From 3a05aa17db86fa6a420cc7115f2ca62eefa946ec Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 14 Feb 2021 19:41:40 +0100 Subject: mac80211: Remove 357-mac80211-optimize-skb-resizing.patch This patch was adapted to apply on top of some stable changes, but we are not sure if this is working correctly. Felix suggested to remove this patch for now. Fixes: 0a59e2a76e6d ("mac80211: Update to version 4.19.161-1") Signed-off-by: Hauke Mehrtens --- .../357-mac80211-optimize-skb-resizing.patch | 215 --------------------- ...ke-ieee80211_schedule_txq-schedule-empty-.patch | 6 +- ...en-using-iTXQ-select-the-queue-in-ieee802.patch | 4 +- ...SS-send-deauth-when-expiring-inactive-STA.patch | 2 +- 4 files changed, 6 insertions(+), 221 deletions(-) delete mode 100644 package/kernel/mac80211/patches/subsys/357-mac80211-optimize-skb-resizing.patch diff --git a/package/kernel/mac80211/patches/subsys/357-mac80211-optimize-skb-resizing.patch b/package/kernel/mac80211/patches/subsys/357-mac80211-optimize-skb-resizing.patch deleted file mode 100644 index e7e8a0b286..0000000000 --- a/package/kernel/mac80211/patches/subsys/357-mac80211-optimize-skb-resizing.patch +++ /dev/null @@ -1,215 +0,0 @@ -From: Felix Fietkau -Date: Sun, 17 Mar 2019 18:11:30 +0100 -Subject: [PATCH] mac80211: optimize skb resizing - -When forwarding unicast packets from ethernet to batman-adv over 802.11s -(with forwarding disabled), the typical required headroom to transmit -encrypted packets on mt76 is 32 (802.11) + 6 (802.11s) + 8 (CCMP) + -2 (padding) + 6 (LLC) + 18 (batman-adv) - 14 (old ethernet header) = 58 bytes. - -On systems where NET_SKB_PAD is 64 this leads to a call to pskb_expand_head -for every packet, since mac80211 also tries to allocate 16 bytes status -headroom for radiotap headers. - -This patch fixes these unnecessary reallocations by only requiring the extra -status headroom in ieee80211_tx_monitor() -If however a reallocation happens before that call, the status headroom gets -added there as well, in order to avoid double reallocation. - -The patch also cleans up the code by moving the headroom calculation to -ieee80211_skb_resize. - -Signed-off-by: Felix Fietkau ---- - ---- a/net/mac80211/ieee80211_i.h -+++ b/net/mac80211/ieee80211_i.h -@@ -1762,6 +1762,9 @@ void ieee80211_clear_fast_xmit(struct st - int ieee80211_tx_control_port(struct wiphy *wiphy, struct net_device *dev, - const u8 *buf, size_t len, - const u8 *dest, __be16 proto, bool unencrypted); -+int ieee80211_skb_resize(struct ieee80211_local *local, -+ struct ieee80211_sub_if_data *sdata, -+ struct sk_buff *skb, int hdrlen, int hdr_add); - - /* HT */ - void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata, ---- a/net/mac80211/status.c -+++ b/net/mac80211/status.c -@@ -671,6 +671,11 @@ void ieee80211_tx_monitor(struct ieee802 - } - } - -+ if (ieee80211_skb_resize(local, NULL, skb, 0, 0)) { -+ dev_kfree_skb(skb); -+ return; -+ } -+ - /* 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/tx.c -+++ b/net/mac80211/tx.c -@@ -1914,42 +1914,53 @@ static bool ieee80211_tx(struct ieee8021 - } - - /* device xmit handlers */ -- --enum ieee80211_encrypt { -- ENCRYPT_NO, -- ENCRYPT_MGMT, -- ENCRYPT_DATA, --}; -- --static int ieee80211_skb_resize(struct ieee80211_sub_if_data *sdata, -- struct sk_buff *skb, -- int head_need, -- enum ieee80211_encrypt encrypt) -+int ieee80211_skb_resize(struct ieee80211_local *local, -+ struct ieee80211_sub_if_data *sdata, -+ struct sk_buff *skb, int hdr_len, int hdr_extra) - { -- struct ieee80211_local *local = sdata->local; -- bool enc_tailroom; -- int tail_need = 0; -- -- enc_tailroom = encrypt == ENCRYPT_MGMT || -- (encrypt == ENCRYPT_DATA && -- sdata->crypto_tx_tailroom_needed_cnt); -- -- if (enc_tailroom) { -- tail_need = IEEE80211_ENCRYPT_TAILROOM; -- tail_need -= skb_tailroom(skb); -- tail_need = max_t(int, tail_need, 0); -+ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); -+ struct ieee80211_hdr *hdr; -+ 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; -+ enc_tailroom = (sdata->crypto_tx_tailroom_needed_cnt || -+ ieee80211_is_mgmt(hdr->frame_control)); -+ hdr_len += sdata->encrypt_headroom; -+ } -+ -+ head_need = head_max = hdr_len; -+ tail_need = tail_max = 0; -+ if (!sdata) { -+ head_need = head_max = local->tx_headroom; -+ } else { -+ head_max += hdr_extra; -+ head_max += max_t(int, local->tx_headroom, -+ local->hw.extra_tx_headroom); -+ head_need += local->hw.extra_tx_headroom; -+ -+ tail_max = IEEE80211_ENCRYPT_TAILROOM; -+ if (enc_tailroom) -+ tail_need = tail_max; - } - - if (skb_cloned(skb) && - (!ieee80211_hw_check(&local->hw, SUPPORTS_CLONED_SKBS) || - !skb_clone_writable(skb, ETH_HLEN) || enc_tailroom)) - I802_DEBUG_INC(local->tx_expand_skb_head_cloned); -- else if (head_need || tail_need) -+ else if (head_need > skb_headroom(skb) || -+ tail_need > skb_tailroom(skb)) - I802_DEBUG_INC(local->tx_expand_skb_head); - else - return 0; - -- if (pskb_expand_head(skb, head_need, tail_need, GFP_ATOMIC)) { -+ head_max = max_t(int, 0, head_max - skb_headroom(skb)); -+ tail_max = max_t(int, 0, tail_max - skb_tailroom(skb)); -+ -+ if (pskb_expand_head(skb, head_max, tail_max, GFP_ATOMIC)) { - wiphy_debug(local->hw.wiphy, - "failed to reallocate TX buffer\n"); - return -ENOMEM; -@@ -1964,24 +1975,9 @@ 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 = (struct ieee80211_hdr *) skb->data; -- int headroom; -- enum ieee80211_encrypt encrypt; -- -- if (info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT) -- encrypt = ENCRYPT_NO; -- else if (ieee80211_is_mgmt(hdr->frame_control)) -- encrypt = ENCRYPT_MGMT; -- else -- encrypt = ENCRYPT_DATA; -- -- headroom = local->tx_headroom; -- if (encrypt != ENCRYPT_NO) -- headroom += sdata->encrypt_headroom; -- headroom -= skb_headroom(skb); -- headroom = max_t(int, 0, headroom); -+ struct ieee80211_hdr *hdr; - -- if (ieee80211_skb_resize(sdata, skb, headroom, encrypt)) { -+ if (ieee80211_skb_resize(local, sdata, skb, 0, 0)) { - ieee80211_free_txskb(&local->hw, skb); - return; - } -@@ -2752,30 +2748,14 @@ 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 -- * the needed header space that we don't need right away. If we -- * can, then we don't reallocate right now but only after the -- * frame arrives at the master device (if it does...) -- * -- * If we cannot, however, then we will reallocate to include all -- * the ever needed space. Also, if we need to reallocate it anyway, -- * make it big enough for everything we may ever need. -- */ -- -- if (head_need > 0 || skb_cloned(skb)) { -- head_need += sdata->encrypt_headroom; -- head_need += local->tx_headroom; -- head_need = max_t(int, 0, head_need); -- if (ieee80211_skb_resize(sdata, skb, head_need, ENCRYPT_DATA)) { -- ieee80211_free_txskb(&local->hw, skb); -- skb = NULL; -- return ERR_PTR(-ENOMEM); -- } -+ if (ieee80211_skb_resize(local, sdata, skb, head_need, -+ sdata->encrypt_headroom)) { -+ ieee80211_free_txskb(&local->hw, skb); -+ skb = NULL; -+ return ERR_PTR(-ENOMEM); - } - - if (encaps_data) -@@ -3388,7 +3368,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); -- int hw_headroom = sdata->local->hw.extra_tx_headroom; - struct ethhdr eth; - struct ieee80211_tx_info *info; - struct ieee80211_hdr *hdr = (void *)fast_tx->hdr; -@@ -3440,10 +3419,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' - */ -- if (unlikely(ieee80211_skb_resize(sdata, skb, -- max_t(int, extra_head + hw_headroom - -- skb_headroom(skb), 0), -- ENCRYPT_NO))) { -+ if (unlikely(ieee80211_skb_resize(local, sdata, skb, extra_head, 0))) { - kfree_skb(skb); - return true; - } diff --git a/package/kernel/mac80211/patches/subsys/358-mac80211-make-ieee80211_schedule_txq-schedule-empty-.patch b/package/kernel/mac80211/patches/subsys/358-mac80211-make-ieee80211_schedule_txq-schedule-empty-.patch index c1e0c5c24c..9c6a7e4f74 100644 --- a/package/kernel/mac80211/patches/subsys/358-mac80211-make-ieee80211_schedule_txq-schedule-empty-.patch +++ b/package/kernel/mac80211/patches/subsys/358-mac80211-make-ieee80211_schedule_txq-schedule-empty-.patch @@ -72,7 +72,7 @@ Signed-off-by: Felix Fietkau /** --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c -@@ -3674,8 +3674,9 @@ out: +@@ -3698,8 +3698,9 @@ out: } EXPORT_SYMBOL(ieee80211_next_txq); @@ -84,7 +84,7 @@ Signed-off-by: Felix Fietkau { struct ieee80211_local *local = hw_to_local(hw); struct txq_info *txqi = to_txq_info(txq); -@@ -3683,7 +3684,8 @@ void ieee80211_schedule_txq(struct ieee8 +@@ -3707,7 +3708,8 @@ void ieee80211_schedule_txq(struct ieee8 spin_lock_bh(&local->active_txq_lock[txq->ac]); if (list_empty(&txqi->schedule_order) && @@ -94,7 +94,7 @@ Signed-off-by: Felix Fietkau /* If airtime accounting is active, always enqueue STAs at the * head of the list to ensure that they only get moved to the * back by the airtime DRR scheduler once they have a negative -@@ -3703,7 +3705,7 @@ void ieee80211_schedule_txq(struct ieee8 +@@ -3727,7 +3729,7 @@ void ieee80211_schedule_txq(struct ieee8 spin_unlock_bh(&local->active_txq_lock[txq->ac]); } diff --git a/package/kernel/mac80211/patches/subsys/360-mac80211-when-using-iTXQ-select-the-queue-in-ieee802.patch b/package/kernel/mac80211/patches/subsys/360-mac80211-when-using-iTXQ-select-the-queue-in-ieee802.patch index ea86758ea0..6e8cff46ac 100644 --- a/package/kernel/mac80211/patches/subsys/360-mac80211-when-using-iTXQ-select-the-queue-in-ieee802.patch +++ b/package/kernel/mac80211/patches/subsys/360-mac80211-when-using-iTXQ-select-the-queue-in-ieee802.patch @@ -13,7 +13,7 @@ Signed-off-by: Felix Fietkau --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c -@@ -3773,6 +3773,7 @@ void __ieee80211_subif_start_xmit(struct +@@ -3797,6 +3797,7 @@ void __ieee80211_subif_start_xmit(struct u32 ctrl_flags) { struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); @@ -21,7 +21,7 @@ Signed-off-by: Felix Fietkau struct sta_info *sta; struct sk_buff *next; -@@ -3786,7 +3787,15 @@ void __ieee80211_subif_start_xmit(struct +@@ -3810,7 +3811,15 @@ void __ieee80211_subif_start_xmit(struct if (ieee80211_lookup_ra_sta(sdata, skb, &sta)) goto out_free; diff --git a/package/kernel/mac80211/patches/subsys/365-mac80211-IBSS-send-deauth-when-expiring-inactive-STA.patch b/package/kernel/mac80211/patches/subsys/365-mac80211-IBSS-send-deauth-when-expiring-inactive-STA.patch index 20345cf924..5fa8fcddcb 100644 --- a/package/kernel/mac80211/patches/subsys/365-mac80211-IBSS-send-deauth-when-expiring-inactive-STA.patch +++ b/package/kernel/mac80211/patches/subsys/365-mac80211-IBSS-send-deauth-when-expiring-inactive-STA.patch @@ -54,7 +54,7 @@ Signed-off-by: Johannes Berg } --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h -@@ -2071,7 +2071,8 @@ void ieee80211_send_auth(struct ieee8021 +@@ -2068,7 +2068,8 @@ void ieee80211_send_auth(struct ieee8021 const u8 *da, const u8 *key, u8 key_len, u8 key_idx, u32 tx_flags); void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata, -- cgit v1.2.3