2010-09-08 15:46:36 -06:00
|
|
|
/**
|
2011-12-09 12:38:07 -07:00
|
|
|
* @file HandleControlPacket.c
|
|
|
|
* This file contains the routines to deal with
|
|
|
|
* sending and receiving of control packets.
|
|
|
|
*/
|
2010-09-08 15:46:36 -06:00
|
|
|
#include "headers.h"
|
|
|
|
|
|
|
|
/**
|
2011-12-09 12:38:07 -07:00
|
|
|
* When a control packet is received, analyze the
|
|
|
|
* "status" and call appropriate response function.
|
|
|
|
* Enqueue the control packet for Application.
|
|
|
|
* @return None
|
|
|
|
*/
|
2012-05-26 10:05:12 -06:00
|
|
|
static VOID handle_rx_control_packet(struct bcm_mini_adapter *Adapter, struct sk_buff *skb)
|
2010-09-08 15:46:36 -06:00
|
|
|
{
|
2012-05-26 10:05:00 -06:00
|
|
|
struct bcm_tarang_data *pTarang = NULL;
|
2010-09-08 15:46:36 -06:00
|
|
|
BOOLEAN HighPriorityMessage = FALSE;
|
2011-12-09 12:38:05 -07:00
|
|
|
struct sk_buff *newPacket = NULL;
|
2010-09-08 15:46:36 -06:00
|
|
|
CHAR cntrl_msg_mask_bit = 0;
|
2011-12-09 12:38:05 -07:00
|
|
|
BOOLEAN drop_pkt_flag = TRUE;
|
2010-09-08 15:46:36 -06:00
|
|
|
USHORT usStatus = *(PUSHORT)(skb->data);
|
2010-11-01 12:09:05 -06:00
|
|
|
|
|
|
|
if (netif_msg_pktdata(Adapter))
|
|
|
|
print_hex_dump(KERN_DEBUG, PFX "rx control: ", DUMP_PREFIX_NONE,
|
2011-12-09 12:38:05 -07:00
|
|
|
16, 1, skb->data, skb->len, 0);
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-12-09 12:38:08 -07:00
|
|
|
switch (usStatus) {
|
2011-12-09 12:38:07 -07:00
|
|
|
case CM_RESPONSES: /* 0xA0 */
|
2011-12-09 12:38:09 -07:00
|
|
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CP_CTRL_PKT,
|
|
|
|
DBG_LVL_ALL,
|
|
|
|
"MAC Version Seems to be Non Multi-Classifier, rejected by Driver");
|
2011-12-09 12:38:06 -07:00
|
|
|
HighPriorityMessage = TRUE;
|
|
|
|
break;
|
|
|
|
case CM_CONTROL_NEWDSX_MULTICLASSIFIER_RESP:
|
|
|
|
HighPriorityMessage = TRUE;
|
|
|
|
if (Adapter->LinkStatus == LINKUP_DONE)
|
2011-12-09 12:38:09 -07:00
|
|
|
CmControlResponseMessage(Adapter,
|
|
|
|
(skb->data + sizeof(USHORT)));
|
2011-12-09 12:38:06 -07:00
|
|
|
break;
|
2011-12-09 12:38:07 -07:00
|
|
|
case LINK_CONTROL_RESP: /* 0xA2 */
|
|
|
|
case STATUS_RSP: /* 0xA1 */
|
2011-12-09 12:38:09 -07:00
|
|
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CP_CTRL_PKT,
|
|
|
|
DBG_LVL_ALL, "LINK_CONTROL_RESP");
|
2011-12-09 12:38:06 -07:00
|
|
|
HighPriorityMessage = TRUE;
|
2011-12-09 12:38:09 -07:00
|
|
|
LinkControlResponseMessage(Adapter,
|
|
|
|
(skb->data + sizeof(USHORT)));
|
2011-12-09 12:38:06 -07:00
|
|
|
break;
|
2011-12-09 12:38:07 -07:00
|
|
|
case STATS_POINTER_RESP: /* 0xA6 */
|
2011-12-09 12:38:06 -07:00
|
|
|
HighPriorityMessage = TRUE;
|
|
|
|
StatisticsResponse(Adapter, (skb->data + sizeof(USHORT)));
|
|
|
|
break;
|
2011-12-09 12:38:07 -07:00
|
|
|
case IDLE_MODE_STATUS: /* 0xA3 */
|
2011-12-09 12:38:09 -07:00
|
|
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CP_CTRL_PKT,
|
|
|
|
DBG_LVL_ALL,
|
|
|
|
"IDLE_MODE_STATUS Type Message Got from F/W");
|
2011-12-09 12:38:06 -07:00
|
|
|
InterfaceIdleModeRespond(Adapter, (PUINT)(skb->data +
|
|
|
|
sizeof(USHORT)));
|
|
|
|
HighPriorityMessage = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AUTH_SS_HOST_MSG:
|
|
|
|
HighPriorityMessage = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2011-12-09 12:38:09 -07:00
|
|
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CP_CTRL_PKT,
|
|
|
|
DBG_LVL_ALL, "Got Default Response");
|
2011-12-09 12:38:06 -07:00
|
|
|
/* Let the Application Deal with This Packet */
|
|
|
|
break;
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
|
|
|
|
2011-12-09 12:38:07 -07:00
|
|
|
/* Queue The Control Packet to The Application Queues */
|
2010-09-08 15:46:36 -06:00
|
|
|
down(&Adapter->RxAppControlQueuelock);
|
|
|
|
|
2011-12-09 12:38:08 -07:00
|
|
|
for (pTarang = Adapter->pTarangs; pTarang; pTarang = pTarang->next) {
|
2011-12-09 12:38:06 -07:00
|
|
|
if (Adapter->device_removed)
|
2010-09-08 15:46:36 -06:00
|
|
|
break;
|
|
|
|
|
2011-12-09 12:38:05 -07:00
|
|
|
drop_pkt_flag = TRUE;
|
2010-09-08 15:46:36 -06:00
|
|
|
/*
|
2011-12-09 12:38:07 -07:00
|
|
|
* There are cntrl msg from A0 to AC. It has been mapped to 0 to
|
|
|
|
* C bit in the cntrl mask.
|
|
|
|
* Also, by default AD to BF has been masked to the rest of the
|
|
|
|
* bits... which wil be ON by default.
|
|
|
|
* if mask bit is enable to particular pkt status, send it out
|
|
|
|
* to app else stop it.
|
|
|
|
*/
|
2010-09-08 15:46:36 -06:00
|
|
|
cntrl_msg_mask_bit = (usStatus & 0x1F);
|
2011-12-09 12:38:07 -07:00
|
|
|
/*
|
|
|
|
* printk("\ninew msg mask bit which is disable in mask:%X",
|
|
|
|
* cntrl_msg_mask_bit);
|
|
|
|
*/
|
2011-12-09 12:38:05 -07:00
|
|
|
if (pTarang->RxCntrlMsgBitMask & (1 << cntrl_msg_mask_bit))
|
2011-12-09 12:38:06 -07:00
|
|
|
drop_pkt_flag = FALSE;
|
2010-09-08 15:46:36 -06:00
|
|
|
|
2011-12-09 12:38:09 -07:00
|
|
|
if ((drop_pkt_flag == TRUE) ||
|
|
|
|
(pTarang->AppCtrlQueueLen > MAX_APP_QUEUE_LEN)
|
|
|
|
|| ((pTarang->AppCtrlQueueLen >
|
|
|
|
MAX_APP_QUEUE_LEN / 2) &&
|
|
|
|
(HighPriorityMessage == FALSE))) {
|
2010-09-08 15:46:36 -06:00
|
|
|
/*
|
2011-12-09 12:38:07 -07:00
|
|
|
* Assumption:-
|
|
|
|
* 1. every tarang manages it own dropped pkt
|
|
|
|
* statitistics
|
|
|
|
* 2. Total packet dropped per tarang will be equal to
|
|
|
|
* the sum of all types of dropped pkt by that
|
|
|
|
* tarang only.
|
|
|
|
*/
|
2011-12-09 12:38:08 -07:00
|
|
|
switch (*(PUSHORT)skb->data) {
|
2011-12-09 12:38:06 -07:00
|
|
|
case CM_RESPONSES:
|
|
|
|
pTarang->stDroppedAppCntrlMsgs.cm_responses++;
|
|
|
|
break;
|
|
|
|
case CM_CONTROL_NEWDSX_MULTICLASSIFIER_RESP:
|
2011-12-09 12:38:09 -07:00
|
|
|
pTarang->stDroppedAppCntrlMsgs.cm_control_newdsx_multiclassifier_resp++;
|
2011-12-09 12:38:06 -07:00
|
|
|
break;
|
|
|
|
case LINK_CONTROL_RESP:
|
|
|
|
pTarang->stDroppedAppCntrlMsgs.link_control_resp++;
|
|
|
|
break;
|
|
|
|
case STATUS_RSP:
|
|
|
|
pTarang->stDroppedAppCntrlMsgs.status_rsp++;
|
|
|
|
break;
|
|
|
|
case STATS_POINTER_RESP:
|
|
|
|
pTarang->stDroppedAppCntrlMsgs.stats_pointer_resp++;
|
|
|
|
break;
|
|
|
|
case IDLE_MODE_STATUS:
|
|
|
|
pTarang->stDroppedAppCntrlMsgs.idle_mode_status++;
|
|
|
|
break;
|
|
|
|
case AUTH_SS_HOST_MSG:
|
|
|
|
pTarang->stDroppedAppCntrlMsgs.auth_ss_host_msg++;
|
|
|
|
break;
|
2010-09-08 15:46:36 -06:00
|
|
|
default:
|
2011-12-09 12:38:06 -07:00
|
|
|
pTarang->stDroppedAppCntrlMsgs.low_priority_message++;
|
|
|
|
break;
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-12-09 12:38:05 -07:00
|
|
|
newPacket = skb_clone(skb, GFP_KERNEL);
|
|
|
|
if (!newPacket)
|
|
|
|
break;
|
2011-12-09 12:38:09 -07:00
|
|
|
ENQUEUEPACKET(pTarang->RxAppControlHead,
|
|
|
|
pTarang->RxAppControlTail, newPacket);
|
2011-12-09 12:38:05 -07:00
|
|
|
pTarang->AppCtrlQueueLen++;
|
|
|
|
}
|
2010-09-08 15:46:36 -06:00
|
|
|
up(&Adapter->RxAppControlQueuelock);
|
2011-12-09 12:38:05 -07:00
|
|
|
wake_up(&Adapter->process_read_wait_queue);
|
|
|
|
dev_kfree_skb(skb);
|
2011-12-09 12:38:09 -07:00
|
|
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL,
|
|
|
|
"After wake_up_interruptible");
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-12-09 12:38:07 -07:00
|
|
|
* @ingroup ctrl_pkt_functions
|
|
|
|
* Thread to handle control pkt reception
|
|
|
|
*/
|
2012-05-26 10:05:12 -06:00
|
|
|
int control_packet_handler(struct bcm_mini_adapter *Adapter /* pointer to adapter object*/)
|
2010-09-08 15:46:36 -06:00
|
|
|
{
|
2011-12-09 12:38:05 -07:00
|
|
|
struct sk_buff *ctrl_packet = NULL;
|
2010-09-08 15:46:36 -06:00
|
|
|
unsigned long flags = 0;
|
2011-12-09 12:38:07 -07:00
|
|
|
/* struct timeval tv; */
|
|
|
|
/* int *puiBuffer = NULL; */
|
2011-12-09 12:38:09 -07:00
|
|
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL,
|
|
|
|
"Entering to make thread wait on control packet event!");
|
2011-12-09 12:38:08 -07:00
|
|
|
while (1) {
|
2010-09-08 15:46:36 -06:00
|
|
|
wait_event_interruptible(Adapter->process_rx_cntrlpkt,
|
2011-12-09 12:38:09 -07:00
|
|
|
atomic_read(&Adapter->cntrlpktCnt) ||
|
|
|
|
Adapter->bWakeUpDevice ||
|
|
|
|
kthread_should_stop());
|
2010-09-08 15:46:36 -06:00
|
|
|
|
|
|
|
|
2011-12-09 12:38:08 -07:00
|
|
|
if (kthread_should_stop()) {
|
2011-12-09 12:38:09 -07:00
|
|
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CP_CTRL_PKT,
|
|
|
|
DBG_LVL_ALL, "Exiting\n");
|
2010-09-08 15:46:36 -06:00
|
|
|
return 0;
|
|
|
|
}
|
2011-12-09 12:38:08 -07:00
|
|
|
if (TRUE == Adapter->bWakeUpDevice) {
|
2010-09-08 15:46:36 -06:00
|
|
|
Adapter->bWakeUpDevice = FALSE;
|
2011-12-09 12:38:09 -07:00
|
|
|
if ((FALSE == Adapter->bTriedToWakeUpFromlowPowerMode)
|
|
|
|
&& ((TRUE == Adapter->IdleMode) ||
|
|
|
|
(TRUE == Adapter->bShutStatus))) {
|
|
|
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS,
|
|
|
|
CP_CTRL_PKT, DBG_LVL_ALL,
|
|
|
|
"Calling InterfaceAbortIdlemode\n");
|
2011-12-09 12:38:07 -07:00
|
|
|
/*
|
|
|
|
* Adapter->bTriedToWakeUpFromlowPowerMode
|
|
|
|
* = TRUE;
|
|
|
|
*/
|
2011-12-09 12:38:05 -07:00
|
|
|
InterfaceIdleModeWakeup(Adapter);
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-12-09 12:38:08 -07:00
|
|
|
while (atomic_read(&Adapter->cntrlpktCnt)) {
|
2010-09-08 15:46:36 -06:00
|
|
|
spin_lock_irqsave(&Adapter->control_queue_lock, flags);
|
|
|
|
ctrl_packet = Adapter->RxControlHead;
|
2011-12-09 12:38:08 -07:00
|
|
|
if (ctrl_packet) {
|
2011-12-09 12:38:09 -07:00
|
|
|
DEQUEUEPACKET(Adapter->RxControlHead,
|
|
|
|
Adapter->RxControlTail);
|
2011-12-09 12:38:07 -07:00
|
|
|
/* Adapter->RxControlHead=ctrl_packet->next; */
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
|
|
|
|
2011-12-09 12:38:09 -07:00
|
|
|
spin_unlock_irqrestore(&Adapter->control_queue_lock,
|
|
|
|
flags);
|
2011-12-09 12:38:05 -07:00
|
|
|
handle_rx_control_packet(Adapter, ctrl_packet);
|
2010-09-08 15:46:36 -06:00
|
|
|
atomic_dec(&Adapter->cntrlpktCnt);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetUpTargetDsxBuffers(Adapter);
|
|
|
|
}
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2010-09-30 02:24:12 -06:00
|
|
|
INT flushAllAppQ(void)
|
2010-09-08 15:46:36 -06:00
|
|
|
{
|
2012-05-26 10:05:12 -06:00
|
|
|
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
2012-05-26 10:05:00 -06:00
|
|
|
struct bcm_tarang_data *pTarang = NULL;
|
2010-09-08 15:46:36 -06:00
|
|
|
struct sk_buff *PacketToDrop = NULL;
|
2011-12-09 12:38:08 -07:00
|
|
|
for (pTarang = Adapter->pTarangs; pTarang; pTarang = pTarang->next) {
|
|
|
|
while (pTarang->RxAppControlHead != NULL) {
|
2011-12-09 12:38:05 -07:00
|
|
|
PacketToDrop = pTarang->RxAppControlHead;
|
2011-12-09 12:38:09 -07:00
|
|
|
DEQUEUEPACKET(pTarang->RxAppControlHead,
|
|
|
|
pTarang->RxAppControlTail);
|
2010-11-01 07:35:21 -06:00
|
|
|
dev_kfree_skb(PacketToDrop);
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
|
|
|
pTarang->AppCtrlQueueLen = 0;
|
2011-12-09 12:38:07 -07:00
|
|
|
/* dropped contrl packet statistics also should be reset. */
|
2011-12-09 12:38:09 -07:00
|
|
|
memset((PVOID)&pTarang->stDroppedAppCntrlMsgs, 0,
|
2012-11-25 17:28:57 -07:00
|
|
|
sizeof(struct bcm_mibs_dropped_cntrl_msg));
|
2010-09-08 15:46:36 -06:00
|
|
|
|
|
|
|
}
|
2011-12-09 12:38:05 -07:00
|
|
|
return STATUS_SUCCESS;
|
2010-09-08 15:46:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|