Commit 2ff81110 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
parents a7bcf21e e5837cef
...@@ -7,53 +7,6 @@ ...@@ -7,53 +7,6 @@
#define MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES 256 #define MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES 256
#include "Debug.h" #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 struct _LEADER
{ {
USHORT Vcid; USHORT Vcid;
...@@ -429,26 +382,28 @@ Driver adapter data structure ...@@ -429,26 +382,28 @@ Driver adapter data structure
struct _MINI_ADAPTER struct _MINI_ADAPTER
{ {
struct _MINI_ADAPTER *next; struct _MINI_ADAPTER *next;
PVOID pvOsDepData; struct net_device *dev;
u32 msg_enable;
CHAR *caDsxReqResp; CHAR *caDsxReqResp;
atomic_t ApplicationRunning; atomic_t ApplicationRunning;
volatile INT CtrlQueueLen; volatile INT CtrlQueueLen;
atomic_t AppCtrlQueueLen; atomic_t AppCtrlQueueLen;
BOOLEAN AppCtrlQueueOverFlow; BOOLEAN AppCtrlQueueOverFlow;
atomic_t CurrentApplicationCount; atomic_t CurrentApplicationCount;
atomic_t RegisteredApplicationCount; atomic_t RegisteredApplicationCount;
BOOLEAN TimerActive; BOOLEAN LinkUpStatus;
ULONG StatisticsPointer; BOOLEAN TimerActive;
u32 StatisticsPointer;
struct sk_buff *RxControlHead; struct sk_buff *RxControlHead;
struct sk_buff *RxControlTail; struct sk_buff *RxControlTail;
// spinlock_t RxControlQueuelock;
struct semaphore RxAppControlQueuelock; struct semaphore RxAppControlQueuelock;
struct semaphore fw_download_sema; struct semaphore fw_download_sema;
PPER_TARANG_DATA pTarangs; PPER_TARANG_DATA pTarangs;
spinlock_t control_queue_lock; spinlock_t control_queue_lock;
wait_queue_head_t process_read_wait_queue; 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 // the pointer to the first packet we have queued in send
// deserialized miniport support variables // deserialized miniport support variables
...@@ -458,24 +413,15 @@ struct _MINI_ADAPTER ...@@ -458,24 +413,15 @@ struct _MINI_ADAPTER
// this to keep track of the Tx and Rx MailBox Registers. // this to keep track of the Tx and Rx MailBox Registers.
atomic_t CurrNumFreeTxDesc; atomic_t CurrNumFreeTxDesc;
// to keep track the no of byte recieved // to keep track the no of byte recieved
atomic_t RxRollOverCount;
USHORT PrevNumRecvDescs; USHORT PrevNumRecvDescs;
USHORT CurrNumRecvDescs; 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; UINT u32TotalDSD;
PacketInfo PackInfo[NO_OF_QUEUES]; PacketInfo PackInfo[NO_OF_QUEUES];
S_CLASSIFIER_RULE astClassifierTable[MAX_CLASSIFIERS]; S_CLASSIFIER_RULE astClassifierTable[MAX_CLASSIFIERS];
BOOLEAN TransferMode;
/*************** qos ******************/ /*************** qos ******************/
UINT bETHCSEnabled; BOOLEAN bETHCSEnabled;
ULONG BEBucketSize; ULONG BEBucketSize;
ULONG rtPSBucketSize; ULONG rtPSBucketSize;
...@@ -483,7 +429,6 @@ struct _MINI_ADAPTER ...@@ -483,7 +429,6 @@ struct _MINI_ADAPTER
BOOLEAN AutoLinkUp; BOOLEAN AutoLinkUp;
BOOLEAN AutoSyncup; BOOLEAN AutoSyncup;
struct net_device *dev;
int major; int major;
int minor; int minor;
wait_queue_head_t tx_packet_wait_queue; wait_queue_head_t tx_packet_wait_queue;
...@@ -491,8 +436,6 @@ struct _MINI_ADAPTER ...@@ -491,8 +436,6 @@ struct _MINI_ADAPTER
atomic_t process_waiting; atomic_t process_waiting;
BOOLEAN fw_download_done; BOOLEAN fw_download_done;
unsigned int ctrlpkt_present;
BOOLEAN packets_given_to_all;
char *txctlpacket[MAX_CNTRL_PKTS]; char *txctlpacket[MAX_CNTRL_PKTS];
atomic_t cntrlpktCnt ; atomic_t cntrlpktCnt ;
atomic_t index_app_read_cntrlpkt; atomic_t index_app_read_cntrlpkt;
...@@ -502,34 +445,30 @@ struct _MINI_ADAPTER ...@@ -502,34 +445,30 @@ struct _MINI_ADAPTER
struct semaphore rdmwrmsync; struct semaphore rdmwrmsync;
STTARGETDSXBUFFER astTargetDsxBuffer[MAX_TARGET_DSX_BUFFERS]; STTARGETDSXBUFFER astTargetDsxBuffer[MAX_TARGET_DSX_BUFFERS];
ULONG ulFreeTargetBufferCnt; ULONG ulFreeTargetBufferCnt;
ULONG ulCurrentTargetBuffer; ULONG ulCurrentTargetBuffer;
ULONG ulTotalTargetBuffersAvailable; ULONG ulTotalTargetBuffersAvailable;
unsigned int timeout;
int irq;
unsigned long chip_id; 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; wait_queue_head_t lowpower_mode_wait_queue;
atomic_t bAbortedByHost;
BOOLEAN bBinDownloaded; BOOLEAN bFlashBoot;
BOOLEAN bCfgDownloaded; BOOLEAN bBinDownloaded;
USHORT usBestEffortQueueIndex; BOOLEAN bCfgDownloaded;
BOOLEAN bSyncUpRequestSent; BOOLEAN bSyncUpRequestSent;
// struct semaphore data_packet_queue_lock; USHORT usBestEffortQueueIndex;
wait_queue_head_t ioctl_fw_dnld_wait_queue; wait_queue_head_t ioctl_fw_dnld_wait_queue;
BOOLEAN waiting_to_fw_download_done; BOOLEAN waiting_to_fw_download_done;
pid_t fw_download_process_pid; pid_t fw_download_process_pid;
PSTARGETPARAMS pstargetparams; PSTARGETPARAMS pstargetparams;
BOOLEAN device_removed; BOOLEAN device_removed;
BOOLEAN DeviceAccess; BOOLEAN DeviceAccess;
INT DDRSetting; BOOLEAN bIsAutoCorrectEnabled;
BOOLEAN bDDRInitDone; BOOLEAN bDDRInitDone;
INT DDRSetting;
ULONG ulPowerSaveMode; ULONG ulPowerSaveMode;
BOOLEAN bIsAutoCorrectEnabled;
spinlock_t txtransmitlock; spinlock_t txtransmitlock;
B_UINT8 txtransmit_running; B_UINT8 txtransmit_running;
/* Thread for control packet handling */ /* Thread for control packet handling */
...@@ -567,13 +506,13 @@ struct _MINI_ADAPTER ...@@ -567,13 +506,13 @@ struct _MINI_ADAPTER
unsigned int usIdleModePattern; unsigned int usIdleModePattern;
//BOOLEAN bTriedToWakeUpFromShutdown; //BOOLEAN bTriedToWakeUpFromShutdown;
BOOLEAN bLinkDownRequested; BOOLEAN bLinkDownRequested;
unsigned int check_for_hang;
int downloadDDR; int downloadDDR;
PHS_DEVICE_EXTENSION stBCMPhsContext; PHS_DEVICE_EXTENSION stBCMPhsContext;
S_HDR_SUPRESSION_CONTEXTINFO stPhsTxContextInfo; S_HDR_SUPRESSION_CONTEXTINFO stPhsTxContextInfo;
uint8_t ucaPHSPktRestoreBuf[2048]; uint8_t ucaPHSPktRestoreBuf[2048];
uint8_t bPHSEnabled; uint8_t bPHSEnabled;
int AutoFirmDld; BOOLEAN AutoFirmDld;
BOOLEAN bMipsConfig; BOOLEAN bMipsConfig;
BOOLEAN bDPLLConfig; BOOLEAN bDPLLConfig;
UINT32 aTxPktSizeHist[MIBS_MAX_HIST_ENTRIES]; UINT32 aTxPktSizeHist[MIBS_MAX_HIST_ENTRIES];
...@@ -599,10 +538,9 @@ struct _MINI_ADAPTER ...@@ -599,10 +538,9 @@ struct _MINI_ADAPTER
struct semaphore NVMRdmWrmLock; struct semaphore NVMRdmWrmLock;
BOOLEAN bNetworkInterfaceRegistered;
BOOLEAN bNetdeviceNotifierRegistered;
struct device *pstCreatedClassDevice; struct device *pstCreatedClassDevice;
BOOLEAN bUsbClassDriverRegistered;
// BOOLEAN InterfaceUpStatus; // BOOLEAN InterfaceUpStatus;
PFLASH2X_CS_INFO psFlash2xCSInfo; PFLASH2X_CS_INFO psFlash2xCSInfo;
PFLASH_CS_INFO psFlashCSInfo ; PFLASH_CS_INFO psFlashCSInfo ;
...@@ -630,17 +568,13 @@ struct _MINI_ADAPTER ...@@ -630,17 +568,13 @@ struct _MINI_ADAPTER
struct semaphore LowPowerModeSync; struct semaphore LowPowerModeSync;
ULONG liDrainCalculated; ULONG liDrainCalculated;
UINT gpioBitMap; UINT gpioBitMap;
S_BCM_DEBUG_STATE stDebugState; S_BCM_DEBUG_STATE stDebugState;
}; };
typedef struct _MINI_ADAPTER MINI_ADAPTER, *PMINI_ADAPTER; typedef struct _MINI_ADAPTER MINI_ADAPTER, *PMINI_ADAPTER;
#define GET_BCM_ADAPTER(net_dev) netdev_priv(net_dev)
typedef struct _DEVICE_EXTENSION
{
PMINI_ADAPTER pAdapt;
}DEVICE_EXTENSION,*PDEVICE_EXTENSION;
struct _ETH_HEADER_STRUC { struct _ETH_HEADER_STRUC {
UCHAR au8DestinationAddress[6]; UCHAR au8DestinationAddress[6];
......
/*
* 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;
}
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* *
* Returns - Zero(Success) * Returns - Zero(Success)
****************************************************************/ ****************************************************************/
static struct class *bcm_class = NULL;
static int bcm_char_open(struct inode *inode, struct file * filp) static int bcm_char_open(struct inode *inode, struct file * filp)
{ {
PMINI_ADAPTER Adapter = NULL; PMINI_ADAPTER Adapter = NULL;
...@@ -93,7 +93,7 @@ static int bcm_char_release(struct inode *inode, struct file *filp) ...@@ -93,7 +93,7 @@ static int bcm_char_release(struct inode *inode, struct file *filp)
/*Stop Queuing the control response Packets*/ /*Stop Queuing the control response Packets*/
atomic_dec(&Adapter->ApplicationRunning); atomic_dec(&Adapter->ApplicationRunning);
bcm_kfree(pTarang); kfree(pTarang);
/* remove this filp from the asynchronously notified filp's */ /* remove this filp from the asynchronously notified filp's */
filp->private_data = NULL; filp->private_data = NULL;
...@@ -102,11 +102,11 @@ static int bcm_char_release(struct inode *inode, struct file *filp) ...@@ -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) 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; PMINI_ADAPTER Adapter = pTarang->Adapter;
struct sk_buff* Packet = NULL; struct sk_buff* Packet = NULL;
UINT PktLen = 0; ssize_t PktLen = 0;
int wait_ret_val=0; int wait_ret_val=0;
wait_ret_val = wait_event_interruptible(Adapter->process_read_wait_queue, wait_ret_val = wait_event_interruptible(Adapter->process_read_wait_queue,
(pTarang->RxAppControlHead || Adapter->device_removed)); (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 ...@@ -139,14 +139,16 @@ static ssize_t bcm_char_read(struct file *filp, char __user *buf, size_t size, l
if(Packet) if(Packet)
{ {
PktLen = Packet->len; 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"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "\nReturning from copy to user failure \n");
return -EFAULT; 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_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
bcm_kfree_skb(Packet); "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"); 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 ...@@ -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) static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
{ {
PPER_TARANG_DATA pTarang = (PPER_TARANG_DATA)filp->private_data; PPER_TARANG_DATA pTarang = filp->private_data;
void __user *argp = (void __user *)argp; void __user *argp = (void __user *)arg;
PMINI_ADAPTER Adapter = pTarang->Adapter; PMINI_ADAPTER Adapter = pTarang->Adapter;
INT Status = STATUS_FAILURE; INT Status = STATUS_FAILURE;
IOCTL_BUFFER IoBuffer={}; int timeout = 0;
#ifndef BCM_SHM_INTERFACE IOCTL_BUFFER IoBuffer;
int timeout = 0;
#endif
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); 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) ...@@ -204,50 +203,41 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
Status = vendorextnIoctl(Adapter, cmd, arg); Status = vendorextnIoctl(Adapter, cmd, arg);
if(Status != CONTINUE_COMMON_PATH ) if(Status != CONTINUE_COMMON_PATH )
{
return Status; return Status;
}
switch(cmd){ switch(cmd){
// Rdms for Swin Idle... // Rdms for Swin Idle...
case IOCTL_BCM_REGISTER_READ_PRIVATE: case IOCTL_BCM_REGISTER_READ_PRIVATE:
{ {
RDM_BUFFER sRdmBuffer = {0}; RDM_BUFFER sRdmBuffer = {0};
PCHAR temp_buff = NULL; PCHAR temp_buff;
UINT Bufflen = 0; UINT Bufflen;
/* Copy Ioctl Buffer structure */ /* Copy Ioctl Buffer structure */
if(copy_from_user((PCHAR)&IoBuffer, argp, if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)))
sizeof(IOCTL_BUFFER))) return -EFAULT;
{
Status = -EFAULT; if (IoBuffer.InputLength > sizeof(sRdmBuffer))
break; 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; Bufflen = IoBuffer.OutputLength + (4 - IoBuffer.OutputLength%4)%4;
temp_buff = (PCHAR)kmalloc(Bufflen, GFP_KERNEL); temp_buff = kmalloc(Bufflen, GFP_KERNEL);
if(!temp_buff) if(!temp_buff)
{ return -ENOMEM;
return STATUS_FAILURE;
}
if(copy_from_user(&sRdmBuffer, IoBuffer.InputBuffer,
IoBuffer.InputLength))
{
Status = -EFAULT;
break;
}
Status = rdmalt(Adapter, (UINT)sRdmBuffer.Register, Status = rdmalt(Adapter, (UINT)sRdmBuffer.Register,
(PUINT)temp_buff, Bufflen); (PUINT)temp_buff, Bufflen);
if(Status != STATUS_SUCCESS) if(Status == STATUS_SUCCESS)
{
bcm_kfree(temp_buff);
return Status;
}
if(copy_to_user(IoBuffer.OutputBuffer,
(PCHAR)temp_buff, (UINT)IoBuffer.OutputLength))
{ {
Status = -EFAULT; if(copy_to_user(IoBuffer.OutputBuffer, temp_buff, IoBuffer.OutputLength))
Status = -EFAULT;
} }
bcm_kfree(temp_buff);
kfree(temp_buff);
break; break;
} }
case IOCTL_BCM_REGISTER_WRITE_PRIVATE: case IOCTL_BCM_REGISTER_WRITE_PRIVATE:
...@@ -256,19 +246,16 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -256,19 +246,16 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
UINT uiTempVar=0; UINT uiTempVar=0;
/* Copy Ioctl Buffer structure */ /* Copy Ioctl Buffer structure */
if(copy_from_user(&IoBuffer, argp, if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)))
sizeof(IOCTL_BUFFER))) return -EFAULT;
{
Status = -EFAULT; if (IoBuffer.InputLength > sizeof(sWrmBuffer))
break; return -EINVAL;
}
/* Get WrmBuffer structure */ /* Get WrmBuffer structure */
if(copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer, if(copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength))
IoBuffer.InputLength)) return -EFAULT;
{
Status = -EFAULT;
break;
}
uiTempVar = sWrmBuffer.Register & EEPROM_REJECT_MASK; uiTempVar = sWrmBuffer.Register & EEPROM_REJECT_MASK;
if(!((Adapter->pstargetparams->m_u32Customize) & VSG_MODE) && if(!((Adapter->pstargetparams->m_u32Customize) & VSG_MODE) &&
((uiTempVar == EEPROM_REJECT_REG_1)|| ((uiTempVar == EEPROM_REJECT_REG_1)||
...@@ -277,8 +264,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -277,8 +264,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
(uiTempVar == EEPROM_REJECT_REG_4))) (uiTempVar == EEPROM_REJECT_REG_4)))
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "EEPROM Access Denied, not in VSG Mode\n"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "EEPROM Access Denied, not in VSG Mode\n");
Status = -EFAULT; return -EFAULT;
break;
} }
Status = wrmalt(Adapter, (UINT)sWrmBuffer.Register, Status = wrmalt(Adapter, (UINT)sWrmBuffer.Register,
(PUINT)sWrmBuffer.Data, sizeof(ULONG)); (PUINT)sWrmBuffer.Data, sizeof(ULONG));
...@@ -305,56 +291,39 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -305,56 +291,39 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
(Adapter->bPreparingForLowPowerMode ==TRUE)) (Adapter->bPreparingForLowPowerMode ==TRUE))
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Device in Idle Mode, Blocking Rdms\n"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Device in Idle Mode, Blocking Rdms\n");
Status = -EACCES; return -EACCES;
break;
} }
/* Copy Ioctl Buffer structure */ /* Copy Ioctl Buffer structure */
if(copy_from_user(&IoBuffer, argp, if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)))
sizeof(IOCTL_BUFFER))) return -EFAULT;
{
Status = -EFAULT; if (IoBuffer.InputLength > sizeof(sRdmBuffer))
break; 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) if(!temp_buff)
{
return STATUS_FAILURE; return STATUS_FAILURE;
}
if(copy_from_user(&sRdmBuffer, IoBuffer.InputBuffer,
IoBuffer.InputLength))
{
Status = -EFAULT;
break;
}
if( if((((ULONG)sRdmBuffer.Register & 0x0F000000) != 0x0F000000) ||
#if !defined(BCM_SHM_INTERFACE) ((ULONG)sRdmBuffer.Register & 0x3))
(((ULONG)sRdmBuffer.Register & 0x0F000000) != 0x0F000000) ||
#endif
((ULONG)sRdmBuffer.Register & 0x3)
)
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "RDM Done On invalid Address : %x Access Denied.\n", BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "RDM Done On invalid Address : %x Access Denied.\n",
(int)sRdmBuffer.Register); (int)sRdmBuffer.Register);
Status = -EINVAL; return -EINVAL;
break;
} }
uiTempVar = sRdmBuffer.Register & EEPROM_REJECT_MASK; uiTempVar = sRdmBuffer.Register & EEPROM_REJECT_MASK;
Status = rdmaltWithLock(Adapter, (UINT)sRdmBuffer.Register, Status = rdmaltWithLock(Adapter, (UINT)sRdmBuffer.Register,
(PUINT)temp_buff, IoBuffer.OutputLength); (PUINT)temp_buff, IoBuffer.OutputLength);
if(Status != STATUS_SUCCESS) if(Status == STATUS_SUCCESS)
{ if(copy_to_user(IoBuffer.OutputBuffer, temp_buff, IoBuffer.OutputLength))
bcm_kfree(temp_buff); Status = -EFAULT;
return Status;
} kfree(temp_buff);
if(copy_to_user(IoBuffer.OutputBuffer,
(PCHAR)temp_buff, (UINT)IoBuffer.OutputLength))
{
Status = -EFAULT;
}
bcm_kfree(temp_buff);
break; break;
} }
case IOCTL_BCM_REGISTER_WRITE: case IOCTL_BCM_REGISTER_WRITE:
...@@ -367,36 +336,28 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -367,36 +336,28 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
(Adapter->bPreparingForLowPowerMode ==TRUE)) (Adapter->bPreparingForLowPowerMode ==TRUE))
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Device in Idle Mode, Blocking Wrms\n"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Device in Idle Mode, Blocking Wrms\n");
Status = -EACCES; return -EACCES;
break;
} }
/* Copy Ioctl Buffer structure */ /* Copy Ioctl Buffer structure */
if(copy_from_user((PCHAR)&IoBuffer, argp, if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)))
sizeof(IOCTL_BUFFER))) return -EFAULT;
{
Status = -EFAULT; if (IoBuffer.InputLength > sizeof(sWrmBuffer))
break; return -EINVAL;
}
/* Get WrmBuffer structure */ /* Get WrmBuffer structure */
if(copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer, if(copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength))
IoBuffer.InputLength)) return -EFAULT;
{
Status = -EFAULT;
break;
}
if(
#if !defined(BCM_SHM_INTERFACE)
(((ULONG)sWrmBuffer.Register & 0x0F000000) != 0x0F000000) || if( (((ULONG)sWrmBuffer.Register & 0x0F000000) != 0x0F000000) ||
#endif ((ULONG)sWrmBuffer.Register & 0x3) )
((ULONG)sWrmBuffer.Register & 0x3)
)
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "WRM Done On invalid Address : %x Access Denied.\n", BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "WRM Done On invalid Address : %x Access Denied.\n",
(int)sWrmBuffer.Register); (int)sWrmBuffer.Register);
Status = -EINVAL; return -EINVAL;
break;
} }
uiTempVar = sWrmBuffer.Register & EEPROM_REJECT_MASK; uiTempVar = sWrmBuffer.Register & EEPROM_REJECT_MASK;
if(!((Adapter->pstargetparams->m_u32Customize) & VSG_MODE) && if(!((Adapter->pstargetparams->m_u32Customize) & VSG_MODE) &&
((uiTempVar == EEPROM_REJECT_REG_1)|| ((uiTempVar == EEPROM_REJECT_REG_1)||
...@@ -406,8 +367,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -406,8 +367,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
(cmd == IOCTL_BCM_REGISTER_WRITE)) (cmd == IOCTL_BCM_REGISTER_WRITE))
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "EEPROM Access Denied, not in VSG Mode\n"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "EEPROM Access Denied, not in VSG Mode\n");
Status = -EFAULT; return -EFAULT;
break;
} }
Status = wrmaltWithLock(Adapter, (UINT)sWrmBuffer.Register, Status = wrmaltWithLock(Adapter, (UINT)sWrmBuffer.Register,
...@@ -436,19 +396,14 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -436,19 +396,14 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
(Adapter->bPreparingForLowPowerMode ==TRUE)) (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"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"GPIO Can't be set/clear in Low power Mode");
Status = -EACCES; return -EACCES;
break;
} }
if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)))
{ return -EFAULT;
Status = -EFAULT; if (IoBuffer.InputLength > sizeof(gpio_info))
break; return -EINVAL;
}
if(copy_from_user(&gpio_info, IoBuffer.InputBuffer, IoBuffer.InputLength)) if(copy_from_user(&gpio_info, IoBuffer.InputBuffer, IoBuffer.InputLength))
{ return -EFAULT;
Status = -EFAULT;
break;
}
uiBit = gpio_info.uiGpioNumber; uiBit = gpio_info.uiGpioNumber;
uiOperation = gpio_info.uiGpioValue; uiOperation = gpio_info.uiGpioValue;
...@@ -517,8 +472,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -517,8 +472,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
break; break;
case BCM_LED_THREAD_STATE_CHANGE_REQ: 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"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"User made LED thread InActive");
if((Adapter->IdleMode == TRUE) || if((Adapter->IdleMode == TRUE) ||
...@@ -529,21 +483,16 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -529,21 +483,16 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
Status = -EACCES; Status = -EACCES;
break; 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 (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)))
if(Status) return -EFAULT;
{
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying the InputBuffer from user space err:%d",Status); if (IoBuffer.InputLength > sizeof(threadReq))
Status = -EFAULT; return -EINVAL;
break;
} 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 LED thread is running(Actively or Inactively) set it state to make inactive
if(Adapter->LEDInfo.led_thread_running) if(Adapter->LEDInfo.led_thread_running)
{ {
...@@ -572,19 +521,13 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -572,19 +521,13 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
if((Adapter->IdleMode == TRUE) || if((Adapter->IdleMode == TRUE) ||
(Adapter->bShutStatus ==TRUE) || (Adapter->bShutStatus ==TRUE) ||
(Adapter->bPreparingForLowPowerMode ==TRUE)) (Adapter->bPreparingForLowPowerMode ==TRUE))
{ return -EACCES;
Status = -EACCES; if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)))
break; return -EFAULT;
} if (IoBuffer.InputLength > sizeof(gpio_info))
if(copy_from_user((PCHAR)&IoBuffer, argp, sizeof(IOCTL_BUFFER))) { return -EINVAL;
Status = -EFAULT; if(copy_from_user(&gpio_info, IoBuffer.InputBuffer, IoBuffer.InputLength))
break; return -EFAULT;
}
if(copy_from_user(&gpio_info, IoBuffer.InputBuffer, IoBuffer.InputLength))
{
Status = -EFAULT;
break;
}
uiBit = gpio_info.uiGpioNumber; uiBit = gpio_info.uiGpioNumber;
//Set the gpio output register //Set the gpio output register
Status = rdmaltWithLock(Adapter, (UINT)GPIO_PIN_STATE_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) ...@@ -608,25 +551,14 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
if((Adapter->IdleMode == TRUE) || if((Adapter->IdleMode == TRUE) ||
(Adapter->bShutStatus ==TRUE) || (Adapter->bShutStatus ==TRUE) ||
(Adapter->bPreparingForLowPowerMode ==TRUE)) (Adapter->bPreparingForLowPowerMode ==TRUE))
{ return -EINVAL;
Status = -EINVAL; if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)))
break; return -EFAULT;
} if (IoBuffer.InputLength > sizeof(gpio_multi_info))
Status = copy_from_user( (PCHAR)&IoBuffer, argp, sizeof( IOCTL_BUFFER)); return -EINVAL;
if(Status) if (copy_from_user(&gpio_multi_info, IoBuffer.InputBuffer, IoBuffer.InputLength))
{ return -EFAULT;
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( &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) 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); 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) ...@@ -686,7 +618,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
if(Status) if(Status)
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying Content to IOBufer for user space err:%d",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; break;
} }
} }
...@@ -700,25 +631,14 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -700,25 +631,14 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
if((Adapter->IdleMode == TRUE) || if((Adapter->IdleMode == TRUE) ||
(Adapter->bShutStatus ==TRUE) || (Adapter->bShutStatus ==TRUE) ||
(Adapter->bPreparingForLowPowerMode ==TRUE)) (Adapter->bPreparingForLowPowerMode ==TRUE))
{ return -EINVAL;
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;
}
Status = copy_from_user( &gpio_multi_mode, IoBuffer.InputBuffer, IoBuffer.InputLength); if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)))
if(Status) return -EFAULT;
{ if (IoBuffer.InputLength > sizeof(gpio_multi_mode))
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying the IOBufer Contents from user space err:%d",Status); return -EINVAL;
Status = -EFAULT; if (copy_from_user(&gpio_multi_mode, IoBuffer.InputBuffer, IoBuffer.InputLength))
break; return -EFAULT;
}
Status = rdmaltWithLock( Adapter, ( UINT) GPIO_MODE_REGISTER, ( PUINT) ucResetValue, sizeof( UINT)); Status = rdmaltWithLock( Adapter, ( UINT) GPIO_MODE_REGISTER, ( PUINT) ucResetValue, sizeof( UINT));
if( STATUS_SUCCESS != Status) if( STATUS_SUCCESS != Status)
...@@ -769,7 +689,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -769,7 +689,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
if(Status) if(Status)
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying Content to IOBufer for user space err:%d",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; break;
} }
} }
...@@ -783,24 +702,20 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -783,24 +702,20 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
case IOCTL_IDLE_REQ: case IOCTL_IDLE_REQ:
{ {
PVOID pvBuffer=NULL; PVOID pvBuffer=NULL;
/* Copy Ioctl Buffer structure */ /* Copy Ioctl Buffer structure */
if(copy_from_user(&IoBuffer, argp, if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)))
sizeof(IOCTL_BUFFER))) return -EFAULT;
{
Status = -EFAULT; /* FIXME: don't accept any length from user */
break; pvBuffer = kmalloc(IoBuffer.InputLength, GFP_KERNEL);
}
pvBuffer=kmalloc(IoBuffer.InputLength, GFP_KERNEL);
if(!pvBuffer) if(!pvBuffer)
{
return -ENOMEM; return -ENOMEM;
}
if(copy_from_user(pvBuffer, IoBuffer.InputBuffer, if(copy_from_user(pvBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength))
IoBuffer.InputLength))
{ {
Status = -EFAULT; Status = -EFAULT;
bcm_kfree(pvBuffer); kfree(pvBuffer);
break; break;
} }
...@@ -820,10 +735,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -820,10 +735,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
Status = CopyBufferToControlPacket(Adapter, (PVOID)pvBuffer); Status = CopyBufferToControlPacket(Adapter, (PVOID)pvBuffer);
cntrlEnd: cntrlEnd:
up(&Adapter->LowPowerModeSync); up(&Adapter->LowPowerModeSync);
bcm_kfree(pvBuffer); kfree(pvBuffer);
break; break;
} }
#ifndef BCM_SHM_INTERFACE
case IOCTL_BCM_BUFFER_DOWNLOAD_START: case IOCTL_BCM_BUFFER_DOWNLOAD_START:
{ {
INT NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock) ; INT NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock) ;
...@@ -844,7 +758,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -844,7 +758,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
Status = reset_card_proc(Adapter); Status = reset_card_proc(Adapter);
if(Status) 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->fw_download_sema);
up(&Adapter->NVMRdmWrmLock); up(&Adapter->NVMRdmWrmLock);
break; break;
...@@ -862,7 +776,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -862,7 +776,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
} }
case IOCTL_BCM_BUFFER_DOWNLOAD: 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); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Starting the firmware download PID =0x%x!!!!\n", current->pid);
do{ do{
if(!down_trylock(&Adapter->fw_download_sema)) if(!down_trylock(&Adapter->fw_download_sema))
...@@ -871,29 +785,23 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -871,29 +785,23 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
Status=-EINVAL; Status=-EINVAL;
break; break;
} }
/* Copy Ioctl Buffer structure */ /* Copy Ioctl Buffer structure */
if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)))
{ return -EFAULT;
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "copy_from_user 1 failed\n");
Status = -EFAULT;
break;
}
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Length for FW DLD is : %lx\n", BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Length for FW DLD is : %lx\n",
IoBuffer.InputLength); IoBuffer.InputLength);
psFwInfo=kmalloc(sizeof(*psFwInfo), GFP_KERNEL);
if (IoBuffer.InputLength > sizeof(FIRMWARE_INFO))
return -EINVAL;
psFwInfo = kmalloc(sizeof(*psFwInfo), GFP_KERNEL);
if(!psFwInfo) if(!psFwInfo)
{ return -ENOMEM;
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Failed to allocate buffer!!!!\n");
Status = -ENOMEM; if(copy_from_user(psFwInfo, IoBuffer.InputBuffer, IoBuffer.InputLength))
break; return -EFAULT;
}
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;
}
if(!psFwInfo->pvMappedFirmwareAddress || if(!psFwInfo->pvMappedFirmwareAddress ||
(psFwInfo->u32FirmwareLength == 0)) (psFwInfo->u32FirmwareLength == 0))
...@@ -929,7 +837,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -929,7 +837,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
if(Status != STATUS_SUCCESS) if(Status != STATUS_SUCCESS)
up(&Adapter->fw_download_sema); up(&Adapter->fw_download_sema);
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, OSAL_DBG, DBG_LVL_ALL, "IOCTL: Firmware File Uploaded\n"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, OSAL_DBG, DBG_LVL_ALL, "IOCTL: Firmware File Uploaded\n");
bcm_kfree(psFwInfo); kfree(psFwInfo);
break; break;
} }
case IOCTL_BCM_BUFFER_DOWNLOAD_STOP: case IOCTL_BCM_BUFFER_DOWNLOAD_STOP:
...@@ -946,7 +854,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -946,7 +854,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
Adapter->bBinDownloaded=TRUE; Adapter->bBinDownloaded=TRUE;
Adapter->bCfgDownloaded=TRUE; Adapter->bCfgDownloaded=TRUE;
atomic_set(&Adapter->CurrNumFreeTxDesc, 0); atomic_set(&Adapter->CurrNumFreeTxDesc, 0);
atomic_set(&Adapter->RxRollOverCount, 0);
Adapter->CurrNumRecvDescs=0; Adapter->CurrNumRecvDescs=0;
Adapter->downloadDDR = 0; Adapter->downloadDDR = 0;
...@@ -999,7 +907,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -999,7 +907,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
up(&Adapter->NVMRdmWrmLock); up(&Adapter->NVMRdmWrmLock);
break; break;
} }
#endif
case IOCTL_BE_BUCKET_SIZE: case IOCTL_BE_BUCKET_SIZE:
Adapter->BEBucketSize = *(PULONG)arg; Adapter->BEBucketSize = *(PULONG)arg;
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
...@@ -1044,22 +951,16 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1044,22 +951,16 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
break; break;
case IOCTL_GET_PACK_INFO: case IOCTL_GET_PACK_INFO:
if(copy_to_user(argp, &Adapter->PackInfo, if(copy_to_user(argp, &Adapter->PackInfo, sizeof(PacketInfo)*NO_OF_QUEUES))
sizeof(PacketInfo)*NO_OF_QUEUES)) return -EFAULT;
{
Status = -EFAULT;
break;
}
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
break; break;
case IOCTL_BCM_SWITCH_TRANSFER_MODE: case IOCTL_BCM_SWITCH_TRANSFER_MODE:
{ {
UINT uiData = 0; UINT uiData = 0;
if(copy_from_user(&uiData, argp, sizeof(UINT))) if(copy_from_user(&uiData, argp, sizeof(UINT)))
{ return -EFAULT;
Status = -EFAULT;
break;
}
if(uiData) /* Allow All Packets */ 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"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SWITCH_TRANSFER_MODE: ETH_PACKET_TUNNELING_MODE\n");
...@@ -1078,22 +979,17 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1078,22 +979,17 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
{ {
/* Copy Ioctl Buffer structure */ /* Copy Ioctl Buffer structure */
if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)))
{ return -EFAULT;
Status = -EFAULT;
break; if(copy_to_user(IoBuffer.OutputBuffer, VER_FILEVERSION_STR, IoBuffer.OutputLength))
} return -EFAULT;
if(copy_to_user(IoBuffer.OutputBuffer,
VER_FILEVERSION_STR, (UINT)IoBuffer.OutputLength))
{
Status = -EFAULT;
break;
}
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
break; break;
} }
case IOCTL_BCM_GET_CURRENT_STATUS: case IOCTL_BCM_GET_CURRENT_STATUS:
{ {
LINK_STATE *plink_state = NULL; LINK_STATE link_state;
/* Copy Ioctl Buffer structure */ /* Copy Ioctl Buffer structure */
if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)))
{ {
...@@ -1101,12 +997,15 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1101,12 +997,15 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
Status = -EFAULT; Status = -EFAULT;
break; break;
} }
plink_state = (LINK_STATE*)arg;
plink_state->bIdleMode = (UCHAR)Adapter->IdleMode;
plink_state->bShutdownMode = Adapter->bShutStatus; memset(&link_state, 0, sizeof(link_state));
plink_state->ucLinkStatus = (UCHAR)Adapter->LinkStatus; link_state.bIdleMode = Adapter->IdleMode;
if(copy_to_user(IoBuffer.OutputBuffer, link_state.bShutdownMode = Adapter->bShutStatus;
(PUCHAR)plink_state, (UINT)IoBuffer.OutputLength)) 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"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy_to_user Failed..\n");
Status = -EFAULT; Status = -EFAULT;
...@@ -1118,17 +1017,14 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1118,17 +1017,14 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
case IOCTL_BCM_SET_MAC_TRACING: case IOCTL_BCM_SET_MAC_TRACING:
{ {
UINT tracing_flag; UINT tracing_flag;
/* copy ioctl Buffer structure */ /* copy ioctl Buffer structure */
if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)))
{ return -EFAULT;
Status = -EFAULT;
break; if(copy_from_user(&tracing_flag,IoBuffer.InputBuffer,sizeof(UINT)))
} return -EFAULT;
if(copy_from_user(&tracing_flag, IoBuffer.InputBuffer,sizeof(UINT)))
{
Status = -EFAULT;
break;
}
if (tracing_flag) if (tracing_flag)
Adapter->pTarangs->MacTracingEnabled = TRUE; Adapter->pTarangs->MacTracingEnabled = TRUE;
else else
...@@ -1138,72 +1034,53 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1138,72 +1034,53 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
case IOCTL_BCM_GET_DSX_INDICATION: case IOCTL_BCM_GET_DSX_INDICATION:
{ {
ULONG ulSFId=0; ULONG ulSFId=0;
if(copy_from_user((PCHAR)&IoBuffer, argp, if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)))
sizeof(IOCTL_BUFFER))) return -EFAULT;
{
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Invalid IO buffer!!!" );
Status = -EFAULT;
break;
}
if(IoBuffer.OutputLength < sizeof(stLocalSFAddIndicationAlt)) if(IoBuffer.OutputLength < sizeof(stLocalSFAddIndicationAlt))
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Mismatch req: %lx needed is =0x%zx!!!", BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,
IoBuffer.OutputLength, sizeof(stLocalSFAddIndicationAlt)); "Mismatch req: %lx needed is =0x%zx!!!",
IoBuffer.OutputLength, sizeof(stLocalSFAddIndicationAlt));
return -EINVAL; return -EINVAL;
} }
if(copy_from_user(&ulSFId, IoBuffer.InputBuffer,
sizeof(ulSFId))) if(copy_from_user(&ulSFId, IoBuffer.InputBuffer, sizeof(ulSFId)))
{ return -EFAULT;
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Invalid SFID!!! %lu", ulSFId );
Status = -EFAULT;
break;
}
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Get DSX Data SF ID is =%lx\n", ulSFId ); 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, get_dsx_sf_data_to_application(Adapter, ulSFId, IoBuffer.OutputBuffer);
IoBuffer.OutputBuffer);
Status=STATUS_SUCCESS; Status=STATUS_SUCCESS;
} }
break; break;
case IOCTL_BCM_GET_HOST_MIBS: case IOCTL_BCM_GET_HOST_MIBS:
{ {
PCHAR temp_buff; PVOID temp_buff;
if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)))
{ return -EFAULT;
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy_from user for IoBuff failed\n");
Status = -EFAULT;
break;
}
if(IoBuffer.OutputLength != sizeof(S_MIBS_HOST_STATS_MIBS)) 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, BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,
sizeof(S_MIBS_HOST_STATS_MIBS)); "Length Check failed %lu %zd\n",
return -EINVAL; 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) if(!temp_buff)
{
return STATUS_FAILURE; return STATUS_FAILURE;
}
Status = ProcessGetHostMibs(Adapter,
(PUCHAR)temp_buff, IoBuffer.OutputLength);
Status = GetDroppedAppCntrlPktMibs((PVOID)temp_buff, Status = ProcessGetHostMibs(Adapter, temp_buff);
(PPER_TARANG_DATA)filp->private_data); GetDroppedAppCntrlPktMibs(temp_buff, pTarang);
if(copy_to_user(IoBuffer.OutputBuffer,(PCHAR)temp_buff, if (Status != STATUS_FAILURE)
sizeof(S_MIBS_HOST_STATS_MIBS))) if(copy_to_user(IoBuffer.OutputBuffer, temp_buff, sizeof(S_MIBS_HOST_STATS_MIBS)))
{ Status = -EFAULT;
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy to user failed\n");
bcm_kfree(temp_buff);
return -EFAULT;
}
bcm_kfree(temp_buff); kfree(temp_buff);
break; break;
} }
...@@ -1213,10 +1090,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1213,10 +1090,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
Adapter->usIdleModePattern = ABORT_IDLE_MODE; Adapter->usIdleModePattern = ABORT_IDLE_MODE;
Adapter->bWakeUpDevice = TRUE; Adapter->bWakeUpDevice = TRUE;
wake_up(&Adapter->process_rx_cntrlpkt); wake_up(&Adapter->process_rx_cntrlpkt);
#if 0
Adapter->bTriedToWakeUpFromlowPowerMode = TRUE;
InterfaceAbortIdlemode (Adapter, Adapter->usIdleModePattern);
#endif
} }
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
break; break;
...@@ -1235,24 +1108,20 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1235,24 +1108,20 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
Status = -EACCES; Status = -EACCES;
break; break;
} }
/* Copy Ioctl Buffer structure */ /* Copy Ioctl Buffer structure */
if(copy_from_user((PCHAR)&IoBuffer, argp, sizeof(IOCTL_BUFFER))) if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)))
{ return -EFAULT;
Status = -EFAULT;
break;
}
pvBuffer=kmalloc(IoBuffer.InputLength, GFP_KERNEL); /* FIXME: restrict length */
pvBuffer = kmalloc(IoBuffer.InputLength, GFP_KERNEL);
if(!pvBuffer) if(!pvBuffer)
{
return -ENOMEM; return -ENOMEM;
break;
}
/* Get WrmBuffer structure */ /* 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; Status = -EFAULT;
break; break;
} }
...@@ -1262,7 +1131,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1262,7 +1131,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
if(((ULONG)pBulkBuffer->Register & 0x0F000000) != 0x0F000000 || if(((ULONG)pBulkBuffer->Register & 0x0F000000) != 0x0F000000 ||
((ULONG)pBulkBuffer->Register & 0x3)) ((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); BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0,"WRM Done On invalid Address : %x Access Denied.\n",(int)pBulkBuffer->Register);
Status = -EINVAL; Status = -EINVAL;
break; break;
...@@ -1277,7 +1146,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1277,7 +1146,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
(uiTempVar == EEPROM_REJECT_REG_4)) && (uiTempVar == EEPROM_REJECT_REG_4)) &&
(cmd == IOCTL_BCM_REGISTER_WRITE)) (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"); BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0,"EEPROM Access Denied, not in VSG Mode\n");
Status = -EFAULT; Status = -EFAULT;
break; break;
...@@ -1293,30 +1162,19 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1293,30 +1162,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_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "WRM Failed\n");
} }
bcm_kfree(pvBuffer); kfree(pvBuffer);
break; break;
} }
case IOCTL_BCM_GET_NVM_SIZE: case IOCTL_BCM_GET_NVM_SIZE:
{
if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)))
{ return -EFAULT;
//IOLog("failed NVM first");
Status = -EFAULT;
break;
}
if(Adapter->eNVMType == NVM_EEPROM || Adapter->eNVMType == NVM_FLASH ) { if(Adapter->eNVMType == NVM_EEPROM || Adapter->eNVMType == NVM_FLASH ) {
if(copy_to_user(IoBuffer.OutputBuffer, if(copy_to_user(IoBuffer.OutputBuffer, &Adapter->uiNVMDSDSize, sizeof(UINT)))
(unsigned char *)&Adapter->uiNVMDSDSize, (UINT)sizeof(UINT))) return -EFAULT;
{
Status = -EFAULT;
return Status;
}
} }
Status = STATUS_SUCCESS ; Status = STATUS_SUCCESS ;
}
break; break;
case IOCTL_BCM_CAL_INIT : case IOCTL_BCM_CAL_INIT :
...@@ -1325,38 +1183,26 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1325,38 +1183,26 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
UINT uiSectorSize = 0 ; UINT uiSectorSize = 0 ;
if(Adapter->eNVMType == NVM_FLASH) if(Adapter->eNVMType == NVM_FLASH)
{ {
Status = copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)); if(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);
return -EFAULT; return -EFAULT;
}
uiSectorSize = *((PUINT)(IoBuffer.InputBuffer)); /* FIXME: unchecked __user access */ if (copy_from_user(&uiSectorSize, IoBuffer.InputBuffer, sizeof(UINT)))
return -EFAULT;
if((uiSectorSize < MIN_SECTOR_SIZE) || (uiSectorSize > MAX_SECTOR_SIZE)) if((uiSectorSize < MIN_SECTOR_SIZE) || (uiSectorSize > MAX_SECTOR_SIZE))
{ {
if (copy_to_user(IoBuffer.OutputBuffer, &Adapter->uiSectorSize,
Status = copy_to_user(IoBuffer.OutputBuffer, sizeof(UINT)))
(unsigned char *)&Adapter->uiSectorSize , return -EFAULT;
(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;
}
} }
else else
{ {
if(IsFlash2x(Adapter)) if(IsFlash2x(Adapter))
{ {
Status = copy_to_user(IoBuffer.OutputBuffer, if (copy_to_user(IoBuffer.OutputBuffer,
(unsigned char *)&Adapter->uiSectorSize , &Adapter->uiSectorSize ,
(UINT)sizeof(UINT)); sizeof(UINT)))
if(Status) return -EFAULT;
{
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Coping the sector size to use space failed. status:%d",Status);
return -EFAULT;
}
} }
else else
{ {
...@@ -1380,25 +1226,19 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1380,25 +1226,19 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
} }
break; break;
case IOCTL_BCM_SET_DEBUG : case IOCTL_BCM_SET_DEBUG :
#ifdef DEBUG
{ {
USER_BCM_DBG_STATE sUserDebugState; 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_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"); 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 (copy_from_user(&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");
return -EFAULT; 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 ", BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "IOCTL_BCM_SET_DEBUG: OnOff=%d Type = 0x%x ",
sUserDebugState.OnOff, sUserDebugState.Type); sUserDebugState.OnOff, sUserDebugState.Type);
...@@ -1421,15 +1261,14 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1421,15 +1261,14 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
BCM_SHOW_DEBUG_BITMAP(Adapter); BCM_SHOW_DEBUG_BITMAP(Adapter);
} }
#endif
break; break;
case IOCTL_BCM_NVM_READ: case IOCTL_BCM_NVM_READ:
case IOCTL_BCM_NVM_WRITE: case IOCTL_BCM_NVM_WRITE:
{ {
NVM_READWRITE stNVMReadWrite;
NVM_READWRITE stNVMReadWrite = {};
PUCHAR pReadData = NULL; PUCHAR pReadData = NULL;
void __user * pBuffertobeCopied = NULL; ULONG ulDSDMagicNumInUsrBuff = 0;
ULONG ulDSDMagicNumInUsrBuff = 0 ;
struct timeval tv0, tv1; struct timeval tv0, tv1;
memset(&tv0,0,sizeof(struct timeval)); memset(&tv0,0,sizeof(struct timeval));
memset(&tv1,0,sizeof(struct timeval)); memset(&tv1,0,sizeof(struct timeval));
...@@ -1454,21 +1293,12 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1454,21 +1293,12 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
/* Copy Ioctl Buffer structure */ /* Copy Ioctl Buffer structure */
if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)))
{ return -EFAULT;
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;
if(copy_from_user(&stNVMReadWrite, pBuffertobeCopied,sizeof(NVM_READWRITE))) if(copy_from_user(&stNVMReadWrite,
{ (IOCTL_BCM_NVM_READ == cmd) ? IoBuffer.OutputBuffer : IoBuffer.InputBuffer,
Status = -EFAULT; sizeof(NVM_READWRITE)))
break; return -EFAULT;
}
// //
// Deny the access if the offset crosses the cal area limit. // Deny the access if the offset crosses the cal area limit.
...@@ -1481,18 +1311,15 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1481,18 +1311,15 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
break; break;
} }
pReadData =(PCHAR)kmalloc(stNVMReadWrite.uiNumBytes, GFP_KERNEL); pReadData = kzalloc(stNVMReadWrite.uiNumBytes, GFP_KERNEL);
if(!pReadData) if(!pReadData)
return -ENOMEM; return -ENOMEM;
memset(pReadData,0,stNVMReadWrite.uiNumBytes);
if(copy_from_user(pReadData, stNVMReadWrite.pBuffer, if(copy_from_user(pReadData, stNVMReadWrite.pBuffer,
stNVMReadWrite.uiNumBytes)) stNVMReadWrite.uiNumBytes))
{ {
Status = -EFAULT; Status = -EFAULT;
bcm_kfree(pReadData); kfree(pReadData);
break; break;
} }
...@@ -1507,7 +1334,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1507,7 +1334,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"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n");
up(&Adapter->NVMRdmWrmLock); up(&Adapter->NVMRdmWrmLock);
bcm_kfree(pReadData); kfree(pReadData);
return -EACCES; return -EACCES;
} }
...@@ -1518,13 +1345,12 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1518,13 +1345,12 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
if(Status != STATUS_SUCCESS) if(Status != STATUS_SUCCESS)
{ {
bcm_kfree(pReadData); kfree(pReadData);
return Status; return Status;
} }
if(copy_to_user(stNVMReadWrite.pBuffer, if(copy_to_user(stNVMReadWrite.pBuffer,pReadData, stNVMReadWrite.uiNumBytes))
pReadData, (UINT)stNVMReadWrite.uiNumBytes))
{ {
bcm_kfree(pReadData); kfree(pReadData);
Status = -EFAULT; Status = -EFAULT;
} }
} }
...@@ -1539,7 +1365,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1539,7 +1365,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"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n");
up(&Adapter->NVMRdmWrmLock); up(&Adapter->NVMRdmWrmLock);
bcm_kfree(pReadData); kfree(pReadData);
return -EACCES; return -EACCES;
} }
...@@ -1567,7 +1393,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1567,7 +1393,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.."); 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); up(&Adapter->NVMRdmWrmLock);
bcm_kfree(pReadData); kfree(pReadData);
return Status; return Status;
} }
...@@ -1576,7 +1402,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1576,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.."); 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); up(&Adapter->NVMRdmWrmLock);
bcm_kfree(pReadData); kfree(pReadData);
return Status; return Status;
} }
} }
...@@ -1593,7 +1419,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1593,7 +1419,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
if(Status != STATUS_SUCCESS) if(Status != STATUS_SUCCESS)
{ {
bcm_kfree(pReadData); kfree(pReadData);
return Status; return Status;
} }
} }
...@@ -1601,7 +1427,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1601,7 +1427,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_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; Status = STATUS_SUCCESS;
} }
break; break;
...@@ -1614,7 +1440,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1614,7 +1440,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
UINT BuffSize = 0; UINT BuffSize = 0;
UINT ReadBytes = 0; UINT ReadBytes = 0;
UINT ReadOffset = 0; UINT ReadOffset = 0;
char __user *OutPutBuff = NULL; void __user *OutPutBuff;
if(IsFlash2x(Adapter) != TRUE) if(IsFlash2x(Adapter) != TRUE)
{ {
...@@ -1623,20 +1449,12 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1623,20 +1449,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"); 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 (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)))
if(Status)
{
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed");
return -EFAULT; return -EFAULT;
}
//Reading FLASH 2.x READ structure //Reading FLASH 2.x READ structure
Status = copy_from_user(&sFlash2xRead, IoBuffer.InputBuffer,sizeof(FLASH2X_READWRITE)); if (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");
return -EFAULT; return -EFAULT;
}
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.Section :%x" ,sFlash2xRead.Section); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.Section :%x" ,sFlash2xRead.Section);
...@@ -1672,7 +1490,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1672,7 +1490,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"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n");
up(&Adapter->NVMRdmWrmLock); up(&Adapter->NVMRdmWrmLock);
bcm_kfree(pReadBuff); kfree(pReadBuff);
return -EACCES; return -EACCES;
} }
...@@ -1700,7 +1518,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1700,7 +1518,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
if(Status) if(Status)
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Copy to use failed with status :%d", Status); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Copy to use failed with status :%d", Status);
Status = -EFAULT;
break; break;
} }
NOB = NOB - ReadBytes; NOB = NOB - ReadBytes;
...@@ -1712,15 +1529,15 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1712,15 +1529,15 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
} }
up(&Adapter->NVMRdmWrmLock); up(&Adapter->NVMRdmWrmLock);
bcm_kfree(pReadBuff); kfree(pReadBuff);
} }
break ; break ;
case IOCTL_BCM_FLASH2X_SECTION_WRITE : case IOCTL_BCM_FLASH2X_SECTION_WRITE :
{ {
FLASH2X_READWRITE sFlash2xWrite = {0}; FLASH2X_READWRITE sFlash2xWrite = {0};
PUCHAR pWriteBuff = NULL; PUCHAR pWriteBuff;
void __user *InputAddr = NULL; void __user *InputAddr;
UINT NOB = 0; UINT NOB = 0;
UINT BuffSize = 0; UINT BuffSize = 0;
UINT WriteOffset = 0; UINT WriteOffset = 0;
...@@ -1737,33 +1554,17 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1737,33 +1554,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"); 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 (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)))
if(Status)
{
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed");
return -EFAULT; return -EFAULT;
}
//Reading FLASH 2.x READ structure //Reading FLASH 2.x READ structure
Status = copy_from_user(&sFlash2xWrite, IoBuffer.InputBuffer, sizeof(FLASH2X_READWRITE)); if (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");
return -EFAULT; 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.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.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.numOfBytes :%x" ,sFlash2xWrite.numOfBytes);
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.bVerify :%x\n" ,sFlash2xWrite.bVerify); 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) && if((sFlash2xWrite.Section != VSA0) && (sFlash2xWrite.Section != VSA1) &&
(sFlash2xWrite.Section != VSA2) ) (sFlash2xWrite.Section != VSA2) )
{ {
...@@ -1783,12 +1584,10 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1783,12 +1584,10 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
else else
BuffSize = NOB ; BuffSize = NOB ;
pWriteBuff = (PCHAR)kmalloc(BuffSize, GFP_KERNEL); pWriteBuff = kmalloc(BuffSize, GFP_KERNEL);
if(pWriteBuff == NULL) if(pWriteBuff == NULL)
{
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Memory allocation failed for Flash 2.x Read Structure");
return -ENOMEM; return -ENOMEM;
}
//extracting the remainder of the given offset. //extracting the remainder of the given offset.
WriteBytes = Adapter->uiSectorSize ; WriteBytes = Adapter->uiSectorSize ;
...@@ -1805,7 +1604,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1805,7 +1604,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"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n");
up(&Adapter->NVMRdmWrmLock); up(&Adapter->NVMRdmWrmLock);
bcm_kfree(pWriteBuff); kfree(pWriteBuff);
return -EACCES; return -EACCES;
} }
...@@ -1816,7 +1615,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1816,7 +1615,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
if(Status) if(Status)
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Copy to user failed with status :%d", Status); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Copy to user failed with status :%d", Status);
Status = -EFAULT;
break ; break ;
} }
BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,pWriteBuff,WriteBytes); BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,pWriteBuff,WriteBytes);
...@@ -1844,28 +1642,22 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1844,28 +1642,22 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
} while(NOB > 0); } while(NOB > 0);
BcmFlash2xWriteSig(Adapter,sFlash2xWrite.Section); BcmFlash2xWriteSig(Adapter,sFlash2xWrite.Section);
up(&Adapter->NVMRdmWrmLock); up(&Adapter->NVMRdmWrmLock);
bcm_kfree(pWriteBuff); kfree(pWriteBuff);
} }
break ; break ;
case IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP : 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"); 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 (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)))
if(Status)
{
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed");
return -EFAULT; return -EFAULT;
}
if(IoBuffer.OutputLength != sizeof(FLASH2X_BITMAP)) if(IoBuffer.OutputLength != sizeof(FLASH2X_BITMAP))
{ return -EINVAL;
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Structure size mismatch Lib :0x%lx Driver :0x%zx ",IoBuffer.OutputLength, sizeof(FLASH2X_BITMAP));
break;
}
psFlash2xBitMap = (PFLASH2X_BITMAP)kzalloc(sizeof(FLASH2X_BITMAP), GFP_KERNEL); psFlash2xBitMap = kzalloc(sizeof(FLASH2X_BITMAP), GFP_KERNEL);
if(psFlash2xBitMap == NULL) if(psFlash2xBitMap == NULL)
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Memory is not available"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Memory is not available");
...@@ -1880,20 +1672,16 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1880,20 +1672,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"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n");
up(&Adapter->NVMRdmWrmLock); up(&Adapter->NVMRdmWrmLock);
bcm_kfree(psFlash2xBitMap); kfree(psFlash2xBitMap);
return -EACCES; return -EACCES;
} }
BcmGetFlash2xSectionalBitMap(Adapter, psFlash2xBitMap); BcmGetFlash2xSectionalBitMap(Adapter, psFlash2xBitMap);
up(&Adapter->NVMRdmWrmLock); up(&Adapter->NVMRdmWrmLock);
Status = copy_to_user(IoBuffer.OutputBuffer, psFlash2xBitMap, sizeof(FLASH2X_BITMAP)); if (copy_to_user(IoBuffer.OutputBuffer, psFlash2xBitMap, sizeof(FLASH2X_BITMAP)))
if(Status) Status = -EFAULT;
{
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "copying Flash2x bitMap failed"); kfree(psFlash2xBitMap);
bcm_kfree(psFlash2xBitMap);
return -EFAULT;
}
bcm_kfree(psFlash2xBitMap);
} }
break ; break ;
case IOCTL_BCM_SET_ACTIVE_SECTION : case IOCTL_BCM_SET_ACTIVE_SECTION :
...@@ -1911,14 +1699,14 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1911,14 +1699,14 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
if(Status) if(Status)
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); 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) if(Status)
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of flash section val failed"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of flash section val failed");
return -EFAULT; return Status;
} }
down(&Adapter->NVMRdmWrmLock); down(&Adapter->NVMRdmWrmLock);
...@@ -1946,29 +1734,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1946,29 +1734,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
Adapter->bAllDSDWriteAllow = FALSE ; Adapter->bAllDSDWriteAllow = FALSE ;
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"IOCTL_BCM_IDENTIFY_ACTIVE_SECTION called"); 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 ; Status = STATUS_SUCCESS ;
} }
break ; break ;
...@@ -1989,14 +1754,14 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -1989,14 +1754,14 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
if(Status) if(Status)
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed Status :%d", 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) if(Status)
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of Copy_Section_Struct failed with Status :%d", 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, "Source SEction :%x", sCopySectStrut.SrcSection);
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Destination SEction :%x", sCopySectStrut.DstSection); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Destination SEction :%x", sCopySectStrut.DstSection);
...@@ -2067,7 +1832,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -2067,7 +1832,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
if(Status) if(Status)
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed");
Status = -EFAULT;
break; break;
} }
if(Adapter->eNVMType != NVM_FLASH) if(Adapter->eNVMType != NVM_FLASH)
...@@ -2080,35 +1844,18 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -2080,35 +1844,18 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
{ {
if(IoBuffer.OutputLength < sizeof(FLASH2X_CS_INFO)) if(IoBuffer.OutputLength < sizeof(FLASH2X_CS_INFO))
{ return -EINVAL;
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;
}
Status = copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlash2xCSInfo, sizeof(FLASH2X_CS_INFO)); if (copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlash2xCSInfo, sizeof(FLASH2X_CS_INFO)))
if(Status) return -EFAULT;
{
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "copying Flash2x cs info failed");
Status = -EFAULT;
break;
}
} }
else else
{ {
if(IoBuffer.OutputLength < sizeof(FLASH_CS_INFO)) if(IoBuffer.OutputLength < sizeof(FLASH_CS_INFO))
{ return -EINVAL;
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; if (copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlashCSInfo, sizeof(FLASH_CS_INFO)))
break; return -EFAULT;
}
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;
}
} }
} }
...@@ -2130,13 +1877,13 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -2130,13 +1877,13 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
if(Status) if(Status)
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); 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) if(Status)
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of flash section val failed"); 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); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Read Section :%d", eFlash2xSectionVal);
...@@ -2166,13 +1913,13 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -2166,13 +1913,13 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
case IOCTL_BCM_NVM_RAW_READ : case IOCTL_BCM_NVM_RAW_READ :
{ {
NVM_READWRITE stNVMRead = {}; NVM_READWRITE stNVMRead;
INT NOB ; INT NOB ;
INT BuffSize ; INT BuffSize ;
INT ReadOffset = 0; INT ReadOffset = 0;
UINT ReadBytes = 0 ; UINT ReadBytes = 0 ;
PUCHAR pReadBuff = NULL ; PUCHAR pReadBuff;
char __user *OutPutBuff = NULL ; void __user *OutPutBuff;
if(Adapter->eNVMType != NVM_FLASH) if(Adapter->eNVMType != NVM_FLASH)
{ {
...@@ -2189,10 +1936,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -2189,10 +1936,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
} }
if(copy_from_user(&stNVMRead, IoBuffer.OutputBuffer,sizeof(NVM_READWRITE))) if(copy_from_user(&stNVMRead, IoBuffer.OutputBuffer,sizeof(NVM_READWRITE)))
{ return -EFAULT;
Status = -EFAULT;
break;
}
NOB = stNVMRead.uiNumBytes; NOB = stNVMRead.uiNumBytes;
//In Raw-Read max Buff size : 64MB //In Raw-Read max Buff size : 64MB
...@@ -2202,11 +1946,10 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -2202,11 +1946,10 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
else else
BuffSize = NOB ; BuffSize = NOB ;
ReadOffset = stNVMRead.uiOffset ; ReadOffset = stNVMRead.uiOffset;
OutPutBuff = stNVMRead.pBuffer; OutPutBuff = stNVMRead.pBuffer;
pReadBuff = kzalloc(BuffSize , GFP_KERNEL);
pReadBuff = (PCHAR)kzalloc(BuffSize , GFP_KERNEL);
if(pReadBuff == NULL) if(pReadBuff == NULL)
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Memory allocation failed for Flash 2.x Read Structure"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Memory allocation failed for Flash 2.x Read Structure");
...@@ -2220,7 +1963,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -2220,7 +1963,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
(Adapter->bPreparingForLowPowerMode ==TRUE)) (Adapter->bPreparingForLowPowerMode ==TRUE))
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n"); 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); up(&Adapter->NVMRdmWrmLock);
return -EACCES; return -EACCES;
} }
...@@ -2241,13 +1984,12 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -2241,13 +1984,12 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
break; 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); Status = copy_to_user(OutPutBuff, pReadBuff,ReadBytes);
if(Status) if(Status)
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Copy to use failed with status :%d", Status); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Copy to use failed with status :%d", Status);
Status = -EFAULT;
break; break;
} }
NOB = NOB - ReadBytes; NOB = NOB - ReadBytes;
...@@ -2260,7 +2002,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -2260,7 +2002,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
} }
Adapter->bFlashRawRead = FALSE ; Adapter->bFlashRawRead = FALSE ;
up(&Adapter->NVMRdmWrmLock); up(&Adapter->NVMRdmWrmLock);
bcm_kfree(pReadBuff); kfree(pReadBuff);
break ; break ;
} }
...@@ -2273,7 +2015,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -2273,7 +2015,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
if(Status) if(Status)
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"copy of Ioctl buffer is failed from user space"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"copy of Ioctl buffer is failed from user space");
Status = -EFAULT;
break; break;
} }
...@@ -2281,7 +2022,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -2281,7 +2022,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
if(Status) if(Status)
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"copy of control bit mask failed from user space"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"copy of control bit mask failed from user space");
Status = -EFAULT;
break; break;
} }
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\n Got user defined cntrl msg bit mask :%lx", RxCntrlMsgBitMask); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\n Got user defined cntrl msg bit mask :%lx", RxCntrlMsgBitMask);
...@@ -2300,71 +2040,44 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -2300,71 +2040,44 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
DevInfo.u32NVMType = Adapter->eNVMType; DevInfo.u32NVMType = Adapter->eNVMType;
DevInfo.u32InterfaceType = BCM_USB; DevInfo.u32InterfaceType = BCM_USB;
Status = copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)); if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)))
if(Status) return -EFAULT;
{
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed");
Status = -EFAULT;
break;
}
if(IoBuffer.OutputLength < sizeof(DevInfo)) if(IoBuffer.OutputLength < sizeof(DevInfo))
{ return -EINVAL;
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)); if (copy_to_user(IoBuffer.OutputBuffer, &DevInfo, sizeof(DevInfo)))
Status = -EINVAL; return -EFAULT;
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;
}
} }
break ; break ;
case IOCTL_BCM_TIME_SINCE_NET_ENTRY: case IOCTL_BCM_TIME_SINCE_NET_ENTRY:
{ {
ST_TIME_ELAPSED stTimeElapsedSinceNetEntry = {0}; 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"); 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 (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)))
if(Status) return -EFAULT;
{
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed");
Status = -EFAULT;
break;
}
if(IoBuffer.OutputLength < sizeof(ST_TIME_ELAPSED)) if(IoBuffer.OutputLength < sizeof(ST_TIME_ELAPSED))
{ return -EINVAL;
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;
}
//stTimeElapsedSinceNetEntry.ul64TimeElapsedSinceNetEntry = Adapter->liTimeSinceLastNetEntry; stTimeElapsedSinceNetEntry.ul64TimeElapsedSinceNetEntry = get_seconds() - Adapter->liTimeSinceLastNetEntry;
do_gettimeofday(&tv);
stTimeElapsedSinceNetEntry.ul64TimeElapsedSinceNetEntry = tv.tv_sec - Adapter->liTimeSinceLastNetEntry;
Status = copy_to_user(IoBuffer.OutputBuffer, &stTimeElapsedSinceNetEntry, sizeof(ST_TIME_ELAPSED)); if (copy_to_user(IoBuffer.OutputBuffer, &stTimeElapsedSinceNetEntry, sizeof(ST_TIME_ELAPSED)))
if(Status) return -EFAULT;
{
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"copying ST_TIME_ELAPSED structure to user space buffer failed");
Status = -EFAULT;
break;
}
} }
break; break;
default: case IOCTL_CLOSE_NOTIFICATION:
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,"IOCTL_CLOSE_NOTIFICATION");
BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "In default ioctl %d\n", cmd); break;
Status = STATUS_FAILURE;
default:
pr_info(DRV_NAME ": unknown ioctl cmd=%#x\n", cmd);
Status = STATUS_FAILURE;
break; break;
} }
return Status; return Status;
...@@ -2380,59 +2093,37 @@ static struct file_operations bcm_fops = { ...@@ -2380,59 +2093,37 @@ static struct file_operations bcm_fops = {
.llseek = no_llseek, .llseek = no_llseek,
}; };
extern struct class *bcm_class;
int register_control_device_interface(PMINI_ADAPTER Adapter) int register_control_device_interface(PMINI_ADAPTER Adapter)
{ {
if(Adapter->major>0) if(Adapter->major>0)
return Adapter->major; return Adapter->major;
Adapter->major = register_chrdev(0, "tarang", &bcm_fops);
if(Adapter->major < 0) Adapter->major = register_chrdev(0, DEV_NAME, &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!"); pr_err(DRV_NAME ": could not created character device\n");
return Adapter->major; 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;
} }
Adapter->pstCreatedClassDevice = device_create (bcm_class, NULL, Adapter->pstCreatedClassDevice = device_create (bcm_class, NULL,
MKDEV(Adapter->major, 0), MKDEV(Adapter->major, 0), Adapter,
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26) DEV_NAME);
NULL ,
#endif
"tarang");
if(IS_ERR(Adapter->pstCreatedClassDevice)) if(IS_ERR(Adapter->pstCreatedClassDevice)) {
{ pr_err(DRV_NAME ": class device create failed\n");
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "class device did not get created : %ld", PTR_ERR(Adapter->pstCreatedClassDevice) ); 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) void unregister_control_device_interface(PMINI_ADAPTER Adapter)
{ {
if(Adapter->major > 0) if(Adapter->major > 0) {
{
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "destroying class device");
device_destroy (bcm_class, MKDEV(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");
}
} }
#include "headers.h" #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(dev);
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
//PMINI_ADAPTER Adapter = (PMINI_ADAPTER)ndev->priv; if (Adapter->fw_download_done == FALSE) {
if(strncmp(ndev->name,gblpnetdev->name,5)==0) pr_notice(PFX "%s: link up failed (download in progress)\n",
{ dev->name);
switch(event) return -EBUSY;
{
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;
};
} }
return NOTIFY_DONE;
}
/* Notifier block to receive netdevice events */ if (netif_msg_ifup(Adapter))
static struct notifier_block bcm_notifier_block = pr_info(PFX "%s: enabling interface\n", dev->name);
{
.notifier_call = bcm_notify_event,
};
struct net_device *gblpnetdev; if (Adapter->LinkUpStatus) {
/***************************************************************************************/ if (netif_msg_link(Adapter))
/* proto-type of lower function */ pr_info(PFX "%s: link up\n", dev->name);
#ifdef BCM_SHM_INTERFACE
const char *bcmVirtDeviceName="bcmeth";
#endif
static INT bcm_open(struct net_device *dev) netif_carrier_on(Adapter->dev);
{ netif_start_queue(Adapter->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);
}
} }
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "<======"); return 0;
return 0;
} }
static INT bcm_close(struct net_device *dev) static INT bcm_close(struct net_device *dev)
{ {
PMINI_ADAPTER Adapter = NULL ;//gpadapter ; PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
Adapter = GET_BCM_ADAPTER(dev);
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "=====>"); if (netif_msg_ifdown(Adapter))
Adapter->if_up=0; pr_info(PFX "%s: disabling interface\n", dev->name);
if(!netif_queue_stopped(dev)) {
netif_carrier_off(dev); netif_carrier_off(dev);
netif_stop_queue(dev); netif_stop_queue(dev);
}
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"<====="); return 0;
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 = GET_BCM_ADAPTER(dev);
PMINI_ADAPTER Adapter = NULL ;// gpadapter ; u16 qindex = skb_get_queue_mapping(skb);
Adapter = GET_BCM_ADAPTER(dev);
pLinuxData = (PLINUX_DEP_DATA)(Adapter->pvOsDepData);
if (Adapter->device_removed || !Adapter->LinkUpStatus)
//BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Dev = %p, pLinuxData = %p", dev, pLinuxData); goto drop;
pLinuxData->netstats.rx_packets=atomic_read(&Adapter->RxRollOverCount)*64*1024+Adapter->PrevNumRecvDescs;
pLinuxData->netstats.rx_bytes=atomic_read(&Adapter->GoodRxByteCount)+atomic_read(&Adapter->BadRxByteCount); if (Adapter->TransferMode != IP_PACKET_ONLY_MODE)
pLinuxData->netstats.rx_dropped=atomic_read(&Adapter->RxPacketDroppedCount); goto drop;
pLinuxData->netstats.rx_errors=atomic_read(&Adapter->RxPacketDroppedCount);
pLinuxData->netstats.rx_length_errors=0; if (INVALID_QUEUE_INDEX == qindex)
pLinuxData->netstats.rx_frame_errors=0; goto drop;
pLinuxData->netstats.rx_crc_errors=0;
pLinuxData->netstats.tx_bytes=atomic_read(&Adapter->GoodTxByteCount); if (Adapter->PackInfo[qindex].uiCurrentPacketsOnHost >=
pLinuxData->netstats.tx_packets=atomic_read(&Adapter->TxTotalPacketCount); SF_MAX_ALLOWED_PACKETS_TO_BACKUP)
pLinuxData->netstats.tx_dropped=atomic_read(&Adapter->TxDroppedPacketCount); return NETDEV_TX_BUSY;
return &(pLinuxData->netstats); /* 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 @ingroup init_functions
Register other driver entry points with the kernel Register other driver entry points with the kernel
*/ */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) static const struct net_device_ops bcmNetDevOps = {
static struct net_device_ops bcmNetDevOps = {
.ndo_open = bcm_open, .ndo_open = bcm_open,
.ndo_stop = bcm_close, .ndo_stop = bcm_close,
.ndo_get_stats = bcm_get_stats,
.ndo_start_xmit = bcm_transmit, .ndo_start_xmit = bcm_transmit,
.ndo_change_mtu = eth_change_mtu, .ndo_change_mtu = eth_change_mtu,
.ndo_set_mac_address = eth_mac_addr, .ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_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; cmd->supported = 0;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) cmd->advertising = 0;
void **temp = NULL; /* actually we're *allocating* the device in alloc_etherdev */ cmd->speed = SPEED_10000;
#endif cmd->duplex = DUPLEX_FULL;
Adapter->dev = alloc_etherdev(sizeof(PMINI_ADAPTER)); cmd->port = PORT_TP;
if(!Adapter->dev) cmd->phy_address = 0;
{ cmd->transceiver = XCVR_INTERNAL;
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "ERR: No Dev"); cmd->autoneg = AUTONEG_DISABLE;
return -ENOMEM; cmd->maxtxpkt = 0;
} cmd->maxrxpkt = 0;
gblpnetdev = Adapter->dev; return 0;
#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);
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 */ strcpy(info->driver, DRV_NAME);
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Registering netdevice notifier\n"); strcpy(info->version, DRV_VERSION);
result = register_netdevice_notifier(&bcm_notifier_block); snprintf(info->fw_version, sizeof(info->fw_version), "%u.%u",
if(result) Adapter->uiFlashLayoutMajorVersion,
{ Adapter->uiFlashLayoutMinorVersion);
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;
}
#else usb_make_path(udev, info->bus_info, sizeof(info->bus_info));
}
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;
}
#if 0 static u32 bcm_get_link(struct net_device *dev)
Adapter->stDebugState.debug_level = DBG_LVL_CURR; {
Adapter->stDebugState.type =(UINT)0xffffffff; PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
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;
printk("-------ps_adapter->stDebugState.type=%x\n",Adapter->stDebugState.type); return Adapter->LinkUpStatus;
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 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"); PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
if(Adapter->dev && !IS_ERR(Adapter->dev) && Adapter->bNetworkInterfaceRegistered)
unregister_netdev(Adapter->dev); Adapter->msg_enable = level;
/* 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);
}
} }
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; int result;
result = InterfaceInitialize();
if(result) net->netdev_ops = &bcmNetDevOps;
{ net->ethtool_ops = &bcm_ethtool_ops;
printk("Initialisation failed for usbbcm"); net->mtu = MTU_SIZE; /* 1400 Bytes */
} net->tx_queue_len = TX_QLEN;
else net->flags |= IFF_NOARP;
{
printk("Initialised usbbcm"); 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) gblpnetdev = Adapter->dev;
{
printk("%s %s Calling InterfaceExit\n",__FILE__, __FUNCTION__);
InterfaceExit();
printk("%s %s InterfaceExit returned\n",__FILE__, __FUNCTION__);
}
module_init(bcm_init); if (netif_msg_probe(Adapter))
module_exit(bcm_exit); dev_info(&udev->dev, PFX "%s: register usb-%s-%s %pM\n",
MODULE_LICENSE ("GPL"); 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);
}
...@@ -15,6 +15,7 @@ typedef enum _E_CLASSIFIER_ACTION ...@@ -15,6 +15,7 @@ typedef enum _E_CLASSIFIER_ACTION
eDeleteClassifier eDeleteClassifier
}E_CLASSIFIER_ACTION; }E_CLASSIFIER_ACTION;
static ULONG GetNextTargetBufferLocation(PMINI_ADAPTER Adapter,B_UINT16 tid);
/************************************************************ /************************************************************
* Function - SearchSfid * Function - SearchSfid
...@@ -28,7 +29,7 @@ typedef enum _E_CLASSIFIER_ACTION ...@@ -28,7 +29,7 @@ typedef enum _E_CLASSIFIER_ACTION
* Returns - Queue index for this SFID(If matched) * Returns - Queue index for this SFID(If matched)
Else Invalid Queue Index(If Not 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; INT iIndex=0;
for(iIndex=(NO_OF_QUEUES-1); iIndex>=0; iIndex--) for(iIndex=(NO_OF_QUEUES-1); iIndex>=0; iIndex--)
...@@ -47,26 +48,16 @@ __inline INT SearchSfid(PMINI_ADAPTER Adapter,UINT uiSfid) ...@@ -47,26 +48,16 @@ __inline INT SearchSfid(PMINI_ADAPTER Adapter,UINT uiSfid)
* Returns - Queue index for the free SFID * Returns - Queue index for the free SFID
* Else returns Invalid Index. * Else returns Invalid Index.
****************************************************************/ ****************************************************************/
__inline INT SearchFreeSfid(PMINI_ADAPTER Adapter) static INT SearchFreeSfid(PMINI_ADAPTER Adapter)
{ {
UINT uiIndex=0; UINT uiIndex=0;
for(uiIndex=0; uiIndex < (NO_OF_QUEUES-1); uiIndex++) for(uiIndex=0; uiIndex < (NO_OF_QUEUES-1); uiIndex++)
if(Adapter->PackInfo[uiIndex].ulSFID==0) if(Adapter->PackInfo[uiIndex].ulSFID==0)
return uiIndex; return uiIndex;
return NO_OF_QUEUES+1; 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 Function: SearchClsid
Description: This routinue would search Classifier having specified ClassifierID as input parameter Description: This routinue would search Classifier having specified ClassifierID as input parameter
...@@ -76,7 +67,7 @@ Input parameters: PMINI_ADAPTER Adapter - Adapter Context ...@@ -76,7 +67,7 @@ Input parameters: PMINI_ADAPTER Adapter - Adapter Context
Return: int :Classifier table index of matching entry 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; unsigned int uiClassifierIndex = 0;
for(uiClassifierIndex=0;uiClassifierIndex<MAX_CLASSIFIERS;uiClassifierIndex++) for(uiClassifierIndex=0;uiClassifierIndex<MAX_CLASSIFIERS;uiClassifierIndex++)
...@@ -94,7 +85,7 @@ __inline int SearchClsid(PMINI_ADAPTER Adapter,ULONG ulSFID,B_UINT16 uiClassifi ...@@ -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. This routinue would search Free available Classifier entry in classifier table.
@return free Classifier Entry index in classifier table for specified SF @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; unsigned int uiClassifierIndex = 0;
...@@ -106,7 +97,7 @@ static __inline int SearchFreeClsid(PMINI_ADAPTER Adapter /**Adapter Context*/ ...@@ -106,7 +97,7 @@ static __inline int SearchFreeClsid(PMINI_ADAPTER Adapter /**Adapter Context*/
return MAX_CLASSIFIERS+1; 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 //deleting all the packet held in the SF
flush_queue(Adapter,uiSearchRuleIndex); flush_queue(Adapter,uiSearchRuleIndex);
...@@ -985,7 +976,7 @@ static VOID CopyToAdapter( register PMINI_ADAPTER Adapter, /**<Pointer to the A ...@@ -985,7 +976,7 @@ static VOID CopyToAdapter( register PMINI_ADAPTER Adapter, /**<Pointer to the A
if(Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication) 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 = NULL;
} }
Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication = pstAddIndication; Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication = pstAddIndication;
...@@ -1061,12 +1052,6 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) ...@@ -1061,12 +1052,6 @@ static VOID DumpCmControlPacket(PVOID pvBuffer)
pstAddIndication->sfAuthorizedSet.u32MaxTrafficBurst); pstAddIndication->sfAuthorizedSet.u32MaxTrafficBurst);
BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MinReservedTrafficRate : 0x%X", BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MinReservedTrafficRate : 0x%X",
pstAddIndication->sfAuthorizedSet.u32MinReservedTrafficRate); 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", BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParamLength : 0x%X",
pstAddIndication->sfAuthorizedSet.u8VendorSpecificQoSParamLength); pstAddIndication->sfAuthorizedSet.u8VendorSpecificQoSParamLength);
BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParam : 0x%X", BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParam : 0x%X",
...@@ -1114,13 +1099,6 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) ...@@ -1114,13 +1099,6 @@ static VOID DumpCmControlPacket(PVOID pvBuffer)
pstAddIndication->sfAuthorizedSet.u8PagingPreference); pstAddIndication->sfAuthorizedSet.u8PagingPreference);
BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16UnsolicitedPollingInterval : 0x%X", BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16UnsolicitedPollingInterval : 0x%X",
pstAddIndication->sfAuthorizedSet.u16UnsolicitedPollingInterval); 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 ", BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "sfAuthorizedSet.u8HARQChannelMapping %x %x %x ",
*(unsigned int*)pstAddIndication->sfAuthorizedSet.u8HARQChannelMapping, *(unsigned int*)pstAddIndication->sfAuthorizedSet.u8HARQChannelMapping,
...@@ -1158,11 +1136,6 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) ...@@ -1158,11 +1136,6 @@ static VOID DumpCmControlPacket(PVOID pvBuffer)
psfCSType->cCPacketClassificationRule.u8IPTypeOfService[0], psfCSType->cCPacketClassificationRule.u8IPTypeOfService[0],
psfCSType->cCPacketClassificationRule.u8IPTypeOfService[1], psfCSType->cCPacketClassificationRule.u8IPTypeOfService[1],
psfCSType->cCPacketClassificationRule.u8IPTypeOfService[2]); 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++) for(uiLoopIndex=0; uiLoopIndex < 1; uiLoopIndex++)
BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Protocol : 0x%02X ", BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Protocol : 0x%02X ",
...@@ -1278,14 +1251,6 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) ...@@ -1278,14 +1251,6 @@ static VOID DumpCmControlPacket(PVOID pvBuffer)
pstAddIndication->sfAdmittedSet.u8QosParamSet); pstAddIndication->sfAdmittedSet.u8QosParamSet);
BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficPriority : 0x%02X", BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficPriority : 0x%02X",
pstAddIndication->sfAdmittedSet.u8TrafficPriority); 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", BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaxTrafficBurst : 0x%X",
pstAddIndication->sfAdmittedSet.u32MaxTrafficBurst); pstAddIndication->sfAdmittedSet.u32MaxTrafficBurst);
BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MinReservedTrafficRate : 0x%X", BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MinReservedTrafficRate : 0x%X",
...@@ -1339,13 +1304,6 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) ...@@ -1339,13 +1304,6 @@ static VOID DumpCmControlPacket(PVOID pvBuffer)
pstAddIndication->sfAdmittedSet.u16TimeBase); pstAddIndication->sfAdmittedSet.u16TimeBase);
BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8PagingPreference : 0x%X", BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8PagingPreference : 0x%X",
pstAddIndication->sfAdmittedSet.u8PagingPreference); 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", BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficIndicationPreference : 0x%02X",
...@@ -1378,11 +1336,6 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) ...@@ -1378,11 +1336,6 @@ static VOID DumpCmControlPacket(PVOID pvBuffer)
psfCSType->cCPacketClassificationRule.u8IPTypeOfService[0], psfCSType->cCPacketClassificationRule.u8IPTypeOfService[0],
psfCSType->cCPacketClassificationRule.u8IPTypeOfService[1], psfCSType->cCPacketClassificationRule.u8IPTypeOfService[1],
psfCSType->cCPacketClassificationRule.u8IPTypeOfService[2]); 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++) for(uiLoopIndex=0; uiLoopIndex < 1; uiLoopIndex++)
BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Protocol: 0x%02X ", BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Protocol: 0x%02X ",
psfCSType->cCPacketClassificationRule.u8Protocol); psfCSType->cCPacketClassificationRule.u8Protocol);
...@@ -1497,20 +1450,10 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) ...@@ -1497,20 +1450,10 @@ static VOID DumpCmControlPacket(PVOID pvBuffer)
pstAddIndication->sfActiveSet.u8QosParamSet); pstAddIndication->sfActiveSet.u8QosParamSet);
BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficPriority : 0x%02X", BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficPriority : 0x%02X",
pstAddIndication->sfActiveSet.u8TrafficPriority); 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", BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaxTrafficBurst : 0x%X",
pstAddIndication->sfActiveSet.u32MaxTrafficBurst); pstAddIndication->sfActiveSet.u32MaxTrafficBurst);
BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MinReservedTrafficRate : 0x%X", BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MinReservedTrafficRate : 0x%X",
pstAddIndication->sfActiveSet.u32MinReservedTrafficRate); 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", BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParamLength : 0x%02X",
pstAddIndication->sfActiveSet.u8VendorSpecificQoSParamLength); pstAddIndication->sfActiveSet.u8VendorSpecificQoSParamLength);
BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParam : 0x%02X", BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParam : 0x%02X",
...@@ -1558,13 +1501,6 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) ...@@ -1558,13 +1501,6 @@ static VOID DumpCmControlPacket(PVOID pvBuffer)
pstAddIndication->sfActiveSet.u16TimeBase); pstAddIndication->sfActiveSet.u16TimeBase);
BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8PagingPreference : 0x%X", BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8PagingPreference : 0x%X",
pstAddIndication->sfActiveSet.u8PagingPreference); 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", BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8TrafficIndicationPreference : 0x%X",
...@@ -1597,11 +1533,6 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) ...@@ -1597,11 +1533,6 @@ static VOID DumpCmControlPacket(PVOID pvBuffer)
psfCSType->cCPacketClassificationRule.u8IPTypeOfService[0], psfCSType->cCPacketClassificationRule.u8IPTypeOfService[0],
psfCSType->cCPacketClassificationRule.u8IPTypeOfService[1], psfCSType->cCPacketClassificationRule.u8IPTypeOfService[1],
psfCSType->cCPacketClassificationRule.u8IPTypeOfService[2]); 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++) for(uiLoopIndex=0; uiLoopIndex < 1; uiLoopIndex++)
BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8Protocol : 0x%X ", BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8Protocol : 0x%X ",
psfCSType->cCPacketClassificationRule.u8Protocol); psfCSType->cCPacketClassificationRule.u8Protocol);
...@@ -1706,12 +1637,8 @@ static inline ULONG RestoreSFParam(PMINI_ADAPTER Adapter, ULONG ulAddrSFParamSet ...@@ -1706,12 +1637,8 @@ static inline ULONG RestoreSFParam(PMINI_ADAPTER Adapter, ULONG ulAddrSFParamSet
return 0; return 0;
} }
ulAddrSFParamSet = ntohl(ulAddrSFParamSet); 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 //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) if(rdm(Adapter, ulAddrSFParamSet, (PUCHAR)pucDestBuffer, nBytesToRead) < 0)
return STATUS_FAILURE; return STATUS_FAILURE;
...@@ -1719,7 +1646,7 @@ static inline ULONG RestoreSFParam(PMINI_ADAPTER Adapter, ULONG ulAddrSFParamSet ...@@ -1719,7 +1646,7 @@ 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 nBytesToWrite = sizeof(stServiceFlowParamSI);
UINT uiRetVal =0; UINT uiRetVal =0;
...@@ -1728,9 +1655,6 @@ static __inline ULONG StoreSFParam(PMINI_ADAPTER Adapter,PUCHAR pucSrcBuffer,ULO ...@@ -1728,9 +1655,6 @@ static __inline ULONG StoreSFParam(PMINI_ADAPTER Adapter,PUCHAR pucSrcBuffer,ULO
{ {
return 0; 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); uiRetVal = wrm(Adapter,ulAddrSFParamSet,(PUCHAR)pucSrcBuffer, nBytesToWrite);
if(uiRetVal < 0) { if(uiRetVal < 0) {
...@@ -1844,7 +1768,7 @@ ULONG StoreCmControlResponseMessage(PMINI_ADAPTER Adapter,PVOID pvBuffer,UINT *p ...@@ -1844,7 +1768,7 @@ ULONG StoreCmControlResponseMessage(PMINI_ADAPTER Adapter,PVOID pvBuffer,UINT *p
(*puBufferLength) = sizeof(stLocalSFAddIndication); (*puBufferLength) = sizeof(stLocalSFAddIndication);
*(stLocalSFAddIndication *)pvBuffer = *pstAddIndication; *(stLocalSFAddIndication *)pvBuffer = *pstAddIndication;
bcm_kfree(pstAddIndication); kfree(pstAddIndication);
return 1; return 1;
} }
...@@ -1931,7 +1855,7 @@ static inline stLocalSFAddIndicationAlt ...@@ -1931,7 +1855,7 @@ static inline stLocalSFAddIndicationAlt
BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "============================================================"); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "============================================================");
return pstAddIndicationDest; return pstAddIndicationDest;
failed_restore_sf_param: failed_restore_sf_param:
bcm_kfree(pstAddIndicationDest); kfree(pstAddIndicationDest);
BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "<=====" ); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "<=====" );
return NULL; return NULL;
} }
...@@ -1988,7 +1912,7 @@ ULONG SetUpTargetDsxBuffers(PMINI_ADAPTER Adapter) ...@@ -1988,7 +1912,7 @@ ULONG SetUpTargetDsxBuffers(PMINI_ADAPTER Adapter)
return 1; return 1;
} }
ULONG GetNextTargetBufferLocation(PMINI_ADAPTER Adapter,B_UINT16 tid) static ULONG GetNextTargetBufferLocation(PMINI_ADAPTER Adapter,B_UINT16 tid)
{ {
ULONG ulTargetDSXBufferAddress; ULONG ulTargetDSXBufferAddress;
ULONG ulTargetDsxBufferIndexToUse,ulMaxTry; ULONG ulTargetDsxBufferIndexToUse,ulMaxTry;
...@@ -2049,7 +1973,7 @@ INT FreeAdapterDsxBuffer(PMINI_ADAPTER Adapter) ...@@ -2049,7 +1973,7 @@ INT FreeAdapterDsxBuffer(PMINI_ADAPTER Adapter)
{ {
if(Adapter->caDsxReqResp) if(Adapter->caDsxReqResp)
{ {
bcm_kfree(Adapter->caDsxReqResp); kfree(Adapter->caDsxReqResp);
} }
return 0; return 0;
...@@ -2102,7 +2026,7 @@ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /**<Pointer to the Adap ...@@ -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)); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " VCID = %x", ntohs(pstAddIndication->u16VCID));
CopyBufferToControlPacket(Adapter,(PVOID)Adapter->caDsxReqResp); CopyBufferToControlPacket(Adapter,(PVOID)Adapter->caDsxReqResp);
bcm_kfree(pstAddIndication); kfree(pstAddIndication);
} }
break; break;
case DSA_RSP: case DSA_RSP:
...@@ -2118,7 +2042,7 @@ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /**<Pointer to the Adap ...@@ -2118,7 +2042,7 @@ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /**<Pointer to the Adap
case DSA_ACK: case DSA_ACK:
{ {
UINT uiSearchRuleIndex=0; UINT uiSearchRuleIndex=0;
struct timeval tv = {0};
BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "VCID:0x%X", BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "VCID:0x%X",
ntohs(pstAddIndication->u16VCID)); ntohs(pstAddIndication->u16VCID));
uiSearchRuleIndex=SearchFreeSfid(Adapter); uiSearchRuleIndex=SearchFreeSfid(Adapter);
...@@ -2169,7 +2093,7 @@ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /**<Pointer to the Adap ...@@ -2169,7 +2093,7 @@ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /**<Pointer to the Adap
Adapter->PackInfo[uiSearchRuleIndex].bActive=FALSE; Adapter->PackInfo[uiSearchRuleIndex].bActive=FALSE;
Adapter->PackInfo[uiSearchRuleIndex].bValid=FALSE; Adapter->PackInfo[uiSearchRuleIndex].bValid=FALSE;
Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value=0; Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value=0;
bcm_kfree(pstAddIndication); kfree(pstAddIndication);
} }
else if(psfLocalSet->bValid && (pstAddIndication->u8CC == 0)) else if(psfLocalSet->bValid && (pstAddIndication->u8CC == 0))
...@@ -2200,14 +2124,13 @@ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /**<Pointer to the Adap ...@@ -2200,14 +2124,13 @@ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /**<Pointer to the Adap
if(!Adapter->LinkUpStatus) if(!Adapter->LinkUpStatus)
{ {
netif_carrier_on(Adapter->dev); netif_carrier_on(Adapter->dev);
netif_start_queue(Adapter->dev); netif_start_queue(Adapter->dev);
Adapter->LinkUpStatus = 1; 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); atomic_set(&Adapter->TxPktAvail, 1);
wake_up(&Adapter->tx_packet_wait_queue); wake_up(&Adapter->tx_packet_wait_queue);
Adapter->liTimeSinceLastNetEntry = tv.tv_sec; Adapter->liTimeSinceLastNetEntry = get_seconds();
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "============Tx Service Flow Created!");
} }
} }
} }
...@@ -2218,13 +2141,13 @@ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /**<Pointer to the Adap ...@@ -2218,13 +2141,13 @@ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /**<Pointer to the Adap
Adapter->PackInfo[uiSearchRuleIndex].bActive=FALSE; Adapter->PackInfo[uiSearchRuleIndex].bActive=FALSE;
Adapter->PackInfo[uiSearchRuleIndex].bValid=FALSE; Adapter->PackInfo[uiSearchRuleIndex].bValid=FALSE;
Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value=0; Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value=0;
bcm_kfree(pstAddIndication); kfree(pstAddIndication);
} }
} }
else else
{ {
BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0, "DSA ACK did not get valid SFID"); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0, "DSA ACK did not get valid SFID");
bcm_kfree(pstAddIndication); kfree(pstAddIndication);
return FALSE; return FALSE;
} }
} }
...@@ -2239,7 +2162,7 @@ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /**<Pointer to the Adap ...@@ -2239,7 +2162,7 @@ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /**<Pointer to the Adap
((stLocalSFChangeIndicationAlt*)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSC_RSP; ((stLocalSFChangeIndicationAlt*)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSC_RSP;
CopyBufferToControlPacket(Adapter,(PVOID)Adapter->caDsxReqResp); CopyBufferToControlPacket(Adapter,(PVOID)Adapter->caDsxReqResp);
bcm_kfree(pstAddIndication); kfree(pstAddIndication);
} }
break; break;
case DSC_RSP: case DSC_RSP:
...@@ -2312,13 +2235,13 @@ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /**<Pointer to the Adap ...@@ -2312,13 +2235,13 @@ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /**<Pointer to the Adap
else if(pstChangeIndication->u8CC == 6) else if(pstChangeIndication->u8CC == 6)
{ {
deleteSFBySfid(Adapter,uiSearchRuleIndex); deleteSFBySfid(Adapter,uiSearchRuleIndex);
bcm_kfree(pstAddIndication); kfree(pstAddIndication);
} }
} }
else else
{ {
BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0, "DSC ACK did not get valid SFID"); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0, "DSC ACK did not get valid SFID");
bcm_kfree(pstAddIndication); kfree(pstAddIndication);
return FALSE; return FALSE;
} }
} }
...@@ -2355,7 +2278,7 @@ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /**<Pointer to the Adap ...@@ -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"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "DSD ACK Rcd, let App handle it\n");
break; break;
default: default:
bcm_kfree(pstAddIndication); kfree(pstAddIndication);
return FALSE ; return FALSE ;
} }
return TRUE; return TRUE;
......
...@@ -150,8 +150,6 @@ typedef struct stLocalSFChangeIndicationAlt{ ...@@ -150,8 +150,6 @@ typedef struct stLocalSFChangeIndicationAlt{
ULONG StoreCmControlResponseMessage(PMINI_ADAPTER Adapter,PVOID pvBuffer,UINT *puBufferLength); ULONG StoreCmControlResponseMessage(PMINI_ADAPTER Adapter,PVOID pvBuffer,UINT *puBufferLength);
ULONG GetNextTargetBufferLocation(PMINI_ADAPTER Adapter,B_UINT16 tid);
INT AllocAdapterDsxBuffer(PMINI_ADAPTER Adapter); INT AllocAdapterDsxBuffer(PMINI_ADAPTER Adapter);
INT FreeAdapterDsxBuffer(PMINI_ADAPTER Adapter); INT FreeAdapterDsxBuffer(PMINI_ADAPTER Adapter);
...@@ -159,7 +157,6 @@ ULONG SetUpTargetDsxBuffers(PMINI_ADAPTER Adapter); ...@@ -159,7 +157,6 @@ ULONG SetUpTargetDsxBuffers(PMINI_ADAPTER Adapter);
BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter,PVOID pvBuffer); BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter,PVOID pvBuffer);
VOID deleteSFBySfid(PMINI_ADAPTER Adapter, UINT uiSearchRuleIndex);
#pragma pack (pop) #pragma pack (pop)
......
#include "headers.h" #include "headers.h"
#ifndef BCM_SHM_INTERFACE
#define DDR_DUMP_INTERNAL_DEVICE_MEMORY 0xBFC02B00 #define DDR_DUMP_INTERNAL_DEVICE_MEMORY 0xBFC02B00
...@@ -188,17 +187,6 @@ static DDR_SET_NODE asDPLL_266MHZ[] = { ...@@ -188,17 +187,6 @@ static DDR_SET_NODE asDPLL_266MHZ[] = {
{0x0f000840,0x0FFF1B00}, {0x0f000840,0x0FFF1B00},
{0x0f000870,0x00000002} {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 #define T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 11 //index for 0x0F007000
static DDR_SET_NODE asT3B_DDRSetting133MHz[] = {// # DPLL Clock Setting static DDR_SET_NODE asT3B_DDRSetting133MHz[] = {// # DPLL Clock Setting
...@@ -1298,5 +1286,4 @@ int download_ddr_settings(PMINI_ADAPTER Adapter) ...@@ -1298,5 +1286,4 @@ int download_ddr_settings(PMINI_ADAPTER Adapter)
return retval; return retval;
} }
#endif
#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;
}
...@@ -9,34 +9,6 @@ ...@@ -9,34 +9,6 @@
#include <linux/string.h> #include <linux/string.h>
#define NONE 0xFFFF #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 { ...@@ -242,44 +214,34 @@ typedef struct _S_BCM_DEBUG_STATE {
//--- Only for direct printk's; "hidden" to API. //--- Only for direct printk's; "hidden" to API.
#define DBG_TYPE_PRINTK 3 #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 { \ #define BCM_DEBUG_PRINT(Adapter, Type, SubType, dbg_level, string, args...) \
if ((DBG_TYPE_PRINTK == Type) && (PRINTKS_ON)) { \ do { \
bcm_print_buffer( dbg_level, __FUNCTION__, __FILE__, __LINE__, buffer, bufferlen, BCM_BASE_TYPE_HEX); \ if (DBG_TYPE_PRINTK == Type) \
} else if (!Adapter) \ pr_info("%s:" string, __func__, ##args); \
; \ else if (Adapter && \
else { \ (dbg_level & DBG_LVL_BITMASK) <= Adapter->stDebugState.debug_level && \
if (((dbg_level & DBG_LVL_BITMASK) <= Adapter->stDebugState.debug_level) && \ (Type & Adapter->stDebugState.type) && \
((Type & Adapter->stDebugState.type) && (SubType & Adapter->stDebugState.subtype[Type]))) { \ (SubType & Adapter->stDebugState.subtype[Type])) { \
if (dbg_level & DBG_NO_FUNC_PRINT) \ if (dbg_level & DBG_NO_FUNC_PRINT) \
bcm_print_buffer( dbg_level, NULL, NULL, __LINE__, buffer, bufferlen, BCM_BASE_TYPE_HEX); \ printk(KERN_DEBUG string, ##args); \
else \ else \
bcm_print_buffer( dbg_level, __FUNCTION__, __FILE__, __LINE__, buffer, bufferlen, BCM_BASE_TYPE_HEX); \ printk(KERN_DEBUG "%s:" string, __func__, ##args); \
} \ } \
} \
} while (0) } 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 { \ #define BCM_SHOW_DEBUG_BITMAP(Adapter) do { \
int i; \ int i; \
......
...@@ -11,8 +11,7 @@ When a control packet is received, analyze the ...@@ -11,8 +11,7 @@ When a control packet is received, analyze the
Enqueue the control packet for Application. Enqueue the control packet for Application.
@return None @return None
*/ */
VOID handle_rx_control_packet(PMINI_ADAPTER Adapter, /**<Pointer to the Adapter structure*/ static VOID handle_rx_control_packet(PMINI_ADAPTER Adapter, struct sk_buff *skb)
struct sk_buff *skb) /**<Pointer to the socket buffer*/
{ {
PPER_TARANG_DATA pTarang = NULL; PPER_TARANG_DATA pTarang = NULL;
BOOLEAN HighPriorityMessage = FALSE; BOOLEAN HighPriorityMessage = FALSE;
...@@ -20,8 +19,10 @@ VOID handle_rx_control_packet(PMINI_ADAPTER Adapter, /**<Pointer to the Adapter ...@@ -20,8 +19,10 @@ VOID handle_rx_control_packet(PMINI_ADAPTER Adapter, /**<Pointer to the Adapter
CHAR cntrl_msg_mask_bit = 0; CHAR cntrl_msg_mask_bit = 0;
BOOLEAN drop_pkt_flag = TRUE ; BOOLEAN drop_pkt_flag = TRUE ;
USHORT usStatus = *(PUSHORT)(skb->data); 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) switch(usStatus)
{ {
...@@ -134,7 +135,7 @@ VOID handle_rx_control_packet(PMINI_ADAPTER Adapter, /**<Pointer to the Adapter ...@@ -134,7 +135,7 @@ VOID handle_rx_control_packet(PMINI_ADAPTER Adapter, /**<Pointer to the Adapter
} }
up(&Adapter->RxAppControlQueuelock); up(&Adapter->RxAppControlQueuelock);
wake_up(&Adapter->process_read_wait_queue); 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"); 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 ...@@ -185,33 +186,7 @@ int control_packet_handler (PMINI_ADAPTER Adapter /**< pointer to adapter obje
{ {
DEQUEUEPACKET(Adapter->RxControlHead,Adapter->RxControlTail); DEQUEUEPACKET(Adapter->RxControlHead,Adapter->RxControlTail);
// Adapter->RxControlHead=ctrl_packet->next; // 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); spin_unlock_irqrestore (&Adapter->control_queue_lock, flags);
handle_rx_control_packet(Adapter, ctrl_packet); handle_rx_control_packet(Adapter, ctrl_packet);
...@@ -234,7 +209,7 @@ INT flushAllAppQ(void) ...@@ -234,7 +209,7 @@ INT flushAllAppQ(void)
{ {
PacketToDrop=pTarang->RxAppControlHead; PacketToDrop=pTarang->RxAppControlHead;
DEQUEUEPACKET(pTarang->RxAppControlHead,pTarang->RxAppControlTail); DEQUEUEPACKET(pTarang->RxAppControlHead,pTarang->RxAppControlTail);
bcm_kfree_skb(PacketToDrop); dev_kfree_skb(PacketToDrop);
} }
pTarang->AppCtrlQueueLen = 0; pTarang->AppCtrlQueueLen = 0;
//dropped contrl packet statistics also should be reset. //dropped contrl packet statistics also should be reset.
......
#ifndef _HOST_MIBS_H
#define _HOST_MIBS_H
INT ProcessGetHostMibs(PMINI_ADAPTER Adapter,
PVOID ioBuffer,
ULONG inputBufferLength);
#endif
#include "headers.h" #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) static UCHAR * GetNextIPV6ChainedHeader(UCHAR **ppucPayload,UCHAR *pucNextHeader,BOOLEAN *bParseDone,USHORT *pusPayloadLength)
{ {
UCHAR *pucRetHeaderPtr = NULL; UCHAR *pucRetHeaderPtr = NULL;
...@@ -257,7 +261,7 @@ USHORT IpVersion6(PMINI_ADAPTER Adapter, /**< Pointer to the driver control stru ...@@ -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 uiLoopIndex=0;
UINT uiIpv6AddIndex=0; UINT uiIpv6AddIndex=0;
...@@ -310,7 +314,7 @@ BOOLEAN MatchSrcIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,IPV6Header *pst ...@@ -310,7 +314,7 @@ BOOLEAN MatchSrcIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,IPV6Header *pst
return FALSE; return FALSE;
} }
BOOLEAN MatchDestIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,IPV6Header *pstIpv6Header) static BOOLEAN MatchDestIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,IPV6Header *pstIpv6Header)
{ {
UINT uiLoopIndex=0; UINT uiLoopIndex=0;
UINT uiIpv6AddIndex=0; UINT uiIpv6AddIndex=0;
...@@ -376,7 +380,7 @@ VOID DumpIpv6Address(ULONG *puIpv6Address) ...@@ -376,7 +380,7 @@ VOID DumpIpv6Address(ULONG *puIpv6Address)
} }
VOID DumpIpv6Header(IPV6Header *pstIpv6Header) static VOID DumpIpv6Header(IPV6Header *pstIpv6Header)
{ {
UCHAR ucVersion; UCHAR ucVersion;
UCHAR ucPrio ; UCHAR ucPrio ;
......
...@@ -101,15 +101,12 @@ typedef enum _E_IPADDR_CONTEXT ...@@ -101,15 +101,12 @@ typedef enum _E_IPADDR_CONTEXT
//Function Prototypes //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 */ USHORT IpVersion6(PMINI_ADAPTER Adapter, /**< Pointer to the driver control structure */
PVOID pcIpHeader, /**<Pointer to the IP Hdr of the packet*/ PVOID pcIpHeader, /**<Pointer to the IP Hdr of the packet*/
S_CLASSIFIER_RULE *pstClassifierRule ); S_CLASSIFIER_RULE *pstClassifierRule );
VOID DumpIpv6Address(ULONG *puIpv6Address); VOID DumpIpv6Address(ULONG *puIpv6Address);
VOID DumpIpv6Header(IPV6Header *pstIpv6Header);
extern BOOLEAN MatchSrcPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort); extern BOOLEAN MatchSrcPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort);
extern BOOLEAN MatchDestPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort); extern BOOLEAN MatchDestPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort);
......
#include "headers.h" #include "headers.h"
#ifndef BCM_SHM_INTERFACE
int InterfaceFileDownload( PVOID arg, int InterfaceFileDownload( PVOID arg,
struct file *flp, struct file *flp,
...@@ -49,7 +48,7 @@ int InterfaceFileDownload( PVOID arg, ...@@ -49,7 +48,7 @@ int InterfaceFileDownload( PVOID arg,
on_chip_loc+=MAX_TRANSFER_CTRL_BYTE_USB; on_chip_loc+=MAX_TRANSFER_CTRL_BYTE_USB;
}/* End of for(;;)*/ }/* End of for(;;)*/
bcm_kfree(buff); kfree(buff);
return errno; return errno;
} }
...@@ -70,8 +69,8 @@ int InterfaceFileReadbackFromChip( PVOID arg, ...@@ -70,8 +69,8 @@ int InterfaceFileReadbackFromChip( PVOID arg,
buff_readback=(PCHAR)kmalloc(MAX_TRANSFER_CTRL_BYTE_USB , GFP_DMA); buff_readback=(PCHAR)kmalloc(MAX_TRANSFER_CTRL_BYTE_USB , GFP_DMA);
if(!buff || !buff_readback) if(!buff || !buff_readback)
{ {
bcm_kfree(buff); kfree(buff);
bcm_kfree(buff_readback); kfree(buff_readback);
return -ENOMEM; return -ENOMEM;
} }
...@@ -138,8 +137,8 @@ int InterfaceFileReadbackFromChip( PVOID arg, ...@@ -138,8 +137,8 @@ int InterfaceFileReadbackFromChip( PVOID arg,
on_chip_loc+=MAX_TRANSFER_CTRL_BYTE_USB; on_chip_loc+=MAX_TRANSFER_CTRL_BYTE_USB;
}/* End of while(1)*/ }/* End of while(1)*/
exit: exit:
bcm_kfree(buff); kfree(buff);
bcm_kfree(buff_readback); kfree(buff_readback);
return Status; return Status;
} }
...@@ -165,7 +164,7 @@ static int bcm_download_config_file(PMINI_ADAPTER Adapter, ...@@ -165,7 +164,7 @@ static int bcm_download_config_file(PMINI_ADAPTER Adapter,
psFwInfo->pvMappedFirmwareAddress, psFwInfo->u32FirmwareLength); psFwInfo->pvMappedFirmwareAddress, psFwInfo->u32FirmwareLength);
if(retval) if(retval)
{ {
bcm_kfree (Adapter->pstargetparams); kfree(Adapter->pstargetparams);
Adapter->pstargetparams = NULL; Adapter->pstargetparams = NULL;
return -EFAULT; return -EFAULT;
} }
...@@ -231,41 +230,6 @@ static int bcm_download_config_file(PMINI_ADAPTER Adapter, ...@@ -231,41 +230,6 @@ static int bcm_download_config_file(PMINI_ADAPTER Adapter,
return retval; 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, static int bcm_compare_buff_contents(unsigned char *readbackbuff,
unsigned char *buff,unsigned int len) unsigned char *buff,unsigned int len)
{ {
...@@ -297,58 +261,6 @@ static int bcm_compare_buff_contents(unsigned char *readbackbuff, ...@@ -297,58 +261,6 @@ static int bcm_compare_buff_contents(unsigned char *readbackbuff,
} }
return retval; 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 bcm_ioctl_fw_download(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwInfo)
{ {
int retval = STATUS_SUCCESS; int retval = STATUS_SUCCESS;
...@@ -389,23 +301,6 @@ int bcm_ioctl_fw_download(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwInfo) ...@@ -389,23 +301,6 @@ int bcm_ioctl_fw_download(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwInfo)
goto error ; 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, retval = buffDnldVerify(Adapter,
buff, buff,
psFwInfo->u32FirmwareLength, psFwInfo->u32FirmwareLength,
...@@ -417,7 +312,7 @@ int bcm_ioctl_fw_download(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwInfo) ...@@ -417,7 +312,7 @@ int bcm_ioctl_fw_download(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwInfo)
} }
} }
error: error:
bcm_kfree(buff); kfree(buff);
return retval; return retval;
} }
...@@ -480,7 +375,7 @@ static INT buffRdbkVerify(PMINI_ADAPTER Adapter, ...@@ -480,7 +375,7 @@ static INT buffRdbkVerify(PMINI_ADAPTER Adapter,
u32FirmwareLength -= len; u32FirmwareLength -= len;
mappedbuffer +=len; mappedbuffer +=len;
}/* end of while (u32FirmwareLength && !retval) */ }/* end of while (u32FirmwareLength && !retval) */
bcm_kfree(readbackbuff); kfree(readbackbuff);
return retval; return retval;
} }
...@@ -506,5 +401,4 @@ INT buffDnldVerify(PMINI_ADAPTER Adapter, unsigned char *mappedbuffer, unsigned ...@@ -506,5 +401,4 @@ INT buffDnldVerify(PMINI_ADAPTER Adapter, unsigned char *mappedbuffer, unsigned
return status; return status;
} }
#endif
...@@ -98,14 +98,6 @@ int InterfaceIdleModeRespond(PMINI_ADAPTER Adapter, unsigned int* puiBuffer) ...@@ -98,14 +98,6 @@ int InterfaceIdleModeRespond(PMINI_ADAPTER Adapter, unsigned int* puiBuffer)
Adapter->bTriedToWakeUpFromlowPowerMode = FALSE; Adapter->bTriedToWakeUpFromlowPowerMode = FALSE;
wake_up(&Adapter->lowpower_mode_wait_queue); 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 else
...@@ -154,17 +146,7 @@ int InterfaceIdleModeRespond(PMINI_ADAPTER Adapter, unsigned int* puiBuffer) ...@@ -154,17 +146,7 @@ int InterfaceIdleModeRespond(PMINI_ADAPTER Adapter, unsigned int* puiBuffer)
return status; return status;
} }
static int InterfaceAbortIdlemode(PMINI_ADAPTER Adapter, unsigned int Pattern)
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)
{ {
int status = STATUS_SUCCESS; int status = STATUS_SUCCESS;
unsigned int value; unsigned int value;
......
...@@ -7,8 +7,6 @@ INT InterfaceIdleModeRespond(PMINI_ADAPTER Adapter, unsigned int *puiBuffer); ...@@ -7,8 +7,6 @@ INT InterfaceIdleModeRespond(PMINI_ADAPTER Adapter, unsigned int *puiBuffer);
VOID InterfaceWriteIdleModeWakePattern(PMINI_ADAPTER Adapter); VOID InterfaceWriteIdleModeWakePattern(PMINI_ADAPTER Adapter);
INT InterfaceAbortIdlemode(PMINI_ADAPTER Adapter, unsigned int Pattern);
INT InterfaceWakeUp(PMINI_ADAPTER Adapter); INT InterfaceWakeUp(PMINI_ADAPTER Adapter);
VOID InterfaceHandleShutdownModeWakeup(PMINI_ADAPTER Adapter); VOID InterfaceHandleShutdownModeWakeup(PMINI_ADAPTER Adapter);
......
...@@ -2,14 +2,27 @@ ...@@ -2,14 +2,27 @@
static struct usb_device_id InterfaceUsbtable[] = { 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_T3B) },
{ USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3L) }, { 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_ZTE, BCM_USB_PRODUCT_ID_226) },
{ USB_DEVICE(BCM_USB_VENDOR_ID_FOXCONN, BCM_USB_PRODUCT_ID_1901) }, { USB_DEVICE(BCM_USB_VENDOR_ID_FOXCONN, BCM_USB_PRODUCT_ID_1901) },
{}
{ }
}; };
MODULE_DEVICE_TABLE(usb, InterfaceUsbtable);
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);
VOID InterfaceAdapterFree(PS_INTERFACE_ADAPTER psIntfAdapter) static VOID InterfaceAdapterFree(PS_INTERFACE_ADAPTER psIntfAdapter)
{ {
INT i = 0; INT i = 0;
// Wake up the wait_queue... // Wake up the wait_queue...
...@@ -48,7 +61,7 @@ VOID InterfaceAdapterFree(PS_INTERFACE_ADAPTER psIntfAdapter) ...@@ -48,7 +61,7 @@ VOID InterfaceAdapterFree(PS_INTERFACE_ADAPTER psIntfAdapter)
{ {
if (psIntfAdapter->asUsbRcb[i].urb != NULL) if (psIntfAdapter->asUsbRcb[i].urb != NULL)
{ {
bcm_kfree(psIntfAdapter->asUsbRcb[i].urb->transfer_buffer); kfree(psIntfAdapter->asUsbRcb[i].urb->transfer_buffer);
usb_free_urb(psIntfAdapter->asUsbRcb[i].urb); usb_free_urb(psIntfAdapter->asUsbRcb[i].urb);
psIntfAdapter->asUsbRcb[i].urb = NULL; psIntfAdapter->asUsbRcb[i].urb = NULL;
} }
...@@ -56,30 +69,7 @@ VOID InterfaceAdapterFree(PS_INTERFACE_ADAPTER psIntfAdapter) ...@@ -56,30 +69,7 @@ VOID InterfaceAdapterFree(PS_INTERFACE_ADAPTER psIntfAdapter)
AdapterFree(psIntfAdapter->psAdapter); AdapterFree(psIntfAdapter->psAdapter);
} }
static VOID ConfigureEndPointTypesThroughEEPROM(PMINI_ADAPTER Adapter)
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)
{
return 0;
}
VOID ConfigureEndPointTypesThroughEEPROM(PMINI_ADAPTER Adapter)
{ {
ULONG ulReg = 0; ULONG ulReg = 0;
...@@ -157,48 +147,32 @@ VOID ConfigureEndPointTypesThroughEEPROM(PMINI_ADAPTER Adapter) ...@@ -157,48 +147,32 @@ VOID ConfigureEndPointTypesThroughEEPROM(PMINI_ADAPTER Adapter)
} }
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 static int
usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id) usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id)
{ {
int retval =0 ; struct usb_device *udev = interface_to_usbdev (intf);
PMINI_ADAPTER psAdapter = NULL; int retval;
PS_INTERFACE_ADAPTER psIntfAdapter = NULL; PMINI_ADAPTER psAdapter;
struct usb_device *udev = NULL; PS_INTERFACE_ADAPTER psIntfAdapter;
struct net_device *ndev;
// BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Usbbcm probe!!"); /* Reserve one extra queue for the bit-bucket */
if((intf == NULL) || (id == NULL)) ndev = alloc_etherdev_mq(sizeof(MINI_ADAPTER), NO_OF_QUEUES+1);
{ if(ndev == NULL) {
// BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "intf or id is NULL"); dev_err(&udev->dev, DRV_NAME ": no memory for device\n");
return -EINVAL;
}
/* Allocate Adapter structure */
if((psAdapter = kzalloc(sizeof(MINI_ADAPTER), GFP_KERNEL)) == NULL)
{
BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0, "Out of memory");
return -ENOMEM; return -ENOMEM;
} }
SET_NETDEV_DEV(ndev, &intf->dev);
psAdapter = netdev_priv(ndev);
psAdapter->dev = ndev;
psAdapter->msg_enable = netif_msg_init(debug, default_msg);
/* Init default driver debug state */ /* Init default driver debug state */
psAdapter->stDebugState.debug_level = DBG_LVL_CURR; psAdapter->stDebugState.debug_level = DBG_LVL_CURR;
psAdapter->stDebugState.type = DBG_TYPE_INITEXIT; 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; * However, realize that by default the Type/Subtype bitmaps are all zero now;
...@@ -217,22 +191,21 @@ usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id) ...@@ -217,22 +191,21 @@ usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id)
retval = InitAdapter(psAdapter); retval = InitAdapter(psAdapter);
if(retval) if(retval)
{ {
BCM_DEBUG_PRINT (psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "InitAdapter Failed\n"); dev_err(&udev->dev, DRV_NAME ": InitAdapter Failed\n");
AdapterFree(psAdapter); AdapterFree(psAdapter);
return retval; return retval;
} }
/* Allocate interface adapter structure */ /* Allocate interface adapter structure */
if((psAdapter->pvInterfaceAdapter = psIntfAdapter = kzalloc(sizeof(S_INTERFACE_ADAPTER), GFP_KERNEL);
kmalloc(sizeof(S_INTERFACE_ADAPTER), GFP_KERNEL)) == NULL) if (psIntfAdapter == NULL)
{ {
BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0, "Out of memory"); dev_err(&udev->dev, DRV_NAME ": no memory for Interface adapter\n");
AdapterFree (psAdapter); AdapterFree (psAdapter);
return -ENOMEM; return -ENOMEM;
} }
memset(psAdapter->pvInterfaceAdapter, 0, sizeof(S_INTERFACE_ADAPTER));
psIntfAdapter = InterfaceAdapterGet(psAdapter); psAdapter->pvInterfaceAdapter = psIntfAdapter;
psIntfAdapter->psAdapter = psAdapter; psIntfAdapter->psAdapter = psAdapter;
/* Store usb interface in Interface Adapter */ /* Store usb interface in Interface Adapter */
...@@ -255,8 +228,6 @@ usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id) ...@@ -255,8 +228,6 @@ usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id)
usb_set_intfdata(intf, NULL); usb_set_intfdata(intf, NULL);
udev = interface_to_usbdev (intf); udev = interface_to_usbdev (intf);
usb_put_dev(udev); usb_put_dev(udev);
if(psAdapter->bUsbClassDriverRegistered == TRUE)
usb_deregister_dev (intf, &usbbcm_class);
InterfaceAdapterFree(psIntfAdapter); InterfaceAdapterFree(psIntfAdapter);
return retval ; return retval ;
} }
...@@ -269,7 +240,6 @@ usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id) ...@@ -269,7 +240,6 @@ usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id)
} }
} }
udev = interface_to_usbdev (intf);
/* Check whether the USB-Device Supports remote Wake-Up */ /* 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)
{ {
...@@ -309,38 +279,26 @@ usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id) ...@@ -309,38 +279,26 @@ usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id)
static void usbbcm_disconnect (struct usb_interface *intf) static void usbbcm_disconnect (struct usb_interface *intf)
{ {
PS_INTERFACE_ADAPTER psIntfAdapter = NULL; PS_INTERFACE_ADAPTER psIntfAdapter = usb_get_intfdata(intf);
PMINI_ADAPTER psAdapter = NULL; PMINI_ADAPTER psAdapter;
struct usb_device *udev = NULL; struct usb_device *udev = interface_to_usbdev (intf);
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) if(psIntfAdapter == NULL)
{
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "InterfaceAdapter pointer is NULL");
return; return;
}
psAdapter = psIntfAdapter->psAdapter; psAdapter = psIntfAdapter->psAdapter;
netif_device_detach(psAdapter->dev);
if(psAdapter->bDoSuspend) if(psAdapter->bDoSuspend)
intf->needs_remote_wakeup = 0; intf->needs_remote_wakeup = 0;
psAdapter->device_removed = TRUE ; psAdapter->device_removed = TRUE ;
usb_set_intfdata(intf, NULL); usb_set_intfdata(intf, NULL);
InterfaceAdapterFree(psIntfAdapter); InterfaceAdapterFree(psIntfAdapter);
udev = interface_to_usbdev (intf);
usb_put_dev(udev); usb_put_dev(udev);
usb_deregister_dev (intf, &usbbcm_class);
} }
static int AllocUsbCb(PS_INTERFACE_ADAPTER psIntfAdapter)
static __inline int AllocUsbCb(PS_INTERFACE_ADAPTER psIntfAdapter)
{ {
int i = 0; int i = 0;
for(i = 0; i < MAXIMUM_USB_TCB; i++) for(i = 0; i < MAXIMUM_USB_TCB; i++)
...@@ -382,13 +340,11 @@ static int device_run(PS_INTERFACE_ADAPTER psIntfAdapter) ...@@ -382,13 +340,11 @@ static int device_run(PS_INTERFACE_ADAPTER psIntfAdapter)
status = InitCardAndDownloadFirmware(psIntfAdapter->psAdapter); status = InitCardAndDownloadFirmware(psIntfAdapter->psAdapter);
if(status != STATUS_SUCCESS) if(status != STATUS_SUCCESS)
{ {
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "InitCardAndDownloadFirmware failed.\n"); pr_err(DRV_NAME "InitCardAndDownloadFirmware failed.\n");
return status; return status;
} }
if(TRUE == psIntfAdapter->psAdapter->fw_download_done) 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)) if(StartInterruptUrb(psIntfAdapter))
{ {
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Cannot send interrupt in URB"); BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Cannot send interrupt in URB");
...@@ -401,48 +357,17 @@ static int device_run(PS_INTERFACE_ADAPTER psIntfAdapter) ...@@ -401,48 +357,17 @@ static int device_run(PS_INTERFACE_ADAPTER psIntfAdapter)
psIntfAdapter->psAdapter->waiting_to_fw_download_done, 5*HZ); psIntfAdapter->psAdapter->waiting_to_fw_download_done, 5*HZ);
if(value == 0) if(value == 0)
{ pr_err(DRV_NAME ": Mailbox Interrupt has not reached to Driver..\n");
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) if(register_control_device_interface(psIntfAdapter->psAdapter) < 0)
{ {
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Register Control Device failed..."); pr_err(DRV_NAME ": Register Control Device failed...\n");
return -EIO; return -EIO;
} }
} }
return 0; 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) static inline int bcm_usb_endpoint_num(const struct usb_endpoint_descriptor *epd)
{ {
...@@ -518,7 +443,7 @@ static inline int bcm_usb_endpoint_is_isoc_out(const struct usb_endpoint_descrip ...@@ -518,7 +443,7 @@ 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)); 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_host_interface *iface_desc;
struct usb_endpoint_descriptor *endpoint; struct usb_endpoint_descriptor *endpoint;
...@@ -530,20 +455,9 @@ INT InterfaceAdapterInit(PS_INTERFACE_ADAPTER psIntfAdapter) ...@@ -530,20 +455,9 @@ INT InterfaceAdapterInit(PS_INTERFACE_ADAPTER psIntfAdapter)
UINT uiData = 0; UINT uiData = 0;
/* Store the usb dev into interface adapter */ /* Store the usb dev into interface adapter */
psIntfAdapter->udev = usb_get_dev(interface_to_usbdev( psIntfAdapter->udev = usb_get_dev(interface_to_usbdev(psIntfAdapter->interface));
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->bHighSpeedDevice = (psIntfAdapter->udev->speed == USB_SPEED_HIGH);
psIntfAdapter->psAdapter->interface_rdm = BcmRDM; psIntfAdapter->psAdapter->interface_rdm = BcmRDM;
psIntfAdapter->psAdapter->interface_wrm = BcmWRM; psIntfAdapter->psAdapter->interface_wrm = BcmWRM;
...@@ -552,28 +466,27 @@ INT InterfaceAdapterInit(PS_INTERFACE_ADAPTER psIntfAdapter) ...@@ -552,28 +466,27 @@ INT InterfaceAdapterInit(PS_INTERFACE_ADAPTER psIntfAdapter)
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "CHIP ID Read Failed\n"); BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "CHIP ID Read Failed\n");
return STATUS_FAILURE; return STATUS_FAILURE;
} }
if(0xbece3200==(psIntfAdapter->psAdapter->chip_id&~(0xF0)))
{
psIntfAdapter->psAdapter->chip_id=(psIntfAdapter->psAdapter->chip_id&~(0xF0));
}
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; dev_info(&psIntfAdapter->udev->dev, "RDM Chip ID 0x%lx\n",
//print_usb_interface_desc(&(iface_desc->desc)); psIntfAdapter->psAdapter->chip_id);
iface_desc = psIntfAdapter->interface->cur_altsetting;
if(psIntfAdapter->psAdapter->chip_id == T3B) if(psIntfAdapter->psAdapter->chip_id == T3B)
{ {
// //
//T3B device will have EEPROM,check if EEPROM is proper and BCM16 can be done or not. //T3B device will have EEPROM,check if EEPROM is proper and BCM16 can be done or not.
// //
BeceemEEPROMBulkRead(psIntfAdapter->psAdapter,&uiData,0x0,4); BeceemEEPROMBulkRead(psIntfAdapter->psAdapter,&uiData,0x0,4);
if(uiData == BECM) if(uiData == BECM)
{
bBcm16 = TRUE; 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); dev_info(&psIntfAdapter->udev->dev, "number of alternate setting %d\n",
psIntfAdapter->interface->num_altsetting);
if(bBcm16 == TRUE) if(bBcm16 == TRUE)
{ {
//selecting alternate setting one as a default setting for High Speed modem. //selecting alternate setting one as a default setting for High Speed modem.
...@@ -644,12 +557,10 @@ INT InterfaceAdapterInit(PS_INTERFACE_ADAPTER psIntfAdapter) ...@@ -644,12 +557,10 @@ INT InterfaceAdapterInit(PS_INTERFACE_ADAPTER psIntfAdapter)
} }
iface_desc = psIntfAdapter->interface->cur_altsetting; 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)
for (value = 0; value < iface_desc->desc.bNumEndpoints; ++value)
{ {
endpoint = &iface_desc->endpoint[value].desc; endpoint = &iface_desc->endpoint[value].desc;
//print_usb_endpoint_descriptor(endpoint);
if (!psIntfAdapter->sBulkIn.bulk_in_endpointAddr && bcm_usb_endpoint_is_bulk_in(endpoint)) if (!psIntfAdapter->sBulkIn.bulk_in_endpointAddr && bcm_usb_endpoint_is_bulk_in(endpoint))
{ {
...@@ -682,10 +593,10 @@ INT InterfaceAdapterInit(PS_INTERFACE_ADAPTER psIntfAdapter) ...@@ -682,10 +593,10 @@ INT InterfaceAdapterInit(PS_INTERFACE_ADAPTER psIntfAdapter)
psIntfAdapter->sIntrIn.int_in_buffer = psIntfAdapter->sIntrIn.int_in_buffer =
kmalloc(buffer_size, GFP_KERNEL); kmalloc(buffer_size, GFP_KERNEL);
if (!psIntfAdapter->sIntrIn.int_in_buffer) { 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"); dev_err(&psIntfAdapter->udev->dev,
"could not allocate interrupt_in_buffer\n");
return -EINVAL; return -EINVAL;
} }
//psIntfAdapter->sIntrIn.int_in_pipe =
} }
if (!psIntfAdapter->sIntrOut.int_out_endpointAddr && bcm_usb_endpoint_is_int_out(endpoint)) if (!psIntfAdapter->sIntrOut.int_out_endpointAddr && bcm_usb_endpoint_is_int_out(endpoint))
...@@ -716,26 +627,15 @@ INT InterfaceAdapterInit(PS_INTERFACE_ADAPTER psIntfAdapter) ...@@ -716,26 +627,15 @@ INT InterfaceAdapterInit(PS_INTERFACE_ADAPTER psIntfAdapter)
psIntfAdapter->sIntrOut.int_out_buffer= kmalloc(buffer_size, psIntfAdapter->sIntrOut.int_out_buffer= kmalloc(buffer_size,
GFP_KERNEL); GFP_KERNEL);
if (!psIntfAdapter->sIntrOut.int_out_buffer) 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"); dev_err(&psIntfAdapter->udev->dev,
return -EINVAL; "could not allocate interrupt_out_buffer\n");
} return -EINVAL;
}
} }
} }
} }
usb_set_intfdata(psIntfAdapter->interface, psIntfAdapter); 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");
}
psIntfAdapter->psAdapter->bcm_file_download = InterfaceFileDownload; psIntfAdapter->psAdapter->bcm_file_download = InterfaceFileDownload;
psIntfAdapter->psAdapter->bcm_file_readback_from_chip = psIntfAdapter->psAdapter->bcm_file_readback_from_chip =
...@@ -757,21 +657,13 @@ INT InterfaceAdapterInit(PS_INTERFACE_ADAPTER psIntfAdapter) ...@@ -757,21 +657,13 @@ INT InterfaceAdapterInit(PS_INTERFACE_ADAPTER psIntfAdapter)
} }
retval = device_run(psIntfAdapter); return device_run(psIntfAdapter);
if(retval)
{
return retval;
}
return 0;
} }
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); 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; psIntfAdapter->bSuspended = TRUE;
if(TRUE == psIntfAdapter->bPreparingForBusSuspend) if(TRUE == psIntfAdapter->bPreparingForBusSuspend)
...@@ -812,57 +704,43 @@ static int InterfaceResume (struct usb_interface *intf) ...@@ -812,57 +704,43 @@ static int InterfaceResume (struct usb_interface *intf)
return 0; 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 = { static struct usb_driver usbbcm_driver = {
.name = "usbbcm", .name = "usbbcm",
.probe = usbbcm_device_probe, .probe = usbbcm_device_probe,
.disconnect = usbbcm_disconnect, .disconnect = usbbcm_disconnect,
.suspend = InterfaceSuspend, .suspend = InterfaceSuspend,
.resume = InterfaceResume, .resume = InterfaceResume,
.pre_reset=InterfacePreReset,
.post_reset=InterfacePostReset,
.id_table = InterfaceUsbtable, .id_table = InterfaceUsbtable,
.supports_autosuspend = 1, .supports_autosuspend = 1,
}; };
struct class *bcm_class;
/*
Function: InterfaceInitialize
Description: This is the hardware specific initialization Function. static __init int bcm_init(void)
Registering the driver with NDIS , other device specific NDIS {
and hardware initializations are done here. printk(KERN_INFO "%s: %s, %s\n", DRV_NAME, DRV_DESCRIPTION, DRV_VERSION);
printk(KERN_INFO "%s\n", DRV_COPYRIGHT);
Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context
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); return usb_register(&usbbcm_driver);
} }
INT InterfaceExit(void) static __exit void bcm_exit(void)
{ {
//PMINI_ADAPTER psAdapter = NULL; class_destroy (bcm_class);
int status = 0;
//BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Deregistering Usb driver!!");
usb_deregister(&usbbcm_driver); usb_deregister(&usbbcm_driver);
return status;
} }
module_init(bcm_init);
module_exit(bcm_exit);
MODULE_DESCRIPTION(DRV_DESCRIPTION);
MODULE_VERSION(DRV_VERSION);
MODULE_LICENSE ("GPL"); MODULE_LICENSE ("GPL");
...@@ -19,33 +19,7 @@ INT InterfaceInitialize(void); ...@@ -19,33 +19,7 @@ INT InterfaceInitialize(void);
INT InterfaceExit(void); INT InterfaceExit(void);
#ifndef BCM_SHM_INTERFACE
INT InterfaceAdapterInit(PS_INTERFACE_ADAPTER Adapter);
INT usbbcm_worker_thread(PS_INTERFACE_ADAPTER psIntfAdapter); 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 #endif
#include "headers.h" #include "headers.h"
#ifndef BCM_SHM_INTERFACE
static void read_int_callback(struct urb *urb/*, struct pt_regs *regs*/) 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*/) ...@@ -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; PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)urb->context;
PMINI_ADAPTER Adapter = psIntfAdapter->psAdapter ; 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) if(Adapter->device_removed == TRUE)
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Device has Got Removed."); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Device has Got Removed.");
...@@ -164,40 +167,3 @@ INT StartInterruptUrb(PS_INTERFACE_ADAPTER psIntfAdapter) ...@@ -164,40 +167,3 @@ INT StartInterruptUrb(PS_INTERFACE_ADAPTER psIntfAdapter)
return status; 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
#include "headers.h" #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 INT
InterfaceRDM(PS_INTERFACE_ADAPTER psIntfAdapter, InterfaceRDM(PS_INTERFACE_ADAPTER psIntfAdapter,
UINT addr, UINT addr,
...@@ -236,9 +224,7 @@ VOID Bcm_kill_all_URBs(PS_INTERFACE_ADAPTER psIntfAdapter) ...@@ -236,9 +224,7 @@ VOID Bcm_kill_all_URBs(PS_INTERFACE_ADAPTER psIntfAdapter)
} }
/* Cancel All submitted TX URB's */ /* 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; tempUrb = psIntfAdapter->asUsbTcb[i].urb;
if(tempUrb) if(tempUrb)
...@@ -248,9 +234,6 @@ VOID Bcm_kill_all_URBs(PS_INTERFACE_ADAPTER psIntfAdapter) ...@@ -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++) for(i = 0; i < MAXIMUM_USB_RCB; i++)
{ {
tempUrb = psIntfAdapter->asUsbRcb[i].urb; tempUrb = psIntfAdapter->asUsbRcb[i].urb;
...@@ -261,16 +244,11 @@ VOID Bcm_kill_all_URBs(PS_INTERFACE_ADAPTER psIntfAdapter) ...@@ -261,16 +244,11 @@ VOID Bcm_kill_all_URBs(PS_INTERFACE_ADAPTER psIntfAdapter)
} }
} }
atomic_set(&psIntfAdapter->uNumTcbUsed, 0); atomic_set(&psIntfAdapter->uNumTcbUsed, 0);
atomic_set(&psIntfAdapter->uCurrTcb, 0); atomic_set(&psIntfAdapter->uCurrTcb, 0);
atomic_set(&psIntfAdapter->uNumRcbUsed, 0); atomic_set(&psIntfAdapter->uNumRcbUsed, 0);
atomic_set(&psIntfAdapter->uCurrRcb, 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) VOID putUsbSuspend(struct work_struct *work)
...@@ -282,9 +260,6 @@ VOID putUsbSuspend(struct work_struct *work) ...@@ -282,9 +260,6 @@ VOID putUsbSuspend(struct work_struct *work)
if(psIntfAdapter->bSuspended == FALSE) if(psIntfAdapter->bSuspended == FALSE)
usb_autopm_put_interface(intf); usb_autopm_put_interface(intf);
else
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Interface Resumed Completely\n");
} }
#endif
#ifndef __INTERFACE_MISC_H #ifndef __INTERFACE_MISC_H
#define __INTERFACE_MISC_H #define __INTERFACE_MISC_H
PS_INTERFACE_ADAPTER
InterfaceAdapterGet(PMINI_ADAPTER psAdapter);
INT INT
InterfaceRDM(PS_INTERFACE_ADAPTER psIntfAdapter, InterfaceRDM(PS_INTERFACE_ADAPTER psIntfAdapter,
UINT addr, UINT addr,
......
#include "headers.h" #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 static PUSB_RCB
...@@ -38,13 +48,9 @@ static void read_bulk_callback(struct urb *urb) ...@@ -38,13 +48,9 @@ static void read_bulk_callback(struct urb *urb)
PMINI_ADAPTER Adapter = psIntfAdapter->psAdapter; PMINI_ADAPTER Adapter = psIntfAdapter->psAdapter;
PLEADER pLeader = urb->transfer_buffer; PLEADER pLeader = urb->transfer_buffer;
if (unlikely(netif_msg_rx_status(Adapter)))
#if 0 pr_info(PFX "%s: rx urb status %d length %d\n",
int *puiBuffer = NULL; Adapter->dev->name, urb->status, urb->actual_length);
struct timeval tv;
memset(&tv, 0, sizeof(tv));
do_gettimeofday(&tv);
#endif
if((Adapter->device_removed == TRUE) || if((Adapter->device_removed == TRUE) ||
(TRUE == Adapter->bEndPointHalted) || (TRUE == Adapter->bEndPointHalted) ||
...@@ -89,10 +95,10 @@ static void read_bulk_callback(struct urb *urb) ...@@ -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); 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) if(MAX_CNTL_PKT_SIZE < pLeader->PLength)
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Corrupted leader length...%d\n", if (netif_msg_rx_err(Adapter))
pLeader->PLength); pr_info(PFX "%s: corrupted leader length...%d\n",
atomic_inc(&Adapter->RxPacketDroppedCount); Adapter->dev->name, pLeader->PLength);
atomic_add(pLeader->PLength, &Adapter->BadRxByteCount); ++Adapter->dev->stats.rx_dropped;
atomic_dec(&psIntfAdapter->uNumRcbUsed); atomic_dec(&psIntfAdapter->uNumRcbUsed);
return; return;
} }
...@@ -145,10 +151,9 @@ static void read_bulk_callback(struct urb *urb) ...@@ -145,10 +151,9 @@ static void read_bulk_callback(struct urb *urb)
skb_put (skb, pLeader->PLength + ETH_HLEN); skb_put (skb, pLeader->PLength + ETH_HLEN);
Adapter->PackInfo[QueueIndex].uiTotalRxBytes+=pLeader->PLength; Adapter->PackInfo[QueueIndex].uiTotalRxBytes+=pLeader->PLength;
Adapter->PackInfo[QueueIndex].uiThisPeriodRxBytes+= 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); 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 */ /* Moving ahead by ETH_HLEN to the data ptr as received from FW */
skb_pull(skb, ETH_HLEN); skb_pull(skb, ETH_HLEN);
...@@ -173,9 +178,12 @@ static void read_bulk_callback(struct urb *urb) ...@@ -173,9 +178,12 @@ static void read_bulk_callback(struct urb *urb)
else else
{ {
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_RX, RX_DATA, DBG_LVL_ALL, "i/f not up hance freeing SKB..."); 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++) for(uiIndex = 0 ; uiIndex < MIBS_MAX_HIST_ENTRIES ; uiIndex++)
{ {
if((pLeader->PLength <= MIBS_PKTSIZEHIST_RANGE*(uiIndex+1)) if((pLeader->PLength <= MIBS_PKTSIZEHIST_RANGE*(uiIndex+1))
......
#include "headers.h" #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)*/ /*this is transmit call-back(BULK OUT)*/
static void write_bulk_callback(struct urb *urb/*, struct pt_regs *regs*/) 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*/) ...@@ -54,10 +9,10 @@ static void write_bulk_callback(struct urb *urb/*, struct pt_regs *regs*/)
PMINI_ADAPTER psAdapter = psIntfAdapter->psAdapter ; PMINI_ADAPTER psAdapter = psIntfAdapter->psAdapter ;
BOOLEAN bpowerDownMsg = FALSE ; BOOLEAN bpowerDownMsg = FALSE ;
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
#if 0
struct timeval tv; if (unlikely(netif_msg_tx_done(Adapter)))
UINT time_ms = 0; pr_info(PFX "%s: transmit status %d\n", Adapter->dev->name, urb->status);
#endif
if(urb->status != STATUS_SUCCESS) if(urb->status != STATUS_SUCCESS)
{ {
if(urb->status == -EPIPE) if(urb->status == -EPIPE)
...@@ -78,11 +33,6 @@ static void write_bulk_callback(struct urb *urb/*, struct pt_regs *regs*/) ...@@ -78,11 +33,6 @@ static void write_bulk_callback(struct urb *urb/*, struct pt_regs *regs*/)
if(TRUE == psAdapter->bPreparingForLowPowerMode) 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) && if(((pControlMsg->szData[0] == GO_TO_IDLE_MODE_PAYLOAD) &&
(pControlMsg->szData[1] == TARGET_CAN_GO_TO_IDLE_MODE))) (pControlMsg->szData[1] == TARGET_CAN_GO_TO_IDLE_MODE)))
...@@ -162,7 +112,7 @@ err_exit : ...@@ -162,7 +112,7 @@ err_exit :
} }
static __inline PUSB_TCB GetBulkOutTcb(PS_INTERFACE_ADAPTER psIntfAdapter) static PUSB_TCB GetBulkOutTcb(PS_INTERFACE_ADAPTER psIntfAdapter)
{ {
PUSB_TCB pTcb = NULL; PUSB_TCB pTcb = NULL;
UINT index = 0; UINT index = 0;
...@@ -183,7 +133,7 @@ static __inline PUSB_TCB GetBulkOutTcb(PS_INTERFACE_ADAPTER psIntfAdapter) ...@@ -183,7 +133,7 @@ static __inline PUSB_TCB GetBulkOutTcb(PS_INTERFACE_ADAPTER psIntfAdapter)
return pTcb; 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; struct urb *urb = pTcb->urb;
...@@ -255,5 +205,4 @@ int InterfaceTransmitPacket(PVOID arg, PVOID data, UINT len) ...@@ -255,5 +205,4 @@ int InterfaceTransmitPacket(PVOID arg, PVOID data, UINT len)
return TransmitTcb(psIntfAdapter, pTcb, data, len); return TransmitTcb(psIntfAdapter, pTcb, data, len);
} }
#endif
...@@ -3,11 +3,5 @@ ...@@ -3,11 +3,5 @@
INT InterfaceTransmitPacket(PVOID arg, PVOID data, UINT len); 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 #endif
#ifndef _MAIN_
#define _MAIN_
#if 0
typedef struct _MINI_ADAPTER
{
S_INTERFACE_ADAPTER stInterfaceAdapter;
}MINI_ADAPTER,*PMINI_ADAPTER;
#endif
#endif
...@@ -75,14 +75,14 @@ static VOID UpdateTokenCount(register PMINI_ADAPTER Adapter) ...@@ -75,14 +75,14 @@ static VOID UpdateTokenCount(register PMINI_ADAPTER Adapter)
* Returns - The number of bytes allowed for transmission. * 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 ===>"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IsPacketAllowedForFlow ===>");
/* Validate the parameters */ /* Validate the parameters */
if(NULL == Adapter || (psSF < Adapter->PackInfo && if(NULL == Adapter || (psSF < Adapter->PackInfo &&
(uintptr_t)psSF > (uintptr_t) &Adapter->PackInfo[HiPriority])) (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; return 0;
} }
...@@ -94,51 +94,27 @@ static __inline ULONG GetSFTokenCount(PMINI_ADAPTER Adapter, PacketInfo *psSF) ...@@ -94,51 +94,27 @@ static __inline ULONG GetSFTokenCount(PMINI_ADAPTER Adapter, PacketInfo *psSF)
} }
else 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-Adapter->PackInfo, psSF->uiCurrentTokenCount);
psSF->uiPendedLast = 1; psSF->uiPendedLast = 1;
} }
} }
else 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 <==="); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IsPacketAllowedForFlow <===");
return 0; 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 @ingroup tx_functions
This function despatches packet from the specified queue. This function despatches packet from the specified queue.
@return Zero(success) or Negative value(failure) @return Zero(success) or Negative value(failure)
*/ */
static __inline INT SendPacketFromQueue(PMINI_ADAPTER Adapter,/**<Logical Adapter*/ static INT SendPacketFromQueue(PMINI_ADAPTER Adapter,/**<Logical Adapter*/
PacketInfo *psSF, /**<Queue identifier*/ PacketInfo *psSF, /**<Queue identifier*/
struct sk_buff* Packet) /**<Pointer to the packet to be sent*/ struct sk_buff* Packet) /**<Pointer to the packet to be sent*/
{ {
INT Status=STATUS_FAILURE; INT Status=STATUS_FAILURE;
UINT uiIndex =0,PktLen = 0; UINT uiIndex =0,PktLen = 0;
...@@ -180,8 +156,7 @@ static __inline INT SendPacketFromQueue(PMINI_ADAPTER Adapter,/**<Logical Adapte ...@@ -180,8 +156,7 @@ static __inline INT SendPacketFromQueue(PMINI_ADAPTER Adapter,/**<Logical Adapte
* Returns - None. * Returns - None.
* *
****************************************************************************/ ****************************************************************************/
static __inline VOID CheckAndSendPacketFromIndex static VOID CheckAndSendPacketFromIndex(PMINI_ADAPTER Adapter, PacketInfo *psSF)
(PMINI_ADAPTER Adapter, PacketInfo *psSF)
{ {
struct sk_buff *QueuePacket=NULL; struct sk_buff *QueuePacket=NULL;
char *pControlPacket = NULL; char *pControlPacket = NULL;
...@@ -189,7 +164,7 @@ static __inline VOID CheckAndSendPacketFromIndex ...@@ -189,7 +164,7 @@ static __inline VOID CheckAndSendPacketFromIndex
int iPacketLen=0; 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 != &Adapter->PackInfo[HiPriority]) && Adapter->LinkUpStatus && atomic_read(&psSF->uiPerSFTxResourceCount))//Get data packet
{ {
if(!psSF->ucDirection ) if(!psSF->ucDirection )
...@@ -197,10 +172,8 @@ static __inline VOID CheckAndSendPacketFromIndex ...@@ -197,10 +172,8 @@ static __inline VOID CheckAndSendPacketFromIndex
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "UpdateTokenCount "); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "UpdateTokenCount ");
if(Adapter->IdleMode || Adapter->bPreparingForLowPowerMode) if(Adapter->IdleMode || Adapter->bPreparingForLowPowerMode)
{ return; /* in idle mode */
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Device is in Idle Mode..Hence blocking Data Packets..\n");
return;
}
// Check for Free Descriptors // Check for Free Descriptors
if(atomic_read(&Adapter->CurrNumFreeTxDesc) <= MINIMUM_PENDING_DESCRIPTORS) if(atomic_read(&Adapter->CurrNumFreeTxDesc) <= MINIMUM_PENDING_DESCRIPTORS)
{ {
...@@ -208,9 +181,6 @@ static __inline VOID CheckAndSendPacketFromIndex ...@@ -208,9 +181,6 @@ static __inline VOID CheckAndSendPacketFromIndex
return ; return ;
} }
#if 0
PruneQueue(Adapter,(psSF-Adapter->PackInfo));
#endif
spin_lock_bh(&psSF->SFQueueLock); spin_lock_bh(&psSF->SFQueueLock);
QueuePacket=psSF->FirstTxQueue; QueuePacket=psSF->FirstTxQueue;
...@@ -240,7 +210,7 @@ static __inline VOID CheckAndSendPacketFromIndex ...@@ -240,7 +210,7 @@ static __inline VOID CheckAndSendPacketFromIndex
} }
else 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", BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "\nAvailable Tokens = %d required = %d\n",
psSF->uiCurrentTokenCount, iPacketLen); psSF->uiCurrentTokenCount, iPacketLen);
//this part indicates that becuase of non-availability of the tokens //this part indicates that becuase of non-availability of the tokens
...@@ -290,17 +260,6 @@ static __inline VOID CheckAndSendPacketFromIndex ...@@ -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) ...@@ -387,12 +346,7 @@ VOID transmit_packets(PMINI_ADAPTER Adapter)
if(exit_flag == TRUE ) if(exit_flag == TRUE )
break ; break ;
}/* end of inner while loop */ }/* 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); update_per_cid_rx (Adapter);
Adapter->txtransmit_running = 0; Adapter->txtransmit_running = 0;
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "<======"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "<======");
......
...@@ -4,10 +4,6 @@ ...@@ -4,10 +4,6 @@
#ifndef __MACROS_H__ #ifndef __MACROS_H__
#define __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 TX_TIMER_PERIOD 10 //10 msec
#define MAX_CLASSIFIERS 100 #define MAX_CLASSIFIERS 100
//#define MAX_CLASSIFIERS_PER_SF 20 //#define MAX_CLASSIFIERS_PER_SF 20
...@@ -17,10 +13,9 @@ ...@@ -17,10 +13,9 @@
#define MAX_DATA_PKTS 200 #define MAX_DATA_PKTS 200
#define MAX_ETH_SIZE 1536 #define MAX_ETH_SIZE 1536
#define MAX_CNTL_PKT_SIZE 2048 #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 MTU_SIZE 1400
#define TX_QLEN 5
#define MAC_ADDR_REGISTER 0xbf60d000 #define MAC_ADDR_REGISTER 0xbf60d000
...@@ -266,7 +261,7 @@ typedef enum _E_PHS_DSC_ACTION ...@@ -266,7 +261,7 @@ typedef enum _E_PHS_DSC_ACTION
#define FIRMWARE_BEGIN_ADDR 0xBFC00000 #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 INVALID_PID (pid_t)-1
#define DDR_80_MHZ 0 #define DDR_80_MHZ 0
...@@ -300,12 +295,7 @@ typedef enum _E_PHS_DSC_ACTION ...@@ -300,12 +295,7 @@ typedef enum _E_PHS_DSC_ACTION
/* Idle Mode Related Registers */ /* Idle Mode Related Registers */
#define DEBUG_INTERRUPT_GENERATOR_REGISTOR 0x0F00007C #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 #define SW_ABORT_IDLEMODE_LOC 0x0FF01FFC
#endif
#define SW_ABORT_IDLEMODE_PATTERN 0xd0ea1d1e #define SW_ABORT_IDLEMODE_PATTERN 0xd0ea1d1e
#define DEVICE_INT_OUT_EP_REG0 0x0F011870 #define DEVICE_INT_OUT_EP_REG0 0x0F011870
...@@ -355,12 +345,7 @@ typedef enum ePMU_MODES ...@@ -355,12 +345,7 @@ typedef enum ePMU_MODES
HYBRID_MODE_6 = 2 HYBRID_MODE_6 = 2
}PMU_MODE; }PMU_MODE;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
#define MAX_RDM_WRM_RETIRES 16
#else
#define MAX_RDM_WRM_RETIRES 1 #define MAX_RDM_WRM_RETIRES 1
#endif
enum eAbortPattern { enum eAbortPattern {
ABORT_SHUTDOWN_MODE = 1, ABORT_SHUTDOWN_MODE = 1,
...@@ -369,27 +354,6 @@ enum eAbortPattern { ...@@ -369,27 +354,6 @@ enum eAbortPattern {
ABORT_IDLE_SYNCDOWN = 3 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 */ /* Offsets used by driver in skb cb variable */
#define SKB_CB_CLASSIFICATION_OFFSET 0 #define SKB_CB_CLASSIFICATION_OFFSET 0
......
...@@ -6,7 +6,7 @@ obj-$(CONFIG_BCM_WIMAX) += bcm_wimax.o ...@@ -6,7 +6,7 @@ obj-$(CONFIG_BCM_WIMAX) += bcm_wimax.o
bcm_wimax-y := InterfaceDld.o InterfaceIdleMode.o InterfaceInit.o InterfaceRx.o \ bcm_wimax-y := InterfaceDld.o InterfaceIdleMode.o InterfaceInit.o InterfaceRx.o \
InterfaceIsr.o InterfaceMisc.o InterfaceTx.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\ Bcmnet.o DDRInit.o HandleControlPacket.o\
LeakyBucket.o Misc.o sort.o Bcmchar.o hostmibs.o PHSModule.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
#include "headers.h" #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) static VOID default_wimax_protocol_initialize(PMINI_ADAPTER Adapter)
{ {
...@@ -60,15 +67,6 @@ InitAdapter(PMINI_ADAPTER psAdapter) ...@@ -60,15 +67,6 @@ InitAdapter(PMINI_ADAPTER psAdapter)
//init_waitqueue_head(&psAdapter->device_wake_queue); //init_waitqueue_head(&psAdapter->device_wake_queue);
psAdapter->fw_download_done=FALSE; 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); default_wimax_protocol_initialize(psAdapter);
for (i=0;i<MAX_CNTRL_PKTS;i++) for (i=0;i<MAX_CNTRL_PKTS;i++)
...@@ -117,7 +115,7 @@ InitAdapter(PMINI_ADAPTER psAdapter) ...@@ -117,7 +115,7 @@ InitAdapter(PMINI_ADAPTER psAdapter)
VOID AdapterFree(PMINI_ADAPTER Adapter) VOID AdapterFree(PMINI_ADAPTER Adapter)
{ {
INT count = 0; int count;
beceem_protocol_reset(Adapter); beceem_protocol_reset(Adapter);
...@@ -125,72 +123,66 @@ VOID AdapterFree(PMINI_ADAPTER Adapter) ...@@ -125,72 +123,66 @@ VOID AdapterFree(PMINI_ADAPTER Adapter)
if(Adapter->control_packet_handler && !IS_ERR(Adapter->control_packet_handler)) if(Adapter->control_packet_handler && !IS_ERR(Adapter->control_packet_handler))
kthread_stop (Adapter->control_packet_handler); kthread_stop (Adapter->control_packet_handler);
if(Adapter->transmit_packet_thread && !IS_ERR(Adapter->transmit_packet_thread)) if(Adapter->transmit_packet_thread && !IS_ERR(Adapter->transmit_packet_thread))
kthread_stop (Adapter->transmit_packet_thread); kthread_stop (Adapter->transmit_packet_thread);
wake_up(&Adapter->process_read_wait_queue);
wake_up(&Adapter->process_read_wait_queue);
if(Adapter->LEDInfo.led_thread_running & (BCM_LED_THREAD_RUNNING_ACTIVELY | BCM_LED_THREAD_RUNNING_INACTIVELY)) if(Adapter->LEDInfo.led_thread_running & (BCM_LED_THREAD_RUNNING_ACTIVELY | BCM_LED_THREAD_RUNNING_INACTIVELY))
kthread_stop (Adapter->LEDInfo.led_cntrl_threadid); 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)) 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)); 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); msleep(100);
} }
unregister_control_device_interface(Adapter); unregister_control_device_interface(Adapter);
if(Adapter->dev && !IS_ERR(Adapter->dev))
free_netdev(Adapter->dev); kfree(Adapter->pstargetparams);
if(Adapter->pstargetparams != NULL)
{
bcm_kfree(Adapter->pstargetparams);
}
for (count =0;count < MAX_CNTRL_PKTS;count++) for (count =0;count < MAX_CNTRL_PKTS;count++)
{ kfree(Adapter->txctlpacket[count]);
if(Adapter->txctlpacket[count])
bcm_kfree(Adapter->txctlpacket[count]);
}
FreeAdapterDsxBuffer(Adapter); FreeAdapterDsxBuffer(Adapter);
if(Adapter->pvOsDepData)
bcm_kfree (Adapter->pvOsDepData); kfree(Adapter->pvInterfaceAdapter);
if(Adapter->pvInterfaceAdapter)
bcm_kfree(Adapter->pvInterfaceAdapter);
//Free the PHS Interface //Free the PHS Interface
PhsCleanup(&Adapter->stBCMPhsContext); PhsCleanup(&Adapter->stBCMPhsContext);
#ifndef BCM_SHM_INTERFACE
BcmDeAllocFlashCSStructure(Adapter); BcmDeAllocFlashCSStructure(Adapter);
#endif
bcm_kfree (Adapter); free_netdev(Adapter->dev);
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "<========\n");
} }
static int create_worker_threads(PMINI_ADAPTER psAdapter)
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 // Rx Control Packets Processing
psAdapter->control_packet_handler = kthread_run((int (*)(void *)) 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)) 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); return PTR_ERR(psAdapter->control_packet_handler);
} }
// Tx Thread // Tx Thread
psAdapter->transmit_packet_thread = kthread_run((int (*)(void *)) 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)) 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); kthread_stop(psAdapter->control_packet_handler);
return PTR_ERR(psAdapter->transmit_packet_thread); return PTR_ERR(psAdapter->transmit_packet_thread);
} }
return 0; return 0;
} }
static struct file *open_firmware_file(PMINI_ADAPTER Adapter, const char *path)
static inline struct file *open_firmware_file(PMINI_ADAPTER Adapter, char *path)
{ {
struct file *flp=NULL; struct file *flp=NULL;
mm_segment_t oldfs; mm_segment_t oldfs;
...@@ -200,26 +192,20 @@ static inline struct file *open_firmware_file(PMINI_ADAPTER Adapter, char *path) ...@@ -200,26 +192,20 @@ static inline struct file *open_firmware_file(PMINI_ADAPTER Adapter, char *path)
set_fs(oldfs); set_fs(oldfs);
if(IS_ERR(flp)) if(IS_ERR(flp))
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Unable To Open File %s, err %lx", pr_err(DRV_NAME "Unable To Open File %s, err %ld",
path, PTR_ERR(flp)); path, PTR_ERR(flp));
flp = NULL; flp = NULL;
} }
else
{ if(Adapter->device_removed)
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Got file descriptor pointer of %s!", flp = NULL;
path);
}
if(Adapter->device_removed)
{
flp = NULL;
}
return flp; return flp;
} }
int BcmFileDownload(PMINI_ADAPTER Adapter,/**< Logical Adapter */ static int BcmFileDownload(PMINI_ADAPTER Adapter,/**< Logical Adapter */
char *path, /**< path to image file */ const char *path, /**< path to image file */
unsigned int loc /**< Download Address on the chip*/ unsigned int loc /**< Download Address on the chip*/
) )
{ {
...@@ -265,29 +251,8 @@ int BcmFileDownload(PMINI_ADAPTER Adapter,/**< Logical Adapter */ ...@@ -265,29 +251,8 @@ int BcmFileDownload(PMINI_ADAPTER Adapter,/**< Logical Adapter */
if(flp && !(IS_ERR(flp))) if(flp && !(IS_ERR(flp)))
filp_close(flp, current->files); filp_close(flp, current->files);
set_fs(oldfs); 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;
}
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 ;
} }
/** /**
...@@ -395,13 +360,6 @@ INT CopyBufferToControlPacket(PMINI_ADAPTER Adapter,/**<Logical Adapter*/ ...@@ -395,13 +360,6 @@ INT CopyBufferToControlPacket(PMINI_ADAPTER Adapter,/**<Logical Adapter*/
/*Setting bIdleMode_tx_from_host to TRUE to indicate LED control thread to represent /*Setting bIdleMode_tx_from_host to TRUE to indicate LED control thread to represent
the wake up from idlemode is from host*/ the wake up from idlemode is from host*/
//Adapter->LEDInfo.bIdleMode_tx_from_host = TRUE; //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; Adapter->bWakeUpDevice = TRUE;
wake_up(&Adapter->process_rx_cntrlpkt); wake_up(&Adapter->process_rx_cntrlpkt);
...@@ -489,9 +447,6 @@ INT CopyBufferToControlPacket(PMINI_ADAPTER Adapter,/**<Logical Adapter*/ ...@@ -489,9 +447,6 @@ INT CopyBufferToControlPacket(PMINI_ADAPTER Adapter,/**<Logical Adapter*/
atomic_inc(&Adapter->index_wr_txcntrlpkt); atomic_inc(&Adapter->index_wr_txcntrlpkt);
BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Calling transmit_packets"); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Calling transmit_packets");
atomic_set(&Adapter->TxPktAvail, 1); atomic_set(&Adapter->TxPktAvail, 1);
#ifdef BCM_SHM_INTERFACE
virtual_mail_box_interrupt();
#endif
wake_up(&Adapter->tx_packet_wait_queue); wake_up(&Adapter->tx_packet_wait_queue);
} }
else else
...@@ -530,18 +485,6 @@ static VOID SendStatisticsPointerRequest(PMINI_ADAPTER Adapter, ...@@ -530,18 +485,6 @@ static VOID SendStatisticsPointerRequest(PMINI_ADAPTER Adapter,
#endif #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() * Function - LinkMessage()
* *
...@@ -552,7 +495,7 @@ void SendLinkDown(PMINI_ADAPTER Adapter) ...@@ -552,7 +495,7 @@ void SendLinkDown(PMINI_ADAPTER Adapter)
* *
* Returns - None. * Returns - None.
*******************************************************************/ *******************************************************************/
__inline VOID LinkMessage(PMINI_ADAPTER Adapter) VOID LinkMessage(PMINI_ADAPTER Adapter)
{ {
PLINK_REQUEST pstLinkRequest=NULL; PLINK_REQUEST pstLinkRequest=NULL;
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "=====>"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "=====>");
...@@ -594,7 +537,7 @@ __inline VOID LinkMessage(PMINI_ADAPTER Adapter) ...@@ -594,7 +537,7 @@ __inline VOID LinkMessage(PMINI_ADAPTER Adapter)
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Calling CopyBufferToControlPacket"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Calling CopyBufferToControlPacket");
CopyBufferToControlPacket(Adapter, pstLinkRequest); CopyBufferToControlPacket(Adapter, pstLinkRequest);
bcm_kfree(pstLinkRequest); kfree(pstLinkRequest);
} }
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "LinkMessage <====="); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "LinkMessage <=====");
return; return;
...@@ -614,8 +557,8 @@ __inline VOID LinkMessage(PMINI_ADAPTER Adapter) ...@@ -614,8 +557,8 @@ __inline VOID LinkMessage(PMINI_ADAPTER Adapter)
VOID StatisticsResponse(PMINI_ADAPTER Adapter,PVOID pvBuffer) VOID StatisticsResponse(PMINI_ADAPTER Adapter,PVOID pvBuffer)
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s====>",__FUNCTION__); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s====>",__FUNCTION__);
Adapter->StatisticsPointer = ntohl(*(PULONG)pvBuffer); Adapter->StatisticsPointer = ntohl(*(__be32 *)pvBuffer);
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Stats at %lx", Adapter->StatisticsPointer); 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__); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s <====",__FUNCTION__);
return; return;
} }
...@@ -787,12 +730,10 @@ void SendIdleModeResponse(PMINI_ADAPTER Adapter) ...@@ -787,12 +730,10 @@ void SendIdleModeResponse(PMINI_ADAPTER Adapter)
down(&Adapter->rdmwrmsync); down(&Adapter->rdmwrmsync);
Adapter->bPreparingForLowPowerMode = TRUE; Adapter->bPreparingForLowPowerMode = TRUE;
up(&Adapter->rdmwrmsync); up(&Adapter->rdmwrmsync);
#ifndef BCM_SHM_INTERFACE
//Killing all URBS. //Killing all URBS.
if(Adapter->bDoSuspend == TRUE) if(Adapter->bDoSuspend == TRUE)
Bcm_kill_all_URBs((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter)); Bcm_kill_all_URBs((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter));
#endif
} }
else else
{ {
...@@ -811,9 +752,7 @@ void SendIdleModeResponse(PMINI_ADAPTER Adapter) ...@@ -811,9 +752,7 @@ void SendIdleModeResponse(PMINI_ADAPTER Adapter)
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"fail to send the Idle mode Request \n"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"fail to send the Idle mode Request \n");
Adapter->bPreparingForLowPowerMode = FALSE; Adapter->bPreparingForLowPowerMode = FALSE;
#ifndef BCM_SHM_INTERFACE
StartInterruptUrb((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter)); StartInterruptUrb((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter));
#endif
} }
do_gettimeofday(&tv); 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); 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 +919,10 @@ VOID DumpPackInfo(PMINI_ADAPTER Adapter) ...@@ -980,12 +919,10 @@ VOID DumpPackInfo(PMINI_ADAPTER Adapter)
} }
int reset_card_proc(PMINI_ADAPTER ps_adapter)
__inline int reset_card_proc(PMINI_ADAPTER ps_adapter)
{ {
int retval = STATUS_SUCCESS; int retval = STATUS_SUCCESS;
#ifndef BCM_SHM_INTERFACE
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
PS_INTERFACE_ADAPTER psIntfAdapter = NULL; PS_INTERFACE_ADAPTER psIntfAdapter = NULL;
unsigned int value = 0, uiResetValue = 0; unsigned int value = 0, uiResetValue = 0;
...@@ -1006,11 +943,9 @@ __inline int reset_card_proc(PMINI_ADAPTER ps_adapter) ...@@ -1006,11 +943,9 @@ __inline int reset_card_proc(PMINI_ADAPTER ps_adapter)
wrmalt(ps_adapter, SYS_CFG, &value, sizeof(value)); wrmalt(ps_adapter, SYS_CFG, &value, sizeof(value));
} }
#ifndef BCM_SHM_INTERFACE
//killing all submitted URBs. //killing all submitted URBs.
psIntfAdapter->psAdapter->StopAllXaction = TRUE ; psIntfAdapter->psAdapter->StopAllXaction = TRUE ;
Bcm_kill_all_URBs(psIntfAdapter); Bcm_kill_all_URBs(psIntfAdapter);
#endif
/* Reset the UMA-B Device */ /* Reset the UMA-B Device */
if(ps_adapter->chip_id >= T3LPB) if(ps_adapter->chip_id >= T3LPB)
{ {
...@@ -1111,11 +1046,10 @@ __inline int reset_card_proc(PMINI_ADAPTER ps_adapter) ...@@ -1111,11 +1046,10 @@ __inline int reset_card_proc(PMINI_ADAPTER ps_adapter)
err_exit : err_exit :
psIntfAdapter->psAdapter->StopAllXaction = FALSE ; psIntfAdapter->psAdapter->StopAllXaction = FALSE ;
#endif
return retval; return retval;
} }
__inline int run_card_proc(PMINI_ADAPTER ps_adapter ) int run_card_proc(PMINI_ADAPTER ps_adapter )
{ {
unsigned int value=0; unsigned int value=0;
{ {
...@@ -1148,19 +1082,15 @@ int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter) ...@@ -1148,19 +1082,15 @@ int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter)
UINT status = STATUS_SUCCESS; UINT status = STATUS_SUCCESS;
UINT value = 0; 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 * Create the threads first and then download the
* Firm/DDR Settings.. * Firm/DDR Settings..
*/ */
if((status = create_worker_threads(ps_adapter))<0) status = create_worker_threads(ps_adapter);
{ if (status<0)
BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Cannot create thread");
return status; return status;
}
/* /*
* For Downloading the Firm, parse the cfg file first. * For Downloading the Firm, parse the cfg file first.
*/ */
...@@ -1169,7 +1099,6 @@ int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter) ...@@ -1169,7 +1099,6 @@ int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter)
return status; return status;
} }
#ifndef BCM_SHM_INTERFACE
if(ps_adapter->chip_id >= T3LPB) if(ps_adapter->chip_id >= T3LPB)
{ {
rdmalt(ps_adapter, SYS_CFG, &value, sizeof (value)); rdmalt(ps_adapter, SYS_CFG, &value, sizeof (value));
...@@ -1187,7 +1116,7 @@ int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter) ...@@ -1187,7 +1116,7 @@ int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter)
status = ddr_init(ps_adapter); status = ddr_init(ps_adapter);
if(status) 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; return status;
} }
...@@ -1201,7 +1130,6 @@ int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter) ...@@ -1201,7 +1130,6 @@ int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter)
BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Error downloading CFG file"); BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Error downloading CFG file");
goto OUT; goto OUT;
} }
BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "CFG file downloaded");
if(register_networkdev(ps_adapter)) if(register_networkdev(ps_adapter))
{ {
...@@ -1266,12 +1194,6 @@ int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter) ...@@ -1266,12 +1194,6 @@ int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter)
goto OUT; goto OUT;
} }
} }
#if 0
else if(psAdapter->eNVMType == NVM_EEPROM)
{
PropagateCalParamsFromEEPROMToMemory();
}
#endif
/* Download Firmare */ /* Download Firmare */
if ((status = BcmFileDownload( ps_adapter, BIN_FILE, FIRMWARE_BEGIN_ADDR))) if ((status = BcmFileDownload( ps_adapter, BIN_FILE, FIRMWARE_BEGIN_ADDR)))
...@@ -1280,7 +1202,6 @@ int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter) ...@@ -1280,7 +1202,6 @@ int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter)
goto OUT; goto OUT;
} }
BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "BIN file downloaded");
status = run_card_proc(ps_adapter); status = run_card_proc(ps_adapter);
if(status) if(status)
{ {
...@@ -1299,61 +1220,12 @@ int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter) ...@@ -1299,61 +1220,12 @@ int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter)
wake_up(&ps_adapter->LEDInfo.notify_led_event); 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; 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; struct file *flp=NULL;
mm_segment_t oldfs={0}; mm_segment_t oldfs={0};
char *buff = NULL; char *buff = NULL;
...@@ -1368,14 +1240,14 @@ int bcm_parse_target_params(PMINI_ADAPTER Adapter) ...@@ -1368,14 +1240,14 @@ int bcm_parse_target_params(PMINI_ADAPTER Adapter)
if((Adapter->pstargetparams = if((Adapter->pstargetparams =
kmalloc(sizeof(STARGETPARAMS), GFP_KERNEL)) == NULL) kmalloc(sizeof(STARGETPARAMS), GFP_KERNEL)) == NULL)
{ {
bcm_kfree(buff); kfree(buff);
return -ENOMEM; return -ENOMEM;
} }
flp=open_firmware_file(Adapter, CFG_FILE); flp=open_firmware_file(Adapter, CFG_FILE);
if(!flp) { 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_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "NOT ABLE TO OPEN THE %s FILE \n", CFG_FILE);
bcm_kfree(buff); kfree(buff);
bcm_kfree(Adapter->pstargetparams); kfree(Adapter->pstargetparams);
Adapter->pstargetparams = NULL; Adapter->pstargetparams = NULL;
return -ENOENT; return -ENOENT;
} }
...@@ -1386,8 +1258,8 @@ int bcm_parse_target_params(PMINI_ADAPTER Adapter) ...@@ -1386,8 +1258,8 @@ int bcm_parse_target_params(PMINI_ADAPTER Adapter)
if(len != sizeof(STARGETPARAMS)) if(len != sizeof(STARGETPARAMS))
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Mismatch in Target Param Structure!\n"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Mismatch in Target Param Structure!\n");
bcm_kfree(buff); kfree(buff);
bcm_kfree(Adapter->pstargetparams); kfree(Adapter->pstargetparams);
Adapter->pstargetparams = NULL; Adapter->pstargetparams = NULL;
filp_close(flp, current->files); filp_close(flp, current->files);
return -ENOENT; return -ENOENT;
...@@ -1399,12 +1271,8 @@ int bcm_parse_target_params(PMINI_ADAPTER Adapter) ...@@ -1399,12 +1271,8 @@ int bcm_parse_target_params(PMINI_ADAPTER Adapter)
* Values in Adapter->pstargetparams are in network byte order * Values in Adapter->pstargetparams are in network byte order
*/ */
memcpy(Adapter->pstargetparams, buff, sizeof(STARGETPARAMS)); memcpy(Adapter->pstargetparams, buff, sizeof(STARGETPARAMS));
bcm_kfree (buff); kfree (buff);
beceem_parse_target_struct(Adapter); beceem_parse_target_struct(Adapter);
#ifdef BCM_SHM_INTERFACE
read_cfg_file(Adapter);
#endif
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
...@@ -1414,22 +1282,23 @@ void beceem_parse_target_struct(PMINI_ADAPTER Adapter) ...@@ -1414,22 +1282,23 @@ void beceem_parse_target_struct(PMINI_ADAPTER Adapter)
if(ntohl(Adapter->pstargetparams->m_u32PhyParameter2) & AUTO_SYNC_DISABLE) 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; Adapter->AutoSyncup = FALSE;
} }
else 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; Adapter->AutoSyncup = TRUE;
} }
if(ntohl(Adapter->pstargetparams->HostDrvrConfig6) & AUTO_LINKUP_ENABLE) 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; Adapter->AutoLinkUp = TRUE;
} }
else 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; Adapter->AutoLinkUp = FALSE;
} }
// Setting the DDR Setting.. // Setting the DDR Setting..
...@@ -1438,59 +1307,54 @@ void beceem_parse_target_struct(PMINI_ADAPTER Adapter) ...@@ -1438,59 +1307,54 @@ void beceem_parse_target_struct(PMINI_ADAPTER Adapter)
Adapter->ulPowerSaveMode = Adapter->ulPowerSaveMode =
(ntohl(Adapter->pstargetparams->HostDrvrConfig6)>>12)&0x0F; (ntohl(Adapter->pstargetparams->HostDrvrConfig6)>>12)&0x0F;
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "DDR Setting: %x\n", Adapter->DDRSetting); pr_info(DRV_NAME ": DDR Setting: %x\n", Adapter->DDRSetting);
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT,DBG_LVL_ALL, "Power Save Mode: %lx\n", pr_info(DRV_NAME ": Power Save Mode: %lx\n", Adapter->ulPowerSaveMode);
Adapter->ulPowerSaveMode);
if(ntohl(Adapter->pstargetparams->HostDrvrConfig6) & AUTO_FIRM_DOWNLOAD) 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; Adapter->AutoFirmDld = TRUE;
} }
else 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; Adapter->AutoFirmDld = FALSE;
} }
uiHostDrvrCfg6 = ntohl(Adapter->pstargetparams->HostDrvrConfig6); uiHostDrvrCfg6 = ntohl(Adapter->pstargetparams->HostDrvrConfig6);
Adapter->bMipsConfig = (uiHostDrvrCfg6>>20)&0x01; 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. //used for backward compatibility.
Adapter->bDPLLConfig = (uiHostDrvrCfg6>>19)&0x01; Adapter->bDPLLConfig = (uiHostDrvrCfg6>>19)&0x01;
Adapter->PmuMode= (uiHostDrvrCfg6 >> 24 ) & 0x03; 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)) if((uiHostDrvrCfg6 >> HOST_BUS_SUSPEND_BIT ) & (0x01))
{ {
Adapter->bDoSuspend = TRUE; 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); 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->eNVMType = (NVM_TYPE)((uiEEPROMFlag>>4)&0x3);
Adapter->bStatusWrite = (uiEEPROMFlag>>6)&0x1; Adapter->bStatusWrite = (uiEEPROMFlag>>6)&0x1;
//printk(("bStatusWrite : 0x%X\n", Adapter->bStatusWrite));
Adapter->uiSectorSizeInCFG = 1024*(0xFFFF & ntohl(Adapter->pstargetparams->HostDrvrConfig4)); Adapter->uiSectorSizeInCFG = 1024*(0xFFFF & ntohl(Adapter->pstargetparams->HostDrvrConfig4));
//printk(("uiSectorSize : 0x%X\n", Adapter->uiSectorSizeInCFG));
Adapter->bSectorSizeOverride =(bool) ((ntohl(Adapter->pstargetparams->HostDrvrConfig4))>>16)&0x1; 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) if(ntohl(Adapter->pstargetparams->m_u32PowerSavingModeOptions) &0x01)
Adapter->ulPowerSaveMode = DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE; Adapter->ulPowerSaveMode = DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE;
//autocorrection part
if(Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE) if(Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE)
doPowerAutoCorrection(Adapter); 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 ; reporting_mode = ntohl(psAdapter->pstargetparams->m_u32PowerSavingModeOptions) &0x02 ;
psAdapter->bIsAutoCorrectEnabled = !((char)(psAdapter->ulPowerSaveMode >> 3) & 0x1); psAdapter->bIsAutoCorrectEnabled = !((char)(psAdapter->ulPowerSaveMode >> 3) & 0x1);
...@@ -1504,20 +1368,9 @@ VOID doPowerAutoCorrection(PMINI_ADAPTER psAdapter) ...@@ -1504,20 +1368,9 @@ VOID doPowerAutoCorrection(PMINI_ADAPTER psAdapter)
if (psAdapter->bIsAutoCorrectEnabled && (psAdapter->chip_id >= T3LPB)) if (psAdapter->bIsAutoCorrectEnabled && (psAdapter->chip_id >= T3LPB))
{ {
//If reporting mode is enable, switch PMU to PMC //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->ulPowerSaveMode = DEVICE_POWERSAVE_MODE_AS_PMU_CLOCK_GATING;
psAdapter->bDoSuspend =FALSE; psAdapter->bDoSuspend =FALSE;
BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"PMC selected..");
} }
...@@ -1558,7 +1411,7 @@ static unsigned char *ReadMacAddrEEPROM(PMINI_ADAPTER Adapter, ulong dwAddress) ...@@ -1558,7 +1411,7 @@ static unsigned char *ReadMacAddrEEPROM(PMINI_ADAPTER Adapter, ulong dwAddress)
if(status != STATUS_SUCCESS) if(status != STATUS_SUCCESS)
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "wrm Failed..\n"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "wrm Failed..\n");
bcm_kfree(pucmacaddr); kfree(pucmacaddr);
pucmacaddr = NULL; pucmacaddr = NULL;
goto OUT; goto OUT;
} }
...@@ -1568,7 +1421,7 @@ static unsigned char *ReadMacAddrEEPROM(PMINI_ADAPTER Adapter, ulong dwAddress) ...@@ -1568,7 +1421,7 @@ static unsigned char *ReadMacAddrEEPROM(PMINI_ADAPTER Adapter, ulong dwAddress)
if(status != STATUS_SUCCESS) if(status != STATUS_SUCCESS)
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "rdm Failed..\n"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "rdm Failed..\n");
bcm_kfree(pucmacaddr); kfree(pucmacaddr);
pucmacaddr = NULL; pucmacaddr = NULL;
goto OUT; goto OUT;
} }
...@@ -1580,43 +1433,6 @@ static unsigned char *ReadMacAddrEEPROM(PMINI_ADAPTER Adapter, ulong dwAddress) ...@@ -1580,43 +1433,6 @@ static unsigned char *ReadMacAddrEEPROM(PMINI_ADAPTER Adapter, ulong dwAddress)
} }
#endif #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) static void convertEndian(B_UINT8 rwFlag, PUINT puiBuffer, UINT uiByteCount)
{ {
...@@ -1640,81 +1456,21 @@ int rdm(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize) ...@@ -1640,81 +1456,21 @@ int rdm(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize)
{ {
INT uiRetVal =0; INT uiRetVal =0;
#ifndef BCM_SHM_INTERFACE
uiRetVal = Adapter->interface_rdm(Adapter->pvInterfaceAdapter, uiRetVal = Adapter->interface_rdm(Adapter->pvInterfaceAdapter,
uiAddress, pucBuff, sSize); uiAddress, pucBuff, sSize);
if(uiRetVal < 0) if(uiRetVal < 0)
return uiRetVal; 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; return uiRetVal;
} }
int wrm(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize) int wrm(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize)
{ {
int iRetVal; int iRetVal;
#ifndef BCM_SHM_INTERFACE
iRetVal = Adapter->interface_wrm(Adapter->pvInterfaceAdapter, iRetVal = Adapter->interface_wrm(Adapter->pvInterfaceAdapter,
uiAddress, pucBuff, sSize); 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; return iRetVal;
} }
...@@ -1735,26 +1491,7 @@ int rdmalt (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size) ...@@ -1735,26 +1491,7 @@ int rdmalt (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size)
return uiRetVal; 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 wrmWithLock(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize)
{ {
INT status = STATUS_SUCCESS ; INT status = STATUS_SUCCESS ;
...@@ -1921,10 +1658,8 @@ static VOID SendShutModeResponse(PMINI_ADAPTER Adapter) ...@@ -1921,10 +1658,8 @@ static VOID SendShutModeResponse(PMINI_ADAPTER Adapter)
Adapter->bPreparingForLowPowerMode = TRUE; Adapter->bPreparingForLowPowerMode = TRUE;
up(&Adapter->rdmwrmsync); up(&Adapter->rdmwrmsync);
//Killing all URBS. //Killing all URBS.
#ifndef BCM_SHM_INTERFACE
if(Adapter->bDoSuspend == TRUE) if(Adapter->bDoSuspend == TRUE)
Bcm_kill_all_URBs((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter)); Bcm_kill_all_URBs((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter));
#endif
} }
else else
{ {
...@@ -1943,14 +1678,12 @@ static VOID SendShutModeResponse(PMINI_ADAPTER Adapter) ...@@ -1943,14 +1678,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"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL,"fail to send the Idle mode Request \n");
Adapter->bPreparingForLowPowerMode = FALSE; Adapter->bPreparingForLowPowerMode = FALSE;
#ifndef BCM_SHM_INTERFACE
StartInterruptUrb((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter)); 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; B_UINT32 uiResetValue = 0;
...@@ -2077,11 +1810,7 @@ void update_per_sf_desc_cnts( PMINI_ADAPTER Adapter) ...@@ -2077,11 +1810,7 @@ void update_per_sf_desc_cnts( PMINI_ADAPTER Adapter)
if(!atomic_read (&Adapter->uiMBupdate)) if(!atomic_read (&Adapter->uiMBupdate))
return; 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) 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"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "rdm failed\n");
return; return;
...@@ -2107,9 +1836,7 @@ void update_per_sf_desc_cnts( PMINI_ADAPTER Adapter) ...@@ -2107,9 +1836,7 @@ void update_per_sf_desc_cnts( PMINI_ADAPTER Adapter)
void flush_queue(PMINI_ADAPTER Adapter, UINT iQIndex) void flush_queue(PMINI_ADAPTER Adapter, UINT iQIndex)
{ {
struct sk_buff* PacketToDrop=NULL; struct sk_buff* PacketToDrop=NULL;
struct net_device_stats* netstats=NULL; struct net_device_stats* netstats = &Adapter->dev->stats;
netstats = &((PLINUX_DEP_DATA)Adapter->pvOsDepData)->netstats;
spin_lock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock); spin_lock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock);
...@@ -2130,25 +1857,23 @@ void flush_queue(PMINI_ADAPTER Adapter, UINT iQIndex) ...@@ -2130,25 +1857,23 @@ void flush_queue(PMINI_ADAPTER Adapter, UINT iQIndex)
Adapter->PackInfo[iQIndex].uiDroppedCountBytes += PacketToDrop->len; Adapter->PackInfo[iQIndex].uiDroppedCountBytes += PacketToDrop->len;
Adapter->PackInfo[iQIndex].uiDroppedCountPackets++; Adapter->PackInfo[iQIndex].uiDroppedCountPackets++;
bcm_kfree_skb(PacketToDrop); dev_kfree_skb(PacketToDrop);
atomic_dec(&Adapter->TotalPacketCount); atomic_dec(&Adapter->TotalPacketCount);
atomic_inc(&Adapter->TxDroppedPacketCount);
} }
} }
spin_unlock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock); 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) 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); netif_carrier_off(Adapter->dev);
} netif_stop_queue(Adapter->dev);
Adapter->IdleMode = FALSE; Adapter->IdleMode = FALSE;
Adapter->LinkUpStatus = FALSE; Adapter->LinkUpStatus = FALSE;
...@@ -2166,78 +1891,18 @@ void beceem_protocol_reset (PMINI_ADAPTER Adapter) ...@@ -2166,78 +1891,18 @@ void beceem_protocol_reset (PMINI_ADAPTER Adapter)
Adapter->TimerActive = FALSE; Adapter->TimerActive = FALSE;
memset(Adapter->astFragmentedPktClassifierTable, 0, memset(Adapter->astFragmentedPktClassifierTable, 0,
sizeof(S_FRAGMENTED_PACKET_INFO) * sizeof(S_FRAGMENTED_PACKET_INFO) * MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES);
MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES);
for(i = 0;i<HiPriority;i++) for(i = 0;i<HiPriority;i++)
{ {
//resetting only the first size (S_MIBS_SERVICEFLOW_TABLE) for the SF. //resetting only the first size (S_MIBS_SERVICEFLOW_TABLE) for the SF.
// It is same between MIBs and 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
/*++
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));
}
#include "headers.h" #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 IN
#define OUT #define OUT
void DumpDataPacketHeader(PUCHAR pPkt);
/* /*
Function: PHSTransmit Function: PHSTransmit
...@@ -81,8 +125,6 @@ int PHSTransmit(PMINI_ADAPTER Adapter, ...@@ -81,8 +125,6 @@ int PHSTransmit(PMINI_ADAPTER Adapter,
{ {
//DumpDataPacketHeader(pucPHSPktHdrInBuf);
// Step 2 Supress Header using PHS and fill into intermediate ucaPHSPktHdrOutBuf. // Step 2 Supress Header using PHS and fill into intermediate ucaPHSPktHdrOutBuf.
// Suppress only if IP Header and PHS Enabled For the Service Flow // Suppress only if IP Header and PHS Enabled For the Service Flow
if(((usPacketType == ETHERNET_FRAMETYPE_IPV4) || if(((usPacketType == ETHERNET_FRAMETYPE_IPV4) ||
...@@ -120,15 +162,15 @@ int PHSTransmit(PMINI_ADAPTER Adapter, ...@@ -120,15 +162,15 @@ int PHSTransmit(PMINI_ADAPTER Adapter,
if(newPacket == NULL) if(newPacket == NULL)
return STATUS_FAILURE; return STATUS_FAILURE;
bcm_kfree_skb(Packet); dev_kfree_skb(Packet);
*pPacket = Packet = newPacket; *pPacket = Packet = newPacket;
pucPHSPktHdrInBuf = Packet->data + BytesToRemove; pucPHSPktHdrInBuf = Packet->data + BytesToRemove;
} }
numBytesCompressed = unPhsOldHdrSize - (unPHSNewPktHeaderLen+PHSI_LEN); numBytesCompressed = unPhsOldHdrSize - (unPHSNewPktHeaderLen+PHSI_LEN);
OsalMemMove(pucPHSPktHdrInBuf + numBytesCompressed, pucPHSPktHdrOutBuf, unPHSNewPktHeaderLen + PHSI_LEN); memcpy(pucPHSPktHdrInBuf + numBytesCompressed, pucPHSPktHdrOutBuf, unPHSNewPktHeaderLen + PHSI_LEN);
OsalMemMove(Packet->data + numBytesCompressed, Packet->data, BytesToRemove); memcpy(Packet->data + numBytesCompressed, Packet->data, BytesToRemove);
skb_pull(Packet, numBytesCompressed); skb_pull(Packet, numBytesCompressed);
return STATUS_SUCCESS; return STATUS_SUCCESS;
...@@ -223,23 +265,12 @@ int PHSRecieve(PMINI_ADAPTER Adapter, ...@@ -223,23 +265,12 @@ int PHSRecieve(PMINI_ADAPTER Adapter,
} }
} }
OsalMemMove(packet->data, Adapter->ucaPHSPktRestoreBuf, nStandardPktHdrLen); memcpy(packet->data, Adapter->ucaPHSPktRestoreBuf, nStandardPktHdrLen);
} }
return STATUS_SUCCESS; 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) void DumpFullPacket(UCHAR *pBuf,UINT nPktLen)
{ {
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
...@@ -270,15 +301,9 @@ int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension,PMINI_ADAPTER Adapter) ...@@ -270,15 +301,9 @@ int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension,PMINI_ADAPTER Adapter)
return -EINVAL; return -EINVAL;
pPhsdeviceExtension->pstServiceFlowPhsRulesTable = pPhsdeviceExtension->pstServiceFlowPhsRulesTable =
(S_SERVICEFLOW_TABLE*)OsalMemAlloc(sizeof(S_SERVICEFLOW_TABLE), kzalloc(sizeof(S_SERVICEFLOW_TABLE), GFP_KERNEL);
PHS_MEM_TAG);
if(pPhsdeviceExtension->pstServiceFlowPhsRulesTable) if(!pPhsdeviceExtension->pstServiceFlowPhsRulesTable)
{
OsalZeroMemory(pPhsdeviceExtension->pstServiceFlowPhsRulesTable,
sizeof(S_SERVICEFLOW_TABLE));
}
else
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation ServiceFlowPhsRulesTable failed"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation ServiceFlowPhsRulesTable failed");
return -ENOMEM; return -ENOMEM;
...@@ -288,14 +313,8 @@ int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension,PMINI_ADAPTER Adapter) ...@@ -288,14 +313,8 @@ int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension,PMINI_ADAPTER Adapter)
for(i=0;i<MAX_SERVICEFLOWS;i++) for(i=0;i<MAX_SERVICEFLOWS;i++)
{ {
S_SERVICEFLOW_ENTRY sServiceFlow = pstServiceFlowTable->stSFList[i]; S_SERVICEFLOW_ENTRY sServiceFlow = pstServiceFlowTable->stSFList[i];
sServiceFlow.pstClassifierTable = (S_CLASSIFIER_TABLE*)OsalMemAlloc( sServiceFlow.pstClassifierTable = kzalloc(sizeof(S_CLASSIFIER_TABLE), GFP_KERNEL);
sizeof(S_CLASSIFIER_TABLE), PHS_MEM_TAG); if(!sServiceFlow.pstClassifierTable)
if(sServiceFlow.pstClassifierTable)
{
OsalZeroMemory(sServiceFlow.pstClassifierTable,sizeof(S_CLASSIFIER_TABLE));
pstServiceFlowTable->stSFList[i].pstClassifierTable = sServiceFlow.pstClassifierTable;
}
else
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation failed"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation failed");
free_phs_serviceflow_rules(pPhsdeviceExtension-> free_phs_serviceflow_rules(pPhsdeviceExtension->
...@@ -305,9 +324,7 @@ int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension,PMINI_ADAPTER Adapter) ...@@ -305,9 +324,7 @@ int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension,PMINI_ADAPTER Adapter)
} }
} }
pPhsdeviceExtension->CompressedTxBuffer = kmalloc(PHS_BUFFER_SIZE, GFP_KERNEL);
pPhsdeviceExtension->CompressedTxBuffer =
OsalMemAlloc(PHS_BUFFER_SIZE,PHS_MEM_TAG);
if(pPhsdeviceExtension->CompressedTxBuffer == NULL) if(pPhsdeviceExtension->CompressedTxBuffer == NULL)
{ {
...@@ -317,12 +334,11 @@ int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension,PMINI_ADAPTER Adapter) ...@@ -317,12 +334,11 @@ int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension,PMINI_ADAPTER Adapter)
return -ENOMEM; return -ENOMEM;
} }
pPhsdeviceExtension->UnCompressedRxBuffer = pPhsdeviceExtension->UnCompressedRxBuffer = kmalloc(PHS_BUFFER_SIZE, GFP_KERNEL);
OsalMemAlloc(PHS_BUFFER_SIZE,PHS_MEM_TAG);
if(pPhsdeviceExtension->UnCompressedRxBuffer == NULL) if(pPhsdeviceExtension->UnCompressedRxBuffer == NULL)
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation failed"); 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); free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable);
pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL; pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL;
return -ENOMEM; return -ENOMEM;
...@@ -343,16 +359,11 @@ int PhsCleanup(IN PPHS_DEVICE_EXTENSION pPHSDeviceExt) ...@@ -343,16 +359,11 @@ int PhsCleanup(IN PPHS_DEVICE_EXTENSION pPHSDeviceExt)
pPHSDeviceExt->pstServiceFlowPhsRulesTable = NULL; pPHSDeviceExt->pstServiceFlowPhsRulesTable = NULL;
} }
if(pPHSDeviceExt->CompressedTxBuffer) kfree(pPHSDeviceExt->CompressedTxBuffer);
{ pPHSDeviceExt->CompressedTxBuffer = NULL;
OsalMemFree(pPHSDeviceExt->CompressedTxBuffer,PHS_BUFFER_SIZE);
pPHSDeviceExt->CompressedTxBuffer = NULL; kfree(pPHSDeviceExt->UnCompressedRxBuffer);
} pPHSDeviceExt->UnCompressedRxBuffer = NULL;
if(pPHSDeviceExt->UnCompressedRxBuffer)
{
OsalMemFree(pPHSDeviceExt->UnCompressedRxBuffer,PHS_BUFFER_SIZE);
pPHSDeviceExt->UnCompressedRxBuffer = NULL;
}
return 0; return 0;
} }
...@@ -478,20 +489,12 @@ ULONG PhsDeletePHSRule(IN void* pvContext,IN B_UINT16 uiVcid,IN B_UINT8 u8PHSI) ...@@ -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].bUsed && pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule)
{ {
if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex] if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8PHSI == u8PHSI) {
.pstPhsRule->u8PHSI == u8PHSI) if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt)
{ pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt--;
if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule if(0 == pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt)
->u8RefCnt) kfree(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule);
pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule memset(&pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex], 0,
->u8RefCnt--;
if(0 == pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex]
.pstPhsRule->u8RefCnt)
OsalMemFree(pstClassifierRulesTable
->stActivePhsRulesList[nClsidIndex].pstPhsRule,
sizeof(S_PHS_RULE));
OsalZeroMemory(&pstClassifierRulesTable
->stActivePhsRulesList[nClsidIndex],
sizeof(S_CLASSIFIER_ENTRY)); sizeof(S_CLASSIFIER_ENTRY));
} }
} }
...@@ -548,10 +551,10 @@ ULONG PhsDeleteClassifierRule(IN void* pvContext,IN B_UINT16 uiVcid ,IN B_UINT16 ...@@ -548,10 +551,10 @@ ULONG PhsDeleteClassifierRule(IN void* pvContext,IN B_UINT16 uiVcid ,IN B_UINT16
if(pstClassifierEntry->pstPhsRule->u8RefCnt) if(pstClassifierEntry->pstPhsRule->u8RefCnt)
pstClassifierEntry->pstPhsRule->u8RefCnt--; pstClassifierEntry->pstPhsRule->u8RefCnt--;
if(0==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, nClsidIndex = GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable,
...@@ -559,10 +562,8 @@ ULONG PhsDeleteClassifierRule(IN void* pvContext,IN B_UINT16 uiVcid ,IN B_UINT16 ...@@ -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((nClsidIndex != PHS_INVALID_TABLE_INDEX) && (!pstClassifierEntry->bUnclassifiedPHSRule))
{ {
if(pstClassifierEntry->pstPhsRule) kfree(pstClassifierEntry->pstPhsRule);
//Delete the classifier entry memset(pstClassifierEntry, 0, sizeof(S_CLASSIFIER_ENTRY));
OsalMemFree(pstClassifierEntry->pstPhsRule,sizeof(S_PHS_RULE));
OsalZeroMemory(pstClassifierEntry,sizeof(S_CLASSIFIER_ENTRY));
} }
} }
return lStatus; return lStatus;
...@@ -619,14 +620,11 @@ ULONG PhsDeleteSFRules(IN void* pvContext,IN B_UINT16 uiVcid) ...@@ -619,14 +620,11 @@ ULONG PhsDeleteSFRules(IN void* pvContext,IN B_UINT16 uiVcid)
.pstPhsRule->u8RefCnt--; .pstPhsRule->u8RefCnt--;
if(0==pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex] if(0==pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex]
.pstPhsRule->u8RefCnt) .pstPhsRule->u8RefCnt)
OsalMemFree(pstClassifierRulesTable kfree(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule);
->stActivePhsRulesList[nClsidIndex].pstPhsRule,
sizeof(S_PHS_RULE));
pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex] pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex]
.pstPhsRule = NULL; .pstPhsRule = NULL;
} }
OsalZeroMemory(&pstClassifierRulesTable memset(&pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex], 0, sizeof(S_CLASSIFIER_ENTRY));
->stActivePhsRulesList[nClsidIndex],sizeof(S_CLASSIFIER_ENTRY));
if(pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex].pstPhsRule) if(pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex].pstPhsRule)
{ {
if(pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex] if(pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex]
...@@ -635,15 +633,12 @@ ULONG PhsDeleteSFRules(IN void* pvContext,IN B_UINT16 uiVcid) ...@@ -635,15 +633,12 @@ ULONG PhsDeleteSFRules(IN void* pvContext,IN B_UINT16 uiVcid)
.pstPhsRule->u8RefCnt--; .pstPhsRule->u8RefCnt--;
if(0 == pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex] if(0 == pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex]
.pstPhsRule->u8RefCnt) .pstPhsRule->u8RefCnt)
OsalMemFree(pstClassifierRulesTable kfree(pstClassifierRulesTable
->stOldPhsRulesList[nClsidIndex].pstPhsRule, ->stOldPhsRulesList[nClsidIndex].pstPhsRule);
sizeof(S_PHS_RULE));
pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex] pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex]
.pstPhsRule = NULL; .pstPhsRule = NULL;
} }
OsalZeroMemory(&pstClassifierRulesTable memset(&pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex], 0, sizeof(S_CLASSIFIER_ENTRY));
->stOldPhsRulesList[nClsidIndex],
sizeof(S_CLASSIFIER_ENTRY));
} }
} }
pstServiceFlowEntry->bUsed = FALSE; pstServiceFlowEntry->bUsed = FALSE;
...@@ -849,7 +844,7 @@ ULONG PhsDeCompress(IN void* pvContext, ...@@ -849,7 +844,7 @@ ULONG PhsDeCompress(IN void* pvContext,
// Does not return any value. // 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; int i,j;
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
...@@ -876,8 +871,7 @@ void free_phs_serviceflow_rules(S_SERVICEFLOW_TABLE *psServiceFlowRulesTable) ...@@ -876,8 +871,7 @@ void free_phs_serviceflow_rules(S_SERVICEFLOW_TABLE *psServiceFlowRulesTable)
->u8RefCnt--; ->u8RefCnt--;
if(0==pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule if(0==pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule
->u8RefCnt) ->u8RefCnt)
OsalMemFree(pstClassifierRulesTable->stActivePhsRulesList[j]. kfree(pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule);
pstPhsRule, sizeof(S_PHS_RULE));
pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule = NULL; pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule = NULL;
} }
if(pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule) if(pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule)
...@@ -888,24 +882,23 @@ void free_phs_serviceflow_rules(S_SERVICEFLOW_TABLE *psServiceFlowRulesTable) ...@@ -888,24 +882,23 @@ void free_phs_serviceflow_rules(S_SERVICEFLOW_TABLE *psServiceFlowRulesTable)
->u8RefCnt--; ->u8RefCnt--;
if(0==pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule if(0==pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule
->u8RefCnt) ->u8RefCnt)
OsalMemFree(pstClassifierRulesTable->stOldPhsRulesList[j] kfree(pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule);
.pstPhsRule,sizeof(S_PHS_RULE));
pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule = NULL; pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule = NULL;
} }
} }
OsalMemFree(pstClassifierRulesTable,sizeof(S_CLASSIFIER_TABLE)); kfree(pstClassifierRulesTable);
stServiceFlowEntry.pstClassifierTable = pstClassifierRulesTable = NULL; stServiceFlowEntry.pstClassifierTable = pstClassifierRulesTable = NULL;
} }
} }
} }
OsalMemFree(psServiceFlowRulesTable,sizeof(S_SERVICEFLOW_TABLE)); kfree(psServiceFlowRulesTable);
psServiceFlowRulesTable = NULL; psServiceFlowRulesTable = NULL;
} }
BOOLEAN ValidatePHSRuleComplete(IN S_PHS_RULE *psPhsRule) static BOOLEAN ValidatePHSRuleComplete(IN S_PHS_RULE *psPhsRule)
{ {
if(psPhsRule) if(psPhsRule)
{ {
...@@ -988,9 +981,9 @@ UINT GetClassifierEntry(IN S_CLASSIFIER_TABLE *pstClassifierTable, ...@@ -988,9 +981,9 @@ UINT GetClassifierEntry(IN S_CLASSIFIER_TABLE *pstClassifierTable,
return PHS_INVALID_TABLE_INDEX; return PHS_INVALID_TABLE_INDEX;
} }
UINT GetPhsRuleEntry(IN S_CLASSIFIER_TABLE *pstClassifierTable, static UINT GetPhsRuleEntry(IN S_CLASSIFIER_TABLE *pstClassifierTable,
IN B_UINT32 uiPHSI,E_CLASSIFIER_ENTRY_CONTEXT eClsContext, IN B_UINT32 uiPHSI,E_CLASSIFIER_ENTRY_CONTEXT eClsContext,
OUT S_PHS_RULE **ppstPhsRule) OUT S_PHS_RULE **ppstPhsRule)
{ {
int i; int i;
S_CLASSIFIER_ENTRY *pstClassifierRule = NULL; S_CLASSIFIER_ENTRY *pstClassifierRule = NULL;
...@@ -1102,7 +1095,7 @@ UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid, ...@@ -1102,7 +1095,7 @@ UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid,
if(psPhsRule->u8PHSFLength) if(psPhsRule->u8PHSFLength)
{ {
//update PHSF //update PHSF
OsalMemMove(pstClassifierEntry->pstPhsRule->u8PHSF, memcpy(pstClassifierEntry->pstPhsRule->u8PHSF,
psPhsRule->u8PHSF , MAX_PHS_LENGTHS); psPhsRule->u8PHSF , MAX_PHS_LENGTHS);
} }
if(psPhsRule->u8PHSFLength) if(psPhsRule->u8PHSFLength)
...@@ -1114,7 +1107,7 @@ UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid, ...@@ -1114,7 +1107,7 @@ UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid,
if(psPhsRule->u8PHSMLength) if(psPhsRule->u8PHSMLength)
{ {
//update PHSM //update PHSM
OsalMemMove(pstClassifierEntry->pstPhsRule->u8PHSM, memcpy(pstClassifierEntry->pstPhsRule->u8PHSM,
psPhsRule->u8PHSM, MAX_PHS_LENGTHS); psPhsRule->u8PHSM, MAX_PHS_LENGTHS);
} }
if(psPhsRule->u8PHSMLength) if(psPhsRule->u8PHSMLength)
...@@ -1147,7 +1140,7 @@ UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid, ...@@ -1147,7 +1140,7 @@ UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid,
return uiStatus; return uiStatus;
} }
UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId, static UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId,
S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule, S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule,
E_CLASSIFIER_ENTRY_CONTEXT eClsContext,B_UINT8 u8AssociatedPHSI) E_CLASSIFIER_ENTRY_CONTEXT eClsContext,B_UINT8 u8AssociatedPHSI)
{ {
...@@ -1234,8 +1227,7 @@ UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId, ...@@ -1234,8 +1227,7 @@ UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId,
{ {
if(psClassifierRules->pstPhsRule == NULL) if(psClassifierRules->pstPhsRule == NULL)
{ {
psClassifierRules->pstPhsRule = (S_PHS_RULE*)OsalMemAlloc psClassifierRules->pstPhsRule = kmalloc(sizeof(S_PHS_RULE),GFP_KERNEL);
(sizeof(S_PHS_RULE),PHS_MEM_TAG);
if(NULL == psClassifierRules->pstPhsRule) if(NULL == psClassifierRules->pstPhsRule)
return ERR_PHSRULE_MEMALLOC_FAIL; return ERR_PHSRULE_MEMALLOC_FAIL;
...@@ -1247,7 +1239,7 @@ UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId, ...@@ -1247,7 +1239,7 @@ UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId,
psClassifierRules->bUnclassifiedPHSRule = psPhsRule->bUnclassifiedPHSRule; psClassifierRules->bUnclassifiedPHSRule = psPhsRule->bUnclassifiedPHSRule;
/* Update The PHS rule */ /* Update The PHS rule */
OsalMemMove(psClassifierRules->pstPhsRule, memcpy(psClassifierRules->pstPhsRule,
psPhsRule, sizeof(S_PHS_RULE)); psPhsRule, sizeof(S_PHS_RULE));
} }
else else
...@@ -1259,7 +1251,7 @@ UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId, ...@@ -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, IN S_CLASSIFIER_ENTRY *pstClassifierEntry,
S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule, S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule,
B_UINT8 u8AssociatedPHSI) B_UINT8 u8AssociatedPHSI)
...@@ -1289,13 +1281,13 @@ UINT UpdateClassifierPHSRule(IN B_UINT16 uiClsId, ...@@ -1289,13 +1281,13 @@ UINT UpdateClassifierPHSRule(IN B_UINT16 uiClsId,
//Step 2.a PHS Rule Does Not Exist .Create New PHS Rule for uiClsId //Step 2.a PHS Rule Does Not Exist .Create New PHS Rule for uiClsId
if(FALSE == bPHSRuleOrphaned) 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) if(NULL == pstClassifierEntry->pstPhsRule)
{ {
return ERR_PHSRULE_MEMALLOC_FAIL; return ERR_PHSRULE_MEMALLOC_FAIL;
} }
} }
OsalMemMove(pstClassifierEntry->pstPhsRule, psPhsRule, sizeof(S_PHS_RULE)); memcpy(pstClassifierEntry->pstPhsRule, psPhsRule, sizeof(S_PHS_RULE));
} }
else else
...@@ -1304,14 +1296,8 @@ UINT UpdateClassifierPHSRule(IN B_UINT16 uiClsId, ...@@ -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"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nTying Classifier to Existing PHS Rule");
if(bPHSRuleOrphaned) if(bPHSRuleOrphaned)
{ {
if(pstClassifierEntry->pstPhsRule) kfree(pstClassifierEntry->pstPhsRule);
{
//Just Free the PHS Rule as Ref Count is Zero
OsalMemFree(pstClassifierEntry->pstPhsRule,sizeof(S_PHS_RULE));
pstClassifierEntry->pstPhsRule = NULL; pstClassifierEntry->pstPhsRule = NULL;
}
} }
pstClassifierEntry->pstPhsRule = pstAddPhsRule; pstClassifierEntry->pstPhsRule = pstAddPhsRule;
...@@ -1326,7 +1312,7 @@ UINT UpdateClassifierPHSRule(IN B_UINT16 uiClsId, ...@@ -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) if(pstPhsRule==NULL)
return FALSE; return FALSE;
...@@ -1345,22 +1331,6 @@ BOOLEAN DerefPhsRule(IN B_UINT16 uiClsId,S_CLASSIFIER_TABLE *psaClassifiertable ...@@ -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) void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension)
{ {
int i,j,k,l; int i,j,k,l;
...@@ -1520,8 +1490,8 @@ int phs_decompress(unsigned char *in_buf,unsigned char *out_buf, ...@@ -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 // 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. // 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 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 *out_buf,UINT *header_size,UINT *new_header_size)
{ {
unsigned char *old_addr = out_buf; unsigned char *old_addr = out_buf;
int supress = 0; int supress = 0;
...@@ -1581,9 +1551,9 @@ int phs_compress(S_PHS_RULE *phs_rule,unsigned char *in_buf ...@@ -1581,9 +1551,9 @@ int phs_compress(S_PHS_RULE *phs_rule,unsigned char *in_buf
// 0 -Packet has failed the verification. // 0 -Packet has failed the verification.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
int verify_suppress_phsf(unsigned char *in_buffer,unsigned char *out_buffer, static int verify_suppress_phsf(unsigned char *in_buffer,unsigned char *out_buffer,
unsigned char *phsf,unsigned char *phsm,unsigned int phss, unsigned char *phsf,unsigned char *phsm,unsigned int phss,
unsigned int phsv,UINT* new_header_size) unsigned int phsv,UINT* new_header_size)
{ {
unsigned int size=0; unsigned int size=0;
int bit,i=0; int bit,i=0;
......
...@@ -27,19 +27,6 @@ void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension); ...@@ -27,19 +27,6 @@ void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension);
int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension,PMINI_ADAPTER Adapter); 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); int PhsCleanup(PPHS_DEVICE_EXTENSION pPHSDeviceExt);
//Utility Functions //Utility Functions
...@@ -52,42 +39,10 @@ ULONG PhsDeleteClassifierRule(void* pvContext, B_UINT16 uiVcid ,B_UINT16 uiClsI ...@@ -52,42 +39,10 @@ ULONG PhsDeleteClassifierRule(void* pvContext, B_UINT16 uiVcid ,B_UINT16 uiClsI
ULONG PhsDeleteSFRules(void* pvContext,B_UINT16 uiVcid) ; 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 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 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); void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension);
......
...@@ -85,10 +85,10 @@ typedef struct _ETH_CS_ETH2_FRAME ...@@ -85,10 +85,10 @@ typedef struct _ETH_CS_ETH2_FRAME
ETH_HEADER_STRUC EThHdr; ETH_HEADER_STRUC EThHdr;
} __attribute__((packed)) ETH_CS_ETH2_FRAME; } __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 //Per SF CS Specification Encodings
typedef enum _E_SERVICEFLOW_CS_SPEC_ typedef enum _E_SERVICEFLOW_CS_SPEC_
{ {
......
#ifndef _PROTOTYPES_H_ #ifndef _PROTOTYPES_H_
#define _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 LinkControlResponseMessage(PMINI_ADAPTER Adapter, PUCHAR pucBuffer);
VOID StatisticsResponse(PMINI_ADAPTER Adapter,PVOID pvBuffer); VOID StatisticsResponse(PMINI_ADAPTER Adapter,PVOID pvBuffer);
VOID IdleModeResponse(PMINI_ADAPTER Adapter,PUINT puiBuffer); 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); int control_packet_handler (PMINI_ADAPTER Adapter);
VOID DeleteAllClassifiersForSF(PMINI_ADAPTER Adapter,UINT uiSearchRuleIndex); VOID DeleteAllClassifiersForSF(PMINI_ADAPTER Adapter,UINT uiSearchRuleIndex);
...@@ -38,25 +27,16 @@ VOID SortClassifiers(PMINI_ADAPTER Adapter); ...@@ -38,25 +27,16 @@ VOID SortClassifiers(PMINI_ADAPTER Adapter);
VOID flush_all_queues(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); VOID PruneQueueAllSF(PMINI_ADAPTER Adapter);
INT SearchSfid(PMINI_ADAPTER Adapter,UINT uiSfid); INT SearchSfid(PMINI_ADAPTER Adapter,UINT uiSfid);
USHORT GetPacketQueueIndex(PMINI_ADAPTER Adapter, /**<Pointer to the driver control structure */ USHORT ClassifyPacket(PMINI_ADAPTER Adapter,struct sk_buff* skb);
struct sk_buff* Packet /**< Pointer to the Packet to be sent*/
); 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*/ INT SetupNextSend(PMINI_ADAPTER Adapter, /**<Logical Adapter*/
struct sk_buff *Packet, /**<data buffer*/ struct sk_buff *Packet, /**<data buffer*/
...@@ -70,11 +50,9 @@ INT SendControlPacket(PMINI_ADAPTER Adapter, /**<Logical Adapter*/ ...@@ -70,11 +50,9 @@ INT SendControlPacket(PMINI_ADAPTER Adapter, /**<Logical Adapter*/
char *pControlPacket/**<Control Packet*/ 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); int register_networkdev(PMINI_ADAPTER Adapter);
void unregister_networkdev(PMINI_ADAPTER Adapter);
INT AllocAdapterDsxBuffer(PMINI_ADAPTER Adapter); INT AllocAdapterDsxBuffer(PMINI_ADAPTER Adapter);
...@@ -82,8 +60,6 @@ VOID AdapterFree(PMINI_ADAPTER Adapter); ...@@ -82,8 +60,6 @@ VOID AdapterFree(PMINI_ADAPTER Adapter);
INT FreeAdapterDsxBuffer(PMINI_ADAPTER Adapter); INT FreeAdapterDsxBuffer(PMINI_ADAPTER Adapter);
int create_worker_threads(PMINI_ADAPTER psAdapter);
int tx_pkt_handler(PMINI_ADAPTER Adapter); int tx_pkt_handler(PMINI_ADAPTER Adapter);
int reset_card_proc(PMINI_ADAPTER Adapter ); int reset_card_proc(PMINI_ADAPTER Adapter );
...@@ -92,7 +68,6 @@ int run_card_proc(PMINI_ADAPTER Adapter ); ...@@ -92,7 +68,6 @@ int run_card_proc(PMINI_ADAPTER Adapter );
int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter); int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter);
int bcm_parse_target_params(PMINI_ADAPTER Adapter);
INT ReadMacAddressFromNVM(PMINI_ADAPTER Adapter); INT ReadMacAddressFromNVM(PMINI_ADAPTER Adapter);
...@@ -110,26 +85,15 @@ int rdmalt (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize); ...@@ -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); 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 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 beceem_parse_target_struct(PMINI_ADAPTER Adapter);
void doPowerAutoCorrection(PMINI_ADAPTER psAdapter);
int bcm_ioctl_fw_download(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwInfo); 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, void CopyMIBSExtendedSFParameters(PMINI_ADAPTER Adapter,
CServiceFlowParamSI *psfLocalSet, UINT uiSearchRuleIndex); CServiceFlowParamSI *psfLocalSet, UINT uiSearchRuleIndex);
...@@ -149,7 +113,6 @@ void update_per_sf_desc_cnts( PMINI_ADAPTER Adapter); ...@@ -149,7 +113,6 @@ void update_per_sf_desc_cnts( PMINI_ADAPTER Adapter);
void ClearTargetDSXBuffer(PMINI_ADAPTER Adapter,B_UINT16 TID,BOOLEAN bFreeAll); 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); void flush_queue(PMINI_ADAPTER Adapter, UINT iQIndex);
...@@ -164,31 +127,11 @@ INT BeceemEEPROMBulkRead( ...@@ -164,31 +127,11 @@ INT BeceemEEPROMBulkRead(
UINT uiNumBytes); 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); 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 PropagateCalParamsFromFlashToMemory(PMINI_ADAPTER Adapter);
INT PropagateCalParamsFromEEPROMToMemory(PMINI_ADAPTER Adapter);
INT BeceemEEPROMBulkWrite( INT BeceemEEPROMBulkWrite(
PMINI_ADAPTER Adapter, PMINI_ADAPTER Adapter,
...@@ -198,11 +141,8 @@ INT BeceemEEPROMBulkWrite( ...@@ -198,11 +141,8 @@ INT BeceemEEPROMBulkWrite(
BOOLEAN bVerify); BOOLEAN bVerify);
INT ReadBeceemEEPROMBulk(PMINI_ADAPTER Adapter,UINT dwAddress, UINT *pdwData, UINT dwNumData);
INT ReadBeceemEEPROM(PMINI_ADAPTER Adapter,UINT dwAddress, UINT *pdwData); INT ReadBeceemEEPROM(PMINI_ADAPTER Adapter,UINT dwAddress, UINT *pdwData);
NVM_TYPE BcmGetNvmType(PMINI_ADAPTER Adapter);
INT BeceemNVMRead( INT BeceemNVMRead(
PMINI_ADAPTER Adapter, PMINI_ADAPTER Adapter,
...@@ -217,24 +157,12 @@ INT BeceemNVMWrite( ...@@ -217,24 +157,12 @@ INT BeceemNVMWrite(
UINT uiNumBytes, UINT uiNumBytes,
BOOLEAN bVerify); BOOLEAN bVerify);
INT BcmUpdateSectorSize(PMINI_ADAPTER Adapter,UINT uiSectorSize);
INT BcmInitNVM(PMINI_ADAPTER Adapter); INT BcmInitNVM(PMINI_ADAPTER Adapter);
INT BcmGetNvmSize(PMINI_ADAPTER Adapter); INT BcmUpdateSectorSize(PMINI_ADAPTER Adapter,UINT uiSectorSize);
BOOLEAN IsSectionExistInFlash(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL section);
INT IsSectionExistInVendorInfo(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL section);
VOID BcmValidateNvmType(PMINI_ADAPTER Adapter);
VOID ConfigureEndPointTypesThroughEEPROM(PMINI_ADAPTER Adapter);
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 BcmGetFlash2xSectionalBitMap(PMINI_ADAPTER Adapter, PFLASH2X_BITMAP psFlash2xBitMap);
INT BcmFlash2xBulkWrite( INT BcmFlash2xBulkWrite(
...@@ -251,7 +179,6 @@ INT BcmFlash2xBulkRead( ...@@ -251,7 +179,6 @@ INT BcmFlash2xBulkRead(
FLASH2X_SECTION_VAL eFlashSectionVal, FLASH2X_SECTION_VAL eFlashSectionVal,
UINT uiOffsetWithinSectionVal, UINT uiOffsetWithinSectionVal,
UINT uiNumBytes); UINT uiNumBytes);
INT BcmGetSectionValEndOffset(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlashSectionVal);
INT BcmGetSectionValStartOffset(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 ...@@ -264,34 +191,13 @@ INT BcmFlash2xCorruptSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSect
INT BcmFlash2xWriteSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlashSectionVal); INT BcmFlash2xWriteSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlashSectionVal);
INT validateFlash2xReadWrite(PMINI_ADAPTER Adapter, PFLASH2X_READWRITE psFlash2xReadWrite); INT validateFlash2xReadWrite(PMINI_ADAPTER Adapter, PFLASH2X_READWRITE psFlash2xReadWrite);
INT IsFlash2x(PMINI_ADAPTER Adapter); INT IsFlash2x(PMINI_ADAPTER Adapter);
INT GetFlashBaseAddr(PMINI_ADAPTER Adapter);
INT SaveHeaderIfPresent(PMINI_ADAPTER Adapter, PUCHAR pBuff, UINT uiSectAlignAddr);
INT BcmCopySection(PMINI_ADAPTER Adapter, INT BcmCopySection(PMINI_ADAPTER Adapter,
FLASH2X_SECTION_VAL SrcSection, FLASH2X_SECTION_VAL SrcSection,
FLASH2X_SECTION_VAL DstSection, FLASH2X_SECTION_VAL DstSection,
UINT offset, UINT offset,
UINT numOfBytes); 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); BOOLEAN IsNonCDLessDevice(PMINI_ADAPTER Adapter);
...@@ -300,7 +206,6 @@ VOID OverrideServiceFlowParams(PMINI_ADAPTER Adapter,PUINT puiBuffer); ...@@ -300,7 +206,6 @@ VOID OverrideServiceFlowParams(PMINI_ADAPTER Adapter,PUINT puiBuffer);
int wrmaltWithLock (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize); 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 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 wrmWithLock(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t size);
INT buffDnldVerify(PMINI_ADAPTER Adapter, unsigned char *mappedbuffer, unsigned int u32FirmwareLength, INT buffDnldVerify(PMINI_ADAPTER Adapter, unsigned char *mappedbuffer, unsigned int u32FirmwareLength,
unsigned long u32StartingAddress); unsigned long u32StartingAddress);
...@@ -309,11 +214,6 @@ INT buffDnldVerify(PMINI_ADAPTER Adapter, unsigned char *mappedbuffer, unsigned ...@@ -309,11 +214,6 @@ INT buffDnldVerify(PMINI_ADAPTER Adapter, unsigned char *mappedbuffer, unsigned
VOID putUsbSuspend(struct work_struct *work); VOID putUsbSuspend(struct work_struct *work);
BOOLEAN IsReqGpioIsLedInNVM(PMINI_ADAPTER Adapter, UINT gpios); 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 #endif
......
...@@ -4,15 +4,14 @@ This file contains the routines related to Quality of Service. ...@@ -4,15 +4,14 @@ This file contains the routines related to Quality of Service.
*/ */
#include "headers.h" #include "headers.h"
BOOLEAN MatchSrcIpAddress(S_CLASSIFIER_RULE *pstClassifierRule,ULONG ulSrcIP); static void EThCSGetPktInfo(PMINI_ADAPTER Adapter,PVOID pvEthPayload,PS_ETHCS_PKT_INFO pstEthCsPktInfo);
BOOLEAN MatchTos(S_CLASSIFIER_RULE *pstClassifierRule,UCHAR ucTypeOfService); static BOOLEAN EThCSClassifyPkt(PMINI_ADAPTER Adapter,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo,S_CLASSIFIER_RULE *pstClassifierRule, B_UINT8 EthCSCupport);
BOOLEAN MatchSrcPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort);
BOOLEAN MatchDestPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushDestPort); static USHORT IpVersion4(PMINI_ADAPTER Adapter, struct iphdr *iphd,
BOOLEAN MatchProtocol(S_CLASSIFIER_RULE *pstClassifierRule,UCHAR ucProtocol); S_CLASSIFIER_RULE *pstClassifierRule );
BOOLEAN MatchDestIpAddress(S_CLASSIFIER_RULE *pstClassifierRule,ULONG ulDestIP);
USHORT ClassifyPacket(PMINI_ADAPTER Adapter,struct sk_buff* skb); static VOID PruneQueue(PMINI_ADAPTER Adapter, INT iIndex);
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);
/******************************************************************* /*******************************************************************
* Function - MatchSrcIpAddress() * Function - MatchSrcIpAddress()
...@@ -205,11 +204,10 @@ BOOLEAN MatchDestPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushDestPort) ...@@ -205,11 +204,10 @@ BOOLEAN MatchDestPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushDestPort)
Compares IPV4 Ip address and port number Compares IPV4 Ip address and port number
@return Queue Index. @return Queue Index.
*/ */
USHORT IpVersion4(PMINI_ADAPTER Adapter, /**< Pointer to the driver control structure */ static USHORT IpVersion4(PMINI_ADAPTER Adapter,
struct iphdr *iphd, /**<Pointer to the IP Hdr of the packet*/ struct iphdr *iphd,
S_CLASSIFIER_RULE *pstClassifierRule ) S_CLASSIFIER_RULE *pstClassifierRule )
{ {
//IPHeaderFormat *pIpHeader=NULL;
xporthdr *xprt_hdr=NULL; xporthdr *xprt_hdr=NULL;
BOOLEAN bClassificationSucceed=FALSE; BOOLEAN bClassificationSucceed=FALSE;
...@@ -261,15 +259,6 @@ USHORT IpVersion4(PMINI_ADAPTER Adapter, /**< Pointer to the driver control stru ...@@ -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 protocol is not TCP or UDP then no need of comparing source port and destination port
if(iphd->protocol!=TCP && iphd->protocol!=UDP) if(iphd->protocol!=TCP && iphd->protocol!=UDP)
break; 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 *****************// //******************Checking Transport Layer Header field if present *****************//
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Source Port %04x", 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); (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 ...@@ -312,29 +301,6 @@ USHORT IpVersion4(PMINI_ADAPTER Adapter, /**< Pointer to the driver control stru
return bClassificationSucceed; 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) VOID PruneQueueAllSF(PMINI_ADAPTER Adapter)
{ {
...@@ -357,23 +323,21 @@ is less than number of bytes in the queue. If so - ...@@ -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 drops packets from the Head till the number of bytes is
less than or equal to max queue size for the queue. less than or equal to max queue size for the queue.
*/ */
VOID PruneQueue(PMINI_ADAPTER Adapter,/**<Pointer to the driver control structure*/ static VOID PruneQueue(PMINI_ADAPTER Adapter, INT iIndex)
INT iIndex/**<Queue Index*/
)
{ {
struct sk_buff* PacketToDrop=NULL; 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); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "=====> Index %d",iIndex);
if(iIndex == HiPriority) if(iIndex == HiPriority)
return; return;
if(!Adapter || (iIndex < 0) || (iIndex > HiPriority)) if(!Adapter || (iIndex < 0) || (iIndex > HiPriority))
return; return;
/* To Store the netdevice statistic */ /* To Store the netdevice statistic */
netstats = &((PLINUX_DEP_DATA)Adapter->pvOsDepData)->netstats; netstats = &Adapter->dev->stats;
spin_lock_bh(&Adapter->PackInfo[iIndex].SFQueueLock); spin_lock_bh(&Adapter->PackInfo[iIndex].SFQueueLock);
...@@ -395,9 +359,13 @@ VOID PruneQueue(PMINI_ADAPTER Adapter,/**<Pointer to the driver control structur ...@@ -395,9 +359,13 @@ VOID PruneQueue(PMINI_ADAPTER Adapter,/**<Pointer to the driver control structur
if(PacketToDrop) if(PacketToDrop)
{ {
if(netstats) struct netdev_queue *txq = netdev_get_tx_queue(Adapter->dev, iIndex);
netstats->tx_dropped++; if (netif_msg_tx_err(Adapter))
atomic_inc(&Adapter->TxDroppedPacketCount); pr_info(PFX "%s: tx queue %d overlimit\n",
Adapter->dev->name, iIndex);
txq->tx_dropped++;
DEQUEUEPACKET(Adapter->PackInfo[iIndex].FirstTxQueue, DEQUEUEPACKET(Adapter->PackInfo[iIndex].FirstTxQueue,
Adapter->PackInfo[iIndex].LastTxQueue); Adapter->PackInfo[iIndex].LastTxQueue);
/// update current bytes and packets count /// update current bytes and packets count
...@@ -407,7 +375,7 @@ VOID PruneQueue(PMINI_ADAPTER Adapter,/**<Pointer to the driver control structur ...@@ -407,7 +375,7 @@ VOID PruneQueue(PMINI_ADAPTER Adapter,/**<Pointer to the driver control structur
/// update dropped bytes and packets counts /// update dropped bytes and packets counts
Adapter->PackInfo[iIndex].uiDroppedCountBytes += PacketToDrop->len; Adapter->PackInfo[iIndex].uiDroppedCountBytes += PacketToDrop->len;
Adapter->PackInfo[iIndex].uiDroppedCountPackets++; 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 ...@@ -416,7 +384,6 @@ VOID PruneQueue(PMINI_ADAPTER Adapter,/**<Pointer to the driver control structur
Adapter->PackInfo[iIndex].uiDroppedCountPackets); Adapter->PackInfo[iIndex].uiDroppedCountPackets);
atomic_dec(&Adapter->TotalPacketCount); atomic_dec(&Adapter->TotalPacketCount);
Adapter->bcm_jiffies = jiffies;
} }
spin_unlock_bh(&Adapter->PackInfo[iIndex].SFQueueLock); spin_unlock_bh(&Adapter->PackInfo[iIndex].SFQueueLock);
...@@ -430,16 +397,15 @@ VOID flush_all_queues(PMINI_ADAPTER Adapter) ...@@ -430,16 +397,15 @@ VOID flush_all_queues(PMINI_ADAPTER Adapter)
{ {
INT iQIndex; INT iQIndex;
UINT uiTotalPacketLength; UINT uiTotalPacketLength;
struct sk_buff* PacketToDrop=NULL; struct sk_buff* PacketToDrop=NULL;
struct net_device_stats* netstats=NULL;
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "=====>"); 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); // down(&Adapter->data_packet_queue_lock);
for(iQIndex=LowPriority; iQIndex<HiPriority; iQIndex++) for(iQIndex=LowPriority; iQIndex<HiPriority; iQIndex++)
{ {
struct netdev_queue *txq = netdev_get_tx_queue(Adapter->dev, iQIndex);
spin_lock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock); spin_lock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock);
while(Adapter->PackInfo[iQIndex].FirstTxQueue) while(Adapter->PackInfo[iQIndex].FirstTxQueue)
{ {
...@@ -447,8 +413,7 @@ VOID flush_all_queues(PMINI_ADAPTER Adapter) ...@@ -447,8 +413,7 @@ VOID flush_all_queues(PMINI_ADAPTER Adapter)
if(PacketToDrop) if(PacketToDrop)
{ {
uiTotalPacketLength = PacketToDrop->len; uiTotalPacketLength = PacketToDrop->len;
netstats->tx_dropped++; txq->tx_dropped++;
atomic_inc(&Adapter->TxDroppedPacketCount);
} }
else else
uiTotalPacketLength = 0; uiTotalPacketLength = 0;
...@@ -457,7 +422,7 @@ VOID flush_all_queues(PMINI_ADAPTER Adapter) ...@@ -457,7 +422,7 @@ VOID flush_all_queues(PMINI_ADAPTER Adapter)
Adapter->PackInfo[iQIndex].LastTxQueue); Adapter->PackInfo[iQIndex].LastTxQueue);
/* Free the skb */ /* Free the skb */
bcm_kfree_skb(PacketToDrop); dev_kfree_skb(PacketToDrop);
/// update current bytes and packets count /// update current bytes and packets count
Adapter->PackInfo[iQIndex].uiCurrentBytesOnHost -= uiTotalPacketLength; Adapter->PackInfo[iQIndex].uiCurrentBytesOnHost -= uiTotalPacketLength;
...@@ -559,12 +524,6 @@ USHORT ClassifyPacket(PMINI_ADAPTER Adapter,struct sk_buff* skb) ...@@ -559,12 +524,6 @@ USHORT ClassifyPacket(PMINI_ADAPTER Adapter,struct sk_buff* skb)
for(uiLoopIndex = MAX_CLASSIFIERS - 1; uiLoopIndex >= 0; uiLoopIndex--) for(uiLoopIndex = MAX_CLASSIFIERS - 1; uiLoopIndex >= 0; uiLoopIndex--)
{ {
if (Adapter->device_removed)
{
bClassificationSucceed = FALSE;
break;
}
if(bClassificationSucceed) if(bClassificationSucceed)
break; break;
//Iterate through all classifiers which are already in order of priority //Iterate through all classifiers which are already in order of priority
...@@ -810,7 +769,10 @@ static BOOLEAN EthCSMatchVLANRules(S_CLASSIFIER_RULE *pstClassifierRule,struct s ...@@ -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; BOOLEAN bClassificationSucceed = FALSE;
bClassificationSucceed = EthCSMatchSrcMACAddress(pstClassifierRule,((ETH_HEADER_STRUC *)(skb->data))->au8SourceAddress); 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_ ...@@ -840,9 +802,11 @@ BOOLEAN EThCSClassifyPkt(PMINI_ADAPTER Adapter,struct sk_buff* skb,PS_ETHCS_PKT_
return bClassificationSucceed; 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); 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); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCSGetPktInfo : Eth Hdr Type : %X\n",u16Etype);
if(u16Etype > 0x5dc) if(u16Etype > 0x5dc)
{ {
......
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: 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 - fix non-standard kernel style
- sparse warnings
- checkpatch warnings - checkpatch warnings
- remove compatiablity code for older kernels - use request firmware
- remove #ifdef's - fix use of file I/O to load config with better API
- fix bogus device nameing and reference counting (see bcm_notify_event) - merge some files together?
- fix use of file I/O to load config
- request firmware
- update to current network device API
- merge some files together
- cleanup/eliminate debug messages - cleanup/eliminate debug messages
- integrate with existing Wimax stack?
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
digraph transmit1 { digraph transmit1 {
node[shape=box] node[shape=box]
edge[weight=5;color=red] edge[weight=5;color=red]
bcm_transmit->reply_to_arp_request[label="ARP"]
bcm_transmit->GetPacketQueueIndex[label="IP Packet"] bcm_transmit->GetPacketQueueIndex[label="IP Packet"]
GetPacketQueueIndex->IpVersion4[label="IPV4"] GetPacketQueueIndex->IpVersion4[label="IPV4"]
GetPacketQueueIndex->IpVersion6[label="IPV6"] GetPacketQueueIndex->IpVersion6[label="IPV6"]
...@@ -35,169 +35,16 @@ SendPacketFromQueue->SetupNextSend->bcm_cmd53 ...@@ -35,169 +35,16 @@ SendPacketFromQueue->SetupNextSend->bcm_cmd53
#include "headers.h" #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 @ingroup ctrl_pkt_functions
This function dispatches control packet to the h/w interface This function dispatches control packet to the h/w interface
@return zero(success) or -ve value(failure) @return zero(success) or -ve value(failure)
*/ */
INT SendControlPacket(PMINI_ADAPTER Adapter, /**<Logical Adapter*/ INT SendControlPacket(PMINI_ADAPTER Adapter, char *pControlPacket)
char *pControlPacket/**<Control Packet*/
)
{ {
PLEADER PLeader = NULL; PLEADER PLeader = (PLEADER)pControlPacket;
struct timeval tv;
memset(&tv, 0, sizeof(tv));
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "========>");
PLeader=(PLEADER)pControlPacket;
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Tx"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Tx");
if(!pControlPacket || !Adapter) if(!pControlPacket || !Adapter)
{ {
...@@ -208,12 +55,6 @@ INT SendControlPacket(PMINI_ADAPTER Adapter, /**<Logical Adapter*/ ...@@ -208,12 +55,6 @@ INT SendControlPacket(PMINI_ADAPTER Adapter, /**<Logical Adapter*/
((PLeader->PLength-1)/MAX_DEVICE_DESC_SIZE)+1)) ((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"); 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; return STATUS_FAILURE;
} }
...@@ -224,76 +65,33 @@ INT SendControlPacket(PMINI_ADAPTER Adapter, /**<Logical Adapter*/ ...@@ -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); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Leader Length: %x",PLeader->PLength);
if(Adapter->device_removed) if(Adapter->device_removed)
return 0; 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 (netif_msg_pktdata(Adapter))
{ print_hex_dump(KERN_DEBUG, PFX "tx control: ", DUMP_PREFIX_NONE,
if(((CONTROL_MESSAGE*)PLeader)->szData[0] == GO_TO_IDLE_MODE_PAYLOAD && 16, 1, pControlPacket, PLeader->PLength + LEADER_SIZE, 0);
((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;
}
} Adapter->interface_transmit(Adapter->pvInterfaceAdapter,
#endif 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); atomic_dec(&Adapter->CurrNumFreeTxDesc);
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "<========="); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "<=========");
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
static LEADER Leader={0};
/** /**
@ingroup tx_functions @ingroup tx_functions
This function despatches the IP packets with the given vcid This function despatches the IP packets with the given vcid
to the target via the host h/w interface. to the target via the host h/w interface.
@return zero(success) or -ve value(failure) @return zero(success) or -ve value(failure)
*/ */
INT SetupNextSend(PMINI_ADAPTER Adapter, /**<Logical Adapter*/ INT SetupNextSend(PMINI_ADAPTER Adapter, struct sk_buff *Packet, USHORT Vcid)
struct sk_buff *Packet, /**<data buffer*/
USHORT Vcid) /**<VCID for this packet*/
{ {
int status=0; int status=0;
#ifdef GDMA_INTERFACE
int dontfree = 0;
#endif
BOOLEAN bHeaderSupressionEnabled = FALSE; BOOLEAN bHeaderSupressionEnabled = FALSE;
B_UINT16 uiClassifierRuleID; 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) if(Packet->len > MAX_DEVICE_DESC_SIZE)
{ {
status = STATUS_FAILURE; status = STATUS_FAILURE;
...@@ -302,14 +100,10 @@ INT SetupNextSend(PMINI_ADAPTER Adapter, /**<Logical Adapter*/ ...@@ -302,14 +100,10 @@ INT SetupNextSend(PMINI_ADAPTER Adapter, /**<Logical Adapter*/
/* Get the Classifier Rule ID */ /* Get the Classifier Rule ID */
uiClassifierRuleID = *((UINT32*) (Packet->cb)+SKB_CB_CLASSIFICATION_OFFSET); uiClassifierRuleID = *((UINT32*) (Packet->cb)+SKB_CB_CLASSIFICATION_OFFSET);
QueueIndex = SearchVcid( Adapter,Vcid);
if(QueueIndex < NO_OF_QUEUES) bHeaderSupressionEnabled = Adapter->PackInfo[QueueIndex].bHeaderSuppressionEnabled
{ & Adapter->bPHSEnabled;
bHeaderSupressionEnabled =
Adapter->PackInfo[QueueIndex].bHeaderSuppressionEnabled;
bHeaderSupressionEnabled =
bHeaderSupressionEnabled & Adapter->bPHSEnabled;
}
if(Adapter->device_removed) if(Adapter->device_removed)
{ {
status = STATUS_FAILURE; status = STATUS_FAILURE;
...@@ -327,15 +121,10 @@ INT SetupNextSend(PMINI_ADAPTER Adapter, /**<Logical Adapter*/ ...@@ -327,15 +121,10 @@ INT SetupNextSend(PMINI_ADAPTER Adapter, /**<Logical Adapter*/
Leader.Vcid = Vcid; Leader.Vcid = Vcid;
if(TCP_ACK == *((UINT32*) (Packet->cb) + SKB_CB_TCPACK_OFFSET )) 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");
Leader.Status = LEADER_STATUS_TCP_ACK; Leader.Status = LEADER_STATUS_TCP_ACK;
}
else else
{
Leader.Status = LEADER_STATUS; Leader.Status = LEADER_STATUS;
}
if(Adapter->PackInfo[QueueIndex].bEthCSSupport) if(Adapter->PackInfo[QueueIndex].bEthCSSupport)
{ {
...@@ -351,68 +140,53 @@ INT SetupNextSend(PMINI_ADAPTER Adapter, /**<Logical Adapter*/ ...@@ -351,68 +140,53 @@ INT SetupNextSend(PMINI_ADAPTER Adapter, /**<Logical Adapter*/
skb_push(Packet, LEADER_SIZE); skb_push(Packet, LEADER_SIZE);
memcpy(Packet->data, &Leader, LEADER_SIZE); memcpy(Packet->data, &Leader, LEADER_SIZE);
} }
else else
{ {
Leader.PLength = Packet->len - ETH_HLEN; Leader.PLength = Packet->len - ETH_HLEN;
memcpy((LEADER*)skb_pull(Packet, (ETH_HLEN - LEADER_SIZE)), &Leader, LEADER_SIZE); 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, status = Adapter->interface_transmit(Adapter->pvInterfaceAdapter,
Packet->data, (Leader.PLength + LEADER_SIZE)); Packet->data, (Leader.PLength + LEADER_SIZE));
#else
status = tx_pkts_to_firmware(Packet,Packet->len,0);
#endif
if(status) 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 else
{ {
struct netdev_queue *txq = netdev_get_tx_queue(Adapter->dev, QueueIndex);
Adapter->PackInfo[QueueIndex].uiTotalTxBytes += Leader.PLength; 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); txq->tx_bytes += Leader.PLength;
++txq->tx_packets;
errExit:
if(STATUS_SUCCESS == status)
{
Adapter->PackInfo[QueueIndex].uiCurrentTokenCount -= Leader.PLength << 3; Adapter->PackInfo[QueueIndex].uiCurrentTokenCount -= Leader.PLength << 3;
Adapter->PackInfo[QueueIndex].uiSentBytes += (Packet->len); Adapter->PackInfo[QueueIndex].uiSentBytes += (Packet->len);
Adapter->PackInfo[QueueIndex].uiSentPackets++; Adapter->PackInfo[QueueIndex].uiSentPackets++;
Adapter->PackInfo[QueueIndex].NumOfPacketsSent++; Adapter->PackInfo[QueueIndex].NumOfPacketsSent++;
atomic_dec(&Adapter->PackInfo[QueueIndex].uiPerSFTxResourceCount); 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; Adapter->PackInfo[QueueIndex].uiThisPeriodSentBytes += Leader.PLength;
} }
atomic_dec(&Adapter->CurrNumFreeTxDesc);
#ifdef GDMA_INTERFACE errExit:
if(!dontfree){
bcm_kfree_skb(Packet); dev_kfree_skb(Packet);
}
#else
bcm_kfree_skb(Packet);
#endif
return status; 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 @ingroup tx_functions
Transmit thread Transmit thread
...@@ -420,57 +194,26 @@ Transmit thread ...@@ -420,57 +194,26 @@ Transmit thread
int tx_pkt_handler(PMINI_ADAPTER Adapter /**< pointer to adapter object*/ int tx_pkt_handler(PMINI_ADAPTER Adapter /**< pointer to adapter object*/
) )
{ {
#ifndef BCM_SHM_INTERFACE
int status = 0; 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) while(! kthread_should_stop()) {
{ /* FIXME - the timeout looks like workaround for racey usage of TxPktAvail */
if(Adapter->LinkUpStatus){ if(Adapter->LinkUpStatus)
wait_event_timeout(Adapter->tx_packet_wait_queue, wait_event_timeout(Adapter->tx_packet_wait_queue,
((atomic_read(&Adapter->TxPktAvail) && tx_pending(Adapter), msecs_to_jiffies(10));
(MINIMUM_PENDING_DESCRIPTORS < else
atomic_read(&Adapter->CurrNumFreeTxDesc)) && wait_event_interruptible(Adapter->tx_packet_wait_queue,
(Adapter->device_removed == FALSE))) || tx_pending(Adapter));
(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;
}
#ifndef BCM_SHM_INTERFACE if (Adapter->device_removed)
break;
if(Adapter->downloadDDR == 1) if(Adapter->downloadDDR == 1)
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Downloading DDR Settings\n");
Adapter->downloadDDR +=1; Adapter->downloadDDR +=1;
status = download_ddr_settings(Adapter); status = download_ddr_settings(Adapter);
if(status) 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; continue;
} }
...@@ -489,7 +232,6 @@ int tx_pkt_handler(PMINI_ADAPTER Adapter /**< pointer to adapter object*/ ...@@ -489,7 +232,6 @@ int tx_pkt_handler(PMINI_ADAPTER Adapter /**< pointer to adapter object*/
update_per_sf_desc_cnts(Adapter); update_per_sf_desc_cnts(Adapter);
} }
} }
#endif
if( atomic_read(&Adapter->CurrNumFreeTxDesc) && if( atomic_read(&Adapter->CurrNumFreeTxDesc) &&
Adapter->LinkStatus == SYNC_UP_REQUEST && Adapter->LinkStatus == SYNC_UP_REQUEST &&
...@@ -507,49 +249,12 @@ int tx_pkt_handler(PMINI_ADAPTER Adapter /**< pointer to adapter object*/ ...@@ -507,49 +249,12 @@ int tx_pkt_handler(PMINI_ADAPTER Adapter /**< pointer to adapter object*/
wake_up(&Adapter->process_rx_cntrlpkt); wake_up(&Adapter->process_rx_cntrlpkt);
} }
#ifdef BCM_SHM_INTERFACE transmit_packets(Adapter);
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);
atomic_set(&Adapter->TxPktAvail, 0); 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 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Exiting the tx thread..\n");
*ptr = *ptr & 0xffff00ff; Adapter->transmit_packet_thread = NULL;
} return 0;
#endif
}
unsigned int total_tx_pkts_pending(void)
{
return atomic_read(&psAdaptertest->TotalPacketCount);
} }
#endif
...@@ -2,19 +2,6 @@ ...@@ -2,19 +2,6 @@
#define CNTRL_SIGNALING_INTERFACE_ #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 #define DSA_REQ 11
...@@ -28,7 +15,6 @@ extern B_UINT32 g_u32Corr2MacFlags; ...@@ -28,7 +15,6 @@ extern B_UINT32 g_u32Corr2MacFlags;
#define DSD_ACK 19 #define DSD_ACK 19
#define MAX_CLASSIFIERS_IN_SF 4 #define MAX_CLASSIFIERS_IN_SF 4
#endif
#define MAX_STRING_LEN 20 #define MAX_STRING_LEN 20
#define MAX_PHS_LENGTHS 255 #define MAX_PHS_LENGTHS 255
...@@ -57,37 +43,7 @@ extern B_UINT32 g_u32Corr2MacFlags; ...@@ -57,37 +43,7 @@ extern B_UINT32 g_u32Corr2MacFlags;
////////////////////////structure Definitions/////////////////////////////////// ////////////////////////structure Definitions///////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// \brief class cCPacketClassificationRule /// \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{ struct _stCPacketClassificationRuleSI{
#endif
/** 16bit UserPriority Of The Service Flow*/ /** 16bit UserPriority Of The Service Flow*/
B_UINT16 u16UserPriority; B_UINT16 u16UserPriority;
...@@ -145,29 +101,10 @@ struct _stCPacketClassificationRuleSI{ ...@@ -145,29 +101,10 @@ struct _stCPacketClassificationRuleSI{
B_UINT8 u8ClassifierActionRule; B_UINT8 u8ClassifierActionRule;
B_UINT16 u16ValidityBitMap; B_UINT16 u16ValidityBitMap;
}; };
#ifndef BECEEM_TARGET
typedef struct _stCPacketClassificationRuleSI CCPacketClassificationRuleSI,stCPacketClassificationRuleSI, *pstCPacketClassificationRuleSI; typedef struct _stCPacketClassificationRuleSI CCPacketClassificationRuleSI,stCPacketClassificationRuleSI, *pstCPacketClassificationRuleSI;
#endif
/// \brief class CPhsRuleSI /// \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 { typedef struct _stPhsRuleSI {
#endif
/** 8bit PHS Index Of The Service Flow*/ /** 8bit PHS Index Of The Service Flow*/
B_UINT8 u8PHSI; B_UINT8 u8PHSI;
/** PHSF Length Of The Service Flow*/ /** PHSF Length Of The Service Flow*/
...@@ -188,31 +125,11 @@ typedef struct _stPhsRuleSI { ...@@ -188,31 +125,11 @@ typedef struct _stPhsRuleSI {
B_UINT8 u8VendorSpecificPHSParams[VENDOR_PHS_PARAM_LENGTH]; B_UINT8 u8VendorSpecificPHSParams[VENDOR_PHS_PARAM_LENGTH];
B_UINT8 u8Padding[2]; B_UINT8 u8Padding[2];
#ifdef BECEEM_TARGET
};
#else
}stPhsRuleSI,*pstPhsRuleSI; }stPhsRuleSI,*pstPhsRuleSI;
typedef stPhsRuleSI CPhsRuleSI; typedef stPhsRuleSI CPhsRuleSI;
#endif
/// \brief structure cConvergenceSLTypes /// \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{ struct _stConvergenceSLTypes{
#endif
/** 8bit Phs Classfier Action Of The Service Flow*/ /** 8bit Phs Classfier Action Of The Service Flow*/
B_UINT8 u8ClassfierDSCAction; B_UINT8 u8ClassfierDSCAction;
/** 8bit Phs DSC Action Of The Service Flow*/ /** 8bit Phs DSC Action Of The Service Flow*/
...@@ -220,111 +137,15 @@ struct _stConvergenceSLTypes{ ...@@ -220,111 +137,15 @@ struct _stConvergenceSLTypes{
/** 16bit Padding */ /** 16bit Padding */
B_UINT8 u8Padding[2]; B_UINT8 u8Padding[2];
/// \brief class cCPacketClassificationRule /// \brief class cCPacketClassificationRule
#ifdef BECEEM_TARGET
CCPacketClassificationRuleSI cCPacketClassificationRule;
#else
stCPacketClassificationRuleSI cCPacketClassificationRule; stCPacketClassificationRuleSI cCPacketClassificationRule;
#endif
/// \brief class CPhsRuleSI /// \brief class CPhsRuleSI
#ifdef BECEEM_TARGET
CPhsRuleSI cPhsRule;
#else
struct _stPhsRuleSI cPhsRule; struct _stPhsRuleSI cPhsRule;
#endif
}; };
#ifndef BECEEM_TARGET
typedef struct _stConvergenceSLTypes stConvergenceSLTypes,CConvergenceSLTypes, *pstConvergenceSLTypes; typedef struct _stConvergenceSLTypes stConvergenceSLTypes,CConvergenceSLTypes, *pstConvergenceSLTypes;
#endif
/// \brief structure CServiceFlowParamSI /// \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{ typedef struct _stServiceFlowParamSI{
#endif //end of ifdef BECEEM_TARGET
/** 32bitSFID Of The Service Flow*/ /** 32bitSFID Of The Service Flow*/
B_UINT32 u32SFID; B_UINT32 u32SFID;
...@@ -367,11 +188,6 @@ typedef struct _stServiceFlowParamSI{ ...@@ -367,11 +188,6 @@ typedef struct _stServiceFlowParamSI{
/** 16bit ARQ Purge timeout */ /** 16bit ARQ Purge timeout */
B_UINT16 u16ARQRxPurgeTimeOut; 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 //TODO::Remove this once we move to a new CORR2 driver
/// \brief Size of an ARQ block /// \brief Size of an ARQ block
B_UINT16 u16ARQBlockSize; B_UINT16 u16ARQBlockSize;
...@@ -496,35 +312,18 @@ typedef struct _stServiceFlowParamSI{ ...@@ -496,35 +312,18 @@ typedef struct _stServiceFlowParamSI{
B_UINT8 bValid; /**< Validity flag */ B_UINT8 bValid; /**< Validity flag */
B_UINT8 u8Padding; /**< Padding byte*/ 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 Structure for Convergence SubLayer Types with a maximum of 4 classifiers
*/ */
stConvergenceSLTypes cConvergenceSLTypes[MAX_CLASSIFIERS_IN_SF]; stConvergenceSLTypes cConvergenceSLTypes[MAX_CLASSIFIERS_IN_SF];
#endif
#ifdef BECEEM_TARGET
};
#else
} stServiceFlowParamSI, *pstServiceFlowParamSI; } stServiceFlowParamSI, *pstServiceFlowParamSI;
typedef stServiceFlowParamSI CServiceFlowParamSI; typedef stServiceFlowParamSI CServiceFlowParamSI;
#endif
/** /**
structure stLocalSFAddRequest structure stLocalSFAddRequest
*/ */
typedef struct _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 u8Type; /**< Type*/
B_UINT8 eConnectionDir; /**< Connection direction*/ B_UINT8 eConnectionDir; /**< Connection direction*/
...@@ -535,19 +334,9 @@ typedef struct _stLocalSFAddRequest{ ...@@ -535,19 +334,9 @@ typedef struct _stLocalSFAddRequest{
/// \brief 16bitVCID /// \brief 16bitVCID
B_UINT16 u16VCID; /**< 16bit VCID*/ B_UINT16 u16VCID; /**< 16bit VCID*/
/// \brief structure ParameterSet /// \brief structure ParameterSet
#ifdef BECEEM_SIGNALLING_INTERFACE_API
CServiceFlowParamSI sfParameterSet;
#endif
#ifdef BECEEM_TARGET
CServiceFlowParamSI *psfParameterSet;
#else
stServiceFlowParamSI *psfParameterSet; /**< structure ParameterSet*/ stServiceFlowParamSI *psfParameterSet; /**< structure ParameterSet*/
#endif
#ifdef USING_VXWORKS
USE_DATA_MEMORY_MANAGER();
#endif
}stLocalSFAddRequest, *pstLocalSFAddRequest; }stLocalSFAddRequest, *pstLocalSFAddRequest;
...@@ -555,12 +344,6 @@ typedef struct _stLocalSFAddRequest{ ...@@ -555,12 +344,6 @@ typedef struct _stLocalSFAddRequest{
structure stLocalSFAddIndication structure stLocalSFAddIndication
*/ */
typedef struct _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 u8Type; /**< Type*/
B_UINT8 eConnectionDir; /**< Connection Direction*/ B_UINT8 eConnectionDir; /**< Connection Direction*/
...@@ -571,37 +354,19 @@ typedef struct _stLocalSFAddIndication{ ...@@ -571,37 +354,19 @@ typedef struct _stLocalSFAddIndication{
/// \brief 16bitVCID /// \brief 16bitVCID
B_UINT16 u16VCID; /**< 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 /// \brief structure AuthorizedSet
#ifdef BECEEM_TARGET
CServiceFlowParamSI *psfAuthorizedSet;
/// \brief structure AdmittedSet
CServiceFlowParamSI *psfAdmittedSet;
/// \brief structure ActiveSet
CServiceFlowParamSI *psfActiveSet;
#else
/// \brief structure AuthorizedSet /// \brief structure AuthorizedSet
stServiceFlowParamSI *psfAuthorizedSet; /**< AuthorizedSet of type stServiceFlowParamSI*/ stServiceFlowParamSI *psfAuthorizedSet; /**< AuthorizedSet of type stServiceFlowParamSI*/
/// \brief structure AdmittedSet /// \brief structure AdmittedSet
stServiceFlowParamSI *psfAdmittedSet; /**< AdmittedSet of type stServiceFlowParamSI*/ stServiceFlowParamSI *psfAdmittedSet; /**< AdmittedSet of type stServiceFlowParamSI*/
/// \brief structure ActiveSet /// \brief structure ActiveSet
stServiceFlowParamSI *psfActiveSet; /**< sfActiveSet of type stServiceFlowParamSI*/ stServiceFlowParamSI *psfActiveSet; /**< sfActiveSet of type stServiceFlowParamSI*/
#endif
B_UINT8 u8CC; /**< Confirmation Code*/ B_UINT8 u8CC; /**< Confirmation Code*/
B_UINT8 u8Padd; /**< 8-bit Padding */ B_UINT8 u8Padd; /**< 8-bit Padding */
B_UINT16 u16Padd; /**< 16 bit Padding */ B_UINT16 u16Padd; /**< 16 bit Padding */
#ifdef USING_VXWORKS
USE_DATA_MEMORY_MANAGER();
#endif
}stLocalSFAddIndication; }stLocalSFAddIndication;
...@@ -619,33 +384,17 @@ typedef struct _stLocalSFAddIndication stLocalSFChangeIndication, *pstLocalSFCha ...@@ -619,33 +384,17 @@ typedef struct _stLocalSFAddIndication stLocalSFChangeIndication, *pstLocalSFCha
structure stLocalSFDeleteRequest structure stLocalSFDeleteRequest
*/ */
typedef struct _stLocalSFDeleteRequest{ typedef struct _stLocalSFDeleteRequest{
#ifdef BECEEM_TARGET
_stLocalSFDeleteRequest( ) :
u8Type(0x00), u8Padding(0x00),
u16TID(0x0000), u32SFID (0x00000000)
{}
#endif
B_UINT8 u8Type; /**< Type*/ B_UINT8 u8Type; /**< Type*/
B_UINT8 u8Padding; /**< Padding byte*/ B_UINT8 u8Padding; /**< Padding byte*/
B_UINT16 u16TID; /**< TID*/ B_UINT16 u16TID; /**< TID*/
/// \brief 32bitSFID /// \brief 32bitSFID
B_UINT32 u32SFID; /**< SFID*/ B_UINT32 u32SFID; /**< SFID*/
#ifdef USING_VXWORKS
USE_DATA_MEMORY_MANAGER();
#endif
}stLocalSFDeleteRequest, *pstLocalSFDeleteRequest; }stLocalSFDeleteRequest, *pstLocalSFDeleteRequest;
/** /**
structure stLocalSFDeleteIndication structure stLocalSFDeleteIndication
*/ */
typedef struct 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 u8Type; /**< Type */
B_UINT8 u8Padding; /**< Padding */ B_UINT8 u8Padding; /**< Padding */
B_UINT16 u16TID; /**< TID */ B_UINT16 u16TID; /**< TID */
...@@ -658,9 +407,6 @@ typedef struct stLocalSFDeleteIndication{ ...@@ -658,9 +407,6 @@ typedef struct stLocalSFDeleteIndication{
/// \brief 8bit Confirmation code /// \brief 8bit Confirmation code
B_UINT8 u8ConfirmationCode; /**< Confirmation code */ B_UINT8 u8ConfirmationCode; /**< Confirmation code */
B_UINT8 u8Padding1[3]; /**< 3 byte Padding */ B_UINT8 u8Padding1[3]; /**< 3 byte Padding */
#ifdef USING_VXWORKS
USE_DATA_MEMORY_MANAGER();
#endif
}stLocalSFDeleteIndication; }stLocalSFDeleteIndication;
typedef struct _stIM_SFHostNotify typedef struct _stIM_SFHostNotify
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <net/ip.h> #include <net/ip.h>
#include <linux/wait.h> #include <linux/wait.h>
#include <linux/notifier.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
...@@ -41,21 +40,7 @@ ...@@ -41,21 +40,7 @@
#endif #endif
#include <linux/tcp.h> #include <linux/tcp.h>
#include <linux/udp.h> #include <linux/udp.h>
#ifndef BCM_SHM_INTERFACE
#include <linux/usb.h> #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 "Typedefs.h"
#include "Version.h" #include "Version.h"
...@@ -71,39 +56,28 @@ extern B_UINT32 g_u32Corr2MacFlags; ...@@ -71,39 +56,28 @@ extern B_UINT32 g_u32Corr2MacFlags;
#include "CmHost.h" #include "CmHost.h"
#include "DDRInit.h" #include "DDRInit.h"
#include "Debug.h" #include "Debug.h"
#include "HostMibs.h"
#include "IPv6ProtocolHdr.h" #include "IPv6ProtocolHdr.h"
#include "osal_misc.h"
#include "PHSModule.h" #include "PHSModule.h"
#include "Protocol.h" #include "Protocol.h"
#include "Prototypes.h" #include "Prototypes.h"
#include "Queue.h" #include "Queue.h"
#include "vendorspecificextn.h" #include "vendorspecificextn.h"
#ifndef BCM_SHM_INTERFACE
#include "InterfaceMacros.h" #include "InterfaceMacros.h"
#include "InterfaceAdapter.h" #include "InterfaceAdapter.h"
#include "InterfaceIsr.h" #include "InterfaceIsr.h"
#include "Interfacemain.h"
#include "InterfaceMisc.h" #include "InterfaceMisc.h"
#include "InterfaceRx.h" #include "InterfaceRx.h"
#include "InterfaceTx.h" #include "InterfaceTx.h"
#endif
#include "InterfaceIdleMode.h" #include "InterfaceIdleMode.h"
#include "InterfaceInit.h" #include "InterfaceInit.h"
#ifdef BCM_SHM_INTERFACE #define DRV_NAME "beceem"
#include <linux/cpe_config.h> #define DEV_NAME "tarang"
#define DRV_DESCRIPTION "Beceem Communications Inc. WiMAX driver"
#ifdef GDMA_INTERFACE #define DRV_COPYRIGHT "Copyright 2010. Beceem Communications Inc"
#include "GdmaInterface.h" #define DRV_VERSION VER_FILEVERSION_STR
#include "symphony.h" #define PFX DRV_NAME " "
#else
#include "virtual_interface.h"
#endif
#endif
#endif #endif
...@@ -10,12 +10,8 @@ ...@@ -10,12 +10,8 @@
*/ */
#include "headers.h" #include "headers.h"
INT ProcessGetHostMibs(PMINI_ADAPTER Adapter, INT ProcessGetHostMibs(PMINI_ADAPTER Adapter, S_MIBS_HOST_STATS_MIBS *pstHostMibs)
PVOID ioBuffer,
ULONG inputBufferLength)
{ {
S_MIBS_HOST_STATS_MIBS *pstHostMibs = NULL;
S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL; S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
S_PHS_RULE *pstPhsRule = NULL; S_PHS_RULE *pstPhsRule = NULL;
S_CLASSIFIER_TABLE *pstClassifierTable = NULL; S_CLASSIFIER_TABLE *pstClassifierTable = NULL;
...@@ -30,15 +26,6 @@ INT ProcessGetHostMibs(PMINI_ADAPTER Adapter, ...@@ -30,15 +26,6 @@ INT ProcessGetHostMibs(PMINI_ADAPTER Adapter,
return STATUS_FAILURE; 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 //Copy the classifier Table
for(nClassifierIndex=0; nClassifierIndex < MAX_CLASSIFIERS; for(nClassifierIndex=0; nClassifierIndex < MAX_CLASSIFIERS;
nClassifierIndex++) nClassifierIndex++)
...@@ -54,7 +41,7 @@ INT ProcessGetHostMibs(PMINI_ADAPTER Adapter, ...@@ -54,7 +41,7 @@ INT ProcessGetHostMibs(PMINI_ADAPTER Adapter,
{ {
if(Adapter->PackInfo[nSfIndex].bValid) 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 else
{ {
...@@ -83,7 +70,7 @@ INT ProcessGetHostMibs(PMINI_ADAPTER Adapter, ...@@ -83,7 +70,7 @@ INT ProcessGetHostMibs(PMINI_ADAPTER Adapter,
pstHostMibs->astPhsRulesTable[nPhsTableIndex].ulSFID = Adapter->PackInfo[nSfIndex].ulSFID; pstHostMibs->astPhsRulesTable[nPhsTableIndex].ulSFID = Adapter->PackInfo[nSfIndex].ulSFID;
OsalMemMove(&pstHostMibs->astPhsRulesTable[nPhsTableIndex].u8PHSI, memcpy(&pstHostMibs->astPhsRulesTable[nPhsTableIndex].u8PHSI,
&pstPhsRule->u8PHSI, &pstPhsRule->u8PHSI,
sizeof(S_PHS_RULE)); sizeof(S_PHS_RULE));
nPhsTableIndex++; nPhsTableIndex++;
...@@ -95,12 +82,9 @@ INT ProcessGetHostMibs(PMINI_ADAPTER Adapter, ...@@ -95,12 +82,9 @@ INT ProcessGetHostMibs(PMINI_ADAPTER Adapter,
} }
//copy other Host Statistics parameters //copy other Host Statistics parameters
pstHostMibs->stHostInfo.GoodTransmits = pstHostMibs->stHostInfo.GoodTransmits = Adapter->dev->stats.tx_packets;
atomic_read(&Adapter->TxTotalPacketCount); pstHostMibs->stHostInfo.GoodReceives = Adapter->dev->stats.rx_packets;
pstHostMibs->stHostInfo.GoodReceives =
atomic_read(&Adapter->GoodRxPktCount);
pstHostMibs->stHostInfo.CurrNumFreeDesc = pstHostMibs->stHostInfo.CurrNumFreeDesc =
atomic_read(&Adapter->CurrNumFreeTxDesc); atomic_read(&Adapter->CurrNumFreeTxDesc);
pstHostMibs->stHostInfo.BEBucketSize = Adapter->BEBucketSize; pstHostMibs->stHostInfo.BEBucketSize = Adapter->BEBucketSize;
...@@ -115,13 +99,10 @@ INT ProcessGetHostMibs(PMINI_ADAPTER Adapter, ...@@ -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(&(pstHostMibs->stDroppedAppCntrlMsgs),
&(pTarang->stDroppedAppCntrlMsgs),sizeof(S_MIBS_DROPPED_APP_CNTRL_MESSAGES));
memcpy((PVOID)&(pstHostMibs->stDroppedAppCntrlMsgs),(PVOID)&(pTarang->stDroppedAppCntrlMsgs),sizeof(S_MIBS_DROPPED_APP_CNTRL_MESSAGES));
return STATUS_SUCCESS ;
} }
......
...@@ -108,52 +108,16 @@ static INT LED_Proportional_Blink(PMINI_ADAPTER Adapter, UCHAR GPIO_Num_tx, ...@@ -108,52 +108,16 @@ static INT LED_Proportional_Blink(PMINI_ADAPTER Adapter, UCHAR GPIO_Num_tx,
ulong timeout = 0; ulong timeout = 0;
/*Read initial value of packets sent/received */ /*Read initial value of packets sent/received */
Initial_num_of_packts_tx = atomic_read(&Adapter->TxTotalPacketCount); Initial_num_of_packts_tx = Adapter->dev->stats.tx_packets;
Initial_num_of_packts_rx = atomic_read(&Adapter->GoodRxPktCount); Initial_num_of_packts_rx = Adapter->dev->stats.rx_packets;
/*Scale the rate of transfer to no of blinks.*/ /*Scale the rate of transfer to no of blinks.*/
num_of_time_tx= ScaleRateofTransfer((ULONG)rate_of_transfer_tx); num_of_time_tx= ScaleRateofTransfer((ULONG)rate_of_transfer_tx);
num_of_time_rx= ScaleRateofTransfer((ULONG)rate_of_transfer_rx); num_of_time_rx= ScaleRateofTransfer((ULONG)rate_of_transfer_rx);
while((Adapter->device_removed == FALSE)) 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; 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*/ /*Blink Tx and Rx LED when both Tx and Rx is in normal bandwidth*/
if(bBlinkBothLED) if(bBlinkBothLED)
{ {
...@@ -249,9 +213,10 @@ static INT LED_Proportional_Blink(PMINI_ADAPTER Adapter, UCHAR GPIO_Num_tx, ...@@ -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 * Read the Tx & Rx packets transmission after 1 second and
* calculate rate of transfer * 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; 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; rate_of_transfer_rx = Final_num_of_packts_rx - Initial_num_of_packts_rx;
/*Read initial value of packets sent/received */ /*Read initial value of packets sent/received */
...@@ -293,7 +258,7 @@ static INT ValidateDSDParamsChecksum( ...@@ -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); 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) if(!puBuffer)
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"LED Thread: ValidateDSDParamsChecksum Allocation failed"); 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( ...@@ -341,10 +306,7 @@ static INT ValidateDSDParamsChecksum(
} }
exit: exit:
if(puBuffer) kfree(puBuffer);
{
OsalMemFree(puBuffer, usParamLen);
}
return Status; return Status;
} }
...@@ -497,12 +459,10 @@ static int ReadConfigFileStructure(PMINI_ADAPTER Adapter, BOOLEAN *bEnableThread ...@@ -497,12 +459,10 @@ static int ReadConfigFileStructure(PMINI_ADAPTER Adapter, BOOLEAN *bEnableThread
{ {
int Status = STATUS_SUCCESS; int Status = STATUS_SUCCESS;
UCHAR GPIO_Array[NUM_OF_LEDS+1]; /*Array to store GPIO numbers from EEPROM*/ UCHAR GPIO_Array[NUM_OF_LEDS+1]; /*Array to store GPIO numbers from EEPROM*/
#ifndef BCM_SHM_INTERFACE
UINT uiIndex = 0; UINT uiIndex = 0;
UINT uiNum_of_LED_Type = 0; UINT uiNum_of_LED_Type = 0;
PUCHAR puCFGData = NULL; PUCHAR puCFGData = NULL;
UCHAR bData = 0; UCHAR bData = 0;
#endif
memset(GPIO_Array, DISABLE_GPIO_NUM, NUM_OF_LEDS+1); memset(GPIO_Array, DISABLE_GPIO_NUM, NUM_OF_LEDS+1);
if(!Adapter->pstargetparams || IS_ERR(Adapter->pstargetparams)) if(!Adapter->pstargetparams || IS_ERR(Adapter->pstargetparams))
...@@ -524,10 +484,6 @@ static int ReadConfigFileStructure(PMINI_ADAPTER Adapter, BOOLEAN *bEnableThread ...@@ -524,10 +484,6 @@ static int ReadConfigFileStructure(PMINI_ADAPTER Adapter, BOOLEAN *bEnableThread
*bEnableThread = FALSE; *bEnableThread = FALSE;
return Status; return Status;
} }
#ifdef BCM_SHM_INTERFACE
*bEnableThread = FALSE;
return Status ;
#else
/* /*
* CONFIG file read successfully. Deallocate the memory of * CONFIG file read successfully. Deallocate the memory of
* uiFileNameBufferSize * uiFileNameBufferSize
...@@ -578,23 +534,7 @@ static int ReadConfigFileStructure(PMINI_ADAPTER Adapter, BOOLEAN *bEnableThread ...@@ -578,23 +534,7 @@ static int ReadConfigFileStructure(PMINI_ADAPTER Adapter, BOOLEAN *bEnableThread
} }
if(uiNum_of_LED_Type >= NUM_OF_LEDS) if(uiNum_of_LED_Type >= NUM_OF_LEDS)
*bEnableThread = FALSE; *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; return Status;
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
...@@ -721,20 +661,6 @@ static VOID LEDControlThread(PMINI_ADAPTER Adapter) ...@@ -721,20 +661,6 @@ static VOID LEDControlThread(PMINI_ADAPTER Adapter)
TURN_OFF_LED(1<<GPIO_num, uiLedIndex); TURN_OFF_LED(1<<GPIO_num, uiLedIndex);
return ;//STATUS_FAILURE; 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) if(GPIO_num != DISABLE_GPIO_NUM)
{ {
...@@ -752,10 +678,6 @@ static VOID LEDControlThread(PMINI_ADAPTER Adapter) ...@@ -752,10 +678,6 @@ static VOID LEDControlThread(PMINI_ADAPTER Adapter)
case DRIVER_INIT: case DRIVER_INIT:
{ {
currdriverstate = DRIVER_INIT;//Adapter->DriverState; currdriverstate = DRIVER_INIT;//Adapter->DriverState;
#if 0
LedGpioInit(Adapter);
Adapter->LEDInfo.bLedInitDone = TRUE;
#endif
BcmGetGPIOPinInfo(Adapter, &GPIO_num, &dummyGPIONum, &uiLedIndex, &dummyIndex, currdriverstate); BcmGetGPIOPinInfo(Adapter, &GPIO_num, &dummyGPIONum, &uiLedIndex, &dummyIndex, currdriverstate);
if(GPIO_num != DISABLE_GPIO_NUM) if(GPIO_num != DISABLE_GPIO_NUM)
...@@ -768,13 +690,6 @@ static VOID LEDControlThread(PMINI_ADAPTER Adapter) ...@@ -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"); //BCM_DEBUG_PRINT (Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"LED Thread: FW_DN_DONE called\n");
currdriverstate = FW_DOWNLOAD; 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); BcmGetGPIOPinInfo(Adapter, &GPIO_num, &dummyGPIONum, &uiLedIndex, &dummyIndex, currdriverstate);
if(GPIO_num != DISABLE_GPIO_NUM) if(GPIO_num != DISABLE_GPIO_NUM)
...@@ -796,12 +711,6 @@ static VOID LEDControlThread(PMINI_ADAPTER Adapter) ...@@ -796,12 +711,6 @@ static VOID LEDControlThread(PMINI_ADAPTER Adapter)
break; break;
case SHUTDOWN_EXIT: 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. //no break, continue to NO_NETWORK_ENTRY state as well.
case NO_NETWORK_ENTRY: case NO_NETWORK_ENTRY:
...@@ -875,34 +784,6 @@ static VOID LEDControlThread(PMINI_ADAPTER Adapter) ...@@ -875,34 +784,6 @@ static VOID LEDControlThread(PMINI_ADAPTER Adapter)
break; break;
case IDLEMODE_EXIT: 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; break;
case DRIVER_HALT: case DRIVER_HALT:
......
#include "headers.h" #include "headers.h"
#define DWORD unsigned int #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 // Procedure: ReadEEPROMStatusRegister
// //
// Description: Reads the standard EEPROM Status Register. // Description: Reads the standard EEPROM Status Register.
...@@ -228,213 +278,27 @@ INT ReadBeceemEEPROM( PMINI_ADAPTER Adapter, ...@@ -228,213 +278,27 @@ INT ReadBeceemEEPROM( PMINI_ADAPTER Adapter,
ReadBeceemEEPROMBulk(Adapter, uiTempOffset + MAX_RW_SIZE, (PUINT)&uiData[4], 4); 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; return STATUS_SUCCESS;
} /* ReadBeceemEEPROM() */ } /* 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 ReadMacAddressFromNVM(PMINI_ADAPTER Adapter)
{ {
INT Status=0, i; INT Status;
unsigned char puMacAddr[6] = {0}; unsigned char puMacAddr[6];
INT AllZeroMac = 0;
INT AllFFMac = 0;
Status = BeceemNVMRead(Adapter, Status = BeceemNVMRead(Adapter,
(PUINT)&puMacAddr[0], (PUINT)&puMacAddr[0],
INIT_PARAMS_1_MACADDRESS_ADDRESS, INIT_PARAMS_1_MACADDRESS_ADDRESS,
MAC_ADDRESS_SIZE); MAC_ADDRESS_SIZE);
if(Status != STATUS_SUCCESS) if(Status == STATUS_SUCCESS)
{ memcpy(Adapter->dev->dev_addr, puMacAddr, MAC_ADDRESS_SIZE);
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");
return Status; return Status;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -476,7 +340,7 @@ INT BeceemEEPROMBulkRead( ...@@ -476,7 +340,7 @@ INT BeceemEEPROMBulkRead(
ReadBeceemEEPROMBulk(Adapter,uiTempOffset,(PUINT)&uiData[0],4); ReadBeceemEEPROMBulk(Adapter,uiTempOffset,(PUINT)&uiData[0],4);
if(uiBytesRemaining >= (MAX_RW_SIZE - uiExtraBytes)) 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); uiBytesRemaining -= (MAX_RW_SIZE - uiExtraBytes);
uiIndex += (MAX_RW_SIZE - uiExtraBytes); uiIndex += (MAX_RW_SIZE - uiExtraBytes);
...@@ -484,7 +348,7 @@ INT BeceemEEPROMBulkRead( ...@@ -484,7 +348,7 @@ INT BeceemEEPROMBulkRead(
} }
else else
{ {
OsalMemMove(pBuffer,(((PUCHAR)&uiData[0])+uiExtraBytes),uiBytesRemaining); memcpy(pBuffer,(((PUCHAR)&uiData[0])+uiExtraBytes),uiBytesRemaining);
uiIndex += uiBytesRemaining; uiIndex += uiBytesRemaining;
uiOffset += uiBytesRemaining; uiOffset += uiBytesRemaining;
uiBytesRemaining = 0; uiBytesRemaining = 0;
...@@ -508,7 +372,7 @@ INT BeceemEEPROMBulkRead( ...@@ -508,7 +372,7 @@ INT BeceemEEPROMBulkRead(
* We read 4 Dwords of data */ * We read 4 Dwords of data */
if(0 == ReadBeceemEEPROMBulk(Adapter,uiOffset,&uiData[0],4)) 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; uiOffset += MAX_RW_SIZE;
uiBytesRemaining -= MAX_RW_SIZE; uiBytesRemaining -= MAX_RW_SIZE;
uiIndex += MAX_RW_SIZE; uiIndex += MAX_RW_SIZE;
...@@ -523,7 +387,7 @@ INT BeceemEEPROMBulkRead( ...@@ -523,7 +387,7 @@ INT BeceemEEPROMBulkRead(
{ {
if(0 == ReadBeceemEEPROM(Adapter,uiOffset,&uiData[0])) if(0 == ReadBeceemEEPROM(Adapter,uiOffset,&uiData[0]))
{ {
OsalMemMove(pcBuff+uiIndex,&uiData[0],4); memcpy(pcBuff+uiIndex,&uiData[0],4);
uiOffset += 4; uiOffset += 4;
uiBytesRemaining -= 4; uiBytesRemaining -= 4;
uiIndex +=4; uiIndex +=4;
...@@ -540,7 +404,7 @@ INT BeceemEEPROMBulkRead( ...@@ -540,7 +404,7 @@ INT BeceemEEPROMBulkRead(
pCharBuff += uiIndex; pCharBuff += uiIndex;
if(0 == ReadBeceemEEPROM(Adapter,uiOffset,&uiData[0])) 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; uiBytesRemaining = 0;
} }
else else
...@@ -571,7 +435,7 @@ INT BeceemEEPROMBulkRead( ...@@ -571,7 +435,7 @@ INT BeceemEEPROMBulkRead(
// <FAILURE> - if failed. // <FAILURE> - if failed.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
INT BeceemFlashBulkRead( static INT BeceemFlashBulkRead(
PMINI_ADAPTER Adapter, PMINI_ADAPTER Adapter,
PUINT pBuffer, PUINT pBuffer,
UINT uiOffset, UINT uiOffset,
...@@ -653,16 +517,8 @@ INT BeceemFlashBulkRead( ...@@ -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)) if(IsFlash2x(Adapter))
return (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER)); return (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER));
else else
...@@ -684,7 +540,7 @@ UINT BcmGetFlashSize(PMINI_ADAPTER Adapter) ...@@ -684,7 +540,7 @@ UINT BcmGetFlashSize(PMINI_ADAPTER Adapter)
// //
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
UINT BcmGetEEPROMSize(PMINI_ADAPTER Adapter) static UINT BcmGetEEPROMSize(PMINI_ADAPTER Adapter)
{ {
UINT uiData = 0; UINT uiData = 0;
UINT uiIndex = 0; UINT uiIndex = 0;
...@@ -733,60 +589,6 @@ UINT BcmGetEEPROMSize(PMINI_ADAPTER Adapter) ...@@ -733,60 +589,6 @@ UINT BcmGetEEPROMSize(PMINI_ADAPTER Adapter)
return 0; 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 // Procedure: FlashSectorErase
...@@ -973,7 +775,7 @@ static INT flashWrite( ...@@ -973,7 +775,7 @@ static INT flashWrite(
// need not write 0xFFFFFFFF because write requires an erase and erase will // need not write 0xFFFFFFFF because write requires an erase and erase will
// make whole sector 0xFFFFFFFF. // make whole sector 0xFFFFFFFF.
// //
if (!OsalMemCompare(pData, uiErasePattern, MAX_RW_SIZE)) if (!memcmp(pData, uiErasePattern, MAX_RW_SIZE))
{ {
return 0; return 0;
} }
...@@ -1138,7 +940,7 @@ static INT flashWriteStatus( ...@@ -1138,7 +940,7 @@ static INT flashWriteStatus(
// need not write 0xFFFFFFFF because write requires an erase and erase will // need not write 0xFFFFFFFF because write requires an erase and erase will
// make whole sector 0xFFFFFFFF. // make whole sector 0xFFFFFFFF.
// //
if (!OsalMemCompare(pData,uiErasePattern,MAX_RW_SIZE)) if (!memcmp(pData,uiErasePattern,MAX_RW_SIZE))
{ {
return 0; return 0;
} }
...@@ -1332,7 +1134,7 @@ static ULONG BcmFlashUnProtectBlock(PMINI_ADAPTER Adapter,UINT uiOffset, UINT ui ...@@ -1332,7 +1134,7 @@ static ULONG BcmFlashUnProtectBlock(PMINI_ADAPTER Adapter,UINT uiOffset, UINT ui
// //
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
INT BeceemFlashBulkWrite( static INT BeceemFlashBulkWrite(
PMINI_ADAPTER Adapter, PMINI_ADAPTER Adapter,
PUINT pBuffer, PUINT pBuffer,
UINT uiOffset, UINT uiOffset,
...@@ -1353,15 +1155,6 @@ INT BeceemFlashBulkWrite( ...@@ -1353,15 +1155,6 @@ INT BeceemFlashBulkWrite(
UINT uiTemp = 0; UINT uiTemp = 0;
UINT index = 0; UINT index = 0;
UINT uiPartOffset = 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) #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); Status = bcmflash_raw_write((uiOffset/FLASH_PART_SIZE),(uiOffset % FLASH_PART_SIZE),( unsigned char *)pBuffer,uiNumBytes);
...@@ -1377,12 +1170,9 @@ INT BeceemFlashBulkWrite( ...@@ -1377,12 +1170,9 @@ INT BeceemFlashBulkWrite(
uiCurrSectOffsetAddr = uiOffset & (Adapter->uiSectorSize - 1); uiCurrSectOffsetAddr = uiOffset & (Adapter->uiSectorSize - 1);
uiSectBoundary = uiSectAlignAddr + Adapter->uiSectorSize; uiSectBoundary = uiSectAlignAddr + Adapter->uiSectorSize;
//pTempBuff = OsalMemAlloc(MAX_SECTOR_SIZE,'!MVN'); pTempBuff = kmalloc(Adapter->uiSectorSize, GFP_KERNEL);
pTempBuff = OsalMemAlloc(Adapter->uiSectorSize ,"!MVN");
if(NULL == pTempBuff) if(NULL == pTempBuff)
{
goto BeceemFlashBulkWrite_EXIT; goto BeceemFlashBulkWrite_EXIT;
}
// //
// check if the data to be written is overlapped accross sectors // check if the data to be written is overlapped accross sectors
// //
...@@ -1399,7 +1189,6 @@ INT BeceemFlashBulkWrite( ...@@ -1399,7 +1189,6 @@ INT BeceemFlashBulkWrite(
uiNumSectTobeRead++; uiNumSectTobeRead++;
} }
} }
#if 1
//Check whether Requested sector is writable or not in case of flash2x write. But if write call is //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 // for DSD calibration, allow it without checking of sector permission
...@@ -1420,7 +1209,6 @@ INT BeceemFlashBulkWrite( ...@@ -1420,7 +1209,6 @@ INT BeceemFlashBulkWrite(
index = index + 1 ; index = index + 1 ;
} }
} }
#endif
Adapter->SelectedChip = RESET_CHIP_SELECT; Adapter->SelectedChip = RESET_CHIP_SELECT;
while(uiNumSectTobeRead) while(uiNumSectTobeRead)
{ {
...@@ -1448,13 +1236,13 @@ INT BeceemFlashBulkWrite( ...@@ -1448,13 +1236,13 @@ INT BeceemFlashBulkWrite(
if(uiNumSectTobeRead > 1) if(uiNumSectTobeRead > 1)
{ {
OsalMemMove(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr)); memcpy(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr));
pcBuffer += ((uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr))); pcBuffer += ((uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr)));
uiNumBytes -= (uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr)); uiNumBytes -= (uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr));
} }
else else
{ {
OsalMemMove(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiNumBytes); memcpy(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiNumBytes);
} }
if(IsFlash2x(Adapter)) if(IsFlash2x(Adapter))
...@@ -1503,7 +1291,7 @@ INT BeceemFlashBulkWrite( ...@@ -1503,7 +1291,7 @@ INT BeceemFlashBulkWrite(
} }
else 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])) if(STATUS_SUCCESS != (*Adapter->fpFlashWriteWithStatusCheck)(Adapter,uiPartOffset+uiIndex,&pTempBuff[uiIndex]))
{ {
...@@ -1541,10 +1329,8 @@ INT BeceemFlashBulkWrite( ...@@ -1541,10 +1329,8 @@ INT BeceemFlashBulkWrite(
{ {
BcmRestoreBlockProtectStatus(Adapter,ulStatus); BcmRestoreBlockProtectStatus(Adapter,ulStatus);
} }
if(pTempBuff)
{ kfree(pTempBuff);
OsalMemFree(pTempBuff,Adapter->uiSectorSize);
}
Adapter->SelectedChip = RESET_CHIP_SELECT; Adapter->SelectedChip = RESET_CHIP_SELECT;
return Status; return Status;
...@@ -1599,14 +1385,10 @@ static INT BeceemFlashBulkWriteStatus( ...@@ -1599,14 +1385,10 @@ static INT BeceemFlashBulkWriteStatus(
uiCurrSectOffsetAddr = uiOffset & (Adapter->uiSectorSize - 1); uiCurrSectOffsetAddr = uiOffset & (Adapter->uiSectorSize - 1);
uiSectBoundary = uiSectAlignAddr + Adapter->uiSectorSize; uiSectBoundary = uiSectAlignAddr + Adapter->uiSectorSize;
pTempBuff = kmalloc(Adapter->uiSectorSize, GFP_KERNEL);
// pTempBuff = OsalMemAlloc(MAX_SECTOR_SIZE,'!MVN');
pTempBuff = OsalMemAlloc(Adapter->uiSectorSize,"!MVN");
if(NULL == pTempBuff) if(NULL == pTempBuff)
{
goto BeceemFlashBulkWriteStatus_EXIT; goto BeceemFlashBulkWriteStatus_EXIT;
}
// //
// check if the data to be written is overlapped accross sectors // check if the data to be written is overlapped accross sectors
// //
...@@ -1662,13 +1444,13 @@ static INT BeceemFlashBulkWriteStatus( ...@@ -1662,13 +1444,13 @@ static INT BeceemFlashBulkWriteStatus(
if(uiNumSectTobeRead > 1) if(uiNumSectTobeRead > 1)
{ {
OsalMemMove(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr)); memcpy(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr));
pcBuffer += ((uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr))); pcBuffer += ((uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr)));
uiNumBytes -= (uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr)); uiNumBytes -= (uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr));
} }
else else
{ {
OsalMemMove(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiNumBytes); memcpy(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiNumBytes);
} }
if(IsFlash2x(Adapter)) if(IsFlash2x(Adapter))
...@@ -1698,25 +1480,10 @@ static INT BeceemFlashBulkWriteStatus( ...@@ -1698,25 +1480,10 @@ static INT BeceemFlashBulkWriteStatus(
{ {
for(uiIndex = 0;uiIndex < Adapter->uiSectorSize;uiIndex += MAX_RW_SIZE) 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(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; Status = STATUS_FAILURE;
goto BeceemFlashBulkWriteStatus_EXIT; goto BeceemFlashBulkWriteStatus_EXIT;
...@@ -1747,10 +1514,8 @@ static INT BeceemFlashBulkWriteStatus( ...@@ -1747,10 +1514,8 @@ static INT BeceemFlashBulkWriteStatus(
{ {
BcmRestoreBlockProtectStatus(Adapter,ulStatus); BcmRestoreBlockProtectStatus(Adapter,ulStatus);
} }
if(pTempBuff)
{ kfree(pTempBuff);
OsalMemFree(pTempBuff,Adapter->uiSectorSize);
}
Adapter->SelectedChip = RESET_CHIP_SELECT; Adapter->SelectedChip = RESET_CHIP_SELECT;
return Status; return Status;
...@@ -1771,7 +1536,7 @@ static INT BeceemFlashBulkWriteStatus( ...@@ -1771,7 +1536,7 @@ static INT BeceemFlashBulkWriteStatus(
INT PropagateCalParamsFromEEPROMToMemory(PMINI_ADAPTER Adapter) INT PropagateCalParamsFromEEPROMToMemory(PMINI_ADAPTER Adapter)
{ {
PCHAR pBuff = OsalMemAlloc(BUFFER_4K,"3MVN"); PCHAR pBuff = kmalloc(BUFFER_4K, GFP_KERNEL);
UINT uiEepromSize = 0; UINT uiEepromSize = 0;
UINT uiIndex = 0; UINT uiIndex = 0;
UINT uiBytesToCopy = 0; UINT uiBytesToCopy = 0;
...@@ -1787,14 +1552,14 @@ INT PropagateCalParamsFromEEPROMToMemory(PMINI_ADAPTER Adapter) ...@@ -1787,14 +1552,14 @@ INT PropagateCalParamsFromEEPROMToMemory(PMINI_ADAPTER Adapter)
if(0 != BeceemEEPROMBulkRead(Adapter,&uiEepromSize,EEPROM_SIZE_OFFSET,4)) if(0 != BeceemEEPROMBulkRead(Adapter,&uiEepromSize,EEPROM_SIZE_OFFSET,4))
{ {
OsalMemFree(pBuff,BUFFER_4K); kfree(pBuff);
return -1; return -1;
} }
uiEepromSize >>= 16; uiEepromSize >>= 16;
if(uiEepromSize > 1024*1024) if(uiEepromSize > 1024*1024)
{ {
OsalMemFree(pBuff,BUFFER_4K); kfree(pBuff);
return -1; return -1;
} }
...@@ -1820,7 +1585,7 @@ INT PropagateCalParamsFromEEPROMToMemory(PMINI_ADAPTER Adapter) ...@@ -1820,7 +1585,7 @@ INT PropagateCalParamsFromEEPROMToMemory(PMINI_ADAPTER Adapter)
wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC-4,&value, sizeof(value)); wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC-4,&value, sizeof(value));
value = 0xbeadbead; value = 0xbeadbead;
wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC-8,&value, sizeof(value)); wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC-8,&value, sizeof(value));
OsalMemFree(pBuff,MAX_RW_SIZE); kfree(pBuff);
return Status; return Status;
...@@ -1873,16 +1638,13 @@ INT PropagateCalParamsFromFlashToMemory(PMINI_ADAPTER Adapter) ...@@ -1873,16 +1638,13 @@ INT PropagateCalParamsFromFlashToMemory(PMINI_ADAPTER Adapter)
return -1; return -1;
} }
pBuff = OsalMemAlloc(uiEepromSize, 0); pBuff = kmalloc(uiEepromSize, GFP_KERNEL);
if ( pBuff == NULL ) if ( pBuff == NULL )
{
return -1; return -1;
}
if(0 != BeceemNVMRead(Adapter,(PUINT)pBuff,uiCalStartAddr, uiEepromSize)) if(0 != BeceemNVMRead(Adapter,(PUINT)pBuff,uiCalStartAddr, uiEepromSize))
{ {
OsalMemFree(pBuff, 0); kfree(pBuff);
return -1; return -1;
} }
...@@ -1905,7 +1667,7 @@ INT PropagateCalParamsFromFlashToMemory(PMINI_ADAPTER Adapter) ...@@ -1905,7 +1667,7 @@ INT PropagateCalParamsFromFlashToMemory(PMINI_ADAPTER Adapter)
uiBytesToCopy = MIN(BUFFER_4K,uiEepromSize); uiBytesToCopy = MIN(BUFFER_4K,uiEepromSize);
} }
OsalMemFree(pBuff, 0); kfree(pBuff);
return Status; return Status;
} }
...@@ -1947,14 +1709,14 @@ static INT BeceemEEPROMReadBackandVerify( ...@@ -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. {// 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); 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 // re-write
BeceemEEPROMBulkWrite(Adapter,(PUCHAR)(pBuffer+uiIndex),uiOffset,MAX_RW_SIZE,FALSE); BeceemEEPROMBulkWrite(Adapter,(PUCHAR)(pBuffer+uiIndex),uiOffset,MAX_RW_SIZE,FALSE);
mdelay(3); mdelay(3);
BeceemEEPROMBulkRead(Adapter,&auiData[0],uiOffset,MAX_RW_SIZE); 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; return -1;
} }
...@@ -1986,7 +1748,7 @@ static INT BeceemEEPROMReadBackandVerify( ...@@ -1986,7 +1748,7 @@ static INT BeceemEEPROMReadBackandVerify(
else else
{ // Handle the reads less than 4 bytes... { // Handle the reads less than 4 bytes...
uiData = 0; uiData = 0;
OsalMemMove(&uiData,((PUCHAR)pBuffer)+(uiIndex*sizeof(UINT)),uiNumBytes); memcpy(&uiData,((PUCHAR)pBuffer)+(uiIndex*sizeof(UINT)),uiNumBytes);
BeceemEEPROMBulkRead(Adapter,&uiRdbk,uiOffset,4); BeceemEEPROMBulkRead(Adapter,&uiRdbk,uiOffset,4);
if(memcmp(&uiData, &uiRdbk, uiNumBytes)) if(memcmp(&uiData, &uiRdbk, uiNumBytes))
...@@ -2186,7 +1948,7 @@ INT BeceemEEPROMBulkWrite( ...@@ -2186,7 +1948,7 @@ INT BeceemEEPROMBulkWrite(
if(uiBytesToCopy >= (16 -uiExtraBytes)) 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 ) ) if ( STATUS_FAILURE == BeceemEEPROMWritePage( Adapter, uiData, uiTempOffset ) )
return STATUS_FAILURE; return STATUS_FAILURE;
...@@ -2197,7 +1959,7 @@ INT BeceemEEPROMBulkWrite( ...@@ -2197,7 +1959,7 @@ INT BeceemEEPROMBulkWrite(
} }
else else
{ {
OsalMemMove((((PUCHAR)&uiData[0])+uiExtraBytes),pBuffer,uiBytesToCopy); memcpy((((PUCHAR)&uiData[0])+uiExtraBytes),pBuffer,uiBytesToCopy);
if ( STATUS_FAILURE == BeceemEEPROMWritePage( Adapter, uiData, uiTempOffset ) ) if ( STATUS_FAILURE == BeceemEEPROMWritePage( Adapter, uiData, uiTempOffset ) )
return STATUS_FAILURE; return STATUS_FAILURE;
...@@ -2233,7 +1995,7 @@ INT BeceemEEPROMBulkWrite( ...@@ -2233,7 +1995,7 @@ INT BeceemEEPROMBulkWrite(
// To program non 16byte aligned data, read 16byte and then update. // To program non 16byte aligned data, read 16byte and then update.
// //
BeceemEEPROMBulkRead(Adapter,&uiData[0],uiOffset,16); 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 ) ) if ( STATUS_FAILURE == BeceemEEPROMWritePage( Adapter, uiData, uiOffset ) )
...@@ -2535,7 +2297,7 @@ INT BcmUpdateSectorSize(PMINI_ADAPTER Adapter,UINT uiSectorSize) ...@@ -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 uiSectorSize = 0;
UINT uiSectorSig = 0; UINT uiSectorSig = 0;
...@@ -2642,20 +2404,8 @@ static INT BcmInitEEPROMQueues(PMINI_ADAPTER Adapter) ...@@ -2642,20 +2404,8 @@ static INT BcmInitEEPROMQueues(PMINI_ADAPTER Adapter)
INT BcmInitNVM(PMINI_ADAPTER ps_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); BcmValidateNvmType(ps_adapter);
BcmInitEEPROMQueues(ps_adapter); BcmInitEEPROMQueues(ps_adapter);
#endif
if(ps_adapter->eNVMType == NVM_AUTODETECT) if(ps_adapter->eNVMType == NVM_AUTODETECT)
{ {
...@@ -2684,7 +2434,7 @@ INT BcmInitNVM(PMINI_ADAPTER ps_adapter) ...@@ -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) if(Adapter->eNVMType == NVM_EEPROM)
{ {
...@@ -2708,7 +2458,7 @@ INT BcmGetNvmSize(PMINI_ADAPTER Adapter) ...@@ -2708,7 +2458,7 @@ INT BcmGetNvmSize(PMINI_ADAPTER Adapter)
// Returns: // Returns:
// <VOID> // <VOID>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
VOID BcmValidateNvmType(PMINI_ADAPTER Adapter) static VOID BcmValidateNvmType(PMINI_ADAPTER Adapter)
{ {
// //
...@@ -2775,7 +2525,7 @@ INT BcmAllocFlashCSStructure(PMINI_ADAPTER psAdapter) ...@@ -2775,7 +2525,7 @@ INT BcmAllocFlashCSStructure(PMINI_ADAPTER psAdapter)
if(psAdapter->psFlash2xCSInfo == NULL) if(psAdapter->psFlash2xCSInfo == NULL)
{ {
BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0,"Can't Allocate memory for Flash 2.x"); 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; return -ENOMEM;
} }
...@@ -2783,8 +2533,8 @@ INT BcmAllocFlashCSStructure(PMINI_ADAPTER psAdapter) ...@@ -2783,8 +2533,8 @@ INT BcmAllocFlashCSStructure(PMINI_ADAPTER psAdapter)
if(psAdapter->psFlash2xVendorInfo == NULL) if(psAdapter->psFlash2xVendorInfo == NULL)
{ {
BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0,"Can't Allocate Vendor Info Memory for Flash 2.x"); BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0,"Can't Allocate Vendor Info Memory for Flash 2.x");
bcm_kfree(psAdapter->psFlashCSInfo); kfree(psAdapter->psFlashCSInfo);
bcm_kfree(psAdapter->psFlash2xCSInfo); kfree(psAdapter->psFlash2xCSInfo);
return -ENOMEM; return -ENOMEM;
} }
...@@ -2798,9 +2548,9 @@ INT BcmDeAllocFlashCSStructure(PMINI_ADAPTER psAdapter) ...@@ -2798,9 +2548,9 @@ INT BcmDeAllocFlashCSStructure(PMINI_ADAPTER psAdapter)
BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0," Adapter structure point is NULL"); BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0," Adapter structure point is NULL");
return -EINVAL; return -EINVAL;
} }
bcm_kfree(psAdapter->psFlashCSInfo); kfree(psAdapter->psFlashCSInfo);
bcm_kfree(psAdapter->psFlash2xCSInfo); kfree(psAdapter->psFlash2xCSInfo);
bcm_kfree(psAdapter->psFlash2xVendorInfo); kfree(psAdapter->psFlash2xVendorInfo);
return STATUS_SUCCESS ; return STATUS_SUCCESS ;
} }
...@@ -2954,7 +2704,7 @@ static INT ConvertEndianOfCSStructure(PFLASH_CS_INFO psFlashCSInfo) ...@@ -2954,7 +2704,7 @@ static INT ConvertEndianOfCSStructure(PFLASH_CS_INFO psFlashCSInfo)
return STATUS_SUCCESS; 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 && return ( Adapter->uiVendorExtnFlag &&
(Adapter->psFlash2xVendorInfo->VendorSection[section].AccessFlags & FLASH2X_SECTION_PRESENT) && (Adapter->psFlash2xVendorInfo->VendorSection[section].AccessFlags & FLASH2X_SECTION_PRESENT) &&
...@@ -3052,7 +2802,7 @@ static VOID UpdateVendorInfo(PMINI_ADAPTER Adapter) ...@@ -3052,7 +2802,7 @@ static VOID UpdateVendorInfo(PMINI_ADAPTER Adapter)
// <VOID> // <VOID>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter) static INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter)
{ {
//FLASH_CS_INFO sFlashCsInfo = {0}; //FLASH_CS_INFO sFlashCsInfo = {0};
...@@ -3070,7 +2820,6 @@ INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter) ...@@ -3070,7 +2820,6 @@ INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter)
memset(Adapter->psFlashCSInfo, 0 ,sizeof(FLASH_CS_INFO)); memset(Adapter->psFlashCSInfo, 0 ,sizeof(FLASH_CS_INFO));
memset(Adapter->psFlash2xCSInfo, 0 ,sizeof(FLASH2X_CS_INFO)); memset(Adapter->psFlash2xCSInfo, 0 ,sizeof(FLASH2X_CS_INFO));
#ifndef BCM_SHM_INTERFACE
if(!Adapter->bDDRInitDone) if(!Adapter->bDDRInitDone)
{ {
{ {
...@@ -3079,7 +2828,6 @@ INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter) ...@@ -3079,7 +2828,6 @@ INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter)
} }
} }
#endif
// Reading first 8 Bytes to get the Flash Layout // Reading first 8 Bytes to get the Flash Layout
// MagicNumber(4 bytes) +FlashLayoutMinorVersion(2 Bytes) +FlashLayoutMajorVersion(2 Bytes) // MagicNumber(4 bytes) +FlashLayoutMinorVersion(2 Bytes) +FlashLayoutMajorVersion(2 Bytes)
...@@ -3147,9 +2895,7 @@ INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter) ...@@ -3147,9 +2895,7 @@ INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter)
return STATUS_FAILURE; return STATUS_FAILURE;
} }
ConvertEndianOf2XCSStructure(Adapter->psFlash2xCSInfo); ConvertEndianOf2XCSStructure(Adapter->psFlash2xCSInfo);
#ifndef BCM_SHM_INTERFACE
BcmDumpFlash2XCSStructure(Adapter->psFlash2xCSInfo,Adapter); BcmDumpFlash2XCSStructure(Adapter->psFlash2xCSInfo,Adapter);
#endif
if((FLASH_CONTROL_STRUCT_SIGNATURE == Adapter->psFlash2xCSInfo->MagicNumber) && if((FLASH_CONTROL_STRUCT_SIGNATURE == Adapter->psFlash2xCSInfo->MagicNumber) &&
(SCSI_FIRMWARE_MINOR_VERSION <= MINOR_VERSION(Adapter->psFlash2xCSInfo->SCSIFirmwareVersion)) && (SCSI_FIRMWARE_MINOR_VERSION <= MINOR_VERSION(Adapter->psFlash2xCSInfo->SCSIFirmwareVersion)) &&
(FLASH_SECTOR_SIZE_SIG == Adapter->psFlash2xCSInfo->FlashSectorSizeSig) && (FLASH_SECTOR_SIZE_SIG == Adapter->psFlash2xCSInfo->FlashSectorSizeSig) &&
...@@ -3181,21 +2927,10 @@ INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter) ...@@ -3181,21 +2927,10 @@ INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter)
Concerns: what if CS sector size does not match with this sector size ??? 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 ???? what is the indication of AccessBitMap in CS in flash 2.x ????
*/ */
#ifndef BCM_SHM_INTERFACE
Adapter->ulFlashID = BcmReadFlashRDID(Adapter); Adapter->ulFlashID = BcmReadFlashRDID(Adapter);
#endif
Adapter->uiFlashLayoutMajorVersion = uiFlashLayoutMajorVersion; 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 ; return STATUS_SUCCESS ;
} }
...@@ -3214,7 +2949,7 @@ INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter) ...@@ -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; UINT uiData = 0;
...@@ -3568,39 +3303,6 @@ INT BcmFlash2xBulkWrite( ...@@ -3568,39 +3303,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 * BcmGetActiveDSD : Set the Active DSD in Adapter Structure which has to be dumped in DDR
* @Adapter :-Drivers private Data Structure * @Adapter :-Drivers private Data Structure
...@@ -3609,7 +3311,7 @@ INT ReadDSDHeader(PMINI_ADAPTER Adapter, PDSD_HEADER psDSDHeader, FLASH2X_SECTIO ...@@ -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 * 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 ; FLASH2X_SECTION_VAL uiHighestPriDSD = 0 ;
...@@ -3647,39 +3349,6 @@ INT BcmGetActiveDSD(PMINI_ADAPTER Adapter) ...@@ -3647,39 +3349,6 @@ INT BcmGetActiveDSD(PMINI_ADAPTER Adapter)
return STATUS_SUCCESS; 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 * BcmGetActiveISO :- Set the Active ISO in Adapter Data Structue
...@@ -3691,7 +3360,7 @@ INT ReadISOHeader(PMINI_ADAPTER Adapter, PISO_HEADER psISOHeader, FLASH2X_SECTIO ...@@ -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 ; INT HighestPriISO = 0 ;
...@@ -4588,7 +4257,7 @@ INT BcmCopyISO(PMINI_ADAPTER Adapter, FLASH2X_COPY_SECTION sCopySectStrut) ...@@ -4588,7 +4257,7 @@ INT BcmCopyISO(PMINI_ADAPTER Adapter, FLASH2X_COPY_SECTION sCopySectStrut)
} }
bcm_kfree(Buff); kfree(Buff);
return Status; return Status;
} }
...@@ -4789,7 +4458,7 @@ Return Value:- ...@@ -4789,7 +4458,7 @@ Return Value:-
Success :- Base Address of the Flash Success :- Base Address of the Flash
**/ **/
INT GetFlashBaseAddr(PMINI_ADAPTER Adapter) static INT GetFlashBaseAddr(PMINI_ADAPTER Adapter)
{ {
UINT uiBaseAddr = 0; UINT uiBaseAddr = 0;
...@@ -4866,20 +4535,6 @@ INT BcmCopySection(PMINI_ADAPTER Adapter, ...@@ -4866,20 +4535,6 @@ INT BcmCopySection(PMINI_ADAPTER Adapter,
return -EINVAL; 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 offset zero means have to copy complete secton
if(numOfBytes == 0) if(numOfBytes == 0)
...@@ -4954,7 +4609,7 @@ INT BcmCopySection(PMINI_ADAPTER Adapter, ...@@ -4954,7 +4609,7 @@ INT BcmCopySection(PMINI_ADAPTER Adapter,
BytesToBeCopied = numOfBytes; BytesToBeCopied = numOfBytes;
} }
}while(numOfBytes > 0) ; }while(numOfBytes > 0) ;
bcm_kfree(pBuff); kfree(pBuff);
Adapter->bHeaderChangeAllowed = FALSE ; Adapter->bHeaderChangeAllowed = FALSE ;
return Status; return Status;
} }
...@@ -4979,14 +4634,6 @@ INT SaveHeaderIfPresent(PMINI_ADAPTER Adapter, PUCHAR pBuff, UINT uiOffset) ...@@ -4979,14 +4634,6 @@ INT SaveHeaderIfPresent(PMINI_ADAPTER Adapter, PUCHAR pBuff, UINT uiOffset)
UINT uiSectAlignAddr = 0; UINT uiSectAlignAddr = 0;
UINT sig = 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 //making the offset sector alligned
uiSectAlignAddr = uiOffset & ~(Adapter->uiSectorSize - 1); uiSectAlignAddr = uiOffset & ~(Adapter->uiSectorSize - 1);
...@@ -5024,7 +4671,7 @@ INT SaveHeaderIfPresent(PMINI_ADAPTER Adapter, PUCHAR pBuff, UINT uiOffset) ...@@ -5024,7 +4671,7 @@ INT SaveHeaderIfPresent(PMINI_ADAPTER Adapter, PUCHAR pBuff, UINT uiOffset)
//Replace Buffer content with Header //Replace Buffer content with Header
memcpy(pBuff +offsetToProtect,pTempBuff,HeaderSizeToProtect); memcpy(pBuff +offsetToProtect,pTempBuff,HeaderSizeToProtect);
bcm_kfree(pTempBuff); kfree(pTempBuff);
} }
if(bHasHeader && Adapter->bSigCorrupted) if(bHasHeader && Adapter->bSigCorrupted)
{ {
...@@ -5044,29 +4691,7 @@ INT SaveHeaderIfPresent(PMINI_ADAPTER Adapter, PUCHAR pBuff, UINT uiOffset) ...@@ -5044,29 +4691,7 @@ INT SaveHeaderIfPresent(PMINI_ADAPTER Adapter, PUCHAR pBuff, UINT uiOffset)
return STATUS_SUCCESS ; 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. BcmDoChipSelect : This will selcet the appropriate chip for writing.
@Adapater :- Bcm Driver Private Data Structure @Adapater :- Bcm Driver Private Data Structure
...@@ -5074,7 +4699,7 @@ BcmDoChipSelect : This will selcet the appropriate chip for writing. ...@@ -5074,7 +4699,7 @@ BcmDoChipSelect : This will selcet the appropriate chip for writing.
OutPut:- OutPut:-
Select the Appropriate chip and retrn status Sucess 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; UINT FlashConfig = 0;
INT ChipNum = 0; INT ChipNum = 0;
...@@ -5365,39 +4990,6 @@ INT WriteToFlashWithoutSectorErase(PMINI_ADAPTER Adapter, ...@@ -5365,39 +4990,6 @@ INT WriteToFlashWithoutSectorErase(PMINI_ADAPTER Adapter,
return Status; 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) BOOLEAN IsSectionExistInFlash(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL section)
{ {
...@@ -5479,7 +5071,7 @@ INT IsSectionWritable(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL Section) ...@@ -5479,7 +5071,7 @@ INT IsSectionWritable(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL Section)
return Status ; return Status ;
} }
INT CorruptDSDSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal) static INT CorruptDSDSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal)
{ {
PUCHAR pBuff = NULL; PUCHAR pBuff = NULL;
...@@ -5543,16 +5135,16 @@ INT CorruptDSDSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal) ...@@ -5543,16 +5135,16 @@ INT CorruptDSDSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal)
else else
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"BCM Signature is not present in header"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"BCM Signature is not present in header");
bcm_kfree(pBuff); kfree(pBuff);
return STATUS_FAILURE; return STATUS_FAILURE;
} }
bcm_kfree(pBuff); kfree(pBuff);
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Corrupted the signature"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Corrupted the signature");
return STATUS_SUCCESS ; 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; PUCHAR pBuff = NULL;
...@@ -5593,14 +5185,14 @@ INT CorruptISOSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal) ...@@ -5593,14 +5185,14 @@ INT CorruptISOSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal)
else else
{ {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"BCM Signature is not present in header"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"BCM Signature is not present in header");
bcm_kfree(pBuff); kfree(pBuff);
return STATUS_FAILURE; return STATUS_FAILURE;
} }
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Corrupted the signature"); 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_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,pBuff,MAX_RW_SIZE);
bcm_kfree(pBuff); kfree(pBuff);
return STATUS_SUCCESS ; return STATUS_SUCCESS ;
} }
......
...@@ -323,15 +323,6 @@ typedef struct _ISO_HEADER ...@@ -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_AFTER_INIT 0x1C000000
#define FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT 0x1F000000 #define FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT 0x1F000000
...@@ -414,76 +405,5 @@ extern int bcmflash_raw_writenoerase(unsigned int flash_id, unsigned int offset, ...@@ -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)) #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 #endif
/*++
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment