316-mac80211-skip-encap-offload-for-tx-multicast-control.patch 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. From: Felix Fietkau <[email protected]>
  2. Date: Fri, 21 Aug 2020 05:54:10 +0200
  3. Subject: [PATCH] mac80211: skip encap offload for tx multicast/control
  4. packets
  5. This simplifies the checks in the encap offload tx handler and allows using
  6. it in cases where software crypto is used for multicast packets, e.g. when
  7. using an AP_VLAN.
  8. Signed-off-by: Felix Fietkau <[email protected]>
  9. ---
  10. --- a/net/mac80211/tx.c
  11. +++ b/net/mac80211/tx.c
  12. @@ -4184,88 +4184,47 @@ static void ieee80211_8023_xmit(struct i
  13. struct sk_buff *skb)
  14. {
  15. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  16. - struct ethhdr *ehdr = (struct ethhdr *)skb->data;
  17. struct ieee80211_local *local = sdata->local;
  18. - bool authorized = false;
  19. - bool multicast;
  20. - unsigned char *ra = ehdr->h_dest;
  21. struct tid_ampdu_tx *tid_tx;
  22. u8 tid;
  23. - if (IS_ERR(sta) || (sta && !sta->uploaded))
  24. - sta = NULL;
  25. -
  26. - if (sdata->vif.type == NL80211_IFTYPE_STATION &&
  27. - (!sta || !test_sta_flag(sta, WLAN_STA_TDLS_PEER)))
  28. - ra = sdata->u.mgd.bssid;
  29. -
  30. - if (is_zero_ether_addr(ra))
  31. - goto out_free;
  32. -
  33. if (local->ops->wake_tx_queue) {
  34. u16 queue = __ieee80211_select_queue(sdata, sta, skb);
  35. skb_set_queue_mapping(skb, queue);
  36. skb_get_hash(skb);
  37. }
  38. - multicast = is_multicast_ether_addr(ra);
  39. -
  40. - if (sta)
  41. - authorized = test_sta_flag(sta, WLAN_STA_AUTHORIZED);
  42. -
  43. - if (!multicast && !authorized &&
  44. - (ehdr->h_proto != sdata->control_port_protocol ||
  45. - !ether_addr_equal(sdata->vif.addr, ehdr->h_source)))
  46. - goto out_free;
  47. -
  48. - if (multicast && sdata->vif.type == NL80211_IFTYPE_AP &&
  49. - !atomic_read(&sdata->u.ap.num_mcast_sta))
  50. - goto out_free;
  51. -
  52. if (unlikely(test_bit(SCAN_SW_SCANNING, &local->scanning)) &&
  53. test_bit(SDATA_STATE_OFFCHANNEL, &sdata->state))
  54. goto out_free;
  55. memset(info, 0, sizeof(*info));
  56. - if (sta) {
  57. - tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK;
  58. - tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]);
  59. - if (tid_tx) {
  60. - if (!test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) {
  61. - /* fall back to non-offload slow path */
  62. - __ieee80211_subif_start_xmit(skb, dev, 0, 0, NULL);
  63. - return;
  64. - }
  65. -
  66. - info->flags |= IEEE80211_TX_CTL_AMPDU;
  67. - if (tid_tx->timeout)
  68. - tid_tx->last_tx = jiffies;
  69. + tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK;
  70. + tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]);
  71. + if (tid_tx) {
  72. + if (!test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) {
  73. + /* fall back to non-offload slow path */
  74. + __ieee80211_subif_start_xmit(skb, dev, 0, 0, NULL);
  75. + return;
  76. }
  77. +
  78. + info->flags |= IEEE80211_TX_CTL_AMPDU;
  79. + if (tid_tx->timeout)
  80. + tid_tx->last_tx = jiffies;
  81. }
  82. - if (unlikely(!multicast && skb->sk &&
  83. + if (unlikely(skb->sk &&
  84. skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS))
  85. info->ack_frame_id = ieee80211_store_ack_skb(local, skb,
  86. &info->flags, NULL);
  87. - if (unlikely(sdata->control_port_protocol == ehdr->h_proto)) {
  88. - if (sdata->control_port_no_encrypt)
  89. - info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
  90. - info->control.flags |= IEEE80211_TX_CTRL_PORT_CTRL_PROTO;
  91. - }
  92. -
  93. - if (multicast)
  94. - info->flags |= IEEE80211_TX_CTL_NO_ACK;
  95. -
  96. info->hw_queue = sdata->vif.hw_queue[skb_get_queue_mapping(skb)];
  97. ieee80211_tx_stats(dev, skb->len);
  98. - if (sta) {
  99. - sta->tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len;
  100. - sta->tx_stats.packets[skb_get_queue_mapping(skb)]++;
  101. - }
  102. + sta->tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len;
  103. + sta->tx_stats.packets[skb_get_queue_mapping(skb)]++;
  104. if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
  105. sdata = container_of(sdata->bss,
  106. @@ -4286,6 +4245,7 @@ netdev_tx_t ieee80211_subif_start_xmit_8
  107. struct net_device *dev)
  108. {
  109. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  110. + struct ethhdr *ehdr = (struct ethhdr *)skb->data;
  111. struct sta_info *sta;
  112. if (WARN_ON(!sdata->hw_80211_encap)) {
  113. @@ -4302,6 +4262,10 @@ netdev_tx_t ieee80211_subif_start_xmit_8
  114. if (ieee80211_lookup_ra_sta(sdata, skb, &sta))
  115. kfree_skb(skb);
  116. + else if (unlikely(IS_ERR_OR_NULL(sta) || !sta->uploaded ||
  117. + !test_sta_flag(sta, WLAN_STA_AUTHORIZED) ||
  118. + sdata->control_port_protocol == ehdr->h_proto))
  119. + ieee80211_subif_start_xmit(skb, dev);
  120. else
  121. ieee80211_8023_xmit(sdata, dev, sta, skb);