mac80211: remove TX_NEEDS_ALIGNED4_SKBS patch
authorFelix Fietkau <nbd@nbd.name>
Mon, 19 Aug 2019 17:14:17 +0000 (19:14 +0200)
committerFelix Fietkau <nbd@nbd.name>
Wed, 21 Aug 2019 12:59:05 +0000 (14:59 +0200)
The intended performance benefit could not be reliably reproduced, and the
patch was not accepted upstream

Signed-off-by: Felix Fietkau <nbd@nbd.name>
package/kernel/mac80211/patches/subsys/350-mac80211-add-hdrlen-to-ieee80211_tx_data.patch [deleted file]
package/kernel/mac80211/patches/subsys/351-mac80211-add-TX_NEEDS_ALIGNED4_SKBS-hw-flag.patch [deleted file]
package/kernel/mac80211/patches/subsys/357-mac80211-optimize-skb-resizing.patch
package/kernel/mac80211/patches/subsys/522-mac80211_configure_antenna_gain.patch

diff --git a/package/kernel/mac80211/patches/subsys/350-mac80211-add-hdrlen-to-ieee80211_tx_data.patch b/package/kernel/mac80211/patches/subsys/350-mac80211-add-hdrlen-to-ieee80211_tx_data.patch
deleted file mode 100644 (file)
index 86d296f..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-From: Janusz Dziedzic <janusz.dziedzic@tieto.com>
-Date: Fri, 19 Feb 2016 11:01:49 +0100
-Subject: [PATCH] mac80211: add hdrlen to ieee80211_tx_data
-
-This is preparation for adding support for inserting padding between the
-802.11 header and LLC data
-
-Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/net/mac80211/ieee80211_i.h
-+++ b/net/mac80211/ieee80211_i.h
-@@ -176,6 +176,7 @@ struct ieee80211_tx_data {
-       struct ieee80211_tx_rate rate;
-       unsigned int flags;
-+      unsigned int hdrlen;
- };
---- a/net/mac80211/tx.c
-+++ b/net/mac80211/tx.c
-@@ -921,7 +921,7 @@ ieee80211_tx_h_fragment(struct ieee80211
-       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
-       struct ieee80211_hdr *hdr = (void *)skb->data;
-       int frag_threshold = tx->local->hw.wiphy->frag_threshold;
--      int hdrlen;
-+      int hdrlen = tx->hdrlen;
-       int fragnum;
-       /* no matter what happens, tx->skb moves to tx->skbs */
-@@ -942,8 +942,6 @@ ieee80211_tx_h_fragment(struct ieee80211
-       if (WARN_ON(info->flags & IEEE80211_TX_CTL_AMPDU))
-               return TX_DROP;
--      hdrlen = ieee80211_hdrlen(hdr->frame_control);
--
-       /* internal error, why isn't DONTFRAG set? */
-       if (WARN_ON(skb->len + FCS_LEN <= frag_threshold))
-               return TX_DROP;
-@@ -1174,6 +1172,8 @@ ieee80211_tx_prepare(struct ieee80211_su
-       hdr = (struct ieee80211_hdr *) skb->data;
-+      tx->hdrlen = ieee80211_hdrlen(hdr->frame_control);
-+
-       if (likely(sta)) {
-               if (!IS_ERR(sta))
-                       tx->sta = sta;
-@@ -3577,6 +3577,7 @@ begin:
-       tx.local = local;
-       tx.skb = skb;
-       tx.sdata = vif_to_sdata(info->control.vif);
-+      tx.hdrlen = ieee80211_hdrlen(hdr->frame_control);
-       if (txq->sta)
-               tx.sta = container_of(txq->sta, struct sta_info, sta);
-@@ -3603,7 +3604,7 @@ begin:
-               if (tx.key &&
-                   (tx.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV))
--                      pn_offs = ieee80211_hdrlen(hdr->frame_control);
-+                      pn_offs = tx.hdrlen;
-               ieee80211_xmit_fast_finish(sta->sdata, sta, pn_offs,
-                                          tx.key, skb);
-@@ -4058,6 +4059,7 @@ ieee80211_build_data_template(struct iee
-       hdr = (void *)skb->data;
-       tx.sta = sta_info_get(sdata, hdr->addr1);
-       tx.skb = skb;
-+      tx.hdrlen = ieee80211_hdrlen(hdr->frame_control);
-       if (ieee80211_tx_h_select_key(&tx) != TX_CONTINUE) {
-               rcu_read_unlock();
---- a/net/mac80211/util.c
-+++ b/net/mac80211/util.c
-@@ -1538,6 +1538,7 @@ void ieee80211_send_auth(struct ieee8021
-       struct ieee80211_local *local = sdata->local;
-       struct sk_buff *skb;
-       struct ieee80211_mgmt *mgmt;
-+      unsigned int hdrlen;
-       int err;
-       /* 24 + 6 = header + auth_algo + auth_transaction + status_code */
-@@ -1561,8 +1562,10 @@ void ieee80211_send_auth(struct ieee8021
-               skb_put_data(skb, extra, extra_len);
-       if (auth_alg == WLAN_AUTH_SHARED_KEY && transaction == 3) {
-+              hdrlen = ieee80211_hdrlen(mgmt->frame_control);
-               mgmt->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
--              err = ieee80211_wep_encrypt(local, skb, key, key_len, key_idx);
-+              err = ieee80211_wep_encrypt(local, skb, hdrlen, key,
-+                                          key_len, key_idx);
-               WARN_ON(err);
-       }
---- a/net/mac80211/wep.c
-+++ b/net/mac80211/wep.c
-@@ -65,11 +65,11 @@ static void ieee80211_wep_get_iv(struct
- static u8 *ieee80211_wep_add_iv(struct ieee80211_local *local,
-                               struct sk_buff *skb,
-+                              unsigned int hdrlen,
-                               int keylen, int keyidx)
- {
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
-       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
--      unsigned int hdrlen;
-       u8 *newhdr;
-       hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
-@@ -77,7 +77,6 @@ static u8 *ieee80211_wep_add_iv(struct i
-       if (WARN_ON(skb_headroom(skb) < IEEE80211_WEP_IV_LEN))
-               return NULL;
--      hdrlen = ieee80211_hdrlen(hdr->frame_control);
-       newhdr = skb_push(skb, IEEE80211_WEP_IV_LEN);
-       memmove(newhdr, newhdr + IEEE80211_WEP_IV_LEN, hdrlen);
-@@ -132,6 +131,7 @@ int ieee80211_wep_encrypt_data(struct ar
-  */
- int ieee80211_wep_encrypt(struct ieee80211_local *local,
-                         struct sk_buff *skb,
-+                        unsigned int hdrlen,
-                         const u8 *key, int keylen, int keyidx)
- {
-       u8 *iv;
-@@ -141,7 +141,7 @@ int ieee80211_wep_encrypt(struct ieee802
-       if (WARN_ON(skb_tailroom(skb) < IEEE80211_WEP_ICV_LEN))
-               return -1;
--      iv = ieee80211_wep_add_iv(local, skb, keylen, keyidx);
-+      iv = ieee80211_wep_add_iv(local, skb, hdrlen, keylen, keyidx);
-       if (!iv)
-               return -1;
-@@ -275,13 +275,14 @@ static int wep_encrypt_skb(struct ieee80
-       struct ieee80211_key_conf *hw_key = info->control.hw_key;
-       if (!hw_key) {
--              if (ieee80211_wep_encrypt(tx->local, skb, tx->key->conf.key,
-+              if (ieee80211_wep_encrypt(tx->local, skb, tx->hdrlen,
-+                                        tx->key->conf.key,
-                                         tx->key->conf.keylen,
-                                         tx->key->conf.keyidx))
-                       return -1;
-       } else if ((hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV) ||
-                  (hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) {
--              if (!ieee80211_wep_add_iv(tx->local, skb,
-+              if (!ieee80211_wep_add_iv(tx->local, skb, tx->hdrlen,
-                                         tx->key->conf.keylen,
-                                         tx->key->conf.keyidx))
-                       return -1;
---- a/net/mac80211/wep.h
-+++ b/net/mac80211/wep.h
-@@ -18,6 +18,7 @@ int ieee80211_wep_encrypt_data(struct ar
-                               size_t klen, u8 *data, size_t data_len);
- int ieee80211_wep_encrypt(struct ieee80211_local *local,
-                         struct sk_buff *skb,
-+                        unsigned int hdrlen,
-                         const u8 *key, int keylen, int keyidx);
- int ieee80211_wep_decrypt_data(struct arc4_ctx *ctx, u8 *rc4key,
-                              size_t klen, u8 *data, size_t data_len);
---- a/net/mac80211/wpa.c
-+++ b/net/mac80211/wpa.c
-@@ -41,7 +41,7 @@ ieee80211_tx_h_michael_mic_add(struct ie
-           skb->len < 24 || !ieee80211_is_data_present(hdr->frame_control))
-               return TX_CONTINUE;
--      hdrlen = ieee80211_hdrlen(hdr->frame_control);
-+      hdrlen = tx->hdrlen;
-       if (skb->len < hdrlen)
-               return TX_DROP;
-@@ -192,7 +192,6 @@ mic_fail_no_key:
- static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
- {
--      struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
-       struct ieee80211_key *key = tx->key;
-       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
-       unsigned int hdrlen;
-@@ -207,7 +206,7 @@ static int tkip_encrypt_skb(struct ieee8
-               return 0;
-       }
--      hdrlen = ieee80211_hdrlen(hdr->frame_control);
-+      hdrlen = tx->hdrlen;
-       len = skb->len - hdrlen;
-       if (info->control.hw_key)
-@@ -425,7 +424,7 @@ static int ccmp_encrypt_skb(struct ieee8
-               return 0;
-       }
--      hdrlen = ieee80211_hdrlen(hdr->frame_control);
-+      hdrlen = tx->hdrlen;
-       len = skb->len - hdrlen;
-       if (info->control.hw_key)
-@@ -657,7 +656,7 @@ static int gcmp_encrypt_skb(struct ieee8
-               return 0;
-       }
--      hdrlen = ieee80211_hdrlen(hdr->frame_control);
-+      hdrlen = tx->hdrlen;
-       len = skb->len - hdrlen;
-       if (info->control.hw_key)
-@@ -797,7 +796,6 @@ static ieee80211_tx_result
- ieee80211_crypto_cs_encrypt(struct ieee80211_tx_data *tx,
-                           struct sk_buff *skb)
- {
--      struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
-       struct ieee80211_key *key = tx->key;
-       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
-       int hdrlen;
-@@ -813,8 +811,7 @@ ieee80211_crypto_cs_encrypt(struct ieee8
-                    pskb_expand_head(skb, iv_len, 0, GFP_ATOMIC)))
-               return TX_DROP;
--      hdrlen = ieee80211_hdrlen(hdr->frame_control);
--
-+      hdrlen = tx->hdrlen;
-       pos = skb_push(skb, iv_len);
-       memmove(pos, pos + iv_len, hdrlen);
diff --git a/package/kernel/mac80211/patches/subsys/351-mac80211-add-TX_NEEDS_ALIGNED4_SKBS-hw-flag.patch b/package/kernel/mac80211/patches/subsys/351-mac80211-add-TX_NEEDS_ALIGNED4_SKBS-hw-flag.patch
deleted file mode 100644 (file)
index 7f0122e..0000000
+++ /dev/null
@@ -1,304 +0,0 @@
-From: Janusz Dziedzic <janusz.dziedzic@tieto.com>
-Date: Sun, 10 Mar 2019 17:22:08 +0100
-Subject: [PATCH] mac80211: add TX_NEEDS_ALIGNED4_SKBS hw flag
-
-The driver should set this flag if the hardware requires tx skb data
-(starting with the LLC header) to be aligned to 4 bytes.
-
-Padding is added after ieee80211_hdr, before IV/LLC.
-
-Before this patch, we have to do memmove(hdrlen) twice in the driver:
-Once before we pass this to HW and once again in tx completion
-(to fix up the skb for monitor mode).
-
-With this patch we can skip this memmove() and thus reduce CPU cycles in
-the data path.
-
-Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/include/net/mac80211.h
-+++ b/include/net/mac80211.h
-@@ -2274,6 +2274,9 @@ struct ieee80211_txq {
-  * @IEEE80211_HW_NO_AMPDU_KEYBORDER_SUPPORT: The card/driver can't handle
-  *    active Tx A-MPDU sessions with Extended Key IDs during rekey.
-  *
-+ * @IEEE80211_HW_TX_NEEDS_ALIGNED4_SKBS: Driver need aligned skbs to four-byte.
-+ *    Padding will be added after ieee80211_hdr, before IV/LLC.
-+ *
-  * @NUM_IEEE80211_HW_FLAGS: number of hardware flags, used for sizing arrays
-  */
- enum ieee80211_hw_flags {
-@@ -2327,6 +2330,7 @@ enum ieee80211_hw_flags {
-       IEEE80211_HW_SUPPORTS_ONLY_HE_MULTI_BSSID,
-       IEEE80211_HW_EXT_KEY_ID_NATIVE,
-       IEEE80211_HW_NO_AMPDU_KEYBORDER_SUPPORT,
-+      IEEE80211_HW_TX_NEEDS_ALIGNED4_SKBS,
-       /* keep last, obviously */
-       NUM_IEEE80211_HW_FLAGS
-@@ -2620,6 +2624,40 @@ ieee80211_get_alt_retry_rate(const struc
- void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb);
- /**
-+ * ieee80211_hdr_padsize - get size of padding between 802.11 header and LLC
-+ * @hw: the hardware
-+ * @hdrlen: 802.11 header length
-+ */
-+static inline unsigned int
-+ieee80211_hdr_padsize(struct ieee80211_hw *hw, unsigned int hdrlen)
-+{
-+      /*
-+       * While hdrlen is already aligned to two-byte boundaries,
-+       * simple check with & 2 will return correct padsize.
-+       */
-+      if (ieee80211_hw_check(hw, TX_NEEDS_ALIGNED4_SKBS))
-+              return hdrlen & 2;
-+      return 0;
-+}
-+
-+/**
-+ * ieee80211_padded_hdrlen - get padded 802.11 header size
-+ * @hw: the hardware
-+ * @fc: frame control field in little-endian format
-+ */
-+static inline unsigned int
-+ieee80211_padded_hdrlen(struct ieee80211_hw *hw, __le16 fc)
-+{
-+      unsigned int hdrlen;
-+
-+      hdrlen = ieee80211_hdrlen(fc);
-+      hdrlen += ieee80211_hdr_padsize(hw, hdrlen);
-+
-+      return hdrlen;
-+}
-+
-+
-+/**
-  * DOC: Hardware crypto acceleration
-  *
-  * mac80211 is capable of taking advantage of many hardware
---- a/net/mac80211/iface.c
-+++ b/net/mac80211/iface.c
-@@ -1876,6 +1876,10 @@ int ieee80211_if_add(struct ieee80211_lo
-                                       + 8 /* rfc1042/bridge tunnel */
-                                       - ETH_HLEN /* ethernet hard_header_len */
-                                       + IEEE80211_ENCRYPT_HEADROOM;
-+
-+              if (ieee80211_hw_check(&local->hw, TX_NEEDS_ALIGNED4_SKBS))
-+                      ndev->needed_headroom += 2; /* padding */
-+
-               ndev->needed_tailroom = IEEE80211_ENCRYPT_TAILROOM;
-               ret = dev_alloc_name(ndev, ndev->name);
---- a/net/mac80211/mesh_pathtbl.c
-+++ b/net/mac80211/mesh_pathtbl.c
-@@ -102,13 +102,15 @@ void mesh_path_assign_nexthop(struct mes
- static void prepare_for_gate(struct sk_buff *skb, char *dst_addr,
-                            struct mesh_path *gate_mpath)
- {
-+      struct ieee80211_sub_if_data *sdata = gate_mpath->sdata;
-+      struct ieee80211_hw *hw = &sdata->local->hw;
-       struct ieee80211_hdr *hdr;
-       struct ieee80211s_hdr *mshdr;
-       int mesh_hdrlen, hdrlen;
-       char *next_hop;
-       hdr = (struct ieee80211_hdr *) skb->data;
--      hdrlen = ieee80211_hdrlen(hdr->frame_control);
-+      hdrlen = ieee80211_padded_hdrlen(hw, hdr->frame_control);
-       mshdr = (struct ieee80211s_hdr *) (skb->data + hdrlen);
-       if (!(mshdr->flags & MESH_FLAGS_AE)) {
---- a/net/mac80211/rx.c
-+++ b/net/mac80211/rx.c
-@@ -2673,7 +2673,7 @@ ieee80211_rx_h_mesh_fwding(struct ieee80
-       struct ieee80211_local *local = rx->local;
-       struct ieee80211_sub_if_data *sdata = rx->sdata;
-       struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
--      u16 ac, q, hdrlen;
-+      u16 ac, q, hdrlen, padsize;
-       int tailroom = 0;
-       hdr = (struct ieee80211_hdr *) skb->data;
-@@ -2766,7 +2766,9 @@ ieee80211_rx_h_mesh_fwding(struct ieee80
-       if (sdata->crypto_tx_tailroom_needed_cnt)
-               tailroom = IEEE80211_ENCRYPT_TAILROOM;
--      fwd_skb = skb_copy_expand(skb, local->tx_headroom +
-+      padsize = ieee80211_hdr_padsize(&local->hw, hdrlen);
-+
-+      fwd_skb = skb_copy_expand(skb, local->tx_headroom + padsize +
-                                      sdata->encrypt_headroom,
-                                 tailroom, GFP_ATOMIC);
-       if (!fwd_skb)
-@@ -2798,6 +2800,12 @@ ieee80211_rx_h_mesh_fwding(struct ieee80
-               return RX_DROP_MONITOR;
-       }
-+      if (padsize) {
-+              skb_push(fwd_skb, padsize);
-+              memmove(fwd_skb->data, skb->data + padsize, hdrlen);
-+              memset(fwd_skb->data + hdrlen, 0, padsize);
-+      }
-+
-       IEEE80211_IFSTA_MESH_CTR_INC(ifmsh, fwded_frames);
-       ieee80211_add_pending_skb(local, fwd_skb);
-  out:
---- a/net/mac80211/sta_info.h
-+++ b/net/mac80211/sta_info.h
-@@ -308,7 +308,7 @@ struct ieee80211_fast_tx {
-       u8 hdr_len;
-       u8 sa_offs, da_offs, pn_offs;
-       u8 band;
--      u8 hdr[30 + 2 + IEEE80211_FAST_XMIT_MAX_IV +
-+      u8 hdr[30 + 2 + 2 + IEEE80211_FAST_XMIT_MAX_IV +
-              sizeof(rfc1042_header)] __aligned(2);
-       struct rcu_head rcu_head;
---- a/net/mac80211/status.c
-+++ b/net/mac80211/status.c
-@@ -512,6 +512,7 @@ static void ieee80211_report_used_skb(st
- {
-       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
-       struct ieee80211_hdr *hdr = (void *)skb->data;
-+      struct ieee80211_hw *hw = &local->hw;
-       bool acked = info->flags & IEEE80211_TX_STAT_ACK;
-       if (dropped)
-@@ -528,7 +529,7 @@ static void ieee80211_report_used_skb(st
-                       skb->dev = NULL;
-               } else {
-                       unsigned int hdr_size =
--                              ieee80211_hdrlen(hdr->frame_control);
-+                              ieee80211_padded_hdrlen(hw, hdr->frame_control);
-                       /* Check to see if packet is a TDLS teardown packet */
-                       if (ieee80211_is_data(hdr->frame_control) &&
-@@ -652,9 +653,22 @@ void ieee80211_tx_monitor(struct ieee802
-       struct sk_buff *skb2;
-       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
-       struct ieee80211_sub_if_data *sdata;
-+      struct ieee80211_hdr *hdr = (void *)skb->data;
-       struct net_device *prev_dev = NULL;
-+      unsigned int hdrlen, padsize;
-       int rtap_len;
-+      /* Remove padding if was added */
-+      if (ieee80211_hw_check(&local->hw, TX_NEEDS_ALIGNED4_SKBS)) {
-+              hdrlen = ieee80211_hdrlen(hdr->frame_control);
-+              padsize = ieee80211_hdr_padsize(&local->hw, hdrlen);
-+
-+              if (padsize && skb->len > hdrlen + padsize) {
-+                      memmove(skb->data + padsize, skb->data, hdrlen);
-+                      skb_pull(skb, padsize);
-+              }
-+      }
-+
-       /* send frame to monitor interfaces now */
-       rtap_len = ieee80211_tx_radiotap_len(info);
-       if (WARN_ON_ONCE(skb_headroom(skb) < rtap_len)) {
---- a/net/mac80211/tkip.c
-+++ b/net/mac80211/tkip.c
-@@ -198,10 +198,12 @@ void ieee80211_get_tkip_p2k(struct ieee8
- {
-       struct ieee80211_key *key = (struct ieee80211_key *)
-                       container_of(keyconf, struct ieee80211_key, conf);
-+      struct ieee80211_hw *hw = &key->local->hw;
-       const u8 *tk = &key->conf.key[NL80211_TKIP_DATA_OFFSET_ENCR_KEY];
-       struct tkip_ctx *ctx = &key->u.tkip.tx;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
--      const u8 *data = (u8 *)hdr + ieee80211_hdrlen(hdr->frame_control);
-+      const u8 *data = (u8 *)hdr + ieee80211_padded_hdrlen(hw,
-+                                                      hdr->frame_control);
-       u32 iv32 = get_unaligned_le32(&data[4]);
-       u16 iv16 = data[2] | (data[0] << 8);
---- a/net/mac80211/tx.c
-+++ b/net/mac80211/tx.c
-@@ -1171,8 +1171,7 @@ ieee80211_tx_prepare(struct ieee80211_su
-       info->flags &= ~IEEE80211_TX_INTFL_NEED_TXPROCESSING;
-       hdr = (struct ieee80211_hdr *) skb->data;
--
--      tx->hdrlen = ieee80211_hdrlen(hdr->frame_control);
-+      tx->hdrlen = ieee80211_padded_hdrlen(&local->hw, hdr->frame_control);
-       if (likely(sta)) {
-               if (!IS_ERR(sta))
-@@ -2244,7 +2243,7 @@ netdev_tx_t ieee80211_monitor_start_xmit
-               goto fail;
-       hdr = (struct ieee80211_hdr *)(skb->data + len_rthdr);
--      hdrlen = ieee80211_hdrlen(hdr->frame_control);
-+      hdrlen = ieee80211_padded_hdrlen(&local->hw, hdr->frame_control);
-       if (skb->len < len_rthdr + hdrlen)
-               goto fail;
-@@ -2463,7 +2462,7 @@ static struct sk_buff *ieee80211_build_h
-       struct ieee80211_chanctx_conf *chanctx_conf;
-       struct ieee80211_sub_if_data *ap_sdata;
-       enum nl80211_band band;
--      int ret;
-+      int padsize, ret;
-       if (IS_ERR(sta))
-               sta = NULL;
-@@ -2774,7 +2773,9 @@ static struct sk_buff *ieee80211_build_h
-       }
-       skb_pull(skb, skip_header_bytes);
-+      padsize = ieee80211_hdr_padsize(&local->hw, hdrlen);
-       head_need = hdrlen + encaps_len + meshhdrlen - skb_headroom(skb);
-+      head_need += padsize;
-       /*
-        * So we need to modify the skb header and hence need a copy of
-@@ -2807,6 +2808,9 @@ static struct sk_buff *ieee80211_build_h
-               memcpy(skb_push(skb, meshhdrlen), &mesh_hdr, meshhdrlen);
- #endif
-+      if (padsize)
-+              memset(skb_push(skb, padsize), 0, padsize);
-+
-       if (ieee80211_is_data_qos(fc)) {
-               __le16 *qos_control;
-@@ -2983,6 +2987,8 @@ void ieee80211_check_fast_xmit(struct st
-               fc |= cpu_to_le16(IEEE80211_STYPE_QOS_DATA);
-       }
-+      build.hdr_len += ieee80211_hdr_padsize(&local->hw, build.hdr_len);
-+
-       /* We store the key here so there's no point in using rcu_dereference()
-        * but that's fine because the code that changes the pointers will call
-        * this function after doing so. For a single CPU that would be enough,
-@@ -3577,7 +3583,7 @@ begin:
-       tx.local = local;
-       tx.skb = skb;
-       tx.sdata = vif_to_sdata(info->control.vif);
--      tx.hdrlen = ieee80211_hdrlen(hdr->frame_control);
-+      tx.hdrlen = ieee80211_padded_hdrlen(hw, hdr->frame_control);
-       if (txq->sta)
-               tx.sta = container_of(txq->sta, struct sta_info, sta);
-@@ -4059,7 +4065,7 @@ ieee80211_build_data_template(struct iee
-       hdr = (void *)skb->data;
-       tx.sta = sta_info_get(sdata, hdr->addr1);
-       tx.skb = skb;
--      tx.hdrlen = ieee80211_hdrlen(hdr->frame_control);
-+      tx.hdrlen = ieee80211_padded_hdrlen(&tx.local->hw, hdr->frame_control);
-       if (ieee80211_tx_h_select_key(&tx) != TX_CONTINUE) {
-               rcu_read_unlock();
---- a/net/mac80211/debugfs.c
-+++ b/net/mac80211/debugfs.c
-@@ -273,6 +273,7 @@ static const char *hw_flag_names[] = {
-       FLAG(SUPPORTS_ONLY_HE_MULTI_BSSID),
-       FLAG(EXT_KEY_ID_NATIVE),
-       FLAG(NO_AMPDU_KEYBORDER_SUPPORT),
-+      FLAG(TX_NEEDS_ALIGNED4_SKBS),
- #undef FLAG
- };
index 6ed2884d5ef3aebb1dc3f2fd9dd5f5d8890d2b90..e2fbdc6787fd65585a12143b6d7e5d4d6bbc0cab 100644 (file)
@@ -24,7 +24,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
 
 --- a/net/mac80211/ieee80211_i.h
 +++ b/net/mac80211/ieee80211_i.h
-@@ -1780,6 +1780,9 @@ int ieee80211_tx_control_port(struct wip
+@@ -1779,6 +1779,9 @@ int ieee80211_tx_control_port(struct wip
                              const u8 *dest, __be16 proto, bool unencrypted);
  int ieee80211_probe_mesh_link(struct wiphy *wiphy, struct net_device *dev,
                              const u8 *buf, size_t len);
@@ -36,9 +36,9 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
  void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata,
 --- a/net/mac80211/status.c
 +++ b/net/mac80211/status.c
-@@ -669,6 +669,11 @@ void ieee80211_tx_monitor(struct ieee802
-               }
-       }
+@@ -655,6 +655,11 @@ void ieee80211_tx_monitor(struct ieee802
+       struct net_device *prev_dev = NULL;
+       int rtap_len;
  
 +      if (ieee80211_skb_resize(local, NULL, skb, 0, 0)) {
 +              dev_kfree_skb(skb);
@@ -50,7 +50,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        if (WARN_ON_ONCE(skb_headroom(skb) < rtap_len)) {
 --- a/net/mac80211/tx.c
 +++ b/net/mac80211/tx.c
-@@ -1935,37 +1935,53 @@ static bool ieee80211_tx(struct ieee8021
+@@ -1936,37 +1936,53 @@ static bool ieee80211_tx(struct ieee8021
  }
  
  /* device xmit handlers */
@@ -67,20 +67,14 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        struct ieee80211_hdr *hdr;
 -      bool enc_tailroom;
 -      int tail_need = 0;
--
++      int head_need, head_max;
++      int tail_need, tail_max;
++      bool enc_tailroom = false;
 -      hdr = (struct ieee80211_hdr *) skb->data;
 -      enc_tailroom = may_encrypt &&
 -                     (sdata->crypto_tx_tailroom_needed_cnt ||
 -                      ieee80211_is_mgmt(hdr->frame_control));
--
--      if (enc_tailroom) {
--              tail_need = IEEE80211_ENCRYPT_TAILROOM;
--              tail_need -= skb_tailroom(skb);
--              tail_need = max_t(int, tail_need, 0);
-+      int head_need, head_max;
-+      int tail_need, tail_max;
-+      bool enc_tailroom = false;
-+
 +      if (sdata && !hdr_len &&
 +          !(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT)) {
 +              hdr = (struct ieee80211_hdr *) skb->data;
@@ -88,7 +82,11 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
 +                              ieee80211_is_mgmt(hdr->frame_control));
 +              hdr_len += sdata->encrypt_headroom;
 +      }
-+
+-      if (enc_tailroom) {
+-              tail_need = IEEE80211_ENCRYPT_TAILROOM;
+-              tail_need -= skb_tailroom(skb);
+-              tail_need = max_t(int, tail_need, 0);
 +      head_need = head_max = hdr_len;
 +      tail_need = tail_max = 0;
 +      if (!sdata) {
@@ -123,7 +121,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
                wiphy_debug(local->hw.wiphy,
                            "failed to reallocate TX buffer\n");
                return -ENOMEM;
-@@ -1981,18 +1997,8 @@ void ieee80211_xmit(struct ieee80211_sub
+@@ -1982,18 +1998,8 @@ void ieee80211_xmit(struct ieee80211_sub
        struct ieee80211_local *local = sdata->local;
        struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
        struct ieee80211_hdr *hdr;
@@ -131,26 +129,24 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
 -      bool may_encrypt;
 -
 -      may_encrypt = !(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT);
+-
 -      headroom = local->tx_headroom;
 -      if (may_encrypt)
 -              headroom += sdata->encrypt_headroom;
 -      headroom -= skb_headroom(skb);
 -      headroom = max_t(int, 0, headroom);
--
 -      if (ieee80211_skb_resize(sdata, skb, headroom, may_encrypt)) {
 +      if (ieee80211_skb_resize(local, sdata, skb, 0, 0)) {
                ieee80211_free_txskb(&local->hw, skb);
                return;
        }
-@@ -2774,30 +2780,14 @@ static struct sk_buff *ieee80211_build_h
+@@ -2774,29 +2780,13 @@ static struct sk_buff *ieee80211_build_h
+       }
  
        skb_pull(skb, skip_header_bytes);
-       padsize = ieee80211_hdr_padsize(&local->hw, hdrlen);
 -      head_need = hdrlen + encaps_len + meshhdrlen - skb_headroom(skb);
-+      head_need = hdrlen + encaps_len + meshhdrlen;
-       head_need += padsize;
+-
 -      /*
 -       * So we need to modify the skb header and hence need a copy of
 -       * that. The head_need variable above doesn't, so far, include
@@ -162,7 +158,8 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
 -       * the ever needed space. Also, if we need to reallocate it anyway,
 -       * make it big enough for everything we may ever need.
 -       */
--
++      head_need = hdrlen + encaps_len + meshhdrlen;
 -      if (head_need > 0 || skb_cloned(skb)) {
 -              head_need += sdata->encrypt_headroom;
 -              head_need += local->tx_headroom;
@@ -180,7 +177,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        }
  
        if (encaps_data)
-@@ -3417,7 +3407,6 @@ static bool ieee80211_xmit_fast(struct i
+@@ -3411,7 +3401,6 @@ static bool ieee80211_xmit_fast(struct i
        struct ieee80211_local *local = sdata->local;
        u16 ethertype = (skb->data[12] << 8) | skb->data[13];
        int extra_head = fast_tx->hdr_len - (ETH_HLEN - 2);
@@ -188,7 +185,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        struct ethhdr eth;
        struct ieee80211_tx_info *info;
        struct ieee80211_hdr *hdr = (void *)fast_tx->hdr;
-@@ -3469,10 +3458,7 @@ static bool ieee80211_xmit_fast(struct i
+@@ -3463,10 +3452,7 @@ static bool ieee80211_xmit_fast(struct i
         * as the may-encrypt argument for the resize to not account for
         * more room than we already have in 'extra_head'
         */
index 580e043f22499deada60d98bc66b7c4681165899..3ca34b7ec31959c7de718ef8e177ed53790750de 100644 (file)
@@ -87,7 +87,7 @@
        CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
 --- a/net/mac80211/ieee80211_i.h
 +++ b/net/mac80211/ieee80211_i.h
-@@ -1373,6 +1373,7 @@ struct ieee80211_local {
+@@ -1372,6 +1372,7 @@ struct ieee80211_local {
        int dynamic_ps_forced_timeout;
  
        int user_power_level; /* in dBm, for all interfaces */