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 D70ABA034F; Wed, 13 May 2020 15:15:10 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DB9A71D5BE; Wed, 13 May 2020 15:15:06 +0200 (CEST) Received: from FRA01-MR2-obe.outbound.protection.outlook.com (mail-eopbgr90103.outbound.protection.outlook.com [40.107.9.103]) by dpdk.org (Postfix) with ESMTP id 6DEEA1D5B6 for ; Wed, 13 May 2020 15:15:05 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AIYTGH5LJlGIf+H5+Wn4VQX9/XIK4L7Fb9sEtRNgYygq0XHK7bXZGpKtxZ6gNOOlTVoxqTRzNg34QFDPfsPpnPqjdbwjCxYpKC8hA0KdSRel44K6CB+YDHYE4ilh7YjD8cC/NcSPXZqEygr02HhqM7+c/fZS93vbheNtmuz3sT8XSHrM2g7i1uJIYi6htl02hhQufmAvZ5m6/qHzMzYnLiQ3X43EeFYxL66WANjpBEtLl/wZgJ53kIk+j41mRvC9b4u7OjLV+OFH3uOlkuVp6pqfn3kTX6Su9hXWi18OC4Hvu0803+fiPOioo+3t9RePvW46Xbxd7CTktlA/bH+fkg== 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=pMi/mnz3iDW1rMNv7lInF8i2CqSeASfgk5BDHvb+TZw=; b=OLYoG+6OVhyLABYsej3rypc+RT5rpKd3Sa8oJ1PA4/I9r+aDvn2AGXrrt7MHcrpDht6CuV6N++dOUs2eePh4U2J6aodJoEfFCv9NzsCu95FU/1HkWAhn1wpVijATAV7g5BeH6SChxNlMt7J9m8fecz4M0AC7hXoXcp/HnsBnRfPbAFQgcqli3foJgzevnfuKIvvl9/fgzQuy6BjNwZ1vYAFwReyhPzmBgpjrwVe0gDH1D1lnXiWEFIm8A3ph3H00BNzv90pFbqj1WH/yEtVnn3LsGH4aDsaNGBS+oUiOlmnSTxSoiIu5SGqcAOObHoqAaByd8eJtq6slJZ1dozMe2A== 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=pMi/mnz3iDW1rMNv7lInF8i2CqSeASfgk5BDHvb+TZw=; b=oW4ATvskfBveQxZwFZT2nZn9vSZeSsAxOezvt4E3qMV4HGWoE+vWkkdXsn//HF8iAn9O+rh0ddEOTaTxqEgMTzWvKHsH4DVZBt0LliuG19wSQve0QHVa/cCXr/uO9M4wXor6qwLJTZ+3foyp7J3NZjuiPh12GCndwraaldZboDU= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=ekinops.com; Received: from MRXP264MB0325.FRAP264.PROD.OUTLOOK.COM (52.134.49.19) by MRXP264MB0359.FRAP264.PROD.OUTLOOK.COM (52.134.50.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.27; Wed, 13 May 2020 13:15:04 +0000 Received: from MRXP264MB0325.FRAP264.PROD.OUTLOOK.COM ([fe80::41a7:e761:6112:5c08]) by MRXP264MB0325.FRAP264.PROD.OUTLOOK.COM ([fe80::41a7:e761:6112:5c08%7]) with mapi id 15.20.2979.033; Wed, 13 May 2020 13:15:04 +0000 From: Renata Saiakhova To: dev@dpdk.org Cc: Renata Saiakhova Date: Wed, 13 May 2020 15:14:22 +0200 Message-Id: <20200513131425.27817-2-Renata.Saiakhova@ekinops.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200513131425.27817-1-Renata.Saiakhova@ekinops.com> References: <20200513131425.27817-1-Renata.Saiakhova@ekinops.com> Content-Type: text/plain X-ClientProxiedBy: AM0PR06CA0123.eurprd06.prod.outlook.com (2603:10a6:208:ab::28) To MRXP264MB0325.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:22::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from renataOAB.oneaccess.intra (91.183.184.98) by AM0PR06CA0123.eurprd06.prod.outlook.com (2603:10a6:208:ab::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.20 via Frontend Transport; Wed, 13 May 2020 13:15:04 +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: 4236b13e-f80a-4e57-245f-08d7f73fa683 X-MS-TrafficTypeDiagnostic: MRXP264MB0359: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1002; X-Forefront-PRVS: 0402872DA1 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mGXoA1/nRDX0E0LPpxBY1/63EM5IIPeHKeVOKCf/UC2j3g7mwgm2KVUF3Hw52bfLDPf+zNc1pk620HMcH/HL7RohEQ3qAJ4yCiH1pyMWrqVa11JHM5aBfn6IZJVVHsCeI+z9HW2DU1sRjSj1e037KHY4H59EU/7KLvtBViogld9lVGcQSGCqBb9DvZUgEiu8ME788Cxx9QYsmbb/lSSINjknNzVgRbBu9vluCnvzDLr5khhItNW5EcVEfU6wF77E2RRvsCqZ27JxVjzzlcHAePXKEN+RsdtkJEepebr8QjYGkrqf0+OT99DR2OK1qn8BrjKgrTBKSX5LSmhIj2H5DdxmEMJqs85wau8QJiPGJfm8dS8ZHKky6meV50SEHRUB0PdvVbLq/+evitSLHmDiBeUwnbZ3fnlR5ovf2lJasQ4nPVA7zC8HVcZCA7clnVoBtKy2rDHsfXQ/zsFle7tRFLsfnbJKdsx350qg2l8+ujGFOLjk1iQRuVHYTtZakCH7LkIlY3ao5T+rnYVEjivP3Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MRXP264MB0325.FRAP264.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFTY:; SFS:(346002)(376002)(136003)(366004)(39850400004)(396003)(33430700001)(16526019)(33440700001)(8936002)(6486002)(5660300002)(2616005)(86362001)(956004)(6512007)(107886003)(66476007)(66556008)(316002)(66946007)(4326008)(6506007)(2906002)(26005)(6666004)(36756003)(52116002)(186003)(6916009)(478600001)(8676002)(1076003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: k8j5MmmPbTEba4UwNzVHSD/EWkHo8f2cK00Z593gdDy2zNUK9Mvs0UY/yzCMr3GBNb7MEuOuGrDCU/F5RxYUEPRLUQG5PeKCje9/JZeWwZ1wypkdRy8ggR6yPYuKGWSr8+EH61W0OnTd6X3ScCDmtw1RKmEbNcBSMMAr1uM329RU6hAx3N8l3yv5JHQYlyY3/rMYUCpQoIbloTlngtL2bTKZ063F5uuAlE4UqabUE5CtmoLTAiSJA75UQLzS0rlJ5pfOuwD6fIwxLEexccne16dAe/gzyil+T+DNh4uTvK7OXXrCct0GxQelt4o6nLwzng2vhRGrPGOp89A3tC65WI9s3g0PenEVHiF+MEs1syxLmWYg3Adx/fiani8BDk12bsHDsLn+msSTwOb+jsDHVbBN/4gcuw8IqR106UorDFdbNoV2gtiZPpTfhrKMRHMgZyKEOgjIrpSHvjGlTzDOnvK2xCKV08XjkfFCC0NiCKo6FOtiabTepgG6NqMrmOry X-OriginatorOrg: ekinops.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4236b13e-f80a-4e57-245f-08d7f73fa683 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 May 2020 13:15:04.6296 (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: zj4vksRdk2w/AU7b9/ChyLCFWaLdcBgiCw32JEdp31His0zdMWBhy+9Nq1blNXpGj/5X29G+/o8zzB/xgP1cL+BXlVOJDvSuBscIpFb+Y/w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MRXP264MB0359 Subject: [dpdk-dev] [PATCH v3 1/4] librte_ethdev: Introduce a 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 | 28 ++++++++++++++++++++++-- lib/librte_ethdev/rte_ethdev_driver.h | 20 +++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 1 + 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 72aed59a5..55f047e22 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -4181,6 +4181,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, @@ -4190,8 +4194,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; @@ -4206,6 +4209,27 @@ 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); + + 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..462e765d1 100644 --- a/lib/librte_ethdev/rte_ethdev_driver.h +++ b/lib/librte_ethdev/rte_ethdev_driver.h @@ -180,6 +180,26 @@ 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); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * 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_experimental +int +rte_eth_dma_zone_free(const struct rte_eth_dev *dev, const char *ring_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..139a81302 100644 --- a/lib/librte_ethdev/rte_ethdev_version.map +++ b/lib/librte_ethdev/rte_ethdev_version.map @@ -241,4 +241,5 @@ EXPERIMENTAL { __rte_ethdev_trace_rx_burst; __rte_ethdev_trace_tx_burst; rte_flow_get_aged_flows; + rte_eth_dma_zone_free; }; -- 2.17.2