* [dpdk-dev] [PATCH 1/2] common/mlx5: share kernel interface name getter
@ 2020-06-02 15:53 Matan Azrad
2020-06-02 15:53 ` [dpdk-dev] [PATCH 2/2] vdpa/mlx5: support MTU feature Matan Azrad
` (2 more replies)
0 siblings, 3 replies; 14+ messages in thread
From: Matan Azrad @ 2020-06-02 15:53 UTC (permalink / raw)
To: Viacheslav Ovsiienko; +Cc: dev, Maxime Coquelin
Some configuration of the mlx5 port are done by the kernel net device
associated to the IB device represents the PCI device.
The DPDK mlx5 driver uses linux system calls, for example ioctl, in
order to configure per port configurations requested by the DPDK user.
One of the basic knowledges required to access the correct kernel net
device is its name.
Move function to get interface name from IB device path to the common
library.
Signed-off-by: Matan Azrad <matan@mellanox.com>
---
drivers/common/mlx5/mlx5_common.c | 88 ++++++++++++++++++++++++
drivers/common/mlx5/mlx5_common.h | 3 +
drivers/common/mlx5/rte_common_mlx5_version.map | 2 +
drivers/net/mlx5/mlx5.c | 2 +-
drivers/net/mlx5/mlx5.h | 1 -
drivers/net/mlx5/mlx5_ethdev.c | 90 +------------------------
6 files changed, 96 insertions(+), 90 deletions(-)
diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c
index 1c77763..3f0d8d3 100644
--- a/drivers/common/mlx5/mlx5_common.c
+++ b/drivers/common/mlx5/mlx5_common.c
@@ -8,8 +8,10 @@
#ifdef RTE_IBVERBS_LINK_DLOPEN
#include <dlfcn.h>
#endif
+#include <dirent.h>
#include <rte_errno.h>
+#include <rte_string_fns.h>
#include "mlx5_common.h"
#include "mlx5_common_utils.h"
@@ -167,6 +169,92 @@ enum mlx5_class
return;
}
+/**
+ * Get kernel interface name from IB device path.
+ *
+ * @param[in] ibdev_path
+ * Pointer to IB device path.
+ * @param[out] ifname
+ * Interface name output buffer.
+ *
+ * @return
+ * 0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_get_ifname_sysfs(const char *ibdev_path, char (*ifname)[IF_NAMESIZE])
+{
+ DIR *dir;
+ struct dirent *dent;
+ unsigned int dev_type = 0;
+ unsigned int dev_port_prev = ~0u;
+ char match[IF_NAMESIZE] = "";
+
+ MLX5_ASSERT(ibdev_path);
+ {
+ MKSTR(path, "%s/device/net", ibdev_path);
+
+ dir = opendir(path);
+ if (dir == NULL) {
+ rte_errno = errno;
+ return -rte_errno;
+ }
+ }
+ while ((dent = readdir(dir)) != NULL) {
+ char *name = dent->d_name;
+ FILE *file;
+ unsigned int dev_port;
+ int r;
+
+ if ((name[0] == '.') &&
+ ((name[1] == '\0') ||
+ ((name[1] == '.') && (name[2] == '\0'))))
+ continue;
+
+ MKSTR(path, "%s/device/net/%s/%s",
+ ibdev_path, name,
+ (dev_type ? "dev_id" : "dev_port"));
+
+ file = fopen(path, "rb");
+ if (file == NULL) {
+ if (errno != ENOENT)
+ continue;
+ /*
+ * Switch to dev_id when dev_port does not exist as
+ * is the case with Linux kernel versions < 3.15.
+ */
+try_dev_id:
+ match[0] = '\0';
+ if (dev_type)
+ break;
+ dev_type = 1;
+ dev_port_prev = ~0u;
+ rewinddir(dir);
+ continue;
+ }
+ r = fscanf(file, (dev_type ? "%x" : "%u"), &dev_port);
+ fclose(file);
+ if (r != 1)
+ continue;
+ /*
+ * Switch to dev_id when dev_port returns the same value for
+ * all ports. May happen when using a MOFED release older than
+ * 3.0 with a Linux kernel >= 3.15.
+ */
+ if (dev_port == dev_port_prev)
+ goto try_dev_id;
+ dev_port_prev = dev_port;
+ if (dev_port == 0)
+ strlcpy(match, name, sizeof(match));
+ }
+ closedir(dir);
+ if (match[0] == '\0') {
+ rte_errno = ENOENT;
+ return -rte_errno;
+ }
+ strncpy(*ifname, match, sizeof(*ifname));
+ return 0;
+}
+
#ifdef MLX5_GLUE
/**
diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h
index 8cd3ea5..4f6373b 100644
--- a/drivers/common/mlx5/mlx5_common.h
+++ b/drivers/common/mlx5/mlx5_common.h
@@ -6,6 +6,7 @@
#define RTE_PMD_MLX5_COMMON_H_
#include <stdio.h>
+#include <net/if.h>
#include <rte_pci.h>
#include <rte_debug.h>
@@ -212,6 +213,8 @@ enum mlx5_class {
__rte_internal
void mlx5_translate_port_name(const char *port_name_in,
struct mlx5_switch_info *port_info_out);
+__rte_internal
+int mlx5_get_ifname_sysfs(const char *ibdev_path, char (*ifname)[IF_NAMESIZE]);
extern uint8_t haswell_broadwell_cpu;
diff --git a/drivers/common/mlx5/rte_common_mlx5_version.map b/drivers/common/mlx5/rte_common_mlx5_version.map
index b3410df..a62584d 100644
--- a/drivers/common/mlx5/rte_common_mlx5_version.map
+++ b/drivers/common/mlx5/rte_common_mlx5_version.map
@@ -33,6 +33,8 @@ INTERNAL {
mlx5_devx_cmd_query_virtq;
mlx5_devx_get_out_command_status;
+ mlx5_get_ifname_sysfs;
+
mlx5_mp_init_primary;
mlx5_mp_uninit_primary;
mlx5_mp_init_secondary;
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 469ff73..91af47b 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -3570,7 +3570,7 @@ struct mlx5_flow_id_pool *
*/
continue;
}
- ret = mlx5_get_master_ifname
+ ret = mlx5_get_ifname_sysfs
(ibv_match[i]->ibdev_path, &ifname);
if (!ret)
list[ns].ifindex =
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 2908c8b..536afae 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -645,7 +645,6 @@ int mlx5_udp_tunnel_port_add(struct rte_eth_dev *dev,
/* mlx5_ethdev.c */
int mlx5_get_ifname(const struct rte_eth_dev *dev, char (*ifname)[IF_NAMESIZE]);
-int mlx5_get_master_ifname(const char *ibdev_path, char (*ifname)[IF_NAMESIZE]);
unsigned int mlx5_ifindex(const struct rte_eth_dev *dev);
int mlx5_ifreq(const struct rte_eth_dev *dev, int req, struct ifreq *ifr);
int mlx5_get_mtu(struct rte_eth_dev *dev, uint16_t *mtu);
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index b837ce6..62344d1 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -129,95 +129,9 @@ struct ethtool_link_settings {
#endif
/**
- * Get master interface name from private structure.
- *
- * @param[in] dev
- * Pointer to Ethernet device.
- * @param[out] ifname
- * Interface name output buffer.
- *
- * @return
- * 0 on success, a negative errno value otherwise and rte_errno is set.
- */
-int
-mlx5_get_master_ifname(const char *ibdev_path, char (*ifname)[IF_NAMESIZE])
-{
- DIR *dir;
- struct dirent *dent;
- unsigned int dev_type = 0;
- unsigned int dev_port_prev = ~0u;
- char match[IF_NAMESIZE] = "";
-
- MLX5_ASSERT(ibdev_path);
- {
- MKSTR(path, "%s/device/net", ibdev_path);
-
- dir = opendir(path);
- if (dir == NULL) {
- rte_errno = errno;
- return -rte_errno;
- }
- }
- while ((dent = readdir(dir)) != NULL) {
- char *name = dent->d_name;
- FILE *file;
- unsigned int dev_port;
- int r;
-
- if ((name[0] == '.') &&
- ((name[1] == '\0') ||
- ((name[1] == '.') && (name[2] == '\0'))))
- continue;
-
- MKSTR(path, "%s/device/net/%s/%s",
- ibdev_path, name,
- (dev_type ? "dev_id" : "dev_port"));
-
- file = fopen(path, "rb");
- if (file == NULL) {
- if (errno != ENOENT)
- continue;
- /*
- * Switch to dev_id when dev_port does not exist as
- * is the case with Linux kernel versions < 3.15.
- */
-try_dev_id:
- match[0] = '\0';
- if (dev_type)
- break;
- dev_type = 1;
- dev_port_prev = ~0u;
- rewinddir(dir);
- continue;
- }
- r = fscanf(file, (dev_type ? "%x" : "%u"), &dev_port);
- fclose(file);
- if (r != 1)
- continue;
- /*
- * Switch to dev_id when dev_port returns the same value for
- * all ports. May happen when using a MOFED release older than
- * 3.0 with a Linux kernel >= 3.15.
- */
- if (dev_port == dev_port_prev)
- goto try_dev_id;
- dev_port_prev = dev_port;
- if (dev_port == 0)
- strlcpy(match, name, sizeof(match));
- }
- closedir(dir);
- if (match[0] == '\0') {
- rte_errno = ENOENT;
- return -rte_errno;
- }
- strncpy(*ifname, match, sizeof(*ifname));
- return 0;
-}
-
-/**
* Get interface name from private structure.
*
- * This is a port representor-aware version of mlx5_get_master_ifname().
+ * This is a port representor-aware version of mlx5_get_ifname_sysfs().
*
* @param[in] dev
* Pointer to Ethernet device.
@@ -238,7 +152,7 @@ struct ethtool_link_settings {
ifindex = mlx5_ifindex(dev);
if (!ifindex) {
if (!priv->representor)
- return mlx5_get_master_ifname(priv->sh->ibdev_path,
+ return mlx5_get_ifname_sysfs(priv->sh->ibdev_path,
ifname);
rte_errno = ENXIO;
return -rte_errno;
--
1.8.3.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [dpdk-dev] [PATCH 2/2] vdpa/mlx5: support MTU feature
2020-06-02 15:53 [dpdk-dev] [PATCH 1/2] common/mlx5: share kernel interface name getter Matan Azrad
@ 2020-06-02 15:53 ` Matan Azrad
2020-06-18 15:22 ` Maxime Coquelin
` (2 more replies)
2020-06-18 15:19 ` [dpdk-dev] [PATCH 1/2] common/mlx5: share kernel interface name getter Maxime Coquelin
2020-06-18 16:07 ` Maxime Coquelin
2 siblings, 3 replies; 14+ messages in thread
From: Matan Azrad @ 2020-06-02 15:53 UTC (permalink / raw)
To: Viacheslav Ovsiienko; +Cc: dev, Maxime Coquelin
The guest virtio device may request MTU updating when the vhost backend
device exposes a capability to support it.
Exspose the MTU feature capability.
In configuration time, check the requested MTU and update it in the HW
device.
Signed-off-by: Matan Azrad <matan@mellanox.com>
---
doc/guides/rel_notes/release_20_08.rst | 1 +
doc/guides/vdpadevs/features/mlx5.ini | 1 +
drivers/vdpa/mlx5/mlx5_vdpa.c | 67 ++++++++++++++++++++++++++++++++--
3 files changed, 65 insertions(+), 4 deletions(-)
diff --git a/doc/guides/rel_notes/release_20_08.rst b/doc/guides/rel_notes/release_20_08.rst
index 25a1563..543a064 100644
--- a/doc/guides/rel_notes/release_20_08.rst
+++ b/doc/guides/rel_notes/release_20_08.rst
@@ -67,6 +67,7 @@ New Features
Updated Mellanox mlx5 vDPA driver with new features, including:
* Added support for virtio queue statistics.
+ * Added support for MTU update.
diff --git a/doc/guides/vdpadevs/features/mlx5.ini b/doc/guides/vdpadevs/features/mlx5.ini
index 788d4e0..8bb9977 100644
--- a/doc/guides/vdpadevs/features/mlx5.ini
+++ b/doc/guides/vdpadevs/features/mlx5.ini
@@ -10,6 +10,7 @@ host tso4 = Y
host tso6 = Y
version 1 = Y
log all = Y
+mtu = Y
any layout = Y
guest announce = Y
mq = Y
diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c
index 94cac66..2a2018b 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa.c
@@ -2,6 +2,11 @@
* Copyright 2019 Mellanox Technologies, Ltd
*/
#include <unistd.h>
+#include <net/if.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <netinet/in.h>
#include <rte_malloc.h>
#include <rte_log.h>
@@ -25,14 +30,19 @@
(1ULL << VIRTIO_NET_F_MQ) | \
(1ULL << VIRTIO_NET_F_GUEST_ANNOUNCE) | \
(1ULL << VIRTIO_F_ORDER_PLATFORM) | \
- (1ULL << VHOST_F_LOG_ALL))
+ (1ULL << VHOST_F_LOG_ALL) | \
+ (1ULL << VIRTIO_NET_F_MTU))
#define MLX5_VDPA_PROTOCOL_FEATURES \
((1ULL << VHOST_USER_PROTOCOL_F_SLAVE_REQ) | \
(1ULL << VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD) | \
(1ULL << VHOST_USER_PROTOCOL_F_HOST_NOTIFIER) | \
(1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD) | \
- (1ULL << VHOST_USER_PROTOCOL_F_MQ))
+ (1ULL << VHOST_USER_PROTOCOL_F_MQ) | \
+ (1ULL << VHOST_USER_PROTOCOL_F_NET_MTU))
+
+#define MLX5_VDPA_MAX_RETRIES 20
+#define MLX5_VDPA_USEC 1000
TAILQ_HEAD(mlx5_vdpa_privs, mlx5_vdpa_priv) priv_list =
TAILQ_HEAD_INITIALIZER(priv_list);
@@ -223,6 +233,55 @@
}
static int
+mlx5_vdpa_mtu_set(struct mlx5_vdpa_priv *priv)
+{
+ struct ifreq request;
+ uint16_t vhost_mtu = 0;
+ uint16_t kern_mtu = 0;
+ int ret = rte_vhost_get_mtu(priv->vid, &vhost_mtu);
+ int sock;
+ int retries = MLX5_VDPA_MAX_RETRIES;
+
+ if (ret) {
+ DRV_LOG(DEBUG, "Cannot get vhost MTU - %d.", ret);
+ return ret;
+ }
+ if (!vhost_mtu) {
+ DRV_LOG(DEBUG, "Vhost MTU is 0.");
+ return ret;
+ }
+ ret = mlx5_get_ifname_sysfs(priv->ctx->device->ibdev_path,
+ &request.ifr_name);
+ if (ret) {
+ DRV_LOG(DEBUG, "Cannot get kernel IF name - %d.", ret);
+ return ret;
+ }
+ sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
+ if (sock == -1) {
+ DRV_LOG(DEBUG, "Cannot open IF socket.");
+ return sock;
+ }
+ while (retries--) {
+ ret = ioctl(sock, SIOCGIFMTU, &request);
+ if (ret == -1)
+ break;
+ kern_mtu = request.ifr_mtu;
+ DRV_LOG(DEBUG, "MTU: current %d requested %d.", (int)kern_mtu,
+ (int)vhost_mtu);
+ if (kern_mtu == vhost_mtu)
+ break;
+ request.ifr_mtu = vhost_mtu;
+ ret = ioctl(sock, SIOCSIFMTU, &request);
+ if (ret == -1)
+ break;
+ request.ifr_mtu = 0;
+ usleep(MLX5_VDPA_USEC);
+ }
+ close(sock);
+ return kern_mtu == vhost_mtu ? 0 : -1;
+}
+
+static int
mlx5_vdpa_dev_close(int vid)
{
int did = rte_vhost_get_vdpa_device_id(vid);
@@ -265,6 +324,8 @@
return -1;
}
priv->vid = vid;
+ if (mlx5_vdpa_mtu_set(priv))
+ DRV_LOG(WARNING, "MTU cannot be set on device %d.", did);
if (mlx5_vdpa_pd_create(priv) || mlx5_vdpa_mem_register(priv) ||
mlx5_vdpa_direct_db_prepare(priv) ||
mlx5_vdpa_virtqs_prepare(priv) || mlx5_vdpa_steer_setup(priv) ||
@@ -513,8 +574,6 @@
return ret;
}
-#define MLX5_VDPA_MAX_RETRIES 20
-#define MLX5_VDPA_USEC 1000
static int
mlx5_vdpa_roce_disable(struct rte_pci_addr *addr, struct ibv_device **ibv)
{
--
1.8.3.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [dpdk-dev] [PATCH 2/2] vdpa/mlx5: support MTU feature
2020-06-02 15:53 ` [dpdk-dev] [PATCH 2/2] vdpa/mlx5: support MTU feature Matan Azrad
@ 2020-06-18 15:22 ` Maxime Coquelin
2020-06-18 19:06 ` [dpdk-dev] [PATCH v2 0/2] " Matan Azrad
2020-06-18 19:08 ` [dpdk-dev] [PATCH] vhost: fix features definition location Matan Azrad
2 siblings, 0 replies; 14+ messages in thread
From: Maxime Coquelin @ 2020-06-18 15:22 UTC (permalink / raw)
To: Matan Azrad, Viacheslav Ovsiienko; +Cc: dev
On 6/2/20 5:53 PM, Matan Azrad wrote:
> The guest virtio device may request MTU updating when the vhost backend
> device exposes a capability to support it.
>
> Exspose the MTU feature capability.
s/Expose/Exspose/
>
> In configuration time, check the requested MTU and update it in the HW
s/In/At/
> device.
>
> Signed-off-by: Matan Azrad <matan@mellanox.com>
> ---
> doc/guides/rel_notes/release_20_08.rst | 1 +
> doc/guides/vdpadevs/features/mlx5.ini | 1 +
> drivers/vdpa/mlx5/mlx5_vdpa.c | 67 ++++++++++++++++++++++++++++++++--
> 3 files changed, 65 insertions(+), 4 deletions(-)
>
I can fix the typos while applying.
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [dpdk-dev] [PATCH v2 0/2] vdpa/mlx5: support MTU feature
2020-06-02 15:53 ` [dpdk-dev] [PATCH 2/2] vdpa/mlx5: support MTU feature Matan Azrad
2020-06-18 15:22 ` Maxime Coquelin
@ 2020-06-18 19:06 ` Matan Azrad
2020-06-18 19:06 ` [dpdk-dev] [PATCH v2 1/2] common/mlx5: share kernel interface name getter Matan Azrad
` (2 more replies)
2020-06-18 19:08 ` [dpdk-dev] [PATCH] vhost: fix features definition location Matan Azrad
2 siblings, 3 replies; 14+ messages in thread
From: Matan Azrad @ 2020-06-18 19:06 UTC (permalink / raw)
To: Maxime Coquelin, Xiao Wang; +Cc: dev
v2: rebase.
Matan Azrad (2):
common/mlx5: share kernel interface name getter
vdpa/mlx5: support MTU feature
doc/guides/rel_notes/release_20_08.rst | 1 +
doc/guides/vdpadevs/features/mlx5.ini | 1 +
drivers/common/mlx5/linux/mlx5_common_os.c | 89 ++++++++++++++++++++++++
drivers/common/mlx5/mlx5_common.h | 3 +
drivers/common/mlx5/rte_common_mlx5_version.map | 2 +
drivers/net/mlx5/linux/mlx5_ethdev_os.c | 91 +------------------------
drivers/net/mlx5/linux/mlx5_os.c | 4 +-
drivers/net/mlx5/mlx5.h | 1 -
drivers/vdpa/mlx5/mlx5_vdpa.c | 67 ++++++++++++++++--
9 files changed, 164 insertions(+), 95 deletions(-)
--
1.8.3.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [dpdk-dev] [PATCH v2 1/2] common/mlx5: share kernel interface name getter
2020-06-18 19:06 ` [dpdk-dev] [PATCH v2 0/2] " Matan Azrad
@ 2020-06-18 19:06 ` Matan Azrad
2020-06-18 19:06 ` [dpdk-dev] [PATCH v2 2/2] vdpa/mlx5: support MTU feature Matan Azrad
2020-06-19 6:39 ` [dpdk-dev] [PATCH v2 0/2] " Maxime Coquelin
2 siblings, 0 replies; 14+ messages in thread
From: Matan Azrad @ 2020-06-18 19:06 UTC (permalink / raw)
To: Maxime Coquelin, Xiao Wang; +Cc: dev
Some configuration of the mlx5 port are done by the kernel net device
associated to the IB device represents the PCI device.
The DPDK mlx5 driver uses linux system calls, for example ioctl, in
order to configure per port configurations requested by the DPDK user.
One of the basic knowledges required to access the correct kernel net
device is its name.
Move function to get interface name from IB device path to the common
library.
Signed-off-by: Matan Azrad <matan@mellanox.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
drivers/common/mlx5/linux/mlx5_common_os.c | 89 ++++++++++++++++++++++++
drivers/common/mlx5/mlx5_common.h | 3 +
drivers/common/mlx5/rte_common_mlx5_version.map | 2 +
drivers/net/mlx5/linux/mlx5_ethdev_os.c | 91 +------------------------
drivers/net/mlx5/linux/mlx5_os.c | 4 +-
drivers/net/mlx5/mlx5.h | 1 -
6 files changed, 99 insertions(+), 91 deletions(-)
diff --git a/drivers/common/mlx5/linux/mlx5_common_os.c b/drivers/common/mlx5/linux/mlx5_common_os.c
index 1b71347..aa67e5a 100644
--- a/drivers/common/mlx5/linux/mlx5_common_os.c
+++ b/drivers/common/mlx5/linux/mlx5_common_os.c
@@ -8,8 +8,11 @@
#ifdef RTE_IBVERBS_LINK_DLOPEN
#include <dlfcn.h>
#endif
+#include <dirent.h>
+#include <net/if.h>
#include <rte_errno.h>
+#include <rte_string_fns.h>
#include "mlx5_common.h"
#include "mlx5_common_utils.h"
@@ -137,6 +140,92 @@
return sysconf(_SC_PAGESIZE);
}
+/**
+ * Get kernel interface name from IB device path.
+ *
+ * @param[in] ibdev_path
+ * Pointer to IB device path.
+ * @param[out] ifname
+ * Interface name output buffer.
+ *
+ * @return
+ * 0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_get_ifname_sysfs(const char *ibdev_path, char *ifname)
+{
+ DIR *dir;
+ struct dirent *dent;
+ unsigned int dev_type = 0;
+ unsigned int dev_port_prev = ~0u;
+ char match[IF_NAMESIZE] = "";
+
+ MLX5_ASSERT(ibdev_path);
+ {
+ MKSTR(path, "%s/device/net", ibdev_path);
+
+ dir = opendir(path);
+ if (dir == NULL) {
+ rte_errno = errno;
+ return -rte_errno;
+ }
+ }
+ while ((dent = readdir(dir)) != NULL) {
+ char *name = dent->d_name;
+ FILE *file;
+ unsigned int dev_port;
+ int r;
+
+ if ((name[0] == '.') &&
+ ((name[1] == '\0') ||
+ ((name[1] == '.') && (name[2] == '\0'))))
+ continue;
+
+ MKSTR(path, "%s/device/net/%s/%s",
+ ibdev_path, name,
+ (dev_type ? "dev_id" : "dev_port"));
+
+ file = fopen(path, "rb");
+ if (file == NULL) {
+ if (errno != ENOENT)
+ continue;
+ /*
+ * Switch to dev_id when dev_port does not exist as
+ * is the case with Linux kernel versions < 3.15.
+ */
+try_dev_id:
+ match[0] = '\0';
+ if (dev_type)
+ break;
+ dev_type = 1;
+ dev_port_prev = ~0u;
+ rewinddir(dir);
+ continue;
+ }
+ r = fscanf(file, (dev_type ? "%x" : "%u"), &dev_port);
+ fclose(file);
+ if (r != 1)
+ continue;
+ /*
+ * Switch to dev_id when dev_port returns the same value for
+ * all ports. May happen when using a MOFED release older than
+ * 3.0 with a Linux kernel >= 3.15.
+ */
+ if (dev_port == dev_port_prev)
+ goto try_dev_id;
+ dev_port_prev = dev_port;
+ if (dev_port == 0)
+ strlcpy(match, name, IF_NAMESIZE);
+ }
+ closedir(dir);
+ if (match[0] == '\0') {
+ rte_errno = ENOENT;
+ return -rte_errno;
+ }
+ strncpy(ifname, match, IF_NAMESIZE);
+ return 0;
+}
+
#ifdef MLX5_GLUE
/**
diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h
index 77f10e6..82b4b13 100644
--- a/drivers/common/mlx5/mlx5_common.h
+++ b/drivers/common/mlx5/mlx5_common.h
@@ -198,6 +198,9 @@ enum mlx5_cqe_status {
__rte_internal
int mlx5_dev_to_pci_addr(const char *dev_path, struct rte_pci_addr *pci_addr);
+__rte_internal
+int mlx5_get_ifname_sysfs(const char *ibdev_path, char *ifname);
+
#define MLX5_CLASS_ARG_NAME "class"
diff --git a/drivers/common/mlx5/rte_common_mlx5_version.map b/drivers/common/mlx5/rte_common_mlx5_version.map
index 3f62400..514d7c5 100644
--- a/drivers/common/mlx5/rte_common_mlx5_version.map
+++ b/drivers/common/mlx5/rte_common_mlx5_version.map
@@ -36,6 +36,8 @@ INTERNAL {
mlx5_devx_cmd_query_virtq;
mlx5_devx_get_out_command_status;
+ mlx5_get_ifname_sysfs;
+
mlx5_mp_init_primary;
mlx5_mp_uninit_primary;
mlx5_mp_init_secondary;
diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c
index ab47cb5..21105f6 100644
--- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c
+++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c
@@ -128,96 +128,11 @@ struct ethtool_link_settings {
#define ETHTOOL_LINK_MODE_200000baseCR4_Full_BIT 2 /* 66 - 64 */
#endif
-/**
- * Get master interface name from private structure.
- *
- * @param[in] dev
- * Pointer to Ethernet device.
- * @param[out] ifname
- * Interface name output buffer.
- *
- * @return
- * 0 on success, a negative errno value otherwise and rte_errno is set.
- */
-int
-mlx5_get_master_ifname(const char *ibdev_path, char (*ifname)[IF_NAMESIZE])
-{
- DIR *dir;
- struct dirent *dent;
- unsigned int dev_type = 0;
- unsigned int dev_port_prev = ~0u;
- char match[IF_NAMESIZE] = "";
-
- MLX5_ASSERT(ibdev_path);
- {
- MKSTR(path, "%s/device/net", ibdev_path);
-
- dir = opendir(path);
- if (dir == NULL) {
- rte_errno = errno;
- return -rte_errno;
- }
- }
- while ((dent = readdir(dir)) != NULL) {
- char *name = dent->d_name;
- FILE *file;
- unsigned int dev_port;
- int r;
-
- if ((name[0] == '.') &&
- ((name[1] == '\0') ||
- ((name[1] == '.') && (name[2] == '\0'))))
- continue;
-
- MKSTR(path, "%s/device/net/%s/%s",
- ibdev_path, name,
- (dev_type ? "dev_id" : "dev_port"));
-
- file = fopen(path, "rb");
- if (file == NULL) {
- if (errno != ENOENT)
- continue;
- /*
- * Switch to dev_id when dev_port does not exist as
- * is the case with Linux kernel versions < 3.15.
- */
-try_dev_id:
- match[0] = '\0';
- if (dev_type)
- break;
- dev_type = 1;
- dev_port_prev = ~0u;
- rewinddir(dir);
- continue;
- }
- r = fscanf(file, (dev_type ? "%x" : "%u"), &dev_port);
- fclose(file);
- if (r != 1)
- continue;
- /*
- * Switch to dev_id when dev_port returns the same value for
- * all ports. May happen when using a MOFED release older than
- * 3.0 with a Linux kernel >= 3.15.
- */
- if (dev_port == dev_port_prev)
- goto try_dev_id;
- dev_port_prev = dev_port;
- if (dev_port == 0)
- strlcpy(match, name, sizeof(match));
- }
- closedir(dir);
- if (match[0] == '\0') {
- rte_errno = ENOENT;
- return -rte_errno;
- }
- strncpy(*ifname, match, sizeof(*ifname));
- return 0;
-}
/**
* Get interface name from private structure.
*
- * This is a port representor-aware version of mlx5_get_master_ifname().
+ * This is a port representor-aware version of mlx5_get_ifname_sysfs().
*
* @param[in] dev
* Pointer to Ethernet device.
@@ -238,8 +153,8 @@ struct ethtool_link_settings {
ifindex = mlx5_ifindex(dev);
if (!ifindex) {
if (!priv->representor)
- return mlx5_get_master_ifname(priv->sh->ibdev_path,
- ifname);
+ return mlx5_get_ifname_sysfs(priv->sh->ibdev_path,
+ *ifname);
rte_errno = ENXIO;
return -rte_errno;
}
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 3792371..b330cd5 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -1637,8 +1637,8 @@
*/
continue;
}
- ret = mlx5_get_master_ifname
- (ibv_match[i]->ibdev_path, &ifname);
+ ret = mlx5_get_ifname_sysfs
+ (ibv_match[i]->ibdev_path, ifname);
if (!ret)
list[ns].ifindex =
if_nametoindex(ifname);
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 5bd5acd..8ecb59c 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -731,7 +731,6 @@ int mlx5_hairpin_cap_get(struct rte_eth_dev *dev,
/* mlx5_ethdev_os.c */
int mlx5_get_ifname(const struct rte_eth_dev *dev, char (*ifname)[IF_NAMESIZE]);
-int mlx5_get_master_ifname(const char *ibdev_path, char (*ifname)[IF_NAMESIZE]);
unsigned int mlx5_ifindex(const struct rte_eth_dev *dev);
int mlx5_ifreq(const struct rte_eth_dev *dev, int req, struct ifreq *ifr);
int mlx5_get_mtu(struct rte_eth_dev *dev, uint16_t *mtu);
--
1.8.3.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [dpdk-dev] [PATCH v2 2/2] vdpa/mlx5: support MTU feature
2020-06-18 19:06 ` [dpdk-dev] [PATCH v2 0/2] " Matan Azrad
2020-06-18 19:06 ` [dpdk-dev] [PATCH v2 1/2] common/mlx5: share kernel interface name getter Matan Azrad
@ 2020-06-18 19:06 ` Matan Azrad
2020-06-19 6:39 ` [dpdk-dev] [PATCH v2 0/2] " Maxime Coquelin
2 siblings, 0 replies; 14+ messages in thread
From: Matan Azrad @ 2020-06-18 19:06 UTC (permalink / raw)
To: Maxime Coquelin, Xiao Wang; +Cc: dev
The guest virtio device may request MTU updating when the vhost backend
device exposes a capability to support it.
Exspose the MTU feature capability.
At configuration time, check the requested MTU and update it in the HW
device.
Signed-off-by: Matan Azrad <matan@mellanox.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
doc/guides/rel_notes/release_20_08.rst | 1 +
doc/guides/vdpadevs/features/mlx5.ini | 1 +
drivers/vdpa/mlx5/mlx5_vdpa.c | 67 ++++++++++++++++++++++++++++++++--
3 files changed, 65 insertions(+), 4 deletions(-)
diff --git a/doc/guides/rel_notes/release_20_08.rst b/doc/guides/rel_notes/release_20_08.rst
index e2c93b1..cc39984 100644
--- a/doc/guides/rel_notes/release_20_08.rst
+++ b/doc/guides/rel_notes/release_20_08.rst
@@ -79,6 +79,7 @@ New Features
Updated Mellanox mlx5 vDPA driver with new features, including:
* Added support for virtio queue statistics.
+ * Added support for MTU update.
diff --git a/doc/guides/vdpadevs/features/mlx5.ini b/doc/guides/vdpadevs/features/mlx5.ini
index 788d4e0..8bb9977 100644
--- a/doc/guides/vdpadevs/features/mlx5.ini
+++ b/doc/guides/vdpadevs/features/mlx5.ini
@@ -10,6 +10,7 @@ host tso4 = Y
host tso6 = Y
version 1 = Y
log all = Y
+mtu = Y
any layout = Y
guest announce = Y
mq = Y
diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c
index 94cac66..8b0b3b8 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa.c
@@ -2,6 +2,11 @@
* Copyright 2019 Mellanox Technologies, Ltd
*/
#include <unistd.h>
+#include <net/if.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <netinet/in.h>
#include <rte_malloc.h>
#include <rte_log.h>
@@ -25,14 +30,19 @@
(1ULL << VIRTIO_NET_F_MQ) | \
(1ULL << VIRTIO_NET_F_GUEST_ANNOUNCE) | \
(1ULL << VIRTIO_F_ORDER_PLATFORM) | \
- (1ULL << VHOST_F_LOG_ALL))
+ (1ULL << VHOST_F_LOG_ALL) | \
+ (1ULL << VIRTIO_NET_F_MTU))
#define MLX5_VDPA_PROTOCOL_FEATURES \
((1ULL << VHOST_USER_PROTOCOL_F_SLAVE_REQ) | \
(1ULL << VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD) | \
(1ULL << VHOST_USER_PROTOCOL_F_HOST_NOTIFIER) | \
(1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD) | \
- (1ULL << VHOST_USER_PROTOCOL_F_MQ))
+ (1ULL << VHOST_USER_PROTOCOL_F_MQ) | \
+ (1ULL << VHOST_USER_PROTOCOL_F_NET_MTU))
+
+#define MLX5_VDPA_MAX_RETRIES 20
+#define MLX5_VDPA_USEC 1000
TAILQ_HEAD(mlx5_vdpa_privs, mlx5_vdpa_priv) priv_list =
TAILQ_HEAD_INITIALIZER(priv_list);
@@ -223,6 +233,55 @@
}
static int
+mlx5_vdpa_mtu_set(struct mlx5_vdpa_priv *priv)
+{
+ struct ifreq request;
+ uint16_t vhost_mtu = 0;
+ uint16_t kern_mtu = 0;
+ int ret = rte_vhost_get_mtu(priv->vid, &vhost_mtu);
+ int sock;
+ int retries = MLX5_VDPA_MAX_RETRIES;
+
+ if (ret) {
+ DRV_LOG(DEBUG, "Cannot get vhost MTU - %d.", ret);
+ return ret;
+ }
+ if (!vhost_mtu) {
+ DRV_LOG(DEBUG, "Vhost MTU is 0.");
+ return ret;
+ }
+ ret = mlx5_get_ifname_sysfs(priv->ctx->device->ibdev_path,
+ request.ifr_name);
+ if (ret) {
+ DRV_LOG(DEBUG, "Cannot get kernel IF name - %d.", ret);
+ return ret;
+ }
+ sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
+ if (sock == -1) {
+ DRV_LOG(DEBUG, "Cannot open IF socket.");
+ return sock;
+ }
+ while (retries--) {
+ ret = ioctl(sock, SIOCGIFMTU, &request);
+ if (ret == -1)
+ break;
+ kern_mtu = request.ifr_mtu;
+ DRV_LOG(DEBUG, "MTU: current %d requested %d.", (int)kern_mtu,
+ (int)vhost_mtu);
+ if (kern_mtu == vhost_mtu)
+ break;
+ request.ifr_mtu = vhost_mtu;
+ ret = ioctl(sock, SIOCSIFMTU, &request);
+ if (ret == -1)
+ break;
+ request.ifr_mtu = 0;
+ usleep(MLX5_VDPA_USEC);
+ }
+ close(sock);
+ return kern_mtu == vhost_mtu ? 0 : -1;
+}
+
+static int
mlx5_vdpa_dev_close(int vid)
{
int did = rte_vhost_get_vdpa_device_id(vid);
@@ -265,6 +324,8 @@
return -1;
}
priv->vid = vid;
+ if (mlx5_vdpa_mtu_set(priv))
+ DRV_LOG(WARNING, "MTU cannot be set on device %d.", did);
if (mlx5_vdpa_pd_create(priv) || mlx5_vdpa_mem_register(priv) ||
mlx5_vdpa_direct_db_prepare(priv) ||
mlx5_vdpa_virtqs_prepare(priv) || mlx5_vdpa_steer_setup(priv) ||
@@ -513,8 +574,6 @@
return ret;
}
-#define MLX5_VDPA_MAX_RETRIES 20
-#define MLX5_VDPA_USEC 1000
static int
mlx5_vdpa_roce_disable(struct rte_pci_addr *addr, struct ibv_device **ibv)
{
--
1.8.3.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [dpdk-dev] [PATCH v2 0/2] vdpa/mlx5: support MTU feature
2020-06-18 19:06 ` [dpdk-dev] [PATCH v2 0/2] " Matan Azrad
2020-06-18 19:06 ` [dpdk-dev] [PATCH v2 1/2] common/mlx5: share kernel interface name getter Matan Azrad
2020-06-18 19:06 ` [dpdk-dev] [PATCH v2 2/2] vdpa/mlx5: support MTU feature Matan Azrad
@ 2020-06-19 6:39 ` Maxime Coquelin
2 siblings, 0 replies; 14+ messages in thread
From: Maxime Coquelin @ 2020-06-19 6:39 UTC (permalink / raw)
To: Matan Azrad, Xiao Wang; +Cc: dev
On 6/18/20 9:06 PM, Matan Azrad wrote:
> v2: rebase.
>
> Matan Azrad (2):
> common/mlx5: share kernel interface name getter
> vdpa/mlx5: support MTU feature
>
> doc/guides/rel_notes/release_20_08.rst | 1 +
> doc/guides/vdpadevs/features/mlx5.ini | 1 +
> drivers/common/mlx5/linux/mlx5_common_os.c | 89 ++++++++++++++++++++++++
> drivers/common/mlx5/mlx5_common.h | 3 +
> drivers/common/mlx5/rte_common_mlx5_version.map | 2 +
> drivers/net/mlx5/linux/mlx5_ethdev_os.c | 91 +------------------------
> drivers/net/mlx5/linux/mlx5_os.c | 4 +-
> drivers/net/mlx5/mlx5.h | 1 -
> drivers/vdpa/mlx5/mlx5_vdpa.c | 67 ++++++++++++++++--
> 9 files changed, 164 insertions(+), 95 deletions(-)
>
Applied to dpdk-next-virtio/master
Thanks,
Maxime
^ permalink raw reply [flat|nested] 14+ messages in thread
* [dpdk-dev] [PATCH] vhost: fix features definition location
2020-06-02 15:53 ` [dpdk-dev] [PATCH 2/2] vdpa/mlx5: support MTU feature Matan Azrad
2020-06-18 15:22 ` Maxime Coquelin
2020-06-18 19:06 ` [dpdk-dev] [PATCH v2 0/2] " Matan Azrad
@ 2020-06-18 19:08 ` Matan Azrad
2020-06-23 5:20 ` [dpdk-dev] [dpdk-stable] " Xia, Chenbo
2020-06-30 7:34 ` [dpdk-dev] " Maxime Coquelin
2 siblings, 2 replies; 14+ messages in thread
From: Matan Azrad @ 2020-06-18 19:08 UTC (permalink / raw)
To: Maxime Coquelin; +Cc: dev, stable
The vhost library provide an infrastructure in order to help the DPDK
users to manage vhost devices.
One of the infrastructure parts is the features enablement APIs.
Some features bits may be defined only in the internal file vhost.h in
case the kernel version doesn't include them.
Hence, user running on old kernel may not be able to manage thus
features.
Move all the feature bits definitions to the API file rte_vhost.h.
Fixes: db69be54b6ff ("vhost: hide internal code")
Fixes: 8d286dbeb8d7 ("vhost: fix multiple queue not enabled for old kernels")
Fixes: 3d3c6590b58c ("vhost: enable virtio MTU feature")
Fixes: 704098fc478c ("vhost: fix build with old kernels")
Cc: stable@dpdk.org
Signed-off-by: Matan Azrad <matan@mellanox.com>
---
lib/librte_vhost/rte_vhost.h | 17 +++++++++++++++++
lib/librte_vhost/vhost.h | 17 -----------------
2 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h
index d43669f..329ed8a 100644
--- a/lib/librte_vhost/rte_vhost.h
+++ b/lib/librte_vhost/rte_vhost.h
@@ -36,6 +36,23 @@
/* support only linear buffers (no chained mbufs) */
#define RTE_VHOST_USER_LINEARBUF_SUPPORT (1ULL << 6)
+/* Features. */
+#ifndef VIRTIO_NET_F_GUEST_ANNOUNCE
+ #define VIRTIO_NET_F_GUEST_ANNOUNCE 21
+#endif
+
+#ifndef VIRTIO_NET_F_MQ
+ #define VIRTIO_NET_F_MQ 22
+#endif
+
+#ifndef VIRTIO_NET_F_MTU
+ #define VIRTIO_NET_F_MTU 3
+#endif
+
+#ifndef VIRTIO_F_ANY_LAYOUT
+ #define VIRTIO_F_ANY_LAYOUT 27
+#endif
+
/** Protocol features. */
#ifndef VHOST_USER_PROTOCOL_F_MQ
#define VHOST_USER_PROTOCOL_F_MQ 0
diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
index df98d15..17f1e9a 100644
--- a/lib/librte_vhost/vhost.h
+++ b/lib/librte_vhost/vhost.h
@@ -202,26 +202,9 @@ struct vhost_virtqueue {
TAILQ_HEAD(, vhost_iotlb_entry) iotlb_pending_list;
} __rte_cache_aligned;
-/* Old kernels have no such macros defined */
-#ifndef VIRTIO_NET_F_GUEST_ANNOUNCE
- #define VIRTIO_NET_F_GUEST_ANNOUNCE 21
-#endif
-
-#ifndef VIRTIO_NET_F_MQ
- #define VIRTIO_NET_F_MQ 22
-#endif
-
#define VHOST_MAX_VRING 0x100
#define VHOST_MAX_QUEUE_PAIRS 0x80
-#ifndef VIRTIO_NET_F_MTU
- #define VIRTIO_NET_F_MTU 3
-#endif
-
-#ifndef VIRTIO_F_ANY_LAYOUT
- #define VIRTIO_F_ANY_LAYOUT 27
-#endif
-
/* Declare IOMMU related bits for older kernels */
#ifndef VIRTIO_F_IOMMU_PLATFORM
--
1.8.3.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [dpdk-dev] [dpdk-stable] [PATCH] vhost: fix features definition location
2020-06-18 19:08 ` [dpdk-dev] [PATCH] vhost: fix features definition location Matan Azrad
@ 2020-06-23 5:20 ` Xia, Chenbo
2020-06-30 7:34 ` [dpdk-dev] " Maxime Coquelin
1 sibling, 0 replies; 14+ messages in thread
From: Xia, Chenbo @ 2020-06-23 5:20 UTC (permalink / raw)
To: Matan Azrad, Maxime Coquelin; +Cc: dev, stable
> -----Original Message-----
> From: stable <stable-bounces@dpdk.org> On Behalf Of Matan Azrad
> Sent: Friday, June 19, 2020 3:08 AM
> To: Maxime Coquelin <maxime.coquelin@redhat.com>
> Cc: dev@dpdk.org; stable@dpdk.org
> Subject: [dpdk-stable] [PATCH] vhost: fix features definition location
>
> The vhost library provide an infrastructure in order to help the DPDK users to
> manage vhost devices.
>
> One of the infrastructure parts is the features enablement APIs.
>
> Some features bits may be defined only in the internal file vhost.h in case the
> kernel version doesn't include them.
>
> Hence, user running on old kernel may not be able to manage thus features.
>
> Move all the feature bits definitions to the API file rte_vhost.h.
>
> Fixes: db69be54b6ff ("vhost: hide internal code")
> Fixes: 8d286dbeb8d7 ("vhost: fix multiple queue not enabled for old kernels")
> Fixes: 3d3c6590b58c ("vhost: enable virtio MTU feature")
> Fixes: 704098fc478c ("vhost: fix build with old kernels")
> Cc: stable@dpdk.org
>
> Signed-off-by: Matan Azrad <matan@mellanox.com>
> ---
> lib/librte_vhost/rte_vhost.h | 17 +++++++++++++++++
> lib/librte_vhost/vhost.h | 17 -----------------
> 2 files changed, 17 insertions(+), 17 deletions(-)
>
> diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h index
> d43669f..329ed8a 100644
> --- a/lib/librte_vhost/rte_vhost.h
> +++ b/lib/librte_vhost/rte_vhost.h
> @@ -36,6 +36,23 @@
> /* support only linear buffers (no chained mbufs) */
> #define RTE_VHOST_USER_LINEARBUF_SUPPORT (1ULL << 6)
>
> +/* Features. */
> +#ifndef VIRTIO_NET_F_GUEST_ANNOUNCE
> + #define VIRTIO_NET_F_GUEST_ANNOUNCE 21 #endif
> +
> +#ifndef VIRTIO_NET_F_MQ
> + #define VIRTIO_NET_F_MQ 22
> +#endif
> +
> +#ifndef VIRTIO_NET_F_MTU
> + #define VIRTIO_NET_F_MTU 3
> +#endif
> +
> +#ifndef VIRTIO_F_ANY_LAYOUT
> + #define VIRTIO_F_ANY_LAYOUT 27
> +#endif
> +
> /** Protocol features. */
> #ifndef VHOST_USER_PROTOCOL_F_MQ
> #define VHOST_USER_PROTOCOL_F_MQ 0
> diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h index
> df98d15..17f1e9a 100644
> --- a/lib/librte_vhost/vhost.h
> +++ b/lib/librte_vhost/vhost.h
> @@ -202,26 +202,9 @@ struct vhost_virtqueue {
> TAILQ_HEAD(, vhost_iotlb_entry) iotlb_pending_list; }
> __rte_cache_aligned;
>
> -/* Old kernels have no such macros defined */ -#ifndef
> VIRTIO_NET_F_GUEST_ANNOUNCE
> - #define VIRTIO_NET_F_GUEST_ANNOUNCE 21 -#endif
> -
> -#ifndef VIRTIO_NET_F_MQ
> - #define VIRTIO_NET_F_MQ 22
> -#endif
> -
> #define VHOST_MAX_VRING 0x100
> #define VHOST_MAX_QUEUE_PAIRS 0x80
>
> -#ifndef VIRTIO_NET_F_MTU
> - #define VIRTIO_NET_F_MTU 3
> -#endif
> -
> -#ifndef VIRTIO_F_ANY_LAYOUT
> - #define VIRTIO_F_ANY_LAYOUT 27
> -#endif
> -
> /* Declare IOMMU related bits for older kernels */ #ifndef
> VIRTIO_F_IOMMU_PLATFORM
>
> --
> 1.8.3.1
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [dpdk-dev] [PATCH] vhost: fix features definition location
2020-06-18 19:08 ` [dpdk-dev] [PATCH] vhost: fix features definition location Matan Azrad
2020-06-23 5:20 ` [dpdk-dev] [dpdk-stable] " Xia, Chenbo
@ 2020-06-30 7:34 ` Maxime Coquelin
2020-06-30 7:41 ` Maxime Coquelin
1 sibling, 1 reply; 14+ messages in thread
From: Maxime Coquelin @ 2020-06-30 7:34 UTC (permalink / raw)
To: Matan Azrad; +Cc: dev, stable
On 6/18/20 9:08 PM, Matan Azrad wrote:
> The vhost library provide an infrastructure in order to help the DPDK
> users to manage vhost devices.
>
> One of the infrastructure parts is the features enablement APIs.
>
> Some features bits may be defined only in the internal file vhost.h in
> case the kernel version doesn't include them.
>
> Hence, user running on old kernel may not be able to manage thus
> features.
>
> Move all the feature bits definitions to the API file rte_vhost.h.
>
> Fixes: db69be54b6ff ("vhost: hide internal code")
> Fixes: 8d286dbeb8d7 ("vhost: fix multiple queue not enabled for old kernels")
> Fixes: 3d3c6590b58c ("vhost: enable virtio MTU feature")
> Fixes: 704098fc478c ("vhost: fix build with old kernels")
> Cc: stable@dpdk.org
>
> Signed-off-by: Matan Azrad <matan@mellanox.com>
> ---
> lib/librte_vhost/rte_vhost.h | 17 +++++++++++++++++
> lib/librte_vhost/vhost.h | 17 -----------------
> 2 files changed, 17 insertions(+), 17 deletions(-)
>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Thanks,
Maxime
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [dpdk-dev] [PATCH] vhost: fix features definition location
2020-06-30 7:34 ` [dpdk-dev] " Maxime Coquelin
@ 2020-06-30 7:41 ` Maxime Coquelin
0 siblings, 0 replies; 14+ messages in thread
From: Maxime Coquelin @ 2020-06-30 7:41 UTC (permalink / raw)
To: Matan Azrad; +Cc: dev, stable
On 6/30/20 9:34 AM, Maxime Coquelin wrote:
>
>
> On 6/18/20 9:08 PM, Matan Azrad wrote:
>> The vhost library provide an infrastructure in order to help the DPDK
>> users to manage vhost devices.
>>
>> One of the infrastructure parts is the features enablement APIs.
>>
>> Some features bits may be defined only in the internal file vhost.h in
>> case the kernel version doesn't include them.
>>
>> Hence, user running on old kernel may not be able to manage thus
>> features.
>>
>> Move all the feature bits definitions to the API file rte_vhost.h.
>>
>> Fixes: db69be54b6ff ("vhost: hide internal code")
>> Fixes: 8d286dbeb8d7 ("vhost: fix multiple queue not enabled for old kernels")
>> Fixes: 3d3c6590b58c ("vhost: enable virtio MTU feature")
>> Fixes: 704098fc478c ("vhost: fix build with old kernels")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Matan Azrad <matan@mellanox.com>
>> ---
>> lib/librte_vhost/rte_vhost.h | 17 +++++++++++++++++
>> lib/librte_vhost/vhost.h | 17 -----------------
>> 2 files changed, 17 insertions(+), 17 deletions(-)
>>
>
> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
>
> Thanks,
> Maxime
>
Applied to dpdk-next-virtio/master
Thanks,
Maxime
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [dpdk-dev] [PATCH 1/2] common/mlx5: share kernel interface name getter
2020-06-02 15:53 [dpdk-dev] [PATCH 1/2] common/mlx5: share kernel interface name getter Matan Azrad
2020-06-02 15:53 ` [dpdk-dev] [PATCH 2/2] vdpa/mlx5: support MTU feature Matan Azrad
@ 2020-06-18 15:19 ` Maxime Coquelin
2020-06-18 16:07 ` Maxime Coquelin
2 siblings, 0 replies; 14+ messages in thread
From: Maxime Coquelin @ 2020-06-18 15:19 UTC (permalink / raw)
To: Matan Azrad, Viacheslav Ovsiienko; +Cc: dev
On 6/2/20 5:53 PM, Matan Azrad wrote:
> Some configuration of the mlx5 port are done by the kernel net device
> associated to the IB device represents the PCI device.
>
> The DPDK mlx5 driver uses linux system calls, for example ioctl, in
> order to configure per port configurations requested by the DPDK user.
>
> One of the basic knowledges required to access the correct kernel net
> device is its name.
>
> Move function to get interface name from IB device path to the common
> library.
>
> Signed-off-by: Matan Azrad <matan@mellanox.com>
> ---
> drivers/common/mlx5/mlx5_common.c | 88 ++++++++++++++++++++++++
> drivers/common/mlx5/mlx5_common.h | 3 +
> drivers/common/mlx5/rte_common_mlx5_version.map | 2 +
> drivers/net/mlx5/mlx5.c | 2 +-
> drivers/net/mlx5/mlx5.h | 1 -
> drivers/net/mlx5/mlx5_ethdev.c | 90 +------------------------
> 6 files changed, 96 insertions(+), 90 deletions(-)
>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [dpdk-dev] [PATCH 1/2] common/mlx5: share kernel interface name getter
2020-06-02 15:53 [dpdk-dev] [PATCH 1/2] common/mlx5: share kernel interface name getter Matan Azrad
2020-06-02 15:53 ` [dpdk-dev] [PATCH 2/2] vdpa/mlx5: support MTU feature Matan Azrad
2020-06-18 15:19 ` [dpdk-dev] [PATCH 1/2] common/mlx5: share kernel interface name getter Maxime Coquelin
@ 2020-06-18 16:07 ` Maxime Coquelin
2020-06-18 18:28 ` Matan Azrad
2 siblings, 1 reply; 14+ messages in thread
From: Maxime Coquelin @ 2020-06-18 16:07 UTC (permalink / raw)
To: Matan Azrad, Viacheslav Ovsiienko; +Cc: dev
Your series does not apply, there are no common ancestor so I can't do
3-way merge.
Could you please rebase it on top of next-virtio's master branch?
Thanks,
Maxime
On 6/2/20 5:53 PM, Matan Azrad wrote:
> Some configuration of the mlx5 port are done by the kernel net device
> associated to the IB device represents the PCI device.
>
> The DPDK mlx5 driver uses linux system calls, for example ioctl, in
> order to configure per port configurations requested by the DPDK user.
>
> One of the basic knowledges required to access the correct kernel net
> device is its name.
>
> Move function to get interface name from IB device path to the common
> library.
>
> Signed-off-by: Matan Azrad <matan@mellanox.com>
> ---
> drivers/common/mlx5/mlx5_common.c | 88 ++++++++++++++++++++++++
> drivers/common/mlx5/mlx5_common.h | 3 +
> drivers/common/mlx5/rte_common_mlx5_version.map | 2 +
> drivers/net/mlx5/mlx5.c | 2 +-
> drivers/net/mlx5/mlx5.h | 1 -
> drivers/net/mlx5/mlx5_ethdev.c | 90 +------------------------
> 6 files changed, 96 insertions(+), 90 deletions(-)
>
> diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c
> index 1c77763..3f0d8d3 100644
> --- a/drivers/common/mlx5/mlx5_common.c
> +++ b/drivers/common/mlx5/mlx5_common.c
> @@ -8,8 +8,10 @@
> #ifdef RTE_IBVERBS_LINK_DLOPEN
> #include <dlfcn.h>
> #endif
> +#include <dirent.h>
>
> #include <rte_errno.h>
> +#include <rte_string_fns.h>
>
> #include "mlx5_common.h"
> #include "mlx5_common_utils.h"
> @@ -167,6 +169,92 @@ enum mlx5_class
> return;
> }
>
> +/**
> + * Get kernel interface name from IB device path.
> + *
> + * @param[in] ibdev_path
> + * Pointer to IB device path.
> + * @param[out] ifname
> + * Interface name output buffer.
> + *
> + * @return
> + * 0 on success, a negative errno value otherwise and rte_errno is set.
> + */
> +int
> +mlx5_get_ifname_sysfs(const char *ibdev_path, char (*ifname)[IF_NAMESIZE])
> +{
> + DIR *dir;
> + struct dirent *dent;
> + unsigned int dev_type = 0;
> + unsigned int dev_port_prev = ~0u;
> + char match[IF_NAMESIZE] = "";
> +
> + MLX5_ASSERT(ibdev_path);
> + {
> + MKSTR(path, "%s/device/net", ibdev_path);
> +
> + dir = opendir(path);
> + if (dir == NULL) {
> + rte_errno = errno;
> + return -rte_errno;
> + }
> + }
> + while ((dent = readdir(dir)) != NULL) {
> + char *name = dent->d_name;
> + FILE *file;
> + unsigned int dev_port;
> + int r;
> +
> + if ((name[0] == '.') &&
> + ((name[1] == '\0') ||
> + ((name[1] == '.') && (name[2] == '\0'))))
> + continue;
> +
> + MKSTR(path, "%s/device/net/%s/%s",
> + ibdev_path, name,
> + (dev_type ? "dev_id" : "dev_port"));
> +
> + file = fopen(path, "rb");
> + if (file == NULL) {
> + if (errno != ENOENT)
> + continue;
> + /*
> + * Switch to dev_id when dev_port does not exist as
> + * is the case with Linux kernel versions < 3.15.
> + */
> +try_dev_id:
> + match[0] = '\0';
> + if (dev_type)
> + break;
> + dev_type = 1;
> + dev_port_prev = ~0u;
> + rewinddir(dir);
> + continue;
> + }
> + r = fscanf(file, (dev_type ? "%x" : "%u"), &dev_port);
> + fclose(file);
> + if (r != 1)
> + continue;
> + /*
> + * Switch to dev_id when dev_port returns the same value for
> + * all ports. May happen when using a MOFED release older than
> + * 3.0 with a Linux kernel >= 3.15.
> + */
> + if (dev_port == dev_port_prev)
> + goto try_dev_id;
> + dev_port_prev = dev_port;
> + if (dev_port == 0)
> + strlcpy(match, name, sizeof(match));
> + }
> + closedir(dir);
> + if (match[0] == '\0') {
> + rte_errno = ENOENT;
> + return -rte_errno;
> + }
> + strncpy(*ifname, match, sizeof(*ifname));
> + return 0;
> +}
> +
> #ifdef MLX5_GLUE
>
> /**
> diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h
> index 8cd3ea5..4f6373b 100644
> --- a/drivers/common/mlx5/mlx5_common.h
> +++ b/drivers/common/mlx5/mlx5_common.h
> @@ -6,6 +6,7 @@
> #define RTE_PMD_MLX5_COMMON_H_
>
> #include <stdio.h>
> +#include <net/if.h>
>
> #include <rte_pci.h>
> #include <rte_debug.h>
> @@ -212,6 +213,8 @@ enum mlx5_class {
> __rte_internal
> void mlx5_translate_port_name(const char *port_name_in,
> struct mlx5_switch_info *port_info_out);
> +__rte_internal
> +int mlx5_get_ifname_sysfs(const char *ibdev_path, char (*ifname)[IF_NAMESIZE]);
>
> extern uint8_t haswell_broadwell_cpu;
>
> diff --git a/drivers/common/mlx5/rte_common_mlx5_version.map b/drivers/common/mlx5/rte_common_mlx5_version.map
> index b3410df..a62584d 100644
> --- a/drivers/common/mlx5/rte_common_mlx5_version.map
> +++ b/drivers/common/mlx5/rte_common_mlx5_version.map
> @@ -33,6 +33,8 @@ INTERNAL {
> mlx5_devx_cmd_query_virtq;
> mlx5_devx_get_out_command_status;
>
> + mlx5_get_ifname_sysfs;
> +
> mlx5_mp_init_primary;
> mlx5_mp_uninit_primary;
> mlx5_mp_init_secondary;
> diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
> index 469ff73..91af47b 100644
> --- a/drivers/net/mlx5/mlx5.c
> +++ b/drivers/net/mlx5/mlx5.c
> @@ -3570,7 +3570,7 @@ struct mlx5_flow_id_pool *
> */
> continue;
> }
> - ret = mlx5_get_master_ifname
> + ret = mlx5_get_ifname_sysfs
> (ibv_match[i]->ibdev_path, &ifname);
> if (!ret)
> list[ns].ifindex =
> diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
> index 2908c8b..536afae 100644
> --- a/drivers/net/mlx5/mlx5.h
> +++ b/drivers/net/mlx5/mlx5.h
> @@ -645,7 +645,6 @@ int mlx5_udp_tunnel_port_add(struct rte_eth_dev *dev,
> /* mlx5_ethdev.c */
>
> int mlx5_get_ifname(const struct rte_eth_dev *dev, char (*ifname)[IF_NAMESIZE]);
> -int mlx5_get_master_ifname(const char *ibdev_path, char (*ifname)[IF_NAMESIZE]);
> unsigned int mlx5_ifindex(const struct rte_eth_dev *dev);
> int mlx5_ifreq(const struct rte_eth_dev *dev, int req, struct ifreq *ifr);
> int mlx5_get_mtu(struct rte_eth_dev *dev, uint16_t *mtu);
> diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
> index b837ce6..62344d1 100644
> --- a/drivers/net/mlx5/mlx5_ethdev.c
> +++ b/drivers/net/mlx5/mlx5_ethdev.c
> @@ -129,95 +129,9 @@ struct ethtool_link_settings {
> #endif
>
> /**
> - * Get master interface name from private structure.
> - *
> - * @param[in] dev
> - * Pointer to Ethernet device.
> - * @param[out] ifname
> - * Interface name output buffer.
> - *
> - * @return
> - * 0 on success, a negative errno value otherwise and rte_errno is set.
> - */
> -int
> -mlx5_get_master_ifname(const char *ibdev_path, char (*ifname)[IF_NAMESIZE])
> -{
> - DIR *dir;
> - struct dirent *dent;
> - unsigned int dev_type = 0;
> - unsigned int dev_port_prev = ~0u;
> - char match[IF_NAMESIZE] = "";
> -
> - MLX5_ASSERT(ibdev_path);
> - {
> - MKSTR(path, "%s/device/net", ibdev_path);
> -
> - dir = opendir(path);
> - if (dir == NULL) {
> - rte_errno = errno;
> - return -rte_errno;
> - }
> - }
> - while ((dent = readdir(dir)) != NULL) {
> - char *name = dent->d_name;
> - FILE *file;
> - unsigned int dev_port;
> - int r;
> -
> - if ((name[0] == '.') &&
> - ((name[1] == '\0') ||
> - ((name[1] == '.') && (name[2] == '\0'))))
> - continue;
> -
> - MKSTR(path, "%s/device/net/%s/%s",
> - ibdev_path, name,
> - (dev_type ? "dev_id" : "dev_port"));
> -
> - file = fopen(path, "rb");
> - if (file == NULL) {
> - if (errno != ENOENT)
> - continue;
> - /*
> - * Switch to dev_id when dev_port does not exist as
> - * is the case with Linux kernel versions < 3.15.
> - */
> -try_dev_id:
> - match[0] = '\0';
> - if (dev_type)
> - break;
> - dev_type = 1;
> - dev_port_prev = ~0u;
> - rewinddir(dir);
> - continue;
> - }
> - r = fscanf(file, (dev_type ? "%x" : "%u"), &dev_port);
> - fclose(file);
> - if (r != 1)
> - continue;
> - /*
> - * Switch to dev_id when dev_port returns the same value for
> - * all ports. May happen when using a MOFED release older than
> - * 3.0 with a Linux kernel >= 3.15.
> - */
> - if (dev_port == dev_port_prev)
> - goto try_dev_id;
> - dev_port_prev = dev_port;
> - if (dev_port == 0)
> - strlcpy(match, name, sizeof(match));
> - }
> - closedir(dir);
> - if (match[0] == '\0') {
> - rte_errno = ENOENT;
> - return -rte_errno;
> - }
> - strncpy(*ifname, match, sizeof(*ifname));
> - return 0;
> -}
> -
> -/**
> * Get interface name from private structure.
> *
> - * This is a port representor-aware version of mlx5_get_master_ifname().
> + * This is a port representor-aware version of mlx5_get_ifname_sysfs().
> *
> * @param[in] dev
> * Pointer to Ethernet device.
> @@ -238,7 +152,7 @@ struct ethtool_link_settings {
> ifindex = mlx5_ifindex(dev);
> if (!ifindex) {
> if (!priv->representor)
> - return mlx5_get_master_ifname(priv->sh->ibdev_path,
> + return mlx5_get_ifname_sysfs(priv->sh->ibdev_path,
> ifname);
> rte_errno = ENXIO;
> return -rte_errno;
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [dpdk-dev] [PATCH 1/2] common/mlx5: share kernel interface name getter
2020-06-18 16:07 ` Maxime Coquelin
@ 2020-06-18 18:28 ` Matan Azrad
0 siblings, 0 replies; 14+ messages in thread
From: Matan Azrad @ 2020-06-18 18:28 UTC (permalink / raw)
To: Maxime Coquelin, Slava Ovsiienko; +Cc: dev
Yes, more conflict are exists with current master-net-mlx.
I have newest version rebased on master-net-mlx.
I will send new version, for all the old versions...
> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: Thursday, June 18, 2020 7:07 PM
> To: Matan Azrad <matan@mellanox.com>; Slava Ovsiienko
> <viacheslavo@mellanox.com>
> Cc: dev@dpdk.org
> Subject: Re: [PATCH 1/2] common/mlx5: share kernel interface name getter
>
> Your series does not apply, there are no common ancestor so I can't do 3-
> way merge.
>
> Could you please rebase it on top of next-virtio's master branch?
>
> Thanks,
> Maxime
>
> On 6/2/20 5:53 PM, Matan Azrad wrote:
> > Some configuration of the mlx5 port are done by the kernel net device
> > associated to the IB device represents the PCI device.
> >
> > The DPDK mlx5 driver uses linux system calls, for example ioctl, in
> > order to configure per port configurations requested by the DPDK user.
> >
> > One of the basic knowledges required to access the correct kernel net
> > device is its name.
> >
> > Move function to get interface name from IB device path to the common
> > library.
> >
> > Signed-off-by: Matan Azrad <matan@mellanox.com>
> > ---
> > drivers/common/mlx5/mlx5_common.c | 88
> ++++++++++++++++++++++++
> > drivers/common/mlx5/mlx5_common.h | 3 +
> > drivers/common/mlx5/rte_common_mlx5_version.map | 2 +
> > drivers/net/mlx5/mlx5.c | 2 +-
> > drivers/net/mlx5/mlx5.h | 1 -
> > drivers/net/mlx5/mlx5_ethdev.c | 90 +------------------------
> > 6 files changed, 96 insertions(+), 90 deletions(-)
> >
> > diff --git a/drivers/common/mlx5/mlx5_common.c
> > b/drivers/common/mlx5/mlx5_common.c
> > index 1c77763..3f0d8d3 100644
> > --- a/drivers/common/mlx5/mlx5_common.c
> > +++ b/drivers/common/mlx5/mlx5_common.c
> > @@ -8,8 +8,10 @@
> > #ifdef RTE_IBVERBS_LINK_DLOPEN
> > #include <dlfcn.h>
> > #endif
> > +#include <dirent.h>
> >
> > #include <rte_errno.h>
> > +#include <rte_string_fns.h>
> >
> > #include "mlx5_common.h"
> > #include "mlx5_common_utils.h"
> > @@ -167,6 +169,92 @@ enum mlx5_class
> > return;
> > }
> >
> > +/**
> > + * Get kernel interface name from IB device path.
> > + *
> > + * @param[in] ibdev_path
> > + * Pointer to IB device path.
> > + * @param[out] ifname
> > + * Interface name output buffer.
> > + *
> > + * @return
> > + * 0 on success, a negative errno value otherwise and rte_errno is set.
> > + */
> > +int
> > +mlx5_get_ifname_sysfs(const char *ibdev_path, char
> > +(*ifname)[IF_NAMESIZE]) {
> > + DIR *dir;
> > + struct dirent *dent;
> > + unsigned int dev_type = 0;
> > + unsigned int dev_port_prev = ~0u;
> > + char match[IF_NAMESIZE] = "";
> > +
> > + MLX5_ASSERT(ibdev_path);
> > + {
> > + MKSTR(path, "%s/device/net", ibdev_path);
> > +
> > + dir = opendir(path);
> > + if (dir == NULL) {
> > + rte_errno = errno;
> > + return -rte_errno;
> > + }
> > + }
> > + while ((dent = readdir(dir)) != NULL) {
> > + char *name = dent->d_name;
> > + FILE *file;
> > + unsigned int dev_port;
> > + int r;
> > +
> > + if ((name[0] == '.') &&
> > + ((name[1] == '\0') ||
> > + ((name[1] == '.') && (name[2] == '\0'))))
> > + continue;
> > +
> > + MKSTR(path, "%s/device/net/%s/%s",
> > + ibdev_path, name,
> > + (dev_type ? "dev_id" : "dev_port"));
> > +
> > + file = fopen(path, "rb");
> > + if (file == NULL) {
> > + if (errno != ENOENT)
> > + continue;
> > + /*
> > + * Switch to dev_id when dev_port does not exist as
> > + * is the case with Linux kernel versions < 3.15.
> > + */
> > +try_dev_id:
> > + match[0] = '\0';
> > + if (dev_type)
> > + break;
> > + dev_type = 1;
> > + dev_port_prev = ~0u;
> > + rewinddir(dir);
> > + continue;
> > + }
> > + r = fscanf(file, (dev_type ? "%x" : "%u"), &dev_port);
> > + fclose(file);
> > + if (r != 1)
> > + continue;
> > + /*
> > + * Switch to dev_id when dev_port returns the same value
> for
> > + * all ports. May happen when using a MOFED release older
> than
> > + * 3.0 with a Linux kernel >= 3.15.
> > + */
> > + if (dev_port == dev_port_prev)
> > + goto try_dev_id;
> > + dev_port_prev = dev_port;
> > + if (dev_port == 0)
> > + strlcpy(match, name, sizeof(match));
> > + }
> > + closedir(dir);
> > + if (match[0] == '\0') {
> > + rte_errno = ENOENT;
> > + return -rte_errno;
> > + }
> > + strncpy(*ifname, match, sizeof(*ifname));
> > + return 0;
> > +}
> > +
> > #ifdef MLX5_GLUE
> >
> > /**
> > diff --git a/drivers/common/mlx5/mlx5_common.h
> > b/drivers/common/mlx5/mlx5_common.h
> > index 8cd3ea5..4f6373b 100644
> > --- a/drivers/common/mlx5/mlx5_common.h
> > +++ b/drivers/common/mlx5/mlx5_common.h
> > @@ -6,6 +6,7 @@
> > #define RTE_PMD_MLX5_COMMON_H_
> >
> > #include <stdio.h>
> > +#include <net/if.h>
> >
> > #include <rte_pci.h>
> > #include <rte_debug.h>
> > @@ -212,6 +213,8 @@ enum mlx5_class {
> > __rte_internal
> > void mlx5_translate_port_name(const char *port_name_in,
> > struct mlx5_switch_info *port_info_out);
> > +__rte_internal
> > +int mlx5_get_ifname_sysfs(const char *ibdev_path, char
> > +(*ifname)[IF_NAMESIZE]);
> >
> > extern uint8_t haswell_broadwell_cpu;
> >
> > diff --git a/drivers/common/mlx5/rte_common_mlx5_version.map
> > b/drivers/common/mlx5/rte_common_mlx5_version.map
> > index b3410df..a62584d 100644
> > --- a/drivers/common/mlx5/rte_common_mlx5_version.map
> > +++ b/drivers/common/mlx5/rte_common_mlx5_version.map
> > @@ -33,6 +33,8 @@ INTERNAL {
> > mlx5_devx_cmd_query_virtq;
> > mlx5_devx_get_out_command_status;
> >
> > + mlx5_get_ifname_sysfs;
> > +
> > mlx5_mp_init_primary;
> > mlx5_mp_uninit_primary;
> > mlx5_mp_init_secondary;
> > diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index
> > 469ff73..91af47b 100644
> > --- a/drivers/net/mlx5/mlx5.c
> > +++ b/drivers/net/mlx5/mlx5.c
> > @@ -3570,7 +3570,7 @@ struct mlx5_flow_id_pool *
> > */
> > continue;
> > }
> > - ret = mlx5_get_master_ifname
> > + ret = mlx5_get_ifname_sysfs
> > (ibv_match[i]->ibdev_path,
> &ifname);
> > if (!ret)
> > list[ns].ifindex =
> > diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index
> > 2908c8b..536afae 100644
> > --- a/drivers/net/mlx5/mlx5.h
> > +++ b/drivers/net/mlx5/mlx5.h
> > @@ -645,7 +645,6 @@ int mlx5_udp_tunnel_port_add(struct rte_eth_dev
> > *dev,
> > /* mlx5_ethdev.c */
> >
> > int mlx5_get_ifname(const struct rte_eth_dev *dev, char
> > (*ifname)[IF_NAMESIZE]); -int mlx5_get_master_ifname(const char
> > *ibdev_path, char (*ifname)[IF_NAMESIZE]); unsigned int
> > mlx5_ifindex(const struct rte_eth_dev *dev); int mlx5_ifreq(const
> > struct rte_eth_dev *dev, int req, struct ifreq *ifr); int
> > mlx5_get_mtu(struct rte_eth_dev *dev, uint16_t *mtu); diff --git
> > a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
> > index b837ce6..62344d1 100644
> > --- a/drivers/net/mlx5/mlx5_ethdev.c
> > +++ b/drivers/net/mlx5/mlx5_ethdev.c
> > @@ -129,95 +129,9 @@ struct ethtool_link_settings { #endif
> >
> > /**
> > - * Get master interface name from private structure.
> > - *
> > - * @param[in] dev
> > - * Pointer to Ethernet device.
> > - * @param[out] ifname
> > - * Interface name output buffer.
> > - *
> > - * @return
> > - * 0 on success, a negative errno value otherwise and rte_errno is set.
> > - */
> > -int
> > -mlx5_get_master_ifname(const char *ibdev_path, char
> > (*ifname)[IF_NAMESIZE]) -{
> > - DIR *dir;
> > - struct dirent *dent;
> > - unsigned int dev_type = 0;
> > - unsigned int dev_port_prev = ~0u;
> > - char match[IF_NAMESIZE] = "";
> > -
> > - MLX5_ASSERT(ibdev_path);
> > - {
> > - MKSTR(path, "%s/device/net", ibdev_path);
> > -
> > - dir = opendir(path);
> > - if (dir == NULL) {
> > - rte_errno = errno;
> > - return -rte_errno;
> > - }
> > - }
> > - while ((dent = readdir(dir)) != NULL) {
> > - char *name = dent->d_name;
> > - FILE *file;
> > - unsigned int dev_port;
> > - int r;
> > -
> > - if ((name[0] == '.') &&
> > - ((name[1] == '\0') ||
> > - ((name[1] == '.') && (name[2] == '\0'))))
> > - continue;
> > -
> > - MKSTR(path, "%s/device/net/%s/%s",
> > - ibdev_path, name,
> > - (dev_type ? "dev_id" : "dev_port"));
> > -
> > - file = fopen(path, "rb");
> > - if (file == NULL) {
> > - if (errno != ENOENT)
> > - continue;
> > - /*
> > - * Switch to dev_id when dev_port does not exist as
> > - * is the case with Linux kernel versions < 3.15.
> > - */
> > -try_dev_id:
> > - match[0] = '\0';
> > - if (dev_type)
> > - break;
> > - dev_type = 1;
> > - dev_port_prev = ~0u;
> > - rewinddir(dir);
> > - continue;
> > - }
> > - r = fscanf(file, (dev_type ? "%x" : "%u"), &dev_port);
> > - fclose(file);
> > - if (r != 1)
> > - continue;
> > - /*
> > - * Switch to dev_id when dev_port returns the same value
> for
> > - * all ports. May happen when using a MOFED release older
> than
> > - * 3.0 with a Linux kernel >= 3.15.
> > - */
> > - if (dev_port == dev_port_prev)
> > - goto try_dev_id;
> > - dev_port_prev = dev_port;
> > - if (dev_port == 0)
> > - strlcpy(match, name, sizeof(match));
> > - }
> > - closedir(dir);
> > - if (match[0] == '\0') {
> > - rte_errno = ENOENT;
> > - return -rte_errno;
> > - }
> > - strncpy(*ifname, match, sizeof(*ifname));
> > - return 0;
> > -}
> > -
> > -/**
> > * Get interface name from private structure.
> > *
> > - * This is a port representor-aware version of mlx5_get_master_ifname().
> > + * This is a port representor-aware version of mlx5_get_ifname_sysfs().
> > *
> > * @param[in] dev
> > * Pointer to Ethernet device.
> > @@ -238,7 +152,7 @@ struct ethtool_link_settings {
> > ifindex = mlx5_ifindex(dev);
> > if (!ifindex) {
> > if (!priv->representor)
> > - return mlx5_get_master_ifname(priv->sh-
> >ibdev_path,
> > + return mlx5_get_ifname_sysfs(priv->sh-
> >ibdev_path,
> > ifname);
> > rte_errno = ENXIO;
> > return -rte_errno;
> >
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2020-06-30 7:42 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-02 15:53 [dpdk-dev] [PATCH 1/2] common/mlx5: share kernel interface name getter Matan Azrad
2020-06-02 15:53 ` [dpdk-dev] [PATCH 2/2] vdpa/mlx5: support MTU feature Matan Azrad
2020-06-18 15:22 ` Maxime Coquelin
2020-06-18 19:06 ` [dpdk-dev] [PATCH v2 0/2] " Matan Azrad
2020-06-18 19:06 ` [dpdk-dev] [PATCH v2 1/2] common/mlx5: share kernel interface name getter Matan Azrad
2020-06-18 19:06 ` [dpdk-dev] [PATCH v2 2/2] vdpa/mlx5: support MTU feature Matan Azrad
2020-06-19 6:39 ` [dpdk-dev] [PATCH v2 0/2] " Maxime Coquelin
2020-06-18 19:08 ` [dpdk-dev] [PATCH] vhost: fix features definition location Matan Azrad
2020-06-23 5:20 ` [dpdk-dev] [dpdk-stable] " Xia, Chenbo
2020-06-30 7:34 ` [dpdk-dev] " Maxime Coquelin
2020-06-30 7:41 ` Maxime Coquelin
2020-06-18 15:19 ` [dpdk-dev] [PATCH 1/2] common/mlx5: share kernel interface name getter Maxime Coquelin
2020-06-18 16:07 ` Maxime Coquelin
2020-06-18 18:28 ` Matan Azrad
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).