Message ID | 20170628133445.16550-4-leon@kernel.org (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
On Wed, Jun 28, 2017 at 04:34:44PM +0300, Leon Romanovsky wrote: > + if (nla_put_u32(msg, RDMA_NLDEV_ATTR_LID, attr.lid)) > + return -EMSGSIZE; > + if (nla_put_u32(msg, RDMA_NLDEV_ATTR_SM_LID, attr.sm_lid)) > + return -EMSGSIZE; Is this careful to only stuff attributes if they actuall exists? Eg these should not be present for iwarp/roce/etc Same comment for all attributes. Only present if they are valid. 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
On Wed, Jun 28, 2017 at 10:05:13AM -0600, Jason Gunthorpe wrote: > On Wed, Jun 28, 2017 at 04:34:44PM +0300, Leon Romanovsky wrote: > > + if (nla_put_u32(msg, RDMA_NLDEV_ATTR_LID, attr.lid)) > > + return -EMSGSIZE; > > + if (nla_put_u32(msg, RDMA_NLDEV_ATTR_SM_LID, attr.sm_lid)) > > + return -EMSGSIZE; > > Is this careful to only stuff attributes if they actuall exists? Eg > these should not be present for iwarp/roce/etc > > Same comment for all attributes. Only present if they are valid. It will be zero if it is not exist, but you are right it is better to avoid to fill unneeded fields. > > Jason
On Wed, Jun 28, 2017 at 07:16:16PM +0300, Leon Romanovsky wrote: > On Wed, Jun 28, 2017 at 10:05:13AM -0600, Jason Gunthorpe wrote: > > On Wed, Jun 28, 2017 at 04:34:44PM +0300, Leon Romanovsky wrote: > > > + if (nla_put_u32(msg, RDMA_NLDEV_ATTR_LID, attr.lid)) > > > + return -EMSGSIZE; > > > + if (nla_put_u32(msg, RDMA_NLDEV_ATTR_SM_LID, attr.sm_lid)) > > > + return -EMSGSIZE; > > > > Is this careful to only stuff attributes if they actuall exists? Eg > > these should not be present for iwarp/roce/etc > > > > Same comment for all attributes. Only present if they are valid. > > It will be zero if it is not exist, but you are right it is better to > avoid to fill unneeded fields. Not existing is the netlink way. Same comment for everything attributes. Many of the guids do not apply to iwarp, IIRC.. 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
On Wed, Jun 28, 2017 at 10:19:03AM -0600, Jason Gunthorpe wrote: > On Wed, Jun 28, 2017 at 07:16:16PM +0300, Leon Romanovsky wrote: > > On Wed, Jun 28, 2017 at 10:05:13AM -0600, Jason Gunthorpe wrote: > > > On Wed, Jun 28, 2017 at 04:34:44PM +0300, Leon Romanovsky wrote: > > > > + if (nla_put_u32(msg, RDMA_NLDEV_ATTR_LID, attr.lid)) > > > > + return -EMSGSIZE; > > > > + if (nla_put_u32(msg, RDMA_NLDEV_ATTR_SM_LID, attr.sm_lid)) > > > > + return -EMSGSIZE; > > > > > > Is this careful to only stuff attributes if they actuall exists? Eg > > > these should not be present for iwarp/roce/etc > > > > > > Same comment for all attributes. Only present if they are valid. > > > > It will be zero if it is not exist, but you are right it is better to > > avoid to fill unneeded fields. > > Not existing is the netlink way. Same comment for everything > attributes. Many of the guids do not apply to iwarp, IIRC.. I got it, this is why I prefer to have basic RDMAtool with minimal prints (device name + caps) be accepted and only after that start work on every field in serial manner. Thanks > > Jason
diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c index 755b8167280b..6b290dada589 100644 --- a/drivers/infiniband/core/nldev.c +++ b/drivers/infiniband/core/nldev.c @@ -45,6 +45,8 @@ static const struct nla_policy nldev_policy[RDMA_NLDEV_ATTR_MAX] = { [RDMA_NLDEV_ATTR_GUID] = { .type = NLA_U64 }, [RDMA_NLDEV_ATTR_SYS_IMAGE_GUID] = { .type = NLA_U64 }, [RDMA_NLDEV_ATTR_SUBNET_PREFIX] = { .type = NLA_U64 }, + [RDMA_NLDEV_ATTR_LID] = { .type = NLA_U32 }, + [RDMA_NLDEV_ATTR_SM_LID] = { .type = NLA_U32 }, }; static int fill_dev_info(struct sk_buff *msg, struct ib_device *device) @@ -99,7 +101,10 @@ static int fill_port_info(struct sk_buff *msg, if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_SUBNET_PREFIX, attr.subnet_prefix, 0)) return -EMSGSIZE; - + if (nla_put_u32(msg, RDMA_NLDEV_ATTR_LID, attr.lid)) + return -EMSGSIZE; + if (nla_put_u32(msg, RDMA_NLDEV_ATTR_SM_LID, attr.sm_lid)) + return -EMSGSIZE; return 0; } diff --git a/include/uapi/rdma/rdma_netlink.h b/include/uapi/rdma/rdma_netlink.h index 5fec88038e6e..22e4870f2e31 100644 --- a/include/uapi/rdma/rdma_netlink.h +++ b/include/uapi/rdma/rdma_netlink.h @@ -284,6 +284,14 @@ enum rdma_nldev_attr { */ RDMA_NLDEV_ATTR_SUBNET_PREFIX, /* u64 */ + /* + * Local Identifier (LID), + * According to IB specification, It is 16-bit address assigned + * by the Subnet Manager. Extended to be 32-bit for OmniPath users. + */ + RDMA_NLDEV_ATTR_LID, /* u32 */ + RDMA_NLDEV_ATTR_SM_LID, /* u32 */ + RDMA_NLDEV_ATTR_MAX }; #endif /* _UAPI_RDMA_NETLINK_H */