wifi: iwlwifi: add MAC context command version 4

Due to NAN additions, this command needs to grow. In iwlmvm
we just need to use the old _v3 (or v2) version, but iwlmld
needs to handle the difference and send both.  Do that as a
first step towards adding NAN support.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20260321192637.5ab609ca1966.I860737f952865bd0b997f1c190c3891864c7c6ba@changeid
This commit is contained in:
Johannes Berg 2026-03-21 19:29:12 +02:00 committed by Miri Korenblit
parent 19a86a3ff3
commit 62e4d33c7d
4 changed files with 81 additions and 20 deletions

View File

@ -34,7 +34,8 @@ enum iwl_mac_conf_subcmd_ids {
*/
CANCEL_CHANNEL_SWITCH_CMD = 0x6,
/**
* @MAC_CONFIG_CMD: &struct iwl_mac_config_cmd
* @MAC_CONFIG_CMD: &struct iwl_mac_config_cmd_v3 or
* &struct iwl_mac_config_cmd
*/
MAC_CONFIG_CMD = 0x8,
/**
@ -357,7 +358,7 @@ struct iwl_mac_wifi_gen_support {
} __packed;
/**
* struct iwl_mac_config_cmd - command structure to configure MAC contexts in
* struct iwl_mac_config_cmd_v3 - command structure to configure MAC contexts in
* MLD API for versions 2 and 3
* ( MAC_CONTEXT_CONFIG_CMD = 0x8 )
*
@ -376,7 +377,7 @@ struct iwl_mac_wifi_gen_support {
* @client: client mac data
* @p2p_dev: mac data for p2p device
*/
struct iwl_mac_config_cmd {
struct iwl_mac_config_cmd_v3 {
__le32 id_and_color;
__le32 action;
/* MAC_CONTEXT_TYPE_API_E */
@ -394,7 +395,62 @@ struct iwl_mac_config_cmd {
struct iwl_mac_client_data client;
struct iwl_mac_p2p_dev_data p2p_dev;
};
} __packed; /* MAC_CONTEXT_CONFIG_CMD_API_S_VER_2_VER_3 */
} __packed; /* MAC_CONTEXT_CONFIG_CMD_API_S_VER_2, _VER_3 */
/**
* struct iwl_mac_nan_data - NAN specific MAC data
* @ndi_addrs: extra NDI addresses being used
* @ndi_addrs_count: number of extra NDI addresses
*/
struct iwl_mac_nan_data {
struct {
u8 addr[ETH_ALEN];
__le16 reserved;
} __packed ndi_addrs[2];
__le32 ndi_addrs_count;
} __packed; /* MAC_CONTEXT_CONFIG_NAN_DATA_API_S_VER_1 */
/**
* struct iwl_mac_config_cmd - command structure to configure MAC contexts in
* MLD API for versions 4
* ( MAC_CONTEXT_CONFIG_CMD = 0x8 )
*
* @id_and_color: ID and color of the MAC
* @action: action to perform, see &enum iwl_ctxt_action
* @mac_type: one of &enum iwl_mac_types
* @local_mld_addr: mld address
* @reserved_for_local_mld_addr: reserved
* @filter_flags: combination of &enum iwl_mac_config_filter_flags
* @wifi_gen_v2: he/eht parameters as in cmd version 2
* @wifi_gen: he/eht/uhr parameters as in cmd version 3
* @nic_not_ack_enabled: mark that the NIC doesn't support receiving
* ACK-enabled AGG, (i.e. both BACK and non-BACK frames in single AGG).
* If the NIC is not ACK_ENABLED it may use the EOF-bit in first non-0
* len delim to determine if AGG or single.
* @client: client mac data
* @p2p_dev: mac data for p2p device
* @nan: NAN specific data (NAN data interface addresses)
*/
struct iwl_mac_config_cmd {
__le32 id_and_color;
__le32 action;
/* MAC_CONTEXT_TYPE_API_E */
__le32 mac_type;
u8 local_mld_addr[6];
__le16 reserved_for_local_mld_addr;
__le32 filter_flags;
union {
struct iwl_mac_wifi_gen_support_v2 wifi_gen_v2;
struct iwl_mac_wifi_gen_support wifi_gen;
};
__le32 nic_not_ack_enabled;
/* MAC_CONTEXT_CONFIG_SPECIFIC_DATA_API_U_VER_3 */
union {
struct iwl_mac_client_data client;
struct iwl_mac_p2p_dev_data p2p_dev;
struct iwl_mac_nan_data nan;
};
} __packed; /* MAC_CONTEXT_CONFIG_CMD_API_S_VER_4 */
/**
* enum iwl_link_ctx_modify_flags - indicate to the fw what fields are being

View File

@ -57,8 +57,7 @@ enum iwl_mac_protection_flags {
* @FW_MAC_TYPE_P2P_DEVICE: P2P Device
* @FW_MAC_TYPE_P2P_STA: P2P client
* @FW_MAC_TYPE_GO: P2P GO
* @FW_MAC_TYPE_TEST: ?
* @FW_MAC_TYPE_MAX: highest support MAC type
* @FW_MAC_TYPE_NAN: NAN (since version 4)
*/
enum iwl_mac_types {
FW_MAC_TYPE_FIRST = 1,
@ -70,8 +69,7 @@ enum iwl_mac_types {
FW_MAC_TYPE_P2P_DEVICE,
FW_MAC_TYPE_P2P_STA,
FW_MAC_TYPE_GO,
FW_MAC_TYPE_TEST,
FW_MAC_TYPE_MAX = FW_MAC_TYPE_TEST
FW_MAC_TYPE_NAN,
}; /* MAC_CONTEXT_TYPE_API_E_VER_1 */
/**

View File

@ -61,13 +61,20 @@ void iwl_mld_cleanup_vif(void *data, u8 *mac, struct ieee80211_vif *vif)
static int iwl_mld_send_mac_cmd(struct iwl_mld *mld,
struct iwl_mac_config_cmd *cmd)
{
u16 cmd_id = WIDE_ID(MAC_CONF_GROUP, MAC_CONFIG_CMD);
int len = sizeof(*cmd);
int ret;
lockdep_assert_wiphy(mld->wiphy);
ret = iwl_mld_send_cmd_pdu(mld,
WIDE_ID(MAC_CONF_GROUP, MAC_CONFIG_CMD),
cmd);
if (iwl_fw_lookup_cmd_ver(mld->fw, cmd_id, 0) < 4) {
if (WARN_ON(cmd->mac_type == cpu_to_le32(FW_MAC_TYPE_NAN)))
return -EINVAL;
len = sizeof(struct iwl_mac_config_cmd_v3);
}
ret = iwl_mld_send_cmd_pdu(mld, cmd_id, cmd, len);
if (ret)
IWL_ERR(mld, "Failed to send MAC_CONFIG_CMD ret = %d\n", ret);

View File

@ -6,7 +6,7 @@
static void iwl_mvm_mld_set_he_support(struct iwl_mvm *mvm,
struct ieee80211_vif *vif,
struct iwl_mac_config_cmd *cmd,
struct iwl_mac_config_cmd_v3 *cmd,
int cmd_ver)
{
if (vif->type == NL80211_IFTYPE_AP) {
@ -24,7 +24,7 @@ static void iwl_mvm_mld_set_he_support(struct iwl_mvm *mvm,
static void iwl_mvm_mld_mac_ctxt_cmd_common(struct iwl_mvm *mvm,
struct ieee80211_vif *vif,
struct iwl_mac_config_cmd *cmd,
struct iwl_mac_config_cmd_v3 *cmd,
u32 action)
{
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
@ -83,7 +83,7 @@ static void iwl_mvm_mld_mac_ctxt_cmd_common(struct iwl_mvm *mvm,
}
static int iwl_mvm_mld_mac_ctxt_send_cmd(struct iwl_mvm *mvm,
struct iwl_mac_config_cmd *cmd)
struct iwl_mac_config_cmd_v3 *cmd)
{
int ret = iwl_mvm_send_cmd_pdu(mvm,
WIDE_ID(MAC_CONF_GROUP, MAC_CONFIG_CMD),
@ -98,7 +98,7 @@ static int iwl_mvm_mld_mac_ctxt_cmd_sta(struct iwl_mvm *mvm,
struct ieee80211_vif *vif,
u32 action, bool force_assoc_off)
{
struct iwl_mac_config_cmd cmd = {};
struct iwl_mac_config_cmd_v3 cmd = {};
WARN_ON(vif->type != NL80211_IFTYPE_STATION);
@ -151,7 +151,7 @@ static int iwl_mvm_mld_mac_ctxt_cmd_listener(struct iwl_mvm *mvm,
struct ieee80211_vif *vif,
u32 action)
{
struct iwl_mac_config_cmd cmd = {};
struct iwl_mac_config_cmd_v3 cmd = {};
WARN_ON(vif->type != NL80211_IFTYPE_MONITOR);
@ -170,7 +170,7 @@ static int iwl_mvm_mld_mac_ctxt_cmd_ibss(struct iwl_mvm *mvm,
struct ieee80211_vif *vif,
u32 action)
{
struct iwl_mac_config_cmd cmd = {};
struct iwl_mac_config_cmd_v3 cmd = {};
WARN_ON(vif->type != NL80211_IFTYPE_ADHOC);
@ -187,7 +187,7 @@ static int iwl_mvm_mld_mac_ctxt_cmd_p2p_device(struct iwl_mvm *mvm,
struct ieee80211_vif *vif,
u32 action)
{
struct iwl_mac_config_cmd cmd = {};
struct iwl_mac_config_cmd_v3 cmd = {};
WARN_ON(vif->type != NL80211_IFTYPE_P2P_DEVICE);
@ -210,7 +210,7 @@ static int iwl_mvm_mld_mac_ctxt_cmd_ap_go(struct iwl_mvm *mvm,
u32 action)
{
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
struct iwl_mac_config_cmd cmd = {};
struct iwl_mac_config_cmd_v3 cmd = {};
WARN_ON(vif->type != NL80211_IFTYPE_AP);
@ -286,7 +286,7 @@ int iwl_mvm_mld_mac_ctxt_changed(struct iwl_mvm *mvm,
int iwl_mvm_mld_mac_ctxt_remove(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
{
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
struct iwl_mac_config_cmd cmd = {
struct iwl_mac_config_cmd_v3 cmd = {
.action = cpu_to_le32(FW_CTXT_ACTION_REMOVE),
.id_and_color = cpu_to_le32(mvmvif->id),
};