mac80211: add hw 80211 encapsulation offloading support
Subsystems (2)
PATCH v10 1/2 mac80211: add hw 80211 encapsulation offloading support
This patch adds a new transmit path for hardware that supports 802.11 encapsulation offloading. In those cases 802.3 frames get passed directly to the driver allowing the hardware to handle the encapsulation. Some features such as monitor mode and TKIP would break when encapsulation offloading is enabled. If any of these get enabled, the code will alwyas fallback to the normal sw encapsulation data path.
The patch defines a secondary netdev_ops struct that the device gets assigned if 802.11 encap support is available and enabled. The driver needs to enable the support on a per vif basis if it finds that all pre-reqs are meet.
--- include/net/mac80211.h | 36 ++++++++ net/mac80211/debugfs.c | 1 + net/mac80211/ieee80211_i.h | 9 ++ net/mac80211/iface.c | 74 ++++++++++++++++ net/mac80211/key.c | 10 +++ net/mac80211/status.c | 74 ++++++++++++++++ net/mac80211/tx.c | 176 ++++++++++++++++++++++++++++++++++++- 7 files changed, 376 insertions(+), 4 deletions(-)
include/net/mac80211.h +36 -0
@@ -826,6 +826,7 @@ enum mac80211_tx_control_flags {IEEE80211_TX_CTRL_AMSDU =BIT (3 ),IEEE80211_TX_CTRL_FAST_XMIT =BIT (4 ),IEEE80211_TX_CTRL_SKIP_MPATH_LOOKUP =BIT (5 ), + IEEE80211_TX_CTRL_HW_80211_ENCAP = BIT(6), };/*
@@ -2302,6 +2303,9 @@ struct ieee80211_txq {* aggregating MPDUs with the same keyid, allowing mac80211 to keep Tx * A-MPDU sessions active while rekeying with Extended Key ID. * +* @IEEE80211_HW_SUPPORTS_80211_ENCAP: Hardware/driver supports 802.11 +* encap for data frames. +* * @NUM_IEEE80211_HW_FLAGS: number of hardware flags, used for sizing arrays */ enum ieee80211_hw_flags {
@@ -2354,6 +2358,7 @@ enum ieee80211_hw_flags {IEEE80211_HW_SUPPORTS_MULTI_BSSID ,IEEE80211_HW_SUPPORTS_ONLY_HE_MULTI_BSSID ,IEEE80211_HW_AMPDU_KEYBORDER_SUPPORT , +IEEE80211_HW_SUPPORTS_80211_ENCAP ,/* keep last, obviously */ NUM_IEEE80211_HW_FLAGS
@@ -4660,6 +4665,26 @@ static inline void ieee80211_tx_status_ni(struct ieee80211_hw *hw,void ieee80211_tx_status_irqsafe (struct ieee80211_hw *hw,struct sk_buff *skb); +/** +* ieee80211_tx_status_8023 - transmit status callback for 802.3 frame format +* +* Call this function for all transmitted data frames after their transmit +* completion. This callback should only be called for data frames which +* are are using driver's (or hardware's) offload capability of encap/decap +* 802.11 frames. +* +* This function may not be called in IRQ context. Calls to this function +* for a single hardware must be synchronized against each other and all +* calls in the same tx status family. +* +* @hw: the hardware the frame was transmitted by +* @vif: the interface for which the frame was transmitted +* @skb: the frame that was transmitted, owned by mac80211 after this call +*/ +void ieee80211_tx_status_8023 (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +struct sk_buff *skb); +/** * ieee80211_report_low_ack - report non-responding station *
@@ -6480,5 +6505,16 @@ u32 ieee80211_calc_rx_airtime(struct ieee80211_hw *hw,u32 ieee80211_calc_tx_airtime (struct ieee80211_hw *hw,struct ieee80211_tx_info *info,int len); +/** +* ieee80211_set_hw_80211_encap - enable hardware encapsulation offloading. +* +* This function is used to notify mac80211 that a vif can be passed raw 802.3. +* The driver needs to then handle the 802.11 encapsulation inside the hardware +* or firmware. +* +* @vif: &struct ieee80211_vif pointer from the add_interface callback. +* @enable: indicate if the feature should be turned on or off +*/ +bool ieee80211_set_hw_80211_encap (struct ieee80211_vif *vif,bool enable);#endif /* MAC80211_H */
net/mac80211/debugfs.c +1 -0
@@ -355,6 +355,7 @@ static const char *hw_flag_names[] = {FLAG (SUPPORTS_MULTI_BSSID ),FLAG (SUPPORTS_ONLY_HE_MULTI_BSSID ),FLAG (AMPDU_KEYBORDER_SUPPORT ), +FLAG (SUPPORTS_80211_ENCAP ), #undef FLAG };
net/mac80211/ieee80211_i.h +9 -0
@@ -984,6 +984,8 @@ struct ieee80211_sub_if_data { } debugfs;#endif +bool hw_80211_encap; +/* must be last, dynamically sized area in this! */ struct ieee80211_vif vif; };
@@ -1762,6 +1764,8 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev);netdev_tx_t ieee80211_subif_start_xmit (struct sk_buff *skb,struct net_device *dev); +netdev_tx_t ieee80211_subif_start_xmit_8023 (struct sk_buff *skb, +struct net_device *dev); void __ieee80211_subif_start_xmit(struct sk_buff *skb, struct net_device *dev, u32 info_flags,
@@ -1948,6 +1952,11 @@ void __ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, int tid, enum nl80211_band band, u32 txdata_flags); +/* sta_out needs to be checked for ERR_PTR() before using */ +int ieee80211_lookup_ra_sta (struct ieee80211_sub_if_data *sdata, +struct sk_buff *skb, +struct sta_info **sta_out); + static inline void ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, int tid,
net/mac80211/iface.c +74 -0
86 lines not on this page · raw message
net/mac80211/key.c +10 -0
@@ -177,6 +177,13 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key) } } +/* TKIP countermeasures don't work in encap offload mode */ +if (key->conf.cipher ==WLAN_CIPHER_SUITE_TKIP && + sdata->hw_80211_encap) { +sdata_dbg (sdata,"TKIP is not allowed in hw 80211 encap mode\n" ); +return -EINVAL ; + } + ret =drv_set_key (key->local,SET_KEY , sdata, sta ? &sta->sta :NULL , &key->conf);
@@ -203,6 +210,9 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key) key->conf.keyidx, sta ? sta->sta.addr : bcast_addr, ret); +if (sdata->hw_80211_encap) +return -EINVAL ; + out_unsupported:switch (key->conf.cipher) {case WLAN_CIPHER_SUITE_WEP40 :
net/mac80211/status.c +74 -0
80 lines not on this page · raw message
net/mac80211/tx.c +172 -4
212 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v10 2/2 ath10k: add tx hw 802.11 encapusaltion offloading support
This patch adds support for ethernet rxtx mode to the driver. The feature is enabled via a new module parameter. If enabled to driver will enable the feature on a per vif basis if all other requirements were met.
Testing on a IPQ4019 based hardware shows a increase in TCP throughput of ~20% when the feature is enabled.
--- drivers/net/wireless/ath/ath10k/core.c | 11 ++++ drivers/net/wireless/ath/ath10k/core.h | 3 + drivers/net/wireless/ath/ath10k/htt_tx.c | 24 +++++--- drivers/net/wireless/ath/ath10k/mac.c | 75 +++++++++++++++++++----- drivers/net/wireless/ath/ath10k/txrx.c | 11 +++- 5 files changed, 99 insertions(+), 25 deletions(-)
drivers/net/wireless/ath/ath10k/core.c +11 -0
@@ -34,6 +34,7 @@ static bool uart_print;static bool skip_otp;static bool rawmode;static bool fw_diag_log; +static bool ethernetmode;unsigned long ath10k_coredump_mask =BIT (ATH10K_FW_CRASH_DUMP_REGISTERS ) |BIT (ATH10K_FW_CRASH_DUMP_CE_DATA );
@@ -46,6 +47,7 @@ module_param(skip_otp, bool, 0644);module_param (rawmode, bool,0644 );module_param (fw_diag_log, bool,0644 );module_param_named (coredump_mask, ath10k_coredump_mask, ulong,0444 ); +module_param (ethernetmode, bool,0644 );MODULE_PARM_DESC (debug_mask,"Debugging mask" );MODULE_PARM_DESC (uart_print,"Uart target debugging" );
@@ -54,6 +56,7 @@ MODULE_PARM_DESC(cryptmode, "Crypto mode: 0-hardware, 1-software");MODULE_PARM_DESC (rawmode,"Use raw 802.11 frame datapath" );MODULE_PARM_DESC (coredump_mask,"Bitfield of what to include in firmware crash file" );MODULE_PARM_DESC (fw_diag_log,"Diag based fw log debugging" ); +MODULE_PARM_DESC (ethernetmode,"Use ethernet frame datapath" );static const struct ath10k_hw_params ath10k_hw_params_list[] = { {
@@ -3041,6 +3044,14 @@ static void ath10k_core_register_work(struct work_struct *work)/* peer stats are enabled by default */ set_bit (ATH10K_FLAG_PEER_STATS , &ar->dev_flags); +if (ethernetmode && rawmode) { +ath10k_err (ar,"ethernet and raw mode cannot co-exist\n" ); + status = -EINVAL ; + goto err; + } + + ar->ethernetmode = ethernetmode; + status =ath10k_core_probe_fw (ar);if (status) {ath10k_err (ar,"could not probe fw (%d)\n" , status);
drivers/net/wireless/ath/ath10k/core.h +3 -0
@@ -109,6 +109,7 @@ enum ath10k_skb_flags {ATH10K_SKB_F_MGMT =BIT (3 ),ATH10K_SKB_F_QOS =BIT (4 ),ATH10K_SKB_F_RAW_TX =BIT (5 ), + ATH10K_SKB_F_HW_80211_ENCAP = BIT(6), }; struct ath10k_skb_cb {
@@ -1220,6 +1221,8 @@ struct ath10k {struct ath10k_bus_params bus_param;struct completion peer_delete_done; +bool ethernetmode; +/* must be last */ u8 drv_priv[0 ]__aligned(sizeof(void *)) ; };
drivers/net/wireless/ath/ath10k/htt_tx.c +15 -9
@@ -1144,6 +1144,10 @@ static u8 ath10k_htt_tx_get_tid(struct sk_buff *skb, bool is_eth)struct ieee80211_hdr *hdr = (void *)skb->data;struct ath10k_skb_cb *cb =ATH10K_SKB_CB (skb); +/* Firmware takes care of tid classification for ethernet format */ +if (cb->flags &ATH10K_SKB_F_HW_80211_ENCAP ) +return skb->priority %IEEE80211_QOS_CTL_TID_MASK ; +if (!is_eth &&ieee80211_is_mgmt (hdr->frame_control))return HTT_DATA_TX_EXT_TID_MGMT ;else if (cb->flags &ATH10K_SKB_F_QOS )
@@ -1378,15 +1382,17 @@ static int ath10k_htt_tx_32(struct ath10k_htt *htt, txbuf_paddr = htt->txbuf.paddr + (sizeof (struct ath10k_htt_txbuf_32 ) * msdu_id); -if ((ieee80211_is_action (hdr->frame_control) || -ieee80211_is_deauth (hdr->frame_control) || -ieee80211_is_disassoc (hdr->frame_control)) && -ieee80211_has_protected (hdr->frame_control)) { -skb_put (msdu,IEEE80211_CCMP_MIC_LEN ); - }else if (!(skb_cb->flags &ATH10K_SKB_F_NO_HWCRYPT ) && - txmode ==ATH10K_HW_TXRX_RAW && -ieee80211_has_protected (hdr->frame_control)) { -skb_put (msdu,IEEE80211_CCMP_MIC_LEN ); +if (!(info->control.flags &IEEE80211_TX_CTRL_HW_80211_ENCAP )) { +if ((ieee80211_is_action (hdr->frame_control) || +ieee80211_is_deauth (hdr->frame_control) || +ieee80211_is_disassoc (hdr->frame_control)) && +ieee80211_has_protected (hdr->frame_control)) { +skb_put (msdu,IEEE80211_CCMP_MIC_LEN ); + }else if (!(skb_cb->flags &ATH10K_SKB_F_NO_HWCRYPT ) && + txmode ==ATH10K_HW_TXRX_RAW && +ieee80211_has_protected (hdr->frame_control)) { +skb_put (msdu,IEEE80211_CCMP_MIC_LEN ); + } } skb_cb->paddr = dma_map_single(dev, msdu->data, msdu->len,
drivers/net/wireless/ath/ath10k/mac.c +60 -15
157 lines not on this page · raw message
drivers/net/wireless/ath/ath10k/txrx.c +10 -1
@@ -50,6 +50,8 @@ int ath10k_txrx_tx_unref(struct ath10k_htt *htt,struct ath10k_skb_cb *skb_cb;struct ath10k_txq *artxq;struct sk_buff *msdu; +struct ieee80211_vif *vif; +u8 flags; ath10k_dbg(ar, ATH10K_DBG_HTT, "htt tx completion msdu_id %u status %d\n",
@@ -78,6 +80,9 @@ int ath10k_txrx_tx_unref(struct ath10k_htt *htt, artxq->num_fw_queued--; } + flags = skb_cb->flags; + vif = skb_cb->vif; +ath10k_htt_tx_free_msdu_id (htt, tx_done->msdu_id);ath10k_htt_tx_dec_pending (htt);if (htt->num_pending_tx ==0 )
@@ -123,7 +128,11 @@ int ath10k_txrx_tx_unref(struct ath10k_htt *htt, info->status.is_valid_ack_signal = true; } -ieee80211_tx_status (htt->ar->hw, msdu); +if (flags &ATH10K_SKB_F_HW_80211_ENCAP ) +ieee80211_tx_status_8023 (htt->ar->hw, vif, msdu); +else +ieee80211_tx_status (htt->ar->hw, msdu); +/* we do not own the msdu anymore */ return 0 ;
Signature · 1 line
2.20.1