a1a2e1558b4225bf676ebcef29af47f9e4ef61d1
[dpdk.git] / drivers / net / softnic / rte_eth_softnic_internals.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 Intel Corporation
3  */
4
5 #ifndef __INCLUDE_RTE_ETH_SOFTNIC_INTERNALS_H__
6 #define __INCLUDE_RTE_ETH_SOFTNIC_INTERNALS_H__
7
8 #include <stddef.h>
9 #include <stdint.h>
10 #include <sys/queue.h>
11
12 #include <rte_mempool.h>
13 #include <rte_mbuf.h>
14 #include <rte_ring.h>
15 #include <rte_ethdev.h>
16 #include <rte_sched.h>
17 #include <rte_port_in_action.h>
18 #include <rte_table_action.h>
19 #include <rte_pipeline.h>
20
21 #include <rte_ethdev_core.h>
22 #include <rte_ethdev_driver.h>
23 #include <rte_tm_driver.h>
24 #include <rte_flow_driver.h>
25
26 #include "rte_eth_softnic.h"
27 #include "conn.h"
28
29 #define NAME_SIZE                                            64
30
31 /**
32  * PMD Parameters
33  */
34
35 struct pmd_params {
36         const char *name;
37         const char *firmware;
38         uint16_t conn_port;
39         uint32_t cpu_id;
40
41         /** Traffic Management (TM) */
42         struct {
43                 uint32_t n_queues; /**< Number of queues */
44                 uint16_t qsize[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
45         } tm;
46 };
47
48 /**
49  * Ethdev Flow API
50  */
51 struct rte_flow;
52
53 TAILQ_HEAD(flow_list, rte_flow);
54
55 struct flow_attr_map {
56         char pipeline_name[NAME_SIZE];
57         uint32_t table_id;
58         int valid;
59 };
60
61 #ifndef SOFTNIC_FLOW_MAX_GROUPS
62 #define SOFTNIC_FLOW_MAX_GROUPS                            64
63 #endif
64
65 struct flow_internals {
66         struct flow_attr_map ingress_map[SOFTNIC_FLOW_MAX_GROUPS];
67         struct flow_attr_map egress_map[SOFTNIC_FLOW_MAX_GROUPS];
68 };
69
70 /**
71  * MEMPOOL
72  */
73 struct softnic_mempool_params {
74         uint32_t buffer_size;
75         uint32_t pool_size;
76         uint32_t cache_size;
77 };
78
79 struct softnic_mempool {
80         TAILQ_ENTRY(softnic_mempool) node;
81         char name[NAME_SIZE];
82         struct rte_mempool *m;
83         uint32_t buffer_size;
84 };
85
86 TAILQ_HEAD(softnic_mempool_list, softnic_mempool);
87
88 /**
89  * SWQ
90  */
91 struct softnic_swq_params {
92         uint32_t size;
93 };
94
95 struct softnic_swq {
96         TAILQ_ENTRY(softnic_swq) node;
97         char name[NAME_SIZE];
98         struct rte_ring *r;
99 };
100
101 TAILQ_HEAD(softnic_swq_list, softnic_swq);
102
103 /**
104  * LINK
105  */
106 struct softnic_link_params {
107         const char *dev_name;
108         uint16_t port_id; /**< Valid only when *dev_name* is NULL. */
109 };
110
111 struct softnic_link {
112         TAILQ_ENTRY(softnic_link) node;
113         char name[NAME_SIZE];
114         uint16_t port_id;
115         uint32_t n_rxq;
116         uint32_t n_txq;
117 };
118
119 TAILQ_HEAD(softnic_link_list, softnic_link);
120
121 /**
122  * TMGR
123  */
124
125 #ifndef TM_MAX_SUBPORTS
126 #define TM_MAX_SUBPORTS                                 8
127 #endif
128
129 #ifndef TM_MAX_PIPES_PER_SUBPORT
130 #define TM_MAX_PIPES_PER_SUBPORT                        4096
131 #endif
132
133 struct tm_params {
134         struct rte_sched_port_params port_params;
135
136         struct rte_sched_subport_params subport_params[TM_MAX_SUBPORTS];
137
138         struct rte_sched_pipe_params
139                 pipe_profiles[RTE_SCHED_PIPE_PROFILES_PER_PORT];
140         uint32_t n_pipe_profiles;
141         uint32_t pipe_to_profile[TM_MAX_SUBPORTS * TM_MAX_PIPES_PER_SUBPORT];
142 };
143
144 /* TM Levels */
145 enum tm_node_level {
146         TM_NODE_LEVEL_PORT = 0,
147         TM_NODE_LEVEL_SUBPORT,
148         TM_NODE_LEVEL_PIPE,
149         TM_NODE_LEVEL_TC,
150         TM_NODE_LEVEL_QUEUE,
151         TM_NODE_LEVEL_MAX,
152 };
153
154 /* TM Shaper Profile */
155 struct tm_shaper_profile {
156         TAILQ_ENTRY(tm_shaper_profile) node;
157         uint32_t shaper_profile_id;
158         uint32_t n_users;
159         struct rte_tm_shaper_params params;
160 };
161
162 TAILQ_HEAD(tm_shaper_profile_list, tm_shaper_profile);
163
164 /* TM Shared Shaper */
165 struct tm_shared_shaper {
166         TAILQ_ENTRY(tm_shared_shaper) node;
167         uint32_t shared_shaper_id;
168         uint32_t n_users;
169         uint32_t shaper_profile_id;
170 };
171
172 TAILQ_HEAD(tm_shared_shaper_list, tm_shared_shaper);
173
174 /* TM WRED Profile */
175 struct tm_wred_profile {
176         TAILQ_ENTRY(tm_wred_profile) node;
177         uint32_t wred_profile_id;
178         uint32_t n_users;
179         struct rte_tm_wred_params params;
180 };
181
182 TAILQ_HEAD(tm_wred_profile_list, tm_wred_profile);
183
184 /* TM Node */
185 struct tm_node {
186         TAILQ_ENTRY(tm_node) node;
187         uint32_t node_id;
188         uint32_t parent_node_id;
189         uint32_t priority;
190         uint32_t weight;
191         uint32_t level;
192         struct tm_node *parent_node;
193         struct tm_shaper_profile *shaper_profile;
194         struct tm_wred_profile *wred_profile;
195         struct rte_tm_node_params params;
196         struct rte_tm_node_stats stats;
197         uint32_t n_children;
198 };
199
200 TAILQ_HEAD(tm_node_list, tm_node);
201
202 /* TM Hierarchy Specification */
203 struct tm_hierarchy {
204         struct tm_shaper_profile_list shaper_profiles;
205         struct tm_shared_shaper_list shared_shapers;
206         struct tm_wred_profile_list wred_profiles;
207         struct tm_node_list nodes;
208
209         uint32_t n_shaper_profiles;
210         uint32_t n_shared_shapers;
211         uint32_t n_wred_profiles;
212         uint32_t n_nodes;
213
214         uint32_t n_tm_nodes[TM_NODE_LEVEL_MAX];
215 };
216
217 struct tm_internals {
218         /** Hierarchy specification
219          *
220          *     -Hierarchy is unfrozen at init and when port is stopped.
221          *     -Hierarchy is frozen on successful hierarchy commit.
222          *     -Run-time hierarchy changes are not allowed, therefore it makes
223          *      sense to keep the hierarchy frozen after the port is started.
224          */
225         struct tm_hierarchy h;
226         int hierarchy_frozen;
227
228         /** Blueprints */
229         struct tm_params params;
230 };
231
232 struct softnic_tmgr_port {
233         TAILQ_ENTRY(softnic_tmgr_port) node;
234         char name[NAME_SIZE];
235         struct rte_sched_port *s;
236 };
237
238 TAILQ_HEAD(softnic_tmgr_port_list, softnic_tmgr_port);
239
240 /**
241  * TAP
242  */
243 struct softnic_tap {
244         TAILQ_ENTRY(softnic_tap) node;
245         char name[NAME_SIZE];
246         int fd;
247 };
248
249 TAILQ_HEAD(softnic_tap_list, softnic_tap);
250
251 /**
252  * Input port action
253  */
254 struct softnic_port_in_action_profile_params {
255         uint64_t action_mask;
256         struct rte_port_in_action_fltr_config fltr;
257         struct rte_port_in_action_lb_config lb;
258 };
259
260 struct softnic_port_in_action_profile {
261         TAILQ_ENTRY(softnic_port_in_action_profile) node;
262         char name[NAME_SIZE];
263         struct softnic_port_in_action_profile_params params;
264         struct rte_port_in_action_profile *ap;
265 };
266
267 TAILQ_HEAD(softnic_port_in_action_profile_list, softnic_port_in_action_profile);
268
269 /**
270  * Table action
271  */
272 struct softnic_table_action_profile_params {
273         uint64_t action_mask;
274         struct rte_table_action_common_config common;
275         struct rte_table_action_lb_config lb;
276         struct rte_table_action_mtr_config mtr;
277         struct rte_table_action_tm_config tm;
278         struct rte_table_action_encap_config encap;
279         struct rte_table_action_nat_config nat;
280         struct rte_table_action_ttl_config ttl;
281         struct rte_table_action_stats_config stats;
282 };
283
284 struct softnic_table_action_profile {
285         TAILQ_ENTRY(softnic_table_action_profile) node;
286         char name[NAME_SIZE];
287         struct softnic_table_action_profile_params params;
288         struct rte_table_action_profile *ap;
289 };
290
291 TAILQ_HEAD(softnic_table_action_profile_list, softnic_table_action_profile);
292
293 /**
294  * Pipeline
295  */
296 struct pipeline_params {
297         uint32_t timer_period_ms;
298         uint32_t offset_port_id;
299 };
300
301 enum softnic_port_in_type {
302         PORT_IN_RXQ,
303         PORT_IN_SWQ,
304         PORT_IN_TMGR,
305         PORT_IN_TAP,
306         PORT_IN_SOURCE,
307 };
308
309 struct softnic_port_in_params {
310         /* Read */
311         enum softnic_port_in_type type;
312         char dev_name[NAME_SIZE];
313         union {
314                 struct {
315                         uint16_t queue_id;
316                 } rxq;
317
318                 struct {
319                         const char *mempool_name;
320                         uint32_t mtu;
321                 } tap;
322
323                 struct {
324                         const char *mempool_name;
325                         const char *file_name;
326                         uint32_t n_bytes_per_pkt;
327                 } source;
328         };
329         uint32_t burst_size;
330
331         /* Action */
332         char action_profile_name[NAME_SIZE];
333 };
334
335 enum softnic_port_out_type {
336         PORT_OUT_TXQ,
337         PORT_OUT_SWQ,
338         PORT_OUT_TMGR,
339         PORT_OUT_TAP,
340         PORT_OUT_SINK,
341 };
342
343 struct softnic_port_out_params {
344         enum softnic_port_out_type type;
345         char dev_name[NAME_SIZE];
346         union {
347                 struct {
348                         uint16_t queue_id;
349                 } txq;
350
351                 struct {
352                         const char *file_name;
353                         uint32_t max_n_pkts;
354                 } sink;
355         };
356         uint32_t burst_size;
357         int retry;
358         uint32_t n_retries;
359 };
360
361 enum softnic_table_type {
362         TABLE_ACL,
363         TABLE_ARRAY,
364         TABLE_HASH,
365         TABLE_LPM,
366         TABLE_STUB,
367 };
368
369 struct softnic_table_acl_params {
370         uint32_t n_rules;
371         uint32_t ip_header_offset;
372         int ip_version;
373 };
374
375 struct softnic_table_array_params {
376         uint32_t n_keys;
377         uint32_t key_offset;
378 };
379
380 #ifndef TABLE_RULE_MATCH_SIZE_MAX
381 #define TABLE_RULE_MATCH_SIZE_MAX                          256
382 #endif
383
384 struct softnic_table_hash_params {
385         uint32_t n_keys;
386         uint32_t key_offset;
387         uint32_t key_size;
388         uint8_t key_mask[TABLE_RULE_MATCH_SIZE_MAX];
389         uint32_t n_buckets;
390         int extendable_bucket;
391 };
392
393 struct softnic_table_lpm_params {
394         uint32_t n_rules;
395         uint32_t key_offset;
396         uint32_t key_size;
397 };
398
399 struct softnic_table_params {
400         /* Match */
401         enum softnic_table_type match_type;
402         union {
403                 struct softnic_table_acl_params acl;
404                 struct softnic_table_array_params array;
405                 struct softnic_table_hash_params hash;
406                 struct softnic_table_lpm_params lpm;
407         } match;
408
409         /* Action */
410         char action_profile_name[NAME_SIZE];
411 };
412
413 struct softnic_port_in {
414         struct softnic_port_in_params params;
415         struct softnic_port_in_action_profile *ap;
416         struct rte_port_in_action *a;
417 };
418
419 struct softnic_port_out {
420         struct softnic_port_out_params params;
421 };
422
423 struct softnic_table {
424         struct softnic_table_params params;
425         struct softnic_table_action_profile *ap;
426         struct rte_table_action *a;
427         struct flow_list flows;
428 };
429
430 struct pipeline {
431         TAILQ_ENTRY(pipeline) node;
432         char name[NAME_SIZE];
433
434         struct rte_pipeline *p;
435         struct pipeline_params params;
436         struct softnic_port_in port_in[RTE_PIPELINE_PORT_IN_MAX];
437         struct softnic_port_out port_out[RTE_PIPELINE_PORT_OUT_MAX];
438         struct softnic_table table[RTE_PIPELINE_TABLE_MAX];
439         uint32_t n_ports_in;
440         uint32_t n_ports_out;
441         uint32_t n_tables;
442
443         struct rte_ring *msgq_req;
444         struct rte_ring *msgq_rsp;
445         uint32_t timer_period_ms;
446
447         int enabled;
448         uint32_t thread_id;
449         uint32_t cpu_id;
450 };
451
452 TAILQ_HEAD(pipeline_list, pipeline);
453
454 /**
455  * Thread
456  */
457 #ifndef THREAD_PIPELINES_MAX
458 #define THREAD_PIPELINES_MAX                               256
459 #endif
460
461 #ifndef THREAD_MSGQ_SIZE
462 #define THREAD_MSGQ_SIZE                                   64
463 #endif
464
465 #ifndef THREAD_TIMER_PERIOD_MS
466 #define THREAD_TIMER_PERIOD_MS                             100
467 #endif
468
469 /**
470  * Master thead: data plane thread context
471  */
472 struct softnic_thread {
473         struct rte_ring *msgq_req;
474         struct rte_ring *msgq_rsp;
475
476         uint32_t enabled;
477 };
478
479 /**
480  * Data plane threads: context
481  */
482 #ifndef TABLE_RULE_ACTION_SIZE_MAX
483 #define TABLE_RULE_ACTION_SIZE_MAX                         2048
484 #endif
485
486 struct softnic_table_data {
487         struct rte_table_action *a;
488 };
489
490 struct pipeline_data {
491         struct rte_pipeline *p;
492         struct softnic_table_data table_data[RTE_PIPELINE_TABLE_MAX];
493         uint32_t n_tables;
494
495         struct rte_ring *msgq_req;
496         struct rte_ring *msgq_rsp;
497         uint64_t timer_period; /* Measured in CPU cycles. */
498         uint64_t time_next;
499
500         uint8_t buffer[TABLE_RULE_ACTION_SIZE_MAX];
501 };
502
503 struct softnic_thread_data {
504         struct rte_pipeline *p[THREAD_PIPELINES_MAX];
505         uint32_t n_pipelines;
506
507         struct pipeline_data pipeline_data[THREAD_PIPELINES_MAX];
508         struct rte_ring *msgq_req;
509         struct rte_ring *msgq_rsp;
510         uint64_t timer_period; /* Measured in CPU cycles. */
511         uint64_t time_next;
512         uint64_t time_next_min;
513         uint64_t iter;
514 } __rte_cache_aligned;
515
516 /**
517  * PMD Internals
518  */
519 struct pmd_internals {
520         /** Params */
521         struct pmd_params params;
522
523         struct {
524                 struct tm_internals tm; /**< Traffic Management */
525         } soft;
526
527         struct flow_internals flow;
528         struct softnic_conn *conn;
529         struct softnic_mempool_list mempool_list;
530         struct softnic_swq_list swq_list;
531         struct softnic_link_list link_list;
532         struct softnic_tmgr_port_list tmgr_port_list;
533         struct softnic_tap_list tap_list;
534         struct softnic_port_in_action_profile_list port_in_action_profile_list;
535         struct softnic_table_action_profile_list table_action_profile_list;
536         struct pipeline_list pipeline_list;
537         struct softnic_thread thread[RTE_MAX_LCORE];
538         struct softnic_thread_data thread_data[RTE_MAX_LCORE];
539 };
540
541 static inline struct rte_eth_dev *
542 ETHDEV(struct pmd_internals *softnic)
543 {
544         uint16_t port_id;
545         int status;
546
547         if (softnic == NULL)
548                 return NULL;
549
550         status = rte_eth_dev_get_port_by_name(softnic->params.name, &port_id);
551         if (status)
552                 return NULL;
553
554         return &rte_eth_devices[port_id];
555 }
556
557 /**
558  * Ethdev Flow API
559  */
560 int
561 flow_attr_map_set(struct pmd_internals *softnic,
562                 uint32_t group_id,
563                 int ingress,
564                 const char *pipeline_name,
565                 uint32_t table_id);
566
567 struct flow_attr_map *
568 flow_attr_map_get(struct pmd_internals *softnic,
569                 uint32_t group_id,
570                 int ingress);
571
572 extern const struct rte_flow_ops pmd_flow_ops;
573
574 /**
575  * MEMPOOL
576  */
577 int
578 softnic_mempool_init(struct pmd_internals *p);
579
580 void
581 softnic_mempool_free(struct pmd_internals *p);
582
583 struct softnic_mempool *
584 softnic_mempool_find(struct pmd_internals *p,
585         const char *name);
586
587 struct softnic_mempool *
588 softnic_mempool_create(struct pmd_internals *p,
589         const char *name,
590         struct softnic_mempool_params *params);
591
592 /**
593  * SWQ
594  */
595 int
596 softnic_swq_init(struct pmd_internals *p);
597
598 void
599 softnic_swq_free(struct pmd_internals *p);
600
601 void
602 softnic_softnic_swq_free_keep_rxq_txq(struct pmd_internals *p);
603
604 struct softnic_swq *
605 softnic_swq_find(struct pmd_internals *p,
606         const char *name);
607
608 struct softnic_swq *
609 softnic_swq_create(struct pmd_internals *p,
610         const char *name,
611         struct softnic_swq_params *params);
612
613 /**
614  * LINK
615  */
616 int
617 softnic_link_init(struct pmd_internals *p);
618
619 void
620 softnic_link_free(struct pmd_internals *p);
621
622 struct softnic_link *
623 softnic_link_find(struct pmd_internals *p,
624         const char *name);
625
626 struct softnic_link *
627 softnic_link_create(struct pmd_internals *p,
628         const char *name,
629         struct softnic_link_params *params);
630
631 /**
632  * TMGR
633  */
634 int
635 softnic_tmgr_init(struct pmd_internals *p);
636
637 void
638 softnic_tmgr_free(struct pmd_internals *p);
639
640 struct softnic_tmgr_port *
641 softnic_tmgr_port_find(struct pmd_internals *p,
642         const char *name);
643
644 struct softnic_tmgr_port *
645 softnic_tmgr_port_create(struct pmd_internals *p,
646         const char *name);
647
648 void
649 tm_hierarchy_init(struct pmd_internals *p);
650
651 void
652 tm_hierarchy_free(struct pmd_internals *p);
653
654 static inline int
655 tm_used(struct rte_eth_dev *dev)
656 {
657         struct pmd_internals *p = dev->data->dev_private;
658
659         return p->soft.tm.h.n_tm_nodes[TM_NODE_LEVEL_PORT];
660 }
661
662 extern const struct rte_tm_ops pmd_tm_ops;
663
664 /**
665  * TAP
666  */
667 int
668 softnic_tap_init(struct pmd_internals *p);
669
670 void
671 softnic_tap_free(struct pmd_internals *p);
672
673 struct softnic_tap *
674 softnic_tap_find(struct pmd_internals *p,
675         const char *name);
676
677 struct softnic_tap *
678 softnic_tap_create(struct pmd_internals *p,
679         const char *name);
680
681 /**
682  * Input port action
683  */
684 int
685 softnic_port_in_action_profile_init(struct pmd_internals *p);
686
687 void
688 softnic_port_in_action_profile_free(struct pmd_internals *p);
689
690 struct softnic_port_in_action_profile *
691 softnic_port_in_action_profile_find(struct pmd_internals *p,
692         const char *name);
693
694 struct softnic_port_in_action_profile *
695 softnic_port_in_action_profile_create(struct pmd_internals *p,
696         const char *name,
697         struct softnic_port_in_action_profile_params *params);
698
699 /**
700  * Table action
701  */
702 int
703 softnic_table_action_profile_init(struct pmd_internals *p);
704
705 void
706 softnic_table_action_profile_free(struct pmd_internals *p);
707
708 struct softnic_table_action_profile *
709 softnic_table_action_profile_find(struct pmd_internals *p,
710         const char *name);
711
712 struct softnic_table_action_profile *
713 softnic_table_action_profile_create(struct pmd_internals *p,
714         const char *name,
715         struct softnic_table_action_profile_params *params);
716
717 /**
718  * Pipeline
719  */
720 int
721 softnic_pipeline_init(struct pmd_internals *p);
722
723 void
724 softnic_pipeline_free(struct pmd_internals *p);
725
726 void
727 softnic_pipeline_disable_all(struct pmd_internals *p);
728
729 struct pipeline *
730 softnic_pipeline_find(struct pmd_internals *p, const char *name);
731
732 struct pipeline *
733 softnic_pipeline_create(struct pmd_internals *p,
734         const char *name,
735         struct pipeline_params *params);
736
737 int
738 softnic_pipeline_port_in_create(struct pmd_internals *p,
739         const char *pipeline_name,
740         struct softnic_port_in_params *params,
741         int enabled);
742
743 int
744 softnic_pipeline_port_in_connect_to_table(struct pmd_internals *p,
745         const char *pipeline_name,
746         uint32_t port_id,
747         uint32_t table_id);
748
749 int
750 softnic_pipeline_port_out_create(struct pmd_internals *p,
751         const char *pipeline_name,
752         struct softnic_port_out_params *params);
753
754 int
755 softnic_pipeline_port_out_find(struct pmd_internals *softnic,
756                 const char *pipeline_name,
757                 const char *name,
758                 uint32_t *port_id);
759
760 int
761 softnic_pipeline_table_create(struct pmd_internals *p,
762         const char *pipeline_name,
763         struct softnic_table_params *params);
764
765 struct softnic_table_rule_match_acl {
766         int ip_version;
767
768         RTE_STD_C11
769         union {
770                 struct {
771                         uint32_t sa;
772                         uint32_t da;
773                 } ipv4;
774
775                 struct {
776                         uint8_t sa[16];
777                         uint8_t da[16];
778                 } ipv6;
779         };
780
781         uint32_t sa_depth;
782         uint32_t da_depth;
783         uint16_t sp0;
784         uint16_t sp1;
785         uint16_t dp0;
786         uint16_t dp1;
787         uint8_t proto;
788         uint8_t proto_mask;
789         uint32_t priority;
790 };
791
792 struct softnic_table_rule_match_array {
793         uint32_t pos;
794 };
795
796 struct softnic_table_rule_match_hash {
797         uint8_t key[TABLE_RULE_MATCH_SIZE_MAX];
798 };
799
800 struct softnic_table_rule_match_lpm {
801         int ip_version;
802
803         RTE_STD_C11
804         union {
805                 uint32_t ipv4;
806                 uint8_t ipv6[16];
807         };
808
809         uint8_t depth;
810 };
811
812 struct softnic_table_rule_match {
813         enum softnic_table_type match_type;
814
815         union {
816                 struct softnic_table_rule_match_acl acl;
817                 struct softnic_table_rule_match_array array;
818                 struct softnic_table_rule_match_hash hash;
819                 struct softnic_table_rule_match_lpm lpm;
820         } match;
821 };
822
823 struct softnic_table_rule_action {
824         uint64_t action_mask;
825         struct rte_table_action_fwd_params fwd;
826         struct rte_table_action_lb_params lb;
827         struct rte_table_action_mtr_params mtr;
828         struct rte_table_action_tm_params tm;
829         struct rte_table_action_encap_params encap;
830         struct rte_table_action_nat_params nat;
831         struct rte_table_action_ttl_params ttl;
832         struct rte_table_action_stats_params stats;
833         struct rte_table_action_time_params time;
834 };
835
836 struct rte_flow {
837         TAILQ_ENTRY(rte_flow) node;
838         struct softnic_table_rule_match match;
839         struct softnic_table_rule_action action;
840         void *data;
841         struct pipeline *pipeline;
842         uint32_t table_id;
843 };
844
845 int
846 softnic_pipeline_port_in_stats_read(struct pmd_internals *p,
847         const char *pipeline_name,
848         uint32_t port_id,
849         struct rte_pipeline_port_in_stats *stats,
850         int clear);
851
852 int
853 softnic_pipeline_port_in_enable(struct pmd_internals *p,
854         const char *pipeline_name,
855         uint32_t port_id);
856
857 int
858 softnic_pipeline_port_in_disable(struct pmd_internals *p,
859         const char *pipeline_name,
860         uint32_t port_id);
861
862 int
863 softnic_pipeline_port_out_stats_read(struct pmd_internals *p,
864         const char *pipeline_name,
865         uint32_t port_id,
866         struct rte_pipeline_port_out_stats *stats,
867         int clear);
868
869 int
870 softnic_pipeline_table_stats_read(struct pmd_internals *p,
871         const char *pipeline_name,
872         uint32_t table_id,
873         struct rte_pipeline_table_stats *stats,
874         int clear);
875
876 int
877 softnic_pipeline_table_rule_add(struct pmd_internals *p,
878         const char *pipeline_name,
879         uint32_t table_id,
880         struct softnic_table_rule_match *match,
881         struct softnic_table_rule_action *action,
882         void **data);
883
884 int
885 softnic_pipeline_table_rule_add_bulk(struct pmd_internals *p,
886         const char *pipeline_name,
887         uint32_t table_id,
888         struct softnic_table_rule_match *match,
889         struct softnic_table_rule_action *action,
890         void **data,
891         uint32_t *n_rules);
892
893 int
894 softnic_pipeline_table_rule_add_default(struct pmd_internals *p,
895         const char *pipeline_name,
896         uint32_t table_id,
897         struct softnic_table_rule_action *action,
898         void **data);
899
900 int
901 softnic_pipeline_table_rule_delete(struct pmd_internals *p,
902         const char *pipeline_name,
903         uint32_t table_id,
904         struct softnic_table_rule_match *match);
905
906 int
907 softnic_pipeline_table_rule_delete_default(struct pmd_internals *p,
908         const char *pipeline_name,
909         uint32_t table_id);
910
911 int
912 softnic_pipeline_table_rule_stats_read(struct pmd_internals *p,
913         const char *pipeline_name,
914         uint32_t table_id,
915         void *data,
916         struct rte_table_action_stats_counters *stats,
917         int clear);
918
919 int
920 softnic_pipeline_table_mtr_profile_add(struct pmd_internals *p,
921         const char *pipeline_name,
922         uint32_t table_id,
923         uint32_t meter_profile_id,
924         struct rte_table_action_meter_profile *profile);
925
926 int
927 softnic_pipeline_table_mtr_profile_delete(struct pmd_internals *p,
928         const char *pipeline_name,
929         uint32_t table_id,
930         uint32_t meter_profile_id);
931
932 int
933 softnic_pipeline_table_rule_mtr_read(struct pmd_internals *p,
934         const char *pipeline_name,
935         uint32_t table_id,
936         void *data,
937         uint32_t tc_mask,
938         struct rte_table_action_mtr_counters *stats,
939         int clear);
940
941 int
942 softnic_pipeline_table_dscp_table_update(struct pmd_internals *p,
943         const char *pipeline_name,
944         uint32_t table_id,
945         uint64_t dscp_mask,
946         struct rte_table_action_dscp_table *dscp_table);
947
948 int
949 softnic_pipeline_table_rule_ttl_read(struct pmd_internals *p,
950         const char *pipeline_name,
951         uint32_t table_id,
952         void *data,
953         struct rte_table_action_ttl_counters *stats,
954         int clear);
955
956 /**
957  * Thread
958  */
959 int
960 softnic_thread_init(struct pmd_internals *p);
961
962 void
963 softnic_thread_free(struct pmd_internals *p);
964
965 int
966 softnic_thread_pipeline_enable(struct pmd_internals *p,
967         uint32_t thread_id,
968         const char *pipeline_name);
969
970 int
971 softnic_thread_pipeline_disable(struct pmd_internals *p,
972         uint32_t thread_id,
973         const char *pipeline_name);
974
975 /**
976  * CLI
977  */
978 void
979 softnic_cli_process(char *in,
980         char *out,
981         size_t out_size,
982         void *arg);
983
984 int
985 softnic_cli_script_process(struct pmd_internals *softnic,
986         const char *file_name,
987         size_t msg_in_len_max,
988         size_t msg_out_len_max);
989
990 #endif /* __INCLUDE_RTE_ETH_SOFTNIC_INTERNALS_H__ */