avoid using MCS9 in iwm(4) Tx rate selection if 40 MHz is disabled
authorstsp <stsp@openbsd.org>
Mon, 6 Nov 2023 08:34:41 +0000 (08:34 +0000)
committerstsp <stsp@openbsd.org>
Mon, 6 Nov 2023 08:34:41 +0000 (08:34 +0000)
MCS9 is not valid on 20HMz so we must not use it in 20MHz-only mode.
Fixes firmware panic 0x00002078, which indicates the driver sets a rate
with a bad number of antennas, bad number of Tx streams, or bad bandwidth.

Observed by dlg@ with the miktrotik AP for which iwm(4) firmware requires
our 20MHz-only workaround to interoperate in 11ac mode.

ok dlg@

sys/dev/pci/if_iwm.c

index 2c107ba..fbab94f 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: if_iwm.c,v 1.411 2023/10/21 06:41:26 stsp Exp $       */
+/*     $OpenBSD: if_iwm.c,v 1.412 2023/11/06 08:34:41 stsp Exp $       */
 
 /*
  * Copyright (c) 2014, 2016 genua gmbh <info@genua.de>
@@ -9294,8 +9294,17 @@ iwm_set_rate_table_vht(struct iwm_node *in, struct iwm_lq_cmd *lqcmd)
                                if (i < 2 && in->in_phyctxt->vht_chan_width >=
                                    IEEE80211_VHTOP0_CHAN_WIDTH_80)
                                        tab |= IWM_RATE_MCS_CHAN_WIDTH_80;
-                               else
+                               else if (in->in_phyctxt->sco ==
+                                   IEEE80211_HTOP0_SCO_SCA ||
+                                   in->in_phyctxt->sco ==
+                                   IEEE80211_HTOP0_SCO_SCB)
                                        tab |= IWM_RATE_MCS_CHAN_WIDTH_40;
+                               else {
+                                       /* no 40 MHz, fall back on MCS 8 */
+                                       tab &= ~IWM_RATE_VHT_MCS_RATE_CODE_MSK;
+                                       tab |= 8;
+                               }
+                                       
                                tab |= IWM_RATE_MCS_RTS_REQUIRED_MSK;
                                if (i < 4) {
                                        if (ieee80211_ra_vht_use_sgi(ni))