Subject: Re: [PATCH RFC] RDMA/core: Handle ARPHRD_NONE devices

From: Jason Gunthorpe <[email-masked]>
Date: Tue, 6 Jun 2023 12:48:45 -0300

On Fri, Jun 02, 2023 at 03:24:30PM -0400, Chuck Lever wrote:
> From: Chuck Lever <[email-masked]>
> 
> We would like to enable the use of siw on top of a VPN that is
> constructed and managed via a tun device. That hasn't worked up
> until now because ARPHRD_NONE devices (such as tun devices) have
> no GID for the RDMA/core to look up.
> 
> But it turns out that the egress device has already been picked for
> us. addr_handler() just has to do the right thing with it.
> 
> Suggested-by: Jason Gunthorpe <[email-masked]>
> Signed-off-by: Chuck Lever <[email-masked]>
> ---
>  drivers/infiniband/core/cma.c |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> index 56e568fcd32b..3351dc5afa17 100644
> --- a/drivers/infiniband/core/cma.c
> +++ b/drivers/infiniband/core/cma.c
> @@ -704,11 +704,15 @@ cma_validate_port(struct ib_device *device, u32 port,
>  		ndev = dev_get_by_index(dev_addr->net, bound_if_index);
>  		if (!ndev)
>  			return ERR_PTR(-ENODEV);
> +	} else if (dev_type == ARPHRD_NONE) {
> +		sgid_attr = rdma_get_gid_attr(device, port, 0);

It seems believable, should it be locked to iwarp devices?

More broadly, should iwarp devices just always do this and skip all
the rest of it?

I think it also has to check that the returned netdev in the sgid_attr
matches the egress netdev selected?

Jason