From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D37A8A00BE; Thu, 17 Feb 2022 04:04:48 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8A10641157; Thu, 17 Feb 2022 04:04:33 +0100 (CET) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id DEB8240DDD for ; Thu, 17 Feb 2022 04:04:29 +0100 (CET) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Jzfls1P8hzbnb7; Thu, 17 Feb 2022 11:03:21 +0800 (CST) Received: from localhost.localdomain (10.67.165.24) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Thu, 17 Feb 2022 11:04:27 +0800 From: Chengwen Feng To: CC: Subject: [PATCH 5/5] dma/hisilicon: use EAL API to generate dmadev name Date: Thu, 17 Feb 2022 10:59:11 +0800 Message-ID: <20220217025911.35822-6-fengchengwen@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220217025911.35822-1-fengchengwen@huawei.com> References: <20220217025911.35822-1-fengchengwen@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500024.china.huawei.com (7.185.36.10) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org For DMA device 0000:7d:0.0, the original generated dmadev name starts with the "7d:0.0", which is not expected. This patch uses rte_pci_device_name API to generates the dmadev name. Cc: stable@dpdk.org Signed-off-by: Chengwen Feng --- doc/guides/dmadevs/hisilicon.rst | 4 ++-- drivers/dma/hisilicon/hisi_dmadev.c | 23 +++++++---------------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/doc/guides/dmadevs/hisilicon.rst b/doc/guides/dmadevs/hisilicon.rst index 81bf090311..8c1f0f8886 100644 --- a/doc/guides/dmadevs/hisilicon.rst +++ b/doc/guides/dmadevs/hisilicon.rst @@ -30,8 +30,8 @@ which can be accessed using API from the ``rte_dmadev`` library. The name of the ``dmadev`` created is like "B:D.F-chX", e.g. DMA 0000:7b:00.0 will create four ``dmadev``, -the 1st ``dmadev`` name is "7b:00.0-ch0", -and the 2nd ``dmadev`` name is "7b:00.0-ch1". +the 1st ``dmadev`` name is "0000:7b:00.0-ch0", +and the 2nd ``dmadev`` name is "0000:7b:00.0-ch1". Device Configuration ~~~~~~~~~~~~~~~~~~~~~ diff --git a/drivers/dma/hisilicon/hisi_dmadev.c b/drivers/dma/hisilicon/hisi_dmadev.c index c36acf01be..9cef2cbfbe 100644 --- a/drivers/dma/hisilicon/hisi_dmadev.c +++ b/drivers/dma/hisilicon/hisi_dmadev.c @@ -784,24 +784,15 @@ hisi_dma_burst_capacity(const void *dev_private, uint16_t vchan) sq_head - 1 - sq_tail; } -static void -hisi_dma_gen_pci_device_name(const struct rte_pci_device *pci_dev, - char *name, size_t size) -{ - memset(name, 0, size); - (void)snprintf(name, size, "%x:%x.%x", - pci_dev->addr.bus, pci_dev->addr.devid, - pci_dev->addr.function); -} - static void hisi_dma_gen_dev_name(const struct rte_pci_device *pci_dev, - uint8_t queue_id, char *name, size_t size) + uint8_t queue_id, char *dev_name, size_t size) { - memset(name, 0, size); - (void)snprintf(name, size, "%x:%x.%x-ch%u", - pci_dev->addr.bus, pci_dev->addr.devid, - pci_dev->addr.function, queue_id); + char name[RTE_DEV_NAME_MAX_LEN] = { 0 }; + + memset(dev_name, 0, size); + rte_pci_device_name(&pci_dev->addr, name, sizeof(name)); + (void)snprintf(dev_name, size, "%s-ch%u", name, queue_id); } /** @@ -917,7 +908,7 @@ hisi_dma_probe(struct rte_pci_driver *pci_drv __rte_unused, uint8_t i; int ret; - hisi_dma_gen_pci_device_name(pci_dev, name, sizeof(name)); + rte_pci_device_name(&pci_dev->addr, name, sizeof(name)); if (pci_dev->mem_resource[2].addr == NULL) { HISI_DMA_LOG(ERR, "%s BAR2 is NULL!\n", name); -- 2.33.0