15 #include <linux/netdevice.h>
16 #include <linux/export.h>
17 #include <linux/types.h>
18 #include <linux/slab.h>
21 #include <linux/if_arp.h>
22 #include <linux/bitmap.h>
44 local = wiphy_priv(wiphy);
58 if (ieee80211_is_data(fc)) {
62 if (ieee80211_has_a4(fc))
64 if (ieee80211_has_tods(fc))
66 if (ieee80211_has_fromds(fc))
72 if (ieee80211_is_mgmt(fc)) {
78 if (ieee80211_is_ctl(fc)) {
79 if(ieee80211_is_pspoll(fc))
82 if (ieee80211_is_back_req(fc)) {
103 skb_queue_walk(&tx->
skbs, skb) {
110 int rate,
int erp,
int short_preamble)
154 dur += short_preamble ? (72 + 24) : (144 + 48);
172 bool short_preamble =
false;
176 sdata = vif_to_sdata(vif);
177 short_preamble = sdata->
vif.bss_conf.use_short_preamble;
201 sband = local->
hw.wiphy->bands[frame_txctl->
band];
203 short_preamble =
false;
209 sdata = vif_to_sdata(vif);
210 short_preamble = sdata->
vif.bss_conf.use_short_preamble;
217 erp, short_preamble);
220 erp, short_preamble);
223 erp, short_preamble);
242 sband = local->
hw.wiphy->bands[frame_txctl->
band];
244 short_preamble =
false;
249 sdata = vif_to_sdata(vif);
250 short_preamble = sdata->
vif.bss_conf.use_short_preamble;
257 erp, short_preamble);
261 erp, short_preamble);
289 for (ac = 0; ac < n_acs; ac++) {
290 int ac_queue = sdata->
vif.hw_queue[
ac];
292 if (ac_queue == queue ||
293 (sdata->
vif.cab_queue == queue &&
295 skb_queue_empty(&local->
pending[ac_queue])))
296 netif_wake_subqueue(sdata->
dev, ac);
306 trace_wake_queue(local, queue, reason);
320 if (skb_queue_empty(&local->
pending[queue])) {
335 __ieee80211_wake_queue(hw, queue, reason);
346 static void __ieee80211_stop_queue(
struct ieee80211_hw *hw,
int queue,
353 trace_stop_queue(local, queue, reason);
373 for (ac = 0; ac < n_acs; ac++) {
374 if (sdata->
vif.hw_queue[ac] == queue ||
375 sdata->
vif.cab_queue == queue)
376 netif_stop_subqueue(sdata->
dev, ac);
389 __ieee80211_stop_queue(hw, queue, reason);
415 __skb_queue_tail(&local->
pending[queue], skb);
422 void (*
fn)(
void *
data),
void *data)
440 __ieee80211_stop_queue(hw, queue,
443 __skb_queue_tail(&local->
pending[queue], skb);
449 for (i = 0; i < hw->
queues; i++)
450 __ieee80211_wake_queue(hw, i,
464 for (i = 0; i < hw->
queues; i++)
465 __ieee80211_stop_queue(hw, i, reason);
502 for (i = 0; i < hw->
queues; i++)
503 __ieee80211_wake_queue(hw, i, reason);
526 switch (sdata->
vif.type) {
533 if (ieee80211_sdata_running(sdata))
534 iterator(data, sdata->
vif.addr,
541 iterator(data, sdata->
vif.addr, &sdata->
vif);
559 switch (sdata->
vif.type) {
566 if (ieee80211_sdata_running(sdata))
567 iterator(data, sdata->
vif.addr,
573 iterator(data, sdata->
vif.addr, &sdata->
vif);
589 "queueing ieee80211 work while going to suspend\n"))
599 if (!ieee80211_can_queue_work(local))
612 if (!ieee80211_can_queue_work(local))
625 bool calc_crc = filter != 0;
628 bitmap_zero(seen_elems, 256);
629 memset(elems, 0,
sizeof(*elems));
635 bool elem_parse_failed;
683 if (calc_crc &&
id < 64 && (filter & (1ULL <<
id)))
684 crc =
crc32_be(crc, pos - 2, elen + 2);
686 elem_parse_failed =
false;
711 elems->
tim = (
void *)pos;
714 elem_parse_failed =
true;
725 if (elen >= 4 && pos[0] == 0x00 && pos[1] == 0x50 &&
730 crc =
crc32_be(crc, pos - 2, elen + 2);
736 }
else if (elen >= 5 && pos[3] == 2) {
741 }
else if (pos[4] == 1) {
764 elem_parse_failed =
true;
770 elem_parse_failed =
true;
780 elem_parse_failed =
true;
802 elem_parse_failed =
true;
806 elem_parse_failed =
true;
824 elem_parse_failed =
true;
837 if (elem_parse_failed)
864 bool use_11b, enable_qos;
867 if (!local->
ops->conf_tx)
873 memset(&qparam, 0,
sizeof(qparam));
911 qparam.
cw_min = (aCWmin + 1) / 2 - 1;
913 qparam.
txop = 6016/32;
915 qparam.
txop = 3008/32;
919 qparam.
cw_max = (aCWmin + 1) / 2 - 1;
920 qparam.
cw_min = (aCWmin + 1) / 4 - 1;
922 qparam.
txop = 3264/32;
924 qparam.
txop = 1504/32;
936 qparam.
uapsd =
false;
939 drv_conf_tx(local, sdata, ac, &qparam);
944 sdata->
vif.bss_conf.qos = enable_qos;
952 const size_t supp_rates_len,
953 const u8 *supp_rates)
956 int i, have_higher_than_11mbit = 0;
959 for (i = 0; i < supp_rates_len; i++)
960 if ((supp_rates[i] & 0x7f) * 5 > 110)
961 have_higher_than_11mbit = 1;
964 have_higher_than_11mbit)
981 sband = local->
hw.wiphy->bands[band];
993 if (bitrates[i].
flags & mandatory_flag)
994 mandatory_rates |=
BIT(i);
995 return mandatory_rates;
1008 skb = dev_alloc_skb(local->
hw.extra_tx_headroom +
1009 sizeof(*mgmt) + 6 + extra_len);
1013 skb_reserve(skb, local->
hw.extra_tx_headroom);
1023 mgmt->
u.auth.auth_transaction =
cpu_to_le16(transaction);
1035 ieee80211_tx_skb(sdata, skb);
1057 skb = dev_alloc_skb(local->
hw.extra_tx_headroom +
1062 skb_reserve(skb, local->
hw.extra_tx_headroom);
1070 IEEE80211_SKB_CB(skb)->flags |=
1073 ieee80211_tx_skb(sdata, skb);
1084 size_t offset = 0, noffset;
1085 int supp_rates_len,
i;
1090 sband = local->
hw.wiphy->bands[
band];
1098 if ((
BIT(i) & rate_mask) == 0)
1100 rates[num_rates++] = (
u8) (sband->
bitrates[i].bitrate / 5);
1103 supp_rates_len =
min_t(
int, num_rates, 8);
1106 *pos++ = supp_rates_len;
1107 memcpy(pos, rates, supp_rates_len);
1108 pos += supp_rates_len;
1112 static const u8 before_extrates[] = {
1121 memcpy(pos, ie + offset, noffset - offset);
1126 ext_rates_len = num_rates - supp_rates_len;
1127 if (ext_rates_len > 0) {
1129 *pos++ = ext_rates_len;
1130 memcpy(pos, rates + supp_rates_len, ext_rates_len);
1131 pos += ext_rates_len;
1142 static const u8 before_ht[] = {
1153 memcpy(pos, ie + offset, noffset - offset);
1158 if (sband->
ht_cap.ht_supported)
1170 memcpy(pos, ie + offset, noffset - offset);
1174 if (sband->
vht_cap.vht_supported)
1184 const u8 *
ssid,
size_t ssid_len,
1234 const u8 *
ssid,
size_t ssid_len,
1236 u32 ratemask,
bool directed,
bool no_cck,
1243 ie, ie_len, directed);
1246 IEEE80211_SKB_CB(skb)->flags |=
1248 ieee80211_tx_skb(sdata, skb);
1261 sband = local->
hw.wiphy->bands[band];
1274 if (i < elems->supp_rates_len)
1279 own_rate = 5 * (rate & 0x7f);
1280 is_basic = !!(rate & 0x80);
1285 for (j = 0; j < num_rates; j++) {
1286 if (bitrates[j].
bitrate == own_rate) {
1287 supp_rates |=
BIT(j);
1288 if (basic_rates && is_basic)
1289 *basic_rates |=
BIT(j);
1320 res = drv_resume(local);
1344 res = drv_start(local);
1347 "upon resume. This could be a software issue "
1348 "prior to suspend or a hardware issue.\n");
1353 drv_set_frag_threshold(local, hw->
wiphy->frag_threshold);
1356 drv_set_rts_threshold(local, hw->
wiphy->rts_threshold);
1359 drv_set_coverage_class(local, hw->
wiphy->coverage_class);
1368 res = drv_add_interface(local, sdata);
1379 ieee80211_sdata_running(sdata))
1380 res = drv_add_interface(local, sdata);
1407 !ieee80211_sdata_running(sdata))
1411 drv_conf_tx(local, sdata, i,
1425 if (!ieee80211_sdata_running(sdata))
1440 switch (sdata->
vif.type) {
1494 if (!sdata->
u.
mgd.associated)
1521 if (ieee80211_sdata_running(sdata))
1566 switch(sdata->
vif.type) {
1574 ieee80211_mesh_restart(sdata);
1585 mesh_plink_restart(sta);
1602 sdata = vif_to_sdata(vif);
1603 local = sdata->
local;
1624 *smps_mode = ifmgd->ap_smps;
1658 if (!ieee80211_sdata_running(sdata))
1665 count += check_mgd_smps(&sdata->
u.
mgd, &smps_mode);
1684 static bool ieee80211_id_in_list(
const u8 *ids,
int n_ids,
u8 id)
1688 for (i = 0; i < n_ids; i++)
1720 const u8 *ids,
int n_ids,
size_t offset)
1724 while (pos < ielen && ieee80211_id_in_list(ids, n_ids, ies[pos]))
1725 pos += 2 + ies[pos + 1];
1735 pos += 2 + ies[pos + 1];
1744 trace_api_enable_rssi_reports(sdata, rssi_min_thold, rssi_max_thold);
1754 sdata->
u.
mgd.rssi_min_thold = rssi_min_thold*16;
1755 sdata->
u.
mgd.rssi_max_thold = rssi_max_thold*16;
1764 WARN_ON(rssi_min_thold == rssi_max_thold ||
1765 rssi_min_thold > rssi_max_thold);
1767 _ieee80211_enable_rssi_reports(sdata, rssi_min_thold,
1776 _ieee80211_enable_rssi_reports(sdata, 0, 0);
1801 pos +=
sizeof(ht_cap->
mcs);
1831 pos +=
sizeof(vht_cap->
vht_mcs);
1848 switch (channel_type) {
1909 u32 basic_rates = sdata->
vif.bss_conf.basic_rates;
1911 sband = local->
hw.wiphy->bands[
band];
1916 if (skb_tailroom(skb) < rates + 2)
1919 pos =
skb_put(skb, rates + 2);
1922 for (i = 0; i < rates; i++) {
1924 if (need_basic && basic_rates &
BIT(i))
1927 *pos++ = basic | (
u8) (rate / 5);
1941 u32 basic_rates = sdata->
vif.bss_conf.basic_rates;
1943 sband = local->
hw.wiphy->bands[
band];
1950 if (skb_tailroom(skb) < exrates + 2)
1954 pos =
skb_put(skb, exrates + 2);
1959 if (need_basic && basic_rates &
BIT(i))
1962 *pos++ = basic | (
u8) (rate / 5);