Commit 4d7ba8ce authored by Parav Pandit's avatar Parav Pandit Committed by Jason Gunthorpe

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: cb7e0e13 ("RDMA/core: Add interface to read device namespace sharing mode")
Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 641114d2
...@@ -1346,32 +1346,35 @@ static int nldev_dellink(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -1346,32 +1346,35 @@ static int nldev_dellink(struct sk_buff *skb, struct nlmsghdr *nlh,
return 0; return 0;
} }
static int nldev_get_sys_get_dumpit(struct sk_buff *skb, static int nldev_sys_get_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
struct netlink_callback *cb) struct netlink_ext_ack *extack)
{ {
struct nlattr *tb[RDMA_NLDEV_ATTR_MAX]; struct nlattr *tb[RDMA_NLDEV_ATTR_MAX];
struct nlmsghdr *nlh; struct sk_buff *msg;
int err; int err;
err = nlmsg_parse(cb->nlh, 0, tb, RDMA_NLDEV_ATTR_MAX - 1, err = nlmsg_parse(nlh, 0, tb, RDMA_NLDEV_ATTR_MAX - 1,
nldev_policy, NULL); nldev_policy, extack);
if (err) if (err)
return err; return err;
nlh = nlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg)
return -ENOMEM;
nlh = nlmsg_put(msg, NETLINK_CB(skb).portid, nlh->nlmsg_seq,
RDMA_NL_GET_TYPE(RDMA_NL_NLDEV, RDMA_NL_GET_TYPE(RDMA_NL_NLDEV,
RDMA_NLDEV_CMD_SYS_GET), RDMA_NLDEV_CMD_SYS_GET),
0, 0); 0, 0);
err = nla_put_u8(skb, RDMA_NLDEV_SYS_ATTR_NETNS_MODE, err = nla_put_u8(msg, RDMA_NLDEV_SYS_ATTR_NETNS_MODE,
(u8)ib_devices_shared_netns); (u8)ib_devices_shared_netns);
if (err) { if (err) {
nlmsg_cancel(skb, nlh); nlmsg_free(msg);
return err; return err;
} }
nlmsg_end(msg, nlh);
nlmsg_end(skb, nlh); return rdma_nl_unicast(msg, NETLINK_CB(skb).portid);
return skb->len;
} }
static int nldev_set_sys_set_doit(struct sk_buff *skb, struct nlmsghdr *nlh, static 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,7 +1444,7 @@ static const struct rdma_nl_cbs nldev_cb_table[RDMA_NLDEV_NUM_OPS] = {
.dump = nldev_res_get_pd_dumpit, .dump = nldev_res_get_pd_dumpit,
}, },
[RDMA_NLDEV_CMD_SYS_GET] = { [RDMA_NLDEV_CMD_SYS_GET] = {
.dump = nldev_get_sys_get_dumpit, .doit = nldev_sys_get_doit,
}, },
[RDMA_NLDEV_CMD_SYS_SET] = { [RDMA_NLDEV_CMD_SYS_SET] = {
.doit = nldev_set_sys_set_doit, .doit = nldev_set_sys_set_doit,
......
...@@ -250,7 +250,7 @@ enum rdma_nldev_command { ...@@ -250,7 +250,7 @@ enum rdma_nldev_command {
RDMA_NLDEV_CMD_PORT_GET, /* can dump */ RDMA_NLDEV_CMD_PORT_GET, /* can dump */
RDMA_NLDEV_CMD_SYS_GET, /* can dump */ RDMA_NLDEV_CMD_SYS_GET,
RDMA_NLDEV_CMD_SYS_SET, RDMA_NLDEV_CMD_SYS_SET,
/* 8 is free to use */ /* 8 is free to use */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment