diff mbox series

[v2,3/5] wifi: ath12k: add EHT support for TX rate

Message ID 20250213173206.1665731-4-quic_sarishar@quicinc.com
State New
Headers show
Series wifi: mac80211/ath12k: add support to fill link statistics of multi-link station | expand

Commit Message

Sarika Sharma Feb. 13, 2025, 5:32 p.m. UTC
Currently, TX rates are not supported for EHT. Hence, add EHT
handling for TX rates and update the EHT-specific fields in arsta
accordingly.

Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-QCAHKSWPL_SILICONZ-1

Signed-off-by: Sarika Sharma <quic_sarishar@quicinc.com>
---
 drivers/net/wireless/ath/ath12k/dp_rx.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

kernel test robot Feb. 22, 2025, 2:23 p.m. UTC | #1
Hi Sarika,

kernel test robot noticed the following build errors:

[auto build test ERROR on 704a2d7237043317ed1b0f8a08203e9ddde70097]

url:    https://github.com/intel-lab-lkp/linux/commits/Sarika-Sharma/wifi-mac80211-correct-RX-stats-packet-increment-for-multi-link/20250214-014020
base:   704a2d7237043317ed1b0f8a08203e9ddde70097
patch link:    https://lore.kernel.org/r/20250213173206.1665731-4-quic_sarishar%40quicinc.com
patch subject: [PATCH v2 3/5] wifi: ath12k: add EHT support for TX rate
config: powerpc-allmodconfig (https://download.01.org/0day-ci/archive/20250222/202502222240.pXNQqv36-lkp@intel.com/config)
compiler: powerpc64-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250222/202502222240.pXNQqv36-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202502222240.pXNQqv36-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/net/wireless/ath/ath12k/dp_rx.c: In function 'ath12k_update_per_peer_tx_stats':
>> drivers/net/wireless/ath/ath12k/dp_rx.c:1488:40: error: implicit declaration of function 'ath12k_eht_gi_to_nl80211_eht_gi'; did you mean 'ath12k_he_gi_to_nl80211_he_gi'? [-Wimplicit-function-declaration]
    1488 |                 arsta->txrate.eht_gi = ath12k_eht_gi_to_nl80211_eht_gi(sgi);
         |                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |                                        ath12k_he_gi_to_nl80211_he_gi
   drivers/net/wireless/ath/ath12k/dp_rx.c:1364:31: warning: variable 'sta' set but not used [-Wunused-but-set-variable]
    1364 |         struct ieee80211_sta *sta;
         |                               ^~~


vim +1488 drivers/net/wireless/ath/ath12k/dp_rx.c

  1357	
  1358	static void
  1359	ath12k_update_per_peer_tx_stats(struct ath12k *ar,
  1360					struct htt_ppdu_stats *ppdu_stats, u8 user)
  1361	{
  1362		struct ath12k_base *ab = ar->ab;
  1363		struct ath12k_peer *peer;
  1364		struct ieee80211_sta *sta;
  1365		struct ath12k_link_sta *arsta;
  1366		struct htt_ppdu_stats_user_rate *user_rate;
  1367		struct ath12k_per_peer_tx_stats *peer_stats = &ar->peer_tx_stats;
  1368		struct htt_ppdu_user_stats *usr_stats = &ppdu_stats->user_stats[user];
  1369		struct htt_ppdu_stats_common *common = &ppdu_stats->common;
  1370		int ret;
  1371		u8 flags, mcs, nss, bw, sgi, dcm, rate_idx = 0;
  1372		u32 v, succ_bytes = 0;
  1373		u16 tones, rate = 0, succ_pkts = 0;
  1374		u32 tx_duration = 0;
  1375		u8 tid = HTT_PPDU_STATS_NON_QOS_TID;
  1376		bool is_ampdu = false;
  1377	
  1378		if (!(usr_stats->tlv_flags & BIT(HTT_PPDU_STATS_TAG_USR_RATE)))
  1379			return;
  1380	
  1381		if (usr_stats->tlv_flags & BIT(HTT_PPDU_STATS_TAG_USR_COMPLTN_COMMON))
  1382			is_ampdu =
  1383				HTT_USR_CMPLTN_IS_AMPDU(usr_stats->cmpltn_cmn.flags);
  1384	
  1385		if (usr_stats->tlv_flags &
  1386		    BIT(HTT_PPDU_STATS_TAG_USR_COMPLTN_ACK_BA_STATUS)) {
  1387			succ_bytes = le32_to_cpu(usr_stats->ack_ba.success_bytes);
  1388			succ_pkts = le32_get_bits(usr_stats->ack_ba.info,
  1389						  HTT_PPDU_STATS_ACK_BA_INFO_NUM_MSDU_M);
  1390			tid = le32_get_bits(usr_stats->ack_ba.info,
  1391					    HTT_PPDU_STATS_ACK_BA_INFO_TID_NUM);
  1392		}
  1393	
  1394		if (common->fes_duration_us)
  1395			tx_duration = le32_to_cpu(common->fes_duration_us);
  1396	
  1397		user_rate = &usr_stats->rate;
  1398		flags = HTT_USR_RATE_PREAMBLE(user_rate->rate_flags);
  1399		bw = HTT_USR_RATE_BW(user_rate->rate_flags) - 2;
  1400		nss = HTT_USR_RATE_NSS(user_rate->rate_flags) + 1;
  1401		mcs = HTT_USR_RATE_MCS(user_rate->rate_flags);
  1402		sgi = HTT_USR_RATE_GI(user_rate->rate_flags);
  1403		dcm = HTT_USR_RATE_DCM(user_rate->rate_flags);
  1404	
  1405		/* Note: If host configured fixed rates and in some other special
  1406		 * cases, the broadcast/management frames are sent in different rates.
  1407		 * Firmware rate's control to be skipped for this?
  1408		 */
  1409	
  1410		if (flags == WMI_RATE_PREAMBLE_HE && mcs > ATH12K_HE_MCS_MAX) {
  1411			ath12k_warn(ab, "Invalid HE mcs %d peer stats",  mcs);
  1412			return;
  1413		}
  1414	
  1415		if (flags == WMI_RATE_PREAMBLE_VHT && mcs > ATH12K_VHT_MCS_MAX) {
  1416			ath12k_warn(ab, "Invalid VHT mcs %d peer stats",  mcs);
  1417			return;
  1418		}
  1419	
  1420		if (flags == WMI_RATE_PREAMBLE_HT && (mcs > ATH12K_HT_MCS_MAX || nss < 1)) {
  1421			ath12k_warn(ab, "Invalid HT mcs %d nss %d peer stats",
  1422				    mcs, nss);
  1423			return;
  1424		}
  1425	
  1426		if (flags == WMI_RATE_PREAMBLE_CCK || flags == WMI_RATE_PREAMBLE_OFDM) {
  1427			ret = ath12k_mac_hw_ratecode_to_legacy_rate(mcs,
  1428								    flags,
  1429								    &rate_idx,
  1430								    &rate);
  1431			if (ret < 0)
  1432				return;
  1433		}
  1434	
  1435		rcu_read_lock();
  1436		spin_lock_bh(&ab->base_lock);
  1437		peer = ath12k_peer_find_by_id(ab, usr_stats->peer_id);
  1438	
  1439		if (!peer || !peer->sta) {
  1440			spin_unlock_bh(&ab->base_lock);
  1441			rcu_read_unlock();
  1442			return;
  1443		}
  1444	
  1445		sta = peer->sta;
  1446		arsta = ath12k_peer_get_link_sta(ab, peer);
  1447		if (!arsta) {
  1448			spin_unlock_bh(&ab->base_lock);
  1449			rcu_read_unlock();
  1450			return;
  1451		}
  1452	
  1453		memset(&arsta->txrate, 0, sizeof(arsta->txrate));
  1454	
  1455		switch (flags) {
  1456		case WMI_RATE_PREAMBLE_OFDM:
  1457			arsta->txrate.legacy = rate;
  1458			break;
  1459		case WMI_RATE_PREAMBLE_CCK:
  1460			arsta->txrate.legacy = rate;
  1461			break;
  1462		case WMI_RATE_PREAMBLE_HT:
  1463			arsta->txrate.mcs = mcs + 8 * (nss - 1);
  1464			arsta->txrate.flags = RATE_INFO_FLAGS_MCS;
  1465			if (sgi)
  1466				arsta->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
  1467			break;
  1468		case WMI_RATE_PREAMBLE_VHT:
  1469			arsta->txrate.mcs = mcs;
  1470			arsta->txrate.flags = RATE_INFO_FLAGS_VHT_MCS;
  1471			if (sgi)
  1472				arsta->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
  1473			break;
  1474		case WMI_RATE_PREAMBLE_HE:
  1475			arsta->txrate.mcs = mcs;
  1476			arsta->txrate.flags = RATE_INFO_FLAGS_HE_MCS;
  1477			arsta->txrate.he_dcm = dcm;
  1478			arsta->txrate.he_gi = ath12k_he_gi_to_nl80211_he_gi(sgi);
  1479			tones = le16_to_cpu(user_rate->ru_end) -
  1480				le16_to_cpu(user_rate->ru_start) + 1;
  1481			v = ath12k_he_ru_tones_to_nl80211_he_ru_alloc(tones);
  1482			arsta->txrate.he_ru_alloc = v;
  1483			break;
  1484		case WMI_RATE_PREAMBLE_EHT:
  1485			arsta->txrate.mcs = mcs;
  1486			arsta->txrate.flags = RATE_INFO_FLAGS_EHT_MCS;
  1487			arsta->txrate.he_dcm = dcm;
> 1488			arsta->txrate.eht_gi = ath12k_eht_gi_to_nl80211_eht_gi(sgi);
  1489			tones = le16_to_cpu(user_rate->ru_end) -
  1490				le16_to_cpu(user_rate->ru_start) + 1;
  1491			v = ath12k_mac_eht_ru_tones_to_nl80211_eht_ru_alloc(tones);
  1492			arsta->txrate.eht_ru_alloc = v;
  1493			break;
  1494		}
  1495	
  1496		arsta->txrate.nss = nss;
  1497		arsta->txrate.bw = ath12k_mac_bw_to_mac80211_bw(bw);
  1498		arsta->tx_duration += tx_duration;
  1499		memcpy(&arsta->last_txrate, &arsta->txrate, sizeof(struct rate_info));
  1500	
  1501		/* PPDU stats reported for mgmt packet doesn't have valid tx bytes.
  1502		 * So skip peer stats update for mgmt packets.
  1503		 */
  1504		if (tid < HTT_PPDU_STATS_NON_QOS_TID) {
  1505			memset(peer_stats, 0, sizeof(*peer_stats));
  1506			peer_stats->succ_pkts = succ_pkts;
  1507			peer_stats->succ_bytes = succ_bytes;
  1508			peer_stats->is_ampdu = is_ampdu;
  1509			peer_stats->duration = tx_duration;
  1510			peer_stats->ba_fails =
  1511				HTT_USR_CMPLTN_LONG_RETRY(usr_stats->cmpltn_cmn.flags) +
  1512				HTT_USR_CMPLTN_SHORT_RETRY(usr_stats->cmpltn_cmn.flags);
  1513		}
  1514	
  1515		spin_unlock_bh(&ab->base_lock);
  1516		rcu_read_unlock();
  1517	}
  1518
kernel test robot Feb. 23, 2025, 2:27 a.m. UTC | #2
Hi Sarika,

kernel test robot noticed the following build errors:

[auto build test ERROR on 704a2d7237043317ed1b0f8a08203e9ddde70097]

url:    https://github.com/intel-lab-lkp/linux/commits/Sarika-Sharma/wifi-mac80211-correct-RX-stats-packet-increment-for-multi-link/20250214-014020
base:   704a2d7237043317ed1b0f8a08203e9ddde70097
patch link:    https://lore.kernel.org/r/20250213173206.1665731-4-quic_sarishar%40quicinc.com
patch subject: [PATCH v2 3/5] wifi: ath12k: add EHT support for TX rate
config: powerpc-allyesconfig (https://download.01.org/0day-ci/archive/20250223/202502231023.vzEGxJWz-lkp@intel.com/config)
compiler: clang version 16.0.6 (https://github.com/llvm/llvm-project 7cbf1a2591520c2491aa35339f227775f4d3adf6)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250223/202502231023.vzEGxJWz-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202502231023.vzEGxJWz-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/net/wireless/ath/ath12k/dp_rx.c:1488:26: error: call to undeclared function 'ath12k_eht_gi_to_nl80211_eht_gi'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
                   arsta->txrate.eht_gi = ath12k_eht_gi_to_nl80211_eht_gi(sgi);
                                          ^
   drivers/net/wireless/ath/ath12k/dp_rx.c:1364:24: warning: variable 'sta' set but not used [-Wunused-but-set-variable]
           struct ieee80211_sta *sta;
                                 ^
   1 warning and 1 error generated.


vim +/ath12k_eht_gi_to_nl80211_eht_gi +1488 drivers/net/wireless/ath/ath12k/dp_rx.c

  1357	
  1358	static void
  1359	ath12k_update_per_peer_tx_stats(struct ath12k *ar,
  1360					struct htt_ppdu_stats *ppdu_stats, u8 user)
  1361	{
  1362		struct ath12k_base *ab = ar->ab;
  1363		struct ath12k_peer *peer;
  1364		struct ieee80211_sta *sta;
  1365		struct ath12k_link_sta *arsta;
  1366		struct htt_ppdu_stats_user_rate *user_rate;
  1367		struct ath12k_per_peer_tx_stats *peer_stats = &ar->peer_tx_stats;
  1368		struct htt_ppdu_user_stats *usr_stats = &ppdu_stats->user_stats[user];
  1369		struct htt_ppdu_stats_common *common = &ppdu_stats->common;
  1370		int ret;
  1371		u8 flags, mcs, nss, bw, sgi, dcm, rate_idx = 0;
  1372		u32 v, succ_bytes = 0;
  1373		u16 tones, rate = 0, succ_pkts = 0;
  1374		u32 tx_duration = 0;
  1375		u8 tid = HTT_PPDU_STATS_NON_QOS_TID;
  1376		bool is_ampdu = false;
  1377	
  1378		if (!(usr_stats->tlv_flags & BIT(HTT_PPDU_STATS_TAG_USR_RATE)))
  1379			return;
  1380	
  1381		if (usr_stats->tlv_flags & BIT(HTT_PPDU_STATS_TAG_USR_COMPLTN_COMMON))
  1382			is_ampdu =
  1383				HTT_USR_CMPLTN_IS_AMPDU(usr_stats->cmpltn_cmn.flags);
  1384	
  1385		if (usr_stats->tlv_flags &
  1386		    BIT(HTT_PPDU_STATS_TAG_USR_COMPLTN_ACK_BA_STATUS)) {
  1387			succ_bytes = le32_to_cpu(usr_stats->ack_ba.success_bytes);
  1388			succ_pkts = le32_get_bits(usr_stats->ack_ba.info,
  1389						  HTT_PPDU_STATS_ACK_BA_INFO_NUM_MSDU_M);
  1390			tid = le32_get_bits(usr_stats->ack_ba.info,
  1391					    HTT_PPDU_STATS_ACK_BA_INFO_TID_NUM);
  1392		}
  1393	
  1394		if (common->fes_duration_us)
  1395			tx_duration = le32_to_cpu(common->fes_duration_us);
  1396	
  1397		user_rate = &usr_stats->rate;
  1398		flags = HTT_USR_RATE_PREAMBLE(user_rate->rate_flags);
  1399		bw = HTT_USR_RATE_BW(user_rate->rate_flags) - 2;
  1400		nss = HTT_USR_RATE_NSS(user_rate->rate_flags) + 1;
  1401		mcs = HTT_USR_RATE_MCS(user_rate->rate_flags);
  1402		sgi = HTT_USR_RATE_GI(user_rate->rate_flags);
  1403		dcm = HTT_USR_RATE_DCM(user_rate->rate_flags);
  1404	
  1405		/* Note: If host configured fixed rates and in some other special
  1406		 * cases, the broadcast/management frames are sent in different rates.
  1407		 * Firmware rate's control to be skipped for this?
  1408		 */
  1409	
  1410		if (flags == WMI_RATE_PREAMBLE_HE && mcs > ATH12K_HE_MCS_MAX) {
  1411			ath12k_warn(ab, "Invalid HE mcs %d peer stats",  mcs);
  1412			return;
  1413		}
  1414	
  1415		if (flags == WMI_RATE_PREAMBLE_VHT && mcs > ATH12K_VHT_MCS_MAX) {
  1416			ath12k_warn(ab, "Invalid VHT mcs %d peer stats",  mcs);
  1417			return;
  1418		}
  1419	
  1420		if (flags == WMI_RATE_PREAMBLE_HT && (mcs > ATH12K_HT_MCS_MAX || nss < 1)) {
  1421			ath12k_warn(ab, "Invalid HT mcs %d nss %d peer stats",
  1422				    mcs, nss);
  1423			return;
  1424		}
  1425	
  1426		if (flags == WMI_RATE_PREAMBLE_CCK || flags == WMI_RATE_PREAMBLE_OFDM) {
  1427			ret = ath12k_mac_hw_ratecode_to_legacy_rate(mcs,
  1428								    flags,
  1429								    &rate_idx,
  1430								    &rate);
  1431			if (ret < 0)
  1432				return;
  1433		}
  1434	
  1435		rcu_read_lock();
  1436		spin_lock_bh(&ab->base_lock);
  1437		peer = ath12k_peer_find_by_id(ab, usr_stats->peer_id);
  1438	
  1439		if (!peer || !peer->sta) {
  1440			spin_unlock_bh(&ab->base_lock);
  1441			rcu_read_unlock();
  1442			return;
  1443		}
  1444	
  1445		sta = peer->sta;
  1446		arsta = ath12k_peer_get_link_sta(ab, peer);
  1447		if (!arsta) {
  1448			spin_unlock_bh(&ab->base_lock);
  1449			rcu_read_unlock();
  1450			return;
  1451		}
  1452	
  1453		memset(&arsta->txrate, 0, sizeof(arsta->txrate));
  1454	
  1455		switch (flags) {
  1456		case WMI_RATE_PREAMBLE_OFDM:
  1457			arsta->txrate.legacy = rate;
  1458			break;
  1459		case WMI_RATE_PREAMBLE_CCK:
  1460			arsta->txrate.legacy = rate;
  1461			break;
  1462		case WMI_RATE_PREAMBLE_HT:
  1463			arsta->txrate.mcs = mcs + 8 * (nss - 1);
  1464			arsta->txrate.flags = RATE_INFO_FLAGS_MCS;
  1465			if (sgi)
  1466				arsta->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
  1467			break;
  1468		case WMI_RATE_PREAMBLE_VHT:
  1469			arsta->txrate.mcs = mcs;
  1470			arsta->txrate.flags = RATE_INFO_FLAGS_VHT_MCS;
  1471			if (sgi)
  1472				arsta->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
  1473			break;
  1474		case WMI_RATE_PREAMBLE_HE:
  1475			arsta->txrate.mcs = mcs;
  1476			arsta->txrate.flags = RATE_INFO_FLAGS_HE_MCS;
  1477			arsta->txrate.he_dcm = dcm;
  1478			arsta->txrate.he_gi = ath12k_he_gi_to_nl80211_he_gi(sgi);
  1479			tones = le16_to_cpu(user_rate->ru_end) -
  1480				le16_to_cpu(user_rate->ru_start) + 1;
  1481			v = ath12k_he_ru_tones_to_nl80211_he_ru_alloc(tones);
  1482			arsta->txrate.he_ru_alloc = v;
  1483			break;
  1484		case WMI_RATE_PREAMBLE_EHT:
  1485			arsta->txrate.mcs = mcs;
  1486			arsta->txrate.flags = RATE_INFO_FLAGS_EHT_MCS;
  1487			arsta->txrate.he_dcm = dcm;
> 1488			arsta->txrate.eht_gi = ath12k_eht_gi_to_nl80211_eht_gi(sgi);
  1489			tones = le16_to_cpu(user_rate->ru_end) -
  1490				le16_to_cpu(user_rate->ru_start) + 1;
  1491			v = ath12k_mac_eht_ru_tones_to_nl80211_eht_ru_alloc(tones);
  1492			arsta->txrate.eht_ru_alloc = v;
  1493			break;
  1494		}
  1495	
  1496		arsta->txrate.nss = nss;
  1497		arsta->txrate.bw = ath12k_mac_bw_to_mac80211_bw(bw);
  1498		arsta->tx_duration += tx_duration;
  1499		memcpy(&arsta->last_txrate, &arsta->txrate, sizeof(struct rate_info));
  1500	
  1501		/* PPDU stats reported for mgmt packet doesn't have valid tx bytes.
  1502		 * So skip peer stats update for mgmt packets.
  1503		 */
  1504		if (tid < HTT_PPDU_STATS_NON_QOS_TID) {
  1505			memset(peer_stats, 0, sizeof(*peer_stats));
  1506			peer_stats->succ_pkts = succ_pkts;
  1507			peer_stats->succ_bytes = succ_bytes;
  1508			peer_stats->is_ampdu = is_ampdu;
  1509			peer_stats->duration = tx_duration;
  1510			peer_stats->ba_fails =
  1511				HTT_USR_CMPLTN_LONG_RETRY(usr_stats->cmpltn_cmn.flags) +
  1512				HTT_USR_CMPLTN_SHORT_RETRY(usr_stats->cmpltn_cmn.flags);
  1513		}
  1514	
  1515		spin_unlock_bh(&ab->base_lock);
  1516		rcu_read_unlock();
  1517	}
  1518
diff mbox series

Patch

diff --git a/drivers/net/wireless/ath/ath12k/dp_rx.c b/drivers/net/wireless/ath/ath12k/dp_rx.c
index 1fa7cf044afe..5dab13b0787d 100644
--- a/drivers/net/wireless/ath/ath12k/dp_rx.c
+++ b/drivers/net/wireless/ath/ath12k/dp_rx.c
@@ -1481,6 +1481,16 @@  ath12k_update_per_peer_tx_stats(struct ath12k *ar,
 		v = ath12k_he_ru_tones_to_nl80211_he_ru_alloc(tones);
 		arsta->txrate.he_ru_alloc = v;
 		break;
+	case WMI_RATE_PREAMBLE_EHT:
+		arsta->txrate.mcs = mcs;
+		arsta->txrate.flags = RATE_INFO_FLAGS_EHT_MCS;
+		arsta->txrate.he_dcm = dcm;
+		arsta->txrate.eht_gi = ath12k_eht_gi_to_nl80211_eht_gi(sgi);
+		tones = le16_to_cpu(user_rate->ru_end) -
+			le16_to_cpu(user_rate->ru_start) + 1;
+		v = ath12k_mac_eht_ru_tones_to_nl80211_eht_ru_alloc(tones);
+		arsta->txrate.eht_ru_alloc = v;
+		break;
 	}
 
 	arsta->txrate.nss = nss;