From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 893B1A0350; Tue, 23 Jun 2020 15:42:58 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8DA301D666; Tue, 23 Jun 2020 15:42:53 +0200 (CEST) Received: from FRA01-MR2-obe.outbound.protection.outlook.com (mail-eopbgr90101.outbound.protection.outlook.com [40.107.9.101]) by dpdk.org (Postfix) with ESMTP id 26BF81D666 for ; Tue, 23 Jun 2020 15:42:52 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L5+IELWkMvLiwPAbcdZqPygQllEWoYlBTvnkUW30N9MZLRh4+QJyInAJxZgy8GgMIFkrue0gVDgZ1ETwYJ3uzFwNGvb/1ddQ9T2TXqhnxPXGgLs6ZLPjehEUXMbCsV87MtwuDnVEwOChZ6gmaE7YYa0I6K3dguUZXAHqP8JeKmHRQD01Mekefj+YmFaENh8JwxItF5hHmHeFW73kpsVpLxVRToFX6bn65HPRg+BhtpOH6aC1Pual/v0UfuMksYGeaYEe8NorNwmzhRiwLZW1Wl8gsUamYJzqUy1JFkEhL9IUoKMCPjcBV8pBwU+AVi+IBhyBIiSAGCpiVcLDROCCAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Q1EzXE1JNqxdriM7+j9bspf5nuJGgDHmhEzPAnWtbc0=; b=RFVrVXizLRCr7sb43e1YwmIc5l8V8Tf0bouJckn3nBSKlOr8Uf0l0VRRAY/YXnIu8bwA2U5XGMk9nF+40lAS0tQYxMirYYjVoClr5JAbhxqEdQlJUSXwPTCQa4ep+COmrcG9rEkQK3n52ZGV5A/IK46X6lRPXXiX/6u73Rbj/E0rQzGKjjFmC/GFpLjK7zmsVrg76oe7hp0b/nTkWH51/1FIjSPYaq3pPsfFaASVi5HNRl1kWErh2yqiH71kixLnsofac1BHyJ9wwxYIQhLfCk2vHcZY33+6y0y9uBr+QnX4GlMhhYPMhkAhyvfO7TfFv3qsZOjWUuHqNEJ1AlVC6g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ekinops.com; dmarc=pass action=none header.from=ekinops.com; dkim=pass header.d=ekinops.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ekinops.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Q1EzXE1JNqxdriM7+j9bspf5nuJGgDHmhEzPAnWtbc0=; b=leeXbcFblgsIUVDO0ug4WNVbfHfxR1f2F5Q8Ww4Vv8ZKFu4ETX4m80L4etxibW6ImCfckFDLfPzHitQEM43XT2bgLH3iHYrueu7l2aMNdKGKUhWoYWl62Wv0w/ETJoLRCSunW6DxqwKoWTcSiCTbv/bsF4E5aW15wNi8HKG8AaI= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=ekinops.com; Received: from MRXP264MB0120.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:1b::10) by MRXP264MB0264.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:20::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Tue, 23 Jun 2020 13:42:51 +0000 Received: from MRXP264MB0120.FRAP264.PROD.OUTLOOK.COM ([fe80::b9c3:a77c:6837:2548]) by MRXP264MB0120.FRAP264.PROD.OUTLOOK.COM ([fe80::b9c3:a77c:6837:2548%6]) with mapi id 15.20.3109.027; Tue, 23 Jun 2020 13:42:51 +0000 From: Renata Saiakhova To: dev@dpdk.org Cc: Renata Saiakhova Date: Tue, 23 Jun 2020 15:42:12 +0200 Message-Id: <20200623134215.31092-2-Renata.Saiakhova@ekinops.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200623134215.31092-1-Renata.Saiakhova@ekinops.com> References: <20200623134215.31092-1-Renata.Saiakhova@ekinops.com> Content-Type: text/plain X-ClientProxiedBy: AM0PR01CA0079.eurprd01.prod.exchangelabs.com (2603:10a6:208:10e::20) To MRXP264MB0120.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:1b::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from renataOAB.oneaccess.intra (91.183.184.98) by AM0PR01CA0079.eurprd01.prod.exchangelabs.com (2603:10a6:208:10e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Tue, 23 Jun 2020 13:42:50 +0000 X-Mailer: git-send-email 2.17.2 X-Originating-IP: [91.183.184.98] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a1f69933-2b0f-43d6-3abc-08d8177b52d5 X-MS-TrafficTypeDiagnostic: MRXP264MB0264: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:883; X-Forefront-PRVS: 04433051BF X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6zeBjlAbKapDjvE+vkP5rKNXKFWkEV15JhK84Q3GhcbouQ8ExBYZQkXKK/I75IMipHx9ubgcBPatzhWlELWKXpnE2AWCrzLG6IGh8q5KKvMd9aapvH059///GBD0jvJRCHjfBvAV7uy5C+OhgcRdLEfA/R5n9cpH0RM9R/GkbWKqxvDtyNiRDNlrpmQOUls/wq1ZKUqz03p2MNhSgnPFufUqrYU8pAPVqm4wBtfWyGA2BaqZTJdSe+vhGZkY0+ry34ny18Isr6MXLi1tJ8vrhMYKxv+S616CfxelfIf1lYsxrkyoxRWNdyk9M2cDRni64ZFFhT5OgyZTdEixx2hd8w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MRXP264MB0120.FRAP264.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFTY:; SFS:(366004)(16526019)(8936002)(52116002)(6666004)(66556008)(66946007)(6486002)(66476007)(107886003)(36756003)(4326008)(186003)(86362001)(2906002)(498600001)(5660300002)(2616005)(1076003)(8676002)(6506007)(26005)(6916009)(6512007)(956004)(83380400001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: p4hROSy4sxZ8ATnIWflvIqE64pXTPqpWbFXkH4He+b4bmiS9dw5R5wiyznFharFEAnmODtvVSf/PuCEWNkxUOqqfiKEIsDgxZ/u65jyYYU/ZNhLPTlZi+nv1npZY2AWO3Iq86E3HnrHrKzb+8QkM8sNGBv9zaXvFQrQddvjOT6SrwEMDH5YzFFFE8mhz0N6A1U+J2iytVf8f4E5KQyE33aV5eias61E9SM/21MnsM1Oe3Cl8ScrehI6Rt4SJ86rVrlGv9ThtaYn//O3levOql6K9VrPCidVhOo6iCdS9tYH4A7D8MdrciSIAa6VBSefbCmdHyO46x7Lu56ds2ZIg2eMOvnv1K64BcNHVpIHPZQqGCwM/nsrUiJxq6GDTiyoeiwLCXzxw+tmwYVSd39m7Z6tL9TmVWCM/l8mMP72/dNfaqahCM+6ZF18LOr5cy+4kLfpZAu5S5E68lePkiMF3wTkk4Njn8tRCZxSst3g7jOk= X-OriginatorOrg: ekinops.com X-MS-Exchange-CrossTenant-Network-Message-Id: a1f69933-2b0f-43d6-3abc-08d8177b52d5 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jun 2020 13:42:51.2336 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f57b78a6-c654-4771-a72f-837275f46179 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ICt8//jzl1HSiXrtMoe9mRy1y8oJH9mvxwkVfIMDTIzDNxeWKNx4pkKtLSAEjJCJ8O1AQ6SmKdUqv8koshhFyx3aKKWIVjo3aP0koLYLRDw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MRXP264MB0264 Subject: [dpdk-dev] [PATCH v5 1/4] ethdev: add function to release HW rings X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" Free previously allocated memzone for HW rings Signed-off-by: Renata Saiakhova --- lib/librte_ethdev/rte_ethdev.c | 30 ++++++++++++++++++++++-- lib/librte_ethdev/rte_ethdev_driver.h | 17 ++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 7 ++++++ 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 8e10a6fc3..e378489a6 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -4184,6 +4184,10 @@ rte_eth_dev_rx_intr_ctl_q_get_fd(uint16_t port_id, uint16_t queue_id) return fd; } +#define ETH_DMA_MZONE_NAME(_name, _port_id, _queue_id, _ring_name) \ + snprintf(_name, sizeof(_name), "eth_p%d_q%d_%s", \ + _port_id, _queue_id, _ring_name) + const struct rte_memzone * rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, uint16_t queue_id, size_t size, unsigned align, @@ -4193,8 +4197,7 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, const struct rte_memzone *mz; int rc; - rc = snprintf(z_name, sizeof(z_name), "eth_p%d_q%d_%s", - dev->data->port_id, queue_id, ring_name); + rc = ETH_DMA_MZONE_NAME(z_name, dev->data->port_id, queue_id, ring_name); if (rc >= RTE_MEMZONE_NAMESIZE) { RTE_ETHDEV_LOG(ERR, "ring name too long\n"); rte_errno = ENAMETOOLONG; @@ -4209,6 +4212,29 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, RTE_MEMZONE_IOVA_CONTIG, align); } +int +rte_eth_dma_zone_free(const struct rte_eth_dev *dev, const char *ring_name, + uint16_t queue_id) +{ + char z_name[RTE_MEMZONE_NAMESIZE]; + const struct rte_memzone *mz; + int rc = 0; + + rc = ETH_DMA_MZONE_NAME(z_name, dev->data->port_id, queue_id, ring_name); + if (rc >= RTE_MEMZONE_NAMESIZE) { + RTE_ETHDEV_LOG(ERR, "ring name too long\n"); + return -ENAMETOOLONG; + } + + mz = rte_memzone_lookup(z_name); + if (mz) + rc = rte_memzone_free(mz); + else + rc = -EINVAL; + + return rc; +} + int rte_eth_dev_create(struct rte_device *device, const char *name, size_t priv_data_size, diff --git a/lib/librte_ethdev/rte_ethdev_driver.h b/lib/librte_ethdev/rte_ethdev_driver.h index 99d4cd6cd..13fd049c0 100644 --- a/lib/librte_ethdev/rte_ethdev_driver.h +++ b/lib/librte_ethdev/rte_ethdev_driver.h @@ -180,6 +180,23 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *eth_dev, const char *name, uint16_t queue_id, size_t size, unsigned align, int socket_id); +/** + * Free previously allocated memzone for HW rings. + * + * @param eth_dev + * The *eth_dev* pointer is the address of the *rte_eth_dev* structure + * @param name + * The name of the memory zone + * @param queue_id + * The index of the queue to add to name + * @return + * Negative errno value on error, 0 on success. + */ +__rte_internal +int +rte_eth_dma_zone_free(const struct rte_eth_dev *eth_dev, const char *name, + uint16_t queue_id); + /** * @internal * Atomically set the link status for the specific device. diff --git a/lib/librte_ethdev/rte_ethdev_version.map b/lib/librte_ethdev/rte_ethdev_version.map index 715505604..664d6b86a 100644 --- a/lib/librte_ethdev/rte_ethdev_version.map +++ b/lib/librte_ethdev/rte_ethdev_version.map @@ -242,3 +242,10 @@ EXPERIMENTAL { __rte_ethdev_trace_tx_burst; rte_flow_get_aged_flows; }; + +INTERNAL { + global: + + rte_eth_dma_zone_free; +}; + -- 2.17.2