mlx5 PMDs use the mlx5_dev_to_pci_addr() routine to convert
Infiniband device name to the Bus-Device-Function location
on the PCI bus. The routine returned success even in case of
not found identification string. On caller side it likely
caused the wrong match with the BDF of previous device
resulting in wrong representor and master recognitions.
Fixes:
771fa900b73a ("mlx5: introduce new driver for Mellanox ConnectX-4 adapters")
Cc: stable@dpdk.org
Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
{
FILE *file;
char line[32];
+ int rc = -ENOENT;
MKSTR(path, "%s/device/uevent", dev_path);
file = fopen(path, "rb");
}
while (fgets(line, sizeof(line), file) == line) {
size_t len = strlen(line);
- int ret;
/* Truncate long lines. */
- if (len == (sizeof(line) - 1))
+ if (len == (sizeof(line) - 1)) {
while (line[(len - 1)] != '\n') {
- ret = fgetc(file);
+ int ret = fgetc(file);
+
if (ret == EOF)
- break;
+ goto exit;
line[(len - 1)] = ret;
}
+ /* No match for long lines. */
+ continue;
+ }
/* Extract information. */
if (sscanf(line,
"PCI_SLOT_NAME="
&pci_addr->bus,
&pci_addr->devid,
&pci_addr->function) == 4) {
+ rc = 0;
break;
}
}
+exit:
fclose(file);
- return 0;
+ if (rc)
+ rte_errno = -rc;
+ return rc;
}
/**