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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
|
/*
* ***************************************************************************
* FILE: unifi_sme.c
*
* PURPOSE: SME related functions.
*
* Copyright (C) 2007-2009 by Cambridge Silicon Radio Ltd.
*
* Refer to LICENSE.txt included with this source code for details on
* the license terms.
*
* ***************************************************************************
*/
#include "unifi_priv.h"
#include "csr_wifi_hip_unifi.h"
#include "csr_wifi_hip_conversions.h"
int
convert_sme_error(CsrResult error)
{
switch (error) {
case CSR_RESULT_SUCCESS:
return 0;
case CSR_RESULT_FAILURE:
case CSR_WIFI_RESULT_NOT_FOUND:
case CSR_WIFI_RESULT_TIMED_OUT:
case CSR_WIFI_RESULT_CANCELLED:
case CSR_WIFI_RESULT_UNAVAILABLE:
return -EIO;
case CSR_WIFI_RESULT_NO_ROOM:
return -EBUSY;
case CSR_WIFI_RESULT_INVALID_PARAMETER:
return -EINVAL;
case CSR_WIFI_RESULT_UNSUPPORTED:
return -EOPNOTSUPP;
default:
return -EIO;
}
}
/*
* ---------------------------------------------------------------------------
* sme_log_event
*
* Callback function to be registered as the SME event callback.
* Copies the signal content into a new udi_log_t struct and adds
* it to the read queue for the SME client.
*
* Arguments:
* arg This is the value given to unifi_add_udi_hook, in
* this case a pointer to the client instance.
* signal Pointer to the received signal.
* signal_len Size of the signal structure in bytes.
* bulkdata Pointers to any associated bulk data.
* dir Direction of the signal. Zero means from host,
* non-zero means to host.
*
* Returns:
* None.
* ---------------------------------------------------------------------------
*/
void
sme_log_event(ul_client_t *pcli,
const u8 *signal, int signal_len,
const bulk_data_param_t *bulkdata,
int dir)
{
unifi_priv_t *priv;
CSR_SIGNAL unpacked_signal;
CsrWifiSmeDataBlock mlmeCommand;
CsrWifiSmeDataBlock dataref1;
CsrWifiSmeDataBlock dataref2;
CsrResult result = CSR_RESULT_SUCCESS;
int r;
func_enter();
/* Just a sanity check */
if ((signal == NULL) || (signal_len <= 0)) {
func_exit();
return;
}
priv = uf_find_instance(pcli->instance);
if (!priv) {
unifi_error(priv, "sme_log_event: invalid priv\n");
func_exit();
return;
}
if (priv->smepriv == NULL) {
unifi_error(priv, "sme_log_event: invalid smepriv\n");
func_exit();
return;
}
unifi_trace(priv, UDBG3,
"sme_log_event: Process signal 0x%.4X\n",
CSR_GET_UINT16_FROM_LITTLE_ENDIAN(signal));
/* If the signal is known, then do any filtering required, otherwise it pass it to the SME. */
r = read_unpack_signal(signal, &unpacked_signal);
if (r == CSR_RESULT_SUCCESS) {
if ((unpacked_signal.SignalPrimitiveHeader.SignalId == CSR_DEBUG_STRING_INDICATION_ID) ||
(unpacked_signal.SignalPrimitiveHeader.SignalId == CSR_DEBUG_WORD16_INDICATION_ID))
{
func_exit();
return;
}
if (unpacked_signal.SignalPrimitiveHeader.SignalId == CSR_MA_PACKET_INDICATION_ID)
{
u16 frmCtrl;
CsrBool unicastPdu = TRUE;
u8 *macHdrLocation;
u8 *raddr = NULL, *taddr = NULL;
CsrWifiMacAddress peerMacAddress;
/* Check if we need to send CsrWifiRouterCtrlMicFailureInd*/
CSR_MA_PACKET_INDICATION *ind = &unpacked_signal.u.MaPacketIndication;
macHdrLocation = (u8 *) bulkdata->d[0].os_data_ptr;
/* Fetch the frame control value from mac header */
frmCtrl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(macHdrLocation);
/* Point to the addresses */
raddr = macHdrLocation + MAC_HEADER_ADDR1_OFFSET;
taddr = macHdrLocation + MAC_HEADER_ADDR2_OFFSET;
CsrMemCpy(peerMacAddress.a, taddr, ETH_ALEN);
if(ind->ReceptionStatus == CSR_MICHAEL_MIC_ERROR)
{
if (*raddr & 0x1)
unicastPdu = FALSE;
CsrWifiRouterCtrlMicFailureIndSend (priv->CSR_WIFI_SME_IFACEQUEUE, 0,
(ind->VirtualInterfaceIdentifier & 0xff),peerMacAddress,
unicastPdu);
return;
}
else
{
if(ind->ReceptionStatus == CSR_RX_SUCCESS)
{
u8 pmBit = (frmCtrl & 0x1000)?0x01:0x00;
u16 interfaceTag = (ind->VirtualInterfaceIdentifier & 0xff);
CsrWifiRouterCtrlStaInfo_t *srcStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv,taddr,interfaceTag);
if((srcStaInfo != NULL) && (uf_check_broadcast_bssid(priv, bulkdata)== FALSE))
{
uf_process_pm_bit_for_peer(priv,srcStaInfo,pmBit,interfaceTag);
/* Update station last activity flag */
srcStaInfo->activity_flag = TRUE;
}
}
}
}
if (unpacked_signal.SignalPrimitiveHeader.SignalId == CSR_MA_PACKET_CONFIRM_ID)
{
CSR_MA_PACKET_CONFIRM *cfm = &unpacked_signal.u.MaPacketConfirm;
u16 interfaceTag = (cfm->VirtualInterfaceIdentifier & 0xff);
netInterface_priv_t *interfacePriv;
CSR_MA_PACKET_REQUEST *req;
CsrWifiMacAddress peerMacAddress;
if (interfaceTag >= CSR_WIFI_NUM_INTERFACES)
{
unifi_error(priv, "Bad MA_PACKET_CONFIRM interfaceTag %d\n", interfaceTag);
func_exit();
return;
}
unifi_trace(priv,UDBG1,"MA-PACKET Confirm (%x, %x)\n", cfm->HostTag, cfm->TransmissionStatus);
interfacePriv = priv->interfacePriv[interfaceTag];
#ifdef CSR_SUPPORT_SME
if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
if(cfm->HostTag == interfacePriv->multicastPduHostTag){
uf_process_ma_pkt_cfm_for_ap(priv ,interfaceTag, cfm);
}
}
#endif
req = &interfacePriv->m4_signal.u.MaPacketRequest;
if(cfm->HostTag & 0x80000000)
{
if (cfm->TransmissionStatus != CSR_TX_SUCCESSFUL)
{
result = CSR_RESULT_FAILURE;
}
#ifdef CSR_SUPPORT_SME
memcpy(peerMacAddress.a, req->Ra.x, ETH_ALEN);
/* Check if this is a confirm for EAPOL M4 frame and we need to send transmistted ind*/
if (interfacePriv->m4_sent && (cfm->HostTag == interfacePriv->m4_hostTag))
{
unifi_trace(priv, UDBG1, "%s: Sending M4 Transmit CFM\n", __FUNCTION__);
CsrWifiRouterCtrlM4TransmittedIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0,
interfaceTag,
peerMacAddress,
result);
interfacePriv->m4_sent = FALSE;
interfacePriv->m4_hostTag = 0xffffffff;
}
#endif
/* If EAPOL was requested via router APIs then send cfm else ignore*/
if((cfm->HostTag & 0x80000000) != CSR_WIFI_EAPOL_M4_HOST_TAG) {
CsrWifiRouterMaPacketCfmSend((u16)signal[2],
cfm->VirtualInterfaceIdentifier,
result,
(cfm->HostTag & 0x3fffffff), cfm->Rate);
} else {
unifi_trace(priv, UDBG1, "%s: M4 received from netdevice\n", __FUNCTION__);
}
func_exit();
return;
}
}
}
mlmeCommand.length = signal_len;
mlmeCommand.data = (u8*)signal;
dataref1.length = bulkdata->d[0].data_length;
if (dataref1.length > 0) {
dataref1.data = (u8 *) bulkdata->d[0].os_data_ptr;
} else
{
dataref1.data = NULL;
}
dataref2.length = bulkdata->d[1].data_length;
if (dataref2.length > 0) {
dataref2.data = (u8 *) bulkdata->d[1].os_data_ptr;
} else
{
dataref2.data = NULL;
}
CsrWifiRouterCtrlHipIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, mlmeCommand.length, mlmeCommand.data,
dataref1.length, dataref1.data,
dataref2.length, dataref2.data);
func_exit();
} /* sme_log_event() */
/*
* ---------------------------------------------------------------------------
* uf_sme_port_state
*
* Return the state of the controlled port.
*
* Arguments:
* priv Pointer to device private context struct
* address Pointer to the destination for tx or sender for rx address
* queue Controlled or uncontrolled queue
*
* Returns:
* An unifi_ControlledPortAction value.
* ---------------------------------------------------------------------------
*/
CsrWifiRouterCtrlPortAction
uf_sme_port_state(unifi_priv_t *priv, unsigned char *address, int queue, u16 interfaceTag)
{
int i;
unifi_port_config_t *port;
netInterface_priv_t *interfacePriv;
if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
unifi_error(priv, "uf_sme_port_state: bad interfaceTag\n");
return CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
}
interfacePriv = priv->interfacePriv[interfaceTag];
if (queue == UF_CONTROLLED_PORT_Q) {
port = &interfacePriv->controlled_data_port;
} else {
port = &interfacePriv->uncontrolled_data_port;
}
if (!port->entries_in_use) {
unifi_trace(priv, UDBG5, "No port configurations, return Discard.\n");
return CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
}
/* If the port configuration is common for all destinations, return it. */
if (port->overide_action == UF_DATA_PORT_OVERIDE) {
unifi_trace(priv, UDBG5, "Single port configuration (%d).\n",
port->port_cfg[0].port_action);
return port->port_cfg[0].port_action;
}
unifi_trace(priv, UDBG5, "Multiple (%d) port configurations.\n", port->entries_in_use);
/* If multiple configurations exist.. */
for (i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
/* .. go through the list and match the destination address. */
if (port->port_cfg[i].in_use &&
memcmp(address, port->port_cfg[i].mac_address.a, ETH_ALEN) == 0) {
/* Return the desired action. */
return port->port_cfg[i].port_action;
}
}
/* Could not find any information, return Open. */
unifi_trace(priv, UDBG5, "port configuration not found, return Open.\n");
return CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN;
} /* uf_sme_port_state() */
/*
* ---------------------------------------------------------------------------
* uf_sme_port_config_handle
*
* Return the port config handle of the controlled/uncontrolled port.
*
* Arguments:
* priv Pointer to device private context struct
* address Pointer to the destination for tx or sender for rx address
* queue Controlled or uncontrolled queue
*
* Returns:
* An unifi_port_cfg_t* .
* ---------------------------------------------------------------------------
*/
unifi_port_cfg_t*
uf_sme_port_config_handle(unifi_priv_t *priv, unsigned char *address, int queue, u16 interfaceTag)
{
int i;
unifi_port_config_t *port;
netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
unifi_error(priv, "uf_sme_port_config_handle: bad interfaceTag\n");
return NULL;
}
if (queue == UF_CONTROLLED_PORT_Q) {
port = &interfacePriv->controlled_data_port;
} else {
port = &interfacePriv->uncontrolled_data_port;
}
if (!port->entries_in_use) {
unifi_trace(priv, UDBG5, "No port configurations, return Discard.\n");
return NULL;
}
/* If the port configuration is common for all destinations, return it. */
if (port->overide_action == UF_DATA_PORT_OVERIDE) {
unifi_trace(priv, UDBG5, "Single port configuration (%d).\n",
port->port_cfg[0].port_action);
if (address) {
unifi_trace(priv, UDBG5, "addr[0] = %x, addr[1] = %x, addr[2] = %x, addr[3] = %x\n", address[0], address[1], address[2], address[3]);
}
return &port->port_cfg[0];
}
unifi_trace(priv, UDBG5, "Multiple port configurations.\n");
/* If multiple configurations exist.. */
for (i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
/* .. go through the list and match the destination address. */
if (port->port_cfg[i].in_use &&
memcmp(address, port->port_cfg[i].mac_address.a, ETH_ALEN) == 0) {
/* Return the desired action. */
return &port->port_cfg[i];
}
}
/* Could not find any information, return Open. */
unifi_trace(priv, UDBG5, "port configuration not found, returning NULL (debug).\n");
return NULL;
} /* uf_sme_port_config_handle */
void
uf_multicast_list_wq(struct work_struct *work)
{
unifi_priv_t *priv = container_of(work, unifi_priv_t,
multicast_list_task);
int i;
u16 interfaceTag = 0;
CsrWifiMacAddress* multicast_address_list = NULL;
int mc_count;
u8 *mc_list;
netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
unifi_error(priv, "uf_multicast_list_wq: bad interfaceTag\n");
return;
}
unifi_trace(priv, UDBG5,
"uf_multicast_list_wq: list count = %d\n",
interfacePriv->mc_list_count);
/* Flush the current list */
CsrWifiRouterCtrlMulticastAddressIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,0, interfaceTag, CSR_WIFI_SME_LIST_ACTION_FLUSH, 0, NULL);
mc_count = interfacePriv->mc_list_count;
mc_list = interfacePriv->mc_list;
/*
* Allocate a new list, need to free it later
* in unifi_mgt_multicast_address_cfm().
*/
multicast_address_list = CsrPmemAlloc(mc_count * sizeof(CsrWifiMacAddress));
if (multicast_address_list == NULL) {
return;
}
for (i = 0; i < mc_count; i++) {
memcpy(multicast_address_list[i].a, mc_list, ETH_ALEN);
mc_list += ETH_ALEN;
}
if (priv->smepriv == NULL) {
CsrPmemFree(multicast_address_list);
return;
}
CsrWifiRouterCtrlMulticastAddressIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,0,
interfaceTag,
CSR_WIFI_SME_LIST_ACTION_ADD,
mc_count, multicast_address_list);
/* The SME will take a copy of the addreses*/
CsrPmemFree(multicast_address_list);
}
int unifi_cfg_power(unifi_priv_t *priv, unsigned char *arg)
{
unifi_cfg_power_t cfg_power;
int rc;
int wol;
if (get_user(cfg_power, (unifi_cfg_power_t*)(((unifi_cfg_command_t*)arg) + 1))) {
unifi_error(priv, "UNIFI_CFG: Failed to get the argument\n");
return -EFAULT;
}
switch (cfg_power) {
case UNIFI_CFG_POWER_OFF:
priv->wol_suspend = (enable_wol == UNIFI_WOL_OFF) ? FALSE : TRUE;
rc = sme_sys_suspend(priv);
if (rc) {
return rc;
}
break;
case UNIFI_CFG_POWER_ON:
wol = priv->wol_suspend;
rc = sme_sys_resume(priv);
if (rc) {
return rc;
}
if (wol) {
/* Kick the BH to ensure pending transfers are handled when
* a suspend happened with card powered.
*/
unifi_send_signal(priv->card, NULL, 0, NULL);
}
break;
default:
unifi_error(priv, "WIFI POWER: Unknown value.\n");
return -EINVAL;
}
return 0;
}
int unifi_cfg_power_save(unifi_priv_t *priv, unsigned char *arg)
{
unifi_cfg_powersave_t cfg_power_save;
CsrWifiSmePowerConfig powerConfig;
int rc;
if (get_user(cfg_power_save, (unifi_cfg_powersave_t*)(((unifi_cfg_command_t*)arg) + 1))) {
unifi_error(priv, "UNIFI_CFG: Failed to get the argument\n");
return -EFAULT;
}
/* Get the coex info from the SME */
rc = sme_mgt_power_config_get(priv, &powerConfig);
if (rc) {
unifi_error(priv, "UNIFI_CFG: Get unifi_PowerConfigValue failed.\n");
return rc;
}
switch (cfg_power_save) {
case UNIFI_CFG_POWERSAVE_NONE:
powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW;
break;
case UNIFI_CFG_POWERSAVE_FAST:
powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_MED;
break;
case UNIFI_CFG_POWERSAVE_FULL:
powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_HIGH;
break;
case UNIFI_CFG_POWERSAVE_AUTO:
powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_AUTO;
break;
default:
unifi_error(priv, "POWERSAVE: Unknown value.\n");
return -EINVAL;
}
rc = sme_mgt_power_config_set(priv, &powerConfig);
if (rc) {
unifi_error(priv, "UNIFI_CFG: Set unifi_PowerConfigValue failed.\n");
}
return rc;
}
int unifi_cfg_power_supply(unifi_priv_t *priv, unsigned char *arg)
{
unifi_cfg_powersupply_t cfg_power_supply;
CsrWifiSmeHostConfig hostConfig;
int rc;
if (get_user(cfg_power_supply, (unifi_cfg_powersupply_t*)(((unifi_cfg_command_t*)arg) + 1))) {
unifi_error(priv, "UNIFI_CFG: Failed to get the argument\n");
return -EFAULT;
}
/* Get the coex info from the SME */
rc = sme_mgt_host_config_get(priv, &hostConfig);
if (rc) {
unifi_error(priv, "UNIFI_CFG: Get unifi_HostConfigValue failed.\n");
return rc;
}
switch (cfg_power_supply) {
case UNIFI_CFG_POWERSUPPLY_MAINS:
hostConfig.powerMode = CSR_WIFI_SME_HOST_POWER_MODE_ACTIVE;
break;
case UNIFI_CFG_POWERSUPPLY_BATTERIES:
hostConfig.powerMode = CSR_WIFI_SME_HOST_POWER_MODE_POWER_SAVE;
break;
default:
unifi_error(priv, "POWERSUPPLY: Unknown value.\n");
return -EINVAL;
}
rc = sme_mgt_host_config_set(priv, &hostConfig);
if (rc) {
unifi_error(priv, "UNIFI_CFG: Set unifi_HostConfigValue failed.\n");
}
return rc;
}
int unifi_cfg_packet_filters(unifi_priv_t *priv, unsigned char *arg)
{
unsigned char *tclas_buffer;
unsigned int tclas_buffer_length;
tclas_t *dhcp_tclas;
int rc;
/* Free any TCLASs previously allocated */
if (priv->packet_filters.tclas_ies_length) {
CsrPmemFree(priv->filter_tclas_ies);
priv->filter_tclas_ies = NULL;
}
tclas_buffer = ((unsigned char*)arg) + sizeof(unifi_cfg_command_t) + sizeof(unsigned int);
if (copy_from_user(&priv->packet_filters, (void*)tclas_buffer,
sizeof(uf_cfg_bcast_packet_filter_t))) {
unifi_error(priv, "UNIFI_CFG: Failed to get the filter struct\n");
return -EFAULT;
}
tclas_buffer_length = priv->packet_filters.tclas_ies_length;
/* Allocate TCLASs if necessary */
if (priv->packet_filters.dhcp_filter) {
priv->packet_filters.tclas_ies_length += sizeof(tclas_t);
}
if (priv->packet_filters.tclas_ies_length > 0) {
priv->filter_tclas_ies = CsrPmemAlloc(priv->packet_filters.tclas_ies_length);
if (priv->filter_tclas_ies == NULL) {
return -ENOMEM;
}
if (tclas_buffer_length) {
tclas_buffer += sizeof(uf_cfg_bcast_packet_filter_t) - sizeof(unsigned char*);
if (copy_from_user(priv->filter_tclas_ies,
tclas_buffer,
tclas_buffer_length)) {
unifi_error(priv, "UNIFI_CFG: Failed to get the TCLAS buffer\n");
return -EFAULT;
}
}
}
if(priv->packet_filters.dhcp_filter)
{
/* Append the DHCP tclas IE */
dhcp_tclas = (tclas_t*)(priv->filter_tclas_ies + tclas_buffer_length);
memset(dhcp_tclas, 0, sizeof(tclas_t));
dhcp_tclas->element_id = 14;
dhcp_tclas->length = sizeof(tcpip_clsfr_t) + 1;
dhcp_tclas->user_priority = 0;
dhcp_tclas->tcp_ip_cls_fr.cls_fr_type = 1;
dhcp_tclas->tcp_ip_cls_fr.version = 4;
((u8*)(&dhcp_tclas->tcp_ip_cls_fr.source_port))[0] = 0x00;
((u8*)(&dhcp_tclas->tcp_ip_cls_fr.source_port))[1] = 0x44;
((u8*)(&dhcp_tclas->tcp_ip_cls_fr.dest_port))[0] = 0x00;
((u8*)(&dhcp_tclas->tcp_ip_cls_fr.dest_port))[1] = 0x43;
dhcp_tclas->tcp_ip_cls_fr.protocol = 0x11;
dhcp_tclas->tcp_ip_cls_fr.cls_fr_mask = 0x58; //bits: 3,4,6
}
rc = sme_mgt_packet_filter_set(priv);
return rc;
}
int unifi_cfg_wmm_qos_info(unifi_priv_t *priv, unsigned char *arg)
{
u8 wmm_qos_info;
int rc = 0;
if (get_user(wmm_qos_info, (u8*)(((unifi_cfg_command_t*)arg) + 1))) {
unifi_error(priv, "UNIFI_CFG: Failed to get the argument\n");
return -EFAULT;
}
/* Store the value in the connection info */
priv->connection_config.wmmQosInfo = wmm_qos_info;
return rc;
}
int unifi_cfg_wmm_addts(unifi_priv_t *priv, unsigned char *arg)
{
CsrUint32 addts_tid;
u8 addts_ie_length;
u8 *addts_ie;
u8 *addts_params;
CsrWifiSmeDataBlock tspec;
CsrWifiSmeDataBlock tclas;
int rc;
addts_params = (u8*)(((unifi_cfg_command_t*)arg) + 1);
if (get_user(addts_tid, (CsrUint32*)addts_params)) {
unifi_error(priv, "unifi_cfg_wmm_addts: Failed to get the argument\n");
return -EFAULT;
}
addts_params += sizeof(CsrUint32);
if (get_user(addts_ie_length, (u8*)addts_params)) {
unifi_error(priv, "unifi_cfg_wmm_addts: Failed to get the argument\n");
return -EFAULT;
}
unifi_trace(priv, UDBG4, "addts: tid = 0x%x ie_length = %d\n",
addts_tid, addts_ie_length);
addts_ie = CsrPmemAlloc(addts_ie_length);
if (addts_ie == NULL) {
unifi_error(priv,
"unifi_cfg_wmm_addts: Failed to malloc %d bytes for addts_ie buffer\n",
addts_ie_length);
return -ENOMEM;
}
addts_params += sizeof(u8);
rc = copy_from_user(addts_ie, addts_params, addts_ie_length);
if (rc) {
unifi_error(priv, "unifi_cfg_wmm_addts: Failed to get the addts buffer\n");
CsrPmemFree(addts_ie);
return -EFAULT;
}
tspec.data = addts_ie;
tspec.length = addts_ie_length;
tclas.data = NULL;
tclas.length = 0;
rc = sme_mgt_tspec(priv, CSR_WIFI_SME_LIST_ACTION_ADD, addts_tid,
&tspec, &tclas);
CsrPmemFree(addts_ie);
return rc;
}
int unifi_cfg_wmm_delts(unifi_priv_t *priv, unsigned char *arg)
{
CsrUint32 delts_tid;
u8 *delts_params;
CsrWifiSmeDataBlock tspec;
CsrWifiSmeDataBlock tclas;
int rc;
delts_params = (u8*)(((unifi_cfg_command_t*)arg) + 1);
if (get_user(delts_tid, (CsrUint32*)delts_params)) {
unifi_error(priv, "unifi_cfg_wmm_delts: Failed to get the argument\n");
return -EFAULT;
}
unifi_trace(priv, UDBG4, "delts: tid = 0x%x\n", delts_tid);
tspec.data = tclas.data = NULL;
tspec.length = tclas.length = 0;
rc = sme_mgt_tspec(priv, CSR_WIFI_SME_LIST_ACTION_REMOVE, delts_tid,
&tspec, &tclas);
return rc;
}
int unifi_cfg_strict_draft_n(unifi_priv_t *priv, unsigned char *arg)
{
CsrBool strict_draft_n;
u8 *strict_draft_n_params;
int rc;
CsrWifiSmeStaConfig staConfig;
CsrWifiSmeDeviceConfig deviceConfig;
strict_draft_n_params = (u8*)(((unifi_cfg_command_t*)arg) + 1);
if (get_user(strict_draft_n, (CsrBool*)strict_draft_n_params)) {
unifi_error(priv, "unifi_cfg_strict_draft_n: Failed to get the argument\n");
return -EFAULT;
}
unifi_trace(priv, UDBG4, "strict_draft_n: = %s\n", ((strict_draft_n) ? "yes":"no"));
rc = sme_mgt_sme_config_get(priv, &staConfig, &deviceConfig);
if (rc) {
unifi_warning(priv, "unifi_cfg_strict_draft_n: Get unifi_SMEConfigValue failed.\n");
return -EFAULT;
}
deviceConfig.enableStrictDraftN = strict_draft_n;
rc = sme_mgt_sme_config_set(priv, &staConfig, &deviceConfig);
if (rc) {
unifi_warning(priv, "unifi_cfg_strict_draft_n: Set unifi_SMEConfigValue failed.\n");
rc = -EFAULT;
}
return rc;
}
int unifi_cfg_enable_okc(unifi_priv_t *priv, unsigned char *arg)
{
CsrBool enable_okc;
u8 *enable_okc_params;
int rc;
CsrWifiSmeStaConfig staConfig;
CsrWifiSmeDeviceConfig deviceConfig;
enable_okc_params = (u8*)(((unifi_cfg_command_t*)arg) + 1);
if (get_user(enable_okc, (CsrBool*)enable_okc_params)) {
unifi_error(priv, "unifi_cfg_enable_okc: Failed to get the argument\n");
return -EFAULT;
}
unifi_trace(priv, UDBG4, "enable_okc: = %s\n", ((enable_okc) ? "yes":"no"));
rc = sme_mgt_sme_config_get(priv, &staConfig, &deviceConfig);
if (rc) {
unifi_warning(priv, "unifi_cfg_enable_okc: Get unifi_SMEConfigValue failed.\n");
return -EFAULT;
}
staConfig.enableOpportunisticKeyCaching = enable_okc;
rc = sme_mgt_sme_config_set(priv, &staConfig, &deviceConfig);
if (rc) {
unifi_warning(priv, "unifi_cfg_enable_okc: Set unifi_SMEConfigValue failed.\n");
rc = -EFAULT;
}
return rc;
}
int unifi_cfg_get_info(unifi_priv_t *priv, unsigned char *arg)
{
unifi_cfg_get_t get_cmd;
char inst_name[IFNAMSIZ];
int rc;
if (get_user(get_cmd, (unifi_cfg_get_t*)(((unifi_cfg_command_t*)arg) + 1))) {
unifi_error(priv, "UNIFI_CFG: Failed to get the argument\n");
return -EFAULT;
}
switch (get_cmd) {
case UNIFI_CFG_GET_COEX:
{
CsrWifiSmeCoexInfo coexInfo;
/* Get the coex info from the SME */
rc = sme_mgt_coex_info_get(priv, &coexInfo);
if (rc) {
unifi_error(priv, "UNIFI_CFG: Get unifi_CoexInfoValue failed.\n");
return rc;
}
/* Copy the info to the out buffer */
if (copy_to_user((void*)arg,
&coexInfo,
sizeof(CsrWifiSmeCoexInfo))) {
unifi_error(priv, "UNIFI_CFG: Failed to copy the coex info\n");
return -EFAULT;
}
break;
}
case UNIFI_CFG_GET_POWER_MODE:
{
CsrWifiSmePowerConfig powerConfig;
rc = sme_mgt_power_config_get(priv, &powerConfig);
if (rc) {
unifi_error(priv, "UNIFI_CFG: Get unifi_PowerConfigValue failed.\n");
return rc;
}
/* Copy the info to the out buffer */
if (copy_to_user((void*)arg,
&powerConfig.powerSaveLevel,
sizeof(CsrWifiSmePowerSaveLevel))) {
unifi_error(priv, "UNIFI_CFG: Failed to copy the power save info\n");
return -EFAULT;
}
break;
}
case UNIFI_CFG_GET_POWER_SUPPLY:
{
CsrWifiSmeHostConfig hostConfig;
rc = sme_mgt_host_config_get(priv, &hostConfig);
if (rc) {
unifi_error(priv, "UNIFI_CFG: Get unifi_HostConfigValue failed.\n");
return rc;
}
/* Copy the info to the out buffer */
if (copy_to_user((void*)arg,
&hostConfig.powerMode,
sizeof(CsrWifiSmeHostPowerMode))) {
unifi_error(priv, "UNIFI_CFG: Failed to copy the host power mode\n");
return -EFAULT;
}
break;
}
case UNIFI_CFG_GET_VERSIONS:
break;
case UNIFI_CFG_GET_INSTANCE:
{
u16 InterfaceId=0;
uf_net_get_name(priv->netdev[InterfaceId], &inst_name[0], sizeof(inst_name));
/* Copy the info to the out buffer */
if (copy_to_user((void*)arg,
&inst_name[0],
sizeof(inst_name))) {
unifi_error(priv, "UNIFI_CFG: Failed to copy the instance name\n");
return -EFAULT;
}
}
break;
case UNIFI_CFG_GET_AP_CONFIG:
{
#ifdef CSR_SUPPORT_WEXT_AP
uf_cfg_ap_config_t cfg_ap_config;
cfg_ap_config.channel = priv->ap_config.channel;
cfg_ap_config.beaconInterval = priv->ap_mac_config.beaconInterval;
cfg_ap_config.wmmEnabled = priv->ap_mac_config.wmmEnabled;
cfg_ap_config.dtimPeriod = priv->ap_mac_config.dtimPeriod;
cfg_ap_config.phySupportedBitmap = priv->ap_mac_config.phySupportedBitmap;
if (copy_to_user((void*)arg,
&cfg_ap_config,
sizeof(uf_cfg_ap_config_t))) {
unifi_error(priv, "UNIFI_CFG: Failed to copy the AP configuration\n");
return -EFAULT;
}
#else
return -EPERM;
#endif
}
break;
default:
unifi_error(priv, "unifi_cfg_get_info: Unknown value.\n");
return -EINVAL;
}
return 0;
}
#ifdef CSR_SUPPORT_WEXT_AP
int
uf_configure_supported_rates(u8 * supportedRates, u8 phySupportedBitmap)
{
int i=0;
CsrBool b=FALSE, g = FALSE, n = FALSE;
b = phySupportedBitmap & CSR_WIFI_SME_AP_PHY_SUPPORT_B;
n = phySupportedBitmap & CSR_WIFI_SME_AP_PHY_SUPPORT_N;
g = phySupportedBitmap & CSR_WIFI_SME_AP_PHY_SUPPORT_G;
if(b || g) {
supportedRates[i++]=0x82;
supportedRates[i++]=0x84;
supportedRates[i++]=0x8b;
supportedRates[i++]=0x96;
} else if(n) {
/* For some strange reasons WiFi stack needs both b and g rates*/
supportedRates[i++]=0x02;
supportedRates[i++]=0x04;
supportedRates[i++]=0x0b;
supportedRates[i++]=0x16;
supportedRates[i++]=0x0c;
supportedRates[i++]=0x12;
supportedRates[i++]=0x18;
supportedRates[i++]=0x24;
supportedRates[i++]=0x30;
supportedRates[i++]=0x48;
supportedRates[i++]=0x60;
supportedRates[i++]=0x6c;
}
if(g) {
if(!b) {
supportedRates[i++]=0x8c;
supportedRates[i++]=0x98;
supportedRates[i++]=0xb0;
} else {
supportedRates[i++]=0x0c;
supportedRates[i++]=0x18;
supportedRates[i++]=0x30;
}
supportedRates[i++]=0x48;
supportedRates[i++]=0x12;
supportedRates[i++]=0x24;
supportedRates[i++]=0x60;
supportedRates[i++]=0x6c;
}
return i;
}
int unifi_cfg_set_ap_config(unifi_priv_t * priv,unsigned char* arg)
{
uf_cfg_ap_config_t cfg_ap_config;
char *buffer;
buffer = ((unsigned char*)arg) + sizeof(unifi_cfg_command_t) + sizeof(unsigned int);
if (copy_from_user(&cfg_ap_config, (void*)buffer,
sizeof(uf_cfg_ap_config_t))) {
unifi_error(priv, "UNIFI_CFG: Failed to get the ap config struct\n");
return -EFAULT;
}
priv->ap_config.channel = cfg_ap_config.channel;
priv->ap_mac_config.dtimPeriod = cfg_ap_config.dtimPeriod;
priv->ap_mac_config.beaconInterval = cfg_ap_config.beaconInterval;
priv->group_sec_config.apGroupkeyTimeout = cfg_ap_config.groupkeyTimeout;
priv->group_sec_config.apStrictGtkRekey = cfg_ap_config.strictGtkRekeyEnabled;
priv->group_sec_config.apGmkTimeout = cfg_ap_config.gmkTimeout;
priv->group_sec_config.apResponseTimeout = cfg_ap_config.responseTimeout;
priv->group_sec_config.apRetransLimit = cfg_ap_config.retransLimit;
priv->ap_mac_config.shortSlotTimeEnabled = cfg_ap_config.shortSlotTimeEnabled;
priv->ap_mac_config.ctsProtectionType=cfg_ap_config.ctsProtectionType;
priv->ap_mac_config.wmmEnabled = cfg_ap_config.wmmEnabled;
priv->ap_mac_config.apHtParams.rxStbc=cfg_ap_config.rxStbc;
priv->ap_mac_config.apHtParams.rifsModeAllowed=cfg_ap_config.rifsModeAllowed;
priv->ap_mac_config.phySupportedBitmap = cfg_ap_config.phySupportedBitmap;
priv->ap_mac_config.maxListenInterval=cfg_ap_config.maxListenInterval;
priv->ap_mac_config.supportedRatesCount= uf_configure_supported_rates(priv->ap_mac_config.supportedRates,priv->ap_mac_config.phySupportedBitmap);
return 0;
}
#endif
#ifdef CSR_SUPPORT_WEXT
void
uf_sme_config_wq(struct work_struct *work)
{
CsrWifiSmeStaConfig staConfig;
CsrWifiSmeDeviceConfig deviceConfig;
unifi_priv_t *priv = container_of(work, unifi_priv_t, sme_config_task);
/* Register to receive indications from the SME */
CsrWifiSmeEventMaskSetReqSend(0,
CSR_WIFI_SME_INDICATIONS_WIFIOFF | CSR_WIFI_SME_INDICATIONS_CONNECTIONQUALITY |
CSR_WIFI_SME_INDICATIONS_MEDIASTATUS | CSR_WIFI_SME_INDICATIONS_MICFAILURE);
if (sme_mgt_sme_config_get(priv, &staConfig, &deviceConfig)) {
unifi_warning(priv, "uf_sme_config_wq: Get unifi_SMEConfigValue failed.\n");
return;
}
if (priv->if_index == CSR_INDEX_5G) {
staConfig.ifIndex = CSR_WIFI_SME_RADIO_IF_GHZ_5_0;
} else {
staConfig.ifIndex = CSR_WIFI_SME_RADIO_IF_GHZ_2_4;
}
deviceConfig.trustLevel = (CsrWifiSme80211dTrustLevel)tl_80211d;
if (sme_mgt_sme_config_set(priv, &staConfig, &deviceConfig)) {
unifi_warning(priv,
"SME config for 802.11d Trust Level and Radio Band failed.\n");
return;
}
} /* uf_sme_config_wq() */
#endif /* CSR_SUPPORT_WEXT */
/*
* ---------------------------------------------------------------------------
* uf_ta_ind_wq
*
* Deferred work queue function to send Traffic Analysis protocols
* indications to the SME.
* These are done in a deferred work queue for two reasons:
* - the CsrWifiRouterCtrl...Send() functions are not safe for atomic context
* - we want to load the main driver data path as lightly as possible
*
* The TA classifications already come from a workqueue.
*
* Arguments:
* work Pointer to work queue item.
*
* Returns:
* None.
* ---------------------------------------------------------------------------
*/
void
uf_ta_ind_wq(struct work_struct *work)
{
struct ta_ind *ind = container_of(work, struct ta_ind, task);
unifi_priv_t *priv = container_of(ind, unifi_priv_t, ta_ind_work);
u16 interfaceTag = 0;
CsrWifiRouterCtrlTrafficProtocolIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,0,
interfaceTag,
ind->packet_type,
ind->direction,
ind->src_addr);
ind->in_use = 0;
} /* uf_ta_ind_wq() */
/*
* ---------------------------------------------------------------------------
* uf_ta_sample_ind_wq
*
* Deferred work queue function to send Traffic Analysis sample
* indications to the SME.
* These are done in a deferred work queue for two reasons:
* - the CsrWifiRouterCtrl...Send() functions are not safe for atomic context
* - we want to load the main driver data path as lightly as possible
*
* The TA classifications already come from a workqueue.
*
* Arguments:
* work Pointer to work queue item.
*
* Returns:
* None.
* ---------------------------------------------------------------------------
*/
void
uf_ta_sample_ind_wq(struct work_struct *work)
{
struct ta_sample_ind *ind = container_of(work, struct ta_sample_ind, task);
unifi_priv_t *priv = container_of(ind, unifi_priv_t, ta_sample_ind_work);
u16 interfaceTag = 0;
unifi_trace(priv, UDBG5, "rxtcp %d txtcp %d rxudp %d txudp %d prio %d\n",
priv->rxTcpThroughput,
priv->txTcpThroughput,
priv->rxUdpThroughput,
priv->txUdpThroughput,
priv->bh_thread.prio);
if(priv->rxTcpThroughput > 1000)
{
if (bh_priority == -1 && priv->bh_thread.prio != 1)
{
struct sched_param param;
priv->bh_thread.prio = 1;
unifi_trace(priv, UDBG1, "%s new thread (RT) priority = %d\n",
priv->bh_thread.name, priv->bh_thread.prio);
param.sched_priority = priv->bh_thread.prio;
sched_setscheduler(priv->bh_thread.thread_task, SCHED_FIFO, ¶m);
}
} else
{
if (bh_priority == -1 && priv->bh_thread.prio != DEFAULT_PRIO)
{
struct sched_param param;
param.sched_priority = 0;
sched_setscheduler(priv->bh_thread.thread_task, SCHED_NORMAL, ¶m);
priv->bh_thread.prio = DEFAULT_PRIO;
unifi_trace(priv, UDBG1, "%s new thread priority = %d\n",
priv->bh_thread.name, priv->bh_thread.prio);
set_user_nice(priv->bh_thread.thread_task, PRIO_TO_NICE(priv->bh_thread.prio));
}
}
CsrWifiRouterCtrlTrafficSampleIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,0, interfaceTag, ind->stats);
ind->in_use = 0;
} /* uf_ta_sample_ind_wq() */
/*
* ---------------------------------------------------------------------------
* uf_send_m4_ready_wq
*
* Deferred work queue function to send M4 ReadyToSend inds to the SME.
* These are done in a deferred work queue for two reasons:
* - the CsrWifiRouterCtrl...Send() functions are not safe for atomic context
* - we want to load the main driver data path as lightly as possible
*
* Arguments:
* work Pointer to work queue item.
*
* Returns:
* None.
* ---------------------------------------------------------------------------
*/
void
uf_send_m4_ready_wq(struct work_struct *work)
{
netInterface_priv_t *InterfacePriv = container_of(work, netInterface_priv_t, send_m4_ready_task);
u16 iface = InterfacePriv->InterfaceTag;
unifi_priv_t *priv = InterfacePriv->privPtr;
CSR_MA_PACKET_REQUEST *req = &InterfacePriv->m4_signal.u.MaPacketRequest;
CsrWifiMacAddress peer;
unsigned long flags;
func_enter();
/* The peer address was stored in the signal */
spin_lock_irqsave(&priv->m4_lock, flags);
memcpy(peer.a, req->Ra.x, sizeof(peer.a));
spin_unlock_irqrestore(&priv->m4_lock, flags);
/* Send a signal to SME */
CsrWifiRouterCtrlM4ReadyToSendIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, iface, peer);
unifi_trace(priv, UDBG1, "M4ReadyToSendInd sent for peer %pMF\n",
peer.a);
func_exit();
} /* uf_send_m4_ready_wq() */
#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
/*
* ---------------------------------------------------------------------------
* uf_send_pkt_to_encrypt
*
* Deferred work queue function to send the WAPI data pkts to SME when unicast KeyId = 1
* These are done in a deferred work queue for two reasons:
* - the CsrWifiRouterCtrl...Send() functions are not safe for atomic context
* - we want to load the main driver data path as lightly as possible
*
* Arguments:
* work Pointer to work queue item.
*
* Returns:
* None.
* ---------------------------------------------------------------------------
*/
void uf_send_pkt_to_encrypt(struct work_struct *work)
{
netInterface_priv_t *interfacePriv = container_of(work, netInterface_priv_t, send_pkt_to_encrypt);
u16 interfaceTag = interfacePriv->InterfaceTag;
unifi_priv_t *priv = interfacePriv->privPtr;
CsrUint32 pktBulkDataLength;
u8 *pktBulkData;
unsigned long flags;
if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_STA) {
func_enter();
pktBulkDataLength = interfacePriv->wapi_unicast_bulk_data.data_length;
if (pktBulkDataLength > 0) {
pktBulkData = (u8 *)CsrPmemAlloc(pktBulkDataLength);
CsrMemSet(pktBulkData, 0, pktBulkDataLength);
} else {
unifi_error(priv, "uf_send_pkt_to_encrypt() : invalid buffer\n");
return;
}
spin_lock_irqsave(&priv->wapi_lock, flags);
/* Copy over the MA PKT REQ bulk data */
CsrMemCpy(pktBulkData, (u8*)interfacePriv->wapi_unicast_bulk_data.os_data_ptr, pktBulkDataLength);
/* Free any bulk data buffers allocated for the WAPI Data pkt */
unifi_net_data_free(priv, &interfacePriv->wapi_unicast_bulk_data);
interfacePriv->wapi_unicast_bulk_data.net_buf_length = 0;
interfacePriv->wapi_unicast_bulk_data.data_length = 0;
interfacePriv->wapi_unicast_bulk_data.os_data_ptr = interfacePriv->wapi_unicast_bulk_data.os_net_buf_ptr = NULL;
spin_unlock_irqrestore(&priv->wapi_lock, flags);
CsrWifiRouterCtrlWapiUnicastTxEncryptIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, pktBulkDataLength, pktBulkData);
unifi_trace(priv, UDBG1, "WapiUnicastTxEncryptInd sent to SME\n");
CsrPmemFree(pktBulkData); /* Would have been copied over by the SME Handler */
func_exit();
} else {
unifi_warning(priv, "uf_send_pkt_to_encrypt() is NOT applicable for interface mode - %d\n",interfacePriv->interfaceMode);
}
}/* uf_send_pkt_to_encrypt() */
#endif
|