mac80211: add pending brcmfmac patches fixing multiple interfaces
[openwrt.git] / package / kernel / mac80211 / patches / 326-brcmfmac-add-mapping-for-interface-index-to-bsscfg-i.patch
1 From: Arend van Spriel <arend@broadcom.com>
2 Date: Wed, 26 Aug 2015 22:15:00 +0200
3 Subject: [PATCH] brcmfmac: add mapping for interface index to bsscfg
4  index
5
6 Because the P2P Device interface in firmware uses the same interface
7 index as the primary interface we use the bsscfg index as index in the
8 struct brcmf_pub::iflist. However, in the data path we get the interface
9 index and not the bsscfg index. So we need a mapping of interface index
10 to bsscfg index, which can be determined upon handle adding the interface.
11
12 Reviewed-by: Hante Meuleman <meuleman@broadcom.com>
13 Reviewed-by: Franky (Zhenhui) Lin <frankyl@broadcom.com>
14 Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
15 Signed-off-by: Arend van Spriel <arend@broadcom.com>
16 ---
17
18 --- a/drivers/net/wireless/brcm80211/brcmfmac/core.c
19 +++ b/drivers/net/wireless/brcm80211/brcmfmac/core.c
20 @@ -85,21 +85,20 @@ char *brcmf_ifname(struct brcmf_pub *drv
21  
22  struct brcmf_if *brcmf_get_ifp(struct brcmf_pub *drvr, int ifidx)
23  {
24 +       struct brcmf_if *ifp;
25 +       s32 bssidx;
26 +
27         if (ifidx < 0 || ifidx >= BRCMF_MAX_IFS) {
28                 brcmf_err("ifidx %d out of range\n", ifidx);
29                 return NULL;
30         }
31  
32 -       /* The ifidx is the idx to map to matching netdev/ifp. When receiving
33 -        * events this is easy because it contains the bssidx which maps
34 -        * 1-on-1 to the netdev/ifp. But for data frames the ifidx is rcvd.
35 -        * bssidx 1 is used for p2p0 and no data can be received or
36 -        * transmitted on it. Therefor bssidx is ifidx + 1 if ifidx > 0
37 -        */
38 -       if (ifidx)
39 -               ifidx++;
40 +       ifp = NULL;
41 +       bssidx = drvr->if2bss[ifidx];
42 +       if (bssidx >= 0)
43 +               ifp = drvr->iflist[bssidx];
44  
45 -       return drvr->iflist[ifidx];
46 +       return ifp;
47  }
48  
49  static void _brcmf_set_multicast_list(struct work_struct *work)
50 @@ -831,6 +830,8 @@ struct brcmf_if *brcmf_add_if(struct brc
51  
52                 ifp = netdev_priv(ndev);
53                 ifp->ndev = ndev;
54 +               /* store mapping ifidx to bssidx */
55 +               drvr->if2bss[ifidx] = bssidx;
56         }
57  
58         ifp->drvr = drvr;
59 @@ -855,6 +856,7 @@ static void brcmf_del_if(struct brcmf_pu
60         struct brcmf_if *ifp;
61  
62         ifp = drvr->iflist[bssidx];
63 +       drvr->if2bss[ifp->ifidx] = -1;
64         drvr->iflist[bssidx] = NULL;
65         if (!ifp) {
66                 brcmf_err("Null interface, idx=%d\n", bssidx);
67 @@ -862,6 +864,7 @@ static void brcmf_del_if(struct brcmf_pu
68         }
69         brcmf_dbg(TRACE, "Enter, idx=%d, ifidx=%d\n", bssidx, ifp->ifidx);
70         if (ifp->ndev) {
71 +               drvr->if2bss[ifp->ifidx] = -1;
72                 if (bssidx == 0) {
73                         if (ifp->ndev->netdev_ops == &brcmf_netdev_ops_pri) {
74                                 rtnl_lock();
75 @@ -926,6 +929,7 @@ int brcmf_attach(struct device *dev)
76         if (!drvr)
77                 return -ENOMEM;
78  
79 +       memset(drvr->if2bss, 0xFF, sizeof(drvr->if2bss));
80         mutex_init(&drvr->proto_block);
81  
82         /* Link to bus module */
83 --- a/drivers/net/wireless/brcm80211/brcmfmac/core.h
84 +++ b/drivers/net/wireless/brcm80211/brcmfmac/core.h
85 @@ -122,6 +122,7 @@ struct brcmf_pub {
86         struct mac_address addresses[BRCMF_MAX_IFS];
87  
88         struct brcmf_if *iflist[BRCMF_MAX_IFS];
89 +       s32 if2bss[BRCMF_MAX_IFS];
90  
91         struct mutex proto_block;
92         unsigned char proto_buf[BRCMF_DCMD_MAXLEN];