Commit 2b76acdb authored by Hante Meuleman's avatar Hante Meuleman Committed by Kalle Valo

brcmfmac: Rework p2p attach, use single method for p2p dev creation.

When module param p2pon is used a p2p device is created at init.
This patch reworks how this is done by using the same method as
for a dynamically (by user space) created p2p device.
Reviewed-by: default avatarArend Van Spriel <arend@broadcom.com>
Reviewed-by: default avatarPieter-Paul Giesberts <pieterpg@broadcom.com>
Reviewed-by: default avatarFranky (Zhenhui) Lin <frankyl@broadcom.com>
Signed-off-by: default avatarHante Meuleman <meuleman@broadcom.com>
Signed-off-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 43569bfa
...@@ -6238,6 +6238,17 @@ struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr, ...@@ -6238,6 +6238,17 @@ struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr,
else else
*cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; *cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
} }
/* p2p might require that "if-events" get processed by fweh. So
* activate the already registered event handlers now and activate
* the rest when initialization has completed. drvr->config needs to
* be assigned before activating events.
*/
drvr->config = cfg;
err = brcmf_fweh_activate_events(ifp);
if (err) {
brcmf_err("FWEH activation failed (%d)\n", err);
goto wiphy_unreg_out;
}
err = brcmf_p2p_attach(cfg, p2pdev_forced); err = brcmf_p2p_attach(cfg, p2pdev_forced);
if (err) { if (err) {
...@@ -6260,6 +6271,13 @@ struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr, ...@@ -6260,6 +6271,13 @@ struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr,
brcmf_notify_tdls_peer_event); brcmf_notify_tdls_peer_event);
} }
/* (re-) activate FWEH event handling */
err = brcmf_fweh_activate_events(ifp);
if (err) {
brcmf_err("FWEH activation failed (%d)\n", err);
goto wiphy_unreg_out;
}
return cfg; return cfg;
wiphy_unreg_out: wiphy_unreg_out:
......
...@@ -828,8 +828,8 @@ struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, s32 bssidx, s32 ifidx, ...@@ -828,8 +828,8 @@ struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, s32 bssidx, s32 ifidx,
} else { } else {
brcmf_dbg(INFO, "allocate netdev interface\n"); brcmf_dbg(INFO, "allocate netdev interface\n");
/* Allocate netdev, including space for private structure */ /* Allocate netdev, including space for private structure */
ndev = alloc_netdev(sizeof(*ifp), name, NET_NAME_UNKNOWN, ndev = alloc_netdev(sizeof(*ifp), is_p2pdev ? "p2p%d" : name,
ether_setup); NET_NAME_UNKNOWN, ether_setup);
if (!ndev) if (!ndev)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -1021,11 +1021,6 @@ int brcmf_bus_start(struct device *dev) ...@@ -1021,11 +1021,6 @@ int brcmf_bus_start(struct device *dev)
if (IS_ERR(ifp)) if (IS_ERR(ifp))
return PTR_ERR(ifp); return PTR_ERR(ifp);
if (brcmf_p2p_enable)
p2p_ifp = brcmf_add_if(drvr, 1, 0, false, "p2p%d", NULL);
else
p2p_ifp = NULL;
if (IS_ERR(p2p_ifp))
p2p_ifp = NULL; p2p_ifp = NULL;
/* signal bus ready */ /* signal bus ready */
...@@ -1060,11 +1055,13 @@ int brcmf_bus_start(struct device *dev) ...@@ -1060,11 +1055,13 @@ int brcmf_bus_start(struct device *dev)
goto fail; goto fail;
} }
ret = brcmf_fweh_activate_events(ifp);
if (ret < 0)
goto fail;
ret = brcmf_net_attach(ifp, false); ret = brcmf_net_attach(ifp, false);
if ((!ret) && (brcmf_p2p_enable)) {
p2p_ifp = drvr->iflist[1];
if (p2p_ifp)
ret = brcmf_net_p2p_attach(p2p_ifp);
}
fail: fail:
if (ret < 0) { if (ret < 0) {
brcmf_err("failed: %d\n", ret); brcmf_err("failed: %d\n", ret);
...@@ -1076,20 +1073,12 @@ int brcmf_bus_start(struct device *dev) ...@@ -1076,20 +1073,12 @@ int brcmf_bus_start(struct device *dev)
brcmf_fws_del_interface(ifp); brcmf_fws_del_interface(ifp);
brcmf_fws_deinit(drvr); brcmf_fws_deinit(drvr);
} }
if (drvr->iflist[0]) { if (ifp)
brcmf_net_detach(ifp->ndev); brcmf_net_detach(ifp->ndev);
drvr->iflist[0] = NULL; if (p2p_ifp)
}
if (p2p_ifp) {
brcmf_net_detach(p2p_ifp->ndev); brcmf_net_detach(p2p_ifp->ndev);
drvr->iflist[1] = NULL;
}
return ret; return ret;
} }
if ((brcmf_p2p_enable) && (p2p_ifp))
if (brcmf_net_p2p_attach(p2p_ifp) < 0)
brcmf_p2p_enable = 0;
return 0; return 0;
} }
......
...@@ -213,6 +213,7 @@ static void brcmf_fweh_handle_if_event(struct brcmf_pub *drvr, ...@@ -213,6 +213,7 @@ static void brcmf_fweh_handle_if_event(struct brcmf_pub *drvr,
is_p2pdev, emsg->ifname, emsg->addr); is_p2pdev, emsg->ifname, emsg->addr);
if (IS_ERR(ifp)) if (IS_ERR(ifp))
return; return;
if (!is_p2pdev)
brcmf_fws_add_interface(ifp); brcmf_fws_add_interface(ifp);
if (!drvr->fweh.evt_handler[BRCMF_E_IF]) if (!drvr->fweh.evt_handler[BRCMF_E_IF])
if (brcmf_net_attach(ifp, false) < 0) if (brcmf_net_attach(ifp, false) < 0)
......
...@@ -2353,83 +2353,30 @@ void brcmf_p2p_stop_device(struct wiphy *wiphy, struct wireless_dev *wdev) ...@@ -2353,83 +2353,30 @@ void brcmf_p2p_stop_device(struct wiphy *wiphy, struct wireless_dev *wdev)
* brcmf_p2p_attach() - attach for P2P. * brcmf_p2p_attach() - attach for P2P.
* *
* @cfg: driver private data for cfg80211 interface. * @cfg: driver private data for cfg80211 interface.
* @p2pdev_forced: create p2p device interface at attach.
*/ */
s32 brcmf_p2p_attach(struct brcmf_cfg80211_info *cfg, bool p2pdev_forced) s32 brcmf_p2p_attach(struct brcmf_cfg80211_info *cfg, bool p2pdev_forced)
{ {
struct brcmf_if *pri_ifp;
struct brcmf_if *p2p_ifp;
struct brcmf_cfg80211_vif *p2p_vif;
struct brcmf_p2p_info *p2p; struct brcmf_p2p_info *p2p;
struct brcmf_pub *drvr; struct brcmf_if *pri_ifp;
s32 bssidx;
s32 err = 0; s32 err = 0;
void *err_ptr;
p2p = &cfg->p2p; p2p = &cfg->p2p;
p2p->cfg = cfg; p2p->cfg = cfg;
drvr = cfg->pub; pri_ifp = brcmf_get_ifp(cfg->pub, 0);
pri_ifp = brcmf_get_ifp(drvr, 0);
p2p->bss_idx[P2PAPI_BSSCFG_PRIMARY].vif = pri_ifp->vif; p2p->bss_idx[P2PAPI_BSSCFG_PRIMARY].vif = pri_ifp->vif;
if (p2pdev_forced) { if (p2pdev_forced) {
p2p_ifp = drvr->iflist[1]; err_ptr = brcmf_p2p_create_p2pdev(p2p, NULL, NULL);
if (IS_ERR(err_ptr)) {
brcmf_err("P2P device creation failed.\n");
err = PTR_ERR(err_ptr);
}
} else { } else {
p2p_ifp = NULL;
p2p->p2pdev_dynamically = true; p2p->p2pdev_dynamically = true;
} }
if (p2p_ifp) {
p2p_vif = brcmf_alloc_vif(cfg, NL80211_IFTYPE_P2P_DEVICE,
false);
if (IS_ERR(p2p_vif)) {
brcmf_err("could not create discovery vif\n");
err = -ENOMEM;
goto exit;
}
p2p_vif->ifp = p2p_ifp;
p2p_ifp->vif = p2p_vif;
p2p_vif->wdev.netdev = p2p_ifp->ndev;
p2p_ifp->ndev->ieee80211_ptr = &p2p_vif->wdev;
SET_NETDEV_DEV(p2p_ifp->ndev, wiphy_dev(cfg->wiphy));
p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif = p2p_vif;
brcmf_p2p_generate_bss_mac(p2p, NULL);
memcpy(p2p_ifp->mac_addr, p2p->dev_addr, ETH_ALEN);
brcmf_p2p_set_firmware(pri_ifp, p2p->dev_addr);
brcmf_fweh_p2pdev_setup(pri_ifp, true);
/* Initialize P2P Discovery in the firmware */
err = brcmf_fil_iovar_int_set(pri_ifp, "p2p_disc", 1);
if (err < 0) {
brcmf_err("set p2p_disc error\n");
brcmf_free_vif(p2p_vif);
goto exit;
}
/* obtain bsscfg index for P2P discovery */
err = brcmf_fil_iovar_int_get(pri_ifp, "p2p_dev", &bssidx);
if (err < 0) {
brcmf_err("retrieving discover bsscfg index failed\n");
brcmf_free_vif(p2p_vif);
goto exit;
}
/* Verify that firmware uses same bssidx as driver !! */
if (p2p_ifp->bssidx != bssidx) {
brcmf_err("Incorrect bssidx=%d, compared to p2p_ifp->bssidx=%d\n",
bssidx, p2p_ifp->bssidx);
brcmf_free_vif(p2p_vif);
goto exit;
}
init_completion(&p2p->send_af_done);
INIT_WORK(&p2p->afx_hdl.afx_work, brcmf_p2p_afx_handler);
init_completion(&p2p->afx_hdl.act_frm_scan);
init_completion(&p2p->wait_next_af);
exit:
brcmf_fweh_p2pdev_setup(pri_ifp, false);
}
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment