mac80211: enhance tracing
authorJohannes Berg <johannes@sipsolutions.net>
Wed, 7 Apr 2010 14:48:40 +0000 (16:48 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 8 Apr 2010 19:24:13 +0000 (15:24 -0400)
Enhance tracing by adding tracing for a variety of
callbacks that the drivers call, and also for
internal calls (currently limited to queue status).
This can aid debugging what is going on in mac80211
in interaction with drivers, since we can now see
what drivers call and not just what mac80211 calls
in the driver.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
net/mac80211/Kconfig
net/mac80211/agg-tx.c
net/mac80211/driver-trace.h
net/mac80211/main.c
net/mac80211/mlme.c
net/mac80211/scan.c
net/mac80211/sta_info.c
net/mac80211/util.c

index 334c359..8a91f6c 100644 (file)
@@ -221,8 +221,8 @@ config MAC80211_DRIVER_API_TRACER
        depends on EVENT_TRACING
        help
          Say Y here to make mac80211 register with the ftrace
-         framework for the driver API -- you can see which
-         driver methods it is calling then by looking at the
-         trace.
+         framework for the driver API -- you can then see which
+         driver methods it is calling and which API functions
+         drivers are calling by looking at the trace.
 
-         If unsure, say N.
+         If unsure, say Y.
index 32d2148..6bb4d0a 100644 (file)
@@ -214,6 +214,8 @@ int ieee80211_start_tx_ba_session(struct ieee80211_sta *pubsta, u16 tid)
        int ret = 0;
        u16 start_seq_num;
 
+       trace_api_start_tx_ba_session(pubsta, tid);
+
        if (WARN_ON(!local->ops->ampdu_action))
                return -EINVAL;
 
@@ -440,6 +442,8 @@ void ieee80211_start_tx_ba_cb(struct ieee80211_vif *vif, u8 *ra, u16 tid)
        struct sta_info *sta;
        u8 *state;
 
+       trace_api_start_tx_ba_cb(sdata, ra, tid);
+
        if (tid >= STA_TID_NUM) {
 #ifdef CONFIG_MAC80211_HT_DEBUG
                printk(KERN_DEBUG "Bad TID value: tid = %d (>= %d)\n",
@@ -541,6 +545,8 @@ int ieee80211_stop_tx_ba_session(struct ieee80211_sta *pubsta, u16 tid,
        struct ieee80211_sub_if_data *sdata = sta->sdata;
        struct ieee80211_local *local = sdata->local;
 
+       trace_api_stop_tx_ba_session(pubsta, tid, initiator);
+
        if (!local->ops->ampdu_action)
                return -EINVAL;
 
@@ -558,6 +564,8 @@ void ieee80211_stop_tx_ba_cb(struct ieee80211_vif *vif, u8 *ra, u8 tid)
        struct sta_info *sta;
        u8 *state;
 
+       trace_api_stop_tx_ba_cb(sdata, ra, tid);
+
        if (tid >= STA_TID_NUM) {
 #ifdef CONFIG_MAC80211_HT_DEBUG
                printk(KERN_DEBUG "Bad TID value: tid = %d (>= %d)\n",
index 41baf73..e209cb8 100644 (file)
@@ -32,6 +32,10 @@ static inline void trace_ ## name(proto) {}
 #define VIF_PR_FMT     " vif:%s(%d)"
 #define VIF_PR_ARG     __get_str(vif_name), __entry->vif_type
 
+/*
+ * Tracing for driver callbacks.
+ */
+
 TRACE_EVENT(drv_start,
        TP_PROTO(struct ieee80211_local *local, int ret),
 
@@ -766,6 +770,277 @@ TRACE_EVENT(drv_flush,
                LOCAL_PR_ARG, __entry->drop
        )
 );
+
+/*
+ * Tracing for API calls that drivers call.
+ */
+
+TRACE_EVENT(api_start_tx_ba_session,
+       TP_PROTO(struct ieee80211_sta *sta, u16 tid),
+
+       TP_ARGS(sta, tid),
+
+       TP_STRUCT__entry(
+               STA_ENTRY
+               __field(u16, tid)
+       ),
+
+       TP_fast_assign(
+               STA_ASSIGN;
+               __entry->tid = tid;
+       ),
+
+       TP_printk(
+               STA_PR_FMT " tid:%d",
+               STA_PR_ARG, __entry->tid
+       )
+);
+
+TRACE_EVENT(api_start_tx_ba_cb,
+       TP_PROTO(struct ieee80211_sub_if_data *sdata, const u8 *ra, u16 tid),
+
+       TP_ARGS(sdata, ra, tid),
+
+       TP_STRUCT__entry(
+               VIF_ENTRY
+               __array(u8, ra, ETH_ALEN)
+               __field(u16, tid)
+       ),
+
+       TP_fast_assign(
+               VIF_ASSIGN;
+               memcpy(__entry->ra, ra, ETH_ALEN);
+               __entry->tid = tid;
+       ),
+
+       TP_printk(
+               VIF_PR_FMT " ra:%pM tid:%d",
+               VIF_PR_ARG, __entry->ra, __entry->tid
+       )
+);
+
+TRACE_EVENT(api_stop_tx_ba_session,
+       TP_PROTO(struct ieee80211_sta *sta, u16 tid, u16 initiator),
+
+       TP_ARGS(sta, tid, initiator),
+
+       TP_STRUCT__entry(
+               STA_ENTRY
+               __field(u16, tid)
+               __field(u16, initiator)
+       ),
+
+       TP_fast_assign(
+               STA_ASSIGN;
+               __entry->tid = tid;
+               __entry->initiator = initiator;
+       ),
+
+       TP_printk(
+               STA_PR_FMT " tid:%d initiator:%d",
+               STA_PR_ARG, __entry->tid, __entry->initiator
+       )
+);
+
+TRACE_EVENT(api_stop_tx_ba_cb,
+       TP_PROTO(struct ieee80211_sub_if_data *sdata, const u8 *ra, u16 tid),
+
+       TP_ARGS(sdata, ra, tid),
+
+       TP_STRUCT__entry(
+               VIF_ENTRY
+               __array(u8, ra, ETH_ALEN)
+               __field(u16, tid)
+       ),
+
+       TP_fast_assign(
+               VIF_ASSIGN;
+               memcpy(__entry->ra, ra, ETH_ALEN);
+               __entry->tid = tid;
+       ),
+
+       TP_printk(
+               VIF_PR_FMT " ra:%pM tid:%d",
+               VIF_PR_ARG, __entry->ra, __entry->tid
+       )
+);
+
+TRACE_EVENT(api_restart_hw,
+       TP_PROTO(struct ieee80211_local *local),
+
+       TP_ARGS(local),
+
+       TP_STRUCT__entry(
+               LOCAL_ENTRY
+       ),
+
+       TP_fast_assign(
+               LOCAL_ASSIGN;
+       ),
+
+       TP_printk(
+               LOCAL_PR_FMT,
+               LOCAL_PR_ARG
+       )
+);
+
+TRACE_EVENT(api_beacon_loss,
+       TP_PROTO(struct ieee80211_sub_if_data *sdata),
+
+       TP_ARGS(sdata),
+
+       TP_STRUCT__entry(
+               VIF_ENTRY
+       ),
+
+       TP_fast_assign(
+               VIF_ASSIGN;
+       ),
+
+       TP_printk(
+               VIF_PR_FMT,
+               VIF_PR_ARG
+       )
+);
+
+TRACE_EVENT(api_connection_loss,
+       TP_PROTO(struct ieee80211_sub_if_data *sdata),
+
+       TP_ARGS(sdata),
+
+       TP_STRUCT__entry(
+               VIF_ENTRY
+       ),
+
+       TP_fast_assign(
+               VIF_ASSIGN;
+       ),
+
+       TP_printk(
+               VIF_PR_FMT,
+               VIF_PR_ARG
+       )
+);
+
+TRACE_EVENT(api_cqm_rssi_notify,
+       TP_PROTO(struct ieee80211_sub_if_data *sdata,
+                enum nl80211_cqm_rssi_threshold_event rssi_event),
+
+       TP_ARGS(sdata, rssi_event),
+
+       TP_STRUCT__entry(
+               VIF_ENTRY
+               __field(u32, rssi_event)
+       ),
+
+       TP_fast_assign(
+               VIF_ASSIGN;
+               __entry->rssi_event = rssi_event;
+       ),
+
+       TP_printk(
+               VIF_PR_FMT " event:%d",
+               VIF_PR_ARG, __entry->rssi_event
+       )
+);
+
+TRACE_EVENT(api_scan_completed,
+       TP_PROTO(struct ieee80211_local *local, bool aborted),
+
+       TP_ARGS(local, aborted),
+
+       TP_STRUCT__entry(
+               LOCAL_ENTRY
+               __field(bool, aborted)
+       ),
+
+       TP_fast_assign(
+               LOCAL_ASSIGN;
+               __entry->aborted = aborted;
+       ),
+
+       TP_printk(
+               LOCAL_PR_FMT " aborted:%d",
+               LOCAL_PR_ARG, __entry->aborted
+       )
+);
+
+TRACE_EVENT(api_sta_block_awake,
+       TP_PROTO(struct ieee80211_local *local,
+                struct ieee80211_sta *sta, bool block),
+
+       TP_ARGS(local, sta, block),
+
+       TP_STRUCT__entry(
+               LOCAL_ENTRY
+               STA_ENTRY
+               __field(bool, block)
+       ),
+
+       TP_fast_assign(
+               LOCAL_ASSIGN;
+               STA_ASSIGN;
+               __entry->block = block;
+       ),
+
+       TP_printk(
+               LOCAL_PR_FMT STA_PR_FMT " block:%d",
+               LOCAL_PR_ARG, STA_PR_FMT, __entry->block
+       )
+);
+
+/*
+ * Tracing for internal functions
+ * (which may also be called in response to driver calls)
+ */
+
+TRACE_EVENT(wake_queue,
+       TP_PROTO(struct ieee80211_local *local, u16 queue,
+                enum queue_stop_reason reason),
+
+       TP_ARGS(local, queue, reason),
+
+       TP_STRUCT__entry(
+               LOCAL_ENTRY
+               __field(u16, queue)
+               __field(u32, reason)
+       ),
+
+       TP_fast_assign(
+               LOCAL_ASSIGN;
+               __entry->queue = queue;
+               __entry->reason = reason;
+       ),
+
+       TP_printk(
+               LOCAL_PR_FMT " queue:%d, reason:%d",
+               LOCAL_PR_ARG, __entry->queue, __entry->reason
+       )
+);
+
+TRACE_EVENT(stop_queue,
+       TP_PROTO(struct ieee80211_local *local, u16 queue,
+                enum queue_stop_reason reason),
+
+       TP_ARGS(local, queue, reason),
+
+       TP_STRUCT__entry(
+               LOCAL_ENTRY
+               __field(u16, queue)
+               __field(u32, reason)
+       ),
+
+       TP_fast_assign(
+               LOCAL_ASSIGN;
+               __entry->queue = queue;
+               __entry->reason = reason;
+       ),
+
+       TP_printk(
+               LOCAL_PR_FMT " queue:%d, reason:%d",
+               LOCAL_PR_ARG, __entry->queue, __entry->reason
+       )
+);
 #endif /* !__MAC80211_DRIVER_TRACE || TRACE_HEADER_MULTI_READ */
 
 #undef TRACE_INCLUDE_PATH
index b887e48..4afe851 100644 (file)
@@ -309,6 +309,8 @@ void ieee80211_restart_hw(struct ieee80211_hw *hw)
 {
        struct ieee80211_local *local = hw_to_local(hw);
 
+       trace_api_restart_hw(local);
+
        /* use this reason, __ieee80211_resume will unblock it */
        ieee80211_stop_queues_by_reason(hw,
                IEEE80211_QUEUE_STOP_REASON_SUSPEND);
index 461167d..d11a54c 100644 (file)
@@ -1007,6 +1007,8 @@ void ieee80211_beacon_loss(struct ieee80211_vif *vif)
        struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
        struct ieee80211_hw *hw = &sdata->local->hw;
 
+       trace_api_beacon_loss(sdata);
+
        WARN_ON(hw->flags & IEEE80211_HW_CONNECTION_MONITOR);
        ieee80211_queue_work(hw, &sdata->u.mgd.beacon_connection_loss_work);
 }
@@ -1017,6 +1019,8 @@ void ieee80211_connection_loss(struct ieee80211_vif *vif)
        struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
        struct ieee80211_hw *hw = &sdata->local->hw;
 
+       trace_api_connection_loss(sdata);
+
        WARN_ON(!(hw->flags & IEEE80211_HW_CONNECTION_MONITOR));
        ieee80211_queue_work(hw, &sdata->u.mgd.beacon_connection_loss_work);
 }
@@ -2261,6 +2265,8 @@ void ieee80211_cqm_rssi_notify(struct ieee80211_vif *vif,
 {
        struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
 
+       trace_api_cqm_rssi_notify(sdata, rssi_event);
+
        cfg80211_cqm_rssi_notify(sdata->dev, rssi_event, gfp);
 }
 EXPORT_SYMBOL(ieee80211_cqm_rssi_notify);
index 75a8597..eb86a5f 100644 (file)
@@ -247,6 +247,8 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
        struct ieee80211_local *local = hw_to_local(hw);
        bool was_hw_scan;
 
+       trace_api_scan_completed(local, aborted);
+
        mutex_lock(&local->scan_mtx);
 
        /*
index 4de987c..ff0eb94 100644 (file)
@@ -957,6 +957,8 @@ void ieee80211_sta_block_awake(struct ieee80211_hw *hw,
 {
        struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
 
+       trace_api_sta_block_awake(sta->local, pubsta, block);
+
        if (block)
                set_sta_flags(sta, WLAN_STA_PS_DRIVER);
        else
index ad9009f..2b75b4f 100644 (file)
@@ -270,6 +270,8 @@ static void __ieee80211_wake_queue(struct ieee80211_hw *hw, int queue,
        struct ieee80211_local *local = hw_to_local(hw);
        struct ieee80211_sub_if_data *sdata;
 
+       trace_wake_queue(local, queue, reason);
+
        if (WARN_ON(queue >= hw->queues))
                return;
 
@@ -312,6 +314,8 @@ static void __ieee80211_stop_queue(struct ieee80211_hw *hw, int queue,
        struct ieee80211_local *local = hw_to_local(hw);
        struct ieee80211_sub_if_data *sdata;
 
+       trace_stop_queue(local, queue, reason);
+
        if (WARN_ON(queue >= hw->queues))
                return;