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 558ABA034F; Mon, 7 Jun 2021 20:10:36 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 285CF4122E; Mon, 7 Jun 2021 20:06:20 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 77F97411E9 for ; Mon, 7 Jun 2021 20:06:18 +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 157I1bsu017517 for ; Mon, 7 Jun 2021 11:06:17 -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=PFkB881T6Iyg0OhwtiQAl9B8bktOgeCicDSCSwzvBKE=; b=XtbOvVrFavOyJ9OWCGscm4WmU33r1nXl2BDaDzFakRRZPoOOb3dtcw35Fexm1cwZBUsl Tfy36rm53HarNx7IMUs+MA1se+rTXkYbwdkvTW0IzBgTTLlEcKQOG6VhYfzg3AYqU1L9 Qt5LY9unOPdEzQ4UKPeOdK2GBDWj2wrzJgMUJ++AxSiXBye/rSIPenKmQ0fBktEdwupK cDWt/w8y7jIJczoTWf2Kjhh1uSP80AS2ipgaa4HQULukALAMXPsFtBQl43kdnilNbNdt EiwesKf31h/r/tCx+wnlBB0RsdY8D0gZ+mJVWkqsYEhiCli1OITIsHqhp+e61qsE2jqT Ew== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com with ESMTP id 391ecv2etb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Mon, 07 Jun 2021 11:06:17 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 7 Jun 2021 11:06:16 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 7 Jun 2021 11:06:15 -0700 Received: from hyd1588t430.marvell.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id 742AF3F7041; Mon, 7 Jun 2021 11:06:13 -0700 (PDT) From: Nithin Dabilpuram To: CC: , , , , , , Date: Mon, 7 Jun 2021 23:29:43 +0530 Message-ID: <20210607175943.31690-63-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: DTjN4sY_JbeHt1pKdMYK2u2fibK72z76 X-Proofpoint-ORIG-GUID: DTjN4sY_JbeHt1pKdMYK2u2fibK72z76 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 62/62] net/cnxk: add multicast 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 Patch adds multicast filter support for cn9k and cn10k platforms. CGX DMAC filter table(32 entries) is divided among all LMACs connected to it i.e. if CGX has 4 LMACs then each LMAC can have up to 8 filters. If CGX has 1 LMAC then it can have up to 32 filters. Above mentioned filter table is used to install unicast and multicast DMAC address filters. Unicast filters are installed via rte_eth_dev_mac_addr_add API while multicast filters are installed via rte_eth_dev_set_mc_addr_list API. So in total, supported MAC filters are equal to DMAC filters plus mcast filters. Signed-off-by: Sunil Kumar Kori --- 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 | 4 +++ drivers/net/cnxk/cnxk_ethdev_ops.c | 63 +++++++++++++++++++++++++++++++++++ 5 files changed, 71 insertions(+) diff --git a/doc/guides/nics/features/cnxk.ini b/doc/guides/nics/features/cnxk.ini index 24803da..337ad24 100644 --- a/doc/guides/nics/features/cnxk.ini +++ b/doc/guides/nics/features/cnxk.ini @@ -22,6 +22,7 @@ TSO = Y Promiscuous mode = Y Allmulticast mode = Y Unicast MAC filter = Y +Multicast MAC filter = Y RSS hash = Y RSS key update = Y RSS reta update = Y diff --git a/doc/guides/nics/features/cnxk_vec.ini b/doc/guides/nics/features/cnxk_vec.ini index b4b1169..4c3f78e 100644 --- a/doc/guides/nics/features/cnxk_vec.ini +++ b/doc/guides/nics/features/cnxk_vec.ini @@ -21,6 +21,7 @@ MTU update = Y Promiscuous mode = Y Allmulticast mode = Y Unicast MAC filter = Y +Multicast MAC filter = Y RSS hash = Y RSS key update = Y RSS reta update = Y diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c index a250cff..6a0b49c 100644 --- a/drivers/net/cnxk/cnxk_ethdev.c +++ b/drivers/net/cnxk/cnxk_ethdev.c @@ -1241,6 +1241,7 @@ struct eth_dev_ops cnxk_eth_dev_ops = { .reta_query = cnxk_nix_reta_query, .rss_hash_update = cnxk_nix_rss_hash_update, .rss_hash_conf_get = cnxk_nix_rss_hash_conf_get, + .set_mc_addr_list = cnxk_nix_mc_addr_list_configure, }; static int @@ -1306,6 +1307,7 @@ cnxk_eth_dev_init(struct rte_eth_dev *eth_dev) } dev->max_mac_entries = max_entries; + dev->dmac_filter_count = 1; /* Get mac address */ rc = roc_nix_npc_mac_addr_get(nix, dev->mac_addr); diff --git a/drivers/net/cnxk/cnxk_ethdev.h b/drivers/net/cnxk/cnxk_ethdev.h index 62c88e6..a28591b 100644 --- a/drivers/net/cnxk/cnxk_ethdev.h +++ b/drivers/net/cnxk/cnxk_ethdev.h @@ -162,6 +162,7 @@ struct cnxk_eth_dev { uint8_t configured; /* Max macfilter entries */ + uint8_t dmac_filter_count; uint8_t max_mac_entries; bool dmac_filter_enable; @@ -249,6 +250,9 @@ 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_mc_addr_list_configure(struct rte_eth_dev *eth_dev, + struct rte_ether_addr *mc_addr_set, + uint32_t nb_mc_addr); int cnxk_nix_mac_addr_add(struct rte_eth_dev *eth_dev, struct rte_ether_addr *addr, uint32_t index, uint32_t pool); diff --git a/drivers/net/cnxk/cnxk_ethdev_ops.c b/drivers/net/cnxk/cnxk_ethdev_ops.c index c28512a..63fe9a6 100644 --- a/drivers/net/cnxk/cnxk_ethdev_ops.c +++ b/drivers/net/cnxk/cnxk_ethdev_ops.c @@ -353,6 +353,7 @@ cnxk_nix_mac_addr_add(struct rte_eth_dev *eth_dev, struct rte_ether_addr *addr, roc_nix_npc_promisc_ena_dis(nix, true); dev->dmac_filter_enable = true; eth_dev->data->promiscuous = false; + dev->dmac_filter_count++; return 0; } @@ -367,6 +368,8 @@ cnxk_nix_mac_addr_del(struct rte_eth_dev *eth_dev, uint32_t index) rc = roc_nix_mac_addr_del(nix, index); if (rc) plt_err("Failed to delete mac address, rc=%d", rc); + + dev->dmac_filter_count--; } int @@ -839,3 +842,63 @@ cnxk_nix_rss_hash_conf_get(struct rte_eth_dev *eth_dev, return 0; } + +int +cnxk_nix_mc_addr_list_configure(struct rte_eth_dev *eth_dev, + struct rte_ether_addr *mc_addr_set, + uint32_t nb_mc_addr) +{ + struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); + const struct rte_ether_addr null_mac_addr = {0}; + struct rte_eth_dev_data *data = eth_dev->data; + struct roc_nix *nix = &dev->nix; + int rc, index; + uint32_t i; + + /* All configured multicast filters should be flushed first */ + for (i = 0; i < dev->max_mac_entries; i++) { + if (rte_is_multicast_ether_addr(&data->mac_addrs[i])) { + rc = roc_nix_mac_addr_del(nix, i); + if (rc) { + plt_err("Failed to flush mcast address, rc=%d", + rc); + return rc; + } + + dev->dmac_filter_count--; + /* Update address in NIC data structure */ + rte_ether_addr_copy(&null_mac_addr, + &data->mac_addrs[i]); + } + } + + if (!mc_addr_set || !nb_mc_addr) + return 0; + + /* Check for available space */ + if (nb_mc_addr > + ((uint32_t)(dev->max_mac_entries - dev->dmac_filter_count))) { + plt_err("No space is available to add multicast filters"); + return -ENOSPC; + } + + /* Multicast addresses are to be installed */ + for (i = 0; i < nb_mc_addr; i++) { + index = roc_nix_mac_addr_add(nix, mc_addr_set[i].addr_bytes); + if (index < 0) { + plt_err("Failed to add mcast mac address, rc=%d", + index); + return index; + } + + dev->dmac_filter_count++; + /* Update address in NIC data structure */ + rte_ether_addr_copy(&mc_addr_set[i], &data->mac_addrs[index]); + } + + roc_nix_npc_promisc_ena_dis(nix, true); + dev->dmac_filter_enable = true; + eth_dev->data->promiscuous = false; + + return 0; +} -- 2.8.4