On Wed, Mar 06, 2019 at 12:08:47PM +0200, Leon Romanovsky wrote: > From: Leon Romanovsky <leonro@xxxxxxxxxxxx> > > Generalize the naming scheme for RDMA devices, so users will always > see names based on topology/GUID information. Such naming scheme has > big advantage that the names are fully automatic, fully predictable > and they stay fixed even if hardware is added or removed (i.e. no > reenumeration takes place) and that broken hardware can be replaced > seamlessly. > > The naming policy is possible to chose from NAME_KERNEL, NAME_PCI, > NAME_GUID or NAME_FALLBACK, which is controlled by udev rule. > > * NAME_KERNEL - don't change names and rely on kernel assignment. This > will keep RDMA names as before. Example: "mlx5_0". > * NAME_PCI - read PCI location and topology as a source for stable names, > which won't change in any software event (reset, PCI probe e.t.c.). > Example: "mlxp0s12f4". I don't think we should have the vendor/driver name in the stable names. Ethernet doesn't do this. At worst it should be the base technology: ibp0s12f4 rocep0s12f4 iwp0s12f4 opap0s12f4 etc > +static int by_pci(struct data *d) > +{ > + char *path, *token, *pci; > + char buf[256]; > + long p, s, f; > + ssize_t len; > + int ret; > + > + ret = asprintf(&path, "/sys/class/infiniband/%s", d->curr); > + if (ret == -1) { > + path = NULL; > + ret = -ENOMEM; > + goto out; > + } > + > + len = readlink(path, buf, sizeof(buf)-1); > + if (len == -1) { > + ret = -EINVAL; > + goto out; > + } > + pci = buf + strlen("../../devices/pci0000:00/"); This is really sketchy. Do dev_path = realpath(/sys/class/infiniband/%s/device/) Check that stat(dev_path + /subsystem).st_inode == stat("/sys/bus/pci").st_inode To confirm PCI Strip the last path off to get the domain:B:D.f: basename(dev_path) Jason