[dpdk-dev] [PATCH 2/2] net/mlx5: fix crash in dev_info_get in secondary process
Raslan Darawsheh
rasland at mellanox.com
Wed Jul 31 09:36:26 CEST 2019
Hi Stephen,
Can you please confirm that Slava's patch fixed your issue and this patch is not needed anymore for MLX5?
So that I can take mlx4 patch only from this series?
Kindest regards,
Raslan Darawsheh
> -----Original Message-----
> From: dev <dev-bounces at dpdk.org> On Behalf Of Stephen Hemminger
> Sent: Friday, July 12, 2019 11:54 PM
> To: Matan Azrad <matan at mellanox.com>; Shahaf Shuler
> <shahafs at mellanox.com>; Yongseok Koh <yskoh at mellanox.com>; Slava
> Ovsiienko <viacheslavo at mellanox.com>
> Cc: dev at dpdk.org; sju at paloaltonetworks.com; Stephen Hemminger
> <stephen at networkplumber.org>
> Subject: [dpdk-dev] [PATCH 2/2] net/mlx5: fix crash in dev_info_get in
> secondary process
>
> mlx5_dev_info_get calls mlx5_get_ifname, but mlx5_get_ifname
> uses priv->ctx which is not a valid pointer in a secondary
> process. The fix is to cache the value in primary.
>
> In the primary process, get and store the interface index of
> the device so that secondary process can see it.
>
> Fixes: e60fbd5b24fc ("mlx5: add device configure/start/stop")
> Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
> ---
> drivers/net/mlx5/mlx5.c | 17 ++++++++---------
> drivers/net/mlx5/mlx5.h | 1 +
> drivers/net/mlx5/mlx5_ethdev.c | 4 +---
> 3 files changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
> index d93f92db56b5..27c5ef9b1763 100644
> --- a/drivers/net/mlx5/mlx5.c
> +++ b/drivers/net/mlx5/mlx5.c
> @@ -1105,6 +1105,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
> int own_domain_id = 0;
> uint16_t port_id;
> unsigned int i;
> + char ifname[IF_NAMESIZE];
>
> /* Determine if this port representor is supposed to be spawned. */
> if (switch_info->representor && dpdk_dev->devargs) {
> @@ -1479,18 +1480,16 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
> mac.addr_bytes[0], mac.addr_bytes[1],
> mac.addr_bytes[2], mac.addr_bytes[3],
> mac.addr_bytes[4], mac.addr_bytes[5]);
> -#ifndef NDEBUG
> - {
> - char ifname[IF_NAMESIZE];
>
> - if (mlx5_get_ifname(eth_dev, &ifname) == 0)
> - DRV_LOG(DEBUG, "port %u ifname is \"%s\"",
> + if (mlx5_get_ifname(eth_dev, &ifname) == 0) {
> + priv->if_index = if_nametoindex(ifname);
> + DRV_LOG(DEBUG, "port %u ifname is \"%s\"",
> eth_dev->data->port_id, ifname);
> - else
> - DRV_LOG(DEBUG, "port %u ifname is unknown",
> - eth_dev->data->port_id);
> + } else {
> + DRV_LOG(DEBUG, "port %u ifname is unknown",
> + eth_dev->data->port_id);
> }
> -#endif
> +
> /* Get actual MTU if possible. */
> err = mlx5_get_mtu(eth_dev, &priv->mtu);
> if (err) {
> diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
> index 5af3f413cdcb..a06ffd444255 100644
> --- a/drivers/net/mlx5/mlx5.h
> +++ b/drivers/net/mlx5/mlx5.h
> @@ -342,6 +342,7 @@ struct mlx5_priv {
> uint16_t vlan_filter[MLX5_MAX_VLAN_IDS]; /* VLAN filters table. */
> unsigned int vlan_filter_n; /* Number of configured VLAN filters. */
> /* Device properties. */
> + unsigned int if_index; /* Associated kernel network device index. */
> uint16_t mtu; /* Configured MTU. */
> unsigned int isolated:1; /* Whether isolated mode is enabled. */
> unsigned int representor:1; /* Device is a port representor. */
> diff --git a/drivers/net/mlx5/mlx5_ethdev.c
> b/drivers/net/mlx5/mlx5_ethdev.c
> index eeefe4df3cd4..41e58db5e573 100644
> --- a/drivers/net/mlx5/mlx5_ethdev.c
> +++ b/drivers/net/mlx5/mlx5_ethdev.c
> @@ -605,7 +605,6 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev, struct
> rte_eth_dev_info *info)
> struct mlx5_priv *priv = dev->data->dev_private;
> struct mlx5_dev_config *config = &priv->config;
> unsigned int max;
> - char ifname[IF_NAMESIZE];
>
> /* FIXME: we should ask the device for these values. */
> info->min_rx_bufsize = 32;
> @@ -626,8 +625,7 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev, struct
> rte_eth_dev_info *info)
> info->rx_offload_capa = (mlx5_get_rx_port_offloads() |
> info->rx_queue_offload_capa);
> info->tx_offload_capa = mlx5_get_tx_port_offloads(dev);
> - if (mlx5_get_ifname(dev, &ifname) == 0)
> - info->if_index = if_nametoindex(ifname);
> + info->if_index = priv->if_index;
> info->reta_size = priv->reta_idx_n ?
> priv->reta_idx_n : config->ind_table_max_size;
> info->hash_key_size = MLX5_RSS_HASH_KEY_LEN;
> --
> 2.20.1
More information about the dev
mailing list