Skip to content

Commit

Permalink
dma/hisilicon: use common PCI device naming
Browse files Browse the repository at this point in the history
[ upstream commit 0339044 ]

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.

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
  • Loading branch information
fengchengwen authored and kevintraynor committed Feb 28, 2022
1 parent 56d6e5b commit c6aea57
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
4 changes: 2 additions & 2 deletions doc/guides/dmadevs/hisilicon.rst
Expand Up @@ -29,8 +29,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
~~~~~~~~~~~~~~~~~~~~~
Expand Down
23 changes: 7 additions & 16 deletions drivers/dma/hisilicon/hisi_dmadev.c
Expand Up @@ -731,24 +731,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);
}

/**
Expand Down Expand Up @@ -864,7 +855,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);
Expand Down

0 comments on commit c6aea57

Please sign in to comment.