tools/net/ynl/ynltool/qstats.c

Source file repositories/reference/linux-study-clean/tools/net/ynl/ynltool/qstats.c

File Facts

System
Linux kernel
Corpus path
tools/net/ynl/ynltool/qstats.c
Extension
.c
Size
18892 bytes
Lines
675
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

struct queue_balance {
	unsigned int ifindex;
	enum netdev_queue_type type;
	unsigned int queue_count;
	__u64 *rx_packets;
	__u64 *rx_bytes;
	__u64 *tx_packets;
	__u64 *tx_bytes;
};

static void print_json_qstats(struct netdev_qstats_get_list *qstats)
{
	jsonw_start_array(json_wtr);

	ynl_dump_foreach(qstats, qs) {
		char ifname[IF_NAMESIZE];
		const char *name;

		jsonw_start_object(json_wtr);

		name = if_indextoname(qs->ifindex, ifname);
		if (name)
			jsonw_string_field(json_wtr, "ifname", name);
		jsonw_uint_field(json_wtr, "ifindex", qs->ifindex);

		if (qs->_present.queue_type)
			jsonw_string_field(json_wtr, "queue-type",
					   netdev_queue_type_str(qs->queue_type));
		if (qs->_present.queue_id)
			jsonw_uint_field(json_wtr, "queue-id", qs->queue_id);

		if (qs->_present.rx_packets || qs->_present.rx_bytes ||
		    qs->_present.rx_alloc_fail || qs->_present.rx_hw_drops ||
		    qs->_present.rx_csum_complete || qs->_present.rx_hw_gro_packets) {
			jsonw_name(json_wtr, "rx");
			jsonw_start_object(json_wtr);
			if (qs->_present.rx_packets)
				jsonw_uint_field(json_wtr, "packets", qs->rx_packets);
			if (qs->_present.rx_bytes)
				jsonw_uint_field(json_wtr, "bytes", qs->rx_bytes);
			if (qs->_present.rx_alloc_fail)
				jsonw_uint_field(json_wtr, "alloc-fail", qs->rx_alloc_fail);
			if (qs->_present.rx_hw_drops)
				jsonw_uint_field(json_wtr, "hw-drops", qs->rx_hw_drops);
			if (qs->_present.rx_hw_drop_overruns)
				jsonw_uint_field(json_wtr, "hw-drop-overruns", qs->rx_hw_drop_overruns);
			if (qs->_present.rx_hw_drop_ratelimits)
				jsonw_uint_field(json_wtr, "hw-drop-ratelimits", qs->rx_hw_drop_ratelimits);
			if (qs->_present.rx_csum_complete)
				jsonw_uint_field(json_wtr, "csum-complete", qs->rx_csum_complete);
			if (qs->_present.rx_csum_unnecessary)
				jsonw_uint_field(json_wtr, "csum-unnecessary", qs->rx_csum_unnecessary);
			if (qs->_present.rx_csum_none)
				jsonw_uint_field(json_wtr, "csum-none", qs->rx_csum_none);
			if (qs->_present.rx_csum_bad)
				jsonw_uint_field(json_wtr, "csum-bad", qs->rx_csum_bad);
			if (qs->_present.rx_hw_gro_packets)
				jsonw_uint_field(json_wtr, "hw-gro-packets", qs->rx_hw_gro_packets);
			if (qs->_present.rx_hw_gro_bytes)
				jsonw_uint_field(json_wtr, "hw-gro-bytes", qs->rx_hw_gro_bytes);
			if (qs->_present.rx_hw_gro_wire_packets)
				jsonw_uint_field(json_wtr, "hw-gro-wire-packets", qs->rx_hw_gro_wire_packets);
			if (qs->_present.rx_hw_gro_wire_bytes)
				jsonw_uint_field(json_wtr, "hw-gro-wire-bytes", qs->rx_hw_gro_wire_bytes);
			jsonw_end_object(json_wtr);
		}

		if (qs->_present.tx_packets || qs->_present.tx_bytes ||
		    qs->_present.tx_hw_drops || qs->_present.tx_csum_none ||
		    qs->_present.tx_hw_gso_packets) {
			jsonw_name(json_wtr, "tx");
			jsonw_start_object(json_wtr);
			if (qs->_present.tx_packets)
				jsonw_uint_field(json_wtr, "packets", qs->tx_packets);
			if (qs->_present.tx_bytes)
				jsonw_uint_field(json_wtr, "bytes", qs->tx_bytes);
			if (qs->_present.tx_hw_drops)
				jsonw_uint_field(json_wtr, "hw-drops", qs->tx_hw_drops);
			if (qs->_present.tx_hw_drop_errors)
				jsonw_uint_field(json_wtr, "hw-drop-errors", qs->tx_hw_drop_errors);
			if (qs->_present.tx_hw_drop_ratelimits)
				jsonw_uint_field(json_wtr, "hw-drop-ratelimits", qs->tx_hw_drop_ratelimits);
			if (qs->_present.tx_csum_none)
				jsonw_uint_field(json_wtr, "csum-none", qs->tx_csum_none);
			if (qs->_present.tx_needs_csum)
				jsonw_uint_field(json_wtr, "needs-csum", qs->tx_needs_csum);
			if (qs->_present.tx_hw_gso_packets)
				jsonw_uint_field(json_wtr, "hw-gso-packets", qs->tx_hw_gso_packets);
			if (qs->_present.tx_hw_gso_bytes)
				jsonw_uint_field(json_wtr, "hw-gso-bytes", qs->tx_hw_gso_bytes);

Annotation

Implementation Notes