3 static VOID default_wimax_protocol_initialize(PMINI_ADAPTER Adapter)
8 for(uiLoopIndex=0; uiLoopIndex < NO_OF_QUEUES-1; uiLoopIndex++)
10 Adapter->PackInfo[uiLoopIndex].uiThreshold=TX_PACKET_THRESHOLD;
11 Adapter->PackInfo[uiLoopIndex].uiMaxAllowedRate=MAX_ALLOWED_RATE;
12 Adapter->PackInfo[uiLoopIndex].uiMaxBucketSize=20*1024*1024;
15 Adapter->BEBucketSize=BE_BUCKET_SIZE;
16 Adapter->rtPSBucketSize=rtPS_BUCKET_SIZE;
17 Adapter->LinkStatus=SYNC_UP_REQUEST;
18 Adapter->TransferMode=IP_PACKET_ONLY_MODE;
19 Adapter->usBestEffortQueueIndex=-1;
25 InitAdapter(PMINI_ADAPTER psAdapter)
28 INT Status = STATUS_SUCCESS ;
29 BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Initialising Adapter = 0x%x",(unsigned int) psAdapter);
33 BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Adapter is NULL");
37 sema_init(&psAdapter->NVMRdmWrmLock,1);
38 // psAdapter->ulFlashCalStart = FLASH_AUTO_INIT_BASE_ADDR;
40 sema_init(&psAdapter->rdmwrmsync, 1);
41 spin_lock_init(&psAdapter->control_queue_lock);
42 spin_lock_init(&psAdapter->txtransmitlock);
43 sema_init(&psAdapter->RxAppControlQueuelock, 1);
44 // sema_init(&psAdapter->data_packet_queue_lock, 1);
45 sema_init(&psAdapter->fw_download_sema, 1);
46 sema_init(&psAdapter->LowPowerModeSync,1);
48 // spin_lock_init(&psAdapter->sleeper_lock);
50 for(i=0;i<NO_OF_QUEUES; i++)
51 spin_lock_init(&psAdapter->PackInfo[i].SFQueueLock);
54 init_waitqueue_head(&psAdapter->process_rx_cntrlpkt);
55 init_waitqueue_head(&psAdapter->tx_packet_wait_queue);
56 init_waitqueue_head(&psAdapter->process_read_wait_queue);
57 init_waitqueue_head(&psAdapter->ioctl_fw_dnld_wait_queue);
58 init_waitqueue_head(&psAdapter->lowpower_mode_wait_queue);
59 psAdapter->waiting_to_fw_download_done = TRUE;
60 //init_waitqueue_head(&psAdapter->device_wake_queue);
61 psAdapter->fw_download_done=FALSE;
63 psAdapter->pvOsDepData = (PLINUX_DEP_DATA) kmalloc(sizeof(LINUX_DEP_DATA),
66 if(psAdapter->pvOsDepData == NULL)
68 BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Linux Specific Data allocation failed");
71 memset(psAdapter->pvOsDepData, 0, sizeof(LINUX_DEP_DATA));
73 default_wimax_protocol_initialize(psAdapter);
74 for (i=0;i<MAX_CNTRL_PKTS;i++)
76 psAdapter->txctlpacket[i] = (char *)kmalloc(MAX_CNTL_PKT_SIZE,
78 if(!psAdapter->txctlpacket[i])
80 BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "No More Cntl pkts got, max got is %d", i);
84 if(AllocAdapterDsxBuffer(psAdapter))
86 BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed to allocate DSX buffers");
90 //Initialize PHS interface
91 if(phs_init(&psAdapter->stBCMPhsContext,psAdapter)!=0)
93 BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"%s:%s:%d:Error PHS Init Failed=====>\n", __FILE__, __FUNCTION__, __LINE__);
97 Status = BcmAllocFlashCSStructure(psAdapter);
100 BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Memory Allocation for Flash structure failed");
104 Status = vendorextnInit(psAdapter);
106 if(STATUS_SUCCESS != Status)
108 BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Vendor Init Failed");
112 BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Adapter initialised");
115 return STATUS_SUCCESS;
118 VOID AdapterFree(PMINI_ADAPTER Adapter)
122 beceem_protocol_reset(Adapter);
124 vendorextnExit(Adapter);
126 if(Adapter->control_packet_handler && !IS_ERR(Adapter->control_packet_handler))
127 kthread_stop (Adapter->control_packet_handler);
128 if(Adapter->transmit_packet_thread && !IS_ERR(Adapter->transmit_packet_thread))
129 kthread_stop (Adapter->transmit_packet_thread);
130 wake_up(&Adapter->process_read_wait_queue);
131 if(Adapter->LEDInfo.led_thread_running & (BCM_LED_THREAD_RUNNING_ACTIVELY | BCM_LED_THREAD_RUNNING_INACTIVELY))
132 kthread_stop (Adapter->LEDInfo.led_cntrl_threadid);
133 bcm_unregister_networkdev(Adapter);
134 while(atomic_read(&Adapter->ApplicationRunning))
136 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Waiting for Application to close.. %d\n",atomic_read(&Adapter->ApplicationRunning));
139 unregister_control_device_interface(Adapter);
140 if(Adapter->dev && !IS_ERR(Adapter->dev))
141 free_netdev(Adapter->dev);
142 if(Adapter->pstargetparams != NULL)
144 bcm_kfree(Adapter->pstargetparams);
146 for (count =0;count < MAX_CNTRL_PKTS;count++)
148 if(Adapter->txctlpacket[count])
149 bcm_kfree(Adapter->txctlpacket[count]);
151 FreeAdapterDsxBuffer(Adapter);
152 if(Adapter->pvOsDepData)
153 bcm_kfree (Adapter->pvOsDepData);
154 if(Adapter->pvInterfaceAdapter)
155 bcm_kfree(Adapter->pvInterfaceAdapter);
157 //Free the PHS Interface
158 PhsCleanup(&Adapter->stBCMPhsContext);
160 #ifndef BCM_SHM_INTERFACE
161 BcmDeAllocFlashCSStructure(Adapter);
165 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "<========\n");
169 int create_worker_threads(PMINI_ADAPTER psAdapter)
171 BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Init Threads...");
172 // Rx Control Packets Processing
173 psAdapter->control_packet_handler = kthread_run((int (*)(void *))
174 control_packet_handler, psAdapter, "CtrlPktHdlr");
175 if(IS_ERR(psAdapter->control_packet_handler))
177 BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "No Kernel Thread, but still returning success\n");
178 return PTR_ERR(psAdapter->control_packet_handler);
181 psAdapter->transmit_packet_thread = kthread_run((int (*)(void *))
182 tx_pkt_handler, psAdapter, "TxPktThread");
183 if(IS_ERR (psAdapter->transmit_packet_thread))
185 BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "No Kernel Thread, but still returning success");
186 kthread_stop(psAdapter->control_packet_handler);
187 return PTR_ERR(psAdapter->transmit_packet_thread);
193 static inline struct file *open_firmware_file(PMINI_ADAPTER Adapter, char *path)
195 struct file *flp=NULL;
199 flp=filp_open(path, O_RDONLY, S_IRWXU);
203 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Unable To Open File %s, err %lx",
209 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Got file descriptor pointer of %s!",
212 if(Adapter->device_removed)
221 int BcmFileDownload(PMINI_ADAPTER Adapter,/**< Logical Adapter */
222 char *path, /**< path to image file */
223 unsigned int loc /**< Download Address on the chip*/
227 struct file *flp=NULL;
229 struct timeval tv={0};
231 flp=open_firmware_file(Adapter, path);
235 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Unable to Open %s\n", path);
238 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Opened file is = %s and length =0x%lx to be downloaded at =0x%x", path,(unsigned long)flp->f_dentry->d_inode->i_size, loc);
239 do_gettimeofday(&tv);
241 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "download start %lx", ((tv.tv_sec * 1000) +
243 if(Adapter->bcm_file_download(Adapter->pvInterfaceAdapter, flp, loc))
245 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed to download the firmware with error\
250 oldfs=get_fs();set_fs(get_ds());
251 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
252 vfs_llseek(flp, 0, 0);
255 if(Adapter->bcm_file_readback_from_chip(Adapter->pvInterfaceAdapter,
258 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed to read back firmware!");
264 oldfs=get_fs();set_fs(get_ds());
265 if(flp && !(IS_ERR(flp)))
266 filp_close(flp, current->files);
268 do_gettimeofday(&tv);
269 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "file download done at %lx", ((tv.tv_sec * 1000) +
275 void bcm_kfree_skb(struct sk_buff *skb)
284 VOID bcm_kfree(VOID *ptr)
294 @ingroup ctrl_pkt_functions
295 This function copies the contents of given buffer
296 to the control packet and queues it for transmission.
297 @note Do not acquire the spinock, as it it already acquired.
298 @return SUCCESS/FAILURE.
300 INT CopyBufferToControlPacket(PMINI_ADAPTER Adapter,/**<Logical Adapter*/
301 PVOID ioBuffer/**<Control Packet Buffer*/
304 PLEADER pLeader=NULL;
306 unsigned char *ctrl_buff=NULL;
308 PLINK_REQUEST pLinkReq = NULL;
309 PUCHAR pucAddIndication = NULL;
311 BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "======>");
314 BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Got Null Buffer\n");
318 pLinkReq = (PLINK_REQUEST)ioBuffer;
319 pLeader=(PLEADER)ioBuffer; //ioBuffer Contains sw_Status and Payload
321 if(Adapter->bShutStatus == TRUE &&
322 pLinkReq->szData[0] == LINK_DOWN_REQ_PAYLOAD &&
323 pLinkReq->szData[1] == LINK_SYNC_UP_SUBTYPE)
325 //Got sync down in SHUTDOWN..we could not process this.
326 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "SYNC DOWN Request in Shut Down Mode..\n");
327 return STATUS_FAILURE;
330 if((pLeader->Status == LINK_UP_CONTROL_REQ) &&
331 ((pLinkReq->szData[0] == LINK_UP_REQ_PAYLOAD &&
332 (pLinkReq->szData[1] == LINK_SYNC_UP_SUBTYPE)) ||//Sync Up Command
333 pLinkReq->szData[0] == NETWORK_ENTRY_REQ_PAYLOAD)) //Net Entry Command
335 if(Adapter->LinkStatus > PHY_SYNC_ACHIVED)
337 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL,"LinkStatus is Greater than PHY_SYN_ACHIEVED");
338 return STATUS_FAILURE;
340 if(TRUE == Adapter->bShutStatus)
342 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "SYNC UP IN SHUTDOWN..Device WakeUp\n");
343 if(Adapter->bTriedToWakeUpFromlowPowerMode == FALSE)
345 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Waking up for the First Time..\n");
346 Adapter->usIdleModePattern = ABORT_SHUTDOWN_MODE; // change it to 1 for current support.
347 Adapter->bWakeUpDevice = TRUE;
348 wake_up(&Adapter->process_rx_cntrlpkt);
350 Status = wait_event_interruptible_timeout(Adapter->lowpower_mode_wait_queue,
351 !Adapter->bShutStatus, (5 * HZ));
353 if(Status == -ERESTARTSYS)
356 if(Adapter->bShutStatus)
358 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Shutdown Mode Wake up Failed - No Wake Up Received\n");
359 return STATUS_FAILURE;
364 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Wakeup has been tried already...\n");
369 if(TRUE == Adapter->IdleMode)
371 //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Device is in Idle mode ... hence \n");
372 if(pLeader->Status == LINK_UP_CONTROL_REQ || pLeader->Status == 0x80 ||
373 pLeader->Status == CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ )
376 if((pLeader->Status == LINK_UP_CONTROL_REQ) && (pLinkReq->szData[0]==LINK_DOWN_REQ_PAYLOAD))
378 if((pLinkReq->szData[1] == LINK_SYNC_DOWN_SUBTYPE))
380 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Link Down Sent in Idle Mode\n");
381 Adapter->usIdleModePattern = ABORT_IDLE_SYNCDOWN;//LINK DOWN sent in Idle Mode
385 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL,"ABORT_IDLE_MODE pattern is being written\n");
386 Adapter->usIdleModePattern = ABORT_IDLE_REG;
391 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL,"ABORT_IDLE_MODE pattern is being written\n");
392 Adapter->usIdleModePattern = ABORT_IDLE_MODE;
395 /*Setting bIdleMode_tx_from_host to TRUE to indicate LED control thread to represent
396 the wake up from idlemode is from host*/
397 //Adapter->LEDInfo.bIdleMode_tx_from_host = TRUE;
399 if(STATUS_SUCCESS != InterfaceIdleModeWakeup(Adapter))
401 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Idle Mode Wake up Failed\n");
402 return STATUS_FAILURE;
405 Adapter->bWakeUpDevice = TRUE;
406 wake_up(&Adapter->process_rx_cntrlpkt);
410 if(LINK_DOWN_REQ_PAYLOAD == pLinkReq->szData[0])
412 // We should not send DREG message down while in idlemode.
413 return STATUS_SUCCESS;
416 Status = wait_event_interruptible_timeout(Adapter->lowpower_mode_wait_queue,
417 !Adapter->IdleMode, (5 * HZ));
419 if(Status == -ERESTARTSYS)
422 if(Adapter->IdleMode)
424 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Idle Mode Wake up Failed - No Wake Up Received\n");
425 return STATUS_FAILURE;
429 return STATUS_SUCCESS;
431 //The Driver has to send control messages with a particular VCID
432 pLeader->Vcid = VCID_CONTROL_PACKET;//VCID for control packet.
434 /* Allocate skb for Control Packet */
435 pktlen = pLeader->PLength;
436 ctrl_buff = (char *)Adapter->txctlpacket[atomic_read(&Adapter->index_wr_txcntrlpkt)%MAX_CNTRL_PKTS];
438 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Control packet to be taken =%d and address is =%pincoming address is =%p and packet len=%x",
439 atomic_read(&Adapter->index_wr_txcntrlpkt), ctrl_buff, ioBuffer, pktlen);
444 if((pLeader->Status == 0x80) ||
445 (pLeader->Status == CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ))
448 //Restructure the DSX message to handle Multiple classifier Support
449 // Write the Service Flow param Structures directly to the target
450 //and embed the pointers in the DSX messages sent to target.
452 //Lets store the current length of the control packet we are transmitting
453 pucAddIndication = (PUCHAR)ioBuffer + LEADER_SIZE;
454 pktlen = pLeader->PLength;
455 Status = StoreCmControlResponseMessage(Adapter,pucAddIndication, &pktlen);
458 ClearTargetDSXBuffer(Adapter,((stLocalSFAddIndicationAlt *)pucAddIndication)->u16TID, FALSE);
459 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, " Error Restoring The DSX Control Packet. Dsx Buffers on Target may not be Setup Properly ");
460 return STATUS_FAILURE;
463 //update the leader to use the new length
464 //The length of the control packet is length of message being sent + Leader length
466 pLeader->PLength = pktlen;
469 memset(ctrl_buff, 0, pktlen+LEADER_SIZE);
470 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Copying the Control Packet Buffer with length=%d\n", pLeader->PLength);
471 *(PLEADER)ctrl_buff=*pLeader;
472 memcpy(ctrl_buff + LEADER_SIZE, ((PUCHAR)ioBuffer + LEADER_SIZE), pLeader->PLength);
473 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Enqueuing the Control Packet");
475 /*Update the statistics counters */
476 spin_lock_bh(&Adapter->PackInfo[HiPriority].SFQueueLock);
477 Adapter->PackInfo[HiPriority].uiCurrentBytesOnHost+=pLeader->PLength;
478 Adapter->PackInfo[HiPriority].uiCurrentPacketsOnHost++;
479 atomic_inc(&Adapter->TotalPacketCount);
480 spin_unlock_bh(&Adapter->PackInfo[HiPriority].SFQueueLock);
482 Adapter->PackInfo[HiPriority].bValid = TRUE;
484 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "CurrBytesOnHost: %x bValid: %x",
485 Adapter->PackInfo[HiPriority].uiCurrentBytesOnHost,
486 Adapter->PackInfo[HiPriority].bValid);
487 Status=STATUS_SUCCESS;
488 /*Queue the packet for transmission */
489 atomic_inc(&Adapter->index_wr_txcntrlpkt);
490 BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Calling transmit_packets");
491 atomic_set(&Adapter->TxPktAvail, 1);
492 #ifdef BCM_SHM_INTERFACE
493 virtual_mail_box_interrupt();
495 wake_up(&Adapter->tx_packet_wait_queue);
500 BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "mem allocation Failed");
502 BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "<====");
506 /*****************************************************************
507 * Function - SendStatisticsPointerRequest()
509 * Description - This function builds and forwards the Statistics
510 * Pointer Request control Packet.
512 * Parameters - Adapter : Pointer to Adapter structure.
513 * - pstStatisticsPtrRequest : Pointer to link request.
516 *****************************************************************/
517 VOID SendStatisticsPointerRequest(PMINI_ADAPTER Adapter,
518 PLINK_REQUEST pstStatisticsPtrRequest)
520 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "======>");
521 pstStatisticsPtrRequest->Leader.Status = STATS_POINTER_REQ_STATUS;
522 pstStatisticsPtrRequest->Leader.PLength = sizeof(ULONG);//minimum 4 bytes
523 pstStatisticsPtrRequest->szData[0] = STATISTICS_POINTER_REQ;
525 CopyBufferToControlPacket(Adapter,pstStatisticsPtrRequest);
526 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "<=====");
532 void SendLinkDown(PMINI_ADAPTER Adapter)
534 LINK_REQUEST stLinkDownRequest;
535 memset(&stLinkDownRequest, 0, sizeof(LINK_REQUEST));
536 stLinkDownRequest.Leader.Status=LINK_UP_CONTROL_REQ;
537 stLinkDownRequest.Leader.PLength=sizeof(ULONG);//minimum 4 bytes
538 stLinkDownRequest.szData[0]=LINK_DOWN_REQ_PAYLOAD;
539 Adapter->bLinkDownRequested = TRUE;
541 CopyBufferToControlPacket(Adapter,&stLinkDownRequest);
544 /******************************************************************
545 * Function - LinkMessage()
547 * Description - This function builds the Sync-up and Link-up request
548 * packet messages depending on the device Link status.
550 * Parameters - Adapter: Pointer to the Adapter structure.
553 *******************************************************************/
554 __inline VOID LinkMessage(PMINI_ADAPTER Adapter)
556 PLINK_REQUEST pstLinkRequest=NULL;
557 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "=====>");
558 if(Adapter->LinkStatus == SYNC_UP_REQUEST && Adapter->AutoSyncup)
560 pstLinkRequest=kmalloc(sizeof(LINK_REQUEST), GFP_ATOMIC);
563 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Can not allocate memory for Link request!");
566 memset(pstLinkRequest,0,sizeof(LINK_REQUEST));
568 Adapter->LinkStatus = WAIT_FOR_SYNC;// current link status
569 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Requesting For SyncUp...");
570 pstLinkRequest->szData[0]=LINK_UP_REQ_PAYLOAD;
571 pstLinkRequest->szData[1]=LINK_SYNC_UP_SUBTYPE;
572 pstLinkRequest->Leader.Status=LINK_UP_CONTROL_REQ;
573 pstLinkRequest->Leader.PLength=sizeof(ULONG);
574 Adapter->bSyncUpRequestSent = TRUE;
576 else if(Adapter->LinkStatus == PHY_SYNC_ACHIVED && Adapter->AutoLinkUp)
578 pstLinkRequest=kmalloc(sizeof(LINK_REQUEST), GFP_ATOMIC);
581 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Can not allocate memory for Link request!");
584 memset(pstLinkRequest,0,sizeof(LINK_REQUEST));
586 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Requesting For LinkUp...");
587 pstLinkRequest->szData[0]=LINK_UP_REQ_PAYLOAD;
588 pstLinkRequest->szData[1]=LINK_NET_ENTRY;
589 pstLinkRequest->Leader.Status=LINK_UP_CONTROL_REQ;
590 pstLinkRequest->Leader.PLength=sizeof(ULONG);
594 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Calling CopyBufferToControlPacket");
595 CopyBufferToControlPacket(Adapter, pstLinkRequest);
596 bcm_kfree(pstLinkRequest);
598 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "LinkMessage <=====");
603 /**********************************************************************
604 * Function - StatisticsResponse()
606 * Description - This function handles the Statistics response packet.
608 * Parameters - Adapter : Pointer to the Adapter structure.
609 * - pvBuffer: Starting address of Statistic response data.
612 ************************************************************************/
613 VOID StatisticsResponse(PMINI_ADAPTER Adapter,PVOID pvBuffer)
615 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s====>",__FUNCTION__);
616 Adapter->StatisticsPointer = ntohl(*(PULONG)pvBuffer);
617 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Stats at %lx", Adapter->StatisticsPointer);
618 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s <====",__FUNCTION__);
623 /**********************************************************************
624 * Function - LinkControlResponseMessage()
626 * Description - This function handles the Link response packets.
628 * Parameters - Adapter : Pointer to the Adapter structure.
629 * - pucBuffer: Starting address of Link response data.
632 ***********************************************************************/
633 VOID LinkControlResponseMessage(PMINI_ADAPTER Adapter,PUCHAR pucBuffer)
635 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "=====>");
637 if(*pucBuffer==LINK_UP_ACK)
639 switch(*(pucBuffer+1))
641 case PHY_SYNC_ACHIVED: //SYNCed UP
642 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "PHY_SYNC_ACHIVED");
644 if(Adapter->LinkStatus == LINKUP_DONE)
646 beceem_protocol_reset(Adapter);
649 Adapter->usBestEffortQueueIndex=INVALID_QUEUE_INDEX ;
650 Adapter->LinkStatus=PHY_SYNC_ACHIVED;
652 if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY)
654 Adapter->DriverState = NO_NETWORK_ENTRY;
655 wake_up(&Adapter->LEDInfo.notify_led_event);
658 LinkMessage(Adapter);
662 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "LINKUP_DONE");
663 Adapter->LinkStatus=LINKUP_DONE;
664 Adapter->bPHSEnabled = *(pucBuffer+3);
665 Adapter->bETHCSEnabled = *(pucBuffer+4) & ETH_CS_MASK;
666 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "PHS Support Status Recieved In LinkUp Ack : %x \n",Adapter->bPHSEnabled);
667 if((FALSE == Adapter->bShutStatus)&&
668 (FALSE == Adapter->IdleMode))
670 if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY)
672 Adapter->DriverState = NORMAL_OPERATION;
673 wake_up(&Adapter->LEDInfo.notify_led_event);
676 LinkMessage(Adapter);
681 * Driver to ignore the DREG_RECEIVED
682 * WiMAX Application should handle this Message
684 //Adapter->liTimeSinceLastNetEntry = 0;
685 Adapter->LinkUpStatus = 0;
686 Adapter->LinkStatus = 0;
687 Adapter->usBestEffortQueueIndex=INVALID_QUEUE_INDEX ;
688 Adapter->bTriedToWakeUpFromlowPowerMode = FALSE;
689 Adapter->IdleMode = FALSE;
690 beceem_protocol_reset(Adapter);
693 case LINK_SHUTDOWN_REQ_FROM_FIRMWARE:
694 case COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW:
696 HandleShutDownModeRequest(Adapter, pucBuffer);
700 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "default case:LinkResponse %x",*(pucBuffer+1));
704 else if(SET_MAC_ADDRESS_RESPONSE==*pucBuffer)
706 PUCHAR puMacAddr = (pucBuffer + 1);
707 Adapter->LinkStatus=SYNC_UP_REQUEST;
708 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "MAC address response, sending SYNC_UP");
709 LinkMessage(Adapter);
710 memcpy(Adapter->dev->dev_addr, puMacAddr, MAC_ADDRESS_SIZE);
712 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "%s <=====",__FUNCTION__);
716 void SendIdleModeResponse(PMINI_ADAPTER Adapter)
718 INT status = 0, NVMAccess = 0,lowPwrAbortMsg = 0;
720 CONTROL_MESSAGE stIdleResponse = {{0}};
721 memset(&tv, 0, sizeof(tv));
722 stIdleResponse.Leader.Status = IDLE_MESSAGE;
723 stIdleResponse.Leader.PLength = IDLE_MODE_PAYLOAD_LENGTH;
724 stIdleResponse.szData[0] = GO_TO_IDLE_MODE_PAYLOAD;
725 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL," ============>");
727 /*********************************
729 ** if [ semaphore is available ]
730 ** acquire semaphone and return value 0 ;
732 ** return non-zero value ;
734 ***********************************/
736 NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock);
738 lowPwrAbortMsg= down_trylock(&Adapter->LowPowerModeSync);
741 if((NVMAccess || lowPwrAbortMsg || atomic_read(&Adapter->TotalPacketCount)) &&
742 (Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE) )
745 up(&Adapter->NVMRdmWrmLock);
748 up(&Adapter->LowPowerModeSync);
750 stIdleResponse.szData[1] = TARGET_CAN_NOT_GO_TO_IDLE_MODE;//NACK- device access is going on.
751 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "HOST IS NACKING Idle mode To F/W!!!!!!!!");
752 Adapter->bPreparingForLowPowerMode = FALSE;
756 stIdleResponse.szData[1] = TARGET_CAN_GO_TO_IDLE_MODE; //2;//Idle ACK
757 Adapter->StatisticsPointer = 0;
759 /* Wait for the LED to TURN OFF before sending ACK response */
760 if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY)
764 /* Wake the LED Thread with IDLEMODE_ENTER State */
765 Adapter->DriverState = LOWPOWER_MODE_ENTER;
766 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL,"LED Thread is Running..Hence Setting LED Event as IDLEMODE_ENTER jiffies:%ld",jiffies);;
767 wake_up(&Adapter->LEDInfo.notify_led_event);
769 /* Wait for 1 SEC for LED to OFF */
770 iRetVal = wait_event_timeout(Adapter->LEDInfo.idleModeSyncEvent, \
771 Adapter->LEDInfo.bIdle_led_off, msecs_to_jiffies(1000));
774 /* If Timed Out to Sync IDLE MODE Enter, do IDLE mode Exit and Send NACK to device */
777 stIdleResponse.szData[1] = TARGET_CAN_NOT_GO_TO_IDLE_MODE;//NACK- device access is going on.
778 Adapter->DriverState = NORMAL_OPERATION;
779 wake_up(&Adapter->LEDInfo.notify_led_event);
780 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "NACKING Idle mode as time out happen from LED side!!!!!!!!");
783 if(stIdleResponse.szData[1] == TARGET_CAN_GO_TO_IDLE_MODE)
785 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL,"ACKING IDLE MODE !!!!!!!!!");
786 down(&Adapter->rdmwrmsync);
787 Adapter->bPreparingForLowPowerMode = TRUE;
788 up(&Adapter->rdmwrmsync);
789 #ifndef BCM_SHM_INTERFACE
791 if(Adapter->bDoSuspend == TRUE)
792 Bcm_kill_all_URBs((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter));
798 Adapter->bPreparingForLowPowerMode = FALSE;
802 up(&Adapter->NVMRdmWrmLock);
805 up(&Adapter->LowPowerModeSync);
808 status = CopyBufferToControlPacket(Adapter,&stIdleResponse);
809 if((status != STATUS_SUCCESS))
811 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"fail to send the Idle mode Request \n");
812 Adapter->bPreparingForLowPowerMode = FALSE;
813 #ifndef BCM_SHM_INTERFACE
814 StartInterruptUrb((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter));
817 do_gettimeofday(&tv);
818 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "IdleMode Msg submitter to Q :%ld ms", tv.tv_sec *1000 + tv.tv_usec /1000);
822 /******************************************************************
823 * Function - DumpPackInfo()
825 * Description - This function dumps the all Queue(PackInfo[]) details.
827 * Parameters - Adapter: Pointer to the Adapter structure.
830 *******************************************************************/
831 VOID DumpPackInfo(PMINI_ADAPTER Adapter)
834 UINT uiLoopIndex = 0;
836 UINT uiClsfrIndex = 0;
837 S_CLASSIFIER_RULE *pstClassifierEntry = NULL;
839 for(uiLoopIndex=0;uiLoopIndex<NO_OF_QUEUES;uiLoopIndex++)
841 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"*********** Showing Details Of Queue %d***** ******",uiLoopIndex);
842 if(FALSE == Adapter->PackInfo[uiLoopIndex].bValid)
844 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"bValid is FALSE for %X index\n",uiLoopIndex);
848 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL," Dumping SF Rule Entry For SFID %lX \n",Adapter->PackInfo[uiLoopIndex].ulSFID);
849 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL," ucDirection %X \n",Adapter->PackInfo[uiLoopIndex].ucDirection);
850 if(Adapter->PackInfo[uiLoopIndex].ucIpVersion == IPV6)
852 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"Ipv6 Service Flow \n");
856 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"Ipv4 Service Flow \n");
858 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL," SF Traffic Priority %X \n",Adapter->PackInfo[uiLoopIndex].u8TrafficPriority);
860 for(uiClsfrIndex=0;uiClsfrIndex<MAX_CLASSIFIERS;uiClsfrIndex++)
862 pstClassifierEntry = &Adapter->astClassifierTable[uiClsfrIndex];
863 if(!pstClassifierEntry->bUsed)
866 if(pstClassifierEntry->ulSFID != Adapter->PackInfo[uiLoopIndex].ulSFID)
869 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tDumping Classifier Rule Entry For Index: %X Classifier Rule ID : %X\n",uiClsfrIndex,pstClassifierEntry->uiClassifierRuleIndex);
870 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tDumping Classifier Rule Entry For Index: %X usVCID_Value : %X\n",uiClsfrIndex,pstClassifierEntry->usVCID_Value);
871 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tDumping Classifier Rule Entry For Index: %X bProtocolValid : %X\n",uiClsfrIndex,pstClassifierEntry->bProtocolValid);
872 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tDumping Classifier Rule Entry For Index: %X bTOSValid : %X\n",uiClsfrIndex,pstClassifierEntry->bTOSValid);
873 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tDumping Classifier Rule Entry For Index: %X bDestIpValid : %X\n",uiClsfrIndex,pstClassifierEntry->bDestIpValid);
874 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tDumping Classifier Rule Entry For Index: %X bSrcIpValid : %X\n",uiClsfrIndex,pstClassifierEntry->bSrcIpValid);
877 for(uiIndex=0;uiIndex<MAX_PORT_RANGE;uiIndex++)
879 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tusSrcPortRangeLo:%X\n",pstClassifierEntry->usSrcPortRangeLo[uiIndex]);
880 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tusSrcPortRangeHi:%X\n",pstClassifierEntry->usSrcPortRangeHi[uiIndex]);
881 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tusDestPortRangeLo:%X\n",pstClassifierEntry->usDestPortRangeLo[uiIndex]);
882 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tusDestPortRangeHi:%X\n",pstClassifierEntry->usDestPortRangeHi[uiIndex]);
885 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL," \tucIPSourceAddressLength : 0x%x\n",pstClassifierEntry->ucIPSourceAddressLength);
886 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tucIPDestinationAddressLength : 0x%x\n",pstClassifierEntry->ucIPDestinationAddressLength);
887 for(uiIndex=0;uiIndex<pstClassifierEntry->ucIPSourceAddressLength;uiIndex++)
889 if(Adapter->PackInfo[uiLoopIndex].ucIpVersion == IPV6)
891 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tIpv6 ulSrcIpAddr :\n");
892 DumpIpv6Address(pstClassifierEntry->stSrcIpAddress.ulIpv6Addr);
893 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tIpv6 ulSrcIpMask :\n");
894 DumpIpv6Address(pstClassifierEntry->stSrcIpAddress.ulIpv6Mask);
898 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tulSrcIpAddr:%lX\n",pstClassifierEntry->stSrcIpAddress.ulIpv4Addr[uiIndex]);
899 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tulSrcIpMask:%lX\n",pstClassifierEntry->stSrcIpAddress.ulIpv4Mask[uiIndex]);
902 for(uiIndex=0;uiIndex<pstClassifierEntry->ucIPDestinationAddressLength;uiIndex++)
904 if(Adapter->PackInfo[uiLoopIndex].ucIpVersion == IPV6)
906 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tIpv6 ulDestIpAddr :\n");
907 DumpIpv6Address(pstClassifierEntry->stDestIpAddress.ulIpv6Addr);
908 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tIpv6 ulDestIpMask :\n");
909 DumpIpv6Address(pstClassifierEntry->stDestIpAddress.ulIpv6Mask);
914 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tulDestIpAddr:%lX\n",pstClassifierEntry->stDestIpAddress.ulIpv4Addr[uiIndex]);
915 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tulDestIpMask:%lX\n",pstClassifierEntry->stDestIpAddress.ulIpv4Mask[uiIndex]);
918 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tucProtocol:0x%X\n",pstClassifierEntry->ucProtocol[0]);
919 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tu8ClassifierRulePriority:%X\n",pstClassifierEntry->u8ClassifierRulePriority);
923 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"ulSFID:%lX\n",Adapter->PackInfo[uiLoopIndex].ulSFID);
924 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"usVCID_Value:%X\n",Adapter->PackInfo[uiLoopIndex].usVCID_Value);
925 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"PhsEnabled: 0x%X\n",Adapter->PackInfo[uiLoopIndex].bHeaderSuppressionEnabled);
926 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiThreshold:%X\n",Adapter->PackInfo[uiLoopIndex].uiThreshold);
929 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"bValid:%X\n",Adapter->PackInfo[uiLoopIndex].bValid);
930 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"bActive:%X\n",Adapter->PackInfo[uiLoopIndex].bActive);
931 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"ActivateReqSent: %x", Adapter->PackInfo[uiLoopIndex].bActivateRequestSent);
932 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"u8QueueType:%X\n",Adapter->PackInfo[uiLoopIndex].u8QueueType);
933 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiMaxBucketSize:%X\n",Adapter->PackInfo[uiLoopIndex].uiMaxBucketSize);
934 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiPerSFTxResourceCount:%X\n",atomic_read(&Adapter->PackInfo[uiLoopIndex].uiPerSFTxResourceCount));
935 //DumpDebug(DUMP_INFO,(" bCSSupport:%X\n",Adapter->PackInfo[uiLoopIndex].bCSSupport));
936 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"CurrQueueDepthOnTarget: %x\n", Adapter->PackInfo[uiLoopIndex].uiCurrentQueueDepthOnTarget);
937 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiCurrentBytesOnHost:%X\n",Adapter->PackInfo[uiLoopIndex].uiCurrentBytesOnHost);
938 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiCurrentPacketsOnHost:%X\n",Adapter->PackInfo[uiLoopIndex].uiCurrentPacketsOnHost);
939 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiDroppedCountBytes:%X\n",Adapter->PackInfo[uiLoopIndex].uiDroppedCountBytes);
940 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiDroppedCountPackets:%X\n",Adapter->PackInfo[uiLoopIndex].uiDroppedCountPackets);
941 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiSentBytes:%X\n",Adapter->PackInfo[uiLoopIndex].uiSentBytes);
942 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiSentPackets:%X\n",Adapter->PackInfo[uiLoopIndex].uiSentPackets);
943 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiCurrentDrainRate:%X\n",Adapter->PackInfo[uiLoopIndex].uiCurrentDrainRate);
944 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiThisPeriodSentBytes:%X\n",Adapter->PackInfo[uiLoopIndex].uiThisPeriodSentBytes);
945 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"liDrainCalculated:%llX\n",Adapter->PackInfo[uiLoopIndex].liDrainCalculated);
946 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiCurrentTokenCount:%X\n",Adapter->PackInfo[uiLoopIndex].uiCurrentTokenCount);
947 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"liLastUpdateTokenAt:%llX\n",Adapter->PackInfo[uiLoopIndex].liLastUpdateTokenAt);
948 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiMaxAllowedRate:%X\n",Adapter->PackInfo[uiLoopIndex].uiMaxAllowedRate);
949 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiPendedLast:%X\n",Adapter->PackInfo[uiLoopIndex].uiPendedLast);
950 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"NumOfPacketsSent:%X\n",Adapter->PackInfo[uiLoopIndex].NumOfPacketsSent);
951 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Direction: %x\n", Adapter->PackInfo[uiLoopIndex].ucDirection);
952 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "CID: %x\n", Adapter->PackInfo[uiLoopIndex].usCID);
953 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ProtocolValid: %x\n", Adapter->PackInfo[uiLoopIndex].bProtocolValid);
954 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "TOSValid: %x\n", Adapter->PackInfo[uiLoopIndex].bTOSValid);
955 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "DestIpValid: %x\n", Adapter->PackInfo[uiLoopIndex].bDestIpValid);
956 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "SrcIpValid: %x\n", Adapter->PackInfo[uiLoopIndex].bSrcIpValid);
957 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ActiveSet: %x\n", Adapter->PackInfo[uiLoopIndex].bActiveSet);
958 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "AdmittedSet: %x\n", Adapter->PackInfo[uiLoopIndex].bAdmittedSet);
959 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "AuthzSet: %x\n", Adapter->PackInfo[uiLoopIndex].bAuthorizedSet);
960 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ClassifyPrority: %x\n", Adapter->PackInfo[uiLoopIndex].bClassifierPriority);
961 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiMaxLatency: %x\n",Adapter->PackInfo[uiLoopIndex].uiMaxLatency);
962 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ServiceClassName: %x %x %x %x\n",Adapter->PackInfo[uiLoopIndex].ucServiceClassName[0],Adapter->PackInfo[uiLoopIndex].ucServiceClassName[1],Adapter->PackInfo[uiLoopIndex].ucServiceClassName[2],Adapter->PackInfo[uiLoopIndex].ucServiceClassName[3]);
963 // BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "bHeaderSuppressionEnabled :%X\n", Adapter->PackInfo[uiLoopIndex].bHeaderSuppressionEnabled);
964 // BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiTotalTxBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiTotalTxBytes);
965 // BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiTotalRxBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiTotalRxBytes);
966 // DumpDebug(DUMP_INFO,(" uiRanOutOfResCount:%X\n",Adapter->PackInfo[uiLoopIndex].uiRanOutOfResCount));
969 for(uiLoopIndex = 0 ; uiLoopIndex < MIBS_MAX_HIST_ENTRIES ; uiLoopIndex++)
970 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"Adapter->aRxPktSizeHist[%x] = %x\n",uiLoopIndex,Adapter->aRxPktSizeHist[uiLoopIndex]);
972 for(uiLoopIndex = 0 ; uiLoopIndex < MIBS_MAX_HIST_ENTRIES ; uiLoopIndex++)
973 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"Adapter->aTxPktSizeHist[%x] = %x\n",uiLoopIndex,Adapter->aTxPktSizeHist[uiLoopIndex]);
983 __inline int reset_card_proc(PMINI_ADAPTER ps_adapter)
985 int retval = STATUS_SUCCESS;
987 #ifndef BCM_SHM_INTERFACE
988 PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
989 PS_INTERFACE_ADAPTER psIntfAdapter = NULL;
990 unsigned int value = 0, uiResetValue = 0;
992 psIntfAdapter = ((PS_INTERFACE_ADAPTER)(ps_adapter->pvInterfaceAdapter)) ;
994 ps_adapter->bDDRInitDone = FALSE;
996 if(ps_adapter->chip_id >= T3LPB)
998 //SYS_CFG register is write protected hence for modifying this reg value, it should be read twice before
999 rdmalt(ps_adapter,SYS_CFG, &value, sizeof(value));
1000 rdmalt(ps_adapter,SYS_CFG, &value, sizeof(value));
1002 //making bit[6...5] same as was before f/w download. this setting force the h/w to
1003 //re-populated the SP RAM area with the string descriptor .
1004 value = value | (ps_adapter->syscfgBefFwDld & 0x00000060) ;
1005 wrmalt(ps_adapter, SYS_CFG, &value, sizeof(value));
1008 #ifndef BCM_SHM_INTERFACE
1009 //killing all submitted URBs.
1010 psIntfAdapter->psAdapter->StopAllXaction = TRUE ;
1011 Bcm_kill_all_URBs(psIntfAdapter);
1013 /* Reset the UMA-B Device */
1014 if(ps_adapter->chip_id >= T3LPB)
1016 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Reseting UMA-B \n");
1017 retval = usb_reset_device(psIntfAdapter->udev);
1019 psIntfAdapter->psAdapter->StopAllXaction = FALSE ;
1021 if(retval != STATUS_SUCCESS)
1023 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Reset failed with ret value :%d", retval);
1026 if (ps_adapter->chip_id == BCS220_2 ||
1027 ps_adapter->chip_id == BCS220_2BC ||
1028 ps_adapter->chip_id == BCS250_BC ||
1029 ps_adapter->chip_id == BCS220_3)
1031 retval = rdmalt(ps_adapter,HPM_CONFIG_LDO145, &value, sizeof(value));
1034 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"read failed with status :%d",retval);
1039 retval = wrmalt(ps_adapter, HPM_CONFIG_LDO145, &value, sizeof(value));
1042 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"write failed with status :%d",retval);
1050 retval = rdmalt(ps_adapter,0x0f007018, &value, sizeof(value));
1052 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"read failed with status :%d",retval);
1056 retval= wrmalt(ps_adapter, 0x0f007018, &value, sizeof(value)) ;
1058 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"write failed with status :%d",retval);
1062 // Toggling the GPIO 8, 9
1064 retval = wrmalt(ps_adapter, GPIO_OUTPUT_REGISTER, &value, sizeof(value));
1066 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"write failed with status :%d",retval);
1070 retval = wrmalt(ps_adapter, GPIO_MODE_REGISTER, &value, sizeof(value)) ;
1072 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"write failed with status :%d",retval);
1078 //ps_adapter->downloadDDR = false;
1080 if(ps_adapter->bFlashBoot)
1082 //In flash boot mode MIPS state register has reverse polarity.
1083 // So just or with setting bit 30.
1084 //Make the MIPS in Reset state.
1085 rdmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &uiResetValue, sizeof(uiResetValue));
1087 uiResetValue |=(1<<30);
1088 wrmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &uiResetValue, sizeof(uiResetValue));
1091 if(ps_adapter->chip_id >= T3LPB)
1095 // WA for SYSConfig Issue.
1096 // Read SYSCFG Twice to make it writable.
1098 rdmalt(ps_adapter, SYS_CFG, &uiResetValue, sizeof(uiResetValue));
1099 if(uiResetValue & (1<<4))
1102 rdmalt(ps_adapter, SYS_CFG, &uiResetValue, sizeof(uiResetValue));//2nd read to make it writable.
1103 uiResetValue &= (~(1<<4));
1104 wrmalt(ps_adapter,SYS_CFG, &uiResetValue, sizeof(uiResetValue));
1109 wrmalt(ps_adapter, 0x0f01186c, &uiResetValue, sizeof(uiResetValue));
1112 psIntfAdapter->psAdapter->StopAllXaction = FALSE ;
1117 __inline int run_card_proc(PMINI_ADAPTER ps_adapter )
1119 unsigned int value=0;
1122 if(rdmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &value, sizeof(value)) < 0) {
1123 BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"%s:%d\n", __FUNCTION__, __LINE__);
1124 return STATUS_FAILURE;
1127 if(ps_adapter->bFlashBoot)
1137 if(wrmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &value, sizeof(value)) < 0) {
1138 BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"%s:%d\n", __FUNCTION__, __LINE__);
1139 return STATUS_FAILURE;
1142 return STATUS_SUCCESS;
1145 int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter)
1148 UINT status = STATUS_SUCCESS;
1150 #ifdef BCM_SHM_INTERFACE
1151 unsigned char *pConfigFileAddr = (unsigned char *)CPE_MACXVI_CFG_ADDR;
1154 * Create the threads first and then download the
1155 * Firm/DDR Settings..
1158 if((status = create_worker_threads(ps_adapter))<0)
1160 BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Cannot create thread");
1164 * For Downloading the Firm, parse the cfg file first.
1166 status = bcm_parse_target_params (ps_adapter);
1171 #ifndef BCM_SHM_INTERFACE
1172 if(ps_adapter->chip_id >= T3LPB)
1174 rdmalt(ps_adapter, SYS_CFG, &value, sizeof (value));
1175 ps_adapter->syscfgBefFwDld = value ;
1176 if((value & 0x60)== 0)
1178 ps_adapter->bFlashBoot = TRUE;
1182 reset_card_proc(ps_adapter);
1184 //Initializing the NVM.
1185 BcmInitNVM(ps_adapter);
1186 status = ddr_init(ps_adapter);
1189 BCM_DEBUG_PRINT (ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "ddr_init Failed\n");
1193 /* Download cfg file */
1194 status = buffDnldVerify(ps_adapter,
1195 (PUCHAR)ps_adapter->pstargetparams,
1196 sizeof(STARGETPARAMS),
1200 BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Error downloading CFG file");
1203 BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "CFG file downloaded");
1205 if(register_networkdev(ps_adapter))
1207 BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Register Netdevice failed. Cleanup needs to be performed.");
1211 if(FALSE == ps_adapter->AutoFirmDld)
1213 BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "AutoFirmDld Disabled in CFG File..\n");
1214 //If Auto f/w download is disable, register the control interface,
1215 //register the control interface after the mailbox.
1216 if(register_control_device_interface(ps_adapter) < 0)
1218 BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Register Control Device failed. Cleanup needs to be performed.");
1222 return STATUS_SUCCESS;
1226 * Do the LED Settings here. It will be used by the Firmware Download
1231 * 1. If the LED Settings fails, do not stop and do the Firmware download.
1232 * 2. This init would happend only if the cfg file is present, else
1233 * call from the ioctl context.
1236 status = InitLedSettings (ps_adapter);
1240 BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_PRINTK, 0, 0,"INIT LED FAILED\n");
1243 if(ps_adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY)
1245 ps_adapter->DriverState = DRIVER_INIT;
1246 wake_up(&ps_adapter->LEDInfo.notify_led_event);
1249 if(ps_adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY)
1251 ps_adapter->DriverState = FW_DOWNLOAD;
1252 wake_up(&ps_adapter->LEDInfo.notify_led_event);
1256 wrmalt(ps_adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 4, &value, sizeof(value));
1257 wrmalt(ps_adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 8, &value, sizeof(value));
1259 if(ps_adapter->eNVMType == NVM_FLASH)
1261 status = PropagateCalParamsFromFlashToMemory(ps_adapter);
1264 BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL," Propogation of Cal param failed .." );
1269 else if(psAdapter->eNVMType == NVM_EEPROM)
1271 PropagateCalParamsFromEEPROMToMemory();
1275 /* Download Firmare */
1276 if ((status = BcmFileDownload( ps_adapter, BIN_FILE, FIRMWARE_BEGIN_ADDR)))
1278 BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "No Firmware File is present... \n");
1282 BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "BIN file downloaded");
1283 status = run_card_proc(ps_adapter);
1286 BCM_DEBUG_PRINT (ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "run_card_proc Failed\n");
1291 ps_adapter->fw_download_done = TRUE;
1295 if(ps_adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY)
1297 ps_adapter->DriverState = FW_DOWNLOAD_DONE;
1298 wake_up(&ps_adapter->LEDInfo.notify_led_event);
1303 ps_adapter->bDDRInitDone = TRUE;
1304 //Initializing the NVM.
1305 BcmInitNVM(ps_adapter);
1307 //Propagating the cal param from Flash to DDR
1309 wrmalt(ps_adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 4, &value, sizeof(value));
1310 wrmalt(ps_adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 8, &value, sizeof(value));
1312 if(ps_adapter->eNVMType == NVM_FLASH)
1314 status = PropagateCalParamsFromFlashToMemory(ps_adapter);
1317 printk("\nPropogation of Cal param from flash to DDR failed ..\n" );
1321 //Copy config file param to DDR.
1322 memcpy(pConfigFileAddr,ps_adapter->pstargetparams, sizeof(STARGETPARAMS));
1324 if(register_networkdev(ps_adapter))
1326 BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Register Netdevice failed. Cleanup needs to be performed.");
1331 status = InitLedSettings (ps_adapter);
1334 BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_PRINTK, 0, 0,"INIT LED FAILED\n");
1339 if(register_control_device_interface(ps_adapter) < 0)
1341 BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Register Control Device failed. Cleanup needs to be performed.");
1345 ps_adapter->fw_download_done = TRUE;
1351 int bcm_parse_target_params(PMINI_ADAPTER Adapter)
1353 #ifdef BCM_SHM_INTERFACE
1354 extern void read_cfg_file(PMINI_ADAPTER Adapter);
1356 struct file *flp=NULL;
1357 mm_segment_t oldfs={0};
1362 buff=(PCHAR)kmalloc(BUFFER_1K, GFP_KERNEL);
1367 if((Adapter->pstargetparams =
1368 kmalloc(sizeof(STARGETPARAMS), GFP_KERNEL)) == NULL)
1373 flp=open_firmware_file(Adapter, CFG_FILE);
1375 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "NOT ABLE TO OPEN THE %s FILE \n", CFG_FILE);
1377 bcm_kfree(Adapter->pstargetparams);
1378 Adapter->pstargetparams = NULL;
1381 oldfs=get_fs(); set_fs(get_ds());
1382 len=vfs_read(flp, buff, BUFFER_1K, &pos);
1385 if(len != sizeof(STARGETPARAMS))
1387 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Mismatch in Target Param Structure!\n");
1389 bcm_kfree(Adapter->pstargetparams);
1390 Adapter->pstargetparams = NULL;
1391 filp_close(flp, current->files);
1394 filp_close(flp, current->files);
1396 /* Check for autolink in config params */
1398 * Values in Adapter->pstargetparams are in network byte order
1400 memcpy(Adapter->pstargetparams, buff, sizeof(STARGETPARAMS));
1402 beceem_parse_target_struct(Adapter);
1403 #ifdef BCM_SHM_INTERFACE
1404 read_cfg_file(Adapter);
1407 return STATUS_SUCCESS;
1410 void beceem_parse_target_struct(PMINI_ADAPTER Adapter)
1412 UINT uiHostDrvrCfg6 =0, uiEEPROMFlag = 0;;
1414 if(ntohl(Adapter->pstargetparams->m_u32PhyParameter2) & AUTO_SYNC_DISABLE)
1416 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "AutoSyncup is Disabled\n");
1417 Adapter->AutoSyncup = FALSE;
1421 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "AutoSyncup is Enabled\n");
1422 Adapter->AutoSyncup = TRUE;
1424 if(ntohl(Adapter->pstargetparams->HostDrvrConfig6) & AUTO_LINKUP_ENABLE)
1426 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Enabling autolink up");
1427 Adapter->AutoLinkUp = TRUE;
1431 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Disabling autolink up");
1432 Adapter->AutoLinkUp = FALSE;
1434 // Setting the DDR Setting..
1435 Adapter->DDRSetting =
1436 (ntohl(Adapter->pstargetparams->HostDrvrConfig6) >>8)&0x0F;
1437 Adapter->ulPowerSaveMode =
1438 (ntohl(Adapter->pstargetparams->HostDrvrConfig6)>>12)&0x0F;
1440 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "DDR Setting: %x\n", Adapter->DDRSetting);
1441 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT,DBG_LVL_ALL, "Power Save Mode: %lx\n",
1442 Adapter->ulPowerSaveMode);
1443 if(ntohl(Adapter->pstargetparams->HostDrvrConfig6) & AUTO_FIRM_DOWNLOAD)
1445 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Enabling Auto Firmware Download\n");
1446 Adapter->AutoFirmDld = TRUE;
1450 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Disabling Auto Firmware Download\n");
1451 Adapter->AutoFirmDld = FALSE;
1453 uiHostDrvrCfg6 = ntohl(Adapter->pstargetparams->HostDrvrConfig6);
1454 Adapter->bMipsConfig = (uiHostDrvrCfg6>>20)&0x01;
1455 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"MIPSConfig : 0x%X\n",Adapter->bMipsConfig);
1456 //used for backward compatibility.
1457 Adapter->bDPLLConfig = (uiHostDrvrCfg6>>19)&0x01;
1459 Adapter->PmuMode= (uiHostDrvrCfg6 >> 24 ) & 0x03;
1460 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "PMU MODE: %x", Adapter->PmuMode);
1462 if((uiHostDrvrCfg6 >> HOST_BUS_SUSPEND_BIT ) & (0x01))
1464 Adapter->bDoSuspend = TRUE;
1465 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Making DoSuspend TRUE as per configFile");
1468 uiEEPROMFlag = ntohl(Adapter->pstargetparams->m_u32EEPROMFlag);
1469 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "uiEEPROMFlag : 0x%X\n",uiEEPROMFlag);
1470 Adapter->eNVMType = (NVM_TYPE)((uiEEPROMFlag>>4)&0x3);
1473 Adapter->bStatusWrite = (uiEEPROMFlag>>6)&0x1;
1474 //printk(("bStatusWrite : 0x%X\n", Adapter->bStatusWrite));
1476 Adapter->uiSectorSizeInCFG = 1024*(0xFFFF & ntohl(Adapter->pstargetparams->HostDrvrConfig4));
1477 //printk(("uiSectorSize : 0x%X\n", Adapter->uiSectorSizeInCFG));
1479 Adapter->bSectorSizeOverride =(bool) ((ntohl(Adapter->pstargetparams->HostDrvrConfig4))>>16)&0x1;
1480 //printk(MP_INIT,("bSectorSizeOverride : 0x%X\n",Adapter->bSectorSizeOverride));
1482 if(ntohl(Adapter->pstargetparams->m_u32PowerSavingModeOptions) &0x01)
1483 Adapter->ulPowerSaveMode = DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE;
1484 //autocorrection part
1485 if(Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE)
1486 doPowerAutoCorrection(Adapter);
1490 VOID doPowerAutoCorrection(PMINI_ADAPTER psAdapter)
1492 UINT reporting_mode = 0;
1494 reporting_mode = ntohl(psAdapter->pstargetparams->m_u32PowerSavingModeOptions) &0x02 ;
1495 psAdapter->bIsAutoCorrectEnabled = !((char)(psAdapter->ulPowerSaveMode >> 3) & 0x1);
1497 if(reporting_mode == TRUE)
1499 BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"can't do suspen/resume as reporting mode is enable");
1500 psAdapter->bDoSuspend = FALSE;
1503 if (psAdapter->bIsAutoCorrectEnabled && (psAdapter->chip_id >= T3LPB))
1505 //If reporting mode is enable, switch PMU to PMC
1507 if(reporting_mode == FALSE)
1509 psAdapter->ulPowerSaveMode = DEVICE_POWERSAVE_MODE_AS_PMU_SHUTDOWN;
1510 psAdapter->bDoSuspend = TRUE;
1511 BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"PMU selected ....");
1517 psAdapter->ulPowerSaveMode = DEVICE_POWERSAVE_MODE_AS_PMU_CLOCK_GATING;
1518 psAdapter->bDoSuspend =FALSE;
1519 BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"PMC selected..");
1523 //clearing space bit[15..12]
1524 psAdapter->pstargetparams->HostDrvrConfig6 &= ~(htonl((0xF << 12)));
1525 //placing the power save mode option
1526 psAdapter->pstargetparams->HostDrvrConfig6 |= htonl((psAdapter->ulPowerSaveMode << 12));
1529 else if (psAdapter->bIsAutoCorrectEnabled == FALSE)
1532 // remove the autocorrect disable bit set before dumping.
1533 psAdapter->ulPowerSaveMode &= ~(1 << 3);
1534 psAdapter->pstargetparams->HostDrvrConfig6 &= ~(htonl(1 << 15));
1535 BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Using Forced User Choice: %lx\n", psAdapter->ulPowerSaveMode);
1538 unsigned char *ReadMacAddrEEPROM(PMINI_ADAPTER Adapter, ulong dwAddress)
1540 unsigned char *pucmacaddr = NULL;
1541 int status = 0, i=0;
1542 unsigned int temp =0;
1545 pucmacaddr = (unsigned char *)kmalloc(MAC_ADDRESS_SIZE, GFP_KERNEL);
1548 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "No Buffers to Read the EEPROM Address\n");
1552 dwAddress |= 0x5b000000;
1553 status = wrmalt(Adapter, EEPROM_COMMAND_Q_REG,
1554 (PUINT)&dwAddress, sizeof(UINT));
1555 if(status != STATUS_SUCCESS)
1557 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "wrm Failed..\n");
1558 bcm_kfree(pucmacaddr);
1562 for(i=0;i<MAC_ADDRESS_SIZE;i++)
1564 status = rdmalt(Adapter, EEPROM_READ_DATA_Q_REG, &temp,sizeof(temp));
1565 if(status != STATUS_SUCCESS)
1567 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "rdm Failed..\n");
1568 bcm_kfree(pucmacaddr);
1572 pucmacaddr[i] = temp & 0xff;
1573 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"%x \n", pucmacaddr[i]);
1580 INT ReadMacAddressFromEEPROM(PMINI_ADAPTER Adapter)
1582 unsigned char *puMacAddr = NULL;
1585 puMacAddr = ReadMacAddrEEPROM(Adapter,0x200);
1588 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Couldn't retrieve the Mac Address\n");
1589 return STATUS_FAILURE;
1593 if((puMacAddr[0] == 0x0 && puMacAddr[1] == 0x0 &&
1594 puMacAddr[2] == 0x0 && puMacAddr[3] == 0x0 &&
1595 puMacAddr[4] == 0x0 && puMacAddr[5] == 0x0) ||
1596 (puMacAddr[0] == 0xFF && puMacAddr[1] == 0xFF &&
1597 puMacAddr[2] == 0xFF && puMacAddr[3] == 0xFF &&
1598 puMacAddr[4] == 0xFF && puMacAddr[5] == 0xFF))
1600 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Invalid Mac Address\n");
1601 bcm_kfree(puMacAddr);
1602 return STATUS_FAILURE;
1604 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "The Mac Address received is: \n");
1605 memcpy(Adapter->dev->dev_addr, puMacAddr, MAC_ADDRESS_SIZE);
1606 for(i=0;i<MAC_ADDRESS_SIZE;i++)
1608 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"%02x ", Adapter->dev->dev_addr[i]);
1610 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"\n");
1611 bcm_kfree(puMacAddr);
1613 return STATUS_SUCCESS;
1617 void convertEndian(B_UINT8 rwFlag, PUINT puiBuffer, UINT uiByteCount)
1621 if(RWM_WRITE == rwFlag) {
1622 for(uiIndex =0; uiIndex < (uiByteCount/sizeof(UINT)); uiIndex++) {
1623 puiBuffer[uiIndex] = htonl(puiBuffer[uiIndex]);
1626 for(uiIndex =0; uiIndex < (uiByteCount/sizeof(UINT)); uiIndex++) {
1627 puiBuffer[uiIndex] = ntohl(puiBuffer[uiIndex]);
1632 #define CACHE_ADDRESS_MASK 0x80000000
1633 #define UNCACHE_ADDRESS_MASK 0xa0000000
1635 int rdm(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize)
1639 #ifndef BCM_SHM_INTERFACE
1640 uiRetVal = Adapter->interface_rdm(Adapter->pvInterfaceAdapter,
1641 uiAddress, pucBuff, sSize);
1648 uiRetVal = STATUS_SUCCESS;
1649 if(uiAddress & 0x10000000) {
1650 // DDR Memory Access
1651 uiAddress |= CACHE_ADDRESS_MASK;
1652 memcpy(pucBuff,(unsigned char *)uiAddress ,sSize);
1655 // Register, SPRAM, Flash
1656 uiAddress |= UNCACHE_ADDRESS_MASK;
1657 if ((uiAddress & FLASH_ADDR_MASK) == (FLASH_CONTIGIOUS_START_ADDR_BCS350 & FLASH_ADDR_MASK))
1659 #if defined(FLASH_DIRECT_ACCESS)
1660 memcpy(pucBuff,(unsigned char *)uiAddress ,sSize);
1662 printk("\nInvalid GSPI ACCESS :Addr :%#X", uiAddress);
1663 uiRetVal = STATUS_FAILURE;
1666 else if(((unsigned int )uiAddress & 0x3) ||
1667 ((unsigned int )pucBuff & 0x3) ||
1668 ((unsigned int )sSize & 0x3)) {
1669 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"rdmalt :unalligned register access uiAddress = %x,pucBuff = %x size = %x\n",(unsigned int )uiAddress,(unsigned int )pucBuff,(unsigned int )sSize);
1670 uiRetVal = STATUS_FAILURE;
1673 for (indx=0;indx<sSize;indx+=4){
1674 *(PUINT)(pucBuff + indx) = *(PUINT)(uiAddress + indx);
1681 int wrm(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize)
1685 #ifndef BCM_SHM_INTERFACE
1686 iRetVal = Adapter->interface_wrm(Adapter->pvInterfaceAdapter,
1687 uiAddress, pucBuff, sSize);
1691 if(uiAddress & 0x10000000) {
1692 // DDR Memory Access
1693 uiAddress |= CACHE_ADDRESS_MASK;
1694 memcpy((unsigned char *)(uiAddress),pucBuff,sSize);
1697 // Register, SPRAM, Flash
1698 uiAddress |= UNCACHE_ADDRESS_MASK;
1700 if(((unsigned int )uiAddress & 0x3) ||
1701 ((unsigned int )pucBuff & 0x3) ||
1702 ((unsigned int )sSize & 0x3)) {
1703 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"wrmalt: unalligned register access uiAddress = %x,pucBuff = %x size = %x\n",(unsigned int )uiAddress,(unsigned int )pucBuff,(unsigned int )sSize);
1704 iRetVal = STATUS_FAILURE;
1707 for (indx=0;indx<sSize;indx+=4) {
1708 *(PUINT)(uiAddress + indx) = *(PUINT)(pucBuff + indx);
1712 iRetVal = STATUS_SUCCESS;
1718 int wrmalt (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size)
1720 convertEndian(RWM_WRITE, pucBuff, size);
1721 return wrm(Adapter, uiAddress, (PUCHAR)pucBuff, size);
1724 int rdmalt (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size)
1728 uiRetVal = rdm(Adapter,uiAddress,(PUCHAR)pucBuff,size);
1729 convertEndian(RWM_READ, (PUINT)pucBuff, size);
1734 int rdmWithLock(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize)
1737 INT status = STATUS_SUCCESS ;
1738 down(&Adapter->rdmwrmsync);
1740 if((Adapter->IdleMode == TRUE) ||
1741 (Adapter->bShutStatus ==TRUE) ||
1742 (Adapter->bPreparingForLowPowerMode ==TRUE))
1748 status = rdm(Adapter, uiAddress, pucBuff, sSize);
1751 up(&Adapter->rdmwrmsync);
1754 int wrmWithLock(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize)
1756 INT status = STATUS_SUCCESS ;
1757 down(&Adapter->rdmwrmsync);
1759 if((Adapter->IdleMode == TRUE) ||
1760 (Adapter->bShutStatus ==TRUE) ||
1761 (Adapter->bPreparingForLowPowerMode ==TRUE))
1767 status =wrm(Adapter, uiAddress, pucBuff, sSize);
1770 up(&Adapter->rdmwrmsync);
1774 int wrmaltWithLock (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size)
1776 int iRetVal = STATUS_SUCCESS;
1778 down(&Adapter->rdmwrmsync);
1780 if((Adapter->IdleMode == TRUE) ||
1781 (Adapter->bShutStatus ==TRUE) ||
1782 (Adapter->bPreparingForLowPowerMode ==TRUE))
1788 iRetVal = wrmalt(Adapter,uiAddress,pucBuff,size);
1791 up(&Adapter->rdmwrmsync);
1795 int rdmaltWithLock (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size)
1797 INT uiRetVal =STATUS_SUCCESS;
1799 down(&Adapter->rdmwrmsync);
1801 if((Adapter->IdleMode == TRUE) ||
1802 (Adapter->bShutStatus ==TRUE) ||
1803 (Adapter->bPreparingForLowPowerMode ==TRUE))
1809 uiRetVal = rdmalt(Adapter,uiAddress, pucBuff, size);
1812 up(&Adapter->rdmwrmsync);
1817 VOID HandleShutDownModeWakeup(PMINI_ADAPTER Adapter)
1819 int clear_abort_pattern = 0,Status = 0;
1820 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "====>\n");
1821 //target has woken up From Shut Down
1822 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "Clearing Shut Down Software abort pattern\n");
1823 Status = wrmalt(Adapter,SW_ABORT_IDLEMODE_LOC, (PUINT)&clear_abort_pattern, sizeof(clear_abort_pattern));
1826 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL,"WRM to SW_ABORT_IDLEMODE_LOC failed with err:%d", Status);
1829 if(Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE)
1832 InterfaceHandleShutdownModeWakeup(Adapter);
1835 if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY)
1837 Adapter->DriverState = NO_NETWORK_ENTRY;
1838 wake_up(&Adapter->LEDInfo.notify_led_event);
1841 Adapter->bTriedToWakeUpFromlowPowerMode = FALSE;
1842 Adapter->bShutStatus = FALSE;
1843 wake_up(&Adapter->lowpower_mode_wait_queue);
1844 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "<====\n");
1847 VOID SendShutModeResponse(PMINI_ADAPTER Adapter)
1849 CONTROL_MESSAGE stShutdownResponse;
1850 UINT NVMAccess = 0,lowPwrAbortMsg = 0;
1853 memset (&stShutdownResponse, 0, sizeof(CONTROL_MESSAGE));
1854 stShutdownResponse.Leader.Status = LINK_UP_CONTROL_REQ;
1855 stShutdownResponse.Leader.PLength = 8;//8 bytes;
1856 stShutdownResponse.szData[0] = LINK_UP_ACK;
1857 stShutdownResponse.szData[1] = LINK_SHUTDOWN_REQ_FROM_FIRMWARE;
1859 /*********************************
1861 ** if [ semaphore is available ]
1862 ** acquire semaphone and return value 0 ;
1864 ** return non-zero value ;
1866 ***********************************/
1868 NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock);
1870 lowPwrAbortMsg= down_trylock(&Adapter->LowPowerModeSync);
1873 if(NVMAccess || lowPwrAbortMsg|| atomic_read(&Adapter->TotalPacketCount))
1876 up(&Adapter->NVMRdmWrmLock);
1879 up(&Adapter->LowPowerModeSync);
1881 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "Device Access is going on NACK the Shut Down MODE\n");
1882 stShutdownResponse.szData[2] = SHUTDOWN_NACK_FROM_DRIVER;//NACK- device access is going on.
1883 Adapter->bPreparingForLowPowerMode = FALSE;
1887 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "Sending SHUTDOWN MODE ACK\n");
1888 stShutdownResponse.szData[2] = SHUTDOWN_ACK_FROM_DRIVER;//ShutDown ACK
1890 /* Wait for the LED to TURN OFF before sending ACK response */
1891 if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY)
1895 /* Wake the LED Thread with LOWPOWER_MODE_ENTER State */
1896 Adapter->DriverState = LOWPOWER_MODE_ENTER;
1897 wake_up(&Adapter->LEDInfo.notify_led_event);
1899 /* Wait for 1 SEC for LED to OFF */
1900 iRetVal = wait_event_timeout(Adapter->LEDInfo.idleModeSyncEvent,\
1901 Adapter->LEDInfo.bIdle_led_off, msecs_to_jiffies(1000));
1903 /* If Timed Out to Sync IDLE MODE Enter, do IDLE mode Exit and Send NACK to device */
1906 stShutdownResponse.szData[1] = SHUTDOWN_NACK_FROM_DRIVER;//NACK- device access is going on.
1908 Adapter->DriverState = NO_NETWORK_ENTRY;
1909 wake_up(&Adapter->LEDInfo.notify_led_event);
1913 if(stShutdownResponse.szData[2] == SHUTDOWN_ACK_FROM_DRIVER)
1915 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL,"ACKING SHUTDOWN MODE !!!!!!!!!");
1916 down(&Adapter->rdmwrmsync);
1917 Adapter->bPreparingForLowPowerMode = TRUE;
1918 up(&Adapter->rdmwrmsync);
1920 #ifndef BCM_SHM_INTERFACE
1921 if(Adapter->bDoSuspend == TRUE)
1922 Bcm_kill_all_URBs((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter));
1927 Adapter->bPreparingForLowPowerMode = FALSE;
1931 up(&Adapter->NVMRdmWrmLock);
1934 up(&Adapter->LowPowerModeSync);
1936 Status = CopyBufferToControlPacket(Adapter,&stShutdownResponse);
1937 if((Status != STATUS_SUCCESS))
1939 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL,"fail to send the Idle mode Request \n");
1940 Adapter->bPreparingForLowPowerMode = FALSE;
1942 #ifndef BCM_SHM_INTERFACE
1943 StartInterruptUrb((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter));
1949 void HandleShutDownModeRequest(PMINI_ADAPTER Adapter,PUCHAR pucBuffer)
1951 B_UINT32 uiResetValue = 0;
1953 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "====>\n");
1955 if(*(pucBuffer+1) == COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW)
1957 HandleShutDownModeWakeup(Adapter);
1959 else if(*(pucBuffer+1) == LINK_SHUTDOWN_REQ_FROM_FIRMWARE)
1961 //Target wants to go to Shut Down Mode
1962 //InterfacePrepareForShutdown(Adapter);
1963 if(Adapter->chip_id == BCS220_2 ||
1964 Adapter->chip_id == BCS220_2BC ||
1965 Adapter->chip_id == BCS250_BC ||
1966 Adapter->chip_id == BCS220_3)
1968 rdmalt(Adapter,HPM_CONFIG_MSW, &uiResetValue, 4);
1969 uiResetValue |= (1<<17);
1970 wrmalt(Adapter, HPM_CONFIG_MSW, &uiResetValue, 4);
1973 SendShutModeResponse(Adapter);
1974 BCM_DEBUG_PRINT (Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL,"ShutDownModeResponse:Notification received: Sending the response(Ack/Nack)\n");
1977 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "<====\n");
1982 VOID ResetCounters(PMINI_ADAPTER Adapter)
1985 beceem_protocol_reset(Adapter);
1987 Adapter->CurrNumRecvDescs = 0;
1988 Adapter->PrevNumRecvDescs = 0;
1989 Adapter->LinkUpStatus = 0;
1990 Adapter->LinkStatus = 0;
1991 atomic_set(&Adapter->cntrlpktCnt,0);
1992 atomic_set (&Adapter->TotalPacketCount,0);
1993 Adapter->fw_download_done=FALSE;
1994 Adapter->LinkStatus = 0;
1995 Adapter->AutoLinkUp = FALSE;
1996 Adapter->IdleMode = FALSE;
1997 Adapter->bShutStatus = FALSE;
2000 S_CLASSIFIER_RULE *GetFragIPClsEntry(PMINI_ADAPTER Adapter,USHORT usIpIdentification,ULONG SrcIP)
2003 for(uiIndex=0;uiIndex<MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES;uiIndex++)
2005 if((Adapter->astFragmentedPktClassifierTable[uiIndex].bUsed)&&
2006 (Adapter->astFragmentedPktClassifierTable[uiIndex].usIpIdentification == usIpIdentification)&&
2007 (Adapter->astFragmentedPktClassifierTable[uiIndex].ulSrcIpAddress== SrcIP)&&
2008 !Adapter->astFragmentedPktClassifierTable[uiIndex].bOutOfOrderFragment)
2009 return Adapter->astFragmentedPktClassifierTable[uiIndex].pstMatchedClassifierEntry;
2014 void AddFragIPClsEntry(PMINI_ADAPTER Adapter,PS_FRAGMENTED_PACKET_INFO psFragPktInfo)
2017 for(uiIndex=0;uiIndex<MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES;uiIndex++)
2019 if(!Adapter->astFragmentedPktClassifierTable[uiIndex].bUsed)
2021 memcpy(&Adapter->astFragmentedPktClassifierTable[uiIndex],psFragPktInfo,sizeof(S_FRAGMENTED_PACKET_INFO));
2028 void DelFragIPClsEntry(PMINI_ADAPTER Adapter,USHORT usIpIdentification,ULONG SrcIp)
2031 for(uiIndex=0;uiIndex<MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES;uiIndex++)
2033 if((Adapter->astFragmentedPktClassifierTable[uiIndex].bUsed)&&
2034 (Adapter->astFragmentedPktClassifierTable[uiIndex].usIpIdentification == usIpIdentification)&&
2035 (Adapter->astFragmentedPktClassifierTable[uiIndex].ulSrcIpAddress== SrcIp))
2036 memset(&Adapter->astFragmentedPktClassifierTable[uiIndex],0,sizeof(S_FRAGMENTED_PACKET_INFO));
2040 void update_per_cid_rx (PMINI_ADAPTER Adapter)
2044 if((jiffies - Adapter->liDrainCalculated) < XSECONDS)
2047 for(qindex = 0; qindex < HiPriority; qindex++)
2049 if(Adapter->PackInfo[qindex].ucDirection == 0)
2051 Adapter->PackInfo[qindex].uiCurrentRxRate =
2052 (Adapter->PackInfo[qindex].uiCurrentRxRate +
2053 Adapter->PackInfo[qindex].uiThisPeriodRxBytes)/2;
2055 Adapter->PackInfo[qindex].uiThisPeriodRxBytes = 0;
2059 Adapter->PackInfo[qindex].uiCurrentDrainRate =
2060 (Adapter->PackInfo[qindex].uiCurrentDrainRate +
2061 Adapter->PackInfo[qindex].uiThisPeriodSentBytes)/2;
2063 Adapter->PackInfo[qindex].uiThisPeriodSentBytes=0;
2066 Adapter->liDrainCalculated=jiffies;
2068 void update_per_sf_desc_cnts( PMINI_ADAPTER Adapter)
2071 u32 uibuff[MAX_TARGET_DSX_BUFFERS];
2073 if(!atomic_read (&Adapter->uiMBupdate))
2076 #ifdef BCM_SHM_INTERFACE
2077 if(rdmalt(Adapter, TARGET_SFID_TXDESC_MAP_LOC, (PUINT)uibuff, sizeof(UINT) * MAX_TARGET_DSX_BUFFERS)<0)
2079 if(rdmaltWithLock(Adapter, TARGET_SFID_TXDESC_MAP_LOC, (PUINT)uibuff, sizeof(UINT) * MAX_TARGET_DSX_BUFFERS)<0)
2082 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "rdm failed\n");
2085 for(iIndex = 0;iIndex < HiPriority; iIndex++)
2087 if(Adapter->PackInfo[iIndex].bValid && Adapter->PackInfo[iIndex].ucDirection)
2089 if(Adapter->PackInfo[iIndex].usVCID_Value < MAX_TARGET_DSX_BUFFERS)
2091 atomic_set(&Adapter->PackInfo[iIndex].uiPerSFTxResourceCount, uibuff[Adapter->PackInfo[iIndex].usVCID_Value]);
2095 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Invalid VCID : %x \n",
2096 Adapter->PackInfo[iIndex].usVCID_Value);
2100 atomic_set (&Adapter->uiMBupdate, FALSE);
2103 void flush_queue(PMINI_ADAPTER Adapter, UINT iQIndex)
2105 struct sk_buff* PacketToDrop=NULL;
2106 struct net_device_stats* netstats=NULL;
2108 netstats = &((PLINUX_DEP_DATA)Adapter->pvOsDepData)->netstats;
2110 spin_lock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock);
2112 while(Adapter->PackInfo[iQIndex].FirstTxQueue &&
2113 atomic_read(&Adapter->TotalPacketCount))
2115 PacketToDrop = Adapter->PackInfo[iQIndex].FirstTxQueue;
2116 if(PacketToDrop && PacketToDrop->len)
2118 netstats->tx_dropped++;
2119 DEQUEUEPACKET(Adapter->PackInfo[iQIndex].FirstTxQueue, \
2120 Adapter->PackInfo[iQIndex].LastTxQueue);
2122 Adapter->PackInfo[iQIndex].uiCurrentPacketsOnHost--;
2123 Adapter->PackInfo[iQIndex].uiCurrentBytesOnHost -= PacketToDrop->len;
2125 //Adding dropped statistics
2126 Adapter->PackInfo[iQIndex].uiDroppedCountBytes += PacketToDrop->len;
2127 Adapter->PackInfo[iQIndex].uiDroppedCountPackets++;
2129 bcm_kfree_skb(PacketToDrop);
2130 atomic_dec(&Adapter->TotalPacketCount);
2131 atomic_inc(&Adapter->TxDroppedPacketCount);
2135 spin_unlock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock);
2139 void beceem_protocol_reset (PMINI_ADAPTER Adapter)
2143 if(NULL != Adapter->dev)
2145 netif_carrier_off(Adapter->dev);
2146 netif_stop_queue(Adapter->dev);
2149 Adapter->IdleMode = FALSE;
2150 Adapter->LinkUpStatus = FALSE;
2151 ClearTargetDSXBuffer(Adapter,0, TRUE);
2152 //Delete All Classifier Rules
2154 for(i = 0;i<HiPriority;i++)
2156 DeleteAllClassifiersForSF(Adapter,i);
2159 flush_all_queues(Adapter);
2161 if(Adapter->TimerActive == TRUE)
2162 Adapter->TimerActive = FALSE;
2164 memset(Adapter->astFragmentedPktClassifierTable, 0,
2165 sizeof(S_FRAGMENTED_PACKET_INFO) *
2166 MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES);
2168 for(i = 0;i<HiPriority;i++)
2170 //resetting only the first size (S_MIBS_SERVICEFLOW_TABLE) for the SF.
2171 // It is same between MIBs and SF.
2172 memset((PVOID)&Adapter->PackInfo[i],0,sizeof(S_MIBS_SERVICEFLOW_TABLE));
2178 #ifdef BCM_SHM_INTERFACE
2181 #define GET_GTB_DIFF(start, end) \
2182 ( (start) < (end) )? ( (end) - (start) ) : ( ~0x0 - ( (start) - (end)) +1 )
2184 void usdelay ( unsigned int a) {
2185 unsigned int start= *(unsigned int *)0xaf8051b4;
2186 unsigned int end = start+1;
2187 unsigned int diff = 0;
2190 end = *(unsigned int *)0xaf8051b4;
2191 diff = (GET_GTB_DIFF(start,end))/80;
2196 void read_cfg_file(PMINI_ADAPTER Adapter) {
2199 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Config File Version = 0x%x \n",Adapter->pstargetparams->m_u32CfgVersion );
2200 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Center Frequency = 0x%x \n",Adapter->pstargetparams->m_u32CenterFrequency );
2201 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Band A Scan = 0x%x \n",Adapter->pstargetparams->m_u32BandAScan );
2202 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Band B Scan = 0x%x \n",Adapter->pstargetparams->m_u32BandBScan );
2203 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Band C Scan = 0x%x \n",Adapter->pstargetparams->m_u32BandCScan );
2204 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"ERTPS Options = 0x%x \n",Adapter->pstargetparams->m_u32ErtpsOptions );
2205 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"PHS Enable = 0x%x \n",Adapter->pstargetparams->m_u32PHSEnable );
2206 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Handoff Enable = 0x%x \n",Adapter->pstargetparams->m_u32HoEnable );
2207 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HO Reserved1 = 0x%x \n",Adapter->pstargetparams->m_u32HoReserved1 );
2208 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HO Reserved2 = 0x%x \n",Adapter->pstargetparams->m_u32HoReserved2 );
2209 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"MIMO Enable = 0x%x \n",Adapter->pstargetparams->m_u32MimoEnable );
2210 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"PKMv2 Enable = 0x%x \n",Adapter->pstargetparams->m_u32SecurityEnable );
2211 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Powersaving Modes Enable = 0x%x \n",Adapter->pstargetparams->m_u32PowerSavingModesEnable );
2212 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Power Saving Mode Options = 0x%x \n",Adapter->pstargetparams->m_u32PowerSavingModeOptions );
2213 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"ARQ Enable = 0x%x \n",Adapter->pstargetparams->m_u32ArqEnable );
2214 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Harq Enable = 0x%x \n",Adapter->pstargetparams->m_u32HarqEnable );
2215 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"EEPROM Flag = 0x%x \n",Adapter->pstargetparams->m_u32EEPROMFlag );
2216 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Customize = 0x%x \n",Adapter->pstargetparams->m_u32Customize );
2217 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Bandwidth = 0x%x \n",Adapter->pstargetparams->m_u32ConfigBW );
2218 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"ShutDown Timer Value = 0x%x \n",Adapter->pstargetparams->m_u32ShutDownInitThresholdTimer );
2219 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"RadioParameter = 0x%x \n",Adapter->pstargetparams->m_u32RadioParameter );
2220 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"PhyParameter1 = 0x%x \n",Adapter->pstargetparams->m_u32PhyParameter1 );
2221 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"PhyParameter2 = 0x%x \n",Adapter->pstargetparams->m_u32PhyParameter2 );
2222 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"PhyParameter3 = 0x%x \n",Adapter->pstargetparams->m_u32PhyParameter3 );
2223 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"m_u32TestOptions = 0x%x \n",Adapter->pstargetparams->m_u32TestOptions );
2224 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"MaxMACDataperDLFrame = 0x%x \n",Adapter->pstargetparams->m_u32MaxMACDataperDLFrame );
2225 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"MaxMACDataperULFrame = 0x%x \n",Adapter->pstargetparams->m_u32MaxMACDataperULFrame );
2226 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Corr2MacFlags = 0x%x \n",Adapter->pstargetparams->m_u32Corr2MacFlags );
2227 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HostDrvrConfig1 = 0x%x \n",Adapter->pstargetparams->HostDrvrConfig1 );
2228 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HostDrvrConfig2 = 0x%x \n",Adapter->pstargetparams->HostDrvrConfig2 );
2229 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HostDrvrConfig3 = 0x%x \n",Adapter->pstargetparams->HostDrvrConfig3 );
2230 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HostDrvrConfig4 = 0x%x \n",Adapter->pstargetparams->HostDrvrConfig4 );
2231 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HostDrvrConfig5 = 0x%x \n",Adapter->pstargetparams->HostDrvrConfig5 );
2232 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HostDrvrConfig6 = 0x%x \n",Adapter->pstargetparams->HostDrvrConfig6 );
2233 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Segmented PUSC Enable = 0x%x \n",Adapter->pstargetparams->m_u32SegmentedPUSCenable );
2234 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"BamcEnable = 0x%x \n",Adapter->pstargetparams->m_u32BandAMCEnable );