Guest User

2.patch

a guest
Sep 29th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 10.17 KB | None | 0 0
  1. diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.c b/target/linux/generic/files/drivers/net/phy/ar8216.c
  2. index 01dc065be1..38ea1471cf 100644
  3. --- a/target/linux/generic/files/drivers/net/phy/ar8216.c
  4. +++ b/target/linux/generic/files/drivers/net/phy/ar8216.c
  5. @@ -539,7 +539,11 @@ ar8216_mangle_rx(struct net_device *dev, struct sk_buff *skb)
  6.     port = buf[0] & 0x7;
  7.  
  8.     /* no need to fix up packets coming from a tagged source */
  9. -   if (priv->vlan_tagged & (1 << port))
  10. +#if OK_PATCH
  11. +   if (priv->vlan_tagged_8216 & (1 << port))
  12. +#else
  13. +   if (priv->vlan_tagged & (1 << port))
  14. +#endif
  15.         return;
  16.  
  17.     /* lookup port vid from local table, the switch passes an invalid vlan id */
  18. @@ -593,9 +597,17 @@ ar8216_vtu_flush(struct ar8xxx_priv *priv)
  19.  }
  20.  
  21.  static void
  22. -ar8216_vtu_load_vlan(struct ar8xxx_priv *priv, u32 vid, u32 port_mask)
  23. -{
  24. -   u32 op;
  25. +#if OK_PATCH
  26. +ar8216_vtu_load_vlan(struct ar8xxx_priv *priv, u32 vlan)
  27. +#else
  28. +ar8216_vtu_load_vlan(struct ar8xxx_priv *priv, u32 vid, u32 port_mask)
  29. +#endif
  30. +{
  31. +   u32 op;
  32. +#if OK_PATCH
  33. +   u32 vid = priv->vlan_id[vlan];
  34. +   u32 port_mask = priv->vlan_table[vlan];
  35. +#endif
  36.  
  37.     op = AR8216_VTU_OP_LOAD | (vid << AR8216_VTU_VID_S);
  38.     ar8216_vtu_op(priv, op, port_mask);
  39. @@ -645,7 +657,11 @@ ar8216_setup_port(struct ar8xxx_priv *priv, int port, u32 members)
  40.  
  41.     if (priv->vlan) {
  42.         pvid = priv->vlan_id[priv->pvid[port]];
  43. +#if OK_PATCH
  44. +       if (priv->vlan_tagged_8216 & (1 << port))
  45. +#else
  46.         if (priv->vlan_tagged & (1 << port))
  47. +#endif
  48.             egress = AR8216_OUT_ADD_VLAN;
  49.         else
  50.             egress = AR8216_OUT_STRIP_VLAN;
  51. @@ -1002,10 +1018,16 @@ ar8xxx_sw_get_port_link(struct switch_dev *dev, int port,
  52.  }
  53.  
  54.  static int
  55. +#if OK_PATCH
  56. +ar8xxx_sw_get_ports(struct switch_val *val, int ports, u8 port_mask, u8 tagged)
  57. +#else
  58.  ar8xxx_sw_get_ports(struct switch_dev *dev, struct switch_val *val)
  59. +#endif
  60.  {
  61. +#if !OK_PATCH
  62.     struct ar8xxx_priv *priv = swdev_to_ar8xxx(dev);
  63.     u8 ports;
  64. +#endif
  65.     int i;
  66.  
  67.     if (val->port_vlan >= AR8X16_MAX_VLANS)
  68. @@ -1013,15 +1035,27 @@ ar8xxx_sw_get_ports(struct switch_dev *dev, struct switch_val *val)
  69.  
  70.     ports = priv->vlan_table[val->port_vlan];
  71.     val->len = 0;
  72. +#if OK_PATCH
  73. +   for (i = 0; i < ports; i++) {
  74. +#else
  75.     for (i = 0; i < dev->ports; i++) {
  76. +#endif
  77.         struct switch_port *p;
  78.  
  79. -       if (!(ports & (1 << i)))
  80. -           continue;
  81. +#if OK_PATCH
  82. +       if (!(port_mask & (1 << i)))
  83. +#else
  84. +       if (!(ports & (1 << i)))
  85. +#endif
  86. +           continue;
  87.  
  88.         p = &val->value.ports[val->len++];
  89.         p->id = i;
  90. -       if (priv->vlan_tagged & (1 << i))
  91. +#if OK_PATCH
  92. +       if (tagged & BIT(i))
  93. +#else
  94. +       if (priv->vlan_tagged & (1 << i))
  95. +#endif
  96.             p->flags = (1 << SWITCH_PORT_FLAG_TAGGED);
  97.         else
  98.             p->flags = 0;
  99. @@ -1034,16 +1068,37 @@ ar8xxx_sw_set_ports(struct switch_dev *dev, struct switch_val *val)
  100.  {
  101.     struct ar8xxx_priv *priv = swdev_to_ar8xxx(dev);
  102.     u8 *vt = &priv->vlan_table[val->port_vlan];
  103. +#if OK_PATCH
  104. +   u8 *tagged = &priv->vlan_tagged_8216;
  105. +#endif
  106.     int i, j;
  107.  
  108.     *vt = 0;
  109.     for (i = 0; i < val->len; i++) {
  110.         struct switch_port *p = &val->value.ports[i];
  111.  
  112. +#if OK_PATCH
  113. +       if (p->flags & BIT(SWITCH_PORT_FLAG_TAGGED)) {
  114. +               /* if port was untagged before then
  115. +                * remove him from other vlans */
  116. +               if(*tagged & BIT(p->id)){
  117. +                       for (j = 0; j < AR8X16_MAX_VLANS; j++) {
  118. +                               if (j == val->port_vlan)
  119. +                                       continue;
  120. +                               priv->vlan_table[j] &= ~(BIT(p->id));
  121. +                       }
  122. +               }
  123. +               *tagged |= BIT(p->id);
  124. +#else
  125.         if (p->flags & (1 << SWITCH_PORT_FLAG_TAGGED)) {
  126.             priv->vlan_tagged |= (1 << p->id);
  127. +#endif
  128.         } else {
  129. +#if OK_PATCH
  130. +           *tagged &= ~(BIT(p->id));
  131. +#else
  132.             priv->vlan_tagged &= ~(1 << p->id);
  133. +#endif
  134.             priv->pvid[p->id] = val->port_vlan;
  135.  
  136.             /* make sure that an untagged port does not
  137. @@ -1060,6 +1115,52 @@ ar8xxx_sw_set_ports(struct switch_dev *dev, struct switch_val *val)
  138.     return 0;
  139.  }
  140.  
  141. +#if OK_PATCH
  142. +static int
  143. +ar8327_sw_set_ports(struct switch_dev *dev, struct switch_val *val)
  144. +{
  145. +    struct ar8216_priv *priv = to_ar8216(dev);
  146. +    u8 *vt = &priv->vlan_table[val->port_vlan];
  147. +    u8 *vlan_tagged = priv->vlan_tagged_8327;
  148. +    u8 *tagged = &vlan_tagged[val->port_vlan];
  149. +    int i;
  150. +    *vt = 0;
  151. +    *tagged = 0;
  152. +    for (i = 0; i < val->len; i++) {
  153. +        struct switch_port *p = &val->value.ports[i];
  154. +        if (p->flags & BIT(SWITCH_PORT_FLAG_TAGGED)) {
  155. +            *tagged |= BIT(p->id);
  156. +        } else {
  157. +            priv->pvid[p->id] = val->port_vlan;
  158. +        }
  159. +        *vt |= BIT(p->id);
  160. +    }
  161. +    return 0;
  162. +}
  163. +
  164. +static int
  165. +ar8216_sw_get_ports(struct switch_dev *dev, struct switch_val *val)
  166. +{
  167. +    int ports = dev->ports;
  168. +    struct ar8216_priv *priv = to_ar8216(dev);
  169. +    u8 port_mask = priv->vlan_table[val->port_vlan];
  170. +    u8 tagged = priv->vlan_tagged_8216;
  171. +
  172. +    return ar8xxx_sw_get_ports(val, ports, port_mask, tagged);
  173. +}
  174. +
  175. +static int
  176. +ar8327_sw_get_ports(struct switch_dev *dev, struct switch_val *val)
  177. +{
  178. +    int ports = dev->ports;
  179. +    struct ar8216_priv *priv = to_ar8216(dev);
  180. +    u8 port_mask = priv->vlan_table[val->port_vlan];
  181. +    u8 tagged = priv->vlan_tagged_8327[val->port_vlan];
  182. +
  183. +    return ar8xxx_sw_get_ports(val, ports, port_mask, tagged);
  184. +}
  185. +#endif
  186. +
  187.  static void
  188.  ar8216_set_mirror_regs(struct ar8xxx_priv *priv)
  189.  {
  190. @@ -1138,9 +1239,12 @@ ar8xxx_sw_hw_apply(struct switch_dev *dev)
  191.                 if (vp & mask)
  192.                     portmask[i] |= vp & ~mask;
  193.             }
  194. -
  195. +#if OK_PATCH
  196. +           chip->vtu_load_vlan(priv, j);
  197. +#else
  198.             chip->vtu_load_vlan(priv, priv->vlan_id[j],
  199.                         priv->vlan_table[j]);
  200. +#endif
  201.         }
  202.     } else {
  203.         /* vlan disabled:
  204. @@ -1698,6 +1802,30 @@ static const struct switch_dev_ops ar8xxx_sw_ops = {
  205.     .get_port_link = ar8xxx_sw_get_port_link,
  206.  };
  207.  
  208. +#if OK_PATCH
  209. +static const struct switch_dev_ops ar8327_sw_ops = {
  210. +   .attr_global = {
  211. +       .attr = ar8xxx_sw_attr_globals,
  212. +       .n_attr = ARRAY_SIZE(ar8xxx_sw_attr_globals),
  213. +   },
  214. +   .attr_port = {
  215. +       .attr = ar8xxx_sw_attr_port,
  216. +       .n_attr = ARRAY_SIZE(ar8xxx_sw_attr_port),
  217. +   },
  218. +   .attr_vlan = {
  219. +       .attr = ar8xxx_sw_attr_vlan,
  220. +       .n_attr = ARRAY_SIZE(ar8xxx_sw_attr_vlan),
  221. +   },
  222. +   .get_port_pvid = ar8xxx_sw_get_pvid,
  223. +   .set_port_pvid = ar8xxx_sw_set_pvid,
  224. +   .get_vlan_ports = ar8327_sw_get_ports,
  225. +   .set_vlan_ports = ar8327_sw_set_ports,
  226. +   .apply_config = ar8xxx_sw_hw_apply,
  227. +   .reset_switch = ar8xxx_sw_reset_switch,
  228. +   .get_port_link = ar8xxx_sw_get_port_link,
  229. +};
  230. +#endif
  231. +
  232.  static const struct ar8xxx_chip ar8216_chip = {
  233.     .caps = AR8XXX_CAP_MIB_COUNTERS,
  234.  
  235. diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.h b/target/linux/generic/files/drivers/net/phy/ar8216.h
  236. index be8c65507e..aa6d58f8c2 100644
  237. --- a/target/linux/generic/files/drivers/net/phy/ar8216.h
  238. +++ b/target/linux/generic/files/drivers/net/phy/ar8216.h
  239. @@ -411,7 +411,11 @@ struct ar8xxx_chip {
  240.     int (*atu_flush)(struct ar8xxx_priv *priv);
  241.     int (*atu_flush_port)(struct ar8xxx_priv *priv, int port);
  242.     void (*vtu_flush)(struct ar8xxx_priv *priv);
  243. -   void (*vtu_load_vlan)(struct ar8xxx_priv *priv, u32 vid, u32 port_mask);
  244. +#if OK_PATCH
  245. +    void (*vtu_load_vlan)(struct ar8xxx_priv *priv, u32 vlan);
  246. +#else
  247. +    void (*vtu_load_vlan)(struct ar8xxx_priv *priv, u32 vid, u32 port_mask);
  248. +#endif
  249.     void (*phy_fixup)(struct ar8xxx_priv *priv, int phy);
  250.     void (*set_mirror_regs)(struct ar8xxx_priv *priv);
  251.     void (*get_arl_entry)(struct ar8xxx_priv *priv, struct arl_entry *a,
  252. @@ -458,7 +462,12 @@ struct ar8xxx_priv {
  253.     bool vlan;
  254.     u16 vlan_id[AR8X16_MAX_VLANS];
  255.     u8 vlan_table[AR8X16_MAX_VLANS];
  256. -   u8 vlan_tagged;
  257. +#if OK_PATCH
  258. +   u8 vlan_tagged_8216;
  259. +   u8 vlan_tagged_8327[AR8X16_MAX_VLANS];
  260. +#else
  261. +   u8 vlan_tagged;
  262. +#endif
  263.     u16 pvid[AR8X16_MAX_PORTS];
  264.     int arl_age_time;
  265.  
  266. diff --git a/target/linux/generic/files/drivers/net/phy/ar8327.c b/target/linux/generic/files/drivers/net/phy/ar8327.c
  267. index 74c80d4452..4dffb3f2b5 100644
  268. --- a/target/linux/generic/files/drivers/net/phy/ar8327.c
  269. +++ b/target/linux/generic/files/drivers/net/phy/ar8327.c
  270. @@ -843,11 +843,20 @@ ar8327_vtu_flush(struct ar8xxx_priv *priv)
  271.  }
  272.  
  273.  static void
  274. -ar8327_vtu_load_vlan(struct ar8xxx_priv *priv, u32 vid, u32 port_mask)
  275. +#if OK_PATCH
  276. +ar8327_vtu_load_vlan(struct ar8xxx_priv *priv, u32 vlan)
  277. +#else
  278. +ar8327_vtu_load_vlan(struct ar8xxx_priv *priv, u32 vid, u32 port_mask)
  279. +#endif
  280.  {
  281.     u32 op;
  282.     u32 val;
  283. -   int i;
  284. +   int i;
  285. +#if OK_PATCH
  286. +   u32 vid = priv->vlan_id[vlan];
  287. +   u32 port_mask = priv->vlan_table[vlan];
  288. +   u32 tagged = priv->vlan_tagged_8327[vlan];
  289. +#endif
  290.  
  291.     op = AR8327_VTU_FUNC1_OP_LOAD | (vid << AR8327_VTU_FUNC1_VID_S);
  292.     val = AR8327_VTU_FUNC0_VALID | AR8327_VTU_FUNC0_IVL;
  293. @@ -858,7 +867,13 @@ ar8327_vtu_load_vlan(struct ar8xxx_priv *priv, u32 vid, u32 port_mask)
  294.             mode = AR8327_VTU_FUNC0_EG_MODE_NOT;
  295.         else if (priv->vlan == 0)
  296.             mode = AR8327_VTU_FUNC0_EG_MODE_KEEP;
  297. -       else if ((priv->vlan_tagged & BIT(i)) || (priv->vlan_id[priv->pvid[i]] != vid))
  298. +#if OK_PATCH
  299. +       else if (tagged & BIT(i))
  300. +#else
  301. +       else if (priv->vlan_tagged & BIT(i))
  302. +#endif
  303. +           mode = AR8327_VTU_FUNC0_EG_MODE_TAG;
  304. +       else if (priv->vlan_id[priv->pvid[i]] != vid)
  305.             mode = AR8327_VTU_FUNC0_EG_MODE_TAG;
  306.         else
  307.             mode = AR8327_VTU_FUNC0_EG_MODE_UNTAG;
  308. @@ -873,8 +888,20 @@ ar8327_setup_port(struct ar8xxx_priv *priv, int port, u32 members)
  309.  {
  310.     u32 t;
  311.     u32 egress, ingress;
  312. -   u32 pvid = priv->vlan_id[priv->pvid[port]];
  313. -
  314. +   u32 pvid;
  315. +
  316. +#if OK_PATCH
  317. +   if (priv->vlan) {
  318. +       pvid = priv->vlan_id[priv->pvid[port]];
  319. +       egress = AR8327_PORT_VLAN1_OUT_MODE_UNMOD;
  320. +       ingress = AR8216_IN_SECURE;
  321. +   } else {
  322. +       pvid = port;
  323. +       egress = AR8327_PORT_VLAN1_OUT_MODE_UNTOUCH;
  324. +       ingress = AR8216_IN_PORT_ONLY;
  325. +   }
  326. +#else
  327. +   pvid = priv->vlan_id[priv->pvid[port]];
  328.     if (priv->vlan) {
  329.         egress = AR8327_PORT_VLAN1_OUT_MODE_UNMOD;
  330.         ingress = AR8216_IN_SECURE;
  331. @@ -882,6 +909,7 @@ ar8327_setup_port(struct ar8xxx_priv *priv, int port, u32 members)
  332.         egress = AR8327_PORT_VLAN1_OUT_MODE_UNTOUCH;
  333.         ingress = AR8216_IN_PORT_ONLY;
  334.     }
  335. +#endif
  336.  
  337.     t = pvid << AR8327_PORT_VLAN0_DEF_SVID_S;
  338.     t |= pvid << AR8327_PORT_VLAN0_DEF_CVID_S;
Add Comment
Please, Sign In to add comment