326-wifi-mac80211-add-mesh-fast-rx-support.patch 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. From: Felix Fietkau <nbd@nbd.name>
  2. Date: Thu, 2 Mar 2023 13:52:29 +0100
  3. Subject: [PATCH] wifi: mac80211: add mesh fast-rx support
  4. This helps bring down rx CPU usage by avoiding calls to the rx handlers in
  5. the slow path. Supports forwarding and local rx, including A-MSDU.
  6. Signed-off-by: Felix Fietkau <nbd@nbd.name>
  7. ---
  8. --- a/net/mac80211/rx.c
  9. +++ b/net/mac80211/rx.c
  10. @@ -4564,6 +4564,12 @@ void ieee80211_check_fast_rx(struct sta_
  11. }
  12. break;
  13. + case NL80211_IFTYPE_MESH_POINT:
  14. + fastrx.expected_ds_bits = cpu_to_le16(IEEE80211_FCTL_FROMDS |
  15. + IEEE80211_FCTL_TODS);
  16. + fastrx.da_offs = offsetof(struct ieee80211_hdr, addr3);
  17. + fastrx.sa_offs = offsetof(struct ieee80211_hdr, addr4);
  18. + break;
  19. default:
  20. goto clear;
  21. }
  22. @@ -4772,6 +4778,7 @@ static bool ieee80211_invoke_fast_rx(str
  23. struct sk_buff *skb = rx->skb;
  24. struct ieee80211_hdr *hdr = (void *)skb->data;
  25. struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
  26. + static ieee80211_rx_result res;
  27. int orig_len = skb->len;
  28. int hdrlen = ieee80211_hdrlen(hdr->frame_control);
  29. int snap_offs = hdrlen;
  30. @@ -4833,7 +4840,8 @@ static bool ieee80211_invoke_fast_rx(str
  31. snap_offs += IEEE80211_CCMP_HDR_LEN;
  32. }
  33. - if (!(status->rx_flags & IEEE80211_RX_AMSDU)) {
  34. + if (!ieee80211_vif_is_mesh(&rx->sdata->vif) &&
  35. + !(status->rx_flags & IEEE80211_RX_AMSDU)) {
  36. if (!pskb_may_pull(skb, snap_offs + sizeof(*payload)))
  37. return false;
  38. @@ -4872,13 +4880,29 @@ static bool ieee80211_invoke_fast_rx(str
  39. /* do the header conversion - first grab the addresses */
  40. ether_addr_copy(addrs.da, skb->data + fast_rx->da_offs);
  41. ether_addr_copy(addrs.sa, skb->data + fast_rx->sa_offs);
  42. - skb_postpull_rcsum(skb, skb->data + snap_offs,
  43. - sizeof(rfc1042_header) + 2);
  44. - /* remove the SNAP but leave the ethertype */
  45. - skb_pull(skb, snap_offs + sizeof(rfc1042_header));
  46. + if (ieee80211_vif_is_mesh(&rx->sdata->vif)) {
  47. + skb_pull(skb, snap_offs - 2);
  48. + put_unaligned_be16(skb->len - 2, skb->data);
  49. + } else {
  50. + skb_postpull_rcsum(skb, skb->data + snap_offs,
  51. + sizeof(rfc1042_header) + 2);
  52. +
  53. + /* remove the SNAP but leave the ethertype */
  54. + skb_pull(skb, snap_offs + sizeof(rfc1042_header));
  55. + }
  56. /* push the addresses in front */
  57. memcpy(skb_push(skb, sizeof(addrs)), &addrs, sizeof(addrs));
  58. + res = ieee80211_rx_mesh_data(rx->sdata, rx->sta, rx->skb);
  59. + switch (res) {
  60. + case RX_QUEUED:
  61. + return true;
  62. + case RX_CONTINUE:
  63. + break;
  64. + default:
  65. + goto drop;
  66. + }
  67. +
  68. ieee80211_rx_8023(rx, fast_rx, orig_len);
  69. return true;