ath6kl: tracing support
v2 cover ath6kl: tracing support
Second version of the tracing support to ath6kl. Changes based on Johannes' comments.
v2:
o simplify sdio trace calls so that their overhead is smaller when tracing is disabled
o add ath6kl_sdio_scat for scatter gather
o uninline ath6kl_info/warn/err() functions, fixes a compilation warning
---
Kalle Valo (7):
ath6kl: add tracing support and tracing points for wmi packets
ath6kl: add tracing points for sdio transfers
ath6kl: add tracing point for hif irqs
ath6kl: adding tracing points for htc_mbox
ath6kl: convert ath6kl_info/err/warn macros to real functions
ath6kl: add tracing support to log functions
ath6kl: add tracing support to debug message macros
drivers/net/wireless/ath/ath6kl/Kconfig | 9 + drivers/net/wireless/ath/ath6kl/Makefile | 5 drivers/net/wireless/ath/ath6kl/debug.c | 66 +++++- drivers/net/wireless/ath/ath6kl/debug.h | 11 - drivers/net/wireless/ath/ath6kl/hif.c | 3 drivers/net/wireless/ath/ath6kl/htc_mbox.c | 21 ++ drivers/net/wireless/ath/ath6kl/sdio.c | 10 + drivers/net/wireless/ath/ath6kl/trace.c | 23 ++ drivers/net/wireless/ath/ath6kl/trace.h | 332 ++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath6kl/txrx.c | 3 drivers/net/wireless/ath/ath6kl/wmi.c | 3 11 files changed, 474 insertions(+), 12 deletions(-) create mode 100644 drivers/net/wireless/ath/ath6kl/trace.c create mode 100644 drivers/net/wireless/ath/ath6kl/trace.h
PATCH v2 1/7 ath6kl: add tracing support and tracing points for wmi packets
Add basic tracing infrastructure support to ath6kl and which can be enabled with CONFIG_ATH6KL_TRACING.
--- drivers/net/wireless/ath/ath6kl/Kconfig | 9 +++ drivers/net/wireless/ath/ath6kl/Makefile | 5 ++ drivers/net/wireless/ath/ath6kl/trace.c | 18 ++++++ drivers/net/wireless/ath/ath6kl/trace.h | 87 ++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath6kl/txrx.c | 3 + drivers/net/wireless/ath/ath6kl/wmi.c | 3 + 6 files changed, 125 insertions(+) create mode 100644 drivers/net/wireless/ath/ath6kl/trace.c create mode 100644 drivers/net/wireless/ath/ath6kl/trace.h
drivers/net/wireless/ath/ath6kl/Kconfig +9 -0
@@ -30,6 +30,15 @@ config ATH6KL_DEBUG ---help--- Enables debug support +config ATH6KL_TRACING + bool "Atheros ath6kl tracing support" + depends on ATH6KL + depends on EVENT_TRACING + ---help--- + Select this to ath6kl use tracing infrastructure. + + If unsure, say Y to make it easier to debug problems. + config ATH6KL_REGDOMAIN bool "Atheros ath6kl regdomain support" depends on ATH6KL
drivers/net/wireless/ath/ath6kl/Makefile +5 -0
@@ -35,10 +35,15 @@ ath6kl_core-y += txrx.o ath6kl_core-y += wmi.o ath6kl_core-y += core.o ath6kl_core-y += recovery.o + ath6kl_core-$(CONFIG_NL80211_TESTMODE) += testmode.o +ath6kl_core-$(CONFIG_ATH6KL_TRACING) += trace.o obj-$(CONFIG_ATH6KL_SDIO) += ath6kl_sdio.o ath6kl_sdio-y += sdio.o obj-$(CONFIG_ATH6KL_USB) += ath6kl_usb.o ath6kl_usb-y += usb.o + +# for tracing framework to find trace.h +CFLAGS_trace.o := -I$(src)
drivers/net/wireless/ath/ath6kl/trace.c new file +18 -0
@@ -0,0 +1,18 @@ +/* +* Copyright (c) 2012 Qualcomm Atheros, Inc. +* +* Permission to use, copy, modify, and/or distribute this software for any +* purpose with or without fee is hereby granted, provided that the above +* copyright notice and this permission notice appear in all copies. +* +* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#define CREATE_TRACE_POINTS +#include "trace.h"
drivers/net/wireless/ath/ath6kl/trace.h new file +87 -0
87 lines not on this page · raw message
drivers/net/wireless/ath/ath6kl/txrx.c +3 -0
@@ -20,6 +20,7 @@#include "core.h" #include "debug.h" #include "htc-ops.h" +#include "trace.h" /* * tid - tid_mux0..tid_mux3
@@ -288,6 +289,8 @@ int ath6kl_control_tx(void *devt, struct sk_buff *skb,int status =0 ;struct ath6kl_cookie *cookie =NULL ; +trace_ath6kl_wmi_cmd (skb->data, skb->len); +if (WARN_ON_ONCE (ar->state ==ATH6KL_STATE_WOW )) {dev_kfree_skb (skb);return -EACCES ;
drivers/net/wireless/ath/ath6kl/wmi.c +3 -0
@@ -20,6 +20,7 @@#include "core.h" #include "debug.h" #include "testmode.h" +#include "trace.h" #include "../regd.h" #include "../regd_common.h"
@@ -4086,6 +4087,8 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb)return -EINVAL ; } +trace_ath6kl_wmi_event (skb->data, skb->len); +return ath6kl_wmi_proc_events (wmi, skb); }
PATCH v2 2/7 ath6kl: add tracing points for sdio transfers
In reply to Kalle ValoAdd tracing points for sdio transfers, just dump the address, flags and the buffer.
--- drivers/net/wireless/ath/ath6kl/sdio.c | 10 +++ drivers/net/wireless/ath/ath6kl/trace.c | 5 ++ drivers/net/wireless/ath/ath6kl/trace.h | 90 +++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+)
drivers/net/wireless/ath/ath6kl/sdio.c +10 -0
@@ -28,6 +28,7 @@#include "target.h" #include "debug.h" #include "cfg80211.h" +#include "trace.h" struct ath6kl_sdio {struct sdio_func *func;
@@ -179,6 +180,8 @@ static int ath6kl_sdio_io(struct sdio_func *func, u32 request, u32 addr, request & HIF_FIXED_ADDRESS ? " (fixed)" : "", buf, len);ath6kl_dbg_dump (ATH6KL_DBG_SDIO_DUMP ,NULL ,"sdio " , buf, len); +trace_ath6kl_sdio (addr, request, buf, len); +return ret; }
@@ -309,6 +312,13 @@ static int ath6kl_sdio_scat_rw(struct ath6kl_sdio *ar_sdio,sdio_claim_host (ar_sdio->func);mmc_set_data_timeout (&data, ar_sdio->func->card); + +trace_ath6kl_sdio_scat (scat_req->addr, + scat_req->req, + scat_req->len, + scat_req->scat_entries, + scat_req->scat_list); +/* synchronous call to process request */ mmc_wait_for_req (ar_sdio->func->card->host, &mmc_req);
drivers/net/wireless/ath/ath6kl/trace.c +5 -0
@@ -14,5 +14,10 @@* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <linux/module.h> +#define CREATE_TRACE_POINTS #include "trace.h" + +EXPORT_TRACEPOINT_SYMBOL (ath6kl_sdio); +EXPORT_TRACEPOINT_SYMBOL (ath6kl_sdio_scat);
drivers/net/wireless/ath/ath6kl/trace.h +90 -0
102 lines not on this page · raw message
PATCH v2 3/7 ath6kl: add tracing point for hif irqs
In reply to Kalle ValoAdd a tracing point for hif irq and dump the register content to user space. This is in hif.c as we could use the same code also with SPI but, as ath6kl doesn't SPI and most likely never will be, this is used just by SDIO so name the trace point as ath6kl_sdio_irq to make it easier to manage filters.
--- drivers/net/wireless/ath/ath6kl/hif.c | 3 +++ drivers/net/wireless/ath/ath6kl/trace.h | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+)
drivers/net/wireless/ath/ath6kl/hif.c +3 -0
@@ -22,6 +22,7 @@#include "target.h" #include "hif-ops.h" #include "debug.h" +#include "trace.h" #define MAILBOX_FOR_BLOCK_SIZE 1
@@ -436,6 +437,8 @@ static int proc_pending_irqs(struct ath6kl_device *dev, bool *done)ath6kl_dump_registers (dev, &dev->irq_proc_reg, &dev->irq_en_reg); +trace_ath6kl_sdio_irq (&dev->irq_en_reg, +sizeof (dev->irq_en_reg));/* Update only those registers that are enabled */ host_int_status = dev->irq_proc_reg.host_int_status &
drivers/net/wireless/ath/ath6kl/trace.h +20 -0
@@ -165,6 +165,26 @@ TRACE_EVENT(ath6kl_sdio_scat, ) ); +TRACE_EVENT (ath6kl_sdio_irq, + TP_PROTO(void *buf, size_t buf_len), + +TP_ARGS (buf, buf_len), + +TP_STRUCT__entry ( + __field(size_t, buf_len) +__dynamic_array (u8, buf, buf_len) + ), + +TP_fast_assign ( + __entry->buf_len = buf_len; + memcpy(__get_dynamic_array(buf), buf, buf_len); + ), + +TP_printk ( +"irq len %d\n" , __entry->buf_len + ) +); +#endif /* _ ATH6KL_TRACE_H || TRACE_HEADER_MULTI_READ*/ /* we don't want to use include/trace/events */
PATCH v2 4/7 ath6kl: adding tracing points for htc_mbox
In reply to Kalle ValoAdd tracing points for htc layer, just dumping the packets to user space. I wasn't really sure what to do with the status value, it might not always be accurate, but I included it anyway.
I skipped htc_pipe (and usb) implementation for now. Need to add those tracepoints later.
--- drivers/net/wireless/ath/ath6kl/htc_mbox.c | 21 ++++++++++- drivers/net/wireless/ath/ath6kl/trace.h | 56 ++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath6kl/htc_mbox.c +20 -1
@@ -19,6 +19,8 @@#include "hif.h" #include "debug.h" #include "hif-ops.h" +#include "trace.h" +#include <asm/unaligned.h> #define CALC_TXRX_PADDED_LEN (dev, len) (__ALIGN_MASK((len), (dev)->block_mask))
@@ -537,6 +539,8 @@ static int ath6kl_htc_tx_issue(struct htc_target *target, packet->buf, padded_len, HIF_WR_ASYNC_BLOCK_INC, packet); +trace_ath6kl_htc_tx (status, packet->endpoint, packet->buf, send_len); +return status; }
@@ -757,7 +761,8 @@ static void ath6kl_htc_tx_bundle(struct htc_endpoint *endpoint, {struct htc_target *target = endpoint->target;struct hif_scatter_req *scat_req =NULL ; -int n_scat, n_sent_bundle =0 , tot_pkts_bundle =0 ; +int n_scat, n_sent_bundle =0 , tot_pkts_bundle =0 , i; +struct htc_packet *packet;int status;u32 txb_mask;u8 ac =WMM_NUM_AC ;
@@ -832,6 +837,13 @@ static void ath6kl_htc_tx_bundle(struct htc_endpoint *endpoint,ath6kl_dbg (ATH6KL_DBG_HTC ,"htc tx scatter bytes %d entries %d\n" , scat_req->len, scat_req->scat_entries); + +for (i =0 ; i < scat_req->scat_entries; i++) { + packet = scat_req->scat_list[i].packet; +trace_ath6kl_htc_tx (packet->status, packet->endpoint, + packet->buf, packet->act_len); + } +ath6kl_hif_submit_scat_req (target->dev, scat_req, false);if (status)
@@ -1903,6 +1915,7 @@ static void ath6kl_htc_rx_complete(struct htc_endpoint *endpoint,ath6kl_dbg (ATH6KL_DBG_HTC ,"htc rx complete ep %d packet 0x%p\n" , endpoint->eid, packet); + endpoint->ep_cb.rx (endpoint->target, packet); }
@@ -2011,6 +2024,9 @@ static int ath6kl_htc_rx_process_packets(struct htc_target *target,list_for_each_entry_safe (packet, tmp_pkt, comp_pktq, list) { ep = &target->endpoint[packet->endpoint]; +trace_ath6kl_htc_rx (packet->status, packet->endpoint, + packet->buf, packet->act_len); +/* process header for each of the recv packet */ status =ath6kl_htc_rx_process_hdr (target, packet, lk_ahds, n_lk_ahd);
@@ -2291,6 +2307,9 @@ static struct htc_packet *htc_wait_for_ctrl_msg(struct htc_target *target)if (ath6kl_htc_rx_packet (target, packet, packet->act_len)) goto fail_ctrl_rx; +trace_ath6kl_htc_rx (packet->status, packet->endpoint, + packet->buf, packet->act_len); +/* process receive header */ packet->status =ath6kl_htc_rx_process_hdr (target, packet,NULL ,NULL );
drivers/net/wireless/ath/ath6kl/trace.h +56 -0
62 lines not on this page · raw message
PATCH v2 5/7 ath6kl: convert ath6kl_info/err/warn macros to real functions
In reply to Kalle ValoAfter this it's cleaner to add trace calls.
--- drivers/net/wireless/ath/ath6kl/debug.c | 51 +++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath6kl/debug.h | 10 ++---- 2 files changed, 54 insertions(+), 7 deletions(-)
drivers/net/wireless/ath/ath6kl/debug.c +51 -0
@@ -56,6 +56,57 @@ int ath6kl_printk(const char *level, const char *fmt, ...) }EXPORT_SYMBOL (ath6kl_printk); +int ath6kl_info (const char *fmt, ...) +{ +struct va_format vaf = { + .fmt = fmt, + }; +va_list args; +int ret; + +va_start (args, fmt); + vaf.va = &args; + ret =ath6kl_printk (KERN_INFO ,"%pV" , &vaf); +va_end (args); + +return ret; +} +EXPORT_SYMBOL (ath6kl_info); + +int ath6kl_err (const char *fmt, ...) +{ +struct va_format vaf = { + .fmt = fmt, + }; +va_list args; +int ret; + +va_start (args, fmt); + vaf.va = &args; + ret =ath6kl_printk (KERN_ERR ,"%pV" , &vaf); +va_end (args); + +return ret; +} +EXPORT_SYMBOL (ath6kl_err); + +int ath6kl_warn (const char *fmt, ...) +{ +struct va_format vaf = { + .fmt = fmt, + }; +va_list args; +int ret; + +va_start (args, fmt); + vaf.va = &args; + ret =ath6kl_printk (KERN_WARNING ,"%pV" , &vaf); +va_end (args); + +return ret; +} +EXPORT_SYMBOL (ath6kl_warn); +#ifdef CONFIG_ATH6KL_DEBUG void ath6kl_dbg (enum ATH6K_DEBUG_MASK mask,const char *fmt, ...)
drivers/net/wireless/ath/ath6kl/debug.h +3 -7
@@ -51,13 +51,9 @@ enum ATH6K_DEBUG_MASK {extern unsigned int debug_mask; extern __printf(2, 3) int ath6kl_printk(const char *level, const char *fmt, ...); - -#define ath6kl_info(fmt, ...) \ - ath6kl_printk(KERN_INFO, fmt, ##__VA_ARGS__) -#define ath6kl_err(fmt, ...) \ - ath6kl_printk(KERN_ERR, fmt, ##__VA_ARGS__) -#define ath6kl_warn(fmt, ...) \ - ath6kl_printk(KERN_WARNING, fmt, ##__VA_ARGS__) +extern __printf(1,2) int ath6kl_info(const char *fmt, ...); +extern __printf(1,2) int ath6kl_err(const char *fmt, ...); +extern __printf(1,2) int ath6kl_warn(const char *fmt, ...); enum ath6kl_war { ATH6KL_WAR_INVALID_RATE,
PATCH v2 6/7 ath6kl: add tracing support to log functions
In reply to Kalle ValoAll log messages are now sent through tracing interface as well if ATH6KL_TRACING is enabled.
--- drivers/net/wireless/ath/ath6kl/debug.c | 3 +++ drivers/net/wireless/ath/ath6kl/debug.h | 1 + drivers/net/wireless/ath/ath6kl/trace.h | 37 +++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+)
drivers/net/wireless/ath/ath6kl/debug.c +3 -0
@@ -67,6 +67,7 @@ int ath6kl_info(const char *fmt, ...)va_start (args, fmt); vaf.va = &args; ret =ath6kl_printk (KERN_INFO ,"%pV" , &vaf); +trace_ath6kl_log_info (&vaf);va_end (args);return ret;
@@ -84,6 +85,7 @@ int ath6kl_err(const char *fmt, ...)va_start (args, fmt); vaf.va = &args; ret =ath6kl_printk (KERN_ERR ,"%pV" , &vaf); +trace_ath6kl_log_err (&vaf);va_end (args);return ret;
@@ -101,6 +103,7 @@ int ath6kl_warn(const char *fmt, ...)va_start (args, fmt); vaf.va = &args; ret =ath6kl_printk (KERN_WARNING ,"%pV" , &vaf); +trace_ath6kl_log_warn (&vaf);va_end (args);return ret;
drivers/net/wireless/ath/ath6kl/debug.h +1 -0
@@ -19,6 +19,7 @@#define DEBUG_H #include "hif.h" +#include "trace.h" enum ATH6K_DEBUG_MASK {ATH6KL_DBG_CREDIT =BIT (0 ),
drivers/net/wireless/ath/ath6kl/trace.h +37 -0
@@ -25,6 +25,11 @@ static inline unsigned int ath6kl_get_wmi_id(void *buf, size_t buf_len)#undef TRACE_EVENT#define TRACE_EVENT (name, proto, ...) \ static inline void trace_ ## name(proto) {} +#undef DECLARE_EVENT_CLASS +#define DECLARE_EVENT_CLASS (...) +#undef DEFINE_EVENT +#define DEFINE_EVENT (evt_class, name, proto, ...) \ +static inline void trace_ ## name(proto) {}#endif /* !CONFIG_ATH6KL_TRACING || __CHECKER__ */ #undef TRACE_SYSTEM
@@ -241,6 +246,38 @@ TRACE_EVENT(ath6kl_htc_tx, ) ); +#define ATH6KL_MSG_MAX 200 + +DECLARE_EVENT_CLASS (ath6kl_log_event, + TP_PROTO(struct va_format *vaf), +TP_ARGS (vaf), +TP_STRUCT__entry ( +__dynamic_array (char, msg,ATH6KL_MSG_MAX ) + ), +TP_fast_assign ( +WARN_ON_ONCE (vsnprintf (__get_dynamic_array (msg), +ATH6KL_MSG_MAX , + vaf->fmt, + *vaf->va) >= ATH6KL_MSG_MAX); + ), +TP_printk ("%s" ,__get_str (msg)) +); + +DEFINE_EVENT (ath6kl_log_event, ath6kl_log_err, + TP_PROTO(struct va_format *vaf), +TP_ARGS (vaf) +); + +DEFINE_EVENT (ath6kl_log_event, ath6kl_log_warn, + TP_PROTO(struct va_format *vaf), +TP_ARGS (vaf) +); + +DEFINE_EVENT (ath6kl_log_event, ath6kl_log_info, + TP_PROTO(struct va_format *vaf), +TP_ARGS (vaf) +); +#endif /* _ ATH6KL_TRACE_H || TRACE_HEADER_MULTI_READ*/ /* we don't want to use include/trace/events */
PATCH v2 7/7 ath6kl: add tracing support to debug message macros
In reply to Kalle ValoNow all log messages are sent through the tracing infrastruture as well. Tracing point doesn't follow debug_mask module parameter, instead it sends all debug messages, so once you enable ath6kl_log_dbg tracing point you will get a lot of messages. Needs to be discussed if this is sensible or not. The overhead should be small enough and we anyway include debug level as well so it's easy to filter in user space.
I wasn't really sure what to do with ath6kl_dbg_dump() and for now decided that it also sends the buffer to user space. But most likely in the future ath6kl_dbg_dump() should go away in favor of using proper tracing points, but we will see.
--- drivers/net/wireless/ath/ath6kl/debug.c | 12 ++++++--- drivers/net/wireless/ath/ath6kl/trace.h | 42 +++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath6kl/debug.c +8 -4
@@ -117,15 +117,15 @@ void ath6kl_dbg(enum ATH6K_DEBUG_MASK mask, const char *fmt, ...)struct va_format vaf;va_list args; -if (!(debug_mask & mask)) -return ; -va_start (args, fmt); vaf.fmt = fmt; vaf.va = &args; -ath6kl_printk (KERN_DEBUG ,"%pV" , &vaf); +if (debug_mask & mask) +ath6kl_printk (KERN_DEBUG ,"%pV" , &vaf); + +trace_ath6kl_log_dbg (mask, &vaf);va_end (args); }
@@ -141,6 +141,10 @@ void ath6kl_dbg_dump(enum ATH6K_DEBUG_MASK mask,print_hex_dump_bytes (prefix,DUMP_PREFIX_OFFSET , buf, len); } + +/* tracing code doesn't like null strings :/ */ +trace_ath6kl_log_dbg_dump (msg ? msg :"" , prefix ? prefix :"" , + buf, len); }EXPORT_SYMBOL (ath6kl_dbg_dump);
drivers/net/wireless/ath/ath6kl/trace.h +42 -0
48 lines not on this page · raw message
Quoted 13 lines · Kalle Valo
Second version of the tracing support to ath6kl. Changes based on Johannes' comments.
v2:
o simplify sdio trace calls so that their overhead is smaller when tracing is disabled
o add
ath6kl_sdio_scatfor scatter gathero uninline ath6kl_info/warn/err() functions, fixes a compilation warning
---
Quoted 8 lines
Kalle Valo (7):
ath6kl: add tracing support and tracing points for wmi packets
ath6kl: add tracing points for sdio transfers
ath6kl: add tracing point for hif irqs
ath6kl: adding tracing points forhtc_mbox
ath6kl: convert ath6kl_info/err/warn macros to real functions
ath6kl: add tracing support to log functions
ath6kl: add tracing support to debug message macros
All seven applied. Fixed a small whitespace problem in patch 5 at the same time.
Signature · 1 line
Kalle Valo