Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mac802154: add trace functionality for driver ops

This patch adds trace events for driver operations.

Signed-off-by: Varka Bhadram <varkab@cdac.in>
Acked-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

authored by

Varka Bhadram and committed by
Marcel Holtmann
0ecc4e68 1caf6f47

+362 -15
+3 -1
net/mac802154/Makefile
··· 1 1 obj-$(CONFIG_MAC802154) += mac802154.o 2 2 mac802154-objs := main.o rx.o tx.o mac_cmd.o mib.o \ 3 - iface.o llsec.o util.o cfg.o 3 + iface.o llsec.o util.o cfg.o trace.o 4 + 5 + CFLAGS_trace.o := -I$(src) 4 6 5 7 ccflags-y += -D__CHECK_ENDIAN__
+78 -14
net/mac802154/driver-ops.h
··· 7 7 #include <net/mac802154.h> 8 8 9 9 #include "ieee802154_i.h" 10 + #include "trace.h" 10 11 11 12 static inline int 12 13 drv_xmit_async(struct ieee802154_local *local, struct sk_buff *skb) ··· 28 27 29 28 static inline int drv_start(struct ieee802154_local *local) 30 29 { 30 + int ret; 31 + 31 32 might_sleep(); 32 33 34 + trace_802154_drv_start(local); 33 35 local->started = true; 34 36 smp_mb(); 35 - 36 - return local->ops->start(&local->hw); 37 + ret = local->ops->start(&local->hw); 38 + trace_802154_drv_return_int(local, ret); 39 + return ret; 37 40 } 38 41 39 42 static inline void drv_stop(struct ieee802154_local *local) 40 43 { 41 44 might_sleep(); 42 45 46 + trace_802154_drv_stop(local); 43 47 local->ops->stop(&local->hw); 48 + trace_802154_drv_return_void(local); 44 49 45 50 /* sync away all work on the tasklet before clearing started */ 46 51 tasklet_disable(&local->tasklet); ··· 60 53 static inline int 61 54 drv_set_channel(struct ieee802154_local *local, u8 page, u8 channel) 62 55 { 56 + int ret; 57 + 63 58 might_sleep(); 64 59 65 - return local->ops->set_channel(&local->hw, page, channel); 60 + trace_802154_drv_set_channel(local, page, channel); 61 + ret = local->ops->set_channel(&local->hw, page, channel); 62 + trace_802154_drv_return_int(local, ret); 63 + return ret; 66 64 } 67 65 68 66 static inline int drv_set_tx_power(struct ieee802154_local *local, s32 mbm) 69 67 { 68 + int ret; 69 + 70 70 might_sleep(); 71 71 72 72 if (!local->ops->set_txpower) { ··· 81 67 return -EOPNOTSUPP; 82 68 } 83 69 84 - return local->ops->set_txpower(&local->hw, mbm); 70 + trace_802154_drv_set_tx_power(local, mbm); 71 + ret = local->ops->set_txpower(&local->hw, mbm); 72 + trace_802154_drv_return_int(local, ret); 73 + return ret; 85 74 } 86 75 87 76 static inline int drv_set_cca_mode(struct ieee802154_local *local, 88 77 const struct wpan_phy_cca *cca) 89 78 { 79 + int ret; 80 + 90 81 might_sleep(); 91 82 92 83 if (!local->ops->set_cca_mode) { ··· 99 80 return -EOPNOTSUPP; 100 81 } 101 82 102 - return local->ops->set_cca_mode(&local->hw, cca); 83 + trace_802154_drv_set_cca_mode(local, cca); 84 + ret = local->ops->set_cca_mode(&local->hw, cca); 85 + trace_802154_drv_return_int(local, ret); 86 + return ret; 103 87 } 104 88 105 89 static inline int drv_set_lbt_mode(struct ieee802154_local *local, bool mode) 106 90 { 91 + int ret; 92 + 107 93 might_sleep(); 108 94 109 95 if (!local->ops->set_lbt) { ··· 116 92 return -EOPNOTSUPP; 117 93 } 118 94 119 - return local->ops->set_lbt(&local->hw, mode); 95 + trace_802154_drv_set_lbt_mode(local, mode); 96 + ret = local->ops->set_lbt(&local->hw, mode); 97 + trace_802154_drv_return_int(local, ret); 98 + return ret; 120 99 } 121 100 122 101 static inline int 123 102 drv_set_cca_ed_level(struct ieee802154_local *local, s32 mbm) 124 103 { 104 + int ret; 105 + 125 106 might_sleep(); 126 107 127 108 if (!local->ops->set_cca_ed_level) { ··· 134 105 return -EOPNOTSUPP; 135 106 } 136 107 137 - return local->ops->set_cca_ed_level(&local->hw, mbm); 108 + trace_802154_drv_set_cca_ed_level(local, mbm); 109 + ret = local->ops->set_cca_ed_level(&local->hw, mbm); 110 + trace_802154_drv_return_int(local, ret); 111 + return ret; 138 112 } 139 113 140 114 static inline int drv_set_pan_id(struct ieee802154_local *local, __le16 pan_id) 141 115 { 142 116 struct ieee802154_hw_addr_filt filt; 117 + int ret; 143 118 144 119 might_sleep(); 145 120 ··· 154 121 155 122 filt.pan_id = pan_id; 156 123 157 - return local->ops->set_hw_addr_filt(&local->hw, &filt, 124 + trace_802154_drv_set_pan_id(local, pan_id); 125 + ret = local->ops->set_hw_addr_filt(&local->hw, &filt, 158 126 IEEE802154_AFILT_PANID_CHANGED); 127 + trace_802154_drv_return_int(local, ret); 128 + return ret; 159 129 } 160 130 161 131 static inline int 162 132 drv_set_extended_addr(struct ieee802154_local *local, __le64 extended_addr) 163 133 { 164 134 struct ieee802154_hw_addr_filt filt; 135 + int ret; 165 136 166 137 might_sleep(); 167 138 ··· 176 139 177 140 filt.ieee_addr = extended_addr; 178 141 179 - return local->ops->set_hw_addr_filt(&local->hw, &filt, 142 + trace_802154_drv_set_extended_addr(local, extended_addr); 143 + ret = local->ops->set_hw_addr_filt(&local->hw, &filt, 180 144 IEEE802154_AFILT_IEEEADDR_CHANGED); 145 + trace_802154_drv_return_int(local, ret); 146 + return ret; 181 147 } 182 148 183 149 static inline int 184 150 drv_set_short_addr(struct ieee802154_local *local, __le16 short_addr) 185 151 { 186 152 struct ieee802154_hw_addr_filt filt; 153 + int ret; 187 154 188 155 might_sleep(); 189 156 ··· 198 157 199 158 filt.short_addr = short_addr; 200 159 201 - return local->ops->set_hw_addr_filt(&local->hw, &filt, 160 + trace_802154_drv_set_short_addr(local, short_addr); 161 + ret = local->ops->set_hw_addr_filt(&local->hw, &filt, 202 162 IEEE802154_AFILT_SADDR_CHANGED); 163 + trace_802154_drv_return_int(local, ret); 164 + return ret; 203 165 } 204 166 205 167 static inline int 206 168 drv_set_pan_coord(struct ieee802154_local *local, bool is_coord) 207 169 { 208 170 struct ieee802154_hw_addr_filt filt; 171 + int ret; 209 172 210 173 might_sleep(); 211 174 ··· 220 175 221 176 filt.pan_coord = is_coord; 222 177 223 - return local->ops->set_hw_addr_filt(&local->hw, &filt, 178 + trace_802154_drv_set_pan_coord(local, is_coord); 179 + ret = local->ops->set_hw_addr_filt(&local->hw, &filt, 224 180 IEEE802154_AFILT_PANC_CHANGED); 181 + trace_802154_drv_return_int(local, ret); 182 + return ret; 225 183 } 226 184 227 185 static inline int 228 186 drv_set_csma_params(struct ieee802154_local *local, u8 min_be, u8 max_be, 229 187 u8 max_csma_backoffs) 230 188 { 189 + int ret; 190 + 231 191 might_sleep(); 232 192 233 193 if (!local->ops->set_csma_params) { ··· 240 190 return -EOPNOTSUPP; 241 191 } 242 192 243 - return local->ops->set_csma_params(&local->hw, min_be, max_be, 193 + trace_802154_drv_set_csma_params(local, min_be, max_be, 194 + max_csma_backoffs); 195 + ret = local->ops->set_csma_params(&local->hw, min_be, max_be, 244 196 max_csma_backoffs); 197 + trace_802154_drv_return_int(local, ret); 198 + return ret; 245 199 } 246 200 247 201 static inline int 248 202 drv_set_max_frame_retries(struct ieee802154_local *local, s8 max_frame_retries) 249 203 { 204 + int ret; 205 + 250 206 might_sleep(); 251 207 252 208 if (!local->ops->set_frame_retries) { ··· 260 204 return -EOPNOTSUPP; 261 205 } 262 206 263 - return local->ops->set_frame_retries(&local->hw, max_frame_retries); 207 + trace_802154_drv_set_max_frame_retries(local, max_frame_retries); 208 + ret = local->ops->set_frame_retries(&local->hw, max_frame_retries); 209 + trace_802154_drv_return_int(local, ret); 210 + return ret; 264 211 } 265 212 266 213 static inline int 267 214 drv_set_promiscuous_mode(struct ieee802154_local *local, bool on) 268 215 { 216 + int ret; 217 + 269 218 might_sleep(); 270 219 271 220 if (!local->ops->set_promiscuous_mode) { ··· 278 217 return -EOPNOTSUPP; 279 218 } 280 219 281 - return local->ops->set_promiscuous_mode(&local->hw, on); 220 + trace_802154_drv_set_promiscuous_mode(local, on); 221 + ret = local->ops->set_promiscuous_mode(&local->hw, on); 222 + trace_802154_drv_return_int(local, ret); 223 + return ret; 282 224 } 283 225 284 226 #endif /* __MAC802154_DRIVER_OPS */
+9
net/mac802154/trace.c
··· 1 + #include <linux/module.h> 2 + 3 + #ifndef __CHECKER__ 4 + #include <net/cfg802154.h> 5 + #include "driver-ops.h" 6 + #define CREATE_TRACE_POINTS 7 + #include "trace.h" 8 + 9 + #endif
+272
net/mac802154/trace.h
··· 1 + /* Based on net/mac80211/trace.h */ 2 + 3 + #undef TRACE_SYSTEM 4 + #define TRACE_SYSTEM mac802154 5 + 6 + #if !defined(__MAC802154_DRIVER_TRACE) || defined(TRACE_HEADER_MULTI_READ) 7 + #define __MAC802154_DRIVER_TRACE 8 + 9 + #include <linux/tracepoint.h> 10 + 11 + #include <net/mac802154.h> 12 + #include "ieee802154_i.h" 13 + 14 + #define MAXNAME 32 15 + #define LOCAL_ENTRY __array(char, wpan_phy_name, MAXNAME) 16 + #define LOCAL_ASSIGN strlcpy(__entry->wpan_phy_name, \ 17 + wpan_phy_name(local->hw.phy), MAXNAME) 18 + #define LOCAL_PR_FMT "%s" 19 + #define LOCAL_PR_ARG __entry->wpan_phy_name 20 + 21 + #define CCA_ENTRY __field(enum nl802154_cca_modes, cca_mode) \ 22 + __field(enum nl802154_cca_opts, cca_opt) 23 + #define CCA_ASSIGN \ 24 + do { \ 25 + (__entry->cca_mode) = cca->mode; \ 26 + (__entry->cca_opt) = cca->opt; \ 27 + } while (0) 28 + #define CCA_PR_FMT "cca_mode: %d, cca_opt: %d" 29 + #define CCA_PR_ARG __entry->cca_mode, __entry->cca_opt 30 + 31 + #define BOOL_TO_STR(bo) (bo) ? "true" : "false" 32 + 33 + /* Tracing for driver callbacks */ 34 + 35 + DECLARE_EVENT_CLASS(local_only_evt, 36 + TP_PROTO(struct ieee802154_local *local), 37 + TP_ARGS(local), 38 + TP_STRUCT__entry( 39 + LOCAL_ENTRY 40 + ), 41 + TP_fast_assign( 42 + LOCAL_ASSIGN; 43 + ), 44 + TP_printk(LOCAL_PR_FMT, LOCAL_PR_ARG) 45 + ); 46 + 47 + DEFINE_EVENT(local_only_evt, 802154_drv_return_void, 48 + TP_PROTO(struct ieee802154_local *local), 49 + TP_ARGS(local) 50 + ); 51 + 52 + TRACE_EVENT(802154_drv_return_int, 53 + TP_PROTO(struct ieee802154_local *local, int ret), 54 + TP_ARGS(local, ret), 55 + TP_STRUCT__entry( 56 + LOCAL_ENTRY 57 + __field(int, ret) 58 + ), 59 + TP_fast_assign( 60 + LOCAL_ASSIGN; 61 + __entry->ret = ret; 62 + ), 63 + TP_printk(LOCAL_PR_FMT ", returned: %d", LOCAL_PR_ARG, 64 + __entry->ret) 65 + ); 66 + 67 + DEFINE_EVENT(local_only_evt, 802154_drv_start, 68 + TP_PROTO(struct ieee802154_local *local), 69 + TP_ARGS(local) 70 + ); 71 + 72 + DEFINE_EVENT(local_only_evt, 802154_drv_stop, 73 + TP_PROTO(struct ieee802154_local *local), 74 + TP_ARGS(local) 75 + ); 76 + 77 + TRACE_EVENT(802154_drv_set_channel, 78 + TP_PROTO(struct ieee802154_local *local, u8 page, u8 channel), 79 + TP_ARGS(local, page, channel), 80 + TP_STRUCT__entry( 81 + LOCAL_ENTRY 82 + __field(u8, page) 83 + __field(u8, channel) 84 + ), 85 + TP_fast_assign( 86 + LOCAL_ASSIGN; 87 + __entry->page = page; 88 + __entry->channel = channel; 89 + ), 90 + TP_printk(LOCAL_PR_FMT ", page: %d, channel: %d", LOCAL_PR_ARG, 91 + __entry->page, __entry->channel) 92 + ); 93 + 94 + TRACE_EVENT(802154_drv_set_cca_mode, 95 + TP_PROTO(struct ieee802154_local *local, 96 + const struct wpan_phy_cca *cca), 97 + TP_ARGS(local, cca), 98 + TP_STRUCT__entry( 99 + LOCAL_ENTRY 100 + CCA_ENTRY 101 + ), 102 + TP_fast_assign( 103 + LOCAL_ASSIGN; 104 + CCA_ASSIGN; 105 + ), 106 + TP_printk(LOCAL_PR_FMT ", " CCA_PR_FMT, LOCAL_PR_ARG, 107 + CCA_PR_ARG) 108 + ); 109 + 110 + TRACE_EVENT(802154_drv_set_cca_ed_level, 111 + TP_PROTO(struct ieee802154_local *local, s32 mbm), 112 + TP_ARGS(local, mbm), 113 + TP_STRUCT__entry( 114 + LOCAL_ENTRY 115 + __field(s32, mbm) 116 + ), 117 + TP_fast_assign( 118 + LOCAL_ASSIGN; 119 + __entry->mbm = mbm; 120 + ), 121 + TP_printk(LOCAL_PR_FMT ", ed level: %d", LOCAL_PR_ARG, 122 + __entry->mbm) 123 + ); 124 + 125 + TRACE_EVENT(802154_drv_set_tx_power, 126 + TP_PROTO(struct ieee802154_local *local, s32 power), 127 + TP_ARGS(local, power), 128 + TP_STRUCT__entry( 129 + LOCAL_ENTRY 130 + __field(s32, power) 131 + ), 132 + TP_fast_assign( 133 + LOCAL_ASSIGN; 134 + __entry->power = power; 135 + ), 136 + TP_printk(LOCAL_PR_FMT ", mbm: %d", LOCAL_PR_ARG, 137 + __entry->power) 138 + ); 139 + 140 + TRACE_EVENT(802154_drv_set_lbt_mode, 141 + TP_PROTO(struct ieee802154_local *local, bool mode), 142 + TP_ARGS(local, mode), 143 + TP_STRUCT__entry( 144 + LOCAL_ENTRY 145 + __field(bool, mode) 146 + ), 147 + TP_fast_assign( 148 + LOCAL_ASSIGN; 149 + __entry->mode = mode; 150 + ), 151 + TP_printk(LOCAL_PR_FMT ", lbt mode: %s", LOCAL_PR_ARG, 152 + BOOL_TO_STR(__entry->mode)) 153 + ); 154 + 155 + TRACE_EVENT(802154_drv_set_short_addr, 156 + TP_PROTO(struct ieee802154_local *local, __le16 short_addr), 157 + TP_ARGS(local, short_addr), 158 + TP_STRUCT__entry( 159 + LOCAL_ENTRY 160 + __field(__le16, short_addr) 161 + ), 162 + TP_fast_assign( 163 + LOCAL_ASSIGN; 164 + __entry->short_addr = short_addr; 165 + ), 166 + TP_printk(LOCAL_PR_FMT ", short addr: 0x%04x", LOCAL_PR_ARG, 167 + le16_to_cpu(__entry->short_addr)) 168 + ); 169 + 170 + TRACE_EVENT(802154_drv_set_pan_id, 171 + TP_PROTO(struct ieee802154_local *local, __le16 pan_id), 172 + TP_ARGS(local, pan_id), 173 + TP_STRUCT__entry( 174 + LOCAL_ENTRY 175 + __field(__le16, pan_id) 176 + ), 177 + TP_fast_assign( 178 + LOCAL_ASSIGN; 179 + __entry->pan_id = pan_id; 180 + ), 181 + TP_printk(LOCAL_PR_FMT ", pan id: 0x%04x", LOCAL_PR_ARG, 182 + le16_to_cpu(__entry->pan_id)) 183 + ); 184 + 185 + TRACE_EVENT(802154_drv_set_extended_addr, 186 + TP_PROTO(struct ieee802154_local *local, __le64 extended_addr), 187 + TP_ARGS(local, extended_addr), 188 + TP_STRUCT__entry( 189 + LOCAL_ENTRY 190 + __field(__le64, extended_addr) 191 + ), 192 + TP_fast_assign( 193 + LOCAL_ASSIGN; 194 + __entry->extended_addr = extended_addr; 195 + ), 196 + TP_printk(LOCAL_PR_FMT ", extended addr: 0x%llx", LOCAL_PR_ARG, 197 + le64_to_cpu(__entry->extended_addr)) 198 + ); 199 + 200 + TRACE_EVENT(802154_drv_set_pan_coord, 201 + TP_PROTO(struct ieee802154_local *local, bool is_coord), 202 + TP_ARGS(local, is_coord), 203 + TP_STRUCT__entry( 204 + LOCAL_ENTRY 205 + __field(bool, is_coord) 206 + ), 207 + TP_fast_assign( 208 + LOCAL_ASSIGN; 209 + __entry->is_coord = is_coord; 210 + ), 211 + TP_printk(LOCAL_PR_FMT ", is_coord: %s", LOCAL_PR_ARG, 212 + BOOL_TO_STR(__entry->is_coord)) 213 + ); 214 + 215 + TRACE_EVENT(802154_drv_set_csma_params, 216 + TP_PROTO(struct ieee802154_local *local, u8 min_be, u8 max_be, 217 + u8 max_csma_backoffs), 218 + TP_ARGS(local, min_be, max_be, max_csma_backoffs), 219 + TP_STRUCT__entry( 220 + LOCAL_ENTRY 221 + __field(u8, min_be) 222 + __field(u8, max_be) 223 + __field(u8, max_csma_backoffs) 224 + ), 225 + TP_fast_assign( 226 + LOCAL_ASSIGN, 227 + __entry->min_be = min_be; 228 + __entry->max_be = max_be; 229 + __entry->max_csma_backoffs = max_csma_backoffs; 230 + ), 231 + TP_printk(LOCAL_PR_FMT ", min be: %d, max be: %d, max csma backoffs: %d", 232 + LOCAL_PR_ARG, __entry->min_be, __entry->max_be, 233 + __entry->max_csma_backoffs) 234 + ); 235 + 236 + TRACE_EVENT(802154_drv_set_max_frame_retries, 237 + TP_PROTO(struct ieee802154_local *local, s8 max_frame_retries), 238 + TP_ARGS(local, max_frame_retries), 239 + TP_STRUCT__entry( 240 + LOCAL_ENTRY 241 + __field(s8, max_frame_retries) 242 + ), 243 + TP_fast_assign( 244 + LOCAL_ASSIGN; 245 + __entry->max_frame_retries = max_frame_retries; 246 + ), 247 + TP_printk(LOCAL_PR_FMT ", max frame retries: %d", LOCAL_PR_ARG, 248 + __entry->max_frame_retries) 249 + ); 250 + 251 + TRACE_EVENT(802154_drv_set_promiscuous_mode, 252 + TP_PROTO(struct ieee802154_local *local, bool on), 253 + TP_ARGS(local, on), 254 + TP_STRUCT__entry( 255 + LOCAL_ENTRY 256 + __field(bool, on) 257 + ), 258 + TP_fast_assign( 259 + LOCAL_ASSIGN; 260 + __entry->on = on; 261 + ), 262 + TP_printk(LOCAL_PR_FMT ", promiscuous mode: %s", LOCAL_PR_ARG, 263 + BOOL_TO_STR(__entry->on)) 264 + ); 265 + 266 + #endif /* !__MAC802154_DRIVER_TRACE || TRACE_HEADER_MULTI_READ */ 267 + 268 + #undef TRACE_INCLUDE_PATH 269 + #define TRACE_INCLUDE_PATH . 270 + #undef TRACE_INCLUDE_FILE 271 + #define TRACE_INCLUDE_FILE trace 272 + #include <trace/define_trace.h>