Commit a8ec12d4 authored by Jérôme Pouiller's avatar Jérôme Pouiller Committed by Greg Kroah-Hartman
Browse files

staging: wfx: simplify hif_set_association_mode()



The structure hif_mib_set_association_mode come from hardware API. It is
not intended to be manipulated in upper layers of the driver.

In add, current code for hif_set_association_mode() is too dumb. It
should pack data with hardware representation instead of leaving all
work to the caller.

Signed-off-by: default avatarJérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20200115135338.14374-31-Jerome.Pouiller@silabs.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9ced9b59
Loading
Loading
Loading
Loading
+20 −2
Original line number Diff line number Diff line
@@ -191,10 +191,28 @@ static inline int hif_set_block_ack_policy(struct wfx_vif *wvif,
}

static inline int hif_set_association_mode(struct wfx_vif *wvif,
					   struct hif_mib_set_association_mode *arg)
					   struct ieee80211_bss_conf *info,
					   struct ieee80211_sta_ht_cap *ht_cap)
{
	int basic_rates = wfx_rate_mask_to_hw(wvif->wdev, info->basic_rates);
	struct hif_mib_set_association_mode val = {
		.preambtype_use = 1,
		.mode = 1,
		.rateset = 1,
		.spacing = 1,
		.short_preamble = info->use_short_preamble,
		.basic_rate_set = cpu_to_le32(basic_rates)
	};

	// FIXME: it is strange to not retrieve all information from bss_info
	if (ht_cap && ht_cap->ht_supported) {
		val.mpdu_start_spacing = ht_cap->ampdu_density;
		if (!(info->ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT))
			val.greenfield = !!(ht_cap->cap & IEEE80211_HT_CAP_GRN_FLD);
	}

	return hif_write_mib(wvif->wdev, wvif->id,
			     HIF_MIB_ID_SET_ASSOCIATION_MODE, arg, sizeof(*arg));
			     HIF_MIB_ID_SET_ASSOCIATION_MODE, &val, sizeof(val));
}

static inline int hif_set_tx_rate_retry_policy(struct wfx_vif *wvif,
+1 −15
Original line number Diff line number Diff line
@@ -712,7 +712,6 @@ static void wfx_join_finalize(struct wfx_vif *wvif,
			      struct ieee80211_bss_conf *info)
{
	struct ieee80211_sta *sta = NULL;
	struct hif_mib_set_association_mode association_mode = { };

	wvif->beacon_int = info->beacon_int;
	rcu_read_lock();
@@ -730,26 +729,13 @@ static void wfx_join_finalize(struct wfx_vif *wvif,
	else
		hif_dual_cts_protection(wvif, false);

	association_mode.preambtype_use = 1;
	association_mode.mode = 1;
	association_mode.rateset = 1;
	association_mode.spacing = 1;
	association_mode.short_preamble = info->use_short_preamble;
	association_mode.basic_rate_set = cpu_to_le32(wfx_rate_mask_to_hw(wvif->wdev, info->basic_rates));
	if (sta && sta->ht_cap.ht_supported &&
	    !(info->ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT))
		association_mode.greenfield =
			!!(sta->ht_cap.cap & IEEE80211_HT_CAP_GRN_FLD);
	if (sta && sta->ht_cap.ht_supported)
		association_mode.mpdu_start_spacing = sta->ht_cap.ampdu_density;

	wfx_cqm_bssloss_sm(wvif, 0, 0, 0);
	cancel_work_sync(&wvif->unjoin_work);

	wvif->bss_params.beacon_lost_count = 20;
	wvif->bss_params.aid = info->aid;

	hif_set_association_mode(wvif, &association_mode);
	hif_set_association_mode(wvif, info, sta ? &sta->ht_cap : NULL);

	if (!info->ibss_joined) {
		hif_keep_alive_period(wvif, 30 /* sec */);