2 * ---------------------------------------------------------------------------
3 * FILE: unifi_pdu_processing.c
6 * This file provides the PDU handling functionality before it gets sent to unfi and after
7 * receiving a PDU from unifi
9 * Copyright (C) 2010 by Cambridge Silicon Radio Ltd.
11 * Refer to LICENSE.txt included with this source code for details on
14 * ---------------------------------------------------------------------------
17 #include <linux/types.h>
18 #include <linux/etherdevice.h>
19 #include <linux/vmalloc.h>
21 #include "csr_wifi_hip_unifi.h"
22 #include "csr_wifi_hip_conversions.h"
24 #include "unifi_priv.h"
25 #include <net/pkt_sched.h>
27 #ifdef CSR_SUPPORT_SME
28 static void _update_buffered_pkt_params_after_alignment(unifi_priv_t *priv, bulk_data_param_t *bulkdata,
29 tx_buffered_packets_t* buffered_pkt)
34 if (priv == NULL || bulkdata == NULL || buffered_pkt == NULL){
38 skb = (struct sk_buff*)bulkdata->d[0].os_net_buf_ptr;
39 align_offset = (u32)(long)(bulkdata->d[0].os_data_ptr) & (CSR_WIFI_ALIGN_BYTES-1);
41 skb_pull(skb,align_offset);
44 buffered_pkt->bulkdata.os_data_ptr = bulkdata->d[0].os_data_ptr;
45 buffered_pkt->bulkdata.data_length = bulkdata->d[0].data_length;
46 buffered_pkt->bulkdata.os_net_buf_ptr = bulkdata->d[0].os_net_buf_ptr;
47 buffered_pkt->bulkdata.net_buf_length = bulkdata->d[0].net_buf_length;
52 unifi_frame_ma_packet_req(unifi_priv_t *priv, CSR_PRIORITY priority,
53 CSR_RATE TransmitRate, CSR_CLIENT_TAG hostTag,
54 u16 interfaceTag, CSR_TRANSMISSION_CONTROL transmissionControl,
55 CSR_PROCESS_ID leSenderProcessId, u8 *peerMacAddress,
59 CSR_MA_PACKET_REQUEST *req = &signal->u.MaPacketRequest;
60 netInterface_priv_t *interfacePriv;
61 u8 ba_session_idx = 0;
62 ba_session_tx_struct *ba_session = NULL;
65 interfacePriv = priv->interfacePriv[interfaceTag];
67 unifi_trace(priv, UDBG5,
68 "In unifi_frame_ma_packet_req, Frame for Peer: %pMF\n",
70 signal->SignalPrimitiveHeader.SignalId = CSR_MA_PACKET_REQUEST_ID;
71 signal->SignalPrimitiveHeader.ReceiverProcessId = 0;
72 signal->SignalPrimitiveHeader.SenderProcessId = leSenderProcessId;
74 /* Fill the MA-PACKET.req */
75 req->Priority = priority;
76 unifi_trace(priv, UDBG3, "Tx Frame with Priority: 0x%x\n", req->Priority);
78 /* A value of 0 is used for auto selection of rates. But for P2P GO case
79 * for action frames the rate is governed by SME. Hence instead of 0,
80 * the rate is filled in with the value passed here
82 req->TransmitRate = TransmitRate;
84 /* packets from netdev then no confirm required but packets from
85 * Nme/Sme eapol data frames requires the confirmation
87 req->TransmissionControl = transmissionControl;
88 req->VirtualInterfaceIdentifier =
89 uf_get_vif_identifier(interfacePriv->interfaceMode,interfaceTag);
90 memcpy(req->Ra.x, peerMacAddress, ETH_ALEN);
92 if (hostTag == 0xffffffff) {
93 req->HostTag = interfacePriv->tag++;
94 req->HostTag |= 0x40000000;
95 unifi_trace(priv, UDBG3, "new host tag assigned = 0x%x\n", req->HostTag);
96 interfacePriv->tag &= 0x0fffffff;
98 req->HostTag = hostTag;
99 unifi_trace(priv, UDBG3, "host tag got from SME = 0x%x\n", req->HostTag);
101 /* check if BA session exists for the peer MAC address on same tID */
102 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
103 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO){
104 ba_addr = peerMacAddress;
106 ba_addr = interfacePriv->bssid.a;
108 for (ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_TX; ba_session_idx++){
109 ba_session = interfacePriv->ba_session_tx[ba_session_idx];
111 if ((!memcmp(ba_session->macAddress.a, ba_addr, ETH_ALEN)) && (ba_session->tID == priority)){
112 req->TransmissionControl |= CSR_ALLOW_BA;
118 unifi_trace(priv, UDBG5, "leaving unifi_frame_ma_packet_req\n");
121 #ifdef CSR_SUPPORT_SME
123 #define TRANSMISSION_CONTROL_TRIGGER_MASK 0x0001
124 #define TRANSMISSION_CONTROL_EOSP_MASK 0x0002
127 int frame_and_send_queued_pdu(unifi_priv_t* priv,tx_buffered_packets_t* buffered_pkt,
128 CsrWifiRouterCtrlStaInfo_t *staRecord,u8 moreData , u8 eosp)
132 bulk_data_param_t bulkdata;
134 u8 toDs, fromDs, macHeaderLengthInBytes = MAC_HEADER_SIZE;
136 u16 *fc = (u16*)(buffered_pkt->bulkdata.os_data_ptr);
137 unsigned long lock_flags;
138 unifi_trace(priv, UDBG3, "frame_and_send_queued_pdu with moreData: %d , EOSP: %d\n",moreData,eosp);
139 unifi_frame_ma_packet_req(priv, buffered_pkt->priority, buffered_pkt->rate, buffered_pkt->hostTag,
140 buffered_pkt->interfaceTag, buffered_pkt->transmissionControl,
141 buffered_pkt->leSenderProcessId, buffered_pkt->peerMacAddress.a, &signal);
142 bulkdata.d[0].os_data_ptr = buffered_pkt->bulkdata.os_data_ptr;
143 bulkdata.d[0].data_length = buffered_pkt->bulkdata.data_length;
144 bulkdata.d[0].os_net_buf_ptr = buffered_pkt->bulkdata.os_net_buf_ptr;
145 bulkdata.d[0].net_buf_length = buffered_pkt->bulkdata.net_buf_length;
146 bulkdata.d[1].os_data_ptr = NULL;
147 bulkdata.d[1].data_length = 0;
148 bulkdata.d[1].os_net_buf_ptr =0;
149 bulkdata.d[1].net_buf_length =0;
152 *fc |= cpu_to_le16(IEEE802_11_FC_MOREDATA_MASK);
154 *fc &= cpu_to_le16(~IEEE802_11_FC_MOREDATA_MASK);
157 if((staRecord != NULL)&& (staRecord->wmmOrQosEnabled == TRUE))
159 unifi_trace(priv, UDBG3, "frame_and_send_queued_pdu WMM Enabled: %d \n",staRecord->wmmOrQosEnabled);
161 toDs = (*fc & cpu_to_le16(IEEE802_11_FC_TO_DS_MASK))?1 : 0;
162 fromDs = (*fc & cpu_to_le16(IEEE802_11_FC_FROM_DS_MASK))? 1: 0;
164 switch(le16_to_cpu(*fc) & IEEE80211_FC_SUBTYPE_MASK)
166 case IEEE802_11_FC_TYPE_QOS_DATA & IEEE80211_FC_SUBTYPE_MASK:
167 case IEEE802_11_FC_TYPE_QOS_NULL & IEEE80211_FC_SUBTYPE_MASK:
168 /* If both are set then the Address4 exists (only for AP) */
169 if (fromDs && toDs) {
170 /* 6 is the size of Address4 field */
171 macHeaderLengthInBytes += (QOS_CONTROL_HEADER_SIZE + 6);
173 macHeaderLengthInBytes += QOS_CONTROL_HEADER_SIZE;
176 /* If order bit set then HT control field is the part of MAC header */
177 if (*fc & cpu_to_le16(IEEE80211_FC_ORDER_MASK)) {
178 macHeaderLengthInBytes += HT_CONTROL_HEADER_SIZE;
179 qc = (u8*)(buffered_pkt->bulkdata.os_data_ptr + (macHeaderLengthInBytes-6));
181 qc = (u8*)(buffered_pkt->bulkdata.os_data_ptr + (macHeaderLengthInBytes-2));
183 *qc = eosp ? *qc | (1 << 4) : *qc & (~(1 << 4));
187 macHeaderLengthInBytes += 6;
191 result = ul_send_signal_unpacked(priv, &signal, &bulkdata);
193 _update_buffered_pkt_params_after_alignment(priv, &bulkdata,buffered_pkt);
196 /* Decrement the packet counts queued in driver */
197 if (result != -ENOSPC) {
198 /* protect entire counter updation by disabling preemption */
199 if (!priv->noOfPktQueuedInDriver) {
200 unifi_error(priv, "packets queued in driver 0 still decrementing\n");
202 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
203 priv->noOfPktQueuedInDriver--;
204 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
206 /* Sta Record is available for all unicast (except genericMgt Frames) & in other case its NULL */
208 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
209 if (!staRecord->noOfPktQueued) {
210 unifi_error(priv, "packets queued in driver per station is 0 still decrementing\n");
212 staRecord->noOfPktQueued--;
214 /* if the STA alive probe frame has failed then reset the saved host tag */
216 if (staRecord->nullDataHostTag == buffered_pkt->hostTag){
217 staRecord->nullDataHostTag = INVALID_HOST_TAG;
220 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
226 #ifdef CSR_SUPPORT_SME
228 void set_eosp_transmit_ctrl(unifi_priv_t *priv, struct list_head *txList)
230 /* dequeue the tx data packets from the appropriate queue */
231 tx_buffered_packets_t *tx_q_item = NULL;
232 struct list_head *listHead;
233 struct list_head *placeHolder;
234 unsigned long lock_flags;
237 unifi_trace(priv, UDBG5, "entering set_eosp_transmit_ctrl\n");
238 /* check for list empty */
239 if (list_empty(txList)) {
240 unifi_warning(priv, "In set_eosp_transmit_ctrl, the list is empty\n");
244 /* return the last node , and modify it. */
246 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
247 list_for_each_prev_safe(listHead, placeHolder, txList) {
248 tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
249 tx_q_item->transmissionControl |= TRANSMISSION_CONTROL_EOSP_MASK;
250 tx_q_item->transmissionControl = (tx_q_item->transmissionControl & ~(CSR_NO_CONFIRM_REQUIRED));
251 unifi_trace(priv, UDBG1,
252 "set_eosp_transmit_ctrl Transmission Control = 0x%x hostTag = 0x%x \n",tx_q_item->transmissionControl,tx_q_item->hostTag);
253 unifi_trace(priv,UDBG3,"in set_eosp_transmit_ctrl no.of buffered frames %d\n",priv->noOfPktQueuedInDriver);
256 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
257 unifi_trace(priv, UDBG1,"List Empty %d\n",list_empty(txList));
258 unifi_trace(priv, UDBG5, "leaving set_eosp_transmit_ctrl\n");
263 void send_vif_availibility_rsp(unifi_priv_t *priv,CSR_VIF_IDENTIFIER vif,CSR_RESULT_CODE resultCode)
266 CSR_MA_VIF_AVAILABILITY_RESPONSE *rsp;
267 bulk_data_param_t *bulkdata = NULL;
270 unifi_trace(priv, UDBG3, "send_vif_availibility_rsp : invoked with resultCode = %d \n", resultCode);
272 memset(&signal,0,sizeof(CSR_SIGNAL));
273 rsp = &signal.u.MaVifAvailabilityResponse;
274 rsp->VirtualInterfaceIdentifier = vif;
275 rsp->ResultCode = resultCode;
276 signal.SignalPrimitiveHeader.SignalId = CSR_MA_VIF_AVAILABILITY_RESPONSE_ID;
277 signal.SignalPrimitiveHeader.ReceiverProcessId = 0;
278 signal.SignalPrimitiveHeader.SenderProcessId = priv->netdev_client->sender_id;
280 /* Send the signal to UniFi */
281 r = ul_send_signal_unpacked(priv, &signal, bulkdata);
283 unifi_error(priv,"Availibility response sending failed %x status %d\n",vif,r);
286 unifi_trace(priv, UDBG3, "send_vif_availibility_rsp : status = %d \n", r);
292 void verify_and_accomodate_tx_packet(unifi_priv_t *priv)
294 tx_buffered_packets_t *tx_q_item;
295 unsigned long lock_flags;
296 struct list_head *listHead, *list;
297 struct list_head *placeHolder;
298 u8 i, j,eospFramedeleted=0;
299 u8 thresholdExcedeDueToBroadcast = TRUE;
300 /* it will be made it interface Specific in the future when multi interfaces are supported ,
301 right now interface 0 is considered */
302 netInterface_priv_t *interfacePriv = priv->interfacePriv[0];
303 CsrWifiRouterCtrlStaInfo_t *staInfo = NULL;
305 unifi_trace(priv, UDBG3, "entering verify_and_accomodate_tx_packet\n");
307 for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
308 staInfo = interfacePriv->staInfo[i];
309 if (staInfo && (staInfo->noOfPktQueued >= CSR_WIFI_DRIVER_MAX_PKT_QUEUING_THRESHOLD_PER_PEER)) {
310 /* remove the first(oldest) packet from the all the access catogory, since data
311 * packets for station record crossed the threshold limit (64 for AP supporting
314 unifi_trace(priv,UDBG3,"number of station pkts queued= %d for sta id = %d\n", staInfo->noOfPktQueued, staInfo->aid);
315 for(j = 0; j < MAX_ACCESS_CATOGORY; j++) {
316 list = &staInfo->dataPdu[j];
317 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
318 list_for_each_safe(listHead, placeHolder, list) {
319 tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
321 thresholdExcedeDueToBroadcast = FALSE;
322 unifi_net_data_free(priv, &tx_q_item->bulkdata);
325 if (!priv->noOfPktQueuedInDriver) {
326 unifi_error(priv, "packets queued in driver 0 still decrementing in %s\n", __FUNCTION__);
328 /* protection provided by spinlock */
329 priv->noOfPktQueuedInDriver--;
332 /* Sta Record is available for all unicast (except genericMgt Frames) & in other case its NULL */
333 if (!staInfo->noOfPktQueued) {
334 unifi_error(priv, "packets queued in driver per station is 0 still decrementing in %s\n", __FUNCTION__);
336 spin_lock(&priv->staRecord_lock);
337 staInfo->noOfPktQueued--;
338 spin_unlock(&priv->staRecord_lock);
342 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
346 if (thresholdExcedeDueToBroadcast && interfacePriv->noOfbroadcastPktQueued > CSR_WIFI_DRIVER_MINIMUM_BROADCAST_PKT_THRESHOLD ) {
347 /* Remove the packets from genericMulticastOrBroadCastFrames queue
348 * (the max packets in driver is reached due to broadcast/multicast frames)
350 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
351 list_for_each_safe(listHead, placeHolder, &interfacePriv->genericMulticastOrBroadCastFrames) {
352 tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
353 if(eospFramedeleted){
354 tx_q_item->transmissionControl |= TRANSMISSION_CONTROL_EOSP_MASK;
355 tx_q_item->transmissionControl = (tx_q_item->transmissionControl & ~(CSR_NO_CONFIRM_REQUIRED));
356 unifi_trace(priv, UDBG1,"updating eosp for next packet hostTag:= 0x%x ",tx_q_item->hostTag);
361 if(tx_q_item->transmissionControl & TRANSMISSION_CONTROL_EOSP_MASK ){
362 eospFramedeleted = 1;
364 unifi_trace(priv,UDBG1, "freeing of multicast packets ToC = 0x%x hostTag = 0x%x \n",tx_q_item->transmissionControl,tx_q_item->hostTag);
366 unifi_net_data_free(priv, &tx_q_item->bulkdata);
368 priv->noOfPktQueuedInDriver--;
369 spin_lock(&priv->staRecord_lock);
370 interfacePriv->noOfbroadcastPktQueued--;
371 spin_unlock(&priv->staRecord_lock);
372 if(!eospFramedeleted){
376 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
378 unifi_trace(priv, UDBG3, "leaving verify_and_accomodate_tx_packet\n");
382 CsrResult enque_tx_data_pdu(unifi_priv_t *priv, bulk_data_param_t *bulkdata,
383 struct list_head *list, CSR_SIGNAL *signal,
387 /* queue the tx data packets on to appropriate queue */
388 CSR_MA_PACKET_REQUEST *req = &signal->u.MaPacketRequest;
389 tx_buffered_packets_t *tx_q_item;
390 unsigned long lock_flags;
392 unifi_trace(priv, UDBG5, "entering enque_tx_data_pdu\n");
394 unifi_error(priv,"List is not specified\n");
395 return CSR_RESULT_FAILURE;
398 /* Removes aged packets & adds the incoming packet */
399 if (priv->noOfPktQueuedInDriver >= CSR_WIFI_DRIVER_SUPPORT_FOR_MAX_PKT_QUEUEING) {
400 unifi_trace(priv,UDBG3,"number of pkts queued= %d \n", priv->noOfPktQueuedInDriver);
401 verify_and_accomodate_tx_packet(priv);
406 tx_q_item = (tx_buffered_packets_t *)kmalloc(sizeof(tx_buffered_packets_t), GFP_ATOMIC);
407 if (tx_q_item == NULL) {
409 "Failed to allocate %d bytes for tx packet record\n",
410 sizeof(tx_buffered_packets_t));
412 return CSR_RESULT_FAILURE;
415 /* disable the preemption */
416 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
417 INIT_LIST_HEAD(&tx_q_item->q);
418 /* fill the tx_q structure members */
419 tx_q_item->bulkdata.os_data_ptr = bulkdata->d[0].os_data_ptr;
420 tx_q_item->bulkdata.data_length = bulkdata->d[0].data_length;
421 tx_q_item->bulkdata.os_net_buf_ptr = bulkdata->d[0].os_net_buf_ptr;
422 tx_q_item->bulkdata.net_buf_length = bulkdata->d[0].net_buf_length;
423 tx_q_item->interfaceTag = req->VirtualInterfaceIdentifier & 0xff;
424 tx_q_item->hostTag = req->HostTag;
425 tx_q_item->leSenderProcessId = signal->SignalPrimitiveHeader.SenderProcessId;
426 tx_q_item->transmissionControl = req->TransmissionControl;
427 tx_q_item->priority = req->Priority;
428 tx_q_item->rate = req->TransmitRate;
429 memcpy(tx_q_item->peerMacAddress.a, req->Ra.x, ETH_ALEN);
433 if (requeueOnSamePos) {
434 list_add(&tx_q_item->q, list);
436 list_add_tail(&tx_q_item->q, list);
439 /* Count of packet queued in driver */
440 priv->noOfPktQueuedInDriver++;
441 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
442 unifi_trace(priv, UDBG5, "leaving enque_tx_data_pdu\n");
443 return CSR_RESULT_SUCCESS;
446 #ifdef CSR_WIFI_REQUEUE_PACKET_TO_HAL
447 CsrResult unifi_reque_ma_packet_request (void *ospriv, u32 host_tag,
448 u16 txStatus, bulk_data_desc_t *bulkDataDesc)
450 CsrResult status = CSR_RESULT_SUCCESS;
451 unifi_priv_t *priv = (unifi_priv_t*)ospriv;
452 netInterface_priv_t *interfacePriv;
453 struct list_head *list = NULL;
454 CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
455 bulk_data_param_t bulkData;
457 CSR_PRIORITY priority = 0;
458 u16 interfaceTag = 0;
459 unifi_TrafficQueue priority_q;
460 u16 frameControl = 0, frameType = 0;
461 unsigned long lock_flags;
463 interfacePriv = priv->interfacePriv[interfaceTag];
465 /* If the current mode is not AP or P2PGO then just return failure
466 * to clear the hip slot
468 if(!((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP) ||
469 (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO))) {
470 return CSR_RESULT_FAILURE;
473 unifi_trace(priv, UDBG6, "unifi_reque_ma_packet_request: host_tag = 0x%x\n", host_tag);
475 staRecord = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv,
476 (((u8 *) bulkDataDesc->os_data_ptr) + 4),
478 if (NULL == staRecord) {
479 unifi_trace(priv, UDBG5, "unifi_reque_ma_packet_request: Invalid STA record \n");
480 return CSR_RESULT_FAILURE;
483 /* Update TIM if MA-PACKET.cfm fails with status as Tx-retry-limit or No-BSS and then just return failure
484 * to clear the hip slot associated with the Packet
486 if (CSR_TX_RETRY_LIMIT == txStatus || CSR_TX_NO_BSS == txStatus) {
487 if (staRecord->timSet == CSR_WIFI_TIM_RESET || staRecord->timSet == CSR_WIFI_TIM_RESETTING)
489 unifi_trace(priv, UDBG2, "unifi_reque_ma_packet_request: CFM failed with Retry Limit or No BSS-->update TIM\n");
490 if (!staRecord->timRequestPendingFlag) {
491 update_tim(priv, staRecord->aid, 1, interfaceTag, staRecord->assignedHandle);
494 /* Cache the TimSet value so that it will processed immidiatly after
495 * completing the current setTim Request
497 staRecord->updateTimReqQueued = 1;
498 unifi_trace(priv, UDBG6, "unifi_reque_ma_packet_request: One more UpdateTim Request(:%d)Queued for AID %x\n",
499 staRecord->updateTimReqQueued, staRecord->aid);
502 return CSR_RESULT_FAILURE;
504 else if ((CSR_TX_LIFETIME == txStatus) || (CSR_TX_BLOCK_ACK_TIMEOUT == txStatus) ||
505 (CSR_TX_FAIL_TRANSMISSION_VIF_INTERRUPTED == txStatus) ||
506 (CSR_TX_REJECTED_PEER_STATION_SLEEPING == txStatus) ||
507 (CSR_TX_REJECTED_DTIM_STARTED == txStatus)) {
508 /* Extract the Frame control and the frame type */
509 frameControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(bulkDataDesc->os_data_ptr);
510 frameType = ((frameControl & IEEE80211_FC_TYPE_MASK) >> FRAME_CONTROL_TYPE_FIELD_OFFSET);
512 /* Mgmt frames will not be re-queued for Tx
513 * so just return failure to clear the hip slot
515 if (IEEE802_11_FRAMETYPE_MANAGEMENT == frameType) {
516 return CSR_RESULT_FAILURE;
518 else if (IEEE802_11_FRAMETYPE_DATA == frameType) {
519 /* QOS NULL and DATA NULL frames will not be re-queued for Tx
520 * so just return failure to clear the hip slot
522 if ((((frameControl & IEEE80211_FC_SUBTYPE_MASK) >> FRAME_CONTROL_SUBTYPE_FIELD_OFFSET) == QOS_DATA_NULL) ||
523 (((frameControl & IEEE80211_FC_SUBTYPE_MASK) >> FRAME_CONTROL_SUBTYPE_FIELD_OFFSET)== DATA_NULL )) {
524 return CSR_RESULT_FAILURE;
528 /* Extract the Packet priority */
529 if (TRUE == staRecord->wmmOrQosEnabled) {
531 u8 dataFrameType = 0;
533 dataFrameType =((frameControl & IEEE80211_FC_SUBTYPE_MASK) >> 4);
535 if (dataFrameType == QOS_DATA) {
536 /* QoS control field is offset from frame control by 2 (frame control)
537 * + 2 (duration/ID) + 2 (sequence control) + 3*ETH_ALEN or 4*ETH_ALEN
539 if((frameControl & IEEE802_11_FC_TO_DS_MASK) && (frameControl & IEEE802_11_FC_FROM_DS_MASK)) {
540 qosControl= CSR_GET_UINT16_FROM_LITTLE_ENDIAN(bulkDataDesc->os_data_ptr + 30);
543 qosControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(bulkDataDesc->os_data_ptr + 24);
547 priority = (CSR_PRIORITY)(qosControl & IEEE802_11_QC_TID_MASK);
549 if (priority < CSR_QOS_UP0 || priority > CSR_QOS_UP7) {
550 unifi_trace(priv, UDBG5, "unifi_reque_ma_packet_request: Invalid priority:%x \n", priority);
551 return CSR_RESULT_FAILURE;
555 priority = CSR_CONTENTION;
558 /* Frame Bulk data to requeue it back to HAL Queues */
559 bulkData.d[0].os_data_ptr = bulkDataDesc->os_data_ptr;
560 bulkData.d[0].data_length = bulkDataDesc->data_length;
561 bulkData.d[0].os_net_buf_ptr = bulkDataDesc->os_net_buf_ptr;
562 bulkData.d[0].net_buf_length = bulkDataDesc->net_buf_length;
564 bulkData.d[1].os_data_ptr = NULL;
565 bulkData.d[1].os_net_buf_ptr = NULL;
566 bulkData.d[1].data_length = bulkData.d[1].net_buf_length = 0;
568 /* Initialize signal to zero */
569 memset(&signal, 0, sizeof(CSR_SIGNAL));
571 /* Frame MA Packet Req */
572 unifi_frame_ma_packet_req(priv, priority, 0, host_tag,
573 interfaceTag, CSR_NO_CONFIRM_REQUIRED,
574 priv->netdev_client->sender_id,
575 staRecord->peerMacAddress.a, &signal);
577 /* Find the Q-Priority */
578 priority_q = unifi_frame_priority_to_queue(priority);
579 list = &staRecord->dataPdu[priority_q];
581 /* Place the Packet on to HAL Queue */
582 status = enque_tx_data_pdu(priv, &bulkData, list, &signal, TRUE);
584 /* Update the Per-station queued packet counter */
586 spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
587 staRecord->noOfPktQueued++;
588 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
592 /* Packet will not be re-queued for any of the other MA Packet Tx failure
593 * reasons so just return failure to clear the hip slot
595 return CSR_RESULT_FAILURE;
602 static void is_all_ac_deliver_enabled_and_moredata(CsrWifiRouterCtrlStaInfo_t *staRecord, u8 *allDeliveryEnabled, u8 *dataAvailable)
605 *allDeliveryEnabled = TRUE;
606 for (i = 0 ;i < MAX_ACCESS_CATOGORY; i++) {
607 if (!IS_DELIVERY_ENABLED(staRecord->powersaveMode[i])) {
608 /* One is is not Delivery Enabled */
609 *allDeliveryEnabled = FALSE;
613 if (*allDeliveryEnabled) {
614 *dataAvailable = (!list_empty(&staRecord->dataPdu[0]) || !list_empty(&staRecord->dataPdu[1])
615 ||!list_empty(&staRecord->dataPdu[2]) ||!list_empty(&staRecord->dataPdu[3])
616 ||!list_empty(&staRecord->mgtFrames));
621 * ---------------------------------------------------------------------------
625 * This function updates tim status in host depending confirm status from firmware
628 * priv Pointer to device private context struct
629 * cfm CSR_MLME_SET_TIM_CONFIRM
630 * receiverProcessId SenderProcessID to fetch handle & timSet status
632 * ---------------------------------------------------------------------------
634 void uf_handle_tim_cfm(unifi_priv_t *priv, CSR_MLME_SET_TIM_CONFIRM *cfm, u16 receiverProcessId)
636 u8 handle = CSR_WIFI_GET_STATION_HANDLE_FROM_RECEIVER_ID(receiverProcessId);
637 u8 timSetStatus = CSR_WIFI_GET_TIMSET_STATE_FROM_RECEIVER_ID(receiverProcessId);
638 u16 interfaceTag = (cfm->VirtualInterfaceIdentifier & 0xff);
639 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
640 CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
641 /* This variable holds what TIM value we wanted to set in firmware */
643 /* Irrespective of interface the count maintained */
644 static u8 retryCount = 0;
645 unsigned long lock_flags;
646 unifi_trace(priv, UDBG3, "entering %s, handle = %x, timSetStatus = %x\n", __FUNCTION__, handle, timSetStatus);
648 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
649 unifi_warning(priv, "bad interfaceTag = %x\n", interfaceTag);
653 if ((handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) && (handle >= UNIFI_MAX_CONNECTIONS)) {
654 unifi_warning(priv, "bad station Handle = %x\n", handle);
658 if (handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) {
659 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
660 if ((staRecord = ((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[handle]))) == NULL) {
661 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
662 unifi_warning(priv, "uf_handle_tim_cfm: station record is NULL handle = %x\n", handle);
665 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
669 case CSR_WIFI_TIM_SETTING:
670 timSetValue = CSR_WIFI_TIM_SET;
672 case CSR_WIFI_TIM_RESETTING:
673 timSetValue = CSR_WIFI_TIM_RESET;
676 unifi_warning(priv, "timSet state is %x: Debug\n", timSetStatus);
680 /* check TIM confirm for success/failures */
681 switch(cfm->ResultCode)
684 if (handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) {
685 /* Unicast frame & station record available */
686 if (timSetStatus == staRecord->timSet) {
687 staRecord->timSet = timSetValue;
688 /* fh_cmd_q can also be full at some point of time!,
689 * resetting count as queue is cleaned by firmware at this point
692 unifi_trace(priv, UDBG2, "tim (%s) successfully in firmware\n", (timSetValue)?"SET":"RESET");
694 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",
695 receiverProcessId, timSetStatus, staRecord->timSet, handle);
698 /* Reset TIM pending flag to send next TIM request */
699 staRecord->timRequestPendingFlag = FALSE;
701 /* Make sure that one more UpdateTim request is queued, if Queued its value
702 * should be CSR_WIFI_TIM_SET or CSR_WIFI_TIM_RESET
704 if (0xFF != staRecord->updateTimReqQueued)
706 /* Process the UpdateTim Request which is queued while previous UpdateTim was in progress */
707 if (staRecord->timSet != staRecord->updateTimReqQueued)
709 unifi_trace(priv, UDBG2, "uf_handle_tim_cfm : Processing Queued UpdateTimReq \n");
711 update_tim(priv, staRecord->aid, staRecord->updateTimReqQueued, interfaceTag, handle);
713 staRecord->updateTimReqQueued = 0xFF;
718 interfacePriv->bcTimSet = timSetValue;
719 /* fh_cmd_q can also be full at some point of time!,
720 * resetting count as queue is cleaned by firmware at this point
723 unifi_trace(priv, UDBG3, "tim (%s) successfully for broadcast frame in firmware\n", (timSetValue)?"SET":"RESET");
725 /* Reset DTIM pending flag to send next DTIM request */
726 interfacePriv->bcTimSetReqPendingFlag = FALSE;
728 /* Make sure that one more UpdateDTim request is queued, if Queued its value
729 * should be CSR_WIFI_TIM_SET or CSR_WIFI_TIM_RESET
731 if (0xFF != interfacePriv->bcTimSetReqQueued)
733 /* Process the UpdateTim Request which is queued while previous UpdateTim was in progress */
734 if (interfacePriv->bcTimSet != interfacePriv->bcTimSetReqQueued)
736 unifi_trace(priv, UDBG2, "uf_handle_tim_cfm : Processing Queued UpdateDTimReq \n");
738 update_tim(priv, 0, interfacePriv->bcTimSetReqQueued, interfaceTag, 0xFFFFFFFF);
740 interfacePriv->bcTimSetReqQueued = 0xFF;
746 case CSR_RC_INVALID_PARAMETERS:
747 case CSR_RC_INSUFFICIENT_RESOURCE:
748 /* check for max retry limit & send again
749 * MAX_RETRY_LIMIT is not maintained for each set of transactions..Its generic
750 * If failure crosses this Limit, we have to take a call to FIX
752 if (retryCount > UNIFI_MAX_RETRY_LIMIT) {
755 /* Because of continuos traffic in fh_cmd_q the tim set request is failing (exceeding retry limit)
756 * but if we didn't synchronize our timSet varible state with firmware then it can cause below issues
757 * cond 1. We want to SET tim in firmware if its fails & max retry limit reached
758 * -> If host set's the timSet to 1, we wont try to send(as max retry reached) update tim but
759 * firmware is not updated with queue(TIM) status so it wont set TIM in beacon finally host start piling
760 * up data & wont try to set tim in firmware (This can cause worser performance)
761 * cond 2. We want to reset tim in firmware it fails & reaches max retry limit
762 * -> If host sets the timSet to Zero, it wont try to set a TIM request unless we wont have any packets
763 * to be queued, so beacon unnecessarily advertizes the TIM
767 if(!staRecord->wmmOrQosEnabled) {
768 moreData = (!list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]) ||
769 !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]) ||
770 !list_empty(&staRecord->mgtFrames));
773 u8 allDeliveryEnabled = 0, dataAvailable = 0;
774 /* Check if all AC's are Delivery Enabled */
775 is_all_ac_deliver_enabled_and_moredata(staRecord, &allDeliveryEnabled, &dataAvailable);
776 /*check for more data in non-delivery enabled queues*/
777 moreData = (uf_is_more_data_for_non_delivery_ac(staRecord) || (allDeliveryEnabled && dataAvailable));
780 /* To avoid cond 1 & 2, check internal Queues status, if we have more Data then set RESET the timSet(0),
781 * so we are trying to be in sync with firmware & next packets before queuing atleast try to
782 * set TIM in firmware otherwise it SET timSet(1)
785 staRecord->timSet = CSR_WIFI_TIM_RESET;
787 staRecord->timSet = CSR_WIFI_TIM_SET;
790 /* Its a broadcast frames */
791 moreData = (!list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames) ||
792 !list_empty(&interfacePriv->genericMulticastOrBroadCastFrames));
794 update_tim(priv, 0, CSR_WIFI_TIM_SET, interfaceTag, 0xFFFFFFFF);
796 update_tim(priv, 0, CSR_WIFI_TIM_RESET, interfaceTag, 0xFFFFFFFF);
800 unifi_error(priv, "no of error's for TIM setting crossed the Limit: verify\n");
805 if (handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) {
806 if (timSetStatus == staRecord->timSet) {
807 unifi_warning(priv, "tim request failed, retry for AID = %x\n", staRecord->aid);
808 update_tim(priv, staRecord->aid, timSetValue, interfaceTag, handle);
810 unifi_trace(priv, UDBG1, "failure: request & confirm states are not matching in TIM cfm: Debug status = %x, staRecord->timSet = %x\n",
811 timSetStatus, staRecord->timSet);
814 unifi_warning(priv, "tim request failed, retry for broadcast frames\n");
815 update_tim(priv, 0, timSetValue, interfaceTag, 0xFFFFFFFF);
819 unifi_warning(priv, "tim update request failed resultcode = %x\n", cfm->ResultCode);
822 unifi_trace(priv, UDBG2, "leaving %s\n", __FUNCTION__);
826 * ---------------------------------------------------------------------------
830 * This function updates tim status in firmware for AID[1 to UNIFI_MAX_CONNECTIONS] or
831 * AID[0] for broadcast/multicast packets.
833 * NOTE: The LSB (least significant BYTE) of senderId while sending this MLME premitive
834 * has been modified(utilized) as below
836 * SenderID in signal's SignalPrimitiveHeader is 2 byte the lowe byte bitmap is below
838 * station handle(6 bits) timSet Status (2 bits)
839 * --------------------- ----------------------
842 * timSet Status can be one of below:
845 * CSR_WIFI_TIM_RESETTING
847 * CSR_WIFI_TIM_SETTING
850 * priv Pointer to device private context struct
851 * aid can be 1 t0 UNIFI_MAX_CONNECTIONS & 0 means multicast/broadcast
852 * setTim value SET(1) / RESET(0)
853 * interfaceTag the interfaceID on which activity going on
854 * handle from (0 <= handle < UNIFI_MAX_CONNECTIONS)
856 * ---------------------------------------------------------------------------
858 void update_tim(unifi_priv_t * priv, u16 aid, u8 setTim, u16 interfaceTag, u32 handle)
862 CSR_MLME_SET_TIM_REQUEST *req = &signal.u.MlmeSetTimRequest;
863 bulk_data_param_t *bulkdata = NULL;
864 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
866 CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
867 u32 oldTimSetStatus = 0, timSetStatus = 0;
869 unifi_trace(priv, UDBG5, "entering the update_tim routine\n");
872 if (handle == 0xFFFFFFFF) {
873 handle &= CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE;
874 if (setTim == interfacePriv->bcTimSet)
876 unifi_trace(priv, UDBG3, "update_tim, Drop:Hdl=%x, timval=%d, globalTim=%d\n", handle, setTim, interfacePriv->bcTimSet);
879 } else if ((handle != 0xFFFFFFFF) && (handle >= UNIFI_MAX_CONNECTIONS)) {
880 unifi_warning(priv, "bad station Handle = %x\n", handle);
885 timSetStatus = CSR_WIFI_TIM_SETTING;
887 timSetStatus = CSR_WIFI_TIM_RESETTING;
890 if (handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) {
891 if ((staRecord = ((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[handle]))) == NULL) {
892 unifi_warning(priv, "station record is NULL in update_tim: handle = %x :debug\n", handle);
895 /* In case of signal sending failed, revert back to old state */
896 oldTimSetStatus = staRecord->timSet;
897 staRecord->timSet = timSetStatus;
900 /* pack senderID LSB */
901 senderIdLsb = CSR_WIFI_PACK_SENDER_ID_LSB_FOR_TIM_REQ(handle, timSetStatus);
903 /* initialize signal to zero */
904 memset(&signal, 0, sizeof(CSR_SIGNAL));
906 /* Frame the MLME-SET-TIM request */
907 signal.SignalPrimitiveHeader.SignalId = CSR_MLME_SET_TIM_REQUEST_ID;
908 signal.SignalPrimitiveHeader.ReceiverProcessId = 0;
909 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(((priv->netdev_client->sender_id & 0xff00) | senderIdLsb),
910 (u8*)&signal.SignalPrimitiveHeader.SenderProcessId);
912 /* set The virtual interfaceIdentifier, aid, tim value */
913 req->VirtualInterfaceIdentifier = uf_get_vif_identifier(interfacePriv->interfaceMode,interfaceTag);
914 req->AssociationId = aid;
915 req->TimValue = setTim;
918 unifi_trace(priv, UDBG2, "update_tim:AID %x,senderIdLsb = 0x%x, handle = 0x%x, timSetStatus = %x, sender proceesID = %x \n",
919 aid,senderIdLsb, handle, timSetStatus, signal.SignalPrimitiveHeader.SenderProcessId);
921 /* Send the signal to UniFi */
922 r = ul_send_signal_unpacked(priv, &signal, bulkdata);
924 /* No need to free bulk data, as TIM request doesn't carries any data */
925 unifi_error(priv, "Error queueing CSR_MLME_SET_TIM_REQUEST signal\n");
927 staRecord->timSet = oldTimSetStatus ;
931 /* MLME_SET_TIM.req sending failed here for AID0, so revert back our bcTimSet status */
932 interfacePriv->bcTimSet = !setTim;
936 /* Update tim request pending flag and ensure no more TIM set requests are send
937 for the same station until TIM confirm is received */
939 staRecord->timRequestPendingFlag = TRUE;
943 /* Update tim request (for AID 0) pending flag and ensure no more DTIM set requests are send
944 * for the same station until TIM confirm is received
946 interfacePriv->bcTimSetReqPendingFlag = TRUE;
949 unifi_trace(priv, UDBG5, "leaving the update_tim routine\n");
953 void process_peer_active_transition(unifi_priv_t * priv,
954 CsrWifiRouterCtrlStaInfo_t *staRecord,
958 u8 spaceAvail[4] = {TRUE,TRUE,TRUE,TRUE};
959 tx_buffered_packets_t * buffered_pkt = NULL;
960 unsigned long lock_flags;
961 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
963 unifi_trace(priv, UDBG5, "entering process_peer_active_transition\n");
965 if(IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag)) {
966 /* giving more priority to multicast packets so delaying unicast packets*/
967 unifi_trace(priv,UDBG2, "Multicast transmission is going on so resume unicast transmission after DTIM over\n");
969 /* As station is active now, even though AP is not able to send frames to it
970 * because of DTIM, it needs to reset the TIM here
972 if (!staRecord->timRequestPendingFlag){
973 if((staRecord->timSet == CSR_WIFI_TIM_SET) || (staRecord->timSet == CSR_WIFI_TIM_SETTING)){
974 update_tim(priv, staRecord->aid, 0, interfaceTag, staRecord->assignedHandle);
979 /* Cache the TimSet value so that it will processed immidiatly after
980 * completing the current setTim Request
982 staRecord->updateTimReqQueued = 0;
983 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
988 while((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->mgtFrames))) {
989 buffered_pkt->transmissionControl &=
990 ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
991 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staRecord,0,FALSE)) == -ENOSPC) {
992 unifi_trace(priv, UDBG2, "p_p_a_t:(ENOSPC) Mgt Frame queueing \n");
993 /* Enqueue at the head of the queue */
994 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
995 list_add(&buffered_pkt->q, &staRecord->mgtFrames);
996 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
997 priv->pausedStaHandle[3]=(u8)(staRecord->assignedHandle);
998 spaceAvail[3] = FALSE;
1002 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
1003 /* the PDU failed where we can't do any thing so free the storage */
1004 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
1006 kfree(buffered_pkt);
1009 if (!staRecord->timRequestPendingFlag) {
1010 if (staRecord->txSuspend) {
1011 if(staRecord->timSet == CSR_WIFI_TIM_SET) {
1012 update_tim(priv,staRecord->aid,0,interfaceTag, staRecord->assignedHandle);
1019 /* Cache the TimSet value so that it will processed immidiatly after
1020 * completing the current setTim Request
1022 staRecord->updateTimReqQueued = 0;
1023 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
1029 unifi_trace(priv, UDBG6, "p_p_a_t:data pkt sending for AC %d \n",i);
1030 while((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->dataPdu[i]))) {
1031 buffered_pkt->transmissionControl &=
1032 ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
1033 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staRecord,0,FALSE)) == -ENOSPC) {
1034 /* Clear the trigger bit transmission control*/
1035 /* Enqueue at the head of the queue */
1036 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
1037 list_add(&buffered_pkt->q, &staRecord->dataPdu[i]);
1038 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
1039 priv->pausedStaHandle[i]=(u8)(staRecord->assignedHandle);
1043 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
1044 /* the PDU failed where we can't do any thing so free the storage */
1045 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
1047 kfree(buffered_pkt);
1051 if (!staRecord->timRequestPendingFlag){
1052 if((staRecord->timSet == CSR_WIFI_TIM_SET) || (staRecord->timSet == CSR_WIFI_TIM_SETTING)) {
1053 unifi_trace(priv, UDBG3, "p_p_a_t:resetting tim .....\n");
1054 update_tim(priv,staRecord->aid,0,interfaceTag, staRecord->assignedHandle);
1059 /* Cache the TimSet value so that it will processed immidiatly after
1060 * completing the current setTim Request
1062 staRecord->updateTimReqQueued = 0;
1063 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
1066 unifi_trace(priv, UDBG5, "leaving process_peer_active_transition\n");
1071 void uf_process_ma_pkt_cfm_for_ap(unifi_priv_t *priv,u16 interfaceTag, const CSR_MA_PACKET_CONFIRM *pkt_cfm)
1073 netInterface_priv_t *interfacePriv;
1075 CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
1076 interfacePriv = priv->interfacePriv[interfaceTag];
1079 if(pkt_cfm->HostTag == interfacePriv->multicastPduHostTag) {
1080 unifi_trace(priv,UDBG2,"CFM for marked Multicast Tag = %x\n",interfacePriv->multicastPduHostTag);
1081 interfacePriv->multicastPduHostTag = 0xffffffff;
1082 resume_suspended_uapsd(priv,interfaceTag);
1083 resume_unicast_buffered_frames(priv,interfaceTag);
1084 if(list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames) &&
1085 list_empty(&interfacePriv->genericMulticastOrBroadCastFrames)) {
1086 unifi_trace(priv,UDBG1,"Resetting multicastTIM");
1087 if (!interfacePriv->bcTimSetReqPendingFlag)
1089 update_tim(priv,0,CSR_WIFI_TIM_RESET,interfaceTag, 0xFFFFFFFF);
1093 /* Cache the DTimSet value so that it will processed immidiatly after
1094 * completing the current setDTim Request
1096 interfacePriv->bcTimSetReqQueued = CSR_WIFI_TIM_RESET;
1097 unifi_trace(priv, UDBG2, "uf_process_ma_pkt_cfm_for_ap : One more UpdateDTim Request(%d) Queued \n",
1098 interfacePriv->bcTimSetReqQueued);
1105 /* Check if it is a Confirm for null data frame used
1106 * for probing station activity
1108 for(i =0; i < UNIFI_MAX_CONNECTIONS; i++) {
1109 staRecord = (CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[i]);
1110 if (staRecord && (staRecord->nullDataHostTag == pkt_cfm->HostTag)) {
1112 unifi_trace(priv, UDBG1, "CFM for Inactive probe Null frame (tag = %x, status = %d)\n",
1114 pkt_cfm->TransmissionStatus
1116 staRecord->nullDataHostTag = INVALID_HOST_TAG;
1118 if(pkt_cfm->TransmissionStatus == CSR_TX_RETRY_LIMIT){
1122 unifi_trace(priv, UDBG1, "Nulldata to probe STA ALIVE Failed with retry limit\n");
1123 /* Recheck if there is some activity after null data is sent.
1125 * If still there is no activity then send a disconnected indication
1126 * to SME to delete the station record.
1128 if (staRecord->activity_flag){
1131 now = CsrTimeGet(NULL);
1133 if (staRecord->lastActivity > now)
1135 /* simple timer wrap (for 1 wrap) */
1136 inactive_time = CsrTimeAdd((u32)CsrTimeSub(CSR_SCHED_TIME_MAX, staRecord->lastActivity),
1141 inactive_time = (u32)CsrTimeSub(now, staRecord->lastActivity);
1144 if (inactive_time >= STA_INACTIVE_TIMEOUT_VAL)
1146 struct list_head send_cfm_list;
1149 /* The SME/NME may be waiting for confirmation for requested frames to this station.
1150 * Though this is --VERY UNLIKELY-- in case of station in active mode. But still as a
1151 * a defensive check, it loops through buffered frames for this station and if confirmation
1152 * is requested, send auto confirmation with failure status. Also flush the frames so
1153 * that these are not processed again in PEER_DEL_REQ handler.
1155 INIT_LIST_HEAD(&send_cfm_list);
1157 uf_prepare_send_cfm_list_for_queued_pkts(priv,
1159 &(staRecord->mgtFrames));
1161 uf_flush_list(priv, &(staRecord->mgtFrames));
1163 for(j = 0; j < MAX_ACCESS_CATOGORY; j++){
1164 uf_prepare_send_cfm_list_for_queued_pkts(priv,
1166 &(staRecord->dataPdu[j]));
1168 uf_flush_list(priv,&(staRecord->dataPdu[j]));
1171 send_auto_ma_packet_confirm(priv, staRecord->interfacePriv, &send_cfm_list);
1175 unifi_warning(priv, "uf_process_ma_pkt_cfm_for_ap: Router Disconnected IND Peer (%x-%x-%x-%x-%x-%x)\n",
1176 staRecord->peerMacAddress.a[0],
1177 staRecord->peerMacAddress.a[1],
1178 staRecord->peerMacAddress.a[2],
1179 staRecord->peerMacAddress.a[3],
1180 staRecord->peerMacAddress.a[4],
1181 staRecord->peerMacAddress.a[5]);
1183 CsrWifiRouterCtrlConnectedIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,
1185 staRecord->interfacePriv->InterfaceTag,
1186 staRecord->peerMacAddress,
1187 CSR_WIFI_ROUTER_CTRL_PEER_DISCONNECTED);
1191 else if (pkt_cfm->TransmissionStatus == CSR_TX_SUCCESSFUL)
1193 staRecord->activity_flag = TRUE;
1200 u16 uf_get_vif_identifier (CsrWifiRouterCtrlMode mode, u16 tag)
1204 case CSR_WIFI_ROUTER_CTRL_MODE_STA:
1205 case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
1206 return (0x02<<8|tag);
1208 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
1209 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
1210 return (0x03<<8|tag);
1212 case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
1213 return (0x01<<8|tag);
1215 case CSR_WIFI_ROUTER_CTRL_MODE_MONITOR:
1216 return (0x04<<8|tag);
1217 case CSR_WIFI_ROUTER_CTRL_MODE_AMP:
1218 return (0x05<<8|tag);
1224 #ifdef CSR_SUPPORT_SME
1227 * ---------------------------------------------------------------------------
1231 * These functions updates mac header for intra BSS packet
1233 * NOTE: This function always has to be called in rx context which
1234 * is in bh thread context since GFP_KERNEL is used. In soft IRQ/ Interrupt
1235 * context shouldn't be used
1238 * priv Pointer to device private context struct
1239 * skb Socket buffer containing data packet to transmit
1240 * newSkb Socket buffer containing data packet + Mac header if no sufficient headroom in skb
1241 * priority to append QOS control header in Mac header
1242 * bulkdata if newSkb allocated then bulkdata updated to send to unifi
1243 * interfaceTag the interfaceID on which activity going on
1244 * macHeaderLengthInBytes no. of bytes of mac header in received frame
1245 * qosDestination used to append Qos control field
1248 * Zero on success or -1 on error.
1249 * ---------------------------------------------------------------------------
1252 static int update_macheader(unifi_priv_t *priv, struct sk_buff *skb,
1253 struct sk_buff *newSkb, CSR_PRIORITY *priority,
1254 bulk_data_param_t *bulkdata, u16 interfaceTag,
1255 u8 macHeaderLengthInBytes,
1260 u8 direction = 0, toDs, fromDs;
1262 u8 sa[ETH_ALEN], da[ETH_ALEN];
1263 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
1265 u8 macHeaderBuf[IEEE802_11_DATA_FRAME_MAC_HEADER_SIZE] = {0};
1267 unifi_trace(priv, UDBG5, "entering the update_macheader function\n");
1269 /* temporary buffer for the Mac header storage */
1270 memcpy(macHeaderBuf, skb->data, macHeaderLengthInBytes);
1272 /* remove the Macheader from the skb */
1273 skb_pull(skb, macHeaderLengthInBytes);
1275 /* get the skb headroom for skb_push check */
1276 headroom = skb_headroom(skb);
1278 /* pointer to frame control field */
1279 fc = (u16*) macHeaderBuf;
1281 toDs = (*fc & cpu_to_le16(IEEE802_11_FC_TO_DS_MASK))?1 : 0;
1282 fromDs = (*fc & cpu_to_le16(IEEE802_11_FC_FROM_DS_MASK))? 1: 0;
1283 unifi_trace(priv, UDBG5, "In update_macheader function, fromDs = %x, toDs = %x\n", fromDs, toDs);
1284 direction = ((fromDs | (toDs << 1)) & 0x3);
1286 /* Address1 or 3 from the macheader */
1287 memcpy(da, macHeaderBuf+4+toDs*12, ETH_ALEN);
1288 /* Address2, 3 or 4 from the mac header */
1289 memcpy(sa, macHeaderBuf+10+fromDs*(6+toDs*8), ETH_ALEN);
1291 unifi_trace(priv, UDBG3, "update_macheader:direction = %x\n", direction);
1292 /* update the toDs, fromDs & address fields in Mac header */
1296 /* toDs = 1 & fromDs = 0 , toAp when frames received from peer
1297 * while sending this packet to Destination the Mac header changed
1298 * as fromDs = 1 & toDs = 0, fromAp
1300 *fc &= cpu_to_le16(~IEEE802_11_FC_TO_DS_MASK);
1301 *fc |= cpu_to_le16(IEEE802_11_FC_FROM_DS_MASK);
1302 /* Address1: MAC address of the actual destination (4 = 2+2) */
1303 memcpy(macHeaderBuf + 4, da, ETH_ALEN);
1304 /* Address2: The MAC address of the AP (10 = 2+2+6) */
1305 memcpy(macHeaderBuf + 10, &interfacePriv->bssid, ETH_ALEN);
1306 /* Address3: MAC address of the actual source from mac header (16 = 2+2+6+6) */
1307 memcpy(macHeaderBuf + 16, sa, ETH_ALEN);
1310 unifi_trace(priv, UDBG3, "when both the toDs & fromDS set, NOT SUPPORTED\n");
1313 unifi_trace(priv, UDBG3, "problem in decoding packet in update_macheader \n");
1317 /* frameType is Data always, Validation is done before calling this function */
1319 /* check for the souce station type */
1320 switch(le16_to_cpu(*fc) & IEEE80211_FC_SUBTYPE_MASK)
1322 case IEEE802_11_FC_TYPE_QOS_DATA & IEEE80211_FC_SUBTYPE_MASK:
1323 /* No need to modify the qos control field */
1324 if (!qosDestination) {
1326 /* If source Sta is QOS enabled & if this bit set, then HTC is supported by
1327 * peer station & htc field present in macHeader
1329 if (*fc & cpu_to_le16(IEEE80211_FC_ORDER_MASK)) {
1330 /* HT control field present in Mac header
1331 * 6 = sizeof(qosControl) + sizeof(htc)
1333 macHeaderLengthInBytes -= 6;
1335 macHeaderLengthInBytes -= 2;
1337 /* Destination STA is non qos so change subtype to DATA */
1338 *fc &= cpu_to_le16(~IEEE80211_FC_SUBTYPE_MASK);
1339 *fc |= cpu_to_le16(IEEE802_11_FC_TYPE_DATA);
1340 /* remove the qos control field & HTC(if present). new macHeaderLengthInBytes is less than old
1341 * macHeaderLengthInBytes so no need to verify skb headroom
1343 if (headroom < macHeaderLengthInBytes) {
1344 unifi_trace(priv, UDBG1, " sufficient headroom not there to push updated mac header \n");
1347 bufPtr = (u8 *) skb_push(skb, macHeaderLengthInBytes);
1349 /* update bulk data os_data_ptr */
1350 bulkdata->d[0].os_data_ptr = skb->data;
1351 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skb;
1352 bulkdata->d[0].data_length = skb->len;
1355 /* pointing to QOS control field */
1357 if (*fc & cpu_to_le16(IEEE80211_FC_ORDER_MASK)) {
1358 qc = *((u8*)(macHeaderBuf + (macHeaderLengthInBytes - 4 - 2)));
1360 qc = *((u8*)(macHeaderBuf + (macHeaderLengthInBytes - 2)));
1363 if ((qc & IEEE802_11_QC_TID_MASK) > 7) {
1366 *priority = qc & IEEE802_11_QC_TID_MASK;
1369 unifi_trace(priv, UDBG1, "Incoming packet priority from QSTA is %x\n", *priority);
1371 if (headroom < macHeaderLengthInBytes) {
1372 unifi_trace(priv, UDBG3, " sufficient headroom not there to push updated mac header \n");
1375 bufPtr = (u8 *) skb_push(skb, macHeaderLengthInBytes);
1380 bulk_data_param_t data_ptrs;
1381 CsrResult csrResult;
1382 unifi_trace(priv, UDBG5, "normal Data packet, NO QOS \n");
1384 if (qosDestination) {
1386 unifi_trace(priv, UDBG3, "destination is QOS station \n");
1388 /* Set Ma-Packet.req UP to UP0 */
1389 *priority = CSR_QOS_UP0;
1391 /* prepare the qos control field */
1393 /* no Amsdu is in ap buffer so eosp is left 0 */
1395 /* multicast/broadcast frames, no acknowledgement needed */
1399 /* update new Mac header Length with 2 = sizeof(qos control) */
1400 macHeaderLengthInBytes += 2;
1402 /* received DATA frame but destiantion is QOS station so update subtype to QOS*/
1403 *fc &= cpu_to_le16(~IEEE80211_FC_SUBTYPE_MASK);
1404 *fc |= cpu_to_le16(IEEE802_11_FC_TYPE_QOS_DATA);
1406 /* appendQosControlOffset = macHeaderLengthInBytes - 2, since source sta is not QOS */
1407 macHeaderBuf[macHeaderLengthInBytes - 2] = qc;
1408 /* txopLimit is 0 */
1409 macHeaderBuf[macHeaderLengthInBytes - 1] = 0;
1410 if (headroom < macHeaderLengthInBytes) {
1411 csrResult = unifi_net_data_malloc(priv, &data_ptrs.d[0], skb->len + macHeaderLengthInBytes);
1413 if (csrResult != CSR_RESULT_SUCCESS) {
1414 unifi_error(priv, " failed to allocate request_data. in update_macheader func\n");
1417 newSkb = (struct sk_buff *)(data_ptrs.d[0].os_net_buf_ptr);
1418 newSkb->len = skb->len + macHeaderLengthInBytes;
1420 memcpy((void*)data_ptrs.d[0].os_data_ptr + macHeaderLengthInBytes,
1421 skb->data, skb->len);
1423 bulkdata->d[0].os_data_ptr = newSkb->data;
1424 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)newSkb;
1425 bulkdata->d[0].data_length = newSkb->len;
1427 bufPtr = (u8*)data_ptrs.d[0].os_data_ptr;
1429 /* The old skb will not be used again */
1432 /* skb headroom is sufficient to append Macheader */
1433 bufPtr = (u8*)skb_push(skb, macHeaderLengthInBytes);
1434 bulkdata->d[0].os_data_ptr = skb->data;
1435 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skb;
1436 bulkdata->d[0].data_length = skb->len;
1439 unifi_trace(priv, UDBG3, "destination is not a QSTA\n");
1440 if (headroom < macHeaderLengthInBytes) {
1441 csrResult = unifi_net_data_malloc(priv, &data_ptrs.d[0], skb->len + macHeaderLengthInBytes);
1443 if (csrResult != CSR_RESULT_SUCCESS) {
1444 unifi_error(priv, " failed to allocate request_data. in update_macheader func\n");
1447 newSkb = (struct sk_buff *)(data_ptrs.d[0].os_net_buf_ptr);
1448 newSkb->len = skb->len + macHeaderLengthInBytes;
1450 memcpy((void*)data_ptrs.d[0].os_data_ptr + macHeaderLengthInBytes,
1451 skb->data, skb->len);
1453 bulkdata->d[0].os_data_ptr = newSkb->data;
1454 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)newSkb;
1455 bulkdata->d[0].data_length = newSkb->len;
1457 bufPtr = (u8*)data_ptrs.d[0].os_data_ptr;
1459 /* The old skb will not be used again */
1462 /* skb headroom is sufficient to append Macheader */
1463 bufPtr = (u8*)skb_push(skb, macHeaderLengthInBytes);
1464 bulkdata->d[0].os_data_ptr = skb->data;
1465 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skb;
1466 bulkdata->d[0].data_length = skb->len;
1472 /* prepare the complete skb, by pushing the MAC header to the begining of the skb->data */
1473 unifi_trace(priv, UDBG5, "updated Mac Header: %d \n",macHeaderLengthInBytes);
1474 memcpy(bufPtr, macHeaderBuf, macHeaderLengthInBytes);
1476 unifi_trace(priv, UDBG5, "leaving the update_macheader function\n");
1480 * ---------------------------------------------------------------------------
1481 * uf_ap_process_data_pdu
1484 * Takes care of intra BSS admission control & routing packets within BSS
1487 * priv Pointer to device private context struct
1488 * skb Socket buffer containing data packet to transmit
1489 * ehdr ethernet header to fetch priority of packet
1490 * srcStaInfo source stations record for connection verification
1493 * signal MA-PACKET.indication signal
1494 * bulkdata if newSkb allocated then bulkdata updated to send to unifi
1495 * macHeaderLengthInBytes no. of bytes of mac header in received frame
1498 * Zero on success(ap processing complete) or -1 if packet also have to be sent to NETDEV.
1499 * ---------------------------------------------------------------------------
1502 uf_ap_process_data_pdu(unifi_priv_t *priv, struct sk_buff *skb,
1503 struct ethhdr *ehdr, CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
1504 const CSR_SIGNAL *signal,
1505 bulk_data_param_t *bulkdata,
1506 u8 macHeaderLengthInBytes)
1508 const CSR_MA_PACKET_INDICATION *ind = &(signal->u.MaPacketIndication);
1509 u16 interfaceTag = (ind->VirtualInterfaceIdentifier & 0x00ff);
1510 struct sk_buff *newSkb = NULL;
1511 /* pointer to skb or private skb created using skb_copy() */
1512 struct sk_buff *skbPtr = skb;
1513 u8 sendToNetdev = FALSE;
1514 u8 qosDestination = FALSE;
1515 CSR_PRIORITY priority = CSR_CONTENTION;
1516 CsrWifiRouterCtrlStaInfo_t *dstStaInfo = NULL;
1517 netInterface_priv_t *interfacePriv;
1519 unifi_trace(priv, UDBG5, "entering uf_ap_process_data_pdu %d\n",macHeaderLengthInBytes);
1520 /* InterfaceTag validation from MA_PACKET.indication */
1521 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
1522 unifi_trace(priv, UDBG1, "Interface Tag is Invalid in uf_ap_process_data_pdu\n");
1523 unifi_net_data_free(priv, &bulkdata->d[0]);
1526 interfacePriv = priv->interfacePriv[interfaceTag];
1528 if((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) &&
1529 (interfacePriv->intraBssEnabled == FALSE)) {
1530 unifi_trace(priv, UDBG2, "uf_ap_process_data_pdu:P2P GO intrabssEnabled?= %d\n", interfacePriv->intraBssEnabled);
1532 /*In P2P GO case, if intraBSS distribution Disabled then don't do IntraBSS routing */
1533 /* If destination in our BSS then drop otherwise give packet to netdev */
1534 dstStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, ehdr->h_dest, interfaceTag);
1536 unifi_net_data_free(priv, &bulkdata->d[0]);
1539 /* May be associated P2PCLI trying to send the packets on backbone (Netdev) */
1543 if(!memcmp(ehdr->h_dest, interfacePriv->bssid.a, ETH_ALEN)) {
1544 /* This packet will be given to the TCP/IP stack since this packet is for us(AP)
1545 * No routing needed */
1546 unifi_trace(priv, UDBG4, "destination address is csr_ap\n");
1550 /* fetch the destination record from staion record database */
1551 dstStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, ehdr->h_dest, interfaceTag);
1553 /* AP mode processing, & if packet is unicast */
1555 if (!(ehdr->h_dest[0] & 0x1)) {
1556 /* destination not in station record & its a unicast packet, so pass the packet to network stack */
1557 unifi_trace(priv, UDBG3, "unicast frame & destination record not exist, send to netdev proto = %x\n", htons(skb->protocol));
1560 /* packet is multicast/broadcast */
1561 /* copy the skb to skbPtr, send skb to netdev & skbPtr to multicast/broad cast list */
1562 unifi_trace(priv, UDBG5, "skb_copy, in uf_ap_process_data_pdu, protocol = %x\n", htons(skb->protocol));
1563 skbPtr = skb_copy(skb, GFP_KERNEL);
1564 if(skbPtr == NULL) {
1565 /* We don't have memory to don't send the frame in BSS*/
1566 unifi_notice(priv, "broacast/multicast frame can't be sent in BSS No memeory: proto = %x\n", htons(skb->protocol));
1569 sendToNetdev = TRUE;
1573 /* validate the Peer & Destination Station record */
1574 if (uf_process_station_records_for_sending_data(priv, interfaceTag, srcStaInfo, dstStaInfo)) {
1575 unifi_notice(priv, "uf_ap_process_data_pdu: station record validation failed \n");
1576 interfacePriv->stats.rx_errors++;
1577 unifi_net_data_free(priv, &bulkdata->d[0]);
1582 /* BroadCast packet received and it's been sent as non QOS packets.
1583 * Since WMM spec not mandates broadcast/multicast to be sent as QOS data only,
1584 * if all Peers are QSTA
1587 /* BroadCast packet and it's been sent as non QOS packets */
1588 qosDestination = FALSE;
1589 } else if(dstStaInfo && (dstStaInfo->wmmOrQosEnabled == TRUE)) {
1590 qosDestination = TRUE;
1593 unifi_trace(priv, UDBG3, "uf_ap_process_data_pdu QoS destination = %s\n", (qosDestination)? "TRUE": "FALSE");
1595 /* packet is allowed to send to unifi, update the Mac header */
1596 if (update_macheader(priv, skbPtr, newSkb, &priority, bulkdata, interfaceTag, macHeaderLengthInBytes, qosDestination)) {
1597 interfacePriv->stats.rx_errors++;
1598 unifi_notice(priv, "(Packet Drop) failed to update the Mac header in uf_ap_process_data_pdu\n");
1600 /* Free's the skb_copy(skbPtr) data since packet processing failed */
1601 bulkdata->d[0].os_data_ptr = skbPtr->data;
1602 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skbPtr;
1603 bulkdata->d[0].data_length = skbPtr->len;
1604 unifi_net_data_free(priv, &bulkdata->d[0]);
1609 unifi_trace(priv, UDBG3, "Mac Header updated...calling uf_process_ma_packet_req \n");
1611 /* Packet is ready to send to unifi ,transmissionControl = 0x0004, confirmation is not needed for data packets */
1612 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 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");
1615 /* Free's the skb_copy(skbPtr) data since packet processing failed */
1616 bulkdata->d[0].os_data_ptr = skbPtr->data;
1617 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skbPtr;
1618 bulkdata->d[0].data_length = skbPtr->len;
1619 unifi_net_data_free(priv, &bulkdata->d[0]);
1621 /* This free's the skb data */
1622 unifi_trace(priv, UDBG1, "In uf_ap_process_data_pdu, (Packet Drop). Unicast data so freeing original skb \n");
1623 unifi_net_data_free(priv, &bulkdata->d[0]);
1626 unifi_trace(priv, UDBG5, "leaving uf_ap_process_data_pdu\n");
1629 /* The packet is multicast/broadcast, so after AP processing packet has to
1630 * be sent to netdev, if peer port state is open
1632 unifi_trace(priv, UDBG4, "Packet will be routed to NetDev\n");
1635 /* Ap handled the packet & its a unicast packet, no need to send to netdev */
1641 CsrResult uf_process_ma_packet_req(unifi_priv_t *priv,
1643 CSR_CLIENT_TAG hostTag,
1645 CSR_TRANSMISSION_CONTROL transmissionControl,
1646 CSR_RATE TransmitRate,
1647 CSR_PRIORITY priority,
1648 CSR_PROCESS_ID leSenderProcessId,
1649 bulk_data_param_t *bulkdata)
1651 CsrResult status = CSR_RESULT_SUCCESS;
1654 #ifdef CSR_SUPPORT_SME
1655 CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
1656 const u8 *macHdrLocation = bulkdata->d[0].os_data_ptr;
1657 CsrWifiPacketType pktType;
1659 u8 queuePacketDozing = FALSE;
1662 struct list_head * list = NULL; /* List to which buffered PDUs are to be enqueued*/
1664 netInterface_priv_t *interfacePriv;
1665 u8 requeueOnSamePos = FALSE;
1666 u32 handle = 0xFFFFFFFF;
1667 unsigned long lock_flags;
1669 unifi_trace(priv, UDBG5,
1670 "entering uf_process_ma_packet_req, peer: %pMF\n",
1673 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
1674 unifi_error(priv, "interfaceTag >= CSR_WIFI_NUM_INTERFACES, interfacetag = %d\n", interfaceTag);
1675 return CSR_RESULT_FAILURE;
1677 interfacePriv = priv->interfacePriv[interfaceTag];
1680 /* fetch the station record for corresponding peer mac address */
1681 if ((staRecord = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, peerMacAddress, interfaceTag))) {
1682 handle = staRecord->assignedHandle;
1685 /* Frame ma-packet.req, this is saved/transmitted depend on queue state */
1686 unifi_frame_ma_packet_req(priv, priority, TransmitRate, hostTag,
1687 interfaceTag, transmissionControl, leSenderProcessId,
1688 peerMacAddress, &signal);
1690 /* Since it's common path between STA & AP mode, in case of STA packet
1691 * need not to be queued but in AP case we have to queue PDU's in
1692 * different scenarios
1694 switch(interfacePriv->interfaceMode)
1696 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
1697 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
1698 /* For this mode processing done below */
1701 /* In case of STA/IBSS/P2PCLI/AMP, no checks needed send the packet down & return */
1702 unifi_trace(priv, UDBG5, "In %s, interface mode is %x \n", __FUNCTION__, interfacePriv->interfaceMode);
1703 if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_NONE) {
1704 unifi_warning(priv, "In %s, interface mode NONE \n", __FUNCTION__);
1706 if ((result = ul_send_signal_unpacked(priv, &signal, bulkdata))) {
1707 status = CSR_RESULT_FAILURE;
1712 /* -----Only AP/P2pGO mode handling falls below----- */
1714 /* convert priority to queue */
1715 priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY) priority);
1717 /* check the powersave status of the peer */
1718 if (staRecord && (staRecord->currentPeerState ==
1719 CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)) {
1720 /* Peer is dozing & packet have to be delivered, so buffer the packet &
1723 queuePacketDozing = TRUE;
1726 /* find the type of frame unicast or mulicast/broadcast */
1727 if (*peerMacAddress & 0x1) {
1728 /* Multicast/broadCast data are always triggered by vif_availability.ind
1731 pktType = CSR_WIFI_MULTICAST_PDU;
1733 pktType = CSR_WIFI_UNICAST_PDU;
1736 /* Fetch the frame control field from mac header & check for frame type */
1737 frmCtrl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(macHdrLocation);
1739 /* Processing done according to Frame/Packet type */
1740 frameType = ((frmCtrl & 0x000c) >> FRAME_CONTROL_TYPE_FIELD_OFFSET);
1743 case IEEE802_11_FRAMETYPE_MANAGEMENT:
1747 case CSR_WIFI_UNICAST_PDU:
1748 unifi_trace(priv, UDBG5, "management unicast PDU in uf_process_ma_packet_req \n");
1749 /* push the packet in to the queue with appropriate mgt list */
1751 /* push the packet to the unifi if list is empty (if packet lost how to re-enque) */
1752 if (list_empty(&interfacePriv->genericMgtFrames)) {
1753 #ifdef CSR_SUPPORT_SME
1754 if(!(IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag))) {
1757 unifi_trace(priv, UDBG3, "genericMgtFrames list is empty uf_process_ma_packet_req \n");
1758 result = ul_send_signal_unpacked(priv, &signal, bulkdata);
1759 /* reque only on ENOSPC */
1760 if(result == -ENOSPC) {
1761 /* requeue the failed packet to genericMgtFrame with same position */
1762 unifi_trace(priv, UDBG1, "(ENOSPC) Sending genericMgtFrames Failed so buffering\n");
1763 list = &interfacePriv->genericMgtFrames;
1764 requeueOnSamePos = TRUE;
1766 #ifdef CSR_SUPPORT_SME
1768 list = &interfacePriv->genericMgtFrames;
1769 unifi_trace(priv, UDBG3, "genericMgtFrames queue empty and dtim started\n hosttag is 0x%x,\n",signal.u.MaPacketRequest.HostTag);
1770 update_eosp_to_head_of_broadcast_list_head(priv,interfaceTag);
1774 /* Queue the packet to genericMgtFrame of unifi_priv_t data structure */
1775 list = &interfacePriv->genericMgtFrames;
1776 unifi_trace(priv, UDBG2, "genericMgtFrames queue not empty\n");
1779 /* check peer power state */
1780 if (queuePacketDozing || !list_empty(&staRecord->mgtFrames) || IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag)) {
1781 /* peer is in dozing mode, so queue packet in mgt frame list of station record */
1782 /*if multicast traffic is going on, buffer the unicast packets*/
1783 list = &staRecord->mgtFrames;
1785 unifi_trace(priv, UDBG1, "staRecord->MgtFrames list empty? = %s, handle = %d, queuePacketDozing = %d\n",
1786 (list_empty(&staRecord->mgtFrames))? "YES": "NO", staRecord->assignedHandle, queuePacketDozing);
1787 if(IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag)){
1788 update_eosp_to_head_of_broadcast_list_head(priv,interfaceTag);
1792 unifi_trace(priv, UDBG5, "staRecord->mgtFrames list is empty uf_process_ma_packet_req \n");
1793 result = ul_send_signal_unpacked(priv, &signal, bulkdata);
1794 if(result == -ENOSPC) {
1795 /* requeue the failed packet to staRecord->mgtFrames with same position */
1796 list = &staRecord->mgtFrames;
1797 requeueOnSamePos = TRUE;
1798 unifi_trace(priv, UDBG1, "(ENOSPC) Sending MgtFrames Failed handle = %d so buffering\n",staRecord->assignedHandle);
1799 priv->pausedStaHandle[0]=(u8)(staRecord->assignedHandle);
1800 } else if (result) {
1801 status = CSR_RESULT_FAILURE;
1806 case CSR_WIFI_MULTICAST_PDU:
1807 unifi_trace(priv, UDBG5, "management multicast/broadcast PDU in uf_process_ma_packet_req 'QUEUE it' \n");
1808 /* Queue the packet to genericMulticastOrBroadCastMgtFrames of unifi_priv_t data structure
1809 * will be sent when we receive VIF AVAILABILITY from firmware as part of DTIM
1812 list = &interfacePriv->genericMulticastOrBroadCastMgtFrames;
1813 if((interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_IBSS) &&
1814 (list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames))) {
1819 unifi_error(priv, "condition never meets: packet type unrecognized\n");
1822 case IEEE802_11_FRAMETYPE_DATA:
1825 case CSR_WIFI_UNICAST_PDU:
1826 unifi_trace(priv, UDBG5, "data unicast PDU in uf_process_ma_packet_req \n");
1827 /* check peer power state, list status & peer port status */
1829 unifi_error(priv, "In %s unicast but staRecord = NULL\n", __FUNCTION__);
1830 return CSR_RESULT_FAILURE;
1831 } else if (queuePacketDozing || isRouterBufferEnabled(priv,priority_q)|| !list_empty(&staRecord->dataPdu[priority_q]) || IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag)) {
1832 /* peer is in dozing mode, so queue packet in mgt frame list of station record */
1833 /* if multicast traffic is going on, buffet the unicast packets */
1834 unifi_trace(priv, UDBG2, "Enqueued to staRecord->dataPdu[%d] queuePacketDozing=%d,\
1835 Buffering enabled = %d \n", priority_q,queuePacketDozing,isRouterBufferEnabled(priv,priority_q));
1836 list = &staRecord->dataPdu[priority_q];
1838 unifi_trace(priv, UDBG5, "staRecord->dataPdu[%d] list is empty uf_process_ma_packet_req \n", priority_q);
1839 /* Pdu allowed to send to unifi */
1840 result = ul_send_signal_unpacked(priv, &signal, bulkdata);
1841 if(result == -ENOSPC) {
1842 /* requeue the failed packet to staRecord->dataPdu[priority_q] with same position */
1843 unifi_trace(priv, UDBG1, "(ENOSPC) Sending Unicast DataPDU to queue %d Failed so buffering\n",priority_q);
1844 requeueOnSamePos = TRUE;
1845 list = &staRecord->dataPdu[priority_q];
1846 priv->pausedStaHandle[priority_q]=(u8)(staRecord->assignedHandle);
1847 if(!isRouterBufferEnabled(priv,priority_q)) {
1848 unifi_error(priv,"Buffering Not enabled for queue %d \n",priority_q);
1850 } else if (result) {
1851 status = CSR_RESULT_FAILURE;
1855 case CSR_WIFI_MULTICAST_PDU:
1856 unifi_trace(priv, UDBG5, "data multicast/broadcast PDU in uf_process_ma_packet_req \n");
1857 /* Queue the packet to genericMulticastOrBroadCastFrames list of unifi_priv_t data structure
1858 * will be sent when we receive VIF AVAILABILITY from firmware as part of DTIM
1860 list = &interfacePriv->genericMulticastOrBroadCastFrames;
1861 if(list_empty(&interfacePriv->genericMulticastOrBroadCastFrames)) {
1866 unifi_error(priv, "condition never meets: packet type un recognized\n");
1870 unifi_error(priv, "unrecognized frame type\n");
1873 status = enque_tx_data_pdu(priv, bulkdata,list, &signal,requeueOnSamePos);
1874 /* Record no. of packet queued for each peer */
1875 if (staRecord && (pktType == CSR_WIFI_UNICAST_PDU) && (!status)) {
1876 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
1877 staRecord->noOfPktQueued++;
1878 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
1880 else if ((pktType == CSR_WIFI_MULTICAST_PDU) && (!status))
1882 /* If broadcast Tim is set && queuing is successfull, then only update TIM */
1883 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
1884 interfacePriv->noOfbroadcastPktQueued++;
1885 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
1888 /* If broadcast Tim is set && queuing is successfull, then only update TIM */
1889 if(setBcTim && !status) {
1890 unifi_trace(priv, UDBG3, "tim set due to broadcast pkt\n");
1891 if (!interfacePriv->bcTimSetReqPendingFlag)
1893 update_tim(priv,0,CSR_WIFI_TIM_SET,interfaceTag, handle);
1897 /* Cache the TimSet value so that it will processed immidiatly after
1898 * completing the current setTim Request
1900 interfacePriv->bcTimSetReqQueued = CSR_WIFI_TIM_SET;
1901 unifi_trace(priv, UDBG2, "uf_process_ma_packet_req : One more UpdateDTim Request(:%d) Queued \n",
1902 interfacePriv->bcTimSetReqQueued);
1904 } else if(staRecord && staRecord->currentPeerState ==
1905 CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE) {
1906 if(staRecord->timSet == CSR_WIFI_TIM_RESET || staRecord->timSet == CSR_WIFI_TIM_RESETTING) {
1907 if(!staRecord->wmmOrQosEnabled) {
1908 if(!list_empty(&staRecord->mgtFrames) ||
1909 !list_empty(&staRecord->dataPdu[3]) ||
1910 !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION])) {
1911 unifi_trace(priv, UDBG3, "tim set due to unicast pkt & peer in powersave\n");
1912 if (!staRecord->timRequestPendingFlag){
1913 update_tim(priv,staRecord->aid,1,interfaceTag, handle);
1917 /* Cache the TimSet value so that it will processed immidiatly after
1918 * completing the current setTim Request
1920 staRecord->updateTimReqQueued = 1;
1921 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
1926 /* Check for non delivery enable(i.e trigger enable), all delivery enable & legacy AC for TIM update in firmware */
1927 u8 allDeliveryEnabled = 0, dataAvailable = 0;
1928 /* Check if all AC's are Delivery Enabled */
1929 is_all_ac_deliver_enabled_and_moredata(staRecord, &allDeliveryEnabled, &dataAvailable);
1930 if (uf_is_more_data_for_non_delivery_ac(staRecord) || (allDeliveryEnabled && dataAvailable)
1931 || (!list_empty(&staRecord->mgtFrames))) {
1932 if (!staRecord->timRequestPendingFlag) {
1933 update_tim(priv,staRecord->aid,1,interfaceTag, handle);
1937 /* Cache the TimSet value so that it will processed immidiatly after
1938 * completing the current setTim Request
1940 staRecord->updateTimReqQueued = 1;
1941 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
1949 if((list) && (pktType == CSR_WIFI_UNICAST_PDU && !queuePacketDozing) && !(isRouterBufferEnabled(priv,priority_q)) && !(IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag))) {
1950 unifi_trace(priv, UDBG2, "buffering cleared for queue = %d So resending buffered frames\n",priority_q);
1951 uf_send_buffered_frames(priv, priority_q);
1953 unifi_trace(priv, UDBG5, "leaving uf_process_ma_packet_req \n");
1956 #ifdef CSR_NATIVE_LINUX
1957 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
1958 unifi_error(priv, "interfaceTag >= CSR_WIFI_NUM_INTERFACES, interfacetag = %d\n", interfaceTag);
1959 return CSR_RESULT_FAILURE;
1961 /* Frame ma-packet.req, this is saved/transmitted depend on queue state */
1962 unifi_frame_ma_packet_req(priv, priority, TransmitRate, hostTag, interfaceTag,
1963 transmissionControl, leSenderProcessId,
1964 peerMacAddress, &signal);
1965 result = ul_send_signal_unpacked(priv, &signal, bulkdata);
1967 return CSR_RESULT_FAILURE;
1974 #ifdef CSR_SUPPORT_SME
1975 s8 uf_get_protection_bit_from_interfacemode(unifi_priv_t *priv, u16 interfaceTag, const u8 *daddr)
1978 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
1980 switch(interfacePriv->interfaceMode)
1982 case CSR_WIFI_ROUTER_CTRL_MODE_STA:
1983 case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
1984 case CSR_WIFI_ROUTER_CTRL_MODE_AMP:
1985 case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
1986 protection = interfacePriv->protect;
1988 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
1989 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
1991 CsrWifiRouterCtrlStaInfo_t *dstStaInfo = NULL;
1992 if (daddr[0] & 0x1) {
1993 unifi_trace(priv, UDBG3, "broadcast/multicast packet in send_ma_pkt_request\n");
1994 /* In this mode, the protect member of priv structure has an information of how
1995 * AP/P2PGO has started, & the member updated in set mode request for AP/P2PGO
1997 protection = interfacePriv->protect;
1999 /* fetch the destination record from staion record database */
2000 dstStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, daddr, interfaceTag);
2002 unifi_trace(priv, UDBG3, "peer not found in station record in send_ma_pkt_request\n");
2005 protection = dstStaInfo->protection;
2010 unifi_trace(priv, UDBG2, "mode unknown in send_ma_pkt_request\n");
2015 #ifdef CSR_SUPPORT_SME
2016 u8 send_multicast_frames(unifi_priv_t *priv, u16 interfaceTag)
2019 tx_buffered_packets_t * buffered_pkt = NULL;
2020 u8 moreData = FALSE;
2022 unsigned long lock_flags;
2023 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2024 u32 hostTag = 0xffffffff;
2027 if(!isRouterBufferEnabled(priv,UNIFI_TRAFFIC_Q_VO)) {
2028 while((interfacePriv->dtimActive)&& (buffered_pkt=dequeue_tx_data_pdu(priv,&interfacePriv->genericMulticastOrBroadCastMgtFrames))) {
2029 buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK);
2030 moreData = (buffered_pkt->transmissionControl & TRANSMISSION_CONTROL_EOSP_MASK)?FALSE:TRUE;
2033 unifi_trace(priv,UDBG2,"DTIM Occurred for interface:sending Mgt packet %d\n",interfaceTag);
2035 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,NULL,moreData,FALSE)) == -ENOSPC) {
2036 unifi_trace(priv,UDBG1,"frame_and_send_queued_pdu failed with ENOSPC for host tag = %x\n", buffered_pkt->hostTag);
2037 /* Enqueue at the head of the queue */
2038 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
2039 list_add(&buffered_pkt->q, &interfacePriv->genericMulticastOrBroadCastMgtFrames);
2040 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
2043 unifi_trace(priv,UDBG1,"send_multicast_frames: Send genericMulticastOrBroadCastMgtFrames (%x, %x)\n",
2044 buffered_pkt->hostTag,
2047 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
2051 interfacePriv->dtimActive = FALSE;
2053 hostTag = buffered_pkt->hostTag;
2056 send_vif_availibility_rsp(priv,uf_get_vif_identifier(interfacePriv->interfaceMode,interfaceTag),CSR_RC_UNSPECIFIED_FAILURE);
2059 /* Buffered frame sent successfully */
2060 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2061 interfacePriv->noOfbroadcastPktQueued--;
2062 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2063 kfree(buffered_pkt);
2068 if(!isRouterBufferEnabled(priv,UNIFI_TRAFFIC_Q_CONTENTION)) {
2069 while((interfacePriv->dtimActive)&& (buffered_pkt=dequeue_tx_data_pdu(priv,&interfacePriv->genericMulticastOrBroadCastFrames))) {
2070 buffered_pkt->transmissionControl |= TRANSMISSION_CONTROL_TRIGGER_MASK;
2071 moreData = (buffered_pkt->transmissionControl & TRANSMISSION_CONTROL_EOSP_MASK)?FALSE:TRUE;
2074 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,NULL,moreData,FALSE)) == -ENOSPC) {
2075 /* Clear the trigger bit transmission control*/
2076 buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK);
2077 /* Enqueue at the head of the queue */
2078 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
2079 list_add(&buffered_pkt->q, &interfacePriv->genericMulticastOrBroadCastFrames);
2080 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
2084 unifi_trace(priv,UDBG1,"send_multicast_frames: Send genericMulticastOrBroadCastFrame failed (%x, %x)\n",
2085 buffered_pkt->hostTag,
2087 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
2090 interfacePriv->dtimActive = FALSE;
2093 hostTag = buffered_pkt->hostTag;
2095 send_vif_availibility_rsp(priv,uf_get_vif_identifier(interfacePriv->interfaceMode,interfaceTag),CSR_RC_UNSPECIFIED_FAILURE);
2098 /* Buffered frame sent successfully */
2099 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2100 interfacePriv->noOfbroadcastPktQueued--;
2101 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2102 kfree(buffered_pkt);
2106 if((interfacePriv->dtimActive == FALSE)) {
2107 /* Record the host Tag*/
2108 unifi_trace(priv,UDBG2,"send_multicast_frames: Recorded hostTag of EOSP packet: = 0x%x\n",hostTag);
2109 interfacePriv->multicastPduHostTag = hostTag;
2114 void uf_process_ma_vif_availibility_ind(unifi_priv_t *priv,u8 *sigdata,
2117 #ifdef CSR_SUPPORT_SME
2119 CSR_MA_VIF_AVAILABILITY_INDICATION *ind;
2123 CSR_RESULT_CODE resultCode = CSR_RC_SUCCESS;
2124 netInterface_priv_t *interfacePriv;
2127 unifi_trace(priv, UDBG3,
2128 "uf_process_ma_vif_availibility_ind: Process signal 0x%.4X\n",
2131 r = read_unpack_signal(sigdata, &signal);
2134 "uf_process_ma_vif_availibility_ind: Received unknown signal 0x%.4X.\n",
2135 CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata));
2139 ind = &signal.u.MaVifAvailabilityIndication;
2140 interfaceTag=ind->VirtualInterfaceIdentifier & 0xff;
2142 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
2143 unifi_error(priv, "in vif_availability_ind interfaceTag is wrong\n");
2147 interfacePriv = priv->interfacePriv[interfaceTag];
2149 if(ind->Multicast) {
2150 if(list_empty(&interfacePriv->genericMulticastOrBroadCastFrames) &&
2151 list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames)) {
2152 /* This condition can occur because of a potential race where the
2153 TIM is not yet reset as host is waiting for confirm but it is sent
2154 by firmware and DTIM occurs*/
2155 unifi_notice(priv,"ma_vif_availibility_ind recevied for multicast but queues are empty%d\n",interfaceTag);
2156 send_vif_availibility_rsp(priv,ind->VirtualInterfaceIdentifier,CSR_RC_NO_BUFFERED_BROADCAST_MULTICAST_FRAMES);
2157 interfacePriv->dtimActive = FALSE;
2158 if(interfacePriv->multicastPduHostTag == 0xffffffff) {
2159 unifi_notice(priv,"ma_vif_availibility_ind recevied for multicast but queues are empty%d\n",interfaceTag);
2160 /* This may be an extra request in very rare race conditions but it is fine as it would atleast remove the potential lock up */
2161 if (!interfacePriv->bcTimSetReqPendingFlag)
2163 update_tim(priv,0,CSR_WIFI_TIM_RESET,interfaceTag, 0xFFFFFFFF);
2167 /* Cache the TimSet value so that it will processed immidiatly after
2168 * completing the current setTim Request
2170 interfacePriv->bcTimSetReqQueued = CSR_WIFI_TIM_RESET;
2171 unifi_trace(priv, UDBG2, "uf_process_ma_vif_availibility_ind : One more UpdateDTim Request(%d) Queued \n",
2172 interfacePriv->bcTimSetReqQueued);
2177 if(interfacePriv->dtimActive) {
2178 unifi_trace(priv,UDBG2,"DTIM Occurred for already active DTIM interface %d\n",interfaceTag);
2181 unifi_trace(priv,UDBG2,"DTIM Occurred for interface %d\n",interfaceTag);
2182 if(list_empty(&interfacePriv->genericMulticastOrBroadCastFrames)) {
2183 set_eosp_transmit_ctrl(priv,&interfacePriv->genericMulticastOrBroadCastMgtFrames);
2185 set_eosp_transmit_ctrl(priv,&interfacePriv->genericMulticastOrBroadCastFrames);
2188 interfacePriv->dtimActive = TRUE;
2189 pduSent = send_multicast_frames(priv,interfaceTag);
2192 unifi_error(priv,"Interface switching is not supported %d\n",interfaceTag);
2193 resultCode = CSR_RC_NOT_SUPPORTED;
2194 send_vif_availibility_rsp(priv,ind->VirtualInterfaceIdentifier,CSR_RC_NOT_SUPPORTED);
2198 #ifdef CSR_SUPPORT_SME
2200 #define GET_ACTIVE_INTERFACE_TAG(priv) 0
2202 static u8 uf_is_more_data_for_delivery_ac(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t *staRecord)
2206 for(i=UNIFI_TRAFFIC_Q_VO; i >= UNIFI_TRAFFIC_Q_BK; i--)
2208 if(((staRecord->powersaveMode[i]==CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)
2209 ||(staRecord->powersaveMode[i]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED))
2210 &&(!list_empty(&staRecord->dataPdu[i]))) {
2211 unifi_trace(priv,UDBG2,"uf_is_more_data_for_delivery_ac: Data Available AC = %d\n", i);
2216 unifi_trace(priv,UDBG2,"uf_is_more_data_for_delivery_ac: Data NOT Available \n");
2220 static u8 uf_is_more_data_for_usp_delivery(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t *staRecord, unifi_TrafficQueue queue)
2224 for(i = queue; i >= UNIFI_TRAFFIC_Q_BK; i--)
2226 if(((staRecord->powersaveMode[i]==CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)
2227 ||(staRecord->powersaveMode[i]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED))
2228 &&(!list_empty(&staRecord->dataPdu[i]))) {
2229 unifi_trace(priv,UDBG2,"uf_is_more_data_for_usp_delivery: Data Available AC = %d\n", i);
2234 unifi_trace(priv,UDBG2,"uf_is_more_data_for_usp_delivery: Data NOT Available \n");
2239 * ---------------------------------------------------------------------------
2240 * uf_send_buffered_data_from_delivery_ac
2242 * This function takes care of
2243 * -> Parsing the delivery enabled queue & sending frame down to HIP
2244 * -> Setting EOSP=1 when USP to be terminated
2245 * -> Depending on MAX SP length services the USP
2247 * NOTE:This function always called from uf_handle_uspframes_delivery(), Dont
2248 * call this function from any other location in code
2251 * priv Pointer to device private context struct
2252 * vif interface specific HIP vif instance
2253 * staInfo peer for which UAPSD to be scheduled
2254 * queue AC from which Data to be sent in USP
2255 * txList access category for processing list
2256 * ---------------------------------------------------------------------------
2258 void uf_send_buffered_data_from_delivery_ac(unifi_priv_t *priv,
2259 CsrWifiRouterCtrlStaInfo_t * staInfo,
2261 struct list_head *txList)
2264 u16 interfaceTag = GET_ACTIVE_INTERFACE_TAG(priv);
2265 tx_buffered_packets_t * buffered_pkt = NULL;
2266 unsigned long lock_flags;
2269 u8 moreData = FALSE;
2270 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2272 unifi_trace(priv, UDBG2, "++uf_send_buffered_data_from_delivery_ac, active=%x\n", staInfo->uapsdActive);
2274 if (queue > UNIFI_TRAFFIC_Q_VO)
2278 while((buffered_pkt=dequeue_tx_data_pdu(priv, txList))) {
2279 if((IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag))) {
2280 unifi_trace(priv, UDBG2, "uf_send_buffered_data_from_delivery_ac: DTIM Active, suspend UAPSD, staId: 0x%x\n",
2283 /* Once resume called, the U-APSD delivery operation will resume */
2284 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2285 staInfo->uspSuspend = TRUE;
2286 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2287 /* re-queueing the packet as DTIM started */
2288 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
2289 list_add(&buffered_pkt->q,txList);
2290 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
2294 buffered_pkt->transmissionControl &=
2295 ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
2298 if((staInfo->wmmOrQosEnabled == TRUE)&&(staInfo->uapsdActive == TRUE)) {
2300 buffered_pkt->transmissionControl = TRANSMISSION_CONTROL_TRIGGER_MASK;
2302 /* Check All delivery enables Ac for more data, because caller of this
2303 * function not aware about last packet
2304 * (First check in moreData fetching helps in draining out Mgt frames Q)
2306 moreData = (!list_empty(txList) || uf_is_more_data_for_usp_delivery(priv, staInfo, queue));
2308 if(staInfo->noOfSpFramesSent == (staInfo->maxSpLength - 1)) {
2312 if(moreData == FALSE) {
2314 buffered_pkt->transmissionControl =
2315 (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
2318 /* Non QoS and non U-APSD */
2319 unifi_warning(priv, "uf_send_buffered_data_from_delivery_ac: non U-APSD !!! \n");
2322 unifi_trace(priv,UDBG2,"uf_send_buffered_data_from_delivery_ac : MoreData:%d, EOSP:%d\n",moreData,eosp);
2324 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staInfo,moreData,eosp)) == -ENOSPC) {
2326 unifi_trace(priv, UDBG2, "uf_send_buffered_data_from_delivery_ac: UASPD suspended, ENOSPC in hipQ=%x\n", queue);
2328 /* Once resume called, the U-APSD delivery operation will resume */
2329 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2330 staInfo->uspSuspend = TRUE;
2331 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2333 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
2334 list_add(&buffered_pkt->q,txList);
2335 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
2336 priv->pausedStaHandle[queue]=(u8)(staInfo->assignedHandle);
2340 /* the PDU failed where we can't do any thing so free the storage */
2341 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
2343 kfree(buffered_pkt);
2344 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2345 staInfo->noOfSpFramesSent++;
2346 if((!moreData) || (staInfo->noOfSpFramesSent == staInfo->maxSpLength)) {
2347 unifi_trace(priv, UDBG2, "uf_send_buffered_data_from_delivery_ac: Terminating USP\n");
2348 staInfo->uapsdActive = FALSE;
2349 staInfo->uspSuspend = FALSE;
2350 staInfo->noOfSpFramesSent = 0;
2351 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2354 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2357 unifi_trace(priv, UDBG2, "--uf_send_buffered_data_from_delivery_ac, active=%x\n", staInfo->uapsdActive);
2360 void uf_send_buffered_data_from_ac(unifi_priv_t *priv,
2361 CsrWifiRouterCtrlStaInfo_t * staInfo,
2363 struct list_head *txList)
2365 tx_buffered_packets_t * buffered_pkt = NULL;
2366 unsigned long lock_flags;
2368 u8 moreData = FALSE;
2373 unifi_trace(priv,UDBG2,"uf_send_buffered_data_from_ac :\n");
2375 while(!isRouterBufferEnabled(priv,queue) &&
2376 ((buffered_pkt=dequeue_tx_data_pdu(priv, txList))!=NULL)){
2378 buffered_pkt->transmissionControl &=
2379 ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
2381 unifi_trace(priv,UDBG3,"uf_send_buffered_data_from_ac : MoreData:%d, EOSP:%d\n",moreData,eosp);
2383 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staInfo,moreData,eosp)) == -ENOSPC) {
2384 /* Enqueue at the head of the queue */
2385 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
2386 list_add(&buffered_pkt->q,txList);
2387 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
2388 if(staInfo != NULL){
2389 priv->pausedStaHandle[queue]=(u8)(staInfo->assignedHandle);
2391 unifi_trace(priv,UDBG3," uf_send_buffered_data_from_ac: PDU sending failed .. no space for queue %d \n",queue);
2394 /* the PDU failed where we can't do any thing so free the storage */
2395 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
2397 kfree(buffered_pkt);
2405 void uf_send_buffered_frames(unifi_priv_t *priv,unifi_TrafficQueue q)
2407 u16 interfaceTag = GET_ACTIVE_INTERFACE_TAG(priv);
2408 u32 startIndex=0,endIndex=0;
2409 CsrWifiRouterCtrlStaInfo_t * staInfo = NULL;
2411 u8 moreData = FALSE;
2413 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2415 if(!((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP) ||
2416 (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO)))
2422 if(interfacePriv->dtimActive) {
2423 /* this function updates dtimActive*/
2424 send_multicast_frames(priv,interfaceTag);
2425 if(!interfacePriv->dtimActive) {
2426 moreData = (!list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames) ||
2427 !list_empty(&interfacePriv->genericMulticastOrBroadCastFrames));
2429 if (!interfacePriv->bcTimSetReqPendingFlag)
2431 update_tim(priv,0,CSR_WIFI_TIM_RESET,interfaceTag, 0XFFFFFFFF);
2435 /* Cache the TimSet value so that it will processed immidiatly after
2436 * completing the current setTim Request
2438 interfacePriv->bcTimSetReqQueued = CSR_WIFI_TIM_RESET;
2439 unifi_trace(priv, UDBG2, "uf_send_buffered_frames : One more UpdateDTim Request(%d) Queued \n",
2440 interfacePriv->bcTimSetReqQueued);
2444 moreData = (!list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames) ||
2445 !list_empty(&interfacePriv->genericMulticastOrBroadCastFrames));
2447 /* This should never happen but if it happens, we need a way out */
2448 unifi_error(priv,"ERROR: No More Data but DTIM is active sending Response\n");
2449 send_vif_availibility_rsp(priv,uf_get_vif_identifier(interfacePriv->interfaceMode,interfaceTag),CSR_RC_NO_BUFFERED_BROADCAST_MULTICAST_FRAMES);
2450 interfacePriv->dtimActive = FALSE;
2456 if(priv->pausedStaHandle[queue] > 7) {
2457 priv->pausedStaHandle[queue] = 0;
2460 if(queue == UNIFI_TRAFFIC_Q_VO) {
2463 unifi_trace(priv,UDBG2,"uf_send_buffered_frames : trying mgt from queue=%d\n",queue);
2464 for(startIndex= 0; startIndex < UNIFI_MAX_CONNECTIONS;startIndex++) {
2465 staInfo = CsrWifiRouterCtrlGetStationRecordFromHandle(priv,startIndex,interfaceTag);
2468 } else if((staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)
2469 &&(staInfo->uapsdActive == FALSE) ) {
2473 if((staInfo != NULL)&&(staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE)
2474 &&(staInfo->uapsdActive == FALSE)){
2475 /*Non-UAPSD case push the management frames out*/
2476 if(!list_empty(&staInfo->mgtFrames)){
2477 uf_send_buffered_data_from_ac(priv,staInfo, UNIFI_TRAFFIC_Q_VO, &staInfo->mgtFrames);
2481 if(isRouterBufferEnabled(priv,queue)) {
2482 unifi_notice(priv,"uf_send_buffered_frames : No space Left for queue = %d\n",queue);
2486 /*push generic management frames out*/
2487 if(!list_empty(&interfacePriv->genericMgtFrames)) {
2488 unifi_trace(priv,UDBG2,"uf_send_buffered_frames : trying generic mgt from queue=%d\n",queue);
2489 uf_send_buffered_data_from_ac(priv,staInfo, UNIFI_TRAFFIC_Q_VO, &interfacePriv->genericMgtFrames);
2494 unifi_trace(priv,UDBG2,"uf_send_buffered_frames : Resume called for Queue=%d\n",queue);
2495 unifi_trace(priv,UDBG2,"uf_send_buffered_frames : start=%d end=%d\n",startIndex,endIndex);
2497 startIndex = priv->pausedStaHandle[queue];
2498 endIndex = (startIndex + UNIFI_MAX_CONNECTIONS -1) % UNIFI_MAX_CONNECTIONS;
2500 while(startIndex != endIndex) {
2501 staInfo = CsrWifiRouterCtrlGetStationRecordFromHandle(priv,startIndex,interfaceTag);
2504 if(startIndex >= UNIFI_MAX_CONNECTIONS) {
2508 } else if((staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)
2509 &&(staInfo->uapsdActive == FALSE)) {
2511 if(startIndex >= UNIFI_MAX_CONNECTIONS) {
2516 /* Peer is active or U-APSD is active so send PDUs to the peer */
2517 unifi_trace(priv,UDBG2,"uf_send_buffered_frames : trying data from queue=%d\n",queue);
2520 if((staInfo != NULL)&&(staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE)
2521 &&(staInfo->uapsdActive == FALSE)) {
2522 if(!list_empty(&staInfo->dataPdu[queue])) {
2524 /*Non-UAPSD case push the AC frames out*/
2525 uf_send_buffered_data_from_ac(priv, staInfo, queue, (&staInfo->dataPdu[queue]));
2529 if(startIndex >= UNIFI_MAX_CONNECTIONS) {
2533 if(isRouterBufferEnabled(priv,queue)) {
2534 priv->pausedStaHandle[queue] = endIndex;
2536 priv->pausedStaHandle[queue] = 0;
2539 /* U-APSD might have stopped because of ENOSPC in lib_hip (pause activity).
2540 * So restart it if U-APSD was active with any of the station
2542 unifi_trace(priv, UDBG4, "csrWifiHipSendBufferedFrames: UAPSD Resume Q=%x\n", queue);
2543 resume_suspended_uapsd(priv, interfaceTag);
2548 u8 uf_is_more_data_for_non_delivery_ac(CsrWifiRouterCtrlStaInfo_t *staRecord)
2554 if(((staRecord->powersaveMode[i]==CSR_WIFI_AC_TRIGGER_ONLY_ENABLED)
2555 ||(staRecord->powersaveMode[i]==CSR_WIFI_AC_LEGACY_POWER_SAVE))
2556 &&(!list_empty(&staRecord->dataPdu[i]))){
2562 if(((staRecord->powersaveMode[UNIFI_TRAFFIC_Q_VO]==CSR_WIFI_AC_TRIGGER_ONLY_ENABLED)
2563 ||(staRecord->powersaveMode[UNIFI_TRAFFIC_Q_VO]==CSR_WIFI_AC_LEGACY_POWER_SAVE))
2564 &&(!list_empty(&staRecord->mgtFrames))){
2575 int uf_process_station_records_for_sending_data(unifi_priv_t *priv,u16 interfaceTag,
2576 CsrWifiRouterCtrlStaInfo_t *srcStaInfo,
2577 CsrWifiRouterCtrlStaInfo_t *dstStaInfo)
2579 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2581 unifi_trace(priv, UDBG5, "entering uf_process_station_records_for_sending_data\n");
2583 if (srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_DISCONNECTED) {
2584 unifi_error(priv, "Peer State not connected AID = %x, handle = %x, control port state = %x\n",
2585 srcStaInfo->aid, srcStaInfo->assignedHandle, srcStaInfo->peerControlledPort->port_action);
2588 switch (interfacePriv->interfaceMode)
2590 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
2591 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
2592 unifi_trace(priv, UDBG5, "mode is AP/P2PGO\n");
2595 unifi_warning(priv, "mode is nor AP neither P2PGO, packet cant be xmit\n");
2599 switch(dstStaInfo->peerControlledPort->port_action)
2601 case CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD:
2602 case CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_BLOCK:
2603 unifi_trace(priv, UDBG5, "destination port is closed/blocked, discarding the packet\n");
2606 unifi_trace(priv, UDBG5, "destination port state is open\n");
2609 /* port state is open, destination station record is valid, Power save state is
2610 * validated in uf_process_ma_packet_req function
2612 unifi_trace(priv, UDBG5, "leaving uf_process_station_records_for_sending_data\n");
2618 * ---------------------------------------------------------------------------
2619 * uf_handle_uspframes_delivery
2621 * This function takes care of handling USP session for peer, when
2622 * -> trigger frame from peer
2623 * -> suspended USP to be processed (resumed)
2625 * NOTE: uf_send_buffered_data_from_delivery_ac() always called from this function, Dont
2626 * make a direct call to uf_send_buffered_data_from_delivery_ac() from any other part of
2630 * priv Pointer to device private context struct
2631 * staInfo peer for which UAPSD to be scheduled
2632 * interfaceTag virtual interface tag
2633 * ---------------------------------------------------------------------------
2635 static void uf_handle_uspframes_delivery(unifi_priv_t * priv, CsrWifiRouterCtrlStaInfo_t *staInfo, u16 interfaceTag)
2639 u8 allDeliveryEnabled = 0, dataAvailable = 0;
2640 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2641 unsigned long lock_flags;
2643 unifi_trace(priv, UDBG2, " ++ uf_handle_uspframes_delivery, uapsd active=%x, suspended?=%x\n",
2644 staInfo->uapsdActive, staInfo->uspSuspend);
2646 /* Check for Buffered frames according to priority order & deliver it
2647 * 1. AC_VO delivery enable & Mgt frames available
2648 * 2. Process remaining Ac's from order AC_VO to AC_BK
2651 /* USP initiated by WMMPS enabled peer & SET the status flag to TRUE */
2652 if (!staInfo->uspSuspend && staInfo->uapsdActive)
2654 unifi_notice(priv, "uf_handle_uspframes_delivery: U-APSD already active! STA=%x:%x:%x:%x:%x:%x\n",
2655 staInfo->peerMacAddress.a[0], staInfo->peerMacAddress.a[1],
2656 staInfo->peerMacAddress.a[2], staInfo->peerMacAddress.a[3],
2657 staInfo->peerMacAddress.a[4], staInfo->peerMacAddress.a[5]);
2661 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2662 staInfo->uapsdActive = TRUE;
2663 staInfo->uspSuspend = FALSE;
2664 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2666 if(((staInfo->powersaveMode[UNIFI_TRAFFIC_Q_VO]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED)||
2667 (staInfo->powersaveMode[UNIFI_TRAFFIC_Q_VO]==CSR_WIFI_AC_DELIVERY_ONLY_ENABLE))
2668 && (!list_empty(&staInfo->mgtFrames))) {
2670 /* Management queue has data && UNIFI_TRAFFIC_Q_VO is delivery enable */
2671 unifi_trace(priv, UDBG4, "uf_handle_uspframes_delivery: Sending buffered management frames\n");
2672 uf_send_buffered_data_from_delivery_ac(priv, staInfo, UNIFI_TRAFFIC_Q_VO, &staInfo->mgtFrames);
2675 if (!uf_is_more_data_for_delivery_ac(priv, staInfo)) {
2676 /* All delivery enable AC's are empty, so QNULL to be sent to terminate the USP
2677 * NOTE: If we have sent Mgt frame also, we must send QNULL followed to terminate USP
2679 if (!staInfo->uspSuspend) {
2680 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2681 staInfo->uapsdActive = FALSE;
2682 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2684 unifi_trace(priv, UDBG2, "uf_handle_uspframes_delivery: sending QNull for trigger\n");
2685 uf_send_qos_null(priv, interfaceTag, staInfo->peerMacAddress.a, (CSR_PRIORITY) staInfo->triggerFramePriority, staInfo);
2686 staInfo->triggerFramePriority = CSR_QOS_UP0;
2688 unifi_trace(priv, UDBG2, "uf_handle_uspframes_delivery: MgtQ xfer suspended\n");
2691 for(i = UNIFI_TRAFFIC_Q_VO; i >= UNIFI_TRAFFIC_Q_BK; i--) {
2692 if(((staInfo->powersaveMode[i]==CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)
2693 ||(staInfo->powersaveMode[i]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED))
2694 && (!list_empty(&staInfo->dataPdu[i]))) {
2695 /* Deliver Data according to AC priority (from VO to BK) as part of USP */
2696 unifi_trace(priv, UDBG4, "uf_handle_uspframes_delivery: Buffered data frames from Queue (%d) for USP\n", i);
2697 uf_send_buffered_data_from_delivery_ac(priv, staInfo, i, &staInfo->dataPdu[i]);
2700 if ((!staInfo->uapsdActive) ||
2701 (staInfo->uspSuspend && IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag))) {
2702 /* If DTIM active found on one AC, No need to parse the remaining AC's
2703 * as USP suspended. Break out of loop
2705 unifi_trace(priv, UDBG2, "uf_handle_uspframes_delivery: suspend=%x, DTIM=%x, USP terminated=%s\n",
2706 staInfo->uspSuspend, IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag),
2707 staInfo->uapsdActive?"NO":"YES");
2713 /* Depending on the USP status, update the TIM accordingly for delivery enabled AC only
2714 * (since we are not manipulating any Non-delivery list(AC))
2716 is_all_ac_deliver_enabled_and_moredata(staInfo, &allDeliveryEnabled, &dataAvailable);
2717 if ((allDeliveryEnabled && !dataAvailable)) {
2718 if ((staInfo->timSet != CSR_WIFI_TIM_RESET) || (staInfo->timSet != CSR_WIFI_TIM_RESETTING)) {
2719 staInfo->updateTimReqQueued = (u8) CSR_WIFI_TIM_RESET;
2720 unifi_trace(priv, UDBG4, " --uf_handle_uspframes_delivery, UAPSD timset\n");
2721 if (!staInfo->timRequestPendingFlag) {
2722 update_tim(priv, staInfo->aid, 0, interfaceTag, staInfo->assignedHandle);
2726 unifi_trace(priv, UDBG2, " --uf_handle_uspframes_delivery, uapsd active=%x, suspend?=%x\n",
2727 staInfo->uapsdActive, staInfo->uspSuspend);
2730 void uf_process_wmm_deliver_ac_uapsd(unifi_priv_t * priv,
2731 CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
2735 CSR_PRIORITY priority;
2736 unifi_TrafficQueue priority_q;
2737 unsigned long lock_flags;
2739 unifi_trace(priv, UDBG2, "++uf_process_wmm_deliver_ac_uapsd: uapsdactive?=%x\n", srcStaInfo->uapsdActive);
2740 /* If recceived Frames trigger Frame and Devlivery enabled AC has data
2741 * then transmit from High priorty delivery enabled AC
2743 priority = (CSR_PRIORITY)(qosControl & IEEE802_11_QC_TID_MASK);
2744 priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY) priority);
2746 if((srcStaInfo->powersaveMode[priority_q]==CSR_WIFI_AC_TRIGGER_ONLY_ENABLED)
2747 ||(srcStaInfo->powersaveMode[priority_q]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED)) {
2748 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2749 srcStaInfo->triggerFramePriority = priority;
2750 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2751 unifi_trace(priv, UDBG2, "uf_process_wmm_deliver_ac_uapsd: trigger frame, Begin U-APSD, triggerQ=%x\n", priority_q);
2752 uf_handle_uspframes_delivery(priv, srcStaInfo, interfaceTag);
2754 unifi_trace(priv, UDBG2, "--uf_process_wmm_deliver_ac_uapsd: uapsdactive?=%x\n", srcStaInfo->uapsdActive);
2758 void uf_send_qos_null(unifi_priv_t * priv,u16 interfaceTag, const u8 *da,CSR_PRIORITY priority,CsrWifiRouterCtrlStaInfo_t * srcStaInfo)
2760 bulk_data_param_t bulkdata;
2761 CsrResult csrResult;
2762 struct sk_buff *skb, *newSkb = NULL;
2763 CsrWifiMacAddress peerAddress;
2764 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2765 CSR_TRANSMISSION_CONTROL transmissionControl = (TRANSMISSION_CONTROL_EOSP_MASK | TRANSMISSION_CONTROL_TRIGGER_MASK);
2769 CSR_RATE transmitRate = 0;
2773 /* Send a Null Frame to Peer,
2774 * 32= size of mac header */
2775 csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], MAC_HEADER_SIZE + QOS_CONTROL_HEADER_SIZE);
2777 if (csrResult != CSR_RESULT_SUCCESS) {
2778 unifi_error(priv, " failed to allocate request_data. in uf_send_qos_null func\n");
2781 skb = (struct sk_buff *)(bulkdata.d[0].os_net_buf_ptr);
2783 bulkdata.d[0].os_data_ptr = skb->data;
2784 bulkdata.d[0].os_net_buf_ptr = (unsigned char*)skb;
2785 bulkdata.d[0].net_buf_length = bulkdata.d[0].data_length = skb->len;
2786 bulkdata.d[1].os_data_ptr = NULL;
2787 bulkdata.d[1].os_net_buf_ptr = NULL;
2788 bulkdata.d[1].net_buf_length = bulkdata.d[1].data_length = 0;
2790 /* For null frames protection bit should not be set in MAC header, so passing value 0 below for protection field */
2792 if (prepare_and_add_macheader(priv, skb, newSkb, priority, &bulkdata, interfaceTag, da, interfacePriv->bssid.a, 0)) {
2793 unifi_error(priv, "failed to create MAC header\n");
2794 unifi_net_data_free(priv, &bulkdata.d[0]);
2797 memcpy(peerAddress.a, ((u8 *) bulkdata.d[0].os_data_ptr) + 4, ETH_ALEN);
2798 /* convert priority to queue */
2799 priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY) priority);
2801 /* Frame ma-packet.req, this is saved/transmitted depend on queue state
2802 * send the null frame at data rate of 1 Mb/s for AP or 6 Mb/s for P2PGO
2804 switch (interfacePriv->interfaceMode)
2806 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
2809 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
2815 unifi_frame_ma_packet_req(priv, priority, transmitRate, 0xffffffff, interfaceTag,
2816 transmissionControl, priv->netdev_client->sender_id,
2817 peerAddress.a, &signal);
2819 r = ul_send_signal_unpacked(priv, &signal, &bulkdata);
2821 unifi_error(priv, "failed to send QOS data null packet result: %d\n",r);
2822 unifi_net_data_free(priv, &bulkdata.d[0]);
2829 void uf_send_nulldata(unifi_priv_t * priv,u16 interfaceTag, const u8 *da,CSR_PRIORITY priority,CsrWifiRouterCtrlStaInfo_t * srcStaInfo)
2831 bulk_data_param_t bulkdata;
2832 CsrResult csrResult;
2833 struct sk_buff *skb, *newSkb = NULL;
2834 CsrWifiMacAddress peerAddress;
2835 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2836 CSR_TRANSMISSION_CONTROL transmissionControl = 0;
2840 CSR_RATE transmitRate = 0;
2841 CSR_MA_PACKET_REQUEST *req = &signal.u.MaPacketRequest;
2842 unsigned long lock_flags;
2845 /* Send a Null Frame to Peer, size = 24 for MAC header */
2846 csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], MAC_HEADER_SIZE);
2848 if (csrResult != CSR_RESULT_SUCCESS) {
2849 unifi_error(priv, "uf_send_nulldata: Failed to allocate memory for NULL frame\n");
2852 skb = (struct sk_buff *)(bulkdata.d[0].os_net_buf_ptr);
2854 bulkdata.d[0].os_data_ptr = skb->data;
2855 bulkdata.d[0].os_net_buf_ptr = (unsigned char*)skb;
2856 bulkdata.d[0].net_buf_length = bulkdata.d[0].data_length = skb->len;
2857 bulkdata.d[1].os_data_ptr = NULL;
2858 bulkdata.d[1].os_net_buf_ptr = NULL;
2859 bulkdata.d[1].net_buf_length = bulkdata.d[1].data_length = 0;
2861 /* For null frames protection bit should not be set in MAC header, so passing value 0 below for protection field */
2862 if (prepare_and_add_macheader(priv, skb, newSkb, priority, &bulkdata, interfaceTag, da, interfacePriv->bssid.a, 0)) {
2863 unifi_error(priv, "uf_send_nulldata: Failed to create MAC header\n");
2864 unifi_net_data_free(priv, &bulkdata.d[0]);
2867 memcpy(peerAddress.a, ((u8 *) bulkdata.d[0].os_data_ptr) + 4, ETH_ALEN);
2868 /* convert priority to queue */
2869 priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY) priority);
2870 transmissionControl &= ~(CSR_NO_CONFIRM_REQUIRED);
2872 /* Frame ma-packet.req, this is saved/transmitted depend on queue state
2873 * send the null frame at data rate of 1 Mb/s for AP or 6 Mb/s for P2PGO
2875 switch (interfacePriv->interfaceMode)
2877 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
2880 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
2886 unifi_frame_ma_packet_req(priv, priority, transmitRate, INVALID_HOST_TAG, interfaceTag,
2887 transmissionControl, priv->netdev_client->sender_id,
2888 peerAddress.a, &signal);
2890 /* Save host tag to check the status on reception of MA packet confirm */
2891 srcStaInfo->nullDataHostTag = req->HostTag;
2892 unifi_trace(priv, UDBG1, "uf_send_nulldata: STA AID = %d hostTag = %x\n", srcStaInfo->aid, req->HostTag);
2894 r = ul_send_signal_unpacked(priv, &signal, &bulkdata);
2897 unifi_trace(priv, UDBG1, "uf_send_nulldata: ENOSPC Requeue the Null frame\n");
2898 enque_tx_data_pdu(priv, &bulkdata, &srcStaInfo->dataPdu[priority_q], &signal, 1);
2899 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2900 srcStaInfo->noOfPktQueued++;
2901 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2905 if(r && r != -ENOSPC){
2906 unifi_error(priv, "uf_send_nulldata: Failed to send Null frame Error = %d\n",r);
2907 unifi_net_data_free(priv, &bulkdata.d[0]);
2908 srcStaInfo->nullDataHostTag = INVALID_HOST_TAG;
2915 u8 uf_check_broadcast_bssid(unifi_priv_t *priv, const bulk_data_param_t *bulkdata)
2918 static const CsrWifiMacAddress broadcast_address = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
2921 toDs = (((bulkdata->d[0].os_data_ptr)[1]) & 0x01) ? 1 : 0;
2922 fromDs =(((bulkdata->d[0].os_data_ptr)[1]) & 0x02) ? 1 : 0;
2926 unifi_trace(priv, UDBG6, "Address 4 present, Don't try to find BSSID\n");
2929 else if((toDs == 0) && (fromDs ==0))
2931 /* BSSID is Address 3 */
2932 bssid = (u8 *) (bulkdata->d[0].os_data_ptr + 4 + (2 * ETH_ALEN));
2936 /* BSSID is Address 1 */
2937 bssid = (u8 *) (bulkdata->d[0].os_data_ptr + 4);
2941 /* BSSID is Address 2 */
2942 bssid = (u8 *) (bulkdata->d[0].os_data_ptr + 4 + ETH_ALEN);
2945 if (memcmp(broadcast_address.a, bssid, ETH_ALEN)== 0)
2956 u8 uf_process_pm_bit_for_peer(unifi_priv_t * priv, CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
2957 u8 pmBit,u16 interfaceTag)
2959 u8 moreData = FALSE;
2960 u8 powerSaveChanged = FALSE;
2961 unsigned long lock_flags;
2963 unifi_trace(priv, UDBG3, "entering uf_process_pm_bit_for_peer\n");
2965 priv->allPeerDozing |= (0x01 << (srcStaInfo->assignedHandle));
2967 priv->allPeerDozing &= ~(0x01 << (srcStaInfo->assignedHandle));
2970 if(srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE) {
2972 /* disable the preemption */
2973 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2974 srcStaInfo->currentPeerState =CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE;
2975 powerSaveChanged = TRUE;
2976 /* enable the preemption */
2977 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2979 return powerSaveChanged;
2982 if(srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE) {
2983 /* disable the preemption */
2984 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2985 srcStaInfo->currentPeerState = CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE;
2986 powerSaveChanged = TRUE;
2987 /* enable the preemption */
2988 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2990 return powerSaveChanged;
2995 if(srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE) {
2996 unifi_trace(priv,UDBG3, "Peer with AID = %d is active now\n",srcStaInfo->aid);
2997 process_peer_active_transition(priv,srcStaInfo,interfaceTag);
2999 unifi_trace(priv,UDBG3, "Peer with AID = %d is in PS Now\n",srcStaInfo->aid);
3000 /* Set TIM if needed */
3001 if(!srcStaInfo->wmmOrQosEnabled) {
3002 moreData = (!list_empty(&srcStaInfo->mgtFrames) ||
3003 !list_empty(&srcStaInfo->dataPdu[UNIFI_TRAFFIC_Q_VO])||
3004 !list_empty(&srcStaInfo->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]));
3005 if(moreData && (srcStaInfo->timSet == CSR_WIFI_TIM_RESET)) {
3006 unifi_trace(priv, UDBG3, "This condition should not occur\n");
3007 if (!srcStaInfo->timRequestPendingFlag){
3008 update_tim(priv,srcStaInfo->aid,1,interfaceTag, srcStaInfo->assignedHandle);
3012 /* Cache the TimSet value so that it will processed immidiatly after
3013 * completing the current setTim Request
3015 srcStaInfo->updateTimReqQueued = 1;
3016 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", srcStaInfo->updateTimReqQueued,
3022 u8 allDeliveryEnabled = 0, dataAvailable = 0;
3023 unifi_trace(priv, UDBG5, "Qos in AP Mode\n");
3024 /* Check if all AC's are Delivery Enabled */
3025 is_all_ac_deliver_enabled_and_moredata(srcStaInfo, &allDeliveryEnabled, &dataAvailable);
3026 /*check for more data in non-delivery enabled queues*/
3027 moreData = (uf_is_more_data_for_non_delivery_ac(srcStaInfo) || (allDeliveryEnabled && dataAvailable));
3029 if(moreData && (srcStaInfo->timSet == CSR_WIFI_TIM_RESET)) {
3030 if (!srcStaInfo->timRequestPendingFlag){
3031 update_tim(priv,srcStaInfo->aid,1,interfaceTag, srcStaInfo->assignedHandle);
3035 /* Cache the TimSet value so that it will processed immidiatly after
3036 * completing the current setTim Request
3038 srcStaInfo->updateTimReqQueued = 1;
3039 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", srcStaInfo->updateTimReqQueued,
3045 unifi_trace(priv, UDBG3, "leaving uf_process_pm_bit_for_peer\n");
3046 return powerSaveChanged;
3051 void uf_process_ps_poll(unifi_priv_t *priv,u8* sa,u8* da,u8 pmBit,u16 interfaceTag)
3053 CsrWifiRouterCtrlStaInfo_t *staRecord =
3054 CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, sa, interfaceTag);
3055 tx_buffered_packets_t * buffered_pkt = NULL;
3056 CsrWifiMacAddress peerMacAddress;
3057 unsigned long lock_flags;
3059 u8 moreData = FALSE;
3060 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
3062 unifi_trace(priv, UDBG3, "entering uf_process_ps_poll\n");
3064 memcpy(peerMacAddress.a,sa,ETH_ALEN);
3065 unifi_trace(priv, UDBG3, "In uf_process_ps_poll, sta record not found:unexpected frame addr = %x:%x:%x:%x:%x:%x\n",
3066 sa[0], sa[1],sa[2], sa[3], sa[4],sa[5]);
3067 CsrWifiRouterCtrlUnexpectedFrameIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,0,interfaceTag,peerMacAddress);
3071 uf_process_pm_bit_for_peer(priv,staRecord,pmBit,interfaceTag);
3073 /* Update station last activity time */
3074 staRecord->activity_flag = TRUE;
3076 /* This should not change the PM bit as PS-POLL has PM bit always set */
3078 unifi_notice (priv," PM bit reset in PS-POLL\n");
3082 if(IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag)) {
3083 /* giving more priority to multicast packets so dropping ps-poll*/
3084 unifi_notice (priv," multicast transmission is going on so don't take action on PS-POLL\n");
3088 if(!staRecord->wmmOrQosEnabled) {
3089 if((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->mgtFrames))) {
3090 buffered_pkt->transmissionControl |= TRANSMISSION_CONTROL_TRIGGER_MASK;
3091 moreData = (!list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]) ||
3092 !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]) ||
3093 !list_empty(&staRecord->mgtFrames));
3095 buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3096 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staRecord,moreData,FALSE)) == -ENOSPC) {
3097 /* Clear the trigger bit transmission control*/
3098 buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3099 /* Enqueue at the head of the queue */
3100 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3101 list_add(&buffered_pkt->q, &staRecord->mgtFrames);
3102 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3103 unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
3104 priv->pausedStaHandle[3]=(u8)(staRecord->assignedHandle);
3107 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3108 /* the PDU failed where we can't do any thing so free the storage */
3109 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3111 kfree(buffered_pkt);
3113 } else if((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]))) {
3114 buffered_pkt->transmissionControl |= TRANSMISSION_CONTROL_TRIGGER_MASK;
3115 moreData = (!list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]) ||
3116 !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]));
3118 buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3119 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staRecord,moreData,FALSE)) == -ENOSPC) {
3120 /* Clear the trigger bit transmission control*/
3121 buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3122 /* Enqueue at the head of the queue */
3123 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3124 list_add(&buffered_pkt->q, &staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]);
3125 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3126 priv->pausedStaHandle[3]=(u8)(staRecord->assignedHandle);
3127 unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
3130 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3131 /* the PDU failed where we can't do any thing so free the storage */
3132 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3134 kfree(buffered_pkt);
3136 } else if((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]))) {
3137 buffered_pkt->transmissionControl |= TRANSMISSION_CONTROL_TRIGGER_MASK;
3138 moreData = !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]);
3140 buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3141 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staRecord,moreData,FALSE)) == -ENOSPC) {
3142 /* Clear the trigger bit transmission control*/
3143 buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3144 /* Enqueue at the head of the queue */
3145 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3146 list_add(&buffered_pkt->q, &staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]);
3147 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3148 priv->pausedStaHandle[0]=(u8)(staRecord->assignedHandle);
3149 unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
3152 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3153 /* the PDU failed where we can't do any thing so free the storage */
3154 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3156 kfree(buffered_pkt);
3159 /* Actually since we have sent an ACK, there
3160 * there is no need to send a NULL frame*/
3162 moreData = (!list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]) ||
3163 !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]) ||
3164 !list_empty(&staRecord->mgtFrames));
3165 if(!moreData && (staRecord->timSet == CSR_WIFI_TIM_SET)) {
3166 unifi_trace(priv, UDBG3, "more data = NULL, set tim to 0 in uf_process_ps_poll\n");
3167 if (!staRecord->timRequestPendingFlag){
3168 update_tim(priv,staRecord->aid,0,interfaceTag, staRecord->assignedHandle);
3172 /* Cache the TimSet value so that it will processed immidiatly after
3173 * completing the current setTim Request
3175 staRecord->updateTimReqQueued = 0;
3176 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
3182 u8 allDeliveryEnabled = 0, dataAvailable = 0;
3183 unifi_trace(priv, UDBG3,"Qos Support station.Processing PS-Poll\n");
3185 /*Send Data From Management Frames*/
3186 /* Priority orders for delivering the buffered packets are
3187 * 1. Deliver the Management frames if there
3188 * 2. Other access catagory frames which are non deliver enable including UNIFI_TRAFFIC_Q_VO
3189 * priority is from VO->BK
3192 /* Check if all AC's are Delivery Enabled */
3193 is_all_ac_deliver_enabled_and_moredata(staRecord, &allDeliveryEnabled, &dataAvailable);
3195 if (allDeliveryEnabled) {
3196 unifi_trace(priv, UDBG3, "uf_process_ps_poll: All ACs are delivery enable so Sending QOS Null in response of Ps-poll\n");
3197 uf_send_qos_null(priv,interfaceTag,sa,CSR_QOS_UP0,staRecord);
3201 if (!list_empty(&staRecord->mgtFrames)) {
3202 if ((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->mgtFrames))) {
3203 /* We dont have packets in non delivery enabled UNIFI_TRAFFIC_Q_VO, So we are looking in management
3204 * queue of the station record
3206 moreData = uf_is_more_data_for_non_delivery_ac(staRecord);
3207 buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3209 /* Last parameter is EOSP & its false always for PS-POLL processing */
3210 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staRecord,moreData,FALSE)) == -ENOSPC) {
3211 /* Clear the trigger bit transmission control*/
3212 buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3213 /* Enqueue at the head of the queue */
3214 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3215 list_add(&buffered_pkt->q, &staRecord->mgtFrames);
3216 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3217 priv->pausedStaHandle[0]=(u8)(staRecord->assignedHandle);
3218 unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
3221 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3222 /* the PDU failed where we can't do any thing so free the storage */
3223 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3225 kfree(buffered_pkt);
3228 unifi_error(priv, "uf_process_ps_poll: Mgt frame list empty!! \n");
3233 /* We dont have buffered packet in mangement frame queue (1 failed), So proceed with condition 2
3234 * UNIFI_TRAFFIC_Q_VO -> VI -> BE -> BK
3236 for(i= 3; i>=0; i--) {
3237 if (!IS_DELIVERY_ENABLED(staRecord->powersaveMode[i])) {
3238 /* Send One packet, if queue is NULL then continue */
3239 if((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->dataPdu[i]))) {
3240 moreData = uf_is_more_data_for_non_delivery_ac(staRecord);
3242 buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3244 /* Last parameter is EOSP & its false always for PS-POLL processing */
3245 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staRecord,moreData,FALSE)) == -ENOSPC) {
3246 /* Clear the trigger bit transmission control*/
3247 buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3248 /* Enqueue at the head of the queue */
3249 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3250 list_add(&buffered_pkt->q, &staRecord->dataPdu[i]);
3251 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3252 priv->pausedStaHandle[0]=(u8)(staRecord->assignedHandle);
3253 unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
3256 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3257 /* the PDU failed where we can't do any thing so free the storage */
3258 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3260 kfree(buffered_pkt);
3267 /* Check if all AC's are Delivery Enabled */
3268 is_all_ac_deliver_enabled_and_moredata(staRecord, &allDeliveryEnabled, &dataAvailable);
3269 /*check for more data in non-delivery enabled queues*/
3270 moreData = (uf_is_more_data_for_non_delivery_ac(staRecord) || (allDeliveryEnabled && dataAvailable));
3271 if(!moreData && (staRecord->timSet == CSR_WIFI_TIM_SET)) {
3272 unifi_trace(priv, UDBG3, "more data = NULL, set tim to 0 in uf_process_ps_poll\n");
3273 if (!staRecord->timRequestPendingFlag){
3274 update_tim(priv,staRecord->aid,0,interfaceTag, staRecord->assignedHandle);
3278 /* Cache the TimSet value so that it will processed immidiatly after
3279 * completing the current setTim Request
3281 staRecord->updateTimReqQueued = 0;
3282 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
3289 unifi_trace(priv, UDBG3, "leaving uf_process_ps_poll\n");
3294 void add_to_send_cfm_list(unifi_priv_t * priv,
3295 tx_buffered_packets_t *tx_q_item,
3296 struct list_head *frames_need_cfm_list)
3298 tx_buffered_packets_t *send_cfm_list_item = NULL;
3300 send_cfm_list_item = (tx_buffered_packets_t *) kmalloc(sizeof(tx_buffered_packets_t), GFP_ATOMIC);
3302 if(send_cfm_list_item == NULL){
3303 unifi_warning(priv, "%s: Failed to allocate memory for new list item \n");
3307 INIT_LIST_HEAD(&send_cfm_list_item->q);
3309 send_cfm_list_item->hostTag = tx_q_item->hostTag;
3310 send_cfm_list_item->interfaceTag = tx_q_item->interfaceTag;
3311 send_cfm_list_item->transmissionControl = tx_q_item->transmissionControl;
3312 send_cfm_list_item->leSenderProcessId = tx_q_item->leSenderProcessId;
3313 send_cfm_list_item->rate = tx_q_item->rate;
3314 memcpy(send_cfm_list_item->peerMacAddress.a, tx_q_item->peerMacAddress.a, ETH_ALEN);
3315 send_cfm_list_item->priority = tx_q_item->priority;
3317 list_add_tail(&send_cfm_list_item->q, frames_need_cfm_list);
3320 void uf_prepare_send_cfm_list_for_queued_pkts(unifi_priv_t * priv,
3321 struct list_head *frames_need_cfm_list,
3322 struct list_head * list)
3324 tx_buffered_packets_t *tx_q_item = NULL;
3325 struct list_head *listHead;
3326 struct list_head *placeHolder;
3327 unsigned long lock_flags;
3331 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3333 /* Search through the list and if confirmation required for any frames,
3334 add it to the send_cfm list */
3335 list_for_each_safe(listHead, placeHolder, list) {
3336 tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
3339 unifi_error(priv, "Entry should exist, otherwise it is a (BUG)\n");
3343 /* check if confirmation is requested and if the sender ID
3344 is not netdevice client then save the entry in the list for need cfms */
3345 if (!(tx_q_item->transmissionControl & CSR_NO_CONFIRM_REQUIRED) &&
3346 (tx_q_item->leSenderProcessId != priv->netdev_client->sender_id)){
3347 unifi_trace(priv, UDBG1, "%s: SenderProcessID=%x host tag=%x transmission control=%x\n",
3349 tx_q_item->leSenderProcessId,
3351 tx_q_item->transmissionControl);
3353 add_to_send_cfm_list(priv, tx_q_item, frames_need_cfm_list);
3357 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3364 void uf_flush_list(unifi_priv_t * priv, struct list_head * list)
3366 tx_buffered_packets_t *tx_q_item;
3367 struct list_head *listHead;
3368 struct list_head *placeHolder;
3369 unsigned long lock_flags;
3371 unifi_trace(priv, UDBG5, "entering the uf_flush_list \n");
3373 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3374 /* go through list, delete & free memory */
3375 list_for_each_safe(listHead, placeHolder, list) {
3376 tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
3379 unifi_error(priv, "entry should exists, otherwise crashes (bug)\n");
3381 unifi_trace(priv, UDBG5,
3382 "proccess_tx: in uf_flush_list peerMacAddress=%02X%02X%02X%02X%02X%02X senderProcessId=%x\n",
3383 tx_q_item->peerMacAddress.a[0], tx_q_item->peerMacAddress.a[1],
3384 tx_q_item->peerMacAddress.a[2], tx_q_item->peerMacAddress.a[3],
3385 tx_q_item->peerMacAddress.a[4], tx_q_item->peerMacAddress.a[5],
3386 tx_q_item->leSenderProcessId);
3389 /* free the allocated memory */
3390 unifi_net_data_free(priv, &tx_q_item->bulkdata);
3393 if (!priv->noOfPktQueuedInDriver) {
3394 unifi_error(priv, "packets queued in driver 0 still decrementing in %s\n", __FUNCTION__);
3396 priv->noOfPktQueuedInDriver--;
3399 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3402 tx_buffered_packets_t *dequeue_tx_data_pdu(unifi_priv_t *priv, struct list_head *txList)
3404 /* dequeue the tx data packets from the appropriate queue */
3405 tx_buffered_packets_t *tx_q_item = NULL;
3406 struct list_head *listHead;
3407 struct list_head *placeHolder;
3408 unsigned long lock_flags;
3410 unifi_trace(priv, UDBG5, "entering dequeue_tx_data_pdu\n");
3411 /* check for list empty */
3412 if (list_empty(txList)) {
3413 unifi_trace(priv, UDBG5, "In dequeue_tx_data_pdu, the list is empty\n");
3417 /* Verification, if packet count is negetive */
3418 if (priv->noOfPktQueuedInDriver == 0xFFFF) {
3419 unifi_warning(priv, "no packet available in queue: debug");
3423 /* return first node after header, & delete from the list && atleast one item exist */
3424 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3425 list_for_each_safe(listHead, placeHolder, txList) {
3426 tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
3430 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3433 unifi_trace(priv, UDBG5,
3434 "proccess_tx: In dequeue_tx_data_pdu peerMacAddress=%02X%02X%02X%02X%02X%02X senderProcessId=%x\n",
3435 tx_q_item->peerMacAddress.a[0], tx_q_item->peerMacAddress.a[1],
3436 tx_q_item->peerMacAddress.a[2], tx_q_item->peerMacAddress.a[3],
3437 tx_q_item->peerMacAddress.a[4], tx_q_item->peerMacAddress.a[5],
3438 tx_q_item->leSenderProcessId);
3441 unifi_trace(priv, UDBG5, "leaving dequeue_tx_data_pdu\n");
3444 /* generic function to get the station record handler */
3445 CsrWifiRouterCtrlStaInfo_t *CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(unifi_priv_t *priv,
3446 const u8 *peerMacAddress,
3450 netInterface_priv_t *interfacePriv;
3451 unsigned long lock_flags;
3453 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
3454 unifi_error(priv, "interfaceTag is not proper, interfaceTag = %d\n", interfaceTag);
3458 interfacePriv = priv->interfacePriv[interfaceTag];
3460 /* disable the preemption untill station record is fetched */
3461 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
3463 for (i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
3464 if (interfacePriv->staInfo[i]!= NULL) {
3465 if (!memcmp(((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[i]))->peerMacAddress.a, peerMacAddress, ETH_ALEN)) {
3466 /* enable the preemption as station record is fetched */
3467 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
3468 unifi_trace(priv, UDBG5, "peer entry found in station record\n");
3469 return ((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[i]));
3473 /* enable the preemption as station record is fetched */
3474 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
3475 unifi_trace(priv, UDBG5, "peer entry not found in station record\n");
3478 /* generic function to get the station record handler from the handle */
3479 CsrWifiRouterCtrlStaInfo_t * CsrWifiRouterCtrlGetStationRecordFromHandle(unifi_priv_t *priv,
3483 netInterface_priv_t *interfacePriv;
3485 if ((handle >= UNIFI_MAX_CONNECTIONS) || (interfaceTag >= CSR_WIFI_NUM_INTERFACES)) {
3486 unifi_error(priv, "handle/interfaceTag is not proper, handle = %d, interfaceTag = %d\n", handle, interfaceTag);
3489 interfacePriv = priv->interfacePriv[interfaceTag];
3490 return ((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[handle]));
3493 /* Function to do inactivity */
3494 void uf_check_inactivity(unifi_priv_t *priv, u16 interfaceTag, u32 currentTime)
3497 CsrWifiRouterCtrlStaInfo_t *staInfo;
3498 u32 elapsedTime; /* Time in microseconds */
3499 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
3500 CsrWifiMacAddress peerMacAddress;
3501 unsigned long lock_flags;
3503 if (interfacePriv == NULL) {
3504 unifi_trace(priv, UDBG3, "uf_check_inactivity: Interface priv is NULL \n");
3508 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
3509 /* Go through the list of stations to check for inactivity */
3510 for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
3511 staInfo = CsrWifiRouterCtrlGetStationRecordFromHandle(priv, i, interfaceTag);
3516 unifi_trace(priv, UDBG3, "Running Inactivity handler Time %xus station's last activity %xus\n",
3517 currentTime, staInfo->lastActivity);
3520 elapsedTime = (currentTime >= staInfo->lastActivity)?
3521 (currentTime - staInfo->lastActivity):
3522 (~((u32)0) - staInfo->lastActivity + currentTime);
3523 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
3525 if (elapsedTime > MAX_INACTIVITY_INTERVAL) {
3526 memcpy((u8*)&peerMacAddress, (u8*)&staInfo->peerMacAddress, sizeof(CsrWifiMacAddress));
3528 /* Indicate inactivity for the station */
3529 unifi_trace(priv, UDBG3, "Station %x:%x:%x:%x:%x:%x inactive since %xus\n sending Inactive Ind\n",
3530 peerMacAddress.a[0], peerMacAddress.a[1],
3531 peerMacAddress.a[2], peerMacAddress.a[3],
3532 peerMacAddress.a[4], peerMacAddress.a[5],
3535 CsrWifiRouterCtrlStaInactiveIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, peerMacAddress);
3539 interfacePriv->last_inactivity_check = currentTime;
3542 /* Function to update activity of a station */
3543 void uf_update_sta_activity(unifi_priv_t *priv, u16 interfaceTag, const u8 *peerMacAddress)
3545 u32 elapsedTime, currentTime; /* Time in microseconds */
3546 u32 timeHi; /* Not used - Time in microseconds */
3547 CsrWifiRouterCtrlStaInfo_t *staInfo;
3548 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
3549 unsigned long lock_flags;
3551 if (interfacePriv == NULL) {
3552 unifi_trace(priv, UDBG3, "uf_check_inactivity: Interface priv is NULL \n");
3556 currentTime = CsrTimeGet(&timeHi);
3559 staInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, peerMacAddress, interfaceTag);
3561 if (staInfo == NULL) {
3562 unifi_trace(priv, UDBG4, "Sta does not exist yet");
3566 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
3567 /* Update activity */
3568 staInfo->lastActivity = currentTime;
3570 /* See if inactivity handler needs to be run
3571 * Here it is theoretically possible that the counter may have wrapped around. But
3572 * since we just want to know when to run the inactivity handler it does not really matter.
3573 * Especially since this is data path it makes sense in keeping it simple and avoiding
3574 * 64 bit handling */
3575 elapsedTime = (currentTime >= interfacePriv->last_inactivity_check)?
3576 (currentTime - interfacePriv->last_inactivity_check):
3577 (~((u32)0) - interfacePriv->last_inactivity_check + currentTime);
3579 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
3581 /* Check if it is time to run the inactivity handler */
3582 if (elapsedTime > INACTIVITY_CHECK_INTERVAL) {
3583 uf_check_inactivity(priv, interfaceTag, currentTime);
3586 void resume_unicast_buffered_frames(unifi_priv_t *priv, u16 interfaceTag)
3589 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
3592 tx_buffered_packets_t * buffered_pkt = NULL;
3593 u8 hipslotFree[4] = {TRUE,TRUE,TRUE,TRUE};
3595 unsigned long lock_flags;
3598 while(!isRouterBufferEnabled(priv,3) &&
3599 ((buffered_pkt=dequeue_tx_data_pdu(priv,&interfacePriv->genericMgtFrames))!=NULL)) {
3600 buffered_pkt->transmissionControl &=
3601 ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
3602 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,NULL,0,FALSE)) == -ENOSPC) {
3603 /* Enqueue at the head of the queue */
3604 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3605 list_add(&buffered_pkt->q, &interfacePriv->genericMgtFrames);
3606 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3607 hipslotFree[3]=FALSE;
3611 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3612 /* the PDU failed where we can't do any thing so free the storage */
3613 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3615 kfree(buffered_pkt);
3618 for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
3619 CsrWifiRouterCtrlStaInfo_t *staInfo = interfacePriv->staInfo[i];
3620 if(!hipslotFree[0] && !hipslotFree[1] && !hipslotFree[2] && !hipslotFree[3]) {
3621 unifi_trace(priv, UDBG3, "(ENOSPC) in resume_unicast_buffered_frames:: hip slots are full \n");
3624 if (staInfo && (staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE)) {
3625 while((( TRUE == hipslotFree[3] ) && (buffered_pkt=dequeue_tx_data_pdu(priv, &staInfo->mgtFrames)))) {
3626 buffered_pkt->transmissionControl &=
3627 ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
3628 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staInfo,0,FALSE)) == -ENOSPC) {
3629 unifi_trace(priv, UDBG3, "(ENOSPC) in resume_unicast_buffered_frames:: hip slots are full for voice queue\n");
3630 /* Enqueue at the head of the queue */
3631 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3632 list_add(&buffered_pkt->q, &staInfo->mgtFrames);
3633 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3634 priv->pausedStaHandle[3]=(u8)(staInfo->assignedHandle);
3635 hipslotFree[3] = FALSE;
3639 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3640 /* the PDU failed where we can't do any thing so free the storage */
3641 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3643 kfree(buffered_pkt);
3651 while((buffered_pkt=dequeue_tx_data_pdu(priv, &staInfo->dataPdu[j]))) {
3652 buffered_pkt->transmissionControl &=
3653 ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
3654 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staInfo,0,FALSE)) == -ENOSPC) {
3655 /* Enqueue at the head of the queue */
3656 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3657 list_add(&buffered_pkt->q, &staInfo->dataPdu[j]);
3658 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3659 priv->pausedStaHandle[j]=(u8)(staInfo->assignedHandle);
3660 hipslotFree[j]=FALSE;
3664 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3665 /* the PDU failed where we can't do any thing so free the storage */
3666 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3668 kfree(buffered_pkt);
3676 void update_eosp_to_head_of_broadcast_list_head(unifi_priv_t *priv,u16 interfaceTag)
3679 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
3680 unsigned long lock_flags;
3681 struct list_head *listHead;
3682 struct list_head *placeHolder;
3683 tx_buffered_packets_t *tx_q_item;
3686 if (interfacePriv->noOfbroadcastPktQueued) {
3688 /* Update the EOSP to the HEAD of b/c list
3689 * beacuse we have received any mgmt packet so it should not hold for long time
3690 * peer may time out.
3692 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3693 list_for_each_safe(listHead, placeHolder, &interfacePriv->genericMulticastOrBroadCastFrames) {
3694 tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
3695 tx_q_item->transmissionControl |= TRANSMISSION_CONTROL_EOSP_MASK;
3696 tx_q_item->transmissionControl = (tx_q_item->transmissionControl & ~(CSR_NO_CONFIRM_REQUIRED));
3697 unifi_trace(priv, UDBG1,"updating eosp for list Head hostTag:= 0x%x ",tx_q_item->hostTag);
3700 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3706 * ---------------------------------------------------------------------------
3707 * resume_suspended_uapsd
3709 * This function takes care processing packets of Unscheduled Service Period,
3710 * which been suspended earlier due to DTIM/HIP ENOSPC scenarios
3713 * priv Pointer to device private context struct
3714 * interfaceTag For which resume should happen
3715 * ---------------------------------------------------------------------------
3717 void resume_suspended_uapsd(unifi_priv_t* priv,u16 interfaceTag)
3721 CsrWifiRouterCtrlStaInfo_t * staInfo = NULL;
3722 unsigned long lock_flags;
3724 unifi_trace(priv, UDBG2, "++resume_suspended_uapsd: \n");
3725 for(startIndex= 0; startIndex < UNIFI_MAX_CONNECTIONS;startIndex++) {
3726 staInfo = CsrWifiRouterCtrlGetStationRecordFromHandle(priv,startIndex,interfaceTag);
3728 if(!staInfo || !staInfo->wmmOrQosEnabled) {
3730 } else if((staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)
3731 &&staInfo->uapsdActive && staInfo->uspSuspend) {
3732 /* U-APSD Still active & previously suspended either ENOSPC of FH queues OR
3733 * due to DTIM activity
3735 uf_handle_uspframes_delivery(priv, staInfo, interfaceTag);
3737 unifi_trace(priv, UDBG2, "resume_suspended_uapsd: PS state=%x, uapsdActive?=%x, suspend?=%x\n",
3738 staInfo->currentPeerState, staInfo->uapsdActive, staInfo->uspSuspend);
3739 if (staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE)
3741 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
3742 staInfo->uapsdActive = FALSE;
3743 staInfo->uspSuspend = FALSE;
3744 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
3748 unifi_trace(priv, UDBG2, "--resume_suspended_uapsd:\n");