17 #include <linux/version.h>
21 #ifdef CSR_SUPPORT_WEXT_AP
51 #ifdef CSR_SUPPORT_SME
52 static void check_inactivity_timer_expire_func(
unsigned long data);
74 if(!buffered_frame_item) {
75 unifi_error(priv,
"Entry should exist, otherwise it is a (BUG)\n");
80 (priv->wifi_on_state == wifi_on_done))
83 unifi_warning(priv,
"Send MA_PACKET_CONFIRM to SenderProcessId = %x for (HostTag = %x TransmissionControl = %x)\n",
93 memset(&unpacked_signal, 0,
sizeof(unpacked_signal));
105 write_pack(&unpacked_signal, sigbuf, &packed_siglen);
106 unifi_warning(priv,
"MA_PACKET_CONFIRM for SME (0x%x, 0x%x, 0x%x, 0x%x)\n",
118 else if((buffered_frame_item->
hostTag & 0x80000000))
121 unifi_warning(priv,
"MA_PACKET_CONFIRM for NME (0x%x, 0x%x, 0x%x, 0x%x)\n",
125 (buffered_frame_item->
hostTag & 0x3FFFFFFF));
130 (buffered_frame_item->
hostTag & 0x3FFFFFFF),
131 buffered_frame_item->
rate);
136 unifi_warning(priv,
"Buffered packet dropped without sending a confirm\n");
142 kfree(buffered_frame_item);
143 buffered_frame_item =
NULL;
154 if (priv->smepriv ==
NULL) {
155 unifi_error(priv,
"CsrWifiRouterCtrlMediaStatusReqHandler: invalid smepriv\n");
159 unifi_error(priv,
"CsrWifiRouterCtrlMediaStatusReqHandler: invalid interfaceTag\n");
175 spin_unlock_irqrestore(&priv->
m4_lock, flags);
178 unifi_trace(priv,
UDBG5,
"CsrWifiRouterCtrlMediaStatusReqHandler: free M4\n");
183 (interfacePriv->
connected != UnifiConnected)) {
188 interfacePriv->
connected = UnifiConnected;
190 #ifdef CSR_SUPPORT_WEXT
194 "CsrWifiRouterCtrlMediaStatusReqHandler: AP/P2PGO setting netif_carrier_on\n");
199 #ifdef CSR_SUPPORT_WEXT
205 interfacePriv->wait_netdev_change =
TRUE;
207 "CsrWifiRouterCtrlMediaStatusReqHandler: waiting for NETDEV_CHANGE\n");
214 "CsrWifiRouterCtrlMediaStatusReqHandler: STA/P2PCLI setting netif_carrier_on\n");
224 static const CsrWifiMacAddress broadcast_address = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
225 interfacePriv->
connected = UnifiConnected;
227 "CsrWifiRouterMediaStatusReqHandler: UnifiConnected && netif_carrier_on\n");
238 #ifdef CSR_SUPPORT_WEXT
240 "CsrWifiRouterMediaStatusReqHandler: cancel waiting for NETDEV_CHANGE\n");
241 interfacePriv->wait_netdev_change =
FALSE;
244 "CsrWifiRouterMediaStatusReqHandler: setting netif_carrier_off\n");
246 #ifdef CSR_SUPPORT_WEXT
256 interfacePriv->
connected = UnifiNotConnected;
261 unifi_trace(priv,
UDBG1,
"CsrWifiRouterCtrlMediaStatusReqHandler: AMP connected\n");
262 interfacePriv->
connected = UnifiConnected;
264 unifi_trace(priv,
UDBG1,
"CsrWifiRouterCtrlMediaStatusReqHandler: AMP disconnected\n");
265 interfacePriv->
connected = UnifiNotConnected;
282 u16 interfaceTag = 0;
289 if (priv->smepriv ==
NULL) {
290 unifi_error(priv,
"CsrWifiRouterCtrlHipReqHandler: invalid smepriv\n");
294 unifi_error(priv,
"CsrWifiRouterCtrlHipReqHandler: invalid interfaceTag\n");
324 unifi_warning(priv,
"signal not sent down, allocation failed in CsrWifiRouterCtrlHipReqHandler\n");
342 unifi_warning(priv,
"signal not sent down, allocation failed in CsrWifiRouterCtrlHipReqHandler\n");
351 *((
u16*)signal_ptr));
361 unifi_error(priv,
"CsrWifiRouterCtrlHipReqHandler: invalid mode: NONE \n");
389 "CsrWifiRouterCtrlHipReqHandler: Failed to send signal (0x%.4X - %u)\n",
390 *((
u16*)signal_ptr), r);
397 #ifdef CSR_WIFI_SEND_GRATUITOUS_ARP
409 static const u8 arp_req[36] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00,
410 0x08, 0x06, 0x00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00, 0x01,
411 0x00, 0x02, 0x5f, 0x20, 0x2f, 0x02,
412 0xc0, 0xa8, 0x00, 0x02,
413 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
414 0xc0, 0xa8, 0x00, 0x02};
421 unifi_error(priv,
"Failed to allocate bulk data in CsrWifiSmeRoamCompleteIndHandler()\n");
430 skb->
data[22] = (priv->sta_ip_address ) & 0xFF;
431 skb->
data[23] = (priv->sta_ip_address >> 8) & 0xFF;
432 skb->
data[24] = (priv->sta_ip_address >> 16) & 0xFF;
433 skb->
data[25] = (priv->sta_ip_address >> 24) & 0xFF;
434 skb->
data[32] = (priv->sta_ip_address ) & 0xFF;
435 skb->
data[33] = (priv->sta_ip_address >> 8) & 0xFF;
436 skb->
data[34] = (priv->sta_ip_address >> 16) & 0xFF;
437 skb->
data[35] = (priv->sta_ip_address >> 24) & 0xFF;
443 if ((protection = uf_get_protection_bit_from_interfacemode(priv, interfaceTag, &arp_req[26])) < 0)
445 unifi_error(priv,
"CsrWifiSmeRoamCompleteIndHandler: Failed to determine protection mode\n");
460 interfaceTag, &arp_req[26],
461 priv->
netdev[interfaceTag]->dev_addr, protection))
463 unifi_error(priv,
"CsrWifiSmeRoamCompleteIndHandler: failed to create MAC header\n");
473 interfacePriv->
bssid.
a, &signal);
478 unifi_error(priv,
"CsrWifiSmeRoamCompleteIndHandler: failed to send QOS data null packet result: %d\n",r);
509 const u8 broadcast_mac_address[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
513 const char* controlled_string;
516 unifi_error(priv,
"configure_data_port: bad interfaceTag\n");
523 port = &interfacePriv->controlled_data_port;
524 controlled_string =
"controlled";
526 port = &interfacePriv->uncontrolled_data_port;
527 controlled_string =
"uncontrolled";
531 "port config request %pM %s with port_action %d.\n",
532 macAddress->
a, controlled_string, port_action);
566 #ifdef CSR_WIFI_SEND_GRATUITOUS_ARP
570 uf_send_gratuitous_arp(priv, interfaceTag);
588 int found_entry_flag;
589 int first_free_slot = -1;
601 found_entry_flag = 0;
607 found_entry_flag = 1;
610 }
else if (first_free_slot == -1) {
621 if (!found_entry_flag) {
622 if (first_free_slot == -1) {
629 unifi_trace(priv,
UDBG3,
"port config index assigned in config_data_port = %d\n", first_free_slot);
655 "port config %pM with port_action %d.\n",
656 macAddress->
a, port_action);
668 unifi_trace(priv,
UDBG3,
"entering CsrWifiRouterCtrlPortConfigureReqHandler\n");
669 if (priv->smepriv ==
NULL) {
670 unifi_error(priv,
"CsrWifiRouterCtrlPortConfigureReqHandler: invalid smepriv\n");
709 unifi_trace(priv,
UDBG1,
"CsrWifiRouterCtrlPortConfigureReqHandler(0x%.4X) Uncaught mode %d\n",
720 unifi_trace(priv,
UDBG3,
"leaving CsrWifiRouterCtrlPortConfigureReqHandler\n");
736 unifi_trace(priv,
UDBG1,
"CsrWifiRouterCtrlWifiOnReqHandler: Don't reset mode\n");
740 unifi_trace(priv,
UDBG1,
"CsrWifiRouterCtrlWifiOnReqHandler: take wake lock\n");
741 wake_lock(&unifi_sdio_wake_lock);
744 unifi_trace(priv,
UDBG1,
"CsrWifiRouterCtrlWifiOnReqHandler: Setting interface %d to NONE\n", i );
770 priv->wifi_on_state = wifi_on_in_progress;
776 unifi_error(priv,
"CsrWifiRouterCtrlWifiOnReqHandler: Failed to get f/w\n");
789 unifi_error(priv,
"CsrWifiRouterCtrlWifiOnReqHandler: Failed to power on UniFi\n");
799 unifi_error(priv,
"CsrWifiRouterCtrlWifiOnReqHandler: Failed to initialise h/w, error %d\n", r);
830 priv->CSR_WIFI_SME_IFACEQUEUE = msg->
source;
845 priv->wifi_on_state = wifi_on_done;
864 if (priv->wifi_on_state == wifi_on_unspecified) {
874 #ifdef CSR_SUPPORT_WEXT
890 if (priv_instance == -1) {
892 "CsrWifiRouterCtrlStopReqHandler: Unknown priv instance, will power off card.\n");
895 power_off = (
fw_init[priv_instance] > 0) ? 0 : 1;
917 "csr_sdio_linux_remove_irq failed to talk to card.\n");
922 "Force low power and try to power off\n");
933 priv->wifi_on_state = wifi_on_unspecified;
956 netif_tx_stop_all_queues(priv->
netdev[i]);
957 interfacePriv->
connected = UnifiConnectedUnknown;
984 if (priv->smepriv ==
NULL) {
985 unifi_error(priv,
"CsrWifiRouterCtrlQosControlReqHandler: invalid smepriv\n");
992 unifi_error(priv,
"CsrWifiRouterCtrlQosControlReqHandler: interfaceID >= CSR_WIFI_NUM_INTERFACES.\n");
1021 unifi_error(priv,
"CsrWifiRouterCtrlTclasAddReqHandler: invalid smepriv\n");
1034 unifi_error(priv,
"CsrWifiRouterCtrlTclasDelReqHandler: invalid smepriv\n");
1049 if (priv->smepriv ==
NULL) {
1050 unifi_error(priv,
"CsrWifiRouterCtrlConfigurePowerModeReqHandler: invalid smepriv\n");
1061 "CsrWifiRouterCtrlConfigurePowerModeReqHandler (mode=%d, wake=%d)\n",
1074 unifi_error(
NULL,
"CsrWifiRouterCtrlWifiOnResHandler: Invalid ospriv.\n");
1095 #ifdef CSR_WIFI_SPLIT_PATCH
1126 unifi_error(priv,
"Failed to register the network device.\n");
1131 #ifdef CSR_WIFI_SPLIT_PATCH
1138 switching_ap_fw =
TRUE;
1159 #ifdef CSR_WIFI_SPLIT_PATCH
1160 if (switching_ap_fw && (priv->pending_mode_set.common.destination != 0xaaaa)) {
1161 unifi_info(priv,
"Completed firmware reload with %s patch\n",
1166 priv->pending_mode_set.clientData,
1167 priv->pending_mode_set.interfaceTag,
1168 priv->pending_mode_set.mode,
1170 priv->pending_mode_set.common.destination = 0xaaaa;
1175 #ifdef ANDROID_BUILD
1178 wake_unlock(&unifi_sdio_wake_lock);
1185 #ifdef CSR_SUPPORT_WEXT
1217 unifi_error(priv,
"CsrWifiRouterMaPacketSubscribeReqHandler: invalid priv\n");
1224 for (i = 0; i < MAX_MA_UNIDATA_IND_FILTERS; i++) {
1226 if (!priv->sme_unidata_ind_filters[i].in_use) {
1228 priv->sme_unidata_ind_filters[
i].in_use = 1;
1229 priv->sme_unidata_ind_filters[
i].appHandle = msg->
source;
1230 priv->sme_unidata_ind_filters[
i].encapsulation = req->
encapsulation;
1231 priv->sme_unidata_ind_filters[
i].protocol = req->
protocol;
1233 priv->sme_unidata_ind_filters[
i].oui[2] = (
u8) (req->
oui & 0xFF);
1234 priv->sme_unidata_ind_filters[
i].oui[1] = (
u8) ((req->
oui >> 8) & 0xFF);
1235 priv->sme_unidata_ind_filters[
i].oui[0] = (
u8) ((req->
oui >> 16) & 0xFF);
1243 "subscribe_req: encap=%d, handle=%d, result=%d\n",
1256 unifi_error(priv,
"CsrWifiRouterMaPacketUnsubscribeReqHandler: invalid priv\n");
1272 "unsubscribe_req: handle=%d, result=%d\n",
1284 unifi_error(priv,
"CsrWifiRouterCtrlCapabilitiesReqHandler: invalid priv\n");
1300 unifi_error(priv,
"CsrWifiRouterCtrlSuspendResHandler: invalid priv\n");
1314 unifi_error(priv,
"CsrWifiRouterCtrlResumeResHandler: invalid priv\n");
1329 unifi_error(priv,
"CsrWifiRouterCtrlTrafficConfigReqHandler: invalid smepriv\n");
1345 unifi_error(priv,
"CsrWifiRouterCtrlTrafficClassificationReqHandler: invalid smepriv\n");
1354 u8 subscriptionHandle,
1369 unsigned long flags;
1371 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
1372 unifi_error(priv,
"_sys_packet_req: interfaceID >= CSR_WIFI_NUM_INTERFACES.\n");
1376 if (!priv->sme_unidata_ind_filters[subscriptionHandle].in_use) {
1377 unifi_error(priv,
"_sys_packet_req: unknown subscription.\n");
1381 subs = &priv->sme_unidata_ind_filters[subscriptionHandle];
1383 "_sys_packet_req: handle=%d, subs=%p, encap=%d\n",
1388 unifi_error(priv,
"_sys_packet_req: failed to allocate bulkdata.\n");
1403 "_sys_packet_req: skb_add_llc_snap -->\n");
1406 "_sys_packet_req: skb_add_llc_snap <--\n");
1409 "_sys_packet_req: failed to translate eth frame.\n");
1433 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
1442 #ifdef CSR_SUPPORT_SME
1443 if ((protection = uf_get_protection_bit_from_interfacemode(priv, interfaceTag, peerMacAddress.
a)) < 0) {
1444 unifi_error(priv,
"unicast address, but destination not in station record database\n");
1452 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
1458 unifi_error(priv,
"failed to create MAC header\n");
1471 spin_unlock_irqrestore(&priv->
m4_lock, flags);
1473 unifi_trace(priv,
UDBG1,
"_sys_packet_req: Sending CsrWifiRouterCtrlM4ReadyToSendInd\n");
1484 "_sys_packet_req: failed to send signal.\n");
1498 llc_snap_hdr_t *
snap;
1508 if (!mareq->
frame || !priv || !priv->smepriv)
1510 unifi_error(priv,
"CsrWifiRouterMaPacketReqHandler: invalid frame/priv/priv->smepriv\n");
1514 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
1515 unifi_error(priv,
"CsrWifiRouterMaPacketReqHandler: interfaceID >= CSR_WIFI_NUM_INTERFACES.\n");
1519 daddr = mareq->
frame;
1523 snap_protocol =
ntohs(snap->protocol);
1525 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
1594 unsigned long flags;
1597 unifi_error(priv,
"CsrWifiRouterCtrlM4TransmitReqHandler: invalid smepriv\n");
1601 unifi_error(priv,
"M4TransmitReqHandler: interfaceTag >= CSR_WIFI_NUM_INTERFACES\n");
1608 spin_unlock_irqrestore(&priv->
m4_lock, flags);
1609 unifi_error(priv,
"CsrWifiRouterCtrlM4TransmitReqHandler: invalid buffer\n");
1619 spin_unlock_irqrestore(&priv->
m4_lock, flags);
1630 "CsrWifiRouterCtrlM4TransmitReqHandler: sent\n");
1633 "CsrWifiRouterCtrlM4TransmitReqHandler: failed to send signal.\n");
1639 static void CsrWifiRouterCtrlResetStationRecordList(
unifi_priv_t *priv,
u16 interfaceTag)
1649 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
1650 unifi_error(priv,
"CsrWifiRouterCtrlResetStationRecordList: bad interfaceTag\n");
1654 INIT_LIST_HEAD(&send_cfm_list);
1658 if ((staInfo=interfacePriv->staInfo[i]) !=
NULL) {
1659 uf_prepare_send_cfm_list_for_queued_pkts(priv,
1662 uf_flush_list(priv,&(staInfo->
mgtFrames));
1664 uf_prepare_send_cfm_list_for_queued_pkts(priv,
1667 uf_flush_list(priv,&(staInfo->
dataPdu[j]));
1674 staInfo->peerControlledPort->in_use =
FALSE;
1675 interfacePriv->controlled_data_port.entries_in_use--;
1679 staInfo->peerUnControlledPort->in_use =
FALSE;
1680 interfacePriv->uncontrolled_data_port.entries_in_use--;
1682 kfree(interfacePriv->staInfo[i]);
1683 interfacePriv->staInfo[
i] =
NULL;
1684 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
1692 #ifdef CSR_SUPPORT_SME
1699 if (priv->noOfPktQueuedInDriver) {
1700 unifi_warning(priv,
"After reset the noOfPktQueuedInDriver = %x\n", priv->noOfPktQueuedInDriver);
1702 priv->noOfPktQueuedInDriver = 0;
1703 spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
1709 unifi_error(priv,
"interfacemode is not correct in CsrWifiRouterCtrlResetStationRecordList: debug\n");
1713 if (((interfacePriv->controlled_data_port.entries_in_use != 0) || (interfacePriv->uncontrolled_data_port.entries_in_use != 0))
1718 unifi_trace(priv,
UDBG3,
"In %s controlled port entries = %d, uncontrolled port entries = %d\n",
1719 __FUNCTION__, interfacePriv->controlled_data_port.entries_in_use,
1720 interfacePriv->uncontrolled_data_port.entries_in_use);
1731 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
1732 unifi_error(priv,
"CsrWifiRouterCtrlInterfaceReset: bad interfaceTag\n");
1738 INIT_LIST_HEAD(&send_cfm_list);
1746 uf_prepare_send_cfm_list_for_queued_pkts(priv,
1748 &(interfacePriv->genericMgtFrames));
1749 uf_flush_list(priv,&(interfacePriv->genericMgtFrames));
1751 uf_prepare_send_cfm_list_for_queued_pkts(priv,
1753 &(interfacePriv->genericMulticastOrBroadCastMgtFrames));
1754 uf_flush_list(priv,&(interfacePriv->genericMulticastOrBroadCastMgtFrames));
1756 uf_prepare_send_cfm_list_for_queued_pkts(priv,
1758 &(interfacePriv->genericMulticastOrBroadCastFrames));
1760 uf_flush_list(priv,&(interfacePriv->genericMulticastOrBroadCastFrames));
1776 CsrWifiRouterCtrlResetStationRecordList(priv,interfaceTag);
1779 interfacePriv->num_stations_joined = 0;
1780 interfacePriv->sta_activity_check_enabled =
FALSE;
1791 unifi_error(priv,
"CsrWifiRouterCtrlModeSetReqHandler: invalid smepriv\n");
1798 #ifdef CSR_WIFI_SPLIT_PATCH
1801 unifi_trace(priv,
UDBG1,
"CsrWifiRouterCtrlModeSetReqHandler: interfacePriv->interfaceMode = %d\n",
1806 #ifdef CSR_WIFI_SPLIT_PATCH
1815 #ifdef ANDROID_BUILD
1818 wake_lock(&unifi_sdio_wake_lock);
1824 unifi_error(priv,
"CsrWifiRouterCtrlModeSetReqHandler: Failed to get f/w\n");
1836 unifi_error(priv,
"CsrWifiRouterCtrlWifiOnReqHandler: Failed to initialise h/w, error %d\n", r);
1862 priv->pending_mode_set = *
req;
1896 unifi_trace(priv,
UDBG3,
"CsrWifiRouterCtrlModeSetReqHandler: IntraBssDisEnabled = %d\n",
1900 interfacePriv->
connected = UnifiConnectedUnknown;
1921 u8 ba_session_idx = 0;
1935 INIT_LIST_HEAD(&send_cfm_list);
1941 uf_prepare_send_cfm_list_for_queued_pkts(priv,
1945 uf_flush_list(priv,&(staInfo->
mgtFrames));
1947 uf_prepare_send_cfm_list_for_queued_pkts(priv,
1950 uf_flush_list(priv,&(staInfo->
dataPdu[j]));
1955 controlledPort = &interfacePriv->controlled_data_port;
1956 unControlledPort = &interfacePriv->uncontrolled_data_port;
1958 unifi_trace(priv,
UDBG1,
"peer_delete_record: Peer found handle = %d, port in use: cont(%d), unCont(%d)\n",
1963 staInfo->peerControlledPort->in_use =
FALSE;
1967 unifi_warning(priv,
"number of controlled port entries is zero, trying to decrement: debug\n");
1972 staInfo->peerUnControlledPort->in_use =
FALSE;
1976 unifi_warning(priv,
"number of uncontrolled port entries is zero, trying to decrement: debug\n");
1979 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
1983 unifi_trace(priv,
UDBG3,
"peer is deleted so TIM updated to 0, in firmware\n");
2020 #ifdef CSR_SUPPORT_SME
2026 #ifdef CSR_SUPPORT_SME
2027 interfacePriv->num_stations_joined--;
2031 if ((interfacePriv->sta_activity_check_enabled) &&
2034 unifi_trace(priv,
UDBG1,
"STOPPING the Inactivity Timer (num of stations = %d)\n", interfacePriv->num_stations_joined);
2035 interfacePriv->sta_activity_check_enabled =
FALSE;
2043 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2066 unifi_trace(priv,
UDBG2,
"entering CsrWifiRouterCtrlPeerDelReqHandler \n");
2069 unifi_error(priv,
"CsrWifiRouterCtrlPeerDelReqHandler: invalid smepriv\n");
2075 unifi_error(priv,
"CsrWifiRouterCtrlPeerDelReqHandler: bad interfaceTag\n");
2085 status = peer_delete_record(priv, req);
2101 u8 i, powerModeTemp = 0;
2105 CsrTime currentTime, currentTimeHi;
2109 unifi_error(priv,
"peer_add_new_record: bad interfaceTag\n");
2116 if(interfacePriv->staInfo[i] ==
NULL) {
2118 freeSlotFound =
TRUE;
2126 unifi_error(priv,
"failed to allocate the %d bytes of mem for station record\n",
2131 unifi_trace(priv,
UDBG1,
"peer_add_new_record: handle = %d AID = %d addr = %x:%x:%x:%x:%x:%x LI=%u\n",
2139 interfacePriv->staInfo[
i] = newRecord;
2183 unifi_trace(priv,
UDBG2,
"peer_add_new_record: WMM : %d ,AC %d, powersaveMode %x \n",
2187 unifi_trace(priv,
UDBG3,
"newRecord->wmmOrQosEnabled : %d , MAX SP : %d\n",
2195 INIT_LIST_HEAD(&newRecord->
dataPdu[j]);
2199 newRecord->lastActivity = currentTime;
2200 newRecord->activity_flag =
TRUE;
2203 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2225 if (!newRecord->peerControlledPort || !newRecord->peerUnControlledPort) {
2227 unifi_warning(priv,
"Un/ControlledPort record not found in port configuration array index = %d\n", i);
2228 kfree(interfacePriv->staInfo[i]);
2229 interfacePriv->staInfo[
i] =
NULL;
2230 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2257 #ifdef CSR_SUPPORT_SME
2258 interfacePriv->num_stations_joined++;
2259 newRecord->interfacePriv = interfacePriv;
2263 INIT_WORK(&newRecord->send_disconnected_ind_task, uf_send_disconnected_ind_wq);
2265 if(!(interfacePriv->sta_activity_check_enabled) &&
2268 "peer_add_new_record: STARTING the Inactivity Timer (num of stations = %d)",
2269 interfacePriv->num_stations_joined);
2271 interfacePriv->sta_activity_check_enabled =
TRUE;
2272 interfacePriv->sta_activity_check_timer.function = check_inactivity_timer_expire_func;
2273 interfacePriv->sta_activity_check_timer.data = (
unsigned long)interfacePriv;
2275 init_timer(&interfacePriv->sta_activity_check_timer);
2276 mod_timer(&interfacePriv->sta_activity_check_timer,
2281 spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
2286 if(!freeSlotFound) {
2287 unifi_error(priv,
"Limited connectivity, Free slot not found for station record addition\n");
2293 #ifdef CSR_SUPPORT_SME
2294 static void check_inactivity_timer_expire_func(
unsigned long data)
2308 priv = interfacePriv->
privPtr;
2310 if (interfacePriv->
InterfaceTag >= CSR_WIFI_NUM_INTERFACES)
2312 unifi_error(priv,
"check_inactivity_timer_expire_func: Invalid interfaceTag\n");
2320 if(interfacePriv->staInfo[i] !=
NULL) {
2321 sta_record = interfacePriv->staInfo[
i];
2323 if (sta_record->activity_flag ==
TRUE){
2324 sta_record->activity_flag =
FALSE;
2325 sta_record->lastActivity = now;
2329 if (sta_record->lastActivity > now)
2341 unifi_trace(priv,
UDBG1,
"STA is Inactive - AID = %d inactive_time = %d\n",
2354 unifi_trace(priv,
UDBG1,
"STA power save state - Active, send a NULL frame to check if it is ALIVE\n");
2355 uf_send_nulldata ( priv,
2356 sta_record->interfacePriv->InterfaceTag,
2366 unifi_trace(priv,
UDBG1,
"STA power save state - PS, TIM is already SET\n");
2376 if (inactive_time > (3 * (sta_record->listenIntervalInTus * 1024)))
2378 unifi_trace(priv,
UDBG1,
"STA is inactive for more than 3 listen intervals\n");
2380 &sta_record->send_disconnected_ind_task);
2386 unifi_trace(priv,
UDBG1,
"STA power save state - PS, update TIM to see if it is ALIVE\n");
2399 mod_timer(&interfacePriv->sta_activity_check_timer,
2420 if(!staInfo->interfacePriv) {
2424 priv = staInfo->interfacePriv->privPtr;
2425 interfaceTag = staInfo->interfacePriv->InterfaceTag;
2427 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
2428 unifi_error(priv,
"uf_send_disconnected_ind_wq: invalid interfaceTag\n");
2437 INIT_LIST_HEAD(&send_cfm_list);
2439 uf_prepare_send_cfm_list_for_queued_pkts(priv,
2443 uf_flush_list(priv, &(staInfo->
mgtFrames));
2446 uf_prepare_send_cfm_list_for_queued_pkts(priv,
2450 uf_flush_list(priv,&(staInfo->
dataPdu[j]));
2455 unifi_warning(priv,
"uf_send_disconnected_ind_wq: Router Disconnected IND Peer (%x-%x-%x-%x-%x-%x)\n",
2465 staInfo->interfacePriv->InterfaceTag,
2483 unifi_trace(priv,
UDBG2,
"entering CsrWifiRouterCtrlPeerAddReqHandler \n");
2486 unifi_error(priv,
"CsrWifiRouterCtrlPeerAddReqHandler: invalid smepriv\n");
2492 unifi_error(priv,
"CsrWifiRouterCtrlPeerAddReqHandler: bad interfaceTag\n");
2502 status = peer_add_new_record(priv,req,&handle);
2521 unifi_trace(priv,
UDBG2,
"entering CsrWifiRouterCtrlPeerUpdateReqHandler \n");
2524 unifi_error(priv,
"CsrWifiRouterCtrlPeerUpdateReqHandler: invalid smepriv\n");
2529 unifi_trace(priv,
UDBG2,
"leaving CsrWifiRouterCtrlPeerUpdateReqHandler \n");
2559 if (ba_session->
interfacePriv->InterfaceTag >= CSR_WIFI_NUM_INTERFACES) {
2564 unifi_warning(priv,
"%s: Calling CsrWifiRouterCtrlBlockAckErrorIndSend(%d, %d, %d, %d, %x:%x:%x:%x:%x:%x, %d)\n",
2566 priv->CSR_WIFI_SME_IFACEQUEUE,
2587 static void ba_session_terminate_timer_func(
unsigned long data)
2602 if (ba_session->
interfacePriv->InterfaceTag >= CSR_WIFI_NUM_INTERFACES) {
2620 u8 ba_session_idx = 0;
2623 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
2630 if(!interfacePriv) {
2647 "%s: stopping ba_session for peer = %pM role = %d tID = %d\n",
2648 __func__, macAddress.
a, role, tID);
2654 ba_session_rx = interfacePriv->
ba_session_rx[ba_session_idx];
2663 if (!ba_session_rx || (ba_session_idx == MAX_SUPPORTED_BA_SESSIONS_RX)) {
2673 for (i = 0; i < ba_session_rx->
wind_size; i++) {
2682 kfree(ba_session_rx);
2685 ba_session_tx = interfacePriv->
ba_session_tx[ba_session_idx];
2693 if (!ba_session_tx || (ba_session_idx == MAX_SUPPORTED_BA_SESSIONS_TX)) {
2698 kfree(ba_session_tx);
2744 u8 ba_session_idx = 0;
2747 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
2754 if(!interfacePriv) {
2777 "%s: ba session with peer= (%pM)\n", __func__,
2792 ba_session_tx = interfacePriv->
ba_session_tx[ba_session_idx];
2793 if (ba_session_tx) {
2802 ba_session_tx =
NULL;
2810 if (ba_session_idx == MAX_SUPPORTED_BA_SESSIONS_TX){
2817 if (!ba_session_tx) {
2823 ba_session_tx->
tID = tID;
2826 interfacePriv->
ba_session_tx[ba_session_idx] = ba_session_tx;
2831 ba_session_rx = interfacePriv->
ba_session_rx[ba_session_idx];
2832 if (ba_session_rx) {
2836 if(ba_session_rx->
wind_size == wind_size &&
2837 ba_session_rx->
timeout == timeout &&
2847 if(ba_session_rx->
wind_size != wind_size) {
2851 ba_session_rx->
timeout = timeout;
2852 ba_session_rx->
timer.function = ba_session_terminate_timer_func;
2853 ba_session_rx->
timer.data = (
unsigned long)ba_session_rx;
2864 if(ba_session_rx->
start_sn != start_sn) {
2876 ba_session_rx =
NULL;
2884 if (ba_session_idx == MAX_SUPPORTED_BA_SESSIONS_RX){
2901 unifi_warning(priv,
"blockack_session_start: Controlled port not opened, Reject BA request\n");
2906 if (!ba_session_rx) {
2916 if (!ba_session_rx->
buffer) {
2917 kfree(ba_session_rx);
2924 ba_session_rx->
timeout = timeout;
2925 ba_session_rx->
timer.function = ba_session_terminate_timer_func;
2926 ba_session_rx->
timer.data = (
unsigned long)ba_session_rx;
2932 ba_session_rx->
tID = tID;
2935 interfacePriv->
ba_session_rx[ba_session_idx] = ba_session_rx;
2969 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
2983 priv->wapi_multicast_filter = req->
status;
2991 #elif defined(UNIFI_DEBUG)
2994 unifi_error(priv,
"CsrWifiRouterCtrlWapiMulticastFilterReqHandler: called when WAPI isn't enabled\n");
3000 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
3012 if ((priv->wapi_unicast_filter == 1) && (req->
status == 0)) {
3014 priv->wapi_unicast_queued_pkt_filter = 1;
3019 priv->wapi_unicast_filter = req->
status;
3027 #elif defined(UNIFI_DEBUG)
3030 unifi_error(priv,
"CsrWifiRouterCtrlWapiUnicastFilterReqHandler: called when WAPI isn't enabled\n");
3036 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
3057 if (priv->smepriv ==
NULL) {
3077 unifi_error(priv,
"CsrWifiRouterCtrlWapiRxPktReqHandler: Received unknown or corrupted signal.\n");
3082 unifi_error(priv,
"CsrWifiRouterCtrlWapiRxPktReqHandler: Unknown signal with reception status = %d\n",pkt_ind->
ReceptionStatus);
3099 "CsrWifiRouterCtrlWapiRxPktReq: "
3100 "Sending signal to client %d, (s:0x%X, r:0x%X) - Signal 0x%X \n",
3114 #elif defined(UNIFI_DEBUG)
3117 unifi_error(priv,
"CsrWifiRouterCtrlWapiRxPktReqHandler: called when WAPI isn't enabled\n");
3123 #if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
3131 u8 appendedCryptoFields = 1 + 1 + 16 + 16;
3134 CSR_MA_PACKET_REQUEST *storedSignalMAPktReq = &interfacePriv->wapi_unicast_ma_pkt_sig.u.MaPacketRequest;
3144 if (priv->smepriv ==
NULL) {
3153 if ((req->
data[0] & 0x88) == 0x88) {
3157 if ( !(req->
dataLength>(macHeaderLengthInBytes+appendedCryptoFields)) ) {
3184 storedSignalMAPktReq->
Ra.
x,
3185 storedSignalMAPktReq->
HostTag,
3190 interfacePriv->wapi_unicast_ma_pkt_sig.SignalPrimitiveHeader.SenderProcessId,
3198 interfacePriv->
stats.tx_packets++;
3201 interfacePriv->
stats.tx_bytes += req->
dataLength - macHeaderLengthInBytes - appendedCryptoFields;
3202 unifi_trace(priv,
UDBG1,
"CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: (Packet Sent), sent count = %x\n", interfacePriv->
stats.tx_packets);
3205 unifi_trace(priv,
UDBG1,
"(HIP validation failure) Result = %d\n", result);
3208 interfacePriv->
stats.tx_dropped++;
3209 unifi_trace(priv,
UDBG1,
"CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: (Packet Drop), dropped count = %x\n", interfacePriv->
stats.tx_dropped);
3219 #elif defined(UNIFI_DEBUG)
3222 unifi_error(priv,
"CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: called when WAPI SW ENCRYPTION isn't enabled\n");
3228 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
3230 #ifdef CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND
3251 #elif defined(UNIFI_DEBUG)
3254 unifi_error(priv,
"CsrWifiRouterCtrlWapiFilterReq: called when WAPI isn't enabled\n");