a32075768a09b1d15034dfba0ecd28a2c8f2fc2d
[openwrt/staging/adrian.git] /
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
4 packets
5
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
8 using an AP_VLAN.
9
10 Signed-off-by: Felix Fietkau <nbd@nbd.name>
11 ---
12
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))
22 continue;
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))
32 continue;
33 if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
34 enabled = false;
35 --- a/net/mac80211/tx.c
36 +++ b/net/mac80211/tx.c
37 @@ -4184,88 +4184,47 @@ static void ieee80211_8023_xmit(struct i
38 struct sk_buff *skb)
39 {
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;
44 - bool multicast;
45 - unsigned char *ra = ehdr->h_dest;
46 struct tid_ampdu_tx *tid_tx;
47 u8 tid;
48
49 - if (IS_ERR(sta) || (sta && !sta->uploaded))
50 - sta = NULL;
51 -
52 - if (sdata->vif.type == NL80211_IFTYPE_STATION &&
53 - (!sta || !test_sta_flag(sta, WLAN_STA_TDLS_PEER)))
54 - ra = sdata->u.mgd.bssid;
55 -
56 - if (is_zero_ether_addr(ra))
57 - goto out_free;
58 -
59 if (local->ops->wake_tx_queue) {
60 u16 queue = __ieee80211_select_queue(sdata, sta, skb);
61 skb_set_queue_mapping(skb, queue);
62 skb_get_hash(skb);
63 }
64
65 - multicast = is_multicast_ether_addr(ra);
66 -
67 - if (sta)
68 - authorized = test_sta_flag(sta, WLAN_STA_AUTHORIZED);
69 -
70 - if (!multicast && !authorized &&
71 - (ehdr->h_proto != sdata->control_port_protocol ||
72 - !ether_addr_equal(sdata->vif.addr, ehdr->h_source)))
73 - goto out_free;
74 -
75 - if (multicast && sdata->vif.type == NL80211_IFTYPE_AP &&
76 - !atomic_read(&sdata->u.ap.num_mcast_sta))
77 - goto out_free;
78 -
79 if (unlikely(test_bit(SCAN_SW_SCANNING, &local->scanning)) &&
80 test_bit(SDATA_STATE_OFFCHANNEL, &sdata->state))
81 goto out_free;
82
83 memset(info, 0, sizeof(*info));
84
85 - if (sta) {
86 - tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK;
87 - tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]);
88 - if (tid_tx) {
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);
92 - return;
93 - }
94 -
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]);
100 + if (tid_tx) {
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);
104 + return;
105 }
106 +
107 + info->flags |= IEEE80211_TX_CTL_AMPDU;
108 + if (tid_tx->timeout)
109 + tid_tx->last_tx = jiffies;
110 }
111
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,
116 &info->flags, NULL);
117
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;
122 - }
123 -
124 - if (multicast)
125 - info->flags |= IEEE80211_TX_CTL_NO_ACK;
126 -
127 info->hw_queue = sdata->vif.hw_queue[skb_get_queue_mapping(skb)];
128
129 ieee80211_tx_stats(dev, skb->len);
130
131 - if (sta) {
132 - sta->tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len;
133 - sta->tx_stats.packets[skb_get_queue_mapping(skb)]++;
134 - }
135 + sta->tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len;
136 + sta->tx_stats.packets[skb_get_queue_mapping(skb)]++;
137
138 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
139 sdata = container_of(sdata->bss,
140 @@ -4286,6 +4245,7 @@ netdev_tx_t ieee80211_subif_start_xmit_8
141 struct net_device *dev)
142 {
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;
146
147 if (unlikely(skb->len < ETH_HLEN)) {
148 @@ -4297,6 +4257,10 @@ netdev_tx_t ieee80211_subif_start_xmit_8
149
150 if (ieee80211_lookup_ra_sta(sdata, skb, &sta))
151 kfree_skb(skb);
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);
156 else
157 ieee80211_8023_xmit(sdata, dev, sta, skb);
158