Subject: Re: [PATCH net-next 2/3] net: dsa: mv88e6xxx: replace ATU violation prints with trace points

From: Saeed Mahameed <[email-masked]>
Date: Wed, 7 Dec 2022 16:14:16 -0800

On 08 Dec 01:39, Vladimir Oltean wrote:
>In applications where the switch ports must perform 802.1X based
>authentication and are therefore locked, ATU violation interrupts are
>quite to be expected as part of normal operation. The problem is that
>they currently spam the kernel log, even if rate limited.
>

+1 

>Create a series of trace points, all derived from the same event class,
>which log these violations to the kernel's trace buffer, which is both
>much faster and much easier to ignore than printing to a serial console.
>
>I've deliberately stopped reporting the portvec, since in my experience
>it contains redundant information with the spid (port) field: portvec ==
>1 << spid.
>
>New usage model:
>
>$ trace-cmd list | grep mv88e6xxx
>mv88e6xxx
>mv88e6xxx:mv88e6xxx_atu_full_violation
>mv88e6xxx:mv88e6xxx_atu_miss_violation
>mv88e6xxx:mv88e6xxx_atu_member_violation
>mv88e6xxx:mv88e6xxx_atu_age_out_violation
>$ trace-cmd record -e mv88e6xxx sleep 10
>
>Signed-off-by: Vladimir Oltean <[email-masked]>
>---
> drivers/net/dsa/mv88e6xxx/Makefile      |  4 ++
> drivers/net/dsa/mv88e6xxx/global1_atu.c | 21 ++++----
> drivers/net/dsa/mv88e6xxx/trace.c       |  6 +++
> drivers/net/dsa/mv88e6xxx/trace.h       | 68 +++++++++++++++++++++++++
> 4 files changed, 87 insertions(+), 12 deletions(-)
> create mode 100644 drivers/net/dsa/mv88e6xxx/trace.c
> create mode 100644 drivers/net/dsa/mv88e6xxx/trace.h
>
>diff --git a/drivers/net/dsa/mv88e6xxx/Makefile b/drivers/net/dsa/mv88e6xxx/Makefile
>index c8eca2b6f959..49bf358b9c4f 100644
>--- a/drivers/net/dsa/mv88e6xxx/Makefile
>+++ b/drivers/net/dsa/mv88e6xxx/Makefile
>@@ -15,3 +15,7 @@ mv88e6xxx-objs += port_hidden.o
> mv88e6xxx-$(CONFIG_NET_DSA_MV88E6XXX_PTP) += ptp.o
> mv88e6xxx-objs += serdes.o
> mv88e6xxx-objs += smi.o
>+mv88e6xxx-objs += trace.o
>+
>+# for tracing framework to find trace.h
>+CFLAGS_trace.o := -I$(src)
>diff --git a/drivers/net/dsa/mv88e6xxx/global1_atu.c b/drivers/net/dsa/mv88e6xxx/global1_atu.c
>index a9e2ff7d0e52..6ba65b723b42 100644
>--- a/drivers/net/dsa/mv88e6xxx/global1_atu.c
>+++ b/drivers/net/dsa/mv88e6xxx/global1_atu.c
>@@ -12,6 +12,7 @@
>
> #include "chip.h"
> #include "global1.h"
>+#include "trace.h"
>
> /* Offset 0x01: ATU FID Register */
>
>@@ -429,29 +430,25 @@ static irqreturn_t mv88e6xxx_g1_atu_prob_irq_thread_fn(int irq, void *dev_id)
> 	spid = entry.state;
>
> 	if (val & MV88E6XXX_G1_ATU_OP_AGE_OUT_VIOLATION) {
>-		dev_err_ratelimited(chip->dev,
>-				    "ATU age out violation for %pM fid %u\n",
>-				    entry.mac, fid);
>+		trace_mv88e6xxx_atu_age_out_violation(chip->dev, spid,
>+						      entry.mac, fid);

no stats here? tracepoints are disabled by default and this event will go
unnoticed, users usually monitor light weight indicators such as stats, then
turn on tracepoints to see what's actually happening.. 

> 	}