pipeline: add TTL update action
[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
65 #include "rte_pipeline.h"
66
67 /** Table actions. */
68 enum rte_table_action_type {
69         /** Forward to next pipeline table, output port or drop. */
70         RTE_TABLE_ACTION_FWD = 0,
71
72         /**  Traffic Metering and Policing. */
73         RTE_TABLE_ACTION_MTR,
74
75         /**  Traffic Management. */
76         RTE_TABLE_ACTION_TM,
77
78         /** Packet encapsulations. */
79         RTE_TABLE_ACTION_ENCAP,
80
81         /** Network Address Translation (NAT). */
82         RTE_TABLE_ACTION_NAT,
83
84         /** Time to Live (TTL) update. */
85         RTE_TABLE_ACTION_TTL,
86 };
87
88 /** Common action configuration (per table action profile). */
89 struct rte_table_action_common_config {
90         /** Input packet Internet Protocol (IP) version. Non-zero for IPv4, zero
91          * for IPv6.
92          */
93         int ip_version;
94
95         /** IP header offset within the input packet buffer. Offset 0 points to
96          * the first byte of the MBUF structure.
97          */
98         uint32_t ip_offset;
99 };
100
101 /**
102  * RTE_TABLE_ACTION_FWD
103  */
104 /** Forward action parameters (per table rule). */
105 struct rte_table_action_fwd_params {
106         /** Forward action. */
107         enum rte_pipeline_action action;
108
109         /** Pipeline table ID or output port ID. */
110         uint32_t id;
111 };
112
113 /**
114  * RTE_TABLE_ACTION_MTR
115  */
116 /** Max number of traffic classes (TCs). */
117 #define RTE_TABLE_ACTION_TC_MAX                                  4
118
119 /** Max number of queues per traffic class. */
120 #define RTE_TABLE_ACTION_TC_QUEUE_MAX                            4
121
122 /** Differentiated Services Code Point (DSCP) translation table entry. */
123 struct rte_table_action_dscp_table_entry {
124         /** Traffic class. Used by the meter or the traffic management actions.
125          * Has to be strictly smaller than *RTE_TABLE_ACTION_TC_MAX*. Traffic
126          * class 0 is the highest priority.
127          */
128         uint32_t tc_id;
129
130         /** Traffic class queue. Used by the traffic management action. Has to
131          * be strictly smaller than *RTE_TABLE_ACTION_TC_QUEUE_MAX*.
132          */
133         uint32_t tc_queue_id;
134
135         /** Packet color. Used by the meter action as the packet input color
136          * for the color aware mode of the traffic metering algorithm.
137          */
138         enum rte_meter_color color;
139 };
140
141 /** DSCP translation table. */
142 struct rte_table_action_dscp_table {
143         /** Array of DSCP table entries */
144         struct rte_table_action_dscp_table_entry entry[64];
145 };
146
147 /** Supported traffic metering algorithms. */
148 enum rte_table_action_meter_algorithm {
149         /** Single Rate Three Color Marker (srTCM) - IETF RFC 2697. */
150         RTE_TABLE_ACTION_METER_SRTCM,
151
152         /** Two Rate Three Color Marker (trTCM) - IETF RFC 2698. */
153         RTE_TABLE_ACTION_METER_TRTCM,
154 };
155
156 /** Traffic metering profile (configuration template). */
157 struct rte_table_action_meter_profile {
158         /** Traffic metering algorithm. */
159         enum rte_table_action_meter_algorithm alg;
160
161         RTE_STD_C11
162         union {
163                 /** Only valid when *alg* is set to srTCM - IETF RFC 2697. */
164                 struct rte_meter_srtcm_params srtcm;
165
166                 /** Only valid when *alg* is set to trTCM - IETF RFC 2698. */
167                 struct rte_meter_trtcm_params trtcm;
168         };
169 };
170
171 /** Policer actions. */
172 enum rte_table_action_policer {
173         /** Recolor the packet as green. */
174         RTE_TABLE_ACTION_POLICER_COLOR_GREEN = 0,
175
176         /** Recolor the packet as yellow. */
177         RTE_TABLE_ACTION_POLICER_COLOR_YELLOW,
178
179         /** Recolor the packet as red. */
180         RTE_TABLE_ACTION_POLICER_COLOR_RED,
181
182         /** Drop the packet. */
183         RTE_TABLE_ACTION_POLICER_DROP,
184
185         /** Number of policer actions. */
186         RTE_TABLE_ACTION_POLICER_MAX
187 };
188
189 /** Meter action configuration per traffic class. */
190 struct rte_table_action_mtr_tc_params {
191         /** Meter profile ID. */
192         uint32_t meter_profile_id;
193
194         /** Policer actions. */
195         enum rte_table_action_policer policer[e_RTE_METER_COLORS];
196 };
197
198 /** Meter action statistics counters per traffic class. */
199 struct rte_table_action_mtr_counters_tc {
200         /** Number of packets per color at the output of the traffic metering
201          * and before the policer actions are executed. Only valid when
202          * *n_packets_valid* is non-zero.
203          */
204         uint64_t n_packets[e_RTE_METER_COLORS];
205
206         /** Number of packet bytes per color at the output of the traffic
207          * metering and before the policer actions are executed. Only valid when
208          * *n_bytes_valid* is non-zero.
209          */
210         uint64_t n_bytes[e_RTE_METER_COLORS];
211
212         /** When non-zero, the *n_packets* field is valid. */
213         int n_packets_valid;
214
215         /** When non-zero, the *n_bytes* field is valid. */
216         int n_bytes_valid;
217 };
218
219 /** Meter action configuration (per table action profile). */
220 struct rte_table_action_mtr_config {
221         /** Meter algorithm. */
222         enum rte_table_action_meter_algorithm alg;
223
224         /** Number of traffic classes. Each traffic class has its own traffic
225          * meter and policer instances. Needs to be equal to either 1 or to
226          * *RTE_TABLE_ACTION_TC_MAX*.
227          */
228         uint32_t n_tc;
229
230         /** When non-zero, the *n_packets* meter stats counter is enabled,
231          * otherwise it is disabled.
232          *
233          * @see struct rte_table_action_mtr_counters_tc
234          */
235         int n_packets_enabled;
236
237         /** When non-zero, the *n_bytes* meter stats counter is enabled,
238          * otherwise it is disabled.
239          *
240          * @see struct rte_table_action_mtr_counters_tc
241          */
242         int n_bytes_enabled;
243 };
244
245 /** Meter action parameters (per table rule). */
246 struct rte_table_action_mtr_params {
247         /** Traffic meter and policer parameters for each of the *tc_mask*
248          * traffic classes.
249          */
250         struct rte_table_action_mtr_tc_params mtr[RTE_TABLE_ACTION_TC_MAX];
251
252         /** Bit mask defining which traffic class parameters are valid in *mtr*.
253          * If bit N is set in *tc_mask*, then parameters for traffic class N are
254          * valid in *mtr*.
255          */
256         uint32_t tc_mask;
257 };
258
259 /** Meter action statistics counters (per table rule). */
260 struct rte_table_action_mtr_counters {
261         /** Stats counters for each of the *tc_mask* traffic classes. */
262         struct rte_table_action_mtr_counters_tc stats[RTE_TABLE_ACTION_TC_MAX];
263
264         /** Bit mask defining which traffic class parameters are valid in *mtr*.
265          * If bit N is set in *tc_mask*, then parameters for traffic class N are
266          * valid in *mtr*.
267          */
268         uint32_t tc_mask;
269 };
270
271 /**
272  * RTE_TABLE_ACTION_TM
273  */
274 /** Traffic management action configuration (per table action profile). */
275 struct rte_table_action_tm_config {
276         /** Number of subports per port. */
277         uint32_t n_subports_per_port;
278
279         /** Number of pipes per subport. */
280         uint32_t n_pipes_per_subport;
281 };
282
283 /** Traffic management action parameters (per table rule). */
284 struct rte_table_action_tm_params {
285         /** Subport ID. */
286         uint32_t subport_id;
287
288         /** Pipe ID. */
289         uint32_t pipe_id;
290 };
291
292 /**
293  * RTE_TABLE_ACTION_ENCAP
294  */
295 /** Supported packet encapsulation types. */
296 enum rte_table_action_encap_type {
297         /** IP -> { Ether | IP } */
298         RTE_TABLE_ACTION_ENCAP_ETHER = 0,
299
300         /** IP -> { Ether | VLAN | IP } */
301         RTE_TABLE_ACTION_ENCAP_VLAN,
302
303         /** IP -> { Ether | S-VLAN | C-VLAN | IP } */
304         RTE_TABLE_ACTION_ENCAP_QINQ,
305
306         /** IP -> { Ether | MPLS | IP } */
307         RTE_TABLE_ACTION_ENCAP_MPLS,
308
309         /** IP -> { Ether | PPPoE | PPP | IP } */
310         RTE_TABLE_ACTION_ENCAP_PPPOE,
311 };
312
313 /** Pre-computed Ethernet header fields for encapsulation action. */
314 struct rte_table_action_ether_hdr {
315         struct ether_addr da; /**< Destination address. */
316         struct ether_addr sa; /**< Source address. */
317 };
318
319 /** Pre-computed VLAN header fields for encapsulation action. */
320 struct rte_table_action_vlan_hdr {
321         uint8_t pcp; /**< Priority Code Point (PCP). */
322         uint8_t dei; /**< Drop Eligibility Indicator (DEI). */
323         uint16_t vid; /**< VLAN Identifier (VID). */
324 };
325
326 /** Pre-computed MPLS header fields for encapsulation action. */
327 struct rte_table_action_mpls_hdr {
328         uint32_t label; /**< Label. */
329         uint8_t tc; /**< Traffic Class (TC). */
330         uint8_t ttl; /**< Time to Live (TTL). */
331 };
332
333 /** Pre-computed PPPoE header fields for encapsulation action. */
334 struct rte_table_action_pppoe_hdr {
335         uint16_t session_id; /**< Session ID. */
336 };
337
338 /** Ether encap parameters. */
339 struct rte_table_action_encap_ether_params {
340         struct rte_table_action_ether_hdr ether; /**< Ethernet header. */
341 };
342
343 /** VLAN encap parameters. */
344 struct rte_table_action_encap_vlan_params {
345         struct rte_table_action_ether_hdr ether; /**< Ethernet header. */
346         struct rte_table_action_vlan_hdr vlan; /**< VLAN header. */
347 };
348
349 /** QinQ encap parameters. */
350 struct rte_table_action_encap_qinq_params {
351         struct rte_table_action_ether_hdr ether; /**< Ethernet header. */
352         struct rte_table_action_vlan_hdr svlan; /**< Service VLAN header. */
353         struct rte_table_action_vlan_hdr cvlan; /**< Customer VLAN header. */
354 };
355
356 /** Max number of MPLS labels per output packet for MPLS encapsulation. */
357 #ifndef RTE_TABLE_ACTION_MPLS_LABELS_MAX
358 #define RTE_TABLE_ACTION_MPLS_LABELS_MAX                   4
359 #endif
360
361 /** MPLS encap parameters. */
362 struct rte_table_action_encap_mpls_params {
363         /** Ethernet header. */
364         struct rte_table_action_ether_hdr ether;
365
366         /** MPLS header. */
367         struct rte_table_action_mpls_hdr mpls[RTE_TABLE_ACTION_MPLS_LABELS_MAX];
368
369         /** Number of MPLS labels in MPLS header. */
370         uint32_t mpls_count;
371
372         /** Non-zero for MPLS unicast, zero for MPLS multicast. */
373         int unicast;
374 };
375
376 /** PPPoE encap parameters. */
377 struct rte_table_action_encap_pppoe_params {
378         struct rte_table_action_ether_hdr ether; /**< Ethernet header. */
379         struct rte_table_action_pppoe_hdr pppoe; /**< PPPoE/PPP headers. */
380 };
381
382 /** Encap action configuration (per table action profile). */
383 struct rte_table_action_encap_config {
384         /** Bit mask defining the set of packet encapsulations enabled for the
385          * current table action profile. If bit (1 << N) is set in *encap_mask*,
386          * then packet encapsulation N is enabled, otherwise it is disabled.
387          *
388          * @see enum rte_table_action_encap_type
389          */
390         uint64_t encap_mask;
391 };
392
393 /** Encap action parameters (per table rule). */
394 struct rte_table_action_encap_params {
395         /** Encapsulation type. */
396         enum rte_table_action_encap_type type;
397
398         RTE_STD_C11
399         union {
400                 /** Only valid when *type* is set to Ether. */
401                 struct rte_table_action_encap_ether_params ether;
402
403                 /** Only valid when *type* is set to VLAN. */
404                 struct rte_table_action_encap_vlan_params vlan;
405
406                 /** Only valid when *type* is set to QinQ. */
407                 struct rte_table_action_encap_qinq_params qinq;
408
409                 /** Only valid when *type* is set to MPLS. */
410                 struct rte_table_action_encap_mpls_params mpls;
411
412                 /** Only valid when *type* is set to PPPoE. */
413                 struct rte_table_action_encap_pppoe_params pppoe;
414         };
415 };
416
417 /**
418  * RTE_TABLE_ACTION_NAT
419  */
420 /** NAT action configuration (per table action profile). */
421 struct rte_table_action_nat_config {
422         /** When non-zero, the IP source address and L4 protocol source port are
423          * translated. When zero, the IP destination address and L4 protocol
424          * destination port are translated.
425          */
426         int source_nat;
427
428         /** Layer 4 protocol, for example TCP (0x06) or UDP (0x11). The checksum
429          * field is computed differently and placed at different header offset
430          * by each layer 4 protocol.
431          */
432         uint8_t proto;
433 };
434
435 /** NAT action parameters (per table rule). */
436 struct rte_table_action_nat_params {
437         /** IP version for *addr*: non-zero for IPv4, zero for IPv6. */
438         int ip_version;
439
440         /** IP address. */
441         union {
442                 /** IPv4 address; only valid when *ip_version* is non-zero. */
443                 uint32_t ipv4;
444
445                 /** IPv6 address; only valid when *ip_version* is set to 0. */
446                 uint8_t ipv6[16];
447         } addr;
448
449         /** Port. */
450         uint16_t port;
451 };
452
453 /**
454  * RTE_TABLE_ACTION_TTL
455  */
456 /** TTL action configuration (per table action profile). */
457 struct rte_table_action_ttl_config {
458         /** When non-zero, the input packets whose updated IPv4 Time to Live
459          * (TTL) field or IPv6 Hop Limit (HL) field is zero are dropped.
460          * When zero, the input packets whose updated IPv4 TTL field or IPv6 HL
461          * field is zero are forwarded as usual (typically for debugging
462          * purpose).
463          */
464         int drop;
465
466         /** When non-zero, the *n_packets* stats counter for TTL action is
467          * enabled, otherwise disabled.
468          *
469          * @see struct rte_table_action_ttl_counters
470          */
471         int n_packets_enabled;
472 };
473
474 /** TTL action parameters (per table rule). */
475 struct rte_table_action_ttl_params {
476         /** When non-zero, decrement the IPv4 TTL field and update the checksum
477          * field, or decrement the IPv6 HL field. When zero, the IPv4 TTL field
478          * or the IPv6 HL field is not changed.
479          */
480         int decrement;
481 };
482
483 /** TTL action statistics packets (per table rule). */
484 struct rte_table_action_ttl_counters {
485         /** Number of IPv4 packets whose updated TTL field is zero or IPv6
486          * packets whose updated HL field is zero.
487          */
488         uint64_t n_packets;
489 };
490
491 /**
492  * Table action profile.
493  */
494 struct rte_table_action_profile;
495
496 /**
497  * Table action profile create.
498  *
499  * @param[in] common
500  *   Common action configuration.
501  * @return
502  *   Table action profile handle on success, NULL otherwise.
503  */
504 struct rte_table_action_profile * __rte_experimental
505 rte_table_action_profile_create(struct rte_table_action_common_config *common);
506
507 /**
508  * Table action profile free.
509  *
510  * @param[in] profile
511  *   Table profile action handle (needs to be valid).
512  * @return
513  *   Zero on success, non-zero error code otherwise.
514  */
515 int __rte_experimental
516 rte_table_action_profile_free(struct rte_table_action_profile *profile);
517
518 /**
519  * Table action profile action register.
520  *
521  * @param[in] profile
522  *   Table profile action handle (needs to be valid and not in frozen state).
523  * @param[in] type
524  *   Specific table action to be registered for *profile*.
525  * @param[in] action_config
526  *   Configuration for the *type* action.
527  *   If struct rte_table_action_*type*_config is defined by the Table Action
528  *   API, it needs to point to a valid instance of this structure, otherwise it
529  *   needs to be set to NULL.
530  * @return
531  *   Zero on success, non-zero error code otherwise.
532  */
533 int __rte_experimental
534 rte_table_action_profile_action_register(struct rte_table_action_profile *profile,
535         enum rte_table_action_type type,
536         void *action_config);
537
538 /**
539  * Table action profile freeze.
540  *
541  * Once this function is called successfully, the given profile enters the
542  * frozen state with the following immediate effects: no more actions can be
543  * registered for this profile, so the profile can be instantiated to create
544  * table action objects.
545  *
546  * @param[in] profile
547  *   Table profile action handle (needs to be valid and not in frozen state).
548  * @return
549  *   Zero on success, non-zero error code otherwise.
550  *
551  * @see rte_table_action_create()
552  */
553 int __rte_experimental
554 rte_table_action_profile_freeze(struct rte_table_action_profile *profile);
555
556 /**
557  * Table action.
558  */
559 struct rte_table_action;
560
561 /**
562  * Table action create.
563  *
564  * Instantiates the given table action profile to create a table action object.
565  *
566  * @param[in] profile
567  *   Table profile action handle (needs to be valid and in frozen state).
568  * @param[in] socket_id
569  *   CPU socket ID where the internal data structures required by the new table
570  *   action object should be allocated.
571  * @return
572  *   Handle to table action object on success, NULL on error.
573  *
574  * @see rte_table_action_create()
575  */
576 struct rte_table_action * __rte_experimental
577 rte_table_action_create(struct rte_table_action_profile *profile,
578         uint32_t socket_id);
579
580 /**
581  * Table action free.
582  *
583  * @param[in] action
584  *   Handle to table action object (needs to be valid).
585  * @return
586  *   Zero on success, non-zero error code otherwise.
587  */
588 int __rte_experimental
589 rte_table_action_free(struct rte_table_action *action);
590
591 /**
592  * Table action table params get.
593  *
594  * @param[in] action
595  *   Handle to table action object (needs to be valid).
596  * @param[inout] params
597  *   Pipeline table parameters (needs to be pre-allocated).
598  * @return
599  *   Zero on success, non-zero error code otherwise.
600  */
601 int __rte_experimental
602 rte_table_action_table_params_get(struct rte_table_action *action,
603         struct rte_pipeline_table_params *params);
604
605 /**
606  * Table action apply.
607  *
608  * @param[in] action
609  *   Handle to table action object (needs to be valid).
610  * @param[in] data
611  *   Data byte array (typically table rule data) to apply action *type* on.
612  * @param[in] type
613  *   Specific table action previously registered for the table action profile of
614  *   the *action* object.
615  * @param[in] action_params
616  *   Parameters for the *type* action.
617  *   If struct rte_table_action_*type*_params is defined by the Table Action
618  *   API, it needs to point to a valid instance of this structure, otherwise it
619  *   needs to be set to NULL.
620  * @return
621  *   Zero on success, non-zero error code otherwise.
622  */
623 int __rte_experimental
624 rte_table_action_apply(struct rte_table_action *action,
625         void *data,
626         enum rte_table_action_type type,
627         void *action_params);
628
629 /**
630  * Table action DSCP table update.
631  *
632  * @param[in] action
633  *   Handle to table action object (needs to be valid).
634  * @param[in] dscp_mask
635  *   64-bit mask defining the DSCP table entries to be updated. If bit N is set
636  *   in this bit mask, then DSCP table entry N is to be updated, otherwise not.
637  * @param[in] table
638  *   DSCP table.
639  * @return
640  *   Zero on success, non-zero error code otherwise.
641  */
642 int __rte_experimental
643 rte_table_action_dscp_table_update(struct rte_table_action *action,
644         uint64_t dscp_mask,
645         struct rte_table_action_dscp_table *table);
646
647 /**
648  * Table action meter profile add.
649  *
650  * @param[in] action
651  *   Handle to table action object (needs to be valid).
652  * @param[in] meter_profile_id
653  *   Meter profile ID to be used for the *profile* once it is successfully added
654  *   to the *action* object (needs to be unused by the set of meter profiles
655  *   currently registered for the *action* object).
656  * @param[in] profile
657  *   Meter profile to be added.
658  * @return
659  *   Zero on success, non-zero error code otherwise.
660  */
661 int __rte_experimental
662 rte_table_action_meter_profile_add(struct rte_table_action *action,
663         uint32_t meter_profile_id,
664         struct rte_table_action_meter_profile *profile);
665
666 /**
667  * Table action meter profile delete.
668  *
669  * @param[in] action
670  *   Handle to table action object (needs to be valid).
671  * @param[in] meter_profile_id
672  *   Meter profile ID of the meter profile to be deleted from the *action*
673  *   object (needs to be valid for the *action* object).
674  * @return
675  *   Zero on success, non-zero error code otherwise.
676  */
677 int __rte_experimental
678 rte_table_action_meter_profile_delete(struct rte_table_action *action,
679         uint32_t meter_profile_id);
680
681 /**
682  * Table action meter read.
683  *
684  * @param[in] action
685  *   Handle to table action object (needs to be valid).
686  * @param[in] data
687  *   Data byte array (typically table rule data) with meter action previously
688  *   applied on it.
689  * @param[in] tc_mask
690  *   Bit mask defining which traffic classes should have the meter stats
691  *   counters read from *data* and stored into *stats*. If bit N is set in this
692  *   bit mask, then traffic class N is part of this operation, otherwise it is
693  *   not. If bit N is set in this bit mask, then traffic class N must be one of
694  *   the traffic classes that are enabled for the meter action in the table
695  *   action profile used by the *action* object.
696  * @param[inout] stats
697  *   When non-NULL, it points to the area where the meter stats counters read
698  *   from *data* are saved. Only the meter stats counters for the *tc_mask*
699  *   traffic classes are read and stored to *stats*.
700  * @param[in] clear
701  *   When non-zero, the meter stats counters are cleared (i.e. set to zero),
702  *   otherwise the counters are not modified. When the read operation is enabled
703  *   (*stats* is non-NULL), the clear operation is performed after the read
704  *   operation is completed.
705  * @return
706  *   Zero on success, non-zero error code otherwise.
707  */
708 int __rte_experimental
709 rte_table_action_meter_read(struct rte_table_action *action,
710         void *data,
711         uint32_t tc_mask,
712         struct rte_table_action_mtr_counters *stats,
713         int clear);
714
715 /**
716  * Table action TTL read.
717  *
718  * @param[in] action
719  *   Handle to table action object (needs to be valid).
720  * @param[in] data
721  *   Data byte array (typically table rule data) with TTL action previously
722  *   applied on it.
723  * @param[inout] stats
724  *   When non-NULL, it points to the area where the TTL stats counters read from
725  *   *data* are saved.
726  * @param[in] clear
727  *   When non-zero, the TTL stats counters are cleared (i.e. set to zero),
728  *   otherwise the counters are not modified. When the read operation is enabled
729  *   (*stats* is non-NULL), the clear operation is performed after the read
730  *   operation is completed.
731  * @return
732  *   Zero on success, non-zero error code otherwise.
733  */
734 int __rte_experimental
735 rte_table_action_ttl_read(struct rte_table_action *action,
736         void *data,
737         struct rte_table_action_ttl_counters *stats,
738         int clear);
739
740 #ifdef __cplusplus
741 }
742 #endif
743
744 #endif /* __INCLUDE_RTE_TABLE_ACTION_H__ */