blob: 974821b9cdc4d51f3705e4847b36651a4d65fd43 [file] [log] [blame]
Alexandre Bellonia556c762018-05-14 22:04:57 +02001// SPDX-License-Identifier: (GPL-2.0 OR MIT)
2/*
3 * Microsemi Ocelot Switch driver
4 *
5 * Copyright (c) 2017 Microsemi Corporation
6 */
Alexandre Bellonia556c762018-05-14 22:04:57 +02007#include <linux/if_bridge.h>
Vladimir Oltean20968052020-09-30 01:27:26 +03008#include <soc/mscc/ocelot_vcap.h>
Alexandre Bellonia556c762018-05-14 22:04:57 +02009#include "ocelot.h"
Vladimir Oltean3c836542020-06-20 18:43:45 +030010#include "ocelot_vcap.h"
Alexandre Bellonia556c762018-05-14 22:04:57 +020011
Steen Hegelund639c1b22018-12-20 14:16:31 +010012#define TABLE_UPDATE_SLEEP_US 10
13#define TABLE_UPDATE_TIMEOUT_US 100000
14
Alexandre Bellonia556c762018-05-14 22:04:57 +020015struct ocelot_mact_entry {
16 u8 mac[ETH_ALEN];
17 u16 vid;
18 enum macaccess_entry_type type;
19};
20
Steen Hegelund639c1b22018-12-20 14:16:31 +010021static inline u32 ocelot_mact_read_macaccess(struct ocelot *ocelot)
22{
23 return ocelot_read(ocelot, ANA_TABLES_MACACCESS);
24}
25
Alexandre Bellonia556c762018-05-14 22:04:57 +020026static inline int ocelot_mact_wait_for_completion(struct ocelot *ocelot)
27{
Steen Hegelund639c1b22018-12-20 14:16:31 +010028 u32 val;
Alexandre Bellonia556c762018-05-14 22:04:57 +020029
Steen Hegelund639c1b22018-12-20 14:16:31 +010030 return readx_poll_timeout(ocelot_mact_read_macaccess,
31 ocelot, val,
32 (val & ANA_TABLES_MACACCESS_MAC_TABLE_CMD_M) ==
33 MACACCESS_CMD_IDLE,
34 TABLE_UPDATE_SLEEP_US, TABLE_UPDATE_TIMEOUT_US);
Alexandre Bellonia556c762018-05-14 22:04:57 +020035}
36
37static void ocelot_mact_select(struct ocelot *ocelot,
38 const unsigned char mac[ETH_ALEN],
39 unsigned int vid)
40{
41 u32 macl = 0, mach = 0;
42
43 /* Set the MAC address to handle and the vlan associated in a format
44 * understood by the hardware.
45 */
46 mach |= vid << 16;
47 mach |= mac[0] << 8;
48 mach |= mac[1] << 0;
49 macl |= mac[2] << 24;
50 macl |= mac[3] << 16;
51 macl |= mac[4] << 8;
52 macl |= mac[5] << 0;
53
54 ocelot_write(ocelot, macl, ANA_TABLES_MACLDATA);
55 ocelot_write(ocelot, mach, ANA_TABLES_MACHDATA);
56
57}
58
Vladimir Oltean9c90eea2020-06-20 18:43:44 +030059int ocelot_mact_learn(struct ocelot *ocelot, int port,
60 const unsigned char mac[ETH_ALEN],
61 unsigned int vid, enum macaccess_entry_type type)
Alexandre Bellonia556c762018-05-14 22:04:57 +020062{
63 ocelot_mact_select(ocelot, mac, vid);
64
65 /* Issue a write command */
66 ocelot_write(ocelot, ANA_TABLES_MACACCESS_VALID |
67 ANA_TABLES_MACACCESS_DEST_IDX(port) |
68 ANA_TABLES_MACACCESS_ENTRYTYPE(type) |
69 ANA_TABLES_MACACCESS_MAC_TABLE_CMD(MACACCESS_CMD_LEARN),
70 ANA_TABLES_MACACCESS);
71
72 return ocelot_mact_wait_for_completion(ocelot);
73}
Vladimir Oltean9c90eea2020-06-20 18:43:44 +030074EXPORT_SYMBOL(ocelot_mact_learn);
Alexandre Bellonia556c762018-05-14 22:04:57 +020075
Vladimir Oltean9c90eea2020-06-20 18:43:44 +030076int ocelot_mact_forget(struct ocelot *ocelot,
77 const unsigned char mac[ETH_ALEN], unsigned int vid)
Alexandre Bellonia556c762018-05-14 22:04:57 +020078{
79 ocelot_mact_select(ocelot, mac, vid);
80
81 /* Issue a forget command */
82 ocelot_write(ocelot,
83 ANA_TABLES_MACACCESS_MAC_TABLE_CMD(MACACCESS_CMD_FORGET),
84 ANA_TABLES_MACACCESS);
85
86 return ocelot_mact_wait_for_completion(ocelot);
87}
Vladimir Oltean9c90eea2020-06-20 18:43:44 +030088EXPORT_SYMBOL(ocelot_mact_forget);
Alexandre Bellonia556c762018-05-14 22:04:57 +020089
90static void ocelot_mact_init(struct ocelot *ocelot)
91{
92 /* Configure the learning mode entries attributes:
93 * - Do not copy the frame to the CPU extraction queues.
94 * - Use the vlan and mac_cpoy for dmac lookup.
95 */
96 ocelot_rmw(ocelot, 0,
97 ANA_AGENCTRL_LEARN_CPU_COPY | ANA_AGENCTRL_IGNORE_DMAC_FLAGS
98 | ANA_AGENCTRL_LEARN_FWD_KILL
99 | ANA_AGENCTRL_LEARN_IGNORE_VLAN,
100 ANA_AGENCTRL);
101
102 /* Clear the MAC table */
103 ocelot_write(ocelot, MACACCESS_CMD_INIT, ANA_TABLES_MACACCESS);
104}
105
Vladimir Olteanf270dbf2019-11-09 15:02:52 +0200106static void ocelot_vcap_enable(struct ocelot *ocelot, int port)
Horatiu Vulturb5962292019-05-31 09:16:56 +0200107{
108 ocelot_write_gix(ocelot, ANA_PORT_VCAP_S2_CFG_S2_ENA |
109 ANA_PORT_VCAP_S2_CFG_S2_IP6_CFG(0xa),
Vladimir Olteanf270dbf2019-11-09 15:02:52 +0200110 ANA_PORT_VCAP_S2_CFG, port);
Horatiu Vulturb5962292019-05-31 09:16:56 +0200111}
112
Steen Hegelund639c1b22018-12-20 14:16:31 +0100113static inline u32 ocelot_vlant_read_vlanaccess(struct ocelot *ocelot)
114{
115 return ocelot_read(ocelot, ANA_TABLES_VLANACCESS);
116}
117
Alexandre Bellonia556c762018-05-14 22:04:57 +0200118static inline int ocelot_vlant_wait_for_completion(struct ocelot *ocelot)
119{
Steen Hegelund639c1b22018-12-20 14:16:31 +0100120 u32 val;
Alexandre Bellonia556c762018-05-14 22:04:57 +0200121
Steen Hegelund639c1b22018-12-20 14:16:31 +0100122 return readx_poll_timeout(ocelot_vlant_read_vlanaccess,
123 ocelot,
124 val,
125 (val & ANA_TABLES_VLANACCESS_VLAN_TBL_CMD_M) ==
126 ANA_TABLES_VLANACCESS_CMD_IDLE,
127 TABLE_UPDATE_SLEEP_US, TABLE_UPDATE_TIMEOUT_US);
Alexandre Bellonia556c762018-05-14 22:04:57 +0200128}
129
Antoine Tenart71425292018-06-26 14:28:49 +0200130static int ocelot_vlant_set_mask(struct ocelot *ocelot, u16 vid, u32 mask)
131{
132 /* Select the VID to configure */
133 ocelot_write(ocelot, ANA_TABLES_VLANTIDX_V_INDEX(vid),
134 ANA_TABLES_VLANTIDX);
135 /* Set the vlan port members mask and issue a write command */
136 ocelot_write(ocelot, ANA_TABLES_VLANACCESS_VLAN_PORT_MASK(mask) |
137 ANA_TABLES_VLANACCESS_CMD_WRITE,
138 ANA_TABLES_VLANACCESS);
139
140 return ocelot_vlant_wait_for_completion(ocelot);
141}
142
Vladimir Oltean97bb69e2019-11-09 15:02:47 +0200143static int ocelot_port_set_native_vlan(struct ocelot *ocelot, int port,
144 u16 vid)
145{
146 struct ocelot_port *ocelot_port = ocelot->ports[port];
Vladimir Oltean87b0f982020-04-14 22:36:15 +0300147 u32 val = 0;
Vladimir Oltean97bb69e2019-11-09 15:02:47 +0200148
149 if (ocelot_port->vid != vid) {
150 /* Always permit deleting the native VLAN (vid = 0) */
151 if (ocelot_port->vid && vid) {
152 dev_err(ocelot->dev,
153 "Port already has a native VLAN: %d\n",
154 ocelot_port->vid);
155 return -EBUSY;
156 }
157 ocelot_port->vid = vid;
158 }
159
160 ocelot_rmw_gix(ocelot, REW_PORT_VLAN_CFG_PORT_VID(vid),
Antoine Tenart71425292018-06-26 14:28:49 +0200161 REW_PORT_VLAN_CFG_PORT_VID_M,
Vladimir Oltean97bb69e2019-11-09 15:02:47 +0200162 REW_PORT_VLAN_CFG, port);
163
Vladimir Oltean87b0f982020-04-14 22:36:15 +0300164 if (ocelot_port->vlan_aware && !ocelot_port->vid)
165 /* If port is vlan-aware and tagged, drop untagged and priority
166 * tagged frames.
167 */
168 val = ANA_PORT_DROP_CFG_DROP_UNTAGGED_ENA |
169 ANA_PORT_DROP_CFG_DROP_PRIO_S_TAGGED_ENA |
170 ANA_PORT_DROP_CFG_DROP_PRIO_C_TAGGED_ENA;
171 ocelot_rmw_gix(ocelot, val,
172 ANA_PORT_DROP_CFG_DROP_UNTAGGED_ENA |
173 ANA_PORT_DROP_CFG_DROP_PRIO_S_TAGGED_ENA |
174 ANA_PORT_DROP_CFG_DROP_PRIO_C_TAGGED_ENA,
175 ANA_PORT_DROP_CFG, port);
176
177 if (ocelot_port->vlan_aware) {
178 if (ocelot_port->vid)
179 /* Tag all frames except when VID == DEFAULT_VLAN */
180 val = REW_TAG_CFG_TAG_CFG(1);
181 else
182 /* Tag all frames */
183 val = REW_TAG_CFG_TAG_CFG(3);
184 } else {
185 /* Port tagging disabled. */
186 val = REW_TAG_CFG_TAG_CFG(0);
187 }
188 ocelot_rmw_gix(ocelot, val,
189 REW_TAG_CFG_TAG_CFG_M,
190 REW_TAG_CFG, port);
191
Vladimir Oltean97bb69e2019-11-09 15:02:47 +0200192 return 0;
193}
194
Vladimir Oltean87b0f982020-04-14 22:36:15 +0300195void ocelot_port_vlan_filtering(struct ocelot *ocelot, int port,
196 bool vlan_aware)
197{
198 struct ocelot_port *ocelot_port = ocelot->ports[port];
199 u32 val;
200
201 ocelot_port->vlan_aware = vlan_aware;
202
203 if (vlan_aware)
204 val = ANA_PORT_VLAN_CFG_VLAN_AWARE_ENA |
205 ANA_PORT_VLAN_CFG_VLAN_POP_CNT(1);
206 else
207 val = 0;
208 ocelot_rmw_gix(ocelot, val,
209 ANA_PORT_VLAN_CFG_VLAN_AWARE_ENA |
210 ANA_PORT_VLAN_CFG_VLAN_POP_CNT_M,
211 ANA_PORT_VLAN_CFG, port);
212
213 ocelot_port_set_native_vlan(ocelot, port, ocelot_port->vid);
214}
215EXPORT_SYMBOL(ocelot_port_vlan_filtering);
216
Vladimir Oltean97bb69e2019-11-09 15:02:47 +0200217/* Default vlan to clasify for untagged frames (may be zero) */
218static void ocelot_port_set_pvid(struct ocelot *ocelot, int port, u16 pvid)
219{
220 struct ocelot_port *ocelot_port = ocelot->ports[port];
221
222 ocelot_rmw_gix(ocelot,
223 ANA_PORT_VLAN_CFG_VLAN_VID(pvid),
224 ANA_PORT_VLAN_CFG_VLAN_VID_M,
225 ANA_PORT_VLAN_CFG, port);
226
227 ocelot_port->pvid = pvid;
Antoine Tenart71425292018-06-26 14:28:49 +0200228}
229
Vladimir Oltean5e256362019-11-14 17:03:27 +0200230int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid,
231 bool untagged)
Antoine Tenart71425292018-06-26 14:28:49 +0200232{
Antoine Tenart71425292018-06-26 14:28:49 +0200233 int ret;
234
Antoine Tenart71425292018-06-26 14:28:49 +0200235 /* Make the port a member of the VLAN */
Vladimir Oltean97bb69e2019-11-09 15:02:47 +0200236 ocelot->vlan_mask[vid] |= BIT(port);
Antoine Tenart71425292018-06-26 14:28:49 +0200237 ret = ocelot_vlant_set_mask(ocelot, vid, ocelot->vlan_mask[vid]);
238 if (ret)
239 return ret;
240
241 /* Default ingress vlan classification */
242 if (pvid)
Vladimir Oltean97bb69e2019-11-09 15:02:47 +0200243 ocelot_port_set_pvid(ocelot, port, vid);
Antoine Tenart71425292018-06-26 14:28:49 +0200244
245 /* Untagged egress vlan clasification */
Vladimir Oltean97bb69e2019-11-09 15:02:47 +0200246 if (untagged) {
247 ret = ocelot_port_set_native_vlan(ocelot, port, vid);
248 if (ret)
249 return ret;
Vladimir Olteanb9cd75e2019-10-26 21:04:27 +0300250 }
Antoine Tenart71425292018-06-26 14:28:49 +0200251
Antoine Tenart71425292018-06-26 14:28:49 +0200252 return 0;
253}
Vladimir Oltean5e256362019-11-14 17:03:27 +0200254EXPORT_SYMBOL(ocelot_vlan_add);
Antoine Tenart71425292018-06-26 14:28:49 +0200255
Vladimir Oltean5e256362019-11-14 17:03:27 +0200256int ocelot_vlan_del(struct ocelot *ocelot, int port, u16 vid)
Vladimir Oltean98559342019-11-09 15:02:48 +0200257{
258 struct ocelot_port *ocelot_port = ocelot->ports[port];
259 int ret;
Antoine Tenart71425292018-06-26 14:28:49 +0200260
261 /* Stop the port from being a member of the vlan */
Vladimir Oltean97bb69e2019-11-09 15:02:47 +0200262 ocelot->vlan_mask[vid] &= ~BIT(port);
Antoine Tenart71425292018-06-26 14:28:49 +0200263 ret = ocelot_vlant_set_mask(ocelot, vid, ocelot->vlan_mask[vid]);
264 if (ret)
265 return ret;
266
267 /* Ingress */
Vladimir Oltean97bb69e2019-11-09 15:02:47 +0200268 if (ocelot_port->pvid == vid)
269 ocelot_port_set_pvid(ocelot, port, 0);
Antoine Tenart71425292018-06-26 14:28:49 +0200270
271 /* Egress */
Vladimir Oltean97bb69e2019-11-09 15:02:47 +0200272 if (ocelot_port->vid == vid)
273 ocelot_port_set_native_vlan(ocelot, port, 0);
Antoine Tenart71425292018-06-26 14:28:49 +0200274
275 return 0;
276}
Vladimir Oltean5e256362019-11-14 17:03:27 +0200277EXPORT_SYMBOL(ocelot_vlan_del);
Antoine Tenart71425292018-06-26 14:28:49 +0200278
Alexandre Bellonia556c762018-05-14 22:04:57 +0200279static void ocelot_vlan_init(struct ocelot *ocelot)
280{
Antoine Tenart71425292018-06-26 14:28:49 +0200281 u16 port, vid;
282
Alexandre Bellonia556c762018-05-14 22:04:57 +0200283 /* Clear VLAN table, by default all ports are members of all VLANs */
284 ocelot_write(ocelot, ANA_TABLES_VLANACCESS_CMD_INIT,
285 ANA_TABLES_VLANACCESS);
286 ocelot_vlant_wait_for_completion(ocelot);
Antoine Tenart71425292018-06-26 14:28:49 +0200287
288 /* Configure the port VLAN memberships */
289 for (vid = 1; vid < VLAN_N_VID; vid++) {
290 ocelot->vlan_mask[vid] = 0;
291 ocelot_vlant_set_mask(ocelot, vid, ocelot->vlan_mask[vid]);
292 }
293
294 /* Because VLAN filtering is enabled, we need VID 0 to get untagged
295 * traffic. It is added automatically if 8021q module is loaded, but
296 * we can't rely on it since module may be not loaded.
297 */
298 ocelot->vlan_mask[0] = GENMASK(ocelot->num_phys_ports - 1, 0);
299 ocelot_vlant_set_mask(ocelot, 0, ocelot->vlan_mask[0]);
300
Antoine Tenart71425292018-06-26 14:28:49 +0200301 /* Set vlan ingress filter mask to all ports but the CPU port by
302 * default.
303 */
Vladimir Oltean714d0ff2019-11-09 15:02:55 +0200304 ocelot_write(ocelot, GENMASK(ocelot->num_phys_ports - 1, 0),
305 ANA_VLANMASK);
Antoine Tenart71425292018-06-26 14:28:49 +0200306
307 for (port = 0; port < ocelot->num_phys_ports; port++) {
308 ocelot_write_gix(ocelot, 0, REW_PORT_VLAN_CFG, port);
309 ocelot_write_gix(ocelot, 0, REW_TAG_CFG, port);
310 }
Alexandre Bellonia556c762018-05-14 22:04:57 +0200311}
312
Vladimir Oltean5e256362019-11-14 17:03:27 +0200313void ocelot_adjust_link(struct ocelot *ocelot, int port,
314 struct phy_device *phydev)
Alexandre Bellonia556c762018-05-14 22:04:57 +0200315{
Vladimir Oltean26f4dba2019-11-09 15:02:59 +0200316 struct ocelot_port *ocelot_port = ocelot->ports[port];
Vladimir Oltean5bc9d2e2019-11-14 17:03:22 +0200317 int speed, mode = 0;
Alexandre Bellonia556c762018-05-14 22:04:57 +0200318
Vladimir Oltean26f4dba2019-11-09 15:02:59 +0200319 switch (phydev->speed) {
Alexandre Bellonia556c762018-05-14 22:04:57 +0200320 case SPEED_10:
321 speed = OCELOT_SPEED_10;
322 break;
323 case SPEED_100:
324 speed = OCELOT_SPEED_100;
325 break;
326 case SPEED_1000:
327 speed = OCELOT_SPEED_1000;
328 mode = DEV_MAC_MODE_CFG_GIGA_MODE_ENA;
329 break;
330 case SPEED_2500:
331 speed = OCELOT_SPEED_2500;
332 mode = DEV_MAC_MODE_CFG_GIGA_MODE_ENA;
333 break;
334 default:
Vladimir Oltean26f4dba2019-11-09 15:02:59 +0200335 dev_err(ocelot->dev, "Unsupported PHY speed on port %d: %d\n",
336 port, phydev->speed);
Alexandre Bellonia556c762018-05-14 22:04:57 +0200337 return;
338 }
339
Vladimir Oltean26f4dba2019-11-09 15:02:59 +0200340 phy_print_status(phydev);
Alexandre Bellonia556c762018-05-14 22:04:57 +0200341
Vladimir Oltean26f4dba2019-11-09 15:02:59 +0200342 if (!phydev->link)
Alexandre Bellonia556c762018-05-14 22:04:57 +0200343 return;
344
345 /* Only full duplex supported for now */
Vladimir Oltean004d44f2019-11-09 15:02:53 +0200346 ocelot_port_writel(ocelot_port, DEV_MAC_MODE_CFG_FDX_ENA |
Alexandre Bellonia556c762018-05-14 22:04:57 +0200347 mode, DEV_MAC_MODE_CFG);
348
Vladimir Oltean1ba8f652020-02-29 16:31:11 +0200349 /* Disable HDX fast control */
350 ocelot_port_writel(ocelot_port, DEV_PORT_MISC_HDX_FAST_DIS,
351 DEV_PORT_MISC);
352
353 /* SGMII only for now */
354 ocelot_port_writel(ocelot_port, PCS1G_MODE_CFG_SGMII_MODE_ENA,
355 PCS1G_MODE_CFG);
356 ocelot_port_writel(ocelot_port, PCS1G_SD_CFG_SD_SEL, PCS1G_SD_CFG);
357
358 /* Enable PCS */
359 ocelot_port_writel(ocelot_port, PCS1G_CFG_PCS_ENA, PCS1G_CFG);
360
361 /* No aneg on SGMII */
362 ocelot_port_writel(ocelot_port, 0, PCS1G_ANEG_CFG);
363
364 /* No loopback */
365 ocelot_port_writel(ocelot_port, 0, PCS1G_LB_CFG);
Alexandre Bellonia556c762018-05-14 22:04:57 +0200366
Alexandre Bellonia556c762018-05-14 22:04:57 +0200367 /* Enable MAC module */
Vladimir Oltean004d44f2019-11-09 15:02:53 +0200368 ocelot_port_writel(ocelot_port, DEV_MAC_ENA_CFG_RX_ENA |
Alexandre Bellonia556c762018-05-14 22:04:57 +0200369 DEV_MAC_ENA_CFG_TX_ENA, DEV_MAC_ENA_CFG);
370
371 /* Take MAC, Port, Phy (intern) and PCS (SGMII/Serdes) clock out of
372 * reset */
Vladimir Oltean004d44f2019-11-09 15:02:53 +0200373 ocelot_port_writel(ocelot_port, DEV_CLOCK_CFG_LINK_SPEED(speed),
Alexandre Bellonia556c762018-05-14 22:04:57 +0200374 DEV_CLOCK_CFG);
375
Alexandre Bellonia556c762018-05-14 22:04:57 +0200376 /* No PFC */
377 ocelot_write_gix(ocelot, ANA_PFC_PFC_CFG_FC_LINK_SPEED(speed),
Vladimir Oltean004d44f2019-11-09 15:02:53 +0200378 ANA_PFC_PFC_CFG, port);
Alexandre Bellonia556c762018-05-14 22:04:57 +0200379
Alexandre Bellonia556c762018-05-14 22:04:57 +0200380 /* Core: Enable port for frame transfer */
Vladimir Oltean886e1382020-07-13 19:57:03 +0300381 ocelot_fields_write(ocelot, port,
382 QSYS_SWITCH_PORT_MODE_PORT_ENA, 1);
Alexandre Bellonia556c762018-05-14 22:04:57 +0200383
384 /* Flow control */
385 ocelot_write_rix(ocelot, SYS_MAC_FC_CFG_PAUSE_VAL_CFG(0xffff) |
386 SYS_MAC_FC_CFG_RX_FC_ENA | SYS_MAC_FC_CFG_TX_FC_ENA |
387 SYS_MAC_FC_CFG_ZERO_PAUSE_ENA |
388 SYS_MAC_FC_CFG_FC_LATENCY_CFG(0x7) |
389 SYS_MAC_FC_CFG_FC_LINK_SPEED(speed),
Vladimir Oltean004d44f2019-11-09 15:02:53 +0200390 SYS_MAC_FC_CFG, port);
391 ocelot_write_rix(ocelot, 0, ANA_POL_FLOWC, port);
Alexandre Bellonia556c762018-05-14 22:04:57 +0200392}
Vladimir Oltean5e256362019-11-14 17:03:27 +0200393EXPORT_SYMBOL(ocelot_adjust_link);
Alexandre Bellonia556c762018-05-14 22:04:57 +0200394
Vladimir Oltean5e256362019-11-14 17:03:27 +0200395void ocelot_port_enable(struct ocelot *ocelot, int port,
396 struct phy_device *phy)
Alexandre Bellonia556c762018-05-14 22:04:57 +0200397{
Alexandre Bellonia556c762018-05-14 22:04:57 +0200398 /* Enable receiving frames on the port, and activate auto-learning of
399 * MAC addresses.
400 */
401 ocelot_write_gix(ocelot, ANA_PORT_PORT_CFG_LEARNAUTO |
402 ANA_PORT_PORT_CFG_RECV_ENA |
Vladimir Oltean004d44f2019-11-09 15:02:53 +0200403 ANA_PORT_PORT_CFG_PORTID_VAL(port),
404 ANA_PORT_PORT_CFG, port);
Vladimir Oltean889b8952019-11-09 15:02:57 +0200405}
Vladimir Oltean5e256362019-11-14 17:03:27 +0200406EXPORT_SYMBOL(ocelot_port_enable);
Vladimir Oltean889b8952019-11-09 15:02:57 +0200407
Vladimir Oltean5e256362019-11-14 17:03:27 +0200408void ocelot_port_disable(struct ocelot *ocelot, int port)
Vladimir Oltean889b8952019-11-09 15:02:57 +0200409{
410 struct ocelot_port *ocelot_port = ocelot->ports[port];
411
412 ocelot_port_writel(ocelot_port, 0, DEV_MAC_ENA_CFG);
Vladimir Oltean886e1382020-07-13 19:57:03 +0300413 ocelot_fields_write(ocelot, port, QSYS_SWITCH_PORT_MODE_PORT_ENA, 0);
Vladimir Oltean889b8952019-11-09 15:02:57 +0200414}
Vladimir Oltean5e256362019-11-14 17:03:27 +0200415EXPORT_SYMBOL(ocelot_port_disable);
Vladimir Oltean889b8952019-11-09 15:02:57 +0200416
Vladimir Olteane2f9a8f2020-09-23 14:24:20 +0300417void ocelot_port_add_txtstamp_skb(struct ocelot *ocelot, int port,
418 struct sk_buff *clone)
Yangbo Lu400928b2019-11-20 16:23:16 +0800419{
Vladimir Olteane2f9a8f2020-09-23 14:24:20 +0300420 struct ocelot_port *ocelot_port = ocelot->ports[port];
Yangbo Lu400928b2019-11-20 16:23:16 +0800421
Vladimir Olteane2f9a8f2020-09-23 14:24:20 +0300422 spin_lock(&ocelot_port->ts_id_lock);
Vladimir Oltean65652432020-09-18 04:07:24 +0300423
Vladimir Olteane2f9a8f2020-09-23 14:24:20 +0300424 skb_shinfo(clone)->tx_flags |= SKBTX_IN_PROGRESS;
425 /* Store timestamp ID in cb[0] of sk_buff */
426 clone->cb[0] = ocelot_port->ts_id;
427 ocelot_port->ts_id = (ocelot_port->ts_id + 1) % 4;
428 skb_queue_tail(&ocelot_port->tx_skbs, clone);
Vladimir Oltean65652432020-09-18 04:07:24 +0300429
Vladimir Olteane2f9a8f2020-09-23 14:24:20 +0300430 spin_unlock(&ocelot_port->ts_id_lock);
Yangbo Lu400928b2019-11-20 16:23:16 +0800431}
432EXPORT_SYMBOL(ocelot_port_add_txtstamp_skb);
433
Yangbo Lue23a7b32019-11-20 16:23:15 +0800434static void ocelot_get_hwtimestamp(struct ocelot *ocelot,
435 struct timespec64 *ts)
Antoine Tenart4e3b0462019-08-12 16:45:37 +0200436{
437 unsigned long flags;
438 u32 val;
439
440 spin_lock_irqsave(&ocelot->ptp_clock_lock, flags);
441
442 /* Read current PTP time to get seconds */
443 val = ocelot_read_rix(ocelot, PTP_PIN_CFG, TOD_ACC_PIN);
444
445 val &= ~(PTP_PIN_CFG_SYNC | PTP_PIN_CFG_ACTION_MASK | PTP_PIN_CFG_DOM);
446 val |= PTP_PIN_CFG_ACTION(PTP_PIN_ACTION_SAVE);
447 ocelot_write_rix(ocelot, val, PTP_PIN_CFG, TOD_ACC_PIN);
448 ts->tv_sec = ocelot_read_rix(ocelot, PTP_PIN_TOD_SEC_LSB, TOD_ACC_PIN);
449
450 /* Read packet HW timestamp from FIFO */
451 val = ocelot_read(ocelot, SYS_PTP_TXSTAMP);
452 ts->tv_nsec = SYS_PTP_TXSTAMP_PTP_TXSTAMP(val);
453
454 /* Sec has incremented since the ts was registered */
455 if ((ts->tv_sec & 0x1) != !!(val & SYS_PTP_TXSTAMP_PTP_TXSTAMP_SEC))
456 ts->tv_sec--;
457
458 spin_unlock_irqrestore(&ocelot->ptp_clock_lock, flags);
459}
Yangbo Lue23a7b32019-11-20 16:23:15 +0800460
461void ocelot_get_txtstamp(struct ocelot *ocelot)
462{
463 int budget = OCELOT_PTP_QUEUE_SZ;
464
465 while (budget--) {
Yangbo Lub049da12019-11-27 15:27:57 +0800466 struct sk_buff *skb, *skb_tmp, *skb_match = NULL;
Yangbo Lue23a7b32019-11-20 16:23:15 +0800467 struct skb_shared_hwtstamps shhwtstamps;
Yangbo Lue23a7b32019-11-20 16:23:15 +0800468 struct ocelot_port *port;
469 struct timespec64 ts;
Yangbo Lub049da12019-11-27 15:27:57 +0800470 unsigned long flags;
Yangbo Lue23a7b32019-11-20 16:23:15 +0800471 u32 val, id, txport;
472
473 val = ocelot_read(ocelot, SYS_PTP_STATUS);
474
475 /* Check if a timestamp can be retrieved */
476 if (!(val & SYS_PTP_STATUS_PTP_MESS_VLD))
477 break;
478
479 WARN_ON(val & SYS_PTP_STATUS_PTP_OVFL);
480
481 /* Retrieve the ts ID and Tx port */
482 id = SYS_PTP_STATUS_PTP_MESS_ID_X(val);
483 txport = SYS_PTP_STATUS_PTP_MESS_TXPORT_X(val);
484
485 /* Retrieve its associated skb */
486 port = ocelot->ports[txport];
487
Yangbo Lub049da12019-11-27 15:27:57 +0800488 spin_lock_irqsave(&port->tx_skbs.lock, flags);
489
490 skb_queue_walk_safe(&port->tx_skbs, skb, skb_tmp) {
491 if (skb->cb[0] != id)
Yangbo Lue23a7b32019-11-20 16:23:15 +0800492 continue;
Yangbo Lub049da12019-11-27 15:27:57 +0800493 __skb_unlink(skb, &port->tx_skbs);
494 skb_match = skb;
Yangbo Lufc62c092019-11-27 15:27:56 +0800495 break;
Yangbo Lue23a7b32019-11-20 16:23:15 +0800496 }
497
Yangbo Lub049da12019-11-27 15:27:57 +0800498 spin_unlock_irqrestore(&port->tx_skbs.lock, flags);
499
laurent brando5fd82202020-07-27 18:26:14 +0800500 /* Get the h/w timestamp */
501 ocelot_get_hwtimestamp(ocelot, &ts);
Yangbo Lue23a7b32019-11-20 16:23:15 +0800502
Yangbo Lub049da12019-11-27 15:27:57 +0800503 if (unlikely(!skb_match))
Yangbo Lue23a7b32019-11-20 16:23:15 +0800504 continue;
505
Yangbo Lue23a7b32019-11-20 16:23:15 +0800506 /* Set the timestamp into the skb */
507 memset(&shhwtstamps, 0, sizeof(shhwtstamps));
508 shhwtstamps.hwtstamp = ktime_set(ts.tv_sec, ts.tv_nsec);
Vladimir Olteane2f9a8f2020-09-23 14:24:20 +0300509 skb_complete_tx_timestamp(skb_match, &shhwtstamps);
laurent brando5fd82202020-07-27 18:26:14 +0800510
511 /* Next ts */
512 ocelot_write(ocelot, SYS_PTP_NXT_PTP_NXT, SYS_PTP_NXT);
Yangbo Lue23a7b32019-11-20 16:23:15 +0800513 }
514}
515EXPORT_SYMBOL(ocelot_get_txtstamp);
Antoine Tenart4e3b0462019-08-12 16:45:37 +0200516
Vladimir Oltean5e256362019-11-14 17:03:27 +0200517int ocelot_fdb_add(struct ocelot *ocelot, int port,
Vladimir Oltean87b0f982020-04-14 22:36:15 +0300518 const unsigned char *addr, u16 vid)
Alexandre Bellonia556c762018-05-14 22:04:57 +0200519{
Vladimir Oltean531ee1a2019-11-09 15:02:49 +0200520 struct ocelot_port *ocelot_port = ocelot->ports[port];
Vladimir Oltean471beb12020-06-21 14:46:00 +0300521 int pgid = port;
522
523 if (port == ocelot->npi)
524 pgid = PGID_CPU;
Alexandre Bellonia556c762018-05-14 22:04:57 +0200525
Antoine Tenart71425292018-06-26 14:28:49 +0200526 if (!vid) {
Vladimir Oltean87b0f982020-04-14 22:36:15 +0300527 if (!ocelot_port->vlan_aware)
Antoine Tenart71425292018-06-26 14:28:49 +0200528 /* If the bridge is not VLAN aware and no VID was
529 * provided, set it to pvid to ensure the MAC entry
530 * matches incoming untagged packets
531 */
Vladimir Oltean531ee1a2019-11-09 15:02:49 +0200532 vid = ocelot_port->pvid;
Antoine Tenart71425292018-06-26 14:28:49 +0200533 else
534 /* If the bridge is VLAN aware a VID must be provided as
535 * otherwise the learnt entry wouldn't match any frame.
536 */
537 return -EINVAL;
538 }
539
Vladimir Oltean471beb12020-06-21 14:46:00 +0300540 return ocelot_mact_learn(ocelot, pgid, addr, vid, ENTRYTYPE_LOCKED);
Alexandre Bellonia556c762018-05-14 22:04:57 +0200541}
Vladimir Oltean5e256362019-11-14 17:03:27 +0200542EXPORT_SYMBOL(ocelot_fdb_add);
Alexandre Bellonia556c762018-05-14 22:04:57 +0200543
Vladimir Oltean5e256362019-11-14 17:03:27 +0200544int ocelot_fdb_del(struct ocelot *ocelot, int port,
545 const unsigned char *addr, u16 vid)
Alexandre Bellonia556c762018-05-14 22:04:57 +0200546{
Alexandre Bellonia556c762018-05-14 22:04:57 +0200547 return ocelot_mact_forget(ocelot, addr, vid);
548}
Vladimir Oltean5e256362019-11-14 17:03:27 +0200549EXPORT_SYMBOL(ocelot_fdb_del);
Alexandre Bellonia556c762018-05-14 22:04:57 +0200550
Vladimir Oltean9c90eea2020-06-20 18:43:44 +0300551int ocelot_port_fdb_do_dump(const unsigned char *addr, u16 vid,
552 bool is_static, void *data)
Alexandre Bellonia556c762018-05-14 22:04:57 +0200553{
Vladimir Oltean531ee1a2019-11-09 15:02:49 +0200554 struct ocelot_dump_ctx *dump = data;
Alexandre Bellonia556c762018-05-14 22:04:57 +0200555 u32 portid = NETLINK_CB(dump->cb->skb).portid;
556 u32 seq = dump->cb->nlh->nlmsg_seq;
557 struct nlmsghdr *nlh;
558 struct ndmsg *ndm;
559
560 if (dump->idx < dump->cb->args[2])
561 goto skip;
562
563 nlh = nlmsg_put(dump->skb, portid, seq, RTM_NEWNEIGH,
564 sizeof(*ndm), NLM_F_MULTI);
565 if (!nlh)
566 return -EMSGSIZE;
567
568 ndm = nlmsg_data(nlh);
569 ndm->ndm_family = AF_BRIDGE;
570 ndm->ndm_pad1 = 0;
571 ndm->ndm_pad2 = 0;
572 ndm->ndm_flags = NTF_SELF;
573 ndm->ndm_type = 0;
574 ndm->ndm_ifindex = dump->dev->ifindex;
Vladimir Oltean531ee1a2019-11-09 15:02:49 +0200575 ndm->ndm_state = is_static ? NUD_NOARP : NUD_REACHABLE;
Alexandre Bellonia556c762018-05-14 22:04:57 +0200576
Vladimir Oltean531ee1a2019-11-09 15:02:49 +0200577 if (nla_put(dump->skb, NDA_LLADDR, ETH_ALEN, addr))
Alexandre Bellonia556c762018-05-14 22:04:57 +0200578 goto nla_put_failure;
579
Vladimir Oltean531ee1a2019-11-09 15:02:49 +0200580 if (vid && nla_put_u16(dump->skb, NDA_VLAN, vid))
Alexandre Bellonia556c762018-05-14 22:04:57 +0200581 goto nla_put_failure;
582
583 nlmsg_end(dump->skb, nlh);
584
585skip:
586 dump->idx++;
587 return 0;
588
589nla_put_failure:
590 nlmsg_cancel(dump->skb, nlh);
591 return -EMSGSIZE;
592}
Vladimir Oltean9c90eea2020-06-20 18:43:44 +0300593EXPORT_SYMBOL(ocelot_port_fdb_do_dump);
Alexandre Bellonia556c762018-05-14 22:04:57 +0200594
Vladimir Oltean531ee1a2019-11-09 15:02:49 +0200595static int ocelot_mact_read(struct ocelot *ocelot, int port, int row, int col,
596 struct ocelot_mact_entry *entry)
Alexandre Bellonia556c762018-05-14 22:04:57 +0200597{
Alexandre Bellonia556c762018-05-14 22:04:57 +0200598 u32 val, dst, macl, mach;
Vladimir Oltean531ee1a2019-11-09 15:02:49 +0200599 char mac[ETH_ALEN];
Alexandre Bellonia556c762018-05-14 22:04:57 +0200600
601 /* Set row and column to read from */
602 ocelot_field_write(ocelot, ANA_TABLES_MACTINDX_M_INDEX, row);
603 ocelot_field_write(ocelot, ANA_TABLES_MACTINDX_BUCKET, col);
604
605 /* Issue a read command */
606 ocelot_write(ocelot,
607 ANA_TABLES_MACACCESS_MAC_TABLE_CMD(MACACCESS_CMD_READ),
608 ANA_TABLES_MACACCESS);
609
610 if (ocelot_mact_wait_for_completion(ocelot))
611 return -ETIMEDOUT;
612
613 /* Read the entry flags */
614 val = ocelot_read(ocelot, ANA_TABLES_MACACCESS);
615 if (!(val & ANA_TABLES_MACACCESS_VALID))
616 return -EINVAL;
617
618 /* If the entry read has another port configured as its destination,
619 * do not report it.
620 */
621 dst = (val & ANA_TABLES_MACACCESS_DEST_IDX_M) >> 3;
Vladimir Oltean531ee1a2019-11-09 15:02:49 +0200622 if (dst != port)
Alexandre Bellonia556c762018-05-14 22:04:57 +0200623 return -EINVAL;
624
625 /* Get the entry's MAC address and VLAN id */
626 macl = ocelot_read(ocelot, ANA_TABLES_MACLDATA);
627 mach = ocelot_read(ocelot, ANA_TABLES_MACHDATA);
628
629 mac[0] = (mach >> 8) & 0xff;
630 mac[1] = (mach >> 0) & 0xff;
631 mac[2] = (macl >> 24) & 0xff;
632 mac[3] = (macl >> 16) & 0xff;
633 mac[4] = (macl >> 8) & 0xff;
634 mac[5] = (macl >> 0) & 0xff;
635
636 entry->vid = (mach >> 16) & 0xfff;
637 ether_addr_copy(entry->mac, mac);
638
639 return 0;
640}
641
Vladimir Oltean5e256362019-11-14 17:03:27 +0200642int ocelot_fdb_dump(struct ocelot *ocelot, int port,
643 dsa_fdb_dump_cb_t *cb, void *data)
Alexandre Bellonia556c762018-05-14 22:04:57 +0200644{
Vladimir Oltean531ee1a2019-11-09 15:02:49 +0200645 int i, j;
Alexandre Bellonia556c762018-05-14 22:04:57 +0200646
Vladimir Oltean21ce7f32020-05-04 01:20:26 +0300647 /* Loop through all the mac tables entries. */
648 for (i = 0; i < ocelot->num_mact_rows; i++) {
Alexandre Bellonia556c762018-05-14 22:04:57 +0200649 for (j = 0; j < 4; j++) {
Vladimir Oltean531ee1a2019-11-09 15:02:49 +0200650 struct ocelot_mact_entry entry;
651 bool is_static;
652 int ret;
653
654 ret = ocelot_mact_read(ocelot, port, i, j, &entry);
Alexandre Bellonia556c762018-05-14 22:04:57 +0200655 /* If the entry is invalid (wrong port, invalid...),
656 * skip it.
657 */
658 if (ret == -EINVAL)
659 continue;
660 else if (ret)
Vladimir Oltean531ee1a2019-11-09 15:02:49 +0200661 return ret;
Alexandre Bellonia556c762018-05-14 22:04:57 +0200662
Vladimir Oltean531ee1a2019-11-09 15:02:49 +0200663 is_static = (entry.type == ENTRYTYPE_LOCKED);
664
665 ret = cb(entry.mac, entry.vid, is_static, data);
Alexandre Bellonia556c762018-05-14 22:04:57 +0200666 if (ret)
Vladimir Oltean531ee1a2019-11-09 15:02:49 +0200667 return ret;
Alexandre Bellonia556c762018-05-14 22:04:57 +0200668 }
669 }
670
Vladimir Oltean531ee1a2019-11-09 15:02:49 +0200671 return 0;
672}
Vladimir Oltean5e256362019-11-14 17:03:27 +0200673EXPORT_SYMBOL(ocelot_fdb_dump);
Vladimir Oltean531ee1a2019-11-09 15:02:49 +0200674
Yangbo Luf1459222019-11-20 16:23:14 +0800675int ocelot_hwstamp_get(struct ocelot *ocelot, int port, struct ifreq *ifr)
Antoine Tenart4e3b0462019-08-12 16:45:37 +0200676{
Antoine Tenart4e3b0462019-08-12 16:45:37 +0200677 return copy_to_user(ifr->ifr_data, &ocelot->hwtstamp_config,
678 sizeof(ocelot->hwtstamp_config)) ? -EFAULT : 0;
679}
Yangbo Luf1459222019-11-20 16:23:14 +0800680EXPORT_SYMBOL(ocelot_hwstamp_get);
Antoine Tenart4e3b0462019-08-12 16:45:37 +0200681
Yangbo Luf1459222019-11-20 16:23:14 +0800682int ocelot_hwstamp_set(struct ocelot *ocelot, int port, struct ifreq *ifr)
Antoine Tenart4e3b0462019-08-12 16:45:37 +0200683{
Vladimir Oltean306fd442019-11-09 15:02:50 +0200684 struct ocelot_port *ocelot_port = ocelot->ports[port];
Antoine Tenart4e3b0462019-08-12 16:45:37 +0200685 struct hwtstamp_config cfg;
686
687 if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg)))
688 return -EFAULT;
689
690 /* reserved for future extensions */
691 if (cfg.flags)
692 return -EINVAL;
693
694 /* Tx type sanity check */
695 switch (cfg.tx_type) {
696 case HWTSTAMP_TX_ON:
Vladimir Oltean306fd442019-11-09 15:02:50 +0200697 ocelot_port->ptp_cmd = IFH_REW_OP_TWO_STEP_PTP;
Antoine Tenart4e3b0462019-08-12 16:45:37 +0200698 break;
699 case HWTSTAMP_TX_ONESTEP_SYNC:
700 /* IFH_REW_OP_ONE_STEP_PTP updates the correctional field, we
701 * need to update the origin time.
702 */
Vladimir Oltean306fd442019-11-09 15:02:50 +0200703 ocelot_port->ptp_cmd = IFH_REW_OP_ORIGIN_PTP;
Antoine Tenart4e3b0462019-08-12 16:45:37 +0200704 break;
705 case HWTSTAMP_TX_OFF:
Vladimir Oltean306fd442019-11-09 15:02:50 +0200706 ocelot_port->ptp_cmd = 0;
Antoine Tenart4e3b0462019-08-12 16:45:37 +0200707 break;
708 default:
709 return -ERANGE;
710 }
711
712 mutex_lock(&ocelot->ptp_lock);
713
714 switch (cfg.rx_filter) {
715 case HWTSTAMP_FILTER_NONE:
716 break;
717 case HWTSTAMP_FILTER_ALL:
718 case HWTSTAMP_FILTER_SOME:
719 case HWTSTAMP_FILTER_PTP_V1_L4_EVENT:
720 case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
721 case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
722 case HWTSTAMP_FILTER_NTP_ALL:
723 case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
724 case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
725 case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
726 case HWTSTAMP_FILTER_PTP_V2_L2_EVENT:
727 case HWTSTAMP_FILTER_PTP_V2_L2_SYNC:
728 case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ:
729 case HWTSTAMP_FILTER_PTP_V2_EVENT:
730 case HWTSTAMP_FILTER_PTP_V2_SYNC:
731 case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
732 cfg.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
733 break;
734 default:
735 mutex_unlock(&ocelot->ptp_lock);
736 return -ERANGE;
737 }
738
739 /* Commit back the result & save it */
740 memcpy(&ocelot->hwtstamp_config, &cfg, sizeof(cfg));
741 mutex_unlock(&ocelot->ptp_lock);
742
743 return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0;
744}
Yangbo Luf1459222019-11-20 16:23:14 +0800745EXPORT_SYMBOL(ocelot_hwstamp_set);
Antoine Tenart4e3b0462019-08-12 16:45:37 +0200746
Vladimir Oltean5e256362019-11-14 17:03:27 +0200747void ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset, u8 *data)
Alexandre Bellonia556c762018-05-14 22:04:57 +0200748{
Alexandre Bellonia556c762018-05-14 22:04:57 +0200749 int i;
750
751 if (sset != ETH_SS_STATS)
752 return;
753
754 for (i = 0; i < ocelot->num_stats; i++)
755 memcpy(data + i * ETH_GSTRING_LEN, ocelot->stats_layout[i].name,
756 ETH_GSTRING_LEN);
757}
Vladimir Oltean5e256362019-11-14 17:03:27 +0200758EXPORT_SYMBOL(ocelot_get_strings);
Alexandre Bellonia556c762018-05-14 22:04:57 +0200759
Claudiu Manoil1e1caa92019-04-16 17:51:59 +0300760static void ocelot_update_stats(struct ocelot *ocelot)
Alexandre Bellonia556c762018-05-14 22:04:57 +0200761{
Alexandre Bellonia556c762018-05-14 22:04:57 +0200762 int i, j;
763
764 mutex_lock(&ocelot->stats_lock);
765
766 for (i = 0; i < ocelot->num_phys_ports; i++) {
767 /* Configure the port to read the stats from */
768 ocelot_write(ocelot, SYS_STAT_CFG_STAT_VIEW(i), SYS_STAT_CFG);
769
770 for (j = 0; j < ocelot->num_stats; j++) {
771 u32 val;
772 unsigned int idx = i * ocelot->num_stats + j;
773
774 val = ocelot_read_rix(ocelot, SYS_COUNT_RX_OCTETS,
775 ocelot->stats_layout[j].offset);
776
777 if (val < (ocelot->stats[idx] & U32_MAX))
778 ocelot->stats[idx] += (u64)1 << 32;
779
780 ocelot->stats[idx] = (ocelot->stats[idx] &
781 ~(u64)U32_MAX) + val;
782 }
783 }
784
Claudiu Manoil1e1caa92019-04-16 17:51:59 +0300785 mutex_unlock(&ocelot->stats_lock);
786}
787
788static void ocelot_check_stats_work(struct work_struct *work)
789{
790 struct delayed_work *del_work = to_delayed_work(work);
791 struct ocelot *ocelot = container_of(del_work, struct ocelot,
792 stats_work);
793
794 ocelot_update_stats(ocelot);
795
Alexandre Bellonia556c762018-05-14 22:04:57 +0200796 queue_delayed_work(ocelot->stats_queue, &ocelot->stats_work,
797 OCELOT_STATS_CHECK_DELAY);
Alexandre Bellonia556c762018-05-14 22:04:57 +0200798}
799
Vladimir Oltean5e256362019-11-14 17:03:27 +0200800void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data)
Alexandre Bellonia556c762018-05-14 22:04:57 +0200801{
Alexandre Bellonia556c762018-05-14 22:04:57 +0200802 int i;
803
804 /* check and update now */
Claudiu Manoil1e1caa92019-04-16 17:51:59 +0300805 ocelot_update_stats(ocelot);
Alexandre Bellonia556c762018-05-14 22:04:57 +0200806
807 /* Copy all counters */
808 for (i = 0; i < ocelot->num_stats; i++)
Vladimir Oltean004d44f2019-11-09 15:02:53 +0200809 *data++ = ocelot->stats[port * ocelot->num_stats + i];
Alexandre Bellonia556c762018-05-14 22:04:57 +0200810}
Vladimir Oltean5e256362019-11-14 17:03:27 +0200811EXPORT_SYMBOL(ocelot_get_ethtool_stats);
Alexandre Bellonia556c762018-05-14 22:04:57 +0200812
Vladimir Oltean5e256362019-11-14 17:03:27 +0200813int ocelot_get_sset_count(struct ocelot *ocelot, int port, int sset)
Vladimir Olteanc7282d32019-11-09 15:02:54 +0200814{
Alexandre Bellonia556c762018-05-14 22:04:57 +0200815 if (sset != ETH_SS_STATS)
816 return -EOPNOTSUPP;
Vladimir Olteanc7282d32019-11-09 15:02:54 +0200817
Alexandre Bellonia556c762018-05-14 22:04:57 +0200818 return ocelot->num_stats;
819}
Vladimir Oltean5e256362019-11-14 17:03:27 +0200820EXPORT_SYMBOL(ocelot_get_sset_count);
Alexandre Bellonia556c762018-05-14 22:04:57 +0200821
Vladimir Oltean5e256362019-11-14 17:03:27 +0200822int ocelot_get_ts_info(struct ocelot *ocelot, int port,
823 struct ethtool_ts_info *info)
Vladimir Olteanc7282d32019-11-09 15:02:54 +0200824{
Antoine Tenart4e3b0462019-08-12 16:45:37 +0200825 info->phc_index = ocelot->ptp_clock ?
826 ptp_clock_index(ocelot->ptp_clock) : -1;
Yangbo Lud2b09a82020-04-20 10:46:46 +0800827 if (info->phc_index == -1) {
828 info->so_timestamping |= SOF_TIMESTAMPING_TX_SOFTWARE |
829 SOF_TIMESTAMPING_RX_SOFTWARE |
830 SOF_TIMESTAMPING_SOFTWARE;
831 return 0;
832 }
Antoine Tenart4e3b0462019-08-12 16:45:37 +0200833 info->so_timestamping |= SOF_TIMESTAMPING_TX_SOFTWARE |
834 SOF_TIMESTAMPING_RX_SOFTWARE |
835 SOF_TIMESTAMPING_SOFTWARE |
836 SOF_TIMESTAMPING_TX_HARDWARE |
837 SOF_TIMESTAMPING_RX_HARDWARE |
838 SOF_TIMESTAMPING_RAW_HARDWARE;
839 info->tx_types = BIT(HWTSTAMP_TX_OFF) | BIT(HWTSTAMP_TX_ON) |
840 BIT(HWTSTAMP_TX_ONESTEP_SYNC);
841 info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) | BIT(HWTSTAMP_FILTER_ALL);
842
843 return 0;
844}
Vladimir Oltean5e256362019-11-14 17:03:27 +0200845EXPORT_SYMBOL(ocelot_get_ts_info);
Antoine Tenart4e3b0462019-08-12 16:45:37 +0200846
Vladimir Oltean5e256362019-11-14 17:03:27 +0200847void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, u8 state)
Alexandre Bellonia556c762018-05-14 22:04:57 +0200848{
Alexandre Bellonia556c762018-05-14 22:04:57 +0200849 u32 port_cfg;
Vladimir Oltean4bda1412019-11-09 15:02:51 +0200850 int p, i;
Alexandre Bellonia556c762018-05-14 22:04:57 +0200851
Vladimir Oltean4bda1412019-11-09 15:02:51 +0200852 if (!(BIT(port) & ocelot->bridge_mask))
853 return;
Alexandre Bellonia556c762018-05-14 22:04:57 +0200854
Vladimir Oltean4bda1412019-11-09 15:02:51 +0200855 port_cfg = ocelot_read_gix(ocelot, ANA_PORT_PORT_CFG, port);
Alexandre Bellonia556c762018-05-14 22:04:57 +0200856
857 switch (state) {
858 case BR_STATE_FORWARDING:
Vladimir Oltean4bda1412019-11-09 15:02:51 +0200859 ocelot->bridge_fwd_mask |= BIT(port);
Gustavo A. R. Silvadf561f662020-08-23 17:36:59 -0500860 fallthrough;
Alexandre Bellonia556c762018-05-14 22:04:57 +0200861 case BR_STATE_LEARNING:
862 port_cfg |= ANA_PORT_PORT_CFG_LEARN_ENA;
863 break;
864
865 default:
866 port_cfg &= ~ANA_PORT_PORT_CFG_LEARN_ENA;
Vladimir Oltean4bda1412019-11-09 15:02:51 +0200867 ocelot->bridge_fwd_mask &= ~BIT(port);
Alexandre Bellonia556c762018-05-14 22:04:57 +0200868 break;
869 }
870
Vladimir Oltean4bda1412019-11-09 15:02:51 +0200871 ocelot_write_gix(ocelot, port_cfg, ANA_PORT_PORT_CFG, port);
Alexandre Bellonia556c762018-05-14 22:04:57 +0200872
873 /* Apply FWD mask. The loop is needed to add/remove the current port as
874 * a source for the other ports.
875 */
Vladimir Oltean4bda1412019-11-09 15:02:51 +0200876 for (p = 0; p < ocelot->num_phys_ports; p++) {
Vladimir Oltean69df5782020-02-29 16:50:02 +0200877 if (ocelot->bridge_fwd_mask & BIT(p)) {
Vladimir Oltean4bda1412019-11-09 15:02:51 +0200878 unsigned long mask = ocelot->bridge_fwd_mask & ~BIT(p);
Alexandre Bellonia556c762018-05-14 22:04:57 +0200879
880 for (i = 0; i < ocelot->num_phys_ports; i++) {
881 unsigned long bond_mask = ocelot->lags[i];
882
883 if (!bond_mask)
884 continue;
885
Vladimir Oltean4bda1412019-11-09 15:02:51 +0200886 if (bond_mask & BIT(p)) {
Alexandre Bellonia556c762018-05-14 22:04:57 +0200887 mask &= ~bond_mask;
888 break;
889 }
890 }
891
Vladimir Olteanc9d22032019-11-09 15:03:01 +0200892 ocelot_write_rix(ocelot, mask,
Vladimir Oltean4bda1412019-11-09 15:02:51 +0200893 ANA_PGID_PGID, PGID_SRC + p);
Alexandre Bellonia556c762018-05-14 22:04:57 +0200894 } else {
Vladimir Oltean69df5782020-02-29 16:50:02 +0200895 ocelot_write_rix(ocelot, 0,
Vladimir Oltean4bda1412019-11-09 15:02:51 +0200896 ANA_PGID_PGID, PGID_SRC + p);
Alexandre Bellonia556c762018-05-14 22:04:57 +0200897 }
898 }
Alexandre Bellonia556c762018-05-14 22:04:57 +0200899}
Vladimir Oltean5e256362019-11-14 17:03:27 +0200900EXPORT_SYMBOL(ocelot_bridge_stp_state_set);
Alexandre Bellonia556c762018-05-14 22:04:57 +0200901
Vladimir Oltean5e256362019-11-14 17:03:27 +0200902void ocelot_set_ageing_time(struct ocelot *ocelot, unsigned int msecs)
Vladimir Oltean4bda1412019-11-09 15:02:51 +0200903{
Vladimir Olteanc0d7ecc2020-05-04 01:20:27 +0300904 unsigned int age_period = ANA_AUTOAGE_AGE_PERIOD(msecs / 2000);
905
906 /* Setting AGE_PERIOD to zero effectively disables automatic aging,
907 * which is clearly not what our intention is. So avoid that.
908 */
909 if (!age_period)
910 age_period = 1;
911
912 ocelot_rmw(ocelot, age_period, ANA_AUTOAGE_AGE_PERIOD_M, ANA_AUTOAGE);
Alexandre Bellonia556c762018-05-14 22:04:57 +0200913}
Vladimir Oltean5e256362019-11-14 17:03:27 +0200914EXPORT_SYMBOL(ocelot_set_ageing_time);
Alexandre Bellonia556c762018-05-14 22:04:57 +0200915
Alexandre Bellonia556c762018-05-14 22:04:57 +0200916static struct ocelot_multicast *ocelot_multicast_get(struct ocelot *ocelot,
917 const unsigned char *addr,
918 u16 vid)
919{
920 struct ocelot_multicast *mc;
921
922 list_for_each_entry(mc, &ocelot->multicast, list) {
923 if (ether_addr_equal(mc->addr, addr) && mc->vid == vid)
924 return mc;
925 }
926
927 return NULL;
928}
929
Vladimir Oltean9403c152020-06-21 14:46:03 +0300930static enum macaccess_entry_type ocelot_classify_mdb(const unsigned char *addr)
931{
932 if (addr[0] == 0x01 && addr[1] == 0x00 && addr[2] == 0x5e)
933 return ENTRYTYPE_MACv4;
934 if (addr[0] == 0x33 && addr[1] == 0x33)
935 return ENTRYTYPE_MACv6;
936 return ENTRYTYPE_NORMAL;
937}
938
939static int ocelot_mdb_get_pgid(struct ocelot *ocelot,
940 enum macaccess_entry_type entry_type)
941{
942 int pgid;
943
944 /* According to VSC7514 datasheet 3.9.1.5 IPv4 Multicast Entries and
945 * 3.9.1.6 IPv6 Multicast Entries, "Instead of a lookup in the
946 * destination mask table (PGID), the destination set is programmed as
947 * part of the entry MAC address.", and the DEST_IDX is set to 0.
948 */
949 if (entry_type == ENTRYTYPE_MACv4 ||
950 entry_type == ENTRYTYPE_MACv6)
951 return 0;
952
953 for_each_nonreserved_multicast_dest_pgid(ocelot, pgid) {
954 struct ocelot_multicast *mc;
955 bool used = false;
956
957 list_for_each_entry(mc, &ocelot->multicast, list) {
958 if (mc->pgid == pgid) {
959 used = true;
960 break;
961 }
962 }
963
964 if (!used)
965 return pgid;
966 }
967
968 return -1;
969}
970
971static void ocelot_encode_ports_to_mdb(unsigned char *addr,
972 struct ocelot_multicast *mc,
973 enum macaccess_entry_type entry_type)
974{
975 memcpy(addr, mc->addr, ETH_ALEN);
976
977 if (entry_type == ENTRYTYPE_MACv4) {
978 addr[0] = 0;
979 addr[1] = mc->ports >> 8;
980 addr[2] = mc->ports & 0xff;
981 } else if (entry_type == ENTRYTYPE_MACv6) {
982 addr[0] = mc->ports >> 8;
983 addr[1] = mc->ports & 0xff;
984 }
985}
986
Vladimir Oltean209edf92020-06-21 14:46:01 +0300987int ocelot_port_mdb_add(struct ocelot *ocelot, int port,
988 const struct switchdev_obj_port_mdb *mdb)
Alexandre Bellonia556c762018-05-14 22:04:57 +0200989{
Vladimir Oltean209edf92020-06-21 14:46:01 +0300990 struct ocelot_port *ocelot_port = ocelot->ports[port];
Vladimir Oltean9403c152020-06-21 14:46:03 +0300991 enum macaccess_entry_type entry_type;
Alexandre Bellonia556c762018-05-14 22:04:57 +0200992 unsigned char addr[ETH_ALEN];
Vladimir Oltean004d44f2019-11-09 15:02:53 +0200993 struct ocelot_multicast *mc;
Alexandre Bellonia556c762018-05-14 22:04:57 +0200994 u16 vid = mdb->vid;
995 bool new = false;
996
Vladimir Oltean471beb12020-06-21 14:46:00 +0300997 if (port == ocelot->npi)
998 port = ocelot->num_phys_ports;
999
Alexandre Bellonia556c762018-05-14 22:04:57 +02001000 if (!vid)
Vladimir Oltean004d44f2019-11-09 15:02:53 +02001001 vid = ocelot_port->pvid;
Alexandre Bellonia556c762018-05-14 22:04:57 +02001002
Vladimir Oltean9403c152020-06-21 14:46:03 +03001003 entry_type = ocelot_classify_mdb(mdb->addr);
1004
Alexandre Bellonia556c762018-05-14 22:04:57 +02001005 mc = ocelot_multicast_get(ocelot, mdb->addr, vid);
1006 if (!mc) {
Vladimir Oltean9403c152020-06-21 14:46:03 +03001007 int pgid = ocelot_mdb_get_pgid(ocelot, entry_type);
1008
1009 if (pgid < 0) {
1010 dev_err(ocelot->dev,
1011 "No more PGIDs available for mdb %pM vid %d\n",
1012 mdb->addr, vid);
1013 return -ENOSPC;
1014 }
1015
Alexandre Bellonia556c762018-05-14 22:04:57 +02001016 mc = devm_kzalloc(ocelot->dev, sizeof(*mc), GFP_KERNEL);
1017 if (!mc)
1018 return -ENOMEM;
1019
1020 memcpy(mc->addr, mdb->addr, ETH_ALEN);
1021 mc->vid = vid;
Vladimir Oltean9403c152020-06-21 14:46:03 +03001022 mc->pgid = pgid;
Alexandre Bellonia556c762018-05-14 22:04:57 +02001023
1024 list_add_tail(&mc->list, &ocelot->multicast);
1025 new = true;
1026 }
1027
Alexandre Bellonia556c762018-05-14 22:04:57 +02001028 if (!new) {
Vladimir Oltean9403c152020-06-21 14:46:03 +03001029 ocelot_encode_ports_to_mdb(addr, mc, entry_type);
Alexandre Bellonia556c762018-05-14 22:04:57 +02001030 ocelot_mact_forget(ocelot, addr, vid);
1031 }
1032
Vladimir Oltean004d44f2019-11-09 15:02:53 +02001033 mc->ports |= BIT(port);
Vladimir Oltean9403c152020-06-21 14:46:03 +03001034 ocelot_encode_ports_to_mdb(addr, mc, entry_type);
Alexandre Bellonia556c762018-05-14 22:04:57 +02001035
Vladimir Oltean9403c152020-06-21 14:46:03 +03001036 return ocelot_mact_learn(ocelot, mc->pgid, addr, vid, entry_type);
Alexandre Bellonia556c762018-05-14 22:04:57 +02001037}
Vladimir Oltean209edf92020-06-21 14:46:01 +03001038EXPORT_SYMBOL(ocelot_port_mdb_add);
Alexandre Bellonia556c762018-05-14 22:04:57 +02001039
Vladimir Oltean209edf92020-06-21 14:46:01 +03001040int ocelot_port_mdb_del(struct ocelot *ocelot, int port,
1041 const struct switchdev_obj_port_mdb *mdb)
Alexandre Bellonia556c762018-05-14 22:04:57 +02001042{
Vladimir Oltean209edf92020-06-21 14:46:01 +03001043 struct ocelot_port *ocelot_port = ocelot->ports[port];
Vladimir Oltean9403c152020-06-21 14:46:03 +03001044 enum macaccess_entry_type entry_type;
Alexandre Bellonia556c762018-05-14 22:04:57 +02001045 unsigned char addr[ETH_ALEN];
Vladimir Oltean004d44f2019-11-09 15:02:53 +02001046 struct ocelot_multicast *mc;
Alexandre Bellonia556c762018-05-14 22:04:57 +02001047 u16 vid = mdb->vid;
1048
Vladimir Oltean471beb12020-06-21 14:46:00 +03001049 if (port == ocelot->npi)
1050 port = ocelot->num_phys_ports;
1051
Alexandre Bellonia556c762018-05-14 22:04:57 +02001052 if (!vid)
Vladimir Oltean004d44f2019-11-09 15:02:53 +02001053 vid = ocelot_port->pvid;
Alexandre Bellonia556c762018-05-14 22:04:57 +02001054
1055 mc = ocelot_multicast_get(ocelot, mdb->addr, vid);
1056 if (!mc)
1057 return -ENOENT;
1058
Vladimir Oltean9403c152020-06-21 14:46:03 +03001059 entry_type = ocelot_classify_mdb(mdb->addr);
1060
1061 ocelot_encode_ports_to_mdb(addr, mc, entry_type);
Alexandre Bellonia556c762018-05-14 22:04:57 +02001062 ocelot_mact_forget(ocelot, addr, vid);
1063
Vladimir Oltean004d44f2019-11-09 15:02:53 +02001064 mc->ports &= ~BIT(port);
Alexandre Bellonia556c762018-05-14 22:04:57 +02001065 if (!mc->ports) {
1066 list_del(&mc->list);
1067 devm_kfree(ocelot->dev, mc);
1068 return 0;
1069 }
1070
Vladimir Oltean9403c152020-06-21 14:46:03 +03001071 ocelot_encode_ports_to_mdb(addr, mc, entry_type);
Alexandre Bellonia556c762018-05-14 22:04:57 +02001072
Vladimir Oltean9403c152020-06-21 14:46:03 +03001073 return ocelot_mact_learn(ocelot, mc->pgid, addr, vid, entry_type);
Alexandre Bellonia556c762018-05-14 22:04:57 +02001074}
Vladimir Oltean209edf92020-06-21 14:46:01 +03001075EXPORT_SYMBOL(ocelot_port_mdb_del);
Alexandre Bellonia556c762018-05-14 22:04:57 +02001076
Vladimir Oltean5e256362019-11-14 17:03:27 +02001077int ocelot_port_bridge_join(struct ocelot *ocelot, int port,
1078 struct net_device *bridge)
Alexandre Bellonia556c762018-05-14 22:04:57 +02001079{
Alexandre Bellonia556c762018-05-14 22:04:57 +02001080 if (!ocelot->bridge_mask) {
1081 ocelot->hw_bridge_dev = bridge;
1082 } else {
1083 if (ocelot->hw_bridge_dev != bridge)
1084 /* This is adding the port to a second bridge, this is
1085 * unsupported */
1086 return -ENODEV;
1087 }
1088
Vladimir Olteanf270dbf2019-11-09 15:02:52 +02001089 ocelot->bridge_mask |= BIT(port);
Alexandre Bellonia556c762018-05-14 22:04:57 +02001090
1091 return 0;
1092}
Vladimir Oltean5e256362019-11-14 17:03:27 +02001093EXPORT_SYMBOL(ocelot_port_bridge_join);
Alexandre Bellonia556c762018-05-14 22:04:57 +02001094
Vladimir Oltean5e256362019-11-14 17:03:27 +02001095int ocelot_port_bridge_leave(struct ocelot *ocelot, int port,
1096 struct net_device *bridge)
Alexandre Bellonia556c762018-05-14 22:04:57 +02001097{
Vladimir Oltean97bb69e2019-11-09 15:02:47 +02001098 ocelot->bridge_mask &= ~BIT(port);
Alexandre Bellonia556c762018-05-14 22:04:57 +02001099
1100 if (!ocelot->bridge_mask)
1101 ocelot->hw_bridge_dev = NULL;
Antoine Tenart71425292018-06-26 14:28:49 +02001102
Vladimir Oltean97bb69e2019-11-09 15:02:47 +02001103 ocelot_port_vlan_filtering(ocelot, port, 0);
1104 ocelot_port_set_pvid(ocelot, port, 0);
1105 return ocelot_port_set_native_vlan(ocelot, port, 0);
Alexandre Bellonia556c762018-05-14 22:04:57 +02001106}
Vladimir Oltean5e256362019-11-14 17:03:27 +02001107EXPORT_SYMBOL(ocelot_port_bridge_leave);
Alexandre Bellonia556c762018-05-14 22:04:57 +02001108
Alexandre Bellonidc96ee32018-06-26 14:28:48 +02001109static void ocelot_set_aggr_pgids(struct ocelot *ocelot)
1110{
1111 int i, port, lag;
1112
1113 /* Reset destination and aggregation PGIDS */
Vladimir Oltean96b029b2020-06-21 14:46:02 +03001114 for_each_unicast_dest_pgid(ocelot, port)
Alexandre Bellonidc96ee32018-06-26 14:28:48 +02001115 ocelot_write_rix(ocelot, BIT(port), ANA_PGID_PGID, port);
1116
Vladimir Oltean96b029b2020-06-21 14:46:02 +03001117 for_each_aggr_pgid(ocelot, i)
Alexandre Bellonidc96ee32018-06-26 14:28:48 +02001118 ocelot_write_rix(ocelot, GENMASK(ocelot->num_phys_ports - 1, 0),
1119 ANA_PGID_PGID, i);
1120
1121 /* Now, set PGIDs for each LAG */
1122 for (lag = 0; lag < ocelot->num_phys_ports; lag++) {
1123 unsigned long bond_mask;
1124 int aggr_count = 0;
1125 u8 aggr_idx[16];
1126
1127 bond_mask = ocelot->lags[lag];
1128 if (!bond_mask)
1129 continue;
1130
1131 for_each_set_bit(port, &bond_mask, ocelot->num_phys_ports) {
1132 // Destination mask
1133 ocelot_write_rix(ocelot, bond_mask,
1134 ANA_PGID_PGID, port);
1135 aggr_idx[aggr_count] = port;
1136 aggr_count++;
1137 }
1138
Vladimir Oltean96b029b2020-06-21 14:46:02 +03001139 for_each_aggr_pgid(ocelot, i) {
Alexandre Bellonidc96ee32018-06-26 14:28:48 +02001140 u32 ac;
1141
1142 ac = ocelot_read_rix(ocelot, ANA_PGID_PGID, i);
1143 ac &= ~bond_mask;
1144 ac |= BIT(aggr_idx[i % aggr_count]);
1145 ocelot_write_rix(ocelot, ac, ANA_PGID_PGID, i);
1146 }
1147 }
1148}
1149
1150static void ocelot_setup_lag(struct ocelot *ocelot, int lag)
1151{
1152 unsigned long bond_mask = ocelot->lags[lag];
1153 unsigned int p;
1154
1155 for_each_set_bit(p, &bond_mask, ocelot->num_phys_ports) {
1156 u32 port_cfg = ocelot_read_gix(ocelot, ANA_PORT_PORT_CFG, p);
1157
1158 port_cfg &= ~ANA_PORT_PORT_CFG_PORTID_VAL_M;
1159
1160 /* Use lag port as logical port for port i */
1161 ocelot_write_gix(ocelot, port_cfg |
1162 ANA_PORT_PORT_CFG_PORTID_VAL(lag),
1163 ANA_PORT_PORT_CFG, p);
1164 }
1165}
1166
Vladimir Oltean9c90eea2020-06-20 18:43:44 +03001167int ocelot_port_lag_join(struct ocelot *ocelot, int port,
1168 struct net_device *bond)
Alexandre Bellonidc96ee32018-06-26 14:28:48 +02001169{
Alexandre Bellonidc96ee32018-06-26 14:28:48 +02001170 struct net_device *ndev;
1171 u32 bond_mask = 0;
Vladimir Olteanf270dbf2019-11-09 15:02:52 +02001172 int lag, lp;
Alexandre Bellonidc96ee32018-06-26 14:28:48 +02001173
1174 rcu_read_lock();
1175 for_each_netdev_in_bond_rcu(bond, ndev) {
Vladimir Oltean004d44f2019-11-09 15:02:53 +02001176 struct ocelot_port_private *priv = netdev_priv(ndev);
Alexandre Bellonidc96ee32018-06-26 14:28:48 +02001177
Vladimir Oltean004d44f2019-11-09 15:02:53 +02001178 bond_mask |= BIT(priv->chip_port);
Alexandre Bellonidc96ee32018-06-26 14:28:48 +02001179 }
1180 rcu_read_unlock();
1181
1182 lp = __ffs(bond_mask);
1183
1184 /* If the new port is the lowest one, use it as the logical port from
1185 * now on
1186 */
Vladimir Olteanf270dbf2019-11-09 15:02:52 +02001187 if (port == lp) {
1188 lag = port;
1189 ocelot->lags[port] = bond_mask;
1190 bond_mask &= ~BIT(port);
Alexandre Bellonidc96ee32018-06-26 14:28:48 +02001191 if (bond_mask) {
1192 lp = __ffs(bond_mask);
1193 ocelot->lags[lp] = 0;
1194 }
1195 } else {
1196 lag = lp;
Vladimir Olteanf270dbf2019-11-09 15:02:52 +02001197 ocelot->lags[lp] |= BIT(port);
Alexandre Bellonidc96ee32018-06-26 14:28:48 +02001198 }
1199
1200 ocelot_setup_lag(ocelot, lag);
1201 ocelot_set_aggr_pgids(ocelot);
1202
1203 return 0;
1204}
Vladimir Oltean9c90eea2020-06-20 18:43:44 +03001205EXPORT_SYMBOL(ocelot_port_lag_join);
Alexandre Bellonidc96ee32018-06-26 14:28:48 +02001206
Vladimir Oltean9c90eea2020-06-20 18:43:44 +03001207void ocelot_port_lag_leave(struct ocelot *ocelot, int port,
1208 struct net_device *bond)
Alexandre Bellonidc96ee32018-06-26 14:28:48 +02001209{
Alexandre Bellonidc96ee32018-06-26 14:28:48 +02001210 u32 port_cfg;
1211 int i;
1212
1213 /* Remove port from any lag */
1214 for (i = 0; i < ocelot->num_phys_ports; i++)
Vladimir Olteanf270dbf2019-11-09 15:02:52 +02001215 ocelot->lags[i] &= ~BIT(port);
Alexandre Bellonidc96ee32018-06-26 14:28:48 +02001216
1217 /* if it was the logical port of the lag, move the lag config to the
1218 * next port
1219 */
Vladimir Olteanf270dbf2019-11-09 15:02:52 +02001220 if (ocelot->lags[port]) {
1221 int n = __ffs(ocelot->lags[port]);
Alexandre Bellonidc96ee32018-06-26 14:28:48 +02001222
Vladimir Olteanf270dbf2019-11-09 15:02:52 +02001223 ocelot->lags[n] = ocelot->lags[port];
1224 ocelot->lags[port] = 0;
Alexandre Bellonidc96ee32018-06-26 14:28:48 +02001225
1226 ocelot_setup_lag(ocelot, n);
1227 }
1228
Vladimir Olteanf270dbf2019-11-09 15:02:52 +02001229 port_cfg = ocelot_read_gix(ocelot, ANA_PORT_PORT_CFG, port);
Alexandre Bellonidc96ee32018-06-26 14:28:48 +02001230 port_cfg &= ~ANA_PORT_PORT_CFG_PORTID_VAL_M;
Vladimir Olteanf270dbf2019-11-09 15:02:52 +02001231 ocelot_write_gix(ocelot, port_cfg | ANA_PORT_PORT_CFG_PORTID_VAL(port),
1232 ANA_PORT_PORT_CFG, port);
Alexandre Bellonidc96ee32018-06-26 14:28:48 +02001233
1234 ocelot_set_aggr_pgids(ocelot);
1235}
Vladimir Oltean9c90eea2020-06-20 18:43:44 +03001236EXPORT_SYMBOL(ocelot_port_lag_leave);
Petr Machata0e332c82018-11-22 23:30:11 +00001237
Vladimir Olteana8015de2020-03-10 03:28:18 +02001238/* Configure the maximum SDU (L2 payload) on RX to the value specified in @sdu.
1239 * The length of VLAN tags is accounted for automatically via DEV_MAC_TAGS_CFG.
Vladimir Oltean0b912fc2020-03-27 21:55:47 +02001240 * In the special case that it's the NPI port that we're configuring, the
1241 * length of the tag and optional prefix needs to be accounted for privately,
1242 * in order to be able to sustain communication at the requested @sdu.
Vladimir Olteana8015de2020-03-10 03:28:18 +02001243 */
Vladimir Oltean0b912fc2020-03-27 21:55:47 +02001244void ocelot_port_set_maxlen(struct ocelot *ocelot, int port, size_t sdu)
Vladimir Oltean31350d72019-11-09 15:02:56 +02001245{
1246 struct ocelot_port *ocelot_port = ocelot->ports[port];
Vladimir Olteana8015de2020-03-10 03:28:18 +02001247 int maxlen = sdu + ETH_HLEN + ETH_FCS_LEN;
Vladimir Olteane8e6e732020-07-13 19:57:05 +03001248 int pause_start, pause_stop;
Vladimir Oltean5bc9d2e2019-11-14 17:03:22 +02001249 int atop_wm;
Vladimir Oltean31350d72019-11-09 15:02:56 +02001250
Vladimir Oltean0b912fc2020-03-27 21:55:47 +02001251 if (port == ocelot->npi) {
1252 maxlen += OCELOT_TAG_LEN;
1253
1254 if (ocelot->inj_prefix == OCELOT_TAG_PREFIX_SHORT)
1255 maxlen += OCELOT_SHORT_PREFIX_LEN;
1256 else if (ocelot->inj_prefix == OCELOT_TAG_PREFIX_LONG)
1257 maxlen += OCELOT_LONG_PREFIX_LEN;
1258 }
1259
Vladimir Olteana8015de2020-03-10 03:28:18 +02001260 ocelot_port_writel(ocelot_port, maxlen, DEV_MAC_MAXLEN_CFG);
Vladimir Olteanfa914e92019-11-14 17:03:23 +02001261
Vladimir Olteane8e6e732020-07-13 19:57:05 +03001262 /* Set Pause watermark hysteresis */
1263 pause_start = 6 * maxlen / OCELOT_BUFFER_CELL_SZ;
1264 pause_stop = 4 * maxlen / OCELOT_BUFFER_CELL_SZ;
Maxim Kochetkov541132f2020-07-13 19:57:07 +03001265 ocelot_fields_write(ocelot, port, SYS_PAUSE_CFG_PAUSE_START,
1266 pause_start);
1267 ocelot_fields_write(ocelot, port, SYS_PAUSE_CFG_PAUSE_STOP,
1268 pause_stop);
Vladimir Olteanfa914e92019-11-14 17:03:23 +02001269
1270 /* Tail dropping watermark */
Vladimir Olteana8015de2020-03-10 03:28:18 +02001271 atop_wm = (ocelot->shared_queue_sz - 9 * maxlen) /
1272 OCELOT_BUFFER_CELL_SZ;
Maxim Kochetkovaa92d832020-07-13 19:57:08 +03001273 ocelot_write_rix(ocelot, ocelot->ops->wm_enc(9 * maxlen),
Vladimir Olteanfa914e92019-11-14 17:03:23 +02001274 SYS_ATOP, port);
Maxim Kochetkovaa92d832020-07-13 19:57:08 +03001275 ocelot_write(ocelot, ocelot->ops->wm_enc(atop_wm), SYS_ATOP_TOT_CFG);
Vladimir Olteanfa914e92019-11-14 17:03:23 +02001276}
Vladimir Oltean0b912fc2020-03-27 21:55:47 +02001277EXPORT_SYMBOL(ocelot_port_set_maxlen);
1278
1279int ocelot_get_max_mtu(struct ocelot *ocelot, int port)
1280{
1281 int max_mtu = 65535 - ETH_HLEN - ETH_FCS_LEN;
1282
1283 if (port == ocelot->npi) {
1284 max_mtu -= OCELOT_TAG_LEN;
1285
1286 if (ocelot->inj_prefix == OCELOT_TAG_PREFIX_SHORT)
1287 max_mtu -= OCELOT_SHORT_PREFIX_LEN;
1288 else if (ocelot->inj_prefix == OCELOT_TAG_PREFIX_LONG)
1289 max_mtu -= OCELOT_LONG_PREFIX_LEN;
1290 }
1291
1292 return max_mtu;
1293}
1294EXPORT_SYMBOL(ocelot_get_max_mtu);
Vladimir Olteanfa914e92019-11-14 17:03:23 +02001295
Vladimir Oltean5e256362019-11-14 17:03:27 +02001296void ocelot_init_port(struct ocelot *ocelot, int port)
Vladimir Olteanfa914e92019-11-14 17:03:23 +02001297{
1298 struct ocelot_port *ocelot_port = ocelot->ports[port];
1299
Yangbo Lub049da12019-11-27 15:27:57 +08001300 skb_queue_head_init(&ocelot_port->tx_skbs);
Vladimir Oltean65652432020-09-18 04:07:24 +03001301 spin_lock_init(&ocelot_port->ts_id_lock);
Vladimir Oltean31350d72019-11-09 15:02:56 +02001302
1303 /* Basic L2 initialization */
1304
Vladimir Oltean5bc9d2e2019-11-14 17:03:22 +02001305 /* Set MAC IFG Gaps
1306 * FDX: TX_IFG = 5, RX_IFG1 = RX_IFG2 = 0
1307 * !FDX: TX_IFG = 5, RX_IFG1 = RX_IFG2 = 5
1308 */
1309 ocelot_port_writel(ocelot_port, DEV_MAC_IFG_CFG_TX_IFG(5),
1310 DEV_MAC_IFG_CFG);
1311
1312 /* Load seed (0) and set MAC HDX late collision */
1313 ocelot_port_writel(ocelot_port, DEV_MAC_HDX_CFG_LATE_COL_POS(67) |
1314 DEV_MAC_HDX_CFG_SEED_LOAD,
1315 DEV_MAC_HDX_CFG);
1316 mdelay(1);
1317 ocelot_port_writel(ocelot_port, DEV_MAC_HDX_CFG_LATE_COL_POS(67),
1318 DEV_MAC_HDX_CFG);
1319
1320 /* Set Max Length and maximum tags allowed */
Vladimir Olteana8015de2020-03-10 03:28:18 +02001321 ocelot_port_set_maxlen(ocelot, port, ETH_DATA_LEN);
Vladimir Oltean5bc9d2e2019-11-14 17:03:22 +02001322 ocelot_port_writel(ocelot_port, DEV_MAC_TAGS_CFG_TAG_ID(ETH_P_8021AD) |
1323 DEV_MAC_TAGS_CFG_VLAN_AWR_ENA |
Vladimir Olteana8015de2020-03-10 03:28:18 +02001324 DEV_MAC_TAGS_CFG_VLAN_DBL_AWR_ENA |
Vladimir Oltean5bc9d2e2019-11-14 17:03:22 +02001325 DEV_MAC_TAGS_CFG_VLAN_LEN_AWR_ENA,
1326 DEV_MAC_TAGS_CFG);
1327
1328 /* Set SMAC of Pause frame (00:00:00:00:00:00) */
1329 ocelot_port_writel(ocelot_port, 0, DEV_MAC_FC_MAC_HIGH_CFG);
1330 ocelot_port_writel(ocelot_port, 0, DEV_MAC_FC_MAC_LOW_CFG);
1331
Vladimir Olteane8e6e732020-07-13 19:57:05 +03001332 /* Enable transmission of pause frames */
Maxim Kochetkov541132f2020-07-13 19:57:07 +03001333 ocelot_fields_write(ocelot, port, SYS_PAUSE_CFG_PAUSE_ENA, 1);
Vladimir Olteane8e6e732020-07-13 19:57:05 +03001334
Vladimir Oltean31350d72019-11-09 15:02:56 +02001335 /* Drop frames with multicast source address */
1336 ocelot_rmw_gix(ocelot, ANA_PORT_DROP_CFG_DROP_MC_SMAC_ENA,
1337 ANA_PORT_DROP_CFG_DROP_MC_SMAC_ENA,
1338 ANA_PORT_DROP_CFG, port);
1339
1340 /* Set default VLAN and tag type to 8021Q. */
1341 ocelot_rmw_gix(ocelot, REW_PORT_VLAN_CFG_PORT_TPID(ETH_P_8021Q),
1342 REW_PORT_VLAN_CFG_PORT_TPID_M,
1343 REW_PORT_VLAN_CFG, port);
1344
1345 /* Enable vcap lookups */
1346 ocelot_vcap_enable(ocelot, port);
1347}
Vladimir Oltean5e256362019-11-14 17:03:27 +02001348EXPORT_SYMBOL(ocelot_init_port);
Vladimir Oltean31350d72019-11-09 15:02:56 +02001349
Vladimir Oltean2d44b092020-09-26 22:32:01 +03001350/* Configure and enable the CPU port module, which is a set of queues
1351 * accessible through register MMIO, frame DMA or Ethernet (in case
1352 * NPI mode is used).
Vladimir Oltean69df5782020-02-29 16:50:02 +02001353 */
Vladimir Oltean2d44b092020-09-26 22:32:01 +03001354static void ocelot_cpu_port_init(struct ocelot *ocelot)
Vladimir Oltean21468192019-11-09 15:03:00 +02001355{
Vladimir Oltean69df5782020-02-29 16:50:02 +02001356 int cpu = ocelot->num_phys_ports;
1357
1358 /* The unicast destination PGID for the CPU port module is unused */
Vladimir Oltean21468192019-11-09 15:03:00 +02001359 ocelot_write_rix(ocelot, 0, ANA_PGID_PGID, cpu);
Vladimir Oltean69df5782020-02-29 16:50:02 +02001360 /* Instead set up a multicast destination PGID for traffic copied to
1361 * the CPU. Whitelisted MAC addresses like the port netdevice MAC
1362 * addresses will be copied to the CPU via this PGID.
1363 */
Vladimir Oltean21468192019-11-09 15:03:00 +02001364 ocelot_write_rix(ocelot, BIT(cpu), ANA_PGID_PGID, PGID_CPU);
1365 ocelot_write_gix(ocelot, ANA_PORT_PORT_CFG_RECV_ENA |
1366 ANA_PORT_PORT_CFG_PORTID_VAL(cpu),
1367 ANA_PORT_PORT_CFG, cpu);
1368
Vladimir Oltean69df5782020-02-29 16:50:02 +02001369 /* Enable CPU port module */
Vladimir Oltean886e1382020-07-13 19:57:03 +03001370 ocelot_fields_write(ocelot, cpu, QSYS_SWITCH_PORT_MODE_PORT_ENA, 1);
Vladimir Oltean69df5782020-02-29 16:50:02 +02001371 /* CPU port Injection/Extraction configuration */
Vladimir Oltean886e1382020-07-13 19:57:03 +03001372 ocelot_fields_write(ocelot, cpu, SYS_PORT_MODE_INCL_XTR_HDR,
Vladimir Oltean2d44b092020-09-26 22:32:01 +03001373 ocelot->xtr_prefix);
Vladimir Oltean886e1382020-07-13 19:57:03 +03001374 ocelot_fields_write(ocelot, cpu, SYS_PORT_MODE_INCL_INJ_HDR,
Vladimir Oltean2d44b092020-09-26 22:32:01 +03001375 ocelot->inj_prefix);
Vladimir Oltean21468192019-11-09 15:03:00 +02001376
1377 /* Configure the CPU port to be VLAN aware */
1378 ocelot_write_gix(ocelot, ANA_PORT_VLAN_CFG_VLAN_VID(0) |
1379 ANA_PORT_VLAN_CFG_VLAN_AWARE_ENA |
1380 ANA_PORT_VLAN_CFG_VLAN_POP_CNT(1),
1381 ANA_PORT_VLAN_CFG, cpu);
Vladimir Oltean21468192019-11-09 15:03:00 +02001382}
Vladimir Oltean21468192019-11-09 15:03:00 +02001383
Alexandre Bellonia556c762018-05-14 22:04:57 +02001384int ocelot_init(struct ocelot *ocelot)
1385{
Alexandre Bellonia556c762018-05-14 22:04:57 +02001386 char queue_name[32];
Vladimir Oltean21468192019-11-09 15:03:00 +02001387 int i, ret;
1388 u32 port;
Alexandre Bellonia556c762018-05-14 22:04:57 +02001389
Vladimir Oltean3a77b592019-11-14 17:03:26 +02001390 if (ocelot->ops->reset) {
1391 ret = ocelot->ops->reset(ocelot);
1392 if (ret) {
1393 dev_err(ocelot->dev, "Switch reset failed\n");
1394 return ret;
1395 }
1396 }
1397
Alexandre Bellonidc96ee32018-06-26 14:28:48 +02001398 ocelot->lags = devm_kcalloc(ocelot->dev, ocelot->num_phys_ports,
1399 sizeof(u32), GFP_KERNEL);
1400 if (!ocelot->lags)
1401 return -ENOMEM;
1402
Alexandre Bellonia556c762018-05-14 22:04:57 +02001403 ocelot->stats = devm_kcalloc(ocelot->dev,
1404 ocelot->num_phys_ports * ocelot->num_stats,
1405 sizeof(u64), GFP_KERNEL);
1406 if (!ocelot->stats)
1407 return -ENOMEM;
1408
1409 mutex_init(&ocelot->stats_lock);
Antoine Tenart4e3b0462019-08-12 16:45:37 +02001410 mutex_init(&ocelot->ptp_lock);
1411 spin_lock_init(&ocelot->ptp_clock_lock);
Alexandre Bellonia556c762018-05-14 22:04:57 +02001412 snprintf(queue_name, sizeof(queue_name), "%s-stats",
1413 dev_name(ocelot->dev));
1414 ocelot->stats_queue = create_singlethread_workqueue(queue_name);
1415 if (!ocelot->stats_queue)
1416 return -ENOMEM;
1417
Claudiu Manoil2b120dd2019-11-09 15:02:58 +02001418 INIT_LIST_HEAD(&ocelot->multicast);
Alexandre Bellonia556c762018-05-14 22:04:57 +02001419 ocelot_mact_init(ocelot);
1420 ocelot_vlan_init(ocelot);
Vladimir Olteanaae4e502020-06-20 18:43:46 +03001421 ocelot_vcap_init(ocelot);
Vladimir Oltean2d44b092020-09-26 22:32:01 +03001422 ocelot_cpu_port_init(ocelot);
Alexandre Bellonia556c762018-05-14 22:04:57 +02001423
1424 for (port = 0; port < ocelot->num_phys_ports; port++) {
1425 /* Clear all counters (5 groups) */
1426 ocelot_write(ocelot, SYS_STAT_CFG_STAT_VIEW(port) |
1427 SYS_STAT_CFG_STAT_CLEAR_SHOT(0x7f),
1428 SYS_STAT_CFG);
1429 }
1430
1431 /* Only use S-Tag */
1432 ocelot_write(ocelot, ETH_P_8021AD, SYS_VLAN_ETYPE_CFG);
1433
1434 /* Aggregation mode */
1435 ocelot_write(ocelot, ANA_AGGR_CFG_AC_SMAC_ENA |
1436 ANA_AGGR_CFG_AC_DMAC_ENA |
1437 ANA_AGGR_CFG_AC_IP4_SIPDIP_ENA |
1438 ANA_AGGR_CFG_AC_IP4_TCPUDP_ENA, ANA_AGGR_CFG);
1439
1440 /* Set MAC age time to default value. The entry is aged after
1441 * 2*AGE_PERIOD
1442 */
1443 ocelot_write(ocelot,
1444 ANA_AUTOAGE_AGE_PERIOD(BR_DEFAULT_AGEING_TIME / 2 / HZ),
1445 ANA_AUTOAGE);
1446
1447 /* Disable learning for frames discarded by VLAN ingress filtering */
1448 regmap_field_write(ocelot->regfields[ANA_ADVLEARN_VLAN_CHK], 1);
1449
1450 /* Setup frame ageing - fixed value "2 sec" - in 6.5 us units */
1451 ocelot_write(ocelot, SYS_FRM_AGING_AGE_TX_ENA |
1452 SYS_FRM_AGING_MAX_AGE(307692), SYS_FRM_AGING);
1453
1454 /* Setup flooding PGIDs */
1455 ocelot_write_rix(ocelot, ANA_FLOODING_FLD_MULTICAST(PGID_MC) |
1456 ANA_FLOODING_FLD_BROADCAST(PGID_MC) |
1457 ANA_FLOODING_FLD_UNICAST(PGID_UC),
1458 ANA_FLOODING, 0);
1459 ocelot_write(ocelot, ANA_FLOODING_IPMC_FLD_MC6_DATA(PGID_MCIPV6) |
1460 ANA_FLOODING_IPMC_FLD_MC6_CTRL(PGID_MC) |
1461 ANA_FLOODING_IPMC_FLD_MC4_DATA(PGID_MCIPV4) |
1462 ANA_FLOODING_IPMC_FLD_MC4_CTRL(PGID_MC),
1463 ANA_FLOODING_IPMC);
1464
1465 for (port = 0; port < ocelot->num_phys_ports; port++) {
1466 /* Transmit the frame to the local port. */
1467 ocelot_write_rix(ocelot, BIT(port), ANA_PGID_PGID, port);
1468 /* Do not forward BPDU frames to the front ports. */
1469 ocelot_write_gix(ocelot,
1470 ANA_PORT_CPU_FWD_BPDU_CFG_BPDU_REDIR_ENA(0xffff),
1471 ANA_PORT_CPU_FWD_BPDU_CFG,
1472 port);
1473 /* Ensure bridging is disabled */
1474 ocelot_write_rix(ocelot, 0, ANA_PGID_PGID, PGID_SRC + port);
1475 }
1476
Alexandre Bellonia556c762018-05-14 22:04:57 +02001477 /* Allow broadcast MAC frames. */
Vladimir Oltean96b029b2020-06-21 14:46:02 +03001478 for_each_nonreserved_multicast_dest_pgid(ocelot, i) {
Alexandre Bellonia556c762018-05-14 22:04:57 +02001479 u32 val = ANA_PGID_PGID_PGID(GENMASK(ocelot->num_phys_ports - 1, 0));
1480
1481 ocelot_write_rix(ocelot, val, ANA_PGID_PGID, i);
1482 }
1483 ocelot_write_rix(ocelot,
1484 ANA_PGID_PGID_PGID(GENMASK(ocelot->num_phys_ports, 0)),
1485 ANA_PGID_PGID, PGID_MC);
1486 ocelot_write_rix(ocelot, 0, ANA_PGID_PGID, PGID_MCIPV4);
1487 ocelot_write_rix(ocelot, 0, ANA_PGID_PGID, PGID_MCIPV6);
1488
Alexandre Bellonia556c762018-05-14 22:04:57 +02001489 /* Allow manual injection via DEVCPU_QS registers, and byte swap these
1490 * registers endianness.
1491 */
1492 ocelot_write_rix(ocelot, QS_INJ_GRP_CFG_BYTE_SWAP |
1493 QS_INJ_GRP_CFG_MODE(1), QS_INJ_GRP_CFG, 0);
1494 ocelot_write_rix(ocelot, QS_XTR_GRP_CFG_BYTE_SWAP |
1495 QS_XTR_GRP_CFG_MODE(1), QS_XTR_GRP_CFG, 0);
1496 ocelot_write(ocelot, ANA_CPUQ_CFG_CPUQ_MIRROR(2) |
1497 ANA_CPUQ_CFG_CPUQ_LRN(2) |
1498 ANA_CPUQ_CFG_CPUQ_MAC_COPY(2) |
1499 ANA_CPUQ_CFG_CPUQ_SRC_COPY(2) |
1500 ANA_CPUQ_CFG_CPUQ_LOCKED_PORTMOVE(2) |
1501 ANA_CPUQ_CFG_CPUQ_ALLBRIDGE(6) |
1502 ANA_CPUQ_CFG_CPUQ_IPMC_CTRL(6) |
1503 ANA_CPUQ_CFG_CPUQ_IGMP(6) |
1504 ANA_CPUQ_CFG_CPUQ_MLD(6), ANA_CPUQ_CFG);
1505 for (i = 0; i < 16; i++)
1506 ocelot_write_rix(ocelot, ANA_CPUQ_8021_CFG_CPUQ_GARP_VAL(6) |
1507 ANA_CPUQ_8021_CFG_CPUQ_BPDU_VAL(6),
1508 ANA_CPUQ_8021_CFG, i);
1509
Claudiu Manoil1e1caa92019-04-16 17:51:59 +03001510 INIT_DELAYED_WORK(&ocelot->stats_work, ocelot_check_stats_work);
Alexandre Bellonia556c762018-05-14 22:04:57 +02001511 queue_delayed_work(ocelot->stats_queue, &ocelot->stats_work,
1512 OCELOT_STATS_CHECK_DELAY);
Antoine Tenart4e3b0462019-08-12 16:45:37 +02001513
Alexandre Bellonia556c762018-05-14 22:04:57 +02001514 return 0;
1515}
1516EXPORT_SYMBOL(ocelot_init);
1517
1518void ocelot_deinit(struct ocelot *ocelot)
1519{
Claudiu Manoilc5d13962019-07-25 16:33:18 +03001520 cancel_delayed_work(&ocelot->stats_work);
Alexandre Bellonia556c762018-05-14 22:04:57 +02001521 destroy_workqueue(ocelot->stats_queue);
1522 mutex_destroy(&ocelot->stats_lock);
Alexandre Bellonia556c762018-05-14 22:04:57 +02001523}
1524EXPORT_SYMBOL(ocelot_deinit);
1525
Vladimir Olteane5fb5122020-09-18 04:07:30 +03001526void ocelot_deinit_port(struct ocelot *ocelot, int port)
1527{
1528 struct ocelot_port *ocelot_port = ocelot->ports[port];
1529
1530 skb_queue_purge(&ocelot_port->tx_skbs);
1531}
1532EXPORT_SYMBOL(ocelot_deinit_port);
1533
Alexandre Bellonia556c762018-05-14 22:04:57 +02001534MODULE_LICENSE("Dual MIT/GPL");