From patchwork Fri Aug 11 08:57:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nithin Dabilpuram X-Patchwork-Id: 130136 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 57C6D43032; Fri, 11 Aug 2023 11:00:23 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8844943273; Fri, 11 Aug 2023 10:59:19 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 325F543265 for ; Fri, 11 Aug 2023 10:59:18 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37AN2Lhc011196 for ; Fri, 11 Aug 2023 01:59: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-transfer-encoding : content-type; s=pfpt0220; bh=Bl5EUihgFJ6sSJVpzMeBCVRZYmLz4AK+L179F2wU0vk=; b=Q3C+eKvrG+OvxEkGU+iL03TeBty2vNBAE29KWaG9+7ZdiygJULJQLVg0zZ+jK8ET+2QR GCxVQDZEYa0JHWbnTmbIY4ru+LXFDMokQRNdzxI9wfmE2Q2qqQVWr35pFzkSaT8NBw6e Tb8Zxl5amvZhyYzaPpGOBRY3aBgrRxJaJ7g1gHx1jEEn0ccTWfFpnbKBsndawe5+JguN RoTgQoNg/FifA3fONgjFUOG4wSUA0sIosJJ4VsxTUbh+iPOEeSROfEPMOFV++a1fsJRg YdH9dvcQpmFZiXU0aTwLBH6WQ1reRjU35iflGPY40oi3n8d63QTFp3pyQMa6vMvxiqKb Gg== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3sd8ya1gbj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Fri, 11 Aug 2023 01:59:17 -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.48; Fri, 11 Aug 2023 01:59:15 -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.48 via Frontend Transport; Fri, 11 Aug 2023 01:59:15 -0700 Received: from hyd1588t430.caveonetworks.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id 647503F706C; Fri, 11 Aug 2023 01:59:13 -0700 (PDT) From: Nithin Dabilpuram To: Nithin Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Rao CC: , Subject: [PATCH 22/31] net/cnxk: add mapping of DMAC address indexes Date: Fri, 11 Aug 2023 14:27:56 +0530 Message-ID: <20230811085805.441256-22-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230811085805.441256-1-ndabilpuram@marvell.com> References: <20230811085805.441256-1-ndabilpuram@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: J5w6g8jcy2UNmlQqhP2sKm5UgO36310A X-Proofpoint-GUID: J5w6g8jcy2UNmlQqhP2sKm5UgO36310A X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-10_20,2023-08-10_01,2023-05-22_02 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 From: Sunil Kumar Kori Add support to map DMAC address indexes during mac address add and remove operation. Signed-off-by: Sunil Kumar Kori --- drivers/net/cnxk/cnxk_ethdev.c | 11 +++++++++++ drivers/net/cnxk/cnxk_ethdev.h | 1 + drivers/net/cnxk/cnxk_ethdev_ops.c | 4 +++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c index 46450088eb..bd161ad375 100644 --- a/drivers/net/cnxk/cnxk_ethdev.c +++ b/drivers/net/cnxk/cnxk_ethdev.c @@ -1921,6 +1921,13 @@ cnxk_eth_dev_init(struct rte_eth_dev *eth_dev) goto dev_fini; } + dev->dmac_idx_map = rte_zmalloc("dmac_idx_map", max_entries * sizeof(int), 0); + if (dev->dmac_idx_map == NULL) { + plt_err("Failed to allocate memory for dmac idx map"); + rc = -ENOMEM; + goto free_mac_addrs; + } + dev->max_mac_entries = max_entries; dev->dmac_filter_count = 1; @@ -1978,6 +1985,7 @@ cnxk_eth_dev_init(struct rte_eth_dev *eth_dev) free_mac_addrs: rte_free(eth_dev->data->mac_addrs); + rte_free(dev->dmac_idx_map); dev_fini: roc_nix_dev_fini(nix); error: @@ -2095,6 +2103,9 @@ cnxk_eth_dev_uninit(struct rte_eth_dev *eth_dev, bool reset) if (rc) plt_err("Failed to free nix lf, rc=%d", rc); + rte_free(dev->dmac_idx_map); + dev->dmac_idx_map = NULL; + rte_free(eth_dev->data->mac_addrs); eth_dev->data->mac_addrs = NULL; diff --git a/drivers/net/cnxk/cnxk_ethdev.h b/drivers/net/cnxk/cnxk_ethdev.h index ed531fb277..8649f9e6f0 100644 --- a/drivers/net/cnxk/cnxk_ethdev.h +++ b/drivers/net/cnxk/cnxk_ethdev.h @@ -329,6 +329,7 @@ struct cnxk_eth_dev { uint8_t dmac_filter_count; uint8_t max_mac_entries; bool dmac_filter_enable; + int *dmac_idx_map; uint16_t flags; uint8_t ptype_disable; diff --git a/drivers/net/cnxk/cnxk_ethdev_ops.c b/drivers/net/cnxk/cnxk_ethdev_ops.c index 3ade8eed36..5de2919047 100644 --- a/drivers/net/cnxk/cnxk_ethdev_ops.c +++ b/drivers/net/cnxk/cnxk_ethdev_ops.c @@ -474,6 +474,8 @@ cnxk_nix_mac_addr_add(struct rte_eth_dev *eth_dev, struct rte_ether_addr *addr, return rc; } + dev->dmac_idx_map[index] = rc; + /* Enable promiscuous mode at NIX level */ roc_nix_npc_promisc_ena_dis(nix, true); dev->dmac_filter_enable = true; @@ -490,7 +492,7 @@ cnxk_nix_mac_addr_del(struct rte_eth_dev *eth_dev, uint32_t index) struct roc_nix *nix = &dev->nix; int rc; - rc = roc_nix_mac_addr_del(nix, index); + rc = roc_nix_mac_addr_del(nix, dev->dmac_idx_map[index]); if (rc) plt_err("Failed to delete mac address, rc=%d", rc);