mbox series

[v2,0/2,SRU,B/master] UBUNTU: SAUCE: arm64: snapdragon: wcn36xx MAC

Message ID 1528970937-26879-1-git-send-email-paolo.pisati@canonical.com
Headers show
Series UBUNTU: SAUCE: arm64: snapdragon: wcn36xx MAC | expand

Message

Paolo Pisati June 14, 2018, 10:08 a.m. UTC
BugLink: http://bugs.launchpad.net/bugs/1776491

Impact:

The wcn36xx driver in Xenial/linux-snapdragon had an ability to autogenerate its
MAC address upon boot, or read it from a file (/lib/firmware/wlan/macaddr0). The
linux-snapdragon kernel in Bionic doesn't have this feature.

While by itself not a bug (Xenial used a QCOM provided custom driver, while
Bionic uses the upstream wcn36xx driver), it can be easily work-arounded by
specifying the hw address in /etc/network/interfaces, or set using ifconfig on
the
command line, but it turned out to be a real problem on ubuntu core:

1) upon boot, with no MAC address assigned, the wcn36xx assigns itself the
dummy address "00:00:00:00:00" and that prevents the network interface from
working at all, until a valid address is set

2) the ubuntu core installer doesn't have any knowledge about this behaviour,
it simply tries to bring up the interface and on failure, it marks it as
'not working'

On top of that, ubuntu core ships a small script in initramfs, that generates
the
/lib/firmware/wlan/macaddr0 file starting from the android boot serial,
effectively generating a unique MAC address per board: clearly, without driver
support, this ubuntu core feature doesn't work.

Fix:

Import back the MAC generation mechanism from Xenial: the pseudo random
generation and the parsing of /lib/firmware/wlan/macaddr0 - see the attached
patch.

How to test:

Unpon boot, if no /lib/firmware/wlan/macaddr0 is present, the kernel will print:

[ 10.612701] wcn36xx a204000.wcnss:smd-edge:wcnss:wifi: Direct firmware load for
wlan/macaddr0 failed with error -2
[ 10.612713] wcn36xx a204000.wcnss:smd-edge:wcnss:wifi: Failed (-2) to read
macaddressfile wlan/macaddr0, using a random address instead

ubuntu@dragon410c:~$ ifconfig wlan0
wlan0: flags=4098<BROADCAST,MULTICAST> mtu 1500
        ether 00:0a:f5:d5:54:d7 txqueuelen 1000 (Ethernet)
        RX packets 0 bytes 0 (0.0 B)
        RX errors 0 dropped 0 overruns 0 frame 0
        TX packets 0 bytes 0 (0.0 B)
        TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

else, if /lib/firmware/wlan/macaddr0 is present, its content will be used to
generate wlan0 MAC address:

ubuntu@dragon410c:~$ cat /lib/firmware/wlan/macaddr0
fe:1a:19:77:d9:88

ubuntu@dragon410c:~$ ifconfig wlan0
wlan0: flags=4098<BROADCAST,MULTICAST> mtu 1500
        ether fe:1a:19:77:d9:88 txqueuelen 1000 (Ethernet)
        RX packets 0 bytes 0 (0.0 B)
        RX errors 0 dropped 0 overruns 0 frame 0
        TX packets 0 bytes 0 (0.0 B)
        TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Regression potential:

Low - the patch is small and the code is wrapped in a Kconfig option
(WCN36XX_SNAPDRAGON_HACKS) that only affects the linux-snapdragon flavour,
leaving the generic kernel untouched.


Paolo Pisati (2):
  UBUNTU: SAUCE: wcn36xx: read MAC from file or randomly generate one
  UBUNTU: [Config] arm64: snapdragon: WCN36XX_SNAPDRAGON_HACKS=y

 debian.master/config/amd64/config.common.amd64     |  1 +
 debian.master/config/arm64/config.flavour.generic  |  1 +
 .../config/arm64/config.flavour.snapdragon         |  1 +
 debian.master/config/armhf/config.common.armhf     |  1 +
 debian.master/config/i386/config.common.i386       |  1 +
 debian.master/config/ppc64el/config.common.ppc64el |  1 +
 drivers/net/wireless/ath/wcn36xx/Kconfig           |  9 +++++
 drivers/net/wireless/ath/wcn36xx/main.c            | 38 +++++++++++++++++++++-
 8 files changed, 52 insertions(+), 1 deletion(-)

Comments

Stefan Bader June 15, 2018, 3:07 p.m. UTC | #1
On 14.06.2018 12:08, Paolo Pisati wrote:
> BugLink: http://bugs.launchpad.net/bugs/1776491
> 
> Impact:
> 
> The wcn36xx driver in Xenial/linux-snapdragon had an ability to autogenerate its
> MAC address upon boot, or read it from a file (/lib/firmware/wlan/macaddr0). The
> linux-snapdragon kernel in Bionic doesn't have this feature.
> 
> While by itself not a bug (Xenial used a QCOM provided custom driver, while
> Bionic uses the upstream wcn36xx driver), it can be easily work-arounded by
> specifying the hw address in /etc/network/interfaces, or set using ifconfig on
> the
> command line, but it turned out to be a real problem on ubuntu core:
> 
> 1) upon boot, with no MAC address assigned, the wcn36xx assigns itself the
> dummy address "00:00:00:00:00" and that prevents the network interface from
> working at all, until a valid address is set
> 
> 2) the ubuntu core installer doesn't have any knowledge about this behaviour,
> it simply tries to bring up the interface and on failure, it marks it as
> 'not working'
> 
> On top of that, ubuntu core ships a small script in initramfs, that generates
> the
> /lib/firmware/wlan/macaddr0 file starting from the android boot serial,
> effectively generating a unique MAC address per board: clearly, without driver
> support, this ubuntu core feature doesn't work.
> 
> Fix:
> 
> Import back the MAC generation mechanism from Xenial: the pseudo random
> generation and the parsing of /lib/firmware/wlan/macaddr0 - see the attached
> patch.
> 
> How to test:
> 
> Unpon boot, if no /lib/firmware/wlan/macaddr0 is present, the kernel will print:
> 
> [ 10.612701] wcn36xx a204000.wcnss:smd-edge:wcnss:wifi: Direct firmware load for
> wlan/macaddr0 failed with error -2
> [ 10.612713] wcn36xx a204000.wcnss:smd-edge:wcnss:wifi: Failed (-2) to read
> macaddressfile wlan/macaddr0, using a random address instead
> 
> ubuntu@dragon410c:~$ ifconfig wlan0
> wlan0: flags=4098<BROADCAST,MULTICAST> mtu 1500
>         ether 00:0a:f5:d5:54:d7 txqueuelen 1000 (Ethernet)
>         RX packets 0 bytes 0 (0.0 B)
>         RX errors 0 dropped 0 overruns 0 frame 0
>         TX packets 0 bytes 0 (0.0 B)
>         TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
> 
> else, if /lib/firmware/wlan/macaddr0 is present, its content will be used to
> generate wlan0 MAC address:
> 
> ubuntu@dragon410c:~$ cat /lib/firmware/wlan/macaddr0
> fe:1a:19:77:d9:88
> 
> ubuntu@dragon410c:~$ ifconfig wlan0
> wlan0: flags=4098<BROADCAST,MULTICAST> mtu 1500
>         ether fe:1a:19:77:d9:88 txqueuelen 1000 (Ethernet)
>         RX packets 0 bytes 0 (0.0 B)
>         RX errors 0 dropped 0 overruns 0 frame 0
>         TX packets 0 bytes 0 (0.0 B)
>         TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
> 
> Regression potential:
> 
> Low - the patch is small and the code is wrapped in a Kconfig option
> (WCN36XX_SNAPDRAGON_HACKS) that only affects the linux-snapdragon flavour,
> leaving the generic kernel untouched.
> 
> 
> Paolo Pisati (2):
>   UBUNTU: SAUCE: wcn36xx: read MAC from file or randomly generate one
>   UBUNTU: [Config] arm64: snapdragon: WCN36XX_SNAPDRAGON_HACKS=y
> 
>  debian.master/config/amd64/config.common.amd64     |  1 +
>  debian.master/config/arm64/config.flavour.generic  |  1 +
>  .../config/arm64/config.flavour.snapdragon         |  1 +
>  debian.master/config/armhf/config.common.armhf     |  1 +
>  debian.master/config/i386/config.common.i386       |  1 +
>  debian.master/config/ppc64el/config.common.ppc64el |  1 +
>  drivers/net/wireless/ath/wcn36xx/Kconfig           |  9 +++++
>  drivers/net/wireless/ath/wcn36xx/main.c            | 38 +++++++++++++++++++++-
>  8 files changed, 52 insertions(+), 1 deletion(-)
> 
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Khalid Elmously June 17, 2018, 6:18 a.m. UTC | #2
On 2018-06-14 12:08:55 , Paolo Pisati wrote:
> BugLink: http://bugs.launchpad.net/bugs/1776491
> 
> Impact:
> 
> The wcn36xx driver in Xenial/linux-snapdragon had an ability to autogenerate its
> MAC address upon boot, or read it from a file (/lib/firmware/wlan/macaddr0). The
> linux-snapdragon kernel in Bionic doesn't have this feature.
> 
> While by itself not a bug (Xenial used a QCOM provided custom driver, while
> Bionic uses the upstream wcn36xx driver), it can be easily work-arounded by
> specifying the hw address in /etc/network/interfaces, or set using ifconfig on
> the
> command line, but it turned out to be a real problem on ubuntu core:
> 
> 1) upon boot, with no MAC address assigned, the wcn36xx assigns itself the
> dummy address "00:00:00:00:00" and that prevents the network interface from
> working at all, until a valid address is set
> 
> 2) the ubuntu core installer doesn't have any knowledge about this behaviour,
> it simply tries to bring up the interface and on failure, it marks it as
> 'not working'
> 
> On top of that, ubuntu core ships a small script in initramfs, that generates
> the
> /lib/firmware/wlan/macaddr0 file starting from the android boot serial,
> effectively generating a unique MAC address per board: clearly, without driver
> support, this ubuntu core feature doesn't work.
> 
> Fix:
> 
> Import back the MAC generation mechanism from Xenial: the pseudo random
> generation and the parsing of /lib/firmware/wlan/macaddr0 - see the attached
> patch.
> 
> How to test:
> 
> Unpon boot, if no /lib/firmware/wlan/macaddr0 is present, the kernel will print:
> 
> [ 10.612701] wcn36xx a204000.wcnss:smd-edge:wcnss:wifi: Direct firmware load for
> wlan/macaddr0 failed with error -2
> [ 10.612713] wcn36xx a204000.wcnss:smd-edge:wcnss:wifi: Failed (-2) to read
> macaddressfile wlan/macaddr0, using a random address instead
> 
> ubuntu@dragon410c:~$ ifconfig wlan0
> wlan0: flags=4098<BROADCAST,MULTICAST> mtu 1500
>         ether 00:0a:f5:d5:54:d7 txqueuelen 1000 (Ethernet)
>         RX packets 0 bytes 0 (0.0 B)
>         RX errors 0 dropped 0 overruns 0 frame 0
>         TX packets 0 bytes 0 (0.0 B)
>         TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
> 
> else, if /lib/firmware/wlan/macaddr0 is present, its content will be used to
> generate wlan0 MAC address:
> 
> ubuntu@dragon410c:~$ cat /lib/firmware/wlan/macaddr0
> fe:1a:19:77:d9:88
> 
> ubuntu@dragon410c:~$ ifconfig wlan0
> wlan0: flags=4098<BROADCAST,MULTICAST> mtu 1500
>         ether fe:1a:19:77:d9:88 txqueuelen 1000 (Ethernet)
>         RX packets 0 bytes 0 (0.0 B)
>         RX errors 0 dropped 0 overruns 0 frame 0
>         TX packets 0 bytes 0 (0.0 B)
>         TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
> 
> Regression potential:
> 
> Low - the patch is small and the code is wrapped in a Kconfig option
> (WCN36XX_SNAPDRAGON_HACKS) that only affects the linux-snapdragon flavour,
> leaving the generic kernel untouched.
> 
> 
> Paolo Pisati (2):
>   UBUNTU: SAUCE: wcn36xx: read MAC from file or randomly generate one
>   UBUNTU: [Config] arm64: snapdragon: WCN36XX_SNAPDRAGON_HACKS=y
> 
>  debian.master/config/amd64/config.common.amd64     |  1 +
>  debian.master/config/arm64/config.flavour.generic  |  1 +
>  .../config/arm64/config.flavour.snapdragon         |  1 +
>  debian.master/config/armhf/config.common.armhf     |  1 +
>  debian.master/config/i386/config.common.i386       |  1 +
>  debian.master/config/ppc64el/config.common.ppc64el |  1 +
>  drivers/net/wireless/ath/wcn36xx/Kconfig           |  9 +++++
>  drivers/net/wireless/ath/wcn36xx/main.c            | 38 +++++++++++++++++++++-
>  8 files changed, 52 insertions(+), 1 deletion(-)
> 
Acked-by: Khalid Elmously <khalid.elmously@canonical.com>
Khalid Elmously June 19, 2018, 6:06 a.m. UTC | #3
Applied to Bionic

On 2018-06-14 12:08:55 , Paolo Pisati wrote:
Thadeu Lima de Souza Cascardo June 26, 2018, 3:54 p.m. UTC | #4
Applied to unstable master branch.

Thanks.
Cascardo.

Applied-to: unstable/master