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 2795DA0C41; Wed, 23 Jun 2021 06:54:00 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 403414120D; Wed, 23 Jun 2021 06:50:39 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 3C88F411EB for ; Wed, 23 Jun 2021 06:50:37 +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 15N4krg7026329 for ; Tue, 22 Jun 2021 21:50:36 -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=hwqayxlyVxI5JdE9RtKr00rePsfLgidHOBmzdFm1lsE=; b=OgX9rZ2hqYlycNdeYROHMbN+1l8h72uFZbJPcCi9uFeAHWjfe0Jq6YKQCuIsASwoB1ht Zuqiuh3ZSB0s6skyJD5spjDmtr/IlYnKY2G/Y7mI7oLHNW0Qyhbud6gGxp9/izyFJhrH /dHQWd1d/JDvdSnQXP1i0rBUWGdNVm4FDHxRLYvNpYm/h299ti2gs7P0YwU+ifIH5o9I xDlGheX6qM9cNhajp7ne2NKbru9LJumrSW1a4bf00L2zRNLE6kkmvd17K230mYTYeVu3 LQ/89rRbwG4YKWNPr2y0hk5fzkc406dBn2n4qIHh2HT3rTt49OhVDSayMfWY3DKXmCM0 nA== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com with ESMTP id 39bptj1gxj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 22 Jun 2021 21:50:36 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 22 Jun 2021 21:50:34 -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.18 via Frontend Transport; Tue, 22 Jun 2021 21:50:34 -0700 Received: from hyd1588t430.marvell.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id D36225B6938; Tue, 22 Jun 2021 21:50:31 -0700 (PDT) From: Nithin Dabilpuram To: CC: , , , , , , , Date: Wed, 23 Jun 2021 10:17:01 +0530 Message-ID: <20210623044702.4240-62-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20210623044702.4240-1-ndabilpuram@marvell.com> References: <20210306153404.10781-1-ndabilpuram@marvell.com> <20210623044702.4240-1-ndabilpuram@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-ORIG-GUID: rEMCS7iXqSY2cQXZy5mCy34TCm8aUPIx X-Proofpoint-GUID: rEMCS7iXqSY2cQXZy5mCy34TCm8aUPIx X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-06-23_01:2021-06-22, 2021-06-23 signatures=0 Subject: [dpdk-dev] [PATCH v4 61/62] net/cnxk: support multicast filter 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 | 65 +++++++++++++++++++++++++++++++++++ 5 files changed, 73 insertions(+) diff --git a/doc/guides/nics/features/cnxk.ini b/doc/guides/nics/features/cnxk.ini index 9945af9..c686ceb 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 77d63c4..018d09e 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 abd9bf1..b7872cc 100644 --- a/drivers/net/cnxk/cnxk_ethdev.c +++ b/drivers/net/cnxk/cnxk_ethdev.c @@ -1270,6 +1270,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 @@ -1334,6 +1335,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 cd08e3a..c07e988 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; @@ -265,6 +266,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 d257763..b6cc528 100644 --- a/drivers/net/cnxk/cnxk_ethdev_ops.c +++ b/drivers/net/cnxk/cnxk_ethdev_ops.c @@ -359,6 +359,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; } @@ -373,6 +374,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 @@ -845,3 +848,65 @@ 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); + struct rte_eth_dev_data *data = eth_dev->data; + struct rte_ether_addr null_mac_addr; + struct roc_nix *nix = &dev->nix; + int rc, index; + uint32_t i; + + memset(&null_mac_addr, 0, sizeof(null_mac_addr)); + + /* 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