956b0505e662b29c24cbdf18c17b1d5c6ed106f8
[openwrt/openwrt.git] / package / network / utils / iw / patches / 303-mesh_add_VHT80.patch
1 From: Sven Eckelmann <sven@open-mesh.com>
2 Date: Tue, 24 Nov 2015 17:55:22 +0100
3 Subject: iw: add VHT80 support for 802.11s
4
5 Support next to the non-HT/HT channel widths like HT20 or NOHT also VHT80
6 channels during the mesh join
7
8 iw dev mesh0 mesh join "meshnet" freq 5180 80MHz
9
10 Signed-off-by: Sven Eckelmann <sven@open-mesh.com>
11 ---
12 ibss.c | 33 ---------------------------------
13 iw.h | 9 +++++++++
14 mesh.c | 16 ++++++++--------
15 util.c | 26 ++++++++++++++++++++++++++
16 4 files changed, 43 insertions(+), 41 deletions(-)
17
18 --- a/ibss.c
19 +++ b/ibss.c
20 @@ -16,39 +16,6 @@
21
22 SECTION(ibss);
23
24 -struct chanmode {
25 - const char *name;
26 - unsigned int width;
27 - int freq1_diff;
28 - int chantype; /* for older kernel */
29 -};
30 -
31 -static int get_cf1(const struct chanmode *chanmode, unsigned long freq)
32 -{
33 - int cf1 = freq, j;
34 - int vht80[] = { 5180, 5260, 5500, 5580, 5660, 5745 };
35 -
36 - switch (chanmode->width) {
37 - case NL80211_CHAN_WIDTH_80:
38 - /* setup center_freq1 */
39 - for (j = 0; j < ARRAY_SIZE(vht80); j++) {
40 - if (freq >= vht80[j] && freq < vht80[j] + 80)
41 - break;
42 - }
43 -
44 - if (j == ARRAY_SIZE(vht80))
45 - break;
46 -
47 - cf1 = vht80[j] + 30;
48 - break;
49 - default:
50 - cf1 = freq + chanmode->freq1_diff;
51 - break;
52 - }
53 -
54 - return cf1;
55 -}
56 -
57 static int join_ibss(struct nl80211_state *state,
58 struct nl_msg *msg,
59 int argc, char **argv,
60 --- a/iw.h
61 +++ b/iw.h
62 @@ -59,6 +59,13 @@ struct cmd {
63 const struct cmd *parent;
64 };
65
66 +struct chanmode {
67 + const char *name;
68 + unsigned int width;
69 + int freq1_diff;
70 + int chantype; /* for older kernel */
71 +};
72 +
73 #define ARRAY_SIZE(ar) (sizeof(ar)/sizeof(ar[0]))
74 #define DIV_ROUND_UP(x, y) (((x) + (y - 1)) / (y))
75
76 @@ -174,6 +181,8 @@ void print_ies(unsigned char *ie, int ie
77 void parse_bitrate(struct nlattr *bitrate_attr, char *buf, int buflen);
78 void iw_hexdump(const char *prefix, const __u8 *data, size_t len);
79
80 +int get_cf1(const struct chanmode *chanmode, unsigned long freq);
81 +
82 #define SCHED_SCAN_OPTIONS "interval <in_msecs> [delay <in_secs>] " \
83 "[freqs <freq>+] [matches [ssid <ssid>]+]] [active [ssid <ssid>]+|passive] [randomise[=<addr>/<mask>]]"
84 int parse_sched_scan(struct nl_msg *msg, int *argc, char ***argv);
85 --- a/mesh.c
86 +++ b/mesh.c
87 @@ -439,12 +439,8 @@ static int join_mesh(struct nl80211_stat
88 int bintval, dtim_period, i, n_rates = 0;
89 char *end, *value = NULL, *sptr = NULL;
90 unsigned long freq = 0;
91 - static const struct {
92 - const char *name;
93 - unsigned int width;
94 - int freq1_diff;
95 - int chantype; /* for older kernel */
96 - } *chanmode_selected = NULL, chanmode[] = {
97 + const struct chanmode *chanmode_selected = NULL;
98 + static const struct chanmode chanmode[] = {
99 { .name = "HT20",
100 .width = NL80211_CHAN_WIDTH_20,
101 .freq1_diff = 0,
102 @@ -461,6 +457,10 @@ static int join_mesh(struct nl80211_stat
103 .width = NL80211_CHAN_WIDTH_20_NOHT,
104 .freq1_diff = 0,
105 .chantype = NL80211_CHAN_NO_HT },
106 + { .name = "80MHz",
107 + .width = NL80211_CHAN_WIDTH_80,
108 + .freq1_diff = 0,
109 + .chantype = -1 },
110 };
111
112 if (argc < 1)
113 @@ -497,7 +497,7 @@ static int join_mesh(struct nl80211_stat
114 NLA_PUT_U32(msg, NL80211_ATTR_CHANNEL_WIDTH,
115 chanmode_selected->width);
116 NLA_PUT_U32(msg, NL80211_ATTR_CENTER_FREQ1,
117 - freq + chanmode_selected->freq1_diff);
118 + get_cf1(chanmode_selected, freq));
119 if (chanmode_selected->chantype != -1)
120 NLA_PUT_U32(msg,
121 NL80211_ATTR_WIPHY_CHANNEL_TYPE,
122 @@ -599,7 +599,7 @@ static int join_mesh(struct nl80211_stat
123 nla_put_failure:
124 return -ENOBUFS;
125 }
126 -COMMAND(mesh, join, "<mesh ID> [[freq <freq in MHz> <HT20|HT40+|HT40-|NOHT>]"
127 +COMMAND(mesh, join, "<mesh ID> [[freq <freq in MHz> <HT20|HT40+|HT40-|NOHT|80MHz>]"
128 " [basic-rates <rate in Mbps,rate2,...>]], [mcast-rate <rate in Mbps>]"
129 " [beacon-interval <time in TUs>] [dtim-period <value>]"
130 " [vendor_sync on|off] [<param>=<value>]*",
131 --- a/util.c
132 +++ b/util.c
133 @@ -728,3 +728,29 @@ void iw_hexdump(const char *prefix, cons
134 }
135 printf("\n\n");
136 }
137 +
138 +int get_cf1(const struct chanmode *chanmode, unsigned long freq)
139 +{
140 + int cf1 = freq, j;
141 + int vht80[] = { 5180, 5260, 5500, 5580, 5660, 5745 };
142 +
143 + switch (chanmode->width) {
144 + case NL80211_CHAN_WIDTH_80:
145 + /* setup center_freq1 */
146 + for (j = 0; j < ARRAY_SIZE(vht80); j++) {
147 + if (freq >= vht80[j] && freq < vht80[j] + 80)
148 + break;
149 + }
150 +
151 + if (j == ARRAY_SIZE(vht80))
152 + break;
153 +
154 + cf1 = vht80[j] + 30;
155 + break;
156 + default:
157 + cf1 = freq + chanmode->freq1_diff;
158 + break;
159 + }
160 +
161 + return cf1;
162 +}