Commit c1944370 authored by Ping-Ke Shih's avatar Ping-Ke Shih Committed by Kalle Valo
Browse files

wifi: rtw89: adjust init_he_cap() to add EHT cap into iftype_data



EHT capabilities are also stored in struct ieee80211_sband_iftype_data, so
adjust allocation of iftype_data as common part named init_he_eht_cap(),
and then init_eht_cap() can be added later. Don't change logic at all
by this patch.

Signed-off-by: default avatarPing-Ke Shih <pkshih@realtek.com>
Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240112062640.36922-2-pkshih@realtek.com
parent 23b83301
Loading
Loading
Loading
Loading
+113 −103
Original line number Diff line number Diff line
@@ -3649,25 +3649,21 @@ static void rtw89_init_vht_cap(struct rtw89_dev *rtwdev,
	vht_cap->vht_mcs.tx_highest = highest[hal->tx_nss - 1];
}

#define RTW89_SBAND_IFTYPES_NR 2

static void rtw89_init_he_cap(struct rtw89_dev *rtwdev,
			      enum nl80211_band band,
			      struct ieee80211_supported_band *sband)
			      enum nl80211_iftype iftype,
			      struct ieee80211_sband_iftype_data *iftype_data)
{
	const struct rtw89_chip_info *chip = rtwdev->chip;
	struct rtw89_hal *hal = &rtwdev->hal;
	struct ieee80211_sband_iftype_data *iftype_data;
	bool no_ng16 = (chip->chip_id == RTL8852A && hal->cv == CHIP_CBV) ||
		       (chip->chip_id == RTL8852B && hal->cv == CHIP_CAV);
	struct ieee80211_sta_he_cap *he_cap;
	int nss = hal->rx_nss;
	u8 *mac_cap_info;
	u8 *phy_cap_info;
	u16 mcs_map = 0;
	int i;
	int nss = hal->rx_nss;
	int idx = 0;

	iftype_data = kcalloc(RTW89_SBAND_IFTYPES_NR, sizeof(*iftype_data), GFP_KERNEL);
	if (!iftype_data)
		return;

