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