]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: hibmcge: add support for tracepoint to dump some fields of rx_desc
authorTao Lan <lantao5@huawei.com>
Sat, 22 Nov 2025 03:46:55 +0000 (11:46 +0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 27 Nov 2025 02:22:40 +0000 (18:22 -0800)
add support for tracepoint to dump some fields of rx_desc

Signed-off-by: Tao Lan <lantao5@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
Link: https://patch.msgid.link/20251122034657.3373143-2-shaojijie@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/hisilicon/hibmcge/Makefile
drivers/net/ethernet/hisilicon/hibmcge/hbg_reg.h
drivers/net/ethernet/hisilicon/hibmcge/hbg_trace.h [new file with mode: 0644]
drivers/net/ethernet/hisilicon/hibmcge/hbg_txrx.c

index 1a9da564b306a2fa4a3bb48fee65e3c46ef21890..d6610ba16855d47b793f647de4791cd8b26dbf52 100644 (file)
@@ -3,6 +3,7 @@
 # Makefile for the HISILICON BMC GE network device drivers.
 #
 
+ccflags-y += -I$(src)
 obj-$(CONFIG_HIBMCGE) += hibmcge.o
 
 hibmcge-objs = hbg_main.o hbg_hw.o hbg_mdio.o hbg_irq.o hbg_txrx.o hbg_ethtool.o \
index a39d1e796e4a412fcc532b7e6870c324a0cd1805..30b3903c8f2deedaa9fb22aa6400e176c8fbebeb 100644 (file)
@@ -252,6 +252,8 @@ struct hbg_rx_desc {
 
 #define HBG_RX_DESC_W2_PKT_LEN_M       GENMASK(31, 16)
 #define HBG_RX_DESC_W2_PORT_NUM_M      GENMASK(15, 12)
+#define HBG_RX_DESC_W3_IP_OFFSET_M     GENMASK(23, 16)
+#define HBG_RX_DESC_W3_VLAN_M          GENMASK(15, 0)
 #define HBG_RX_DESC_W4_IP_TCP_UDP_M    GENMASK(31, 30)
 #define HBG_RX_DESC_W4_IPSEC_B         BIT(29)
 #define HBG_RX_DESC_W4_IP_VERSION_B    BIT(28)
@@ -269,6 +271,8 @@ struct hbg_rx_desc {
 #define HBG_RX_DESC_W4_L3_ERR_CODE_M   GENMASK(12, 9)
 #define HBG_RX_DESC_W4_L2_ERR_B                BIT(8)
 #define HBG_RX_DESC_W4_IDX_MATCH_B     BIT(7)
+#define HBG_RX_DESC_W4_PARSE_MODE_M    GENMASK(6, 5)
+#define HBG_RX_DESC_W5_VALID_SIZE_M    GENMASK(15, 0)
 
 enum hbg_l3_err_code {
        HBG_L3_OK = 0,
diff --git a/drivers/net/ethernet/hisilicon/hibmcge/hbg_trace.h b/drivers/net/ethernet/hisilicon/hibmcge/hbg_trace.h
new file mode 100644 (file)
index 0000000..b70fd96
--- /dev/null
@@ -0,0 +1,84 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/* Copyright (c) 2025 Hisilicon Limited. */
+
+/* This must be outside ifdef _HBG_TRACE_H */
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM hibmcge
+
+#if !defined(_HBG_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
+#define _HBG_TRACE_H_
+
+#include <linux/bitfield.h>
+#include <linux/pci.h>
+#include <linux/tracepoint.h>
+#include <linux/types.h>
+#include "hbg_reg.h"
+
+TRACE_EVENT(hbg_rx_desc,
+           TP_PROTO(struct hbg_priv *priv, u32 index,
+                    struct hbg_rx_desc *rx_desc),
+           TP_ARGS(priv, index, rx_desc),
+
+           TP_STRUCT__entry(__field(u32, index)
+                            __field(u8, port_num)
+                            __field(u8, ip_offset)
+                            __field(u8, parse_mode)
+                            __field(u8, l4_error_code)
+                            __field(u8, l3_error_code)
+                            __field(u8, l2_error_code)
+                            __field(u16, packet_len)
+                            __field(u16, valid_size)
+                            __field(u16, vlan)
+                            __string(pciname, pci_name(priv->pdev))
+                            __string(devname, priv->netdev->name)
+           ),
+
+           TP_fast_assign(__entry->index = index,
+                          __entry->packet_len =
+                               FIELD_GET(HBG_RX_DESC_W2_PKT_LEN_M,
+                                         rx_desc->word2);
+                          __entry->port_num =
+                               FIELD_GET(HBG_RX_DESC_W2_PORT_NUM_M,
+                                         rx_desc->word2);
+                          __entry->ip_offset =
+                               FIELD_GET(HBG_RX_DESC_W3_IP_OFFSET_M,
+                                         rx_desc->word3);
+                          __entry->vlan =
+                               FIELD_GET(HBG_RX_DESC_W3_VLAN_M,
+                                         rx_desc->word3);
+                          __entry->parse_mode =
+                               FIELD_GET(HBG_RX_DESC_W4_PARSE_MODE_M,
+                                         rx_desc->word4);
+                          __entry->l4_error_code =
+                               FIELD_GET(HBG_RX_DESC_W4_L4_ERR_CODE_M,
+                                         rx_desc->word4);
+                          __entry->l3_error_code =
+                               FIELD_GET(HBG_RX_DESC_W4_L3_ERR_CODE_M,
+                                         rx_desc->word4);
+                          __entry->l2_error_code =
+                               FIELD_GET(HBG_RX_DESC_W4_L2_ERR_B,
+                                         rx_desc->word4);
+                          __entry->valid_size =
+                               FIELD_GET(HBG_RX_DESC_W5_VALID_SIZE_M,
+                                         rx_desc->word5);
+                          __assign_str(pciname);
+                          __assign_str(devname);
+           ),
+
+           TP_printk("%s %s index:%u, port num:%u, len:%u, valid size:%u, ip_offset:%u, vlan:0x%04x, parse mode:%u, l4_err:0x%x, l3_err:0x%x, l2_err:0x%x",
+                     __get_str(pciname), __get_str(devname), __entry->index,
+                     __entry->port_num, __entry->packet_len,
+                     __entry->valid_size, __entry->ip_offset,  __entry->vlan,
+                     __entry->parse_mode, __entry->l4_error_code,
+                     __entry->l3_error_code, __entry->l2_error_code
+           )
+);
+
+#endif /* _HBG_TRACE_H_ */
+
+/* This must be outside ifdef _HBG_TRACE_H */
+#undef TRACE_INCLUDE_PATH
+#define TRACE_INCLUDE_PATH .
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_FILE hbg_trace
+#include <trace/define_trace.h>
index 8d814c8f19ea0c3eb685db9d69bf5e5259eba2cf..5f2e48f1dd257f4fcb7435dcb7295462ef1b0240 100644 (file)
@@ -7,6 +7,9 @@
 #include "hbg_reg.h"
 #include "hbg_txrx.h"
 
+#define CREATE_TRACE_POINTS
+#include "hbg_trace.h"
+
 #define netdev_get_tx_ring(netdev) \
                        (&(((struct hbg_priv *)netdev_priv(netdev))->tx_ring))
 
@@ -429,6 +432,7 @@ static int hbg_napi_rx_poll(struct napi_struct *napi, int budget)
                        break;
                rx_desc = (struct hbg_rx_desc *)buffer->skb->data;
                pkt_len = FIELD_GET(HBG_RX_DESC_W2_PKT_LEN_M, rx_desc->word2);
+               trace_hbg_rx_desc(priv, ring->ntc, rx_desc);
 
                if (unlikely(!hbg_rx_pkt_check(priv, rx_desc, buffer->skb))) {
                        hbg_buffer_free(buffer);