[RFC PATCH] wifi: iwlwifi: mei: tell user space when CSME needs a DHCP refresh
From: Andrei Rusu de Castro
Date: Mon Nov 16 2026 - 11:42:20 EST
CSME shares the host's IPv4 address and learns it from the host's DHCP
exchange: iwlmei copies the host's DHCP requests to CSME, and CSME's
filters pass the replies to it. When AMT's wireless is switched back on
while the host owns the NIC, CSME redoes the SAP setup within a fraction
of a second, then waits about 28 seconds, sends
SAP_MSG_NOTIF_TRIGGER_IP_REFRESH, which iwlmei ignores, and without a
refresh falls back to a lease of its own 20-30 seconds later. AMT is
unreachable for 44-57 seconds after the switch.
Only the DHCP client in user space can refresh the lease, so add an
ip_refresh op to iwlmei and have iwlmvm send a new Intel vendor event,
IWL_MVM_VENDOR_CMD_IP_REFRESH_EVENT, on the station interface. iwlmei
calls it when CSME asks for a refresh, and as soon as CSME's filters pass
a DHCP reply after its wireless was enabled: the first filter sets CSME
sends then do not (four of the five it sent in one traced switch), and a
refresh before that shows CSME the request but not the reply.
The vendor event follows the existing iwlmei interface to user space
(IWL_MVM_VENDOR_CMD_ROAMING_FORBIDDEN_EVENT, with the same
IWL_MVM_VENDOR_ATTR_VIF_ADDR attribute), so a user space that already
listens to these events needs nothing new to find it. The value 0x3c
follows the last command of Intel's backport tree (0x3b) to avoid a
collision. A uevent on the netdev would add a new kind of interface for
one driver, and the driver cannot refresh the lease itself: SAP has no
message to hand CSME the address. No upstream DHCP client listens to
iwlmei's vendor events yet; tested with a small listener on the nl80211
vendor multicast group that renews the lease through NetworkManager.
Tested on an HP ZBook Firefly 14 G10 (AX211, CSME 16.1): after AMT's
wireless was switched off and on while the host was connected, the event
arrived 1.7-2.0 s after the switch and AMT answered over Wi-Fi 6.0-7.3 s
after it (each probe includes AMT's TLS handshake of about 1 s), instead
of 44-57 s; the host stayed associated.
Signed-off-by: Andrei Rusu de Castro <arc@empyreal.works>
---
RFC because this adds a value to the Intel vendor command list in
include/uapi/linux/nl80211-vnd-intel.h, and no upstream user space
consumes iwlmei's vendor events yet. If you would rather have this
reported another way (or a different value than 0x3c), I'll rework it.
Applies to iwlwifi-next. IWLMEI depends on BROKEN; it builds with
CONFIG_WERROR only together with [1], and binds only with [2]:
[1] https://lore.kernel.org/r/20261116-iwlmei-nvm-const-0c16d1de@empyreal.works
[2] https://lore.kernel.org/r/20261116-mei-cl-dma-parent-60802f47@empyreal.works
.../net/wireless/intel/iwlwifi/mei/iwl-mei.h | 3 +
drivers/net/wireless/intel/iwlwifi/mei/main.c | 68 +++++++++++++++++++
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h | 2 +
drivers/net/wireless/intel/iwlwifi/mvm/ops.c | 11 +++
.../wireless/intel/iwlwifi/mvm/vendor-cmd.c | 24 +++++++
include/uapi/linux/nl80211-vnd-intel.h | 7 ++
6 files changed, 115 insertions(+)
diff --git a/drivers/net/wireless/intel/iwlwifi/mei/iwl-mei.h b/drivers/net/wireless/intel/iwlwifi/mei/iwl-mei.h
index 2081775e0ec9..7f4db53fa2f0 100644
--- a/drivers/net/wireless/intel/iwlwifi/mei/iwl-mei.h
+++ b/drivers/net/wireless/intel/iwlwifi/mei/iwl-mei.h
@@ -307,6 +307,8 @@ enum iwl_mei_sap_version {
* when the SAP connection is re-established.
* @nic_stolen: this means that device is no longer available. The device can
* still be used until the callback returns.
+ * @ip_refresh: CSME needs the host to refresh its DHCP lease, so that CSME
+ * learns the IPv4 address it shares with the host.
*/
struct iwl_mei_ops {
void (*me_conn_status)(void *priv,
@@ -315,6 +317,7 @@ struct iwl_mei_ops {
void (*roaming_forbidden)(void *priv, bool forbidden);
void (*sap_connected)(void *priv);
void (*nic_stolen)(void *priv);
+ void (*ip_refresh)(void *priv);
};
#if IS_ENABLED(CONFIG_IWLMEI)
diff --git a/drivers/net/wireless/intel/iwlwifi/mei/main.c b/drivers/net/wireless/intel/iwlwifi/mei/main.c
index ce92e26c42d7..aa7f0728379a 100644
--- a/drivers/net/wireless/intel/iwlwifi/mei/main.c
+++ b/drivers/net/wireless/intel/iwlwifi/mei/main.c
@@ -149,6 +149,8 @@ struct iwl_mei_filters {
* @filters: the filters sent by CSME
* @got_ownership: true if we own the device
* @amt_enabled: true if CSME has wireless enabled
+ * @ip_refresh_on_filters: refresh the host's DHCP lease once CSME's filters
+ * pass a DHCP reply to CSME, after CSME's wireless was enabled
* @csa_throttled: when true, we can't send CHECK_SHARED_AREA over the MEI
* bus, but rather need to wait until send_csa_msg_wk runs
* @csme_taking_ownership: true when CSME is taking ownership. Used to remember
@@ -180,6 +182,7 @@ struct iwl_mei {
struct iwl_mei_filters __rcu *filters;
bool got_ownership;
bool amt_enabled;
+ bool ip_refresh_on_filters;
bool csa_throttled;
bool csme_taking_ownership;
bool link_prot_state;
@@ -692,6 +695,57 @@ iwl_mei_handle_rx_start_ok(struct mei_cl_device *cldev,
mutex_unlock(&iwl_mei_mutex);
}
+/*
+ * CSME shares the host's IPv4 address and learns it by watching the host's
+ * DHCP exchange: iwlmei copies the host's DHCP requests to CSME, and CSME's
+ * filters pass the replies to it. Without a fresh exchange CSME only falls
+ * back to a lease of its own after a timeout, so have the op mode ask the
+ * DHCP client in user space to refresh the lease: when CSME asks for it, and
+ * as soon as CSME's filters pass a DHCP reply after its wireless was enabled
+ * (the first filters it sends then do not yet).
+ */
+static void iwl_mei_request_ip_refresh(struct mei_cl_device *cldev)
+{
+ if (!iwl_mei_cache.ops || !iwl_mei_cache.ops->ip_refresh)
+ return;
+
+ dev_dbg(&cldev->dev, "Asking for an IP refresh\n");
+ iwl_mei_cache.ops->ip_refresh(iwl_mei_cache.priv);
+}
+
+static void iwl_mei_handle_ip_refresh(struct mei_cl_device *cldev,
+ const struct iwl_sap_hdr *hdr)
+{
+ struct iwl_mei *mei = mei_cldev_get_drvdata(cldev);
+
+ mei->ip_refresh_on_filters = false;
+ iwl_mei_request_ip_refresh(cldev);
+}
+
+/* Whether a DHCP reply (UDP from port 67 to port 68) reaches CSME. */
+static bool iwl_mei_filters_pass_dhcp_reply(const struct iwl_sap_oob_filters *filters)
+{
+ const struct iwl_sap_flex_filter *filt;
+
+ for (filt = &filters->flex_filters[0];
+ filt < &filters->flex_filters[0] + ARRAY_SIZE(filters->flex_filters);
+ filt++) {
+ if (!(filt->flags & SAP_FLEX_FILTER_ENABLED))
+ break;
+
+ if (filt->flags & SAP_FLEX_FILTER_TCP)
+ continue;
+
+ if ((filt->src_port && filt->src_port != cpu_to_be16(67)) ||
+ (filt->dst_port && filt->dst_port != cpu_to_be16(68)))
+ continue;
+
+ return true;
+ }
+
+ return false;
+}
+
static void iwl_mei_handle_csme_filters(struct mei_cl_device *cldev,
const struct iwl_sap_csme_filters *filters)
{
@@ -714,6 +768,17 @@ static void iwl_mei_handle_csme_filters(struct mei_cl_device *cldev,
if (old_filters)
kfree_rcu(old_filters, rcu_head);
+
+ if (mei->ip_refresh_on_filters) {
+ bool pass = iwl_mei_filters_pass_dhcp_reply(&filters->filters);
+
+ dev_dbg(&cldev->dev, "CSME filters %s DHCP replies\n",
+ pass ? "pass" : "do not yet pass");
+ if (pass) {
+ mei->ip_refresh_on_filters = false;
+ iwl_mei_request_ip_refresh(cldev);
+ }
+ }
}
static void
@@ -826,6 +891,8 @@ static void iwl_mei_handle_amt_state(struct mei_cl_device *cldev,
mei->amt_enabled = dw->val;
+ mei->ip_refresh_on_filters = mei->amt_enabled;
+
if (mei->amt_enabled)
iwl_mei_set_init_conf(mei);
else if (iwl_mei_cache.ops)
@@ -1019,6 +1086,7 @@ static void iwl_mei_handle_sap_msg(struct mei_cl_device *cldev,
iwl_mei_handle_csme_taking_ownership, 0);
SAP_MSG_HANDLER(PLDR_ACK, iwl_mei_handle_pldr_ack,
sizeof(struct iwl_sap_pldr_ack_data));
+ SAP_MSG_HANDLER(TRIGGER_IP_REFRESH, iwl_mei_handle_ip_refresh, 0);
default:
/*
* This is not really an error, there are message that we decided
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
index ae2ee8771f16..0883d2ee5c11 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
@@ -2683,6 +2683,8 @@ static inline bool iwl_mvm_mei_filter_scan(struct iwl_mvm *mvm,
return false;
}
+void iwl_mvm_send_ip_refresh_event(struct iwl_mvm *mvm,
+ struct ieee80211_vif *vif);
void iwl_mvm_send_roaming_forbidden_event(struct iwl_mvm *mvm,
struct ieee80211_vif *vif,
bool forbidden);
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
index 183251457361..84cc2944ca8f 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
@@ -1185,12 +1185,23 @@ static void iwl_mvm_mei_nic_stolen(void *priv)
rtnl_unlock();
}
+static void iwl_mvm_mei_ip_refresh(void *priv)
+{
+ struct iwl_mvm *mvm = priv;
+
+ if (!mvm->hw_registered || !mvm->csme_vif)
+ return;
+
+ iwl_mvm_send_ip_refresh_event(mvm, mvm->csme_vif);
+}
+
static const struct iwl_mei_ops mei_ops = {
.me_conn_status = iwl_mvm_me_conn_status,
.rfkill = iwl_mvm_mei_rfkill,
.roaming_forbidden = iwl_mvm_mei_roaming_forbidden,
.sap_connected = iwl_mvm_mei_sap_connected,
.nic_stolen = iwl_mvm_mei_nic_stolen,
+ .ip_refresh = iwl_mvm_mei_ip_refresh,
};
static struct iwl_op_mode *
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/vendor-cmd.c b/drivers/net/wireless/intel/iwlwifi/mvm/vendor-cmd.c
index 0f7fa6032c66..dda79feb7949 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/vendor-cmd.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/vendor-cmd.c
@@ -106,6 +106,7 @@ static const struct wiphy_vendor_command iwl_mvm_vendor_commands[] = {
enum iwl_mvm_vendor_events_idx {
/* 0x0 - 0x3 are deprecated */
IWL_MVM_VENDOR_EVENT_IDX_ROAMING_FORBIDDEN = 4,
+ IWL_MVM_VENDOR_EVENT_IDX_IP_REFRESH,
NUM_IWL_MVM_VENDOR_EVENT_IDX
};
@@ -115,6 +116,10 @@ iwl_mvm_vendor_events[NUM_IWL_MVM_VENDOR_EVENT_IDX] = {
.vendor_id = INTEL_OUI,
.subcmd = IWL_MVM_VENDOR_CMD_ROAMING_FORBIDDEN_EVENT,
},
+ [IWL_MVM_VENDOR_EVENT_IDX_IP_REFRESH] = {
+ .vendor_id = INTEL_OUI,
+ .subcmd = IWL_MVM_VENDOR_CMD_IP_REFRESH_EVENT,
+ },
};
void iwl_mvm_vendor_cmds_register(struct iwl_mvm *mvm)
@@ -125,6 +130,25 @@ void iwl_mvm_vendor_cmds_register(struct iwl_mvm *mvm)
mvm->hw->wiphy->n_vendor_events = ARRAY_SIZE(iwl_mvm_vendor_events);
}
+void iwl_mvm_send_ip_refresh_event(struct iwl_mvm *mvm,
+ struct ieee80211_vif *vif)
+{
+ struct sk_buff *msg =
+ cfg80211_vendor_event_alloc(mvm->hw->wiphy,
+ ieee80211_vif_to_wdev(vif),
+ 100, IWL_MVM_VENDOR_EVENT_IDX_IP_REFRESH,
+ GFP_KERNEL);
+ if (!msg)
+ return;
+
+ if (nla_put(msg, IWL_MVM_VENDOR_ATTR_VIF_ADDR, ETH_ALEN, vif->addr)) {
+ kfree_skb(msg);
+ return;
+ }
+
+ cfg80211_vendor_event(msg, GFP_KERNEL);
+}
+
void iwl_mvm_send_roaming_forbidden_event(struct iwl_mvm *mvm,
struct ieee80211_vif *vif,
bool forbidden)
diff --git a/include/uapi/linux/nl80211-vnd-intel.h b/include/uapi/linux/nl80211-vnd-intel.h
index 79ccc9401d50..f95abb1fd405 100644
--- a/include/uapi/linux/nl80211-vnd-intel.h
+++ b/include/uapi/linux/nl80211-vnd-intel.h
@@ -45,12 +45,19 @@
* @IWL_MVM_VENDOR_CMD_ROAMING_FORBIDDEN_EVENT: notifies if roaming is allowed.
* It contains a &IWL_MVM_VENDOR_ATTR_ROAMING_FORBIDDEN and a
* &IWL_MVM_VENDOR_ATTR_VIF_ADDR attributes.
+ * @IWL_MVM_VENDOR_CMD_IP_REFRESH_EVENT: the CSME firmware needs the host to
+ * refresh its DHCP lease on the interface with the
+ * &IWL_MVM_VENDOR_ATTR_VIF_ADDR attribute. The CSME firmware shares the
+ * host's IPv4 address and learns it from the host's DHCP exchange; without
+ * a refresh it falls back to a lease of its own after a timeout. The user
+ * space DHCP client should renew the lease when it receives this event.
*/
enum iwl_mvm_vendor_cmd {
IWL_MVM_VENDOR_CMD_GET_CSME_CONN_INFO = 0x2d,
IWL_MVM_VENDOR_CMD_HOST_GET_OWNERSHIP = 0x30,
IWL_MVM_VENDOR_CMD_ROAMING_FORBIDDEN_EVENT = 0x32,
+ IWL_MVM_VENDOR_CMD_IP_REFRESH_EVENT = 0x3c,
};
enum iwl_vendor_auth_akm_mode {
--
2.55.0