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 = %p", 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
;
64 default_wimax_protocol_initialize(psAdapter
);
65 for (i
=0;i
<MAX_CNTRL_PKTS
;i
++)
67 psAdapter
->txctlpacket
[i
] = (char *)kmalloc(MAX_CNTL_PKT_SIZE
,
69 if(!psAdapter
->txctlpacket
[i
])
71 BCM_DEBUG_PRINT(psAdapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "No More Cntl pkts got, max got is %d", i
);
75 if(AllocAdapterDsxBuffer(psAdapter
))
77 BCM_DEBUG_PRINT(psAdapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Failed to allocate DSX buffers");
81 //Initialize PHS interface
82 if(phs_init(&psAdapter
->stBCMPhsContext
,psAdapter
)!=0)
84 BCM_DEBUG_PRINT(psAdapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
,"%s:%s:%d:Error PHS Init Failed=====>\n", __FILE__
, __FUNCTION__
, __LINE__
);
88 Status
= BcmAllocFlashCSStructure(psAdapter
);
91 BCM_DEBUG_PRINT(psAdapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
,"Memory Allocation for Flash structure failed");
95 Status
= vendorextnInit(psAdapter
);
97 if(STATUS_SUCCESS
!= Status
)
99 BCM_DEBUG_PRINT(psAdapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
,"Vendor Init Failed");
103 BCM_DEBUG_PRINT(psAdapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Adapter initialised");
106 return STATUS_SUCCESS
;
109 VOID
AdapterFree(PMINI_ADAPTER Adapter
)
113 beceem_protocol_reset(Adapter
);
115 vendorextnExit(Adapter
);
117 if(Adapter
->control_packet_handler
&& !IS_ERR(Adapter
->control_packet_handler
))
118 kthread_stop (Adapter
->control_packet_handler
);
120 if(Adapter
->transmit_packet_thread
&& !IS_ERR(Adapter
->transmit_packet_thread
))
121 kthread_stop (Adapter
->transmit_packet_thread
);
123 wake_up(&Adapter
->process_read_wait_queue
);
125 if(Adapter
->LEDInfo
.led_thread_running
& (BCM_LED_THREAD_RUNNING_ACTIVELY
| BCM_LED_THREAD_RUNNING_INACTIVELY
))
126 kthread_stop (Adapter
->LEDInfo
.led_cntrl_threadid
);
128 unregister_netdev(Adapter
->dev
);
130 /* FIXME: use proper wait_event and refcounting */
131 while(atomic_read(&Adapter
->ApplicationRunning
))
133 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Waiting for Application to close.. %d\n",atomic_read(&Adapter
->ApplicationRunning
));
136 unregister_control_device_interface(Adapter
);
138 kfree(Adapter
->pstargetparams
);
140 for (count
=0;count
< MAX_CNTRL_PKTS
;count
++)
141 kfree(Adapter
->txctlpacket
[count
]);
143 FreeAdapterDsxBuffer(Adapter
);
145 kfree(Adapter
->pvInterfaceAdapter
);
147 //Free the PHS Interface
148 PhsCleanup(&Adapter
->stBCMPhsContext
);
150 BcmDeAllocFlashCSStructure(Adapter
);
152 free_netdev(Adapter
->dev
);
156 int create_worker_threads(PMINI_ADAPTER psAdapter
)
158 const char *name
= psAdapter
->dev
->name
;
160 BCM_DEBUG_PRINT(psAdapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Init Threads...");
161 // Rx Control Packets Processing
162 psAdapter
->control_packet_handler
= kthread_run((int (*)(void *))
163 control_packet_handler
, psAdapter
, "%s-rx", name
);
164 if(IS_ERR(psAdapter
->control_packet_handler
))
166 BCM_DEBUG_PRINT(psAdapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "No Kernel Thread, but still returning success\n");
167 return PTR_ERR(psAdapter
->control_packet_handler
);
170 psAdapter
->transmit_packet_thread
= kthread_run((int (*)(void *))
171 tx_pkt_handler
, psAdapter
, "%s-tx", name
);
172 if(IS_ERR (psAdapter
->transmit_packet_thread
))
174 BCM_DEBUG_PRINT(psAdapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "No Kernel Thread, but still returning success");
175 kthread_stop(psAdapter
->control_packet_handler
);
176 return PTR_ERR(psAdapter
->transmit_packet_thread
);
182 static inline struct file
*open_firmware_file(PMINI_ADAPTER Adapter
, char *path
)
184 struct file
*flp
=NULL
;
188 flp
=filp_open(path
, O_RDONLY
, S_IRWXU
);
192 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Unable To Open File %s, err %lx",
198 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Got file descriptor pointer of %s!",
201 if(Adapter
->device_removed
)
210 int BcmFileDownload(PMINI_ADAPTER Adapter
,/**< Logical Adapter */
211 char *path
, /**< path to image file */
212 unsigned int loc
/**< Download Address on the chip*/
216 struct file
*flp
=NULL
;
218 struct timeval tv
={0};
220 flp
=open_firmware_file(Adapter
, path
);
224 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Unable to Open %s\n", path
);
227 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
);
228 do_gettimeofday(&tv
);
230 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "download start %lx", ((tv
.tv_sec
* 1000) +
232 if(Adapter
->bcm_file_download(Adapter
->pvInterfaceAdapter
, flp
, loc
))
234 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Failed to download the firmware with error\
239 oldfs
=get_fs();set_fs(get_ds());
240 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
241 vfs_llseek(flp
, 0, 0);
244 if(Adapter
->bcm_file_readback_from_chip(Adapter
->pvInterfaceAdapter
,
247 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Failed to read back firmware!");
253 oldfs
=get_fs();set_fs(get_ds());
254 if(flp
&& !(IS_ERR(flp
)))
255 filp_close(flp
, current
->files
);
257 do_gettimeofday(&tv
);
258 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "file download done at %lx", ((tv
.tv_sec
* 1000) +
264 @ingroup ctrl_pkt_functions
265 This function copies the contents of given buffer
266 to the control packet and queues it for transmission.
267 @note Do not acquire the spinock, as it it already acquired.
268 @return SUCCESS/FAILURE.
270 INT
CopyBufferToControlPacket(PMINI_ADAPTER Adapter
,/**<Logical Adapter*/
271 PVOID ioBuffer
/**<Control Packet Buffer*/
274 PLEADER pLeader
=NULL
;
276 unsigned char *ctrl_buff
=NULL
;
278 PLINK_REQUEST pLinkReq
= NULL
;
279 PUCHAR pucAddIndication
= NULL
;
281 BCM_DEBUG_PRINT( Adapter
,DBG_TYPE_TX
, TX_CONTROL
, DBG_LVL_ALL
, "======>");
284 BCM_DEBUG_PRINT( Adapter
,DBG_TYPE_TX
, TX_CONTROL
,DBG_LVL_ALL
, "Got Null Buffer\n");
288 pLinkReq
= (PLINK_REQUEST
)ioBuffer
;
289 pLeader
=(PLEADER
)ioBuffer
; //ioBuffer Contains sw_Status and Payload
291 if(Adapter
->bShutStatus
== TRUE
&&
292 pLinkReq
->szData
[0] == LINK_DOWN_REQ_PAYLOAD
&&
293 pLinkReq
->szData
[1] == LINK_SYNC_UP_SUBTYPE
)
295 //Got sync down in SHUTDOWN..we could not process this.
296 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, TX_CONTROL
,DBG_LVL_ALL
, "SYNC DOWN Request in Shut Down Mode..\n");
297 return STATUS_FAILURE
;
300 if((pLeader
->Status
== LINK_UP_CONTROL_REQ
) &&
301 ((pLinkReq
->szData
[0] == LINK_UP_REQ_PAYLOAD
&&
302 (pLinkReq
->szData
[1] == LINK_SYNC_UP_SUBTYPE
)) ||//Sync Up Command
303 pLinkReq
->szData
[0] == NETWORK_ENTRY_REQ_PAYLOAD
)) //Net Entry Command
305 if(Adapter
->LinkStatus
> PHY_SYNC_ACHIVED
)
307 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, TX_CONTROL
,DBG_LVL_ALL
,"LinkStatus is Greater than PHY_SYN_ACHIEVED");
308 return STATUS_FAILURE
;
310 if(TRUE
== Adapter
->bShutStatus
)
312 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, TX_CONTROL
,DBG_LVL_ALL
, "SYNC UP IN SHUTDOWN..Device WakeUp\n");
313 if(Adapter
->bTriedToWakeUpFromlowPowerMode
== FALSE
)
315 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, TX_CONTROL
,DBG_LVL_ALL
, "Waking up for the First Time..\n");
316 Adapter
->usIdleModePattern
= ABORT_SHUTDOWN_MODE
; // change it to 1 for current support.
317 Adapter
->bWakeUpDevice
= TRUE
;
318 wake_up(&Adapter
->process_rx_cntrlpkt
);
320 Status
= wait_event_interruptible_timeout(Adapter
->lowpower_mode_wait_queue
,
321 !Adapter
->bShutStatus
, (5 * HZ
));
323 if(Status
== -ERESTARTSYS
)
326 if(Adapter
->bShutStatus
)
328 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, TX_CONTROL
,DBG_LVL_ALL
, "Shutdown Mode Wake up Failed - No Wake Up Received\n");
329 return STATUS_FAILURE
;
334 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, TX_CONTROL
,DBG_LVL_ALL
, "Wakeup has been tried already...\n");
339 if(TRUE
== Adapter
->IdleMode
)
341 //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Device is in Idle mode ... hence \n");
342 if(pLeader
->Status
== LINK_UP_CONTROL_REQ
|| pLeader
->Status
== 0x80 ||
343 pLeader
->Status
== CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ
)
346 if((pLeader
->Status
== LINK_UP_CONTROL_REQ
) && (pLinkReq
->szData
[0]==LINK_DOWN_REQ_PAYLOAD
))
348 if((pLinkReq
->szData
[1] == LINK_SYNC_DOWN_SUBTYPE
))
350 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, TX_CONTROL
,DBG_LVL_ALL
, "Link Down Sent in Idle Mode\n");
351 Adapter
->usIdleModePattern
= ABORT_IDLE_SYNCDOWN
;//LINK DOWN sent in Idle Mode
355 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, TX_CONTROL
,DBG_LVL_ALL
,"ABORT_IDLE_MODE pattern is being written\n");
356 Adapter
->usIdleModePattern
= ABORT_IDLE_REG
;
361 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, TX_CONTROL
,DBG_LVL_ALL
,"ABORT_IDLE_MODE pattern is being written\n");
362 Adapter
->usIdleModePattern
= ABORT_IDLE_MODE
;
365 /*Setting bIdleMode_tx_from_host to TRUE to indicate LED control thread to represent
366 the wake up from idlemode is from host*/
367 //Adapter->LEDInfo.bIdleMode_tx_from_host = TRUE;
368 Adapter
->bWakeUpDevice
= TRUE
;
369 wake_up(&Adapter
->process_rx_cntrlpkt
);
373 if(LINK_DOWN_REQ_PAYLOAD
== pLinkReq
->szData
[0])
375 // We should not send DREG message down while in idlemode.
376 return STATUS_SUCCESS
;
379 Status
= wait_event_interruptible_timeout(Adapter
->lowpower_mode_wait_queue
,
380 !Adapter
->IdleMode
, (5 * HZ
));
382 if(Status
== -ERESTARTSYS
)
385 if(Adapter
->IdleMode
)
387 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, TX_CONTROL
,DBG_LVL_ALL
, "Idle Mode Wake up Failed - No Wake Up Received\n");
388 return STATUS_FAILURE
;
392 return STATUS_SUCCESS
;
394 //The Driver has to send control messages with a particular VCID
395 pLeader
->Vcid
= VCID_CONTROL_PACKET
;//VCID for control packet.
397 /* Allocate skb for Control Packet */
398 pktlen
= pLeader
->PLength
;
399 ctrl_buff
= (char *)Adapter
->txctlpacket
[atomic_read(&Adapter
->index_wr_txcntrlpkt
)%MAX_CNTRL_PKTS
];
401 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",
402 atomic_read(&Adapter
->index_wr_txcntrlpkt
), ctrl_buff
, ioBuffer
, pktlen
);
407 if((pLeader
->Status
== 0x80) ||
408 (pLeader
->Status
== CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ
))
411 //Restructure the DSX message to handle Multiple classifier Support
412 // Write the Service Flow param Structures directly to the target
413 //and embed the pointers in the DSX messages sent to target.
415 //Lets store the current length of the control packet we are transmitting
416 pucAddIndication
= (PUCHAR
)ioBuffer
+ LEADER_SIZE
;
417 pktlen
= pLeader
->PLength
;
418 Status
= StoreCmControlResponseMessage(Adapter
,pucAddIndication
, &pktlen
);
421 ClearTargetDSXBuffer(Adapter
,((stLocalSFAddIndicationAlt
*)pucAddIndication
)->u16TID
, FALSE
);
422 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 ");
423 return STATUS_FAILURE
;
426 //update the leader to use the new length
427 //The length of the control packet is length of message being sent + Leader length
429 pLeader
->PLength
= pktlen
;
432 memset(ctrl_buff
, 0, pktlen
+LEADER_SIZE
);
433 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, TX_CONTROL
, DBG_LVL_ALL
, "Copying the Control Packet Buffer with length=%d\n", pLeader
->PLength
);
434 *(PLEADER
)ctrl_buff
=*pLeader
;
435 memcpy(ctrl_buff
+ LEADER_SIZE
, ((PUCHAR
)ioBuffer
+ LEADER_SIZE
), pLeader
->PLength
);
436 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, TX_CONTROL
, DBG_LVL_ALL
, "Enqueuing the Control Packet");
438 /*Update the statistics counters */
439 spin_lock_bh(&Adapter
->PackInfo
[HiPriority
].SFQueueLock
);
440 Adapter
->PackInfo
[HiPriority
].uiCurrentBytesOnHost
+=pLeader
->PLength
;
441 Adapter
->PackInfo
[HiPriority
].uiCurrentPacketsOnHost
++;
442 atomic_inc(&Adapter
->TotalPacketCount
);
443 spin_unlock_bh(&Adapter
->PackInfo
[HiPriority
].SFQueueLock
);
445 Adapter
->PackInfo
[HiPriority
].bValid
= TRUE
;
447 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, TX_CONTROL
, DBG_LVL_ALL
, "CurrBytesOnHost: %x bValid: %x",
448 Adapter
->PackInfo
[HiPriority
].uiCurrentBytesOnHost
,
449 Adapter
->PackInfo
[HiPriority
].bValid
);
450 Status
=STATUS_SUCCESS
;
451 /*Queue the packet for transmission */
452 atomic_inc(&Adapter
->index_wr_txcntrlpkt
);
453 BCM_DEBUG_PRINT( Adapter
,DBG_TYPE_TX
, TX_CONTROL
,DBG_LVL_ALL
, "Calling transmit_packets");
454 atomic_set(&Adapter
->TxPktAvail
, 1);
455 wake_up(&Adapter
->tx_packet_wait_queue
);
460 BCM_DEBUG_PRINT( Adapter
,DBG_TYPE_TX
, TX_CONTROL
, DBG_LVL_ALL
, "mem allocation Failed");
462 BCM_DEBUG_PRINT( Adapter
,DBG_TYPE_TX
, TX_CONTROL
, DBG_LVL_ALL
, "<====");
467 /*****************************************************************
468 * Function - SendStatisticsPointerRequest()
470 * Description - This function builds and forwards the Statistics
471 * Pointer Request control Packet.
473 * Parameters - Adapter : Pointer to Adapter structure.
474 * - pstStatisticsPtrRequest : Pointer to link request.
477 *****************************************************************/
478 static VOID
SendStatisticsPointerRequest(PMINI_ADAPTER Adapter
,
479 PLINK_REQUEST pstStatisticsPtrRequest
)
481 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_RX
, RX_DPC
, DBG_LVL_ALL
, "======>");
482 pstStatisticsPtrRequest
->Leader
.Status
= STATS_POINTER_REQ_STATUS
;
483 pstStatisticsPtrRequest
->Leader
.PLength
= sizeof(ULONG
);//minimum 4 bytes
484 pstStatisticsPtrRequest
->szData
[0] = STATISTICS_POINTER_REQ
;
486 CopyBufferToControlPacket(Adapter
,pstStatisticsPtrRequest
);
487 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_RX
, RX_DPC
, DBG_LVL_ALL
, "<=====");
493 void SendLinkDown(PMINI_ADAPTER Adapter
)
495 LINK_REQUEST stLinkDownRequest
;
496 memset(&stLinkDownRequest
, 0, sizeof(LINK_REQUEST
));
497 stLinkDownRequest
.Leader
.Status
=LINK_UP_CONTROL_REQ
;
498 stLinkDownRequest
.Leader
.PLength
=sizeof(ULONG
);//minimum 4 bytes
499 stLinkDownRequest
.szData
[0]=LINK_DOWN_REQ_PAYLOAD
;
500 Adapter
->bLinkDownRequested
= TRUE
;
502 CopyBufferToControlPacket(Adapter
,&stLinkDownRequest
);
505 /******************************************************************
506 * Function - LinkMessage()
508 * Description - This function builds the Sync-up and Link-up request
509 * packet messages depending on the device Link status.
511 * Parameters - Adapter: Pointer to the Adapter structure.
514 *******************************************************************/
515 VOID
LinkMessage(PMINI_ADAPTER Adapter
)
517 PLINK_REQUEST pstLinkRequest
=NULL
;
518 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, LINK_UP_MSG
, DBG_LVL_ALL
, "=====>");
519 if(Adapter
->LinkStatus
== SYNC_UP_REQUEST
&& Adapter
->AutoSyncup
)
521 pstLinkRequest
=kmalloc(sizeof(LINK_REQUEST
), GFP_ATOMIC
);
524 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, LINK_UP_MSG
, DBG_LVL_ALL
, "Can not allocate memory for Link request!");
527 memset(pstLinkRequest
,0,sizeof(LINK_REQUEST
));
529 Adapter
->LinkStatus
= WAIT_FOR_SYNC
;// current link status
530 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, LINK_UP_MSG
, DBG_LVL_ALL
, "Requesting For SyncUp...");
531 pstLinkRequest
->szData
[0]=LINK_UP_REQ_PAYLOAD
;
532 pstLinkRequest
->szData
[1]=LINK_SYNC_UP_SUBTYPE
;
533 pstLinkRequest
->Leader
.Status
=LINK_UP_CONTROL_REQ
;
534 pstLinkRequest
->Leader
.PLength
=sizeof(ULONG
);
535 Adapter
->bSyncUpRequestSent
= TRUE
;
537 else if(Adapter
->LinkStatus
== PHY_SYNC_ACHIVED
&& Adapter
->AutoLinkUp
)
539 pstLinkRequest
=kmalloc(sizeof(LINK_REQUEST
), GFP_ATOMIC
);
542 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, LINK_UP_MSG
, DBG_LVL_ALL
, "Can not allocate memory for Link request!");
545 memset(pstLinkRequest
,0,sizeof(LINK_REQUEST
));
547 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, LINK_UP_MSG
, DBG_LVL_ALL
, "Requesting For LinkUp...");
548 pstLinkRequest
->szData
[0]=LINK_UP_REQ_PAYLOAD
;
549 pstLinkRequest
->szData
[1]=LINK_NET_ENTRY
;
550 pstLinkRequest
->Leader
.Status
=LINK_UP_CONTROL_REQ
;
551 pstLinkRequest
->Leader
.PLength
=sizeof(ULONG
);
555 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, LINK_UP_MSG
, DBG_LVL_ALL
, "Calling CopyBufferToControlPacket");
556 CopyBufferToControlPacket(Adapter
, pstLinkRequest
);
557 kfree(pstLinkRequest
);
559 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, LINK_UP_MSG
, DBG_LVL_ALL
, "LinkMessage <=====");
564 /**********************************************************************
565 * Function - StatisticsResponse()
567 * Description - This function handles the Statistics response packet.
569 * Parameters - Adapter : Pointer to the Adapter structure.
570 * - pvBuffer: Starting address of Statistic response data.
573 ************************************************************************/
574 VOID
StatisticsResponse(PMINI_ADAPTER Adapter
,PVOID pvBuffer
)
576 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
, "%s====>",__FUNCTION__
);
577 Adapter
->StatisticsPointer
= ntohl(*(__be32
*)pvBuffer
);
578 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
, "Stats at %x", (UINT
)Adapter
->StatisticsPointer
);
579 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
, "%s <====",__FUNCTION__
);
584 /**********************************************************************
585 * Function - LinkControlResponseMessage()
587 * Description - This function handles the Link response packets.
589 * Parameters - Adapter : Pointer to the Adapter structure.
590 * - pucBuffer: Starting address of Link response data.
593 ***********************************************************************/
594 VOID
LinkControlResponseMessage(PMINI_ADAPTER Adapter
,PUCHAR pucBuffer
)
596 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_RX
, RX_DPC
, DBG_LVL_ALL
, "=====>");
598 if(*pucBuffer
==LINK_UP_ACK
)
600 switch(*(pucBuffer
+1))
602 case PHY_SYNC_ACHIVED
: //SYNCed UP
603 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0, "PHY_SYNC_ACHIVED");
605 if(Adapter
->LinkStatus
== LINKUP_DONE
)
607 beceem_protocol_reset(Adapter
);
610 Adapter
->usBestEffortQueueIndex
=INVALID_QUEUE_INDEX
;
611 Adapter
->LinkStatus
=PHY_SYNC_ACHIVED
;
613 if(Adapter
->LEDInfo
.led_thread_running
& BCM_LED_THREAD_RUNNING_ACTIVELY
)
615 Adapter
->DriverState
= NO_NETWORK_ENTRY
;
616 wake_up(&Adapter
->LEDInfo
.notify_led_event
);
619 LinkMessage(Adapter
);
623 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_RX
, RX_DPC
, DBG_LVL_ALL
, "LINKUP_DONE");
624 Adapter
->LinkStatus
=LINKUP_DONE
;
625 Adapter
->bPHSEnabled
= *(pucBuffer
+3);
626 Adapter
->bETHCSEnabled
= *(pucBuffer
+4) & ETH_CS_MASK
;
627 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0, "PHS Support Status Recieved In LinkUp Ack : %x \n",Adapter
->bPHSEnabled
);
628 if((FALSE
== Adapter
->bShutStatus
)&&
629 (FALSE
== Adapter
->IdleMode
))
631 if(Adapter
->LEDInfo
.led_thread_running
& BCM_LED_THREAD_RUNNING_ACTIVELY
)
633 Adapter
->DriverState
= NORMAL_OPERATION
;
634 wake_up(&Adapter
->LEDInfo
.notify_led_event
);
637 LinkMessage(Adapter
);
642 * Driver to ignore the DREG_RECEIVED
643 * WiMAX Application should handle this Message
645 //Adapter->liTimeSinceLastNetEntry = 0;
646 Adapter
->LinkUpStatus
= 0;
647 Adapter
->LinkStatus
= 0;
648 Adapter
->usBestEffortQueueIndex
=INVALID_QUEUE_INDEX
;
649 Adapter
->bTriedToWakeUpFromlowPowerMode
= FALSE
;
650 Adapter
->IdleMode
= FALSE
;
651 beceem_protocol_reset(Adapter
);
654 case LINK_SHUTDOWN_REQ_FROM_FIRMWARE
:
655 case COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW
:
657 HandleShutDownModeRequest(Adapter
, pucBuffer
);
661 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0, "default case:LinkResponse %x",*(pucBuffer
+1));
665 else if(SET_MAC_ADDRESS_RESPONSE
==*pucBuffer
)
667 PUCHAR puMacAddr
= (pucBuffer
+ 1);
668 Adapter
->LinkStatus
=SYNC_UP_REQUEST
;
669 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_RX
, RX_DPC
, DBG_LVL_ALL
, "MAC address response, sending SYNC_UP");
670 LinkMessage(Adapter
);
671 memcpy(Adapter
->dev
->dev_addr
, puMacAddr
, MAC_ADDRESS_SIZE
);
673 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_RX
, RX_DPC
, DBG_LVL_ALL
, "%s <=====",__FUNCTION__
);
677 void SendIdleModeResponse(PMINI_ADAPTER Adapter
)
679 INT status
= 0, NVMAccess
= 0,lowPwrAbortMsg
= 0;
681 CONTROL_MESSAGE stIdleResponse
= {{0}};
682 memset(&tv
, 0, sizeof(tv
));
683 stIdleResponse
.Leader
.Status
= IDLE_MESSAGE
;
684 stIdleResponse
.Leader
.PLength
= IDLE_MODE_PAYLOAD_LENGTH
;
685 stIdleResponse
.szData
[0] = GO_TO_IDLE_MODE_PAYLOAD
;
686 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_RX
, RX_DPC
, DBG_LVL_ALL
," ============>");
688 /*********************************
690 ** if [ semaphore is available ]
691 ** acquire semaphone and return value 0 ;
693 ** return non-zero value ;
695 ***********************************/
697 NVMAccess
= down_trylock(&Adapter
->NVMRdmWrmLock
);
699 lowPwrAbortMsg
= down_trylock(&Adapter
->LowPowerModeSync
);
702 if((NVMAccess
|| lowPwrAbortMsg
|| atomic_read(&Adapter
->TotalPacketCount
)) &&
703 (Adapter
->ulPowerSaveMode
!= DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE
) )
706 up(&Adapter
->NVMRdmWrmLock
);
709 up(&Adapter
->LowPowerModeSync
);
711 stIdleResponse
.szData
[1] = TARGET_CAN_NOT_GO_TO_IDLE_MODE
;//NACK- device access is going on.
712 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_RX
, RX_DPC
, DBG_LVL_ALL
, "HOST IS NACKING Idle mode To F/W!!!!!!!!");
713 Adapter
->bPreparingForLowPowerMode
= FALSE
;
717 stIdleResponse
.szData
[1] = TARGET_CAN_GO_TO_IDLE_MODE
; //2;//Idle ACK
718 Adapter
->StatisticsPointer
= 0;
720 /* Wait for the LED to TURN OFF before sending ACK response */
721 if(Adapter
->LEDInfo
.led_thread_running
& BCM_LED_THREAD_RUNNING_ACTIVELY
)
725 /* Wake the LED Thread with IDLEMODE_ENTER State */
726 Adapter
->DriverState
= LOWPOWER_MODE_ENTER
;
727 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
);;
728 wake_up(&Adapter
->LEDInfo
.notify_led_event
);
730 /* Wait for 1 SEC for LED to OFF */
731 iRetVal
= wait_event_timeout(Adapter
->LEDInfo
.idleModeSyncEvent
, \
732 Adapter
->LEDInfo
.bIdle_led_off
, msecs_to_jiffies(1000));
735 /* If Timed Out to Sync IDLE MODE Enter, do IDLE mode Exit and Send NACK to device */
738 stIdleResponse
.szData
[1] = TARGET_CAN_NOT_GO_TO_IDLE_MODE
;//NACK- device access is going on.
739 Adapter
->DriverState
= NORMAL_OPERATION
;
740 wake_up(&Adapter
->LEDInfo
.notify_led_event
);
741 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_RX
, RX_DPC
, DBG_LVL_ALL
, "NACKING Idle mode as time out happen from LED side!!!!!!!!");
744 if(stIdleResponse
.szData
[1] == TARGET_CAN_GO_TO_IDLE_MODE
)
746 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_RX
, RX_DPC
, DBG_LVL_ALL
,"ACKING IDLE MODE !!!!!!!!!");
747 down(&Adapter
->rdmwrmsync
);
748 Adapter
->bPreparingForLowPowerMode
= TRUE
;
749 up(&Adapter
->rdmwrmsync
);
751 if(Adapter
->bDoSuspend
== TRUE
)
752 Bcm_kill_all_URBs((PS_INTERFACE_ADAPTER
)(Adapter
->pvInterfaceAdapter
));
757 Adapter
->bPreparingForLowPowerMode
= FALSE
;
761 up(&Adapter
->NVMRdmWrmLock
);
764 up(&Adapter
->LowPowerModeSync
);
767 status
= CopyBufferToControlPacket(Adapter
,&stIdleResponse
);
768 if((status
!= STATUS_SUCCESS
))
770 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"fail to send the Idle mode Request \n");
771 Adapter
->bPreparingForLowPowerMode
= FALSE
;
772 StartInterruptUrb((PS_INTERFACE_ADAPTER
)(Adapter
->pvInterfaceAdapter
));
774 do_gettimeofday(&tv
);
775 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);
779 /******************************************************************
780 * Function - DumpPackInfo()
782 * Description - This function dumps the all Queue(PackInfo[]) details.
784 * Parameters - Adapter: Pointer to the Adapter structure.
787 *******************************************************************/
788 VOID
DumpPackInfo(PMINI_ADAPTER Adapter
)
791 UINT uiLoopIndex
= 0;
793 UINT uiClsfrIndex
= 0;
794 S_CLASSIFIER_RULE
*pstClassifierEntry
= NULL
;
796 for(uiLoopIndex
=0;uiLoopIndex
<NO_OF_QUEUES
;uiLoopIndex
++)
798 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"*********** Showing Details Of Queue %d***** ******",uiLoopIndex
);
799 if(FALSE
== Adapter
->PackInfo
[uiLoopIndex
].bValid
)
801 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"bValid is FALSE for %X index\n",uiLoopIndex
);
805 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
," Dumping SF Rule Entry For SFID %lX \n",Adapter
->PackInfo
[uiLoopIndex
].ulSFID
);
806 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
," ucDirection %X \n",Adapter
->PackInfo
[uiLoopIndex
].ucDirection
);
807 if(Adapter
->PackInfo
[uiLoopIndex
].ucIpVersion
== IPV6
)
809 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"Ipv6 Service Flow \n");
813 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"Ipv4 Service Flow \n");
815 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
," SF Traffic Priority %X \n",Adapter
->PackInfo
[uiLoopIndex
].u8TrafficPriority
);
817 for(uiClsfrIndex
=0;uiClsfrIndex
<MAX_CLASSIFIERS
;uiClsfrIndex
++)
819 pstClassifierEntry
= &Adapter
->astClassifierTable
[uiClsfrIndex
];
820 if(!pstClassifierEntry
->bUsed
)
823 if(pstClassifierEntry
->ulSFID
!= Adapter
->PackInfo
[uiLoopIndex
].ulSFID
)
826 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
);
827 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
);
828 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
);
829 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
);
830 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
);
831 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
);
834 for(uiIndex
=0;uiIndex
<MAX_PORT_RANGE
;uiIndex
++)
836 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tusSrcPortRangeLo:%X\n",pstClassifierEntry
->usSrcPortRangeLo
[uiIndex
]);
837 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tusSrcPortRangeHi:%X\n",pstClassifierEntry
->usSrcPortRangeHi
[uiIndex
]);
838 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tusDestPortRangeLo:%X\n",pstClassifierEntry
->usDestPortRangeLo
[uiIndex
]);
839 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tusDestPortRangeHi:%X\n",pstClassifierEntry
->usDestPortRangeHi
[uiIndex
]);
842 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
," \tucIPSourceAddressLength : 0x%x\n",pstClassifierEntry
->ucIPSourceAddressLength
);
843 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tucIPDestinationAddressLength : 0x%x\n",pstClassifierEntry
->ucIPDestinationAddressLength
);
844 for(uiIndex
=0;uiIndex
<pstClassifierEntry
->ucIPSourceAddressLength
;uiIndex
++)
846 if(Adapter
->PackInfo
[uiLoopIndex
].ucIpVersion
== IPV6
)
848 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tIpv6 ulSrcIpAddr :\n");
849 DumpIpv6Address(pstClassifierEntry
->stSrcIpAddress
.ulIpv6Addr
);
850 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tIpv6 ulSrcIpMask :\n");
851 DumpIpv6Address(pstClassifierEntry
->stSrcIpAddress
.ulIpv6Mask
);
855 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tulSrcIpAddr:%lX\n",pstClassifierEntry
->stSrcIpAddress
.ulIpv4Addr
[uiIndex
]);
856 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tulSrcIpMask:%lX\n",pstClassifierEntry
->stSrcIpAddress
.ulIpv4Mask
[uiIndex
]);
859 for(uiIndex
=0;uiIndex
<pstClassifierEntry
->ucIPDestinationAddressLength
;uiIndex
++)
861 if(Adapter
->PackInfo
[uiLoopIndex
].ucIpVersion
== IPV6
)
863 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tIpv6 ulDestIpAddr :\n");
864 DumpIpv6Address(pstClassifierEntry
->stDestIpAddress
.ulIpv6Addr
);
865 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tIpv6 ulDestIpMask :\n");
866 DumpIpv6Address(pstClassifierEntry
->stDestIpAddress
.ulIpv6Mask
);
871 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tulDestIpAddr:%lX\n",pstClassifierEntry
->stDestIpAddress
.ulIpv4Addr
[uiIndex
]);
872 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tulDestIpMask:%lX\n",pstClassifierEntry
->stDestIpAddress
.ulIpv4Mask
[uiIndex
]);
875 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tucProtocol:0x%X\n",pstClassifierEntry
->ucProtocol
[0]);
876 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tu8ClassifierRulePriority:%X\n",pstClassifierEntry
->u8ClassifierRulePriority
);
880 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"ulSFID:%lX\n",Adapter
->PackInfo
[uiLoopIndex
].ulSFID
);
881 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"usVCID_Value:%X\n",Adapter
->PackInfo
[uiLoopIndex
].usVCID_Value
);
882 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"PhsEnabled: 0x%X\n",Adapter
->PackInfo
[uiLoopIndex
].bHeaderSuppressionEnabled
);
883 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"uiThreshold:%X\n",Adapter
->PackInfo
[uiLoopIndex
].uiThreshold
);
886 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"bValid:%X\n",Adapter
->PackInfo
[uiLoopIndex
].bValid
);
887 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"bActive:%X\n",Adapter
->PackInfo
[uiLoopIndex
].bActive
);
888 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"ActivateReqSent: %x", Adapter
->PackInfo
[uiLoopIndex
].bActivateRequestSent
);
889 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"u8QueueType:%X\n",Adapter
->PackInfo
[uiLoopIndex
].u8QueueType
);
890 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"uiMaxBucketSize:%X\n",Adapter
->PackInfo
[uiLoopIndex
].uiMaxBucketSize
);
891 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"uiPerSFTxResourceCount:%X\n",atomic_read(&Adapter
->PackInfo
[uiLoopIndex
].uiPerSFTxResourceCount
));
892 //DumpDebug(DUMP_INFO,(" bCSSupport:%X\n",Adapter->PackInfo[uiLoopIndex].bCSSupport));
893 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"CurrQueueDepthOnTarget: %x\n", Adapter
->PackInfo
[uiLoopIndex
].uiCurrentQueueDepthOnTarget
);
894 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"uiCurrentBytesOnHost:%X\n",Adapter
->PackInfo
[uiLoopIndex
].uiCurrentBytesOnHost
);
895 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"uiCurrentPacketsOnHost:%X\n",Adapter
->PackInfo
[uiLoopIndex
].uiCurrentPacketsOnHost
);
896 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"uiDroppedCountBytes:%X\n",Adapter
->PackInfo
[uiLoopIndex
].uiDroppedCountBytes
);
897 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"uiDroppedCountPackets:%X\n",Adapter
->PackInfo
[uiLoopIndex
].uiDroppedCountPackets
);
898 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"uiSentBytes:%X\n",Adapter
->PackInfo
[uiLoopIndex
].uiSentBytes
);
899 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"uiSentPackets:%X\n",Adapter
->PackInfo
[uiLoopIndex
].uiSentPackets
);
900 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"uiCurrentDrainRate:%X\n",Adapter
->PackInfo
[uiLoopIndex
].uiCurrentDrainRate
);
901 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"uiThisPeriodSentBytes:%X\n",Adapter
->PackInfo
[uiLoopIndex
].uiThisPeriodSentBytes
);
902 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"liDrainCalculated:%llX\n",Adapter
->PackInfo
[uiLoopIndex
].liDrainCalculated
);
903 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"uiCurrentTokenCount:%X\n",Adapter
->PackInfo
[uiLoopIndex
].uiCurrentTokenCount
);
904 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"liLastUpdateTokenAt:%llX\n",Adapter
->PackInfo
[uiLoopIndex
].liLastUpdateTokenAt
);
905 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"uiMaxAllowedRate:%X\n",Adapter
->PackInfo
[uiLoopIndex
].uiMaxAllowedRate
);
906 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"uiPendedLast:%X\n",Adapter
->PackInfo
[uiLoopIndex
].uiPendedLast
);
907 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"NumOfPacketsSent:%X\n",Adapter
->PackInfo
[uiLoopIndex
].NumOfPacketsSent
);
908 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
, "Direction: %x\n", Adapter
->PackInfo
[uiLoopIndex
].ucDirection
);
909 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
, "CID: %x\n", Adapter
->PackInfo
[uiLoopIndex
].usCID
);
910 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
, "ProtocolValid: %x\n", Adapter
->PackInfo
[uiLoopIndex
].bProtocolValid
);
911 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
, "TOSValid: %x\n", Adapter
->PackInfo
[uiLoopIndex
].bTOSValid
);
912 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
, "DestIpValid: %x\n", Adapter
->PackInfo
[uiLoopIndex
].bDestIpValid
);
913 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
, "SrcIpValid: %x\n", Adapter
->PackInfo
[uiLoopIndex
].bSrcIpValid
);
914 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
, "ActiveSet: %x\n", Adapter
->PackInfo
[uiLoopIndex
].bActiveSet
);
915 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
, "AdmittedSet: %x\n", Adapter
->PackInfo
[uiLoopIndex
].bAdmittedSet
);
916 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
, "AuthzSet: %x\n", Adapter
->PackInfo
[uiLoopIndex
].bAuthorizedSet
);
917 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
, "ClassifyPrority: %x\n", Adapter
->PackInfo
[uiLoopIndex
].bClassifierPriority
);
918 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
, "uiMaxLatency: %x\n",Adapter
->PackInfo
[uiLoopIndex
].uiMaxLatency
);
919 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]);
920 // BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "bHeaderSuppressionEnabled :%X\n", Adapter->PackInfo[uiLoopIndex].bHeaderSuppressionEnabled);
921 // BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiTotalTxBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiTotalTxBytes);
922 // BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiTotalRxBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiTotalRxBytes);
923 // DumpDebug(DUMP_INFO,(" uiRanOutOfResCount:%X\n",Adapter->PackInfo[uiLoopIndex].uiRanOutOfResCount));
926 for(uiLoopIndex
= 0 ; uiLoopIndex
< MIBS_MAX_HIST_ENTRIES
; uiLoopIndex
++)
927 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"Adapter->aRxPktSizeHist[%x] = %x\n",uiLoopIndex
,Adapter
->aRxPktSizeHist
[uiLoopIndex
]);
929 for(uiLoopIndex
= 0 ; uiLoopIndex
< MIBS_MAX_HIST_ENTRIES
; uiLoopIndex
++)
930 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"Adapter->aTxPktSizeHist[%x] = %x\n",uiLoopIndex
,Adapter
->aTxPktSizeHist
[uiLoopIndex
]);
939 int reset_card_proc(PMINI_ADAPTER ps_adapter
)
941 int retval
= STATUS_SUCCESS
;
943 PMINI_ADAPTER Adapter
= GET_BCM_ADAPTER(gblpnetdev
);
944 PS_INTERFACE_ADAPTER psIntfAdapter
= NULL
;
945 unsigned int value
= 0, uiResetValue
= 0;
947 psIntfAdapter
= ((PS_INTERFACE_ADAPTER
)(ps_adapter
->pvInterfaceAdapter
)) ;
949 ps_adapter
->bDDRInitDone
= FALSE
;
951 if(ps_adapter
->chip_id
>= T3LPB
)
953 //SYS_CFG register is write protected hence for modifying this reg value, it should be read twice before
954 rdmalt(ps_adapter
,SYS_CFG
, &value
, sizeof(value
));
955 rdmalt(ps_adapter
,SYS_CFG
, &value
, sizeof(value
));
957 //making bit[6...5] same as was before f/w download. this setting force the h/w to
958 //re-populated the SP RAM area with the string descriptor .
959 value
= value
| (ps_adapter
->syscfgBefFwDld
& 0x00000060) ;
960 wrmalt(ps_adapter
, SYS_CFG
, &value
, sizeof(value
));
963 //killing all submitted URBs.
964 psIntfAdapter
->psAdapter
->StopAllXaction
= TRUE
;
965 Bcm_kill_all_URBs(psIntfAdapter
);
966 /* Reset the UMA-B Device */
967 if(ps_adapter
->chip_id
>= T3LPB
)
969 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0, "Reseting UMA-B \n");
970 retval
= usb_reset_device(psIntfAdapter
->udev
);
972 psIntfAdapter
->psAdapter
->StopAllXaction
= FALSE
;
974 if(retval
!= STATUS_SUCCESS
)
976 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0, "Reset failed with ret value :%d", retval
);
979 if (ps_adapter
->chip_id
== BCS220_2
||
980 ps_adapter
->chip_id
== BCS220_2BC
||
981 ps_adapter
->chip_id
== BCS250_BC
||
982 ps_adapter
->chip_id
== BCS220_3
)
984 retval
= rdmalt(ps_adapter
,HPM_CONFIG_LDO145
, &value
, sizeof(value
));
987 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"read failed with status :%d",retval
);
992 retval
= wrmalt(ps_adapter
, HPM_CONFIG_LDO145
, &value
, sizeof(value
));
995 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"write failed with status :%d",retval
);
1003 retval
= rdmalt(ps_adapter
,0x0f007018, &value
, sizeof(value
));
1005 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"read failed with status :%d",retval
);
1009 retval
= wrmalt(ps_adapter
, 0x0f007018, &value
, sizeof(value
)) ;
1011 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"write failed with status :%d",retval
);
1015 // Toggling the GPIO 8, 9
1017 retval
= wrmalt(ps_adapter
, GPIO_OUTPUT_REGISTER
, &value
, sizeof(value
));
1019 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"write failed with status :%d",retval
);
1023 retval
= wrmalt(ps_adapter
, GPIO_MODE_REGISTER
, &value
, sizeof(value
)) ;
1025 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"write failed with status :%d",retval
);
1031 //ps_adapter->downloadDDR = false;
1033 if(ps_adapter
->bFlashBoot
)
1035 //In flash boot mode MIPS state register has reverse polarity.
1036 // So just or with setting bit 30.
1037 //Make the MIPS in Reset state.
1038 rdmalt(ps_adapter
, CLOCK_RESET_CNTRL_REG_1
, &uiResetValue
, sizeof(uiResetValue
));
1040 uiResetValue
|=(1<<30);
1041 wrmalt(ps_adapter
, CLOCK_RESET_CNTRL_REG_1
, &uiResetValue
, sizeof(uiResetValue
));
1044 if(ps_adapter
->chip_id
>= T3LPB
)
1048 // WA for SYSConfig Issue.
1049 // Read SYSCFG Twice to make it writable.
1051 rdmalt(ps_adapter
, SYS_CFG
, &uiResetValue
, sizeof(uiResetValue
));
1052 if(uiResetValue
& (1<<4))
1055 rdmalt(ps_adapter
, SYS_CFG
, &uiResetValue
, sizeof(uiResetValue
));//2nd read to make it writable.
1056 uiResetValue
&= (~(1<<4));
1057 wrmalt(ps_adapter
,SYS_CFG
, &uiResetValue
, sizeof(uiResetValue
));
1062 wrmalt(ps_adapter
, 0x0f01186c, &uiResetValue
, sizeof(uiResetValue
));
1065 psIntfAdapter
->psAdapter
->StopAllXaction
= FALSE
;
1069 int run_card_proc(PMINI_ADAPTER ps_adapter
)
1071 unsigned int value
=0;
1074 if(rdmalt(ps_adapter
, CLOCK_RESET_CNTRL_REG_1
, &value
, sizeof(value
)) < 0) {
1075 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
,"%s:%d\n", __FUNCTION__
, __LINE__
);
1076 return STATUS_FAILURE
;
1079 if(ps_adapter
->bFlashBoot
)
1089 if(wrmalt(ps_adapter
, CLOCK_RESET_CNTRL_REG_1
, &value
, sizeof(value
)) < 0) {
1090 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
,"%s:%d\n", __FUNCTION__
, __LINE__
);
1091 return STATUS_FAILURE
;
1094 return STATUS_SUCCESS
;
1097 int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter
)
1100 UINT status
= STATUS_SUCCESS
;
1103 * Create the threads first and then download the
1104 * Firm/DDR Settings..
1107 if((status
= create_worker_threads(ps_adapter
))<0)
1109 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Cannot create thread");
1113 * For Downloading the Firm, parse the cfg file first.
1115 status
= bcm_parse_target_params (ps_adapter
);
1120 if(ps_adapter
->chip_id
>= T3LPB
)
1122 rdmalt(ps_adapter
, SYS_CFG
, &value
, sizeof (value
));
1123 ps_adapter
->syscfgBefFwDld
= value
;
1124 if((value
& 0x60)== 0)
1126 ps_adapter
->bFlashBoot
= TRUE
;
1130 reset_card_proc(ps_adapter
);
1132 //Initializing the NVM.
1133 BcmInitNVM(ps_adapter
);
1134 status
= ddr_init(ps_adapter
);
1137 BCM_DEBUG_PRINT (ps_adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "ddr_init Failed\n");
1141 /* Download cfg file */
1142 status
= buffDnldVerify(ps_adapter
,
1143 (PUCHAR
)ps_adapter
->pstargetparams
,
1144 sizeof(STARGETPARAMS
),
1148 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Error downloading CFG file");
1151 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "CFG file downloaded");
1153 if(register_networkdev(ps_adapter
))
1155 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Register Netdevice failed. Cleanup needs to be performed.");
1159 if(FALSE
== ps_adapter
->AutoFirmDld
)
1161 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "AutoFirmDld Disabled in CFG File..\n");
1162 //If Auto f/w download is disable, register the control interface,
1163 //register the control interface after the mailbox.
1164 if(register_control_device_interface(ps_adapter
) < 0)
1166 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Register Control Device failed. Cleanup needs to be performed.");
1170 return STATUS_SUCCESS
;
1174 * Do the LED Settings here. It will be used by the Firmware Download
1179 * 1. If the LED Settings fails, do not stop and do the Firmware download.
1180 * 2. This init would happend only if the cfg file is present, else
1181 * call from the ioctl context.
1184 status
= InitLedSettings (ps_adapter
);
1188 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_PRINTK
, 0, 0,"INIT LED FAILED\n");
1191 if(ps_adapter
->LEDInfo
.led_thread_running
& BCM_LED_THREAD_RUNNING_ACTIVELY
)
1193 ps_adapter
->DriverState
= DRIVER_INIT
;
1194 wake_up(&ps_adapter
->LEDInfo
.notify_led_event
);
1197 if(ps_adapter
->LEDInfo
.led_thread_running
& BCM_LED_THREAD_RUNNING_ACTIVELY
)
1199 ps_adapter
->DriverState
= FW_DOWNLOAD
;
1200 wake_up(&ps_adapter
->LEDInfo
.notify_led_event
);
1204 wrmalt(ps_adapter
, EEPROM_CAL_DATA_INTERNAL_LOC
- 4, &value
, sizeof(value
));
1205 wrmalt(ps_adapter
, EEPROM_CAL_DATA_INTERNAL_LOC
- 8, &value
, sizeof(value
));
1207 if(ps_adapter
->eNVMType
== NVM_FLASH
)
1209 status
= PropagateCalParamsFromFlashToMemory(ps_adapter
);
1212 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
," Propogation of Cal param failed .." );
1217 /* Download Firmare */
1218 if ((status
= BcmFileDownload( ps_adapter
, BIN_FILE
, FIRMWARE_BEGIN_ADDR
)))
1220 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "No Firmware File is present... \n");
1224 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "BIN file downloaded");
1225 status
= run_card_proc(ps_adapter
);
1228 BCM_DEBUG_PRINT (ps_adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "run_card_proc Failed\n");
1233 ps_adapter
->fw_download_done
= TRUE
;
1237 if(ps_adapter
->LEDInfo
.led_thread_running
& BCM_LED_THREAD_RUNNING_ACTIVELY
)
1239 ps_adapter
->DriverState
= FW_DOWNLOAD_DONE
;
1240 wake_up(&ps_adapter
->LEDInfo
.notify_led_event
);
1247 int bcm_parse_target_params(PMINI_ADAPTER Adapter
)
1249 struct file
*flp
=NULL
;
1250 mm_segment_t oldfs
={0};
1255 buff
=(PCHAR
)kmalloc(BUFFER_1K
, GFP_KERNEL
);
1260 if((Adapter
->pstargetparams
=
1261 kmalloc(sizeof(STARGETPARAMS
), GFP_KERNEL
)) == NULL
)
1266 flp
=open_firmware_file(Adapter
, CFG_FILE
);
1268 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "NOT ABLE TO OPEN THE %s FILE \n", CFG_FILE
);
1270 kfree(Adapter
->pstargetparams
);
1271 Adapter
->pstargetparams
= NULL
;
1274 oldfs
=get_fs(); set_fs(get_ds());
1275 len
=vfs_read(flp
, (void __user __force
*)buff
, BUFFER_1K
, &pos
);
1278 if(len
!= sizeof(STARGETPARAMS
))
1280 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
,"Mismatch in Target Param Structure!\n");
1282 kfree(Adapter
->pstargetparams
);
1283 Adapter
->pstargetparams
= NULL
;
1284 filp_close(flp
, current
->files
);
1287 filp_close(flp
, current
->files
);
1289 /* Check for autolink in config params */
1291 * Values in Adapter->pstargetparams are in network byte order
1293 memcpy(Adapter
->pstargetparams
, buff
, sizeof(STARGETPARAMS
));
1295 beceem_parse_target_struct(Adapter
);
1296 return STATUS_SUCCESS
;
1299 void beceem_parse_target_struct(PMINI_ADAPTER Adapter
)
1301 UINT uiHostDrvrCfg6
=0, uiEEPROMFlag
= 0;;
1303 if(ntohl(Adapter
->pstargetparams
->m_u32PhyParameter2
) & AUTO_SYNC_DISABLE
)
1305 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "AutoSyncup is Disabled\n");
1306 Adapter
->AutoSyncup
= FALSE
;
1310 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "AutoSyncup is Enabled\n");
1311 Adapter
->AutoSyncup
= TRUE
;
1313 if(ntohl(Adapter
->pstargetparams
->HostDrvrConfig6
) & AUTO_LINKUP_ENABLE
)
1315 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Enabling autolink up");
1316 Adapter
->AutoLinkUp
= TRUE
;
1320 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Disabling autolink up");
1321 Adapter
->AutoLinkUp
= FALSE
;
1323 // Setting the DDR Setting..
1324 Adapter
->DDRSetting
=
1325 (ntohl(Adapter
->pstargetparams
->HostDrvrConfig6
) >>8)&0x0F;
1326 Adapter
->ulPowerSaveMode
=
1327 (ntohl(Adapter
->pstargetparams
->HostDrvrConfig6
)>>12)&0x0F;
1329 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "DDR Setting: %x\n", Adapter
->DDRSetting
);
1330 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
,DBG_LVL_ALL
, "Power Save Mode: %lx\n",
1331 Adapter
->ulPowerSaveMode
);
1332 if(ntohl(Adapter
->pstargetparams
->HostDrvrConfig6
) & AUTO_FIRM_DOWNLOAD
)
1334 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Enabling Auto Firmware Download\n");
1335 Adapter
->AutoFirmDld
= TRUE
;
1339 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Disabling Auto Firmware Download\n");
1340 Adapter
->AutoFirmDld
= FALSE
;
1342 uiHostDrvrCfg6
= ntohl(Adapter
->pstargetparams
->HostDrvrConfig6
);
1343 Adapter
->bMipsConfig
= (uiHostDrvrCfg6
>>20)&0x01;
1344 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
,"MIPSConfig : 0x%X\n",Adapter
->bMipsConfig
);
1345 //used for backward compatibility.
1346 Adapter
->bDPLLConfig
= (uiHostDrvrCfg6
>>19)&0x01;
1348 Adapter
->PmuMode
= (uiHostDrvrCfg6
>> 24 ) & 0x03;
1349 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "PMU MODE: %x", Adapter
->PmuMode
);
1351 if((uiHostDrvrCfg6
>> HOST_BUS_SUSPEND_BIT
) & (0x01))
1353 Adapter
->bDoSuspend
= TRUE
;
1354 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Making DoSuspend TRUE as per configFile");
1357 uiEEPROMFlag
= ntohl(Adapter
->pstargetparams
->m_u32EEPROMFlag
);
1358 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "uiEEPROMFlag : 0x%X\n",uiEEPROMFlag
);
1359 Adapter
->eNVMType
= (NVM_TYPE
)((uiEEPROMFlag
>>4)&0x3);
1362 Adapter
->bStatusWrite
= (uiEEPROMFlag
>>6)&0x1;
1363 //printk(("bStatusWrite : 0x%X\n", Adapter->bStatusWrite));
1365 Adapter
->uiSectorSizeInCFG
= 1024*(0xFFFF & ntohl(Adapter
->pstargetparams
->HostDrvrConfig4
));
1366 //printk(("uiSectorSize : 0x%X\n", Adapter->uiSectorSizeInCFG));
1368 Adapter
->bSectorSizeOverride
=(bool) ((ntohl(Adapter
->pstargetparams
->HostDrvrConfig4
))>>16)&0x1;
1369 //printk(MP_INIT,("bSectorSizeOverride : 0x%X\n",Adapter->bSectorSizeOverride));
1371 if(ntohl(Adapter
->pstargetparams
->m_u32PowerSavingModeOptions
) &0x01)
1372 Adapter
->ulPowerSaveMode
= DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE
;
1373 //autocorrection part
1374 if(Adapter
->ulPowerSaveMode
!= DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE
)
1375 doPowerAutoCorrection(Adapter
);
1379 VOID
doPowerAutoCorrection(PMINI_ADAPTER psAdapter
)
1381 UINT reporting_mode
= 0;
1383 reporting_mode
= ntohl(psAdapter
->pstargetparams
->m_u32PowerSavingModeOptions
) &0x02 ;
1384 psAdapter
->bIsAutoCorrectEnabled
= !((char)(psAdapter
->ulPowerSaveMode
>> 3) & 0x1);
1386 if(reporting_mode
== TRUE
)
1388 BCM_DEBUG_PRINT(psAdapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
,"can't do suspen/resume as reporting mode is enable");
1389 psAdapter
->bDoSuspend
= FALSE
;
1392 if (psAdapter
->bIsAutoCorrectEnabled
&& (psAdapter
->chip_id
>= T3LPB
))
1394 //If reporting mode is enable, switch PMU to PMC
1396 psAdapter
->ulPowerSaveMode
= DEVICE_POWERSAVE_MODE_AS_PMU_CLOCK_GATING
;
1397 psAdapter
->bDoSuspend
=FALSE
;
1398 BCM_DEBUG_PRINT(psAdapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
,"PMC selected..");
1402 //clearing space bit[15..12]
1403 psAdapter
->pstargetparams
->HostDrvrConfig6
&= ~(htonl((0xF << 12)));
1404 //placing the power save mode option
1405 psAdapter
->pstargetparams
->HostDrvrConfig6
|= htonl((psAdapter
->ulPowerSaveMode
<< 12));
1408 else if (psAdapter
->bIsAutoCorrectEnabled
== FALSE
)
1411 // remove the autocorrect disable bit set before dumping.
1412 psAdapter
->ulPowerSaveMode
&= ~(1 << 3);
1413 psAdapter
->pstargetparams
->HostDrvrConfig6
&= ~(htonl(1 << 15));
1414 BCM_DEBUG_PRINT(psAdapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
,"Using Forced User Choice: %lx\n", psAdapter
->ulPowerSaveMode
);
1419 static unsigned char *ReadMacAddrEEPROM(PMINI_ADAPTER Adapter
, ulong dwAddress
)
1421 unsigned char *pucmacaddr
= NULL
;
1422 int status
= 0, i
=0;
1423 unsigned int temp
=0;
1426 pucmacaddr
= (unsigned char *)kmalloc(MAC_ADDRESS_SIZE
, GFP_KERNEL
);
1429 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0, "No Buffers to Read the EEPROM Address\n");
1433 dwAddress
|= 0x5b000000;
1434 status
= wrmalt(Adapter
, EEPROM_COMMAND_Q_REG
,
1435 (PUINT
)&dwAddress
, sizeof(UINT
));
1436 if(status
!= STATUS_SUCCESS
)
1438 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0, "wrm Failed..\n");
1443 for(i
=0;i
<MAC_ADDRESS_SIZE
;i
++)
1445 status
= rdmalt(Adapter
, EEPROM_READ_DATA_Q_REG
, &temp
,sizeof(temp
));
1446 if(status
!= STATUS_SUCCESS
)
1448 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0, "rdm Failed..\n");
1453 pucmacaddr
[i
] = temp
& 0xff;
1454 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, DRV_ENTRY
, DBG_LVL_ALL
,"%x \n", pucmacaddr
[i
]);
1462 static void convertEndian(B_UINT8 rwFlag
, PUINT puiBuffer
, UINT uiByteCount
)
1466 if(RWM_WRITE
== rwFlag
) {
1467 for(uiIndex
=0; uiIndex
< (uiByteCount
/sizeof(UINT
)); uiIndex
++) {
1468 puiBuffer
[uiIndex
] = htonl(puiBuffer
[uiIndex
]);
1471 for(uiIndex
=0; uiIndex
< (uiByteCount
/sizeof(UINT
)); uiIndex
++) {
1472 puiBuffer
[uiIndex
] = ntohl(puiBuffer
[uiIndex
]);
1477 #define CACHE_ADDRESS_MASK 0x80000000
1478 #define UNCACHE_ADDRESS_MASK 0xa0000000
1480 int rdm(PMINI_ADAPTER Adapter
, UINT uiAddress
, PCHAR pucBuff
, size_t sSize
)
1484 uiRetVal
= Adapter
->interface_rdm(Adapter
->pvInterfaceAdapter
,
1485 uiAddress
, pucBuff
, sSize
);
1492 int wrm(PMINI_ADAPTER Adapter
, UINT uiAddress
, PCHAR pucBuff
, size_t sSize
)
1496 iRetVal
= Adapter
->interface_wrm(Adapter
->pvInterfaceAdapter
,
1497 uiAddress
, pucBuff
, sSize
);
1503 int wrmalt (PMINI_ADAPTER Adapter
, UINT uiAddress
, PUINT pucBuff
, size_t size
)
1505 convertEndian(RWM_WRITE
, pucBuff
, size
);
1506 return wrm(Adapter
, uiAddress
, (PUCHAR
)pucBuff
, size
);
1509 int rdmalt (PMINI_ADAPTER Adapter
, UINT uiAddress
, PUINT pucBuff
, size_t size
)
1513 uiRetVal
= rdm(Adapter
,uiAddress
,(PUCHAR
)pucBuff
,size
);
1514 convertEndian(RWM_READ
, (PUINT
)pucBuff
, size
);
1519 int rdmWithLock(PMINI_ADAPTER Adapter
, UINT uiAddress
, PCHAR pucBuff
, size_t sSize
)
1522 INT status
= STATUS_SUCCESS
;
1523 down(&Adapter
->rdmwrmsync
);
1525 if((Adapter
->IdleMode
== TRUE
) ||
1526 (Adapter
->bShutStatus
==TRUE
) ||
1527 (Adapter
->bPreparingForLowPowerMode
==TRUE
))
1533 status
= rdm(Adapter
, uiAddress
, pucBuff
, sSize
);
1536 up(&Adapter
->rdmwrmsync
);
1539 int wrmWithLock(PMINI_ADAPTER Adapter
, UINT uiAddress
, PCHAR pucBuff
, size_t sSize
)
1541 INT status
= STATUS_SUCCESS
;
1542 down(&Adapter
->rdmwrmsync
);
1544 if((Adapter
->IdleMode
== TRUE
) ||
1545 (Adapter
->bShutStatus
==TRUE
) ||
1546 (Adapter
->bPreparingForLowPowerMode
==TRUE
))
1552 status
=wrm(Adapter
, uiAddress
, pucBuff
, sSize
);
1555 up(&Adapter
->rdmwrmsync
);
1559 int wrmaltWithLock (PMINI_ADAPTER Adapter
, UINT uiAddress
, PUINT pucBuff
, size_t size
)
1561 int iRetVal
= STATUS_SUCCESS
;
1563 down(&Adapter
->rdmwrmsync
);
1565 if((Adapter
->IdleMode
== TRUE
) ||
1566 (Adapter
->bShutStatus
==TRUE
) ||
1567 (Adapter
->bPreparingForLowPowerMode
==TRUE
))
1573 iRetVal
= wrmalt(Adapter
,uiAddress
,pucBuff
,size
);
1576 up(&Adapter
->rdmwrmsync
);
1580 int rdmaltWithLock (PMINI_ADAPTER Adapter
, UINT uiAddress
, PUINT pucBuff
, size_t size
)
1582 INT uiRetVal
=STATUS_SUCCESS
;
1584 down(&Adapter
->rdmwrmsync
);
1586 if((Adapter
->IdleMode
== TRUE
) ||
1587 (Adapter
->bShutStatus
==TRUE
) ||
1588 (Adapter
->bPreparingForLowPowerMode
==TRUE
))
1594 uiRetVal
= rdmalt(Adapter
,uiAddress
, pucBuff
, size
);
1597 up(&Adapter
->rdmwrmsync
);
1602 static VOID
HandleShutDownModeWakeup(PMINI_ADAPTER Adapter
)
1604 int clear_abort_pattern
= 0,Status
= 0;
1605 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, MP_SHUTDOWN
, DBG_LVL_ALL
, "====>\n");
1606 //target has woken up From Shut Down
1607 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, MP_SHUTDOWN
, DBG_LVL_ALL
, "Clearing Shut Down Software abort pattern\n");
1608 Status
= wrmalt(Adapter
,SW_ABORT_IDLEMODE_LOC
, (PUINT
)&clear_abort_pattern
, sizeof(clear_abort_pattern
));
1611 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, MP_SHUTDOWN
, DBG_LVL_ALL
,"WRM to SW_ABORT_IDLEMODE_LOC failed with err:%d", Status
);
1614 if(Adapter
->ulPowerSaveMode
!= DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE
)
1617 InterfaceHandleShutdownModeWakeup(Adapter
);
1620 if(Adapter
->LEDInfo
.led_thread_running
& BCM_LED_THREAD_RUNNING_ACTIVELY
)
1622 Adapter
->DriverState
= NO_NETWORK_ENTRY
;
1623 wake_up(&Adapter
->LEDInfo
.notify_led_event
);
1626 Adapter
->bTriedToWakeUpFromlowPowerMode
= FALSE
;
1627 Adapter
->bShutStatus
= FALSE
;
1628 wake_up(&Adapter
->lowpower_mode_wait_queue
);
1629 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, MP_SHUTDOWN
, DBG_LVL_ALL
, "<====\n");
1632 static VOID
SendShutModeResponse(PMINI_ADAPTER Adapter
)
1634 CONTROL_MESSAGE stShutdownResponse
;
1635 UINT NVMAccess
= 0,lowPwrAbortMsg
= 0;
1638 memset (&stShutdownResponse
, 0, sizeof(CONTROL_MESSAGE
));
1639 stShutdownResponse
.Leader
.Status
= LINK_UP_CONTROL_REQ
;
1640 stShutdownResponse
.Leader
.PLength
= 8;//8 bytes;
1641 stShutdownResponse
.szData
[0] = LINK_UP_ACK
;
1642 stShutdownResponse
.szData
[1] = LINK_SHUTDOWN_REQ_FROM_FIRMWARE
;
1644 /*********************************
1646 ** if [ semaphore is available ]
1647 ** acquire semaphone and return value 0 ;
1649 ** return non-zero value ;
1651 ***********************************/
1653 NVMAccess
= down_trylock(&Adapter
->NVMRdmWrmLock
);
1655 lowPwrAbortMsg
= down_trylock(&Adapter
->LowPowerModeSync
);
1658 if(NVMAccess
|| lowPwrAbortMsg
|| atomic_read(&Adapter
->TotalPacketCount
))
1661 up(&Adapter
->NVMRdmWrmLock
);
1664 up(&Adapter
->LowPowerModeSync
);
1666 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, MP_SHUTDOWN
, DBG_LVL_ALL
, "Device Access is going on NACK the Shut Down MODE\n");
1667 stShutdownResponse
.szData
[2] = SHUTDOWN_NACK_FROM_DRIVER
;//NACK- device access is going on.
1668 Adapter
->bPreparingForLowPowerMode
= FALSE
;
1672 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, MP_SHUTDOWN
, DBG_LVL_ALL
, "Sending SHUTDOWN MODE ACK\n");
1673 stShutdownResponse
.szData
[2] = SHUTDOWN_ACK_FROM_DRIVER
;//ShutDown ACK
1675 /* Wait for the LED to TURN OFF before sending ACK response */
1676 if(Adapter
->LEDInfo
.led_thread_running
& BCM_LED_THREAD_RUNNING_ACTIVELY
)
1680 /* Wake the LED Thread with LOWPOWER_MODE_ENTER State */
1681 Adapter
->DriverState
= LOWPOWER_MODE_ENTER
;
1682 wake_up(&Adapter
->LEDInfo
.notify_led_event
);
1684 /* Wait for 1 SEC for LED to OFF */
1685 iRetVal
= wait_event_timeout(Adapter
->LEDInfo
.idleModeSyncEvent
,\
1686 Adapter
->LEDInfo
.bIdle_led_off
, msecs_to_jiffies(1000));
1688 /* If Timed Out to Sync IDLE MODE Enter, do IDLE mode Exit and Send NACK to device */
1691 stShutdownResponse
.szData
[1] = SHUTDOWN_NACK_FROM_DRIVER
;//NACK- device access is going on.
1693 Adapter
->DriverState
= NO_NETWORK_ENTRY
;
1694 wake_up(&Adapter
->LEDInfo
.notify_led_event
);
1698 if(stShutdownResponse
.szData
[2] == SHUTDOWN_ACK_FROM_DRIVER
)
1700 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, MP_SHUTDOWN
, DBG_LVL_ALL
,"ACKING SHUTDOWN MODE !!!!!!!!!");
1701 down(&Adapter
->rdmwrmsync
);
1702 Adapter
->bPreparingForLowPowerMode
= TRUE
;
1703 up(&Adapter
->rdmwrmsync
);
1705 if(Adapter
->bDoSuspend
== TRUE
)
1706 Bcm_kill_all_URBs((PS_INTERFACE_ADAPTER
)(Adapter
->pvInterfaceAdapter
));
1710 Adapter
->bPreparingForLowPowerMode
= FALSE
;
1714 up(&Adapter
->NVMRdmWrmLock
);
1717 up(&Adapter
->LowPowerModeSync
);
1719 Status
= CopyBufferToControlPacket(Adapter
,&stShutdownResponse
);
1720 if((Status
!= STATUS_SUCCESS
))
1722 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, MP_SHUTDOWN
, DBG_LVL_ALL
,"fail to send the Idle mode Request \n");
1723 Adapter
->bPreparingForLowPowerMode
= FALSE
;
1725 StartInterruptUrb((PS_INTERFACE_ADAPTER
)(Adapter
->pvInterfaceAdapter
));
1730 void HandleShutDownModeRequest(PMINI_ADAPTER Adapter
,PUCHAR pucBuffer
)
1732 B_UINT32 uiResetValue
= 0;
1734 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, MP_SHUTDOWN
, DBG_LVL_ALL
, "====>\n");
1736 if(*(pucBuffer
+1) == COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW
)
1738 HandleShutDownModeWakeup(Adapter
);
1740 else if(*(pucBuffer
+1) == LINK_SHUTDOWN_REQ_FROM_FIRMWARE
)
1742 //Target wants to go to Shut Down Mode
1743 //InterfacePrepareForShutdown(Adapter);
1744 if(Adapter
->chip_id
== BCS220_2
||
1745 Adapter
->chip_id
== BCS220_2BC
||
1746 Adapter
->chip_id
== BCS250_BC
||
1747 Adapter
->chip_id
== BCS220_3
)
1749 rdmalt(Adapter
,HPM_CONFIG_MSW
, &uiResetValue
, 4);
1750 uiResetValue
|= (1<<17);
1751 wrmalt(Adapter
, HPM_CONFIG_MSW
, &uiResetValue
, 4);
1754 SendShutModeResponse(Adapter
);
1755 BCM_DEBUG_PRINT (Adapter
,DBG_TYPE_OTHERS
, MP_SHUTDOWN
, DBG_LVL_ALL
,"ShutDownModeResponse:Notification received: Sending the response(Ack/Nack)\n");
1758 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, MP_SHUTDOWN
, DBG_LVL_ALL
, "<====\n");
1763 VOID
ResetCounters(PMINI_ADAPTER Adapter
)
1766 beceem_protocol_reset(Adapter
);
1768 Adapter
->CurrNumRecvDescs
= 0;
1769 Adapter
->PrevNumRecvDescs
= 0;
1770 Adapter
->LinkUpStatus
= 0;
1771 Adapter
->LinkStatus
= 0;
1772 atomic_set(&Adapter
->cntrlpktCnt
,0);
1773 atomic_set (&Adapter
->TotalPacketCount
,0);
1774 Adapter
->fw_download_done
=FALSE
;
1775 Adapter
->LinkStatus
= 0;
1776 Adapter
->AutoLinkUp
= FALSE
;
1777 Adapter
->IdleMode
= FALSE
;
1778 Adapter
->bShutStatus
= FALSE
;
1781 S_CLASSIFIER_RULE
*GetFragIPClsEntry(PMINI_ADAPTER Adapter
,USHORT usIpIdentification
,ULONG SrcIP
)
1784 for(uiIndex
=0;uiIndex
<MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES
;uiIndex
++)
1786 if((Adapter
->astFragmentedPktClassifierTable
[uiIndex
].bUsed
)&&
1787 (Adapter
->astFragmentedPktClassifierTable
[uiIndex
].usIpIdentification
== usIpIdentification
)&&
1788 (Adapter
->astFragmentedPktClassifierTable
[uiIndex
].ulSrcIpAddress
== SrcIP
)&&
1789 !Adapter
->astFragmentedPktClassifierTable
[uiIndex
].bOutOfOrderFragment
)
1790 return Adapter
->astFragmentedPktClassifierTable
[uiIndex
].pstMatchedClassifierEntry
;
1795 void AddFragIPClsEntry(PMINI_ADAPTER Adapter
,PS_FRAGMENTED_PACKET_INFO psFragPktInfo
)
1798 for(uiIndex
=0;uiIndex
<MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES
;uiIndex
++)
1800 if(!Adapter
->astFragmentedPktClassifierTable
[uiIndex
].bUsed
)
1802 memcpy(&Adapter
->astFragmentedPktClassifierTable
[uiIndex
],psFragPktInfo
,sizeof(S_FRAGMENTED_PACKET_INFO
));
1809 void DelFragIPClsEntry(PMINI_ADAPTER Adapter
,USHORT usIpIdentification
,ULONG SrcIp
)
1812 for(uiIndex
=0;uiIndex
<MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES
;uiIndex
++)
1814 if((Adapter
->astFragmentedPktClassifierTable
[uiIndex
].bUsed
)&&
1815 (Adapter
->astFragmentedPktClassifierTable
[uiIndex
].usIpIdentification
== usIpIdentification
)&&
1816 (Adapter
->astFragmentedPktClassifierTable
[uiIndex
].ulSrcIpAddress
== SrcIp
))
1817 memset(&Adapter
->astFragmentedPktClassifierTable
[uiIndex
],0,sizeof(S_FRAGMENTED_PACKET_INFO
));
1821 void update_per_cid_rx (PMINI_ADAPTER Adapter
)
1825 if((jiffies
- Adapter
->liDrainCalculated
) < XSECONDS
)
1828 for(qindex
= 0; qindex
< HiPriority
; qindex
++)
1830 if(Adapter
->PackInfo
[qindex
].ucDirection
== 0)
1832 Adapter
->PackInfo
[qindex
].uiCurrentRxRate
=
1833 (Adapter
->PackInfo
[qindex
].uiCurrentRxRate
+
1834 Adapter
->PackInfo
[qindex
].uiThisPeriodRxBytes
)/2;
1836 Adapter
->PackInfo
[qindex
].uiThisPeriodRxBytes
= 0;
1840 Adapter
->PackInfo
[qindex
].uiCurrentDrainRate
=
1841 (Adapter
->PackInfo
[qindex
].uiCurrentDrainRate
+
1842 Adapter
->PackInfo
[qindex
].uiThisPeriodSentBytes
)/2;
1844 Adapter
->PackInfo
[qindex
].uiThisPeriodSentBytes
=0;
1847 Adapter
->liDrainCalculated
=jiffies
;
1849 void update_per_sf_desc_cnts( PMINI_ADAPTER Adapter
)
1852 u32 uibuff
[MAX_TARGET_DSX_BUFFERS
];
1854 if(!atomic_read (&Adapter
->uiMBupdate
))
1857 if(rdmaltWithLock(Adapter
, TARGET_SFID_TXDESC_MAP_LOC
, (PUINT
)uibuff
, sizeof(UINT
) * MAX_TARGET_DSX_BUFFERS
)<0)
1859 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0, "rdm failed\n");
1862 for(iIndex
= 0;iIndex
< HiPriority
; iIndex
++)
1864 if(Adapter
->PackInfo
[iIndex
].bValid
&& Adapter
->PackInfo
[iIndex
].ucDirection
)
1866 if(Adapter
->PackInfo
[iIndex
].usVCID_Value
< MAX_TARGET_DSX_BUFFERS
)
1868 atomic_set(&Adapter
->PackInfo
[iIndex
].uiPerSFTxResourceCount
, uibuff
[Adapter
->PackInfo
[iIndex
].usVCID_Value
]);
1872 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0, "Invalid VCID : %x \n",
1873 Adapter
->PackInfo
[iIndex
].usVCID_Value
);
1877 atomic_set (&Adapter
->uiMBupdate
, FALSE
);
1880 void flush_queue(PMINI_ADAPTER Adapter
, UINT iQIndex
)
1882 struct sk_buff
* PacketToDrop
=NULL
;
1883 struct net_device_stats
* netstats
= &Adapter
->dev
->stats
;
1885 spin_lock_bh(&Adapter
->PackInfo
[iQIndex
].SFQueueLock
);
1887 while(Adapter
->PackInfo
[iQIndex
].FirstTxQueue
&&
1888 atomic_read(&Adapter
->TotalPacketCount
))
1890 PacketToDrop
= Adapter
->PackInfo
[iQIndex
].FirstTxQueue
;
1891 if(PacketToDrop
&& PacketToDrop
->len
)
1893 netstats
->tx_dropped
++;
1894 DEQUEUEPACKET(Adapter
->PackInfo
[iQIndex
].FirstTxQueue
, \
1895 Adapter
->PackInfo
[iQIndex
].LastTxQueue
);
1897 Adapter
->PackInfo
[iQIndex
].uiCurrentPacketsOnHost
--;
1898 Adapter
->PackInfo
[iQIndex
].uiCurrentBytesOnHost
-= PacketToDrop
->len
;
1900 //Adding dropped statistics
1901 Adapter
->PackInfo
[iQIndex
].uiDroppedCountBytes
+= PacketToDrop
->len
;
1902 Adapter
->PackInfo
[iQIndex
].uiDroppedCountPackets
++;
1904 dev_kfree_skb(PacketToDrop
);
1905 atomic_dec(&Adapter
->TotalPacketCount
);
1906 atomic_inc(&Adapter
->TxDroppedPacketCount
);
1910 spin_unlock_bh(&Adapter
->PackInfo
[iQIndex
].SFQueueLock
);
1914 void beceem_protocol_reset (PMINI_ADAPTER Adapter
)
1918 if (netif_msg_link(Adapter
))
1919 pr_notice(DRV_NAME
"%s: protocol reset\n", Adapter
->dev
->name
);
1921 netif_carrier_off(Adapter
->dev
);
1922 netif_stop_queue(Adapter
->dev
);
1924 Adapter
->IdleMode
= FALSE
;
1925 Adapter
->LinkUpStatus
= FALSE
;
1926 ClearTargetDSXBuffer(Adapter
,0, TRUE
);
1927 //Delete All Classifier Rules
1929 for(i
= 0;i
<HiPriority
;i
++)
1931 DeleteAllClassifiersForSF(Adapter
,i
);
1934 flush_all_queues(Adapter
);
1936 if(Adapter
->TimerActive
== TRUE
)
1937 Adapter
->TimerActive
= FALSE
;
1939 memset(Adapter
->astFragmentedPktClassifierTable
, 0,
1940 sizeof(S_FRAGMENTED_PACKET_INFO
) * MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES
);
1942 for(i
= 0;i
<HiPriority
;i
++)
1944 //resetting only the first size (S_MIBS_SERVICEFLOW_TABLE) for the SF.
1945 // It is same between MIBs and SF.
1946 memset(&Adapter
->PackInfo
[i
].stMibsExtServiceFlowTable
,
1947 0, sizeof(S_MIBS_EXTSERVICEFLOW_PARAMETERS
));