4 *Copyright (C) 2010 Beceem Communications, Inc.
6 *This program is free software: you can redistribute it and/or modify
7 *it under the terms of the GNU General Public License version 2 as
8 *published by the Free Software Foundation.
10 *This program is distributed in the hope that it will be useful,but
11 *WITHOUT ANY WARRANTY; without even the implied warranty of
12 *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 *See the GNU General Public License for more details.
15 *You should have received a copy of the GNU General Public License
16 *along with this program. If not, write to the Free Software Foundation, Inc.,
17 *51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 extern int DeviceInsertedCount
;
26 static VOID
default_wimax_protocol_initialize(PMINI_ADAPTER Adapter
)
31 for(uiLoopIndex
=0; uiLoopIndex
< NO_OF_QUEUES
-1; uiLoopIndex
++)
33 Adapter
->PackInfo
[uiLoopIndex
].uiThreshold
=TX_PACKET_THRESHOLD
;
34 Adapter
->PackInfo
[uiLoopIndex
].uiMaxAllowedRate
=MAX_ALLOWED_RATE
;
35 Adapter
->PackInfo
[uiLoopIndex
].uiMaxBucketSize
=20*1024*1024;
38 Adapter
->BEBucketSize
=BE_BUCKET_SIZE
;
39 Adapter
->rtPSBucketSize
=rtPS_BUCKET_SIZE
;
40 Adapter
->LinkStatus
=SYNC_UP_REQUEST
;
41 Adapter
->TransferMode
=IP_PACKET_ONLY_MODE
;
42 Adapter
->usBestEffortQueueIndex
=-1;
48 InitAdapter(PMINI_ADAPTER psAdapter
)
51 INT Status
= STATUS_SUCCESS
;
52 BCM_DEBUG_PRINT(psAdapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Initialising Adapter = 0x%x",(unsigned int) psAdapter
);
56 BCM_DEBUG_PRINT(psAdapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Adapter is NULL");
60 sema_init(&psAdapter
->NVMRdmWrmLock
,1);
61 // psAdapter->ulFlashCalStart = FLASH_AUTO_INIT_BASE_ADDR;
63 sema_init(&psAdapter
->rdmwrmsync
, 1);
64 sema_init(&psAdapter
->rdmWrmDevAccLock
, 1);
65 spin_lock_init(&psAdapter
->control_queue_lock
);
66 spin_lock_init(&psAdapter
->txtransmitlock
);
67 sema_init(&psAdapter
->RxAppControlQueuelock
, 1);
68 // sema_init(&psAdapter->data_packet_queue_lock, 1);
69 sema_init(&psAdapter
->fw_download_sema
, 1);
70 sema_init(&psAdapter
->LowPowerModeSync
,1);
72 // spin_lock_init(&psAdapter->sleeper_lock);
73 for(i
=0;i
<NO_OF_QUEUES
; i
++)
74 spin_lock_init(&psAdapter
->PackInfo
[i
].SFQueueLock
);
77 init_waitqueue_head(&psAdapter
->process_rx_cntrlpkt
);
78 init_waitqueue_head(&psAdapter
->tx_packet_wait_queue
);
79 init_waitqueue_head(&psAdapter
->process_read_wait_queue
);
80 init_waitqueue_head(&psAdapter
->ioctl_fw_dnld_wait_queue
);
81 init_waitqueue_head(&psAdapter
->lowpower_mode_wait_queue
);
82 psAdapter
->waiting_to_fw_download_done
= TRUE
;
83 //init_waitqueue_head(&psAdapter->device_wake_queue);
84 psAdapter
->fw_download_done
=FALSE
;
86 psAdapter
->pvOsDepData
= (PLINUX_DEP_DATA
) kmalloc(sizeof(LINUX_DEP_DATA
),
89 if(psAdapter
->pvOsDepData
== NULL
)
91 BCM_DEBUG_PRINT(psAdapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Linux Specific Data allocation failed");
94 memset(psAdapter
->pvOsDepData
, 0, sizeof(LINUX_DEP_DATA
));
96 default_wimax_protocol_initialize(psAdapter
);
97 for (i
=0;i
<MAX_CNTRL_PKTS
;i
++)
99 psAdapter
->txctlpacket
[i
] = (char *)kmalloc(MAX_CNTL_PKT_SIZE
,
101 if(!psAdapter
->txctlpacket
[i
])
103 BCM_DEBUG_PRINT(psAdapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "No More Cntl pkts got, max got is %d", i
);
107 if(AllocAdapterDsxBuffer(psAdapter
))
109 BCM_DEBUG_PRINT(psAdapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Failed to allocate DSX buffers");
113 //Initialize PHS interface
114 if(phs_init(&psAdapter
->stBCMPhsContext
,psAdapter
)!=0)
116 BCM_DEBUG_PRINT(psAdapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
,"%s:%s:%d:Error PHS Init Failed=====>\n", __FILE__
, __FUNCTION__
, __LINE__
);
120 Status
= BcmAllocFlashCSStructure(psAdapter
);
123 BCM_DEBUG_PRINT(psAdapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
,"Memory Allocation for Flash structure failed");
127 Status
= vendorextnInit(psAdapter
);
129 if(STATUS_SUCCESS
!= Status
)
131 BCM_DEBUG_PRINT(psAdapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
,"Vendor Init Failed");
135 BCM_DEBUG_PRINT(psAdapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Adapter initialised");
138 return STATUS_SUCCESS
;
141 VOID
AdapterFree(PMINI_ADAPTER Adapter
)
145 //Driver supports only one device...
146 //In case of probe not success this function got called...
147 // Making DeviceInsertedCount value as zero: so other device can be inserted.
149 DeviceInsertedCount
= 0;
151 beceem_protocol_reset(Adapter
);
153 vendorextnExit(Adapter
);
155 if(Adapter
->control_packet_handler
&& !IS_ERR(Adapter
->control_packet_handler
))
156 kthread_stop (Adapter
->control_packet_handler
);
157 if(Adapter
->transmit_packet_thread
&& !IS_ERR(Adapter
->transmit_packet_thread
))
158 kthread_stop (Adapter
->transmit_packet_thread
);
159 wake_up(&Adapter
->process_read_wait_queue
);
160 if(Adapter
->LEDInfo
.led_thread_running
& (BCM_LED_THREAD_RUNNING_ACTIVELY
| BCM_LED_THREAD_RUNNING_INACTIVELY
))
161 kthread_stop (Adapter
->LEDInfo
.led_cntrl_threadid
);
162 bcm_unregister_networkdev(Adapter
);
163 while(atomic_read(&Adapter
->ApplicationRunning
))
165 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Waiting for Application to close.. %d\n",atomic_read(&Adapter
->ApplicationRunning
));
168 unregister_control_device_interface(Adapter
);
169 if(Adapter
->dev
&& !IS_ERR(Adapter
->dev
))
170 free_netdev(Adapter
->dev
);
171 if(Adapter
->pstargetparams
!= NULL
)
173 bcm_kfree(Adapter
->pstargetparams
);
175 for (count
=0;count
< MAX_CNTRL_PKTS
;count
++)
177 if(Adapter
->txctlpacket
[count
])
178 bcm_kfree(Adapter
->txctlpacket
[count
]);
180 FreeAdapterDsxBuffer(Adapter
);
181 if(Adapter
->pvOsDepData
)
182 bcm_kfree (Adapter
->pvOsDepData
);
183 if(Adapter
->pvInterfaceAdapter
)
184 bcm_kfree(Adapter
->pvInterfaceAdapter
);
186 //Free the PHS Interface
187 PhsCleanup(&Adapter
->stBCMPhsContext
);
189 #ifndef BCM_SHM_INTERFACE
190 BcmDeAllocFlashCSStructure(Adapter
);
194 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "<========\n");
198 int create_worker_threads(PMINI_ADAPTER psAdapter
)
200 BCM_DEBUG_PRINT(psAdapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Init Threads...");
201 // Rx Control Packets Processing
202 psAdapter
->control_packet_handler
= kthread_run((int (*)(void *))
203 control_packet_handler
, psAdapter
, "CtrlPktHdlr");
204 if(IS_ERR(psAdapter
->control_packet_handler
))
206 BCM_DEBUG_PRINT(psAdapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "No Kernel Thread, but still returning success\n");
207 return PTR_ERR(psAdapter
->control_packet_handler
);
210 psAdapter
->transmit_packet_thread
= kthread_run((int (*)(void *))
211 tx_pkt_handler
, psAdapter
, "TxPktThread");
212 if(IS_ERR (psAdapter
->transmit_packet_thread
))
214 BCM_DEBUG_PRINT(psAdapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "No Kernel Thread, but still returning success");
215 kthread_stop(psAdapter
->control_packet_handler
);
216 return PTR_ERR(psAdapter
->transmit_packet_thread
);
222 static inline struct file
*open_firmware_file(PMINI_ADAPTER Adapter
, char *path
)
224 struct file
*flp
=NULL
;
228 flp
=filp_open(path
, O_RDONLY
, S_IRWXU
);
232 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Unable To Open File %s, err %lx",
238 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Got file descriptor pointer of %s!",
241 if(Adapter
->device_removed
)
250 int BcmFileDownload(PMINI_ADAPTER Adapter
,/**< Logical Adapter */
251 char *path
, /**< path to image file */
252 unsigned int loc
/**< Download Address on the chip*/
256 struct file
*flp
=NULL
;
258 struct timeval tv
={0};
260 flp
=open_firmware_file(Adapter
, path
);
264 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Unable to Open %s\n", path
);
267 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
);
268 do_gettimeofday(&tv
);
270 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "download start %lx", ((tv
.tv_sec
* 1000) +
272 if(Adapter
->bcm_file_download(Adapter
->pvInterfaceAdapter
, flp
, loc
))
274 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Failed to download the firmware with error\
279 oldfs
=get_fs();set_fs(get_ds());
280 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
281 vfs_llseek(flp
, 0, 0);
284 if(Adapter
->bcm_file_readback_from_chip(Adapter
->pvInterfaceAdapter
,
287 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Failed to read back firmware!");
293 oldfs
=get_fs();set_fs(get_ds());
294 if(flp
&& !(IS_ERR(flp
)))
295 filp_close(flp
, current
->files
);
297 do_gettimeofday(&tv
);
298 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "file download done at %lx", ((tv
.tv_sec
* 1000) +
304 void bcm_kfree_skb(struct sk_buff
*skb
)
313 VOID
bcm_kfree(VOID
*ptr
)
323 @ingroup ctrl_pkt_functions
324 This function copies the contents of given buffer
325 to the control packet and queues it for transmission.
326 @note Do not acquire the spinock, as it it already acquired.
327 @return SUCCESS/FAILURE.
329 INT
CopyBufferToControlPacket(PMINI_ADAPTER Adapter
,/**<Logical Adapter*/
330 PVOID ioBuffer
/**<Control Packet Buffer*/
333 PLEADER pLeader
=NULL
;
335 unsigned char *ctrl_buff
=NULL
;
337 PLINK_REQUEST pLinkReq
= NULL
;
338 PUCHAR pucAddIndication
= NULL
;
340 BCM_DEBUG_PRINT( Adapter
,DBG_TYPE_TX
, TX_CONTROL
, DBG_LVL_ALL
, "======>");
343 BCM_DEBUG_PRINT( Adapter
,DBG_TYPE_TX
, TX_CONTROL
,DBG_LVL_ALL
, "Got Null Buffer\n");
347 pLinkReq
= (PLINK_REQUEST
)ioBuffer
;
348 pLeader
=(PLEADER
)ioBuffer
; //ioBuffer Contains sw_Status and Payload
350 if(Adapter
->bShutStatus
== TRUE
&&
351 pLinkReq
->szData
[0] == LINK_DOWN_REQ_PAYLOAD
&&
352 pLinkReq
->szData
[1] == LINK_SYNC_UP_SUBTYPE
)
354 //Got sync down in SHUTDOWN..we could not process this.
355 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, TX_CONTROL
,DBG_LVL_ALL
, "SYNC DOWN Request in Shut Down Mode..\n");
356 return STATUS_FAILURE
;
359 if((pLeader
->Status
== LINK_UP_CONTROL_REQ
) &&
360 ((pLinkReq
->szData
[0] == LINK_UP_REQ_PAYLOAD
&&
361 (pLinkReq
->szData
[1] == LINK_SYNC_UP_SUBTYPE
)) ||//Sync Up Command
362 pLinkReq
->szData
[0] == NETWORK_ENTRY_REQ_PAYLOAD
)) //Net Entry Command
364 if(Adapter
->LinkStatus
> PHY_SYNC_ACHIVED
)
366 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, TX_CONTROL
,DBG_LVL_ALL
,"LinkStatus is Greater than PHY_SYN_ACHIEVED");
367 return STATUS_FAILURE
;
369 if(TRUE
== Adapter
->bShutStatus
)
371 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, TX_CONTROL
,DBG_LVL_ALL
, "SYNC UP IN SHUTDOWN..Device WakeUp\n");
372 if(Adapter
->bTriedToWakeUpFromlowPowerMode
== FALSE
)
374 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, TX_CONTROL
,DBG_LVL_ALL
, "Waking up for the First Time..\n");
375 Adapter
->usIdleModePattern
= ABORT_SHUTDOWN_MODE
; // change it to 1 for current support.
376 Adapter
->bWakeUpDevice
= TRUE
;
377 wake_up(&Adapter
->process_rx_cntrlpkt
);
379 Status
= wait_event_interruptible_timeout(Adapter
->lowpower_mode_wait_queue
,
380 !Adapter
->bShutStatus
, (5 * HZ
));
382 if(Status
== -ERESTARTSYS
)
385 if(Adapter
->bShutStatus
)
387 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, TX_CONTROL
,DBG_LVL_ALL
, "Shutdown Mode Wake up Failed - No Wake Up Received\n");
388 return STATUS_FAILURE
;
393 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, TX_CONTROL
,DBG_LVL_ALL
, "Wakeup has been tried already...\n");
398 if(TRUE
== Adapter
->IdleMode
)
400 //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Device is in Idle mode ... hence \n");
401 if(pLeader
->Status
== LINK_UP_CONTROL_REQ
|| pLeader
->Status
== 0x80 ||
402 pLeader
->Status
== CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ
)
405 if((pLeader
->Status
== LINK_UP_CONTROL_REQ
) && (pLinkReq
->szData
[0]==LINK_DOWN_REQ_PAYLOAD
))
407 if((pLinkReq
->szData
[1] == LINK_SYNC_DOWN_SUBTYPE
))
409 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, TX_CONTROL
,DBG_LVL_ALL
, "Link Down Sent in Idle Mode\n");
410 Adapter
->usIdleModePattern
= ABORT_IDLE_SYNCDOWN
;//LINK DOWN sent in Idle Mode
414 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, TX_CONTROL
,DBG_LVL_ALL
,"ABORT_IDLE_MODE pattern is being written\n");
415 Adapter
->usIdleModePattern
= ABORT_IDLE_REG
;
420 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, TX_CONTROL
,DBG_LVL_ALL
,"ABORT_IDLE_MODE pattern is being written\n");
421 Adapter
->usIdleModePattern
= ABORT_IDLE_MODE
;
424 /*Setting bIdleMode_tx_from_host to TRUE to indicate LED control thread to represent
425 the wake up from idlemode is from host*/
426 //Adapter->LEDInfo.bIdleMode_tx_from_host = TRUE;
428 if(STATUS_SUCCESS
!= InterfaceIdleModeWakeup(Adapter
))
430 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, NEXT_SEND
, DBG_LVL_ALL
, "Idle Mode Wake up Failed\n");
431 return STATUS_FAILURE
;
434 Adapter
->bWakeUpDevice
= TRUE
;
435 wake_up(&Adapter
->process_rx_cntrlpkt
);
439 if(LINK_DOWN_REQ_PAYLOAD
== pLinkReq
->szData
[0])
441 // We should not send DREG message down while in idlemode.
442 return STATUS_SUCCESS
;
445 Status
= wait_event_interruptible_timeout(Adapter
->lowpower_mode_wait_queue
,
446 !Adapter
->IdleMode
, (5 * HZ
));
448 if(Status
== -ERESTARTSYS
)
451 if(Adapter
->IdleMode
)
453 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, TX_CONTROL
,DBG_LVL_ALL
, "Idle Mode Wake up Failed - No Wake Up Received\n");
454 return STATUS_FAILURE
;
458 return STATUS_SUCCESS
;
460 //The Driver has to send control messages with a particular VCID
461 pLeader
->Vcid
= VCID_CONTROL_PACKET
;//VCID for control packet.
463 /* Allocate skb for Control Packet */
464 pktlen
= pLeader
->PLength
;
467 if((pLeader
->Status
== 0x80) ||
468 (pLeader
->Status
== CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ
))
471 //Restructure the DSX message to handle Multiple classifier Support
472 // Write the Service Flow param Structures directly to the target
473 //and embed the pointers in the DSX messages sent to target.
475 //Lets store the current length of the control packet we are transmitting
476 pucAddIndication
= (PUCHAR
)ioBuffer
+ LEADER_SIZE
;
477 pktlen
= pLeader
->PLength
;
478 Status
= StoreCmControlResponseMessage(Adapter
,pucAddIndication
, &pktlen
);
481 ClearTargetDSXBuffer(Adapter
,((stLocalSFAddIndicationAlt
*)pucAddIndication
)->u16TID
, FALSE
);
482 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 ");
483 return STATUS_FAILURE
;
486 //update the leader to use the new length
487 //The length of the control packet is length of message being sent + Leader length
489 pLeader
->PLength
= pktlen
;
493 /*Update the statistics counters */
494 spin_lock_bh(&Adapter
->PackInfo
[HiPriority
].SFQueueLock
);
496 ctrl_buff
= (char *)Adapter
->txctlpacket
[atomic_read(&Adapter
->index_wr_txcntrlpkt
)%MAX_CNTRL_PKTS
];
498 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", atomic_read(&Adapter
->index_wr_txcntrlpkt
), ctrl_buff
, ioBuffer
, pktlen
);
501 memset(ctrl_buff
, 0, pktlen
+LEADER_SIZE
);
502 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, TX_CONTROL
, DBG_LVL_ALL
, "Copying the Control Packet Buffer with length=%d\n", pLeader
->PLength
);
503 *(PLEADER
)ctrl_buff
=*pLeader
;
504 memcpy(ctrl_buff
+ LEADER_SIZE
, ((PUCHAR
)ioBuffer
+ LEADER_SIZE
), pLeader
->PLength
);
505 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, TX_CONTROL
, DBG_LVL_ALL
, "Enqueuing the Control Packet");
507 Adapter
->PackInfo
[HiPriority
].uiCurrentBytesOnHost
+=pLeader
->PLength
;
508 Adapter
->PackInfo
[HiPriority
].uiCurrentPacketsOnHost
++;
509 atomic_inc(&Adapter
->TotalPacketCount
);
511 Adapter
->PackInfo
[HiPriority
].bValid
= TRUE
;
513 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, TX_CONTROL
, DBG_LVL_ALL
, "CurrBytesOnHost: %x bValid: %x",
514 Adapter
->PackInfo
[HiPriority
].uiCurrentBytesOnHost
,
515 Adapter
->PackInfo
[HiPriority
].bValid
);
516 Status
=STATUS_SUCCESS
;
517 /*Queue the packet for transmission */
518 atomic_inc(&Adapter
->index_wr_txcntrlpkt
);
519 BCM_DEBUG_PRINT( Adapter
,DBG_TYPE_TX
, TX_CONTROL
,DBG_LVL_ALL
, "Calling transmit_packets");
520 atomic_set(&Adapter
->TxPktAvail
, 1);
521 #ifdef BCM_SHM_INTERFACE
522 virtual_mail_box_interrupt();
524 wake_up(&Adapter
->tx_packet_wait_queue
);
529 BCM_DEBUG_PRINT( Adapter
,DBG_TYPE_TX
, TX_CONTROL
, DBG_LVL_ALL
, "mem allocation Failed");
531 spin_unlock_bh(&Adapter
->PackInfo
[HiPriority
].SFQueueLock
);
532 BCM_DEBUG_PRINT( Adapter
,DBG_TYPE_TX
, TX_CONTROL
, DBG_LVL_ALL
, "<====");
536 /*****************************************************************
537 * Function - SendStatisticsPointerRequest()
539 * Description - This function builds and forwards the Statistics
540 * Pointer Request control Packet.
542 * Parameters - Adapter : Pointer to Adapter structure.
543 * - pstStatisticsPtrRequest : Pointer to link request.
546 *****************************************************************/
547 VOID
SendStatisticsPointerRequest(PMINI_ADAPTER Adapter
,
548 PLINK_REQUEST pstStatisticsPtrRequest
)
550 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_RX
, RX_DPC
, DBG_LVL_ALL
, "======>");
551 pstStatisticsPtrRequest
->Leader
.Status
= STATS_POINTER_REQ_STATUS
;
552 pstStatisticsPtrRequest
->Leader
.PLength
= sizeof(ULONG
);//minimum 4 bytes
553 pstStatisticsPtrRequest
->szData
[0] = STATISTICS_POINTER_REQ
;
555 CopyBufferToControlPacket(Adapter
,pstStatisticsPtrRequest
);
556 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_RX
, RX_DPC
, DBG_LVL_ALL
, "<=====");
562 void SendLinkDown(PMINI_ADAPTER Adapter
)
564 LINK_REQUEST stLinkDownRequest
;
565 memset(&stLinkDownRequest
, 0, sizeof(LINK_REQUEST
));
566 stLinkDownRequest
.Leader
.Status
=LINK_UP_CONTROL_REQ
;
567 stLinkDownRequest
.Leader
.PLength
=sizeof(ULONG
);//minimum 4 bytes
568 stLinkDownRequest
.szData
[0]=LINK_DOWN_REQ_PAYLOAD
;
569 Adapter
->bLinkDownRequested
= TRUE
;
571 CopyBufferToControlPacket(Adapter
,&stLinkDownRequest
);
574 /******************************************************************
575 * Function - LinkMessage()
577 * Description - This function builds the Sync-up and Link-up request
578 * packet messages depending on the device Link status.
580 * Parameters - Adapter: Pointer to the Adapter structure.
583 *******************************************************************/
584 __inline VOID
LinkMessage(PMINI_ADAPTER Adapter
)
586 PLINK_REQUEST pstLinkRequest
=NULL
;
587 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, LINK_UP_MSG
, DBG_LVL_ALL
, "=====>");
588 if(Adapter
->LinkStatus
== SYNC_UP_REQUEST
&& Adapter
->AutoSyncup
)
590 pstLinkRequest
=kmalloc(sizeof(LINK_REQUEST
), GFP_ATOMIC
);
593 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, LINK_UP_MSG
, DBG_LVL_ALL
, "Can not allocate memory for Link request!");
596 memset(pstLinkRequest
,0,sizeof(LINK_REQUEST
));
598 Adapter
->LinkStatus
= WAIT_FOR_SYNC
;// current link status
599 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, LINK_UP_MSG
, DBG_LVL_ALL
, "Requesting For SyncUp...");
600 pstLinkRequest
->szData
[0]=LINK_UP_REQ_PAYLOAD
;
601 pstLinkRequest
->szData
[1]=LINK_SYNC_UP_SUBTYPE
;
602 pstLinkRequest
->Leader
.Status
=LINK_UP_CONTROL_REQ
;
603 pstLinkRequest
->Leader
.PLength
=sizeof(ULONG
);
604 Adapter
->bSyncUpRequestSent
= TRUE
;
606 else if(Adapter
->LinkStatus
== PHY_SYNC_ACHIVED
&& Adapter
->AutoLinkUp
)
608 pstLinkRequest
=kmalloc(sizeof(LINK_REQUEST
), GFP_ATOMIC
);
611 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, LINK_UP_MSG
, DBG_LVL_ALL
, "Can not allocate memory for Link request!");
614 memset(pstLinkRequest
,0,sizeof(LINK_REQUEST
));
616 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, LINK_UP_MSG
, DBG_LVL_ALL
, "Requesting For LinkUp...");
617 pstLinkRequest
->szData
[0]=LINK_UP_REQ_PAYLOAD
;
618 pstLinkRequest
->szData
[1]=LINK_NET_ENTRY
;
619 pstLinkRequest
->Leader
.Status
=LINK_UP_CONTROL_REQ
;
620 pstLinkRequest
->Leader
.PLength
=sizeof(ULONG
);
624 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, LINK_UP_MSG
, DBG_LVL_ALL
, "Calling CopyBufferToControlPacket");
625 CopyBufferToControlPacket(Adapter
, pstLinkRequest
);
626 bcm_kfree(pstLinkRequest
);
628 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, LINK_UP_MSG
, DBG_LVL_ALL
, "LinkMessage <=====");
633 /**********************************************************************
634 * Function - StatisticsResponse()
636 * Description - This function handles the Statistics response packet.
638 * Parameters - Adapter : Pointer to the Adapter structure.
639 * - pvBuffer: Starting address of Statistic response data.
642 ************************************************************************/
643 VOID
StatisticsResponse(PMINI_ADAPTER Adapter
,PVOID pvBuffer
)
645 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
, "%s====>",__FUNCTION__
);
646 Adapter
->StatisticsPointer
= ntohl(*(PULONG
)pvBuffer
);
647 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
, "Stats at %lx", Adapter
->StatisticsPointer
);
648 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
, "%s <====",__FUNCTION__
);
653 /**********************************************************************
654 * Function - LinkControlResponseMessage()
656 * Description - This function handles the Link response packets.
658 * Parameters - Adapter : Pointer to the Adapter structure.
659 * - pucBuffer: Starting address of Link response data.
662 ***********************************************************************/
663 VOID
LinkControlResponseMessage(PMINI_ADAPTER Adapter
,PUCHAR pucBuffer
)
665 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_RX
, RX_DPC
, DBG_LVL_ALL
, "=====>");
667 if(*pucBuffer
==LINK_UP_ACK
)
669 switch(*(pucBuffer
+1))
671 case PHY_SYNC_ACHIVED
: //SYNCed UP
672 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0, "PHY_SYNC_ACHIVED");
674 if(Adapter
->LinkStatus
== LINKUP_DONE
)
676 beceem_protocol_reset(Adapter
);
679 Adapter
->usBestEffortQueueIndex
=INVALID_QUEUE_INDEX
;
680 Adapter
->LinkStatus
=PHY_SYNC_ACHIVED
;
682 if(Adapter
->LEDInfo
.led_thread_running
& BCM_LED_THREAD_RUNNING_ACTIVELY
)
684 Adapter
->DriverState
= NO_NETWORK_ENTRY
;
685 wake_up(&Adapter
->LEDInfo
.notify_led_event
);
688 LinkMessage(Adapter
);
692 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_RX
, RX_DPC
, DBG_LVL_ALL
, "LINKUP_DONE");
693 Adapter
->LinkStatus
=LINKUP_DONE
;
694 Adapter
->bPHSEnabled
= *(pucBuffer
+3);
695 Adapter
->bETHCSEnabled
= *(pucBuffer
+4) & ETH_CS_MASK
;
696 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0, "PHS Support Status Recieved In LinkUp Ack : %x \n",Adapter
->bPHSEnabled
);
697 if((FALSE
== Adapter
->bShutStatus
)&&
698 (FALSE
== Adapter
->IdleMode
))
700 if(Adapter
->LEDInfo
.led_thread_running
& BCM_LED_THREAD_RUNNING_ACTIVELY
)
702 Adapter
->DriverState
= NORMAL_OPERATION
;
703 wake_up(&Adapter
->LEDInfo
.notify_led_event
);
706 LinkMessage(Adapter
);
711 * Driver to ignore the DREG_RECEIVED
712 * WiMAX Application should handle this Message
714 //Adapter->liTimeSinceLastNetEntry = 0;
715 Adapter
->LinkUpStatus
= 0;
716 Adapter
->LinkStatus
= 0;
717 Adapter
->usBestEffortQueueIndex
=INVALID_QUEUE_INDEX
;
718 Adapter
->bTriedToWakeUpFromlowPowerMode
= FALSE
;
719 Adapter
->IdleMode
= FALSE
;
721 if(Adapter
->LEDInfo
.led_thread_running
& BCM_LED_THREAD_RUNNING_ACTIVELY
)
723 Adapter
->DriverState
= NO_NETWORK_ENTRY
;
724 wake_up(&Adapter
->LEDInfo
.notify_led_event
);
727 beceem_protocol_reset(Adapter
);
730 case LINK_SHUTDOWN_REQ_FROM_FIRMWARE
:
731 case SHUTDOWN_REQ_FRM_FW_STANDBY_TIMER
:
732 case SHUTDOWN_REQ_FRM_FW_HIBERNATION_BUTTON_PRESS
:
733 case COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW
:
735 HandleShutDownModeRequest(Adapter
, pucBuffer
);
739 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0, "default case:LinkResponse %x",*(pucBuffer
+1));
743 else if(SET_MAC_ADDRESS_RESPONSE
==*pucBuffer
)
745 PUCHAR puMacAddr
= (pucBuffer
+ 1);
746 Adapter
->LinkStatus
=SYNC_UP_REQUEST
;
747 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_RX
, RX_DPC
, DBG_LVL_ALL
, "MAC address response, sending SYNC_UP");
748 LinkMessage(Adapter
);
749 memcpy(Adapter
->dev
->dev_addr
, puMacAddr
, MAC_ADDRESS_SIZE
);
751 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_RX
, RX_DPC
, DBG_LVL_ALL
, "%s <=====",__FUNCTION__
);
755 void SendIdleModeResponse(PMINI_ADAPTER Adapter
)
757 INT status
= 0, NVMAccess
= 0,lowPwrAbortMsg
= 0;
759 CONTROL_MESSAGE stIdleResponse
= {{0}};
760 memset(&tv
, 0, sizeof(tv
));
761 stIdleResponse
.Leader
.Status
= IDLE_MESSAGE
;
762 stIdleResponse
.Leader
.PLength
= IDLE_MODE_PAYLOAD_LENGTH
;
763 stIdleResponse
.szData
[0] = GO_TO_IDLE_MODE_PAYLOAD
;
764 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_RX
, RX_DPC
, DBG_LVL_ALL
," ============>");
766 /*********************************
768 ** if [ semaphore is available ]
769 ** acquire semaphone and return value 0 ;
771 ** return non-zero value ;
773 ***********************************/
775 NVMAccess
= down_trylock(&Adapter
->NVMRdmWrmLock
);
777 lowPwrAbortMsg
= down_trylock(&Adapter
->LowPowerModeSync
);
780 if((NVMAccess
|| lowPwrAbortMsg
|| atomic_read(&Adapter
->TotalPacketCount
)) &&
781 (Adapter
->ulPowerSaveMode
!= DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE
) )
784 up(&Adapter
->NVMRdmWrmLock
);
787 up(&Adapter
->LowPowerModeSync
);
789 stIdleResponse
.szData
[1] = TARGET_CAN_NOT_GO_TO_IDLE_MODE
;//NACK- device access is going on.
790 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_RX
, RX_DPC
, DBG_LVL_ALL
, "HOST IS NACKING Idle mode To F/W!!!!!!!!");
791 Adapter
->bPreparingForLowPowerMode
= FALSE
;
795 stIdleResponse
.szData
[1] = TARGET_CAN_GO_TO_IDLE_MODE
; //2;//Idle ACK
796 Adapter
->StatisticsPointer
= 0;
798 /* Wait for the LED to TURN OFF before sending ACK response */
799 if(Adapter
->LEDInfo
.led_thread_running
& BCM_LED_THREAD_RUNNING_ACTIVELY
)
803 /* Wake the LED Thread with IDLEMODE_ENTER State */
804 Adapter
->DriverState
= LOWPOWER_MODE_ENTER
;
805 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
);;
806 wake_up(&Adapter
->LEDInfo
.notify_led_event
);
808 /* Wait for 1 SEC for LED to OFF */
809 iRetVal
= wait_event_timeout(Adapter
->LEDInfo
.idleModeSyncEvent
, \
810 Adapter
->LEDInfo
.bIdle_led_off
, msecs_to_jiffies(1000));
813 /* If Timed Out to Sync IDLE MODE Enter, do IDLE mode Exit and Send NACK to device */
816 stIdleResponse
.szData
[1] = TARGET_CAN_NOT_GO_TO_IDLE_MODE
;//NACK- device access is going on.
817 Adapter
->DriverState
= NORMAL_OPERATION
;
818 wake_up(&Adapter
->LEDInfo
.notify_led_event
);
819 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_RX
, RX_DPC
, DBG_LVL_ALL
, "NACKING Idle mode as time out happen from LED side!!!!!!!!");
822 if(stIdleResponse
.szData
[1] == TARGET_CAN_GO_TO_IDLE_MODE
)
824 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_RX
, RX_DPC
, DBG_LVL_ALL
,"ACKING IDLE MODE !!!!!!!!!");
825 down(&Adapter
->rdmwrmsync
);
826 Adapter
->bPreparingForLowPowerMode
= TRUE
;
827 up(&Adapter
->rdmwrmsync
);
828 #ifndef BCM_SHM_INTERFACE
830 if(Adapter
->bDoSuspend
== TRUE
)
831 Bcm_kill_all_URBs((PS_INTERFACE_ADAPTER
)(Adapter
->pvInterfaceAdapter
));
837 Adapter
->bPreparingForLowPowerMode
= FALSE
;
841 up(&Adapter
->NVMRdmWrmLock
);
844 up(&Adapter
->LowPowerModeSync
);
847 status
= CopyBufferToControlPacket(Adapter
,&stIdleResponse
);
848 if((status
!= STATUS_SUCCESS
))
850 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"fail to send the Idle mode Request \n");
851 Adapter
->bPreparingForLowPowerMode
= FALSE
;
852 #ifndef BCM_SHM_INTERFACE
853 StartInterruptUrb((PS_INTERFACE_ADAPTER
)(Adapter
->pvInterfaceAdapter
));
856 do_gettimeofday(&tv
);
857 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);
861 /******************************************************************
862 * Function - DumpPackInfo()
864 * Description - This function dumps the all Queue(PackInfo[]) details.
866 * Parameters - Adapter: Pointer to the Adapter structure.
869 *******************************************************************/
870 VOID
DumpPackInfo(PMINI_ADAPTER Adapter
)
872 UINT uiLoopIndex
= 0;
874 UINT uiClsfrIndex
= 0;
875 S_CLASSIFIER_RULE
*pstClassifierEntry
= NULL
;
877 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"Total Packets at host: %x\n",atomic_read(&Adapter
->TotalPacketCount
));
878 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"Read Counter for Control Packet: %x\n",atomic_read(&Adapter
->index_rd_txcntrlpkt
));
879 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"Write Counter for Control Packet: %x\n",atomic_read(&Adapter
->index_wr_txcntrlpkt
));
881 for(uiLoopIndex
=0;uiLoopIndex
<NO_OF_QUEUES
;uiLoopIndex
++)
883 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"*********** Showing Details Of Queue %d***** ******",uiLoopIndex
);
884 if(FALSE
== Adapter
->PackInfo
[uiLoopIndex
].bValid
)
886 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"bValid is FALSE for %X index\n",uiLoopIndex
);
890 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
," Dumping SF Rule Entry For SFID %lX \n",Adapter
->PackInfo
[uiLoopIndex
].ulSFID
);
891 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
," ucDirection %X \n",Adapter
->PackInfo
[uiLoopIndex
].ucDirection
);
892 if(Adapter
->PackInfo
[uiLoopIndex
].ucIpVersion
== IPV6
)
894 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"Ipv6 Service Flow \n");
898 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"Ipv4 Service Flow \n");
900 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
," SF Traffic Priority %X \n",Adapter
->PackInfo
[uiLoopIndex
].u8TrafficPriority
);
902 for(uiClsfrIndex
=0;uiClsfrIndex
<MAX_CLASSIFIERS
;uiClsfrIndex
++)
904 pstClassifierEntry
= &Adapter
->astClassifierTable
[uiClsfrIndex
];
905 if(!pstClassifierEntry
->bUsed
)
908 if(pstClassifierEntry
->ulSFID
!= Adapter
->PackInfo
[uiLoopIndex
].ulSFID
)
911 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
);
912 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
);
913 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
);
914 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
);
915 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
);
916 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
);
919 for(uiIndex
=0;uiIndex
<MAX_PORT_RANGE
;uiIndex
++)
921 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tusSrcPortRangeLo:%X\n",pstClassifierEntry
->usSrcPortRangeLo
[uiIndex
]);
922 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tusSrcPortRangeHi:%X\n",pstClassifierEntry
->usSrcPortRangeHi
[uiIndex
]);
923 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tusDestPortRangeLo:%X\n",pstClassifierEntry
->usDestPortRangeLo
[uiIndex
]);
924 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tusDestPortRangeHi:%X\n",pstClassifierEntry
->usDestPortRangeHi
[uiIndex
]);
927 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
," \tucIPSourceAddressLength : 0x%x\n",pstClassifierEntry
->ucIPSourceAddressLength
);
928 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tucIPDestinationAddressLength : 0x%x\n",pstClassifierEntry
->ucIPDestinationAddressLength
);
929 for(uiIndex
=0;uiIndex
<pstClassifierEntry
->ucIPSourceAddressLength
;uiIndex
++)
931 if(Adapter
->PackInfo
[uiLoopIndex
].ucIpVersion
== IPV6
)
933 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tIpv6 ulSrcIpAddr :\n");
934 DumpIpv6Address(pstClassifierEntry
->stSrcIpAddress
.ulIpv6Addr
);
935 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tIpv6 ulSrcIpMask :\n");
936 DumpIpv6Address(pstClassifierEntry
->stSrcIpAddress
.ulIpv6Mask
);
940 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tulSrcIpAddr:%lX\n",pstClassifierEntry
->stSrcIpAddress
.ulIpv4Addr
[uiIndex
]);
941 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tulSrcIpMask:%lX\n",pstClassifierEntry
->stSrcIpAddress
.ulIpv4Mask
[uiIndex
]);
944 for(uiIndex
=0;uiIndex
<pstClassifierEntry
->ucIPDestinationAddressLength
;uiIndex
++)
946 if(Adapter
->PackInfo
[uiLoopIndex
].ucIpVersion
== IPV6
)
948 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tIpv6 ulDestIpAddr :\n");
949 DumpIpv6Address(pstClassifierEntry
->stDestIpAddress
.ulIpv6Addr
);
950 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tIpv6 ulDestIpMask :\n");
951 DumpIpv6Address(pstClassifierEntry
->stDestIpAddress
.ulIpv6Mask
);
956 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tulDestIpAddr:%lX\n",pstClassifierEntry
->stDestIpAddress
.ulIpv4Addr
[uiIndex
]);
957 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tulDestIpMask:%lX\n",pstClassifierEntry
->stDestIpAddress
.ulIpv4Mask
[uiIndex
]);
960 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tucProtocol:0x%X\n",pstClassifierEntry
->ucProtocol
[0]);
961 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"\tu8ClassifierRulePriority:%X\n",pstClassifierEntry
->u8ClassifierRulePriority
);
965 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"ulSFID:%lX\n",Adapter
->PackInfo
[uiLoopIndex
].ulSFID
);
966 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"usVCID_Value:%X\n",Adapter
->PackInfo
[uiLoopIndex
].usVCID_Value
);
967 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"PhsEnabled: 0x%X\n",Adapter
->PackInfo
[uiLoopIndex
].bHeaderSuppressionEnabled
);
968 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"uiThreshold:%X\n",Adapter
->PackInfo
[uiLoopIndex
].uiThreshold
);
971 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"bValid:%X\n",Adapter
->PackInfo
[uiLoopIndex
].bValid
);
972 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"bActive:%X\n",Adapter
->PackInfo
[uiLoopIndex
].bActive
);
973 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"ActivateReqSent: %x", Adapter
->PackInfo
[uiLoopIndex
].bActivateRequestSent
);
974 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"u8QueueType:%X\n",Adapter
->PackInfo
[uiLoopIndex
].u8QueueType
);
975 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"uiMaxBucketSize:%X\n",Adapter
->PackInfo
[uiLoopIndex
].uiMaxBucketSize
);
976 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"uiPerSFTxResourceCount:%X\n",atomic_read(&Adapter
->PackInfo
[uiLoopIndex
].uiPerSFTxResourceCount
));
977 //DumpDebug(DUMP_INFO,(" bCSSupport:%X\n",Adapter->PackInfo[uiLoopIndex].bCSSupport));
978 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"CurrQueueDepthOnTarget: %x\n", Adapter
->PackInfo
[uiLoopIndex
].uiCurrentQueueDepthOnTarget
);
979 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"uiCurrentBytesOnHost:%X\n",Adapter
->PackInfo
[uiLoopIndex
].uiCurrentBytesOnHost
);
980 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"uiCurrentPacketsOnHost:%X\n",Adapter
->PackInfo
[uiLoopIndex
].uiCurrentPacketsOnHost
);
981 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"uiDroppedCountBytes:%X\n",Adapter
->PackInfo
[uiLoopIndex
].uiDroppedCountBytes
);
982 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"uiDroppedCountPackets:%X\n",Adapter
->PackInfo
[uiLoopIndex
].uiDroppedCountPackets
);
983 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"uiSentBytes:%X\n",Adapter
->PackInfo
[uiLoopIndex
].uiSentBytes
);
984 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"uiSentPackets:%X\n",Adapter
->PackInfo
[uiLoopIndex
].uiSentPackets
);
985 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"uiCurrentDrainRate:%X\n",Adapter
->PackInfo
[uiLoopIndex
].uiCurrentDrainRate
);
986 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"uiThisPeriodSentBytes:%X\n",Adapter
->PackInfo
[uiLoopIndex
].uiThisPeriodSentBytes
);
987 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"liDrainCalculated:%llX\n",Adapter
->PackInfo
[uiLoopIndex
].liDrainCalculated
);
988 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"uiCurrentTokenCount:%X\n",Adapter
->PackInfo
[uiLoopIndex
].uiCurrentTokenCount
);
989 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"liLastUpdateTokenAt:%llX\n",Adapter
->PackInfo
[uiLoopIndex
].liLastUpdateTokenAt
);
990 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"uiMaxAllowedRate:%X\n",Adapter
->PackInfo
[uiLoopIndex
].uiMaxAllowedRate
);
991 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"uiPendedLast:%X\n",Adapter
->PackInfo
[uiLoopIndex
].uiPendedLast
);
992 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"NumOfPacketsSent:%X\n",Adapter
->PackInfo
[uiLoopIndex
].NumOfPacketsSent
);
993 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
, "Direction: %x\n", Adapter
->PackInfo
[uiLoopIndex
].ucDirection
);
994 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
, "CID: %x\n", Adapter
->PackInfo
[uiLoopIndex
].usCID
);
995 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
, "ProtocolValid: %x\n", Adapter
->PackInfo
[uiLoopIndex
].bProtocolValid
);
996 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
, "TOSValid: %x\n", Adapter
->PackInfo
[uiLoopIndex
].bTOSValid
);
997 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
, "DestIpValid: %x\n", Adapter
->PackInfo
[uiLoopIndex
].bDestIpValid
);
998 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
, "SrcIpValid: %x\n", Adapter
->PackInfo
[uiLoopIndex
].bSrcIpValid
);
999 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
, "ActiveSet: %x\n", Adapter
->PackInfo
[uiLoopIndex
].bActiveSet
);
1000 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
, "AdmittedSet: %x\n", Adapter
->PackInfo
[uiLoopIndex
].bAdmittedSet
);
1001 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
, "AuthzSet: %x\n", Adapter
->PackInfo
[uiLoopIndex
].bAuthorizedSet
);
1002 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
, "ClassifyPrority: %x\n", Adapter
->PackInfo
[uiLoopIndex
].bClassifierPriority
);
1003 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
, "uiMaxLatency: %x\n",Adapter
->PackInfo
[uiLoopIndex
].uiMaxLatency
);
1004 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]);
1005 // BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "bHeaderSuppressionEnabled :%X\n", Adapter->PackInfo[uiLoopIndex].bHeaderSuppressionEnabled);
1006 // BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiTotalTxBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiTotalTxBytes);
1007 // BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiTotalRxBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiTotalRxBytes);
1008 // DumpDebug(DUMP_INFO,(" uiRanOutOfResCount:%X\n",Adapter->PackInfo[uiLoopIndex].uiRanOutOfResCount));
1011 for(uiLoopIndex
= 0 ; uiLoopIndex
< MIBS_MAX_HIST_ENTRIES
; uiLoopIndex
++)
1012 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"Adapter->aRxPktSizeHist[%x] = %x\n",uiLoopIndex
,Adapter
->aRxPktSizeHist
[uiLoopIndex
]);
1014 for(uiLoopIndex
= 0 ; uiLoopIndex
< MIBS_MAX_HIST_ENTRIES
; uiLoopIndex
++)
1015 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_OTHERS
, DUMP_INFO
, DBG_LVL_ALL
,"Adapter->aTxPktSizeHist[%x] = %x\n",uiLoopIndex
,Adapter
->aTxPktSizeHist
[uiLoopIndex
]);
1025 __inline
int reset_card_proc(PMINI_ADAPTER ps_adapter
)
1027 int retval
= STATUS_SUCCESS
;
1029 #ifndef BCM_SHM_INTERFACE
1031 PS_INTERFACE_ADAPTER psIntfAdapter
= NULL
;
1032 unsigned int value
= 0, uiResetValue
= 0;
1034 psIntfAdapter
= ((PS_INTERFACE_ADAPTER
)(ps_adapter
->pvInterfaceAdapter
)) ;
1036 ps_adapter
->bDDRInitDone
= FALSE
;
1038 if(ps_adapter
->chip_id
>= T3LPB
)
1040 //SYS_CFG register is write protected hence for modifying this reg value, it should be read twice before
1041 rdmalt(ps_adapter
,SYS_CFG
, &value
, sizeof(value
));
1042 rdmalt(ps_adapter
,SYS_CFG
, &value
, sizeof(value
));
1044 //making bit[6...5] same as was before f/w download. this setting force the h/w to
1045 //re-populated the SP RAM area with the string descriptor .
1046 value
= value
| (ps_adapter
->syscfgBefFwDld
& 0x00000060) ;
1047 wrmalt(ps_adapter
, SYS_CFG
, &value
, sizeof(value
));
1050 #ifndef BCM_SHM_INTERFACE
1051 //killing all submitted URBs.
1052 psIntfAdapter
->psAdapter
->StopAllXaction
= TRUE
;
1053 Bcm_kill_all_URBs(psIntfAdapter
);
1055 /* Reset the UMA-B Device */
1056 if(ps_adapter
->chip_id
>= T3LPB
)
1058 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_PRINTK
, 0, 0, "Reseting UMA-B \n");
1059 retval
= usb_reset_device(psIntfAdapter
->udev
);
1061 psIntfAdapter
->psAdapter
->StopAllXaction
= FALSE
;
1063 if(retval
!= STATUS_SUCCESS
)
1065 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_PRINTK
, 0, 0, "Reset failed with ret value :%d", retval
);
1068 if (ps_adapter
->chip_id
== BCS220_2
||
1069 ps_adapter
->chip_id
== BCS220_2BC
||
1070 ps_adapter
->chip_id
== BCS250_BC
||
1071 ps_adapter
->chip_id
== BCS220_3
)
1073 retval
= rdmalt(ps_adapter
,HPM_CONFIG_LDO145
, &value
, sizeof(value
));
1076 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_PRINTK
, 0, 0,"read failed with status :%d",retval
);
1081 retval
= wrmalt(ps_adapter
, HPM_CONFIG_LDO145
, &value
, sizeof(value
));
1084 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_PRINTK
, 0, 0,"write failed with status :%d",retval
);
1092 retval
= rdmalt(ps_adapter
,0x0f007018, &value
, sizeof(value
));
1094 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_PRINTK
, 0, 0,"read failed with status :%d",retval
);
1098 retval
= wrmalt(ps_adapter
, 0x0f007018, &value
, sizeof(value
)) ;
1100 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_PRINTK
, 0, 0,"write failed with status :%d",retval
);
1104 // Toggling the GPIO 8, 9
1106 retval
= wrmalt(ps_adapter
, GPIO_OUTPUT_REGISTER
, &value
, sizeof(value
));
1108 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_PRINTK
, 0, 0,"write failed with status :%d",retval
);
1112 retval
= wrmalt(ps_adapter
, GPIO_MODE_REGISTER
, &value
, sizeof(value
)) ;
1114 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_PRINTK
, 0, 0,"write failed with status :%d",retval
);
1120 //ps_adapter->downloadDDR = false;
1122 if(ps_adapter
->bFlashBoot
)
1124 //In flash boot mode MIPS state register has reverse polarity.
1125 // So just or with setting bit 30.
1126 //Make the MIPS in Reset state.
1127 rdmalt(ps_adapter
, CLOCK_RESET_CNTRL_REG_1
, &uiResetValue
, sizeof(uiResetValue
));
1129 uiResetValue
|=(1<<30);
1130 wrmalt(ps_adapter
, CLOCK_RESET_CNTRL_REG_1
, &uiResetValue
, sizeof(uiResetValue
));
1133 if(ps_adapter
->chip_id
>= T3LPB
)
1137 // WA for SYSConfig Issue.
1138 // Read SYSCFG Twice to make it writable.
1140 rdmalt(ps_adapter
, SYS_CFG
, &uiResetValue
, sizeof(uiResetValue
));
1141 if(uiResetValue
& (1<<4))
1144 rdmalt(ps_adapter
, SYS_CFG
, &uiResetValue
, sizeof(uiResetValue
));//2nd read to make it writable.
1145 uiResetValue
&= (~(1<<4));
1146 wrmalt(ps_adapter
,SYS_CFG
, &uiResetValue
, sizeof(uiResetValue
));
1151 wrmalt(ps_adapter
, 0x0f01186c, &uiResetValue
, sizeof(uiResetValue
));
1154 psIntfAdapter
->psAdapter
->StopAllXaction
= FALSE
;
1159 __inline
int run_card_proc(PMINI_ADAPTER ps_adapter
)
1161 unsigned int value
=0;
1164 if(rdmalt(ps_adapter
, CLOCK_RESET_CNTRL_REG_1
, &value
, sizeof(value
)) < 0) {
1165 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
,"%s:%d\n", __FUNCTION__
, __LINE__
);
1166 return STATUS_FAILURE
;
1169 if(ps_adapter
->bFlashBoot
)
1179 if(wrmalt(ps_adapter
, CLOCK_RESET_CNTRL_REG_1
, &value
, sizeof(value
)) < 0) {
1180 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
,"%s:%d\n", __FUNCTION__
, __LINE__
);
1181 return STATUS_FAILURE
;
1184 return STATUS_SUCCESS
;
1187 int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter
)
1190 UINT status
= STATUS_SUCCESS
;
1192 #ifdef BCM_SHM_INTERFACE
1193 unsigned char *pConfigFileAddr
= (unsigned char *)CPE_MACXVI_CFG_ADDR
;
1196 * Create the threads first and then download the
1197 * Firm/DDR Settings..
1200 if((status
= create_worker_threads(ps_adapter
))<0)
1202 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Cannot create thread");
1206 * For Downloading the Firm, parse the cfg file first.
1208 status
= bcm_parse_target_params (ps_adapter
);
1213 #ifndef BCM_SHM_INTERFACE
1214 if(ps_adapter
->chip_id
>= T3LPB
)
1216 rdmalt(ps_adapter
, SYS_CFG
, &value
, sizeof (value
));
1217 ps_adapter
->syscfgBefFwDld
= value
;
1218 if((value
& 0x60)== 0)
1220 ps_adapter
->bFlashBoot
= TRUE
;
1224 reset_card_proc(ps_adapter
);
1226 //Initializing the NVM.
1227 BcmInitNVM(ps_adapter
);
1228 status
= ddr_init(ps_adapter
);
1231 BCM_DEBUG_PRINT (ps_adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "ddr_init Failed\n");
1235 /* Download cfg file */
1236 status
= buffDnldVerify(ps_adapter
,
1237 (PUCHAR
)ps_adapter
->pstargetparams
,
1238 sizeof(STARGETPARAMS
),
1242 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Error downloading CFG file");
1245 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "CFG file downloaded");
1247 if(register_networkdev(ps_adapter
))
1249 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Register Netdevice failed. Cleanup needs to be performed.");
1253 if(FALSE
== ps_adapter
->AutoFirmDld
)
1255 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "AutoFirmDld Disabled in CFG File..\n");
1256 //If Auto f/w download is disable, register the control interface,
1257 //register the control interface after the mailbox.
1258 if(register_control_device_interface(ps_adapter
) < 0)
1260 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Register Control Device failed. Cleanup needs to be performed.");
1264 return STATUS_SUCCESS
;
1268 * Do the LED Settings here. It will be used by the Firmware Download
1273 * 1. If the LED Settings fails, do not stop and do the Firmware download.
1274 * 2. This init would happend only if the cfg file is present, else
1275 * call from the ioctl context.
1278 status
= InitLedSettings (ps_adapter
);
1282 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_PRINTK
, 0, 0,"INIT LED FAILED\n");
1285 if(ps_adapter
->LEDInfo
.led_thread_running
& BCM_LED_THREAD_RUNNING_ACTIVELY
)
1287 ps_adapter
->DriverState
= DRIVER_INIT
;
1288 wake_up(&ps_adapter
->LEDInfo
.notify_led_event
);
1291 if(ps_adapter
->LEDInfo
.led_thread_running
& BCM_LED_THREAD_RUNNING_ACTIVELY
)
1293 ps_adapter
->DriverState
= FW_DOWNLOAD
;
1294 wake_up(&ps_adapter
->LEDInfo
.notify_led_event
);
1298 wrmalt(ps_adapter
, EEPROM_CAL_DATA_INTERNAL_LOC
- 4, &value
, sizeof(value
));
1299 wrmalt(ps_adapter
, EEPROM_CAL_DATA_INTERNAL_LOC
- 8, &value
, sizeof(value
));
1301 if(ps_adapter
->eNVMType
== NVM_FLASH
)
1303 status
= PropagateCalParamsFromFlashToMemory(ps_adapter
);
1306 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
," Propogation of Cal param failed .." );
1311 else if(psAdapter
->eNVMType
== NVM_EEPROM
)
1313 PropagateCalParamsFromEEPROMToMemory();
1317 /* Download Firmare */
1318 if ((status
= BcmFileDownload( ps_adapter
, BIN_FILE
, FIRMWARE_BEGIN_ADDR
)))
1320 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "No Firmware File is present... \n");
1324 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "BIN file downloaded");
1325 status
= run_card_proc(ps_adapter
);
1328 BCM_DEBUG_PRINT (ps_adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "run_card_proc Failed\n");
1333 ps_adapter
->fw_download_done
= TRUE
;
1337 if(ps_adapter
->LEDInfo
.led_thread_running
& BCM_LED_THREAD_RUNNING_ACTIVELY
)
1339 ps_adapter
->DriverState
= FW_DOWNLOAD_DONE
;
1340 wake_up(&ps_adapter
->LEDInfo
.notify_led_event
);
1345 ps_adapter
->bDDRInitDone
= TRUE
;
1346 //Initializing the NVM.
1347 BcmInitNVM(ps_adapter
);
1349 //Propagating the cal param from Flash to DDR
1351 wrmalt(ps_adapter
, EEPROM_CAL_DATA_INTERNAL_LOC
- 4, &value
, sizeof(value
));
1352 wrmalt(ps_adapter
, EEPROM_CAL_DATA_INTERNAL_LOC
- 8, &value
, sizeof(value
));
1354 if(ps_adapter
->eNVMType
== NVM_FLASH
)
1356 status
= PropagateCalParamsFromFlashToMemory(ps_adapter
);
1359 printk("\nPropogation of Cal param from flash to DDR failed ..\n" );
1363 //Copy config file param to DDR.
1364 memcpy(pConfigFileAddr
,ps_adapter
->pstargetparams
, sizeof(STARGETPARAMS
));
1366 if(register_networkdev(ps_adapter
))
1368 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Register Netdevice failed. Cleanup needs to be performed.");
1373 status
= InitLedSettings (ps_adapter
);
1376 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_PRINTK
, 0, 0,"INIT LED FAILED\n");
1381 if(register_control_device_interface(ps_adapter
) < 0)
1383 BCM_DEBUG_PRINT(ps_adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Register Control Device failed. Cleanup needs to be performed.");
1387 ps_adapter
->fw_download_done
= TRUE
;
1394 * ACP : Appended Configuration Parameters
1395 * Capture them from the buffer and merge.
1397 int capture_and_merge_acp(PMINI_ADAPTER Adapter
, unsigned char *ptr
, int size
)
1399 fw_typeval_rec_t
*sp_fwrec
;
1400 int j
, k
, recsz
= sizeof (fw_typeval_rec_t
);
1402 B_UINT32 VID
=0, PID
=0;
1403 B_UINT32 DevVID
=0, DevPID
=0;
1405 ptr
+= CFGFIL_SZ_MIN
; // seek ahead 144 bytes
1407 rdmalt(Adapter
, 0x0f011810, &DevVID
, sizeof(B_UINT32
));
1408 rdmalt(Adapter
, 0x0f011814, &DevPID
, sizeof(B_UINT32
));
1409 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "DevVID 0x%08x : DevPID = 0x%08x", DevVID
, DevPID
);
1411 //--- Process each 'new ACP record' (of Type/Value pairs of (4+4=) 8 bytes each)...
1412 for (j
=0, k
=0; j
< ((size
-CFGFIL_SZ_MIN
)/recsz
); j
++, k
++) {
1413 // Map the read-in memory bytes to the structure
1414 sp_fwrec
= (fw_typeval_rec_t
*)ptr
+k
;
1415 type
= ntohl (sp_fwrec
->type
);
1416 val
= ntohl (sp_fwrec
->value
);
1418 /* The very first Type/Value pair MUST be VID_PID , meaning type MUST be zero. */
1419 if (unlikely(((0 == j
) && type
))) { // first pair
1420 printk (KERN_WARNING
"\n\n*** WARNING ***\n\
1421 INVALID TYPE [0x%x]. For First ACP, Type MUST be zero. Please Fix the config file %s first.\n\
1422 Only then can ACP entries be processed.\n", type
, CFG_FILE
);
1426 if (type
== BCM_ACP_TYPE_NEW
) {
1427 VID
= (val
& 0xffff0000) >> 16;
1428 PID
= val
& 0x0000ffff;
1429 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "NEW ACP Section [VID.PID = %04x.%04x] follows:",
1433 /* The whole idea is that the 'new' appended (ACP) data overwrites the
1434 * previous 'usual' 0-143 bytes data if it exists.
1435 * So, we know the Type n => the structure field n.
1436 * (See the HLD Design Doc).
1437 * Therefore, just overwrite location (ptr+(n*4)) in the buffer with the corr. value!
1438 * This will correspond to the structure member to be updated, as the user uses this
1439 * very same Type field to specify that (s)he wants this member updated.
1441 if ((VID
== DevVID
) && (PID
== DevPID
) && type
) {
1442 if (unlikely(type
> BCM_ACP_TYPE_MAX
)) {
1443 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "INVALID ACP TYPE [0x%x]!! Aborting this record...", type
);
1446 *(B_UINT32
*)((ptr
-CFGFIL_SZ_MIN
)+((type
- 1)*sizeof (B_UINT32
))) = ntohl (val
);
1450 #if (BCM_DBG_SHOW_CFG_MEMBUF == 1)
1451 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0, "\n");
1453 120 * print_hex_dump - print a text hex dump to syslog for a binary blob of data
1454 121 * @level: kernel log level (e.g. KERN_DEBUG)
1455 122 * @prefix_str: string to prefix each line with;
1456 123 * caller supplies trailing spaces for alignment if desired
1457 124 * @prefix_type: controls whether prefix of an offset, address, or none
1458 125 * is printed (%DUMP_PREFIX_OFFSET, %DUMP_PREFIX_ADDRESS, %DUMP_PREFIX_NONE)
1459 126 * @rowsize: number of bytes to print per line; must be 16 or 32
1460 127 * @groupsize: number of bytes to print at a time (1, 2, 4, 8; default = 1)
1461 128 * @buf: data blob to dump
1462 129 * @len: number of bytes in the @buf
1463 130 * @ascii: include ASCII after the hex output
1465 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0, "\nMemory Dump of Config Data:\n\
1466 <offset> 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F\n\n");
1467 print_hex_dump (KERN_ALERT
, "", DUMP_PREFIX_ADDRESS
, 16, 1, ptr
-CFGFIL_SZ_MIN
, size
, 0);
1473 int bcm_parse_target_params(PMINI_ADAPTER Adapter
)
1475 #ifdef BCM_SHM_INTERFACE
1476 extern void read_cfg_file(PMINI_ADAPTER Adapter
);
1478 struct file
*flp
=NULL
;
1479 mm_segment_t oldfs
={0};
1480 unsigned char *buff
= NULL
;
1485 if((Adapter
->pstargetparams
=
1486 kmalloc(sizeof(STARGETPARAMS
), GFP_KERNEL
)) == NULL
) {
1489 flp
=open_firmware_file(Adapter
, CFG_FILE
);
1491 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "NOT ABLE TO OPEN THE %s FILE \n", CFG_FILE
);
1492 bcm_kfree(Adapter
->pstargetparams
);
1495 oldfs
=get_fs(); set_fs(get_ds());
1497 cfgfil_sz
= flp
->f_dentry
->d_inode
->i_size
;
1498 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Config file %s size = %ld bytes", CFG_FILE
,(long int)cfgfil_sz
);
1500 if( (cfgfil_sz
< CFGFIL_SZ_MIN
) || (cfgfil_sz
> CFGFIL_SZ_MAX
)){
1501 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Firmware Config file %s size invalid (too small/large)!\n", CFG_FILE
);
1502 bcm_kfree(Adapter
->pstargetparams
);
1503 filp_close(flp
, current
->files
);
1505 return -EINVAL
; // ?
1508 buff
=(PCHAR
)kmalloc (cfgfil_sz
, GFP_KERNEL
);
1510 bcm_kfree(Adapter
->pstargetparams
);
1511 filp_close(flp
, current
->files
);
1517 len
=vfs_read(flp
, buff
, cfgfil_sz
, &pos
);
1518 if ((len
< CFGFIL_SZ_MIN
) ||(cfgfil_sz
> CFGFIL_SZ_MAX
)){
1519 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
,"Mismatch in Target Param Structure!\n");
1521 bcm_kfree(Adapter
->pstargetparams
);
1522 filp_close(flp
, current
->files
);
1526 filp_close(flp
, current
->files
);
1530 * Now 'buff' contains the "usual" first 144 bytes of binary configuration data;
1531 * and if cfgfil_sz > 144 , then it also now contains the new "flexi-config"
1532 * appended data (ACP - Appended Configuration Parameters).
1534 if (cfgfil_sz
> CFGFIL_SZ_MIN
) {
1535 BCM_DEBUG_PRINT (Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "## Flexi-Config ACP (Additional Configuration Parameters) detected ##");
1536 if (capture_and_merge_acp (Adapter
, buff
, cfgfil_sz
)) {
1537 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "***WARNING *** Function %s failed. ACP processing aborted...\n",
1538 "capture_and_merge_acp");
1542 /* Check for autolink in config params */
1544 * Values in Adapter->pstargetparams are in network byte order
1546 memcpy(Adapter
->pstargetparams
, buff
, sizeof(STARGETPARAMS
));
1548 beceem_parse_target_struct(Adapter
);
1549 #ifdef BCM_SHM_INTERFACE
1550 read_cfg_file(Adapter
);
1553 return STATUS_SUCCESS
;
1556 void beceem_parse_target_struct(PMINI_ADAPTER Adapter
)
1558 UINT uiHostDrvrCfg6
=0, uiEEPROMFlag
= 0;
1559 UINT uiHarqEnable
= 0;
1561 if(ntohl(Adapter
->pstargetparams
->m_u32PhyParameter2
) & AUTO_SYNC_DISABLE
)
1563 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "AutoSyncup is Disabled\n");
1564 Adapter
->AutoSyncup
= FALSE
;
1568 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "AutoSyncup is Enabled\n");
1569 Adapter
->AutoSyncup
= TRUE
;
1571 if(ntohl(Adapter
->pstargetparams
->HostDrvrConfig6
) & AUTO_LINKUP_ENABLE
)
1573 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Enabling autolink up");
1574 Adapter
->AutoLinkUp
= TRUE
;
1578 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Disabling autolink up");
1579 Adapter
->AutoLinkUp
= FALSE
;
1581 // Setting the DDR Setting..
1582 Adapter
->DDRSetting
=
1583 (ntohl(Adapter
->pstargetparams
->HostDrvrConfig6
) >>8)&0x0F;
1584 Adapter
->ulPowerSaveMode
=
1585 (ntohl(Adapter
->pstargetparams
->HostDrvrConfig6
)>>12)&0x0F;
1587 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "DDR Setting: %x\n", Adapter
->DDRSetting
);
1588 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
,DBG_LVL_ALL
, "Power Save Mode: %lx\n",
1589 Adapter
->ulPowerSaveMode
);
1591 uiHostDrvrCfg6
= ntohl(Adapter
->pstargetparams
->HostDrvrConfig6
);
1593 if(uiHostDrvrCfg6
& AUTO_FIRM_DOWNLOAD
)
1595 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Enabling Auto Firmware Download\n");
1596 Adapter
->AutoFirmDld
= TRUE
;
1600 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Disabling Auto Firmware Download\n");
1601 Adapter
->AutoFirmDld
= FALSE
;
1604 uiHarqEnable
= ntohl(Adapter
->pstargetparams
->m_u32HarqEnable
);
1605 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
,"HarqCat5Enable : 0x%X\n", uiHarqEnable
);
1606 Adapter
->bHarqCat5Enable
= ( uiHarqEnable
>> 16 ) & 0xFF;
1607 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
,"HarqCat5Enable : 0x%X\n",Adapter
->bHarqCat5Enable
);
1610 Adapter
->bMipsConfig
= (uiHostDrvrCfg6
>>20)&0x01;
1611 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
,"MIPSConfig : 0x%X\n",Adapter
->bMipsConfig
);
1612 //used for backward compatibility.
1613 Adapter
->bDPLLConfig
= (uiHostDrvrCfg6
>>19)&0x01;
1615 Adapter
->PmuMode
= (uiHostDrvrCfg6
>> 24 ) & 0x03;
1616 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "PMU MODE: %x", Adapter
->PmuMode
);
1618 if((uiHostDrvrCfg6
>> HOST_BUS_SUSPEND_BIT
) & (0x01))
1620 Adapter
->bDoSuspend
= TRUE
;
1621 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "Making DoSuspend TRUE as per configFile");
1624 uiEEPROMFlag
= ntohl(Adapter
->pstargetparams
->m_u32EEPROMFlag
);
1625 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
, "uiEEPROMFlag : 0x%X\n",uiEEPROMFlag
);
1626 Adapter
->eNVMType
= (NVM_TYPE
)((uiEEPROMFlag
>>4)&0x3);
1629 Adapter
->bStatusWrite
= (uiEEPROMFlag
>>6)&0x1;
1630 //printk(("bStatusWrite : 0x%X\n", Adapter->bStatusWrite));
1632 Adapter
->uiSectorSizeInCFG
= 1024*(0xFFFF & ntohl(Adapter
->pstargetparams
->HostDrvrConfig4
));
1633 //printk(("uiSectorSize : 0x%X\n", Adapter->uiSectorSizeInCFG));
1635 Adapter
->bSectorSizeOverride
=(bool) ((ntohl(Adapter
->pstargetparams
->HostDrvrConfig4
))>>16)&0x1;
1636 //printk(MP_INIT,("bSectorSizeOverride : 0x%X\n",Adapter->bSectorSizeOverride));
1638 if(ntohl(Adapter
->pstargetparams
->m_u32PowerSavingModeOptions
) &0x01)
1639 Adapter
->ulPowerSaveMode
= DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE
;
1640 //autocorrection part
1641 if(Adapter
->ulPowerSaveMode
!= DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE
)
1642 doPowerAutoCorrection(Adapter
);
1644 Adapter
->ucDsxLinkUpCfg
= ((uiHostDrvrCfg6
>>21)&0x03)?((uiHostDrvrCfg6
>>21)&0x03): CONNECT_ON_DL_UL
;
1645 BCM_DEBUG_PRINT (Adapter
, DBG_TYPE_PRINTK
, 0, 0, "LinkUp Config : 0x%X\n",Adapter
->ucDsxLinkUpCfg
);
1649 VOID
doPowerAutoCorrection(PMINI_ADAPTER psAdapter
)
1651 UINT reporting_mode
= 0;
1653 reporting_mode
= ntohl(psAdapter
->pstargetparams
->m_u32PowerSavingModeOptions
) &0x02 ;
1654 psAdapter
->bIsAutoCorrectEnabled
= !((char)(psAdapter
->ulPowerSaveMode
>> 3) & 0x1);
1656 if(reporting_mode
== TRUE
)
1658 BCM_DEBUG_PRINT(psAdapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
,"can't do suspen/resume as reporting mode is enable");
1659 psAdapter
->bDoSuspend
= FALSE
;
1662 if (psAdapter
->bIsAutoCorrectEnabled
&& (psAdapter
->chip_id
>= T3LPB
))
1664 //If reporting mode is enable, switch PMU to PMC
1666 if(reporting_mode
== FALSE
)
1668 psAdapter
->ulPowerSaveMode
= DEVICE_POWERSAVE_MODE_AS_PMU_SHUTDOWN
;
1669 psAdapter
->bDoSuspend
= TRUE
;
1670 BCM_DEBUG_PRINT(psAdapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
,"PMU selected ....");
1676 psAdapter
->ulPowerSaveMode
= DEVICE_POWERSAVE_MODE_AS_PMU_CLOCK_GATING
;
1677 psAdapter
->bDoSuspend
=FALSE
;
1678 BCM_DEBUG_PRINT(psAdapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
,"PMC selected..");
1682 //clearing space bit[15..12]
1683 psAdapter
->pstargetparams
->HostDrvrConfig6
&= ~(htonl((0xF << 12)));
1684 //placing the power save mode option
1685 psAdapter
->pstargetparams
->HostDrvrConfig6
|= htonl((psAdapter
->ulPowerSaveMode
<< 12));
1688 else if (psAdapter
->bIsAutoCorrectEnabled
== FALSE
)
1691 // remove the autocorrect disable bit set before dumping.
1692 psAdapter
->ulPowerSaveMode
&= ~(1 << 3);
1693 psAdapter
->pstargetparams
->HostDrvrConfig6
&= ~(htonl(1 << 15));
1694 BCM_DEBUG_PRINT(psAdapter
,DBG_TYPE_INITEXIT
, MP_INIT
, DBG_LVL_ALL
,"Using Forced User Choice: %lx\n", psAdapter
->ulPowerSaveMode
);
1698 unsigned char *ReadMacAddrEEPROM(PMINI_ADAPTER Adapter
, ulong dwAddress
)
1700 unsigned char *pucmacaddr
= NULL
;
1701 int status
= 0, i
=0;
1702 unsigned int temp
=0;
1705 pucmacaddr
= (unsigned char *)kmalloc(MAC_ADDRESS_SIZE
, GFP_KERNEL
);
1708 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0, "No Buffers to Read the EEPROM Address\n");
1712 dwAddress
|= 0x5b000000;
1713 status
= wrmalt(Adapter
, EEPROM_COMMAND_Q_REG
,
1714 (PUINT
)&dwAddress
, sizeof(UINT
));
1715 if(status
!= STATUS_SUCCESS
)
1717 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0, "wrm Failed..\n");
1718 bcm_kfree(pucmacaddr
);
1722 for(i
=0;i
<MAC_ADDRESS_SIZE
;i
++)
1724 status
= rdmalt(Adapter
, EEPROM_READ_DATA_Q_REG
, &temp
,sizeof(temp
));
1725 if(status
!= STATUS_SUCCESS
)
1727 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0, "rdm Failed..\n");
1728 bcm_kfree(pucmacaddr
);
1732 pucmacaddr
[i
] = temp
& 0xff;
1733 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_INITEXIT
, DRV_ENTRY
, DBG_LVL_ALL
,"%x \n", pucmacaddr
[i
]);
1740 INT
ReadMacAddressFromEEPROM(PMINI_ADAPTER Adapter
)
1742 unsigned char *puMacAddr
= NULL
;
1745 puMacAddr
= ReadMacAddrEEPROM(Adapter
,0x200);
1748 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, NEXT_SEND
, DBG_LVL_ALL
, "Couldn't retrieve the Mac Address\n");
1749 return STATUS_FAILURE
;
1753 if((puMacAddr
[0] == 0x0 && puMacAddr
[1] == 0x0 &&
1754 puMacAddr
[2] == 0x0 && puMacAddr
[3] == 0x0 &&
1755 puMacAddr
[4] == 0x0 && puMacAddr
[5] == 0x0) ||
1756 (puMacAddr
[0] == 0xFF && puMacAddr
[1] == 0xFF &&
1757 puMacAddr
[2] == 0xFF && puMacAddr
[3] == 0xFF &&
1758 puMacAddr
[4] == 0xFF && puMacAddr
[5] == 0xFF))
1760 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, NEXT_SEND
, DBG_LVL_ALL
, "Invalid Mac Address\n");
1761 bcm_kfree(puMacAddr
);
1762 return STATUS_FAILURE
;
1764 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, NEXT_SEND
, DBG_LVL_ALL
, "The Mac Address received is: \n");
1765 memcpy(Adapter
->dev
->dev_addr
, puMacAddr
, MAC_ADDRESS_SIZE
);
1766 for(i
=0;i
<MAC_ADDRESS_SIZE
;i
++)
1768 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"%02x ", Adapter
->dev
->dev_addr
[i
]);
1770 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"\n");
1771 bcm_kfree(puMacAddr
);
1773 return STATUS_SUCCESS
;
1777 void convertEndian(B_UINT8 rwFlag
, PUINT puiBuffer
, UINT uiByteCount
)
1781 if(RWM_WRITE
== rwFlag
) {
1782 for(uiIndex
=0; uiIndex
< (uiByteCount
/sizeof(UINT
)); uiIndex
++) {
1783 puiBuffer
[uiIndex
] = htonl(puiBuffer
[uiIndex
]);
1786 for(uiIndex
=0; uiIndex
< (uiByteCount
/sizeof(UINT
)); uiIndex
++) {
1787 puiBuffer
[uiIndex
] = ntohl(puiBuffer
[uiIndex
]);
1792 #define CACHE_ADDRESS_MASK 0x80000000
1793 #define UNCACHE_ADDRESS_MASK 0xa0000000
1795 int rdm(PMINI_ADAPTER Adapter
, UINT uiAddress
, PCHAR pucBuff
, size_t sSize
)
1799 #ifndef BCM_SHM_INTERFACE
1800 uiRetVal
= Adapter
->interface_rdm(Adapter
->pvInterfaceAdapter
,
1801 uiAddress
, pucBuff
, sSize
);
1808 uiRetVal
= STATUS_SUCCESS
;
1809 if(uiAddress
& 0x10000000) {
1810 // DDR Memory Access
1811 uiAddress
|= CACHE_ADDRESS_MASK
;
1812 memcpy(pucBuff
,(unsigned char *)uiAddress
,sSize
);
1815 // Register, SPRAM, Flash
1816 uiAddress
|= UNCACHE_ADDRESS_MASK
;
1817 if ((uiAddress
& FLASH_ADDR_MASK
) == (FLASH_CONTIGIOUS_START_ADDR_BCS350
& FLASH_ADDR_MASK
))
1819 #if defined(FLASH_DIRECT_ACCESS)
1820 memcpy(pucBuff
,(unsigned char *)uiAddress
,sSize
);
1822 printk("\nInvalid GSPI ACCESS :Addr :%#X", uiAddress
);
1823 uiRetVal
= STATUS_FAILURE
;
1826 else if(((unsigned int )uiAddress
& 0x3) ||
1827 ((unsigned int )pucBuff
& 0x3) ||
1828 ((unsigned int )sSize
& 0x3)) {
1829 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
);
1830 uiRetVal
= STATUS_FAILURE
;
1833 for (indx
=0;indx
<sSize
;indx
+=4){
1834 *(PUINT
)(pucBuff
+ indx
) = *(PUINT
)(uiAddress
+ indx
);
1841 int wrm(PMINI_ADAPTER Adapter
, UINT uiAddress
, PCHAR pucBuff
, size_t sSize
)
1845 #ifndef BCM_SHM_INTERFACE
1846 iRetVal
= Adapter
->interface_wrm(Adapter
->pvInterfaceAdapter
,
1847 uiAddress
, pucBuff
, sSize
);
1851 if(uiAddress
& 0x10000000) {
1852 // DDR Memory Access
1853 uiAddress
|= CACHE_ADDRESS_MASK
;
1854 memcpy((unsigned char *)(uiAddress
),pucBuff
,sSize
);
1857 // Register, SPRAM, Flash
1858 uiAddress
|= UNCACHE_ADDRESS_MASK
;
1860 if(((unsigned int )uiAddress
& 0x3) ||
1861 ((unsigned int )pucBuff
& 0x3) ||
1862 ((unsigned int )sSize
& 0x3)) {
1863 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
);
1864 iRetVal
= STATUS_FAILURE
;
1867 for (indx
=0;indx
<sSize
;indx
+=4) {
1868 *(PUINT
)(uiAddress
+ indx
) = *(PUINT
)(pucBuff
+ indx
);
1872 iRetVal
= STATUS_SUCCESS
;
1878 int wrmalt (PMINI_ADAPTER Adapter
, UINT uiAddress
, PUINT pucBuff
, size_t size
)
1880 convertEndian(RWM_WRITE
, pucBuff
, size
);
1881 return wrm(Adapter
, uiAddress
, (PUCHAR
)pucBuff
, size
);
1884 int rdmalt (PMINI_ADAPTER Adapter
, UINT uiAddress
, PUINT pucBuff
, size_t size
)
1888 uiRetVal
= rdm(Adapter
,uiAddress
,(PUCHAR
)pucBuff
,size
);
1889 convertEndian(RWM_READ
, (PUINT
)pucBuff
, size
);
1894 int rdmWithLock(PMINI_ADAPTER Adapter
, UINT uiAddress
, PCHAR pucBuff
, size_t sSize
)
1897 INT status
= STATUS_SUCCESS
;
1898 down(&Adapter
->rdmwrmsync
);
1900 if((Adapter
->IdleMode
== TRUE
) ||
1901 (Adapter
->bShutStatus
==TRUE
) ||
1902 (Adapter
->bPreparingForLowPowerMode
==TRUE
))
1908 status
= rdm(Adapter
, uiAddress
, pucBuff
, sSize
);
1911 up(&Adapter
->rdmwrmsync
);
1914 int wrmWithLock(PMINI_ADAPTER Adapter
, UINT uiAddress
, PCHAR pucBuff
, size_t sSize
)
1916 INT status
= STATUS_SUCCESS
;
1917 down(&Adapter
->rdmwrmsync
);
1919 if((Adapter
->IdleMode
== TRUE
) ||
1920 (Adapter
->bShutStatus
==TRUE
) ||
1921 (Adapter
->bPreparingForLowPowerMode
==TRUE
))
1927 status
=wrm(Adapter
, uiAddress
, pucBuff
, sSize
);
1930 up(&Adapter
->rdmwrmsync
);
1934 int wrmaltWithLock (PMINI_ADAPTER Adapter
, UINT uiAddress
, PUINT pucBuff
, size_t size
)
1936 int iRetVal
= STATUS_SUCCESS
;
1938 down(&Adapter
->rdmwrmsync
);
1940 if((Adapter
->IdleMode
== TRUE
) ||
1941 (Adapter
->bShutStatus
==TRUE
) ||
1942 (Adapter
->bPreparingForLowPowerMode
==TRUE
))
1948 iRetVal
= wrmalt(Adapter
,uiAddress
,pucBuff
,size
);
1951 up(&Adapter
->rdmwrmsync
);
1955 int rdmaltWithLock (PMINI_ADAPTER Adapter
, UINT uiAddress
, PUINT pucBuff
, size_t size
)
1957 INT uiRetVal
=STATUS_SUCCESS
;
1959 down(&Adapter
->rdmwrmsync
);
1961 if((Adapter
->IdleMode
== TRUE
) ||
1962 (Adapter
->bShutStatus
==TRUE
) ||
1963 (Adapter
->bPreparingForLowPowerMode
==TRUE
))
1969 uiRetVal
= rdmalt(Adapter
,uiAddress
, pucBuff
, size
);
1972 up(&Adapter
->rdmwrmsync
);
1977 VOID
HandleShutDownModeWakeup(PMINI_ADAPTER Adapter
)
1979 int clear_abort_pattern
= 0,Status
= 0;
1980 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, MP_SHUTDOWN
, DBG_LVL_ALL
, "====>\n");
1981 //target has woken up From Shut Down
1982 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, MP_SHUTDOWN
, DBG_LVL_ALL
, "Clearing Shut Down Software abort pattern\n");
1983 Status
= wrmalt(Adapter
,SW_ABORT_IDLEMODE_LOC
, (PUINT
)&clear_abort_pattern
, sizeof(clear_abort_pattern
));
1986 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, MP_SHUTDOWN
, DBG_LVL_ALL
,"WRM to SW_ABORT_IDLEMODE_LOC failed with err:%d", Status
);
1989 if(Adapter
->ulPowerSaveMode
!= DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE
)
1992 InterfaceHandleShutdownModeWakeup(Adapter
);
1995 if(Adapter
->LEDInfo
.led_thread_running
& BCM_LED_THREAD_RUNNING_ACTIVELY
)
1997 Adapter
->DriverState
= NO_NETWORK_ENTRY
;
1998 wake_up(&Adapter
->LEDInfo
.notify_led_event
);
2001 Adapter
->bTriedToWakeUpFromlowPowerMode
= FALSE
;
2002 Adapter
->bShutStatus
= FALSE
;
2003 wake_up(&Adapter
->lowpower_mode_wait_queue
);
2004 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, MP_SHUTDOWN
, DBG_LVL_ALL
, "<====\n");
2007 VOID
SendShutModeResponse(PMINI_ADAPTER Adapter
)
2009 CONTROL_MESSAGE stShutdownResponse
;
2010 UINT NVMAccess
= 0,lowPwrAbortMsg
= 0;
2013 memset (&stShutdownResponse
, 0, sizeof(CONTROL_MESSAGE
));
2014 stShutdownResponse
.Leader
.Status
= LINK_UP_CONTROL_REQ
;
2015 stShutdownResponse
.Leader
.PLength
= 8;//8 bytes;
2016 stShutdownResponse
.szData
[0] = LINK_UP_ACK
;
2017 stShutdownResponse
.szData
[1] = LINK_SHUTDOWN_REQ_FROM_FIRMWARE
;
2019 /*********************************
2021 ** if [ semaphore is available ]
2022 ** acquire semaphone and return value 0 ;
2024 ** return non-zero value ;
2026 ***********************************/
2029 if(Adapter
->link_shutdown_req_type
== SHUTDOWN_REQ_FRM_FW_HIBERNATION_BUTTON_PRESS
)
2031 down(&Adapter
->NVMRdmWrmLock
);
2032 down(&Adapter
->LowPowerModeSync
);
2039 NVMAccess
= down_trylock(&Adapter
->NVMRdmWrmLock
);
2040 lowPwrAbortMsg
= down_trylock(&Adapter
->LowPowerModeSync
);
2044 (NVMAccess
|| lowPwrAbortMsg
|| atomic_read(&Adapter
->TotalPacketCount
))
2046 (Adapter
->link_shutdown_req_type
!= SHUTDOWN_REQ_FRM_FW_HIBERNATION_BUTTON_PRESS
)
2050 up(&Adapter
->NVMRdmWrmLock
);
2053 up(&Adapter
->LowPowerModeSync
);
2055 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, MP_SHUTDOWN
, DBG_LVL_ALL
, "Device Access is going on NACK the Shut Down MODE\n");
2056 stShutdownResponse
.szData
[2] = SHUTDOWN_NACK_FROM_DRIVER
;//NACK- device access is going on.
2057 Adapter
->bPreparingForLowPowerMode
= FALSE
;
2061 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, MP_SHUTDOWN
, DBG_LVL_ALL
, "Sending SHUTDOWN MODE ACK\n");
2062 stShutdownResponse
.szData
[2] = SHUTDOWN_ACK_FROM_DRIVER
;//ShutDown ACK
2064 /* Wait for the LED to TURN OFF before sending ACK response */
2065 if(Adapter
->LEDInfo
.led_thread_running
& BCM_LED_THREAD_RUNNING_ACTIVELY
)
2069 /* Wake the LED Thread with LOWPOWER_MODE_ENTER State */
2070 Adapter
->DriverState
= LOWPOWER_MODE_ENTER
;
2071 wake_up(&Adapter
->LEDInfo
.notify_led_event
);
2073 /* Wait for 1 SEC for LED to OFF */
2074 iRetVal
= wait_event_timeout(Adapter
->LEDInfo
.idleModeSyncEvent
,\
2075 Adapter
->LEDInfo
.bIdle_led_off
, msecs_to_jiffies(1000));
2077 /* If Timed Out to Sync IDLE MODE Enter, do IDLE mode Exit and Send NACK to device */
2080 stShutdownResponse
.szData
[1] = SHUTDOWN_NACK_FROM_DRIVER
;//NACK- device access is going on.
2082 Adapter
->DriverState
= NO_NETWORK_ENTRY
;
2083 wake_up(&Adapter
->LEDInfo
.notify_led_event
);
2087 if(stShutdownResponse
.szData
[2] == SHUTDOWN_ACK_FROM_DRIVER
)
2089 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, MP_SHUTDOWN
, DBG_LVL_ALL
,"ACKING SHUTDOWN MODE !!!!!!!!!");
2090 down(&Adapter
->rdmwrmsync
);
2091 Adapter
->bPreparingForLowPowerMode
= TRUE
;
2092 up(&Adapter
->rdmwrmsync
);
2094 #ifndef BCM_SHM_INTERFACE
2095 if(Adapter
->bDoSuspend
== TRUE
)
2096 Bcm_kill_all_URBs((PS_INTERFACE_ADAPTER
)(Adapter
->pvInterfaceAdapter
));
2101 Adapter
->bPreparingForLowPowerMode
= FALSE
;
2105 up(&Adapter
->NVMRdmWrmLock
);
2108 up(&Adapter
->LowPowerModeSync
);
2110 Status
= CopyBufferToControlPacket(Adapter
,&stShutdownResponse
);
2111 if((Status
!= STATUS_SUCCESS
))
2113 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, MP_SHUTDOWN
, DBG_LVL_ALL
,"fail to send the Idle mode Request \n");
2114 Adapter
->bPreparingForLowPowerMode
= FALSE
;
2116 #ifndef BCM_SHM_INTERFACE
2117 StartInterruptUrb((PS_INTERFACE_ADAPTER
)(Adapter
->pvInterfaceAdapter
));
2123 void HandleShutDownModeRequest(PMINI_ADAPTER Adapter
,PUCHAR pucBuffer
)
2125 B_UINT32 uiResetValue
= 0;
2127 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, MP_SHUTDOWN
, DBG_LVL_ALL
, "====>\n");
2129 if(*(pucBuffer
+1) == COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW
)
2131 HandleShutDownModeWakeup(Adapter
);
2135 *(pucBuffer
+1) == LINK_SHUTDOWN_REQ_FROM_FIRMWARE
2137 *(pucBuffer
+1) == SHUTDOWN_REQ_FRM_FW_STANDBY_TIMER
2139 *(pucBuffer
+1) == SHUTDOWN_REQ_FRM_FW_HIBERNATION_BUTTON_PRESS
2142 Adapter
->link_shutdown_req_type
= *(pucBuffer
+1);
2144 //Target wants to go to Shut Down Mode
2145 //InterfacePrepareForShutdown(Adapter);
2146 if(Adapter
->chip_id
== BCS220_2
||
2147 Adapter
->chip_id
== BCS220_2BC
||
2148 Adapter
->chip_id
== BCS250_BC
||
2149 Adapter
->chip_id
== BCS220_3
)
2151 rdmalt(Adapter
,HPM_CONFIG_MSW
, &uiResetValue
, 4);
2152 uiResetValue
|= (1<<17);
2153 wrmalt(Adapter
, HPM_CONFIG_MSW
, &uiResetValue
, 4);
2156 SendShutModeResponse(Adapter
);
2157 BCM_DEBUG_PRINT (Adapter
,DBG_TYPE_OTHERS
, MP_SHUTDOWN
, DBG_LVL_ALL
,"ShutDownModeResponse:Notification received: Sending the response(Ack/Nack)\n");
2160 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, MP_SHUTDOWN
, DBG_LVL_ALL
, "<====\n");
2165 VOID
ResetCounters(PMINI_ADAPTER Adapter
)
2168 beceem_protocol_reset(Adapter
);
2170 Adapter
->CurrNumRecvDescs
= 0;
2171 Adapter
->PrevNumRecvDescs
= 0;
2172 Adapter
->LinkUpStatus
= 0;
2173 Adapter
->LinkStatus
= 0;
2174 atomic_set(&Adapter
->cntrlpktCnt
,0);
2175 atomic_set (&Adapter
->TotalPacketCount
,0);
2176 Adapter
->fw_download_done
=FALSE
;
2177 Adapter
->LinkStatus
= 0;
2178 Adapter
->AutoLinkUp
= FALSE
;
2179 Adapter
->IdleMode
= FALSE
;
2180 Adapter
->bShutStatus
= FALSE
;
2183 S_CLASSIFIER_RULE
*GetFragIPClsEntry(PMINI_ADAPTER Adapter
,USHORT usIpIdentification
,ULONG SrcIP
)
2186 for(uiIndex
=0;uiIndex
<MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES
;uiIndex
++)
2188 if((Adapter
->astFragmentedPktClassifierTable
[uiIndex
].bUsed
)&&
2189 (Adapter
->astFragmentedPktClassifierTable
[uiIndex
].usIpIdentification
== usIpIdentification
)&&
2190 (Adapter
->astFragmentedPktClassifierTable
[uiIndex
].ulSrcIpAddress
== SrcIP
)&&
2191 !Adapter
->astFragmentedPktClassifierTable
[uiIndex
].bOutOfOrderFragment
)
2192 return Adapter
->astFragmentedPktClassifierTable
[uiIndex
].pstMatchedClassifierEntry
;
2197 void AddFragIPClsEntry(PMINI_ADAPTER Adapter
,PS_FRAGMENTED_PACKET_INFO psFragPktInfo
)
2200 for(uiIndex
=0;uiIndex
<MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES
;uiIndex
++)
2202 if(!Adapter
->astFragmentedPktClassifierTable
[uiIndex
].bUsed
)
2204 memcpy(&Adapter
->astFragmentedPktClassifierTable
[uiIndex
],psFragPktInfo
,sizeof(S_FRAGMENTED_PACKET_INFO
));
2211 void DelFragIPClsEntry(PMINI_ADAPTER Adapter
,USHORT usIpIdentification
,ULONG SrcIp
)
2214 for(uiIndex
=0;uiIndex
<MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES
;uiIndex
++)
2216 if((Adapter
->astFragmentedPktClassifierTable
[uiIndex
].bUsed
)&&
2217 (Adapter
->astFragmentedPktClassifierTable
[uiIndex
].usIpIdentification
== usIpIdentification
)&&
2218 (Adapter
->astFragmentedPktClassifierTable
[uiIndex
].ulSrcIpAddress
== SrcIp
))
2219 memset(&Adapter
->astFragmentedPktClassifierTable
[uiIndex
],0,sizeof(S_FRAGMENTED_PACKET_INFO
));
2223 void update_per_cid_rx (PMINI_ADAPTER Adapter
)
2227 if((jiffies
- Adapter
->liDrainCalculated
) < XSECONDS
)
2230 for(qindex
= 0; qindex
< HiPriority
; qindex
++)
2232 if(Adapter
->PackInfo
[qindex
].ucDirection
== 0)
2234 Adapter
->PackInfo
[qindex
].uiCurrentRxRate
=
2235 (Adapter
->PackInfo
[qindex
].uiCurrentRxRate
+
2236 Adapter
->PackInfo
[qindex
].uiThisPeriodRxBytes
)/2;
2238 Adapter
->PackInfo
[qindex
].uiThisPeriodRxBytes
= 0;
2242 Adapter
->PackInfo
[qindex
].uiCurrentDrainRate
=
2243 (Adapter
->PackInfo
[qindex
].uiCurrentDrainRate
+
2244 Adapter
->PackInfo
[qindex
].uiThisPeriodSentBytes
)/2;
2246 Adapter
->PackInfo
[qindex
].uiThisPeriodSentBytes
=0;
2249 Adapter
->liDrainCalculated
=jiffies
;
2251 void update_per_sf_desc_cnts( PMINI_ADAPTER Adapter
)
2254 u32 uibuff
[MAX_TARGET_DSX_BUFFERS
];
2256 if(!atomic_read (&Adapter
->uiMBupdate
))
2259 #ifdef BCM_SHM_INTERFACE
2260 if(rdmalt(Adapter
, TARGET_SFID_TXDESC_MAP_LOC
, (PUINT
)uibuff
, sizeof(UINT
) * MAX_TARGET_DSX_BUFFERS
)<0)
2262 if(rdmaltWithLock(Adapter
, TARGET_SFID_TXDESC_MAP_LOC
, (PUINT
)uibuff
, sizeof(UINT
) * MAX_TARGET_DSX_BUFFERS
)<0)
2265 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0, "rdm failed\n");
2268 for(iIndex
= 0;iIndex
< HiPriority
; iIndex
++)
2270 if(Adapter
->PackInfo
[iIndex
].bValid
&& Adapter
->PackInfo
[iIndex
].ucDirection
)
2272 if(Adapter
->PackInfo
[iIndex
].usVCID_Value
< MAX_TARGET_DSX_BUFFERS
)
2274 atomic_set(&Adapter
->PackInfo
[iIndex
].uiPerSFTxResourceCount
, uibuff
[Adapter
->PackInfo
[iIndex
].usVCID_Value
]);
2278 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0, "Invalid VCID : %x \n",
2279 Adapter
->PackInfo
[iIndex
].usVCID_Value
);
2283 atomic_set (&Adapter
->uiMBupdate
, FALSE
);
2286 void flush_queue(PMINI_ADAPTER Adapter
, UINT iQIndex
)
2288 struct sk_buff
* PacketToDrop
=NULL
;
2289 struct net_device_stats
* netstats
=NULL
;
2291 netstats
= &((PLINUX_DEP_DATA
)Adapter
->pvOsDepData
)->netstats
;
2293 spin_lock_bh(&Adapter
->PackInfo
[iQIndex
].SFQueueLock
);
2295 while(Adapter
->PackInfo
[iQIndex
].FirstTxQueue
&&
2296 atomic_read(&Adapter
->TotalPacketCount
))
2298 PacketToDrop
= Adapter
->PackInfo
[iQIndex
].FirstTxQueue
;
2299 if(PacketToDrop
&& PacketToDrop
->len
)
2301 netstats
->tx_dropped
++;
2302 DEQUEUEPACKET(Adapter
->PackInfo
[iQIndex
].FirstTxQueue
, \
2303 Adapter
->PackInfo
[iQIndex
].LastTxQueue
);
2305 Adapter
->PackInfo
[iQIndex
].uiCurrentPacketsOnHost
--;
2306 Adapter
->PackInfo
[iQIndex
].uiCurrentBytesOnHost
-= PacketToDrop
->len
;
2308 //Adding dropped statistics
2309 Adapter
->PackInfo
[iQIndex
].uiDroppedCountBytes
+= PacketToDrop
->len
;
2310 Adapter
->PackInfo
[iQIndex
].uiDroppedCountPackets
++;
2312 bcm_kfree_skb(PacketToDrop
);
2313 atomic_dec(&Adapter
->TotalPacketCount
);
2314 atomic_inc(&Adapter
->TxDroppedPacketCount
);
2318 spin_unlock_bh(&Adapter
->PackInfo
[iQIndex
].SFQueueLock
);
2322 void beceem_protocol_reset (PMINI_ADAPTER Adapter
)
2326 if(NULL
!= Adapter
->dev
)
2328 netif_carrier_off(Adapter
->dev
);
2329 netif_stop_queue(Adapter
->dev
);
2332 Adapter
->IdleMode
= FALSE
;
2333 Adapter
->LinkUpStatus
= FALSE
;
2334 Adapter
->ucDsxConnBitMap
= FALSE
;
2335 ClearTargetDSXBuffer(Adapter
,0, TRUE
);
2336 //Delete All Classifier Rules
2338 for(i
= 0;i
<HiPriority
;i
++)
2340 DeleteAllClassifiersForSF(Adapter
,i
);
2343 flush_all_queues(Adapter
);
2345 if(Adapter
->TimerActive
== TRUE
)
2346 Adapter
->TimerActive
= FALSE
;
2348 memset(Adapter
->astFragmentedPktClassifierTable
, 0,
2349 sizeof(S_FRAGMENTED_PACKET_INFO
) *
2350 MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES
);
2352 for(i
= 0;i
<HiPriority
;i
++)
2354 //resetting only the first size (S_MIBS_SERVICEFLOW_TABLE) for the SF.
2355 // It is same between MIBs and SF.
2356 memset((PVOID
)&Adapter
->PackInfo
[i
],0,sizeof(S_MIBS_SERVICEFLOW_TABLE
));
2362 #ifdef BCM_SHM_INTERFACE
2365 #define GET_GTB_DIFF(start, end) \
2366 ( (start) < (end) )? ( (end) - (start) ) : ( ~0x0 - ( (start) - (end)) +1 )
2368 void usdelay ( unsigned int a
) {
2369 unsigned int start
= *(unsigned int *)0xaf8051b4;
2370 unsigned int end
= start
+1;
2371 unsigned int diff
= 0;
2374 end
= *(unsigned int *)0xaf8051b4;
2375 diff
= (GET_GTB_DIFF(start
,end
))/80;
2380 void read_cfg_file(PMINI_ADAPTER Adapter
) {
2383 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"Config File Version = 0x%x \n",Adapter
->pstargetparams
->m_u32CfgVersion
);
2384 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"Center Frequency = 0x%x \n",Adapter
->pstargetparams
->m_u32CenterFrequency
);
2385 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"Band A Scan = 0x%x \n",Adapter
->pstargetparams
->m_u32BandAScan
);
2386 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"Band B Scan = 0x%x \n",Adapter
->pstargetparams
->m_u32BandBScan
);
2387 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"Band C Scan = 0x%x \n",Adapter
->pstargetparams
->m_u32BandCScan
);
2388 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"ERTPS Options = 0x%x \n",Adapter
->pstargetparams
->m_u32ErtpsOptions
);
2389 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"PHS Enable = 0x%x \n",Adapter
->pstargetparams
->m_u32PHSEnable
);
2390 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"Handoff Enable = 0x%x \n",Adapter
->pstargetparams
->m_u32HoEnable
);
2391 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"HO Reserved1 = 0x%x \n",Adapter
->pstargetparams
->m_u32HoReserved1
);
2392 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"HO Reserved2 = 0x%x \n",Adapter
->pstargetparams
->m_u32HoReserved2
);
2393 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"MIMO Enable = 0x%x \n",Adapter
->pstargetparams
->m_u32MimoEnable
);
2394 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"PKMv2 Enable = 0x%x \n",Adapter
->pstargetparams
->m_u32SecurityEnable
);
2395 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"Powersaving Modes Enable = 0x%x \n",Adapter
->pstargetparams
->m_u32PowerSavingModesEnable
);
2396 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"Power Saving Mode Options = 0x%x \n",Adapter
->pstargetparams
->m_u32PowerSavingModeOptions
);
2397 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"ARQ Enable = 0x%x \n",Adapter
->pstargetparams
->m_u32ArqEnable
);
2398 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"Harq Enable = 0x%x \n",Adapter
->pstargetparams
->m_u32HarqEnable
);
2399 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"EEPROM Flag = 0x%x \n",Adapter
->pstargetparams
->m_u32EEPROMFlag
);
2400 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"Customize = 0x%x \n",Adapter
->pstargetparams
->m_u32Customize
);
2401 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"Bandwidth = 0x%x \n",Adapter
->pstargetparams
->m_u32ConfigBW
);
2402 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"ShutDown Timer Value = 0x%x \n",Adapter
->pstargetparams
->m_u32ShutDownInitThresholdTimer
);
2403 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"RadioParameter = 0x%x \n",Adapter
->pstargetparams
->m_u32RadioParameter
);
2404 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"PhyParameter1 = 0x%x \n",Adapter
->pstargetparams
->m_u32PhyParameter1
);
2405 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"PhyParameter2 = 0x%x \n",Adapter
->pstargetparams
->m_u32PhyParameter2
);
2406 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"PhyParameter3 = 0x%x \n",Adapter
->pstargetparams
->m_u32PhyParameter3
);
2407 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"m_u32TestOptions = 0x%x \n",Adapter
->pstargetparams
->m_u32TestOptions
);
2408 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"MaxMACDataperDLFrame = 0x%x \n",Adapter
->pstargetparams
->m_u32MaxMACDataperDLFrame
);
2409 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"MaxMACDataperULFrame = 0x%x \n",Adapter
->pstargetparams
->m_u32MaxMACDataperULFrame
);
2410 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"Corr2MacFlags = 0x%x \n",Adapter
->pstargetparams
->m_u32Corr2MacFlags
);
2411 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"HostDrvrConfig1 = 0x%x \n",Adapter
->pstargetparams
->HostDrvrConfig1
);
2412 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"HostDrvrConfig2 = 0x%x \n",Adapter
->pstargetparams
->HostDrvrConfig2
);
2413 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"HostDrvrConfig3 = 0x%x \n",Adapter
->pstargetparams
->HostDrvrConfig3
);
2414 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"HostDrvrConfig4 = 0x%x \n",Adapter
->pstargetparams
->HostDrvrConfig4
);
2415 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"HostDrvrConfig5 = 0x%x \n",Adapter
->pstargetparams
->HostDrvrConfig5
);
2416 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"HostDrvrConfig6 = 0x%x \n",Adapter
->pstargetparams
->HostDrvrConfig6
);
2417 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"Segmented PUSC Enable = 0x%x \n",Adapter
->pstargetparams
->m_u32SegmentedPUSCenable
);
2418 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0,"BamcEnable = 0x%x \n",Adapter
->pstargetparams
->m_u32BandAMCEnable
);