From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CE1E2A0524; Thu, 3 Jun 2021 01:59:01 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EBAF1410E7; Thu, 3 Jun 2021 01:58:55 +0200 (CEST) Received: from stargate.chelsio.com (stargate.chelsio.com [12.32.117.8]) by mails.dpdk.org (Postfix) with ESMTP id 972DD410EF for ; Thu, 3 Jun 2021 01:58:53 +0200 (CEST) Received: from localhost (scalar.blr.asicdesigners.com [10.193.185.94]) by stargate.chelsio.com (8.13.8/8.13.8) with ESMTP id 152NwpqF007563 for ; Wed, 2 Jun 2021 16:58:51 -0700 From: Rahul Lakkireddy To: dev@dpdk.org Date: Thu, 3 Jun 2021 03:27:51 +0530 Message-Id: <5ef2283e6487eecf8f421168fd3018854f7c0f45.1622676125.git.rahul.lakkireddy@chelsio.com> X-Mailer: git-send-email 2.5.3 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH 2/2] net/cxgbe: add MAC matchall to track promisc traffic X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" Chelsio T6 ASIC doesn't track Rx promisc traffic dropped due to lack of Rx buffers and hence the imissed counter doesn't increment. Add support for RAW MAC filter to insert a wildcard matchall rule at the end of MPS TCAM to make MPS track the promisc traffic. This rule will only be added/removed when promisc mode is turned on/off on the interface. Signed-off-by: Rahul Lakkireddy --- doc/guides/nics/cxgbe.rst | 14 ++--- drivers/net/cxgbe/base/common.h | 3 + drivers/net/cxgbe/base/t4fw_interface.h | 2 + drivers/net/cxgbe/cxgbe_ethdev.c | 14 +++++ drivers/net/cxgbe/cxgbe_main.c | 14 +++++ drivers/net/cxgbe/mps_tcam.c | 75 ++++++++++++++++++++++++- drivers/net/cxgbe/mps_tcam.h | 4 +- 7 files changed, 115 insertions(+), 11 deletions(-) diff --git a/doc/guides/nics/cxgbe.rst b/doc/guides/nics/cxgbe.rst index 4a8fef07b8..a1d30c488b 100644 --- a/doc/guides/nics/cxgbe.rst +++ b/doc/guides/nics/cxgbe.rst @@ -70,7 +70,7 @@ in :ref:`t5-nics` and :ref:`t6-nics`. Prerequisites ------------- -- Requires firmware version **1.25.4.0** and higher. Visit +- Requires firmware version **1.25.6.0** and higher. Visit `Chelsio Download Center `_ to get latest firmware bundled with the latest Chelsio Unified Wire package. @@ -404,7 +404,7 @@ Unified Wire package for Linux operating system are as follows: .. code-block:: console - firmware-version: 1.25.4.0, TP 0.1.23.2 + firmware-version: 1.25.6.0, TP 0.1.23.2 Running testpmd ~~~~~~~~~~~~~~~ @@ -462,7 +462,7 @@ devices managed by librte_net_cxgbe in Linux operating system. EAL: PCI memory mapped at 0x7fd7c0200000 EAL: PCI memory mapped at 0x7fd77cdfd000 EAL: PCI memory mapped at 0x7fd7c10b7000 - PMD: rte_cxgbe_pmd: fw: 1.25.4.0, TP: 0.1.23.2 + PMD: rte_cxgbe_pmd: fw: 1.25.6.0, TP: 0.1.23.2 PMD: rte_cxgbe_pmd: Coming up as MASTER: Initializing adapter Interactive-mode selected Configuring Port 0 (socket 0) @@ -568,7 +568,7 @@ virtual functions. [...] EAL: PCI device 0000:02:01.0 on NUMA socket 0 EAL: probe driver: 1425:5803 net_cxgbevf - PMD: rte_cxgbe_pmd: Firmware version: 1.25.4.0 + PMD: rte_cxgbe_pmd: Firmware version: 1.25.6.0 PMD: rte_cxgbe_pmd: TP Microcode version: 0.1.23.2 PMD: rte_cxgbe_pmd: Chelsio rev 0 PMD: rte_cxgbe_pmd: No bootstrap loaded @@ -576,7 +576,7 @@ virtual functions. PMD: rte_cxgbe_pmd: 0000:02:01.0 Chelsio rev 0 1G/10GBASE-SFP EAL: PCI device 0000:02:01.1 on NUMA socket 0 EAL: probe driver: 1425:5803 net_cxgbevf - PMD: rte_cxgbe_pmd: Firmware version: 1.25.4.0 + PMD: rte_cxgbe_pmd: Firmware version: 1.25.6.0 PMD: rte_cxgbe_pmd: TP Microcode version: 0.1.23.2 PMD: rte_cxgbe_pmd: Chelsio rev 0 PMD: rte_cxgbe_pmd: No bootstrap loaded @@ -654,7 +654,7 @@ Unified Wire package for FreeBSD operating system are as follows: .. code-block:: console - dev.t5nex.0.firmware_version: 1.25.4.0 + dev.t5nex.0.firmware_version: 1.25.6.0 Running testpmd ~~~~~~~~~~~~~~~ @@ -772,7 +772,7 @@ devices managed by librte_net_cxgbe in FreeBSD operating system. EAL: PCI memory mapped at 0x8007ec000 EAL: PCI memory mapped at 0x842800000 EAL: PCI memory mapped at 0x80086c000 - PMD: rte_cxgbe_pmd: fw: 1.25.4.0, TP: 0.1.23.2 + PMD: rte_cxgbe_pmd: fw: 1.25.6.0, TP: 0.1.23.2 PMD: rte_cxgbe_pmd: Coming up as MASTER: Initializing adapter Interactive-mode selected Configuring Port 0 (socket 0) diff --git a/drivers/net/cxgbe/base/common.h b/drivers/net/cxgbe/base/common.h index 2f8569cbbc..58d7d7a8f2 100644 --- a/drivers/net/cxgbe/base/common.h +++ b/drivers/net/cxgbe/base/common.h @@ -266,6 +266,9 @@ struct adapter_params { u32 viid_smt_extn_support:1; /* FW returns vin and smt index */ u32 max_tx_coalesce_num; /* Max # of Tx packets that can be coalesced */ u8 vi_enable_rx; /* FW support for enable/disable VI Rx at runtime */ + + u16 rawf_start; /* FW supports RAW MAC match-all filters */ + u16 rawf_size; }; /* Firmware Port Capabilities types. diff --git a/drivers/net/cxgbe/base/t4fw_interface.h b/drivers/net/cxgbe/base/t4fw_interface.h index 0310a7ce8b..a0a9292c0c 100644 --- a/drivers/net/cxgbe/base/t4fw_interface.h +++ b/drivers/net/cxgbe/base/t4fw_interface.h @@ -703,6 +703,8 @@ enum fw_params_param_dev { FW_PARAMS_PARAM_DEV_HASHFILTER_WITH_OFLD = 0x28, FW_PARAMS_PARAM_DEV_FILTER = 0x2E, FW_PARAMS_PARAM_DEV_VI_ENABLE_INGRESS_AFTER_LINKUP = 0x32, + FW_PARAMS_PARAM_PFVF_RAWF_START = 0x36, + FW_PARAMS_PARAM_PFVF_RAWF_END = 0x37, }; /* diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c index b88f80fd3e..550843b4d7 100644 --- a/drivers/net/cxgbe/cxgbe_ethdev.c +++ b/drivers/net/cxgbe/cxgbe_ethdev.c @@ -152,6 +152,13 @@ int cxgbe_dev_promiscuous_enable(struct rte_eth_dev *eth_dev) { struct port_info *pi = eth_dev->data->dev_private; struct adapter *adapter = pi->adapter; + int ret; + + if (adapter->params.rawf_size != 0) { + ret = cxgbe_mpstcam_rawf_enable(pi); + if (ret < 0) + return ret; + } return t4_set_rxmode(adapter, adapter->mbox, pi->viid, -1, 1, -1, 1, -1, false); @@ -161,6 +168,13 @@ int cxgbe_dev_promiscuous_disable(struct rte_eth_dev *eth_dev) { struct port_info *pi = eth_dev->data->dev_private; struct adapter *adapter = pi->adapter; + int ret; + + if (adapter->params.rawf_size != 0) { + ret = cxgbe_mpstcam_rawf_disable(pi); + if (ret < 0) + return ret; + } return t4_set_rxmode(adapter, adapter->mbox, pi->viid, -1, 0, -1, 1, -1, false); diff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c index b14ce283ed..6dd1bf1f83 100644 --- a/drivers/net/cxgbe/cxgbe_main.c +++ b/drivers/net/cxgbe/cxgbe_main.c @@ -1501,6 +1501,20 @@ static int adap_init0(struct adapter *adap) ret = t4_query_params(adap, adap->mbox, adap->pf, 0, 1, params, val); adap->params.vi_enable_rx = (ret == 0 && val[0] != 0); + /* Read the RAW MPS entries. In T6, the last 2 TCAM entries + * are reserved for RAW MAC addresses (rawf = 2, one per port). + */ + if (CHELSIO_CHIP_VERSION(adap->params.chip) > CHELSIO_T5) { + params[0] = CXGBE_FW_PARAM_PFVF(RAWF_START); + params[1] = CXGBE_FW_PARAM_PFVF(RAWF_END); + ret = t4_query_params(adap, adap->mbox, adap->pf, 0, 2, + params, val); + if (ret == 0) { + adap->params.rawf_start = val[0]; + adap->params.rawf_size = val[1] - val[0] + 1; + } + } + /* * The MTU/MSS Table is initialized by now, so load their values. If * we're initializing the adapter, then we'll make any modifications diff --git a/drivers/net/cxgbe/mps_tcam.c b/drivers/net/cxgbe/mps_tcam.c index 178921b701..abbf06e1a1 100644 --- a/drivers/net/cxgbe/mps_tcam.c +++ b/drivers/net/cxgbe/mps_tcam.c @@ -49,7 +49,8 @@ cxgbe_mpstcam_lookup(struct mpstcam_table *t, const u8 *eth_addr, return NULL; for (i = 0; i < t->size; i++) { - if (entry[i].state == MPS_ENTRY_UNUSED) + if (entry[i].state == MPS_ENTRY_UNUSED || + entry[i].state == MPS_ENTRY_RAWF) continue; /* entry is not being used */ if (match_entry(&entry[i], eth_addr, mask)) return &entry[i]; @@ -184,7 +185,7 @@ int cxgbe_mpstcam_remove(struct port_info *pi, u16 idx) return -EOPNOTSUPP; t4_os_write_lock(&t->lock); entry = &t->entry[idx]; - if (entry->state == MPS_ENTRY_UNUSED) { + if (entry->state != MPS_ENTRY_USED) { t4_os_write_unlock(&t->lock); return -EINVAL; } @@ -206,11 +207,73 @@ int cxgbe_mpstcam_remove(struct port_info *pi, u16 idx) return ret; } +int cxgbe_mpstcam_rawf_enable(struct port_info *pi) +{ + struct adapter *adap = pi->adapter; + struct mps_tcam_entry *entry; + struct mpstcam_table *t; + u16 rawf_idx; + int ret = 0; + + t = adap->mpstcam; + if (adap->params.rawf_size == 0 || t == NULL) + return -EOPNOTSUPP; + + t4_os_write_lock(&t->lock); + rawf_idx = adap->params.rawf_start + pi->port_id; + entry = &t->entry[rawf_idx]; + if (__atomic_load_n(&entry->refcnt, __ATOMIC_RELAXED) == 1) + goto out_unlock; + + ret = t4_alloc_raw_mac_filt(adap, pi->viid, entry->eth_addr, + entry->mask, rawf_idx, 0, pi->port_id, + false); + if (ret < 0) + goto out_unlock; + + __atomic_store_n(&entry->refcnt, 1, __ATOMIC_RELAXED); + +out_unlock: + t4_os_write_unlock(&t->lock); + return ret; +} + +int cxgbe_mpstcam_rawf_disable(struct port_info *pi) +{ + struct adapter *adap = pi->adapter; + struct mps_tcam_entry *entry; + struct mpstcam_table *t; + u16 rawf_idx; + int ret = 0; + + t = adap->mpstcam; + if (adap->params.rawf_size == 0 || t == NULL) + return -EOPNOTSUPP; + + t4_os_write_lock(&t->lock); + rawf_idx = adap->params.rawf_start + pi->port_id; + entry = &t->entry[rawf_idx]; + if (__atomic_load_n(&entry->refcnt, __ATOMIC_RELAXED) != 1) + goto out_unlock; + + ret = t4_free_raw_mac_filt(adap, pi->viid, entry->eth_addr, + entry->mask, rawf_idx, 0, pi->port_id, + false); + if (ret < 0) + goto out_unlock; + + __atomic_store_n(&entry->refcnt, 0, __ATOMIC_RELAXED); + +out_unlock: + t4_os_write_unlock(&t->lock); + return ret; +} + struct mpstcam_table *t4_init_mpstcam(struct adapter *adap) { + u16 size = adap->params.arch.mps_tcam_size; struct mpstcam_table *t; int i; - u16 size = adap->params.arch.mps_tcam_size; t = t4_os_alloc(sizeof(*t) + size * sizeof(struct mps_tcam_entry)); if (!t) @@ -226,6 +289,12 @@ struct mpstcam_table *t4_init_mpstcam(struct adapter *adap) t->entry[i].idx = i; } + /* RAW MAC entries are reserved for match-all wildcard to + * match all promiscuous traffic. So, mark them special. + */ + for (i = 0; i < adap->params.rawf_size; i++) + t->entry[adap->params.rawf_start + i].state = MPS_ENTRY_RAWF; + /* first entry is used by chip. this is overwritten only * in t4_cleanup_mpstcam() */ diff --git a/drivers/net/cxgbe/mps_tcam.h b/drivers/net/cxgbe/mps_tcam.h index 998c2b59df..a359f52442 100644 --- a/drivers/net/cxgbe/mps_tcam.h +++ b/drivers/net/cxgbe/mps_tcam.h @@ -17,6 +17,7 @@ enum { * for a specific entry */ MPS_ENTRY_USED, + MPS_ENTRY_RAWF, /* Reserved for RAW MAC Filters */ }; struct mps_tcam_entry { @@ -48,5 +49,6 @@ void t4_cleanup_mpstcam(struct adapter *adap); int cxgbe_mpstcam_alloc(struct port_info *pi, const u8 *mac, const u8 *mask); int cxgbe_mpstcam_remove(struct port_info *pi, u16 idx); int cxgbe_mpstcam_modify(struct port_info *pi, int idx, const u8 *addr); - +int cxgbe_mpstcam_rawf_enable(struct port_info *pi); +int cxgbe_mpstcam_rawf_disable(struct port_info *pi); #endif /* _CXGBE_MPSTCAM_H_ */ -- 2.27.0