X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fsoftnic%2Frte_eth_softnic_internals.h;h=1c789420d4f8709f4e5e847cd67451d615315362;hb=bd2fbb6252f91afb0e5c35e248ad48d6d6e42733;hp=36dc24723b9caf062be67887e129c8ec8c91ce0d;hpb=dfcd81838cad25139cb0a67f6950505ffb426730;p=dpdk.git diff --git a/drivers/net/softnic/rte_eth_softnic_internals.h b/drivers/net/softnic/rte_eth_softnic_internals.h index 36dc24723b..1c789420d4 100644 --- a/drivers/net/softnic/rte_eth_softnic_internals.h +++ b/drivers/net/softnic/rte_eth_softnic_internals.h @@ -9,10 +9,15 @@ #include #include +#include #include #include #include #include +#include +#include +#include + #include #include @@ -36,6 +41,24 @@ struct pmd_params { } tm; }; +/** + * MEMPOOL + */ +struct softnic_mempool_params { + uint32_t buffer_size; + uint32_t pool_size; + uint32_t cache_size; +}; + +struct softnic_mempool { + TAILQ_ENTRY(softnic_mempool) node; + char name[NAME_SIZE]; + struct rte_mempool *m; + uint32_t buffer_size; +}; + +TAILQ_HEAD(softnic_mempool_list, softnic_mempool); + /** * SWQ */ @@ -70,7 +93,7 @@ struct softnic_link { TAILQ_HEAD(softnic_link_list, softnic_link); /** - * Traffic Management (TM) Internals + * TMGR */ #ifndef TM_MAX_SUBPORTS @@ -181,6 +204,279 @@ struct tm_internals { struct rte_sched_port *sched; }; +struct softnic_tmgr_port { + TAILQ_ENTRY(softnic_tmgr_port) node; + char name[NAME_SIZE]; + struct rte_sched_port *s; +}; + +TAILQ_HEAD(softnic_tmgr_port_list, softnic_tmgr_port); + +/** + * TAP + */ +struct softnic_tap { + TAILQ_ENTRY(softnic_tap) node; + char name[NAME_SIZE]; + int fd; +}; + +TAILQ_HEAD(softnic_tap_list, softnic_tap); + +/** + * Input port action + */ +struct softnic_port_in_action_profile_params { + uint64_t action_mask; + struct rte_port_in_action_fltr_config fltr; + struct rte_port_in_action_lb_config lb; +}; + +struct softnic_port_in_action_profile { + TAILQ_ENTRY(softnic_port_in_action_profile) node; + char name[NAME_SIZE]; + struct softnic_port_in_action_profile_params params; + struct rte_port_in_action_profile *ap; +}; + +TAILQ_HEAD(softnic_port_in_action_profile_list, softnic_port_in_action_profile); + +/** + * Table action + */ +struct softnic_table_action_profile_params { + uint64_t action_mask; + struct rte_table_action_common_config common; + struct rte_table_action_lb_config lb; + struct rte_table_action_mtr_config mtr; + struct rte_table_action_tm_config tm; + struct rte_table_action_encap_config encap; + struct rte_table_action_nat_config nat; + struct rte_table_action_ttl_config ttl; + struct rte_table_action_stats_config stats; +}; + +struct softnic_table_action_profile { + TAILQ_ENTRY(softnic_table_action_profile) node; + char name[NAME_SIZE]; + struct softnic_table_action_profile_params params; + struct rte_table_action_profile *ap; +}; + +TAILQ_HEAD(softnic_table_action_profile_list, softnic_table_action_profile); + +/** + * Pipeline + */ +struct pipeline_params { + uint32_t timer_period_ms; + uint32_t offset_port_id; +}; + +enum softnic_port_in_type { + PORT_IN_RXQ, + PORT_IN_SWQ, + PORT_IN_TMGR, + PORT_IN_TAP, + PORT_IN_SOURCE, +}; + +struct softnic_port_in_params { + /* Read */ + enum softnic_port_in_type type; + const char *dev_name; + union { + struct { + uint16_t queue_id; + } rxq; + + struct { + const char *mempool_name; + uint32_t mtu; + } tap; + + struct { + const char *mempool_name; + const char *file_name; + uint32_t n_bytes_per_pkt; + } source; + }; + uint32_t burst_size; + + /* Action */ + const char *action_profile_name; +}; + +enum softnic_port_out_type { + PORT_OUT_TXQ, + PORT_OUT_SWQ, + PORT_OUT_TMGR, + PORT_OUT_TAP, + PORT_OUT_SINK, +}; + +struct softnic_port_out_params { + enum softnic_port_out_type type; + const char *dev_name; + union { + struct { + uint16_t queue_id; + } txq; + + struct { + const char *file_name; + uint32_t max_n_pkts; + } sink; + }; + uint32_t burst_size; + int retry; + uint32_t n_retries; +}; + +enum softnic_table_type { + TABLE_ACL, + TABLE_ARRAY, + TABLE_HASH, + TABLE_LPM, + TABLE_STUB, +}; + +struct softnic_table_acl_params { + uint32_t n_rules; + uint32_t ip_header_offset; + int ip_version; +}; + +struct softnic_table_array_params { + uint32_t n_keys; + uint32_t key_offset; +}; + +struct softnic_table_hash_params { + uint32_t n_keys; + uint32_t key_offset; + uint32_t key_size; + uint8_t *key_mask; + uint32_t n_buckets; + int extendable_bucket; +}; + +struct softnic_table_lpm_params { + uint32_t n_rules; + uint32_t key_offset; + uint32_t key_size; +}; + +struct softnic_table_params { + /* Match */ + enum softnic_table_type match_type; + union { + struct softnic_table_acl_params acl; + struct softnic_table_array_params array; + struct softnic_table_hash_params hash; + struct softnic_table_lpm_params lpm; + } match; + + /* Action */ + const char *action_profile_name; +}; + +struct softnic_port_in { + struct softnic_port_in_params params; + struct softnic_port_in_action_profile *ap; + struct rte_port_in_action *a; +}; + +struct softnic_table { + struct softnic_table_params params; + struct softnic_table_action_profile *ap; + struct rte_table_action *a; +}; + +struct pipeline { + TAILQ_ENTRY(pipeline) node; + char name[NAME_SIZE]; + + struct rte_pipeline *p; + struct softnic_port_in port_in[RTE_PIPELINE_PORT_IN_MAX]; + struct softnic_table table[RTE_PIPELINE_TABLE_MAX]; + uint32_t n_ports_in; + uint32_t n_ports_out; + uint32_t n_tables; + + struct rte_ring *msgq_req; + struct rte_ring *msgq_rsp; + uint32_t timer_period_ms; + + int enabled; + uint32_t thread_id; + uint32_t cpu_id; +}; + +TAILQ_HEAD(pipeline_list, pipeline); + +/** + * Thread + */ +#ifndef THREAD_PIPELINES_MAX +#define THREAD_PIPELINES_MAX 256 +#endif + +#ifndef THREAD_MSGQ_SIZE +#define THREAD_MSGQ_SIZE 64 +#endif + +#ifndef THREAD_TIMER_PERIOD_MS +#define THREAD_TIMER_PERIOD_MS 100 +#endif + +/** + * Master thead: data plane thread context + */ +struct softnic_thread { + struct rte_ring *msgq_req; + struct rte_ring *msgq_rsp; + + uint32_t enabled; +}; + +/** + * Data plane threads: context + */ +#ifndef TABLE_RULE_ACTION_SIZE_MAX +#define TABLE_RULE_ACTION_SIZE_MAX 2048 +#endif + +struct softnic_table_data { + struct rte_table_action *a; +}; + +struct pipeline_data { + struct rte_pipeline *p; + struct softnic_table_data table_data[RTE_PIPELINE_TABLE_MAX]; + uint32_t n_tables; + + struct rte_ring *msgq_req; + struct rte_ring *msgq_rsp; + uint64_t timer_period; /* Measured in CPU cycles. */ + uint64_t time_next; + + uint8_t buffer[TABLE_RULE_ACTION_SIZE_MAX]; +}; + +struct softnic_thread_data { + struct rte_pipeline *p[THREAD_PIPELINES_MAX]; + uint32_t n_pipelines; + + struct pipeline_data pipeline_data[THREAD_PIPELINES_MAX]; + struct rte_ring *msgq_req; + struct rte_ring *msgq_rsp; + uint64_t timer_period; /* Measured in CPU cycles. */ + uint64_t time_next; + uint64_t time_next_min; + uint64_t iter; +} __rte_cache_aligned; + /** * PMD Internals */ @@ -188,15 +484,40 @@ struct pmd_internals { /** Params */ struct pmd_params params; - /** Soft device */ struct { struct tm_internals tm; /**< Traffic Management */ } soft; + struct softnic_mempool_list mempool_list; struct softnic_swq_list swq_list; struct softnic_link_list link_list; + struct softnic_tmgr_port_list tmgr_port_list; + struct softnic_tap_list tap_list; + struct softnic_port_in_action_profile_list port_in_action_profile_list; + struct softnic_table_action_profile_list table_action_profile_list; + struct pipeline_list pipeline_list; + struct softnic_thread thread[RTE_MAX_LCORE]; + struct softnic_thread_data thread_data[RTE_MAX_LCORE]; }; +/** + * MEMPOOL + */ +int +softnic_mempool_init(struct pmd_internals *p); + +void +softnic_mempool_free(struct pmd_internals *p); + +struct softnic_mempool * +softnic_mempool_find(struct pmd_internals *p, + const char *name); + +struct softnic_mempool * +softnic_mempool_create(struct pmd_internals *p, + const char *name, + struct softnic_mempool_params *params); + /** * SWQ */ @@ -234,12 +555,25 @@ softnic_link_create(struct pmd_internals *p, struct softnic_link_params *params); /** - * Traffic Management (TM) Operation + * TMGR */ -extern const struct rte_tm_ops pmd_tm_ops; +int +softnic_tmgr_init(struct pmd_internals *p); + +void +softnic_tmgr_free(struct pmd_internals *p); + +struct softnic_tmgr_port * +softnic_tmgr_port_find(struct pmd_internals *p, + const char *name); + +struct softnic_tmgr_port * +softnic_tmgr_port_create(struct pmd_internals *p, + const char *name, + struct rte_sched_port *sched); int -tm_init(struct pmd_internals *p, struct pmd_params *params, int numa_node); +tm_init(struct pmd_internals *p); void tm_free(struct pmd_internals *p); @@ -251,9 +585,114 @@ void tm_stop(struct pmd_internals *p); static inline int -tm_used(struct rte_eth_dev *dev __rte_unused) +tm_used(struct rte_eth_dev *dev) { - return 0; + struct pmd_internals *p = dev->data->dev_private; + + return p->soft.tm.h.n_tm_nodes[TM_NODE_LEVEL_PORT]; } +extern const struct rte_tm_ops pmd_tm_ops; + +/** + * TAP + */ +int +softnic_tap_init(struct pmd_internals *p); + +void +softnic_tap_free(struct pmd_internals *p); + +struct softnic_tap * +softnic_tap_find(struct pmd_internals *p, + const char *name); + +struct softnic_tap * +softnic_tap_create(struct pmd_internals *p, + const char *name); + +/** + * Input port action + */ +int +softnic_port_in_action_profile_init(struct pmd_internals *p); + +void +softnic_port_in_action_profile_free(struct pmd_internals *p); + +struct softnic_port_in_action_profile * +softnic_port_in_action_profile_find(struct pmd_internals *p, + const char *name); + +struct softnic_port_in_action_profile * +softnic_port_in_action_profile_create(struct pmd_internals *p, + const char *name, + struct softnic_port_in_action_profile_params *params); + +/** + * Table action + */ +int +softnic_table_action_profile_init(struct pmd_internals *p); + +void +softnic_table_action_profile_free(struct pmd_internals *p); + +struct softnic_table_action_profile * +softnic_table_action_profile_find(struct pmd_internals *p, + const char *name); + +struct softnic_table_action_profile * +softnic_table_action_profile_create(struct pmd_internals *p, + const char *name, + struct softnic_table_action_profile_params *params); + +/** + * Pipeline + */ +int +softnic_pipeline_init(struct pmd_internals *p); + +void +softnic_pipeline_free(struct pmd_internals *p); + +struct pipeline * +softnic_pipeline_find(struct pmd_internals *p, const char *name); + +struct pipeline * +softnic_pipeline_create(struct pmd_internals *p, + const char *name, + struct pipeline_params *params); + +int +softnic_pipeline_port_in_create(struct pmd_internals *p, + const char *pipeline_name, + struct softnic_port_in_params *params, + int enabled); + +int +softnic_pipeline_port_in_connect_to_table(struct pmd_internals *p, + const char *pipeline_name, + uint32_t port_id, + uint32_t table_id); + +int +softnic_pipeline_port_out_create(struct pmd_internals *p, + const char *pipeline_name, + struct softnic_port_out_params *params); + +int +softnic_pipeline_table_create(struct pmd_internals *p, + const char *pipeline_name, + struct softnic_table_params *params); + +/** + * Thread + */ +int +softnic_thread_init(struct pmd_internals *p); + +void +softnic_thread_free(struct pmd_internals *p); + #endif /* __INCLUDE_RTE_ETH_SOFTNIC_INTERNALS_H__ */