dpni.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110
  1. /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
  2. /* Copyright 2013-2016 Freescale Semiconductor Inc.
  3. * Copyright 2016 NXP
  4. * Copyright 2020 NXP
  5. */
  6. #ifndef __FSL_DPNI_H
  7. #define __FSL_DPNI_H
  8. #include "dpkg.h"
  9. struct fsl_mc_io;
  10. /* Data Path Network Interface API
  11. * Contains initialization APIs and runtime control APIs for DPNI
  12. */
  13. /** General DPNI macros */
  14. /**
  15. * DPNI_MAX_TC - Maximum number of traffic classes
  16. */
  17. #define DPNI_MAX_TC 8
  18. /**
  19. * DPNI_MAX_DPBP - Maximum number of buffer pools per DPNI
  20. */
  21. #define DPNI_MAX_DPBP 8
  22. /**
  23. * DPNI_ALL_TCS - All traffic classes considered; see dpni_set_queue()
  24. */
  25. #define DPNI_ALL_TCS (u8)(-1)
  26. /**
  27. * DPNI_ALL_TC_FLOWS - All flows within traffic class considered; see
  28. * dpni_set_queue()
  29. */
  30. #define DPNI_ALL_TC_FLOWS (u16)(-1)
  31. /**
  32. * DPNI_NEW_FLOW_ID - Generate new flow ID; see dpni_set_queue()
  33. */
  34. #define DPNI_NEW_FLOW_ID (u16)(-1)
  35. /**
  36. * DPNI_OPT_TX_FRM_RELEASE - Tx traffic is always released to a buffer pool on
  37. * transmit, there are no resources allocated to have the frames confirmed back
  38. * to the source after transmission.
  39. */
  40. #define DPNI_OPT_TX_FRM_RELEASE 0x000001
  41. /**
  42. * DPNI_OPT_NO_MAC_FILTER - Disables support for MAC address filtering for
  43. * addresses other than primary MAC address. This affects both unicast and
  44. * multicast. Promiscuous mode can still be enabled/disabled for both unicast
  45. * and multicast. If promiscuous mode is disabled, only traffic matching the
  46. * primary MAC address will be accepted.
  47. */
  48. #define DPNI_OPT_NO_MAC_FILTER 0x000002
  49. /**
  50. * DPNI_OPT_HAS_POLICING - Allocate policers for this DPNI. They can be used to
  51. * rate-limit traffic per traffic class (TC) basis.
  52. */
  53. #define DPNI_OPT_HAS_POLICING 0x000004
  54. /**
  55. * DPNI_OPT_SHARED_CONGESTION - Congestion can be managed in several ways,
  56. * allowing the buffer pool to deplete on ingress, taildrop on each queue or
  57. * use congestion groups for sets of queues. If set, it configures a single
  58. * congestion groups across all TCs. If reset, a congestion group is allocated
  59. * for each TC. Only relevant if the DPNI has multiple traffic classes.
  60. */
  61. #define DPNI_OPT_SHARED_CONGESTION 0x000008
  62. /**
  63. * DPNI_OPT_HAS_KEY_MASKING - Enables TCAM for Flow Steering and QoS look-ups.
  64. * If not specified, all look-ups are exact match. Note that TCAM is not
  65. * available on LS1088 and its variants. Setting this bit on these SoCs will
  66. * trigger an error.
  67. */
  68. #define DPNI_OPT_HAS_KEY_MASKING 0x000010
  69. /**
  70. * DPNI_OPT_NO_FS - Disables the flow steering table.
  71. */
  72. #define DPNI_OPT_NO_FS 0x000020
  73. /**
  74. * DPNI_OPT_SHARED_FS - Flow steering table is shared between all traffic
  75. * classes
  76. */
  77. #define DPNI_OPT_SHARED_FS 0x001000
  78. int dpni_open(struct fsl_mc_io *mc_io,
  79. u32 cmd_flags,
  80. int dpni_id,
  81. u16 *token);
  82. int dpni_close(struct fsl_mc_io *mc_io,
  83. u32 cmd_flags,
  84. u16 token);
  85. /**
  86. * struct dpni_pools_cfg - Structure representing buffer pools configuration
  87. * @num_dpbp: Number of DPBPs
  88. * @pools: Array of buffer pools parameters; The number of valid entries
  89. * must match 'num_dpbp' value
  90. * @pools.dpbp_id: DPBP object ID
  91. * @pools.buffer_size: Buffer size
  92. * @pools.backup_pool: Backup pool
  93. */
  94. struct dpni_pools_cfg {
  95. u8 num_dpbp;
  96. struct {
  97. int dpbp_id;
  98. u16 buffer_size;
  99. int backup_pool;
  100. } pools[DPNI_MAX_DPBP];
  101. };
  102. int dpni_set_pools(struct fsl_mc_io *mc_io,
  103. u32 cmd_flags,
  104. u16 token,
  105. const struct dpni_pools_cfg *cfg);
  106. int dpni_enable(struct fsl_mc_io *mc_io,
  107. u32 cmd_flags,
  108. u16 token);
  109. int dpni_disable(struct fsl_mc_io *mc_io,
  110. u32 cmd_flags,
  111. u16 token);
  112. int dpni_is_enabled(struct fsl_mc_io *mc_io,
  113. u32 cmd_flags,
  114. u16 token,
  115. int *en);
  116. int dpni_reset(struct fsl_mc_io *mc_io,
  117. u32 cmd_flags,
  118. u16 token);
  119. /* DPNI IRQ Index and Events */
  120. #define DPNI_IRQ_INDEX 0
  121. /* DPNI_IRQ_EVENT_LINK_CHANGED - indicates a change in link state */
  122. #define DPNI_IRQ_EVENT_LINK_CHANGED 0x00000001
  123. /* DPNI_IRQ_EVENT_ENDPOINT_CHANGED - indicates a change in endpoint */
  124. #define DPNI_IRQ_EVENT_ENDPOINT_CHANGED 0x00000002
  125. int dpni_set_irq_enable(struct fsl_mc_io *mc_io,
  126. u32 cmd_flags,
  127. u16 token,
  128. u8 irq_index,
  129. u8 en);
  130. int dpni_get_irq_enable(struct fsl_mc_io *mc_io,
  131. u32 cmd_flags,
  132. u16 token,
  133. u8 irq_index,
  134. u8 *en);
  135. int dpni_set_irq_mask(struct fsl_mc_io *mc_io,
  136. u32 cmd_flags,
  137. u16 token,
  138. u8 irq_index,
  139. u32 mask);
  140. int dpni_get_irq_mask(struct fsl_mc_io *mc_io,
  141. u32 cmd_flags,
  142. u16 token,
  143. u8 irq_index,
  144. u32 *mask);
  145. int dpni_get_irq_status(struct fsl_mc_io *mc_io,
  146. u32 cmd_flags,
  147. u16 token,
  148. u8 irq_index,
  149. u32 *status);
  150. int dpni_clear_irq_status(struct fsl_mc_io *mc_io,
  151. u32 cmd_flags,
  152. u16 token,
  153. u8 irq_index,
  154. u32 status);
  155. /**
  156. * struct dpni_attr - Structure representing DPNI attributes
  157. * @options: Any combination of the following options:
  158. * DPNI_OPT_TX_FRM_RELEASE
  159. * DPNI_OPT_NO_MAC_FILTER
  160. * DPNI_OPT_HAS_POLICING
  161. * DPNI_OPT_SHARED_CONGESTION
  162. * DPNI_OPT_HAS_KEY_MASKING
  163. * DPNI_OPT_NO_FS
  164. * @num_queues: Number of Tx and Rx queues used for traffic distribution.
  165. * @num_tcs: Number of traffic classes (TCs), reserved for the DPNI.
  166. * @mac_filter_entries: Number of entries in the MAC address filtering table.
  167. * @vlan_filter_entries: Number of entries in the VLAN address filtering table.
  168. * @qos_entries: Number of entries in the QoS classification table.
  169. * @fs_entries: Number of entries in the flow steering table.
  170. * @qos_key_size: Size, in bytes, of the QoS look-up key. Defining a key larger
  171. * than this when adding QoS entries will result in an error.
  172. * @fs_key_size: Size, in bytes, of the flow steering look-up key. Defining a
  173. * key larger than this when composing the hash + FS key will
  174. * result in an error.
  175. * @wriop_version: Version of WRIOP HW block. The 3 version values are stored
  176. * on 6, 5, 5 bits respectively.
  177. */
  178. struct dpni_attr {
  179. u32 options;
  180. u8 num_queues;
  181. u8 num_tcs;
  182. u8 mac_filter_entries;
  183. u8 vlan_filter_entries;
  184. u8 qos_entries;
  185. u16 fs_entries;
  186. u8 qos_key_size;
  187. u8 fs_key_size;
  188. u16 wriop_version;
  189. };
  190. int dpni_get_attributes(struct fsl_mc_io *mc_io,
  191. u32 cmd_flags,
  192. u16 token,
  193. struct dpni_attr *attr);
  194. /* DPNI errors */
  195. /**
  196. * DPNI_ERROR_EOFHE - Extract out of frame header error
  197. */
  198. #define DPNI_ERROR_EOFHE 0x00020000
  199. /**
  200. * DPNI_ERROR_FLE - Frame length error
  201. */
  202. #define DPNI_ERROR_FLE 0x00002000
  203. /**
  204. * DPNI_ERROR_FPE - Frame physical error
  205. */
  206. #define DPNI_ERROR_FPE 0x00001000
  207. /**
  208. * DPNI_ERROR_PHE - Parsing header error
  209. */
  210. #define DPNI_ERROR_PHE 0x00000020
  211. /**
  212. * DPNI_ERROR_L3CE - Parser L3 checksum error
  213. */
  214. #define DPNI_ERROR_L3CE 0x00000004
  215. /**
  216. * DPNI_ERROR_L4CE - Parser L3 checksum error
  217. */
  218. #define DPNI_ERROR_L4CE 0x00000001
  219. /**
  220. * enum dpni_error_action - Defines DPNI behavior for errors
  221. * @DPNI_ERROR_ACTION_DISCARD: Discard the frame
  222. * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow
  223. * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue
  224. */
  225. enum dpni_error_action {
  226. DPNI_ERROR_ACTION_DISCARD = 0,
  227. DPNI_ERROR_ACTION_CONTINUE = 1,
  228. DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE = 2
  229. };
  230. /**
  231. * struct dpni_error_cfg - Structure representing DPNI errors treatment
  232. * @errors: Errors mask; use 'DPNI_ERROR__<X>
  233. * @error_action: The desired action for the errors mask
  234. * @set_frame_annotation: Set to '1' to mark the errors in frame annotation
  235. * status (FAS); relevant only for the non-discard action
  236. */
  237. struct dpni_error_cfg {
  238. u32 errors;
  239. enum dpni_error_action error_action;
  240. int set_frame_annotation;
  241. };
  242. int dpni_set_errors_behavior(struct fsl_mc_io *mc_io,
  243. u32 cmd_flags,
  244. u16 token,
  245. struct dpni_error_cfg *cfg);
  246. /* DPNI buffer layout modification options */
  247. /**
  248. * DPNI_BUF_LAYOUT_OPT_TIMESTAMP - Select to modify the time-stamp setting
  249. */
  250. #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP 0x00000001
  251. /**
  252. * DPNI_BUF_LAYOUT_OPT_PARSER_RESULT - Select to modify the parser-result
  253. * setting; not applicable for Tx
  254. */
  255. #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT 0x00000002
  256. /**
  257. * DPNI_BUF_LAYOUT_OPT_FRAME_STATUS - Select to modify the frame-status setting
  258. */
  259. #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS 0x00000004
  260. /**
  261. * DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE - Select to modify the private-data-size setting
  262. */
  263. #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE 0x00000008
  264. /**
  265. * DPNI_BUF_LAYOUT_OPT_DATA_ALIGN - Select to modify the data-alignment setting
  266. */
  267. #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN 0x00000010
  268. /**
  269. * DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM - Select to modify the data-head-room setting
  270. */
  271. #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM 0x00000020
  272. /**
  273. * DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM - Select to modify the data-tail-room setting
  274. */
  275. #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM 0x00000040
  276. /**
  277. * struct dpni_buffer_layout - Structure representing DPNI buffer layout
  278. * @options: Flags representing the suggested modifications to the buffer
  279. * layout; Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
  280. * @pass_timestamp: Pass timestamp value
  281. * @pass_parser_result: Pass parser results
  282. * @pass_frame_status: Pass frame status
  283. * @private_data_size: Size kept for private data (in bytes)
  284. * @data_align: Data alignment
  285. * @data_head_room: Data head room
  286. * @data_tail_room: Data tail room
  287. */
  288. struct dpni_buffer_layout {
  289. u32 options;
  290. int pass_timestamp;
  291. int pass_parser_result;
  292. int pass_frame_status;
  293. u16 private_data_size;
  294. u16 data_align;
  295. u16 data_head_room;
  296. u16 data_tail_room;
  297. };
  298. /**
  299. * enum dpni_queue_type - Identifies a type of queue targeted by the command
  300. * @DPNI_QUEUE_RX: Rx queue
  301. * @DPNI_QUEUE_TX: Tx queue
  302. * @DPNI_QUEUE_TX_CONFIRM: Tx confirmation queue
  303. * @DPNI_QUEUE_RX_ERR: Rx error queue
  304. */
  305. enum dpni_queue_type {
  306. DPNI_QUEUE_RX,
  307. DPNI_QUEUE_TX,
  308. DPNI_QUEUE_TX_CONFIRM,
  309. DPNI_QUEUE_RX_ERR,
  310. };
  311. int dpni_get_buffer_layout(struct fsl_mc_io *mc_io,
  312. u32 cmd_flags,
  313. u16 token,
  314. enum dpni_queue_type qtype,
  315. struct dpni_buffer_layout *layout);
  316. int dpni_set_buffer_layout(struct fsl_mc_io *mc_io,
  317. u32 cmd_flags,
  318. u16 token,
  319. enum dpni_queue_type qtype,
  320. const struct dpni_buffer_layout *layout);
  321. /**
  322. * enum dpni_offload - Identifies a type of offload targeted by the command
  323. * @DPNI_OFF_RX_L3_CSUM: Rx L3 checksum validation
  324. * @DPNI_OFF_RX_L4_CSUM: Rx L4 checksum validation
  325. * @DPNI_OFF_TX_L3_CSUM: Tx L3 checksum generation
  326. * @DPNI_OFF_TX_L4_CSUM: Tx L4 checksum generation
  327. */
  328. enum dpni_offload {
  329. DPNI_OFF_RX_L3_CSUM,
  330. DPNI_OFF_RX_L4_CSUM,
  331. DPNI_OFF_TX_L3_CSUM,
  332. DPNI_OFF_TX_L4_CSUM,
  333. };
  334. int dpni_set_offload(struct fsl_mc_io *mc_io,
  335. u32 cmd_flags,
  336. u16 token,
  337. enum dpni_offload type,
  338. u32 config);
  339. int dpni_get_offload(struct fsl_mc_io *mc_io,
  340. u32 cmd_flags,
  341. u16 token,
  342. enum dpni_offload type,
  343. u32 *config);
  344. int dpni_get_qdid(struct fsl_mc_io *mc_io,
  345. u32 cmd_flags,
  346. u16 token,
  347. enum dpni_queue_type qtype,
  348. u16 *qdid);
  349. int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
  350. u32 cmd_flags,
  351. u16 token,
  352. u16 *data_offset);
  353. #define DPNI_STATISTICS_CNT 7
  354. /**
  355. * union dpni_statistics - Union describing the DPNI statistics
  356. * @page_0: Page_0 statistics structure
  357. * @page_0.ingress_all_frames: Ingress frame count
  358. * @page_0.ingress_all_bytes: Ingress byte count
  359. * @page_0.ingress_multicast_frames: Ingress multicast frame count
  360. * @page_0.ingress_multicast_bytes: Ingress multicast byte count
  361. * @page_0.ingress_broadcast_frames: Ingress broadcast frame count
  362. * @page_0.ingress_broadcast_bytes: Ingress broadcast byte count
  363. * @page_1: Page_1 statistics structure
  364. * @page_1.egress_all_frames: Egress frame count
  365. * @page_1.egress_all_bytes: Egress byte count
  366. * @page_1.egress_multicast_frames: Egress multicast frame count
  367. * @page_1.egress_multicast_bytes: Egress multicast byte count
  368. * @page_1.egress_broadcast_frames: Egress broadcast frame count
  369. * @page_1.egress_broadcast_bytes: Egress broadcast byte count
  370. * @page_2: Page_2 statistics structure
  371. * @page_2.ingress_filtered_frames: Ingress filtered frame count
  372. * @page_2.ingress_discarded_frames: Ingress discarded frame count
  373. * @page_2.ingress_nobuffer_discards: Ingress discarded frame count due to
  374. * lack of buffers
  375. * @page_2.egress_discarded_frames: Egress discarded frame count
  376. * @page_2.egress_confirmed_frames: Egress confirmed frame count
  377. * @page_3: Page_3 statistics structure
  378. * @page_3.egress_dequeue_bytes: Cumulative count of the number of bytes
  379. * dequeued from egress FQs
  380. * @page_3.egress_dequeue_frames: Cumulative count of the number of frames
  381. * dequeued from egress FQs
  382. * @page_3.egress_reject_bytes: Cumulative count of the number of bytes in
  383. * egress frames whose enqueue was rejected
  384. * @page_3.egress_reject_frames: Cumulative count of the number of egress
  385. * frames whose enqueue was rejected
  386. * @page_4: Page_4 statistics structure: congestion points
  387. * @page_4.cgr_reject_frames: number of rejected frames due to congestion point
  388. * @page_4.cgr_reject_bytes: number of rejected bytes due to congestion point
  389. * @page_5: Page_5 statistics structure: policer
  390. * @page_5.policer_cnt_red: NUmber of red colored frames
  391. * @page_5.policer_cnt_yellow: number of yellow colored frames
  392. * @page_5.policer_cnt_green: number of green colored frames
  393. * @page_5.policer_cnt_re_red: number of recolored red frames
  394. * @page_5.policer_cnt_re_yellow: number of recolored yellow frames
  395. * @page_6: Page_6 statistics structure
  396. * @page_6.tx_pending_frames: total number of frames pending in egress FQs
  397. * @raw: raw statistics structure, used to index counters
  398. */
  399. union dpni_statistics {
  400. struct {
  401. u64 ingress_all_frames;
  402. u64 ingress_all_bytes;
  403. u64 ingress_multicast_frames;
  404. u64 ingress_multicast_bytes;
  405. u64 ingress_broadcast_frames;
  406. u64 ingress_broadcast_bytes;
  407. } page_0;
  408. struct {
  409. u64 egress_all_frames;
  410. u64 egress_all_bytes;
  411. u64 egress_multicast_frames;
  412. u64 egress_multicast_bytes;
  413. u64 egress_broadcast_frames;
  414. u64 egress_broadcast_bytes;
  415. } page_1;
  416. struct {
  417. u64 ingress_filtered_frames;
  418. u64 ingress_discarded_frames;
  419. u64 ingress_nobuffer_discards;
  420. u64 egress_discarded_frames;
  421. u64 egress_confirmed_frames;
  422. } page_2;
  423. struct {
  424. u64 egress_dequeue_bytes;
  425. u64 egress_dequeue_frames;
  426. u64 egress_reject_bytes;
  427. u64 egress_reject_frames;
  428. } page_3;
  429. struct {
  430. u64 cgr_reject_frames;
  431. u64 cgr_reject_bytes;
  432. } page_4;
  433. struct {
  434. u64 policer_cnt_red;
  435. u64 policer_cnt_yellow;
  436. u64 policer_cnt_green;
  437. u64 policer_cnt_re_red;
  438. u64 policer_cnt_re_yellow;
  439. } page_5;
  440. struct {
  441. u64 tx_pending_frames;
  442. } page_6;
  443. struct {
  444. u64 counter[DPNI_STATISTICS_CNT];
  445. } raw;
  446. };
  447. int dpni_get_statistics(struct fsl_mc_io *mc_io,
  448. u32 cmd_flags,
  449. u16 token,
  450. u8 page,
  451. union dpni_statistics *stat);
  452. #define DPNI_LINK_OPT_AUTONEG 0x0000000000000001ULL
  453. #define DPNI_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
  454. #define DPNI_LINK_OPT_PAUSE 0x0000000000000004ULL
  455. #define DPNI_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
  456. #define DPNI_LINK_OPT_PFC_PAUSE 0x0000000000000010ULL
  457. /**
  458. * struct dpni_link_cfg - Structure representing DPNI link configuration
  459. * @rate: Rate
  460. * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
  461. */
  462. struct dpni_link_cfg {
  463. u32 rate;
  464. u64 options;
  465. };
  466. int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
  467. u32 cmd_flags,
  468. u16 token,
  469. const struct dpni_link_cfg *cfg);
  470. int dpni_get_link_cfg(struct fsl_mc_io *mc_io,
  471. u32 cmd_flags,
  472. u16 token,
  473. struct dpni_link_cfg *cfg);
  474. /**
  475. * struct dpni_link_state - Structure representing DPNI link state
  476. * @rate: Rate
  477. * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
  478. * @up: Link state; '0' for down, '1' for up
  479. */
  480. struct dpni_link_state {
  481. u32 rate;
  482. u64 options;
  483. int up;
  484. };
  485. int dpni_get_link_state(struct fsl_mc_io *mc_io,
  486. u32 cmd_flags,
  487. u16 token,
  488. struct dpni_link_state *state);
  489. int dpni_set_max_frame_length(struct fsl_mc_io *mc_io,
  490. u32 cmd_flags,
  491. u16 token,
  492. u16 max_frame_length);
  493. int dpni_get_max_frame_length(struct fsl_mc_io *mc_io,
  494. u32 cmd_flags,
  495. u16 token,
  496. u16 *max_frame_length);
  497. int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io,
  498. u32 cmd_flags,
  499. u16 token,
  500. int en);
  501. int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io,
  502. u32 cmd_flags,
  503. u16 token,
  504. int *en);
  505. int dpni_set_unicast_promisc(struct fsl_mc_io *mc_io,
  506. u32 cmd_flags,
  507. u16 token,
  508. int en);
  509. int dpni_get_unicast_promisc(struct fsl_mc_io *mc_io,
  510. u32 cmd_flags,
  511. u16 token,
  512. int *en);
  513. int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
  514. u32 cmd_flags,
  515. u16 token,
  516. const u8 mac_addr[6]);
  517. int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
  518. u32 cmd_flags,
  519. u16 token,
  520. u8 mac_addr[6]);
  521. int dpni_get_port_mac_addr(struct fsl_mc_io *mc_io,
  522. u32 cm_flags,
  523. u16 token,
  524. u8 mac_addr[6]);
  525. int dpni_add_mac_addr(struct fsl_mc_io *mc_io,
  526. u32 cmd_flags,
  527. u16 token,
  528. const u8 mac_addr[6]);
  529. int dpni_remove_mac_addr(struct fsl_mc_io *mc_io,
  530. u32 cmd_flags,
  531. u16 token,
  532. const u8 mac_addr[6]);
  533. int dpni_clear_mac_filters(struct fsl_mc_io *mc_io,
  534. u32 cmd_flags,
  535. u16 token,
  536. int unicast,
  537. int multicast);
  538. /**
  539. * enum dpni_dist_mode - DPNI distribution mode
  540. * @DPNI_DIST_MODE_NONE: No distribution
  541. * @DPNI_DIST_MODE_HASH: Use hash distribution; only relevant if
  542. * the 'DPNI_OPT_DIST_HASH' option was set at DPNI creation
  543. * @DPNI_DIST_MODE_FS: Use explicit flow steering; only relevant if
  544. * the 'DPNI_OPT_DIST_FS' option was set at DPNI creation
  545. */
  546. enum dpni_dist_mode {
  547. DPNI_DIST_MODE_NONE = 0,
  548. DPNI_DIST_MODE_HASH = 1,
  549. DPNI_DIST_MODE_FS = 2
  550. };
  551. /**
  552. * enum dpni_fs_miss_action - DPNI Flow Steering miss action
  553. * @DPNI_FS_MISS_DROP: In case of no-match, drop the frame
  554. * @DPNI_FS_MISS_EXPLICIT_FLOWID: In case of no-match, use explicit flow-id
  555. * @DPNI_FS_MISS_HASH: In case of no-match, distribute using hash
  556. */
  557. enum dpni_fs_miss_action {
  558. DPNI_FS_MISS_DROP = 0,
  559. DPNI_FS_MISS_EXPLICIT_FLOWID = 1,
  560. DPNI_FS_MISS_HASH = 2
  561. };
  562. /**
  563. * struct dpni_fs_tbl_cfg - Flow Steering table configuration
  564. * @miss_action: Miss action selection
  565. * @default_flow_id: Used when 'miss_action = DPNI_FS_MISS_EXPLICIT_FLOWID'
  566. */
  567. struct dpni_fs_tbl_cfg {
  568. enum dpni_fs_miss_action miss_action;
  569. u16 default_flow_id;
  570. };
  571. int dpni_prepare_key_cfg(const struct dpkg_profile_cfg *cfg,
  572. u8 *key_cfg_buf);
  573. /**
  574. * struct dpni_rx_tc_dist_cfg - Rx traffic class distribution configuration
  575. * @dist_size: Set the distribution size;
  576. * supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
  577. * 112,128,192,224,256,384,448,512,768,896,1024
  578. * @dist_mode: Distribution mode
  579. * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
  580. * the extractions to be used for the distribution key by calling
  581. * dpni_prepare_key_cfg() relevant only when
  582. * 'dist_mode != DPNI_DIST_MODE_NONE', otherwise it can be '0'
  583. * @fs_cfg: Flow Steering table configuration; only relevant if
  584. * 'dist_mode = DPNI_DIST_MODE_FS'
  585. */
  586. struct dpni_rx_tc_dist_cfg {
  587. u16 dist_size;
  588. enum dpni_dist_mode dist_mode;
  589. u64 key_cfg_iova;
  590. struct dpni_fs_tbl_cfg fs_cfg;
  591. };
  592. int dpni_set_rx_tc_dist(struct fsl_mc_io *mc_io,
  593. u32 cmd_flags,
  594. u16 token,
  595. u8 tc_id,
  596. const struct dpni_rx_tc_dist_cfg *cfg);
  597. /**
  598. * DPNI_FS_MISS_DROP - When used for fs_miss_flow_id in function
  599. * dpni_set_rx_dist, will signal to dpni to drop all unclassified frames
  600. */
  601. #define DPNI_FS_MISS_DROP ((uint16_t)-1)
  602. /**
  603. * struct dpni_rx_dist_cfg - Rx distribution configuration
  604. * @dist_size: distribution size
  605. * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
  606. * the extractions to be used for the distribution key by calling
  607. * dpni_prepare_key_cfg(); relevant only when enable!=0 otherwise
  608. * it can be '0'
  609. * @enable: enable/disable the distribution.
  610. * @tc: TC id for which distribution is set
  611. * @fs_miss_flow_id: when packet misses all rules from flow steering table and
  612. * hash is disabled it will be put into this queue id; use
  613. * DPNI_FS_MISS_DROP to drop frames. The value of this field is
  614. * used only when flow steering distribution is enabled and hash
  615. * distribution is disabled
  616. */
  617. struct dpni_rx_dist_cfg {
  618. u16 dist_size;
  619. u64 key_cfg_iova;
  620. u8 enable;
  621. u8 tc;
  622. u16 fs_miss_flow_id;
  623. };
  624. int dpni_set_rx_fs_dist(struct fsl_mc_io *mc_io,
  625. u32 cmd_flags,
  626. u16 token,
  627. const struct dpni_rx_dist_cfg *cfg);
  628. int dpni_set_rx_hash_dist(struct fsl_mc_io *mc_io,
  629. u32 cmd_flags,
  630. u16 token,
  631. const struct dpni_rx_dist_cfg *cfg);
  632. /**
  633. * struct dpni_qos_tbl_cfg - Structure representing QOS table configuration
  634. * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
  635. * key extractions to be used as the QoS criteria by calling
  636. * dpkg_prepare_key_cfg()
  637. * @discard_on_miss: Set to '1' to discard frames in case of no match (miss);
  638. * '0' to use the 'default_tc' in such cases
  639. * @default_tc: Used in case of no-match and 'discard_on_miss'= 0
  640. */
  641. struct dpni_qos_tbl_cfg {
  642. u64 key_cfg_iova;
  643. int discard_on_miss;
  644. u8 default_tc;
  645. };
  646. int dpni_set_qos_table(struct fsl_mc_io *mc_io,
  647. u32 cmd_flags,
  648. u16 token,
  649. const struct dpni_qos_tbl_cfg *cfg);
  650. /**
  651. * enum dpni_dest - DPNI destination types
  652. * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
  653. * does not generate FQDAN notifications; user is expected to
  654. * dequeue from the queue based on polling or other user-defined
  655. * method
  656. * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
  657. * notifications to the specified DPIO; user is expected to dequeue
  658. * from the queue only after notification is received
  659. * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
  660. * FQDAN notifications, but is connected to the specified DPCON
  661. * object; user is expected to dequeue from the DPCON channel
  662. */
  663. enum dpni_dest {
  664. DPNI_DEST_NONE = 0,
  665. DPNI_DEST_DPIO = 1,
  666. DPNI_DEST_DPCON = 2
  667. };
  668. /**
  669. * struct dpni_queue - Queue structure
  670. * @destination: - Destination structure
  671. * @destination.id: ID of the destination, only relevant if DEST_TYPE is > 0.
  672. * Identifies either a DPIO or a DPCON object.
  673. * Not relevant for Tx queues.
  674. * @destination.type: May be one of the following:
  675. * 0 - No destination, queue can be manually
  676. * queried, but will not push traffic or
  677. * notifications to a DPIO;
  678. * 1 - The destination is a DPIO. When traffic
  679. * becomes available in the queue a FQDAN
  680. * (FQ data available notification) will be
  681. * generated to selected DPIO;
  682. * 2 - The destination is a DPCON. The queue is
  683. * associated with a DPCON object for the
  684. * purpose of scheduling between multiple
  685. * queues. The DPCON may be independently
  686. * configured to generate notifications.
  687. * Not relevant for Tx queues.
  688. * @destination.hold_active: Hold active, maintains a queue scheduled for longer
  689. * in a DPIO during dequeue to reduce spread of traffic.
  690. * Only relevant if queues are
  691. * not affined to a single DPIO.
  692. * @user_context: User data, presented to the user along with any frames
  693. * from this queue. Not relevant for Tx queues.
  694. * @flc: FD FLow Context structure
  695. * @flc.value: Default FLC value for traffic dequeued from
  696. * this queue. Please check description of FD
  697. * structure for more information.
  698. * Note that FLC values set using dpni_add_fs_entry,
  699. * if any, take precedence over values per queue.
  700. * @flc.stash_control: Boolean, indicates whether the 6 lowest
  701. * - significant bits are used for stash control.
  702. * significant bits are used for stash control. If set, the 6
  703. * least significant bits in value are interpreted as follows:
  704. * - bits 0-1: indicates the number of 64 byte units of context
  705. * that are stashed. FLC value is interpreted as a memory address
  706. * in this case, excluding the 6 LS bits.
  707. * - bits 2-3: indicates the number of 64 byte units of frame
  708. * annotation to be stashed. Annotation is placed at FD[ADDR].
  709. * - bits 4-5: indicates the number of 64 byte units of frame
  710. * data to be stashed. Frame data is placed at FD[ADDR] +
  711. * FD[OFFSET].
  712. * For more details check the Frame Descriptor section in the
  713. * hardware documentation.
  714. */
  715. struct dpni_queue {
  716. struct {
  717. u16 id;
  718. enum dpni_dest type;
  719. char hold_active;
  720. u8 priority;
  721. } destination;
  722. u64 user_context;
  723. struct {
  724. u64 value;
  725. char stash_control;
  726. } flc;
  727. };
  728. /**
  729. * struct dpni_queue_id - Queue identification, used for enqueue commands
  730. * or queue control
  731. * @fqid: FQID used for enqueueing to and/or configuration of this specific FQ
  732. * @qdbin: Queueing bin, used to enqueue using QDID, DQBIN, QPRI. Only relevant
  733. * for Tx queues.
  734. */
  735. struct dpni_queue_id {
  736. u32 fqid;
  737. u16 qdbin;
  738. };
  739. /* Set User Context */
  740. #define DPNI_QUEUE_OPT_USER_CTX 0x00000001
  741. #define DPNI_QUEUE_OPT_DEST 0x00000002
  742. #define DPNI_QUEUE_OPT_FLC 0x00000004
  743. #define DPNI_QUEUE_OPT_HOLD_ACTIVE 0x00000008
  744. int dpni_set_queue(struct fsl_mc_io *mc_io,
  745. u32 cmd_flags,
  746. u16 token,
  747. enum dpni_queue_type qtype,
  748. u8 tc,
  749. u8 index,
  750. u8 options,
  751. const struct dpni_queue *queue);
  752. int dpni_get_queue(struct fsl_mc_io *mc_io,
  753. u32 cmd_flags,
  754. u16 token,
  755. enum dpni_queue_type qtype,
  756. u8 tc,
  757. u8 index,
  758. struct dpni_queue *queue,
  759. struct dpni_queue_id *qid);
  760. /**
  761. * enum dpni_congestion_unit - DPNI congestion units
  762. * @DPNI_CONGESTION_UNIT_BYTES: bytes units
  763. * @DPNI_CONGESTION_UNIT_FRAMES: frames units
  764. */
  765. enum dpni_congestion_unit {
  766. DPNI_CONGESTION_UNIT_BYTES = 0,
  767. DPNI_CONGESTION_UNIT_FRAMES
  768. };
  769. /**
  770. * enum dpni_congestion_point - Structure representing congestion point
  771. * @DPNI_CP_QUEUE: Set taildrop per queue, identified by QUEUE_TYPE, TC and
  772. * QUEUE_INDEX
  773. * @DPNI_CP_GROUP: Set taildrop per queue group. Depending on options used to
  774. * define the DPNI this can be either per TC (default) or per
  775. * interface (DPNI_OPT_SHARED_CONGESTION set at DPNI create).
  776. * QUEUE_INDEX is ignored if this type is used.
  777. */
  778. enum dpni_congestion_point {
  779. DPNI_CP_QUEUE,
  780. DPNI_CP_GROUP,
  781. };
  782. /**
  783. * struct dpni_dest_cfg - Structure representing DPNI destination parameters
  784. * @dest_type: Destination type
  785. * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
  786. * @priority: Priority selection within the DPIO or DPCON channel; valid
  787. * values are 0-1 or 0-7, depending on the number of priorities
  788. * in that channel; not relevant for 'DPNI_DEST_NONE' option
  789. */
  790. struct dpni_dest_cfg {
  791. enum dpni_dest dest_type;
  792. int dest_id;
  793. u8 priority;
  794. };
  795. /* DPNI congestion options */
  796. /**
  797. * DPNI_CONG_OPT_FLOW_CONTROL - This congestion will trigger flow control or
  798. * priority flow control. This will have effect only if flow control is
  799. * enabled with dpni_set_link_cfg().
  800. */
  801. #define DPNI_CONG_OPT_FLOW_CONTROL 0x00000040
  802. /**
  803. * struct dpni_congestion_notification_cfg - congestion notification
  804. * configuration
  805. * @units: Units type
  806. * @threshold_entry: Above this threshold we enter a congestion state.
  807. * set it to '0' to disable it
  808. * @threshold_exit: Below this threshold we exit the congestion state.
  809. * @message_ctx: The context that will be part of the CSCN message
  810. * @message_iova: I/O virtual address (must be in DMA-able memory),
  811. * must be 16B aligned; valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>'
  812. * is contained in 'options'
  813. * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel
  814. * @notification_mode: Mask of available options; use 'DPNI_CONG_OPT_<X>' values
  815. */
  816. struct dpni_congestion_notification_cfg {
  817. enum dpni_congestion_unit units;
  818. u32 threshold_entry;
  819. u32 threshold_exit;
  820. u64 message_ctx;
  821. u64 message_iova;
  822. struct dpni_dest_cfg dest_cfg;
  823. u16 notification_mode;
  824. };
  825. int dpni_set_congestion_notification(
  826. struct fsl_mc_io *mc_io,
  827. u32 cmd_flags,
  828. u16 token,
  829. enum dpni_queue_type qtype,
  830. u8 tc_id,
  831. const struct dpni_congestion_notification_cfg *cfg);
  832. /**
  833. * struct dpni_taildrop - Structure representing the taildrop
  834. * @enable: Indicates whether the taildrop is active or not.
  835. * @units: Indicates the unit of THRESHOLD. Queue taildrop only supports
  836. * byte units, this field is ignored and assumed = 0 if
  837. * CONGESTION_POINT is 0.
  838. * @threshold: Threshold value, in units identified by UNITS field. Value 0
  839. * cannot be used as a valid taildrop threshold, THRESHOLD must
  840. * be > 0 if the taildrop is enabled.
  841. */
  842. struct dpni_taildrop {
  843. char enable;
  844. enum dpni_congestion_unit units;
  845. u32 threshold;
  846. };
  847. int dpni_set_taildrop(struct fsl_mc_io *mc_io,
  848. u32 cmd_flags,
  849. u16 token,
  850. enum dpni_congestion_point cg_point,
  851. enum dpni_queue_type q_type,
  852. u8 tc,
  853. u8 q_index,
  854. struct dpni_taildrop *taildrop);
  855. int dpni_get_taildrop(struct fsl_mc_io *mc_io,
  856. u32 cmd_flags,
  857. u16 token,
  858. enum dpni_congestion_point cg_point,
  859. enum dpni_queue_type q_type,
  860. u8 tc,
  861. u8 q_index,
  862. struct dpni_taildrop *taildrop);
  863. /**
  864. * struct dpni_rule_cfg - Rule configuration for table lookup
  865. * @key_iova: I/O virtual address of the key (must be in DMA-able memory)
  866. * @mask_iova: I/O virtual address of the mask (must be in DMA-able memory)
  867. * @key_size: key and mask size (in bytes)
  868. */
  869. struct dpni_rule_cfg {
  870. u64 key_iova;
  871. u64 mask_iova;
  872. u8 key_size;
  873. };
  874. /**
  875. * DPNI_FS_OPT_DISCARD - Discard matching traffic. If set, this takes
  876. * precedence over any other configuration and matching traffic is always
  877. * discarded.
  878. */
  879. #define DPNI_FS_OPT_DISCARD 0x1
  880. /**
  881. * DPNI_FS_OPT_SET_FLC - Set FLC value. If set, flc member of struct
  882. * dpni_fs_action_cfg is used to override the FLC value set per queue.
  883. * For more details check the Frame Descriptor section in the hardware
  884. * documentation.
  885. */
  886. #define DPNI_FS_OPT_SET_FLC 0x2
  887. /**
  888. * DPNI_FS_OPT_SET_STASH_CONTROL - Indicates whether the 6 lowest significant
  889. * bits of FLC are used for stash control. If set, the 6 least significant bits
  890. * in value are interpreted as follows:
  891. * - bits 0-1: indicates the number of 64 byte units of context that are
  892. * stashed. FLC value is interpreted as a memory address in this case,
  893. * excluding the 6 LS bits.
  894. * - bits 2-3: indicates the number of 64 byte units of frame annotation
  895. * to be stashed. Annotation is placed at FD[ADDR].
  896. * - bits 4-5: indicates the number of 64 byte units of frame data to be
  897. * stashed. Frame data is placed at FD[ADDR] + FD[OFFSET].
  898. * This flag is ignored if DPNI_FS_OPT_SET_FLC is not specified.
  899. */
  900. #define DPNI_FS_OPT_SET_STASH_CONTROL 0x4
  901. /**
  902. * struct dpni_fs_action_cfg - Action configuration for table look-up
  903. * @flc: FLC value for traffic matching this rule. Please check the
  904. * Frame Descriptor section in the hardware documentation for
  905. * more information.
  906. * @flow_id: Identifies the Rx queue used for matching traffic. Supported
  907. * values are in range 0 to num_queue-1.
  908. * @options: Any combination of DPNI_FS_OPT_ values.
  909. */
  910. struct dpni_fs_action_cfg {
  911. u64 flc;
  912. u16 flow_id;
  913. u16 options;
  914. };
  915. int dpni_add_fs_entry(struct fsl_mc_io *mc_io,
  916. u32 cmd_flags,
  917. u16 token,
  918. u8 tc_id,
  919. u16 index,
  920. const struct dpni_rule_cfg *cfg,
  921. const struct dpni_fs_action_cfg *action);
  922. int dpni_remove_fs_entry(struct fsl_mc_io *mc_io,
  923. u32 cmd_flags,
  924. u16 token,
  925. u8 tc_id,
  926. const struct dpni_rule_cfg *cfg);
  927. int dpni_add_qos_entry(struct fsl_mc_io *mc_io,
  928. u32 cmd_flags,
  929. u16 token,
  930. const struct dpni_rule_cfg *cfg,
  931. u8 tc_id,
  932. u16 index);
  933. int dpni_remove_qos_entry(struct fsl_mc_io *mc_io,
  934. u32 cmd_flags,
  935. u16 token,
  936. const struct dpni_rule_cfg *cfg);
  937. int dpni_clear_qos_table(struct fsl_mc_io *mc_io,
  938. u32 cmd_flags,
  939. u16 token);
  940. int dpni_get_api_version(struct fsl_mc_io *mc_io,
  941. u32 cmd_flags,
  942. u16 *major_ver,
  943. u16 *minor_ver);
  944. /**
  945. * struct dpni_tx_shaping_cfg - Structure representing DPNI tx shaping configuration
  946. * @rate_limit: Rate in Mbps
  947. * @max_burst_size: Burst size in bytes (up to 64KB)
  948. */
  949. struct dpni_tx_shaping_cfg {
  950. u32 rate_limit;
  951. u16 max_burst_size;
  952. };
  953. int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
  954. u32 cmd_flags,
  955. u16 token,
  956. const struct dpni_tx_shaping_cfg *tx_cr_shaper,
  957. const struct dpni_tx_shaping_cfg *tx_er_shaper,
  958. int coupled);
  959. /**
  960. * struct dpni_single_step_cfg - configure single step PTP (IEEE 1588)
  961. * @en: enable single step PTP. When enabled the PTPv1 functionality
  962. * will not work. If the field is zero, offset and ch_update
  963. * parameters will be ignored
  964. * @offset: start offset from the beginning of the frame where
  965. * timestamp field is found. The offset must respect all MAC
  966. * headers, VLAN tags and other protocol headers
  967. * @ch_update: when set UDP checksum will be updated inside packet
  968. * @peer_delay: For peer-to-peer transparent clocks add this value to the
  969. * correction field in addition to the transient time update.
  970. * The value expresses nanoseconds.
  971. * @ptp_onestep_reg_base: 1588 SINGLE_STEP register base address. This address
  972. * is used to update directly the register contents.
  973. * User has to create an address mapping for it.
  974. *
  975. *
  976. */
  977. struct dpni_single_step_cfg {
  978. u8 en;
  979. u8 ch_update;
  980. u16 offset;
  981. u32 peer_delay;
  982. u32 ptp_onestep_reg_base;
  983. };
  984. int dpni_set_single_step_cfg(struct fsl_mc_io *mc_io,
  985. u32 cmd_flags,
  986. u16 token,
  987. struct dpni_single_step_cfg *ptp_cfg);
  988. int dpni_get_single_step_cfg(struct fsl_mc_io *mc_io,
  989. u32 cmd_flags,
  990. u16 token,
  991. struct dpni_single_step_cfg *ptp_cfg);
  992. int dpni_enable_vlan_filter(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  993. u32 en);
  994. int dpni_add_vlan_id(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  995. u16 vlan_id, u8 flags, u8 tc_id, u8 flow_id);
  996. int dpni_remove_vlan_id(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  997. u16 vlan_id);
  998. #endif /* __FSL_DPNI_H */