ocelot.h 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342
  1. /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
  2. /* Copyright (c) 2017 Microsemi Corporation
  3. */
  4. #ifndef _SOC_MSCC_OCELOT_H
  5. #define _SOC_MSCC_OCELOT_H
  6. #include <linux/ptp_clock_kernel.h>
  7. #include <linux/net_tstamp.h>
  8. #include <linux/if_vlan.h>
  9. #include <linux/regmap.h>
  10. #include <net/dsa.h>
  11. /* Port Group IDs (PGID) are masks of destination ports.
  12. *
  13. * For L2 forwarding, the switch performs 3 lookups in the PGID table for each
  14. * frame, and forwards the frame to the ports that are present in the logical
  15. * AND of all 3 PGIDs.
  16. *
  17. * These PGID lookups are:
  18. * - In one of PGID[0-63]: for the destination masks. There are 2 paths by
  19. * which the switch selects a destination PGID:
  20. * - The {DMAC, VID} is present in the MAC table. In that case, the
  21. * destination PGID is given by the DEST_IDX field of the MAC table entry
  22. * that matched.
  23. * - The {DMAC, VID} is not present in the MAC table (it is unknown). The
  24. * frame is disseminated as being either unicast, multicast or broadcast,
  25. * and according to that, the destination PGID is chosen as being the
  26. * value contained by ANA_FLOODING_FLD_UNICAST,
  27. * ANA_FLOODING_FLD_MULTICAST or ANA_FLOODING_FLD_BROADCAST.
  28. * The destination PGID can be an unicast set: the first PGIDs, 0 to
  29. * ocelot->num_phys_ports - 1, or a multicast set: the PGIDs from
  30. * ocelot->num_phys_ports to 63. By convention, a unicast PGID corresponds to
  31. * a physical port and has a single bit set in the destination ports mask:
  32. * that corresponding to the port number itself. In contrast, a multicast
  33. * PGID will have potentially more than one single bit set in the destination
  34. * ports mask.
  35. * - In one of PGID[64-79]: for the aggregation mask. The switch classifier
  36. * dissects each frame and generates a 4-bit Link Aggregation Code which is
  37. * used for this second PGID table lookup. The goal of link aggregation is to
  38. * hash multiple flows within the same LAG on to different destination ports.
  39. * The first lookup will result in a PGID with all the LAG members present in
  40. * the destination ports mask, and the second lookup, by Link Aggregation
  41. * Code, will ensure that each flow gets forwarded only to a single port out
  42. * of that mask (there are no duplicates).
  43. * - In one of PGID[80-90]: for the source mask. The third time, the PGID table
  44. * is indexed with the ingress port (plus 80). These PGIDs answer the
  45. * question "is port i allowed to forward traffic to port j?" If yes, then
  46. * BIT(j) of PGID 80+i will be found set. The third PGID lookup can be used
  47. * to enforce the L2 forwarding matrix imposed by e.g. a Linux bridge.
  48. */
  49. /* Reserve some destination PGIDs at the end of the range:
  50. * PGID_BLACKHOLE: used for not forwarding the frames
  51. * PGID_CPU: used for whitelisting certain MAC addresses, such as the addresses
  52. * of the switch port net devices, towards the CPU port module.
  53. * PGID_UC: the flooding destinations for unknown unicast traffic.
  54. * PGID_MC: the flooding destinations for non-IP multicast traffic.
  55. * PGID_MCIPV4: the flooding destinations for IPv4 multicast traffic.
  56. * PGID_MCIPV6: the flooding destinations for IPv6 multicast traffic.
  57. * PGID_BC: the flooding destinations for broadcast traffic.
  58. */
  59. #define PGID_BLACKHOLE 57
  60. #define PGID_CPU 58
  61. #define PGID_UC 59
  62. #define PGID_MC 60
  63. #define PGID_MCIPV4 61
  64. #define PGID_MCIPV6 62
  65. #define PGID_BC 63
  66. #define for_each_unicast_dest_pgid(ocelot, pgid) \
  67. for ((pgid) = 0; \
  68. (pgid) < (ocelot)->num_phys_ports; \
  69. (pgid)++)
  70. #define for_each_nonreserved_multicast_dest_pgid(ocelot, pgid) \
  71. for ((pgid) = (ocelot)->num_phys_ports + 1; \
  72. (pgid) < PGID_BLACKHOLE; \
  73. (pgid)++)
  74. #define for_each_aggr_pgid(ocelot, pgid) \
  75. for ((pgid) = PGID_AGGR; \
  76. (pgid) < PGID_SRC; \
  77. (pgid)++)
  78. /* Aggregation PGIDs, one per Link Aggregation Code */
  79. #define PGID_AGGR 64
  80. /* Source PGIDs, one per physical port */
  81. #define PGID_SRC 80
  82. #define OCELOT_NUM_TC 8
  83. #define OCELOT_SPEED_2500 0
  84. #define OCELOT_SPEED_1000 1
  85. #define OCELOT_SPEED_100 2
  86. #define OCELOT_SPEED_10 3
  87. #define OCELOT_PTP_PINS_NUM 4
  88. #define TARGET_OFFSET 24
  89. #define REG_MASK GENMASK(TARGET_OFFSET - 1, 0)
  90. #define REG(reg, offset) [reg & REG_MASK] = offset
  91. #define REG_RESERVED_ADDR 0xffffffff
  92. #define REG_RESERVED(reg) REG(reg, REG_RESERVED_ADDR)
  93. enum ocelot_target {
  94. ANA = 1,
  95. QS,
  96. QSYS,
  97. REW,
  98. SYS,
  99. S0,
  100. S1,
  101. S2,
  102. HSIO,
  103. PTP,
  104. FDMA,
  105. GCB,
  106. DEV_GMII,
  107. TARGET_MAX,
  108. };
  109. enum ocelot_reg {
  110. ANA_ADVLEARN = ANA << TARGET_OFFSET,
  111. ANA_VLANMASK,
  112. ANA_PORT_B_DOMAIN,
  113. ANA_ANAGEFIL,
  114. ANA_ANEVENTS,
  115. ANA_STORMLIMIT_BURST,
  116. ANA_STORMLIMIT_CFG,
  117. ANA_ISOLATED_PORTS,
  118. ANA_COMMUNITY_PORTS,
  119. ANA_AUTOAGE,
  120. ANA_MACTOPTIONS,
  121. ANA_LEARNDISC,
  122. ANA_AGENCTRL,
  123. ANA_MIRRORPORTS,
  124. ANA_EMIRRORPORTS,
  125. ANA_FLOODING,
  126. ANA_FLOODING_IPMC,
  127. ANA_SFLOW_CFG,
  128. ANA_PORT_MODE,
  129. ANA_CUT_THRU_CFG,
  130. ANA_PGID_PGID,
  131. ANA_TABLES_ANMOVED,
  132. ANA_TABLES_MACHDATA,
  133. ANA_TABLES_MACLDATA,
  134. ANA_TABLES_STREAMDATA,
  135. ANA_TABLES_MACACCESS,
  136. ANA_TABLES_MACTINDX,
  137. ANA_TABLES_VLANACCESS,
  138. ANA_TABLES_VLANTIDX,
  139. ANA_TABLES_ISDXACCESS,
  140. ANA_TABLES_ISDXTIDX,
  141. ANA_TABLES_ENTRYLIM,
  142. ANA_TABLES_PTP_ID_HIGH,
  143. ANA_TABLES_PTP_ID_LOW,
  144. ANA_TABLES_STREAMACCESS,
  145. ANA_TABLES_STREAMTIDX,
  146. ANA_TABLES_SEQ_HISTORY,
  147. ANA_TABLES_SEQ_MASK,
  148. ANA_TABLES_SFID_MASK,
  149. ANA_TABLES_SFIDACCESS,
  150. ANA_TABLES_SFIDTIDX,
  151. ANA_MSTI_STATE,
  152. ANA_OAM_UPM_LM_CNT,
  153. ANA_SG_ACCESS_CTRL,
  154. ANA_SG_CONFIG_REG_1,
  155. ANA_SG_CONFIG_REG_2,
  156. ANA_SG_CONFIG_REG_3,
  157. ANA_SG_CONFIG_REG_4,
  158. ANA_SG_CONFIG_REG_5,
  159. ANA_SG_GCL_GS_CONFIG,
  160. ANA_SG_GCL_TI_CONFIG,
  161. ANA_SG_STATUS_REG_1,
  162. ANA_SG_STATUS_REG_2,
  163. ANA_SG_STATUS_REG_3,
  164. ANA_PORT_VLAN_CFG,
  165. ANA_PORT_DROP_CFG,
  166. ANA_PORT_QOS_CFG,
  167. ANA_PORT_VCAP_CFG,
  168. ANA_PORT_VCAP_S1_KEY_CFG,
  169. ANA_PORT_VCAP_S2_CFG,
  170. ANA_PORT_PCP_DEI_MAP,
  171. ANA_PORT_CPU_FWD_CFG,
  172. ANA_PORT_CPU_FWD_BPDU_CFG,
  173. ANA_PORT_CPU_FWD_GARP_CFG,
  174. ANA_PORT_CPU_FWD_CCM_CFG,
  175. ANA_PORT_PORT_CFG,
  176. ANA_PORT_POL_CFG,
  177. ANA_PORT_PTP_CFG,
  178. ANA_PORT_PTP_DLY1_CFG,
  179. ANA_PORT_PTP_DLY2_CFG,
  180. ANA_PORT_SFID_CFG,
  181. ANA_PFC_PFC_CFG,
  182. ANA_PFC_PFC_TIMER,
  183. ANA_IPT_OAM_MEP_CFG,
  184. ANA_IPT_IPT,
  185. ANA_PPT_PPT,
  186. ANA_FID_MAP_FID_MAP,
  187. ANA_AGGR_CFG,
  188. ANA_CPUQ_CFG,
  189. ANA_CPUQ_CFG2,
  190. ANA_CPUQ_8021_CFG,
  191. ANA_DSCP_CFG,
  192. ANA_DSCP_REWR_CFG,
  193. ANA_VCAP_RNG_TYPE_CFG,
  194. ANA_VCAP_RNG_VAL_CFG,
  195. ANA_VRAP_CFG,
  196. ANA_VRAP_HDR_DATA,
  197. ANA_VRAP_HDR_MASK,
  198. ANA_DISCARD_CFG,
  199. ANA_FID_CFG,
  200. ANA_POL_PIR_CFG,
  201. ANA_POL_CIR_CFG,
  202. ANA_POL_MODE_CFG,
  203. ANA_POL_PIR_STATE,
  204. ANA_POL_CIR_STATE,
  205. ANA_POL_STATE,
  206. ANA_POL_FLOWC,
  207. ANA_POL_HYST,
  208. ANA_POL_MISC_CFG,
  209. QS_XTR_GRP_CFG = QS << TARGET_OFFSET,
  210. QS_XTR_RD,
  211. QS_XTR_FRM_PRUNING,
  212. QS_XTR_FLUSH,
  213. QS_XTR_DATA_PRESENT,
  214. QS_XTR_CFG,
  215. QS_INJ_GRP_CFG,
  216. QS_INJ_WR,
  217. QS_INJ_CTRL,
  218. QS_INJ_STATUS,
  219. QS_INJ_ERR,
  220. QS_INH_DBG,
  221. QSYS_PORT_MODE = QSYS << TARGET_OFFSET,
  222. QSYS_SWITCH_PORT_MODE,
  223. QSYS_STAT_CNT_CFG,
  224. QSYS_EEE_CFG,
  225. QSYS_EEE_THRES,
  226. QSYS_IGR_NO_SHARING,
  227. QSYS_EGR_NO_SHARING,
  228. QSYS_SW_STATUS,
  229. QSYS_EXT_CPU_CFG,
  230. QSYS_PAD_CFG,
  231. QSYS_CPU_GROUP_MAP,
  232. QSYS_QMAP,
  233. QSYS_ISDX_SGRP,
  234. QSYS_TIMED_FRAME_ENTRY,
  235. QSYS_TFRM_MISC,
  236. QSYS_TFRM_PORT_DLY,
  237. QSYS_TFRM_TIMER_CFG_1,
  238. QSYS_TFRM_TIMER_CFG_2,
  239. QSYS_TFRM_TIMER_CFG_3,
  240. QSYS_TFRM_TIMER_CFG_4,
  241. QSYS_TFRM_TIMER_CFG_5,
  242. QSYS_TFRM_TIMER_CFG_6,
  243. QSYS_TFRM_TIMER_CFG_7,
  244. QSYS_TFRM_TIMER_CFG_8,
  245. QSYS_RED_PROFILE,
  246. QSYS_RES_QOS_MODE,
  247. QSYS_RES_CFG,
  248. QSYS_RES_STAT,
  249. QSYS_EGR_DROP_MODE,
  250. QSYS_EQ_CTRL,
  251. QSYS_EVENTS_CORE,
  252. QSYS_QMAXSDU_CFG_0,
  253. QSYS_QMAXSDU_CFG_1,
  254. QSYS_QMAXSDU_CFG_2,
  255. QSYS_QMAXSDU_CFG_3,
  256. QSYS_QMAXSDU_CFG_4,
  257. QSYS_QMAXSDU_CFG_5,
  258. QSYS_QMAXSDU_CFG_6,
  259. QSYS_QMAXSDU_CFG_7,
  260. QSYS_PREEMPTION_CFG,
  261. QSYS_CIR_CFG,
  262. QSYS_EIR_CFG,
  263. QSYS_SE_CFG,
  264. QSYS_SE_DWRR_CFG,
  265. QSYS_SE_CONNECT,
  266. QSYS_SE_DLB_SENSE,
  267. QSYS_CIR_STATE,
  268. QSYS_EIR_STATE,
  269. QSYS_SE_STATE,
  270. QSYS_HSCH_MISC_CFG,
  271. QSYS_TAG_CONFIG,
  272. QSYS_TAS_PARAM_CFG_CTRL,
  273. QSYS_PORT_MAX_SDU,
  274. QSYS_PARAM_CFG_REG_1,
  275. QSYS_PARAM_CFG_REG_2,
  276. QSYS_PARAM_CFG_REG_3,
  277. QSYS_PARAM_CFG_REG_4,
  278. QSYS_PARAM_CFG_REG_5,
  279. QSYS_GCL_CFG_REG_1,
  280. QSYS_GCL_CFG_REG_2,
  281. QSYS_PARAM_STATUS_REG_1,
  282. QSYS_PARAM_STATUS_REG_2,
  283. QSYS_PARAM_STATUS_REG_3,
  284. QSYS_PARAM_STATUS_REG_4,
  285. QSYS_PARAM_STATUS_REG_5,
  286. QSYS_PARAM_STATUS_REG_6,
  287. QSYS_PARAM_STATUS_REG_7,
  288. QSYS_PARAM_STATUS_REG_8,
  289. QSYS_PARAM_STATUS_REG_9,
  290. QSYS_GCL_STATUS_REG_1,
  291. QSYS_GCL_STATUS_REG_2,
  292. REW_PORT_VLAN_CFG = REW << TARGET_OFFSET,
  293. REW_TAG_CFG,
  294. REW_PORT_CFG,
  295. REW_DSCP_CFG,
  296. REW_PCP_DEI_QOS_MAP_CFG,
  297. REW_PTP_CFG,
  298. REW_PTP_DLY1_CFG,
  299. REW_RED_TAG_CFG,
  300. REW_DSCP_REMAP_DP1_CFG,
  301. REW_DSCP_REMAP_CFG,
  302. REW_STAT_CFG,
  303. REW_REW_STICKY,
  304. REW_PPT,
  305. SYS_COUNT_RX_OCTETS = SYS << TARGET_OFFSET,
  306. SYS_COUNT_RX_UNICAST,
  307. SYS_COUNT_RX_MULTICAST,
  308. SYS_COUNT_RX_BROADCAST,
  309. SYS_COUNT_RX_SHORTS,
  310. SYS_COUNT_RX_FRAGMENTS,
  311. SYS_COUNT_RX_JABBERS,
  312. SYS_COUNT_RX_CRC_ALIGN_ERRS,
  313. SYS_COUNT_RX_SYM_ERRS,
  314. SYS_COUNT_RX_64,
  315. SYS_COUNT_RX_65_127,
  316. SYS_COUNT_RX_128_255,
  317. SYS_COUNT_RX_256_511,
  318. SYS_COUNT_RX_512_1023,
  319. SYS_COUNT_RX_1024_1526,
  320. SYS_COUNT_RX_1527_MAX,
  321. SYS_COUNT_RX_PAUSE,
  322. SYS_COUNT_RX_CONTROL,
  323. SYS_COUNT_RX_LONGS,
  324. SYS_COUNT_RX_CLASSIFIED_DROPS,
  325. SYS_COUNT_RX_RED_PRIO_0,
  326. SYS_COUNT_RX_RED_PRIO_1,
  327. SYS_COUNT_RX_RED_PRIO_2,
  328. SYS_COUNT_RX_RED_PRIO_3,
  329. SYS_COUNT_RX_RED_PRIO_4,
  330. SYS_COUNT_RX_RED_PRIO_5,
  331. SYS_COUNT_RX_RED_PRIO_6,
  332. SYS_COUNT_RX_RED_PRIO_7,
  333. SYS_COUNT_RX_YELLOW_PRIO_0,
  334. SYS_COUNT_RX_YELLOW_PRIO_1,
  335. SYS_COUNT_RX_YELLOW_PRIO_2,
  336. SYS_COUNT_RX_YELLOW_PRIO_3,
  337. SYS_COUNT_RX_YELLOW_PRIO_4,
  338. SYS_COUNT_RX_YELLOW_PRIO_5,
  339. SYS_COUNT_RX_YELLOW_PRIO_6,
  340. SYS_COUNT_RX_YELLOW_PRIO_7,
  341. SYS_COUNT_RX_GREEN_PRIO_0,
  342. SYS_COUNT_RX_GREEN_PRIO_1,
  343. SYS_COUNT_RX_GREEN_PRIO_2,
  344. SYS_COUNT_RX_GREEN_PRIO_3,
  345. SYS_COUNT_RX_GREEN_PRIO_4,
  346. SYS_COUNT_RX_GREEN_PRIO_5,
  347. SYS_COUNT_RX_GREEN_PRIO_6,
  348. SYS_COUNT_RX_GREEN_PRIO_7,
  349. SYS_COUNT_TX_OCTETS,
  350. SYS_COUNT_TX_UNICAST,
  351. SYS_COUNT_TX_MULTICAST,
  352. SYS_COUNT_TX_BROADCAST,
  353. SYS_COUNT_TX_COLLISION,
  354. SYS_COUNT_TX_DROPS,
  355. SYS_COUNT_TX_PAUSE,
  356. SYS_COUNT_TX_64,
  357. SYS_COUNT_TX_65_127,
  358. SYS_COUNT_TX_128_255,
  359. SYS_COUNT_TX_256_511,
  360. SYS_COUNT_TX_512_1023,
  361. SYS_COUNT_TX_1024_1526,
  362. SYS_COUNT_TX_1527_MAX,
  363. SYS_COUNT_TX_YELLOW_PRIO_0,
  364. SYS_COUNT_TX_YELLOW_PRIO_1,
  365. SYS_COUNT_TX_YELLOW_PRIO_2,
  366. SYS_COUNT_TX_YELLOW_PRIO_3,
  367. SYS_COUNT_TX_YELLOW_PRIO_4,
  368. SYS_COUNT_TX_YELLOW_PRIO_5,
  369. SYS_COUNT_TX_YELLOW_PRIO_6,
  370. SYS_COUNT_TX_YELLOW_PRIO_7,
  371. SYS_COUNT_TX_GREEN_PRIO_0,
  372. SYS_COUNT_TX_GREEN_PRIO_1,
  373. SYS_COUNT_TX_GREEN_PRIO_2,
  374. SYS_COUNT_TX_GREEN_PRIO_3,
  375. SYS_COUNT_TX_GREEN_PRIO_4,
  376. SYS_COUNT_TX_GREEN_PRIO_5,
  377. SYS_COUNT_TX_GREEN_PRIO_6,
  378. SYS_COUNT_TX_GREEN_PRIO_7,
  379. SYS_COUNT_TX_AGED,
  380. SYS_COUNT_DROP_LOCAL,
  381. SYS_COUNT_DROP_TAIL,
  382. SYS_COUNT_DROP_YELLOW_PRIO_0,
  383. SYS_COUNT_DROP_YELLOW_PRIO_1,
  384. SYS_COUNT_DROP_YELLOW_PRIO_2,
  385. SYS_COUNT_DROP_YELLOW_PRIO_3,
  386. SYS_COUNT_DROP_YELLOW_PRIO_4,
  387. SYS_COUNT_DROP_YELLOW_PRIO_5,
  388. SYS_COUNT_DROP_YELLOW_PRIO_6,
  389. SYS_COUNT_DROP_YELLOW_PRIO_7,
  390. SYS_COUNT_DROP_GREEN_PRIO_0,
  391. SYS_COUNT_DROP_GREEN_PRIO_1,
  392. SYS_COUNT_DROP_GREEN_PRIO_2,
  393. SYS_COUNT_DROP_GREEN_PRIO_3,
  394. SYS_COUNT_DROP_GREEN_PRIO_4,
  395. SYS_COUNT_DROP_GREEN_PRIO_5,
  396. SYS_COUNT_DROP_GREEN_PRIO_6,
  397. SYS_COUNT_DROP_GREEN_PRIO_7,
  398. SYS_COUNT_SF_MATCHING_FRAMES,
  399. SYS_COUNT_SF_NOT_PASSING_FRAMES,
  400. SYS_COUNT_SF_NOT_PASSING_SDU,
  401. SYS_COUNT_SF_RED_FRAMES,
  402. SYS_RESET_CFG,
  403. SYS_SR_ETYPE_CFG,
  404. SYS_VLAN_ETYPE_CFG,
  405. SYS_PORT_MODE,
  406. SYS_FRONT_PORT_MODE,
  407. SYS_FRM_AGING,
  408. SYS_STAT_CFG,
  409. SYS_SW_STATUS,
  410. SYS_MISC_CFG,
  411. SYS_REW_MAC_HIGH_CFG,
  412. SYS_REW_MAC_LOW_CFG,
  413. SYS_TIMESTAMP_OFFSET,
  414. SYS_CMID,
  415. SYS_PAUSE_CFG,
  416. SYS_PAUSE_TOT_CFG,
  417. SYS_ATOP,
  418. SYS_ATOP_TOT_CFG,
  419. SYS_MAC_FC_CFG,
  420. SYS_MMGT,
  421. SYS_MMGT_FAST,
  422. SYS_EVENTS_DIF,
  423. SYS_EVENTS_CORE,
  424. SYS_PTP_STATUS,
  425. SYS_PTP_TXSTAMP,
  426. SYS_PTP_NXT,
  427. SYS_PTP_CFG,
  428. SYS_RAM_INIT,
  429. SYS_CM_ADDR,
  430. SYS_CM_DATA_WR,
  431. SYS_CM_DATA_RD,
  432. SYS_CM_OP,
  433. SYS_CM_DATA,
  434. PTP_PIN_CFG = PTP << TARGET_OFFSET,
  435. PTP_PIN_TOD_SEC_MSB,
  436. PTP_PIN_TOD_SEC_LSB,
  437. PTP_PIN_TOD_NSEC,
  438. PTP_PIN_WF_HIGH_PERIOD,
  439. PTP_PIN_WF_LOW_PERIOD,
  440. PTP_CFG_MISC,
  441. PTP_CLK_CFG_ADJ_CFG,
  442. PTP_CLK_CFG_ADJ_FREQ,
  443. GCB_SOFT_RST = GCB << TARGET_OFFSET,
  444. GCB_MIIM_MII_STATUS,
  445. GCB_MIIM_MII_CMD,
  446. GCB_MIIM_MII_DATA,
  447. DEV_CLOCK_CFG = DEV_GMII << TARGET_OFFSET,
  448. DEV_PORT_MISC,
  449. DEV_EVENTS,
  450. DEV_EEE_CFG,
  451. DEV_RX_PATH_DELAY,
  452. DEV_TX_PATH_DELAY,
  453. DEV_PTP_PREDICT_CFG,
  454. DEV_MAC_ENA_CFG,
  455. DEV_MAC_MODE_CFG,
  456. DEV_MAC_MAXLEN_CFG,
  457. DEV_MAC_TAGS_CFG,
  458. DEV_MAC_ADV_CHK_CFG,
  459. DEV_MAC_IFG_CFG,
  460. DEV_MAC_HDX_CFG,
  461. DEV_MAC_DBG_CFG,
  462. DEV_MAC_FC_MAC_LOW_CFG,
  463. DEV_MAC_FC_MAC_HIGH_CFG,
  464. DEV_MAC_STICKY,
  465. PCS1G_CFG,
  466. PCS1G_MODE_CFG,
  467. PCS1G_SD_CFG,
  468. PCS1G_ANEG_CFG,
  469. PCS1G_ANEG_NP_CFG,
  470. PCS1G_LB_CFG,
  471. PCS1G_DBG_CFG,
  472. PCS1G_CDET_CFG,
  473. PCS1G_ANEG_STATUS,
  474. PCS1G_ANEG_NP_STATUS,
  475. PCS1G_LINK_STATUS,
  476. PCS1G_LINK_DOWN_CNT,
  477. PCS1G_STICKY,
  478. PCS1G_DEBUG_STATUS,
  479. PCS1G_LPI_CFG,
  480. PCS1G_LPI_WAKE_ERROR_CNT,
  481. PCS1G_LPI_STATUS,
  482. PCS1G_TSTPAT_MODE_CFG,
  483. PCS1G_TSTPAT_STATUS,
  484. DEV_PCS_FX100_CFG,
  485. DEV_PCS_FX100_STATUS,
  486. };
  487. enum ocelot_regfield {
  488. ANA_ADVLEARN_VLAN_CHK,
  489. ANA_ADVLEARN_LEARN_MIRROR,
  490. ANA_ANEVENTS_FLOOD_DISCARD,
  491. ANA_ANEVENTS_MSTI_DROP,
  492. ANA_ANEVENTS_ACLKILL,
  493. ANA_ANEVENTS_ACLUSED,
  494. ANA_ANEVENTS_AUTOAGE,
  495. ANA_ANEVENTS_VS2TTL1,
  496. ANA_ANEVENTS_STORM_DROP,
  497. ANA_ANEVENTS_LEARN_DROP,
  498. ANA_ANEVENTS_AGED_ENTRY,
  499. ANA_ANEVENTS_CPU_LEARN_FAILED,
  500. ANA_ANEVENTS_AUTO_LEARN_FAILED,
  501. ANA_ANEVENTS_LEARN_REMOVE,
  502. ANA_ANEVENTS_AUTO_LEARNED,
  503. ANA_ANEVENTS_AUTO_MOVED,
  504. ANA_ANEVENTS_DROPPED,
  505. ANA_ANEVENTS_CLASSIFIED_DROP,
  506. ANA_ANEVENTS_CLASSIFIED_COPY,
  507. ANA_ANEVENTS_VLAN_DISCARD,
  508. ANA_ANEVENTS_FWD_DISCARD,
  509. ANA_ANEVENTS_MULTICAST_FLOOD,
  510. ANA_ANEVENTS_UNICAST_FLOOD,
  511. ANA_ANEVENTS_DEST_KNOWN,
  512. ANA_ANEVENTS_BUCKET3_MATCH,
  513. ANA_ANEVENTS_BUCKET2_MATCH,
  514. ANA_ANEVENTS_BUCKET1_MATCH,
  515. ANA_ANEVENTS_BUCKET0_MATCH,
  516. ANA_ANEVENTS_CPU_OPERATION,
  517. ANA_ANEVENTS_DMAC_LOOKUP,
  518. ANA_ANEVENTS_SMAC_LOOKUP,
  519. ANA_ANEVENTS_SEQ_GEN_ERR_0,
  520. ANA_ANEVENTS_SEQ_GEN_ERR_1,
  521. ANA_TABLES_MACACCESS_B_DOM,
  522. ANA_TABLES_MACTINDX_BUCKET,
  523. ANA_TABLES_MACTINDX_M_INDEX,
  524. QSYS_SWITCH_PORT_MODE_PORT_ENA,
  525. QSYS_SWITCH_PORT_MODE_SCH_NEXT_CFG,
  526. QSYS_SWITCH_PORT_MODE_YEL_RSRVD,
  527. QSYS_SWITCH_PORT_MODE_INGRESS_DROP_MODE,
  528. QSYS_SWITCH_PORT_MODE_TX_PFC_ENA,
  529. QSYS_SWITCH_PORT_MODE_TX_PFC_MODE,
  530. QSYS_TIMED_FRAME_ENTRY_TFRM_VLD,
  531. QSYS_TIMED_FRAME_ENTRY_TFRM_FP,
  532. QSYS_TIMED_FRAME_ENTRY_TFRM_PORTNO,
  533. QSYS_TIMED_FRAME_ENTRY_TFRM_TM_SEL,
  534. QSYS_TIMED_FRAME_ENTRY_TFRM_TM_T,
  535. SYS_PORT_MODE_DATA_WO_TS,
  536. SYS_PORT_MODE_INCL_INJ_HDR,
  537. SYS_PORT_MODE_INCL_XTR_HDR,
  538. SYS_PORT_MODE_INCL_HDR_ERR,
  539. SYS_RESET_CFG_CORE_ENA,
  540. SYS_RESET_CFG_MEM_ENA,
  541. SYS_RESET_CFG_MEM_INIT,
  542. GCB_SOFT_RST_SWC_RST,
  543. GCB_MIIM_MII_STATUS_PENDING,
  544. GCB_MIIM_MII_STATUS_BUSY,
  545. SYS_PAUSE_CFG_PAUSE_START,
  546. SYS_PAUSE_CFG_PAUSE_STOP,
  547. SYS_PAUSE_CFG_PAUSE_ENA,
  548. REGFIELD_MAX
  549. };
  550. enum {
  551. /* VCAP_CORE_CFG */
  552. VCAP_CORE_UPDATE_CTRL,
  553. VCAP_CORE_MV_CFG,
  554. /* VCAP_CORE_CACHE */
  555. VCAP_CACHE_ENTRY_DAT,
  556. VCAP_CACHE_MASK_DAT,
  557. VCAP_CACHE_ACTION_DAT,
  558. VCAP_CACHE_CNT_DAT,
  559. VCAP_CACHE_TG_DAT,
  560. /* VCAP_CONST */
  561. VCAP_CONST_VCAP_VER,
  562. VCAP_CONST_ENTRY_WIDTH,
  563. VCAP_CONST_ENTRY_CNT,
  564. VCAP_CONST_ENTRY_SWCNT,
  565. VCAP_CONST_ENTRY_TG_WIDTH,
  566. VCAP_CONST_ACTION_DEF_CNT,
  567. VCAP_CONST_ACTION_WIDTH,
  568. VCAP_CONST_CNT_WIDTH,
  569. VCAP_CONST_CORE_CNT,
  570. VCAP_CONST_IF_CNT,
  571. };
  572. enum ocelot_ptp_pins {
  573. PTP_PIN_0,
  574. PTP_PIN_1,
  575. PTP_PIN_2,
  576. PTP_PIN_3,
  577. TOD_ACC_PIN
  578. };
  579. enum ocelot_stat {
  580. OCELOT_STAT_RX_OCTETS,
  581. OCELOT_STAT_RX_UNICAST,
  582. OCELOT_STAT_RX_MULTICAST,
  583. OCELOT_STAT_RX_BROADCAST,
  584. OCELOT_STAT_RX_SHORTS,
  585. OCELOT_STAT_RX_FRAGMENTS,
  586. OCELOT_STAT_RX_JABBERS,
  587. OCELOT_STAT_RX_CRC_ALIGN_ERRS,
  588. OCELOT_STAT_RX_SYM_ERRS,
  589. OCELOT_STAT_RX_64,
  590. OCELOT_STAT_RX_65_127,
  591. OCELOT_STAT_RX_128_255,
  592. OCELOT_STAT_RX_256_511,
  593. OCELOT_STAT_RX_512_1023,
  594. OCELOT_STAT_RX_1024_1526,
  595. OCELOT_STAT_RX_1527_MAX,
  596. OCELOT_STAT_RX_PAUSE,
  597. OCELOT_STAT_RX_CONTROL,
  598. OCELOT_STAT_RX_LONGS,
  599. OCELOT_STAT_RX_CLASSIFIED_DROPS,
  600. OCELOT_STAT_RX_RED_PRIO_0,
  601. OCELOT_STAT_RX_RED_PRIO_1,
  602. OCELOT_STAT_RX_RED_PRIO_2,
  603. OCELOT_STAT_RX_RED_PRIO_3,
  604. OCELOT_STAT_RX_RED_PRIO_4,
  605. OCELOT_STAT_RX_RED_PRIO_5,
  606. OCELOT_STAT_RX_RED_PRIO_6,
  607. OCELOT_STAT_RX_RED_PRIO_7,
  608. OCELOT_STAT_RX_YELLOW_PRIO_0,
  609. OCELOT_STAT_RX_YELLOW_PRIO_1,
  610. OCELOT_STAT_RX_YELLOW_PRIO_2,
  611. OCELOT_STAT_RX_YELLOW_PRIO_3,
  612. OCELOT_STAT_RX_YELLOW_PRIO_4,
  613. OCELOT_STAT_RX_YELLOW_PRIO_5,
  614. OCELOT_STAT_RX_YELLOW_PRIO_6,
  615. OCELOT_STAT_RX_YELLOW_PRIO_7,
  616. OCELOT_STAT_RX_GREEN_PRIO_0,
  617. OCELOT_STAT_RX_GREEN_PRIO_1,
  618. OCELOT_STAT_RX_GREEN_PRIO_2,
  619. OCELOT_STAT_RX_GREEN_PRIO_3,
  620. OCELOT_STAT_RX_GREEN_PRIO_4,
  621. OCELOT_STAT_RX_GREEN_PRIO_5,
  622. OCELOT_STAT_RX_GREEN_PRIO_6,
  623. OCELOT_STAT_RX_GREEN_PRIO_7,
  624. OCELOT_STAT_TX_OCTETS,
  625. OCELOT_STAT_TX_UNICAST,
  626. OCELOT_STAT_TX_MULTICAST,
  627. OCELOT_STAT_TX_BROADCAST,
  628. OCELOT_STAT_TX_COLLISION,
  629. OCELOT_STAT_TX_DROPS,
  630. OCELOT_STAT_TX_PAUSE,
  631. OCELOT_STAT_TX_64,
  632. OCELOT_STAT_TX_65_127,
  633. OCELOT_STAT_TX_128_255,
  634. OCELOT_STAT_TX_256_511,
  635. OCELOT_STAT_TX_512_1023,
  636. OCELOT_STAT_TX_1024_1526,
  637. OCELOT_STAT_TX_1527_MAX,
  638. OCELOT_STAT_TX_YELLOW_PRIO_0,
  639. OCELOT_STAT_TX_YELLOW_PRIO_1,
  640. OCELOT_STAT_TX_YELLOW_PRIO_2,
  641. OCELOT_STAT_TX_YELLOW_PRIO_3,
  642. OCELOT_STAT_TX_YELLOW_PRIO_4,
  643. OCELOT_STAT_TX_YELLOW_PRIO_5,
  644. OCELOT_STAT_TX_YELLOW_PRIO_6,
  645. OCELOT_STAT_TX_YELLOW_PRIO_7,
  646. OCELOT_STAT_TX_GREEN_PRIO_0,
  647. OCELOT_STAT_TX_GREEN_PRIO_1,
  648. OCELOT_STAT_TX_GREEN_PRIO_2,
  649. OCELOT_STAT_TX_GREEN_PRIO_3,
  650. OCELOT_STAT_TX_GREEN_PRIO_4,
  651. OCELOT_STAT_TX_GREEN_PRIO_5,
  652. OCELOT_STAT_TX_GREEN_PRIO_6,
  653. OCELOT_STAT_TX_GREEN_PRIO_7,
  654. OCELOT_STAT_TX_AGED,
  655. OCELOT_STAT_DROP_LOCAL,
  656. OCELOT_STAT_DROP_TAIL,
  657. OCELOT_STAT_DROP_YELLOW_PRIO_0,
  658. OCELOT_STAT_DROP_YELLOW_PRIO_1,
  659. OCELOT_STAT_DROP_YELLOW_PRIO_2,
  660. OCELOT_STAT_DROP_YELLOW_PRIO_3,
  661. OCELOT_STAT_DROP_YELLOW_PRIO_4,
  662. OCELOT_STAT_DROP_YELLOW_PRIO_5,
  663. OCELOT_STAT_DROP_YELLOW_PRIO_6,
  664. OCELOT_STAT_DROP_YELLOW_PRIO_7,
  665. OCELOT_STAT_DROP_GREEN_PRIO_0,
  666. OCELOT_STAT_DROP_GREEN_PRIO_1,
  667. OCELOT_STAT_DROP_GREEN_PRIO_2,
  668. OCELOT_STAT_DROP_GREEN_PRIO_3,
  669. OCELOT_STAT_DROP_GREEN_PRIO_4,
  670. OCELOT_STAT_DROP_GREEN_PRIO_5,
  671. OCELOT_STAT_DROP_GREEN_PRIO_6,
  672. OCELOT_STAT_DROP_GREEN_PRIO_7,
  673. OCELOT_NUM_STATS,
  674. };
  675. struct ocelot_stat_layout {
  676. u32 reg;
  677. char name[ETH_GSTRING_LEN];
  678. };
  679. /* 32-bit counter checked for wraparound by ocelot_port_update_stats()
  680. * and copied to ocelot->stats.
  681. */
  682. #define OCELOT_STAT(kind) \
  683. [OCELOT_STAT_ ## kind] = { .reg = SYS_COUNT_ ## kind }
  684. /* Same as above, except also exported to ethtool -S. Standard counters should
  685. * only be exposed to more specific interfaces rather than by their string name.
  686. */
  687. #define OCELOT_STAT_ETHTOOL(kind, ethtool_name) \
  688. [OCELOT_STAT_ ## kind] = { .reg = SYS_COUNT_ ## kind, .name = ethtool_name }
  689. #define OCELOT_COMMON_STATS \
  690. OCELOT_STAT_ETHTOOL(RX_OCTETS, "rx_octets"), \
  691. OCELOT_STAT_ETHTOOL(RX_UNICAST, "rx_unicast"), \
  692. OCELOT_STAT_ETHTOOL(RX_MULTICAST, "rx_multicast"), \
  693. OCELOT_STAT_ETHTOOL(RX_BROADCAST, "rx_broadcast"), \
  694. OCELOT_STAT_ETHTOOL(RX_SHORTS, "rx_shorts"), \
  695. OCELOT_STAT_ETHTOOL(RX_FRAGMENTS, "rx_fragments"), \
  696. OCELOT_STAT_ETHTOOL(RX_JABBERS, "rx_jabbers"), \
  697. OCELOT_STAT_ETHTOOL(RX_CRC_ALIGN_ERRS, "rx_crc_align_errs"), \
  698. OCELOT_STAT_ETHTOOL(RX_SYM_ERRS, "rx_sym_errs"), \
  699. OCELOT_STAT_ETHTOOL(RX_64, "rx_frames_below_65_octets"), \
  700. OCELOT_STAT_ETHTOOL(RX_65_127, "rx_frames_65_to_127_octets"), \
  701. OCELOT_STAT_ETHTOOL(RX_128_255, "rx_frames_128_to_255_octets"), \
  702. OCELOT_STAT_ETHTOOL(RX_256_511, "rx_frames_256_to_511_octets"), \
  703. OCELOT_STAT_ETHTOOL(RX_512_1023, "rx_frames_512_to_1023_octets"), \
  704. OCELOT_STAT_ETHTOOL(RX_1024_1526, "rx_frames_1024_to_1526_octets"), \
  705. OCELOT_STAT_ETHTOOL(RX_1527_MAX, "rx_frames_over_1526_octets"), \
  706. OCELOT_STAT_ETHTOOL(RX_PAUSE, "rx_pause"), \
  707. OCELOT_STAT_ETHTOOL(RX_CONTROL, "rx_control"), \
  708. OCELOT_STAT_ETHTOOL(RX_LONGS, "rx_longs"), \
  709. OCELOT_STAT_ETHTOOL(RX_CLASSIFIED_DROPS, "rx_classified_drops"), \
  710. OCELOT_STAT_ETHTOOL(RX_RED_PRIO_0, "rx_red_prio_0"), \
  711. OCELOT_STAT_ETHTOOL(RX_RED_PRIO_1, "rx_red_prio_1"), \
  712. OCELOT_STAT_ETHTOOL(RX_RED_PRIO_2, "rx_red_prio_2"), \
  713. OCELOT_STAT_ETHTOOL(RX_RED_PRIO_3, "rx_red_prio_3"), \
  714. OCELOT_STAT_ETHTOOL(RX_RED_PRIO_4, "rx_red_prio_4"), \
  715. OCELOT_STAT_ETHTOOL(RX_RED_PRIO_5, "rx_red_prio_5"), \
  716. OCELOT_STAT_ETHTOOL(RX_RED_PRIO_6, "rx_red_prio_6"), \
  717. OCELOT_STAT_ETHTOOL(RX_RED_PRIO_7, "rx_red_prio_7"), \
  718. OCELOT_STAT_ETHTOOL(RX_YELLOW_PRIO_0, "rx_yellow_prio_0"), \
  719. OCELOT_STAT_ETHTOOL(RX_YELLOW_PRIO_1, "rx_yellow_prio_1"), \
  720. OCELOT_STAT_ETHTOOL(RX_YELLOW_PRIO_2, "rx_yellow_prio_2"), \
  721. OCELOT_STAT_ETHTOOL(RX_YELLOW_PRIO_3, "rx_yellow_prio_3"), \
  722. OCELOT_STAT_ETHTOOL(RX_YELLOW_PRIO_4, "rx_yellow_prio_4"), \
  723. OCELOT_STAT_ETHTOOL(RX_YELLOW_PRIO_5, "rx_yellow_prio_5"), \
  724. OCELOT_STAT_ETHTOOL(RX_YELLOW_PRIO_6, "rx_yellow_prio_6"), \
  725. OCELOT_STAT_ETHTOOL(RX_YELLOW_PRIO_7, "rx_yellow_prio_7"), \
  726. OCELOT_STAT_ETHTOOL(RX_GREEN_PRIO_0, "rx_green_prio_0"), \
  727. OCELOT_STAT_ETHTOOL(RX_GREEN_PRIO_1, "rx_green_prio_1"), \
  728. OCELOT_STAT_ETHTOOL(RX_GREEN_PRIO_2, "rx_green_prio_2"), \
  729. OCELOT_STAT_ETHTOOL(RX_GREEN_PRIO_3, "rx_green_prio_3"), \
  730. OCELOT_STAT_ETHTOOL(RX_GREEN_PRIO_4, "rx_green_prio_4"), \
  731. OCELOT_STAT_ETHTOOL(RX_GREEN_PRIO_5, "rx_green_prio_5"), \
  732. OCELOT_STAT_ETHTOOL(RX_GREEN_PRIO_6, "rx_green_prio_6"), \
  733. OCELOT_STAT_ETHTOOL(RX_GREEN_PRIO_7, "rx_green_prio_7"), \
  734. OCELOT_STAT_ETHTOOL(TX_OCTETS, "tx_octets"), \
  735. OCELOT_STAT_ETHTOOL(TX_UNICAST, "tx_unicast"), \
  736. OCELOT_STAT_ETHTOOL(TX_MULTICAST, "tx_multicast"), \
  737. OCELOT_STAT_ETHTOOL(TX_BROADCAST, "tx_broadcast"), \
  738. OCELOT_STAT_ETHTOOL(TX_COLLISION, "tx_collision"), \
  739. OCELOT_STAT_ETHTOOL(TX_DROPS, "tx_drops"), \
  740. OCELOT_STAT_ETHTOOL(TX_PAUSE, "tx_pause"), \
  741. OCELOT_STAT_ETHTOOL(TX_64, "tx_frames_below_65_octets"), \
  742. OCELOT_STAT_ETHTOOL(TX_65_127, "tx_frames_65_to_127_octets"), \
  743. OCELOT_STAT_ETHTOOL(TX_128_255, "tx_frames_128_255_octets"), \
  744. OCELOT_STAT_ETHTOOL(TX_256_511, "tx_frames_256_511_octets"), \
  745. OCELOT_STAT_ETHTOOL(TX_512_1023, "tx_frames_512_1023_octets"), \
  746. OCELOT_STAT_ETHTOOL(TX_1024_1526, "tx_frames_1024_1526_octets"), \
  747. OCELOT_STAT_ETHTOOL(TX_1527_MAX, "tx_frames_over_1526_octets"), \
  748. OCELOT_STAT_ETHTOOL(TX_YELLOW_PRIO_0, "tx_yellow_prio_0"), \
  749. OCELOT_STAT_ETHTOOL(TX_YELLOW_PRIO_1, "tx_yellow_prio_1"), \
  750. OCELOT_STAT_ETHTOOL(TX_YELLOW_PRIO_2, "tx_yellow_prio_2"), \
  751. OCELOT_STAT_ETHTOOL(TX_YELLOW_PRIO_3, "tx_yellow_prio_3"), \
  752. OCELOT_STAT_ETHTOOL(TX_YELLOW_PRIO_4, "tx_yellow_prio_4"), \
  753. OCELOT_STAT_ETHTOOL(TX_YELLOW_PRIO_5, "tx_yellow_prio_5"), \
  754. OCELOT_STAT_ETHTOOL(TX_YELLOW_PRIO_6, "tx_yellow_prio_6"), \
  755. OCELOT_STAT_ETHTOOL(TX_YELLOW_PRIO_7, "tx_yellow_prio_7"), \
  756. OCELOT_STAT_ETHTOOL(TX_GREEN_PRIO_0, "tx_green_prio_0"), \
  757. OCELOT_STAT_ETHTOOL(TX_GREEN_PRIO_1, "tx_green_prio_1"), \
  758. OCELOT_STAT_ETHTOOL(TX_GREEN_PRIO_2, "tx_green_prio_2"), \
  759. OCELOT_STAT_ETHTOOL(TX_GREEN_PRIO_3, "tx_green_prio_3"), \
  760. OCELOT_STAT_ETHTOOL(TX_GREEN_PRIO_4, "tx_green_prio_4"), \
  761. OCELOT_STAT_ETHTOOL(TX_GREEN_PRIO_5, "tx_green_prio_5"), \
  762. OCELOT_STAT_ETHTOOL(TX_GREEN_PRIO_6, "tx_green_prio_6"), \
  763. OCELOT_STAT_ETHTOOL(TX_GREEN_PRIO_7, "tx_green_prio_7"), \
  764. OCELOT_STAT_ETHTOOL(TX_AGED, "tx_aged"), \
  765. OCELOT_STAT_ETHTOOL(DROP_LOCAL, "drop_local"), \
  766. OCELOT_STAT_ETHTOOL(DROP_TAIL, "drop_tail"), \
  767. OCELOT_STAT_ETHTOOL(DROP_YELLOW_PRIO_0, "drop_yellow_prio_0"), \
  768. OCELOT_STAT_ETHTOOL(DROP_YELLOW_PRIO_1, "drop_yellow_prio_1"), \
  769. OCELOT_STAT_ETHTOOL(DROP_YELLOW_PRIO_2, "drop_yellow_prio_2"), \
  770. OCELOT_STAT_ETHTOOL(DROP_YELLOW_PRIO_3, "drop_yellow_prio_3"), \
  771. OCELOT_STAT_ETHTOOL(DROP_YELLOW_PRIO_4, "drop_yellow_prio_4"), \
  772. OCELOT_STAT_ETHTOOL(DROP_YELLOW_PRIO_5, "drop_yellow_prio_5"), \
  773. OCELOT_STAT_ETHTOOL(DROP_YELLOW_PRIO_6, "drop_yellow_prio_6"), \
  774. OCELOT_STAT_ETHTOOL(DROP_YELLOW_PRIO_7, "drop_yellow_prio_7"), \
  775. OCELOT_STAT_ETHTOOL(DROP_GREEN_PRIO_0, "drop_green_prio_0"), \
  776. OCELOT_STAT_ETHTOOL(DROP_GREEN_PRIO_1, "drop_green_prio_1"), \
  777. OCELOT_STAT_ETHTOOL(DROP_GREEN_PRIO_2, "drop_green_prio_2"), \
  778. OCELOT_STAT_ETHTOOL(DROP_GREEN_PRIO_3, "drop_green_prio_3"), \
  779. OCELOT_STAT_ETHTOOL(DROP_GREEN_PRIO_4, "drop_green_prio_4"), \
  780. OCELOT_STAT_ETHTOOL(DROP_GREEN_PRIO_5, "drop_green_prio_5"), \
  781. OCELOT_STAT_ETHTOOL(DROP_GREEN_PRIO_6, "drop_green_prio_6"), \
  782. OCELOT_STAT_ETHTOOL(DROP_GREEN_PRIO_7, "drop_green_prio_7")
  783. struct ocelot_stats_region {
  784. struct list_head node;
  785. u32 base;
  786. int count;
  787. u32 *buf;
  788. };
  789. enum ocelot_tag_prefix {
  790. OCELOT_TAG_PREFIX_DISABLED = 0,
  791. OCELOT_TAG_PREFIX_NONE,
  792. OCELOT_TAG_PREFIX_SHORT,
  793. OCELOT_TAG_PREFIX_LONG,
  794. };
  795. struct ocelot;
  796. struct ocelot_ops {
  797. struct net_device *(*port_to_netdev)(struct ocelot *ocelot, int port);
  798. int (*netdev_to_port)(struct net_device *dev);
  799. int (*reset)(struct ocelot *ocelot);
  800. u16 (*wm_enc)(u16 value);
  801. u16 (*wm_dec)(u16 value);
  802. void (*wm_stat)(u32 val, u32 *inuse, u32 *maxuse);
  803. void (*psfp_init)(struct ocelot *ocelot);
  804. int (*psfp_filter_add)(struct ocelot *ocelot, int port,
  805. struct flow_cls_offload *f);
  806. int (*psfp_filter_del)(struct ocelot *ocelot, struct flow_cls_offload *f);
  807. int (*psfp_stats_get)(struct ocelot *ocelot, struct flow_cls_offload *f,
  808. struct flow_stats *stats);
  809. void (*cut_through_fwd)(struct ocelot *ocelot);
  810. void (*tas_clock_adjust)(struct ocelot *ocelot);
  811. void (*update_stats)(struct ocelot *ocelot);
  812. };
  813. struct ocelot_vcap_policer {
  814. struct list_head pol_list;
  815. u16 base;
  816. u16 max;
  817. u16 base2;
  818. u16 max2;
  819. };
  820. struct ocelot_vcap_block {
  821. struct list_head rules;
  822. int count;
  823. };
  824. struct ocelot_bridge_vlan {
  825. u16 vid;
  826. unsigned long portmask;
  827. unsigned long untagged;
  828. struct list_head list;
  829. };
  830. enum ocelot_port_tag_config {
  831. /* all VLANs are egress-untagged */
  832. OCELOT_PORT_TAG_DISABLED = 0,
  833. /* all VLANs except the native VLAN and VID 0 are egress-tagged */
  834. OCELOT_PORT_TAG_NATIVE = 1,
  835. /* all VLANs except VID 0 are egress-tagged */
  836. OCELOT_PORT_TAG_TRUNK_NO_VID0 = 2,
  837. /* all VLANs are egress-tagged */
  838. OCELOT_PORT_TAG_TRUNK = 3,
  839. };
  840. struct ocelot_psfp_list {
  841. struct list_head stream_list;
  842. struct list_head sfi_list;
  843. struct list_head sgi_list;
  844. /* Serialize access to the lists */
  845. struct mutex lock;
  846. };
  847. enum ocelot_sb {
  848. OCELOT_SB_BUF,
  849. OCELOT_SB_REF,
  850. OCELOT_SB_NUM,
  851. };
  852. enum ocelot_sb_pool {
  853. OCELOT_SB_POOL_ING,
  854. OCELOT_SB_POOL_EGR,
  855. OCELOT_SB_POOL_NUM,
  856. };
  857. /* MAC table entry types.
  858. * ENTRYTYPE_NORMAL is subject to aging.
  859. * ENTRYTYPE_LOCKED is not subject to aging.
  860. * ENTRYTYPE_MACv4 is not subject to aging. For IPv4 multicast.
  861. * ENTRYTYPE_MACv6 is not subject to aging. For IPv6 multicast.
  862. */
  863. enum macaccess_entry_type {
  864. ENTRYTYPE_NORMAL = 0,
  865. ENTRYTYPE_LOCKED,
  866. ENTRYTYPE_MACv4,
  867. ENTRYTYPE_MACv6,
  868. };
  869. enum ocelot_proto {
  870. OCELOT_PROTO_PTP_L2 = BIT(0),
  871. OCELOT_PROTO_PTP_L4 = BIT(1),
  872. };
  873. #define OCELOT_QUIRK_PCS_PERFORMS_RATE_ADAPTATION BIT(0)
  874. #define OCELOT_QUIRK_QSGMII_PORTS_MUST_BE_UP BIT(1)
  875. struct ocelot_lag_fdb {
  876. unsigned char addr[ETH_ALEN];
  877. u16 vid;
  878. struct net_device *bond;
  879. struct list_head list;
  880. };
  881. struct ocelot_mirror {
  882. refcount_t refcount;
  883. int to;
  884. };
  885. struct ocelot_port;
  886. struct ocelot_port {
  887. struct ocelot *ocelot;
  888. struct regmap *target;
  889. struct net_device *bond;
  890. struct net_device *bridge;
  891. struct ocelot_port *dsa_8021q_cpu;
  892. /* VLAN that untagged frames are classified to, on ingress */
  893. const struct ocelot_bridge_vlan *pvid_vlan;
  894. struct tc_taprio_qopt_offload *taprio;
  895. phy_interface_t phy_mode;
  896. unsigned int ptp_skbs_in_flight;
  897. struct sk_buff_head tx_skbs;
  898. unsigned int trap_proto;
  899. u16 mrp_ring_id;
  900. u8 ptp_cmd;
  901. u8 ts_id;
  902. u8 index;
  903. u8 stp_state;
  904. bool vlan_aware;
  905. bool is_dsa_8021q_cpu;
  906. bool learn_ena;
  907. bool lag_tx_active;
  908. int bridge_num;
  909. int speed;
  910. };
  911. struct ocelot {
  912. struct device *dev;
  913. struct devlink *devlink;
  914. struct devlink_port *devlink_ports;
  915. const struct ocelot_ops *ops;
  916. struct regmap *targets[TARGET_MAX];
  917. struct regmap_field *regfields[REGFIELD_MAX];
  918. const u32 *const *map;
  919. const struct ocelot_stat_layout *stats_layout;
  920. struct list_head stats_regions;
  921. u32 pool_size[OCELOT_SB_NUM][OCELOT_SB_POOL_NUM];
  922. int packet_buffer_size;
  923. int num_frame_refs;
  924. int num_mact_rows;
  925. struct ocelot_port **ports;
  926. u8 base_mac[ETH_ALEN];
  927. struct list_head vlans;
  928. struct list_head traps;
  929. struct list_head lag_fdbs;
  930. /* Switches like VSC9959 have flooding per traffic class */
  931. int num_flooding_pgids;
  932. /* In tables like ANA:PORT and the ANA:PGID:PGID mask,
  933. * the CPU is located after the physical ports (at the
  934. * num_phys_ports index).
  935. */
  936. u8 num_phys_ports;
  937. int npi;
  938. enum ocelot_tag_prefix npi_inj_prefix;
  939. enum ocelot_tag_prefix npi_xtr_prefix;
  940. unsigned long bridges;
  941. struct list_head multicast;
  942. struct list_head pgids;
  943. struct list_head dummy_rules;
  944. struct ocelot_vcap_block block[3];
  945. struct ocelot_vcap_policer vcap_pol;
  946. struct vcap_props *vcap;
  947. struct ocelot_mirror *mirror;
  948. struct ocelot_psfp_list psfp;
  949. /* Workqueue to check statistics for overflow */
  950. struct delayed_work stats_work;
  951. struct workqueue_struct *stats_queue;
  952. /* Lock for serializing access to the statistics array */
  953. spinlock_t stats_lock;
  954. u64 *stats;
  955. /* Lock for serializing indirect access to STAT_VIEW registers */
  956. struct mutex stat_view_lock;
  957. /* Lock for serializing access to the MAC table */
  958. struct mutex mact_lock;
  959. /* Lock for serializing forwarding domain changes */
  960. struct mutex fwd_domain_lock;
  961. /* Lock for serializing Time-Aware Shaper changes */
  962. struct mutex tas_lock;
  963. struct workqueue_struct *owq;
  964. u8 ptp:1;
  965. struct ptp_clock *ptp_clock;
  966. struct ptp_clock_info ptp_info;
  967. unsigned int ptp_skbs_in_flight;
  968. /* Protects the 2-step TX timestamp ID logic */
  969. spinlock_t ts_id_lock;
  970. /* Protects the PTP clock */
  971. spinlock_t ptp_clock_lock;
  972. struct ptp_pin_desc ptp_pins[OCELOT_PTP_PINS_NUM];
  973. struct ocelot_fdma *fdma;
  974. };
  975. struct ocelot_policer {
  976. u32 rate; /* kilobit per second */
  977. u32 burst; /* bytes */
  978. };
  979. #define ocelot_bulk_read(ocelot, reg, buf, count) \
  980. __ocelot_bulk_read_ix(ocelot, reg, 0, buf, count)
  981. #define ocelot_read_ix(ocelot, reg, gi, ri) \
  982. __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
  983. #define ocelot_read_gix(ocelot, reg, gi) \
  984. __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi))
  985. #define ocelot_read_rix(ocelot, reg, ri) \
  986. __ocelot_read_ix(ocelot, reg, reg##_RSZ * (ri))
  987. #define ocelot_read(ocelot, reg) \
  988. __ocelot_read_ix(ocelot, reg, 0)
  989. #define ocelot_write_ix(ocelot, val, reg, gi, ri) \
  990. __ocelot_write_ix(ocelot, val, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
  991. #define ocelot_write_gix(ocelot, val, reg, gi) \
  992. __ocelot_write_ix(ocelot, val, reg, reg##_GSZ * (gi))
  993. #define ocelot_write_rix(ocelot, val, reg, ri) \
  994. __ocelot_write_ix(ocelot, val, reg, reg##_RSZ * (ri))
  995. #define ocelot_write(ocelot, val, reg) __ocelot_write_ix(ocelot, val, reg, 0)
  996. #define ocelot_rmw_ix(ocelot, val, m, reg, gi, ri) \
  997. __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
  998. #define ocelot_rmw_gix(ocelot, val, m, reg, gi) \
  999. __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi))
  1000. #define ocelot_rmw_rix(ocelot, val, m, reg, ri) \
  1001. __ocelot_rmw_ix(ocelot, val, m, reg, reg##_RSZ * (ri))
  1002. #define ocelot_rmw(ocelot, val, m, reg) __ocelot_rmw_ix(ocelot, val, m, reg, 0)
  1003. #define ocelot_field_write(ocelot, reg, val) \
  1004. regmap_field_write((ocelot)->regfields[(reg)], (val))
  1005. #define ocelot_field_read(ocelot, reg, val) \
  1006. regmap_field_read((ocelot)->regfields[(reg)], (val))
  1007. #define ocelot_fields_write(ocelot, id, reg, val) \
  1008. regmap_fields_write((ocelot)->regfields[(reg)], (id), (val))
  1009. #define ocelot_fields_read(ocelot, id, reg, val) \
  1010. regmap_fields_read((ocelot)->regfields[(reg)], (id), (val))
  1011. #define ocelot_target_read_ix(ocelot, target, reg, gi, ri) \
  1012. __ocelot_target_read_ix(ocelot, target, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
  1013. #define ocelot_target_read_gix(ocelot, target, reg, gi) \
  1014. __ocelot_target_read_ix(ocelot, target, reg, reg##_GSZ * (gi))
  1015. #define ocelot_target_read_rix(ocelot, target, reg, ri) \
  1016. __ocelot_target_read_ix(ocelot, target, reg, reg##_RSZ * (ri))
  1017. #define ocelot_target_read(ocelot, target, reg) \
  1018. __ocelot_target_read_ix(ocelot, target, reg, 0)
  1019. #define ocelot_target_write_ix(ocelot, target, val, reg, gi, ri) \
  1020. __ocelot_target_write_ix(ocelot, target, val, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
  1021. #define ocelot_target_write_gix(ocelot, target, val, reg, gi) \
  1022. __ocelot_target_write_ix(ocelot, target, val, reg, reg##_GSZ * (gi))
  1023. #define ocelot_target_write_rix(ocelot, target, val, reg, ri) \
  1024. __ocelot_target_write_ix(ocelot, target, val, reg, reg##_RSZ * (ri))
  1025. #define ocelot_target_write(ocelot, target, val, reg) \
  1026. __ocelot_target_write_ix(ocelot, target, val, reg, 0)
  1027. /* I/O */
  1028. u32 ocelot_port_readl(struct ocelot_port *port, u32 reg);
  1029. void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg);
  1030. void ocelot_port_rmwl(struct ocelot_port *port, u32 val, u32 mask, u32 reg);
  1031. int __ocelot_bulk_read_ix(struct ocelot *ocelot, u32 reg, u32 offset, void *buf,
  1032. int count);
  1033. u32 __ocelot_read_ix(struct ocelot *ocelot, u32 reg, u32 offset);
  1034. void __ocelot_write_ix(struct ocelot *ocelot, u32 val, u32 reg, u32 offset);
  1035. void __ocelot_rmw_ix(struct ocelot *ocelot, u32 val, u32 mask, u32 reg,
  1036. u32 offset);
  1037. u32 __ocelot_target_read_ix(struct ocelot *ocelot, enum ocelot_target target,
  1038. u32 reg, u32 offset);
  1039. void __ocelot_target_write_ix(struct ocelot *ocelot, enum ocelot_target target,
  1040. u32 val, u32 reg, u32 offset);
  1041. /* Packet I/O */
  1042. bool ocelot_can_inject(struct ocelot *ocelot, int grp);
  1043. void ocelot_port_inject_frame(struct ocelot *ocelot, int port, int grp,
  1044. u32 rew_op, struct sk_buff *skb);
  1045. void ocelot_ifh_port_set(void *ifh, int port, u32 rew_op, u32 vlan_tag);
  1046. int ocelot_xtr_poll_frame(struct ocelot *ocelot, int grp, struct sk_buff **skb);
  1047. void ocelot_drain_cpu_queue(struct ocelot *ocelot, int grp);
  1048. void ocelot_ptp_rx_timestamp(struct ocelot *ocelot, struct sk_buff *skb,
  1049. u64 timestamp);
  1050. /* Hardware initialization */
  1051. int ocelot_regfields_init(struct ocelot *ocelot,
  1052. const struct reg_field *const regfields);
  1053. struct regmap *ocelot_regmap_init(struct ocelot *ocelot, struct resource *res);
  1054. int ocelot_init(struct ocelot *ocelot);
  1055. void ocelot_deinit(struct ocelot *ocelot);
  1056. void ocelot_init_port(struct ocelot *ocelot, int port);
  1057. void ocelot_deinit_port(struct ocelot *ocelot, int port);
  1058. void ocelot_port_setup_dsa_8021q_cpu(struct ocelot *ocelot, int cpu);
  1059. void ocelot_port_teardown_dsa_8021q_cpu(struct ocelot *ocelot, int cpu);
  1060. void ocelot_port_assign_dsa_8021q_cpu(struct ocelot *ocelot, int port, int cpu);
  1061. void ocelot_port_unassign_dsa_8021q_cpu(struct ocelot *ocelot, int port);
  1062. u32 ocelot_port_assigned_dsa_8021q_cpu_mask(struct ocelot *ocelot, int port);
  1063. /* DSA callbacks */
  1064. void ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset, u8 *data);
  1065. void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data);
  1066. int ocelot_get_sset_count(struct ocelot *ocelot, int port, int sset);
  1067. void ocelot_port_get_stats64(struct ocelot *ocelot, int port,
  1068. struct rtnl_link_stats64 *stats);
  1069. void ocelot_port_get_pause_stats(struct ocelot *ocelot, int port,
  1070. struct ethtool_pause_stats *pause_stats);
  1071. void ocelot_port_get_rmon_stats(struct ocelot *ocelot, int port,
  1072. struct ethtool_rmon_stats *rmon_stats,
  1073. const struct ethtool_rmon_hist_range **ranges);
  1074. void ocelot_port_get_eth_ctrl_stats(struct ocelot *ocelot, int port,
  1075. struct ethtool_eth_ctrl_stats *ctrl_stats);
  1076. void ocelot_port_get_eth_mac_stats(struct ocelot *ocelot, int port,
  1077. struct ethtool_eth_mac_stats *mac_stats);
  1078. void ocelot_port_get_eth_phy_stats(struct ocelot *ocelot, int port,
  1079. struct ethtool_eth_phy_stats *phy_stats);
  1080. int ocelot_get_ts_info(struct ocelot *ocelot, int port,
  1081. struct ethtool_ts_info *info);
  1082. void ocelot_set_ageing_time(struct ocelot *ocelot, unsigned int msecs);
  1083. int ocelot_port_vlan_filtering(struct ocelot *ocelot, int port, bool enabled,
  1084. struct netlink_ext_ack *extack);
  1085. void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, u8 state);
  1086. u32 ocelot_get_bridge_fwd_mask(struct ocelot *ocelot, int src_port);
  1087. int ocelot_port_pre_bridge_flags(struct ocelot *ocelot, int port,
  1088. struct switchdev_brport_flags val);
  1089. void ocelot_port_bridge_flags(struct ocelot *ocelot, int port,
  1090. struct switchdev_brport_flags val);
  1091. int ocelot_port_get_default_prio(struct ocelot *ocelot, int port);
  1092. int ocelot_port_set_default_prio(struct ocelot *ocelot, int port, u8 prio);
  1093. int ocelot_port_get_dscp_prio(struct ocelot *ocelot, int port, u8 dscp);
  1094. int ocelot_port_add_dscp_prio(struct ocelot *ocelot, int port, u8 dscp, u8 prio);
  1095. int ocelot_port_del_dscp_prio(struct ocelot *ocelot, int port, u8 dscp, u8 prio);
  1096. int ocelot_port_bridge_join(struct ocelot *ocelot, int port,
  1097. struct net_device *bridge, int bridge_num,
  1098. struct netlink_ext_ack *extack);
  1099. void ocelot_port_bridge_leave(struct ocelot *ocelot, int port,
  1100. struct net_device *bridge);
  1101. int ocelot_mact_flush(struct ocelot *ocelot, int port);
  1102. int ocelot_fdb_dump(struct ocelot *ocelot, int port,
  1103. dsa_fdb_dump_cb_t *cb, void *data);
  1104. int ocelot_fdb_add(struct ocelot *ocelot, int port, const unsigned char *addr,
  1105. u16 vid, const struct net_device *bridge);
  1106. int ocelot_fdb_del(struct ocelot *ocelot, int port, const unsigned char *addr,
  1107. u16 vid, const struct net_device *bridge);
  1108. int ocelot_lag_fdb_add(struct ocelot *ocelot, struct net_device *bond,
  1109. const unsigned char *addr, u16 vid,
  1110. const struct net_device *bridge);
  1111. int ocelot_lag_fdb_del(struct ocelot *ocelot, struct net_device *bond,
  1112. const unsigned char *addr, u16 vid,
  1113. const struct net_device *bridge);
  1114. int ocelot_vlan_prepare(struct ocelot *ocelot, int port, u16 vid, bool pvid,
  1115. bool untagged, struct netlink_ext_ack *extack);
  1116. int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid,
  1117. bool untagged);
  1118. int ocelot_vlan_del(struct ocelot *ocelot, int port, u16 vid);
  1119. int ocelot_hwstamp_get(struct ocelot *ocelot, int port, struct ifreq *ifr);
  1120. int ocelot_hwstamp_set(struct ocelot *ocelot, int port, struct ifreq *ifr);
  1121. int ocelot_port_txtstamp_request(struct ocelot *ocelot, int port,
  1122. struct sk_buff *skb,
  1123. struct sk_buff **clone);
  1124. void ocelot_get_txtstamp(struct ocelot *ocelot);
  1125. void ocelot_port_set_maxlen(struct ocelot *ocelot, int port, size_t sdu);
  1126. int ocelot_get_max_mtu(struct ocelot *ocelot, int port);
  1127. int ocelot_port_policer_add(struct ocelot *ocelot, int port,
  1128. struct ocelot_policer *pol);
  1129. int ocelot_port_policer_del(struct ocelot *ocelot, int port);
  1130. int ocelot_port_mirror_add(struct ocelot *ocelot, int from, int to,
  1131. bool ingress, struct netlink_ext_ack *extack);
  1132. void ocelot_port_mirror_del(struct ocelot *ocelot, int from, bool ingress);
  1133. int ocelot_cls_flower_replace(struct ocelot *ocelot, int port,
  1134. struct flow_cls_offload *f, bool ingress);
  1135. int ocelot_cls_flower_destroy(struct ocelot *ocelot, int port,
  1136. struct flow_cls_offload *f, bool ingress);
  1137. int ocelot_cls_flower_stats(struct ocelot *ocelot, int port,
  1138. struct flow_cls_offload *f, bool ingress);
  1139. int ocelot_port_mdb_add(struct ocelot *ocelot, int port,
  1140. const struct switchdev_obj_port_mdb *mdb,
  1141. const struct net_device *bridge);
  1142. int ocelot_port_mdb_del(struct ocelot *ocelot, int port,
  1143. const struct switchdev_obj_port_mdb *mdb,
  1144. const struct net_device *bridge);
  1145. int ocelot_port_lag_join(struct ocelot *ocelot, int port,
  1146. struct net_device *bond,
  1147. struct netdev_lag_upper_info *info,
  1148. struct netlink_ext_ack *extack);
  1149. void ocelot_port_lag_leave(struct ocelot *ocelot, int port,
  1150. struct net_device *bond);
  1151. void ocelot_port_lag_change(struct ocelot *ocelot, int port, bool lag_tx_active);
  1152. int ocelot_bond_get_id(struct ocelot *ocelot, struct net_device *bond);
  1153. int ocelot_devlink_sb_register(struct ocelot *ocelot);
  1154. void ocelot_devlink_sb_unregister(struct ocelot *ocelot);
  1155. int ocelot_sb_pool_get(struct ocelot *ocelot, unsigned int sb_index,
  1156. u16 pool_index,
  1157. struct devlink_sb_pool_info *pool_info);
  1158. int ocelot_sb_pool_set(struct ocelot *ocelot, unsigned int sb_index,
  1159. u16 pool_index, u32 size,
  1160. enum devlink_sb_threshold_type threshold_type,
  1161. struct netlink_ext_ack *extack);
  1162. int ocelot_sb_port_pool_get(struct ocelot *ocelot, int port,
  1163. unsigned int sb_index, u16 pool_index,
  1164. u32 *p_threshold);
  1165. int ocelot_sb_port_pool_set(struct ocelot *ocelot, int port,
  1166. unsigned int sb_index, u16 pool_index,
  1167. u32 threshold, struct netlink_ext_ack *extack);
  1168. int ocelot_sb_tc_pool_bind_get(struct ocelot *ocelot, int port,
  1169. unsigned int sb_index, u16 tc_index,
  1170. enum devlink_sb_pool_type pool_type,
  1171. u16 *p_pool_index, u32 *p_threshold);
  1172. int ocelot_sb_tc_pool_bind_set(struct ocelot *ocelot, int port,
  1173. unsigned int sb_index, u16 tc_index,
  1174. enum devlink_sb_pool_type pool_type,
  1175. u16 pool_index, u32 threshold,
  1176. struct netlink_ext_ack *extack);
  1177. int ocelot_sb_occ_snapshot(struct ocelot *ocelot, unsigned int sb_index);
  1178. int ocelot_sb_occ_max_clear(struct ocelot *ocelot, unsigned int sb_index);
  1179. int ocelot_sb_occ_port_pool_get(struct ocelot *ocelot, int port,
  1180. unsigned int sb_index, u16 pool_index,
  1181. u32 *p_cur, u32 *p_max);
  1182. int ocelot_sb_occ_tc_port_bind_get(struct ocelot *ocelot, int port,
  1183. unsigned int sb_index, u16 tc_index,
  1184. enum devlink_sb_pool_type pool_type,
  1185. u32 *p_cur, u32 *p_max);
  1186. void ocelot_phylink_mac_link_down(struct ocelot *ocelot, int port,
  1187. unsigned int link_an_mode,
  1188. phy_interface_t interface,
  1189. unsigned long quirks);
  1190. void ocelot_phylink_mac_link_up(struct ocelot *ocelot, int port,
  1191. struct phy_device *phydev,
  1192. unsigned int link_an_mode,
  1193. phy_interface_t interface,
  1194. int speed, int duplex,
  1195. bool tx_pause, bool rx_pause,
  1196. unsigned long quirks);
  1197. int ocelot_mact_lookup(struct ocelot *ocelot, int *dst_idx,
  1198. const unsigned char mac[ETH_ALEN],
  1199. unsigned int vid, enum macaccess_entry_type *type);
  1200. int ocelot_mact_learn_streamdata(struct ocelot *ocelot, int dst_idx,
  1201. const unsigned char mac[ETH_ALEN],
  1202. unsigned int vid,
  1203. enum macaccess_entry_type type,
  1204. int sfid, int ssid);
  1205. int ocelot_migrate_mdbs(struct ocelot *ocelot, unsigned long from_mask,
  1206. unsigned long to_mask);
  1207. int ocelot_vcap_policer_add(struct ocelot *ocelot, u32 pol_ix,
  1208. struct ocelot_policer *pol);
  1209. int ocelot_vcap_policer_del(struct ocelot *ocelot, u32 pol_ix);
  1210. #if IS_ENABLED(CONFIG_BRIDGE_MRP)
  1211. int ocelot_mrp_add(struct ocelot *ocelot, int port,
  1212. const struct switchdev_obj_mrp *mrp);
  1213. int ocelot_mrp_del(struct ocelot *ocelot, int port,
  1214. const struct switchdev_obj_mrp *mrp);
  1215. int ocelot_mrp_add_ring_role(struct ocelot *ocelot, int port,
  1216. const struct switchdev_obj_ring_role_mrp *mrp);
  1217. int ocelot_mrp_del_ring_role(struct ocelot *ocelot, int port,
  1218. const struct switchdev_obj_ring_role_mrp *mrp);
  1219. #else
  1220. static inline int ocelot_mrp_add(struct ocelot *ocelot, int port,
  1221. const struct switchdev_obj_mrp *mrp)
  1222. {
  1223. return -EOPNOTSUPP;
  1224. }
  1225. static inline int ocelot_mrp_del(struct ocelot *ocelot, int port,
  1226. const struct switchdev_obj_mrp *mrp)
  1227. {
  1228. return -EOPNOTSUPP;
  1229. }
  1230. static inline int
  1231. ocelot_mrp_add_ring_role(struct ocelot *ocelot, int port,
  1232. const struct switchdev_obj_ring_role_mrp *mrp)
  1233. {
  1234. return -EOPNOTSUPP;
  1235. }
  1236. static inline int
  1237. ocelot_mrp_del_ring_role(struct ocelot *ocelot, int port,
  1238. const struct switchdev_obj_ring_role_mrp *mrp)
  1239. {
  1240. return -EOPNOTSUPP;
  1241. }
  1242. #endif
  1243. #endif