2017-07-31 08:46:43

by Reizer, Eyal

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

The following commits:
c815fde wlcore: spi: Populate config firmware data
d776fc8 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 for a wl18xx device
also overrides the mac address that is stored inside the device.
Warn users about this bogus mac address and use a random mac instead

Cc: stable <[email protected]>
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

---
drivers/net/wireless/ti/wlcore/main.c | 16 ++++++++++++++++
drivers/net/wireless/ti/wlcore/sdio.c | 1 +
drivers/net/wireless/ti/wlcore/spi.c | 1 +
3 files changed, 18 insertions(+)

diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/t=
i/wlcore/main.c
index 60aaa85..7ce4221 100644
--- a/drivers/net/wireless/ti/wlcore/main.c
+++ b/drivers/net/wireless/ti/wlcore/main.c
@@ -5961,6 +5961,22 @@ static void wl12xx_derive_mac_addresses(struct wl127=
1 *wl, u32 oui, u32 nic)
if (nic + WLCORE_NUM_MAC_ADDRESSES - wl->num_mac_addr > 0xffffff)
wl1271_warning("NIC part of the MAC address wraps around!");
=20
+ if (oui =3D=3D 0xdeadbe && nic =3D=3D 0xef0000) {
+ wl1271_warning("Detected unconfigured mac address in nvs.\n"
+ "Using a random TI mac address 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 the nvs file can "
+ "be removed as a default mac address is "
+ "stored internally.\n");
+
+ /* Use TI oui and a random nic */
+ oui =3D 0x080028;
+ nic =3D get_random_int();
+ }
+
for (i =3D 0; i < wl->num_mac_addr; i++) {
wl->addresses[i].addr[0] =3D (u8)(oui >> 16);
wl->addresses[i].addr[1] =3D (u8)(oui >> 8);
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 {
--=20
2.7.4


2017-08-05 05:51:16

by Julian Calaby

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

Hi Eyal,

On Mon, Jul 31, 2017 at 6:45 PM, Reizer, Eyal <[email protected]> wrote:
> The following commits:
> c815fde wlcore: spi: Populate config firmware data
> d776fc8 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 for a wl18xx device
> also overrides the mac address that is stored inside the device.
> Warn users about this bogus mac address and use a random mac instead
>
> Cc: stable <[email protected]>
> Signed-off-by: Eyal Reizer <[email protected]>
> ---
>
> diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/ti/wlcore/main.c
> index 60aaa85..7ce4221 100644
> --- a/drivers/net/wireless/ti/wlcore/main.c
> +++ b/drivers/net/wireless/ti/wlcore/main.c
> @@ -5961,6 +5961,22 @@ static void wl12xx_derive_mac_addresses(struct wl1271 *wl, u32 oui, u32 nic)
> if (nic + WLCORE_NUM_MAC_ADDRESSES - wl->num_mac_addr > 0xffffff)
> wl1271_warning("NIC part of the MAC address wraps around!");
>
> + if (oui == 0xdeadbe && nic == 0xef0000) {
> + wl1271_warning("Detected unconfigured mac address in nvs.\n"
> + "Using a random TI mac address 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 the nvs file can "
> + "be removed as a default mac address is "
> + "stored internally.\n");
> +
> + /* Use TI oui and a random nic */
> + oui = 0x080028;

Is there (or should there be) a constant for this?

Thanks,

--
Julian Calaby

Email: [email protected]
Profile: http://www.google.com/profiles/julian.calaby/

2017-08-07 07:31:38

by Reizer, Eyal

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

DQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogSnVsaWFuIENhbGFieSBb
bWFpbHRvOmp1bGlhbi5jYWxhYnlAZ21haWwuY29tXQ0KPiBTZW50OiBTYXR1cmRheSwgQXVndXN0
IDUsIDIwMTcgODo1MSBBTQ0KPiBUbzogUmVpemVyLCBFeWFsDQo+IENjOiBLYWxsZSBW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pY2UuXG4iDQo+ID4gKyAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAiV2hlbiB1c2luZyBhIHdsMTh4eCBkZXZpY2UgdGhl
IG52cyBmaWxlIGNhbiAiDQo+ID4gKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiYmUg
cmVtb3ZlZCBhcyBhIGRlZmF1bHQgbWFjIGFkZHJlc3MgaXMgIg0KPiA+ICsgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgInN0b3JlZCBpbnRlcm5hbGx5LlxuIik7DQo+ID4gKw0KPiA+ICsg
ICAgICAgICAgICAgICAvKiBVc2UgVEkgb3VpIGFuZCBhIHJhbmRvbSBuaWMgKi8NCj4gPiArICAg
ICAgICAgICAgICAgb3VpID0gMHgwODAwMjg7DQo+IA0KPiBJcyB0aGVyZSAob3Igc2hvdWxkIHRo
ZXJlIGJlKSBhIGNvbnN0YW50IGZvciB0aGlzPw0KDQpUaGFua3MgZm9yIHRoZSBjb21tZW50LiBT
dWJtaXR0aW5nIHY1IGZpeGluZyB0aGlzLg0KDQpCZXN0IFJlZ2FyZHMsDQpFeWFsDQo=