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