summaryrefslogtreecommitdiff
path: root/drivers/net/mlx5/mlx5_ethdev.c
diff options
context:
space:
mode:
authorViacheslav Ovsiienko <viacheslavo@mellanox.com>2019-03-27 13:15:35 +0000
committerFerruh Yigit <ferruh.yigit@intel.com>2019-03-29 17:25:32 +0100
commit299d7dc28c37afc459a802f6f1ef9ece9f9c0a0c (patch)
tree5b3e3a748f0f2780ad3f35b69fd1c47e4a23e59e /drivers/net/mlx5/mlx5_ethdev.c
parentbc5560c15e74d66b019b4bbbd5573519b0a462c3 (diff)
downloaddpdk-next-eventdev-299d7dc28c37afc459a802f6f1ef9ece9f9c0a0c.zip
dpdk-next-eventdev-299d7dc28c37afc459a802f6f1ef9ece9f9c0a0c.tar.gz
dpdk-next-eventdev-299d7dc28c37afc459a802f6f1ef9ece9f9c0a0c.tar.xz
net/mlx5: add representor recognition on Linux 5.x
The master device and VF representors were distinguished by presence of port name, master device did not have one. The new Linux kernels starting from 5.0 provide the port name for master device and the implemented representor recognizing method does not work. The new recognizing method is based on querying the VF number, has been created on the base of the device. The IFLA_NUM_VF attribute is returned by kernel if IFLA_EXT_MASK attribute is specified in the Netlink request message. Also the presence check of device symlink in device sysfs folder is added to distinguish representors with sysfs based method. Signed-off-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com> Acked-by: Shahaf Shuler <shahafs@mellanox.com>
Diffstat (limited to 'drivers/net/mlx5/mlx5_ethdev.c')
-rw-r--r--drivers/net/mlx5/mlx5_ethdev.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index 2e8a296..933839c 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -1362,8 +1362,10 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info)
.port_name = 0,
.switch_id = 0,
};
+ DIR *dir;
bool port_name_set = false;
bool port_switch_id_set = false;
+ bool device_dir = false;
char c;
int ret;
@@ -1376,6 +1378,8 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info)
ifname);
MKSTR(phys_switch_id, "/sys/class/net/%s/phys_switch_id",
ifname);
+ MKSTR(pci_device, "/sys/class/net/%s/device",
+ ifname);
file = fopen(phys_port_name, "rb");
if (file != NULL) {
@@ -1394,9 +1398,21 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info)
fscanf(file, "%" SCNx64 "%c", &data.switch_id, &c) == 2 &&
c == '\n';
fclose(file);
- data.master = port_switch_id_set && !port_name_set;
- data.representor = port_switch_id_set && port_name_set;
+ dir = opendir(pci_device);
+ if (dir != NULL) {
+ closedir(dir);
+ device_dir = true;
+ }
+ data.master = port_switch_id_set && (!port_name_set || device_dir);
+ data.representor = port_switch_id_set && port_name_set && !device_dir;
*info = data;
+ assert(!(data.master && data.representor));
+ if (data.master && data.representor) {
+ DRV_LOG(ERR, "ifindex %u device is recognized as master"
+ " and as representor", ifindex);
+ rte_errno = ENODEV;
+ return -rte_errno;
+ }
return 0;
}