Subject: Re: [PATCH net-next 1/2] nfp: initialize netdev's dev_port with correct id

From: Leon Romanovsky <[email-masked]>
Date: Wed, 29 Mar 2023 21:49:59 +0300

On Wed, Mar 29, 2023 at 04:45:47PM +0200, Louis Peens wrote:
> From: Yinjun Zhang <[email-masked]>
> 
> `dev_port` is used to differentiate devices that share the same
> function, which is the case in most of NFP NICs.

And how did it work without dev_port?
I have no idea what does it mean "different devices that share the same
function".

Thanks

> 
> In some customized scenario, `dev_port` is used to rename netdev
> instead of `phys_port_name`, which requires to initialize it
> correctly to get expected netdev name.
> 
> Example rules using `dev_port`:
> 
>   SUBSYSTEM=="net", ACTION=="add", KERNELS=="0000:e1:00.0", ATTR{dev_port}=="0", NAME:="ens8np0"
>   SUBSYSTEM=="net", ACTION=="add", KERNELS=="0000:e1:00.0", ATTR{dev_port}=="1", NAME:="ens8np1"
> 
> Signed-off-by: Yinjun Zhang <[email-masked]>
> Acked-by: Simon Horman <[email-masked]>
> Signed-off-by: Louis Peens <[email-masked]>
> ---
>  drivers/net/ethernet/netronome/nfp/nfp_port.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ethernet/netronome/nfp/nfp_port.c b/drivers/net/ethernet/netronome/nfp/nfp_port.c
> index 4f2308570dcf..54640bcb70fb 100644
> --- a/drivers/net/ethernet/netronome/nfp/nfp_port.c
> +++ b/drivers/net/ethernet/netronome/nfp/nfp_port.c
> @@ -189,6 +189,7 @@ int nfp_port_init_phy_port(struct nfp_pf *pf, struct nfp_app *app,
>  
>  	port->eth_port = &pf->eth_tbl->ports[id];
>  	port->eth_id = pf->eth_tbl->ports[id].index;
> +	port->netdev->dev_port = id;
>  	if (pf->mac_stats_mem)
>  		port->eth_stats =
>  			pf->mac_stats_mem + port->eth_id * NFP_MAC_STATS_SIZE;
> -- 
> 2.34.1
>