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.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
stdio.hstdlib.hstring.herrno.hnet/if.hmath.hynl.hnetdev-user.hmain.h
Detected Declarations
struct queue_balancefunction print_json_qstatsfunction ynl_dump_foreachfunction print_onefunction print_plain_qstatsfunction qstats_dumpfunction do_showfunction compute_statsfunction print_balance_statsfunction print_balance_stats_jsonfunction cmp_ifindex_typefunction do_balancefunction do_hw_grofunction ynl_dump_foreachfunction do_helpfunction do_qstats
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
- Immediate include surface: `stdio.h`, `stdlib.h`, `string.h`, `errno.h`, `net/if.h`, `math.h`, `ynl.h`, `netdev-user.h`.
- Detected declarations: `struct queue_balance`, `function print_json_qstats`, `function ynl_dump_foreach`, `function print_one`, `function print_plain_qstats`, `function qstats_dump`, `function do_show`, `function compute_stats`, `function print_balance_stats`, `function print_balance_stats_json`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.