Procházet zdrojové kódy

qcacmn: ratetable changes for 11BE

modify dp_getmodulation and dp_getrateindex to pass puncturing mode
update DP_RATE_TABLE_SIZE to support 11BE

Change-Id: I7f59b29c18d882b541dca0477c7ed6c8cff4da59
CRs-Fixed: 3098366
aloksing před 3 roky
rodič
revize
2491f91f55

+ 203 - 6
dp/cmn_dp_api/dp_ratetable.c

@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 2016-2019, 2021 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2019, 2022 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -66,6 +67,9 @@ enum DP_CMN_RATECODE_PREAM_TYPE {
 	DP_CMN_RATECODE_PREAM_HT,
 	DP_CMN_RATECODE_PREAM_VHT,
 	DP_CMN_RATECODE_PREAM_HE,
+#ifdef WLAN_FEATURE_11BE
+	DP_CMN_RATECODE_PREAM_EHT,
+#endif
 	DP_CMN_RATECODE_PREAM_COUNT,
 };
 
@@ -3368,18 +3372,68 @@ static const uint16_t _rc_idx[DP_CMN_MOD_IEEE80211_T_MAX_PHY] = {
 	HE_40_RATE_TABLE_INDEX,
 	HE_80_RATE_TABLE_INDEX,
 	HE_160_RATE_TABLE_INDEX,
+#ifdef WLAN_FEATURE_11BE
+	EHT_20_RATE_TABLE_INDEX,
+	EHT_40_RATE_TABLE_INDEX,
+	EHT_60_RATE_TABLE_INDEX,
+	EHT_80_RATE_TABLE_INDEX,
+	EHT_120_RATE_TABLE_INDEX,
+	EHT_140_RATE_TABLE_INDEX,
+	EHT_160_RATE_TABLE_INDEX,
+	EHT_200_RATE_TABLE_INDEX,
+	EHT_240_RATE_TABLE_INDEX,
+	EHT_280_RATE_TABLE_INDEX,
+	EHT_320_RATE_TABLE_INDEX,
+#endif
 };
 
+#ifdef WLAN_FEATURE_11BE
+static inline
+enum BW_TYPES_FP dp_get_bw_fp_from_full_bw_pmode(uint8_t bw,
+						 uint8_t punc_mode)
+{
+	CMN_DP_ASSERT(punc_mode < PUNCTURED_MODE_CNT);
+
+	switch (bw) {
+	case CMN_BW_80MHZ:
+		if (punc_mode == PUNCTURED_20MHZ)
+			return BW_60MHZ_P;
+		else
+			return BW_80MHZ_F;
+	case CMN_BW_160MHZ:
+		if (punc_mode == PUNCTURED_40MHZ)
+			return BW_120MHZ_P;
+		else if (punc_mode == PUNCTURED_20MHZ)
+			return BW_140MHZ_P;
+		else
+			return BW_160MHZ_F;
+	case CMN_BW_320MHZ:
+		if (punc_mode == PUNCTURED_120MHZ)
+			return BW_200MHZ_P;
+		else if (punc_mode == PUNCTURED_80MHZ)
+			return BW_240MHZ_P;
+		else if (punc_mode == PUNCTURED_40MHZ)
+			return BW_280MHZ_P;
+		else
+			return BW_320MHZ_F;
+	default:
+		return (enum BW_TYPES_FP)bw;
+	}
+}
+#endif
+
 /*
  * dp_getmodulation - return rate modulation given code spatial width
  * @pream_type - preamble type
  * @width - bandwidth
+ * @punc_mode - punctered bandwidth
  *
  * return - modulation type
  */
