xref: /linux/drivers/block/null_blk/trace.h (revision ae22a94997b8a03dcb3c922857c203246711f9d4)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * null_blk device driver tracepoints.
4  *
5  * Copyright (C) 2020 Western Digital Corporation or its affiliates.
6  */
7 
8 #undef TRACE_SYSTEM
9 #define TRACE_SYSTEM nullb
10 
11 #if !defined(_TRACE_NULLB_H) || defined(TRACE_HEADER_MULTI_READ)
12 #define _TRACE_NULLB_H
13 
14 #include <linux/tracepoint.h>
15 #include <linux/trace_seq.h>
16 
17 #include "null_blk.h"
18 
19 const char *nullb_trace_disk_name(struct trace_seq *p, char *name);
20 
21 #define __print_disk_name(name) nullb_trace_disk_name(p, name)
22 
23 #ifndef TRACE_HEADER_MULTI_READ
24 static inline void __assign_disk_name(char *name, struct gendisk *disk)
25 {
26 	if (disk)
27 		memcpy(name, disk->disk_name, DISK_NAME_LEN);
28 	else
29 		memset(name, 0, DISK_NAME_LEN);
30 }
31 #endif
32 
33 TRACE_EVENT(nullb_zone_op,
34 	    TP_PROTO(struct nullb_cmd *cmd, unsigned int zone_no,
35 		     unsigned int zone_cond),
36 	    TP_ARGS(cmd, zone_no, zone_cond),
37 	    TP_STRUCT__entry(
38 		__array(char, disk, DISK_NAME_LEN)
39 		__field(enum req_op, op)
40 		__field(unsigned int, zone_no)
41 		__field(unsigned int, zone_cond)
42 	    ),
43 	    TP_fast_assign(
44 		__entry->op = req_op(blk_mq_rq_from_pdu(cmd));
45 		__entry->zone_no = zone_no;
46 		__entry->zone_cond = zone_cond;
47 		__assign_disk_name(__entry->disk,
48 			blk_mq_rq_from_pdu(cmd)->q->disk);
49 	    ),
50 	    TP_printk("%s req=%-15s zone_no=%u zone_cond=%-10s",
51 		      __print_disk_name(__entry->disk),
52 		      blk_op_str(__entry->op),
53 		      __entry->zone_no,
54 		      blk_zone_cond_str(__entry->zone_cond))
55 );
56 
57 TRACE_EVENT(nullb_report_zones,
58 	    TP_PROTO(struct nullb *nullb, unsigned int nr_zones),
59 	    TP_ARGS(nullb, nr_zones),
60 	    TP_STRUCT__entry(
61 		__array(char, disk, DISK_NAME_LEN)
62 		__field(unsigned int, nr_zones)
63 	    ),
64 	    TP_fast_assign(
65 		__entry->nr_zones = nr_zones;
66 		__assign_disk_name(__entry->disk, nullb->disk);
67 	    ),
68 	    TP_printk("%s nr_zones=%u",
69 		      __print_disk_name(__entry->disk), __entry->nr_zones)
70 );
71 
72 #endif /* _TRACE_NULLB_H */
73 
74 #undef TRACE_INCLUDE_PATH
75 #define TRACE_INCLUDE_PATH .
76 #undef TRACE_INCLUDE_FILE
77 #define TRACE_INCLUDE_FILE trace
78 
79 /* This part must be outside protection */
80 #include <trace/define_trace.h>
81