Subject: Re: [PATCH rdma-next v1 06/11] RDMA/nldev: Add support to get status of all counters

From: Jason Gunthorpe <[email-masked]>
Date: Mon, 27 Sep 2021 14:30:01 -0300

On Wed, Sep 15, 2021 at 02:07:25AM +0300, Leon Romanovsky wrote:
> +static int stat_get_doit_default_counter(struct sk_buff *skb,
> +					 struct nlmsghdr *nlh,
> +					 struct netlink_ext_ack *extack,
> +					 struct nlattr *tb[])
> +{
> +	struct rdma_hw_stats *stats;
> +	struct ib_device *device;
> +	u32 index, port;
> +	int ret;
> +
> +	if (!tb[RDMA_NLDEV_ATTR_DEV_INDEX] || !tb[RDMA_NLDEV_ATTR_PORT_INDEX])
> +		return -EINVAL;
> +
> +	index = nla_get_u32(tb[RDMA_NLDEV_ATTR_DEV_INDEX]);
> +	device = ib_device_get_by_index(sock_net(skb->sk), index);
> +	if (!device)
> +		return -EINVAL;
> +
> +	port = nla_get_u32(tb[RDMA_NLDEV_ATTR_PORT_INDEX]);
> +	if (!rdma_is_port_valid(device, port)) {
> +		ret = -EINVAL;
> +		goto end;
> +	}
> +
> +	stats = ib_get_hw_stats_port(device, port);
> +	if (!stats) {
> +		ret = -EINVAL;
> +		goto end;
> +	}
> +
> +	if (tb[RDMA_NLDEV_ATTR_STAT_HWCOUNTER_DYNAMIC])
> +		ret = stat_get_doit_stats_list(skb, nlh, extack, tb,
> +					       device, port, stats);
> +	else
> +		ret = stat_get_doit_stats_values(skb, nlh, extack, tb, device,
> +						 port, stats);

This seems strange, why is the output of a get contingent on a ignored
input attribute? Shouldn't the HWCOUNTER_DYNAMIC just always be
emitted?

Jason