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