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) <noreply@anthropic.com>
This commit is contained in:
2026-07-28 21:04:18 +09:00
parent 127ab70fbb
commit 0114504158
@@ -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;
}