1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Fri, 21 Aug 2020 05:54:10 +0200
3 Subject: [PATCH] mac80211: skip encap offload for tx multicast/control
6 This simplifies the checks in the encap offload tx handler and allows using
7 it in cases where software crypto is used for multicast packets, e.g. when
10 Signed-off-by: Felix Fietkau <nbd@nbd.name>
13 --- a/net/mac80211/tx.c
14 +++ b/net/mac80211/tx.c
15 @@ -4184,88 +4184,47 @@ static void ieee80211_8023_xmit(struct i
18 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
19 - struct ethhdr *ehdr = (struct ethhdr *)skb->data;
20 struct ieee80211_local *local = sdata->local;
21 - bool authorized = false;
23 - unsigned char *ra = ehdr->h_dest;
24 struct tid_ampdu_tx *tid_tx;
27 - if (IS_ERR(sta) || (sta && !sta->uploaded))
30 - if (sdata->vif.type == NL80211_IFTYPE_STATION &&
31 - (!sta || !test_sta_flag(sta, WLAN_STA_TDLS_PEER)))
32 - ra = sdata->u.mgd.bssid;
34 - if (is_zero_ether_addr(ra))
37 if (local->ops->wake_tx_queue) {
38 u16 queue = __ieee80211_select_queue(sdata, sta, skb);
39 skb_set_queue_mapping(skb, queue);
43 - multicast = is_multicast_ether_addr(ra);
46 - authorized = test_sta_flag(sta, WLAN_STA_AUTHORIZED);
48 - if (!multicast && !authorized &&
49 - (ehdr->h_proto != sdata->control_port_protocol ||
50 - !ether_addr_equal(sdata->vif.addr, ehdr->h_source)))
53 - if (multicast && sdata->vif.type == NL80211_IFTYPE_AP &&
54 - !atomic_read(&sdata->u.ap.num_mcast_sta))
57 if (unlikely(test_bit(SCAN_SW_SCANNING, &local->scanning)) &&
58 test_bit(SDATA_STATE_OFFCHANNEL, &sdata->state))
61 memset(info, 0, sizeof(*info));
64 - tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK;
65 - tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]);
67 - if (!test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) {
68 - /* fall back to non-offload slow path */
69 - __ieee80211_subif_start_xmit(skb, dev, 0, 0, NULL);
73 - info->flags |= IEEE80211_TX_CTL_AMPDU;
74 - if (tid_tx->timeout)
75 - tid_tx->last_tx = jiffies;
76 + tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK;
77 + tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]);
79 + if (!test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) {
80 + /* fall back to non-offload slow path */
81 + __ieee80211_subif_start_xmit(skb, dev, 0, 0, NULL);
85 + info->flags |= IEEE80211_TX_CTL_AMPDU;
86 + if (tid_tx->timeout)
87 + tid_tx->last_tx = jiffies;
90 - if (unlikely(!multicast && skb->sk &&
91 + if (unlikely(skb->sk &&
92 skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS))
93 info->ack_frame_id = ieee80211_store_ack_skb(local, skb,
96 - if (unlikely(sdata->control_port_protocol == ehdr->h_proto)) {
97 - if (sdata->control_port_no_encrypt)
98 - info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
99 - info->control.flags |= IEEE80211_TX_CTRL_PORT_CTRL_PROTO;
103 - info->flags |= IEEE80211_TX_CTL_NO_ACK;
105 info->hw_queue = sdata->vif.hw_queue[skb_get_queue_mapping(skb)];
107 ieee80211_tx_stats(dev, skb->len);
110 - sta->tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len;
111 - sta->tx_stats.packets[skb_get_queue_mapping(skb)]++;
113 + sta->tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len;
114 + sta->tx_stats.packets[skb_get_queue_mapping(skb)]++;
116 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
117 sdata = container_of(sdata->bss,
118 @@ -4286,6 +4245,7 @@ netdev_tx_t ieee80211_subif_start_xmit_8
119 struct net_device *dev)
121 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
122 + struct ethhdr *ehdr = (struct ethhdr *)skb->data;
123 struct sta_info *sta;
125 if (WARN_ON(!sdata->hw_80211_encap)) {
126 @@ -4302,6 +4262,10 @@ netdev_tx_t ieee80211_subif_start_xmit_8
128 if (ieee80211_lookup_ra_sta(sdata, skb, &sta))
130 + else if (unlikely(IS_ERR_OR_NULL(sta) || !sta->uploaded ||
131 + !test_sta_flag(sta, WLAN_STA_AUTHORIZED) ||
132 + sdata->control_port_protocol == ehdr->h_proto))
133 + ieee80211_subif_start_xmit(skb, dev);
135 ieee80211_8023_xmit(sdata, dev, sta, skb);