git: 1f07bcd91de1 - main - iwm: placeholders for HT rates, update some FW flags to openbsd

From: Adrian Chadd <adrian_at_FreeBSD.org>
Date: Mon, 12 Oct 2026 02:51:31 UTC
The branch main has been updated by adrian:

URL: https://cgit.FreeBSD.org/src/commit/?id=1f07bcd91de1d02d1adb8a1215945cd02f469489

commit 1f07bcd91de1d02d1adb8a1215945cd02f469489
Author:     Adrian Chadd <adrian@FreeBSD.org>
AuthorDate: 2026-10-12 02:41:12 +0000
Commit:     Adrian Chadd <adrian@FreeBSD.org>
CommitDate: 2026-10-12 02:41:12 +0000

    iwm: placeholders for HT rates, update some FW flags to openbsd
    
    * update a flag to openbsd iwm
    * lay down placeholder ht rate / MIMO config routines based on
      openbsd's updated init path
    
    Obtained from: OpenBSD a6e25c727a2214219715b51ba6af2221d7e0d674
    
    Differential Revision:  https://reviews.freebsd.org/D60073
---
 sys/dev/iwm/if_iwm.c          | 39 ++++++++++++++++++++++++++++++++++++---
 sys/dev/iwm/if_iwm_phy_ctxt.c |  3 +++
 sys/dev/iwm/if_iwmreg.h       |  2 +-
 3 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/sys/dev/iwm/if_iwm.c b/sys/dev/iwm/if_iwm.c
index 51a0313842d0..dcebda12e263 100644
--- a/sys/dev/iwm/if_iwm.c
+++ b/sys/dev/iwm/if_iwm.c
@@ -2003,6 +2003,11 @@ iwm_add_channel_band(struct iwm_softc *sc, struct ieee80211_channel chans[],
 	}
 }
 
+/* TODO: HT20 */
+/* TODO: HT40 */
+/* TODO: VHT20 */
+/* TODO: VHT40, VHT80 */
+
 static void
 iwm_init_channel_map(struct ieee80211com *ic, int maxchans, int *nchans,
     struct ieee80211_channel chans[])
@@ -2036,6 +2041,23 @@ iwm_init_channel_map(struct ieee80211com *ic, int maxchans, int *nchans,
 	}
 }
 
+static int
+iwm_mimo_enabled(struct iwm_softc *sc)
+{
+	return (!sc->nvm_data->sku_cap_mimo_disable);
+}
+
+static void
+iwm_setup_ht_rates(struct iwm_softc *sc)
+{
+	/* XXX TODO MCS0..7 */
+
+	if (!iwm_mimo_enabled(sc))
+		return;
+
+	/* XXX TODO: MCS8..15 if >1 antenna and mimo enabled */
+}
+
 static void
 iwm_set_hw_address_family_8000(struct iwm_softc *sc, struct iwm_nvm_data *data,
 	const uint16_t *mac_override, const uint16_t *nvm_hw)
@@ -4671,7 +4693,7 @@ iwm_send_update_mcc_cmd(struct iwm_softc *sc, const char *alpha2)
 	int n_channels;
 	uint16_t mcc;
 #endif
