diff mbox series

[RFC,v5,19/19] virtio/vsock: update trace event for SEQPACKET

Message ID 20210218054219.1069224-1-arseny.krasnov@kaspersky.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series virtio/vsock: introduce SOCK_SEQPACKET support | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count fail Series longer than 15 patches
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix success Link
netdev/cc_maintainers success CCed 10 of 10 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch warning WARNING: quoted string split across lines
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Arseny Krasnov Feb. 18, 2021, 5:42 a.m. UTC
This updates current implementation for trace event of virtio vsock:
SEQPACKET socket's type, SEQPACKET specific ops and SEQPACKET 'msg_len'
and 'msg_cnt' fields are added.

Signed-off-by: Arseny Krasnov <arseny.krasnov@kaspersky.com>
---
 .../events/vsock_virtio_transport_common.h    | 48 +++++++++++++++----
 net/vmw_vsock/virtio_transport_common.c       | 25 +++++++++-
 2 files changed, 61 insertions(+), 12 deletions(-)

Comments

Steven Rostedt March 2, 2021, 10:25 p.m. UTC | #1
On Thu, 18 Feb 2021 08:42:15 +0300
Arseny Krasnov <arseny.krasnov@kaspersky.com> wrote:

Not sure if this was pulled in yet, but I do have a small issue with this
patch.

> @@ -69,14 +82,19 @@ TRACE_EVENT(virtio_transport_alloc_pkt,
>  		__entry->type = type;
>  		__entry->op = op;
>  		__entry->flags = flags;
> +		__entry->msg_len = msg_len;
> +		__entry->msg_cnt = msg_cnt;
>  	),
> -	TP_printk("%u:%u -> %u:%u len=%u type=%s op=%s flags=%#x",
> +	TP_printk("%u:%u -> %u:%u len=%u type=%s op=%s flags=%#x "
> +		  "msg_len=%u msg_cnt=%u",

It's considered poor formatting to split strings like the above. This is
one of the exceptions for the 80 character limit. Do not break strings just
to keep it within 80 characters.

-- Steve


>  		  __entry->src_cid, __entry->src_port,
>  		  __entry->dst_cid, __entry->dst_port,
>  		  __entry->len,
>  		  show_type(__entry->type),
>  		  show_op(__entry->op),
> -		  __entry->flags)
> +		  __entry->flags,
> +		  __entry->msg_len,
> +		  __entry->msg_cnt)
>  );
Arseny Krasnov March 3, 2021, 10:42 a.m. UTC | #2
On 03.03.2021 01:25, Steven Rostedt wrote:
> On Thu, 18 Feb 2021 08:42:15 +0300
> Arseny Krasnov <arseny.krasnov@kaspersky.com> wrote:
>
> Not sure if this was pulled in yet, but I do have a small issue with this
> patch.
No, it is in RFC state.
>
>> @@ -69,14 +82,19 @@ TRACE_EVENT(virtio_transport_alloc_pkt,
>>  		__entry->type = type;
>>  		__entry->op = op;
>>  		__entry->flags = flags;
>> +		__entry->msg_len = msg_len;
>> +		__entry->msg_cnt = msg_cnt;
>>  	),
>> -	TP_printk("%u:%u -> %u:%u len=%u type=%s op=%s flags=%#x",
>> +	TP_printk("%u:%u -> %u:%u len=%u type=%s op=%s flags=%#x "
>> +		  "msg_len=%u msg_cnt=%u",
> It's considered poor formatting to split strings like the above. This is
> one of the exceptions for the 80 character limit. Do not break strings just
> to keep it within 80 characters.
>
> -- Steve
Ok, will fix in next version, Thank You
>
>
>>  		  __entry->src_cid, __entry->src_port,
>>  		  __entry->dst_cid, __entry->dst_port,
>>  		  __entry->len,
>>  		  show_type(__entry->type),
>>  		  show_op(__entry->op),
>> -		  __entry->flags)
>> +		  __entry->flags,
>> +		  __entry->msg_len,
>> +		  __entry->msg_cnt)
>>  );
diff mbox series

Patch

diff --git a/include/trace/events/vsock_virtio_transport_common.h b/include/trace/events/vsock_virtio_transport_common.h
index 6782213778be..23bc0f39c450 100644
--- a/include/trace/events/vsock_virtio_transport_common.h
+++ b/include/trace/events/vsock_virtio_transport_common.h
@@ -9,9 +9,12 @@ 
 #include <linux/tracepoint.h>
 
 TRACE_DEFINE_ENUM(VIRTIO_VSOCK_TYPE_STREAM);
+TRACE_DEFINE_ENUM(VIRTIO_VSOCK_TYPE_SEQPACKET);
 
 #define show_type(val) \
