]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
wifi: iwlwifi: mld: add monitor internal station
authorDaniel Gabay <daniel.gabay@intel.com>
Wed, 30 Apr 2025 12:57:23 +0000 (15:57 +0300)
committerMiri Korenblit <miriam.rachel.korenblit@intel.com>
Tue, 6 May 2025 19:22:11 +0000 (22:22 +0300)
This is needed for TX injection over monitor interface.

Signed-off-by: Daniel Gabay <daniel.gabay@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20250430155443.5ec460d3f1c2.Ic8456efb4cdd722dcd9c4910a1569ef9d3e4e066@changeid
drivers/net/wireless/intel/iwlwifi/mld/link.c
drivers/net/wireless/intel/iwlwifi/mld/link.h
drivers/net/wireless/intel/iwlwifi/mld/mac80211.c
drivers/net/wireless/intel/iwlwifi/mld/sta.c
drivers/net/wireless/intel/iwlwifi/mld/sta.h
drivers/net/wireless/intel/iwlwifi/mld/tx.c

index 82a4979a3af3c90b7bb41eb8d5b3fe21d4e773c2..fa822b748791282254571bd36d1a4b3157302360 100644 (file)
@@ -783,6 +783,7 @@ iwl_mld_init_link(struct iwl_mld *mld, struct ieee80211_bss_conf *link,
        iwl_mld_init_internal_sta(&mld_link->bcast_sta);
        iwl_mld_init_internal_sta(&mld_link->mcast_sta);
        iwl_mld_init_internal_sta(&mld_link->aux_sta);
+       iwl_mld_init_internal_sta(&mld_link->mon_sta);
 
        wiphy_delayed_work_init(&mld_link->rx_omi.finished_work,
                                iwl_mld_omi_bw_finished_work);
index 42b7bdcbd741210f0943107f7da04e8736e47f0d..40492f0974e2620c6d3d1fe19f75b90a209cfc68 100644 (file)
@@ -40,6 +40,7 @@ struct iwl_probe_resp_data {
  * @bcast_sta: station used for broadcast packets. Used in AP, GO and IBSS.
  * @mcast_sta: station used for multicast packets. Used in AP, GO and IBSS.
  * @aux_sta: station used for remain on channel. Used in P2P device.
+ * @mon_sta: station used for TX injection in monitor interface.
  * @link_id: over the air link ID
  * @ap_early_keys: The firmware cannot install keys before bcast/mcast STAs,
  *     but higher layers work differently, so we store the keys here for
@@ -73,6 +74,7 @@ struct iwl_mld_link {
        struct iwl_mld_int_sta bcast_sta;
        struct iwl_mld_int_sta mcast_sta;
        struct iwl_mld_int_sta aux_sta;
+       struct iwl_mld_int_sta mon_sta;
        u8 link_id;
 
        struct {
@@ -107,6 +109,8 @@ iwl_mld_cleanup_link(struct iwl_mld *mld, struct iwl_mld_link *link)
                iwl_mld_free_internal_sta(mld, &link->mcast_sta);
        if (link->aux_sta.sta_id != IWL_INVALID_STA)
                iwl_mld_free_internal_sta(mld, &link->aux_sta);
+       if (link->mon_sta.sta_id != IWL_INVALID_STA)
+               iwl_mld_free_internal_sta(mld, &link->mon_sta);
 }
 
 /* Convert a percentage from [0,100] to [0,255] */
index ef976e4d700fd8785245d90ef9c8b2a6f365400e..b64e3f290e71e0eb58f911f2cb33ab24c02e1101 100644 (file)
@@ -1021,12 +1021,19 @@ int iwl_mld_assign_vif_chanctx(struct ieee80211_hw *hw,
                iwl_mld_send_ap_tx_power_constraint_cmd(mld, vif, link);
 
        if (vif->type == NL80211_IFTYPE_MONITOR) {
-               /* TODO: task=sniffer add sniffer station */
+               ret = iwl_mld_add_mon_sta(mld, vif, link);
+               if (ret)
+                       goto deactivate_link;
+
                mld->monitor.p80 =
                        iwl_mld_chandef_get_primary_80(&vif->bss_conf.chanreq.oper);
        }
 
        return 0;
+
+deactivate_link:
+       if (mld_link->active)
+               iwl_mld_deactivate_link(mld, link);
 err:
        RCU_INIT_POINTER(mld_link->chan_ctx, NULL);
        return ret;
@@ -1052,7 +1059,8 @@ void iwl_mld_unassign_vif_chanctx(struct ieee80211_hw *hw,
 
        iwl_mld_deactivate_link(mld, link);
 
-       /* TODO: task=sniffer remove sniffer station */
+       if (vif->type == NL80211_IFTYPE_MONITOR)
+               iwl_mld_remove_mon_sta(mld, vif, link);
 
        if (n_active > 1) {
                /* Indicate to mac80211 that EML is disabled */
index 332a7aecec2d33e23b1a419d36268a9e1ec79299..dfaa885dd1d00222213996fc0560544446e726c0 100644 (file)
@@ -1087,6 +1087,24 @@ int iwl_mld_add_aux_sta(struct iwl_mld *mld,
                                        0, NULL, IWL_MAX_TID_COUNT);
 }
 
+int iwl_mld_add_mon_sta(struct iwl_mld *mld,
+                       struct ieee80211_vif *vif,
+                       struct ieee80211_bss_conf *link)
+{
+       struct iwl_mld_link *mld_link = iwl_mld_link_from_mac80211(link);
+
+       if (WARN_ON(!mld_link))
+               return -EINVAL;
+
+       if (WARN_ON(vif->type != NL80211_IFTYPE_MONITOR))
+               return -EINVAL;
+
+       return iwl_mld_add_internal_sta(mld, &mld_link->mon_sta,
+                                       STATION_TYPE_BCAST_MGMT,
+                                       mld_link->fw_id, NULL,
+                                       IWL_MAX_TID_COUNT);
+}
+
 static void iwl_mld_remove_internal_sta(struct iwl_mld *mld,
                                        struct iwl_mld_int_sta *internal_sta,
                                        bool flush, u8 tid)
@@ -1156,6 +1174,22 @@ void iwl_mld_remove_aux_sta(struct iwl_mld *mld,
                                    IWL_MAX_TID_COUNT);
 }
 
+void iwl_mld_remove_mon_sta(struct iwl_mld *mld,
+                           struct ieee80211_vif *vif,
+                           struct ieee80211_bss_conf *link)
+{
+       struct iwl_mld_link *mld_link = iwl_mld_link_from_mac80211(link);
+
+       if (WARN_ON(!mld_link))
+               return;
+
+       if (WARN_ON(vif->type != NL80211_IFTYPE_MONITOR))
+               return;
+
+       iwl_mld_remove_internal_sta(mld, &mld_link->mon_sta, false,
+                                   IWL_MAX_TID_COUNT);
+}
+
 static int iwl_mld_update_sta_resources(struct iwl_mld *mld,
                                        struct ieee80211_vif *vif,
                                        struct ieee80211_sta *sta,
index ddcffd7b9fde1e7fc18e820d5440ab8f9dfe8108..c45d815d0c73a7d1187e6954429e93f945d4cf7e 100644 (file)
@@ -247,6 +247,10 @@ int iwl_mld_add_mcast_sta(struct iwl_mld *mld,
 int iwl_mld_add_aux_sta(struct iwl_mld *mld,
                        struct iwl_mld_int_sta *internal_sta);
 
+int iwl_mld_add_mon_sta(struct iwl_mld *mld,
+                       struct ieee80211_vif *vif,
+                       struct ieee80211_bss_conf *link);
+
 void iwl_mld_remove_bcast_sta(struct iwl_mld *mld,
                              struct ieee80211_vif *vif,
                              struct ieee80211_bss_conf *link);
@@ -259,6 +263,10 @@ void iwl_mld_remove_aux_sta(struct iwl_mld *mld,
                            struct ieee80211_vif *vif,
                            struct ieee80211_bss_conf *link);
 
+void iwl_mld_remove_mon_sta(struct iwl_mld *mld,
+                           struct ieee80211_vif *vif,
+                           struct ieee80211_bss_conf *link);
+
 int iwl_mld_update_link_stas(struct iwl_mld *mld,
                             struct ieee80211_vif *vif,
                             struct ieee80211_sta *sta,
index 543abe72e4652850da4df9f3343380e61dee146b..f818545fae97cc9492b7787a60ab351699bd3e8a 100644 (file)
@@ -649,8 +649,10 @@ iwl_mld_get_tx_queue_id(struct iwl_mld *mld, struct ieee80211_txq *txq,
                WARN_ON(!ieee80211_is_mgmt(fc));
 
                return mld_vif->deflink.aux_sta.queue_id;
+       case NL80211_IFTYPE_MONITOR:
+               mld_vif = iwl_mld_vif_from_mac80211(info->control.vif);
+               return mld_vif->deflink.mon_sta.queue_id;
        default:
-               /* TODO: consider monitor (task=monitor) */
                WARN_ONCE(1, "Unsupported vif type\n");
                break;
        }