linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ath6kl: print firmware capabilities
@ 2013-03-05 16:38 Kalle Valo
  2013-03-05 18:06 ` Joe Perches
  2013-03-05 18:31 ` Marcel Holtmann
  0 siblings, 2 replies; 7+ messages in thread
From: Kalle Valo @ 2013-03-05 16:38 UTC (permalink / raw)
  To: kvalo; +Cc: ath6kl-devel, linux-wireless

Printin the  firmware capabilities during the first firmware boot makes it easier to find out what
features firmware supports.

Obligatory screenshot:

[21025.678481] ath6kl: ar6003 hw 2.1.1 sdio fw 3.2.0.144 api 3
[21025.678667] ath6kl: firmware supports: sched-scan,sta-p2pdev-duplex,rsn-cap-override

Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
---
 drivers/net/wireless/ath/ath6kl/init.c |   68 ++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)

diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c
index 072a229..fd06332 100644
--- a/drivers/net/wireless/ath/ath6kl/init.c
+++ b/drivers/net/wireless/ath/ath6kl/init.c
@@ -1549,10 +1549,76 @@ static const char *ath6kl_init_get_hif_name(enum ath6kl_hif_type type)
 	return NULL;
 }
 
+
+static const struct fw_capa_str_map {
+	int id;
+	const char *name;
+} fw_capa_map[] = {
+	{ ATH6KL_FW_CAPABILITY_HOST_P2P, "host-p2p" },
+	{ ATH6KL_FW_CAPABILITY_SCHED_SCAN, "sched-scan" },
+	{ ATH6KL_FW_CAPABILITY_STA_P2PDEV_DUPLEX, "sta-p2pdev-duplex" },
+	{ ATH6KL_FW_CAPABILITY_INACTIVITY_TIMEOUT, "inactivity-timeout" },
+	{ ATH6KL_FW_CAPABILITY_RSN_CAP_OVERRIDE, "rsn-cap-override" },
+	{ ATH6KL_FW_CAPABILITY_WOW_MULTICAST_FILTER, "wow-mc-filter" },
+	{ ATH6KL_FW_CAPABILITY_BMISS_ENHANCE, "bmiss-enhance" },
+	{ ATH6KL_FW_CAPABILITY_SCHED_SCAN_MATCH_LIST, "sscan-math-list" },
+	{ ATH6KL_FW_CAPABILITY_RSSI_SCAN_THOLD, "rssi-scan-thold" },
+	{ ATH6KL_FW_CAPABILITY_CUSTOM_MAC_ADDR, "custom-mac-addr" },
+	{ ATH6KL_FW_CAPABILITY_TX_ERR_NOTIFY, "tx-err-notify" },
+	{ ATH6KL_FW_CAPABILITY_REGDOMAIN, "regdomain" },
+	{ ATH6KL_FW_CAPABILITY_SCHED_SCAN_V2, "sched-scan-v2" },
+	{ ATH6KL_FW_CAPABILITY_HEART_BEAT_POLL, "hb-poll" },
+};
+
+static const char *ath6kl_init_get_fw_capa_name(unsigned int id)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(fw_capa_map); i++) {
+		if (fw_capa_map[i].id == id)
+			return fw_capa_map[i].name;
+	}
+
+	return "<unknown>";
+}
+
+static void ath6kl_init_fw_capas(struct ath6kl *ar, char *buf, size_t buf_len)
+{
+	u8 *data = (u8 *) ar->fw_capabilities;
+	size_t len = 0;
+	int i, index, bit;
+
+	for (i = 0; i < ATH6KL_FW_CAPABILITY_MAX; i++) {
+		index = i / 8;
+		bit = i % 8;
+
+		if (index >= sizeof(ar->fw_capabilities) * 4)
+			break;
+
+		if (buf_len - len < 4) {
+			ath6kl_warn("firmware capability buffer too small!\n");
+			strncpy(buf, "<error>", buf_len);
+			return;
+		}
+
+		if (data[index] & (1 << bit)) {
+			len += scnprintf(buf + len, buf_len - len, "%s,",
+					    ath6kl_init_get_fw_capa_name(i));
+		}
+	}
+
+	/* overwrite the last comma */
+	if (len > 0)
+		len --;
+
+	buf[len] = '\0';
+}
+
 static int __ath6kl_init_hw_start(struct ath6kl *ar)
 {
 	long timeleft;
 	int ret, i;
+	char buf[200];
 
 	ath6kl_dbg(ATH6KL_DBG_BOOT, "hw start\n");
 
@@ -1615,6 +1681,8 @@ static int __ath6kl_init_hw_start(struct ath6kl *ar)
 			    ar->wiphy->fw_version,
 			    ar->fw_api,
 			    test_bit(TESTMODE, &ar->flag) ? " testmode" : "");
+		ath6kl_init_fw_capas(ar, buf, sizeof(buf));
+		ath6kl_info("firmware supports: %s\n", buf);
 	}
 
 	if (ar->version.abi_ver != ATH6KL_ABI_VERSION) {


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] ath6kl: print firmware capabilities
  2013-03-05 16:38 Kalle Valo
@ 2013-03-05 18:06 ` Joe Perches
  2013-03-05 18:19   ` Kalle Valo
  2013-03-05 18:31 ` Marcel Holtmann
  1 sibling, 1 reply; 7+ messages in thread
From: Joe Perches @ 2013-03-05 18:06 UTC (permalink / raw)
  To: Kalle Valo; +Cc: ath6kl-devel, linux-wireless

On Tue, 2013-03-05 at 18:38 +0200, Kalle Valo wrote:
> Printin the  firmware capabilities during the first firmware boot makes it easier to find out what
> features firmware supports.
[]
> diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c
[]
> +static void ath6kl_init_fw_capas(struct ath6kl *ar, char *buf, size_t buf_len)
> +{
[]
> +		if (buf_len - len < 4) {
> +			ath6kl_warn("firmware capability buffer too small!\n");
> +			strncpy(buf, "<error>", buf_len);

4 is an odd size to use.
It seems weird to overwrite the known bits.
why not just add ...?




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ath6kl: print firmware capabilities
  2013-03-05 18:06 ` Joe Perches
@ 2013-03-05 18:19   ` Kalle Valo
  0 siblings, 0 replies; 7+ messages in thread
From: Kalle Valo @ 2013-03-05 18:19 UTC (permalink / raw)
  To: Joe Perches; +Cc: ath6kl-devel, linux-wireless

Joe Perches <joe@perches.com> writes:

> On Tue, 2013-03-05 at 18:38 +0200, Kalle Valo wrote:
>> Printin the  firmware capabilities during the first firmware boot makes it easier to find out what
>> features firmware supports.
> []
>> diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c
> []
>> +static void ath6kl_init_fw_capas(struct ath6kl *ar, char *buf, size_t buf_len)
>> +{
> []
>> +		if (buf_len - len < 4) {
>> +			ath6kl_warn("firmware capability buffer too small!\n");
>> +			strncpy(buf, "<error>", buf_len);
>
> 4 is an odd size to use.

I have to admit that I was lazy here. I think "< 2" (or "== 1") would be
the correct value to use but I didn't check that and just used 4 to be
on the safe side :)

> It seems weird to overwrite the known bits.

I did that just to make sure that the truncation won't be missed.

> why not just add ...?

You mean to the end of buffer? Like "first,second,th..."? Looks good,
I'll do that.

-- 
Kalle Valo

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ath6kl: print firmware capabilities
  2013-03-05 16:38 Kalle Valo
  2013-03-05 18:06 ` Joe Perches
@ 2013-03-05 18:31 ` Marcel Holtmann
  2013-03-05 18:35   ` Kalle Valo
  1 sibling, 1 reply; 7+ messages in thread
From: Marcel Holtmann @ 2013-03-05 18:31 UTC (permalink / raw)
  To: Kalle Valo; +Cc: ath6kl-devel, linux-wireless

Hi Kalle,

