Lets make wifi fast again!
 help / color / mirror / Atom feed
From: Noah Causin <n0manletter@gmail.com>
To: make-wifi-fast@lists.bufferbloat.net
Subject: Re: [Make-wifi-fast] [PATCH v2] mac80211: Move crypto IV generation to after TXQ dequeue.
Date: Wed, 17 Aug 2016 11:47:13 -0400	[thread overview]
Message-ID: <7df7eed3-4d65-7953-81cd-af969060642a@gmail.com> (raw)
In-Reply-To: <20160817144531.4285-1-toke@toke.dk>

Hi,

Thank you and others for all the work you all have done.

I have a question:
How do I apply this to Felix Fietkaus's lede staging branch?

Thank you,

Noah Causin

On 8/17/2016 10:45 AM, Toke Høiland-Jørgensen wrote:
> The FQ portion of the intermediate queues will reorder packets, which
> means that crypto IV generation needs to happen after dequeue when they
> are enabled, or the receiver will throw packets away when receiving
> them.
>
> This fixes the performance regression introduced by enabling softq in
> ath9k.
>
> Cc: Felix Fietkau <nbd@nbd.name>
> Tested-by: Dave Taht <dave@taht.net>
> Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
> ---
> Changes since v1:
>    - Recalculate pn_offs when needed instead of storing it.
>
>   net/mac80211/sta_info.h |  3 +-
>   net/mac80211/tx.c       | 85 +++++++++++++++++++++++++++++++++++++------------
>   2 files changed, 66 insertions(+), 22 deletions(-)
>
> diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
> index 0556be3..c9d4d69 100644
> --- a/net/mac80211/sta_info.h
> +++ b/net/mac80211/sta_info.h
> @@ -266,7 +266,6 @@ struct sta_ampdu_mlme {
>    * @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
>    *
> @@ -277,7 +276,7 @@ struct sta_ampdu_mlme {
>   struct ieee80211_fast_tx {
>   	struct ieee80211_key *key;
>   	u8 hdr_len;
> -	u8 sa_offs, da_offs, pn_offs;
> +	u8 sa_offs, da_offs;
>   	u8 band;
>   	u8 hdr[30 + 2 + IEEE80211_FAST_XMIT_MAX_IV +
>   	       sizeof(rfc1042_header)] __aligned(2);
> diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
> index 1d0746d..9caf75f 100644
> --- a/net/mac80211/tx.c
> +++ b/net/mac80211/tx.c
> @@ -1074,6 +1074,64 @@ ieee80211_tx_h_calculate_duration(struct ieee80211_tx_data *tx)
>   	return TX_CONTINUE;
>   }
>   
> +static void ieee80211_gen_crypto_iv(struct ieee80211_key_conf *conf,
> +					   struct sta_info *sta, struct sk_buff *skb)
> +{
> +	struct ieee80211_sub_if_data *sdata;
> +	u64 pn;
> +	u8 *crypto_hdr;
> +	u8 pn_offs = 0;
> +
> +	if (!conf || !sta || !(conf->flags & IEEE80211_KEY_FLAG_GENERATE_IV))
> +		return;
> +
> +	sdata = sta->sdata;
> +
> +	switch (sdata->vif.type) {
> +	case NL80211_IFTYPE_STATION:
> +		if (sdata->u.mgd.use_4addr) {
> +			pn_offs = 30;
> +			break;
> +		}
> +		pn_offs = 24;
> +		break;
> +	case NL80211_IFTYPE_AP_VLAN:
> +		if (sdata->wdev.use_4addr) {
> +			pn_offs = 30;
> +			break;
> +		}
> +		/* fall through */
> +	case NL80211_IFTYPE_ADHOC:
> +	case NL80211_IFTYPE_AP:
> +		pn_offs = 24;
> +		break;
> +	default:
> +		return;
> +	}
> +
> +	if (sta->sta.wme) {
> +		pn_offs += 2;
> +	}
> +
> +	crypto_hdr = skb->data + pn_offs;
> +	switch (conf->cipher) {
> +	case WLAN_CIPHER_SUITE_CCMP:
> +	case WLAN_CIPHER_SUITE_CCMP_256:
> +	case WLAN_CIPHER_SUITE_GCMP:
> +	case WLAN_CIPHER_SUITE_GCMP_256:
> +		pn = atomic64_inc_return(&conf->tx_pn);
> +		crypto_hdr[0] = pn;
> +		crypto_hdr[1] = pn >> 8;
> +		crypto_hdr[4] = pn >> 16;
> +		crypto_hdr[5] = pn >> 24;
> +		crypto_hdr[6] = pn >> 32;
> +		crypto_hdr[7] = pn >> 40;
> +		break;
> +	}
> +}
> +
> +
> +
>   /* actual transmit path */
>   
>   static bool ieee80211_tx_prep_agg(struct ieee80211_tx_data *tx,
> @@ -1503,6 +1561,11 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,
>   						    sta);
>   		struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
>   
> +		if (info->control.hw_key) {
> +			ieee80211_gen_crypto_iv(info->control.hw_key,
> +			container_of(txq->sta, struct sta_info, sta), skb);
> +		}
> +
>   		hdr->seq_ctrl = ieee80211_tx_next_seq(sta, txq->tid);
>   		if (test_bit(IEEE80211_TXQ_AMPDU, &txqi->flags))
>   			info->flags |= IEEE80211_TX_CTL_AMPDU;
> @@ -2874,7 +2937,6 @@ void ieee80211_check_fast_xmit(struct sta_info *sta)
>   			if (gen_iv) {
>   				(build.hdr + build.hdr_len)[3] =
>   					0x20 | (build.key->conf.keyidx << 6);
> -				build.pn_offs = build.hdr_len;
>   			}
>   			if (gen_iv || iv_spc)
>   				build.hdr_len += IEEE80211_CCMP_HDR_LEN;
> @@ -2885,7 +2947,6 @@ void ieee80211_check_fast_xmit(struct sta_info *sta)
>   			if (gen_iv) {
>   				(build.hdr + build.hdr_len)[3] =
>   					0x20 | (build.key->conf.keyidx << 6);
> -				build.pn_offs = build.hdr_len;
>   			}
>   			if (gen_iv || iv_spc)
>   				build.hdr_len += IEEE80211_GCMP_HDR_LEN;
> @@ -3289,24 +3350,8 @@ static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata,
>   	sta->tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len;
>   	sta->tx_stats.packets[skb_get_queue_mapping(skb)]++;
>   
> -	if (fast_tx->pn_offs) {
> -		u64 pn;
> -		u8 *crypto_hdr = skb->data + fast_tx->pn_offs;
> -
> -		switch (fast_tx->key->conf.cipher) {
> -		case WLAN_CIPHER_SUITE_CCMP:
> -		case WLAN_CIPHER_SUITE_CCMP_256:
> -		case WLAN_CIPHER_SUITE_GCMP:
> -		case WLAN_CIPHER_SUITE_GCMP_256:
> -			pn = atomic64_inc_return(&fast_tx->key->conf.tx_pn);
> -			crypto_hdr[0] = pn;
> -			crypto_hdr[1] = pn >> 8;
> -			crypto_hdr[4] = pn >> 16;
> -			crypto_hdr[5] = pn >> 24;
> -			crypto_hdr[6] = pn >> 32;
> -			crypto_hdr[7] = pn >> 40;
> -			break;
> -		}
> +	if (fast_tx->key && !local->ops->wake_tx_queue) {
> +		ieee80211_gen_crypto_iv(&fast_tx->key->conf, sta, skb);
>   	}
>   
>   	if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)


  reply	other threads:[~2016-08-17 15:47 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-17 12:58 [Make-wifi-fast] [PATCH] " Toke Høiland-Jørgensen
2016-08-17 13:08 ` Johannes Berg
2016-08-17 13:16   ` Toke Høiland-Jørgensen
2016-08-17 13:18     ` Johannes Berg
2016-08-17 13:23       ` Toke Høiland-Jørgensen
2016-08-17 14:45 ` [Make-wifi-fast] [PATCH v2] " Toke Høiland-Jørgensen
2016-08-17 15:47   ` Noah Causin [this message]
2016-08-17 22:33     ` Toke Høiland-Jørgensen
2016-08-19  3:06       ` Noah Causin
2016-08-22 14:24         ` Toke Høiland-Jørgensen
2016-08-23 17:06           ` Noah Causin
2016-08-23 17:51             ` Toke Høiland-Jørgensen
2016-08-17 19:49   ` Johannes Berg
2016-08-17 20:07     ` Dave Taht
2016-08-17 20:43       ` Johannes Berg
2016-08-22 14:47         ` Toke Høiland-Jørgensen
2016-08-26  8:38           ` Johannes Berg
2016-08-26  8:54             ` Toke Høiland-Jørgensen
2016-08-24 16:20   ` [Make-wifi-fast] [PATCH v3] mac80211: Move reorder-sensitive TX handlers " Toke Høiland-Jørgensen
2016-08-24 22:40     ` Noah Causin
2016-08-25 12:45       ` Toke Høiland-Jørgensen
2016-08-26 14:30         ` Toke Høiland-Jørgensen
2016-08-26 14:51           ` Dave Taht
2016-08-30 13:15     ` [Make-wifi-fast] [PATCH v4] " Toke Høiland-Jørgensen
2016-08-30 13:17       ` Toke Høiland-Jørgensen
2016-08-31 21:06       ` Johannes Berg
2016-09-01  8:23         ` Toke Høiland-Jørgensen
2016-09-01  8:34           ` Johannes Berg
2016-09-01  8:38             ` Toke Høiland-Jørgensen
2016-09-01  9:07               ` Johannes Berg
2016-09-01  9:20                 ` Toke Høiland-Jørgensen
2016-09-01  9:27                   ` Johannes Berg
2016-09-01  9:42                     ` Toke Høiland-Jørgensen
2016-09-01 16:03       ` [Make-wifi-fast] [PATCH v5] " Toke Høiland-Jørgensen
2016-09-01 17:59         ` Johannes Berg
2016-09-01 18:30           ` Toke Høiland-Jørgensen
2016-09-01 18:35             ` Johannes Berg
2016-09-02  2:48         ` Jason Andryuk
2016-09-02  9:27           ` Toke Høiland-Jørgensen
2016-09-02 13:41         ` [Make-wifi-fast] [PATCH v6] " Toke Høiland-Jørgensen
2016-09-02 14:44           ` Toke Høiland-Jørgensen
2016-09-05 11:30           ` [Make-wifi-fast] [PATCH v7] " Toke Høiland-Jørgensen
2016-09-05 16:06             ` Toke Høiland-Jørgensen
2016-09-05 17:00               ` Dave Taht
2016-09-05 17:26                 ` Toke Høiland-Jørgensen
2016-09-05 17:59                   ` Dave Taht
2016-09-05 20:23                     ` Dave Taht
2016-09-05 20:45                       ` Toke Høiland-Jørgensen
2016-09-05 21:02                         ` Dave Taht
2016-09-05 21:25                           ` Toke Høiland-Jørgensen
2016-09-05 21:29                             ` Dave Taht
2016-09-05 21:35                               ` Toke Høiland-Jørgensen
2016-09-05 21:42                                 ` Dave Taht
2016-09-05 22:04                                   ` Dave Taht
2016-09-05 22:01                             ` Toke Høiland-Jørgensen
2016-09-05 22:08                               ` Dave Taht
2016-09-05 22:31                                 ` Dave Taht
2016-09-05 17:49             ` Felix Fietkau
2016-09-05 17:59               ` Toke Høiland-Jørgensen
2016-09-05 18:45                 ` Felix Fietkau
2016-09-06 11:43             ` Toke Høiland-Jørgensen
2016-09-06 11:45               ` Toke Høiland-Jørgensen
2016-09-06 11:44             ` [Make-wifi-fast] [PATCH v8] " Toke Høiland-Jørgensen
2016-09-06 22:04               ` Felix Fietkau
2016-09-12 12:35               ` Johannes Berg
2016-09-12 13:08                 ` Toke Høiland-Jørgensen
2016-09-12 13:19                   ` Johannes Berg
2016-09-22 17:04               ` [Make-wifi-fast] [PATCH v9 0/2] mac80211: TXQ dequeue path rework Toke Høiland-Jørgensen
2016-09-22 17:04               ` [Make-wifi-fast] [PATCH v9 1/2] mac80211: Move ieee802111_tx_dequeue() to later in tx.c Toke Høiland-Jørgensen
2016-09-30 11:13                 ` Johannes Berg
2016-09-22 17:04               ` [Make-wifi-fast] [PATCH v9 2/2] mac80211: Move reorder-sensitive TX handlers to after TXQ dequeue Toke Høiland-Jørgensen
2016-09-30 10:27                 ` Johannes Berg
2016-09-30 12:39                   ` Toke Høiland-Jørgensen
2016-09-30 12:43                     ` Johannes Berg
2016-09-30 12:45                       ` Toke Høiland-Jørgensen
2016-09-30 12:49                 ` Johannes Berg
2016-09-30 14:01                   ` Toke Høiland-Jørgensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.bufferbloat.net/postorius/lists/make-wifi-fast.lists.bufferbloat.net/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7df7eed3-4d65-7953-81cd-af969060642a@gmail.com \
    --to=n0manletter@gmail.com \
    --cc=make-wifi-fast@lists.bufferbloat.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox