Skip to content

Commit

Permalink
mac80211: add TX fastpath
Browse files Browse the repository at this point in the history
In order to speed up mac80211's TX path, add the "fast-xmit" cache
that will cache the data frame 802.11 header and other data to be
able to build the frame more quickly. This cache is rebuilt when
external triggers imply changes, but a lot of the checks done per
packet today are simplified away to the check for the cache.

There's also a more detailed description in the code.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  • Loading branch information
Johannes Berg committed Apr 22, 2015
1 parent a839e46 commit 17c18bf
Show file tree
Hide file tree
Showing 9 changed files with 480 additions and 3 deletions.
6 changes: 5 additions & 1 deletion include/net/mac80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -1796,6 +1796,10 @@ struct ieee80211_txq {
* the driver returns 1. This also forces the driver to advertise its
* supported cipher suites.
*
* @IEEE80211_HW_SUPPORT_FAST_XMIT: The driver/hardware supports fast-xmit,
* this currently requires only the ability to calculate the duration
* for frames.
*
* @IEEE80211_HW_QUEUE_CONTROL: The driver wants to control per-interface
* queue mapping in order to use different queues (not just one per AC)
* for different virtual interfaces. See the doc section on HW queue
Expand Down Expand Up @@ -1844,7 +1848,7 @@ enum ieee80211_hw_flags {
IEEE80211_HW_WANT_MONITOR_VIF = 1<<14,
IEEE80211_HW_NO_AUTO_VIF = 1<<15,
IEEE80211_HW_SW_CRYPTO_CONTROL = 1<<16,
/* free slots */
IEEE80211_HW_SUPPORT_FAST_XMIT = 1<<17,
IEEE80211_HW_REPORTS_TX_ACK_STATUS = 1<<18,
IEEE80211_HW_CONNECTION_MONITOR = 1<<19,
IEEE80211_HW_QUEUE_CONTROL = 1<<20,
Expand Down
9 changes: 8 additions & 1 deletion net/mac80211/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ static int ieee80211_set_noack_map(struct wiphy *wiphy,
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);

sdata->noack_map = noack_map;

ieee80211_check_fast_xmit_iface(sdata);

return 0;
}

Expand Down Expand Up @@ -2099,10 +2102,14 @@ static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
int err;

if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
ieee80211_check_fast_xmit_all(local);

err = drv_set_frag_threshold(local, wiphy->frag_threshold);

if (err)
if (err) {
ieee80211_check_fast_xmit_all(local);
return err;
}
}

