319-mac80211-avoid-extra-memcpy-in-A-MSDU-head-creation.patch 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. From: Michael Braun <michael-dev@fami-braun.de>
  2. Date: Sat, 15 Oct 2016 13:28:18 +0200
  3. Subject: [PATCH] mac80211: avoid extra memcpy in A-MSDU head creation
  4. Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
  5. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  6. ---
  7. --- a/net/mac80211/tx.c
  8. +++ b/net/mac80211/tx.c
  9. @@ -3069,11 +3069,11 @@ static bool ieee80211_amsdu_prepare_head
  10. struct ieee80211_local *local = sdata->local;
  11. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  12. struct ieee80211_hdr *hdr;
  13. - struct ethhdr amsdu_hdr;
  14. + struct ethhdr *amsdu_hdr;
  15. int hdr_len = fast_tx->hdr_len - sizeof(rfc1042_header);
  16. int subframe_len = skb->len - hdr_len;
  17. void *data;
  18. - u8 *qc;
  19. + u8 *qc, *h_80211_src, *h_80211_dst;
  20. if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE)
  21. return false;
  22. @@ -3081,19 +3081,22 @@ static bool ieee80211_amsdu_prepare_head
  23. if (info->control.flags & IEEE80211_TX_CTRL_AMSDU)
  24. return true;
  25. - if (!ieee80211_amsdu_realloc_pad(local, skb, sizeof(amsdu_hdr),
  26. + if (!ieee80211_amsdu_realloc_pad(local, skb, sizeof(*amsdu_hdr),
  27. &subframe_len))
  28. return false;
  29. - amsdu_hdr.h_proto = cpu_to_be16(subframe_len);
  30. - memcpy(amsdu_hdr.h_source, skb->data + fast_tx->sa_offs, ETH_ALEN);
  31. - memcpy(amsdu_hdr.h_dest, skb->data + fast_tx->da_offs, ETH_ALEN);
  32. + data = skb_push(skb, sizeof(*amsdu_hdr));
  33. + memmove(data, data + sizeof(*amsdu_hdr), hdr_len);
  34. + hdr = data;
  35. + amsdu_hdr = data + hdr_len;
  36. + /* h_80211_src/dst is addr* field within hdr */
  37. + h_80211_src = data + fast_tx->sa_offs;
  38. + h_80211_dst = data + fast_tx->da_offs;
  39. - data = skb_push(skb, sizeof(amsdu_hdr));
  40. - memmove(data, data + sizeof(amsdu_hdr), hdr_len);
  41. - memcpy(data + hdr_len, &amsdu_hdr, sizeof(amsdu_hdr));
  42. + amsdu_hdr->h_proto = cpu_to_be16(subframe_len);
  43. + ether_addr_copy(amsdu_hdr->h_source, h_80211_src);
  44. + ether_addr_copy(amsdu_hdr->h_dest, h_80211_dst);
  45. - hdr = data;
  46. qc = ieee80211_get_qos_ctl(hdr);
  47. *qc |= IEEE80211_QOS_CTL_A_MSDU_PRESENT;