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