mediatek: update to latest kernel patchset from v4.13-rc
[openwrt/openwrt.git] / target / linux / mediatek / patches-4.9 / 0031-net-dsa-dsa-api-compat.patch
1 From a319687ac18dcc557a88054282508e061ad8495f Mon Sep 17 00:00:00 2001
2 From: John Crispin <john@phrozen.org>
3 Date: Thu, 10 Aug 2017 14:42:19 +0200
4 Subject: [PATCH 31/57] net: dsa: dsa api compat
5
6 make the latest driver work on the old API
7
8 Signed-off-by: John Crispin <john@phrozen.org>
9 ---
10 drivers/net/dsa/mt7530.c | 14 ++++++++------
11 drivers/net/dsa/mt7530.h | 2 ++
12 net/dsa/tag_mtk.c | 2 +-
13 3 files changed, 11 insertions(+), 7 deletions(-)
14
15 --- a/drivers/net/dsa/mt7530.c
16 +++ b/drivers/net/dsa/mt7530.c
17 @@ -834,6 +834,7 @@ mt7530_port_bridge_join(struct dsa_switc
18 int i;
19
20 mutex_lock(&priv->reg_mutex);
21 + priv->bridge_dev[port] = bridge;
22
23 for (i = 0; i < MT7530_NUM_PORTS; i++) {
24 /* Add this port to the port matrix of the other ports in the
25 @@ -841,7 +842,7 @@ mt7530_port_bridge_join(struct dsa_switc
26 * and not being setup until the port becomes enabled.
27 */
28 if (ds->enabled_port_mask & BIT(i) && i != port) {
29 - if (ds->ports[i].bridge_dev != bridge)
30 + if (priv->bridge_dev[i] != bridge)
31 continue;
32 if (priv->ports[i].enable)
33 mt7530_set(priv, MT7530_PCR_P(i),
34 @@ -864,8 +865,7 @@ mt7530_port_bridge_join(struct dsa_switc
35 }
36
37 static void
38 -mt7530_port_bridge_leave(struct dsa_switch *ds, int port,
39 - struct net_device *bridge)
40 +mt7530_port_bridge_leave(struct dsa_switch *ds, int port)
41 {
42 struct mt7530_priv *priv = ds->priv;
43 int i;
44 @@ -878,7 +878,7 @@ mt7530_port_bridge_leave(struct dsa_swit
45 * is kept and not being setup until the port becomes enabled.
46 */
47 if (ds->enabled_port_mask & BIT(i) && i != port) {
48 - if (ds->ports[i].bridge_dev != bridge)
49 + if (priv->bridge_dev[i] != priv->bridge_dev[port])
50 continue;
51 if (priv->ports[i].enable)
52 mt7530_clear(priv, MT7530_PCR_P(i),
53 @@ -890,6 +890,7 @@ mt7530_port_bridge_leave(struct dsa_swit
54 /* Set the cpu port to be the only one in the port matrix of
55 * this port.
56 */
57 + priv->bridge_dev[port] = NULL;
58 if (priv->ports[port].enable)
59 mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK,
60 PCR_MATRIX(BIT(MT7530_CPU_PORT)));
61 @@ -1033,7 +1034,7 @@ mt7530_probe(struct mdio_device *mdiodev
62 if (!priv)
63 return -ENOMEM;
64
65 - priv->ds = dsa_switch_alloc(&mdiodev->dev, DSA_MAX_PORTS);
66 + priv->ds = devm_kzalloc(&mdiodev->dev, sizeof(*priv->ds), GFP_KERNEL);
67 if (!priv->ds)
68 return -ENOMEM;
69
70 @@ -1076,12 +1077,13 @@ mt7530_probe(struct mdio_device *mdiodev
71 priv->bus = mdiodev->bus;
72 priv->dev = &mdiodev->dev;
73 priv->ds->priv = priv;
74 + priv->ds->dev = &mdiodev->dev;
75 priv->ds->ops = &mt7530_switch_ops;
76 mutex_init(&priv->reg_mutex);
77 lpriv = priv;
78 dev_set_drvdata(&mdiodev->dev, priv);
79
80 - return dsa_register_switch(priv->ds, &mdiodev->dev);
81 + return dsa_register_switch(priv->ds, priv->ds->dev->of_node);
82 }
83
84 static void
85 --- a/drivers/net/dsa/mt7530.h
86 +++ b/drivers/net/dsa/mt7530.h
87 @@ -379,6 +379,8 @@ struct mt7530_priv {
88 struct mt7530_port ports[MT7530_NUM_PORTS];
89 /* protect among processes for registers access*/
90 struct mutex reg_mutex;
91 +
92 + struct net_device *bridge_dev[MT7530_NUM_PORTS];
93 };
94
95 struct mt7530_hw_stats {
96 --- a/net/dsa/tag_mtk.c
97 +++ b/net/dsa/tag_mtk.c
98 @@ -35,7 +35,7 @@ static struct sk_buff *mtk_tag_xmit(stru
99 /* Build the tag after the MAC Source Address */
100 mtk_tag = skb->data + 2 * ETH_ALEN;
101 mtk_tag[0] = 0;
102 - mtk_tag[1] = (1 << p->dp->index) & MTK_HDR_XMIT_DP_BIT_MASK;
103 + mtk_tag[1] = (1 << p->port) & MTK_HDR_XMIT_DP_BIT_MASK;
104 mtk_tag[2] = 0;
105 mtk_tag[3] = 0;
106