[dpdk-dev] [PATCH v10 11/25] eal/pci: helpers for device name parsing/update

Shreyansh Jain shreyansh.jain at nxp.com
Wed Oct 26 08:23:17 CEST 2016


Hello Reshma,

On Tuesday 25 October 2016 09:19 PM, Pattan, Reshma wrote:
> Hi Shreyansh,
>
>> -----Original Message-----
>> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Shreyansh Jain
>> Sent: Friday, September 16, 2016 5:30 AM
>> To: dev at dpdk.org
>> Cc: viktorin at rehivetech.com; David Marchand <david.marchand at 6wind.com>;
>> hemant.agrawal at nxp.com; Thomas Monjalon
>> <thomas.monjalon at 6wind.com>; Shreyansh Jain <shreyansh.jain at nxp.com>
>> Subject: [dpdk-dev] [PATCH v10 11/25] eal/pci: helpers for device name
>> parsing/update
>>
>> From: David Marchand <david.marchand at 6wind.com>
>>
>> - Move rte_eth_dev_create_unique_device_name() from ether/rte_ethdev.c to
>>   common/include/rte_pci.h as rte_eal_pci_device_name(). Being a common
>>   method, can be used across crypto/net PCI PMDs.
>> - Remove crypto specific routine and fallback to common name function.
>> - Introduce a eal private Update function for PCI device naming.
>>
>> Signed-off-by: David Marchand <david.marchand at 6wind.com>
>> [Shreyansh: Merge crypto/pci helper patches]
>> Signed-off-by: Shreyansh Jain <shreyansh.jain at nxp.com>
>> ---
>>  lib/librte_cryptodev/rte_cryptodev.c    | 27 +++---------------
>>  lib/librte_eal/bsdapp/eal/eal_pci.c     | 49
>> +++++++++++++++++++++++++++++++++
>>  lib/librte_eal/common/eal_private.h     | 13 +++++++++
>>  lib/librte_eal/common/include/rte_pci.h | 24 ++++++++++++++++
>>  lib/librte_eal/linuxapp/eal/eal_pci.c   | 13 +++++++++
>>  lib/librte_ether/rte_ethdev.c           | 24 +++-------------
>>  6 files changed, 107 insertions(+), 43 deletions(-)
>>
>> diff --git a/lib/librte_cryptodev/rte_cryptodev.c
>> b/lib/librte_cryptodev/rte_cryptodev.c
>> index 2a3b649..c81e366 100644
>> --- a/lib/librte_cryptodev/rte_cryptodev.c
>> +++ b/lib/librte_cryptodev/rte_cryptodev.c
>> @@ -365,23 +365,6 @@ rte_cryptodev_pmd_allocate(const char *name, int
>> socket_id)
>>  	return cryptodev;
>>  }
>>
>>   *
>>   * This function is private to EAL.
>> diff --git a/lib/librte_eal/common/include/rte_pci.h
>> b/lib/librte_eal/common/include/rte_pci.h
>> index cf81898..e1f695f 100644
>> --- a/lib/librte_eal/common/include/rte_pci.h
>> +++ b/lib/librte_eal/common/include/rte_pci.h
>> @@ -82,6 +82,7 @@ extern "C" {
>>  /** Formatting string for PCI device identifier: Ex: 0000:00:01.0 */  #define
>> PCI_PRI_FMT "%.4" PRIx16 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
>> +#define PCI_PRI_STR_SIZE sizeof("XXXX:XX:XX.X")
>>
>>  /** Short formatting string, without domain, for PCI device: Ex: 00:01.0 */
>> #define PCI_SHORT_PRI_FMT "%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8 @@ -308,6
>>
>> +static inline void
>> +rte_eal_pci_device_name(const struct rte_pci_addr *addr,
>> +		    char *output, size_t size)
>> +{
>> +	RTE_VERIFY(size >= PCI_PRI_STR_SIZE);
>> +	RTE_VERIFY(snprintf(output, size, PCI_PRI_FMT,
>> +			    addr->domain, addr->bus,
>> +			    addr->devid, addr->function) >= 0); }
>> +
>>
>> +int
>> +pci_update_device(const struct rte_pci_addr *addr) {
>> +	char filename[PATH_MAX];
>> +
>> +	snprintf(filename, sizeof(filename), "%s/" PCI_PRI_FMT,
>> +		 pci_get_sysfs_path(), addr->domain, addr->bus, addr->devid,
>> +		 addr->function);
>> +
>> +	return pci_scan_one(filename, addr->domain, addr->bus, addr->devid,
>> +				addr->function);
>> +}
>> +
>
>
> Earlier device names were created in the format "bus:deviceid.function" as per the below ethdev API.
> Now after above new eal API the name format is "domain:bus:deviceid.func" was that intentional  and why is that so.

Yes, this is intentional.
It is to bring the naming in sync with the device name being used for 
scanning on the bus (/sys/bus/pci/devices/AAAA:BB:CC.D/).
Also, it was proposed in a separate patch [1] but merged in this series.

[1] http://dpdk.org/ml/archives/dev/2016-July/044614.html

(Just as a note: I am not the original author of this patch but above is 
what I understood and acked it).

>
>> -static int
>> -rte_eth_dev_create_unique_device_name(char *name, size_t size,
>> -		struct rte_pci_device *pci_dev)
>> -{
>> -	int ret;
>> -
>> -	ret = snprintf(name, size, "%d:%d.%d",
>> -			pci_dev->addr.bus, pci_dev->addr.devid,
>> -			pci_dev->addr.function);
>> -	if (ret < 0)
>> -		return ret;
>> -	return 0;
>> -}
>> -
>

-
Shreyansh


More information about the dev mailing list