ocelot.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
  2. /*
  3. * Microsemi Ocelot Switch driver
  4. *
  5. * Copyright (c) 2017 Microsemi Corporation
  6. */
  7. #ifndef _MSCC_OCELOT_H_
  8. #define _MSCC_OCELOT_H_
  9. #include <linux/bitops.h>
  10. #include <linux/etherdevice.h>
  11. #include <linux/if_vlan.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/regmap.h>
  14. #include "ocelot_ana.h"
  15. #include "ocelot_dev.h"
  16. #include "ocelot_hsio.h"
  17. #include "ocelot_qsys.h"
  18. #include "ocelot_rew.h"
  19. #include "ocelot_sys.h"
  20. #include "ocelot_qs.h"
  21. #define PGID_AGGR 64
  22. #define PGID_SRC 80
  23. /* Reserved PGIDs */
  24. #define PGID_CPU (PGID_AGGR - 5)
  25. #define PGID_UC (PGID_AGGR - 4)
  26. #define PGID_MC (PGID_AGGR - 3)
  27. #define PGID_MCIPV4 (PGID_AGGR - 2)
  28. #define PGID_MCIPV6 (PGID_AGGR - 1)
  29. #define OCELOT_BUFFER_CELL_SZ 60
  30. #define OCELOT_STATS_CHECK_DELAY (2 * HZ)
  31. #define IFH_LEN 4
  32. struct frame_info {
  33. u32 len;
  34. u16 port;
  35. u16 vid;
  36. u8 cpuq;
  37. u8 tag_type;
  38. };
  39. #define IFH_INJ_BYPASS BIT(31)
  40. #define IFH_INJ_POP_CNT_DISABLE (3 << 28)
  41. #define IFH_TAG_TYPE_C 0
  42. #define IFH_TAG_TYPE_S 1
  43. #define OCELOT_SPEED_2500 0
  44. #define OCELOT_SPEED_1000 1
  45. #define OCELOT_SPEED_100 2
  46. #define OCELOT_SPEED_10 3
  47. #define TARGET_OFFSET 24
  48. #define REG_MASK GENMASK(TARGET_OFFSET - 1, 0)
  49. #define REG(reg, offset) [reg & REG_MASK] = offset
  50. enum ocelot_target {
  51. ANA = 1,
  52. QS,
  53. QSYS,
  54. REW,
  55. SYS,
  56. HSIO,
  57. TARGET_MAX,
  58. };
  59. enum ocelot_reg {
  60. ANA_ADVLEARN = ANA << TARGET_OFFSET,
  61. ANA_VLANMASK,
  62. ANA_PORT_B_DOMAIN,
  63. ANA_ANAGEFIL,
  64. ANA_ANEVENTS,
  65. ANA_STORMLIMIT_BURST,
  66. ANA_STORMLIMIT_CFG,
  67. ANA_ISOLATED_PORTS,
  68. ANA_COMMUNITY_PORTS,
  69. ANA_AUTOAGE,
  70. ANA_MACTOPTIONS,
  71. ANA_LEARNDISC,
  72. ANA_AGENCTRL,
  73. ANA_MIRRORPORTS,
  74. ANA_EMIRRORPORTS,
  75. ANA_FLOODING,
  76. ANA_FLOODING_IPMC,
  77. ANA_SFLOW_CFG,
  78. ANA_PORT_MODE,
  79. ANA_CUT_THRU_CFG,
  80. ANA_PGID_PGID,
  81. ANA_TABLES_ANMOVED,
  82. ANA_TABLES_MACHDATA,
  83. ANA_TABLES_MACLDATA,
  84. ANA_TABLES_STREAMDATA,
  85. ANA_TABLES_MACACCESS,
  86. ANA_TABLES_MACTINDX,
  87. ANA_TABLES_VLANACCESS,
  88. ANA_TABLES_VLANTIDX,
  89. ANA_TABLES_ISDXACCESS,
  90. ANA_TABLES_ISDXTIDX,
  91. ANA_TABLES_ENTRYLIM,
  92. ANA_TABLES_PTP_ID_HIGH,
  93. ANA_TABLES_PTP_ID_LOW,
  94. ANA_TABLES_STREAMACCESS,
  95. ANA_TABLES_STREAMTIDX,
  96. ANA_TABLES_SEQ_HISTORY,
  97. ANA_TABLES_SEQ_MASK,
  98. ANA_TABLES_SFID_MASK,
  99. ANA_TABLES_SFIDACCESS,
  100. ANA_TABLES_SFIDTIDX,
  101. ANA_MSTI_STATE,
  102. ANA_OAM_UPM_LM_CNT,
  103. ANA_SG_ACCESS_CTRL,
  104. ANA_SG_CONFIG_REG_1,
  105. ANA_SG_CONFIG_REG_2,
  106. ANA_SG_CONFIG_REG_3,
  107. ANA_SG_CONFIG_REG_4,
  108. ANA_SG_CONFIG_REG_5,
  109. ANA_SG_GCL_GS_CONFIG,
  110. ANA_SG_GCL_TI_CONFIG,
  111. ANA_SG_STATUS_REG_1,
  112. ANA_SG_STATUS_REG_2,
  113. ANA_SG_STATUS_REG_3,
  114. ANA_PORT_VLAN_CFG,
  115. ANA_PORT_DROP_CFG,
  116. ANA_PORT_QOS_CFG,
  117. ANA_PORT_VCAP_CFG,
  118. ANA_PORT_VCAP_S1_KEY_CFG,
  119. ANA_PORT_VCAP_S2_CFG,
  120. ANA_PORT_PCP_DEI_MAP,
  121. ANA_PORT_CPU_FWD_CFG,
  122. ANA_PORT_CPU_FWD_BPDU_CFG,
  123. ANA_PORT_CPU_FWD_GARP_CFG,
  124. ANA_PORT_CPU_FWD_CCM_CFG,
  125. ANA_PORT_PORT_CFG,
  126. ANA_PORT_POL_CFG,
  127. ANA_PORT_PTP_CFG,
  128. ANA_PORT_PTP_DLY1_CFG,
  129. ANA_PORT_PTP_DLY2_CFG,
  130. ANA_PORT_SFID_CFG,
  131. ANA_PFC_PFC_CFG,
  132. ANA_PFC_PFC_TIMER,
  133. ANA_IPT_OAM_MEP_CFG,
  134. ANA_IPT_IPT,
  135. ANA_PPT_PPT,
  136. ANA_FID_MAP_FID_MAP,
  137. ANA_AGGR_CFG,
  138. ANA_CPUQ_CFG,
  139. ANA_CPUQ_CFG2,
  140. ANA_CPUQ_8021_CFG,
  141. ANA_DSCP_CFG,
  142. ANA_DSCP_REWR_CFG,
  143. ANA_VCAP_RNG_TYPE_CFG,
  144. ANA_VCAP_RNG_VAL_CFG,
  145. ANA_VRAP_CFG,
  146. ANA_VRAP_HDR_DATA,
  147. ANA_VRAP_HDR_MASK,
  148. ANA_DISCARD_CFG,
  149. ANA_FID_CFG,
  150. ANA_POL_PIR_CFG,
  151. ANA_POL_CIR_CFG,
  152. ANA_POL_MODE_CFG,
  153. ANA_POL_PIR_STATE,
  154. ANA_POL_CIR_STATE,
  155. ANA_POL_STATE,
  156. ANA_POL_FLOWC,
  157. ANA_POL_HYST,
  158. ANA_POL_MISC_CFG,
  159. QS_XTR_GRP_CFG = QS << TARGET_OFFSET,
  160. QS_XTR_RD,
  161. QS_XTR_FRM_PRUNING,
  162. QS_XTR_FLUSH,
  163. QS_XTR_DATA_PRESENT,
  164. QS_XTR_CFG,
  165. QS_INJ_GRP_CFG,
  166. QS_INJ_WR,
  167. QS_INJ_CTRL,
  168. QS_INJ_STATUS,
  169. QS_INJ_ERR,
  170. QS_INH_DBG,
  171. QSYS_PORT_MODE = QSYS << TARGET_OFFSET,
  172. QSYS_SWITCH_PORT_MODE,
  173. QSYS_STAT_CNT_CFG,
  174. QSYS_EEE_CFG,
  175. QSYS_EEE_THRES,
  176. QSYS_IGR_NO_SHARING,
  177. QSYS_EGR_NO_SHARING,
  178. QSYS_SW_STATUS,
  179. QSYS_EXT_CPU_CFG,
  180. QSYS_PAD_CFG,
  181. QSYS_CPU_GROUP_MAP,
  182. QSYS_QMAP,
  183. QSYS_ISDX_SGRP,
  184. QSYS_TIMED_FRAME_ENTRY,
  185. QSYS_TFRM_MISC,
  186. QSYS_TFRM_PORT_DLY,
  187. QSYS_TFRM_TIMER_CFG_1,
  188. QSYS_TFRM_TIMER_CFG_2,
  189. QSYS_TFRM_TIMER_CFG_3,
  190. QSYS_TFRM_TIMER_CFG_4,
  191. QSYS_TFRM_TIMER_CFG_5,
  192. QSYS_TFRM_TIMER_CFG_6,
  193. QSYS_TFRM_TIMER_CFG_7,
  194. QSYS_TFRM_TIMER_CFG_8,
  195. QSYS_RED_PROFILE,
  196. QSYS_RES_QOS_MODE,
  197. QSYS_RES_CFG,
  198. QSYS_RES_STAT,
  199. QSYS_EGR_DROP_MODE,
  200. QSYS_EQ_CTRL,
  201. QSYS_EVENTS_CORE,
  202. QSYS_QMAXSDU_CFG_0,
  203. QSYS_QMAXSDU_CFG_1,
  204. QSYS_QMAXSDU_CFG_2,
  205. QSYS_QMAXSDU_CFG_3,
  206. QSYS_QMAXSDU_CFG_4,
  207. QSYS_QMAXSDU_CFG_5,
  208. QSYS_QMAXSDU_CFG_6,
  209. QSYS_QMAXSDU_CFG_7,
  210. QSYS_PREEMPTION_CFG,
  211. QSYS_CIR_CFG,
  212. QSYS_EIR_CFG,
  213. QSYS_SE_CFG,
  214. QSYS_SE_DWRR_CFG,
  215. QSYS_SE_CONNECT,
  216. QSYS_SE_DLB_SENSE,
  217. QSYS_CIR_STATE,
  218. QSYS_EIR_STATE,
  219. QSYS_SE_STATE,
  220. QSYS_HSCH_MISC_CFG,
  221. QSYS_TAG_CONFIG,
  222. QSYS_TAS_PARAM_CFG_CTRL,
  223. QSYS_PORT_MAX_SDU,
  224. QSYS_PARAM_CFG_REG_1,
  225. QSYS_PARAM_CFG_REG_2,
  226. QSYS_PARAM_CFG_REG_3,
  227. QSYS_PARAM_CFG_REG_4,
  228. QSYS_PARAM_CFG_REG_5,
  229. QSYS_GCL_CFG_REG_1,
  230. QSYS_GCL_CFG_REG_2,
  231. QSYS_PARAM_STATUS_REG_1,
  232. QSYS_PARAM_STATUS_REG_2,
  233. QSYS_PARAM_STATUS_REG_3,
  234. QSYS_PARAM_STATUS_REG_4,
  235. QSYS_PARAM_STATUS_REG_5,
  236. QSYS_PARAM_STATUS_REG_6,
  237. QSYS_PARAM_STATUS_REG_7,
  238. QSYS_PARAM_STATUS_REG_8,
  239. QSYS_PARAM_STATUS_REG_9,
  240. QSYS_GCL_STATUS_REG_1,
  241. QSYS_GCL_STATUS_REG_2,
  242. REW_PORT_VLAN_CFG = REW << TARGET_OFFSET,
  243. REW_TAG_CFG,
  244. REW_PORT_CFG,
  245. REW_DSCP_CFG,
  246. REW_PCP_DEI_QOS_MAP_CFG,
  247. REW_PTP_CFG,
  248. REW_PTP_DLY1_CFG,
  249. REW_RED_TAG_CFG,
  250. REW_DSCP_REMAP_DP1_CFG,
  251. REW_DSCP_REMAP_CFG,
  252. REW_STAT_CFG,
  253. REW_REW_STICKY,
  254. REW_PPT,
  255. SYS_COUNT_RX_OCTETS = SYS << TARGET_OFFSET,
  256. SYS_COUNT_RX_UNICAST,
  257. SYS_COUNT_RX_MULTICAST,
  258. SYS_COUNT_RX_BROADCAST,
  259. SYS_COUNT_RX_SHORTS,
  260. SYS_COUNT_RX_FRAGMENTS,
  261. SYS_COUNT_RX_JABBERS,
  262. SYS_COUNT_RX_CRC_ALIGN_ERRS,
  263. SYS_COUNT_RX_SYM_ERRS,
  264. SYS_COUNT_RX_64,
  265. SYS_COUNT_RX_65_127,
  266. SYS_COUNT_RX_128_255,
  267. SYS_COUNT_RX_256_1023,
  268. SYS_COUNT_RX_1024_1526,
  269. SYS_COUNT_RX_1527_MAX,
  270. SYS_COUNT_RX_PAUSE,
  271. SYS_COUNT_RX_CONTROL,
  272. SYS_COUNT_RX_LONGS,
  273. SYS_COUNT_RX_CLASSIFIED_DROPS,
  274. SYS_COUNT_TX_OCTETS,
  275. SYS_COUNT_TX_UNICAST,
  276. SYS_COUNT_TX_MULTICAST,
  277. SYS_COUNT_TX_BROADCAST,
  278. SYS_COUNT_TX_COLLISION,
  279. SYS_COUNT_TX_DROPS,
  280. SYS_COUNT_TX_PAUSE,
  281. SYS_COUNT_TX_64,
  282. SYS_COUNT_TX_65_127,
  283. SYS_COUNT_TX_128_511,
  284. SYS_COUNT_TX_512_1023,
  285. SYS_COUNT_TX_1024_1526,
  286. SYS_COUNT_TX_1527_MAX,
  287. SYS_COUNT_TX_AGING,
  288. SYS_RESET_CFG,
  289. SYS_SR_ETYPE_CFG,
  290. SYS_VLAN_ETYPE_CFG,
  291. SYS_PORT_MODE,
  292. SYS_FRONT_PORT_MODE,
  293. SYS_FRM_AGING,
  294. SYS_STAT_CFG,
  295. SYS_SW_STATUS,
  296. SYS_MISC_CFG,
  297. SYS_REW_MAC_HIGH_CFG,
  298. SYS_REW_MAC_LOW_CFG,
  299. SYS_TIMESTAMP_OFFSET,
  300. SYS_CMID,
  301. SYS_PAUSE_CFG,
  302. SYS_PAUSE_TOT_CFG,
  303. SYS_ATOP,
  304. SYS_ATOP_TOT_CFG,
  305. SYS_MAC_FC_CFG,
  306. SYS_MMGT,
  307. SYS_MMGT_FAST,
  308. SYS_EVENTS_DIF,
  309. SYS_EVENTS_CORE,
  310. SYS_CNT,
  311. SYS_PTP_STATUS,
  312. SYS_PTP_TXSTAMP,
  313. SYS_PTP_NXT,
  314. SYS_PTP_CFG,
  315. SYS_RAM_INIT,
  316. SYS_CM_ADDR,
  317. SYS_CM_DATA_WR,
  318. SYS_CM_DATA_RD,
  319. SYS_CM_OP,
  320. SYS_CM_DATA,
  321. HSIO_PLL5G_CFG0 = HSIO << TARGET_OFFSET,
  322. HSIO_PLL5G_CFG1,
  323. HSIO_PLL5G_CFG2,
  324. HSIO_PLL5G_CFG3,
  325. HSIO_PLL5G_CFG4,
  326. HSIO_PLL5G_CFG5,
  327. HSIO_PLL5G_CFG6,
  328. HSIO_PLL5G_STATUS0,
  329. HSIO_PLL5G_STATUS1,
  330. HSIO_PLL5G_BIST_CFG0,
  331. HSIO_PLL5G_BIST_CFG1,
  332. HSIO_PLL5G_BIST_CFG2,
  333. HSIO_PLL5G_BIST_STAT0,
  334. HSIO_PLL5G_BIST_STAT1,
  335. HSIO_RCOMP_CFG0,
  336. HSIO_RCOMP_STATUS,
  337. HSIO_SYNC_ETH_CFG,
  338. HSIO_SYNC_ETH_PLL_CFG,
  339. HSIO_S1G_DES_CFG,
  340. HSIO_S1G_IB_CFG,
  341. HSIO_S1G_OB_CFG,
  342. HSIO_S1G_SER_CFG,
  343. HSIO_S1G_COMMON_CFG,
  344. HSIO_S1G_PLL_CFG,
  345. HSIO_S1G_PLL_STATUS,
  346. HSIO_S1G_DFT_CFG0,
  347. HSIO_S1G_DFT_CFG1,
  348. HSIO_S1G_DFT_CFG2,
  349. HSIO_S1G_TP_CFG,
  350. HSIO_S1G_RC_PLL_BIST_CFG,
  351. HSIO_S1G_MISC_CFG,
  352. HSIO_S1G_DFT_STATUS,
  353. HSIO_S1G_MISC_STATUS,
  354. HSIO_MCB_S1G_ADDR_CFG,
  355. HSIO_S6G_DIG_CFG,
  356. HSIO_S6G_DFT_CFG0,
  357. HSIO_S6G_DFT_CFG1,
  358. HSIO_S6G_DFT_CFG2,
  359. HSIO_S6G_TP_CFG0,
  360. HSIO_S6G_TP_CFG1,
  361. HSIO_S6G_RC_PLL_BIST_CFG,
  362. HSIO_S6G_MISC_CFG,
  363. HSIO_S6G_OB_ANEG_CFG,
  364. HSIO_S6G_DFT_STATUS,
  365. HSIO_S6G_ERR_CNT,
  366. HSIO_S6G_MISC_STATUS,
  367. HSIO_S6G_DES_CFG,
  368. HSIO_S6G_IB_CFG,
  369. HSIO_S6G_IB_CFG1,
  370. HSIO_S6G_IB_CFG2,
  371. HSIO_S6G_IB_CFG3,
  372. HSIO_S6G_IB_CFG4,
  373. HSIO_S6G_IB_CFG5,
  374. HSIO_S6G_OB_CFG,
  375. HSIO_S6G_OB_CFG1,
  376. HSIO_S6G_SER_CFG,
  377. HSIO_S6G_COMMON_CFG,
  378. HSIO_S6G_PLL_CFG,
  379. HSIO_S6G_ACJTAG_CFG,
  380. HSIO_S6G_GP_CFG,
  381. HSIO_S6G_IB_STATUS0,
  382. HSIO_S6G_IB_STATUS1,
  383. HSIO_S6G_ACJTAG_STATUS,
  384. HSIO_S6G_PLL_STATUS,
  385. HSIO_S6G_REVID,
  386. HSIO_MCB_S6G_ADDR_CFG,
  387. HSIO_HW_CFG,
  388. HSIO_HW_QSGMII_CFG,
  389. HSIO_HW_QSGMII_STAT,
  390. HSIO_CLK_CFG,
  391. HSIO_TEMP_SENSOR_CTRL,
  392. HSIO_TEMP_SENSOR_CFG,
  393. HSIO_TEMP_SENSOR_STAT,
  394. };
  395. enum ocelot_regfield {
  396. ANA_ADVLEARN_VLAN_CHK,
  397. ANA_ADVLEARN_LEARN_MIRROR,
  398. ANA_ANEVENTS_FLOOD_DISCARD,
  399. ANA_ANEVENTS_MSTI_DROP,
  400. ANA_ANEVENTS_ACLKILL,
  401. ANA_ANEVENTS_ACLUSED,
  402. ANA_ANEVENTS_AUTOAGE,
  403. ANA_ANEVENTS_VS2TTL1,
  404. ANA_ANEVENTS_STORM_DROP,
  405. ANA_ANEVENTS_LEARN_DROP,
  406. ANA_ANEVENTS_AGED_ENTRY,
  407. ANA_ANEVENTS_CPU_LEARN_FAILED,
  408. ANA_ANEVENTS_AUTO_LEARN_FAILED,
  409. ANA_ANEVENTS_LEARN_REMOVE,
  410. ANA_ANEVENTS_AUTO_LEARNED,
  411. ANA_ANEVENTS_AUTO_MOVED,
  412. ANA_ANEVENTS_DROPPED,
  413. ANA_ANEVENTS_CLASSIFIED_DROP,
  414. ANA_ANEVENTS_CLASSIFIED_COPY,
  415. ANA_ANEVENTS_VLAN_DISCARD,
  416. ANA_ANEVENTS_FWD_DISCARD,
  417. ANA_ANEVENTS_MULTICAST_FLOOD,
  418. ANA_ANEVENTS_UNICAST_FLOOD,
  419. ANA_ANEVENTS_DEST_KNOWN,
  420. ANA_ANEVENTS_BUCKET3_MATCH,
  421. ANA_ANEVENTS_BUCKET2_MATCH,
  422. ANA_ANEVENTS_BUCKET1_MATCH,
  423. ANA_ANEVENTS_BUCKET0_MATCH,
  424. ANA_ANEVENTS_CPU_OPERATION,
  425. ANA_ANEVENTS_DMAC_LOOKUP,
  426. ANA_ANEVENTS_SMAC_LOOKUP,
  427. ANA_ANEVENTS_SEQ_GEN_ERR_0,
  428. ANA_ANEVENTS_SEQ_GEN_ERR_1,
  429. ANA_TABLES_MACACCESS_B_DOM,
  430. ANA_TABLES_MACTINDX_BUCKET,
  431. ANA_TABLES_MACTINDX_M_INDEX,
  432. QSYS_TIMED_FRAME_ENTRY_TFRM_VLD,
  433. QSYS_TIMED_FRAME_ENTRY_TFRM_FP,
  434. QSYS_TIMED_FRAME_ENTRY_TFRM_PORTNO,
  435. QSYS_TIMED_FRAME_ENTRY_TFRM_TM_SEL,
  436. QSYS_TIMED_FRAME_ENTRY_TFRM_TM_T,
  437. SYS_RESET_CFG_CORE_ENA,
  438. SYS_RESET_CFG_MEM_ENA,
  439. SYS_RESET_CFG_MEM_INIT,
  440. REGFIELD_MAX
  441. };
  442. struct ocelot_multicast {
  443. struct list_head list;
  444. unsigned char addr[ETH_ALEN];
  445. u16 vid;
  446. u16 ports;
  447. };
  448. struct ocelot_port;
  449. struct ocelot_stat_layout {
  450. u32 offset;
  451. char name[ETH_GSTRING_LEN];
  452. };
  453. struct ocelot {
  454. struct device *dev;
  455. struct regmap *targets[TARGET_MAX];
  456. struct regmap_field *regfields[REGFIELD_MAX];
  457. const u32 *const *map;
  458. const struct ocelot_stat_layout *stats_layout;
  459. unsigned int num_stats;
  460. u8 base_mac[ETH_ALEN];
  461. struct net_device *hw_bridge_dev;
  462. u16 bridge_mask;
  463. u16 bridge_fwd_mask;
  464. struct workqueue_struct *ocelot_owq;
  465. int shared_queue_sz;
  466. u8 num_phys_ports;
  467. u8 num_cpu_ports;
  468. struct ocelot_port **ports;
  469. u32 *lags;
  470. /* Keep track of the vlan port masks */
  471. u32 vlan_mask[VLAN_N_VID];
  472. struct list_head multicast;
  473. /* Workqueue to check statistics for overflow with its lock */
  474. struct mutex stats_lock;
  475. u64 *stats;
  476. struct delayed_work stats_work;
  477. struct workqueue_struct *stats_queue;
  478. };
  479. struct ocelot_port {
  480. struct net_device *dev;
  481. struct ocelot *ocelot;
  482. struct phy_device *phy;
  483. void __iomem *regs;
  484. u8 chip_port;
  485. /* Keep a track of the mc addresses added to the mac table, so that they
  486. * can be removed when needed.
  487. */
  488. struct list_head mc;
  489. /* Ingress default VLAN (pvid) */
  490. u16 pvid;
  491. /* Egress default VLAN (vid) */
  492. u16 vid;
  493. u8 vlan_aware;
  494. u64 *stats;
  495. };
  496. u32 __ocelot_read_ix(struct ocelot *ocelot, u32 reg, u32 offset);
  497. #define ocelot_read_ix(ocelot, reg, gi, ri) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
  498. #define ocelot_read_gix(ocelot, reg, gi) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi))
  499. #define ocelot_read_rix(ocelot, reg, ri) __ocelot_read_ix(ocelot, reg, reg##_RSZ * (ri))
  500. #define ocelot_read(ocelot, reg) __ocelot_read_ix(ocelot, reg, 0)
  501. void __ocelot_write_ix(struct ocelot *ocelot, u32 val, u32 reg, u32 offset);
  502. #define ocelot_write_ix(ocelot, val, reg, gi, ri) __ocelot_write_ix(ocelot, val, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
  503. #define ocelot_write_gix(ocelot, val, reg, gi) __ocelot_write_ix(ocelot, val, reg, reg##_GSZ * (gi))
  504. #define ocelot_write_rix(ocelot, val, reg, ri) __ocelot_write_ix(ocelot, val, reg, reg##_RSZ * (ri))
  505. #define ocelot_write(ocelot, val, reg) __ocelot_write_ix(ocelot, val, reg, 0)
  506. void __ocelot_rmw_ix(struct ocelot *ocelot, u32 val, u32 mask, u32 reg,
  507. u32 offset);
  508. #define ocelot_rmw_ix(ocelot, val, m, reg, gi, ri) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
  509. #define ocelot_rmw_gix(ocelot, val, m, reg, gi) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi))
  510. #define ocelot_rmw_rix(ocelot, val, m, reg, ri) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_RSZ * (ri))
  511. #define ocelot_rmw(ocelot, val, m, reg) __ocelot_rmw_ix(ocelot, val, m, reg, 0)
  512. u32 ocelot_port_readl(struct ocelot_port *port, u32 reg);
  513. void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg);
  514. int ocelot_regfields_init(struct ocelot *ocelot,
  515. const struct reg_field *const regfields);
  516. struct regmap *ocelot_io_platform_init(struct ocelot *ocelot,
  517. struct platform_device *pdev,
  518. const char *name);
  519. #define ocelot_field_write(ocelot, reg, val) regmap_field_write((ocelot)->regfields[(reg)], (val))
  520. #define ocelot_field_read(ocelot, reg, val) regmap_field_read((ocelot)->regfields[(reg)], (val))
  521. int ocelot_init(struct ocelot *ocelot);
  522. void ocelot_deinit(struct ocelot *ocelot);
  523. int ocelot_chip_init(struct ocelot *ocelot);
  524. int ocelot_probe_port(struct ocelot *ocelot, u8 port,
  525. void __iomem *regs,
  526. struct phy_device *phy);
  527. extern struct notifier_block ocelot_netdevice_nb;
  528. #endif