Re: [PATCH v3] ath9k_htc: introduce support for different fw versions

2015-09-06 Thread Kalle Valo
Oleksij Rempel  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
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3] ath9k_htc: introduce support for different fw versions

2015-09-06 Thread Oleksij Rempel
Am 06.09.2015 um 12:55 schrieb Kalle Valo:
> Oleksij Rempel  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



signature.asc
Description: OpenPGP digital signature


Re: [PATCH v3] ath9k_htc: introduce support for different fw versions

2015-09-06 Thread Kalle Valo
Oleksij Rempel  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
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3] ath9k_htc: introduce support for different fw versions

2015-08-13 Thread 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 li...@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, 

[PATCH v3] ath9k_htc: introduce support for different fw versions

2015-07-12 Thread 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 li...@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,