Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.c b/target/linux/generic/files/drivers/net/phy/ar8216.c
- index 01dc065be1..38ea1471cf 100644
- --- a/target/linux/generic/files/drivers/net/phy/ar8216.c
- +++ b/target/linux/generic/files/drivers/net/phy/ar8216.c
- @@ -539,7 +539,11 @@ ar8216_mangle_rx(struct net_device *dev, struct sk_buff *skb)
- port = buf[0] & 0x7;
- /* no need to fix up packets coming from a tagged source */
- - if (priv->vlan_tagged & (1 << port))
- +#if OK_PATCH
- + if (priv->vlan_tagged_8216 & (1 << port))
- +#else
- + if (priv->vlan_tagged & (1 << port))
- +#endif
- return;
- /* lookup port vid from local table, the switch passes an invalid vlan id */
- @@ -593,9 +597,17 @@ ar8216_vtu_flush(struct ar8xxx_priv *priv)
- }
- static void
- -ar8216_vtu_load_vlan(struct ar8xxx_priv *priv, u32 vid, u32 port_mask)
- -{
- - u32 op;
- +#if OK_PATCH
- +ar8216_vtu_load_vlan(struct ar8xxx_priv *priv, u32 vlan)
- +#else
- +ar8216_vtu_load_vlan(struct ar8xxx_priv *priv, u32 vid, u32 port_mask)
- +#endif
- +{
- + u32 op;
- +#if OK_PATCH
- + u32 vid = priv->vlan_id[vlan];
- + u32 port_mask = priv->vlan_table[vlan];
- +#endif
- op = AR8216_VTU_OP_LOAD | (vid << AR8216_VTU_VID_S);
- ar8216_vtu_op(priv, op, port_mask);
- @@ -645,7 +657,11 @@ ar8216_setup_port(struct ar8xxx_priv *priv, int port, u32 members)
- if (priv->vlan) {
- pvid = priv->vlan_id[priv->pvid[port]];
- +#if OK_PATCH
- + if (priv->vlan_tagged_8216 & (1 << port))
- +#else
- if (priv->vlan_tagged & (1 << port))
- +#endif
- egress = AR8216_OUT_ADD_VLAN;
- else
- egress = AR8216_OUT_STRIP_VLAN;
- @@ -1002,10 +1018,16 @@ ar8xxx_sw_get_port_link(struct switch_dev *dev, int port,
- }
- static int
- +#if OK_PATCH
- +ar8xxx_sw_get_ports(struct switch_val *val, int ports, u8 port_mask, u8 tagged)
- +#else
- ar8xxx_sw_get_ports(struct switch_dev *dev, struct switch_val *val)
- +#endif
- {
- +#if !OK_PATCH
- struct ar8xxx_priv *priv = swdev_to_ar8xxx(dev);
- u8 ports;
- +#endif
- int i;
- if (val->port_vlan >= AR8X16_MAX_VLANS)
- @@ -1013,15 +1035,27 @@ ar8xxx_sw_get_ports(struct switch_dev *dev, struct switch_val *val)
- ports = priv->vlan_table[val->port_vlan];
- val->len = 0;
- +#if OK_PATCH
- + for (i = 0; i < ports; i++) {
- +#else
- for (i = 0; i < dev->ports; i++) {
- +#endif
- struct switch_port *p;
- - if (!(ports & (1 << i)))
- - continue;
- +#if OK_PATCH
- + if (!(port_mask & (1 << i)))
- +#else
- + if (!(ports & (1 << i)))
- +#endif
- + continue;
- p = &val->value.ports[val->len++];
- p->id = i;
- - if (priv->vlan_tagged & (1 << i))
- +#if OK_PATCH
- + if (tagged & BIT(i))
- +#else
- + if (priv->vlan_tagged & (1 << i))
- +#endif
- p->flags = (1 << SWITCH_PORT_FLAG_TAGGED);
- else
- p->flags = 0;
- @@ -1034,16 +1068,37 @@ ar8xxx_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];
- +#if OK_PATCH
- + u8 *tagged = &priv->vlan_tagged_8216;
- +#endif
- int i, j;
- *vt = 0;
- for (i = 0; i < val->len; i++) {
- struct switch_port *p = &val->value.ports[i];
- +#if OK_PATCH
- + if (p->flags & BIT(SWITCH_PORT_FLAG_TAGGED)) {
- + /* if port was untagged before then
- + * remove him from other vlans */
- + if(*tagged & BIT(p->id)){
- + for (j = 0; j < AR8X16_MAX_VLANS; j++) {
- + if (j == val->port_vlan)
- + continue;
- + priv->vlan_table[j] &= ~(BIT(p->id));
- + }
- + }
- + *tagged |= BIT(p->id);
- +#else
- if (p->flags & (1 << SWITCH_PORT_FLAG_TAGGED)) {
- priv->vlan_tagged |= (1 << p->id);
- +#endif
- } else {
- +#if OK_PATCH
- + *tagged &= ~(BIT(p->id));
- +#else
- priv->vlan_tagged &= ~(1 << p->id);
- +#endif
- priv->pvid[p->id] = val->port_vlan;
- /* make sure that an untagged port does not
- @@ -1060,6 +1115,52 @@ ar8xxx_sw_set_ports(struct switch_dev *dev, struct switch_val *val)
- return 0;
- }
- +#if OK_PATCH
- +static int
- +ar8327_sw_set_ports(struct switch_dev *dev, struct switch_val *val)
- +{
- + struct ar8216_priv *priv = to_ar8216(dev);
- + u8 *vt = &priv->vlan_table[val->port_vlan];
- + u8 *vlan_tagged = priv->vlan_tagged_8327;
- + u8 *tagged = &vlan_tagged[val->port_vlan];
- + int i;
- + *vt = 0;
- + *tagged = 0;
- + for (i = 0; i < val->len; i++) {
- + struct switch_port *p = &val->value.ports[i];
- + if (p->flags & BIT(SWITCH_PORT_FLAG_TAGGED)) {
- + *tagged |= BIT(p->id);
- + } else {
- + priv->pvid[p->id] = val->port_vlan;
- + }
- + *vt |= BIT(p->id);
- + }
- + return 0;
- +}
- +
- +static int
- +ar8216_sw_get_ports(struct switch_dev *dev, struct switch_val *val)
- +{
- + int ports = dev->ports;
- + struct ar8216_priv *priv = to_ar8216(dev);
- + u8 port_mask = priv->vlan_table[val->port_vlan];
- + u8 tagged = priv->vlan_tagged_8216;
- +
- + return ar8xxx_sw_get_ports(val, ports, port_mask, tagged);
- +}
- +
- +static int
- +ar8327_sw_get_ports(struct switch_dev *dev, struct switch_val *val)
- +{
- + int ports = dev->ports;
- + struct ar8216_priv *priv = to_ar8216(dev);
- + u8 port_mask = priv->vlan_table[val->port_vlan];
- + u8 tagged = priv->vlan_tagged_8327[val->port_vlan];
- +
- + return ar8xxx_sw_get_ports(val, ports, port_mask, tagged);
- +}
- +#endif
- +
- static void
- ar8216_set_mirror_regs(struct ar8xxx_priv *priv)
- {
- @@ -1138,9 +1239,12 @@ ar8xxx_sw_hw_apply(struct switch_dev *dev)
- if (vp & mask)
- portmask[i] |= vp & ~mask;
- }
- -
- +#if OK_PATCH
- + chip->vtu_load_vlan(priv, j);
- +#else
- chip->vtu_load_vlan(priv, priv->vlan_id[j],
- priv->vlan_table[j]);
- +#endif
- }
- } else {
- /* vlan disabled:
- @@ -1698,6 +1802,30 @@ static const struct switch_dev_ops ar8xxx_sw_ops = {
- .get_port_link = ar8xxx_sw_get_port_link,
- };
- +#if OK_PATCH
- +static const struct switch_dev_ops ar8327_sw_ops = {
- + .attr_global = {
- + .attr = ar8xxx_sw_attr_globals,
- + .n_attr = ARRAY_SIZE(ar8xxx_sw_attr_globals),
- + },
- + .attr_port = {
- + .attr = ar8xxx_sw_attr_port,
- + .n_attr = ARRAY_SIZE(ar8xxx_sw_attr_port),
- + },
- + .attr_vlan = {
- + .attr = ar8xxx_sw_attr_vlan,
- + .n_attr = ARRAY_SIZE(ar8xxx_sw_attr_vlan),
- + },
- + .get_port_pvid = ar8xxx_sw_get_pvid,
- + .set_port_pvid = ar8xxx_sw_set_pvid,
- + .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,
- +};
- +#endif
- +
- static const struct ar8xxx_chip ar8216_chip = {
- .caps = AR8XXX_CAP_MIB_COUNTERS,
- diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.h b/target/linux/generic/files/drivers/net/phy/ar8216.h
- index be8c65507e..aa6d58f8c2 100644
- --- a/target/linux/generic/files/drivers/net/phy/ar8216.h
- +++ b/target/linux/generic/files/drivers/net/phy/ar8216.h
- @@ -411,7 +411,11 @@ struct ar8xxx_chip {
- int (*atu_flush)(struct ar8xxx_priv *priv);
- int (*atu_flush_port)(struct ar8xxx_priv *priv, int port);
- void (*vtu_flush)(struct ar8xxx_priv *priv);
- - void (*vtu_load_vlan)(struct ar8xxx_priv *priv, u32 vid, u32 port_mask);
- +#if OK_PATCH
- + void (*vtu_load_vlan)(struct ar8xxx_priv *priv, u32 vlan);
- +#else
- + void (*vtu_load_vlan)(struct ar8xxx_priv *priv, u32 vid, u32 port_mask);
- +#endif
- void (*phy_fixup)(struct ar8xxx_priv *priv, int phy);
- void (*set_mirror_regs)(struct ar8xxx_priv *priv);
- void (*get_arl_entry)(struct ar8xxx_priv *priv, struct arl_entry *a,
- @@ -458,7 +462,12 @@ struct ar8xxx_priv {
- bool vlan;
- u16 vlan_id[AR8X16_MAX_VLANS];
- u8 vlan_table[AR8X16_MAX_VLANS];
- - u8 vlan_tagged;
- +#if OK_PATCH
- + u8 vlan_tagged_8216;
- + u8 vlan_tagged_8327[AR8X16_MAX_VLANS];
- +#else
- + u8 vlan_tagged;
- +#endif
- u16 pvid[AR8X16_MAX_PORTS];
- int arl_age_time;
- diff --git a/target/linux/generic/files/drivers/net/phy/ar8327.c b/target/linux/generic/files/drivers/net/phy/ar8327.c
- index 74c80d4452..4dffb3f2b5 100644
- --- a/target/linux/generic/files/drivers/net/phy/ar8327.c
- +++ b/target/linux/generic/files/drivers/net/phy/ar8327.c
- @@ -843,11 +843,20 @@ ar8327_vtu_flush(struct ar8xxx_priv *priv)
- }
- static void
- -ar8327_vtu_load_vlan(struct ar8xxx_priv *priv, u32 vid, u32 port_mask)
- +#if OK_PATCH
- +ar8327_vtu_load_vlan(struct ar8xxx_priv *priv, u32 vlan)
- +#else
- +ar8327_vtu_load_vlan(struct ar8xxx_priv *priv, u32 vid, u32 port_mask)
- +#endif
- {
- u32 op;
- u32 val;
- - int i;
- + int i;
- +#if OK_PATCH
- + u32 vid = priv->vlan_id[vlan];
- + u32 port_mask = priv->vlan_table[vlan];
- + u32 tagged = priv->vlan_tagged_8327[vlan];
- +#endif
- op = AR8327_VTU_FUNC1_OP_LOAD | (vid << AR8327_VTU_FUNC1_VID_S);
- val = AR8327_VTU_FUNC0_VALID | AR8327_VTU_FUNC0_IVL;
- @@ -858,7 +867,13 @@ 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)) || (priv->vlan_id[priv->pvid[i]] != vid))
- +#if OK_PATCH
- + else if (tagged & BIT(i))
- +#else
- + else if (priv->vlan_tagged & BIT(i))
- +#endif
- + mode = AR8327_VTU_FUNC0_EG_MODE_TAG;
- + else if (priv->vlan_id[priv->pvid[i]] != vid)
- mode = AR8327_VTU_FUNC0_EG_MODE_TAG;
- else
- mode = AR8327_VTU_FUNC0_EG_MODE_UNTAG;
- @@ -873,8 +888,20 @@ ar8327_setup_port(struct ar8xxx_priv *priv, int port, u32 members)
- {
- u32 t;
- u32 egress, ingress;
- - u32 pvid = priv->vlan_id[priv->pvid[port]];
- -
- + u32 pvid;
- +
- +#if OK_PATCH
- + 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;
- + }
- +#else
- + pvid = priv->vlan_id[priv->pvid[port]];
- if (priv->vlan) {
- egress = AR8327_PORT_VLAN1_OUT_MODE_UNMOD;
- ingress = AR8216_IN_SECURE;
- @@ -882,6 +909,7 @@ ar8327_setup_port(struct ar8xxx_priv *priv, int port, u32 members)
- egress = AR8327_PORT_VLAN1_OUT_MODE_UNTOUCH;
- ingress = AR8216_IN_PORT_ONLY;
- }
- +#endif
- t = pvid << AR8327_PORT_VLAN0_DEF_SVID_S;
- t |= pvid << AR8327_PORT_VLAN0_DEF_CVID_S;
Add Comment
Please, Sign In to add comment