326-brcmfmac-add-mapping-for-interface-index-to-bsscfg-i.patch 2.9 KB

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