1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#include <linux/version.h>
18#include <linux/types.h>
19#include <linux/etherdevice.h>
20#include <linux/vmalloc.h>
21
22#include "csr_wifi_hip_unifi.h"
23#include "csr_wifi_hip_conversions.h"
24#include "csr_time.h"
25#include "unifi_priv.h"
26#include <net/pkt_sched.h>
27
28#ifdef CSR_SUPPORT_SME
29static void _update_buffered_pkt_params_after_alignment(unifi_priv_t *priv, bulk_data_param_t *bulkdata,
30 tx_buffered_packets_t* buffered_pkt)
31{
32 struct sk_buff *skb ;
33 u32 align_offset;
34
35 if (priv == NULL || bulkdata == NULL || buffered_pkt == NULL){
36 return;
37 }
38
39 skb = (struct sk_buff*)bulkdata->d[0].os_net_buf_ptr;
40 align_offset = (u32)(long)(bulkdata->d[0].os_data_ptr) & (CSR_WIFI_ALIGN_BYTES-1);
41 if(align_offset){
42 skb_pull(skb,align_offset);
43 }
44
45 buffered_pkt->bulkdata.os_data_ptr = bulkdata->d[0].os_data_ptr;
46 buffered_pkt->bulkdata.data_length = bulkdata->d[0].data_length;
47 buffered_pkt->bulkdata.os_net_buf_ptr = bulkdata->d[0].os_net_buf_ptr;
48 buffered_pkt->bulkdata.net_buf_length = bulkdata->d[0].net_buf_length;
49}
50#endif
51
52void
53unifi_frame_ma_packet_req(unifi_priv_t *priv, CSR_PRIORITY priority,
54 CSR_RATE TransmitRate, CSR_CLIENT_TAG hostTag,
55 u16 interfaceTag, CSR_TRANSMISSION_CONTROL transmissionControl,
56 CSR_PROCESS_ID leSenderProcessId, u8 *peerMacAddress,
57 CSR_SIGNAL *signal)
58{
59
60 CSR_MA_PACKET_REQUEST *req = &signal->u.MaPacketRequest;
61 netInterface_priv_t *interfacePriv;
62 u8 ba_session_idx = 0;
63 ba_session_tx_struct *ba_session = NULL;
64 u8 *ba_addr = NULL;
65
66 interfacePriv = priv->interfacePriv[interfaceTag];
67
68 unifi_trace(priv, UDBG5,
69 "In unifi_frame_ma_packet_req, Frame for Peer: %pMF\n",
70 peerMacAddress);
71 signal->SignalPrimitiveHeader.SignalId = CSR_MA_PACKET_REQUEST_ID;
72 signal->SignalPrimitiveHeader.ReceiverProcessId = 0;
73 signal->SignalPrimitiveHeader.SenderProcessId = leSenderProcessId;
74
75
76 req->Priority = priority;
77 unifi_trace(priv, UDBG3, "Tx Frame with Priority: 0x%x\n", req->Priority);
78
79
80
81
82
83 req->TransmitRate = TransmitRate;
84
85
86
87
88 req->TransmissionControl = transmissionControl;
89 req->VirtualInterfaceIdentifier =
90 uf_get_vif_identifier(interfacePriv->interfaceMode,interfaceTag);
91 memcpy(req->Ra.x, peerMacAddress, ETH_ALEN);
92
93 if (hostTag == 0xffffffff) {
94 req->HostTag = interfacePriv->tag++;
95 req->HostTag |= 0x40000000;
96 unifi_trace(priv, UDBG3, "new host tag assigned = 0x%x\n", req->HostTag);
97 interfacePriv->tag &= 0x0fffffff;
98 } else {
99 req->HostTag = hostTag;
100 unifi_trace(priv, UDBG3, "host tag got from SME = 0x%x\n", req->HostTag);
101 }
102
103 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
104 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO){
105 ba_addr = peerMacAddress;
106 }else{
107 ba_addr = interfacePriv->bssid.a;
108 }
109 for (ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_TX; ba_session_idx++){
110 ba_session = interfacePriv->ba_session_tx[ba_session_idx];
111 if (ba_session){
112 if ((!memcmp(ba_session->macAddress.a, ba_addr, ETH_ALEN)) && (ba_session->tID == priority)){
113 req->TransmissionControl |= CSR_ALLOW_BA;
114 break;
115 }
116 }
117 }
118
119 unifi_trace(priv, UDBG5, "leaving unifi_frame_ma_packet_req\n");
120}
121
122#ifdef CSR_SUPPORT_SME
123
124#define TRANSMISSION_CONTROL_TRIGGER_MASK 0x0001
125#define TRANSMISSION_CONTROL_EOSP_MASK 0x0002
126
127static
128int frame_and_send_queued_pdu(unifi_priv_t* priv,tx_buffered_packets_t* buffered_pkt,
129 CsrWifiRouterCtrlStaInfo_t *staRecord,u8 moreData , u8 eosp)
130{
131
132 CSR_SIGNAL signal;
133 bulk_data_param_t bulkdata;
134 int result;
135 u8 toDs, fromDs, macHeaderLengthInBytes = MAC_HEADER_SIZE;
136 u8 *qc;
137 u16 *fc = (u16*)(buffered_pkt->bulkdata.os_data_ptr);
138 unsigned long lock_flags;
139 unifi_trace(priv, UDBG3, "frame_and_send_queued_pdu with moreData: %d , EOSP: %d\n",moreData,eosp);
140 unifi_frame_ma_packet_req(priv, buffered_pkt->priority, buffered_pkt->rate, buffered_pkt->hostTag,
141 buffered_pkt->interfaceTag, buffered_pkt->transmissionControl,
142 buffered_pkt->leSenderProcessId, buffered_pkt->peerMacAddress.a, &signal);
143 bulkdata.d[0].os_data_ptr = buffered_pkt->bulkdata.os_data_ptr;
144 bulkdata.d[0].data_length = buffered_pkt->bulkdata.data_length;
145 bulkdata.d[0].os_net_buf_ptr = buffered_pkt->bulkdata.os_net_buf_ptr;
146 bulkdata.d[0].net_buf_length = buffered_pkt->bulkdata.net_buf_length;
147 bulkdata.d[1].os_data_ptr = NULL;
148 bulkdata.d[1].data_length = 0;
149 bulkdata.d[1].os_net_buf_ptr =0;
150 bulkdata.d[1].net_buf_length =0;
151
152 if(moreData) {
153 *fc |= cpu_to_le16(IEEE802_11_FC_MOREDATA_MASK);
154 } else {
155 *fc &= cpu_to_le16(~IEEE802_11_FC_MOREDATA_MASK);
156 }
157
158 if((staRecord != NULL)&& (staRecord->wmmOrQosEnabled == TRUE))
159 {
160 unifi_trace(priv, UDBG3, "frame_and_send_queued_pdu WMM Enabled: %d \n",staRecord->wmmOrQosEnabled);
161
162 toDs = (*fc & cpu_to_le16(IEEE802_11_FC_TO_DS_MASK))?1 : 0;
163 fromDs = (*fc & cpu_to_le16(IEEE802_11_FC_FROM_DS_MASK))? 1: 0;
164
165 switch(le16_to_cpu(*fc) & IEEE80211_FC_SUBTYPE_MASK)
166 {
167 case IEEE802_11_FC_TYPE_QOS_DATA & IEEE80211_FC_SUBTYPE_MASK:
168 case IEEE802_11_FC_TYPE_QOS_NULL & IEEE80211_FC_SUBTYPE_MASK:
169
170 if (fromDs && toDs) {
171
172 macHeaderLengthInBytes += (QOS_CONTROL_HEADER_SIZE + 6);
173 } else {
174 macHeaderLengthInBytes += QOS_CONTROL_HEADER_SIZE;
175 }
176
177
178 if (*fc & cpu_to_le16(IEEE80211_FC_ORDER_MASK)) {
179 macHeaderLengthInBytes += HT_CONTROL_HEADER_SIZE;
180 qc = (u8*)(buffered_pkt->bulkdata.os_data_ptr + (macHeaderLengthInBytes-6));
181 } else {
182 qc = (u8*)(buffered_pkt->bulkdata.os_data_ptr + (macHeaderLengthInBytes-2));
183 }
184 *qc = eosp ? *qc | (1 << 4) : *qc & (~(1 << 4));
185 break;
186 default:
187 if (fromDs && toDs)
188 macHeaderLengthInBytes += 6;
189 }
190
191 }
192 result = ul_send_signal_unpacked(priv, &signal, &bulkdata);
193 if(result){
194 _update_buffered_pkt_params_after_alignment(priv, &bulkdata,buffered_pkt);
195 }
196
197
198 if (result != -ENOSPC) {
199
200 if (!priv->noOfPktQueuedInDriver) {
201 unifi_error(priv, "packets queued in driver 0 still decrementing\n");
202 } else {
203 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
204 priv->noOfPktQueuedInDriver--;
205 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
206 }
207
208 if (staRecord) {
209 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
210 if (!staRecord->noOfPktQueued) {
211 unifi_error(priv, "packets queued in driver per station is 0 still decrementing\n");
212 } else {
213 staRecord->noOfPktQueued--;
214 }
215
216 if (result){
217 if (staRecord->nullDataHostTag == buffered_pkt->hostTag){
218 staRecord->nullDataHostTag = INVALID_HOST_TAG;
219 }
220 }
221 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
222 }
223
224 }
225 return result;
226}
227#ifdef CSR_SUPPORT_SME
228static
229void set_eosp_transmit_ctrl(unifi_priv_t *priv, struct list_head *txList)
230{
231
232 tx_buffered_packets_t *tx_q_item = NULL;
233 struct list_head *listHead;
234 struct list_head *placeHolder;
235 unsigned long lock_flags;
236
237
238 unifi_trace(priv, UDBG5, "entering set_eosp_transmit_ctrl\n");
239
240 if (list_empty(txList)) {
241 unifi_warning(priv, "In set_eosp_transmit_ctrl, the list is empty\n");
242 return;
243 }
244
245
246
247 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
248 list_for_each_prev_safe(listHead, placeHolder, txList) {
249 tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
250 tx_q_item->transmissionControl |= TRANSMISSION_CONTROL_EOSP_MASK;
251 tx_q_item->transmissionControl = (tx_q_item->transmissionControl & ~(CSR_NO_CONFIRM_REQUIRED));
252 unifi_trace(priv, UDBG1,
253 "set_eosp_transmit_ctrl Transmission Control = 0x%x hostTag = 0x%x \n",tx_q_item->transmissionControl,tx_q_item->hostTag);
254 unifi_trace(priv,UDBG3,"in set_eosp_transmit_ctrl no.of buffered frames %d\n",priv->noOfPktQueuedInDriver);
255 break;
256 }
257 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
258 unifi_trace(priv, UDBG1,"List Empty %d\n",list_empty(txList));
259 unifi_trace(priv, UDBG5, "leaving set_eosp_transmit_ctrl\n");
260 return;
261}
262
263static
264void send_vif_availibility_rsp(unifi_priv_t *priv,CSR_VIF_IDENTIFIER vif,CSR_RESULT_CODE resultCode)
265{
266 CSR_SIGNAL signal;
267 CSR_MA_VIF_AVAILABILITY_RESPONSE *rsp;
268 bulk_data_param_t *bulkdata = NULL;
269 int r;
270
271 unifi_trace(priv, UDBG3, "send_vif_availibility_rsp : invoked with resultCode = %d \n", resultCode);
272
273 memset(&signal,0,sizeof(CSR_SIGNAL));
274 rsp = &signal.u.MaVifAvailabilityResponse;
275 rsp->VirtualInterfaceIdentifier = vif;
276 rsp->ResultCode = resultCode;
277 signal.SignalPrimitiveHeader.SignalId = CSR_MA_VIF_AVAILABILITY_RESPONSE_ID;
278 signal.SignalPrimitiveHeader.ReceiverProcessId = 0;
279 signal.SignalPrimitiveHeader.SenderProcessId = priv->netdev_client->sender_id;
280
281
282 r = ul_send_signal_unpacked(priv, &signal, bulkdata);
283 if(r) {
284 unifi_error(priv,"Availibility response sending failed %x status %d\n",vif,r);
285 }
286 else {
287 unifi_trace(priv, UDBG3, "send_vif_availibility_rsp : status = %d \n", r);
288 }
289}
290#endif
291
292static
293void verify_and_accomodate_tx_packet(unifi_priv_t *priv)
294{
295 tx_buffered_packets_t *tx_q_item;
296 unsigned long lock_flags;
297 struct list_head *listHead, *list;
298 struct list_head *placeHolder;
299 u8 i, j,eospFramedeleted=0;
300 u8 thresholdExcedeDueToBroadcast = TRUE;
301
302
303 netInterface_priv_t *interfacePriv = priv->interfacePriv[0];
304 CsrWifiRouterCtrlStaInfo_t *staInfo = NULL;
305
306 unifi_trace(priv, UDBG3, "entering verify_and_accomodate_tx_packet\n");
307
308 for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
309 staInfo = interfacePriv->staInfo[i];
310 if (staInfo && (staInfo->noOfPktQueued >= CSR_WIFI_DRIVER_MAX_PKT_QUEUING_THRESHOLD_PER_PEER)) {
311
312
313
314
315 unifi_trace(priv,UDBG3,"number of station pkts queued= %d for sta id = %d\n", staInfo->noOfPktQueued, staInfo->aid);
316 for(j = 0; j < MAX_ACCESS_CATOGORY; j++) {
317 list = &staInfo->dataPdu[j];
318 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
319 list_for_each_safe(listHead, placeHolder, list) {
320 tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
321 list_del(listHead);
322 thresholdExcedeDueToBroadcast = FALSE;
323 unifi_net_data_free(priv, &tx_q_item->bulkdata);
324 kfree(tx_q_item);
325 tx_q_item = NULL;
326 if (!priv->noOfPktQueuedInDriver) {
327 unifi_error(priv, "packets queued in driver 0 still decrementing in %s\n", __FUNCTION__);
328 } else {
329
330 priv->noOfPktQueuedInDriver--;
331
332 }
333
334 if (!staInfo->noOfPktQueued) {
335 unifi_error(priv, "packets queued in driver per station is 0 still decrementing in %s\n", __FUNCTION__);
336 } else {
337 spin_lock(&priv->staRecord_lock);
338 staInfo->noOfPktQueued--;
339 spin_unlock(&priv->staRecord_lock);
340 }
341 break;
342 }
343 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
344 }
345 }
346 }
347 if (thresholdExcedeDueToBroadcast && interfacePriv->noOfbroadcastPktQueued > CSR_WIFI_DRIVER_MINIMUM_BROADCAST_PKT_THRESHOLD ) {
348
349
350
351 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
352 list_for_each_safe(listHead, placeHolder, &interfacePriv->genericMulticastOrBroadCastFrames) {
353 tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
354 if(eospFramedeleted){
355 tx_q_item->transmissionControl |= TRANSMISSION_CONTROL_EOSP_MASK;
356 tx_q_item->transmissionControl = (tx_q_item->transmissionControl & ~(CSR_NO_CONFIRM_REQUIRED));
357 unifi_trace(priv, UDBG1,"updating eosp for next packet hostTag:= 0x%x ",tx_q_item->hostTag);
358 eospFramedeleted =0;
359 break;
360 }
361
362 if(tx_q_item->transmissionControl & TRANSMISSION_CONTROL_EOSP_MASK ){
363 eospFramedeleted = 1;
364 }
365 unifi_trace(priv,UDBG1, "freeing of multicast packets ToC = 0x%x hostTag = 0x%x \n",tx_q_item->transmissionControl,tx_q_item->hostTag);
366 list_del(listHead);
367 unifi_net_data_free(priv, &tx_q_item->bulkdata);
368 kfree(tx_q_item);
369 priv->noOfPktQueuedInDriver--;
370 spin_lock(&priv->staRecord_lock);
371 interfacePriv->noOfbroadcastPktQueued--;
372 spin_unlock(&priv->staRecord_lock);
373 if(!eospFramedeleted){
374 break;
375 }
376 }
377 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
378 }
379 unifi_trace(priv, UDBG3, "leaving verify_and_accomodate_tx_packet\n");
380}
381
382static
383CsrResult enque_tx_data_pdu(unifi_priv_t *priv, bulk_data_param_t *bulkdata,
384 struct list_head *list, CSR_SIGNAL *signal,
385 u8 requeueOnSamePos)
386{
387
388
389 CSR_MA_PACKET_REQUEST *req = &signal->u.MaPacketRequest;
390 tx_buffered_packets_t *tx_q_item;
391 unsigned long lock_flags;
392
393 unifi_trace(priv, UDBG5, "entering enque_tx_data_pdu\n");
394 if(!list) {
395 unifi_error(priv,"List is not specified\n");
396 return CSR_RESULT_FAILURE;
397 }
398
399
400 if (priv->noOfPktQueuedInDriver >= CSR_WIFI_DRIVER_SUPPORT_FOR_MAX_PKT_QUEUEING) {
401 unifi_trace(priv,UDBG3,"number of pkts queued= %d \n", priv->noOfPktQueuedInDriver);
402 verify_and_accomodate_tx_packet(priv);
403 }
404
405
406
407 tx_q_item = (tx_buffered_packets_t *)kmalloc(sizeof(tx_buffered_packets_t), GFP_ATOMIC);
408 if (tx_q_item == NULL) {
409 unifi_error(priv,
410 "Failed to allocate %d bytes for tx packet record\n",
411 sizeof(tx_buffered_packets_t));
412 func_exit();
413 return CSR_RESULT_FAILURE;
414 }
415
416
417 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
418 INIT_LIST_HEAD(&tx_q_item->q);
419
420 tx_q_item->bulkdata.os_data_ptr = bulkdata->d[0].os_data_ptr;
421 tx_q_item->bulkdata.data_length = bulkdata->d[0].data_length;
422 tx_q_item->bulkdata.os_net_buf_ptr = bulkdata->d[0].os_net_buf_ptr;
423 tx_q_item->bulkdata.net_buf_length = bulkdata->d[0].net_buf_length;
424 tx_q_item->interfaceTag = req->VirtualInterfaceIdentifier & 0xff;
425 tx_q_item->hostTag = req->HostTag;
426 tx_q_item->leSenderProcessId = signal->SignalPrimitiveHeader.SenderProcessId;
427 tx_q_item->transmissionControl = req->TransmissionControl;
428 tx_q_item->priority = req->Priority;
429 tx_q_item->rate = req->TransmitRate;
430 memcpy(tx_q_item->peerMacAddress.a, req->Ra.x, ETH_ALEN);
431
432
433
434 if (requeueOnSamePos) {
435 list_add(&tx_q_item->q, list);
436 } else {
437 list_add_tail(&tx_q_item->q, list);
438 }
439
440
441 priv->noOfPktQueuedInDriver++;
442 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
443 unifi_trace(priv, UDBG5, "leaving enque_tx_data_pdu\n");
444 return CSR_RESULT_SUCCESS;
445}
446
447#ifdef CSR_WIFI_REQUEUE_PACKET_TO_HAL
448CsrResult unifi_reque_ma_packet_request (void *ospriv, u32 host_tag,
449 u16 txStatus, bulk_data_desc_t *bulkDataDesc)
450{
451 CsrResult status = CSR_RESULT_SUCCESS;
452 unifi_priv_t *priv = (unifi_priv_t*)ospriv;
453 netInterface_priv_t *interfacePriv;
454 struct list_head *list = NULL;
455 CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
456 bulk_data_param_t bulkData;
457 CSR_SIGNAL signal;
458 CSR_PRIORITY priority = 0;
459 u16 interfaceTag = 0;
460 unifi_TrafficQueue priority_q;
461 u16 frameControl = 0, frameType = 0;
462 unsigned long lock_flags;
463
464 interfacePriv = priv->interfacePriv[interfaceTag];
465
466
467
468
469 if(!((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP) ||
470 (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO))) {
471 return CSR_RESULT_FAILURE;
472 }
473
474 unifi_trace(priv, UDBG6, "unifi_reque_ma_packet_request: host_tag = 0x%x\n", host_tag);
475
476 staRecord = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv,
477 (((u8 *) bulkDataDesc->os_data_ptr) + 4),
478 interfaceTag);
479 if (NULL == staRecord) {
480 unifi_trace(priv, UDBG5, "unifi_reque_ma_packet_request: Invalid STA record \n");
481 return CSR_RESULT_FAILURE;
482 }
483
484
485
486
487 if (CSR_TX_RETRY_LIMIT == txStatus || CSR_TX_NO_BSS == txStatus) {
488 if (staRecord->timSet == CSR_WIFI_TIM_RESET || staRecord->timSet == CSR_WIFI_TIM_RESETTING)
489 {
490 unifi_trace(priv, UDBG2, "unifi_reque_ma_packet_request: CFM failed with Retry Limit or No BSS-->update TIM\n");
491 if (!staRecord->timRequestPendingFlag) {
492 update_tim(priv, staRecord->aid, 1, interfaceTag, staRecord->assignedHandle);
493 }
494 else {
495
496
497
498 staRecord->updateTimReqQueued = 1;
499 unifi_trace(priv, UDBG6, "unifi_reque_ma_packet_request: One more UpdateTim Request(:%d)Queued for AID %x\n",
500 staRecord->updateTimReqQueued, staRecord->aid);
501 }
502 }
503 return CSR_RESULT_FAILURE;
504 }
505 else if ((CSR_TX_LIFETIME == txStatus) || (CSR_TX_BLOCK_ACK_TIMEOUT == txStatus) ||
506 (CSR_TX_FAIL_TRANSMISSION_VIF_INTERRUPTED == txStatus) ||
507 (CSR_TX_REJECTED_PEER_STATION_SLEEPING == txStatus) ||
508 (CSR_TX_REJECTED_DTIM_STARTED == txStatus)) {
509
510 frameControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(bulkDataDesc->os_data_ptr);
511 frameType = ((frameControl & IEEE80211_FC_TYPE_MASK) >> FRAME_CONTROL_TYPE_FIELD_OFFSET);
512
513
514
515
516 if (IEEE802_11_FRAMETYPE_MANAGEMENT == frameType) {
517 return CSR_RESULT_FAILURE;
518 }
519 else if (IEEE802_11_FRAMETYPE_DATA == frameType) {
520
521
522
523 if ((((frameControl & IEEE80211_FC_SUBTYPE_MASK) >> FRAME_CONTROL_SUBTYPE_FIELD_OFFSET) == QOS_DATA_NULL) ||
524 (((frameControl & IEEE80211_FC_SUBTYPE_MASK) >> FRAME_CONTROL_SUBTYPE_FIELD_OFFSET)== DATA_NULL )) {
525 return CSR_RESULT_FAILURE;
526 }
527 }
528
529
530 if (TRUE == staRecord->wmmOrQosEnabled) {
531 u16 qosControl = 0;
532 u8 dataFrameType = 0;
533
534 dataFrameType =((frameControl & IEEE80211_FC_SUBTYPE_MASK) >> 4);
535
536 if (dataFrameType == QOS_DATA) {
537
538
539
540 if((frameControl & IEEE802_11_FC_TO_DS_MASK) && (frameControl & IEEE802_11_FC_FROM_DS_MASK)) {
541 qosControl= CSR_GET_UINT16_FROM_LITTLE_ENDIAN(bulkDataDesc->os_data_ptr + 30);
542 }
543 else {
544 qosControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(bulkDataDesc->os_data_ptr + 24);
545 }
546 }
547
548 priority = (CSR_PRIORITY)(qosControl & IEEE802_11_QC_TID_MASK);
549
550 if (priority < CSR_QOS_UP0 || priority > CSR_QOS_UP7) {
551 unifi_trace(priv, UDBG5, "unifi_reque_ma_packet_request: Invalid priority:%x \n", priority);
552 return CSR_RESULT_FAILURE;
553 }
554 }
555 else {
556 priority = CSR_CONTENTION;
557 }
558
559
560 bulkData.d[0].os_data_ptr = bulkDataDesc->os_data_ptr;
561 bulkData.d[0].data_length = bulkDataDesc->data_length;
562 bulkData.d[0].os_net_buf_ptr = bulkDataDesc->os_net_buf_ptr;
563 bulkData.d[0].net_buf_length = bulkDataDesc->net_buf_length;
564
565 bulkData.d[1].os_data_ptr = NULL;
566 bulkData.d[1].os_net_buf_ptr = NULL;
567 bulkData.d[1].data_length = bulkData.d[1].net_buf_length = 0;
568
569
570 memset(&signal, 0, sizeof(CSR_SIGNAL));
571
572
573 unifi_frame_ma_packet_req(priv, priority, 0, host_tag,
574 interfaceTag, CSR_NO_CONFIRM_REQUIRED,
575 priv->netdev_client->sender_id,
576 staRecord->peerMacAddress.a, &signal);
577
578
579 priority_q = unifi_frame_priority_to_queue(priority);
580 list = &staRecord->dataPdu[priority_q];
581
582
583 status = enque_tx_data_pdu(priv, &bulkData, list, &signal, TRUE);
584
585
586 if (!status) {
587 spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
588 staRecord->noOfPktQueued++;
589 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
590 }
591 }
592 else {
593
594
595
596 return CSR_RESULT_FAILURE;
597 }
598
599 return status;
600}
601#endif
602
603static void is_all_ac_deliver_enabled_and_moredata(CsrWifiRouterCtrlStaInfo_t *staRecord, u8 *allDeliveryEnabled, u8 *dataAvailable)
604{
605 u8 i;
606 *allDeliveryEnabled = TRUE;
607 for (i = 0 ;i < MAX_ACCESS_CATOGORY; i++) {
608 if (!IS_DELIVERY_ENABLED(staRecord->powersaveMode[i])) {
609
610 *allDeliveryEnabled = FALSE;
611 break;
612 }
613 }
614 if (*allDeliveryEnabled) {
615 *dataAvailable = (!list_empty(&staRecord->dataPdu[0]) || !list_empty(&staRecord->dataPdu[1])
616 ||!list_empty(&staRecord->dataPdu[2]) ||!list_empty(&staRecord->dataPdu[3])
617 ||!list_empty(&staRecord->mgtFrames));
618 }
619}
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635void uf_handle_tim_cfm(unifi_priv_t *priv, CSR_MLME_SET_TIM_CONFIRM *cfm, u16 receiverProcessId)
636{
637 u8 handle = CSR_WIFI_GET_STATION_HANDLE_FROM_RECEIVER_ID(receiverProcessId);
638 u8 timSetStatus = CSR_WIFI_GET_TIMSET_STATE_FROM_RECEIVER_ID(receiverProcessId);
639 u16 interfaceTag = (cfm->VirtualInterfaceIdentifier & 0xff);
640 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
641 CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
642
643 u16 timSetValue = 0;
644
645 static u8 retryCount = 0;
646 unsigned long lock_flags;
647 unifi_trace(priv, UDBG3, "entering %s, handle = %x, timSetStatus = %x\n", __FUNCTION__, handle, timSetStatus);
648
649 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
650 unifi_warning(priv, "bad interfaceTag = %x\n", interfaceTag);
651 return;
652 }
653
654 if ((handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) && (handle >= UNIFI_MAX_CONNECTIONS)) {
655 unifi_warning(priv, "bad station Handle = %x\n", handle);
656 return;
657 }
658
659 if (handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) {
660 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
661 if ((staRecord = ((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[handle]))) == NULL) {
662 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
663 unifi_warning(priv, "uf_handle_tim_cfm: station record is NULL handle = %x\n", handle);
664 return;
665 }
666 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
667 }
668 switch(timSetStatus)
669 {
670 case CSR_WIFI_TIM_SETTING:
671 timSetValue = CSR_WIFI_TIM_SET;
672 break;
673 case CSR_WIFI_TIM_RESETTING:
674 timSetValue = CSR_WIFI_TIM_RESET;
675 break;
676 default:
677 unifi_warning(priv, "timSet state is %x: Debug\n", timSetStatus);
678 return;
679 }
680
681
682 switch(cfm->ResultCode)
683 {
684 case CSR_RC_SUCCESS:
685 if (handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) {
686
687 if (timSetStatus == staRecord->timSet) {
688 staRecord->timSet = timSetValue;
689
690
691
692 retryCount = 0;
693 unifi_trace(priv, UDBG2, "tim (%s) successfully in firmware\n", (timSetValue)?"SET":"RESET");
694 } else {
695 unifi_trace(priv, UDBG3, "receiver processID = %x, success: request & confirm states are not matching in TIM cfm: Debug status = %x, staRecord->timSet = %x, handle = %x\n",
696 receiverProcessId, timSetStatus, staRecord->timSet, handle);
697 }
698
699
700 staRecord->timRequestPendingFlag = FALSE;
701
702
703
704
705 if (0xFF != staRecord->updateTimReqQueued)
706 {
707
708 if (staRecord->timSet != staRecord->updateTimReqQueued)
709 {
710 unifi_trace(priv, UDBG2, "uf_handle_tim_cfm : Processing Queued UpdateTimReq \n");
711
712 update_tim(priv, staRecord->aid, staRecord->updateTimReqQueued, interfaceTag, handle);
713
714 staRecord->updateTimReqQueued = 0xFF;
715 }
716 }
717 } else {
718
719 interfacePriv->bcTimSet = timSetValue;
720
721
722
723 retryCount = 0;
724 unifi_trace(priv, UDBG3, "tim (%s) successfully for broadcast frame in firmware\n", (timSetValue)?"SET":"RESET");
725
726
727 interfacePriv->bcTimSetReqPendingFlag = FALSE;
728
729
730
731
732 if (0xFF != interfacePriv->bcTimSetReqQueued)
733 {
734
735 if (interfacePriv->bcTimSet != interfacePriv->bcTimSetReqQueued)
736 {
737 unifi_trace(priv, UDBG2, "uf_handle_tim_cfm : Processing Queued UpdateDTimReq \n");
738
739 update_tim(priv, 0, interfacePriv->bcTimSetReqQueued, interfaceTag, 0xFFFFFFFF);
740
741 interfacePriv->bcTimSetReqQueued = 0xFF;
742 }
743 }
744
745 }
746 break;
747 case CSR_RC_INVALID_PARAMETERS:
748 case CSR_RC_INSUFFICIENT_RESOURCE:
749
750
751
752
753 if (retryCount > UNIFI_MAX_RETRY_LIMIT) {
754 u8 moreData = FALSE;
755 retryCount = 0;
756
757
758
759
760
761
762
763
764
765
766
767 if(staRecord) {
768 if(!staRecord->wmmOrQosEnabled) {
769 moreData = (!list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]) ||
770 !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]) ||
771 !list_empty(&staRecord->mgtFrames));
772 } else {
773
774 u8 allDeliveryEnabled = 0, dataAvailable = 0;
775
776 is_all_ac_deliver_enabled_and_moredata(staRecord, &allDeliveryEnabled, &dataAvailable);
777
778 moreData = (uf_is_more_data_for_non_delivery_ac(staRecord) || (allDeliveryEnabled && dataAvailable));
779
780 }
781
782
783
784
785 if (moreData) {
786 staRecord->timSet = CSR_WIFI_TIM_RESET;
787 } else {
788 staRecord->timSet = CSR_WIFI_TIM_SET;
789 }
790 } else {
791
792 moreData = (!list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames) ||
793 !list_empty(&interfacePriv->genericMulticastOrBroadCastFrames));
794 if (moreData) {
795 update_tim(priv, 0, CSR_WIFI_TIM_SET, interfaceTag, 0xFFFFFFFF);
796 } else {
797 update_tim(priv, 0, CSR_WIFI_TIM_RESET, interfaceTag, 0xFFFFFFFF);
798 }
799 }
800
801 unifi_error(priv, "no of error's for TIM setting crossed the Limit: verify\n");
802 return;
803 }
804 retryCount++;
805
806 if (handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) {
807 if (timSetStatus == staRecord->timSet) {
808 unifi_warning(priv, "tim request failed, retry for AID = %x\n", staRecord->aid);
809 update_tim(priv, staRecord->aid, timSetValue, interfaceTag, handle);
810 } else {
811 unifi_trace(priv, UDBG1, "failure: request & confirm states are not matching in TIM cfm: Debug status = %x, staRecord->timSet = %x\n",
812 timSetStatus, staRecord->timSet);
813 }
814 } else {
815 unifi_warning(priv, "tim request failed, retry for broadcast frames\n");
816 update_tim(priv, 0, timSetValue, interfaceTag, 0xFFFFFFFF);
817 }
818 break;
819 default:
820 unifi_warning(priv, "tim update request failed resultcode = %x\n", cfm->ResultCode);
821 }
822
823 unifi_trace(priv, UDBG2, "leaving %s\n", __FUNCTION__);
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
859void update_tim(unifi_priv_t * priv, u16 aid, u8 setTim, u16 interfaceTag, u32 handle)
860{
861 CSR_SIGNAL signal;
862 s32 r;
863 CSR_MLME_SET_TIM_REQUEST *req = &signal.u.MlmeSetTimRequest;
864 bulk_data_param_t *bulkdata = NULL;
865 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
866 u8 senderIdLsb = 0;
867 CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
868 u32 oldTimSetStatus = 0, timSetStatus = 0;
869
870 unifi_trace(priv, UDBG5, "entering the update_tim routine\n");
871
872
873 if (handle == 0xFFFFFFFF) {
874 handle &= CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE;
875 if (setTim == interfacePriv->bcTimSet)
876 {
877 unifi_trace(priv, UDBG3, "update_tim, Drop:Hdl=%x, timval=%d, globalTim=%d\n", handle, setTim, interfacePriv->bcTimSet);
878 return;
879 }
880 } else if ((handle != 0xFFFFFFFF) && (handle >= UNIFI_MAX_CONNECTIONS)) {
881 unifi_warning(priv, "bad station Handle = %x\n", handle);
882 return;
883 }
884
885 if (setTim) {
886 timSetStatus = CSR_WIFI_TIM_SETTING;
887 } else {
888 timSetStatus = CSR_WIFI_TIM_RESETTING;
889 }
890
891 if (handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) {
892 if ((staRecord = ((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[handle]))) == NULL) {
893 unifi_warning(priv, "station record is NULL in update_tim: handle = %x :debug\n", handle);
894 return;
895 }
896
897 oldTimSetStatus = staRecord->timSet;
898 staRecord->timSet = timSetStatus;
899 }
900
901
902 senderIdLsb = CSR_WIFI_PACK_SENDER_ID_LSB_FOR_TIM_REQ(handle, timSetStatus);
903
904
905 memset(&signal, 0, sizeof(CSR_SIGNAL));
906
907
908 signal.SignalPrimitiveHeader.SignalId = CSR_MLME_SET_TIM_REQUEST_ID;
909 signal.SignalPrimitiveHeader.ReceiverProcessId = 0;
910 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(((priv->netdev_client->sender_id & 0xff00) | senderIdLsb),
911 (u8*)&signal.SignalPrimitiveHeader.SenderProcessId);
912
913
914 req->VirtualInterfaceIdentifier = uf_get_vif_identifier(interfacePriv->interfaceMode,interfaceTag);
915 req->AssociationId = aid;
916 req->TimValue = setTim;
917
918
919 unifi_trace(priv, UDBG2, "update_tim:AID %x,senderIdLsb = 0x%x, handle = 0x%x, timSetStatus = %x, sender proceesID = %x \n",
920 aid,senderIdLsb, handle, timSetStatus, signal.SignalPrimitiveHeader.SenderProcessId);
921
922
923 r = ul_send_signal_unpacked(priv, &signal, bulkdata);
924 if (r) {
925
926 unifi_error(priv, "Error queueing CSR_MLME_SET_TIM_REQUEST signal\n");
927 if (staRecord) {
928 staRecord->timSet = oldTimSetStatus ;
929 }
930 else
931 {
932
933 interfacePriv->bcTimSet = !setTim;
934 }
935 }
936 else {
937
938
939 if (staRecord) {
940 staRecord->timRequestPendingFlag = TRUE;
941 }
942 else
943 {
944
945
946
947 interfacePriv->bcTimSetReqPendingFlag = TRUE;
948 }
949 }
950 unifi_trace(priv, UDBG5, "leaving the update_tim routine\n");
951}
952
953static
954void process_peer_active_transition(unifi_priv_t * priv,
955 CsrWifiRouterCtrlStaInfo_t *staRecord,
956 u16 interfaceTag)
957{
958 int r,i;
959 u8 spaceAvail[4] = {TRUE,TRUE,TRUE,TRUE};
960 tx_buffered_packets_t * buffered_pkt = NULL;
961 unsigned long lock_flags;
962 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
963
964 unifi_trace(priv, UDBG5, "entering process_peer_active_transition\n");
965
966 if(IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag)) {
967
968 unifi_trace(priv,UDBG2, "Multicast transmission is going on so resume unicast transmission after DTIM over\n");
969
970
971
972
973 if (!staRecord->timRequestPendingFlag){
974 if((staRecord->timSet == CSR_WIFI_TIM_SET) || (staRecord->timSet == CSR_WIFI_TIM_SETTING)){
975 update_tim(priv, staRecord->aid, 0, interfaceTag, staRecord->assignedHandle);
976 }
977 }
978 else
979 {
980
981
982
983 staRecord->updateTimReqQueued = 0;
984 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
985 staRecord->aid);
986 }
987 return;
988 }
989 while((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->mgtFrames))) {
990 buffered_pkt->transmissionControl &=
991 ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
992 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staRecord,0,FALSE)) == -ENOSPC) {
993 unifi_trace(priv, UDBG2, "p_p_a_t:(ENOSPC) Mgt Frame queueing \n");
994
995 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
996 list_add(&buffered_pkt->q, &staRecord->mgtFrames);
997 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
998 priv->pausedStaHandle[3]=(u8)(staRecord->assignedHandle);
999 spaceAvail[3] = FALSE;
1000 break;
1001 } else {
1002 if(r){
1003 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
1004
1005 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
1006 }
1007 kfree(buffered_pkt);
1008 }
1009 }
1010 if (!staRecord->timRequestPendingFlag) {
1011 if (staRecord->txSuspend) {
1012 if(staRecord->timSet == CSR_WIFI_TIM_SET) {
1013 update_tim(priv,staRecord->aid,0,interfaceTag, staRecord->assignedHandle);
1014 }
1015 return;
1016 }
1017 }
1018 else
1019 {
1020
1021
1022
1023 staRecord->updateTimReqQueued = 0;
1024 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
1025 staRecord->aid);
1026 }
1027 for(i=3;i>=0;i--) {
1028 if(!spaceAvail[i])
1029 continue;
1030 unifi_trace(priv, UDBG6, "p_p_a_t:data pkt sending for AC %d \n",i);
1031 while((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->dataPdu[i]))) {
1032 buffered_pkt->transmissionControl &=
1033 ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
1034 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staRecord,0,FALSE)) == -ENOSPC) {
1035
1036
1037 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
1038 list_add(&buffered_pkt->q, &staRecord->dataPdu[i]);
1039 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
1040 priv->pausedStaHandle[i]=(u8)(staRecord->assignedHandle);
1041 break;
1042 } else {
1043 if(r){
1044 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
1045
1046 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
1047 }
1048 kfree(buffered_pkt);
1049 }
1050 }
1051 }
1052 if (!staRecord->timRequestPendingFlag){
1053 if((staRecord->timSet == CSR_WIFI_TIM_SET) || (staRecord->timSet == CSR_WIFI_TIM_SETTING)) {
1054 unifi_trace(priv, UDBG3, "p_p_a_t:resetting tim .....\n");
1055 update_tim(priv,staRecord->aid,0,interfaceTag, staRecord->assignedHandle);
1056 }
1057 }
1058 else
1059 {
1060
1061
1062
1063 staRecord->updateTimReqQueued = 0;
1064 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
1065 staRecord->aid);
1066 }
1067 unifi_trace(priv, UDBG5, "leaving process_peer_active_transition\n");
1068}
1069
1070
1071
1072void uf_process_ma_pkt_cfm_for_ap(unifi_priv_t *priv,u16 interfaceTag, const CSR_MA_PACKET_CONFIRM *pkt_cfm)
1073{
1074 netInterface_priv_t *interfacePriv;
1075 u8 i;
1076 CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
1077 interfacePriv = priv->interfacePriv[interfaceTag];
1078
1079
1080 if(pkt_cfm->HostTag == interfacePriv->multicastPduHostTag) {
1081 unifi_trace(priv,UDBG2,"CFM for marked Multicast Tag = %x\n",interfacePriv->multicastPduHostTag);
1082 interfacePriv->multicastPduHostTag = 0xffffffff;
1083 resume_suspended_uapsd(priv,interfaceTag);
1084 resume_unicast_buffered_frames(priv,interfaceTag);
1085 if(list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames) &&
1086 list_empty(&interfacePriv->genericMulticastOrBroadCastFrames)) {
1087 unifi_trace(priv,UDBG1,"Resetting multicastTIM");
1088 if (!interfacePriv->bcTimSetReqPendingFlag)
1089 {
1090 update_tim(priv,0,CSR_WIFI_TIM_RESET,interfaceTag, 0xFFFFFFFF);
1091 }
1092 else
1093 {
1094
1095
1096
1097 interfacePriv->bcTimSetReqQueued = CSR_WIFI_TIM_RESET;
1098 unifi_trace(priv, UDBG2, "uf_process_ma_pkt_cfm_for_ap : One more UpdateDTim Request(%d) Queued \n",
1099 interfacePriv->bcTimSetReqQueued);
1100 }
1101
1102 }
1103 return;
1104 }
1105
1106
1107
1108
1109 for(i =0; i < UNIFI_MAX_CONNECTIONS; i++) {
1110 staRecord = (CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[i]);
1111 if (staRecord && (staRecord->nullDataHostTag == pkt_cfm->HostTag)) {
1112
1113 unifi_trace(priv, UDBG1, "CFM for Inactive probe Null frame (tag = %x, status = %d)\n",
1114 pkt_cfm->HostTag,
1115 pkt_cfm->TransmissionStatus
1116 );
1117 staRecord->nullDataHostTag = INVALID_HOST_TAG;
1118
1119 if(pkt_cfm->TransmissionStatus == CSR_TX_RETRY_LIMIT){
1120 CsrTime now;
1121 CsrTime inactive_time;
1122
1123 unifi_trace(priv, UDBG1, "Nulldata to probe STA ALIVE Failed with retry limit\n");
1124
1125
1126
1127
1128
1129 if (staRecord->activity_flag){
1130 return;
1131 }
1132 now = CsrTimeGet(NULL);
1133
1134 if (staRecord->lastActivity > now)
1135 {
1136
1137 inactive_time = CsrTimeAdd((CsrTime)CsrTimeSub(CSR_SCHED_TIME_MAX, staRecord->lastActivity),
1138 now);
1139 }
1140 else
1141 {
1142 inactive_time = (CsrTime)CsrTimeSub(now, staRecord->lastActivity);
1143 }
1144
1145 if (inactive_time >= STA_INACTIVE_TIMEOUT_VAL)
1146 {
1147 struct list_head send_cfm_list;
1148 u8 j;
1149
1150
1151
1152
1153
1154
1155
1156 INIT_LIST_HEAD(&send_cfm_list);
1157
1158 uf_prepare_send_cfm_list_for_queued_pkts(priv,
1159 &send_cfm_list,
1160 &(staRecord->mgtFrames));
1161
1162 uf_flush_list(priv, &(staRecord->mgtFrames));
1163
1164 for(j = 0; j < MAX_ACCESS_CATOGORY; j++){
1165 uf_prepare_send_cfm_list_for_queued_pkts(priv,
1166 &send_cfm_list,
1167 &(staRecord->dataPdu[j]));
1168
1169 uf_flush_list(priv,&(staRecord->dataPdu[j]));
1170 }
1171
1172 send_auto_ma_packet_confirm(priv, staRecord->interfacePriv, &send_cfm_list);
1173
1174
1175
1176 unifi_warning(priv, "uf_process_ma_pkt_cfm_for_ap: Router Disconnected IND Peer (%x-%x-%x-%x-%x-%x)\n",
1177 staRecord->peerMacAddress.a[0],
1178 staRecord->peerMacAddress.a[1],
1179 staRecord->peerMacAddress.a[2],
1180 staRecord->peerMacAddress.a[3],
1181 staRecord->peerMacAddress.a[4],
1182 staRecord->peerMacAddress.a[5]);
1183
1184 CsrWifiRouterCtrlConnectedIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,
1185 0,
1186 staRecord->interfacePriv->InterfaceTag,
1187 staRecord->peerMacAddress,
1188 CSR_WIFI_ROUTER_CTRL_PEER_DISCONNECTED);
1189 }
1190
1191 }
1192 else if (pkt_cfm->TransmissionStatus == CSR_TX_SUCCESSFUL)
1193 {
1194 staRecord->activity_flag = TRUE;
1195 }
1196 }
1197 }
1198}
1199
1200#endif
1201u16 uf_get_vif_identifier (CsrWifiRouterCtrlMode mode, u16 tag)
1202{
1203 switch(mode)
1204 {
1205 case CSR_WIFI_ROUTER_CTRL_MODE_STA:
1206 case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
1207 return (0x02<<8|tag);
1208
1209 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
1210 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
1211 return (0x03<<8|tag);
1212
1213 case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
1214 return (0x01<<8|tag);
1215
1216 case CSR_WIFI_ROUTER_CTRL_MODE_MONITOR:
1217 return (0x04<<8|tag);
1218 case CSR_WIFI_ROUTER_CTRL_MODE_AMP:
1219 return (0x05<<8|tag);
1220 default:
1221 return tag;
1222 }
1223}
1224
1225#ifdef CSR_SUPPORT_SME
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253static int update_macheader(unifi_priv_t *priv, struct sk_buff *skb,
1254 struct sk_buff *newSkb, CSR_PRIORITY *priority,
1255 bulk_data_param_t *bulkdata, u16 interfaceTag,
1256 u8 macHeaderLengthInBytes,
1257 u8 qosDestination)
1258{
1259
1260 u16 *fc = NULL;
1261 u8 direction = 0, toDs, fromDs;
1262 u8 *bufPtr = NULL;
1263 u8 sa[ETH_ALEN], da[ETH_ALEN];
1264 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
1265 int headroom;
1266 u8 macHeaderBuf[IEEE802_11_DATA_FRAME_MAC_HEADER_SIZE] = {0};
1267
1268 unifi_trace(priv, UDBG5, "entering the update_macheader function\n");
1269
1270
1271 memcpy(macHeaderBuf, skb->data, macHeaderLengthInBytes);
1272
1273
1274 skb_pull(skb, macHeaderLengthInBytes);
1275
1276
1277 headroom = skb_headroom(skb);
1278
1279
1280 fc = (u16*) macHeaderBuf;
1281
1282 toDs = (*fc & cpu_to_le16(IEEE802_11_FC_TO_DS_MASK))?1 : 0;
1283 fromDs = (*fc & cpu_to_le16(IEEE802_11_FC_FROM_DS_MASK))? 1: 0;
1284 unifi_trace(priv, UDBG5, "In update_macheader function, fromDs = %x, toDs = %x\n", fromDs, toDs);
1285 direction = ((fromDs | (toDs << 1)) & 0x3);
1286
1287
1288 memcpy(da, macHeaderBuf+4+toDs*12, ETH_ALEN);
1289
1290 memcpy(sa, macHeaderBuf+10+fromDs*(6+toDs*8), ETH_ALEN);
1291
1292 unifi_trace(priv, UDBG3, "update_macheader:direction = %x\n", direction);
1293
1294 switch(direction)
1295 {
1296 case 2:
1297
1298
1299
1300
1301 *fc &= cpu_to_le16(~IEEE802_11_FC_TO_DS_MASK);
1302 *fc |= cpu_to_le16(IEEE802_11_FC_FROM_DS_MASK);
1303
1304 memcpy(macHeaderBuf + 4, da, ETH_ALEN);
1305
1306 memcpy(macHeaderBuf + 10, &interfacePriv->bssid, ETH_ALEN);
1307
1308 memcpy(macHeaderBuf + 16, sa, ETH_ALEN);
1309 break;
1310 case 3:
1311 unifi_trace(priv, UDBG3, "when both the toDs & fromDS set, NOT SUPPORTED\n");
1312 break;
1313 default:
1314 unifi_trace(priv, UDBG3, "problem in decoding packet in update_macheader \n");
1315 return -1;
1316 }
1317
1318
1319
1320
1321 switch(le16_to_cpu(*fc) & IEEE80211_FC_SUBTYPE_MASK)
1322 {
1323 case IEEE802_11_FC_TYPE_QOS_DATA & IEEE80211_FC_SUBTYPE_MASK:
1324
1325 if (!qosDestination) {
1326
1327
1328
1329
1330 if (*fc & cpu_to_le16(IEEE80211_FC_ORDER_MASK)) {
1331
1332
1333
1334 macHeaderLengthInBytes -= 6;
1335 } else {
1336 macHeaderLengthInBytes -= 2;
1337 }
1338
1339 *fc &= cpu_to_le16(~IEEE80211_FC_SUBTYPE_MASK);
1340 *fc |= cpu_to_le16(IEEE802_11_FC_TYPE_DATA);
1341
1342
1343
1344 if (headroom < macHeaderLengthInBytes) {
1345 unifi_trace(priv, UDBG1, " sufficient headroom not there to push updated mac header \n");
1346 return -1;
1347 }
1348 bufPtr = (u8 *) skb_push(skb, macHeaderLengthInBytes);
1349
1350
1351 bulkdata->d[0].os_data_ptr = skb->data;
1352 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skb;
1353 bulkdata->d[0].data_length = skb->len;
1354
1355 } else {
1356
1357 u8 qc;
1358 if (*fc & cpu_to_le16(IEEE80211_FC_ORDER_MASK)) {
1359 qc = *((u8*)(macHeaderBuf + (macHeaderLengthInBytes - 4 - 2)));
1360 } else {
1361 qc = *((u8*)(macHeaderBuf + (macHeaderLengthInBytes - 2)));
1362 }
1363
1364 if ((qc & IEEE802_11_QC_TID_MASK) > 7) {
1365 *priority = 7;
1366 } else {
1367 *priority = qc & IEEE802_11_QC_TID_MASK;
1368 }
1369
1370 unifi_trace(priv, UDBG1, "Incoming packet priority from QSTA is %x\n", *priority);
1371
1372 if (headroom < macHeaderLengthInBytes) {
1373 unifi_trace(priv, UDBG3, " sufficient headroom not there to push updated mac header \n");
1374 return -1;
1375 }
1376 bufPtr = (u8 *) skb_push(skb, macHeaderLengthInBytes);
1377 }
1378 break;
1379 default:
1380 {
1381 bulk_data_param_t data_ptrs;
1382 CsrResult csrResult;
1383 unifi_trace(priv, UDBG5, "normal Data packet, NO QOS \n");
1384
1385 if (qosDestination) {
1386 u8 qc = 0;
1387 unifi_trace(priv, UDBG3, "destination is QOS station \n");
1388
1389
1390 *priority = CSR_QOS_UP0;
1391
1392
1393 qc |= CSR_QOS_UP0;
1394
1395 if (da[0] & 0x1) {
1396
1397 qc |= 1 << 5;
1398 }
1399
1400
1401 macHeaderLengthInBytes += 2;
1402
1403
1404 *fc &= cpu_to_le16(~IEEE80211_FC_SUBTYPE_MASK);
1405 *fc |= cpu_to_le16(IEEE802_11_FC_TYPE_QOS_DATA);
1406
1407
1408 macHeaderBuf[macHeaderLengthInBytes - 2] = qc;
1409
1410 macHeaderBuf[macHeaderLengthInBytes - 1] = 0;
1411 if (headroom < macHeaderLengthInBytes) {
1412 csrResult = unifi_net_data_malloc(priv, &data_ptrs.d[0], skb->len + macHeaderLengthInBytes);
1413
1414 if (csrResult != CSR_RESULT_SUCCESS) {
1415 unifi_error(priv, " failed to allocate request_data. in update_macheader func\n");
1416 return -1;
1417 }
1418 newSkb = (struct sk_buff *)(data_ptrs.d[0].os_net_buf_ptr);
1419 newSkb->len = skb->len + macHeaderLengthInBytes;
1420
1421 memcpy((void*)data_ptrs.d[0].os_data_ptr + macHeaderLengthInBytes,
1422 skb->data, skb->len);
1423
1424 bulkdata->d[0].os_data_ptr = newSkb->data;
1425 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)newSkb;
1426 bulkdata->d[0].data_length = newSkb->len;
1427
1428 bufPtr = (u8*)data_ptrs.d[0].os_data_ptr;
1429
1430
1431 kfree_skb(skb);
1432 } else {
1433
1434 bufPtr = (u8*)skb_push(skb, macHeaderLengthInBytes);
1435 bulkdata->d[0].os_data_ptr = skb->data;
1436 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skb;
1437 bulkdata->d[0].data_length = skb->len;
1438 }
1439 } else {
1440 unifi_trace(priv, UDBG3, "destination is not a QSTA\n");
1441 if (headroom < macHeaderLengthInBytes) {
1442 csrResult = unifi_net_data_malloc(priv, &data_ptrs.d[0], skb->len + macHeaderLengthInBytes);
1443
1444 if (csrResult != CSR_RESULT_SUCCESS) {
1445 unifi_error(priv, " failed to allocate request_data. in update_macheader func\n");
1446 return -1;
1447 }
1448 newSkb = (struct sk_buff *)(data_ptrs.d[0].os_net_buf_ptr);
1449 newSkb->len = skb->len + macHeaderLengthInBytes;
1450
1451 memcpy((void*)data_ptrs.d[0].os_data_ptr + macHeaderLengthInBytes,
1452 skb->data, skb->len);
1453
1454 bulkdata->d[0].os_data_ptr = newSkb->data;
1455 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)newSkb;
1456 bulkdata->d[0].data_length = newSkb->len;
1457
1458 bufPtr = (u8*)data_ptrs.d[0].os_data_ptr;
1459
1460
1461 kfree_skb(skb);
1462 } else {
1463
1464 bufPtr = (u8*)skb_push(skb, macHeaderLengthInBytes);
1465 bulkdata->d[0].os_data_ptr = skb->data;
1466 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skb;
1467 bulkdata->d[0].data_length = skb->len;
1468 }
1469 }
1470 }
1471 }
1472
1473
1474 unifi_trace(priv, UDBG5, "updated Mac Header: %d \n",macHeaderLengthInBytes);
1475 memcpy(bufPtr, macHeaderBuf, macHeaderLengthInBytes);
1476
1477 unifi_trace(priv, UDBG5, "leaving the update_macheader function\n");
1478 return 0;
1479}
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502int
1503uf_ap_process_data_pdu(unifi_priv_t *priv, struct sk_buff *skb,
1504 struct ethhdr *ehdr, CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
1505 const CSR_SIGNAL *signal,
1506 bulk_data_param_t *bulkdata,
1507 u8 macHeaderLengthInBytes)
1508{
1509 const CSR_MA_PACKET_INDICATION *ind = &(signal->u.MaPacketIndication);
1510 u16 interfaceTag = (ind->VirtualInterfaceIdentifier & 0x00ff);
1511 struct sk_buff *newSkb = NULL;
1512
1513 struct sk_buff *skbPtr = skb;
1514 u8 sendToNetdev = FALSE;
1515 u8 qosDestination = FALSE;
1516 CSR_PRIORITY priority = CSR_CONTENTION;
1517 CsrWifiRouterCtrlStaInfo_t *dstStaInfo = NULL;
1518 netInterface_priv_t *interfacePriv;
1519
1520 unifi_trace(priv, UDBG5, "entering uf_ap_process_data_pdu %d\n",macHeaderLengthInBytes);
1521
1522 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
1523 unifi_trace(priv, UDBG1, "Interface Tag is Invalid in uf_ap_process_data_pdu\n");
1524 unifi_net_data_free(priv, &bulkdata->d[0]);
1525 return 0;
1526 }
1527 interfacePriv = priv->interfacePriv[interfaceTag];
1528
1529 if((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) &&
1530 (interfacePriv->intraBssEnabled == FALSE)) {
1531 unifi_trace(priv, UDBG2, "uf_ap_process_data_pdu:P2P GO intrabssEnabled?= %d\n", interfacePriv->intraBssEnabled);
1532
1533
1534
1535 dstStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, ehdr->h_dest, interfaceTag);
1536 if (dstStaInfo) {
1537 unifi_net_data_free(priv, &bulkdata->d[0]);
1538 return 0;
1539 }
1540
1541 return -1;
1542 }
1543
1544 if(!memcmp(ehdr->h_dest, interfacePriv->bssid.a, ETH_ALEN)) {
1545
1546
1547 unifi_trace(priv, UDBG4, "destination address is csr_ap\n");
1548 return -1;
1549 }
1550
1551
1552 dstStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, ehdr->h_dest, interfaceTag);
1553
1554
1555 if(!dstStaInfo) {
1556 if (!(ehdr->h_dest[0] & 0x1)) {
1557
1558 unifi_trace(priv, UDBG3, "unicast frame & destination record not exist, send to netdev proto = %x\n", htons(skb->protocol));
1559 return -1;
1560 } else {
1561
1562
1563 unifi_trace(priv, UDBG5, "skb_copy, in uf_ap_process_data_pdu, protocol = %x\n", htons(skb->protocol));
1564 skbPtr = skb_copy(skb, GFP_KERNEL);
1565 if(skbPtr == NULL) {
1566
1567 unifi_notice(priv, "broacast/multicast frame can't be sent in BSS No memeory: proto = %x\n", htons(skb->protocol));
1568 return -1;
1569 }
1570 sendToNetdev = TRUE;
1571 }
1572 } else {
1573
1574
1575 if (uf_process_station_records_for_sending_data(priv, interfaceTag, srcStaInfo, dstStaInfo)) {
1576 unifi_notice(priv, "uf_ap_process_data_pdu: station record validation failed \n");
1577 interfacePriv->stats.rx_errors++;
1578 unifi_net_data_free(priv, &bulkdata->d[0]);
1579 return 0;
1580 }
1581 }
1582
1583
1584
1585
1586
1587 if(sendToNetdev) {
1588
1589 qosDestination = FALSE;
1590 } else if(dstStaInfo && (dstStaInfo->wmmOrQosEnabled == TRUE)) {
1591 qosDestination = TRUE;
1592 }
1593
1594 unifi_trace(priv, UDBG3, "uf_ap_process_data_pdu QoS destination = %s\n", (qosDestination)? "TRUE": "FALSE");
1595
1596
1597 if (update_macheader(priv, skbPtr, newSkb, &priority, bulkdata, interfaceTag, macHeaderLengthInBytes, qosDestination)) {
1598 interfacePriv->stats.rx_errors++;
1599 unifi_notice(priv, "(Packet Drop) failed to update the Mac header in uf_ap_process_data_pdu\n");
1600 if (sendToNetdev) {
1601
1602 bulkdata->d[0].os_data_ptr = skbPtr->data;
1603 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skbPtr;
1604 bulkdata->d[0].data_length = skbPtr->len;
1605 unifi_net_data_free(priv, &bulkdata->d[0]);
1606 }
1607 return -1;
1608 }
1609
1610 unifi_trace(priv, UDBG3, "Mac Header updated...calling uf_process_ma_packet_req \n");
1611
1612
1613 if (uf_process_ma_packet_req(priv, ehdr->h_dest, 0xffffffff, interfaceTag, CSR_NO_CONFIRM_REQUIRED, (CSR_RATE)0,priority, priv->netdev_client->sender_id, bulkdata)) {
1614 if (sendToNetdev) {
1615 unifi_trace(priv, UDBG1, "In uf_ap_process_data_pdu, (Packet Drop) uf_process_ma_packet_req failed. freeing skb_copy data (original data sent to Netdev)\n");
1616
1617 bulkdata->d[0].os_data_ptr = skbPtr->data;
1618 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skbPtr;
1619 bulkdata->d[0].data_length = skbPtr->len;
1620 unifi_net_data_free(priv, &bulkdata->d[0]);
1621 } else {
1622
1623 unifi_trace(priv, UDBG1, "In uf_ap_process_data_pdu, (Packet Drop). Unicast data so freeing original skb \n");
1624 unifi_net_data_free(priv, &bulkdata->d[0]);
1625 }
1626 }
1627 unifi_trace(priv, UDBG5, "leaving uf_ap_process_data_pdu\n");
1628
1629 if (sendToNetdev) {
1630
1631
1632
1633 unifi_trace(priv, UDBG4, "Packet will be routed to NetDev\n");
1634 return -1;
1635 }
1636
1637 return 0;
1638}
1639
1640#endif
1641
1642CsrResult uf_process_ma_packet_req(unifi_priv_t *priv,
1643 u8 *peerMacAddress,
1644 CSR_CLIENT_TAG hostTag,
1645 u16 interfaceTag,
1646 CSR_TRANSMISSION_CONTROL transmissionControl,
1647 CSR_RATE TransmitRate,
1648 CSR_PRIORITY priority,
1649 CSR_PROCESS_ID leSenderProcessId,
1650 bulk_data_param_t *bulkdata)
1651{
1652 CsrResult status = CSR_RESULT_SUCCESS;
1653 CSR_SIGNAL signal;
1654 int result;
1655#ifdef CSR_SUPPORT_SME
1656 CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
1657 const u8 *macHdrLocation = bulkdata->d[0].os_data_ptr;
1658 CsrWifiPacketType pktType;
1659 int frameType = 0;
1660 u8 queuePacketDozing = FALSE;
1661 u32 priority_q;
1662 u16 frmCtrl;
1663 struct list_head * list = NULL;
1664 u8 setBcTim=FALSE;
1665 netInterface_priv_t *interfacePriv;
1666 u8 requeueOnSamePos = FALSE;
1667 u32 handle = 0xFFFFFFFF;
1668 unsigned long lock_flags;
1669
1670 unifi_trace(priv, UDBG5,
1671 "entering uf_process_ma_packet_req, peer: %pMF\n",
1672 peerMacAddress);
1673
1674 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
1675 unifi_error(priv, "interfaceTag >= CSR_WIFI_NUM_INTERFACES, interfacetag = %d\n", interfaceTag);
1676 return CSR_RESULT_FAILURE;
1677 }
1678 interfacePriv = priv->interfacePriv[interfaceTag];
1679
1680
1681
1682 if ((staRecord = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, peerMacAddress, interfaceTag))) {
1683 handle = staRecord->assignedHandle;
1684 }
1685
1686
1687 unifi_frame_ma_packet_req(priv, priority, TransmitRate, hostTag,
1688 interfaceTag, transmissionControl, leSenderProcessId,
1689 peerMacAddress, &signal);
1690
1691
1692
1693
1694
1695 switch(interfacePriv->interfaceMode)
1696 {
1697 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
1698 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
1699
1700 break;
1701 default:
1702
1703 unifi_trace(priv, UDBG5, "In %s, interface mode is %x \n", __FUNCTION__, interfacePriv->interfaceMode);
1704 if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_NONE) {
1705 unifi_warning(priv, "In %s, interface mode NONE \n", __FUNCTION__);
1706 }
1707 if ((result = ul_send_signal_unpacked(priv, &signal, bulkdata))) {
1708 status = CSR_RESULT_FAILURE;
1709 }
1710 return status;
1711 }
1712
1713
1714
1715
1716 priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY) priority);
1717
1718
1719 if (staRecord && (staRecord->currentPeerState ==
1720 CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)) {
1721
1722
1723
1724 queuePacketDozing = TRUE;
1725 }
1726
1727
1728 if (*peerMacAddress & 0x1) {
1729
1730
1731
1732 pktType = CSR_WIFI_MULTICAST_PDU;
1733 } else {
1734 pktType = CSR_WIFI_UNICAST_PDU;
1735 }
1736
1737
1738 frmCtrl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(macHdrLocation);
1739
1740
1741 frameType = ((frmCtrl & 0x000c) >> FRAME_CONTROL_TYPE_FIELD_OFFSET);
1742 switch(frameType)
1743 {
1744 case IEEE802_11_FRAMETYPE_MANAGEMENT:
1745
1746 switch(pktType)
1747 {
1748 case CSR_WIFI_UNICAST_PDU:
1749 unifi_trace(priv, UDBG5, "management unicast PDU in uf_process_ma_packet_req \n");
1750
1751 if (!staRecord) {
1752
1753 if (list_empty(&interfacePriv->genericMgtFrames)) {
1754#ifdef CSR_SUPPORT_SME
1755 if(!(IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag))) {
1756#endif
1757
1758 unifi_trace(priv, UDBG3, "genericMgtFrames list is empty uf_process_ma_packet_req \n");
1759 result = ul_send_signal_unpacked(priv, &signal, bulkdata);
1760
1761 if(result == -ENOSPC) {
1762
1763 unifi_trace(priv, UDBG1, "(ENOSPC) Sending genericMgtFrames Failed so buffering\n");
1764 list = &interfacePriv->genericMgtFrames;
1765 requeueOnSamePos = TRUE;
1766 }
1767#ifdef CSR_SUPPORT_SME
1768 }else{
1769 list = &interfacePriv->genericMgtFrames;
1770 unifi_trace(priv, UDBG3, "genericMgtFrames queue empty and dtim started\n hosttag is 0x%x,\n",signal.u.MaPacketRequest.HostTag);
1771 update_eosp_to_head_of_broadcast_list_head(priv,interfaceTag);
1772 }
1773#endif
1774 } else {
1775
1776 list = &interfacePriv->genericMgtFrames;
1777 unifi_trace(priv, UDBG2, "genericMgtFrames queue not empty\n");
1778 }
1779 } else {
1780
1781 if (queuePacketDozing || !list_empty(&staRecord->mgtFrames) || IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag)) {
1782
1783
1784 list = &staRecord->mgtFrames;
1785
1786 unifi_trace(priv, UDBG1, "staRecord->MgtFrames list empty? = %s, handle = %d, queuePacketDozing = %d\n",
1787 (list_empty(&staRecord->mgtFrames))? "YES": "NO", staRecord->assignedHandle, queuePacketDozing);
1788 if(IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag)){
1789 update_eosp_to_head_of_broadcast_list_head(priv,interfaceTag);
1790 }
1791
1792 } else {
1793 unifi_trace(priv, UDBG5, "staRecord->mgtFrames list is empty uf_process_ma_packet_req \n");
1794 result = ul_send_signal_unpacked(priv, &signal, bulkdata);
1795 if(result == -ENOSPC) {
1796
1797 list = &staRecord->mgtFrames;
1798 requeueOnSamePos = TRUE;
1799 unifi_trace(priv, UDBG1, "(ENOSPC) Sending MgtFrames Failed handle = %d so buffering\n",staRecord->assignedHandle);
1800 priv->pausedStaHandle[0]=(u8)(staRecord->assignedHandle);
1801 } else if (result) {
1802 status = CSR_RESULT_FAILURE;
1803 }
1804 }
1805 }
1806 break;
1807 case CSR_WIFI_MULTICAST_PDU:
1808 unifi_trace(priv, UDBG5, "management multicast/broadcast PDU in uf_process_ma_packet_req 'QUEUE it' \n");
1809
1810
1811
1812
1813 list = &interfacePriv->genericMulticastOrBroadCastMgtFrames;
1814 if((interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_IBSS) &&
1815 (list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames))) {
1816 setBcTim=TRUE;
1817 }
1818 break;
1819 default:
1820 unifi_error(priv, "condition never meets: packet type unrecognized\n");
1821 }
1822 break;
1823 case IEEE802_11_FRAMETYPE_DATA:
1824 switch(pktType)
1825 {
1826 case CSR_WIFI_UNICAST_PDU:
1827 unifi_trace(priv, UDBG5, "data unicast PDU in uf_process_ma_packet_req \n");
1828
1829 if(!staRecord) {
1830 unifi_error(priv, "In %s unicast but staRecord = NULL\n", __FUNCTION__);
1831 return CSR_RESULT_FAILURE;
1832 } else if (queuePacketDozing || isRouterBufferEnabled(priv,priority_q)|| !list_empty(&staRecord->dataPdu[priority_q]) || IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag)) {
1833
1834
1835 unifi_trace(priv, UDBG2, "Enqueued to staRecord->dataPdu[%d] queuePacketDozing=%d,\
1836 Buffering enabled = %d \n", priority_q,queuePacketDozing,isRouterBufferEnabled(priv,priority_q));
1837 list = &staRecord->dataPdu[priority_q];
1838 } else {
1839 unifi_trace(priv, UDBG5, "staRecord->dataPdu[%d] list is empty uf_process_ma_packet_req \n", priority_q);
1840
1841 result = ul_send_signal_unpacked(priv, &signal, bulkdata);
1842 if(result == -ENOSPC) {
1843
1844 unifi_trace(priv, UDBG1, "(ENOSPC) Sending Unicast DataPDU to queue %d Failed so buffering\n",priority_q);
1845 requeueOnSamePos = TRUE;
1846 list = &staRecord->dataPdu[priority_q];
1847 priv->pausedStaHandle[priority_q]=(u8)(staRecord->assignedHandle);
1848 if(!isRouterBufferEnabled(priv,priority_q)) {
1849 unifi_error(priv,"Buffering Not enabled for queue %d \n",priority_q);
1850 }
1851 } else if (result) {
1852 status = CSR_RESULT_FAILURE;
1853 }
1854 }
1855 break;
1856 case CSR_WIFI_MULTICAST_PDU:
1857 unifi_trace(priv, UDBG5, "data multicast/broadcast PDU in uf_process_ma_packet_req \n");
1858
1859
1860
1861 list = &interfacePriv->genericMulticastOrBroadCastFrames;
1862 if(list_empty(&interfacePriv->genericMulticastOrBroadCastFrames)) {
1863 setBcTim = TRUE;
1864 }
1865 break;
1866 default:
1867 unifi_error(priv, "condition never meets: packet type un recognized\n");
1868 }
1869 break;
1870 default:
1871 unifi_error(priv, "unrecognized frame type\n");
1872 }
1873 if(list) {
1874 status = enque_tx_data_pdu(priv, bulkdata,list, &signal,requeueOnSamePos);
1875
1876 if (staRecord && (pktType == CSR_WIFI_UNICAST_PDU) && (!status)) {
1877 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
1878 staRecord->noOfPktQueued++;
1879 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
1880 }
1881 else if ((pktType == CSR_WIFI_MULTICAST_PDU) && (!status))
1882 {
1883
1884 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
1885 interfacePriv->noOfbroadcastPktQueued++;
1886 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
1887 }
1888 }
1889
1890 if(setBcTim && !status) {
1891 unifi_trace(priv, UDBG3, "tim set due to broadcast pkt\n");
1892 if (!interfacePriv->bcTimSetReqPendingFlag)
1893 {
1894 update_tim(priv,0,CSR_WIFI_TIM_SET,interfaceTag, handle);
1895 }
1896 else
1897 {
1898
1899
1900
1901 interfacePriv->bcTimSetReqQueued = CSR_WIFI_TIM_SET;
1902 unifi_trace(priv, UDBG2, "uf_process_ma_packet_req : One more UpdateDTim Request(:%d) Queued \n",
1903 interfacePriv->bcTimSetReqQueued);
1904 }
1905 } else if(staRecord && staRecord->currentPeerState ==
1906 CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE) {
1907 if(staRecord->timSet == CSR_WIFI_TIM_RESET || staRecord->timSet == CSR_WIFI_TIM_RESETTING) {
1908 if(!staRecord->wmmOrQosEnabled) {
1909 if(!list_empty(&staRecord->mgtFrames) ||
1910 !list_empty(&staRecord->dataPdu[3]) ||
1911 !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION])) {
1912 unifi_trace(priv, UDBG3, "tim set due to unicast pkt & peer in powersave\n");
1913 if (!staRecord->timRequestPendingFlag){
1914 update_tim(priv,staRecord->aid,1,interfaceTag, handle);
1915 }
1916 else
1917 {
1918
1919
1920
1921 staRecord->updateTimReqQueued = 1;
1922 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
1923 staRecord->aid);
1924 }
1925 }
1926 } else {
1927
1928 u8 allDeliveryEnabled = 0, dataAvailable = 0;
1929
1930 is_all_ac_deliver_enabled_and_moredata(staRecord, &allDeliveryEnabled, &dataAvailable);
1931 if (uf_is_more_data_for_non_delivery_ac(staRecord) || (allDeliveryEnabled && dataAvailable)
1932 || (!list_empty(&staRecord->mgtFrames))) {
1933 if (!staRecord->timRequestPendingFlag) {
1934 update_tim(priv,staRecord->aid,1,interfaceTag, handle);
1935 }
1936 else
1937 {
1938
1939
1940
1941 staRecord->updateTimReqQueued = 1;
1942 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
1943 staRecord->aid);
1944 }
1945 }
1946 }
1947 }
1948 }
1949
1950 if((list) && (pktType == CSR_WIFI_UNICAST_PDU && !queuePacketDozing) && !(isRouterBufferEnabled(priv,priority_q)) && !(IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag))) {
1951 unifi_trace(priv, UDBG2, "buffering cleared for queue = %d So resending buffered frames\n",priority_q);
1952 uf_send_buffered_frames(priv, priority_q);
1953 }
1954 unifi_trace(priv, UDBG5, "leaving uf_process_ma_packet_req \n");
1955 return status;
1956#else
1957#ifdef CSR_NATIVE_LINUX
1958 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
1959 unifi_error(priv, "interfaceTag >= CSR_WIFI_NUM_INTERFACES, interfacetag = %d\n", interfaceTag);
1960 return CSR_RESULT_FAILURE;
1961 }
1962
1963 unifi_frame_ma_packet_req(priv, priority, TransmitRate, hostTag, interfaceTag,
1964 transmissionControl, leSenderProcessId,
1965 peerMacAddress, &signal);
1966 result = ul_send_signal_unpacked(priv, &signal, bulkdata);
1967 if (result) {
1968 return CSR_RESULT_FAILURE;
1969 }
1970#endif
1971 return status;
1972#endif
1973}
1974
1975#ifdef CSR_SUPPORT_SME
1976s8 uf_get_protection_bit_from_interfacemode(unifi_priv_t *priv, u16 interfaceTag, const u8 *daddr)
1977{
1978 s8 protection = 0;
1979 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
1980
1981 switch(interfacePriv->interfaceMode)
1982 {
1983 case CSR_WIFI_ROUTER_CTRL_MODE_STA:
1984 case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
1985 case CSR_WIFI_ROUTER_CTRL_MODE_AMP:
1986 case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
1987 protection = interfacePriv->protect;
1988 break;
1989 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
1990 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
1991 {
1992 CsrWifiRouterCtrlStaInfo_t *dstStaInfo = NULL;
1993 if (daddr[0] & 0x1) {
1994 unifi_trace(priv, UDBG3, "broadcast/multicast packet in send_ma_pkt_request\n");
1995
1996
1997
1998 protection = interfacePriv->protect;
1999 } else {
2000
2001 dstStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, daddr, interfaceTag);
2002 if (!dstStaInfo) {
2003 unifi_trace(priv, UDBG3, "peer not found in station record in send_ma_pkt_request\n");
2004 return -1;
2005 }
2006 protection = dstStaInfo->protection;
2007 }
2008 }
2009 break;
2010 default:
2011 unifi_trace(priv, UDBG2, "mode unknown in send_ma_pkt_request\n");
2012 }
2013 return protection;
2014}
2015#endif
2016#ifdef CSR_SUPPORT_SME
2017u8 send_multicast_frames(unifi_priv_t *priv, u16 interfaceTag)
2018{
2019 int r;
2020 tx_buffered_packets_t * buffered_pkt = NULL;
2021 u8 moreData = FALSE;
2022 u8 pduSent =0;
2023 unsigned long lock_flags;
2024 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2025 u32 hostTag = 0xffffffff;
2026
2027 func_enter();
2028 if(!isRouterBufferEnabled(priv,UNIFI_TRAFFIC_Q_VO)) {
2029 while((interfacePriv->dtimActive)&& (buffered_pkt=dequeue_tx_data_pdu(priv,&interfacePriv->genericMulticastOrBroadCastMgtFrames))) {
2030 buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK);
2031 moreData = (buffered_pkt->transmissionControl & TRANSMISSION_CONTROL_EOSP_MASK)?FALSE:TRUE;
2032
2033
2034 unifi_trace(priv,UDBG2,"DTIM Occurred for interface:sending Mgt packet %d\n",interfaceTag);
2035
2036 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,NULL,moreData,FALSE)) == -ENOSPC) {
2037 unifi_trace(priv,UDBG1,"frame_and_send_queued_pdu failed with ENOSPC for host tag = %x\n", buffered_pkt->hostTag);
2038
2039 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
2040 list_add(&buffered_pkt->q, &interfacePriv->genericMulticastOrBroadCastMgtFrames);
2041 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
2042 break;
2043 } else {
2044 unifi_trace(priv,UDBG1,"send_multicast_frames: Send genericMulticastOrBroadCastMgtFrames (%x, %x)\n",
2045 buffered_pkt->hostTag,
2046 r);
2047 if(r) {
2048 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
2049 }
2050 if(!moreData) {
2051
2052 interfacePriv->dtimActive = FALSE;
2053 if(!r) {
2054 hostTag = buffered_pkt->hostTag;
2055 pduSent++;
2056 } else {
2057 send_vif_availibility_rsp(priv,uf_get_vif_identifier(interfacePriv->interfaceMode,interfaceTag),CSR_RC_UNSPECIFIED_FAILURE);
2058 }
2059 }
2060
2061 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2062 interfacePriv->noOfbroadcastPktQueued--;
2063 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2064 kfree(buffered_pkt);
2065 }
2066
2067 }
2068 }
2069 if(!isRouterBufferEnabled(priv,UNIFI_TRAFFIC_Q_CONTENTION)) {
2070 while((interfacePriv->dtimActive)&& (buffered_pkt=dequeue_tx_data_pdu(priv,&interfacePriv->genericMulticastOrBroadCastFrames))) {
2071 buffered_pkt->transmissionControl |= TRANSMISSION_CONTROL_TRIGGER_MASK;
2072 moreData = (buffered_pkt->transmissionControl & TRANSMISSION_CONTROL_EOSP_MASK)?FALSE:TRUE;
2073
2074
2075 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,NULL,moreData,FALSE)) == -ENOSPC) {
2076
2077 buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK);
2078
2079 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
2080 list_add(&buffered_pkt->q, &interfacePriv->genericMulticastOrBroadCastFrames);
2081 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
2082 break;
2083 } else {
2084 if(r) {
2085 unifi_trace(priv,UDBG1,"send_multicast_frames: Send genericMulticastOrBroadCastFrame failed (%x, %x)\n",
2086 buffered_pkt->hostTag,
2087 r);
2088 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
2089 }
2090 if(!moreData) {
2091 interfacePriv->dtimActive = FALSE;
2092 if(!r) {
2093 pduSent ++;
2094 hostTag = buffered_pkt->hostTag;
2095 } else {
2096 send_vif_availibility_rsp(priv,uf_get_vif_identifier(interfacePriv->interfaceMode,interfaceTag),CSR_RC_UNSPECIFIED_FAILURE);
2097 }
2098 }
2099
2100 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2101 interfacePriv->noOfbroadcastPktQueued--;
2102 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2103 kfree(buffered_pkt);
2104 }
2105 }
2106 }
2107 if((interfacePriv->dtimActive == FALSE)) {
2108
2109 unifi_trace(priv,UDBG2,"send_multicast_frames: Recorded hostTag of EOSP packet: = 0x%x\n",hostTag);
2110 interfacePriv->multicastPduHostTag = hostTag;
2111 }
2112 return pduSent;
2113}
2114#endif
2115void uf_process_ma_vif_availibility_ind(unifi_priv_t *priv,u8 *sigdata,
2116 u32 siglen)
2117{
2118#ifdef CSR_SUPPORT_SME
2119 CSR_SIGNAL signal;
2120 CSR_MA_VIF_AVAILABILITY_INDICATION *ind;
2121 int r;
2122 u16 interfaceTag;
2123 u8 pduSent =0;
2124 CSR_RESULT_CODE resultCode = CSR_RC_SUCCESS;
2125 netInterface_priv_t *interfacePriv;
2126
2127 func_enter();
2128 unifi_trace(priv, UDBG3,
2129 "uf_process_ma_vif_availibility_ind: Process signal 0x%.4X\n",
2130 *((u16*)sigdata));
2131
2132 r = read_unpack_signal(sigdata, &signal);
2133 if (r) {
2134 unifi_error(priv,
2135 "uf_process_ma_vif_availibility_ind: Received unknown signal 0x%.4X.\n",
2136 CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata));
2137 func_exit();
2138 return;
2139 }
2140 ind = &signal.u.MaVifAvailabilityIndication;
2141 interfaceTag=ind->VirtualInterfaceIdentifier & 0xff;
2142
2143 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
2144 unifi_error(priv, "in vif_availability_ind interfaceTag is wrong\n");
2145 return;
2146 }
2147
2148 interfacePriv = priv->interfacePriv[interfaceTag];
2149
2150 if(ind->Multicast) {
2151 if(list_empty(&interfacePriv->genericMulticastOrBroadCastFrames) &&
2152 list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames)) {
2153
2154
2155
2156 unifi_notice(priv,"ma_vif_availibility_ind recevied for multicast but queues are empty%d\n",interfaceTag);
2157 send_vif_availibility_rsp(priv,ind->VirtualInterfaceIdentifier,CSR_RC_NO_BUFFERED_BROADCAST_MULTICAST_FRAMES);
2158 interfacePriv->dtimActive = FALSE;
2159 if(interfacePriv->multicastPduHostTag == 0xffffffff) {
2160 unifi_notice(priv,"ma_vif_availibility_ind recevied for multicast but queues are empty%d\n",interfaceTag);
2161
2162 if (!interfacePriv->bcTimSetReqPendingFlag)
2163 {
2164 update_tim(priv,0,CSR_WIFI_TIM_RESET,interfaceTag, 0xFFFFFFFF);
2165 }
2166 else
2167 {
2168
2169
2170
2171 interfacePriv->bcTimSetReqQueued = CSR_WIFI_TIM_RESET;
2172 unifi_trace(priv, UDBG2, "uf_process_ma_vif_availibility_ind : One more UpdateDTim Request(%d) Queued \n",
2173 interfacePriv->bcTimSetReqQueued);
2174 }
2175 }
2176 return;
2177 }
2178 if(interfacePriv->dtimActive) {
2179 unifi_trace(priv,UDBG2,"DTIM Occurred for already active DTIM interface %d\n",interfaceTag);
2180 return;
2181 } else {
2182 unifi_trace(priv,UDBG2,"DTIM Occurred for interface %d\n",interfaceTag);
2183 if(list_empty(&interfacePriv->genericMulticastOrBroadCastFrames)) {
2184 set_eosp_transmit_ctrl(priv,&interfacePriv->genericMulticastOrBroadCastMgtFrames);
2185 } else {
2186 set_eosp_transmit_ctrl(priv,&interfacePriv->genericMulticastOrBroadCastFrames);
2187 }
2188 }
2189 interfacePriv->dtimActive = TRUE;
2190 pduSent = send_multicast_frames(priv,interfaceTag);
2191 }
2192 else {
2193 unifi_error(priv,"Interface switching is not supported %d\n",interfaceTag);
2194 resultCode = CSR_RC_NOT_SUPPORTED;
2195 send_vif_availibility_rsp(priv,ind->VirtualInterfaceIdentifier,CSR_RC_NOT_SUPPORTED);
2196 }
2197#endif
2198}
2199#ifdef CSR_SUPPORT_SME
2200
2201#define GET_ACTIVE_INTERFACE_TAG(priv) 0
2202
2203static u8 uf_is_more_data_for_delivery_ac(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t *staRecord)
2204{
2205 s8 i;
2206
2207 for(i=UNIFI_TRAFFIC_Q_VO; i >= UNIFI_TRAFFIC_Q_BK; i--)
2208 {
2209 if(((staRecord->powersaveMode[i]==CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)
2210 ||(staRecord->powersaveMode[i]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED))
2211 &&(!list_empty(&staRecord->dataPdu[i]))) {
2212 unifi_trace(priv,UDBG2,"uf_is_more_data_for_delivery_ac: Data Available AC = %d\n", i);
2213 return TRUE;
2214 }
2215 }
2216
2217 unifi_trace(priv,UDBG2,"uf_is_more_data_for_delivery_ac: Data NOT Available \n");
2218 return FALSE;
2219}
2220
2221static u8 uf_is_more_data_for_usp_delivery(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t *staRecord, unifi_TrafficQueue queue)
2222{
2223 s8 i;
2224
2225 for(i = queue; i >= UNIFI_TRAFFIC_Q_BK; i--)
2226 {
2227 if(((staRecord->powersaveMode[i]==CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)
2228 ||(staRecord->powersaveMode[i]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED))
2229 &&(!list_empty(&staRecord->dataPdu[i]))) {
2230 unifi_trace(priv,UDBG2,"uf_is_more_data_for_usp_delivery: Data Available AC = %d\n", i);
2231 return TRUE;
2232 }
2233 }
2234
2235 unifi_trace(priv,UDBG2,"uf_is_more_data_for_usp_delivery: Data NOT Available \n");
2236 return FALSE;
2237}
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259void uf_send_buffered_data_from_delivery_ac(unifi_priv_t *priv,
2260 CsrWifiRouterCtrlStaInfo_t * staInfo,
2261 u8 queue,
2262 struct list_head *txList)
2263{
2264
2265 u16 interfaceTag = GET_ACTIVE_INTERFACE_TAG(priv);
2266 tx_buffered_packets_t * buffered_pkt = NULL;
2267 unsigned long lock_flags;
2268 u8 eosp=FALSE;
2269 s8 r =0;
2270 u8 moreData = FALSE;
2271 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2272
2273 unifi_trace(priv, UDBG2, "++uf_send_buffered_data_from_delivery_ac, active=%x\n", staInfo->uapsdActive);
2274
2275 if (queue > UNIFI_TRAFFIC_Q_VO)
2276 {
2277 return;
2278 }
2279 while((buffered_pkt=dequeue_tx_data_pdu(priv, txList))) {
2280 if((IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag))) {
2281 unifi_trace(priv, UDBG2, "uf_send_buffered_data_from_delivery_ac: DTIM Active, suspend UAPSD, staId: 0x%x\n",
2282 staInfo->aid);
2283
2284
2285 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2286 staInfo->uspSuspend = TRUE;
2287 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2288
2289 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
2290 list_add(&buffered_pkt->q,txList);
2291 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
2292 break;
2293 }
2294
2295 buffered_pkt->transmissionControl &=
2296 ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
2297
2298
2299 if((staInfo->wmmOrQosEnabled == TRUE)&&(staInfo->uapsdActive == TRUE)) {
2300
2301 buffered_pkt->transmissionControl = TRANSMISSION_CONTROL_TRIGGER_MASK;
2302
2303
2304
2305
2306
2307 moreData = (!list_empty(txList) || uf_is_more_data_for_usp_delivery(priv, staInfo, queue));
2308
2309 if(staInfo->noOfSpFramesSent == (staInfo->maxSpLength - 1)) {
2310 moreData = FALSE;
2311 }
2312
2313 if(moreData == FALSE) {
2314 eosp = TRUE;
2315 buffered_pkt->transmissionControl =
2316 (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
2317 }
2318 } else {
2319
2320 unifi_warning(priv, "uf_send_buffered_data_from_delivery_ac: non U-APSD !!! \n");
2321 }
2322
2323 unifi_trace(priv,UDBG2,"uf_send_buffered_data_from_delivery_ac : MoreData:%d, EOSP:%d\n",moreData,eosp);
2324
2325 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staInfo,moreData,eosp)) == -ENOSPC) {
2326
2327 unifi_trace(priv, UDBG2, "uf_send_buffered_data_from_delivery_ac: UASPD suspended, ENOSPC in hipQ=%x\n", queue);
2328
2329
2330 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2331 staInfo->uspSuspend = TRUE;
2332 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2333
2334 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
2335 list_add(&buffered_pkt->q,txList);
2336 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
2337 priv->pausedStaHandle[queue]=(u8)(staInfo->assignedHandle);
2338 break;
2339 } else {
2340 if(r){
2341
2342 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
2343 }
2344 kfree(buffered_pkt);
2345 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2346 staInfo->noOfSpFramesSent++;
2347 if((!moreData) || (staInfo->noOfSpFramesSent == staInfo->maxSpLength)) {
2348 unifi_trace(priv, UDBG2, "uf_send_buffered_data_from_delivery_ac: Terminating USP\n");
2349 staInfo->uapsdActive = FALSE;
2350 staInfo->uspSuspend = FALSE;
2351 staInfo->noOfSpFramesSent = 0;
2352 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2353 break;
2354 }
2355 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2356 }
2357 }
2358 unifi_trace(priv, UDBG2, "--uf_send_buffered_data_from_delivery_ac, active=%x\n", staInfo->uapsdActive);
2359}
2360
2361void uf_send_buffered_data_from_ac(unifi_priv_t *priv,
2362 CsrWifiRouterCtrlStaInfo_t * staInfo,
2363 u8 queue,
2364 struct list_head *txList)
2365{
2366 tx_buffered_packets_t * buffered_pkt = NULL;
2367 unsigned long lock_flags;
2368 u8 eosp=FALSE;
2369 u8 moreData = FALSE;
2370 s8 r =0;
2371
2372 func_enter();
2373
2374 unifi_trace(priv,UDBG2,"uf_send_buffered_data_from_ac :\n");
2375
2376 while(!isRouterBufferEnabled(priv,queue) &&
2377 ((buffered_pkt=dequeue_tx_data_pdu(priv, txList))!=NULL)){
2378
2379 buffered_pkt->transmissionControl &=
2380 ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
2381
2382 unifi_trace(priv,UDBG3,"uf_send_buffered_data_from_ac : MoreData:%d, EOSP:%d\n",moreData,eosp);
2383
2384 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staInfo,moreData,eosp)) == -ENOSPC) {
2385
2386 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
2387 list_add(&buffered_pkt->q,txList);
2388 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
2389 if(staInfo != NULL){
2390 priv->pausedStaHandle[queue]=(u8)(staInfo->assignedHandle);
2391 }
2392 unifi_trace(priv,UDBG3," uf_send_buffered_data_from_ac: PDU sending failed .. no space for queue %d \n",queue);
2393 } else {
2394 if(r){
2395
2396 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
2397 }
2398 kfree(buffered_pkt);
2399 }
2400 }
2401
2402 func_exit();
2403
2404}
2405
2406void uf_send_buffered_frames(unifi_priv_t *priv,unifi_TrafficQueue q)
2407{
2408 u16 interfaceTag = GET_ACTIVE_INTERFACE_TAG(priv);
2409 u32 startIndex=0,endIndex=0;
2410 CsrWifiRouterCtrlStaInfo_t * staInfo = NULL;
2411 u8 queue;
2412 u8 moreData = FALSE;
2413
2414 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2415
2416 if(!((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP) ||
2417 (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO)))
2418 return;
2419 func_enter();
2420
2421 queue = (q<=3)?q:0;
2422
2423 if(interfacePriv->dtimActive) {
2424
2425 send_multicast_frames(priv,interfaceTag);
2426 if(!interfacePriv->dtimActive) {
2427 moreData = (!list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames) ||
2428 !list_empty(&interfacePriv->genericMulticastOrBroadCastFrames));
2429 if(!moreData) {
2430 if (!interfacePriv->bcTimSetReqPendingFlag)
2431 {
2432 update_tim(priv,0,CSR_WIFI_TIM_RESET,interfaceTag, 0XFFFFFFFF);
2433 }
2434 else
2435 {
2436
2437
2438
2439 interfacePriv->bcTimSetReqQueued = CSR_WIFI_TIM_RESET;
2440 unifi_trace(priv, UDBG2, "uf_send_buffered_frames : One more UpdateDTim Request(%d) Queued \n",
2441 interfacePriv->bcTimSetReqQueued);
2442 }
2443 }
2444 } else {
2445 moreData = (!list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames) ||
2446 !list_empty(&interfacePriv->genericMulticastOrBroadCastFrames));
2447 if(!moreData) {
2448
2449 unifi_error(priv,"ERROR: No More Data but DTIM is active sending Response\n");
2450 send_vif_availibility_rsp(priv,uf_get_vif_identifier(interfacePriv->interfaceMode,interfaceTag),CSR_RC_NO_BUFFERED_BROADCAST_MULTICAST_FRAMES);
2451 interfacePriv->dtimActive = FALSE;
2452 }
2453 }
2454 func_exit();
2455 return;
2456 }
2457 if(priv->pausedStaHandle[queue] > 7) {
2458 priv->pausedStaHandle[queue] = 0;
2459 }
2460
2461 if(queue == UNIFI_TRAFFIC_Q_VO) {
2462
2463
2464 unifi_trace(priv,UDBG2,"uf_send_buffered_frames : trying mgt from queue=%d\n",queue);
2465 for(startIndex= 0; startIndex < UNIFI_MAX_CONNECTIONS;startIndex++) {
2466 staInfo = CsrWifiRouterCtrlGetStationRecordFromHandle(priv,startIndex,interfaceTag);
2467 if(!staInfo ) {
2468 continue;
2469 } else if((staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)
2470 &&(staInfo->uapsdActive == FALSE) ) {
2471 continue;
2472 }
2473
2474 if((staInfo != NULL)&&(staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE)
2475 &&(staInfo->uapsdActive == FALSE)){
2476
2477 if(!list_empty(&staInfo->mgtFrames)){
2478 uf_send_buffered_data_from_ac(priv,staInfo, UNIFI_TRAFFIC_Q_VO, &staInfo->mgtFrames);
2479 }
2480 }
2481
2482 if(isRouterBufferEnabled(priv,queue)) {
2483 unifi_notice(priv,"uf_send_buffered_frames : No space Left for queue = %d\n",queue);
2484 break;
2485 }
2486 }
2487
2488 if(!list_empty(&interfacePriv->genericMgtFrames)) {
2489 unifi_trace(priv,UDBG2,"uf_send_buffered_frames : trying generic mgt from queue=%d\n",queue);
2490 uf_send_buffered_data_from_ac(priv,staInfo, UNIFI_TRAFFIC_Q_VO, &interfacePriv->genericMgtFrames);
2491 }
2492 }
2493
2494
2495 unifi_trace(priv,UDBG2,"uf_send_buffered_frames : Resume called for Queue=%d\n",queue);
2496 unifi_trace(priv,UDBG2,"uf_send_buffered_frames : start=%d end=%d\n",startIndex,endIndex);
2497
2498 startIndex = priv->pausedStaHandle[queue];
2499 endIndex = (startIndex + UNIFI_MAX_CONNECTIONS -1) % UNIFI_MAX_CONNECTIONS;
2500
2501 while(startIndex != endIndex) {
2502 staInfo = CsrWifiRouterCtrlGetStationRecordFromHandle(priv,startIndex,interfaceTag);
2503 if(!staInfo) {
2504 startIndex ++;
2505 if(startIndex >= UNIFI_MAX_CONNECTIONS) {
2506 startIndex = 0;
2507 }
2508 continue;
2509 } else if((staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)
2510 &&(staInfo->uapsdActive == FALSE)) {
2511 startIndex ++;
2512 if(startIndex >= UNIFI_MAX_CONNECTIONS) {
2513 startIndex = 0;
2514 }
2515 continue;
2516 }
2517
2518 unifi_trace(priv,UDBG2,"uf_send_buffered_frames : trying data from queue=%d\n",queue);
2519
2520
2521 if((staInfo != NULL)&&(staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE)
2522 &&(staInfo->uapsdActive == FALSE)) {
2523 if(!list_empty(&staInfo->dataPdu[queue])) {
2524
2525
2526 uf_send_buffered_data_from_ac(priv, staInfo, queue, (&staInfo->dataPdu[queue]));
2527 }
2528 }
2529 startIndex ++;
2530 if(startIndex >= UNIFI_MAX_CONNECTIONS) {
2531 startIndex = 0;
2532 }
2533 }
2534 if(isRouterBufferEnabled(priv,queue)) {
2535 priv->pausedStaHandle[queue] = endIndex;
2536 } else {
2537 priv->pausedStaHandle[queue] = 0;
2538 }
2539
2540
2541
2542
2543 unifi_trace(priv, UDBG4, "csrWifiHipSendBufferedFrames: UAPSD Resume Q=%x\n", queue);
2544 resume_suspended_uapsd(priv, interfaceTag);
2545 func_exit();
2546}
2547
2548
2549u8 uf_is_more_data_for_non_delivery_ac(CsrWifiRouterCtrlStaInfo_t *staRecord)
2550{
2551 u8 i;
2552
2553 for(i=0;i<=3;i++)
2554 {
2555 if(((staRecord->powersaveMode[i]==CSR_WIFI_AC_TRIGGER_ONLY_ENABLED)
2556 ||(staRecord->powersaveMode[i]==CSR_WIFI_AC_LEGACY_POWER_SAVE))
2557 &&(!list_empty(&staRecord->dataPdu[i]))){
2558
2559 return TRUE;
2560 }
2561 }
2562
2563 if(((staRecord->powersaveMode[UNIFI_TRAFFIC_Q_VO]==CSR_WIFI_AC_TRIGGER_ONLY_ENABLED)
2564 ||(staRecord->powersaveMode[UNIFI_TRAFFIC_Q_VO]==CSR_WIFI_AC_LEGACY_POWER_SAVE))
2565 &&(!list_empty(&staRecord->mgtFrames))){
2566
2567 return TRUE;
2568 }
2569
2570
2571
2572 return FALSE;
2573}
2574
2575
2576int uf_process_station_records_for_sending_data(unifi_priv_t *priv,u16 interfaceTag,
2577 CsrWifiRouterCtrlStaInfo_t *srcStaInfo,
2578 CsrWifiRouterCtrlStaInfo_t *dstStaInfo)
2579{
2580 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2581
2582 unifi_trace(priv, UDBG5, "entering uf_process_station_records_for_sending_data\n");
2583
2584 if (srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_DISCONNECTED) {
2585 unifi_error(priv, "Peer State not connected AID = %x, handle = %x, control port state = %x\n",
2586 srcStaInfo->aid, srcStaInfo->assignedHandle, srcStaInfo->peerControlledPort->port_action);
2587 return -1;
2588 }
2589 switch (interfacePriv->interfaceMode)
2590 {
2591 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
2592 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
2593 unifi_trace(priv, UDBG5, "mode is AP/P2PGO\n");
2594 break;
2595 default:
2596 unifi_warning(priv, "mode is nor AP neither P2PGO, packet cant be xmit\n");
2597 return -1;
2598 }
2599
2600 switch(dstStaInfo->peerControlledPort->port_action)
2601 {
2602 case CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD:
2603 case CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_BLOCK:
2604 unifi_trace(priv, UDBG5, "destination port is closed/blocked, discarding the packet\n");
2605 return -1;
2606 default:
2607 unifi_trace(priv, UDBG5, "destination port state is open\n");
2608 }
2609
2610
2611
2612
2613 unifi_trace(priv, UDBG5, "leaving uf_process_station_records_for_sending_data\n");
2614 return 0;
2615}
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636static void uf_handle_uspframes_delivery(unifi_priv_t * priv, CsrWifiRouterCtrlStaInfo_t *staInfo, u16 interfaceTag)
2637{
2638
2639 s8 i;
2640 u8 allDeliveryEnabled = 0, dataAvailable = 0;
2641 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2642 unsigned long lock_flags;
2643
2644 unifi_trace(priv, UDBG2, " ++ uf_handle_uspframes_delivery, uapsd active=%x, suspended?=%x\n",
2645 staInfo->uapsdActive, staInfo->uspSuspend);
2646
2647
2648
2649
2650
2651
2652
2653 if (!staInfo->uspSuspend && staInfo->uapsdActive)
2654 {
2655 unifi_notice(priv, "uf_handle_uspframes_delivery: U-APSD already active! STA=%x:%x:%x:%x:%x:%x\n",
2656 staInfo->peerMacAddress.a[0], staInfo->peerMacAddress.a[1],
2657 staInfo->peerMacAddress.a[2], staInfo->peerMacAddress.a[3],
2658 staInfo->peerMacAddress.a[4], staInfo->peerMacAddress.a[5]);
2659 return;
2660 }
2661
2662 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2663 staInfo->uapsdActive = TRUE;
2664 staInfo->uspSuspend = FALSE;
2665 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2666
2667 if(((staInfo->powersaveMode[UNIFI_TRAFFIC_Q_VO]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED)||
2668 (staInfo->powersaveMode[UNIFI_TRAFFIC_Q_VO]==CSR_WIFI_AC_DELIVERY_ONLY_ENABLE))
2669 && (!list_empty(&staInfo->mgtFrames))) {
2670
2671
2672 unifi_trace(priv, UDBG4, "uf_handle_uspframes_delivery: Sending buffered management frames\n");
2673 uf_send_buffered_data_from_delivery_ac(priv, staInfo, UNIFI_TRAFFIC_Q_VO, &staInfo->mgtFrames);
2674 }
2675
2676 if (!uf_is_more_data_for_delivery_ac(priv, staInfo)) {
2677
2678
2679
2680 if (!staInfo->uspSuspend) {
2681 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2682 staInfo->uapsdActive = FALSE;
2683 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2684
2685 unifi_trace(priv, UDBG2, "uf_handle_uspframes_delivery: sending QNull for trigger\n");
2686 uf_send_qos_null(priv, interfaceTag, staInfo->peerMacAddress.a, (CSR_PRIORITY) staInfo->triggerFramePriority, staInfo);
2687 staInfo->triggerFramePriority = CSR_QOS_UP0;
2688 } else {
2689 unifi_trace(priv, UDBG2, "uf_handle_uspframes_delivery: MgtQ xfer suspended\n");
2690 }
2691 } else {
2692 for(i = UNIFI_TRAFFIC_Q_VO; i >= UNIFI_TRAFFIC_Q_BK; i--) {
2693 if(((staInfo->powersaveMode[i]==CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)
2694 ||(staInfo->powersaveMode[i]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED))
2695 && (!list_empty(&staInfo->dataPdu[i]))) {
2696
2697 unifi_trace(priv, UDBG4, "uf_handle_uspframes_delivery: Buffered data frames from Queue (%d) for USP\n", i);
2698 uf_send_buffered_data_from_delivery_ac(priv, staInfo, i, &staInfo->dataPdu[i]);
2699 }
2700
2701 if ((!staInfo->uapsdActive) ||
2702 (staInfo->uspSuspend && IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag))) {
2703
2704
2705
2706 unifi_trace(priv, UDBG2, "uf_handle_uspframes_delivery: suspend=%x, DTIM=%x, USP terminated=%s\n",
2707 staInfo->uspSuspend, IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag),
2708 staInfo->uapsdActive?"NO":"YES");
2709 break;
2710 }
2711 }
2712 }
2713
2714
2715
2716
2717 is_all_ac_deliver_enabled_and_moredata(staInfo, &allDeliveryEnabled, &dataAvailable);
2718 if ((allDeliveryEnabled && !dataAvailable)) {
2719 if ((staInfo->timSet != CSR_WIFI_TIM_RESET) || (staInfo->timSet != CSR_WIFI_TIM_RESETTING)) {
2720 staInfo->updateTimReqQueued = (u8) CSR_WIFI_TIM_RESET;
2721 unifi_trace(priv, UDBG4, " --uf_handle_uspframes_delivery, UAPSD timset\n");
2722 if (!staInfo->timRequestPendingFlag) {
2723 update_tim(priv, staInfo->aid, 0, interfaceTag, staInfo->assignedHandle);
2724 }
2725 }
2726 }
2727 unifi_trace(priv, UDBG2, " --uf_handle_uspframes_delivery, uapsd active=%x, suspend?=%x\n",
2728 staInfo->uapsdActive, staInfo->uspSuspend);
2729}
2730
2731void uf_process_wmm_deliver_ac_uapsd(unifi_priv_t * priv,
2732 CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
2733 u16 qosControl,
2734 u16 interfaceTag)
2735{
2736 CSR_PRIORITY priority;
2737 unifi_TrafficQueue priority_q;
2738 unsigned long lock_flags;
2739
2740 unifi_trace(priv, UDBG2, "++uf_process_wmm_deliver_ac_uapsd: uapsdactive?=%x\n", srcStaInfo->uapsdActive);
2741
2742
2743
2744 priority = (CSR_PRIORITY)(qosControl & IEEE802_11_QC_TID_MASK);
2745 priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY) priority);
2746
2747 if((srcStaInfo->powersaveMode[priority_q]==CSR_WIFI_AC_TRIGGER_ONLY_ENABLED)
2748 ||(srcStaInfo->powersaveMode[priority_q]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED)) {
2749 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2750 srcStaInfo->triggerFramePriority = priority;
2751 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2752 unifi_trace(priv, UDBG2, "uf_process_wmm_deliver_ac_uapsd: trigger frame, Begin U-APSD, triggerQ=%x\n", priority_q);
2753 uf_handle_uspframes_delivery(priv, srcStaInfo, interfaceTag);
2754 }
2755 unifi_trace(priv, UDBG2, "--uf_process_wmm_deliver_ac_uapsd: uapsdactive?=%x\n", srcStaInfo->uapsdActive);
2756}
2757
2758
2759void uf_send_qos_null(unifi_priv_t * priv,u16 interfaceTag, const u8 *da,CSR_PRIORITY priority,CsrWifiRouterCtrlStaInfo_t * srcStaInfo)
2760{
2761 bulk_data_param_t bulkdata;
2762 CsrResult csrResult;
2763 struct sk_buff *skb, *newSkb = NULL;
2764 CsrWifiMacAddress peerAddress;
2765 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2766 CSR_TRANSMISSION_CONTROL transmissionControl = (TRANSMISSION_CONTROL_EOSP_MASK | TRANSMISSION_CONTROL_TRIGGER_MASK);
2767 int r;
2768 CSR_SIGNAL signal;
2769 u32 priority_q;
2770 CSR_RATE transmitRate = 0;
2771
2772
2773 func_enter();
2774
2775
2776 csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], MAC_HEADER_SIZE + QOS_CONTROL_HEADER_SIZE);
2777
2778 if (csrResult != CSR_RESULT_SUCCESS) {
2779 unifi_error(priv, " failed to allocate request_data. in uf_send_qos_null func\n");
2780 return ;
2781 }
2782 skb = (struct sk_buff *)(bulkdata.d[0].os_net_buf_ptr);
2783 skb->len = 0;
2784 bulkdata.d[0].os_data_ptr = skb->data;
2785 bulkdata.d[0].os_net_buf_ptr = (unsigned char*)skb;
2786 bulkdata.d[0].net_buf_length = bulkdata.d[0].data_length = skb->len;
2787 bulkdata.d[1].os_data_ptr = NULL;
2788 bulkdata.d[1].os_net_buf_ptr = NULL;
2789 bulkdata.d[1].net_buf_length = bulkdata.d[1].data_length = 0;
2790
2791
2792
2793 if (prepare_and_add_macheader(priv, skb, newSkb, priority, &bulkdata, interfaceTag, da, interfacePriv->bssid.a, 0)) {
2794 unifi_error(priv, "failed to create MAC header\n");
2795 unifi_net_data_free(priv, &bulkdata.d[0]);
2796 return;
2797 }
2798 memcpy(peerAddress.a, ((u8 *) bulkdata.d[0].os_data_ptr) + 4, ETH_ALEN);
2799
2800 priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY) priority);
2801
2802
2803
2804
2805 switch (interfacePriv->interfaceMode)
2806 {
2807 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
2808 transmitRate = 2;
2809 break;
2810 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
2811 transmitRate = 12;
2812 break;
2813 default:
2814 transmitRate = 0;
2815 }
2816 unifi_frame_ma_packet_req(priv, priority, transmitRate, 0xffffffff, interfaceTag,
2817 transmissionControl, priv->netdev_client->sender_id,
2818 peerAddress.a, &signal);
2819
2820 r = ul_send_signal_unpacked(priv, &signal, &bulkdata);
2821 if(r) {
2822 unifi_error(priv, "failed to send QOS data null packet result: %d\n",r);
2823 unifi_net_data_free(priv, &bulkdata.d[0]);
2824 }
2825
2826 func_exit();
2827 return;
2828
2829}
2830void uf_send_nulldata(unifi_priv_t * priv,u16 interfaceTag, const u8 *da,CSR_PRIORITY priority,CsrWifiRouterCtrlStaInfo_t * srcStaInfo)
2831{
2832 bulk_data_param_t bulkdata;
2833 CsrResult csrResult;
2834 struct sk_buff *skb, *newSkb = NULL;
2835 CsrWifiMacAddress peerAddress;
2836 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2837 CSR_TRANSMISSION_CONTROL transmissionControl = 0;
2838 int r;
2839 CSR_SIGNAL signal;
2840 u32 priority_q;
2841 CSR_RATE transmitRate = 0;
2842 CSR_MA_PACKET_REQUEST *req = &signal.u.MaPacketRequest;
2843 unsigned long lock_flags;
2844
2845 func_enter();
2846
2847 csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], MAC_HEADER_SIZE);
2848
2849 if (csrResult != CSR_RESULT_SUCCESS) {
2850 unifi_error(priv, "uf_send_nulldata: Failed to allocate memory for NULL frame\n");
2851 return ;
2852 }
2853 skb = (struct sk_buff *)(bulkdata.d[0].os_net_buf_ptr);
2854 skb->len = 0;
2855 bulkdata.d[0].os_data_ptr = skb->data;
2856 bulkdata.d[0].os_net_buf_ptr = (unsigned char*)skb;
2857 bulkdata.d[0].net_buf_length = bulkdata.d[0].data_length = skb->len;
2858 bulkdata.d[1].os_data_ptr = NULL;
2859 bulkdata.d[1].os_net_buf_ptr = NULL;
2860 bulkdata.d[1].net_buf_length = bulkdata.d[1].data_length = 0;
2861
2862
2863 if (prepare_and_add_macheader(priv, skb, newSkb, priority, &bulkdata, interfaceTag, da, interfacePriv->bssid.a, 0)) {
2864 unifi_error(priv, "uf_send_nulldata: Failed to create MAC header\n");
2865 unifi_net_data_free(priv, &bulkdata.d[0]);
2866 return;
2867 }
2868 memcpy(peerAddress.a, ((u8 *) bulkdata.d[0].os_data_ptr) + 4, ETH_ALEN);
2869
2870 priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY) priority);
2871 transmissionControl &= ~(CSR_NO_CONFIRM_REQUIRED);
2872
2873
2874
2875
2876 switch (interfacePriv->interfaceMode)
2877 {
2878 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
2879 transmitRate = 2;
2880 break;
2881 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
2882 transmitRate = 12;
2883 break;
2884 default:
2885 transmitRate = 0;
2886 }
2887 unifi_frame_ma_packet_req(priv, priority, transmitRate, INVALID_HOST_TAG, interfaceTag,
2888 transmissionControl, priv->netdev_client->sender_id,
2889 peerAddress.a, &signal);
2890
2891
2892 srcStaInfo->nullDataHostTag = req->HostTag;
2893 unifi_trace(priv, UDBG1, "uf_send_nulldata: STA AID = %d hostTag = %x\n", srcStaInfo->aid, req->HostTag);
2894
2895 r = ul_send_signal_unpacked(priv, &signal, &bulkdata);
2896
2897 if(r == -ENOSPC) {
2898 unifi_trace(priv, UDBG1, "uf_send_nulldata: ENOSPC Requeue the Null frame\n");
2899 enque_tx_data_pdu(priv, &bulkdata, &srcStaInfo->dataPdu[priority_q], &signal, 1);
2900 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2901 srcStaInfo->noOfPktQueued++;
2902 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2903
2904
2905 }
2906 if(r && r != -ENOSPC){
2907 unifi_error(priv, "uf_send_nulldata: Failed to send Null frame Error = %d\n",r);
2908 unifi_net_data_free(priv, &bulkdata.d[0]);
2909 srcStaInfo->nullDataHostTag = INVALID_HOST_TAG;
2910 }
2911
2912 func_exit();
2913 return;
2914}
2915
2916u8 uf_check_broadcast_bssid(unifi_priv_t *priv, const bulk_data_param_t *bulkdata)
2917{
2918 u8 *bssid = NULL;
2919 static const CsrWifiMacAddress broadcast_address = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
2920 u8 toDs, fromDs;
2921
2922 toDs = (((bulkdata->d[0].os_data_ptr)[1]) & 0x01) ? 1 : 0;
2923 fromDs =(((bulkdata->d[0].os_data_ptr)[1]) & 0x02) ? 1 : 0;
2924
2925 if (toDs && fromDs)
2926 {
2927 unifi_trace(priv, UDBG6, "Address 4 present, Don't try to find BSSID\n");
2928 bssid = NULL;
2929 }
2930 else if((toDs == 0) && (fromDs ==0))
2931 {
2932
2933 bssid = (u8 *) (bulkdata->d[0].os_data_ptr + 4 + (2 * ETH_ALEN));
2934 }
2935 else if(toDs)
2936 {
2937
2938 bssid = (u8 *) (bulkdata->d[0].os_data_ptr + 4);
2939 }
2940 else if(fromDs)
2941 {
2942
2943 bssid = (u8 *) (bulkdata->d[0].os_data_ptr + 4 + ETH_ALEN);
2944 }
2945
2946 if (memcmp(broadcast_address.a, bssid, ETH_ALEN)== 0)
2947 {
2948 return TRUE;
2949 }
2950 else
2951 {
2952 return FALSE;
2953 }
2954}
2955
2956
2957u8 uf_process_pm_bit_for_peer(unifi_priv_t * priv, CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
2958 u8 pmBit,u16 interfaceTag)
2959{
2960 u8 moreData = FALSE;
2961 u8 powerSaveChanged = FALSE;
2962 unsigned long lock_flags;
2963
2964 unifi_trace(priv, UDBG3, "entering uf_process_pm_bit_for_peer\n");
2965 if (pmBit) {
2966 priv->allPeerDozing |= (0x01 << (srcStaInfo->assignedHandle));
2967 } else {
2968 priv->allPeerDozing &= ~(0x01 << (srcStaInfo->assignedHandle));
2969 }
2970 if(pmBit) {
2971 if(srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE) {
2972
2973
2974 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2975 srcStaInfo->currentPeerState =CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE;
2976 powerSaveChanged = TRUE;
2977
2978 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2979 } else {
2980 return powerSaveChanged;
2981 }
2982 } else {
2983 if(srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE) {
2984
2985 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2986 srcStaInfo->currentPeerState = CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE;
2987 powerSaveChanged = TRUE;
2988
2989 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2990 }else {
2991 return powerSaveChanged;
2992 }
2993 }
2994
2995
2996 if(srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE) {
2997 unifi_trace(priv,UDBG3, "Peer with AID = %d is active now\n",srcStaInfo->aid);
2998 process_peer_active_transition(priv,srcStaInfo,interfaceTag);
2999 } else {
3000 unifi_trace(priv,UDBG3, "Peer with AID = %d is in PS Now\n",srcStaInfo->aid);
3001
3002 if(!srcStaInfo->wmmOrQosEnabled) {
3003 moreData = (!list_empty(&srcStaInfo->mgtFrames) ||
3004 !list_empty(&srcStaInfo->dataPdu[UNIFI_TRAFFIC_Q_VO])||
3005 !list_empty(&srcStaInfo->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]));
3006 if(moreData && (srcStaInfo->timSet == CSR_WIFI_TIM_RESET)) {
3007 unifi_trace(priv, UDBG3, "This condition should not occur\n");
3008 if (!srcStaInfo->timRequestPendingFlag){
3009 update_tim(priv,srcStaInfo->aid,1,interfaceTag, srcStaInfo->assignedHandle);
3010 }
3011 else
3012 {
3013
3014
3015
3016 srcStaInfo->updateTimReqQueued = 1;
3017 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", srcStaInfo->updateTimReqQueued,
3018 srcStaInfo->aid);
3019 }
3020
3021 }
3022 } else {
3023 u8 allDeliveryEnabled = 0, dataAvailable = 0;
3024 unifi_trace(priv, UDBG5, "Qos in AP Mode\n");
3025
3026 is_all_ac_deliver_enabled_and_moredata(srcStaInfo, &allDeliveryEnabled, &dataAvailable);
3027
3028 moreData = (uf_is_more_data_for_non_delivery_ac(srcStaInfo) || (allDeliveryEnabled && dataAvailable));
3029
3030 if(moreData && (srcStaInfo->timSet == CSR_WIFI_TIM_RESET)) {
3031 if (!srcStaInfo->timRequestPendingFlag){
3032 update_tim(priv,srcStaInfo->aid,1,interfaceTag, srcStaInfo->assignedHandle);
3033 }
3034 else
3035 {
3036
3037
3038
3039 srcStaInfo->updateTimReqQueued = 1;
3040 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", srcStaInfo->updateTimReqQueued,
3041 srcStaInfo->aid);
3042 }
3043 }
3044 }
3045 }
3046 unifi_trace(priv, UDBG3, "leaving uf_process_pm_bit_for_peer\n");
3047 return powerSaveChanged;
3048}
3049
3050
3051
3052void uf_process_ps_poll(unifi_priv_t *priv,u8* sa,u8* da,u8 pmBit,u16 interfaceTag)
3053{
3054 CsrWifiRouterCtrlStaInfo_t *staRecord =
3055 CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, sa, interfaceTag);
3056 tx_buffered_packets_t * buffered_pkt = NULL;
3057 CsrWifiMacAddress peerMacAddress;
3058 unsigned long lock_flags;
3059 s8 r =0;
3060 u8 moreData = FALSE;
3061 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
3062
3063 unifi_trace(priv, UDBG3, "entering uf_process_ps_poll\n");
3064 if(!staRecord) {
3065 memcpy(peerMacAddress.a,sa,ETH_ALEN);
3066 unifi_trace(priv, UDBG3, "In uf_process_ps_poll, sta record not found:unexpected frame addr = %x:%x:%x:%x:%x:%x\n",
3067 sa[0], sa[1],sa[2], sa[3], sa[4],sa[5]);
3068 CsrWifiRouterCtrlUnexpectedFrameIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,0,interfaceTag,peerMacAddress);
3069 return;
3070 }
3071
3072 uf_process_pm_bit_for_peer(priv,staRecord,pmBit,interfaceTag);
3073
3074
3075 staRecord->activity_flag = TRUE;
3076
3077
3078 if(!pmBit) {
3079 unifi_notice (priv," PM bit reset in PS-POLL\n");
3080 return;
3081 }
3082
3083 if(IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag)) {
3084
3085 unifi_notice (priv," multicast transmission is going on so don't take action on PS-POLL\n");
3086 return;
3087 }
3088
3089 if(!staRecord->wmmOrQosEnabled) {
3090 if((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->mgtFrames))) {
3091 buffered_pkt->transmissionControl |= TRANSMISSION_CONTROL_TRIGGER_MASK;
3092 moreData = (!list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]) ||
3093 !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]) ||
3094 !list_empty(&staRecord->mgtFrames));
3095
3096 buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3097 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staRecord,moreData,FALSE)) == -ENOSPC) {
3098
3099 buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3100
3101 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3102 list_add(&buffered_pkt->q, &staRecord->mgtFrames);
3103 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3104 unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
3105 priv->pausedStaHandle[3]=(u8)(staRecord->assignedHandle);
3106 } else {
3107 if(r){
3108 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3109
3110 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3111 }
3112 kfree(buffered_pkt);
3113 }
3114 } else if((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]))) {
3115 buffered_pkt->transmissionControl |= TRANSMISSION_CONTROL_TRIGGER_MASK;
3116 moreData = (!list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]) ||
3117 !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]));
3118
3119 buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3120 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staRecord,moreData,FALSE)) == -ENOSPC) {
3121
3122 buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3123
3124 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3125 list_add(&buffered_pkt->q, &staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]);
3126 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3127 priv->pausedStaHandle[3]=(u8)(staRecord->assignedHandle);
3128 unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
3129 } else {
3130 if(r){
3131 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3132
3133 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3134 }
3135 kfree(buffered_pkt);
3136 }
3137 } else if((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]))) {
3138 buffered_pkt->transmissionControl |= TRANSMISSION_CONTROL_TRIGGER_MASK;
3139 moreData = !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]);
3140
3141 buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3142 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staRecord,moreData,FALSE)) == -ENOSPC) {
3143
3144 buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3145
3146 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3147 list_add(&buffered_pkt->q, &staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]);
3148 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3149 priv->pausedStaHandle[0]=(u8)(staRecord->assignedHandle);
3150 unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
3151 } else {
3152 if(r){
3153 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3154
3155 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3156 }
3157 kfree(buffered_pkt);
3158 }
3159 } else {
3160
3161
3162 }
3163 moreData = (!list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]) ||
3164 !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]) ||
3165 !list_empty(&staRecord->mgtFrames));
3166 if(!moreData && (staRecord->timSet == CSR_WIFI_TIM_SET)) {
3167 unifi_trace(priv, UDBG3, "more data = NULL, set tim to 0 in uf_process_ps_poll\n");
3168 if (!staRecord->timRequestPendingFlag){
3169 update_tim(priv,staRecord->aid,0,interfaceTag, staRecord->assignedHandle);
3170 }
3171 else
3172 {
3173
3174
3175
3176 staRecord->updateTimReqQueued = 0;
3177 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
3178 staRecord->aid);
3179 }
3180 }
3181 } else {
3182
3183 u8 allDeliveryEnabled = 0, dataAvailable = 0;
3184 unifi_trace(priv, UDBG3,"Qos Support station.Processing PS-Poll\n");
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194 is_all_ac_deliver_enabled_and_moredata(staRecord, &allDeliveryEnabled, &dataAvailable);
3195
3196 if (allDeliveryEnabled) {
3197 unifi_trace(priv, UDBG3, "uf_process_ps_poll: All ACs are delivery enable so Sending QOS Null in response of Ps-poll\n");
3198 uf_send_qos_null(priv,interfaceTag,sa,CSR_QOS_UP0,staRecord);
3199 return;
3200 }
3201
3202 if (!list_empty(&staRecord->mgtFrames)) {
3203 if ((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->mgtFrames))) {
3204
3205
3206
3207 moreData = uf_is_more_data_for_non_delivery_ac(staRecord);
3208 buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3209
3210
3211 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staRecord,moreData,FALSE)) == -ENOSPC) {
3212
3213 buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3214
3215 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3216 list_add(&buffered_pkt->q, &staRecord->mgtFrames);
3217 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3218 priv->pausedStaHandle[0]=(u8)(staRecord->assignedHandle);
3219 unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
3220 } else {
3221 if(r){
3222 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3223
3224 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3225 }
3226 kfree(buffered_pkt);
3227 }
3228 } else {
3229 unifi_error(priv, "uf_process_ps_poll: Mgt frame list empty!! \n");
3230 }
3231
3232 } else {
3233 s8 i;
3234
3235
3236
3237 for(i= 3; i>=0; i--) {
3238 if (!IS_DELIVERY_ENABLED(staRecord->powersaveMode[i])) {
3239
3240 if((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->dataPdu[i]))) {
3241 moreData = uf_is_more_data_for_non_delivery_ac(staRecord);
3242
3243 buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3244
3245
3246 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staRecord,moreData,FALSE)) == -ENOSPC) {
3247
3248 buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3249
3250 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3251 list_add(&buffered_pkt->q, &staRecord->dataPdu[i]);
3252 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3253 priv->pausedStaHandle[0]=(u8)(staRecord->assignedHandle);
3254 unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
3255 } else {
3256 if(r) {
3257 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3258
3259 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3260 }
3261 kfree(buffered_pkt);
3262 }
3263 break;
3264 }
3265 }
3266 }
3267 }
3268
3269 is_all_ac_deliver_enabled_and_moredata(staRecord, &allDeliveryEnabled, &dataAvailable);
3270
3271 moreData = (uf_is_more_data_for_non_delivery_ac(staRecord) || (allDeliveryEnabled && dataAvailable));
3272 if(!moreData && (staRecord->timSet == CSR_WIFI_TIM_SET)) {
3273 unifi_trace(priv, UDBG3, "more data = NULL, set tim to 0 in uf_process_ps_poll\n");
3274 if (!staRecord->timRequestPendingFlag){
3275 update_tim(priv,staRecord->aid,0,interfaceTag, staRecord->assignedHandle);
3276 }
3277 else
3278 {
3279
3280
3281
3282 staRecord->updateTimReqQueued = 0;
3283 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
3284 staRecord->aid);
3285 }
3286
3287 }
3288 }
3289
3290 unifi_trace(priv, UDBG3, "leaving uf_process_ps_poll\n");
3291}
3292
3293
3294
3295void add_to_send_cfm_list(unifi_priv_t * priv,
3296 tx_buffered_packets_t *tx_q_item,
3297 struct list_head *frames_need_cfm_list)
3298{
3299 tx_buffered_packets_t *send_cfm_list_item = NULL;
3300
3301 send_cfm_list_item = (tx_buffered_packets_t *) kmalloc(sizeof(tx_buffered_packets_t), GFP_ATOMIC);
3302
3303 if(send_cfm_list_item == NULL){
3304 unifi_warning(priv, "%s: Failed to allocate memory for new list item \n");
3305 return;
3306 }
3307
3308 INIT_LIST_HEAD(&send_cfm_list_item->q);
3309
3310 send_cfm_list_item->hostTag = tx_q_item->hostTag;
3311 send_cfm_list_item->interfaceTag = tx_q_item->interfaceTag;
3312 send_cfm_list_item->transmissionControl = tx_q_item->transmissionControl;
3313 send_cfm_list_item->leSenderProcessId = tx_q_item->leSenderProcessId;
3314 send_cfm_list_item->rate = tx_q_item->rate;
3315 memcpy(send_cfm_list_item->peerMacAddress.a, tx_q_item->peerMacAddress.a, ETH_ALEN);
3316 send_cfm_list_item->priority = tx_q_item->priority;
3317
3318 list_add_tail(&send_cfm_list_item->q, frames_need_cfm_list);
3319}
3320
3321void uf_prepare_send_cfm_list_for_queued_pkts(unifi_priv_t * priv,
3322 struct list_head *frames_need_cfm_list,
3323 struct list_head * list)
3324{
3325 tx_buffered_packets_t *tx_q_item = NULL;
3326 struct list_head *listHead;
3327 struct list_head *placeHolder;
3328 unsigned long lock_flags;
3329
3330 func_enter();
3331
3332 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3333
3334
3335
3336 list_for_each_safe(listHead, placeHolder, list) {
3337 tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
3338
3339 if(!tx_q_item) {
3340 unifi_error(priv, "Entry should exist, otherwise it is a (BUG)\n");
3341 continue;
3342 }
3343
3344
3345
3346 if (!(tx_q_item->transmissionControl & CSR_NO_CONFIRM_REQUIRED) &&
3347 (tx_q_item->leSenderProcessId != priv->netdev_client->sender_id)){
3348 unifi_trace(priv, UDBG1, "%s: SenderProcessID=%x host tag=%x transmission control=%x\n",
3349 __FUNCTION__,
3350 tx_q_item->leSenderProcessId,
3351 tx_q_item->hostTag,
3352 tx_q_item->transmissionControl);
3353
3354 add_to_send_cfm_list(priv, tx_q_item, frames_need_cfm_list);
3355 }
3356 }
3357
3358 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3359
3360 func_exit();
3361}
3362
3363
3364
3365void uf_flush_list(unifi_priv_t * priv, struct list_head * list)
3366{
3367 tx_buffered_packets_t *tx_q_item;
3368 struct list_head *listHead;
3369 struct list_head *placeHolder;
3370 unsigned long lock_flags;
3371
3372 unifi_trace(priv, UDBG5, "entering the uf_flush_list \n");
3373
3374 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3375
3376 list_for_each_safe(listHead, placeHolder, list) {
3377 tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
3378
3379 if(!tx_q_item) {
3380 unifi_error(priv, "entry should exists, otherwise crashes (bug)\n");
3381 }
3382 unifi_trace(priv, UDBG5,
3383 "proccess_tx: in uf_flush_list peerMacAddress=%02X%02X%02X%02X%02X%02X senderProcessId=%x\n",
3384 tx_q_item->peerMacAddress.a[0], tx_q_item->peerMacAddress.a[1],
3385 tx_q_item->peerMacAddress.a[2], tx_q_item->peerMacAddress.a[3],
3386 tx_q_item->peerMacAddress.a[4], tx_q_item->peerMacAddress.a[5],
3387 tx_q_item->leSenderProcessId);
3388
3389 list_del(listHead);
3390
3391 unifi_net_data_free(priv, &tx_q_item->bulkdata);
3392 kfree(tx_q_item);
3393 tx_q_item = NULL;
3394 if (!priv->noOfPktQueuedInDriver) {
3395 unifi_error(priv, "packets queued in driver 0 still decrementing in %s\n", __FUNCTION__);
3396 } else {
3397 priv->noOfPktQueuedInDriver--;
3398 }
3399 }
3400 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3401}
3402
3403tx_buffered_packets_t *dequeue_tx_data_pdu(unifi_priv_t *priv, struct list_head *txList)
3404{
3405
3406 tx_buffered_packets_t *tx_q_item = NULL;
3407 struct list_head *listHead;
3408 struct list_head *placeHolder;
3409 unsigned long lock_flags;
3410
3411 unifi_trace(priv, UDBG5, "entering dequeue_tx_data_pdu\n");
3412
3413 if (list_empty(txList)) {
3414 unifi_trace(priv, UDBG5, "In dequeue_tx_data_pdu, the list is empty\n");
3415 return NULL;
3416 }
3417
3418
3419 if (priv->noOfPktQueuedInDriver == 0xFFFF) {
3420 unifi_warning(priv, "no packet available in queue: debug");
3421 return NULL;
3422 }
3423
3424
3425 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3426 list_for_each_safe(listHead, placeHolder, txList) {
3427 tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
3428 list_del(listHead);
3429 break;
3430 }
3431 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3432
3433 if (tx_q_item) {
3434 unifi_trace(priv, UDBG5,
3435 "proccess_tx: In dequeue_tx_data_pdu peerMacAddress=%02X%02X%02X%02X%02X%02X senderProcessId=%x\n",
3436 tx_q_item->peerMacAddress.a[0], tx_q_item->peerMacAddress.a[1],
3437 tx_q_item->peerMacAddress.a[2], tx_q_item->peerMacAddress.a[3],
3438 tx_q_item->peerMacAddress.a[4], tx_q_item->peerMacAddress.a[5],
3439 tx_q_item->leSenderProcessId);
3440 }
3441
3442 unifi_trace(priv, UDBG5, "leaving dequeue_tx_data_pdu\n");
3443 return tx_q_item;
3444}
3445
3446CsrWifiRouterCtrlStaInfo_t *CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(unifi_priv_t *priv,
3447 const u8 *peerMacAddress,
3448 u16 interfaceTag)
3449{
3450 u8 i;
3451 netInterface_priv_t *interfacePriv;
3452 unsigned long lock_flags;
3453
3454 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
3455 unifi_error(priv, "interfaceTag is not proper, interfaceTag = %d\n", interfaceTag);
3456 return NULL;
3457 }
3458
3459 interfacePriv = priv->interfacePriv[interfaceTag];
3460
3461
3462 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
3463
3464 for (i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
3465 if (interfacePriv->staInfo[i]!= NULL) {
3466 if (!memcmp(((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[i]))->peerMacAddress.a, peerMacAddress, ETH_ALEN)) {
3467
3468 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
3469 unifi_trace(priv, UDBG5, "peer entry found in station record\n");
3470 return ((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[i]));
3471 }
3472 }
3473 }
3474
3475 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
3476 unifi_trace(priv, UDBG5, "peer entry not found in station record\n");
3477 return NULL;
3478}
3479
3480CsrWifiRouterCtrlStaInfo_t * CsrWifiRouterCtrlGetStationRecordFromHandle(unifi_priv_t *priv,
3481 u32 handle,
3482 u16 interfaceTag)
3483{
3484 netInterface_priv_t *interfacePriv;
3485
3486 if ((handle >= UNIFI_MAX_CONNECTIONS) || (interfaceTag >= CSR_WIFI_NUM_INTERFACES)) {
3487 unifi_error(priv, "handle/interfaceTag is not proper, handle = %d, interfaceTag = %d\n", handle, interfaceTag);
3488 return NULL;
3489 }
3490 interfacePriv = priv->interfacePriv[interfaceTag];
3491 return ((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[handle]));
3492}
3493
3494
3495void uf_check_inactivity(unifi_priv_t *priv, u16 interfaceTag, CsrTime currentTime)
3496{
3497 u32 i;
3498 CsrWifiRouterCtrlStaInfo_t *staInfo;
3499 CsrTime elapsedTime;
3500 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
3501 CsrWifiMacAddress peerMacAddress;
3502 unsigned long lock_flags;
3503
3504 if (interfacePriv == NULL) {
3505 unifi_trace(priv, UDBG3, "uf_check_inactivity: Interface priv is NULL \n");
3506 return;
3507 }
3508
3509 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
3510
3511 for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
3512 staInfo = CsrWifiRouterCtrlGetStationRecordFromHandle(priv, i, interfaceTag);
3513 if(!staInfo ) {
3514 continue;
3515 }
3516
3517 unifi_trace(priv, UDBG3, "Running Inactivity handler Time %xus station's last activity %xus\n",
3518 currentTime, staInfo->lastActivity);
3519
3520
3521 elapsedTime = (currentTime >= staInfo->lastActivity)?
3522 (currentTime - staInfo->lastActivity):
3523 (~((u32)0) - staInfo->lastActivity + currentTime);
3524 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
3525
3526 if (elapsedTime > MAX_INACTIVITY_INTERVAL) {
3527 memcpy((u8*)&peerMacAddress, (u8*)&staInfo->peerMacAddress, sizeof(CsrWifiMacAddress));
3528
3529
3530 unifi_trace(priv, UDBG3, "Station %x:%x:%x:%x:%x:%x inactive since %xus\n sending Inactive Ind\n",
3531 peerMacAddress.a[0], peerMacAddress.a[1],
3532 peerMacAddress.a[2], peerMacAddress.a[3],
3533 peerMacAddress.a[4], peerMacAddress.a[5],
3534 elapsedTime);
3535
3536 CsrWifiRouterCtrlStaInactiveIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, peerMacAddress);
3537 }
3538 }
3539
3540 interfacePriv->last_inactivity_check = currentTime;
3541}
3542
3543
3544void uf_update_sta_activity(unifi_priv_t *priv, u16 interfaceTag, const u8 *peerMacAddress)
3545{
3546 CsrTime elapsedTime, currentTime;
3547 CsrTime timeHi;
3548 CsrWifiRouterCtrlStaInfo_t *staInfo;
3549 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
3550 unsigned long lock_flags;
3551
3552 if (interfacePriv == NULL) {
3553 unifi_trace(priv, UDBG3, "uf_check_inactivity: Interface priv is NULL \n");
3554 return;
3555 }
3556
3557 currentTime = CsrTimeGet(&timeHi);
3558
3559
3560 staInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, peerMacAddress, interfaceTag);
3561
3562 if (staInfo == NULL) {
3563 unifi_trace(priv, UDBG4, "Sta does not exist yet");
3564 return;
3565 }
3566
3567 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
3568
3569 staInfo->lastActivity = currentTime;
3570
3571
3572
3573
3574
3575
3576 elapsedTime = (currentTime >= interfacePriv->last_inactivity_check)?
3577 (currentTime - interfacePriv->last_inactivity_check):
3578 (~((u32)0) - interfacePriv->last_inactivity_check + currentTime);
3579
3580 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
3581
3582
3583 if (elapsedTime > INACTIVITY_CHECK_INTERVAL) {
3584 uf_check_inactivity(priv, interfaceTag, currentTime);
3585 }
3586}
3587void resume_unicast_buffered_frames(unifi_priv_t *priv, u16 interfaceTag)
3588{
3589
3590 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
3591 u8 i;
3592 int j;
3593 tx_buffered_packets_t * buffered_pkt = NULL;
3594 u8 hipslotFree[4] = {TRUE,TRUE,TRUE,TRUE};
3595 int r;
3596 unsigned long lock_flags;
3597
3598 func_enter();
3599 while(!isRouterBufferEnabled(priv,3) &&
3600 ((buffered_pkt=dequeue_tx_data_pdu(priv,&interfacePriv->genericMgtFrames))!=NULL)) {
3601 buffered_pkt->transmissionControl &=
3602 ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
3603 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,NULL,0,FALSE)) == -ENOSPC) {
3604
3605 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3606 list_add(&buffered_pkt->q, &interfacePriv->genericMgtFrames);
3607 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3608 hipslotFree[3]=FALSE;
3609 break;
3610 }else {
3611 if(r){
3612 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3613
3614 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3615 }
3616 kfree(buffered_pkt);
3617 }
3618 }
3619 for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
3620 CsrWifiRouterCtrlStaInfo_t *staInfo = interfacePriv->staInfo[i];
3621 if(!hipslotFree[0] && !hipslotFree[1] && !hipslotFree[2] && !hipslotFree[3]) {
3622 unifi_trace(priv, UDBG3, "(ENOSPC) in resume_unicast_buffered_frames:: hip slots are full \n");
3623 break;
3624 }
3625 if (staInfo && (staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE)) {
3626 while((( TRUE == hipslotFree[3] ) && (buffered_pkt=dequeue_tx_data_pdu(priv, &staInfo->mgtFrames)))) {
3627 buffered_pkt->transmissionControl &=
3628 ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
3629 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staInfo,0,FALSE)) == -ENOSPC) {
3630 unifi_trace(priv, UDBG3, "(ENOSPC) in resume_unicast_buffered_frames:: hip slots are full for voice queue\n");
3631
3632 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3633 list_add(&buffered_pkt->q, &staInfo->mgtFrames);
3634 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3635 priv->pausedStaHandle[3]=(u8)(staInfo->assignedHandle);
3636 hipslotFree[3] = FALSE;
3637 break;
3638 } else {
3639 if(r){
3640 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3641
3642 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3643 }
3644 kfree(buffered_pkt);
3645 }
3646 }
3647
3648 for(j=3;j>=0;j--) {
3649 if(!hipslotFree[j])
3650 continue;
3651
3652 while((buffered_pkt=dequeue_tx_data_pdu(priv, &staInfo->dataPdu[j]))) {
3653 buffered_pkt->transmissionControl &=
3654 ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
3655 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staInfo,0,FALSE)) == -ENOSPC) {
3656
3657 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3658 list_add(&buffered_pkt->q, &staInfo->dataPdu[j]);
3659 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3660 priv->pausedStaHandle[j]=(u8)(staInfo->assignedHandle);
3661 hipslotFree[j]=FALSE;
3662 break;
3663 } else {
3664 if(r){
3665 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3666
3667 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3668 }
3669 kfree(buffered_pkt);
3670 }
3671 }
3672 }
3673 }
3674 }
3675 func_exit();
3676}
3677void update_eosp_to_head_of_broadcast_list_head(unifi_priv_t *priv,u16 interfaceTag)
3678{
3679
3680 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
3681 unsigned long lock_flags;
3682 struct list_head *listHead;
3683 struct list_head *placeHolder;
3684 tx_buffered_packets_t *tx_q_item;
3685
3686 func_enter();
3687 if (interfacePriv->noOfbroadcastPktQueued) {
3688
3689
3690
3691
3692
3693 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3694 list_for_each_safe(listHead, placeHolder, &interfacePriv->genericMulticastOrBroadCastFrames) {
3695 tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
3696 tx_q_item->transmissionControl |= TRANSMISSION_CONTROL_EOSP_MASK;
3697 tx_q_item->transmissionControl = (tx_q_item->transmissionControl & ~(CSR_NO_CONFIRM_REQUIRED));
3698 unifi_trace(priv, UDBG1,"updating eosp for list Head hostTag:= 0x%x ",tx_q_item->hostTag);
3699 break;
3700 }
3701 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3702 }
3703 func_exit();
3704}
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718void resume_suspended_uapsd(unifi_priv_t* priv,u16 interfaceTag)
3719{
3720
3721 u8 startIndex;
3722 CsrWifiRouterCtrlStaInfo_t * staInfo = NULL;
3723 unsigned long lock_flags;
3724
3725 unifi_trace(priv, UDBG2, "++resume_suspended_uapsd: \n");
3726 for(startIndex= 0; startIndex < UNIFI_MAX_CONNECTIONS;startIndex++) {
3727 staInfo = CsrWifiRouterCtrlGetStationRecordFromHandle(priv,startIndex,interfaceTag);
3728
3729 if(!staInfo || !staInfo->wmmOrQosEnabled) {
3730 continue;
3731 } else if((staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)
3732 &&staInfo->uapsdActive && staInfo->uspSuspend) {
3733
3734
3735
3736 uf_handle_uspframes_delivery(priv, staInfo, interfaceTag);
3737 } else {
3738 unifi_trace(priv, UDBG2, "resume_suspended_uapsd: PS state=%x, uapsdActive?=%x, suspend?=%x\n",
3739 staInfo->currentPeerState, staInfo->uapsdActive, staInfo->uspSuspend);
3740 if (staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE)
3741 {
3742 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
3743 staInfo->uapsdActive = FALSE;
3744 staInfo->uspSuspend = FALSE;
3745 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
3746 }
3747 }
3748 }
3749 unifi_trace(priv, UDBG2, "--resume_suspended_uapsd:\n");
3750}
3751
3752#endif
3753