303-mesh_add_VHT80.patch 4.4 KB

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