351-0008-brcmfmac-support-get_channel-cfg80211-callback.patch 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
  2. Date: Fri, 20 May 2016 13:38:58 +0200
  3. Subject: [PATCH] brcmfmac: support get_channel cfg80211 callback
  4. MIME-Version: 1.0
  5. Content-Type: text/plain; charset=UTF-8
  6. Content-Transfer-Encoding: 8bit
  7. This is important for brcmfmac as some of released firmwares (e.g.
  8. brcmfmac4366b-pcie.bin) may pick different channel than requested. This
  9. has been tested with BCM4366B1 in D-Link DIR-885L.
  10. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
  11. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  12. ---
  13. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
  14. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
  15. @@ -4847,6 +4847,68 @@ exit:
  16. return err;
  17. }
  18. +static int brcmf_cfg80211_get_channel(struct wiphy *wiphy,
  19. + struct wireless_dev *wdev,
  20. + struct cfg80211_chan_def *chandef)
  21. +{
  22. + struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
  23. + struct net_device *ndev = wdev->netdev;
  24. + struct brcmf_if *ifp;
  25. + struct brcmu_chan ch;
  26. + enum nl80211_band band = 0;
  27. + enum nl80211_chan_width width = 0;
  28. + u32 chanspec;
  29. + int freq, err;
  30. +
  31. + if (!ndev)
  32. + return -ENODEV;
  33. + ifp = netdev_priv(ndev);
  34. +
  35. + err = brcmf_fil_iovar_int_get(ifp, "chanspec", &chanspec);
  36. + if (err) {
  37. + brcmf_err("chanspec failed (%d)\n", err);
  38. + return err;
  39. + }
  40. +
  41. + ch.chspec = chanspec;
  42. + cfg->d11inf.decchspec(&ch);
  43. +
  44. + switch (ch.band) {
  45. + case BRCMU_CHAN_BAND_2G:
  46. + band = NL80211_BAND_2GHZ;
  47. + break;
  48. + case BRCMU_CHAN_BAND_5G:
  49. + band = NL80211_BAND_5GHZ;
  50. + break;
  51. + }
  52. +
  53. + switch (ch.bw) {
  54. + case BRCMU_CHAN_BW_80:
  55. + width = NL80211_CHAN_WIDTH_80;
  56. + break;
  57. + case BRCMU_CHAN_BW_40:
  58. + width = NL80211_CHAN_WIDTH_40;
  59. + break;
  60. + case BRCMU_CHAN_BW_20:
  61. + width = NL80211_CHAN_WIDTH_20;
  62. + break;
  63. + case BRCMU_CHAN_BW_80P80:
  64. + width = NL80211_CHAN_WIDTH_80P80;
  65. + break;
  66. + case BRCMU_CHAN_BW_160:
  67. + width = NL80211_CHAN_WIDTH_160;
  68. + break;
  69. + }
  70. +
  71. + freq = ieee80211_channel_to_frequency(ch.control_ch_num, band);
  72. + chandef->chan = ieee80211_get_channel(wiphy, freq);
  73. + chandef->width = width;
  74. + chandef->center_freq1 = ieee80211_channel_to_frequency(ch.chnum, band);
  75. + chandef->center_freq2 = 0;
  76. +
  77. + return 0;
  78. +}
  79. +
  80. static int brcmf_cfg80211_crit_proto_start(struct wiphy *wiphy,
  81. struct wireless_dev *wdev,
  82. enum nl80211_crit_proto_id proto,
  83. @@ -5009,6 +5071,7 @@ static struct cfg80211_ops brcmf_cfg8021
  84. .mgmt_tx = brcmf_cfg80211_mgmt_tx,
  85. .remain_on_channel = brcmf_p2p_remain_on_channel,
  86. .cancel_remain_on_channel = brcmf_cfg80211_cancel_remain_on_channel,
  87. + .get_channel = brcmf_cfg80211_get_channel,
  88. .start_p2p_device = brcmf_p2p_start_device,
  89. .stop_p2p_device = brcmf_p2p_stop_device,
  90. .crit_proto_start = brcmf_cfg80211_crit_proto_start,