1 From: Arend van Spriel <arend@broadcom.com>
2 Date: Wed, 26 Aug 2015 22:14:57 +0200
3 Subject: [PATCH] brcmfmac: correct detection of p2pdev interface event
5 The p2pdev interface is setup in firmware resulting in a interface
6 event. This event has role and no-if flag. When role is p2p client
7 and no-if flag is set it indicates that this is the p2pdev interface.
8 This info is used in handling the event and adding interface in the
11 Reviewed-by: Hante Meuleman <meuleman@broadcom.com>
12 Reviewed-by: Franky (Zhenhui) Lin <frankyl@broadcom.com>
13 Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
14 Signed-off-by: Arend van Spriel <arend@broadcom.com>
17 --- a/drivers/net/wireless/brcm80211/brcmfmac/core.c
18 +++ b/drivers/net/wireless/brcm80211/brcmfmac/core.c
19 @@ -795,7 +795,7 @@ fail:
22 struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, s32 bssidx, s32 ifidx,
23 - char *name, u8 *mac_addr)
24 + bool is_p2pdev, char *name, u8 *mac_addr)
27 struct net_device *ndev;
28 @@ -821,7 +821,7 @@ struct brcmf_if *brcmf_add_if(struct brc
32 - if (!brcmf_p2p_enable && bssidx == 1) {
33 + if (!brcmf_p2p_enable && is_p2pdev) {
34 /* this is P2P_DEVICE interface */
35 brcmf_dbg(INFO, "allocate non-netdev interface\n");
36 ifp = kzalloc(sizeof(*ifp), GFP_KERNEL);
37 @@ -999,12 +999,12 @@ int brcmf_bus_start(struct device *dev)
38 brcmf_dbg(TRACE, "\n");
40 /* add primary networking interface */
41 - ifp = brcmf_add_if(drvr, 0, 0, "wlan%d", NULL);
42 + ifp = brcmf_add_if(drvr, 0, 0, false, "wlan%d", NULL);
47 - p2p_ifp = brcmf_add_if(drvr, 1, 0, "p2p%d", NULL);
48 + p2p_ifp = brcmf_add_if(drvr, 1, 0, false, "p2p%d", NULL);
52 --- a/drivers/net/wireless/brcm80211/brcmfmac/core.h
53 +++ b/drivers/net/wireless/brcm80211/brcmfmac/core.h
54 @@ -205,7 +205,7 @@ char *brcmf_ifname(struct brcmf_pub *drv
55 struct brcmf_if *brcmf_get_ifp(struct brcmf_pub *drvr, int ifidx);
56 int brcmf_net_attach(struct brcmf_if *ifp, bool rtnl_locked);
57 struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, s32 bssidx, s32 ifidx,
58 - char *name, u8 *mac_addr);
59 + bool is_p2pdev, char *name, u8 *mac_addr);
60 void brcmf_remove_interface(struct brcmf_if *ifp);
61 int brcmf_get_next_free_bsscfgidx(struct brcmf_pub *drvr);
62 void brcmf_txflowblock_if(struct brcmf_if *ifp,
63 --- a/drivers/net/wireless/brcm80211/brcmfmac/fweh.c
64 +++ b/drivers/net/wireless/brcm80211/brcmfmac/fweh.c
65 @@ -179,6 +179,7 @@ static void brcmf_fweh_handle_if_event(s
67 struct brcmf_if_event *ifevent = data;
72 brcmf_dbg(EVENT, "action: %u idx: %u bsscfg: %u flags: %u role: %u\n",
73 @@ -186,18 +187,16 @@ static void brcmf_fweh_handle_if_event(s
74 ifevent->flags, ifevent->role);
76 /* The P2P Device interface event must not be ignored
77 - * contrary to what firmware tells us. The only way to
78 - * distinguish the P2P Device is by looking at the ifidx
79 - * and bssidx received.
80 + * contrary to what firmware tells us.
82 - if (!(ifevent->ifidx == 0 && ifevent->bssidx == 1) &&
83 - (ifevent->flags & BRCMF_E_IF_FLAG_NOIF)) {
84 + is_p2pdev = (ifevent->flags & BRCMF_E_IF_FLAG_NOIF) &&
85 + ifevent->role == BRCMF_E_IF_ROLE_P2P_CLIENT;
86 + if (!is_p2pdev && (ifevent->flags & BRCMF_E_IF_FLAG_NOIF)) {
87 brcmf_dbg(EVENT, "event can be ignored\n");
90 if (ifevent->ifidx >= BRCMF_MAX_IFS) {
91 - brcmf_err("invalid interface index: %u\n",
93 + brcmf_err("invalid interface index: %u\n", ifevent->ifidx);
97 @@ -207,7 +206,7 @@ static void brcmf_fweh_handle_if_event(s
98 brcmf_dbg(EVENT, "adding %s (%pM)\n", emsg->ifname,
100 ifp = brcmf_add_if(drvr, ifevent->bssidx, ifevent->ifidx,
101 - emsg->ifname, emsg->addr);
102 + is_p2pdev, emsg->ifname, emsg->addr);
105 brcmf_fws_add_interface(ifp);