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/iface.c
14 +++ b/net/mac80211/iface.c
15 @@ -378,7 +378,8 @@ static bool ieee80211_set_sdata_offload_
16 if (key->conf.cipher == WLAN_CIPHER_SUITE_AES_CMAC ||
17 key->conf.cipher == WLAN_CIPHER_SUITE_BIP_GMAC_128 ||
18 key->conf.cipher == WLAN_CIPHER_SUITE_BIP_GMAC_256 ||
19 - key->conf.cipher == WLAN_CIPHER_SUITE_BIP_CMAC_256)
20 + key->conf.cipher == WLAN_CIPHER_SUITE_BIP_CMAC_256 ||
21 + !(key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE))
23 if (key->conf.cipher == WLAN_CIPHER_SUITE_TKIP ||
24 !(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
25 @@ -1448,7 +1449,8 @@ static void ieee80211_set_vif_encap_ops(
26 if (key->conf.cipher == WLAN_CIPHER_SUITE_AES_CMAC ||
27 key->conf.cipher == WLAN_CIPHER_SUITE_BIP_GMAC_128 ||
28 key->conf.cipher == WLAN_CIPHER_SUITE_BIP_GMAC_256 ||
29 - key->conf.cipher == WLAN_CIPHER_SUITE_BIP_CMAC_256)
30 + key->conf.cipher == WLAN_CIPHER_SUITE_BIP_CMAC_256 ||
31 + !(key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE))
33 if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
35 --- a/net/mac80211/tx.c
36 +++ b/net/mac80211/tx.c
37 @@ -4190,88 +4190,47 @@ static void ieee80211_8023_xmit(struct i
40 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
41 - struct ethhdr *ehdr = (struct ethhdr *)skb->data;
42 struct ieee80211_local *local = sdata->local;
43 - bool authorized = false;
45 - unsigned char *ra = ehdr->h_dest;
46 struct tid_ampdu_tx *tid_tx;
49 - if (IS_ERR(sta) || (sta && !sta->uploaded))
52 - if (sdata->vif.type == NL80211_IFTYPE_STATION &&
53 - (!sta || !test_sta_flag(sta, WLAN_STA_TDLS_PEER)))
54 - ra = sdata->u.mgd.bssid;
56 - if (is_zero_ether_addr(ra))
59 if (local->ops->wake_tx_queue) {
60 u16 queue = __ieee80211_select_queue(sdata, sta, skb);
61 skb_set_queue_mapping(skb, queue);
65 - multicast = is_multicast_ether_addr(ra);
68 - authorized = test_sta_flag(sta, WLAN_STA_AUTHORIZED);
70 - if (!multicast && !authorized &&
71 - (ehdr->h_proto != sdata->control_port_protocol ||
72 - !ether_addr_equal(sdata->vif.addr, ehdr->h_source)))
75 - if (multicast && sdata->vif.type == NL80211_IFTYPE_AP &&
76 - !atomic_read(&sdata->u.ap.num_mcast_sta))
79 if (unlikely(test_bit(SCAN_SW_SCANNING, &local->scanning)) &&
80 test_bit(SDATA_STATE_OFFCHANNEL, &sdata->state))
83 memset(info, 0, sizeof(*info));
86 - tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK;
87 - tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]);
89 - if (!test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) {
90 - /* fall back to non-offload slow path */
91 - __ieee80211_subif_start_xmit(skb, dev, 0, 0, NULL);
95 - info->flags |= IEEE80211_TX_CTL_AMPDU;
96 - if (tid_tx->timeout)
97 - tid_tx->last_tx = jiffies;
98 + tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK;
99 + tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]);
101 + if (!test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) {
102 + /* fall back to non-offload slow path */
103 + __ieee80211_subif_start_xmit(skb, dev, 0, 0, NULL);
107 + info->flags |= IEEE80211_TX_CTL_AMPDU;
108 + if (tid_tx->timeout)
109 + tid_tx->last_tx = jiffies;
112 - if (unlikely(!multicast && skb->sk &&
113 + if (unlikely(skb->sk &&
114 skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS))
115 info->ack_frame_id = ieee80211_store_ack_skb(local, skb,
118 - if (unlikely(sdata->control_port_protocol == ehdr->h_proto)) {
119 - if (sdata->control_port_no_encrypt)
120 - info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
121 - info->control.flags |= IEEE80211_TX_CTRL_PORT_CTRL_PROTO;
125 - info->flags |= IEEE80211_TX_CTL_NO_ACK;
127 info->hw_queue = sdata->vif.hw_queue[skb_get_queue_mapping(skb)];
129 ieee80211_tx_stats(dev, skb->len);
132 - sta->tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len;
133 - sta->tx_stats.packets[skb_get_queue_mapping(skb)]++;
135 + sta->tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len;
136 + sta->tx_stats.packets[skb_get_queue_mapping(skb)]++;
138 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
139 sdata = container_of(sdata->bss,
140 @@ -4292,6 +4251,7 @@ netdev_tx_t ieee80211_subif_start_xmit_8
141 struct net_device *dev)
143 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
144 + struct ethhdr *ehdr = (struct ethhdr *)skb->data;
145 struct sta_info *sta;
147 if (unlikely(skb->len < ETH_HLEN)) {
148 @@ -4303,6 +4263,10 @@ netdev_tx_t ieee80211_subif_start_xmit_8
150 if (ieee80211_lookup_ra_sta(sdata, skb, &sta))
152 + else if (unlikely(IS_ERR_OR_NULL(sta) || !sta->uploaded ||
153 + !test_sta_flag(sta, WLAN_STA_AUTHORIZED) ||
154 + sdata->control_port_protocol == ehdr->h_proto))
155 + ieee80211_subif_start_xmit(skb, dev);
157 ieee80211_8023_xmit(sdata, dev, sta, skb);