	for (i = 0; i < 8; i++) {
		if (i < nss)
@@ -3676,41 +3672,22 @@ static void rtw89_init_he_cap(struct rtw89_dev *rtwdev,
			mcs_map |= IEEE80211_HE_MCS_NOT_SUPPORTED << (i * 2);
	}

	for (i = 0; i < NUM_NL80211_IFTYPES; i++) {
		struct ieee80211_sta_he_cap *he_cap;
		u8 *mac_cap_info;
		u8 *phy_cap_info;

		switch (i) {
		case NL80211_IFTYPE_STATION:
		case NL80211_IFTYPE_AP:
			break;
		default:
			continue;
		}

		if (idx >= RTW89_SBAND_IFTYPES_NR) {
			rtw89_warn(rtwdev, "run out of iftype_data\n");
			break;
		}

		iftype_data[idx].types_mask = BIT(i);
		he_cap = &iftype_data[idx].he_cap;
	he_cap = &iftype_data->he_cap;
	mac_cap_info = he_cap->he_cap_elem.mac_cap_info;
	phy_cap_info = he_cap->he_cap_elem.phy_cap_info;

	he_cap->has_he = true;
	mac_cap_info[0] = IEEE80211_HE_MAC_CAP0_HTC_HE;
		if (i == NL80211_IFTYPE_STATION)
	if (iftype == NL80211_IFTYPE_STATION)
		mac_cap_info[1] = IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_16US;
	mac_cap_info[2] = IEEE80211_HE_MAC_CAP2_ALL_ACK |
			  IEEE80211_HE_MAC_CAP2_BSR;
	mac_cap_info[3] = IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_EXT_2;
		if (i == NL80211_IFTYPE_AP)
	if (iftype == NL80211_IFTYPE_AP)
		mac_cap_info[3] |= IEEE80211_HE_MAC_CAP3_OMI_CONTROL;
	mac_cap_info[4] = IEEE80211_HE_MAC_CAP4_OPS |
			  IEEE80211_HE_MAC_CAP4_AMSDU_IN_AMPDU;
		if (i == NL80211_IFTYPE_STATION)
	if (iftype == NL80211_IFTYPE_STATION)
		mac_cap_info[5] = IEEE80211_HE_MAC_CAP5_HT_VHT_TRIG_FRAME_RX;
	if (band == NL80211_BAND_2GHZ) {
		phy_cap_info[0] =
@@ -3729,10 +3706,10 @@ static void rtw89_init_he_cap(struct rtw89_dev *rtwdev,
			  IEEE80211_HE_PHY_CAP2_STBC_RX_UNDER_80MHZ |
			  IEEE80211_HE_PHY_CAP2_DOPPLER_TX;
	phy_cap_info[3] = IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_16_QAM;
		if (i == NL80211_IFTYPE_STATION)
	if (iftype == NL80211_IFTYPE_STATION)
		phy_cap_info[3] |= IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_16_QAM |
				   IEEE80211_HE_PHY_CAP3_DCM_MAX_TX_NSS_2;
		if (i == NL80211_IFTYPE_AP)
	if (iftype == NL80211_IFTYPE_AP)
		phy_cap_info[3] |= IEEE80211_HE_PHY_CAP3_RX_PARTIAL_BW_SU_IN_20MHZ_MU;
	phy_cap_info[4] = IEEE80211_HE_PHY_CAP4_SU_BEAMFORMEE |
			  IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_4;
@@ -3760,7 +3737,7 @@ static void rtw89_init_he_cap(struct rtw89_dev *rtwdev,
			  IEEE80211_HE_PHY_CAP9_RX_FULL_BW_SU_USING_MU_WITH_NON_COMP_SIGB |
			  u8_encode_bits(IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_16US,
					 IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_MASK);
		if (i == NL80211_IFTYPE_STATION)
	if (iftype == NL80211_IFTYPE_STATION)
		phy_cap_info[9] |= IEEE80211_HE_PHY_CAP9_TX_1024_QAM_LESS_THAN_242_TONE_RU;
	he_cap->he_mcs_nss_supp.rx_mcs_80 = cpu_to_le16(mcs_map);
	he_cap->he_mcs_nss_supp.tx_mcs_80 = cpu_to_le16(mcs_map);
@@ -3778,9 +3755,42 @@ static void rtw89_init_he_cap(struct rtw89_dev *rtwdev,
					IEEE80211_HE_6GHZ_CAP_MAX_AMPDU_LEN_EXP) |
		       le16_encode_bits(IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454,
					IEEE80211_HE_6GHZ_CAP_MAX_MPDU_LEN);
			iftype_data[idx].he_6ghz_capa.capa = capa;
		iftype_data->he_6ghz_capa.capa = capa;
	}
}

#define RTW89_SBAND_IFTYPES_NR 2

static void rtw89_init_he_eht_cap(struct rtw89_dev *rtwdev,
				  enum nl80211_band band,
				  struct ieee80211_supported_band *sband)
{
	struct ieee80211_sband_iftype_data *iftype_data;
	enum nl80211_iftype iftype;
	int idx = 0;

	iftype_data = kcalloc(RTW89_SBAND_IFTYPES_NR, sizeof(*iftype_data), GFP_KERNEL);
	if (!iftype_data)
		return;

	for (iftype = 0; iftype < NUM_NL80211_IFTYPES; iftype++) {
		switch (iftype) {
		case NL80211_IFTYPE_STATION:
		case NL80211_IFTYPE_AP:
			break;
		default:
			continue;
		}

		if (idx >= RTW89_SBAND_IFTYPES_NR) {
			rtw89_warn(rtwdev, "run out of iftype_data\n");
			break;
		}

		iftype_data[idx].types_mask = BIT(iftype);

		rtw89_init_he_cap(rtwdev, band, iftype, &iftype_data[idx]);

		idx++;
	}

@@ -3800,7 +3810,7 @@ static int rtw89_core_set_supported_band(struct rtw89_dev *rtwdev)
		if (!sband_2ghz)
			goto err;
		rtw89_init_ht_cap(rtwdev, &sband_2ghz->ht_cap);
		rtw89_init_he_cap(rtwdev, NL80211_BAND_2GHZ, sband_2ghz);
		rtw89_init_he_eht_cap(rtwdev, NL80211_BAND_2GHZ, sband_2ghz);
		hw->wiphy->bands[NL80211_BAND_2GHZ] = sband_2ghz;
	}

@@ -3810,7 +3820,7 @@ static int rtw89_core_set_supported_band(struct rtw89_dev *rtwdev)
			goto err;
		rtw89_init_ht_cap(rtwdev, &sband_5ghz->ht_cap);
		rtw89_init_vht_cap(rtwdev, &sband_5ghz->vht_cap);
		rtw89_init_he_cap(rtwdev, NL80211_BAND_5GHZ, sband_5ghz);
		rtw89_init_he_eht_cap(rtwdev, NL80211_BAND_5GHZ, sband_5ghz);
		hw->wiphy->bands[NL80211_BAND_5GHZ] = sband_5ghz;
	}

@@ -3818,7 +3828,7 @@ static int rtw89_core_set_supported_band(struct rtw89_dev *rtwdev)
		sband_6ghz = kmemdup(&rtw89_sband_6ghz, size, GFP_KERNEL);
		if (!sband_6ghz)
			goto err;
		rtw89_init_he_cap(rtwdev, NL80211_BAND_6GHZ, sband_6ghz);
		rtw89_init_he_eht_cap(rtwdev, NL80211_BAND_6GHZ, sband_6ghz);
		hw->wiphy->bands[NL80211_BAND_6GHZ] = sband_6ghz;
	}