82b878e
4965 version of Eric patch "iwl3945: better skb management in rx path".
82b878e
It fixes several problems :
82b878e
82b878e
1) skb->truesize is underestimated.
82b878e
   We really consume PAGE_SIZE bytes for a fragment,
82b878e
   not the frame length.
82b878e
2) 128 bytes of initial headroom is a bit low and forces reallocations.
82b878e
3) We can avoid consuming a full page for small enough frames.
82b878e
82b878e
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
82b878e
---
82b878e
 drivers/net/wireless/iwlegacy/4965-mac.c | 18 ++++++++++++------
82b878e
 1 file changed, 12 insertions(+), 6 deletions(-)
82b878e
82b878e
diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c
82b878e
index d287fd2..4e5d408 100644
82b878e
--- a/drivers/net/wireless/iwlegacy/4965-mac.c
82b878e
+++ b/drivers/net/wireless/iwlegacy/4965-mac.c
82b878e
@@ -574,9 +574,11 @@ il4965_translate_rx_status(struct il_priv *il, u32 decrypt_in)
82b878e
 	return decrypt_out;
82b878e
 }
82b878e
 
82b878e
+#define SMALL_PACKET_SIZE 256
82b878e
+
82b878e
 static void
82b878e
 il4965_pass_packet_to_mac80211(struct il_priv *il, struct ieee80211_hdr *hdr,
82b878e
-			       u16 len, u32 ampdu_status, struct il_rx_buf *rxb,
82b878e
+			       u32 len, u32 ampdu_status, struct il_rx_buf *rxb,
82b878e
 			       struct ieee80211_rx_status *stats)
82b878e
 {
82b878e
 	struct sk_buff *skb;
82b878e
@@ -598,21 +600,25 @@ il4965_pass_packet_to_mac80211(struct il_priv *il, struct ieee80211_hdr *hdr,
82b878e
 	    il_set_decrypted_flag(il, hdr, ampdu_status, stats))
82b878e
 		return;
82b878e
 
82b878e
-	skb = dev_alloc_skb(128);
82b878e
+	skb = dev_alloc_skb(SMALL_PACKET_SIZE);
82b878e
 	if (!skb) {
82b878e
 		IL_ERR("dev_alloc_skb failed\n");
82b878e
 		return;
82b878e
 	}
82b878e
 
82b878e
-	skb_add_rx_frag(skb, 0, rxb->page, (void *)hdr - rxb_addr(rxb), len,
82b878e
-			len);
82b878e
+	if (len <= SMALL_PACKET_SIZE) {
82b878e
+		memcpy(skb_put(skb, len), hdr, len);
82b878e
+	} else {
82b878e
+		skb_add_rx_frag(skb, 0, rxb->page, (void *)hdr - rxb_addr(rxb),
82b878e
+				len, PAGE_SIZE << il->hw_params.rx_page_order);
82b878e
+		il->alloc_rxb_page--;
82b878e
+		rxb->page = NULL;
82b878e
+	}
82b878e
 
82b878e
 	il_update_stats(il, false, fc, len);
82b878e
 	memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats));
82b878e
 
82b878e
 	ieee80211_rx(il->hw, skb);
82b878e
-	il->alloc_rxb_page--;
82b878e
-	rxb->page = NULL;
82b878e
 }
82b878e
 
82b878e
 /* Called for N_RX (legacy ABG frames), or
82b878e
-- 
82b878e
1.7.11.7
82b878e
82b878e