if ((changed & WIPHY_PARAM_COVERAGE_CLASS) ||
Expand Down
6 changes: 6 additions & 0 deletions net/mac80211/chan.c
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,8 @@ static int ieee80211_assign_vif_chanctx(struct ieee80211_sub_if_data *sdata,
ieee80211_bss_info_change_notify(sdata,
BSS_CHANGED_IDLE);

ieee80211_check_fast_xmit_iface(sdata);

return ret;
}

Expand Down Expand Up @@ -1030,6 +1032,8 @@ ieee80211_vif_use_reserved_reassign(struct ieee80211_sub_if_data *sdata)
if (sdata->vif.type == NL80211_IFTYPE_AP)
__ieee80211_vif_copy_chanctx_to_vlans(sdata, false);

ieee80211_check_fast_xmit_iface(sdata);

if (ieee80211_chanctx_refcount(local, old_ctx) == 0)
ieee80211_free_chanctx(local, old_ctx);

Expand Down Expand Up @@ -1376,6 +1380,8 @@ static int ieee80211_vif_use_reserved_switch(struct ieee80211_local *local)
__ieee80211_vif_copy_chanctx_to_vlans(sdata,
false);

ieee80211_check_fast_xmit_iface(sdata);

sdata->radar_required = sdata->reserved_radar_required;

if (sdata->vif.bss_conf.chandef.width !=
Expand Down
5 changes: 5 additions & 0 deletions net/mac80211/ieee80211_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -1651,6 +1651,11 @@ struct sk_buff *
ieee80211_build_data_template(struct ieee80211_sub_if_data *sdata,
struct sk_buff *skb, u32 info_flags);

void ieee80211_check_fast_xmit(struct sta_info *sta);
void ieee80211_check_fast_xmit_all(struct ieee80211_local *local);
void ieee80211_check_fast_xmit_iface(struct ieee80211_sub_if_data *sdata);
void ieee80211_clear_fast_xmit(struct sta_info *sta);

/* HT */
void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata,
struct ieee80211_sta_ht_cap *ht_cap);
Expand Down
2 changes: 2 additions & 0 deletions net/mac80211/key.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ static void __ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata,

if (uni) {
rcu_assign_pointer(sdata->default_unicast_key, key);
ieee80211_check_fast_xmit_iface(sdata);
drv_set_default_unicast_key(sdata->local, sdata, idx);
}

Expand Down Expand Up @@ -298,6 +299,7 @@ static void ieee80211_key_replace(struct ieee80211_sub_if_data *sdata,
if (pairwise) {
rcu_assign_pointer(sta->ptk[idx], new);
sta->ptk_idx = idx;
ieee80211_check_fast_xmit(sta);
} else {
rcu_assign_pointer(sta->gtk[idx], new);
sta->gtk_idx = idx;
Expand Down
2 changes: 2 additions & 0 deletions net/mac80211/rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,8 @@ static void sta_ps_start(struct sta_info *sta)
ps_dbg(sdata, "STA %pM aid %d enters power save mode\n",
sta->sta.addr, sta->sta.aid);

ieee80211_clear_fast_xmit(sta);

if (!sta->sta.txq[0])
return;

Expand Down
6 changes: 6 additions & 0 deletions net/mac80211/sta_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,8 @@ void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta)
ps_dbg(sdata,
"STA %pM aid %d sending %d filtered/%d PS frames since STA not sleeping anymore\n",
sta->sta.addr, sta->sta.aid, filtered, buffered);

ieee80211_check_fast_xmit(sta);
}

static void ieee80211_send_null_response(struct ieee80211_sub_if_data *sdata,
Expand Down Expand Up @@ -1599,6 +1601,7 @@ void ieee80211_sta_block_awake(struct ieee80211_hw *hw,

if (block) {
set_sta_flag(sta, WLAN_STA_PS_DRIVER);
ieee80211_clear_fast_xmit(sta);
return;
}

Expand All @@ -1616,6 +1619,7 @@ void ieee80211_sta_block_awake(struct ieee80211_hw *hw,
ieee80211_queue_work(hw, &sta->drv_deliver_wk);
} else {
clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
ieee80211_check_fast_xmit(sta);
}
}
EXPORT_SYMBOL(ieee80211_sta_block_awake);
Expand Down Expand Up @@ -1720,6 +1724,7 @@ int sta_info_move_state(struct sta_info *sta,
!sta->sdata->u.vlan.sta))
atomic_dec(&sta->sdata->bss->num_mcast_sta);
clear_bit(WLAN_STA_AUTHORIZED, &sta->_flags);
ieee80211_clear_fast_xmit(sta);
}
break;
case IEEE80211_STA_AUTHORIZED:
Expand All @@ -1729,6 +1734,7 @@ int sta_info_move_state(struct sta_info *sta,
!sta->sdata->u.vlan.sta))
atomic_inc(&sta->sdata->bss->num_mcast_sta);
set_bit(WLAN_STA_AUTHORIZED, &sta->_flags);
ieee80211_check_fast_xmit(sta);
}
break;
default:
Expand Down
27 changes: 27 additions & 0 deletions net/mac80211/sta_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,30 @@ struct sta_ampdu_mlme {
/* Value to indicate no TID reservation */
#define IEEE80211_TID_UNRESERVED 0xff

/**
* struct ieee80211_fast_tx - TX fastpath information
* @key: key to use for hw crypto
* @hdr: the 802.11 header to put with the frame
* @hdr_len: actual 802.11 header length
* @sa_offs: offset of the SA
* @da_offs: offset of the DA
* @pn_offs: offset where to put PN for crypto (or 0 if not needed)
* @band: band this will be transmitted on, for tx_info
* @rcu_head: RCU head to free this struct
*
* Try to keep this struct small so it fits into a single cacheline.
*/
struct ieee80211_fast_tx {
struct ieee80211_key *key;
u8 hdr[30 + 2 + IEEE80211_CCMP_HDR_LEN +
sizeof(rfc1042_header)];
u8 hdr_len;
u8 sa_offs, da_offs, pn_offs;
u8 band;

struct rcu_head rcu_head;
};

/**
* struct sta_info - STA information
*
Expand Down Expand Up @@ -339,6 +363,7 @@ struct sta_ampdu_mlme {
* using IEEE80211_NUM_TID entry for non-QoS frames
* @rx_msdu: MSDUs received from this station, using IEEE80211_NUM_TID
* entry for non-QoS frames
* @fast_tx: TX fastpath information
*/
struct sta_info {
/* General information, mostly static */
Expand All @@ -356,6 +381,8 @@ struct sta_info {
spinlock_t rate_ctrl_lock;
spinlock_t lock;

struct ieee80211_fast_tx __rcu *fast_tx;

struct work_struct drv_deliver_wk;

u16 listen_interval;
Expand Down
Loading

0 comments on commit 17c18bf

Please sign in to comment.