Skip to content

Commit

Permalink
mac80211: enhance tracing
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johannes Berg authored and John W. Linville committed Apr 8, 2010
1 parent 403820e commit b5878a2
Show file tree
Hide file tree
Showing 8 changed files with 303 additions and 4 deletions.
8 changes: 4 additions & 4 deletions net/mac80211/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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.
8 changes: 8 additions & 0 deletions net/mac80211/agg-tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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;

Expand All @@ -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",
Expand Down
275 changes: 275 additions & 0 deletions net/mac80211/driver-trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -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),

Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions net/mac80211/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions net/mac80211/mlme.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
2 changes: 2 additions & 0 deletions net/mac80211/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/*
Expand Down
2 changes: 2 additions & 0 deletions net/mac80211/sta_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit b5878a2

Please sign in to comment.