* [PATCH ethtool-next] channels: support json output
@ 2025-04-29 15:03 Jakub Kicinski
2025-04-29 20:30 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Kicinski @ 2025-04-29 15:03 UTC (permalink / raw)
To: mkubecek; +Cc: netdev, Jakub Kicinski
Make -l | --show-channels support JSON output format.
# ./ethtool -j -l '*' | jq
[
{
"ifname": "eth0",
"rx-max": 32,
"tx-max": 32,
"combined-max": 32,
"rx": 0,
"tx": 0,
"combined": 20
},
{
"ifname": "veth0",
"rx-max": 80,
"tx-max": 80,
"rx": 1,
"tx": 1
},
{
"ifname": "veth1",
"rx-max": 80,
"tx-max": 80,
"rx": 1,
"tx": 1
}
]
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
ethtool.c | 1 +
netlink/channels.c | 18 +++++++++++++-----
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/ethtool.c b/ethtool.c
index 9c8a5428affd..1485b0253253 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -6046,6 +6046,7 @@ static const struct option args[] = {
},
{
.opts = "-l|--show-channels",
+ .json = true,
.func = do_gchannels,
.nlfunc = nl_gchannels,
.help = "Query Channels"
diff --git a/netlink/channels.c b/netlink/channels.c
index 5cae227106d6..b8213d7e3172 100644
--- a/netlink/channels.c
+++ b/netlink/channels.c
@@ -33,22 +33,27 @@ int channels_reply_cb(const struct nlmsghdr *nlhdr, void *data)
if (!dev_ok(nlctx))
return err_ret;
+ open_json_object(NULL);
+
if (silent)
- putchar('\n');
- printf("Channel parameters for %s:\n", nlctx->devname);
- printf("Pre-set maximums:\n");
+ show_cr();
+ print_string(PRINT_ANY, "ifname", "Channel parameters for %s:\n",
+ nlctx->devname);
+ print_string(PRINT_FP, NULL, "Pre-set maximums:\n", NULL);
show_u32("rx-max", "RX:\t\t", tb[ETHTOOL_A_CHANNELS_RX_MAX]);
show_u32("tx-max", "TX:\t\t", tb[ETHTOOL_A_CHANNELS_TX_MAX]);
show_u32("other-max", "Other:\t\t", tb[ETHTOOL_A_CHANNELS_OTHER_MAX]);
show_u32("combined-max", "Combined:\t",
tb[ETHTOOL_A_CHANNELS_COMBINED_MAX]);
- printf("Current hardware settings:\n");
+ print_string(PRINT_FP, NULL, "Current hardware settings:\n", NULL);
show_u32("rx", "RX:\t\t", tb[ETHTOOL_A_CHANNELS_RX_COUNT]);
show_u32("tx", "TX:\t\t", tb[ETHTOOL_A_CHANNELS_TX_COUNT]);
show_u32("other", "Other:\t\t", tb[ETHTOOL_A_CHANNELS_OTHER_COUNT]);
show_u32("combined", "Combined:\t",
tb[ETHTOOL_A_CHANNELS_COMBINED_COUNT]);
+ close_json_object();
+
return MNL_CB_OK;
}
@@ -70,7 +75,10 @@ int nl_gchannels(struct cmd_context *ctx)
ETHTOOL_A_CHANNELS_HEADER, 0);
if (ret < 0)
return ret;
- return nlsock_send_get_request(nlsk, channels_reply_cb);
+ new_json_obj(ctx->json);
+ ret = nlsock_send_get_request(nlsk, channels_reply_cb);
+ delete_json_obj();
+ return ret;
}
/* CHANNELS_SET */
--
2.49.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH ethtool-next] channels: support json output
2025-04-29 15:03 [PATCH ethtool-next] channels: support json output Jakub Kicinski
@ 2025-04-29 20:30 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-04-29 20:30 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: mkubecek, netdev
Hello:
This patch was applied to ethtool/ethtool.git (master)
by Michal Kubecek <mkubecek@suse.cz>:
On Tue, 29 Apr 2025 08:03:32 -0700 you wrote:
> Make -l | --show-channels support JSON output format.
>
> # ./ethtool -j -l '*' | jq
> [
> {
> "ifname": "eth0",
> "rx-max": 32,
> "tx-max": 32,
> "combined-max": 32,
> "rx": 0,
> "tx": 0,
> "combined": 20
> },
> {
> "ifname": "veth0",
> "rx-max": 80,
> "tx-max": 80,
> "rx": 1,
> "tx": 1
> },
> {
> "ifname": "veth1",
> "rx-max": 80,
> "tx-max": 80,
> "rx": 1,
> "tx": 1
> }
> ]
>
> [...]
Here is the summary with links:
- [ethtool-next] channels: support json output
https://git.kernel.org/pub/scm/network/ethtool/ethtool.git/commit/?id=64226907d0d6
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-04-29 20:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-29 15:03 [PATCH ethtool-next] channels: support json output Jakub Kicinski
2025-04-29 20:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).