-enum DP_CMN_MODULATION_TYPE dp_getmodulation(
-		uint16_t pream_type,
-		uint8_t width)
+#ifdef WLAN_FEATURE_11BE
+enum DP_CMN_MODULATION_TYPE dp_getmodulation(uint16_t pream_type,
+					     uint8_t width,
+					     uint8_t punc_mode)
 {
 	static const enum DP_CMN_MODULATION_TYPE _vht_bw_mod[] = {
 		DP_CMN_MOD_IEEE80211_T_VHT_20,
@@ -3395,6 +3449,20 @@ enum DP_CMN_MODULATION_TYPE dp_getmodulation(
 		DP_CMN_MOD_IEEE80211_T_HE_160
 	};
 
+	static const enum DP_CMN_MODULATION_TYPE _eht_bw_mod[] = {
+		DP_CMN_MOD_IEEE80211_T_EHT_20,
+		DP_CMN_MOD_IEEE80211_T_EHT_40,
+		DP_CMN_MOD_IEEE80211_T_EHT_60,
+		DP_CMN_MOD_IEEE80211_T_EHT_80,
+		DP_CMN_MOD_IEEE80211_T_EHT_120,
+		DP_CMN_MOD_IEEE80211_T_EHT_140,
+		DP_CMN_MOD_IEEE80211_T_EHT_160,
+		DP_CMN_MOD_IEEE80211_T_EHT_200,
+		DP_CMN_MOD_IEEE80211_T_EHT_240,
+		DP_CMN_MOD_IEEE80211_T_EHT_280,
+		DP_CMN_MOD_IEEE80211_T_EHT_320,
+	};
+
 	enum DP_CMN_MODULATION_TYPE modulation;
 
 	CMN_DP_ASSERT(width < CMN_BW_CNT);
@@ -3419,13 +3487,71 @@ enum DP_CMN_MODULATION_TYPE dp_getmodulation(
 		modulation = _he_bw_mod[width];
 		break;
 
+	case DP_CMN_RATECODE_PREAM_EHT:
+		{
+			enum BW_TYPES_FP bw_fp =
+				dp_get_bw_fp_from_full_bw_pmode(width,
+								punc_mode);
+			modulation = _eht_bw_mod[bw_fp];
+			break;
+		}
+
 	default:
 		modulation = DP_CMN_MOD_IEEE80211_T_OFDM;
+	}
+
+	return modulation;
+}
+#else
+enum DP_CMN_MODULATION_TYPE dp_getmodulation(uint16_t pream_type,
+					     uint8_t width,
+					     uint8_t punc_mode)
+{
+	static const enum DP_CMN_MODULATION_TYPE _vht_bw_mod[] = {
+		DP_CMN_MOD_IEEE80211_T_VHT_20,
+		DP_CMN_MOD_IEEE80211_T_VHT_40,
+		DP_CMN_MOD_IEEE80211_T_VHT_80,
+		DP_CMN_MOD_IEEE80211_T_VHT_160
+	};
+
+	static const enum DP_CMN_MODULATION_TYPE _he_bw_mod[] = {
+		DP_CMN_MOD_IEEE80211_T_HE_20,
+		DP_CMN_MOD_IEEE80211_T_HE_40,
+		DP_CMN_MOD_IEEE80211_T_HE_80,
+		DP_CMN_MOD_IEEE80211_T_HE_160
+	};
+
+	enum DP_CMN_MODULATION_TYPE modulation;
+
+	CMN_DP_ASSERT(width < CMN_BW_CNT);
+
+	switch (pream_type) {
+	case DP_CMN_RATECODE_PREAM_HT:
+		if (width)
+			modulation = DP_CMN_MOD_IEEE80211_T_HT_40;
+		else
+			modulation = DP_CMN_MOD_IEEE80211_T_HT_20;
+		break;
+
+	case DP_CMN_RATECODE_PREAM_CCK:
+		modulation = DP_CMN_MOD_IEEE80211_T_CCK;
+		break;
+
+	case DP_CMN_RATECODE_PREAM_VHT:
+		modulation = _vht_bw_mod[width];
+		break;
+
+	case DP_CMN_RATECODE_PREAM_HE:
+		modulation = _he_bw_mod[width];
 		break;
+
+	default:
+		modulation = DP_CMN_MOD_IEEE80211_T_OFDM;
 	}
 
 	return modulation;
 }
+#endif /* WLAN_FEATURE_11BE */
 
 /* dp_getrateindex - calculate ratekbps
  * @mcs - MCS index
@@ -3437,9 +3563,10 @@ enum DP_CMN_MODULATION_TYPE dp_getmodulation(
  *
  * return - rate in kbps
  */
+#ifdef WLAN_FEATURE_11BE
 uint32_t
 dp_getrateindex(uint32_t gi, uint16_t mcs, uint8_t nss, uint8_t preamble,
-		uint8_t bw, uint32_t *rix, uint16_t *ratecode)
+		uint8_t bw, uint8_t punc_bw, uint32_t *rix, uint16_t *ratecode)
 {
 	uint32_t ratekbps = 0, res = RT_INVALID_INDEX; /* represents failure */
 	uint16_t rc;
@@ -3447,13 +3574,17 @@ dp_getrateindex(uint32_t gi, uint16_t mcs, uint8_t nss, uint8_t preamble,
 
 	/* For error case, where idx exceeds bountry limit */
 	*ratecode = 0;
-	mod = dp_getmodulation(preamble, bw);
+	mod = dp_getmodulation(preamble, bw, punc_bw);
 	rc = mcs;
 
 	/* get the base of corresponding rate table  entry */
 	res = _rc_idx[mod];
 
 	switch (preamble) {
+	case DP_CMN_RATECODE_PREAM_EHT:
+		res += ((rc + 2) % NUM_EHT_MCS) + nss * NUM_EHT_MCS;
+		break;
+
 	case DP_CMN_RATECODE_PREAM_HE:
 		res += rc + nss * NUM_HE_MCS;
 		break;
@@ -3502,7 +3633,73 @@ done:
 
 	return ratekbps;
 }
+#else
+uint32_t
+dp_getrateindex(uint32_t gi, uint16_t mcs, uint8_t nss, uint8_t preamble,
+		uint8_t bw, uint8_t punc_bw, uint32_t *rix, uint16_t *ratecode)
+{
+	uint32_t ratekbps = 0, res = RT_INVALID_INDEX; /* represents failure */
+	uint16_t rc;
+	enum DP_CMN_MODULATION_TYPE mod;
+
+	/* For error case, where idx exceeds bountry limit */
+	*ratecode = 0;
+	mod = dp_getmodulation(preamble, bw, punc_bw);
+	rc = mcs;
+
+	/* get the base of corresponding rate table  entry */
+	res = _rc_idx[mod];
+
+	switch (preamble) {
+	case DP_CMN_RATECODE_PREAM_HE:
+		res += rc + nss * NUM_HE_MCS;
+		break;
+
+	case DP_CMN_RATECODE_PREAM_VHT:
+		res += rc + nss * NUM_VHT_MCS;
+		break;
+
+	case DP_CMN_RATECODE_PREAM_HT:
+		res += rc + nss * NUM_HT_MCS;
+		break;
+
+	case DP_CMN_RATECODE_PREAM_CCK:
+		rc  &= ~HW_RATECODE_CCK_SHORT_PREAM_MASK;
+		res += rc;
+		break;
 
+	case DP_CMN_RATECODE_PREAM_OFDM:
+		res += rc;
+		break;
+
+	default:
+		break;
+	}
+	if (res >= DP_RATE_TABLE_SIZE)
+		goto done;
+
+	if (!gi) {
+		ratekbps = dp_11abgnratetable.info[res].userratekbps;
+	} else {
+		switch (gi) {
+		case CDP_SGI_0_4_US:
+			ratekbps = dp_11abgnratetable.info[res].ratekbpssgi;
+			break;
+		case CDP_SGI_1_6_US:
+			ratekbps = dp_11abgnratetable.info[res].ratekbpsdgi;
+			break;
+		case CDP_SGI_3_2_US:
+			ratekbps = dp_11abgnratetable.info[res].ratekbpsqgi;
+			break;
+		}
+	}
+	*ratecode = dp_11abgnratetable.info[res].ratecode;
+done:
+	*rix = res;
+
+	return ratekbps;
+}
+#endif
 qdf_export_symbol(dp_getrateindex);
 
 /* dp_rate_idx_to_kbps - get rate kbps from index

+ 81 - 6
dp/cmn_dp_api/dp_ratetable.h

@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
- * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021,2022 Qualcomm Innovation Center, Inc. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -54,6 +54,10 @@ enum CMN_MODE_TYPES {
 	CMN_IEEE80211_MODE_AXA,
 	CMN_IEEE80211_MODE_AXG,
 	CMN_IEEE80211_MODE_AX,
+#ifdef WLAN_FEATURE_11BE
+	CMN_IEEE80211_MODE_BEA,
+	CMN_IEEE80211_MODE_BEG,
+#endif
 	CMN_IEEE80211_MODE_MAX
 };
 
@@ -65,6 +69,9 @@ enum CMN_MODE_TYPES {
 #define NUM_VHT_MCS 12
 
 #define NUM_HE_MCS 14
+#ifdef WLAN_FEATURE_11BE
+#define NUM_EHT_MCS 16
+#endif
 
 #define NUM_SPATIAL_STREAM 4
 #define NUM_SPATIAL_STREAMS 8
@@ -152,7 +159,30 @@ static inline int dp_ath_rate_out(uint64_t _i)
 #define HE_80_RATE_TABLE_INDEX (HE_40_RATE_TABLE_INDEX + NUM_HE_RIX_PER_BW)
 
 #define HE_160_RATE_TABLE_INDEX (HE_80_RATE_TABLE_INDEX + NUM_HE_RIX_PER_BW)
-#define DP_RATE_TABLE_SIZE (HE_160_RATE_TABLE_INDEX + NUM_HE_RIX_FOR_160MHZ)
+#define HE_LAST_RIX_PLUS_ONE (HE_160_RATE_TABLE_INDEX + NUM_HE_RIX_FOR_160MHZ)
+
+#ifdef WLAN_FEATURE_11BE
+#define NUM_EHT_RIX_PER_BW (NUM_EHT_MCS * NUM_SPATIAL_STREAMS)
+
+#define EHT_20_RATE_TABLE_INDEX HE_LAST_RIX_PLUS_ONE
+#define EHT_40_RATE_TABLE_INDEX (EHT_20_RATE_TABLE_INDEX + NUM_EHT_RIX_PER_BW)
+#define EHT_60_RATE_TABLE_INDEX (EHT_40_RATE_TABLE_INDEX + NUM_EHT_RIX_PER_BW)
+#define EHT_80_RATE_TABLE_INDEX (EHT_60_RATE_TABLE_INDEX + NUM_EHT_RIX_PER_BW)
+#define EHT_120_RATE_TABLE_INDEX (EHT_80_RATE_TABLE_INDEX + NUM_EHT_RIX_PER_BW)
+#define EHT_140_RATE_TABLE_INDEX (EHT_120_RATE_TABLE_INDEX + NUM_EHT_RIX_PER_BW)
+#define EHT_160_RATE_TABLE_INDEX (EHT_140_RATE_TABLE_INDEX + NUM_EHT_RIX_PER_BW)
+#define EHT_200_RATE_TABLE_INDEX (EHT_160_RATE_TABLE_INDEX + NUM_EHT_RIX_PER_BW)
+#define EHT_240_RATE_TABLE_INDEX (EHT_200_RATE_TABLE_INDEX + NUM_EHT_RIX_PER_BW)
+#define EHT_280_RATE_TABLE_INDEX (EHT_240_RATE_TABLE_INDEX + NUM_EHT_RIX_PER_BW)
+#define EHT_320_RATE_TABLE_INDEX (EHT_280_RATE_TABLE_INDEX + NUM_EHT_RIX_PER_BW)
+#define EHT_LAST_RIX_PLUS_ONE (EHT_320_RATE_TABLE_INDEX + NUM_EHT_RIX_PER_BW)
+#endif
+
+#ifdef WLAN_FEATURE_11BE
+#define DP_RATE_TABLE_SIZE EHT_LAST_RIX_PLUS_ONE
+#else
+#define DP_RATE_TABLE_SIZE HE_LAST_RIX_PLUS_ONE
+#endif
 
 /* The following would span more than one octet
  * when 160MHz BW defined for VHT
@@ -172,6 +202,19 @@ enum DP_CMN_MODULATION_TYPE {
 	   DP_CMN_MOD_IEEE80211_T_HE_40,
 	   DP_CMN_MOD_IEEE80211_T_HE_80,
 	   DP_CMN_MOD_IEEE80211_T_HE_160,
+#ifdef WLAN_FEATURE_11BE
+	   DP_CMN_MOD_IEEE80211_T_EHT_20,
+	   DP_CMN_MOD_IEEE80211_T_EHT_40,
+	   DP_CMN_MOD_IEEE80211_T_EHT_60,
+	   DP_CMN_MOD_IEEE80211_T_EHT_80,
+	   DP_CMN_MOD_IEEE80211_T_EHT_120,
+	   DP_CMN_MOD_IEEE80211_T_EHT_140,
+	   DP_CMN_MOD_IEEE80211_T_EHT_160,
+	   DP_CMN_MOD_IEEE80211_T_EHT_200,
+	   DP_CMN_MOD_IEEE80211_T_EHT_240,
+	   DP_CMN_MOD_IEEE80211_T_EHT_280,
+	   DP_CMN_MOD_IEEE80211_T_EHT_320,
+#endif
 	   DP_CMN_MOD_IEEE80211_T_MAX_PHY
 };
 
@@ -184,15 +227,47 @@ enum HW_RATECODE_PREAM_TYPE {
 	HW_RATECODE_PREAM_HT,
 	HW_RATECODE_PREAM_VHT,
 	HW_RATECODE_PREAM_HE,
+#ifdef WLAN_FEATURE_11BE
+	HW_RATECODE_PREAM_EHT,
+#endif
+};
+
+#ifdef WLAN_FEATURE_11BE
+enum BW_TYPES_FP {
+	BW_20MHZ_F = 0,
+	BW_40MHZ_F,
+	BW_60MHZ_P,
+	BW_80MHZ_F,
+	BW_120MHZ_P,
+	BW_140MHZ_P,
+	BW_160MHZ_F,
+	BW_200MHZ_P,
+	BW_240MHZ_P,
+	BW_280MHZ_P,
+	BW_320MHZ_F,
+	BW_FP_CNT,
+	BW_FP_LAST = BW_320MHZ_F,
+};
+#endif
+
+enum PUNCTURED_MODES {
+	NO_PUNCTURE,
+#ifdef WLAN_FEATURE_11BE
+	PUNCTURED_20MHZ,
+	PUNCTURED_40MHZ,
+	PUNCTURED_80MHZ,
+	PUNCTURED_120MHZ,
+	PUNCTURED_MODE_CNT,
+#endif
 };
 
-enum DP_CMN_MODULATION_TYPE dp_getmodulation(
-		uint16_t pream_type,
-		uint8_t width);
+enum DP_CMN_MODULATION_TYPE dp_getmodulation(uint16_t pream_type,
+					     uint8_t width,
+					     uint8_t punc_mode);
 
 uint32_t
 dp_getrateindex(uint32_t gi, uint16_t mcs, uint8_t nss, uint8_t preamble,
-		uint8_t bw, uint32_t *rix, uint16_t *ratecode);
+		uint8_t bw, uint8_t punc_bw, uint32_t *rix, uint16_t *ratecode);
 
 int dp_rate_idx_to_kbps(uint8_t rate_idx, uint8_t gintval);
 

+ 2 - 1
dp/wifi3.0/dp_main.c

@@ -9737,7 +9737,8 @@ static int dp_txrx_get_ratekbps(int preamb, int mcs,
 	uint16_t ratecode;
 
 	return dp_getrateindex((uint32_t)gintval, (uint16_t)mcs, 1,
-			       (uint8_t)preamb, 1, &rix, &ratecode);
+			       (uint8_t)preamb, 1, NO_PUNCTURE,
+			       &rix, &ratecode);
 }
 #else
 static int dp_txrx_get_ratekbps(int preamb, int mcs,

+ 2 - 1
dp/wifi3.0/monitor/dp_mon.c

@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021,2022 Qualcomm Innovation Center, Inc. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -2211,6 +2211,7 @@ dp_tx_rate_stats_update(struct dp_peer *peer,
 				   ppdu->nss,
 				   ppdu->preamble,
 				   ppdu->bw,
+				   NO_PUNCTURE,
 				   &rix,
 				   &ratecode);
 

+ 2 - 1
dp/wifi3.0/monitor/dp_rx_mon.c

@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2021 The Linux Foundation. All rights reserved.
- * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021,2022 Qualcomm Innovation Center, Inc. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -712,6 +712,7 @@ static inline void dp_rx_rate_stats_update(struct dp_peer *peer,
 				   nss,
 				   ppdu->u.preamble,
 				   ppdu->u.bw,
+				   NO_PUNCTURE,
 				   &rix,
 				   &ratecode);