512-ath9k_channelbw_debugfs.patch 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. --- a/drivers/net/wireless/ath/ath9k/debug.c
  2. +++ b/drivers/net/wireless/ath/ath9k/debug.c
  3. @@ -1431,6 +1431,7 @@ int ath9k_init_debug(struct ath_hw *ah)
  4. ath9k_cmn_debug_base_eeprom(sc->debug.debugfs_phy, sc->sc_ah);
  5. ath9k_cmn_debug_modal_eeprom(sc->debug.debugfs_phy, sc->sc_ah);
  6. ath9k_cmn_debug_eeprom(sc->debug.debugfs_phy, sc->sc_ah);
  7. + ath9k_cmn_debug_chanbw(sc->debug.debugfs_phy, sc->sc_ah);
  8. debugfs_create_u32("gpio_mask", 0600,
  9. sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask);
  10. --- a/drivers/net/wireless/ath/ath.h
  11. +++ b/drivers/net/wireless/ath/ath.h
  12. @@ -151,6 +151,7 @@ struct ath_common {
  13. int debug_mask;
  14. enum ath_device_state state;
  15. unsigned long op_flags;
  16. + u32 chan_bw;
  17. struct ath_ani ani;
  18. @@ -181,6 +182,7 @@ struct ath_common {
  19. const struct ath_ops *ops;
  20. const struct ath_bus_ops *bus_ops;
  21. const struct ath_ps_ops *ps_ops;
  22. + const struct ieee80211_ops *ieee_ops;
  23. bool btcoex_enabled;
  24. bool disable_ani;
  25. --- a/drivers/net/wireless/ath/ath9k/common.c
  26. +++ b/drivers/net/wireless/ath/ath9k/common.c
  27. @@ -297,11 +297,13 @@ EXPORT_SYMBOL(ath9k_cmn_get_hw_crypto_ke
  28. /*
  29. * Update internal channel flags.
  30. */
  31. -static void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan,
  32. +static void ath9k_cmn_update_ichannel(struct ath_common *common,
  33. + struct ath9k_channel *ichan,
  34. struct cfg80211_chan_def *chandef)
  35. {
  36. struct ieee80211_channel *chan = chandef->chan;
  37. u16 flags = 0;
  38. + int width;
  39. ichan->channel = chan->center_freq;
  40. ichan->chan = chan;
  41. @@ -309,7 +311,19 @@ static void ath9k_cmn_update_ichannel(st
  42. if (chan->band == NL80211_BAND_5GHZ)
  43. flags |= CHANNEL_5GHZ;
  44. - switch (chandef->width) {
  45. + switch (common->chan_bw) {
  46. + case 5:
  47. + width = NL80211_CHAN_WIDTH_5;
  48. + break;
  49. + case 10:
  50. + width = NL80211_CHAN_WIDTH_10;
  51. + break;
  52. + default:
  53. + width = chandef->width;
  54. + break;
  55. + }
  56. +
  57. + switch (width) {
  58. case NL80211_CHAN_WIDTH_5:
  59. flags |= CHANNEL_QUARTER;
  60. break;
  61. @@ -342,10 +356,11 @@ struct ath9k_channel *ath9k_cmn_get_chan
  62. struct cfg80211_chan_def *chandef)
  63. {
  64. struct ieee80211_channel *curchan = chandef->chan;
  65. + struct ath_common *common = ath9k_hw_common(ah);
  66. struct ath9k_channel *channel;
  67. channel = &ah->channels[curchan->hw_value];
  68. - ath9k_cmn_update_ichannel(channel, chandef);
  69. + ath9k_cmn_update_ichannel(common, channel, chandef);
  70. return channel;
  71. }
  72. --- a/drivers/net/wireless/ath/ath9k/common-debug.c
  73. +++ b/drivers/net/wireless/ath/ath9k/common-debug.c
  74. @@ -315,3 +315,55 @@ void ath9k_cmn_debug_eeprom(struct dentr
  75. &fops_eeprom);
  76. }
  77. EXPORT_SYMBOL(ath9k_cmn_debug_eeprom);
  78. +
  79. +static ssize_t read_file_chan_bw(struct file *file, char __user *user_buf,
  80. + size_t count, loff_t *ppos)
  81. +{
  82. + struct ath_hw *ah = file->private_data;
  83. + struct ath_common *common = ath9k_hw_common(ah);
  84. + char buf[32];
  85. + unsigned int len;
  86. +
  87. + len = sprintf(buf, "0x%08x\n", common->chan_bw);
  88. + return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  89. +}
  90. +
  91. +static ssize_t write_file_chan_bw(struct file *file, const char __user *user_buf,
  92. + size_t count, loff_t *ppos)
  93. +{
  94. + struct ath_hw *ah = file->private_data;
  95. + struct ath_common *common = ath9k_hw_common(ah);
  96. + unsigned long chan_bw;
  97. + char buf[32];
  98. + ssize_t len;
  99. +
  100. + len = min(count, sizeof(buf) - 1);
  101. + if (copy_from_user(buf, user_buf, len))
  102. + return -EFAULT;
  103. +
  104. + buf[len] = '\0';
  105. + if (kstrtoul(buf, 0, &chan_bw))
  106. + return -EINVAL;
  107. +
  108. + common->chan_bw = chan_bw;
  109. + if (!test_bit(ATH_OP_INVALID, &common->op_flags))
  110. + common->ieee_ops->config(ah->hw, IEEE80211_CONF_CHANGE_CHANNEL);
  111. +
  112. + return count;
  113. +}
  114. +
  115. +static const struct file_operations fops_chanbw = {
  116. + .read = read_file_chan_bw,
  117. + .write = write_file_chan_bw,
  118. + .open = simple_open,
  119. + .owner = THIS_MODULE,
  120. + .llseek = default_llseek,
  121. +};
  122. +
  123. +void ath9k_cmn_debug_chanbw(struct dentry *debugfs_phy,
  124. + struct ath_hw *ah)
  125. +{
  126. + debugfs_create_file("chanbw", S_IRUSR | S_IWUSR, debugfs_phy, ah,
  127. + &fops_chanbw);
  128. +}
  129. +EXPORT_SYMBOL(ath9k_cmn_debug_chanbw);
  130. --- a/drivers/net/wireless/ath/ath9k/htc_drv_debug.c
  131. +++ b/drivers/net/wireless/ath/ath9k/htc_drv_debug.c
  132. @@ -513,6 +513,7 @@ int ath9k_htc_init_debug(struct ath_hw *
  133. ath9k_cmn_debug_base_eeprom(priv->debug.debugfs_phy, priv->ah);
  134. ath9k_cmn_debug_modal_eeprom(priv->debug.debugfs_phy, priv->ah);
  135. ath9k_cmn_debug_eeprom(priv->debug.debugfs_phy, priv->ah);
  136. + ath9k_cmn_debug_chanbw(priv->debug.debugfs_phy, priv->ah);
  137. return 0;
  138. }
  139. --- a/drivers/net/wireless/ath/ath9k/common-debug.h
  140. +++ b/drivers/net/wireless/ath/ath9k/common-debug.h
  141. @@ -71,6 +71,8 @@ void ath9k_cmn_debug_base_eeprom(struct
  142. struct ath_hw *ah);
  143. void ath9k_cmn_debug_eeprom(struct dentry *debugfs_phy,
  144. struct ath_hw *ah);
  145. +void ath9k_cmn_debug_chanbw(struct dentry *debugfs_phy,
  146. + struct ath_hw *ah);
  147. void ath9k_cmn_debug_stat_rx(struct ath_rx_stats *rxstats,
  148. struct ath_rx_status *rs);
  149. void ath9k_cmn_debug_recv(struct dentry *debugfs_phy,
  150. --- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c
  151. +++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
  152. @@ -631,6 +631,7 @@ static int ath9k_init_priv(struct ath9k_
  153. priv->ah = ah;
  154. common = ath9k_hw_common(ah);
  155. + common->ieee_ops = &ath9k_htc_ops;
  156. common->ops = &ah->reg_ops;
  157. common->ps_ops = &ath9k_htc_ps_ops;
  158. common->bus_ops = &ath9k_usb_bus_ops;
  159. @@ -746,9 +747,9 @@ static void ath9k_set_hw_capab(struct at
  160. hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN |
  161. WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
  162. - WIPHY_FLAG_HAS_CHANNEL_SWITCH;
  163. -
  164. - hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS;
  165. + WIPHY_FLAG_HAS_CHANNEL_SWITCH |
  166. + WIPHY_FLAG_SUPPORTS_5_10_MHZ |
  167. + WIPHY_FLAG_SUPPORTS_TDLS;
  168. hw->queues = 4;
  169. hw->max_listen_interval = 1;
  170. --- a/drivers/net/wireless/ath/ath9k/init.c
  171. +++ b/drivers/net/wireless/ath/ath9k/init.c
  172. @@ -691,6 +691,7 @@ static int ath9k_init_softc(u16 devid, s
  173. if (!ath9k_is_chanctx_enabled())
  174. sc->cur_chan->hw_queue_base = 0;
  175. + common->ieee_ops = &ath9k_ops;
  176. common->ops = &ah->reg_ops;
  177. common->bus_ops = bus_ops;
  178. common->ps_ops = &ath9k_ps_ops;