ar8216: support tagged an untagged ports
patchset created with gluon tools
This commit is contained in:
parent
57f788f276
commit
48fb28d8a7
2574
patches/openwrt/0025-ar8216-support-tagged-an-untagged-ports.patch
Normal file
2574
patches/openwrt/0025-ar8216-support-tagged-an-untagged-ports.patch
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,223 +0,0 @@
|
||||
diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.c b/target/linux/generic/files/drivers/net/phy/ar8216.c
|
||||
index 3846159..bd6cc97 100644
|
||||
--- a/target/linux/generic/files/drivers/net/phy/ar8216.c
|
||||
+++ b/target/linux/generic/files/drivers/net/phy/ar8216.c
|
||||
@@ -73,8 +73,7 @@ struct ar8xxx_chip {
|
||||
|
||||
void (*init_globals)(struct ar8xxx_priv *priv);
|
||||
void (*init_port)(struct ar8xxx_priv *priv, int port);
|
||||
- void (*setup_port)(struct ar8xxx_priv *priv, int port, u32 egress,
|
||||
- u32 ingress, u32 members, u32 pvid);
|
||||
+ void (*setup_port)(struct ar8xxx_priv *priv, int port, u32 members);
|
||||
u32 (*read_port_status)(struct ar8xxx_priv *priv, int port);
|
||||
int (*atu_flush)(struct ar8xxx_priv *priv);
|
||||
void (*vtu_flush)(struct ar8xxx_priv *priv);
|
||||
@@ -722,10 +721,24 @@ ar8216_read_port_status(struct ar8xxx_priv *priv, int port)
|
||||
}
|
||||
|
||||
static void
|
||||
-ar8216_setup_port(struct ar8xxx_priv *priv, int port, u32 egress, u32 ingress,
|
||||
- u32 members, u32 pvid)
|
||||
+ar8216_setup_port(struct ar8xxx_priv *priv, int port, u32 members)
|
||||
{
|
||||
u32 header;
|
||||
+ u32 egress, ingress;
|
||||
+ u32 pvid;
|
||||
+
|
||||
+ if (priv->vlan) {
|
||||
+ pvid = priv->vlan_id[priv->pvid[port]];
|
||||
+ if (priv->vlan_tagged & (1 << port))
|
||||
+ egress = AR8216_OUT_ADD_VLAN;
|
||||
+ else
|
||||
+ egress = AR8216_OUT_STRIP_VLAN;
|
||||
+ ingress = AR8216_IN_SECURE;
|
||||
+ } else {
|
||||
+ pvid = port;
|
||||
+ egress = AR8216_OUT_KEEP;
|
||||
+ ingress = AR8216_IN_PORT_ONLY;
|
||||
+ }
|
||||
|
||||
if (chip_is_ar8216(priv) && priv->vlan && port == AR8216_PORT_CPU)
|
||||
header = AR8216_PORT_CTRL_HEADER;
|
||||
@@ -807,9 +820,24 @@ static const struct ar8xxx_chip ar8216_chip = {
|
||||
};
|
||||
|
||||
static void
|
||||
-ar8236_setup_port(struct ar8xxx_priv *priv, int port, u32 egress, u32 ingress,
|
||||
- u32 members, u32 pvid)
|
||||
+ar8236_setup_port(struct ar8xxx_priv *priv, int port, u32 members)
|
||||
{
|
||||
+ u32 egress, ingress;
|
||||
+ u32 pvid;
|
||||
+
|
||||
+ if (priv->vlan) {
|
||||
+ pvid = priv->vlan_id[priv->pvid[port]];
|
||||
+ if (priv->vlan_tagged & (1 << port))
|
||||
+ egress = AR8216_OUT_ADD_VLAN;
|
||||
+ else
|
||||
+ egress = AR8216_OUT_STRIP_VLAN;
|
||||
+ ingress = AR8216_IN_SECURE;
|
||||
+ } else {
|
||||
+ pvid = port;
|
||||
+ egress = AR8216_OUT_KEEP;
|
||||
+ ingress = AR8216_IN_PORT_ONLY;
|
||||
+ }
|
||||
+
|
||||
ar8xxx_rmw(priv, AR8216_REG_PORT_CTRL(port),
|
||||
AR8216_PORT_CTRL_LEARN | AR8216_PORT_CTRL_VLAN_MODE |
|
||||
AR8216_PORT_CTRL_SINGLE_VLAN | AR8216_PORT_CTRL_STATE |
|
||||
@@ -1720,7 +1748,7 @@ ar8327_vtu_load_vlan(struct ar8xxx_priv *priv, u32 vid, u32 port_mask)
|
||||
mode = AR8327_VTU_FUNC0_EG_MODE_NOT;
|
||||
else if (priv->vlan == 0)
|
||||
mode = AR8327_VTU_FUNC0_EG_MODE_KEEP;
|
||||
- else if (priv->vlan_tagged & BIT(i))
|
||||
+ else if ((priv->vlan_tagged & BIT(i)) || (priv->vlan_id[priv->pvid[i]] != vid))
|
||||
mode = AR8327_VTU_FUNC0_EG_MODE_TAG;
|
||||
else
|
||||
mode = AR8327_VTU_FUNC0_EG_MODE_UNTAG;
|
||||
@@ -1731,31 +1759,28 @@ ar8327_vtu_load_vlan(struct ar8xxx_priv *priv, u32 vid, u32 port_mask)
|
||||
}
|
||||
|
||||
static void
|
||||
-ar8327_setup_port(struct ar8xxx_priv *priv, int port, u32 egress, u32 ingress,
|
||||
- u32 members, u32 pvid)
|
||||
+ar8327_setup_port(struct ar8xxx_priv *priv, int port, u32 members)
|
||||
{
|
||||
u32 t;
|
||||
- u32 mode;
|
||||
+ u32 egress, ingress;
|
||||
+ u32 pvid;
|
||||
+
|
||||
+ if (priv->vlan) {
|
||||
+ pvid = priv->vlan_id[priv->pvid[port]];
|
||||
+ egress = AR8327_PORT_VLAN1_OUT_MODE_UNMOD;
|
||||
+ ingress = AR8216_IN_SECURE;
|
||||
+ } else {
|
||||
+ pvid = port;
|
||||
+ egress = AR8327_PORT_VLAN1_OUT_MODE_UNTOUCH;
|
||||
+ ingress = AR8216_IN_PORT_ONLY;
|
||||
+ }
|
||||
|
||||
t = pvid << AR8327_PORT_VLAN0_DEF_SVID_S;
|
||||
t |= pvid << AR8327_PORT_VLAN0_DEF_CVID_S;
|
||||
priv->write(priv, AR8327_REG_PORT_VLAN0(port), t);
|
||||
|
||||
- mode = AR8327_PORT_VLAN1_OUT_MODE_UNMOD;
|
||||
- switch (egress) {
|
||||
- case AR8216_OUT_KEEP:
|
||||
- mode = AR8327_PORT_VLAN1_OUT_MODE_UNTOUCH;
|
||||
- break;
|
||||
- case AR8216_OUT_STRIP_VLAN:
|
||||
- mode = AR8327_PORT_VLAN1_OUT_MODE_UNTAG;
|
||||
- break;
|
||||
- case AR8216_OUT_ADD_VLAN:
|
||||
- mode = AR8327_PORT_VLAN1_OUT_MODE_TAG;
|
||||
- break;
|
||||
- }
|
||||
-
|
||||
t = AR8327_PORT_VLAN1_PORT_VLAN_PROP;
|
||||
- t |= mode << AR8327_PORT_VLAN1_OUT_MODE_S;
|
||||
+ t |= egress << AR8327_PORT_VLAN1_OUT_MODE_S;
|
||||
priv->write(priv, AR8327_REG_PORT_VLAN1(port), t);
|
||||
|
||||
t = members;
|
||||
@@ -1875,6 +1900,30 @@ ar8xxx_sw_get_ports(struct switch_dev *dev, struct switch_val *val)
|
||||
}
|
||||
|
||||
static int
|
||||
+ar8327_sw_get_ports(struct switch_dev *dev, struct switch_val *val)
|
||||
+{
|
||||
+ struct ar8xxx_priv *priv = swdev_to_ar8xxx(dev);
|
||||
+ u8 ports = priv->vlan_table[val->port_vlan];
|
||||
+ int i;
|
||||
+
|
||||
+ val->len = 0;
|
||||
+ for (i = 0; i < dev->ports; i++) {
|
||||
+ struct switch_port *p;
|
||||
+
|
||||
+ if (!(ports & (1 << i)))
|
||||
+ continue;
|
||||
+
|
||||
+ p = &val->value.ports[val->len++];
|
||||
+ p->id = i;
|
||||
+ if ((priv->vlan_tagged & (1 << i)) || (priv->pvid[i] != val->port_vlan))
|
||||
+ p->flags = (1 << SWITCH_PORT_FLAG_TAGGED);
|
||||
+ else
|
||||
+ p->flags = 0;
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
ar8xxx_sw_set_ports(struct switch_dev *dev, struct switch_val *val)
|
||||
{
|
||||
struct ar8xxx_priv *priv = swdev_to_ar8xxx(dev);
|
||||
@@ -1905,6 +1954,31 @@ ar8xxx_sw_set_ports(struct switch_dev *dev, struct switch_val *val)
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static int
|
||||
+ar8327_sw_set_ports(struct switch_dev *dev, struct switch_val *val)
|
||||
+{
|
||||
+ struct ar8xxx_priv *priv = swdev_to_ar8xxx(dev);
|
||||
+ u8 *vt = &priv->vlan_table[val->port_vlan];
|
||||
+ int i, j;
|
||||
+
|
||||
+ *vt = 0;
|
||||
+ for (i = 0; i < val->len; i++) {
|
||||
+ struct switch_port *p = &val->value.ports[i];
|
||||
+
|
||||
+ if (p->flags & (1 << SWITCH_PORT_FLAG_TAGGED)) {
|
||||
+ if (val->port_vlan == priv->pvid[p->id]) {
|
||||
+ priv->vlan_tagged |= (1 << p->id);
|
||||
+ }
|
||||
+ } else {
|
||||
+ priv->vlan_tagged &= ~(1 << p->id);
|
||||
+ priv->pvid[p->id] = val->port_vlan;
|
||||
+ }
|
||||
+
|
||||
+ *vt |= 1 << p->id;
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static void
|
||||
ar8327_set_mirror_regs(struct ar8xxx_priv *priv)
|
||||
{
|
||||
@@ -2041,24 +2115,7 @@ ar8xxx_sw_hw_apply(struct switch_dev *dev)
|
||||
|
||||
/* update the port destination mask registers and tag settings */
|
||||
for (i = 0; i < dev->ports; i++) {
|
||||
- int egress, ingress;
|
||||
- int pvid;
|
||||
-
|
||||
- if (priv->vlan) {
|
||||
- pvid = priv->vlan_id[priv->pvid[i]];
|
||||
- if (priv->vlan_tagged & (1 << i))
|
||||
- egress = AR8216_OUT_ADD_VLAN;
|
||||
- else
|
||||
- egress = AR8216_OUT_STRIP_VLAN;
|
||||
- ingress = AR8216_IN_SECURE;
|
||||
- } else {
|
||||
- pvid = i;
|
||||
- egress = AR8216_OUT_KEEP;
|
||||
- ingress = AR8216_IN_PORT_ONLY;
|
||||
- }
|
||||
-
|
||||
- priv->chip->setup_port(priv, i, egress, ingress, portmask[i],
|
||||
- pvid);
|
||||
+ priv->chip->setup_port(priv, i, portmask[i]);
|
||||
}
|
||||
|
||||
ar8xxx_set_mirror_regs(priv);
|
||||
@@ -2464,8 +2521,8 @@ static const struct switch_dev_ops ar8327_sw_ops = {
|
||||
},
|
||||
.get_port_pvid = ar8xxx_sw_get_pvid,
|
||||
.set_port_pvid = ar8xxx_sw_set_pvid,
|
||||
- .get_vlan_ports = ar8xxx_sw_get_ports,
|
||||
- .set_vlan_ports = ar8xxx_sw_set_ports,
|
||||
+ .get_vlan_ports = ar8327_sw_get_ports,
|
||||
+ .set_vlan_ports = ar8327_sw_set_ports,
|
||||
.apply_config = ar8xxx_sw_hw_apply,
|
||||
.reset_switch = ar8xxx_sw_reset_switch,
|
||||
.get_port_link = ar8xxx_sw_get_port_link,
|
Loading…
Reference in New Issue
Block a user