301-ibss_add_VHT80.patch 2.9 KB

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