332-v4.19-0006-brcmfmac-specify-some-features-per-firmware-version.patch 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. From 1e591c56a65fbbcd5754a4210a0ef0402d5e5f33 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
  3. Date: Mon, 9 Jul 2018 06:55:43 +0200
  4. Subject: [PATCH] brcmfmac: specify some features per firmware version
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. Some features supported by firmware aren't advertised and there is no
  9. way for a driver to query them. This includes e.g. monitor mode details.
  10. Most firmwares support monitor interface but only the latest ones
  11. /announce/ it with a "monitor" flag in the "cap" iovar. There isn't any
  12. reliable detection method for older firmwares (BRCMF_C_MONITOR was tried
  13. but "it only indicates the core part of the stack supports").
  14. Similarly support for tagging monitor frames and building radiotap
  15. headers can't be reliably detected for all firmwares.
  16. This commit adds table that allows mapping features to firmware version.
  17. It adds mappings for 43602a1 and 4366b1 firmwares from
  18. linux-firmware.git. Both were confirmed to be passing monitor frames.
  19. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
  20. Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
  21. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  22. ---
  23. .../wireless/broadcom/brcm80211/brcmfmac/feature.c | 38 ++++++++++++++++++++++
  24. 1 file changed, 38 insertions(+)
  25. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c
  26. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c
  27. @@ -92,6 +92,42 @@ static int brcmf_feat_debugfs_read(struc
  28. }
  29. #endif /* DEBUG */
  30. +struct brcmf_feat_fwfeat {
  31. + const char * const fwid;
  32. + u32 feat_flags;
  33. +};
  34. +
  35. +static const struct brcmf_feat_fwfeat brcmf_feat_fwfeat_map[] = {
  36. + /* brcmfmac43602-pcie.ap.bin from linux-firmware.git commit ea1178515b88 */
  37. + { "01-6cb8e269", BIT(BRCMF_FEAT_MONITOR) },
  38. + /* brcmfmac4366b-pcie.bin from linux-firmware.git commit 52442afee990 */
  39. + { "01-c47a91a4", BIT(BRCMF_FEAT_MONITOR) },
  40. +};
  41. +
  42. +static void brcmf_feat_firmware_overrides(struct brcmf_pub *drv)
  43. +{
  44. + const struct brcmf_feat_fwfeat *e;
  45. + u32 feat_flags = 0;
  46. + int i;
  47. +
  48. + for (i = 0; i < ARRAY_SIZE(brcmf_feat_fwfeat_map); i++) {
  49. + e = &brcmf_feat_fwfeat_map[i];
  50. + if (!strcmp(e->fwid, drv->fwver)) {
  51. + feat_flags = e->feat_flags;
  52. + break;
  53. + }
  54. + }
  55. +
  56. + if (!feat_flags)
  57. + return;
  58. +
  59. + for (i = 0; i < BRCMF_FEAT_LAST; i++)
  60. + if (feat_flags & BIT(i))
  61. + brcmf_dbg(INFO, "enabling firmware feature: %s\n",
  62. + brcmf_feat_names[i]);
  63. + drv->feat_flags |= feat_flags;
  64. +}
  65. +
  66. /**
  67. * brcmf_feat_iovar_int_get() - determine feature through iovar query.
  68. *
  69. @@ -219,6 +255,8 @@ void brcmf_feat_attach(struct brcmf_pub
  70. ifp->drvr->feat_flags &= ~drvr->settings->feature_disable;
  71. }
  72. + brcmf_feat_firmware_overrides(drvr);
  73. +
  74. /* set chip related quirks */
  75. switch (drvr->bus_if->chip) {
  76. case BRCM_CC_43236_CHIP_ID: