]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: iwlwifi: mld: make iwl_mvm_find_ie_offset a iwlwifi util
authorMiri Korenblit <miriam.rachel.korenblit@intel.com>
Sat, 28 Dec 2024 20:34:05 +0000 (22:34 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 13 Jan 2025 14:26:39 +0000 (15:26 +0100)
This is needed also for more opmodes, and is really not opmode dependent.
Make it a iwlwifi util.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Link: https://patch.msgid.link/20241228223206.a36373eefbf2.Ib1f305b78508c98934f6000720d6455c88a860cb@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/intel/iwlwifi/iwl-utils.h
drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h

index e3dbe6376036c72fe46c00d4da9694c893f05805..8f1f11d06fbe1cf1439fdc969fa96a156169e144 100644 (file)
@@ -5,6 +5,8 @@
 #ifndef __iwl_utils_h__
 #define __iwl_utils_h__
 
+#include <net/cfg80211.h>
+
 #ifdef CONFIG_INET
 /**
  * iwl_tx_tso_segment - Segments a TSO packet into subframes for A-MSDU.
@@ -33,4 +35,22 @@ int iwl_tx_tso_segment(struct sk_buff *skb, unsigned int num_subframes,
 }
 #endif /* CONFIG_INET */
 
+static inline
+u32 iwl_find_ie_offset(u8 *beacon, u8 eid, u32 frame_size)
+{
+       struct ieee80211_mgmt *mgmt = (void *)beacon;
+       const u8 *ie;
+
+       if (WARN_ON_ONCE(frame_size <= (mgmt->u.beacon.variable - beacon)))
+               return 0;
+
+       frame_size -= mgmt->u.beacon.variable - beacon;
+
+       ie = cfg80211_find_ie(eid, mgmt->u.beacon.variable, frame_size);
+       if (!ie)
+               return 0;
+
+       return ie - beacon;
+}
+
 #endif /* __iwl_utils_h__ */
index 7fbfec6750c19dce57f1483dca23d4c213526d62..b8ae860390457bf3978efbb2c96aba4c7883a900 100644 (file)
@@ -16,6 +16,7 @@
 #include "debugfs.h"
 #include "iwl-modparams.h"
 #include "iwl-drv.h"
+#include "iwl-utils.h"
 #include "fw/error-dump.h"
 #include "fw/api/phy-ctxt.h"
 
@@ -1413,9 +1414,9 @@ static int _iwl_dbgfs_inject_beacon_ie(struct iwl_mvm *mvm, char *bin, int len)
 
                if (iwl_fw_lookup_cmd_ver(mvm->fw,
                                          BEACON_TEMPLATE_CMD, 0) >= 14) {
-                       u32 offset = iwl_mvm_find_ie_offset(beacon->data,
-                                                           WLAN_EID_S1G_TWT,
-                                                           beacon->len);
+                       u32 offset = iwl_find_ie_offset(beacon->data,
+                                                       WLAN_EID_S1G_TWT,
+                                                       beacon->len);
 
                        beacon_cmd.btwt_offset = cpu_to_le32(offset);
                }
index 51ee62ae70fbc9e699eaca78891ff73bcd6cef52..bbf0f2753f9fc1181802189cb7ae22ec73cf8462 100644 (file)
@@ -12,6 +12,7 @@
 #include "fw-api.h"
 #include "mvm.h"
 #include "time-event.h"
+#include "iwl-utils.h"
 
 const u8 iwl_mvm_ac_to_tx_fifo[] = {
        IWL_MVM_TX_FIFO_VO,
@@ -868,23 +869,6 @@ void iwl_mvm_mac_ctxt_set_tim(struct iwl_mvm *mvm,
        }
 }
 
-u32 iwl_mvm_find_ie_offset(u8 *beacon, u8 eid, u32 frame_size)
-{
-       struct ieee80211_mgmt *mgmt = (void *)beacon;
-       const u8 *ie;
-
-       if (WARN_ON_ONCE(frame_size <= (mgmt->u.beacon.variable - beacon)))
-               return 0;
-
-       frame_size -= mgmt->u.beacon.variable - beacon;
-
-       ie = cfg80211_find_ie(eid, mgmt->u.beacon.variable, frame_size);
-       if (!ie)
-               return 0;
-
-       return ie - beacon;
-}
-
 u8 iwl_mvm_mac_ctxt_get_lowest_rate(struct iwl_mvm *mvm,
                                    struct ieee80211_tx_info *info,
                                    struct ieee80211_vif *vif)
@@ -1078,13 +1062,13 @@ static int iwl_mvm_mac_ctxt_send_beacon_v7(struct iwl_mvm *mvm,
                                         beacon->data, beacon->len);
 
        beacon_cmd.csa_offset =
-               cpu_to_le32(iwl_mvm_find_ie_offset(beacon->data,
-                                                  WLAN_EID_CHANNEL_SWITCH,
-                                                  beacon->len));
+               cpu_to_le32(iwl_find_ie_offset(beacon->data,
+                                              WLAN_EID_CHANNEL_SWITCH,
+                                              beacon->len));
        beacon_cmd.ecsa_offset =
-               cpu_to_le32(iwl_mvm_find_ie_offset(beacon->data,
-                                                  WLAN_EID_EXT_CHANSWITCH_ANN,
-                                                  beacon->len));
+               cpu_to_le32(iwl_find_ie_offset(beacon->data,
+                                              WLAN_EID_EXT_CHANSWITCH_ANN,
+                                              beacon->len));
 
        return iwl_mvm_mac_ctxt_send_beacon_cmd(mvm, beacon, &beacon_cmd,
                                                sizeof(beacon_cmd));
@@ -1151,20 +1135,20 @@ static int iwl_mvm_mac_ctxt_send_beacon_v9(struct iwl_mvm *mvm,
                                         beacon->data, beacon->len);
 
        beacon_cmd.csa_offset =
-               cpu_to_le32(iwl_mvm_find_ie_offset(beacon->data,
-                                                  WLAN_EID_CHANNEL_SWITCH,
-                                                  beacon->len));
+               cpu_to_le32(iwl_find_ie_offset(beacon->data,
+                                              WLAN_EID_CHANNEL_SWITCH,
+                                              beacon->len));
        beacon_cmd.ecsa_offset =
-               cpu_to_le32(iwl_mvm_find_ie_offset(beacon->data,
-                                                  WLAN_EID_EXT_CHANSWITCH_ANN,
-                                                  beacon->len));
+               cpu_to_le32(iwl_find_ie_offset(beacon->data,
+                                              WLAN_EID_EXT_CHANSWITCH_ANN,
+                                              beacon->len));
 
        if (vif->type == NL80211_IFTYPE_AP &&
            iwl_fw_lookup_cmd_ver(mvm->fw, BEACON_TEMPLATE_CMD, 0) >= 14)
                beacon_cmd.btwt_offset =
-                       cpu_to_le32(iwl_mvm_find_ie_offset(beacon->data,
-                                                          WLAN_EID_S1G_TWT,
-                                                          beacon->len));
+                       cpu_to_le32(iwl_find_ie_offset(beacon->data,
+                                                      WLAN_EID_S1G_TWT,
+                                                      beacon->len));
 
        return iwl_mvm_mac_ctxt_send_beacon_cmd(mvm, beacon, &beacon_cmd,
                                                sizeof(beacon_cmd));
index dbf32bf5760bfb6cc0594491601866d54c125ad8..43e304f224755b8349fddf7f791c3c5b2b2e0957 100644 (file)
@@ -1819,7 +1819,6 @@ u8 iwl_mvm_next_antenna(struct iwl_mvm *mvm, u8 valid, u8 last_idx);
 void iwl_mvm_get_sync_time(struct iwl_mvm *mvm, int clock_type, u32 *gp2,
                           u64 *boottime, ktime_t *realtime);
 u32 iwl_mvm_get_systime(struct iwl_mvm *mvm);
-u32 iwl_mvm_find_ie_offset(u8 *beacon, u8 eid, u32 frame_size);
 
 /* Tx / Host Commands */
 int __must_check iwl_mvm_send_cmd(struct iwl_mvm *mvm,