Re: [PATCH rdma-rc] RDMA/core: Change system parameters callback from dumpit to doit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 13, 2019 at 08:26:57AM +0300, Leon Romanovsky wrote:
> From: Parav Pandit <parav@xxxxxxxxxxxx>
>
> .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@xxxxxxxxxxxx>
> Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>
> ---
> Jason, Doug
>
> It will send extra complexity with kernel-headers updates

send -> save

> if this patch goes as part of second PR to Linus in this merge
> window.
>
> Thanks
> ---
>  drivers/infiniband/core/nldev.c  | 27 +++++++++++++++------------
>  include/uapi/rdma/rdma_netlink.h |  2 +-
>  2 files changed, 16 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
> index 46c0ec97aa53..7ce3a6b7a936 100644
> --- a/drivers/infiniband/core/nldev.c
> +++ b/drivers/infiniband/core/nldev.c
> @@ -1508,32 +1508,35 @@ static int nldev_dellink(struct sk_buff *skb, struct nlmsghdr *nlh,
>  	return 0;
>  }
>
> -static int nldev_get_sys_get_dumpit(struct sk_buff *skb,
> -				    struct netlink_callback *cb)
> +static int nldev_sys_get_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
> +			      struct netlink_ext_ack *extack)
>  {
>  	struct nlattr *tb[RDMA_NLDEV_ATTR_MAX];
> -	struct nlmsghdr *nlh;
> +	struct sk_buff *msg;
>  	int err;
>
> -	err = nlmsg_parse(cb->nlh, 0, tb, RDMA_NLDEV_ATTR_MAX - 1,
> -			  nldev_policy, NULL);
> +	err = nlmsg_parse(nlh, 0, tb, RDMA_NLDEV_ATTR_MAX - 1,
> +			  nldev_policy, extack);
>  	if (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_NLDEV_CMD_SYS_GET),
>  			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);
>  	if (err) {
> -		nlmsg_cancel(skb, nlh);
> +		nlmsg_free(msg);
>  		return err;
>  	}
> -
> -	nlmsg_end(skb, nlh);
> -	return skb->len;
> +	nlmsg_end(msg, nlh);
> +	return rdma_nl_unicast(msg, NETLINK_CB(skb).portid);
>  }
>
>  static int nldev_set_sys_set_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
> @@ -1929,7 +1932,7 @@ static const struct rdma_nl_cbs nldev_cb_table[RDMA_NLDEV_NUM_OPS] = {
>  		.dump = nldev_res_get_pd_dumpit,
>  	},
>  	[RDMA_NLDEV_CMD_SYS_GET] = {
> -		.dump = nldev_get_sys_get_dumpit,
> +		.doit = nldev_sys_get_doit,
>  	},
>  	[RDMA_NLDEV_CMD_SYS_SET] = {
>  		.doit = nldev_set_sys_set_doit,
> diff --git a/include/uapi/rdma/rdma_netlink.h b/include/uapi/rdma/rdma_netlink.h
> index aaeeb0a8aec6..03694f4b5e18 100644
> --- a/include/uapi/rdma/rdma_netlink.h
> +++ b/include/uapi/rdma/rdma_netlink.h
> @@ -250,7 +250,7 @@ enum rdma_nldev_command {
>
>  	RDMA_NLDEV_CMD_PORT_GET, /* can dump */
>
> -	RDMA_NLDEV_CMD_SYS_GET, /* can dump */
> +	RDMA_NLDEV_CMD_SYS_GET,
>  	RDMA_NLDEV_CMD_SYS_SET,
>
>  	/* 8 is free to use */
> --
> 2.20.1
>




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux