diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-10 16:04:53 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-10 16:04:53 -0800 |
commit | 949f6711b83d2809d1ccb9d830155a65fdacdff9 (patch) | |
tree | 4b8bdb0e98489bc8ad77fa144926931c37e2e4f2 /drivers/staging/bcm | |
parent | 443e6221e465efa8efb752a8405a759ef1161af9 (diff) | |
parent | 7959d55679e4360205c9ebc89d40a5503c53bae2 (diff) |
Merge branch 'staging-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6
* 'staging-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6: (510 commits)
staging: speakup: fix failure handling
staging: usbip: remove double giveback of URB
Staging: batman-adv: Remove batman-adv from staging
Staging: hv: Use only one txf buffer per channel and kmalloc/GFP_KERNEL on initialize
staging: hv: remove unneeded osd_schedule_callback
staging: hv: convert channel_mgmt.c to not call osd_schedule_callback
staging: hv: convert vmbus_on_msg_dpc to not call osd_schedule_callback
staging: brcm80211: Fix WL_<type> logging macros
Staging: IIO: DDS: AD9833 / AD9834 driver
Staging: IIO: dds.h convenience macros
Staging: IIO: Direct digital synthesis abi documentation
staging: brcm80211: Convert ETHER_TYPE_802_1X to ETH_P_PAE
staging: brcm80211: Remove unused ETHER_TYPE_<foo> #defines
staging: brcm80211: Remove ETHER_HDR_LEN, use ETH_HLEN
staging: brcm80211: Convert ETHER_ADDR_LEN to ETH_ALEN
staging: brcm80211: Convert ETHER_IS<FOO> to is_<foo>_ether_addr
staging: brcm80211: Remove unused ether_<foo> #defines and struct
staging: brcm80211: Convert ETHER_IS_MULTI to is_multicast_ether_addr
staging: brcm80211: Remove unused #defines ETHER_<foo>_LOCALADDR
Staging: comedi: Fix checkpatch.pl issues in file s526.c
...
Fix up trivial conflict in drivers/video/udlfb.c
Diffstat (limited to 'drivers/staging/bcm')
44 files changed, 1483 insertions, 4554 deletions
diff --git a/drivers/staging/bcm/Adapter.h b/drivers/staging/bcm/Adapter.h index 748460e898d8..32909e2938d5 100644 --- a/drivers/staging/bcm/Adapter.h +++ b/drivers/staging/bcm/Adapter.h @@ -7,53 +7,6 @@ #define MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES 256 #include "Debug.h" -typedef struct _LIST_ENTRY{ - struct _LIST_ENTRY *next; - struct _LIST_ENTRY *prev; -} LIST_ENTRY, *PLIST_ENTRY; - -typedef struct _BCM_LIST_ENTRY { - - LIST_ENTRY Link; - -} BCM_LIST_ENTRY, *PBCM_LIST_ENTRY; - -typedef enum _RCB_STATUS -{ - DRIVER_PROCESSED=1, - APPLICATION_PROCESSED -} RCB_STATUS, *PRCB_STATUS; - -#define fFILLED 1 -#define fEMPTY 0 - -struct _BCM_CB -{ - // The network packet that this RCB is receiving - PVOID pv_packet; - // Describes the length of the packet . - UINT ui_packet_length; - // Pointer to the first buffer in the packet (only one buffer for Rx) - PUCHAR buffer; - atomic_t status; - UINT filled; -} __attribute__((packed)); -typedef struct _BCM_CB BCM_CB,*PBCM_CB; - -typedef BCM_CB BCM_RCB, *PBCM_RCB; -typedef BCM_CB BCM_TCB, *PBCM_TCB; - -/* This is to be stored in the "pvOsDepData" of ADAPTER */ -typedef struct LINUX_DEP_DATA -{ - struct net_device *virtualdev; /* Our Interface (veth0) */ - struct net_device *actualdev; /* True Interface (eth0) */ - struct net_device_stats netstats; /* Net statistics */ - struct fasync_struct *async_queue; /* For asynchronus notification */ - -} LINUX_DEP_DATA, *PLINUX_DEP_DATA; - - struct _LEADER { USHORT Vcid; @@ -429,26 +382,28 @@ Driver adapter data structure struct _MINI_ADAPTER { struct _MINI_ADAPTER *next; - PVOID pvOsDepData; + struct net_device *dev; + u32 msg_enable; + CHAR *caDsxReqResp; - atomic_t ApplicationRunning; + atomic_t ApplicationRunning; volatile INT CtrlQueueLen; - atomic_t AppCtrlQueueLen; - BOOLEAN AppCtrlQueueOverFlow; - atomic_t CurrentApplicationCount; - atomic_t RegisteredApplicationCount; - BOOLEAN TimerActive; - ULONG StatisticsPointer; + atomic_t AppCtrlQueueLen; + BOOLEAN AppCtrlQueueOverFlow; + atomic_t CurrentApplicationCount; + atomic_t RegisteredApplicationCount; + BOOLEAN LinkUpStatus; + BOOLEAN TimerActive; + u32 StatisticsPointer; struct sk_buff *RxControlHead; struct sk_buff *RxControlTail; -// spinlock_t RxControlQueuelock; + struct semaphore RxAppControlQueuelock; struct semaphore fw_download_sema; PPER_TARANG_DATA pTarangs; spinlock_t control_queue_lock; wait_queue_head_t process_read_wait_queue; - ULONG bcm_jiffies; /* Store Jiffies value */ // the pointer to the first packet we have queued in send // deserialized miniport support variables @@ -458,24 +413,15 @@ struct _MINI_ADAPTER // this to keep track of the Tx and Rx MailBox Registers. atomic_t CurrNumFreeTxDesc; // to keep track the no of byte recieved - atomic_t RxRollOverCount; USHORT PrevNumRecvDescs; USHORT CurrNumRecvDescs; - atomic_t GoodRxByteCount; - atomic_t GoodRxPktCount; - atomic_t BadRxByteCount; - atomic_t RxPacketDroppedCount; - atomic_t GoodTxByteCount; - atomic_t TxTotalPacketCount; - atomic_t TxDroppedPacketCount; - ULONG LinkUpStatus; - BOOLEAN TransferMode; UINT u32TotalDSD; PacketInfo PackInfo[NO_OF_QUEUES]; S_CLASSIFIER_RULE astClassifierTable[MAX_CLASSIFIERS]; + BOOLEAN TransferMode; /*************** qos ******************/ - UINT bETHCSEnabled; + BOOLEAN bETHCSEnabled; ULONG BEBucketSize; ULONG rtPSBucketSize; @@ -483,7 +429,6 @@ struct _MINI_ADAPTER BOOLEAN AutoLinkUp; BOOLEAN AutoSyncup; - struct net_device *dev; int major; int minor; wait_queue_head_t tx_packet_wait_queue; @@ -491,8 +436,6 @@ struct _MINI_ADAPTER atomic_t process_waiting; BOOLEAN fw_download_done; - unsigned int ctrlpkt_present; - BOOLEAN packets_given_to_all; char *txctlpacket[MAX_CNTRL_PKTS]; atomic_t cntrlpktCnt ; atomic_t index_app_read_cntrlpkt; @@ -502,34 +445,30 @@ struct _MINI_ADAPTER struct semaphore rdmwrmsync; STTARGETDSXBUFFER astTargetDsxBuffer[MAX_TARGET_DSX_BUFFERS]; - ULONG ulFreeTargetBufferCnt; + ULONG ulFreeTargetBufferCnt; ULONG ulCurrentTargetBuffer; ULONG ulTotalTargetBuffersAvailable; - unsigned int timeout; - int irq; + unsigned long chip_id; - unsigned int bFlashBoot; - unsigned int if_up; -// spinlock_t sleeper_lock; - atomic_t rdm_wrm_access; - atomic_t tx_rx_access; + wait_queue_head_t lowpower_mode_wait_queue; - atomic_t bAbortedByHost; - BOOLEAN bBinDownloaded; - BOOLEAN bCfgDownloaded; - USHORT usBestEffortQueueIndex; - BOOLEAN bSyncUpRequestSent; -// struct semaphore data_packet_queue_lock; + + BOOLEAN bFlashBoot; + BOOLEAN bBinDownloaded; + BOOLEAN bCfgDownloaded; + BOOLEAN bSyncUpRequestSent; + USHORT usBestEffortQueueIndex; + wait_queue_head_t ioctl_fw_dnld_wait_queue; BOOLEAN waiting_to_fw_download_done; pid_t fw_download_process_pid; PSTARGETPARAMS pstargetparams; BOOLEAN device_removed; BOOLEAN DeviceAccess; - INT DDRSetting; + BOOLEAN bIsAutoCorrectEnabled; BOOLEAN bDDRInitDone; + INT DDRSetting; ULONG ulPowerSaveMode; - BOOLEAN bIsAutoCorrectEnabled; spinlock_t txtransmitlock; B_UINT8 txtransmit_running; /* Thread for control packet handling */ @@ -567,13 +506,13 @@ struct _MINI_ADAPTER unsigned int usIdleModePattern; //BOOLEAN bTriedToWakeUpFromShutdown; BOOLEAN bLinkDownRequested; - unsigned int check_for_hang; + int downloadDDR; PHS_DEVICE_EXTENSION stBCMPhsContext; S_HDR_SUPRESSION_CONTEXTINFO stPhsTxContextInfo; uint8_t ucaPHSPktRestoreBuf[2048]; uint8_t bPHSEnabled; - int AutoFirmDld; + BOOLEAN AutoFirmDld; BOOLEAN bMipsConfig; BOOLEAN bDPLLConfig; UINT32 aTxPktSizeHist[MIBS_MAX_HIST_ENTRIES]; @@ -599,10 +538,9 @@ struct _MINI_ADAPTER struct semaphore NVMRdmWrmLock; - BOOLEAN bNetworkInterfaceRegistered; - BOOLEAN bNetdeviceNotifierRegistered; + struct device *pstCreatedClassDevice; - BOOLEAN bUsbClassDriverRegistered; + // BOOLEAN InterfaceUpStatus; PFLASH2X_CS_INFO psFlash2xCSInfo; PFLASH_CS_INFO psFlashCSInfo ; @@ -630,17 +568,13 @@ struct _MINI_ADAPTER struct semaphore LowPowerModeSync; ULONG liDrainCalculated; UINT gpioBitMap; + S_BCM_DEBUG_STATE stDebugState; }; typedef struct _MINI_ADAPTER MINI_ADAPTER, *PMINI_ADAPTER; - -typedef struct _DEVICE_EXTENSION -{ - PMINI_ADAPTER pAdapt; -}DEVICE_EXTENSION,*PDEVICE_EXTENSION; - +#define GET_BCM_ADAPTER(net_dev) netdev_priv(net_dev) struct _ETH_HEADER_STRUC { UCHAR au8DestinationAddress[6]; @@ -667,8 +601,8 @@ typedef LINK_REQUEST CONTROL_MESSAGE; typedef struct _DDR_SETTING { - ULONG ulRegAddress; - ULONG ulRegValue; + UINT ulRegAddress; + UINT ulRegValue; }DDR_SETTING, *PDDR_SETTING; typedef DDR_SETTING DDR_SET_NODE, *PDDR_SET_NODE; INT diff --git a/drivers/staging/bcm/Arp.c b/drivers/staging/bcm/Arp.c deleted file mode 100644 index d60d8593d2ef..000000000000 --- a/drivers/staging/bcm/Arp.c +++ /dev/null @@ -1,94 +0,0 @@ - -/* - * File Name: Arp.c - * Abstract: This file contains the routines for handling ARP PACKETS - */ -#include "headers.h" -#define ARP_PKT_SIZE 60 - -/* ========================================================================= - * Function - reply_to_arp_request() - * - * Description - When this host tries to broadcast ARP request packet through - * the virtual interface (veth0), reply directly to upper layer. - * This function allocates a new skb for ARP reply packet, - * fills in the fields of the packet and then sends it to - * upper layer. - * - * Parameters - skb: Pointer to sk_buff structure of the ARP request pkt. - * - * Returns - None - * =========================================================================*/ - -VOID -reply_to_arp_request(struct sk_buff *skb) -{ - PMINI_ADAPTER Adapter; - struct ArpHeader *pArpHdr = NULL; - struct ethhdr *pethhdr = NULL; - UCHAR uiIPHdr[4]; - /* Check for valid skb */ - if(skb == NULL) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Invalid skb: Cannot reply to ARP request\n"); - return; - } - - - Adapter = GET_BCM_ADAPTER(skb->dev); - /* Print the ARP Request Packet */ - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, ARP_RESP, DBG_LVL_ALL, "ARP Packet Dump :"); - BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_TX, ARP_RESP, DBG_LVL_ALL, (PUCHAR)(skb->data), skb->len); - - /* - * Extract the Ethernet Header and Arp Payload including Header - */ - pethhdr = (struct ethhdr *)skb->data; - pArpHdr = (struct ArpHeader *)(skb->data+ETH_HLEN); - - if(Adapter->bETHCSEnabled) - { - if(memcmp(pethhdr->h_source, Adapter->dev->dev_addr, ETH_ALEN)) - { - bcm_kfree_skb(skb); - return; - } - } - - // Set the Ethernet Header First. - memcpy(pethhdr->h_dest, pethhdr->h_source, ETH_ALEN); - if(!memcmp(pethhdr->h_source, Adapter->dev->dev_addr, ETH_ALEN)) - { - pethhdr->h_source[5]++; - } - - /* Set the reply to ARP Reply */ - pArpHdr->arp.ar_op = ntohs(ARPOP_REPLY); - - /* Set the HW Address properly */ - memcpy(pArpHdr->ar_sha, pethhdr->h_source, ETH_ALEN); - memcpy(pArpHdr->ar_tha, pethhdr->h_dest, ETH_ALEN); - - // Swapping the IP Adddress - memcpy(uiIPHdr,pArpHdr->ar_sip,4); - memcpy(pArpHdr->ar_sip,pArpHdr->ar_tip,4); - memcpy(pArpHdr->ar_tip,uiIPHdr,4); - - /* Print the ARP Reply Packet */ - - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, ARP_RESP, DBG_LVL_ALL, "ARP REPLY PACKET: "); - - /* Send the Packet to upper layer */ - BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_TX, ARP_RESP, DBG_LVL_ALL, (PUCHAR)(skb->data), skb->len); - - skb->protocol = eth_type_trans(skb,skb->dev); - skb->pkt_type = PACKET_HOST; - -// skb->mac.raw=skb->data+LEADER_SIZE; - skb_set_mac_header (skb, LEADER_SIZE); - netif_rx(skb); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, ARP_RESP, DBG_LVL_ALL, "<=============\n"); - return; -} - - diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index fead9c56162e..31674ea1cd48 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -12,7 +12,7 @@ * * Returns - Zero(Success) ****************************************************************/ -static struct class *bcm_class = NULL; + static int bcm_char_open(struct inode *inode, struct file * filp) { PMINI_ADAPTER Adapter = NULL; @@ -93,7 +93,7 @@ static int bcm_char_release(struct inode *inode, struct file *filp) /*Stop Queuing the control response Packets*/ atomic_dec(&Adapter->ApplicationRunning); - bcm_kfree(pTarang); + kfree(pTarang); /* remove this filp from the asynchronously notified filp's */ filp->private_data = NULL; @@ -102,11 +102,11 @@ static int bcm_char_release(struct inode *inode, struct file *filp) static ssize_t bcm_char_read(struct file *filp, char __user *buf, size_t size, loff_t *f_pos) { - PPER_TARANG_DATA pTarang = (PPER_TARANG_DATA)filp->private_data; + PPER_TARANG_DATA pTarang = filp->private_data; PMINI_ADAPTER Adapter = pTarang->Adapter; - struct sk_buff* Packet = NULL; - UINT PktLen = 0; - int wait_ret_val=0; + struct sk_buff* Packet = NULL; + ssize_t PktLen = 0; + int wait_ret_val=0; wait_ret_val = wait_event_interruptible(Adapter->process_read_wait_queue, (pTarang->RxAppControlHead || Adapter->device_removed)); @@ -139,14 +139,16 @@ static ssize_t bcm_char_read(struct file *filp, char __user *buf, size_t size, l if(Packet) { PktLen = Packet->len; - if(copy_to_user(buf, Packet->data, PktLen)) + if(copy_to_user(buf, Packet->data, min_t(size_t, PktLen, size))) { - bcm_kfree_skb(Packet); + dev_kfree_skb(Packet); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "\nReturning from copy to user failure \n"); return -EFAULT; } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Read %d Bytes From Adapter packet = 0x%p by process %d!\n", PktLen, Packet, current->pid); - bcm_kfree_skb(Packet); + BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "Read %zd Bytes From Adapter packet = %p by process %d!\n", + PktLen, Packet, current->pid); + dev_kfree_skb(Packet); } BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "<====\n"); @@ -155,15 +157,12 @@ static ssize_t bcm_char_read(struct file *filp, char __user *buf, size_t size, l static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { - PPER_TARANG_DATA pTarang = (PPER_TARANG_DATA)filp->private_data; - void __user *argp = (void __user *)argp; + PPER_TARANG_DATA pTarang = filp->private_data; + void __user *argp = (void __user *)arg; PMINI_ADAPTER Adapter = pTarang->Adapter; INT Status = STATUS_FAILURE; - IOCTL_BUFFER IoBuffer={}; -#ifndef BCM_SHM_INTERFACE - int timeout = 0; -#endif - + int timeout = 0; + IOCTL_BUFFER IoBuffer; BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Parameters Passed to control IOCTL cmd=0x%X arg=0x%lX", cmd, arg); @@ -204,50 +203,41 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = vendorextnIoctl(Adapter, cmd, arg); if(Status != CONTINUE_COMMON_PATH ) - { return Status; - } switch(cmd){ // Rdms for Swin Idle... case IOCTL_BCM_REGISTER_READ_PRIVATE: { RDM_BUFFER sRdmBuffer = {0}; - PCHAR temp_buff = NULL; - UINT Bufflen = 0; + PCHAR temp_buff; + UINT Bufflen; + /* Copy Ioctl Buffer structure */ - if(copy_from_user((PCHAR)&IoBuffer, argp, - sizeof(IOCTL_BUFFER))) - { - Status = -EFAULT; - break; - } + if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + + if (IoBuffer.InputLength > sizeof(sRdmBuffer)) + return -EINVAL; + if(copy_from_user(&sRdmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) + return -EFAULT; + + /* FIXME: need to restrict BuffLen */ Bufflen = IoBuffer.OutputLength + (4 - IoBuffer.OutputLength%4)%4; - temp_buff = (PCHAR)kmalloc(Bufflen, GFP_KERNEL); + temp_buff = kmalloc(Bufflen, GFP_KERNEL); if(!temp_buff) - { - return STATUS_FAILURE; - } - if(copy_from_user(&sRdmBuffer, IoBuffer.InputBuffer, - IoBuffer.InputLength)) - { - Status = -EFAULT; - break; - } + return -ENOMEM; + Status = rdmalt(Adapter, (UINT)sRdmBuffer.Register, (PUINT)temp_buff, Bufflen); - if(Status != STATUS_SUCCESS) - { - bcm_kfree(temp_buff); - return Status; - } - if(copy_to_user(IoBuffer.OutputBuffer, - (PCHAR)temp_buff, (UINT)IoBuffer.OutputLength)) + if(Status == STATUS_SUCCESS) { - Status = -EFAULT; + if(copy_to_user(IoBuffer.OutputBuffer, temp_buff, IoBuffer.OutputLength)) + Status = -EFAULT; } - bcm_kfree(temp_buff); + + kfree(temp_buff); break; } case IOCTL_BCM_REGISTER_WRITE_PRIVATE: @@ -256,19 +246,16 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) UINT uiTempVar=0; /* Copy Ioctl Buffer structure */ - if(copy_from_user(&IoBuffer, argp, - sizeof(IOCTL_BUFFER))) - { - Status = -EFAULT; - break; - } + if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + + if (IoBuffer.InputLength > sizeof(sWrmBuffer)) + return -EINVAL; + /* Get WrmBuffer structure */ - if(copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer, - IoBuffer.InputLength)) - { - Status = -EFAULT; - break; - } + if(copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) + return -EFAULT; + uiTempVar = sWrmBuffer.Register & EEPROM_REJECT_MASK; if(!((Adapter->pstargetparams->m_u32Customize) & VSG_MODE) && ((uiTempVar == EEPROM_REJECT_REG_1)|| @@ -277,8 +264,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) (uiTempVar == EEPROM_REJECT_REG_4))) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "EEPROM Access Denied, not in VSG Mode\n"); - Status = -EFAULT; - break; + return -EFAULT; } Status = wrmalt(Adapter, (UINT)sWrmBuffer.Register, (PUINT)sWrmBuffer.Data, sizeof(ULONG)); @@ -305,56 +291,39 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) (Adapter->bPreparingForLowPowerMode ==TRUE)) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Device in Idle Mode, Blocking Rdms\n"); - Status = -EACCES; - break; + return -EACCES; } /* Copy Ioctl Buffer structure */ - if(copy_from_user(&IoBuffer, argp, - sizeof(IOCTL_BUFFER))) - { - Status = -EFAULT; - break; - } + if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + + if (IoBuffer.InputLength > sizeof(sRdmBuffer)) + return -EINVAL; - temp_buff = (PCHAR)kmalloc(IoBuffer.OutputLength, GFP_KERNEL); + if(copy_from_user(&sRdmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) + return -EFAULT; + + /* FIXME: don't trust user supplied length */ + temp_buff = kmalloc(IoBuffer.OutputLength, GFP_KERNEL); if(!temp_buff) - { return STATUS_FAILURE; - } - if(copy_from_user(&sRdmBuffer, IoBuffer.InputBuffer, - IoBuffer.InputLength)) - { - Status = -EFAULT; - break; - } - if( -#if !defined(BCM_SHM_INTERFACE) - (((ULONG)sRdmBuffer.Register & 0x0F000000) != 0x0F000000) || -#endif - ((ULONG)sRdmBuffer.Register & 0x3) - ) + if((((ULONG)sRdmBuffer.Register & 0x0F000000) != 0x0F000000) || + ((ULONG)sRdmBuffer.Register & 0x3)) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "RDM Done On invalid Address : %x Access Denied.\n", (int)sRdmBuffer.Register); - Status = -EINVAL; - break; + return -EINVAL; } uiTempVar = sRdmBuffer.Register & EEPROM_REJECT_MASK; Status = rdmaltWithLock(Adapter, (UINT)sRdmBuffer.Register, (PUINT)temp_buff, IoBuffer.OutputLength); - if(Status != STATUS_SUCCESS) - { - bcm_kfree(temp_buff); - return Status; - } - if(copy_to_user(IoBuffer.OutputBuffer, - (PCHAR)temp_buff, (UINT)IoBuffer.OutputLength)) - { - Status = -EFAULT; - } - bcm_kfree(temp_buff); + if(Status == STATUS_SUCCESS) + if(copy_to_user(IoBuffer.OutputBuffer, temp_buff, IoBuffer.OutputLength)) + Status = -EFAULT; + + kfree(temp_buff); break; } case IOCTL_BCM_REGISTER_WRITE: @@ -367,36 +336,28 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) (Adapter->bPreparingForLowPowerMode ==TRUE)) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Device in Idle Mode, Blocking Wrms\n"); - Status = -EACCES; - break; + return -EACCES; } + /* Copy Ioctl Buffer structure */ - if(copy_from_user((PCHAR)&IoBuffer, argp, - sizeof(IOCTL_BUFFER))) - { - Status = -EFAULT; - break; - } + if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + + if (IoBuffer.InputLength > sizeof(sWrmBuffer)) + return -EINVAL; + /* Get WrmBuffer structure */ - if(copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer, - IoBuffer.InputLength)) - { - Status = -EFAULT; - break; - } - if( -#if !defined(BCM_SHM_INTERFACE) + if(copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) + return -EFAULT; - (((ULONG)sWrmBuffer.Register & 0x0F000000) != 0x0F000000) || -#endif - ((ULONG)sWrmBuffer.Register & 0x3) - ) + if( (((ULONG)sWrmBuffer.Register & 0x0F000000) != 0x0F000000) || + ((ULONG)sWrmBuffer.Register & 0x3) ) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "WRM Done On invalid Address : %x Access Denied.\n", (int)sWrmBuffer.Register); - Status = -EINVAL; - break; + return -EINVAL; } + uiTempVar = sWrmBuffer.Register & EEPROM_REJECT_MASK; if(!((Adapter->pstargetparams->m_u32Customize) & VSG_MODE) && ((uiTempVar == EEPROM_REJECT_REG_1)|| @@ -406,8 +367,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) (cmd == IOCTL_BCM_REGISTER_WRITE)) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "EEPROM Access Denied, not in VSG Mode\n"); - Status = -EFAULT; - break; + return -EFAULT; } Status = wrmaltWithLock(Adapter, (UINT)sWrmBuffer.Register, @@ -436,19 +396,14 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) (Adapter->bPreparingForLowPowerMode ==TRUE)) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"GPIO Can't be set/clear in Low power Mode"); - Status = -EACCES; - break; + return -EACCES; } if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - { - Status = -EFAULT; - break; - } + return -EFAULT; + if (IoBuffer.InputLength > sizeof(gpio_info)) + return -EINVAL; if(copy_from_user(&gpio_info, IoBuffer.InputBuffer, IoBuffer.InputLength)) - { - Status = -EFAULT; - break; - } + return -EFAULT; uiBit = gpio_info.uiGpioNumber; uiOperation = gpio_info.uiGpioValue; @@ -517,8 +472,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) break; case BCM_LED_THREAD_STATE_CHANGE_REQ: { - - USER_THREAD_REQ threadReq = {0}; + USER_THREAD_REQ threadReq = { 0 }; BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"User made LED thread InActive"); if((Adapter->IdleMode == TRUE) || @@ -529,21 +483,16 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = -EACCES; break; } - Status =copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying the IOBufer from user space err:%d",Status); - Status = -EFAULT; - break; - } - Status= copy_from_user(&threadReq, IoBuffer.InputBuffer, IoBuffer.InputLength); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying the InputBuffer from user space err:%d",Status); - Status = -EFAULT; - break; - } + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + + if (IoBuffer.InputLength > sizeof(threadReq)) + return -EINVAL; + + if (copy_from_user(&threadReq, IoBuffer.InputBuffer, IoBuffer.InputLength)) + return -EFAULT; + //if LED thread is running(Actively or Inactively) set it state to make inactive if(Adapter->LEDInfo.led_thread_running) { @@ -572,19 +521,13 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) if((Adapter->IdleMode == TRUE) || (Adapter->bShutStatus ==TRUE) || (Adapter->bPreparingForLowPowerMode ==TRUE)) - { - Status = -EACCES; - break; - } - if(copy_from_user((PCHAR)&IoBuffer, argp, sizeof(IOCTL_BUFFER))) { - Status = -EFAULT; - break; - } - if(copy_from_user(&gpio_info, IoBuffer.InputBuffer, IoBuffer.InputLength)) - { - Status = -EFAULT; - break; - } + return -EACCES; + if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + if (IoBuffer.InputLength > sizeof(gpio_info)) + return -EINVAL; + if(copy_from_user(&gpio_info, IoBuffer.InputBuffer, IoBuffer.InputLength)) + return -EFAULT; uiBit = gpio_info.uiGpioNumber; //Set the gpio output register Status = rdmaltWithLock(Adapter, (UINT)GPIO_PIN_STATE_REGISTER, @@ -608,25 +551,14 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) if((Adapter->IdleMode == TRUE) || (Adapter->bShutStatus ==TRUE) || (Adapter->bPreparingForLowPowerMode ==TRUE)) - { - Status = -EINVAL; - break; - } - Status = copy_from_user( (PCHAR)&IoBuffer, argp, sizeof( IOCTL_BUFFER)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying the IOBufer from user space err:%d",Status); - Status = -EFAULT; - break; - } + return -EINVAL; + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + if (IoBuffer.InputLength > sizeof(gpio_multi_info)) + return -EINVAL; + if (copy_from_user(&gpio_multi_info, IoBuffer.InputBuffer, IoBuffer.InputLength)) + return -EFAULT; - Status = copy_from_user( &gpio_multi_info, IoBuffer.InputBuffer, IoBuffer.InputLength); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying the IOBufer Contents from user space err:%d",Status); - Status = -EFAULT; - break; - } if(IsReqGpioIsLedInNVM(Adapter,pgpio_multi_info[WIMAX_IDX].uiGPIOMask)== FALSE) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Sorry, Requested GPIO<0x%X> is not correspond to NVM LED bit map<0x%X>!!!",pgpio_multi_info[WIMAX_IDX].uiGPIOMask,Adapter->gpioBitMap); @@ -686,7 +618,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) if(Status) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying Content to IOBufer for user space err:%d",Status); - Status = -EFAULT; break; } } @@ -700,25 +631,14 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) if((Adapter->IdleMode == TRUE) || (Adapter->bShutStatus ==TRUE) || (Adapter->bPreparingForLowPowerMode ==TRUE)) - { - Status = -EINVAL; - break; - } - Status = copy_from_user(&IoBuffer, argp, sizeof( IOCTL_BUFFER)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying the IOBufer from user space err:%d",Status); - Status = -EFAULT; - break; - } + return -EINVAL; - Status = copy_from_user( &gpio_multi_mode, IoBuffer.InputBuffer, IoBuffer.InputLength); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying the IOBufer Contents from user space err:%d",Status); - Status = -EFAULT; - break; - } + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + if (IoBuffer.InputLength > sizeof(gpio_multi_mode)) + return -EINVAL; + if (copy_from_user(&gpio_multi_mode, IoBuffer.InputBuffer, IoBuffer.InputLength)) + return -EFAULT; Status = rdmaltWithLock( Adapter, ( UINT) GPIO_MODE_REGISTER, ( PUINT) ucResetValue, sizeof( UINT)); if( STATUS_SUCCESS != Status) @@ -769,7 +689,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) if(Status) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying Content to IOBufer for user space err:%d",Status); - Status = -EFAULT; break; } } @@ -783,24 +702,20 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) case IOCTL_IDLE_REQ: { PVOID pvBuffer=NULL; + /* Copy Ioctl Buffer structure */ - if(copy_from_user(&IoBuffer, argp, - sizeof(IOCTL_BUFFER))) - { - Status = -EFAULT; - break; - } - pvBuffer=kmalloc(IoBuffer.InputLength, GFP_KERNEL); + if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + + /* FIXME: don't accept any length from user */ + pvBuffer = kmalloc(IoBuffer.InputLength, GFP_KERNEL); if(!pvBuffer) - { return -ENOMEM; - } - if(copy_from_user(pvBuffer, IoBuffer.InputBuffer, - IoBuffer.InputLength)) + if(copy_from_user(pvBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) { Status = -EFAULT; - bcm_kfree(pvBuffer); + kfree(pvBuffer); break; } @@ -820,10 +735,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = CopyBufferToControlPacket(Adapter, (PVOID)pvBuffer); cntrlEnd: up(&Adapter->LowPowerModeSync); - bcm_kfree(pvBuffer); + kfree(pvBuffer); break; } -#ifndef BCM_SHM_INTERFACE case IOCTL_BCM_BUFFER_DOWNLOAD_START: { INT NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock) ; @@ -844,7 +758,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = reset_card_proc(Adapter); if(Status) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "reset_card_proc Failed!\n"); + pr_err(PFX "%s: reset_card_proc Failed!\n", Adapter->dev->name); up(&Adapter->fw_download_sema); up(&Adapter->NVMRdmWrmLock); break; @@ -862,7 +776,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) } case IOCTL_BCM_BUFFER_DOWNLOAD: { - FIRMWARE_INFO *psFwInfo=NULL; + FIRMWARE_INFO *psFwInfo = NULL; BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Starting the firmware download PID =0x%x!!!!\n", current->pid); do{ if(!down_trylock(&Adapter->fw_download_sema)) @@ -871,29 +785,23 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status=-EINVAL; break; } + /* Copy Ioctl Buffer structure */ if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "copy_from_user 1 failed\n"); - Status = -EFAULT; - break; - } + return -EFAULT; + BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Length for FW DLD is : %lx\n", IoBuffer.InputLength); - psFwInfo=kmalloc(sizeof(*psFwInfo), GFP_KERNEL); + + if (IoBuffer.InputLength > sizeof(FIRMWARE_INFO)) + return -EINVAL; + + psFwInfo = kmalloc(sizeof(*psFwInfo), GFP_KERNEL); if(!psFwInfo) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Failed to allocate buffer!!!!\n"); - Status = -ENOMEM; - break; - } - if(copy_from_user(psFwInfo, IoBuffer.InputBuffer, - IoBuffer.InputLength)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy_from_user 2 failed\n"); - Status = -EFAULT; - break; - } + return -ENOMEM; + + if(copy_from_user(psFwInfo, IoBuffer.InputBuffer, IoBuffer.InputLength)) + return -EFAULT; if(!psFwInfo->pvMappedFirmwareAddress || (psFwInfo->u32FirmwareLength == 0)) @@ -929,7 +837,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) if(Status != STATUS_SUCCESS) up(&Adapter->fw_download_sema); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, OSAL_DBG, DBG_LVL_ALL, "IOCTL: Firmware File Uploaded\n"); - bcm_kfree(psFwInfo); + kfree(psFwInfo); break; } case IOCTL_BCM_BUFFER_DOWNLOAD_STOP: @@ -946,7 +854,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Adapter->bBinDownloaded=TRUE; Adapter->bCfgDownloaded=TRUE; atomic_set(&Adapter->CurrNumFreeTxDesc, 0); - atomic_set(&Adapter->RxRollOverCount, 0); + Adapter->CurrNumRecvDescs=0; Adapter->downloadDDR = 0; @@ -999,7 +907,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) up(&Adapter->NVMRdmWrmLock); break; } -#endif case IOCTL_BE_BUCKET_SIZE: Status = 0; if (get_user(Adapter->BEBucketSize, (unsigned long __user *)arg)) @@ -1050,22 +957,16 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) break; case IOCTL_GET_PACK_INFO: - if(copy_to_user(argp, &Adapter->PackInfo, - sizeof(PacketInfo)*NO_OF_QUEUES)) - { - Status = -EFAULT; - break; - } + if(copy_to_user(argp, &Adapter->PackInfo, sizeof(PacketInfo)*NO_OF_QUEUES)) + return -EFAULT; Status = STATUS_SUCCESS; break; case IOCTL_BCM_SWITCH_TRANSFER_MODE: { UINT uiData = 0; if(copy_from_user(&uiData, argp, sizeof(UINT))) - { - Status = -EFAULT; - break; - } + return -EFAULT; + if(uiData) /* Allow All Packets */ { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SWITCH_TRANSFER_MODE: ETH_PACKET_TUNNELING_MODE\n"); @@ -1084,22 +985,16 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { /* Copy Ioctl Buffer structure */ if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - { - Status = -EFAULT; - break; - } - if(copy_to_user(IoBuffer.OutputBuffer, - VER_FILEVERSION_STR, (UINT)IoBuffer.OutputLength)) - { - Status = -EFAULT; - break; - } + return -EFAULT; + + if(copy_to_user(IoBuffer.OutputBuffer, VER_FILEVERSION_STR, IoBuffer.OutputLength)) + return -EFAULT; Status = STATUS_SUCCESS; break; } case IOCTL_BCM_GET_CURRENT_STATUS: { - LINK_STATE plink_state; + LINK_STATE link_state; /* Copy Ioctl Buffer structure */ if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) @@ -1108,19 +1003,19 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = -EFAULT; break; } - if (IoBuffer.OutputLength != sizeof(plink_state)) { + if (IoBuffer.OutputLength != sizeof(link_state)) { Status = -EINVAL; break; } - if (copy_from_user(&plink_state, (void __user *)arg, sizeof(plink_state))) { - Status = -EFAULT; - break; - } - plink_state.bIdleMode = (UCHAR)Adapter->IdleMode; - plink_state.bShutdownMode = Adapter->bShutStatus; - plink_state.ucLinkStatus = (UCHAR)Adapter->LinkStatus; - if (copy_to_user(IoBuffer.OutputBuffer, &plink_state, IoBuffer.OutputLength)) { + memset(&link_state, 0, sizeof(link_state)); + link_state.bIdleMode = Adapter->IdleMode; + link_state.bShutdownMode = Adapter->bShutStatus; + link_state.ucLinkStatus = Adapter->LinkStatus; + + if (copy_to_user(IoBuffer.OutputBuffer, &link_state, + min_t(size_t, sizeof(link_state), IoBuffer.OutputLength))) + { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy_to_user Failed..\n"); Status = -EFAULT; break; @@ -1131,17 +1026,14 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) case IOCTL_BCM_SET_MAC_TRACING: { UINT tracing_flag; + /* copy ioctl Buffer structure */ - if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - { - Status = -EFAULT; - break; - } - if(copy_from_user(&tracing_flag, IoBuffer.InputBuffer,sizeof(UINT))) - { - Status = -EFAULT; - break; - } + if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + + if(copy_from_user(&tracing_flag,IoBuffer.InputBuffer,sizeof(UINT))) + return -EFAULT; + if (tracing_flag) Adapter->pTarangs->MacTracingEnabled = TRUE; else @@ -1151,72 +1043,53 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) case IOCTL_BCM_GET_DSX_INDICATION: { ULONG ulSFId=0; - if(copy_from_user((PCHAR)&IoBuffer, argp, - sizeof(IOCTL_BUFFER))) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Invalid IO buffer!!!" ); - Status = -EFAULT; - break; - } + if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + if(IoBuffer.OutputLength < sizeof(stLocalSFAddIndicationAlt)) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Mismatch req: %lx needed is =0x%zx!!!", - IoBuffer.OutputLength, sizeof(stLocalSFAddIndicationAlt)); + BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, + "Mismatch req: %lx needed is =0x%zx!!!", + IoBuffer.OutputLength, sizeof(stLocalSFAddIndicationAlt)); return -EINVAL; } - if(copy_from_user(&ulSFId, IoBuffer.InputBuffer, - sizeof(ulSFId))) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Invalid SFID!!! %lu", ulSFId ); - Status = -EFAULT; - break; - } + + if(copy_from_user(&ulSFId, IoBuffer.InputBuffer, sizeof(ulSFId))) + return -EFAULT; + BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Get DSX Data SF ID is =%lx\n", ulSFId ); - get_dsx_sf_data_to_application(Adapter, ulSFId, - IoBuffer.OutputBuffer); + get_dsx_sf_data_to_application(Adapter, ulSFId, IoBuffer.OutputBuffer); Status=STATUS_SUCCESS; } break; case IOCTL_BCM_GET_HOST_MIBS: { - PCHAR temp_buff; + PVOID temp_buff; if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy_from user for IoBuff failed\n"); - Status = -EFAULT; - break; - } + return -EFAULT; if(IoBuffer.OutputLength != sizeof(S_MIBS_HOST_STATS_MIBS)) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Length Check failed %lu %zd\n", IoBuffer.OutputLength, - sizeof(S_MIBS_HOST_STATS_MIBS)); - return -EINVAL; + BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, + "Length Check failed %lu %zd\n", + IoBuffer.OutputLength, sizeof(S_MIBS_HOST_STATS_MIBS)); + return -EINVAL; } - temp_buff = (PCHAR)kmalloc(IoBuffer.OutputLength, GFP_KERNEL); - + /* FIXME: HOST_STATS are too big for kmalloc (122048)! */ + temp_buff = kzalloc(sizeof(S_MIBS_HOST_STATS_MIBS), GFP_KERNEL); if(!temp_buff) - { return STATUS_FAILURE; - } - - Status = ProcessGetHostMibs(Adapter, - (PUCHAR)temp_buff, IoBuffer.OutputLength); - Status = GetDroppedAppCntrlPktMibs((PVOID)temp_buff, - (PPER_TARANG_DATA)filp->private_data); + Status = ProcessGetHostMibs(Adapter, temp_buff); + GetDroppedAppCntrlPktMibs(temp_buff, pTarang); - if(copy_to_user(IoBuffer.OutputBuffer,(PCHAR)temp_buff, - sizeof(S_MIBS_HOST_STATS_MIBS))) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy to user failed\n"); - bcm_kfree(temp_buff); - return -EFAULT; - } + if (Status != STATUS_FAILURE) + if(copy_to_user(IoBuffer.OutputBuffer, temp_buff, sizeof(S_MIBS_HOST_STATS_MIBS))) + Status = -EFAULT; - bcm_kfree(temp_buff); + kfree(temp_buff); break; } @@ -1226,10 +1099,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Adapter->usIdleModePattern = ABORT_IDLE_MODE; Adapter->bWakeUpDevice = TRUE; wake_up(&Adapter->process_rx_cntrlpkt); - #if 0 - Adapter->bTriedToWakeUpFromlowPowerMode = TRUE; - InterfaceAbortIdlemode (Adapter, Adapter->usIdleModePattern); - #endif } Status = STATUS_SUCCESS; break; @@ -1248,24 +1117,20 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = -EACCES; break; } + /* Copy Ioctl Buffer structure */ - if(copy_from_user((PCHAR)&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - { - Status = -EFAULT; - break; - } + if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; - pvBuffer=kmalloc(IoBuffer.InputLength, GFP_KERNEL); + /* FIXME: restrict length */ + pvBuffer = kmalloc(IoBuffer.InputLength, GFP_KERNEL); if(!pvBuffer) - { return -ENOMEM; - break; - } /* Get WrmBuffer structure */ - if(copy_from_user(pvBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) + if(copy_from_user(pvBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) { - bcm_kfree(pvBuffer); + kfree(pvBuffer); Status = -EFAULT; break; } @@ -1275,7 +1140,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) if(((ULONG)pBulkBuffer->Register & 0x0F000000) != 0x0F000000 || ((ULONG)pBulkBuffer->Register & 0x3)) { - bcm_kfree(pvBuffer); + kfree(pvBuffer); BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0,"WRM Done On invalid Address : %x Access Denied.\n",(int)pBulkBuffer->Register); Status = -EINVAL; break; @@ -1290,7 +1155,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) (uiTempVar == EEPROM_REJECT_REG_4)) && (cmd == IOCTL_BCM_REGISTER_WRITE)) { - bcm_kfree(pvBuffer); + kfree(pvBuffer); BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0,"EEPROM Access Denied, not in VSG Mode\n"); Status = -EFAULT; break; @@ -1306,30 +1171,19 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "WRM Failed\n"); } - bcm_kfree(pvBuffer); + kfree(pvBuffer); break; } case IOCTL_BCM_GET_NVM_SIZE: - { - if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - { - //IOLog("failed NVM first"); - Status = -EFAULT; - break; - } + return -EFAULT; + if(Adapter->eNVMType == NVM_EEPROM || Adapter->eNVMType == NVM_FLASH ) { - if(copy_to_user(IoBuffer.OutputBuffer, - (unsigned char *)&Adapter->uiNVMDSDSize, (UINT)sizeof(UINT))) - { - Status = -EFAULT; - return Status; - } + if(copy_to_user(IoBuffer.OutputBuffer, &Adapter->uiNVMDSDSize, sizeof(UINT))) + return -EFAULT; } - Status = STATUS_SUCCESS ; - } break; case IOCTL_BCM_CAL_INIT : @@ -1338,40 +1192,26 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) UINT uiSectorSize = 0 ; if(Adapter->eNVMType == NVM_FLASH) { - Status = copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Copy From User space failed. status :%d", Status); + if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) return -EFAULT; - } - if (get_user(uiSectorSize, (unsigned int __user *)IoBuffer.InputBuffer)) + + if (copy_from_user(&uiSectorSize, IoBuffer.InputBuffer, sizeof(UINT))) return -EFAULT; if((uiSectorSize < MIN_SECTOR_SIZE) || (uiSectorSize > MAX_SECTOR_SIZE)) { - - Status = copy_to_user(IoBuffer.OutputBuffer, - (unsigned char *)&Adapter->uiSectorSize , - (UINT)sizeof(UINT)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Coping the sector size to use space failed. status:%d",Status); - return -EFAULT; - } + if (copy_to_user(IoBuffer.OutputBuffer, &Adapter->uiSectorSize, + sizeof(UINT))) + return -EFAULT; } else { if(IsFlash2x(Adapter)) { - Status = copy_to_user(IoBuffer.OutputBuffer, - (unsigned char *)&Adapter->uiSectorSize , - (UINT)sizeof(UINT)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Coping the sector size to use space failed. status:%d",Status); - return -EFAULT; - } - + if (copy_to_user(IoBuffer.OutputBuffer, + &Adapter->uiSectorSize , + sizeof(UINT))) + return -EFAULT; } else { @@ -1395,25 +1235,19 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) } break; case IOCTL_BCM_SET_DEBUG : +#ifdef DEBUG { USER_BCM_DBG_STATE sUserDebugState; // BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "Entered the ioctl %x \n", IOCTL_BCM_SET_DEBUG ); BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "In SET_DEBUG ioctl\n"); - Status = copy_from_user((PCHAR)&IoBuffer, argp, sizeof(IOCTL_BUFFER)); - if(Status) - { - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy from user failed\n"); - Status = -EFAULT; - break; - } - Status = copy_from_user(&sUserDebugState,IoBuffer.InputBuffer, sizeof(USER_BCM_DBG_STATE)); - if(Status) - { - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of IoBuffer.InputBuffer failed"); + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) return -EFAULT; - } + + if (copy_from_user(&sUserDebugState, IoBuffer.InputBuffer, sizeof(USER_BCM_DBG_STATE))) + return -EFAULT; + BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "IOCTL_BCM_SET_DEBUG: OnOff=%d Type = 0x%x ", sUserDebugState.OnOff, sUserDebugState.Type); @@ -1436,15 +1270,14 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) BCM_SHOW_DEBUG_BITMAP(Adapter); } +#endif break; case IOCTL_BCM_NVM_READ: case IOCTL_BCM_NVM_WRITE: { - - NVM_READWRITE stNVMReadWrite = {}; + NVM_READWRITE stNVMReadWrite; PUCHAR pReadData = NULL; - void __user * pBuffertobeCopied = NULL; - ULONG ulDSDMagicNumInUsrBuff = 0 ; + ULONG ulDSDMagicNumInUsrBuff = 0; struct timeval tv0, tv1; memset(&tv0,0,sizeof(struct timeval)); memset(&tv1,0,sizeof(struct timeval)); @@ -1469,21 +1302,12 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) /* Copy Ioctl Buffer structure */ if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"copy_from_user failed\n"); - Status = -EFAULT; - break; - } - if(IOCTL_BCM_NVM_READ == cmd) - pBuffertobeCopied = IoBuffer.OutputBuffer; - else - pBuffertobeCopied = IoBuffer.InputBuffer; + return -EFAULT; - if(copy_from_user(&stNVMReadWrite, pBuffertobeCopied,sizeof(NVM_READWRITE))) - { - Status = -EFAULT; - break; - } + if(copy_from_user(&stNVMReadWrite, + (IOCTL_BCM_NVM_READ == cmd) ? IoBuffer.OutputBuffer : IoBuffer.InputBuffer, + sizeof(NVM_READWRITE))) + return -EFAULT; // // Deny the access if the offset crosses the cal area limit. @@ -1496,18 +1320,15 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) break; } - pReadData =(PCHAR)kmalloc(stNVMReadWrite.uiNumBytes, GFP_KERNEL); - + pReadData = kzalloc(stNVMReadWrite.uiNumBytes, GFP_KERNEL); if(!pReadData) return -ENOMEM; - memset(pReadData,0,stNVMReadWrite.uiNumBytes); - if(copy_from_user(pReadData, stNVMReadWrite.pBuffer, stNVMReadWrite.uiNumBytes)) { Status = -EFAULT; - bcm_kfree(pReadData); + kfree(pReadData); break; } @@ -1522,7 +1343,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n"); up(&Adapter->NVMRdmWrmLock); - bcm_kfree(pReadData); + kfree(pReadData); return -EACCES; } @@ -1533,13 +1354,12 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) if(Status != STATUS_SUCCESS) { - bcm_kfree(pReadData); + kfree(pReadData); return Status; } - if(copy_to_user(stNVMReadWrite.pBuffer, - pReadData, (UINT)stNVMReadWrite.uiNumBytes)) + if(copy_to_user(stNVMReadWrite.pBuffer,pReadData, stNVMReadWrite.uiNumBytes)) { - bcm_kfree(pReadData); + kfree(pReadData); Status = -EFAULT; } } @@ -1554,7 +1374,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n"); up(&Adapter->NVMRdmWrmLock); - bcm_kfree(pReadData); + kfree(pReadData); return -EACCES; } @@ -1582,7 +1402,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"DSD Sig is present neither in Flash nor User provided Input.."); up(&Adapter->NVMRdmWrmLock); - bcm_kfree(pReadData); + kfree(pReadData); return Status; } @@ -1591,7 +1411,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"DSD Sig is present neither in Flash nor User provided Input.."); up(&Adapter->NVMRdmWrmLock); - bcm_kfree(pReadData); + kfree(pReadData); return Status; } } @@ -1608,7 +1428,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) if(Status != STATUS_SUCCESS) { - bcm_kfree(pReadData); + kfree(pReadData); return Status; } } @@ -1616,7 +1436,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, " timetaken by Write/read :%ld msec\n",(tv1.tv_sec - tv0.tv_sec)*1000 +(tv1.tv_usec - tv0.tv_usec)/1000); - bcm_kfree(pReadData); + kfree(pReadData); Status = STATUS_SUCCESS; } break; @@ -1629,7 +1449,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) UINT BuffSize = 0; UINT ReadBytes = 0; UINT ReadOffset = 0; - char __user *OutPutBuff = NULL; + void __user *OutPutBuff; if(IsFlash2x(Adapter) != TRUE) { @@ -1638,20 +1458,12 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) } BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_FLASH2X_SECTION_READ Called"); - Status = copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) return -EFAULT; - } //Reading FLASH 2.x READ structure - Status = copy_from_user(&sFlash2xRead, IoBuffer.InputBuffer,sizeof(FLASH2X_READWRITE)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of Input Buffer failed"); + if (copy_from_user(&sFlash2xRead, IoBuffer.InputBuffer,sizeof(FLASH2X_READWRITE))) return -EFAULT; - } BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.Section :%x" ,sFlash2xRead.Section); @@ -1687,7 +1499,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n"); up(&Adapter->NVMRdmWrmLock); - bcm_kfree(pReadBuff); + kfree(pReadBuff); return -EACCES; } @@ -1715,7 +1527,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) if(Status) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Copy to use failed with status :%d", Status); - Status = -EFAULT; break; } NOB = NOB - ReadBytes; @@ -1727,15 +1538,15 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) } up(&Adapter->NVMRdmWrmLock); - bcm_kfree(pReadBuff); + kfree(pReadBuff); } break ; case IOCTL_BCM_FLASH2X_SECTION_WRITE : { FLASH2X_READWRITE sFlash2xWrite = {0}; - PUCHAR pWriteBuff = NULL; - void __user *InputAddr = NULL; + PUCHAR pWriteBuff; + void __user *InputAddr; UINT NOB = 0; UINT BuffSize = 0; UINT WriteOffset = 0; @@ -1752,33 +1563,17 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, " IOCTL_BCM_FLASH2X_SECTION_WRITE Called"); - Status = copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) return -EFAULT; - } //Reading FLASH 2.x READ structure - Status = copy_from_user(&sFlash2xWrite, IoBuffer.InputBuffer, sizeof(FLASH2X_READWRITE)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Reading of output Buffer from IOCTL buffer fails"); + if (copy_from_user(&sFlash2xWrite, IoBuffer.InputBuffer, sizeof(FLASH2X_READWRITE))) return -EFAULT; - } BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.Section :%x" ,sFlash2xWrite.Section); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.offset :%d" ,sFlash2xWrite.offset); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.numOfBytes :%x" ,sFlash2xWrite.numOfBytes); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.bVerify :%x\n" ,sFlash2xWrite.bVerify); - #if 0 - if((sFlash2xWrite.Section == ISO_IMAGE1) ||(sFlash2xWrite.Section == ISO_IMAGE2) || - (sFlash2xWrite.Section == DSD0) || (sFlash2xWrite.Section == DSD1) || (sFlash2xWrite.Section == DSD2)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"ISO/DSD Image write is not allowed.... "); - return STATUS_FAILURE ; - } - #endif if((sFlash2xWrite.Section != VSA0) && (sFlash2xWrite.Section != VSA1) && (sFlash2xWrite.Section != VSA2) ) { @@ -1798,12 +1593,10 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) else BuffSize = NOB ; - pWriteBuff = (PCHAR)kmalloc(BuffSize, GFP_KERNEL); + pWriteBuff = kmalloc(BuffSize, GFP_KERNEL); if(pWriteBuff == NULL) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Memory allocation failed for Flash 2.x Read Structure"); return -ENOMEM; - } + //extracting the remainder of the given offset. WriteBytes = Adapter->uiSectorSize ; @@ -1820,7 +1613,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n"); up(&Adapter->NVMRdmWrmLock); - bcm_kfree(pWriteBuff); + kfree(pWriteBuff); return -EACCES; } @@ -1831,7 +1624,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) if(Status) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Copy to user failed with status :%d", Status); - Status = -EFAULT; break ; } BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,pWriteBuff,WriteBytes); @@ -1859,28 +1651,22 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) } while(NOB > 0); BcmFlash2xWriteSig(Adapter,sFlash2xWrite.Section); up(&Adapter->NVMRdmWrmLock); - bcm_kfree(pWriteBuff); + kfree(pWriteBuff); } break ; case IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP : { - PFLASH2X_BITMAP psFlash2xBitMap = NULL ; + PFLASH2X_BITMAP psFlash2xBitMap; BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP Called"); - Status = copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) return -EFAULT; - } + if(IoBuffer.OutputLength != sizeof(FLASH2X_BITMAP)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Structure size mismatch Lib :0x%lx Driver :0x%zx ",IoBuffer.OutputLength, sizeof(FLASH2X_BITMAP)); - break; - } + return -EINVAL; - psFlash2xBitMap = (PFLASH2X_BITMAP)kzalloc(sizeof(FLASH2X_BITMAP), GFP_KERNEL); + psFlash2xBitMap = kzalloc(sizeof(FLASH2X_BITMAP), GFP_KERNEL); if(psFlash2xBitMap == NULL) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Memory is not available"); @@ -1895,20 +1681,16 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n"); up(&Adapter->NVMRdmWrmLock); - bcm_kfree(psFlash2xBitMap); + kfree(psFlash2xBitMap); return -EACCES; } BcmGetFlash2xSectionalBitMap(Adapter, psFlash2xBitMap); up(&Adapter->NVMRdmWrmLock); - Status = copy_to_user(IoBuffer.OutputBuffer, psFlash2xBitMap, sizeof(FLASH2X_BITMAP)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "copying Flash2x bitMap failed"); - bcm_kfree(psFlash2xBitMap); - return -EFAULT; - } - bcm_kfree(psFlash2xBitMap); + if (copy_to_user(IoBuffer.OutputBuffer, psFlash2xBitMap, sizeof(FLASH2X_BITMAP))) + Status = -EFAULT; + + kfree(psFlash2xBitMap); } break ; case IOCTL_BCM_SET_ACTIVE_SECTION : @@ -1926,14 +1708,14 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) if(Status) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); - return -EFAULT; + return Status; } Status = copy_from_user(&eFlash2xSectionVal,IoBuffer.InputBuffer, sizeof(INT)); if(Status) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of flash section val failed"); - return -EFAULT; + return Status; } down(&Adapter->NVMRdmWrmLock); @@ -1961,29 +1743,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Adapter->bAllDSDWriteAllow = FALSE ; BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"IOCTL_BCM_IDENTIFY_ACTIVE_SECTION called"); - #if 0 - SECTION_TYPE section = 0 ; - - - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_IDENTIFY_ACTIVE_SECTION Called"); - Status = copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Copy of IOCTL BUFFER failed"); - return -EFAULT; - } - Status = copy_from_user((PCHAR)section,(PCHAR)&IoBuffer, sizeof(INT)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Copy of section type failed failed"); - return -EFAULT; - } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Read Section :%d", section); - if(section == DSD) - Adapter->ulFlashCalStart = Adapter->uiActiveDSDOffsetAtFwDld ; - else - Status = STATUS_FAILURE ; - #endif Status = STATUS_SUCCESS ; } break ; @@ -2004,14 +1763,14 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) if(Status) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed Status :%d", Status); - return -EFAULT; + return Status; } - Status = copy_from_user(&sCopySectStrut,IoBuffer.InputBuffer, sizeof(FLASH2X_COPY_SECTION)); + Status = copy_from_user(&sCopySectStrut, IoBuffer.InputBuffer, sizeof(FLASH2X_COPY_SECTION)); if(Status) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of Copy_Section_Struct failed with Status :%d", Status); - return -EFAULT; + return Status; } BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Source SEction :%x", sCopySectStrut.SrcSection); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Destination SEction :%x", sCopySectStrut.DstSection); @@ -2082,7 +1841,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) if(Status) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); - Status = -EFAULT; break; } if(Adapter->eNVMType != NVM_FLASH) @@ -2095,35 +1853,18 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { if(IoBuffer.OutputLength < sizeof(FLASH2X_CS_INFO)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0," Passed buffer size:0x%lX is insufficient for the CS structure.. \nRequired size :0x%zx ",IoBuffer.OutputLength, sizeof(FLASH2X_CS_INFO)); - Status = -EINVAL; - break; - } + return -EINVAL; - Status = copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlash2xCSInfo, sizeof(FLASH2X_CS_INFO)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "copying Flash2x cs info failed"); - Status = -EFAULT; - break; - } + if (copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlash2xCSInfo, sizeof(FLASH2X_CS_INFO))) + return -EFAULT; } else { if(IoBuffer.OutputLength < sizeof(FLASH_CS_INFO)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0," Passed buffer size:0x%lX is insufficient for the CS structure.. Required size :0x%zx ",IoBuffer.OutputLength, sizeof(FLASH_CS_INFO)); - Status = -EINVAL; - break; - } - Status = copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlashCSInfo, sizeof(FLASH_CS_INFO)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "copying Flash CS info failed"); - Status = -EFAULT; - break; - } + return -EINVAL; + + if (copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlashCSInfo, sizeof(FLASH_CS_INFO))) + return -EFAULT; } } @@ -2145,13 +1886,13 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) if(Status) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); - return -EFAULT; + return Status; } - Status = copy_from_user(&eFlash2xSectionVal,IoBuffer.InputBuffer, sizeof(INT)); + Status = copy_from_user(&eFlash2xSectionVal, IoBuffer.InputBuffer, sizeof(INT)); if(Status) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of flash section val failed"); - return -EFAULT; + return Status; } BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Read Section :%d", eFlash2xSectionVal); @@ -2181,13 +1922,13 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) case IOCTL_BCM_NVM_RAW_READ : { - NVM_READWRITE stNVMRead = {}; + NVM_READWRITE stNVMRead; INT NOB ; INT BuffSize ; INT ReadOffset = 0; UINT ReadBytes = 0 ; - PUCHAR pReadBuff = NULL ; - char __user *OutPutBuff = NULL ; + PUCHAR pReadBuff; + void __user *OutPutBuff; if(Adapter->eNVMType != NVM_FLASH) { @@ -2204,10 +1945,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) } if(copy_from_user(&stNVMRead, IoBuffer.OutputBuffer,sizeof(NVM_READWRITE))) - { - Status = -EFAULT; - break; - } + return -EFAULT; NOB = stNVMRead.uiNumBytes; //In Raw-Read max Buff size : 64MB @@ -2217,11 +1955,10 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) else BuffSize = NOB ; - ReadOffset = stNVMRead.uiOffset ; + ReadOffset = stNVMRead.uiOffset; OutPutBuff = stNVMRead.pBuffer; - - pReadBuff = (PCHAR)kzalloc(BuffSize , GFP_KERNEL); + pReadBuff = kzalloc(BuffSize , GFP_KERNEL); if(pReadBuff == NULL) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Memory allocation failed for Flash 2.x Read Structure"); @@ -2235,7 +1972,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) (Adapter->bPreparingForLowPowerMode ==TRUE)) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n"); - bcm_kfree(pReadBuff); + kfree(pReadBuff); up(&Adapter->NVMRdmWrmLock); return -EACCES; } @@ -2256,13 +1993,12 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) break; } - BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,pReadBuff, ReadBytes); + BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,pReadBuff,ReadBytes); Status = copy_to_user(OutPutBuff, pReadBuff,ReadBytes); if(Status) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Copy to use failed with status :%d", Status); - Status = -EFAULT; break; } NOB = NOB - ReadBytes; @@ -2275,7 +2011,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) } Adapter->bFlashRawRead = FALSE ; up(&Adapter->NVMRdmWrmLock); - bcm_kfree(pReadBuff); + kfree(pReadBuff); break ; } @@ -2288,7 +2024,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) if(Status) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"copy of Ioctl buffer is failed from user space"); - Status = -EFAULT; break; } @@ -2296,7 +2031,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) if(Status) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"copy of control bit mask failed from user space"); - Status = -EFAULT; break; } BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\n Got user defined cntrl msg bit mask :%lx", RxCntrlMsgBitMask); @@ -2315,71 +2049,44 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) DevInfo.u32NVMType = Adapter->eNVMType; DevInfo.u32InterfaceType = BCM_USB; - Status = copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); - Status = -EFAULT; - break; - } + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + if(IoBuffer.OutputLength < sizeof(DevInfo)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"User Passed buffer length is less than actural buffer size"); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"user passed buffer size :0x%lX, expected size :0x%zx",IoBuffer.OutputLength, sizeof(DevInfo)); - Status = -EINVAL; - break; - } - Status = copy_to_user(IoBuffer.OutputBuffer, &DevInfo, sizeof(DevInfo)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"copying Dev info structure to user space buffer failed"); - Status = -EFAULT; - break; - } + return -EINVAL; + + if (copy_to_user(IoBuffer.OutputBuffer, &DevInfo, sizeof(DevInfo))) + return -EFAULT; } break ; case IOCTL_BCM_TIME_SINCE_NET_ENTRY: { ST_TIME_ELAPSED stTimeElapsedSinceNetEntry = {0}; - struct timeval tv = {0} ; BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"IOCTL_BCM_TIME_SINCE_NET_ENTRY called"); - Status = copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); - Status = -EFAULT; - break; - } + if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) + return -EFAULT; + if(IoBuffer.OutputLength < sizeof(ST_TIME_ELAPSED)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"User Passed buffer length:0x%lx is less than expected buff size :0x%zX",IoBuffer.OutputLength,sizeof(ST_TIME_ELAPSED)); - Status = -EINVAL; - break; - } + return -EINVAL; - //stTimeElapsedSinceNetEntry.ul64TimeElapsedSinceNetEntry = Adapter->liTimeSinceLastNetEntry; - do_gettimeofday(&tv); - stTimeElapsedSinceNetEntry.ul64TimeElapsedSinceNetEntry = tv.tv_sec - Adapter->liTimeSinceLastNetEntry; + stTimeElapsedSinceNetEntry.ul64TimeElapsedSinceNetEntry = get_seconds() - Adapter->liTimeSinceLastNetEntry; - Status = copy_to_user(IoBuffer.OutputBuffer, &stTimeElapsedSinceNetEntry, sizeof(ST_TIME_ELAPSED)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"copying ST_TIME_ELAPSED structure to user space buffer failed"); - Status = -EFAULT; - break; - } + if (copy_to_user(IoBuffer.OutputBuffer, &stTimeElapsedSinceNetEntry, sizeof(ST_TIME_ELAPSED))) + return -EFAULT; } break; - default: - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "wrong input %x",cmd); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "In default ioctl %d\n", cmd); - Status = STATUS_FAILURE; + case IOCTL_CLOSE_NOTIFICATION: + BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"IOCTL_CLOSE_NOTIFICATION"); + break; + default: + pr_info(DRV_NAME ": unknown ioctl cmd=%#x\n", cmd); + Status = STATUS_FAILURE; break; } return Status; @@ -2395,59 +2102,37 @@ static struct file_operations bcm_fops = { .llseek = no_llseek, }; +extern struct class *bcm_class; int register_control_device_interface(PMINI_ADAPTER Adapter) { + if(Adapter->major>0) - return Adapter->major; - Adapter->major = register_chrdev(0, "tarang", &bcm_fops); - if(Adapter->major < 0) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "register_chrdev:Failed to registering WiMax control char device!"); - return Adapter->major; - } - - bcm_class = NULL; - bcm_class = class_create (THIS_MODULE, "tarang"); - if(IS_ERR (bcm_class)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Unable to create class\n"); - unregister_chrdev(Adapter->major, "tarang"); - Adapter->major = 0; - return -ENODEV; + return Adapter->major; + + Adapter->major = register_chrdev(0, DEV_NAME, &bcm_fops); + if(Adapter->major < 0) { + pr_err(DRV_NAME ": could not created character device\n"); + return Adapter->major; } + Adapter->pstCreatedClassDevice = device_create (bcm_class, NULL, - MKDEV(Adapter->major, 0), -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26) - NULL , -#endif - "tarang"); + MKDEV(Adapter->major, 0), Adapter, + DEV_NAME); - if(IS_ERR(Adapter->pstCreatedClassDevice)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "class device did not get created : %ld", PTR_ERR(Adapter->pstCreatedClassDevice) ); + if(IS_ERR(Adapter->pstCreatedClassDevice)) { + pr_err(DRV_NAME ": class device create failed\n"); + unregister_chrdev(Adapter->major, DEV_NAME); + return PTR_ERR(Adapter->pstCreatedClassDevice); } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Got Major No: %d", Adapter->major); - return 0; + + return 0; } void unregister_control_device_interface(PMINI_ADAPTER Adapter) { - if(Adapter->major > 0) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "destroying class device"); + if(Adapter->major > 0) { device_destroy (bcm_class, MKDEV(Adapter->major, 0)); + unregister_chrdev(Adapter->major, DEV_NAME); } - if(!IS_ERR(bcm_class)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "destroying created class "); - class_destroy (bcm_class); - bcm_class = NULL; - } - if(Adapter->major > 0) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"unregistering character interface"); - unregister_chrdev(Adapter->major, "tarang"); - } - } diff --git a/drivers/staging/bcm/Bcmnet.c b/drivers/staging/bcm/Bcmnet.c index bc2969821421..a6ce2396c791 100644 --- a/drivers/staging/bcm/Bcmnet.c +++ b/drivers/staging/bcm/Bcmnet.c @@ -1,264 +1,238 @@ #include "headers.h" -static INT bcm_notify_event(struct notifier_block *nb, ULONG event, PVOID dev) +struct net_device *gblpnetdev; + +static INT bcm_open(struct net_device *dev) { - struct net_device *ndev = (struct net_device*)dev; - PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); - //PMINI_ADAPTER Adapter = (PMINI_ADAPTER)ndev->priv; - if(strncmp(ndev->name,gblpnetdev->name,5)==0) - { - switch(event) - { - case NETDEV_CHANGEADDR: - case NETDEV_GOING_DOWN: - /*ignore this */ - break; - case NETDEV_DOWN: - break; - - case NETDEV_UP: - break; - - case NETDEV_REGISTER: - /* Increment the Reference Count for "veth0" */ - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Register RefCount: %x\n", - netdev_refcnt_read(ndev)); - dev_hold(ndev); - break; - - case NETDEV_UNREGISTER: - /* Decrement the Reference Count for "veth0" */ - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Unregister RefCnt: %x\n", - netdev_refcnt_read(ndev)); - dev_put(ndev); - break; - }; + PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev); + + if (Adapter->fw_download_done == FALSE) { + pr_notice(PFX "%s: link up failed (download in progress)\n", + dev->name); + return -EBUSY; } - return NOTIFY_DONE; -} -/* Notifier block to receive netdevice events */ -static struct notifier_block bcm_notifier_block = -{ - .notifier_call = bcm_notify_event, -}; + if (netif_msg_ifup(Adapter)) + pr_info(PFX "%s: enabling interface\n", dev->name); -struct net_device *gblpnetdev; -/***************************************************************************************/ -/* proto-type of lower function */ -#ifdef BCM_SHM_INTERFACE -const char *bcmVirtDeviceName="bcmeth"; -#endif + if (Adapter->LinkUpStatus) { + if (netif_msg_link(Adapter)) + pr_info(PFX "%s: link up\n", dev->name); -static INT bcm_open(struct net_device *dev) -{ - PMINI_ADAPTER Adapter = NULL ; //(PMINI_ADAPTER)dev->priv; - Adapter = GET_BCM_ADAPTER(dev); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "======>"); - if(Adapter->fw_download_done==FALSE) - return -EINVAL; - Adapter->if_up=1; - if(Adapter->LinkUpStatus == 1){ - if(netif_queue_stopped(Adapter->dev)){ - netif_carrier_on(Adapter->dev); - netif_start_queue(Adapter->dev); - } + netif_carrier_on(Adapter->dev); + netif_start_queue(Adapter->dev); } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "<======"); - return 0; + return 0; } static INT bcm_close(struct net_device *dev) { - PMINI_ADAPTER Adapter = NULL ;//gpadapter ; - Adapter = GET_BCM_ADAPTER(dev); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "=====>"); - Adapter->if_up=0; - if(!netif_queue_stopped(dev)) { - netif_carrier_off(dev); - netif_stop_queue(dev); - } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"<====="); - return 0; + PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev); + + if (netif_msg_ifdown(Adapter)) + pr_info(PFX "%s: disabling interface\n", dev->name); + + netif_carrier_off(dev); + netif_stop_queue(dev); + + return 0; +} + +static u16 bcm_select_queue(struct net_device *dev, struct sk_buff *skb) +{ + return ClassifyPacket(netdev_priv(dev), skb); } -static struct net_device_stats *bcm_get_stats(struct net_device *dev) +/******************************************************************* +* Function - bcm_transmit() +* +* Description - This is the main transmit function for our virtual +* interface(eth0). It handles the ARP packets. It +* clones this packet and then Queue it to a suitable +* Queue. Then calls the transmit_packet(). +* +* Parameter - skb - Pointer to the socket buffer structure +* dev - Pointer to the virtual net device structure +* +*********************************************************************/ + +static netdev_tx_t bcm_transmit(struct sk_buff *skb, struct net_device *dev) { - PLINUX_DEP_DATA pLinuxData=NULL; - PMINI_ADAPTER Adapter = NULL ;// gpadapter ; - Adapter = GET_BCM_ADAPTER(dev); - pLinuxData = (PLINUX_DEP_DATA)(Adapter->pvOsDepData); - - //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Dev = %p, pLinuxData = %p", dev, pLinuxData); - pLinuxData->netstats.rx_packets=atomic_read(&Adapter->RxRollOverCount)*64*1024+Adapter->PrevNumRecvDescs; - pLinuxData->netstats.rx_bytes=atomic_read(&Adapter->GoodRxByteCount)+atomic_read(&Adapter->BadRxByteCount); - pLinuxData->netstats.rx_dropped=atomic_read(&Adapter->RxPacketDroppedCount); - pLinuxData->netstats.rx_errors=atomic_read(&Adapter->RxPacketDroppedCount); - pLinuxData->netstats.rx_length_errors=0; - pLinuxData->netstats.rx_frame_errors=0; - pLinuxData->netstats.rx_crc_errors=0; - pLinuxData->netstats.tx_bytes=atomic_read(&Adapter->GoodTxByteCount); - pLinuxData->netstats.tx_packets=atomic_read(&Adapter->TxTotalPacketCount); - pLinuxData->netstats.tx_dropped=atomic_read(&Adapter->TxDroppedPacketCount); - - return &(pLinuxData->netstats); + PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev); + u16 qindex = skb_get_queue_mapping(skb); + + + if (Adapter->device_removed || !Adapter->LinkUpStatus) + goto drop; + + if (Adapter->TransferMode != IP_PACKET_ONLY_MODE) + goto drop; + + if (INVALID_QUEUE_INDEX == qindex) + goto drop; + + if (Adapter->PackInfo[qindex].uiCurrentPacketsOnHost >= + SF_MAX_ALLOWED_PACKETS_TO_BACKUP) + return NETDEV_TX_BUSY; + + /* Now Enqueue the packet */ + if (netif_msg_tx_queued(Adapter)) + pr_info(PFX "%s: enqueueing packet to queue %d\n", + dev->name, qindex); + + spin_lock(&Adapter->PackInfo[qindex].SFQueueLock); + Adapter->PackInfo[qindex].uiCurrentBytesOnHost += skb->len; + Adapter->PackInfo[qindex].uiCurrentPacketsOnHost++; + + *((B_UINT32 *) skb->cb + SKB_CB_LATENCY_OFFSET) = jiffies; + ENQUEUEPACKET(Adapter->PackInfo[qindex].FirstTxQueue, + Adapter->PackInfo[qindex].LastTxQueue, skb); + atomic_inc(&Adapter->TotalPacketCount); + spin_unlock(&Adapter->PackInfo[qindex].SFQueueLock); + + /* FIXME - this is racy and incorrect, replace with work queue */ + if (!atomic_read(&Adapter->TxPktAvail)) { + atomic_set(&Adapter->TxPktAvail, 1); + wake_up(&Adapter->tx_packet_wait_queue); + } + return NETDEV_TX_OK; + + drop: + dev_kfree_skb(skb); + return NETDEV_TX_OK; } + + + /** @ingroup init_functions Register other driver entry points with the kernel */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) -static struct net_device_ops bcmNetDevOps = { +static const struct net_device_ops bcmNetDevOps = { .ndo_open = bcm_open, .ndo_stop = bcm_close, - .ndo_get_stats = bcm_get_stats, .ndo_start_xmit = bcm_transmit, .ndo_change_mtu = eth_change_mtu, .ndo_set_mac_address = eth_mac_addr, .ndo_validate_addr = eth_validate_addr, + .ndo_select_queue = bcm_select_queue, }; -#endif -int register_networkdev(PMINI_ADAPTER Adapter) +static struct device_type wimax_type = { + .name = "wimax", +}; + +static int bcm_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) { - int result=0; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) - void **temp = NULL; /* actually we're *allocating* the device in alloc_etherdev */ -#endif - Adapter->dev = alloc_etherdev(sizeof(PMINI_ADAPTER)); - if(!Adapter->dev) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "ERR: No Dev"); - return -ENOMEM; - } - gblpnetdev = Adapter->dev; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) - Adapter->dev->priv = Adapter; -#else - temp = netdev_priv(Adapter->dev); - *temp = (void *)Adapter; -#endif - //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "init adapterptr: %x %x\n", (UINT)Adapter, temp); - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) - Adapter->dev->netdev_ops = &bcmNetDevOps; -#else - Adapter->dev->open = bcm_open; - Adapter->dev->stop = bcm_close; - Adapter->dev->get_stats = bcm_get_stats; - Adapter->dev->hard_start_xmit = bcm_transmit; - Adapter->dev->hard_header_len = ETH_HLEN + LEADER_SIZE; -#endif - -#ifndef BCM_SHM_INTERFACE - Adapter->dev->mtu = MTU_SIZE; /* 1400 Bytes */ - /* Read the MAC Address from EEPROM */ - ReadMacAddressFromNVM(Adapter); + cmd->supported = 0; + cmd->advertising = 0; + cmd->speed = SPEED_10000; + cmd->duplex = DUPLEX_FULL; + cmd->port = PORT_TP; + cmd->phy_address = 0; + cmd->transceiver = XCVR_INTERNAL; + cmd->autoneg = AUTONEG_DISABLE; + cmd->maxtxpkt = 0; + cmd->maxrxpkt = 0; + return 0; +} +static void bcm_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) +{ + PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev); + PS_INTERFACE_ADAPTER psIntfAdapter = Adapter->pvInterfaceAdapter; + struct usb_device *udev = interface_to_usbdev(psIntfAdapter->interface); - /* Register the notifier block for getting netdevice events */ - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Registering netdevice notifier\n"); - result = register_netdevice_notifier(&bcm_notifier_block); - if(result) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "BCM Notifier Block did not get registered"); - Adapter->bNetdeviceNotifierRegistered = FALSE; - return result; - } - else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "BCM Notifier got Registered"); - Adapter->bNetdeviceNotifierRegistered = TRUE; - } + strcpy(info->driver, DRV_NAME); + strcpy(info->version, DRV_VERSION); + snprintf(info->fw_version, sizeof(info->fw_version), "%u.%u", + Adapter->uiFlashLayoutMajorVersion, + Adapter->uiFlashLayoutMinorVersion); -#else - - Adapter->dev->mtu = CPE_MTU_SIZE; - -#if 0 - //for CPE - harcode the virtual mac address - Adapter->dev->dev_addr[0] = MII_WIMAX_MACADDRESS[0]; - Adapter->dev->dev_addr[1] = MII_WIMAX_MACADDRESS[1]; - Adapter->dev->dev_addr[2] = MII_WIMAX_MACADDRESS[2]; - Adapter->dev->dev_addr[3] = MII_WIMAX_MACADDRESS[3]; - Adapter->dev->dev_addr[4] = MII_WIMAX_MACADDRESS[4]; - Adapter->dev->dev_addr[5] = MII_WIMAX_MACADDRESS[5]; -#else - ReadMacAddressFromNVM(Adapter); -#endif - strcpy(Adapter->dev->name, bcmVirtDeviceName); //Copy the device name - -#endif - - result = register_netdev(Adapter->dev); - if (!result) - { - Adapter->bNetworkInterfaceRegistered = TRUE ; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Beceem Network device name is %s!", Adapter->dev->name); - } - else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Network device can not be registered!"); - Adapter->bNetworkInterfaceRegistered = FALSE ; - return result; - } + usb_make_path(udev, info->bus_info, sizeof(info->bus_info)); +} -#if 0 - Adapter->stDebugState.debug_level = DBG_LVL_CURR; - Adapter->stDebugState.type =(UINT)0xffffffff; - Adapter->stDebugState.subtype[DBG_TYPE_OTHERS] = 0xffffffff; - Adapter->stDebugState.subtype[DBG_TYPE_RX] = 0xffffffff; - Adapter->stDebugState.subtype[DBG_TYPE_TX] = 0xffffffff; - Adapter->stDebugState.subtype[DBG_TYPE_INITEXIT] = 0xffffffff; +static u32 bcm_get_link(struct net_device *dev) +{ + PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev); - printk("-------ps_adapter->stDebugState.type=%x\n",Adapter->stDebugState.type); - printk("-------ps_adapter->stDebugState.subtype[DBG_TYPE_OTHERS]=%x\n",Adapter->stDebugState.subtype[DBG_TYPE_OTHERS]); - printk("-------ps_adapter->stDebugState.subtype[DBG_TYPE_RX]=%x\n",Adapter->stDebugState.subtype[DBG_TYPE_RX]); - printk("-------ps_adapter->stDebugState.subtype[DBG_TYPE_TX]=%x\n",Adapter->stDebugState.subtype[DBG_TYPE_TX]); -#endif + return Adapter->LinkUpStatus; +} - return 0; +static u32 bcm_get_msglevel (struct net_device *dev) +{ + PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev); + + return Adapter->msg_enable; } -void bcm_unregister_networkdev(PMINI_ADAPTER Adapter) +static void bcm_set_msglevel (struct net_device *dev, u32 level) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Unregistering the Net Dev...\n"); - if(Adapter->dev && !IS_ERR(Adapter->dev) && Adapter->bNetworkInterfaceRegistered) - unregister_netdev(Adapter->dev); - /* Unregister the notifier block */ - if(Adapter->bNetdeviceNotifierRegistered == TRUE) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Unregistering netdevice notifier\n"); - unregister_netdevice_notifier(&bcm_notifier_block); - } + PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev); + + Adapter->msg_enable = level; } -static int bcm_init(void) +static const struct ethtool_ops bcm_ethtool_ops = { + .get_settings = bcm_get_settings, + .get_drvinfo = bcm_get_drvinfo, + .get_link = bcm_get_link, + .get_msglevel = bcm_get_msglevel, + .set_msglevel = bcm_set_msglevel, +}; + +int register_networkdev(PMINI_ADAPTER Adapter) { + struct net_device *net = Adapter->dev; + PS_INTERFACE_ADAPTER IntfAdapter = Adapter->pvInterfaceAdapter; + struct usb_interface *udev = IntfAdapter->interface; + struct usb_device *xdev = IntfAdapter->udev; + int result; - result = InterfaceInitialize(); - if(result) - { - printk("Initialisation failed for usbbcm"); - } - else - { - printk("Initialised usbbcm"); + + net->netdev_ops = &bcmNetDevOps; + net->ethtool_ops = &bcm_ethtool_ops; + net->mtu = MTU_SIZE; /* 1400 Bytes */ + net->tx_queue_len = TX_QLEN; + net->flags |= IFF_NOARP; + + netif_carrier_off(net); + + SET_NETDEV_DEVTYPE(net, &wimax_type); + + /* Read the MAC Address from EEPROM */ + result = ReadMacAddressFromNVM(Adapter); + if (result != STATUS_SUCCESS) { + dev_err(&udev->dev, + PFX "Error in Reading the mac Address: %d", result); + return -EIO; } - return result; -} + result = register_netdev(net); + if (result) + return result; -static void bcm_exit(void) -{ - printk("%s %s Calling InterfaceExit\n",__FILE__, __FUNCTION__); - InterfaceExit(); - printk("%s %s InterfaceExit returned\n",__FILE__, __FUNCTION__); -} + gblpnetdev = Adapter->dev; -module_init(bcm_init); -module_exit(bcm_exit); -MODULE_LICENSE ("GPL"); + if (netif_msg_probe(Adapter)) + dev_info(&udev->dev, PFX "%s: register usb-%s-%s %pM\n", + net->name, xdev->bus->bus_name, xdev->devpath, + net->dev_addr); + return 0; +} +void unregister_networkdev(PMINI_ADAPTER Adapter) +{ + struct net_device *net = Adapter->dev; + PS_INTERFACE_ADAPTER IntfAdapter = Adapter->pvInterfaceAdapter; + struct usb_interface *udev = IntfAdapter->interface; + struct usb_device *xdev = IntfAdapter->udev; + + if (netif_msg_probe(Adapter)) + dev_info(&udev->dev, PFX "%s: unregister usb-%s%s\n", + net->name, xdev->bus->bus_name, xdev->devpath); + + unregister_netdev(Adapter->dev); +} diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index 6f388a374ddc..5ac45820d564 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -15,6 +15,7 @@ typedef enum _E_CLASSIFIER_ACTION eDeleteClassifier }E_CLASSIFIER_ACTION; +static ULONG GetNextTargetBufferLocation(PMINI_ADAPTER Adapter,B_UINT16 tid); /************************************************************ * Function - SearchSfid @@ -28,7 +29,7 @@ typedef enum _E_CLASSIFIER_ACTION * Returns - Queue index for this SFID(If matched) Else Invalid Queue Index(If Not matched) ************************************************************/ -__inline INT SearchSfid(PMINI_ADAPTER Adapter,UINT uiSfid) +INT SearchSfid(PMINI_ADAPTER Adapter,UINT uiSfid) { INT iIndex=0; for(iIndex=(NO_OF_QUEUES-1); iIndex>=0; iIndex--) @@ -47,26 +48,16 @@ __inline INT SearchSfid(PMINI_ADAPTER Adapter,UINT uiSfid) * Returns - Queue index for the free SFID * Else returns Invalid Index. ****************************************************************/ -__inline INT SearchFreeSfid(PMINI_ADAPTER Adapter) +static INT SearchFreeSfid(PMINI_ADAPTER Adapter) { UINT uiIndex=0; + for(uiIndex=0; uiIndex < (NO_OF_QUEUES-1); uiIndex++) if(Adapter->PackInfo[uiIndex].ulSFID==0) return uiIndex; return NO_OF_QUEUES+1; } -__inline int SearchVcid(PMINI_ADAPTER Adapter,unsigned short usVcid) -{ - int iIndex=0; - for(iIndex=(NO_OF_QUEUES-1);iIndex>=0;iIndex--) - if(Adapter->PackInfo[iIndex].usVCID_Value == usVcid) - return iIndex; - return NO_OF_QUEUES+1; - -} - - /* Function: SearchClsid Description: This routinue would search Classifier having specified ClassifierID as input parameter @@ -76,7 +67,7 @@ Input parameters: PMINI_ADAPTER Adapter - Adapter Context Return: int :Classifier table index of matching entry */ -__inline int SearchClsid(PMINI_ADAPTER Adapter,ULONG ulSFID,B_UINT16 uiClassifierID) +static int SearchClsid(PMINI_ADAPTER Adapter,ULONG ulSFID,B_UINT16 uiClassifierID) { unsigned int uiClassifierIndex = 0; for(uiClassifierIndex=0;uiClassifierIndex<MAX_CLASSIFIERS;uiClassifierIndex++) @@ -94,7 +85,7 @@ __inline int SearchClsid(PMINI_ADAPTER Adapter,ULONG ulSFID,B_UINT16 uiClassifi This routinue would search Free available Classifier entry in classifier table. @return free Classifier Entry index in classifier table for specified SF */ -static __inline int SearchFreeClsid(PMINI_ADAPTER Adapter /**Adapter Context*/ +static int SearchFreeClsid(PMINI_ADAPTER Adapter /**Adapter Context*/ ) { unsigned int uiClassifierIndex = 0; @@ -106,7 +97,7 @@ static __inline int SearchFreeClsid(PMINI_ADAPTER Adapter /**Adapter Context*/ return MAX_CLASSIFIERS+1; } -VOID deleteSFBySfid(PMINI_ADAPTER Adapter, UINT uiSearchRuleIndex) +static VOID deleteSFBySfid(PMINI_ADAPTER Adapter, UINT uiSearchRuleIndex) { //deleting all the packet held in the SF flush_queue(Adapter,uiSearchRuleIndex); @@ -985,7 +976,7 @@ static VOID CopyToAdapter( register PMINI_ADAPTER Adapter, /**<Pointer to the A if(Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication) { - bcm_kfree(Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication); + kfree(Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication); Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication = NULL; } Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication = pstAddIndication; @@ -1061,12 +1052,6 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) pstAddIndication->sfAuthorizedSet.u32MaxTrafficBurst); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MinReservedTrafficRate : 0x%X", pstAddIndication->sfAuthorizedSet.u32MinReservedTrafficRate); -#if 0 - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MinimumTolerableTrafficRate : 0x%X", - pstAddIndication->sfAuthorizedSet.u32MinimumTolerableTrafficRate); - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32RequesttransmissionPolicy : 0x%X", - pstAddIndication->sfAuthorizedSet.u32RequesttransmissionPolicy); -#endif BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParamLength : 0x%X", pstAddIndication->sfAuthorizedSet.u8VendorSpecificQoSParamLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParam : 0x%X", @@ -1114,13 +1099,6 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) pstAddIndication->sfAuthorizedSet.u8PagingPreference); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16UnsolicitedPollingInterval : 0x%X", pstAddIndication->sfAuthorizedSet.u16UnsolicitedPollingInterval); -#if 0 - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "MBSZoneIdentifierassignmentLength : 0x%X", - pstAddIndication->sfAuthorizedSet.MBSZoneIdentifierassignmentLength); - for(uiLoopIndex=0; uiLoopIndex < MAX_STRING_LEN; uiLoopIndex++) - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "MBSZoneIdentifierassignment : 0x%X", - pstAddIndication->sfAuthorizedSet.MBSZoneIdentifierassignment[uiLoopIndex]); -#endif BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "sfAuthorizedSet.u8HARQChannelMapping %x %x %x ", *(unsigned int*)pstAddIndication->sfAuthorizedSet.u8HARQChannelMapping, @@ -1158,11 +1136,6 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) psfCSType->cCPacketClassificationRule.u8IPTypeOfService[0], psfCSType->cCPacketClassificationRule.u8IPTypeOfService[1], psfCSType->cCPacketClassificationRule.u8IPTypeOfService[2]); -#if 0 - - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u8ProtocolLength :0x%X ", - psfCSType->cCPacketClassificationRule.u8ProtocolLength); -#endif for(uiLoopIndex=0; uiLoopIndex < 1; uiLoopIndex++) BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Protocol : 0x%02X ", @@ -1278,14 +1251,6 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) pstAddIndication->sfAdmittedSet.u8QosParamSet); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficPriority : 0x%02X", pstAddIndication->sfAdmittedSet.u8TrafficPriority); -#if 0 - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32MaxSustainedTrafficRate : 0x%02X", - ntohl(pstAddIndication->sfAdmittedSet.u32MaxSustainedTrafficRate)); - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32MinimumTolerableTrafficRate : 0x%X", - pstAddIndication->sfAdmittedSet.u32MinimumTolerableTrafficRate); - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32RequesttransmissionPolicy : 0x%X", - pstAddIndication->sfAdmittedSet.u32RequesttransmissionPolicy); -#endif BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaxTrafficBurst : 0x%X", pstAddIndication->sfAdmittedSet.u32MaxTrafficBurst); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MinReservedTrafficRate : 0x%X", @@ -1339,13 +1304,6 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) pstAddIndication->sfAdmittedSet.u16TimeBase); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8PagingPreference : 0x%X", pstAddIndication->sfAdmittedSet.u8PagingPreference); -#if 0 - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "MBSZoneIdentifierassignmentLength : 0x%X", - pstAddIndication->sfAdmittedSet.MBSZoneIdentifierassignmentLength); - for(uiLoopIndex=0; uiLoopIndex < MAX_STRING_LEN; uiLoopIndex++) - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "MBSZoneIdentifierassignment : 0x%X", - pstAddIndication->sfAdmittedSet.MBSZoneIdentifierassignment[uiLoopIndex]); -#endif BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficIndicationPreference : 0x%02X", @@ -1378,11 +1336,6 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) psfCSType->cCPacketClassificationRule.u8IPTypeOfService[0], psfCSType->cCPacketClassificationRule.u8IPTypeOfService[1], psfCSType->cCPacketClassificationRule.u8IPTypeOfService[2]); -#if 0 - - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolLength :0x%02X ", - psfCSType->cCPacketClassificationRule.u8ProtocolLength); -#endif for(uiLoopIndex=0; uiLoopIndex < 1; uiLoopIndex++) BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Protocol: 0x%02X ", psfCSType->cCPacketClassificationRule.u8Protocol); @@ -1497,20 +1450,10 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) pstAddIndication->sfActiveSet.u8QosParamSet); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficPriority : 0x%02X", pstAddIndication->sfActiveSet.u8TrafficPriority); -#if 0 - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32MaxSustainedTrafficRate : 0x%02X", - ntohl(pstAddIndication->sfActiveSet.u32MaxSustainedTrafficRate)); -#endif BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaxTrafficBurst : 0x%X", pstAddIndication->sfActiveSet.u32MaxTrafficBurst); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MinReservedTrafficRate : 0x%X", pstAddIndication->sfActiveSet.u32MinReservedTrafficRate); -#if 0 - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32MinimumTolerableTrafficRate : 0x%X", - pstAddIndication->sfActiveSet.u32MinimumTolerableTrafficRate); - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32RequesttransmissionPolicy : 0x%X", - pstAddIndication->sfActiveSet.u32RequesttransmissionPolicy); -#endif BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParamLength : 0x%02X", pstAddIndication->sfActiveSet.u8VendorSpecificQoSParamLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParam : 0x%02X", @@ -1558,13 +1501,6 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) pstAddIndication->sfActiveSet.u16TimeBase); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8PagingPreference : 0x%X", pstAddIndication->sfActiveSet.u8PagingPreference); -#if 0 - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " MBSZoneIdentifierassignmentLength : 0x%X", - pstAddIndication->sfActiveSet.MBSZoneIdentifierassignmentLength); - for(uiLoopIndex=0; uiLoopIndex < MAX_STRING_LEN; uiLoopIndex++) - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " MBSZoneIdentifierassignment : 0x%X", - pstAddIndication->sfActiveSet.MBSZoneIdentifierassignment[uiLoopIndex]); -#endif BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8TrafficIndicationPreference : 0x%X", @@ -1597,11 +1533,6 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) psfCSType->cCPacketClassificationRule.u8IPTypeOfService[0], psfCSType->cCPacketClassificationRule.u8IPTypeOfService[1], psfCSType->cCPacketClassificationRule.u8IPTypeOfService[2]); -#if 0 - - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " u8ProtocolLength :0x%X ", - psfCSType->cCPacketClassificationRule.u8ProtocolLength); -#endif for(uiLoopIndex=0; uiLoopIndex < 1; uiLoopIndex++) BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8Protocol : 0x%X ", psfCSType->cCPacketClassificationRule.u8Protocol); @@ -1706,12 +1637,8 @@ static inline ULONG RestoreSFParam(PMINI_ADAPTER Adapter, ULONG ulAddrSFParamSet return 0; } ulAddrSFParamSet = ntohl(ulAddrSFParamSet); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " RestoreSFParam: Total Words of DSX Message To Read: 0x%zx From Target At : 0x%lx ", - nBytesToRead/sizeof(ULONG),ulAddrSFParamSet); - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "sizeof(stServiceFlowParamSI) = %zx", sizeof(stServiceFlowParamSI)); //Read out the SF Param Set At the indicated Location - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "nBytesToRead = %x", nBytesToRead); if(rdm(Adapter, ulAddrSFParamSet, (PUCHAR)pucDestBuffer, nBytesToRead) < 0) return STATUS_FAILURE; @@ -1719,23 +1646,20 @@ static inline ULONG RestoreSFParam(PMINI_ADAPTER Adapter, ULONG ulAddrSFParamSet } -static __inline ULONG StoreSFParam(PMINI_ADAPTER Adapter,PUCHAR pucSrcBuffer,ULONG ulAddrSFParamSet) +static ULONG StoreSFParam(PMINI_ADAPTER Adapter,PUCHAR pucSrcBuffer,ULONG ulAddrSFParamSet) { UINT nBytesToWrite = sizeof(stServiceFlowParamSI); - UINT uiRetVal =0; + int ret = 0; if(ulAddrSFParamSet == 0 || NULL == pucSrcBuffer) { return 0; } - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " StoreSFParam: Total Words of DSX Message To Write: 0x%zX To Target At : 0x%lX ",(nBytesToWrite/sizeof(ULONG)),ulAddrSFParamSet); - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "WRM with %x bytes",nBytesToWrite); - - uiRetVal = wrm(Adapter,ulAddrSFParamSet,(PUCHAR)pucSrcBuffer, nBytesToWrite); - if(uiRetVal < 0) { + ret = wrm(Adapter, ulAddrSFParamSet, (u8 *)pucSrcBuffer, nBytesToWrite); + if (ret < 0) { BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "%s:%d WRM failed",__FUNCTION__, __LINE__); - return uiRetVal; + return ret; } return 1; } @@ -1778,7 +1702,7 @@ ULONG StoreCmControlResponseMessage(PMINI_ADAPTER Adapter,PVOID pvBuffer,UINT *p } // For DSA_REQ, only upto "psfAuthorizedSet" parameter should be accessed by driver! - pstAddIndication=(stLocalSFAddIndication *)kmalloc(sizeof(*pstAddIndication), GFP_KERNEL); + pstAddIndication=kmalloc(sizeof(*pstAddIndication), GFP_KERNEL); if(NULL==pstAddIndication) return 0; @@ -1844,7 +1768,7 @@ ULONG StoreCmControlResponseMessage(PMINI_ADAPTER Adapter,PVOID pvBuffer,UINT *p (*puBufferLength) = sizeof(stLocalSFAddIndication); *(stLocalSFAddIndication *)pvBuffer = *pstAddIndication; - bcm_kfree(pstAddIndication); + kfree(pstAddIndication); return 1; } @@ -1931,7 +1855,7 @@ static inline stLocalSFAddIndicationAlt BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "============================================================"); return pstAddIndicationDest; failed_restore_sf_param: - bcm_kfree(pstAddIndicationDest); + kfree(pstAddIndicationDest); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "<=====" ); return NULL; } @@ -1988,7 +1912,7 @@ ULONG SetUpTargetDsxBuffers(PMINI_ADAPTER Adapter) return 1; } -ULONG GetNextTargetBufferLocation(PMINI_ADAPTER Adapter,B_UINT16 tid) +static ULONG GetNextTargetBufferLocation(PMINI_ADAPTER Adapter,B_UINT16 tid) { ULONG ulTargetDSXBufferAddress; ULONG ulTargetDsxBufferIndexToUse,ulMaxTry; @@ -2049,7 +1973,7 @@ INT FreeAdapterDsxBuffer(PMINI_ADAPTER Adapter) { if(Adapter->caDsxReqResp) { - bcm_kfree(Adapter->caDsxReqResp); + kfree(Adapter->caDsxReqResp); } return 0; @@ -2102,7 +2026,7 @@ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /**<Pointer to the Adap BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " VCID = %x", ntohs(pstAddIndication->u16VCID)); CopyBufferToControlPacket(Adapter,(PVOID)Adapter->caDsxReqResp); - bcm_kfree(pstAddIndication); + kfree(pstAddIndication); } break; case DSA_RSP: @@ -2118,7 +2042,7 @@ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /**<Pointer to the Adap case DSA_ACK: { UINT uiSearchRuleIndex=0; - struct timeval tv = {0}; + BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "VCID:0x%X", ntohs(pstAddIndication->u16VCID)); uiSearchRuleIndex=SearchFreeSfid(Adapter); @@ -2169,7 +2093,7 @@ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /**<Pointer to the Adap Adapter->PackInfo[uiSearchRuleIndex].bActive=FALSE; Adapter->PackInfo[uiSearchRuleIndex].bValid=FALSE; Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value=0; - bcm_kfree(pstAddIndication); + kfree(pstAddIndication); } else if(psfLocalSet->bValid && (pstAddIndication->u8CC == 0)) @@ -2200,14 +2124,13 @@ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /**<Pointer to the Adap if(!Adapter->LinkUpStatus) { netif_carrier_on(Adapter->dev); - netif_start_queue(Adapter->dev); + netif_start_queue(Adapter->dev); Adapter->LinkUpStatus = 1; - do_gettimeofday(&tv); - + if (netif_msg_link(Adapter)) + pr_info(PFX "%s: link up\n", Adapter->dev->name); atomic_set(&Adapter->TxPktAvail, 1); wake_up(&Adapter->tx_packet_wait_queue); - Adapter->liTimeSinceLastNetEntry = tv.tv_sec; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "============Tx Service Flow Created!"); + Adapter->liTimeSinceLastNetEntry = get_seconds(); } } } @@ -2218,13 +2141,13 @@ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /**<Pointer to the Adap Adapter->PackInfo[uiSearchRuleIndex].bActive=FALSE; Adapter->PackInfo[uiSearchRuleIndex].bValid=FALSE; Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value=0; - bcm_kfree(pstAddIndication); + kfree(pstAddIndication); } } else { BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0, "DSA ACK did not get valid SFID"); - bcm_kfree(pstAddIndication); + kfree(pstAddIndication); return FALSE; } } @@ -2239,7 +2162,7 @@ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /**<Pointer to the Adap ((stLocalSFChangeIndicationAlt*)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSC_RSP; CopyBufferToControlPacket(Adapter,(PVOID)Adapter->caDsxReqResp); - bcm_kfree(pstAddIndication); + kfree(pstAddIndication); } break; case DSC_RSP: @@ -2312,13 +2235,13 @@ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /**<Pointer to the Adap else if(pstChangeIndication->u8CC == 6) { deleteSFBySfid(Adapter,uiSearchRuleIndex); - bcm_kfree(pstAddIndication); + kfree(pstAddIndication); } } else { BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0, "DSC ACK did not get valid SFID"); - bcm_kfree(pstAddIndication); + kfree(pstAddIndication); return FALSE; } } @@ -2355,7 +2278,7 @@ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /**<Pointer to the Adap BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "DSD ACK Rcd, let App handle it\n"); break; default: - bcm_kfree(pstAddIndication); + kfree(pstAddIndication); return FALSE ; } return TRUE; diff --git a/drivers/staging/bcm/CmHost.h b/drivers/staging/bcm/CmHost.h index 847782c3765b..8f689769b4ba 100644 --- a/drivers/staging/bcm/CmHost.h +++ b/drivers/staging/bcm/CmHost.h @@ -150,8 +150,6 @@ typedef struct stLocalSFChangeIndicationAlt{ ULONG StoreCmControlResponseMessage(PMINI_ADAPTER Adapter,PVOID pvBuffer,UINT *puBufferLength); -ULONG GetNextTargetBufferLocation(PMINI_ADAPTER Adapter,B_UINT16 tid); - INT AllocAdapterDsxBuffer(PMINI_ADAPTER Adapter); INT FreeAdapterDsxBuffer(PMINI_ADAPTER Adapter); @@ -159,7 +157,6 @@ ULONG SetUpTargetDsxBuffers(PMINI_ADAPTER Adapter); BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter,PVOID pvBuffer); -VOID deleteSFBySfid(PMINI_ADAPTER Adapter, UINT uiSearchRuleIndex); #pragma pack (pop) diff --git a/drivers/staging/bcm/DDRInit.c b/drivers/staging/bcm/DDRInit.c index 8907e211d483..1c7db81a1ee8 100644 --- a/drivers/staging/bcm/DDRInit.c +++ b/drivers/staging/bcm/DDRInit.c @@ -1,6 +1,5 @@ #include "headers.h" -#ifndef BCM_SHM_INTERFACE #define DDR_DUMP_INTERNAL_DEVICE_MEMORY 0xBFC02B00 @@ -188,17 +187,6 @@ static DDR_SET_NODE asDPLL_266MHZ[] = { {0x0f000840,0x0FFF1B00}, {0x0f000870,0x00000002} }; -#if 0 -static DDR_SET_NODE asDPLL_800MHZ[] = { - {0x0f000810,0x00000F95}, - {0x0f000810,0x00000F95}, - {0x0f000810,0x00000F95}, - {0x0f000820,0x03F1365B}, - {0x0f000840,0x0FFF0000}, - {0x0f000880,0x000003DD}, - {0x0f000860,0x00000000} - }; -#endif #define T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 11 //index for 0x0F007000 static DDR_SET_NODE asT3B_DDRSetting133MHz[] = {// # DPLL Clock Setting @@ -788,7 +776,7 @@ int ddr_init(MINI_ADAPTER *Adapter) { PDDR_SETTING psDDRSetting=NULL; ULONG RegCount=0; - ULONG value = 0; + UINT value = 0; UINT uiResetValue = 0; UINT uiClockSetting = 0; int retval = STATUS_SUCCESS; @@ -982,7 +970,7 @@ int ddr_init(MINI_ADAPTER *Adapter) { value = psDDRSetting->ulRegValue; } - retval = wrmalt(Adapter, psDDRSetting->ulRegAddress, (PUINT)&value, sizeof(value)); + retval = wrmalt(Adapter, psDDRSetting->ulRegAddress, &value, sizeof(value)); if(STATUS_SUCCESS != retval) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"%s:%d\n", __FUNCTION__, __LINE__); break; @@ -1298,5 +1286,4 @@ int download_ddr_settings(PMINI_ADAPTER Adapter) return retval; } -#endif diff --git a/drivers/staging/bcm/Debug.c b/drivers/staging/bcm/Debug.c deleted file mode 100644 index 2703f304756d..000000000000 --- a/drivers/staging/bcm/Debug.c +++ /dev/null @@ -1,41 +0,0 @@ -#include "headers.h" - -static UINT current_debug_level=BCM_SCREAM; - -int bcm_print_buffer( UINT debug_level, const char *function_name, - char *file_name, int line_number, unsigned char *buffer, int bufferlen, enum _BASE_TYPE base) -{ - static const char * const buff_dump_base[] = { - "DEC", "HEX", "OCT", "BIN" - }; - if(debug_level>=current_debug_level) - { - int i=0; - printk("\n%s:%s:%d:Buffer dump of size 0x%x in the %s:\n", file_name, function_name, line_number, bufferlen, buff_dump_base[1]); - for(;i<bufferlen;i++) - { - if(i && !(i%16) ) - printk("\n"); - switch(base) - { - case BCM_BASE_TYPE_DEC: - printk("%03d ", buffer[i]); - break; - case BCM_BASE_TYPE_OCT: - printk("%0x03o ", buffer[i]); - break; - case BCM_BASE_TYPE_BIN: - printk("%02x ", buffer[i]); - break; - case BCM_BASE_TYPE_HEX: - default: - printk("%02X ", buffer[i]); - break; - } - } - printk("\n"); - } - return 0; -} - - diff --git a/drivers/staging/bcm/Debug.h b/drivers/staging/bcm/Debug.h index 3d788b59ab57..3138729cf34f 100644 --- a/drivers/staging/bcm/Debug.h +++ b/drivers/staging/bcm/Debug.h @@ -9,34 +9,6 @@ #include <linux/string.h> #define NONE 0xFFFF -typedef enum _BASE_TYPE -{ - BCM_BASE_TYPE_DEC, - BCM_BASE_TYPE_OCT, - BCM_BASE_TYPE_BIN, - BCM_BASE_TYPE_HEX, - BCM_BASE_TYPE_NONE, -} BASE_TYPE, *PBASE_TYPE; - -int bcm_print_buffer( UINT debug_level, const char *function_name, - char *file_name, int line_number, unsigned char *buffer, int bufferlen, BASE_TYPE base); - -#ifdef BCM_SHM_INTERFACE -#define CPE_VIRTUAL_ERROR_CODE_BASE_ADDR (0xBFC02E00 + 0x4C) -// ERROR codes for debugging -extern unsigned char u32ErrorCounter ; -#define ERROR_DEVICE_REMOVED 0x1 -#define ERROR_LEADER_LENGTH_ZERO 0x2 -#define ERROR_LEADER_LENGTH_CORRUPTED 0x3 -#define ERROR_NO_SKBUFF 0x4 - -#define ERROR_DL_MODULE 0xaa000000 -extern void CPE_ERROR_LOG(unsigned int module,unsigned int code); - -#endif - - - //-------------------------------------------------------------------------------- @@ -242,44 +214,34 @@ typedef struct _S_BCM_DEBUG_STATE { //--- Only for direct printk's; "hidden" to API. #define DBG_TYPE_PRINTK 3 -#define PRINTKS_ON 1 // "hidden" from API, set to 0 to turn off all printk's - -#define BCM_DEBUG_PRINT(Adapter, Type, SubType, dbg_level, string, args...) do { \ - if ((DBG_TYPE_PRINTK == Type) && (PRINTKS_ON)) { \ - printk ("%s:" string, __FUNCTION__, ##args); \ - printk("\n"); \ - } else if (!Adapter) \ - ; \ - else { \ - if (((dbg_level & DBG_LVL_BITMASK) <= Adapter->stDebugState.debug_level) && \ - ((Type & Adapter->stDebugState.type) && (SubType & Adapter->stDebugState.subtype[Type]))) { \ - if (dbg_level & DBG_NO_FUNC_PRINT) \ - printk (string, ##args); \ - else \ - { \ - printk ("%s:" string, __FUNCTION__, ##args); \ - printk("\n"); \ - } \ - } \ - } \ -} while (0) -#define BCM_DEBUG_PRINT_BUFFER(Adapter, Type, SubType, dbg_level, buffer, bufferlen) do { \ - if ((DBG_TYPE_PRINTK == Type) && (PRINTKS_ON)) { \ - bcm_print_buffer( dbg_level, __FUNCTION__, __FILE__, __LINE__, buffer, bufferlen, BCM_BASE_TYPE_HEX); \ - } else if (!Adapter) \ - ; \ - else { \ - if (((dbg_level & DBG_LVL_BITMASK) <= Adapter->stDebugState.debug_level) && \ - ((Type & Adapter->stDebugState.type) && (SubType & Adapter->stDebugState.subtype[Type]))) { \ - if (dbg_level & DBG_NO_FUNC_PRINT) \ - bcm_print_buffer( dbg_level, NULL, NULL, __LINE__, buffer, bufferlen, BCM_BASE_TYPE_HEX); \ - else \ - bcm_print_buffer( dbg_level, __FUNCTION__, __FILE__, __LINE__, buffer, bufferlen, BCM_BASE_TYPE_HEX); \ - } \ - } \ +#define BCM_DEBUG_PRINT(Adapter, Type, SubType, dbg_level, string, args...) \ + do { \ + if (DBG_TYPE_PRINTK == Type) \ + pr_info("%s:" string, __func__, ##args); \ + else if (Adapter && \ + (dbg_level & DBG_LVL_BITMASK) <= Adapter->stDebugState.debug_level && \ + (Type & Adapter->stDebugState.type) && \ + (SubType & Adapter->stDebugState.subtype[Type])) { \ + if (dbg_level & DBG_NO_FUNC_PRINT) \ + printk(KERN_DEBUG string, ##args); \ + else \ + printk(KERN_DEBUG "%s:" string, __func__, ##args); \ + } \ } while (0) +#define BCM_DEBUG_PRINT_BUFFER(Adapter, Type, SubType, dbg_level, buffer, bufferlen) do { \ + if (DBG_TYPE_PRINTK == Type || \ + (Adapter && \ + (dbg_level & DBG_LVL_BITMASK) <= Adapter->stDebugState.debug_level && \ + (Type & Adapter->stDebugState.type) && \ + (SubType & Adapter->stDebugState.subtype[Type]))) { \ + printk(KERN_DEBUG "%s:\n", __func__); \ + print_hex_dump(KERN_DEBUG, " ", DUMP_PREFIX_OFFSET, \ + 16, 1, buffer, bufferlen, false); \ + } \ +} while(0) + #define BCM_SHOW_DEBUG_BITMAP(Adapter) do { \ int i; \ diff --git a/drivers/staging/bcm/HandleControlPacket.c b/drivers/staging/bcm/HandleControlPacket.c index 7b2ec28a4bc1..2b1e9e17e11c 100644 --- a/drivers/staging/bcm/HandleControlPacket.c +++ b/drivers/staging/bcm/HandleControlPacket.c @@ -11,8 +11,7 @@ When a control packet is received, analyze the Enqueue the control packet for Application. @return None */ -VOID handle_rx_control_packet(PMINI_ADAPTER Adapter, /**<Pointer to the Adapter structure*/ - struct sk_buff *skb) /**<Pointer to the socket buffer*/ +static VOID handle_rx_control_packet(PMINI_ADAPTER Adapter, struct sk_buff *skb) { PPER_TARANG_DATA pTarang = NULL; BOOLEAN HighPriorityMessage = FALSE; @@ -20,8 +19,10 @@ VOID handle_rx_control_packet(PMINI_ADAPTER Adapter, /**<Pointer to the Adapter CHAR cntrl_msg_mask_bit = 0; BOOLEAN drop_pkt_flag = TRUE ; USHORT usStatus = *(PUSHORT)(skb->data); - BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL, "=====>"); - /* Get the Leader field */ + + if (netif_msg_pktdata(Adapter)) + print_hex_dump(KERN_DEBUG, PFX "rx control: ", DUMP_PREFIX_NONE, + 16, 1, skb->data, skb->len, 0); switch(usStatus) { @@ -134,7 +135,7 @@ VOID handle_rx_control_packet(PMINI_ADAPTER Adapter, /**<Pointer to the Adapter } up(&Adapter->RxAppControlQueuelock); wake_up(&Adapter->process_read_wait_queue); - bcm_kfree_skb(skb); + dev_kfree_skb(skb); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL, "After wake_up_interruptible"); } @@ -185,33 +186,7 @@ int control_packet_handler (PMINI_ADAPTER Adapter /**< pointer to adapter obje { DEQUEUEPACKET(Adapter->RxControlHead,Adapter->RxControlTail); // Adapter->RxControlHead=ctrl_packet->next; - ((PLINUX_DEP_DATA)Adapter->pvOsDepData)->netstats.rx_packets++; - ((PLINUX_DEP_DATA)Adapter->pvOsDepData)->netstats.rx_bytes+= - ((PLEADER)ctrl_packet->data)->PLength; - } - #if 0 //Idle mode debug profiling... - if(*(PUSHORT)ctrl_packet->data == IDLE_MODE_STATUS) - { - puiBuffer = (PUINT)(ctrl_packet->data +sizeof(USHORT)); - if((ntohl(*puiBuffer) == GO_TO_IDLE_MODE_PAYLOAD)) - { - memset(&tv, 0, sizeof(tv)); - do_gettimeofday(&tv); - if((ntohl(*(puiBuffer+1)) == 0)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL, "IdleMode Wake-up Msg from f/w at time :%ld ms", tv.tv_sec *1000 + tv.tv_usec /1000); - } - else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL, "IdleMode req Msg from f/w at time :%ld ms", tv.tv_sec *1000 + tv.tv_usec /1000); - } - } - else if((ntohl(*puiBuffer) == IDLE_MODE_SF_UPDATE_MSG)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL, "GOT IDLE_MODE_SF_UPDATE MSG at time :%ld ms", tv.tv_sec *1000 + tv.tv_usec /1000); - } } - #endif spin_unlock_irqrestore (&Adapter->control_queue_lock, flags); handle_rx_control_packet(Adapter, ctrl_packet); @@ -234,7 +209,7 @@ INT flushAllAppQ(void) { PacketToDrop=pTarang->RxAppControlHead; DEQUEUEPACKET(pTarang->RxAppControlHead,pTarang->RxAppControlTail); - bcm_kfree_skb(PacketToDrop); + dev_kfree_skb(PacketToDrop); } pTarang->AppCtrlQueueLen = 0; //dropped contrl packet statistics also should be reset. diff --git a/drivers/staging/bcm/HostMibs.h b/drivers/staging/bcm/HostMibs.h deleted file mode 100644 index 28a578311378..000000000000 --- a/drivers/staging/bcm/HostMibs.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _HOST_MIBS_H -#define _HOST_MIBS_H - -INT ProcessGetHostMibs(PMINI_ADAPTER Adapter, - PVOID ioBuffer, - ULONG inputBufferLength); -#endif diff --git a/drivers/staging/bcm/IPv6Protocol.c b/drivers/staging/bcm/IPv6Protocol.c index 5ec3b896c6a7..91b6fbe33c91 100644 --- a/drivers/staging/bcm/IPv6Protocol.c +++ b/drivers/staging/bcm/IPv6Protocol.c @@ -1,5 +1,9 @@ #include "headers.h" +static BOOLEAN MatchSrcIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,IPV6Header *pstIpv6Header); +static BOOLEAN MatchDestIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,IPV6Header *pstIpv6Header); +static VOID DumpIpv6Header(IPV6Header *pstIpv6Header); + static UCHAR * GetNextIPV6ChainedHeader(UCHAR **ppucPayload,UCHAR *pucNextHeader,BOOLEAN *bParseDone,USHORT *pusPayloadLength) { UCHAR *pucRetHeaderPtr = NULL; @@ -257,7 +261,7 @@ USHORT IpVersion6(PMINI_ADAPTER Adapter, /**< Pointer to the driver control stru } -BOOLEAN MatchSrcIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,IPV6Header *pstIpv6Header) +static BOOLEAN MatchSrcIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,IPV6Header *pstIpv6Header) { UINT uiLoopIndex=0; UINT uiIpv6AddIndex=0; @@ -310,7 +314,7 @@ BOOLEAN MatchSrcIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,IPV6Header *pst return FALSE; } -BOOLEAN MatchDestIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,IPV6Header *pstIpv6Header) +static BOOLEAN MatchDestIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,IPV6Header *pstIpv6Header) { UINT uiLoopIndex=0; UINT uiIpv6AddIndex=0; @@ -376,7 +380,7 @@ VOID DumpIpv6Address(ULONG *puIpv6Address) } -VOID DumpIpv6Header(IPV6Header *pstIpv6Header) +static VOID DumpIpv6Header(IPV6Header *pstIpv6Header) { UCHAR ucVersion; UCHAR ucPrio ; diff --git a/drivers/staging/bcm/IPv6ProtocolHdr.h b/drivers/staging/bcm/IPv6ProtocolHdr.h index b93f7902e283..a0db5a1de763 100644 --- a/drivers/staging/bcm/IPv6ProtocolHdr.h +++ b/drivers/staging/bcm/IPv6ProtocolHdr.h @@ -101,15 +101,12 @@ typedef enum _E_IPADDR_CONTEXT //Function Prototypes -BOOLEAN MatchSrcIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,IPV6Header *pstIpv6Header); -BOOLEAN MatchDestIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,IPV6Header *pstIpv6Header); USHORT IpVersion6(PMINI_ADAPTER Adapter, /**< Pointer to the driver control structure */ PVOID pcIpHeader, /**<Pointer to the IP Hdr of the packet*/ S_CLASSIFIER_RULE *pstClassifierRule ); VOID DumpIpv6Address(ULONG *puIpv6Address); -VOID DumpIpv6Header(IPV6Header *pstIpv6Header); extern BOOLEAN MatchSrcPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort); extern BOOLEAN MatchDestPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort); diff --git a/drivers/staging/bcm/InterfaceDld.c b/drivers/staging/bcm/InterfaceDld.c index 60c0f29f3eef..df64acb06126 100644 --- a/drivers/staging/bcm/InterfaceDld.c +++ b/drivers/staging/bcm/InterfaceDld.c @@ -1,20 +1,18 @@ #include "headers.h" -#ifndef BCM_SHM_INTERFACE int InterfaceFileDownload( PVOID arg, struct file *flp, unsigned int on_chip_loc) { - char *buff=NULL; // unsigned int reg=0; mm_segment_t oldfs={0}; int errno=0, len=0 /*,is_config_file = 0*/; loff_t pos=0; PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)arg; //PMINI_ADAPTER Adapter = psIntfAdapter->psAdapter; + char *buff=kmalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_KERNEL); - buff=(PCHAR)kmalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_KERNEL); if(!buff) { return -ENOMEM; @@ -49,7 +47,7 @@ int InterfaceFileDownload( PVOID arg, on_chip_loc+=MAX_TRANSFER_CTRL_BYTE_USB; }/* End of for(;;)*/ - bcm_kfree(buff); + kfree(buff); return errno; } @@ -57,7 +55,7 @@ int InterfaceFileReadbackFromChip( PVOID arg, struct file *flp, unsigned int on_chip_loc) { - char *buff=NULL, *buff_readback=NULL; + char *buff, *buff_readback; unsigned int reg=0; mm_segment_t oldfs={0}; int errno=0, len=0, is_config_file = 0; @@ -66,12 +64,12 @@ int InterfaceFileReadbackFromChip( PVOID arg, INT Status = STATUS_SUCCESS; PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)arg; - buff=(PCHAR)kmalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_DMA); - buff_readback=(PCHAR)kmalloc(MAX_TRANSFER_CTRL_BYTE_USB , GFP_DMA); + buff=kmalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_DMA); + buff_readback=kmalloc(MAX_TRANSFER_CTRL_BYTE_USB , GFP_DMA); if(!buff || !buff_readback) { - bcm_kfree(buff); - bcm_kfree(buff_readback); + kfree(buff); + kfree(buff_readback); return -ENOMEM; } @@ -138,8 +136,8 @@ int InterfaceFileReadbackFromChip( PVOID arg, on_chip_loc+=MAX_TRANSFER_CTRL_BYTE_USB; }/* End of while(1)*/ exit: - bcm_kfree(buff); - bcm_kfree(buff_readback); + kfree(buff); + kfree(buff_readback); return Status; } @@ -165,7 +163,7 @@ static int bcm_download_config_file(PMINI_ADAPTER Adapter, psFwInfo->pvMappedFirmwareAddress, psFwInfo->u32FirmwareLength); if(retval) { - bcm_kfree (Adapter->pstargetparams); + kfree(Adapter->pstargetparams); Adapter->pstargetparams = NULL; return -EFAULT; } @@ -231,41 +229,6 @@ static int bcm_download_config_file(PMINI_ADAPTER Adapter, return retval; } -#if 0 -static int bcm_download_buffer(PMINI_ADAPTER Adapter, - unsigned char *mappedbuffer, unsigned int u32FirmwareLength, - unsigned long u32StartingAddress) -{ - char *buff=NULL; - unsigned int len = 0; - int retval = STATUS_SUCCESS; - buff = kzalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_KERNEL); - - len = u32FirmwareLength; - - while(u32FirmwareLength) - { - len = MIN_VAL (u32FirmwareLength, MAX_TRANSFER_CTRL_BYTE_USB); - if(STATUS_SUCCESS != (retval = copy_from_user(buff, - (unsigned char *)mappedbuffer, len))) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "copy_from_user failed\n"); - break; - } - retval = wrm (Adapter, u32StartingAddress, buff, len); - if(retval) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "wrm failed\n"); - break; - } - u32StartingAddress += len; - u32FirmwareLength -= len; - mappedbuffer +=len; - } - bcm_kfree(buff); - return retval; -} -#endif static int bcm_compare_buff_contents(unsigned char *readbackbuff, unsigned char *buff,unsigned int len) { @@ -297,58 +260,6 @@ static int bcm_compare_buff_contents(unsigned char *readbackbuff, } return retval; } -#if 0 -static int bcm_buffer_readback(PMINI_ADAPTER Adapter, - unsigned char *mappedbuffer, unsigned int u32FirmwareLength, - unsigned long u32StartingAddress) -{ - unsigned char *buff = NULL; - unsigned char *readbackbuff = NULL; - unsigned int len = u32FirmwareLength; - int retval = STATUS_SUCCESS; - - buff=(unsigned char *)kzalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_KERNEL); - if(NULL == buff) - return -ENOMEM; - readbackbuff = (unsigned char *)kzalloc(MAX_TRANSFER_CTRL_BYTE_USB, - GFP_KERNEL); - if(NULL == readbackbuff) - { - bcm_kfree(buff); - return -ENOMEM; - } - while (u32FirmwareLength && !retval) - { - len = MIN_VAL (u32FirmwareLength, MAX_TRANSFER_CTRL_BYTE_USB); - - /* read from the appl buff and then read from the target, compare */ - if(STATUS_SUCCESS != (retval = copy_from_user(buff, - (unsigned char *)mappedbuffer, len))) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "copy_from_user failed\n"); - break; - } - retval = rdm (Adapter, u32StartingAddress, readbackbuff, len); - if(retval) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "rdm failed\n"); - break; - } - - if (STATUS_SUCCESS != - (retval = bcm_compare_buff_contents (readbackbuff, buff, len))) - { - break; - } - u32StartingAddress += len; - u32FirmwareLength -= len; - mappedbuffer +=len; - }/* end of while (u32FirmwareLength && !retval) */ - bcm_kfree(buff); - bcm_kfree(readbackbuff); - return retval; -} -#endif int bcm_ioctl_fw_download(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwInfo) { int retval = STATUS_SUCCESS; @@ -375,7 +286,7 @@ int bcm_ioctl_fw_download(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwInfo) else { - buff = (PUCHAR)kzalloc(psFwInfo->u32FirmwareLength,GFP_KERNEL); + buff = kzalloc(psFwInfo->u32FirmwareLength,GFP_KERNEL); if(buff==NULL) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Failed in allocation memory"); @@ -389,23 +300,6 @@ int bcm_ioctl_fw_download(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwInfo) goto error ; } - #if 0 - retval = bcm_download_buffer(Adapter, - (unsigned char *)psFwInfo->pvMappedFirmwareAddress, - psFwInfo->u32FirmwareLength, psFwInfo->u32StartingAddress); - if(retval != STATUS_SUCCESS) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "User space buffer download fails...."); - } - retval = bcm_buffer_readback (Adapter, - (unsigned char *)psFwInfo->pvMappedFirmwareAddress, - psFwInfo->u32FirmwareLength, psFwInfo->u32StartingAddress); - - if(retval != STATUS_SUCCESS) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "read back verifier failed ...."); - } - #endif retval = buffDnldVerify(Adapter, buff, psFwInfo->u32FirmwareLength, @@ -417,7 +311,7 @@ int bcm_ioctl_fw_download(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwInfo) } } error: - bcm_kfree(buff); + kfree(buff); return retval; } @@ -450,11 +344,10 @@ static INT buffRdbkVerify(PMINI_ADAPTER Adapter, PUCHAR mappedbuffer, UINT u32FirmwareLength, ULONG u32StartingAddress) { - PUCHAR readbackbuff = NULL; UINT len = u32FirmwareLength; INT retval = STATUS_SUCCESS; + PUCHAR readbackbuff = kzalloc(MAX_TRANSFER_CTRL_BYTE_USB,GFP_KERNEL); - readbackbuff = (PUCHAR)kzalloc(MAX_TRANSFER_CTRL_BYTE_USB,GFP_KERNEL); if(NULL == readbackbuff) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "MEMORY ALLOCATION FAILED"); @@ -480,7 +373,7 @@ static INT buffRdbkVerify(PMINI_ADAPTER Adapter, u32FirmwareLength -= len; mappedbuffer +=len; }/* end of while (u32FirmwareLength && !retval) */ - bcm_kfree(readbackbuff); + kfree(readbackbuff); return retval; } @@ -506,5 +399,4 @@ error: return status; } -#endif diff --git a/drivers/staging/bcm/InterfaceIdleMode.c b/drivers/staging/bcm/InterfaceIdleMode.c index 0750382733ff..bf5c0ad86610 100644 --- a/drivers/staging/bcm/InterfaceIdleMode.c +++ b/drivers/staging/bcm/InterfaceIdleMode.c @@ -98,14 +98,6 @@ int InterfaceIdleModeRespond(PMINI_ADAPTER Adapter, unsigned int* puiBuffer) Adapter->bTriedToWakeUpFromlowPowerMode = FALSE; wake_up(&Adapter->lowpower_mode_wait_queue); - #if 0 - if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"LED Thread is Running. Hence Setting the LED Event as IDLEMODE_EXIT"); - Adapter->DriverState = IDLEMODE_EXIT; - wake_up(&Adapter->LEDInfo.notify_led_event); - } - #endif } else @@ -154,17 +146,7 @@ int InterfaceIdleModeRespond(PMINI_ADAPTER Adapter, unsigned int* puiBuffer) return status; } - -VOID InterfaceWriteIdleModeWakePattern(PMINI_ADAPTER Adapter) -{ -/* BeceemWriteMemoryUshort(Adapter, Host2CPU_Mailbox_Low, 0x1d1e); - BeceemWriteMemoryUshort(Adapter, Host2CPU_Mailbox_Low, 0x1d1e); - BeceemWriteMemoryUshort(Adapter, Host2CPU_Mailbox_Upp, 0xd0ea); - BeceemWriteMemoryUshort(Adapter, Host2CPU_Mailbox_Upp, 0xd0ea);*/ - return; -} - -int InterfaceAbortIdlemode(PMINI_ADAPTER Adapter, unsigned int Pattern) +static int InterfaceAbortIdlemode(PMINI_ADAPTER Adapter, unsigned int Pattern) { int status = STATUS_SUCCESS; unsigned int value; diff --git a/drivers/staging/bcm/InterfaceIdleMode.h b/drivers/staging/bcm/InterfaceIdleMode.h index 1bc723d2d72c..859a2ffba6b7 100644 --- a/drivers/staging/bcm/InterfaceIdleMode.h +++ b/drivers/staging/bcm/InterfaceIdleMode.h @@ -7,8 +7,6 @@ INT InterfaceIdleModeRespond(PMINI_ADAPTER Adapter, unsigned int *puiBuffer); VOID InterfaceWriteIdleModeWakePattern(PMINI_ADAPTER Adapter); -INT InterfaceAbortIdlemode(PMINI_ADAPTER Adapter, unsigned int Pattern); - INT InterfaceWakeUp(PMINI_ADAPTER Adapter); VOID InterfaceHandleShutdownModeWakeup(PMINI_ADAPTER Adapter); diff --git a/drivers/staging/bcm/InterfaceInit.c b/drivers/staging/bcm/InterfaceInit.c index e97ad99b1bb4..d78d5ef1f298 100644 --- a/drivers/staging/bcm/InterfaceInit.c +++ b/drivers/staging/bcm/InterfaceInit.c @@ -1,54 +1,63 @@ #include "headers.h" static struct usb_device_id InterfaceUsbtable[] = { - { USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3) }, + { USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3) }, { USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3B) }, { USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3L) }, - { USB_DEVICE(BCM_USB_VENDOR_ID_ZTE, BCM_USB_PRODUCT_ID_226) }, + { USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_SM250) }, + { USB_DEVICE(BCM_USB_VENDOR_ID_ZTE, BCM_USB_PRODUCT_ID_226) }, { USB_DEVICE(BCM_USB_VENDOR_ID_FOXCONN, BCM_USB_PRODUCT_ID_1901) }, - {} + { USB_DEVICE(BCM_USB_VENDOR_ID_ZTE, BCM_USB_PRODUCT_ID_ZTE_TU25) }, + { } }; +MODULE_DEVICE_TABLE(usb, InterfaceUsbtable); -VOID InterfaceAdapterFree(PS_INTERFACE_ADAPTER psIntfAdapter) +static int debug = -1; +module_param(debug, uint, 0600); +MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)"); + +static const u32 default_msg = + NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK + | NETIF_MSG_TIMER | NETIF_MSG_TX_ERR | NETIF_MSG_RX_ERR + | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN; + +static int InterfaceAdapterInit(PS_INTERFACE_ADAPTER Adapter); + +static void InterfaceAdapterFree(PS_INTERFACE_ADAPTER psIntfAdapter) { - INT i = 0; - // Wake up the wait_queue... - if(psIntfAdapter->psAdapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) - { + int i = 0; + + /* Wake up the wait_queue... */ + if (psIntfAdapter->psAdapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { psIntfAdapter->psAdapter->DriverState = DRIVER_HALT; wake_up(&psIntfAdapter->psAdapter->LEDInfo.notify_led_event); } reset_card_proc(psIntfAdapter->psAdapter); - //worst case time taken by the RDM/WRM will be 5 sec. will check after every 100 ms - //to accertain the device is not being accessed. After this No RDM/WRM should be made. - while(psIntfAdapter->psAdapter->DeviceAccess) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"Device is being Accessed \n"); + /* + * worst case time taken by the RDM/WRM will be 5 sec. will check after every 100 ms + * to accertain the device is not being accessed. After this No RDM/WRM should be made. + */ + while (psIntfAdapter->psAdapter->DeviceAccess) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, + "Device is being accessed.\n"); msleep(100); } /* Free interrupt URB */ - //psIntfAdapter->psAdapter->device_removed = TRUE; - if(psIntfAdapter->psInterruptUrb) - { - usb_free_urb(psIntfAdapter->psInterruptUrb); - } + /* psIntfAdapter->psAdapter->device_removed = TRUE; */ + usb_free_urb(psIntfAdapter->psInterruptUrb); /* Free transmit URBs */ - for(i = 0; i < MAXIMUM_USB_TCB; i++) - { - if(psIntfAdapter->asUsbTcb[i].urb != NULL) - { + for (i = 0; i < MAXIMUM_USB_TCB; i++) { + if (psIntfAdapter->asUsbTcb[i].urb != NULL) { usb_free_urb(psIntfAdapter->asUsbTcb[i].urb); psIntfAdapter->asUsbTcb[i].urb = NULL; } } /* Free receive URB and buffers */ - for(i = 0; i < MAXIMUM_USB_RCB; i++) - { - if (psIntfAdapter->asUsbRcb[i].urb != NULL) - { - bcm_kfree(psIntfAdapter->asUsbRcb[i].urb->transfer_buffer); + for (i = 0; i < MAXIMUM_USB_RCB; i++) { + if (psIntfAdapter->asUsbRcb[i].urb != NULL) { + kfree(psIntfAdapter->asUsbRcb[i].urb->transfer_buffer); usb_free_urb(psIntfAdapter->asUsbRcb[i].urb); psIntfAdapter->asUsbRcb[i].urb = NULL; } @@ -56,151 +65,109 @@ VOID InterfaceAdapterFree(PS_INTERFACE_ADAPTER psIntfAdapter) AdapterFree(psIntfAdapter->psAdapter); } - - -static int usbbcm_open(struct inode *inode, struct file *file) -{ - return 0; -} - -static int usbbcm_release(struct inode *inode, struct file *file) -{ - return 0; -} - -static ssize_t usbbcm_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) -{ - return 0; -} - -static ssize_t usbbcm_write(struct file *file, const char __user *user_buffer, size_t count, loff_t *ppos) +static void ConfigureEndPointTypesThroughEEPROM(PMINI_ADAPTER Adapter) { - return 0; -} + unsigned long ulReg = 0; + int ret; - -VOID ConfigureEndPointTypesThroughEEPROM(PMINI_ADAPTER Adapter) -{ - ULONG ulReg = 0; - -// Program EP2 MAX_PKT_SIZE + /* Program EP2 MAX_PKT_SIZE */ ulReg = ntohl(EP2_MPS_REG); - BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x128,4,TRUE); + BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x128, 4, TRUE); ulReg = ntohl(EP2_MPS); - BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x12C,4,TRUE); + BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x12C, 4, TRUE); ulReg = ntohl(EP2_CFG_REG); - BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x132,4,TRUE); - if(((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter))->bHighSpeedDevice == TRUE) - { + BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x132, 4, TRUE); + if (((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter))->bHighSpeedDevice == TRUE) { ulReg = ntohl(EP2_CFG_INT); - BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x136,4,TRUE); - } - else - { -// USE BULK EP as TX in FS mode. + BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x136, 4, TRUE); + } else { + /* USE BULK EP as TX in FS mode. */ ulReg = ntohl(EP2_CFG_BULK); - BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x136,4,TRUE); + BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x136, 4, TRUE); } - -// Program EP4 MAX_PKT_SIZE. + /* Program EP4 MAX_PKT_SIZE. */ ulReg = ntohl(EP4_MPS_REG); - BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x13C,4,TRUE); + BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x13C, 4, TRUE); ulReg = ntohl(EP4_MPS); - BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x140,4,TRUE); + BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x140, 4, TRUE); -// Program TX EP as interrupt (Alternate Setting) - if( rdmalt(Adapter,0x0F0110F8, (PUINT)&ulReg,4)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "reading of Tx EP is failing"); - return ; + /* Program TX EP as interrupt(Alternate Setting) */ + ret = rdmalt(Adapter, 0x0F0110F8, (u32 *)&ulReg, sizeof(u32)); + if (ret) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, + "reading of Tx EP failed\n"); + return; } ulReg |= 0x6; ulReg = ntohl(ulReg); - BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1CC,4,TRUE); + BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x1CC, 4, TRUE); ulReg = ntohl(EP4_CFG_REG); - BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1C8,4,TRUE); -// Program ISOCHRONOUS EP size to zero. + BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x1C8, 4, TRUE); + /* Program ISOCHRONOUS EP size to zero. */ ulReg = ntohl(ISO_MPS_REG); - BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1D2,4,TRUE); + BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x1D2, 4, TRUE); ulReg = ntohl(ISO_MPS); - BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1D6,4,TRUE); + BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x1D6, 4, TRUE); -// Update EEPROM Version. -// Read 4 bytes from 508 and modify 511 and 510. -// - ReadBeceemEEPROM(Adapter,0x1FC,(PUINT)&ulReg); + /* + * Update EEPROM Version. + * Read 4 bytes from 508 and modify 511 and 510. + */ + ReadBeceemEEPROM(Adapter, 0x1FC, (PUINT)&ulReg); ulReg &= 0x0101FFFF; - BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1FC,4,TRUE); -// -//Update length field if required. Also make the string NULL terminated. -// - ReadBeceemEEPROM(Adapter,0xA8,(PUINT)&ulReg); - if((ulReg&0x00FF0000)>>16 > 0x30) - { + BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x1FC, 4, TRUE); + + /* Update length field if required. Also make the string NULL terminated. */ + + ReadBeceemEEPROM(Adapter, 0xA8, (PUINT)&ulReg); + if ((ulReg&0x00FF0000)>>16 > 0x30) { ulReg = (ulReg&0xFF00FFFF)|(0x30<<16); - BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0xA8,4,TRUE); + BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0xA8, 4, TRUE); } - ReadBeceemEEPROM(Adapter,0x148,(PUINT)&ulReg); - if((ulReg&0x00FF0000)>>16 > 0x30) - { + ReadBeceemEEPROM(Adapter, 0x148, (PUINT)&ulReg); + if ((ulReg&0x00FF0000)>>16 > 0x30) { ulReg = (ulReg&0xFF00FFFF)|(0x30<<16); - BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x148,4,TRUE); + BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x148, 4, TRUE); } ulReg = 0; - BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x122,4,TRUE); + BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x122, 4, TRUE); ulReg = 0; - BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1C2,4,TRUE); - + BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x1C2, 4, TRUE); } -static struct file_operations usbbcm_fops = { - .open = usbbcm_open, - .release = usbbcm_release, - .read = usbbcm_read, - .write = usbbcm_write, - .owner = THIS_MODULE, - .llseek = no_llseek, -}; - -static struct usb_class_driver usbbcm_class = { - .name = "usbbcm", - .fops = &usbbcm_fops, - .minor_base = BCM_USB_MINOR_BASE, -}; - static int usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id) { - int retval =0 ; - PMINI_ADAPTER psAdapter = NULL; - PS_INTERFACE_ADAPTER psIntfAdapter = NULL; - struct usb_device *udev = NULL; - -// BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Usbbcm probe!!"); - if((intf == NULL) || (id == NULL)) - { - // BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "intf or id is NULL"); - return -EINVAL; - } + struct usb_device *udev = interface_to_usbdev(intf); + int retval; + PMINI_ADAPTER psAdapter; + PS_INTERFACE_ADAPTER psIntfAdapter; + struct net_device *ndev; - /* Allocate Adapter structure */ - if((psAdapter = kzalloc(sizeof(MINI_ADAPTER), GFP_KERNEL)) == NULL) - { - BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0, "Out of memory"); + /* Reserve one extra queue for the bit-bucket */ + ndev = alloc_etherdev_mq(sizeof(MINI_ADAPTER), NO_OF_QUEUES+1); + if (ndev == NULL) { + dev_err(&udev->dev, DRV_NAME ": no memory for device\n"); return -ENOMEM; } - /* Init default driver debug state */ + SET_NETDEV_DEV(ndev, &intf->dev); - psAdapter->stDebugState.debug_level = DBG_LVL_CURR; + psAdapter = netdev_priv(ndev); + psAdapter->dev = ndev; + psAdapter->msg_enable = netif_msg_init(debug, default_msg); + + /* Init default driver debug state */ + + psAdapter->stDebugState.debug_level = DBG_LVL_CURR; psAdapter->stDebugState.type = DBG_TYPE_INITEXIT; - memset (psAdapter->stDebugState.subtype, 0, sizeof (psAdapter->stDebugState.subtype)); - /* Technically, one can start using BCM_DEBUG_PRINT after this point. + /* + * Technically, one can start using BCM_DEBUG_PRINT after this point. * However, realize that by default the Type/Subtype bitmaps are all zero now; * so no prints will actually appear until the TestApp turns on debug paths via * the ioctl(); so practically speaking, in early init, no logging happens. @@ -211,160 +178,128 @@ usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id) * Further, we turn this OFF once init_module() completes. */ - psAdapter->stDebugState.subtype[DBG_TYPE_INITEXIT] = 0xff; + psAdapter->stDebugState.subtype[DBG_TYPE_INITEXIT] = 0xff; BCM_SHOW_DEBUG_BITMAP(psAdapter); retval = InitAdapter(psAdapter); - if(retval) - { - BCM_DEBUG_PRINT (psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "InitAdapter Failed\n"); + if (retval) { + dev_err(&udev->dev, DRV_NAME ": InitAdapter Failed\n"); AdapterFree(psAdapter); return retval; } /* Allocate interface adapter structure */ - if((psAdapter->pvInterfaceAdapter = - kmalloc(sizeof(S_INTERFACE_ADAPTER), GFP_KERNEL)) == NULL) - { - BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0, "Out of memory"); - AdapterFree (psAdapter); + psIntfAdapter = kzalloc(sizeof(S_INTERFACE_ADAPTER), GFP_KERNEL); + if (psIntfAdapter == NULL) { + dev_err(&udev->dev, DRV_NAME ": no memory for Interface adapter\n"); + AdapterFree(psAdapter); return -ENOMEM; } - memset(psAdapter->pvInterfaceAdapter, 0, sizeof(S_INTERFACE_ADAPTER)); - psIntfAdapter = InterfaceAdapterGet(psAdapter); + psAdapter->pvInterfaceAdapter = psIntfAdapter; psIntfAdapter->psAdapter = psAdapter; /* Store usb interface in Interface Adapter */ psIntfAdapter->interface = intf; usb_set_intfdata(intf, psIntfAdapter); - BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "psIntfAdapter 0x%p",psIntfAdapter); + BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, + "psIntfAdapter 0x%p\n", psIntfAdapter); retval = InterfaceAdapterInit(psIntfAdapter); - if(retval) - { + if (retval) { /* If the Firmware/Cfg File is not present - * then return success, let the application - * download the files. - */ - if(-ENOENT == retval){ - BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "File Not Found, Use App to Download\n"); + * then return success, let the application + * download the files. + */ + if (-ENOENT == retval) { + BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, + "File Not Found. Use app to download.\n"); return STATUS_SUCCESS; } - BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "InterfaceAdapterInit Failed \n"); + BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, + "InterfaceAdapterInit failed.\n"); usb_set_intfdata(intf, NULL); - udev = interface_to_usbdev (intf); + udev = interface_to_usbdev(intf); usb_put_dev(udev); - if(psAdapter->bUsbClassDriverRegistered == TRUE) - usb_deregister_dev (intf, &usbbcm_class); InterfaceAdapterFree(psIntfAdapter); - return retval ; + return retval; } - if(psAdapter->chip_id > T3) - { - uint32_t uiNackZeroLengthInt=4; - if(wrmalt(psAdapter, DISABLE_USB_ZERO_LEN_INT, &uiNackZeroLengthInt, sizeof(uiNackZeroLengthInt))) - { - return -EIO;; - } + if (psAdapter->chip_id > T3) { + uint32_t uiNackZeroLengthInt = 4; + + retval = wrmalt(psAdapter, DISABLE_USB_ZERO_LEN_INT, &uiNackZeroLengthInt, sizeof(uiNackZeroLengthInt)); + if (retval) + return retval; } - udev = interface_to_usbdev (intf); /* Check whether the USB-Device Supports remote Wake-Up */ - if(USB_CONFIG_ATT_WAKEUP & udev->actconfig->desc.bmAttributes) - { + if (USB_CONFIG_ATT_WAKEUP & udev->actconfig->desc.bmAttributes) { /* If Suspend then only support dynamic suspend */ - if(psAdapter->bDoSuspend) - { + if (psAdapter->bDoSuspend) { #ifdef CONFIG_PM pm_runtime_set_autosuspend_delay(&udev->dev, 0); intf->needs_remote_wakeup = 1; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35) - udev->autosuspend_disabled = 0; -#else usb_enable_autosuspend(udev); -#endif - device_init_wakeup(&intf->dev,1); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32) - usb_autopm_disable(intf); -#endif + device_init_wakeup(&intf->dev, 1); INIT_WORK(&psIntfAdapter->usbSuspendWork, putUsbSuspend); - BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Enabling USB Auto-Suspend\n"); + BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, + "Enabling USB Auto-Suspend\n"); #endif - } - else - { + } else { intf->needs_remote_wakeup = 0; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35) - udev->autosuspend_disabled = 1; -#else usb_disable_autosuspend(udev); -#endif } } - psAdapter->stDebugState.subtype[DBG_TYPE_INITEXIT] = 0x0; - return retval; + psAdapter->stDebugState.subtype[DBG_TYPE_INITEXIT] = 0x0; + return retval; } -static void usbbcm_disconnect (struct usb_interface *intf) +static void usbbcm_disconnect(struct usb_interface *intf) { - PS_INTERFACE_ADAPTER psIntfAdapter = NULL; - PMINI_ADAPTER psAdapter = NULL; - struct usb_device *udev = NULL; - PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); - - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Usb disconnected"); - if(intf == NULL) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "intf pointer is NULL"); - return; - } - psIntfAdapter = usb_get_intfdata(intf); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "psIntfAdapter 0x%p",psIntfAdapter); - if(psIntfAdapter == NULL) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "InterfaceAdapter pointer is NULL"); + PS_INTERFACE_ADAPTER psIntfAdapter = usb_get_intfdata(intf); + PMINI_ADAPTER psAdapter; + struct usb_device *udev = interface_to_usbdev(intf); + + if (psIntfAdapter == NULL) return; - } + psAdapter = psIntfAdapter->psAdapter; - if(psAdapter->bDoSuspend) + netif_device_detach(psAdapter->dev); + + if (psAdapter->bDoSuspend) intf->needs_remote_wakeup = 0; psAdapter->device_removed = TRUE ; usb_set_intfdata(intf, NULL); InterfaceAdapterFree(psIntfAdapter); - udev = interface_to_usbdev (intf); usb_put_dev(udev); - usb_deregister_dev (intf, &usbbcm_class); } - -static __inline int AllocUsbCb(PS_INTERFACE_ADAPTER psIntfAdapter) +static int AllocUsbCb(PS_INTERFACE_ADAPTER psIntfAdapter) { int i = 0; - for(i = 0; i < MAXIMUM_USB_TCB; i++) - { - if((psIntfAdapter->asUsbTcb[i].urb = - usb_alloc_urb(0, GFP_KERNEL)) == NULL) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Cant allocate Tx urb for index %d", i); + + for (i = 0; i < MAXIMUM_USB_TCB; i++) { + if ((psIntfAdapter->asUsbTcb[i].urb = + usb_alloc_urb(0, GFP_KERNEL)) == NULL) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, + "Can't allocate Tx urb for index %d\n", i); return -ENOMEM; } } - for(i = 0; i < MAXIMUM_USB_RCB; i++) - { + for (i = 0; i < MAXIMUM_USB_RCB; i++) { if ((psIntfAdapter->asUsbRcb[i].urb = - usb_alloc_urb(0, GFP_KERNEL)) == NULL) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Cant allocate Rx urb for index %d", i); + usb_alloc_urb(0, GFP_KERNEL)) == NULL) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, + "Can't allocate Rx urb for index %d\n", i); return -ENOMEM; } - if((psIntfAdapter->asUsbRcb[i].urb->transfer_buffer = - kmalloc(MAX_DATA_BUFFER_SIZE, GFP_KERNEL)) == NULL) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Cant allocate Rx buffer for index %d", i); + if ((psIntfAdapter->asUsbRcb[i].urb->transfer_buffer = + kmalloc(MAX_DATA_BUFFER_SIZE, GFP_KERNEL)) == NULL) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, + "Can't allocate Rx buffer for index %d\n", i); return -ENOMEM; } psIntfAdapter->asUsbRcb[i].urb->transfer_buffer_length = MAX_DATA_BUFFER_SIZE; @@ -372,77 +307,41 @@ static __inline int AllocUsbCb(PS_INTERFACE_ADAPTER psIntfAdapter) return 0; } - - static int device_run(PS_INTERFACE_ADAPTER psIntfAdapter) { - INT value = 0; + int value = 0; UINT status = STATUS_SUCCESS; status = InitCardAndDownloadFirmware(psIntfAdapter->psAdapter); - if(status != STATUS_SUCCESS) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "InitCardAndDownloadFirmware failed.\n"); + if (status != STATUS_SUCCESS) { + pr_err(DRV_NAME "InitCardAndDownloadFirmware failed.\n"); return status; } - if(TRUE == psIntfAdapter->psAdapter->fw_download_done) - { - - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Sending first interrupt URB down......"); - if(StartInterruptUrb(psIntfAdapter)) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Cannot send interrupt in URB"); + if (TRUE == psIntfAdapter->psAdapter->fw_download_done) { + if (StartInterruptUrb(psIntfAdapter)) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, + "Cannot send interrupt in URB\n"); } - //now register the cntrl interface. - //after downloading the f/w waiting for 5 sec to get the mailbox interrupt. + /* + * now register the cntrl interface. + * after downloading the f/w waiting for 5 sec to get the mailbox interrupt. + */ psIntfAdapter->psAdapter->waiting_to_fw_download_done = FALSE; value = wait_event_timeout(psIntfAdapter->psAdapter->ioctl_fw_dnld_wait_queue, psIntfAdapter->psAdapter->waiting_to_fw_download_done, 5*HZ); - if(value == 0) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"Mailbox Interrupt has not reached to Driver.."); - } - else - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"Got the mailbox interrupt ...Registering control interface...\n "); - } - if(register_control_device_interface(psIntfAdapter->psAdapter) < 0) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Register Control Device failed..."); + if (value == 0) + pr_err(DRV_NAME ": Timeout waiting for mailbox interrupt.\n"); + + if (register_control_device_interface(psIntfAdapter->psAdapter) < 0) { + pr_err(DRV_NAME ": Register Control Device failed.\n"); return -EIO; } } return 0; } -#if 0 -static void print_usb_interface_desc(struct usb_interface_descriptor *usb_intf_desc) -{ - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "**************** INTERFACE DESCRIPTOR *********************"); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bLength: %x", usb_intf_desc->bLength); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bDescriptorType: %x", usb_intf_desc->bDescriptorType); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bInterfaceNumber: %x", usb_intf_desc->bInterfaceNumber); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bAlternateSetting: %x", usb_intf_desc->bAlternateSetting); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bNumEndpoints: %x", usb_intf_desc->bNumEndpoints); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bInterfaceClass: %x", usb_intf_desc->bInterfaceClass); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bInterfaceSubClass: %x", usb_intf_desc->bInterfaceSubClass); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bInterfaceProtocol: %x", usb_intf_desc->bInterfaceProtocol); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "iInterface :%x\n",usb_intf_desc->iInterface); -} -static void print_usb_endpoint_descriptor(struct usb_endpoint_descriptor *usb_ep_desc) -{ - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "**************** ENDPOINT DESCRIPTOR *********************"); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bLength :%x ", usb_ep_desc->bLength); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bDescriptorType :%x ", usb_ep_desc->bDescriptorType); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bEndpointAddress :%x ", usb_ep_desc->bEndpointAddress); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bmAttributes :%x ", usb_ep_desc->bmAttributes); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "wMaxPacketSize :%x ",usb_ep_desc->wMaxPacketSize); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bInterval :%x ",usb_ep_desc->bInterval); -} - -#endif static inline int bcm_usb_endpoint_num(const struct usb_endpoint_descriptor *epd) { @@ -518,124 +417,111 @@ static inline int bcm_usb_endpoint_is_isoc_out(const struct usb_endpoint_descrip return (bcm_usb_endpoint_xfer_isoc(epd) && bcm_usb_endpoint_dir_out(epd)); } -INT InterfaceAdapterInit(PS_INTERFACE_ADAPTER psIntfAdapter) +static int InterfaceAdapterInit(PS_INTERFACE_ADAPTER psIntfAdapter) { struct usb_host_interface *iface_desc; struct usb_endpoint_descriptor *endpoint; size_t buffer_size; - ULONG value; - INT retval = 0; - INT usedIntOutForBulkTransfer = 0 ; + unsigned long value; + int retval = 0; + int usedIntOutForBulkTransfer = 0 ; BOOLEAN bBcm16 = FALSE; UINT uiData = 0; /* Store the usb dev into interface adapter */ - psIntfAdapter->udev = usb_get_dev(interface_to_usbdev( - psIntfAdapter->interface)); - - if((psIntfAdapter->udev->speed == USB_SPEED_HIGH)) - { - psIntfAdapter->bHighSpeedDevice = TRUE ; - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "MODEM IS CONFIGURED TO HIGH_SPEED "); - } - else - { - psIntfAdapter->bHighSpeedDevice = FALSE ; - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "MODEM IS CONFIGURED TO FULL_SPEED "); - } + psIntfAdapter->udev = usb_get_dev(interface_to_usbdev(psIntfAdapter->interface)); + psIntfAdapter->bHighSpeedDevice = (psIntfAdapter->udev->speed == USB_SPEED_HIGH); psIntfAdapter->psAdapter->interface_rdm = BcmRDM; psIntfAdapter->psAdapter->interface_wrm = BcmWRM; - if(rdmalt(psIntfAdapter->psAdapter, CHIP_ID_REG, (PUINT)&(psIntfAdapter->psAdapter->chip_id), sizeof(UINT)) < 0) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "CHIP ID Read Failed\n"); - return STATUS_FAILURE; - } - if(0xbece3200==(psIntfAdapter->psAdapter->chip_id&~(0xF0))) - { - psIntfAdapter->psAdapter->chip_id=(psIntfAdapter->psAdapter->chip_id&~(0xF0)); + retval = rdmalt(psIntfAdapter->psAdapter, CHIP_ID_REG, + (u32 *)&(psIntfAdapter->psAdapter->chip_id), sizeof(u32)); + if (retval) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, "CHIP ID Read Failed\n"); + return retval; } - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "First RDM Chip ID 0x%lx\n", psIntfAdapter->psAdapter->chip_id); + if (0xbece3200 == (psIntfAdapter->psAdapter->chip_id & ~(0xF0))) + psIntfAdapter->psAdapter->chip_id &= ~0xF0; - iface_desc = psIntfAdapter->interface->cur_altsetting; - //print_usb_interface_desc(&(iface_desc->desc)); + dev_info(&psIntfAdapter->udev->dev, "RDM Chip ID 0x%lx\n", + psIntfAdapter->psAdapter->chip_id); - if(psIntfAdapter->psAdapter->chip_id == T3B) - { + iface_desc = psIntfAdapter->interface->cur_altsetting; - // - //T3B device will have EEPROM,check if EEPROM is proper and BCM16 can be done or not. - // - BeceemEEPROMBulkRead(psIntfAdapter->psAdapter,&uiData,0x0,4); - if(uiData == BECM) - { + if (psIntfAdapter->psAdapter->chip_id == T3B) { + /* T3B device will have EEPROM, check if EEPROM is proper and BCM16 can be done or not. */ + BeceemEEPROMBulkRead(psIntfAdapter->psAdapter, &uiData, 0x0, 4); + if (uiData == BECM) bBcm16 = TRUE; - } - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Number of Altsetting aviailable for This Modem 0x%x\n", psIntfAdapter->interface->num_altsetting); - if(bBcm16 == TRUE) - { - //selecting alternate setting one as a default setting for High Speed modem. - if(psIntfAdapter->bHighSpeedDevice) - retval= usb_set_interface(psIntfAdapter->udev,DEFAULT_SETTING_0,ALTERNATE_SETTING_1); - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "BCM16 is Applicable on this dongle"); - if(retval || (psIntfAdapter->bHighSpeedDevice == FALSE)) - { + + dev_info(&psIntfAdapter->udev->dev, "number of alternate setting %d\n", + psIntfAdapter->interface->num_altsetting); + + if (bBcm16 == TRUE) { + /* selecting alternate setting one as a default setting for High Speed modem. */ + if (psIntfAdapter->bHighSpeedDevice) + retval= usb_set_interface(psIntfAdapter->udev, DEFAULT_SETTING_0, ALTERNATE_SETTING_1); + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, + "BCM16 is applicable on this dongle\n"); + if (retval || (psIntfAdapter->bHighSpeedDevice == FALSE)) { usedIntOutForBulkTransfer = EP2 ; endpoint = &iface_desc->endpoint[EP2].desc; - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Interface altsetting got failed or Moemd is configured to FS.hence will work on default setting 0 \n"); + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, + "Interface altsetting failed or modem is configured to Full Speed, hence will work on default setting 0\n"); /* - If Modem is high speed device EP2 should be INT OUT End point - If Mode is FS then EP2 should be bulk end point - */ - if(((psIntfAdapter->bHighSpeedDevice ==TRUE ) && (bcm_usb_endpoint_is_int_out(endpoint)== FALSE)) - ||((psIntfAdapter->bHighSpeedDevice == FALSE)&& (bcm_usb_endpoint_is_bulk_out(endpoint)== FALSE))) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"Configuring the EEPROM "); - //change the EP2, EP4 to INT OUT end point + * If Modem is high speed device EP2 should be INT OUT End point + * If Mode is FS then EP2 should be bulk end point + */ + if (((psIntfAdapter->bHighSpeedDevice == TRUE) && (bcm_usb_endpoint_is_int_out(endpoint) == FALSE)) + || ((psIntfAdapter->bHighSpeedDevice == FALSE) && (bcm_usb_endpoint_is_bulk_out(endpoint) == FALSE))) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, + "Configuring the EEPROM\n"); + /* change the EP2, EP4 to INT OUT end point */ ConfigureEndPointTypesThroughEEPROM(psIntfAdapter->psAdapter); /* - It resets the device and if any thing gets changed in USB descriptor it will show fail and - re-enumerate the device - */ + * It resets the device and if any thing gets changed + * in USB descriptor it will show fail and re-enumerate + * the device + */ retval = usb_reset_device(psIntfAdapter->udev); - if(retval) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "reset got failed. hence Re-enumerating the device \n"); + if (retval) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, + "reset failed. Re-enumerating the device.\n"); return retval ; } } - if((psIntfAdapter->bHighSpeedDevice == FALSE) && bcm_usb_endpoint_is_bulk_out(endpoint)) - { - // Once BULK is selected in FS mode. Revert it back to INT. Else USB_IF will fail. + if ((psIntfAdapter->bHighSpeedDevice == FALSE) && bcm_usb_endpoint_is_bulk_out(endpoint)) { + /* Once BULK is selected in FS mode. Revert it back to INT. Else USB_IF will fail. */ UINT _uiData = ntohl(EP2_CFG_INT); - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"Reverting Bulk to INT as it is FS MODE"); - BeceemEEPROMBulkWrite(psIntfAdapter->psAdapter,(PUCHAR)&_uiData,0x136,4,TRUE); + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, + "Reverting Bulk to INT as it is in Full Speed mode.\n"); + BeceemEEPROMBulkWrite(psIntfAdapter->psAdapter, (PUCHAR)&_uiData, 0x136, 4, TRUE); } - } - else - { + } else { usedIntOutForBulkTransfer = EP4 ; endpoint = &iface_desc->endpoint[EP4].desc; - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Choosing AltSetting as a default setting"); - if( bcm_usb_endpoint_is_int_out(endpoint) == FALSE) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, " Dongle does not have BCM16 Fix"); - //change the EP2, EP4 to INT OUT end point and use EP4 in altsetting + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, + "Choosing AltSetting as a default setting.\n"); + if (bcm_usb_endpoint_is_int_out(endpoint) == FALSE) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, + "Dongle does not have BCM16 Fix.\n"); + /* change the EP2, EP4 to INT OUT end point and use EP4 in altsetting */ ConfigureEndPointTypesThroughEEPROM(psIntfAdapter->psAdapter); /* - It resets the device and if any thing gets changed in USB descriptor it will show fail and - re-enumerate the device - */ + * It resets the device and if any thing gets changed in + * USB descriptor it will show fail and re-enumerate the + * device + */ retval = usb_reset_device(psIntfAdapter->udev); - if(retval) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "reset got failed. hence Re-enumerating the device \n"); - return retval ; + if (retval) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, + "reset failed. Re-enumerating the device.\n"); + return retval; } } @@ -644,99 +530,67 @@ INT InterfaceAdapterInit(PS_INTERFACE_ADAPTER psIntfAdapter) } iface_desc = psIntfAdapter->interface->cur_altsetting; - //print_usb_interface_desc(&(iface_desc->desc)); - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Current number of endpoints :%x \n", iface_desc->desc.bNumEndpoints); - for (value = 0; value < iface_desc->desc.bNumEndpoints; ++value) - { - endpoint = &iface_desc->endpoint[value].desc; - //print_usb_endpoint_descriptor(endpoint); - - if (!psIntfAdapter->sBulkIn.bulk_in_endpointAddr && bcm_usb_endpoint_is_bulk_in(endpoint)) - { - buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); - psIntfAdapter->sBulkIn.bulk_in_size = buffer_size; - psIntfAdapter->sBulkIn.bulk_in_endpointAddr = - endpoint->bEndpointAddress; - psIntfAdapter->sBulkIn.bulk_in_pipe = + + for (value = 0; value < iface_desc->desc.bNumEndpoints; ++value) { + endpoint = &iface_desc->endpoint[value].desc; + + if (!psIntfAdapter->sBulkIn.bulk_in_endpointAddr && bcm_usb_endpoint_is_bulk_in(endpoint)) { + buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); + psIntfAdapter->sBulkIn.bulk_in_size = buffer_size; + psIntfAdapter->sBulkIn.bulk_in_endpointAddr = endpoint->bEndpointAddress; + psIntfAdapter->sBulkIn.bulk_in_pipe = usb_rcvbulkpipe(psIntfAdapter->udev, psIntfAdapter->sBulkIn.bulk_in_endpointAddr); - } - - if (!psIntfAdapter->sBulkOut.bulk_out_endpointAddr && bcm_usb_endpoint_is_bulk_out(endpoint)) - { + } - psIntfAdapter->sBulkOut.bulk_out_endpointAddr = - endpoint->bEndpointAddress; - psIntfAdapter->sBulkOut.bulk_out_pipe = - usb_sndbulkpipe(psIntfAdapter->udev, + if (!psIntfAdapter->sBulkOut.bulk_out_endpointAddr && bcm_usb_endpoint_is_bulk_out(endpoint)) { + psIntfAdapter->sBulkOut.bulk_out_endpointAddr = endpoint->bEndpointAddress; + psIntfAdapter->sBulkOut.bulk_out_pipe = + usb_sndbulkpipe(psIntfAdapter->udev, psIntfAdapter->sBulkOut.bulk_out_endpointAddr); - } - - if (!psIntfAdapter->sIntrIn.int_in_endpointAddr && bcm_usb_endpoint_is_int_in(endpoint)) - { - buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); - psIntfAdapter->sIntrIn.int_in_size = buffer_size; - psIntfAdapter->sIntrIn.int_in_endpointAddr = - endpoint->bEndpointAddress; - psIntfAdapter->sIntrIn.int_in_interval = endpoint->bInterval; - psIntfAdapter->sIntrIn.int_in_buffer = + } + + if (!psIntfAdapter->sIntrIn.int_in_endpointAddr && bcm_usb_endpoint_is_int_in(endpoint)) { + buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); + psIntfAdapter->sIntrIn.int_in_size = buffer_size; + psIntfAdapter->sIntrIn.int_in_endpointAddr = endpoint->bEndpointAddress; + psIntfAdapter->sIntrIn.int_in_interval = endpoint->bInterval; + psIntfAdapter->sIntrIn.int_in_buffer = kmalloc(buffer_size, GFP_KERNEL); - if (!psIntfAdapter->sIntrIn.int_in_buffer) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Could not allocate interrupt_in_buffer"); - return -EINVAL; - } - //psIntfAdapter->sIntrIn.int_in_pipe = - } - - if (!psIntfAdapter->sIntrOut.int_out_endpointAddr && bcm_usb_endpoint_is_int_out(endpoint)) - { - - if( !psIntfAdapter->sBulkOut.bulk_out_endpointAddr && - (psIntfAdapter->psAdapter->chip_id == T3B) && (value == usedIntOutForBulkTransfer)) - { - //use first intout end point as a bulk out end point - buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); - psIntfAdapter->sBulkOut.bulk_out_size = buffer_size; - //printk("\nINT OUT Endpoing buffer size :%x endpoint :%x\n", buffer_size, value +1); - psIntfAdapter->sBulkOut.bulk_out_endpointAddr = - endpoint->bEndpointAddress; - psIntfAdapter->sBulkOut.bulk_out_pipe = - usb_sndintpipe(psIntfAdapter->udev, - psIntfAdapter->sBulkOut.bulk_out_endpointAddr); - psIntfAdapter->sBulkOut.int_out_interval = endpoint->bInterval; + if (!psIntfAdapter->sIntrIn.int_in_buffer) { + dev_err(&psIntfAdapter->udev->dev, + "could not allocate interrupt_in_buffer\n"); + return -EINVAL; + } + } + if (!psIntfAdapter->sIntrOut.int_out_endpointAddr && bcm_usb_endpoint_is_int_out(endpoint)) { + if (!psIntfAdapter->sBulkOut.bulk_out_endpointAddr && + (psIntfAdapter->psAdapter->chip_id == T3B) && (value == usedIntOutForBulkTransfer)) { + /* use first intout end point as a bulk out end point */ + buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); + psIntfAdapter->sBulkOut.bulk_out_size = buffer_size; + psIntfAdapter->sBulkOut.bulk_out_endpointAddr = endpoint->bEndpointAddress; + psIntfAdapter->sBulkOut.bulk_out_pipe = usb_sndintpipe(psIntfAdapter->udev, + psIntfAdapter->sBulkOut.bulk_out_endpointAddr); + psIntfAdapter->sBulkOut.int_out_interval = endpoint->bInterval; + } else if (value == EP6) { + buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); + psIntfAdapter->sIntrOut.int_out_size = buffer_size; + psIntfAdapter->sIntrOut.int_out_endpointAddr = endpoint->bEndpointAddress; + psIntfAdapter->sIntrOut.int_out_interval = endpoint->bInterval; + psIntfAdapter->sIntrOut.int_out_buffer= kmalloc(buffer_size, GFP_KERNEL); + if (!psIntfAdapter->sIntrOut.int_out_buffer) { + dev_err(&psIntfAdapter->udev->dev, + "could not allocate interrupt_out_buffer\n"); + return -EINVAL; + } } - else if(value == EP6) - { - buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); - psIntfAdapter->sIntrOut.int_out_size = buffer_size; - psIntfAdapter->sIntrOut.int_out_endpointAddr = - endpoint->bEndpointAddress; - psIntfAdapter->sIntrOut.int_out_interval = endpoint->bInterval; - psIntfAdapter->sIntrOut.int_out_buffer= kmalloc(buffer_size, - GFP_KERNEL); - if (!psIntfAdapter->sIntrOut.int_out_buffer) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Could not allocate interrupt_out_buffer"); - return -EINVAL; - } - } - } - } - usb_set_intfdata(psIntfAdapter->interface, psIntfAdapter); - retval = usb_register_dev(psIntfAdapter->interface, &usbbcm_class); - if(retval) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "usb register dev failed = %d", retval); - psIntfAdapter->psAdapter->bUsbClassDriverRegistered = FALSE; - return retval; - } - else - { - psIntfAdapter->psAdapter->bUsbClassDriverRegistered = TRUE; - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "usb dev registered"); + } } + usb_set_intfdata(psIntfAdapter->interface, psIntfAdapter); + psIntfAdapter->psAdapter->bcm_file_download = InterfaceFileDownload; psIntfAdapter->psAdapter->bcm_file_readback_from_chip = InterfaceFileReadbackFromChip; @@ -744,67 +598,51 @@ INT InterfaceAdapterInit(PS_INTERFACE_ADAPTER psIntfAdapter) retval = CreateInterruptUrb(psIntfAdapter); - if(retval) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Cannot create interrupt urb"); + if (retval) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, + "Cannot create interrupt urb\n"); return retval; } retval = AllocUsbCb(psIntfAdapter); - if(retval) - { + if (retval) return retval; - } - - retval = device_run(psIntfAdapter); - if(retval) - { - return retval; - } - - - return 0; + return device_run(psIntfAdapter); } -static int InterfaceSuspend (struct usb_interface *intf, pm_message_t message) +static int InterfaceSuspend(struct usb_interface *intf, pm_message_t message) { PS_INTERFACE_ADAPTER psIntfAdapter = usb_get_intfdata(intf); - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "=================================\n"); - //Bcm_kill_all_URBs(psIntfAdapter); + psIntfAdapter->bSuspended = TRUE; - if(TRUE == psIntfAdapter->bPreparingForBusSuspend) - { + if (TRUE == psIntfAdapter->bPreparingForBusSuspend) { psIntfAdapter->bPreparingForBusSuspend = FALSE; - if(psIntfAdapter->psAdapter->LinkStatus == LINKUP_DONE) - { + if (psIntfAdapter->psAdapter->LinkStatus == LINKUP_DONE) { psIntfAdapter->psAdapter->IdleMode = TRUE ; - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Host Entered in PMU Idle Mode.."); - } - else - { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, + "Host Entered in PMU Idle Mode.\n"); + } else { psIntfAdapter->psAdapter->bShutStatus = TRUE; - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Host Entered in PMU Shutdown Mode.."); + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, + "Host Entered in PMU Shutdown Mode.\n"); } } psIntfAdapter->psAdapter->bPreparingForLowPowerMode = FALSE; - //Signaling the control pkt path + /* Signaling the control pkt path */ wake_up(&psIntfAdapter->psAdapter->lowpower_mode_wait_queue); return 0; } -static int InterfaceResume (struct usb_interface *intf) +static int InterfaceResume(struct usb_interface *intf) { - PS_INTERFACE_ADAPTER psIntfAdapter = usb_get_intfdata(intf); - printk("=================================\n"); + PS_INTERFACE_ADAPTER psIntfAdapter = usb_get_intfdata(intf); mdelay(100); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32) - intf->pm_usage_cnt =1 ; -#endif + psIntfAdapter->bSuspended = FALSE; StartInterruptUrb(psIntfAdapter); @@ -812,57 +650,41 @@ static int InterfaceResume (struct usb_interface *intf) return 0; } -static int InterfacePreReset(struct usb_interface *intf) -{ - printk("====================>"); - return STATUS_SUCCESS; -} - -static int InterfacePostReset(struct usb_interface *intf) -{ - printk("Do Post chip reset setting here if it is required"); - return STATUS_SUCCESS; -} static struct usb_driver usbbcm_driver = { - .name = "usbbcm", - .probe = usbbcm_device_probe, - .disconnect = usbbcm_disconnect, - .suspend = InterfaceSuspend, - .resume = InterfaceResume, - .pre_reset=InterfacePreReset, - .post_reset=InterfacePostReset, - .id_table = InterfaceUsbtable, - .supports_autosuspend = 1, + .name = "usbbcm", + .probe = usbbcm_device_probe, + .disconnect = usbbcm_disconnect, + .suspend = InterfaceSuspend, + .resume = InterfaceResume, + .id_table = InterfaceUsbtable, + .supports_autosuspend = 1, }; +struct class *bcm_class; -/* -Function: InterfaceInitialize - -Description: This is the hardware specific initialization Function. - Registering the driver with NDIS , other device specific NDIS - and hardware initializations are done here. - -Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context +static __init int bcm_init(void) +{ + printk(KERN_INFO "%s: %s, %s\n", DRV_NAME, DRV_DESCRIPTION, DRV_VERSION); + printk(KERN_INFO "%s\n", DRV_COPYRIGHT); + bcm_class = class_create(THIS_MODULE, DRV_NAME); + if (IS_ERR(bcm_class)) { + printk(KERN_ERR DRV_NAME ": could not create class\n"); + return PTR_ERR(bcm_class); + } -Return: BCM_STATUS_SUCCESS - If Initialization of the - HW Interface was successful. - Other - If an error occured. -*/ -INT InterfaceInitialize(void) -{ -// BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Registering Usb driver!!"); return usb_register(&usbbcm_driver); } -INT InterfaceExit(void) +static __exit void bcm_exit(void) { - //PMINI_ADAPTER psAdapter = NULL; - int status = 0; - - //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Deregistering Usb driver!!"); usb_deregister(&usbbcm_driver); - return status; + class_destroy(bcm_class); } -MODULE_LICENSE ("GPL"); + +module_init(bcm_init); +module_exit(bcm_exit); + +MODULE_DESCRIPTION(DRV_DESCRIPTION); +MODULE_VERSION(DRV_VERSION); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/bcm/InterfaceInit.h b/drivers/staging/bcm/InterfaceInit.h index e7a96e5c5c50..058315a64c05 100644 --- a/drivers/staging/bcm/InterfaceInit.h +++ b/drivers/staging/bcm/InterfaceInit.h @@ -8,9 +8,11 @@ #define BCM_USB_PRODUCT_ID_T3 0x0300 #define BCM_USB_PRODUCT_ID_T3B 0x0210 #define BCM_USB_PRODUCT_ID_T3L 0x0220 +#define BCM_USB_PRODUCT_ID_SM250 0xbccd #define BCM_USB_PRODUCT_ID_SYM 0x15E #define BCM_USB_PRODUCT_ID_1901 0xe017 #define BCM_USB_PRODUCT_ID_226 0x0132 +#define BCM_USB_PRODUCT_ID_ZTE_TU25 0x0007 #define BCM_USB_MINOR_BASE 192 @@ -19,33 +21,7 @@ INT InterfaceInitialize(void); INT InterfaceExit(void); -#ifndef BCM_SHM_INTERFACE -INT InterfaceAdapterInit(PS_INTERFACE_ADAPTER Adapter); - INT usbbcm_worker_thread(PS_INTERFACE_ADAPTER psIntfAdapter); -VOID InterfaceAdapterFree(PS_INTERFACE_ADAPTER psIntfAdapter); - -#else -INT InterfaceAdapterInit(PMINI_ADAPTER Adapter); -#endif - - -#if 0 - -ULONG InterfaceClaimAdapter(PMINI_ADAPTER Adapter); - -VOID InterfaceDDRControllerInit(PMINI_ADAPTER Adapter); - -ULONG InterfaceReset(PMINI_ADAPTER Adapter); - -ULONG InterfaceRegisterResources(PMINI_ADAPTER Adapter); - -VOID InterfaceUnRegisterResources(PMINI_ADAPTER Adapter); - -ULONG InterfaceFirmwareDownload(PMINI_ADAPTER Adapter); - -#endif - #endif diff --git a/drivers/staging/bcm/InterfaceIsr.c b/drivers/staging/bcm/InterfaceIsr.c index f928fe4d564d..220ff922bdcf 100644 --- a/drivers/staging/bcm/InterfaceIsr.c +++ b/drivers/staging/bcm/InterfaceIsr.c @@ -1,6 +1,5 @@ #include "headers.h" -#ifndef BCM_SHM_INTERFACE static void read_int_callback(struct urb *urb/*, struct pt_regs *regs*/) { @@ -8,6 +7,10 @@ static void read_int_callback(struct urb *urb/*, struct pt_regs *regs*/) PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)urb->context; PMINI_ADAPTER Adapter = psIntfAdapter->psAdapter ; + if (netif_msg_intr(Adapter)) + pr_info(PFX "%s: interrupt status %d\n", + Adapter->dev->name, status); + if(Adapter->device_removed == TRUE) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Device has Got Removed."); @@ -87,7 +90,7 @@ static void read_int_callback(struct urb *urb/*, struct pt_regs *regs*/) BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Interrupt IN endPoint has got halted/stalled...need to clear this"); Adapter->bEndPointHalted = TRUE ; wake_up(&Adapter->tx_packet_wait_queue); - urb->status = STATUS_SUCCESS ;; + urb->status = STATUS_SUCCESS ; return; } /* software-driven interface shutdown */ @@ -164,40 +167,3 @@ INT StartInterruptUrb(PS_INTERFACE_ADAPTER psIntfAdapter) return status; } -/* -Function: InterfaceEnableInterrupt - -Description: This is the hardware specific Function for configuring - and enabling the interrupts on the device. - -Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context - - -Return: BCM_STATUS_SUCCESS - If configuring the interrupts was successful. - Other - If an error occured. -*/ - -void InterfaceEnableInterrupt(PMINI_ADAPTER Adapter) -{ - -} - -/* -Function: InterfaceDisableInterrupt - -Description: This is the hardware specific Function for disabling the interrupts on the device. - -Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context - - -Return: BCM_STATUS_SUCCESS - If disabling the interrupts was successful. - Other - If an error occured. -*/ - -void InterfaceDisableInterrupt(PMINI_ADAPTER Adapter) -{ - -} - -#endif - diff --git a/drivers/staging/bcm/InterfaceMisc.c b/drivers/staging/bcm/InterfaceMisc.c index 8fc893b37fe4..a51185b522cf 100644 --- a/drivers/staging/bcm/InterfaceMisc.c +++ b/drivers/staging/bcm/InterfaceMisc.c @@ -1,17 +1,5 @@ #include "headers.h" -#ifndef BCM_SHM_INTERFACE - -PS_INTERFACE_ADAPTER -InterfaceAdapterGet(PMINI_ADAPTER psAdapter) -{ - if(psAdapter == NULL) - { - return NULL; - } - return (PS_INTERFACE_ADAPTER)(psAdapter->pvInterfaceAdapter); -} - INT InterfaceRDM(PS_INTERFACE_ADAPTER psIntfAdapter, UINT addr, @@ -102,7 +90,7 @@ InterfaceWRM(PS_INTERFACE_ADAPTER psIntfAdapter, if((psIntfAdapter->psAdapter->StopAllXaction == TRUE) && (psIntfAdapter->psAdapter->chip_id >= T3LPB)) { BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, WRM, DBG_LVL_ALL,"Currently Xaction is not allowed on the bus..."); - return EACCES; + return -EACCES; } if(psIntfAdapter->bSuspended ==TRUE || psIntfAdapter->bPreparingForBusSuspend == TRUE) @@ -236,9 +224,7 @@ VOID Bcm_kill_all_URBs(PS_INTERFACE_ADAPTER psIntfAdapter) } /* Cancel All submitted TX URB's */ - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Cancelling All Submitted TX Urbs \n"); - - for(i = 0; i < MAXIMUM_USB_TCB; i++) + for(i = 0; i < MAXIMUM_USB_TCB; i++) { tempUrb = psIntfAdapter->asUsbTcb[i].urb; if(tempUrb) @@ -248,9 +234,6 @@ VOID Bcm_kill_all_URBs(PS_INTERFACE_ADAPTER psIntfAdapter) } } - - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Cancelling All submitted Rx Urbs \n"); - for(i = 0; i < MAXIMUM_USB_RCB; i++) { tempUrb = psIntfAdapter->asUsbRcb[i].urb; @@ -261,16 +244,11 @@ VOID Bcm_kill_all_URBs(PS_INTERFACE_ADAPTER psIntfAdapter) } } - atomic_set(&psIntfAdapter->uNumTcbUsed, 0); atomic_set(&psIntfAdapter->uCurrTcb, 0); atomic_set(&psIntfAdapter->uNumRcbUsed, 0); atomic_set(&psIntfAdapter->uCurrRcb, 0); - - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "TCB: used- %d cur-%d\n", atomic_read(&psIntfAdapter->uNumTcbUsed), atomic_read(&psIntfAdapter->uCurrTcb)); - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "RCB: used- %d cur-%d\n", atomic_read(&psIntfAdapter->uNumRcbUsed), atomic_read(&psIntfAdapter->uCurrRcb)); - } VOID putUsbSuspend(struct work_struct *work) @@ -282,9 +260,6 @@ VOID putUsbSuspend(struct work_struct *work) if(psIntfAdapter->bSuspended == FALSE) usb_autopm_put_interface(intf); - else - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Interface Resumed Completely\n"); } -#endif diff --git a/drivers/staging/bcm/InterfaceMisc.h b/drivers/staging/bcm/InterfaceMisc.h index 74c81d45cff4..6c9e39bf9889 100644 --- a/drivers/staging/bcm/InterfaceMisc.h +++ b/drivers/staging/bcm/InterfaceMisc.h @@ -1,9 +1,6 @@ #ifndef __INTERFACE_MISC_H #define __INTERFACE_MISC_H -PS_INTERFACE_ADAPTER -InterfaceAdapterGet(PMINI_ADAPTER psAdapter); - INT InterfaceRDM(PS_INTERFACE_ADAPTER psIntfAdapter, UINT addr, diff --git a/drivers/staging/bcm/InterfaceRx.c b/drivers/staging/bcm/InterfaceRx.c index 6fee9684f2ef..533f8ebe0f84 100644 --- a/drivers/staging/bcm/InterfaceRx.c +++ b/drivers/staging/bcm/InterfaceRx.c @@ -1,5 +1,15 @@ #include "headers.h" -extern int SearchVcid(PMINI_ADAPTER , unsigned short); + +static int SearchVcid(PMINI_ADAPTER Adapter,unsigned short usVcid) +{ + int iIndex=0; + + for(iIndex=(NO_OF_QUEUES-1);iIndex>=0;iIndex--) + if(Adapter->PackInfo[iIndex].usVCID_Value == usVcid) + return iIndex; + return NO_OF_QUEUES+1; + +} static PUSB_RCB @@ -38,13 +48,9 @@ static void read_bulk_callback(struct urb *urb) PMINI_ADAPTER Adapter = psIntfAdapter->psAdapter; PLEADER pLeader = urb->transfer_buffer; - - #if 0 - int *puiBuffer = NULL; - struct timeval tv; - memset(&tv, 0, sizeof(tv)); - do_gettimeofday(&tv); - #endif + if (unlikely(netif_msg_rx_status(Adapter))) + pr_info(PFX "%s: rx urb status %d length %d\n", + Adapter->dev->name, urb->status, urb->actual_length); if((Adapter->device_removed == TRUE) || (TRUE == Adapter->bEndPointHalted) || @@ -89,10 +95,10 @@ static void read_bulk_callback(struct urb *urb) BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "Leader Status:0x%hX, Length:0x%hX, VCID:0x%hX", pLeader->Status,pLeader->PLength,pLeader->Vcid); if(MAX_CNTL_PKT_SIZE < pLeader->PLength) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Corrupted leader length...%d\n", - pLeader->PLength); - atomic_inc(&Adapter->RxPacketDroppedCount); - atomic_add(pLeader->PLength, &Adapter->BadRxByteCount); + if (netif_msg_rx_err(Adapter)) + pr_info(PFX "%s: corrupted leader length...%d\n", + Adapter->dev->name, pLeader->PLength); + ++Adapter->dev->stats.rx_dropped; atomic_dec(&psIntfAdapter->uNumRcbUsed); return; } @@ -145,10 +151,9 @@ static void read_bulk_callback(struct urb *urb) skb_put (skb, pLeader->PLength + ETH_HLEN); Adapter->PackInfo[QueueIndex].uiTotalRxBytes+=pLeader->PLength; Adapter->PackInfo[QueueIndex].uiThisPeriodRxBytes+= pLeader->PLength; - atomic_add(pLeader->PLength, &Adapter->GoodRxByteCount); BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_RX, RX_DATA, DBG_LVL_ALL, "Recived Data pkt of len :0x%X", pLeader->PLength); - if(Adapter->if_up) + if(netif_running(Adapter->dev)) { /* Moving ahead by ETH_HLEN to the data ptr as received from FW */ skb_pull(skb, ETH_HLEN); @@ -173,9 +178,12 @@ static void read_bulk_callback(struct urb *urb) else { BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_RX, RX_DATA, DBG_LVL_ALL, "i/f not up hance freeing SKB..."); - bcm_kfree_skb(skb); + dev_kfree_skb(skb); } - atomic_inc(&Adapter->GoodRxPktCount); + + ++Adapter->dev->stats.rx_packets; + Adapter->dev->stats.rx_bytes += pLeader->PLength; + for(uiIndex = 0 ; uiIndex < MIBS_MAX_HIST_ENTRIES ; uiIndex++) { if((pLeader->PLength <= MIBS_PKTSIZEHIST_RANGE*(uiIndex+1)) diff --git a/drivers/staging/bcm/InterfaceTx.c b/drivers/staging/bcm/InterfaceTx.c index 771f7b34d2ec..a842de9de6b5 100644 --- a/drivers/staging/bcm/InterfaceTx.c +++ b/drivers/staging/bcm/InterfaceTx.c @@ -1,50 +1,5 @@ #include "headers.h" -#ifndef BCM_SHM_INTERFACE - -/* -Function: InterfaceTxDataPacket - -Description: This is the hardware specific Function for Transmitting - data packet to the device. - -Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context - PVOID Packet - Packet Containing the data to be transmitted - USHORT usVcid - VCID on which data packet is to be sent - - -Return: BCM_STATUS_SUCCESS - If Tx was successful. - Other - If an error occured. -*/ - -ULONG InterfaceTxDataPacket(PMINI_ADAPTER Adapter,PVOID Packet,USHORT usVcid) -{ - ULONG Status = 0; - return Status; -} - -/* -Function: InterfaceTxControlPacket - -Description: This is the hardware specific Function for Transmitting - control packet to the device. - -Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context - PVOID pvBuffer - Buffer containg control packet - UINT uiBufferLength - Buffer Length - -Return: BCM_STATUS_SUCCESS - If control packet transmit was successful. - Other - If an error occured. -*/ - -ULONG InterfaceTxControlPacket(PMINI_ADAPTER Adapter,PVOID pvBuffer,UINT uiBufferLength) -{ - ULONG Status = 0; - - - - return Status; -} /*this is transmit call-back(BULK OUT)*/ static void write_bulk_callback(struct urb *urb/*, struct pt_regs *regs*/) { @@ -54,10 +9,10 @@ static void write_bulk_callback(struct urb *urb/*, struct pt_regs *regs*/) PMINI_ADAPTER psAdapter = psIntfAdapter->psAdapter ; BOOLEAN bpowerDownMsg = FALSE ; PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); -#if 0 - struct timeval tv; - UINT time_ms = 0; -#endif + + if (unlikely(netif_msg_tx_done(Adapter))) + pr_info(PFX "%s: transmit status %d\n", Adapter->dev->name, urb->status); + if(urb->status != STATUS_SUCCESS) { if(urb->status == -EPIPE) @@ -78,11 +33,6 @@ static void write_bulk_callback(struct urb *urb/*, struct pt_regs *regs*/) if(TRUE == psAdapter->bPreparingForLowPowerMode) { - #if 0 - do_gettimeofday(&tv); - time_ms = tv.tv_sec *1000 + tv.tv_usec/1000; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, " %s Idle Mode ACK_Sent got from device at time :0x%x", __FUNCTION__, time_ms); - #endif if(((pControlMsg->szData[0] == GO_TO_IDLE_MODE_PAYLOAD) && (pControlMsg->szData[1] == TARGET_CAN_GO_TO_IDLE_MODE))) @@ -152,17 +102,12 @@ static void write_bulk_callback(struct urb *urb/*, struct pt_regs *regs*/) } err_exit : -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35) - usb_buffer_free(urb->dev, urb->transfer_buffer_length, - urb->transfer_buffer, urb->transfer_dma); -#else usb_free_coherent(urb->dev, urb->transfer_buffer_length, urb->transfer_buffer, urb->transfer_dma); -#endif } -static __inline PUSB_TCB GetBulkOutTcb(PS_INTERFACE_ADAPTER psIntfAdapter) +static PUSB_TCB GetBulkOutTcb(PS_INTERFACE_ADAPTER psIntfAdapter) { PUSB_TCB pTcb = NULL; UINT index = 0; @@ -183,20 +128,14 @@ static __inline PUSB_TCB GetBulkOutTcb(PS_INTERFACE_ADAPTER psIntfAdapter) return pTcb; } -static __inline int TransmitTcb(PS_INTERFACE_ADAPTER psIntfAdapter, PUSB_TCB pTcb, PVOID data, int len) +static int TransmitTcb(PS_INTERFACE_ADAPTER psIntfAdapter, PUSB_TCB pTcb, PVOID data, int len) { struct urb *urb = pTcb->urb; int retval = 0; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35) - urb->transfer_buffer = usb_buffer_alloc(psIntfAdapter->udev, len, - GFP_ATOMIC, &urb->transfer_dma); -#else urb->transfer_buffer = usb_alloc_coherent(psIntfAdapter->udev, len, GFP_ATOMIC, &urb->transfer_dma); -#endif - if (!urb->transfer_buffer) { BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Error allocating memory\n"); @@ -255,5 +194,4 @@ int InterfaceTransmitPacket(PVOID arg, PVOID data, UINT len) return TransmitTcb(psIntfAdapter, pTcb, data, len); } -#endif diff --git a/drivers/staging/bcm/InterfaceTx.h b/drivers/staging/bcm/InterfaceTx.h index 053f631e2042..273147577c17 100644 --- a/drivers/staging/bcm/InterfaceTx.h +++ b/drivers/staging/bcm/InterfaceTx.h @@ -3,11 +3,5 @@ INT InterfaceTransmitPacket(PVOID arg, PVOID data, UINT len); - -ULONG InterfaceTxDataPacket(PMINI_ADAPTER Adapter,PVOID Packet,USHORT usVcid); - -ULONG InterfaceTxControlPacket(PMINI_ADAPTER Adapter,PVOID pvBuffer,UINT uiBufferLength); - - #endif diff --git a/drivers/staging/bcm/Interfacemain.h b/drivers/staging/bcm/Interfacemain.h deleted file mode 100644 index e0db563c5e0f..000000000000 --- a/drivers/staging/bcm/Interfacemain.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _MAIN_ -#define _MAIN_ -#if 0 -typedef struct _MINI_ADAPTER -{ - S_INTERFACE_ADAPTER stInterfaceAdapter; -}MINI_ADAPTER,*PMINI_ADAPTER; - -#endif -#endif diff --git a/drivers/staging/bcm/LeakyBucket.c b/drivers/staging/bcm/LeakyBucket.c index cae382313ce9..f4cf41c0e46b 100644 --- a/drivers/staging/bcm/LeakyBucket.c +++ b/drivers/staging/bcm/LeakyBucket.c @@ -75,14 +75,14 @@ static VOID UpdateTokenCount(register PMINI_ADAPTER Adapter) * Returns - The number of bytes allowed for transmission. * ***********************************************************************/ -static __inline ULONG GetSFTokenCount(PMINI_ADAPTER Adapter, PacketInfo *psSF) +static ULONG GetSFTokenCount(PMINI_ADAPTER Adapter, PacketInfo *psSF) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IsPacketAllowedForFlow ===>"); /* Validate the parameters */ if(NULL == Adapter || (psSF < Adapter->PackInfo && (uintptr_t)psSF > (uintptr_t) &Adapter->PackInfo[HiPriority])) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IPAFF: Got wrong Parameters:Adapter: %p, QIndex: %ld\n", Adapter, (psSF-Adapter->PackInfo)); + BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IPAFF: Got wrong Parameters:Adapter: %p, QIndex: %zd\n", Adapter, (psSF-Adapter->PackInfo)); return 0; } @@ -94,51 +94,27 @@ static __inline ULONG GetSFTokenCount(PMINI_ADAPTER Adapter, PacketInfo *psSF) } else { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "Not enough tokens in queue %ld Available %u\n", + BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "Not enough tokens in queue %zd Available %u\n", psSF-Adapter->PackInfo, psSF->uiCurrentTokenCount); psSF->uiPendedLast = 1; } } else { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IPAFF: Queue %ld not valid\n", psSF-Adapter->PackInfo); + BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IPAFF: Queue %zd not valid\n", psSF-Adapter->PackInfo); } BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IsPacketAllowedForFlow <==="); return 0; } -static __inline void RemovePacketFromQueue(PacketInfo *pPackInfo , struct sk_buff *Packet) -{ - struct sk_buff *psQueueCurrent=NULL, *psLastQueueNode=NULL; - psQueueCurrent = pPackInfo->FirstTxQueue; - while(psQueueCurrent) - { - if(Packet == psQueueCurrent) - { - if(psQueueCurrent == pPackInfo->FirstTxQueue) - { - pPackInfo->FirstTxQueue=psQueueCurrent->next; - if(psQueueCurrent==pPackInfo->LastTxQueue) - pPackInfo->LastTxQueue=NULL; - } - else - { - psLastQueueNode->next=psQueueCurrent->next; - } - break; - } - psLastQueueNode = psQueueCurrent; - psQueueCurrent=psQueueCurrent->next; - } -} /** @ingroup tx_functions This function despatches packet from the specified queue. @return Zero(success) or Negative value(failure) */ -static __inline INT SendPacketFromQueue(PMINI_ADAPTER Adapter,/**<Logical Adapter*/ - PacketInfo *psSF, /**<Queue identifier*/ - struct sk_buff* Packet) /**<Pointer to the packet to be sent*/ +static INT SendPacketFromQueue(PMINI_ADAPTER Adapter,/**<Logical Adapter*/ + PacketInfo *psSF, /**<Queue identifier*/ + struct sk_buff* Packet) /**<Pointer to the packet to be sent*/ { INT Status=STATUS_FAILURE; UINT uiIndex =0,PktLen = 0; @@ -180,8 +156,7 @@ static __inline INT SendPacketFromQueue(PMINI_ADAPTER Adapter,/**<Logical Adapte * Returns - None. * ****************************************************************************/ -static __inline VOID CheckAndSendPacketFromIndex -(PMINI_ADAPTER Adapter, PacketInfo *psSF) +static VOID CheckAndSendPacketFromIndex(PMINI_ADAPTER Adapter, PacketInfo *psSF) { struct sk_buff *QueuePacket=NULL; char *pControlPacket = NULL; @@ -189,7 +164,7 @@ static __inline VOID CheckAndSendPacketFromIndex int iPacketLen=0; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "%ld ====>", (psSF-Adapter->PackInfo)); + BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "%zd ====>", (psSF-Adapter->PackInfo)); if((psSF != &Adapter->PackInfo[HiPriority]) && Adapter->LinkUpStatus && atomic_read(&psSF->uiPerSFTxResourceCount))//Get data packet { if(!psSF->ucDirection ) @@ -197,10 +172,8 @@ static __inline VOID CheckAndSendPacketFromIndex BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "UpdateTokenCount "); if(Adapter->IdleMode || Adapter->bPreparingForLowPowerMode) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Device is in Idle Mode..Hence blocking Data Packets..\n"); - return; - } + return; /* in idle mode */ + // Check for Free Descriptors if(atomic_read(&Adapter->CurrNumFreeTxDesc) <= MINIMUM_PENDING_DESCRIPTORS) { @@ -208,9 +181,6 @@ static __inline VOID CheckAndSendPacketFromIndex return ; } -#if 0 - PruneQueue(Adapter,(psSF-Adapter->PackInfo)); -#endif spin_lock_bh(&psSF->SFQueueLock); QueuePacket=psSF->FirstTxQueue; @@ -240,7 +210,7 @@ static __inline VOID CheckAndSendPacketFromIndex } else { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "For Queue: %ld\n", psSF-Adapter->PackInfo); + BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "For Queue: %zd\n", psSF-Adapter->PackInfo); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "\nAvailable Tokens = %d required = %d\n", psSF->uiCurrentTokenCount, iPacketLen); //this part indicates that becuase of non-availability of the tokens @@ -290,17 +260,6 @@ static __inline VOID CheckAndSendPacketFromIndex } } } - - if(Status != STATUS_SUCCESS) //Tx of data packet to device Failed - { - if(Adapter->bcm_jiffies == 0) - Adapter->bcm_jiffies = jiffies; - } - else - { - Adapter->bcm_jiffies = 0; - } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "<====="); } @@ -387,12 +346,7 @@ VOID transmit_packets(PMINI_ADAPTER Adapter) if(exit_flag == TRUE ) break ; }/* end of inner while loop */ - if(Adapter->bcm_jiffies == 0 && - atomic_read(&Adapter->TotalPacketCount) != 0 && - uiPrevTotalCount == atomic_read(&Adapter->TotalPacketCount)) - { - Adapter->bcm_jiffies = jiffies; - } + update_per_cid_rx (Adapter); Adapter->txtransmit_running = 0; BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "<======"); diff --git a/drivers/staging/bcm/Macros.h b/drivers/staging/bcm/Macros.h index 0241234605f1..feb351578c8b 100644 --- a/drivers/staging/bcm/Macros.h +++ b/drivers/staging/bcm/Macros.h @@ -4,10 +4,6 @@ #ifndef __MACROS_H__ #define __MACROS_H__ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) -#define kthread_run(threadfn,data,datafmt)(struct task_struct *)kernel_thread(threadfn,data,0) -#endif - #define TX_TIMER_PERIOD 10 //10 msec #define MAX_CLASSIFIERS 100 //#define MAX_CLASSIFIERS_PER_SF 20 @@ -17,10 +13,9 @@ #define MAX_DATA_PKTS 200 #define MAX_ETH_SIZE 1536 #define MAX_CNTL_PKT_SIZE 2048 -/* TIMER RELATED */ -#define JIFFIES_2_QUADPART() (ULONG)(jiffies * 10000) // jiffies(1msec) to Quadpart(100nsec) #define MTU_SIZE 1400 +#define TX_QLEN 5 #define MAC_ADDR_REGISTER 0xbf60d000 @@ -266,7 +261,7 @@ typedef enum _E_PHS_DSC_ACTION #define FIRMWARE_BEGIN_ADDR 0xBFC00000 -#define INVALID_QUEUE_INDEX (USHORT)-1 +#define INVALID_QUEUE_INDEX NO_OF_QUEUES #define INVALID_PID (pid_t)-1 #define DDR_80_MHZ 0 @@ -300,12 +295,7 @@ typedef enum _E_PHS_DSC_ACTION /* Idle Mode Related Registers */ #define DEBUG_INTERRUPT_GENERATOR_REGISTOR 0x0F00007C -#ifdef BCM_SHM_INTERFACE -#define SW_ABORT_IDLEMODE_LOC 0xbfc02f9c -#define CPE_VIRTUAL_MAILBOX_REG 0xBFC02E58 -#else #define SW_ABORT_IDLEMODE_LOC 0x0FF01FFC -#endif #define SW_ABORT_IDLEMODE_PATTERN 0xd0ea1d1e #define DEVICE_INT_OUT_EP_REG0 0x0F011870 @@ -355,12 +345,7 @@ typedef enum ePMU_MODES HYBRID_MODE_6 = 2 }PMU_MODE; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) -#define MAX_RDM_WRM_RETIRES 16 -#else #define MAX_RDM_WRM_RETIRES 1 -#endif - enum eAbortPattern { ABORT_SHUTDOWN_MODE = 1, @@ -369,27 +354,6 @@ enum eAbortPattern { ABORT_IDLE_SYNCDOWN = 3 }; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) - #define GET_BCM_ADAPTER(net_dev) ({\ - PMINI_ADAPTER __Adapter = NULL; \ - if (net_dev) { \ - __Adapter = (PMINI_ADAPTER)(net_dev->priv); \ - } \ - else { \ - __Adapter = NULL; \ - }__Adapter;} ) -#else - #define GET_BCM_ADAPTER(net_dev) ({\ - PMINI_ADAPTER __Adapter = NULL; \ - if (net_dev) { \ - __Adapter = (PMINI_ADAPTER)(*((unsigned long *)netdev_priv(net_dev))); \ - } \ - else { \ - __Adapter = NULL; \ - }__Adapter;}) - - -#endif /* Offsets used by driver in skb cb variable */ #define SKB_CB_CLASSIFICATION_OFFSET 0 diff --git a/drivers/staging/bcm/Makefile b/drivers/staging/bcm/Makefile index c3ae25af670a..652b7f87737c 100644 --- a/drivers/staging/bcm/Makefile +++ b/drivers/staging/bcm/Makefile @@ -6,7 +6,7 @@ obj-$(CONFIG_BCM_WIMAX) += bcm_wimax.o bcm_wimax-y := InterfaceDld.o InterfaceIdleMode.o InterfaceInit.o InterfaceRx.o \ InterfaceIsr.o InterfaceMisc.o InterfaceTx.o \ - Arp.o CmHost.o Debug.o IPv6Protocol.o Qos.o Transmit.o\ + CmHost.o IPv6Protocol.o Qos.o Transmit.o\ Bcmnet.o DDRInit.o HandleControlPacket.o\ LeakyBucket.o Misc.o sort.o Bcmchar.o hostmibs.o PHSModule.o\ - Osal_Misc.o led_control.o nvm.o vendorspecificextn.o + led_control.o nvm.o vendorspecificextn.o diff --git a/drivers/staging/bcm/Misc.c b/drivers/staging/bcm/Misc.c index 22550f745917..f585aae9cf8b 100644 --- a/drivers/staging/bcm/Misc.c +++ b/drivers/staging/bcm/Misc.c @@ -1,5 +1,12 @@ #include "headers.h" +static int BcmFileDownload(PMINI_ADAPTER Adapter, const char *path, + unsigned int loc); +static VOID doPowerAutoCorrection(PMINI_ADAPTER psAdapter); +static void HandleShutDownModeRequest(PMINI_ADAPTER Adapter,PUCHAR pucBuffer); +static int bcm_parse_target_params(PMINI_ADAPTER Adapter); +static void beceem_protocol_reset (PMINI_ADAPTER Adapter); + static VOID default_wimax_protocol_initialize(PMINI_ADAPTER Adapter) { @@ -60,21 +67,11 @@ InitAdapter(PMINI_ADAPTER psAdapter) //init_waitqueue_head(&psAdapter->device_wake_queue); psAdapter->fw_download_done=FALSE; - psAdapter->pvOsDepData = (PLINUX_DEP_DATA) kmalloc(sizeof(LINUX_DEP_DATA), - GFP_KERNEL); - - if(psAdapter->pvOsDepData == NULL) - { - BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Linux Specific Data allocation failed"); - return -ENOMEM; - } - memset(psAdapter->pvOsDepData, 0, sizeof(LINUX_DEP_DATA)); default_wimax_protocol_initialize(psAdapter); for (i=0;i<MAX_CNTRL_PKTS;i++) { - psAdapter->txctlpacket[i] = (char *)kmalloc(MAX_CNTL_PKT_SIZE, - GFP_KERNEL); + psAdapter->txctlpacket[i] = kmalloc(MAX_CNTL_PKT_SIZE, GFP_KERNEL); if(!psAdapter->txctlpacket[i]) { BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "No More Cntl pkts got, max got is %d", i); @@ -117,7 +114,7 @@ InitAdapter(PMINI_ADAPTER psAdapter) VOID AdapterFree(PMINI_ADAPTER Adapter) { - INT count = 0; + int count; beceem_protocol_reset(Adapter); @@ -125,72 +122,66 @@ VOID AdapterFree(PMINI_ADAPTER Adapter) if(Adapter->control_packet_handler && !IS_ERR(Adapter->control_packet_handler)) kthread_stop (Adapter->control_packet_handler); + if(Adapter->transmit_packet_thread && !IS_ERR(Adapter->transmit_packet_thread)) - kthread_stop (Adapter->transmit_packet_thread); - wake_up(&Adapter->process_read_wait_queue); + kthread_stop (Adapter->transmit_packet_thread); + + wake_up(&Adapter->process_read_wait_queue); + if(Adapter->LEDInfo.led_thread_running & (BCM_LED_THREAD_RUNNING_ACTIVELY | BCM_LED_THREAD_RUNNING_INACTIVELY)) kthread_stop (Adapter->LEDInfo.led_cntrl_threadid); - bcm_unregister_networkdev(Adapter); + + unregister_networkdev(Adapter); + + /* FIXME: use proper wait_event and refcounting */ while(atomic_read(&Adapter->ApplicationRunning)) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Waiting for Application to close.. %d\n",atomic_read(&Adapter->ApplicationRunning)); msleep(100); } unregister_control_device_interface(Adapter); - if(Adapter->dev && !IS_ERR(Adapter->dev)) - free_netdev(Adapter->dev); - if(Adapter->pstargetparams != NULL) - { - bcm_kfree(Adapter->pstargetparams); - } + + kfree(Adapter->pstargetparams); + for (count =0;count < MAX_CNTRL_PKTS;count++) - { - if(Adapter->txctlpacket[count]) - bcm_kfree(Adapter->txctlpacket[count]); - } + kfree(Adapter->txctlpacket[count]); + FreeAdapterDsxBuffer(Adapter); - if(Adapter->pvOsDepData) - bcm_kfree (Adapter->pvOsDepData); - if(Adapter->pvInterfaceAdapter) - bcm_kfree(Adapter->pvInterfaceAdapter); + + kfree(Adapter->pvInterfaceAdapter); //Free the PHS Interface PhsCleanup(&Adapter->stBCMPhsContext); -#ifndef BCM_SHM_INTERFACE BcmDeAllocFlashCSStructure(Adapter); -#endif - bcm_kfree (Adapter); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "<========\n"); + free_netdev(Adapter->dev); } - -int create_worker_threads(PMINI_ADAPTER psAdapter) +static int create_worker_threads(PMINI_ADAPTER psAdapter) { - BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Init Threads..."); // Rx Control Packets Processing psAdapter->control_packet_handler = kthread_run((int (*)(void *)) - control_packet_handler, psAdapter, "CtrlPktHdlr"); + control_packet_handler, psAdapter, "%s-rx", DRV_NAME); if(IS_ERR(psAdapter->control_packet_handler)) { - BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "No Kernel Thread, but still returning success\n"); + pr_notice(DRV_NAME ": could not create control thread\n"); return PTR_ERR(psAdapter->control_packet_handler); } + // Tx Thread psAdapter->transmit_packet_thread = kthread_run((int (*)(void *)) - tx_pkt_handler, psAdapter, "TxPktThread"); + tx_pkt_handler, psAdapter, "%s-tx", DRV_NAME); if(IS_ERR (psAdapter->transmit_packet_thread)) { - BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "No Kernel Thread, but still returning success"); + pr_notice(DRV_NAME ": could not creat transmit thread\n"); kthread_stop(psAdapter->control_packet_handler); return PTR_ERR(psAdapter->transmit_packet_thread); } return 0; } - -static inline struct file *open_firmware_file(PMINI_ADAPTER Adapter, char *path) +static struct file *open_firmware_file(PMINI_ADAPTER Adapter, const char *path) { struct file *flp=NULL; mm_segment_t oldfs; @@ -200,26 +191,20 @@ static inline struct file *open_firmware_file(PMINI_ADAPTER Adapter, char *path) set_fs(oldfs); if(IS_ERR(flp)) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Unable To Open File %s, err %lx", - path, PTR_ERR(flp)); - flp = NULL; - } - else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Got file descriptor pointer of %s!", - path); + pr_err(DRV_NAME "Unable To Open File %s, err %ld", + path, PTR_ERR(flp)); + flp = NULL; } - if(Adapter->device_removed) - { - flp = NULL; - } + + if(Adapter->device_removed) + flp = NULL; return flp; } -int BcmFileDownload(PMINI_ADAPTER Adapter,/**< Logical Adapter */ - char *path, /**< path to image file */ +static int BcmFileDownload(PMINI_ADAPTER Adapter,/**< Logical Adapter */ + const char *path, /**< path to image file */ unsigned int loc /**< Download Address on the chip*/ ) { @@ -248,9 +233,7 @@ int BcmFileDownload(PMINI_ADAPTER Adapter,/**< Logical Adapter */ goto exit_download; } oldfs=get_fs();set_fs(get_ds()); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) vfs_llseek(flp, 0, 0); -#endif set_fs(oldfs); if(Adapter->bcm_file_readback_from_chip(Adapter->pvInterfaceAdapter, flp, loc)) @@ -265,29 +248,8 @@ exit_download: if(flp && !(IS_ERR(flp))) filp_close(flp, current->files); set_fs(oldfs); - do_gettimeofday(&tv); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "file download done at %lx", ((tv.tv_sec * 1000) + - (tv.tv_usec/1000))); - return errorno; -} - -void bcm_kfree_skb(struct sk_buff *skb) -{ - if(skb) - { - kfree_skb(skb); - } - skb = NULL ; -} - -VOID bcm_kfree(VOID *ptr) -{ - if(ptr) - { - kfree(ptr); - } - ptr = NULL ; + return errorno; } /** @@ -395,13 +357,6 @@ INT CopyBufferToControlPacket(PMINI_ADAPTER Adapter,/**<Logical Adapter*/ /*Setting bIdleMode_tx_from_host to TRUE to indicate LED control thread to represent the wake up from idlemode is from host*/ //Adapter->LEDInfo.bIdleMode_tx_from_host = TRUE; -#if 0 - if(STATUS_SUCCESS != InterfaceIdleModeWakeup(Adapter)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Idle Mode Wake up Failed\n"); - return STATUS_FAILURE; - } -#endif Adapter->bWakeUpDevice = TRUE; wake_up(&Adapter->process_rx_cntrlpkt); @@ -489,9 +444,6 @@ INT CopyBufferToControlPacket(PMINI_ADAPTER Adapter,/**<Logical Adapter*/ atomic_inc(&Adapter->index_wr_txcntrlpkt); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Calling transmit_packets"); atomic_set(&Adapter->TxPktAvail, 1); -#ifdef BCM_SHM_INTERFACE - virtual_mail_box_interrupt(); -#endif wake_up(&Adapter->tx_packet_wait_queue); } else @@ -530,18 +482,6 @@ static VOID SendStatisticsPointerRequest(PMINI_ADAPTER Adapter, #endif -void SendLinkDown(PMINI_ADAPTER Adapter) -{ - LINK_REQUEST stLinkDownRequest; - memset(&stLinkDownRequest, 0, sizeof(LINK_REQUEST)); - stLinkDownRequest.Leader.Status=LINK_UP_CONTROL_REQ; - stLinkDownRequest.Leader.PLength=sizeof(ULONG);//minimum 4 bytes - stLinkDownRequest.szData[0]=LINK_DOWN_REQ_PAYLOAD; - Adapter->bLinkDownRequested = TRUE; - - CopyBufferToControlPacket(Adapter,&stLinkDownRequest); -} - /****************************************************************** * Function - LinkMessage() * @@ -552,7 +492,7 @@ void SendLinkDown(PMINI_ADAPTER Adapter) * * Returns - None. *******************************************************************/ -__inline VOID LinkMessage(PMINI_ADAPTER Adapter) +VOID LinkMessage(PMINI_ADAPTER Adapter) { PLINK_REQUEST pstLinkRequest=NULL; BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "=====>"); @@ -594,7 +534,7 @@ __inline VOID LinkMessage(PMINI_ADAPTER Adapter) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Calling CopyBufferToControlPacket"); CopyBufferToControlPacket(Adapter, pstLinkRequest); - bcm_kfree(pstLinkRequest); + kfree(pstLinkRequest); } BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "LinkMessage <====="); return; @@ -614,8 +554,8 @@ __inline VOID LinkMessage(PMINI_ADAPTER Adapter) VOID StatisticsResponse(PMINI_ADAPTER Adapter,PVOID pvBuffer) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s====>",__FUNCTION__); - Adapter->StatisticsPointer = ntohl(*(PULONG)pvBuffer); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Stats at %lx", Adapter->StatisticsPointer); + Adapter->StatisticsPointer = ntohl(*(__be32 *)pvBuffer); + BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Stats at %x", (UINT)Adapter->StatisticsPointer); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s <====",__FUNCTION__); return; } @@ -764,7 +704,7 @@ void SendIdleModeResponse(PMINI_ADAPTER Adapter) /* Wake the LED Thread with IDLEMODE_ENTER State */ Adapter->DriverState = LOWPOWER_MODE_ENTER; - 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);; + 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); wake_up(&Adapter->LEDInfo.notify_led_event); /* Wait for 1 SEC for LED to OFF */ @@ -787,12 +727,10 @@ void SendIdleModeResponse(PMINI_ADAPTER Adapter) down(&Adapter->rdmwrmsync); Adapter->bPreparingForLowPowerMode = TRUE; up(&Adapter->rdmwrmsync); -#ifndef BCM_SHM_INTERFACE //Killing all URBS. if(Adapter->bDoSuspend == TRUE) Bcm_kill_all_URBs((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter)); -#endif } else { @@ -811,9 +749,7 @@ void SendIdleModeResponse(PMINI_ADAPTER Adapter) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"fail to send the Idle mode Request \n"); Adapter->bPreparingForLowPowerMode = FALSE; -#ifndef BCM_SHM_INTERFACE StartInterruptUrb((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter)); -#endif } do_gettimeofday(&tv); 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); @@ -980,12 +916,10 @@ VOID DumpPackInfo(PMINI_ADAPTER Adapter) } - -__inline int reset_card_proc(PMINI_ADAPTER ps_adapter) +int reset_card_proc(PMINI_ADAPTER ps_adapter) { int retval = STATUS_SUCCESS; -#ifndef BCM_SHM_INTERFACE PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); PS_INTERFACE_ADAPTER psIntfAdapter = NULL; unsigned int value = 0, uiResetValue = 0; @@ -1006,11 +940,9 @@ __inline int reset_card_proc(PMINI_ADAPTER ps_adapter) wrmalt(ps_adapter, SYS_CFG, &value, sizeof(value)); } -#ifndef BCM_SHM_INTERFACE //killing all submitted URBs. psIntfAdapter->psAdapter->StopAllXaction = TRUE ; Bcm_kill_all_URBs(psIntfAdapter); -#endif /* Reset the UMA-B Device */ if(ps_adapter->chip_id >= T3LPB) { @@ -1111,11 +1043,10 @@ __inline int reset_card_proc(PMINI_ADAPTER ps_adapter) err_exit : psIntfAdapter->psAdapter->StopAllXaction = FALSE ; -#endif return retval; } -__inline int run_card_proc(PMINI_ADAPTER ps_adapter ) +int run_card_proc(PMINI_ADAPTER ps_adapter ) { unsigned int value=0; { @@ -1146,21 +1077,17 @@ __inline int run_card_proc(PMINI_ADAPTER ps_adapter ) int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter) { - UINT status = STATUS_SUCCESS; + int status; UINT value = 0; -#ifdef BCM_SHM_INTERFACE - unsigned char *pConfigFileAddr = (unsigned char *)CPE_MACXVI_CFG_ADDR; -#endif /* * Create the threads first and then download the * Firm/DDR Settings.. */ - if((status = create_worker_threads(ps_adapter))<0) - { - BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Cannot create thread"); + status = create_worker_threads(ps_adapter); + if (status<0) return status; - } + /* * For Downloading the Firm, parse the cfg file first. */ @@ -1169,7 +1096,6 @@ int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter) return status; } -#ifndef BCM_SHM_INTERFACE if(ps_adapter->chip_id >= T3LPB) { rdmalt(ps_adapter, SYS_CFG, &value, sizeof (value)); @@ -1187,7 +1113,7 @@ int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter) status = ddr_init(ps_adapter); if(status) { - BCM_DEBUG_PRINT (ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "ddr_init Failed\n"); + pr_err(DRV_NAME "ddr_init Failed\n"); return status; } @@ -1201,7 +1127,6 @@ int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter) BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Error downloading CFG file"); goto OUT; } - BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "CFG file downloaded"); if(register_networkdev(ps_adapter)) { @@ -1266,12 +1191,6 @@ int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter) goto OUT; } } -#if 0 - else if(psAdapter->eNVMType == NVM_EEPROM) - { - PropagateCalParamsFromEEPROMToMemory(); - } -#endif /* Download Firmare */ if ((status = BcmFileDownload( ps_adapter, BIN_FILE, FIRMWARE_BEGIN_ADDR))) @@ -1280,7 +1199,6 @@ int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter) goto OUT; } - BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "BIN file downloaded"); status = run_card_proc(ps_adapter); if(status) { @@ -1299,68 +1217,19 @@ OUT: wake_up(&ps_adapter->LEDInfo.notify_led_event); } -#else - - ps_adapter->bDDRInitDone = TRUE; - //Initializing the NVM. - BcmInitNVM(ps_adapter); - - //Propagating the cal param from Flash to DDR - value = 0; - wrmalt(ps_adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 4, &value, sizeof(value)); - wrmalt(ps_adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 8, &value, sizeof(value)); - - if(ps_adapter->eNVMType == NVM_FLASH) - { - status = PropagateCalParamsFromFlashToMemory(ps_adapter); - if(status) - { - printk("\nPropogation of Cal param from flash to DDR failed ..\n" ); - } - } - - //Copy config file param to DDR. - memcpy(pConfigFileAddr,ps_adapter->pstargetparams, sizeof(STARGETPARAMS)); - - if(register_networkdev(ps_adapter)) - { - BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Register Netdevice failed. Cleanup needs to be performed."); - return -EIO; - } - - - status = InitLedSettings (ps_adapter); - if(status) - { - BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_PRINTK, 0, 0,"INIT LED FAILED\n"); - return status; - } - - - if(register_control_device_interface(ps_adapter) < 0) - { - BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Register Control Device failed. Cleanup needs to be performed."); - return -EIO; - } - - ps_adapter->fw_download_done = TRUE; -#endif return status; } -int bcm_parse_target_params(PMINI_ADAPTER Adapter) +static int bcm_parse_target_params(PMINI_ADAPTER Adapter) { -#ifdef BCM_SHM_INTERFACE - extern void read_cfg_file(PMINI_ADAPTER Adapter); -#endif struct file *flp=NULL; mm_segment_t oldfs={0}; - char *buff = NULL; + char *buff; int len = 0; loff_t pos = 0; - buff=(PCHAR)kmalloc(BUFFER_1K, GFP_KERNEL); + buff=kmalloc(BUFFER_1K, GFP_KERNEL); if(!buff) { return -ENOMEM; @@ -1368,14 +1237,14 @@ int bcm_parse_target_params(PMINI_ADAPTER Adapter) if((Adapter->pstargetparams = kmalloc(sizeof(STARGETPARAMS), GFP_KERNEL)) == NULL) { - bcm_kfree(buff); + kfree(buff); return -ENOMEM; } flp=open_firmware_file(Adapter, CFG_FILE); if(!flp) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "NOT ABLE TO OPEN THE %s FILE \n", CFG_FILE); - bcm_kfree(buff); - bcm_kfree(Adapter->pstargetparams); + kfree(buff); + kfree(Adapter->pstargetparams); Adapter->pstargetparams = NULL; return -ENOENT; } @@ -1386,8 +1255,8 @@ int bcm_parse_target_params(PMINI_ADAPTER Adapter) if(len != sizeof(STARGETPARAMS)) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Mismatch in Target Param Structure!\n"); - bcm_kfree(buff); - bcm_kfree(Adapter->pstargetparams); + kfree(buff); + kfree(Adapter->pstargetparams); Adapter->pstargetparams = NULL; filp_close(flp, current->files); return -ENOENT; @@ -1399,37 +1268,34 @@ int bcm_parse_target_params(PMINI_ADAPTER Adapter) * Values in Adapter->pstargetparams are in network byte order */ memcpy(Adapter->pstargetparams, buff, sizeof(STARGETPARAMS)); - bcm_kfree (buff); + kfree (buff); beceem_parse_target_struct(Adapter); -#ifdef BCM_SHM_INTERFACE - read_cfg_file(Adapter); - -#endif return STATUS_SUCCESS; } void beceem_parse_target_struct(PMINI_ADAPTER Adapter) { - UINT uiHostDrvrCfg6 =0, uiEEPROMFlag = 0;; + UINT uiHostDrvrCfg6 =0, uiEEPROMFlag = 0; if(ntohl(Adapter->pstargetparams->m_u32PhyParameter2) & AUTO_SYNC_DISABLE) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "AutoSyncup is Disabled\n"); + pr_info(DRV_NAME ": AutoSyncup is Disabled\n"); Adapter->AutoSyncup = FALSE; } else { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "AutoSyncup is Enabled\n"); + pr_info(DRV_NAME ": AutoSyncup is Enabled\n"); Adapter->AutoSyncup = TRUE; } + if(ntohl(Adapter->pstargetparams->HostDrvrConfig6) & AUTO_LINKUP_ENABLE) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Enabling autolink up"); + pr_info(DRV_NAME ": Enabling autolink up"); Adapter->AutoLinkUp = TRUE; } else { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Disabling autolink up"); + pr_info(DRV_NAME ": Disabling autolink up"); Adapter->AutoLinkUp = FALSE; } // Setting the DDR Setting.. @@ -1438,59 +1304,54 @@ void beceem_parse_target_struct(PMINI_ADAPTER Adapter) Adapter->ulPowerSaveMode = (ntohl(Adapter->pstargetparams->HostDrvrConfig6)>>12)&0x0F; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "DDR Setting: %x\n", Adapter->DDRSetting); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT,DBG_LVL_ALL, "Power Save Mode: %lx\n", - Adapter->ulPowerSaveMode); + pr_info(DRV_NAME ": DDR Setting: %x\n", Adapter->DDRSetting); + pr_info(DRV_NAME ": Power Save Mode: %lx\n", Adapter->ulPowerSaveMode); if(ntohl(Adapter->pstargetparams->HostDrvrConfig6) & AUTO_FIRM_DOWNLOAD) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Enabling Auto Firmware Download\n"); + pr_info(DRV_NAME ": Enabling Auto Firmware Download\n"); Adapter->AutoFirmDld = TRUE; } else { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Disabling Auto Firmware Download\n"); + pr_info(DRV_NAME ": Disabling Auto Firmware Download\n"); Adapter->AutoFirmDld = FALSE; } uiHostDrvrCfg6 = ntohl(Adapter->pstargetparams->HostDrvrConfig6); Adapter->bMipsConfig = (uiHostDrvrCfg6>>20)&0x01; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"MIPSConfig : 0x%X\n",Adapter->bMipsConfig); + pr_info(DRV_NAME ": MIPSConfig : 0x%X\n",Adapter->bMipsConfig); //used for backward compatibility. Adapter->bDPLLConfig = (uiHostDrvrCfg6>>19)&0x01; Adapter->PmuMode= (uiHostDrvrCfg6 >> 24 ) & 0x03; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "PMU MODE: %x", Adapter->PmuMode); + pr_info(DRV_NAME ": PMU MODE: %x", Adapter->PmuMode); if((uiHostDrvrCfg6 >> HOST_BUS_SUSPEND_BIT ) & (0x01)) { Adapter->bDoSuspend = TRUE; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Making DoSuspend TRUE as per configFile"); + pr_info(DRV_NAME ": Making DoSuspend TRUE as per configFile"); } uiEEPROMFlag = ntohl(Adapter->pstargetparams->m_u32EEPROMFlag); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "uiEEPROMFlag : 0x%X\n",uiEEPROMFlag); + pr_info(DRV_NAME ": uiEEPROMFlag : 0x%X\n",uiEEPROMFlag); Adapter->eNVMType = (NVM_TYPE)((uiEEPROMFlag>>4)&0x3); - Adapter->bStatusWrite = (uiEEPROMFlag>>6)&0x1; - //printk(("bStatusWrite : 0x%X\n", Adapter->bStatusWrite)); Adapter->uiSectorSizeInCFG = 1024*(0xFFFF & ntohl(Adapter->pstargetparams->HostDrvrConfig4)); - //printk(("uiSectorSize : 0x%X\n", Adapter->uiSectorSizeInCFG)); Adapter->bSectorSizeOverride =(bool) ((ntohl(Adapter->pstargetparams->HostDrvrConfig4))>>16)&0x1; - //printk(MP_INIT,("bSectorSizeOverride : 0x%X\n",Adapter->bSectorSizeOverride)); if(ntohl(Adapter->pstargetparams->m_u32PowerSavingModeOptions) &0x01) Adapter->ulPowerSaveMode = DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE; - //autocorrection part + if(Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE) doPowerAutoCorrection(Adapter); } -VOID doPowerAutoCorrection(PMINI_ADAPTER psAdapter) +static VOID doPowerAutoCorrection(PMINI_ADAPTER psAdapter) { - UINT reporting_mode = 0; + UINT reporting_mode; reporting_mode = ntohl(psAdapter->pstargetparams->m_u32PowerSavingModeOptions) &0x02 ; psAdapter->bIsAutoCorrectEnabled = !((char)(psAdapter->ulPowerSaveMode >> 3) & 0x1); @@ -1504,20 +1365,9 @@ VOID doPowerAutoCorrection(PMINI_ADAPTER psAdapter) if (psAdapter->bIsAutoCorrectEnabled && (psAdapter->chip_id >= T3LPB)) { //If reporting mode is enable, switch PMU to PMC - #if 0 - if(reporting_mode == FALSE) - { - psAdapter->ulPowerSaveMode = DEVICE_POWERSAVE_MODE_AS_PMU_SHUTDOWN; - psAdapter->bDoSuspend = TRUE; - BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"PMU selected ...."); - - } - else - #endif { psAdapter->ulPowerSaveMode = DEVICE_POWERSAVE_MODE_AS_PMU_CLOCK_GATING; psAdapter->bDoSuspend =FALSE; - BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"PMC selected.."); } @@ -1540,12 +1390,10 @@ VOID doPowerAutoCorrection(PMINI_ADAPTER psAdapter) #if 0 static unsigned char *ReadMacAddrEEPROM(PMINI_ADAPTER Adapter, ulong dwAddress) { - unsigned char *pucmacaddr = NULL; - int status = 0, i=0; - unsigned int temp =0; + int status = 0, i = 0; + unsigned int temp = 0; + unsigned char *pucmacaddr = kmalloc(MAC_ADDRESS_SIZE, GFP_KERNEL); - - pucmacaddr = (unsigned char *)kmalloc(MAC_ADDRESS_SIZE, GFP_KERNEL); if(!pucmacaddr) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "No Buffers to Read the EEPROM Address\n"); @@ -1558,7 +1406,7 @@ static unsigned char *ReadMacAddrEEPROM(PMINI_ADAPTER Adapter, ulong dwAddress) if(status != STATUS_SUCCESS) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "wrm Failed..\n"); - bcm_kfree(pucmacaddr); + kfree(pucmacaddr); pucmacaddr = NULL; goto OUT; } @@ -1568,7 +1416,7 @@ static unsigned char *ReadMacAddrEEPROM(PMINI_ADAPTER Adapter, ulong dwAddress) if(status != STATUS_SUCCESS) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "rdm Failed..\n"); - bcm_kfree(pucmacaddr); + kfree(pucmacaddr); pucmacaddr = NULL; goto OUT; } @@ -1580,43 +1428,6 @@ OUT: } #endif -#if 0 -INT ReadMacAddressFromEEPROM(PMINI_ADAPTER Adapter) -{ - unsigned char *puMacAddr = NULL; - int i =0; - - puMacAddr = ReadMacAddrEEPROM(Adapter,0x200); - if(!puMacAddr) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Couldn't retrieve the Mac Address\n"); - return STATUS_FAILURE; - } - else - { - if((puMacAddr[0] == 0x0 && puMacAddr[1] == 0x0 && - puMacAddr[2] == 0x0 && puMacAddr[3] == 0x0 && - puMacAddr[4] == 0x0 && puMacAddr[5] == 0x0) || - (puMacAddr[0] == 0xFF && puMacAddr[1] == 0xFF && - puMacAddr[2] == 0xFF && puMacAddr[3] == 0xFF && - puMacAddr[4] == 0xFF && puMacAddr[5] == 0xFF)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Invalid Mac Address\n"); - bcm_kfree(puMacAddr); - return STATUS_FAILURE; - } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "The Mac Address received is: \n"); - memcpy(Adapter->dev->dev_addr, puMacAddr, MAC_ADDRESS_SIZE); - for(i=0;i<MAC_ADDRESS_SIZE;i++) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"%02x ", Adapter->dev->dev_addr[i]); - } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"\n"); - bcm_kfree(puMacAddr); - } - return STATUS_SUCCESS; -} -#endif static void convertEndian(B_UINT8 rwFlag, PUINT puiBuffer, UINT uiByteCount) { @@ -1640,81 +1451,21 @@ int rdm(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize) { INT uiRetVal =0; -#ifndef BCM_SHM_INTERFACE uiRetVal = Adapter->interface_rdm(Adapter->pvInterfaceAdapter, uiAddress, pucBuff, sSize); if(uiRetVal < 0) return uiRetVal; -#else - int indx; - uiRetVal = STATUS_SUCCESS; - if(uiAddress & 0x10000000) { - // DDR Memory Access - uiAddress |= CACHE_ADDRESS_MASK; - memcpy(pucBuff,(unsigned char *)uiAddress ,sSize); - } - else { - // Register, SPRAM, Flash - uiAddress |= UNCACHE_ADDRESS_MASK; - if ((uiAddress & FLASH_ADDR_MASK) == (FLASH_CONTIGIOUS_START_ADDR_BCS350 & FLASH_ADDR_MASK)) - { - #if defined(FLASH_DIRECT_ACCESS) - memcpy(pucBuff,(unsigned char *)uiAddress ,sSize); - #else - printk("\nInvalid GSPI ACCESS :Addr :%#X", uiAddress); - uiRetVal = STATUS_FAILURE; - #endif - } - else if(((unsigned int )uiAddress & 0x3) || - ((unsigned int )pucBuff & 0x3) || - ((unsigned int )sSize & 0x3)) { - 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); - uiRetVal = STATUS_FAILURE; - } - else { - for (indx=0;indx<sSize;indx+=4){ - *(PUINT)(pucBuff + indx) = *(PUINT)(uiAddress + indx); - } - } - } -#endif return uiRetVal; } int wrm(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize) { int iRetVal; -#ifndef BCM_SHM_INTERFACE iRetVal = Adapter->interface_wrm(Adapter->pvInterfaceAdapter, uiAddress, pucBuff, sSize); -#else - int indx; - if(uiAddress & 0x10000000) { - // DDR Memory Access - uiAddress |= CACHE_ADDRESS_MASK; - memcpy((unsigned char *)(uiAddress),pucBuff,sSize); - } - else { - // Register, SPRAM, Flash - uiAddress |= UNCACHE_ADDRESS_MASK; - - if(((unsigned int )uiAddress & 0x3) || - ((unsigned int )pucBuff & 0x3) || - ((unsigned int )sSize & 0x3)) { - 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); - iRetVal = STATUS_FAILURE; - } - else { - for (indx=0;indx<sSize;indx+=4) { - *(PUINT)(uiAddress + indx) = *(PUINT)(pucBuff + indx); - } - } - } - iRetVal = STATUS_SUCCESS; -#endif return iRetVal; } @@ -1735,26 +1486,7 @@ int rdmalt (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size) return uiRetVal; } -int rdmWithLock(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize) -{ - - INT status = STATUS_SUCCESS ; - down(&Adapter->rdmwrmsync); - - if((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus ==TRUE) || - (Adapter->bPreparingForLowPowerMode ==TRUE)) - { - status = -EACCES; - goto exit; - } - status = rdm(Adapter, uiAddress, pucBuff, sSize); - -exit: - up(&Adapter->rdmwrmsync); - return status ; -} int wrmWithLock(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize) { INT status = STATUS_SUCCESS ; @@ -1921,10 +1653,8 @@ static VOID SendShutModeResponse(PMINI_ADAPTER Adapter) Adapter->bPreparingForLowPowerMode = TRUE; up(&Adapter->rdmwrmsync); //Killing all URBS. -#ifndef BCM_SHM_INTERFACE if(Adapter->bDoSuspend == TRUE) Bcm_kill_all_URBs((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter)); -#endif } else { @@ -1943,14 +1673,12 @@ static VOID SendShutModeResponse(PMINI_ADAPTER Adapter) BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL,"fail to send the Idle mode Request \n"); Adapter->bPreparingForLowPowerMode = FALSE; -#ifndef BCM_SHM_INTERFACE StartInterruptUrb((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter)); -#endif } } -void HandleShutDownModeRequest(PMINI_ADAPTER Adapter,PUCHAR pucBuffer) +static void HandleShutDownModeRequest(PMINI_ADAPTER Adapter,PUCHAR pucBuffer) { B_UINT32 uiResetValue = 0; @@ -2077,11 +1805,7 @@ void update_per_sf_desc_cnts( PMINI_ADAPTER Adapter) if(!atomic_read (&Adapter->uiMBupdate)) return; -#ifdef BCM_SHM_INTERFACE - if(rdmalt(Adapter, TARGET_SFID_TXDESC_MAP_LOC, (PUINT)uibuff, sizeof(UINT) * MAX_TARGET_DSX_BUFFERS)<0) -#else if(rdmaltWithLock(Adapter, TARGET_SFID_TXDESC_MAP_LOC, (PUINT)uibuff, sizeof(UINT) * MAX_TARGET_DSX_BUFFERS)<0) -#endif { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "rdm failed\n"); return; @@ -2107,9 +1831,7 @@ void update_per_sf_desc_cnts( PMINI_ADAPTER Adapter) void flush_queue(PMINI_ADAPTER Adapter, UINT iQIndex) { struct sk_buff* PacketToDrop=NULL; - struct net_device_stats* netstats=NULL; - - netstats = &((PLINUX_DEP_DATA)Adapter->pvOsDepData)->netstats; + struct net_device_stats* netstats = &Adapter->dev->stats; spin_lock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock); @@ -2130,25 +1852,23 @@ void flush_queue(PMINI_ADAPTER Adapter, UINT iQIndex) Adapter->PackInfo[iQIndex].uiDroppedCountBytes += PacketToDrop->len; Adapter->PackInfo[iQIndex].uiDroppedCountPackets++; - bcm_kfree_skb(PacketToDrop); + dev_kfree_skb(PacketToDrop); atomic_dec(&Adapter->TotalPacketCount); - atomic_inc(&Adapter->TxDroppedPacketCount); - } } spin_unlock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock); } -void beceem_protocol_reset (PMINI_ADAPTER Adapter) +static void beceem_protocol_reset (PMINI_ADAPTER Adapter) { - int i =0; + int i; - if(NULL != Adapter->dev) - { - netif_carrier_off(Adapter->dev); - netif_stop_queue(Adapter->dev); - } + if (netif_msg_link(Adapter)) + pr_notice(PFX "%s: protocol reset\n", Adapter->dev->name); + + netif_carrier_off(Adapter->dev); + netif_stop_queue(Adapter->dev); Adapter->IdleMode = FALSE; Adapter->LinkUpStatus = FALSE; @@ -2166,78 +1886,18 @@ void beceem_protocol_reset (PMINI_ADAPTER Adapter) Adapter->TimerActive = FALSE; memset(Adapter->astFragmentedPktClassifierTable, 0, - sizeof(S_FRAGMENTED_PACKET_INFO) * - MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES); + sizeof(S_FRAGMENTED_PACKET_INFO) * MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES); for(i = 0;i<HiPriority;i++) { //resetting only the first size (S_MIBS_SERVICEFLOW_TABLE) for the SF. // It is same between MIBs and SF. - memset((PVOID)&Adapter->PackInfo[i],0,sizeof(S_MIBS_SERVICEFLOW_TABLE)); + memset(&Adapter->PackInfo[i].stMibsExtServiceFlowTable, + 0, sizeof(S_MIBS_EXTSERVICEFLOW_PARAMETERS)); } } -#ifdef BCM_SHM_INTERFACE - - -#define GET_GTB_DIFF(start, end) \ -( (start) < (end) )? ( (end) - (start) ) : ( ~0x0 - ( (start) - (end)) +1 ) - -void usdelay ( unsigned int a) { - unsigned int start= *(unsigned int *)0xaf8051b4; - unsigned int end = start+1; - unsigned int diff = 0; - - while(1) { - end = *(unsigned int *)0xaf8051b4; - diff = (GET_GTB_DIFF(start,end))/80; - if (diff >= a) - break; - } -} -void read_cfg_file(PMINI_ADAPTER Adapter) { - - - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Config File Version = 0x%x \n",Adapter->pstargetparams->m_u32CfgVersion ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Center Frequency = 0x%x \n",Adapter->pstargetparams->m_u32CenterFrequency ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Band A Scan = 0x%x \n",Adapter->pstargetparams->m_u32BandAScan ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Band B Scan = 0x%x \n",Adapter->pstargetparams->m_u32BandBScan ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Band C Scan = 0x%x \n",Adapter->pstargetparams->m_u32BandCScan ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"ERTPS Options = 0x%x \n",Adapter->pstargetparams->m_u32ErtpsOptions ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"PHS Enable = 0x%x \n",Adapter->pstargetparams->m_u32PHSEnable ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Handoff Enable = 0x%x \n",Adapter->pstargetparams->m_u32HoEnable ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HO Reserved1 = 0x%x \n",Adapter->pstargetparams->m_u32HoReserved1 ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HO Reserved2 = 0x%x \n",Adapter->pstargetparams->m_u32HoReserved2 ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"MIMO Enable = 0x%x \n",Adapter->pstargetparams->m_u32MimoEnable ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"PKMv2 Enable = 0x%x \n",Adapter->pstargetparams->m_u32SecurityEnable ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Powersaving Modes Enable = 0x%x \n",Adapter->pstargetparams->m_u32PowerSavingModesEnable ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Power Saving Mode Options = 0x%x \n",Adapter->pstargetparams->m_u32PowerSavingModeOptions ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"ARQ Enable = 0x%x \n",Adapter->pstargetparams->m_u32ArqEnable ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Harq Enable = 0x%x \n",Adapter->pstargetparams->m_u32HarqEnable ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"EEPROM Flag = 0x%x \n",Adapter->pstargetparams->m_u32EEPROMFlag ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Customize = 0x%x \n",Adapter->pstargetparams->m_u32Customize ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Bandwidth = 0x%x \n",Adapter->pstargetparams->m_u32ConfigBW ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"ShutDown Timer Value = 0x%x \n",Adapter->pstargetparams->m_u32ShutDownInitThresholdTimer ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"RadioParameter = 0x%x \n",Adapter->pstargetparams->m_u32RadioParameter ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"PhyParameter1 = 0x%x \n",Adapter->pstargetparams->m_u32PhyParameter1 ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"PhyParameter2 = 0x%x \n",Adapter->pstargetparams->m_u32PhyParameter2 ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"PhyParameter3 = 0x%x \n",Adapter->pstargetparams->m_u32PhyParameter3 ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"m_u32TestOptions = 0x%x \n",Adapter->pstargetparams->m_u32TestOptions ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"MaxMACDataperDLFrame = 0x%x \n",Adapter->pstargetparams->m_u32MaxMACDataperDLFrame ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"MaxMACDataperULFrame = 0x%x \n",Adapter->pstargetparams->m_u32MaxMACDataperULFrame ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Corr2MacFlags = 0x%x \n",Adapter->pstargetparams->m_u32Corr2MacFlags ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HostDrvrConfig1 = 0x%x \n",Adapter->pstargetparams->HostDrvrConfig1 ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HostDrvrConfig2 = 0x%x \n",Adapter->pstargetparams->HostDrvrConfig2 ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HostDrvrConfig3 = 0x%x \n",Adapter->pstargetparams->HostDrvrConfig3 ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HostDrvrConfig4 = 0x%x \n",Adapter->pstargetparams->HostDrvrConfig4 ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HostDrvrConfig5 = 0x%x \n",Adapter->pstargetparams->HostDrvrConfig5 ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HostDrvrConfig6 = 0x%x \n",Adapter->pstargetparams->HostDrvrConfig6 ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Segmented PUSC Enable = 0x%x \n",Adapter->pstargetparams->m_u32SegmentedPUSCenable ); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"BamcEnable = 0x%x \n",Adapter->pstargetparams->m_u32BandAMCEnable ); -} - -#endif diff --git a/drivers/staging/bcm/Osal_Misc.c b/drivers/staging/bcm/Osal_Misc.c deleted file mode 100644 index feefd20a5291..000000000000 --- a/drivers/staging/bcm/Osal_Misc.c +++ /dev/null @@ -1,27 +0,0 @@ - /*++ - - Copyright (c) Beceem Communications Inc. - - Module Name: - WIN_Misc.c - - Abstract: - Implements the Miscelanneous OS Construts - Linked Lists - Dispatcher Objects(Events,Semaphores,Spin Locks and the like) - Files - - Revision History: - Who When What - -------- -------- ---------------------------------------------- - Name Date Created/reviewed/modified - Rajeev 24/1/08 Created - Notes: - - --*/ -#include "headers.h" - -bool OsalMemCompare(void *dest, void *src, UINT len) -{ - return (memcmp(src, dest, len)); -} diff --git a/drivers/staging/bcm/PHSModule.c b/drivers/staging/bcm/PHSModule.c index 8a38cf43e795..d1ca1912a74b 100644 --- a/drivers/staging/bcm/PHSModule.c +++ b/drivers/staging/bcm/PHSModule.c @@ -1,10 +1,54 @@ #include "headers.h" +static UINT CreateSFToClassifierRuleMapping(B_UINT16 uiVcid,B_UINT16 uiClsId,S_SERVICEFLOW_TABLE *psServiceFlowTable,S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI); + +static UINT CreateClassiferToPHSRuleMapping(B_UINT16 uiVcid,B_UINT16 uiClsId,S_SERVICEFLOW_ENTRY *pstServiceFlowEntry,S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI); + +static UINT CreateClassifierPHSRule(B_UINT16 uiClsId,S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule,E_CLASSIFIER_ENTRY_CONTEXT eClsContext,B_UINT8 u8AssociatedPHSI); + +static UINT UpdateClassifierPHSRule(B_UINT16 uiClsId,S_CLASSIFIER_ENTRY *pstClassifierEntry,S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI); + +static BOOLEAN ValidatePHSRuleComplete(S_PHS_RULE *psPhsRule); + +static BOOLEAN DerefPhsRule(B_UINT16 uiClsId,S_CLASSIFIER_TABLE *psaClassifiertable,S_PHS_RULE *pstPhsRule); + +static UINT GetClassifierEntry(S_CLASSIFIER_TABLE *pstClassifierTable,B_UINT32 uiClsid,E_CLASSIFIER_ENTRY_CONTEXT eClsContext, S_CLASSIFIER_ENTRY **ppstClassifierEntry); + +static UINT GetPhsRuleEntry(S_CLASSIFIER_TABLE *pstClassifierTable,B_UINT32 uiPHSI,E_CLASSIFIER_ENTRY_CONTEXT eClsContext,S_PHS_RULE **ppstPhsRule); + +static void free_phs_serviceflow_rules(S_SERVICEFLOW_TABLE *psServiceFlowRulesTable); + +static int phs_compress(S_PHS_RULE *phs_members,unsigned char *in_buf, + unsigned char *out_buf,unsigned int *header_size,UINT *new_header_size ); + + +static int verify_suppress_phsf(unsigned char *in_buffer,unsigned char *out_buffer, + unsigned char *phsf,unsigned char *phsm,unsigned int phss,unsigned int phsv,UINT *new_header_size ); + +static int phs_decompress(unsigned char *in_buf,unsigned char *out_buf,\ + S_PHS_RULE *phs_rules,UINT *header_size); + + +static ULONG PhsCompress(void* pvContext, + B_UINT16 uiVcid, + B_UINT16 uiClsId, + void *pvInputBuffer, + void *pvOutputBuffer, + UINT *pOldHeaderSize, + UINT *pNewHeaderSize ); + +static ULONG PhsDeCompress(void* pvContext, + B_UINT16 uiVcid, + void *pvInputBuffer, + void *pvOutputBuffer, + UINT *pInHeaderSize, + UINT *pOutHeaderSize); + + + #define IN #define OUT -void DumpDataPacketHeader(PUCHAR pPkt); - /* Function: PHSTransmit @@ -81,8 +125,6 @@ int PHSTransmit(PMINI_ADAPTER Adapter, { - //DumpDataPacketHeader(pucPHSPktHdrInBuf); - // Step 2 Supress Header using PHS and fill into intermediate ucaPHSPktHdrOutBuf. // Suppress only if IP Header and PHS Enabled For the Service Flow if(((usPacketType == ETHERNET_FRAMETYPE_IPV4) || @@ -120,15 +162,15 @@ int PHSTransmit(PMINI_ADAPTER Adapter, if(newPacket == NULL) return STATUS_FAILURE; - bcm_kfree_skb(Packet); + dev_kfree_skb(Packet); *pPacket = Packet = newPacket; pucPHSPktHdrInBuf = Packet->data + BytesToRemove; } numBytesCompressed = unPhsOldHdrSize - (unPHSNewPktHeaderLen+PHSI_LEN); - OsalMemMove(pucPHSPktHdrInBuf + numBytesCompressed, pucPHSPktHdrOutBuf, unPHSNewPktHeaderLen + PHSI_LEN); - OsalMemMove(Packet->data + numBytesCompressed, Packet->data, BytesToRemove); + memcpy(pucPHSPktHdrInBuf + numBytesCompressed, pucPHSPktHdrOutBuf, unPHSNewPktHeaderLen + PHSI_LEN); + memcpy(Packet->data + numBytesCompressed, Packet->data, BytesToRemove); skb_pull(Packet, numBytesCompressed); return STATUS_SUCCESS; @@ -223,23 +265,12 @@ int PHSRecieve(PMINI_ADAPTER Adapter, } } - OsalMemMove(packet->data, Adapter->ucaPHSPktRestoreBuf, nStandardPktHdrLen); + memcpy(packet->data, Adapter->ucaPHSPktRestoreBuf, nStandardPktHdrLen); } return STATUS_SUCCESS; } -void DumpDataPacketHeader(PUCHAR pPkt) -{ - struct iphdr *iphd = (struct iphdr*)pPkt; - PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"Phs Send/Recieve : IP Packet Hdr \n"); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"TOS : %x \n",iphd->tos); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"Src IP : %x \n",iphd->saddr); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"Dest IP : %x \n \n",iphd->daddr); - -} - void DumpFullPacket(UCHAR *pBuf,UINT nPktLen) { PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); @@ -270,15 +301,9 @@ int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension,PMINI_ADAPTER Adapter) return -EINVAL; pPhsdeviceExtension->pstServiceFlowPhsRulesTable = - (S_SERVICEFLOW_TABLE*)OsalMemAlloc(sizeof(S_SERVICEFLOW_TABLE), - PHS_MEM_TAG); + kzalloc(sizeof(S_SERVICEFLOW_TABLE), GFP_KERNEL); - if(pPhsdeviceExtension->pstServiceFlowPhsRulesTable) - { - OsalZeroMemory(pPhsdeviceExtension->pstServiceFlowPhsRulesTable, - sizeof(S_SERVICEFLOW_TABLE)); - } - else + if(!pPhsdeviceExtension->pstServiceFlowPhsRulesTable) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation ServiceFlowPhsRulesTable failed"); return -ENOMEM; @@ -288,14 +313,8 @@ int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension,PMINI_ADAPTER Adapter) for(i=0;i<MAX_SERVICEFLOWS;i++) { S_SERVICEFLOW_ENTRY sServiceFlow = pstServiceFlowTable->stSFList[i]; - sServiceFlow.pstClassifierTable = (S_CLASSIFIER_TABLE*)OsalMemAlloc( - sizeof(S_CLASSIFIER_TABLE), PHS_MEM_TAG); - if(sServiceFlow.pstClassifierTable) - { - OsalZeroMemory(sServiceFlow.pstClassifierTable,sizeof(S_CLASSIFIER_TABLE)); - pstServiceFlowTable->stSFList[i].pstClassifierTable = sServiceFlow.pstClassifierTable; - } - else + sServiceFlow.pstClassifierTable = kzalloc(sizeof(S_CLASSIFIER_TABLE), GFP_KERNEL); + if(!sServiceFlow.pstClassifierTable) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation failed"); free_phs_serviceflow_rules(pPhsdeviceExtension-> @@ -305,9 +324,7 @@ int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension,PMINI_ADAPTER Adapter) } } - - pPhsdeviceExtension->CompressedTxBuffer = - OsalMemAlloc(PHS_BUFFER_SIZE,PHS_MEM_TAG); + pPhsdeviceExtension->CompressedTxBuffer = kmalloc(PHS_BUFFER_SIZE, GFP_KERNEL); if(pPhsdeviceExtension->CompressedTxBuffer == NULL) { @@ -317,12 +334,11 @@ int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension,PMINI_ADAPTER Adapter) return -ENOMEM; } - pPhsdeviceExtension->UnCompressedRxBuffer = - OsalMemAlloc(PHS_BUFFER_SIZE,PHS_MEM_TAG); + pPhsdeviceExtension->UnCompressedRxBuffer = kmalloc(PHS_BUFFER_SIZE, GFP_KERNEL); if(pPhsdeviceExtension->UnCompressedRxBuffer == NULL) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation failed"); - OsalMemFree(pPhsdeviceExtension->CompressedTxBuffer,PHS_BUFFER_SIZE); + kfree(pPhsdeviceExtension->CompressedTxBuffer); free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable); pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL; return -ENOMEM; @@ -343,16 +359,11 @@ int PhsCleanup(IN PPHS_DEVICE_EXTENSION pPHSDeviceExt) pPHSDeviceExt->pstServiceFlowPhsRulesTable = NULL; } - if(pPHSDeviceExt->CompressedTxBuffer) - { - OsalMemFree(pPHSDeviceExt->CompressedTxBuffer,PHS_BUFFER_SIZE); - pPHSDeviceExt->CompressedTxBuffer = NULL; - } - if(pPHSDeviceExt->UnCompressedRxBuffer) - { - OsalMemFree(pPHSDeviceExt->UnCompressedRxBuffer,PHS_BUFFER_SIZE); - pPHSDeviceExt->UnCompressedRxBuffer = NULL; - } + kfree(pPHSDeviceExt->CompressedTxBuffer); + pPHSDeviceExt->CompressedTxBuffer = NULL; + + kfree(pPHSDeviceExt->UnCompressedRxBuffer); + pPHSDeviceExt->UnCompressedRxBuffer = NULL; return 0; } @@ -478,20 +489,12 @@ ULONG PhsDeletePHSRule(IN void* pvContext,IN B_UINT16 uiVcid,IN B_UINT8 u8PHSI) { if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].bUsed && pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule) { - if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex] - .pstPhsRule->u8PHSI == u8PHSI) - { - if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule - ->u8RefCnt) - pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule - ->u8RefCnt--; - if(0 == pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex] - .pstPhsRule->u8RefCnt) - OsalMemFree(pstClassifierRulesTable - ->stActivePhsRulesList[nClsidIndex].pstPhsRule, - sizeof(S_PHS_RULE)); - OsalZeroMemory(&pstClassifierRulesTable - ->stActivePhsRulesList[nClsidIndex], + if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8PHSI == u8PHSI) { + if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt) + pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt--; + if(0 == pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt) + kfree(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule); + memset(&pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex], 0, sizeof(S_CLASSIFIER_ENTRY)); } } @@ -548,10 +551,10 @@ ULONG PhsDeleteClassifierRule(IN void* pvContext,IN B_UINT16 uiVcid ,IN B_UINT16 if(pstClassifierEntry->pstPhsRule->u8RefCnt) pstClassifierEntry->pstPhsRule->u8RefCnt--; if(0==pstClassifierEntry->pstPhsRule->u8RefCnt) - OsalMemFree(pstClassifierEntry->pstPhsRule,sizeof(S_PHS_RULE)); + kfree(pstClassifierEntry->pstPhsRule); } - OsalZeroMemory(pstClassifierEntry,sizeof(S_CLASSIFIER_ENTRY)); + memset(pstClassifierEntry, 0, sizeof(S_CLASSIFIER_ENTRY)); } nClsidIndex = GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable, @@ -559,10 +562,8 @@ ULONG PhsDeleteClassifierRule(IN void* pvContext,IN B_UINT16 uiVcid ,IN B_UINT16 if((nClsidIndex != PHS_INVALID_TABLE_INDEX) && (!pstClassifierEntry->bUnclassifiedPHSRule)) { - if(pstClassifierEntry->pstPhsRule) - //Delete the classifier entry - OsalMemFree(pstClassifierEntry->pstPhsRule,sizeof(S_PHS_RULE)); - OsalZeroMemory(pstClassifierEntry,sizeof(S_CLASSIFIER_ENTRY)); + kfree(pstClassifierEntry->pstPhsRule); + memset(pstClassifierEntry, 0, sizeof(S_CLASSIFIER_ENTRY)); } } return lStatus; @@ -619,14 +620,11 @@ ULONG PhsDeleteSFRules(IN void* pvContext,IN B_UINT16 uiVcid) .pstPhsRule->u8RefCnt--; if(0==pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex] .pstPhsRule->u8RefCnt) - OsalMemFree(pstClassifierRulesTable - ->stActivePhsRulesList[nClsidIndex].pstPhsRule, - sizeof(S_PHS_RULE)); + kfree(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule); pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex] .pstPhsRule = NULL; } - OsalZeroMemory(&pstClassifierRulesTable - ->stActivePhsRulesList[nClsidIndex],sizeof(S_CLASSIFIER_ENTRY)); + memset(&pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex], 0, sizeof(S_CLASSIFIER_ENTRY)); if(pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex].pstPhsRule) { if(pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex] @@ -635,15 +633,12 @@ ULONG PhsDeleteSFRules(IN void* pvContext,IN B_UINT16 uiVcid) .pstPhsRule->u8RefCnt--; if(0 == pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex] .pstPhsRule->u8RefCnt) - OsalMemFree(pstClassifierRulesTable - ->stOldPhsRulesList[nClsidIndex].pstPhsRule, - sizeof(S_PHS_RULE)); + kfree(pstClassifierRulesTable + ->stOldPhsRulesList[nClsidIndex].pstPhsRule); pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex] .pstPhsRule = NULL; } - OsalZeroMemory(&pstClassifierRulesTable - ->stOldPhsRulesList[nClsidIndex], - sizeof(S_CLASSIFIER_ENTRY)); + memset(&pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex], 0, sizeof(S_CLASSIFIER_ENTRY)); } } pstServiceFlowEntry->bUsed = FALSE; @@ -849,7 +844,7 @@ ULONG PhsDeCompress(IN void* pvContext, // Does not return any value. //----------------------------------------------------------------------------- -void free_phs_serviceflow_rules(S_SERVICEFLOW_TABLE *psServiceFlowRulesTable) +static void free_phs_serviceflow_rules(S_SERVICEFLOW_TABLE *psServiceFlowRulesTable) { int i,j; PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); @@ -876,8 +871,7 @@ void free_phs_serviceflow_rules(S_SERVICEFLOW_TABLE *psServiceFlowRulesTable) ->u8RefCnt--; if(0==pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule ->u8RefCnt) - OsalMemFree(pstClassifierRulesTable->stActivePhsRulesList[j]. - pstPhsRule, sizeof(S_PHS_RULE)); + kfree(pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule); pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule = NULL; } if(pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule) @@ -888,24 +882,23 @@ void free_phs_serviceflow_rules(S_SERVICEFLOW_TABLE *psServiceFlowRulesTable) ->u8RefCnt--; if(0==pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule ->u8RefCnt) - OsalMemFree(pstClassifierRulesTable->stOldPhsRulesList[j] - .pstPhsRule,sizeof(S_PHS_RULE)); + kfree(pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule); pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule = NULL; } } - OsalMemFree(pstClassifierRulesTable,sizeof(S_CLASSIFIER_TABLE)); + kfree(pstClassifierRulesTable); stServiceFlowEntry.pstClassifierTable = pstClassifierRulesTable = NULL; } } } - OsalMemFree(psServiceFlowRulesTable,sizeof(S_SERVICEFLOW_TABLE)); - psServiceFlowRulesTable = NULL; + kfree(psServiceFlowRulesTable); + psServiceFlowRulesTable = NULL; } -BOOLEAN ValidatePHSRuleComplete(IN S_PHS_RULE *psPhsRule) +static BOOLEAN ValidatePHSRuleComplete(IN S_PHS_RULE *psPhsRule) { if(psPhsRule) { @@ -988,9 +981,9 @@ UINT GetClassifierEntry(IN S_CLASSIFIER_TABLE *pstClassifierTable, return PHS_INVALID_TABLE_INDEX; } -UINT GetPhsRuleEntry(IN S_CLASSIFIER_TABLE *pstClassifierTable, - IN B_UINT32 uiPHSI,E_CLASSIFIER_ENTRY_CONTEXT eClsContext, - OUT S_PHS_RULE **ppstPhsRule) +static UINT GetPhsRuleEntry(IN S_CLASSIFIER_TABLE *pstClassifierTable, + IN B_UINT32 uiPHSI,E_CLASSIFIER_ENTRY_CONTEXT eClsContext, + OUT S_PHS_RULE **ppstPhsRule) { int i; S_CLASSIFIER_ENTRY *pstClassifierRule = NULL; @@ -1102,7 +1095,7 @@ UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid, if(psPhsRule->u8PHSFLength) { //update PHSF - OsalMemMove(pstClassifierEntry->pstPhsRule->u8PHSF, + memcpy(pstClassifierEntry->pstPhsRule->u8PHSF, psPhsRule->u8PHSF , MAX_PHS_LENGTHS); } if(psPhsRule->u8PHSFLength) @@ -1114,7 +1107,7 @@ UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid, if(psPhsRule->u8PHSMLength) { //update PHSM - OsalMemMove(pstClassifierEntry->pstPhsRule->u8PHSM, + memcpy(pstClassifierEntry->pstPhsRule->u8PHSM, psPhsRule->u8PHSM, MAX_PHS_LENGTHS); } if(psPhsRule->u8PHSMLength) @@ -1147,7 +1140,7 @@ UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid, return uiStatus; } -UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId, +static UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId, S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule, E_CLASSIFIER_ENTRY_CONTEXT eClsContext,B_UINT8 u8AssociatedPHSI) { @@ -1234,8 +1227,7 @@ UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId, { if(psClassifierRules->pstPhsRule == NULL) { - psClassifierRules->pstPhsRule = (S_PHS_RULE*)OsalMemAlloc - (sizeof(S_PHS_RULE),PHS_MEM_TAG); + psClassifierRules->pstPhsRule = kmalloc(sizeof(S_PHS_RULE),GFP_KERNEL); if(NULL == psClassifierRules->pstPhsRule) return ERR_PHSRULE_MEMALLOC_FAIL; @@ -1247,7 +1239,7 @@ UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId, psClassifierRules->bUnclassifiedPHSRule = psPhsRule->bUnclassifiedPHSRule; /* Update The PHS rule */ - OsalMemMove(psClassifierRules->pstPhsRule, + memcpy(psClassifierRules->pstPhsRule, psPhsRule, sizeof(S_PHS_RULE)); } else @@ -1259,7 +1251,7 @@ UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId, } -UINT UpdateClassifierPHSRule(IN B_UINT16 uiClsId, +static UINT UpdateClassifierPHSRule(IN B_UINT16 uiClsId, IN S_CLASSIFIER_ENTRY *pstClassifierEntry, S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule, B_UINT8 u8AssociatedPHSI) @@ -1289,13 +1281,13 @@ UINT UpdateClassifierPHSRule(IN B_UINT16 uiClsId, //Step 2.a PHS Rule Does Not Exist .Create New PHS Rule for uiClsId if(FALSE == bPHSRuleOrphaned) { - pstClassifierEntry->pstPhsRule = (S_PHS_RULE*)OsalMemAlloc(sizeof(S_PHS_RULE),PHS_MEM_TAG); + pstClassifierEntry->pstPhsRule = kmalloc(sizeof(S_PHS_RULE), GFP_KERNEL); if(NULL == pstClassifierEntry->pstPhsRule) { return ERR_PHSRULE_MEMALLOC_FAIL; } } - OsalMemMove(pstClassifierEntry->pstPhsRule, psPhsRule, sizeof(S_PHS_RULE)); + memcpy(pstClassifierEntry->pstPhsRule, psPhsRule, sizeof(S_PHS_RULE)); } else @@ -1304,14 +1296,8 @@ UINT UpdateClassifierPHSRule(IN B_UINT16 uiClsId, BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nTying Classifier to Existing PHS Rule"); if(bPHSRuleOrphaned) { - if(pstClassifierEntry->pstPhsRule) - { - //Just Free the PHS Rule as Ref Count is Zero - OsalMemFree(pstClassifierEntry->pstPhsRule,sizeof(S_PHS_RULE)); + kfree(pstClassifierEntry->pstPhsRule); pstClassifierEntry->pstPhsRule = NULL; - - } - } pstClassifierEntry->pstPhsRule = pstAddPhsRule; @@ -1326,7 +1312,7 @@ UINT UpdateClassifierPHSRule(IN B_UINT16 uiClsId, } -BOOLEAN DerefPhsRule(IN B_UINT16 uiClsId,S_CLASSIFIER_TABLE *psaClassifiertable,S_PHS_RULE *pstPhsRule) +static BOOLEAN DerefPhsRule(IN B_UINT16 uiClsId,S_CLASSIFIER_TABLE *psaClassifiertable,S_PHS_RULE *pstPhsRule) { if(pstPhsRule==NULL) return FALSE; @@ -1345,22 +1331,6 @@ BOOLEAN DerefPhsRule(IN B_UINT16 uiClsId,S_CLASSIFIER_TABLE *psaClassifiertable } } -static void DumpBuffer(PVOID BuffVAddress, int xferSize) -{ - int i; - int iPrintLength; - PUCHAR temp=(PUCHAR)BuffVAddress; - PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); - iPrintLength=(xferSize<32?xferSize:32); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\n"); - - for (i=0;i < iPrintLength;i++) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "%x|",temp[i]); - } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\n"); -} - - void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension) { int i,j,k,l; @@ -1520,8 +1490,8 @@ int phs_decompress(unsigned char *in_buf,unsigned char *out_buf, // size-The number of bytes copied into the output buffer i.e dynamic fields // 0 -If PHS rule is NULL.If PHSV field is not set.If the verification fails. //----------------------------------------------------------------------------- -int phs_compress(S_PHS_RULE *phs_rule,unsigned char *in_buf - ,unsigned char *out_buf,UINT *header_size,UINT *new_header_size) +static int phs_compress(S_PHS_RULE *phs_rule,unsigned char *in_buf + ,unsigned char *out_buf,UINT *header_size,UINT *new_header_size) { unsigned char *old_addr = out_buf; int supress = 0; @@ -1581,9 +1551,9 @@ int phs_compress(S_PHS_RULE *phs_rule,unsigned char *in_buf // 0 -Packet has failed the verification. //----------------------------------------------------------------------------- - int verify_suppress_phsf(unsigned char *in_buffer,unsigned char *out_buffer, - unsigned char *phsf,unsigned char *phsm,unsigned int phss, - unsigned int phsv,UINT* new_header_size) +static int verify_suppress_phsf(unsigned char *in_buffer,unsigned char *out_buffer, + unsigned char *phsf,unsigned char *phsm,unsigned int phss, + unsigned int phsv,UINT* new_header_size) { unsigned int size=0; int bit,i=0; diff --git a/drivers/staging/bcm/PHSModule.h b/drivers/staging/bcm/PHSModule.h index bf2b5763252c..0dd05a7c55d9 100644 --- a/drivers/staging/bcm/PHSModule.h +++ b/drivers/staging/bcm/PHSModule.h @@ -27,19 +27,6 @@ void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension); int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension,PMINI_ADAPTER Adapter); -void free_phs_serviceflow_rules(S_SERVICEFLOW_TABLE *psServiceFlowRulesTable); - -int phs_compress(S_PHS_RULE *phs_members,unsigned char *in_buf, - unsigned char *out_buf,unsigned int *header_size,UINT *new_header_size ); - - -int verify_suppress_phsf(unsigned char *in_buffer,unsigned char *out_buffer, - unsigned char *phsf,unsigned char *phsm,unsigned int phss,unsigned int phsv,UINT *new_header_size ); - -int phs_decompress(unsigned char *in_buf,unsigned char *out_buf,\ - S_PHS_RULE *phs_rules,UINT *header_size); - - int PhsCleanup(PPHS_DEVICE_EXTENSION pPHSDeviceExt); //Utility Functions @@ -52,42 +39,10 @@ ULONG PhsDeleteClassifierRule(void* pvContext, B_UINT16 uiVcid ,B_UINT16 uiClsI ULONG PhsDeleteSFRules(void* pvContext,B_UINT16 uiVcid) ; -ULONG PhsCompress(void* pvContext, - B_UINT16 uiVcid, - B_UINT16 uiClsId, - void *pvInputBuffer, - void *pvOutputBuffer, - UINT *pOldHeaderSize, - UINT *pNewHeaderSize ); - -ULONG PhsDeCompress(void* pvContext, - B_UINT16 uiVcid, - void *pvInputBuffer, - void *pvOutputBuffer, - UINT *pInHeaderSize, - UINT *pOutHeaderSize); - - BOOLEAN ValidatePHSRule(S_PHS_RULE *psPhsRule); -BOOLEAN ValidatePHSRuleComplete(S_PHS_RULE *psPhsRule); - UINT GetServiceFlowEntry(S_SERVICEFLOW_TABLE *psServiceFlowTable,B_UINT16 uiVcid,S_SERVICEFLOW_ENTRY **ppstServiceFlowEntry); -UINT GetClassifierEntry(S_CLASSIFIER_TABLE *pstClassifierTable,B_UINT32 uiClsid,E_CLASSIFIER_ENTRY_CONTEXT eClsContext, S_CLASSIFIER_ENTRY **ppstClassifierEntry); - -UINT GetPhsRuleEntry(S_CLASSIFIER_TABLE *pstClassifierTable,B_UINT32 uiPHSI,E_CLASSIFIER_ENTRY_CONTEXT eClsContext,S_PHS_RULE **ppstPhsRule); - - -UINT CreateSFToClassifierRuleMapping(B_UINT16 uiVcid,B_UINT16 uiClsId,S_SERVICEFLOW_TABLE *psServiceFlowTable,S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI); - -UINT CreateClassiferToPHSRuleMapping(B_UINT16 uiVcid,B_UINT16 uiClsId,S_SERVICEFLOW_ENTRY *pstServiceFlowEntry,S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI); - -UINT CreateClassifierPHSRule(B_UINT16 uiClsId,S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule,E_CLASSIFIER_ENTRY_CONTEXT eClsContext,B_UINT8 u8AssociatedPHSI); - -UINT UpdateClassifierPHSRule(B_UINT16 uiClsId,S_CLASSIFIER_ENTRY *pstClassifierEntry,S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI); - -BOOLEAN DerefPhsRule(B_UINT16 uiClsId,S_CLASSIFIER_TABLE *psaClassifiertable,S_PHS_RULE *pstPhsRule); void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension); diff --git a/drivers/staging/bcm/Protocol.h b/drivers/staging/bcm/Protocol.h index 00f1cc12356a..b8a4009bdf0c 100644 --- a/drivers/staging/bcm/Protocol.h +++ b/drivers/staging/bcm/Protocol.h @@ -85,10 +85,10 @@ typedef struct _ETH_CS_ETH2_FRAME ETH_HEADER_STRUC EThHdr; } __attribute__((packed)) ETH_CS_ETH2_FRAME; +#define ETHERNET_FRAMETYPE_IPV4 ntohs(0x0800) +#define ETHERNET_FRAMETYPE_IPV6 ntohs(0x86dd) +#define ETHERNET_FRAMETYPE_802QVLAN ntohs(0x8100) -#define ETHERNET_FRAMETYPE_IPV4 ntohs(0x0800) -#define ETHERNET_FRAMETYPE_IPV6 ntohs(0x86dd) -#define ETHERNET_FRAMETYPE_802QVLAN 0x8100 //Per SF CS Specification Encodings typedef enum _E_SERVICEFLOW_CS_SPEC_ { diff --git a/drivers/staging/bcm/Prototypes.h b/drivers/staging/bcm/Prototypes.h index 70ec8bcafd1e..b80b806c90a3 100644 --- a/drivers/staging/bcm/Prototypes.h +++ b/drivers/staging/bcm/Prototypes.h @@ -1,23 +1,12 @@ #ifndef _PROTOTYPES_H_ #define _PROTOTYPES_H_ -int BcmFileDownload(PMINI_ADAPTER Adapter,/**< Logical Adapter */ - char *path, /**< path to image file */ - unsigned int loc /**< Download Address on the chip*/ - ); VOID LinkControlResponseMessage(PMINI_ADAPTER Adapter, PUCHAR pucBuffer); VOID StatisticsResponse(PMINI_ADAPTER Adapter,PVOID pvBuffer); VOID IdleModeResponse(PMINI_ADAPTER Adapter,PUINT puiBuffer); -void bcm_kfree_skb(struct sk_buff *skb); -VOID bcm_kfree(VOID *ptr); - - -VOID handle_rx_control_packet(PMINI_ADAPTER Adapter, /**<Pointer to the Adapter structure*/ - struct sk_buff *skb); /**<Pointer to the socket buffer*/ - int control_packet_handler (PMINI_ADAPTER Adapter); VOID DeleteAllClassifiersForSF(PMINI_ADAPTER Adapter,UINT uiSearchRuleIndex); @@ -38,25 +27,16 @@ VOID SortClassifiers(PMINI_ADAPTER Adapter); VOID flush_all_queues(PMINI_ADAPTER Adapter); -USHORT IpVersion4(PMINI_ADAPTER Adapter, /**< Pointer to the driver control structure */ - struct iphdr *iphd, /**<Pointer to the IP Hdr of the packet*/ - S_CLASSIFIER_RULE *pstClassifierRule ); - -VOID PruneQueue(PMINI_ADAPTER Adapter,/**<Pointer to the driver control structure*/ - INT iIndex/**<Queue Index*/ - ); - VOID PruneQueueAllSF(PMINI_ADAPTER Adapter); INT SearchSfid(PMINI_ADAPTER Adapter,UINT uiSfid); -USHORT GetPacketQueueIndex(PMINI_ADAPTER Adapter, /**<Pointer to the driver control structure */ - struct sk_buff* Packet /**< Pointer to the Packet to be sent*/ - ); +USHORT ClassifyPacket(PMINI_ADAPTER Adapter,struct sk_buff* skb); + +BOOLEAN MatchSrcPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort); +BOOLEAN MatchDestPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort); +BOOLEAN MatchProtocol(S_CLASSIFIER_RULE *pstClassifierRule,UCHAR ucProtocol); -VOID -reply_to_arp_request(struct sk_buff *skb /**<sk_buff of ARP request*/ - ); INT SetupNextSend(PMINI_ADAPTER Adapter, /**<Logical Adapter*/ struct sk_buff *Packet, /**<data buffer*/ @@ -70,11 +50,9 @@ INT SendControlPacket(PMINI_ADAPTER Adapter, /**<Logical Adapter*/ char *pControlPacket/**<Control Packet*/ ); -INT bcm_transmit(struct sk_buff *skb, /**< skb */ - struct net_device *dev /**< net device pointer */ - ); int register_networkdev(PMINI_ADAPTER Adapter); +void unregister_networkdev(PMINI_ADAPTER Adapter); INT AllocAdapterDsxBuffer(PMINI_ADAPTER Adapter); @@ -82,8 +60,6 @@ VOID AdapterFree(PMINI_ADAPTER Adapter); INT FreeAdapterDsxBuffer(PMINI_ADAPTER Adapter); -int create_worker_threads(PMINI_ADAPTER psAdapter); - int tx_pkt_handler(PMINI_ADAPTER Adapter); int reset_card_proc(PMINI_ADAPTER Adapter ); @@ -92,7 +68,6 @@ int run_card_proc(PMINI_ADAPTER Adapter ); int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter); -int bcm_parse_target_params(PMINI_ADAPTER Adapter); INT ReadMacAddressFromNVM(PMINI_ADAPTER Adapter); @@ -110,26 +85,15 @@ int rdmalt (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize); int get_dsx_sf_data_to_application(PMINI_ADAPTER Adapter, UINT uiSFId, void __user * user_buffer); -void SendLinkDown(PMINI_ADAPTER Adapter); - void SendIdleModeResponse(PMINI_ADAPTER Adapter); -void HandleShutDownModeRequest(PMINI_ADAPTER Adapter,PUCHAR pucBuffer); - -int ProcessGetHostMibs(PMINI_ADAPTER Adapter, PVOID ioBuffer, - ULONG inputBufferLength); -int GetDroppedAppCntrlPktMibs(PVOID ioBuffer, PPER_TARANG_DATA pTarang); +int ProcessGetHostMibs(PMINI_ADAPTER Adapter, S_MIBS_HOST_STATS_MIBS *buf); +void GetDroppedAppCntrlPktMibs(S_MIBS_HOST_STATS_MIBS *ioBuffer, PPER_TARANG_DATA pTarang); void beceem_parse_target_struct(PMINI_ADAPTER Adapter); -void doPowerAutoCorrection(PMINI_ADAPTER psAdapter); - int bcm_ioctl_fw_download(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwInfo); -void bcm_unregister_networkdev(PMINI_ADAPTER Adapter); - -int SearchVcid(PMINI_ADAPTER Adapter,unsigned short usVcid); - void CopyMIBSExtendedSFParameters(PMINI_ADAPTER Adapter, CServiceFlowParamSI *psfLocalSet, UINT uiSearchRuleIndex); @@ -149,7 +113,6 @@ void update_per_sf_desc_cnts( PMINI_ADAPTER Adapter); void ClearTargetDSXBuffer(PMINI_ADAPTER Adapter,B_UINT16 TID,BOOLEAN bFreeAll); -void beceem_protocol_reset (PMINI_ADAPTER Adapter); void flush_queue(PMINI_ADAPTER Adapter, UINT iQIndex); @@ -164,31 +127,11 @@ INT BeceemEEPROMBulkRead( UINT uiNumBytes); -INT BeceemFlashBulkRead( - PMINI_ADAPTER Adapter, - PUINT pBuffer, - UINT uiOffset, - UINT uiNumBytes); - -UINT BcmGetEEPROMSize(PMINI_ADAPTER Adapter); INT WriteBeceemEEPROM(PMINI_ADAPTER Adapter,UINT uiEEPROMOffset, UINT uiData); -UINT BcmGetFlashSize(PMINI_ADAPTER Adapter); - -UINT BcmGetFlashSectorSize(PMINI_ADAPTER Adapter, UINT FlashSectorSizeSig, UINT FlashSectorSize); - -INT BeceemFlashBulkWrite( - PMINI_ADAPTER Adapter, - PUINT pBuffer, - UINT uiOffset, - UINT uiNumBytes, - BOOLEAN bVerify); - INT PropagateCalParamsFromFlashToMemory(PMINI_ADAPTER Adapter); -INT PropagateCalParamsFromEEPROMToMemory(PMINI_ADAPTER Adapter); - INT BeceemEEPROMBulkWrite( PMINI_ADAPTER Adapter, @@ -198,11 +141,8 @@ INT BeceemEEPROMBulkWrite( BOOLEAN bVerify); -INT ReadBeceemEEPROMBulk(PMINI_ADAPTER Adapter,UINT dwAddress, UINT *pdwData, UINT dwNumData); - INT ReadBeceemEEPROM(PMINI_ADAPTER Adapter,UINT dwAddress, UINT *pdwData); -NVM_TYPE BcmGetNvmType(PMINI_ADAPTER Adapter); INT BeceemNVMRead( PMINI_ADAPTER Adapter, @@ -217,24 +157,12 @@ INT BeceemNVMWrite( UINT uiNumBytes, BOOLEAN bVerify); -INT BcmUpdateSectorSize(PMINI_ADAPTER Adapter,UINT uiSectorSize); INT BcmInitNVM(PMINI_ADAPTER Adapter); -INT BcmGetNvmSize(PMINI_ADAPTER Adapter); - -INT IsSectionExistInVendorInfo(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL section); - -VOID BcmValidateNvmType(PMINI_ADAPTER Adapter); - -VOID ConfigureEndPointTypesThroughEEPROM(PMINI_ADAPTER Adapter); +INT BcmUpdateSectorSize(PMINI_ADAPTER Adapter,UINT uiSectorSize); +BOOLEAN IsSectionExistInFlash(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL section); -INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter); -INT ReadDSDHeader(PMINI_ADAPTER Adapter, PDSD_HEADER psDSDHeader, FLASH2X_SECTION_VAL dsd); -INT BcmGetActiveDSD(PMINI_ADAPTER Adapter); -INT ReadISOHeader(PMINI_ADAPTER Adapter, PISO_HEADER psISOHeader, FLASH2X_SECTION_VAL IsoImage); -INT BcmGetActiveISO(PMINI_ADAPTER Adapter); -B_UINT8 IsOffsetWritable(PMINI_ADAPTER Adapter, UINT uiOffset); INT BcmGetFlash2xSectionalBitMap(PMINI_ADAPTER Adapter, PFLASH2X_BITMAP psFlash2xBitMap); INT BcmFlash2xBulkWrite( @@ -251,7 +179,6 @@ INT BcmFlash2xBulkRead( FLASH2X_SECTION_VAL eFlashSectionVal, UINT uiOffsetWithinSectionVal, UINT uiNumBytes); -INT BcmGetSectionValEndOffset(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlashSectionVal); INT BcmGetSectionValStartOffset(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlashSectionVal); @@ -264,34 +191,13 @@ INT BcmFlash2xCorruptSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSect INT BcmFlash2xWriteSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlashSectionVal); INT validateFlash2xReadWrite(PMINI_ADAPTER Adapter, PFLASH2X_READWRITE psFlash2xReadWrite); INT IsFlash2x(PMINI_ADAPTER Adapter); -INT GetFlashBaseAddr(PMINI_ADAPTER Adapter); -INT SaveHeaderIfPresent(PMINI_ADAPTER Adapter, PUCHAR pBuff, UINT uiSectAlignAddr); INT BcmCopySection(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL SrcSection, FLASH2X_SECTION_VAL DstSection, UINT offset, UINT numOfBytes); -INT BcmDoChipSelect(PMINI_ADAPTER Adapter, UINT offset); -INT BcmMakeFlashCSActive(PMINI_ADAPTER Adapter, UINT offset); -INT ReadDSDSignature(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL dsd); -INT ReadDSDPriority(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL dsd); -FLASH2X_SECTION_VAL getHighestPriDSD(PMINI_ADAPTER Adapter); -INT ReadISOSignature(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL iso); -INT ReadISOPriority(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL iso); -FLASH2X_SECTION_VAL getHighestPriISO(PMINI_ADAPTER Adapter); -INT WriteToFlashWithoutSectorErase(PMINI_ADAPTER Adapter, - PUINT pBuff, - FLASH2X_SECTION_VAL eFlash2xSectionVal, - UINT uiOffset, - UINT uiNumBytes - ); - -//UINT getNumOfSubSectionWithWRPermisson(PMINI_ADAPTER Adapter, SECTION_TYPE secType); -BOOLEAN IsSectionExistInFlash(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL section); -INT IsSectionWritable(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL Section); -INT CorruptDSDSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal); -INT CorruptISOSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal); + BOOLEAN IsNonCDLessDevice(PMINI_ADAPTER Adapter); @@ -300,7 +206,6 @@ VOID OverrideServiceFlowParams(PMINI_ADAPTER Adapter,PUINT puiBuffer); int wrmaltWithLock (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize); int rdmaltWithLock (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize); -int rdmWithLock(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t size); int wrmWithLock(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t size); INT buffDnldVerify(PMINI_ADAPTER Adapter, unsigned char *mappedbuffer, unsigned int u32FirmwareLength, unsigned long u32StartingAddress); @@ -309,11 +214,6 @@ INT buffDnldVerify(PMINI_ADAPTER Adapter, unsigned char *mappedbuffer, unsigned VOID putUsbSuspend(struct work_struct *work); BOOLEAN IsReqGpioIsLedInNVM(PMINI_ADAPTER Adapter, UINT gpios); -#ifdef BCM_SHM_INTERFACE -INT beceem_virtual_device_init(void); -VOID virtual_mail_box_interrupt(void); -INT beceem_virtual_device_exit(void); -#endif #endif diff --git a/drivers/staging/bcm/Qos.c b/drivers/staging/bcm/Qos.c index 75b2b879633f..8ce4536e6e28 100644 --- a/drivers/staging/bcm/Qos.c +++ b/drivers/staging/bcm/Qos.c @@ -4,15 +4,14 @@ This file contains the routines related to Quality of Service. */ #include "headers.h" -BOOLEAN MatchSrcIpAddress(S_CLASSIFIER_RULE *pstClassifierRule,ULONG ulSrcIP); -BOOLEAN MatchTos(S_CLASSIFIER_RULE *pstClassifierRule,UCHAR ucTypeOfService); -BOOLEAN MatchSrcPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort); -BOOLEAN MatchDestPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushDestPort); -BOOLEAN MatchProtocol(S_CLASSIFIER_RULE *pstClassifierRule,UCHAR ucProtocol); -BOOLEAN MatchDestIpAddress(S_CLASSIFIER_RULE *pstClassifierRule,ULONG ulDestIP); -USHORT ClassifyPacket(PMINI_ADAPTER Adapter,struct sk_buff* skb); -void EThCSGetPktInfo(PMINI_ADAPTER Adapter,PVOID pvEthPayload,PS_ETHCS_PKT_INFO pstEthCsPktInfo); -BOOLEAN EThCSClassifyPkt(PMINI_ADAPTER Adapter,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo,S_CLASSIFIER_RULE *pstClassifierRule, B_UINT8 EthCSCupport); +static void EThCSGetPktInfo(PMINI_ADAPTER Adapter,PVOID pvEthPayload,PS_ETHCS_PKT_INFO pstEthCsPktInfo); +static BOOLEAN EThCSClassifyPkt(PMINI_ADAPTER Adapter,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo,S_CLASSIFIER_RULE *pstClassifierRule, B_UINT8 EthCSCupport); + +static USHORT IpVersion4(PMINI_ADAPTER Adapter, struct iphdr *iphd, + S_CLASSIFIER_RULE *pstClassifierRule ); + +static VOID PruneQueue(PMINI_ADAPTER Adapter, INT iIndex); + /******************************************************************* * Function - MatchSrcIpAddress() @@ -205,11 +204,10 @@ BOOLEAN MatchDestPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushDestPort) Compares IPV4 Ip address and port number @return Queue Index. */ -USHORT IpVersion4(PMINI_ADAPTER Adapter, /**< Pointer to the driver control structure */ - struct iphdr *iphd, /**<Pointer to the IP Hdr of the packet*/ - S_CLASSIFIER_RULE *pstClassifierRule ) +static USHORT IpVersion4(PMINI_ADAPTER Adapter, + struct iphdr *iphd, + S_CLASSIFIER_RULE *pstClassifierRule ) { - //IPHeaderFormat *pIpHeader=NULL; xporthdr *xprt_hdr=NULL; BOOLEAN bClassificationSucceed=FALSE; @@ -261,15 +259,6 @@ USHORT IpVersion4(PMINI_ADAPTER Adapter, /**< Pointer to the driver control stru //if protocol is not TCP or UDP then no need of comparing source port and destination port if(iphd->protocol!=TCP && iphd->protocol!=UDP) break; -#if 0 - //check if memory is available of src and Dest port - if(ETH_AND_IP_HEADER_LEN + L4_SRC_PORT_LEN + L4_DEST_PORT_LEN > Packet->len) - { - //This is not an erroneous condition and pkt will be checked for next classification. - bClassificationSucceed = FALSE; - break; - } -#endif //******************Checking Transport Layer Header field if present *****************// BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Source Port %04x", (iphd->protocol==UDP)?xprt_hdr->uhdr.source:xprt_hdr->thdr.source); @@ -312,29 +301,6 @@ USHORT IpVersion4(PMINI_ADAPTER Adapter, /**< Pointer to the driver control stru return bClassificationSucceed; } -/** -@ingroup tx_functions -@return Queue Index based on priority. -*/ -USHORT GetPacketQueueIndex(PMINI_ADAPTER Adapter, /**<Pointer to the driver control structure */ - struct sk_buff* Packet /**< Pointer to the Packet to be sent*/ - ) -{ - USHORT usIndex=-1; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, QUEUE_INDEX, DBG_LVL_ALL, "=====>"); - - if(NULL==Adapter || NULL==Packet) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, QUEUE_INDEX, DBG_LVL_ALL, "Got NULL Values<======"); - return -1; - } - - usIndex = ClassifyPacket(Adapter,Packet); - - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, QUEUE_INDEX, DBG_LVL_ALL, "Got Queue Index %x",usIndex); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, QUEUE_INDEX, DBG_LVL_ALL, "GetPacketQueueIndex <=============="); - return usIndex; -} VOID PruneQueueAllSF(PMINI_ADAPTER Adapter) { @@ -357,23 +323,21 @@ is less than number of bytes in the queue. If so - drops packets from the Head till the number of bytes is less than or equal to max queue size for the queue. */ -VOID PruneQueue(PMINI_ADAPTER Adapter,/**<Pointer to the driver control structure*/ - INT iIndex/**<Queue Index*/ - ) +static VOID PruneQueue(PMINI_ADAPTER Adapter, INT iIndex) { struct sk_buff* PacketToDrop=NULL; - struct net_device_stats* netstats=NULL; + struct net_device_stats *netstats; BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "=====> Index %d",iIndex); if(iIndex == HiPriority) - return; + return; if(!Adapter || (iIndex < 0) || (iIndex > HiPriority)) return; /* To Store the netdevice statistic */ - netstats = &((PLINUX_DEP_DATA)Adapter->pvOsDepData)->netstats; + netstats = &Adapter->dev->stats; spin_lock_bh(&Adapter->PackInfo[iIndex].SFQueueLock); @@ -395,9 +359,13 @@ VOID PruneQueue(PMINI_ADAPTER Adapter,/**<Pointer to the driver control structur if(PacketToDrop) { - if(netstats) - netstats->tx_dropped++; - atomic_inc(&Adapter->TxDroppedPacketCount); + struct netdev_queue *txq = netdev_get_tx_queue(Adapter->dev, iIndex); + if (netif_msg_tx_err(Adapter)) + pr_info(PFX "%s: tx queue %d overlimit\n", + Adapter->dev->name, iIndex); + + txq->tx_dropped++; + DEQUEUEPACKET(Adapter->PackInfo[iIndex].FirstTxQueue, Adapter->PackInfo[iIndex].LastTxQueue); /// update current bytes and packets count @@ -407,7 +375,7 @@ VOID PruneQueue(PMINI_ADAPTER Adapter,/**<Pointer to the driver control structur /// update dropped bytes and packets counts Adapter->PackInfo[iIndex].uiDroppedCountBytes += PacketToDrop->len; Adapter->PackInfo[iIndex].uiDroppedCountPackets++; - bcm_kfree_skb(PacketToDrop); + dev_kfree_skb(PacketToDrop); } @@ -416,7 +384,6 @@ VOID PruneQueue(PMINI_ADAPTER Adapter,/**<Pointer to the driver control structur Adapter->PackInfo[iIndex].uiDroppedCountPackets); atomic_dec(&Adapter->TotalPacketCount); - Adapter->bcm_jiffies = jiffies; } spin_unlock_bh(&Adapter->PackInfo[iIndex].SFQueueLock); @@ -430,16 +397,15 @@ VOID flush_all_queues(PMINI_ADAPTER Adapter) { INT iQIndex; UINT uiTotalPacketLength; - struct sk_buff* PacketToDrop=NULL; - struct net_device_stats* netstats=NULL; + struct sk_buff* PacketToDrop=NULL; BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "=====>"); - /* To Store the netdevice statistic */ - netstats = &((PLINUX_DEP_DATA)Adapter->pvOsDepData)->netstats; // down(&Adapter->data_packet_queue_lock); for(iQIndex=LowPriority; iQIndex<HiPriority; iQIndex++) { + struct netdev_queue *txq = netdev_get_tx_queue(Adapter->dev, iQIndex); + spin_lock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock); while(Adapter->PackInfo[iQIndex].FirstTxQueue) { @@ -447,8 +413,7 @@ VOID flush_all_queues(PMINI_ADAPTER Adapter) if(PacketToDrop) { uiTotalPacketLength = PacketToDrop->len; - netstats->tx_dropped++; - atomic_inc(&Adapter->TxDroppedPacketCount); + txq->tx_dropped++; } else uiTotalPacketLength = 0; @@ -457,7 +422,7 @@ VOID flush_all_queues(PMINI_ADAPTER Adapter) Adapter->PackInfo[iQIndex].LastTxQueue); /* Free the skb */ - bcm_kfree_skb(PacketToDrop); + dev_kfree_skb(PacketToDrop); /// update current bytes and packets count Adapter->PackInfo[iQIndex].uiCurrentBytesOnHost -= uiTotalPacketLength; @@ -559,12 +524,6 @@ USHORT ClassifyPacket(PMINI_ADAPTER Adapter,struct sk_buff* skb) for(uiLoopIndex = MAX_CLASSIFIERS - 1; uiLoopIndex >= 0; uiLoopIndex--) { - if (Adapter->device_removed) - { - bClassificationSucceed = FALSE; - break; - } - if(bClassificationSucceed) break; //Iterate through all classifiers which are already in order of priority @@ -810,7 +769,10 @@ static BOOLEAN EthCSMatchVLANRules(S_CLASSIFIER_RULE *pstClassifierRule,struct s } -BOOLEAN EThCSClassifyPkt(PMINI_ADAPTER Adapter,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo,S_CLASSIFIER_RULE *pstClassifierRule, B_UINT8 EthCSCupport) +static BOOLEAN EThCSClassifyPkt(PMINI_ADAPTER Adapter,struct sk_buff* skb, + PS_ETHCS_PKT_INFO pstEthCsPktInfo, + S_CLASSIFIER_RULE *pstClassifierRule, + B_UINT8 EthCSCupport) { BOOLEAN bClassificationSucceed = FALSE; bClassificationSucceed = EthCSMatchSrcMACAddress(pstClassifierRule,((ETH_HEADER_STRUC *)(skb->data))->au8SourceAddress); @@ -840,9 +802,11 @@ BOOLEAN EThCSClassifyPkt(PMINI_ADAPTER Adapter,struct sk_buff* skb,PS_ETHCS_PKT_ return bClassificationSucceed; } -void EThCSGetPktInfo(PMINI_ADAPTER Adapter,PVOID pvEthPayload,PS_ETHCS_PKT_INFO pstEthCsPktInfo) +static void EThCSGetPktInfo(PMINI_ADAPTER Adapter,PVOID pvEthPayload, + PS_ETHCS_PKT_INFO pstEthCsPktInfo) { USHORT u16Etype = ntohs(((ETH_HEADER_STRUC*)pvEthPayload)->u16Etype); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCSGetPktInfo : Eth Hdr Type : %X\n",u16Etype); if(u16Etype > 0x5dc) { diff --git a/drivers/staging/bcm/TODO b/drivers/staging/bcm/TODO index 366634be5fe1..cd3e9f2ed87a 100644 --- a/drivers/staging/bcm/TODO +++ b/drivers/staging/bcm/TODO @@ -1,15 +1,22 @@ +This driver is barely functional in its current state. + +BIG: + - existing API is (/dev/tarang) should be replaced + Is it possible to use same API as Intel Wimax stack and + have same user level components. + - Qos and queue model is non-standard and inflexible. + Use existing TC Qos? + TODO: + - support more than one board - eliminate global variables + - remove developer debug BCM_DEBUG() macros + add a limited number of messages through netif_msg() - fix non-standard kernel style - - sparse warnings - checkpatch warnings - - remove compatiablity code for older kernels - - remove #ifdef's - - fix bogus device nameing and reference counting (see bcm_notify_event) - - fix use of file I/O to load config - - request firmware - - update to current network device API - - merge some files together + - use request firmware + - fix use of file I/O to load config with better API + - merge some files together? - cleanup/eliminate debug messages - - integrate with existing Wimax stack? + diff --git a/drivers/staging/bcm/Transmit.c b/drivers/staging/bcm/Transmit.c index 12f9e13457db..0f7000960d50 100644 --- a/drivers/staging/bcm/Transmit.c +++ b/drivers/staging/bcm/Transmit.c @@ -6,7 +6,7 @@ digraph transmit1 { node[shape=box] edge[weight=5;color=red] -bcm_transmit->reply_to_arp_request[label="ARP"] + bcm_transmit->GetPacketQueueIndex[label="IP Packet"] GetPacketQueueIndex->IpVersion4[label="IPV4"] GetPacketQueueIndex->IpVersion6[label="IPV6"] @@ -35,169 +35,16 @@ SendPacketFromQueue->SetupNextSend->bcm_cmd53 #include "headers.h" -/******************************************************************* -* Function - bcm_transmit() -* -* Description - This is the main transmit function for our virtual -* interface(veth0). It handles the ARP packets. It -* clones this packet and then Queue it to a suitable -* Queue. Then calls the transmit_packet(). -* -* Parameter - skb - Pointer to the socket buffer structure -* dev - Pointer to the virtual net device structure -* -* Returns - zero (success) or -ve value (failure) -* -*********************************************************************/ - -INT bcm_transmit(struct sk_buff *skb, /**< skb */ - struct net_device *dev /**< net device pointer */ - ) -{ - PMINI_ADAPTER Adapter = NULL; - USHORT qindex=0; - struct timeval tv; - UINT pkt_type = 0; - UINT calltransmit = 0; - - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_TX, TX_OSAL_DBG, DBG_LVL_ALL, "\n%s====>\n",__FUNCTION__); - - memset(&tv, 0, sizeof(tv)); - /* Check for valid parameters */ - if(skb == NULL || dev==NULL) - { - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_TX,TX_OSAL_DBG, DBG_LVL_ALL, "Got NULL skb or dev\n"); - return -EINVAL; - } - - Adapter = GET_BCM_ADAPTER(dev); - if(!Adapter) - { - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_TX, TX_OSAL_DBG, DBG_LVL_ALL, "Got Invalid Adapter\n"); - return -EINVAL; - } - if(Adapter->device_removed == TRUE || !Adapter->LinkUpStatus) - { - if(!netif_queue_stopped(dev)) { - netif_carrier_off(dev); - netif_stop_queue(dev); - } - return STATUS_FAILURE; - } - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_TX, TX_OSAL_DBG, DBG_LVL_ALL, "Packet size : %d\n", skb->len); - - /*Add Ethernet CS check here*/ - if(Adapter->TransferMode == IP_PACKET_ONLY_MODE ) - { - pkt_type = ntohs(*(PUSHORT)(skb->data + 12)); - /* Get the queue index where the packet is to be queued */ - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_TX, TX_OSAL_DBG, DBG_LVL_ALL, "Getting the Queue Index....."); - - qindex = GetPacketQueueIndex(Adapter,skb); - - if((SHORT)INVALID_QUEUE_INDEX==(SHORT)qindex) - { - if(pkt_type == ETH_ARP_FRAME) - { - /* - Reply directly to ARP request packet - ARP Spoofing only if NO ETH CS rule matches for it - */ - BCM_DEBUG_PRINT (Adapter,DBG_TYPE_TX, TX_OSAL_DBG, DBG_LVL_ALL,"ARP OPCODE = %02x", - - (*(PUCHAR)(skb->data + 21))); - - reply_to_arp_request(skb); - - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_TX,TX_OSAL_DBG, DBG_LVL_ALL,"After reply_to_arp_request \n"); - - } - else - { - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_TX, TX_OSAL_DBG, DBG_LVL_ALL, - "Invalid queue index, dropping pkt\n"); - - bcm_kfree_skb(skb); - } - return STATUS_SUCCESS; - } - - if(Adapter->PackInfo[qindex].uiCurrentPacketsOnHost >= SF_MAX_ALLOWED_PACKETS_TO_BACKUP) - { - atomic_inc(&Adapter->TxDroppedPacketCount); - bcm_kfree_skb(skb); - return STATUS_SUCCESS; - } - - /* Now Enqueue the packet */ - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "bcm_transmit Enqueueing the Packet To Queue %d",qindex); - spin_lock(&Adapter->PackInfo[qindex].SFQueueLock); - Adapter->PackInfo[qindex].uiCurrentBytesOnHost += skb->len; - Adapter->PackInfo[qindex].uiCurrentPacketsOnHost++; - - *((B_UINT32 *)skb->cb + SKB_CB_LATENCY_OFFSET ) = jiffies; - ENQUEUEPACKET(Adapter->PackInfo[qindex].FirstTxQueue, - Adapter->PackInfo[qindex].LastTxQueue, skb); - atomic_inc(&Adapter->TotalPacketCount); - spin_unlock(&Adapter->PackInfo[qindex].SFQueueLock); - do_gettimeofday(&tv); - - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_OSAL_DBG, DBG_LVL_ALL,"ENQ: \n"); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_OSAL_DBG, DBG_LVL_ALL, "Pkt Len = %d, sec: %ld, usec: %ld\n", - (skb->len-ETH_HLEN), tv.tv_sec, tv.tv_usec); - -#ifdef BCM_SHM_INTERFACE - spin_lock(&Adapter->txtransmitlock); - if(Adapter->txtransmit_running == 0) - { - Adapter->txtransmit_running = 1; - calltransmit = 1; - } - else - calltransmit = 0; - - spin_unlock(&Adapter->txtransmitlock); -#endif - if(calltransmit == 1) - transmit_packets(Adapter); - else - { - if(!atomic_read(&Adapter->TxPktAvail)) - { - atomic_set(&Adapter->TxPktAvail, 1); -#ifdef BCM_SHM_INTERFACE - virtual_mail_box_interrupt(); -#endif - wake_up(&Adapter->tx_packet_wait_queue); - } - } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_OSAL_DBG, DBG_LVL_ALL, "<===="); - } - else - bcm_kfree_skb(skb); - - return STATUS_SUCCESS; -} - /** @ingroup ctrl_pkt_functions This function dispatches control packet to the h/w interface @return zero(success) or -ve value(failure) */ -INT SendControlPacket(PMINI_ADAPTER Adapter, /**<Logical Adapter*/ - char *pControlPacket/**<Control Packet*/ - ) +INT SendControlPacket(PMINI_ADAPTER Adapter, char *pControlPacket) { - PLEADER PLeader = NULL; - struct timeval tv; - memset(&tv, 0, sizeof(tv)); - - - - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "========>"); + PLEADER PLeader = (PLEADER)pControlPacket; - PLeader=(PLEADER)pControlPacket; BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Tx"); if(!pControlPacket || !Adapter) { @@ -208,12 +55,6 @@ INT SendControlPacket(PMINI_ADAPTER Adapter, /**<Logical Adapter*/ ((PLeader->PLength-1)/MAX_DEVICE_DESC_SIZE)+1)) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "NO FREE DESCRIPTORS TO SEND CONTROL PACKET"); - if(Adapter->bcm_jiffies == 0) - { - Adapter->bcm_jiffies = jiffies; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "UPDATED TIME(hex): %lu", - Adapter->bcm_jiffies); - } return STATUS_FAILURE; } @@ -224,76 +65,33 @@ INT SendControlPacket(PMINI_ADAPTER Adapter, /**<Logical Adapter*/ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Leader Length: %x",PLeader->PLength); if(Adapter->device_removed) return 0; -#ifndef BCM_SHM_INTERFACE - Adapter->interface_transmit(Adapter->pvInterfaceAdapter, - pControlPacket, (PLeader->PLength + LEADER_SIZE)); -#else - tx_pkts_to_firmware(pControlPacket,(PLeader->PLength + LEADER_SIZE),1); - if(PLeader->Status==IDLE_MESSAGE) - { - if(((CONTROL_MESSAGE*)PLeader)->szData[0] == GO_TO_IDLE_MODE_PAYLOAD && - ((CONTROL_MESSAGE*)PLeader)->szData[1] == TARGET_CAN_GO_TO_IDLE_MODE) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Idle Mode Ack Sent to the Device\n"); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Host Entering into Idle Mode\n"); - do_gettimeofday(&tv); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "IdleMode Msg sent to f/w at time :%ld ms", tv.tv_sec *1000 + tv.tv_usec /1000); - if(Adapter->bDoSuspend != TRUE) - { - Adapter->IdleMode = TRUE; - Adapter->bPreparingForLowPowerMode = FALSE ; - } - } - } - if((PLeader->Status == LINK_UP_CONTROL_REQ) && - ((PUCHAR)pControlPacket)[sizeof(LEADER)] == LINK_UP_ACK && - ((PUCHAR)pControlPacket)[sizeof(LEADER)+1] == - LINK_SHUTDOWN_REQ_FROM_FIRMWARE && - ((PUCHAR)pControlPacket)[sizeof(LEADER)+2] == SHUTDOWN_ACK_FROM_DRIVER) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Shut Down ACK Sent and Host entering Shut State \n"); - if(Adapter->bDoSuspend != TRUE) - { - Adapter->bShutStatus = TRUE; - Adapter->bPreparingForLowPowerMode = FALSE; - Adapter->bTriedToWakeUpFromlowPowerMode = FALSE; - } + if (netif_msg_pktdata(Adapter)) + print_hex_dump(KERN_DEBUG, PFX "tx control: ", DUMP_PREFIX_NONE, + 16, 1, pControlPacket, PLeader->PLength + LEADER_SIZE, 0); - } -#endif + Adapter->interface_transmit(Adapter->pvInterfaceAdapter, + pControlPacket, (PLeader->PLength + LEADER_SIZE)); - ((PLINUX_DEP_DATA)Adapter->pvOsDepData)->netstats.tx_packets++; - ((PLINUX_DEP_DATA)Adapter->pvOsDepData)->netstats.tx_bytes+= - PLeader->PLength; atomic_dec(&Adapter->CurrNumFreeTxDesc); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "<========="); return STATUS_SUCCESS; } -static LEADER Leader={0}; + /** @ingroup tx_functions This function despatches the IP packets with the given vcid to the target via the host h/w interface. @return zero(success) or -ve value(failure) */ -INT SetupNextSend(PMINI_ADAPTER Adapter, /**<Logical Adapter*/ - struct sk_buff *Packet, /**<data buffer*/ - USHORT Vcid) /**<VCID for this packet*/ +INT SetupNextSend(PMINI_ADAPTER Adapter, struct sk_buff *Packet, USHORT Vcid) { int status=0; -#ifdef GDMA_INTERFACE - int dontfree = 0; -#endif BOOLEAN bHeaderSupressionEnabled = FALSE; B_UINT16 uiClassifierRuleID; - int QueueIndex = NO_OF_QUEUES + 1; + u16 QueueIndex = skb_get_queue_mapping(Packet); + LEADER Leader={0}; - if(!Adapter || !Packet) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Got NULL Adapter or Packet"); - return -EINVAL; - } if(Packet->len > MAX_DEVICE_DESC_SIZE) { status = STATUS_FAILURE; @@ -302,14 +100,10 @@ INT SetupNextSend(PMINI_ADAPTER Adapter, /**<Logical Adapter*/ /* Get the Classifier Rule ID */ uiClassifierRuleID = *((UINT32*) (Packet->cb)+SKB_CB_CLASSIFICATION_OFFSET); - QueueIndex = SearchVcid( Adapter,Vcid); - if(QueueIndex < NO_OF_QUEUES) - { - bHeaderSupressionEnabled = - Adapter->PackInfo[QueueIndex].bHeaderSuppressionEnabled; - bHeaderSupressionEnabled = - bHeaderSupressionEnabled & Adapter->bPHSEnabled; - } + + bHeaderSupressionEnabled = Adapter->PackInfo[QueueIndex].bHeaderSuppressionEnabled + & Adapter->bPHSEnabled; + if(Adapter->device_removed) { status = STATUS_FAILURE; @@ -327,15 +121,10 @@ INT SetupNextSend(PMINI_ADAPTER Adapter, /**<Logical Adapter*/ Leader.Vcid = Vcid; - if(TCP_ACK == *((UINT32*) (Packet->cb) + SKB_CB_TCPACK_OFFSET )) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Sending TCP ACK\n"); + if(TCP_ACK == *((UINT32*) (Packet->cb) + SKB_CB_TCPACK_OFFSET )) Leader.Status = LEADER_STATUS_TCP_ACK; - } else - { Leader.Status = LEADER_STATUS; - } if(Adapter->PackInfo[QueueIndex].bEthCSSupport) { @@ -351,68 +140,53 @@ INT SetupNextSend(PMINI_ADAPTER Adapter, /**<Logical Adapter*/ skb_push(Packet, LEADER_SIZE); memcpy(Packet->data, &Leader, LEADER_SIZE); } - else { Leader.PLength = Packet->len - ETH_HLEN; memcpy((LEADER*)skb_pull(Packet, (ETH_HLEN - LEADER_SIZE)), &Leader, LEADER_SIZE); } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Packet->len = %d", Packet->len); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Vcid = %d", Vcid); - -#ifndef BCM_SHM_INTERFACE status = Adapter->interface_transmit(Adapter->pvInterfaceAdapter, Packet->data, (Leader.PLength + LEADER_SIZE)); -#else - status = tx_pkts_to_firmware(Packet,Packet->len,0); -#endif if(status) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Tx Failed..\n"); + ++Adapter->dev->stats.tx_errors; + if (netif_msg_tx_err(Adapter)) + pr_info(PFX "%s: transmit error %d\n", Adapter->dev->name, + status); } else { + struct netdev_queue *txq = netdev_get_tx_queue(Adapter->dev, QueueIndex); Adapter->PackInfo[QueueIndex].uiTotalTxBytes += Leader.PLength; - atomic_add(Leader.PLength, &Adapter->GoodTxByteCount); - atomic_inc(&Adapter->TxTotalPacketCount); -#ifdef GDMA_INTERFACE - dontfree = 1; -#endif - } - atomic_dec(&Adapter->CurrNumFreeTxDesc); - -errExit: + txq->tx_bytes += Leader.PLength; + ++txq->tx_packets; - if(STATUS_SUCCESS == status) - { Adapter->PackInfo[QueueIndex].uiCurrentTokenCount -= Leader.PLength << 3; Adapter->PackInfo[QueueIndex].uiSentBytes += (Packet->len); Adapter->PackInfo[QueueIndex].uiSentPackets++; Adapter->PackInfo[QueueIndex].NumOfPacketsSent++; atomic_dec(&Adapter->PackInfo[QueueIndex].uiPerSFTxResourceCount); -#ifdef BCM_SHM_INTERFACE - if(atomic_read(&Adapter->PackInfo[QueueIndex].uiPerSFTxResourceCount) < 0) - { - atomic_set(&Adapter->PackInfo[QueueIndex].uiPerSFTxResourceCount, 0); - } -#endif Adapter->PackInfo[QueueIndex].uiThisPeriodSentBytes += Leader.PLength; } + atomic_dec(&Adapter->CurrNumFreeTxDesc); -#ifdef GDMA_INTERFACE - if(!dontfree){ - bcm_kfree_skb(Packet); - } -#else - bcm_kfree_skb(Packet); -#endif +errExit: + + dev_kfree_skb(Packet); return status; } +static int tx_pending(PMINI_ADAPTER Adapter) +{ + return (atomic_read(&Adapter->TxPktAvail) + && MINIMUM_PENDING_DESCRIPTORS < atomic_read(&Adapter->CurrNumFreeTxDesc)) + || Adapter->device_removed || (1 == Adapter->downloadDDR); +} + /** @ingroup tx_functions Transmit thread @@ -420,57 +194,26 @@ Transmit thread int tx_pkt_handler(PMINI_ADAPTER Adapter /**< pointer to adapter object*/ ) { -#ifndef BCM_SHM_INTERFACE int status = 0; -#endif - - UINT calltransmit = 1; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Entring to wait for signal from the interrupt service thread!Adapter = %p",Adapter); - - while(1) - { - if(Adapter->LinkUpStatus){ + while(! kthread_should_stop()) { + /* FIXME - the timeout looks like workaround for racey usage of TxPktAvail */ + if(Adapter->LinkUpStatus) wait_event_timeout(Adapter->tx_packet_wait_queue, - ((atomic_read(&Adapter->TxPktAvail) && - (MINIMUM_PENDING_DESCRIPTORS < - atomic_read(&Adapter->CurrNumFreeTxDesc)) && - (Adapter->device_removed == FALSE))) || - (1 == Adapter->downloadDDR) || kthread_should_stop() -#ifndef BCM_SHM_INTERFACE - || (TRUE == Adapter->bEndPointHalted) -#endif - , msecs_to_jiffies(10)); - } - else{ - wait_event(Adapter->tx_packet_wait_queue, - ((atomic_read(&Adapter->TxPktAvail) && - (MINIMUM_PENDING_DESCRIPTORS < - atomic_read(&Adapter->CurrNumFreeTxDesc)) && - (Adapter->device_removed == FALSE))) || - (1 == Adapter->downloadDDR) || kthread_should_stop() -#ifndef BCM_SHM_INTERFACE - || (TRUE == Adapter->bEndPointHalted) -#endif - ); - } - - if(kthread_should_stop() || Adapter->device_removed) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Exiting the tx thread..\n"); - Adapter->transmit_packet_thread = NULL; - return 0; - } + tx_pending(Adapter), msecs_to_jiffies(10)); + else + wait_event_interruptible(Adapter->tx_packet_wait_queue, + tx_pending(Adapter)); -#ifndef BCM_SHM_INTERFACE + if (Adapter->device_removed) + break; if(Adapter->downloadDDR == 1) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Downloading DDR Settings\n"); Adapter->downloadDDR +=1; status = download_ddr_settings(Adapter); if(status) - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "DDR DOWNLOAD FAILED!\n"); + pr_err(PFX "DDR DOWNLOAD FAILED! %d\n", status); continue; } @@ -489,7 +232,6 @@ int tx_pkt_handler(PMINI_ADAPTER Adapter /**< pointer to adapter object*/ update_per_sf_desc_cnts(Adapter); } } -#endif if( atomic_read(&Adapter->CurrNumFreeTxDesc) && Adapter->LinkStatus == SYNC_UP_REQUEST && @@ -507,49 +249,12 @@ int tx_pkt_handler(PMINI_ADAPTER Adapter /**< pointer to adapter object*/ wake_up(&Adapter->process_rx_cntrlpkt); } -#ifdef BCM_SHM_INTERFACE - spin_lock_bh(&Adapter->txtransmitlock); - if(Adapter->txtransmit_running == 0) - { - Adapter->txtransmit_running = 1; - calltransmit = 1; - } - else - calltransmit = 0; - spin_unlock_bh(&Adapter->txtransmitlock); -#endif - - if(calltransmit) - transmit_packets(Adapter); + transmit_packets(Adapter); atomic_set(&Adapter->TxPktAvail, 0); } - return 0; -} - -#ifdef BCM_SHM_INTERFACE -extern PMINI_ADAPTER psAdaptertest; -void virtual_mail_box_interrupt(void) -{ - -#ifndef GDMA_INTERFACE - PUINT ptr = (PUINT)CPE_VIRTUAL_MAILBOX_REG; - UINT intval = (UINT)((*ptr & 0xFF00) >> 8); - if (intval != 0) - { - atomic_set(&psAdaptertest->CurrNumFreeTxDesc, intval); - atomic_set (&psAdaptertest->uiMBupdate, TRUE); - //make it to 0 - *ptr = *ptr & 0xffff00ff; - } -#endif -} -unsigned int total_tx_pkts_pending(void) -{ - return atomic_read(&psAdaptertest->TotalPacketCount); + BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Exiting the tx thread..\n"); + Adapter->transmit_packet_thread = NULL; + return 0; } - -#endif - - diff --git a/drivers/staging/bcm/cntrl_SignalingInterface.h b/drivers/staging/bcm/cntrl_SignalingInterface.h index 4cbe30022248..890778450a86 100644 --- a/drivers/staging/bcm/cntrl_SignalingInterface.h +++ b/drivers/staging/bcm/cntrl_SignalingInterface.h @@ -2,19 +2,6 @@ #define CNTRL_SIGNALING_INTERFACE_ -#ifdef BECEEM_TARGET - -#include <mac_common.h> -#include <msg_Dsa.h> -#include <msg_Dsc.h> -#include <msg_Dsd.h> -#include <sch_definitions.h> -using namespace Beceem; -#ifdef ENABLE_CORRIGENDUM2_UPDATE -extern B_UINT32 g_u32Corr2MacFlags; -#endif - -#else #define DSA_REQ 11 @@ -28,7 +15,6 @@ extern B_UINT32 g_u32Corr2MacFlags; #define DSD_ACK 19 #define MAX_CLASSIFIERS_IN_SF 4 -#endif #define MAX_STRING_LEN 20 #define MAX_PHS_LENGTHS 255 @@ -57,37 +43,7 @@ extern B_UINT32 g_u32Corr2MacFlags; ////////////////////////structure Definitions/////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// \brief class cCPacketClassificationRule -#ifdef BECEEM_TARGET -class CCPacketClassificationRuleSI{ - public: - /// \brief Constructor for the class - CCPacketClassificationRuleSI(): - u8ClassifierRulePriority(mClassifierRulePriority), - u8IPTypeOfServiceLength(mIPTypeOfService), - u8Protocol(mProtocol), - u8IPMaskedSourceAddressLength(0), - u8IPDestinationAddressLength(0), - u8ProtocolSourcePortRangeLength(0), - u8ProtocolDestPortRangeLength(0), - u8EthernetDestMacAddressLength(0), - u8EthernetSourceMACAddressLength(0), - u8EthertypeLength(0), - u16UserPriority(mUserPriority), - u16VLANID(mVLANID), - u8AssociatedPHSI(mAssociatedPHSI), - u16PacketClassificationRuleIndex(mPacketClassifierRuleIndex), - u8VendorSpecificClassifierParamLength(mVendorSpecificClassifierParamLength), - u8IPv6FlowLableLength(mIPv6FlowLableLength), - u8ClassifierActionRule(mClassifierActionRule) - - {} - void Reset() - { - CCPacketClassificationRuleSI(); - } -#else struct _stCPacketClassificationRuleSI{ -#endif /** 16bit UserPriority Of The Service Flow*/ B_UINT16 u16UserPriority; @@ -145,29 +101,10 @@ struct _stCPacketClassificationRuleSI{ B_UINT8 u8ClassifierActionRule; B_UINT16 u16ValidityBitMap; }; -#ifndef BECEEM_TARGET typedef struct _stCPacketClassificationRuleSI CCPacketClassificationRuleSI,stCPacketClassificationRuleSI, *pstCPacketClassificationRuleSI; -#endif /// \brief class CPhsRuleSI -#ifdef BECEEM_TARGET -class CPhsRuleSI{ - public: - /// \brief Constructor for the class - CPhsRuleSI(): - u8PHSI(mPHSI), - u8PHSFLength(0), - u8PHSMLength(0), - u8PHSS(mPHSS), - u8PHSV(mPHSV), - u8VendorSpecificPHSParamsLength(mVendorSpecificPHSParamLength){} - void Reset() - { - CPhsRuleSI(); - } -#else typedef struct _stPhsRuleSI { -#endif /** 8bit PHS Index Of The Service Flow*/ B_UINT8 u8PHSI; /** PHSF Length Of The Service Flow*/ @@ -188,31 +125,11 @@ typedef struct _stPhsRuleSI { B_UINT8 u8VendorSpecificPHSParams[VENDOR_PHS_PARAM_LENGTH]; B_UINT8 u8Padding[2]; -#ifdef BECEEM_TARGET -}; -#else }stPhsRuleSI,*pstPhsRuleSI; typedef stPhsRuleSI CPhsRuleSI; -#endif /// \brief structure cConvergenceSLTypes -#ifdef BECEEM_TARGET -class CConvergenceSLTypes{ - public: - /// \brief Constructor for the class - CConvergenceSLTypes(): - u8ClassfierDSCAction(mClassifierDSCAction), - u8PhsDSCAction (mPhsDSCAction) - {} - void Reset() - { - CConvergenceSLTypes(); - cCPacketClassificationRule.Reset(); - cPhsRule.Reset(); - } -#else struct _stConvergenceSLTypes{ -#endif /** 8bit Phs Classfier Action Of The Service Flow*/ B_UINT8 u8ClassfierDSCAction; /** 8bit Phs DSC Action Of The Service Flow*/ @@ -220,111 +137,15 @@ struct _stConvergenceSLTypes{ /** 16bit Padding */ B_UINT8 u8Padding[2]; /// \brief class cCPacketClassificationRule -#ifdef BECEEM_TARGET - CCPacketClassificationRuleSI cCPacketClassificationRule; -#else stCPacketClassificationRuleSI cCPacketClassificationRule; -#endif /// \brief class CPhsRuleSI -#ifdef BECEEM_TARGET - CPhsRuleSI cPhsRule; -#else struct _stPhsRuleSI cPhsRule; -#endif }; -#ifndef BECEEM_TARGET typedef struct _stConvergenceSLTypes stConvergenceSLTypes,CConvergenceSLTypes, *pstConvergenceSLTypes; -#endif /// \brief structure CServiceFlowParamSI -#ifdef BECEEM_TARGET -class CServiceFlowParamSI{ - public: - /// \brief Constructor for the class - CServiceFlowParamSI(): - u32SFID(mSFid), - u16CID(mCid), - u8ServiceClassNameLength(mServiceClassNameLength), - u8MBSService(mMBSService), - u8QosParamSet(mQosParamSetType), - u8TrafficPriority(mTrafficPriority), - u32MaxSustainedTrafficRate(mMaximumSustainedTrafficRate), - u32MaxTrafficBurst(mMaximumTrafficBurst), - u32MinReservedTrafficRate(mMinimumReservedTrafficRate), - u8ServiceFlowSchedulingType(mServiceFlowSchedulingType), - u8RequesttransmissionPolicy(mRequestTransmissionPolicy), - u32ToleratedJitter(mToleratedJitter), - u32MaximumLatency(mMaximumLatency), - u8FixedLengthVSVariableLengthSDUIndicator - (mFixedLengthVSVariableLength), - u8SDUSize(mSDUSize), - u16TargetSAID(mTargetSAID), - u8ARQEnable(mARQEnable), - u16ARQWindowSize(mARQWindowSize), - u16ARQBlockLifeTime(mARQBlockLifeTime), - u16ARQSyncLossTimeOut(mARQSyncLossTimeOut), - u8ARQDeliverInOrder(mARQDeliverInOrder), - u16ARQRxPurgeTimeOut(mARQRXPurgeTimeOut), - //Add ARQ BLOCK SIZE, ARQ TX and RX delay initializations here - //after we move to only CORR2 - u8RxARQAckProcessingTime(mRxARQAckProcessingTime), - u8CSSpecification(mCSSpecification), - u8TypeOfDataDeliveryService(mTypeOfDataDeliveryService), - u16SDUInterArrivalTime(mSDUInterArrivalTime), - u16TimeBase(mTimeBase), - u8PagingPreference(mPagingPreference), - u8MBSZoneIdentifierassignment(mMBSZoneIdentifierassignmentLength), - u8TrafficIndicationPreference(mTrafficIndicationPreference), - u8GlobalServicesClassNameLength(mGlobalServicesClassNameLength), - u8SNFeedbackEnabled(mSNFeedbackEnabled), - u8FSNSize(mFSNSize), - u8CIDAllocation4activeBSsLength(mCIDAllocation4activeBSsLength), - u16UnsolicitedGrantInterval(mUnsolicitedGrantInterval), - u16UnsolicitedPollingInterval(mUnsolicitedPollingInterval), - u8PDUSNExtendedSubheader4HarqReordering(mPDUSNExtendedSubheader4HarqReordering), - u8MBSContentsIDLength(mMBSContentsIDLength), - u8HARQServiceFlows(mHARQServiceFlows), - u8AuthTokenLength(mAuthTokenLength), - u8HarqChannelMappingLength(mHarqChannelMappingLength), - u8VendorSpecificQoSParamLength(mVendorSpecificQoSParamLength), - bValid(FALSE), - u8TotalClassifiers() -{ -//Remove the bolck after we move to Corr2 only code -#ifdef ENABLE_CORRIGENDUM2_UPDATE - if((g_u32Corr2MacFlags & CORR_2_DSX) || (g_u32Corr2MacFlags & CORR_2_ARQ)) - { - /* IEEE Comment #627 / MTG Comment #426 */ - u16ARQBlockSize = mARQBlockSize; - if(g_u32Corr2MacFlags & CORR_2_ARQ) { - u16ARQRetryTxTimeOut = mARQRetryTimeOutTxDelay; - if(g_u32VENDOR_TYPE == VENDOR_ALCATEL) { - u16ARQRetryRxTimeOut = mARQRetryTimeOutRxDelay_ALU; - } else { - u16ARQRetryRxTimeOut = mARQRetryTimeOutRxDelay; - } - } - else - { - u16ARQRetryTxTimeOut = mARQRetryTimeOutTxDelayCorr1; - u16ARQRetryRxTimeOut = mARQRetryTimeOutRxDelayCorr1; - } - } - else -#endif - { - u16ARQBlockSize = mARQBlockSizeCorr1; - u16ARQRetryTxTimeOut = mARQRetryTimeOutTxDelayCorr1; - u16ARQRetryRxTimeOut = mARQRetryTimeOutRxDelayCorr1; - } -} - - void ComputeMacOverhead(B_UINT8 u8SecOvrhead); - B_UINT16 GetMacOverhead() { return u16MacOverhead; } -#else typedef struct _stServiceFlowParamSI{ -#endif //end of ifdef BECEEM_TARGET /** 32bitSFID Of The Service Flow*/ B_UINT32 u32SFID; @@ -367,11 +188,6 @@ typedef struct _stServiceFlowParamSI{ /** 16bit ARQ Purge timeout */ B_UINT16 u16ARQRxPurgeTimeOut; -#if 0 //def ENABLE_CORRIGENDUM2_UPDATE -/* IEEE Comment #627 / MTG Comment #426 */ - /// \brief Size of an ARQ block, changed from 2 bytes to 1 - B_UINT8 u8ARQBlockSize; -#endif //TODO::Remove this once we move to a new CORR2 driver /// \brief Size of an ARQ block B_UINT16 u16ARQBlockSize; @@ -496,35 +312,18 @@ typedef struct _stServiceFlowParamSI{ B_UINT8 bValid; /**< Validity flag */ B_UINT8 u8Padding; /**< Padding byte*/ -#ifdef BECEEM_TARGET -/** -Structure for Convergence SubLayer Types with a maximum of 4 classifiers -*/ - CConvergenceSLTypes cConvergenceSLTypes[MAX_CLASSIFIERS_IN_SF]; -#else /** Structure for Convergence SubLayer Types with a maximum of 4 classifiers */ stConvergenceSLTypes cConvergenceSLTypes[MAX_CLASSIFIERS_IN_SF]; -#endif -#ifdef BECEEM_TARGET -}; -#else } stServiceFlowParamSI, *pstServiceFlowParamSI; typedef stServiceFlowParamSI CServiceFlowParamSI; -#endif /** structure stLocalSFAddRequest */ typedef struct _stLocalSFAddRequest{ -#ifdef BECEEM_TARGET - _stLocalSFAddRequest( ) : - u8Type(0x00), eConnectionDir(0x00), - u16TID(0x0000), u16CID(0x0000), u16VCID(0x0000) - {} -#endif B_UINT8 u8Type; /**< Type*/ B_UINT8 eConnectionDir; /**< Connection direction*/ @@ -535,19 +334,9 @@ typedef struct _stLocalSFAddRequest{ /// \brief 16bitVCID B_UINT16 u16VCID; /**< 16bit VCID*/ /// \brief structure ParameterSet -#ifdef BECEEM_SIGNALLING_INTERFACE_API - CServiceFlowParamSI sfParameterSet; -#endif -#ifdef BECEEM_TARGET - CServiceFlowParamSI *psfParameterSet; -#else stServiceFlowParamSI *psfParameterSet; /**< structure ParameterSet*/ -#endif -#ifdef USING_VXWORKS - USE_DATA_MEMORY_MANAGER(); -#endif }stLocalSFAddRequest, *pstLocalSFAddRequest; @@ -555,12 +344,6 @@ typedef struct _stLocalSFAddRequest{ structure stLocalSFAddIndication */ typedef struct _stLocalSFAddIndication{ -#ifdef BECEEM_TARGET - _stLocalSFAddIndication( ) : - u8Type(0x00), eConnectionDir(0x00), - u16TID(0x0000), u16CID(0x0000), u16VCID(0x0000) - {} -#endif B_UINT8 u8Type; /**< Type*/ B_UINT8 eConnectionDir; /**< Connection Direction*/ @@ -571,37 +354,19 @@ typedef struct _stLocalSFAddIndication{ /// \brief 16bitVCID B_UINT16 u16VCID; /**< 16bitVCID*/ -#ifdef BECEEM_SIGNALLING_INTERFACE_API - CServiceFlowParamSI sfAuthorizedSet; - /// \brief structure AdmittedSet - CServiceFlowParamSI sfAdmittedSet; - /// \brief structure ActiveSet - CServiceFlowParamSI sfActiveSet; -#endif /// \brief structure AuthorizedSet -#ifdef BECEEM_TARGET - CServiceFlowParamSI *psfAuthorizedSet; - /// \brief structure AdmittedSet - CServiceFlowParamSI *psfAdmittedSet; - /// \brief structure ActiveSet - CServiceFlowParamSI *psfActiveSet; -#else /// \brief structure AuthorizedSet stServiceFlowParamSI *psfAuthorizedSet; /**< AuthorizedSet of type stServiceFlowParamSI*/ /// \brief structure AdmittedSet stServiceFlowParamSI *psfAdmittedSet; /**< AdmittedSet of type stServiceFlowParamSI*/ /// \brief structure ActiveSet stServiceFlowParamSI *psfActiveSet; /**< sfActiveSet of type stServiceFlowParamSI*/ -#endif B_UINT8 u8CC; /**< Confirmation Code*/ B_UINT8 u8Padd; /**< 8-bit Padding */ B_UINT16 u16Padd; /**< 16 bit Padding */ -#ifdef USING_VXWORKS - USE_DATA_MEMORY_MANAGER(); -#endif }stLocalSFAddIndication; @@ -619,33 +384,17 @@ typedef struct _stLocalSFAddIndication stLocalSFChangeIndication, *pstLocalSFCha structure stLocalSFDeleteRequest */ typedef struct _stLocalSFDeleteRequest{ -#ifdef BECEEM_TARGET - _stLocalSFDeleteRequest( ) : - u8Type(0x00), u8Padding(0x00), - u16TID(0x0000), u32SFID (0x00000000) - {} -#endif B_UINT8 u8Type; /**< Type*/ B_UINT8 u8Padding; /**< Padding byte*/ B_UINT16 u16TID; /**< TID*/ /// \brief 32bitSFID B_UINT32 u32SFID; /**< SFID*/ -#ifdef USING_VXWORKS - USE_DATA_MEMORY_MANAGER(); -#endif }stLocalSFDeleteRequest, *pstLocalSFDeleteRequest; /** structure stLocalSFDeleteIndication */ typedef struct stLocalSFDeleteIndication{ -#ifdef BECEEM_TARGET - stLocalSFDeleteIndication( ) : - u8Type(0x00), u8Padding(0x00), - u16TID(0x0000), u16CID(0x0000), - u16VCID(0x0000),u32SFID (0x00000000) - {} -#endif B_UINT8 u8Type; /**< Type */ B_UINT8 u8Padding; /**< Padding */ B_UINT16 u16TID; /**< TID */ @@ -658,9 +407,6 @@ typedef struct stLocalSFDeleteIndication{ /// \brief 8bit Confirmation code B_UINT8 u8ConfirmationCode; /**< Confirmation code */ B_UINT8 u8Padding1[3]; /**< 3 byte Padding */ -#ifdef USING_VXWORKS - USE_DATA_MEMORY_MANAGER(); -#endif }stLocalSFDeleteIndication; typedef struct _stIM_SFHostNotify diff --git a/drivers/staging/bcm/headers.h b/drivers/staging/bcm/headers.h index 9d4e3aca1b34..1148e5e22eb9 100644 --- a/drivers/staging/bcm/headers.h +++ b/drivers/staging/bcm/headers.h @@ -22,7 +22,6 @@ #include <linux/etherdevice.h> #include <net/ip.h> #include <linux/wait.h> -#include <linux/notifier.h> #include <linux/proc_fs.h> #include <linux/interrupt.h> @@ -36,26 +35,10 @@ #include <linux/mm.h> #include <linux/pagemap.h> #include <asm/uaccess.h> -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) #include <linux/kthread.h> -#endif #include <linux/tcp.h> #include <linux/udp.h> -#ifndef BCM_SHM_INTERFACE #include <linux/usb.h> -#endif -#ifdef BECEEM_TARGET - -#include <mac_common.h> -#include <msg_Dsa.h> -#include <msg_Dsc.h> -#include <msg_Dsd.h> -#include <sch_definitions.h> -using namespace Beceem; -#ifdef ENABLE_CORRIGENDUM2_UPDATE -extern B_UINT32 g_u32Corr2MacFlags; -#endif -#endif #include "Typedefs.h" #include "Version.h" @@ -71,39 +54,28 @@ extern B_UINT32 g_u32Corr2MacFlags; #include "CmHost.h" #include "DDRInit.h" #include "Debug.h" -#include "HostMibs.h" #include "IPv6ProtocolHdr.h" -#include "osal_misc.h" #include "PHSModule.h" #include "Protocol.h" #include "Prototypes.h" #include "Queue.h" #include "vendorspecificextn.h" -#ifndef BCM_SHM_INTERFACE #include "InterfaceMacros.h" #include "InterfaceAdapter.h" #include "InterfaceIsr.h" -#include "Interfacemain.h" #include "InterfaceMisc.h" #include "InterfaceRx.h" #include "InterfaceTx.h" -#endif #include "InterfaceIdleMode.h" #include "InterfaceInit.h" -#ifdef BCM_SHM_INTERFACE -#include <linux/cpe_config.h> - -#ifdef GDMA_INTERFACE -#include "GdmaInterface.h" -#include "symphony.h" -#else -#include "virtual_interface.h" - -#endif - -#endif +#define DRV_NAME "beceem" +#define DEV_NAME "tarang" +#define DRV_DESCRIPTION "Beceem Communications Inc. WiMAX driver" +#define DRV_COPYRIGHT "Copyright 2010. Beceem Communications Inc" +#define DRV_VERSION VER_FILEVERSION_STR +#define PFX DRV_NAME " " #endif diff --git a/drivers/staging/bcm/hostmibs.c b/drivers/staging/bcm/hostmibs.c index e9da513b3c24..c13ea5c9a2aa 100644 --- a/drivers/staging/bcm/hostmibs.c +++ b/drivers/staging/bcm/hostmibs.c @@ -10,12 +10,8 @@ */ #include "headers.h" -INT ProcessGetHostMibs(PMINI_ADAPTER Adapter, - PVOID ioBuffer, - ULONG inputBufferLength) +INT ProcessGetHostMibs(PMINI_ADAPTER Adapter, S_MIBS_HOST_STATS_MIBS *pstHostMibs) { - - S_MIBS_HOST_STATS_MIBS *pstHostMibs = NULL; S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL; S_PHS_RULE *pstPhsRule = NULL; S_CLASSIFIER_TABLE *pstClassifierTable = NULL; @@ -30,15 +26,6 @@ INT ProcessGetHostMibs(PMINI_ADAPTER Adapter, return STATUS_FAILURE; } - if(ioBuffer == NULL) - { - return -EINVAL; - } - memset(ioBuffer,0,sizeof(S_MIBS_HOST_STATS_MIBS)); - - pstHostMibs = (S_MIBS_HOST_STATS_MIBS *)ioBuffer; - - //Copy the classifier Table for(nClassifierIndex=0; nClassifierIndex < MAX_CLASSIFIERS; nClassifierIndex++) @@ -54,7 +41,7 @@ INT ProcessGetHostMibs(PMINI_ADAPTER Adapter, { if(Adapter->PackInfo[nSfIndex].bValid) { - OsalMemMove((PVOID)&pstHostMibs->astSFtable[nSfIndex],(PVOID)&Adapter->PackInfo[nSfIndex],sizeof(S_MIBS_SERVICEFLOW_TABLE)); + memcpy((PVOID)&pstHostMibs->astSFtable[nSfIndex],(PVOID)&Adapter->PackInfo[nSfIndex],sizeof(S_MIBS_SERVICEFLOW_TABLE)); } else { @@ -83,7 +70,7 @@ INT ProcessGetHostMibs(PMINI_ADAPTER Adapter, pstHostMibs->astPhsRulesTable[nPhsTableIndex].ulSFID = Adapter->PackInfo[nSfIndex].ulSFID; - OsalMemMove(&pstHostMibs->astPhsRulesTable[nPhsTableIndex].u8PHSI, + memcpy(&pstHostMibs->astPhsRulesTable[nPhsTableIndex].u8PHSI, &pstPhsRule->u8PHSI, sizeof(S_PHS_RULE)); nPhsTableIndex++; @@ -95,12 +82,9 @@ INT ProcessGetHostMibs(PMINI_ADAPTER Adapter, } - //copy other Host Statistics parameters - pstHostMibs->stHostInfo.GoodTransmits = - atomic_read(&Adapter->TxTotalPacketCount); - pstHostMibs->stHostInfo.GoodReceives = - atomic_read(&Adapter->GoodRxPktCount); + pstHostMibs->stHostInfo.GoodTransmits = Adapter->dev->stats.tx_packets; + pstHostMibs->stHostInfo.GoodReceives = Adapter->dev->stats.rx_packets; pstHostMibs->stHostInfo.CurrNumFreeDesc = atomic_read(&Adapter->CurrNumFreeTxDesc); pstHostMibs->stHostInfo.BEBucketSize = Adapter->BEBucketSize; @@ -115,13 +99,10 @@ INT ProcessGetHostMibs(PMINI_ADAPTER Adapter, } -INT GetDroppedAppCntrlPktMibs(PVOID ioBuffer, PPER_TARANG_DATA pTarang) +VOID GetDroppedAppCntrlPktMibs(S_MIBS_HOST_STATS_MIBS *pstHostMibs, const PPER_TARANG_DATA pTarang) { - S_MIBS_HOST_STATS_MIBS *pstHostMibs = (S_MIBS_HOST_STATS_MIBS *)ioBuffer; - - memcpy((PVOID)&(pstHostMibs->stDroppedAppCntrlMsgs),(PVOID)&(pTarang->stDroppedAppCntrlMsgs),sizeof(S_MIBS_DROPPED_APP_CNTRL_MESSAGES)); - - return STATUS_SUCCESS ; + memcpy(&(pstHostMibs->stDroppedAppCntrlMsgs), + &(pTarang->stDroppedAppCntrlMsgs),sizeof(S_MIBS_DROPPED_APP_CNTRL_MESSAGES)); } diff --git a/drivers/staging/bcm/led_control.c b/drivers/staging/bcm/led_control.c index 97adaae7dfc0..16e939fa15d6 100644 --- a/drivers/staging/bcm/led_control.c +++ b/drivers/staging/bcm/led_control.c @@ -108,52 +108,16 @@ static INT LED_Proportional_Blink(PMINI_ADAPTER Adapter, UCHAR GPIO_Num_tx, ulong timeout = 0; /*Read initial value of packets sent/received */ - Initial_num_of_packts_tx = atomic_read(&Adapter->TxTotalPacketCount); - Initial_num_of_packts_rx = atomic_read(&Adapter->GoodRxPktCount); + Initial_num_of_packts_tx = Adapter->dev->stats.tx_packets; + Initial_num_of_packts_rx = Adapter->dev->stats.rx_packets; + /*Scale the rate of transfer to no of blinks.*/ num_of_time_tx= ScaleRateofTransfer((ULONG)rate_of_transfer_tx); num_of_time_rx= ScaleRateofTransfer((ULONG)rate_of_transfer_rx); while((Adapter->device_removed == FALSE)) { - #if 0 - if(0 == num_of_time_tx && 0 == num_of_time_rx) - { - timeout = 1000; - Status = wait_event_interruptible_timeout(Adapter->LEDInfo.notify_led_event, - currdriverstate!= Adapter->DriverState || kthread_should_stop(), - msecs_to_jiffies (timeout)); - if(kthread_should_stop()) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL, "Led thread got signal to exit..hence exiting"); - Adapter->LEDInfo.led_thread_running= BCM_LED_THREAD_DISABLED; - return EVENT_SIGNALED; - } - if(Status) - return EVENT_SIGNALED; - - } - #endif - timeout = 50; - #if 0 - /*Turn on LED if Tx is high bandwidth*/ - if(num_of_time_tx > MAX_NUM_OF_BLINKS) - { - TURN_ON_LED(1<<GPIO_Num_tx, uiTxLedIndex); - num_of_time_tx = 0; - bBlinkBothLED = FALSE; - num_of_time = num_of_time_rx; - } - /*Turn on LED if Rx is high bandwidth*/ - if(num_of_time_rx > MAX_NUM_OF_BLINKS) - { - TURN_ON_LED(1<<GPIO_Num_rx, uiRxLedIndex); - num_of_time_rx = 0; - bBlinkBothLED = FALSE; - num_of_time = num_of_time_tx; - } - #endif /*Blink Tx and Rx LED when both Tx and Rx is in normal bandwidth*/ if(bBlinkBothLED) { @@ -249,9 +213,10 @@ static INT LED_Proportional_Blink(PMINI_ADAPTER Adapter, UCHAR GPIO_Num_tx, * Read the Tx & Rx packets transmission after 1 second and * calculate rate of transfer */ - Final_num_of_packts_tx = atomic_read(&Adapter->TxTotalPacketCount); + Final_num_of_packts_tx = Adapter->dev->stats.tx_packets; + Final_num_of_packts_rx = Adapter->dev->stats.rx_packets; + rate_of_transfer_tx = Final_num_of_packts_tx - Initial_num_of_packts_tx; - Final_num_of_packts_rx = atomic_read(&Adapter->GoodRxPktCount); rate_of_transfer_rx = Final_num_of_packts_rx - Initial_num_of_packts_rx; /*Read initial value of packets sent/received */ @@ -293,7 +258,7 @@ static INT ValidateDSDParamsChecksum( BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"LED Thread:ValidateDSDParamsChecksum: 0x%lx 0x%X",ulParamOffset, usParamLen); - puBuffer = OsalMemAlloc(usParamLen,"!MEM"); + puBuffer = kmalloc(usParamLen, GFP_KERNEL); if(!puBuffer) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"LED Thread: ValidateDSDParamsChecksum Allocation failed"); @@ -341,10 +306,7 @@ static INT ValidateDSDParamsChecksum( } exit: - if(puBuffer) - { - OsalMemFree(puBuffer, usParamLen); - } + kfree(puBuffer); return Status; } @@ -497,12 +459,10 @@ static int ReadConfigFileStructure(PMINI_ADAPTER Adapter, BOOLEAN *bEnableThread { int Status = STATUS_SUCCESS; UCHAR GPIO_Array[NUM_OF_LEDS+1]; /*Array to store GPIO numbers from EEPROM*/ -#ifndef BCM_SHM_INTERFACE UINT uiIndex = 0; UINT uiNum_of_LED_Type = 0; PUCHAR puCFGData = NULL; UCHAR bData = 0; -#endif memset(GPIO_Array, DISABLE_GPIO_NUM, NUM_OF_LEDS+1); if(!Adapter->pstargetparams || IS_ERR(Adapter->pstargetparams)) @@ -524,10 +484,6 @@ static int ReadConfigFileStructure(PMINI_ADAPTER Adapter, BOOLEAN *bEnableThread *bEnableThread = FALSE; return Status; } -#ifdef BCM_SHM_INTERFACE - *bEnableThread = FALSE; - return Status ; -#else /* * CONFIG file read successfully. Deallocate the memory of * uiFileNameBufferSize @@ -578,23 +534,7 @@ static int ReadConfigFileStructure(PMINI_ADAPTER Adapter, BOOLEAN *bEnableThread } if(uiNum_of_LED_Type >= NUM_OF_LEDS) *bEnableThread = FALSE; -#endif -#if 0 - for(uiIndex=0; uiIndex<NUM_OF_LEDS; uiIndex++) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"LEDState[%d].LED_Type = %x\n", uiIndex, - Adapter->LEDInfo.LEDState[uiIndex].LED_Type); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"LEDState[%d].LED_On_State = %x\n", uiIndex, - Adapter->LEDInfo.LEDState[uiIndex].LED_On_State); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"LEDState[%d].LED_Blink_State = %x\n", uiIndex, - Adapter->LEDInfo.LEDState[uiIndex].LED_Blink_State); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"LEDState[%d].GPIO_Num = %x\n", uiIndex, - Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num); - } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"LED Thread: Polarity = %d\n", - Adapter->LEDInfo.BitPolarty); -#endif return Status; } //-------------------------------------------------------------------------- @@ -721,20 +661,6 @@ static VOID LEDControlThread(PMINI_ADAPTER Adapter) TURN_OFF_LED(1<<GPIO_num, uiLedIndex); return ;//STATUS_FAILURE; } - #if 0 - if(Adapter->device_removed) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"Device removed hence exiting from Led Thread.."); - return ; //-ENODEV; - } - #endif - #if 0 - if((GPIO_num != DISABLE_GPIO_NUM) && - ((currdriverstate != FW_DOWNLOAD) && - (currdriverstate != NORMAL_OPERATION) && - (currdriverstate != IDLEMODE_EXIT))) - TURN_OFF_LED(1<<GPIO_num, uiLedIndex); - #endif if(GPIO_num != DISABLE_GPIO_NUM) { @@ -752,10 +678,6 @@ static VOID LEDControlThread(PMINI_ADAPTER Adapter) case DRIVER_INIT: { currdriverstate = DRIVER_INIT;//Adapter->DriverState; - #if 0 - LedGpioInit(Adapter); - Adapter->LEDInfo.bLedInitDone = TRUE; - #endif BcmGetGPIOPinInfo(Adapter, &GPIO_num, &dummyGPIONum, &uiLedIndex, &dummyIndex, currdriverstate); if(GPIO_num != DISABLE_GPIO_NUM) @@ -768,13 +690,6 @@ static VOID LEDControlThread(PMINI_ADAPTER Adapter) { //BCM_DEBUG_PRINT (Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"LED Thread: FW_DN_DONE called\n"); currdriverstate = FW_DOWNLOAD; - #if 0 - if(Adapter->LEDInfo.bLedInitDone == FALSE) - { - LedGpioInit(Adapter); - Adapter->LEDInfo.bLedInitDone = TRUE; - } - #endif BcmGetGPIOPinInfo(Adapter, &GPIO_num, &dummyGPIONum, &uiLedIndex, &dummyIndex, currdriverstate); if(GPIO_num != DISABLE_GPIO_NUM) @@ -796,12 +711,6 @@ static VOID LEDControlThread(PMINI_ADAPTER Adapter) break; case SHUTDOWN_EXIT: - #if 0 - if(Adapter->ulPowerSaveMode == DEVICE_POWERSAVE_MODE_AS_PMU_SHUTDOWN) - { - LedGpioInit(Adapter); - } - #endif //no break, continue to NO_NETWORK_ENTRY state as well. case NO_NETWORK_ENTRY: @@ -875,34 +784,6 @@ static VOID LEDControlThread(PMINI_ADAPTER Adapter) break; case IDLEMODE_EXIT: { -#if 0 - UCHAR GPIO_num_tx = DISABLE_GPIO_NUM; - UCHAR GPIO_num_rx = DISABLE_GPIO_NUM; - UCHAR uiTxLedIndex = 0; - UCHAR uiRxLedIndex = 0; - - currdriverstate = IDLEMODE_EXIT; - if(DEVICE_POWERSAVE_MODE_AS_PMU_SHUTDOWN == Adapter->ulPowerSaveMode) - { - LedGpioInit(Adapter); - } - BcmGetGPIOPinInfo(Adapter, &GPIO_num_tx, &GPIO_num_rx, &uiTxLedIndex,&uiRxLedIndex,currdriverstate); - - Adapter->LEDInfo.bIdle_led_off = FALSE; - - if((GPIO_num_tx == DISABLE_GPIO_NUM) && (GPIO_num_rx == DISABLE_GPIO_NUM)) - { - GPIO_num = DISABLE_GPIO_NUM ; - } - else - { - timeout = 50; - if(Adapter->LEDInfo.bIdleMode_tx_from_host) - LED_Blink(Adapter, 1<<GPIO_num_tx, uiTxLedIndex, timeout, -1,currdriverstate); - else - LED_Blink(Adapter, 1<<GPIO_num_rx, uiRxLedIndex, timeout, -1,currdriverstate); - } -#endif } break; case DRIVER_HALT: diff --git a/drivers/staging/bcm/nvm.c b/drivers/staging/bcm/nvm.c index 41c9ab8a2385..c7292373a65f 100644 --- a/drivers/staging/bcm/nvm.c +++ b/drivers/staging/bcm/nvm.c @@ -1,6 +1,56 @@ #include "headers.h" #define DWORD unsigned int + +static INT BcmDoChipSelect(PMINI_ADAPTER Adapter, UINT offset); +static INT BcmGetActiveDSD(PMINI_ADAPTER Adapter); +static INT BcmGetActiveISO(PMINI_ADAPTER Adapter); +static UINT BcmGetEEPROMSize(PMINI_ADAPTER Adapter); +static INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter); +static UINT BcmGetFlashSectorSize(PMINI_ADAPTER Adapter, UINT FlashSectorSizeSig, UINT FlashSectorSize); + +static VOID BcmValidateNvmType(PMINI_ADAPTER Adapter); +static INT BcmGetNvmSize(PMINI_ADAPTER Adapter); +static UINT BcmGetFlashSize(PMINI_ADAPTER Adapter); +static NVM_TYPE BcmGetNvmType(PMINI_ADAPTER Adapter); + +static INT BcmGetSectionValEndOffset(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal); + +static B_UINT8 IsOffsetWritable(PMINI_ADAPTER Adapter, UINT uiOffset); +static INT IsSectionWritable(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL Section); +static INT IsSectionExistInVendorInfo(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL section); + +static INT ReadDSDPriority(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL dsd); +static INT ReadDSDSignature(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL dsd); +static INT ReadISOPriority(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL iso); +static INT ReadISOSignature(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL iso); + +static INT CorruptDSDSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal); +static INT CorruptISOSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal); +static INT SaveHeaderIfPresent(PMINI_ADAPTER Adapter, PUCHAR pBuff, UINT uiSectAlignAddr); +static INT WriteToFlashWithoutSectorErase(PMINI_ADAPTER Adapter, PUINT pBuff, + FLASH2X_SECTION_VAL eFlash2xSectionVal, + UINT uiOffset, UINT uiNumBytes); +static FLASH2X_SECTION_VAL getHighestPriDSD(PMINI_ADAPTER Adapter); +static FLASH2X_SECTION_VAL getHighestPriISO(PMINI_ADAPTER Adapter); + +static INT BeceemFlashBulkRead( + PMINI_ADAPTER Adapter, + PUINT pBuffer, + UINT uiOffset, + UINT uiNumBytes); + +static INT BeceemFlashBulkWrite( + PMINI_ADAPTER Adapter, + PUINT pBuffer, + UINT uiOffset, + UINT uiNumBytes, + BOOLEAN bVerify); + +static INT GetFlashBaseAddr(PMINI_ADAPTER Adapter); + +static INT ReadBeceemEEPROMBulk(PMINI_ADAPTER Adapter,UINT dwAddress, UINT *pdwData, UINT dwNumData); + // Procedure: ReadEEPROMStatusRegister // // Description: Reads the standard EEPROM Status Register. @@ -228,213 +278,27 @@ INT ReadBeceemEEPROM( PMINI_ADAPTER Adapter, ReadBeceemEEPROMBulk(Adapter, uiTempOffset + MAX_RW_SIZE, (PUINT)&uiData[4], 4); } - OsalMemMove( (PUCHAR) pBuffer, ( ((PUCHAR)&uiData[0]) + uiByteOffset ), 4); + memcpy( (PUCHAR) pBuffer, ( ((PUCHAR)&uiData[0]) + uiByteOffset ), 4); return STATUS_SUCCESS; } /* ReadBeceemEEPROM() */ -#if 0 -//----------------------------------------------------------------------------- -// Procedure: IsEEPROMWriteDone -// -// Description: Reads the SPI status to see the status of previous write. -// -// Arguments: -// Adapter - ptr to Adapter object instance -// -// Returns: -// BOOLEAN - TRUE - write went through -// - FALSE - Write Failed. -//----------------------------------------------------------------------------- - -BOOLEAN IsEEPROMWriteDone(PMINI_ADAPTER Adapter) -{ - UINT uiRetries = 16; - //UINT uiStatus = 0; - UINT value; - - //sleep for 1.2ms ..worst case EEPROM write can take up to 1.2ms. - mdelay(2); - - value = 0; - rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value)); - - while(((value >> 14) & 1) == 1) - { - // EEPROM_SPI_Q_STATUS1_REG will be cleared only if write back to that. - value = (0x1 << 14); - wrmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG,&value, sizeof(value)); - udelay(1000); - uiRetries--; - if(uiRetries == 0) - { - return FALSE; - } - value = 0; - rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value)); - } - return TRUE; - - -} - - -//----------------------------------------------------------------------------- -// Procedure: ReadBeceemEEPROMBulk -// -// Description: This routine reads 16Byte data from EEPROM -// -// Arguments: -// Adapter - ptr to Adapter object instance -// dwAddress - EEPROM Offset to read the data from. -// pdwData - Pointer to double word where data needs to be stored in. -// -// Returns: -// OSAL_STATUS_CODE: -//----------------------------------------------------------------------------- - -INT ReadBeceemEEPROMBulk(PMINI_ADAPTER Adapter,DWORD dwAddress, DWORD *pdwData) -{ - DWORD dwRetries = 16; - DWORD dwIndex = 0; - UINT value, tmpVal; - - - value = 0; - rdmalt (Adapter, 0x0f003008, &value, sizeof(value)); - - //read 0x0f003020 untill bit 1 of 0x0f003008 is set. - while(((value >> 1) & 1) == 0) - { - - rdmalt (Adapter, 0x0f003020, &tmpVal, sizeof(tmpVal)); - dwRetries--; - if(dwRetries == 0) - { - return -1; - } - value = 0; - rdmalt (Adapter, 0x0f003008, &value, sizeof(value)); - } - - value = dwAddress | 0xfb000000; - wrmalt (Adapter, 0x0f003018, &value, sizeof(value)); - - udelay(1000); - value = 0; - for(dwIndex = 0;dwIndex < 4 ; dwIndex++) - { - value = 0; - rdmalt (Adapter, 0x0f003020, &value, sizeof(value)); - pdwData[dwIndex] = value; - - value = 0; - rdmalt (Adapter, 0x0f003020, &value, sizeof(value)); - pdwData[dwIndex] |= (value << 8); - - value = 0; - rdmalt (Adapter, 0x0f003020, &value, sizeof(value)); - pdwData[dwIndex] |= (value << 16); - - value = 0; - rdmalt (Adapter, 0x0f003020, &value, sizeof(value)); - pdwData[dwIndex] |= (value << 24); - - } - return 0; -} - -//----------------------------------------------------------------------------- -// Procedure: ReadBeceemEEPROM -// -// Description: This routine reads 4Byte data from EEPROM -// -// Arguments: -// Adapter - ptr to Adapter object instance -// dwAddress - EEPROM Offset to read the data from. -// pdwData - Pointer to double word where data needs to be stored in. -// -// Returns: -// OSAL_STATUS_CODE: -//----------------------------------------------------------------------------- - -INT ReadBeceemEEPROM(PMINI_ADAPTER Adapter,DWORD dwAddress, DWORD *pdwData) -{ - - DWORD dwReadValue = 0; - DWORD dwRetries = 16, dwCompleteWord = 0; - UINT value, tmpVal; - - rdmalt(Adapter, 0x0f003008, &value, sizeof(value)); - while (((value >> 1) & 1) == 0) { - rdmalt(Adapter, 0x0f003020, &tmpVal, sizeof(tmpVal)); - - if (dwRetries == 0) { - return -1; - } - rdmalt(Adapter, 0x0f003008, &value, sizeof(value)); - } - - - //wrm (0x0f003018, 0xNbXXXXXX) // N is the number of bytes u want to read (0 means 1, f means 16, b is the opcode for page read) - // Follow it up by N executions of rdm(0x0f003020) to read the rxed bytes from rx queue. - dwAddress |= 0x3b000000; - wrmalt(Adapter, 0x0f003018,&dwAddress,4); - mdelay(10); - rdmalt(Adapter, 0x0f003020,&dwReadValue,4); - dwCompleteWord=dwReadValue; - rdmalt(Adapter, 0x0f003020,&dwReadValue,4); - dwCompleteWord|=(dwReadValue<<8); - rdmalt(Adapter, 0x0f003020,&dwReadValue,4); - dwCompleteWord|=(dwReadValue<<16); - rdmalt(Adapter, 0x0f003020,&dwReadValue,4); - dwCompleteWord|=(dwReadValue<<24); - - *pdwData = dwCompleteWord; - - return 0; -} -#endif INT ReadMacAddressFromNVM(PMINI_ADAPTER Adapter) { - INT Status=0, i; - unsigned char puMacAddr[6] = {0}; - INT AllZeroMac = 0; - INT AllFFMac = 0; + INT Status; + unsigned char puMacAddr[6]; Status = BeceemNVMRead(Adapter, (PUINT)&puMacAddr[0], INIT_PARAMS_1_MACADDRESS_ADDRESS, MAC_ADDRESS_SIZE); - if(Status != STATUS_SUCCESS) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Error in Reading the mac Addres with status :%d", Status); - return Status; - } - - memcpy(Adapter->dev->dev_addr, puMacAddr, MAC_ADDRESS_SIZE); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Modem MAC Addr :"); - BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_PRINTK, 0, DBG_LVL_ALL,&Adapter->dev->dev_addr[0],MAC_ADDRESS_SIZE); - for(i=0;i<MAC_ADDRESS_SIZE;i++) - { - - if(Adapter->dev->dev_addr[i] == 0x00) - AllZeroMac++; - if(Adapter->dev->dev_addr[i] == 0xFF) - AllFFMac++; - - } - //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "\n"); - if(AllZeroMac == MAC_ADDRESS_SIZE) - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Warning :: MAC Address has all 00's"); - if(AllFFMac == MAC_ADDRESS_SIZE) - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Warning :: MAC Address has all FF's"); + if(Status == STATUS_SUCCESS) + memcpy(Adapter->dev->dev_addr, puMacAddr, MAC_ADDRESS_SIZE); return Status; - } //----------------------------------------------------------------------------- @@ -476,7 +340,7 @@ INT BeceemEEPROMBulkRead( ReadBeceemEEPROMBulk(Adapter,uiTempOffset,(PUINT)&uiData[0],4); if(uiBytesRemaining >= (MAX_RW_SIZE - uiExtraBytes)) { - OsalMemMove(pBuffer,(((PUCHAR)&uiData[0])+uiExtraBytes),MAX_RW_SIZE - uiExtraBytes); + memcpy(pBuffer,(((PUCHAR)&uiData[0])+uiExtraBytes),MAX_RW_SIZE - uiExtraBytes); uiBytesRemaining -= (MAX_RW_SIZE - uiExtraBytes); uiIndex += (MAX_RW_SIZE - uiExtraBytes); @@ -484,7 +348,7 @@ INT BeceemEEPROMBulkRead( } else { - OsalMemMove(pBuffer,(((PUCHAR)&uiData[0])+uiExtraBytes),uiBytesRemaining); + memcpy(pBuffer,(((PUCHAR)&uiData[0])+uiExtraBytes),uiBytesRemaining); uiIndex += uiBytesRemaining; uiOffset += uiBytesRemaining; uiBytesRemaining = 0; @@ -508,7 +372,7 @@ INT BeceemEEPROMBulkRead( * We read 4 Dwords of data */ if(0 == ReadBeceemEEPROMBulk(Adapter,uiOffset,&uiData[0],4)) { - OsalMemMove(pcBuff+uiIndex,&uiData[0],MAX_RW_SIZE); + memcpy(pcBuff+uiIndex,&uiData[0],MAX_RW_SIZE); uiOffset += MAX_RW_SIZE; uiBytesRemaining -= MAX_RW_SIZE; uiIndex += MAX_RW_SIZE; @@ -523,7 +387,7 @@ INT BeceemEEPROMBulkRead( { if(0 == ReadBeceemEEPROM(Adapter,uiOffset,&uiData[0])) { - OsalMemMove(pcBuff+uiIndex,&uiData[0],4); + memcpy(pcBuff+uiIndex,&uiData[0],4); uiOffset += 4; uiBytesRemaining -= 4; uiIndex +=4; @@ -540,7 +404,7 @@ INT BeceemEEPROMBulkRead( pCharBuff += uiIndex; if(0 == ReadBeceemEEPROM(Adapter,uiOffset,&uiData[0])) { - OsalMemMove(pCharBuff,&uiData[0],uiBytesRemaining);//copy only bytes requested. + memcpy(pCharBuff,&uiData[0],uiBytesRemaining);//copy only bytes requested. uiBytesRemaining = 0; } else @@ -571,7 +435,7 @@ INT BeceemEEPROMBulkRead( // <FAILURE> - if failed. //----------------------------------------------------------------------------- -INT BeceemFlashBulkRead( +static INT BeceemFlashBulkRead( PMINI_ADAPTER Adapter, PUINT pBuffer, UINT uiOffset, @@ -653,16 +517,8 @@ INT BeceemFlashBulkRead( // //----------------------------------------------------------------------------- -UINT BcmGetFlashSize(PMINI_ADAPTER Adapter) +static UINT BcmGetFlashSize(PMINI_ADAPTER Adapter) { -#if 0 - if(Adapter->bDDRInitDone) - { - return rdm(Adapter,FLASH_CONTIGIOUS_START_ADDR_AFTER_INIT|FLASH_SIZE_ADDR); - } - - return rdm(Adapter,FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT|FLASH_SIZE_ADDR); -#endif if(IsFlash2x(Adapter)) return (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER)); else @@ -684,7 +540,7 @@ UINT BcmGetFlashSize(PMINI_ADAPTER Adapter) // //----------------------------------------------------------------------------- -UINT BcmGetEEPROMSize(PMINI_ADAPTER Adapter) +static UINT BcmGetEEPROMSize(PMINI_ADAPTER Adapter) { UINT uiData = 0; UINT uiIndex = 0; @@ -733,60 +589,6 @@ UINT BcmGetEEPROMSize(PMINI_ADAPTER Adapter) return 0; } -#if 0 -/***********************************************************************************/ -// -// WriteBeceemEEPROM: Writes 4 byte data to EEPROM offset. -// -// uiEEPROMOffset - Offset to be written to. -// uiData - Data to be written. -// -/***********************************************************************************/ - -INT WriteBeceemEEPROM(PMINI_ADAPTER Adapter,UINT uiEEPROMOffset, UINT uiData) -{ - INT Status = 0; - ULONG ulRdBk = 0; - ULONG ulRetryCount = 3; - UINT value; - - if(uiEEPROMOffset > EEPROM_END) - { - - return -1; - } - - uiData = htonl(uiData); - while(ulRetryCount--) - { - value = 0x06000000; - wrmalt(Adapter, 0x0F003018,&value, sizeof(value));//flush the EEPROM FIFO. - wrmalt(Adapter, 0x0F00301C,&uiData, sizeof(uiData)); - value = 0x3A000000 | uiEEPROMOffset; - wrmalt(Adapter, 0x0F003018,&value, sizeof(value)); - __udelay(100000); - //read back and verify. - Status = ReadBeceemEEPROM(Adapter,uiEEPROMOffset,(UINT *)&ulRdBk); - if(Status == 0) - { - if(ulRdBk == uiData) - { - return Status; - } - else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "WriteBeceemEEPROM: Readback does not match\n"); - } - } - else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "WriteBeceemEEPROM: Readback failed\n"); - } - } - - return 0; -} -#endif //----------------------------------------------------------------------------- // Procedure: FlashSectorErase @@ -973,7 +775,7 @@ static INT flashWrite( // need not write 0xFFFFFFFF because write requires an erase and erase will // make whole sector 0xFFFFFFFF. // - if (!OsalMemCompare(pData, uiErasePattern, MAX_RW_SIZE)) + if (!memcmp(pData, uiErasePattern, MAX_RW_SIZE)) { return 0; } @@ -1138,7 +940,7 @@ static INT flashWriteStatus( // need not write 0xFFFFFFFF because write requires an erase and erase will // make whole sector 0xFFFFFFFF. // - if (!OsalMemCompare(pData,uiErasePattern,MAX_RW_SIZE)) + if (!memcmp(pData,uiErasePattern,MAX_RW_SIZE)) { return 0; } @@ -1332,7 +1134,7 @@ static ULONG BcmFlashUnProtectBlock(PMINI_ADAPTER Adapter,UINT uiOffset, UINT ui // //----------------------------------------------------------------------------- -INT BeceemFlashBulkWrite( +static INT BeceemFlashBulkWrite( PMINI_ADAPTER Adapter, PUINT pBuffer, UINT uiOffset, @@ -1353,15 +1155,6 @@ INT BeceemFlashBulkWrite( UINT uiTemp = 0; UINT index = 0; UINT uiPartOffset = 0; - #if 0 - struct timeval tv1 = {0}; - struct timeval tv2 = {0}; - - struct timeval tr = {0}; - struct timeval te = {0}; - struct timeval tw = {0}; - struct timeval twv = {0}; - #endif #if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS) Status = bcmflash_raw_write((uiOffset/FLASH_PART_SIZE),(uiOffset % FLASH_PART_SIZE),( unsigned char *)pBuffer,uiNumBytes); @@ -1377,12 +1170,9 @@ INT BeceemFlashBulkWrite( uiCurrSectOffsetAddr = uiOffset & (Adapter->uiSectorSize - 1); uiSectBoundary = uiSectAlignAddr + Adapter->uiSectorSize; - //pTempBuff = OsalMemAlloc(MAX_SECTOR_SIZE,'!MVN'); - pTempBuff = OsalMemAlloc(Adapter->uiSectorSize ,"!MVN"); + pTempBuff = kmalloc(Adapter->uiSectorSize, GFP_KERNEL); if(NULL == pTempBuff) - { goto BeceemFlashBulkWrite_EXIT; - } // // check if the data to be written is overlapped accross sectors // @@ -1399,7 +1189,6 @@ INT BeceemFlashBulkWrite( uiNumSectTobeRead++; } } - #if 1 //Check whether Requested sector is writable or not in case of flash2x write. But if write call is // for DSD calibration, allow it without checking of sector permission @@ -1420,7 +1209,6 @@ INT BeceemFlashBulkWrite( index = index + 1 ; } } - #endif Adapter->SelectedChip = RESET_CHIP_SELECT; while(uiNumSectTobeRead) { @@ -1448,13 +1236,13 @@ INT BeceemFlashBulkWrite( if(uiNumSectTobeRead > 1) { - OsalMemMove(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr)); + memcpy(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr)); pcBuffer += ((uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr))); uiNumBytes -= (uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr)); } else { - OsalMemMove(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiNumBytes); + memcpy(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiNumBytes); } if(IsFlash2x(Adapter)) @@ -1503,7 +1291,7 @@ INT BeceemFlashBulkWrite( } else { - if(OsalMemCompare(ucReadBk,&pTempBuff[uiIndex],MAX_RW_SIZE)) + if(memcmp(ucReadBk,&pTempBuff[uiIndex],MAX_RW_SIZE)) { if(STATUS_SUCCESS != (*Adapter->fpFlashWriteWithStatusCheck)(Adapter,uiPartOffset+uiIndex,&pTempBuff[uiIndex])) { @@ -1541,10 +1329,8 @@ BeceemFlashBulkWrite_EXIT: { BcmRestoreBlockProtectStatus(Adapter,ulStatus); } - if(pTempBuff) - { - OsalMemFree(pTempBuff,Adapter->uiSectorSize); - } + + kfree(pTempBuff); Adapter->SelectedChip = RESET_CHIP_SELECT; return Status; @@ -1599,14 +1385,10 @@ static INT BeceemFlashBulkWriteStatus( uiCurrSectOffsetAddr = uiOffset & (Adapter->uiSectorSize - 1); uiSectBoundary = uiSectAlignAddr + Adapter->uiSectorSize; - - -// pTempBuff = OsalMemAlloc(MAX_SECTOR_SIZE,'!MVN'); - pTempBuff = OsalMemAlloc(Adapter->uiSectorSize,"!MVN"); + pTempBuff = kmalloc(Adapter->uiSectorSize, GFP_KERNEL); if(NULL == pTempBuff) - { goto BeceemFlashBulkWriteStatus_EXIT; - } + // // check if the data to be written is overlapped accross sectors // @@ -1662,13 +1444,13 @@ static INT BeceemFlashBulkWriteStatus( if(uiNumSectTobeRead > 1) { - OsalMemMove(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr)); + memcpy(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr)); pcBuffer += ((uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr))); uiNumBytes -= (uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr)); } else { - OsalMemMove(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiNumBytes); + memcpy(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiNumBytes); } if(IsFlash2x(Adapter)) @@ -1698,25 +1480,10 @@ static INT BeceemFlashBulkWriteStatus( { for(uiIndex = 0;uiIndex < Adapter->uiSectorSize;uiIndex += MAX_RW_SIZE) { -#if 0 - if(0 == BeceemFlashBulkRead(Adapter,uiReadBk,uiOffsetFromSectStart+uiIndex + Adapter->ulFlashCalStart ,MAX_RW_SIZE)) - { - for(uiReadIndex = 0;uiReadIndex < 4; uiReadIndex++) - { - if(*((PUINT)&pTempBuff[uiIndex+uiReadIndex*4]) != uiReadBk[uiReadIndex]) - { - Status = -1; - goto BeceemFlashBulkWriteStatus_EXIT; - - } - } - - } -#endif if(STATUS_SUCCESS == BeceemFlashBulkRead(Adapter,(PUINT)ucReadBk,uiOffsetFromSectStart+uiIndex,MAX_RW_SIZE)) { - if(OsalMemCompare(ucReadBk,&pTempBuff[uiIndex],MAX_RW_SIZE)) + if(memcmp(ucReadBk,&pTempBuff[uiIndex],MAX_RW_SIZE)) { Status = STATUS_FAILURE; goto BeceemFlashBulkWriteStatus_EXIT; @@ -1747,10 +1514,8 @@ BeceemFlashBulkWriteStatus_EXIT: { BcmRestoreBlockProtectStatus(Adapter,ulStatus); } - if(pTempBuff) - { - OsalMemFree(pTempBuff,Adapter->uiSectorSize); - } + + kfree(pTempBuff); Adapter->SelectedChip = RESET_CHIP_SELECT; return Status; @@ -1771,7 +1536,7 @@ BeceemFlashBulkWriteStatus_EXIT: INT PropagateCalParamsFromEEPROMToMemory(PMINI_ADAPTER Adapter) { - PCHAR pBuff = OsalMemAlloc(BUFFER_4K,"3MVN"); + PCHAR pBuff = kmalloc(BUFFER_4K, GFP_KERNEL); UINT uiEepromSize = 0; UINT uiIndex = 0; UINT uiBytesToCopy = 0; @@ -1787,14 +1552,14 @@ INT PropagateCalParamsFromEEPROMToMemory(PMINI_ADAPTER Adapter) if(0 != BeceemEEPROMBulkRead(Adapter,&uiEepromSize,EEPROM_SIZE_OFFSET,4)) { - OsalMemFree(pBuff,BUFFER_4K); + kfree(pBuff); return -1; } uiEepromSize >>= 16; if(uiEepromSize > 1024*1024) { - OsalMemFree(pBuff,BUFFER_4K); + kfree(pBuff); return -1; } @@ -1820,7 +1585,7 @@ INT PropagateCalParamsFromEEPROMToMemory(PMINI_ADAPTER Adapter) wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC-4,&value, sizeof(value)); value = 0xbeadbead; wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC-8,&value, sizeof(value)); - OsalMemFree(pBuff,MAX_RW_SIZE); + kfree(pBuff); return Status; @@ -1873,16 +1638,13 @@ INT PropagateCalParamsFromFlashToMemory(PMINI_ADAPTER Adapter) return -1; } - pBuff = OsalMemAlloc(uiEepromSize, 0); - + pBuff = kmalloc(uiEepromSize, GFP_KERNEL); if ( pBuff == NULL ) - { return -1; - } if(0 != BeceemNVMRead(Adapter,(PUINT)pBuff,uiCalStartAddr, uiEepromSize)) { - OsalMemFree(pBuff, 0); + kfree(pBuff); return -1; } @@ -1905,7 +1667,7 @@ INT PropagateCalParamsFromFlashToMemory(PMINI_ADAPTER Adapter) uiBytesToCopy = MIN(BUFFER_4K,uiEepromSize); } - OsalMemFree(pBuff, 0); + kfree(pBuff); return Status; } @@ -1947,14 +1709,14 @@ static INT BeceemEEPROMReadBackandVerify( {// for the requests more than or equal to MAX_RW_SIZE bytes, use bulk read function to make the access faster. BeceemEEPROMBulkRead(Adapter,&auiData[0],uiOffset,MAX_RW_SIZE); - if(OsalMemCompare(&pBuffer[uiIndex],&auiData[0],MAX_RW_SIZE)) + if(memcmp(&pBuffer[uiIndex],&auiData[0],MAX_RW_SIZE)) { // re-write BeceemEEPROMBulkWrite(Adapter,(PUCHAR)(pBuffer+uiIndex),uiOffset,MAX_RW_SIZE,FALSE); mdelay(3); BeceemEEPROMBulkRead(Adapter,&auiData[0],uiOffset,MAX_RW_SIZE); - if(OsalMemCompare(&pBuffer[uiIndex],&auiData[0],MAX_RW_SIZE)) + if(memcmp(&pBuffer[uiIndex],&auiData[0],MAX_RW_SIZE)) { return -1; } @@ -1986,7 +1748,7 @@ static INT BeceemEEPROMReadBackandVerify( else { // Handle the reads less than 4 bytes... uiData = 0; - OsalMemMove(&uiData,((PUCHAR)pBuffer)+(uiIndex*sizeof(UINT)),uiNumBytes); + memcpy(&uiData,((PUCHAR)pBuffer)+(uiIndex*sizeof(UINT)),uiNumBytes); BeceemEEPROMBulkRead(Adapter,&uiRdbk,uiOffset,4); if(memcmp(&uiData, &uiRdbk, uiNumBytes)) @@ -2186,7 +1948,7 @@ INT BeceemEEPROMBulkWrite( if(uiBytesToCopy >= (16 -uiExtraBytes)) { - OsalMemMove((((PUCHAR)&uiData[0])+uiExtraBytes),pBuffer,MAX_RW_SIZE- uiExtraBytes); + memcpy((((PUCHAR)&uiData[0])+uiExtraBytes),pBuffer,MAX_RW_SIZE- uiExtraBytes); if ( STATUS_FAILURE == BeceemEEPROMWritePage( Adapter, uiData, uiTempOffset ) ) return STATUS_FAILURE; @@ -2197,7 +1959,7 @@ INT BeceemEEPROMBulkWrite( } else { - OsalMemMove((((PUCHAR)&uiData[0])+uiExtraBytes),pBuffer,uiBytesToCopy); + memcpy((((PUCHAR)&uiData[0])+uiExtraBytes),pBuffer,uiBytesToCopy); if ( STATUS_FAILURE == BeceemEEPROMWritePage( Adapter, uiData, uiTempOffset ) ) return STATUS_FAILURE; @@ -2233,7 +1995,7 @@ INT BeceemEEPROMBulkWrite( // To program non 16byte aligned data, read 16byte and then update. // BeceemEEPROMBulkRead(Adapter,&uiData[0],uiOffset,16); - OsalMemMove(&uiData[0],pBuffer+uiIndex,uiBytesToCopy); + memcpy(&uiData[0],pBuffer+uiIndex,uiBytesToCopy); if ( STATUS_FAILURE == BeceemEEPROMWritePage( Adapter, uiData, uiOffset ) ) @@ -2535,7 +2297,7 @@ INT BcmUpdateSectorSize(PMINI_ADAPTER Adapter,UINT uiSectorSize) // //----------------------------------------------------------------------------- -UINT BcmGetFlashSectorSize(PMINI_ADAPTER Adapter, UINT FlashSectorSizeSig, UINT FlashSectorSize) +static UINT BcmGetFlashSectorSize(PMINI_ADAPTER Adapter, UINT FlashSectorSizeSig, UINT FlashSectorSize) { UINT uiSectorSize = 0; UINT uiSectorSig = 0; @@ -2642,20 +2404,8 @@ static INT BcmInitEEPROMQueues(PMINI_ADAPTER Adapter) INT BcmInitNVM(PMINI_ADAPTER ps_adapter) { -#ifdef BCM_SHM_INTERFACE -#ifdef FLASH_DIRECT_ACCESS - unsigned int data,data1,data2 = 1; - wrm(ps_adapter, PAD_SELECT_REGISTER, &data2, 4); - data1 = rdm(ps_adapter,SYS_CFG,&data,4); - data1 = rdm(ps_adapter,SYS_CFG,&data,4); - data2 = (data | 0x80 | 0x8000); - wrm(ps_adapter,SYS_CFG, &data2,4); // over-write as Flash boot mode -#endif - ps_adapter->eNVMType = NVM_FLASH; -#else BcmValidateNvmType(ps_adapter); BcmInitEEPROMQueues(ps_adapter); -#endif if(ps_adapter->eNVMType == NVM_AUTODETECT) { @@ -2684,7 +2434,7 @@ INT BcmInitNVM(PMINI_ADAPTER ps_adapter) */ /***************************************************************************/ -INT BcmGetNvmSize(PMINI_ADAPTER Adapter) +static INT BcmGetNvmSize(PMINI_ADAPTER Adapter) { if(Adapter->eNVMType == NVM_EEPROM) { @@ -2708,7 +2458,7 @@ INT BcmGetNvmSize(PMINI_ADAPTER Adapter) // Returns: // <VOID> //----------------------------------------------------------------------------- -VOID BcmValidateNvmType(PMINI_ADAPTER Adapter) +static VOID BcmValidateNvmType(PMINI_ADAPTER Adapter) { // @@ -2775,7 +2525,7 @@ INT BcmAllocFlashCSStructure(PMINI_ADAPTER psAdapter) if(psAdapter->psFlash2xCSInfo == NULL) { BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0,"Can't Allocate memory for Flash 2.x"); - bcm_kfree(psAdapter->psFlashCSInfo); + kfree(psAdapter->psFlashCSInfo); return -ENOMEM; } @@ -2783,8 +2533,8 @@ INT BcmAllocFlashCSStructure(PMINI_ADAPTER psAdapter) if(psAdapter->psFlash2xVendorInfo == NULL) { BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0,"Can't Allocate Vendor Info Memory for Flash 2.x"); - bcm_kfree(psAdapter->psFlashCSInfo); - bcm_kfree(psAdapter->psFlash2xCSInfo); + kfree(psAdapter->psFlashCSInfo); + kfree(psAdapter->psFlash2xCSInfo); return -ENOMEM; } @@ -2798,9 +2548,9 @@ INT BcmDeAllocFlashCSStructure(PMINI_ADAPTER psAdapter) BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0," Adapter structure point is NULL"); return -EINVAL; } - bcm_kfree(psAdapter->psFlashCSInfo); - bcm_kfree(psAdapter->psFlash2xCSInfo); - bcm_kfree(psAdapter->psFlash2xVendorInfo); + kfree(psAdapter->psFlashCSInfo); + kfree(psAdapter->psFlash2xCSInfo); + kfree(psAdapter->psFlash2xVendorInfo); return STATUS_SUCCESS ; } @@ -2954,7 +2704,7 @@ static INT ConvertEndianOfCSStructure(PFLASH_CS_INFO psFlashCSInfo) return STATUS_SUCCESS; } -INT IsSectionExistInVendorInfo(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL section) +static INT IsSectionExistInVendorInfo(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL section) { return ( Adapter->uiVendorExtnFlag && (Adapter->psFlash2xVendorInfo->VendorSection[section].AccessFlags & FLASH2X_SECTION_PRESENT) && @@ -3052,7 +2802,7 @@ static VOID UpdateVendorInfo(PMINI_ADAPTER Adapter) // <VOID> //----------------------------------------------------------------------------- -INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter) +static INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter) { //FLASH_CS_INFO sFlashCsInfo = {0}; @@ -3070,7 +2820,6 @@ INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter) memset(Adapter->psFlashCSInfo, 0 ,sizeof(FLASH_CS_INFO)); memset(Adapter->psFlash2xCSInfo, 0 ,sizeof(FLASH2X_CS_INFO)); -#ifndef BCM_SHM_INTERFACE if(!Adapter->bDDRInitDone) { { @@ -3079,7 +2828,6 @@ INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter) } } -#endif // Reading first 8 Bytes to get the Flash Layout // MagicNumber(4 bytes) +FlashLayoutMinorVersion(2 Bytes) +FlashLayoutMajorVersion(2 Bytes) @@ -3147,9 +2895,7 @@ INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter) return STATUS_FAILURE; } ConvertEndianOf2XCSStructure(Adapter->psFlash2xCSInfo); -#ifndef BCM_SHM_INTERFACE BcmDumpFlash2XCSStructure(Adapter->psFlash2xCSInfo,Adapter); -#endif if((FLASH_CONTROL_STRUCT_SIGNATURE == Adapter->psFlash2xCSInfo->MagicNumber) && (SCSI_FIRMWARE_MINOR_VERSION <= MINOR_VERSION(Adapter->psFlash2xCSInfo->SCSIFirmwareVersion)) && (FLASH_SECTOR_SIZE_SIG == Adapter->psFlash2xCSInfo->FlashSectorSizeSig) && @@ -3181,21 +2927,10 @@ INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter) Concerns: what if CS sector size does not match with this sector size ??? what is the indication of AccessBitMap in CS in flash 2.x ???? */ -#ifndef BCM_SHM_INTERFACE Adapter->ulFlashID = BcmReadFlashRDID(Adapter); -#endif Adapter->uiFlashLayoutMajorVersion = uiFlashLayoutMajorVersion; - #if 0 - if(FLASH_PART_SST25VF080B == Adapter->ulFlashID) - { - // - // 1MB flash has been selected. we have to use 64K as sector size no matter what is kept in FLASH_CS. - // - Adapter->uiSectorSize = 0x10000; - } - #endif return STATUS_SUCCESS ; } @@ -3214,7 +2949,7 @@ INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter) // //----------------------------------------------------------------------------- -NVM_TYPE BcmGetNvmType(PMINI_ADAPTER Adapter) +static NVM_TYPE BcmGetNvmType(PMINI_ADAPTER Adapter) { UINT uiData = 0; @@ -3569,39 +3304,6 @@ INT BcmFlash2xBulkWrite( } /** -* ReadDSDHeader : Read the DSD map for the DSD Section val provided in Argument. -* @Adapter : Beceem Private Data Structure -* @psDSDHeader :Pointer of the buffer where header has to be read -* @dsd :value of the Dyanmic DSD like DSD0 of DSD1 or DSD2 -* -* Return Value:- -* if suceeds return STATUS_SUCCESS or negative error code. -**/ -INT ReadDSDHeader(PMINI_ADAPTER Adapter, PDSD_HEADER psDSDHeader, FLASH2X_SECTION_VAL dsd) -{ - INT Status = STATUS_SUCCESS; - - Status =BcmFlash2xBulkRead(Adapter, - (PUINT)psDSDHeader, - dsd, - Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader, - sizeof(DSD_HEADER)); - if(Status == STATUS_SUCCESS) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "DSDImageMagicNumber :0X%x", ntohl(psDSDHeader->DSDImageMagicNumber)); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "DSDImageSize :0X%x ",ntohl(psDSDHeader->DSDImageSize)); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "DSDImageCRC :0X%x",ntohl(psDSDHeader->DSDImageCRC)); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "DSDImagePriority :0X%x",ntohl(psDSDHeader->DSDImagePriority)); - } - else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"DSD Header read is failed with status :%d", Status); - } - - return Status; -} - -/** * BcmGetActiveDSD : Set the Active DSD in Adapter Structure which has to be dumped in DDR * @Adapter :-Drivers private Data Structure * @@ -3609,7 +3311,7 @@ INT ReadDSDHeader(PMINI_ADAPTER Adapter, PDSD_HEADER psDSDHeader, FLASH2X_SECTIO * Return STATUS_SUCESS if get sucess in setting the right DSD else negaive error code * **/ -INT BcmGetActiveDSD(PMINI_ADAPTER Adapter) +static INT BcmGetActiveDSD(PMINI_ADAPTER Adapter) { FLASH2X_SECTION_VAL uiHighestPriDSD = 0 ; @@ -3647,39 +3349,6 @@ INT BcmGetActiveDSD(PMINI_ADAPTER Adapter) return STATUS_SUCCESS; } -/** -* ReadISOUnReservedBytes : Read the ISO map for the ISO Section val provided in Argument. -* @Adapter : Driver Private Data Structure -* @psISOHeader :Pointer of the location where header has to be read -* @IsoImage :value of the Dyanmic ISO like ISO_IMAGE1 of ISO_IMAGE2 -* -* Return Value:- -* if suceeds return STATUS_SUCCESS or negative error code. -**/ - -INT ReadISOHeader(PMINI_ADAPTER Adapter, PISO_HEADER psISOHeader, FLASH2X_SECTION_VAL IsoImage) -{ - INT Status = STATUS_SUCCESS; - - Status = BcmFlash2xBulkRead(Adapter, - (PUINT)psISOHeader, - IsoImage, - 0, - sizeof(ISO_HEADER)); - - if(Status == STATUS_SUCCESS) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "ISOImageMagicNumber :0X%x", ntohl(psISOHeader->ISOImageMagicNumber)); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "ISOImageSize :0X%x ",ntohl(psISOHeader->ISOImageSize)); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "ISOImageCRC :0X%x",ntohl(psISOHeader->ISOImageCRC)); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "ISOImagePriority :0X%x",ntohl(psISOHeader->ISOImagePriority)); - } - else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "ISO Header Read failed"); - } - return Status; -} /** * BcmGetActiveISO :- Set the Active ISO in Adapter Data Structue @@ -3691,7 +3360,7 @@ INT ReadISOHeader(PMINI_ADAPTER Adapter, PISO_HEADER psISOHeader, FLASH2X_SECTIO * **/ -INT BcmGetActiveISO(PMINI_ADAPTER Adapter) +static INT BcmGetActiveISO(PMINI_ADAPTER Adapter) { INT HighestPriISO = 0 ; @@ -4588,7 +4257,7 @@ INT BcmCopyISO(PMINI_ADAPTER Adapter, FLASH2X_COPY_SECTION sCopySectStrut) } - bcm_kfree(Buff); + kfree(Buff); return Status; } @@ -4789,7 +4458,7 @@ Return Value:- Success :- Base Address of the Flash **/ -INT GetFlashBaseAddr(PMINI_ADAPTER Adapter) +static INT GetFlashBaseAddr(PMINI_ADAPTER Adapter) { UINT uiBaseAddr = 0; @@ -4866,20 +4535,6 @@ INT BcmCopySection(PMINI_ADAPTER Adapter, return -EINVAL; } - #if 0 - else - { - if((SrcSection == VSA0) || (SrcSection == VSA1) || (SrcSection == VSA2)) - { - if((DstSection != VSA0) && (DstSection != VSA1) && (DstSection != VSA2)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Source and Destion secton is not of same type"); - return -EINVAL; - } - } - - } - #endif //if offset zero means have to copy complete secton if(numOfBytes == 0) @@ -4954,7 +4609,7 @@ INT BcmCopySection(PMINI_ADAPTER Adapter, BytesToBeCopied = numOfBytes; } }while(numOfBytes > 0) ; - bcm_kfree(pBuff); + kfree(pBuff); Adapter->bHeaderChangeAllowed = FALSE ; return Status; } @@ -4979,14 +4634,6 @@ INT SaveHeaderIfPresent(PMINI_ADAPTER Adapter, PUCHAR pBuff, UINT uiOffset) UINT uiSectAlignAddr = 0; UINT sig = 0; - #if 0 - //if Chenges in Header is allowed, Return back - if(Adapter->bHeaderChangeAllowed == TRUE) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Header Change is allowed"); - return STATUS_SUCCESS ; - } - #endif //making the offset sector alligned uiSectAlignAddr = uiOffset & ~(Adapter->uiSectorSize - 1); @@ -5024,7 +4671,7 @@ INT SaveHeaderIfPresent(PMINI_ADAPTER Adapter, PUCHAR pBuff, UINT uiOffset) //Replace Buffer content with Header memcpy(pBuff +offsetToProtect,pTempBuff,HeaderSizeToProtect); - bcm_kfree(pTempBuff); + kfree(pTempBuff); } if(bHasHeader && Adapter->bSigCorrupted) { @@ -5044,29 +4691,7 @@ INT SaveHeaderIfPresent(PMINI_ADAPTER Adapter, PUCHAR pBuff, UINT uiOffset) return STATUS_SUCCESS ; } -INT BcmMakeFlashCSActive(PMINI_ADAPTER Adapter, UINT offset) -{ - UINT GPIOConfig = 0 ; - - - if(Adapter->bFlashRawRead == FALSE) - { - //Applicable for Flash2.x - if(IsFlash2x(Adapter) == FALSE) - return STATUS_SUCCESS; - } - if(offset/FLASH_PART_SIZE) - { - //bit[14..12] -> will select make Active CS1, CS2 or CS3 - // Select CS1, CS2 and CS3 (CS0 is dedicated pin) - rdmalt(Adapter,FLASH_GPIO_CONFIG_REG, &GPIOConfig, 4); - GPIOConfig |= (7 << 12); - wrmalt(Adapter,FLASH_GPIO_CONFIG_REG, &GPIOConfig, 4); - } - - return STATUS_SUCCESS ; -} /** BcmDoChipSelect : This will selcet the appropriate chip for writing. @Adapater :- Bcm Driver Private Data Structure @@ -5074,7 +4699,7 @@ BcmDoChipSelect : This will selcet the appropriate chip for writing. OutPut:- Select the Appropriate chip and retrn status Sucess **/ -INT BcmDoChipSelect(PMINI_ADAPTER Adapter, UINT offset) +static INT BcmDoChipSelect(PMINI_ADAPTER Adapter, UINT offset) { UINT FlashConfig = 0; INT ChipNum = 0; @@ -5365,39 +4990,6 @@ INT WriteToFlashWithoutSectorErase(PMINI_ADAPTER Adapter, return Status; } -#if 0 -UINT getNumOfSubSectionWithWRPermisson(PMINI_ADAPTER Adapter, SECTION_TYPE secType) -{ - - UINT numOfWRSubSec = 0; - switch(secType) - { - case ISO : - if(IsSectionWritable(Adapter,ISO_IMAGE1)) - numOfWRSubSec = numOfWRSubSec + 1; - if(IsSectionWritable(Adapter,ISO_IMAGE2)) - numOfWRSubSec = numOfWRSubSec + 1; - break; - - case DSD : - if(IsSectionWritable(Adapter,DSD2)) - numOfWRSubSec = numOfWRSubSec + 1; - if(IsSectionWritable(Adapter,DSD1)) - numOfWRSubSec = numOfWRSubSec + 1; - if(IsSectionWritable(Adapter,DSD0)) - numOfWRSubSec = numOfWRSubSec + 1; - break ; - - case VSA : - //for VSA Add code Here - default : - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Invalid secton<%d> is passed", secType);\ - numOfWRSubSec = 0; - - } - return numOfWRSubSec; -} -#endif BOOLEAN IsSectionExistInFlash(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL section) { @@ -5479,7 +5071,7 @@ INT IsSectionWritable(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL Section) return Status ; } -INT CorruptDSDSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal) +static INT CorruptDSDSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal) { PUCHAR pBuff = NULL; @@ -5543,16 +5135,16 @@ INT CorruptDSDSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal) else { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"BCM Signature is not present in header"); - bcm_kfree(pBuff); + kfree(pBuff); return STATUS_FAILURE; } - bcm_kfree(pBuff); + kfree(pBuff); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Corrupted the signature"); return STATUS_SUCCESS ; } -INT CorruptISOSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal) +static INT CorruptISOSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal) { PUCHAR pBuff = NULL; @@ -5593,14 +5185,14 @@ INT CorruptISOSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal) else { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"BCM Signature is not present in header"); - bcm_kfree(pBuff); + kfree(pBuff); return STATUS_FAILURE; } BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Corrupted the signature"); BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,pBuff,MAX_RW_SIZE); - bcm_kfree(pBuff); + kfree(pBuff); return STATUS_SUCCESS ; } diff --git a/drivers/staging/bcm/nvm.h b/drivers/staging/bcm/nvm.h index 6ec6ca85b501..651b5a455b32 100644 --- a/drivers/staging/bcm/nvm.h +++ b/drivers/staging/bcm/nvm.h @@ -323,15 +323,6 @@ typedef struct _ISO_HEADER -#ifdef BCM_SHM_INTERFACE - -#define FLASH_ADDR_MASK 0x1F000000 -extern int bcmflash_raw_read(unsigned int flash_id, unsigned int offset, unsigned char *inbuf, unsigned int len); -extern int bcmflash_raw_write(unsigned int flash_id, unsigned int offset, unsigned char *outbuf, unsigned int len); -extern int bcmflash_raw_writenoerase(unsigned int flash_id, unsigned int offset, unsigned char *outbuf, unsigned int len); - - -#endif #define FLASH_CONTIGIOUS_START_ADDR_AFTER_INIT 0x1C000000 #define FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT 0x1F000000 @@ -414,76 +405,5 @@ extern int bcmflash_raw_writenoerase(unsigned int flash_id, unsigned int offset, #define FIELD_OFFSET_IN_HEADER(HeaderPointer,Field) ((PUCHAR)&((HeaderPointer)(NULL))->Field - (PUCHAR)(NULL)) -#if 0 -INT BeceemEEPROMBulkRead( - PMINI_ADAPTER Adapter, - PUINT pBuffer, - UINT uiOffset, - UINT uiNumBytes); - - -INT BeceemFlashBulkRead( - PMINI_ADAPTER Adapter, - PUINT pBuffer, - UINT uiOffset, - UINT uiNumBytes); - -UINT BcmGetEEPROMSize(PMINI_ADAPTER Adapter); - -UINT BcmGetFlashSize(PMINI_ADAPTER Adapter); - -UINT BcmGetFlashSectorSize(PMINI_ADAPTER Adapter); - - - -INT BeceemFlashBulkWrite( - PMINI_ADAPTER Adapter, - PUINT pBuffer, - UINT uiOffset, - UINT uiNumBytes, - BOOLEAN bVerify); - -INT PropagateCalParamsFromFlashToMemory(PMINI_ADAPTER Adapter); - -INT PropagateCalParamsFromEEPROMToMemory(PMINI_ADAPTER Adapter); - - -INT BeceemEEPROMBulkWrite( - PMINI_ADAPTER Adapter, - PUCHAR pBuffer, - UINT uiOffset, - UINT uiNumBytes, - BOOLEAN bVerify); - - -INT ReadBeceemEEPROM(PMINI_ADAPTER Adapter,UINT dwAddress, UINT *pdwData); - -NVM_TYPE BcmGetNvmType(PMINI_ADAPTER Adapter); - -INT BeceemNVMRead( - PMINI_ADAPTER Adapter, - PUINT pBuffer, - UINT uiOffset, - UINT uiNumBytes); - -INT BeceemNVMWrite( - PMINI_ADAPTER Adapter, - PUINT pBuffer, - UINT uiOffset, - UINT uiNumBytes, - BOOLEAN bVerify); - -INT ReadMacAddressFromEEPROM(PMINI_ADAPTER Adapter); - -INT BcmUpdateSectorSize(PMINI_ADAPTER Adapter,UINT uiSectorSize); - -INT BcmInitNVM(PMINI_ADAPTER Adapter); - -VOID BcmValidateNvmType(PMINI_ADAPTER Adapter); - -VOID BcmGetFlashCSInfo(PMINI_ADAPTER Adapter); - -#endif - #endif diff --git a/drivers/staging/bcm/osal_misc.h b/drivers/staging/bcm/osal_misc.h deleted file mode 100644 index ff4adde17cd8..000000000000 --- a/drivers/staging/bcm/osal_misc.h +++ /dev/null @@ -1,49 +0,0 @@ - /*++ - - Copyright (c) Beceem Communications Inc. - - Module Name: - OSAL_Misc.h - - Abstract: - Provides the OS Abstracted macros to access: - Linked Lists - Dispatcher Objects(Events,Semaphores,Spin Locks and the like) - Files - - - Revision History: - Who When What - -------- -------- ---------------------------------------------- - Name Date Created/reviewed/modified - Rajeev 24/1/08 Created - Notes: - - --*/ -#ifndef _OSAL_MISC_H_ -#define _OSAL_MISC_H_ -//OSAL Macros -//OSAL Primitives -typedef PUCHAR POSAL_NW_PACKET ; //Nw packets - - -#define OsalMemAlloc(n,t) kmalloc(n,GFP_KERNEL) - -#define OsalMemFree(x,n) bcm_kfree(x) - -#define OsalMemMove(dest, src, len) \ -{ \ - memcpy(dest,src, len); \ -} - -#define OsalZeroMemory(pDest, Len) \ -{ \ - memset(pDest,0,Len); \ -} - -//#define OsalMemSet(pSrc,Char,Len) memset(pSrc,Char,Len) - -bool OsalMemCompare(void *dest, void *src, UINT len); - -#endif - |