From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0641BA09F6; Fri, 18 Dec 2020 10:37:27 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EBD0BCAC8; Fri, 18 Dec 2020 10:34:52 +0100 (CET) Received: from smtpbgsg2.qq.com (smtpbgsg2.qq.com [54.254.200.128]) by dpdk.org (Postfix) with ESMTP id C1468CAAD for ; Fri, 18 Dec 2020 10:34:47 +0100 (CET) X-QQ-mid: bizesmtp28t1608284082tpihewb9 Received: from localhost.localdomain.com (unknown [183.129.236.74]) by esmtp10.qq.com (ESMTP) with id ; Fri, 18 Dec 2020 17:34:42 +0800 (CST) X-QQ-SSF: 01400000002000C0D000B00A0000000 X-QQ-FEAT: Ry58bBY793uY6wq+yhefwV6Gmi8IOuOfDcnjJmSLMP+Bkuon2it8WbVca/+Y4 5uqs3UZFe2r7F6kR4ypGcNJ7kVGR2MVgENpKVkR1hRisEsC/WBnjz+2TYinDxJj//XfZzkB t5EWQUQf6Opk14J8G3y7pk2p1aFW60tbRMOTr+ku7eGJOJ0XcP89imx9rsnvEAFUIrWR+zW VoD1Jm7xSJqSrHtKstvIn37lVc/DLEHyE6YHZeK6AbSUmmxmB7jDvWpCOBz1okmxfcYVfph rcqnk3Bz3oW3vMARBZ+jjGx5BGSr8lxzUIYI8slM3bFimwOuPZg1pZrx4DwA53+6UO1e6xQ N8GG9J1zOj6oj5XyHdmRG+AZXjQrQ== X-QQ-GoodBg: 2 From: Jiawen Wu To: dev@dpdk.org Cc: Jiawen Wu Date: Fri, 18 Dec 2020 17:36:38 +0800 Message-Id: <20201218093702.3651867-10-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201218093702.3651867-1-jiawenwu@trustnetic.com> References: <20201218093702.3651867-1-jiawenwu@trustnetic.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:trustnetic.com:qybgforeign:qybgforeign7 X-QQ-Bgrelay: 1 Subject: [dpdk-dev] [PATCH v3 09/33] net/txgbe: add L2 tunnel filter init and uninit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add L2 tunnel filter init and uninit. Signed-off-by: Jiawen Wu --- drivers/net/txgbe/txgbe_ethdev.c | 65 ++++++++++++++++++++++++++++++++ drivers/net/txgbe/txgbe_ethdev.h | 31 +++++++++++++++ 2 files changed, 96 insertions(+) diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c index e8362c07e..5f1ba8f2e 100644 --- a/drivers/net/txgbe/txgbe_ethdev.c +++ b/drivers/net/txgbe/txgbe_ethdev.c @@ -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); diff --git a/drivers/net/txgbe/txgbe_ethdev.h b/drivers/net/txgbe/txgbe_ethdev.h index 6f365eb99..63e263a85 100644 --- a/drivers/net/txgbe/txgbe_ethdev.h +++ b/drivers/net/txgbe/txgbe_ethdev.h @@ -13,6 +13,8 @@ #include #include #include +#include +#include /* 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) -- 2.18.2