rocker.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. /*
  2. * drivers/net/ethernet/rocker/rocker.h - Rocker switch device driver
  3. * Copyright (c) 2014 Jiri Pirko <jiri@resnulli.us>
  4. * Copyright (c) 2014 Scott Feldman <sfeldma@gmail.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. */
  11. #ifndef _ROCKER_H
  12. #define _ROCKER_H
  13. #include <linux/types.h>
  14. /* Return codes */
  15. enum {
  16. ROCKER_OK = 0,
  17. ROCKER_ENOENT = 2,
  18. ROCKER_ENXIO = 6,
  19. ROCKER_ENOMEM = 12,
  20. ROCKER_EEXIST = 17,
  21. ROCKER_EINVAL = 22,
  22. ROCKER_EMSGSIZE = 90,
  23. ROCKER_ENOTSUP = 95,
  24. ROCKER_ENOBUFS = 105,
  25. };
  26. #define ROCKER_FP_PORTS_MAX 62
  27. #define PCI_VENDOR_ID_REDHAT 0x1b36
  28. #define PCI_DEVICE_ID_REDHAT_ROCKER 0x0006
  29. #define ROCKER_PCI_BAR0_SIZE 0x2000
  30. /* MSI-X vectors */
  31. enum {
  32. ROCKER_MSIX_VEC_CMD,
  33. ROCKER_MSIX_VEC_EVENT,
  34. ROCKER_MSIX_VEC_TEST,
  35. ROCKER_MSIX_VEC_RESERVED0,
  36. __ROCKER_MSIX_VEC_TX,
  37. __ROCKER_MSIX_VEC_RX,
  38. #define ROCKER_MSIX_VEC_TX(port) \
  39. (__ROCKER_MSIX_VEC_TX + ((port) * 2))
  40. #define ROCKER_MSIX_VEC_RX(port) \
  41. (__ROCKER_MSIX_VEC_RX + ((port) * 2))
  42. #define ROCKER_MSIX_VEC_COUNT(portcnt) \
  43. (ROCKER_MSIX_VEC_RX((portcnt - 1)) + 1)
  44. };
  45. /* Rocker bogus registers */
  46. #define ROCKER_BOGUS_REG0 0x0000
  47. #define ROCKER_BOGUS_REG1 0x0004
  48. #define ROCKER_BOGUS_REG2 0x0008
  49. #define ROCKER_BOGUS_REG3 0x000c
  50. /* Rocker test registers */
  51. #define ROCKER_TEST_REG 0x0010
  52. #define ROCKER_TEST_REG64 0x0018 /* 8-byte */
  53. #define ROCKER_TEST_IRQ 0x0020
  54. #define ROCKER_TEST_DMA_ADDR 0x0028 /* 8-byte */
  55. #define ROCKER_TEST_DMA_SIZE 0x0030
  56. #define ROCKER_TEST_DMA_CTRL 0x0034
  57. /* Rocker test register ctrl */
  58. #define ROCKER_TEST_DMA_CTRL_CLEAR BIT(0)
  59. #define ROCKER_TEST_DMA_CTRL_FILL BIT(1)
  60. #define ROCKER_TEST_DMA_CTRL_INVERT BIT(2)
  61. /* Rocker DMA ring register offsets */
  62. #define ROCKER_DMA_DESC_ADDR(x) (0x1000 + (x) * 32) /* 8-byte */
  63. #define ROCKER_DMA_DESC_SIZE(x) (0x1008 + (x) * 32)
  64. #define ROCKER_DMA_DESC_HEAD(x) (0x100c + (x) * 32)
  65. #define ROCKER_DMA_DESC_TAIL(x) (0x1010 + (x) * 32)
  66. #define ROCKER_DMA_DESC_CTRL(x) (0x1014 + (x) * 32)
  67. #define ROCKER_DMA_DESC_CREDITS(x) (0x1018 + (x) * 32)
  68. #define ROCKER_DMA_DESC_RES1(x) (0x101c + (x) * 32)
  69. /* Rocker dma ctrl register bits */
  70. #define ROCKER_DMA_DESC_CTRL_RESET BIT(0)
  71. /* Rocker DMA ring types */
  72. enum rocker_dma_type {
  73. ROCKER_DMA_CMD,
  74. ROCKER_DMA_EVENT,
  75. __ROCKER_DMA_TX,
  76. __ROCKER_DMA_RX,
  77. #define ROCKER_DMA_TX(port) (__ROCKER_DMA_TX + (port) * 2)
  78. #define ROCKER_DMA_RX(port) (__ROCKER_DMA_RX + (port) * 2)
  79. };
  80. /* Rocker DMA ring size limits and default sizes */
  81. #define ROCKER_DMA_SIZE_MIN 2ul
  82. #define ROCKER_DMA_SIZE_MAX 65536ul
  83. #define ROCKER_DMA_CMD_DEFAULT_SIZE 32ul
  84. #define ROCKER_DMA_EVENT_DEFAULT_SIZE 32ul
  85. #define ROCKER_DMA_TX_DEFAULT_SIZE 64ul
  86. #define ROCKER_DMA_TX_DESC_SIZE 256
  87. #define ROCKER_DMA_RX_DEFAULT_SIZE 64ul
  88. #define ROCKER_DMA_RX_DESC_SIZE 256
  89. /* Rocker DMA descriptor struct */
  90. struct rocker_desc {
  91. u64 buf_addr;
  92. u64 cookie;
  93. u16 buf_size;
  94. u16 tlv_size;
  95. u16 resv[5];
  96. u16 comp_err;
  97. };
  98. #define ROCKER_DMA_DESC_COMP_ERR_GEN BIT(15)
  99. /* Rocker DMA TLV struct */
  100. struct rocker_tlv {
  101. u32 type;
  102. u16 len;
  103. };
  104. /* TLVs */
  105. enum {
  106. ROCKER_TLV_CMD_UNSPEC,
  107. ROCKER_TLV_CMD_TYPE, /* u16 */
  108. ROCKER_TLV_CMD_INFO, /* nest */
  109. __ROCKER_TLV_CMD_MAX,
  110. ROCKER_TLV_CMD_MAX = __ROCKER_TLV_CMD_MAX - 1,
  111. };
  112. enum {
  113. ROCKER_TLV_CMD_TYPE_UNSPEC,
  114. ROCKER_TLV_CMD_TYPE_GET_PORT_SETTINGS,
  115. ROCKER_TLV_CMD_TYPE_SET_PORT_SETTINGS,
  116. ROCKER_TLV_CMD_TYPE_OF_DPA_FLOW_ADD,
  117. ROCKER_TLV_CMD_TYPE_OF_DPA_FLOW_MOD,
  118. ROCKER_TLV_CMD_TYPE_OF_DPA_FLOW_DEL,
  119. ROCKER_TLV_CMD_TYPE_OF_DPA_FLOW_GET_STATS,
  120. ROCKER_TLV_CMD_TYPE_OF_DPA_GROUP_ADD,
  121. ROCKER_TLV_CMD_TYPE_OF_DPA_GROUP_MOD,
  122. ROCKER_TLV_CMD_TYPE_OF_DPA_GROUP_DEL,
  123. ROCKER_TLV_CMD_TYPE_OF_DPA_GROUP_GET_STATS,
  124. ROCKER_TLV_CMD_TYPE_CLEAR_PORT_STATS,
  125. ROCKER_TLV_CMD_TYPE_GET_PORT_STATS,
  126. __ROCKER_TLV_CMD_TYPE_MAX,
  127. ROCKER_TLV_CMD_TYPE_MAX = __ROCKER_TLV_CMD_TYPE_MAX - 1,
  128. };
  129. enum {
  130. ROCKER_TLV_CMD_PORT_SETTINGS_UNSPEC,
  131. ROCKER_TLV_CMD_PORT_SETTINGS_PPORT, /* u32 */
  132. ROCKER_TLV_CMD_PORT_SETTINGS_SPEED, /* u32 */
  133. ROCKER_TLV_CMD_PORT_SETTINGS_DUPLEX, /* u8 */
  134. ROCKER_TLV_CMD_PORT_SETTINGS_AUTONEG, /* u8 */
  135. ROCKER_TLV_CMD_PORT_SETTINGS_MACADDR, /* binary */
  136. ROCKER_TLV_CMD_PORT_SETTINGS_MODE, /* u8 */
  137. ROCKER_TLV_CMD_PORT_SETTINGS_LEARNING, /* u8 */
  138. ROCKER_TLV_CMD_PORT_SETTINGS_PHYS_NAME, /* binary */
  139. ROCKER_TLV_CMD_PORT_SETTINGS_MTU, /* u16 */
  140. __ROCKER_TLV_CMD_PORT_SETTINGS_MAX,
  141. ROCKER_TLV_CMD_PORT_SETTINGS_MAX =
  142. __ROCKER_TLV_CMD_PORT_SETTINGS_MAX - 1,
  143. };
  144. enum {
  145. ROCKER_TLV_CMD_PORT_STATS_UNSPEC,
  146. ROCKER_TLV_CMD_PORT_STATS_PPORT, /* u32 */
  147. ROCKER_TLV_CMD_PORT_STATS_RX_PKTS, /* u64 */
  148. ROCKER_TLV_CMD_PORT_STATS_RX_BYTES, /* u64 */
  149. ROCKER_TLV_CMD_PORT_STATS_RX_DROPPED, /* u64 */
  150. ROCKER_TLV_CMD_PORT_STATS_RX_ERRORS, /* u64 */
  151. ROCKER_TLV_CMD_PORT_STATS_TX_PKTS, /* u64 */
  152. ROCKER_TLV_CMD_PORT_STATS_TX_BYTES, /* u64 */
  153. ROCKER_TLV_CMD_PORT_STATS_TX_DROPPED, /* u64 */
  154. ROCKER_TLV_CMD_PORT_STATS_TX_ERRORS, /* u64 */
  155. __ROCKER_TLV_CMD_PORT_STATS_MAX,
  156. ROCKER_TLV_CMD_PORT_STATS_MAX = __ROCKER_TLV_CMD_PORT_STATS_MAX - 1,
  157. };
  158. enum rocker_port_mode {
  159. ROCKER_PORT_MODE_OF_DPA,
  160. };
  161. enum {
  162. ROCKER_TLV_EVENT_UNSPEC,
  163. ROCKER_TLV_EVENT_TYPE, /* u16 */
  164. ROCKER_TLV_EVENT_INFO, /* nest */
  165. __ROCKER_TLV_EVENT_MAX,
  166. ROCKER_TLV_EVENT_MAX = __ROCKER_TLV_EVENT_MAX - 1,
  167. };
  168. enum {
  169. ROCKER_TLV_EVENT_TYPE_UNSPEC,
  170. ROCKER_TLV_EVENT_TYPE_LINK_CHANGED,
  171. ROCKER_TLV_EVENT_TYPE_MAC_VLAN_SEEN,
  172. __ROCKER_TLV_EVENT_TYPE_MAX,
  173. ROCKER_TLV_EVENT_TYPE_MAX = __ROCKER_TLV_EVENT_TYPE_MAX - 1,
  174. };
  175. enum {
  176. ROCKER_TLV_EVENT_LINK_CHANGED_UNSPEC,
  177. ROCKER_TLV_EVENT_LINK_CHANGED_PPORT, /* u32 */
  178. ROCKER_TLV_EVENT_LINK_CHANGED_LINKUP, /* u8 */
  179. __ROCKER_TLV_EVENT_LINK_CHANGED_MAX,
  180. ROCKER_TLV_EVENT_LINK_CHANGED_MAX =
  181. __ROCKER_TLV_EVENT_LINK_CHANGED_MAX - 1,
  182. };
  183. enum {
  184. ROCKER_TLV_EVENT_MAC_VLAN_UNSPEC,
  185. ROCKER_TLV_EVENT_MAC_VLAN_PPORT, /* u32 */
  186. ROCKER_TLV_EVENT_MAC_VLAN_MAC, /* binary */
  187. ROCKER_TLV_EVENT_MAC_VLAN_VLAN_ID, /* __be16 */
  188. __ROCKER_TLV_EVENT_MAC_VLAN_MAX,
  189. ROCKER_TLV_EVENT_MAC_VLAN_MAX = __ROCKER_TLV_EVENT_MAC_VLAN_MAX - 1,
  190. };
  191. enum {
  192. ROCKER_TLV_RX_UNSPEC,
  193. ROCKER_TLV_RX_FLAGS, /* u16, see ROCKER_RX_FLAGS_ */
  194. ROCKER_TLV_RX_CSUM, /* u16 */
  195. ROCKER_TLV_RX_FRAG_ADDR, /* u64 */
  196. ROCKER_TLV_RX_FRAG_MAX_LEN, /* u16 */
  197. ROCKER_TLV_RX_FRAG_LEN, /* u16 */
  198. __ROCKER_TLV_RX_MAX,
  199. ROCKER_TLV_RX_MAX = __ROCKER_TLV_RX_MAX - 1,
  200. };
  201. #define ROCKER_RX_FLAGS_IPV4 BIT(0)
  202. #define ROCKER_RX_FLAGS_IPV6 BIT(1)
  203. #define ROCKER_RX_FLAGS_CSUM_CALC BIT(2)
  204. #define ROCKER_RX_FLAGS_IPV4_CSUM_GOOD BIT(3)
  205. #define ROCKER_RX_FLAGS_IP_FRAG BIT(4)
  206. #define ROCKER_RX_FLAGS_TCP BIT(5)
  207. #define ROCKER_RX_FLAGS_UDP BIT(6)
  208. #define ROCKER_RX_FLAGS_TCP_UDP_CSUM_GOOD BIT(7)
  209. #define ROCKER_RX_FLAGS_FWD_OFFLOAD BIT(8)
  210. enum {
  211. ROCKER_TLV_TX_UNSPEC,
  212. ROCKER_TLV_TX_OFFLOAD, /* u8, see ROCKER_TX_OFFLOAD_ */
  213. ROCKER_TLV_TX_L3_CSUM_OFF, /* u16 */
  214. ROCKER_TLV_TX_TSO_MSS, /* u16 */
  215. ROCKER_TLV_TX_TSO_HDR_LEN, /* u16 */
  216. ROCKER_TLV_TX_FRAGS, /* array */
  217. __ROCKER_TLV_TX_MAX,
  218. ROCKER_TLV_TX_MAX = __ROCKER_TLV_TX_MAX - 1,
  219. };
  220. #define ROCKER_TX_OFFLOAD_NONE 0
  221. #define ROCKER_TX_OFFLOAD_IP_CSUM 1
  222. #define ROCKER_TX_OFFLOAD_TCP_UDP_CSUM 2
  223. #define ROCKER_TX_OFFLOAD_L3_CSUM 3
  224. #define ROCKER_TX_OFFLOAD_TSO 4
  225. #define ROCKER_TX_FRAGS_MAX 16
  226. enum {
  227. ROCKER_TLV_TX_FRAG_UNSPEC,
  228. ROCKER_TLV_TX_FRAG, /* nest */
  229. __ROCKER_TLV_TX_FRAG_MAX,
  230. ROCKER_TLV_TX_FRAG_MAX = __ROCKER_TLV_TX_FRAG_MAX - 1,
  231. };
  232. enum {
  233. ROCKER_TLV_TX_FRAG_ATTR_UNSPEC,
  234. ROCKER_TLV_TX_FRAG_ATTR_ADDR, /* u64 */
  235. ROCKER_TLV_TX_FRAG_ATTR_LEN, /* u16 */
  236. __ROCKER_TLV_TX_FRAG_ATTR_MAX,
  237. ROCKER_TLV_TX_FRAG_ATTR_MAX = __ROCKER_TLV_TX_FRAG_ATTR_MAX - 1,
  238. };
  239. /* cmd info nested for OF-DPA msgs */
  240. enum {
  241. ROCKER_TLV_OF_DPA_UNSPEC,
  242. ROCKER_TLV_OF_DPA_TABLE_ID, /* u16 */
  243. ROCKER_TLV_OF_DPA_PRIORITY, /* u32 */
  244. ROCKER_TLV_OF_DPA_HARDTIME, /* u32 */
  245. ROCKER_TLV_OF_DPA_IDLETIME, /* u32 */
  246. ROCKER_TLV_OF_DPA_COOKIE, /* u64 */
  247. ROCKER_TLV_OF_DPA_IN_PPORT, /* u32 */
  248. ROCKER_TLV_OF_DPA_IN_PPORT_MASK, /* u32 */
  249. ROCKER_TLV_OF_DPA_OUT_PPORT, /* u32 */
  250. ROCKER_TLV_OF_DPA_GOTO_TABLE_ID, /* u16 */
  251. ROCKER_TLV_OF_DPA_GROUP_ID, /* u32 */
  252. ROCKER_TLV_OF_DPA_GROUP_ID_LOWER, /* u32 */
  253. ROCKER_TLV_OF_DPA_GROUP_COUNT, /* u16 */
  254. ROCKER_TLV_OF_DPA_GROUP_IDS, /* u32 array */
  255. ROCKER_TLV_OF_DPA_VLAN_ID, /* __be16 */
  256. ROCKER_TLV_OF_DPA_VLAN_ID_MASK, /* __be16 */
  257. ROCKER_TLV_OF_DPA_VLAN_PCP, /* __be16 */
  258. ROCKER_TLV_OF_DPA_VLAN_PCP_MASK, /* __be16 */
  259. ROCKER_TLV_OF_DPA_VLAN_PCP_ACTION, /* u8 */
  260. ROCKER_TLV_OF_DPA_NEW_VLAN_ID, /* __be16 */
  261. ROCKER_TLV_OF_DPA_NEW_VLAN_PCP, /* u8 */
  262. ROCKER_TLV_OF_DPA_TUNNEL_ID, /* u32 */
  263. ROCKER_TLV_OF_DPA_TUNNEL_LPORT, /* u32 */
  264. ROCKER_TLV_OF_DPA_ETHERTYPE, /* __be16 */
  265. ROCKER_TLV_OF_DPA_DST_MAC, /* binary */
  266. ROCKER_TLV_OF_DPA_DST_MAC_MASK, /* binary */
  267. ROCKER_TLV_OF_DPA_SRC_MAC, /* binary */
  268. ROCKER_TLV_OF_DPA_SRC_MAC_MASK, /* binary */
  269. ROCKER_TLV_OF_DPA_IP_PROTO, /* u8 */
  270. ROCKER_TLV_OF_DPA_IP_PROTO_MASK, /* u8 */
  271. ROCKER_TLV_OF_DPA_IP_DSCP, /* u8 */
  272. ROCKER_TLV_OF_DPA_IP_DSCP_MASK, /* u8 */
  273. ROCKER_TLV_OF_DPA_IP_DSCP_ACTION, /* u8 */
  274. ROCKER_TLV_OF_DPA_NEW_IP_DSCP, /* u8 */
  275. ROCKER_TLV_OF_DPA_IP_ECN, /* u8 */
  276. ROCKER_TLV_OF_DPA_IP_ECN_MASK, /* u8 */
  277. ROCKER_TLV_OF_DPA_DST_IP, /* __be32 */
  278. ROCKER_TLV_OF_DPA_DST_IP_MASK, /* __be32 */
  279. ROCKER_TLV_OF_DPA_SRC_IP, /* __be32 */
  280. ROCKER_TLV_OF_DPA_SRC_IP_MASK, /* __be32 */
  281. ROCKER_TLV_OF_DPA_DST_IPV6, /* binary */
  282. ROCKER_TLV_OF_DPA_DST_IPV6_MASK, /* binary */
  283. ROCKER_TLV_OF_DPA_SRC_IPV6, /* binary */
  284. ROCKER_TLV_OF_DPA_SRC_IPV6_MASK, /* binary */
  285. ROCKER_TLV_OF_DPA_SRC_ARP_IP, /* __be32 */
  286. ROCKER_TLV_OF_DPA_SRC_ARP_IP_MASK, /* __be32 */
  287. ROCKER_TLV_OF_DPA_L4_DST_PORT, /* __be16 */
  288. ROCKER_TLV_OF_DPA_L4_DST_PORT_MASK, /* __be16 */
  289. ROCKER_TLV_OF_DPA_L4_SRC_PORT, /* __be16 */
  290. ROCKER_TLV_OF_DPA_L4_SRC_PORT_MASK, /* __be16 */
  291. ROCKER_TLV_OF_DPA_ICMP_TYPE, /* u8 */
  292. ROCKER_TLV_OF_DPA_ICMP_TYPE_MASK, /* u8 */
  293. ROCKER_TLV_OF_DPA_ICMP_CODE, /* u8 */
  294. ROCKER_TLV_OF_DPA_ICMP_CODE_MASK, /* u8 */
  295. ROCKER_TLV_OF_DPA_IPV6_LABEL, /* __be32 */
  296. ROCKER_TLV_OF_DPA_IPV6_LABEL_MASK, /* __be32 */
  297. ROCKER_TLV_OF_DPA_QUEUE_ID_ACTION, /* u8 */
  298. ROCKER_TLV_OF_DPA_NEW_QUEUE_ID, /* u8 */
  299. ROCKER_TLV_OF_DPA_CLEAR_ACTIONS, /* u32 */
  300. ROCKER_TLV_OF_DPA_POP_VLAN, /* u8 */
  301. ROCKER_TLV_OF_DPA_TTL_CHECK, /* u8 */
  302. ROCKER_TLV_OF_DPA_COPY_CPU_ACTION, /* u8 */
  303. __ROCKER_TLV_OF_DPA_MAX,
  304. ROCKER_TLV_OF_DPA_MAX = __ROCKER_TLV_OF_DPA_MAX - 1,
  305. };
  306. /* OF-DPA table IDs */
  307. enum rocker_of_dpa_table_id {
  308. ROCKER_OF_DPA_TABLE_ID_INGRESS_PORT = 0,
  309. ROCKER_OF_DPA_TABLE_ID_VLAN = 10,
  310. ROCKER_OF_DPA_TABLE_ID_TERMINATION_MAC = 20,
  311. ROCKER_OF_DPA_TABLE_ID_UNICAST_ROUTING = 30,
  312. ROCKER_OF_DPA_TABLE_ID_MULTICAST_ROUTING = 40,
  313. ROCKER_OF_DPA_TABLE_ID_BRIDGING = 50,
  314. ROCKER_OF_DPA_TABLE_ID_ACL_POLICY = 60,
  315. };
  316. /* OF-DPA flow stats */
  317. enum {
  318. ROCKER_TLV_OF_DPA_FLOW_STAT_UNSPEC,
  319. ROCKER_TLV_OF_DPA_FLOW_STAT_DURATION, /* u32 */
  320. ROCKER_TLV_OF_DPA_FLOW_STAT_RX_PKTS, /* u64 */
  321. ROCKER_TLV_OF_DPA_FLOW_STAT_TX_PKTS, /* u64 */
  322. __ROCKER_TLV_OF_DPA_FLOW_STAT_MAX,
  323. ROCKER_TLV_OF_DPA_FLOW_STAT_MAX = __ROCKER_TLV_OF_DPA_FLOW_STAT_MAX - 1,
  324. };
  325. /* OF-DPA group types */
  326. enum rocker_of_dpa_group_type {
  327. ROCKER_OF_DPA_GROUP_TYPE_L2_INTERFACE = 0,
  328. ROCKER_OF_DPA_GROUP_TYPE_L2_REWRITE,
  329. ROCKER_OF_DPA_GROUP_TYPE_L3_UCAST,
  330. ROCKER_OF_DPA_GROUP_TYPE_L2_MCAST,
  331. ROCKER_OF_DPA_GROUP_TYPE_L2_FLOOD,
  332. ROCKER_OF_DPA_GROUP_TYPE_L3_INTERFACE,
  333. ROCKER_OF_DPA_GROUP_TYPE_L3_MCAST,
  334. ROCKER_OF_DPA_GROUP_TYPE_L3_ECMP,
  335. ROCKER_OF_DPA_GROUP_TYPE_L2_OVERLAY,
  336. };
  337. /* OF-DPA group L2 overlay types */
  338. enum rocker_of_dpa_overlay_type {
  339. ROCKER_OF_DPA_OVERLAY_TYPE_FLOOD_UCAST = 0,
  340. ROCKER_OF_DPA_OVERLAY_TYPE_FLOOD_MCAST,
  341. ROCKER_OF_DPA_OVERLAY_TYPE_MCAST_UCAST,
  342. ROCKER_OF_DPA_OVERLAY_TYPE_MCAST_MCAST,
  343. };
  344. /* OF-DPA group ID encoding */
  345. #define ROCKER_GROUP_TYPE_SHIFT 28
  346. #define ROCKER_GROUP_TYPE_MASK 0xf0000000
  347. #define ROCKER_GROUP_VLAN_SHIFT 16
  348. #define ROCKER_GROUP_VLAN_MASK 0x0fff0000
  349. #define ROCKER_GROUP_PORT_SHIFT 0
  350. #define ROCKER_GROUP_PORT_MASK 0x0000ffff
  351. #define ROCKER_GROUP_TUNNEL_ID_SHIFT 12
  352. #define ROCKER_GROUP_TUNNEL_ID_MASK 0x0ffff000
  353. #define ROCKER_GROUP_SUBTYPE_SHIFT 10
  354. #define ROCKER_GROUP_SUBTYPE_MASK 0x00000c00
  355. #define ROCKER_GROUP_INDEX_SHIFT 0
  356. #define ROCKER_GROUP_INDEX_MASK 0x0000ffff
  357. #define ROCKER_GROUP_INDEX_LONG_SHIFT 0
  358. #define ROCKER_GROUP_INDEX_LONG_MASK 0x0fffffff
  359. #define ROCKER_GROUP_TYPE_GET(group_id) \
  360. (((group_id) & ROCKER_GROUP_TYPE_MASK) >> ROCKER_GROUP_TYPE_SHIFT)
  361. #define ROCKER_GROUP_TYPE_SET(type) \
  362. (((type) << ROCKER_GROUP_TYPE_SHIFT) & ROCKER_GROUP_TYPE_MASK)
  363. #define ROCKER_GROUP_VLAN_GET(group_id) \
  364. (((group_id) & ROCKER_GROUP_VLAN_ID_MASK) >> ROCKER_GROUP_VLAN_ID_SHIFT)
  365. #define ROCKER_GROUP_VLAN_SET(vlan_id) \
  366. (((vlan_id) << ROCKER_GROUP_VLAN_SHIFT) & ROCKER_GROUP_VLAN_MASK)
  367. #define ROCKER_GROUP_PORT_GET(group_id) \
  368. (((group_id) & ROCKER_GROUP_PORT_MASK) >> ROCKER_GROUP_PORT_SHIFT)
  369. #define ROCKER_GROUP_PORT_SET(port) \
  370. (((port) << ROCKER_GROUP_PORT_SHIFT) & ROCKER_GROUP_PORT_MASK)
  371. #define ROCKER_GROUP_INDEX_GET(group_id) \
  372. (((group_id) & ROCKER_GROUP_INDEX_MASK) >> ROCKER_GROUP_INDEX_SHIFT)
  373. #define ROCKER_GROUP_INDEX_SET(index) \
  374. (((index) << ROCKER_GROUP_INDEX_SHIFT) & ROCKER_GROUP_INDEX_MASK)
  375. #define ROCKER_GROUP_INDEX_LONG_GET(group_id) \
  376. (((group_id) & ROCKER_GROUP_INDEX_LONG_MASK) >> \
  377. ROCKER_GROUP_INDEX_LONG_SHIFT)
  378. #define ROCKER_GROUP_INDEX_LONG_SET(index) \
  379. (((index) << ROCKER_GROUP_INDEX_LONG_SHIFT) & \
  380. ROCKER_GROUP_INDEX_LONG_MASK)
  381. #define ROCKER_GROUP_NONE 0
  382. #define ROCKER_GROUP_L2_INTERFACE(vlan_id, port) \
  383. (ROCKER_GROUP_TYPE_SET(ROCKER_OF_DPA_GROUP_TYPE_L2_INTERFACE) |\
  384. ROCKER_GROUP_VLAN_SET(ntohs(vlan_id)) | ROCKER_GROUP_PORT_SET(port))
  385. #define ROCKER_GROUP_L2_REWRITE(index) \
  386. (ROCKER_GROUP_TYPE_SET(ROCKER_OF_DPA_GROUP_TYPE_L2_REWRITE) |\
  387. ROCKER_GROUP_INDEX_LONG_SET(index))
  388. #define ROCKER_GROUP_L2_MCAST(vlan_id, index) \
  389. (ROCKER_GROUP_TYPE_SET(ROCKER_OF_DPA_GROUP_TYPE_L2_MCAST) |\
  390. ROCKER_GROUP_VLAN_SET(ntohs(vlan_id)) | ROCKER_GROUP_INDEX_SET(index))
  391. #define ROCKER_GROUP_L2_FLOOD(vlan_id, index) \
  392. (ROCKER_GROUP_TYPE_SET(ROCKER_OF_DPA_GROUP_TYPE_L2_FLOOD) |\
  393. ROCKER_GROUP_VLAN_SET(ntohs(vlan_id)) | ROCKER_GROUP_INDEX_SET(index))
  394. #define ROCKER_GROUP_L3_UNICAST(index) \
  395. (ROCKER_GROUP_TYPE_SET(ROCKER_OF_DPA_GROUP_TYPE_L3_UCAST) |\
  396. ROCKER_GROUP_INDEX_LONG_SET(index))
  397. /* Rocker general purpose registers */
  398. #define ROCKER_CONTROL 0x0300
  399. #define ROCKER_PORT_PHYS_COUNT 0x0304
  400. #define ROCKER_PORT_PHYS_LINK_STATUS 0x0310 /* 8-byte */
  401. #define ROCKER_PORT_PHYS_ENABLE 0x0318 /* 8-byte */
  402. #define ROCKER_SWITCH_ID 0x0320 /* 8-byte */
  403. /* Rocker control bits */
  404. #define ROCKER_CONTROL_RESET BIT(0)
  405. #endif