Traces are added to flow parsing to ease debugging. Signed-off-by: Ratheesh Kannoth --- .../ethernet/marvell/octeontx2/nic/Makefile | 2 +- .../marvell/octeontx2/nic/switch/sw_fl.c | 18 +++- .../marvell/octeontx2/nic/switch/sw_trace.c | 11 +++ .../marvell/octeontx2/nic/switch/sw_trace.h | 82 +++++++++++++++++++ 4 files changed, 109 insertions(+), 4 deletions(-) create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_trace.c create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_trace.h diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/Makefile b/drivers/net/ethernet/marvell/octeontx2/nic/Makefile index da87e952c187..5f722d0cfac2 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/Makefile +++ b/drivers/net/ethernet/marvell/octeontx2/nic/Makefile @@ -13,7 +13,7 @@ rvu_nicpf-y := otx2_pf.o otx2_common.o otx2_txrx.o otx2_ethtool.o \ switch/sw_fdb.o switch/sw_fl.o ifdef CONFIG_OCTEONTX_SWITCH -rvu_nicpf-y += switch/sw_nb.o switch/sw_fib.o +rvu_nicpf-y += switch/sw_nb.o switch/sw_fib.o switch/sw_trace.o endif rvu_nicvf-y := otx2_vf.o diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fl.c b/drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fl.c index c9aa0043cc4c..3ddae5d08578 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fl.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fl.c @@ -18,6 +18,7 @@ #include "../otx2_struct.h" #include "../cn10k.h" #include "sw_nb.h" +#include "sw_trace.h" #include "sw_fl.h" #if !IS_ENABLED(CONFIG_OCTEONTX_SWITCH) @@ -140,6 +141,7 @@ static int sw_fl_parse_actions(struct otx2_nic *nic, switch (act->id) { case FLOW_ACTION_REDIRECT: + trace_sw_act_dump(__func__, __LINE__, act->id); tuple->in_pf = nic->pcifunc; out_nic = netdev_priv(act->dev); tuple->xmit_pf = out_nic->pcifunc; @@ -147,6 +149,7 @@ static int sw_fl_parse_actions(struct otx2_nic *nic, break; case FLOW_ACTION_CT: + trace_sw_act_dump(__func__, __LINE__, act->id); err = nf_flow_table_offload_add_cb(act->ct.flow_table, sw_fl_setup_ft_block_ingress_cb, nic); @@ -161,6 +164,7 @@ static int sw_fl_parse_actions(struct otx2_nic *nic, break; case FLOW_ACTION_MANGLE: + trace_sw_act_dump(__func__, __LINE__, act->id); tuple->mangle[used].type = act->mangle.htype; tuple->mangle[used].val = act->mangle.val; tuple->mangle[used].mask = act->mangle.mask; @@ -170,6 +174,7 @@ static int sw_fl_parse_actions(struct otx2_nic *nic, break; default: + trace_sw_act_dump(__func__, __LINE__, act->id); break; } } @@ -445,21 +450,28 @@ static int sw_fl_add(struct otx2_nic *nic, struct flow_cls_offload *f) return 0; rc = sw_fl_parse_flow(nic, f, &tuple, &features); - if (rc) + if (rc) { + trace_sw_fl_dump(__func__, __LINE__, &tuple); return -EFAULT; + } if (!netif_is_ovs_port(nic->netdev)) { rc = sw_fl_get_pcifunc(nic, tuple.ip4src, &tuple.in_pf, &tuple, true); - if (rc) + if (rc) { + trace_sw_fl_dump(__func__, __LINE__, &tuple); return rc; + } rc = sw_fl_get_pcifunc(nic, tuple.ip4dst, &tuple.xmit_pf, &tuple, false); - if (rc) + if (rc) { + trace_sw_fl_dump(__func__, __LINE__, &tuple); return rc; + } } + trace_sw_fl_dump(__func__, __LINE__, &tuple); sw_fl_add_to_list(nic, &tuple, f->cookie, true); return 0; } diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_trace.c b/drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_trace.c new file mode 100644 index 000000000000..260fd2bb3606 --- /dev/null +++ b/drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_trace.c @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Marvell RVU Admin Function driver + * + * Copyright (C) 2026 Marvell. + * + */ + +#define CREATE_TRACE_POINTS +#include "sw_trace.h" +EXPORT_TRACEPOINT_SYMBOL(sw_fl_dump); +EXPORT_TRACEPOINT_SYMBOL(sw_act_dump); diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_trace.h b/drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_trace.h new file mode 100644 index 000000000000..e23deca0309a --- /dev/null +++ b/drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_trace.h @@ -0,0 +1,82 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Marvell RVU Admin Function driver + * + * Copyright (C) 2026 Marvell. + * + */ + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM rvu + +#if !defined(SW_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) +#define SW_TRACE_H + +#include +#include + +#include "mbox.h" + +TRACE_EVENT(sw_fl_dump, + TP_PROTO(const char *fname, int line, struct fl_tuple *ftuple), + TP_ARGS(fname, line, ftuple), + TP_STRUCT__entry(__string(f, fname) + __field(int, l) + __array(u8, smac, ETH_ALEN) + __array(u8, dmac, ETH_ALEN) + __field(u16, eth_type) + __field(u32, sip) + __field(u32, dip) + __field(u8, ip_proto) + __field(u16, sport) + __field(u16, dport) + __field(u8, uni_di) + __field(u16, in_pf) + __field(u16, out_pf) + ), + TP_fast_assign(__assign_str(f); + __entry->l = line; + memcpy(__entry->smac, ftuple->smac, ETH_ALEN); + memcpy(__entry->dmac, ftuple->dmac, ETH_ALEN); + __entry->sip = (__force u32)(ftuple->ip4src); + __entry->dip = (__force u32)(ftuple->ip4dst); + __entry->eth_type = (__force u16)ftuple->eth_type; + __entry->ip_proto = ftuple->proto; + __entry->sport = (__force u16)(ftuple->sport); + __entry->dport = (__force u16)(ftuple->dport); + __entry->uni_di = ftuple->uni_di; + __entry->in_pf = ftuple->in_pf; + __entry->out_pf = ftuple->xmit_pf; + ), + TP_printk("[%s:%d] %pM %pI4:%u to %pM %pI4:%u eth_type=%#x proto=%u uni=%u in=%#x out=%#x", + __get_str(f), __entry->l, __entry->smac, &__entry->sip, __entry->sport, + __entry->dmac, &__entry->dip, __entry->dport, + ntohs((__force __be16)__entry->eth_type), __entry->ip_proto, __entry->uni_di, + __entry->in_pf, __entry->out_pf) +); + +TRACE_EVENT(sw_act_dump, + TP_PROTO(const char *fname, int line, u32 act), + TP_ARGS(fname, line, act), + TP_STRUCT__entry(__string(fname, fname) + __field(int, line) + __field(u32, act) + ), + + TP_fast_assign(__assign_str(fname); + __entry->line = line; + __entry->act = act; + ), + + TP_printk("[%s:%d] %u", + __get_str(fname), __entry->line, __entry->act) +); + +#endif + +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH ../../drivers/net/ethernet/marvell/octeontx2/nic/switch/ + +#undef TRACE_INCLUDE_FILE +#define TRACE_INCLUDE_FILE sw_trace + +#include -- 2.43.0