summaryrefslogtreecommitdiff
path: root/drivers/net/mlx5/mlx5_ethdev.c
diff options
context:
space:
mode:
authorViacheslav Ovsiienko <viacheslavo@mellanox.com>2019-04-05 13:25:55 +0000
committerFerruh Yigit <ferruh.yigit@intel.com>2019-04-12 11:02:02 +0200
commit9c2bbd048856f50297b3c2d751dd2ada7952b7f0 (patch)
treee6bcc98bc127b699574deb0a708af785cf4f6ff5 /drivers/net/mlx5/mlx5_ethdev.c
parentae4eb7dc79005c0a1944eebb5b6c7884768474e0 (diff)
downloaddpdk-next-eventdev-9c2bbd048856f50297b3c2d751dd2ada7952b7f0.zip
dpdk-next-eventdev-9c2bbd048856f50297b3c2d751dd2ada7952b7f0.tar.gz
dpdk-next-eventdev-9c2bbd048856f50297b3c2d751dd2ada7952b7f0.tar.xz
net/mlx5: fix device probing for old kernel drivers
Retrieving network interface index via Netlink fails in case of old ib_core kernel driver installed - mlx5_nl_ifindex() routine fails due to RDMA_NLDEV_ATTR_NDEV_INDEX attribute is not supported by the old driver. The patch allowing to retrieve the network interface index and name via Netlink [1]. So, the problem depends on ib_core module version - 4.16 supports getting ifindex via Netlink, 4.15 does not. This error was ignored in previous versions of MLX5 PMD probing routine. For single device ifindex was retrieved via sysfs and link control was not lost, so problem just was not noticed. In order to support MLX5 PMD functioning over old kernel driver this patch adds ifindex retrieving via sysfs into probing routine. It is worth to note this method works for master/standalone device only. [1] https://www.spinics.net/lists/linux-rdma/msg62948.html Linux tree: 5b2cc79d (Leon Romanovsky 2018-03-27 20:40:49 +0300 270) Fixes: ad74bc619504 ("net/mlx5: support multiport IB device during probing") 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.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index 9ae9ddd..1e6fe19 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -127,21 +127,18 @@ struct ethtool_link_settings {
* @return
* 0 on success, a negative errno value otherwise and rte_errno is set.
*/
-static int
-mlx5_get_master_ifname(const struct rte_eth_dev *dev,
- char (*ifname)[IF_NAMESIZE])
+int
+mlx5_get_master_ifname(const char *ibdev_path, char (*ifname)[IF_NAMESIZE])
{
- struct mlx5_priv *priv = dev->data->dev_private;
DIR *dir;
struct dirent *dent;
unsigned int dev_type = 0;
unsigned int dev_port_prev = ~0u;
char match[IF_NAMESIZE] = "";
- assert(priv);
- assert(priv->sh);
+ assert(ibdev_path);
{
- MKSTR(path, "%s/device/net", priv->sh->ibdev_path);
+ MKSTR(path, "%s/device/net", ibdev_path);
dir = opendir(path);
if (dir == NULL) {
@@ -161,7 +158,7 @@ mlx5_get_master_ifname(const struct rte_eth_dev *dev,
continue;
MKSTR(path, "%s/device/net/%s/%s",
- priv->sh->ibdev_path, name,
+ ibdev_path, name,
(dev_type ? "dev_id" : "dev_port"));
file = fopen(path, "rb");
@@ -222,15 +219,18 @@ int
mlx5_get_ifname(const struct rte_eth_dev *dev, char (*ifname)[IF_NAMESIZE])
{
struct mlx5_priv *priv = dev->data->dev_private;
- unsigned int ifindex =
- priv->nl_socket_rdma >= 0 ?
- mlx5_nl_ifindex(priv->nl_socket_rdma,
- priv->sh->ibdev_name,
- priv->ibv_port) : 0;
+ unsigned int ifindex;
+ assert(priv);
+ assert(priv->sh);
+ ifindex = priv->nl_socket_rdma >= 0 ?
+ mlx5_nl_ifindex(priv->nl_socket_rdma,
+ priv->sh->ibdev_name,
+ priv->ibv_port) : 0;
if (!ifindex) {
if (!priv->representor)
- return mlx5_get_master_ifname(dev, ifname);
+ return mlx5_get_master_ifname(priv->sh->ibdev_path,
+ ifname);
rte_errno = ENXIO;
return -rte_errno;
}