|
|
923a60 |
From 88eb414beca3ab29f40a6e422faa790ddaae2918 Mon Sep 17 00:00:00 2001
|
|
|
923a60 |
From: Tom Gundersen <teg@jklm.no>
|
|
|
923a60 |
Date: Wed, 1 Apr 2015 16:51:02 +0200
|
|
|
923a60 |
Subject: [PATCH] udev: net_id - support multi-port enpo* device names
|
|
|
923a60 |
|
|
|
923a60 |
I'd argue that having firmware labels for such devices makes
|
|
|
923a60 |
no sense, but they exist, so make sure we handle them as best
|
|
|
923a60 |
as we can.
|
|
|
923a60 |
---
|
|
|
923a60 |
src/udev/udev-builtin-net_id.c | 33 +++++++++++++++++++++++++--------
|
|
|
923a60 |
1 file changed, 25 insertions(+), 8 deletions(-)
|
|
|
923a60 |
|
|
|
923a60 |
diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
|
|
|
923a60 |
index 99caa0a2ab..6a5ada6883 100644
|
|
|
923a60 |
--- a/src/udev/udev-builtin-net_id.c
|
|
|
923a60 |
+++ b/src/udev/udev-builtin-net_id.c
|
|
|
923a60 |
@@ -35,7 +35,7 @@
|
|
|
923a60 |
* Type of names:
|
|
|
923a60 |
* b<number> -- BCMA bus core number
|
|
|
923a60 |
* ccw<name> -- CCW bus group name
|
|
|
923a60 |
- * o<index> -- on-board device index number
|
|
|
923a60 |
+ * o<index>[d<dev_port>] -- on-board device index number
|
|
|
923a60 |
* s<slot>[f<function>][d<dev_port>] -- hotplug slot index number
|
|
|
923a60 |
* x<MAC> -- MAC address
|
|
|
923a60 |
* [P<domain>]p<bus>s<slot>[f<function>][d<dev_id>/<dev_port>]
|
|
|
923a60 |
@@ -128,22 +128,39 @@ struct netnames {
|
|
|
923a60 |
|
|
|
923a60 |
/* retrieve on-board index number and label from firmware */
|
|
|
923a60 |
static int dev_pci_onboard(struct udev_device *dev, struct netnames *names) {
|
|
|
923a60 |
- const char *index;
|
|
|
923a60 |
+ unsigned dev_port = 0;
|
|
|
923a60 |
+ size_t l;
|
|
|
923a60 |
+ char *s;
|
|
|
923a60 |
+ const char *attr;
|
|
|
923a60 |
int idx;
|
|
|
923a60 |
|
|
|
923a60 |
/* ACPI _DSM -- device specific method for naming a PCI or PCI Express device */
|
|
|
923a60 |
- index = udev_device_get_sysattr_value(names->pcidev, "acpi_index");
|
|
|
923a60 |
+ attr = udev_device_get_sysattr_value(names->pcidev, "acpi_index");
|
|
|
923a60 |
/* SMBIOS type 41 -- Onboard Devices Extended Information */
|
|
|
923a60 |
- if (!index)
|
|
|
923a60 |
- index = udev_device_get_sysattr_value(names->pcidev, "index");
|
|
|
923a60 |
- if (!index)
|
|
|
923a60 |
+ if (!attr)
|
|
|
923a60 |
+ attr = udev_device_get_sysattr_value(names->pcidev, "index");
|
|
|
923a60 |
+ if (!attr)
|
|
|
923a60 |
return -ENOENT;
|
|
|
923a60 |
- idx = strtoul(index, NULL, 0);
|
|
|
923a60 |
+
|
|
|
923a60 |
+ idx = strtoul(attr, NULL, 0);
|
|
|
923a60 |
if (idx <= 0)
|
|
|
923a60 |
return -EINVAL;
|
|
|
923a60 |
- snprintf(names->pci_onboard, sizeof(names->pci_onboard), "o%d", idx);
|
|
|
923a60 |
+
|
|
|
923a60 |
+ /* kernel provided multi-device index */
|
|
|
923a60 |
+ attr = udev_device_get_sysattr_value(dev, "dev_port");
|
|
|
923a60 |
+ if (attr)
|
|
|
923a60 |
+ dev_port = strtol(attr, NULL, 10);
|
|
|
923a60 |
+
|
|
|
923a60 |
+ s = names->pci_onboard;
|
|
|
923a60 |
+ l = sizeof(names->pci_onboard);
|
|
|
923a60 |
+ l = strpcpyf(&s, l, "o%d", idx);
|
|
|
923a60 |
+ if (dev_port > 0)
|
|
|
923a60 |
+ l = strpcpyf(&s, l, "d%d", dev_port);
|
|
|
923a60 |
+ if (l == 0)
|
|
|
923a60 |
+ names->pci_onboard[0] = '\0';
|
|
|
923a60 |
|
|
|
923a60 |
names->pci_onboard_label = udev_device_get_sysattr_value(names->pcidev, "label");
|
|
|
923a60 |
+
|
|
|
923a60 |
return 0;
|
|
|
923a60 |
}
|
|
|
923a60 |
|