dpsw.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright 2014-2016 Freescale Semiconductor Inc.
  4. * Copyright 2017-2021 NXP
  5. *
  6. */
  7. #ifndef __FSL_DPSW_H
  8. #define __FSL_DPSW_H
  9. /* Data Path L2-Switch API
  10. * Contains API for handling DPSW topology and functionality
  11. */
  12. struct fsl_mc_io;
  13. /* DPSW general definitions */
  14. #define DPSW_MAX_PRIORITIES 8
  15. #define DPSW_MAX_IF 64
  16. int dpsw_open(struct fsl_mc_io *mc_io, u32 cmd_flags, int dpsw_id, u16 *token);
  17. int dpsw_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
  18. /* DPSW options */
  19. /**
  20. * DPSW_OPT_FLOODING_DIS - Flooding was disabled at device create
  21. */
  22. #define DPSW_OPT_FLOODING_DIS 0x0000000000000001ULL
  23. /**
  24. * DPSW_OPT_MULTICAST_DIS - Multicast was disabled at device create
  25. */
  26. #define DPSW_OPT_MULTICAST_DIS 0x0000000000000004ULL
  27. /**
  28. * DPSW_OPT_CTRL_IF_DIS - Control interface support is disabled
  29. */
  30. #define DPSW_OPT_CTRL_IF_DIS 0x0000000000000010ULL
  31. /**
  32. * enum dpsw_component_type - component type of a bridge
  33. * @DPSW_COMPONENT_TYPE_C_VLAN: A C-VLAN component of an
  34. * enterprise VLAN bridge or of a Provider Bridge used
  35. * to process C-tagged frames
  36. * @DPSW_COMPONENT_TYPE_S_VLAN: An S-VLAN component of a
  37. * Provider Bridge
  38. *
  39. */
  40. enum dpsw_component_type {
  41. DPSW_COMPONENT_TYPE_C_VLAN = 0,
  42. DPSW_COMPONENT_TYPE_S_VLAN
  43. };
  44. /**
  45. * enum dpsw_flooding_cfg - flooding configuration requested
  46. * @DPSW_FLOODING_PER_VLAN: Flooding replicators are allocated per VLAN and
  47. * interfaces present in each of them can be configured using
  48. * dpsw_vlan_add_if_flooding()/dpsw_vlan_remove_if_flooding().
  49. * This is the default configuration.
  50. *
  51. * @DPSW_FLOODING_PER_FDB: Flooding replicators are allocated per FDB and
  52. * interfaces present in each of them can be configured using
  53. * dpsw_set_egress_flood().
  54. */
  55. enum dpsw_flooding_cfg {
  56. DPSW_FLOODING_PER_VLAN = 0,
  57. DPSW_FLOODING_PER_FDB,
  58. };
  59. /**
  60. * enum dpsw_broadcast_cfg - broadcast configuration requested
  61. * @DPSW_BROADCAST_PER_OBJECT: There is only one broadcast replicator per DPSW
  62. * object. This is the default configuration.
  63. * @DPSW_BROADCAST_PER_FDB: Broadcast replicators are allocated per FDB and
  64. * interfaces present in each of them can be configured using
  65. * dpsw_set_egress_flood().
  66. */
  67. enum dpsw_broadcast_cfg {
  68. DPSW_BROADCAST_PER_OBJECT = 0,
  69. DPSW_BROADCAST_PER_FDB,
  70. };
  71. int dpsw_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
  72. int dpsw_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
  73. int dpsw_reset(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
  74. /* DPSW IRQ Index and Events */
  75. #define DPSW_IRQ_INDEX_IF 0x0000
  76. #define DPSW_IRQ_INDEX_L2SW 0x0001
  77. /**
  78. * DPSW_IRQ_EVENT_LINK_CHANGED - Indicates that the link state changed
  79. */
  80. #define DPSW_IRQ_EVENT_LINK_CHANGED 0x0001
  81. /**
  82. * DPSW_IRQ_EVENT_ENDPOINT_CHANGED - Indicates a change in endpoint
  83. */
  84. #define DPSW_IRQ_EVENT_ENDPOINT_CHANGED 0x0002
  85. /**
  86. * struct dpsw_irq_cfg - IRQ configuration
  87. * @addr: Address that must be written to signal a message-based interrupt
  88. * @val: Value to write into irq_addr address
  89. * @irq_num: A user defined number associated with this IRQ
  90. */
  91. struct dpsw_irq_cfg {
  92. u64 addr;
  93. u32 val;
  94. int irq_num;
  95. };
  96. int dpsw_set_irq_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  97. u8 irq_index, u8 en);
  98. int dpsw_set_irq_mask(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  99. u8 irq_index, u32 mask);
  100. int dpsw_get_irq_status(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  101. u8 irq_index, u32 *status);
  102. int dpsw_clear_irq_status(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  103. u8 irq_index, u32 status);
  104. /**
  105. * struct dpsw_attr - Structure representing DPSW attributes
  106. * @id: DPSW object ID
  107. * @options: Enable/Disable DPSW features
  108. * @max_vlans: Maximum Number of VLANs
  109. * @max_meters_per_if: Number of meters per interface
  110. * @max_fdbs: Maximum Number of FDBs
  111. * @max_fdb_entries: Number of FDB entries for default FDB table;
  112. * 0 - indicates default 1024 entries.
  113. * @fdb_aging_time: Default FDB aging time for default FDB table;
  114. * 0 - indicates default 300 seconds
  115. * @max_fdb_mc_groups: Number of multicast groups in each FDB table;
  116. * 0 - indicates default 32
  117. * @mem_size: DPSW frame storage memory size
  118. * @num_ifs: Number of interfaces
  119. * @num_vlans: Current number of VLANs
  120. * @num_fdbs: Current number of FDBs
  121. * @component_type: Component type of this bridge
  122. * @flooding_cfg: Flooding configuration (PER_VLAN - default, PER_FDB)
  123. * @broadcast_cfg: Broadcast configuration (PER_OBJECT - default, PER_FDB)
  124. */
  125. struct dpsw_attr {
  126. int id;
  127. u64 options;
  128. u16 max_vlans;
  129. u8 max_meters_per_if;
  130. u8 max_fdbs;
  131. u16 max_fdb_entries;
  132. u16 fdb_aging_time;
  133. u16 max_fdb_mc_groups;
  134. u16 num_ifs;
  135. u16 mem_size;
  136. u16 num_vlans;
  137. u8 num_fdbs;
  138. enum dpsw_component_type component_type;
  139. enum dpsw_flooding_cfg flooding_cfg;
  140. enum dpsw_broadcast_cfg broadcast_cfg;
  141. };
  142. int dpsw_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  143. struct dpsw_attr *attr);
  144. /**
  145. * struct dpsw_ctrl_if_attr - Control interface attributes
  146. * @rx_fqid: Receive FQID
  147. * @rx_err_fqid: Receive error FQID
  148. * @tx_err_conf_fqid: Transmit error and confirmation FQID
  149. */
  150. struct dpsw_ctrl_if_attr {
  151. u32 rx_fqid;
  152. u32 rx_err_fqid;
  153. u32 tx_err_conf_fqid;
  154. };
  155. int dpsw_ctrl_if_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags,
  156. u16 token, struct dpsw_ctrl_if_attr *attr);
  157. enum dpsw_queue_type {
  158. DPSW_QUEUE_RX,
  159. DPSW_QUEUE_TX_ERR_CONF,
  160. DPSW_QUEUE_RX_ERR,
  161. };
  162. #define DPSW_MAX_DPBP 8
  163. /**
  164. * struct dpsw_ctrl_if_pools_cfg - Control interface buffer pools configuration
  165. * @num_dpbp: Number of DPBPs
  166. * @pools: Array of buffer pools parameters; The number of valid entries
  167. * must match 'num_dpbp' value
  168. * @pools.dpbp_id: DPBP object ID
  169. * @pools.buffer_size: Buffer size
  170. * @pools.backup_pool: Backup pool
  171. */
  172. struct dpsw_ctrl_if_pools_cfg {
  173. u8 num_dpbp;
  174. struct {
  175. int dpbp_id;
  176. u16 buffer_size;
  177. int backup_pool;
  178. } pools[DPSW_MAX_DPBP];
  179. };
  180. int dpsw_ctrl_if_set_pools(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  181. const struct dpsw_ctrl_if_pools_cfg *cfg);
  182. #define DPSW_CTRL_IF_QUEUE_OPT_USER_CTX 0x00000001
  183. #define DPSW_CTRL_IF_QUEUE_OPT_DEST 0x00000002
  184. enum dpsw_ctrl_if_dest {
  185. DPSW_CTRL_IF_DEST_NONE = 0,
  186. DPSW_CTRL_IF_DEST_DPIO = 1,
  187. };
  188. struct dpsw_ctrl_if_dest_cfg {
  189. enum dpsw_ctrl_if_dest dest_type;
  190. int dest_id;
  191. u8 priority;
  192. };
  193. struct dpsw_ctrl_if_queue_cfg {
  194. u32 options;
  195. u64 user_ctx;
  196. struct dpsw_ctrl_if_dest_cfg dest_cfg;
  197. };
  198. int dpsw_ctrl_if_set_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  199. enum dpsw_queue_type qtype,
  200. const struct dpsw_ctrl_if_queue_cfg *cfg);
  201. int dpsw_ctrl_if_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
  202. int dpsw_ctrl_if_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
  203. /**
  204. * enum dpsw_action - Action selection for special/control frames
  205. * @DPSW_ACTION_DROP: Drop frame
  206. * @DPSW_ACTION_REDIRECT: Redirect frame to control port
  207. */
  208. enum dpsw_action {
  209. DPSW_ACTION_DROP = 0,
  210. DPSW_ACTION_REDIRECT = 1
  211. };
  212. #define DPSW_LINK_OPT_AUTONEG 0x0000000000000001ULL
  213. #define DPSW_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
  214. #define DPSW_LINK_OPT_PAUSE 0x0000000000000004ULL
  215. #define DPSW_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
  216. /**
  217. * struct dpsw_link_cfg - Structure representing DPSW link configuration
  218. * @rate: Rate
  219. * @options: Mask of available options; use 'DPSW_LINK_OPT_<X>' values
  220. */
  221. struct dpsw_link_cfg {
  222. u32 rate;
  223. u64 options;
  224. };
  225. int dpsw_if_set_link_cfg(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 if_id,
  226. struct dpsw_link_cfg *cfg);
  227. /**
  228. * struct dpsw_link_state - Structure representing DPSW link state
  229. * @rate: Rate
  230. * @options: Mask of available options; use 'DPSW_LINK_OPT_<X>' values
  231. * @up: 0 - covers two cases: down and disconnected, 1 - up
  232. */
  233. struct dpsw_link_state {
  234. u32 rate;
  235. u64 options;
  236. u8 up;
  237. };
  238. int dpsw_if_get_link_state(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  239. u16 if_id, struct dpsw_link_state *state);
  240. /**
  241. * struct dpsw_tci_cfg - Tag Control Information (TCI) configuration
  242. * @pcp: Priority Code Point (PCP): a 3-bit field which refers
  243. * to the IEEE 802.1p priority
  244. * @dei: Drop Eligible Indicator (DEI): a 1-bit field. May be used
  245. * separately or in conjunction with PCP to indicate frames
  246. * eligible to be dropped in the presence of congestion
  247. * @vlan_id: VLAN Identifier (VID): a 12-bit field specifying the VLAN
  248. * to which the frame belongs. The hexadecimal values
  249. * of 0x000 and 0xFFF are reserved;
  250. * all other values may be used as VLAN identifiers,
  251. * allowing up to 4,094 VLANs
  252. */
  253. struct dpsw_tci_cfg {
  254. u8 pcp;
  255. u8 dei;
  256. u16 vlan_id;
  257. };
  258. int dpsw_if_set_tci(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 if_id,
  259. const struct dpsw_tci_cfg *cfg);
  260. int dpsw_if_get_tci(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 if_id,
  261. struct dpsw_tci_cfg *cfg);
  262. /**
  263. * enum dpsw_stp_state - Spanning Tree Protocol (STP) states
  264. * @DPSW_STP_STATE_DISABLED: Disabled state
  265. * @DPSW_STP_STATE_LISTENING: Listening state
  266. * @DPSW_STP_STATE_LEARNING: Learning state
  267. * @DPSW_STP_STATE_FORWARDING: Forwarding state
  268. * @DPSW_STP_STATE_BLOCKING: Blocking state
  269. *
  270. */
  271. enum dpsw_stp_state {
  272. DPSW_STP_STATE_DISABLED = 0,
  273. DPSW_STP_STATE_LISTENING = 1,
  274. DPSW_STP_STATE_LEARNING = 2,
  275. DPSW_STP_STATE_FORWARDING = 3,
  276. DPSW_STP_STATE_BLOCKING = 0
  277. };
  278. /**
  279. * struct dpsw_stp_cfg - Spanning Tree Protocol (STP) Configuration
  280. * @vlan_id: VLAN ID STP state
  281. * @state: STP state
  282. */
  283. struct dpsw_stp_cfg {
  284. u16 vlan_id;
  285. enum dpsw_stp_state state;
  286. };
  287. int dpsw_if_set_stp(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 if_id,
  288. const struct dpsw_stp_cfg *cfg);
  289. /**
  290. * enum dpsw_accepted_frames - Types of frames to accept
  291. * @DPSW_ADMIT_ALL: The device accepts VLAN tagged, untagged and
  292. * priority tagged frames
  293. * @DPSW_ADMIT_ONLY_VLAN_TAGGED: The device discards untagged frames or
  294. * Priority-Tagged frames received on this interface.
  295. *
  296. */
  297. enum dpsw_accepted_frames {
  298. DPSW_ADMIT_ALL = 1,
  299. DPSW_ADMIT_ONLY_VLAN_TAGGED = 3
  300. };
  301. /**
  302. * enum dpsw_counter - Counters types
  303. * @DPSW_CNT_ING_FRAME: Counts ingress frames
  304. * @DPSW_CNT_ING_BYTE: Counts ingress bytes
  305. * @DPSW_CNT_ING_FLTR_FRAME: Counts filtered ingress frames
  306. * @DPSW_CNT_ING_FRAME_DISCARD: Counts discarded ingress frame
  307. * @DPSW_CNT_ING_MCAST_FRAME: Counts ingress multicast frames
  308. * @DPSW_CNT_ING_MCAST_BYTE: Counts ingress multicast bytes
  309. * @DPSW_CNT_ING_BCAST_FRAME: Counts ingress broadcast frames
  310. * @DPSW_CNT_ING_BCAST_BYTES: Counts ingress broadcast bytes
  311. * @DPSW_CNT_EGR_FRAME: Counts egress frames
  312. * @DPSW_CNT_EGR_BYTE: Counts egress bytes
  313. * @DPSW_CNT_EGR_FRAME_DISCARD: Counts discarded egress frames
  314. * @DPSW_CNT_EGR_STP_FRAME_DISCARD: Counts egress STP discarded frames
  315. * @DPSW_CNT_ING_NO_BUFF_DISCARD: Counts ingress no buffer discarded frames
  316. */
  317. enum dpsw_counter {
  318. DPSW_CNT_ING_FRAME = 0x0,
  319. DPSW_CNT_ING_BYTE = 0x1,
  320. DPSW_CNT_ING_FLTR_FRAME = 0x2,
  321. DPSW_CNT_ING_FRAME_DISCARD = 0x3,
  322. DPSW_CNT_ING_MCAST_FRAME = 0x4,
  323. DPSW_CNT_ING_MCAST_BYTE = 0x5,
  324. DPSW_CNT_ING_BCAST_FRAME = 0x6,
  325. DPSW_CNT_ING_BCAST_BYTES = 0x7,
  326. DPSW_CNT_EGR_FRAME = 0x8,
  327. DPSW_CNT_EGR_BYTE = 0x9,
  328. DPSW_CNT_EGR_FRAME_DISCARD = 0xa,
  329. DPSW_CNT_EGR_STP_FRAME_DISCARD = 0xb,
  330. DPSW_CNT_ING_NO_BUFF_DISCARD = 0xc,
  331. };
  332. int dpsw_if_get_counter(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  333. u16 if_id, enum dpsw_counter type, u64 *counter);
  334. int dpsw_if_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 if_id);
  335. int dpsw_if_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 if_id);
  336. /**
  337. * struct dpsw_if_attr - Structure representing DPSW interface attributes
  338. * @num_tcs: Number of traffic classes
  339. * @rate: Transmit rate in bits per second
  340. * @options: Interface configuration options (bitmap)
  341. * @enabled: Indicates if interface is enabled
  342. * @accept_all_vlan: The device discards/accepts incoming frames
  343. * for VLANs that do not include this interface
  344. * @admit_untagged: When set to 'DPSW_ADMIT_ONLY_VLAN_TAGGED', the device
  345. * discards untagged frames or priority-tagged frames received on
  346. * this interface;
  347. * When set to 'DPSW_ADMIT_ALL', untagged frames or priority-
  348. * tagged frames received on this interface are accepted
  349. * @qdid: control frames transmit qdid
  350. */
  351. struct dpsw_if_attr {
  352. u8 num_tcs;
  353. u32 rate;
  354. u32 options;
  355. int enabled;
  356. int accept_all_vlan;
  357. enum dpsw_accepted_frames admit_untagged;
  358. u16 qdid;
  359. };
  360. int dpsw_if_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  361. u16 if_id, struct dpsw_if_attr *attr);
  362. int dpsw_if_set_max_frame_length(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  363. u16 if_id, u16 frame_length);
  364. /**
  365. * struct dpsw_vlan_cfg - VLAN Configuration
  366. * @fdb_id: Forwarding Data Base
  367. */
  368. struct dpsw_vlan_cfg {
  369. u16 fdb_id;
  370. };
  371. int dpsw_vlan_add(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  372. u16 vlan_id, const struct dpsw_vlan_cfg *cfg);
  373. #define DPSW_VLAN_ADD_IF_OPT_FDB_ID 0x0001
  374. /**
  375. * struct dpsw_vlan_if_cfg - Set of VLAN Interfaces
  376. * @num_ifs: The number of interfaces that are assigned to the egress
  377. * list for this VLAN
  378. * @if_id: The set of interfaces that are
  379. * assigned to the egress list for this VLAN
  380. * @options: Options map for this command (DPSW_VLAN_ADD_IF_OPT_FDB_ID)
  381. * @fdb_id: FDB id to be used by this VLAN on these specific interfaces
  382. * (taken into account only if the DPSW_VLAN_ADD_IF_OPT_FDB_ID is
  383. * specified in the options field)
  384. */
  385. struct dpsw_vlan_if_cfg {
  386. u16 num_ifs;
  387. u16 options;
  388. u16 if_id[DPSW_MAX_IF];
  389. u16 fdb_id;
  390. };
  391. int dpsw_vlan_add_if(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  392. u16 vlan_id, const struct dpsw_vlan_if_cfg *cfg);
  393. int dpsw_vlan_add_if_untagged(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  394. u16 vlan_id, const struct dpsw_vlan_if_cfg *cfg);
  395. int dpsw_vlan_remove_if(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  396. u16 vlan_id, const struct dpsw_vlan_if_cfg *cfg);
  397. int dpsw_vlan_remove_if_untagged(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  398. u16 vlan_id, const struct dpsw_vlan_if_cfg *cfg);
  399. int dpsw_vlan_remove(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  400. u16 vlan_id);
  401. /**
  402. * enum dpsw_fdb_entry_type - FDB Entry type - Static/Dynamic
  403. * @DPSW_FDB_ENTRY_STATIC: Static entry
  404. * @DPSW_FDB_ENTRY_DINAMIC: Dynamic entry
  405. */
  406. enum dpsw_fdb_entry_type {
  407. DPSW_FDB_ENTRY_STATIC = 0,
  408. DPSW_FDB_ENTRY_DINAMIC = 1
  409. };
  410. /**
  411. * struct dpsw_fdb_unicast_cfg - Unicast entry configuration
  412. * @type: Select static or dynamic entry
  413. * @mac_addr: MAC address
  414. * @if_egress: Egress interface ID
  415. */
  416. struct dpsw_fdb_unicast_cfg {
  417. enum dpsw_fdb_entry_type type;
  418. u8 mac_addr[6];
  419. u16 if_egress;
  420. };
  421. int dpsw_fdb_add_unicast(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  422. u16 fdb_id, const struct dpsw_fdb_unicast_cfg *cfg);
  423. int dpsw_fdb_remove_unicast(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  424. u16 fdb_id, const struct dpsw_fdb_unicast_cfg *cfg);
  425. #define DPSW_FDB_ENTRY_TYPE_DYNAMIC BIT(0)
  426. #define DPSW_FDB_ENTRY_TYPE_UNICAST BIT(1)
  427. /**
  428. * struct fdb_dump_entry - fdb snapshot entry
  429. * @mac_addr: MAC address
  430. * @type: bit0 - DINAMIC(1)/STATIC(0), bit1 - UNICAST(1)/MULTICAST(0)
  431. * @if_info: unicast - egress interface, multicast - number of egress interfaces
  432. * @if_mask: multicast - egress interface mask
  433. */
  434. struct fdb_dump_entry {
  435. u8 mac_addr[6];
  436. u8 type;
  437. u8 if_info;
  438. u8 if_mask[8];
  439. };
  440. int dpsw_fdb_dump(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 fdb_id,
  441. u64 iova_addr, u32 iova_size, u16 *num_entries);
  442. /**
  443. * struct dpsw_fdb_multicast_cfg - Multi-cast entry configuration
  444. * @type: Select static or dynamic entry
  445. * @mac_addr: MAC address
  446. * @num_ifs: Number of external and internal interfaces
  447. * @if_id: Egress interface IDs
  448. */
  449. struct dpsw_fdb_multicast_cfg {
  450. enum dpsw_fdb_entry_type type;
  451. u8 mac_addr[6];
  452. u16 num_ifs;
  453. u16 if_id[DPSW_MAX_IF];
  454. };
  455. int dpsw_fdb_add_multicast(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  456. u16 fdb_id, const struct dpsw_fdb_multicast_cfg *cfg);
  457. int dpsw_fdb_remove_multicast(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  458. u16 fdb_id, const struct dpsw_fdb_multicast_cfg *cfg);
  459. /**
  460. * enum dpsw_learning_mode - Auto-learning modes
  461. * @DPSW_LEARNING_MODE_DIS: Disable Auto-learning
  462. * @DPSW_LEARNING_MODE_HW: Enable HW auto-Learning
  463. * @DPSW_LEARNING_MODE_NON_SECURE: Enable None secure learning by CPU
  464. * @DPSW_LEARNING_MODE_SECURE: Enable secure learning by CPU
  465. *
  466. * NONE - SECURE LEARNING
  467. * SMAC found DMAC found CTLU Action
  468. * v v Forward frame to
  469. * 1. DMAC destination
  470. * - v Forward frame to
  471. * 1. DMAC destination
  472. * 2. Control interface
  473. * v - Forward frame to
  474. * 1. Flooding list of interfaces
  475. * - - Forward frame to
  476. * 1. Flooding list of interfaces
  477. * 2. Control interface
  478. * SECURE LEARING
  479. * SMAC found DMAC found CTLU Action
  480. * v v Forward frame to
  481. * 1. DMAC destination
  482. * - v Forward frame to
  483. * 1. Control interface
  484. * v - Forward frame to
  485. * 1. Flooding list of interfaces
  486. * - - Forward frame to
  487. * 1. Control interface
  488. */
  489. enum dpsw_learning_mode {
  490. DPSW_LEARNING_MODE_DIS = 0,
  491. DPSW_LEARNING_MODE_HW = 1,
  492. DPSW_LEARNING_MODE_NON_SECURE = 2,
  493. DPSW_LEARNING_MODE_SECURE = 3
  494. };
  495. /**
  496. * struct dpsw_fdb_attr - FDB Attributes
  497. * @max_fdb_entries: Number of FDB entries
  498. * @fdb_ageing_time: Ageing time in seconds
  499. * @learning_mode: Learning mode
  500. * @num_fdb_mc_groups: Current number of multicast groups
  501. * @max_fdb_mc_groups: Maximum number of multicast groups
  502. */
  503. struct dpsw_fdb_attr {
  504. u16 max_fdb_entries;
  505. u16 fdb_ageing_time;
  506. enum dpsw_learning_mode learning_mode;
  507. u16 num_fdb_mc_groups;
  508. u16 max_fdb_mc_groups;
  509. };
  510. int dpsw_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags,
  511. u16 *major_ver, u16 *minor_ver);
  512. int dpsw_if_get_port_mac_addr(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  513. u16 if_id, u8 mac_addr[6]);
  514. /**
  515. * struct dpsw_fdb_cfg - FDB Configuration
  516. * @num_fdb_entries: Number of FDB entries
  517. * @fdb_ageing_time: Ageing time in seconds
  518. */
  519. struct dpsw_fdb_cfg {
  520. u16 num_fdb_entries;
  521. u16 fdb_ageing_time;
  522. };
  523. int dpsw_fdb_add(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 *fdb_id,
  524. const struct dpsw_fdb_cfg *cfg);
  525. int dpsw_fdb_remove(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 fdb_id);
  526. /**
  527. * enum dpsw_flood_type - Define the flood type of a DPSW object
  528. * @DPSW_BROADCAST: Broadcast flooding
  529. * @DPSW_FLOODING: Unknown flooding
  530. */
  531. enum dpsw_flood_type {
  532. DPSW_BROADCAST = 0,
  533. DPSW_FLOODING,
  534. };
  535. struct dpsw_egress_flood_cfg {
  536. u16 fdb_id;
  537. enum dpsw_flood_type flood_type;
  538. u16 num_ifs;
  539. u16 if_id[DPSW_MAX_IF];
  540. };
  541. int dpsw_set_egress_flood(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  542. const struct dpsw_egress_flood_cfg *cfg);
  543. int dpsw_if_set_learning_mode(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  544. u16 if_id, enum dpsw_learning_mode mode);
  545. /**
  546. * struct dpsw_acl_cfg - ACL Configuration
  547. * @max_entries: Number of ACL rules
  548. */
  549. struct dpsw_acl_cfg {
  550. u16 max_entries;
  551. };
  552. int dpsw_acl_add(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 *acl_id,
  553. const struct dpsw_acl_cfg *cfg);
  554. int dpsw_acl_remove(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  555. u16 acl_id);
  556. /**
  557. * struct dpsw_acl_if_cfg - List of interfaces to associate with an ACL table
  558. * @num_ifs: Number of interfaces
  559. * @if_id: List of interfaces
  560. */
  561. struct dpsw_acl_if_cfg {
  562. u16 num_ifs;
  563. u16 if_id[DPSW_MAX_IF];
  564. };
  565. int dpsw_acl_add_if(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  566. u16 acl_id, const struct dpsw_acl_if_cfg *cfg);
  567. int dpsw_acl_remove_if(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  568. u16 acl_id, const struct dpsw_acl_if_cfg *cfg);
  569. /**
  570. * struct dpsw_acl_fields - ACL fields.
  571. * @l2_dest_mac: Destination MAC address: BPDU, Multicast, Broadcast, Unicast,
  572. * slow protocols, MVRP, STP
  573. * @l2_source_mac: Source MAC address
  574. * @l2_tpid: Layer 2 (Ethernet) protocol type, used to identify the following
  575. * protocols: MPLS, PTP, PFC, ARP, Jumbo frames, LLDP, IEEE802.1ae,
  576. * Q-in-Q, IPv4, IPv6, PPPoE
  577. * @l2_pcp_dei: indicate which protocol is encapsulated in the payload
  578. * @l2_vlan_id: layer 2 VLAN ID
  579. * @l2_ether_type: layer 2 Ethernet type
  580. * @l3_dscp: Layer 3 differentiated services code point
  581. * @l3_protocol: Tells the Network layer at the destination host, to which
  582. * Protocol this packet belongs to. The following protocol are
  583. * supported: ICMP, IGMP, IPv4 (encapsulation), TCP, IPv6
  584. * (encapsulation), GRE, PTP
  585. * @l3_source_ip: Source IPv4 IP
  586. * @l3_dest_ip: Destination IPv4 IP
  587. * @l4_source_port: Source TCP/UDP Port
  588. * @l4_dest_port: Destination TCP/UDP Port
  589. */
  590. struct dpsw_acl_fields {
  591. u8 l2_dest_mac[6];
  592. u8 l2_source_mac[6];
  593. u16 l2_tpid;
  594. u8 l2_pcp_dei;
  595. u16 l2_vlan_id;
  596. u16 l2_ether_type;
  597. u8 l3_dscp;
  598. u8 l3_protocol;
  599. u32 l3_source_ip;
  600. u32 l3_dest_ip;
  601. u16 l4_source_port;
  602. u16 l4_dest_port;
  603. };
  604. /**
  605. * struct dpsw_acl_key - ACL key
  606. * @match: Match fields
  607. * @mask: Mask: b'1 - valid, b'0 don't care
  608. */
  609. struct dpsw_acl_key {
  610. struct dpsw_acl_fields match;
  611. struct dpsw_acl_fields mask;
  612. };
  613. /**
  614. * enum dpsw_acl_action - action to be run on the ACL rule match
  615. * @DPSW_ACL_ACTION_DROP: Drop frame
  616. * @DPSW_ACL_ACTION_REDIRECT: Redirect to certain port
  617. * @DPSW_ACL_ACTION_ACCEPT: Accept frame
  618. * @DPSW_ACL_ACTION_REDIRECT_TO_CTRL_IF: Redirect to control interface
  619. */
  620. enum dpsw_acl_action {
  621. DPSW_ACL_ACTION_DROP,
  622. DPSW_ACL_ACTION_REDIRECT,
  623. DPSW_ACL_ACTION_ACCEPT,
  624. DPSW_ACL_ACTION_REDIRECT_TO_CTRL_IF
  625. };
  626. /**
  627. * struct dpsw_acl_result - ACL action
  628. * @action: Action should be taken when ACL entry hit
  629. * @if_id: Interface IDs to redirect frame. Valid only if redirect selected for
  630. * action
  631. */
  632. struct dpsw_acl_result {
  633. enum dpsw_acl_action action;
  634. u16 if_id;
  635. };
  636. /**
  637. * struct dpsw_acl_entry_cfg - ACL entry
  638. * @key_iova: I/O virtual address of DMA-able memory filled with key after call
  639. * to dpsw_acl_prepare_entry_cfg()
  640. * @result: Required action when entry hit occurs
  641. * @precedence: Precedence inside ACL 0 is lowest; This priority can not change
  642. * during the lifetime of a Policy. It is user responsibility to
  643. * space the priorities according to consequent rule additions.
  644. */
  645. struct dpsw_acl_entry_cfg {
  646. u64 key_iova;
  647. struct dpsw_acl_result result;
  648. int precedence;
  649. };
  650. void dpsw_acl_prepare_entry_cfg(const struct dpsw_acl_key *key,
  651. u8 *entry_cfg_buf);
  652. int dpsw_acl_add_entry(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  653. u16 acl_id, const struct dpsw_acl_entry_cfg *cfg);
  654. int dpsw_acl_remove_entry(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  655. u16 acl_id, const struct dpsw_acl_entry_cfg *cfg);
  656. /**
  657. * enum dpsw_reflection_filter - Filter type for frames to be reflected
  658. * @DPSW_REFLECTION_FILTER_INGRESS_ALL: Reflect all frames
  659. * @DPSW_REFLECTION_FILTER_INGRESS_VLAN: Reflect only frames that belong to
  660. * the particular VLAN defined by vid parameter
  661. *
  662. */
  663. enum dpsw_reflection_filter {
  664. DPSW_REFLECTION_FILTER_INGRESS_ALL = 0,
  665. DPSW_REFLECTION_FILTER_INGRESS_VLAN = 1
  666. };
  667. /**
  668. * struct dpsw_reflection_cfg - Structure representing the mirroring config
  669. * @filter: Filter type for frames to be mirrored
  670. * @vlan_id: VLAN ID to mirror; valid only when the type is DPSW_INGRESS_VLAN
  671. */
  672. struct dpsw_reflection_cfg {
  673. enum dpsw_reflection_filter filter;
  674. u16 vlan_id;
  675. };
  676. int dpsw_set_reflection_if(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  677. u16 if_id);
  678. int dpsw_if_add_reflection(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  679. u16 if_id, const struct dpsw_reflection_cfg *cfg);
  680. int dpsw_if_remove_reflection(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  681. u16 if_id, const struct dpsw_reflection_cfg *cfg);
  682. #endif /* __FSL_DPSW_H */