6 #include <linux/export.h>
7 #include <linux/bitops.h>
9 #include <linux/slab.h>
23 if (!(basic_rates &
BIT(i)))
25 if (sband->
bitrates[i].bitrate > bitrate)
45 return 2407 + chan * 5;
48 if (chan >= 182 && chan <= 196)
49 return 4000 + chan * 5;
51 return 5000 + chan * 5;
55 return 56160 + chan * 2160;
70 return (freq - 2407) / 5;
71 else if (freq >= 4910 && freq <= 4980)
72 return (freq - 4000) / 5;
73 else if (freq <= 45000)
74 return (freq - 5000) / 5;
75 else if (freq >= 58320 && freq <= 64800)
76 return (freq - 56160) / 2160;
96 if (sband->
channels[i].center_freq == freq)
114 if (sband->
bitrates[i].bitrate == 60 ||
115 sband->
bitrates[i].bitrate == 120 ||
116 sband->
bitrates[i].bitrate == 240) {
127 if (sband->
bitrates[i].bitrate == 10) {
134 if (sband->
bitrates[i].bitrate == 20 ||
136 sband->
bitrates[i].bitrate == 110 ||
138 sband->
bitrates[i].bitrate == 120 ||
139 sband->
bitrates[i].bitrate == 240) {
145 if (sband->
bitrates[i].bitrate != 10 &&
152 WARN_ON(want != 0 && want != 3 && want != 6);
170 if (wiphy->
bands[band])
171 set_mandatory_flags_band(wiphy->
bands[band], band);
193 if (pairwise && !mac_addr)
203 if (pairwise && key_idx &&
266 if (ieee80211_is_data(fc)) {
267 if (ieee80211_has_a4(fc))
269 if (ieee80211_is_data_qos(fc)) {
271 if (ieee80211_has_order(fc))
277 if (ieee80211_is_ctl(fc)) {
372 if (!pskb_may_pull(skb, hdrlen + 1))
391 (is_multicast_ether_addr(
dst) &&
392 ether_addr_equal(
src, addr)))
398 if (!pskb_may_pull(skb, hdrlen + 1))
416 if (!pskb_may_pull(skb, hdrlen + 8))
451 const u8 *encaps_data;
452 int encaps_len, skip_header_bytes;
459 nh_pos = skb_network_header(skb) - skb->
data;
460 h_pos = skb_transport_header(skb) - skb->
data;
464 ethertype = (skb->
data[12] << 8) | skb->
data[13];
511 skip_header_bytes -= 2;
512 }
else if (ethertype > 0x600) {
515 skip_header_bytes -= 2;
522 nh_pos -= skip_header_bytes;
523 h_pos -= skip_header_bytes;
525 head_need = hdrlen + encaps_len - skb_headroom(skb);
527 if (head_need > 0 || skb_cloned(skb)) {
528 head_need =
max(head_need, 0);
540 nh_pos += encaps_len;
552 skb_set_mac_header(skb, 0);
553 skb_set_network_header(skb, nh_pos);
554 skb_set_transport_header(skb, h_pos);
563 const unsigned int extra_headroom,
564 bool has_80211_header)
573 if (has_80211_header) {
586 while (skb != frame) {
589 unsigned int subframe_len =
sizeof(
struct ethhdr) + ntohs(len);
591 remaining = skb->
len;
595 padding = (4 - subframe_len) & 0x3;
597 if (subframe_len > remaining)
602 if (remaining <= subframe_len + padding)
605 unsigned int hlen =
ALIGN(extra_headroom, 4);
610 frame = dev_alloc_skb(hlen + subframe_len + 2);
614 skb_reserve(frame, hlen +
sizeof(
struct ethhdr) + 2);
621 dev_kfree_skb(frame);
626 skb_reset_network_header(frame);
630 payload = frame->
data;
631 ethertype = (payload[6] << 8) | payload[7];
647 __skb_queue_tail(list, frame);
653 __skb_queue_purge(list);
674 dscp = ipv4_get_dsfield(ip_hdr(skb)) & 0xfc;
677 dscp = ipv6_get_dsfield(ipv6_hdr(skb)) & 0xfc;
705 for (i = 0; i < 6; i++) {
708 if (rdev->
ops->add_key(wdev->
wiphy, dev, i,
false,
NULL,
710 netdev_err(dev,
"failed to set key %d\n", i);
714 if (rdev->
ops->set_default_key(wdev->
wiphy, dev,
716 netdev_err(dev,
"failed to set defkey %d\n", i);
720 if (rdev->
ops->set_default_mgmt_key(wdev->
wiphy, dev, i))
721 netdev_err(dev,
"failed to set mgtdef %d\n", i);
739 spin_unlock_irqrestore(&wdev->
event_lock, flags);
744 if (!is_zero_ether_addr(ev->
cr.bssid))
745 bssid = ev->
cr.bssid;
748 ev->
cr.req_ie, ev->
cr.req_ie_len,
749 ev->
cr.resp_ie, ev->
cr.resp_ie_len,
756 ev->
rm.req_ie_len, ev->
rm.resp_ie,
761 ev->
dc.ie, ev->
dc.ie_len,
762 ev->
dc.reason,
true);
774 spin_unlock_irqrestore(&wdev->
event_lock, flags);
809 if (!rdev->
ops->change_virtual_intf ||
810 !(rdev->wiphy.interface_modes & (1 << ntype)))
820 if (ntype != otype && netif_running(dev)) {
822 err = cfg80211_can_change_interface(rdev, dev->
ieee80211_ptr,
853 err = rdev->
ops->change_virtual_intf(&rdev->wiphy, dev,
854 ntype, flags, params);
858 if (!err && params && params->
use_4addr != -1)
892 if (!err && ntype != otype && netif_running(dev)) {
902 static const u32 __mcs2bitrate[] = {
944 return __mcs2bitrate[rate->
mcs];
954 return cfg80211_calculate_bitrate_60g(rate);
960 modulation = rate->
mcs & 7;
961 streams = (rate->
mcs >> 3) + 1;
967 bitrate *= (modulation + 1);
968 else if (modulation == 4)
969 bitrate *= (modulation + 2);
971 bitrate *= (modulation + 3);
976 bitrate = (bitrate / 9) * 10;
979 return (bitrate + 50000) / 100000;
1015 u32 used_iftypes =
BIT(iftype);
1021 int num_different_channels = 0;
1029 if (rdev->wiphy.software_iftypes &
BIT(iftype))
1032 memset(num, 0,
sizeof(num));
1033 memset(used_channels, 0,
sizeof(used_channels));
1042 used_channels[0] = chan;
1043 num_different_channels++;
1046 num_different_channels++;
1051 if (wdev_iter == wdev)
1054 if (!netif_running(wdev_iter->
netdev))
1063 if (rdev->wiphy.software_iftypes &
BIT(wdev_iter->
iftype))
1075 wdev_unlock(wdev_iter);
1082 if (!used_channels[i] || used_channels[i] == ch)
1085 if (i == CFG80211_MAX_NUM_DIFFERENT_CHANNELS)
1088 if (used_channels[i] ==
NULL) {
1089 used_channels[
i] = ch;
1090 num_different_channels++;
1094 num_different_channels++;
1098 num[wdev_iter->
iftype]++;
1106 for (i = 0; i < rdev->wiphy.n_iface_combinations; i++) {
1109 u32 all_iftypes = 0;
1111 c = &rdev->wiphy.iface_combinations[
i];
1124 if (rdev->wiphy.software_iftypes &
BIT(iftype))
1126 for (j = 0; j < c->
n_limits; j++) {
1127 all_iftypes |= limits[
j].
types;
1128 if (!(limits[j].
types &
BIT(iftype)))
1130 if (limits[j].
max < num[iftype])
1142 if ((all_iftypes & used_iftypes) != used_iftypes)
1159 const u8 *rates,
unsigned int n_rates,
1172 for (i = 0; i < n_rates; i++) {
1173 int rate = (rates[
i] & 0x7f) * 5;
1177 if (sband->
bitrates[j].bitrate == rate) {
1199 { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
1204 { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 };