All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2-next] ss: add support for xdp statistics
@ 2020-09-24  7:03 Ciara Loftus
  2020-09-29 15:33 ` David Ahern
  0 siblings, 1 reply; 2+ messages in thread
From: Ciara Loftus @ 2020-09-24  7:03 UTC (permalink / raw)
  To: netdev; +Cc: bjorn.topel, Ciara Loftus

The patch exposes statistics for XDP sockets which can be useful for
debugging purposes.

The stats exposed are:
    rx dropped
    rx invalid
    rx queue full
    rx fill ring empty
    tx invalid
    tx ring empty

Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
---
 misc/ss.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/misc/ss.c b/misc/ss.c
index 458e381f..77e1847e 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -4536,6 +4536,21 @@ static void xdp_show_umem(struct xdp_diag_umem *umem, struct xdp_diag_ring *fr,
 		xdp_show_ring("cr", cr);
 }
 
+static void xdp_show_stats(struct xdp_diag_stats *stats)
+{
+	if (oneline)
+		out(" stats(");
+	else
+		out("\n\tstats(");
+	out("rx dropped:%llu", stats->n_rx_dropped);
+	out(",rx invalid:%llu", stats->n_rx_invalid);
+	out(",rx queue full:%llu", stats->n_rx_full);
+	out(",rx fill ring empty:%llu", stats->n_fill_ring_empty);
+	out(",tx invalid:%llu", stats->n_tx_invalid);
+	out(",tx ring empty:%llu", stats->n_tx_ring_empty);
+	out(")");
+}
+
 static int xdp_show_sock(struct nlmsghdr *nlh, void *arg)
 {
 	struct xdp_diag_ring *rx = NULL, *tx = NULL, *fr = NULL, *cr = NULL;
@@ -4543,6 +4558,7 @@ static int xdp_show_sock(struct nlmsghdr *nlh, void *arg)
 	struct rtattr *tb[XDP_DIAG_MAX + 1];
 	struct xdp_diag_info *info = NULL;
 	struct xdp_diag_umem *umem = NULL;
+	struct xdp_diag_stats *stats = NULL;
 	const struct filter *f = arg;
 	struct sockstat stat = {};
 
@@ -4577,6 +4593,8 @@ static int xdp_show_sock(struct nlmsghdr *nlh, void *arg)
 
 		stat.rq = skmeminfo[SK_MEMINFO_RMEM_ALLOC];
 	}
+	if (tb[XDP_DIAG_STATS])
+		stats = RTA_DATA(tb[XDP_DIAG_STATS]);
 
 	if (xdp_stats_print(&stat, f))
 		return 0;
@@ -4588,6 +4606,8 @@ static int xdp_show_sock(struct nlmsghdr *nlh, void *arg)
 			xdp_show_ring("tx", tx);
 		if (umem)
 			xdp_show_umem(umem, fr, cr);
+		if (stats)
+			xdp_show_stats(stats);
 	}
 
 	if (show_mem)
@@ -4606,7 +4626,7 @@ static int xdp_show(struct filter *f)
 
 	req.r.sdiag_family = AF_XDP;
 	req.r.xdiag_show = XDP_SHOW_INFO | XDP_SHOW_RING_CFG | XDP_SHOW_UMEM |
-			   XDP_SHOW_MEMINFO;
+			   XDP_SHOW_MEMINFO | XDP_SHOW_STATS;
 
 	return handle_netlink_request(f, &req.nlh, sizeof(req), xdp_show_sock);
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH iproute2-next] ss: add support for xdp statistics
  2020-09-24  7:03 [PATCH iproute2-next] ss: add support for xdp statistics Ciara Loftus
@ 2020-09-29 15:33 ` David Ahern
  0 siblings, 0 replies; 2+ messages in thread
From: David Ahern @ 2020-09-29 15:33 UTC (permalink / raw)
  To: Ciara Loftus, netdev; +Cc: bjorn.topel

On 9/24/20 12:03 AM, Ciara Loftus wrote:
> The patch exposes statistics for XDP sockets which can be useful for
> debugging purposes.
> 
> The stats exposed are:
>     rx dropped
>     rx invalid
>     rx queue full
>     rx fill ring empty
>     tx invalid
>     tx ring empty
> 
> Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
> ---
>  misc/ss.c | 22 +++++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
> 

applied to iproute2-next. Thanks,


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-29 15:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-24  7:03 [PATCH iproute2-next] ss: add support for xdp statistics Ciara Loftus
2020-09-29 15:33 ` David Ahern

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.