From 01145041581a64a4e96d53968700ec49acdde50c Mon Sep 17 00:00:00 2001 From: vasilito Date: Tue, 28 Jul 2026 21:04:18 +0900 Subject: [PATCH] redbear-iwlwifi: recover lost rb_iwlwifi_send_hcmd C definition The firmware host-command dispatch rb_iwlwifi_send_hcmd() was implemented in commit b22fa7e24c but the definition was later lost from linux_port.c while the Rust extern decl + call sites (src/mld/mod.rs) remained -> 'undefined reference to rb_iwlwifi_send_hcmd' at link (cook failed; cargo check passed since it does not link). Restored the function verbatim from b22fa7e24c; all its helpers (rb_iwlwifi_require_transport, rb_iwlwifi_full_init_locked, iwl_pcie_send_cmd, rb_iwl_cmd_hdr, rb_iwlwifi_transport_lock/cmd_cookie) still exist in the current linux_port.c. Verified: linux_port.c compiles and now exports rb_iwlwifi_send_hcmd (T). Co-Authored-By: Claude Opus 4.8 (1M context) --- .../redbear-iwlwifi/source/src/linux_port.c | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/local/recipes/drivers/redbear-iwlwifi/source/src/linux_port.c b/local/recipes/drivers/redbear-iwlwifi/source/src/linux_port.c index 2ee6134e20..27c0d04629 100644 --- a/local/recipes/drivers/redbear-iwlwifi/source/src/linux_port.c +++ b/local/recipes/drivers/redbear-iwlwifi/source/src/linux_port.c @@ -2716,3 +2716,44 @@ int rb_iwlwifi_bridge_tx_submit(const uint8_t *data, size_t len) return 0; } + +/* + * Firmware host-command dispatch (recovered from commit b22fa7e24c "wire + * mac80211 callbacks to firmware command transport"; the definition had been + * lost from linux_port.c while the extern decl + call sites remained in the + * Rust MLD layer, causing an undefined-reference link failure). Signature + * matches the Rust extern in src/mld/mod.rs: (dev, wide_id, payload, len)->i32. + */ +int rb_iwlwifi_send_hcmd(struct pci_dev *dev, unsigned int wide_id, + const void *payload, int len) +{ + struct iwl_trans_pcie *trans; + struct { + struct rb_iwl_cmd_hdr hdr; + u8 data[256]; + } cmd_buf; + int rc; + + if (!dev || !payload || len <= 0 || len > 256) + return -EINVAL; + + mutex_lock(&rb_iwlwifi_transport_lock); + rc = rb_iwlwifi_require_transport(dev, &trans); + if (rc) + goto out; + rc = rb_iwlwifi_full_init_locked(trans, 0, 0, NULL, NULL); + if (rc) + goto out; + + memset(&cmd_buf, 0, sizeof(cmd_buf)); + cmd_buf.hdr.id = wide_id; + cmd_buf.hdr.len = (u32)(sizeof(struct rb_iwl_cmd_hdr) + (unsigned int)len); + cmd_buf.hdr.cookie = (u32)atomic_add_return(1, &rb_iwlwifi_cmd_cookie); + memcpy(cmd_buf.data, payload, (size_t)len); + + rc = iwl_pcie_send_cmd(trans, &cmd_buf, (int)cmd_buf.hdr.len); + +out: + mutex_unlock(&rb_iwlwifi_transport_lock); + return rc; +}