Blob Blame History Raw
From cee3f7b101fb22540e2f92067a5c49d3f817e441 Mon Sep 17 00:00:00 2001
From: Jordan Hargrave <Jordan_Hargrave@dell.com>
Date: Tue, 25 Feb 2014 15:51:50 -0600
Subject: [PATCH] Scan for devid for Mellanox cards

---
 src/eths.c | 15 +++++++++++++++
 src/eths.h |  1 +
 2 files changed, 16 insertions(+)

diff --git a/src/eths.c b/src/eths.c
index bcd02e1..38bb7fe 100644
--- a/src/eths.c
+++ b/src/eths.c
@@ -34,6 +34,20 @@ char *pr_ether(char *buf, const int size, const unsigned char *s)
 	return (buf);
 }
 
+static int eths_get_devid(const char *devname, int *devid)
+{
+	char path[PATH_MAX];
+	char *devidstr = NULL;
+
+	*devid = -1;
+	snprintf(path, sizeof(path), "/sys/class/net/%s/dev_id", devname);
+	if (sysfs_read_file(path, &devidstr) == 0) {
+		sscanf(devidstr, "%i", devid);
+		free(devidstr);
+	}
+	return NULL;
+}
+
 static int eths_get_ifindex(const char *devname, int *ifindex)
 {
 	int fd, err;
@@ -149,6 +163,7 @@ static void fill_eth_dev(struct network_device *dev)
 	eths_get_ifindex(dev->kernel_name, &dev->ifindex);
 	eths_get_hwaddr(dev->kernel_name, dev->dev_addr, sizeof(dev->dev_addr), &dev->arphrd_type);
 	eths_get_permaddr(dev->kernel_name, dev->perm_addr, sizeof(dev->perm_addr));
+	eths_get_devid(dev->kernel_name, &dev->devid);
 	rc = eths_get_info(dev->kernel_name, &dev->drvinfo);
 	if (rc == 0)
 		dev->drvinfo_valid = 1;
diff --git a/src/eths.h b/src/eths.h
index f686136..12c278b 100644
--- a/src/eths.h
+++ b/src/eths.h
@@ -27,6 +27,7 @@ struct network_device {
 	int arphrd_type; /* e.g. ARPHDR_ETHER */
 	int hardware_claimed; /* true when recognized as PCI or PCMCIA and added to list of bios_devices */
   	int ifindex;
+	int devid;
 };
 
 extern void get_eths(struct libbiosdevname_state *state);
-- 
1.8.4.2