DPDK patches and discussions
 help / color / mirror / Atom feed
From: Yongseok Koh <yskoh@mellanox.com>
To: Slava Ovsiienko <viacheslavo@mellanox.com>
Cc: dev <dev@dpdk.org>, Shahaf Shuler <shahafs@mellanox.com>,
	"stephen@networkplumber.org" <stephen@networkplumber.org>
Subject: Re: [dpdk-dev] [PATCH v2 1/2] net/mlx5: cache the associated network device ifindex
Date: Mon, 22 Jul 2019 05:52:49 +0000	[thread overview]
Message-ID: <99FCF885-1DC9-4EF0-942A-2B7E0BACDADF@mellanox.com> (raw)
In-Reply-To: <1563721001-3730-2-git-send-email-viacheslavo@mellanox.com>

> On Jul 21, 2019, at 7:56 AM, Viacheslav Ovsiienko <viacheslavo@mellanox.com> wrote:
> 
> The associated device index is retrieved via Netlink request to
> underlying Infiniband device driver. This network device index
> is permanent throughout the lifetime of device. We do not
> spawn the rte_eth_dev ports without associated network device, and
> if network device is being unbound we get the remove notification
> message and rte_eth_dev port is also detached. So, we may store
> the ifindex in mlx5_device_spawn() routine at rte_eth_dev port
> creation and initialization time and use the cached value further
> instead of doing actual Netlink request.
> 
> Reported-by: Stephen Hemminger <stephen@networkplumber.org>
> Signed-off-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
> ---

Acked-by: Yongseok Koh <yskoh@mellanox.com>

> drivers/net/mlx5/mlx5.c        |  7 +++++++
> drivers/net/mlx5/mlx5.h        |  1 +
> drivers/net/mlx5/mlx5_ethdev.c | 19 +++++++------------
> 3 files changed, 15 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
> index 608daed..2f6254b 100644
> --- a/drivers/net/mlx5/mlx5.c
> +++ b/drivers/net/mlx5/mlx5.c
> @@ -1630,6 +1630,13 @@ struct mlx5_dev_spawn_data {
> 		eth_dev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR;
> 		eth_dev->data->representor_id = priv->representor_id;
> 	}
> +	/*
> +	 * Store associated network device interface index. This index
> +	 * is permanent throughout the lifetime of device. So, we may store
> +	 * the ifindex here and use the cached value further.
> +	 */
> +	assert(spawn->ifindex);
> +	priv->if_index = spawn->ifindex;
> 	eth_dev->data->dev_private = priv;
> 	priv->dev_data = eth_dev->data;
> 	eth_dev->data->mac_addrs = priv->mac;
> diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
> index a73375a..1011dcc 100644
> --- a/drivers/net/mlx5/mlx5.h
> +++ b/drivers/net/mlx5/mlx5.h
> @@ -465,6 +465,7 @@ struct mlx5_priv {
> 	uint16_t domain_id; /* Switch domain identifier. */
> 	uint16_t vport_id; /* Associated VF vport index (if any). */
> 	int32_t representor_id; /* Port representor identifier. */
> +	unsigned int if_index; /* Associated kernel network device index. */
> 	/* RX/TX queues. */
> 	unsigned int rxqs_n; /* RX queues array size. */
> 	unsigned int txqs_n; /* TX queues array size. */
> diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
> index 6c9bcf1..dfd9e97 100644
> --- a/drivers/net/mlx5/mlx5_ethdev.c
> +++ b/drivers/net/mlx5/mlx5_ethdev.c
> @@ -225,10 +225,7 @@ struct ethtool_link_settings {
> 
> 	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;
> +	ifindex = mlx5_ifindex(dev);
> 	if (!ifindex) {
> 		if (!priv->representor)
> 			return mlx5_get_master_ifname(priv->sh->ibdev_path,
> @@ -299,14 +296,14 @@ struct ethtool_link_settings {
> unsigned int
> mlx5_ifindex(const struct rte_eth_dev *dev)
> {
> -	char ifname[IF_NAMESIZE];
> +	struct mlx5_priv *priv = dev->data->dev_private;
> 	unsigned int ifindex;
> 
> -	if (mlx5_get_ifname(dev, &ifname))
> -		return 0;
> -	ifindex = if_nametoindex(ifname);
> +	assert(priv);
> +	assert(priv->if_index);
> +	ifindex = priv->if_index;
> 	if (!ifindex)
> -		rte_errno = errno;
> +		rte_errno = ENXIO;
> 	return ifindex;
> }
> 
> @@ -641,7 +638,6 @@ struct ethtool_link_settings {
> 	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;
> @@ -662,8 +658,7 @@ struct ethtool_link_settings {
> 	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 = mlx5_ifindex(dev);
> 	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;
> -- 
> 1.8.3.1
> 


  reply	other threads:[~2019-07-22  5:52 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-12 20:54 [dpdk-dev] [PATCH 0/2] fix dev_info_get in mlx secondary process Stephen Hemminger
2019-07-12 20:54 ` [dpdk-dev] [PATCH 1/2] net/mlx4: fix crash in dev_info_get in " Stephen Hemminger
2019-07-30 13:48   ` Matan Azrad
2019-08-04  6:57   ` Raslan Darawsheh
2019-08-05  7:42     ` Raslan Darawsheh
2019-07-12 20:54 ` [dpdk-dev] [PATCH 2/2] net/mlx5: " Stephen Hemminger
2019-07-15  7:41   ` Slava Ovsiienko
2019-07-19  5:31   ` [dpdk-dev] [PATCH 0/2] net/mlx5: cache the associated network device ifindex Viacheslav Ovsiienko
2019-07-19  5:31     ` [dpdk-dev] [PATCH 1/2] " Viacheslav Ovsiienko
2019-07-19 16:15       ` Stephen Hemminger
2019-07-19 16:41         ` Slava Ovsiienko
2019-07-19 18:03           ` Stephen Hemminger
2019-07-19 18:31             ` Slava Ovsiienko
2019-07-19  5:31     ` [dpdk-dev] [PATCH 2/2] Revert "net/mlx5: fix master device Netlink socket sharing" Viacheslav Ovsiienko
2019-07-19 16:16       ` Stephen Hemminger
2019-07-19 16:21         ` Slava Ovsiienko
2019-07-19 16:23           ` Stephen Hemminger
2019-07-21 14:56     ` [dpdk-dev] [PATCH v2 0/2] net/mlx5: cache the associated network device ifindex Viacheslav Ovsiienko
2019-07-21 14:56       ` [dpdk-dev] [PATCH v2 1/2] " Viacheslav Ovsiienko
2019-07-22  5:52         ` Yongseok Koh [this message]
2019-07-21 14:56       ` [dpdk-dev] [PATCH v2 2/2] Revert "net/mlx5: fix master device Netlink socket sharing" Viacheslav Ovsiienko
2019-07-22  5:53         ` Yongseok Koh
2019-07-22  8:43       ` [dpdk-dev] [PATCH v2 0/2] net/mlx5: cache the associated network device ifindex Raslan Darawsheh
2019-07-31  7:36   ` [dpdk-dev] [PATCH 2/2] net/mlx5: fix crash in dev_info_get in secondary process Raslan Darawsheh
2019-07-31 13:47     ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=99FCF885-1DC9-4EF0-942A-2B7E0BACDADF@mellanox.com \
    --to=yskoh@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=shahafs@mellanox.com \
    --cc=stephen@networkplumber.org \
    --cc=viacheslavo@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).