hc
2024-05-16 8d2a02b24d66aa359e83eebc1ed3c0f85367a1cb
....@@ -1,17 +1,5 @@
1
-/*
2
- * Copyright (c) 2015-2016 Quantenna Communications, Inc.
3
- *
4
- * This program is free software; you can redistribute it and/or
5
- * modify it under the terms of the GNU General Public License
6
- * as published by the Free Software Foundation; either version 2
7
- * of the License, or (at your option) any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU General Public License for more details.
13
- *
14
- */
1
+// SPDX-License-Identifier: GPL-2.0+
2
+/* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
153
164 #include <linux/nl80211.h>
175
....@@ -136,6 +124,8 @@
136124 chdef->center_freq1 = le16_to_cpu(qch->center_freq1);
137125 chdef->center_freq2 = le16_to_cpu(qch->center_freq2);
138126 chdef->width = qlink_chanwidth_to_nl(qch->width);
127
+ chdef->edmg.bw_config = 0;
128
+ chdef->edmg.channels = 0;
139129 }
140130
141131 void qlink_chandef_cfg2q(const struct cfg80211_chan_def *chdef,
....@@ -194,3 +184,120 @@
194184 memcpy(qacl->mac_addrs, acl->mac_addrs,
195185 acl->n_acl_entries * sizeof(*qacl->mac_addrs));
196186 }
187
+
188
+enum qlink_band qlink_utils_band_cfg2q(enum nl80211_band band)
189
+{
190
+ switch (band) {
191
+ case NL80211_BAND_2GHZ:
192
+ return QLINK_BAND_2GHZ;
193
+ case NL80211_BAND_5GHZ:
194
+ return QLINK_BAND_5GHZ;
195
+ case NL80211_BAND_60GHZ:
196
+ return QLINK_BAND_60GHZ;
197
+ default:
198
+ return -EINVAL;
199
+ }
200
+}
201
+
202
+enum qlink_dfs_state qlink_utils_dfs_state_cfg2q(enum nl80211_dfs_state state)
203
+{
204
+ switch (state) {
205
+ case NL80211_DFS_USABLE:
206
+ return QLINK_DFS_USABLE;
207
+ case NL80211_DFS_AVAILABLE:
208
+ return QLINK_DFS_AVAILABLE;
209
+ case NL80211_DFS_UNAVAILABLE:
210
+ default:
211
+ return QLINK_DFS_UNAVAILABLE;
212
+ }
213
+}
214
+
215
+u32 qlink_utils_chflags_cfg2q(u32 cfgflags)
216
+{
217
+ u32 flags = 0;
218
+
219
+ if (cfgflags & IEEE80211_CHAN_DISABLED)
220
+ flags |= QLINK_CHAN_DISABLED;
221
+
222
+ if (cfgflags & IEEE80211_CHAN_NO_IR)
223
+ flags |= QLINK_CHAN_NO_IR;
224
+
225
+ if (cfgflags & IEEE80211_CHAN_RADAR)
226
+ flags |= QLINK_CHAN_RADAR;
227
+
228
+ if (cfgflags & IEEE80211_CHAN_NO_HT40PLUS)
229
+ flags |= QLINK_CHAN_NO_HT40PLUS;
230
+
231
+ if (cfgflags & IEEE80211_CHAN_NO_HT40MINUS)
232
+ flags |= QLINK_CHAN_NO_HT40MINUS;
233
+
234
+ if (cfgflags & IEEE80211_CHAN_NO_80MHZ)
235
+ flags |= QLINK_CHAN_NO_80MHZ;
236
+
237
+ if (cfgflags & IEEE80211_CHAN_NO_160MHZ)
238
+ flags |= QLINK_CHAN_NO_160MHZ;
239
+
240
+ return flags;
241
+}
242
+
243
+static u32 qtnf_reg_rule_flags_parse(u32 qflags)
244
+{
245
+ u32 flags = 0;
246
+
247
+ if (qflags & QLINK_RRF_NO_OFDM)
248
+ flags |= NL80211_RRF_NO_OFDM;
249
+
250
+ if (qflags & QLINK_RRF_NO_CCK)
251
+ flags |= NL80211_RRF_NO_CCK;
252
+
253
+ if (qflags & QLINK_RRF_NO_INDOOR)
254
+ flags |= NL80211_RRF_NO_INDOOR;
255
+
256
+ if (qflags & QLINK_RRF_NO_OUTDOOR)
257
+ flags |= NL80211_RRF_NO_OUTDOOR;
258
+
259
+ if (qflags & QLINK_RRF_DFS)
260
+ flags |= NL80211_RRF_DFS;
261
+
262
+ if (qflags & QLINK_RRF_PTP_ONLY)
263
+ flags |= NL80211_RRF_PTP_ONLY;
264
+
265
+ if (qflags & QLINK_RRF_PTMP_ONLY)
266
+ flags |= NL80211_RRF_PTMP_ONLY;
267
+
268
+ if (qflags & QLINK_RRF_NO_IR)
269
+ flags |= NL80211_RRF_NO_IR;
270
+
271
+ if (qflags & QLINK_RRF_AUTO_BW)
272
+ flags |= NL80211_RRF_AUTO_BW;
273
+
274
+ if (qflags & QLINK_RRF_IR_CONCURRENT)
275
+ flags |= NL80211_RRF_IR_CONCURRENT;
276
+
277
+ if (qflags & QLINK_RRF_NO_HT40MINUS)
278
+ flags |= NL80211_RRF_NO_HT40MINUS;
279
+
280
+ if (qflags & QLINK_RRF_NO_HT40PLUS)
281
+ flags |= NL80211_RRF_NO_HT40PLUS;
282
+
283
+ if (qflags & QLINK_RRF_NO_80MHZ)
284
+ flags |= NL80211_RRF_NO_80MHZ;
285
+
286
+ if (qflags & QLINK_RRF_NO_160MHZ)
287
+ flags |= NL80211_RRF_NO_160MHZ;
288
+
289
+ return flags;
290
+}
291
+
292
+void qlink_utils_regrule_q2nl(struct ieee80211_reg_rule *rule,
293
+ const struct qlink_tlv_reg_rule *tlv)
294
+{
295
+ rule->freq_range.start_freq_khz = le32_to_cpu(tlv->start_freq_khz);
296
+ rule->freq_range.end_freq_khz = le32_to_cpu(tlv->end_freq_khz);
297
+ rule->freq_range.max_bandwidth_khz =
298
+ le32_to_cpu(tlv->max_bandwidth_khz);
299
+ rule->power_rule.max_antenna_gain = le32_to_cpu(tlv->max_antenna_gain);
300
+ rule->power_rule.max_eirp = le32_to_cpu(tlv->max_eirp);
301
+ rule->dfs_cac_ms = le32_to_cpu(tlv->dfs_cac_ms);
302
+ rule->flags = qtnf_reg_rule_flags_parse(le32_to_cpu(tlv->flags));
303
+}