* [PATCH] ath9k_htc: introduce support for different fw versions
@ 2015-06-14 16:12 Oleksij Rempel
2015-06-14 23:27 ` Julian Calaby
0 siblings, 1 reply; 14+ messages in thread
From: Oleksij Rempel @ 2015-06-14 16:12 UTC (permalink / raw)
To: ath9k-devel, kvalo, linux-wireless; +Cc: Oleksij Rempel
Current kernel support only one fw name with theoretically only one
fw version. By replacing fw with other version we will break compatibility
with older kernels.
To avoid this kind of regression this patch will reuse fw version model
from iwlwifi driver.
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
---
drivers/net/wireless/ath/ath9k/hif_usb.c | 102 ++++++++++++++++++++------
drivers/net/wireless/ath/ath9k/hif_usb.h | 13 +++-
drivers/net/wireless/ath/ath9k/htc_drv_init.c | 4 +
3 files changed, 95 insertions(+), 24 deletions(-)
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
index 10c02f5..18407f2 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.c
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
@@ -17,10 +17,6 @@
#include <asm/unaligned.h>
#include "htc.h"
-/* identify firmware images */
-#define FIRMWARE_AR7010_1_1 "htc_7010.fw"
-#define FIRMWARE_AR9271 "htc_9271.fw"
-
MODULE_FIRMWARE(FIRMWARE_AR7010_1_1);
MODULE_FIRMWARE(FIRMWARE_AR9271);
@@ -1080,12 +1076,88 @@ static void ath9k_hif_usb_firmware_fail(struct hif_device_usb *hif_dev)
device_unlock(parent);
}
+static void ath9k_hif_usb_firmware_cb(const struct firmware *fw, void *context);
+
+/* taken from iwlwifi */
+static int ath9k_hif_request_firmware(struct hif_device_usb *hif_dev,
+ bool first)
+{
+ char index[8], *chip;
+ int ret;
+
+ if (first) {
+ if (htc_use_dev_fw) {
+ hif_dev->fw_minor_index = FIRMWARE_MINOR_IDX_MAX + 1;
+ sprintf(index, "%s", "dev");
+ } else {
+ hif_dev->fw_minor_index = FIRMWARE_MINOR_IDX_MAX;
+ sprintf(index, "%d", hif_dev->fw_minor_index);
+ }
+ } else {
+ hif_dev->fw_minor_index--;
+ sprintf(index, "%d", hif_dev->fw_minor_index);
+ }
+
+ /* test for FW 1.3 */
+ if (MAJOR_VERSION_REQ == 1 && hif_dev->fw_minor_index == 3) {
+ const char *filename;
+
+ if (IS_AR7010_DEVICE(hif_dev->usb_device_id->driver_info))
+ filename = FIRMWARE_AR7010_1_1;
+ else
+ filename = FIRMWARE_AR9271;
+
+ /* expected fw locations:
+ * - htc_9271.fw (stable version 1.3, depricated)
+ */
+ snprintf(hif_dev->fw_name, sizeof(hif_dev->fw_name),
+ "%s", filename);
+
+ } else if (hif_dev->fw_minor_index < FIRMWARE_MINOR_IDX_MIN) {
+ dev_err(&hif_dev->udev->dev, "no suitable firmware found!\n");
+
+ return -ENOENT;
+ } else {
+ if (IS_AR7010_DEVICE(hif_dev->usb_device_id->driver_info))
+ chip = "7010";
+ else
+ chip = "9271";
+
+ /* expected fw locations:
+ * - ath9k_htc/htc_9271-1.dev.0.fw (development version)
+ * - ath9k_htc/htc_9271-1.4.0.fw (stable version)
+ */
+ snprintf(hif_dev->fw_name, sizeof(hif_dev->fw_name),
+ "ath9k_htc/htc_%s-%d.%s.0.fw",
+ chip, MAJOR_VERSION_REQ, index);
+ }
+
+ ret = request_firmware_nowait(THIS_MODULE, true, hif_dev->fw_name,
+ &hif_dev->udev->dev, GFP_KERNEL,
+ hif_dev, ath9k_hif_usb_firmware_cb);
+ if (ret) {
+ dev_err(&hif_dev->udev->dev,
+ "ath9k_htc: Async request for firmware %s failed\n",
+ hif_dev->fw_name);
+ return ret;
+ }
+
+ dev_info(&hif_dev->udev->dev, "ath9k_htc: Firmware %s requested\n",
+ hif_dev->fw_name);
+
+ return ret;
+}
+
static void ath9k_hif_usb_firmware_cb(const struct firmware *fw, void *context)
{
struct hif_device_usb *hif_dev = context;
int ret;
if (!fw) {
+ ret = ath9k_hif_request_firmware(hif_dev, false);
+ if (!ret)
+ return;
+
dev_err(&hif_dev->udev->dev,
"ath9k_htc: Failed to get firmware %s\n",
hif_dev->fw_name);
@@ -1215,27 +1287,11 @@ static int ath9k_hif_usb_probe(struct usb_interface *interface,
init_completion(&hif_dev->fw_done);
- /* Find out which firmware to load */
-
- if (IS_AR7010_DEVICE(id->driver_info))
- hif_dev->fw_name = FIRMWARE_AR7010_1_1;
- else
- hif_dev->fw_name = FIRMWARE_AR9271;
-
- ret = request_firmware_nowait(THIS_MODULE, true, hif_dev->fw_name,
- &hif_dev->udev->dev, GFP_KERNEL,
- hif_dev, ath9k_hif_usb_firmware_cb);
- if (ret) {
- dev_err(&hif_dev->udev->dev,
- "ath9k_htc: Async request for firmware %s failed\n",
- hif_dev->fw_name);
+ ret = ath9k_hif_request_firmware(hif_dev, true);
+ if (ret)
goto err_fw_req;
- }
- dev_info(&hif_dev->udev->dev, "ath9k_htc: Firmware %s requested\n",
- hif_dev->fw_name);
-
- return 0;
+ return ret;
err_fw_req:
usb_set_intfdata(interface, NULL);
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.h b/drivers/net/wireless/ath/ath9k/hif_usb.h
index 51496e7..c55b786 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.h
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.h
@@ -17,8 +17,18 @@
#ifndef HTC_USB_H
#define HTC_USB_H
+/* old firmware images */
+#define FIRMWARE_AR7010_1_1 "htc_7010.fw"
+#define FIRMWARE_AR9271 "htc_9271.fw"
+
+/* supported Major FW version */
#define MAJOR_VERSION_REQ 1
#define MINOR_VERSION_REQ 3
+/* minimal and maximal supported Minor FW version. */
+#define FIRMWARE_MINOR_IDX_MAX 4
+#define FIRMWARE_MINOR_IDX_MIN 3
+
+extern int htc_use_dev_fw;
#define IS_AR7010_DEVICE(_v) (((_v) == AR9280_USB) || ((_v) == AR9287_USB))
@@ -101,7 +111,8 @@ struct hif_device_usb {
struct usb_anchor reg_in_submitted;
struct usb_anchor mgmt_submitted;
struct sk_buff *remain_skb;
- const char *fw_name;
+ char fw_name[32];
+ int fw_minor_index;
int rx_remain_len;
int rx_pkt_len;
int rx_transfer_len;
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
index 7468562..57ca9b6 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
@@ -38,6 +38,10 @@ static int ath9k_ps_enable;
module_param_named(ps_enable, ath9k_ps_enable, int, 0444);
MODULE_PARM_DESC(ps_enable, "Enable WLAN PowerSave");
+int htc_use_dev_fw = 0;
+module_param_named(use_dev_fw, htc_use_dev_fw, int, 0444);
+MODULE_PARM_DESC(use_dev_fw, "Use development FW version");
+
#ifdef CONFIG_MAC80211_LEDS
int ath9k_htc_led_blink = 1;
module_param_named(blink, ath9k_htc_led_blink, int, 0444);
--
2.1.4
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH] ath9k_htc: introduce support for different fw versions
2015-06-14 16:12 [PATCH] ath9k_htc: introduce support for different fw versions Oleksij Rempel
@ 2015-06-14 23:27 ` Julian Calaby
2015-06-15 18:55 ` Oleksij Rempel
` (2 more replies)
0 siblings, 3 replies; 14+ messages in thread
From: Julian Calaby @ 2015-06-14 23:27 UTC (permalink / raw)
To: Oleksij Rempel; +Cc: ath9k-devel, kvalo, linux-wireless
Hi Oleksij,
On Mon, Jun 15, 2015 at 2:12 AM, Oleksij Rempel <linux@rempel-privat.de> wrote:
> Current kernel support only one fw name with theoretically only one
> fw version. By replacing fw with other version we will break compatibility
> with older kernels.
>
> To avoid this kind of regression this patch will reuse fw version model
> from iwlwifi driver.
>
> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
> ---
> drivers/net/wireless/ath/ath9k/hif_usb.c | 102 ++++++++++++++++++++------
> drivers/net/wireless/ath/ath9k/hif_usb.h | 13 +++-
> drivers/net/wireless/ath/ath9k/htc_drv_init.c | 4 +
> 3 files changed, 95 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
> index 10c02f5..18407f2 100644
> --- a/drivers/net/wireless/ath/ath9k/hif_usb.c
> +++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
> @@ -17,10 +17,6 @@
> #include <asm/unaligned.h>
> #include "htc.h"
>
> -/* identify firmware images */
> -#define FIRMWARE_AR7010_1_1 "htc_7010.fw"
> -#define FIRMWARE_AR9271 "htc_9271.fw"
> -
> MODULE_FIRMWARE(FIRMWARE_AR7010_1_1);
> MODULE_FIRMWARE(FIRMWARE_AR9271);
Shouldn't you declare the versioned firmware names here too?
Thanks,
--
Julian Calaby
Email: julian.calaby@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH] ath9k_htc: introduce support for different fw versions
2015-06-14 23:27 ` Julian Calaby
@ 2015-06-15 18:55 ` Oleksij Rempel
2015-06-15 18:57 ` Oleksij Rempel
2015-06-15 18:58 ` [PATCH v2] " Oleksij Rempel
2 siblings, 0 replies; 14+ messages in thread
From: Oleksij Rempel @ 2015-06-15 18:55 UTC (permalink / raw)
To: Julian Calaby; +Cc: ath9k-devel, kvalo, linux-wireless
[-- Attachment #1: Type: text/plain, Size: 1421 bytes --]
Am 15.06.2015 um 01:27 schrieb Julian Calaby:
> Hi Oleksij,
>
> On Mon, Jun 15, 2015 at 2:12 AM, Oleksij Rempel <linux@rempel-privat.de> wrote:
>> Current kernel support only one fw name with theoretically only one
>> fw version. By replacing fw with other version we will break compatibility
>> with older kernels.
>>
>> To avoid this kind of regression this patch will reuse fw version model
>> from iwlwifi driver.
>>
>> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
>> ---
>> drivers/net/wireless/ath/ath9k/hif_usb.c | 102 ++++++++++++++++++++------
>> drivers/net/wireless/ath/ath9k/hif_usb.h | 13 +++-
>> drivers/net/wireless/ath/ath9k/htc_drv_init.c | 4 +
>> 3 files changed, 95 insertions(+), 24 deletions(-)
>>
>> diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
>> index 10c02f5..18407f2 100644
>> --- a/drivers/net/wireless/ath/ath9k/hif_usb.c
>> +++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
>> @@ -17,10 +17,6 @@
>> #include <asm/unaligned.h>
>> #include "htc.h"
>>
>> -/* identify firmware images */
>> -#define FIRMWARE_AR7010_1_1 "htc_7010.fw"
>> -#define FIRMWARE_AR9271 "htc_9271.fw"
>> -
>> MODULE_FIRMWARE(FIRMWARE_AR7010_1_1);
>> MODULE_FIRMWARE(FIRMWARE_AR9271);
>
> Shouldn't you declare the versioned firmware names here too?
Thank you.
--
Regards,
Oleksij
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH] ath9k_htc: introduce support for different fw versions
2015-06-14 23:27 ` Julian Calaby
2015-06-15 18:55 ` Oleksij Rempel
@ 2015-06-15 18:57 ` Oleksij Rempel
2015-06-15 18:58 ` [PATCH v2] " Oleksij Rempel
2 siblings, 0 replies; 14+ messages in thread
From: Oleksij Rempel @ 2015-06-15 18:57 UTC (permalink / raw)
To: ath9k-devel, kvalo, linux-wireless; +Cc: Oleksij Rempel
Current kernel support only one fw name with theoretically only one
fw version. By replacing fw with other version we will break compatibility
with older kernels.
To avoid this kind of regression this patch will reuse fw version model
from iwlwifi driver.
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
---
drivers/net/wireless/ath/ath9k/hif_usb.c | 106 ++++++++++++++++++++------
drivers/net/wireless/ath/ath9k/hif_usb.h | 21 ++++-
drivers/net/wireless/ath/ath9k/htc_drv_init.c | 4 +
3 files changed, 105 insertions(+), 26 deletions(-)
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
index 10c02f5..165dd20 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.c
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
@@ -17,12 +17,8 @@
#include <asm/unaligned.h>
#include "htc.h"
-/* identify firmware images */
-#define FIRMWARE_AR7010_1_1 "htc_7010.fw"
-#define FIRMWARE_AR9271 "htc_9271.fw"
-
-MODULE_FIRMWARE(FIRMWARE_AR7010_1_1);
-MODULE_FIRMWARE(FIRMWARE_AR9271);
+MODULE_FIRMWARE(HTC_7010_MODULE_FW);
+MODULE_FIRMWARE(HTC_9271_MODULE_FW);
static struct usb_device_id ath9k_hif_usb_ids[] = {
{ USB_DEVICE(0x0cf3, 0x9271) }, /* Atheros */
@@ -1080,12 +1076,88 @@ static void ath9k_hif_usb_firmware_fail(struct hif_device_usb *hif_dev)
device_unlock(parent);
}
+static void ath9k_hif_usb_firmware_cb(const struct firmware *fw, void *context);
+
+/* taken from iwlwifi */
+static int ath9k_hif_request_firmware(struct hif_device_usb *hif_dev,
+ bool first)
+{
+ char index[8], *chip;
+ int ret;
+
+ if (first) {
+ if (htc_use_dev_fw) {
+ hif_dev->fw_minor_index = FIRMWARE_MINOR_IDX_MAX + 1;
+ sprintf(index, "%s", "dev");
+ } else {
+ hif_dev->fw_minor_index = FIRMWARE_MINOR_IDX_MAX;
+ sprintf(index, "%d", hif_dev->fw_minor_index);
+ }
+ } else {
+ hif_dev->fw_minor_index--;
+ sprintf(index, "%d", hif_dev->fw_minor_index);
+ }
+
+ /* test for FW 1.3 */
+ if (MAJOR_VERSION_REQ == 1 && hif_dev->fw_minor_index == 3) {
+ const char *filename;
+
+ if (IS_AR7010_DEVICE(hif_dev->usb_device_id->driver_info))
+ filename = FIRMWARE_AR7010_1_1;
+ else
+ filename = FIRMWARE_AR9271;
+
+ /* expected fw locations:
+ * - htc_9271.fw (stable version 1.3, depricated)
+ */
+ snprintf(hif_dev->fw_name, sizeof(hif_dev->fw_name),
+ "%s", filename);
+
+ } else if (hif_dev->fw_minor_index < FIRMWARE_MINOR_IDX_MIN) {
+ dev_err(&hif_dev->udev->dev, "no suitable firmware found!\n");
+
+ return -ENOENT;
+ } else {
+ if (IS_AR7010_DEVICE(hif_dev->usb_device_id->driver_info))
+ chip = "7010";
+ else
+ chip = "9271";
+
+ /* expected fw locations:
+ * - ath9k_htc/htc_9271-1.dev.0.fw (development version)
+ * - ath9k_htc/htc_9271-1.4.0.fw (stable version)
+ */
+ snprintf(hif_dev->fw_name, sizeof(hif_dev->fw_name),
+ "%s/htc_%s-%d.%s.0.fw", HTC_FW_PATH,
+ chip, MAJOR_VERSION_REQ, index);
+ }
+
+ ret = request_firmware_nowait(THIS_MODULE, true, hif_dev->fw_name,
+ &hif_dev->udev->dev, GFP_KERNEL,
+ hif_dev, ath9k_hif_usb_firmware_cb);
+ if (ret) {
+ dev_err(&hif_dev->udev->dev,
+ "ath9k_htc: Async request for firmware %s failed\n",
+ hif_dev->fw_name);
+ return ret;
+ }
+
+ dev_info(&hif_dev->udev->dev, "ath9k_htc: Firmware %s requested\n",
+ hif_dev->fw_name);
+
+ return ret;
+}
+
static void ath9k_hif_usb_firmware_cb(const struct firmware *fw, void *context)
{
struct hif_device_usb *hif_dev = context;
int ret;
if (!fw) {
+ ret = ath9k_hif_request_firmware(hif_dev, false);
+ if (!ret)
+ return;
+
dev_err(&hif_dev->udev->dev,
"ath9k_htc: Failed to get firmware %s\n",
hif_dev->fw_name);
@@ -1215,27 +1287,11 @@ static int ath9k_hif_usb_probe(struct usb_interface *interface,
init_completion(&hif_dev->fw_done);
- /* Find out which firmware to load */
-
- if (IS_AR7010_DEVICE(id->driver_info))
- hif_dev->fw_name = FIRMWARE_AR7010_1_1;
- else
- hif_dev->fw_name = FIRMWARE_AR9271;
-
- ret = request_firmware_nowait(THIS_MODULE, true, hif_dev->fw_name,
- &hif_dev->udev->dev, GFP_KERNEL,
- hif_dev, ath9k_hif_usb_firmware_cb);
- if (ret) {
- dev_err(&hif_dev->udev->dev,
- "ath9k_htc: Async request for firmware %s failed\n",
- hif_dev->fw_name);
+ ret = ath9k_hif_request_firmware(hif_dev, true);
+ if (ret)
goto err_fw_req;
- }
- dev_info(&hif_dev->udev->dev, "ath9k_htc: Firmware %s requested\n",
- hif_dev->fw_name);
-
- return 0;
+ return ret;
err_fw_req:
usb_set_intfdata(interface, NULL);
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.h b/drivers/net/wireless/ath/ath9k/hif_usb.h
index 51496e7..7c2ef7e 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.h
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.h
@@ -17,8 +17,26 @@
#ifndef HTC_USB_H
#define HTC_USB_H
+/* old firmware images */
+#define FIRMWARE_AR7010_1_1 "htc_7010.fw"
+#define FIRMWARE_AR9271 "htc_9271.fw"
+
+/* supported Major FW version */
#define MAJOR_VERSION_REQ 1
#define MINOR_VERSION_REQ 3
+/* minimal and maximal supported Minor FW version. */
+#define FIRMWARE_MINOR_IDX_MAX 4
+#define FIRMWARE_MINOR_IDX_MIN 3
+#define HTC_FW_PATH "ath9k_htc"
+
+#define HTC_9271_MODULE_FW HTC_FW_PATH "/htc_9271-" \
+ __stringify(MAJOR_VERSION_REQ) \
+ "." __stringify(FIRMWARE_MINOR_IDX_MAX) ".0.fw"
+#define HTC_7010_MODULE_FW HTC_FW_PATH "/htc_7010-" \
+ __stringify(MAJOR_VERSION_REQ) \
+ "." __stringify(FIRMWARE_MINOR_IDX_MAX) ".0.fw"
+
+extern int htc_use_dev_fw;
#define IS_AR7010_DEVICE(_v) (((_v) == AR9280_USB) || ((_v) == AR9287_USB))
@@ -101,7 +119,8 @@ struct hif_device_usb {
struct usb_anchor reg_in_submitted;
struct usb_anchor mgmt_submitted;
struct sk_buff *remain_skb;
- const char *fw_name;
+ char fw_name[32];
+ int fw_minor_index;
int rx_remain_len;
int rx_pkt_len;
int rx_transfer_len;
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
index 7468562..57ca9b6 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
@@ -38,6 +38,10 @@ static int ath9k_ps_enable;
module_param_named(ps_enable, ath9k_ps_enable, int, 0444);
MODULE_PARM_DESC(ps_enable, "Enable WLAN PowerSave");
+int htc_use_dev_fw = 0;
+module_param_named(use_dev_fw, htc_use_dev_fw, int, 0444);
+MODULE_PARM_DESC(use_dev_fw, "Use development FW version");
+
#ifdef CONFIG_MAC80211_LEDS
int ath9k_htc_led_blink = 1;
module_param_named(blink, ath9k_htc_led_blink, int, 0444);
--
2.1.4
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH v2] ath9k_htc: introduce support for different fw versions
2015-06-14 23:27 ` Julian Calaby
2015-06-15 18:55 ` Oleksij Rempel
2015-06-15 18:57 ` Oleksij Rempel
@ 2015-06-15 18:58 ` Oleksij Rempel
2015-07-03 4:07 ` Oleksij Rempel
2015-07-12 12:17 ` Kalle Valo
2 siblings, 2 replies; 14+ messages in thread
From: Oleksij Rempel @ 2015-06-15 18:58 UTC (permalink / raw)
To: ath9k-devel, kvalo, linux-wireless; +Cc: Oleksij Rempel
Current kernel support only one fw name with theoretically only one
fw version. By replacing fw with other version we will break compatibility
with older kernels.
To avoid this kind of regression this patch will reuse fw version model
from iwlwifi driver.
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
---
drivers/net/wireless/ath/ath9k/hif_usb.c | 106 ++++++++++++++++++++------
drivers/net/wireless/ath/ath9k/hif_usb.h | 21 ++++-
drivers/net/wireless/ath/ath9k/htc_drv_init.c | 4 +
3 files changed, 105 insertions(+), 26 deletions(-)
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
index 10c02f5..165dd20 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.c
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
@@ -17,12 +17,8 @@
#include <asm/unaligned.h>
#include "htc.h"
-/* identify firmware images */
-#define FIRMWARE_AR7010_1_1 "htc_7010.fw"
-#define FIRMWARE_AR9271 "htc_9271.fw"
-
-MODULE_FIRMWARE(FIRMWARE_AR7010_1_1);
-MODULE_FIRMWARE(FIRMWARE_AR9271);
+MODULE_FIRMWARE(HTC_7010_MODULE_FW);
+MODULE_FIRMWARE(HTC_9271_MODULE_FW);
static struct usb_device_id ath9k_hif_usb_ids[] = {
{ USB_DEVICE(0x0cf3, 0x9271) }, /* Atheros */
@@ -1080,12 +1076,88 @@ static void ath9k_hif_usb_firmware_fail(struct hif_device_usb *hif_dev)
device_unlock(parent);
}
+static void ath9k_hif_usb_firmware_cb(const struct firmware *fw, void *context);
+
+/* taken from iwlwifi */
+static int ath9k_hif_request_firmware(struct hif_device_usb *hif_dev,
+ bool first)
+{
+ char index[8], *chip;
+ int ret;
+
+ if (first) {
+ if (htc_use_dev_fw) {
+ hif_dev->fw_minor_index = FIRMWARE_MINOR_IDX_MAX + 1;
+ sprintf(index, "%s", "dev");
+ } else {
+ hif_dev->fw_minor_index = FIRMWARE_MINOR_IDX_MAX;
+ sprintf(index, "%d", hif_dev->fw_minor_index);
+ }
+ } else {
+ hif_dev->fw_minor_index--;
+ sprintf(index, "%d", hif_dev->fw_minor_index);
+ }
+
+ /* test for FW 1.3 */
+ if (MAJOR_VERSION_REQ == 1 && hif_dev->fw_minor_index == 3) {
+ const char *filename;
+
+ if (IS_AR7010_DEVICE(hif_dev->usb_device_id->driver_info))
+ filename = FIRMWARE_AR7010_1_1;
+ else
+ filename = FIRMWARE_AR9271;
+
+ /* expected fw locations:
+ * - htc_9271.fw (stable version 1.3, depricated)
+ */
+ snprintf(hif_dev->fw_name, sizeof(hif_dev->fw_name),
+ "%s", filename);
+
+ } else if (hif_dev->fw_minor_index < FIRMWARE_MINOR_IDX_MIN) {
+ dev_err(&hif_dev->udev->dev, "no suitable firmware found!\n");
+
+ return -ENOENT;
+ } else {
+ if (IS_AR7010_DEVICE(hif_dev->usb_device_id->driver_info))
+ chip = "7010";
+ else
+ chip = "9271";
+
+ /* expected fw locations:
+ * - ath9k_htc/htc_9271-1.dev.0.fw (development version)
+ * - ath9k_htc/htc_9271-1.4.0.fw (stable version)
+ */
+ snprintf(hif_dev->fw_name, sizeof(hif_dev->fw_name),
+ "%s/htc_%s-%d.%s.0.fw", HTC_FW_PATH,
+ chip, MAJOR_VERSION_REQ, index);
+ }
+
+ ret = request_firmware_nowait(THIS_MODULE, true, hif_dev->fw_name,
+ &hif_dev->udev->dev, GFP_KERNEL,
+ hif_dev, ath9k_hif_usb_firmware_cb);
+ if (ret) {
+ dev_err(&hif_dev->udev->dev,
+ "ath9k_htc: Async request for firmware %s failed\n",
+ hif_dev->fw_name);
+ return ret;
+ }
+
+ dev_info(&hif_dev->udev->dev, "ath9k_htc: Firmware %s requested\n",
+ hif_dev->fw_name);
+
+ return ret;
+}
+
static void ath9k_hif_usb_firmware_cb(const struct firmware *fw, void *context)
{
struct hif_device_usb *hif_dev = context;
int ret;
if (!fw) {
+ ret = ath9k_hif_request_firmware(hif_dev, false);
+ if (!ret)
+ return;
+
dev_err(&hif_dev->udev->dev,
"ath9k_htc: Failed to get firmware %s\n",
hif_dev->fw_name);
@@ -1215,27 +1287,11 @@ static int ath9k_hif_usb_probe(struct usb_interface *interface,
init_completion(&hif_dev->fw_done);
- /* Find out which firmware to load */
-
- if (IS_AR7010_DEVICE(id->driver_info))
- hif_dev->fw_name = FIRMWARE_AR7010_1_1;
- else
- hif_dev->fw_name = FIRMWARE_AR9271;
-
- ret = request_firmware_nowait(THIS_MODULE, true, hif_dev->fw_name,
- &hif_dev->udev->dev, GFP_KERNEL,
- hif_dev, ath9k_hif_usb_firmware_cb);
- if (ret) {
- dev_err(&hif_dev->udev->dev,
- "ath9k_htc: Async request for firmware %s failed\n",
- hif_dev->fw_name);
+ ret = ath9k_hif_request_firmware(hif_dev, true);
+ if (ret)
goto err_fw_req;
- }
- dev_info(&hif_dev->udev->dev, "ath9k_htc: Firmware %s requested\n",
- hif_dev->fw_name);
-
- return 0;
+ return ret;
err_fw_req:
usb_set_intfdata(interface, NULL);
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.h b/drivers/net/wireless/ath/ath9k/hif_usb.h
index 51496e7..7c2ef7e 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.h
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.h
@@ -17,8 +17,26 @@
#ifndef HTC_USB_H
#define HTC_USB_H
+/* old firmware images */
+#define FIRMWARE_AR7010_1_1 "htc_7010.fw"
+#define FIRMWARE_AR9271 "htc_9271.fw"
+
+/* supported Major FW version */
#define MAJOR_VERSION_REQ 1
#define MINOR_VERSION_REQ 3
+/* minimal and maximal supported Minor FW version. */
+#define FIRMWARE_MINOR_IDX_MAX 4
+#define FIRMWARE_MINOR_IDX_MIN 3
+#define HTC_FW_PATH "ath9k_htc"
+
+#define HTC_9271_MODULE_FW HTC_FW_PATH "/htc_9271-" \
+ __stringify(MAJOR_VERSION_REQ) \
+ "." __stringify(FIRMWARE_MINOR_IDX_MAX) ".0.fw"
+#define HTC_7010_MODULE_FW HTC_FW_PATH "/htc_7010-" \
+ __stringify(MAJOR_VERSION_REQ) \
+ "." __stringify(FIRMWARE_MINOR_IDX_MAX) ".0.fw"
+
+extern int htc_use_dev_fw;
#define IS_AR7010_DEVICE(_v) (((_v) == AR9280_USB) || ((_v) == AR9287_USB))
@@ -101,7 +119,8 @@ struct hif_device_usb {
struct usb_anchor reg_in_submitted;
struct usb_anchor mgmt_submitted;
struct sk_buff *remain_skb;
- const char *fw_name;
+ char fw_name[32];
+ int fw_minor_index;
int rx_remain_len;
int rx_pkt_len;
int rx_transfer_len;
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
index 7468562..57ca9b6 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
@@ -38,6 +38,10 @@ static int ath9k_ps_enable;
module_param_named(ps_enable, ath9k_ps_enable, int, 0444);
MODULE_PARM_DESC(ps_enable, "Enable WLAN PowerSave");
+int htc_use_dev_fw = 0;
+module_param_named(use_dev_fw, htc_use_dev_fw, int, 0444);
+MODULE_PARM_DESC(use_dev_fw, "Use development FW version");
+
#ifdef CONFIG_MAC80211_LEDS
int ath9k_htc_led_blink = 1;
module_param_named(blink, ath9k_htc_led_blink, int, 0444);
--
2.1.4
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v2] ath9k_htc: introduce support for different fw versions
2015-06-15 18:58 ` [PATCH v2] " Oleksij Rempel
@ 2015-07-03 4:07 ` Oleksij Rempel
2015-07-03 10:53 ` Kalle Valo
2015-07-12 12:17 ` Kalle Valo
1 sibling, 1 reply; 14+ messages in thread
From: Oleksij Rempel @ 2015-07-03 4:07 UTC (permalink / raw)
To: ath9k-devel, kvalo, linux-wireless
[-- Attachment #1: Type: text/plain, Size: 7287 bytes --]
Any updates here?
Am 15.06.2015 um 20:58 schrieb Oleksij Rempel:
> Current kernel support only one fw name with theoretically only one
> fw version. By replacing fw with other version we will break compatibility
> with older kernels.
>
> To avoid this kind of regression this patch will reuse fw version model
> from iwlwifi driver.
>
> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
> ---
> drivers/net/wireless/ath/ath9k/hif_usb.c | 106 ++++++++++++++++++++------
> drivers/net/wireless/ath/ath9k/hif_usb.h | 21 ++++-
> drivers/net/wireless/ath/ath9k/htc_drv_init.c | 4 +
> 3 files changed, 105 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
> index 10c02f5..165dd20 100644
> --- a/drivers/net/wireless/ath/ath9k/hif_usb.c
> +++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
> @@ -17,12 +17,8 @@
> #include <asm/unaligned.h>
> #include "htc.h"
>
> -/* identify firmware images */
> -#define FIRMWARE_AR7010_1_1 "htc_7010.fw"
> -#define FIRMWARE_AR9271 "htc_9271.fw"
> -
> -MODULE_FIRMWARE(FIRMWARE_AR7010_1_1);
> -MODULE_FIRMWARE(FIRMWARE_AR9271);
> +MODULE_FIRMWARE(HTC_7010_MODULE_FW);
> +MODULE_FIRMWARE(HTC_9271_MODULE_FW);
>
> static struct usb_device_id ath9k_hif_usb_ids[] = {
> { USB_DEVICE(0x0cf3, 0x9271) }, /* Atheros */
> @@ -1080,12 +1076,88 @@ static void ath9k_hif_usb_firmware_fail(struct hif_device_usb *hif_dev)
> device_unlock(parent);
> }
>
> +static void ath9k_hif_usb_firmware_cb(const struct firmware *fw, void *context);
> +
> +/* taken from iwlwifi */
> +static int ath9k_hif_request_firmware(struct hif_device_usb *hif_dev,
> + bool first)
> +{
> + char index[8], *chip;
> + int ret;
> +
> + if (first) {
> + if (htc_use_dev_fw) {
> + hif_dev->fw_minor_index = FIRMWARE_MINOR_IDX_MAX + 1;
> + sprintf(index, "%s", "dev");
> + } else {
> + hif_dev->fw_minor_index = FIRMWARE_MINOR_IDX_MAX;
> + sprintf(index, "%d", hif_dev->fw_minor_index);
> + }
> + } else {
> + hif_dev->fw_minor_index--;
> + sprintf(index, "%d", hif_dev->fw_minor_index);
> + }
> +
> + /* test for FW 1.3 */
> + if (MAJOR_VERSION_REQ == 1 && hif_dev->fw_minor_index == 3) {
> + const char *filename;
> +
> + if (IS_AR7010_DEVICE(hif_dev->usb_device_id->driver_info))
> + filename = FIRMWARE_AR7010_1_1;
> + else
> + filename = FIRMWARE_AR9271;
> +
> + /* expected fw locations:
> + * - htc_9271.fw (stable version 1.3, depricated)
> + */
> + snprintf(hif_dev->fw_name, sizeof(hif_dev->fw_name),
> + "%s", filename);
> +
> + } else if (hif_dev->fw_minor_index < FIRMWARE_MINOR_IDX_MIN) {
> + dev_err(&hif_dev->udev->dev, "no suitable firmware found!\n");
> +
> + return -ENOENT;
> + } else {
> + if (IS_AR7010_DEVICE(hif_dev->usb_device_id->driver_info))
> + chip = "7010";
> + else
> + chip = "9271";
> +
> + /* expected fw locations:
> + * - ath9k_htc/htc_9271-1.dev.0.fw (development version)
> + * - ath9k_htc/htc_9271-1.4.0.fw (stable version)
> + */
> + snprintf(hif_dev->fw_name, sizeof(hif_dev->fw_name),
> + "%s/htc_%s-%d.%s.0.fw", HTC_FW_PATH,
> + chip, MAJOR_VERSION_REQ, index);
> + }
> +
> + ret = request_firmware_nowait(THIS_MODULE, true, hif_dev->fw_name,
> + &hif_dev->udev->dev, GFP_KERNEL,
> + hif_dev, ath9k_hif_usb_firmware_cb);
> + if (ret) {
> + dev_err(&hif_dev->udev->dev,
> + "ath9k_htc: Async request for firmware %s failed\n",
> + hif_dev->fw_name);
> + return ret;
> + }
> +
> + dev_info(&hif_dev->udev->dev, "ath9k_htc: Firmware %s requested\n",
> + hif_dev->fw_name);
> +
> + return ret;
> +}
> +
> static void ath9k_hif_usb_firmware_cb(const struct firmware *fw, void *context)
> {
> struct hif_device_usb *hif_dev = context;
> int ret;
>
> if (!fw) {
> + ret = ath9k_hif_request_firmware(hif_dev, false);
> + if (!ret)
> + return;
> +
> dev_err(&hif_dev->udev->dev,
> "ath9k_htc: Failed to get firmware %s\n",
> hif_dev->fw_name);
> @@ -1215,27 +1287,11 @@ static int ath9k_hif_usb_probe(struct usb_interface *interface,
>
> init_completion(&hif_dev->fw_done);
>
> - /* Find out which firmware to load */
> -
> - if (IS_AR7010_DEVICE(id->driver_info))
> - hif_dev->fw_name = FIRMWARE_AR7010_1_1;
> - else
> - hif_dev->fw_name = FIRMWARE_AR9271;
> -
> - ret = request_firmware_nowait(THIS_MODULE, true, hif_dev->fw_name,
> - &hif_dev->udev->dev, GFP_KERNEL,
> - hif_dev, ath9k_hif_usb_firmware_cb);
> - if (ret) {
> - dev_err(&hif_dev->udev->dev,
> - "ath9k_htc: Async request for firmware %s failed\n",
> - hif_dev->fw_name);
> + ret = ath9k_hif_request_firmware(hif_dev, true);
> + if (ret)
> goto err_fw_req;
> - }
>
> - dev_info(&hif_dev->udev->dev, "ath9k_htc: Firmware %s requested\n",
> - hif_dev->fw_name);
> -
> - return 0;
> + return ret;
>
> err_fw_req:
> usb_set_intfdata(interface, NULL);
> diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.h b/drivers/net/wireless/ath/ath9k/hif_usb.h
> index 51496e7..7c2ef7e 100644
> --- a/drivers/net/wireless/ath/ath9k/hif_usb.h
> +++ b/drivers/net/wireless/ath/ath9k/hif_usb.h
> @@ -17,8 +17,26 @@
> #ifndef HTC_USB_H
> #define HTC_USB_H
>
> +/* old firmware images */
> +#define FIRMWARE_AR7010_1_1 "htc_7010.fw"
> +#define FIRMWARE_AR9271 "htc_9271.fw"
> +
> +/* supported Major FW version */
> #define MAJOR_VERSION_REQ 1
> #define MINOR_VERSION_REQ 3
> +/* minimal and maximal supported Minor FW version. */
> +#define FIRMWARE_MINOR_IDX_MAX 4
> +#define FIRMWARE_MINOR_IDX_MIN 3
> +#define HTC_FW_PATH "ath9k_htc"
> +
> +#define HTC_9271_MODULE_FW HTC_FW_PATH "/htc_9271-" \
> + __stringify(MAJOR_VERSION_REQ) \
> + "." __stringify(FIRMWARE_MINOR_IDX_MAX) ".0.fw"
> +#define HTC_7010_MODULE_FW HTC_FW_PATH "/htc_7010-" \
> + __stringify(MAJOR_VERSION_REQ) \
> + "." __stringify(FIRMWARE_MINOR_IDX_MAX) ".0.fw"
> +
> +extern int htc_use_dev_fw;
>
> #define IS_AR7010_DEVICE(_v) (((_v) == AR9280_USB) || ((_v) == AR9287_USB))
>
> @@ -101,7 +119,8 @@ struct hif_device_usb {
> struct usb_anchor reg_in_submitted;
> struct usb_anchor mgmt_submitted;
> struct sk_buff *remain_skb;
> - const char *fw_name;
> + char fw_name[32];
> + int fw_minor_index;
> int rx_remain_len;
> int rx_pkt_len;
> int rx_transfer_len;
> diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
> index 7468562..57ca9b6 100644
> --- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c
> +++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
> @@ -38,6 +38,10 @@ static int ath9k_ps_enable;
> module_param_named(ps_enable, ath9k_ps_enable, int, 0444);
> MODULE_PARM_DESC(ps_enable, "Enable WLAN PowerSave");
>
> +int htc_use_dev_fw = 0;
> +module_param_named(use_dev_fw, htc_use_dev_fw, int, 0444);
> +MODULE_PARM_DESC(use_dev_fw, "Use development FW version");
> +
> #ifdef CONFIG_MAC80211_LEDS
> int ath9k_htc_led_blink = 1;
> module_param_named(blink, ath9k_htc_led_blink, int, 0444);
>
--
Regards,
Oleksij
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH v2] ath9k_htc: introduce support for different fw versions
2015-06-15 18:58 ` [PATCH v2] " Oleksij Rempel
2015-07-03 4:07 ` Oleksij Rempel
@ 2015-07-12 12:17 ` Kalle Valo
2015-07-12 17:42 ` [PATCH v3] " Oleksij Rempel
2015-08-14 5:12 ` Oleksij Rempel
1 sibling, 2 replies; 14+ messages in thread
From: Kalle Valo @ 2015-07-12 12:17 UTC (permalink / raw)
To: Oleksij Rempel; +Cc: ath9k-devel, linux-wireless
Oleksij Rempel <linux@rempel-privat.de> writes:
> Current kernel support only one fw name with theoretically only one
> fw version. By replacing fw with other version we will break compatibility
> with older kernels.
>
> To avoid this kind of regression this patch will reuse fw version model
> from iwlwifi driver.
>
> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
[...]
> +int htc_use_dev_fw = 0;
> +module_param_named(use_dev_fw, htc_use_dev_fw, int, 0444);
> +MODULE_PARM_DESC(use_dev_fw, "Use development FW version");
The commit log is really vague, please document properly how the
functionality changes from user point of view. And especially what does
this module parameter do? I'm a bit concerned about that.
--
Kalle Valo
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v3] ath9k_htc: introduce support for different fw versions
2015-07-12 12:17 ` Kalle Valo
@ 2015-07-12 17:42 ` Oleksij Rempel
2015-08-14 5:12 ` Oleksij Rempel
1 sibling, 0 replies; 14+ messages in thread
From: Oleksij Rempel @ 2015-07-12 17:42 UTC (permalink / raw)
To: ath9k-devel, kvalo, linux-wireless; +Cc: Oleksij Rempel
Current kernel support only one fw name with theoretically only one
fw version located in “firmware/htc_[9271|7010].fw”. Which is ok so far we have only one fw version (1.3). After we realised new fw 1.4, we faced compatibility problem which was decided to solve by firmware name and location:
- new firmware is located now in firmware/ath9k_htc/htc_[9271|7010]-1.4.0.fw
- old version 1.3 should be on old place, so old kernel have no issues with it.
- new kernels including this patch should be able to try different supported (min..max) fw version.
- new kernel should be able to support old fw location too. At least for now.
At same time this patch will add new module option which should allow user to play with development fw version without replacing stable one. If user will set “ath9k_htc use_dev_fw=1” module will try to find firmware/ath9k_htc/htc_[9271|7010]-1.dev.0.fw first and if it fails, use stable version: for example...1.4.0.fw.
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
---
drivers/net/wireless/ath/ath9k/hif_usb.c | 106 ++++++++++++++++++++------
drivers/net/wireless/ath/ath9k/hif_usb.h | 21 ++++-
drivers/net/wireless/ath/ath9k/htc_drv_init.c | 4 +
3 files changed, 105 insertions(+), 26 deletions(-)
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
index 10c02f5..165dd20 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.c
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
@@ -17,12 +17,8 @@
#include <asm/unaligned.h>
#include "htc.h"
-/* identify firmware images */
-#define FIRMWARE_AR7010_1_1 "htc_7010.fw"
-#define FIRMWARE_AR9271 "htc_9271.fw"
-
-MODULE_FIRMWARE(FIRMWARE_AR7010_1_1);
-MODULE_FIRMWARE(FIRMWARE_AR9271);
+MODULE_FIRMWARE(HTC_7010_MODULE_FW);
+MODULE_FIRMWARE(HTC_9271_MODULE_FW);
static struct usb_device_id ath9k_hif_usb_ids[] = {
{ USB_DEVICE(0x0cf3, 0x9271) }, /* Atheros */
@@ -1080,12 +1076,88 @@ static void ath9k_hif_usb_firmware_fail(struct hif_device_usb *hif_dev)
device_unlock(parent);
}
+static void ath9k_hif_usb_firmware_cb(const struct firmware *fw, void *context);
+
+/* taken from iwlwifi */
+static int ath9k_hif_request_firmware(struct hif_device_usb *hif_dev,
+ bool first)
+{
+ char index[8], *chip;
+ int ret;
+
+ if (first) {
+ if (htc_use_dev_fw) {
+ hif_dev->fw_minor_index = FIRMWARE_MINOR_IDX_MAX + 1;
+ sprintf(index, "%s", "dev");
+ } else {
+ hif_dev->fw_minor_index = FIRMWARE_MINOR_IDX_MAX;
+ sprintf(index, "%d", hif_dev->fw_minor_index);
+ }
+ } else {
+ hif_dev->fw_minor_index--;
+ sprintf(index, "%d", hif_dev->fw_minor_index);
+ }
+
+ /* test for FW 1.3 */
+ if (MAJOR_VERSION_REQ == 1 && hif_dev->fw_minor_index == 3) {
+ const char *filename;
+
+ if (IS_AR7010_DEVICE(hif_dev->usb_device_id->driver_info))
+ filename = FIRMWARE_AR7010_1_1;
+ else
+ filename = FIRMWARE_AR9271;
+
+ /* expected fw locations:
+ * - htc_9271.fw (stable version 1.3, depricated)
+ */
+ snprintf(hif_dev->fw_name, sizeof(hif_dev->fw_name),
+ "%s", filename);
+
+ } else if (hif_dev->fw_minor_index < FIRMWARE_MINOR_IDX_MIN) {
+ dev_err(&hif_dev->udev->dev, "no suitable firmware found!\n");
+
+ return -ENOENT;
+ } else {
+ if (IS_AR7010_DEVICE(hif_dev->usb_device_id->driver_info))
+ chip = "7010";
+ else
+ chip = "9271";
+
+ /* expected fw locations:
+ * - ath9k_htc/htc_9271-1.dev.0.fw (development version)
+ * - ath9k_htc/htc_9271-1.4.0.fw (stable version)
+ */
+ snprintf(hif_dev->fw_name, sizeof(hif_dev->fw_name),
+ "%s/htc_%s-%d.%s.0.fw", HTC_FW_PATH,
+ chip, MAJOR_VERSION_REQ, index);
+ }
+
+ ret = request_firmware_nowait(THIS_MODULE, true, hif_dev->fw_name,
+ &hif_dev->udev->dev, GFP_KERNEL,
+ hif_dev, ath9k_hif_usb_firmware_cb);
+ if (ret) {
+ dev_err(&hif_dev->udev->dev,
+ "ath9k_htc: Async request for firmware %s failed\n",
+ hif_dev->fw_name);
+ return ret;
+ }
+
+ dev_info(&hif_dev->udev->dev, "ath9k_htc: Firmware %s requested\n",
+ hif_dev->fw_name);
+
+ return ret;
+}
+
static void ath9k_hif_usb_firmware_cb(const struct firmware *fw, void *context)
{
struct hif_device_usb *hif_dev = context;
int ret;
if (!fw) {
+ ret = ath9k_hif_request_firmware(hif_dev, false);
+ if (!ret)
+ return;
+
dev_err(&hif_dev->udev->dev,
"ath9k_htc: Failed to get firmware %s\n",
hif_dev->fw_name);
@@ -1215,27 +1287,11 @@ static int ath9k_hif_usb_probe(struct usb_interface *interface,
init_completion(&hif_dev->fw_done);
- /* Find out which firmware to load */
-
- if (IS_AR7010_DEVICE(id->driver_info))
- hif_dev->fw_name = FIRMWARE_AR7010_1_1;
- else
- hif_dev->fw_name = FIRMWARE_AR9271;
-
- ret = request_firmware_nowait(THIS_MODULE, true, hif_dev->fw_name,
- &hif_dev->udev->dev, GFP_KERNEL,
- hif_dev, ath9k_hif_usb_firmware_cb);
- if (ret) {
- dev_err(&hif_dev->udev->dev,
- "ath9k_htc: Async request for firmware %s failed\n",
- hif_dev->fw_name);
+ ret = ath9k_hif_request_firmware(hif_dev, true);
+ if (ret)
goto err_fw_req;
- }
- dev_info(&hif_dev->udev->dev, "ath9k_htc: Firmware %s requested\n",
- hif_dev->fw_name);
-
- return 0;
+ return ret;
err_fw_req:
usb_set_intfdata(interface, NULL);
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.h b/drivers/net/wireless/ath/ath9k/hif_usb.h
index 51496e7..7c2ef7e 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.h
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.h
@@ -17,8 +17,26 @@
#ifndef HTC_USB_H
#define HTC_USB_H
+/* old firmware images */
+#define FIRMWARE_AR7010_1_1 "htc_7010.fw"
+#define FIRMWARE_AR9271 "htc_9271.fw"
+
+/* supported Major FW version */
#define MAJOR_VERSION_REQ 1
#define MINOR_VERSION_REQ 3
+/* minimal and maximal supported Minor FW version. */
+#define FIRMWARE_MINOR_IDX_MAX 4
+#define FIRMWARE_MINOR_IDX_MIN 3
+#define HTC_FW_PATH "ath9k_htc"
+
+#define HTC_9271_MODULE_FW HTC_FW_PATH "/htc_9271-" \
+ __stringify(MAJOR_VERSION_REQ) \
+ "." __stringify(FIRMWARE_MINOR_IDX_MAX) ".0.fw"
+#define HTC_7010_MODULE_FW HTC_FW_PATH "/htc_7010-" \
+ __stringify(MAJOR_VERSION_REQ) \
+ "." __stringify(FIRMWARE_MINOR_IDX_MAX) ".0.fw"
+
+extern int htc_use_dev_fw;
#define IS_AR7010_DEVICE(_v) (((_v) == AR9280_USB) || ((_v) == AR9287_USB))
@@ -101,7 +119,8 @@ struct hif_device_usb {
struct usb_anchor reg_in_submitted;
struct usb_anchor mgmt_submitted;
struct sk_buff *remain_skb;
- const char *fw_name;
+ char fw_name[32];
+ int fw_minor_index;
int rx_remain_len;
int rx_pkt_len;
int rx_transfer_len;
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
index 7468562..57ca9b6 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
@@ -38,6 +38,10 @@ static int ath9k_ps_enable;
module_param_named(ps_enable, ath9k_ps_enable, int, 0444);
MODULE_PARM_DESC(ps_enable, "Enable WLAN PowerSave");
+int htc_use_dev_fw = 0;
+module_param_named(use_dev_fw, htc_use_dev_fw, int, 0444);
+MODULE_PARM_DESC(use_dev_fw, "Use development FW version");
+
#ifdef CONFIG_MAC80211_LEDS
int ath9k_htc_led_blink = 1;
module_param_named(blink, ath9k_htc_led_blink, int, 0444);
--
2.1.4
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH v3] ath9k_htc: introduce support for different fw versions
2015-07-12 12:17 ` Kalle Valo
2015-07-12 17:42 ` [PATCH v3] " Oleksij Rempel
@ 2015-08-14 5:12 ` Oleksij Rempel
2015-09-06 10:55 ` Kalle Valo
1 sibling, 1 reply; 14+ messages in thread
From: Oleksij Rempel @ 2015-08-14 5:12 UTC (permalink / raw)
To: ath9k-devel, kvalo, linux-wireless; +Cc: Oleksij Rempel
Current kernel support only one fw name with theoretically only one
fw version located in “firmware/htc_[9271|7010].fw”. Which is ok so far we have only one fw version (1.3). After we realised new fw 1.4, we faced compatibility problem which was decided to solve by firmware name and location:
- new firmware is located now in firmware/ath9k_htc/htc_[9271|7010]-1.4.0.fw
- old version 1.3 should be on old place, so old kernel have no issues with it.
- new kernels including this patch should be able to try different supported (min..max) fw version.
- new kernel should be able to support old fw location too. At least for now.
At same time this patch will add new module option which should allow user to play with development fw version without replacing stable one. If user will set “ath9k_htc use_dev_fw=1” module will try to find firmware/ath9k_htc/htc_[9271|7010]-1.dev.0.fw first and if it fails, use stable version: for example...1.4.0.fw.
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
---
drivers/net/wireless/ath/ath9k/hif_usb.c | 106 ++++++++++++++++++++------
drivers/net/wireless/ath/ath9k/hif_usb.h | 21 ++++-
drivers/net/wireless/ath/ath9k/htc_drv_init.c | 4 +
3 files changed, 105 insertions(+), 26 deletions(-)
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
index 10c02f5..165dd20 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.c
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
@@ -17,12 +17,8 @@
#include <asm/unaligned.h>
#include "htc.h"
-/* identify firmware images */
-#define FIRMWARE_AR7010_1_1 "htc_7010.fw"
-#define FIRMWARE_AR9271 "htc_9271.fw"
-
-MODULE_FIRMWARE(FIRMWARE_AR7010_1_1);
-MODULE_FIRMWARE(FIRMWARE_AR9271);
+MODULE_FIRMWARE(HTC_7010_MODULE_FW);
+MODULE_FIRMWARE(HTC_9271_MODULE_FW);
static struct usb_device_id ath9k_hif_usb_ids[] = {
{ USB_DEVICE(0x0cf3, 0x9271) }, /* Atheros */
@@ -1080,12 +1076,88 @@ static void ath9k_hif_usb_firmware_fail(struct hif_device_usb *hif_dev)
device_unlock(parent);
}
+static void ath9k_hif_usb_firmware_cb(const struct firmware *fw, void *context);
+
+/* taken from iwlwifi */
+static int ath9k_hif_request_firmware(struct hif_device_usb *hif_dev,
+ bool first)
+{
+ char index[8], *chip;
+ int ret;
+
+ if (first) {
+ if (htc_use_dev_fw) {
+ hif_dev->fw_minor_index = FIRMWARE_MINOR_IDX_MAX + 1;
+ sprintf(index, "%s", "dev");
+ } else {
+ hif_dev->fw_minor_index = FIRMWARE_MINOR_IDX_MAX;
+ sprintf(index, "%d", hif_dev->fw_minor_index);
+ }
+ } else {
+ hif_dev->fw_minor_index--;
+ sprintf(index, "%d", hif_dev->fw_minor_index);
+ }
+
+ /* test for FW 1.3 */
+ if (MAJOR_VERSION_REQ == 1 && hif_dev->fw_minor_index == 3) {
+ const char *filename;
+
+ if (IS_AR7010_DEVICE(hif_dev->usb_device_id->driver_info))
+ filename = FIRMWARE_AR7010_1_1;
+ else
+ filename = FIRMWARE_AR9271;
+
+ /* expected fw locations:
+ * - htc_9271.fw (stable version 1.3, depricated)
+ */
+ snprintf(hif_dev->fw_name, sizeof(hif_dev->fw_name),
+ "%s", filename);
+
+ } else if (hif_dev->fw_minor_index < FIRMWARE_MINOR_IDX_MIN) {
+ dev_err(&hif_dev->udev->dev, "no suitable firmware found!\n");
+
+ return -ENOENT;
+ } else {
+ if (IS_AR7010_DEVICE(hif_dev->usb_device_id->driver_info))
+ chip = "7010";
+ else
+ chip = "9271";
+
+ /* expected fw locations:
+ * - ath9k_htc/htc_9271-1.dev.0.fw (development version)
+ * - ath9k_htc/htc_9271-1.4.0.fw (stable version)
+ */
+ snprintf(hif_dev->fw_name, sizeof(hif_dev->fw_name),
+ "%s/htc_%s-%d.%s.0.fw", HTC_FW_PATH,
+ chip, MAJOR_VERSION_REQ, index);
+ }
+
+ ret = request_firmware_nowait(THIS_MODULE, true, hif_dev->fw_name,
+ &hif_dev->udev->dev, GFP_KERNEL,
+ hif_dev, ath9k_hif_usb_firmware_cb);
+ if (ret) {
+ dev_err(&hif_dev->udev->dev,
+ "ath9k_htc: Async request for firmware %s failed\n",
+ hif_dev->fw_name);
+ return ret;
+ }
+
+ dev_info(&hif_dev->udev->dev, "ath9k_htc: Firmware %s requested\n",
+ hif_dev->fw_name);
+
+ return ret;
+}
+
static void ath9k_hif_usb_firmware_cb(const struct firmware *fw, void *context)
{
struct hif_device_usb *hif_dev = context;
int ret;
if (!fw) {
+ ret = ath9k_hif_request_firmware(hif_dev, false);
+ if (!ret)
+ return;
+
dev_err(&hif_dev->udev->dev,
"ath9k_htc: Failed to get firmware %s\n",
hif_dev->fw_name);
@@ -1215,27 +1287,11 @@ static int ath9k_hif_usb_probe(struct usb_interface *interface,
init_completion(&hif_dev->fw_done);
- /* Find out which firmware to load */
-
- if (IS_AR7010_DEVICE(id->driver_info))
- hif_dev->fw_name = FIRMWARE_AR7010_1_1;
- else
- hif_dev->fw_name = FIRMWARE_AR9271;
-
- ret = request_firmware_nowait(THIS_MODULE, true, hif_dev->fw_name,
- &hif_dev->udev->dev, GFP_KERNEL,
- hif_dev, ath9k_hif_usb_firmware_cb);
- if (ret) {
- dev_err(&hif_dev->udev->dev,
- "ath9k_htc: Async request for firmware %s failed\n",
- hif_dev->fw_name);
+ ret = ath9k_hif_request_firmware(hif_dev, true);
+ if (ret)
goto err_fw_req;
- }
- dev_info(&hif_dev->udev->dev, "ath9k_htc: Firmware %s requested\n",
- hif_dev->fw_name);
-
- return 0;
+ return ret;
err_fw_req:
usb_set_intfdata(interface, NULL);
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.h b/drivers/net/wireless/ath/ath9k/hif_usb.h
index 51496e7..7c2ef7e 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.h
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.h
@@ -17,8 +17,26 @@
#ifndef HTC_USB_H
#define HTC_USB_H
+/* old firmware images */
+#define FIRMWARE_AR7010_1_1 "htc_7010.fw"
+#define FIRMWARE_AR9271 "htc_9271.fw"
+
+/* supported Major FW version */
#define MAJOR_VERSION_REQ 1
#define MINOR_VERSION_REQ 3
+/* minimal and maximal supported Minor FW version. */
+#define FIRMWARE_MINOR_IDX_MAX 4
+#define FIRMWARE_MINOR_IDX_MIN 3
+#define HTC_FW_PATH "ath9k_htc"
+
+#define HTC_9271_MODULE_FW HTC_FW_PATH "/htc_9271-" \
+ __stringify(MAJOR_VERSION_REQ) \
+ "." __stringify(FIRMWARE_MINOR_IDX_MAX) ".0.fw"
+#define HTC_7010_MODULE_FW HTC_FW_PATH "/htc_7010-" \
+ __stringify(MAJOR_VERSION_REQ) \
+ "." __stringify(FIRMWARE_MINOR_IDX_MAX) ".0.fw"
+
+extern int htc_use_dev_fw;
#define IS_AR7010_DEVICE(_v) (((_v) == AR9280_USB) || ((_v) == AR9287_USB))
@@ -101,7 +119,8 @@ struct hif_device_usb {
struct usb_anchor reg_in_submitted;
struct usb_anchor mgmt_submitted;
struct sk_buff *remain_skb;
- const char *fw_name;
+ char fw_name[32];
+ int fw_minor_index;
int rx_remain_len;
int rx_pkt_len;
int rx_transfer_len;
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
index 7468562..57ca9b6 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
@@ -38,6 +38,10 @@ static int ath9k_ps_enable;
module_param_named(ps_enable, ath9k_ps_enable, int, 0444);
MODULE_PARM_DESC(ps_enable, "Enable WLAN PowerSave");
+int htc_use_dev_fw = 0;
+module_param_named(use_dev_fw, htc_use_dev_fw, int, 0444);
+MODULE_PARM_DESC(use_dev_fw, "Use development FW version");
+
#ifdef CONFIG_MAC80211_LEDS
int ath9k_htc_led_blink = 1;
module_param_named(blink, ath9k_htc_led_blink, int, 0444);
--
2.1.4
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v3] ath9k_htc: introduce support for different fw versions
2015-08-14 5:12 ` Oleksij Rempel
@ 2015-09-06 10:55 ` Kalle Valo
2015-09-06 11:01 ` Oleksij Rempel
0 siblings, 1 reply; 14+ messages in thread
From: Kalle Valo @ 2015-09-06 10:55 UTC (permalink / raw)
To: Oleksij Rempel; +Cc: ath9k-devel, linux-wireless
Oleksij Rempel <linux@rempel-privat.de> writes:
> Current kernel support only one fw name with theoretically only one
> fw version located in “firmware/htc_[9271|7010].fw”. Which is ok so
> far we have only one fw version (1.3). After we realised new fw 1.4,
> we faced compatibility problem which was decided to solve by firmware
> name and location:
>
> - new firmware is located now in firmware/ath9k_htc/htc_[9271|7010]-1.4.0.fw
> - old version 1.3 should be on old place, so old kernel have no issues with it.
> - new kernels including this patch should be able to try different supported (min..max) fw version.
> - new kernel should be able to support old fw location too. At least for now.
Please word wrap the commit log.
> At same time this patch will add new module option which should allow
> user to play with development fw version without replacing stable one.
> If user will set “ath9k_htc use_dev_fw=1” module will try to find
> firmware/ath9k_htc/htc_[9271|7010]-1.dev.0.fw first and if it fails,
> use stable version: for example...1.4.0.fw.
I'm not really sure if this module parameter makes sense and I haven't
noticed any other wifi driver having a similar parameter. If user wants
to test a developemnt firmware he can override a stable firmware version
with a simple cp operation. So why is the module parameter needed?
--
Kalle Valo
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3] ath9k_htc: introduce support for different fw versions
2015-09-06 10:55 ` Kalle Valo
@ 2015-09-06 11:01 ` Oleksij Rempel
2015-09-06 13:16 ` Kalle Valo
0 siblings, 1 reply; 14+ messages in thread
From: Oleksij Rempel @ 2015-09-06 11:01 UTC (permalink / raw)
To: Kalle Valo; +Cc: ath9k-devel, linux-wireless
[-- Attachment #1: Type: text/plain, Size: 1903 bytes --]
Am 06.09.2015 um 12:55 schrieb Kalle Valo:
> Oleksij Rempel <linux@rempel-privat.de> writes:
>
>> Current kernel support only one fw name with theoretically only one
>> fw version located in “firmware/htc_[9271|7010].fw”. Which is ok so
>> far we have only one fw version (1.3). After we realised new fw 1.4,
>> we faced compatibility problem which was decided to solve by firmware
>> name and location:
>>
>> - new firmware is located now in firmware/ath9k_htc/htc_[9271|7010]-1.4.0.fw
>> - old version 1.3 should be on old place, so old kernel have no issues with it.
>> - new kernels including this patch should be able to try different supported (min..max) fw version.
>> - new kernel should be able to support old fw location too. At least for now.
>
> Please word wrap the commit log.
ok.
>> At same time this patch will add new module option which should allow
>> user to play with development fw version without replacing stable one.
>> If user will set “ath9k_htc use_dev_fw=1” module will try to find
>> firmware/ath9k_htc/htc_[9271|7010]-1.dev.0.fw first and if it fails,
>> use stable version: for example...1.4.0.fw.
>
> I'm not really sure if this module parameter makes sense and I haven't
> noticed any other wifi driver having a similar parameter. If user wants
> to test a developemnt firmware he can override a stable firmware version
> with a simple cp operation. So why is the module parameter needed?
>
Sure, iwl module has CONFIG for this case, so you should recompile it.
The use case which i was thinking is the ability to provide a package
for dev FW, which will not conflict with main FW package.
The package just should provide 3 files, /etc/modules/ath9k_htc_params
and /lib/firmware/bla.fw
If dev package introduces some regressions i still can ask user to
reload module with other parameter.
--
Regards,
Oleksij
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3] ath9k_htc: introduce support for different fw versions
2015-09-06 11:01 ` Oleksij Rempel
@ 2015-09-06 13:16 ` Kalle Valo
0 siblings, 0 replies; 14+ messages in thread
From: Kalle Valo @ 2015-09-06 13:16 UTC (permalink / raw)
To: Oleksij Rempel; +Cc: ath9k-devel, linux-wireless
Oleksij Rempel <linux@rempel-privat.de> writes:
>>> At same time this patch will add new module option which should allow
>>> user to play with development fw version without replacing stable one.
>>> If user will set “ath9k_htc use_dev_fw=1” module will try to find
>>> firmware/ath9k_htc/htc_[9271|7010]-1.dev.0.fw first and if it fails,
>>> use stable version: for example...1.4.0.fw.
>>
>> I'm not really sure if this module parameter makes sense and I haven't
>> noticed any other wifi driver having a similar parameter. If user wants
>> to test a developemnt firmware he can override a stable firmware version
>> with a simple cp operation. So why is the module parameter needed?
>
> Sure, iwl module has CONFIG for this case, so you should recompile it.
Yeah, that's even worse.
> The use case which i was thinking is the ability to provide a package
> for dev FW, which will not conflict with main FW package.
>
> The package just should provide 3 files, /etc/modules/ath9k_htc_params
> and /lib/firmware/bla.fw
> If dev package introduces some regressions i still can ask user to
> reload module with other parameter.
I think this should be doable even without a module parameter, but I
guess the module parameter is ok then.
--
Kalle Valo
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2015-09-06 13:16 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-14 16:12 [PATCH] ath9k_htc: introduce support for different fw versions Oleksij Rempel
2015-06-14 23:27 ` Julian Calaby
2015-06-15 18:55 ` Oleksij Rempel
2015-06-15 18:57 ` Oleksij Rempel
2015-06-15 18:58 ` [PATCH v2] " Oleksij Rempel
2015-07-03 4:07 ` Oleksij Rempel
2015-07-03 10:53 ` Kalle Valo
2015-07-03 17:43 ` Oleksij Rempel
2015-07-12 12:17 ` Kalle Valo
2015-07-12 17:42 ` [PATCH v3] " Oleksij Rempel
2015-08-14 5:12 ` Oleksij Rempel
2015-09-06 10:55 ` Kalle Valo
2015-09-06 11:01 ` Oleksij Rempel
2015-09-06 13:16 ` 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).