> Printin the  firmware capabilities during the first firmware boot makes it easier to find out what
> features firmware supports.
> 
> Obligatory screenshot:
> 
> [21025.678481] ath6kl: ar6003 hw 2.1.1 sdio fw 3.2.0.144 api 3
> [21025.678667] ath6kl: firmware supports: sched-scan,sta-p2pdev-duplex,rsn-cap-override
> 
> Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
> ---
> drivers/net/wireless/ath/ath6kl/init.c |   68 ++++++++++++++++++++++++++++++++
> 1 file changed, 68 insertions(+)
> 
> diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c
> index 072a229..fd06332 100644
> --- a/drivers/net/wireless/ath/ath6kl/init.c
> +++ b/drivers/net/wireless/ath/ath6kl/init.c
> @@ -1549,10 +1549,76 @@ static const char *ath6kl_init_get_hif_name(enum ath6kl_hif_type type)
> 	return NULL;
> }
> 
> +
> +static const struct fw_capa_str_map {
> +	int id;
> +	const char *name;
> +} fw_capa_map[] = {
> +	{ ATH6KL_FW_CAPABILITY_HOST_P2P, "host-p2p" },
> +	{ ATH6KL_FW_CAPABILITY_SCHED_SCAN, "sched-scan" },
> +	{ ATH6KL_FW_CAPABILITY_STA_P2PDEV_DUPLEX, "sta-p2pdev-duplex" },
> +	{ ATH6KL_FW_CAPABILITY_INACTIVITY_TIMEOUT, "inactivity-timeout" },
> +	{ ATH6KL_FW_CAPABILITY_RSN_CAP_OVERRIDE, "rsn-cap-override" },
> +	{ ATH6KL_FW_CAPABILITY_WOW_MULTICAST_FILTER, "wow-mc-filter" },
> +	{ ATH6KL_FW_CAPABILITY_BMISS_ENHANCE, "bmiss-enhance" },
> +	{ ATH6KL_FW_CAPABILITY_SCHED_SCAN_MATCH_LIST, "sscan-math-list" },

math ;)

> +	{ ATH6KL_FW_CAPABILITY_RSSI_SCAN_THOLD, "rssi-scan-thold" },
> +	{ ATH6KL_FW_CAPABILITY_CUSTOM_MAC_ADDR, "custom-mac-addr" },
> +	{ ATH6KL_FW_CAPABILITY_TX_ERR_NOTIFY, "tx-err-notify" },
> +	{ ATH6KL_FW_CAPABILITY_REGDOMAIN, "regdomain" },
> +	{ ATH6KL_FW_CAPABILITY_SCHED_SCAN_V2, "sched-scan-v2" },
> +	{ ATH6KL_FW_CAPABILITY_HEART_BEAT_POLL, "hb-poll" },
> +};

Regards

Marcel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ath6kl: print firmware capabilities
  2013-03-05 18:31 ` Marcel Holtmann
@ 2013-03-05 18:35   ` Kalle Valo
  0 siblings, 0 replies; 7+ messages in thread
From: Kalle Valo @ 2013-03-05 18:35 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: ath6kl-devel, linux-wireless

Marcel Holtmann <marcel@holtmann.org> writes:

>> +	{ ATH6KL_FW_CAPABILITY_SCHED_SCAN_MATCH_LIST, "sscan-math-list" },
>
> math ;)

Oops, I'll fix that in v2. Thanks!

-- 
Kalle Valo

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] ath6kl: print firmware capabilities
@ 2013-03-06  6:56 Kalle Valo
  2013-03-18 11:34 ` Kalle Valo
  0 siblings, 1 reply; 7+ messages in thread
From: Kalle Valo @ 2013-03-06  6:56 UTC (permalink / raw)
  To: kvalo; +Cc: ath6kl-devel, linux-wireless

Printin the  firmware capabilities during the first firmware boot makes it easier to find out what
features firmware supports.

Obligatory screenshot:

[21025.678481] ath6kl: ar6003 hw 2.1.1 sdio fw 3.2.0.144 api 3
[21025.678667] ath6kl: firmware supports: sched-scan,sta-p2pdev-duplex,rsn-cap-override

Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
---
 drivers/net/wireless/ath/ath6kl/init.c |   73 ++++++++++++++++++++++++++++++++
 1 file changed, 73 insertions(+)

diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c
index 072a229..3e45adc 100644
--- a/drivers/net/wireless/ath/ath6kl/init.c
+++ b/drivers/net/wireless/ath/ath6kl/init.c
@@ -1549,10 +1549,81 @@ static const char *ath6kl_init_get_hif_name(enum ath6kl_hif_type type)
 	return NULL;
 }
 
+
+static const struct fw_capa_str_map {
+	int id;
+	const char *name;
+} fw_capa_map[] = {
+	{ ATH6KL_FW_CAPABILITY_HOST_P2P, "host-p2p" },
+	{ ATH6KL_FW_CAPABILITY_SCHED_SCAN, "sched-scan" },
+	{ ATH6KL_FW_CAPABILITY_STA_P2PDEV_DUPLEX, "sta-p2pdev-duplex" },
+	{ ATH6KL_FW_CAPABILITY_INACTIVITY_TIMEOUT, "inactivity-timeout" },
+	{ ATH6KL_FW_CAPABILITY_RSN_CAP_OVERRIDE, "rsn-cap-override" },
+	{ ATH6KL_FW_CAPABILITY_WOW_MULTICAST_FILTER, "wow-mc-filter" },
+	{ ATH6KL_FW_CAPABILITY_BMISS_ENHANCE, "bmiss-enhance" },
+	{ ATH6KL_FW_CAPABILITY_SCHED_SCAN_MATCH_LIST, "sscan-match-list" },
+	{ ATH6KL_FW_CAPABILITY_RSSI_SCAN_THOLD, "rssi-scan-thold" },
+	{ ATH6KL_FW_CAPABILITY_CUSTOM_MAC_ADDR, "custom-mac-addr" },
+	{ ATH6KL_FW_CAPABILITY_TX_ERR_NOTIFY, "tx-err-notify" },
+	{ ATH6KL_FW_CAPABILITY_REGDOMAIN, "regdomain" },
+	{ ATH6KL_FW_CAPABILITY_SCHED_SCAN_V2, "sched-scan-v2" },
+	{ ATH6KL_FW_CAPABILITY_HEART_BEAT_POLL, "hb-poll" },
+};
+
+static const char *ath6kl_init_get_fw_capa_name(unsigned int id)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(fw_capa_map); i++) {
+		if (fw_capa_map[i].id == id)
+			return fw_capa_map[i].name;
+	}
+
+	return "<unknown>";
+}
+
+static void ath6kl_init_get_fwcaps(struct ath6kl *ar, char *buf, size_t buf_len)
+{
+	u8 *data = (u8 *) ar->fw_capabilities;
+	size_t trunc_len, len = 0;
+	int i, index, bit;
+	char *trunc = "...";
+
+	for (i = 0; i < ATH6KL_FW_CAPABILITY_MAX; i++) {
+		index = i / 8;
+		bit = i % 8;
+
+		if (index >= sizeof(ar->fw_capabilities) * 4)
+			break;
+
+		if (buf_len - len < 4) {
+			ath6kl_warn("firmware capability buffer too small!\n");
+
+			/* add "..." to the end of string */
+			trunc_len = strlen(trunc) + 1;
+			strncpy(buf + buf_len - trunc_len, trunc, trunc_len);
+
+			return;
+		}
+
+		if (data[index] & (1 << bit)) {
+			len += scnprintf(buf + len, buf_len - len, "%s,",
+					    ath6kl_init_get_fw_capa_name(i));
+		}
+	}
+
+	/* overwrite the last comma */
+	if (len > 0)
+		len--;
+
+	buf[len] = '\0';
+}
+
 static int __ath6kl_init_hw_start(struct ath6kl *ar)
 {
 	long timeleft;
 	int ret, i;
+	char buf[200];
 
 	ath6kl_dbg(ATH6KL_DBG_BOOT, "hw start\n");
 
@@ -1615,6 +1686,8 @@ static int __ath6kl_init_hw_start(struct ath6kl *ar)
 			    ar->wiphy->fw_version,
 			    ar->fw_api,
 			    test_bit(TESTMODE, &ar->flag) ? " testmode" : "");
+		ath6kl_init_get_fwcaps(ar, buf, sizeof(buf));
+		ath6kl_info("firmware supports: %s\n", buf);
 	}
 
 	if (ar->version.abi_ver != ATH6KL_ABI_VERSION) {


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] ath6kl: print firmware capabilities
  2013-03-06  6:56 [PATCH] ath6kl: print firmware capabilities Kalle Valo
@ 2013-03-18 11:34 ` Kalle Valo
  0 siblings, 0 replies; 7+ messages in thread
From: Kalle Valo @ 2013-03-18 11:34 UTC (permalink / raw)
  To: ath6kl-devel; +Cc: linux-wireless

Kalle Valo <kvalo@qca.qualcomm.com> writes:

> Printin the  firmware capabilities during the first firmware boot makes it easier to find out what
> features firmware supports.
>
> Obligatory screenshot:
>
> [21025.678481] ath6kl: ar6003 hw 2.1.1 sdio fw 3.2.0.144 api 3
> [21025.678667] ath6kl: firmware supports: sched-scan,sta-p2pdev-duplex,rsn-cap-override
>
> Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>

Applied with cosmetic fixes to the commit log.

-- 
Kalle Valo

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-03-18 11:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-06  6:56 [PATCH] ath6kl: print firmware capabilities Kalle Valo
2013-03-18 11:34 ` Kalle Valo
  -- strict thread matches above, loose matches on Subject: below --
2013-03-05 16:38 Kalle Valo
2013-03-05 18:06 ` Joe Perches
2013-03-05 18:19   ` Kalle Valo
2013-03-05 18:31 ` Marcel Holtmann
2013-03-05 18:35   ` Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).