diff mbox

[rdma-next,2/4] RDMA/netlink: Advertise IB subnet prefix

Message ID 20170628133445.16550-3-leon@kernel.org (mailing list archive)
State Superseded
Headers show

Commit Message

Leon Romanovsky June 28, 2017, 1:34 p.m. UTC
From: Leon Romanovsky <leonro@mellanox.com>

Add IB subnet prefix to the port properties exported
by RDMA netlink.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/core/nldev.c  | 4 ++++
 include/uapi/rdma/rdma_netlink.h | 5 +++++
 2 files changed, 9 insertions(+)

Comments

Jason Gunthorpe June 28, 2017, 4:02 p.m. UTC | #1
On Wed, Jun 28, 2017 at 04:34:43PM +0300, Leon Romanovsky wrote:

> +	/*
> +	 * Subnet prefix (in host byte order)
> +	 */
> +	RDMA_NLDEV_ATTR_SUBNET_PREFIX,		/* u64 */

I've always hated how random the be / host choices are in our API.

Since the GUID is in host order I recommend making the subnet_prefix
in host order too.

At the very least, the comments beside anything not in host order
should be 'be64' not u64

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Leon Romanovsky June 28, 2017, 4:10 p.m. UTC | #2
On Wed, Jun 28, 2017 at 10:02:51AM -0600, Jason Gunthorpe wrote:
> On Wed, Jun 28, 2017 at 04:34:43PM +0300, Leon Romanovsky wrote:
>
> > +	/*
> > +	 * Subnet prefix (in host byte order)
> > +	 */
> > +	RDMA_NLDEV_ATTR_SUBNET_PREFIX,		/* u64 */
>
> I've always hated how random the be / host choices are in our API.

Agree

>
> Since the GUID is in host order I recommend making the subnet_prefix
> in host order too.
>
> At the very least, the comments beside anything not in host order
> should be 'be64' not u64

Those comments represent netlink types. It doesn't have be64.

>
> Jason
Jason Gunthorpe June 28, 2017, 4:12 p.m. UTC | #3
On Wed, Jun 28, 2017 at 07:10:20PM +0300, Leon Romanovsky wrote:
> > Since the GUID is in host order I recommend making the subnet_prefix
> > in host order too.
> >
> > At the very least, the comments beside anything not in host order
> > should be 'be64' not u64
> 
> Those comments represent netlink types. It doesn't have be64.

Then don't send b64 down netlink as a netlink u64 type?

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Leon Romanovsky June 28, 2017, 4:21 p.m. UTC | #4
On Wed, Jun 28, 2017 at 10:12:36AM -0600, Jason Gunthorpe wrote:
> On Wed, Jun 28, 2017 at 07:10:20PM +0300, Leon Romanovsky wrote:
> > > Since the GUID is in host order I recommend making the subnet_prefix
> > > in host order too.
> > >
> > > At the very least, the comments beside anything not in host order
> > > should be 'be64' not u64
> >
> > Those comments represent netlink types. It doesn't have be64.
>
> Then don't send b64 down netlink as a netlink u64 type?

Agree, conversion to u64 is the right way to do.

>
> Jason
diff mbox

Patch

diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
index 56500810c2c0..755b8167280b 100644
--- a/drivers/infiniband/core/nldev.c
+++ b/drivers/infiniband/core/nldev.c
@@ -44,6 +44,7 @@  static const struct nla_policy nldev_policy[RDMA_NLDEV_ATTR_MAX] = {
 					    .len = IB_FW_VERSION_NAME_MAX - 1},
 	[RDMA_NLDEV_ATTR_GUID]		= { .type = NLA_U64 },
 	[RDMA_NLDEV_ATTR_SYS_IMAGE_GUID] = { .type = NLA_U64 },
+	[RDMA_NLDEV_ATTR_SUBNET_PREFIX]	= { .type = NLA_U64 },
 };
 
 static int fill_dev_info(struct sk_buff *msg, struct ib_device *device)
@@ -95,6 +96,9 @@  static int fill_port_info(struct sk_buff *msg,
 	if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_CAP_FLAGS,
 			      (u64)attr.port_cap_flags, 0))
 		return -EMSGSIZE;
+	if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_SUBNET_PREFIX,
+			      attr.subnet_prefix, 0))
+		return -EMSGSIZE;
 
 	return 0;
 }
diff --git a/include/uapi/rdma/rdma_netlink.h b/include/uapi/rdma/rdma_netlink.h
index f46af029ace2..5fec88038e6e 100644
--- a/include/uapi/rdma/rdma_netlink.h
+++ b/include/uapi/rdma/rdma_netlink.h
@@ -279,6 +279,11 @@  enum rdma_nldev_attr {
 	 */
 	RDMA_NLDEV_ATTR_SYS_IMAGE_GUID,		/* u64 */
 
+	/*
+	 * Subnet prefix (in host byte order)
+	 */
+	RDMA_NLDEV_ATTR_SUBNET_PREFIX,		/* u64 */
+
 	RDMA_NLDEV_ATTR_MAX
 };
 #endif /* _UAPI_RDMA_NETLINK_H */