331-v4.18-0005-brcmfmac-add-debugfs-entry-for-reading-firmware-capa.patch 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. From 88001968245c42c26416476bf0ef960442371605 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
  3. Date: Mon, 14 May 2018 08:48:20 +0200
  4. Subject: [PATCH] brcmfmac: add debugfs entry for reading firmware capabilities
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. This allows reading all capabilities as reported by a firmware. They are
  9. printed using native (raw) names, just like developers like it the most.
  10. It's how firmware reports support for various features, e.g. supported
  11. modes, supported standards, power saving details, max BSS-es.
  12. Access to all that info is useful for trying new firmwares, comparing
  13. them and debugging features AKA bugs.
  14. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
  15. Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
  16. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  17. ---
  18. .../wireless/broadcom/brcm80211/brcmfmac/feature.c | 36 ++++++++++++++++++++++
  19. 1 file changed, 36 insertions(+)
  20. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c
  21. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c
  22. @@ -138,6 +138,41 @@ static void brcmf_feat_firmware_capabili
  23. }
  24. }
  25. +/**
  26. + * brcmf_feat_fwcap_debugfs_read() - expose firmware capabilities to debugfs.
  27. + *
  28. + * @seq: sequence for debugfs entry.
  29. + * @data: raw data pointer.
  30. + */
  31. +static int brcmf_feat_fwcap_debugfs_read(struct seq_file *seq, void *data)
  32. +{
  33. + struct brcmf_bus *bus_if = dev_get_drvdata(seq->private);
  34. + struct brcmf_if *ifp = brcmf_get_ifp(bus_if->drvr, 0);
  35. + char caps[MAX_CAPS_BUFFER_SIZE + 1] = { };
  36. + char *tmp;
  37. + int err;
  38. +
  39. + err = brcmf_fil_iovar_data_get(ifp, "cap", caps, sizeof(caps));
  40. + if (err) {
  41. + brcmf_err("could not get firmware cap (%d)\n", err);
  42. + return err;
  43. + }
  44. +
  45. + /* Put every capability in a new line */
  46. + for (tmp = caps; *tmp; tmp++) {
  47. + if (*tmp == ' ')
  48. + *tmp = '\n';
  49. + }
  50. +
  51. + /* Usually there is a space at the end of capabilities string */
  52. + seq_printf(seq, "%s", caps);
  53. + /* So make sure we don't print two line breaks */
  54. + if (tmp > caps && *(tmp - 1) != '\n')
  55. + seq_printf(seq, "\n");
  56. +
  57. + return 0;
  58. +}
  59. +
  60. void brcmf_feat_attach(struct brcmf_pub *drvr)
  61. {
  62. struct brcmf_if *ifp = brcmf_get_ifp(drvr, 0);
  63. @@ -196,6 +231,7 @@ void brcmf_feat_attach(struct brcmf_pub
  64. }
  65. brcmf_debugfs_add_entry(drvr, "features", brcmf_feat_debugfs_read);
  66. + brcmf_debugfs_add_entry(drvr, "fwcap", brcmf_feat_fwcap_debugfs_read);
  67. }
  68. bool brcmf_feat_is_enabled(struct brcmf_if *ifp, enum brcmf_feat_id id)