DPDK  21.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 <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 #ifndef TM_MAX_PIPE_PROFILE
165 #define TM_MAX_PIPE_PROFILE 256
166 #endif
167 
168 #ifndef TM_MAX_SUBPORT_PROFILE
169 #define TM_MAX_SUBPORT_PROFILE 256
170 #endif
171 
172 struct tm_params {
173  struct rte_sched_port_params port_params;
174  struct rte_sched_subport_params subport_params[TM_MAX_SUBPORTS];
175  struct rte_sched_subport_profile_params
176  subport_profile[TM_MAX_SUBPORT_PROFILE];
177  uint32_t n_subport_profiles;
178  uint32_t subport_to_profile[TM_MAX_SUBPORT_PROFILE];
179  struct rte_sched_pipe_params pipe_profiles[TM_MAX_PIPE_PROFILE];
180  uint32_t n_pipe_profiles;
181  uint32_t pipe_to_profile[TM_MAX_SUBPORTS * TM_MAX_PIPES_PER_SUBPORT];
182 };
183 
184 /* TM Levels */
185 enum tm_node_level {
186  TM_NODE_LEVEL_PORT = 0,
187  TM_NODE_LEVEL_SUBPORT,
188  TM_NODE_LEVEL_PIPE,
189  TM_NODE_LEVEL_TC,
190  TM_NODE_LEVEL_QUEUE,
191  TM_NODE_LEVEL_MAX,
192 };
193 
194 /* TM Shaper Profile */
195 struct tm_shaper_profile {
196  TAILQ_ENTRY(tm_shaper_profile) node;
197  uint32_t shaper_profile_id;
198  uint32_t n_users;
199  struct rte_tm_shaper_params params;
200 };
201 
202 TAILQ_HEAD(tm_shaper_profile_list, tm_shaper_profile);
203 
204 /* TM Shared Shaper */
205 struct tm_shared_shaper {
206  TAILQ_ENTRY(tm_shared_shaper) node;
207  uint32_t shared_shaper_id;
208  uint32_t n_users;
209  uint32_t shaper_profile_id;
210 };
211 
212 TAILQ_HEAD(tm_shared_shaper_list, tm_shared_shaper);
213 
214 /* TM WRED Profile */
215 struct tm_wred_profile {
216  TAILQ_ENTRY(tm_wred_profile) node;
217  uint32_t wred_profile_id;
218  uint32_t n_users;
219  struct rte_tm_wred_params params;
220 };
221 
222 TAILQ_HEAD(tm_wred_profile_list, tm_wred_profile);
223 
224 /* TM Node */
225 struct tm_node {
226  TAILQ_ENTRY(tm_node) node;
227  uint32_t node_id;
228  uint32_t parent_node_id;
229  uint32_t priority;
230  uint32_t weight;
231  uint32_t level;
232  struct tm_node *parent_node;
233  struct tm_shaper_profile *shaper_profile;
234  struct tm_wred_profile *wred_profile;
235  struct rte_tm_node_params params;
236  struct rte_tm_node_stats stats;
237  uint32_t n_children;
238 };
239 
240 TAILQ_HEAD(tm_node_list, tm_node);
241 
242 /* TM Hierarchy Specification */
243 struct tm_hierarchy {
244  struct tm_shaper_profile_list shaper_profiles;
245  struct tm_shared_shaper_list shared_shapers;
246  struct tm_wred_profile_list wred_profiles;
247  struct tm_node_list nodes;
248 
249  uint32_t n_shaper_profiles;
250  uint32_t n_shared_shapers;
251  uint32_t n_wred_profiles;
252  uint32_t n_nodes;
253 
254  uint32_t n_tm_nodes[TM_NODE_LEVEL_MAX];
255 };
256 
257 struct tm_internals {
265  struct tm_hierarchy h;
266  int hierarchy_frozen;
267 
269  struct tm_params params;
270 };
271 
272 struct softnic_tmgr_port {
273  TAILQ_ENTRY(softnic_tmgr_port) node;
274  char name[NAME_SIZE];
275  struct rte_sched_port *s;
276 };
277 
278 TAILQ_HEAD(softnic_tmgr_port_list, softnic_tmgr_port);
279 
283 struct softnic_tap {
284  TAILQ_ENTRY(softnic_tap) node;
285  char name[NAME_SIZE];
286  int fd;
287 };
288 
289 TAILQ_HEAD(softnic_tap_list, softnic_tap);
290 
295  const char *dev_name;
296  uint32_t dev_id;
297  uint32_t n_queues;
298  uint32_t queue_size;
299  uint32_t session_pool_size;
300 };
301 
302 struct softnic_cryptodev {
303  TAILQ_ENTRY(softnic_cryptodev) node;
304  char name[NAME_SIZE];
305  uint16_t dev_id;
306  uint32_t n_queues;
307  struct rte_mempool *mp_create;
308  struct rte_mempool *mp_init;
309 };
310 
311 TAILQ_HEAD(softnic_cryptodev_list, softnic_cryptodev);
312 
317  uint64_t action_mask;
318  struct rte_port_in_action_fltr_config fltr;
320 };
321 
322 struct softnic_port_in_action_profile {
323  TAILQ_ENTRY(softnic_port_in_action_profile) node;
324  char name[NAME_SIZE];
326  struct rte_port_in_action_profile *ap;
327 };
328 
329 TAILQ_HEAD(softnic_port_in_action_profile_list, softnic_port_in_action_profile);
330 
335  uint64_t action_mask;
336  struct rte_table_action_common_config common;
337  struct rte_table_action_lb_config lb;
338  struct rte_table_action_mtr_config mtr;
339  struct rte_table_action_tm_config tm;
340  struct rte_table_action_encap_config encap;
341  struct rte_table_action_nat_config nat;
342  struct rte_table_action_ttl_config ttl;
343  struct rte_table_action_stats_config stats;
344  struct rte_table_action_sym_crypto_config sym_crypto;
345 };
346 
347 struct softnic_table_action_profile {
348  TAILQ_ENTRY(softnic_table_action_profile) node;
349  char name[NAME_SIZE];
351  struct rte_table_action_profile *ap;
352 };
353 
354 TAILQ_HEAD(softnic_table_action_profile_list, softnic_table_action_profile);
355 
356 struct softnic_table_meter_profile {
357  TAILQ_ENTRY(softnic_table_meter_profile) node;
358  uint32_t meter_profile_id;
359  struct rte_table_action_meter_profile profile;
360 };
361 
362 TAILQ_HEAD(softnic_table_meter_profile_list,
363  softnic_table_meter_profile);
364 
369  uint32_t timer_period_ms;
370  uint32_t offset_port_id;
371 };
372 
373 enum softnic_port_in_type {
374  PORT_IN_RXQ,
375  PORT_IN_SWQ,
376  PORT_IN_TMGR,
377  PORT_IN_TAP,
378  PORT_IN_SOURCE,
379  PORT_IN_CRYPTODEV,
380 };
381 
382 struct softnic_port_in_params {
383  /* Read */
384  enum softnic_port_in_type type;
385  char dev_name[NAME_SIZE];
386  union {
387  struct {
388  uint16_t queue_id;
389  } rxq;
390 
391  struct {
392  const char *mempool_name;
393  uint32_t mtu;
394  } tap;
395 
396  struct {
397  const char *mempool_name;
398  const char *file_name;
399  uint32_t n_bytes_per_pkt;
400  } source;
401 
402  struct {
403  uint16_t queue_id;
404  void *f_callback;
405  void *arg_callback;
406  } cryptodev;
407  };
408  uint32_t burst_size;
409 
410  /* Action */
411  char action_profile_name[NAME_SIZE];
412 };
413 
414 enum softnic_port_out_type {
415  PORT_OUT_TXQ,
416  PORT_OUT_SWQ,
417  PORT_OUT_TMGR,
418  PORT_OUT_TAP,
419  PORT_OUT_SINK,
420  PORT_OUT_CRYPTODEV,
421 };
422 
423 struct softnic_port_out_params {
424  enum softnic_port_out_type type;
425  char dev_name[NAME_SIZE];
426  union {
427  struct {
428  uint16_t queue_id;
429  } txq;
430 
431  struct {
432  const char *file_name;
433  uint32_t max_n_pkts;
434  } sink;
435 
436  struct {
437  uint16_t queue_id;
438  uint32_t op_offset;
439  } cryptodev;
440  };
441  uint32_t burst_size;
442  int retry;
443  uint32_t n_retries;
444 };
445 
446 enum softnic_table_type {
447  TABLE_ACL,
448  TABLE_ARRAY,
449  TABLE_HASH,
450  TABLE_LPM,
451  TABLE_STUB,
452 };
453 
454 struct softnic_table_acl_params {
455  uint32_t n_rules;
456  uint32_t ip_header_offset;
457  int ip_version;
458 };
459 
460 struct softnic_table_array_params {
461  uint32_t n_keys;
462  uint32_t key_offset;
463 };
464 
465 #ifndef TABLE_RULE_MATCH_SIZE_MAX
466 #define TABLE_RULE_MATCH_SIZE_MAX 256
467 #endif
468 
469 struct softnic_table_hash_params {
470  uint32_t n_keys;
471  uint32_t key_offset;
472  uint32_t key_size;
473  uint8_t key_mask[TABLE_RULE_MATCH_SIZE_MAX];
474  uint32_t n_buckets;
475  int extendable_bucket;
476 };
477 
478 struct softnic_table_lpm_params {
479  uint32_t n_rules;
480  uint32_t key_offset;
481  uint32_t key_size;
482 };
483 
484 struct softnic_table_params {
485  /* Match */
486  enum softnic_table_type match_type;
487  union {
488  struct softnic_table_acl_params acl;
489  struct softnic_table_array_params array;
490  struct softnic_table_hash_params hash;
491  struct softnic_table_lpm_params lpm;
492  } match;
493 
494  /* Action */
495  char action_profile_name[NAME_SIZE];
496 };
497 
498 struct softnic_port_in {
499  struct softnic_port_in_params params;
500  struct softnic_port_in_action_profile *ap;
501  struct rte_port_in_action *a;
502 };
503 
504 struct softnic_port_out {
505  struct softnic_port_out_params params;
506 };
507 
508 struct softnic_table {
509  struct softnic_table_params params;
510  struct softnic_table_action_profile *ap;
511  struct rte_table_action *a;
512  struct flow_list flows;
513  struct rte_table_action_dscp_table dscp_table;
514  struct softnic_table_meter_profile_list meter_profiles;
515 };
516 
517 struct pipeline {
518  TAILQ_ENTRY(pipeline) node;
519  char name[NAME_SIZE];
520 
521  struct rte_pipeline *p;
522  struct pipeline_params params;
523  struct softnic_port_in port_in[RTE_PIPELINE_PORT_IN_MAX];
524  struct softnic_port_out port_out[RTE_PIPELINE_PORT_OUT_MAX];
525  struct softnic_table table[RTE_PIPELINE_TABLE_MAX];
526  uint32_t n_ports_in;
527  uint32_t n_ports_out;
528  uint32_t n_tables;
529 
530  struct rte_ring *msgq_req;
531  struct rte_ring *msgq_rsp;
532  uint32_t timer_period_ms;
533 
534  int enabled;
535  uint32_t thread_id;
536  uint32_t cpu_id;
537 };
538 
539 TAILQ_HEAD(pipeline_list, pipeline);
540 
544 #ifndef THREAD_PIPELINES_MAX
545 #define THREAD_PIPELINES_MAX 256
546 #endif
547 
548 #ifndef THREAD_MSGQ_SIZE
549 #define THREAD_MSGQ_SIZE 64
550 #endif
551 
552 #ifndef THREAD_TIMER_PERIOD_MS
553 #define THREAD_TIMER_PERIOD_MS 100
554 #endif
555 
560  struct rte_ring *msgq_req;
561  struct rte_ring *msgq_rsp;
562 
563  uint32_t service_id;
564 };
565 
569 #ifndef TABLE_RULE_ACTION_SIZE_MAX
570 #define TABLE_RULE_ACTION_SIZE_MAX 2048
571 #endif
572 
573 struct softnic_table_data {
574  struct rte_table_action *a;
575 };
576 
577 struct pipeline_data {
578  struct rte_pipeline *p;
579  struct softnic_table_data table_data[RTE_PIPELINE_TABLE_MAX];
580  uint32_t n_tables;
581 
582  struct rte_ring *msgq_req;
583  struct rte_ring *msgq_rsp;
584  uint64_t timer_period; /* Measured in CPU cycles. */
585  uint64_t time_next;
586 
587  uint8_t buffer[TABLE_RULE_ACTION_SIZE_MAX];
588 };
589 
590 struct softnic_thread_data {
591  struct rte_pipeline *p[THREAD_PIPELINES_MAX];
592  uint32_t n_pipelines;
593 
594  struct pipeline_data pipeline_data[THREAD_PIPELINES_MAX];
595  struct rte_ring *msgq_req;
596  struct rte_ring *msgq_rsp;
597  uint64_t timer_period; /* Measured in CPU cycles. */
598  uint64_t time_next;
599  uint64_t time_next_min;
600  uint64_t iter;
602 
608  struct pmd_params params;
609 
610  struct {
611  struct tm_internals tm;
612  } soft;
613 
614  struct flow_internals flow;
615  struct mtr_internals mtr;
616 
617  struct softnic_conn *conn;
618  struct softnic_mempool_list mempool_list;
619  struct softnic_swq_list swq_list;
620  struct softnic_link_list link_list;
621  struct softnic_tmgr_port_list tmgr_port_list;
622  struct softnic_tap_list tap_list;
623  struct softnic_cryptodev_list cryptodev_list;
624  struct softnic_port_in_action_profile_list port_in_action_profile_list;
625  struct softnic_table_action_profile_list table_action_profile_list;
626  struct pipeline_list pipeline_list;
627  struct softnic_thread thread[RTE_MAX_LCORE];
628  struct softnic_thread_data thread_data[RTE_MAX_LCORE];
629 };
630 
631 static inline struct rte_eth_dev *
632 ETHDEV(struct pmd_internals *softnic)
633 {
634  uint16_t port_id;
635  int status;
636 
637  if (softnic == NULL)
638  return NULL;
639 
640  status = rte_eth_dev_get_port_by_name(softnic->params.name, &port_id);
641  if (status)
642  return NULL;
643 
644  return &rte_eth_devices[port_id];
645 }
646 
650 int
651 flow_attr_map_set(struct pmd_internals *softnic,
652  uint32_t group_id,
653  int ingress,
654  const char *pipeline_name,
655  uint32_t table_id);
656 
657 struct flow_attr_map *
658 flow_attr_map_get(struct pmd_internals *softnic,
659  uint32_t group_id,
660  int ingress);
661 
662 extern const struct rte_flow_ops pmd_flow_ops;
663 
667 int
668 softnic_mtr_init(struct pmd_internals *p);
669 
670 void
671 softnic_mtr_free(struct pmd_internals *p);
672 
673 struct softnic_mtr *
674 softnic_mtr_find(struct pmd_internals *p,
675  uint32_t mtr_id);
676 
678 softnic_mtr_meter_profile_find(struct pmd_internals *p,
679  uint32_t meter_profile_id);
680 
681 extern const struct rte_mtr_ops pmd_mtr_ops;
682 
686 int
687 softnic_mempool_init(struct pmd_internals *p);
688 
689 void
690 softnic_mempool_free(struct pmd_internals *p);
691 
692 struct softnic_mempool *
693 softnic_mempool_find(struct pmd_internals *p,
694  const char *name);
695 
696 struct softnic_mempool *
697 softnic_mempool_create(struct pmd_internals *p,
698  const char *name,
699  struct softnic_mempool_params *params);
700 
704 int
705 softnic_swq_init(struct pmd_internals *p);
706 
707 void
708 softnic_swq_free(struct pmd_internals *p);
709 
710 void
711 softnic_softnic_swq_free_keep_rxq_txq(struct pmd_internals *p);
712 
713 struct softnic_swq *
714 softnic_swq_find(struct pmd_internals *p,
715  const char *name);
716 
717 struct softnic_swq *
718 softnic_swq_create(struct pmd_internals *p,
719  const char *name,
720  struct softnic_swq_params *params);
721 
725 int
726 softnic_link_init(struct pmd_internals *p);
727 
728 void
729 softnic_link_free(struct pmd_internals *p);
730 
731 struct softnic_link *
732 softnic_link_find(struct pmd_internals *p,
733  const char *name);
734 
735 struct softnic_link *
736 softnic_link_create(struct pmd_internals *p,
737  const char *name,
738  struct softnic_link_params *params);
739 
743 int
744 softnic_tmgr_init(struct pmd_internals *p);
745 
746 void
747 softnic_tmgr_free(struct pmd_internals *p);
748 
749 struct softnic_tmgr_port *
750 softnic_tmgr_port_find(struct pmd_internals *p,
751  const char *name);
752 
753 struct softnic_tmgr_port *
754 softnic_tmgr_port_create(struct pmd_internals *p,
755  const char *name);
756 
757 void
758 tm_hierarchy_init(struct pmd_internals *p);
759 
760 void
761 tm_hierarchy_free(struct pmd_internals *p);
762 
763 static inline int
764 tm_used(struct rte_eth_dev *dev)
765 {
766  struct pmd_internals *p = dev->data->dev_private;
767 
768  return p->soft.tm.h.n_tm_nodes[TM_NODE_LEVEL_PORT];
769 }
770 
771 extern const struct rte_tm_ops pmd_tm_ops;
772 
776 int
777 softnic_tap_init(struct pmd_internals *p);
778 
779 void
780 softnic_tap_free(struct pmd_internals *p);
781 
782 struct softnic_tap *
783 softnic_tap_find(struct pmd_internals *p,
784  const char *name);
785 
786 struct softnic_tap *
787 softnic_tap_create(struct pmd_internals *p,
788  const char *name);
789 
793 int
794 softnic_cryptodev_init(struct pmd_internals *p);
795 
796 void
797 softnic_cryptodev_free(struct pmd_internals *p);
798 
799 struct softnic_cryptodev *
800 softnic_cryptodev_find(struct pmd_internals *p,
801  const char *name);
802 
803 struct softnic_cryptodev *
804 softnic_cryptodev_create(struct pmd_internals *p,
805  const char *name,
806  struct softnic_cryptodev_params *params);
807 
811 int
812 softnic_port_in_action_profile_init(struct pmd_internals *p);
813 
814 void
815 softnic_port_in_action_profile_free(struct pmd_internals *p);
816 
817 struct softnic_port_in_action_profile *
818 softnic_port_in_action_profile_find(struct pmd_internals *p,
819  const char *name);
820 
821 struct softnic_port_in_action_profile *
822 softnic_port_in_action_profile_create(struct pmd_internals *p,
823  const char *name,
825 
829 int
830 softnic_table_action_profile_init(struct pmd_internals *p);
831 
832 void
833 softnic_table_action_profile_free(struct pmd_internals *p);
834 
835 struct softnic_table_action_profile *
836 softnic_table_action_profile_find(struct pmd_internals *p,
837  const char *name);
838 
839 struct softnic_table_action_profile *
840 softnic_table_action_profile_create(struct pmd_internals *p,
841  const char *name,
842  struct softnic_table_action_profile_params *params);
843 
845 softnic_table_action_policer(enum rte_mtr_policer_action action);
846 
850 int
851 softnic_pipeline_init(struct pmd_internals *p);
852 
853 void
854 softnic_pipeline_free(struct pmd_internals *p);
855 
856 void
857 softnic_pipeline_disable_all(struct pmd_internals *p);
858 
859 uint32_t
860 softnic_pipeline_thread_count(struct pmd_internals *p, uint32_t thread_id);
861 
862 struct pipeline *
863 softnic_pipeline_find(struct pmd_internals *p, const char *name);
864 
865 struct pipeline *
866 softnic_pipeline_create(struct pmd_internals *p,
867  const char *name,
868  struct pipeline_params *params);
869 
870 int
871 softnic_pipeline_port_in_create(struct pmd_internals *p,
872  const char *pipeline_name,
873  struct softnic_port_in_params *params,
874  int enabled);
875 
876 int
877 softnic_pipeline_port_in_connect_to_table(struct pmd_internals *p,
878  const char *pipeline_name,
879  uint32_t port_id,
880  uint32_t table_id);
881 
882 int
883 softnic_pipeline_port_out_create(struct pmd_internals *p,
884  const char *pipeline_name,
885  struct softnic_port_out_params *params);
886 
887 int
888 softnic_pipeline_port_out_find(struct pmd_internals *softnic,
889  const char *pipeline_name,
890  const char *name,
891  uint32_t *port_id);
892 
893 int
894 softnic_pipeline_table_create(struct pmd_internals *p,
895  const char *pipeline_name,
896  struct softnic_table_params *params);
897 
898 struct softnic_table_meter_profile *
899 softnic_pipeline_table_meter_profile_find(struct softnic_table *table,
900  uint32_t meter_profile_id);
901 
902 struct softnic_table_rule_match_acl {
903  int ip_version;
904 
906  union {
907  struct {
908  uint32_t sa;
909  uint32_t da;
910  } ipv4;
911 
912  struct {
913  uint8_t sa[16];
914  uint8_t da[16];
915  } ipv6;
916  };
917 
918  uint32_t sa_depth;
919  uint32_t da_depth;
920  uint16_t sp0;
921  uint16_t sp1;
922  uint16_t dp0;
923  uint16_t dp1;
924  uint8_t proto;
925  uint8_t proto_mask;
926  uint32_t priority;
927 };
928 
929 struct softnic_table_rule_match_array {
930  uint32_t pos;
931 };
932 
933 struct softnic_table_rule_match_hash {
934  uint8_t key[TABLE_RULE_MATCH_SIZE_MAX];
935 };
936 
937 struct softnic_table_rule_match_lpm {
938  int ip_version;
939 
941  union {
942  uint32_t ipv4;
943  uint8_t ipv6[16];
944  };
945 
946  uint8_t depth;
947 };
948 
949 struct softnic_table_rule_match {
950  enum softnic_table_type match_type;
951 
952  union {
953  struct softnic_table_rule_match_acl acl;
954  struct softnic_table_rule_match_array array;
955  struct softnic_table_rule_match_hash hash;
956  struct softnic_table_rule_match_lpm lpm;
957  } match;
958 };
959 
960 #ifndef SYM_CRYPTO_MAX_KEY_SIZE
961 #define SYM_CRYPTO_MAX_KEY_SIZE (256)
962 #endif
963 struct softnic_table_rule_action {
964  uint64_t action_mask;
965  struct rte_table_action_fwd_params fwd;
966  struct rte_table_action_lb_params lb;
968  struct rte_table_action_tm_params tm;
969  struct rte_table_action_encap_params encap;
970  struct rte_table_action_nat_params nat;
971  struct rte_table_action_ttl_params ttl;
972  struct rte_table_action_stats_params stats;
975  struct rte_table_action_decap_params decap;
976  struct rte_table_action_sym_crypto_params sym_crypto;
977  uint8_t sym_crypto_key[SYM_CRYPTO_MAX_KEY_SIZE];
978 };
979 
980 struct rte_flow {
981  TAILQ_ENTRY(rte_flow) node;
982  struct softnic_table_rule_match match;
983  struct softnic_table_rule_action action;
984  void *data;
985  struct pipeline *pipeline;
986  uint32_t table_id;
987 };
988 
989 int
990 softnic_pipeline_port_in_stats_read(struct pmd_internals *p,
991  const char *pipeline_name,
992  uint32_t port_id,
993  struct rte_pipeline_port_in_stats *stats,
994  int clear);
995 
996 int
997 softnic_pipeline_port_in_enable(struct pmd_internals *p,
998  const char *pipeline_name,
999  uint32_t port_id);
1000 
1001 int
1002 softnic_pipeline_port_in_disable(struct pmd_internals *p,
1003  const char *pipeline_name,
1004  uint32_t port_id);
1005 
1006 int
1007 softnic_pipeline_port_out_stats_read(struct pmd_internals *p,
1008  const char *pipeline_name,
1009  uint32_t port_id,
1010  struct rte_pipeline_port_out_stats *stats,
1011  int clear);
1012 
1013 int
1014 softnic_pipeline_table_stats_read(struct pmd_internals *p,
1015  const char *pipeline_name,
1016  uint32_t table_id,
1017  struct rte_pipeline_table_stats *stats,
1018  int clear);
1019 
1020 int
1021 softnic_pipeline_table_rule_add(struct pmd_internals *p,
1022  const char *pipeline_name,
1023  uint32_t table_id,
1024  struct softnic_table_rule_match *match,
1025  struct softnic_table_rule_action *action,
1026  void **data);
1027 
1028 int
1029 softnic_pipeline_table_rule_add_bulk(struct pmd_internals *p,
1030  const char *pipeline_name,
1031  uint32_t table_id,
1032  struct softnic_table_rule_match *match,
1033  struct softnic_table_rule_action *action,
1034  void **data,
1035  uint32_t *n_rules);
1036 
1037 int
1038 softnic_pipeline_table_rule_add_default(struct pmd_internals *p,
1039  const char *pipeline_name,
1040  uint32_t table_id,
1041  struct softnic_table_rule_action *action,
1042  void **data);
1043 
1044 int
1045 softnic_pipeline_table_rule_delete(struct pmd_internals *p,
1046  const char *pipeline_name,
1047  uint32_t table_id,
1048  struct softnic_table_rule_match *match);
1049 
1050 int
1051 softnic_pipeline_table_rule_delete_default(struct pmd_internals *p,
1052  const char *pipeline_name,
1053  uint32_t table_id);
1054 
1055 int
1056 softnic_pipeline_table_rule_stats_read(struct pmd_internals *p,
1057  const char *pipeline_name,
1058  uint32_t table_id,
1059  void *data,
1060  struct rte_table_action_stats_counters *stats,
1061  int clear);
1062 
1063 int
1064 softnic_pipeline_table_mtr_profile_add(struct pmd_internals *p,
1065  const char *pipeline_name,
1066  uint32_t table_id,
1067  uint32_t meter_profile_id,
1068  struct rte_table_action_meter_profile *profile);
1069 
1070 int
1071 softnic_pipeline_table_mtr_profile_delete(struct pmd_internals *p,
1072  const char *pipeline_name,
1073  uint32_t table_id,
1074  uint32_t meter_profile_id);
1075 
1076 int
1077 softnic_pipeline_table_rule_mtr_read(struct pmd_internals *p,
1078  const char *pipeline_name,
1079  uint32_t table_id,
1080  void *data,
1081  uint32_t tc_mask,
1082  struct rte_table_action_mtr_counters *stats,
1083  int clear);
1084 
1085 int
1086 softnic_pipeline_table_dscp_table_update(struct pmd_internals *p,
1087  const char *pipeline_name,
1088  uint32_t table_id,
1089  uint64_t dscp_mask,
1090  struct rte_table_action_dscp_table *dscp_table);
1091 
1092 int
1093 softnic_pipeline_table_rule_ttl_read(struct pmd_internals *p,
1094  const char *pipeline_name,
1095  uint32_t table_id,
1096  void *data,
1097  struct rte_table_action_ttl_counters *stats,
1098  int clear);
1099 
1103 int
1104 softnic_thread_init(struct pmd_internals *p);
1105 
1106 void
1107 softnic_thread_free(struct pmd_internals *p);
1108 
1109 int
1110 softnic_thread_pipeline_enable(struct pmd_internals *p,
1111  uint32_t thread_id,
1112  const char *pipeline_name);
1113 
1114 int
1115 softnic_thread_pipeline_disable(struct pmd_internals *p,
1116  uint32_t thread_id,
1117  const char *pipeline_name);
1118 
1122 void
1123 softnic_cli_process(char *in,
1124  char *out,
1125  size_t out_size,
1126  void *arg);
1127 
1128 int
1129 softnic_cli_script_process(struct pmd_internals *softnic,
1130  const char *file_name,
1131  size_t msg_in_len_max,
1132  size_t msg_out_len_max);
1133 
1134 #endif /* __INCLUDE_RTE_ETH_SOFTNIC_INTERNALS_H__ */
rte_mtr_policer_action
Definition: rte_mtr.h:180
#define RTE_PIPELINE_TABLE_MAX
Definition: rte_pipeline.h:204
struct tm_internals tm
struct pmd_params params
rte_table_action_policer
struct pmd_params::@15 tm
int rte_eth_dev_get_port_by_name(const char *name, uint16_t *port_id)
#define __rte_cache_aligned
Definition: rte_common.h:400
#define RTE_STD_C11
Definition: rte_common.h:40
struct rte_table_action_mtr_tc_params mtr[RTE_TABLE_ACTION_TC_MAX]
#define RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
Definition: rte_sched.h:89
TAILQ_HEAD(vdev_driver_list, rte_vdev_driver)
#define RTE_PIPELINE_PORT_IN_MAX
Definition: rte_pipeline.h:537
#define RTE_PIPELINE_PORT_OUT_MAX
Definition: rte_pipeline.h:669