319-v4.12-0022-brcmfmac-add-support-to-move-wiphy-instance-into-net.patch 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. From 0cc0236cf713a9ecfcf902e35bd098bc179265a8 Mon Sep 17 00:00:00 2001
  2. From: Arend Van Spriel <arend.vanspriel@broadcom.com>
  3. Date: Tue, 28 Mar 2017 11:43:26 +0100
  4. Subject: [PATCH] brcmfmac: add support to move wiphy instance into network
  5. namespace
  6. To support network namespace the driver must assure all created
  7. network interfaces are in the same namespace as the wiphy instance
  8. and flag the support using WIPHY_FLAG_NETNS_OK.
  9. Verified using two terminals:
  10. Terminal 1 Terminal 2
  11. -------------------------- ---------------------------------
  12. # ip netns add brcm-wifi # iw dev
  13. phy#0
  14. Interface wlan3
  15. ifindex 11
  16. wdev 0x1
  17. # ip netns exec brcm-wifi bash
  18. # iw dev
  19. # echo $$
  20. 20337 # iw phy0 set netns 20337
  21. # iw dev
  22. phy#0
  23. Interface wlan3
  24. ifindex 11
  25. wdev 0x2
  26. # iw phy0 interface add wl3.ap type __ap
  27. # iw dev
  28. phy#0
  29. Interface wl3.ap
  30. ifindex 2
  31. wdev 0x3
  32. Interface wlan3
  33. ifindex 11
  34. wdev 0x2
  35. # iw dev
  36. # iw phy0 set netns 1
  37. # iw dev
  38. # iw dev
  39. phy#0
  40. Interface wl3.ap
  41. ifindex 2
  42. wdev 0x5
  43. Interface wlan3
  44. ifindex 11
  45. wdev 0x4
  46. Note:
  47. increasing wdev identifier above indicates issue in
  48. cfg80211 which is addressed separately.
  49. Tested-by: Mark Asselstine <mark.asselstine@windriver.com>
  50. Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
  51. Reviewed-by: Franky Lin <franky.lin@broadcom.com>
  52. Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
  53. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  54. ---
  55. drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 3 ++-
  56. drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c | 3 ++-
  57. 2 files changed, 4 insertions(+), 2 deletions(-)
  58. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
  59. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
  60. @@ -6453,7 +6453,8 @@ static int brcmf_setup_wiphy(struct wiph
  61. BIT(NL80211_BSS_SELECT_ATTR_BAND_PREF) |
  62. BIT(NL80211_BSS_SELECT_ATTR_RSSI_ADJUST);
  63. - wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT |
  64. + wiphy->flags |= WIPHY_FLAG_NETNS_OK |
  65. + WIPHY_FLAG_PS_ON_BY_DEFAULT |
  66. WIPHY_FLAG_OFFCHAN_TX |
  67. WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
  68. if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_TDLS))
  69. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
  70. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
  71. @@ -485,8 +485,9 @@ int brcmf_net_attach(struct brcmf_if *if
  72. ndev->needed_headroom += drvr->hdrlen;
  73. ndev->ethtool_ops = &brcmf_ethtool_ops;
  74. - /* set the mac address */
  75. + /* set the mac address & netns */
  76. memcpy(ndev->dev_addr, ifp->mac_addr, ETH_ALEN);
  77. + dev_net_set(ndev, wiphy_net(cfg_to_wiphy(drvr->config)));
  78. INIT_WORK(&ifp->multicast_work, _brcmf_set_multicast_list);
  79. INIT_WORK(&ifp->ndoffload_work, _brcmf_update_ndtable);