Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Kamal Heib <kheib@redhat.com>
Cc: linux-rdma@vger.kernel.org, Leon Romanovsky <leon@kernel.org>
Subject: Re: [PATCH for-next v1] RDMA/nldev: Add support for reporting ipoib netdev
Date: Mon, 18 Sep 2023 09:30:26 -0300	[thread overview]
Message-ID: <20230918123026.GA13795@ziepe.ca> (raw)
In-Reply-To: <20230915183757.510557-1-kheib@redhat.com>

On Fri, Sep 15, 2023 at 02:37:57PM -0400, Kamal Heib wrote:
> This patch adds support for reporting the ipoib net device for a given
> RDMA device by calling ib_get_net_dev_by_params() when filling the
> port's info.
> 
> $ rdma link show mlx5_0/1
> link mlx5_0/1 subnet_prefix fe80:0000:0000:0000 lid 66 sm_lid 3 lmc 0
> 	state ACTIVE physical_state LINK_UP netdev ibp196s0f0
> 
> Signed-off-by: Kamal Heib <kheib@redhat.com>
> ---
> v1: Check namespace and query pkey.
> ---
>  drivers/infiniband/core/nldev.c | 27 ++++++++++++++++++++++++++-
>  1 file changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
> index d5d3e4f0de77..f3fa8143cdc7 100644
> --- a/drivers/infiniband/core/nldev.c
> +++ b/drivers/infiniband/core/nldev.c
> @@ -308,10 +308,12 @@ static int fill_port_info(struct sk_buff *msg,
>  			  struct ib_device *device, u32 port,
>  			  const struct net *net)
>  {
> +	struct net_device *ipoib_netdev = NULL;
>  	struct net_device *netdev = NULL;
>  	struct ib_port_attr attr;
> -	int ret;
>  	u64 cap_flags = 0;
> +	u16 pkey;
> +	int ret;
>  
>  	if (fill_nldev_handle(msg, device))
>  		return -EMSGSIZE;
> @@ -340,6 +342,26 @@ static int fill_port_info(struct sk_buff *msg,
>  			return -EMSGSIZE;
>  		if (nla_put_u8(msg, RDMA_NLDEV_ATTR_LMC, attr.lmc))
>  			return -EMSGSIZE;
> +
> +		ret = ib_query_pkey(device, port, 0, &pkey);
> +		if (ret)
> +			goto out;

That doesn't really make any sense..

The whole idea there is only one ipoib device doesn't even make sense.

I still don't like this at all.

> +
> +		ipoib_netdev = ib_get_net_dev_by_params(device, port,
> +							pkey,
> +							NULL, NULL);
> +		if (ipoib_netdev && net_eq(dev_net(ipoib_netdev), net)) {
> +			ret = nla_put_u32(msg,
> +					  RDMA_NLDEV_ATTR_NDEV_INDEX,
> +					  ipoib_netdev->ifindex);
> +			if (ret)
> +				goto out;
> +			ret = nla_put_string(msg,
> +					     RDMA_NLDEV_ATTR_NDEV_NAME,
> +					     ipoib_netdev->name);
> +			if (ret)
> +				goto out;

and I don't think the existing netlink attributes should be redefined
to be about ipoib

Jason

      parent reply	other threads:[~2023-09-18 12:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-15 18:37 [PATCH for-next v1] RDMA/nldev: Add support for reporting ipoib netdev Kamal Heib
2023-09-18 11:52 ` Leon Romanovsky
2023-09-18 12:30 ` Jason Gunthorpe [this message]

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=20230918123026.GA13795@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=kheib@redhat.com \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    /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