mac80211: fix build with linux kernel 6.6
authorWeijie Gao <hackpascal@gmail.com>
Thu, 29 Feb 2024 15:56:40 +0000 (23:56 +0800)
committerRobert Marko <robimarko@gmail.com>
Mon, 11 Mar 2024 19:17:26 +0000 (20:17 +0100)
Fix build failure with linux kernel 6.6

Related kernel commits:

20b0b53aca43 (genetlink: introduce split op representation)

bffcc6882a1b (genetlink: remove userhdr from struct genl_info)

e9a688bcb193 (random: use rejection sampling for uniform bounded
random integers)

3c202d14a9d7 (prandom: remove prandom_u32_max())

3d2f20ad46f8 (wifi: iwlwifi: Use generic thermal_zone_get_trip()
function)

Signed-off-by: Weijie Gao <hackpascal@gmail.com>
package/kernel/mac80211/patches/build/230-backport_genl_info_userhdr.patch [new file with mode: 0644]
package/kernel/mac80211/patches/build/240-backport_genl_split_ops.patch [new file with mode: 0644]
package/kernel/mac80211/patches/build/250-backport_iwlwifi_thermal.patch [new file with mode: 0644]
package/kernel/mac80211/patches/subsys/301-mac80211-sta-randomize-BA-session-dialog-token-alloc.patch

