-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrs_mgmt_tx.c
More file actions
1656 lines (1213 loc) · 41.2 KB
/
Copy pathrs_mgmt_tx.c
File metadata and controls
1656 lines (1213 loc) · 41.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// SPDX-License-Identifier: GPL-2.0-or-later
/**
* Copyright (C) [2022-2023] Renesas Electronics Corporation and/or its affiliates.
*/
////////////////////////////////////////////////////////////////////////////////
/// INCLUDE
#include <linux/version.h>
#include <linux/sched/clock.h>
#include "rs_mgmt_tx.h"
#include "rs_mac.h"
#include "rs_params.h"
#include "rs_priv.h"
////////////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITION
#define CONFIG_RS_DBG
#define RS_MAC80211_CHANGEABLE \
(ACCEPT_BA_BIT | ACCEPT_BAR_BIT | ACCEPT_OTHER_DATA_FRAMES_BIT | ACCEPT_PROBE_ASK_BIT | \
ACCEPT_PS_POLL_BIT)
#define RS_MAC80211_NOT_CHANGEABLE \
(ACCEPT_QO_S_NULL_BIT | ACCEPT_Q_DATA_BIT | ACCEPT_DATA_BIT | ACCEPT_OTHER_MGMT_FRAMES_BIT | \
ACCEPT_MY_UNICAST_BIT | ACCEPT_BROADCAST_BIT | ACCEPT_BEACON_BIT | ACCEPT_PROBE_RESP_BIT)
#define RS_DEFAULT_RX_FILTER (RS_MAC80211_CHANGEABLE | RS_MAC80211_NOT_CHANGEABLE)
#define RS_LPCA_PPM 20 // Low Power Clock accuracy
#define RS_UAPSD_TIMEOUT 300 // UAPSD Timer timeout, in ms (Default: 300). If 0, UAPSD is disabled
static const s32 bw2chnl[] = {
[NL80211_CHAN_WIDTH_20_NOHT] = RS_CHAN_BW_20, [NL80211_CHAN_WIDTH_20] = RS_CHAN_BW_20,
#ifdef CONFIG_SUPPORT_5G
[NL80211_CHAN_WIDTH_40] = RS_CHAN_BW_49, [NL80211_CHAN_WIDTH_80] = RS_CHAN_BW_80,
[NL80211_CHAN_WIDTH_160] = RS_CHAN_BW_160, [NL80211_CHAN_WIDTH_80P80] = RS_CHAN_BW_80P80,
#endif
};
const s32 chnl2bw[] = {
[RS_CHAN_BW_20] = NL80211_CHAN_WIDTH_20,
#ifdef CONFIG_SUPPORT_5G
[RS_CHAN_BW_49] = NL80211_CHAN_WIDTH_40, [RS_CHAN_BW_80] = NL80211_CHAN_WIDTH_80,
[RS_CHAN_BW_160] = NL80211_CHAN_WIDTH_160, [RS_CHAN_BW_80P80] = NL80211_CHAN_WIDTH_80P80,
#endif
};
////////////////////////////////////////////////////////////////////////////////
/// LOCAL FUNCTION
static inline u8 ampdudensity2usec(u8 ampdudensity)
{
switch (ampdudensity) {
case IEEE80211_HT_MPDU_DENSITY_NONE:
return 0;
case IEEE80211_HT_MPDU_DENSITY_0_25:
case IEEE80211_HT_MPDU_DENSITY_0_5:
case IEEE80211_HT_MPDU_DENSITY_1:
return 1;
case IEEE80211_HT_MPDU_DENSITY_2:
return 2;
case IEEE80211_HT_MPDU_DENSITY_4:
return 4;
case IEEE80211_HT_MPDU_DENSITY_8:
return 8;
case IEEE80211_HT_MPDU_DENSITY_16:
return 16;
default:
return 0;
}
}
static inline bool use_pairwise_key(struct cfg80211_crypto_settings *crypto)
{
if ((crypto->cipher_group == WLAN_CIPHER_SUITE_WEP40) ||
(crypto->cipher_group == WLAN_CIPHER_SUITE_WEP104))
return false;
return true;
}
static inline bool is_atomic_mgmt(s32 id)
{
return ((id == MGMT_TIM_UPDATE_ASK) || (id == MGMT_BFMER_ENABLE_ASK) ||
(id == TDLS_PEER_TRAFFIC_IND_ASK));
}
static inline uint8_t passive_scan_flag(u32 flags)
{
if (flags & (IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_RADAR))
return RS_SCAN_PASSIVE_BIT;
return 0;
}
static struct sk_buff *rs_alloc_skb(struct rs_hw_priv *hw_priv, s32 len, u16 mgmt_id, u16 task_id)
{
struct sk_buff *skb;
struct rs_fw_mgmt *mgmt;
u16 frame_len = sizeof(struct rs_fw_mgmt) + len;
skb = dev_alloc_skb(frame_len);
if (!skb) {
RS_WARN("%s: Failed in allocation of skb\n", __func__);
return NULL;
}
memset(skb->data, 0, frame_len);
mgmt = (struct rs_fw_mgmt *)skb->data;
mgmt->id = mgmt_id;
mgmt->dest_id = task_id;
mgmt->src_id = RS_HOST_T_ID;
mgmt->param_len = len;
skb_put(skb, frame_len);
return skb;
}
static void wait_mgmt_chk(struct rs_hw_priv *hw)
{
struct rs_core *core = hw->core;
struct rs_event *event = &core->mgmt_thread.event;
u32 waiting_time = 2000; // 2sec
hw->mgmt_chk_completed = false;
wait_event_timeout(event->mgmt_chk_queue, (hw->mgmt_chk_completed == true),
msecs_to_jiffies(waiting_time));
hw->mgmt_chk_completed = false;
}
static s32 set_skb_event(struct rs_core *core, struct sk_buff *skb)
{
struct sk_buff *temp_skb = NULL;
struct skb_info *tx_params = NULL;
struct rs_fw_mgmt *mgmt = NULL;
temp_skb = skb;
if (unlikely(in_atomic()) == 0) {
MGMT_LOCK(core);
}
mgmt = (struct rs_fw_mgmt *)(temp_skb->data);
temp_skb->priority = MGMT_SOFT_Q;
tx_params = (struct skb_info *)&(IEEE80211_SKB_CB(temp_skb)->driver_data);
tx_params->flags |= INTERNAL_MGMT_PKT;
skb_queue_tail(&core->mgmt_tx_queue, temp_skb);
rs_set_event(&core->mgmt_thread.event);
/* If it is atomic mgmt, it should not give msleep. */
if (!is_atomic_mgmt(mgmt->id)) {
wait_mgmt_chk(core->priv);
}
if (unlikely(in_atomic()) == 0) {
MGMT_UNLOCK(core);
}
return 0;
}
static void *get_mgmt_param(struct sk_buff *skb)
{
struct rs_fw_mgmt *mgmt = (struct rs_fw_mgmt *)skb->data;
if (!mgmt) {
RS_WARN("%s: skb->data is not assigned\n", __func__);
dev_kfree_skb(skb);
return NULL;
}
if (mgmt->param_len == 0)
return NULL;
else
return mgmt->param;
}
////////////////////////////////////////////////////////////////////////////////
/// GLOBAL FUNCTION
s32 rs_reset(struct rs_hw_priv *hw_priv)
{
struct rs_reset_req *req;
struct sk_buff *skb;
u64 ts = local_clock();
unsigned long rem_nsec = do_div(ts, 1000000000);
u32 bt_coex;
RS_DBG(RS_FN_ENTRY_STR);
skb = rs_alloc_skb(hw_priv, sizeof(struct rs_reset_req), MGMT_RESET_ASK, MM_T);
if (!skb) {
RS_WARN("%s: Failed in allocation of skb\n", __func__);
return -ENOMEM;
}
req = (struct rs_reset_req *)get_mgmt_param(skb);
/* u64 nsec time to u32 usec time (usec) */
req->time = rem_nsec / 1000 + ts * 1000000;
bt_coex = rs_get_bt_coex();
/* Set BT coexistence */
if (bt_coex < 4) {
req->bt_coex = bt_coex;
} else {
req->bt_coex = 0;
printk("bt_coex parameter force to 0 !!! (Must 0 to 3)\n");
}
return set_skb_event(hw_priv->core, skb);
}
s32 rs_dev_start(struct rs_hw_priv *hw_priv)
{
struct rs_dev_start_req *req;
struct sk_buff *skb;
RS_DBG(RS_FN_ENTRY_STR);
skb = rs_alloc_skb(hw_priv, sizeof(struct rs_dev_start_req), MGMT_START_ASK, MM_T);
if (!skb) {
RS_WARN("%s: Failed in allocation of skb\n", __func__);
return -ENOMEM;
}
req = (struct rs_dev_start_req *)get_mgmt_param(skb);
memcpy(&req->phy_cfg, &hw_priv->phy_config, sizeof(hw_priv->phy_config));
req->uapsd_timeout = RS_UAPSD_TIMEOUT;
req->lp_clk_accuracy = RS_LPCA_PPM;
return set_skb_event(hw_priv->core, skb);
}
s32 rs_version_req(struct rs_hw_priv *hw_priv, struct rs_version_chk *cfm)
{
struct sk_buff *skb;
RS_DBG(RS_FN_ENTRY_STR);
skb = rs_alloc_skb(hw_priv, 0, MGMT_VERSION_ASK, MM_T);
if (!skb) {
RS_WARN("%s: Failed in allocation of skb\n", __func__);
return -ENOMEM;
}
return set_skb_event(hw_priv->core, skb);
}
s32 rs_add_if(struct rs_hw_priv *hw_priv, const unsigned char *mac, enum nl80211_iftype iftype, bool p2p,
struct rs_add_if_chk *cfm)
{
struct rs_add_if_req *req;
struct sk_buff *skb;
RS_DBG(RS_FN_ENTRY_STR);
skb = rs_alloc_skb(hw_priv, sizeof(struct rs_add_if_req), MGMT_ADD_IF_ASK, MM_T);
if (!skb) {
RS_WARN("%s: Failed in allocation of skb\n", __func__);
return -ENOMEM;
}
req = (struct rs_add_if_req *)get_mgmt_param(skb);
memcpy(&(req->addr.addr[0]), mac, ETH_ALEN);
switch (iftype) {
case NL80211_IFTYPE_STATION:
req->iftype = IF_STA;
break;
case NL80211_IFTYPE_ADHOC:
req->iftype = IF_IBSS;
break;
case NL80211_IFTYPE_AP:
req->iftype = IF_AP;
break;
case NL80211_IFTYPE_MESH_POINT:
req->iftype = IF_MESH_POINT;
break;
case NL80211_IFTYPE_AP_VLAN:
return -1;
case NL80211_IFTYPE_MONITOR:
req->iftype = IF_MONITOR;
req->uf = false;
break;
default:
req->iftype = IF_STA;
break;
}
req->p2p = p2p;
return set_skb_event(hw_priv->core, skb);
}
s32 rs_remove_if(struct rs_hw_priv *hw_priv, u8 vif_index)
{
struct rs_remove_if_req *remove_if_req;
struct sk_buff *skb;
RS_DBG(RS_FN_ENTRY_STR);
skb = rs_alloc_skb(hw_priv, sizeof(struct rs_remove_if_req), MGMT_REMOVE_IF_ASK, MM_T);
if (!skb) {
RS_WARN("%s: Failed in allocation of skb\n", __func__);
return -ENOMEM;
}
remove_if_req = (struct rs_remove_if_req *)get_mgmt_param(skb);
remove_if_req->vif_index = vif_index;
return set_skb_event(hw_priv->core, skb);
}
s32 rs_set_channel(struct rs_hw_priv *hw_priv, s32 phy_idx, struct rs_set_channel_chk *cfm)
{
struct cfg80211_chan_def *chandef = &hw_priv->hw->conf.chandef;
struct rs_set_channel_req *req;
enum nl80211_chan_width width;
u16 center_freq, center_freq1, center_freq2;
s8 tx_power = 0;
enum nl80211_band band;
struct sk_buff *skb;
RS_DBG(RS_FN_ENTRY_STR);
if (phy_idx >= hw_priv->phy_cnt)
return -ENOTSUPP;
skb = rs_alloc_skb(hw_priv, sizeof(struct rs_set_channel_req), MGMT_SET_CHANNEL_ASK, MM_T);
if (!skb) {
RS_WARN("%s: Failed in allocation of skb\n", __func__);
return -ENOMEM;
}
req = (struct rs_set_channel_req *)get_mgmt_param(skb);
if (phy_idx == 0) {
width = chandef->width;
band = chandef->chan->band;
center_freq = chandef->chan->center_freq;
center_freq1 = chandef->center_freq1;
center_freq2 = chandef->center_freq2;
tx_power = chandef->chan->max_power;
} else {
struct rs_sec_phy_chan *chan = &hw_priv->sec_phy_chan;
width = chnl2bw[chan->type];
band = chan->band;
center_freq = chan->prim20_freq;
center_freq1 = chan->center_freq1;
center_freq2 = chan->center_freq2;
}
req->band = band;
req->type = bw2chnl[width];
req->prim20_freq = center_freq;
req->center1_freq = center_freq1;
req->center2_freq = center_freq2;
req->index = phy_idx;
req->tx_power = tx_power;
RS_DBG("mac80211: freq=%d(c1:%d - c2:%d)/width=%d - band=%d\n"
" hw(%d): prim20=%d(c1:%d - c2:%d)/ type=%d - band=%d\n",
center_freq, center_freq1, center_freq2, width, band, phy_idx, req->prim20_freq,
req->center1_freq, req->center2_freq, req->type, req->band);
return set_skb_event(hw_priv->core, skb);
}
s32 rs_key_add(struct rs_hw_priv *hw_priv, u8 vif_id, u8 sta_id, bool pairwise, u8 *key, u8 key_len,
u8 key_idx, u8 cipher_suite, struct rs_key_add_chk *cfm)
{
struct rs_key_add_req *req;
struct sk_buff *skb;
RS_DBG(RS_FN_ENTRY_STR);
skb = rs_alloc_skb(hw_priv, sizeof(struct rs_key_add_req), MGMT_KEY_ADD_ASK, MM_T);
if (!skb) {
RS_WARN("%s: Failed in allocation of skb\n", __func__);
return -ENOMEM;
}
req = (struct rs_key_add_req *)get_mgmt_param(skb);
if (sta_id != 0xFF) {
req->sta_id = sta_id;
} else {
req->sta_id = sta_id;
req->key_idx = (u8)key_idx; /* only useful for default keys */
}
req->pairwise = pairwise;
req->vif_id = vif_id;
req->key.length = key_len;
memcpy(&(req->key.array[0]), key, key_len);
req->cipher_suite = cipher_suite;
RS_DBG("%s: sta_id:%d key_idx:%d vif_id:%d cipher:%d key_len:%d\n", __func__, req->sta_id,
req->key_idx, req->vif_id, req->cipher_suite, req->key.length);
#if defined(CONFIG_RS_DBG) || defined(CONFIG_DYNAMIC_DEBUG)
print_hex_dump_bytes("key: ", DUMP_PREFIX_OFFSET, req->key.array, req->key.length);
#endif
return set_skb_event(hw_priv->core, skb);
}
s32 rs_key_del(struct rs_hw_priv *hw_priv, uint8_t hw_key_idx)
{
struct rs_key_del_req *req;
struct sk_buff *skb;
RS_DBG(RS_FN_ENTRY_STR);
skb = rs_alloc_skb(hw_priv, sizeof(struct rs_key_del_req), MGMT_KEY_DEL_ASK, MM_T);
if (!skb) {
RS_WARN("%s: Failed in allocation of skb\n", __func__);
return -ENOMEM;
}
req = (struct rs_key_del_req *)get_mgmt_param(skb);
req->hw_key_idx = hw_key_idx;
return set_skb_event(hw_priv->core, skb);
}
s32 rs_bcn_change(struct rs_hw_priv *hw_priv, u8 vif_id, void *bcn_addr, u16 bcn_len, u16 tim_oft,
u16 tim_len, u16 *csa_oft)
{
struct rs_bcn_change_req *req;
struct sk_buff *skb;
RS_DBG(RS_FN_ENTRY_STR);
skb = rs_alloc_skb(hw_priv, sizeof(struct rs_bcn_change_req), MGMT_BCN_CHANGE_ASK, MM_T);
if (!skb) {
RS_WARN("%s: Failed in allocation of skb\n", __func__);
return -ENOMEM;
}
req = (struct rs_bcn_change_req *)get_mgmt_param(skb);
// req->bcn_ptr = bcn_addr;
req->bcn_len = bcn_len;
req->tim_oft = tim_oft;
req->tim_len = tim_len;
req->vif_id = vif_id;
memcpy(req->bcn_ptr, bcn_addr, bcn_len);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)
BUILD_BUG_ON_MSG(IEEE80211_MAX_CNTDWN_COUNTERS_NUM != RS_BCN_MAX_CSA_CPT,
"RS_BCN_MAX_CSA_CPT and IEEE80211_MAX_CNTDWN_COUNTERS_NUM "
"have different value");
#else
BUILD_BUG_ON_MSG(IEEE80211_MAX_CSA_COUNTERS_NUM != RS_BCN_MAX_CSA_CPT,
"RS_BCN_MAX_CSA_CPT and IEEE80211_MAX_CSA_COUNTERS_NUM "
"have different value");
#endif
if (csa_oft) {
s32 i;
for (i = 0; i < RS_BCN_MAX_CSA_CPT; i++) {
req->csa_oft[i] = csa_oft[i];
}
}
return set_skb_event(hw_priv->core, skb);
}
s32 rs_roc(struct rs_hw_priv *hw_priv, struct rs_vif_priv *vif, struct ieee80211_channel *chan, u32 duration)
{
struct rs_remain_on_channel_req *req;
struct cfg80211_chan_def chandef;
struct sk_buff *skb;
RS_DBG(RS_FN_ENTRY_STR);
skb = rs_alloc_skb(hw_priv, sizeof(struct rs_remain_on_channel_req), MGMT_REMAIN_ON_CHANNEL_ASK,
MM_T);
if (!skb) {
RS_WARN("%s: Failed in allocation of skb\n", __func__);
return -ENOMEM;
}
cfg80211_chandef_create(&chandef, chan, NL80211_CHAN_NO_HT);
req = (struct rs_remain_on_channel_req *)get_mgmt_param(skb);
req->op_code = MGMT_ROC_OP_START;
req->vif_index = vif->vif_index;
req->duration_ms = duration;
req->band = chan->band;
req->type = bw2chnl[chandef.width];
req->prim20_freq = chan->center_freq;
req->center1_freq = chandef.center_freq1;
req->center2_freq = chandef.center_freq2;
req->tx_power = chan->max_power;
return set_skb_event(hw_priv->core, skb);
}
s32 rs_cancel_roc(struct rs_hw_priv *hw_priv)
{
struct rs_remain_on_channel_req *req;
struct sk_buff *skb;
RS_DBG(RS_FN_ENTRY_STR);
skb = rs_alloc_skb(hw_priv, sizeof(struct rs_remain_on_channel_req), MGMT_REMAIN_ON_CHANNEL_ASK,
MM_T);
if (!skb) {
RS_WARN("%s: Failed in allocation of skb\n", __func__);
return -ENOMEM;
}
req = (struct rs_remain_on_channel_req *)get_mgmt_param(skb);
req->op_code = MGMT_ROC_OP_CANCEL;
return set_skb_event(hw_priv->core, skb);
}
s32 rs_set_power(struct rs_hw_priv *hw_priv, u8 vif_id, s8 pwr, struct rs_set_power_chk *cfm)
{
struct rs_set_power_req *req;
struct sk_buff *skb;
RS_DBG(RS_FN_ENTRY_STR);
skb = rs_alloc_skb(hw_priv, sizeof(struct rs_set_power_req), MGMT_SET_POWER_ASK, MM_T);
if (!skb) {
RS_WARN("%s: Failed in allocation of skb\n", __func__);
return -ENOMEM;
}
req = (struct rs_set_power_req *)get_mgmt_param(skb);
req->vif_id = vif_id;
req->power = pwr;
return set_skb_event(hw_priv->core, skb);
}
s32 rs_set_edca(struct rs_hw_priv *hw_priv, u8 hw_queue, u32 param, bool uapsd, u8 vif_index)
{
struct rs_set_edca_req *req;
struct sk_buff *skb;
RS_DBG(RS_FN_ENTRY_STR);
skb = rs_alloc_skb(hw_priv, sizeof(struct rs_set_edca_req), MGMT_SET_EDCA_ASK, MM_T);
if (!skb) {
RS_WARN("%s: Failed in allocation of skb\n", __func__);
return -ENOMEM;
}
req = (struct rs_set_edca_req *)get_mgmt_param(skb);
req->ac_param = param;
req->uapsd = uapsd;
req->hw_queue = hw_queue;
req->vif_index = vif_index;
return set_skb_event(hw_priv->core, skb);
}
#ifdef CONFIG_RS_P2P_DEBUGFS
s32 rs_p2p_opps_req(struct rs_hw_priv *hw_priv, struct rs_vif_priv *vif_priv, u8 ctw,
struct rs_set_p2p_opps_chk *cfm)
{
struct rs_set_p2p_opps_req *req;
struct sk_buff *skb;
RS_DBG(RS_FN_ENTRY_STR);
skb = rs_alloc_skb(hw_priv, sizeof(struct rs_set_p2p_opps_req), MGMT_SET_P2P_OPPS_ASK, MM_T);
if (!skb) {
RS_WARN("%s: Failed in allocation of skb\n", __func__);
return -ENOMEM;
}
req = (struct rs_set_p2p_opps_req *)get_mgmt_param(skb);
req->vif_index = vif_priv->vif_index;
req->ctwindow = ctw;
return set_skb_event(hw_priv->core, skb);
}
s32 rs_p2p_noa_req(struct rs_hw_priv *hw_priv, struct rs_vif_priv *vif_priv, u8 count, u8 interval,
u8 duration, bool dyn_noa, struct rs_set_p2p_noa_chk *cfm)
{
struct rs_set_p2p_noa_req *req;
struct sk_buff *skb;
RS_DBG(RS_FN_ENTRY_STR);
skb = rs_alloc_skb(hw_priv, sizeof(struct rs_set_p2p_noa_req), MGMT_SET_P2P_NOA_ASK, MM_T);
if (!skb) {
RS_WARN("%s: Failed in allocation of skb\n", __func__);
return -ENOMEM;
}
req = (struct rs_set_p2p_noa_req *)get_mgmt_param(skb);
req->vif_index = vif_priv->vif_index;
req->noa_inst_nb = 0;
req->count = count;
if (count) {
req->duration_us = duration * 1024;
req->interval_us = interval * 1024;
req->start_offset = (interval - duration - 10) * 1024;
req->dyn_noa = dyn_noa;
}
return set_skb_event(hw_priv->core, skb);
}
#endif /* CONFIG_RS_P2P_DEBUGFS */
s32 rs_sta_add(struct rs_hw_priv *hw_priv, struct ieee80211_sta *sta, u8 vif_index,
struct rs_sta_add_chk *cfm)
{
struct rs_sta_add_req *req;
u32 *phy_value;
struct rs_sta_priv *sta_priv;
struct sk_buff *skb;
RS_DBG(RS_FN_ENTRY_STR);
skb = rs_alloc_skb(hw_priv, sizeof(struct rs_sta_add_req), MGMT_STA_ADD_ASK, MM_T);
if (!skb) {
RS_WARN("%s: Failed in allocation of skb\n", __func__);
return -ENOMEM;
}
req = (struct rs_sta_add_req *)get_mgmt_param(skb);
memcpy(&(req->mac_addr.addr[0]), &(sta->addr[0]), ETH_ALEN);
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)
if (sta->ht_cap.ht_supported) {
if (sta->vht_cap.vht_supported) {
s32 vht_exp =
(sta->vht_cap.cap & IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK) >>
IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT;
req->ampdu_size_max_vht = (1 << (IEEE80211_HT_MAX_AMPDU_FACTOR + vht_exp)) - 1;
}
req->ampdu_size_max_ht =
(1 << (IEEE80211_HT_MAX_AMPDU_FACTOR + sta->ht_cap.ampdu_factor)) - 1;
req->ampdu_spacing_min = ampdudensity2usec(sta->ht_cap.ampdu_density);
}
#else
if (sta->deflink.ht_cap.ht_supported) {
if (sta->deflink.vht_cap.vht_supported) {
s32 vht_exp = (sta->deflink.vht_cap.cap &
IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK) >>
IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT;
req->ampdu_size_max_vht = (1 << (IEEE80211_HT_MAX_AMPDU_FACTOR + vht_exp)) - 1;
}
req->ampdu_size_max_ht =
(1 << (IEEE80211_HT_MAX_AMPDU_FACTOR + sta->deflink.ht_cap.ampdu_factor)) - 1;
req->ampdu_spacing_min = ampdudensity2usec(sta->deflink.ht_cap.ampdu_density);
}
#endif
sta_priv = (struct rs_sta_priv *)sta->drv_priv;
req->vif_index = vif_index;
req->tdls_sta = sta->tdls;
phy_value = (u32 *)&(req->paid_gid);
*phy_value |= RS_PHY_GROUD_ID_MASK_SHIFT(sta_priv->gid);
*phy_value |= RS_PHY_PAID_MASK_SHIFT(sta_priv->paid);
return set_skb_event(hw_priv->core, skb);
}
s32 rs_sta_del(struct rs_hw_priv *hw_priv, u8 sta_id)
{
struct rs_sta_del_req *req;
struct sk_buff *skb;
RS_DBG(RS_FN_ENTRY_STR);
skb = rs_alloc_skb(hw_priv, sizeof(struct rs_sta_del_req), MGMT_STA_DEL_ASK, MM_T);
if (!skb) {
RS_WARN("%s: Failed in allocation of skb\n", __func__);
return -ENOMEM;
}
req = (struct rs_sta_del_req *)get_mgmt_param(skb);
req->sta_id = sta_id;
return set_skb_event(hw_priv->core, skb);
}
s32 rs_set_filter(struct rs_hw_priv *hw_priv, u32 filter)
{
struct rs_set_filter_req *req;
u32 rx_filter = 0;
struct sk_buff *skb;
RS_DBG(RS_FN_ENTRY_STR);
skb = rs_alloc_skb(hw_priv, sizeof(struct rs_set_filter_req), MGMT_SET_FILTER_ASK, MM_T);
if (!skb) {
RS_WARN("%s: Failed in allocation of skb\n", __func__);
return -ENOMEM;
}
req = (struct rs_set_filter_req *)get_mgmt_param(skb);
#if 0 /* removed */
if (filter & FIF_PROMISC_IN_BSS)
rx_filter |= ACCEPT_UNICAST_BIT;
#endif
if (filter & FIF_ALLMULTI)
rx_filter |= ACCEPT_MULTICAST_BIT;
if (filter & (FIF_FCSFAIL | FIF_PLCPFAIL))
rx_filter |= ACCEPT_ERROR_FRAMES_BIT;
if (filter & FIF_BCN_PRBRESP_PROMISC)
rx_filter |= ACCEPT_OTHER_BSSID_BIT;
if (filter & FIF_CONTROL)
rx_filter |= ACCEPT_OTHER_CNTRL_FRAMES_BIT | ACCEPT_CF_END_BIT | ACCEPT_ACK_BIT |
ACCEPT_CTS_BIT | ACCEPT_RTS_BIT | ACCEPT_BA_BIT | ACCEPT_BAR_BIT;
if (filter & FIF_OTHER_BSS)
rx_filter |= ACCEPT_OTHER_BSSID_BIT;
if (filter & FIF_PSPOLL) {
rx_filter |= ACCEPT_PS_POLL_BIT;
}
if (filter & FIF_PROBE_REQ) {
rx_filter |= ACCEPT_PROBE_ASK_BIT;
rx_filter |= ACCEPT_ALL_BEACON_BIT;
}
rx_filter |= RS_MAC80211_NOT_CHANGEABLE;
if (ieee80211_hw_check(hw_priv->hw, AMPDU_AGGREGATION))
rx_filter |= ACCEPT_BA_BIT;
req->filter = rx_filter;
RS_DBG("new total_flags = 0x%08x\nrx filter set to 0x%08x\n", filter, rx_filter);
return set_skb_event(hw_priv->core, skb);
}
s32 rs_add_chanctx(struct rs_hw_priv *hw_priv, struct ieee80211_chanctx_conf *ctx,
struct rs_chan_ctxt_add_chk *cfm)
{
struct rs_chan_ctxt_add_req *req;
struct sk_buff *skb;
RS_DBG(RS_FN_ENTRY_STR);
skb = rs_alloc_skb(hw_priv, sizeof(struct rs_chan_ctxt_add_req), MGMT_CHAN_CTXT_ADD_ASK, MM_T);
if (!skb) {
RS_WARN("%s: Failed in allocation of skb\n", __func__);
return -ENOMEM;
}
req = (struct rs_chan_ctxt_add_req *)get_mgmt_param(skb);
req->band = ctx->def.chan->band;
req->type = bw2chnl[ctx->def.width];
req->prim20_freq = ctx->def.chan->center_freq;
req->center1_freq = ctx->def.center_freq1;
req->center2_freq = ctx->def.center_freq2;
req->tx_power = ctx->def.chan->max_power;
RS_DBG("mac80211: freq=%d(c1:%d - c2:%d)/width=%d - band=%d\n"
" prim20=%d(c1:%d - c2:%d)/ type=%d - band=%d\n",
ctx->def.chan->center_freq, ctx->def.center_freq1, ctx->def.center_freq2, ctx->def.width,
ctx->def.chan->band, req->prim20_freq, req->center1_freq, req->center2_freq, req->type,
req->band);
return set_skb_event(hw_priv->core, skb);
}
s32 rs_del_chanctx(struct rs_hw_priv *hw_priv, u8 index)
{
struct rs_chan_ctxt_del_req *req;
struct sk_buff *skb;
RS_DBG(RS_FN_ENTRY_STR);
skb = rs_alloc_skb(hw_priv, sizeof(struct rs_chan_ctxt_del_req), MGMT_CHAN_CTXT_DEL_ASK, MM_T);
if (!skb) {
RS_WARN("%s: Failed in allocation of skb\n", __func__);
return -ENOMEM;
}
req = (struct rs_chan_ctxt_del_req *)get_mgmt_param(skb);
req->index = index;
return set_skb_event(hw_priv->core, skb);
}
s32 rs_link_chanctx(struct rs_hw_priv *hw_priv, u8 vif_id, u8 chan_idx, u8 chan_switch)
{
struct rs_chan_ctxt_link_req *req;
struct sk_buff *skb;
RS_DBG(RS_FN_ENTRY_STR);
skb = rs_alloc_skb(hw_priv, sizeof(struct rs_chan_ctxt_link_req), MGMT_CHAN_CTXT_LINK_ASK, MM_T);
if (!skb) {
RS_WARN("%s: Failed in allocation of skb\n", __func__);
return -ENOMEM;
}
req = (struct rs_chan_ctxt_link_req *)get_mgmt_param(skb);
req->vif_index = vif_id;
req->chan_index = chan_idx;
req->chan_switch = chan_switch;
return set_skb_event(hw_priv->core, skb);
}
s32 rs_unlink_chanctx(struct rs_hw_priv *hw_priv, u8 vif_id)
{
struct rs_chan_ctxt_unlink_req *req;
struct sk_buff *skb;
RS_DBG(RS_FN_ENTRY_STR);
skb = rs_alloc_skb(hw_priv, sizeof(struct rs_chan_ctxt_unlink_req), MGMT_CHAN_CTXT_UNLINK_ASK, MM_T);
if (!skb) {
RS_WARN("%s: Failed in allocation of skb\n", __func__);
return -ENOMEM;
}
req = (struct rs_chan_ctxt_unlink_req *)get_mgmt_param(skb);
req->vif_index = vif_id;
return set_skb_event(hw_priv->core, skb);
}
s32 rs_update_chanctx(struct rs_hw_priv *hw_priv, struct ieee80211_chanctx_conf *ctx)
{
struct rs_chan_ctxt_update_req *req;
struct rs_chanctx *chanctx;
struct sk_buff *skb;
RS_DBG(RS_FN_ENTRY_STR);
skb = rs_alloc_skb(hw_priv, sizeof(struct rs_chan_ctxt_update_req), MGMT_CHAN_CTXT_UPDATE_ASK, MM_T);
if (!skb) {
RS_WARN("%s: Failed in allocation of skb\n", __func__);
return -ENOMEM;
}
req = (struct rs_chan_ctxt_update_req *)get_mgmt_param(skb);
chanctx = (struct rs_chanctx *)ctx->drv_priv;
req->chan_index = chanctx->index;
req->band = ctx->def.chan->band;
req->type = bw2chnl[ctx->def.width];
req->prim20_freq = ctx->def.chan->center_freq;
req->center1_freq = ctx->def.center_freq1;
req->center2_freq = ctx->def.center_freq2;
req->tx_power = ctx->def.chan->max_power;
RS_DBG("mac80211: freq=%d(c1:%d - c2:%d)/width=%d - band=%d\n"
" prim20=%d(c1:%d - c2:%d)/ type=%d - band=%d\n",
ctx->def.chan->center_freq, ctx->def.center_freq1, ctx->def.center_freq2, ctx->def.width,
ctx->def.chan->band, req->prim20_freq, req->center1_freq, req->center2_freq, req->type,
req->band);
return set_skb_event(hw_priv->core, skb);
}
s32 rs_sched_chanctx(struct rs_hw_priv *hw_priv, u8 vif_id, u8 chan_idx, u8 type)
{
struct rs_chan_ctxt_sched_req *req;
struct sk_buff *skb;
RS_DBG(RS_FN_ENTRY_STR);
skb = rs_alloc_skb(hw_priv, sizeof(struct rs_chan_ctxt_sched_req), MGMT_CHAN_CTXT_SCHED_ASK, MM_T);
if (!skb) {
RS_WARN("%s: Failed in allocation of skb\n", __func__);
return -ENOMEM;
}
req = (struct rs_chan_ctxt_sched_req *)get_mgmt_param(skb);
req->vif_index = vif_id;
req->chan_index = chan_idx;
req->type = type;
return set_skb_event(hw_priv->core, skb);
}
s32 rs_dtim_req(struct rs_hw_priv *hw_priv, u8 dtim_period)
{
struct rs_set_dtim_req *req;
struct sk_buff *skb;
RS_DBG(RS_FN_ENTRY_STR);
skb = rs_alloc_skb(hw_priv, sizeof(struct rs_set_dtim_req), MGMT_SET_DTIM_ASK, MM_T);
if (!skb) {
RS_WARN("%s: Failed in allocation of skb\n", __func__);
return -ENOMEM;
}
req = (struct rs_set_dtim_req *)get_mgmt_param(skb);
req->dtim_period = dtim_period;
return set_skb_event(hw_priv->core, skb);
}
s32 rs_set_basic_rates(struct rs_hw_priv *hw_priv, u32 basic_rates, u8 vif_id, u8 band)
{
struct rs_set_basic_rates_req *req;
struct sk_buff *skb;
RS_DBG(RS_FN_ENTRY_STR);
skb = rs_alloc_skb(hw_priv, sizeof(struct rs_set_basic_rates_req), MGMT_SET_BASIC_RATES_ASK, MM_T);
if (!skb) {
RS_WARN("%s: Failed in allocation of skb\n", __func__);
return -ENOMEM;
}
req = (struct rs_set_basic_rates_req *)get_mgmt_param(skb);
req->basic_rates = basic_rates;
req->vif_id = vif_id;
req->band = band;
return set_skb_event(hw_priv->core, skb);
}
s32 rs_set_beacon_int(struct rs_hw_priv *hw_priv, u16 beacon_int, u8 vif_id)
{
struct rs_set_beacon_int_req *req;
struct sk_buff *skb;
RS_DBG(RS_FN_ENTRY_STR);
skb = rs_alloc_skb(hw_priv, sizeof(struct rs_set_beacon_int_req), MGMT_SET_BEACON_INT_ASK, MM_T);
if (!skb) {
RS_WARN("%s: Failed in allocation of skb\n", __func__);
return -ENOMEM;
}
req = (struct rs_set_beacon_int_req *)get_mgmt_param(skb);