-	int resp_v2 = iwm_fw_has_capa(sc, IWM_UCODE_TLV_CAPA_LAR_SUPPORT_V2);
+	int resp_v3 = iwm_fw_has_capa(sc, IWM_UCODE_TLV_CAPA_LAR_SUPPORT_V3);
 
 	if (!iwm_is_lar_supported(sc)) {
 		IWM_DPRINTF(sc, IWM_DEBUG_LAR, "%s: no LAR support\n",
@@ -4686,7 +4708,7 @@ iwm_send_update_mcc_cmd(struct iwm_softc *sc, const char *alpha2)
 	else
 		mcc_cmd.source_id = IWM_MCC_SOURCE_OLD_FW;
 
-	if (resp_v2)
+	if (resp_v3)
 		hcmd.len[0] = sizeof(struct iwm_mcc_update_cmd);
 	else
 		hcmd.len[0] = sizeof(struct iwm_mcc_update_cmd_v1);
@@ -4703,7 +4725,7 @@ iwm_send_update_mcc_cmd(struct iwm_softc *sc, const char *alpha2)
 	pkt = hcmd.resp_pkt;
 
 	/* Extract MCC response */
-	if (resp_v2) {
+	if (resp_v3) {
 		mcc_resp = (void *)pkt->data;
 		mcc = mcc_resp->mcc;
 		n_channels =  le32toh(mcc_resp->n_channels);
@@ -4906,6 +4928,9 @@ iwm_init(struct iwm_softc *sc)
 		return;
 	}
 
+	if (sc->nvm_data->sku_cap_11n_enable)
+		iwm_setup_ht_rates(sc);
+
 	/*
 	 * Ok, firmware loaded and we are jogging
 	 */
@@ -6191,6 +6216,11 @@ iwm_attach(device_t dev)
 	IWM_DPRINTF(sc, IWM_DEBUG_RESET | IWM_DEBUG_TRACE,
 	    "<-%s\n", __func__);
 
+	device_printf(dev, "%s: TX ant=0x%x, RX ant=0x%x\n",
+	    __func__,
+	    iwm_get_valid_tx_ant(sc),
+	    iwm_get_valid_rx_ant(sc));
+
 	return 0;
 
 	/* Free allocated memory if something failed during attachment. */
@@ -6287,6 +6317,9 @@ iwm_preinit(void *arg)
 	    sc->sc_hw_rev & IWM_CSR_HW_REV_TYPE_MSK,
 	    sc->sc_fwver, ether_sprintf(sc->nvm_data->hw_addr));
 
+	if (sc->nvm_data->sku_cap_11n_enable)
+		iwm_setup_ht_rates(sc);
+
 	/* not all hardware can do 5GHz band */
 	if (!sc->nvm_data->sku_cap_band_52GHz_enable)
 		memset(&ic->ic_sup_rates[IEEE80211_MODE_11A], 0,
diff --git a/sys/dev/iwm/if_iwm_phy_ctxt.c b/sys/dev/iwm/if_iwm_phy_ctxt.c
index 65ebc4449af9..7ca86b31267f 100644
--- a/sys/dev/iwm/if_iwm_phy_ctxt.c
+++ b/sys/dev/iwm/if_iwm_phy_ctxt.c
@@ -209,6 +209,9 @@ iwm_phy_ctxt_cmd_data(struct iwm_softc *sc,
 	    IWM_PHY_BAND_24 : IWM_PHY_BAND_5;
 
 	cmd->ci.channel = ieee80211_chan2ieee(ic, chan);
+
+	/* TODO: HT40 */
+	/* TODO: VHT40/VHT80 */
 	cmd->ci.width = IWM_PHY_VHT_CHANNEL_MODE20;
 	cmd->ci.ctrl_pos = IWM_PHY_VHT_CTRL_POS_1_BELOW;
 
diff --git a/sys/dev/iwm/if_iwmreg.h b/sys/dev/iwm/if_iwmreg.h
index 296d07bc4b31..c8241aa5ceea 100644
--- a/sys/dev/iwm/if_iwmreg.h
+++ b/sys/dev/iwm/if_iwmreg.h
@@ -954,7 +954,7 @@ enum msix_ivar_for_cause {
 #define IWM_UCODE_TLV_CAPA_MULTI_QUEUE_RX_SUPPORT	68
 #define IWM_UCODE_TLV_CAPA_BEACON_ANT_SELECTION		71
 #define IWM_UCODE_TLV_CAPA_BEACON_STORING		72
-#define IWM_UCODE_TLV_CAPA_LAR_SUPPORT_V2		73
+#define IWM_UCODE_TLV_CAPA_LAR_SUPPORT_V3		73
 #define IWM_UCODE_TLV_CAPA_CT_KILL_BY_FW		74
 #define IWM_UCODE_TLV_CAPA_TEMP_THS_REPORT_SUPPORT	75
 #define IWM_UCODE_TLV_CAPA_CTDP_SUPPORT			76