]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: iwlwifi: mld: change cluster_id type to u8 array
authorBenjamin Berg <benjamin.berg@intel.com>
Sun, 11 Jan 2026 17:39:24 +0000 (19:39 +0200)
committerMiri Korenblit <miriam.rachel.korenblit@intel.com>
Wed, 21 Jan 2026 12:23:03 +0000 (14:23 +0200)
While the cluster_id is two bytes long, it is just the last two bytes of
the cluster ID MAC address. This does not really map to a big or little
endian data type. Switch it to use an array to avoid confusion and
adjust all users so that they do the right thing independent of
endianness.

Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Reviewed-by: Ilan Peer <ilan.peer@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20260111193638.80921dc7d305.I56c2bbe0bfc6ee02782bc5d69fda2ac77f3502c4@changeid
drivers/net/wireless/intel/iwlwifi/fw/api/mac-cfg.h
drivers/net/wireless/intel/iwlwifi/mld/nan.c

index f260115abc5ab5ae9d01cbfa8a66c88261ab5646..c7a833f8041a04b411662625713a840f81b81bac 100644 (file)
@@ -1057,7 +1057,8 @@ enum iwl_nan_flags {
  * @nmi_addr: NAN Management Interface (NMI) address
  * @reserved_for_nmi_addr: reserved
  * @discovery_beacon_interval: discovery beacon interval in TUs
- * @cluster_id: local cluster ID, in case the local device starts a cluster
+ * @cluster_id: lower last two bytes of the cluster ID, in case the local
+ *     device starts a cluster
  * @sta_id: station ID of the NAN station
  * @hb_channel: channel for 5 GHz if the device supports operation on 5 GHz.
  *     Valid values are 44 and 149, which correspond to the 5 GHz channel, and
@@ -1082,7 +1083,7 @@ struct iwl_nan_config_cmd {
        __le16 reserved_for_nmi_addr;
        __le32 discovery_beacon_interval;
 
-       __le16 cluster_id;
+       u8 cluster_id[2];
        u8 sta_id;
        u8 hb_channel;
 
@@ -1113,12 +1114,12 @@ enum iwl_nan_cluster_notif_flags {
  * struct iwl_nan_cluster_notif - event sent when the device starts or joins a
  *     NAN cluster.
  *
- * @cluster_id: cluster ID
+ * @cluster_id: the last two bytes of the cluster ID
  * @flags: combination of &enum iwl_nan_cluster_notif_flags
  * @reserved: reserved
  */
 struct iwl_nan_cluster_notif {
-       __le16 cluster_id;
+       u8 cluster_id[2];
        u8 flags;
        u8 reserved;
 }; /* NAN_JOINED_CLUSTER_NTF_API_S_VER_1 */
index d4298f44baf77df39f182820d817e45e26b85bb6..2dbd3d58b0c6200af8b18835e03cc00a411f0e0e 100644 (file)
@@ -55,8 +55,8 @@ static int iwl_mld_nan_config(struct iwl_mld *mld,
        cmd.master_pref = conf->master_pref;
 
        if (conf->cluster_id)
-               cmd.cluster_id =
-                       cpu_to_le16(*(const u16 *)(conf->cluster_id + 4));
+               memcpy(cmd.cluster_id, conf->cluster_id + 4,
+                      sizeof(cmd.cluster_id));
 
        cmd.scan_period = conf->scan_period < 255 ? conf->scan_period : 255;
        cmd.dwell_time =
@@ -215,14 +215,14 @@ void iwl_mld_handle_nan_cluster_notif(struct iwl_mld *mld,
                ieee80211_vif_to_wdev(mld->nan_device_vif) : NULL;
        bool new_cluster = !!(notif->flags &
                              IWL_NAN_CLUSTER_NOTIF_FLAG_NEW_CLUSTER);
-       u8 cluster_id[ETH_ALEN] __aligned(2) = {
-               0x50, 0x6f, 0x9a, 0x01, 0x00, 0x00
+       u8 cluster_id[ETH_ALEN] = {
+               0x50, 0x6f, 0x9a, 0x01,
+               notif->cluster_id[0], notif->cluster_id[1]
        };
-       u16 id = le16_to_cpu(notif->cluster_id);
 
        IWL_DEBUG_INFO(mld,
-                      "NAN: cluster event: cluster_id=0x%x, flags=0x%x\n",
-                      id, notif->flags);
+                      "NAN: cluster event: cluster_id=%pM, flags=0x%x\n",
+                      cluster_id, notif->flags);
 
        if (IWL_FW_CHECK(mld, !wdev, "NAN: cluster event without wdev\n"))
                return;
@@ -231,8 +231,6 @@ void iwl_mld_handle_nan_cluster_notif(struct iwl_mld *mld,
                         "NAN: cluster event without NAN started\n"))
                return;
 
-       *((u16 *)(cluster_id + 4)) = id;
-
        cfg80211_nan_cluster_joined(wdev, cluster_id, new_cluster, GFP_KERNEL);
 }