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 BE6D5A0519; Mon, 22 Jun 2020 11:55:32 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8E8C91D645; Mon, 22 Jun 2020 11:55:31 +0200 (CEST) Received: from FRA01-PR2-obe.outbound.protection.outlook.com (mail-eopbgr120091.outbound.protection.outlook.com [40.107.12.91]) by dpdk.org (Postfix) with ESMTP id 2EBDC1D644 for ; Mon, 22 Jun 2020 11:55:30 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iL/9ZF5fyuIUDq42FkpkRWaDlVovn6q9OfwrqpGWzdtPY/rnYKzNO6nm68+2th841ZjatwZN8bT0gYtsanZAKP4jxmJHLySoPfod+baET6LFX0KyE9UGhcWQy6XeCYE5BqZYUH5/YBdjGYf7MFsFb1MZTmhE4kCY5eJ5ESxVtwUleM/SFzmjio90BberTemU0AK24wdMebdkZ+3Mo7YjSFep0v3/BoTQ2SnMzEBmmQOO1m0VOjV/rxjN8oycJxA++0IzyT5lhffkCvipumxbutMgdUaaRjngi9VwQYRp/s1iAZzGU8TdNlkex2+/+AMpwzLfBIGmpbMVD9KQilKCKw== 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=5qPWXZYMCjRIvc6Nr1fxWbWpGx18O0qMwS88vEMD/j4=; b=BbLOqGFlDCzWFTLIR7Q87nVjSPGy+5kRC/KFP2M3RkrQfAchECP98sDi+3C5qei4KzdyaAmJpLMX9y5CZqFUssC3tTdCgYMjlaN0DRI8IUX4ot+Zxhyvl2XoZGZDKxLtuKZRd2vdzXY2eQCprL0tpcPaxuhyiybJv3lvVQi1p5ekYHhWqniCM3DtJcdsGR+spcT9fkN0ggombTbPjdjefH+/mWFHua2f+A1TZqgiNyD2gm3BRIyKxOusa2LyXLuYuI/f3x7NErUC7Tw4CUVP+vpQ5i+0HhGMUKCjBJ5O1dXQ8/SMectPqzvXwIrAXGkUu3CiRijcGCpxKQEiuv1NPg== 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=5qPWXZYMCjRIvc6Nr1fxWbWpGx18O0qMwS88vEMD/j4=; b=RU7yI0DjNua+ewdxWZL9mTcHX+BgRSTeVpp97WcQsfPnhJqiThpBKHtAGBNM0Y3iM72TBf6JL7x7JG1hSe66eVRMELMYnTRHMmyaRWyb0qSn0NF9UuBrvfLFYzW0xRFembx+QYYCa4b2zDLEqsrIxqh1frI3HsYIwfJmMURiC8Q= 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 MRXP264MB0391.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:16::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.24; Mon, 22 Jun 2020 09:55:29 +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; Mon, 22 Jun 2020 09:55:29 +0000 From: Renata Saiakhova To: dev@dpdk.org Cc: Renata Saiakhova Date: Mon, 22 Jun 2020 11:54:40 +0200 Message-Id: <20200622095443.26136-2-Renata.Saiakhova@ekinops.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200622095443.26136-1-Renata.Saiakhova@ekinops.com> References: <20200622095443.26136-1-Renata.Saiakhova@ekinops.com> Content-Type: text/plain X-ClientProxiedBy: AM0PR10CA0015.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::25) 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 AM0PR10CA0015.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 09:55:28 +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: 4c9df49f-52ed-4a43-8da6-08d81692650b X-MS-TrafficTypeDiagnostic: MRXP264MB0391: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1002; X-Forefront-PRVS: 0442E569BC X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QOTBL7gNtzY9EVodYuRF299+WhFygGVfyp5XtVrpWBcvAO0gYvzqMmTwTTsgES19btCRH1EIH4YgdY6HctmInJs2zBO2d/OU4LeBr3ARjGdpeB7shliaB7kanL4/NJNbSvJUh6Akqat2gkPxjlTfvzHb8H+GnodFhZuKWmzvs7458r5p2nRcHgTk9MQwstPEj8+jN5Q277KDj5sc+wjFGRXLbfqn8WvpoVtmLASq7vKUrdljjxzQcbEQ4ax3Qf8+buNviV/ljan21qbaz/OUgfQ6VZfq0DbDT/bbNGK71IYcaOUwO0yL1bk/MNYiquJNw2x6F5Yfp766hfY1yTaJzg== 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:(346002)(396003)(136003)(366004)(39840400004)(376002)(316002)(1076003)(478600001)(107886003)(6666004)(36756003)(52116002)(86362001)(8676002)(2906002)(66556008)(8936002)(83380400001)(66476007)(66946007)(16526019)(956004)(26005)(2616005)(186003)(6512007)(6486002)(6506007)(6916009)(5660300002)(4326008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: kZxNac8xZ3m8mAruDsS63jgNd2qkH6wtj1U0MsMULQeYAG6xThOceVCA2MvIrtxJkd3iudm89bEv9f0S0dIXoGftmpVxq4v6B5Cf3TPFx9VuwbUiTQzeAH4DtO7+ok44M2e408+uyag3EcMx5JyVAMA6h9NvPQriKOMYfWBjUumE3rrpnko6CeXqFpB6vIMPMZnv//TdJgqIKwri+ajnM2gT101XxJfOout5K8eXMa7hq17aIdiIa6+DILBJFLyN2/KSNLE9glf2sRGgHZ8WHzajbaznB2IwI+GF5BrBqZyKA/qqyGJ3U+lWIOLKyugUcOr71UG8STpbTp3F8/+JkinGr3UE5F3wrDD4jhz3EJZhtJjF2J3SYL6lE0dHT6kKQClfkU1rlI7RVUAO6c3gjAisTsflh6FpE18oDoOW5ei1scszE6hfioPIN6wqWfL2weXdaLaSrdM8wrht9QvIREL6KBHZndcIA+POfY2d5co= X-OriginatorOrg: ekinops.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4c9df49f-52ed-4a43-8da6-08d81692650b X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2020 09:55:29.0376 (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: IMfXc3jKtBbiEEPVyZGpYL2gqoRxuKwUvo19z3dgKWLf8b6BqAbvRnuWRb7p2qWxic/yQQMoOdNSHAdkRFNQGyFOE9JDOUEDtCaGmVl5XvY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MRXP264MB0391 Subject: [dpdk-dev] [PATCH v4 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 | 20 ++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 1 + 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 72aed59a5..ec1da2006 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_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..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