From 25c277bcbc00617a7203d5605022f762bcad5c0c Mon Sep 17 00:00:00 2001 From: stsp Date: Thu, 29 Jul 2021 12:00:30 +0000 Subject: [PATCH] Support the new iwx(4) firmware TLC_MNG_CONFIG command. This command was expanded by a 4 byte max_tx_op field. As far as I can tell the Linux driver makes no use of this field, so just initialize it to zero. New firmware panics when we try to initialize Tx rate scaling otherwise. ok kevlo@ --- sys/dev/pci/if_iwx.c | 14 ++++++++++---- sys/dev/pci/if_iwxreg.h | 9 ++++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/sys/dev/pci/if_iwx.c b/sys/dev/pci/if_iwx.c index c6f8b3f1357..ba9123114ff 100644 --- a/sys/dev/pci/if_iwx.c +++ b/sys/dev/pci/if_iwx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwx.c,v 1.82 2021/07/29 11:58:35 stsp Exp $ */ +/* $OpenBSD: if_iwx.c,v 1.83 2021/07/29 12:00:30 stsp Exp $ */ /* * Copyright (c) 2014, 2016 genua gmbh @@ -6668,10 +6668,17 @@ iwx_rs_init(struct iwx_softc *sc, struct iwx_node *in) struct ieee80211_rateset *rs = &ni->ni_rates; struct iwx_tlc_config_cmd cfg_cmd; uint32_t cmd_id; - int i; + int i, cmdver; + size_t cmd_size = sizeof(cfg_cmd); memset(&cfg_cmd, 0, sizeof(cfg_cmd)); + /* In old versions of the API the struct is 4 bytes smaller */ + cmdver = iwx_lookup_cmd_ver(sc, IWX_DATA_PATH_GROUP, + IWX_TLC_MNG_CONFIG_CMD); + if (cmdver == IWX_FW_CMD_VER_UNKNOWN || cmdver < 3) + cmd_size -= sizeof(uint32_t); + for (i = 0; i < rs->rs_nrates; i++) { uint8_t rval = rs->rs_rates[i] & IEEE80211_RATE_VAL; int idx = iwx_rs_rval2idx(rval); @@ -6697,8 +6704,7 @@ iwx_rs_init(struct iwx_softc *sc, struct iwx_node *in) cfg_cmd.sgi_ch_width_supp = (1 << IWX_TLC_MNG_CH_WIDTH_20MHZ); cmd_id = iwx_cmd_id(IWX_TLC_MNG_CONFIG_CMD, IWX_DATA_PATH_GROUP, 0); - return iwx_send_cmd_pdu(sc, cmd_id, IWX_CMD_ASYNC, sizeof(cfg_cmd), - &cfg_cmd); + return iwx_send_cmd_pdu(sc, cmd_id, IWX_CMD_ASYNC, cmd_size, &cfg_cmd); } void diff --git a/sys/dev/pci/if_iwxreg.h b/sys/dev/pci/if_iwxreg.h index 0af70424750..ba0f5a49d45 100644 --- a/sys/dev/pci/if_iwxreg.h +++ b/sys/dev/pci/if_iwxreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwxreg.h,v 1.27 2021/07/29 11:58:35 stsp Exp $ */ +/* $OpenBSD: if_iwxreg.h,v 1.28 2021/07/29 12:00:30 stsp Exp $ */ /*- * Based on BSD-licensed source modules in the Linux iwlwifi driver, @@ -4755,6 +4755,8 @@ enum iwx_tlc_mng_ht_rates { * @sgi_ch_width_supp: bitmap of SGI support per channel width * use (1 << @enum iwx_tlc_mng_cfg_cw) * @reserved2: reserved + * @max_tx_op: max TXOP in uSecs for all AC (BK, BE, VO, VI), + * set zero for no limit. */ struct iwx_tlc_config_cmd { uint8_t sta_id; @@ -4768,8 +4770,9 @@ struct iwx_tlc_config_cmd { uint16_t ht_rates[IWX_TLC_NSS_MAX][2]; uint16_t max_mpdu_len; uint8_t sgi_ch_width_supp; - uint8_t reserved2[1]; -} __packed; /* TLC_MNG_CONFIG_CMD_API_S_VER_2 */ + uint8_t reserved2; + uint32_t max_tx_op; +} __packed; /* TLC_MNG_CONFIG_CMD_API_S_VER_3 */ /** * @IWX_TLC_NOTIF_FLAG_RATE: last initial rate update -- 2.20.1