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 12CD2A034F; Wed, 13 May 2020 11:17:29 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E703E1D455; Wed, 13 May 2020 11:17:28 +0200 (CEST) Received: from FRA01-PR2-obe.outbound.protection.outlook.com (mail-eopbgr120125.outbound.protection.outlook.com [40.107.12.125]) by dpdk.org (Postfix) with ESMTP id 56CAB1D44F for ; Wed, 13 May 2020 11:17:28 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BSapHwuFcG3mEx0BuanYKm5hoxdV6otLcw1/kzqDgf6F3D/mdYqQWxuq27rm/cbUEituQmoj3L85j+gFAZvvDGUSn2RfVGIdBXkVSQHQ+vwT44hgrU9a/v3KFEyiZNUHe8aWySwhFHfi9pzcr16HZ8EJQDrUFL+Xw6bixlZyUMFIbbM6jR83yTGY8hRXJorKC1B9CuX2LW7Wy7fhI9wYtygooAAUUY3JPLUq4YIpUBhImWxcVcx70x8B7DHbaHMM8qFKuwQZQ3YMdmP+AQp3YH2Qgzj89O2IRJyQKbayM9u+v8gtibPNCJTl4ZH4aAohgBcXNSEyEsIGsvd0BMgCdw== 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=PtGwWN8omLnNJf39K9VzTP+esJzwx9S2Asble0M5YeQ=; b=F634xZQkXj54ZI3Cz2mpCewL7h1OwQAriQGpY1kAyp1VvoUrtptsPd+uSROtYiZt64Hs00T1hwtngxOUgIwewbR76jIav4iaQsQdbrjd8nkd/J+SyU4u0L5u+/BLJM/ZPUT6d95hMyBc238FxSrzRrhT28g5lx8ddAIsz65Kp7X41MoHBOjS8GFE8um8B9UAqJv5tjclV9HkRI+3AnNZY62Zk8KsJs2VlfpgUqQzSoKFucUCPoYfghSfTnb8Q2GktJiA+9EW30ggP2WI0cqMlzNCusWHoy2+pTCyB6jOH9SmH07bTcok5C+cTcoizzNehciUEsWKl0qMOMMqEcQNwA== 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=PtGwWN8omLnNJf39K9VzTP+esJzwx9S2Asble0M5YeQ=; b=nZnqKi6+TjfuqkBAOTk+RjUYxkqWOVZYTdBqy7oUDJ81j5OzNtvrXhtMUZy6gueRGSiovVJLeDRvrzNZFqPJE3SSWSW3OSGQmVd+K1nyHd5LweT/uhJG1F9UAU+iL2iLilfBNPdxiwJPJLVfTYj6D7gvY9xZ4Jo8De6I396NjIw= Authentication-Results: monjalon.net; dkim=none (message not signed) header.d=none;monjalon.net; dmarc=none action=none header.from=ekinops.com; Received: from MRXP264MB0325.FRAP264.PROD.OUTLOOK.COM (52.134.49.19) by MRXP264MB0183.FRAP264.PROD.OUTLOOK.COM (52.134.44.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.26; Wed, 13 May 2020 09:17:27 +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 09:17:27 +0000 From: Renata Saiakhova To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Ray Kinsella , Neil Horman Cc: dev@dpdk.org, Renata Saiakhova Date: Wed, 13 May 2020 11:15:44 +0200 Message-Id: <20200513091547.19658-2-Renata.Saiakhova@ekinops.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200513091547.19658-1-Renata.Saiakhova@ekinops.com> References: <20200513091547.19658-1-Renata.Saiakhova@ekinops.com> Content-Type: text/plain X-ClientProxiedBy: AM4PR05CA0018.eurprd05.prod.outlook.com (2603:10a6:205::31) 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 AM4PR05CA0018.eurprd05.prod.outlook.com (2603:10a6:205::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.30 via Frontend Transport; Wed, 13 May 2020 09:17:27 +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: c8bbecc3-737c-4e91-2c01-08d7f71e749b X-MS-TrafficTypeDiagnostic: MRXP264MB0183: 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: 2JRIQmgHdVz3fb0hx4AntKx12D5ZyzIYV1oP42Q0T4rHol1pkt7Sny8RHmjLx3+fr2ch7lm7bDQEtAIEqFRngdFMqt/S/yTcQelAeWyp/Ho/8lRoeuh7wxDb1r/EzsdNh8ziUiixvuMS4WOmWXTVs0D5hVwEAxTIyf/FKqRgisWE2z1HvwPwnQ49995oCOze0BzLOx+PgubFko0t4qiZgTMYhfv4vpxPZBbtWCaIUm/9hBsVwcNPlQujpyl6Gs6PvR3c9AhyR7tOmJlYp6XpPtZIXjLAciOom19kinRVFYckmiLRjQd2Io7T/Fi89En1yL6L8EIfVbf4+2YiECWoeKMh9hY6XsIrJHPPrnlEzFooLGsnG+khqPwNKe6SV4j/ydQzgin9WVq6CBob76GvALUSPnaU0+/EQBpQYZhwlx+q/CpPWHtqERi2EyI/DUCbYH9Le547Jt2JzVY7U54TFn9GcDJ0eFnPy5YdNt2ijeEEhTDA7iMPFDLhO47szATX3Q5ZPLCF+hCsVFcr2dtTFQ== 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:(366004)(396003)(346002)(376002)(39840400004)(136003)(33430700001)(33440700001)(2616005)(66946007)(2906002)(110136005)(956004)(86362001)(66556008)(66476007)(6486002)(4326008)(316002)(6512007)(8676002)(8936002)(16526019)(6506007)(107886003)(6666004)(5660300002)(26005)(1076003)(36756003)(478600001)(186003)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: zcQpqNCPXASbwzBFNBQHVCW+ZuPcJzbEpRZ8eYhNJjrFlP6N6uqgrQ1Xtu/LwgnnXtdgZT5GeIhxU9eTp5otXoBCTjv8faGWr8QMivqZLLRnc+t7S7RjazaCb9q8bVKm1sKmZ1bgHJCNbh9nbhBBMCmOXAcgEpjgqCrAUObhNNlZVsdV3HtdyKwnkNjrmmkaOo4QvmK0GV7yYkd8FS4p8a3ScMxDDFGDFjMNld/5J5YAT3+ZGXA3K0KZYnBhQgm4s7uQVBMTpJ4dVf5yAP8vU9sm8Y1ByTcbVqd+zIUAFWzkKa1l/8YJvJs9WCl8KGtYXYdPnKLUVNW3/N78+D6YVzswzK5XHpE3OFfbLFtFidJMQVgrmkm9iL/FuCIB0HuEhSCjbGjoUxMlVPcEj7z2hOjpFgizs1760UXot2aL0BDxDPjlR2qhFjMC0+QzD9No0gSot9442CRiE74fb0wJwdL3Nrt1dj5xOgeXKn9EeLI= X-OriginatorOrg: ekinops.com X-MS-Exchange-CrossTenant-Network-Message-Id: c8bbecc3-737c-4e91-2c01-08d7f71e749b X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 May 2020 09:17:27.4919 (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: 0wYTEfVcCSwff/Qqb4jglAG2I/gKMUkn4R+ufRH00V3DfiX5SC07UAtroa+9zonnwGr0R3qY55YXosCF6P/HVLYpLVc9rGHYkX/dy+YpJ1c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MRXP264MB0183 Subject: [dpdk-dev] [PATCH v2 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 | 30 ++++++++++++++++++++++-- lib/librte_ethdev/rte_ethdev_driver.h | 19 +++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 1 + 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 72aed59a5..7200ef48c 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,29 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, RTE_MEMZONE_IOVA_CONTIG, align); } +int __rte_experimental +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; +} + +#undef ETH_DMA_MZONE_NAME + 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..f32d55720 100644 --- a/lib/librte_ethdev/rte_ethdev_driver.h +++ b/lib/librte_ethdev/rte_ethdev_driver.h @@ -180,6 +180,25 @@ 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. + */ +int __rte_experimental +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