net/txgbe: add L2 tunnel filter init and uninit
Add L2 tunnel filter init and uninit. Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
This commit is contained in:
parent
1bdc587a25
commit
c13f84a71b
@ -88,6 +88,8 @@ static const struct reg_info *txgbe_regs_others[] = {
|
||||
txgbe_regs_diagnostic,
|
||||
NULL};
|
||||
|
||||
static int txgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev);
|
||||
static int txgbe_l2_tn_filter_uninit(struct rte_eth_dev *eth_dev);
|
||||
static int txgbe_dev_set_link_up(struct rte_eth_dev *dev);
|
||||
static int txgbe_dev_set_link_down(struct rte_eth_dev *dev);
|
||||
static int txgbe_dev_close(struct rte_eth_dev *dev);
|
||||
@ -687,6 +689,9 @@ eth_txgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)
|
||||
/* initialize 5tuple filter list */
|
||||
TAILQ_INIT(&filter_info->fivetuple_list);
|
||||
|
||||
/* initialize l2 tunnel filter list & hash */
|
||||
txgbe_l2_tn_filter_init(eth_dev);
|
||||
|
||||
/* initialize bandwidth configuration info */
|
||||
memset(bw_conf, 0, sizeof(struct txgbe_bw_conf));
|
||||
|
||||
@ -723,6 +728,63 @@ static int txgbe_ntuple_filter_uninit(struct rte_eth_dev *eth_dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int txgbe_l2_tn_filter_uninit(struct rte_eth_dev *eth_dev)
|
||||
{
|
||||
struct txgbe_l2_tn_info *l2_tn_info = TXGBE_DEV_L2_TN(eth_dev);
|
||||
struct txgbe_l2_tn_filter *l2_tn_filter;
|
||||
|
||||
if (l2_tn_info->hash_map)
|
||||
rte_free(l2_tn_info->hash_map);
|
||||
if (l2_tn_info->hash_handle)
|
||||
rte_hash_free(l2_tn_info->hash_handle);
|
||||
|
||||
while ((l2_tn_filter = TAILQ_FIRST(&l2_tn_info->l2_tn_list))) {
|
||||
TAILQ_REMOVE(&l2_tn_info->l2_tn_list,
|
||||
l2_tn_filter,
|
||||
entries);
|
||||
rte_free(l2_tn_filter);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int txgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev)
|
||||
{
|
||||
struct txgbe_l2_tn_info *l2_tn_info = TXGBE_DEV_L2_TN(eth_dev);
|
||||
char l2_tn_hash_name[RTE_HASH_NAMESIZE];
|
||||
struct rte_hash_parameters l2_tn_hash_params = {
|
||||
.name = l2_tn_hash_name,
|
||||
.entries = TXGBE_MAX_L2_TN_FILTER_NUM,
|
||||
.key_len = sizeof(struct txgbe_l2_tn_key),
|
||||
.hash_func = rte_hash_crc,
|
||||
.hash_func_init_val = 0,
|
||||
.socket_id = rte_socket_id(),
|
||||
};
|
||||
|
||||
TAILQ_INIT(&l2_tn_info->l2_tn_list);
|
||||
snprintf(l2_tn_hash_name, RTE_HASH_NAMESIZE,
|
||||
"l2_tn_%s", TDEV_NAME(eth_dev));
|
||||
l2_tn_info->hash_handle = rte_hash_create(&l2_tn_hash_params);
|
||||
if (!l2_tn_info->hash_handle) {
|
||||
PMD_INIT_LOG(ERR, "Failed to create L2 TN hash table!");
|
||||
return -EINVAL;
|
||||
}
|
||||
l2_tn_info->hash_map = rte_zmalloc("txgbe",
|
||||
sizeof(struct txgbe_l2_tn_filter *) *
|
||||
TXGBE_MAX_L2_TN_FILTER_NUM,
|
||||
0);
|
||||
if (!l2_tn_info->hash_map) {
|
||||
PMD_INIT_LOG(ERR,
|
||||
"Failed to allocate memory for L2 TN hash map!");
|
||||
return -ENOMEM;
|
||||
}
|
||||
l2_tn_info->e_tag_en = FALSE;
|
||||
l2_tn_info->e_tag_fwd_en = FALSE;
|
||||
l2_tn_info->e_tag_ether_type = RTE_ETHER_TYPE_ETAG;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
eth_txgbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
|
||||
struct rte_pci_device *pci_dev)
|
||||
@ -1802,6 +1864,9 @@ txgbe_dev_close(struct rte_eth_dev *dev)
|
||||
rte_free(dev->data->hash_mac_addrs);
|
||||
dev->data->hash_mac_addrs = NULL;
|
||||
|
||||
/* remove all the L2 tunnel filters & hash */
|
||||
txgbe_l2_tn_filter_uninit(dev);
|
||||
|
||||
/* Remove all ntuple filters of the device */
|
||||
txgbe_ntuple_filter_uninit(dev);
|
||||
|
||||
|
@ -13,6 +13,8 @@
|
||||
#include <rte_time.h>
|
||||
#include <rte_ethdev.h>
|
||||
#include <rte_ethdev_core.h>
|
||||
#include <rte_hash.h>
|
||||
#include <rte_hash_crc.h>
|
||||
|
||||
/* need update link, bit flag */
|
||||
#define TXGBE_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)
|
||||
@ -59,6 +61,8 @@
|
||||
#define TXGBE_MISC_VEC_ID RTE_INTR_VEC_ZERO_OFFSET
|
||||
#define TXGBE_RX_VEC_START RTE_INTR_VEC_RXTX_OFFSET
|
||||
|
||||
#define TXGBE_MAX_L2_TN_FILTER_NUM 128
|
||||
|
||||
/* structure for interrupt relative data */
|
||||
struct txgbe_interrupt {
|
||||
uint32_t flags;
|
||||
@ -171,6 +175,28 @@ struct txgbe_filter_info {
|
||||
uint32_t syn_info;
|
||||
};
|
||||
|
||||
struct txgbe_l2_tn_key {
|
||||
enum rte_eth_tunnel_type l2_tn_type;
|
||||
uint32_t tn_id;
|
||||
};
|
||||
|
||||
struct txgbe_l2_tn_filter {
|
||||
TAILQ_ENTRY(txgbe_l2_tn_filter) entries;
|
||||
struct txgbe_l2_tn_key key;
|
||||
uint32_t pool;
|
||||
};
|
||||
|
||||
TAILQ_HEAD(txgbe_l2_tn_filter_list, txgbe_l2_tn_filter);
|
||||
|
||||
struct txgbe_l2_tn_info {
|
||||
struct txgbe_l2_tn_filter_list l2_tn_list;
|
||||
struct txgbe_l2_tn_filter **hash_map;
|
||||
struct rte_hash *hash_handle;
|
||||
bool e_tag_en; /* e-tag enabled */
|
||||
bool e_tag_fwd_en; /* e-tag based forwarding enabled */
|
||||
uint16_t e_tag_ether_type; /* ether type for e-tag */
|
||||
};
|
||||
|
||||
/* The configuration of bandwidth */
|
||||
struct txgbe_bw_conf {
|
||||
uint8_t tc_num; /* Number of TCs. */
|
||||
@ -191,6 +217,7 @@ struct txgbe_adapter {
|
||||
struct txgbe_vf_info *vfdata;
|
||||
struct txgbe_uta_info uta_info;
|
||||
struct txgbe_filter_info filter;
|
||||
struct txgbe_l2_tn_info l2_tn;
|
||||
struct txgbe_bw_conf bw_conf;
|
||||
bool rx_bulk_alloc_allowed;
|
||||
struct rte_timecounter systime_tc;
|
||||
@ -236,6 +263,10 @@ struct txgbe_adapter {
|
||||
|
||||
#define TXGBE_DEV_FILTER(dev) \
|
||||
(&((struct txgbe_adapter *)(dev)->data->dev_private)->filter)
|
||||
|
||||
#define TXGBE_DEV_L2_TN(dev) \
|
||||
(&((struct txgbe_adapter *)(dev)->data->dev_private)->l2_tn)
|
||||
|
||||
#define TXGBE_DEV_BW_CONF(dev) \
|
||||
(&((struct txgbe_adapter *)(dev)->data->dev_private)->bw_conf)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user