iw: refresh patches
[openwrt/staging/yousong.git] / package / network / utils / iw / patches / 301-ibss_add_VHT80.patch
1 From: "Janusz.Dziedzic@tieto.com" <Janusz.Dziedzic@tieto.com>
2 Date: Thu, 10 Sep 2015 12:04:13 +0200
3 Subject: ibss: add VHT80 support for IBSS
4
5 Add VHT80 support for IBSS.
6
7 eg. iw wlan0 ibss join 5180 80MHZ
8 iw wlan0 ibbs join 5220 80MHZ
9
10 Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
11 [fix formatting]
12 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
13 ---
14 ibss.c | 49 +++++++++++++++++++++++++++++++++++++++++--------
15 1 file changed, 41 insertions(+), 8 deletions(-)
16
17 --- a/ibss.c
18 +++ b/ibss.c
19 @@ -16,6 +16,39 @@
20
21 SECTION(ibss);
22
23 +struct chanmode {
24 + const char *name;
25 + unsigned int width;
26 + int freq1_diff;
27 + int chantype; /* for older kernel */
28 +};
29 +
30 +static int get_cf1(const struct chanmode *chanmode, unsigned long freq)
31 +{
32 + int cf1 = freq, j;
33 + int vht80[] = { 5180, 5260, 5500, 5580, 5660, 5745 };
34 +
35 + switch (chanmode->width) {
36 + case NL80211_CHAN_WIDTH_80:
37 + /* setup center_freq1 */
38 + for (j = 0; j < ARRAY_SIZE(vht80); j++) {
39 + if (freq >= vht80[j] && freq < vht80[j] + 80)
40 + break;
41 + }
42 +
43 + if (j == ARRAY_SIZE(vht80))
44 + break;
45 +
46 + cf1 = vht80[j] + 30;
47 + break;
48 + default:
49 + cf1 = freq + chanmode->freq1_diff;
50 + break;
51 + }
52 +
53 + return cf1;
54 +}
55 +
56 static int join_ibss(struct nl80211_state *state,
57 struct nl_msg *msg,
58 int argc, char **argv,
59 @@ -30,12 +63,8 @@ static int join_ibss(struct nl80211_stat
60 int bintval;
61 int i;
62 unsigned long freq;
63 - static const struct {
64 - const char *name;
65 - unsigned int width;
66 - int freq1_diff;
67 - int chantype; /* for older kernel */
68 - } *chanmode_selected = NULL, chanmode[] = {
69 + const struct chanmode *chanmode_selected = NULL;
70 + static const struct chanmode chanmode[] = {
71 { .name = "HT20",
72 .width = NL80211_CHAN_WIDTH_20,
73 .freq1_diff = 0,
74 @@ -60,6 +89,10 @@ static int join_ibss(struct nl80211_stat
75 .width = NL80211_CHAN_WIDTH_10,
76 .freq1_diff = 0,
77 .chantype = -1 },
78 + { .name = "80MHZ",
79 + .width = NL80211_CHAN_WIDTH_80,
80 + .freq1_diff = 0,
81 + .chantype = -1 },
82 };
83
84 if (argc < 2)
85 @@ -90,7 +123,7 @@ static int join_ibss(struct nl80211_stat
86 NLA_PUT_U32(msg, NL80211_ATTR_CHANNEL_WIDTH,
87 chanmode_selected->width);
88 NLA_PUT_U32(msg, NL80211_ATTR_CENTER_FREQ1,
89 - freq + chanmode_selected->freq1_diff);
90 + get_cf1(chanmode_selected, freq));
91 if (chanmode_selected->chantype != -1)
92 NLA_PUT_U32(msg,
93 NL80211_ATTR_WIPHY_CHANNEL_TYPE,
94 @@ -192,7 +225,7 @@ COMMAND(ibss, leave, NULL,
95 NL80211_CMD_LEAVE_IBSS, 0, CIB_NETDEV, leave_ibss,
96 "Leave the current IBSS cell.");
97 COMMAND(ibss, join,
98 - "<SSID> <freq in MHz> [HT20|HT40+|HT40-|NOHT|5MHZ|10MHZ] [fixed-freq] [<fixed bssid>] [beacon-interval <TU>]"
99 + "<SSID> <freq in MHz> [HT20|HT40+|HT40-|NOHT|5MHZ|10MHZ|80MHZ] [fixed-freq] [<fixed bssid>] [beacon-interval <TU>]"
100 " [basic-rates <rate in Mbps,rate2,...>] [mcast-rate <rate in Mbps>] "
101 "[key d:0:abcde]",
102 NL80211_CMD_JOIN_IBSS, 0, CIB_NETDEV, join_ibss,