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 D09D4A034F; Wed, 13 May 2020 11:48:48 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 70B091D414; Wed, 13 May 2020 11:48:48 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 8BC3D1C2F9 for ; Wed, 13 May 2020 11:48:46 +0200 (CEST) IronPort-SDR: j+k2Oy2rTalqbx++sa6R1Phb/SmoWFxdjszKYL2ppxKEf0xYsuQStf1eho/YRLSwn9ebp+OpKn MuAJylj2Sqsg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2020 02:48:30 -0700 IronPort-SDR: pJDBI08rP+asyQqKkM+6+DvH4GM5KVMqMOCo0cDrenWZ/rPqrM2av7S99lXEFa1RqtDLmq/0jw jvcvijtbPM6A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,387,1583222400"; d="scan'208";a="265812945" Received: from aburakov-mobl.ger.corp.intel.com (HELO [10.254.0.95]) ([10.254.0.95]) by orsmga006.jf.intel.com with ESMTP; 13 May 2020 02:48:29 -0700 To: Renata Saiakhova , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Ray Kinsella , Neil Horman Cc: dev@dpdk.org References: <20200513091547.19658-1-Renata.Saiakhova@ekinops.com> <20200513091547.19658-2-Renata.Saiakhova@ekinops.com> From: "Burakov, Anatoly" Message-ID: <5ff280ce-551b-5c10-75ee-617250742f9a@intel.com> Date: Wed, 13 May 2020 10:48:28 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200513091547.19658-2-Renata.Saiakhova@ekinops.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [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" On 13-May-20 10:15 AM, Renata Saiakhova wrote: > 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 Not sure #undef is necessary in a .c file :) Otherwise LGTM Acked-by: Anatoly Burakov -- Thanks, Anatoly