2017-08-14 12:16:20

by Reizer, Eyal

[permalink] [raw]
Subject: [v7 wlcore: add missing nvs file name info for wilink8

The following commits:
commit c815fdebef44 ("wlcore: spi: Populate config firmware data")
commit d776fc86b82f ("wlcore: sdio: Populate config firmware data")

Populated the nvs entry for wilink6 and wilink7 only while it is
still needed for wilink8 as well.
This broke user space backward compatibility when upgrading from older
kernels, as the alternate mac address would not be read from the nvs that
is present in the file system (lib/firmware/ti-connectivity/wl1271-nvs.bin)
causing mac address change of the wlan interface.

This patch fix this and update the structure field with the same default
nvs file name that has been used before.

In addition, some distros hold a default wl1271-nvs.bin in the file
system with a bogus mac address (deadbeef...) that overrides the mac
address that is stored inside the device.
Warn users about this bogus mac address and use the internal mac address

Fixes: c815fdebef44 ("wlcore: spi: Populate config firmware data")
Fixes: d776fc86b82f ("wlcore: sdio: Populate config firmware data")
Signed-off-by: Eyal Reizer <[email protected]>
---
v2->v3: add a check for default deadbeef... mac address and warn about it
v3->v4: use a random TI mac address instead of the bogus one
v4->v5: add constant definition for TI oui address
v5->v6: after also verifying on wilink6/7 Use mac internal mac address
instead of a random one
v6->v7: use random mac in case internal mac is zero
---
drivers/net/wireless/ti/wlcore/main.c | 23 +++++++++++++++++++++++
drivers/net/wireless/ti/wlcore/sdio.c | 1 +
drivers/net/wireless/ti/wlcore/spi.c | 1 +
drivers/net/wireless/ti/wlcore/wlcore.h | 3 +++
4 files changed, 28 insertions(+)

diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/t=
i/wlcore/main.c
index 60aaa85..40692ac 100644
--- a/drivers/net/wireless/ti/wlcore/main.c
+++ b/drivers/net/wireless/ti/wlcore/main.c
@@ -6040,6 +6040,29 @@ static int wl1271_register_hw(struct wl1271 *wl)
nic_addr =3D wl->fuse_nic_addr + 1;
}
=20
+ if (oui_addr =3D=3D 0xdeadbe && nic_addr =3D=3D 0xef0000) {
+ wl1271_warning("Detected unconfigured mac address in nvs.\n"
+ "derive from fuse instead.\n"
+ "in case of using a wl12xx device, your "
+ "device performance may not be optimized.\n"
+ "Please use the calibrator tool to configure "
+ "your device.\n"
+ "When using a wl18xx device this default nvs "
+ "file can be removed from the file system\n");
+
+ if (wl->fuse_oui_addr =3D=3D 0 && wl->fuse_nic_addr =3D=3D 0) {
+ wl1271_warning("Fuse mac address is zero. using "
+ "random mac\n");
+ /* Use TI oui and a random nic */
+ oui_addr =3D WLCORE_TI_OUI_ADDRESS;
+ nic_addr =3D get_random_int();
+ } else {
+ oui_addr =3D wl->fuse_oui_addr;
+ /* fuse has the BD_ADDR, the WLAN addresses are the next two */
+ nic_addr =3D wl->fuse_nic_addr + 1;
+ }
+ }
+
wl12xx_derive_mac_addresses(wl, oui_addr, nic_addr);
=20
ret =3D ieee80211_register_hw(wl->hw);
diff --git a/drivers/net/wireless/ti/wlcore/sdio.c b/drivers/net/wireless/t=
i/wlcore/sdio.c
index 2fb3871..f8a1fea 100644
--- a/drivers/net/wireless/ti/wlcore/sdio.c
+++ b/drivers/net/wireless/ti/wlcore/sdio.c
@@ -230,6 +230,7 @@ static const struct wilink_family_data wl128x_data =3D =
{
static const struct wilink_family_data wl18xx_data =3D {
.name =3D "wl18xx",
.cfg_name =3D "ti-connectivity/wl18xx-conf.bin",
+ .nvs_name =3D "ti-connectivity/wl1271-nvs.bin",
};
=20
static const struct of_device_id wlcore_sdio_of_match_table[] =3D {
diff --git a/drivers/net/wireless/ti/wlcore/spi.c b/drivers/net/wireless/ti=
/wlcore/spi.c
index fdabb92..62ce54a 100644
--- a/drivers/net/wireless/ti/wlcore/spi.c
+++ b/drivers/net/wireless/ti/wlcore/spi.c
@@ -92,6 +92,7 @@ static const struct wilink_family_data wl128x_data =3D {
static const struct wilink_family_data wl18xx_data =3D {
.name =3D "wl18xx",
.cfg_name =3D "ti-connectivity/wl18xx-conf.bin",
+ .nvs_name =3D "ti-connectivity/wl1271-nvs.bin",
};
=20
struct wl12xx_spi_glue {
diff --git a/drivers/net/wireless/ti/wlcore/wlcore.h b/drivers/net/wireless=
/ti/wlcore/wlcore.h
index 1827546..95fbedc 100644
--- a/drivers/net/wireless/ti/wlcore/wlcore.h
+++ b/drivers/net/wireless/ti/wlcore/wlcore.h
@@ -40,6 +40,9 @@
/* wl12xx/wl18xx maximum transmission power (in dBm) */
#define WLCORE_MAX_TXPWR 25
=20
+/* Texas Instruments pre assigned OUI */
+#define WLCORE_TI_OUI_ADDRESS 0x080028
+
/* forward declaration */
struct wl1271_tx_hw_descr;
enum wl_rx_buf_align;
--=20
2.7.4


2017-08-15 13:09:57

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [v7 wlcore: add missing nvs file name info for wilink8

Hi,

On Mon, Aug 14, 2017 at 12:15:16PM +0000, Reizer, Eyal wrote:
> The following commits:
> commit c815fdebef44 ("wlcore: spi: Populate config firmware data")
> commit d776fc86b82f ("wlcore: sdio: Populate config firmware data")
>
> Populated the nvs entry for wilink6 and wilink7 only while it is
> still needed for wilink8 as well.
> This broke user space backward compatibility when upgrading from older
> kernels, as the alternate mac address would not be read from the nvs that
> is present in the file system (lib/firmware/ti-connectivity/wl1271-nvs.bin)
> causing mac address change of the wlan interface.
>
> This patch fix this and update the structure field with the same default
> nvs file name that has been used before.
>
> In addition, some distros hold a default wl1271-nvs.bin in the file
> system with a bogus mac address (deadbeef...) that overrides the mac
> address that is stored inside the device.
> Warn users about this bogus mac address and use the internal mac address
>
> Fixes: c815fdebef44 ("wlcore: spi: Populate config firmware data")
> Fixes: d776fc86b82f ("wlcore: sdio: Populate config firmware data")
> Signed-off-by: Eyal Reizer <[email protected]>
> ---
> v2->v3: add a check for default deadbeef... mac address and warn about it
> v3->v4: use a random TI mac address instead of the bogus one
> v4->v5: add constant definition for TI oui address
> v5->v6: after also verifying on wilink6/7 Use mac internal mac address
> instead of a random one
> v6->v7: use random mac in case internal mac is zero
> ---
> drivers/net/wireless/ti/wlcore/main.c | 23 +++++++++++++++++++++++
> drivers/net/wireless/ti/wlcore/sdio.c | 1 +
> drivers/net/wireless/ti/wlcore/spi.c | 1 +
> drivers/net/wireless/ti/wlcore/wlcore.h | 3 +++
> 4 files changed, 28 insertions(+)
>
> diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/ti/wlcore/main.c
> index 60aaa85..40692ac 100644
> --- a/drivers/net/wireless/ti/wlcore/main.c
> +++ b/drivers/net/wireless/ti/wlcore/main.c
> @@ -6040,6 +6040,29 @@ static int wl1271_register_hw(struct wl1271 *wl)
> nic_addr = wl->fuse_nic_addr + 1;
> }
>
> + if (oui_addr == 0xdeadbe && nic_addr == 0xef0000) {
> + wl1271_warning("Detected unconfigured mac address in nvs.\n"
> + "derive from fuse instead.\n"
> + "in case of using a wl12xx device, your "
> + "device performance may not be optimized.\n"
> + "Please use the calibrator tool to configure "
> + "your device.\n"
> + "When using a wl18xx device this default nvs "
> + "file can be removed from the file system\n");

Usually we do not break multiline messages to make it easier to grep
for them. Also it feels weird to say "if your device is ..., then
...", when we actually know which device it is. I suggest the
following:

wl1271_warning("Detected unconfigured mac address in nvs, derive from fuse instead.\n");
if (device_is_wl12xx) {
wl1271_warning("Your device performance is not optimized.\n");
wl1271_warning("Please use the calibrator tool to configure your device.\n");
} else {
wl1271_warning("This default nvs file can be removed from the file system\n");
}

> + if (wl->fuse_oui_addr == 0 && wl->fuse_nic_addr == 0) {
> + wl1271_warning("Fuse mac address is zero. using "
> + "random mac\n");

This one should also go into one line.

> + /* Use TI oui and a random nic */
> + oui_addr = WLCORE_TI_OUI_ADDRESS;
> + nic_addr = get_random_int();
> + } else {
> + oui_addr = wl->fuse_oui_addr;
> + /* fuse has the BD_ADDR, the WLAN addresses are the next two */
> + nic_addr = wl->fuse_nic_addr + 1;
> + }
> + }
> +
> wl12xx_derive_mac_addresses(wl, oui_addr, nic_addr);
>
> ret = ieee80211_register_hw(wl->hw);
> diff --git a/drivers/net/wireless/ti/wlcore/sdio.c b/drivers/net/wireless/ti/wlcore/sdio.c
> index 2fb3871..f8a1fea 100644
> --- a/drivers/net/wireless/ti/wlcore/sdio.c
> +++ b/drivers/net/wireless/ti/wlcore/sdio.c
> @@ -230,6 +230,7 @@ static const struct wilink_family_data wl128x_data = {
> static const struct wilink_family_data wl18xx_data = {
> .name = "wl18xx",
> .cfg_name = "ti-connectivity/wl18xx-conf.bin",
> + .nvs_name = "ti-connectivity/wl1271-nvs.bin",
> };
>
> static const struct of_device_id wlcore_sdio_of_match_table[] = {
> diff --git a/drivers/net/wireless/ti/wlcore/spi.c b/drivers/net/wireless/ti/wlcore/spi.c
> index fdabb92..62ce54a 100644
> --- a/drivers/net/wireless/ti/wlcore/spi.c
> +++ b/drivers/net/wireless/ti/wlcore/spi.c
> @@ -92,6 +92,7 @@ static const struct wilink_family_data wl128x_data = {
> static const struct wilink_family_data wl18xx_data = {
> .name = "wl18xx",
> .cfg_name = "ti-connectivity/wl18xx-conf.bin",
> + .nvs_name = "ti-connectivity/wl1271-nvs.bin",
> };
>
> struct wl12xx_spi_glue {
> diff --git a/drivers/net/wireless/ti/wlcore/wlcore.h b/drivers/net/wireless/ti/wlcore/wlcore.h
> index 1827546..95fbedc 100644
> --- a/drivers/net/wireless/ti/wlcore/wlcore.h
> +++ b/drivers/net/wireless/ti/wlcore/wlcore.h
> @@ -40,6 +40,9 @@
> /* wl12xx/wl18xx maximum transmission power (in dBm) */
> #define WLCORE_MAX_TXPWR 25
>
> +/* Texas Instruments pre assigned OUI */
> +#define WLCORE_TI_OUI_ADDRESS 0x080028
> +
> /* forward declaration */
> struct wl1271_tx_hw_descr;
> enum wl_rx_buf_align;

Otherwise:

Reviewed-by: Sebastian Reichel <[email protected]>

-- Sebastian


Attachments:
(No filename) (5.28 kB)
signature.asc (833.00 B)
Download all attachments

2017-08-16 07:18:01

by Reizer, Eyal

[permalink] [raw]
Subject: RE: [v7 wlcore: add missing nvs file name info for wilink8

> >
> > + if (oui_addr =3D=3D 0xdeadbe && nic_addr =3D=3D 0xef0000) {
> > + wl1271_warning("Detected unconfigured mac address in
> nvs.\n"
> > + "derive from fuse instead.\n"
> > + "in case of using a wl12xx device, your "
> > + "device performance may not be
> optimized.\n"
> > + "Please use the calibrator tool to configure "
> > + "your device.\n"
> > + "When using a wl18xx device this default nvs
> "
> > + "file can be removed from the file
> system\n");
>=20
> Usually we do not break multiline messages to make it easier to grep
> for them. Also it feels weird to say "if your device is ..., then
> ...", when we actually know which device it is. I suggest the
> following:
>=20
> wl1271_warning("Detected unconfigured mac address in nvs, derive from
> fuse instead.\n");
> if (device_is_wl12xx) {
> wl1271_warning("Your device performance is not optimized.\n");
> wl1271_warning("Please use the calibrator tool to configure your
> device.\n");
> } else {
> wl1271_warning("This default nvs file can be removed from the file
> system\n");
> }
OK, will try that out.

>=20
> > + if (wl->fuse_oui_addr =3D=3D 0 && wl->fuse_nic_addr =3D=3D 0) {
> > + wl1271_warning("Fuse mac address is zero. using "
> > + "random mac\n");
>=20
> This one should also go into one line.

This will still exceed 80 characters. Is this still ok?

>=20
> > + /* Use TI oui and a random nic */
> > + oui_addr =3D WLCORE_TI_OUI_ADDRESS;
> > + nic_addr =3D get_random_int();
> > + } else {
> > + oui_addr =3D wl->fuse_oui_addr;
> > + /* fuse has the BD_ADDR, the WLAN addresses are
> the next two */
> > + nic_addr =3D wl->fuse_nic_addr + 1;
> > + }
> > + }
> > +
> > wl12xx_derive_mac_addresses(wl, oui_addr, nic_addr);
> >
> > ret =3D ieee80211_register_hw(wl->hw);
> > diff --git a/drivers/net/wireless/ti/wlcore/sdio.c
> b/drivers/net/wireless/ti/wlcore/sdio.c
> > index 2fb3871..f8a1fea 100644
> > --- a/drivers/net/wireless/ti/wlcore/sdio.c
> > +++ b/drivers/net/wireless/ti/wlcore/sdio.c
> > @@ -230,6 +230,7 @@ static const struct wilink_family_data wl128x_data =
=3D
> {
> > static const struct wilink_family_data wl18xx_data =3D {
> > .name =3D "wl18xx",
> > .cfg_name =3D "ti-connectivity/wl18xx-conf.bin",
> > + .nvs_name =3D "ti-connectivity/wl1271-nvs.bin",
> > };
> >
> > static const struct of_device_id wlcore_sdio_of_match_table[] =3D {
> > diff --git a/drivers/net/wireless/ti/wlcore/spi.c
> b/drivers/net/wireless/ti/wlcore/spi.c
> > index fdabb92..62ce54a 100644
> > --- a/drivers/net/wireless/ti/wlcore/spi.c
> > +++ b/drivers/net/wireless/ti/wlcore/spi.c
> > @@ -92,6 +92,7 @@ static const struct wilink_family_data wl128x_data =
=3D {
> > static const struct wilink_family_data wl18xx_data =3D {
> > .name =3D "wl18xx",
> > .cfg_name =3D "ti-connectivity/wl18xx-conf.bin",
> > + .nvs_name =3D "ti-connectivity/wl1271-nvs.bin",
> > };
> >
> > struct wl12xx_spi_glue {
> > diff --git a/drivers/net/wireless/ti/wlcore/wlcore.h
> b/drivers/net/wireless/ti/wlcore/wlcore.h
> > index 1827546..95fbedc 100644
> > --- a/drivers/net/wireless/ti/wlcore/wlcore.h
> > +++ b/drivers/net/wireless/ti/wlcore/wlcore.h
> > @@ -40,6 +40,9 @@
> > /* wl12xx/wl18xx maximum transmission power (in dBm) */
> > #define WLCORE_MAX_TXPWR 25
> >
> > +/* Texas Instruments pre assigned OUI */
> > +#define WLCORE_TI_OUI_ADDRESS 0x080028
> > +
> > /* forward declaration */
> > struct wl1271_tx_hw_descr;
> > enum wl_rx_buf_align;
>=20
> Otherwise:
>=20
> Reviewed-by: Sebastian Reichel <[email protected]>
>=20
Thank you. Will submit v8 with your comments about the strings.=20
Just waiting for clarification on the 80 characters question above

Best Regards,
Eyal

2017-08-14 16:04:11

by Tony Lindgren

[permalink] [raw]
Subject: Re: [v7 wlcore: add missing nvs file name info for wilink8

* Reizer, Eyal <[email protected]> [170814 05:15]:
> The following commits:
> commit c815fdebef44 ("wlcore: spi: Populate config firmware data")
> commit d776fc86b82f ("wlcore: sdio: Populate config firmware data")
>
> Populated the nvs entry for wilink6 and wilink7 only while it is
> still needed for wilink8 as well.
> This broke user space backward compatibility when upgrading from older
> kernels, as the alternate mac address would not be read from the nvs that
> is present in the file system (lib/firmware/ti-connectivity/wl1271-nvs.bin)
> causing mac address change of the wlan interface.
>
> This patch fix this and update the structure field with the same default
> nvs file name that has been used before.
>
> In addition, some distros hold a default wl1271-nvs.bin in the file
> system with a bogus mac address (deadbeef...) that overrides the mac
> address that is stored inside the device.
> Warn users about this bogus mac address and use the internal mac address
>
> Fixes: c815fdebef44 ("wlcore: spi: Populate config firmware data")
> Fixes: d776fc86b82f ("wlcore: sdio: Populate config firmware data")
> Signed-off-by: Eyal Reizer <[email protected]>
> ---
> v2->v3: add a check for default deadbeef... mac address and warn about it
> v3->v4: use a random TI mac address instead of the bogus one
> v4->v5: add constant definition for TI oui address
> v5->v6: after also verifying on wilink6/7 Use mac internal mac address
> instead of a random one
> v6->v7: use random mac in case internal mac is zero

Great, works for me! Thanks for fixing this issue properly:

Tested-by: Tony Lindgren <[email protected]>

2017-08-16 13:57:52

by Kalle Valo

[permalink] [raw]
Subject: Re: [v7 wlcore: add missing nvs file name info for wilink8

"Reizer, Eyal" <[email protected]> writes:

>> > + if (wl->fuse_oui_addr == 0 && wl->fuse_nic_addr == 0) {
>> > + wl1271_warning("Fuse mac address is zero. using "
>> > + "random mac\n");
>>
>> This one should also go into one line.
>
> This will still exceed 80 characters. Is this still ok?

Yes, it's ok that the _format string_ goes above 80 chars, but if there
are paremeters you should split them to a separate line. Example:

pr_debug("This is an example of a very long message which also prints few variables foo %d bar %d",
foo, bar);

--
Kalle Valo