1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Fri, 22 Mar 2019 18:06:03 +0100
3 Subject: [PATCH] mac80211: when using iTXQ, select the queue in
4 ieee80211_subif_start_xmit
6 When using iTXQ, the network stack does not need the real queue number, since
7 mac80211 is using its internal queues anyway. In that case we can defer
8 selecting the queue and remove a redundant station lookup in the tx path to save
11 Signed-off-by: Felix Fietkau <nbd@nbd.name>
14 --- a/net/mac80211/tx.c
15 +++ b/net/mac80211/tx.c
16 @@ -3751,6 +3751,7 @@ void __ieee80211_subif_start_xmit(struct
19 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
20 + struct ieee80211_local *local = sdata->local;
24 @@ -3764,7 +3765,15 @@ void __ieee80211_subif_start_xmit(struct
25 if (ieee80211_lookup_ra_sta(sdata, skb, &sta))
28 - if (!IS_ERR_OR_NULL(sta)) {
32 + if (local->ops->wake_tx_queue) {
33 + u16 queue = __ieee80211_select_queue(sdata, sta, skb);
34 + skb_set_queue_mapping(skb, queue);
38 struct ieee80211_fast_tx *fast_tx;
40 /* We need a bit of data queued to build aggregates properly, so
41 --- a/net/mac80211/wme.c
42 +++ b/net/mac80211/wme.c
43 @@ -141,6 +141,42 @@ u16 ieee80211_select_queue_80211(struct
44 return ieee80211_downgrade_queue(sdata, NULL, skb);
47 +u16 __ieee80211_select_queue(struct ieee80211_sub_if_data *sdata,
48 + struct sta_info *sta, struct sk_buff *skb)
50 + struct mac80211_qos_map *qos_map;
53 + /* all mesh/ocb stations are required to support WME */
54 + if (sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
55 + sdata->vif.type == NL80211_IFTYPE_OCB)
63 + skb->priority = 0; /* required for correct WPA/11i MIC */
64 + return IEEE80211_AC_BE;
67 + if (skb->protocol == sdata->control_port_protocol) {
72 + /* use the data classifier to determine what 802.1d tag the
74 + qos_map = rcu_dereference(sdata->qos_map);
75 + skb->priority = cfg80211_classify8021d(skb, qos_map ?
76 + &qos_map->qos_map : NULL);
79 + return ieee80211_downgrade_queue(sdata, sta, skb);
83 /* Indicate which queue to use. */
84 u16 ieee80211_select_queue(struct ieee80211_sub_if_data *sdata,
86 @@ -148,10 +184,12 @@ u16 ieee80211_select_queue(struct ieee80
87 struct ieee80211_local *local = sdata->local;
88 struct sta_info *sta = NULL;
91 - struct mac80211_qos_map *qos_map;
94 + /* when using iTXQ, we can do this later */
95 + if (local->ops->wake_tx_queue)
98 if (local->hw.queues < IEEE80211_NUM_ACS || skb->len < 6) {
99 skb->priority = 0; /* required for correct WPA/11i MIC */
101 @@ -161,10 +199,8 @@ u16 ieee80211_select_queue(struct ieee80
102 switch (sdata->vif.type) {
103 case NL80211_IFTYPE_AP_VLAN:
104 sta = rcu_dereference(sdata->u.vlan.sta);
106 - qos = sta->sta.wme;
111 case NL80211_IFTYPE_AP:
113 @@ -172,56 +208,26 @@ u16 ieee80211_select_queue(struct ieee80
114 case NL80211_IFTYPE_WDS:
115 ra = sdata->u.wds.remote_addr;
117 -#ifdef CPTCFG_MAC80211_MESH
118 - case NL80211_IFTYPE_MESH_POINT:
122 case NL80211_IFTYPE_STATION:
123 /* might be a TDLS station */
124 sta = sta_info_get(sdata, skb->data);
126 - qos = sta->sta.wme;
129 ra = sdata->u.mgd.bssid;
131 case NL80211_IFTYPE_ADHOC:
134 - case NL80211_IFTYPE_OCB:
135 - /* all stations are required to support WME */
142 - if (!sta && ra && !is_multicast_ether_addr(ra)) {
143 + if (!sta && ra && !is_multicast_ether_addr(ra))
144 sta = sta_info_get(sdata, ra);
146 - qos = sta->sta.wme;
150 - skb->priority = 0; /* required for correct WPA/11i MIC */
151 - ret = IEEE80211_AC_BE;
154 + ret = __ieee80211_select_queue(sdata, sta, skb);
156 - if (skb->protocol == sdata->control_port_protocol) {
161 - /* use the data classifier to determine what 802.1d tag the
162 - * data frame has */
163 - qos_map = rcu_dereference(sdata->qos_map);
164 - skb->priority = cfg80211_classify8021d(skb, qos_map ?
165 - &qos_map->qos_map : NULL);
168 - ret = ieee80211_downgrade_queue(sdata, sta, skb);
173 --- a/net/mac80211/wme.h
174 +++ b/net/mac80211/wme.h
176 u16 ieee80211_select_queue_80211(struct ieee80211_sub_if_data *sdata,
178 struct ieee80211_hdr *hdr);
179 +u16 __ieee80211_select_queue(struct ieee80211_sub_if_data *sdata,
180 + struct sta_info *sta, struct sk_buff *skb);
181 u16 ieee80211_select_queue(struct ieee80211_sub_if_data *sdata,
182 struct sk_buff *skb);
183 void ieee80211_set_qos_hdr(struct ieee80211_sub_if_data *sdata,