2 * ---------------------------------------------------------------------------
6 * Driver specific implementation of the SME SYS SAP.
7 * It is part of the porting exercise.
9 * Copyright (C) 2008-2011 by Cambridge Silicon Radio Ltd.
11 * Refer to LICENSE.txt included with this source code for details on
14 * ---------------------------------------------------------------------------
17 #include "csr_wifi_hip_unifiversion.h"
18 #include "unifi_priv.h"
19 #include "csr_wifi_hip_conversions.h"
20 #ifdef CSR_SUPPORT_WEXT_AP
21 #include "csr_wifi_sme_sef.h"
25 * This file implements the SME SYS API and contains the following functions:
26 * CsrWifiRouterCtrlMediaStatusReqHandler()
27 * CsrWifiRouterCtrlHipReqHandler()
28 * CsrWifiRouterCtrlPortConfigureReqHandler()
29 * CsrWifiRouterCtrlWifiOnReqHandler()
30 * CsrWifiRouterCtrlWifiOffReqHandler()
31 * CsrWifiRouterCtrlSuspendResHandler()
32 * CsrWifiRouterCtrlResumeResHandler()
33 * CsrWifiRouterCtrlQosControlReqHandler()
34 * CsrWifiRouterCtrlConfigurePowerModeReqHandler()
35 * CsrWifiRouterCtrlWifiOnResHandler()
36 * CsrWifiRouterCtrlWifiOffRspHandler()
37 * CsrWifiRouterCtrlMulticastAddressResHandler()
38 * CsrWifiRouterCtrlTrafficConfigReqHandler()
39 * CsrWifiRouterCtrlTrafficClassificationReqHandler()
40 * CsrWifiRouterCtrlTclasAddReqHandler()
41 * CsrWifiRouterCtrlTclasDelReqHandler()
42 * CsrWifiRouterCtrlSetModeReqHandler()
43 * CsrWifiRouterCtrlWapiMulticastFilterReqHandler()
44 * CsrWifiRouterCtrlWapiUnicastFilterReqHandler()
45 * CsrWifiRouterCtrlWapiUnicastTxPktReqHandler()
46 * CsrWifiRouterCtrlWapiRxPktReqHandler()
47 * CsrWifiRouterCtrlWapiFilterReqHandler()
50 #ifdef CSR_SUPPORT_SME
51 static void check_inactivity_timer_expire_func(unsigned long data
);
52 void uf_send_disconnected_ind_wq(struct work_struct
*work
);
55 void send_auto_ma_packet_confirm(unifi_priv_t
*priv
,
56 netInterface_priv_t
*interfacePriv
,
57 struct list_head
*buffered_frames_list
)
59 tx_buffered_packets_t
*buffered_frame_item
= NULL
;
60 struct list_head
*listHead
;
61 struct list_head
*placeHolder
;
64 CSR_SIGNAL unpacked_signal
;
65 u8 sigbuf
[UNIFI_PACKED_SIGBUF_SIZE
];
69 list_for_each_safe(listHead
, placeHolder
, buffered_frames_list
)
71 buffered_frame_item
= list_entry(listHead
, tx_buffered_packets_t
, q
);
73 if(!buffered_frame_item
) {
74 unifi_error(priv
, "Entry should exist, otherwise it is a (BUG)\n");
78 if ((interfacePriv
->interfaceMode
!= CSR_WIFI_ROUTER_CTRL_MODE_NONE
) &&
79 (priv
->wifi_on_state
== wifi_on_done
))
82 unifi_warning(priv
, "Send MA_PACKET_CONFIRM to SenderProcessId = %x for (HostTag = %x TransmissionControl = %x)\n",
83 (buffered_frame_item
->leSenderProcessId
),
84 buffered_frame_item
->hostTag
,
85 buffered_frame_item
->transmissionControl
);
87 client_id
= buffered_frame_item
->leSenderProcessId
& 0xFF00;
89 if (client_id
== priv
->sme_cli
->sender_id
)
91 /* construct a MA-PACKET.confirm message for SME */
92 memset(&unpacked_signal
, 0, sizeof(unpacked_signal
));
93 unpacked_signal
.SignalPrimitiveHeader
.SignalId
= CSR_MA_PACKET_CONFIRM_ID
;
94 unpacked_signal
.SignalPrimitiveHeader
.ReceiverProcessId
= buffered_frame_item
->leSenderProcessId
;
95 unpacked_signal
.SignalPrimitiveHeader
.SenderProcessId
= CSR_WIFI_ROUTER_IFACEQUEUE
;
97 unpacked_signal
.u
.MaPacketConfirm
.VirtualInterfaceIdentifier
= uf_get_vif_identifier(interfacePriv
->interfaceMode
,
98 interfacePriv
->InterfaceTag
);
99 unpacked_signal
.u
.MaPacketConfirm
.TransmissionStatus
= CSR_RESULT_FAILURE
;
100 unpacked_signal
.u
.MaPacketConfirm
.RetryCount
= 0;
101 unpacked_signal
.u
.MaPacketConfirm
.Rate
= buffered_frame_item
->rate
;
102 unpacked_signal
.u
.MaPacketConfirm
.HostTag
= buffered_frame_item
->hostTag
;
104 write_pack(&unpacked_signal
, sigbuf
, &packed_siglen
);
105 unifi_warning(priv
, "MA_PACKET_CONFIRM for SME (0x%x, 0x%x, 0x%x, 0x%x)\n",
106 unpacked_signal
.SignalPrimitiveHeader
.ReceiverProcessId
,
107 unpacked_signal
.SignalPrimitiveHeader
.SenderProcessId
,
108 unpacked_signal
.u
.MaPacketConfirm
.VirtualInterfaceIdentifier
,
109 unpacked_signal
.u
.MaPacketConfirm
.HostTag
);
111 CsrWifiRouterCtrlHipIndSend(priv
->CSR_WIFI_SME_IFACEQUEUE
,
117 else if((buffered_frame_item
->hostTag
& 0x80000000))
119 /* construct a MA-PACKET.confirm message for NME */
120 unifi_warning(priv
, "MA_PACKET_CONFIRM for NME (0x%x, 0x%x, 0x%x, 0x%x)\n",
121 buffered_frame_item
->leSenderProcessId
,
122 buffered_frame_item
->interfaceTag
,
123 buffered_frame_item
->transmissionControl
,
124 (buffered_frame_item
->hostTag
& 0x3FFFFFFF));
126 CsrWifiRouterMaPacketCfmSend((buffered_frame_item
->leSenderProcessId
& 0xFF),
127 buffered_frame_item
->interfaceTag
,
129 (buffered_frame_item
->hostTag
& 0x3FFFFFFF),
130 buffered_frame_item
->rate
);
135 unifi_warning(priv
, "Buffered packet dropped without sending a confirm\n");
141 kfree(buffered_frame_item
);
142 buffered_frame_item
= NULL
;
146 void CsrWifiRouterCtrlMediaStatusReqHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
148 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
149 CsrWifiRouterCtrlMediaStatusReq
* req
= (CsrWifiRouterCtrlMediaStatusReq
*)msg
;
150 netInterface_priv_t
*interfacePriv
= priv
->interfacePriv
[req
->interfaceTag
];
153 if (priv
->smepriv
== NULL
) {
154 unifi_error(priv
, "CsrWifiRouterCtrlMediaStatusReqHandler: invalid smepriv\n");
157 if (req
->interfaceTag
>= CSR_WIFI_NUM_INTERFACES
) {
158 unifi_error(priv
, "CsrWifiRouterCtrlMediaStatusReqHandler: invalid interfaceTag\n");
161 unifi_trace(priv
, UDBG3
, "CsrWifiRouterCtrlMediaStatusReqHandler: Mode = %d req->mediaStatus = %d\n",interfacePriv
->interfaceMode
,req
->mediaStatus
);
162 if (interfacePriv
->interfaceMode
!= CSR_WIFI_ROUTER_CTRL_MODE_AMP
) {
163 bulk_data_desc_t bulk_data
;
165 bulk_data
.data_length
= 0;
167 spin_lock_irqsave(&priv
->m4_lock
, flags
);
168 if (interfacePriv
->m4_bulk_data
.data_length
> 0) {
169 bulk_data
= interfacePriv
->m4_bulk_data
;
170 interfacePriv
->m4_bulk_data
.net_buf_length
= 0;
171 interfacePriv
->m4_bulk_data
.data_length
= 0;
172 interfacePriv
->m4_bulk_data
.os_data_ptr
= interfacePriv
->m4_bulk_data
.os_net_buf_ptr
= NULL
;
174 spin_unlock_irqrestore(&priv
->m4_lock
, flags
);
176 if (bulk_data
.data_length
!= 0) {
177 unifi_trace(priv
, UDBG5
, "CsrWifiRouterCtrlMediaStatusReqHandler: free M4\n");
178 unifi_net_data_free(priv
, &bulk_data
);
181 if ((req
->mediaStatus
== CSR_WIFI_SME_MEDIA_STATUS_CONNECTED
) &&
182 (interfacePriv
->connected
!= UnifiConnected
)) {
184 switch(interfacePriv
->interfaceMode
){
185 case CSR_WIFI_ROUTER_CTRL_MODE_AP
:
186 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
:
187 interfacePriv
->connected
= UnifiConnected
;
188 netif_carrier_on(priv
->netdev
[req
->interfaceTag
]);
189 #ifdef CSR_SUPPORT_WEXT
190 wext_send_started_event(priv
);
192 unifi_trace(priv
, UDBG1
,
193 "CsrWifiRouterCtrlMediaStatusReqHandler: AP/P2PGO setting netif_carrier_on\n");
194 netif_tx_wake_all_queues(priv
->netdev
[req
->interfaceTag
]);
198 #ifdef CSR_SUPPORT_WEXT
199 /* In the WEXT builds (sme and native), the userspace is not ready
200 * to process any EAPOL or WAPI packets, until it has been informed
201 * of the NETDEV_CHANGE.
203 if (interfacePriv
->netdev_callback_registered
&& (interfacePriv
->interfaceMode
!= CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI
)) {
204 interfacePriv
->wait_netdev_change
= TRUE
;
205 unifi_trace(priv
, UDBG1
,
206 "CsrWifiRouterCtrlMediaStatusReqHandler: waiting for NETDEV_CHANGE\n");
208 * Carrier can go to on, only after wait_netdev_change is set to TRUE.
209 * Otherwise there can be a race in uf_netdev_event().
211 netif_carrier_on(priv
->netdev
[req
->interfaceTag
]);
212 unifi_trace(priv
, UDBG1
,
213 "CsrWifiRouterCtrlMediaStatusReqHandler: STA/P2PCLI setting netif_carrier_on\n");
218 /* In the NME build, the userspace does not wait for the NETDEV_CHANGE
219 * so it is ready to process all the EAPOL or WAPI packets.
220 * At this point, we enable all the Tx queues, and we indicate any packets
221 * that are queued (and the respective port is opened).
223 static const CsrWifiMacAddress broadcast_address
= {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
224 interfacePriv
->connected
= UnifiConnected
;
225 unifi_trace(priv
, UDBG1
,
226 "CsrWifiRouterMediaStatusReqHandler: UnifiConnected && netif_carrier_on\n");
227 netif_carrier_on(priv
->netdev
[req
->interfaceTag
]);
228 netif_tx_wake_all_queues(priv
->netdev
[req
->interfaceTag
]);
229 uf_process_rx_pending_queue(priv
, UF_UNCONTROLLED_PORT_Q
, broadcast_address
, 1, interfacePriv
->InterfaceTag
);
230 uf_process_rx_pending_queue(priv
, UF_CONTROLLED_PORT_Q
, broadcast_address
, 1, interfacePriv
->InterfaceTag
);
236 if (req
->mediaStatus
== CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED
) {
237 #ifdef CSR_SUPPORT_WEXT
238 unifi_trace(priv
, UDBG1
,
239 "CsrWifiRouterMediaStatusReqHandler: cancel waiting for NETDEV_CHANGE\n");
240 interfacePriv
->wait_netdev_change
= FALSE
;
242 unifi_trace(priv
, UDBG1
,
243 "CsrWifiRouterMediaStatusReqHandler: setting netif_carrier_off\n");
244 netif_carrier_off(priv
->netdev
[req
->interfaceTag
]);
245 #ifdef CSR_SUPPORT_WEXT
246 switch(interfacePriv
->interfaceMode
){
247 case CSR_WIFI_ROUTER_CTRL_MODE_AP
:
248 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
:
249 wext_send_started_event(priv
);
255 interfacePriv
->connected
= UnifiNotConnected
;
258 /* For AMP, just update the L2 connected flag */
259 if (req
->mediaStatus
== CSR_WIFI_SME_MEDIA_STATUS_CONNECTED
) {
260 unifi_trace(priv
, UDBG1
, "CsrWifiRouterCtrlMediaStatusReqHandler: AMP connected\n");
261 interfacePriv
->connected
= UnifiConnected
;
263 unifi_trace(priv
, UDBG1
, "CsrWifiRouterCtrlMediaStatusReqHandler: AMP disconnected\n");
264 interfacePriv
->connected
= UnifiNotConnected
;
270 void CsrWifiRouterCtrlHipReqHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
272 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
273 CsrWifiRouterCtrlHipReq
* hipreq
= (CsrWifiRouterCtrlHipReq
*)msg
;
274 bulk_data_param_t bulkdata
;
281 u16 interfaceTag
= 0;
282 CSR_MA_PACKET_REQUEST
*req
;
283 netInterface_priv_t
*interfacePriv
;
288 if (priv
->smepriv
== NULL
) {
289 unifi_error(priv
, "CsrWifiRouterCtrlHipReqHandler: invalid smepriv\n");
292 if (interfaceTag
>= CSR_WIFI_NUM_INTERFACES
) {
293 unifi_error(priv
, "CsrWifiRouterCtrlHipReqHandler: invalid interfaceTag\n");
297 interfacePriv
= priv
->interfacePriv
[interfaceTag
];
299 /* Initialize bulkdata to avoid os_net_buf is garbage */
300 memset(&bulkdata
, 0, sizeof(bulk_data_param_t
));
302 signal
= (CSR_SIGNAL
*)hipreq
->mlmeCommand
;
304 unifi_trace(priv
, UDBG4
, "CsrWifiRouterCtrlHipReqHandler: 0x04%X ---->\n",
305 *((u16
*)hipreq
->mlmeCommand
));
307 /* Construct the signal. */
308 signal_ptr
= (u8
*)hipreq
->mlmeCommand
;
309 signal_length
= hipreq
->mlmeCommandLength
;
312 * The MSB of the sender ID needs to be set to the client ID.
313 * The LSB is controlled by the SME.
315 signal_ptr
[5] = (priv
->sme_cli
->sender_id
>> 8) & 0xff;
317 /* Allocate buffers for the bulk data. */
318 if (hipreq
->dataRef1Length
) {
319 csrResult
= unifi_net_data_malloc(priv
, &bulkdata
.d
[0], hipreq
->dataRef1Length
);
320 if (csrResult
== CSR_RESULT_SUCCESS
) {
321 dest
= (void*)bulkdata
.d
[0].os_data_ptr
;
322 memcpy(dest
, hipreq
->dataRef1
, hipreq
->dataRef1Length
);
323 bulkdata
.d
[0].data_length
= hipreq
->dataRef1Length
;
325 unifi_warning(priv
, "signal not sent down, allocation failed in CsrWifiRouterCtrlHipReqHandler\n");
329 bulkdata
.d
[0].os_data_ptr
= NULL
;
330 bulkdata
.d
[0].data_length
= 0;
332 if (hipreq
->dataRef2Length
) {
333 csrResult
= unifi_net_data_malloc(priv
, &bulkdata
.d
[1], hipreq
->dataRef2Length
);
334 if (csrResult
== CSR_RESULT_SUCCESS
) {
335 dest
= (void*)bulkdata
.d
[1].os_data_ptr
;
336 memcpy(dest
, hipreq
->dataRef2
, hipreq
->dataRef2Length
);
337 bulkdata
.d
[1].data_length
= hipreq
->dataRef2Length
;
339 if (bulkdata
.d
[0].data_length
)
341 unifi_net_data_free(priv
, &bulkdata
.d
[0]);
343 unifi_warning(priv
, "signal not sent down, allocation failed in CsrWifiRouterCtrlHipReqHandler\n");
347 bulkdata
.d
[1].os_data_ptr
= NULL
;
348 bulkdata
.d
[1].data_length
= 0;
351 unifi_trace(priv
, UDBG3
, "SME SEND: Signal 0x%.4X \n",
352 *((u16
*)signal_ptr
));
353 if (signal
->SignalPrimitiveHeader
.SignalId
== CSR_MA_PACKET_REQUEST_ID
)
355 CSR_SIGNAL unpacked_signal
;
356 read_unpack_signal((u8
*) signal
, &unpacked_signal
);
357 req
= &unpacked_signal
.u
.MaPacketRequest
;
358 interfaceTag
= req
->VirtualInterfaceIdentifier
& 0xff;
359 switch(interfacePriv
->interfaceMode
)
361 case CSR_WIFI_ROUTER_CTRL_MODE_NONE
:
362 unifi_error(priv
, "CsrWifiRouterCtrlHipReqHandler: invalid mode: NONE \n");
365 unifi_trace(priv
, UDBG5
, "mode is %x\n", interfacePriv
->interfaceMode
);
367 /* While sending ensure that first 2 bits b31 and b30 are 00. These are used for local routing*/
368 r
= uf_process_ma_packet_req(priv
, req
->Ra
.x
, (req
->HostTag
& 0x3FFFFFFF), interfaceTag
,
369 req
->TransmissionControl
, req
->TransmitRate
,
370 req
->Priority
, signal
->SignalPrimitiveHeader
.SenderProcessId
,
374 if (bulkdata
.d
[0].data_length
)
376 unifi_net_data_free(priv
, &bulkdata
.d
[0]);
378 if (bulkdata
.d
[1].data_length
)
380 unifi_net_data_free(priv
, &bulkdata
.d
[1]);
384 /* ul_send_signal_raw frees the bulk data if it fails */
385 r
= ul_send_signal_raw(priv
, signal_ptr
, signal_length
, &bulkdata
);
390 "CsrWifiRouterCtrlHipReqHandler: Failed to send signal (0x%.4X - %u)\n",
391 *((u16
*)signal_ptr
), r
);
392 CsrWifiRouterCtrlWifiOffIndSend(priv
->CSR_WIFI_SME_IFACEQUEUE
,0,CSR_WIFI_SME_CONTROL_INDICATION_ERROR
);
395 unifi_trace(priv
, UDBG4
, "CsrWifiRouterCtrlHipReqHandler: <----\n");
398 #ifdef CSR_WIFI_SEND_GRATUITOUS_ARP
400 uf_send_gratuitous_arp(unifi_priv_t
*priv
, u16 interfaceTag
)
402 netInterface_priv_t
*interfacePriv
= priv
->interfacePriv
[interfaceTag
];
403 CSR_PRIORITY priority
;
405 bulk_data_param_t bulkdata
;
407 struct sk_buff
*skb
, *newSkb
= NULL
;
410 static const u8 arp_req
[36] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00,
411 0x08, 0x06, 0x00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00, 0x01,
412 0x00, 0x02, 0x5f, 0x20, 0x2f, 0x02,
413 0xc0, 0xa8, 0x00, 0x02,
414 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
415 0xc0, 0xa8, 0x00, 0x02};
417 csrResult
= unifi_net_data_malloc(priv
, &bulkdata
.d
[0], sizeof(arp_req
));
418 if (csrResult
!= CSR_RESULT_SUCCESS
)
420 unifi_error(priv
, "Failed to allocate bulk data in CsrWifiSmeRoamCompleteIndHandler()\n");
423 skb
= (struct sk_buff
*)(bulkdata
.d
[0].os_net_buf_ptr
);
424 skb
->len
= bulkdata
.d
[0].data_length
;
426 memcpy(skb
->data
, arp_req
, sizeof(arp_req
));
427 /* add MAC and IP address */
428 memcpy(skb
->data
+ 16, priv
->netdev
[interfaceTag
]->dev_addr
, ETH_ALEN
);
429 skb
->data
[22] = (priv
->sta_ip_address
) & 0xFF;
430 skb
->data
[23] = (priv
->sta_ip_address
>> 8) & 0xFF;
431 skb
->data
[24] = (priv
->sta_ip_address
>> 16) & 0xFF;
432 skb
->data
[25] = (priv
->sta_ip_address
>> 24) & 0xFF;
433 skb
->data
[32] = (priv
->sta_ip_address
) & 0xFF;
434 skb
->data
[33] = (priv
->sta_ip_address
>> 8) & 0xFF;
435 skb
->data
[34] = (priv
->sta_ip_address
>> 16) & 0xFF;
436 skb
->data
[35] = (priv
->sta_ip_address
>> 24) & 0xFF;
438 bulkdata
.d
[1].os_data_ptr
= NULL
;
439 bulkdata
.d
[1].os_net_buf_ptr
= NULL
;
440 bulkdata
.d
[1].net_buf_length
= bulkdata
.d
[1].data_length
= 0;
442 if ((protection
= uf_get_protection_bit_from_interfacemode(priv
, interfaceTag
, &arp_req
[26])) < 0)
444 unifi_error(priv
, "CsrWifiSmeRoamCompleteIndHandler: Failed to determine protection mode\n");
445 unifi_net_data_free(priv
, &bulkdata
.d
[0]);
449 if ((priv
->sta_wmm_capabilities
& QOS_CAPABILITY_WMM_ENABLED
) == 1)
451 priority
= CSR_QOS_UP0
;
455 priority
= CSR_CONTENTION
;
458 if (prepare_and_add_macheader(priv
, skb
, newSkb
, priority
, &bulkdata
,
459 interfaceTag
, &arp_req
[26],
460 priv
->netdev
[interfaceTag
]->dev_addr
, protection
))
462 unifi_error(priv
, "CsrWifiSmeRoamCompleteIndHandler: failed to create MAC header\n");
463 unifi_net_data_free(priv
, &bulkdata
.d
[0]);
466 bulkdata
.d
[0].os_data_ptr
= skb
->data
;
467 bulkdata
.d
[0].os_net_buf_ptr
= skb
;
468 bulkdata
.d
[0].data_length
= skb
->len
;
470 unifi_frame_ma_packet_req(priv
, priority
, 0, 0xffffffff, interfaceTag
,
471 CSR_NO_CONFIRM_REQUIRED
, priv
->netdev_client
->sender_id
,
472 interfacePriv
->bssid
.a
, &signal
);
474 r
= ul_send_signal_unpacked(priv
, &signal
, &bulkdata
);
477 unifi_error(priv
, "CsrWifiSmeRoamCompleteIndHandler: failed to send QOS data null packet result: %d\n",r
);
478 unifi_net_data_free(priv
, &bulkdata
.d
[0]);
483 #endif /* CSR_WIFI_SEND_GRATUITOUS_ARP */
486 * ---------------------------------------------------------------------------
487 * configure_data_port
489 * Store the new controlled port configuration.
492 * priv Pointer to device private context struct
493 * port_cfg Pointer to the port configuration
496 * An unifi_ControlledPortAction value.
497 * ---------------------------------------------------------------------------
500 configure_data_port(unifi_priv_t
*priv
,
501 CsrWifiRouterCtrlPortAction port_action
,
502 const CsrWifiMacAddress
*macAddress
,
506 const u8 broadcast_mac_address
[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
507 unifi_port_config_t
*port
;
508 netInterface_priv_t
*interfacePriv
;
510 const char* controlled_string
; /* cosmetic "controlled"/"uncontrolled" for trace */
512 if (interfaceTag
>= CSR_WIFI_NUM_INTERFACES
) {
513 unifi_error(priv
, "configure_data_port: bad interfaceTag\n");
517 interfacePriv
= priv
->interfacePriv
[interfaceTag
];
519 if (queue
== UF_CONTROLLED_PORT_Q
) {
520 port
= &interfacePriv
->controlled_data_port
;
521 controlled_string
= "controlled";
523 port
= &interfacePriv
->uncontrolled_data_port
;
524 controlled_string
= "uncontrolled";
527 unifi_trace(priv
, UDBG2
,
528 "port config request %pM %s with port_action %d.\n",
529 macAddress
->a
, controlled_string
, port_action
);
531 /* If the new configuration has the broadcast MAC address or if we are in infrastructure mode then clear the list first and set port overide mode */
532 if ((CSR_WIFI_ROUTER_CTRL_MODE_STA
== interfacePriv
->interfaceMode
||
533 interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI
) ||
534 !memcmp(macAddress
->a
, broadcast_mac_address
, ETH_ALEN
)) {
536 port
->port_cfg
[0].port_action
= port_action
;
537 port
->port_cfg
[0].mac_address
= *macAddress
;
538 port
->port_cfg
[0].in_use
= TRUE
;
539 port
->entries_in_use
= 1;
540 port
->overide_action
= UF_DATA_PORT_OVERIDE
;
542 unifi_trace(priv
, UDBG2
, "%s port override on\n",
543 (queue
== UF_CONTROLLED_PORT_Q
) ? "Controlled" : "Uncontrolled");
545 /* Discard the remaining entries in the port config table */
546 for (i
= 1; i
< UNIFI_MAX_CONNECTIONS
; i
++) {
547 port
->port_cfg
[i
].in_use
= FALSE
;
550 if (port_action
== CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN
) {
551 unifi_trace(priv
, UDBG1
, "%s port broadcast set to open.\n",
552 (queue
== UF_CONTROLLED_PORT_Q
) ? "Controlled" : "Uncontrolled");
555 * Ask stack to schedule for transmission any packets queued
556 * while controlled port was not open.
557 * Use netif_schedule() instead of netif_wake_queue() because
558 * transmission should be already enabled at this point. If it
559 * is not, probably the interface is down and should remain as is.
561 uf_resume_data_plane(priv
, queue
, *macAddress
, interfaceTag
);
563 #ifdef CSR_WIFI_SEND_GRATUITOUS_ARP
564 if ((CSR_WIFI_ROUTER_CTRL_MODE_STA
== interfacePriv
->interfaceMode
) &&
565 (queue
== UF_CONTROLLED_PORT_Q
) && (priv
->sta_ip_address
!= 0xFFFFFFFF))
567 uf_send_gratuitous_arp(priv
, interfaceTag
);
571 unifi_trace(priv
, UDBG1
, "%s port broadcast set to %s.\n",
572 (queue
== UF_CONTROLLED_PORT_Q
) ? "Controlled" : "Uncontrolled",
573 (port_action
== CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD
) ? "discard": "closed");
575 /* If port is closed, discard all the pending Rx packets */
576 if (port_action
== CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD
) {
577 uf_free_pending_rx_packets(priv
, queue
, *macAddress
,interfaceTag
);
581 /* store the new configuration, either in the entry with matching mac address (if already present),
582 * otherwise in a new entry
585 int found_entry_flag
;
586 int first_free_slot
= -1;
588 /* If leaving override mode, free the port entry used for override */
589 if (port
->overide_action
== UF_DATA_PORT_OVERIDE
) {
590 port
->port_cfg
[0].in_use
= FALSE
;
591 port
->entries_in_use
= 0;
592 port
->overide_action
= UF_DATA_PORT_NOT_OVERIDE
;
594 unifi_trace(priv
, UDBG2
, "%s port override off\n",
595 (queue
== UF_CONTROLLED_PORT_Q
) ? "Controlled" : "Uncontrolled");
598 found_entry_flag
= 0;
599 for (i
= 0; i
< UNIFI_MAX_CONNECTIONS
; i
++) {
600 if (port
->port_cfg
[i
].in_use
) {
601 if (!memcmp(&port
->port_cfg
[i
].mac_address
.a
, macAddress
->a
, ETH_ALEN
)) {
602 /* We've seen this address before, reconfigure it */
603 port
->port_cfg
[i
].port_action
= port_action
;
604 found_entry_flag
= 1;
607 } else if (first_free_slot
== -1) {
608 /* Remember the first free slot on the way past so it can be claimed
609 * if this turns out to be a new MAC address (to save walking the list again).
615 /* At this point we found an existing entry and have updated it, or need to
616 * add a new entry. If all slots are allocated, give up and return an error.
618 if (!found_entry_flag
) {
619 if (first_free_slot
== -1) {
620 unifi_error(priv
, "no free slot found in port config array (%d used)\n", port
->entries_in_use
);
623 port
->entries_in_use
++;
626 unifi_trace(priv
, UDBG3
, "port config index assigned in config_data_port = %d\n", first_free_slot
);
627 port
->port_cfg
[first_free_slot
].in_use
= TRUE
;
628 port
->port_cfg
[first_free_slot
].port_action
= port_action
;
629 port
->port_cfg
[first_free_slot
].mac_address
= *macAddress
;
632 if (port_action
== CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN
) {
634 * Ask stack to schedule for transmission any packets queued
635 * while controlled port was not open.
636 * Use netif_schedule() instead of netif_wake_queue() because
637 * transmission should be already enabled at this point. If it
638 * is not, probably the interface is down and should remain as is.
640 uf_resume_data_plane(priv
, queue
, *macAddress
, interfaceTag
);
644 * If port is closed, discard all the pending Rx packets
645 * coming from the peer station.
647 if (port_action
== CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD
) {
648 uf_free_pending_rx_packets(priv
, queue
, *macAddress
,interfaceTag
);
651 unifi_trace(priv
, UDBG2
,
652 "port config %pM with port_action %d.\n",
653 macAddress
->a
, port_action
);
656 } /* configure_data_port() */
659 void CsrWifiRouterCtrlPortConfigureReqHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
661 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
662 CsrWifiRouterCtrlPortConfigureReq
* req
= (CsrWifiRouterCtrlPortConfigureReq
*)msg
;
663 netInterface_priv_t
*interfacePriv
= priv
->interfacePriv
[req
->interfaceTag
];
665 unifi_trace(priv
, UDBG3
, "entering CsrWifiRouterCtrlPortConfigureReqHandler\n");
666 if (priv
->smepriv
== NULL
) {
667 unifi_error(priv
, "CsrWifiRouterCtrlPortConfigureReqHandler: invalid smepriv\n");
671 /* To update the protection status of the peer/station */
672 switch(interfacePriv
->interfaceMode
)
674 case CSR_WIFI_ROUTER_CTRL_MODE_STA
:
675 case CSR_WIFI_ROUTER_CTRL_MODE_AMP
:
676 case CSR_WIFI_ROUTER_CTRL_MODE_IBSS
:
677 case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI
:
678 /* Since for Unifi as a station, the station record not maintained & interfaceID is
679 * only needed to update the peer protection status
681 interfacePriv
->protect
= req
->setProtection
;
683 case CSR_WIFI_ROUTER_CTRL_MODE_AP
:
684 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
:
687 CsrWifiRouterCtrlStaInfo_t
*staRecord
;
688 /* Ifscontrolled port is open means, The peer has been added to station record
689 * so that the protection corresponding to the peer is valid in this req
691 if (req
->controlledPortAction
== CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN
) {
692 for(i
=0; i
< UNIFI_MAX_CONNECTIONS
; i
++) {
693 staRecord
= (CsrWifiRouterCtrlStaInfo_t
*) (interfacePriv
->staInfo
[i
]);
695 /* Find the matching station record & set the protection type */
696 if (!memcmp(req
->macAddress
.a
, staRecord
->peerMacAddress
.a
, ETH_ALEN
)) {
697 staRecord
->protection
= req
->setProtection
;
706 unifi_trace(priv
, UDBG1
, "CsrWifiRouterCtrlPortConfigureReqHandler(0x%.4X) Uncaught mode %d\n",
707 msg
->source
, interfacePriv
->interfaceMode
);
710 configure_data_port(priv
, req
->uncontrolledPortAction
, (const CsrWifiMacAddress
*)&req
->macAddress
,
711 UF_UNCONTROLLED_PORT_Q
, req
->interfaceTag
);
712 configure_data_port(priv
, req
->controlledPortAction
, (const CsrWifiMacAddress
*)&req
->macAddress
,
713 UF_CONTROLLED_PORT_Q
, req
->interfaceTag
);
715 CsrWifiRouterCtrlPortConfigureCfmSend(msg
->source
,req
->clientData
,req
->interfaceTag
,
716 CSR_RESULT_SUCCESS
, req
->macAddress
);
717 unifi_trace(priv
, UDBG3
, "leaving CsrWifiRouterCtrlPortConfigureReqHandler\n");
721 void CsrWifiRouterCtrlWifiOnReqHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
723 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
724 CsrWifiRouterCtrlVersions versions
;
725 CsrWifiRouterCtrlWifiOnReq
* req
= (CsrWifiRouterCtrlWifiOnReq
*)msg
;
732 if( priv
->wol_suspend
) {
733 unifi_trace(priv
, UDBG1
, "CsrWifiRouterCtrlWifiOnReqHandler: Don't reset mode\n");
736 /* Take the wakelock while Wi-Fi On is in progress */
737 unifi_trace(priv
, UDBG1
, "CsrWifiRouterCtrlWifiOnReqHandler: take wake lock\n");
738 wake_lock(&unifi_sdio_wake_lock
);
740 for (i
=0; i
<CSR_WIFI_NUM_INTERFACES
; i
++) {
741 unifi_trace(priv
, UDBG1
, "CsrWifiRouterCtrlWifiOnReqHandler: Setting interface %d to NONE\n", i
);
743 priv
->interfacePriv
[i
]->interfaceMode
= 0;
746 unifi_trace(priv
, UDBG1
, "CsrWifiRouterCtrlWifiOnReqHandler(0x%.4X) req->dataLength=%d req->data=0x%x\n", msg
->source
, req
->dataLength
, req
->data
);
748 if(req
->dataLength
==3 && req
->data
&& req
->data
[0]==0 && req
->data
[1]==1 && req
->data
[2]==1)
750 priv
->cmanrTestMode
= TRUE
;
751 unifi_trace(priv
, UDBG1
, "CsrWifiRouterCtrlWifiOnReqHandler: cmanrTestMode=%d\n", priv
->cmanrTestMode
);
755 priv
->cmanrTestMode
= FALSE
;
759 * The request to initialise UniFi might come while UniFi is running.
760 * We need to block all I/O activity until the reset completes, otherwise
761 * an SDIO error might occur resulting an indication to the SME which
762 * makes it think that the initialisation has failed.
764 priv
->bh_thread
.block_thread
= 1;
766 /* Update the wifi_on state */
767 priv
->wifi_on_state
= wifi_on_in_progress
;
769 /* If UniFi was unpowered, acquire the firmware for download to chip */
770 if (!priv
->wol_suspend
) {
771 r
= uf_request_firmware_files(priv
, UNIFI_FW_STA
);
773 unifi_error(priv
, "CsrWifiRouterCtrlWifiOnReqHandler: Failed to get f/w\n");
774 CsrWifiRouterCtrlWifiOnCfmSend(msg
->source
, req
->clientData
, CSR_RESULT_FAILURE
);
778 unifi_trace(priv
, UDBG1
, "Don't need firmware\n");
781 /* Power on UniFi (which may not necessarily have been off) */
782 CsrSdioClaim(priv
->sdio
);
783 csrResult
= CsrSdioPowerOn(priv
->sdio
);
784 CsrSdioRelease(priv
->sdio
);
785 if (csrResult
!= CSR_RESULT_SUCCESS
&& csrResult
!= CSR_SDIO_RESULT_NOT_RESET
) {
786 unifi_error(priv
, "CsrWifiRouterCtrlWifiOnReqHandler: Failed to power on UniFi\n");
787 CsrWifiRouterCtrlWifiOnCfmSend(msg
->source
, req
->clientData
, CSR_RESULT_FAILURE
);
791 /* If CsrSdioPowerOn() returns CSR_RESULT_SUCCESS, it means that we need to initialise UniFi */
792 if (csrResult
== CSR_RESULT_SUCCESS
&& !priv
->wol_suspend
) {
793 /* Initialise UniFi hardware */
794 r
= uf_init_hw(priv
);
796 unifi_error(priv
, "CsrWifiRouterCtrlWifiOnReqHandler: Failed to initialise h/w, error %d\n", r
);
797 CsrWifiRouterCtrlWifiOnCfmSend(msg
->source
, req
->clientData
, CSR_RESULT_FAILURE
);
801 unifi_trace(priv
, UDBG1
, "UniFi already initialised\n");
804 /* Completed handling of wake up from suspend with UniFi powered */
805 priv
->wol_suspend
= FALSE
;
807 /* Re-enable the I/O thread */
808 priv
->bh_thread
.block_thread
= 0;
811 * Start the I/O thread. The thread might be already running.
812 * This fine, just carry on with the request.
814 r
= uf_init_bh(priv
);
816 CsrSdioClaim(priv
->sdio
);
817 CsrSdioPowerOff(priv
->sdio
);
818 CsrSdioRelease(priv
->sdio
);
819 CsrWifiRouterCtrlWifiOnCfmSend(msg
->source
, req
->clientData
, CSR_RESULT_FAILURE
);
823 /* Get the version information from the core */
824 unifi_card_info(priv
->card
, &priv
->card_info
);
826 /* Set the sme queue id */
827 priv
->CSR_WIFI_SME_IFACEQUEUE
= msg
->source
;
828 CSR_WIFI_SME_IFACEQUEUE
= msg
->source
;
831 /* Copy to the unifiio_card_info structure. */
832 versions
.chipId
= priv
->card_info
.chip_id
;
833 versions
.chipVersion
= priv
->card_info
.chip_version
;
834 versions
.firmwareBuild
= priv
->card_info
.fw_build
;
835 versions
.firmwareHip
= priv
->card_info
.fw_hip_version
;
836 versions
.routerBuild
= (char*)CSR_WIFI_VERSION
;
837 versions
.routerHip
= (UNIFI_HIP_MAJOR_VERSION
<< 8) | UNIFI_HIP_MINOR_VERSION
;
839 CsrWifiRouterCtrlWifiOnIndSend(msg
->source
, 0, CSR_RESULT_SUCCESS
, versions
);
841 /* Update the wifi_on state */
842 priv
->wifi_on_state
= wifi_on_done
;
848 * Common code for CsrWifiRouterCtrlWifiOffReqHandler() and
849 * CsrWifiRouterCtrlWifiOffRspHandler().
852 wifi_off(unifi_priv_t
*priv
)
861 if (priv
->wifi_on_state
== wifi_on_unspecified
) {
862 unifi_trace(priv
, UDBG1
, "wifi_off already\n");
866 unifi_trace(priv
, UDBG1
, "wifi_off\n");
868 /* Destroy the Traffic Analysis Module */
869 cancel_work_sync(&priv
->ta_ind_work
.task
);
870 cancel_work_sync(&priv
->ta_sample_ind_work
.task
);
871 #ifdef CSR_SUPPORT_WEXT
872 cancel_work_sync(&priv
->sme_config_task
);
873 wext_send_disassoc_event(priv
);
876 /* Cancel pending M4 stuff */
877 for (i
= 0; i
< CSR_WIFI_NUM_INTERFACES
; i
++) {
878 if (priv
->netdev
[i
]) {
879 netInterface_priv_t
*netpriv
= (netInterface_priv_t
*) netdev_priv(priv
->netdev
[i
]);
880 cancel_work_sync(&netpriv
->send_m4_ready_task
);
883 flush_workqueue(priv
->unifi_workqueue
);
885 /* fw_init parameter can prevent power off UniFi, for debugging */
886 priv_instance
= uf_find_priv(priv
);
887 if (priv_instance
== -1) {
889 "CsrWifiRouterCtrlStopReqHandler: Unknown priv instance, will power off card.\n");
892 power_off
= (fw_init
[priv_instance
] > 0) ? 0 : 1;
895 /* Production test mode requires power to the chip, too */
896 if (priv
->ptest_mode
) {
900 /* Stop the bh_thread */
901 uf_stop_thread(priv
, &priv
->bh_thread
);
903 /* Read the f/w panic codes, if any. Protect against second wifi_off() call,
904 * which may happen if SME requests a wifi_off and closes the char device */
905 if (priv
->init_progress
!= UNIFI_INIT_NONE
) {
906 CsrSdioClaim(priv
->sdio
);
907 unifi_capture_panic(priv
->card
);
908 CsrSdioRelease(priv
->sdio
);
911 /* Unregister the interrupt handler */
912 if (csr_sdio_linux_remove_irq(priv
->sdio
)) {
914 "csr_sdio_linux_remove_irq failed to talk to card.\n");
918 unifi_trace(priv
, UDBG2
,
919 "Force low power and try to power off\n");
920 /* Put UniFi to deep sleep, in case we can not power it off */
921 CsrSdioClaim(priv
->sdio
);
922 csrResult
= unifi_force_low_power_mode(priv
->card
);
923 CsrSdioRelease(priv
->sdio
);
925 CsrSdioPowerOff(priv
->sdio
);
928 /* Consider UniFi to be uninitialised */
929 priv
->init_progress
= UNIFI_INIT_NONE
;
930 priv
->wifi_on_state
= wifi_on_unspecified
;
936 void CsrWifiRouterCtrlWifiOffReqHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
938 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
939 CsrWifiRouterCtrlWifiOffReq
* req
= (CsrWifiRouterCtrlWifiOffReq
*)msg
;
946 unifi_trace(priv
, UDBG1
, "CsrWifiRouterCtrlWifiOffReqHandler(0x%.4X)\n", msg
->source
);
948 /* Stop the network traffic on all interfaces before freeing the core. */
949 for (i
=0; i
<CSR_WIFI_NUM_INTERFACES
; i
++) {
950 netInterface_priv_t
*interfacePriv
= priv
->interfacePriv
[i
];
951 if (interfacePriv
->netdev_registered
== 1) {
952 netif_carrier_off(priv
->netdev
[i
]);
953 netif_tx_stop_all_queues(priv
->netdev
[i
]);
954 interfacePriv
->connected
= UnifiConnectedUnknown
;
956 interfacePriv
->interfaceMode
= 0;
958 /* Enable all queues by default */
959 interfacePriv
->queueEnabled
[0] = 1;
960 interfacePriv
->queueEnabled
[1] = 1;
961 interfacePriv
->queueEnabled
[2] = 1;
962 interfacePriv
->queueEnabled
[3] = 1;
966 CsrWifiRouterCtrlWifiOffCfmSend(msg
->source
,req
->clientData
);
968 /* If this is called in response to closing the character device, the
969 * caller must use uf_sme_cancel_request() to terminate any pending SME
970 * blocking request or there will be a delay while the operation times out.
975 void CsrWifiRouterCtrlQosControlReqHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
977 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
978 CsrWifiRouterCtrlQosControlReq
* req
= (CsrWifiRouterCtrlQosControlReq
*)msg
;
979 netInterface_priv_t
*interfacePriv
;
981 if (priv
->smepriv
== NULL
) {
982 unifi_error(priv
, "CsrWifiRouterCtrlQosControlReqHandler: invalid smepriv\n");
986 unifi_trace(priv
, UDBG4
, "CsrWifiRouterCtrlQosControlReqHandler:scontrol = %d", req
->control
);
988 if (req
->interfaceTag
>= CSR_WIFI_NUM_INTERFACES
) {
989 unifi_error(priv
, "CsrWifiRouterCtrlQosControlReqHandler: interfaceID >= CSR_WIFI_NUM_INTERFACES.\n");
992 interfacePriv
= priv
->interfacePriv
[req
->interfaceTag
];
994 if (req
->control
== CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_WMM_ON
) {
995 priv
->sta_wmm_capabilities
|= QOS_CAPABILITY_WMM_ENABLED
;
996 unifi_trace(priv
, UDBG1
, "WMM enabled\n");
998 unifi_trace(priv
, UDBG1
, "Queue Config %x\n", req
->queueConfig
);
1000 interfacePriv
->queueEnabled
[UNIFI_TRAFFIC_Q_BK
] = (req
->queueConfig
& CSR_WIFI_ROUTER_CTRL_QUEUE_BK_ENABLE
)?1:0;
1001 interfacePriv
->queueEnabled
[UNIFI_TRAFFIC_Q_BE
] = (req
->queueConfig
& CSR_WIFI_ROUTER_CTRL_QUEUE_BE_ENABLE
)?1:0;
1002 interfacePriv
->queueEnabled
[UNIFI_TRAFFIC_Q_VI
] = (req
->queueConfig
& CSR_WIFI_ROUTER_CTRL_QUEUE_VI_ENABLE
)?1:0;
1003 interfacePriv
->queueEnabled
[UNIFI_TRAFFIC_Q_VO
] = (req
->queueConfig
& CSR_WIFI_ROUTER_CTRL_QUEUE_VO_ENABLE
)?1:0;
1006 priv
->sta_wmm_capabilities
= 0;
1007 unifi_trace(priv
, UDBG1
, "WMM disabled\n");
1012 void CsrWifiRouterCtrlTclasAddReqHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
1014 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
1015 CsrWifiRouterCtrlTclasAddReq
* req
= (CsrWifiRouterCtrlTclasAddReq
*)msg
;
1018 unifi_error(priv
, "CsrWifiRouterCtrlTclasAddReqHandler: invalid smepriv\n");
1022 CsrWifiRouterCtrlTclasAddCfmSend(msg
->source
, req
->clientData
, req
->interfaceTag
, CSR_RESULT_SUCCESS
);
1025 void CsrWifiRouterCtrlTclasDelReqHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
1027 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
1028 CsrWifiRouterCtrlTclasDelReq
* req
= (CsrWifiRouterCtrlTclasDelReq
*)msg
;
1031 unifi_error(priv
, "CsrWifiRouterCtrlTclasDelReqHandler: invalid smepriv\n");
1035 CsrWifiRouterCtrlTclasDelCfmSend(msg
->source
, req
->clientData
, req
->interfaceTag
, CSR_RESULT_SUCCESS
);
1039 void CsrWifiRouterCtrlConfigurePowerModeReqHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
1041 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
1042 CsrWifiRouterCtrlConfigurePowerModeReq
* req
= (CsrWifiRouterCtrlConfigurePowerModeReq
*)msg
;
1043 enum unifi_low_power_mode pm
;
1044 CsrResult csrResult
;
1046 if (priv
->smepriv
== NULL
) {
1047 unifi_error(priv
, "CsrWifiRouterCtrlConfigurePowerModeReqHandler: invalid smepriv\n");
1051 if (req
->mode
== CSR_WIFI_ROUTER_CTRL_LOW_POWER_MODE_DISABLED
) {
1052 pm
= UNIFI_LOW_POWER_DISABLED
;
1054 pm
= UNIFI_LOW_POWER_ENABLED
;
1057 unifi_trace(priv
, UDBG2
,
1058 "CsrWifiRouterCtrlConfigurePowerModeReqHandler (mode=%d, wake=%d)\n",
1059 req
->mode
, req
->wakeHost
);
1060 csrResult
= unifi_configure_low_power_mode(priv
->card
, pm
,
1061 (req
->wakeHost
? UNIFI_PERIODIC_WAKE_HOST_ENABLED
: UNIFI_PERIODIC_WAKE_HOST_DISABLED
));
1065 void CsrWifiRouterCtrlWifiOnResHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
1067 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
1068 CsrWifiRouterCtrlWifiOnRes
* res
= (CsrWifiRouterCtrlWifiOnRes
*)msg
;
1071 unifi_error(NULL
, "CsrWifiRouterCtrlWifiOnResHandler: Invalid ospriv.\n");
1075 unifi_trace(priv
, UDBG1
,
1076 "CsrWifiRouterCtrlWifiOnResHandler: status %d (patch %u)\n", res
->status
, res
->smeVersions
.firmwarePatch
);
1078 if (res
->smeVersions
.firmwarePatch
!= 0) {
1079 unifi_info(priv
, "Firmware patch %d\n", res
->smeVersions
.firmwarePatch
);
1082 if (res
->numInterfaceAddress
> CSR_WIFI_NUM_INTERFACES
) {
1083 unifi_error(priv
, "WifiOnResHandler bad numInterfaceAddress %d\n", res
->numInterfaceAddress
);
1087 /* UniFi is now initialised, complete the init. */
1088 if (res
->status
== CSR_RESULT_SUCCESS
)
1090 int i
; /* used as a loop counter */
1091 u32 intmode
= CSR_WIFI_INTMODE_DEFAULT
;
1092 #ifdef CSR_WIFI_SPLIT_PATCH
1093 u8 switching_ap_fw
= FALSE
;
1095 /* Register the UniFi device with the OS network manager */
1096 unifi_trace(priv
, UDBG3
, "Card Init Completed Successfully\n");
1098 /* Store the MAC address in the netdev */
1099 for(i
=0;i
<res
->numInterfaceAddress
;i
++)
1101 memcpy(priv
->netdev
[i
]->dev_addr
, res
->stationMacAddress
[i
].a
, ETH_ALEN
);
1104 /* Copy version structure into the private versions field */
1105 priv
->sme_versions
= res
->smeVersions
;
1107 unifi_trace(priv
, UDBG2
, "network interfaces count = %d\n",
1108 res
->numInterfaceAddress
);
1110 /* Register the netdevs for each interface. */
1111 for(i
=0;i
<res
->numInterfaceAddress
;i
++)
1113 netInterface_priv_t
*interfacePriv
= priv
->interfacePriv
[i
];
1114 if(!interfacePriv
->netdev_registered
)
1117 unifi_trace(priv
, UDBG3
, "registering net device %d\n", i
);
1118 r
= uf_register_netdev(priv
, i
);
1121 /* unregister the net_device that are registered in the previous iterations */
1122 uf_unregister_netdev(priv
);
1123 unifi_error(priv
, "Failed to register the network device.\n");
1124 CsrWifiRouterCtrlWifiOnCfmSend(msg
->source
, res
->clientData
, CSR_RESULT_FAILURE
);
1128 #ifdef CSR_WIFI_SPLIT_PATCH
1131 /* If a netdev is already registered, we have received this WifiOnRes
1132 * in response to switching AP/STA firmware in a ModeSetReq.
1133 * Rememeber this in order to send a ModeSetCfm once
1135 switching_ap_fw
= TRUE
;
1139 priv
->totalInterfaceCount
= res
->numInterfaceAddress
;
1141 /* If the MIB has selected f/w scheduled interrupt mode, apply it now
1142 * but let module param override.
1144 if (run_bh_once
!= -1) {
1145 intmode
= (u32
)run_bh_once
;
1146 } else if (res
->scheduledInterrupt
) {
1147 intmode
= CSR_WIFI_INTMODE_RUN_BH_ONCE
;
1149 unifi_set_interrupt_mode(priv
->card
, intmode
);
1151 priv
->init_progress
= UNIFI_INIT_COMPLETED
;
1153 /* Acknowledge the CsrWifiRouterCtrlWifiOnReq now */
1154 CsrWifiRouterCtrlWifiOnCfmSend(msg
->source
, res
->clientData
, CSR_RESULT_SUCCESS
);
1156 #ifdef CSR_WIFI_SPLIT_PATCH
1157 if (switching_ap_fw
&& (priv
->pending_mode_set
.common
.destination
!= 0xaaaa)) {
1158 unifi_info(priv
, "Completed firmware reload with %s patch\n",
1159 CSR_WIFI_HIP_IS_AP_FW(priv
->interfacePriv
[0]->interfaceMode
) ? "AP" : "STA");
1161 /* Confirm the ModeSetReq that requested the AP/STA patch switch */
1162 CsrWifiRouterCtrlModeSetCfmSend(priv
->pending_mode_set
.common
.source
,
1163 priv
->pending_mode_set
.clientData
,
1164 priv
->pending_mode_set
.interfaceTag
,
1165 priv
->pending_mode_set
.mode
,
1166 CSR_RESULT_SUCCESS
);
1167 priv
->pending_mode_set
.common
.destination
= 0xaaaa;
1170 unifi_info(priv
, "UniFi ready\n");
1172 #ifdef ANDROID_BUILD
1173 /* Release the wakelock */
1174 unifi_trace(priv
, UDBG1
, "ready: release wake lock\n");
1175 wake_unlock(&unifi_sdio_wake_lock
);
1177 /* Firmware initialisation is complete, so let the SDIO bus
1178 * clock be raised when convienent to the core.
1180 unifi_request_max_sdio_clock(priv
->card
);
1182 #ifdef CSR_SUPPORT_WEXT
1183 /* Notify the Android wpa_supplicant that we are ready */
1184 wext_send_started_event(priv
);
1186 queue_work(priv
->unifi_workqueue
, &priv
->sme_config_task
);
1190 /* Acknowledge the CsrWifiRouterCtrlWifiOnReq now */
1191 CsrWifiRouterCtrlWifiOnCfmSend(msg
->source
, res
->clientData
, CSR_RESULT_FAILURE
);
1196 void CsrWifiRouterCtrlWifiOffResHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
1201 void CsrWifiRouterCtrlMulticastAddressResHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
1206 void CsrWifiRouterMaPacketSubscribeReqHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
1208 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
1209 CsrWifiRouterMaPacketSubscribeReq
* req
= (CsrWifiRouterMaPacketSubscribeReq
*)msg
;
1214 unifi_error(priv
, "CsrWifiRouterMaPacketSubscribeReqHandler: invalid priv\n");
1218 /* Look for an unused filter */
1220 result
= CSR_WIFI_RESULT_NO_ROOM
;
1221 for (i
= 0; i
< MAX_MA_UNIDATA_IND_FILTERS
; i
++) {
1223 if (!priv
->sme_unidata_ind_filters
[i
].in_use
) {
1225 priv
->sme_unidata_ind_filters
[i
].in_use
= 1;
1226 priv
->sme_unidata_ind_filters
[i
].appHandle
= msg
->source
;
1227 priv
->sme_unidata_ind_filters
[i
].encapsulation
= req
->encapsulation
;
1228 priv
->sme_unidata_ind_filters
[i
].protocol
= req
->protocol
;
1230 priv
->sme_unidata_ind_filters
[i
].oui
[2] = (u8
) (req
->oui
& 0xFF);
1231 priv
->sme_unidata_ind_filters
[i
].oui
[1] = (u8
) ((req
->oui
>> 8) & 0xFF);
1232 priv
->sme_unidata_ind_filters
[i
].oui
[0] = (u8
) ((req
->oui
>> 16) & 0xFF);
1234 result
= CSR_RESULT_SUCCESS
;
1239 unifi_trace(priv
, UDBG1
,
1240 "subscribe_req: encap=%d, handle=%d, result=%d\n",
1241 req
->encapsulation
, i
, result
);
1242 CsrWifiRouterMaPacketSubscribeCfmSend(msg
->source
,req
->interfaceTag
, i
, result
, 0);
1246 void CsrWifiRouterMaPacketUnsubscribeReqHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
1248 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
1249 CsrWifiRouterMaPacketUnsubscribeReq
* req
= (CsrWifiRouterMaPacketUnsubscribeReq
*)msg
;
1253 unifi_error(priv
, "CsrWifiRouterMaPacketUnsubscribeReqHandler: invalid priv\n");
1257 result
= CSR_WIFI_RESULT_NOT_FOUND
;
1259 if (req
->subscriptionHandle
< MAX_MA_UNIDATA_IND_FILTERS
) {
1260 if (priv
->sme_unidata_ind_filters
[req
->subscriptionHandle
].in_use
) {
1261 priv
->sme_unidata_ind_filters
[req
->subscriptionHandle
].in_use
= 0;
1262 result
= CSR_RESULT_SUCCESS
;
1264 result
= CSR_WIFI_RESULT_NOT_FOUND
;
1268 unifi_trace(priv
, UDBG1
,
1269 "unsubscribe_req: handle=%d, result=%d\n",
1270 req
->subscriptionHandle
, result
);
1271 CsrWifiRouterMaPacketUnsubscribeCfmSend(msg
->source
,req
->interfaceTag
, result
);
1275 void CsrWifiRouterCtrlCapabilitiesReqHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
1277 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
1278 CsrWifiRouterCtrlCapabilitiesReq
* req
= (CsrWifiRouterCtrlCapabilitiesReq
*)msg
;
1281 unifi_error(priv
, "CsrWifiRouterCtrlCapabilitiesReqHandler: invalid priv\n");
1285 CsrWifiRouterCtrlCapabilitiesCfmSend(msg
->source
,req
->clientData
,
1286 UNIFI_SOFT_COMMAND_Q_LENGTH
- 1,
1287 UNIFI_SOFT_TRAFFIC_Q_LENGTH
- 1);
1291 void CsrWifiRouterCtrlSuspendResHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
1293 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
1294 CsrWifiRouterCtrlSuspendRes
* res
= (CsrWifiRouterCtrlSuspendRes
*)msg
;
1297 unifi_error(priv
, "CsrWifiRouterCtrlSuspendResHandler: invalid priv\n");
1301 sme_complete_request(priv
, res
->status
);
1305 void CsrWifiRouterCtrlResumeResHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
1307 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
1308 CsrWifiRouterCtrlResumeRes
* res
= (CsrWifiRouterCtrlResumeRes
*)msg
;
1311 unifi_error(priv
, "CsrWifiRouterCtrlResumeResHandler: invalid priv\n");
1315 sme_complete_request(priv
, res
->status
);
1319 void CsrWifiRouterCtrlTrafficConfigReqHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
1321 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
1322 CsrWifiRouterCtrlTrafficConfigReq
* req
= (CsrWifiRouterCtrlTrafficConfigReq
*)msg
;
1323 CsrResult csrResult
;
1326 unifi_error(priv
, "CsrWifiRouterCtrlTrafficConfigReqHandler: invalid smepriv\n");
1329 if (req
->trafficConfigType
== CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_FILTER
)
1331 req
->config
.packetFilter
|= CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM
;
1333 csrResult
= unifi_ta_configure(priv
->card
, req
->trafficConfigType
, (const CsrWifiRouterCtrlTrafficConfig
*)&req
->config
);
1336 void CsrWifiRouterCtrlTrafficClassificationReqHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
1338 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
1339 CsrWifiRouterCtrlTrafficClassificationReq
* req
= (CsrWifiRouterCtrlTrafficClassificationReq
*)msg
;
1342 unifi_error(priv
, "CsrWifiRouterCtrlTrafficClassificationReqHandler: invalid smepriv\n");
1346 unifi_ta_classification(priv
->card
, req
->trafficType
, req
->period
);
1350 _sys_packet_req(unifi_priv_t
*priv
, const CSR_SIGNAL
*signal
,
1351 u8 subscriptionHandle
,
1352 u16 frameLength
, u8
*frame
,
1356 const sme_ma_unidata_ind_filter_t
*subs
;
1357 bulk_data_param_t bulkdata
;
1358 CSR_MA_PACKET_REQUEST req
= signal
->u
.MaPacketRequest
;
1359 struct sk_buff
*skb
, *newSkb
= NULL
;
1360 CsrWifiMacAddress peerMacAddress
;
1361 CsrResult csrResult
;
1362 u16 interfaceTag
= req
.VirtualInterfaceIdentifier
& 0xff;
1363 u8 eapolStore
= FALSE
;
1365 netInterface_priv_t
*interfacePriv
;
1366 unsigned long flags
;
1368 if (interfaceTag
>= CSR_WIFI_NUM_INTERFACES
) {
1369 unifi_error(priv
, "_sys_packet_req: interfaceID >= CSR_WIFI_NUM_INTERFACES.\n");
1372 interfacePriv
= priv
->interfacePriv
[interfaceTag
];
1373 if (!priv
->sme_unidata_ind_filters
[subscriptionHandle
].in_use
) {
1374 unifi_error(priv
, "_sys_packet_req: unknown subscription.\n");
1378 subs
= &priv
->sme_unidata_ind_filters
[subscriptionHandle
];
1379 unifi_trace(priv
, UDBG1
,
1380 "_sys_packet_req: handle=%d, subs=%p, encap=%d\n",
1381 subscriptionHandle
, subs
, subs
->encapsulation
);
1383 csrResult
= unifi_net_data_malloc(priv
, &bulkdata
.d
[0], frameLength
);
1384 if (csrResult
!= CSR_RESULT_SUCCESS
) {
1385 unifi_error(priv
, "_sys_packet_req: failed to allocate bulkdata.\n");
1386 return (int)CsrHipResultToStatus(csrResult
);
1389 /* get the peer Mac address */
1390 memcpy(&peerMacAddress
, frame
, ETH_ALEN
);
1392 /* Determine if we need to add encapsulation header */
1393 if (subs
->encapsulation
== CSR_WIFI_ROUTER_ENCAPSULATION_ETHERNET
) {
1394 memcpy((void*)bulkdata
.d
[0].os_data_ptr
, frame
, frameLength
);
1396 /* The translation is performed on the skb */
1397 skb
= (struct sk_buff
*)bulkdata
.d
[0].os_net_buf_ptr
;
1399 unifi_trace(priv
, UDBG1
,
1400 "_sys_packet_req: skb_add_llc_snap -->\n");
1401 r
= skb_add_llc_snap(priv
->netdev
[interfaceTag
], skb
, proto
);
1402 unifi_trace(priv
, UDBG1
,
1403 "_sys_packet_req: skb_add_llc_snap <--\n");
1406 "_sys_packet_req: failed to translate eth frame.\n");
1407 unifi_net_data_free(priv
,&bulkdata
.d
[0]);
1411 bulkdata
.d
[0].data_length
= skb
->len
;
1413 /* Crop the MAC addresses from the packet */
1414 memcpy((void*)bulkdata
.d
[0].os_data_ptr
, frame
+ 2*ETH_ALEN
, frameLength
- 2*ETH_ALEN
);
1415 bulkdata
.d
[0].data_length
= frameLength
- 2*ETH_ALEN
;
1416 skb
= (struct sk_buff
*)bulkdata
.d
[0].os_net_buf_ptr
;
1417 skb
->len
= bulkdata
.d
[0].data_length
;
1421 bulkdata
.d
[1].os_data_ptr
= NULL
;
1422 bulkdata
.d
[1].os_net_buf_ptr
= NULL
;
1423 bulkdata
.d
[1].data_length
= 0;
1425 /* check for m4 detection */
1426 if (0 == uf_verify_m4(priv
, bulkdata
.d
[0].os_data_ptr
, bulkdata
.d
[0].data_length
)) {
1430 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
1431 if (proto
== ETH_P_WAI
)
1433 protection
= 0; /*WAI packets always sent unencrypted*/
1439 #ifdef CSR_SUPPORT_SME
1440 if ((protection
= uf_get_protection_bit_from_interfacemode(priv
, interfaceTag
, peerMacAddress
.a
)) < 0) {
1441 unifi_error(priv
, "unicast address, but destination not in station record database\n");
1442 unifi_net_data_free(priv
,&bulkdata
.d
[0]);
1449 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
1453 /* add Mac header */
1454 if (prepare_and_add_macheader(priv
, skb
, newSkb
, req
.Priority
, &bulkdata
, interfaceTag
, frame
, frame
+ ETH_ALEN
, protection
)) {
1455 unifi_error(priv
, "failed to create MAC header\n");
1456 unifi_net_data_free(priv
,&bulkdata
.d
[0]);
1461 spin_lock_irqsave(&priv
->m4_lock
, flags
);
1462 /* Store the EAPOL M4 packet for later */
1463 interfacePriv
->m4_signal
= *signal
;
1464 interfacePriv
->m4_bulk_data
.net_buf_length
= bulkdata
.d
[0].net_buf_length
;
1465 interfacePriv
->m4_bulk_data
.data_length
= bulkdata
.d
[0].data_length
;
1466 interfacePriv
->m4_bulk_data
.os_data_ptr
= bulkdata
.d
[0].os_data_ptr
;
1467 interfacePriv
->m4_bulk_data
.os_net_buf_ptr
= bulkdata
.d
[0].os_net_buf_ptr
;
1468 spin_unlock_irqrestore(&priv
->m4_lock
, flags
);
1469 /* Send a signal to SME */
1470 unifi_trace(priv
, UDBG1
, "_sys_packet_req: Sending CsrWifiRouterCtrlM4ReadyToSendInd\n");
1471 CsrWifiRouterCtrlM4ReadyToSendIndSend(priv
->CSR_WIFI_SME_IFACEQUEUE
, 0, interfaceTag
, peerMacAddress
);
1475 /* Send the signal to UniFi */
1476 /* Set the B31 to 1 for local routing*/
1477 r
= uf_process_ma_packet_req(priv
, peerMacAddress
.a
, (req
.HostTag
| 0x80000000), interfaceTag
, 0,
1478 (CSR_RATE
)0, req
.Priority
, signal
->SignalPrimitiveHeader
.SenderProcessId
, &bulkdata
);
1481 "_sys_packet_req: failed to send signal.\n");
1482 unifi_net_data_free(priv
,&bulkdata
.d
[0]);
1485 /* The final CsrWifiRouterMaPacketCfmSend() will called when the actual MA-PACKET.cfm is received from the chip */
1490 void CsrWifiRouterMaPacketReqHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
1493 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
1494 CsrWifiRouterMaPacketReq
* mareq
= (CsrWifiRouterMaPacketReq
*)msg
;
1495 llc_snap_hdr_t
*snap
;
1498 CSR_MA_PACKET_REQUEST
*req
= &signal
.u
.MaPacketRequest
;
1499 CsrWifiRouterCtrlPortAction controlPortaction
;
1501 u16 interfaceTag
= mareq
->interfaceTag
& 0x00ff;
1503 netInterface_priv_t
*interfacePriv
;
1505 if (!mareq
->frame
|| !priv
|| !priv
->smepriv
)
1507 unifi_error(priv
, "CsrWifiRouterMaPacketReqHandler: invalid frame/priv/priv->smepriv\n");
1511 if (interfaceTag
>= CSR_WIFI_NUM_INTERFACES
) {
1512 unifi_error(priv
, "CsrWifiRouterMaPacketReqHandler: interfaceID >= CSR_WIFI_NUM_INTERFACES.\n");
1516 interfacePriv
= priv
->interfacePriv
[interfaceTag
];
1517 /* get a pointer to dest & source Mac address */
1518 daddr
= mareq
->frame
;
1519 saddr
= (mareq
->frame
+ ETH_ALEN
);
1520 /* point to the proper position of frame, since frame has MAC header */
1521 snap
= (llc_snap_hdr_t
*) (mareq
->frame
+ 2 * ETH_ALEN
);
1522 snap_protocol
= ntohs(snap
->protocol
);
1523 if((snap_protocol
== ETH_P_PAE
)
1524 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
1525 || (snap_protocol
== ETH_P_WAI
)
1529 queue
= UF_UNCONTROLLED_PORT_Q
;
1533 queue
= UF_CONTROLLED_PORT_Q
;
1536 /* Controlled port restrictions apply to the packets */
1537 controlPortaction
= uf_sme_port_state(priv
, daddr
, queue
, interfaceTag
);
1538 if (controlPortaction
!= CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN
)
1540 unifi_warning(priv
, "CsrWifiRouterMaPacketReqHandler: (%s)controlled port is closed.\n", (queue
== UF_CONTROLLED_PORT_Q
)?"":"un");
1541 if(mareq
->cfmRequested
)
1543 CsrWifiRouterMaPacketCfmSend(msg
->source
,
1551 signal
.SignalPrimitiveHeader
.SignalId
= CSR_MA_PACKET_REQUEST_ID
;
1552 /* Store the appHandle in the LSB of the SenderId. */
1553 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(((priv
->sme_cli
->sender_id
& 0xff00) | (unsigned int)msg
->source
),
1554 (u8
*)&signal
.SignalPrimitiveHeader
.SenderProcessId
);
1555 signal
.SignalPrimitiveHeader
.ReceiverProcessId
= 0;
1557 /* Fill in the MA-PACKET.req signal */
1558 memcpy(req
->Ra
.x
, daddr
, ETH_ALEN
);
1559 req
->Priority
= mareq
->priority
;
1560 req
->TransmitRate
= 0; /* Let firmware select the rate*/
1561 req
->VirtualInterfaceIdentifier
= uf_get_vif_identifier(interfacePriv
->interfaceMode
,interfaceTag
);
1562 req
->HostTag
= mareq
->hostTag
;
1564 if(mareq
->cfmRequested
)
1565 req
->TransmissionControl
= 0;
1567 req
->TransmissionControl
= CSR_NO_CONFIRM_REQUIRED
;
1569 r
= _sys_packet_req(priv
, &signal
, mareq
->subscriptionHandle
,
1570 mareq
->frameLength
, mareq
->frame
, snap_protocol
);
1572 if (r
&& mareq
->cfmRequested
)
1574 CsrWifiRouterMaPacketCfmSend(msg
->source
,interfaceTag
,
1581 void CsrWifiRouterMaPacketCancelReqHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
1585 void CsrWifiRouterCtrlM4TransmitReqHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
1587 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
1588 CsrWifiRouterCtrlM4TransmitReq
* req
= (CsrWifiRouterCtrlM4TransmitReq
*)msg
;
1590 bulk_data_param_t bulkdata
;
1591 netInterface_priv_t
*interfacePriv
;
1592 CSR_SIGNAL m4_signal
;
1593 unsigned long flags
;
1596 unifi_error(priv
, "CsrWifiRouterCtrlM4TransmitReqHandler: invalid smepriv\n");
1599 if (req
->interfaceTag
>= CSR_WIFI_NUM_INTERFACES
) {
1600 unifi_error(priv
, "M4TransmitReqHandler: interfaceTag >= CSR_WIFI_NUM_INTERFACES\n");
1604 interfacePriv
= priv
->interfacePriv
[req
->interfaceTag
];
1605 spin_lock_irqsave(&priv
->m4_lock
, flags
);
1606 if (interfacePriv
->m4_bulk_data
.data_length
== 0) {
1607 spin_unlock_irqrestore(&priv
->m4_lock
, flags
);
1608 unifi_error(priv
, "CsrWifiRouterCtrlM4TransmitReqHandler: invalid buffer\n");
1612 memcpy(&bulkdata
.d
[0], &interfacePriv
->m4_bulk_data
, sizeof(bulk_data_desc_t
));
1614 interfacePriv
->m4_bulk_data
.net_buf_length
= 0;
1615 interfacePriv
->m4_bulk_data
.data_length
= 0;
1616 interfacePriv
->m4_bulk_data
.os_data_ptr
= interfacePriv
->m4_bulk_data
.os_net_buf_ptr
= NULL
;
1617 m4_signal
= interfacePriv
->m4_signal
;
1618 spin_unlock_irqrestore(&priv
->m4_lock
, flags
);
1620 bulkdata
.d
[1].os_data_ptr
= NULL
;
1621 bulkdata
.d
[1].data_length
= 0;
1623 interfacePriv
->m4_sent
= TRUE
;
1624 m4_signal
.u
.MaPacketRequest
.HostTag
|= 0x80000000;
1625 /* Store the hostTag for later varification */
1626 interfacePriv
->m4_hostTag
= m4_signal
.u
.MaPacketRequest
.HostTag
;
1627 r
= ul_send_signal_unpacked(priv
, &m4_signal
, &bulkdata
);
1628 unifi_trace(priv
, UDBG1
,
1629 "CsrWifiRouterCtrlM4TransmitReqHandler: sent\n");
1632 "CsrWifiRouterCtrlM4TransmitReqHandler: failed to send signal.\n");
1633 unifi_net_data_free(priv
, &bulkdata
.d
[0]);
1637 /* reset the station records when the mode is set as CSR_WIFI_ROUTER_CTRL_MODE_NONE */
1638 static void CsrWifiRouterCtrlResetStationRecordList(unifi_priv_t
*priv
, u16 interfaceTag
)
1641 CsrWifiRouterCtrlStaInfo_t
*staInfo
=NULL
;
1642 netInterface_priv_t
*interfacePriv
= priv
->interfacePriv
[interfaceTag
];
1643 unsigned long lock_flags
;
1645 /* create a list for sending confirms of un-delivered packets */
1646 struct list_head send_cfm_list
;
1648 if (interfaceTag
>= CSR_WIFI_NUM_INTERFACES
) {
1649 unifi_error(priv
, "CsrWifiRouterCtrlResetStationRecordList: bad interfaceTag\n");
1653 INIT_LIST_HEAD(&send_cfm_list
);
1655 /* Reset the station record to NULL if mode is NONE */
1656 for(i
= 0; i
< UNIFI_MAX_CONNECTIONS
; i
++) {
1657 if ((staInfo
=interfacePriv
->staInfo
[i
]) != NULL
) {
1658 uf_prepare_send_cfm_list_for_queued_pkts(priv
,
1660 &(staInfo
->mgtFrames
));
1661 uf_flush_list(priv
,&(staInfo
->mgtFrames
));
1662 for(j
=0;j
<MAX_ACCESS_CATOGORY
;j
++){
1663 uf_prepare_send_cfm_list_for_queued_pkts(priv
,
1665 &(staInfo
->dataPdu
[j
]));
1666 uf_flush_list(priv
,&(staInfo
->dataPdu
[j
]));
1669 spin_lock_irqsave(&priv
->staRecord_lock
,lock_flags
);
1670 /* Removing station record information from port config array */
1671 memset(staInfo
->peerControlledPort
, 0, sizeof(unifi_port_cfg_t
));
1672 staInfo
->peerControlledPort
->port_action
= CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD
;
1673 staInfo
->peerControlledPort
->in_use
= FALSE
;
1674 interfacePriv
->controlled_data_port
.entries_in_use
--;
1676 memset(staInfo
->peerUnControlledPort
, 0, sizeof(unifi_port_cfg_t
));
1677 staInfo
->peerUnControlledPort
->port_action
= CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD
;
1678 staInfo
->peerUnControlledPort
->in_use
= FALSE
;
1679 interfacePriv
->uncontrolled_data_port
.entries_in_use
--;
1681 kfree(interfacePriv
->staInfo
[i
]);
1682 interfacePriv
->staInfo
[i
] = NULL
;
1683 spin_unlock_irqrestore(&priv
->staRecord_lock
,lock_flags
);
1686 /* after the critical region process the list of frames that requested cfm
1687 * and send cfm to requestor one by one
1689 send_auto_ma_packet_confirm(priv
, interfacePriv
, &send_cfm_list
);
1691 #ifdef CSR_SUPPORT_SME
1692 /* Interface Independent, no of packet queued, incase of mode is None or AP set to 0 */
1693 switch(interfacePriv
->interfaceMode
)
1695 case CSR_WIFI_ROUTER_CTRL_MODE_AP
:
1696 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
:
1697 case CSR_WIFI_ROUTER_CTRL_MODE_NONE
:
1698 if (priv
->noOfPktQueuedInDriver
) {
1699 unifi_warning(priv
, "After reset the noOfPktQueuedInDriver = %x\n", priv
->noOfPktQueuedInDriver
);
1700 spin_lock_irqsave(&priv
->tx_q_lock
,lock_flags
);
1701 priv
->noOfPktQueuedInDriver
= 0;
1702 spin_unlock_irqrestore(&priv
->tx_q_lock
,lock_flags
);
1705 case CSR_WIFI_ROUTER_CTRL_MODE_IBSS
:
1708 unifi_error(priv
, "interfacemode is not correct in CsrWifiRouterCtrlResetStationRecordList: debug\n");
1712 if (((interfacePriv
->controlled_data_port
.entries_in_use
!= 0) || (interfacePriv
->uncontrolled_data_port
.entries_in_use
!= 0))
1713 && (interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_NONE
)) {
1714 /* Print in case if the value of entries goes to -ve/+ve (apart from 0)
1715 * we expect the entries should be zero here if mode is set as NONE
1717 unifi_trace(priv
, UDBG3
, "In %s controlled port entries = %d, uncontrolled port entries = %d\n",
1718 __FUNCTION__
, interfacePriv
->controlled_data_port
.entries_in_use
,
1719 interfacePriv
->uncontrolled_data_port
.entries_in_use
);
1723 void CsrWifiRouterCtrlInterfaceReset(unifi_priv_t
*priv
, u16 interfaceTag
)
1725 netInterface_priv_t
*interfacePriv
;
1727 /* create a list for sending confirms of un-delivered packets */
1728 struct list_head send_cfm_list
;
1730 if (interfaceTag
>= CSR_WIFI_NUM_INTERFACES
) {
1731 unifi_error(priv
, "CsrWifiRouterCtrlInterfaceReset: bad interfaceTag\n");
1735 interfacePriv
= priv
->interfacePriv
[interfaceTag
];
1737 INIT_LIST_HEAD(&send_cfm_list
);
1739 /* Enable all queues by default */
1740 interfacePriv
->queueEnabled
[0] = 1;
1741 interfacePriv
->queueEnabled
[1] = 1;
1742 interfacePriv
->queueEnabled
[2] = 1;
1743 interfacePriv
->queueEnabled
[3] = 1;
1745 uf_prepare_send_cfm_list_for_queued_pkts(priv
,
1747 &(interfacePriv
->genericMgtFrames
));
1748 uf_flush_list(priv
,&(interfacePriv
->genericMgtFrames
));
1750 uf_prepare_send_cfm_list_for_queued_pkts(priv
,
1752 &(interfacePriv
->genericMulticastOrBroadCastMgtFrames
));
1753 uf_flush_list(priv
,&(interfacePriv
->genericMulticastOrBroadCastMgtFrames
));
1755 uf_prepare_send_cfm_list_for_queued_pkts(priv
,
1757 &(interfacePriv
->genericMulticastOrBroadCastFrames
));
1759 uf_flush_list(priv
,&(interfacePriv
->genericMulticastOrBroadCastFrames
));
1761 /* process the list of frames that requested cfm
1762 and send cfm to requestor one by one */
1763 send_auto_ma_packet_confirm(priv
, interfacePriv
, &send_cfm_list
);
1765 /* Reset the station record to NULL if mode is tried to set as NONE */
1766 switch(interfacePriv
->interfaceMode
)
1768 case CSR_WIFI_ROUTER_CTRL_MODE_STA
:
1769 case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI
:
1770 case CSR_WIFI_ROUTER_CTRL_MODE_MONITOR
:
1771 case CSR_WIFI_ROUTER_CTRL_MODE_AMP
:
1772 /* station records not available in these modes */
1775 CsrWifiRouterCtrlResetStationRecordList(priv
,interfaceTag
);
1778 interfacePriv
->num_stations_joined
= 0;
1779 interfacePriv
->sta_activity_check_enabled
= FALSE
;
1783 void CsrWifiRouterCtrlModeSetReqHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
1785 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
1786 CsrWifiRouterCtrlModeSetReq
* req
= (CsrWifiRouterCtrlModeSetReq
*)msg
;
1790 unifi_error(priv
, "CsrWifiRouterCtrlModeSetReqHandler: invalid smepriv\n");
1794 if (req
->interfaceTag
< CSR_WIFI_NUM_INTERFACES
)
1796 netInterface_priv_t
*interfacePriv
= priv
->interfacePriv
[req
->interfaceTag
];
1797 #ifdef CSR_WIFI_SPLIT_PATCH
1798 u8 old_mode
= interfacePriv
->interfaceMode
;
1800 unifi_trace(priv
, UDBG1
, "CsrWifiRouterCtrlModeSetReqHandler: interfacePriv->interfaceMode = %d\n",
1801 interfacePriv
->interfaceMode
);
1803 interfacePriv
->interfaceMode
= req
->mode
;
1805 #ifdef CSR_WIFI_SPLIT_PATCH
1806 /* Detect a change in mode that requires a switch to/from the AP firmware patch.
1807 * This should only happen when transitioning in/out of AP modes.
1809 if (CSR_WIFI_HIP_IS_AP_FW(req
->mode
) != CSR_WIFI_HIP_IS_AP_FW(old_mode
))
1811 CsrWifiRouterCtrlVersions versions
;
1814 #ifdef ANDROID_BUILD
1815 /* Take the wakelock while switching patch */
1816 unifi_trace(priv
, UDBG1
, "patch switch: take wake lock\n");
1817 wake_lock(&unifi_sdio_wake_lock
);
1819 unifi_info(priv
, "Resetting UniFi with %s patch\n", CSR_WIFI_HIP_IS_AP_FW(req
->mode
) ? "AP" : "STA");
1821 r
= uf_request_firmware_files(priv
, UNIFI_FW_STA
);
1823 unifi_error(priv
, "CsrWifiRouterCtrlModeSetReqHandler: Failed to get f/w\n");
1824 CsrWifiRouterCtrlModeSetCfmSend(msg
->source
, req
->clientData
, req
->interfaceTag
,
1825 req
->mode
, CSR_RESULT_FAILURE
);
1829 /* Block the I/O thread */
1830 priv
->bh_thread
.block_thread
= 1;
1832 /* Reset and download the new patch */
1833 r
= uf_init_hw(priv
);
1835 unifi_error(priv
, "CsrWifiRouterCtrlWifiOnReqHandler: Failed to initialise h/w, error %d\n", r
);
1836 CsrWifiRouterCtrlModeSetCfmSend(msg
->source
, req
->clientData
, req
->interfaceTag
,
1837 req
->mode
, CSR_RESULT_FAILURE
);
1841 /* Re-enable the I/O thread */
1842 priv
->bh_thread
.block_thread
= 0;
1844 /* Get the version information from the core */
1845 unifi_card_info(priv
->card
, &priv
->card_info
);
1847 /* Copy to the unifiio_card_info structure. */
1848 versions
.chipId
= priv
->card_info
.chip_id
;
1849 versions
.chipVersion
= priv
->card_info
.chip_version
;
1850 versions
.firmwareBuild
= priv
->card_info
.fw_build
;
1851 versions
.firmwareHip
= priv
->card_info
.fw_hip_version
;
1852 versions
.routerBuild
= (char*)CSR_WIFI_VERSION
;
1853 versions
.routerHip
= (UNIFI_HIP_MAJOR_VERSION
<< 8) | UNIFI_HIP_MINOR_VERSION
;
1855 /* Now that new firmware is running, send a WifiOnInd to the NME. This will
1856 * cause it to retransfer the MIB.
1858 CsrWifiRouterCtrlWifiOnIndSend(msg
->source
, 0, CSR_RESULT_SUCCESS
, versions
);
1860 /* Store the request so we know where to send the ModeSetCfm */
1861 priv
->pending_mode_set
= *req
;
1866 /* No patch switch, confirm straightaway */
1867 CsrWifiRouterCtrlModeSetCfmSend(msg
->source
, req
->clientData
, req
->interfaceTag
,
1868 req
->mode
, CSR_RESULT_SUCCESS
);
1871 interfacePriv
->bssid
= req
->bssid
;
1872 /* For modes other than AP/P2PGO, set below member FALSE */
1873 interfacePriv
->intraBssEnabled
= FALSE
;
1874 /* Initialise the variable bcTimSet with a value
1875 * other then CSR_WIFI_TIM_SET or CSR_WIFI_TIM_RESET value
1877 interfacePriv
->bcTimSet
= 0xFF;
1878 interfacePriv
->bcTimSetReqPendingFlag
= FALSE
;
1879 /* Initialise the variable bcTimSetReqQueued with a value
1880 * other then CSR_WIFI_TIM_SET or CSR_WIFI_TIM_RESET value
1882 interfacePriv
->bcTimSetReqQueued
=0xFF;
1883 CsrWifiRouterCtrlInterfaceReset(priv
,req
->interfaceTag
);
1885 if(req
->mode
== CSR_WIFI_ROUTER_CTRL_MODE_AP
||
1886 req
->mode
== CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
) {
1887 interfacePriv
->protect
= req
->protection
;
1888 interfacePriv
->dtimActive
=FALSE
;
1889 interfacePriv
->multicastPduHostTag
= 0xffffffff;
1890 /* For AP/P2PGO mode SME sending intraBssDistEnabled
1891 * i.e. for AP: intraBssDistEnabled = TRUE, for P2PGO
1892 * intraBssDistEnabled = TRUE/FALSE on requirement
1894 interfacePriv
->intraBssEnabled
= req
->intraBssDistEnabled
;
1895 unifi_trace(priv
, UDBG3
, "CsrWifiRouterCtrlModeSetReqHandler: IntraBssDisEnabled = %d\n",
1896 req
->intraBssDistEnabled
);
1897 } else if (req
->mode
== CSR_WIFI_ROUTER_CTRL_MODE_NONE
) {
1898 netif_carrier_off(priv
->netdev
[req
->interfaceTag
]);
1899 interfacePriv
->connected
= UnifiConnectedUnknown
;
1903 unifi_error(priv
, "CsrWifiRouterCtrlModeSetReqHandler: invalid interfaceTag :%d\n",req
->interfaceTag
);
1907 void CsrWifiRouterMaPacketResHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
1911 /* delete the station record from the station record data base */
1912 static int peer_delete_record(unifi_priv_t
*priv
, CsrWifiRouterCtrlPeerDelReq
*req
)
1915 CsrWifiRouterCtrlStaInfo_t
*staInfo
= NULL
;
1916 unifi_port_config_t
*controlledPort
;
1917 unifi_port_config_t
*unControlledPort
;
1918 netInterface_priv_t
*interfacePriv
;
1920 u8 ba_session_idx
= 0;
1921 ba_session_rx_struct
*ba_session_rx
= NULL
;
1922 ba_session_tx_struct
*ba_session_tx
= NULL
;
1924 /* create a list for sending confirms of un-delivered packets */
1925 struct list_head send_cfm_list
;
1927 unsigned long lock_flags
;
1929 if ((req
->peerRecordHandle
>= UNIFI_MAX_CONNECTIONS
) || (req
->interfaceTag
>= CSR_WIFI_NUM_INTERFACES
)) {
1930 unifi_error(priv
, "handle/interfaceTag is not proper, handle = %d, interfaceTag = %d\n", req
->peerRecordHandle
, req
->interfaceTag
);
1931 return CSR_RESULT_FAILURE
;
1934 INIT_LIST_HEAD(&send_cfm_list
);
1936 interfacePriv
= priv
->interfacePriv
[req
->interfaceTag
];
1937 /* remove the station record & make it NULL */
1938 if ((staInfo
=interfacePriv
->staInfo
[req
->peerRecordHandle
])!=NULL
) {
1940 uf_prepare_send_cfm_list_for_queued_pkts(priv
,
1942 &(staInfo
->mgtFrames
));
1944 uf_flush_list(priv
,&(staInfo
->mgtFrames
));
1945 for(j
=0;j
<MAX_ACCESS_CATOGORY
;j
++){
1946 uf_prepare_send_cfm_list_for_queued_pkts(priv
,
1948 &(staInfo
->dataPdu
[j
]));
1949 uf_flush_list(priv
,&(staInfo
->dataPdu
[j
]));
1952 spin_lock_irqsave(&priv
->staRecord_lock
,lock_flags
);
1953 /* clear the port configure array info, for the corresponding peer entry */
1954 controlledPort
= &interfacePriv
->controlled_data_port
;
1955 unControlledPort
= &interfacePriv
->uncontrolled_data_port
;
1957 unifi_trace(priv
, UDBG1
, "peer_delete_record: Peer found handle = %d, port in use: cont(%d), unCont(%d)\n",
1958 req
->peerRecordHandle
, controlledPort
->entries_in_use
, unControlledPort
->entries_in_use
);
1960 memset(staInfo
->peerControlledPort
, 0, sizeof(unifi_port_cfg_t
));
1961 staInfo
->peerControlledPort
->port_action
= CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD
;
1962 staInfo
->peerControlledPort
->in_use
= FALSE
;
1963 if (controlledPort
->entries_in_use
) {
1964 controlledPort
->entries_in_use
--;
1966 unifi_warning(priv
, "number of controlled port entries is zero, trying to decrement: debug\n");
1969 memset(staInfo
->peerUnControlledPort
, 0, sizeof(unifi_port_cfg_t
));
1970 staInfo
->peerUnControlledPort
->port_action
= CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD
;
1971 staInfo
->peerUnControlledPort
->in_use
= FALSE
;
1972 if (unControlledPort
->entries_in_use
) {
1973 unControlledPort
->entries_in_use
--;
1975 unifi_warning(priv
, "number of uncontrolled port entries is zero, trying to decrement: debug\n");
1978 spin_unlock_irqrestore(&priv
->staRecord_lock
,lock_flags
);
1979 /* update the TIM with zero */
1980 if (interfacePriv
->interfaceMode
!= CSR_WIFI_ROUTER_CTRL_MODE_IBSS
&&
1981 staInfo
->timSet
== CSR_WIFI_TIM_SET
) {
1982 unifi_trace(priv
, UDBG3
, "peer is deleted so TIM updated to 0, in firmware\n");
1983 update_tim(priv
,staInfo
->aid
,0,req
->interfaceTag
, req
->peerRecordHandle
);
1987 /* Stop BA session if it is active, for this peer address all BA sessions
1988 (per tID per role) are closed */
1990 down(&priv
->ba_mutex
);
1991 for(ba_session_idx
=0; ba_session_idx
< MAX_SUPPORTED_BA_SESSIONS_RX
; ba_session_idx
++){
1992 ba_session_rx
= priv
->interfacePriv
[req
->interfaceTag
]->ba_session_rx
[ba_session_idx
];
1994 if(!memcmp(ba_session_rx
->macAddress
.a
, staInfo
->peerMacAddress
.a
, ETH_ALEN
)){
1995 blockack_session_stop(priv
,
1997 CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT
,
1999 ba_session_rx
->macAddress
);
2004 for(ba_session_idx
=0; ba_session_idx
< MAX_SUPPORTED_BA_SESSIONS_TX
; ba_session_idx
++){
2005 ba_session_tx
= priv
->interfacePriv
[req
->interfaceTag
]->ba_session_tx
[ba_session_idx
];
2007 if(!memcmp(ba_session_tx
->macAddress
.a
, staInfo
->peerMacAddress
.a
, ETH_ALEN
)){
2008 blockack_session_stop(priv
,
2010 CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR
,
2012 ba_session_tx
->macAddress
);
2017 up(&priv
->ba_mutex
);
2019 #ifdef CSR_SUPPORT_SME
2020 unifi_trace(priv
, UDBG1
, "Canceling work queue for STA with AID: %d\n", staInfo
->aid
);
2021 cancel_work_sync(&staInfo
->send_disconnected_ind_task
);
2024 spin_lock_irqsave(&priv
->staRecord_lock
,lock_flags
);
2025 #ifdef CSR_SUPPORT_SME
2026 interfacePriv
->num_stations_joined
--;
2028 staInfo
->nullDataHostTag
= INVALID_HOST_TAG
;
2030 if ((interfacePriv
->sta_activity_check_enabled
) &&
2031 (interfacePriv
->num_stations_joined
< STA_INACTIVE_DETECTION_TRIGGER_THRESHOLD
))
2033 unifi_trace(priv
, UDBG1
, "STOPPING the Inactivity Timer (num of stations = %d)\n", interfacePriv
->num_stations_joined
);
2034 interfacePriv
->sta_activity_check_enabled
= FALSE
;
2035 del_timer_sync(&interfacePriv
->sta_activity_check_timer
);
2039 /* Free the station record for corresponding peer */
2040 kfree(interfacePriv
->staInfo
[req
->peerRecordHandle
]);
2041 interfacePriv
->staInfo
[req
->peerRecordHandle
] = NULL
;
2042 spin_unlock_irqrestore(&priv
->staRecord_lock
,lock_flags
);
2044 /* after the critical region process the list of frames that requested cfm
2045 and send cfm to requestor one by one */
2046 send_auto_ma_packet_confirm(priv
, interfacePriv
, &send_cfm_list
);
2052 unifi_trace(priv
, UDBG3
, " peer not found: Delete request Peer handle[%d]\n", req
->peerRecordHandle
);
2055 return CSR_RESULT_SUCCESS
;
2058 void CsrWifiRouterCtrlPeerDelReqHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
2060 CsrWifiRouterCtrlPeerDelReq
* req
= (CsrWifiRouterCtrlPeerDelReq
*)msg
;
2061 CsrResult status
= CSR_RESULT_SUCCESS
;
2062 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
2063 netInterface_priv_t
*interfacePriv
;
2065 unifi_trace(priv
, UDBG2
, "entering CsrWifiRouterCtrlPeerDelReqHandler\n");
2068 unifi_error(priv
, "CsrWifiRouterCtrlPeerDelReqHandler: invalid smepriv\n");
2072 if (req
->interfaceTag
>= CSR_WIFI_NUM_INTERFACES
)
2074 unifi_error(priv
, "CsrWifiRouterCtrlPeerDelReqHandler: bad interfaceTag\n");
2078 interfacePriv
= priv
->interfacePriv
[req
->interfaceTag
];
2080 switch(interfacePriv
->interfaceMode
)
2082 case CSR_WIFI_ROUTER_CTRL_MODE_AP
:
2083 case CSR_WIFI_ROUTER_CTRL_MODE_IBSS
:
2084 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
:
2085 /* remove the station from station record data base */
2086 status
= peer_delete_record(priv
, req
);
2088 case CSR_WIFI_ROUTER_CTRL_MODE_STA
:
2089 case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI
:
2091 /* No station record to maintain in these modes */
2095 CsrWifiRouterCtrlPeerDelCfmSend(msg
->source
,req
->clientData
,req
->interfaceTag
,status
);
2096 unifi_trace(priv
, UDBG2
, "leaving CsrWifiRouterCtrlPeerDelReqHandler \n");
2099 /* Add the new station to the station record data base */
2100 static int peer_add_new_record(unifi_priv_t
*priv
,CsrWifiRouterCtrlPeerAddReq
*req
,u32
*handle
)
2102 u8 i
, powerModeTemp
= 0;
2103 u8 freeSlotFound
= FALSE
;
2104 CsrWifiRouterCtrlStaInfo_t
*newRecord
= NULL
;
2105 netInterface_priv_t
*interfacePriv
= priv
->interfacePriv
[req
->interfaceTag
];
2106 u32 currentTime
, currentTimeHi
;
2107 unsigned long lock_flags
;
2109 if (req
->interfaceTag
>= CSR_WIFI_NUM_INTERFACES
) {
2110 unifi_error(priv
, "peer_add_new_record: bad interfaceTag\n");
2111 return CSR_RESULT_FAILURE
;
2114 currentTime
= CsrTimeGet(¤tTimeHi
);
2116 for(i
= 0; i
< UNIFI_MAX_CONNECTIONS
; i
++) {
2117 if(interfacePriv
->staInfo
[i
] == NULL
) {
2118 /* Slot is empty, so can be used for station record */
2119 freeSlotFound
= TRUE
;
2122 /* Allocate for the new station record , to avoid race condition would happen between ADD_PEER &
2123 * DEL_PEER the allocation made atomic memory rather than kernel memory
2125 newRecord
= kmalloc(sizeof(CsrWifiRouterCtrlStaInfo_t
), GFP_ATOMIC
);
2127 unifi_error(priv
, "failed to allocate the %d bytes of mem for station record\n",
2128 sizeof(CsrWifiRouterCtrlStaInfo_t
));
2129 return CSR_RESULT_FAILURE
;
2132 unifi_trace(priv
, UDBG1
, "peer_add_new_record: handle = %d AID = %d addr = %x:%x:%x:%x:%x:%x LI=%u\n",
2133 *handle
, req
->associationId
, req
->peerMacAddress
.a
[0], req
->peerMacAddress
.a
[1], req
->peerMacAddress
.a
[2],
2134 req
->peerMacAddress
.a
[3], req
->peerMacAddress
.a
[4], req
->peerMacAddress
.a
[5],
2135 req
->staInfo
.listenIntervalInTus
);
2137 /* disable the preemption until station record updated */
2138 spin_lock_irqsave(&priv
->staRecord_lock
,lock_flags
);
2140 interfacePriv
->staInfo
[i
] = newRecord
;
2141 /* Initialize the record*/
2142 memset(newRecord
,0,sizeof(CsrWifiRouterCtrlStaInfo_t
));
2143 /* update the station record */
2144 memcpy(newRecord
->peerMacAddress
.a
, req
->peerMacAddress
.a
, ETH_ALEN
);
2145 newRecord
->wmmOrQosEnabled
= req
->staInfo
.wmmOrQosEnabled
;
2147 /* maxSpLength is bit map in qosInfo field, so converting accordingly */
2148 newRecord
->maxSpLength
= req
->staInfo
.maxSpLength
* 2;
2150 /*Max SP 0 mean any number of packets. since we buffer only 512
2151 packets we are hard coding this to zero for the moment */
2153 if(newRecord
->maxSpLength
== 0)
2154 newRecord
->maxSpLength
=512;
2156 newRecord
->assignedHandle
= i
;
2158 /* copy power save mode of all access catagory (Trigger/Delivery/both enabled/disabled) */
2159 powerModeTemp
= (u8
) ((req
->staInfo
.powersaveMode
>> 4) & 0xff);
2161 if(!(req
->staInfo
.powersaveMode
& 0x0001))
2162 newRecord
->powersaveMode
[UNIFI_TRAFFIC_Q_BK
]= CSR_WIFI_AC_LEGACY_POWER_SAVE
;
2164 newRecord
->powersaveMode
[UNIFI_TRAFFIC_Q_BK
]= powerModeTemp
& 0x03;
2166 if(!(req
->staInfo
.powersaveMode
& 0x0002))
2167 newRecord
->powersaveMode
[UNIFI_TRAFFIC_Q_BE
]= CSR_WIFI_AC_LEGACY_POWER_SAVE
;
2169 newRecord
->powersaveMode
[UNIFI_TRAFFIC_Q_BE
]= ((powerModeTemp
& 0x0C)>> 2);
2171 if(!(req
->staInfo
.powersaveMode
& 0x0004))
2172 newRecord
->powersaveMode
[UNIFI_TRAFFIC_Q_VI
]= CSR_WIFI_AC_LEGACY_POWER_SAVE
;
2174 newRecord
->powersaveMode
[UNIFI_TRAFFIC_Q_VI
]= ((powerModeTemp
& 0x30)>> 4);
2176 if(!(req
->staInfo
.powersaveMode
& 0x0008))
2177 newRecord
->powersaveMode
[UNIFI_TRAFFIC_Q_VO
]= CSR_WIFI_AC_LEGACY_POWER_SAVE
;
2179 newRecord
->powersaveMode
[UNIFI_TRAFFIC_Q_VO
]= ((powerModeTemp
& 0xC0)>> 6);
2183 for(k
=0; k
< MAX_ACCESS_CATOGORY
;k
++)
2184 unifi_trace(priv
, UDBG2
, "peer_add_new_record: WMM : %d ,AC %d, powersaveMode %x \n",
2185 req
->staInfo
.wmmOrQosEnabled
,k
,newRecord
->powersaveMode
[k
]);
2188 unifi_trace(priv
, UDBG3
, "newRecord->wmmOrQosEnabled : %d , MAX SP : %d\n",
2189 newRecord
->wmmOrQosEnabled
,newRecord
->maxSpLength
);
2191 /* Initialize the mgtFrames & data Pdu list */
2194 INIT_LIST_HEAD(&newRecord
->mgtFrames
);
2195 for(j
= 0; j
< MAX_ACCESS_CATOGORY
; j
++) {
2196 INIT_LIST_HEAD(&newRecord
->dataPdu
[j
]);
2200 newRecord
->lastActivity
= currentTime
;
2201 newRecord
->activity_flag
= TRUE
;
2203 /* enable the preemption as station record updated */
2204 spin_unlock_irqrestore(&priv
->staRecord_lock
,lock_flags
);
2206 /* First time port actions are set for the peer with below information */
2207 configure_data_port(priv
, CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN
, &newRecord
->peerMacAddress
,
2208 UF_UNCONTROLLED_PORT_Q
, req
->interfaceTag
);
2210 if (interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_IBSS
) {
2211 configure_data_port(priv
, CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN
, &newRecord
->peerMacAddress
,
2212 UF_CONTROLLED_PORT_Q
, req
->interfaceTag
);
2214 configure_data_port(priv
, CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD
, &newRecord
->peerMacAddress
,
2215 UF_CONTROLLED_PORT_Q
, req
->interfaceTag
);
2219 spin_lock_irqsave(&priv
->staRecord_lock
,lock_flags
);
2220 /* Port status must be already set before calling the Add Peer request */
2221 newRecord
->peerControlledPort
= uf_sme_port_config_handle(priv
, newRecord
->peerMacAddress
.a
,
2222 UF_CONTROLLED_PORT_Q
, req
->interfaceTag
);
2223 newRecord
->peerUnControlledPort
= uf_sme_port_config_handle(priv
, newRecord
->peerMacAddress
.a
,
2224 UF_UNCONTROLLED_PORT_Q
, req
->interfaceTag
);
2226 if (!newRecord
->peerControlledPort
|| !newRecord
->peerUnControlledPort
) {
2227 /* enable the preemption as station record failed to update */
2228 unifi_warning(priv
, "Un/ControlledPort record not found in port configuration array index = %d\n", i
);
2229 kfree(interfacePriv
->staInfo
[i
]);
2230 interfacePriv
->staInfo
[i
] = NULL
;
2231 spin_unlock_irqrestore(&priv
->staRecord_lock
,lock_flags
);
2232 return CSR_RESULT_FAILURE
;
2235 newRecord
->currentPeerState
= CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE
;
2237 /* changes done during block ack handling */
2238 newRecord
->txSuspend
= FALSE
;
2240 /*U-APSD related data structure*/
2241 newRecord
->timRequestPendingFlag
= FALSE
;
2243 /* Initialise the variable updateTimReqQueued with a value
2244 * other then CSR_WIFI_TIM_SET or CSR_WIFI_TIM_RESET value
2246 newRecord
->updateTimReqQueued
= 0xFF;
2247 newRecord
->timSet
= CSR_WIFI_TIM_RESET
;
2248 newRecord
->uapsdActive
= FALSE
;
2249 newRecord
->noOfSpFramesSent
=0;
2250 newRecord
->triggerFramePriority
= CSR_QOS_UP0
;
2252 /* The protection bit is updated once the port opens for corresponding peer in
2253 * routerPortConfigure request */
2255 /* update the association ID */
2256 newRecord
->aid
= req
->associationId
;
2258 #ifdef CSR_SUPPORT_SME
2259 interfacePriv
->num_stations_joined
++;
2260 newRecord
->interfacePriv
= interfacePriv
;
2261 newRecord
->listenIntervalInTus
= req
->staInfo
.listenIntervalInTus
;
2262 newRecord
->nullDataHostTag
= INVALID_HOST_TAG
;
2264 INIT_WORK(&newRecord
->send_disconnected_ind_task
, uf_send_disconnected_ind_wq
);
2266 if(!(interfacePriv
->sta_activity_check_enabled
) &&
2267 (interfacePriv
->num_stations_joined
>= STA_INACTIVE_DETECTION_TRIGGER_THRESHOLD
)){
2268 unifi_trace(priv
, UDBG1
,
2269 "peer_add_new_record: STARTING the Inactivity Timer (num of stations = %d)",
2270 interfacePriv
->num_stations_joined
);
2272 interfacePriv
->sta_activity_check_enabled
= TRUE
;
2273 interfacePriv
->sta_activity_check_timer
.function
= check_inactivity_timer_expire_func
;
2274 interfacePriv
->sta_activity_check_timer
.data
= (unsigned long)interfacePriv
;
2276 init_timer(&interfacePriv
->sta_activity_check_timer
);
2277 mod_timer(&interfacePriv
->sta_activity_check_timer
,
2278 (jiffies
+ usecs_to_jiffies(STA_INACTIVE_DETECTION_TIMER_INTERVAL
* 1000 * 1000)));
2282 spin_unlock_irqrestore(&priv
->staRecord_lock
,lock_flags
);
2287 if(!freeSlotFound
) {
2288 unifi_error(priv
, "Limited connectivity, Free slot not found for station record addition\n");
2289 return CSR_RESULT_FAILURE
;
2291 return CSR_RESULT_SUCCESS
;
2294 #ifdef CSR_SUPPORT_SME
2295 static void check_inactivity_timer_expire_func(unsigned long data
)
2297 struct unifi_priv
*priv
;
2298 CsrWifiRouterCtrlStaInfo_t
*sta_record
= NULL
;
2302 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*) data
;
2309 priv
= interfacePriv
->privPtr
;
2311 if (interfacePriv
->InterfaceTag
>= CSR_WIFI_NUM_INTERFACES
)
2313 unifi_error(priv
, "check_inactivity_timer_expire_func: Invalid interfaceTag\n");
2317 /* RUN Algorithm to check inactivity for each connected station */
2318 now
= CsrTimeGet(NULL
);
2320 for(i
= 0; i
< UNIFI_MAX_CONNECTIONS
; i
++) {
2321 if(interfacePriv
->staInfo
[i
] != NULL
) {
2322 sta_record
= interfacePriv
->staInfo
[i
];
2324 if (sta_record
->activity_flag
== TRUE
){
2325 sta_record
->activity_flag
= FALSE
;
2326 sta_record
->lastActivity
= now
;
2330 if (sta_record
->lastActivity
> now
)
2332 /* simple timer wrap (for 1 wrap) */
2333 inactive_time
= CsrTimeAdd((u32
)CsrTimeSub(CSR_SCHED_TIME_MAX
, sta_record
->lastActivity
), now
);
2337 inactive_time
= (u32
)CsrTimeSub(now
, sta_record
->lastActivity
);
2340 if (inactive_time
>= STA_INACTIVE_TIMEOUT_VAL
)
2342 unifi_trace(priv
, UDBG1
, "STA is Inactive - AID = %d inactive_time = %d\n",
2346 /* station is in-active, if it is in active mode send a null frame
2347 * and the station should acknowledge the null frame, if acknowledgement
2348 * is not received throw out the station.
2349 * If the station is in Power Save, update TIM for the station so
2350 * that it wakes up and register some activity through PS-Poll or
2353 if (sta_record
->currentPeerState
== CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE
)
2355 unifi_trace(priv
, UDBG1
, "STA power save state - Active, send a NULL frame to check if it is ALIVE\n");
2356 uf_send_nulldata ( priv
,
2357 sta_record
->interfacePriv
->InterfaceTag
,
2358 sta_record
->peerMacAddress
.a
,
2362 else if (sta_record
->currentPeerState
== CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE
)
2364 if((sta_record
->timSet
== CSR_WIFI_TIM_SET
) ||
2365 (sta_record
->timSet
== CSR_WIFI_TIM_SETTING
))
2367 unifi_trace(priv
, UDBG1
, "STA power save state - PS, TIM is already SET\n");
2369 /* If TIM is set and we do not have any activity for
2370 * more than 3 listen intervals then send a disconnected
2371 * indication to SME, to delete the station from station
2373 * The inactivity is already more than STA_INACTIVE_TIMEOUT_VAL
2374 * and this check ensures if the listen interval is a larger
2375 * value than STA_INACTIVE_TIMEOUT_VAL.
2377 if (inactive_time
> (3 * (sta_record
->listenIntervalInTus
* 1024)))
2379 unifi_trace(priv
, UDBG1
, "STA is inactive for more than 3 listen intervals\n");
2380 queue_work( priv
->unifi_workqueue
,
2381 &sta_record
->send_disconnected_ind_task
);
2387 unifi_trace(priv
, UDBG1
, "STA power save state - PS, update TIM to see if it is ALIVE\n");
2391 interfacePriv
->InterfaceTag
,
2392 sta_record
->assignedHandle
);
2399 /* re-run the timer interrupt */
2400 mod_timer(&interfacePriv
->sta_activity_check_timer
,
2401 (jiffies
+ usecs_to_jiffies(STA_INACTIVE_DETECTION_TIMER_INTERVAL
* 1000 * 1000)));
2406 void uf_send_disconnected_ind_wq(struct work_struct
*work
)
2409 CsrWifiRouterCtrlStaInfo_t
*staInfo
= container_of(work
, CsrWifiRouterCtrlStaInfo_t
, send_disconnected_ind_task
);
2412 struct list_head send_cfm_list
;
2419 if(!staInfo
->interfacePriv
) {
2423 priv
= staInfo
->interfacePriv
->privPtr
;
2424 interfaceTag
= staInfo
->interfacePriv
->InterfaceTag
;
2426 if (interfaceTag
>= CSR_WIFI_NUM_INTERFACES
) {
2427 unifi_error(priv
, "uf_send_disconnected_ind_wq: invalid interfaceTag\n");
2431 /* The SME/NME may be waiting for confirmation for requested frames to this station.
2432 * So loop through buffered frames for this station and if confirmation is
2433 * requested, send auto confirmation with failure status. Also flush the frames so
2434 * that these are not processed again in PEER_DEL_REQ handler.
2436 INIT_LIST_HEAD(&send_cfm_list
);
2438 uf_prepare_send_cfm_list_for_queued_pkts(priv
,
2440 &(staInfo
->mgtFrames
));
2442 uf_flush_list(priv
, &(staInfo
->mgtFrames
));
2444 for(j
= 0; j
< MAX_ACCESS_CATOGORY
; j
++){
2445 uf_prepare_send_cfm_list_for_queued_pkts(priv
,
2447 &(staInfo
->dataPdu
[j
]));
2449 uf_flush_list(priv
,&(staInfo
->dataPdu
[j
]));
2452 send_auto_ma_packet_confirm(priv
, staInfo
->interfacePriv
, &send_cfm_list
);
2454 unifi_warning(priv
, "uf_send_disconnected_ind_wq: Router Disconnected IND Peer (%x-%x-%x-%x-%x-%x)\n",
2455 staInfo
->peerMacAddress
.a
[0],
2456 staInfo
->peerMacAddress
.a
[1],
2457 staInfo
->peerMacAddress
.a
[2],
2458 staInfo
->peerMacAddress
.a
[3],
2459 staInfo
->peerMacAddress
.a
[4],
2460 staInfo
->peerMacAddress
.a
[5]);
2462 CsrWifiRouterCtrlConnectedIndSend(priv
->CSR_WIFI_SME_IFACEQUEUE
,
2464 staInfo
->interfacePriv
->InterfaceTag
,
2465 staInfo
->peerMacAddress
,
2466 CSR_WIFI_ROUTER_CTRL_PEER_DISCONNECTED
);
2474 void CsrWifiRouterCtrlPeerAddReqHandler(void* drvpriv
,CsrWifiFsmEvent
* msg
)
2476 CsrWifiRouterCtrlPeerAddReq
* req
= (CsrWifiRouterCtrlPeerAddReq
*)msg
;
2477 CsrResult status
= CSR_RESULT_SUCCESS
;
2478 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
2480 netInterface_priv_t
*interfacePriv
;
2482 unifi_trace(priv
, UDBG2
, "entering CsrWifiRouterCtrlPeerAddReqHandler \n");
2485 unifi_error(priv
, "CsrWifiRouterCtrlPeerAddReqHandler: invalid smepriv\n");
2489 if (req
->interfaceTag
>= CSR_WIFI_NUM_INTERFACES
)
2491 unifi_error(priv
, "CsrWifiRouterCtrlPeerAddReqHandler: bad interfaceTag\n");
2495 interfacePriv
= priv
->interfacePriv
[req
->interfaceTag
];
2497 switch(interfacePriv
->interfaceMode
)
2499 case CSR_WIFI_ROUTER_CTRL_MODE_AP
:
2500 case CSR_WIFI_ROUTER_CTRL_MODE_IBSS
:
2501 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
:
2502 /* Add station record */
2503 status
= peer_add_new_record(priv
,req
,&handle
);
2505 case CSR_WIFI_ROUTER_CTRL_MODE_STA
:
2506 case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI
:
2508 /* No station record to maintain in these modes */
2512 CsrWifiRouterCtrlPeerAddCfmSend(msg
->source
,req
->clientData
,req
->interfaceTag
,req
->peerMacAddress
,handle
,status
);
2513 unifi_trace(priv
, UDBG2
, "leaving CsrWifiRouterCtrlPeerAddReqHandler \n");
2516 void CsrWifiRouterCtrlPeerUpdateReqHandler(void* drvpriv
,CsrWifiFsmEvent
* msg
)
2518 CsrWifiRouterCtrlPeerUpdateReq
* req
= (CsrWifiRouterCtrlPeerUpdateReq
*)msg
;
2519 CsrResult status
= CSR_RESULT_SUCCESS
;
2520 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
2522 unifi_trace(priv
, UDBG2
, "entering CsrWifiRouterCtrlPeerUpdateReqHandler \n");
2525 unifi_error(priv
, "CsrWifiRouterCtrlPeerUpdateReqHandler: invalid smepriv\n");
2529 CsrWifiRouterCtrlPeerUpdateCfmSend(msg
->source
,req
->clientData
,req
->interfaceTag
,status
);
2530 unifi_trace(priv
, UDBG2
, "leaving CsrWifiRouterCtrlPeerUpdateReqHandler \n");
2534 void CsrWifiRouterCtrlRawSdioDeinitialiseReqHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
2536 /* This will never be called as it is intercepted in the Userspace */
2539 void CsrWifiRouterCtrlRawSdioInitialiseReqHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
2541 /* This will never be called as it is intercepted in the Userspace */
2545 uf_send_ba_err_wq(struct work_struct
*work
)
2547 ba_session_rx_struct
*ba_session
= container_of(work
, ba_session_rx_struct
, send_ba_err_task
);
2554 if(!ba_session
->interfacePriv
) {
2558 priv
= ba_session
->interfacePriv
->privPtr
;
2560 if (ba_session
->interfacePriv
->InterfaceTag
>= CSR_WIFI_NUM_INTERFACES
) {
2561 unifi_error(priv
, "%s: invalid interfaceTag\n", __FUNCTION__
);
2565 unifi_warning(priv
, "%s: Calling CsrWifiRouterCtrlBlockAckErrorIndSend(%d, %d, %d, %d, %x:%x:%x:%x:%x:%x, %d)\n",
2567 priv
->CSR_WIFI_SME_IFACEQUEUE
,
2569 ba_session
->interfacePriv
->InterfaceTag
,
2571 ba_session
->macAddress
.a
[0],
2572 ba_session
->macAddress
.a
[1],
2573 ba_session
->macAddress
.a
[2],
2574 ba_session
->macAddress
.a
[3],
2575 ba_session
->macAddress
.a
[4],
2576 ba_session
->macAddress
.a
[5],
2579 CsrWifiRouterCtrlBlockAckErrorIndSend(priv
->CSR_WIFI_SME_IFACEQUEUE
,
2581 ba_session
->interfacePriv
->InterfaceTag
,
2583 ba_session
->macAddress
,
2584 CSR_RESULT_SUCCESS
);
2588 static void ba_session_terminate_timer_func(unsigned long data
)
2590 ba_session_rx_struct
*ba_session
= (ba_session_rx_struct
*)data
;
2591 struct unifi_priv
*priv
;
2597 if(!ba_session
->interfacePriv
) {
2601 priv
= ba_session
->interfacePriv
->privPtr
;
2603 if (ba_session
->interfacePriv
->InterfaceTag
>= CSR_WIFI_NUM_INTERFACES
) {
2604 unifi_error(priv
, "%s: invalid interfaceTag\n", __FUNCTION__
);
2608 queue_work(priv
->unifi_workqueue
, &ba_session
->send_ba_err_task
);
2612 u8
blockack_session_stop(unifi_priv_t
*priv
,
2614 CsrWifiRouterCtrlBlockAckRole role
,
2616 CsrWifiMacAddress macAddress
)
2618 netInterface_priv_t
*interfacePriv
;
2619 ba_session_rx_struct
*ba_session_rx
= NULL
;
2620 ba_session_tx_struct
*ba_session_tx
= NULL
;
2621 u8 ba_session_idx
= 0;
2624 if (interfaceTag
>= CSR_WIFI_NUM_INTERFACES
) {
2625 unifi_error(priv
, "%s: bad interfaceTag = %d\n", __FUNCTION__
, interfaceTag
);
2629 interfacePriv
= priv
->interfacePriv
[interfaceTag
];
2631 if(!interfacePriv
) {
2632 unifi_error(priv
, "%s: bad interfacePriv\n", __FUNCTION__
);
2637 unifi_error(priv
, "%s: bad tID = %d\n", __FUNCTION__
, tID
);
2641 if((role
!= CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR
) &&
2642 (role
!= CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT
)) {
2643 unifi_error(priv
, "%s: bad role = %d\n", __FUNCTION__
, role
);
2648 "%s: stopping ba_session for peer = %pM role = %d tID = %d\n",
2649 __func__
, macAddress
.a
, role
, tID
);
2651 /* find out the appropriate ba session (/station /tid /role) for which stop is requested */
2652 if (role
== CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT
){
2653 for (ba_session_idx
=0; ba_session_idx
< MAX_SUPPORTED_BA_SESSIONS_RX
; ba_session_idx
++){
2655 ba_session_rx
= interfacePriv
->ba_session_rx
[ba_session_idx
];
2658 if ((!memcmp(ba_session_rx
->macAddress
.a
, macAddress
.a
, ETH_ALEN
)) && (ba_session_rx
->tID
== tID
)){
2664 if (!ba_session_rx
|| (ba_session_idx
== MAX_SUPPORTED_BA_SESSIONS_RX
)) {
2665 unifi_error(priv
, "%s: bad ba_session for Rx [tID=%d]\n", __FUNCTION__
, tID
);
2670 if(ba_session_rx
->timeout
) {
2671 del_timer_sync(&ba_session_rx
->timer
);
2673 cancel_work_sync(&ba_session_rx
->send_ba_err_task
);
2674 for (i
= 0; i
< ba_session_rx
->wind_size
; i
++) {
2675 if(ba_session_rx
->buffer
[i
].active
) {
2676 frame_desc_struct
*frame_desc
= &ba_session_rx
->buffer
[i
];
2677 unifi_net_data_free(priv
, &frame_desc
->bulkdata
.d
[0]);
2680 kfree(ba_session_rx
->buffer
);
2682 interfacePriv
->ba_session_rx
[ba_session_idx
] = NULL
;
2683 kfree(ba_session_rx
);
2684 }else if (role
== CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR
){
2685 for (ba_session_idx
=0; ba_session_idx
< MAX_SUPPORTED_BA_SESSIONS_TX
; ba_session_idx
++){
2686 ba_session_tx
= interfacePriv
->ba_session_tx
[ba_session_idx
];
2688 if ((!memcmp(ba_session_tx
->macAddress
.a
, macAddress
.a
, ETH_ALEN
)) && (ba_session_tx
->tID
== tID
)){
2694 if (!ba_session_tx
|| (ba_session_idx
== MAX_SUPPORTED_BA_SESSIONS_TX
)) {
2695 unifi_error(priv
, "%s: bad ba_session for Tx [tID=%d]\n", __FUNCTION__
, tID
);
2698 interfacePriv
->ba_session_tx
[ba_session_idx
] = NULL
;
2699 kfree(ba_session_tx
);
2707 void CsrWifiRouterCtrlBlockAckDisableReqHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
2709 CsrWifiRouterCtrlBlockAckDisableReq
* req
= (CsrWifiRouterCtrlBlockAckDisableReq
*)msg
;
2711 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
2713 unifi_trace(priv
, UDBG6
, "%s: in ok\n", __FUNCTION__
);
2715 down(&priv
->ba_mutex
);
2716 r
= blockack_session_stop(priv
,
2719 req
->trafficStreamID
,
2721 up(&priv
->ba_mutex
);
2723 CsrWifiRouterCtrlBlockAckDisableCfmSend(msg
->source
,
2726 r
?CSR_RESULT_SUCCESS
:CSR_RESULT_FAILURE
);
2728 unifi_trace(priv
, UDBG6
, "%s: out ok\n", __FUNCTION__
);
2732 u8
blockack_session_start(unifi_priv_t
*priv
,
2736 CsrWifiRouterCtrlBlockAckRole role
,
2739 CsrWifiMacAddress macAddress
2742 netInterface_priv_t
*interfacePriv
;
2743 ba_session_rx_struct
*ba_session_rx
= NULL
;
2744 ba_session_tx_struct
*ba_session_tx
= NULL
;
2745 u8 ba_session_idx
= 0;
2748 if (interfaceTag
>= CSR_WIFI_NUM_INTERFACES
) {
2749 unifi_error(priv
, "%s: bad interfaceTag = %d\n", __FUNCTION__
, interfaceTag
);
2753 interfacePriv
= priv
->interfacePriv
[interfaceTag
];
2755 if(!interfacePriv
) {
2756 unifi_error(priv
, "%s: bad interfacePriv\n", __FUNCTION__
);
2762 unifi_error(priv
, "%s: bad tID=%d\n", __FUNCTION__
, tID
);
2766 if(wind_size
> MAX_BA_WIND_SIZE
) {
2767 unifi_error(priv
, "%s: bad wind_size = %d\n", __FUNCTION__
, wind_size
);
2771 if(role
!= CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR
&&
2772 role
!= CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT
) {
2773 unifi_error(priv
, "%s: bad role = %d\n", __FUNCTION__
, role
);
2778 "%s: ba session with peer= (%pM)\n", __func__
,
2781 unifi_warning(priv
, "%s: ba session for tID=%d timeout=%d role=%d wind_size=%d start_sn=%d\n", __FUNCTION__
,
2788 /* Check if BA session exists for per station, per TID, per role or not.
2789 if BA session exists update parameters and if it does not exist
2790 create a new BA session */
2791 if (role
== CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR
){
2792 for (ba_session_idx
=0; ba_session_idx
< MAX_SUPPORTED_BA_SESSIONS_TX
; ba_session_idx
++){
2793 ba_session_tx
= interfacePriv
->ba_session_tx
[ba_session_idx
];
2794 if (ba_session_tx
) {
2795 if ((!memcmp(ba_session_tx
->macAddress
.a
, macAddress
.a
, ETH_ALEN
)) && (ba_session_tx
->tID
== tID
)){
2796 unifi_warning(priv
, "%s: ba_session for Tx already exists\n", __FUNCTION__
);
2802 /* we have to create new ba_session_tx struct */
2803 ba_session_tx
= NULL
;
2805 /* loop through until an empty BA session slot is there and save the session there */
2806 for (ba_session_idx
=0; ba_session_idx
< MAX_SUPPORTED_BA_SESSIONS_TX
; ba_session_idx
++){
2807 if (!(interfacePriv
->ba_session_tx
[ba_session_idx
])){
2811 if (ba_session_idx
== MAX_SUPPORTED_BA_SESSIONS_TX
){
2812 unifi_error(priv
, "%s: All ba_session used for Tx, NO free session available\n", __FUNCTION__
);
2816 /* create and populate the new BA session structure */
2817 ba_session_tx
= kzalloc(sizeof(ba_session_tx_struct
), GFP_KERNEL
);
2818 if (!ba_session_tx
) {
2819 unifi_error(priv
, "%s: kmalloc failed for ba_session_tx\n", __FUNCTION__
);
2823 ba_session_tx
->interfacePriv
= interfacePriv
;
2824 ba_session_tx
->tID
= tID
;
2825 ba_session_tx
->macAddress
= macAddress
;
2827 interfacePriv
->ba_session_tx
[ba_session_idx
] = ba_session_tx
;
2829 } else if (role
== CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT
){
2831 for (ba_session_idx
=0; ba_session_idx
< MAX_SUPPORTED_BA_SESSIONS_RX
; ba_session_idx
++){
2832 ba_session_rx
= interfacePriv
->ba_session_rx
[ba_session_idx
];
2833 if (ba_session_rx
) {
2834 if ((!memcmp(ba_session_rx
->macAddress
.a
, macAddress
.a
, ETH_ALEN
)) && (ba_session_rx
->tID
== tID
)){
2835 unifi_warning(priv
, "%s: ba_session for Rx[tID = %d] already exists\n", __FUNCTION__
, tID
);
2837 if(ba_session_rx
->wind_size
== wind_size
&&
2838 ba_session_rx
->timeout
== timeout
&&
2839 ba_session_rx
->expected_sn
== start_sn
) {
2843 if(ba_session_rx
->timeout
) {
2844 del_timer_sync(&ba_session_rx
->timer
);
2845 ba_session_rx
->timeout
= 0;
2848 if(ba_session_rx
->wind_size
!= wind_size
) {
2849 blockack_session_stop(priv
, interfaceTag
, role
, tID
, macAddress
);
2852 ba_session_rx
->timeout
= timeout
;
2853 ba_session_rx
->timer
.function
= ba_session_terminate_timer_func
;
2854 ba_session_rx
->timer
.data
= (unsigned long)ba_session_rx
;
2855 init_timer(&ba_session_rx
->timer
);
2856 mod_timer(&ba_session_rx
->timer
, (jiffies
+ usecs_to_jiffies((ba_session_rx
->timeout
) * 1024)));
2859 * The starting sequence number shall remain same if the BA
2860 * enable request is issued to update BA parameters only. If
2861 * it is not same, then we scroll our window to the new starting
2862 * sequence number. This could happen if the DELBA frame from
2863 * originator is lost and then we receive ADDBA frame with new SSN.
2865 if(ba_session_rx
->start_sn
!= start_sn
) {
2866 scroll_ba_window(priv
, interfacePriv
, ba_session_rx
, start_sn
);
2874 /* we could have a valid BA session pointer here or un-initialized
2875 ba session pointer. but in any case we have to create a new session.
2876 so re-initialize the ba_session pointer */
2877 ba_session_rx
= NULL
;
2879 /* loop through until an empty BA session slot is there and save the session there */
2880 for (ba_session_idx
=0; ba_session_idx
< MAX_SUPPORTED_BA_SESSIONS_RX
; ba_session_idx
++){
2881 if (!(interfacePriv
->ba_session_rx
[ba_session_idx
])){
2885 if (ba_session_idx
== MAX_SUPPORTED_BA_SESSIONS_RX
){
2886 unifi_error(priv
, "%s: All ba_session used for Rx, NO free session available\n", __FUNCTION__
);
2890 /* It is observed that with some devices there is a race between
2891 * EAPOL exchanges and BA session establishment. This results in
2892 * some EAPOL authentication packets getting stuck in BA reorder
2893 * buffer and hence the conection cannot be established. To avoid
2894 * this we check here if the EAPOL authentication is complete and
2895 * if so then only allow the BA session to establish.
2897 * It is verified that the peers normally re-establish
2898 * the BA session after the initial rejection.
2900 if (CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN
!= uf_sme_port_state(priv
, macAddress
.a
, UF_CONTROLLED_PORT_Q
, interfacePriv
->InterfaceTag
))
2902 unifi_warning(priv
, "blockack_session_start: Controlled port not opened, Reject BA request\n");
2906 ba_session_rx
= kzalloc(sizeof(ba_session_rx_struct
), GFP_KERNEL
);
2907 if (!ba_session_rx
) {
2908 unifi_error(priv
, "%s: kmalloc failed for ba_session_rx\n", __FUNCTION__
);
2912 ba_session_rx
->wind_size
= wind_size
;
2913 ba_session_rx
->start_sn
= ba_session_rx
->expected_sn
= start_sn
;
2914 ba_session_rx
->trigger_ba_after_ssn
= FALSE
;
2916 ba_session_rx
->buffer
= kzalloc(ba_session_rx
->wind_size
*sizeof(frame_desc_struct
), GFP_KERNEL
);
2917 if (!ba_session_rx
->buffer
) {
2918 kfree(ba_session_rx
);
2919 unifi_error(priv
, "%s: kmalloc failed for buffer\n", __FUNCTION__
);
2923 INIT_WORK(&ba_session_rx
->send_ba_err_task
, uf_send_ba_err_wq
);
2925 ba_session_rx
->timeout
= timeout
;
2926 ba_session_rx
->timer
.function
= ba_session_terminate_timer_func
;
2927 ba_session_rx
->timer
.data
= (unsigned long)ba_session_rx
;
2928 init_timer(&ba_session_rx
->timer
);
2929 mod_timer(&ba_session_rx
->timer
, (jiffies
+ usecs_to_jiffies((ba_session_rx
->timeout
) * 1024)));
2932 ba_session_rx
->interfacePriv
= interfacePriv
;
2933 ba_session_rx
->tID
= tID
;
2934 ba_session_rx
->macAddress
= macAddress
;
2936 interfacePriv
->ba_session_rx
[ba_session_idx
] = ba_session_rx
;
2941 void CsrWifiRouterCtrlBlockAckEnableReqHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
2943 CsrWifiRouterCtrlBlockAckEnableReq
* req
= (CsrWifiRouterCtrlBlockAckEnableReq
*)msg
;
2945 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
2947 unifi_trace(priv
, UDBG6
, ">>%s\n", __FUNCTION__
);
2948 down(&priv
->ba_mutex
);
2949 r
= blockack_session_start(priv
,
2951 req
->trafficStreamID
,
2958 up(&priv
->ba_mutex
);
2960 CsrWifiRouterCtrlBlockAckEnableCfmSend(msg
->source
,
2963 r
?CSR_RESULT_SUCCESS
:CSR_RESULT_FAILURE
);
2964 unifi_trace(priv
, UDBG6
, "<<%s: r=%d\n", __FUNCTION__
, r
);
2968 void CsrWifiRouterCtrlWapiMulticastFilterReqHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
2970 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
2972 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
2973 CsrWifiRouterCtrlWapiMulticastFilterReq
* req
= (CsrWifiRouterCtrlWapiMulticastFilterReq
*)msg
;
2974 netInterface_priv_t
*interfacePriv
= priv
->interfacePriv
[req
->interfaceTag
];
2976 if (CSR_WIFI_ROUTER_CTRL_MODE_STA
== interfacePriv
->interfaceMode
) {
2978 unifi_trace(priv
, UDBG6
, ">>%s\n", __FUNCTION__
);
2980 unifi_trace(priv
, UDBG1
, "CsrWifiRouterCtrlWapiMulticastFilterReq: req->status = %d\n", req
->status
);
2982 /* status 1 - Filter on
2983 * status 0 - Filter off */
2984 priv
->wapi_multicast_filter
= req
->status
;
2986 unifi_trace(priv
, UDBG6
, "<<%s\n", __FUNCTION__
);
2989 unifi_warning(priv
, "%s is NOT applicable for interface mode - %d\n", __FUNCTION__
,interfacePriv
->interfaceMode
);
2992 #elif defined(UNIFI_DEBUG)
2994 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
2995 unifi_error(priv
,"CsrWifiRouterCtrlWapiMulticastFilterReqHandler: called when WAPI isn't enabled\n");
2999 void CsrWifiRouterCtrlWapiUnicastFilterReqHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
3001 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
3003 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
3004 CsrWifiRouterCtrlWapiUnicastFilterReq
* req
= (CsrWifiRouterCtrlWapiUnicastFilterReq
*)msg
;
3005 netInterface_priv_t
*interfacePriv
= priv
->interfacePriv
[req
->interfaceTag
];
3007 if (CSR_WIFI_ROUTER_CTRL_MODE_STA
== interfacePriv
->interfaceMode
) {
3009 unifi_trace(priv
, UDBG6
, ">>%s\n", __FUNCTION__
);
3011 unifi_trace(priv
, UDBG1
, "CsrWifiRouterCtrlWapiUnicastFilterReq: req->status= %d\n", req
->status
);
3013 if ((priv
->wapi_unicast_filter
== 1) && (req
->status
== 0)) {
3014 /* When we have successfully re-associated and obtained a new unicast key with keyid = 0 */
3015 priv
->wapi_unicast_queued_pkt_filter
= 1;
3018 /* status 1 - Filter ON
3019 * status 0 - Filter OFF */
3020 priv
->wapi_unicast_filter
= req
->status
;
3022 unifi_trace(priv
, UDBG6
, "<<%s\n", __FUNCTION__
);
3025 unifi_warning(priv
, "%s is NOT applicable for interface mode - %d\n", __FUNCTION__
,interfacePriv
->interfaceMode
);
3028 #elif defined(UNIFI_DEBUG)
3030 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
3031 unifi_error(priv
,"CsrWifiRouterCtrlWapiUnicastFilterReqHandler: called when WAPI isn't enabled\n");
3035 void CsrWifiRouterCtrlWapiRxPktReqHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
3037 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
3039 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
3040 CsrWifiRouterCtrlWapiRxPktReq
* req
= (CsrWifiRouterCtrlWapiRxPktReq
*)msg
;
3041 int client_id
, receiver_id
;
3042 bulk_data_param_t bulkdata
;
3044 ul_client_t
*client
;
3046 CSR_MA_PACKET_INDICATION
*pkt_ind
;
3047 netInterface_priv_t
*interfacePriv
;
3050 unifi_error(priv
, "CsrWifiRouterCtrlWapiRxPktReq : invalid priv\n", __func__
);
3054 if (priv
->smepriv
== NULL
) {
3055 unifi_error(priv
, "CsrWifiRouterCtrlWapiRxPktReq : invalid sme priv\n", __func__
);
3059 interfacePriv
= priv
->interfacePriv
[req
->interfaceTag
];
3061 if (CSR_WIFI_ROUTER_CTRL_MODE_STA
== interfacePriv
->interfaceMode
) {
3063 unifi_trace(priv
, UDBG6
, ">>%s\n", __FUNCTION__
);
3066 if (req
->dataLength
== 0 || req
->data
== NULL
) {
3067 unifi_error(priv
, "CsrWifiRouterCtrlWapiRxPktReq: invalid request\n",__FUNCTION__
);
3071 res
= unifi_net_data_malloc(priv
, &bulkdata
.d
[0], req
->dataLength
);
3072 if (res
!= CSR_RESULT_SUCCESS
) {
3073 unifi_error(priv
, "CsrWifiRouterCtrlWapiRxPktReq: Could not allocate net data\n",__FUNCTION__
);
3077 /* This function is expected to be called only when the MIC has been verified by SME to be correct
3078 * So reset the reception status to rx_success */
3079 res
= read_unpack_signal(req
->signal
, &signal
);
3081 unifi_error(priv
,"CsrWifiRouterCtrlWapiRxPktReqHandler: Received unknown or corrupted signal.\n");
3084 pkt_ind
= (CSR_MA_PACKET_INDICATION
*) (&((&signal
)->u
).MaPacketIndication
);
3085 if (pkt_ind
->ReceptionStatus
!= CSR_MICHAEL_MIC_ERROR
) {
3086 unifi_error(priv
,"CsrWifiRouterCtrlWapiRxPktReqHandler: Unknown signal with reception status = %d\n",pkt_ind
->ReceptionStatus
);
3089 unifi_trace(priv
, UDBG4
,"CsrWifiRouterCtrlWapiRxPktReqHandler: MIC verified , RX_SUCCESS \n",__FUNCTION__
);
3090 pkt_ind
->ReceptionStatus
= CSR_RX_SUCCESS
;
3091 write_pack(&signal
, req
->signal
, &(req
->signalLength
));
3094 memcpy((void*)bulkdata
.d
[0].os_data_ptr
, req
->data
, req
->dataLength
);
3096 receiver_id
= CSR_GET_UINT16_FROM_LITTLE_ENDIAN((req
->signal
) + sizeof(s16
)) & 0xFFF0;
3097 client_id
= (receiver_id
& 0x0F00) >> UDI_SENDER_ID_SHIFT
;
3099 client
= &priv
->ul_clients
[client_id
];
3101 if (client
&& client
->event_hook
) {
3102 unifi_trace(priv
, UDBG3
,
3103 "CsrWifiRouterCtrlWapiRxPktReq: "
3104 "Sending signal to client %d, (s:0x%X, r:0x%X) - Signal 0x%X \n",
3105 client
->client_id
, client
->sender_id
, receiver_id
,
3106 CSR_GET_UINT16_FROM_LITTLE_ENDIAN(req
->signal
));
3108 client
->event_hook(client
, req
->signal
, req
->signalLength
, &bulkdata
, UDI_TO_HOST
);
3110 unifi_trace(priv
, UDBG4
, "No client to give the packet to\n");
3111 unifi_net_data_free(priv
, &bulkdata
.d
[0]);
3114 unifi_trace(priv
, UDBG6
, "<<%s\n", __FUNCTION__
);
3116 unifi_warning(priv
, "%s is NOT applicable for interface mode - %d\n", __FUNCTION__
,interfacePriv
->interfaceMode
);
3118 #elif defined(UNIFI_DEBUG)
3120 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
3121 unifi_error(priv
,"CsrWifiRouterCtrlWapiRxPktReqHandler: called when WAPI isn't enabled\n");
3125 void CsrWifiRouterCtrlWapiUnicastTxPktReqHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
3127 #if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
3129 unifi_priv_t
*priv
= (unifi_priv_t
*) drvpriv
;
3130 CsrWifiRouterCtrlWapiUnicastTxPktReq
*req
= (CsrWifiRouterCtrlWapiUnicastTxPktReq
*) msg
;
3131 netInterface_priv_t
*interfacePriv
= priv
->interfacePriv
[req
->interfaceTag
];
3132 bulk_data_param_t bulkdata
;
3133 u8 macHeaderLengthInBytes
= MAC_HEADER_SIZE
;
3134 /*KeyID, Reserved, PN, MIC*/
3135 u8 appendedCryptoFields
= 1 + 1 + 16 + 16;
3137 /* Retrieve the MA PACKET REQ fields from the Signal retained from send_ma_pkt_request() */
3138 CSR_MA_PACKET_REQUEST
*storedSignalMAPktReq
= &interfacePriv
->wapi_unicast_ma_pkt_sig
.u
.MaPacketRequest
;
3140 if (CSR_WIFI_ROUTER_CTRL_MODE_STA
== interfacePriv
->interfaceMode
) {
3142 unifi_trace(priv
, UDBG6
, ">>%s\n", __FUNCTION__
);
3145 unifi_error(priv
, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler : invalid priv\n",__FUNCTION__
);
3148 if (priv
->smepriv
== NULL
) {
3149 unifi_error(priv
, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler : invalid sme priv\n",__FUNCTION__
);
3152 if (req
->data
== NULL
) {
3153 unifi_error(priv
, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: invalid request\n",__FUNCTION__
);
3156 /* If it is QoS data (type = data subtype = QoS), frame header contains QoS control field */
3157 if ((req
->data
[0] & 0x88) == 0x88) {
3158 macHeaderLengthInBytes
= macHeaderLengthInBytes
+ QOS_CONTROL_HEADER_SIZE
;
3161 if ( !(req
->dataLength
>(macHeaderLengthInBytes
+appendedCryptoFields
)) ) {
3162 unifi_error(priv
, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: invalid dataLength\n",__FUNCTION__
);
3166 /* Encrypted DATA Packet contained in (req->data)
3167 * -------------------------------------------------------------------
3168 * |MAC Header| KeyId | Reserved | PN | xxDataxx | xxMICxxx |
3169 * -------------------------------------------------------------------
3170 * (<-----Encrypted----->)
3171 * -------------------------------------------------------------------
3172 * |24/26(QoS)| 1 | 1 | 16 | x | 16 |
3173 * -------------------------------------------------------------------
3175 result
= unifi_net_data_malloc(priv
, &bulkdata
.d
[0], req
->dataLength
);
3176 if (result
!= CSR_RESULT_SUCCESS
) {
3177 unifi_error(priv
, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: Could not allocate net data\n",__FUNCTION__
);
3180 memcpy((void*)bulkdata
.d
[0].os_data_ptr
, req
->data
, req
->dataLength
);
3181 bulkdata
.d
[0].data_length
= req
->dataLength
;
3182 bulkdata
.d
[1].os_data_ptr
= NULL
;
3183 bulkdata
.d
[1].data_length
= 0;
3185 /* Send UniFi msg */
3186 /* Here hostTag is been sent as 0xffffffff, its been appended properly while framing MA-Packet request in pdu_processing.c file */
3187 result
= uf_process_ma_packet_req(priv
,
3188 storedSignalMAPktReq
->Ra
.x
,
3189 storedSignalMAPktReq
->HostTag
,/* Ask for a new HostTag */
3191 storedSignalMAPktReq
->TransmissionControl
,
3192 storedSignalMAPktReq
->TransmitRate
,
3193 storedSignalMAPktReq
->Priority
, /* Retained value */
3194 interfacePriv
->wapi_unicast_ma_pkt_sig
.SignalPrimitiveHeader
.SenderProcessId
, /*FIXME AP: VALIDATE ???*/
3197 if (result
== NETDEV_TX_OK
) {
3198 (priv
->netdev
[req
->interfaceTag
])->trans_start
= jiffies
;
3199 /* Should really count tx stats in the UNITDATA.status signal but
3200 * that doesn't have the length.
3202 interfacePriv
->stats
.tx_packets
++;
3204 /* count only the packet payload */
3205 interfacePriv
->stats
.tx_bytes
+= req
->dataLength
- macHeaderLengthInBytes
- appendedCryptoFields
;
3206 unifi_trace(priv
, UDBG1
, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: (Packet Sent), sent count = %x\n", interfacePriv
->stats
.tx_packets
);
3208 /* Failed to send: fh queue was full, and the skb was discarded*/
3209 unifi_trace(priv
, UDBG1
, "(HIP validation failure) Result = %d\n", result
);
3210 unifi_net_data_free(priv
, &bulkdata
.d
[0]);
3212 interfacePriv
->stats
.tx_dropped
++;
3213 unifi_trace(priv
, UDBG1
, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: (Packet Drop), dropped count = %x\n", interfacePriv
->stats
.tx_dropped
);
3216 unifi_trace(priv
, UDBG6
, "<<%s\n", __FUNCTION__
);
3220 unifi_warning(priv
, "%s is NOT applicable for interface mode - %d\n", __FUNCTION__
,interfacePriv
->interfaceMode
);
3223 #elif defined(UNIFI_DEBUG)
3225 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
3226 unifi_error(priv
,"CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: called when WAPI SW ENCRYPTION isn't enabled\n");
3230 void CsrWifiRouterCtrlWapiFilterReqHandler(void* drvpriv
, CsrWifiFsmEvent
* msg
)
3232 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
3234 #ifdef CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND
3235 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
3236 CsrWifiRouterCtrlWapiFilterReq
* req
= (CsrWifiRouterCtrlWapiFilterReq
*)msg
;
3237 netInterface_priv_t
*interfacePriv
= priv
->interfacePriv
[req
->interfaceTag
];
3239 if (CSR_WIFI_ROUTER_CTRL_MODE_STA
== interfacePriv
->interfaceMode
) {
3241 unifi_trace(priv
, UDBG6
, ">>%s\n", __FUNCTION__
);
3243 unifi_trace(priv
, UDBG1
, "CsrWifiRouterCtrlWapiFilterReq: req->isWapiConnected [0/1] = %d \n",req
->isWapiConnected
);
3245 priv
->isWapiConnection
= req
->isWapiConnected
;
3247 unifi_trace(priv
, UDBG6
, "<<%s\n", __FUNCTION__
);
3250 unifi_warning(priv
, "%s is NOT applicable for interface mode - %d\n", __FUNCTION__
,interfacePriv
->interfaceMode
);
3255 #elif defined(UNIFI_DEBUG)
3257 unifi_priv_t
*priv
= (unifi_priv_t
*)drvpriv
;
3258 unifi_error(priv
,"CsrWifiRouterCtrlWapiFilterReq: called when WAPI isn't enabled\n");