1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #if IS_ENABLED(CONFIG_NET_DEVLINK) 3 4 #undef TRACE_SYSTEM 5 #define TRACE_SYSTEM devlink 6 7 #if !defined(_TRACE_DEVLINK_H) || defined(TRACE_HEADER_MULTI_READ) 8 #define _TRACE_DEVLINK_H 9 10 #include <linux/device.h> 11 #include <net/devlink.h> 12 #include <linux/tracepoint.h> 13 14 /* 15 * Tracepoint for devlink hardware message: 16 */ 17 TRACE_EVENT(devlink_hwmsg, 18 TP_PROTO(const struct devlink *devlink, bool incoming, 19 unsigned long type, const u8 *buf, size_t len), 20 21 TP_ARGS(devlink, incoming, type, buf, len), 22 23 TP_STRUCT__entry( 24 __string(bus_name, devlink->dev->bus->name) 25 __string(dev_name, dev_name(devlink->dev)) 26 __string(driver_name, devlink->dev->driver->name) 27 __field(bool, incoming) 28 __field(unsigned long, type) 29 __dynamic_array(u8, buf, len) 30 __field(size_t, len) 31 ), 32 33 TP_fast_assign( 34 __assign_str(bus_name, devlink->dev->bus->name); 35 __assign_str(dev_name, dev_name(devlink->dev)); 36 __assign_str(driver_name, devlink->dev->driver->name); 37 __entry->incoming = incoming; 38 __entry->type = type; 39 memcpy(__get_dynamic_array(buf), buf, len); 40 __entry->len = len; 41 ), 42 43 TP_printk("bus_name=%s dev_name=%s driver_name=%s incoming=%d type=%lu buf=0x[%*phD] len=%zu", 44 __get_str(bus_name), __get_str(dev_name), 45 __get_str(driver_name), __entry->incoming, __entry->type, 46 (int) __entry->len, __get_dynamic_array(buf), __entry->len) 47 ); 48 49 /* 50 * Tracepoint for devlink hardware error: 51 */ 52 TRACE_EVENT(devlink_hwerr, 53 TP_PROTO(const struct devlink *devlink, int err, const char *msg), 54 55 TP_ARGS(devlink, err, msg), 56 57 TP_STRUCT__entry( 58 __string(bus_name, devlink->dev->bus->name) 59 __string(dev_name, dev_name(devlink->dev)) 60 __string(driver_name, devlink->dev->driver->name) 61 __field(int, err) 62 __string(msg, msg) 63 ), 64 65 TP_fast_assign( 66 __assign_str(bus_name, devlink->dev->bus->name); 67 __assign_str(dev_name, dev_name(devlink->dev)); 68 __assign_str(driver_name, devlink->dev->driver->name); 69 __entry->err = err; 70 __assign_str(msg, msg); 71 ), 72 73 TP_printk("bus_name=%s dev_name=%s driver_name=%s err=%d %s", 74 __get_str(bus_name), __get_str(dev_name), 75 __get_str(driver_name), __entry->err, __get_str(msg)) 76 ); 77 78 /* 79 * Tracepoint for devlink health message: 80 */ 81 TRACE_EVENT(devlink_health_report, 82 TP_PROTO(const struct devlink *devlink, const char *reporter_name, 83 const char *msg), 84 85 TP_ARGS(devlink, reporter_name, msg), 86 87 TP_STRUCT__entry( 88 __string(bus_name, devlink->dev->bus->name) 89 __string(dev_name, dev_name(devlink->dev)) 90 __string(driver_name, devlink->dev->driver->name) 91 __string(reporter_name, msg) 92 __string(msg, msg) 93 ), 94 95 TP_fast_assign( 96 __assign_str(bus_name, devlink->dev->bus->name); 97 __assign_str(dev_name, dev_name(devlink->dev)); 98 __assign_str(driver_name, devlink->dev->driver->name); 99 __assign_str(reporter_name, reporter_name); 100 __assign_str(msg, msg); 101 ), 102 103 TP_printk("bus_name=%s dev_name=%s driver_name=%s reporter_name=%s: %s", 104 __get_str(bus_name), __get_str(dev_name), 105 __get_str(driver_name), __get_str(reporter_name), 106 __get_str(msg)) 107 ); 108 109 /* 110 * Tracepoint for devlink health recover aborted message: 111 */ 112 TRACE_EVENT(devlink_health_recover_aborted, 113 TP_PROTO(const struct devlink *devlink, const char *reporter_name, 114 bool health_state, u64 time_since_last_recover), 115 116 TP_ARGS(devlink, reporter_name, health_state, time_since_last_recover), 117 118 TP_STRUCT__entry( 119 __string(bus_name, devlink->dev->bus->name) 120 __string(dev_name, dev_name(devlink->dev)) 121 __string(driver_name, devlink->dev->driver->name) 122 __string(reporter_name, reporter_name) 123 __field(bool, health_state) 124 __field(u64, time_since_last_recover) 125 ), 126 127 TP_fast_assign( 128 __assign_str(bus_name, devlink->dev->bus->name); 129 __assign_str(dev_name, dev_name(devlink->dev)); 130 __assign_str(driver_name, devlink->dev->driver->name); 131 __assign_str(reporter_name, reporter_name); 132 __entry->health_state = health_state; 133 __entry->time_since_last_recover = time_since_last_recover; 134 ), 135 136 TP_printk("bus_name=%s dev_name=%s driver_name=%s reporter_name=%s: health_state=%d time_since_last_recover=%llu recover aborted", 137 __get_str(bus_name), __get_str(dev_name), 138 __get_str(driver_name), __get_str(reporter_name), 139 __entry->health_state, 140 __entry->time_since_last_recover) 141 ); 142 143 /* 144 * Tracepoint for devlink health reporter state update: 145 */ 146 TRACE_EVENT(devlink_health_reporter_state_update, 147 TP_PROTO(const struct devlink *devlink, const char *reporter_name, 148 bool new_state), 149 150 TP_ARGS(devlink, reporter_name, new_state), 151 152 TP_STRUCT__entry( 153 __string(bus_name, devlink->dev->bus->name) 154 __string(dev_name, dev_name(devlink->dev)) 155 __string(driver_name, devlink->dev->driver->name) 156 __string(reporter_name, reporter_name) 157 __field(u8, new_state) 158 ), 159 160 TP_fast_assign( 161 __assign_str(bus_name, devlink->dev->bus->name); 162 __assign_str(dev_name, dev_name(devlink->dev)); 163 __assign_str(driver_name, devlink->dev->driver->name); 164 __assign_str(reporter_name, reporter_name); 165 __entry->new_state = new_state; 166 ), 167 168 TP_printk("bus_name=%s dev_name=%s driver_name=%s reporter_name=%s: new_state=%d", 169 __get_str(bus_name), __get_str(dev_name), 170 __get_str(driver_name), __get_str(reporter_name), 171 __entry->new_state) 172 ); 173 174 #endif /* _TRACE_DEVLINK_H */ 175 176 /* This part must be outside protection */ 177 #include <trace/define_trace.h> 178 179 #else /* CONFIG_NET_DEVLINK */ 180 181 #if !defined(_TRACE_DEVLINK_H) 182 #define _TRACE_DEVLINK_H 183 184 #include <net/devlink.h> 185 186 static inline void trace_devlink_hwmsg(const struct devlink *devlink, 187 bool incoming, unsigned long type, 188 const u8 *buf, size_t len) 189 { 190 } 191 192 static inline void trace_devlink_hwerr(const struct devlink *devlink, 193 int err, const char *msg) 194 { 195 } 196 #endif /* _TRACE_DEVLINK_H */ 197 198 #endif 199