-	__print_symbolic(val, { VIRTIO_VSOCK_TYPE_STREAM, "STREAM" })
+	__print_symbolic(val, \
+				{ VIRTIO_VSOCK_TYPE_STREAM, "STREAM" }, \
+				{ VIRTIO_VSOCK_TYPE_SEQPACKET, "SEQPACKET" })
 
 TRACE_DEFINE_ENUM(VIRTIO_VSOCK_OP_INVALID);
 TRACE_DEFINE_ENUM(VIRTIO_VSOCK_OP_REQUEST);
@@ -21,6 +24,8 @@  TRACE_DEFINE_ENUM(VIRTIO_VSOCK_OP_SHUTDOWN);
 TRACE_DEFINE_ENUM(VIRTIO_VSOCK_OP_RW);
 TRACE_DEFINE_ENUM(VIRTIO_VSOCK_OP_CREDIT_UPDATE);
 TRACE_DEFINE_ENUM(VIRTIO_VSOCK_OP_CREDIT_REQUEST);
+TRACE_DEFINE_ENUM(VIRTIO_VSOCK_OP_SEQ_BEGIN);
+TRACE_DEFINE_ENUM(VIRTIO_VSOCK_OP_SEQ_END);
 
 #define show_op(val) \
 	__print_symbolic(val, \
@@ -31,7 +36,9 @@  TRACE_DEFINE_ENUM(VIRTIO_VSOCK_OP_CREDIT_REQUEST);
 			 { VIRTIO_VSOCK_OP_SHUTDOWN, "SHUTDOWN" }, \
 			 { VIRTIO_VSOCK_OP_RW, "RW" }, \
 			 { VIRTIO_VSOCK_OP_CREDIT_UPDATE, "CREDIT_UPDATE" }, \
-			 { VIRTIO_VSOCK_OP_CREDIT_REQUEST, "CREDIT_REQUEST" })
+			 { VIRTIO_VSOCK_OP_CREDIT_REQUEST, "CREDIT_REQUEST" }, \
+			 { VIRTIO_VSOCK_OP_SEQ_BEGIN, "SEQ_BEGIN" }, \
+			 { VIRTIO_VSOCK_OP_SEQ_END, "SEQ_END" })
 
 TRACE_EVENT(virtio_transport_alloc_pkt,
 	TP_PROTO(
@@ -40,7 +47,9 @@  TRACE_EVENT(virtio_transport_alloc_pkt,
 		 __u32 len,
 		 __u16 type,
 		 __u16 op,
-		 __u32 flags
+		 __u32 flags,
+		 __u32 msg_len,
+		 __u32 msg_cnt
 	),
 	TP_ARGS(
 		src_cid, src_port,
@@ -48,7 +57,9 @@  TRACE_EVENT(virtio_transport_alloc_pkt,
 		len,
 		type,
 		op,
-		flags
+		flags,
+		msg_len,
+		msg_cnt
 	),
 	TP_STRUCT__entry(
 		__field(__u32, src_cid)
@@ -59,6 +70,8 @@  TRACE_EVENT(virtio_transport_alloc_pkt,
 		__field(__u16, type)
 		__field(__u16, op)
 		__field(__u32, flags)
+		__field(__u32, msg_len)
+		__field(__u32, msg_cnt)
 	),
 	TP_fast_assign(
 		__entry->src_cid = src_cid;
@@ -69,14 +82,19 @@  TRACE_EVENT(virtio_transport_alloc_pkt,
 		__entry->type = type;
 		__entry->op = op;
 		__entry->flags = flags;
+		__entry->msg_len = msg_len;
+		__entry->msg_cnt = msg_cnt;
 	),
-	TP_printk("%u:%u -> %u:%u len=%u type=%s op=%s flags=%#x",
+	TP_printk("%u:%u -> %u:%u len=%u type=%s op=%s flags=%#x "
+		  "msg_len=%u msg_cnt=%u",
 		  __entry->src_cid, __entry->src_port,
 		  __entry->dst_cid, __entry->dst_port,
 		  __entry->len,
 		  show_type(__entry->type),
 		  show_op(__entry->op),
-		  __entry->flags)
+		  __entry->flags,
+		  __entry->msg_len,
+		  __entry->msg_cnt)
 );
 
 TRACE_EVENT(virtio_transport_recv_pkt,
@@ -88,7 +106,9 @@  TRACE_EVENT(virtio_transport_recv_pkt,
 		 __u16 op,
 		 __u32 flags,
 		 __u32 buf_alloc,
-		 __u32 fwd_cnt
+		 __u32 fwd_cnt,
+		 __u32 msg_len,
+		 __u32 msg_cnt
 	),
 	TP_ARGS(
 		src_cid, src_port,
@@ -98,7 +118,9 @@  TRACE_EVENT(virtio_transport_recv_pkt,
 		op,
 		flags,
 		buf_alloc,
-		fwd_cnt
+		fwd_cnt,
+		msg_len,
+		msg_cnt
 	),
 	TP_STRUCT__entry(
 		__field(__u32, src_cid)
@@ -111,6 +133,8 @@  TRACE_EVENT(virtio_transport_recv_pkt,
 		__field(__u32, flags)
 		__field(__u32, buf_alloc)
 		__field(__u32, fwd_cnt)
+		__field(__u32, msg_len)
+		__field(__u32, msg_cnt)
 	),
 	TP_fast_assign(
 		__entry->src_cid = src_cid;
@@ -123,9 +147,11 @@  TRACE_EVENT(virtio_transport_recv_pkt,
 		__entry->flags = flags;
 		__entry->buf_alloc = buf_alloc;
 		__entry->fwd_cnt = fwd_cnt;
+		__entry->msg_len = msg_len;
+		__entry->msg_cnt = msg_cnt;
 	),
 	TP_printk("%u:%u -> %u:%u len=%u type=%s op=%s flags=%#x "
-		  "buf_alloc=%u fwd_cnt=%u",
+		  "buf_alloc=%u fwd_cnt=%u msg_len=%u msg_cnt=%u",
 		  __entry->src_cid, __entry->src_port,
 		  __entry->dst_cid, __entry->dst_port,
 		  __entry->len,
@@ -133,7 +159,9 @@  TRACE_EVENT(virtio_transport_recv_pkt,
 		  show_op(__entry->op),
 		  __entry->flags,
 		  __entry->buf_alloc,
-		  __entry->fwd_cnt)
+		  __entry->fwd_cnt,
+		  __entry->msg_len,
+		  __entry->msg_cnt)
 );
 
 #endif /* _TRACE_VSOCK_VIRTIO_TRANSPORT_COMMON_H */
diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
index 8431d0a891ed..2ab5291e2bf7 100644
--- a/net/vmw_vsock/virtio_transport_common.c
+++ b/net/vmw_vsock/virtio_transport_common.c
@@ -47,6 +47,8 @@  virtio_transport_alloc_pkt(struct virtio_vsock_pkt_info *info,
 {
 	struct virtio_vsock_pkt *pkt;
 	int err;
+	u32 msg_len = 0;
+	u32 msg_cnt = 0;
 
 	pkt = kzalloc(sizeof(*pkt), GFP_KERNEL);
 	if (!pkt)
@@ -74,6 +76,14 @@  virtio_transport_alloc_pkt(struct virtio_vsock_pkt_info *info,
 		err = memcpy_from_msg(pkt->buf, info->msg, len);
 		if (err)
 			goto out;
+
+		if (info->op == VIRTIO_VSOCK_OP_SEQ_BEGIN ||
+		    info->op == VIRTIO_VSOCK_OP_SEQ_END) {
+			struct virtio_vsock_seq_hdr *seq_hdr = pkt->buf;
+
+			msg_len = le32_to_cpu(seq_hdr->msg_len);
+			msg_cnt = le32_to_cpu(seq_hdr->msg_cnt);
+		}
 	}
 
 	trace_virtio_transport_alloc_pkt(src_cid, src_port,
@@ -81,7 +91,7 @@  virtio_transport_alloc_pkt(struct virtio_vsock_pkt_info *info,
 					 len,
 					 info->type,
 					 info->op,
-					 info->flags);
+					 info->flags, msg_len, msg_cnt);
 
 	return pkt;
 
@@ -1336,12 +1346,22 @@  void virtio_transport_recv_pkt(struct virtio_transport *t,
 	struct vsock_sock *vsk;
 	struct sock *sk;
 	bool space_available;
+	u32 msg_len = 0;
+	u32 msg_cnt = 0;
 
 	vsock_addr_init(&src, le64_to_cpu(pkt->hdr.src_cid),
 			le32_to_cpu(pkt->hdr.src_port));
 	vsock_addr_init(&dst, le64_to_cpu(pkt->hdr.dst_cid),
 			le32_to_cpu(pkt->hdr.dst_port));
 
+	if (le16_to_cpu(pkt->hdr.op) == VIRTIO_VSOCK_OP_SEQ_BEGIN ||
+	    le16_to_cpu(pkt->hdr.op) == VIRTIO_VSOCK_OP_SEQ_END) {
+		struct virtio_vsock_seq_hdr *seq_hdr = pkt->buf;
+
+		msg_len = le32_to_cpu(seq_hdr->msg_len);
+		msg_cnt = le32_to_cpu(seq_hdr->msg_cnt);
+	}
+
 	trace_virtio_transport_recv_pkt(src.svm_cid, src.svm_port,
 					dst.svm_cid, dst.svm_port,
 					le32_to_cpu(pkt->hdr.len),
@@ -1349,7 +1369,8 @@  void virtio_transport_recv_pkt(struct virtio_transport *t,
 					le16_to_cpu(pkt->hdr.op),
 					le32_to_cpu(pkt->hdr.flags),
 					le32_to_cpu(pkt->hdr.buf_alloc),
-					le32_to_cpu(pkt->hdr.fwd_cnt));
+					le32_to_cpu(pkt->hdr.fwd_cnt),
+					msg_len, msg_cnt);
 
 	if (!virtio_transport_valid_type(le16_to_cpu(pkt->hdr.type))) {
 		(void)virtio_transport_reset_no_sock(t, pkt);