Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 426d0a56 authored by Hante Meuleman's avatar Hante Meuleman Committed by John W. Linville
Browse files

brcmfmac: Use role from wdev on AP commands and fix stop_ap.



Use the stored role in wdev struct to determine AP/GO role. This
simplifies code. Fix stop_ap for GO role.

Reviewed-by: default avatarArend Van Spriel <arend@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 avatarJohn W. Linville <linville@tuxdriver.com>
parent 2fde59d9
Loading
Loading
Loading
Loading
+14 −37
Original line number Diff line number Diff line
@@ -3655,7 +3655,6 @@ static s32
brcmf_cfg80211_start_ap(struct wiphy *wiphy, struct net_device *ndev,
			struct cfg80211_ap_settings *settings)
{
	struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
	s32 ie_offset;
	struct brcmf_if *ifp = netdev_priv(ndev);
	struct brcmf_tlv *ssid_ie;
@@ -3675,22 +3674,7 @@ brcmf_cfg80211_start_ap(struct wiphy *wiphy, struct net_device *ndev,
		  settings->ssid, settings->ssid_len, settings->auth_type,
		  settings->inactivity_timeout);

	if (ifp->vif == cfg->p2p.bss_idx[P2PAPI_BSSCFG_PRIMARY].vif) {
		brcmf_dbg(TRACE, "Role = AP\n");
		dev_role = NL80211_IFTYPE_AP;
		if (!test_bit(BRCMF_VIF_STATUS_AP_CREATING,
			      &ifp->vif->sme_state)) {
			brcmf_err("Not in AP creation mode\n");
			return -EPERM;
		}
	} else {
		brcmf_dbg(TRACE, "Role = P2P GO\n");
		dev_role = NL80211_IFTYPE_P2P_GO;
		if (ifp->vif == cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif) {
			ifp = cfg->p2p.bss_idx[P2PAPI_BSSCFG_PRIMARY].vif->ifp;
			ndev = ifp->ndev;
		}
	}
	dev_role = ifp->vif->wdev.iftype;

	memset(&ssid_le, 0, sizeof(ssid_le));
	if (settings->ssid == NULL || settings->ssid_len == 0) {
@@ -3826,10 +3810,11 @@ static int brcmf_cfg80211_stop_ap(struct wiphy *wiphy, struct net_device *ndev)
{
	struct brcmf_if *ifp = netdev_priv(ndev);
	s32 err = -EPERM;
	struct brcmf_fil_bss_enable_le bss_enable;

	brcmf_dbg(TRACE, "Enter\n");

	if (ifp->vif->mode == WL_MODE_AP) {
	if (ifp->vif->wdev.iftype == NL80211_IFTYPE_AP) {
		/* Due to most likely deauths outstanding we sleep */
		/* first to make sure they get processed by fw. */
		msleep(400);
@@ -3843,10 +3828,18 @@ static int brcmf_cfg80211_stop_ap(struct wiphy *wiphy, struct net_device *ndev)
			brcmf_err("BRCMF_C_UP error %d\n", err);
			goto exit;
		}
	} else {
		bss_enable.bsscfg_idx = cpu_to_le32(ifp->bssidx);
		bss_enable.enable = cpu_to_le32(0);
		err = brcmf_fil_iovar_data_set(ifp, "bss", &bss_enable,
					       sizeof(bss_enable));
		if (err < 0)
			brcmf_err("bss_enable config failed %d\n", err);
	}
	brcmf_set_mpc(ndev, 1);
		clear_bit(BRCMF_VIF_STATUS_AP_CREATING, &ifp->vif->sme_state);
	set_bit(BRCMF_VIF_STATUS_AP_CREATING, &ifp->vif->sme_state);
	clear_bit(BRCMF_VIF_STATUS_AP_CREATED, &ifp->vif->sme_state);
	}

exit:
	return err;
}
@@ -3855,27 +3848,11 @@ static s32
brcmf_cfg80211_change_beacon(struct wiphy *wiphy, struct net_device *ndev,
			     struct cfg80211_beacon_data *info)
{
	struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
	struct brcmf_if *ifp = netdev_priv(ndev);
	s32 err;

	brcmf_dbg(TRACE, "Enter\n");

	if (ifp->vif == cfg->p2p.bss_idx[P2PAPI_BSSCFG_PRIMARY].vif) {
		brcmf_dbg(TRACE, "Role = AP\n");
		if (!test_bit(BRCMF_VIF_STATUS_AP_CREATED,
			      &ifp->vif->sme_state)) {
			brcmf_err("AP was not yet created\n");
			return -EPERM;
		}
	} else {
		brcmf_dbg(TRACE, "Role = P2P GO\n");
		if (ifp->vif == cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif) {
			ifp = cfg->p2p.bss_idx[P2PAPI_BSSCFG_PRIMARY].vif->ifp;
			ndev = ifp->ndev;
		}
	}

	err = brcmf_config_ap_mgmt_ie(ifp->vif, info);

	return err;