mac80211: add brcmfmac patch fixing user space picked MACs
[openwrt/staging/lynxis/omap.git] / package / kernel / mac80211 / patches / 863-brcmfmac-set-wiphy-s-addresses-to-provide-valid-MACs.patch
1 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
2 Date: Thu, 9 Jul 2015 16:53:30 +0200
3 Subject: [PATCH] brcmfmac: set wiphy's addresses to provide valid MACs
4 MIME-Version: 1.0
5 Content-Type: text/plain; charset=UTF-8
6 Content-Transfer-Encoding: 8bit
7
8 Broadcom's firmware requires every BSS to use MAC address with unique
9 last few bits. The amount of bits may depend on a particular firmware,
10 it was verified to be 2 for BCM43602 one.
11 If this condition won't be fulfilled firmware will reject such MAC:
12 brcmfmac: _brcmf_set_mac_address: Setting cur_etheraddr failed, -52
13
14 We don't want to simply set addr_mask as it would also disallow using
15 locally administrated bit. Instead let's build a list of addresses
16 manually enabling 0x2 bit for extra interfaces.
17
18 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
19 ---
20
21 --- a/drivers/net/wireless/brcm80211/brcmfmac/cfg80211.c
22 +++ b/drivers/net/wireless/brcm80211/brcmfmac/cfg80211.c
23 @@ -5813,6 +5813,7 @@ static void brcmf_wiphy_wowl_params(struct wiphy *wiphy)
24
25 static int brcmf_setup_wiphy(struct wiphy *wiphy, struct brcmf_if *ifp)
26 {
27 + struct brcmf_pub *drvr = ifp->drvr;
28 struct ieee80211_supported_band *band;
29 __le32 bandlist[3];
30 u32 n_bands;
31 @@ -5826,6 +5827,19 @@ static int brcmf_setup_wiphy(struct wiphy *wiphy, struct brcmf_if *ifp)
32 if (err)
33 return err;
34
35 + for (i = 0; i < wiphy->iface_combinations->max_interfaces &&
36 + i < ARRAY_SIZE(drvr->addresses); i++) {
37 + u8 *addr = drvr->addresses[i].addr;
38 +
39 + memcpy(addr, drvr->mac, ETH_ALEN);
40 + if (i) {
41 + addr[0] |= BIT(1);
42 + addr[ETH_ALEN - 1] ^= i;
43 + }
44 + }
45 + wiphy->addresses = drvr->addresses;
46 + wiphy->n_addresses = i;
47 +
48 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
49 wiphy->cipher_suites = __wl_cipher_suites;
50 wiphy->n_cipher_suites = ARRAY_SIZE(__wl_cipher_suites);
51 --- a/drivers/net/wireless/brcm80211/brcmfmac/core.h
52 +++ b/drivers/net/wireless/brcm80211/brcmfmac/core.h
53 @@ -21,6 +21,7 @@
54 #ifndef BRCMFMAC_CORE_H
55 #define BRCMFMAC_CORE_H
56
57 +#include <net/cfg80211.h>
58 #include "fweh.h"
59
60 #define TOE_TX_CSUM_OL 0x00000001
61 @@ -118,6 +119,8 @@ struct brcmf_pub {
62 /* Multicast data packets sent to dongle */
63 unsigned long tx_multicast;
64
65 + struct mac_address addresses[BRCMF_MAX_IFS];
66 +
67 struct brcmf_if *iflist[BRCMF_MAX_IFS];
68
69 struct mutex proto_block;