5 #ifndef __INCLUDE_RTE_ETH_SOFTNIC_INTERNALS_H__
6 #define __INCLUDE_RTE_ETH_SOFTNIC_INTERNALS_H__
10 #include <sys/queue.h>
27 #include "rte_eth_softnic.h"
57 struct flow_attr_map {
58 char pipeline_name[NAME_SIZE];
63 #ifndef SOFTNIC_FLOW_MAX_GROUPS
64 #define SOFTNIC_FLOW_MAX_GROUPS 64
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];
79 uint32_t meter_profile_id;
88 TAILQ_ENTRY(softnic_mtr) node;
91 struct rte_flow *flow;
96 struct mtr_internals {
97 struct softnic_mtr_meter_profile_list meter_profiles;
98 struct softnic_mtr_list mtrs;
105 uint32_t buffer_size;
110 struct softnic_mempool {
111 TAILQ_ENTRY(softnic_mempool) node;
112 char name[NAME_SIZE];
114 uint32_t buffer_size;
117 TAILQ_HEAD(softnic_mempool_list, softnic_mempool);
127 TAILQ_ENTRY(softnic_swq) node;
128 char name[NAME_SIZE];
138 const char *dev_name;
142 struct softnic_link {
143 TAILQ_ENTRY(softnic_link) node;
144 char name[NAME_SIZE];
156 #ifndef TM_MAX_SUBPORTS
157 #define TM_MAX_SUBPORTS 8
160 #ifndef TM_MAX_PIPES_PER_SUBPORT
161 #define TM_MAX_PIPES_PER_SUBPORT 4096
167 struct rte_sched_subport_params subport_params[TM_MAX_SUBPORTS];
169 struct rte_sched_pipe_params
171 uint32_t n_pipe_profiles;
172 uint32_t pipe_to_profile[TM_MAX_SUBPORTS * TM_MAX_PIPES_PER_SUBPORT];
177 TM_NODE_LEVEL_PORT = 0,
178 TM_NODE_LEVEL_SUBPORT,
186 struct tm_shaper_profile {
187 TAILQ_ENTRY(tm_shaper_profile) node;
188 uint32_t shaper_profile_id;
193 TAILQ_HEAD(tm_shaper_profile_list, tm_shaper_profile);
196 struct tm_shared_shaper {
197 TAILQ_ENTRY(tm_shared_shaper) node;
198 uint32_t shared_shaper_id;
200 uint32_t shaper_profile_id;
203 TAILQ_HEAD(tm_shared_shaper_list, tm_shared_shaper);
206 struct tm_wred_profile {
207 TAILQ_ENTRY(tm_wred_profile) node;
208 uint32_t wred_profile_id;
213 TAILQ_HEAD(tm_wred_profile_list, tm_wred_profile);
217 TAILQ_ENTRY(tm_node) node;
219 uint32_t parent_node_id;
223 struct tm_node *parent_node;
224 struct tm_shaper_profile *shaper_profile;
225 struct tm_wred_profile *wred_profile;
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;
240 uint32_t n_shaper_profiles;
241 uint32_t n_shared_shapers;
242 uint32_t n_wred_profiles;
245 uint32_t n_tm_nodes[TM_NODE_LEVEL_MAX];
248 struct tm_internals {
256 struct tm_hierarchy h;
257 int hierarchy_frozen;
260 struct tm_params params;
263 struct softnic_tmgr_port {
264 TAILQ_ENTRY(softnic_tmgr_port) node;
265 char name[NAME_SIZE];
266 struct rte_sched_port *s;
269 TAILQ_HEAD(softnic_tmgr_port_list, softnic_tmgr_port);
275 TAILQ_ENTRY(softnic_tap) node;
276 char name[NAME_SIZE];
286 const char *dev_name;
290 uint32_t session_pool_size;
293 struct softnic_cryptodev {
294 TAILQ_ENTRY(softnic_cryptodev) node;
295 char name[NAME_SIZE];
302 TAILQ_HEAD(softnic_cryptodev_list, softnic_cryptodev);
308 uint64_t action_mask;
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;
320 TAILQ_HEAD(softnic_port_in_action_profile_list, softnic_port_in_action_profile);
326 uint64_t action_mask;
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;
345 TAILQ_HEAD(softnic_table_action_profile_list, softnic_table_action_profile);
347 struct softnic_table_meter_profile {
348 TAILQ_ENTRY(softnic_table_meter_profile) node;
349 uint32_t meter_profile_id;
354 softnic_table_meter_profile);
360 uint32_t timer_period_ms;
361 uint32_t offset_port_id;
364 enum softnic_port_in_type {
373 struct softnic_port_in_params {
375 enum softnic_port_in_type type;
376 char dev_name[NAME_SIZE];
383 const char *mempool_name;
388 const char *mempool_name;
389 const char *file_name;
390 uint32_t n_bytes_per_pkt;
402 char action_profile_name[NAME_SIZE];
405 enum softnic_port_out_type {
414 struct softnic_port_out_params {
415 enum softnic_port_out_type type;
416 char dev_name[NAME_SIZE];
423 const char *file_name;
437 enum softnic_table_type {
445 struct softnic_table_acl_params {
447 uint32_t ip_header_offset;
451 struct softnic_table_array_params {
456 #ifndef TABLE_RULE_MATCH_SIZE_MAX
457 #define TABLE_RULE_MATCH_SIZE_MAX 256
460 struct softnic_table_hash_params {
464 uint8_t key_mask[TABLE_RULE_MATCH_SIZE_MAX];
466 int extendable_bucket;
469 struct softnic_table_lpm_params {
475 struct softnic_table_params {
477 enum softnic_table_type match_type;
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;
486 char action_profile_name[NAME_SIZE];
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;
495 struct softnic_port_out {
496 struct softnic_port_out_params params;
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;
505 struct softnic_table_meter_profile_list meter_profiles;
509 TAILQ_ENTRY(pipeline) node;
510 char name[NAME_SIZE];
512 struct rte_pipeline *p;
518 uint32_t n_ports_out;
523 uint32_t timer_period_ms;
535 #ifndef THREAD_PIPELINES_MAX
536 #define THREAD_PIPELINES_MAX 256
539 #ifndef THREAD_MSGQ_SIZE
540 #define THREAD_MSGQ_SIZE 64
543 #ifndef THREAD_TIMER_PERIOD_MS
544 #define THREAD_TIMER_PERIOD_MS 100
560 #ifndef TABLE_RULE_ACTION_SIZE_MAX
561 #define TABLE_RULE_ACTION_SIZE_MAX 2048
564 struct softnic_table_data {
565 struct rte_table_action *a;
568 struct pipeline_data {
569 struct rte_pipeline *p;
570 struct softnic_table_data table_data[RTE_PIPELINE_TABLE_MAX];
575 uint64_t timer_period;
578 uint8_t buffer[TABLE_RULE_ACTION_SIZE_MAX];
581 struct softnic_thread_data {
582 struct rte_pipeline *p[THREAD_PIPELINES_MAX];
583 uint32_t n_pipelines;
585 struct pipeline_data pipeline_data[THREAD_PIPELINES_MAX];
588 uint64_t timer_period;
590 uint64_t time_next_min;
602 struct tm_internals tm;
605 struct flow_internals flow;
606 struct mtr_internals mtr;
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;
619 struct softnic_thread_data thread_data[RTE_MAX_LCORE];
622 static inline struct rte_eth_dev *
635 return &rte_eth_devices[port_id];
645 const char *pipeline_name,
648 struct flow_attr_map *
670 uint32_t meter_profile_id);
672 extern const struct rte_mtr_ops pmd_mtr_ops;
683 struct softnic_mempool *
687 struct softnic_mempool *
702 softnic_softnic_swq_free_keep_rxq_txq(
struct pmd_internals *p);
722 struct softnic_link *
726 struct softnic_link *
740 struct softnic_tmgr_port *
744 struct softnic_tmgr_port *
755 tm_used(
struct rte_eth_dev *dev)
759 return p->soft.
tm.h.n_tm_nodes[TM_NODE_LEVEL_PORT];
762 extern const struct rte_tm_ops pmd_tm_ops;
790 struct softnic_cryptodev *
794 struct softnic_cryptodev *
803 softnic_port_in_action_profile_init(
struct pmd_internals *p);
806 softnic_port_in_action_profile_free(
struct pmd_internals *p);
808 struct softnic_port_in_action_profile *
812 struct softnic_port_in_action_profile *
813 softnic_port_in_action_profile_create(
struct pmd_internals *p,
826 struct softnic_table_action_profile *
830 struct softnic_table_action_profile *
851 softnic_pipeline_thread_count(
struct pmd_internals *p, uint32_t thread_id);
854 softnic_pipeline_find(
struct pmd_internals *p,
const char *name);
863 const char *pipeline_name,
864 struct softnic_port_in_params *params,
868 softnic_pipeline_port_in_connect_to_table(
struct pmd_internals *p,
869 const char *pipeline_name,
875 const char *pipeline_name,
876 struct softnic_port_out_params *params);
879 softnic_pipeline_port_out_find(
struct pmd_internals *softnic,
880 const char *pipeline_name,
886 const char *pipeline_name,
887 struct softnic_table_params *params);
889 struct softnic_table_meter_profile *
890 softnic_pipeline_table_meter_profile_find(
struct softnic_table *table,
891 uint32_t meter_profile_id);
893 struct softnic_table_rule_match_acl {
920 struct softnic_table_rule_match_array {
924 struct softnic_table_rule_match_hash {
925 uint8_t key[TABLE_RULE_MATCH_SIZE_MAX];
928 struct softnic_table_rule_match_lpm {
940 struct softnic_table_rule_match {
941 enum softnic_table_type match_type;
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;
951 struct softnic_table_rule_action {
952 uint64_t action_mask;
968 TAILQ_ENTRY(rte_flow) node;
969 struct softnic_table_rule_match match;
970 struct softnic_table_rule_action action;
972 struct pipeline *pipeline;
978 const
char *pipeline_name,
985 const
char *pipeline_name,
990 const
char *pipeline_name,
994 softnic_pipeline_port_out_stats_read(struct
pmd_internals *p,
995 const
char *pipeline_name,
1002 const
char *pipeline_name,
1009 const
char *pipeline_name,
1011 struct softnic_table_rule_match *match,
1012 struct softnic_table_rule_action *action,
1016 softnic_pipeline_table_rule_add_bulk(struct
pmd_internals *p,
1017 const
char *pipeline_name,
1019 struct softnic_table_rule_match *match,
1020 struct softnic_table_rule_action *action,
1025 softnic_pipeline_table_rule_add_default(struct
pmd_internals *p,
1026 const
char *pipeline_name,
1028 struct softnic_table_rule_action *action,
1033 const
char *pipeline_name,
1035 struct softnic_table_rule_match *match);
1038 softnic_pipeline_table_rule_delete_default(struct
pmd_internals *p,
1039 const
char *pipeline_name,
1043 softnic_pipeline_table_rule_stats_read(struct
pmd_internals *p,
1044 const
char *pipeline_name,
1051 softnic_pipeline_table_mtr_profile_add(struct
pmd_internals *p,
1052 const
char *pipeline_name,
1054 uint32_t meter_profile_id,
1058 softnic_pipeline_table_mtr_profile_delete(struct
pmd_internals *p,
1059 const
char *pipeline_name,
1061 uint32_t meter_profile_id);
1064 softnic_pipeline_table_rule_mtr_read(struct
pmd_internals *p,
1065 const
char *pipeline_name,
1073 softnic_pipeline_table_dscp_table_update(struct
pmd_internals *p,
1074 const
char *pipeline_name,
1080 softnic_pipeline_table_rule_ttl_read(struct
pmd_internals *p,
1081 const
char *pipeline_name,
1099 const
char *pipeline_name);
1104 const
char *pipeline_name);
1110 softnic_cli_process(
char *in,
1117 const
char *file_name,
1118 size_t msg_in_len_max,
1119 size_t msg_out_len_max);