xref: /dpdk/lib/pipeline/rte_swx_ctl.h (revision 719834a6849e1daf4a70ff7742bbcc3ae7e25607)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2020 Intel Corporation
3  */
4 #ifndef __INCLUDE_RTE_SWX_CTL_H__
5 #define __INCLUDE_RTE_SWX_CTL_H__
6 
7 /**
8  * @file
9  * RTE SWX Pipeline Control
10  */
11 
12 #include <stdint.h>
13 #include <stdio.h>
14 
15 #include <rte_compat.h>
16 #include <rte_meter.h>
17 
18 #include "rte_swx_port.h"
19 #include "rte_swx_table.h"
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 struct rte_swx_pipeline;
26 
27 /** Name size. */
28 #ifndef RTE_SWX_CTL_NAME_SIZE
29 #define RTE_SWX_CTL_NAME_SIZE 64
30 #endif
31 
32 /*
33  * Pipeline Query API.
34  */
35 
36 /** Pipeline info. */
37 struct rte_swx_ctl_pipeline_info {
38 	/** Pipeline name. */
39 	char name[RTE_SWX_CTL_NAME_SIZE];
40 
41 	/** Number of input ports. */
42 	uint32_t n_ports_in;
43 
44 	/** Number of input ports. */
45 	uint32_t n_ports_out;
46 
47 	/** Number of packet mirroring slots. */
48 	uint32_t n_mirroring_slots;
49 
50 	/** Number of packet mirroring sessions. */
51 	uint32_t n_mirroring_sessions;
52 
53 	/** Number of actions. */
54 	uint32_t n_actions;
55 
56 	/** Number of tables. */
57 	uint32_t n_tables;
58 
59 	/** Number of selector tables. */
60 	uint32_t n_selectors;
61 
62 	/** Number of learner tables. */
63 	uint32_t n_learners;
64 
65 	/** Number of register arrays. */
66 	uint32_t n_regarrays;
67 
68 	/** Number of meter arrays. */
69 	uint32_t n_metarrays;
70 
71 	/** Number of RSS objects. */
72 	uint32_t n_rss;
73 };
74 
75 /**
76  * Pipeline info get
77  *
78  * @param[in] p
79  *   Pipeline handle.
80  * @param[out] pipeline
81  *   Pipeline info.
82  * @return
83  *   0 on success or the following error codes otherwise:
84  *   -EINVAL: Invalid argument.
85  */
86 __rte_experimental
87 int
88 rte_swx_ctl_pipeline_info_get(struct rte_swx_pipeline *p,
89 			      struct rte_swx_ctl_pipeline_info *pipeline);
90 
91 /**
92  * Pipeline NUMA node get
93  *
94  * @param[in] p
95  *   Pipeline handle.
96  * @param[out] numa_node
97  *   Pipeline NUMA node.
98  * @return
99  *   0 on success or the following error codes otherwise:
100  *   -EINVAL: Invalid argument.
101  */
102 __rte_experimental
103 int
104 rte_swx_ctl_pipeline_numa_node_get(struct rte_swx_pipeline *p,
105 				   int *numa_node);
106 
107 /*
108  * Ports Query API.
109  */
110 
111 /**
112  * Input port statistics counters read
113  *
114  * @param[in] p
115  *   Pipeline handle.
116  * @param[in] port_id
117  *   Port ID (0 .. *n_ports_in* - 1).
118  * @param[out] stats
119  *   Input port stats.
120  * @return
121  *   0 on success or the following error codes otherwise:
122  *   -EINVAL: Invalid argument.
123  */
124 __rte_experimental
125 int
126 rte_swx_ctl_pipeline_port_in_stats_read(struct rte_swx_pipeline *p,
127 					uint32_t port_id,
128 					struct rte_swx_port_in_stats *stats);
129 
130 /**
131  * Output port statistics counters read
132  *
133  * @param[in] p
134  *   Pipeline handle.
135  * @param[in] port_id
136  *   Port ID (0 .. *n_ports_out* - 1).
137  * @param[out] stats
138  *   Output port stats.
139  * @return
140  *   0 on success or the following error codes otherwise:
141  *   -EINVAL: Invalid argument.
142  */
143 __rte_experimental
144 int
145 rte_swx_ctl_pipeline_port_out_stats_read(struct rte_swx_pipeline *p,
146 					 uint32_t port_id,
147 					 struct rte_swx_port_out_stats *stats);
148 
149 /*
150  * Action Query API.
151  */
152 
153 /** Action info. */
154 struct rte_swx_ctl_action_info {
155 	/** Action name. */
156 	char name[RTE_SWX_CTL_NAME_SIZE];
157 
158 	/** Number of action arguments. */
159 	uint32_t n_args;
160 };
161 
162 /**
163  * Action info get
164  *
165  * @param[in] p
166  *   Pipeline handle.
167  * @param[in] action_id
168  *   Action ID (0 .. *n_actions* - 1).
169  * @param[out] action
170  *   Action info.
171  * @return
172  *   0 on success or the following error codes otherwise:
173  *   -EINVAL: Invalid argument.
174  */
175 __rte_experimental
176 int
177 rte_swx_ctl_action_info_get(struct rte_swx_pipeline *p,
178 			    uint32_t action_id,
179 			    struct rte_swx_ctl_action_info *action);
180 
181 /** Action argument info. */
182 struct rte_swx_ctl_action_arg_info {
183 	/** Action argument name. */
184 	char name[RTE_SWX_CTL_NAME_SIZE];
185 
186 	/** Action argument size (in bits). */
187 	uint32_t n_bits;
188 
189 	/** Non-zero (true) when this action argument must be stored in the
190 	 * table in network byte order (NBO), zero when it must be stored in
191 	 * host byte order (HBO).
192 	 */
193 	int is_network_byte_order;
194 };
195 
196 /**
197  * Action argument info get
198  *
199  * @param[in] p
200  *   Pipeline handle.
201  * @param[in] action_id
202  *   Action ID (0 .. *n_actions* - 1).
203  * @param[in] action_arg_id
204  *   Action ID (0 .. *n_args* - 1).
205  * @param[out] action_arg
206  *   Action argument info.
207  * @return
208  *   0 on success or the following error codes otherwise:
209  *   -EINVAL: Invalid argument.
210  */
211 __rte_experimental
212 int
213 rte_swx_ctl_action_arg_info_get(struct rte_swx_pipeline *p,
214 				uint32_t action_id,
215 				uint32_t action_arg_id,
216 				struct rte_swx_ctl_action_arg_info *action_arg);
217 
218 /*
219  * Table Query API.
220  */
221 
222 /** Table info. */
223 struct rte_swx_ctl_table_info {
224 	/** Table name. */
225 	char name[RTE_SWX_CTL_NAME_SIZE];
226 
227 	/** Table creation arguments. */
228 	char args[RTE_SWX_CTL_NAME_SIZE];
229 
230 	/** Number of match fields. */
231 	uint32_t n_match_fields;
232 
233 	/** Number of actions. */
234 	uint32_t n_actions;
235 
236 	/** Non-zero (true) when the default action is constant, therefore it
237 	 * cannot be changed; zero (false) when the default action not constant,
238 	 * therefore it can be changed.
239 	 */
240 	int default_action_is_const;
241 
242 	/**  Hash function. */
243 	rte_swx_hash_func_t hash_func;
244 
245 	/** Table size parameter. */
246 	uint32_t size;
247 };
248 
249 /**
250  * Table info get
251  *
252  * @param[in] p
253  *   Pipeline handle.
254  * @param[in] table_id
255  *   Table ID (0 .. *n_tables* - 1).
256  * @param[out] table
257  *   Table info.
258  * @return
259  *   0 on success or the following error codes otherwise:
260  *   -EINVAL: Invalid argument.
261  */
262 __rte_experimental
263 int
264 rte_swx_ctl_table_info_get(struct rte_swx_pipeline *p,
265 			   uint32_t table_id,
266 			   struct rte_swx_ctl_table_info *table);
267 
268 /** Table match field info.
269  *
270  * If (n_bits, offset) are known for all the match fields of the table, then the
271  * table (key_offset, key_size, key_mask0) can be computed.
272  */
273 struct rte_swx_ctl_table_match_field_info {
274 	/** Match type of the current match field. */
275 	enum rte_swx_table_match_type match_type;
276 
277 	/** Non-zero (true) when the current match field is part of a registered
278 	 * header, zero (false) when it is part of the registered meta-data.
279 	 */
280 	int is_header;
281 
282 	/** Match field size (in bits). */
283 	uint32_t n_bits;
284 
285 	/** Match field offset within its parent struct (one of the headers or
286 	 * the meta-data).
287 	 */
288 	uint32_t offset;
289 };
290 
291 /**
292  * Table match field info get
293  *
294  * @param[in] p
295  *   Pipeline handle.
296  * @param[in] table_id
297  *   Table ID (0 .. *n_tables*).
298  * @param[in] match_field_id
299  *   Match field ID (0 .. *n_match_fields* - 1).
300  * @param[out] match_field
301  *   Table match field info.
302  * @return
303  *   0 on success or the following error codes otherwise:
304  *   -EINVAL: Invalid argument.
305  */
306 __rte_experimental
307 int
308 rte_swx_ctl_table_match_field_info_get(struct rte_swx_pipeline *p,
309 	uint32_t table_id,
310 	uint32_t match_field_id,
311 	struct rte_swx_ctl_table_match_field_info *match_field);
312 
313 /** Table action info. */
314 struct rte_swx_ctl_table_action_info {
315 	/** Action ID. */
316 	uint32_t action_id;
317 
318 	/**  When non-zero (true), the action can be assigned to regular table entries. */
319 	int action_is_for_table_entries;
320 
321 	/**  When non-zero (true), the action can be assigned to the table default entry. */
322 	int action_is_for_default_entry;
323 };
324 
325 /**
326  * Table action info get
327  *
328  * @param[in] p
329  *   Pipeline handle.
330  * @param[in] table_id
331  *   Table ID (0 .. *n_tables*).
332  * @param[in] table_action_id
333  *   Action index within the set of table actions (0 .. table n_actions - 1).
334  *   Not to be confused with the action ID, which works at the pipeline level
335  *   (0 .. pipeline n_actions - 1), which is precisely what this function
336  *   returns as part of *table_action*.
337  * @param[out] table_action
338  *   Table action info.
339  * @return
340  *   0 on success or the following error codes otherwise:
341  *   -EINVAL: Invalid argument.
342  */
343 __rte_experimental
344 int
345 rte_swx_ctl_table_action_info_get(struct rte_swx_pipeline *p,
346 	uint32_t table_id,
347 	uint32_t table_action_id,
348 	struct rte_swx_ctl_table_action_info *table_action);
349 
350 /**
351  * Table operations get
352  *
353  * @param[in] p
354  *   Pipeline handle.
355  * @param[in] table_id
356  *   Table ID (0 .. *n_tables*).
357  * @param[out] table_ops
358  *   Table operations. Only valid when function returns success and *is_stub* is
359  *   zero (false).
360  * @param[out] is_stub
361  *   A stub table is a table with no match fields. No "regular" table entries
362  *   (i.e. entries other than the default entry) can be added to such a table,
363  *   therefore the lookup operation always results in lookup miss. Non-zero
364  *   (true) when the current table is a stub table, zero (false) otherwise.
365  * @return
366  *   0 on success or the following error codes otherwise:
367  *   -EINVAL: Invalid argument.
368  */
369 __rte_experimental
370 int
371 rte_swx_ctl_table_ops_get(struct rte_swx_pipeline *p,
372 			  uint32_t table_id,
373 			  struct rte_swx_table_ops *table_ops,
374 			  int *is_stub);
375 
376 /** Table statistics. */
377 struct rte_swx_table_stats {
378 	/** Number of packets with lookup hit. */
379 	uint64_t n_pkts_hit;
380 
381 	/** Number of packets with lookup miss. */
382 	uint64_t n_pkts_miss;
383 
384 	/** Number of packets (with either lookup hit or miss) per pipeline
385 	 * action. Array of pipeline *n_actions* elements indexed by the
386 	 * pipeline-level *action_id*, therefore this array has the same size
387 	 * for all the tables within the same pipeline.
388 	 */
389 	uint64_t *n_pkts_action;
390 };
391 
392 /**
393  * Table statistics counters read
394  *
395  * @param[in] p
396  *   Pipeline handle.
397  * @param[in] table_name
398  *   Table name.
399  * @param[out] stats
400  *   Table stats. Must point to a pre-allocated structure. The *n_pkts_action*
401  *   field also needs to be pre-allocated as array of pipeline *n_actions*
402  *   elements. The pipeline actions that are not valid for the current table
403  *   have their associated *n_pkts_action* element always set to zero.
404  * @return
405  *   0 on success or the following error codes otherwise:
406  *   -EINVAL: Invalid argument.
407  */
408 __rte_experimental
409 int
410 rte_swx_ctl_pipeline_table_stats_read(struct rte_swx_pipeline *p,
411 				      const char *table_name,
412 				      struct rte_swx_table_stats *stats);
413 
414 /*
415  * Selector Table Query API.
416  */
417 
418 /** Selector info. */
419 struct rte_swx_ctl_selector_info {
420 	/** Selector table name. */
421 	char name[RTE_SWX_CTL_NAME_SIZE];
422 
423 	/** Number of selector fields. */
424 	uint32_t n_selector_fields;
425 
426 	/** Maximum number of groups. */
427 	uint32_t n_groups_max;
428 
429 	/** Maximum number of members per group. */
430 	uint32_t n_members_per_group_max;
431 };
432 
433 /**
434  * Selector table info get
435  *
436  * @param[in] p
437  *   Pipeline handle.
438  * @param[in] selector_id
439  *   Selector table ID (0 .. *n_selectors* - 1).
440  * @param[out] selector
441  *   Selector table info.
442  * @return
443  *   0 on success or the following error codes otherwise:
444  *   -EINVAL: Invalid argument.
445  */
446 __rte_experimental
447 int
448 rte_swx_ctl_selector_info_get(struct rte_swx_pipeline *p,
449 			      uint32_t selector_id,
450 			      struct rte_swx_ctl_selector_info *selector);
451 
452 /**
453  * Selector table "group ID" field info get
454  *
455  * @param[in] p
456  *   Pipeline handle.
457  * @param[in] selector_id
458  *   Selector table ID (0 .. *n_selectors*).
459  * @param[out] field
460  *   Selector table "group ID" field info.
461  * @return
462  *   0 on success or the following error codes otherwise:
463  *   -EINVAL: Invalid argument.
464  */
465 __rte_experimental
466 int
467 rte_swx_ctl_selector_group_id_field_info_get(struct rte_swx_pipeline *p,
468 					     uint32_t selector_id,
469 					     struct rte_swx_ctl_table_match_field_info *field);
470 
471 /**
472  * Sselector table selector field info get
473  *
474  * @param[in] p
475  *   Pipeline handle.
476  * @param[in] selector_id
477  *   Selector table ID (0 .. *n_selectors*).
478  * @param[in] selector_field_id
479  *   Selector table selector field ID (0 .. *n_selector_fields* - 1).
480  * @param[out] field
481  *   Selector table selector field info.
482  * @return
483  *   0 on success or the following error codes otherwise:
484  *   -EINVAL: Invalid argument.
485  */
486 __rte_experimental
487 int
488 rte_swx_ctl_selector_field_info_get(struct rte_swx_pipeline *p,
489 				    uint32_t selector_id,
490 				    uint32_t selector_field_id,
491 				    struct rte_swx_ctl_table_match_field_info *field);
492 
493 /**
494  * Selector table "member ID" field info get
495  *
496  * @param[in] p
497  *   Pipeline handle.
498  * @param[in] selector_id
499  *   Selector table ID (0 .. *n_selectors*).
500  * @param[out] field
501  *   Selector table "member ID" field info.
502  * @return
503  *   0 on success or the following error codes otherwise:
504  *   -EINVAL: Invalid argument.
505  */
506 __rte_experimental
507 int
508 rte_swx_ctl_selector_member_id_field_info_get(struct rte_swx_pipeline *p,
509 					      uint32_t selector_id,
510 					      struct rte_swx_ctl_table_match_field_info *field);
511 
512 /** Selector table statistics. */
513 struct rte_swx_pipeline_selector_stats {
514 	/** Number of packets. */
515 	uint64_t n_pkts;
516 };
517 
518 /**
519  * Selector table statistics counters read
520  *
521  * @param[in] p
522  *   Pipeline handle.
523  * @param[in] selector_name
524  *   Selector table name.
525  * @param[out] stats
526  *   Selector table stats. Must point to a pre-allocated structure.
527  * @return
528  *   0 on success or the following error codes otherwise:
529  *   -EINVAL: Invalid argument.
530  */
531 __rte_experimental
532 int
533 rte_swx_ctl_pipeline_selector_stats_read(struct rte_swx_pipeline *p,
534 					 const char *selector_name,
535 					 struct rte_swx_pipeline_selector_stats *stats);
536 
537 /*
538  * Learner Table Query API.
539  */
540 
541 /** Learner table info. */
542 struct rte_swx_ctl_learner_info {
543 	/** Learner table name. */
544 	char name[RTE_SWX_CTL_NAME_SIZE];
545 
546 	/** Number of match fields. */
547 	uint32_t n_match_fields;
548 
549 	/** Number of actions. */
550 	uint32_t n_actions;
551 
552 	/** Non-zero (true) when the default action is constant, therefore it
553 	 * cannot be changed; zero (false) when the default action not constant,
554 	 * therefore it can be changed.
555 	 */
556 	int default_action_is_const;
557 
558 	/** Learner table size parameter. */
559 	uint32_t size;
560 
561 	/** Number of possible key timeout values. */
562 	uint32_t n_key_timeouts;
563 };
564 
565 /**
566  * Learner table info get
567  *
568  * @param[in] p
569  *   Pipeline handle.
570  * @param[in] learner_id
571  *   Learner table ID (0 .. *n_learners* - 1).
572  * @param[out] learner
573  *   Learner table info.
574  * @return
575  *   0 on success or the following error codes otherwise:
576  *   -EINVAL: Invalid argument.
577  */
578 __rte_experimental
579 int
580 rte_swx_ctl_learner_info_get(struct rte_swx_pipeline *p,
581 			     uint32_t learner_id,
582 			     struct rte_swx_ctl_learner_info *learner);
583 
584 /**
585  * Learner table match field info get
586  *
587  * @param[in] p
588  *   Pipeline handle.
589  * @param[in] learner_id
590  *   Learner table ID (0 .. *n_learners* - 1).
591  * @param[in] match_field_id
592  *   Match field ID (0 .. *n_match_fields* - 1).
593  * @param[out] match_field
594  *   Learner table match field info.
595  * @return
596  *   0 on success or the following error codes otherwise:
597  *   -EINVAL: Invalid argument.
598  */
599 __rte_experimental
600 int
601 rte_swx_ctl_learner_match_field_info_get(struct rte_swx_pipeline *p,
602 					 uint32_t learner_id,
603 					 uint32_t match_field_id,
604 					 struct rte_swx_ctl_table_match_field_info *match_field);
605 
606 /**
607  * Learner table action info get
608  *
609  * @param[in] p
610  *   Pipeline handle.
611  * @param[in] learner_id
612  *   Learner table ID (0 .. *n_learners* - 1).
613  * @param[in] learner_action_id
614  *   Action index within the set of learner table actions (0 .. learner table n_actions - 1). Not
615  *   to be confused with the pipeline-leve action ID (0 .. pipeline n_actions - 1), which is
616  *   precisely what this function returns as part of the *learner_action*.
617  * @param[out] learner_action
618  *   Learner action info.
619  * @return
620  *   0 on success or the following error codes otherwise:
621  *   -EINVAL: Invalid argument.
622  */
623 __rte_experimental
624 int
625 rte_swx_ctl_learner_action_info_get(struct rte_swx_pipeline *p,
626 				    uint32_t learner_id,
627 				    uint32_t learner_action_id,
628 				    struct rte_swx_ctl_table_action_info *learner_action);
629 
630 /**
631  * Learner table timeout get
632  *
633  * @param[in] p
634  *   Pipeline handle.
635  * @param[in] learner_id
636  *   Learner table ID (0 .. *n_learners* - 1).
637  * @param[in] timeout_id
638  *   Timeout ID.
639  * @param[out] timeout
640  *   Timeout value measured in seconds. Must be non-NULL.
641  * @return
642  *   0 on success or the following error codes otherwise:
643  *   -EINVAL: Invalid argument.
644  */
645 __rte_experimental
646 int
647 rte_swx_ctl_pipeline_learner_timeout_get(struct rte_swx_pipeline *p,
648 					 uint32_t learner_id,
649 					 uint32_t timeout_id,
650 					 uint32_t *timeout);
651 
652 /**
653  * Learner table timeout set
654  *
655  * @param[in] p
656  *   Pipeline handle.
657  * @param[in] learner_id
658  *   Learner table ID (0 .. *n_learners* - 1).
659  * @param[in] timeout_id
660  *   Timeout ID.
661  * @param[in] timeout
662  *   Timeout value measured in seconds.
663  * @return
664  *   0 on success or the following error codes otherwise:
665  *   -EINVAL: Invalid argument.
666  */
667 __rte_experimental
668 int
669 rte_swx_ctl_pipeline_learner_timeout_set(struct rte_swx_pipeline *p,
670 					 uint32_t learner_id,
671 					 uint32_t timeout_id,
672 					 uint32_t timeout);
673 
674 /** Learner table statistics. */
675 struct rte_swx_learner_stats {
676 	/** Number of packets with lookup hit. */
677 	uint64_t n_pkts_hit;
678 
679 	/** Number of packets with lookup miss. */
680 	uint64_t n_pkts_miss;
681 
682 	/** Number of packets with successful learning. */
683 	uint64_t n_pkts_learn_ok;
684 
685 	/** Number of packets with learning error. */
686 	uint64_t n_pkts_learn_err;
687 
688 	/** Number of packets with rearm event. */
689 	uint64_t n_pkts_rearm;
690 
691 	/** Number of packets with forget event. */
692 	uint64_t n_pkts_forget;
693 
694 	/** Number of packets (with either lookup hit or miss) per pipeline action. Array of
695 	 * pipeline *n_actions* elements indexed by the pipeline-level *action_id*, therefore this
696 	 * array has the same size for all the tables within the same pipeline.
697 	 */
698 	uint64_t *n_pkts_action;
699 };
700 
701 /**
702  * Learner table statistics counters read
703  *
704  * @param[in] p
705  *   Pipeline handle.
706  * @param[in] learner_name
707  *   Learner table name.
708  * @param[out] stats
709  *   Learner table stats. Must point to a pre-allocated structure. The *n_pkts_action* field also
710  *   needs to be pre-allocated as array of pipeline *n_actions* elements. The pipeline actions that
711  *   are not valid for the current learner table have their associated *n_pkts_action* element
712  *   always set to zero.
713  * @return
714  *   0 on success or the following error codes otherwise:
715  *   -EINVAL: Invalid argument.
716  */
717 __rte_experimental
718 int
719 rte_swx_ctl_pipeline_learner_stats_read(struct rte_swx_pipeline *p,
720 				      const char *learner_name,
721 				      struct rte_swx_learner_stats *stats);
722 
723 /*
724  * Packet mirroring API.
725  */
726 
727 /** Packet mirroring session parameters. */
728 struct rte_swx_pipeline_mirroring_session_params {
729 	/** Output port ID. */
730 	uint32_t port_id;
731 
732 	/** Fast clone flag. */
733 	int fast_clone;
734 
735 	/** Truncation packet length (in bytes). Zero means no truncation. */
736 	uint32_t truncation_length;
737 };
738 
739 /**
740  * Packet mirroring session set
741  *
742  * @param[in] p
743  *   Pipeline handle.
744  * @param[in] session_id
745  *   Packet mirroring session ID.
746  * @param[in] params
747  *   Packet mirroring session parameters.
748  * @return
749  *   0 on success or the following error codes otherwise:
750  *   -EINVAL: Invalid argument;
751  *   -EEXIST: Pipeline was already built successfully.
752  */
753 __rte_experimental
754 int
755 rte_swx_ctl_pipeline_mirroring_session_set(struct rte_swx_pipeline *p,
756 	uint32_t session_id,
757 	struct rte_swx_pipeline_mirroring_session_params *params);
758 
759 /*
760  * Table Update API.
761  */
762 
763 /** Table state. */
764 struct rte_swx_table_state {
765 	/** Table object. */
766 	void *obj;
767 
768 	/** Action ID of the table default action. */
769 	uint64_t default_action_id;
770 
771 	/** Action data of the table default action. Ignored when the action
772 	 * data size is zero; otherwise, action data size bytes are meaningful.
773 	 */
774 	uint8_t *default_action_data;
775 };
776 
777 /**
778  * Pipeline table state get
779  *
780  * @param[in] p
781  *   Pipeline handle.
782  * @param[out] table_state
783  *   After successful execution, the *table_state* contains the pointer to the
784  *   current pipeline table state, which is an array of *n_tables* elements,
785  *   with array element i containing the state of the i-th pipeline table. The
786  *   pipeline continues to own all the data structures directly or indirectly
787  *   referenced by the *table_state* until the subsequent successful invocation
788  *   of function *rte_swx_pipeline_table_state_set*.
789  * @return
790  *   0 on success or the following error codes otherwise:
791  *   -EINVAL: Invalid argument.
792  */
793 __rte_experimental
794 int
795 rte_swx_pipeline_table_state_get(struct rte_swx_pipeline *p,
796 				 struct rte_swx_table_state **table_state);
797 
798 /**
799  * Pipeline table state set
800  *
801  * @param[in] p
802  *   Pipeline handle.
803  * @param[out] table_state
804  *   After successful execution, the pipeline table state is updated to this
805  *   *table_state*. The ownership of all the data structures directly or
806  *   indirectly referenced by this *table_state* is passed from the caller to
807  *   the pipeline.
808  * @return
809  *   0 on success or the following error codes otherwise:
810  *   -EINVAL: Invalid argument.
811  */
812 __rte_experimental
813 int
814 rte_swx_pipeline_table_state_set(struct rte_swx_pipeline *p,
815 				 struct rte_swx_table_state *table_state);
816 
817 /*
818  * High Level Reference Table Update API.
819  */
820 
821 /** Pipeline control opaque data structure. */
822 struct rte_swx_ctl_pipeline;
823 
824 /**
825  * Pipeline control find
826  *
827  * @param[in] name
828  *   Pipeline name.
829  * @return
830  *   Valid pipeline control handle if found or NULL otherwise.
831  */
832 __rte_experimental
833 struct rte_swx_ctl_pipeline *
834 rte_swx_ctl_pipeline_find(const char *name);
835 
836 /**
837  * Pipeline control create
838  *
839  * @param[in] p
840  *   Pipeline handle.
841  * @return
842  *   Pipeline control handle, on success, or NULL, on error.
843  */
844 __rte_experimental
845 struct rte_swx_ctl_pipeline *
846 rte_swx_ctl_pipeline_create(struct rte_swx_pipeline *p);
847 
848 /**
849  * Pipeline table entry add
850  *
851  * Schedule entry for addition to table or update as part of the next commit
852  * operation.
853  *
854  * @param[in] ctl
855  *   Pipeline control handle.
856  * @param[in] table_name
857  *   Table name.
858  * @param[in] entry
859  *   Entry to be added to the table.
860  * @return
861  *   0 on success or the following error codes otherwise:
862  *   -EINVAL: Invalid argument.
863  */
864 __rte_experimental
865 int
866 rte_swx_ctl_pipeline_table_entry_add(struct rte_swx_ctl_pipeline *ctl,
867 				     const char *table_name,
868 				     struct rte_swx_table_entry *entry);
869 
870 /**
871  * Pipeline table default entry add
872  *
873  * Schedule table default entry update as part of the next commit operation.
874  *
875  * @param[in] ctl
876  *   Pipeline control handle.
877  * @param[in] table_name
878  *   Table name.
879  * @param[in] entry
880  *   The new table default entry. The *key* and *key_mask* entry fields are
881  *   ignored.
882  * @return
883  *   0 on success or the following error codes otherwise:
884  *   -EINVAL: Invalid argument.
885  */
886 __rte_experimental
887 int
888 rte_swx_ctl_pipeline_table_default_entry_add(struct rte_swx_ctl_pipeline *ctl,
889 					     const char *table_name,
890 					     struct rte_swx_table_entry *entry);
891 
892 /**
893  * Pipeline table entry delete
894  *
895  * Schedule entry for deletion from table as part of the next commit operation.
896  * Request is silently discarded if no such entry exists.
897  *
898  * @param[in] ctl
899  *   Pipeline control handle.
900  * @param[in] table_name
901  *   Table name.
902  * @param[in] entry
903  *   Entry to be deleted from the table. The *action_id* and *action_data* entry
904  *   fields are ignored.
905  * @return
906  *   0 on success or the following error codes otherwise:
907  *   -EINVAL: Invalid argument.
908  */
909 __rte_experimental
910 int
911 rte_swx_ctl_pipeline_table_entry_delete(struct rte_swx_ctl_pipeline *ctl,
912 					const char *table_name,
913 					struct rte_swx_table_entry *entry);
914 
915 /**
916  * Pipeline selector table group add
917  *
918  * Add a new group to a selector table. This operation is executed before this
919  * function returns and its result is independent of the result of the next
920  * commit operation.
921  *
922  * @param[in] ctl
923  *   Pipeline control handle.
924  * @param[in] selector_name
925  *   Selector table name.
926  * @param[out] group_id
927  *   The ID of the new group. Only valid when the function call is successful.
928  *   This group is initially empty, i.e. it does not contain any members.
929  * @return
930  *   0 on success or the following error codes otherwise:
931  *   -EINVAL: Invalid argument;
932  *   -ENOSPC: All groups are currently in use, no group available.
933  */
934 __rte_experimental
935 int
936 rte_swx_ctl_pipeline_selector_group_add(struct rte_swx_ctl_pipeline *ctl,
937 					const char *selector_name,
938 					uint32_t *group_id);
939 
940 /**
941  * Pipeline selector table group delete
942  *
943  * Schedule a group for deletion as part of the next commit operation. The group
944  * to be deleted can be empty or non-empty.
945  *
946  * @param[in] ctl
947  *   Pipeline control handle.
948  * @param[in] selector_name
949  *   Selector table name.
950  * @param[in] group_id
951  *   Group to be deleted from the selector table.
952  * @return
953  *   0 on success or the following error codes otherwise:
954  *   -EINVAL: Invalid argument;
955  *   -ENOMEM: Not enough memory.
956  */
957 __rte_experimental
958 int
959 rte_swx_ctl_pipeline_selector_group_delete(struct rte_swx_ctl_pipeline *ctl,
960 					   const char *selector_name,
961 					   uint32_t group_id);
962 
963 /**
964  * Pipeline selector table member add to group
965  *
966  * Schedule the operation to add a new member to an existing group as part of
967  * the next commit operation. If this member is already in this group, the
968  * member weight is updated to the new value. A weight of zero means this member
969  * is to be deleted from the group.
970  *
971  * @param[in] ctl
972  *   Pipeline control handle.
973  * @param[in] selector_name
974  *   Selector table name.
975  * @param[in] group_id
976  *   The group ID.
977  * @param[in] member_id
978  *   The member to be added to the group.
979  * @param[in] member_weight
980  *   Member weight.
981  * @return
982  *   0 on success or the following error codes otherwise:
983  *   -EINVAL: Invalid argument;
984  *   -ENOMEM: Not enough memory;
985  *   -ENOSPC: The group is full.
986  */
987 __rte_experimental
988 int
989 rte_swx_ctl_pipeline_selector_group_member_add(struct rte_swx_ctl_pipeline *ctl,
990 					       const char *selector_name,
991 					       uint32_t group_id,
992 					       uint32_t member_id,
993 					       uint32_t member_weight);
994 
995 /**
996  * Pipeline selector table member delete from group
997  *
998  * Schedule the operation to delete a member from an existing group as part of
999  * the next commit operation.
1000  *
1001  * @param[in] ctl
1002  *   Pipeline control handle.
1003  * @param[in] selector_name
1004  *   Selector table name.
1005  * @param[in] group_id
1006  *   The group ID. Must be valid.
1007  * @param[in] member_id
1008  *   The member to be added to the group. Must be valid.
1009  * @return
1010  *   0 on success or the following error codes otherwise:
1011  *   -EINVAL: Invalid argument.
1012  */
1013 __rte_experimental
1014 int
1015 rte_swx_ctl_pipeline_selector_group_member_delete(struct rte_swx_ctl_pipeline *ctl,
1016 						  const char *selector_name,
1017 						  uint32_t group_id,
1018 						  uint32_t member_id);
1019 
1020 /**
1021  * Pipeline learner table default entry add
1022  *
1023  * Schedule learner table default entry update as part of the next commit operation.
1024  *
1025  * @param[in] ctl
1026  *   Pipeline control handle.
1027  * @param[in] learner_name
1028  *   Learner table name.
1029  * @param[in] entry
1030  *   The new table default entry. The *key* and *key_mask* entry fields are ignored.
1031  * @return
1032  *   0 on success or the following error codes otherwise:
1033  *   -EINVAL: Invalid argument.
1034  */
1035 __rte_experimental
1036 int
1037 rte_swx_ctl_pipeline_learner_default_entry_add(struct rte_swx_ctl_pipeline *ctl,
1038 					       const char *learner_name,
1039 					       struct rte_swx_table_entry *entry);
1040 
1041 /**
1042  * Pipeline commit
1043  *
1044  * Perform all the scheduled table work.
1045  *
1046  * @param[in] ctl
1047  *   Pipeline control handle.
1048  * @param[in] abort_on_fail
1049  *   When non-zero (false), all the scheduled work is discarded after a failed
1050  *   commit. Otherwise, the scheduled work is still kept pending for the next
1051  *   commit.
1052  * @return
1053  *   0 on success or the following error codes otherwise:
1054  *   -EINVAL: Invalid argument.
1055  */
1056 __rte_experimental
1057 int
1058 rte_swx_ctl_pipeline_commit(struct rte_swx_ctl_pipeline *ctl,
1059 			    int abort_on_fail);
1060 
1061 /**
1062  * Pipeline abort
1063  *
1064  * Discard all the scheduled table work.
1065  *
1066  * @param[in] ctl
1067  *   Pipeline control handle.
1068  */
1069 __rte_experimental
1070 void
1071 rte_swx_ctl_pipeline_abort(struct rte_swx_ctl_pipeline *ctl);
1072 
1073 /**
1074  * Pipeline table entry read
1075  *
1076  * Read table entry from string.
1077  *
1078  * @param[in] ctl
1079  *   Pipeline control handle.
1080  * @param[in] table_name
1081  *   Table name.
1082  * @param[in] string
1083  *   String containing the table entry.
1084  * @param[out] is_blank_or_comment
1085  *   On error, this argument provides an indication of whether *string* contains
1086  *   an invalid table entry (set to zero) or a blank or comment line that should
1087  *   typically be ignored (set to a non-zero value).
1088  * @return
1089  *   0 on success or the following error codes otherwise:
1090  *   -EINVAL: Invalid argument.
1091  */
1092 __rte_experimental
1093 struct rte_swx_table_entry *
1094 rte_swx_ctl_pipeline_table_entry_read(struct rte_swx_ctl_pipeline *ctl,
1095 				      const char *table_name,
1096 				      const char *string,
1097 				      int *is_blank_or_comment);
1098 
1099 /**
1100  * Pipeline learner table default entry read
1101  *
1102  * Read learner table default entry from string.
1103  *
1104  * @param[in] ctl
1105  *   Pipeline control handle.
1106  * @param[in] learner_name
1107  *   Learner table name.
1108  * @param[in] string
1109  *   String containing the learner table default entry.
1110  * @param[out] is_blank_or_comment
1111  *   On error, this argument provides an indication of whether *string* contains
1112  *   an invalid table entry (set to zero) or a blank or comment line that should
1113  *   typically be ignored (set to a non-zero value).
1114  * @return
1115  *   0 on success or the following error codes otherwise:
1116  *   -EINVAL: Invalid argument.
1117  */
1118 __rte_experimental
1119 struct rte_swx_table_entry *
1120 rte_swx_ctl_pipeline_learner_default_entry_read(struct rte_swx_ctl_pipeline *ctl,
1121 						const char *learner_name,
1122 						const char *string,
1123 						int *is_blank_or_comment);
1124 
1125 /**
1126  * Pipeline table print to file
1127  *
1128  * Print all the table entries to file.
1129  *
1130  * @param[in] f
1131  *   Output file.
1132  * @param[in] ctl
1133  *   Pipeline control handle.
1134  * @param[in] table_name
1135  *   Table name.
1136  * @return
1137  *   0 on success or the following error codes otherwise:
1138  *   -EINVAL: Invalid argument.
1139  */
1140 __rte_experimental
1141 int
1142 rte_swx_ctl_pipeline_table_fprintf(FILE *f,
1143 				   struct rte_swx_ctl_pipeline *ctl,
1144 				   const char *table_name);
1145 
1146 /**
1147  * Pipeline selector print to file
1148  *
1149  * Print all the selector entries to file.
1150  *
1151  * @param[in] f
1152  *   Output file.
1153  * @param[in] ctl
1154  *   Pipeline control handle.
1155  * @param[in] selector_name
1156  *   Selector table name.
1157  * @return
1158  *   0 on success or the following error codes otherwise:
1159  *   -EINVAL: Invalid argument.
1160  */
1161 __rte_experimental
1162 int
1163 rte_swx_ctl_pipeline_selector_fprintf(FILE *f,
1164 				      struct rte_swx_ctl_pipeline *ctl,
1165 				      const char *selector_name);
1166 
1167 /*
1168  * Register Array Query API.
1169  */
1170 
1171 /** Register array info. */
1172 struct rte_swx_ctl_regarray_info {
1173 	/** Register array name. */
1174 	char name[RTE_SWX_CTL_NAME_SIZE];
1175 
1176 	/** Register array size. */
1177 	uint32_t size;
1178 };
1179 
1180 /**
1181  * Register array info get
1182  *
1183  * @param[in] p
1184  *   Pipeline handle.
1185  * @param[in] regarray_id
1186  *   Register array ID (0 .. *n_regarrays* - 1).
1187  * @param[out] regarray
1188  *   Register array info.
1189  * @return
1190  *   0 on success or the following error codes otherwise:
1191  *   -EINVAL: Invalid argument.
1192  */
1193 __rte_experimental
1194 int
1195 rte_swx_ctl_regarray_info_get(struct rte_swx_pipeline *p,
1196 			      uint32_t regarray_id,
1197 			      struct rte_swx_ctl_regarray_info *regarray);
1198 
1199 /**
1200  * Register read
1201  *
1202  * @param[in] p
1203  *   Pipeline handle.
1204  * @param[in] regarray_name
1205  *   Register array name.
1206  * @param[in] regarray_index
1207  *   Register index within the array (0 .. *size* - 1).
1208  * @param[out] value
1209  *   Current register value.
1210  * @return
1211  *   0 on success or the following error codes otherwise:
1212  *   -EINVAL: Invalid argument.
1213  */
1214 __rte_experimental
1215 int
1216 rte_swx_ctl_pipeline_regarray_read(struct rte_swx_pipeline *p,
1217 				   const char *regarray_name,
1218 				   uint32_t regarray_index,
1219 				   uint64_t *value);
1220 
1221 /**
1222  * Register write
1223  *
1224  * @param[in] p
1225  *   Pipeline handle.
1226  * @param[in] regarray_name
1227  *   Register array name.
1228  * @param[in] regarray_index
1229  *   Register index within the array (0 .. *size* - 1).
1230  * @param[in] value
1231  *   Value to be written to the register.
1232  * @return
1233  *   0 on success or the following error codes otherwise:
1234  *   -EINVAL: Invalid argument.
1235  */
1236 __rte_experimental
1237 int
1238 rte_swx_ctl_pipeline_regarray_write(struct rte_swx_pipeline *p,
1239 				   const char *regarray_name,
1240 				   uint32_t regarray_index,
1241 				   uint64_t value);
1242 
1243 /**
1244  * Register read with table key lookup
1245  *
1246  * @param[in] p
1247  *   Pipeline handle.
1248  * @param[in] regarray_name
1249  *   Register array name.
1250  * @param[in] table_name
1251  *   Regular or learner table name.
1252  * @param[in] table_key
1253  *   Table key.
1254  * @param[out] value
1255  *   Current register value.
1256  * @return
1257  *   0 on success or the following error codes otherwise:
1258  *   -EINVAL: Invalid argument;
1259  *   -ENOMEM: Not enough memory.
1260  */
1261 __rte_experimental
1262 int
1263 rte_swx_ctl_pipeline_regarray_read_with_key(struct rte_swx_pipeline *p,
1264 					    const char *regarray_name,
1265 					    const char *table_name,
1266 					    uint8_t *table_key,
1267 					    uint64_t *value);
1268 
1269 /**
1270  * Register write with table key lookup
1271  *
1272  * @param[in] p
1273  *   Pipeline handle.
1274  * @param[in] regarray_name
1275  *   Register array name.
1276  * @param[in] table_name
1277  *   Regular or learner table name.
1278  * @param[in] table_key
1279  *   Table key.
1280  * @param[in] value
1281  *   Value to be written to the register.
1282  * @return
1283  *   0 on success or the following error codes otherwise:
1284  *   -EINVAL: Invalid argument;
1285  *   -ENOMEM: Not enough memory.
1286  */
1287 __rte_experimental
1288 int
1289 rte_swx_ctl_pipeline_regarray_write_with_key(struct rte_swx_pipeline *p,
1290 					     const char *regarray_name,
1291 					     const char *table_name,
1292 					     uint8_t *table_key,
1293 					     uint64_t value);
1294 
1295 /*
1296  * Meter Array Query and Configuration API.
1297  */
1298 
1299 /** Meter array info. */
1300 struct rte_swx_ctl_metarray_info {
1301 	/** Meter array name. */
1302 	char name[RTE_SWX_CTL_NAME_SIZE];
1303 
1304 	/** Meter array size. */
1305 	uint32_t size;
1306 };
1307 
1308 /**
1309  * Meter array info get
1310  *
1311  * @param[in] p
1312  *   Pipeline handle.
1313  * @param[in] metarray_id
1314  *   Meter array ID (0 .. *n_metarrays* - 1).
1315  * @param[out] metarray
1316  *   Meter array info.
1317  * @return
1318  *   0 on success or the following error codes otherwise:
1319  *   -EINVAL: Invalid argument.
1320  */
1321 __rte_experimental
1322 int
1323 rte_swx_ctl_metarray_info_get(struct rte_swx_pipeline *p,
1324 			      uint32_t metarray_id,
1325 			      struct rte_swx_ctl_metarray_info *metarray);
1326 
1327 /**
1328  * Meter profile add
1329  *
1330  * @param[in] p
1331  *   Pipeline handle.
1332  * @param[in] name
1333  *   Meter profile name.
1334  * @param[in] params
1335  *   Meter profile parameters.
1336  * @return
1337  *   0 on success or the following error codes otherwise:
1338  *   -EINVAL: Invalid argument;
1339  *   -ENOMEM: Not enough space/cannot allocate memory;
1340  *   -EEXIST: Meter profile with this name already exists.
1341  */
1342 __rte_experimental
1343 int
1344 rte_swx_ctl_meter_profile_add(struct rte_swx_pipeline *p,
1345 			      const char *name,
1346 			      struct rte_meter_trtcm_params *params);
1347 
1348 /**
1349  * Meter profile delete
1350  *
1351  * @param[in] p
1352  *   Pipeline handle.
1353  * @param[in] name
1354  *   Meter profile name.
1355  * @return
1356  *   0 on success or the following error codes otherwise:
1357  *   -EINVAL: Invalid argument;
1358  *   -EBUSY: Meter profile is currently in use.
1359  */
1360 __rte_experimental
1361 int
1362 rte_swx_ctl_meter_profile_delete(struct rte_swx_pipeline *p,
1363 				 const char *name);
1364 
1365 /**
1366  * Meter reset
1367  *
1368  * Reset a meter within a given meter array to use the default profile that
1369  * causes all the input packets to be colored as green. It is the responsibility
1370  * of the control plane to make sure this meter is not used by the data plane
1371  * pipeline before calling this function.
1372  *
1373  * @param[in] p
1374  *   Pipeline handle.
1375  * @param[in] metarray_name
1376  *   Meter array name.
1377  * @param[in] metarray_index
1378  *   Meter index within the meter array.
1379  * @return
1380  *   0 on success or the following error codes otherwise:
1381  *   -EINVAL: Invalid argument.
1382  */
1383 __rte_experimental
1384 int
1385 rte_swx_ctl_meter_reset(struct rte_swx_pipeline *p,
1386 			const char *metarray_name,
1387 			uint32_t metarray_index);
1388 
1389 /**
1390  * Meter set
1391  *
1392  * Set a meter within a given meter array to use a specific profile. It is the
1393  * responsibility of the control plane to make sure this meter is not used by
1394  * the data plane pipeline before calling this function.
1395  *
1396  * @param[in] p
1397  *   Pipeline handle.
1398  * @param[in] metarray_name
1399  *   Meter array name.
1400  * @param[in] metarray_index
1401  *   Meter index within the meter array.
1402  * @param[in] profile_name
1403  *   Existing meter profile name.
1404  * @return
1405  *   0 on success or the following error codes otherwise:
1406  *   -EINVAL: Invalid argument.
1407  */
1408 __rte_experimental
1409 int
1410 rte_swx_ctl_meter_set(struct rte_swx_pipeline *p,
1411 		      const char *metarray_name,
1412 		      uint32_t metarray_index,
1413 		      const char *profile_name);
1414 
1415 /** Meter statistics counters. */
1416 struct rte_swx_ctl_meter_stats {
1417 	/** Number of packets tagged by the meter for each color. */
1418 	uint64_t n_pkts[RTE_COLORS];
1419 
1420 	/** Number of bytes tagged by the meter for each color. */
1421 	uint64_t n_bytes[RTE_COLORS];
1422 };
1423 
1424 /**
1425  * Meter statistics counters read
1426  *
1427  * @param[in] p
1428  *   Pipeline handle.
1429  * @param[in] metarray_name
1430  *   Meter array name.
1431  * @param[in] metarray_index
1432  *   Meter index within the meter array.
1433  * @param[out] stats
1434  *   Meter statistics counters.
1435  * @return
1436  *   0 on success or the following error codes otherwise:
1437  *   -EINVAL: Invalid argument.
1438  */
1439 __rte_experimental
1440 int
1441 rte_swx_ctl_meter_stats_read(struct rte_swx_pipeline *p,
1442 			     const char *metarray_name,
1443 			     uint32_t metarray_index,
1444 			     struct rte_swx_ctl_meter_stats *stats);
1445 
1446 /**
1447  * Meter reset with table key lookup
1448  *
1449  * Reset a meter within a given meter array to use the default profile that
1450  * causes all the input packets to be colored as green. It is the responsibility
1451  * of the control plane to make sure this meter is not used by the data plane
1452  * pipeline before calling this function.
1453  *
1454  * @param[in] p
1455  *   Pipeline handle.
1456  * @param[in] metarray_name
1457  *   Meter array name.
1458  * @param[in] table_name
1459  *   Regular or learner table name.
1460  * @param[in] table_key
1461  *   Table key.
1462  * @return
1463  *   0 on success or the following error codes otherwise:
1464  *   -EINVAL: Invalid argument.
1465  */
1466 __rte_experimental
1467 int
1468 rte_swx_ctl_meter_reset_with_key(struct rte_swx_pipeline *p,
1469 				 const char *metarray_name,
1470 				 const char *table_name,
1471 				 uint8_t *table_key);
1472 
1473 /**
1474  * Meter set with table key lookup
1475  *
1476  * Set a meter within a given meter array to use a specific profile. It is the
1477  * responsibility of the control plane to make sure this meter is not used by
1478  * the data plane pipeline before calling this function.
1479  *
1480  * @param[in] p
1481  *   Pipeline handle.
1482  * @param[in] metarray_name
1483  *   Meter array name.
1484  * @param[in] table_name
1485  *   Regular or learner table name.
1486  * @param[in] table_key
1487  *   Table key.
1488  * @param[in] profile_name
1489  *   Existing meter profile name.
1490  * @return
1491  *   0 on success or the following error codes otherwise:
1492  *   -EINVAL: Invalid argument.
1493  */
1494 __rte_experimental
1495 int
1496 rte_swx_ctl_meter_set_with_key(struct rte_swx_pipeline *p,
1497 			       const char *metarray_name,
1498 			       const char *table_name,
1499 			       uint8_t *table_key,
1500 			       const char *profile_name);
1501 
1502 /**
1503  * Meter statistics counters read with table key lookup
1504  *
1505  * @param[in] p
1506  *   Pipeline handle.
1507  * @param[in] metarray_name
1508  *   Meter array name.
1509  * @param[in] table_name
1510  *   Regular or learner table name.
1511  * @param[in] table_key
1512  *   Table key.
1513  * @param[out] stats
1514  *   Meter statistics counters.
1515  * @return
1516  *   0 on success or the following error codes otherwise:
1517  *   -EINVAL: Invalid argument.
1518  */
1519 __rte_experimental
1520 int
1521 rte_swx_ctl_meter_stats_read_with_key(struct rte_swx_pipeline *p,
1522 				      const char *metarray_name,
1523 				      const char *table_name,
1524 				      uint8_t *table_key,
1525 				      struct rte_swx_ctl_meter_stats *stats);
1526 
1527 /*
1528  * RSS Query and Configuration API.
1529  */
1530 
1531 /** RSS object info. */
1532 struct rte_swx_ctl_rss_info {
1533 	/** RSS object name. */
1534 	char name[RTE_SWX_CTL_NAME_SIZE];
1535 };
1536 
1537 /**
1538  * RSS object info get
1539  *
1540  * @param[in] p
1541  *   Pipeline handle.
1542  * @param[in] rss_obj_id
1543  *   RSS object ID (0 .. *n_rss* - 1).
1544  * @param[out] rss
1545  *   RSS object info.
1546  * @return
1547  *   0 on success or the following error codes otherwise:
1548  *   -EINVAL: Invalid argument.
1549  */
1550 __rte_experimental
1551 int
1552 rte_swx_ctl_rss_info_get(struct rte_swx_pipeline *p,
1553 			 uint32_t rss_obj_id,
1554 			 struct rte_swx_ctl_rss_info *rss);
1555 
1556 /**
1557  * RSS object key size read
1558  *
1559  * @param[in] p
1560  *   Pipeline handle.
1561  * @param[in] rss_obj_name
1562  *   RSS object name.
1563  * @param[out] key_size
1564  *   RSS key size in bytes.
1565  * @return
1566  *   0 on success or the following error codes otherwise:
1567  *   -EINVAL: Invalid argument.
1568  */
1569 __rte_experimental
1570 int
1571 rte_swx_ctl_pipeline_rss_key_size_read(struct rte_swx_pipeline *p,
1572 				       const char *rss_obj_name,
1573 				       uint32_t *key_size);
1574 
1575 /**
1576  * RSS object key read
1577  *
1578  * @param[in] p
1579  *   Pipeline handle.
1580  * @param[in] rss_obj_name
1581  *   RSS object name.
1582  * @param[out] key
1583  *   RSS key. Must be pre-allocated by the caller to store *key_size* bytes.
1584  * @return
1585  *   0 on success or the following error codes otherwise:
1586  *   -EINVAL: Invalid argument.
1587  */
1588 __rte_experimental
1589 int
1590 rte_swx_ctl_pipeline_rss_key_read(struct rte_swx_pipeline *p,
1591 				  const char *rss_obj_name,
1592 				  uint8_t *key);
1593 
1594 /**
1595  * RSS object key write
1596  *
1597  * @param[in] p
1598  *   Pipeline handle.
1599  * @param[in] rss_obj_name
1600  *   RSS object name.
1601  * @param[in] key_size
1602  *   RSS key size in bytes. Must be at least 4 and a power of 2.
1603  * @param[in] key
1604  *   RSS key.
1605  * @return
1606  *   0 on success or the following error codes otherwise:
1607  *   -EINVAL: Invalid argument.
1608  */
1609 __rte_experimental
1610 int
1611 rte_swx_ctl_pipeline_rss_key_write(struct rte_swx_pipeline *p,
1612 				   const char *rss_obj_name,
1613 				   uint32_t key_size,
1614 				   uint8_t *key);
1615 
1616 /**
1617  * Pipeline control free
1618  *
1619  * @param[in] ctl
1620  *   Pipeline control handle.
1621  *   If ctl is NULL, no operation is performed.
1622  */
1623 __rte_experimental
1624 void
1625 rte_swx_ctl_pipeline_free(struct rte_swx_ctl_pipeline *ctl);
1626 
1627 #ifdef __cplusplus
1628 }
1629 #endif
1630 
1631 #endif
1632