Skip to content

Commit 4fa2813

Browse files
mikijoyjgunthorpe
authored andcommitted
RDMA/nldev: Expose port_cap_flags2
port_cap_flags2 represents IBTA PortInfo:CapabilityMask2. The field safely extends the RDMA_NLDEV_ATTR_CAP_FLAGS operand as it was exported as 64 bit to allow this kind of extension. Signed-off-by: Michael Guralnik <michaelgur@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
1 parent 2e8039c commit 4fa2813

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

drivers/infiniband/core/nldev.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ static int fill_port_info(struct sk_buff *msg,
227227
struct net_device *netdev = NULL;
228228
struct ib_port_attr attr;
229229
int ret;
230+
u64 cap_flags = 0;
230231

231232
if (fill_nldev_handle(msg, device))
232233
return -EMSGSIZE;
@@ -239,10 +240,12 @@ static int fill_port_info(struct sk_buff *msg,
239240
return ret;
240241

241242
if (rdma_protocol_ib(device, port)) {
242-
BUILD_BUG_ON(sizeof(attr.port_cap_flags) > sizeof(u64));
243+
BUILD_BUG_ON((sizeof(attr.port_cap_flags) +
244+
sizeof(attr.port_cap_flags2)) > sizeof(u64));
245+
cap_flags = attr.port_cap_flags |
246+
((u64)attr.port_cap_flags2 << 32);
243247
if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_CAP_FLAGS,
244-
(u64)attr.port_cap_flags,
245-
RDMA_NLDEV_ATTR_PAD))
248+
cap_flags, RDMA_NLDEV_ATTR_PAD))
246249
return -EMSGSIZE;
247250
if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_SUBNET_PREFIX,
248251
attr.subnet_prefix, RDMA_NLDEV_ATTR_PAD))

include/uapi/rdma/rdma_netlink.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,9 @@ enum rdma_nldev_attr {
283283

284284
/*
285285
* Device and port capabilities
286+
*
287+
* When used for port info, first 32-bits are CapabilityMask followed by
288+
* 16-bit CapabilityMask2.
286289
*/
287290
RDMA_NLDEV_ATTR_CAP_FLAGS, /* u64 */
288291

0 commit comments

Comments
 (0)