Commit 1ec7291e authored by Johannes Berg's avatar Johannes Berg
Browse files

wifi: mac80211: add helpers to access sband iftype data



There's quite a bit of code accessing sband iftype data
(HE, HE 6 GHz, EHT) and we always need to remember to use
the ieee80211_vif_type_p2p() helper. Add new helpers to
directly get it from the sband/vif rather than having to
call ieee80211_vif_type_p2p().

Convert most code with the following spatch:

    @@
    expression vif, sband;
    @@
    -ieee80211_get_he_iftype_cap(sband, ieee80211_vif_type_p2p(vif))
    +ieee80211_get_he_iftype_cap_vif(sband, vif)

    @@
    expression vif, sband;
    @@
    -ieee80211_get_eht_iftype_cap(sband, ieee80211_vif_type_p2p(vif))
    +ieee80211_get_eht_iftype_cap_vif(sband, vif)

    @@
    expression vif, sband;
    @@
    -ieee80211_get_he_6ghz_capa(sband, ieee80211_vif_type_p2p(vif))
    +ieee80211_get_he_6ghz_capa_vif(sband, vif)

Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarGregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230604120651.db099f49e764.Ie892966c49e22c7b7ee1073bc684f142debfdc84@changeid


Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 2ad66fcb
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -2269,8 +2269,7 @@ bool iwl_mvm_is_nic_ack_enabled(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
	 * so take it from one of them.
	 */
	sband = mvm->hw->wiphy->bands[NL80211_BAND_2GHZ];
	own_he_cap = ieee80211_get_he_iftype_cap(sband,
						 ieee80211_vif_type_p2p(vif));
	own_he_cap = ieee80211_get_he_iftype_cap_vif(sband, vif);

	return (own_he_cap && (own_he_cap->he_cap_elem.mac_cap_info[2] &
			       IEEE80211_HE_MAC_CAP2_ACK_EN));
@@ -3452,8 +3451,7 @@ static void iwl_mvm_reset_cca_40mhz_workaround(struct iwl_mvm *mvm,

	sband->ht_cap.cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;

	he_cap = ieee80211_get_he_iftype_cap(sband,
					     ieee80211_vif_type_p2p(vif));
	he_cap = ieee80211_get_he_iftype_cap_vif(sband, vif);

	if (he_cap) {
		/* we know that ours is writable */
+2 −3
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
/*
 * Copyright (C) 2012-2014, 2018-2020 Intel Corporation
 * Copyright (C) 2012-2014, 2018-2023 Intel Corporation
 * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
 * Copyright (C) 2016-2017 Intel Deutschland GmbH
 */
@@ -192,8 +192,7 @@ static void iwl_mvm_rx_monitor_notif(struct iwl_mvm *mvm,
	WARN_ON(!(sband->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40));
	sband->ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;

	he_cap = ieee80211_get_he_iftype_cap(sband,
					     ieee80211_vif_type_p2p(vif));
	he_cap = ieee80211_get_he_iftype_cap_vif(sband, vif);

	if (he_cap) {
		/* we know that ours is writable */
+2 −3
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
/*
 * Copyright (C) 2017 Intel Deutschland GmbH
 * Copyright (C) 2018-2022 Intel Corporation
 * Copyright (C) 2018-2023 Intel Corporation
 */
#include "rs.h"
#include "fw-api.h"
@@ -94,8 +94,7 @@ static u16 rs_fw_get_config_flags(struct iwl_mvm *mvm,
	    IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD))
		flags |= IWL_TLC_MNG_CFG_FLAGS_LDPC_MSK;

	sband_he_cap = ieee80211_get_he_iftype_cap(sband,
						   ieee80211_vif_type_p2p(vif));
	sband_he_cap = ieee80211_get_he_iftype_cap_vif(sband, vif);
	if (sband_he_cap &&
	    !(sband_he_cap->he_cap_elem.phy_cap_info[1] &
			IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD))
+43 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
 * Copyright 2007-2010	Johannes Berg <johannes@sipsolutions.net>
 * Copyright 2013-2014  Intel Mobile Communications GmbH
 * Copyright (C) 2015 - 2017 Intel Deutschland GmbH
 * Copyright (C) 2018 - 2022 Intel Corporation
 * Copyright (C) 2018 - 2023 Intel Corporation
 */

#ifndef MAC80211_H
@@ -6866,6 +6866,48 @@ ieee80211_vif_type_p2p(struct ieee80211_vif *vif)
	return ieee80211_iftype_p2p(vif->type, vif->p2p);
}

/**
 * ieee80211_get_he_iftype_cap_vif - return HE capabilities for sband/vif
 * @sband: the sband to search for the iftype on
 * @vif: the vif to get the iftype from
 *
 * Return: pointer to the struct ieee80211_sta_he_cap, or %NULL is none found
 */
static inline const struct ieee80211_sta_he_cap *
ieee80211_get_he_iftype_cap_vif(const struct ieee80211_supported_band *sband,
				struct ieee80211_vif *vif)
{
	return ieee80211_get_he_iftype_cap(sband, ieee80211_vif_type_p2p(vif));
}

/**
 * ieee80211_get_he_6ghz_capa_vif - return HE 6 GHz capabilities
 * @sband: the sband to search for the STA on
 * @vif: the vif to get the iftype from
 *
 * Return: the 6GHz capabilities
 */
static inline __le16
ieee80211_get_he_6ghz_capa_vif(const struct ieee80211_supported_band *sband,
			       struct ieee80211_vif *vif)
{
	return ieee80211_get_he_6ghz_capa(sband, ieee80211_vif_type_p2p(vif));
}

/**
 * ieee80211_get_eht_iftype_cap_vif - return ETH capabilities for sband/vif
 * @sband: the sband to search for the iftype on
 * @vif: the vif to get the iftype from
 *
 * Return: pointer to the struct ieee80211_sta_eht_cap, or %NULL is none found
 */
static inline const struct ieee80211_sta_eht_cap *
ieee80211_get_eht_iftype_cap_vif(const struct ieee80211_supported_band *sband,
				 struct ieee80211_vif *vif)
{
	return ieee80211_get_eht_iftype_cap(sband, ieee80211_vif_type_p2p(vif));
}

/**
 * ieee80211_update_mu_groups - set the VHT MU-MIMO groud data
 *
+2 −3
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
/*
 * EHT handling
 *
 * Copyright(c) 2021-2022 Intel Corporation
 * Copyright(c) 2021-2023 Intel Corporation
 */

#include "ieee80211_i.h"
@@ -25,8 +25,7 @@ ieee80211_eht_cap_ie_to_sta_eht_cap(struct ieee80211_sub_if_data *sdata,
	memset(eht_cap, 0, sizeof(*eht_cap));

	if (!eht_cap_ie_elem ||
	    !ieee80211_get_eht_iftype_cap(sband,
					 ieee80211_vif_type_p2p(&sdata->vif)))
	    !ieee80211_get_eht_iftype_cap_vif(sband, &sdata->vif))
		return;

	mcs_nss_size = ieee80211_eht_mcs_nss_size(he_cap_ie_elem,
Loading