|
|
7b9b3ff |
From: Eric Dumazet <edumazet@google.com>
|
|
|
7b9b3ff |
|
|
|
7b9b3ff |
Steinar reported reallocations of skb->head with IPv6, leading to
|
|
|
7b9b3ff |
a warning in skb_try_coalesce()
|
|
|
7b9b3ff |
|
|
|
7b9b3ff |
It turns out iwl3945 has 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 |
Reported-by: Steinar H. Gunderson <sesse@google.com>
|
|
|
7b9b3ff |
Signed-off-by: Eric Dumazet <edumazet@google.com>
|
|
|
7b9b3ff |
Cc: Paul Stewart <pstew@google.com>
|
|
|
7b9b3ff |
---
|
|
|
7b9b3ff |
v3: use regular memcpy(skb_put(...),...)
|
|
|
7b9b3ff |
v2: SMALL_PACKET_SIZE define
|
|
|
7b9b3ff |
|
|
|
7b9b3ff |
drivers/net/wireless/iwlegacy/3945.c | 31 +++++++++++++++----------
|
|
|
7b9b3ff |
1 file changed, 19 insertions(+), 12 deletions(-)
|
|
|
7b9b3ff |
|
|
|
7b9b3ff |
diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c
|
|
|
7b9b3ff |
index c092033..f09e257 100644
|
|
|
7b9b3ff |
--- a/drivers/net/wireless/iwlegacy/3945.c
|
|
|
7b9b3ff |
+++ b/drivers/net/wireless/iwlegacy/3945.c
|
|
|
7b9b3ff |
@@ -475,6 +475,8 @@ il3945_is_network_packet(struct il_priv *il, struct ieee80211_hdr *header)
|
|
|
7b9b3ff |
}
|
|
|
7b9b3ff |
}
|
|
|
7b9b3ff |
|
|
|
7b9b3ff |
+#define SMALL_PACKET_SIZE 256
|
|
|
7b9b3ff |
+
|
|
|
7b9b3ff |
static void
|
|
|
7b9b3ff |
il3945_pass_packet_to_mac80211(struct il_priv *il, struct il_rx_buf *rxb,
|
|
|
7b9b3ff |
struct ieee80211_rx_status *stats)
|
|
|
7b9b3ff |
@@ -483,14 +485,13 @@ il3945_pass_packet_to_mac80211(struct il_priv *il, struct il_rx_buf *rxb,
|
|
|
7b9b3ff |
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)IL_RX_DATA(pkt);
|
|
|
7b9b3ff |
struct il3945_rx_frame_hdr *rx_hdr = IL_RX_HDR(pkt);
|
|
|
7b9b3ff |
struct il3945_rx_frame_end *rx_end = IL_RX_END(pkt);
|
|
|
7b9b3ff |
- u16 len = le16_to_cpu(rx_hdr->len);
|
|
|
7b9b3ff |
+ u32 len = le16_to_cpu(rx_hdr->len);
|
|
|
7b9b3ff |
struct sk_buff *skb;
|
|
|
7b9b3ff |
__le16 fc = hdr->frame_control;
|
|
|
7b9b3ff |
+ u32 fraglen = PAGE_SIZE << il->hw_params.rx_page_order;
|
|
|
7b9b3ff |
|
|
|
7b9b3ff |
/* We received data from the HW, so stop the watchdog */
|
|
|
7b9b3ff |
- if (unlikely
|
|
|
7b9b3ff |
- (len + IL39_RX_FRAME_SIZE >
|
|
|
7b9b3ff |
- PAGE_SIZE << il->hw_params.rx_page_order)) {
|
|
|
7b9b3ff |
+ if (unlikely(len + IL39_RX_FRAME_SIZE > fraglen)) {
|
|
|
7b9b3ff |
D_DROP("Corruption detected!\n");
|
|
|
7b9b3ff |
return;
|
|
|
7b9b3ff |
}
|
|
|
7b9b3ff |
@@ -506,26 +507,32 @@ il3945_pass_packet_to_mac80211(struct il_priv *il, struct il_rx_buf *rxb,
|
|
|
7b9b3ff |
D_INFO("Woke queues - frame received on passive channel\n");
|
|
|
7b9b3ff |
}
|
|
|
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 |
if (!il3945_mod_params.sw_crypto)
|
|
|
7b9b3ff |
- il_set_decrypted_flag(il, (struct ieee80211_hdr *)rxb_addr(rxb),
|
|
|
7b9b3ff |
+ il_set_decrypted_flag(il, (struct ieee80211_hdr *)pkt,
|
|
|
7b9b3ff |
le32_to_cpu(rx_end->status), stats);
|
|
|
7b9b3ff |
|
|
|
7b9b3ff |
- skb_add_rx_frag(skb, 0, rxb->page,
|
|
|
7b9b3ff |
- (void *)rx_hdr->payload - (void *)pkt, len,
|
|
|
7b9b3ff |
- len);
|
|
|
7b9b3ff |
-
|
|
|
7b9b3ff |
+ /* If frame is small enough to fit into skb->head, copy it
|
|
|
7b9b3ff |
+ * and do not consume a full page
|
|
|
7b9b3ff |
+ */
|
|
|
7b9b3ff |
+ if (len <= SMALL_PACKET_SIZE) {
|
|
|
7b9b3ff |
+ memcpy(skb_put(skb, len), rx_hdr->payload, len);
|
|
|
7b9b3ff |
+ } else {
|
|
|
7b9b3ff |
+ skb_add_rx_frag(skb, 0, rxb->page,
|
|
|
7b9b3ff |
+ (void *)rx_hdr->payload - (void *)pkt, len,
|
|
|
7b9b3ff |
+ fraglen);
|
|
|
7b9b3ff |
+ il->alloc_rxb_page--;
|
|
|
7b9b3ff |
+ rxb->page = NULL;
|
|
|
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 |
#define IL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6)
|
|
|
7b9b3ff |
|
|
|
7b9b3ff |
|