[PATCH] mctp i2c: Add rx trace

From: Tal Yacobi
Date: Tue May 28 2024 - 10:35:05 EST


mctp-i2c rx implementation doesn't call
__i2c_transfer which calls the i2c reply trace function.

Add an mctp_reply trace function that will be used instead.

Signed-off-by: Tal Yacobi <talycb8@xxxxxxxxx>
---
drivers/net/mctp/mctp-i2c.c | 3 +++
include/trace/events/mctp.h | 16 ++++++++++++++++
2 files changed, 19 insertions(+)

diff --git a/drivers/net/mctp/mctp-i2c.c b/drivers/net/mctp/mctp-i2c.c
index b37a9e4bade4..22754f4e4a8d 100644
--- a/drivers/net/mctp/mctp-i2c.c
+++ b/drivers/net/mctp/mctp-i2c.c
@@ -24,6 +24,7 @@
#include <linux/if_arp.h>
#include <net/mctp.h>
#include <net/mctpdevice.h>
+#include <trace/events/mctp.h>

/* byte_count is limited to u8 */
#define MCTP_I2C_MAXBLOCK 255
@@ -312,6 +313,8 @@ static int mctp_i2c_recv(struct mctp_i2c_dev *midev)
return -ENOMEM;
}

+ trace_mctp_reply(midev->rx_buffer, recvlen);
+
skb->protocol = htons(ETH_P_MCTP);
skb_put_data(skb, midev->rx_buffer, recvlen);
skb_reset_mac_header(skb);
diff --git a/include/trace/events/mctp.h b/include/trace/events/mctp.h
index 165cf25f77a7..d115c353dff9 100644
--- a/include/trace/events/mctp.h
+++ b/include/trace/events/mctp.h
@@ -73,6 +73,22 @@ TRACE_EVENT(mctp_key_release,
)
);

+TRACE_EVENT(mctp_reply,
+ TP_PROTO(const u8 *rx_buffer, const size_t recvlen),
+ TP_ARGS(rx_buffer, recvlen),
+ TP_STRUCT__entry(
+ __field(__u16, len)
+ __dynamic_array(__u8, buf, recvlen)),
+ TP_fast_assign(
+ __entry->len = (__u16) recvlen;
+ memcpy(__get_dynamic_array(buf), rx_buffer, recvlen);
+ ),
+ TP_printk("l=%u [%*phD]",
+ __entry->len,
+ __entry->len, __get_dynamic_array(buf)
+ )
+);
+
#endif

#include <trace/define_trace.h>
--
2.43.0