[Open-FCoE] [RESUBMIT PATCH] libhbalinux: Reading device_id, etc. from sysfs instead of libpciaccess

Steve Ma steve.ma at intel.com
Wed Apr 22 16:21:23 UTC 2009


The vendor_id, device_id, subsystem_vendor_id, subsystem_device_id,
and device_class can be either obtained from libpciaccess and sysfs
for networking HBA. We need only to read these information from
the sysfs, and remove code for getting these information from pci.
---

 lport.c |    4 +---
 pci.c   |   10 +---------
 2 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/lport.c b/lport.c
index 8c1beb7..99629f9 100644
--- a/lport.c
+++ b/lport.c
@@ -181,7 +181,7 @@ sysfs_scan(struct dirent *dp, void *arg)
 		goto skip;
 	buf[i] = '\0';
 
-	if (strstr(buf, "devices/pci")) {
+	if (strstr(buf, "devices/pci") && !strstr(buf, "/net/")) {
 		snprintf(hba_dir, sizeof(hba_dir), "%s/device/..", host_dir);
 	} else {
 		/* assume a net device */
@@ -316,7 +316,6 @@ sysfs_scan(struct dirent *dp, void *arg)
 	snprintf(buf, sizeof(buf), "fcoe:%s", ifname);
 	ap->ad_name = strdup(buf);
 
-#if 0
 	/* Get vendor_id */
 	rc = sa_sys_read_u32(hba_dir, "vendor", &hba_info.vendor_id);
 
@@ -334,7 +333,6 @@ sysfs_scan(struct dirent *dp, void *arg)
 	/* Get device_class */
 	rc = sa_sys_read_u32(hba_dir, "class", &hba_info.device_class);
 	hba_info.device_class = hba_info.device_class>>8;
-#endif
 
 	/*
 	 * Get Hardware Information via PCI Library
diff --git a/pci.c b/pci.c
index 0a06d86..e559ae8 100644
--- a/pci.c
+++ b/pci.c
@@ -158,11 +158,6 @@ get_pci_device_info(struct pci_device *dev, struct hba_info *hba_info)
 	u_int8_t hdr_type;
 	char *unknown = "Unknown";
 
-	hba_info->vendor_id = dev->vendor_id;
-	hba_info->device_id = dev->device_id;
-	hba_info->subsystem_vendor_id = dev->subvendor_id;
-	hba_info->subsystem_device_id = dev->subdevice_id;
-
 	name = pci_device_get_vendor_name(dev);
 	if (!name)
 		name = unknown;
@@ -178,12 +173,9 @@ get_pci_device_info(struct pci_device *dev, struct hba_info *hba_info)
 			name, sizeof(hba_info->ModelDescription));
 
 	/*
-	 * Reading device class and revision from PCIe
+	 * Reading hardware revision from PCIe
 	 * configuration header space.
 	 */
-	pci_device_cfg_read_u16(dev, &class, PCI_CLASS_DEVICE);
-	hba_info->device_class = class;
-
 	pci_device_cfg_read_u8(dev, &revision, PCI_REVISION_ID);
 	snprintf(hba_info->HardwareVersion,
 		 sizeof(hba_info->HardwareVersion),




More information about the devel mailing list