diff --git a/package/kernel/mac80211/patches/build/230-backport_genl_info_userhdr.patch b/package/kernel/mac80211/patches/build/230-backport_genl_info_userhdr.patch
new file mode 100644 (file)
index 0000000..38f86dc
--- /dev/null
@@ -0,0 +1,32 @@
+--- a/backport-include/net/genetlink.h
++++ b/backport-include/net/genetlink.h
+@@ -3,6 +3,7 @@
+ #include_next <net/genetlink.h>
+ #include <linux/version.h>
++#if LINUX_VERSION_IS_LESS(4,12,0)
+ static inline void __bp_genl_info_userhdr_set(struct genl_info *info,
+                                             void *userhdr)
+ {
+@@ -14,7 +15,6 @@ static inline void *__bp_genl_info_userh
+       return info->userhdr;
+ }
+-#if LINUX_VERSION_IS_LESS(4,12,0)
+ #define GENL_SET_ERR_MSG(info, msg) NL_SET_ERR_MSG(genl_info_extack(info), msg)
+ static inline int genl_err_attr(struct genl_info *info, int err,
+@@ -44,11 +44,13 @@ static inline struct netlink_ext_ack *ge
+ #endif
+ }
++#if LINUX_VERSION_IS_LESS(6,6,0)
+ /* this gets put in place of info->userhdr, since we use that above */
+ static inline void *genl_info_userhdr(struct genl_info *info)
+ {
+       return (u8 *)info->genlhdr + GENL_HDRLEN;
+ }
++#endif
+ #if LINUX_VERSION_IS_LESS(4,10,0)
+ #define __genl_ro_after_init
diff --git a/package/kernel/mac80211/patches/build/240-backport_genl_split_ops.patch b/package/kernel/mac80211/patches/build/240-backport_genl_split_ops.patch
new file mode 100644 (file)
index 0000000..b22804c
--- /dev/null
@@ -0,0 +1,32 @@
+--- a/net/wireless/nl80211.c
++++ b/net/wireless/nl80211.c
+@@ -16442,8 +16442,14 @@ static u32 nl80211_internal_flags[] = {
+ #undef SELECTOR
+ };
++#if LINUX_VERSION_IS_LESS(6,2,0)
+ static int nl80211_pre_doit(const struct genl_ops *ops, struct sk_buff *skb,
+                           struct genl_info *info)
++#else
++static int nl80211_pre_doit(const struct genl_split_ops *ops,
++                          struct sk_buff *skb,
++                          struct genl_info *info)
++#endif
+ {
+       struct cfg80211_registered_device *rdev = NULL;
+       struct wireless_dev *wdev = NULL;
+@@ -16543,8 +16549,14 @@ out_unlock:
+       return err;
+ }
++#if LINUX_VERSION_IS_LESS(6,2,0)
+ static void nl80211_post_doit(const struct genl_ops *ops, struct sk_buff *skb,
+                             struct genl_info *info)
++#else
++static void nl80211_post_doit(const struct genl_split_ops *ops,
++                            struct sk_buff *skb,
++                            struct genl_info *info)
++#endif
+ {
+       u32 internal_flags = nl80211_internal_flags[ops->internal_flags];
diff --git a/package/kernel/mac80211/patches/build/250-backport_iwlwifi_thermal.patch b/package/kernel/mac80211/patches/build/250-backport_iwlwifi_thermal.patch
new file mode 100644 (file)
index 0000000..631fdd7
--- /dev/null
@@ -0,0 +1,160 @@
+--- a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
++++ b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
+@@ -531,7 +531,11 @@ struct iwl_mvm_tt_mgmt {
+  * @tzone: thermal zone device data
+ */
+ struct iwl_mvm_thermal_device {
++#if LINUX_VERSION_IS_LESS(6,6,0)
+       s16 temp_trips[IWL_MAX_DTS_TRIPS];
++#else
++      struct thermal_trip trips[IWL_MAX_DTS_TRIPS];
++#endif
+       u8 fw_trips_index[IWL_MAX_DTS_TRIPS];
+       struct thermal_zone_device *tzone;
+ };
+--- a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
++++ b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
+@@ -573,6 +573,7 @@ int iwl_mvm_send_temp_report_ths_cmd(str
+        * and uncompressed, the FW should get it compressed and sorted
+        */
++#if LINUX_VERSION_IS_LESS(6,6,0)
+       /* compress temp_trips to cmd array, remove uninitialized values*/
+       for (i = 0; i < IWL_MAX_DTS_TRIPS; i++) {
+               if (mvm->tz_device.temp_trips[i] != S16_MIN) {
+@@ -580,6 +581,15 @@ int iwl_mvm_send_temp_report_ths_cmd(str
+                               cpu_to_le16(mvm->tz_device.temp_trips[i]);
+               }
+       }
++#else
++      /* compress trips to cmd array, remove uninitialized values*/
++      for (i = 0; i < IWL_MAX_DTS_TRIPS; i++) {
++              if (mvm->tz_device.trips[i].temperature != INT_MIN) {
++                      cmd.thresholds[idx++] =
++                              cpu_to_le16((s16)(mvm->tz_device.trips[i].temperature / 1000));
++              }
++      }
++#endif
+       cmd.num_temps = cpu_to_le32(idx);
+       if (!idx)
+@@ -593,8 +603,13 @@ int iwl_mvm_send_temp_report_ths_cmd(str
+        */
+       for (i = 0; i < idx; i++) {
+               for (j = 0; j < IWL_MAX_DTS_TRIPS; j++) {
++#if LINUX_VERSION_IS_LESS(6,6,0)
+                       if (le16_to_cpu(cmd.thresholds[i]) ==
+                               mvm->tz_device.temp_trips[j])
++#else
++                      if ((int)(le16_to_cpu(cmd.thresholds[i]) * 1000) ==
++                              mvm->tz_device.trips[j].temperature)
++#endif
+                               mvm->tz_device.fw_trips_index[i] = j;
+               }
+       }
+@@ -638,6 +653,7 @@ out:
+       return ret;
+ }
++#if LINUX_VERSION_IS_LESS(6,6,0)
+ static int iwl_mvm_tzone_get_trip_temp(struct thermal_zone_device *device,
+                                      int trip, int *temp)
+ {
+@@ -661,14 +677,19 @@ static int iwl_mvm_tzone_get_trip_type(s
+       return 0;
+ }
++#endif
+ static int iwl_mvm_tzone_set_trip_temp(struct thermal_zone_device *device,
+                                      int trip, int temp)
+ {
+       struct iwl_mvm *mvm = thermal_zone_device_priv(device);
+       struct iwl_mvm_thermal_device *tzone;
++#if LINUX_VERSION_IS_LESS(6,6,0)
+       int i, ret;
+       s16 temperature;
++#else
++      int ret;
++#endif
+       mutex_lock(&mvm->mutex);
+@@ -678,17 +699,21 @@ static int iwl_mvm_tzone_set_trip_temp(s
+               goto out;
+       }
++#if LINUX_VERSION_IS_LESS(6,6,0)
+       if (trip < 0 || trip >= IWL_MAX_DTS_TRIPS) {
+               ret = -EINVAL;
+               goto out;
+       }
++#endif
+       if ((temp / 1000) > S16_MAX) {
+               ret = -EINVAL;
+               goto out;
+       }
++#if LINUX_VERSION_IS_LESS(6,6,0)
+       temperature = (s16)(temp / 1000);
++#endif
+       tzone = &mvm->tz_device;
+       if (!tzone) {
+@@ -696,6 +721,7 @@ static int iwl_mvm_tzone_set_trip_temp(s
+               goto out;
+       }
++#if LINUX_VERSION_IS_LESS(6,6,0)
+       /* no updates*/
+       if (tzone->temp_trips[trip] == temperature) {
+               ret = 0;
+@@ -711,6 +737,7 @@ static int iwl_mvm_tzone_set_trip_temp(s
+       }
+       tzone->temp_trips[trip] = temperature;
++#endif
+       ret = iwl_mvm_send_temp_report_ths_cmd(mvm);
+ out:
+@@ -720,8 +747,10 @@ out:
+ static  struct thermal_zone_device_ops tzone_ops = {
+       .get_temp = iwl_mvm_tzone_get_temp,
++#if LINUX_VERSION_IS_LESS(6,6,0)
+       .get_trip_temp = iwl_mvm_tzone_get_trip_temp,
+       .get_trip_type = iwl_mvm_tzone_get_trip_type,
++#endif
+       .set_trip_temp = iwl_mvm_tzone_set_trip_temp,
+ };
+@@ -743,7 +772,12 @@ static void iwl_mvm_thermal_zone_registe
+       BUILD_BUG_ON(ARRAY_SIZE(name) >= THERMAL_NAME_LENGTH);
+       sprintf(name, "iwlwifi_%u", atomic_inc_return(&counter) & 0xFF);
++#if LINUX_VERSION_IS_LESS(6,6,0)
+       mvm->tz_device.tzone = thermal_zone_device_register(name,
++#else
++      mvm->tz_device.tzone = thermal_zone_device_register_with_trips(name,
++                                                      mvm->tz_device.trips,
++#endif
+                                                       IWL_MAX_DTS_TRIPS,
+                                                       IWL_WRITABLE_TRIPS_MSK,
+                                                       mvm, &tzone_ops,
+@@ -766,8 +800,15 @@ static void iwl_mvm_thermal_zone_registe
+       /* 0 is a valid temperature,
+        * so initialize the array with S16_MIN which invalid temperature
+        */
++#if LINUX_VERSION_IS_LESS(6,6,0)
+       for (i = 0 ; i < IWL_MAX_DTS_TRIPS; i++)
+               mvm->tz_device.temp_trips[i] = S16_MIN;
++#else
++      for (i = 0 ; i < IWL_MAX_DTS_TRIPS; i++) {
++              mvm->tz_device.trips[i].temperature = INT_MIN;
++              mvm->tz_device.trips[i].type = THERMAL_TRIP_PASSIVE;
++      }
++#endif
+ }
+ static int iwl_mvm_tcool_get_max_state(struct thermal_cooling_device *cdev,
index ec1e1d12ebbd674dc69dc9213f42b1f1ede0a0a2..1034e2c928fd2205986493c5dc48ae102fa61cfb 100644 (file)
@@ -28,11 +28,15 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
 
 --- a/net/mac80211/sta_info.c
 +++ b/net/mac80211/sta_info.c
-@@ -561,6 +561,7 @@ __sta_info_alloc(struct ieee80211_sub_if
+@@ -561,6 +561,11 @@ __sta_info_alloc(struct ieee80211_sub_if
        INIT_WORK(&sta->drv_deliver_wk, sta_deliver_ps_frames);
        INIT_WORK(&sta->ampdu_mlme.work, ieee80211_ba_session_work);
        mutex_init(&sta->ampdu_mlme.mtx);
++#if LINUX_VERSION_IS_LESS(6,2,0)
 +      sta->ampdu_mlme.dialog_token_allocator = prandom_u32_max(U8_MAX);
++#else
++      sta->ampdu_mlme.dialog_token_allocator = get_random_u32_below(U8_MAX);
++#endif
  #ifdef CPTCFG_MAC80211_MESH
        if (ieee80211_vif_is_mesh(&sdata->vif)) {
                sta->mesh = kzalloc(sizeof(*sta->mesh), gfp);