New upstream version 18.08
[deb_dpdk.git] / lib / librte_pipeline / rte_table_action.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018 Intel Corporation
3  */
4
5 #ifndef __INCLUDE_RTE_TABLE_ACTION_H__
6 #define __INCLUDE_RTE_TABLE_ACTION_H__
7
8 /**
9  * @file
10  * RTE Pipeline Table Actions
11  *
12  * This API provides a common set of actions for pipeline tables to speed up
13  * application development.
14  *
15  * Each match-action rule added to a pipeline table has associated data that
16  * stores the action context. This data is input to the table action handler
17  * called for every input packet that hits the rule as part of the table lookup
18  * during the pipeline execution. The pipeline library allows the user to define
19  * his own table actions by providing customized table action handlers (table
20  * lookup) and complete freedom of setting the rules and their data (table rule
21  * add/delete). While the user can still follow this process, this API is
22  * intended to provide a quicker development alternative for a set of predefined
23  * actions.
24  *
25  * The typical steps to use this API are:
26  *  - Define a table action profile. This is a configuration template that can
27  *    potentially be shared by multiple tables from the same or different
28  *    pipelines, with different tables from the same pipeline likely to use
29  *    different action profiles. For every table using a given action profile,
30  *    the profile defines the set of actions and the action configuration to be
31  *    implemented for all the table rules. API functions:
32  *    rte_table_action_profile_create(),
33  *    rte_table_action_profile_action_register(),
34  *    rte_table_action_profile_freeze().
35  *
36  *  - Instantiate the table action profile to create table action objects. Each
37  *    pipeline table has its own table action object. API functions:
38  *    rte_table_action_create().
39  *
40  *  - Use the table action object to generate the pipeline table action handlers
41  *    (invoked by the pipeline table lookup operation). API functions:
42  *    rte_table_action_table_params_get().
43  *
44  *  - Use the table action object to generate the rule data (for the pipeline
45  *    table rule add operation) based on given action parameters. API functions:
46  *    rte_table_action_apply().
47  *
48  *  - Use the table action object to read action data (e.g. stats counters) for
49  *    any given rule. API functions: rte_table_action_XYZ_read().
50  *
51  * @warning
52  * @b EXPERIMENTAL: this API may change without prior notice
53  */
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58
59 #include <stdint.h>
60
61 #include <rte_compat.h>
62 #include <rte_ether.h>
63 #include <rte_meter.h>
64 #include <rte_table_hash.h>
65
66 #include "rte_pipeline.h"
67
68 /** Table actions. */
69 enum rte_table_action_type {
70         /** Forward to next pipeline table, output port or drop. */
71         RTE_TABLE_ACTION_FWD = 0,
72
73         /**  Load balance. */
74         RTE_TABLE_ACTION_LB,
75
76         /**  Traffic Metering and Policing. */
77         RTE_TABLE_ACTION_MTR,
78
79         /**  Traffic Management. */
80         RTE_TABLE_ACTION_TM,
81
82         /** Packet encapsulations. */
83         RTE_TABLE_ACTION_ENCAP,
84
85         /** Network Address Translation (NAT). */
86         RTE_TABLE_ACTION_NAT,
87
88         /** Time to Live (TTL) update. */
89         RTE_TABLE_ACTION_TTL,
90
91         /** Statistics. */
92         RTE_TABLE_ACTION_STATS,
93
94         /** Timestamp. */
95         RTE_TABLE_ACTION_TIME,
96 };
97
98 /** Common action configuration (per table action profile). */
99 struct rte_table_action_common_config {
100         /** Input packet Internet Protocol (IP) version. Non-zero for IPv4, zero
101          * for IPv6.
102          */
103         int ip_version;
104
105         /** IP header offset within the input packet buffer. Offset 0 points to
106          * the first byte of the MBUF structure.
107          */
108         uint32_t ip_offset;
109 };
110
111 /**
112  * RTE_TABLE_ACTION_FWD
113  */
114 /** Forward action parameters (per table rule). */
115 struct rte_table_action_fwd_params {
116         /** Forward action. */
117         enum rte_pipeline_action action;
118
119         /** Pipeline table ID or output port ID. */
120         uint32_t id;
121 };
122
123 /**
124  * RTE_TABLE_ACTION_LB
125  */
126 /** Load balance key size min (number of bytes). */
127 #define RTE_TABLE_ACTION_LB_KEY_SIZE_MIN                    8
128
129 /** Load balance key size max (number of bytes). */
130 #define RTE_TABLE_ACTION_LB_KEY_SIZE_MAX                    64
131
132 /** Load balance table size. */
133 #define RTE_TABLE_ACTION_LB_TABLE_SIZE                      8
134
135 /** Load balance action configuration (per table action profile). */
136 struct rte_table_action_lb_config {
137         /** Key size (number of bytes). */
138         uint32_t key_size;
139
140         /** Key offset within the input packet buffer. Offset 0 points to the
141          * first byte of the MBUF structure.
142          */
143         uint32_t key_offset;
144
145         /** Key mask (*key_size* bytes are valid). */
146         uint8_t key_mask[RTE_TABLE_ACTION_LB_KEY_SIZE_MAX];
147
148         /** Hash function. */
149         rte_table_hash_op_hash f_hash;
150
151         /** Seed value for *f_hash*. */
152         uint64_t seed;
153
154         /** Output value offset within the input packet buffer. Offset 0 points
155          * to the first byte of the MBUF structure.
156          */
157         uint32_t out_offset;
158 };
159
160 /** Load balance action parameters (per table rule). */
161 struct rte_table_action_lb_params {
162         /** Table defining the output values and their weights. The weights are
163          * set in 1/RTE_TABLE_ACTION_LB_TABLE_SIZE increments. To assign a
164          * weight of N/RTE_TABLE_ACTION_LB_TABLE_SIZE to a given output value
165          * (0 <= N <= RTE_TABLE_ACTION_LB_TABLE_SIZE), the same output value
166          * needs to show up exactly N times in this table.
167          */
168         uint32_t out[RTE_TABLE_ACTION_LB_TABLE_SIZE];
169 };
170
171 /**
172  * RTE_TABLE_ACTION_MTR
173  */
174 /** Max number of traffic classes (TCs). */
175 #define RTE_TABLE_ACTION_TC_MAX                                  4
176
177 /** Max number of queues per traffic class. */
178 #define RTE_TABLE_ACTION_TC_QUEUE_MAX                            4
179
180 /** Differentiated Services Code Point (DSCP) translation table entry. */
181 struct rte_table_action_dscp_table_entry {
182         /** Traffic class. Used by the meter or the traffic management actions.
183          * Has to be strictly smaller than *RTE_TABLE_ACTION_TC_MAX*. Traffic
184          * class 0 is the highest priority.
185          */
186         uint32_t tc_id;
187
188         /** Traffic class queue. Used by the traffic management action. Has to
189          * be strictly smaller than *RTE_TABLE_ACTION_TC_QUEUE_MAX*.
190          */
191         uint32_t tc_queue_id;
192
193         /** Packet color. Used by the meter action as the packet input color
194          * for the color aware mode of the traffic metering algorithm.
195          */
196         enum rte_meter_color color;
197 };
198
199 /** DSCP translation table. */
200 struct rte_table_action_dscp_table {
201         /** Array of DSCP table entries */
202         struct rte_table_action_dscp_table_entry entry[64];
203 };
204
205 /** Supported traffic metering algorithms. */
206 enum rte_table_action_meter_algorithm {
207         /** Single Rate Three Color Marker (srTCM) - IETF RFC 2697. */
208         RTE_TABLE_ACTION_METER_SRTCM,
209
210         /** Two Rate Three Color Marker (trTCM) - IETF RFC 2698. */
211         RTE_TABLE_ACTION_METER_TRTCM,
212 };
213
214 /** Traffic metering profile (configuration template). */
215 struct rte_table_action_meter_profile {
216         /** Traffic metering algorithm. */
217         enum rte_table_action_meter_algorithm alg;
218
219         RTE_STD_C11
220         union {
221                 /** Only valid when *alg* is set to srTCM - IETF RFC 2697. */
222                 struct rte_meter_srtcm_params srtcm;
223
224                 /** Only valid when *alg* is set to trTCM - IETF RFC 2698. */
225                 struct rte_meter_trtcm_params trtcm;
226         };
227 };
228
229 /** Policer actions. */
230 enum rte_table_action_policer {
231         /** Recolor the packet as green. */
232         RTE_TABLE_ACTION_POLICER_COLOR_GREEN = 0,
233
234         /** Recolor the packet as yellow. */
235         RTE_TABLE_ACTION_POLICER_COLOR_YELLOW,
236
237         /** Recolor the packet as red. */
238         RTE_TABLE_ACTION_POLICER_COLOR_RED,
239
240         /** Drop the packet. */
241         RTE_TABLE_ACTION_POLICER_DROP,
242
243         /** Number of policer actions. */
244         RTE_TABLE_ACTION_POLICER_MAX
245 };
246
247 /** Meter action configuration per traffic class. */
248 struct rte_table_action_mtr_tc_params {
249         /** Meter profile ID. */
250         uint32_t meter_profile_id;
251
252         /** Policer actions. */
253         enum rte_table_action_policer policer[e_RTE_METER_COLORS];
254 };
255
256 /** Meter action statistics counters per traffic class. */
257 struct rte_table_action_mtr_counters_tc {
258         /** Number of packets per color at the output of the traffic metering
259          * and before the policer actions are executed. Only valid when
260          * *n_packets_valid* is non-zero.
261          */
262         uint64_t n_packets[e_RTE_METER_COLORS];
263
264         /** Number of packet bytes per color at the output of the traffic
265          * metering and before the policer actions are executed. Only valid when
266          * *n_bytes_valid* is non-zero.
267          */
268         uint64_t n_bytes[e_RTE_METER_COLORS];
269
270         /** When non-zero, the *n_packets* field is valid. */
271         int n_packets_valid;
272
273         /** When non-zero, the *n_bytes* field is valid. */
274         int n_bytes_valid;
275 };
276
277 /** Meter action configuration (per table action profile). */
278 struct rte_table_action_mtr_config {
279         /** Meter algorithm. */
280         enum rte_table_action_meter_algorithm alg;
281
282         /** Number of traffic classes. Each traffic class has its own traffic
283          * meter and policer instances. Needs to be equal to either 1 or to
284          * *RTE_TABLE_ACTION_TC_MAX*.
285          */
286         uint32_t n_tc;
287
288         /** When non-zero, the *n_packets* meter stats counter is enabled,
289          * otherwise it is disabled.
290          *
291          * @see struct rte_table_action_mtr_counters_tc
292          */
293         int n_packets_enabled;
294
295         /** When non-zero, the *n_bytes* meter stats counter is enabled,
296          * otherwise it is disabled.
297          *
298          * @see struct rte_table_action_mtr_counters_tc
299          */
300         int n_bytes_enabled;
301 };
302
303 /** Meter action parameters (per table rule). */
304 struct rte_table_action_mtr_params {
305         /** Traffic meter and policer parameters for each of the *tc_mask*
306          * traffic classes.
307          */
308         struct rte_table_action_mtr_tc_params mtr[RTE_TABLE_ACTION_TC_MAX];
309
310         /** Bit mask defining which traffic class parameters are valid in *mtr*.
311          * If bit N is set in *tc_mask*, then parameters for traffic class N are
312          * valid in *mtr*.
313          */
314         uint32_t tc_mask;
315 };
316
317 /** Meter action statistics counters (per table rule). */
318 struct rte_table_action_mtr_counters {
319         /** Stats counters for each of the *tc_mask* traffic classes. */
320         struct rte_table_action_mtr_counters_tc stats[RTE_TABLE_ACTION_TC_MAX];
321
322         /** Bit mask defining which traffic class parameters are valid in *mtr*.
323          * If bit N is set in *tc_mask*, then parameters for traffic class N are
324          * valid in *mtr*.
325          */
326         uint32_t tc_mask;
327 };
328
329 /**
330  * RTE_TABLE_ACTION_TM
331  */
332 /** Traffic management action configuration (per table action profile). */
333 struct rte_table_action_tm_config {
334         /** Number of subports per port. */
335         uint32_t n_subports_per_port;
336
337         /** Number of pipes per subport. */
338         uint32_t n_pipes_per_subport;
339 };
340
341 /** Traffic management action parameters (per table rule). */
342 struct rte_table_action_tm_params {
343         /** Subport ID. */
344         uint32_t subport_id;
345
346         /** Pipe ID. */
347         uint32_t pipe_id;
348 };
349
350 /**
351  * RTE_TABLE_ACTION_ENCAP
352  */
353 /** Supported packet encapsulation types. */
354 enum rte_table_action_encap_type {
355         /** IP -> { Ether | IP } */
356         RTE_TABLE_ACTION_ENCAP_ETHER = 0,
357
358         /** IP -> { Ether | VLAN | IP } */
359         RTE_TABLE_ACTION_ENCAP_VLAN,
360
361         /** IP -> { Ether | S-VLAN | C-VLAN | IP } */
362         RTE_TABLE_ACTION_ENCAP_QINQ,
363
364         /** IP -> { Ether | MPLS | IP } */
365         RTE_TABLE_ACTION_ENCAP_MPLS,
366
367         /** IP -> { Ether | PPPoE | PPP | IP } */
368         RTE_TABLE_ACTION_ENCAP_PPPOE,
369 };
370
371 /** Pre-computed Ethernet header fields for encapsulation action. */
372 struct rte_table_action_ether_hdr {
373         struct ether_addr da; /**< Destination address. */
374         struct ether_addr sa; /**< Source address. */
375 };
376
377 /** Pre-computed VLAN header fields for encapsulation action. */
378 struct rte_table_action_vlan_hdr {
379         uint8_t pcp; /**< Priority Code Point (PCP). */
380         uint8_t dei; /**< Drop Eligibility Indicator (DEI). */
381         uint16_t vid; /**< VLAN Identifier (VID). */
382 };
383
384 /** Pre-computed MPLS header fields for encapsulation action. */
385 struct rte_table_action_mpls_hdr {
386         uint32_t label; /**< Label. */
387         uint8_t tc; /**< Traffic Class (TC). */
388         uint8_t ttl; /**< Time to Live (TTL). */
389 };
390
391 /** Pre-computed PPPoE header fields for encapsulation action. */
392 struct rte_table_action_pppoe_hdr {
393         uint16_t session_id; /**< Session ID. */
394 };
395
396 /** Ether encap parameters. */
397 struct rte_table_action_encap_ether_params {
398         struct rte_table_action_ether_hdr ether; /**< Ethernet header. */
399 };
400
401 /** VLAN encap parameters. */
402 struct rte_table_action_encap_vlan_params {
403         struct rte_table_action_ether_hdr ether; /**< Ethernet header. */
404         struct rte_table_action_vlan_hdr vlan; /**< VLAN header. */
405 };
406
407 /** QinQ encap parameters. */
408 struct rte_table_action_encap_qinq_params {
409         struct rte_table_action_ether_hdr ether; /**< Ethernet header. */
410         struct rte_table_action_vlan_hdr svlan; /**< Service VLAN header. */
411         struct rte_table_action_vlan_hdr cvlan; /**< Customer VLAN header. */
412 };
413
414 /** Max number of MPLS labels per output packet for MPLS encapsulation. */
415 #ifndef RTE_TABLE_ACTION_MPLS_LABELS_MAX
416 #define RTE_TABLE_ACTION_MPLS_LABELS_MAX                   4
417 #endif
418
419 /** MPLS encap parameters. */
420 struct rte_table_action_encap_mpls_params {
421         /** Ethernet header. */
422         struct rte_table_action_ether_hdr ether;
423
424         /** MPLS header. */
425         struct rte_table_action_mpls_hdr mpls[RTE_TABLE_ACTION_MPLS_LABELS_MAX];
426
427         /** Number of MPLS labels in MPLS header. */
428         uint32_t mpls_count;
429
430         /** Non-zero for MPLS unicast, zero for MPLS multicast. */
431         int unicast;
432 };
433
434 /** PPPoE encap parameters. */
435 struct rte_table_action_encap_pppoe_params {
436         struct rte_table_action_ether_hdr ether; /**< Ethernet header. */
437         struct rte_table_action_pppoe_hdr pppoe; /**< PPPoE/PPP headers. */
438 };
439
440 /** Encap action configuration (per table action profile). */
441 struct rte_table_action_encap_config {
442         /** Bit mask defining the set of packet encapsulations enabled for the
443          * current table action profile. If bit (1 << N) is set in *encap_mask*,
444          * then packet encapsulation N is enabled, otherwise it is disabled.
445          *
446          * @see enum rte_table_action_encap_type
447          */
448         uint64_t encap_mask;
449 };
450
451 /** Encap action parameters (per table rule). */
452 struct rte_table_action_encap_params {
453         /** Encapsulation type. */
454         enum rte_table_action_encap_type type;
455
456         RTE_STD_C11
457         union {
458                 /** Only valid when *type* is set to Ether. */
459                 struct rte_table_action_encap_ether_params ether;
460
461                 /** Only valid when *type* is set to VLAN. */
462                 struct rte_table_action_encap_vlan_params vlan;
463
464                 /** Only valid when *type* is set to QinQ. */
465                 struct rte_table_action_encap_qinq_params qinq;
466
467                 /** Only valid when *type* is set to MPLS. */
468                 struct rte_table_action_encap_mpls_params mpls;
469
470                 /** Only valid when *type* is set to PPPoE. */
471                 struct rte_table_action_encap_pppoe_params pppoe;
472         };
473 };
474
475 /**
476  * RTE_TABLE_ACTION_NAT
477  */
478 /** NAT action configuration (per table action profile). */
479 struct rte_table_action_nat_config {
480         /** When non-zero, the IP source address and L4 protocol source port are
481          * translated. When zero, the IP destination address and L4 protocol
482          * destination port are translated.
483          */
484         int source_nat;
485
486         /** Layer 4 protocol, for example TCP (0x06) or UDP (0x11). The checksum
487          * field is computed differently and placed at different header offset
488          * by each layer 4 protocol.
489          */
490         uint8_t proto;
491 };
492
493 /** NAT action parameters (per table rule). */
494 struct rte_table_action_nat_params {
495         /** IP version for *addr*: non-zero for IPv4, zero for IPv6. */
496         int ip_version;
497
498         /** IP address. */
499         union {
500                 /** IPv4 address; only valid when *ip_version* is non-zero. */
501                 uint32_t ipv4;
502
503                 /** IPv6 address; only valid when *ip_version* is set to 0. */
504                 uint8_t ipv6[16];
505         } addr;
506
507         /** Port. */
508         uint16_t port;
509 };
510
511 /**
512  * RTE_TABLE_ACTION_TTL
513  */
514 /** TTL action configuration (per table action profile). */
515 struct rte_table_action_ttl_config {
516         /** When non-zero, the input packets whose updated IPv4 Time to Live
517          * (TTL) field or IPv6 Hop Limit (HL) field is zero are dropped.
518          * When zero, the input packets whose updated IPv4 TTL field or IPv6 HL
519          * field is zero are forwarded as usual (typically for debugging
520          * purpose).
521          */
522         int drop;
523
524         /** When non-zero, the *n_packets* stats counter for TTL action is
525          * enabled, otherwise disabled.
526          *
527          * @see struct rte_table_action_ttl_counters
528          */
529         int n_packets_enabled;
530 };
531
532 /** TTL action parameters (per table rule). */
533 struct rte_table_action_ttl_params {
534         /** When non-zero, decrement the IPv4 TTL field and update the checksum
535          * field, or decrement the IPv6 HL field. When zero, the IPv4 TTL field
536          * or the IPv6 HL field is not changed.
537          */
538         int decrement;
539 };
540
541 /** TTL action statistics packets (per table rule). */
542 struct rte_table_action_ttl_counters {
543         /** Number of IPv4 packets whose updated TTL field is zero or IPv6
544          * packets whose updated HL field is zero.
545          */
546         uint64_t n_packets;
547 };
548
549 /**
550  * RTE_TABLE_ACTION_STATS
551  */
552 /** Stats action configuration (per table action profile). */
553 struct rte_table_action_stats_config {
554         /** When non-zero, the *n_packets* stats counter is enabled, otherwise
555          * disabled.
556          *
557          * @see struct rte_table_action_stats_counters
558          */
559         int n_packets_enabled;
560
561         /** When non-zero, the *n_bytes* stats counter is enabled, otherwise
562          * disabled.
563          *
564          * @see struct rte_table_action_stats_counters
565          */
566         int n_bytes_enabled;
567 };
568
569 /** Stats action parameters (per table rule). */
570 struct rte_table_action_stats_params {
571         /** Initial value for the *n_packets* stats counter. Typically set to 0.
572          *
573          * @see struct rte_table_action_stats_counters
574          */
575         uint64_t n_packets;
576
577         /** Initial value for the *n_bytes* stats counter. Typically set to 0.
578          *
579          * @see struct rte_table_action_stats_counters
580          */
581         uint64_t n_bytes;
582 };
583
584 /** Stats action counters (per table rule). */
585 struct rte_table_action_stats_counters {
586         /** Number of packets. Valid only when *n_packets_valid* is non-zero. */
587         uint64_t n_packets;
588
589         /** Number of bytes. Valid only when *n_bytes_valid* is non-zero. */
590         uint64_t n_bytes;
591
592         /** When non-zero, the *n_packets* field is valid, otherwise invalid. */
593         int n_packets_valid;
594
595         /** When non-zero, the *n_bytes* field is valid, otherwise invalid. */
596         int n_bytes_valid;
597 };
598
599 /**
600  * RTE_TABLE_ACTION_TIME
601  */
602 /** Timestamp action parameters (per table rule). */
603 struct rte_table_action_time_params {
604         /** Initial timestamp value. Typically set to current time. */
605         uint64_t time;
606 };
607
608 /**
609  * Table action profile.
610  */
611 struct rte_table_action_profile;
612
613 /**
614  * Table action profile create.
615  *
616  * @param[in] common
617  *   Common action configuration.
618  * @return
619  *   Table action profile handle on success, NULL otherwise.
620  */
621 struct rte_table_action_profile * __rte_experimental
622 rte_table_action_profile_create(struct rte_table_action_common_config *common);
623
624 /**
625  * Table action profile free.
626  *
627  * @param[in] profile
628  *   Table profile action handle (needs to be valid).
629  * @return
630  *   Zero on success, non-zero error code otherwise.
631  */
632 int __rte_experimental
633 rte_table_action_profile_free(struct rte_table_action_profile *profile);
634
635 /**
636  * Table action profile action register.
637  *
638  * @param[in] profile
639  *   Table profile action handle (needs to be valid and not in frozen state).
640  * @param[in] type
641  *   Specific table action to be registered for *profile*.
642  * @param[in] action_config
643  *   Configuration for the *type* action.
644  *   If struct rte_table_action_*type*_config is defined by the Table Action
645  *   API, it needs to point to a valid instance of this structure, otherwise it
646  *   needs to be set to NULL.
647  * @return
648  *   Zero on success, non-zero error code otherwise.
649  */
650 int __rte_experimental
651 rte_table_action_profile_action_register(struct rte_table_action_profile *profile,
652         enum rte_table_action_type type,
653         void *action_config);
654
655 /**
656  * Table action profile freeze.
657  *
658  * Once this function is called successfully, the given profile enters the
659  * frozen state with the following immediate effects: no more actions can be
660  * registered for this profile, so the profile can be instantiated to create
661  * table action objects.
662  *
663  * @param[in] profile
664  *   Table profile action handle (needs to be valid and not in frozen state).
665  * @return
666  *   Zero on success, non-zero error code otherwise.
667  *
668  * @see rte_table_action_create()
669  */
670 int __rte_experimental
671 rte_table_action_profile_freeze(struct rte_table_action_profile *profile);
672
673 /**
674  * Table action.
675  */
676 struct rte_table_action;
677
678 /**
679  * Table action create.
680  *
681  * Instantiates the given table action profile to create a table action object.
682  *
683  * @param[in] profile
684  *   Table profile action handle (needs to be valid and in frozen state).
685  * @param[in] socket_id
686  *   CPU socket ID where the internal data structures required by the new table
687  *   action object should be allocated.
688  * @return
689  *   Handle to table action object on success, NULL on error.
690  *
691  * @see rte_table_action_create()
692  */
693 struct rte_table_action * __rte_experimental
694 rte_table_action_create(struct rte_table_action_profile *profile,
695         uint32_t socket_id);
696
697 /**
698  * Table action free.
699  *
700  * @param[in] action
701  *   Handle to table action object (needs to be valid).
702  * @return
703  *   Zero on success, non-zero error code otherwise.
704  */
705 int __rte_experimental
706 rte_table_action_free(struct rte_table_action *action);
707
708 /**
709  * Table action table params get.
710  *
711  * @param[in] action
712  *   Handle to table action object (needs to be valid).
713  * @param[inout] params
714  *   Pipeline table parameters (needs to be pre-allocated).
715  * @return
716  *   Zero on success, non-zero error code otherwise.
717  */
718 int __rte_experimental
719 rte_table_action_table_params_get(struct rte_table_action *action,
720         struct rte_pipeline_table_params *params);
721
722 /**
723  * Table action apply.
724  *
725  * @param[in] action
726  *   Handle to table action object (needs to be valid).
727  * @param[in] data
728  *   Data byte array (typically table rule data) to apply action *type* on.
729  * @param[in] type
730  *   Specific table action previously registered for the table action profile of
731  *   the *action* object.
732  * @param[in] action_params
733  *   Parameters for the *type* action.
734  *   If struct rte_table_action_*type*_params is defined by the Table Action
735  *   API, it needs to point to a valid instance of this structure, otherwise it
736  *   needs to be set to NULL.
737  * @return
738  *   Zero on success, non-zero error code otherwise.
739  */
740 int __rte_experimental
741 rte_table_action_apply(struct rte_table_action *action,
742         void *data,
743         enum rte_table_action_type type,
744         void *action_params);
745
746 /**
747  * Table action DSCP table update.
748  *
749  * @param[in] action
750  *   Handle to table action object (needs to be valid).
751  * @param[in] dscp_mask
752  *   64-bit mask defining the DSCP table entries to be updated. If bit N is set
753  *   in this bit mask, then DSCP table entry N is to be updated, otherwise not.
754  * @param[in] table
755  *   DSCP table.
756  * @return
757  *   Zero on success, non-zero error code otherwise.
758  */
759 int __rte_experimental
760 rte_table_action_dscp_table_update(struct rte_table_action *action,
761         uint64_t dscp_mask,
762         struct rte_table_action_dscp_table *table);
763
764 /**
765  * Table action meter profile add.
766  *
767  * @param[in] action
768  *   Handle to table action object (needs to be valid).
769  * @param[in] meter_profile_id
770  *   Meter profile ID to be used for the *profile* once it is successfully added
771  *   to the *action* object (needs to be unused by the set of meter profiles
772  *   currently registered for the *action* object).
773  * @param[in] profile
774  *   Meter profile to be added.
775  * @return
776  *   Zero on success, non-zero error code otherwise.
777  */
778 int __rte_experimental
779 rte_table_action_meter_profile_add(struct rte_table_action *action,
780         uint32_t meter_profile_id,
781         struct rte_table_action_meter_profile *profile);
782
783 /**
784  * Table action meter profile delete.
785  *
786  * @param[in] action
787  *   Handle to table action object (needs to be valid).
788  * @param[in] meter_profile_id
789  *   Meter profile ID of the meter profile to be deleted from the *action*
790  *   object (needs to be valid for the *action* object).
791  * @return
792  *   Zero on success, non-zero error code otherwise.
793  */
794 int __rte_experimental
795 rte_table_action_meter_profile_delete(struct rte_table_action *action,
796         uint32_t meter_profile_id);
797
798 /**
799  * Table action meter read.
800  *
801  * @param[in] action
802  *   Handle to table action object (needs to be valid).
803  * @param[in] data
804  *   Data byte array (typically table rule data) with meter action previously
805  *   applied on it.
806  * @param[in] tc_mask
807  *   Bit mask defining which traffic classes should have the meter stats
808  *   counters read from *data* and stored into *stats*. If bit N is set in this
809  *   bit mask, then traffic class N is part of this operation, otherwise it is
810  *   not. If bit N is set in this bit mask, then traffic class N must be one of
811  *   the traffic classes that are enabled for the meter action in the table
812  *   action profile used by the *action* object.
813  * @param[inout] stats
814  *   When non-NULL, it points to the area where the meter stats counters read
815  *   from *data* are saved. Only the meter stats counters for the *tc_mask*
816  *   traffic classes are read and stored to *stats*.
817  * @param[in] clear
818  *   When non-zero, the meter stats counters are cleared (i.e. set to zero),
819  *   otherwise the counters are not modified. When the read operation is enabled
820  *   (*stats* is non-NULL), the clear operation is performed after the read
821  *   operation is completed.
822  * @return
823  *   Zero on success, non-zero error code otherwise.
824  */
825 int __rte_experimental
826 rte_table_action_meter_read(struct rte_table_action *action,
827         void *data,
828         uint32_t tc_mask,
829         struct rte_table_action_mtr_counters *stats,
830         int clear);
831
832 /**
833  * Table action TTL read.
834  *
835  * @param[in] action
836  *   Handle to table action object (needs to be valid).
837  * @param[in] data
838  *   Data byte array (typically table rule data) with TTL action previously
839  *   applied on it.
840  * @param[inout] stats
841  *   When non-NULL, it points to the area where the TTL stats counters read from
842  *   *data* are saved.
843  * @param[in] clear
844  *   When non-zero, the TTL stats counters are cleared (i.e. set to zero),
845  *   otherwise the counters are not modified. When the read operation is enabled
846  *   (*stats* is non-NULL), the clear operation is performed after the read
847  *   operation is completed.
848  * @return
849  *   Zero on success, non-zero error code otherwise.
850  */
851 int __rte_experimental
852 rte_table_action_ttl_read(struct rte_table_action *action,
853         void *data,
854         struct rte_table_action_ttl_counters *stats,
855         int clear);
856
857 /**
858  * Table action stats read.
859  *
860  * @param[in] action
861  *   Handle to table action object (needs to be valid).
862  * @param[in] data
863  *   Data byte array (typically table rule data) with stats action previously
864  *   applied on it.
865  * @param[inout] stats
866  *   When non-NULL, it points to the area where the stats counters read from
867  *   *data* are saved.
868  * @param[in] clear
869  *   When non-zero, the stats counters are cleared (i.e. set to zero), otherwise
870  *   the counters are not modified. When the read operation is enabled (*stats*
871  *   is non-NULL), the clear operation is performed after the read operation is
872  *   completed.
873  * @return
874  *   Zero on success, non-zero error code otherwise.
875  */
876 int __rte_experimental
877 rte_table_action_stats_read(struct rte_table_action *action,
878         void *data,
879         struct rte_table_action_stats_counters *stats,
880         int clear);
881
882 /**
883  * Table action timestamp read.
884  *
885  * @param[in] action
886  *   Handle to table action object (needs to be valid).
887  * @param[in] data
888  *   Data byte array (typically table rule data) with timestamp action
889  *   previously applied on it.
890  * @param[inout] timestamp
891  *   Pre-allocated memory where the timestamp read from *data* is saved (has to
892  *   be non-NULL).
893  * @return
894  *   Zero on success, non-zero error code otherwise.
895  */
896 int __rte_experimental
897 rte_table_action_time_read(struct rte_table_action *action,
898         void *data,
899         uint64_t *timestamp);
900
901 #ifdef __cplusplus
902 }
903 #endif
904
905 #endif /* __INCLUDE_RTE_TABLE_ACTION_H__ */