From nobody Wed Feb 26 02:11:58 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Z2dJZ5f34z5pQT2; Wed, 26 Feb 2025 02:11:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Z2dJZ46FPz49TL; Wed, 26 Feb 2025 02:11:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1740535918; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=KzFm21/gEPeNJGIgJomqLzCUroGGml7VmGiIkk/4FVk=; b=IhoDrkBenYMXRVzShQ11X35YNt1vYbXAPFUm2RlqYtAdzLfbXSMpp4aQL1iFCh9kgW9E7P 2CoxwNmieaGyN0dGX9QsV4dcu14JGFxGxx9u355Up7Oon8Q/X8Dc5FKp1fIBJhXo77gr8n sNaTPCwDlrbCHv/DfY4TROOxk7cks+N25UzUoyEqF95+q4flLPJpBk5tphn05Bpq7sMKsK 5UJ4SJUq17zEsFJy16bUV2eF9UquP/9bI+7+m/zHPVnBy0f7JCTzi3BGcwaDBvasSd9iho f/CUdobuzrNSvJTcHt1Uv3aOxM+OCXgCLe4AcKMQKdvIQ1+BE2zslJMDCcK0Bw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1740535918; a=rsa-sha256; cv=none; b=VeE+/5u0SOZ2PDAKn+BwO/St6YRrZzodD8TljztgtzRXwNqUhMU5F+m2ftHzWhfp34Q4QW FBzpD3KJZMj1E2phhKjp5RdidvyArZ6lJThlZ5bw/2WFg83JegSCw7a++MK9ZwnLyZhn0V rVcM6Ve3rJA5qHZsPZY1tgLYJHblT/MaOL8xxDtC4pKXWfRCek4j4fi2jeIzqxOgTrPg3/ ewLuXsWYFe/plbJvjJJXL0GFK5tXZLCDUP0GXBY3GShJcrjZ7wKWoIVLEpHfkdCaSIqHrg Ga0QSHo5He8hUD4zYIPt6S2BKlSzYcgQhO8walBxWVUwThwYA/5asVcVipH0YQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1740535918; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=KzFm21/gEPeNJGIgJomqLzCUroGGml7VmGiIkk/4FVk=; b=DB4z3Q3AChadCDqipWNmIni+O3pai037KeK0CJgX77gFyYx9zZgcguqw7GEEzNLkHlpv+e KURxXanSk0HmiINZEhrycxulE9aUKT0K6US08augfWe58UCUD5yb/GRgZlz4WB0IAGQQko +4j7e83PZQz5Rn5dZufN+RFFEMEDW/CWk41Rzs2kYd63zVfVRfqYalcyhwb2veB27vkA+e LAvrpQQOOBWPzhP9uEYn5qxyawWHXUu8j00udQXkyyEQVVNLPu0I5xGXHTAX/fPGoiXvJk iF0YvecHicMqPD3bVwTMEucefxQCJA6hMrM8ym/v0sVH8A8+84zLWsAs0CHLIA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Z2dJZ3dPpzsjr; Wed, 26 Feb 2025 02:11:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 51Q2Bw5S073103; Wed, 26 Feb 2025 02:11:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 51Q2BwbT073100; Wed, 26 Feb 2025 02:11:58 GMT (envelope-from git) Date: Wed, 26 Feb 2025 02:11:58 GMT Message-Id: <202502260211.51Q2BwbT073100@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 3f8cfb8a3a3b - main - iwlwifi: bring in some of the rs code List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3f8cfb8a3a3b9fbe6d4aebde81aee80f8e89e2ea Auto-Submitted: auto-generated The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=3f8cfb8a3a3b9fbe6d4aebde81aee80f8e89e2ea commit 3f8cfb8a3a3b9fbe6d4aebde81aee80f8e89e2ea Author: Bjoern A. Zeeb AuthorDate: 2025-01-25 11:00:23 +0000 Commit: Bjoern A. Zeeb CommitDate: 2025-02-26 02:10:55 +0000 iwlwifi: bring in some of the rs code Bring in code to call into rs-fw.c functionality for firmware supported rate select. Anything before AX200 (firmware matching iwlwiif-[0-9]*.ucode) will still need further implementation, and so does iwl_mvm_rs_tx_status(). These bits marked with compat.linuxkpi.80211.debug TODO()s for now. Implement some lindebugfs bits to gather more statistical information. Sponsored by: The FreeBSD Foundation Obtained from: bz_wifi_11n branch (partially) MFC after: 3 days --- sys/contrib/dev/iwlwifi/mvm/rs.c | 133 +++++++++++++++++++++++++++++++++++---- sys/contrib/dev/iwlwifi/mvm/rs.h | 9 ++- 2 files changed, 128 insertions(+), 14 deletions(-) diff --git a/sys/contrib/dev/iwlwifi/mvm/rs.c b/sys/contrib/dev/iwlwifi/mvm/rs.c index 981686e66920..f460624871ee 100644 --- a/sys/contrib/dev/iwlwifi/mvm/rs.c +++ b/sys/contrib/dev/iwlwifi/mvm/rs.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2020-2021 The FreeBSD Foundation + * Copyright (c) 2020-2025 The FreeBSD Foundation * * This software was developed by Björn Zeeb under sponsorship from * the FreeBSD Foundation. @@ -33,42 +33,123 @@ * This file is left as a wrapper to make mvm compile and we will only * deal with it on a need basis. Most newer chipsets do this in firmware. */ +#include +#include /* LinuxKPI 802.11 TODO() calls. */ -#include - +#include "rs.h" #include "mvm.h" #ifdef CONFIG_IWLWIFI_DEBUGFS +/* + * Fill struct iwl_mvm_frame_stats. + * Deal with various RATE_MCS_*_MSK. See rx.c, fw/api/rs.h, et al. + * XXX-BZ consider calling iwl_new_rate_from_v1() in rx.c so we can also + * use this in rxmq.c. + */ void iwl_mvm_update_frame_stats(struct iwl_mvm *mvm, u32 rate, bool agg) { - + uint8_t nss; + + spin_lock_bh(&mvm->drv_stats_lock); + mvm->drv_rx_stats.success_frames++; + + if (rate & RATE_MCS_HT_MSK_V1) { + mvm->drv_rx_stats.ht_frames++; + nss = 1 + ((rate & RATE_HT_MCS_NSS_MSK_V1) >> RATE_HT_MCS_NSS_POS_V1); + } else if (rate & RATE_MCS_VHT_MSK_V1) { + mvm->drv_rx_stats.vht_frames++; + nss = 1 + FIELD_GET(RATE_MCS_NSS_MSK, rate); + } else { + mvm->drv_rx_stats.legacy_frames++; + nss = 0; + } + + switch (rate & RATE_MCS_CHAN_WIDTH_MSK_V1) { + case RATE_MCS_CHAN_WIDTH_20: + mvm->drv_rx_stats.bw_20_frames++; + break; + case RATE_MCS_CHAN_WIDTH_40: + mvm->drv_rx_stats.bw_40_frames++; + break; + case RATE_MCS_CHAN_WIDTH_80: + mvm->drv_rx_stats.bw_80_frames++; + break; + case RATE_MCS_CHAN_WIDTH_160: + mvm->drv_rx_stats.bw_160_frames++; + break; + } + + if ((rate & RATE_MCS_CCK_MSK_V1) == 0 && + (rate & RATE_MCS_SGI_MSK_V1) != 0) + mvm->drv_rx_stats.sgi_frames++; + else + mvm->drv_rx_stats.ngi_frames++; + + switch (nss) { + case 1: + mvm->drv_rx_stats.siso_frames++; + break; + case 2: + mvm->drv_rx_stats.mimo2_frames++; + break; + } + + if (agg) + mvm->drv_rx_stats.agg_frames++; + + /* ampdu_count? */ + /* fail_frames? */ + + mvm->drv_rx_stats.last_rates[mvm->drv_rx_stats.last_frame_idx] = rate; + mvm->drv_rx_stats.last_frame_idx++; + mvm->drv_rx_stats.last_frame_idx %= + ARRAY_SIZE(mvm->drv_rx_stats.last_rates); + + spin_unlock_bh(&mvm->drv_stats_lock); } void iwl_mvm_reset_frame_stats(struct iwl_mvm *mvm) { - + /* Apply same locking rx.c does; debugfs seems to read unloked? */ + spin_lock_bh(&mvm->drv_stats_lock); + memset(&mvm->drv_rx_stats, 0, sizeof(mvm->drv_rx_stats)); + spin_unlock_bh(&mvm->drv_stats_lock); } #endif int iwl_mvm_rate_control_register(void) { - + TODO("This likely has to call into net80211 unless we gain compat code in LinuxKPI"); return (0); } -int -iwl_mvm_tx_protection(struct iwl_mvm *mvm, struct iwl_mvm_sta *sta, bool enable) +void +iwl_mvm_rate_control_unregister(void) { + TODO("This likely has to call into net80211 unless we gain compat code in LinuxKPI"); +} - return (0); +int +iwl_mvm_tx_protection(struct iwl_mvm *mvm, struct iwl_mvm_sta *mvmsta, bool enable) +{ + if (iwl_mvm_has_tlc_offload(mvm)) + return (rs_fw_tx_protection(mvm, mvmsta, enable)); + else { + TODO(); + return (0); + } } -void -iwl_mvm_rate_control_unregister(void) +static void +iwl_mvm_rs_sw_rate_init(struct iwl_mvm *mvm, struct ieee80211_vif *vif, + struct ieee80211_sta *sta, + struct ieee80211_bss_conf *link_conf, struct ieee80211_link_sta *link_sta, + enum nl80211_band band) { + TODO(); } void @@ -77,18 +158,28 @@ iwl_mvm_rs_rate_init(struct iwl_mvm *mvm, struct ieee80211_vif *vif, struct ieee80211_bss_conf *link_conf, struct ieee80211_link_sta *link_sta, enum nl80211_band band) { + if (iwl_mvm_has_tlc_offload(mvm)) + iwl_mvm_rs_fw_rate_init(mvm, vif, sta, link_conf, link_sta, band); + else + iwl_mvm_rs_sw_rate_init(mvm, vif, sta, link_conf, link_sta, band); } void iwl_mvm_rs_tx_status(struct iwl_mvm *mvm, struct ieee80211_sta *sta, int tid, struct ieee80211_tx_info *ba_info, bool t) { + TODO(); } void -rs_update_last_rssi(struct iwl_mvm *mvm, struct iwl_mvm_sta *mvmsta, +rs_update_last_rssi(struct iwl_mvm *mvm __unused, struct iwl_mvm_sta *mvmsta, struct ieee80211_rx_status *rx_status) { + struct iwl_lq_sta *lq_sta; + int i; + + if (mvmsta == NULL || rx_status == NULL) + return; /* * Assumption based on mvm/sta.h is that this should update @@ -96,12 +187,28 @@ rs_update_last_rssi(struct iwl_mvm *mvm, struct iwl_mvm_sta *mvmsta, * access in that struct so nowhere to put rssi information. * So the only thing would be if this is required internally * to functions in this file. + * The "FW" version accesses more fields. We assume they + * are the same for now. */ + + lq_sta = &mvmsta->deflink.lq_sta.rs_drv; + + lq_sta->pers.last_rssi = S8_MIN; + lq_sta->pers.chains = rx_status->chains; + + for (i = 0; i < nitems(lq_sta->pers.chain_signal); i++) { + if ((rx_status->chains & BIT(i)) == 0) + continue; + + lq_sta->pers.chain_signal[i] = rx_status->chain_signal[i]; + if (rx_status->chain_signal[i] > lq_sta->pers.last_rssi) + lq_sta->pers.last_rssi = rx_status->chain_signal[i]; + } } int rs_pretty_print_rate_v1(char *buf, int bufsz, const u32 rate) { - + TODO(); return (0); } diff --git a/sys/contrib/dev/iwlwifi/mvm/rs.h b/sys/contrib/dev/iwlwifi/mvm/rs.h index a9b10b841f95..71c0744f017c 100644 --- a/sys/contrib/dev/iwlwifi/mvm/rs.h +++ b/sys/contrib/dev/iwlwifi/mvm/rs.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2020-2021 The FreeBSD Foundation + * Copyright (c) 2020-2025 The FreeBSD Foundation * * This software was developed by Björn Zeeb under sponsorship from * the FreeBSD Foundation. @@ -69,6 +69,13 @@ struct iwl_lq_sta { struct { spinlock_t lock; uint16_t max_agg_bufsize; + /* + * Based on the assumption that these are in "FW" too and + * there is a f() to set last_rssi add them here too. + */ + uint8_t chains; + uint8_t chain_signal[IEEE80211_MAX_CHAINS]; + uint8_t last_rssi; } pers; };