Skip to content

Commit 8646384

Browse files
vladimirolteankuba-moo
authored andcommitted
net: dsa: mv88e6xxx: replace ATU violation prints with trace points
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. 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. New usage model: $ trace-cmd list | grep mv88e6xxx mv88e6xxx mv88e6xxx:mv88e6xxx_atu_full_violation mv88e6xxx:mv88e6xxx_atu_miss_violation mv88e6xxx:mv88e6xxx_atu_member_violation $ trace-cmd record -e mv88e6xxx sleep 10 Signed-off-by: Vladimir Oltean <[email protected]> Reviewed-by: Saeed Mahameed <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 4bf24ad commit 8646384

File tree

4 files changed

+86
-9
lines changed

4 files changed

+86
-9
lines changed

drivers/net/dsa/mv88e6xxx/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ mv88e6xxx-objs += port_hidden.o
1515
mv88e6xxx-$(CONFIG_NET_DSA_MV88E6XXX_PTP) += ptp.o
1616
mv88e6xxx-objs += serdes.o
1717
mv88e6xxx-objs += smi.o
18+
mv88e6xxx-objs += trace.o
19+
20+
# for tracing framework to find trace.h
21+
CFLAGS_trace.o := -I$(src)

drivers/net/dsa/mv88e6xxx/global1_atu.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "chip.h"
1414
#include "global1.h"
15+
#include "trace.h"
1516

1617
/* Offset 0x01: ATU FID Register */
1718

@@ -429,23 +430,23 @@ static irqreturn_t mv88e6xxx_g1_atu_prob_irq_thread_fn(int irq, void *dev_id)
429430
spid = entry.state;
430431

431432
if (val & MV88E6XXX_G1_ATU_OP_MEMBER_VIOLATION) {
432-
dev_err_ratelimited(chip->dev,
433-
"ATU member violation for %pM fid %u portvec %x spid %d\n",
434-
entry.mac, fid, entry.portvec, spid);
433+
trace_mv88e6xxx_atu_member_violation(chip->dev, spid,
434+
entry.portvec, entry.mac,
435+
fid);
435436
chip->ports[spid].atu_member_violation++;
436437
}
437438

438439
if (val & MV88E6XXX_G1_ATU_OP_MISS_VIOLATION) {
439-
dev_err_ratelimited(chip->dev,
440-
"ATU miss violation for %pM fid %u portvec %x spid %d\n",
441-
entry.mac, fid, entry.portvec, spid);
440+
trace_mv88e6xxx_atu_miss_violation(chip->dev, spid,
441+
entry.portvec, entry.mac,
442+
fid);
442443
chip->ports[spid].atu_miss_violation++;
443444
}
444445

445446
if (val & MV88E6XXX_G1_ATU_OP_FULL_VIOLATION) {
446-
dev_err_ratelimited(chip->dev,
447-
"ATU full violation for %pM fid %u portvec %x spid %d\n",
448-
entry.mac, fid, entry.portvec, spid);
447+
trace_mv88e6xxx_atu_full_violation(chip->dev, spid,
448+
entry.portvec, entry.mac,
449+
fid);
449450
chip->ports[spid].atu_full_violation++;
450451
}
451452
mv88e6xxx_reg_unlock(chip);

drivers/net/dsa/mv88e6xxx/trace.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
/* Copyright 2022 NXP
3+
*/
4+
5+
#define CREATE_TRACE_POINTS
6+
#include "trace.h"

drivers/net/dsa/mv88e6xxx/trace.h

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/* SPDX-License-Identifier: GPL-2.0-or-later */
2+
/* Copyright 2022 NXP
3+
*/
4+
5+
#undef TRACE_SYSTEM
6+
#define TRACE_SYSTEM mv88e6xxx
7+
8+
#if !defined(_MV88E6XXX_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
9+
#define _MV88E6XXX_TRACE_H
10+
11+
#include <linux/device.h>
12+
#include <linux/if_ether.h>
13+
#include <linux/tracepoint.h>
14+
15+
DECLARE_EVENT_CLASS(mv88e6xxx_atu_violation,
16+
17+
TP_PROTO(const struct device *dev, int spid, u16 portvec,
18+
const unsigned char *addr, u16 fid),
19+
20+
TP_ARGS(dev, spid, portvec, addr, fid),
21+
22+
TP_STRUCT__entry(
23+
__string(name, dev_name(dev))
24+
__field(int, spid)
25+
__field(u16, portvec)
26+
__array(unsigned char, addr, ETH_ALEN)
27+
__field(u16, fid)
28+
),
29+
30+
TP_fast_assign(
31+
__assign_str(name, dev_name(dev));
32+
__entry->spid = spid;
33+
__entry->portvec = portvec;
34+
memcpy(__entry->addr, addr, ETH_ALEN);
35+
__entry->fid = fid;
36+
),
37+
38+
TP_printk("dev %s spid %d portvec 0x%x addr %pM fid %u",
39+
__get_str(name), __entry->spid, __entry->portvec,
40+
__entry->addr, __entry->fid)
41+
);
42+
43+
DEFINE_EVENT(mv88e6xxx_atu_violation, mv88e6xxx_atu_member_violation,
44+
TP_PROTO(const struct device *dev, int spid, u16 portvec,
45+
const unsigned char *addr, u16 fid),
46+
TP_ARGS(dev, spid, portvec, addr, fid));
47+
48+
DEFINE_EVENT(mv88e6xxx_atu_violation, mv88e6xxx_atu_miss_violation,
49+
TP_PROTO(const struct device *dev, int spid, u16 portvec,
50+
const unsigned char *addr, u16 fid),
51+
TP_ARGS(dev, spid, portvec, addr, fid));
52+
53+
DEFINE_EVENT(mv88e6xxx_atu_violation, mv88e6xxx_atu_full_violation,
54+
TP_PROTO(const struct device *dev, int spid, u16 portvec,
55+
const unsigned char *addr, u16 fid),
56+
TP_ARGS(dev, spid, portvec, addr, fid));
57+
58+
#endif /* _MV88E6XXX_TRACE_H */
59+
60+
/* We don't want to use include/trace/events */
61+
#undef TRACE_INCLUDE_PATH
62+
#define TRACE_INCLUDE_PATH .
63+
#undef TRACE_INCLUDE_FILE
64+
#define TRACE_INCLUDE_FILE trace
65+
/* This part must be outside protection */
66+
#include <trace/define_trace.h>

0 commit comments

Comments
 (0)