aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorParav Pandit <parav@mellanox.com>2019-05-13 01:26:57 -0400
committerJason Gunthorpe <jgg@mellanox.com>2019-05-13 21:16:48 -0400
commit4d7ba8ce0fec6d5f364dc15786453d26fc0ccb65 (patch)
tree2a64ec1f5e0d0b962ac09442fc6bfd3ba396095e
parent641114d2af312d39ca9bbc2369d18a5823da51c6 (diff)
RDMA/core: Change system parameters callback from dumpit to doit
.dumpit() callback is used for returning same type of data in the loop, e.g. loop over ports, resources, devices. However system parameters are general and standalone for whole subsystem. It means that getting system parameters should be doit callback. Fixes: cb7e0e130503 ("RDMA/core: Add interface to read device namespace sharing mode") Signed-off-by: Parav Pandit <parav@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
-rw-r--r--drivers/infiniband/core/nldev.c27
-rw-r--r--include/uapi/rdma/rdma_netlink.h2
2 files changed, 16 insertions, 13 deletions
diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
index bced945a456d..cbd712f5f8b2 100644
--- a/drivers/infiniband/core/nldev.c
+++ b/drivers/infiniband/core/nldev.c
@@ -1346,32 +1346,35 @@ static int nldev_dellink(struct sk_buff *skb, struct nlmsghdr *nlh,
1346 return 0; 1346 return 0;
1347} 1347}
1348 1348
1349static int nldev_get_sys_get_dumpit(struct sk_buff *skb, 1349static int nldev_sys_get_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
1350 struct netlink_callback *cb) 1350 struct netlink_ext_ack *extack)
1351{ 1351{
1352 struct nlattr *tb[RDMA_NLDEV_ATTR_MAX]; 1352 struct nlattr *tb[RDMA_NLDEV_ATTR_MAX];
1353 struct nlmsghdr *nlh; 1353 struct sk_buff *msg;
1354 int err; 1354 int err;
1355 1355
1356 err = nlmsg_parse(cb->nlh, 0, tb, RDMA_NLDEV_ATTR_MAX - 1, 1356 err = nlmsg_parse(nlh, 0, tb, RDMA_NLDEV_ATTR_MAX - 1,
1357 nldev_policy, NULL); 1357 nldev_policy, extack);
1358 if (err) 1358 if (err)
1359 return err; 1359 return err;
1360 1360
1361 nlh = nlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, 1361 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
1362 if (!msg)
1363 return -ENOMEM;
1364
1365 nlh = nlmsg_put(msg, NETLINK_CB(skb).portid, nlh->nlmsg_seq,
1362 RDMA_NL_GET_TYPE(RDMA_NL_NLDEV, 1366 RDMA_NL_GET_TYPE(RDMA_NL_NLDEV,
1363 RDMA_NLDEV_CMD_SYS_GET), 1367 RDMA_NLDEV_CMD_SYS_GET),
1364 0, 0); 1368 0, 0);
1365 1369
1366 err = nla_put_u8(skb, RDMA_NLDEV_SYS_ATTR_NETNS_MODE, 1370 err = nla_put_u8(msg, RDMA_NLDEV_SYS_ATTR_NETNS_MODE,
1367 (u8)ib_devices_shared_netns); 1371 (u8)ib_devices_shared_netns);
1368 if (err) { 1372 if (err) {
1369 nlmsg_cancel(skb, nlh); 1373 nlmsg_free(msg);
1370 return err; 1374 return err;
1371 } 1375 }
1372 1376 nlmsg_end(msg, nlh);
1373 nlmsg_end(skb, nlh); 1377 return rdma_nl_unicast(msg, NETLINK_CB(skb).portid);
1374 return skb->len;
1375} 1378}
1376 1379
1377static int nldev_set_sys_set_doit(struct sk_buff *skb, struct nlmsghdr *nlh, 1380static int nldev_set_sys_set_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
@@ -1441,7 +1444,7 @@ static const struct rdma_nl_cbs nldev_cb_table[RDMA_NLDEV_NUM_OPS] = {
1441 .dump = nldev_res_get_pd_dumpit, 1444 .dump = nldev_res_get_pd_dumpit,
1442 }, 1445 },
1443 [RDMA_NLDEV_CMD_SYS_GET] = { 1446 [RDMA_NLDEV_CMD_SYS_GET] = {
1444 .dump = nldev_get_sys_get_dumpit, 1447 .doit = nldev_sys_get_doit,
1445 }, 1448 },
1446 [RDMA_NLDEV_CMD_SYS_SET] = { 1449 [RDMA_NLDEV_CMD_SYS_SET] = {
1447 .doit = nldev_set_sys_set_doit, 1450 .doit = nldev_set_sys_set_doit,
diff --git a/include/uapi/rdma/rdma_netlink.h b/include/uapi/rdma/rdma_netlink.h
index 42a8bdc40a14..41db51367efa 100644
--- a/include/uapi/rdma/rdma_netlink.h
+++ b/include/uapi/rdma/rdma_netlink.h
@@ -250,7 +250,7 @@ enum rdma_nldev_command {
250 250
251 RDMA_NLDEV_CMD_PORT_GET, /* can dump */ 251 RDMA_NLDEV_CMD_PORT_GET, /* can dump */
252 252
253 RDMA_NLDEV_CMD_SYS_GET, /* can dump */ 253 RDMA_NLDEV_CMD_SYS_GET,
254 RDMA_NLDEV_CMD_SYS_SET, 254 RDMA_NLDEV_CMD_SYS_SET,
255 255
256 /* 8 is free to use */ 256 /* 8 is free to use */