e3872f31f3a1b98f3efadce8efaee4294d2640c1
[librecmc/librecmc.git] /
1 From b345f0637c0042f9e6b78378a32256d90f485774 Mon Sep 17 00:00:00 2001
2 From: Aloka Dixit <quic_alokad@quicinc.com>
3 Date: Mon, 30 Jan 2023 16:12:26 -0800
4 Subject: [PATCH] wifi: cfg80211: include puncturing bitmap in channel switch
5  events
6
7 Add puncturing bitmap in channel switch notifications
8 and corresponding trace functions.
9
10 Signed-off-by: Aloka Dixit <quic_alokad@quicinc.com>
11 Link: https://lore.kernel.org/r/20230131001227.25014-4-quic_alokad@quicinc.com
12 [fix qtnfmac]
13 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
14 ---
15  drivers/net/wireless/ath/ath6kl/cfg80211.c    |  2 +-
16  drivers/net/wireless/marvell/mwifiex/11h.c    |  2 +-
17  .../net/wireless/quantenna/qtnfmac/event.c    |  2 +-
18  include/net/cfg80211.h                        |  6 +++--
19  net/mac80211/cfg.c                            |  5 ++--
20  net/mac80211/mlme.c                           |  4 ++--
21  net/wireless/nl80211.c                        | 20 ++++++++++------
22  net/wireless/trace.h                          | 24 ++++++++++++-------
23  8 files changed, 41 insertions(+), 24 deletions(-)
24
25 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c
26 +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c
27 @@ -1119,7 +1119,7 @@ void ath6kl_cfg80211_ch_switch_notify(st
28                                         NL80211_CHAN_HT20 : NL80211_CHAN_NO_HT);
29  
30         mutex_lock(&vif->wdev.mtx);
31 -       cfg80211_ch_switch_notify(vif->ndev, &chandef, 0);
32 +       cfg80211_ch_switch_notify(vif->ndev, &chandef, 0, 0);
33         mutex_unlock(&vif->wdev.mtx);
34  }
35  
36 --- a/drivers/net/wireless/marvell/mwifiex/11h.c
37 +++ b/drivers/net/wireless/marvell/mwifiex/11h.c
38 @@ -292,6 +292,6 @@ void mwifiex_dfs_chan_sw_work_queue(stru
39         mwifiex_dbg(priv->adapter, MSG,
40                     "indicating channel switch completion to kernel\n");
41         mutex_lock(&priv->wdev.mtx);
42 -       cfg80211_ch_switch_notify(priv->netdev, &priv->dfs_chandef, 0);
43 +       cfg80211_ch_switch_notify(priv->netdev, &priv->dfs_chandef, 0, 0);
44         mutex_unlock(&priv->wdev.mtx);
45  }
46 --- a/drivers/net/wireless/quantenna/qtnfmac/event.c
47 +++ b/drivers/net/wireless/quantenna/qtnfmac/event.c
48 @@ -478,7 +478,7 @@ qtnf_event_handle_freq_change(struct qtn
49                         continue;
50  
51                 mutex_lock(&vif->wdev.mtx);
52 -               cfg80211_ch_switch_notify(vif->netdev, &chandef, 0);
53 +               cfg80211_ch_switch_notify(vif->netdev, &chandef, 0, 0);
54                 mutex_unlock(&vif->wdev.mtx);
55         }
56  
57 --- a/include/net/cfg80211.h
58 +++ b/include/net/cfg80211.h
59 @@ -8325,13 +8325,14 @@ bool cfg80211_reg_can_beacon_relax(struc
60   * @dev: the device which switched channels
61   * @chandef: the new channel definition
62   * @link_id: the link ID for MLO, must be 0 for non-MLO
63 + * @punct_bitmap: the new puncturing bitmap
64   *
65   * Caller must acquire wdev_lock, therefore must only be called from sleepable
66   * driver context!
67   */
68  void cfg80211_ch_switch_notify(struct net_device *dev,
69                                struct cfg80211_chan_def *chandef,
70 -                              unsigned int link_id);
71 +                              unsigned int link_id, u16 punct_bitmap);
72  
73  /*
74   * cfg80211_ch_switch_started_notify - notify channel switch start
75 @@ -8340,6 +8341,7 @@ void cfg80211_ch_switch_notify(struct ne
76   * @link_id: the link ID for MLO, must be 0 for non-MLO
77   * @count: the number of TBTTs until the channel switch happens
78   * @quiet: whether or not immediate quiet was requested by the AP
79 + * @punct_bitmap: the future puncturing bitmap
80   *
81   * Inform the userspace about the channel switch that has just
82   * started, so that it can take appropriate actions (eg. starting
83 @@ -8348,7 +8350,7 @@ void cfg80211_ch_switch_notify(struct ne
84  void cfg80211_ch_switch_started_notify(struct net_device *dev,
85                                        struct cfg80211_chan_def *chandef,
86                                        unsigned int link_id, u8 count,
87 -                                      bool quiet);
88 +                                      bool quiet, u16 punct_bitmap);
89  
90  /**
91   * ieee80211_operating_class_to_band - convert operating class to band
92 --- a/net/mac80211/cfg.c
93 +++ b/net/mac80211/cfg.c
94 @@ -3600,7 +3600,8 @@ static int __ieee80211_csa_finalize(stru
95         if (err)
96                 return err;
97  
98 -       cfg80211_ch_switch_notify(sdata->dev, &sdata->deflink.csa_chandef, 0);
99 +       cfg80211_ch_switch_notify(sdata->dev, &sdata->deflink.csa_chandef, 0,
100 +                                 0);
101  
102         return 0;
103  }
104 @@ -3872,7 +3873,7 @@ __ieee80211_channel_switch(struct wiphy
105  
106         cfg80211_ch_switch_started_notify(sdata->dev,
107                                           &sdata->deflink.csa_chandef, 0,
108 -                                         params->count, params->block_tx);
109 +                                         params->count, params->block_tx, 0);
110  
111         if (changed) {
112                 ieee80211_link_info_change_notify(sdata, &sdata->deflink,
113 --- a/net/mac80211/mlme.c
114 +++ b/net/mac80211/mlme.c
115 @@ -1778,7 +1778,7 @@ static void ieee80211_chswitch_post_beac
116                 return;
117         }
118  
119 -       cfg80211_ch_switch_notify(sdata->dev, &link->reserved_chandef, 0);
120 +       cfg80211_ch_switch_notify(sdata->dev, &link->reserved_chandef, 0, 0);
121  }
122  
123  void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success)
124 @@ -1988,7 +1988,7 @@ ieee80211_sta_process_chanswitch(struct
125         mutex_unlock(&local->mtx);
126  
127         cfg80211_ch_switch_started_notify(sdata->dev, &csa_ie.chandef, 0,
128 -                                         csa_ie.count, csa_ie.mode);
129 +                                         csa_ie.count, csa_ie.mode, 0);
130  
131         if (local->ops->channel_switch) {
132                 /* use driver's channel switch callback */
133 --- a/net/wireless/nl80211.c
134 +++ b/net/wireless/nl80211.c
135 @@ -18973,7 +18973,7 @@ static void nl80211_ch_switch_notify(str
136                                      struct cfg80211_chan_def *chandef,
137                                      gfp_t gfp,
138                                      enum nl80211_commands notif,
139 -                                    u8 count, bool quiet)
140 +                                    u8 count, bool quiet, u16 punct_bitmap)
141  {
142         struct wireless_dev *wdev = netdev->ieee80211_ptr;
143         struct sk_buff *msg;
144 @@ -19007,6 +19007,9 @@ static void nl80211_ch_switch_notify(str
145                         goto nla_put_failure;
146         }
147  
148 +       if (nla_put_u32(msg, NL80211_ATTR_PUNCT_BITMAP, punct_bitmap))
149 +               goto nla_put_failure;
150 +
151         genlmsg_end(msg, hdr);
152  
153         genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
154 @@ -19019,7 +19022,7 @@ static void nl80211_ch_switch_notify(str
155  
156  void cfg80211_ch_switch_notify(struct net_device *dev,
157                                struct cfg80211_chan_def *chandef,
158 -                              unsigned int link_id)
159 +                              unsigned int link_id, u16 punct_bitmap)
160  {
161         struct wireless_dev *wdev = dev->ieee80211_ptr;
162         struct wiphy *wiphy = wdev->wiphy;
163 @@ -19028,7 +19031,7 @@ void cfg80211_ch_switch_notify(struct ne
164         ASSERT_WDEV_LOCK(wdev);
165         WARN_INVALID_LINK_ID(wdev, link_id);
166  
167 -       trace_cfg80211_ch_switch_notify(dev, chandef, link_id);
168 +       trace_cfg80211_ch_switch_notify(dev, chandef, link_id, punct_bitmap);
169  
170         switch (wdev->iftype) {
171         case NL80211_IFTYPE_STATION:
172 @@ -19056,14 +19059,15 @@ void cfg80211_ch_switch_notify(struct ne
173         cfg80211_sched_dfs_chan_update(rdev);
174  
175         nl80211_ch_switch_notify(rdev, dev, link_id, chandef, GFP_KERNEL,
176 -                                NL80211_CMD_CH_SWITCH_NOTIFY, 0, false);
177 +                                NL80211_CMD_CH_SWITCH_NOTIFY, 0, false,
178 +                                punct_bitmap);
179  }
180  EXPORT_SYMBOL(cfg80211_ch_switch_notify);
181  
182  void cfg80211_ch_switch_started_notify(struct net_device *dev,
183                                        struct cfg80211_chan_def *chandef,
184                                        unsigned int link_id, u8 count,
185 -                                      bool quiet)
186 +                                      bool quiet, u16 punct_bitmap)
187  {
188         struct wireless_dev *wdev = dev->ieee80211_ptr;
189         struct wiphy *wiphy = wdev->wiphy;
190 @@ -19072,11 +19076,13 @@ void cfg80211_ch_switch_started_notify(s
191         ASSERT_WDEV_LOCK(wdev);
192         WARN_INVALID_LINK_ID(wdev, link_id);
193  
194 -       trace_cfg80211_ch_switch_started_notify(dev, chandef, link_id);
195 +       trace_cfg80211_ch_switch_started_notify(dev, chandef, link_id,
196 +                                               punct_bitmap);
197 +
198  
199         nl80211_ch_switch_notify(rdev, dev, link_id, chandef, GFP_KERNEL,
200                                  NL80211_CMD_CH_SWITCH_STARTED_NOTIFY,
201 -                                count, quiet);
202 +                                count, quiet, punct_bitmap);
203  }
204  EXPORT_SYMBOL(cfg80211_ch_switch_started_notify);
205  
206 --- a/net/wireless/trace.h
207 +++ b/net/wireless/trace.h
208 @@ -3245,39 +3245,47 @@ TRACE_EVENT(cfg80211_chandef_dfs_require
209  TRACE_EVENT(cfg80211_ch_switch_notify,
210         TP_PROTO(struct net_device *netdev,
211                  struct cfg80211_chan_def *chandef,
212 -                unsigned int link_id),
213 -       TP_ARGS(netdev, chandef, link_id),
214 +                unsigned int link_id,
215 +                u16 punct_bitmap),
216 +       TP_ARGS(netdev, chandef, link_id, punct_bitmap),
217         TP_STRUCT__entry(
218                 NETDEV_ENTRY
219                 CHAN_DEF_ENTRY
220                 __field(unsigned int, link_id)
221 +               __field(u16, punct_bitmap)
222         ),
223         TP_fast_assign(
224                 NETDEV_ASSIGN;
225                 CHAN_DEF_ASSIGN(chandef);
226                 __entry->link_id = link_id;
227 +               __entry->punct_bitmap = punct_bitmap;
228         ),
229 -       TP_printk(NETDEV_PR_FMT ", " CHAN_DEF_PR_FMT ", link:%d",
230 -                 NETDEV_PR_ARG, CHAN_DEF_PR_ARG, __entry->link_id)
231 +       TP_printk(NETDEV_PR_FMT ", " CHAN_DEF_PR_FMT ", link:%d, punct_bitmap:%u",
232 +                 NETDEV_PR_ARG, CHAN_DEF_PR_ARG, __entry->link_id,
233 +                 __entry->punct_bitmap)
234  );
235  
236  TRACE_EVENT(cfg80211_ch_switch_started_notify,
237         TP_PROTO(struct net_device *netdev,
238                  struct cfg80211_chan_def *chandef,
239 -                unsigned int link_id),
240 -       TP_ARGS(netdev, chandef, link_id),
241 +                unsigned int link_id,
242 +                u16 punct_bitmap),
243 +       TP_ARGS(netdev, chandef, link_id, punct_bitmap),
244         TP_STRUCT__entry(
245                 NETDEV_ENTRY
246                 CHAN_DEF_ENTRY
247                 __field(unsigned int, link_id)
248 +               __field(u16, punct_bitmap)
249         ),
250         TP_fast_assign(
251                 NETDEV_ASSIGN;
252                 CHAN_DEF_ASSIGN(chandef);
253                 __entry->link_id = link_id;
254 +               __entry->punct_bitmap = punct_bitmap;
255         ),
256 -       TP_printk(NETDEV_PR_FMT ", " CHAN_DEF_PR_FMT ", link:%d",
257 -                 NETDEV_PR_ARG, CHAN_DEF_PR_ARG, __entry->link_id)
258 +       TP_printk(NETDEV_PR_FMT ", " CHAN_DEF_PR_FMT ", link:%d, punct_bitmap:%u",
259 +                 NETDEV_PR_ARG, CHAN_DEF_PR_ARG, __entry->link_id,
260 +                 __entry->punct_bitmap)
261  );
262  
263  TRACE_EVENT(cfg80211_radar_event,