[PATCH net-next v4 4/4] net: bonding: add tracepoint for 802.3ad

Tonghao Zhang
2025-05-14T09:27:01Z

Users can monitor NIC link status changes through netlink. However, LACP
protocol failures may occur despite operational physical links. There is
no way to detect LACP state changes. This patch adds tracepoint at LACP state
transition.

Cc: Jay Vosburgh <jv@jvosburgh.net>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>
Signed-off-by: Tonghao Zhang <tonghao@bamaicloud.com>
Signed-off-by: Zengbing Tu <tuzengbing@didiglobal.com>
---
drivers/net/bonding/bond_3ad.c | 6 ++++++
include/trace/events/bonding.h | 37 ++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+)
create mode 100644 include/trace/events/bonding.h

diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index d1c2d416ac87..55703230ab29 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -16,6 +16,9 @@
#include <net/bond_3ad.h>
#include <net/netlink.h>

+#define CREATE_TRACE_POINTS
+#include <trace/events/bonding.h>
+
/* General definitions */
#define AD_SHORT_TIMEOUT 1
#define AD_LONG_TIMEOUT 0
@@ -1146,6 +1149,9 @@ static void ad_mux_machine(struct port *port, bool *update_slave_arr)
port->actor_port_number,
last_state,
port->sm_mux_state);
+
+ trace_3ad_mux_state(port->slave->dev, last_state, port->sm_mux_state);
+
switch (port->sm_mux_state) {
case AD_MUX_DETACHED:
port->actor_oper_port_state &= ~LACP_STATE_SYNCHRONIZATION;
diff --git a/include/trace/events/bonding.h b/include/trace/events/bonding.h
new file mode 100644
index 000000000000..1ee4b07d912a
--- /dev/null
+++ b/include/trace/events/bonding.h
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#if !defined(_TRACE_BONDING_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_BONDING_H
+
+#include <linux/netdevice.h>
+#include <linux/tracepoint.h>
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM bonding
+
+TRACE_EVENT(3ad_mux_state,
+ TP_PROTO(struct net_device *dev, u32 last_state, u32 curr_state),
+ TP_ARGS(dev, last_state, curr_state),
+
+ TP_STRUCT__entry(
+ __field(int, ifindex)
+ __string(dev_name, dev->name)
+ __field(u32, last_state)
+ __field(u32, curr_state)
+ ),
+
+ TP_fast_assign(
+ __entry->ifindex = dev->ifindex;
+ __assign_str(dev_name);
+ __entry->last_state = last_state;
+ __entry->curr_state = curr_state;
+ ),
+
+ TP_printk("ifindex %d dev %s last_state 0x%x curr_state 0x%x",
+ __entry->ifindex, __get_str(dev_name),
+ __entry->last_state, __entry->curr_state)
+);
+
+#endif /* _TRACE_BONDING_H */
+
+#include <trace/define_trace.h>
--
2.34.1