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