git: 65373e8d0239 - main - iwm: bring in the command table version code from openbsd
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 12 Oct 2026 02:51:34 UTC
The branch main has been updated by adrian:
URL: https://cgit.FreeBSD.org/src/commit/?id=65373e8d02391054eb867edaeb92348c6f2d4ff4
commit 65373e8d02391054eb867edaeb92348c6f2d4ff4
Author: Adrian Chadd <adrian@FreeBSD.org>
AuthorDate: 2026-10-12 02:41:24 +0000
Commit: Adrian Chadd <adrian@FreeBSD.org>
CommitDate: 2026-10-12 02:41:24 +0000
iwm: bring in the command table version code from openbsd
Parse the command table; same way as OpenBSD (ie, memcpy()
and not anything endianness happy.)
Nothing is using it yet.
Obtained from: OpenBSD a6e25c727a2214219715b51ba6af2221d7e0d674
Differential Revision: https://reviews.freebsd.org/D60075
---
sys/dev/iwm/if_iwm.c | 31 +++++++++++++++++++++++++++++++
sys/dev/iwm/if_iwmvar.h | 4 ++++
2 files changed, 35 insertions(+)
diff --git a/sys/dev/iwm/if_iwm.c b/sys/dev/iwm/if_iwm.c
index 32d6dbc864fc..642c8fbd44f2 100644
--- a/sys/dev/iwm/if_iwm.c
+++ b/sys/dev/iwm/if_iwm.c
@@ -562,6 +562,21 @@ iwm_fw_info_free(struct iwm_fw_info *fw)
memset(fw->img, 0, sizeof(fw->img));
}
+static uint8_t
+iwm_lookup_cmd_ver(struct iwm_softc *sc, uint8_t grp, uint8_t cmd)
+{
+ const struct iwm_fw_cmd_version *entry;
+ int i;
+
+ for (i = 0; i < sc->n_cmd_versions; i++) {
+ entry = &sc->cmd_versions[i];
+ if (entry->group == grp && entry->cmd == cmd)
+ return entry->cmd_ver;
+ }
+
+ return IWM_FW_CMD_VER_UNKNOWN;
+}
+
static int
iwm_read_firmware(struct iwm_softc *sc)
{
@@ -817,6 +832,22 @@ iwm_read_firmware(struct iwm_softc *sc)
}
case IWM_UCODE_TLV_CMD_VERSIONS:
+ if (tlv_len % sizeof(struct iwm_fw_cmd_version)) {
+ tlv_len /= sizeof(struct iwm_fw_cmd_version);
+ tlv_len *= sizeof(struct iwm_fw_cmd_version);
+ }
+ if (sc->n_cmd_versions != 0) {
+ error = EINVAL;
+ goto parse_out;
+ }
+ if (tlv_len > sizeof(sc->cmd_versions)) {
+ error = EINVAL;
+ goto parse_out;
+ }
+ memcpy(&sc->cmd_versions[0], tlv_data, tlv_len);
+ sc->n_cmd_versions = tlv_len / sizeof(struct iwm_fw_cmd_version);
+ break;
+
case IWM_UCODE_TLV_SDIO_ADMA_ADDR:
case IWM_UCODE_TLV_FW_GSCAN_CAPA:
/* ignore, not used by current driver */
diff --git a/sys/dev/iwm/if_iwmvar.h b/sys/dev/iwm/if_iwmvar.h
index 361c2d073520..424587ad88a2 100644
--- a/sys/dev/iwm/if_iwmvar.h
+++ b/sys/dev/iwm/if_iwmvar.h
@@ -489,6 +489,10 @@ struct iwm_softc {
struct iwm_fw_info sc_fw;
struct iwm_tlv_calib_ctrl sc_default_calib[IWM_UCODE_TYPE_MAX];
+#define IWM_MAX_FW_CMD_VERSIONS 64
+ struct iwm_fw_cmd_version cmd_versions[IWM_MAX_FW_CMD_VERSIONS];
+ int n_cmd_versions;
+
const struct iwm_cfg *cfg;
struct iwm_nvm_data *nvm_data;
struct iwm_phy_db *sc_phy_db;