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/version.h>
18 #include <linux/types.h>
19 #include <linux/etherdevice.h>
20 #include <linux/vmalloc.h>
22 #include "csr_wifi_hip_unifi.h"
23 #include "csr_wifi_hip_conversions.h"
25 #include "unifi_priv.h"
26 #include <net/pkt_sched.h>
28 #ifdef CSR_SUPPORT_SME
29 static void _update_buffered_pkt_params_after_alignment(unifi_priv_t *priv, bulk_data_param_t *bulkdata,
30 tx_buffered_packets_t* buffered_pkt)
35 if (priv == NULL || bulkdata == NULL || buffered_pkt == NULL){
39 skb = (struct sk_buff*)bulkdata->d[0].os_net_buf_ptr;
40 align_offset = (u32)(long)(bulkdata->d[0].os_data_ptr) & (CSR_WIFI_ALIGN_BYTES-1);
42 skb_pull(skb,align_offset);
45 buffered_pkt->bulkdata.os_data_ptr = bulkdata->d[0].os_data_ptr;
46 buffered_pkt->bulkdata.data_length = bulkdata->d[0].data_length;
47 buffered_pkt->bulkdata.os_net_buf_ptr = bulkdata->d[0].os_net_buf_ptr;
48 buffered_pkt->bulkdata.net_buf_length = bulkdata->d[0].net_buf_length;
53 unifi_frame_ma_packet_req(unifi_priv_t *priv, CSR_PRIORITY priority,
54 CSR_RATE TransmitRate, CSR_CLIENT_TAG hostTag,
55 u16 interfaceTag, CSR_TRANSMISSION_CONTROL transmissionControl,
56 CSR_PROCESS_ID leSenderProcessId, u8 *peerMacAddress,
60 CSR_MA_PACKET_REQUEST *req = &signal->u.MaPacketRequest;
61 netInterface_priv_t *interfacePriv;
62 u8 ba_session_idx = 0;
63 ba_session_tx_struct *ba_session = NULL;
66 interfacePriv = priv->interfacePriv[interfaceTag];
68 unifi_trace(priv, UDBG5,
69 "In unifi_frame_ma_packet_req, Frame for Peer: %pMF\n",
71 signal->SignalPrimitiveHeader.SignalId = CSR_MA_PACKET_REQUEST_ID;
72 signal->SignalPrimitiveHeader.ReceiverProcessId = 0;
73 signal->SignalPrimitiveHeader.SenderProcessId = leSenderProcessId;
75 /* Fill the MA-PACKET.req */
76 req->Priority = priority;
77 unifi_trace(priv, UDBG3, "Tx Frame with Priority: 0x%x\n", req->Priority);
79 /* A value of 0 is used for auto selection of rates. But for P2P GO case
80 * for action frames the rate is governed by SME. Hence instead of 0,
81 * the rate is filled in with the value passed here
83 req->TransmitRate = TransmitRate;
85 /* packets from netdev then no confirm required but packets from
86 * Nme/Sme eapol data frames requires the confirmation
88 req->TransmissionControl = transmissionControl;
89 req->VirtualInterfaceIdentifier =
90 uf_get_vif_identifier(interfacePriv->interfaceMode,interfaceTag);
91 memcpy(req->Ra.x, peerMacAddress, ETH_ALEN);
93 if (hostTag == 0xffffffff) {
94 req->HostTag = interfacePriv->tag++;
95 req->HostTag |= 0x40000000;
96 unifi_trace(priv, UDBG3, "new host tag assigned = 0x%x\n", req->HostTag);
97 interfacePriv->tag &= 0x0fffffff;
99 req->HostTag = hostTag;
100 unifi_trace(priv, UDBG3, "host tag got from SME = 0x%x\n", req->HostTag);
102 /* check if BA session exists for the peer MAC address on same tID */
103 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
104 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO){
105 ba_addr = peerMacAddress;
107 ba_addr = interfacePriv->bssid.a;
109 for (ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_TX; ba_session_idx++){
110 ba_session = interfacePriv->ba_session_tx[ba_session_idx];
112 if ((!memcmp(ba_session->macAddress.a, ba_addr, ETH_ALEN)) && (ba_session->tID == priority)){
113 req->TransmissionControl |= CSR_ALLOW_BA;
119 unifi_trace(priv, UDBG5, "leaving unifi_frame_ma_packet_req\n");
122 #ifdef CSR_SUPPORT_SME
124 #define TRANSMISSION_CONTROL_TRIGGER_MASK 0x0001
125 #define TRANSMISSION_CONTROL_EOSP_MASK 0x0002
128 int frame_and_send_queued_pdu(unifi_priv_t* priv,tx_buffered_packets_t* buffered_pkt,
129 CsrWifiRouterCtrlStaInfo_t *staRecord,u8 moreData , u8 eosp)
133 bulk_data_param_t bulkdata;
135 u8 toDs, fromDs, macHeaderLengthInBytes = MAC_HEADER_SIZE;
137 u16 *fc = (u16*)(buffered_pkt->bulkdata.os_data_ptr);
138 unsigned long lock_flags;
139 unifi_trace(priv, UDBG3, "frame_and_send_queued_pdu with moreData: %d , EOSP: %d\n",moreData,eosp);
140 unifi_frame_ma_packet_req(priv, buffered_pkt->priority, buffered_pkt->rate, buffered_pkt->hostTag,
141 buffered_pkt->interfaceTag, buffered_pkt->transmissionControl,
142 buffered_pkt->leSenderProcessId, buffered_pkt->peerMacAddress.a, &signal);
143 bulkdata.d[0].os_data_ptr = buffered_pkt->bulkdata.os_data_ptr;
144 bulkdata.d[0].data_length = buffered_pkt->bulkdata.data_length;
145 bulkdata.d[0].os_net_buf_ptr = buffered_pkt->bulkdata.os_net_buf_ptr;
146 bulkdata.d[0].net_buf_length = buffered_pkt->bulkdata.net_buf_length;
147 bulkdata.d[1].os_data_ptr = NULL;
148 bulkdata.d[1].data_length = 0;
149 bulkdata.d[1].os_net_buf_ptr =0;
150 bulkdata.d[1].net_buf_length =0;
153 *fc |= cpu_to_le16(IEEE802_11_FC_MOREDATA_MASK);
155 *fc &= cpu_to_le16(~IEEE802_11_FC_MOREDATA_MASK);
158 if((staRecord != NULL)&& (staRecord->wmmOrQosEnabled == TRUE))
160 unifi_trace(priv, UDBG3, "frame_and_send_queued_pdu WMM Enabled: %d \n",staRecord->wmmOrQosEnabled);
162 toDs = (*fc & cpu_to_le16(IEEE802_11_FC_TO_DS_MASK))?1 : 0;
163 fromDs = (*fc & cpu_to_le16(IEEE802_11_FC_FROM_DS_MASK))? 1: 0;
165 switch(le16_to_cpu(*fc) & IEEE80211_FC_SUBTYPE_MASK)
167 case IEEE802_11_FC_TYPE_QOS_DATA & IEEE80211_FC_SUBTYPE_MASK:
168 case IEEE802_11_FC_TYPE_QOS_NULL & IEEE80211_FC_SUBTYPE_MASK:
169 /* If both are set then the Address4 exists (only for AP) */
170 if (fromDs && toDs) {
171 /* 6 is the size of Address4 field */
172 macHeaderLengthInBytes += (QOS_CONTROL_HEADER_SIZE + 6);
174 macHeaderLengthInBytes += QOS_CONTROL_HEADER_SIZE;
177 /* If order bit set then HT control field is the part of MAC header */
178 if (*fc & cpu_to_le16(IEEE80211_FC_ORDER_MASK)) {
179 macHeaderLengthInBytes += HT_CONTROL_HEADER_SIZE;
180 qc = (u8*)(buffered_pkt->bulkdata.os_data_ptr + (macHeaderLengthInBytes-6));
182 qc = (u8*)(buffered_pkt->bulkdata.os_data_ptr + (macHeaderLengthInBytes-2));
184 *qc = eosp ? *qc | (1 << 4) : *qc & (~(1 << 4));
188 macHeaderLengthInBytes += 6;
192 result = ul_send_signal_unpacked(priv, &signal, &bulkdata);
194 _update_buffered_pkt_params_after_alignment(priv, &bulkdata,buffered_pkt);
197 /* Decrement the packet counts queued in driver */
198 if (result != -ENOSPC) {
199 /* protect entire counter updation by disabling preemption */
200 if (!priv->noOfPktQueuedInDriver) {
201 unifi_error(priv, "packets queued in driver 0 still decrementing\n");
203 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
204 priv->noOfPktQueuedInDriver--;
205 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
207 /* Sta Record is available for all unicast (except genericMgt Frames) & in other case its NULL */
209 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
210 if (!staRecord->noOfPktQueued) {
211 unifi_error(priv, "packets queued in driver per station is 0 still decrementing\n");
213 staRecord->noOfPktQueued--;
215 /* if the STA alive probe frame has failed then reset the saved host tag */
217 if (staRecord->nullDataHostTag == buffered_pkt->hostTag){
218 staRecord->nullDataHostTag = INVALID_HOST_TAG;
221 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
227 #ifdef CSR_SUPPORT_SME
229 void set_eosp_transmit_ctrl(unifi_priv_t *priv, struct list_head *txList)
231 /* dequeue the tx data packets from the appropriate queue */
232 tx_buffered_packets_t *tx_q_item = NULL;
233 struct list_head *listHead;
234 struct list_head *placeHolder;
235 unsigned long lock_flags;
238 unifi_trace(priv, UDBG5, "entering set_eosp_transmit_ctrl\n");
239 /* check for list empty */
240 if (list_empty(txList)) {
241 unifi_warning(priv, "In set_eosp_transmit_ctrl, the list is empty\n");
245 /* return the last node , and modify it. */
247 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
248 list_for_each_prev_safe(listHead, placeHolder, txList) {
249 tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
250 tx_q_item->transmissionControl |= TRANSMISSION_CONTROL_EOSP_MASK;
251 tx_q_item->transmissionControl = (tx_q_item->transmissionControl & ~(CSR_NO_CONFIRM_REQUIRED));
252 unifi_trace(priv, UDBG1,
253 "set_eosp_transmit_ctrl Transmission Control = 0x%x hostTag = 0x%x \n",tx_q_item->transmissionControl,tx_q_item->hostTag);
254 unifi_trace(priv,UDBG3,"in set_eosp_transmit_ctrl no.of buffered frames %d\n",priv->noOfPktQueuedInDriver);
257 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
258 unifi_trace(priv, UDBG1,"List Empty %d\n",list_empty(txList));
259 unifi_trace(priv, UDBG5, "leaving set_eosp_transmit_ctrl\n");
264 void send_vif_availibility_rsp(unifi_priv_t *priv,CSR_VIF_IDENTIFIER vif,CSR_RESULT_CODE resultCode)
267 CSR_MA_VIF_AVAILABILITY_RESPONSE *rsp;
268 bulk_data_param_t *bulkdata = NULL;
271 unifi_trace(priv, UDBG3, "send_vif_availibility_rsp : invoked with resultCode = %d \n", resultCode);
273 memset(&signal,0,sizeof(CSR_SIGNAL));
274 rsp = &signal.u.MaVifAvailabilityResponse;
275 rsp->VirtualInterfaceIdentifier = vif;
276 rsp->ResultCode = resultCode;
277 signal.SignalPrimitiveHeader.SignalId = CSR_MA_VIF_AVAILABILITY_RESPONSE_ID;
278 signal.SignalPrimitiveHeader.ReceiverProcessId = 0;
279 signal.SignalPrimitiveHeader.SenderProcessId = priv->netdev_client->sender_id;
281 /* Send the signal to UniFi */
282 r = ul_send_signal_unpacked(priv, &signal, bulkdata);
284 unifi_error(priv,"Availibility response sending failed %x status %d\n",vif,r);
287 unifi_trace(priv, UDBG3, "send_vif_availibility_rsp : status = %d \n", r);
293 void verify_and_accomodate_tx_packet(unifi_priv_t *priv)
295 tx_buffered_packets_t *tx_q_item;
296 unsigned long lock_flags;
297 struct list_head *listHead, *list;
298 struct list_head *placeHolder;
299 u8 i, j,eospFramedeleted=0;
300 u8 thresholdExcedeDueToBroadcast = TRUE;
301 /* it will be made it interface Specific in the future when multi interfaces are supported ,
302 right now interface 0 is considered */
303 netInterface_priv_t *interfacePriv = priv->interfacePriv[0];
304 CsrWifiRouterCtrlStaInfo_t *staInfo = NULL;
306 unifi_trace(priv, UDBG3, "entering verify_and_accomodate_tx_packet\n");
308 for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
309 staInfo = interfacePriv->staInfo[i];
310 if (staInfo && (staInfo->noOfPktQueued >= CSR_WIFI_DRIVER_MAX_PKT_QUEUING_THRESHOLD_PER_PEER)) {
311 /* remove the first(oldest) packet from the all the access catogory, since data
312 * packets for station record crossed the threshold limit (64 for AP supporting
315 unifi_trace(priv,UDBG3,"number of station pkts queued= %d for sta id = %d\n", staInfo->noOfPktQueued, staInfo->aid);
316 for(j = 0; j < MAX_ACCESS_CATOGORY; j++) {
317 list = &staInfo->dataPdu[j];
318 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
319 list_for_each_safe(listHead, placeHolder, list) {
320 tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
322 thresholdExcedeDueToBroadcast = FALSE;
323 unifi_net_data_free(priv, &tx_q_item->bulkdata);
326 if (!priv->noOfPktQueuedInDriver) {
327 unifi_error(priv, "packets queued in driver 0 still decrementing in %s\n", __FUNCTION__);
329 /* protection provided by spinlock */
330 priv->noOfPktQueuedInDriver--;
333 /* Sta Record is available for all unicast (except genericMgt Frames) & in other case its NULL */
334 if (!staInfo->noOfPktQueued) {
335 unifi_error(priv, "packets queued in driver per station is 0 still decrementing in %s\n", __FUNCTION__);
337 spin_lock(&priv->staRecord_lock);
338 staInfo->noOfPktQueued--;
339 spin_unlock(&priv->staRecord_lock);
343 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
347 if (thresholdExcedeDueToBroadcast && interfacePriv->noOfbroadcastPktQueued > CSR_WIFI_DRIVER_MINIMUM_BROADCAST_PKT_THRESHOLD ) {
348 /* Remove the packets from genericMulticastOrBroadCastFrames queue
349 * (the max packets in driver is reached due to broadcast/multicast frames)
351 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
352 list_for_each_safe(listHead, placeHolder, &interfacePriv->genericMulticastOrBroadCastFrames) {
353 tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
354 if(eospFramedeleted){
355 tx_q_item->transmissionControl |= TRANSMISSION_CONTROL_EOSP_MASK;
356 tx_q_item->transmissionControl = (tx_q_item->transmissionControl & ~(CSR_NO_CONFIRM_REQUIRED));
357 unifi_trace(priv, UDBG1,"updating eosp for next packet hostTag:= 0x%x ",tx_q_item->hostTag);
362 if(tx_q_item->transmissionControl & TRANSMISSION_CONTROL_EOSP_MASK ){
363 eospFramedeleted = 1;
365 unifi_trace(priv,UDBG1, "freeing of multicast packets ToC = 0x%x hostTag = 0x%x \n",tx_q_item->transmissionControl,tx_q_item->hostTag);
367 unifi_net_data_free(priv, &tx_q_item->bulkdata);
369 priv->noOfPktQueuedInDriver--;
370 spin_lock(&priv->staRecord_lock);
371 interfacePriv->noOfbroadcastPktQueued--;
372 spin_unlock(&priv->staRecord_lock);
373 if(!eospFramedeleted){
377 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
379 unifi_trace(priv, UDBG3, "leaving verify_and_accomodate_tx_packet\n");
383 CsrResult enque_tx_data_pdu(unifi_priv_t *priv, bulk_data_param_t *bulkdata,
384 struct list_head *list, CSR_SIGNAL *signal,
388 /* queue the tx data packets on to appropriate queue */
389 CSR_MA_PACKET_REQUEST *req = &signal->u.MaPacketRequest;
390 tx_buffered_packets_t *tx_q_item;
391 unsigned long lock_flags;
393 unifi_trace(priv, UDBG5, "entering enque_tx_data_pdu\n");
395 unifi_error(priv,"List is not specified\n");
396 return CSR_RESULT_FAILURE;
399 /* Removes aged packets & adds the incoming packet */
400 if (priv->noOfPktQueuedInDriver >= CSR_WIFI_DRIVER_SUPPORT_FOR_MAX_PKT_QUEUEING) {
401 unifi_trace(priv,UDBG3,"number of pkts queued= %d \n", priv->noOfPktQueuedInDriver);
402 verify_and_accomodate_tx_packet(priv);
407 tx_q_item = (tx_buffered_packets_t *)kmalloc(sizeof(tx_buffered_packets_t), GFP_ATOMIC);
408 if (tx_q_item == NULL) {
410 "Failed to allocate %d bytes for tx packet record\n",
411 sizeof(tx_buffered_packets_t));
413 return CSR_RESULT_FAILURE;
416 /* disable the preemption */
417 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
418 INIT_LIST_HEAD(&tx_q_item->q);
419 /* fill the tx_q structure members */
420 tx_q_item->bulkdata.os_data_ptr = bulkdata->d[0].os_data_ptr;
421 tx_q_item->bulkdata.data_length = bulkdata->d[0].data_length;
422 tx_q_item->bulkdata.os_net_buf_ptr = bulkdata->d[0].os_net_buf_ptr;
423 tx_q_item->bulkdata.net_buf_length = bulkdata->d[0].net_buf_length;
424 tx_q_item->interfaceTag = req->VirtualInterfaceIdentifier & 0xff;
425 tx_q_item->hostTag = req->HostTag;
426 tx_q_item->leSenderProcessId = signal->SignalPrimitiveHeader.SenderProcessId;
427 tx_q_item->transmissionControl = req->TransmissionControl;
428 tx_q_item->priority = req->Priority;
429 tx_q_item->rate = req->TransmitRate;
430 memcpy(tx_q_item->peerMacAddress.a, req->Ra.x, ETH_ALEN);
434 if (requeueOnSamePos) {
435 list_add(&tx_q_item->q, list);
437 list_add_tail(&tx_q_item->q, list);
440 /* Count of packet queued in driver */
441 priv->noOfPktQueuedInDriver++;
442 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
443 unifi_trace(priv, UDBG5, "leaving enque_tx_data_pdu\n");
444 return CSR_RESULT_SUCCESS;
447 #ifdef CSR_WIFI_REQUEUE_PACKET_TO_HAL
448 CsrResult unifi_reque_ma_packet_request (void *ospriv, u32 host_tag,
449 u16 txStatus, bulk_data_desc_t *bulkDataDesc)
451 CsrResult status = CSR_RESULT_SUCCESS;
452 unifi_priv_t *priv = (unifi_priv_t*)ospriv;
453 netInterface_priv_t *interfacePriv;
454 struct list_head *list = NULL;
455 CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
456 bulk_data_param_t bulkData;
458 CSR_PRIORITY priority = 0;
459 u16 interfaceTag = 0;
460 unifi_TrafficQueue priority_q;
461 u16 frameControl = 0, frameType = 0;
462 unsigned long lock_flags;
464 interfacePriv = priv->interfacePriv[interfaceTag];
466 /* If the current mode is not AP or P2PGO then just return failure
467 * to clear the hip slot
469 if(!((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP) ||
470 (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO))) {
471 return CSR_RESULT_FAILURE;
474 unifi_trace(priv, UDBG6, "unifi_reque_ma_packet_request: host_tag = 0x%x\n", host_tag);
476 staRecord = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv,
477 (((u8 *) bulkDataDesc->os_data_ptr) + 4),
479 if (NULL == staRecord) {
480 unifi_trace(priv, UDBG5, "unifi_reque_ma_packet_request: Invalid STA record \n");
481 return CSR_RESULT_FAILURE;
484 /* Update TIM if MA-PACKET.cfm fails with status as Tx-retry-limit or No-BSS and then just return failure
485 * to clear the hip slot associated with the Packet
487 if (CSR_TX_RETRY_LIMIT == txStatus || CSR_TX_NO_BSS == txStatus) {
488 if (staRecord->timSet == CSR_WIFI_TIM_RESET || staRecord->timSet == CSR_WIFI_TIM_RESETTING)
490 unifi_trace(priv, UDBG2, "unifi_reque_ma_packet_request: CFM failed with Retry Limit or No BSS-->update TIM\n");
491 if (!staRecord->timRequestPendingFlag) {
492 update_tim(priv, staRecord->aid, 1, interfaceTag, staRecord->assignedHandle);
495 /* Cache the TimSet value so that it will processed immidiatly after
496 * completing the current setTim Request
498 staRecord->updateTimReqQueued = 1;
499 unifi_trace(priv, UDBG6, "unifi_reque_ma_packet_request: One more UpdateTim Request(:%d)Queued for AID %x\n",
500 staRecord->updateTimReqQueued, staRecord->aid);
503 return CSR_RESULT_FAILURE;
505 else if ((CSR_TX_LIFETIME == txStatus) || (CSR_TX_BLOCK_ACK_TIMEOUT == txStatus) ||
506 (CSR_TX_FAIL_TRANSMISSION_VIF_INTERRUPTED == txStatus) ||
507 (CSR_TX_REJECTED_PEER_STATION_SLEEPING == txStatus) ||
508 (CSR_TX_REJECTED_DTIM_STARTED == txStatus)) {
509 /* Extract the Frame control and the frame type */
510 frameControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(bulkDataDesc->os_data_ptr);
511 frameType = ((frameControl & IEEE80211_FC_TYPE_MASK) >> FRAME_CONTROL_TYPE_FIELD_OFFSET);
513 /* Mgmt frames will not be re-queued for Tx
514 * so just return failure to clear the hip slot
516 if (IEEE802_11_FRAMETYPE_MANAGEMENT == frameType) {
517 return CSR_RESULT_FAILURE;
519 else if (IEEE802_11_FRAMETYPE_DATA == frameType) {
520 /* QOS NULL and DATA NULL frames will not be re-queued for Tx
521 * so just return failure to clear the hip slot
523 if ((((frameControl & IEEE80211_FC_SUBTYPE_MASK) >> FRAME_CONTROL_SUBTYPE_FIELD_OFFSET) == QOS_DATA_NULL) ||
524 (((frameControl & IEEE80211_FC_SUBTYPE_MASK) >> FRAME_CONTROL_SUBTYPE_FIELD_OFFSET)== DATA_NULL )) {
525 return CSR_RESULT_FAILURE;
529 /* Extract the Packet priority */
530 if (TRUE == staRecord->wmmOrQosEnabled) {
532 u8 dataFrameType = 0;
534 dataFrameType =((frameControl & IEEE80211_FC_SUBTYPE_MASK) >> 4);
536 if (dataFrameType == QOS_DATA) {
537 /* QoS control field is offset from frame control by 2 (frame control)
538 * + 2 (duration/ID) + 2 (sequence control) + 3*ETH_ALEN or 4*ETH_ALEN
540 if((frameControl & IEEE802_11_FC_TO_DS_MASK) && (frameControl & IEEE802_11_FC_FROM_DS_MASK)) {
541 qosControl= CSR_GET_UINT16_FROM_LITTLE_ENDIAN(bulkDataDesc->os_data_ptr + 30);
544 qosControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(bulkDataDesc->os_data_ptr + 24);
548 priority = (CSR_PRIORITY)(qosControl & IEEE802_11_QC_TID_MASK);
550 if (priority < CSR_QOS_UP0 || priority > CSR_QOS_UP7) {
551 unifi_trace(priv, UDBG5, "unifi_reque_ma_packet_request: Invalid priority:%x \n", priority);
552 return CSR_RESULT_FAILURE;
556 priority = CSR_CONTENTION;
559 /* Frame Bulk data to requeue it back to HAL Queues */
560 bulkData.d[0].os_data_ptr = bulkDataDesc->os_data_ptr;
561 bulkData.d[0].data_length = bulkDataDesc->data_length;
562 bulkData.d[0].os_net_buf_ptr = bulkDataDesc->os_net_buf_ptr;
563 bulkData.d[0].net_buf_length = bulkDataDesc->net_buf_length;
565 bulkData.d[1].os_data_ptr = NULL;
566 bulkData.d[1].os_net_buf_ptr = NULL;
567 bulkData.d[1].data_length = bulkData.d[1].net_buf_length = 0;
569 /* Initialize signal to zero */
570 memset(&signal, 0, sizeof(CSR_SIGNAL));
572 /* Frame MA Packet Req */
573 unifi_frame_ma_packet_req(priv, priority, 0, host_tag,
574 interfaceTag, CSR_NO_CONFIRM_REQUIRED,
575 priv->netdev_client->sender_id,
576 staRecord->peerMacAddress.a, &signal);
578 /* Find the Q-Priority */
579 priority_q = unifi_frame_priority_to_queue(priority);
580 list = &staRecord->dataPdu[priority_q];
582 /* Place the Packet on to HAL Queue */
583 status = enque_tx_data_pdu(priv, &bulkData, list, &signal, TRUE);
585 /* Update the Per-station queued packet counter */
587 spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
588 staRecord->noOfPktQueued++;
589 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
593 /* Packet will not be re-queued for any of the other MA Packet Tx failure
594 * reasons so just return failure to clear the hip slot
596 return CSR_RESULT_FAILURE;
603 static void is_all_ac_deliver_enabled_and_moredata(CsrWifiRouterCtrlStaInfo_t *staRecord, u8 *allDeliveryEnabled, u8 *dataAvailable)
606 *allDeliveryEnabled = TRUE;
607 for (i = 0 ;i < MAX_ACCESS_CATOGORY; i++) {
608 if (!IS_DELIVERY_ENABLED(staRecord->powersaveMode[i])) {
609 /* One is is not Delivery Enabled */
610 *allDeliveryEnabled = FALSE;
614 if (*allDeliveryEnabled) {
615 *dataAvailable = (!list_empty(&staRecord->dataPdu[0]) || !list_empty(&staRecord->dataPdu[1])
616 ||!list_empty(&staRecord->dataPdu[2]) ||!list_empty(&staRecord->dataPdu[3])
617 ||!list_empty(&staRecord->mgtFrames));
622 * ---------------------------------------------------------------------------
626 * This function updates tim status in host depending confirm status from firmware
629 * priv Pointer to device private context struct
630 * cfm CSR_MLME_SET_TIM_CONFIRM
631 * receiverProcessId SenderProcessID to fetch handle & timSet status
633 * ---------------------------------------------------------------------------
635 void uf_handle_tim_cfm(unifi_priv_t *priv, CSR_MLME_SET_TIM_CONFIRM *cfm, u16 receiverProcessId)
637 u8 handle = CSR_WIFI_GET_STATION_HANDLE_FROM_RECEIVER_ID(receiverProcessId);
638 u8 timSetStatus = CSR_WIFI_GET_TIMSET_STATE_FROM_RECEIVER_ID(receiverProcessId);
639 u16 interfaceTag = (cfm->VirtualInterfaceIdentifier & 0xff);
640 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
641 CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
642 /* This variable holds what TIM value we wanted to set in firmware */
644 /* Irrespective of interface the count maintained */
645 static u8 retryCount = 0;
646 unsigned long lock_flags;
647 unifi_trace(priv, UDBG3, "entering %s, handle = %x, timSetStatus = %x\n", __FUNCTION__, handle, timSetStatus);
649 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
650 unifi_warning(priv, "bad interfaceTag = %x\n", interfaceTag);
654 if ((handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) && (handle >= UNIFI_MAX_CONNECTIONS)) {
655 unifi_warning(priv, "bad station Handle = %x\n", handle);
659 if (handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) {
660 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
661 if ((staRecord = ((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[handle]))) == NULL) {
662 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
663 unifi_warning(priv, "uf_handle_tim_cfm: station record is NULL handle = %x\n", handle);
666 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
670 case CSR_WIFI_TIM_SETTING:
671 timSetValue = CSR_WIFI_TIM_SET;
673 case CSR_WIFI_TIM_RESETTING:
674 timSetValue = CSR_WIFI_TIM_RESET;
677 unifi_warning(priv, "timSet state is %x: Debug\n", timSetStatus);
681 /* check TIM confirm for success/failures */
682 switch(cfm->ResultCode)
685 if (handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) {
686 /* Unicast frame & station record available */
687 if (timSetStatus == staRecord->timSet) {
688 staRecord->timSet = timSetValue;
689 /* fh_cmd_q can also be full at some point of time!,
690 * resetting count as queue is cleaned by firmware at this point
693 unifi_trace(priv, UDBG2, "tim (%s) successfully in firmware\n", (timSetValue)?"SET":"RESET");
695 unifi_trace(priv, UDBG3, "receiver processID = %x, success: request & confirm states are not matching in TIM cfm: Debug status = %x, staRecord->timSet = %x, handle = %x\n",
696 receiverProcessId, timSetStatus, staRecord->timSet, handle);
699 /* Reset TIM pending flag to send next TIM request */
700 staRecord->timRequestPendingFlag = FALSE;
702 /* Make sure that one more UpdateTim request is queued, if Queued its value
703 * should be CSR_WIFI_TIM_SET or CSR_WIFI_TIM_RESET
705 if (0xFF != staRecord->updateTimReqQueued)
707 /* Process the UpdateTim Request which is queued while previous UpdateTim was in progress */
708 if (staRecord->timSet != staRecord->updateTimReqQueued)
710 unifi_trace(priv, UDBG2, "uf_handle_tim_cfm : Processing Queued UpdateTimReq \n");
712 update_tim(priv, staRecord->aid, staRecord->updateTimReqQueued, interfaceTag, handle);
714 staRecord->updateTimReqQueued = 0xFF;
719 interfacePriv->bcTimSet = timSetValue;
720 /* fh_cmd_q can also be full at some point of time!,
721 * resetting count as queue is cleaned by firmware at this point
724 unifi_trace(priv, UDBG3, "tim (%s) successfully for broadcast frame in firmware\n", (timSetValue)?"SET":"RESET");
726 /* Reset DTIM pending flag to send next DTIM request */
727 interfacePriv->bcTimSetReqPendingFlag = FALSE;
729 /* Make sure that one more UpdateDTim request is queued, if Queued its value
730 * should be CSR_WIFI_TIM_SET or CSR_WIFI_TIM_RESET
732 if (0xFF != interfacePriv->bcTimSetReqQueued)
734 /* Process the UpdateTim Request which is queued while previous UpdateTim was in progress */
735 if (interfacePriv->bcTimSet != interfacePriv->bcTimSetReqQueued)
737 unifi_trace(priv, UDBG2, "uf_handle_tim_cfm : Processing Queued UpdateDTimReq \n");
739 update_tim(priv, 0, interfacePriv->bcTimSetReqQueued, interfaceTag, 0xFFFFFFFF);
741 interfacePriv->bcTimSetReqQueued = 0xFF;
747 case CSR_RC_INVALID_PARAMETERS:
748 case CSR_RC_INSUFFICIENT_RESOURCE:
749 /* check for max retry limit & send again
750 * MAX_RETRY_LIMIT is not maintained for each set of transactions..Its generic
751 * If failure crosses this Limit, we have to take a call to FIX
753 if (retryCount > UNIFI_MAX_RETRY_LIMIT) {
756 /* Because of continuos traffic in fh_cmd_q the tim set request is failing (exceeding retry limit)
757 * but if we didn't synchronize our timSet varible state with firmware then it can cause below issues
758 * cond 1. We want to SET tim in firmware if its fails & max retry limit reached
759 * -> If host set's the timSet to 1, we wont try to send(as max retry reached) update tim but
760 * firmware is not updated with queue(TIM) status so it wont set TIM in beacon finally host start piling
761 * up data & wont try to set tim in firmware (This can cause worser performance)
762 * cond 2. We want to reset tim in firmware it fails & reaches max retry limit
763 * -> If host sets the timSet to Zero, it wont try to set a TIM request unless we wont have any packets
764 * to be queued, so beacon unnecessarily advertizes the TIM
768 if(!staRecord->wmmOrQosEnabled) {
769 moreData = (!list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]) ||
770 !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]) ||
771 !list_empty(&staRecord->mgtFrames));
774 u8 allDeliveryEnabled = 0, dataAvailable = 0;
775 /* Check if all AC's are Delivery Enabled */
776 is_all_ac_deliver_enabled_and_moredata(staRecord, &allDeliveryEnabled, &dataAvailable);
777 /*check for more data in non-delivery enabled queues*/
778 moreData = (uf_is_more_data_for_non_delivery_ac(staRecord) || (allDeliveryEnabled && dataAvailable));
781 /* To avoid cond 1 & 2, check internal Queues status, if we have more Data then set RESET the timSet(0),
782 * so we are trying to be in sync with firmware & next packets before queuing atleast try to
783 * set TIM in firmware otherwise it SET timSet(1)
786 staRecord->timSet = CSR_WIFI_TIM_RESET;
788 staRecord->timSet = CSR_WIFI_TIM_SET;
791 /* Its a broadcast frames */
792 moreData = (!list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames) ||
793 !list_empty(&interfacePriv->genericMulticastOrBroadCastFrames));
795 update_tim(priv, 0, CSR_WIFI_TIM_SET, interfaceTag, 0xFFFFFFFF);
797 update_tim(priv, 0, CSR_WIFI_TIM_RESET, interfaceTag, 0xFFFFFFFF);
801 unifi_error(priv, "no of error's for TIM setting crossed the Limit: verify\n");
806 if (handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) {
807 if (timSetStatus == staRecord->timSet) {
808 unifi_warning(priv, "tim request failed, retry for AID = %x\n", staRecord->aid);
809 update_tim(priv, staRecord->aid, timSetValue, interfaceTag, handle);
811 unifi_trace(priv, UDBG1, "failure: request & confirm states are not matching in TIM cfm: Debug status = %x, staRecord->timSet = %x\n",
812 timSetStatus, staRecord->timSet);
815 unifi_warning(priv, "tim request failed, retry for broadcast frames\n");
816 update_tim(priv, 0, timSetValue, interfaceTag, 0xFFFFFFFF);
820 unifi_warning(priv, "tim update request failed resultcode = %x\n", cfm->ResultCode);
823 unifi_trace(priv, UDBG2, "leaving %s\n", __FUNCTION__);
827 * ---------------------------------------------------------------------------
831 * This function updates tim status in firmware for AID[1 to UNIFI_MAX_CONNECTIONS] or
832 * AID[0] for broadcast/multicast packets.
834 * NOTE: The LSB (least significant BYTE) of senderId while sending this MLME premitive
835 * has been modified(utilized) as below
837 * SenderID in signal's SignalPrimitiveHeader is 2 byte the lowe byte bitmap is below
839 * station handle(6 bits) timSet Status (2 bits)
840 * --------------------- ----------------------
843 * timSet Status can be one of below:
846 * CSR_WIFI_TIM_RESETTING
848 * CSR_WIFI_TIM_SETTING
851 * priv Pointer to device private context struct
852 * aid can be 1 t0 UNIFI_MAX_CONNECTIONS & 0 means multicast/broadcast
853 * setTim value SET(1) / RESET(0)
854 * interfaceTag the interfaceID on which activity going on
855 * handle from (0 <= handle < UNIFI_MAX_CONNECTIONS)
857 * ---------------------------------------------------------------------------
859 void update_tim(unifi_priv_t * priv, u16 aid, u8 setTim, u16 interfaceTag, u32 handle)
863 CSR_MLME_SET_TIM_REQUEST *req = &signal.u.MlmeSetTimRequest;
864 bulk_data_param_t *bulkdata = NULL;
865 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
867 CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
868 u32 oldTimSetStatus = 0, timSetStatus = 0;
870 unifi_trace(priv, UDBG5, "entering the update_tim routine\n");
873 if (handle == 0xFFFFFFFF) {
874 handle &= CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE;
875 if (setTim == interfacePriv->bcTimSet)
877 unifi_trace(priv, UDBG3, "update_tim, Drop:Hdl=%x, timval=%d, globalTim=%d\n", handle, setTim, interfacePriv->bcTimSet);
880 } else if ((handle != 0xFFFFFFFF) && (handle >= UNIFI_MAX_CONNECTIONS)) {
881 unifi_warning(priv, "bad station Handle = %x\n", handle);
886 timSetStatus = CSR_WIFI_TIM_SETTING;
888 timSetStatus = CSR_WIFI_TIM_RESETTING;
891 if (handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) {
892 if ((staRecord = ((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[handle]))) == NULL) {
893 unifi_warning(priv, "station record is NULL in update_tim: handle = %x :debug\n", handle);
896 /* In case of signal sending failed, revert back to old state */
897 oldTimSetStatus = staRecord->timSet;
898 staRecord->timSet = timSetStatus;
901 /* pack senderID LSB */
902 senderIdLsb = CSR_WIFI_PACK_SENDER_ID_LSB_FOR_TIM_REQ(handle, timSetStatus);
904 /* initialize signal to zero */
905 memset(&signal, 0, sizeof(CSR_SIGNAL));
907 /* Frame the MLME-SET-TIM request */
908 signal.SignalPrimitiveHeader.SignalId = CSR_MLME_SET_TIM_REQUEST_ID;
909 signal.SignalPrimitiveHeader.ReceiverProcessId = 0;
910 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(((priv->netdev_client->sender_id & 0xff00) | senderIdLsb),
911 (u8*)&signal.SignalPrimitiveHeader.SenderProcessId);
913 /* set The virtual interfaceIdentifier, aid, tim value */
914 req->VirtualInterfaceIdentifier = uf_get_vif_identifier(interfacePriv->interfaceMode,interfaceTag);
915 req->AssociationId = aid;
916 req->TimValue = setTim;
919 unifi_trace(priv, UDBG2, "update_tim:AID %x,senderIdLsb = 0x%x, handle = 0x%x, timSetStatus = %x, sender proceesID = %x \n",
920 aid,senderIdLsb, handle, timSetStatus, signal.SignalPrimitiveHeader.SenderProcessId);
922 /* Send the signal to UniFi */
923 r = ul_send_signal_unpacked(priv, &signal, bulkdata);
925 /* No need to free bulk data, as TIM request doesn't carries any data */
926 unifi_error(priv, "Error queueing CSR_MLME_SET_TIM_REQUEST signal\n");
928 staRecord->timSet = oldTimSetStatus ;
932 /* MLME_SET_TIM.req sending failed here for AID0, so revert back our bcTimSet status */
933 interfacePriv->bcTimSet = !setTim;
937 /* Update tim request pending flag and ensure no more TIM set requests are send
938 for the same station until TIM confirm is received */
940 staRecord->timRequestPendingFlag = TRUE;
944 /* Update tim request (for AID 0) pending flag and ensure no more DTIM set requests are send
945 * for the same station until TIM confirm is received
947 interfacePriv->bcTimSetReqPendingFlag = TRUE;
950 unifi_trace(priv, UDBG5, "leaving the update_tim routine\n");
954 void process_peer_active_transition(unifi_priv_t * priv,
955 CsrWifiRouterCtrlStaInfo_t *staRecord,
959 u8 spaceAvail[4] = {TRUE,TRUE,TRUE,TRUE};
960 tx_buffered_packets_t * buffered_pkt = NULL;
961 unsigned long lock_flags;
962 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
964 unifi_trace(priv, UDBG5, "entering process_peer_active_transition\n");
966 if(IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag)) {
967 /* giving more priority to multicast packets so delaying unicast packets*/
968 unifi_trace(priv,UDBG2, "Multicast transmission is going on so resume unicast transmission after DTIM over\n");
970 /* As station is active now, even though AP is not able to send frames to it
971 * because of DTIM, it needs to reset the TIM here
973 if (!staRecord->timRequestPendingFlag){
974 if((staRecord->timSet == CSR_WIFI_TIM_SET) || (staRecord->timSet == CSR_WIFI_TIM_SETTING)){
975 update_tim(priv, staRecord->aid, 0, interfaceTag, staRecord->assignedHandle);
980 /* Cache the TimSet value so that it will processed immidiatly after
981 * completing the current setTim Request
983 staRecord->updateTimReqQueued = 0;
984 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
989 while((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->mgtFrames))) {
990 buffered_pkt->transmissionControl &=
991 ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
992 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staRecord,0,FALSE)) == -ENOSPC) {
993 unifi_trace(priv, UDBG2, "p_p_a_t:(ENOSPC) Mgt Frame queueing \n");
994 /* Enqueue at the head of the queue */
995 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
996 list_add(&buffered_pkt->q, &staRecord->mgtFrames);
997 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
998 priv->pausedStaHandle[3]=(u8)(staRecord->assignedHandle);
999 spaceAvail[3] = FALSE;
1003 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
1004 /* the PDU failed where we can't do any thing so free the storage */
1005 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
1007 kfree(buffered_pkt);
1010 if (!staRecord->timRequestPendingFlag) {
1011 if (staRecord->txSuspend) {
1012 if(staRecord->timSet == CSR_WIFI_TIM_SET) {
1013 update_tim(priv,staRecord->aid,0,interfaceTag, staRecord->assignedHandle);
1020 /* Cache the TimSet value so that it will processed immidiatly after
1021 * completing the current setTim Request
1023 staRecord->updateTimReqQueued = 0;
1024 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
1030 unifi_trace(priv, UDBG6, "p_p_a_t:data pkt sending for AC %d \n",i);
1031 while((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->dataPdu[i]))) {
1032 buffered_pkt->transmissionControl &=
1033 ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
1034 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staRecord,0,FALSE)) == -ENOSPC) {
1035 /* Clear the trigger bit transmission control*/
1036 /* Enqueue at the head of the queue */
1037 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
1038 list_add(&buffered_pkt->q, &staRecord->dataPdu[i]);
1039 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
1040 priv->pausedStaHandle[i]=(u8)(staRecord->assignedHandle);
1044 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
1045 /* the PDU failed where we can't do any thing so free the storage */
1046 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
1048 kfree(buffered_pkt);
1052 if (!staRecord->timRequestPendingFlag){
1053 if((staRecord->timSet == CSR_WIFI_TIM_SET) || (staRecord->timSet == CSR_WIFI_TIM_SETTING)) {
1054 unifi_trace(priv, UDBG3, "p_p_a_t:resetting tim .....\n");
1055 update_tim(priv,staRecord->aid,0,interfaceTag, staRecord->assignedHandle);
1060 /* Cache the TimSet value so that it will processed immidiatly after
1061 * completing the current setTim Request
1063 staRecord->updateTimReqQueued = 0;
1064 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
1067 unifi_trace(priv, UDBG5, "leaving process_peer_active_transition\n");
1072 void uf_process_ma_pkt_cfm_for_ap(unifi_priv_t *priv,u16 interfaceTag, const CSR_MA_PACKET_CONFIRM *pkt_cfm)
1074 netInterface_priv_t *interfacePriv;
1076 CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
1077 interfacePriv = priv->interfacePriv[interfaceTag];
1080 if(pkt_cfm->HostTag == interfacePriv->multicastPduHostTag) {
1081 unifi_trace(priv,UDBG2,"CFM for marked Multicast Tag = %x\n",interfacePriv->multicastPduHostTag);
1082 interfacePriv->multicastPduHostTag = 0xffffffff;
1083 resume_suspended_uapsd(priv,interfaceTag);
1084 resume_unicast_buffered_frames(priv,interfaceTag);
1085 if(list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames) &&
1086 list_empty(&interfacePriv->genericMulticastOrBroadCastFrames)) {
1087 unifi_trace(priv,UDBG1,"Resetting multicastTIM");
1088 if (!interfacePriv->bcTimSetReqPendingFlag)
1090 update_tim(priv,0,CSR_WIFI_TIM_RESET,interfaceTag, 0xFFFFFFFF);
1094 /* Cache the DTimSet value so that it will processed immidiatly after
1095 * completing the current setDTim Request
1097 interfacePriv->bcTimSetReqQueued = CSR_WIFI_TIM_RESET;
1098 unifi_trace(priv, UDBG2, "uf_process_ma_pkt_cfm_for_ap : One more UpdateDTim Request(%d) Queued \n",
1099 interfacePriv->bcTimSetReqQueued);
1106 /* Check if it is a Confirm for null data frame used
1107 * for probing station activity
1109 for(i =0; i < UNIFI_MAX_CONNECTIONS; i++) {
1110 staRecord = (CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[i]);
1111 if (staRecord && (staRecord->nullDataHostTag == pkt_cfm->HostTag)) {
1113 unifi_trace(priv, UDBG1, "CFM for Inactive probe Null frame (tag = %x, status = %d)\n",
1115 pkt_cfm->TransmissionStatus
1117 staRecord->nullDataHostTag = INVALID_HOST_TAG;
1119 if(pkt_cfm->TransmissionStatus == CSR_TX_RETRY_LIMIT){
1121 CsrTime inactive_time;
1123 unifi_trace(priv, UDBG1, "Nulldata to probe STA ALIVE Failed with retry limit\n");
1124 /* Recheck if there is some activity after null data is sent.
1126 * If still there is no activity then send a disconnected indication
1127 * to SME to delete the station record.
1129 if (staRecord->activity_flag){
1132 now = CsrTimeGet(NULL);
1134 if (staRecord->lastActivity > now)
1136 /* simple timer wrap (for 1 wrap) */
1137 inactive_time = CsrTimeAdd((CsrTime)CsrTimeSub(CSR_SCHED_TIME_MAX, staRecord->lastActivity),
1142 inactive_time = (CsrTime)CsrTimeSub(now, staRecord->lastActivity);
1145 if (inactive_time >= STA_INACTIVE_TIMEOUT_VAL)
1147 struct list_head send_cfm_list;
1150 /* The SME/NME may be waiting for confirmation for requested frames to this station.
1151 * Though this is --VERY UNLIKELY-- in case of station in active mode. But still as a
1152 * a defensive check, it loops through buffered frames for this station and if confirmation
1153 * is requested, send auto confirmation with failure status. Also flush the frames so
1154 * that these are not processed again in PEER_DEL_REQ handler.
1156 INIT_LIST_HEAD(&send_cfm_list);
1158 uf_prepare_send_cfm_list_for_queued_pkts(priv,
1160 &(staRecord->mgtFrames));
1162 uf_flush_list(priv, &(staRecord->mgtFrames));
1164 for(j = 0; j < MAX_ACCESS_CATOGORY; j++){
1165 uf_prepare_send_cfm_list_for_queued_pkts(priv,
1167 &(staRecord->dataPdu[j]));
1169 uf_flush_list(priv,&(staRecord->dataPdu[j]));
1172 send_auto_ma_packet_confirm(priv, staRecord->interfacePriv, &send_cfm_list);
1176 unifi_warning(priv, "uf_process_ma_pkt_cfm_for_ap: Router Disconnected IND Peer (%x-%x-%x-%x-%x-%x)\n",
1177 staRecord->peerMacAddress.a[0],
1178 staRecord->peerMacAddress.a[1],
1179 staRecord->peerMacAddress.a[2],
1180 staRecord->peerMacAddress.a[3],
1181 staRecord->peerMacAddress.a[4],
1182 staRecord->peerMacAddress.a[5]);
1184 CsrWifiRouterCtrlConnectedIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,
1186 staRecord->interfacePriv->InterfaceTag,
1187 staRecord->peerMacAddress,
1188 CSR_WIFI_ROUTER_CTRL_PEER_DISCONNECTED);
1192 else if (pkt_cfm->TransmissionStatus == CSR_TX_SUCCESSFUL)
1194 staRecord->activity_flag = TRUE;
1201 u16 uf_get_vif_identifier (CsrWifiRouterCtrlMode mode, u16 tag)
1205 case CSR_WIFI_ROUTER_CTRL_MODE_STA:
1206 case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
1207 return (0x02<<8|tag);
1209 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
1210 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
1211 return (0x03<<8|tag);
1213 case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
1214 return (0x01<<8|tag);
1216 case CSR_WIFI_ROUTER_CTRL_MODE_MONITOR:
1217 return (0x04<<8|tag);
1218 case CSR_WIFI_ROUTER_CTRL_MODE_AMP:
1219 return (0x05<<8|tag);
1225 #ifdef CSR_SUPPORT_SME
1228 * ---------------------------------------------------------------------------
1232 * These functions updates mac header for intra BSS packet
1234 * NOTE: This function always has to be called in rx context which
1235 * is in bh thread context since GFP_KERNEL is used. In soft IRQ/ Interrupt
1236 * context shouldn't be used
1239 * priv Pointer to device private context struct
1240 * skb Socket buffer containing data packet to transmit
1241 * newSkb Socket buffer containing data packet + Mac header if no sufficient headroom in skb
1242 * priority to append QOS control header in Mac header
1243 * bulkdata if newSkb allocated then bulkdata updated to send to unifi
1244 * interfaceTag the interfaceID on which activity going on
1245 * macHeaderLengthInBytes no. of bytes of mac header in received frame
1246 * qosDestination used to append Qos control field
1249 * Zero on success or -1 on error.
1250 * ---------------------------------------------------------------------------
1253 static int update_macheader(unifi_priv_t *priv, struct sk_buff *skb,
1254 struct sk_buff *newSkb, CSR_PRIORITY *priority,
1255 bulk_data_param_t *bulkdata, u16 interfaceTag,
1256 u8 macHeaderLengthInBytes,
1261 u8 direction = 0, toDs, fromDs;
1263 u8 sa[ETH_ALEN], da[ETH_ALEN];
1264 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
1266 u8 macHeaderBuf[IEEE802_11_DATA_FRAME_MAC_HEADER_SIZE] = {0};
1268 unifi_trace(priv, UDBG5, "entering the update_macheader function\n");
1270 /* temporary buffer for the Mac header storage */
1271 memcpy(macHeaderBuf, skb->data, macHeaderLengthInBytes);
1273 /* remove the Macheader from the skb */
1274 skb_pull(skb, macHeaderLengthInBytes);
1276 /* get the skb headroom for skb_push check */
1277 headroom = skb_headroom(skb);
1279 /* pointer to frame control field */
1280 fc = (u16*) macHeaderBuf;
1282 toDs = (*fc & cpu_to_le16(IEEE802_11_FC_TO_DS_MASK))?1 : 0;
1283 fromDs = (*fc & cpu_to_le16(IEEE802_11_FC_FROM_DS_MASK))? 1: 0;
1284 unifi_trace(priv, UDBG5, "In update_macheader function, fromDs = %x, toDs = %x\n", fromDs, toDs);
1285 direction = ((fromDs | (toDs << 1)) & 0x3);
1287 /* Address1 or 3 from the macheader */
1288 memcpy(da, macHeaderBuf+4+toDs*12, ETH_ALEN);
1289 /* Address2, 3 or 4 from the mac header */
1290 memcpy(sa, macHeaderBuf+10+fromDs*(6+toDs*8), ETH_ALEN);
1292 unifi_trace(priv, UDBG3, "update_macheader:direction = %x\n", direction);
1293 /* update the toDs, fromDs & address fields in Mac header */
1297 /* toDs = 1 & fromDs = 0 , toAp when frames received from peer
1298 * while sending this packet to Destination the Mac header changed
1299 * as fromDs = 1 & toDs = 0, fromAp
1301 *fc &= cpu_to_le16(~IEEE802_11_FC_TO_DS_MASK);
1302 *fc |= cpu_to_le16(IEEE802_11_FC_FROM_DS_MASK);
1303 /* Address1: MAC address of the actual destination (4 = 2+2) */
1304 memcpy(macHeaderBuf + 4, da, ETH_ALEN);
1305 /* Address2: The MAC address of the AP (10 = 2+2+6) */
1306 memcpy(macHeaderBuf + 10, &interfacePriv->bssid, ETH_ALEN);
1307 /* Address3: MAC address of the actual source from mac header (16 = 2+2+6+6) */
1308 memcpy(macHeaderBuf + 16, sa, ETH_ALEN);
1311 unifi_trace(priv, UDBG3, "when both the toDs & fromDS set, NOT SUPPORTED\n");
1314 unifi_trace(priv, UDBG3, "problem in decoding packet in update_macheader \n");
1318 /* frameType is Data always, Validation is done before calling this function */
1320 /* check for the souce station type */
1321 switch(le16_to_cpu(*fc) & IEEE80211_FC_SUBTYPE_MASK)
1323 case IEEE802_11_FC_TYPE_QOS_DATA & IEEE80211_FC_SUBTYPE_MASK:
1324 /* No need to modify the qos control field */
1325 if (!qosDestination) {
1327 /* If source Sta is QOS enabled & if this bit set, then HTC is supported by
1328 * peer station & htc field present in macHeader
1330 if (*fc & cpu_to_le16(IEEE80211_FC_ORDER_MASK)) {
1331 /* HT control field present in Mac header
1332 * 6 = sizeof(qosControl) + sizeof(htc)
1334 macHeaderLengthInBytes -= 6;
1336 macHeaderLengthInBytes -= 2;
1338 /* Destination STA is non qos so change subtype to DATA */
1339 *fc &= cpu_to_le16(~IEEE80211_FC_SUBTYPE_MASK);
1340 *fc |= cpu_to_le16(IEEE802_11_FC_TYPE_DATA);
1341 /* remove the qos control field & HTC(if present). new macHeaderLengthInBytes is less than old
1342 * macHeaderLengthInBytes so no need to verify skb headroom
1344 if (headroom < macHeaderLengthInBytes) {
1345 unifi_trace(priv, UDBG1, " sufficient headroom not there to push updated mac header \n");
1348 bufPtr = (u8 *) skb_push(skb, macHeaderLengthInBytes);
1350 /* update bulk data os_data_ptr */
1351 bulkdata->d[0].os_data_ptr = skb->data;
1352 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skb;
1353 bulkdata->d[0].data_length = skb->len;
1356 /* pointing to QOS control field */
1358 if (*fc & cpu_to_le16(IEEE80211_FC_ORDER_MASK)) {
1359 qc = *((u8*)(macHeaderBuf + (macHeaderLengthInBytes - 4 - 2)));
1361 qc = *((u8*)(macHeaderBuf + (macHeaderLengthInBytes - 2)));
1364 if ((qc & IEEE802_11_QC_TID_MASK) > 7) {
1367 *priority = qc & IEEE802_11_QC_TID_MASK;
1370 unifi_trace(priv, UDBG1, "Incoming packet priority from QSTA is %x\n", *priority);
1372 if (headroom < macHeaderLengthInBytes) {
1373 unifi_trace(priv, UDBG3, " sufficient headroom not there to push updated mac header \n");
1376 bufPtr = (u8 *) skb_push(skb, macHeaderLengthInBytes);
1381 bulk_data_param_t data_ptrs;
1382 CsrResult csrResult;
1383 unifi_trace(priv, UDBG5, "normal Data packet, NO QOS \n");
1385 if (qosDestination) {
1387 unifi_trace(priv, UDBG3, "destination is QOS station \n");
1389 /* Set Ma-Packet.req UP to UP0 */
1390 *priority = CSR_QOS_UP0;
1392 /* prepare the qos control field */
1394 /* no Amsdu is in ap buffer so eosp is left 0 */
1396 /* multicast/broadcast frames, no acknowledgement needed */
1400 /* update new Mac header Length with 2 = sizeof(qos control) */
1401 macHeaderLengthInBytes += 2;
1403 /* received DATA frame but destiantion is QOS station so update subtype to QOS*/
1404 *fc &= cpu_to_le16(~IEEE80211_FC_SUBTYPE_MASK);
1405 *fc |= cpu_to_le16(IEEE802_11_FC_TYPE_QOS_DATA);
1407 /* appendQosControlOffset = macHeaderLengthInBytes - 2, since source sta is not QOS */
1408 macHeaderBuf[macHeaderLengthInBytes - 2] = qc;
1409 /* txopLimit is 0 */
1410 macHeaderBuf[macHeaderLengthInBytes - 1] = 0;
1411 if (headroom < macHeaderLengthInBytes) {
1412 csrResult = unifi_net_data_malloc(priv, &data_ptrs.d[0], skb->len + macHeaderLengthInBytes);
1414 if (csrResult != CSR_RESULT_SUCCESS) {
1415 unifi_error(priv, " failed to allocate request_data. in update_macheader func\n");
1418 newSkb = (struct sk_buff *)(data_ptrs.d[0].os_net_buf_ptr);
1419 newSkb->len = skb->len + macHeaderLengthInBytes;
1421 memcpy((void*)data_ptrs.d[0].os_data_ptr + macHeaderLengthInBytes,
1422 skb->data, skb->len);
1424 bulkdata->d[0].os_data_ptr = newSkb->data;
1425 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)newSkb;
1426 bulkdata->d[0].data_length = newSkb->len;
1428 bufPtr = (u8*)data_ptrs.d[0].os_data_ptr;
1430 /* The old skb will not be used again */
1433 /* skb headroom is sufficient to append Macheader */
1434 bufPtr = (u8*)skb_push(skb, macHeaderLengthInBytes);
1435 bulkdata->d[0].os_data_ptr = skb->data;
1436 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skb;
1437 bulkdata->d[0].data_length = skb->len;
1440 unifi_trace(priv, UDBG3, "destination is not a QSTA\n");
1441 if (headroom < macHeaderLengthInBytes) {
1442 csrResult = unifi_net_data_malloc(priv, &data_ptrs.d[0], skb->len + macHeaderLengthInBytes);
1444 if (csrResult != CSR_RESULT_SUCCESS) {
1445 unifi_error(priv, " failed to allocate request_data. in update_macheader func\n");
1448 newSkb = (struct sk_buff *)(data_ptrs.d[0].os_net_buf_ptr);
1449 newSkb->len = skb->len + macHeaderLengthInBytes;
1451 memcpy((void*)data_ptrs.d[0].os_data_ptr + macHeaderLengthInBytes,
1452 skb->data, skb->len);
1454 bulkdata->d[0].os_data_ptr = newSkb->data;
1455 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)newSkb;
1456 bulkdata->d[0].data_length = newSkb->len;
1458 bufPtr = (u8*)data_ptrs.d[0].os_data_ptr;
1460 /* The old skb will not be used again */
1463 /* skb headroom is sufficient to append Macheader */
1464 bufPtr = (u8*)skb_push(skb, macHeaderLengthInBytes);
1465 bulkdata->d[0].os_data_ptr = skb->data;
1466 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skb;
1467 bulkdata->d[0].data_length = skb->len;
1473 /* prepare the complete skb, by pushing the MAC header to the begining of the skb->data */
1474 unifi_trace(priv, UDBG5, "updated Mac Header: %d \n",macHeaderLengthInBytes);
1475 memcpy(bufPtr, macHeaderBuf, macHeaderLengthInBytes);
1477 unifi_trace(priv, UDBG5, "leaving the update_macheader function\n");
1481 * ---------------------------------------------------------------------------
1482 * uf_ap_process_data_pdu
1485 * Takes care of intra BSS admission control & routing packets within BSS
1488 * priv Pointer to device private context struct
1489 * skb Socket buffer containing data packet to transmit
1490 * ehdr ethernet header to fetch priority of packet
1491 * srcStaInfo source stations record for connection verification
1494 * signal MA-PACKET.indication signal
1495 * bulkdata if newSkb allocated then bulkdata updated to send to unifi
1496 * macHeaderLengthInBytes no. of bytes of mac header in received frame
1499 * Zero on success(ap processing complete) or -1 if packet also have to be sent to NETDEV.
1500 * ---------------------------------------------------------------------------
1503 uf_ap_process_data_pdu(unifi_priv_t *priv, struct sk_buff *skb,
1504 struct ethhdr *ehdr, CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
1505 const CSR_SIGNAL *signal,
1506 bulk_data_param_t *bulkdata,
1507 u8 macHeaderLengthInBytes)
1509 const CSR_MA_PACKET_INDICATION *ind = &(signal->u.MaPacketIndication);
1510 u16 interfaceTag = (ind->VirtualInterfaceIdentifier & 0x00ff);
1511 struct sk_buff *newSkb = NULL;
1512 /* pointer to skb or private skb created using skb_copy() */
1513 struct sk_buff *skbPtr = skb;
1514 u8 sendToNetdev = FALSE;
1515 u8 qosDestination = FALSE;
1516 CSR_PRIORITY priority = CSR_CONTENTION;
1517 CsrWifiRouterCtrlStaInfo_t *dstStaInfo = NULL;
1518 netInterface_priv_t *interfacePriv;
1520 unifi_trace(priv, UDBG5, "entering uf_ap_process_data_pdu %d\n",macHeaderLengthInBytes);
1521 /* InterfaceTag validation from MA_PACKET.indication */
1522 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
1523 unifi_trace(priv, UDBG1, "Interface Tag is Invalid in uf_ap_process_data_pdu\n");
1524 unifi_net_data_free(priv, &bulkdata->d[0]);
1527 interfacePriv = priv->interfacePriv[interfaceTag];
1529 if((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) &&
1530 (interfacePriv->intraBssEnabled == FALSE)) {
1531 unifi_trace(priv, UDBG2, "uf_ap_process_data_pdu:P2P GO intrabssEnabled?= %d\n", interfacePriv->intraBssEnabled);
1533 /*In P2P GO case, if intraBSS distribution Disabled then don't do IntraBSS routing */
1534 /* If destination in our BSS then drop otherwise give packet to netdev */
1535 dstStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, ehdr->h_dest, interfaceTag);
1537 unifi_net_data_free(priv, &bulkdata->d[0]);
1540 /* May be associated P2PCLI trying to send the packets on backbone (Netdev) */
1544 if(!memcmp(ehdr->h_dest, interfacePriv->bssid.a, ETH_ALEN)) {
1545 /* This packet will be given to the TCP/IP stack since this packet is for us(AP)
1546 * No routing needed */
1547 unifi_trace(priv, UDBG4, "destination address is csr_ap\n");
1551 /* fetch the destination record from staion record database */
1552 dstStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, ehdr->h_dest, interfaceTag);
1554 /* AP mode processing, & if packet is unicast */
1556 if (!(ehdr->h_dest[0] & 0x1)) {
1557 /* destination not in station record & its a unicast packet, so pass the packet to network stack */
1558 unifi_trace(priv, UDBG3, "unicast frame & destination record not exist, send to netdev proto = %x\n", htons(skb->protocol));
1561 /* packet is multicast/broadcast */
1562 /* copy the skb to skbPtr, send skb to netdev & skbPtr to multicast/broad cast list */
1563 unifi_trace(priv, UDBG5, "skb_copy, in uf_ap_process_data_pdu, protocol = %x\n", htons(skb->protocol));
1564 skbPtr = skb_copy(skb, GFP_KERNEL);
1565 if(skbPtr == NULL) {
1566 /* We don't have memory to don't send the frame in BSS*/
1567 unifi_notice(priv, "broacast/multicast frame can't be sent in BSS No memeory: proto = %x\n", htons(skb->protocol));
1570 sendToNetdev = TRUE;
1574 /* validate the Peer & Destination Station record */
1575 if (uf_process_station_records_for_sending_data(priv, interfaceTag, srcStaInfo, dstStaInfo)) {
1576 unifi_notice(priv, "uf_ap_process_data_pdu: station record validation failed \n");
1577 interfacePriv->stats.rx_errors++;
1578 unifi_net_data_free(priv, &bulkdata->d[0]);
1583 /* BroadCast packet received and it's been sent as non QOS packets.
1584 * Since WMM spec not mandates broadcast/multicast to be sent as QOS data only,
1585 * if all Peers are QSTA
1588 /* BroadCast packet and it's been sent as non QOS packets */
1589 qosDestination = FALSE;
1590 } else if(dstStaInfo && (dstStaInfo->wmmOrQosEnabled == TRUE)) {
1591 qosDestination = TRUE;
1594 unifi_trace(priv, UDBG3, "uf_ap_process_data_pdu QoS destination = %s\n", (qosDestination)? "TRUE": "FALSE");
1596 /* packet is allowed to send to unifi, update the Mac header */
1597 if (update_macheader(priv, skbPtr, newSkb, &priority, bulkdata, interfaceTag, macHeaderLengthInBytes, qosDestination)) {
1598 interfacePriv->stats.rx_errors++;
1599 unifi_notice(priv, "(Packet Drop) failed to update the Mac header in uf_ap_process_data_pdu\n");
1601 /* Free's the skb_copy(skbPtr) data since packet processing failed */
1602 bulkdata->d[0].os_data_ptr = skbPtr->data;
1603 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skbPtr;
1604 bulkdata->d[0].data_length = skbPtr->len;
1605 unifi_net_data_free(priv, &bulkdata->d[0]);
1610 unifi_trace(priv, UDBG3, "Mac Header updated...calling uf_process_ma_packet_req \n");
1612 /* Packet is ready to send to unifi ,transmissionControl = 0x0004, confirmation is not needed for data packets */
1613 if (uf_process_ma_packet_req(priv, ehdr->h_dest, 0xffffffff, interfaceTag, CSR_NO_CONFIRM_REQUIRED, (CSR_RATE)0,priority, priv->netdev_client->sender_id, bulkdata)) {
1615 unifi_trace(priv, UDBG1, "In uf_ap_process_data_pdu, (Packet Drop) uf_process_ma_packet_req failed. freeing skb_copy data (original data sent to Netdev)\n");
1616 /* Free's the skb_copy(skbPtr) data since packet processing failed */
1617 bulkdata->d[0].os_data_ptr = skbPtr->data;
1618 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skbPtr;
1619 bulkdata->d[0].data_length = skbPtr->len;
1620 unifi_net_data_free(priv, &bulkdata->d[0]);
1622 /* This free's the skb data */
1623 unifi_trace(priv, UDBG1, "In uf_ap_process_data_pdu, (Packet Drop). Unicast data so freeing original skb \n");
1624 unifi_net_data_free(priv, &bulkdata->d[0]);
1627 unifi_trace(priv, UDBG5, "leaving uf_ap_process_data_pdu\n");
1630 /* The packet is multicast/broadcast, so after AP processing packet has to
1631 * be sent to netdev, if peer port state is open
1633 unifi_trace(priv, UDBG4, "Packet will be routed to NetDev\n");
1636 /* Ap handled the packet & its a unicast packet, no need to send to netdev */
1642 CsrResult uf_process_ma_packet_req(unifi_priv_t *priv,
1644 CSR_CLIENT_TAG hostTag,
1646 CSR_TRANSMISSION_CONTROL transmissionControl,
1647 CSR_RATE TransmitRate,
1648 CSR_PRIORITY priority,
1649 CSR_PROCESS_ID leSenderProcessId,
1650 bulk_data_param_t *bulkdata)
1652 CsrResult status = CSR_RESULT_SUCCESS;
1655 #ifdef CSR_SUPPORT_SME
1656 CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
1657 const u8 *macHdrLocation = bulkdata->d[0].os_data_ptr;
1658 CsrWifiPacketType pktType;
1660 u8 queuePacketDozing = FALSE;
1663 struct list_head * list = NULL; /* List to which buffered PDUs are to be enqueued*/
1665 netInterface_priv_t *interfacePriv;
1666 u8 requeueOnSamePos = FALSE;
1667 u32 handle = 0xFFFFFFFF;
1668 unsigned long lock_flags;
1670 unifi_trace(priv, UDBG5,
1671 "entering uf_process_ma_packet_req, peer: %pMF\n",
1674 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
1675 unifi_error(priv, "interfaceTag >= CSR_WIFI_NUM_INTERFACES, interfacetag = %d\n", interfaceTag);
1676 return CSR_RESULT_FAILURE;
1678 interfacePriv = priv->interfacePriv[interfaceTag];
1681 /* fetch the station record for corresponding peer mac address */
1682 if ((staRecord = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, peerMacAddress, interfaceTag))) {
1683 handle = staRecord->assignedHandle;
1686 /* Frame ma-packet.req, this is saved/transmitted depend on queue state */
1687 unifi_frame_ma_packet_req(priv, priority, TransmitRate, hostTag,
1688 interfaceTag, transmissionControl, leSenderProcessId,
1689 peerMacAddress, &signal);
1691 /* Since it's common path between STA & AP mode, in case of STA packet
1692 * need not to be queued but in AP case we have to queue PDU's in
1693 * different scenarios
1695 switch(interfacePriv->interfaceMode)
1697 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
1698 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
1699 /* For this mode processing done below */
1702 /* In case of STA/IBSS/P2PCLI/AMP, no checks needed send the packet down & return */
1703 unifi_trace(priv, UDBG5, "In %s, interface mode is %x \n", __FUNCTION__, interfacePriv->interfaceMode);
1704 if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_NONE) {
1705 unifi_warning(priv, "In %s, interface mode NONE \n", __FUNCTION__);
1707 if ((result = ul_send_signal_unpacked(priv, &signal, bulkdata))) {
1708 status = CSR_RESULT_FAILURE;
1713 /* -----Only AP/P2pGO mode handling falls below----- */
1715 /* convert priority to queue */
1716 priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY) priority);
1718 /* check the powersave status of the peer */
1719 if (staRecord && (staRecord->currentPeerState ==
1720 CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)) {
1721 /* Peer is dozing & packet have to be delivered, so buffer the packet &
1724 queuePacketDozing = TRUE;
1727 /* find the type of frame unicast or mulicast/broadcast */
1728 if (*peerMacAddress & 0x1) {
1729 /* Multicast/broadCast data are always triggered by vif_availability.ind
1732 pktType = CSR_WIFI_MULTICAST_PDU;
1734 pktType = CSR_WIFI_UNICAST_PDU;
1737 /* Fetch the frame control field from mac header & check for frame type */
1738 frmCtrl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(macHdrLocation);
1740 /* Processing done according to Frame/Packet type */
1741 frameType = ((frmCtrl & 0x000c) >> FRAME_CONTROL_TYPE_FIELD_OFFSET);
1744 case IEEE802_11_FRAMETYPE_MANAGEMENT:
1748 case CSR_WIFI_UNICAST_PDU:
1749 unifi_trace(priv, UDBG5, "management unicast PDU in uf_process_ma_packet_req \n");
1750 /* push the packet in to the queue with appropriate mgt list */
1752 /* push the packet to the unifi if list is empty (if packet lost how to re-enque) */
1753 if (list_empty(&interfacePriv->genericMgtFrames)) {
1754 #ifdef CSR_SUPPORT_SME
1755 if(!(IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag))) {
1758 unifi_trace(priv, UDBG3, "genericMgtFrames list is empty uf_process_ma_packet_req \n");
1759 result = ul_send_signal_unpacked(priv, &signal, bulkdata);
1760 /* reque only on ENOSPC */
1761 if(result == -ENOSPC) {
1762 /* requeue the failed packet to genericMgtFrame with same position */
1763 unifi_trace(priv, UDBG1, "(ENOSPC) Sending genericMgtFrames Failed so buffering\n");
1764 list = &interfacePriv->genericMgtFrames;
1765 requeueOnSamePos = TRUE;
1767 #ifdef CSR_SUPPORT_SME
1769 list = &interfacePriv->genericMgtFrames;
1770 unifi_trace(priv, UDBG3, "genericMgtFrames queue empty and dtim started\n hosttag is 0x%x,\n",signal.u.MaPacketRequest.HostTag);
1771 update_eosp_to_head_of_broadcast_list_head(priv,interfaceTag);
1775 /* Queue the packet to genericMgtFrame of unifi_priv_t data structure */
1776 list = &interfacePriv->genericMgtFrames;
1777 unifi_trace(priv, UDBG2, "genericMgtFrames queue not empty\n");
1780 /* check peer power state */
1781 if (queuePacketDozing || !list_empty(&staRecord->mgtFrames) || IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag)) {
1782 /* peer is in dozing mode, so queue packet in mgt frame list of station record */
1783 /*if multicast traffic is going on, buffer the unicast packets*/
1784 list = &staRecord->mgtFrames;
1786 unifi_trace(priv, UDBG1, "staRecord->MgtFrames list empty? = %s, handle = %d, queuePacketDozing = %d\n",
1787 (list_empty(&staRecord->mgtFrames))? "YES": "NO", staRecord->assignedHandle, queuePacketDozing);
1788 if(IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag)){
1789 update_eosp_to_head_of_broadcast_list_head(priv,interfaceTag);
1793 unifi_trace(priv, UDBG5, "staRecord->mgtFrames list is empty uf_process_ma_packet_req \n");
1794 result = ul_send_signal_unpacked(priv, &signal, bulkdata);
1795 if(result == -ENOSPC) {
1796 /* requeue the failed packet to staRecord->mgtFrames with same position */
1797 list = &staRecord->mgtFrames;
1798 requeueOnSamePos = TRUE;
1799 unifi_trace(priv, UDBG1, "(ENOSPC) Sending MgtFrames Failed handle = %d so buffering\n",staRecord->assignedHandle);
1800 priv->pausedStaHandle[0]=(u8)(staRecord->assignedHandle);
1801 } else if (result) {
1802 status = CSR_RESULT_FAILURE;
1807 case CSR_WIFI_MULTICAST_PDU:
1808 unifi_trace(priv, UDBG5, "management multicast/broadcast PDU in uf_process_ma_packet_req 'QUEUE it' \n");
1809 /* Queue the packet to genericMulticastOrBroadCastMgtFrames of unifi_priv_t data structure
1810 * will be sent when we receive VIF AVAILABILITY from firmware as part of DTIM
1813 list = &interfacePriv->genericMulticastOrBroadCastMgtFrames;
1814 if((interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_IBSS) &&
1815 (list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames))) {
1820 unifi_error(priv, "condition never meets: packet type unrecognized\n");
1823 case IEEE802_11_FRAMETYPE_DATA:
1826 case CSR_WIFI_UNICAST_PDU:
1827 unifi_trace(priv, UDBG5, "data unicast PDU in uf_process_ma_packet_req \n");
1828 /* check peer power state, list status & peer port status */
1830 unifi_error(priv, "In %s unicast but staRecord = NULL\n", __FUNCTION__);
1831 return CSR_RESULT_FAILURE;
1832 } else if (queuePacketDozing || isRouterBufferEnabled(priv,priority_q)|| !list_empty(&staRecord->dataPdu[priority_q]) || IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag)) {
1833 /* peer is in dozing mode, so queue packet in mgt frame list of station record */
1834 /* if multicast traffic is going on, buffet the unicast packets */
1835 unifi_trace(priv, UDBG2, "Enqueued to staRecord->dataPdu[%d] queuePacketDozing=%d,\
1836 Buffering enabled = %d \n", priority_q,queuePacketDozing,isRouterBufferEnabled(priv,priority_q));
1837 list = &staRecord->dataPdu[priority_q];
1839 unifi_trace(priv, UDBG5, "staRecord->dataPdu[%d] list is empty uf_process_ma_packet_req \n", priority_q);
1840 /* Pdu allowed to send to unifi */
1841 result = ul_send_signal_unpacked(priv, &signal, bulkdata);
1842 if(result == -ENOSPC) {
1843 /* requeue the failed packet to staRecord->dataPdu[priority_q] with same position */
1844 unifi_trace(priv, UDBG1, "(ENOSPC) Sending Unicast DataPDU to queue %d Failed so buffering\n",priority_q);
1845 requeueOnSamePos = TRUE;
1846 list = &staRecord->dataPdu[priority_q];
1847 priv->pausedStaHandle[priority_q]=(u8)(staRecord->assignedHandle);
1848 if(!isRouterBufferEnabled(priv,priority_q)) {
1849 unifi_error(priv,"Buffering Not enabled for queue %d \n",priority_q);
1851 } else if (result) {
1852 status = CSR_RESULT_FAILURE;
1856 case CSR_WIFI_MULTICAST_PDU:
1857 unifi_trace(priv, UDBG5, "data multicast/broadcast PDU in uf_process_ma_packet_req \n");
1858 /* Queue the packet to genericMulticastOrBroadCastFrames list of unifi_priv_t data structure
1859 * will be sent when we receive VIF AVAILABILITY from firmware as part of DTIM
1861 list = &interfacePriv->genericMulticastOrBroadCastFrames;
1862 if(list_empty(&interfacePriv->genericMulticastOrBroadCastFrames)) {
1867 unifi_error(priv, "condition never meets: packet type un recognized\n");
1871 unifi_error(priv, "unrecognized frame type\n");
1874 status = enque_tx_data_pdu(priv, bulkdata,list, &signal,requeueOnSamePos);
1875 /* Record no. of packet queued for each peer */
1876 if (staRecord && (pktType == CSR_WIFI_UNICAST_PDU) && (!status)) {
1877 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
1878 staRecord->noOfPktQueued++;
1879 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
1881 else if ((pktType == CSR_WIFI_MULTICAST_PDU) && (!status))
1883 /* If broadcast Tim is set && queuing is successfull, then only update TIM */
1884 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
1885 interfacePriv->noOfbroadcastPktQueued++;
1886 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
1889 /* If broadcast Tim is set && queuing is successfull, then only update TIM */
1890 if(setBcTim && !status) {
1891 unifi_trace(priv, UDBG3, "tim set due to broadcast pkt\n");
1892 if (!interfacePriv->bcTimSetReqPendingFlag)
1894 update_tim(priv,0,CSR_WIFI_TIM_SET,interfaceTag, handle);
1898 /* Cache the TimSet value so that it will processed immidiatly after
1899 * completing the current setTim Request
1901 interfacePriv->bcTimSetReqQueued = CSR_WIFI_TIM_SET;
1902 unifi_trace(priv, UDBG2, "uf_process_ma_packet_req : One more UpdateDTim Request(:%d) Queued \n",
1903 interfacePriv->bcTimSetReqQueued);
1905 } else if(staRecord && staRecord->currentPeerState ==
1906 CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE) {
1907 if(staRecord->timSet == CSR_WIFI_TIM_RESET || staRecord->timSet == CSR_WIFI_TIM_RESETTING) {
1908 if(!staRecord->wmmOrQosEnabled) {
1909 if(!list_empty(&staRecord->mgtFrames) ||
1910 !list_empty(&staRecord->dataPdu[3]) ||
1911 !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION])) {
1912 unifi_trace(priv, UDBG3, "tim set due to unicast pkt & peer in powersave\n");
1913 if (!staRecord->timRequestPendingFlag){
1914 update_tim(priv,staRecord->aid,1,interfaceTag, handle);
1918 /* Cache the TimSet value so that it will processed immidiatly after
1919 * completing the current setTim Request
1921 staRecord->updateTimReqQueued = 1;
1922 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
1927 /* Check for non delivery enable(i.e trigger enable), all delivery enable & legacy AC for TIM update in firmware */
1928 u8 allDeliveryEnabled = 0, dataAvailable = 0;
1929 /* Check if all AC's are Delivery Enabled */
1930 is_all_ac_deliver_enabled_and_moredata(staRecord, &allDeliveryEnabled, &dataAvailable);
1931 if (uf_is_more_data_for_non_delivery_ac(staRecord) || (allDeliveryEnabled && dataAvailable)
1932 || (!list_empty(&staRecord->mgtFrames))) {
1933 if (!staRecord->timRequestPendingFlag) {
1934 update_tim(priv,staRecord->aid,1,interfaceTag, handle);
1938 /* Cache the TimSet value so that it will processed immidiatly after
1939 * completing the current setTim Request
1941 staRecord->updateTimReqQueued = 1;
1942 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
1950 if((list) && (pktType == CSR_WIFI_UNICAST_PDU && !queuePacketDozing) && !(isRouterBufferEnabled(priv,priority_q)) && !(IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag))) {
1951 unifi_trace(priv, UDBG2, "buffering cleared for queue = %d So resending buffered frames\n",priority_q);
1952 uf_send_buffered_frames(priv, priority_q);
1954 unifi_trace(priv, UDBG5, "leaving uf_process_ma_packet_req \n");
1957 #ifdef CSR_NATIVE_LINUX
1958 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
1959 unifi_error(priv, "interfaceTag >= CSR_WIFI_NUM_INTERFACES, interfacetag = %d\n", interfaceTag);
1960 return CSR_RESULT_FAILURE;
1962 /* Frame ma-packet.req, this is saved/transmitted depend on queue state */
1963 unifi_frame_ma_packet_req(priv, priority, TransmitRate, hostTag, interfaceTag,
1964 transmissionControl, leSenderProcessId,
1965 peerMacAddress, &signal);
1966 result = ul_send_signal_unpacked(priv, &signal, bulkdata);
1968 return CSR_RESULT_FAILURE;
1975 #ifdef CSR_SUPPORT_SME
1976 s8 uf_get_protection_bit_from_interfacemode(unifi_priv_t *priv, u16 interfaceTag, const u8 *daddr)
1979 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
1981 switch(interfacePriv->interfaceMode)
1983 case CSR_WIFI_ROUTER_CTRL_MODE_STA:
1984 case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
1985 case CSR_WIFI_ROUTER_CTRL_MODE_AMP:
1986 case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
1987 protection = interfacePriv->protect;
1989 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
1990 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
1992 CsrWifiRouterCtrlStaInfo_t *dstStaInfo = NULL;
1993 if (daddr[0] & 0x1) {
1994 unifi_trace(priv, UDBG3, "broadcast/multicast packet in send_ma_pkt_request\n");
1995 /* In this mode, the protect member of priv structure has an information of how
1996 * AP/P2PGO has started, & the member updated in set mode request for AP/P2PGO
1998 protection = interfacePriv->protect;
2000 /* fetch the destination record from staion record database */
2001 dstStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, daddr, interfaceTag);
2003 unifi_trace(priv, UDBG3, "peer not found in station record in send_ma_pkt_request\n");
2006 protection = dstStaInfo->protection;
2011 unifi_trace(priv, UDBG2, "mode unknown in send_ma_pkt_request\n");
2016 #ifdef CSR_SUPPORT_SME
2017 u8 send_multicast_frames(unifi_priv_t *priv, u16 interfaceTag)
2020 tx_buffered_packets_t * buffered_pkt = NULL;
2021 u8 moreData = FALSE;
2023 unsigned long lock_flags;
2024 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2025 u32 hostTag = 0xffffffff;
2028 if(!isRouterBufferEnabled(priv,UNIFI_TRAFFIC_Q_VO)) {
2029 while((interfacePriv->dtimActive)&& (buffered_pkt=dequeue_tx_data_pdu(priv,&interfacePriv->genericMulticastOrBroadCastMgtFrames))) {
2030 buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK);
2031 moreData = (buffered_pkt->transmissionControl & TRANSMISSION_CONTROL_EOSP_MASK)?FALSE:TRUE;
2034 unifi_trace(priv,UDBG2,"DTIM Occurred for interface:sending Mgt packet %d\n",interfaceTag);
2036 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,NULL,moreData,FALSE)) == -ENOSPC) {
2037 unifi_trace(priv,UDBG1,"frame_and_send_queued_pdu failed with ENOSPC for host tag = %x\n", buffered_pkt->hostTag);
2038 /* Enqueue at the head of the queue */
2039 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
2040 list_add(&buffered_pkt->q, &interfacePriv->genericMulticastOrBroadCastMgtFrames);
2041 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
2044 unifi_trace(priv,UDBG1,"send_multicast_frames: Send genericMulticastOrBroadCastMgtFrames (%x, %x)\n",
2045 buffered_pkt->hostTag,
2048 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
2052 interfacePriv->dtimActive = FALSE;
2054 hostTag = buffered_pkt->hostTag;
2057 send_vif_availibility_rsp(priv,uf_get_vif_identifier(interfacePriv->interfaceMode,interfaceTag),CSR_RC_UNSPECIFIED_FAILURE);
2060 /* Buffered frame sent successfully */
2061 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2062 interfacePriv->noOfbroadcastPktQueued--;
2063 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2064 kfree(buffered_pkt);
2069 if(!isRouterBufferEnabled(priv,UNIFI_TRAFFIC_Q_CONTENTION)) {
2070 while((interfacePriv->dtimActive)&& (buffered_pkt=dequeue_tx_data_pdu(priv,&interfacePriv->genericMulticastOrBroadCastFrames))) {
2071 buffered_pkt->transmissionControl |= TRANSMISSION_CONTROL_TRIGGER_MASK;
2072 moreData = (buffered_pkt->transmissionControl & TRANSMISSION_CONTROL_EOSP_MASK)?FALSE:TRUE;
2075 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,NULL,moreData,FALSE)) == -ENOSPC) {
2076 /* Clear the trigger bit transmission control*/
2077 buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK);
2078 /* Enqueue at the head of the queue */
2079 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
2080 list_add(&buffered_pkt->q, &interfacePriv->genericMulticastOrBroadCastFrames);
2081 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
2085 unifi_trace(priv,UDBG1,"send_multicast_frames: Send genericMulticastOrBroadCastFrame failed (%x, %x)\n",
2086 buffered_pkt->hostTag,
2088 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
2091 interfacePriv->dtimActive = FALSE;
2094 hostTag = buffered_pkt->hostTag;
2096 send_vif_availibility_rsp(priv,uf_get_vif_identifier(interfacePriv->interfaceMode,interfaceTag),CSR_RC_UNSPECIFIED_FAILURE);
2099 /* Buffered frame sent successfully */
2100 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2101 interfacePriv->noOfbroadcastPktQueued--;
2102 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2103 kfree(buffered_pkt);
2107 if((interfacePriv->dtimActive == FALSE)) {
2108 /* Record the host Tag*/
2109 unifi_trace(priv,UDBG2,"send_multicast_frames: Recorded hostTag of EOSP packet: = 0x%x\n",hostTag);
2110 interfacePriv->multicastPduHostTag = hostTag;
2115 void uf_process_ma_vif_availibility_ind(unifi_priv_t *priv,u8 *sigdata,
2118 #ifdef CSR_SUPPORT_SME
2120 CSR_MA_VIF_AVAILABILITY_INDICATION *ind;
2124 CSR_RESULT_CODE resultCode = CSR_RC_SUCCESS;
2125 netInterface_priv_t *interfacePriv;
2128 unifi_trace(priv, UDBG3,
2129 "uf_process_ma_vif_availibility_ind: Process signal 0x%.4X\n",
2132 r = read_unpack_signal(sigdata, &signal);
2135 "uf_process_ma_vif_availibility_ind: Received unknown signal 0x%.4X.\n",
2136 CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata));
2140 ind = &signal.u.MaVifAvailabilityIndication;
2141 interfaceTag=ind->VirtualInterfaceIdentifier & 0xff;
2143 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
2144 unifi_error(priv, "in vif_availability_ind interfaceTag is wrong\n");
2148 interfacePriv = priv->interfacePriv[interfaceTag];
2150 if(ind->Multicast) {
2151 if(list_empty(&interfacePriv->genericMulticastOrBroadCastFrames) &&
2152 list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames)) {
2153 /* This condition can occur because of a potential race where the
2154 TIM is not yet reset as host is waiting for confirm but it is sent
2155 by firmware and DTIM occurs*/
2156 unifi_notice(priv,"ma_vif_availibility_ind recevied for multicast but queues are empty%d\n",interfaceTag);
2157 send_vif_availibility_rsp(priv,ind->VirtualInterfaceIdentifier,CSR_RC_NO_BUFFERED_BROADCAST_MULTICAST_FRAMES);
2158 interfacePriv->dtimActive = FALSE;
2159 if(interfacePriv->multicastPduHostTag == 0xffffffff) {
2160 unifi_notice(priv,"ma_vif_availibility_ind recevied for multicast but queues are empty%d\n",interfaceTag);
2161 /* This may be an extra request in very rare race conditions but it is fine as it would atleast remove the potential lock up */
2162 if (!interfacePriv->bcTimSetReqPendingFlag)
2164 update_tim(priv,0,CSR_WIFI_TIM_RESET,interfaceTag, 0xFFFFFFFF);
2168 /* Cache the TimSet value so that it will processed immidiatly after
2169 * completing the current setTim Request
2171 interfacePriv->bcTimSetReqQueued = CSR_WIFI_TIM_RESET;
2172 unifi_trace(priv, UDBG2, "uf_process_ma_vif_availibility_ind : One more UpdateDTim Request(%d) Queued \n",
2173 interfacePriv->bcTimSetReqQueued);
2178 if(interfacePriv->dtimActive) {
2179 unifi_trace(priv,UDBG2,"DTIM Occurred for already active DTIM interface %d\n",interfaceTag);
2182 unifi_trace(priv,UDBG2,"DTIM Occurred for interface %d\n",interfaceTag);
2183 if(list_empty(&interfacePriv->genericMulticastOrBroadCastFrames)) {
2184 set_eosp_transmit_ctrl(priv,&interfacePriv->genericMulticastOrBroadCastMgtFrames);
2186 set_eosp_transmit_ctrl(priv,&interfacePriv->genericMulticastOrBroadCastFrames);
2189 interfacePriv->dtimActive = TRUE;
2190 pduSent = send_multicast_frames(priv,interfaceTag);
2193 unifi_error(priv,"Interface switching is not supported %d\n",interfaceTag);
2194 resultCode = CSR_RC_NOT_SUPPORTED;
2195 send_vif_availibility_rsp(priv,ind->VirtualInterfaceIdentifier,CSR_RC_NOT_SUPPORTED);
2199 #ifdef CSR_SUPPORT_SME
2201 #define GET_ACTIVE_INTERFACE_TAG(priv) 0
2203 static u8 uf_is_more_data_for_delivery_ac(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t *staRecord)
2207 for(i=UNIFI_TRAFFIC_Q_VO; i >= UNIFI_TRAFFIC_Q_BK; i--)
2209 if(((staRecord->powersaveMode[i]==CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)
2210 ||(staRecord->powersaveMode[i]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED))
2211 &&(!list_empty(&staRecord->dataPdu[i]))) {
2212 unifi_trace(priv,UDBG2,"uf_is_more_data_for_delivery_ac: Data Available AC = %d\n", i);
2217 unifi_trace(priv,UDBG2,"uf_is_more_data_for_delivery_ac: Data NOT Available \n");
2221 static u8 uf_is_more_data_for_usp_delivery(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t *staRecord, unifi_TrafficQueue queue)
2225 for(i = queue; i >= UNIFI_TRAFFIC_Q_BK; i--)
2227 if(((staRecord->powersaveMode[i]==CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)
2228 ||(staRecord->powersaveMode[i]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED))
2229 &&(!list_empty(&staRecord->dataPdu[i]))) {
2230 unifi_trace(priv,UDBG2,"uf_is_more_data_for_usp_delivery: Data Available AC = %d\n", i);
2235 unifi_trace(priv,UDBG2,"uf_is_more_data_for_usp_delivery: Data NOT Available \n");
2240 * ---------------------------------------------------------------------------
2241 * uf_send_buffered_data_from_delivery_ac
2243 * This function takes care of
2244 * -> Parsing the delivery enabled queue & sending frame down to HIP
2245 * -> Setting EOSP=1 when USP to be terminated
2246 * -> Depending on MAX SP length services the USP
2248 * NOTE:This function always called from uf_handle_uspframes_delivery(), Dont
2249 * call this function from any other location in code
2252 * priv Pointer to device private context struct
2253 * vif interface specific HIP vif instance
2254 * staInfo peer for which UAPSD to be scheduled
2255 * queue AC from which Data to be sent in USP
2256 * txList access category for processing list
2257 * ---------------------------------------------------------------------------
2259 void uf_send_buffered_data_from_delivery_ac(unifi_priv_t *priv,
2260 CsrWifiRouterCtrlStaInfo_t * staInfo,
2262 struct list_head *txList)
2265 u16 interfaceTag = GET_ACTIVE_INTERFACE_TAG(priv);
2266 tx_buffered_packets_t * buffered_pkt = NULL;
2267 unsigned long lock_flags;
2270 u8 moreData = FALSE;
2271 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2273 unifi_trace(priv, UDBG2, "++uf_send_buffered_data_from_delivery_ac, active=%x\n", staInfo->uapsdActive);
2275 if (queue > UNIFI_TRAFFIC_Q_VO)
2279 while((buffered_pkt=dequeue_tx_data_pdu(priv, txList))) {
2280 if((IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag))) {
2281 unifi_trace(priv, UDBG2, "uf_send_buffered_data_from_delivery_ac: DTIM Active, suspend UAPSD, staId: 0x%x\n",
2284 /* Once resume called, the U-APSD delivery operation will resume */
2285 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2286 staInfo->uspSuspend = TRUE;
2287 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2288 /* re-queueing the packet as DTIM started */
2289 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
2290 list_add(&buffered_pkt->q,txList);
2291 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
2295 buffered_pkt->transmissionControl &=
2296 ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
2299 if((staInfo->wmmOrQosEnabled == TRUE)&&(staInfo->uapsdActive == TRUE)) {
2301 buffered_pkt->transmissionControl = TRANSMISSION_CONTROL_TRIGGER_MASK;
2303 /* Check All delivery enables Ac for more data, because caller of this
2304 * function not aware about last packet
2305 * (First check in moreData fetching helps in draining out Mgt frames Q)
2307 moreData = (!list_empty(txList) || uf_is_more_data_for_usp_delivery(priv, staInfo, queue));
2309 if(staInfo->noOfSpFramesSent == (staInfo->maxSpLength - 1)) {
2313 if(moreData == FALSE) {
2315 buffered_pkt->transmissionControl =
2316 (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
2319 /* Non QoS and non U-APSD */
2320 unifi_warning(priv, "uf_send_buffered_data_from_delivery_ac: non U-APSD !!! \n");
2323 unifi_trace(priv,UDBG2,"uf_send_buffered_data_from_delivery_ac : MoreData:%d, EOSP:%d\n",moreData,eosp);
2325 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staInfo,moreData,eosp)) == -ENOSPC) {
2327 unifi_trace(priv, UDBG2, "uf_send_buffered_data_from_delivery_ac: UASPD suspended, ENOSPC in hipQ=%x\n", queue);
2329 /* Once resume called, the U-APSD delivery operation will resume */
2330 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2331 staInfo->uspSuspend = TRUE;
2332 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2334 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
2335 list_add(&buffered_pkt->q,txList);
2336 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
2337 priv->pausedStaHandle[queue]=(u8)(staInfo->assignedHandle);
2341 /* the PDU failed where we can't do any thing so free the storage */
2342 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
2344 kfree(buffered_pkt);
2345 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2346 staInfo->noOfSpFramesSent++;
2347 if((!moreData) || (staInfo->noOfSpFramesSent == staInfo->maxSpLength)) {
2348 unifi_trace(priv, UDBG2, "uf_send_buffered_data_from_delivery_ac: Terminating USP\n");
2349 staInfo->uapsdActive = FALSE;
2350 staInfo->uspSuspend = FALSE;
2351 staInfo->noOfSpFramesSent = 0;
2352 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2355 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2358 unifi_trace(priv, UDBG2, "--uf_send_buffered_data_from_delivery_ac, active=%x\n", staInfo->uapsdActive);
2361 void uf_send_buffered_data_from_ac(unifi_priv_t *priv,
2362 CsrWifiRouterCtrlStaInfo_t * staInfo,
2364 struct list_head *txList)
2366 tx_buffered_packets_t * buffered_pkt = NULL;
2367 unsigned long lock_flags;
2369 u8 moreData = FALSE;
2374 unifi_trace(priv,UDBG2,"uf_send_buffered_data_from_ac :\n");
2376 while(!isRouterBufferEnabled(priv,queue) &&
2377 ((buffered_pkt=dequeue_tx_data_pdu(priv, txList))!=NULL)){
2379 buffered_pkt->transmissionControl &=
2380 ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
2382 unifi_trace(priv,UDBG3,"uf_send_buffered_data_from_ac : MoreData:%d, EOSP:%d\n",moreData,eosp);
2384 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staInfo,moreData,eosp)) == -ENOSPC) {
2385 /* Enqueue at the head of the queue */
2386 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
2387 list_add(&buffered_pkt->q,txList);
2388 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
2389 if(staInfo != NULL){
2390 priv->pausedStaHandle[queue]=(u8)(staInfo->assignedHandle);
2392 unifi_trace(priv,UDBG3," uf_send_buffered_data_from_ac: PDU sending failed .. no space for queue %d \n",queue);
2395 /* the PDU failed where we can't do any thing so free the storage */
2396 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
2398 kfree(buffered_pkt);
2406 void uf_send_buffered_frames(unifi_priv_t *priv,unifi_TrafficQueue q)
2408 u16 interfaceTag = GET_ACTIVE_INTERFACE_TAG(priv);
2409 u32 startIndex=0,endIndex=0;
2410 CsrWifiRouterCtrlStaInfo_t * staInfo = NULL;
2412 u8 moreData = FALSE;
2414 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2416 if(!((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP) ||
2417 (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO)))
2423 if(interfacePriv->dtimActive) {
2424 /* this function updates dtimActive*/
2425 send_multicast_frames(priv,interfaceTag);
2426 if(!interfacePriv->dtimActive) {
2427 moreData = (!list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames) ||
2428 !list_empty(&interfacePriv->genericMulticastOrBroadCastFrames));
2430 if (!interfacePriv->bcTimSetReqPendingFlag)
2432 update_tim(priv,0,CSR_WIFI_TIM_RESET,interfaceTag, 0XFFFFFFFF);
2436 /* Cache the TimSet value so that it will processed immidiatly after
2437 * completing the current setTim Request
2439 interfacePriv->bcTimSetReqQueued = CSR_WIFI_TIM_RESET;
2440 unifi_trace(priv, UDBG2, "uf_send_buffered_frames : One more UpdateDTim Request(%d) Queued \n",
2441 interfacePriv->bcTimSetReqQueued);
2445 moreData = (!list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames) ||
2446 !list_empty(&interfacePriv->genericMulticastOrBroadCastFrames));
2448 /* This should never happen but if it happens, we need a way out */
2449 unifi_error(priv,"ERROR: No More Data but DTIM is active sending Response\n");
2450 send_vif_availibility_rsp(priv,uf_get_vif_identifier(interfacePriv->interfaceMode,interfaceTag),CSR_RC_NO_BUFFERED_BROADCAST_MULTICAST_FRAMES);
2451 interfacePriv->dtimActive = FALSE;
2457 if(priv->pausedStaHandle[queue] > 7) {
2458 priv->pausedStaHandle[queue] = 0;
2461 if(queue == UNIFI_TRAFFIC_Q_VO) {
2464 unifi_trace(priv,UDBG2,"uf_send_buffered_frames : trying mgt from queue=%d\n",queue);
2465 for(startIndex= 0; startIndex < UNIFI_MAX_CONNECTIONS;startIndex++) {
2466 staInfo = CsrWifiRouterCtrlGetStationRecordFromHandle(priv,startIndex,interfaceTag);
2469 } else if((staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)
2470 &&(staInfo->uapsdActive == FALSE) ) {
2474 if((staInfo != NULL)&&(staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE)
2475 &&(staInfo->uapsdActive == FALSE)){
2476 /*Non-UAPSD case push the management frames out*/
2477 if(!list_empty(&staInfo->mgtFrames)){
2478 uf_send_buffered_data_from_ac(priv,staInfo, UNIFI_TRAFFIC_Q_VO, &staInfo->mgtFrames);
2482 if(isRouterBufferEnabled(priv,queue)) {
2483 unifi_notice(priv,"uf_send_buffered_frames : No space Left for queue = %d\n",queue);
2487 /*push generic management frames out*/
2488 if(!list_empty(&interfacePriv->genericMgtFrames)) {
2489 unifi_trace(priv,UDBG2,"uf_send_buffered_frames : trying generic mgt from queue=%d\n",queue);
2490 uf_send_buffered_data_from_ac(priv,staInfo, UNIFI_TRAFFIC_Q_VO, &interfacePriv->genericMgtFrames);
2495 unifi_trace(priv,UDBG2,"uf_send_buffered_frames : Resume called for Queue=%d\n",queue);
2496 unifi_trace(priv,UDBG2,"uf_send_buffered_frames : start=%d end=%d\n",startIndex,endIndex);
2498 startIndex = priv->pausedStaHandle[queue];
2499 endIndex = (startIndex + UNIFI_MAX_CONNECTIONS -1) % UNIFI_MAX_CONNECTIONS;
2501 while(startIndex != endIndex) {
2502 staInfo = CsrWifiRouterCtrlGetStationRecordFromHandle(priv,startIndex,interfaceTag);
2505 if(startIndex >= UNIFI_MAX_CONNECTIONS) {
2509 } else if((staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)
2510 &&(staInfo->uapsdActive == FALSE)) {
2512 if(startIndex >= UNIFI_MAX_CONNECTIONS) {
2517 /* Peer is active or U-APSD is active so send PDUs to the peer */
2518 unifi_trace(priv,UDBG2,"uf_send_buffered_frames : trying data from queue=%d\n",queue);
2521 if((staInfo != NULL)&&(staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE)
2522 &&(staInfo->uapsdActive == FALSE)) {
2523 if(!list_empty(&staInfo->dataPdu[queue])) {
2525 /*Non-UAPSD case push the AC frames out*/
2526 uf_send_buffered_data_from_ac(priv, staInfo, queue, (&staInfo->dataPdu[queue]));
2530 if(startIndex >= UNIFI_MAX_CONNECTIONS) {
2534 if(isRouterBufferEnabled(priv,queue)) {
2535 priv->pausedStaHandle[queue] = endIndex;
2537 priv->pausedStaHandle[queue] = 0;
2540 /* U-APSD might have stopped because of ENOSPC in lib_hip (pause activity).
2541 * So restart it if U-APSD was active with any of the station
2543 unifi_trace(priv, UDBG4, "csrWifiHipSendBufferedFrames: UAPSD Resume Q=%x\n", queue);
2544 resume_suspended_uapsd(priv, interfaceTag);
2549 u8 uf_is_more_data_for_non_delivery_ac(CsrWifiRouterCtrlStaInfo_t *staRecord)
2555 if(((staRecord->powersaveMode[i]==CSR_WIFI_AC_TRIGGER_ONLY_ENABLED)
2556 ||(staRecord->powersaveMode[i]==CSR_WIFI_AC_LEGACY_POWER_SAVE))
2557 &&(!list_empty(&staRecord->dataPdu[i]))){
2563 if(((staRecord->powersaveMode[UNIFI_TRAFFIC_Q_VO]==CSR_WIFI_AC_TRIGGER_ONLY_ENABLED)
2564 ||(staRecord->powersaveMode[UNIFI_TRAFFIC_Q_VO]==CSR_WIFI_AC_LEGACY_POWER_SAVE))
2565 &&(!list_empty(&staRecord->mgtFrames))){
2576 int uf_process_station_records_for_sending_data(unifi_priv_t *priv,u16 interfaceTag,
2577 CsrWifiRouterCtrlStaInfo_t *srcStaInfo,
2578 CsrWifiRouterCtrlStaInfo_t *dstStaInfo)
2580 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2582 unifi_trace(priv, UDBG5, "entering uf_process_station_records_for_sending_data\n");
2584 if (srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_DISCONNECTED) {
2585 unifi_error(priv, "Peer State not connected AID = %x, handle = %x, control port state = %x\n",
2586 srcStaInfo->aid, srcStaInfo->assignedHandle, srcStaInfo->peerControlledPort->port_action);
2589 switch (interfacePriv->interfaceMode)
2591 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
2592 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
2593 unifi_trace(priv, UDBG5, "mode is AP/P2PGO\n");
2596 unifi_warning(priv, "mode is nor AP neither P2PGO, packet cant be xmit\n");
2600 switch(dstStaInfo->peerControlledPort->port_action)
2602 case CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD:
2603 case CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_BLOCK:
2604 unifi_trace(priv, UDBG5, "destination port is closed/blocked, discarding the packet\n");
2607 unifi_trace(priv, UDBG5, "destination port state is open\n");
2610 /* port state is open, destination station record is valid, Power save state is
2611 * validated in uf_process_ma_packet_req function
2613 unifi_trace(priv, UDBG5, "leaving uf_process_station_records_for_sending_data\n");
2619 * ---------------------------------------------------------------------------
2620 * uf_handle_uspframes_delivery
2622 * This function takes care of handling USP session for peer, when
2623 * -> trigger frame from peer
2624 * -> suspended USP to be processed (resumed)
2626 * NOTE: uf_send_buffered_data_from_delivery_ac() always called from this function, Dont
2627 * make a direct call to uf_send_buffered_data_from_delivery_ac() from any other part of
2631 * priv Pointer to device private context struct
2632 * staInfo peer for which UAPSD to be scheduled
2633 * interfaceTag virtual interface tag
2634 * ---------------------------------------------------------------------------
2636 static void uf_handle_uspframes_delivery(unifi_priv_t * priv, CsrWifiRouterCtrlStaInfo_t *staInfo, u16 interfaceTag)
2640 u8 allDeliveryEnabled = 0, dataAvailable = 0;
2641 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2642 unsigned long lock_flags;
2644 unifi_trace(priv, UDBG2, " ++ uf_handle_uspframes_delivery, uapsd active=%x, suspended?=%x\n",
2645 staInfo->uapsdActive, staInfo->uspSuspend);
2647 /* Check for Buffered frames according to priority order & deliver it
2648 * 1. AC_VO delivery enable & Mgt frames available
2649 * 2. Process remaining Ac's from order AC_VO to AC_BK
2652 /* USP initiated by WMMPS enabled peer & SET the status flag to TRUE */
2653 if (!staInfo->uspSuspend && staInfo->uapsdActive)
2655 unifi_notice(priv, "uf_handle_uspframes_delivery: U-APSD already active! STA=%x:%x:%x:%x:%x:%x\n",
2656 staInfo->peerMacAddress.a[0], staInfo->peerMacAddress.a[1],
2657 staInfo->peerMacAddress.a[2], staInfo->peerMacAddress.a[3],
2658 staInfo->peerMacAddress.a[4], staInfo->peerMacAddress.a[5]);
2662 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2663 staInfo->uapsdActive = TRUE;
2664 staInfo->uspSuspend = FALSE;
2665 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2667 if(((staInfo->powersaveMode[UNIFI_TRAFFIC_Q_VO]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED)||
2668 (staInfo->powersaveMode[UNIFI_TRAFFIC_Q_VO]==CSR_WIFI_AC_DELIVERY_ONLY_ENABLE))
2669 && (!list_empty(&staInfo->mgtFrames))) {
2671 /* Management queue has data && UNIFI_TRAFFIC_Q_VO is delivery enable */
2672 unifi_trace(priv, UDBG4, "uf_handle_uspframes_delivery: Sending buffered management frames\n");
2673 uf_send_buffered_data_from_delivery_ac(priv, staInfo, UNIFI_TRAFFIC_Q_VO, &staInfo->mgtFrames);
2676 if (!uf_is_more_data_for_delivery_ac(priv, staInfo)) {
2677 /* All delivery enable AC's are empty, so QNULL to be sent to terminate the USP
2678 * NOTE: If we have sent Mgt frame also, we must send QNULL followed to terminate USP
2680 if (!staInfo->uspSuspend) {
2681 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2682 staInfo->uapsdActive = FALSE;
2683 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2685 unifi_trace(priv, UDBG2, "uf_handle_uspframes_delivery: sending QNull for trigger\n");
2686 uf_send_qos_null(priv, interfaceTag, staInfo->peerMacAddress.a, (CSR_PRIORITY) staInfo->triggerFramePriority, staInfo);
2687 staInfo->triggerFramePriority = CSR_QOS_UP0;
2689 unifi_trace(priv, UDBG2, "uf_handle_uspframes_delivery: MgtQ xfer suspended\n");
2692 for(i = UNIFI_TRAFFIC_Q_VO; i >= UNIFI_TRAFFIC_Q_BK; i--) {
2693 if(((staInfo->powersaveMode[i]==CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)
2694 ||(staInfo->powersaveMode[i]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED))
2695 && (!list_empty(&staInfo->dataPdu[i]))) {
2696 /* Deliver Data according to AC priority (from VO to BK) as part of USP */
2697 unifi_trace(priv, UDBG4, "uf_handle_uspframes_delivery: Buffered data frames from Queue (%d) for USP\n", i);
2698 uf_send_buffered_data_from_delivery_ac(priv, staInfo, i, &staInfo->dataPdu[i]);
2701 if ((!staInfo->uapsdActive) ||
2702 (staInfo->uspSuspend && IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag))) {
2703 /* If DTIM active found on one AC, No need to parse the remaining AC's
2704 * as USP suspended. Break out of loop
2706 unifi_trace(priv, UDBG2, "uf_handle_uspframes_delivery: suspend=%x, DTIM=%x, USP terminated=%s\n",
2707 staInfo->uspSuspend, IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag),
2708 staInfo->uapsdActive?"NO":"YES");
2714 /* Depending on the USP status, update the TIM accordingly for delivery enabled AC only
2715 * (since we are not manipulating any Non-delivery list(AC))
2717 is_all_ac_deliver_enabled_and_moredata(staInfo, &allDeliveryEnabled, &dataAvailable);
2718 if ((allDeliveryEnabled && !dataAvailable)) {
2719 if ((staInfo->timSet != CSR_WIFI_TIM_RESET) || (staInfo->timSet != CSR_WIFI_TIM_RESETTING)) {
2720 staInfo->updateTimReqQueued = (u8) CSR_WIFI_TIM_RESET;
2721 unifi_trace(priv, UDBG4, " --uf_handle_uspframes_delivery, UAPSD timset\n");
2722 if (!staInfo->timRequestPendingFlag) {
2723 update_tim(priv, staInfo->aid, 0, interfaceTag, staInfo->assignedHandle);
2727 unifi_trace(priv, UDBG2, " --uf_handle_uspframes_delivery, uapsd active=%x, suspend?=%x\n",
2728 staInfo->uapsdActive, staInfo->uspSuspend);
2731 void uf_process_wmm_deliver_ac_uapsd(unifi_priv_t * priv,
2732 CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
2736 CSR_PRIORITY priority;
2737 unifi_TrafficQueue priority_q;
2738 unsigned long lock_flags;
2740 unifi_trace(priv, UDBG2, "++uf_process_wmm_deliver_ac_uapsd: uapsdactive?=%x\n", srcStaInfo->uapsdActive);
2741 /* If recceived Frames trigger Frame and Devlivery enabled AC has data
2742 * then transmit from High priorty delivery enabled AC
2744 priority = (CSR_PRIORITY)(qosControl & IEEE802_11_QC_TID_MASK);
2745 priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY) priority);
2747 if((srcStaInfo->powersaveMode[priority_q]==CSR_WIFI_AC_TRIGGER_ONLY_ENABLED)
2748 ||(srcStaInfo->powersaveMode[priority_q]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED)) {
2749 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2750 srcStaInfo->triggerFramePriority = priority;
2751 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2752 unifi_trace(priv, UDBG2, "uf_process_wmm_deliver_ac_uapsd: trigger frame, Begin U-APSD, triggerQ=%x\n", priority_q);
2753 uf_handle_uspframes_delivery(priv, srcStaInfo, interfaceTag);
2755 unifi_trace(priv, UDBG2, "--uf_process_wmm_deliver_ac_uapsd: uapsdactive?=%x\n", srcStaInfo->uapsdActive);
2759 void uf_send_qos_null(unifi_priv_t * priv,u16 interfaceTag, const u8 *da,CSR_PRIORITY priority,CsrWifiRouterCtrlStaInfo_t * srcStaInfo)
2761 bulk_data_param_t bulkdata;
2762 CsrResult csrResult;
2763 struct sk_buff *skb, *newSkb = NULL;
2764 CsrWifiMacAddress peerAddress;
2765 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2766 CSR_TRANSMISSION_CONTROL transmissionControl = (TRANSMISSION_CONTROL_EOSP_MASK | TRANSMISSION_CONTROL_TRIGGER_MASK);
2770 CSR_RATE transmitRate = 0;
2774 /* Send a Null Frame to Peer,
2775 * 32= size of mac header */
2776 csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], MAC_HEADER_SIZE + QOS_CONTROL_HEADER_SIZE);
2778 if (csrResult != CSR_RESULT_SUCCESS) {
2779 unifi_error(priv, " failed to allocate request_data. in uf_send_qos_null func\n");
2782 skb = (struct sk_buff *)(bulkdata.d[0].os_net_buf_ptr);
2784 bulkdata.d[0].os_data_ptr = skb->data;
2785 bulkdata.d[0].os_net_buf_ptr = (unsigned char*)skb;
2786 bulkdata.d[0].net_buf_length = bulkdata.d[0].data_length = skb->len;
2787 bulkdata.d[1].os_data_ptr = NULL;
2788 bulkdata.d[1].os_net_buf_ptr = NULL;
2789 bulkdata.d[1].net_buf_length = bulkdata.d[1].data_length = 0;
2791 /* For null frames protection bit should not be set in MAC header, so passing value 0 below for protection field */
2793 if (prepare_and_add_macheader(priv, skb, newSkb, priority, &bulkdata, interfaceTag, da, interfacePriv->bssid.a, 0)) {
2794 unifi_error(priv, "failed to create MAC header\n");
2795 unifi_net_data_free(priv, &bulkdata.d[0]);
2798 memcpy(peerAddress.a, ((u8 *) bulkdata.d[0].os_data_ptr) + 4, ETH_ALEN);
2799 /* convert priority to queue */
2800 priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY) priority);
2802 /* Frame ma-packet.req, this is saved/transmitted depend on queue state
2803 * send the null frame at data rate of 1 Mb/s for AP or 6 Mb/s for P2PGO
2805 switch (interfacePriv->interfaceMode)
2807 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
2810 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
2816 unifi_frame_ma_packet_req(priv, priority, transmitRate, 0xffffffff, interfaceTag,
2817 transmissionControl, priv->netdev_client->sender_id,
2818 peerAddress.a, &signal);
2820 r = ul_send_signal_unpacked(priv, &signal, &bulkdata);
2822 unifi_error(priv, "failed to send QOS data null packet result: %d\n",r);
2823 unifi_net_data_free(priv, &bulkdata.d[0]);
2830 void uf_send_nulldata(unifi_priv_t * priv,u16 interfaceTag, const u8 *da,CSR_PRIORITY priority,CsrWifiRouterCtrlStaInfo_t * srcStaInfo)
2832 bulk_data_param_t bulkdata;
2833 CsrResult csrResult;
2834 struct sk_buff *skb, *newSkb = NULL;
2835 CsrWifiMacAddress peerAddress;
2836 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2837 CSR_TRANSMISSION_CONTROL transmissionControl = 0;
2841 CSR_RATE transmitRate = 0;
2842 CSR_MA_PACKET_REQUEST *req = &signal.u.MaPacketRequest;
2843 unsigned long lock_flags;
2846 /* Send a Null Frame to Peer, size = 24 for MAC header */
2847 csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], MAC_HEADER_SIZE);
2849 if (csrResult != CSR_RESULT_SUCCESS) {
2850 unifi_error(priv, "uf_send_nulldata: Failed to allocate memory for NULL frame\n");
2853 skb = (struct sk_buff *)(bulkdata.d[0].os_net_buf_ptr);
2855 bulkdata.d[0].os_data_ptr = skb->data;
2856 bulkdata.d[0].os_net_buf_ptr = (unsigned char*)skb;
2857 bulkdata.d[0].net_buf_length = bulkdata.d[0].data_length = skb->len;
2858 bulkdata.d[1].os_data_ptr = NULL;
2859 bulkdata.d[1].os_net_buf_ptr = NULL;
2860 bulkdata.d[1].net_buf_length = bulkdata.d[1].data_length = 0;
2862 /* For null frames protection bit should not be set in MAC header, so passing value 0 below for protection field */
2863 if (prepare_and_add_macheader(priv, skb, newSkb, priority, &bulkdata, interfaceTag, da, interfacePriv->bssid.a, 0)) {
2864 unifi_error(priv, "uf_send_nulldata: Failed to create MAC header\n");
2865 unifi_net_data_free(priv, &bulkdata.d[0]);
2868 memcpy(peerAddress.a, ((u8 *) bulkdata.d[0].os_data_ptr) + 4, ETH_ALEN);
2869 /* convert priority to queue */
2870 priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY) priority);
2871 transmissionControl &= ~(CSR_NO_CONFIRM_REQUIRED);
2873 /* Frame ma-packet.req, this is saved/transmitted depend on queue state
2874 * send the null frame at data rate of 1 Mb/s for AP or 6 Mb/s for P2PGO
2876 switch (interfacePriv->interfaceMode)
2878 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
2881 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
2887 unifi_frame_ma_packet_req(priv, priority, transmitRate, INVALID_HOST_TAG, interfaceTag,
2888 transmissionControl, priv->netdev_client->sender_id,
2889 peerAddress.a, &signal);
2891 /* Save host tag to check the status on reception of MA packet confirm */
2892 srcStaInfo->nullDataHostTag = req->HostTag;
2893 unifi_trace(priv, UDBG1, "uf_send_nulldata: STA AID = %d hostTag = %x\n", srcStaInfo->aid, req->HostTag);
2895 r = ul_send_signal_unpacked(priv, &signal, &bulkdata);
2898 unifi_trace(priv, UDBG1, "uf_send_nulldata: ENOSPC Requeue the Null frame\n");
2899 enque_tx_data_pdu(priv, &bulkdata, &srcStaInfo->dataPdu[priority_q], &signal, 1);
2900 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2901 srcStaInfo->noOfPktQueued++;
2902 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2906 if(r && r != -ENOSPC){
2907 unifi_error(priv, "uf_send_nulldata: Failed to send Null frame Error = %d\n",r);
2908 unifi_net_data_free(priv, &bulkdata.d[0]);
2909 srcStaInfo->nullDataHostTag = INVALID_HOST_TAG;
2916 u8 uf_check_broadcast_bssid(unifi_priv_t *priv, const bulk_data_param_t *bulkdata)
2919 static const CsrWifiMacAddress broadcast_address = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
2922 toDs = (((bulkdata->d[0].os_data_ptr)[1]) & 0x01) ? 1 : 0;
2923 fromDs =(((bulkdata->d[0].os_data_ptr)[1]) & 0x02) ? 1 : 0;
2927 unifi_trace(priv, UDBG6, "Address 4 present, Don't try to find BSSID\n");
2930 else if((toDs == 0) && (fromDs ==0))
2932 /* BSSID is Address 3 */
2933 bssid = (u8 *) (bulkdata->d[0].os_data_ptr + 4 + (2 * ETH_ALEN));
2937 /* BSSID is Address 1 */
2938 bssid = (u8 *) (bulkdata->d[0].os_data_ptr + 4);
2942 /* BSSID is Address 2 */
2943 bssid = (u8 *) (bulkdata->d[0].os_data_ptr + 4 + ETH_ALEN);
2946 if (memcmp(broadcast_address.a, bssid, ETH_ALEN)== 0)
2957 u8 uf_process_pm_bit_for_peer(unifi_priv_t * priv, CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
2958 u8 pmBit,u16 interfaceTag)
2960 u8 moreData = FALSE;
2961 u8 powerSaveChanged = FALSE;
2962 unsigned long lock_flags;
2964 unifi_trace(priv, UDBG3, "entering uf_process_pm_bit_for_peer\n");
2966 priv->allPeerDozing |= (0x01 << (srcStaInfo->assignedHandle));
2968 priv->allPeerDozing &= ~(0x01 << (srcStaInfo->assignedHandle));
2971 if(srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE) {
2973 /* disable the preemption */
2974 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2975 srcStaInfo->currentPeerState =CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE;
2976 powerSaveChanged = TRUE;
2977 /* enable the preemption */
2978 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2980 return powerSaveChanged;
2983 if(srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE) {
2984 /* disable the preemption */
2985 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
2986 srcStaInfo->currentPeerState = CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE;
2987 powerSaveChanged = TRUE;
2988 /* enable the preemption */
2989 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2991 return powerSaveChanged;
2996 if(srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE) {
2997 unifi_trace(priv,UDBG3, "Peer with AID = %d is active now\n",srcStaInfo->aid);
2998 process_peer_active_transition(priv,srcStaInfo,interfaceTag);
3000 unifi_trace(priv,UDBG3, "Peer with AID = %d is in PS Now\n",srcStaInfo->aid);
3001 /* Set TIM if needed */
3002 if(!srcStaInfo->wmmOrQosEnabled) {
3003 moreData = (!list_empty(&srcStaInfo->mgtFrames) ||
3004 !list_empty(&srcStaInfo->dataPdu[UNIFI_TRAFFIC_Q_VO])||
3005 !list_empty(&srcStaInfo->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]));
3006 if(moreData && (srcStaInfo->timSet == CSR_WIFI_TIM_RESET)) {
3007 unifi_trace(priv, UDBG3, "This condition should not occur\n");
3008 if (!srcStaInfo->timRequestPendingFlag){
3009 update_tim(priv,srcStaInfo->aid,1,interfaceTag, srcStaInfo->assignedHandle);
3013 /* Cache the TimSet value so that it will processed immidiatly after
3014 * completing the current setTim Request
3016 srcStaInfo->updateTimReqQueued = 1;
3017 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", srcStaInfo->updateTimReqQueued,
3023 u8 allDeliveryEnabled = 0, dataAvailable = 0;
3024 unifi_trace(priv, UDBG5, "Qos in AP Mode\n");
3025 /* Check if all AC's are Delivery Enabled */
3026 is_all_ac_deliver_enabled_and_moredata(srcStaInfo, &allDeliveryEnabled, &dataAvailable);
3027 /*check for more data in non-delivery enabled queues*/
3028 moreData = (uf_is_more_data_for_non_delivery_ac(srcStaInfo) || (allDeliveryEnabled && dataAvailable));
3030 if(moreData && (srcStaInfo->timSet == CSR_WIFI_TIM_RESET)) {
3031 if (!srcStaInfo->timRequestPendingFlag){
3032 update_tim(priv,srcStaInfo->aid,1,interfaceTag, srcStaInfo->assignedHandle);
3036 /* Cache the TimSet value so that it will processed immidiatly after
3037 * completing the current setTim Request
3039 srcStaInfo->updateTimReqQueued = 1;
3040 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", srcStaInfo->updateTimReqQueued,
3046 unifi_trace(priv, UDBG3, "leaving uf_process_pm_bit_for_peer\n");
3047 return powerSaveChanged;
3052 void uf_process_ps_poll(unifi_priv_t *priv,u8* sa,u8* da,u8 pmBit,u16 interfaceTag)
3054 CsrWifiRouterCtrlStaInfo_t *staRecord =
3055 CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, sa, interfaceTag);
3056 tx_buffered_packets_t * buffered_pkt = NULL;
3057 CsrWifiMacAddress peerMacAddress;
3058 unsigned long lock_flags;
3060 u8 moreData = FALSE;
3061 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
3063 unifi_trace(priv, UDBG3, "entering uf_process_ps_poll\n");
3065 memcpy(peerMacAddress.a,sa,ETH_ALEN);
3066 unifi_trace(priv, UDBG3, "In uf_process_ps_poll, sta record not found:unexpected frame addr = %x:%x:%x:%x:%x:%x\n",
3067 sa[0], sa[1],sa[2], sa[3], sa[4],sa[5]);
3068 CsrWifiRouterCtrlUnexpectedFrameIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,0,interfaceTag,peerMacAddress);
3072 uf_process_pm_bit_for_peer(priv,staRecord,pmBit,interfaceTag);
3074 /* Update station last activity time */
3075 staRecord->activity_flag = TRUE;
3077 /* This should not change the PM bit as PS-POLL has PM bit always set */
3079 unifi_notice (priv," PM bit reset in PS-POLL\n");
3083 if(IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag)) {
3084 /* giving more priority to multicast packets so dropping ps-poll*/
3085 unifi_notice (priv," multicast transmission is going on so don't take action on PS-POLL\n");
3089 if(!staRecord->wmmOrQosEnabled) {
3090 if((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->mgtFrames))) {
3091 buffered_pkt->transmissionControl |= TRANSMISSION_CONTROL_TRIGGER_MASK;
3092 moreData = (!list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]) ||
3093 !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]) ||
3094 !list_empty(&staRecord->mgtFrames));
3096 buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3097 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staRecord,moreData,FALSE)) == -ENOSPC) {
3098 /* Clear the trigger bit transmission control*/
3099 buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3100 /* Enqueue at the head of the queue */
3101 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3102 list_add(&buffered_pkt->q, &staRecord->mgtFrames);
3103 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3104 unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
3105 priv->pausedStaHandle[3]=(u8)(staRecord->assignedHandle);
3108 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3109 /* the PDU failed where we can't do any thing so free the storage */
3110 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3112 kfree(buffered_pkt);
3114 } else if((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]))) {
3115 buffered_pkt->transmissionControl |= TRANSMISSION_CONTROL_TRIGGER_MASK;
3116 moreData = (!list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]) ||
3117 !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]));
3119 buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3120 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staRecord,moreData,FALSE)) == -ENOSPC) {
3121 /* Clear the trigger bit transmission control*/
3122 buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3123 /* Enqueue at the head of the queue */
3124 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3125 list_add(&buffered_pkt->q, &staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]);
3126 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3127 priv->pausedStaHandle[3]=(u8)(staRecord->assignedHandle);
3128 unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
3131 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3132 /* the PDU failed where we can't do any thing so free the storage */
3133 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3135 kfree(buffered_pkt);
3137 } else if((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]))) {
3138 buffered_pkt->transmissionControl |= TRANSMISSION_CONTROL_TRIGGER_MASK;
3139 moreData = !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]);
3141 buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3142 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staRecord,moreData,FALSE)) == -ENOSPC) {
3143 /* Clear the trigger bit transmission control*/
3144 buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3145 /* Enqueue at the head of the queue */
3146 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3147 list_add(&buffered_pkt->q, &staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]);
3148 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3149 priv->pausedStaHandle[0]=(u8)(staRecord->assignedHandle);
3150 unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
3153 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3154 /* the PDU failed where we can't do any thing so free the storage */
3155 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3157 kfree(buffered_pkt);
3160 /* Actually since we have sent an ACK, there
3161 * there is no need to send a NULL frame*/
3163 moreData = (!list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]) ||
3164 !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]) ||
3165 !list_empty(&staRecord->mgtFrames));
3166 if(!moreData && (staRecord->timSet == CSR_WIFI_TIM_SET)) {
3167 unifi_trace(priv, UDBG3, "more data = NULL, set tim to 0 in uf_process_ps_poll\n");
3168 if (!staRecord->timRequestPendingFlag){
3169 update_tim(priv,staRecord->aid,0,interfaceTag, staRecord->assignedHandle);
3173 /* Cache the TimSet value so that it will processed immidiatly after
3174 * completing the current setTim Request
3176 staRecord->updateTimReqQueued = 0;
3177 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
3183 u8 allDeliveryEnabled = 0, dataAvailable = 0;
3184 unifi_trace(priv, UDBG3,"Qos Support station.Processing PS-Poll\n");
3186 /*Send Data From Management Frames*/
3187 /* Priority orders for delivering the buffered packets are
3188 * 1. Deliver the Management frames if there
3189 * 2. Other access catagory frames which are non deliver enable including UNIFI_TRAFFIC_Q_VO
3190 * priority is from VO->BK
3193 /* Check if all AC's are Delivery Enabled */
3194 is_all_ac_deliver_enabled_and_moredata(staRecord, &allDeliveryEnabled, &dataAvailable);
3196 if (allDeliveryEnabled) {
3197 unifi_trace(priv, UDBG3, "uf_process_ps_poll: All ACs are delivery enable so Sending QOS Null in response of Ps-poll\n");
3198 uf_send_qos_null(priv,interfaceTag,sa,CSR_QOS_UP0,staRecord);
3202 if (!list_empty(&staRecord->mgtFrames)) {
3203 if ((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->mgtFrames))) {
3204 /* We dont have packets in non delivery enabled UNIFI_TRAFFIC_Q_VO, So we are looking in management
3205 * queue of the station record
3207 moreData = uf_is_more_data_for_non_delivery_ac(staRecord);
3208 buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3210 /* Last parameter is EOSP & its false always for PS-POLL processing */
3211 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staRecord,moreData,FALSE)) == -ENOSPC) {
3212 /* Clear the trigger bit transmission control*/
3213 buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3214 /* Enqueue at the head of the queue */
3215 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3216 list_add(&buffered_pkt->q, &staRecord->mgtFrames);
3217 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3218 priv->pausedStaHandle[0]=(u8)(staRecord->assignedHandle);
3219 unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
3222 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3223 /* the PDU failed where we can't do any thing so free the storage */
3224 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3226 kfree(buffered_pkt);
3229 unifi_error(priv, "uf_process_ps_poll: Mgt frame list empty!! \n");
3234 /* We dont have buffered packet in mangement frame queue (1 failed), So proceed with condition 2
3235 * UNIFI_TRAFFIC_Q_VO -> VI -> BE -> BK
3237 for(i= 3; i>=0; i--) {
3238 if (!IS_DELIVERY_ENABLED(staRecord->powersaveMode[i])) {
3239 /* Send One packet, if queue is NULL then continue */
3240 if((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->dataPdu[i]))) {
3241 moreData = uf_is_more_data_for_non_delivery_ac(staRecord);
3243 buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3245 /* Last parameter is EOSP & its false always for PS-POLL processing */
3246 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staRecord,moreData,FALSE)) == -ENOSPC) {
3247 /* Clear the trigger bit transmission control*/
3248 buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3249 /* Enqueue at the head of the queue */
3250 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3251 list_add(&buffered_pkt->q, &staRecord->dataPdu[i]);
3252 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3253 priv->pausedStaHandle[0]=(u8)(staRecord->assignedHandle);
3254 unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
3257 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3258 /* the PDU failed where we can't do any thing so free the storage */
3259 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3261 kfree(buffered_pkt);
3268 /* Check if all AC's are Delivery Enabled */
3269 is_all_ac_deliver_enabled_and_moredata(staRecord, &allDeliveryEnabled, &dataAvailable);
3270 /*check for more data in non-delivery enabled queues*/
3271 moreData = (uf_is_more_data_for_non_delivery_ac(staRecord) || (allDeliveryEnabled && dataAvailable));
3272 if(!moreData && (staRecord->timSet == CSR_WIFI_TIM_SET)) {
3273 unifi_trace(priv, UDBG3, "more data = NULL, set tim to 0 in uf_process_ps_poll\n");
3274 if (!staRecord->timRequestPendingFlag){
3275 update_tim(priv,staRecord->aid,0,interfaceTag, staRecord->assignedHandle);
3279 /* Cache the TimSet value so that it will processed immidiatly after
3280 * completing the current setTim Request
3282 staRecord->updateTimReqQueued = 0;
3283 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
3290 unifi_trace(priv, UDBG3, "leaving uf_process_ps_poll\n");
3295 void add_to_send_cfm_list(unifi_priv_t * priv,
3296 tx_buffered_packets_t *tx_q_item,
3297 struct list_head *frames_need_cfm_list)
3299 tx_buffered_packets_t *send_cfm_list_item = NULL;
3301 send_cfm_list_item = (tx_buffered_packets_t *) kmalloc(sizeof(tx_buffered_packets_t), GFP_ATOMIC);
3303 if(send_cfm_list_item == NULL){
3304 unifi_warning(priv, "%s: Failed to allocate memory for new list item \n");
3308 INIT_LIST_HEAD(&send_cfm_list_item->q);
3310 send_cfm_list_item->hostTag = tx_q_item->hostTag;
3311 send_cfm_list_item->interfaceTag = tx_q_item->interfaceTag;
3312 send_cfm_list_item->transmissionControl = tx_q_item->transmissionControl;
3313 send_cfm_list_item->leSenderProcessId = tx_q_item->leSenderProcessId;
3314 send_cfm_list_item->rate = tx_q_item->rate;
3315 memcpy(send_cfm_list_item->peerMacAddress.a, tx_q_item->peerMacAddress.a, ETH_ALEN);
3316 send_cfm_list_item->priority = tx_q_item->priority;
3318 list_add_tail(&send_cfm_list_item->q, frames_need_cfm_list);
3321 void uf_prepare_send_cfm_list_for_queued_pkts(unifi_priv_t * priv,
3322 struct list_head *frames_need_cfm_list,
3323 struct list_head * list)
3325 tx_buffered_packets_t *tx_q_item = NULL;
3326 struct list_head *listHead;
3327 struct list_head *placeHolder;
3328 unsigned long lock_flags;
3332 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3334 /* Search through the list and if confirmation required for any frames,
3335 add it to the send_cfm list */
3336 list_for_each_safe(listHead, placeHolder, list) {
3337 tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
3340 unifi_error(priv, "Entry should exist, otherwise it is a (BUG)\n");
3344 /* check if confirmation is requested and if the sender ID
3345 is not netdevice client then save the entry in the list for need cfms */
3346 if (!(tx_q_item->transmissionControl & CSR_NO_CONFIRM_REQUIRED) &&
3347 (tx_q_item->leSenderProcessId != priv->netdev_client->sender_id)){
3348 unifi_trace(priv, UDBG1, "%s: SenderProcessID=%x host tag=%x transmission control=%x\n",
3350 tx_q_item->leSenderProcessId,
3352 tx_q_item->transmissionControl);
3354 add_to_send_cfm_list(priv, tx_q_item, frames_need_cfm_list);
3358 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3365 void uf_flush_list(unifi_priv_t * priv, struct list_head * list)
3367 tx_buffered_packets_t *tx_q_item;
3368 struct list_head *listHead;
3369 struct list_head *placeHolder;
3370 unsigned long lock_flags;
3372 unifi_trace(priv, UDBG5, "entering the uf_flush_list \n");
3374 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3375 /* go through list, delete & free memory */
3376 list_for_each_safe(listHead, placeHolder, list) {
3377 tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
3380 unifi_error(priv, "entry should exists, otherwise crashes (bug)\n");
3382 unifi_trace(priv, UDBG5,
3383 "proccess_tx: in uf_flush_list peerMacAddress=%02X%02X%02X%02X%02X%02X senderProcessId=%x\n",
3384 tx_q_item->peerMacAddress.a[0], tx_q_item->peerMacAddress.a[1],
3385 tx_q_item->peerMacAddress.a[2], tx_q_item->peerMacAddress.a[3],
3386 tx_q_item->peerMacAddress.a[4], tx_q_item->peerMacAddress.a[5],
3387 tx_q_item->leSenderProcessId);
3390 /* free the allocated memory */
3391 unifi_net_data_free(priv, &tx_q_item->bulkdata);
3394 if (!priv->noOfPktQueuedInDriver) {
3395 unifi_error(priv, "packets queued in driver 0 still decrementing in %s\n", __FUNCTION__);
3397 priv->noOfPktQueuedInDriver--;
3400 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3403 tx_buffered_packets_t *dequeue_tx_data_pdu(unifi_priv_t *priv, struct list_head *txList)
3405 /* dequeue the tx data packets from the appropriate queue */
3406 tx_buffered_packets_t *tx_q_item = NULL;
3407 struct list_head *listHead;
3408 struct list_head *placeHolder;
3409 unsigned long lock_flags;
3411 unifi_trace(priv, UDBG5, "entering dequeue_tx_data_pdu\n");
3412 /* check for list empty */
3413 if (list_empty(txList)) {
3414 unifi_trace(priv, UDBG5, "In dequeue_tx_data_pdu, the list is empty\n");
3418 /* Verification, if packet count is negetive */
3419 if (priv->noOfPktQueuedInDriver == 0xFFFF) {
3420 unifi_warning(priv, "no packet available in queue: debug");
3424 /* return first node after header, & delete from the list && atleast one item exist */
3425 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3426 list_for_each_safe(listHead, placeHolder, txList) {
3427 tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
3431 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3434 unifi_trace(priv, UDBG5,
3435 "proccess_tx: In dequeue_tx_data_pdu peerMacAddress=%02X%02X%02X%02X%02X%02X senderProcessId=%x\n",
3436 tx_q_item->peerMacAddress.a[0], tx_q_item->peerMacAddress.a[1],
3437 tx_q_item->peerMacAddress.a[2], tx_q_item->peerMacAddress.a[3],
3438 tx_q_item->peerMacAddress.a[4], tx_q_item->peerMacAddress.a[5],
3439 tx_q_item->leSenderProcessId);
3442 unifi_trace(priv, UDBG5, "leaving dequeue_tx_data_pdu\n");
3445 /* generic function to get the station record handler */
3446 CsrWifiRouterCtrlStaInfo_t *CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(unifi_priv_t *priv,
3447 const u8 *peerMacAddress,
3451 netInterface_priv_t *interfacePriv;
3452 unsigned long lock_flags;
3454 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
3455 unifi_error(priv, "interfaceTag is not proper, interfaceTag = %d\n", interfaceTag);
3459 interfacePriv = priv->interfacePriv[interfaceTag];
3461 /* disable the preemption untill station record is fetched */
3462 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
3464 for (i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
3465 if (interfacePriv->staInfo[i]!= NULL) {
3466 if (!memcmp(((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[i]))->peerMacAddress.a, peerMacAddress, ETH_ALEN)) {
3467 /* enable the preemption as station record is fetched */
3468 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
3469 unifi_trace(priv, UDBG5, "peer entry found in station record\n");
3470 return ((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[i]));
3474 /* enable the preemption as station record is fetched */
3475 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
3476 unifi_trace(priv, UDBG5, "peer entry not found in station record\n");
3479 /* generic function to get the station record handler from the handle */
3480 CsrWifiRouterCtrlStaInfo_t * CsrWifiRouterCtrlGetStationRecordFromHandle(unifi_priv_t *priv,
3484 netInterface_priv_t *interfacePriv;
3486 if ((handle >= UNIFI_MAX_CONNECTIONS) || (interfaceTag >= CSR_WIFI_NUM_INTERFACES)) {
3487 unifi_error(priv, "handle/interfaceTag is not proper, handle = %d, interfaceTag = %d\n", handle, interfaceTag);
3490 interfacePriv = priv->interfacePriv[interfaceTag];
3491 return ((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[handle]));
3494 /* Function to do inactivity */
3495 void uf_check_inactivity(unifi_priv_t *priv, u16 interfaceTag, CsrTime currentTime)
3498 CsrWifiRouterCtrlStaInfo_t *staInfo;
3499 CsrTime elapsedTime; /* Time in microseconds */
3500 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
3501 CsrWifiMacAddress peerMacAddress;
3502 unsigned long lock_flags;
3504 if (interfacePriv == NULL) {
3505 unifi_trace(priv, UDBG3, "uf_check_inactivity: Interface priv is NULL \n");
3509 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
3510 /* Go through the list of stations to check for inactivity */
3511 for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
3512 staInfo = CsrWifiRouterCtrlGetStationRecordFromHandle(priv, i, interfaceTag);
3517 unifi_trace(priv, UDBG3, "Running Inactivity handler Time %xus station's last activity %xus\n",
3518 currentTime, staInfo->lastActivity);
3521 elapsedTime = (currentTime >= staInfo->lastActivity)?
3522 (currentTime - staInfo->lastActivity):
3523 (~((u32)0) - staInfo->lastActivity + currentTime);
3524 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
3526 if (elapsedTime > MAX_INACTIVITY_INTERVAL) {
3527 memcpy((u8*)&peerMacAddress, (u8*)&staInfo->peerMacAddress, sizeof(CsrWifiMacAddress));
3529 /* Indicate inactivity for the station */
3530 unifi_trace(priv, UDBG3, "Station %x:%x:%x:%x:%x:%x inactive since %xus\n sending Inactive Ind\n",
3531 peerMacAddress.a[0], peerMacAddress.a[1],
3532 peerMacAddress.a[2], peerMacAddress.a[3],
3533 peerMacAddress.a[4], peerMacAddress.a[5],
3536 CsrWifiRouterCtrlStaInactiveIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, peerMacAddress);
3540 interfacePriv->last_inactivity_check = currentTime;
3543 /* Function to update activity of a station */
3544 void uf_update_sta_activity(unifi_priv_t *priv, u16 interfaceTag, const u8 *peerMacAddress)
3546 CsrTime elapsedTime, currentTime; /* Time in microseconds */
3547 CsrTime timeHi; /* Not used - Time in microseconds */
3548 CsrWifiRouterCtrlStaInfo_t *staInfo;
3549 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
3550 unsigned long lock_flags;
3552 if (interfacePriv == NULL) {
3553 unifi_trace(priv, UDBG3, "uf_check_inactivity: Interface priv is NULL \n");
3557 currentTime = CsrTimeGet(&timeHi);
3560 staInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, peerMacAddress, interfaceTag);
3562 if (staInfo == NULL) {
3563 unifi_trace(priv, UDBG4, "Sta does not exist yet");
3567 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
3568 /* Update activity */
3569 staInfo->lastActivity = currentTime;
3571 /* See if inactivity handler needs to be run
3572 * Here it is theoretically possible that the counter may have wrapped around. But
3573 * since we just want to know when to run the inactivity handler it does not really matter.
3574 * Especially since this is data path it makes sense in keeping it simple and avoiding
3575 * 64 bit handling */
3576 elapsedTime = (currentTime >= interfacePriv->last_inactivity_check)?
3577 (currentTime - interfacePriv->last_inactivity_check):
3578 (~((u32)0) - interfacePriv->last_inactivity_check + currentTime);
3580 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
3582 /* Check if it is time to run the inactivity handler */
3583 if (elapsedTime > INACTIVITY_CHECK_INTERVAL) {
3584 uf_check_inactivity(priv, interfaceTag, currentTime);
3587 void resume_unicast_buffered_frames(unifi_priv_t *priv, u16 interfaceTag)
3590 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
3593 tx_buffered_packets_t * buffered_pkt = NULL;
3594 u8 hipslotFree[4] = {TRUE,TRUE,TRUE,TRUE};
3596 unsigned long lock_flags;
3599 while(!isRouterBufferEnabled(priv,3) &&
3600 ((buffered_pkt=dequeue_tx_data_pdu(priv,&interfacePriv->genericMgtFrames))!=NULL)) {
3601 buffered_pkt->transmissionControl &=
3602 ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
3603 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,NULL,0,FALSE)) == -ENOSPC) {
3604 /* Enqueue at the head of the queue */
3605 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3606 list_add(&buffered_pkt->q, &interfacePriv->genericMgtFrames);
3607 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3608 hipslotFree[3]=FALSE;
3612 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3613 /* the PDU failed where we can't do any thing so free the storage */
3614 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3616 kfree(buffered_pkt);
3619 for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
3620 CsrWifiRouterCtrlStaInfo_t *staInfo = interfacePriv->staInfo[i];
3621 if(!hipslotFree[0] && !hipslotFree[1] && !hipslotFree[2] && !hipslotFree[3]) {
3622 unifi_trace(priv, UDBG3, "(ENOSPC) in resume_unicast_buffered_frames:: hip slots are full \n");
3625 if (staInfo && (staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE)) {
3626 while((( TRUE == hipslotFree[3] ) && (buffered_pkt=dequeue_tx_data_pdu(priv, &staInfo->mgtFrames)))) {
3627 buffered_pkt->transmissionControl &=
3628 ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
3629 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staInfo,0,FALSE)) == -ENOSPC) {
3630 unifi_trace(priv, UDBG3, "(ENOSPC) in resume_unicast_buffered_frames:: hip slots are full for voice queue\n");
3631 /* Enqueue at the head of the queue */
3632 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3633 list_add(&buffered_pkt->q, &staInfo->mgtFrames);
3634 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3635 priv->pausedStaHandle[3]=(u8)(staInfo->assignedHandle);
3636 hipslotFree[3] = FALSE;
3640 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3641 /* the PDU failed where we can't do any thing so free the storage */
3642 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3644 kfree(buffered_pkt);
3652 while((buffered_pkt=dequeue_tx_data_pdu(priv, &staInfo->dataPdu[j]))) {
3653 buffered_pkt->transmissionControl &=
3654 ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
3655 if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staInfo,0,FALSE)) == -ENOSPC) {
3656 /* Enqueue at the head of the queue */
3657 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3658 list_add(&buffered_pkt->q, &staInfo->dataPdu[j]);
3659 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3660 priv->pausedStaHandle[j]=(u8)(staInfo->assignedHandle);
3661 hipslotFree[j]=FALSE;
3665 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3666 /* the PDU failed where we can't do any thing so free the storage */
3667 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3669 kfree(buffered_pkt);
3677 void update_eosp_to_head_of_broadcast_list_head(unifi_priv_t *priv,u16 interfaceTag)
3680 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
3681 unsigned long lock_flags;
3682 struct list_head *listHead;
3683 struct list_head *placeHolder;
3684 tx_buffered_packets_t *tx_q_item;
3687 if (interfacePriv->noOfbroadcastPktQueued) {
3689 /* Update the EOSP to the HEAD of b/c list
3690 * beacuse we have received any mgmt packet so it should not hold for long time
3691 * peer may time out.
3693 spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
3694 list_for_each_safe(listHead, placeHolder, &interfacePriv->genericMulticastOrBroadCastFrames) {
3695 tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
3696 tx_q_item->transmissionControl |= TRANSMISSION_CONTROL_EOSP_MASK;
3697 tx_q_item->transmissionControl = (tx_q_item->transmissionControl & ~(CSR_NO_CONFIRM_REQUIRED));
3698 unifi_trace(priv, UDBG1,"updating eosp for list Head hostTag:= 0x%x ",tx_q_item->hostTag);
3701 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
3707 * ---------------------------------------------------------------------------
3708 * resume_suspended_uapsd
3710 * This function takes care processing packets of Unscheduled Service Period,
3711 * which been suspended earlier due to DTIM/HIP ENOSPC scenarios
3714 * priv Pointer to device private context struct
3715 * interfaceTag For which resume should happen
3716 * ---------------------------------------------------------------------------
3718 void resume_suspended_uapsd(unifi_priv_t* priv,u16 interfaceTag)
3722 CsrWifiRouterCtrlStaInfo_t * staInfo = NULL;
3723 unsigned long lock_flags;
3725 unifi_trace(priv, UDBG2, "++resume_suspended_uapsd: \n");
3726 for(startIndex= 0; startIndex < UNIFI_MAX_CONNECTIONS;startIndex++) {
3727 staInfo = CsrWifiRouterCtrlGetStationRecordFromHandle(priv,startIndex,interfaceTag);
3729 if(!staInfo || !staInfo->wmmOrQosEnabled) {
3731 } else if((staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)
3732 &&staInfo->uapsdActive && staInfo->uspSuspend) {
3733 /* U-APSD Still active & previously suspended either ENOSPC of FH queues OR
3734 * due to DTIM activity
3736 uf_handle_uspframes_delivery(priv, staInfo, interfaceTag);
3738 unifi_trace(priv, UDBG2, "resume_suspended_uapsd: PS state=%x, uapsdActive?=%x, suspend?=%x\n",
3739 staInfo->currentPeerState, staInfo->uapsdActive, staInfo->uspSuspend);
3740 if (staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE)
3742 spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
3743 staInfo->uapsdActive = FALSE;
3744 staInfo->uspSuspend = FALSE;
3745 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
3749 unifi_trace(priv, UDBG2, "--resume_suspended_uapsd:\n");