public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Maor Gottlieb <maorg@nvidia.com>
To: David Ahern <dsahern@gmail.com>,
	Mark Zhang <markzhang@nvidia.com>, <jgg@nvidia.com>,
	<dledford@redhat.com>
Cc: <linux-rdma@vger.kernel.org>, <netdev@vger.kernel.org>,
	<aharonl@nvidia.com>, <netao@nvidia.com>, <leonro@nvidia.com>
Subject: Re: [PATCH iproute2-next v1 2/3] rdma: Add stat "mode" support
Date: Sat, 16 Oct 2021 10:14:23 +0300	[thread overview]
Message-ID: <500bd7ed-4d49-5426-321f-158b55b4138c@nvidia.com> (raw)
In-Reply-To: <a01a1b0e-90a4-c14f-fa5f-35a698d5b730@gmail.com>


On 10/16/2021 2:56 AM, David Ahern wrote:
> On 10/14/21 1:53 AM, Mark Zhang wrote:
>> +static int do_stat_mode_parse_cb(const struct nlmsghdr *nlh, void *data,
>> +				 bool supported)
>> +{
>> +	struct nlattr *tb[RDMA_NLDEV_ATTR_MAX] = {};
>> +	struct nlattr *nla_entry;
>> +	const char *dev, *name;
>> +	struct rd *rd = data;
>> +	int enabled, err = 0;
>> +	bool isfirst = true;
>> +	uint32_t port;
>> +
>> +	mnl_attr_parse(nlh, 0, rd_attr_cb, tb);
>> +	if (!tb[RDMA_NLDEV_ATTR_DEV_INDEX] || !tb[RDMA_NLDEV_ATTR_DEV_NAME] ||
>> +	    !tb[RDMA_NLDEV_ATTR_PORT_INDEX] ||
>> +	    !tb[RDMA_NLDEV_ATTR_STAT_HWCOUNTERS])
>> +		return MNL_CB_ERROR;
>> +
>> +	dev = mnl_attr_get_str(tb[RDMA_NLDEV_ATTR_DEV_NAME]);
>> +	port = mnl_attr_get_u32(tb[RDMA_NLDEV_ATTR_PORT_INDEX]);
>> +
>> +	mnl_attr_for_each_nested(nla_entry,
>> +				 tb[RDMA_NLDEV_ATTR_STAT_HWCOUNTERS]) {
>> +		struct nlattr *cnt[RDMA_NLDEV_ATTR_MAX] = {};
>> +
>> +		err  = mnl_attr_parse_nested(nla_entry, rd_attr_cb, cnt);
>> +		if ((err != MNL_CB_OK) ||
>> +		    (!cnt[RDMA_NLDEV_ATTR_STAT_HWCOUNTER_ENTRY_NAME]))
>> +			return -EINVAL;
>> +
>> +		if (!cnt[RDMA_NLDEV_ATTR_STAT_HWCOUNTER_DYNAMIC])
>> +			continue;
>> +
>> +		enabled = mnl_attr_get_u8(cnt[RDMA_NLDEV_ATTR_STAT_HWCOUNTER_DYNAMIC]);
>> +		name = mnl_attr_get_str(cnt[RDMA_NLDEV_ATTR_STAT_HWCOUNTER_ENTRY_NAME]);
>> +		if (supported || enabled) {
>> +			if (isfirst) {
>> +				open_json_object(NULL);
> I don't see the close_json_object(). Did you verify json output is proper?

I verified it, the json output is proper.
Anyway, close_json_object() is called in newline(), few lines below.
>
>
>> +				print_color_string(PRINT_ANY, COLOR_NONE,
>> +						   "ifname", "link %s/", dev);
>> +				print_color_uint(PRINT_ANY, COLOR_NONE, "port",
>> +						 "%u ", port);
>> +				if (supported)
>> +					open_json_array(PRINT_ANY,
>> +						"supported optional-counters");
>> +				else
>> +					open_json_array(PRINT_ANY,
>> +							"optional-counters");
>> +				print_color_string(PRINT_FP, COLOR_NONE, NULL,
>> +						   " ", NULL);
>> +				isfirst = false;
>> +			} else {
>> +				print_color_string(PRINT_FP, COLOR_NONE, NULL,
>> +						   ",", NULL);
>> +			}
>> +			if (rd->pretty_output && !rd->json_output)
>> +				newline_indent(rd);
>> +
>> +			print_color_string(PRINT_ANY, COLOR_NONE, NULL, "%s",
>> +					   name);
>> +		}
>> +	}
>> +
>> +	if (!isfirst) {
>> +		close_json_array(PRINT_JSON, NULL);
>> +		newline(rd);
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>

  reply	other threads:[~2021-10-16  7:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-14  7:53 [PATCH iproute2-next v1 0/3] Optional counter statistics support Mark Zhang
2021-10-14  7:53 ` [PATCH iproute2-next v1 1/3] rdma: Update uapi headers Mark Zhang
2021-10-14  7:53 ` [PATCH iproute2-next v1 2/3] rdma: Add stat "mode" support Mark Zhang
2021-10-15 23:56   ` David Ahern
2021-10-16  7:14     ` Maor Gottlieb [this message]
2021-10-14  7:53 ` [PATCH iproute2-next v1 3/3] rdma: Add optional-counters set/unset support Mark Zhang
2021-10-15  2:28 ` [PATCH iproute2-next v1 0/3] Optional counter statistics support David Ahern
2021-10-15  2:48   ` Mark Zhang
2021-10-16 18:53 ` David Ahern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=500bd7ed-4d49-5426-321f-158b55b4138c@nvidia.com \
    --to=maorg@nvidia.com \
    --cc=aharonl@nvidia.com \
    --cc=dledford@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=jgg@nvidia.com \
    --cc=leonro@nvidia.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=markzhang@nvidia.com \
    --cc=netao@nvidia.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox