Re: [PATCH] IB/core: Add more speed parsing in ib_get_eth_speed()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 26, 2023 at 01:34:53AM -0700, Selvin Xavier wrote:
> From: Kalesh AP <kalesh-anakkur.purayil@xxxxxxxxxxxx>
> 
> The function ib_get_eth_speed() does not take consideration
> of 50G, 56G, 100G and 200G speeds. Added these speeds parsing.
> We are not considering the lane width now. This can be enhanced
> later.
> 
> Also, refactored the code to use switch case instead of if-else.
> 
> Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@xxxxxxxxxxxx>
> Signed-off-by: Selvin Xavier <selvin.xavier@xxxxxxxxxxxx>
> ---
>  drivers/infiniband/core/verbs.c | 34 ++++++++++++++++++++++++++++------
>  1 file changed, 28 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
> index b99b3cc..ebd389a 100644
> --- a/drivers/infiniband/core/verbs.c
> +++ b/drivers/infiniband/core/verbs.c
> @@ -1908,22 +1908,44 @@ int ib_get_eth_speed(struct ib_device *dev, u32 port_num, u16 *speed, u8 *width)
>  			netdev_speed);
>  	}
>  
> -	if (netdev_speed <= SPEED_1000) {
> +	switch (netdev_speed) {
> +	case SPEED_1000:
>  		*width = IB_WIDTH_1X;
>  		*speed = IB_SPEED_SDR;
> -	} else if (netdev_speed <= SPEED_10000) {
> +		break;
> +	case SPEED_10000:

This conversion is not equal to code before. We have more speeds between
SPEED_1000 and SPEED_10000.

include/uapi/linux/ethtool.h
...
  1889 #define SPEED_1000              1000
  1890 #define SPEED_2500              2500
  1891 #define SPEED_5000              5000
  1892 #define SPEED_10000             10000


Thanks



>  		*width = IB_WIDTH_1X;
>  		*speed = IB_SPEED_FDR10;
> -	} else if (netdev_speed <= SPEED_20000) {
> +		break;
> +	case SPEED_20000:
>  		*width = IB_WIDTH_4X;
>  		*speed = IB_SPEED_DDR;
> -	} else if (netdev_speed <= SPEED_25000) {
> +		break;
> +	case SPEED_25000:
>  		*width = IB_WIDTH_1X;
>  		*speed = IB_SPEED_EDR;
> -	} else if (netdev_speed <= SPEED_40000) {
> +		break;
> +	case SPEED_40000:
>  		*width = IB_WIDTH_4X;
>  		*speed = IB_SPEED_FDR10;
> -	} else {
> +		break;
> +	case SPEED_50000:
> +		*width = IB_WIDTH_2X;
> +		*speed = IB_SPEED_EDR;
> +		break;
> +	case SPEED_56000:
> +		*width = IB_WIDTH_4X;
> +		*speed = IB_SPEED_FDR;
> +		break;
> +	case SPEED_100000:
> +		*width = IB_WIDTH_4X;
> +		*speed = IB_SPEED_EDR;
> +		break;
> +	case SPEED_200000:
> +		*width = IB_WIDTH_4X;
> +		*speed = IB_SPEED_HDR;
> +		break;
> +	default:
>  		*width = IB_WIDTH_4X;
>  		*speed = IB_SPEED_EDR;
>  	}
> -- 
> 2.5.5
> 





[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux