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 8E0EAA034F; Mon, 7 Jun 2021 20:07:35 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 982F1411BC; Mon, 7 Jun 2021 20:04:55 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 5023F411A7 for ; Mon, 7 Jun 2021 20:04:54 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 157I1aHw017508 for ; Mon, 7 Jun 2021 11:04:53 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=wHBI0rP3eA/A3DUQqPaCeubHs+3kiAlCSSfkgZRoMkc=; b=IuG/tGlp9pQqk43vxnUApNW87c0zBP3i2doZd1Py/qoXmCEX4LvUOEs8DOpky4BpmW64 vLs8EuGO8QjomAnf0OZyg6dsh58tsihqcxx1poqI1OqXOHQtfpXtZpR/v5YgUpHN3qrI hKoloAyn12+PN8iv93ZEAuVr/23DIgcwUrSViEZo3+Svlldulcq/lDEOtPV7sKZ0iGd1 FUj1CsRAX1fHDseXVqsEe7D7Ic1Jir6nXegAnAYxQXzn7+AQ9c4urRvJjuu78NAYa2TA ixtK7TSNh9VaVeaS1uuvaeb6ZkxsTgCL7znedD4VQgwAY5n/GgPcVTb3jjUSOsvk5ufe Jw== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com with ESMTP id 391ecv2ej7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Mon, 07 Jun 2021 11:04:53 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 7 Jun 2021 11:04:51 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 7 Jun 2021 11:04:51 -0700 Received: from hyd1588t430.marvell.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id 301DF3F703F; Mon, 7 Jun 2021 11:04:48 -0700 (PDT) From: Nithin Dabilpuram To: CC: , , , , , , Date: Mon, 7 Jun 2021 23:29:16 +0530 Message-ID: <20210607175943.31690-36-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20210607175943.31690-1-ndabilpuram@marvell.com> References: <20210306153404.10781-1-ndabilpuram@marvell.com> <20210607175943.31690-1-ndabilpuram@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-GUID: -7Lbrg4z13s5ficixhN0Jw8QcQKNOJVM X-Proofpoint-ORIG-GUID: -7Lbrg4z13s5ficixhN0Jw8QcQKNOJVM X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.761 definitions=2021-06-07_14:2021-06-04, 2021-06-07 signatures=0 Subject: [dpdk-dev] [PATCH v2 35/62] net/cnxk: add DMAC filter support 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" From: Sunil Kumar Kori DMAC filter support is added for cn9k and cn10k platforms. Signed-off-by: Sunil Kumar Kori --- doc/guides/nics/cnxk.rst | 1 + doc/guides/nics/features/cnxk.ini | 1 + doc/guides/nics/features/cnxk_vec.ini | 1 + drivers/net/cnxk/cnxk_ethdev.c | 2 ++ drivers/net/cnxk/cnxk_ethdev.h | 5 ++++ drivers/net/cnxk/cnxk_ethdev_ops.c | 44 ++++++++++++++++++++++++++++++++--- 6 files changed, 51 insertions(+), 3 deletions(-) diff --git a/doc/guides/nics/cnxk.rst b/doc/guides/nics/cnxk.rst index 364e511..ce33f17 100644 --- a/doc/guides/nics/cnxk.rst +++ b/doc/guides/nics/cnxk.rst @@ -23,6 +23,7 @@ Features of the CNXK Ethdev PMD are: - Lock-free Tx queue - Multiple queues for TX and RX - Receiver Side Scaling (RSS) +- MAC filtering - Inner and Outer Checksum offload - Link state information - MTU update diff --git a/doc/guides/nics/features/cnxk.ini b/doc/guides/nics/features/cnxk.ini index 9b2e163..20d4d12 100644 --- a/doc/guides/nics/features/cnxk.ini +++ b/doc/guides/nics/features/cnxk.ini @@ -18,6 +18,7 @@ Queue start/stop = Y MTU update = Y TSO = Y Promiscuous mode = Y +Unicast MAC filter = Y RSS hash = Y Inner RSS = Y Jumbo frame = Y diff --git a/doc/guides/nics/features/cnxk_vec.ini b/doc/guides/nics/features/cnxk_vec.ini index 31471e0..e1de8ab 100644 --- a/doc/guides/nics/features/cnxk_vec.ini +++ b/doc/guides/nics/features/cnxk_vec.ini @@ -17,6 +17,7 @@ Free Tx mbuf on demand = Y Queue start/stop = Y MTU update = Y Promiscuous mode = Y +Unicast MAC filter = Y RSS hash = Y Inner RSS = Y Jumbo frame = Y diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c index 1e58599..36d45b4 100644 --- a/drivers/net/cnxk/cnxk_ethdev.c +++ b/drivers/net/cnxk/cnxk_ethdev.c @@ -1068,6 +1068,8 @@ cnxk_nix_dev_start(struct rte_eth_dev *eth_dev) /* CNXK platform independent eth dev ops */ struct eth_dev_ops cnxk_eth_dev_ops = { .mtu_set = cnxk_nix_mtu_set, + .mac_addr_add = cnxk_nix_mac_addr_add, + .mac_addr_remove = cnxk_nix_mac_addr_del, .mac_addr_set = cnxk_nix_mac_addr_set, .dev_infos_get = cnxk_nix_info_get, .link_update = cnxk_nix_link_update, diff --git a/drivers/net/cnxk/cnxk_ethdev.h b/drivers/net/cnxk/cnxk_ethdev.h index 73aef34..38ac654 100644 --- a/drivers/net/cnxk/cnxk_ethdev.h +++ b/drivers/net/cnxk/cnxk_ethdev.h @@ -139,6 +139,7 @@ struct cnxk_eth_dev { /* Max macfilter entries */ uint8_t max_mac_entries; + bool dmac_filter_enable; uint16_t flags; uint8_t ptype_disable; @@ -206,6 +207,10 @@ int cnxk_nix_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev); int cnxk_nix_remove(struct rte_pci_device *pci_dev); int cnxk_nix_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu); +int cnxk_nix_mac_addr_add(struct rte_eth_dev *eth_dev, + struct rte_ether_addr *addr, uint32_t index, + uint32_t pool); +void cnxk_nix_mac_addr_del(struct rte_eth_dev *eth_dev, uint32_t index); int cnxk_nix_mac_addr_set(struct rte_eth_dev *eth_dev, struct rte_ether_addr *addr); int cnxk_nix_promisc_enable(struct rte_eth_dev *eth_dev); diff --git a/drivers/net/cnxk/cnxk_ethdev_ops.c b/drivers/net/cnxk/cnxk_ethdev_ops.c index 6feb3a9..fc60576 100644 --- a/drivers/net/cnxk/cnxk_ethdev_ops.c +++ b/drivers/net/cnxk/cnxk_ethdev_ops.c @@ -101,6 +101,43 @@ cnxk_nix_mac_addr_set(struct rte_eth_dev *eth_dev, struct rte_ether_addr *addr) } int +cnxk_nix_mac_addr_add(struct rte_eth_dev *eth_dev, struct rte_ether_addr *addr, + uint32_t index, uint32_t pool) +{ + struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); + struct roc_nix *nix = &dev->nix; + int rc; + + PLT_SET_USED(index); + PLT_SET_USED(pool); + + rc = roc_nix_mac_addr_add(nix, addr->addr_bytes); + if (rc < 0) { + plt_err("Failed to add mac address, rc=%d", rc); + return rc; + } + + /* Enable promiscuous mode at NIX level */ + roc_nix_npc_promisc_ena_dis(nix, true); + dev->dmac_filter_enable = true; + eth_dev->data->promiscuous = false; + + return 0; +} + +void +cnxk_nix_mac_addr_del(struct rte_eth_dev *eth_dev, uint32_t index) +{ + struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); + struct roc_nix *nix = &dev->nix; + int rc; + + rc = roc_nix_mac_addr_del(nix, index); + if (rc) + plt_err("Failed to delete mac address, rc=%d", rc); +} + +int cnxk_nix_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu) { uint32_t old_frame_size, frame_size = mtu + CNXK_NIX_L2_OVERHEAD; @@ -212,8 +249,8 @@ cnxk_nix_promisc_disable(struct rte_eth_dev *eth_dev) if (roc_nix_is_vf_or_sdp(nix)) return rc; - rc = roc_nix_npc_promisc_ena_dis(nix, false); - if (rc < 0) { + rc = roc_nix_npc_promisc_ena_dis(nix, dev->dmac_filter_enable); + if (rc) { plt_err("Failed to setup promisc mode in npc, rc=%d(%s)", rc, roc_error_msg_get(rc)); return rc; @@ -223,9 +260,10 @@ cnxk_nix_promisc_disable(struct rte_eth_dev *eth_dev) if (rc) { plt_err("Failed to setup promisc mode in mac, rc=%d(%s)", rc, roc_error_msg_get(rc)); - roc_nix_npc_promisc_ena_dis(nix, true); + roc_nix_npc_promisc_ena_dis(nix, !dev->dmac_filter_enable); return rc; } + dev->dmac_filter_enable = false; return 0; } -- 2.8.4