Re: [PATCH rdma-next] RDMA/core: Add rdma_dev_to_netns()

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

 



On Wed, Oct 07, 2020 at 02:03:55AM -0700, Ka-Cheong Poon wrote:
> This function returns the namespace of a struct ib_device if the RDMA
> subsystem is in exclusive network namespace mode.  If the subsystem is
> in shared namespace mode, this function returns NULL.
>
> Signed-off-by: Ka-Cheong Poon <ka-cheong.poon@xxxxxxxxxx>
> ---
>  drivers/infiniband/core/device.c | 16 ++++++++++++++++
>  include/rdma/ib_verbs.h          |  1 +
>  2 files changed, 17 insertions(+)

We don't merge functions without users.

Thanks

>
> diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
> index c36b4d2b61e0..a3dd95bf3050 100644
> --- a/drivers/infiniband/core/device.c
> +++ b/drivers/infiniband/core/device.c
> @@ -144,6 +144,22 @@ bool rdma_dev_access_netns(const struct ib_device *dev, const struct net *net)
>  }
>  EXPORT_SYMBOL(rdma_dev_access_netns);
>
> +/**
> + * rdma_dev_to_netns() - Return the net namespace of a given device if the
> + *			 RDMA subsystem is in exclusive network namespace
> + *			 mode.  If it is in shared namespace mode, this
> + *			 function returns NULL.  Caller can use it to
> + *			 differentiate the two modes of the RDMA subsystem.
> + *
> + * @device: Pointer to rdma device to get the namespace
> + */
> +struct net *rdma_dev_to_netns(const struct ib_device *device)
> +{
> +	return ib_devices_shared_netns ? NULL :
> +		read_pnet(&device->coredev.rdma_net);
> +}
> +EXPORT_SYMBOL(rdma_dev_to_netns);
> +
>  /*
>   * xarray has this behavior where it won't iterate over NULL values stored in
>   * allocated arrays.  So we need our own iterator to see all values stored in
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index c0b2fa7e9b95..aeced1a3324f 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -4715,6 +4715,7 @@ static inline struct ib_device *rdma_device_to_ibdev(struct device *device)
>
>  bool rdma_dev_access_netns(const struct ib_device *device,
>  			   const struct net *net);
> +struct net *rdma_dev_to_netns(const struct ib_device *device);
>
>  #define IB_ROCE_UDP_ENCAP_VALID_PORT_MIN (0xC000)
>  #define IB_GRH_FLOWLABEL_MASK (0x000FFFFF)
> --
> 2.18.4
>



[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