public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Junxian Huang <huangjunxian6@hisilicon.com>
Cc: jgg@nvidia.com, linux-rdma@vger.kernel.org, linuxarm@huawei.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 for-next] RDMA/core: Get IB width and speed from netdev
Date: Mon, 24 Jul 2023 14:19:38 +0300	[thread overview]
Message-ID: <20230724111938.GB9776@unreal> (raw)
In-Reply-To: <20230721092052.2090449-1-huangjunxian6@hisilicon.com>

On Fri, Jul 21, 2023 at 05:20:52PM +0800, Junxian Huang wrote:
> From: Haoyue Xu <xuhaoyue1@hisilicon.com>
> 
> Previously, there was no way to query the number of lanes for a network
> card, so the same netdev_speed would result in a fixed pair of width and
> speed. As network card specifications become more diverse, such fixed
> mode is no longer suitable, so a method is needed to obtain the correct
> width and speed based on the number of lanes.
> 
> This patch retrieves netdev lanes and speed from net_device and
> translates them to IB width and speed.
> 
> Signed-off-by: Haoyue Xu <xuhaoyue1@hisilicon.com>
> Signed-off-by: Luoyouming <luoyouming@huawei.com>
> Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
> ---
>  drivers/infiniband/core/verbs.c | 100 +++++++++++++++++++++++++-------
>  1 file changed, 79 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
> index b99b3cc283b6..25367bd6dd97 100644
> --- a/drivers/infiniband/core/verbs.c
> +++ b/drivers/infiniband/core/verbs.c
> @@ -1880,6 +1880,80 @@ int ib_modify_qp_with_udata(struct ib_qp *ib_qp, struct ib_qp_attr *attr,
>  }
>  EXPORT_SYMBOL(ib_modify_qp_with_udata);
>  
> +static void ib_get_width_and_speed(u32 netdev_speed, u32 lanes,
> +				   u16 *speed, u8 *width)

<...>

> +	switch (netdev_speed / lanes) {
> +	case SPEED_2500:
> +		*speed = IB_SPEED_SDR;
> +		break;
> +	case SPEED_5000:
> +		*speed = IB_SPEED_DDR;
> +		break;
> +	case SPEED_10000:
> +		*speed = IB_SPEED_FDR10;
> +		break;
> +	case SPEED_14000:
> +		*speed = IB_SPEED_FDR;
> +		break;
> +	case SPEED_25000:
> +		*speed = IB_SPEED_EDR;
> +		break;
> +	case SPEED_50000:
> +		*speed = IB_SPEED_HDR;
> +		break;
> +	case SPEED_100000:
> +		*speed = IB_SPEED_NDR;
> +		break;
> +	default:
> +		*speed = IB_SPEED_SDR;
> +	}

How did you come to these translation values?

Thanks

  reply	other threads:[~2023-07-24 11:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-21  9:20 [PATCH v4 for-next] RDMA/core: Get IB width and speed from netdev Junxian Huang
2023-07-24 11:19 ` Leon Romanovsky [this message]
2023-07-27  3:44   ` Junxian Huang
2023-07-27  6:58     ` Leon Romanovsky
2023-07-27  7:53       ` Junxian Huang
2023-07-30 12:06 ` Leon Romanovsky

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=20230724111938.GB9776@unreal \
    --to=leon@kernel.org \
    --cc=huangjunxian6@hisilicon.com \
    --cc=jgg@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linuxarm@huawei.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