Skip to content

Commit 25a0ad8

Browse files
Steve Wisedledford
authored andcommitted
RDMA/nldev: Add explicit pad attribute
Add a specific RDMA_NLDEV_ATTR_PAD attribute to be used for 64b attribute padding. To preserve the ABI, make this attribute equal to RDMA_NLDEV_ATTR_UNSPEC, which has a value of 0, because that has been used up until now as the pad attribute. Change all the previous use of 0 as the pad with this new enum. Signed-off-by: Steve Wise <[email protected]> Reviewed-by: Leon Romanovsky <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent ffab8c8 commit 25a0ad8

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

drivers/infiniband/core/nldev.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ static int fill_dev_info(struct sk_buff *msg, struct ib_device *device)
122122

123123
BUILD_BUG_ON(sizeof(device->attrs.device_cap_flags) != sizeof(u64));
124124
if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_CAP_FLAGS,
125-
device->attrs.device_cap_flags, 0))
125+
device->attrs.device_cap_flags,
126+
RDMA_NLDEV_ATTR_PAD))
126127
return -EMSGSIZE;
127128

128129
ib_get_device_fw_str(device, fw);
@@ -131,10 +132,12 @@ static int fill_dev_info(struct sk_buff *msg, struct ib_device *device)
131132
return -EMSGSIZE;
132133

133134
if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_NODE_GUID,
134-
be64_to_cpu(device->node_guid), 0))
135+
be64_to_cpu(device->node_guid),
136+
RDMA_NLDEV_ATTR_PAD))
135137
return -EMSGSIZE;
136138
if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_SYS_IMAGE_GUID,
137-
be64_to_cpu(device->attrs.sys_image_guid), 0))
139+
be64_to_cpu(device->attrs.sys_image_guid),
140+
RDMA_NLDEV_ATTR_PAD))
138141
return -EMSGSIZE;
139142
if (nla_put_u8(msg, RDMA_NLDEV_ATTR_DEV_NODE_TYPE, device->node_type))
140143
return -EMSGSIZE;
@@ -161,11 +164,11 @@ static int fill_port_info(struct sk_buff *msg,
161164

162165
BUILD_BUG_ON(sizeof(attr.port_cap_flags) > sizeof(u64));
163166
if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_CAP_FLAGS,
164-
(u64)attr.port_cap_flags, 0))
167+
(u64)attr.port_cap_flags, RDMA_NLDEV_ATTR_PAD))
165168
return -EMSGSIZE;
166169
if (rdma_protocol_ib(device, port) &&
167170
nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_SUBNET_PREFIX,
168-
attr.subnet_prefix, 0))
171+
attr.subnet_prefix, RDMA_NLDEV_ATTR_PAD))
169172
return -EMSGSIZE;
170173
if (rdma_protocol_ib(device, port)) {
171174
if (nla_put_u32(msg, RDMA_NLDEV_ATTR_LID, attr.lid))
@@ -209,8 +212,8 @@ static int fill_res_info_entry(struct sk_buff *msg,
209212

210213
if (nla_put_string(msg, RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_NAME, name))
211214
goto err;
212-
if (nla_put_u64_64bit(msg,
213-
RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_CURR, curr, 0))
215+
if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_CURR, curr,
216+
RDMA_NLDEV_ATTR_PAD))
214217
goto err;
215218

216219
nla_nest_end(msg, entry_attr);
@@ -409,7 +412,7 @@ static int fill_res_cq_entry(struct sk_buff *msg, struct netlink_callback *cb,
409412
if (nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_CQE, cq->cqe))
410413
goto err;
411414
if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_RES_USECNT,
412-
atomic_read(&cq->usecnt), 0))
415+
atomic_read(&cq->usecnt), RDMA_NLDEV_ATTR_PAD))
413416
goto err;
414417

415418
/* Poll context is only valid for kernel CQs */
@@ -445,11 +448,12 @@ static int fill_res_mr_entry(struct sk_buff *msg, struct netlink_callback *cb,
445448
if (nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_LKEY, mr->lkey))
446449
goto err;
447450
if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_RES_IOVA,
448-
mr->iova, 0))
451+
mr->iova, RDMA_NLDEV_ATTR_PAD))
449452
goto err;
450453
}
451454

452-
if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_RES_MRLEN, mr->length, 0))
455+
if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_RES_MRLEN, mr->length,
456+
RDMA_NLDEV_ATTR_PAD))
453457
goto err;
454458

455459
if (fill_res_name_pid(msg, res))
@@ -484,7 +488,7 @@ static int fill_res_pd_entry(struct sk_buff *msg, struct netlink_callback *cb,
484488
goto err;
485489
}
486490
if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_RES_USECNT,
487-
atomic_read(&pd->usecnt), 0))
491+
atomic_read(&pd->usecnt), RDMA_NLDEV_ATTR_PAD))
488492
goto err;
489493
if ((pd->flags & IB_PD_UNSAFE_GLOBAL_RKEY) &&
490494
nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_UNSAFE_GLOBAL_RKEY,

include/uapi/rdma/rdma_netlink.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,9 @@ enum rdma_nldev_attr {
253253
/* don't change the order or add anything between, this is ABI! */
254254
RDMA_NLDEV_ATTR_UNSPEC,
255255

256+
/* Pad attribute for 64b alignment */
257+
RDMA_NLDEV_ATTR_PAD = RDMA_NLDEV_ATTR_UNSPEC,
258+
256259
/* Identifier for ib_device */
257260
RDMA_NLDEV_ATTR_DEV_INDEX, /* u32 */
258261

0 commit comments

Comments
 (0)