[dpdk-dev] [PATCH] pci: Add the class_id support in pci probe

Thomas Monjalon thomas.monjalon at 6wind.com
Thu May 19 12:33:47 CEST 2016


2016-05-11 14:08, Ziye Yang:
> This patch is used to add the class_id (class_code,
> subclass_code, programming_interface) support for
> pci_device probe. With this patch, it will be
> flexible for users to probe a class of devices
> by class_id.
> 
> Signed-off-by: Ziye Yang <ziye.yang at intel.com>
> ---
>  lib/librte_eal/bsdapp/eal/eal_pci.c     | 4 ++++
>  lib/librte_eal/common/eal_common_pci.c  | 3 +++
>  lib/librte_eal/common/include/rte_pci.h | 8 ++++++--
>  lib/librte_eal/linuxapp/eal/eal_pci.c   | 9 +++++++++
>  4 files changed, 22 insertions(+), 2 deletions(-)

Please remove the deprecation notice.

> --- a/lib/librte_eal/common/include/rte_pci.h
> +++ b/lib/librte_eal/common/include/rte_pci.h
> @@ -129,6 +129,7 @@ struct rte_pci_id {
>  	uint16_t device_id;           /**< Device ID or PCI_ANY_ID. */
>  	uint16_t subsystem_vendor_id; /**< Subsystem vendor ID or PCI_ANY_ID. */
>  	uint16_t subsystem_device_id; /**< Subsystem device ID or PCI_ANY_ID. */
> +	uint32_t class_id;           /**< Class ID (class, subclass, pi) or CLASS_ANY_ID. */
>  };

A space is missing.
It would be more logical to put the class_id at the beginning of the struct.

>  /** Any PCI device identifier (vendor, device, ...) */
>  #define PCI_ANY_ID (0xffff)
> +#define CLASS_ANY_ID (0xffffff)

These constants should be prefixed with RTE_.

> --- a/lib/librte_eal/linuxapp/eal/eal_pci.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
> +	/* get class_id */
> +	snprintf(filename, sizeof(filename), "%s/class",
> +		 dirname);
> +	if (eal_parse_sysfs_value(filename, &tmp) < 0) {
> +		free(dev);
> +		return -1;
> +	}
> +	dev->id.class_id = (uint32_t)tmp && CLASS_ANY_ID;

Should be a bitwise &. Why masking is needed?


More information about the dev mailing list