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