From e126a1e4137f5c7fba00e762369eb30a16f8fbf4 Mon Sep 17 00:00:00 2001
From: Christian Lamparter <chunkeey@gmail.com>
Date: Fri, 25 Feb 2022 08:11:36 +0100
Subject: [PATCH] mac80211: add #if guards against 5.4 compile failures

Both struct net_device_path_ctx and struct net_device_path
are not available in 5.4. This causes an build error on the
bcm63xx target.

|mac80211/driver-ops.h: In function 'drv_net_fill_forward_path':
|driver-ops.h:1502:57: error: passing argument 4 of
|'local->ops->net_fill_forward_path' from incompatible pointer type
| [-Werror=incompatible-pointer-types]
| 1502 |                          ctx, path);
|      |                          ^~~
|      |                            |
|      |                         struct net_device_path_ctx *

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
---
 ...dd-support-for-.ndo_fill_forward_path.patch | 18 ++++++++++++------
 ...-introduce-set_radar_offchan-callback.patch |  2 +-
 ...-offchannel_chain-structs-to-backgrou.patch |  2 +-
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/package/kernel/mac80211/patches/subsys/308-mac80211-add-support-for-.ndo_fill_forward_path.patch b/package/kernel/mac80211/patches/subsys/308-mac80211-add-support-for-.ndo_fill_forward_path.patch
index 7764edfb27..2f3c1a2669 100644
--- a/package/kernel/mac80211/patches/subsys/308-mac80211-add-support-for-.ndo_fill_forward_path.patch
+++ b/package/kernel/mac80211/patches/subsys/308-mac80211-add-support-for-.ndo_fill_forward_path.patch
@@ -22,24 +22,27 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
   */
  struct ieee80211_ops {
  	void (*tx)(struct ieee80211_hw *hw,
-@@ -4265,6 +4267,11 @@ struct ieee80211_ops {
+@@ -4265,6 +4267,13 @@ struct ieee80211_ops {
  			      struct ieee80211_twt_setup *twt);
  	void (*twt_teardown_request)(struct ieee80211_hw *hw,
  				     struct ieee80211_sta *sta, u8 flowid);
++#if LINUX_VERSION_IS_GEQ(5,10,0)
 +	int (*net_fill_forward_path)(struct ieee80211_hw *hw,
 +				     struct ieee80211_vif *vif,
 +				     struct ieee80211_sta *sta,
 +				     struct net_device_path_ctx *ctx,
 +				     struct net_device_path *path);
++#endif
  };
  
  /**
 --- a/net/mac80211/driver-ops.h
 +++ b/net/mac80211/driver-ops.h
-@@ -1483,4 +1483,26 @@ static inline void drv_twt_teardown_requ
+@@ -1483,4 +1483,28 @@ static inline void drv_twt_teardown_requ
  	trace_drv_return_void(local);
  }
- 
+
++#if LINUX_VERSION_IS_GEQ(5,10,0)
 +static inline int drv_net_fill_forward_path(struct ieee80211_local *local,
 +					    struct ieee80211_sub_if_data *sdata,
 +					    struct ieee80211_sta *sta,
@@ -61,6 +64,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
 +
 +	return ret;
 +}
++#endif
 +
  #endif /* __MAC80211_DRIVER_OPS */
 --- a/net/mac80211/ieee80211_i.h
@@ -143,7 +147,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  static const struct net_device_ops ieee80211_dataif_8023_ops = {
  #if LINUX_VERSION_IS_LESS(4,10,0)
  	.ndo_change_mtu = __change_mtu,
-@@ -839,7 +899,9 @@ static const struct net_device_ops ieee8
+@@ -839,7 +901,9 @@ static const struct net_device_ops ieee8
  #else
  	.ndo_get_stats64 = bp_ieee80211_get_stats64,
  #endif
@@ -156,16 +160,18 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  static bool ieee80211_iftype_supports_hdr_offload(enum nl80211_iftype iftype)
 --- a/net/mac80211/trace.h
 +++ b/net/mac80211/trace.h
-@@ -2892,6 +2892,13 @@ TRACE_EVENT(drv_twt_teardown_request,
+@@ -2892,6 +2892,15 @@ TRACE_EVENT(drv_twt_teardown_request,
  	)
  );
- 
+
++#if LINUX_VERSION_IS_GEQ(5,10,0)
 +DEFINE_EVENT(sta_event, drv_net_fill_forward_path,
 +	TP_PROTO(struct ieee80211_local *local,
 +		 struct ieee80211_sub_if_data *sdata,
 +		 struct ieee80211_sta *sta),
 +	TP_ARGS(local, sdata, sta)
 +);
++#endif
 +
  #endif /* !__MAC80211_DRIVER_TRACE || TRACE_HEADER_MULTI_READ */
  
diff --git a/package/kernel/mac80211/patches/subsys/319-mac80211-introduce-set_radar_offchan-callback.patch b/package/kernel/mac80211/patches/subsys/319-mac80211-introduce-set_radar_offchan-callback.patch
index 127b86e76d..eb80afbccb 100644
--- a/package/kernel/mac80211/patches/subsys/319-mac80211-introduce-set_radar_offchan-callback.patch
+++ b/package/kernel/mac80211/patches/subsys/319-mac80211-introduce-set_radar_offchan-callback.patch
@@ -35,9 +35,9 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  				     struct ieee80211_sta *sta, u8 flowid);
 +	int (*set_radar_offchan)(struct ieee80211_hw *hw,
 +				 struct cfg80211_chan_def *chandef);
+ #if LINUX_VERSION_IS_GEQ(5,10,0)
  	int (*net_fill_forward_path)(struct ieee80211_hw *hw,
  				     struct ieee80211_vif *vif,
- 				     struct ieee80211_sta *sta,
 --- a/net/mac80211/cfg.c
 +++ b/net/mac80211/cfg.c
 @@ -4344,6 +4344,18 @@ out:
diff --git a/package/kernel/mac80211/patches/subsys/320-cfg80211-rename-offchannel_chain-structs-to-backgrou.patch b/package/kernel/mac80211/patches/subsys/320-cfg80211-rename-offchannel_chain-structs-to-backgrou.patch
index ce4611b145..a73e81bec6 100644
--- a/package/kernel/mac80211/patches/subsys/320-cfg80211-rename-offchannel_chain-structs-to-backgrou.patch
+++ b/package/kernel/mac80211/patches/subsys/320-cfg80211-rename-offchannel_chain-structs-to-backgrou.patch
@@ -107,9 +107,9 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
 -				 struct cfg80211_chan_def *chandef);
 +	int (*set_radar_background)(struct ieee80211_hw *hw,
 +				    struct cfg80211_chan_def *chandef);
+ #if LINUX_VERSION_IS_GEQ(5,10,0)
  	int (*net_fill_forward_path)(struct ieee80211_hw *hw,
  				     struct ieee80211_vif *vif,
- 				     struct ieee80211_sta *sta,
 --- a/include/uapi/linux/nl80211.h
 +++ b/include/uapi/linux/nl80211.h
 @@ -2608,10 +2608,10 @@ enum nl80211_commands {
-- 
2.30.2