RE: [PATCH rdma-next v4] RDMA/nldev: Return device protocol

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

 




> -----Original Message-----
> From: linux-rdma-owner@xxxxxxxxxxxxxxx <linux-rdma-
> owner@xxxxxxxxxxxxxxx> On Behalf Of Leon Romanovsky
> Sent: Tuesday, April 2, 2019 1:51 PM
> To: Doug Ledford <dledford@xxxxxxxxxx>; Jason Gunthorpe
> <jgg@xxxxxxxxxxxx>
> Cc: Leon Romanovsky <leonro@xxxxxxxxxxxx>; RDMA mailing list <linux-
> rdma@xxxxxxxxxxxxxxx>
> Subject: [PATCH rdma-next v4] RDMA/nldev: Return device protocol
> 
> From: Leon Romanovsky <leonro@xxxxxxxxxxxx>
> 
> Add new RDMA_NLDEV_ATTR_DEV_PROTOCOL attribute to give ability for
> UDEV rules create Ib device stable names based on link type protocol.
> The assumption that devices like mlx4 with duality in their link type under
> one IB device struct won't be allowed in the future.
> 
> Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>
> ---
>  Changelog
>  v3 -> v4:
>   * Used preferred by Jason coding style.
>  v2 -> v3:
>   * Fixed double assignment in case of OPA link
>   * Update commit message
>  v1 -> v2:
>   * Created special netlink attribute to return device protocol.
>  v0 -> v1:
>   * Added special return type for RXE to return same information as it
>     was provided by link_set while RXE link is created.
> ---
>  drivers/infiniband/core/nldev.c  | 24 +++++++++++++++++++++++-
> include/uapi/rdma/rdma_netlink.h |  4 ++++
>  2 files changed, 27 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
> index 854f47d78d8e..2c04bf408ee3 100644
> --- a/drivers/infiniband/core/nldev.c
> +++ b/drivers/infiniband/core/nldev.c
> @@ -118,6 +118,8 @@ static const struct nla_policy
> nldev_policy[RDMA_NLDEV_ATTR_MAX] = {
>  				    .len = RDMA_NLDEV_ATTR_ENTRY_STRLEN
> },
>  	[RDMA_NLDEV_SYS_ATTR_NETNS_MODE]	= { .type = NLA_U8 },
>  	[RDMA_NLDEV_NET_NS_FD]			= { .type = NLA_U32 },
> +	[RDMA_NLDEV_ATTR_DEV_PROTOCOL]		= { .type =
> NLA_NUL_STRING,
> +				    .len = RDMA_NLDEV_ATTR_ENTRY_STRLEN
> },
>  };
> 
>  static int put_driver_name_print_type(struct sk_buff *msg, const char
> *name, @@ -200,6 +202,8 @@ static int fill_nldev_handle(struct sk_buff
> *msg, struct ib_device *device)  static int fill_dev_info(struct sk_buff *msg,
> struct ib_device *device)  {
>  	char fw[IB_FW_VERSION_NAME_MAX];
> +	int ret = 0;
> +	u8 port;
> 
>  	if (fill_nldev_handle(msg, device))
>  		return -EMSGSIZE;
> @@ -228,7 +232,25 @@ static int fill_dev_info(struct sk_buff *msg, struct
> ib_device *device)
>  		return -EMSGSIZE;
>  	if (nla_put_u8(msg, RDMA_NLDEV_ATTR_DEV_NODE_TYPE, device-
> >node_type))
>  		return -EMSGSIZE;
> -	return 0;
> +
> +	/*
> +	 * Link type is determined on first port and mlx4 device
> +	 * which can potentially have two different link type for the same
> +	 * IB device is considered as better to be avoided in the future,
> +	 */
> +	port = rdma_start_port(device);
> +	if (rdma_cap_opa_mad(device, port))
> +		ret = nla_put_string(msg,
> RDMA_NLDEV_ATTR_DEV_PROTOCOL, "opa");
> +	else if (rdma_protocol_ib(device, port))
> +		ret = nla_put_string(msg,
> RDMA_NLDEV_ATTR_DEV_PROTOCOL, "ib");
> +	else if (rdma_protocol_iwarp(device, port))
> +		ret = nla_put_string(msg,
> RDMA_NLDEV_ATTR_DEV_PROTOCOL, "iw");
> +	else if (rdma_protocol_roce(device, port))
> +		ret = nla_put_string(msg,
> RDMA_NLDEV_ATTR_DEV_PROTOCOL, "roce");
> +	else if (rdma_protocol_usnic(device, port))
> +		ret = nla_put_string(msg,
> RDMA_NLDEV_ATTR_DEV_PROTOCOL,
> +				     "usnic");
> +	return ret;
>  }
> 
>  static int fill_port_info(struct sk_buff *msg, diff --git
> a/include/uapi/rdma/rdma_netlink.h b/include/uapi/rdma/rdma_netlink.h
> index 09b0ad8ea9d4..d4a5b7bcd51a 100644
> --- a/include/uapi/rdma/rdma_netlink.h
> +++ b/include/uapi/rdma/rdma_netlink.h
> @@ -484,6 +484,10 @@ enum rdma_nldev_attr {
>  	 * File descriptor handle of the net namespace object
>  	 */
>  	RDMA_NLDEV_NET_NS_FD,			/* u32 */
> +	/*
> +	 * Device protocol, e.g. ib, iw, usnic, roce and opa
> +	 */
> +	RDMA_NLDEV_ATTR_DEV_PROTOCOL,		/* string */
> 
>  	/*
>  	 * Always the end
> --
> 2.20.1
Reviewed-by: Parav Pandit <parav@xxxxxxxxxxxx>





[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