9338120fd4cabc78ebf16b991eb4b004a9a82c7e
[openwrt/staging/nbd.git] /
1 From b0481fbc0d853fd164055293002c621827eba5ad Mon Sep 17 00:00:00 2001
2 From: Vladimir Oltean <vladimir.oltean@nxp.com>
3 Date: Sat, 9 Nov 2019 15:02:53 +0200
4 Subject: [PATCH] net: mscc: ocelot: separate net_device related items out of
5 ocelot_port
6
7 The ocelot and ocelot_port structures will be used by a new DSA driver,
8 so the ocelot_board.c file will have to allocate and work with a private
9 structure (ocelot_port_private), which embeds the generic struct
10 ocelot_port. This is because in DSA, at least one interface does not
11 have a net_device, and the DSA driver API does not interact with that
12 anyway.
13
14 The ocelot_port structure is equivalent to dsa_port, and ocelot to
15 dsa_switch. The members of ocelot_port which have an equivalent in
16 dsa_port (such as dp->vlan_filtering) have been moved to
17 ocelot_port_private.
18
19 We want to enforce the coding convention that "ocelot_port" refers to
20 the structure, and "port" refers to the integer index. One can retrieve
21 the structure at any time from ocelot->ports[port].
22
23 The patch is large but only contains variable renaming and mechanical
24 movement of fields from one structure to another.
25
26 Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
27 Signed-off-by: David S. Miller <davem@davemloft.net>
28 ---
29 drivers/net/ethernet/mscc/ocelot.c | 288 ++++++++++++++++--------------
30 drivers/net/ethernet/mscc/ocelot.h | 21 ++-
31 drivers/net/ethernet/mscc/ocelot_ace.h | 4 +-
32 drivers/net/ethernet/mscc/ocelot_board.c | 25 ++-
33 drivers/net/ethernet/mscc/ocelot_flower.c | 32 ++--
34 drivers/net/ethernet/mscc/ocelot_tc.c | 57 +++---
35 6 files changed, 235 insertions(+), 192 deletions(-)
36
37 --- a/drivers/net/ethernet/mscc/ocelot.c
38 +++ b/drivers/net/ethernet/mscc/ocelot.c
39 @@ -229,8 +229,6 @@ static void ocelot_port_vlan_filtering(s
40 ocelot_rmw_gix(ocelot, val,
41 REW_TAG_CFG_TAG_CFG_M,
42 REW_TAG_CFG, port);
43 -
44 - ocelot_port->vlan_aware = vlan_aware;
45 }
46
47 static int ocelot_port_set_native_vlan(struct ocelot *ocelot, int port,
48 @@ -297,9 +295,10 @@ static int ocelot_vlan_add(struct ocelot
49 static int ocelot_vlan_vid_add(struct net_device *dev, u16 vid, bool pvid,
50 bool untagged)
51 {
52 - struct ocelot_port *ocelot_port = netdev_priv(dev);
53 + struct ocelot_port_private *priv = netdev_priv(dev);
54 + struct ocelot_port *ocelot_port = &priv->port;
55 struct ocelot *ocelot = ocelot_port->ocelot;
56 - int port = ocelot_port->chip_port;
57 + int port = priv->chip_port;
58 int ret;
59
60 ret = ocelot_vlan_add(ocelot, port, vid, pvid, untagged);
61 @@ -337,9 +336,9 @@ static int ocelot_vlan_del(struct ocelot
62
63 static int ocelot_vlan_vid_del(struct net_device *dev, u16 vid)
64 {
65 - struct ocelot_port *ocelot_port = netdev_priv(dev);
66 - struct ocelot *ocelot = ocelot_port->ocelot;
67 - int port = ocelot_port->chip_port;
68 + struct ocelot_port_private *priv = netdev_priv(dev);
69 + struct ocelot *ocelot = priv->port.ocelot;
70 + int port = priv->chip_port;
71 int ret;
72
73 /* 8021q removes VID 0 on module unload for all interfaces
74 @@ -412,10 +411,11 @@ static u16 ocelot_wm_enc(u16 value)
75
76 static void ocelot_port_adjust_link(struct net_device *dev)
77 {
78 - struct ocelot_port *port = netdev_priv(dev);
79 - struct ocelot *ocelot = port->ocelot;
80 - u8 p = port->chip_port;
81 + struct ocelot_port_private *priv = netdev_priv(dev);
82 + struct ocelot_port *ocelot_port = &priv->port;
83 + struct ocelot *ocelot = ocelot_port->ocelot;
84 int speed, atop_wm, mode = 0;
85 + u8 port = priv->chip_port;
86
87 switch (dev->phydev->speed) {
88 case SPEED_10:
89 @@ -444,62 +444,66 @@ static void ocelot_port_adjust_link(stru
90 return;
91
92 /* Only full duplex supported for now */
93 - ocelot_port_writel(port, DEV_MAC_MODE_CFG_FDX_ENA |
94 + ocelot_port_writel(ocelot_port, DEV_MAC_MODE_CFG_FDX_ENA |
95 mode, DEV_MAC_MODE_CFG);
96
97 /* Set MAC IFG Gaps
98 * FDX: TX_IFG = 5, RX_IFG1 = RX_IFG2 = 0
99 * !FDX: TX_IFG = 5, RX_IFG1 = RX_IFG2 = 5
100 */
101 - ocelot_port_writel(port, DEV_MAC_IFG_CFG_TX_IFG(5), DEV_MAC_IFG_CFG);
102 + ocelot_port_writel(ocelot_port, DEV_MAC_IFG_CFG_TX_IFG(5),
103 + DEV_MAC_IFG_CFG);
104
105 /* Load seed (0) and set MAC HDX late collision */
106 - ocelot_port_writel(port, DEV_MAC_HDX_CFG_LATE_COL_POS(67) |
107 + ocelot_port_writel(ocelot_port, DEV_MAC_HDX_CFG_LATE_COL_POS(67) |
108 DEV_MAC_HDX_CFG_SEED_LOAD,
109 DEV_MAC_HDX_CFG);
110 mdelay(1);
111 - ocelot_port_writel(port, DEV_MAC_HDX_CFG_LATE_COL_POS(67),
112 + ocelot_port_writel(ocelot_port, DEV_MAC_HDX_CFG_LATE_COL_POS(67),
113 DEV_MAC_HDX_CFG);
114
115 /* Disable HDX fast control */
116 - ocelot_port_writel(port, DEV_PORT_MISC_HDX_FAST_DIS, DEV_PORT_MISC);
117 + ocelot_port_writel(ocelot_port, DEV_PORT_MISC_HDX_FAST_DIS,
118 + DEV_PORT_MISC);
119
120 /* SGMII only for now */
121 - ocelot_port_writel(port, PCS1G_MODE_CFG_SGMII_MODE_ENA, PCS1G_MODE_CFG);
122 - ocelot_port_writel(port, PCS1G_SD_CFG_SD_SEL, PCS1G_SD_CFG);
123 + ocelot_port_writel(ocelot_port, PCS1G_MODE_CFG_SGMII_MODE_ENA,
124 + PCS1G_MODE_CFG);
125 + ocelot_port_writel(ocelot_port, PCS1G_SD_CFG_SD_SEL, PCS1G_SD_CFG);
126
127 /* Enable PCS */
128 - ocelot_port_writel(port, PCS1G_CFG_PCS_ENA, PCS1G_CFG);
129 + ocelot_port_writel(ocelot_port, PCS1G_CFG_PCS_ENA, PCS1G_CFG);
130
131 /* No aneg on SGMII */
132 - ocelot_port_writel(port, 0, PCS1G_ANEG_CFG);
133 + ocelot_port_writel(ocelot_port, 0, PCS1G_ANEG_CFG);
134
135 /* No loopback */
136 - ocelot_port_writel(port, 0, PCS1G_LB_CFG);
137 + ocelot_port_writel(ocelot_port, 0, PCS1G_LB_CFG);
138
139 /* Set Max Length and maximum tags allowed */
140 - ocelot_port_writel(port, VLAN_ETH_FRAME_LEN, DEV_MAC_MAXLEN_CFG);
141 - ocelot_port_writel(port, DEV_MAC_TAGS_CFG_TAG_ID(ETH_P_8021AD) |
142 + ocelot_port_writel(ocelot_port, VLAN_ETH_FRAME_LEN,
143 + DEV_MAC_MAXLEN_CFG);
144 + ocelot_port_writel(ocelot_port, DEV_MAC_TAGS_CFG_TAG_ID(ETH_P_8021AD) |
145 DEV_MAC_TAGS_CFG_VLAN_AWR_ENA |
146 DEV_MAC_TAGS_CFG_VLAN_LEN_AWR_ENA,
147 DEV_MAC_TAGS_CFG);
148
149 /* Enable MAC module */
150 - ocelot_port_writel(port, DEV_MAC_ENA_CFG_RX_ENA |
151 + ocelot_port_writel(ocelot_port, DEV_MAC_ENA_CFG_RX_ENA |
152 DEV_MAC_ENA_CFG_TX_ENA, DEV_MAC_ENA_CFG);
153
154 /* Take MAC, Port, Phy (intern) and PCS (SGMII/Serdes) clock out of
155 * reset */
156 - ocelot_port_writel(port, DEV_CLOCK_CFG_LINK_SPEED(speed),
157 + ocelot_port_writel(ocelot_port, DEV_CLOCK_CFG_LINK_SPEED(speed),
158 DEV_CLOCK_CFG);
159
160 /* Set SMAC of Pause frame (00:00:00:00:00:00) */
161 - ocelot_port_writel(port, 0, DEV_MAC_FC_MAC_HIGH_CFG);
162 - ocelot_port_writel(port, 0, DEV_MAC_FC_MAC_LOW_CFG);
163 + ocelot_port_writel(ocelot_port, 0, DEV_MAC_FC_MAC_HIGH_CFG);
164 + ocelot_port_writel(ocelot_port, 0, DEV_MAC_FC_MAC_LOW_CFG);
165
166 /* No PFC */
167 ocelot_write_gix(ocelot, ANA_PFC_PFC_CFG_FC_LINK_SPEED(speed),
168 - ANA_PFC_PFC_CFG, p);
169 + ANA_PFC_PFC_CFG, port);
170
171 /* Set Pause WM hysteresis
172 * 152 = 6 * VLAN_ETH_FRAME_LEN / OCELOT_BUFFER_CELL_SZ
173 @@ -507,13 +511,13 @@ static void ocelot_port_adjust_link(stru
174 */
175 ocelot_write_rix(ocelot, SYS_PAUSE_CFG_PAUSE_ENA |
176 SYS_PAUSE_CFG_PAUSE_STOP(101) |
177 - SYS_PAUSE_CFG_PAUSE_START(152), SYS_PAUSE_CFG, p);
178 + SYS_PAUSE_CFG_PAUSE_START(152), SYS_PAUSE_CFG, port);
179
180 /* Core: Enable port for frame transfer */
181 ocelot_write_rix(ocelot, QSYS_SWITCH_PORT_MODE_INGRESS_DROP_MODE |
182 QSYS_SWITCH_PORT_MODE_SCH_NEXT_CFG(1) |
183 QSYS_SWITCH_PORT_MODE_PORT_ENA,
184 - QSYS_SWITCH_PORT_MODE, p);
185 + QSYS_SWITCH_PORT_MODE, port);
186
187 /* Flow control */
188 ocelot_write_rix(ocelot, SYS_MAC_FC_CFG_PAUSE_VAL_CFG(0xffff) |
189 @@ -521,20 +525,21 @@ static void ocelot_port_adjust_link(stru
190 SYS_MAC_FC_CFG_ZERO_PAUSE_ENA |
191 SYS_MAC_FC_CFG_FC_LATENCY_CFG(0x7) |
192 SYS_MAC_FC_CFG_FC_LINK_SPEED(speed),
193 - SYS_MAC_FC_CFG, p);
194 - ocelot_write_rix(ocelot, 0, ANA_POL_FLOWC, p);
195 + SYS_MAC_FC_CFG, port);
196 + ocelot_write_rix(ocelot, 0, ANA_POL_FLOWC, port);
197
198 /* Tail dropping watermark */
199 atop_wm = (ocelot->shared_queue_sz - 9 * VLAN_ETH_FRAME_LEN) / OCELOT_BUFFER_CELL_SZ;
200 ocelot_write_rix(ocelot, ocelot_wm_enc(9 * VLAN_ETH_FRAME_LEN),
201 - SYS_ATOP, p);
202 + SYS_ATOP, port);
203 ocelot_write(ocelot, ocelot_wm_enc(atop_wm), SYS_ATOP_TOT_CFG);
204 }
205
206 static int ocelot_port_open(struct net_device *dev)
207 {
208 - struct ocelot_port *port = netdev_priv(dev);
209 - struct ocelot *ocelot = port->ocelot;
210 + struct ocelot_port_private *priv = netdev_priv(dev);
211 + struct ocelot *ocelot = priv->port.ocelot;
212 + int port = priv->chip_port;
213 int err;
214
215 /* Enable receiving frames on the port, and activate auto-learning of
216 @@ -542,43 +547,44 @@ static int ocelot_port_open(struct net_d
217 */
218 ocelot_write_gix(ocelot, ANA_PORT_PORT_CFG_LEARNAUTO |
219 ANA_PORT_PORT_CFG_RECV_ENA |
220 - ANA_PORT_PORT_CFG_PORTID_VAL(port->chip_port),
221 - ANA_PORT_PORT_CFG, port->chip_port);
222 + ANA_PORT_PORT_CFG_PORTID_VAL(port),
223 + ANA_PORT_PORT_CFG, port);
224
225 - if (port->serdes) {
226 - err = phy_set_mode_ext(port->serdes, PHY_MODE_ETHERNET,
227 - port->phy_mode);
228 + if (priv->serdes) {
229 + err = phy_set_mode_ext(priv->serdes, PHY_MODE_ETHERNET,
230 + priv->phy_mode);
231 if (err) {
232 netdev_err(dev, "Could not set mode of SerDes\n");
233 return err;
234 }
235 }
236
237 - err = phy_connect_direct(dev, port->phy, &ocelot_port_adjust_link,
238 - port->phy_mode);
239 + err = phy_connect_direct(dev, priv->phy, &ocelot_port_adjust_link,
240 + priv->phy_mode);
241 if (err) {
242 netdev_err(dev, "Could not attach to PHY\n");
243 return err;
244 }
245
246 - dev->phydev = port->phy;
247 + dev->phydev = priv->phy;
248
249 - phy_attached_info(port->phy);
250 - phy_start(port->phy);
251 + phy_attached_info(priv->phy);
252 + phy_start(priv->phy);
253 return 0;
254 }
255
256 static int ocelot_port_stop(struct net_device *dev)
257 {
258 - struct ocelot_port *port = netdev_priv(dev);
259 + struct ocelot_port_private *priv = netdev_priv(dev);
260 + struct ocelot_port *port = &priv->port;
261
262 - phy_disconnect(port->phy);
263 + phy_disconnect(priv->phy);
264
265 dev->phydev = NULL;
266
267 ocelot_port_writel(port, 0, DEV_MAC_ENA_CFG);
268 ocelot_rmw_rix(port->ocelot, 0, QSYS_SWITCH_PORT_MODE_PORT_ENA,
269 - QSYS_SWITCH_PORT_MODE, port->chip_port);
270 + QSYS_SWITCH_PORT_MODE, priv->chip_port);
271 return 0;
272 }
273
274 @@ -604,13 +610,15 @@ static int ocelot_gen_ifh(u32 *ifh, stru
275
276 static int ocelot_port_xmit(struct sk_buff *skb, struct net_device *dev)
277 {
278 + struct ocelot_port_private *priv = netdev_priv(dev);
279 struct skb_shared_info *shinfo = skb_shinfo(skb);
280 - struct ocelot_port *port = netdev_priv(dev);
281 - struct ocelot *ocelot = port->ocelot;
282 - u32 val, ifh[IFH_LEN];
283 + struct ocelot_port *ocelot_port = &priv->port;
284 + struct ocelot *ocelot = ocelot_port->ocelot;
285 struct frame_info info = {};
286 u8 grp = 0; /* Send everything on CPU group 0 */
287 unsigned int i, count, last;
288 + int port = priv->chip_port;
289 + u32 val, ifh[IFH_LEN];
290
291 val = ocelot_read(ocelot, QS_INJ_STATUS);
292 if (!(val & QS_INJ_STATUS_FIFO_RDY(BIT(grp))) ||
293 @@ -620,15 +628,15 @@ static int ocelot_port_xmit(struct sk_bu
294 ocelot_write_rix(ocelot, QS_INJ_CTRL_GAP_SIZE(1) |
295 QS_INJ_CTRL_SOF, QS_INJ_CTRL, grp);
296
297 - info.port = BIT(port->chip_port);
298 + info.port = BIT(port);
299 info.tag_type = IFH_TAG_TYPE_C;
300 info.vid = skb_vlan_tag_get(skb);
301
302 /* Check if timestamping is needed */
303 if (ocelot->ptp && shinfo->tx_flags & SKBTX_HW_TSTAMP) {
304 - info.rew_op = port->ptp_cmd;
305 - if (port->ptp_cmd == IFH_REW_OP_TWO_STEP_PTP)
306 - info.rew_op |= (port->ts_id % 4) << 3;
307 + info.rew_op = ocelot_port->ptp_cmd;
308 + if (ocelot_port->ptp_cmd == IFH_REW_OP_TWO_STEP_PTP)
309 + info.rew_op |= (ocelot_port->ts_id % 4) << 3;
310 }
311
312 ocelot_gen_ifh(ifh, &info);
313 @@ -663,7 +671,7 @@ static int ocelot_port_xmit(struct sk_bu
314 dev->stats.tx_bytes += skb->len;
315
316 if (ocelot->ptp && shinfo->tx_flags & SKBTX_HW_TSTAMP &&
317 - port->ptp_cmd == IFH_REW_OP_TWO_STEP_PTP) {
318 + ocelot_port->ptp_cmd == IFH_REW_OP_TWO_STEP_PTP) {
319 struct ocelot_skb *oskb =
320 kzalloc(sizeof(struct ocelot_skb), GFP_ATOMIC);
321
322 @@ -673,10 +681,10 @@ static int ocelot_port_xmit(struct sk_bu
323 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
324
325 oskb->skb = skb;
326 - oskb->id = port->ts_id % 4;
327 - port->ts_id++;
328 + oskb->id = ocelot_port->ts_id % 4;
329 + ocelot_port->ts_id++;
330
331 - list_add_tail(&oskb->head, &port->skbs);
332 + list_add_tail(&oskb->head, &ocelot_port->skbs);
333
334 return NETDEV_TX_OK;
335 }
336 @@ -715,25 +723,29 @@ EXPORT_SYMBOL(ocelot_get_hwtimestamp);
337
338 static int ocelot_mc_unsync(struct net_device *dev, const unsigned char *addr)
339 {
340 - struct ocelot_port *port = netdev_priv(dev);
341 + struct ocelot_port_private *priv = netdev_priv(dev);
342 + struct ocelot_port *ocelot_port = &priv->port;
343 + struct ocelot *ocelot = ocelot_port->ocelot;
344
345 - return ocelot_mact_forget(port->ocelot, addr, port->pvid);
346 + return ocelot_mact_forget(ocelot, addr, ocelot_port->pvid);
347 }
348
349 static int ocelot_mc_sync(struct net_device *dev, const unsigned char *addr)
350 {
351 - struct ocelot_port *port = netdev_priv(dev);
352 + struct ocelot_port_private *priv = netdev_priv(dev);
353 + struct ocelot_port *ocelot_port = &priv->port;
354 + struct ocelot *ocelot = ocelot_port->ocelot;
355
356 - return ocelot_mact_learn(port->ocelot, PGID_CPU, addr, port->pvid,
357 + return ocelot_mact_learn(ocelot, PGID_CPU, addr, ocelot_port->pvid,
358 ENTRYTYPE_LOCKED);
359 }
360
361 static void ocelot_set_rx_mode(struct net_device *dev)
362 {
363 - struct ocelot_port *port = netdev_priv(dev);
364 - struct ocelot *ocelot = port->ocelot;
365 - int i;
366 + struct ocelot_port_private *priv = netdev_priv(dev);
367 + struct ocelot *ocelot = priv->port.ocelot;
368 u32 val;
369 + int i;
370
371 /* This doesn't handle promiscuous mode because the bridge core is
372 * setting IFF_PROMISC on all slave interfaces and all frames would be
373 @@ -749,10 +761,11 @@ static void ocelot_set_rx_mode(struct ne
374 static int ocelot_port_get_phys_port_name(struct net_device *dev,
375 char *buf, size_t len)
376 {
377 - struct ocelot_port *port = netdev_priv(dev);
378 + struct ocelot_port_private *priv = netdev_priv(dev);
379 + int port = priv->chip_port;
380 int ret;
381
382 - ret = snprintf(buf, len, "p%d", port->chip_port);
383 + ret = snprintf(buf, len, "p%d", port);
384 if (ret >= len)
385 return -EINVAL;
386
387 @@ -761,15 +774,16 @@ static int ocelot_port_get_phys_port_nam
388
389 static int ocelot_port_set_mac_address(struct net_device *dev, void *p)
390 {
391 - struct ocelot_port *port = netdev_priv(dev);
392 - struct ocelot *ocelot = port->ocelot;
393 + struct ocelot_port_private *priv = netdev_priv(dev);
394 + struct ocelot_port *ocelot_port = &priv->port;
395 + struct ocelot *ocelot = ocelot_port->ocelot;
396 const struct sockaddr *addr = p;
397
398 /* Learn the new net device MAC address in the mac table. */
399 - ocelot_mact_learn(ocelot, PGID_CPU, addr->sa_data, port->pvid,
400 + ocelot_mact_learn(ocelot, PGID_CPU, addr->sa_data, ocelot_port->pvid,
401 ENTRYTYPE_LOCKED);
402 /* Then forget the previous one. */
403 - ocelot_mact_forget(ocelot, dev->dev_addr, port->pvid);
404 + ocelot_mact_forget(ocelot, dev->dev_addr, ocelot_port->pvid);
405
406 ether_addr_copy(dev->dev_addr, addr->sa_data);
407 return 0;
408 @@ -778,11 +792,12 @@ static int ocelot_port_set_mac_address(s
409 static void ocelot_get_stats64(struct net_device *dev,
410 struct rtnl_link_stats64 *stats)
411 {
412 - struct ocelot_port *port = netdev_priv(dev);
413 - struct ocelot *ocelot = port->ocelot;
414 + struct ocelot_port_private *priv = netdev_priv(dev);
415 + struct ocelot *ocelot = priv->port.ocelot;
416 + int port = priv->chip_port;
417
418 /* Configure the port to read the stats from */
419 - ocelot_write(ocelot, SYS_STAT_CFG_STAT_VIEW(port->chip_port),
420 + ocelot_write(ocelot, SYS_STAT_CFG_STAT_VIEW(port),
421 SYS_STAT_CFG);
422
423 /* Get Rx stats */
424 @@ -814,12 +829,13 @@ static void ocelot_get_stats64(struct ne
425 }
426
427 static int ocelot_fdb_add(struct ocelot *ocelot, int port,
428 - const unsigned char *addr, u16 vid)
429 + const unsigned char *addr, u16 vid,
430 + bool vlan_aware)
431 {
432 struct ocelot_port *ocelot_port = ocelot->ports[port];
433
434 if (!vid) {
435 - if (!ocelot_port->vlan_aware)
436 + if (!vlan_aware)
437 /* If the bridge is not VLAN aware and no VID was
438 * provided, set it to pvid to ensure the MAC entry
439 * matches incoming untagged packets
440 @@ -841,10 +857,11 @@ static int ocelot_port_fdb_add(struct nd
441 u16 vid, u16 flags,
442 struct netlink_ext_ack *extack)
443 {
444 - struct ocelot_port *ocelot_port = netdev_priv(dev);
445 - struct ocelot *ocelot = ocelot_port->ocelot;
446 + struct ocelot_port_private *priv = netdev_priv(dev);
447 + struct ocelot *ocelot = priv->port.ocelot;
448 + int port = priv->chip_port;
449
450 - return ocelot_fdb_add(ocelot, ocelot_port->chip_port, addr, vid);
451 + return ocelot_fdb_add(ocelot, port, addr, vid, priv->vlan_aware);
452 }
453
454 static int ocelot_fdb_del(struct ocelot *ocelot, int port,
455 @@ -857,10 +874,11 @@ static int ocelot_port_fdb_del(struct nd
456 struct net_device *dev,
457 const unsigned char *addr, u16 vid)
458 {
459 - struct ocelot_port *ocelot_port = netdev_priv(dev);
460 - struct ocelot *ocelot = ocelot_port->ocelot;
461 + struct ocelot_port_private *priv = netdev_priv(dev);
462 + struct ocelot *ocelot = priv->port.ocelot;
463 + int port = priv->chip_port;
464
465 - return ocelot_fdb_del(ocelot, ocelot_port->chip_port, addr, vid);
466 + return ocelot_fdb_del(ocelot, port, addr, vid);
467 }
468
469 struct ocelot_dump_ctx {
470 @@ -999,18 +1017,18 @@ static int ocelot_port_fdb_dump(struct s
471 struct net_device *dev,
472 struct net_device *filter_dev, int *idx)
473 {
474 - struct ocelot_port *ocelot_port = netdev_priv(dev);
475 - struct ocelot *ocelot = ocelot_port->ocelot;
476 + struct ocelot_port_private *priv = netdev_priv(dev);
477 + struct ocelot *ocelot = priv->port.ocelot;
478 struct ocelot_dump_ctx dump = {
479 .dev = dev,
480 .skb = skb,
481 .cb = cb,
482 .idx = *idx,
483 };
484 + int port = priv->chip_port;
485 int ret;
486
487 - ret = ocelot_fdb_dump(ocelot, ocelot_port->chip_port,
488 - ocelot_port_fdb_do_dump, &dump);
489 + ret = ocelot_fdb_dump(ocelot, port, ocelot_port_fdb_do_dump, &dump);
490
491 *idx = dump.idx;
492
493 @@ -1033,12 +1051,12 @@ static int ocelot_set_features(struct ne
494 netdev_features_t features)
495 {
496 netdev_features_t changed = dev->features ^ features;
497 - struct ocelot_port *ocelot_port = netdev_priv(dev);
498 - struct ocelot *ocelot = ocelot_port->ocelot;
499 - int port = ocelot_port->chip_port;
500 + struct ocelot_port_private *priv = netdev_priv(dev);
501 + struct ocelot *ocelot = priv->port.ocelot;
502 + int port = priv->chip_port;
503
504 if ((dev->features & NETIF_F_HW_TC) > (features & NETIF_F_HW_TC) &&
505 - ocelot_port->tc.offload_cnt) {
506 + priv->tc.offload_cnt) {
507 netdev_err(dev,
508 "Cannot disable HW TC offload while offloads active\n");
509 return -EBUSY;
510 @@ -1053,8 +1071,8 @@ static int ocelot_set_features(struct ne
511 static int ocelot_get_port_parent_id(struct net_device *dev,
512 struct netdev_phys_item_id *ppid)
513 {
514 - struct ocelot_port *ocelot_port = netdev_priv(dev);
515 - struct ocelot *ocelot = ocelot_port->ocelot;
516 + struct ocelot_port_private *priv = netdev_priv(dev);
517 + struct ocelot *ocelot = priv->port.ocelot;
518
519 ppid->id_len = sizeof(ocelot->base_mac);
520 memcpy(&ppid->id, &ocelot->base_mac, ppid->id_len);
521 @@ -1136,9 +1154,9 @@ static int ocelot_hwstamp_set(struct oce
522
523 static int ocelot_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
524 {
525 - struct ocelot_port *ocelot_port = netdev_priv(dev);
526 - struct ocelot *ocelot = ocelot_port->ocelot;
527 - int port = ocelot_port->chip_port;
528 + struct ocelot_port_private *priv = netdev_priv(dev);
529 + struct ocelot *ocelot = priv->port.ocelot;
530 + int port = priv->chip_port;
531
532 /* The function is only used for PTP operations for now */
533 if (!ocelot->ptp)
534 @@ -1175,8 +1193,8 @@ static const struct net_device_ops ocelo
535
536 static void ocelot_get_strings(struct net_device *netdev, u32 sset, u8 *data)
537 {
538 - struct ocelot_port *port = netdev_priv(netdev);
539 - struct ocelot *ocelot = port->ocelot;
540 + struct ocelot_port_private *priv = netdev_priv(netdev);
541 + struct ocelot *ocelot = priv->port.ocelot;
542 int i;
543
544 if (sset != ETH_SS_STATS)
545 @@ -1230,8 +1248,9 @@ static void ocelot_check_stats_work(stru
546 static void ocelot_get_ethtool_stats(struct net_device *dev,
547 struct ethtool_stats *stats, u64 *data)
548 {
549 - struct ocelot_port *port = netdev_priv(dev);
550 - struct ocelot *ocelot = port->ocelot;
551 + struct ocelot_port_private *priv = netdev_priv(dev);
552 + struct ocelot *ocelot = priv->port.ocelot;
553 + int port = priv->chip_port;
554 int i;
555
556 /* check and update now */
557 @@ -1239,13 +1258,13 @@ static void ocelot_get_ethtool_stats(str
558
559 /* Copy all counters */
560 for (i = 0; i < ocelot->num_stats; i++)
561 - *data++ = ocelot->stats[port->chip_port * ocelot->num_stats + i];
562 + *data++ = ocelot->stats[port * ocelot->num_stats + i];
563 }
564
565 static int ocelot_get_sset_count(struct net_device *dev, int sset)
566 {
567 - struct ocelot_port *port = netdev_priv(dev);
568 - struct ocelot *ocelot = port->ocelot;
569 + struct ocelot_port_private *priv = netdev_priv(dev);
570 + struct ocelot *ocelot = priv->port.ocelot;
571
572 if (sset != ETH_SS_STATS)
573 return -EOPNOTSUPP;
574 @@ -1255,8 +1274,8 @@ static int ocelot_get_sset_count(struct
575 static int ocelot_get_ts_info(struct net_device *dev,
576 struct ethtool_ts_info *info)
577 {
578 - struct ocelot_port *ocelot_port = netdev_priv(dev);
579 - struct ocelot *ocelot = ocelot_port->ocelot;
580 + struct ocelot_port_private *priv = netdev_priv(dev);
581 + struct ocelot *ocelot = priv->port.ocelot;
582
583 if (!ocelot->ptp)
584 return ethtool_op_get_ts_info(dev, info);
585 @@ -1388,9 +1407,9 @@ static int ocelot_port_attr_set(struct n
586 const struct switchdev_attr *attr,
587 struct switchdev_trans *trans)
588 {
589 - struct ocelot_port *ocelot_port = netdev_priv(dev);
590 - struct ocelot *ocelot = ocelot_port->ocelot;
591 - int port = ocelot_port->chip_port;
592 + struct ocelot_port_private *priv = netdev_priv(dev);
593 + struct ocelot *ocelot = priv->port.ocelot;
594 + int port = priv->chip_port;
595 int err = 0;
596
597 switch (attr->id) {
598 @@ -1402,8 +1421,8 @@ static int ocelot_port_attr_set(struct n
599 ocelot_port_attr_ageing_set(ocelot, port, attr->u.ageing_time);
600 break;
601 case SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING:
602 - ocelot_port_vlan_filtering(ocelot, port,
603 - attr->u.vlan_filtering);
604 + priv->vlan_aware = attr->u.vlan_filtering;
605 + ocelot_port_vlan_filtering(ocelot, port, priv->vlan_aware);
606 break;
607 case SWITCHDEV_ATTR_ID_BRIDGE_MC_DISABLED:
608 ocelot_port_attr_mc_set(ocelot, port, !attr->u.mc_disabled);
609 @@ -1468,15 +1487,17 @@ static int ocelot_port_obj_add_mdb(struc
610 const struct switchdev_obj_port_mdb *mdb,
611 struct switchdev_trans *trans)
612 {
613 - struct ocelot_port *port = netdev_priv(dev);
614 - struct ocelot *ocelot = port->ocelot;
615 - struct ocelot_multicast *mc;
616 + struct ocelot_port_private *priv = netdev_priv(dev);
617 + struct ocelot_port *ocelot_port = &priv->port;
618 + struct ocelot *ocelot = ocelot_port->ocelot;
619 unsigned char addr[ETH_ALEN];
620 + struct ocelot_multicast *mc;
621 + int port = priv->chip_port;
622 u16 vid = mdb->vid;
623 bool new = false;
624
625 if (!vid)
626 - vid = port->pvid;
627 + vid = ocelot_port->pvid;
628
629 mc = ocelot_multicast_get(ocelot, mdb->addr, vid);
630 if (!mc) {
631 @@ -1500,7 +1521,7 @@ static int ocelot_port_obj_add_mdb(struc
632 ocelot_mact_forget(ocelot, addr, vid);
633 }
634
635 - mc->ports |= BIT(port->chip_port);
636 + mc->ports |= BIT(port);
637 addr[2] = mc->ports << 0;
638 addr[1] = mc->ports << 8;
639
640 @@ -1510,14 +1531,16 @@ static int ocelot_port_obj_add_mdb(struc
641 static int ocelot_port_obj_del_mdb(struct net_device *dev,
642 const struct switchdev_obj_port_mdb *mdb)
643 {
644 - struct ocelot_port *port = netdev_priv(dev);
645 - struct ocelot *ocelot = port->ocelot;
646 - struct ocelot_multicast *mc;
647 + struct ocelot_port_private *priv = netdev_priv(dev);
648 + struct ocelot_port *ocelot_port = &priv->port;
649 + struct ocelot *ocelot = ocelot_port->ocelot;
650 unsigned char addr[ETH_ALEN];
651 + struct ocelot_multicast *mc;
652 + int port = priv->chip_port;
653 u16 vid = mdb->vid;
654
655 if (!vid)
656 - vid = port->pvid;
657 + vid = ocelot_port->pvid;
658
659 mc = ocelot_multicast_get(ocelot, mdb->addr, vid);
660 if (!mc)
661 @@ -1529,7 +1552,7 @@ static int ocelot_port_obj_del_mdb(struc
662 addr[0] = 0;
663 ocelot_mact_forget(ocelot, addr, vid);
664
665 - mc->ports &= ~BIT(port->chip_port);
666 + mc->ports &= ~BIT(port);
667 if (!mc->ports) {
668 list_del(&mc->list);
669 devm_kfree(ocelot->dev, mc);
670 @@ -1683,9 +1706,9 @@ static int ocelot_port_lag_join(struct o
671
672 rcu_read_lock();
673 for_each_netdev_in_bond_rcu(bond, ndev) {
674 - struct ocelot_port *port = netdev_priv(ndev);
675 + struct ocelot_port_private *priv = netdev_priv(ndev);
676
677 - bond_mask |= BIT(port->chip_port);
678 + bond_mask |= BIT(priv->chip_port);
679 }
680 rcu_read_unlock();
681
682 @@ -1753,20 +1776,23 @@ static int ocelot_netdevice_port_event(s
683 unsigned long event,
684 struct netdev_notifier_changeupper_info *info)
685 {
686 - struct ocelot_port *ocelot_port = netdev_priv(dev);
687 + struct ocelot_port_private *priv = netdev_priv(dev);
688 + struct ocelot_port *ocelot_port = &priv->port;
689 struct ocelot *ocelot = ocelot_port->ocelot;
690 - int port = ocelot_port->chip_port;
691 + int port = priv->chip_port;
692 int err = 0;
693
694 switch (event) {
695 case NETDEV_CHANGEUPPER:
696 if (netif_is_bridge_master(info->upper_dev)) {
697 - if (info->linking)
698 + if (info->linking) {
699 err = ocelot_port_bridge_join(ocelot, port,
700 info->upper_dev);
701 - else
702 + } else {
703 err = ocelot_port_bridge_leave(ocelot, port,
704 info->upper_dev);
705 + priv->vlan_aware = false;
706 + }
707 }
708 if (netif_is_lag_master(info->upper_dev)) {
709 if (info->linking)
710 @@ -2084,21 +2110,23 @@ int ocelot_probe_port(struct ocelot *oce
711 void __iomem *regs,
712 struct phy_device *phy)
713 {
714 + struct ocelot_port_private *priv;
715 struct ocelot_port *ocelot_port;
716 struct net_device *dev;
717 u32 val;
718 int err;
719
720 - dev = alloc_etherdev(sizeof(struct ocelot_port));
721 + dev = alloc_etherdev(sizeof(struct ocelot_port_private));
722 if (!dev)
723 return -ENOMEM;
724 SET_NETDEV_DEV(dev, ocelot->dev);
725 - ocelot_port = netdev_priv(dev);
726 - ocelot_port->dev = dev;
727 + priv = netdev_priv(dev);
728 + priv->dev = dev;
729 + priv->phy = phy;
730 + priv->chip_port = port;
731 + ocelot_port = &priv->port;
732 ocelot_port->ocelot = ocelot;
733 ocelot_port->regs = regs;
734 - ocelot_port->chip_port = port;
735 - ocelot_port->phy = phy;
736 ocelot->ports[port] = ocelot_port;
737
738 dev->netdev_ops = &ocelot_port_netdev_ops;
739 --- a/drivers/net/ethernet/mscc/ocelot.h
740 +++ b/drivers/net/ethernet/mscc/ocelot.h
741 @@ -479,11 +479,9 @@ struct ocelot {
742 };
743
744 struct ocelot_port {
745 - struct net_device *dev;
746 struct ocelot *ocelot;
747 - struct phy_device *phy;
748 +
749 void __iomem *regs;
750 - u8 chip_port;
751
752 /* Ingress default VLAN (pvid) */
753 u16 pvid;
754 @@ -491,18 +489,23 @@ struct ocelot_port {
755 /* Egress default VLAN (vid) */
756 u16 vid;
757
758 - u8 vlan_aware;
759 + u8 ptp_cmd;
760 + struct list_head skbs;
761 + u8 ts_id;
762 +};
763
764 - u64 *stats;
765 +struct ocelot_port_private {
766 + struct ocelot_port port;
767 + struct net_device *dev;
768 + struct phy_device *phy;
769 + u8 chip_port;
770 +
771 + u8 vlan_aware;
772
773 phy_interface_t phy_mode;
774 struct phy *serdes;
775
776 struct ocelot_port_tc tc;
777 -
778 - u8 ptp_cmd;
779 - struct list_head skbs;
780 - u8 ts_id;
781 };
782
783 struct ocelot_skb {
784 --- a/drivers/net/ethernet/mscc/ocelot_ace.h
785 +++ b/drivers/net/ethernet/mscc/ocelot_ace.h
786 @@ -224,9 +224,9 @@ int ocelot_ace_rule_stats_update(struct
787 int ocelot_ace_init(struct ocelot *ocelot);
788 void ocelot_ace_deinit(void);
789
790 -int ocelot_setup_tc_block_flower_bind(struct ocelot_port *port,
791 +int ocelot_setup_tc_block_flower_bind(struct ocelot_port_private *priv,
792 struct flow_block_offload *f);
793 -void ocelot_setup_tc_block_flower_unbind(struct ocelot_port *port,
794 +void ocelot_setup_tc_block_flower_unbind(struct ocelot_port_private *priv,
795 struct flow_block_offload *f);
796
797 #endif /* _MSCC_OCELOT_ACE_H_ */
798 --- a/drivers/net/ethernet/mscc/ocelot_board.c
799 +++ b/drivers/net/ethernet/mscc/ocelot_board.c
800 @@ -95,6 +95,8 @@ static irqreturn_t ocelot_xtr_irq_handle
801
802 do {
803 struct skb_shared_hwtstamps *shhwtstamps;
804 + struct ocelot_port_private *priv;
805 + struct ocelot_port *ocelot_port;
806 u64 tod_in_ns, full_ts_in_ns;
807 struct frame_info info = {};
808 struct net_device *dev;
809 @@ -122,7 +124,10 @@ static irqreturn_t ocelot_xtr_irq_handle
810
811 ocelot_parse_ifh(ifh, &info);
812
813 - dev = ocelot->ports[info.port]->dev;
814 + ocelot_port = ocelot->ports[info.port];
815 + priv = container_of(ocelot_port, struct ocelot_port_private,
816 + port);
817 + dev = priv->dev;
818
819 skb = netdev_alloc_skb(dev, info.len);
820
821 @@ -371,6 +376,8 @@ static int mscc_ocelot_probe(struct plat
822 ocelot_init(ocelot);
823
824 for_each_available_child_of_node(ports, portnp) {
825 + struct ocelot_port_private *priv;
826 + struct ocelot_port *ocelot_port;
827 struct device_node *phy_node;
828 struct phy_device *phy;
829 struct resource *res;
830 @@ -406,13 +413,17 @@ static int mscc_ocelot_probe(struct plat
831 goto out_put_ports;
832 }
833
834 + ocelot_port = ocelot->ports[port];
835 + priv = container_of(ocelot_port, struct ocelot_port_private,
836 + port);
837 +
838 phy_mode = of_get_phy_mode(portnp);
839 if (phy_mode < 0)
840 - ocelot->ports[port]->phy_mode = PHY_INTERFACE_MODE_NA;
841 - else
842 - ocelot->ports[port]->phy_mode = phy_mode;
843 + phy_mode = PHY_INTERFACE_MODE_NA;
844 +
845 + priv->phy_mode = phy_mode;
846
847 - switch (ocelot->ports[port]->phy_mode) {
848 + switch (priv->phy_mode) {
849 case PHY_INTERFACE_MODE_NA:
850 continue;
851 case PHY_INTERFACE_MODE_SGMII:
852 @@ -421,7 +432,7 @@ static int mscc_ocelot_probe(struct plat
853 /* Ensure clock signals and speed is set on all
854 * QSGMII links
855 */
856 - ocelot_port_writel(ocelot->ports[port],
857 + ocelot_port_writel(ocelot_port,
858 DEV_CLOCK_CFG_LINK_SPEED
859 (OCELOT_SPEED_1000),
860 DEV_CLOCK_CFG);
861 @@ -449,7 +460,7 @@ static int mscc_ocelot_probe(struct plat
862 goto out_put_ports;
863 }
864
865 - ocelot->ports[port]->serdes = serdes;
866 + priv->serdes = serdes;
867 }
868
869 register_netdevice_notifier(&ocelot_netdevice_nb);
870 --- a/drivers/net/ethernet/mscc/ocelot_flower.c
871 +++ b/drivers/net/ethernet/mscc/ocelot_flower.c
872 @@ -10,7 +10,7 @@
873
874 struct ocelot_port_block {
875 struct ocelot_acl_block *block;
876 - struct ocelot_port *port;
877 + struct ocelot_port_private *priv;
878 };
879
880 static int ocelot_flower_parse_action(struct flow_cls_offload *f,
881 @@ -177,8 +177,8 @@ struct ocelot_ace_rule *ocelot_ace_rule_
882 if (!rule)
883 return NULL;
884
885 - rule->port = block->port;
886 - rule->chip_port = block->port->chip_port;
887 + rule->port = &block->priv->port;
888 + rule->chip_port = block->priv->chip_port;
889 return rule;
890 }
891
892 @@ -202,7 +202,7 @@ static int ocelot_flower_replace(struct
893 if (ret)
894 return ret;
895
896 - port_block->port->tc.offload_cnt++;
897 + port_block->priv->tc.offload_cnt++;
898 return 0;
899 }
900
901 @@ -213,14 +213,14 @@ static int ocelot_flower_destroy(struct
902 int ret;
903
904 rule.prio = f->common.prio;
905 - rule.port = port_block->port;
906 + rule.port = &port_block->priv->port;
907 rule.id = f->cookie;
908
909 ret = ocelot_ace_rule_offload_del(&rule);
910 if (ret)
911 return ret;
912
913 - port_block->port->tc.offload_cnt--;
914 + port_block->priv->tc.offload_cnt--;
915 return 0;
916 }
917
918 @@ -231,7 +231,7 @@ static int ocelot_flower_stats_update(st
919 int ret;
920
921 rule.prio = f->common.prio;
922 - rule.port = port_block->port;
923 + rule.port = &port_block->priv->port;
924 rule.id = f->cookie;
925 ret = ocelot_ace_rule_stats_update(&rule);
926 if (ret)
927 @@ -261,7 +261,7 @@ static int ocelot_setup_tc_block_cb_flow
928 {
929 struct ocelot_port_block *port_block = cb_priv;
930
931 - if (!tc_cls_can_offload_and_chain0(port_block->port->dev, type_data))
932 + if (!tc_cls_can_offload_and_chain0(port_block->priv->dev, type_data))
933 return -EOPNOTSUPP;
934
935 switch (type) {
936 @@ -275,7 +275,7 @@ static int ocelot_setup_tc_block_cb_flow
937 }
938
939 static struct ocelot_port_block*
940 -ocelot_port_block_create(struct ocelot_port *port)
941 +ocelot_port_block_create(struct ocelot_port_private *priv)
942 {
943 struct ocelot_port_block *port_block;
944
945 @@ -283,7 +283,7 @@ ocelot_port_block_create(struct ocelot_p
946 if (!port_block)
947 return NULL;
948
949 - port_block->port = port;
950 + port_block->priv = priv;
951
952 return port_block;
953 }
954 @@ -300,7 +300,7 @@ static void ocelot_tc_block_unbind(void
955 ocelot_port_block_destroy(port_block);
956 }
957
958 -int ocelot_setup_tc_block_flower_bind(struct ocelot_port *port,
959 +int ocelot_setup_tc_block_flower_bind(struct ocelot_port_private *priv,
960 struct flow_block_offload *f)
961 {
962 struct ocelot_port_block *port_block;
963 @@ -311,14 +311,14 @@ int ocelot_setup_tc_block_flower_bind(st
964 return -EOPNOTSUPP;
965
966 block_cb = flow_block_cb_lookup(f->block,
967 - ocelot_setup_tc_block_cb_flower, port);
968 + ocelot_setup_tc_block_cb_flower, priv);
969 if (!block_cb) {
970 - port_block = ocelot_port_block_create(port);
971 + port_block = ocelot_port_block_create(priv);
972 if (!port_block)
973 return -ENOMEM;
974
975 block_cb = flow_block_cb_alloc(ocelot_setup_tc_block_cb_flower,
976 - port, port_block,
977 + priv, port_block,
978 ocelot_tc_block_unbind);
979 if (IS_ERR(block_cb)) {
980 ret = PTR_ERR(block_cb);
981 @@ -339,13 +339,13 @@ err_cb_register:
982 return ret;
983 }
984
985 -void ocelot_setup_tc_block_flower_unbind(struct ocelot_port *port,
986 +void ocelot_setup_tc_block_flower_unbind(struct ocelot_port_private *priv,
987 struct flow_block_offload *f)
988 {
989 struct flow_block_cb *block_cb;
990
991 block_cb = flow_block_cb_lookup(f->block,
992 - ocelot_setup_tc_block_cb_flower, port);
993 + ocelot_setup_tc_block_cb_flower, priv);
994 if (!block_cb)
995 return;
996
997 --- a/drivers/net/ethernet/mscc/ocelot_tc.c
998 +++ b/drivers/net/ethernet/mscc/ocelot_tc.c
999 @@ -9,17 +9,19 @@
1000 #include "ocelot_ace.h"
1001 #include <net/pkt_cls.h>
1002
1003 -static int ocelot_setup_tc_cls_matchall(struct ocelot_port *port,
1004 +static int ocelot_setup_tc_cls_matchall(struct ocelot_port_private *priv,
1005 struct tc_cls_matchall_offload *f,
1006 bool ingress)
1007 {
1008 struct netlink_ext_ack *extack = f->common.extack;
1009 + struct ocelot *ocelot = priv->port.ocelot;
1010 struct ocelot_policer pol = { 0 };
1011 struct flow_action_entry *action;
1012 + int port = priv->chip_port;
1013 int err;
1014
1015 - netdev_dbg(port->dev, "%s: port %u command %d cookie %lu\n",
1016 - __func__, port->chip_port, f->command, f->cookie);
1017 + netdev_dbg(priv->dev, "%s: port %u command %d cookie %lu\n",
1018 + __func__, port, f->command, f->cookie);
1019
1020 if (!ingress) {
1021 NL_SET_ERR_MSG_MOD(extack, "Only ingress is supported");
1022 @@ -34,7 +36,7 @@ static int ocelot_setup_tc_cls_matchall(
1023 return -EOPNOTSUPP;
1024 }
1025
1026 - if (port->tc.block_shared) {
1027 + if (priv->tc.block_shared) {
1028 NL_SET_ERR_MSG_MOD(extack,
1029 "Rate limit is not supported on shared blocks");
1030 return -EOPNOTSUPP;
1031 @@ -47,7 +49,7 @@ static int ocelot_setup_tc_cls_matchall(
1032 return -EOPNOTSUPP;
1033 }
1034
1035 - if (port->tc.police_id && port->tc.police_id != f->cookie) {
1036 + if (priv->tc.police_id && priv->tc.police_id != f->cookie) {
1037 NL_SET_ERR_MSG_MOD(extack,
1038 "Only one policer per port is supported\n");
1039 return -EEXIST;
1040 @@ -58,28 +60,27 @@ static int ocelot_setup_tc_cls_matchall(
1041 PSCHED_NS2TICKS(action->police.burst),
1042 PSCHED_TICKS_PER_SEC);
1043
1044 - err = ocelot_port_policer_add(port->ocelot, port->chip_port,
1045 - &pol);
1046 + err = ocelot_port_policer_add(ocelot, port, &pol);
1047 if (err) {
1048 NL_SET_ERR_MSG_MOD(extack, "Could not add policer\n");
1049 return err;
1050 }
1051
1052 - port->tc.police_id = f->cookie;
1053 - port->tc.offload_cnt++;
1054 + priv->tc.police_id = f->cookie;
1055 + priv->tc.offload_cnt++;
1056 return 0;
1057 case TC_CLSMATCHALL_DESTROY:
1058 - if (port->tc.police_id != f->cookie)
1059 + if (priv->tc.police_id != f->cookie)
1060 return -ENOENT;
1061
1062 - err = ocelot_port_policer_del(port->ocelot, port->chip_port);
1063 + err = ocelot_port_policer_del(ocelot, port);
1064 if (err) {
1065 NL_SET_ERR_MSG_MOD(extack,
1066 "Could not delete policer\n");
1067 return err;
1068 }
1069 - port->tc.police_id = 0;
1070 - port->tc.offload_cnt--;
1071 + priv->tc.police_id = 0;
1072 + priv->tc.offload_cnt--;
1073 return 0;
1074 case TC_CLSMATCHALL_STATS: /* fall through */
1075 default:
1076 @@ -91,21 +92,21 @@ static int ocelot_setup_tc_block_cb(enum
1077 void *type_data,
1078 void *cb_priv, bool ingress)
1079 {
1080 - struct ocelot_port *port = cb_priv;
1081 + struct ocelot_port_private *priv = cb_priv;
1082
1083 - if (!tc_cls_can_offload_and_chain0(port->dev, type_data))
1084 + if (!tc_cls_can_offload_and_chain0(priv->dev, type_data))
1085 return -EOPNOTSUPP;
1086
1087 switch (type) {
1088 case TC_SETUP_CLSMATCHALL:
1089 - netdev_dbg(port->dev, "tc_block_cb: TC_SETUP_CLSMATCHALL %s\n",
1090 + netdev_dbg(priv->dev, "tc_block_cb: TC_SETUP_CLSMATCHALL %s\n",
1091 ingress ? "ingress" : "egress");
1092
1093 - return ocelot_setup_tc_cls_matchall(port, type_data, ingress);
1094 + return ocelot_setup_tc_cls_matchall(priv, type_data, ingress);
1095 case TC_SETUP_CLSFLOWER:
1096 return 0;
1097 default:
1098 - netdev_dbg(port->dev, "tc_block_cb: type %d %s\n",
1099 + netdev_dbg(priv->dev, "tc_block_cb: type %d %s\n",
1100 type,
1101 ingress ? "ingress" : "egress");
1102
1103 @@ -131,19 +132,19 @@ static int ocelot_setup_tc_block_cb_eg(e
1104
1105 static LIST_HEAD(ocelot_block_cb_list);
1106
1107 -static int ocelot_setup_tc_block(struct ocelot_port *port,
1108 +static int ocelot_setup_tc_block(struct ocelot_port_private *priv,
1109 struct flow_block_offload *f)
1110 {
1111 struct flow_block_cb *block_cb;
1112 flow_setup_cb_t *cb;
1113 int err;
1114
1115 - netdev_dbg(port->dev, "tc_block command %d, binder_type %d\n",
1116 + netdev_dbg(priv->dev, "tc_block command %d, binder_type %d\n",
1117 f->command, f->binder_type);
1118
1119 if (f->binder_type == FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS) {
1120 cb = ocelot_setup_tc_block_cb_ig;
1121 - port->tc.block_shared = f->block_shared;
1122 + priv->tc.block_shared = f->block_shared;
1123 } else if (f->binder_type == FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS) {
1124 cb = ocelot_setup_tc_block_cb_eg;
1125 } else {
1126 @@ -154,14 +155,14 @@ static int ocelot_setup_tc_block(struct
1127
1128 switch (f->command) {
1129 case FLOW_BLOCK_BIND:
1130 - if (flow_block_cb_is_busy(cb, port, &ocelot_block_cb_list))
1131 + if (flow_block_cb_is_busy(cb, priv, &ocelot_block_cb_list))
1132 return -EBUSY;
1133
1134 - block_cb = flow_block_cb_alloc(cb, port, port, NULL);
1135 + block_cb = flow_block_cb_alloc(cb, priv, priv, NULL);
1136 if (IS_ERR(block_cb))
1137 return PTR_ERR(block_cb);
1138
1139 - err = ocelot_setup_tc_block_flower_bind(port, f);
1140 + err = ocelot_setup_tc_block_flower_bind(priv, f);
1141 if (err < 0) {
1142 flow_block_cb_free(block_cb);
1143 return err;
1144 @@ -170,11 +171,11 @@ static int ocelot_setup_tc_block(struct
1145 list_add_tail(&block_cb->driver_list, f->driver_block_list);
1146 return 0;
1147 case FLOW_BLOCK_UNBIND:
1148 - block_cb = flow_block_cb_lookup(f->block, cb, port);
1149 + block_cb = flow_block_cb_lookup(f->block, cb, priv);
1150 if (!block_cb)
1151 return -ENOENT;
1152
1153 - ocelot_setup_tc_block_flower_unbind(port, f);
1154 + ocelot_setup_tc_block_flower_unbind(priv, f);
1155 flow_block_cb_remove(block_cb, f);
1156 list_del(&block_cb->driver_list);
1157 return 0;
1158 @@ -186,11 +187,11 @@ static int ocelot_setup_tc_block(struct
1159 int ocelot_setup_tc(struct net_device *dev, enum tc_setup_type type,
1160 void *type_data)
1161 {
1162 - struct ocelot_port *port = netdev_priv(dev);
1163 + struct ocelot_port_private *priv = netdev_priv(dev);
1164
1165 switch (type) {
1166 case TC_SETUP_BLOCK:
1167 - return ocelot_setup_tc_block(port, type_data);
1168 + return ocelot_setup_tc_block(priv, type_data);
1169 default:
1170 return -EOPNOTSUPP;
1171 }