Add filter list init and uninit. Signed-off-by: Jiawen Wu <jiawe...@trustnetic.com> --- drivers/net/txgbe/txgbe_ethdev.c | 6 ++ drivers/net/txgbe/txgbe_ethdev.h | 8 ++ drivers/net/txgbe/txgbe_flow.c | 127 +++++++++++++++++++++++++++++++ 3 files changed, 141 insertions(+)
diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c index 2983b63a2..bffccb822 100644 --- a/drivers/net/txgbe/txgbe_ethdev.c +++ b/drivers/net/txgbe/txgbe_ethdev.c @@ -698,6 +698,9 @@ eth_txgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused) /* initialize l2 tunnel filter list & hash */ txgbe_l2_tn_filter_init(eth_dev); + /* initialize flow filter lists */ + txgbe_filterlist_init(); + /* initialize bandwidth configuration info */ memset(bw_conf, 0, sizeof(struct txgbe_bw_conf)); @@ -1941,6 +1944,9 @@ txgbe_dev_close(struct rte_eth_dev *dev) /* Remove all ntuple filters of the device */ txgbe_ntuple_filter_uninit(dev); + /* clear all the filters list */ + txgbe_filterlist_flush(); + return ret; } diff --git a/drivers/net/txgbe/txgbe_ethdev.h b/drivers/net/txgbe/txgbe_ethdev.h index b8fc605a7..ceecb746f 100644 --- a/drivers/net/txgbe/txgbe_ethdev.h +++ b/drivers/net/txgbe/txgbe_ethdev.h @@ -263,6 +263,11 @@ struct txgbe_l2_tn_info { uint16_t e_tag_ether_type; /* ether type for e-tag */ }; +struct rte_flow { + enum rte_filter_type filter_type; + void *rule; +}; + /* The configuration of bandwidth */ struct txgbe_bw_conf { uint8_t tc_num; /* Number of TCs. */ @@ -448,6 +453,9 @@ txgbe_dev_l2_tunnel_filter_add(struct rte_eth_dev *dev, int txgbe_dev_l2_tunnel_filter_del(struct rte_eth_dev *dev, struct txgbe_l2_tunnel_conf *l2_tunnel); +void txgbe_filterlist_init(void); +void txgbe_filterlist_flush(void); + void txgbe_set_ivar_map(struct txgbe_hw *hw, int8_t direction, uint8_t queue, uint8_t msix_vector); diff --git a/drivers/net/txgbe/txgbe_flow.c b/drivers/net/txgbe/txgbe_flow.c index 0d90ef33a..77e025863 100644 --- a/drivers/net/txgbe/txgbe_flow.c +++ b/drivers/net/txgbe/txgbe_flow.c @@ -16,6 +16,7 @@ #include <rte_cycles.h> #include <rte_bus_pci.h> +#include <rte_malloc.h> #include <rte_hash_crc.h> #include <rte_flow.h> #include <rte_flow_driver.h> @@ -29,6 +30,58 @@ #define TXGBE_MAX_N_TUPLE_PRIO 7 #define TXGBE_MAX_FLX_SOURCE_OFF 62 +/* ntuple filter list structure */ +struct txgbe_ntuple_filter_ele { + TAILQ_ENTRY(txgbe_ntuple_filter_ele) entries; + struct rte_eth_ntuple_filter filter_info; +}; +/* ethertype filter list structure */ +struct txgbe_ethertype_filter_ele { + TAILQ_ENTRY(txgbe_ethertype_filter_ele) entries; + struct rte_eth_ethertype_filter filter_info; +}; +/* syn filter list structure */ +struct txgbe_eth_syn_filter_ele { + TAILQ_ENTRY(txgbe_eth_syn_filter_ele) entries; + struct rte_eth_syn_filter filter_info; +}; +/* fdir filter list structure */ +struct txgbe_fdir_rule_ele { + TAILQ_ENTRY(txgbe_fdir_rule_ele) entries; + struct txgbe_fdir_rule filter_info; +}; +/* l2_tunnel filter list structure */ +struct txgbe_eth_l2_tunnel_conf_ele { + TAILQ_ENTRY(txgbe_eth_l2_tunnel_conf_ele) entries; + struct txgbe_l2_tunnel_conf filter_info; +}; +/* rss filter list structure */ +struct txgbe_rss_conf_ele { + TAILQ_ENTRY(txgbe_rss_conf_ele) entries; + struct txgbe_rte_flow_rss_conf filter_info; +}; +/* txgbe_flow memory list structure */ +struct txgbe_flow_mem { + TAILQ_ENTRY(txgbe_flow_mem) entries; + struct rte_flow *flow; +}; + +TAILQ_HEAD(txgbe_ntuple_filter_list, txgbe_ntuple_filter_ele); +TAILQ_HEAD(txgbe_ethertype_filter_list, txgbe_ethertype_filter_ele); +TAILQ_HEAD(txgbe_syn_filter_list, txgbe_eth_syn_filter_ele); +TAILQ_HEAD(txgbe_fdir_rule_filter_list, txgbe_fdir_rule_ele); +TAILQ_HEAD(txgbe_l2_tunnel_filter_list, txgbe_eth_l2_tunnel_conf_ele); +TAILQ_HEAD(txgbe_rss_filter_list, txgbe_rss_conf_ele); +TAILQ_HEAD(txgbe_flow_mem_list, txgbe_flow_mem); + +static struct txgbe_ntuple_filter_list filter_ntuple_list; +static struct txgbe_ethertype_filter_list filter_ethertype_list; +static struct txgbe_syn_filter_list filter_syn_list; +static struct txgbe_fdir_rule_filter_list filter_fdir_list; +static struct txgbe_l2_tunnel_filter_list filter_l2_tunnel_list; +static struct txgbe_rss_filter_list filter_rss_list; +static struct txgbe_flow_mem_list txgbe_flow_list; + /** * Endless loop will never happen with below assumption * 1. there is at least one no-void item(END) @@ -2502,3 +2555,77 @@ txgbe_parse_rss_filter(struct rte_eth_dev *dev, return 0; } +void +txgbe_filterlist_init(void) +{ + TAILQ_INIT(&filter_ntuple_list); + TAILQ_INIT(&filter_ethertype_list); + TAILQ_INIT(&filter_syn_list); + TAILQ_INIT(&filter_fdir_list); + TAILQ_INIT(&filter_l2_tunnel_list); + TAILQ_INIT(&filter_rss_list); + TAILQ_INIT(&txgbe_flow_list); +} + +void +txgbe_filterlist_flush(void) +{ + struct txgbe_ntuple_filter_ele *ntuple_filter_ptr; + struct txgbe_ethertype_filter_ele *ethertype_filter_ptr; + struct txgbe_eth_syn_filter_ele *syn_filter_ptr; + struct txgbe_eth_l2_tunnel_conf_ele *l2_tn_filter_ptr; + struct txgbe_fdir_rule_ele *fdir_rule_ptr; + struct txgbe_flow_mem *txgbe_flow_mem_ptr; + struct txgbe_rss_conf_ele *rss_filter_ptr; + + while ((ntuple_filter_ptr = TAILQ_FIRST(&filter_ntuple_list))) { + TAILQ_REMOVE(&filter_ntuple_list, + ntuple_filter_ptr, + entries); + rte_free(ntuple_filter_ptr); + } + + while ((ethertype_filter_ptr = TAILQ_FIRST(&filter_ethertype_list))) { + TAILQ_REMOVE(&filter_ethertype_list, + ethertype_filter_ptr, + entries); + rte_free(ethertype_filter_ptr); + } + + while ((syn_filter_ptr = TAILQ_FIRST(&filter_syn_list))) { + TAILQ_REMOVE(&filter_syn_list, + syn_filter_ptr, + entries); + rte_free(syn_filter_ptr); + } + + while ((l2_tn_filter_ptr = TAILQ_FIRST(&filter_l2_tunnel_list))) { + TAILQ_REMOVE(&filter_l2_tunnel_list, + l2_tn_filter_ptr, + entries); + rte_free(l2_tn_filter_ptr); + } + + while ((fdir_rule_ptr = TAILQ_FIRST(&filter_fdir_list))) { + TAILQ_REMOVE(&filter_fdir_list, + fdir_rule_ptr, + entries); + rte_free(fdir_rule_ptr); + } + + while ((rss_filter_ptr = TAILQ_FIRST(&filter_rss_list))) { + TAILQ_REMOVE(&filter_rss_list, + rss_filter_ptr, + entries); + rte_free(rss_filter_ptr); + } + + while ((txgbe_flow_mem_ptr = TAILQ_FIRST(&txgbe_flow_list))) { + TAILQ_REMOVE(&txgbe_flow_list, + txgbe_flow_mem_ptr, + entries); + rte_free(txgbe_flow_mem_ptr->flow); + rte_free(txgbe_flow_mem_ptr); + } +} + -- 2.18.4