pci: Add the class_id support in pci probe
PATCH 1/1 pci: Add the class_id support in pci probe
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.
--- 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(-)
lib/librte_eal/bsdapp/eal/eal_pci.c +4 -0
@@ -278,6 +278,10 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)/* get subsystem_device id */ dev->id.subsystem_device_id = conf->pc_subdevice; + dev->id.class_id = (conf->pc_class <<16 ) | + (conf->pc_subclass <<8 ) | + (conf->pc_progif); +/* TODO: get max_vfs */ dev->max_vfs =0 ;
lib/librte_eal/common/eal_common_pci.c +3 -0
@@ -162,6 +162,9 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *dif (id_table->subsystem_device_id != dev->id.subsystem_device_id && id_table->subsystem_device_id !=PCI_ANY_ID )continue ; +if (id_table->class_id != dev->id.class_id && + id_table->class_id !=CLASS_ANY_ID ) +continue ;struct rte_pci_addr *loc = &dev->addr;
lib/librte_eal/common/include/rte_pci.h +6 -2
@@ -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. */ };/**
@@ -170,6 +171,7 @@ struct rte_pci_device {/** Any PCI device identifier (vendor, device, ...) */ #define PCI_ANY_ID (0xffff) +#define CLASS_ANY_ID (0xffffff)#ifdef __cplusplus/** C++ macro used to help building up tables of device IDs */
@@ -177,14 +179,16 @@ struct rte_pci_device { (vend), \ (dev), \PCI_ANY_ID , \ - PCI_ANY_ID +PCI_ANY_ID , \ + CLASS_ANY_ID#else /** Macro used to help building up tables of device IDs */ #define RTE_PCI_DEVICE (vend, dev) \ .vendor_id = (vend), \ .device_id = (dev), \ .subsystem_vendor_id = PCI_ANY_ID, \ - .subsystem_device_id = PCI_ANY_ID + .subsystem_device_id = PCI_ANY_ID, \ + .class_id = CLASS_ANY_ID#endif struct rte_pci_driver ;
lib/librte_eal/linuxapp/eal/eal_pci.c +9 -0
@@ -306,6 +306,15 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus, } dev->id.subsystem_device_id = (uint16_t )tmp; +/* 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 ; +/* get max_vfs */ dev->max_vfs =0 ;snprintf (filename,sizeof (filename),"%s/max_vfs" , dirname);
Signature · 1 line
1.9.3
Quoted 7 lines · On Wed, 11 May 2016 14:08:15 +0800 Ziye Yang <[email protected]> wrote:
This patch is used to add the
class_id(class_code,subclass_code,programming_interface) support forpci_deviceprobe. With this patch, it will be flexible for users to probe a class of devices byclass_id.Signed-off-by Ziye Yang <[email protected]>
I like this, and it is necessary but since rte_pci_id is a visible data structure it causes ABI breakage.
Quoted 12 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Wednesday, May 11, 2016 4:21 PM
To: Yang, Ziye <[email protected]>
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH] pci: Add theclass_idsupport in pci probeOn Wed, 11 May 2016 14:08:15 +0800
Ziye Yang <[email protected]> wrote:
Quoted 8 lines
Quoted 5 lines
This patch is used to add the
class_id(class_code,subclass_code,programming_interface) support forpci_deviceprobe. With this patch, it will be flexible for users to probe a class of devices byclass_id.Signed-off-by Ziye Yang <[email protected]>I like this, and it is necessary but since
rte_pci_idis a visible data structure it causes ABI breakage.
A notice was published for this change in 16.04, so we should be ok ABI-wise.
/Bruce
2016-05-11 14:08, Ziye Yang:
Quoted 6 lines
This patch is used to add the
class_id(class_code,subclass_code,programming_interface) support forpci_deviceprobe. With this patch, it will be flexible for users to probe a class of devices byclass_id.
Quoted 7 lines
Signed-off-by Ziye Yang <[email protected]>--- 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.
lib/librte_eal/common/include/rte_pci.h struct rte_pci_id { · line 133
Quoted 8 lines
lib/librte_eal/common/include/rte_pci.h +1
-0@@ -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.
lib/librte_eal/common/include/rte_pci.h struct rte_pci_device { · line 174
Quoted 3 lines
lib/librte_eal/common/include/rte_pci.h +1
-0/** Any PCI device identifier (vendor, device, ...) */ #define PCI_ANY_ID (0xffff) +#define CLASS_ANY_ID (0xffffff)
These constants should be prefixed with RTE_.
lib/librte_eal/linuxapp/eal/eal_pci.c pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus, · line 316
Quoted 10 lines
lib/librte_eal/linuxapp/eal/eal_pci.c +8
-0+/* 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?
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Thursday, May 19, 2016 6:34 PM
To: Yang, Ziye <[email protected]>
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH] pci: Add the class_id support in pci probe
2016-05-11 14:08, Ziye Yang:
Quoted 11 lines
This patch is used to add the
class_id(class_code,subclass_code,programming_interface) support forpci_deviceprobe. With this patch, it will be flexible for users to probe a class of devices byclass_id.Signed-off-by Ziye Yang <[email protected]>--- 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.
lib/librte_eal/common/include/rte_pci.h struct rte_pci_id { · line 133
Quoted 9 lines
lib/librte_eal/common/include/rte_pci.h +0
-0@@ -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. */lib/librte_eal/common/include/rte_pci.h +1
-0+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.
Quoted 3 lines
/** Any PCI device identifier (vendor, device, ...) */ #define
PCI_ANY_ID(0xffff)
+#defineCLASS_ANY_ID(0xffffff)
These constants should be prefixed with RTE_.
[Ziye] suggest for doing another patch to change PCI_ANY_ID to RTE_PCI_ANY_ID since it will affect Other files.
lib/librte_eal/linuxapp/eal/eal_pci.c pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus, · line 316
Quoted 10 lines
lib/librte_eal/linuxapp/eal/eal_pci.c +8
-0+/* 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? [Ziye] Only 24bit info is needed.
2016-05-19 12:18, Yang, Ziye:
Quoted 6 lines
From: Thomas Monjalon [mailto:[email protected]] 2016-05-11 14:08, Ziye Yang:
lib/librte_eal/linuxapp/eal/eal_pci.c pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus, · line 316
Quoted 1 line
lib/librte_eal/linuxapp/eal/eal_pci.c +1
-0+ dev->id.class_id = (uint32_t )tmp &&CLASS_ANY_ID ;Should be a bitwise &. Why masking is needed?
[Ziye] Only 24bit info is needed.
What are the other bits?
Please put a comment in the code.
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Thursday, May 19, 2016 8:57 PM
To: Yang, Ziye <[email protected]>
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH] pci: Add the class_id support in pci probe
2016-05-19 12:18, Yang, Ziye:
Quoted 6 lines
From: Thomas Monjalon [mailto:[email protected]] 2016-05-11 14:08, Ziye Yang:
lib/librte_eal/linuxapp/eal/eal_pci.c pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus, · line 316
Quoted 1 line
lib/librte_eal/linuxapp/eal/eal_pci.c +1
-0+ dev->id.class_id = (uint32_t )tmp &&CLASS_ANY_ID ;Should be a bitwise &. Why masking is needed?
[Ziye] Only 24bit info is needed.
What are the other bits?
Please put a comment in the code.
[Ziye] Revision ID is defined in pci spec, classid has 24 bits. And when we read from the system, we will only get class_id, subclass and program interface. I will put the comment
PATCH v2 1/1 ci: Add the class_id support in pci probe
In reply to Ziye YangThis 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.
--- doc/guides/rel_notes/deprecation.rst | 6 ------ lib/librte_eal/bsdapp/eal/eal_pci.c | 5 +++++ 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 +++++++++ 5 files changed, 23 insertions(+), 8 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -6
@@ -20,12 +20,6 @@ Deprecation Notices do not need to care about the kind of devices that are being used, making it easier to add new buses later. -* ABI changes are planned for struct rte_pci_id, i.e., add new field ``class``. - This new added ``class`` field can be used to probe pci device by class - related info. This change should impact size of struct rte_pci_id and struct - rte_pci_device. The release 16.04 does not contain these ABI changes, but - release 16.07 will. - * The xstats API and rte_eth_xstats struct will be changed to allow retrieval of values without any string copies or parsing. No backwards compatibility is planned, as it would require code duplication
lib/librte_eal/bsdapp/eal/eal_pci.c +5 -0
@@ -278,6 +278,11 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)/* get subsystem_device id */ dev->id.subsystem_device_id = conf->pc_subdevice; +/* get class id */ + dev->id.class_id = (conf->pc_class <<16 ) | + (conf->pc_subclass <<8 ) | + (conf->pc_progif); +/* TODO: get max_vfs */ dev->max_vfs =0 ;
lib/librte_eal/common/eal_common_pci.c +3 -0
@@ -162,6 +162,9 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *dif (id_table->subsystem_device_id != dev->id.subsystem_device_id && id_table->subsystem_device_id !=PCI_ANY_ID )continue ; +if (id_table->class_id != dev->id.class_id && + id_table->class_id !=RTE_CLASS_ANY_ID ) +continue ;struct rte_pci_addr *loc = &dev->addr;
lib/librte_eal/common/include/rte_pci.h +6 -2
@@ -125,6 +125,7 @@ struct rte_pci_resource {* table of these IDs for each device that it supports. */ struct rte_pci_id { +uint32_t class_id;/**< Class ID (class, subclass, pi) or RTE_CLASS_ANY_ID. */ uint16_t vendor_id;/**< Vendor ID or PCI_ANY_ID. */ uint16_t device_id;/**< Device ID or PCI_ANY_ID. */ uint16_t subsystem_vendor_id;/**< Subsystem vendor ID or PCI_ANY_ID. */
@@ -170,6 +171,7 @@ struct rte_pci_device {/** Any PCI device identifier (vendor, device, ...) */ #define PCI_ANY_ID (0xffff) +#define RTE_CLASS_ANY_ID (0xffffff)#ifdef __cplusplus/** C++ macro used to help building up tables of device IDs */
@@ -177,14 +179,16 @@ struct rte_pci_device { (vend), \ (dev), \PCI_ANY_ID , \ - PCI_ANY_ID +PCI_ANY_ID , \ + RTE_CLASS_ANY_ID#else /** Macro used to help building up tables of device IDs */ #define RTE_PCI_DEVICE (vend, dev) \ .vendor_id = (vend), \ .device_id = (dev), \ .subsystem_vendor_id = PCI_ANY_ID, \ - .subsystem_device_id = PCI_ANY_ID + .subsystem_device_id = PCI_ANY_ID, \ + .class_id = RTE_CLASS_ANY_ID#endif struct rte_pci_driver ;
lib/librte_eal/linuxapp/eal/eal_pci.c +9 -0
@@ -306,6 +306,15 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus, } dev->id.subsystem_device_id = (uint16_t )tmp; +/* 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 &RTE_CLASS_ANY_ID ; +/* get max_vfs */ dev->max_vfs =0 ;snprintf (filename,sizeof (filename),"%s/max_vfs" , dirname);
Signature · 1 line
1.9.3
PATCH v3 1/1 ci: Add the class_id support in pci probe
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.
--- doc/guides/rel_notes/deprecation.rst | 6 ------ lib/librte_eal/bsdapp/eal/eal_pci.c | 5 +++++ 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 | 10 ++++++++++ 5 files changed, 24 insertions(+), 8 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -6
@@ -20,12 +20,6 @@ Deprecation Notices do not need to care about the kind of devices that are being used, making it easier to add new buses later. -* ABI changes are planned for struct rte_pci_id, i.e., add new field ``class``. - This new added ``class`` field can be used to probe pci device by class - related info. This change should impact size of struct rte_pci_id and struct - rte_pci_device. The release 16.04 does not contain these ABI changes, but - release 16.07 will. - * The xstats API and rte_eth_xstats struct will be changed to allow retrieval of values without any string copies or parsing. No backwards compatibility is planned, as it would require code duplication
lib/librte_eal/bsdapp/eal/eal_pci.c +5 -0
@@ -278,6 +278,11 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)/* get subsystem_device id */ dev->id.subsystem_device_id = conf->pc_subdevice; +/* get class id */ + dev->id.class_id = (conf->pc_class <<16 ) | + (conf->pc_subclass <<8 ) | + (conf->pc_progif); +/* TODO: get max_vfs */ dev->max_vfs =0 ;
lib/librte_eal/common/eal_common_pci.c +3 -0
@@ -162,6 +162,9 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *dif (id_table->subsystem_device_id != dev->id.subsystem_device_id && id_table->subsystem_device_id !=PCI_ANY_ID )continue ; +if (id_table->class_id != dev->id.class_id && + id_table->class_id !=RTE_CLASS_ANY_ID ) +continue ;struct rte_pci_addr *loc = &dev->addr;
lib/librte_eal/common/include/rte_pci.h +6 -2
@@ -125,6 +125,7 @@ struct rte_pci_resource {* table of these IDs for each device that it supports. */ struct rte_pci_id { +uint32_t class_id;/**< Class ID (class, subclass, pi) or RTE_CLASS_ANY_ID. */ uint16_t vendor_id;/**< Vendor ID or PCI_ANY_ID. */ uint16_t device_id;/**< Device ID or PCI_ANY_ID. */ uint16_t subsystem_vendor_id;/**< Subsystem vendor ID or PCI_ANY_ID. */
@@ -170,6 +171,7 @@ struct rte_pci_device {/** Any PCI device identifier (vendor, device, ...) */ #define PCI_ANY_ID (0xffff) +#define RTE_CLASS_ANY_ID (0xffffff)#ifdef __cplusplus/** C++ macro used to help building up tables of device IDs */
@@ -177,14 +179,16 @@ struct rte_pci_device { (vend), \ (dev), \PCI_ANY_ID , \ - PCI_ANY_ID +PCI_ANY_ID , \ + RTE_CLASS_ANY_ID#else /** Macro used to help building up tables of device IDs */ #define RTE_PCI_DEVICE (vend, dev) \ .vendor_id = (vend), \ .device_id = (dev), \ .subsystem_vendor_id = PCI_ANY_ID, \ - .subsystem_device_id = PCI_ANY_ID + .subsystem_device_id = PCI_ANY_ID, \ + .class_id = RTE_CLASS_ANY_ID#endif struct rte_pci_driver ;
lib/librte_eal/linuxapp/eal/eal_pci.c +10 -0
@@ -306,6 +306,16 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus, } dev->id.subsystem_device_id = (uint16_t )tmp; +/* get class_id */ +snprintf (filename,sizeof (filename),"%s/class" , + dirname); +if (eal_parse_sysfs_value (filename, &tmp) <0 ) { +free (dev); +return -1 ; + } +/* the least 24 bits are valid: class, subclass, program interface */ + dev->id.class_id = (uint32_t )tmp &RTE_CLASS_ANY_ID ; +/* get max_vfs */ dev->max_vfs =0 ;snprintf (filename,sizeof (filename),"%s/max_vfs" , dirname);
Signature · 1 line
1.9.3
Re: [PATCH v3] ci: Add the class_id support in pci probe
Hi Ziye,
Please check the title.
It could be "pci: add class id".
Please try to add a changelog below the 3 dashes when making a new revision.
Other comments below:
2016-05-19 21:17, Ziye Yang:
lib/librte_eal/common/include/rte_pci.h struct rte_pci_resource { · line 131
Quoted 10 lines
lib/librte_eal/common/include/rte_pci.h +1
-0@@ -125,6 +125,7 @@ struct rte_pci_resource {* table of these IDs for each device that it supports. */ struct rte_pci_id { +uint32_t class_id;/**< Class ID (class, subclass, pi) or RTE_CLASS_ANY_ID. */ uint16_t vendor_id;/**< Vendor ID or PCI_ANY_ID. */ uint16_t device_id;/**< Device ID or PCI_ANY_ID. */ uint16_t subsystem_vendor_id;/**< Subsystem vendor ID or PCI_ANY_ID. */
You moved class_id at the beginning (which looks good)...
Quoted 7 lines
lib/librte_eal/common/include/rte_pci.h +2
-1@@ -177,14 +179,16 @@ struct rte_pci_device { (vend), \ (dev), \PCI_ANY_ID , \ -PCI_ANY_ID +PCI_ANY_ID , \ +RTE_CLASS_ANY_ID
lib/librte_eal/common/include/rte_pci.h struct rte_pci_device { · line 192
Quoted 10 lines
lib/librte_eal/common/include/rte_pci.h +2
-1#else /** Macro used to help building up tables of device IDs */ #define RTE_PCI_DEVICE (vend, dev) \ .vendor_id = (vend), \ .device_id = (dev), \ .subsystem_vendor_id = PCI_ANY_ID, \ - .subsystem_device_id = PCI_ANY_ID + .subsystem_device_id = PCI_ANY_ID, \ + .class_id = RTE_CLASS_ANY_ID#endif
... but forgot to move these lines.
PATCH v4 1/1 Pci: Add the class_id support
In reply to Ziye YangThis 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.
---
Changes in v4: adjust title name and change RTE_PCI_DEVICE macro
doc/guides/rel_notes/deprecation.rst | 6 ------ lib/librte_eal/bsdapp/eal/eal_pci.c | 5 +++++ lib/librte_eal/common/eal_common_pci.c | 3 +++ lib/librte_eal/common/include/rte_pci.h | 4 ++++ lib/librte_eal/linuxapp/eal/eal_pci.c | 10 ++++++++++ 5 files changed, 22 insertions(+), 6 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -6
@@ -20,12 +20,6 @@ Deprecation Notices do not need to care about the kind of devices that are being used, making it easier to add new buses later. -* ABI changes are planned for struct rte_pci_id, i.e., add new field ``class``. - This new added ``class`` field can be used to probe pci device by class - related info. This change should impact size of struct rte_pci_id and struct - rte_pci_device. The release 16.04 does not contain these ABI changes, but - release 16.07 will. - * The xstats API and rte_eth_xstats struct will be changed to allow retrieval of values without any string copies or parsing. No backwards compatibility is planned, as it would require code duplication
lib/librte_eal/bsdapp/eal/eal_pci.c +5 -0
@@ -278,6 +278,11 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)/* get subsystem_device id */ dev->id.subsystem_device_id = conf->pc_subdevice; +/* get class id */ + dev->id.class_id = (conf->pc_class <<16 ) | + (conf->pc_subclass <<8 ) | + (conf->pc_progif); +/* TODO: get max_vfs */ dev->max_vfs =0 ;
lib/librte_eal/common/eal_common_pci.c +3 -0
@@ -162,6 +162,9 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *dif (id_table->subsystem_device_id != dev->id.subsystem_device_id && id_table->subsystem_device_id !=PCI_ANY_ID )continue ; +if (id_table->class_id != dev->id.class_id && + id_table->class_id !=RTE_CLASS_ANY_ID ) +continue ;struct rte_pci_addr *loc = &dev->addr;
lib/librte_eal/common/include/rte_pci.h +4 -0
@@ -125,6 +125,7 @@ struct rte_pci_resource {* table of these IDs for each device that it supports. */ struct rte_pci_id { +uint32_t class_id;/**< Class ID (class, subclass, pi) or RTE_CLASS_ANY_ID. */ uint16_t vendor_id;/**< Vendor ID or PCI_ANY_ID. */ uint16_t device_id;/**< Device ID or PCI_ANY_ID. */ uint16_t subsystem_vendor_id;/**< Subsystem vendor ID or PCI_ANY_ID. */
@@ -170,10 +171,12 @@ struct rte_pci_device {/** Any PCI device identifier (vendor, device, ...) */ #define PCI_ANY_ID (0xffff) +#define RTE_CLASS_ANY_ID (0xffffff)#ifdef __cplusplus/** C++ macro used to help building up tables of device IDs */ #define RTE_PCI_DEVICE (vend, dev) \ + RTE_CLASS_ANY_ID, \ (vend), \ (dev), \ PCI_ANY_ID, \
@@ -181,6 +184,7 @@ struct rte_pci_device {#else /** Macro used to help building up tables of device IDs */ #define RTE_PCI_DEVICE (vend, dev) \ + .class_id = RTE_CLASS_ANY_ID, \ .vendor_id = (vend), \ .device_id = (dev), \ .subsystem_vendor_id = PCI_ANY_ID, \
lib/librte_eal/linuxapp/eal/eal_pci.c +10 -0
@@ -306,6 +306,16 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus, } dev->id.subsystem_device_id = (uint16_t )tmp; +/* get class_id */ +snprintf (filename,sizeof (filename),"%s/class" , + dirname); +if (eal_parse_sysfs_value (filename, &tmp) <0 ) { +free (dev); +return -1 ; + } +/* the least 24 bits are valid: class, subclass, program interface */ + dev->id.class_id = (uint32_t )tmp &RTE_CLASS_ANY_ID ; +/* get max_vfs */ dev->max_vfs =0 ;snprintf (filename,sizeof (filename),"%s/max_vfs" , dirname);
Signature · 1 line
1.9.3
Thomas Monjalon
AppliedRe: [PATCH v4] Pci: Add the class_id support
2016-05-24 20:50, Ziye Yang:
Quoted 8 lines
This patch is used to add the
class_id(class_code,subclass_code,programming_interface) support forpci_deviceprobe. With this patch, it will be flexible for users to probe a class of devices byclass_id.Signed-off-by Ziye Yang <[email protected]>
Applied, thanks
Re: [PATCH v4] Pci: Add the class_id support
Quoted 8 lines · Thomas Monjalon
2016-05-24 20:50, Ziye Yang:
Quoted 7 lines
This patch is used to add the
class_id(class_code,subclass_code,programming_interface) support forpci_deviceprobe. With this patch, it will be flexible for users to probe a class of devices byclass_id.
Quoted 4 lines
Quoted 1 line
Signed-off-by Ziye Yang <[email protected]>Applied, thanks
Hi Thomas, Ziye,
Is modification in public "struct rte_pci_id" is a ABI break? If so, it requires eal LIBABIVER increase and release notes update.
Regards,
ferruh
Re: [PATCH v4] Pci: Add the class_id support
2016-07-06 12:08, Ferruh Yigit:
Quoted 9 lines · Thomas Monjalon
Quoted 8 lines
2016-05-24 20:50, Ziye Yang:
Quoted 7 lines
This patch is used to add the
class_id(class_code,subclass_code,programming_interface) support forpci_deviceprobe. With this patch, it will be flexible for users to probe a class of devices byclass_id.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Ziye Yang <[email protected]>Applied, thanks
Hi Thomas, Ziye,
Is modification in public "struct
rte_pci_id" is a ABI break? If so, it requires eal LIBABIVER increase and release notes update.
Not really sure. I was thinking that it is used only by drivers but not by applications.