323-brcmfmac-correct-detection-of-p2pdev-interface-event.patch 3.9 KB

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