net/softnic: implement start and stop
[dpdk.git] / drivers / net / softnic / rte_eth_softnic_internals.h
index 52da1ae..4738cf3 100644 (file)
@@ -22,6 +22,7 @@
 #include <rte_tm_driver.h>
 
 #include "rte_eth_softnic.h"
+#include "conn.h"
 
 #define NAME_SIZE                                            64
 
@@ -32,6 +33,7 @@
 struct pmd_params {
        const char *name;
        const char *firmware;
+       uint16_t conn_port;
        uint32_t cpu_id;
 
        /** Traffic Management (TM) */
@@ -415,10 +417,68 @@ struct pipeline {
 
 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
  */
@@ -430,6 +490,7 @@ struct pmd_internals {
                struct tm_internals tm; /**< Traffic Management */
        } soft;
 
+       struct softnic_conn *conn;
        struct softnic_mempool_list mempool_list;
        struct softnic_swq_list swq_list;
        struct softnic_link_list link_list;
@@ -438,6 +499,8 @@ struct pmd_internals {
        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];
 };
 
 /**
@@ -467,6 +530,9 @@ softnic_swq_init(struct pmd_internals *p);
 void
 softnic_swq_free(struct pmd_internals *p);
 
+void
+softnic_softnic_swq_free_keep_rxq_txq(struct pmd_internals *p);
+
 struct softnic_swq *
 softnic_swq_find(struct pmd_internals *p,
        const char *name);
@@ -596,6 +662,9 @@ softnic_pipeline_init(struct pmd_internals *p);
 void
 softnic_pipeline_free(struct pmd_internals *p);
 
+void
+softnic_pipeline_disable_all(struct pmd_internals *p);
+
 struct pipeline *
 softnic_pipeline_find(struct pmd_internals *p, const char *name);
 
@@ -626,4 +695,224 @@ softnic_pipeline_table_create(struct pmd_internals *p,
        const char *pipeline_name,
        struct softnic_table_params *params);
 
+struct softnic_table_rule_match_acl {
+       int ip_version;
+
+       RTE_STD_C11
+       union {
+               struct {
+                       uint32_t sa;
+                       uint32_t da;
+               } ipv4;
+
+               struct {
+                       uint8_t sa[16];
+                       uint8_t da[16];
+               } ipv6;
+       };
+
+       uint32_t sa_depth;
+       uint32_t da_depth;
+       uint16_t sp0;
+       uint16_t sp1;
+       uint16_t dp0;
+       uint16_t dp1;
+       uint8_t proto;
+       uint8_t proto_mask;
+       uint32_t priority;
+};
+
+struct softnic_table_rule_match_array {
+       uint32_t pos;
+};
+
+#ifndef TABLE_RULE_MATCH_SIZE_MAX
+#define TABLE_RULE_MATCH_SIZE_MAX                          256
+#endif
+
+struct softnic_table_rule_match_hash {
+       uint8_t key[TABLE_RULE_MATCH_SIZE_MAX];
+};
+
+struct softnic_table_rule_match_lpm {
+       int ip_version;
+
+       RTE_STD_C11
+       union {
+               uint32_t ipv4;
+               uint8_t ipv6[16];
+       };
+
+       uint8_t depth;
+};
+
+struct softnic_table_rule_match {
+       enum softnic_table_type match_type;
+
+       union {
+               struct softnic_table_rule_match_acl acl;
+               struct softnic_table_rule_match_array array;
+               struct softnic_table_rule_match_hash hash;
+               struct softnic_table_rule_match_lpm lpm;
+       } match;
+};
+
+struct softnic_table_rule_action {
+       uint64_t action_mask;
+       struct rte_table_action_fwd_params fwd;
+       struct rte_table_action_lb_params lb;
+       struct rte_table_action_mtr_params mtr;
+       struct rte_table_action_tm_params tm;
+       struct rte_table_action_encap_params encap;
+       struct rte_table_action_nat_params nat;
+       struct rte_table_action_ttl_params ttl;
+       struct rte_table_action_stats_params stats;
+       struct rte_table_action_time_params time;
+};
+
+int
+softnic_pipeline_port_in_stats_read(struct pmd_internals *p,
+       const char *pipeline_name,
+       uint32_t port_id,
+       struct rte_pipeline_port_in_stats *stats,
+       int clear);
+
+int
+softnic_pipeline_port_in_enable(struct pmd_internals *p,
+       const char *pipeline_name,
+       uint32_t port_id);
+
+int
+softnic_pipeline_port_in_disable(struct pmd_internals *p,
+       const char *pipeline_name,
+       uint32_t port_id);
+
+int
+softnic_pipeline_port_out_stats_read(struct pmd_internals *p,
+       const char *pipeline_name,
+       uint32_t port_id,
+       struct rte_pipeline_port_out_stats *stats,
+       int clear);
+
+int
+softnic_pipeline_table_stats_read(struct pmd_internals *p,
+       const char *pipeline_name,
+       uint32_t table_id,
+       struct rte_pipeline_table_stats *stats,
+       int clear);
+
+int
+softnic_pipeline_table_rule_add(struct pmd_internals *p,
+       const char *pipeline_name,
+       uint32_t table_id,
+       struct softnic_table_rule_match *match,
+       struct softnic_table_rule_action *action,
+       void **data);
+
+int
+softnic_pipeline_table_rule_add_bulk(struct pmd_internals *p,
+       const char *pipeline_name,
+       uint32_t table_id,
+       struct softnic_table_rule_match *match,
+       struct softnic_table_rule_action *action,
+       void **data,
+       uint32_t *n_rules);
+
+int
+softnic_pipeline_table_rule_add_default(struct pmd_internals *p,
+       const char *pipeline_name,
+       uint32_t table_id,
+       struct softnic_table_rule_action *action,
+       void **data);
+
+int
+softnic_pipeline_table_rule_delete(struct pmd_internals *p,
+       const char *pipeline_name,
+       uint32_t table_id,
+       struct softnic_table_rule_match *match);
+
+int
+softnic_pipeline_table_rule_delete_default(struct pmd_internals *p,
+       const char *pipeline_name,
+       uint32_t table_id);
+
+int
+softnic_pipeline_table_rule_stats_read(struct pmd_internals *p,
+       const char *pipeline_name,
+       uint32_t table_id,
+       void *data,
+       struct rte_table_action_stats_counters *stats,
+       int clear);
+
+int
+softnic_pipeline_table_mtr_profile_add(struct pmd_internals *p,
+       const char *pipeline_name,
+       uint32_t table_id,
+       uint32_t meter_profile_id,
+       struct rte_table_action_meter_profile *profile);
+
+int
+softnic_pipeline_table_mtr_profile_delete(struct pmd_internals *p,
+       const char *pipeline_name,
+       uint32_t table_id,
+       uint32_t meter_profile_id);
+
+int
+softnic_pipeline_table_rule_mtr_read(struct pmd_internals *p,
+       const char *pipeline_name,
+       uint32_t table_id,
+       void *data,
+       uint32_t tc_mask,
+       struct rte_table_action_mtr_counters *stats,
+       int clear);
+
+int
+softnic_pipeline_table_dscp_table_update(struct pmd_internals *p,
+       const char *pipeline_name,
+       uint32_t table_id,
+       uint64_t dscp_mask,
+       struct rte_table_action_dscp_table *dscp_table);
+
+int
+softnic_pipeline_table_rule_ttl_read(struct pmd_internals *p,
+       const char *pipeline_name,
+       uint32_t table_id,
+       void *data,
+       struct rte_table_action_ttl_counters *stats,
+       int clear);
+
+/**
+ * Thread
+ */
+int
+softnic_thread_init(struct pmd_internals *p);
+
+void
+softnic_thread_free(struct pmd_internals *p);
+
+int
+softnic_thread_pipeline_enable(struct pmd_internals *p,
+       uint32_t thread_id,
+       const char *pipeline_name);
+
+int
+softnic_thread_pipeline_disable(struct pmd_internals *p,
+       uint32_t thread_id,
+       const char *pipeline_name);
+
+/**
+ * CLI
+ */
+void
+softnic_cli_process(char *in,
+       char *out,
+       size_t out_size,
+       void *arg);
+
+int
+softnic_cli_script_process(struct pmd_internals *softnic,
+       const char *file_name,
+       size_t msg_in_len_max,
+       size_t msg_out_len_max);
+
 #endif /* __INCLUDE_RTE_ETH_SOFTNIC_INTERNALS_H__ */