diff options
Diffstat (limited to 'drivers/staging/bcm')
| -rw-r--r-- | drivers/staging/bcm/Adapter.h | 6 | ||||
| -rw-r--r-- | drivers/staging/bcm/Bcmchar.c | 3526 | ||||
| -rw-r--r-- | drivers/staging/bcm/Bcmnet.c | 2 | ||||
| -rw-r--r-- | drivers/staging/bcm/CmHost.c | 1292 | ||||
| -rw-r--r-- | drivers/staging/bcm/DDRInit.c | 32 | ||||
| -rw-r--r-- | drivers/staging/bcm/InterfaceDld.c | 6 | ||||
| -rw-r--r-- | drivers/staging/bcm/InterfaceIdleMode.c | 3 | ||||
| -rw-r--r-- | drivers/staging/bcm/InterfaceInit.c | 416 | ||||
| -rw-r--r-- | drivers/staging/bcm/InterfaceIsr.c | 223 | ||||
| -rw-r--r-- | drivers/staging/bcm/InterfaceMisc.h | 12 | ||||
| -rw-r--r-- | drivers/staging/bcm/Kconfig | 1 | ||||
| -rw-r--r-- | drivers/staging/bcm/PHSModule.c | 9 | ||||
| -rw-r--r-- | drivers/staging/bcm/Qos.c | 238 | ||||
| -rw-r--r-- | drivers/staging/bcm/Transmit.c | 19 | ||||
| -rw-r--r-- | drivers/staging/bcm/Typedefs.h | 22 | ||||
| -rw-r--r-- | drivers/staging/bcm/headers.h | 2 | ||||
| -rw-r--r-- | drivers/staging/bcm/hostmibs.c | 51 | ||||
| -rw-r--r-- | drivers/staging/bcm/nvm.c | 30 |
18 files changed, 3354 insertions, 2536 deletions
diff --git a/drivers/staging/bcm/Adapter.h b/drivers/staging/bcm/Adapter.h index f0d6f0c3820..1b2d9f3bd55 100644 --- a/drivers/staging/bcm/Adapter.h +++ b/drivers/staging/bcm/Adapter.h @@ -37,8 +37,10 @@ struct bcm_link_request { union u_ip_address { struct { - ULONG ulIpv4Addr[MAX_IP_RANGE_LENGTH]; /* Source Ip Address Range */ - ULONG ulIpv4Mask[MAX_IP_RANGE_LENGTH]; /* Source Ip Mask Address Range */ + /* Source Ip Address Range */ + ULONG ulIpv4Addr[MAX_IP_RANGE_LENGTH]; + /* Source Ip Mask Address Range */ + ULONG ulIpv4Mask[MAX_IP_RANGE_LENGTH]; }; struct { ULONG ulIpv6Addr[MAX_IP_RANGE_LENGTH * 4]; /* Source Ip Address Range */ diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index f1b6de0293c..606d5f5e921 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -1,6 +1,94 @@ #include <linux/fs.h> #include "headers.h" + +static int bcm_handle_nvm_read_cmd(struct bcm_mini_adapter *Adapter, + PUCHAR pReadData, struct bcm_nvm_readwrite *stNVMReadWrite) +{ + INT Status = STATUS_FAILURE; + + down(&Adapter->NVMRdmWrmLock); + + if ((Adapter->IdleMode == TRUE) || (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + + BCM_DEBUG_PRINT(Adapter, + DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "Device is in Idle/Shutdown Mode\n"); + up(&Adapter->NVMRdmWrmLock); + kfree(pReadData); + return -EACCES; + } + + Status = BeceemNVMRead(Adapter, (PUINT)pReadData, + stNVMReadWrite->uiOffset, + stNVMReadWrite->uiNumBytes); + up(&Adapter->NVMRdmWrmLock); + + if (Status != STATUS_SUCCESS) { + kfree(pReadData); + return Status; + } + + if (copy_to_user(stNVMReadWrite->pBuffer, pReadData, + stNVMReadWrite->uiNumBytes)) { + kfree(pReadData); + return -EFAULT; + } + + return STATUS_SUCCESS; +} + +static int handle_flash2x_adapter(struct bcm_mini_adapter *Adapter, + PUCHAR pReadData, struct bcm_nvm_readwrite *stNVMReadWrite) +{ + /* + * New Requirement:- + * DSD section updation will be allowed in two case:- + * 1. if DSD sig is present in DSD header means dongle + * is ok and updation is fruitfull + * 2. if point 1 failes then user buff should have + * DSD sig. this point ensures that if dongle is + * corrupted then user space program first modify + * the DSD header with valid DSD sig so that this + * as well as further write may be worthwhile. + * + * This restriction has been put assuming that + * if DSD sig is corrupted, DSD data won't be + * considered valid. + */ + INT Status; + ULONG ulDSDMagicNumInUsrBuff = 0; + + Status = BcmFlash2xCorruptSig(Adapter, Adapter->eActiveDSD); + if (Status == STATUS_SUCCESS) + return STATUS_SUCCESS; + + if (((stNVMReadWrite->uiOffset + stNVMReadWrite->uiNumBytes) != + Adapter->uiNVMDSDSize) || + (stNVMReadWrite->uiNumBytes < SIGNATURE_SIZE)) { + + 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); + kfree(pReadData); + return Status; + } + + ulDSDMagicNumInUsrBuff = + ntohl(*(PUINT)(pReadData + stNVMReadWrite->uiNumBytes - + SIGNATURE_SIZE)); + if (ulDSDMagicNumInUsrBuff != DSD_IMAGE_MAGIC_NUMBER) { + 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); + kfree(pReadData); + return Status; + } + + return STATUS_SUCCESS; +} + /*************************************************************** * Function - bcm_char_open() * @@ -101,9 +189,11 @@ static ssize_t bcm_char_read(struct file *filp, char __user *buf, size_t size, int wait_ret_val = 0; unsigned long ret = 0; - wait_ret_val = wait_event_interruptible(Adapter->process_read_wait_queue, - (pTarang->RxAppControlHead || - Adapter->device_removed)); + wait_ret_val = wait_event_interruptible( + Adapter->process_read_wait_queue, + (pTarang->RxAppControlHead || + Adapter->device_removed)); + if ((wait_ret_val == -ERESTARTSYS)) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Exiting as i've been asked to exit!!!\n"); @@ -150,1903 +240,2363 @@ static ssize_t bcm_char_read(struct file *filp, char __user *buf, size_t size, return PktLen; } -static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) +static int bcm_char_ioctl_reg_read_private(void __user *argp, + struct bcm_mini_adapter *Adapter) { - struct bcm_tarang_data *pTarang = filp->private_data; - void __user *argp = (void __user *)arg; - struct bcm_mini_adapter *Adapter = pTarang->Adapter; - INT Status = STATUS_FAILURE; - int timeout = 0; + struct bcm_rdm_buffer sRdmBuffer = {0}; struct bcm_ioctl_buffer IoBuffer; + PCHAR temp_buff; + INT Status = STATUS_FAILURE; + UINT Bufflen; + u16 temp_value; int bytes; - 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); - - if (_IOC_TYPE(cmd) != BCM_IOCTL) + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) return -EFAULT; - if (_IOC_DIR(cmd) & _IOC_READ) - Status = !access_ok(VERIFY_WRITE, argp, _IOC_SIZE(cmd)); - else if (_IOC_DIR(cmd) & _IOC_WRITE) - Status = !access_ok(VERIFY_READ, argp, _IOC_SIZE(cmd)); - else if (_IOC_NONE == (_IOC_DIR(cmd) & _IOC_NONE)) - Status = STATUS_SUCCESS; - if (Status) - return -EFAULT; + if (IoBuffer.InputLength > sizeof(sRdmBuffer)) + return -EINVAL; - if (Adapter->device_removed) + if (copy_from_user(&sRdmBuffer, IoBuffer.InputBuffer, + IoBuffer.InputLength)) return -EFAULT; - if (false == Adapter->fw_download_done) { - switch (cmd) { - case IOCTL_MAC_ADDR_REQ: - case IOCTL_LINK_REQ: - case IOCTL_CM_REQUEST: - case IOCTL_SS_INFO_REQ: - case IOCTL_SEND_CONTROL_MESSAGE: - case IOCTL_IDLE_REQ: - case IOCTL_BCM_GPIO_SET_REQUEST: - case IOCTL_BCM_GPIO_STATUS_REQUEST: - return -EACCES; - default: - break; - } + if (IoBuffer.OutputLength > USHRT_MAX || + IoBuffer.OutputLength == 0) { + return -EINVAL; } - Status = vendorextnIoctl(Adapter, cmd, arg); - if (Status != CONTINUE_COMMON_PATH) - return Status; + Bufflen = IoBuffer.OutputLength; + temp_value = 4 - (Bufflen % 4); + Bufflen += temp_value % 4; - switch (cmd) { - /* Rdms for Swin Idle... */ - case IOCTL_BCM_REGISTER_READ_PRIVATE: { - struct bcm_rdm_buffer sRdmBuffer = {0}; - PCHAR temp_buff; - UINT Bufflen; - u16 temp_value; - - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (IoBuffer.InputLength > sizeof(sRdmBuffer)) - return -EINVAL; + temp_buff = kmalloc(Bufflen, GFP_KERNEL); + if (!temp_buff) + return -ENOMEM; - if (copy_from_user(&sRdmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) + bytes = rdmalt(Adapter, (UINT)sRdmBuffer.Register, + (PUINT)temp_buff, Bufflen); + if (bytes > 0) { + Status = STATUS_SUCCESS; + if (copy_to_user(IoBuffer.OutputBuffer, temp_buff, bytes)) { + kfree(temp_buff); return -EFAULT; - - if (IoBuffer.OutputLength > USHRT_MAX || - IoBuffer.OutputLength == 0) { - return -EINVAL; } + } else { + Status = bytes; + } - Bufflen = IoBuffer.OutputLength; - temp_value = 4 - (Bufflen % 4); - Bufflen += temp_value % 4; + kfree(temp_buff); + return Status; +} - temp_buff = kmalloc(Bufflen, GFP_KERNEL); - if (!temp_buff) - return -ENOMEM; +static int bcm_char_ioctl_reg_write_private(void __user *argp, + struct bcm_mini_adapter *Adapter) +{ + struct bcm_wrm_buffer sWrmBuffer = {0}; + struct bcm_ioctl_buffer IoBuffer; + UINT uiTempVar = 0; + INT Status; - bytes = rdmalt(Adapter, (UINT)sRdmBuffer.Register, - (PUINT)temp_buff, Bufflen); - if (bytes > 0) { - Status = STATUS_SUCCESS; - if (copy_to_user(IoBuffer.OutputBuffer, temp_buff, bytes)) { - kfree(temp_buff); - return -EFAULT; - } - } else { - Status = bytes; - } + /* Copy Ioctl Buffer structure */ - kfree(temp_buff); - break; - } + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; - case IOCTL_BCM_REGISTER_WRITE_PRIVATE: { - struct bcm_wrm_buffer sWrmBuffer = {0}; - UINT uiTempVar = 0; - /* Copy Ioctl Buffer structure */ + if (IoBuffer.InputLength > sizeof(sWrmBuffer)) + return -EINVAL; - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; + /* Get WrmBuffer structure */ + if (copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer, + IoBuffer.InputLength)) + return -EFAULT; - if (IoBuffer.InputLength > sizeof(sWrmBuffer)) - return -EINVAL; + uiTempVar = sWrmBuffer.Register & EEPROM_REJECT_MASK; + if (!((Adapter->pstargetparams->m_u32Customize) & VSG_MODE) && + ((uiTempVar == EEPROM_REJECT_REG_1) || + (uiTempVar == EEPROM_REJECT_REG_2) || + (uiTempVar == EEPROM_REJECT_REG_3) || + (uiTempVar == EEPROM_REJECT_REG_4))) { - /* Get WrmBuffer structure */ - if (copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "EEPROM Access Denied, not in VSG Mode\n"); + return -EFAULT; + } - uiTempVar = sWrmBuffer.Register & EEPROM_REJECT_MASK; - if (!((Adapter->pstargetparams->m_u32Customize) & VSG_MODE) && - ((uiTempVar == EEPROM_REJECT_REG_1) || - (uiTempVar == EEPROM_REJECT_REG_2) || - (uiTempVar == EEPROM_REJECT_REG_3) || - (uiTempVar == EEPROM_REJECT_REG_4))) { + Status = wrmalt(Adapter, (UINT)sWrmBuffer.Register, + (PUINT)sWrmBuffer.Data, sizeof(ULONG)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "EEPROM Access Denied, not in VSG Mode\n"); - return -EFAULT; - } + if (Status == STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, + DBG_LVL_ALL, "WRM Done\n"); + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, + DBG_LVL_ALL, "WRM Failed\n"); + Status = -EFAULT; + } + return Status; +} - Status = wrmalt(Adapter, (UINT)sWrmBuffer.Register, - (PUINT)sWrmBuffer.Data, sizeof(ULONG)); +static int bcm_char_ioctl_eeprom_reg_read(void __user *argp, + struct bcm_mini_adapter *Adapter) +{ + struct bcm_rdm_buffer sRdmBuffer = {0}; + struct bcm_ioctl_buffer IoBuffer; + PCHAR temp_buff = NULL; + UINT uiTempVar = 0; + INT Status; + int bytes; - if (Status == STATUS_SUCCESS) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, "WRM Done\n"); - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, "WRM Failed\n"); - Status = -EFAULT; - } - break; + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Device in Idle Mode, Blocking Rdms\n"); + return -EACCES; } - case IOCTL_BCM_REGISTER_READ: - case IOCTL_BCM_EEPROM_REGISTER_READ: { - struct bcm_rdm_buffer sRdmBuffer = {0}; - PCHAR temp_buff = NULL; - UINT uiTempVar = 0; - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Device in Idle Mode, Blocking Rdms\n"); - return -EACCES; - } + if (IoBuffer.InputLength > sizeof(sRdmBuffer)) + return -EINVAL; - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; + if (copy_from_user(&sRdmBuffer, IoBuffer.InputBuffer, + IoBuffer.InputLength)) + return -EFAULT; - if (IoBuffer.InputLength > sizeof(sRdmBuffer)) - return -EINVAL; + if (IoBuffer.OutputLength > USHRT_MAX || + IoBuffer.OutputLength == 0) { + return -EINVAL; + } - if (copy_from_user(&sRdmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; + temp_buff = kmalloc(IoBuffer.OutputLength, GFP_KERNEL); + if (!temp_buff) + return STATUS_FAILURE; - if (IoBuffer.OutputLength > USHRT_MAX || - IoBuffer.OutputLength == 0) { - return -EINVAL; - } + if ((((ULONG)sRdmBuffer.Register & 0x0F000000) != 0x0F000000) || + ((ULONG)sRdmBuffer.Register & 0x3)) { - temp_buff = kmalloc(IoBuffer.OutputLength, GFP_KERNEL); - if (!temp_buff) - return STATUS_FAILURE; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "RDM Done On invalid Address : %x Access Denied.\n", + (int)sRdmBuffer.Register); - if ((((ULONG)sRdmBuffer.Register & 0x0F000000) != 0x0F000000) || - ((ULONG)sRdmBuffer.Register & 0x3)) { + kfree(temp_buff); + return -EINVAL; + } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "RDM Done On invalid Address : %x Access Denied.\n", - (int)sRdmBuffer.Register); + uiTempVar = sRdmBuffer.Register & EEPROM_REJECT_MASK; + bytes = rdmaltWithLock(Adapter, (UINT)sRdmBuffer.Register, + (PUINT)temp_buff, IoBuffer.OutputLength); + if (bytes > 0) { + Status = STATUS_SUCCESS; + if (copy_to_user(IoBuffer.OutputBuffer, temp_buff, bytes)) { kfree(temp_buff); - return -EINVAL; + return -EFAULT; } + } else { + Status = bytes; + } - uiTempVar = sRdmBuffer.Register & EEPROM_REJECT_MASK; - bytes = rdmaltWithLock(Adapter, (UINT)sRdmBuffer.Register, - (PUINT)temp_buff, IoBuffer.OutputLength); + kfree(temp_buff); + return Status; +} - if (bytes > 0) { - Status = STATUS_SUCCESS; - if (copy_to_user(IoBuffer.OutputBuffer, temp_buff, bytes)) { - kfree(temp_buff); - return -EFAULT; - } - } else { - Status = bytes; - } +static int bcm_char_ioctl_eeprom_reg_write(void __user *argp, + struct bcm_mini_adapter *Adapter, + UINT cmd) +{ + struct bcm_wrm_buffer sWrmBuffer = {0}; + struct bcm_ioctl_buffer IoBuffer; + UINT uiTempVar = 0; + INT Status; - kfree(temp_buff); - break; + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Device in Idle Mode, Blocking Wrms\n"); + return -EACCES; } - case IOCTL_BCM_REGISTER_WRITE: - case IOCTL_BCM_EEPROM_REGISTER_WRITE: { - struct bcm_wrm_buffer sWrmBuffer = {0}; - UINT uiTempVar = 0; - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Device in Idle Mode, Blocking Wrms\n"); - return -EACCES; - } + if (IoBuffer.InputLength > sizeof(sWrmBuffer)) + return -EINVAL; - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; + /* Get WrmBuffer structure */ + if (copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer, + IoBuffer.InputLength)) + return -EFAULT; - if (IoBuffer.InputLength > sizeof(sWrmBuffer)) - return -EINVAL; + if ((((ULONG)sWrmBuffer.Register & 0x0F000000) != 0x0F000000) || + ((ULONG)sWrmBuffer.Register & 0x3)) { - /* Get WrmBuffer structure */ - if (copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "WRM Done On invalid Address : %x Access Denied.\n", + (int)sWrmBuffer.Register); + return -EINVAL; + } - if ((((ULONG)sWrmBuffer.Register & 0x0F000000) != 0x0F000000) || - ((ULONG)sWrmBuffer.Register & 0x3)) { + uiTempVar = sWrmBuffer.Register & EEPROM_REJECT_MASK; + if (!((Adapter->pstargetparams->m_u32Customize) & VSG_MODE) && + ((uiTempVar == EEPROM_REJECT_REG_1) || + (uiTempVar == EEPROM_REJECT_REG_2) || + (uiTempVar == EEPROM_REJECT_REG_3) || + (uiTempVar == EEPROM_REJECT_REG_4)) && + (cmd == IOCTL_BCM_REGISTER_WRITE)) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "WRM Done On invalid Address : %x Access Denied.\n", - (int)sWrmBuffer.Register); - return -EINVAL; - } - - uiTempVar = sWrmBuffer.Register & EEPROM_REJECT_MASK; - if (!((Adapter->pstargetparams->m_u32Customize) & VSG_MODE) && - ((uiTempVar == EEPROM_REJECT_REG_1) || - (uiTempVar == EEPROM_REJECT_REG_2) || - (uiTempVar == EEPROM_REJECT_REG_3) || - (uiTempVar == EEPROM_REJECT_REG_4)) && - (cmd == IOCTL_BCM_REGISTER_WRITE)) { - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "EEPROM Access Denied, not in VSG Mode\n"); - return -EFAULT; - } + "EEPROM Access Denied, not in VSG Mode\n"); + return -EFAULT; + } - Status = wrmaltWithLock(Adapter, (UINT)sWrmBuffer.Register, - (PUINT)sWrmBuffer.Data, - sWrmBuffer.Length); + Status = wrmaltWithLock(Adapter, (UINT)sWrmBuffer.Register, + (PUINT)sWrmBuffer.Data, + sWrmBuffer.Length); - if (Status == STATUS_SUCCESS) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, OSAL_DBG, - DBG_LVL_ALL, "WRM Done\n"); - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, "WRM Failed\n"); - Status = -EFAULT; - } - break; + if (Status == STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, OSAL_DBG, + DBG_LVL_ALL, "WRM Done\n"); + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, + DBG_LVL_ALL, "WRM Failed\n"); + Status = -EFAULT; } - case IOCTL_BCM_GPIO_SET_REQUEST: { - UCHAR ucResetValue[4]; - UINT value = 0; - UINT uiBit = 0; - UINT uiOperation = 0; - struct bcm_gpio_info gpio_info = {0}; + return Status; +} - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { +static int bcm_char_ioctl_gpio_set_request(void __user *argp, + struct bcm_mini_adapter *Adapter) +{ + struct bcm_gpio_info gpio_info = {0}; + struct bcm_ioctl_buffer IoBuffer; + UCHAR ucResetValue[4]; + UINT value = 0; + UINT uiBit = 0; + UINT uiOperation = 0; + INT Status; + int bytes; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, - "GPIO Can't be set/clear in Low power Mode"); - return -EACCES; - } + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, + DBG_LVL_ALL, + "GPIO Can't be set/clear in Low power Mode"); + return -EACCES; + } - if (IoBuffer.InputLength > sizeof(gpio_info)) - return -EINVAL; + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; - if (copy_from_user(&gpio_info, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; + if (IoBuffer.InputLength > sizeof(gpio_info)) + return -EINVAL; - uiBit = gpio_info.uiGpioNumber; - uiOperation = gpio_info.uiGpioValue; - value = (1<<uiBit); + if (copy_from_user(&gpio_info, IoBuffer.InputBuffer, + IoBuffer.InputLength)) + return -EFAULT; - if (IsReqGpioIsLedInNVM(Adapter, value) == false) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, - "Sorry, Requested GPIO<0x%X> is not correspond to LED !!!", - value); - Status = -EINVAL; - break; - } + uiBit = gpio_info.uiGpioNumber; + uiOperation = gpio_info.uiGpioValue; + value = (1<<uiBit); - /* Set - setting 1 */ - if (uiOperation) { - /* Set the gpio output register */ - Status = wrmaltWithLock(Adapter, - BCM_GPIO_OUTPUT_SET_REG, - (PUINT)(&value), sizeof(UINT)); - - if (Status == STATUS_SUCCESS) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - OSAL_DBG, DBG_LVL_ALL, - "Set the GPIO bit\n"); - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - OSAL_DBG, DBG_LVL_ALL, - "Failed to set the %dth GPIO\n", - uiBit); - break; - } - } else { - /* Set the gpio output register */ - Status = wrmaltWithLock(Adapter, - BCM_GPIO_OUTPUT_CLR_REG, - (PUINT)(&value), sizeof(UINT)); + if (IsReqGpioIsLedInNVM(Adapter, value) == false) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, + DBG_LVL_ALL, + "Sorry, Requested GPIO<0x%X> is not correspond to LED !!!", + value); + return -EINVAL; + } - if (Status == STATUS_SUCCESS) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - OSAL_DBG, DBG_LVL_ALL, - "Set the GPIO bit\n"); - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - OSAL_DBG, DBG_LVL_ALL, - "Failed to clear the %dth GPIO\n", - uiBit); - break; - } - } + /* Set - setting 1 */ + if (uiOperation) { + /* Set the gpio output register */ + Status = wrmaltWithLock(Adapter, + BCM_GPIO_OUTPUT_SET_REG, + (PUINT)(&value), sizeof(UINT)); - bytes = rdmaltWithLock(Adapter, (UINT)GPIO_MODE_REGISTER, - (PUINT)ucResetValue, sizeof(UINT)); - if (bytes < 0) { - Status = bytes; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "GPIO_MODE_REGISTER read failed"); - break; + if (Status == STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + OSAL_DBG, DBG_LVL_ALL, + "Set the GPIO bit\n"); } else { - Status = STATUS_SUCCESS; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + OSAL_DBG, DBG_LVL_ALL, + "Failed to set the %dth GPIO\n", + uiBit); + return Status; } - - /* Set the gpio mode register to output */ - *(UINT *)ucResetValue |= (1<<uiBit); - Status = wrmaltWithLock(Adapter, GPIO_MODE_REGISTER, - (PUINT)ucResetValue, sizeof(UINT)); + } else { + /* Set the gpio output register */ + Status = wrmaltWithLock(Adapter, + BCM_GPIO_OUTPUT_CLR_REG, + (PUINT)(&value), sizeof(UINT)); if (Status == STATUS_SUCCESS) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, - "Set the GPIO to output Mode\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + OSAL_DBG, DBG_LVL_ALL, + "Set the GPIO bit\n"); } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, - "Failed to put GPIO in Output Mode\n"); - break; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + OSAL_DBG, DBG_LVL_ALL, + "Failed to clear the %dth GPIO\n", + uiBit); + return Status; } } - break; - case BCM_LED_THREAD_STATE_CHANGE_REQ: { - struct bcm_user_thread_req threadReq = {0}; + bytes = rdmaltWithLock(Adapter, (UINT)GPIO_MODE_REGISTER, + (PUINT)ucResetValue, sizeof(UINT)); + if (bytes < 0) { + Status = bytes; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "User made LED thread InActive"); + "GPIO_MODE_REGISTER read failed"); + return Status; + } else { + Status = STATUS_SUCCESS; + } - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { + /* Set the gpio mode register to output */ + *(UINT *)ucResetValue |= (1<<uiBit); + Status = wrmaltWithLock(Adapter, GPIO_MODE_REGISTER, + (PUINT)ucResetValue, sizeof(UINT)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, - "GPIO Can't be set/clear in Low power Mode"); - Status = -EACCES; - break; - } + if (Status == STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, + DBG_LVL_ALL, + "Set the GPIO to output Mode\n"); + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, + DBG_LVL_ALL, + "Failed to put GPIO in Output Mode\n"); + } - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; + return Status; +} - if (IoBuffer.InputLength > sizeof(threadReq)) - return -EINVAL; +static int bcm_char_ioctl_led_thread_state_change_req(void __user *argp, + struct bcm_mini_adapter *Adapter) +{ + struct bcm_user_thread_req threadReq = {0}; + struct bcm_ioctl_buffer IoBuffer; - if (copy_from_user(&threadReq, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "User made LED thread InActive"); - /* if LED thread is running(Actively or Inactively) set it state to make inactive */ - if (Adapter->LEDInfo.led_thread_running) { - if (threadReq.ThreadState == LED_THREAD_ACTIVATION_REQ) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - OSAL_DBG, DBG_LVL_ALL, - "Activating thread req"); - Adapter->DriverState = LED_THREAD_ACTIVE; - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - OSAL_DBG, DBG_LVL_ALL, - "DeActivating Thread req....."); - Adapter->DriverState = LED_THREAD_INACTIVE; - } + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { - /* signal thread. */ - wake_up(&Adapter->LEDInfo.notify_led_event); - } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, + DBG_LVL_ALL, + "GPIO Can't be set/clear in Low power Mode"); + return -EACCES; } - break; - - case IOCTL_BCM_GPIO_STATUS_REQUEST: { - ULONG uiBit = 0; - UCHAR ucRead[4]; - struct bcm_gpio_info gpio_info = {0}; - - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) - return -EACCES; - - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (IoBuffer.InputLength > sizeof(gpio_info)) - return -EINVAL; - if (copy_from_user(&gpio_info, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; - uiBit = gpio_info.uiGpioNumber; + if (IoBuffer.InputLength > sizeof(threadReq)) + return -EINVAL; - /* Set the gpio output register */ - bytes = rdmaltWithLock(Adapter, (UINT)GPIO_PIN_STATE_REGISTER, - (PUINT)ucRead, sizeof(UINT)); + if (copy_from_user(&threadReq, IoBuffer.InputBuffer, + IoBuffer.InputLength)) + return -EFAULT; - if (bytes < 0) { - Status = bytes; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "RDM Failed\n"); - return Status; + /* if LED thread is running(Actively or Inactively) + * set it state to make inactive + */ + if (Adapter->LEDInfo.led_thread_running) { + if (threadReq.ThreadState == LED_THREAD_ACTIVATION_REQ) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + OSAL_DBG, DBG_LVL_ALL, + "Activating thread req"); + Adapter->DriverState = LED_THREAD_ACTIVE; } else { - Status = STATUS_SUCCESS; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + OSAL_DBG, DBG_LVL_ALL, + "DeActivating Thread req....."); + Adapter->DriverState = LED_THREAD_INACTIVE; } + + /* signal thread. */ + wake_up(&Adapter->LEDInfo.notify_led_event); } - break; + return STATUS_SUCCESS; +} - case IOCTL_BCM_GPIO_MULTI_REQUEST: { - UCHAR ucResetValue[4]; - struct bcm_gpio_multi_info gpio_multi_info[MAX_IDX]; - struct bcm_gpio_multi_info *pgpio_multi_info = (struct bcm_gpio_multi_info *)gpio_multi_info; +static int bcm_char_ioctl_gpio_status_request(void __user *argp, + struct bcm_mini_adapter *Adapter) +{ + struct bcm_gpio_info gpio_info = {0}; + struct bcm_ioctl_buffer IoBuffer; + ULONG uiBit = 0; + UCHAR ucRead[4]; + INT Status; + int bytes; - memset(pgpio_multi_info, 0, MAX_IDX * sizeof(struct bcm_gpio_multi_info)); + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) + return -EACCES; - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) - return -EINVAL; + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; + if (IoBuffer.InputLength > sizeof(gpio_info)) + return -EINVAL; - if (IoBuffer.InputLength > sizeof(gpio_multi_info)) - return -EINVAL; + if (copy_from_user(&gpio_info, IoBuffer.InputBuffer, + IoBuffer.InputLength)) + return -EFAULT; - if (copy_from_user(&gpio_multi_info, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; + uiBit = gpio_info.uiGpioNumber; - 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); - Status = -EINVAL; - break; - } + /* Set the gpio output register */ + bytes = rdmaltWithLock(Adapter, (UINT)GPIO_PIN_STATE_REGISTER, + (PUINT)ucRead, sizeof(UINT)); - /* Set the gpio output register */ - if ((pgpio_multi_info[WIMAX_IDX].uiGPIOMask) & - (pgpio_multi_info[WIMAX_IDX].uiGPIOCommand)) { - /* Set 1's in GPIO OUTPUT REGISTER */ - *(UINT *)ucResetValue = pgpio_multi_info[WIMAX_IDX].uiGPIOMask & - pgpio_multi_info[WIMAX_IDX].uiGPIOCommand & - pgpio_multi_info[WIMAX_IDX].uiGPIOValue; - - if (*(UINT *) ucResetValue) - Status = wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_SET_REG, - (PUINT)ucResetValue, sizeof(ULONG)); - - if (Status != STATUS_SUCCESS) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "WRM to BCM_GPIO_OUTPUT_SET_REG Failed."); - return Status; - } + if (bytes < 0) { + Status = bytes; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "RDM Failed\n"); + return Status; + } else { + Status = STATUS_SUCCESS; + } + return Status; +} - /* Clear to 0's in GPIO OUTPUT REGISTER */ - *(UINT *)ucResetValue = (pgpio_multi_info[WIMAX_IDX].uiGPIOMask & - pgpio_multi_info[WIMAX_IDX].uiGPIOCommand & - (~(pgpio_multi_info[WIMAX_IDX].uiGPIOValue))); +static int bcm_char_ioctl_gpio_multi_request(void __user *argp, + struct bcm_mini_adapter *Adapter) +{ + struct bcm_gpio_multi_info gpio_multi_info[MAX_IDX]; + struct bcm_gpio_multi_info *pgpio_multi_info = + (struct bcm_gpio_multi_info *)gpio_multi_info; + struct bcm_ioctl_buffer IoBuffer; + UCHAR ucResetValue[4]; + INT Status = STATUS_FAILURE; + int bytes; - if (*(UINT *) ucResetValue) - Status = wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_CLR_REG, (PUINT)ucResetValue, sizeof(ULONG)); + memset(pgpio_multi_info, 0, + MAX_IDX * sizeof(struct bcm_gpio_multi_info)); - if (Status != STATUS_SUCCESS) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "WRM to BCM_GPIO_OUTPUT_CLR_REG Failed."); - return Status; - } - } + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) + return -EINVAL; - if (pgpio_multi_info[WIMAX_IDX].uiGPIOMask) { - bytes = rdmaltWithLock(Adapter, (UINT)GPIO_PIN_STATE_REGISTER, (PUINT)ucResetValue, sizeof(UINT)); + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; - if (bytes < 0) { - Status = bytes; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "RDM to GPIO_PIN_STATE_REGISTER Failed."); - return Status; - } else { - Status = STATUS_SUCCESS; - } + if (IoBuffer.InputLength > sizeof(gpio_multi_info)) + return -EINVAL; + if (IoBuffer.OutputLength > sizeof(gpio_multi_info)) + IoBuffer.OutputLength = sizeof(gpio_multi_info); - pgpio_multi_info[WIMAX_IDX].uiGPIOValue = (*(UINT *)ucResetValue & - pgpio_multi_info[WIMAX_IDX].uiGPIOMask); - } + if (copy_from_user(&gpio_multi_info, IoBuffer.InputBuffer, + IoBuffer.InputLength)) + return -EFAULT; - Status = copy_to_user(IoBuffer.OutputBuffer, &gpio_multi_info, IoBuffer.OutputLength); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Failed while copying Content to IOBufer for user space err:%d", Status); - return -EFAULT; - } + 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); + return -EINVAL; } - break; - case IOCTL_BCM_GPIO_MODE_REQUEST: { - UCHAR ucResetValue[4]; - struct bcm_gpio_multi_mode gpio_multi_mode[MAX_IDX]; - struct bcm_gpio_multi_mode *pgpio_multi_mode = (struct bcm_gpio_multi_mode *)gpio_multi_mode; + /* Set the gpio output register */ + if ((pgpio_multi_info[WIMAX_IDX].uiGPIOMask) & + (pgpio_multi_info[WIMAX_IDX].uiGPIOCommand)) { + /* Set 1's in GPIO OUTPUT REGISTER */ + *(UINT *)ucResetValue = pgpio_multi_info[WIMAX_IDX].uiGPIOMask & + pgpio_multi_info[WIMAX_IDX].uiGPIOCommand & + pgpio_multi_info[WIMAX_IDX].uiGPIOValue; - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) - return -EINVAL; + if (*(UINT *) ucResetValue) + Status = wrmaltWithLock(Adapter, + BCM_GPIO_OUTPUT_SET_REG, + (PUINT)ucResetValue, sizeof(ULONG)); - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; + if (Status != STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "WRM to BCM_GPIO_OUTPUT_SET_REG Failed."); + return Status; + } - if (IoBuffer.InputLength > sizeof(gpio_multi_mode)) - return -EINVAL; + /* Clear to 0's in GPIO OUTPUT REGISTER */ + *(UINT *)ucResetValue = + (pgpio_multi_info[WIMAX_IDX].uiGPIOMask & + pgpio_multi_info[WIMAX_IDX].uiGPIOCommand & + (~(pgpio_multi_info[WIMAX_IDX].uiGPIOValue))); - if (copy_from_user(&gpio_multi_mode, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; + if (*(UINT *) ucResetValue) + Status = wrmaltWithLock(Adapter, + BCM_GPIO_OUTPUT_CLR_REG, (PUINT)ucResetValue, + sizeof(ULONG)); - bytes = rdmaltWithLock(Adapter, (UINT)GPIO_MODE_REGISTER, (PUINT)ucResetValue, sizeof(UINT)); + if (Status != STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "WRM to BCM_GPIO_OUTPUT_CLR_REG Failed."); + return Status; + } + } + + if (pgpio_multi_info[WIMAX_IDX].uiGPIOMask) { + bytes = rdmaltWithLock(Adapter, (UINT)GPIO_PIN_STATE_REGISTER, + (PUINT)ucResetValue, sizeof(UINT)); if (bytes < 0) { Status = bytes; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Read of GPIO_MODE_REGISTER failed"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "RDM to GPIO_PIN_STATE_REGISTER Failed."); return Status; } else { Status = STATUS_SUCCESS; } - /* Validating the request */ - if (IsReqGpioIsLedInNVM(Adapter, pgpio_multi_mode[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_mode[WIMAX_IDX].uiGPIOMask, Adapter->gpioBitMap); - Status = -EINVAL; - break; - } + pgpio_multi_info[WIMAX_IDX].uiGPIOValue = + (*(UINT *)ucResetValue & + pgpio_multi_info[WIMAX_IDX].uiGPIOMask); + } - if (pgpio_multi_mode[WIMAX_IDX].uiGPIOMask) { - /* write all OUT's (1's) */ - *(UINT *) ucResetValue |= (pgpio_multi_mode[WIMAX_IDX].uiGPIOMode & - pgpio_multi_mode[WIMAX_IDX].uiGPIOMask); + Status = copy_to_user(IoBuffer.OutputBuffer, &gpio_multi_info, + IoBuffer.OutputLength); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Failed while copying Content to IOBufer for user space err:%d", + Status); + return -EFAULT; + } + return Status; +} - /* write all IN's (0's) */ - *(UINT *) ucResetValue &= ~((~pgpio_multi_mode[WIMAX_IDX].uiGPIOMode) & - pgpio_multi_mode[WIMAX_IDX].uiGPIOMask); +static int bcm_char_ioctl_gpio_mode_request(void __user *argp, + struct bcm_mini_adapter *Adapter) +{ + struct bcm_gpio_multi_mode gpio_multi_mode[MAX_IDX]; + struct bcm_gpio_multi_mode *pgpio_multi_mode = + (struct bcm_gpio_multi_mode *)gpio_multi_mode; + struct bcm_ioctl_buffer IoBuffer; + UCHAR ucResetValue[4]; + INT Status; + int bytes; - /* Currently implemented return the modes of all GPIO's - * else needs to bit AND with mask - */ - pgpio_multi_mode[WIMAX_IDX].uiGPIOMode = *(UINT *)ucResetValue; + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) + return -EINVAL; - Status = wrmaltWithLock(Adapter, GPIO_MODE_REGISTER, (PUINT)ucResetValue, sizeof(ULONG)); - if (Status == STATUS_SUCCESS) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "WRM to GPIO_MODE_REGISTER Done"); - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "WRM to GPIO_MODE_REGISTER Failed"); - Status = -EFAULT; - break; - } - } else { -/* if uiGPIOMask is 0 then return mode register configuration */ - pgpio_multi_mode[WIMAX_IDX].uiGPIOMode = *(UINT *)ucResetValue; - } + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; - Status = copy_to_user(IoBuffer.OutputBuffer, &gpio_multi_mode, IoBuffer.OutputLength); - if (Status) { + if (IoBuffer.InputLength > sizeof(gpio_multi_mode)) + return -EINVAL; + if (IoBuffer.OutputLength > sizeof(gpio_multi_mode)) + IoBuffer.OutputLength = sizeof(gpio_multi_mode); + + if (copy_from_user(&gpio_multi_mode, IoBuffer.InputBuffer, + IoBuffer.InputLength)) + return -EFAULT; + + bytes = rdmaltWithLock(Adapter, (UINT)GPIO_MODE_REGISTER, + (PUINT)ucResetValue, sizeof(UINT)); + + if (bytes < 0) { + Status = bytes; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Read of GPIO_MODE_REGISTER failed"); + return Status; + } else { + Status = STATUS_SUCCESS; + } + + /* Validating the request */ + if (IsReqGpioIsLedInNVM(Adapter, pgpio_multi_mode[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_mode[WIMAX_IDX].uiGPIOMask, + Adapter->gpioBitMap); + return -EINVAL; + } + + if (pgpio_multi_mode[WIMAX_IDX].uiGPIOMask) { + /* write all OUT's (1's) */ + *(UINT *) ucResetValue |= + (pgpio_multi_mode[WIMAX_IDX].uiGPIOMode & + pgpio_multi_mode[WIMAX_IDX].uiGPIOMask); + + /* write all IN's (0's) */ + *(UINT *) ucResetValue &= + ~((~pgpio_multi_mode[WIMAX_IDX].uiGPIOMode) & + pgpio_multi_mode[WIMAX_IDX].uiGPIOMask); + + /* Currently implemented return the modes of all GPIO's + * else needs to bit AND with mask + */ + pgpio_multi_mode[WIMAX_IDX].uiGPIOMode = *(UINT *)ucResetValue; + + Status = wrmaltWithLock(Adapter, GPIO_MODE_REGISTER, + (PUINT)ucResetValue, sizeof(ULONG)); + if (Status == STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, + DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "WRM to GPIO_MODE_REGISTER Done"); + } else { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Failed while copying Content to IOBufer for user space err:%d", Status); + "WRM to GPIO_MODE_REGISTER Failed"); return -EFAULT; } + } else { + /* if uiGPIOMask is 0 then return mode register configuration */ + pgpio_multi_mode[WIMAX_IDX].uiGPIOMode = *(UINT *)ucResetValue; } - break; - case IOCTL_MAC_ADDR_REQ: - case IOCTL_LINK_REQ: - case IOCTL_CM_REQUEST: - case IOCTL_SS_INFO_REQ: - case IOCTL_SEND_CONTROL_MESSAGE: - case IOCTL_IDLE_REQ: { - PVOID pvBuffer = NULL; + Status = copy_to_user(IoBuffer.OutputBuffer, &gpio_multi_mode, + IoBuffer.OutputLength); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Failed while copying Content to IOBufer for user space err:%d", + Status); + return -EFAULT; + } + return Status; +} - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; +static int bcm_char_ioctl_misc_request(void __user *argp, + struct bcm_mini_adapter *Adapter) +{ + struct bcm_ioctl_buffer IoBuffer; + PVOID pvBuffer = NULL; + INT Status; - if (IoBuffer.InputLength < sizeof(struct bcm_link_request)) - return -EINVAL; + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; - if (IoBuffer.InputLength > MAX_CNTL_PKT_SIZE) - return -EINVAL; + if (IoBuffer.InputLength < sizeof(struct bcm_link_request)) + return -EINVAL; - pvBuffer = memdup_user(IoBuffer.InputBuffer, - IoBuffer.InputLength); - if (IS_ERR(pvBuffer)) - return PTR_ERR(pvBuffer); - - down(&Adapter->LowPowerModeSync); - Status = wait_event_interruptible_timeout(Adapter->lowpower_mode_wait_queue, - !Adapter->bPreparingForLowPowerMode, - (1 * HZ)); - if (Status == -ERESTARTSYS) - goto cntrlEnd; - - if (Adapter->bPreparingForLowPowerMode) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Preparing Idle Mode is still True - Hence Rejecting control message\n"); - Status = STATUS_FAILURE; - goto cntrlEnd; - } - Status = CopyBufferToControlPacket(Adapter, (PVOID)pvBuffer); + if (IoBuffer.InputLength > MAX_CNTL_PKT_SIZE) + return -EINVAL; -cntrlEnd: - up(&Adapter->LowPowerModeSync); - kfree(pvBuffer); - break; - } + pvBuffer = memdup_user(IoBuffer.InputBuffer, + IoBuffer.InputLength); + if (IS_ERR(pvBuffer)) + return PTR_ERR(pvBuffer); - case IOCTL_BCM_BUFFER_DOWNLOAD_START: { - if (down_trylock(&Adapter->NVMRdmWrmLock)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "IOCTL_BCM_CHIP_RESET not allowed as EEPROM Read/Write is in progress\n"); - return -EACCES; - } + down(&Adapter->LowPowerModeSync); + Status = wait_event_interruptible_timeout( + Adapter->lowpower_mode_wait_queue, + !Adapter->bPreparingForLowPowerMode, + (1 * HZ)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Starting the firmware download PID =0x%x!!!!\n", current->pid); - - if (down_trylock(&Adapter->fw_download_sema)) - return -EBUSY; - - Adapter->bBinDownloaded = false; - Adapter->fw_download_process_pid = current->pid; - Adapter->bCfgDownloaded = false; - Adapter->fw_download_done = false; - netif_carrier_off(Adapter->dev); - netif_stop_queue(Adapter->dev); - Status = reset_card_proc(Adapter); - if (Status) { - pr_err(PFX "%s: reset_card_proc Failed!\n", Adapter->dev->name); - up(&Adapter->fw_download_sema); - up(&Adapter->NVMRdmWrmLock); - return Status; - } - mdelay(10); + if (Status == -ERESTARTSYS) + goto cntrlEnd; - up(&Adapter->NVMRdmWrmLock); - return Status; + if (Adapter->bPreparingForLowPowerMode) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "Preparing Idle Mode is still True - Hence Rejecting control message\n"); + Status = STATUS_FAILURE; + goto cntrlEnd; } + Status = CopyBufferToControlPacket(Adapter, (PVOID)pvBuffer); - case IOCTL_BCM_BUFFER_DOWNLOAD: { - struct bcm_firmware_info *psFwInfo = NULL; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Starting the firmware download PID =0x%x!!!!\n", current->pid); +cntrlEnd: + up(&Adapter->LowPowerModeSync); + kfree(pvBuffer); + return Status; +} - if (!down_trylock(&Adapter->fw_download_sema)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Invalid way to download buffer. Use Start and then call this!!!\n"); - up(&Adapter->fw_download_sema); - Status = -EINVAL; - return Status; - } +static int bcm_char_ioctl_buffer_download_start( + struct bcm_mini_adapter *Adapter) +{ + INT Status; - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) { - up(&Adapter->fw_download_sema); - return -EFAULT; - } + if (down_trylock(&Adapter->NVMRdmWrmLock)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "IOCTL_BCM_CHIP_RESET not allowed as EEPROM Read/Write is in progress\n"); + return -EACCES; + } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Length for FW DLD is : %lx\n", IoBuffer.InputLength); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Starting the firmware download PID =0x%x!!!!\n", + current->pid); + + if (down_trylock(&Adapter->fw_download_sema)) + return -EBUSY; + + Adapter->bBinDownloaded = false; + Adapter->fw_download_process_pid = current->pid; + Adapter->bCfgDownloaded = false; + Adapter->fw_download_done = false; + netif_carrier_off(Adapter->dev); + netif_stop_queue(Adapter->dev); + Status = reset_card_proc(Adapter); + if (Status) { + pr_err(PFX "%s: reset_card_proc Failed!\n", Adapter->dev->name); + up(&Adapter->fw_download_sema); + up(&Adapter->NVMRdmWrmLock); + return Status; + } + mdelay(10); - if (IoBuffer.InputLength > sizeof(struct bcm_firmware_info)) { - up(&Adapter->fw_download_sema); - return -EINVAL; - } + up(&Adapter->NVMRdmWrmLock); + return Status; +} - psFwInfo = kmalloc(sizeof(*psFwInfo), GFP_KERNEL); - if (!psFwInfo) { - up(&Adapter->fw_download_sema); - return -ENOMEM; - } +static int bcm_char_ioctl_buffer_download(void __user *argp, + struct bcm_mini_adapter *Adapter) +{ + struct bcm_firmware_info *psFwInfo = NULL; + struct bcm_ioctl_buffer IoBuffer; + INT Status; - if (copy_from_user(psFwInfo, IoBuffer.InputBuffer, IoBuffer.InputLength)) { - up(&Adapter->fw_download_sema); - kfree(psFwInfo); - return -EFAULT; - } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Starting the firmware download PID =0x%x!!!!\n", current->pid); - if (!psFwInfo->pvMappedFirmwareAddress || - (psFwInfo->u32FirmwareLength == 0)) { + if (!down_trylock(&Adapter->fw_download_sema)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Invalid way to download buffer. Use Start and then call this!!!\n"); + up(&Adapter->fw_download_sema); + return -EINVAL; + } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Something else is wrong %lu\n", - psFwInfo->u32FirmwareLength); - up(&Adapter->fw_download_sema); - kfree(psFwInfo); - Status = -EINVAL; - return Status; - } + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) { + up(&Adapter->fw_download_sema); + return -EFAULT; + } - Status = bcm_ioctl_fw_download(Adapter, psFwInfo); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Length for FW DLD is : %lx\n", IoBuffer.InputLength); - if (Status != STATUS_SUCCESS) { - if (psFwInfo->u32StartingAddress == CONFIG_BEGIN_ADDR) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "IOCTL: Configuration File Upload Failed\n"); - else - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "IOCTL: Firmware File Upload Failed\n"); + if (IoBuffer.InputLength > sizeof(struct bcm_firmware_info)) { + up(&Adapter->fw_download_sema); + return -EINVAL; + } - /* up(&Adapter->fw_download_sema); */ + psFwInfo = kmalloc(sizeof(*psFwInfo), GFP_KERNEL); + if (!psFwInfo) { + up(&Adapter->fw_download_sema); + return -ENOMEM; + } - if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { - Adapter->DriverState = DRIVER_INIT; - Adapter->LEDInfo.bLedInitDone = false; - wake_up(&Adapter->LEDInfo.notify_led_event); - } - } + if (copy_from_user(psFwInfo, IoBuffer.InputBuffer, + IoBuffer.InputLength)) { + up(&Adapter->fw_download_sema); + kfree(psFwInfo); + return -EFAULT; + } - if (Status != STATUS_SUCCESS) - up(&Adapter->fw_download_sema); + if (!psFwInfo->pvMappedFirmwareAddress || + (psFwInfo->u32FirmwareLength == 0)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, OSAL_DBG, DBG_LVL_ALL, "IOCTL: Firmware File Uploaded\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Something else is wrong %lu\n", + psFwInfo->u32FirmwareLength); + up(&Adapter->fw_download_sema); kfree(psFwInfo); + Status = -EINVAL; return Status; } - case IOCTL_BCM_BUFFER_DOWNLOAD_STOP: { - if (!down_trylock(&Adapter->fw_download_sema)) { - up(&Adapter->fw_download_sema); - return -EINVAL; - } + Status = bcm_ioctl_fw_download(Adapter, psFwInfo); - if (down_trylock(&Adapter->NVMRdmWrmLock)) { + if (Status != STATUS_SUCCESS) { + if (psFwInfo->u32StartingAddress == CONFIG_BEGIN_ADDR) BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "FW download blocked as EEPROM Read/Write is in progress\n"); - up(&Adapter->fw_download_sema); - return -EACCES; - } - - Adapter->bBinDownloaded = TRUE; - Adapter->bCfgDownloaded = TRUE; - atomic_set(&Adapter->CurrNumFreeTxDesc, 0); - Adapter->CurrNumRecvDescs = 0; - Adapter->downloadDDR = 0; - - /* setting the Mips to Run */ - Status = run_card_proc(Adapter); + "IOCTL: Configuration File Upload Failed\n"); + else + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "IOCTL: Firmware File Upload Failed\n"); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Firm Download Failed\n"); - up(&Adapter->fw_download_sema); - up(&Adapter->NVMRdmWrmLock); - return Status; - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, "Firm Download Over...\n"); - } + /* up(&Adapter->fw_download_sema); */ - mdelay(10); - - /* Wait for MailBox Interrupt */ - if (StartInterruptUrb((struct bcm_interface_adapter *)Adapter->pvInterfaceAdapter)) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Unable to send interrupt...\n"); - - timeout = 5*HZ; - Adapter->waiting_to_fw_download_done = false; - wait_event_timeout(Adapter->ioctl_fw_dnld_wait_queue, - Adapter->waiting_to_fw_download_done, timeout); - Adapter->fw_download_process_pid = INVALID_PID; - Adapter->fw_download_done = TRUE; - atomic_set(&Adapter->CurrNumFreeTxDesc, 0); - Adapter->CurrNumRecvDescs = 0; - Adapter->PrevNumRecvDescs = 0; - atomic_set(&Adapter->cntrlpktCnt, 0); - Adapter->LinkUpStatus = 0; - Adapter->LinkStatus = 0; - - if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { - Adapter->DriverState = FW_DOWNLOAD_DONE; + if (Adapter->LEDInfo.led_thread_running & + BCM_LED_THREAD_RUNNING_ACTIVELY) { + Adapter->DriverState = DRIVER_INIT; + Adapter->LEDInfo.bLedInitDone = false; wake_up(&Adapter->LEDInfo.notify_led_event); } + } + + if (Status != STATUS_SUCCESS) + up(&Adapter->fw_download_sema); - if (!timeout) - Status = -ENODEV; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, OSAL_DBG, DBG_LVL_ALL, + "IOCTL: Firmware File Uploaded\n"); + kfree(psFwInfo); + return Status; +} +static int bcm_char_ioctl_buffer_download_stop(void __user *argp, + struct bcm_mini_adapter *Adapter) +{ + INT Status; + int timeout = 0; + + if (!down_trylock(&Adapter->fw_download_sema)) { up(&Adapter->fw_download_sema); - up(&Adapter->NVMRdmWrmLock); - return Status; + return -EINVAL; } - case IOCTL_BE_BUCKET_SIZE: - Status = 0; - if (get_user(Adapter->BEBucketSize, (unsigned long __user *)arg)) - Status = -EFAULT; - break; + if (down_trylock(&Adapter->NVMRdmWrmLock)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "FW download blocked as EEPROM Read/Write is in progress\n"); + up(&Adapter->fw_download_sema); + return -EACCES; + } - case IOCTL_RTPS_BUCKET_SIZE: - Status = 0; - if (get_user(Adapter->rtPSBucketSize, (unsigned long __user *)arg)) - Status = -EFAULT; - break; + Adapter->bBinDownloaded = TRUE; + Adapter->bCfgDownloaded = TRUE; + atomic_set(&Adapter->CurrNumFreeTxDesc, 0); + Adapter->CurrNumRecvDescs = 0; + Adapter->downloadDDR = 0; - case IOCTL_CHIP_RESET: { - INT NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock); - if (NVMAccess) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, " IOCTL_BCM_CHIP_RESET not allowed as EEPROM Read/Write is in progress\n"); - return -EACCES; - } + /* setting the Mips to Run */ + Status = run_card_proc(Adapter); - down(&Adapter->RxAppControlQueuelock); - Status = reset_card_proc(Adapter); - flushAllAppQ(); - up(&Adapter->RxAppControlQueuelock); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Firm Download Failed\n"); + up(&Adapter->fw_download_sema); up(&Adapter->NVMRdmWrmLock); - ResetCounters(Adapter); - break; + return Status; + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, + DBG_LVL_ALL, "Firm Download Over...\n"); } - case IOCTL_QOS_THRESHOLD: { - USHORT uiLoopIndex; + mdelay(10); - Status = 0; - for (uiLoopIndex = 0; uiLoopIndex < NO_OF_QUEUES; uiLoopIndex++) { - if (get_user(Adapter->PackInfo[uiLoopIndex].uiThreshold, - (unsigned long __user *)arg)) { - Status = -EFAULT; - break; - } - } - break; + /* Wait for MailBox Interrupt */ + if (StartInterruptUrb((struct bcm_interface_adapter *)Adapter->pvInterfaceAdapter)) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Unable to send interrupt...\n"); + + timeout = 5*HZ; + Adapter->waiting_to_fw_download_done = false; + wait_event_timeout(Adapter->ioctl_fw_dnld_wait_queue, + Adapter->waiting_to_fw_download_done, timeout); + Adapter->fw_download_process_pid = INVALID_PID; + Adapter->fw_download_done = TRUE; + atomic_set(&Adapter->CurrNumFreeTxDesc, 0); + Adapter->CurrNumRecvDescs = 0; + Adapter->PrevNumRecvDescs = 0; + atomic_set(&Adapter->cntrlpktCnt, 0); + Adapter->LinkUpStatus = 0; + Adapter->LinkStatus = 0; + + if (Adapter->LEDInfo.led_thread_running & + BCM_LED_THREAD_RUNNING_ACTIVELY) { + Adapter->DriverState = FW_DOWNLOAD_DONE; + wake_up(&Adapter->LEDInfo.notify_led_event); } - case IOCTL_DUMP_PACKET_INFO: - DumpPackInfo(Adapter); - DumpPhsRules(&Adapter->stBCMPhsContext); - Status = STATUS_SUCCESS; - break; + if (!timeout) + Status = -ENODEV; - case IOCTL_GET_PACK_INFO: - if (copy_to_user(argp, &Adapter->PackInfo, sizeof(struct bcm_packet_info)*NO_OF_QUEUES)) - return -EFAULT; - Status = STATUS_SUCCESS; - break; + up(&Adapter->fw_download_sema); + up(&Adapter->NVMRdmWrmLock); + return Status; +} - case IOCTL_BCM_SWITCH_TRANSFER_MODE: { - UINT uiData = 0; - if (copy_from_user(&uiData, argp, sizeof(UINT))) - return -EFAULT; +static int bcm_char_ioctl_chip_reset(struct bcm_mini_adapter *Adapter) +{ + INT Status; + INT NVMAccess; - 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"); - Adapter->TransferMode = ETH_PACKET_TUNNELING_MODE; - } else { - /* Allow IP only Packets */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SWITCH_TRANSFER_MODE: IP_PACKET_ONLY_MODE\n"); - Adapter->TransferMode = IP_PACKET_ONLY_MODE; - } - Status = STATUS_SUCCESS; - break; + NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock); + if (NVMAccess) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + " IOCTL_BCM_CHIP_RESET not allowed as EEPROM Read/Write is in progress\n"); + return -EACCES; } - case IOCTL_BCM_GET_DRIVER_VERSION: { - ulong len; - - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; + down(&Adapter->RxAppControlQueuelock); + Status = reset_card_proc(Adapter); + flushAllAppQ(); + up(&Adapter->RxAppControlQueuelock); + up(&Adapter->NVMRdmWrmLock); + ResetCounters(Adapter); + return Status; +} - len = min_t(ulong, IoBuffer.OutputLength, strlen(DRV_VERSION) + 1); +static int bcm_char_ioctl_qos_threshold(ULONG arg, + struct bcm_mini_adapter *Adapter) +{ + USHORT uiLoopIndex; - if (copy_to_user(IoBuffer.OutputBuffer, DRV_VERSION, len)) + for (uiLoopIndex = 0; uiLoopIndex < NO_OF_QUEUES; uiLoopIndex++) { + if (get_user(Adapter->PackInfo[uiLoopIndex].uiThreshold, + (unsigned long __user *)arg)) { return -EFAULT; - Status = STATUS_SUCCESS; - break; + } } + return 0; +} - case IOCTL_BCM_GET_CURRENT_STATUS: { - struct bcm_link_state link_state; +static int bcm_char_ioctl_switch_transfer_mode(void __user *argp, + struct bcm_mini_adapter *Adapter) +{ + UINT uiData = 0; - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "copy_from_user failed..\n"); - return -EFAULT; - } + if (copy_from_user(&uiData, argp, sizeof(UINT))) + return -EFAULT; - if (IoBuffer.OutputLength != sizeof(link_state)) { - Status = -EINVAL; - break; - } + 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"); + Adapter->TransferMode = ETH_PACKET_TUNNELING_MODE; + } else { + /* Allow IP only Packets */ + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "IOCTL_BCM_SWITCH_TRANSFER_MODE: IP_PACKET_ONLY_MODE\n"); + Adapter->TransferMode = IP_PACKET_ONLY_MODE; + } + return STATUS_SUCCESS; +} - memset(&link_state, 0, sizeof(link_state)); - link_state.bIdleMode = Adapter->IdleMode; - link_state.bShutdownMode = Adapter->bShutStatus; - link_state.ucLinkStatus = Adapter->LinkStatus; +static int bcm_char_ioctl_get_driver_version(void __user *argp) +{ + struct bcm_ioctl_buffer IoBuffer; + ulong len; - 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"); - return -EFAULT; - } - Status = STATUS_SUCCESS; - break; - } + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; - case IOCTL_BCM_SET_MAC_TRACING: { - UINT tracing_flag; + len = min_t(ulong, IoBuffer.OutputLength, strlen(DRV_VERSION) + 1); - /* copy ioctl Buffer structure */ - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; + if (copy_to_user(IoBuffer.OutputBuffer, DRV_VERSION, len)) + return -EFAULT; - if (copy_from_user(&tracing_flag, IoBuffer.InputBuffer, sizeof(UINT))) - return -EFAULT; + return STATUS_SUCCESS; +} - if (tracing_flag) - Adapter->pTarangs->MacTracingEnabled = TRUE; - else - Adapter->pTarangs->MacTracingEnabled = false; - break; +static int bcm_char_ioctl_get_current_status(void __user *argp, + struct bcm_mini_adapter *Adapter) +{ + struct bcm_link_state link_state; + struct bcm_ioctl_buffer IoBuffer; + + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "copy_from_user failed..\n"); + return -EFAULT; } - case IOCTL_BCM_GET_DSX_INDICATION: { - ULONG ulSFId = 0; - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; + if (IoBuffer.OutputLength != sizeof(link_state)) + return -EINVAL; - if (IoBuffer.OutputLength < sizeof(struct bcm_add_indication_alt)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Mismatch req: %lx needed is =0x%zx!!!", - IoBuffer.OutputLength, sizeof(struct bcm_add_indication_alt)); - return -EINVAL; - } + memset(&link_state, 0, sizeof(link_state)); + link_state.bIdleMode = Adapter->IdleMode; + link_state.bShutdownMode = Adapter->bShutStatus; + link_state.ucLinkStatus = Adapter->LinkStatus; - if (copy_from_user(&ulSFId, IoBuffer.InputBuffer, sizeof(ulSFId))) - return -EFAULT; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Get DSX Data SF ID is =%lx\n", ulSFId); - get_dsx_sf_data_to_application(Adapter, ulSFId, IoBuffer.OutputBuffer); - Status = STATUS_SUCCESS; + 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"); + return -EFAULT; } - break; + return STATUS_SUCCESS; +} - case IOCTL_BCM_GET_HOST_MIBS: { - PVOID temp_buff; - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; +static int bcm_char_ioctl_set_mac_tracing(void __user *argp, + struct bcm_mini_adapter *Adapter) +{ + struct bcm_ioctl_buffer IoBuffer; + UINT tracing_flag; - if (IoBuffer.OutputLength != sizeof(struct bcm_host_stats_mibs)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Length Check failed %lu %zd\n", - IoBuffer.OutputLength, sizeof(struct bcm_host_stats_mibs)); - return -EINVAL; - } + /* copy ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; - /* FIXME: HOST_STATS are too big for kmalloc (122048)! */ - temp_buff = kzalloc(sizeof(struct bcm_host_stats_mibs), GFP_KERNEL); - if (!temp_buff) - return STATUS_FAILURE; + if (copy_from_user(&tracing_flag, IoBuffer.InputBuffer, sizeof(UINT))) + return -EFAULT; - Status = ProcessGetHostMibs(Adapter, temp_buff); - GetDroppedAppCntrlPktMibs(temp_buff, pTarang); + if (tracing_flag) + Adapter->pTarangs->MacTracingEnabled = TRUE; + else + Adapter->pTarangs->MacTracingEnabled = false; - if (Status != STATUS_FAILURE) - if (copy_to_user(IoBuffer.OutputBuffer, temp_buff, sizeof(struct bcm_host_stats_mibs))) { - kfree(temp_buff); - return -EFAULT; - } + return STATUS_SUCCESS; +} - kfree(temp_buff); - break; +static int bcm_char_ioctl_get_dsx_indication(void __user *argp, + struct bcm_mini_adapter *Adapter) +{ + struct bcm_ioctl_buffer IoBuffer; + ULONG ulSFId = 0; + + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; + + if (IoBuffer.OutputLength < sizeof(struct bcm_add_indication_alt)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Mismatch req: %lx needed is =0x%zx!!!", + IoBuffer.OutputLength, + sizeof(struct bcm_add_indication_alt)); + return -EINVAL; } - case IOCTL_BCM_WAKE_UP_DEVICE_FROM_IDLE: - if ((false == Adapter->bTriedToWakeUpFromlowPowerMode) && (TRUE == Adapter->IdleMode)) { - Adapter->usIdleModePattern = ABORT_IDLE_MODE; - Adapter->bWakeUpDevice = TRUE; - wake_up(&Adapter->process_rx_cntrlpkt); - } + if (copy_from_user(&ulSFId, IoBuffer.InputBuffer, sizeof(ulSFId))) + return -EFAULT; - Status = STATUS_SUCCESS; - break; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "Get DSX Data SF ID is =%lx\n", ulSFId); + get_dsx_sf_data_to_application(Adapter, ulSFId, IoBuffer.OutputBuffer); + return STATUS_SUCCESS; +} - case IOCTL_BCM_BULK_WRM: { - struct bcm_bulk_wrm_buffer *pBulkBuffer; - UINT uiTempVar = 0; - PCHAR pvBuffer = NULL; +static int bcm_char_ioctl_get_host_mibs(void __user *argp, + struct bcm_mini_adapter *Adapter, struct bcm_tarang_data *pTarang) +{ + struct bcm_ioctl_buffer IoBuffer; + INT Status = STATUS_FAILURE; + PVOID temp_buff; - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "Device in Idle/Shutdown Mode, Blocking Wrms\n"); - Status = -EACCES; - break; - } + if (IoBuffer.OutputLength != sizeof(struct bcm_host_stats_mibs)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Length Check failed %lu %zd\n", IoBuffer.OutputLength, + sizeof(struct bcm_host_stats_mibs)); + return -EINVAL; + } + + /* FIXME: HOST_STATS are too big for kmalloc (122048)! */ + temp_buff = kzalloc(sizeof(struct bcm_host_stats_mibs), GFP_KERNEL); + if (!temp_buff) + return STATUS_FAILURE; + + Status = ProcessGetHostMibs(Adapter, temp_buff); + GetDroppedAppCntrlPktMibs(temp_buff, pTarang); - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + if (Status != STATUS_FAILURE) { + if (copy_to_user(IoBuffer.OutputBuffer, temp_buff, + sizeof(struct bcm_host_stats_mibs))) { + kfree(temp_buff); return -EFAULT; + } + } - if (IoBuffer.InputLength < sizeof(ULONG) * 2) - return -EINVAL; + kfree(temp_buff); + return Status; +} - pvBuffer = memdup_user(IoBuffer.InputBuffer, - IoBuffer.InputLength); - if (IS_ERR(pvBuffer)) - return PTR_ERR(pvBuffer); +static int bcm_char_ioctl_bulk_wrm(void __user *argp, + struct bcm_mini_adapter *Adapter, UINT cmd) +{ + struct bcm_bulk_wrm_buffer *pBulkBuffer; + struct bcm_ioctl_buffer IoBuffer; + UINT uiTempVar = 0; + INT Status = STATUS_FAILURE; + PCHAR pvBuffer = NULL; - pBulkBuffer = (struct bcm_bulk_wrm_buffer *)pvBuffer; + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { - if (((ULONG)pBulkBuffer->Register & 0x0F000000) != 0x0F000000 || - ((ULONG)pBulkBuffer->Register & 0x3)) { - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "WRM Done On invalid Address : %x Access Denied.\n", (int)pBulkBuffer->Register); - kfree(pvBuffer); - Status = -EINVAL; - break; - } + BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, + "Device in Idle/Shutdown Mode, Blocking Wrms\n"); + return -EACCES; + } - uiTempVar = pBulkBuffer->Register & EEPROM_REJECT_MASK; - if (!((Adapter->pstargetparams->m_u32Customize)&VSG_MODE) && - ((uiTempVar == EEPROM_REJECT_REG_1) || - (uiTempVar == EEPROM_REJECT_REG_2) || - (uiTempVar == EEPROM_REJECT_REG_3) || - (uiTempVar == EEPROM_REJECT_REG_4)) && - (cmd == IOCTL_BCM_REGISTER_WRITE)) { + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; - kfree(pvBuffer); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "EEPROM Access Denied, not in VSG Mode\n"); - Status = -EFAULT; - break; - } + if (IoBuffer.InputLength < sizeof(ULONG) * 2) + return -EINVAL; - if (pBulkBuffer->SwapEndian == false) - Status = wrmWithLock(Adapter, (UINT)pBulkBuffer->Register, (PCHAR)pBulkBuffer->Values, IoBuffer.InputLength - 2*sizeof(ULONG)); - else - Status = wrmaltWithLock(Adapter, (UINT)pBulkBuffer->Register, (PUINT)pBulkBuffer->Values, IoBuffer.InputLength - 2*sizeof(ULONG)); + pvBuffer = memdup_user(IoBuffer.InputBuffer, + IoBuffer.InputLength); + if (IS_ERR(pvBuffer)) + return PTR_ERR(pvBuffer); - if (Status != STATUS_SUCCESS) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "WRM Failed\n"); + pBulkBuffer = (struct bcm_bulk_wrm_buffer *)pvBuffer; + if (((ULONG)pBulkBuffer->Register & 0x0F000000) != 0x0F000000 || + ((ULONG)pBulkBuffer->Register & 0x3)) { + BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, + "WRM Done On invalid Address : %x Access Denied.\n", + (int)pBulkBuffer->Register); kfree(pvBuffer); - break; + return -EINVAL; } - case IOCTL_BCM_GET_NVM_SIZE: - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + uiTempVar = pBulkBuffer->Register & EEPROM_REJECT_MASK; + if (!((Adapter->pstargetparams->m_u32Customize)&VSG_MODE) && + ((uiTempVar == EEPROM_REJECT_REG_1) || + (uiTempVar == EEPROM_REJECT_REG_2) || + (uiTempVar == EEPROM_REJECT_REG_3) || + (uiTempVar == EEPROM_REJECT_REG_4)) && + (cmd == IOCTL_BCM_REGISTER_WRITE)) { + + kfree(pvBuffer); + BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, + "EEPROM Access Denied, not in VSG Mode\n"); + return -EFAULT; + } + + if (pBulkBuffer->SwapEndian == false) + Status = wrmWithLock(Adapter, (UINT)pBulkBuffer->Register, + (PCHAR)pBulkBuffer->Values, + IoBuffer.InputLength - 2*sizeof(ULONG)); + else + Status = wrmaltWithLock(Adapter, (UINT)pBulkBuffer->Register, + (PUINT)pBulkBuffer->Values, + IoBuffer.InputLength - 2*sizeof(ULONG)); + + if (Status != STATUS_SUCCESS) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "WRM Failed\n"); + + kfree(pvBuffer); + return Status; +} + +static int bcm_char_ioctl_get_nvm_size(void __user *argp, + struct bcm_mini_adapter *Adapter) +{ + struct bcm_ioctl_buffer IoBuffer; + + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; + + if (Adapter->eNVMType == NVM_EEPROM || Adapter->eNVMType == NVM_FLASH) { + if (copy_to_user(IoBuffer.OutputBuffer, &Adapter->uiNVMDSDSize, + sizeof(UINT))) return -EFAULT; + } - if (Adapter->eNVMType == NVM_EEPROM || Adapter->eNVMType == NVM_FLASH) { - if (copy_to_user(IoBuffer.OutputBuffer, &Adapter->uiNVMDSDSize, sizeof(UINT))) - return -EFAULT; - } + return STATUS_SUCCESS; +} - Status = STATUS_SUCCESS; - break; +static int bcm_char_ioctl_cal_init(void __user *argp, + struct bcm_mini_adapter *Adapter) +{ + struct bcm_ioctl_buffer IoBuffer; + UINT uiSectorSize = 0; + INT Status = STATUS_FAILURE; - case IOCTL_BCM_CAL_INIT: { - UINT uiSectorSize = 0; - if (Adapter->eNVMType == NVM_FLASH) { - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; + if (Adapter->eNVMType == NVM_FLASH) { + if (copy_from_user(&IoBuffer, argp, + sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; - if (copy_from_user(&uiSectorSize, IoBuffer.InputBuffer, sizeof(UINT))) - return -EFAULT; + if (copy_from_user(&uiSectorSize, IoBuffer.InputBuffer, + sizeof(UINT))) + return -EFAULT; - if ((uiSectorSize < MIN_SECTOR_SIZE) || (uiSectorSize > MAX_SECTOR_SIZE)) { - if (copy_to_user(IoBuffer.OutputBuffer, &Adapter->uiSectorSize, - sizeof(UINT))) + if ((uiSectorSize < MIN_SECTOR_SIZE) || + (uiSectorSize > MAX_SECTOR_SIZE)) { + if (copy_to_user(IoBuffer.OutputBuffer, + &Adapter->uiSectorSize, sizeof(UINT))) + return -EFAULT; + } else { + if (IsFlash2x(Adapter)) { + if (copy_to_user(IoBuffer.OutputBuffer, + &Adapter->uiSectorSize, sizeof(UINT))) return -EFAULT; } else { - if (IsFlash2x(Adapter)) { - if (copy_to_user(IoBuffer.OutputBuffer, &Adapter->uiSectorSize, sizeof(UINT))) - return -EFAULT; - } else { - if ((TRUE == Adapter->bShutStatus) || (TRUE == Adapter->IdleMode)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Device is in Idle/Shutdown Mode\n"); - return -EACCES; - } - - Adapter->uiSectorSize = uiSectorSize; - BcmUpdateSectorSize(Adapter, Adapter->uiSectorSize); + if ((TRUE == Adapter->bShutStatus) || + (TRUE == Adapter->IdleMode)) { + BCM_DEBUG_PRINT(Adapter, + DBG_TYPE_PRINTK, 0, 0, + "Device is in Idle/Shutdown Mode\n"); + return -EACCES; } + + Adapter->uiSectorSize = uiSectorSize; + BcmUpdateSectorSize(Adapter, + Adapter->uiSectorSize); } - Status = STATUS_SUCCESS; - } else { - Status = STATUS_FAILURE; } + Status = STATUS_SUCCESS; + } else { + Status = STATUS_FAILURE; } - break; + return Status; +} - case IOCTL_BCM_SET_DEBUG: +static int bcm_char_ioctl_set_debug(void __user *argp, + struct bcm_mini_adapter *Adapter) +{ #ifdef DEBUG - { - struct bcm_user_debug_state sUserDebugState; + struct bcm_ioctl_buffer IoBuffer; + struct bcm_user_debug_state sUserDebugState; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "In SET_DEBUG ioctl\n"); - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "In SET_DEBUG ioctl\n"); + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; - if (copy_from_user(&sUserDebugState, IoBuffer.InputBuffer, sizeof(struct bcm_user_debug_state))) - return -EFAULT; + if (copy_from_user(&sUserDebugState, IoBuffer.InputBuffer, + sizeof(struct bcm_user_debug_state))) + return -EFAULT; - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "IOCTL_BCM_SET_DEBUG: OnOff=%d Type = 0x%x ", - sUserDebugState.OnOff, sUserDebugState.Type); - /* sUserDebugState.Subtype <<= 1; */ - sUserDebugState.Subtype = 1 << sUserDebugState.Subtype; - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "actual Subtype=0x%x\n", sUserDebugState.Subtype); - - /* Update new 'DebugState' in the Adapter */ - Adapter->stDebugState.type |= sUserDebugState.Type; - /* Subtype: A bitmap of 32 bits for Subtype per Type. - * Valid indexes in 'subtype' array: 1,2,4,8 - * corresponding to valid Type values. Hence we can use the 'Type' field - * as the index value, ignoring the array entries 0,3,5,6,7 ! - */ - if (sUserDebugState.OnOff) - Adapter->stDebugState.subtype[sUserDebugState.Type] |= sUserDebugState.Subtype; - else - Adapter->stDebugState.subtype[sUserDebugState.Type] &= ~sUserDebugState.Subtype; + BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, + "IOCTL_BCM_SET_DEBUG: OnOff=%d Type = 0x%x ", + sUserDebugState.OnOff, sUserDebugState.Type); + /* sUserDebugState.Subtype <<= 1; */ + sUserDebugState.Subtype = 1 << sUserDebugState.Subtype; + BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, + "actual Subtype=0x%x\n", sUserDebugState.Subtype); + + /* Update new 'DebugState' in the Adapter */ + Adapter->stDebugState.type |= sUserDebugState.Type; + /* Subtype: A bitmap of 32 bits for Subtype per Type. + * Valid indexes in 'subtype' array: 1,2,4,8 + * corresponding to valid Type values. Hence we can use the 'Type' field + * as the index value, ignoring the array entries 0,3,5,6,7 ! + */ + if (sUserDebugState.OnOff) + Adapter->stDebugState.subtype[sUserDebugState.Type] |= + sUserDebugState.Subtype; + else + Adapter->stDebugState.subtype[sUserDebugState.Type] &= + ~sUserDebugState.Subtype; + + BCM_SHOW_DEBUG_BITMAP(Adapter); +#endif + return STATUS_SUCCESS; +} + +static int bcm_char_ioctl_nvm_rw(void __user *argp, + struct bcm_mini_adapter *Adapter, UINT cmd) +{ + struct bcm_nvm_readwrite stNVMReadWrite; + struct timeval tv0, tv1; + struct bcm_ioctl_buffer IoBuffer; + PUCHAR pReadData = NULL; + INT Status = STATUS_FAILURE; - BCM_SHOW_DEBUG_BITMAP(Adapter); + memset(&tv0, 0, sizeof(struct timeval)); + memset(&tv1, 0, sizeof(struct timeval)); + if ((Adapter->eNVMType == NVM_FLASH) && + (Adapter->uiFlashLayoutMajorVersion == 0)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "The Flash Control Section is Corrupted. Hence Rejection on NVM Read/Write\n"); + return -EFAULT; } -#endif - break; - case IOCTL_BCM_NVM_READ: - case IOCTL_BCM_NVM_WRITE: { - struct bcm_nvm_readwrite stNVMReadWrite; - PUCHAR pReadData = NULL; - ULONG ulDSDMagicNumInUsrBuff = 0; - struct timeval tv0, tv1; - memset(&tv0, 0, sizeof(struct timeval)); - memset(&tv1, 0, sizeof(struct timeval)); - if ((Adapter->eNVMType == NVM_FLASH) && (Adapter->uiFlashLayoutMajorVersion == 0)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "The Flash Control Section is Corrupted. Hence Rejection on NVM Read/Write\n"); - return -EFAULT; + if (IsFlash2x(Adapter)) { + if ((Adapter->eActiveDSD != DSD0) && + (Adapter->eActiveDSD != DSD1) && + (Adapter->eActiveDSD != DSD2)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "No DSD is active..hence NVM Command is blocked"); + return STATUS_FAILURE; } + } - if (IsFlash2x(Adapter)) { - if ((Adapter->eActiveDSD != DSD0) && - (Adapter->eActiveDSD != DSD1) && - (Adapter->eActiveDSD != DSD2)) { + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "No DSD is active..hence NVM Command is blocked"); - return STATUS_FAILURE; - } + if (copy_from_user(&stNVMReadWrite, + (IOCTL_BCM_NVM_READ == cmd) ? + IoBuffer.OutputBuffer : IoBuffer.InputBuffer, + sizeof(struct bcm_nvm_readwrite))) + return -EFAULT; + + /* + * Deny the access if the offset crosses the cal area limit. + */ + if (stNVMReadWrite.uiNumBytes > Adapter->uiNVMDSDSize) + return STATUS_FAILURE; + + if (stNVMReadWrite.uiOffset > + Adapter->uiNVMDSDSize - stNVMReadWrite.uiNumBytes) + return STATUS_FAILURE; + + pReadData = memdup_user(stNVMReadWrite.pBuffer, + stNVMReadWrite.uiNumBytes); + if (IS_ERR(pReadData)) + return PTR_ERR(pReadData); + + do_gettimeofday(&tv0); + if (IOCTL_BCM_NVM_READ == cmd) { + int ret = bcm_handle_nvm_read_cmd(Adapter, pReadData, + &stNVMReadWrite); + if (ret != STATUS_SUCCESS) + return ret; + } else { + down(&Adapter->NVMRdmWrmLock); + + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + + BCM_DEBUG_PRINT(Adapter, + DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "Device is in Idle/Shutdown Mode\n"); + up(&Adapter->NVMRdmWrmLock); + kfree(pReadData); + return -EACCES; } - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; + Adapter->bHeaderChangeAllowed = TRUE; + if (IsFlash2x(Adapter)) { + int ret = handle_flash2x_adapter(Adapter, + pReadData, + &stNVMReadWrite); + if (ret != STATUS_SUCCESS) + return ret; + } - if (copy_from_user(&stNVMReadWrite, - (IOCTL_BCM_NVM_READ == cmd) ? IoBuffer.OutputBuffer : IoBuffer.InputBuffer, - sizeof(struct bcm_nvm_readwrite))) - return -EFAULT; + Status = BeceemNVMWrite(Adapter, (PUINT)pReadData, + stNVMReadWrite.uiOffset, stNVMReadWrite.uiNumBytes, + stNVMReadWrite.bVerify); + if (IsFlash2x(Adapter)) + BcmFlash2xWriteSig(Adapter, Adapter->eActiveDSD); - /* - * Deny the access if the offset crosses the cal area limit. - */ - if (stNVMReadWrite.uiNumBytes > Adapter->uiNVMDSDSize) - return STATUS_FAILURE; + Adapter->bHeaderChangeAllowed = false; - if (stNVMReadWrite.uiOffset > Adapter->uiNVMDSDSize - stNVMReadWrite.uiNumBytes) { - /* BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Can't allow access beyond NVM Size: 0x%x 0x%x\n", stNVMReadWrite.uiOffset, stNVMReadWrite.uiNumBytes); */ - return STATUS_FAILURE; + up(&Adapter->NVMRdmWrmLock); + + if (Status != STATUS_SUCCESS) { + kfree(pReadData); + return Status; } + } - pReadData = memdup_user(stNVMReadWrite.pBuffer, - stNVMReadWrite.uiNumBytes); - if (IS_ERR(pReadData)) - return PTR_ERR(pReadData); + do_gettimeofday(&tv1); + 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); - do_gettimeofday(&tv0); - if (IOCTL_BCM_NVM_READ == cmd) { - down(&Adapter->NVMRdmWrmLock); + kfree(pReadData); + return STATUS_SUCCESS; +} - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { +static int bcm_char_ioctl_flash2x_section_read(void __user *argp, + struct bcm_mini_adapter *Adapter) +{ + struct bcm_flash2x_readwrite sFlash2xRead = {0}; + struct bcm_ioctl_buffer IoBuffer; + PUCHAR pReadBuff = NULL; + UINT NOB = 0; + UINT BuffSize = 0; + UINT ReadBytes = 0; + UINT ReadOffset = 0; + INT Status = STATUS_FAILURE; + void __user *OutPutBuff; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); - up(&Adapter->NVMRdmWrmLock); - kfree(pReadData); - return -EACCES; - } + if (IsFlash2x(Adapter) != TRUE) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Flash Does not have 2.x map"); + return -EINVAL; + } - Status = BeceemNVMRead(Adapter, (PUINT)pReadData, stNVMReadWrite.uiOffset, stNVMReadWrite.uiNumBytes); - up(&Adapter->NVMRdmWrmLock); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, + DBG_LVL_ALL, "IOCTL_BCM_FLASH2X_SECTION_READ Called"); + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; - if (Status != STATUS_SUCCESS) { - kfree(pReadData); - return Status; - } + /* Reading FLASH 2.x READ structure */ + if (copy_from_user(&sFlash2xRead, IoBuffer.InputBuffer, + sizeof(struct bcm_flash2x_readwrite))) + return -EFAULT; - if (copy_to_user(stNVMReadWrite.pBuffer, pReadData, stNVMReadWrite.uiNumBytes)) { - kfree(pReadData); - return -EFAULT; - } - } else { - down(&Adapter->NVMRdmWrmLock); + 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.offset :%x", + sFlash2xRead.offset); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "\nsFlash2xRead.numOfBytes :%x", + sFlash2xRead.numOfBytes); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "\nsFlash2xRead.bVerify :%x\n", + sFlash2xRead.bVerify); + + /* This was internal to driver for raw read. + * now it has ben exposed to user space app. + */ + if (validateFlash2xReadWrite(Adapter, &sFlash2xRead) == false) + return STATUS_FAILURE; + + NOB = sFlash2xRead.numOfBytes; + if (NOB > Adapter->uiSectorSize) + BuffSize = Adapter->uiSectorSize; + else + BuffSize = NOB; + + ReadOffset = sFlash2xRead.offset; + OutPutBuff = IoBuffer.OutputBuffer; + pReadBuff = (PCHAR)kzalloc(BuffSize , GFP_KERNEL); + + if (pReadBuff == NULL) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Memory allocation failed for Flash 2.x Read Structure"); + return -ENOMEM; + } + down(&Adapter->NVMRdmWrmLock); - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); - up(&Adapter->NVMRdmWrmLock); - kfree(pReadData); - return -EACCES; - } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, + DBG_LVL_ALL, + "Device is in Idle/Shutdown Mode\n"); + up(&Adapter->NVMRdmWrmLock); + kfree(pReadBuff); + return -EACCES; + } - Adapter->bHeaderChangeAllowed = TRUE; - if (IsFlash2x(Adapter)) { - /* - * New Requirement:- - * DSD section updation will be allowed in two case:- - * 1. if DSD sig is present in DSD header means dongle is ok and updation is fruitfull - * 2. if point 1 failes then user buff should have DSD sig. this point ensures that if dongle is - * corrupted then user space program first modify the DSD header with valid DSD sig so - * that this as well as further write may be worthwhile. - * - * This restriction has been put assuming that if DSD sig is corrupted, DSD - * data won't be considered valid. - */ - - Status = BcmFlash2xCorruptSig(Adapter, Adapter->eActiveDSD); - if (Status != STATUS_SUCCESS) { - if (((stNVMReadWrite.uiOffset + stNVMReadWrite.uiNumBytes) != Adapter->uiNVMDSDSize) || - (stNVMReadWrite.uiNumBytes < SIGNATURE_SIZE)) { - - 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); - kfree(pReadData); - return Status; - } - - ulDSDMagicNumInUsrBuff = ntohl(*(PUINT)(pReadData + stNVMReadWrite.uiNumBytes - SIGNATURE_SIZE)); - if (ulDSDMagicNumInUsrBuff != DSD_IMAGE_MAGIC_NUMBER) { - 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); - kfree(pReadData); - return Status; - } - } - } + while (NOB) { + if (NOB > Adapter->uiSectorSize) + ReadBytes = Adapter->uiSectorSize; + else + ReadBytes = NOB; - Status = BeceemNVMWrite(Adapter, (PUINT)pReadData, stNVMReadWrite.uiOffset, stNVMReadWrite.uiNumBytes, stNVMReadWrite.bVerify); - if (IsFlash2x(Adapter)) - BcmFlash2xWriteSig(Adapter, Adapter->eActiveDSD); + /* Reading the data from Flash 2.x */ + Status = BcmFlash2xBulkRead(Adapter, (PUINT)pReadBuff, + sFlash2xRead.Section, ReadOffset, ReadBytes); + if (Status) { + BCM_DEBUG_PRINT(Adapter, + DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "Flash 2x read err with Status :%d", + Status); + break; + } - Adapter->bHeaderChangeAllowed = false; + BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, + DBG_LVL_ALL, pReadBuff, ReadBytes); + Status = copy_to_user(OutPutBuff, pReadBuff, ReadBytes); + if (Status) { + BCM_DEBUG_PRINT(Adapter, + DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "Copy to use failed with status :%d", Status); up(&Adapter->NVMRdmWrmLock); - - if (Status != STATUS_SUCCESS) { - kfree(pReadData); - return Status; - } + kfree(pReadBuff); + return -EFAULT; + } + NOB = NOB - ReadBytes; + if (NOB) { + ReadOffset = ReadOffset + ReadBytes; + OutPutBuff = OutPutBuff + ReadBytes; } + } - do_gettimeofday(&tv1); - 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); + up(&Adapter->NVMRdmWrmLock); + kfree(pReadBuff); + return Status; +} - kfree(pReadData); - return STATUS_SUCCESS; +static int bcm_char_ioctl_flash2x_section_write(void __user *argp, + struct bcm_mini_adapter *Adapter) +{ + struct bcm_flash2x_readwrite sFlash2xWrite = {0}; + struct bcm_ioctl_buffer IoBuffer; + PUCHAR pWriteBuff; + void __user *InputAddr; + UINT NOB = 0; + UINT BuffSize = 0; + UINT WriteOffset = 0; + UINT WriteBytes = 0; + INT Status = STATUS_FAILURE; + + if (IsFlash2x(Adapter) != TRUE) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Flash Does not have 2.x map"); + return -EINVAL; } - case IOCTL_BCM_FLASH2X_SECTION_READ: { - struct bcm_flash2x_readwrite sFlash2xRead = {0}; - PUCHAR pReadBuff = NULL; - UINT NOB = 0; - UINT BuffSize = 0; - UINT ReadBytes = 0; - UINT ReadOffset = 0; - void __user *OutPutBuff; + /* First make this False so that we can enable the Sector + * Permission Check in BeceemFlashBulkWrite + */ + Adapter->bAllDSDWriteAllow = false; - if (IsFlash2x(Adapter) != TRUE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Does not have 2.x map"); - return -EINVAL; - } + 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_READ Called"); - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; - /* Reading FLASH 2.x READ structure */ - if (copy_from_user(&sFlash2xRead, IoBuffer.InputBuffer, sizeof(struct bcm_flash2x_readwrite))) - return -EFAULT; + /* Reading FLASH 2.x READ structure */ + if (copy_from_user(&sFlash2xWrite, IoBuffer.InputBuffer, + sizeof(struct bcm_flash2x_readwrite))) + 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.offset :%x", sFlash2xRead.offset); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.numOfBytes :%x", sFlash2xRead.numOfBytes); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.bVerify :%x\n", sFlash2xRead.bVerify); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "\nsFlash2xRead.Section :%x", sFlash2xWrite.Section); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "\nsFlash2xRead.offset :%d", sFlash2xWrite.offset); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "\nsFlash2xRead.numOfBytes :%x", sFlash2xWrite.numOfBytes); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "\nsFlash2xRead.bVerify :%x\n", sFlash2xWrite.bVerify); - /* This was internal to driver for raw read. now it has ben exposed to user space app. */ - if (validateFlash2xReadWrite(Adapter, &sFlash2xRead) == false) - return STATUS_FAILURE; + if ((sFlash2xWrite.Section != VSA0) && (sFlash2xWrite.Section != VSA1) + && (sFlash2xWrite.Section != VSA2)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "Only VSA write is allowed"); + return -EINVAL; + } - NOB = sFlash2xRead.numOfBytes; - if (NOB > Adapter->uiSectorSize) - BuffSize = Adapter->uiSectorSize; - else - BuffSize = NOB; + if (validateFlash2xReadWrite(Adapter, &sFlash2xWrite) == false) + return STATUS_FAILURE; - ReadOffset = sFlash2xRead.offset; - OutPutBuff = IoBuffer.OutputBuffer; - pReadBuff = (PCHAR)kzalloc(BuffSize , GFP_KERNEL); + InputAddr = sFlash2xWrite.pDataBuff; + WriteOffset = sFlash2xWrite.offset; + NOB = sFlash2xWrite.numOfBytes; - if (pReadBuff == NULL) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Memory allocation failed for Flash 2.x Read Structure"); - return -ENOMEM; - } - down(&Adapter->NVMRdmWrmLock); + if (NOB > Adapter->uiSectorSize) + BuffSize = Adapter->uiSectorSize; + else + BuffSize = NOB; - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { + pWriteBuff = kmalloc(BuffSize, GFP_KERNEL); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); - up(&Adapter->NVMRdmWrmLock); - kfree(pReadBuff); - return -EACCES; - } + if (pWriteBuff == NULL) + return -ENOMEM; - while (NOB) { - if (NOB > Adapter->uiSectorSize) - ReadBytes = Adapter->uiSectorSize; - else - ReadBytes = NOB; + /* extracting the remainder of the given offset. */ + WriteBytes = Adapter->uiSectorSize; + if (WriteOffset % Adapter->uiSectorSize) { + WriteBytes = Adapter->uiSectorSize - + (WriteOffset % Adapter->uiSectorSize); + } - /* Reading the data from Flash 2.x */ - Status = BcmFlash2xBulkRead(Adapter, (PUINT)pReadBuff, sFlash2xRead.Section, ReadOffset, ReadBytes); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Flash 2x read err with Status :%d", Status); - break; - } + if (NOB < WriteBytes) + WriteBytes = NOB; - BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, pReadBuff, ReadBytes); + down(&Adapter->NVMRdmWrmLock); - Status = copy_to_user(OutPutBuff, pReadBuff, ReadBytes); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Copy to use failed with status :%d", Status); - up(&Adapter->NVMRdmWrmLock); - kfree(pReadBuff); - return -EFAULT; - } - NOB = NOB - ReadBytes; - if (NOB) { - ReadOffset = ReadOffset + ReadBytes; - OutPutBuff = OutPutBuff + ReadBytes; - } - } + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "Device is in Idle/Shutdown Mode\n"); up(&Adapter->NVMRdmWrmLock); - kfree(pReadBuff); + kfree(pWriteBuff); + return -EACCES; } - break; - case IOCTL_BCM_FLASH2X_SECTION_WRITE: { - struct bcm_flash2x_readwrite sFlash2xWrite = {0}; - PUCHAR pWriteBuff; - void __user *InputAddr; - UINT NOB = 0; - UINT BuffSize = 0; - UINT WriteOffset = 0; - UINT WriteBytes = 0; + BcmFlash2xCorruptSig(Adapter, sFlash2xWrite.Section); + do { + Status = copy_from_user(pWriteBuff, InputAddr, WriteBytes); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Copy to user failed with status :%d", Status); + up(&Adapter->NVMRdmWrmLock); + kfree(pWriteBuff); + return -EFAULT; + } + BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, + OSAL_DBG, DBG_LVL_ALL, pWriteBuff, WriteBytes); + + /* Writing the data from Flash 2.x */ + Status = BcmFlash2xBulkWrite(Adapter, (PUINT)pWriteBuff, + sFlash2xWrite.Section, + WriteOffset, + WriteBytes, + sFlash2xWrite.bVerify); - if (IsFlash2x(Adapter) != TRUE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Does not have 2.x map"); - return -EINVAL; + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Flash 2x read err with Status :%d", Status); + break; } - /* First make this False so that we can enable the Sector Permission Check in BeceemFlashBulkWrite */ - Adapter->bAllDSDWriteAllow = false; + NOB = NOB - WriteBytes; + if (NOB) { + WriteOffset = WriteOffset + WriteBytes; + InputAddr = InputAddr + WriteBytes; + if (NOB > Adapter->uiSectorSize) + WriteBytes = Adapter->uiSectorSize; + else + WriteBytes = NOB; + } + } while (NOB > 0); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_FLASH2X_SECTION_WRITE Called"); + BcmFlash2xWriteSig(Adapter, sFlash2xWrite.Section); + up(&Adapter->NVMRdmWrmLock); + kfree(pWriteBuff); + return Status; +} - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; +static int bcm_char_ioctl_flash2x_section_bitmap(void __user *argp, + struct bcm_mini_adapter *Adapter) +{ + struct bcm_flash2x_bitmap *psFlash2xBitMap; + struct bcm_ioctl_buffer IoBuffer; - /* Reading FLASH 2.x READ structure */ - if (copy_from_user(&sFlash2xWrite, IoBuffer.InputBuffer, sizeof(struct bcm_flash2x_readwrite))) - return -EFAULT; +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, "\nsFlash2xRead.Section :%x", sFlash2xWrite.Section); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.offset :%d", sFlash2xWrite.offset); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.numOfBytes :%x", sFlash2xWrite.numOfBytes); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.bVerify :%x\n", sFlash2xWrite.bVerify); + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; - if ((sFlash2xWrite.Section != VSA0) && (sFlash2xWrite.Section != VSA1) && (sFlash2xWrite.Section != VSA2)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Only VSA write is allowed"); - return -EINVAL; - } + if (IoBuffer.OutputLength != sizeof(struct bcm_flash2x_bitmap)) + return -EINVAL; - if (validateFlash2xReadWrite(Adapter, &sFlash2xWrite) == false) - return STATUS_FAILURE; + psFlash2xBitMap = kzalloc(sizeof(struct bcm_flash2x_bitmap), + GFP_KERNEL); - InputAddr = sFlash2xWrite.pDataBuff; - WriteOffset = sFlash2xWrite.offset; - NOB = sFlash2xWrite.numOfBytes; + if (psFlash2xBitMap == NULL) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Memory is not available"); + return -ENOMEM; + } - if (NOB > Adapter->uiSectorSize) - BuffSize = Adapter->uiSectorSize; - else - BuffSize = NOB; + /* Reading the Flash Sectio Bit map */ + down(&Adapter->NVMRdmWrmLock); - pWriteBuff = kmalloc(BuffSize, GFP_KERNEL); + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { - if (pWriteBuff == NULL) - return -ENOMEM; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "Device is in Idle/Shutdown Mode\n"); + up(&Adapter->NVMRdmWrmLock); + kfree(psFlash2xBitMap); + return -EACCES; + } - /* extracting the remainder of the given offset. */ - WriteBytes = Adapter->uiSectorSize; - if (WriteOffset % Adapter->uiSectorSize) - WriteBytes = Adapter->uiSectorSize - (WriteOffset % Adapter->uiSectorSize); + BcmGetFlash2xSectionalBitMap(Adapter, psFlash2xBitMap); + up(&Adapter->NVMRdmWrmLock); + if (copy_to_user(IoBuffer.OutputBuffer, psFlash2xBitMap, + sizeof(struct bcm_flash2x_bitmap))) { + kfree(psFlash2xBitMap); + return -EFAULT; + } - if (NOB < WriteBytes) - WriteBytes = NOB; + kfree(psFlash2xBitMap); + return STATUS_FAILURE; +} - down(&Adapter->NVMRdmWrmLock); +static int bcm_char_ioctl_set_active_section(void __user *argp, + struct bcm_mini_adapter *Adapter) +{ + enum bcm_flash2x_section_val eFlash2xSectionVal = 0; + INT Status = STATUS_FAILURE; + struct bcm_ioctl_buffer IoBuffer; - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "IOCTL_BCM_SET_ACTIVE_SECTION Called"); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); - up(&Adapter->NVMRdmWrmLock); - kfree(pWriteBuff); - return -EACCES; - } + if (IsFlash2x(Adapter) != TRUE) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Flash Does not have 2.x map"); + return -EINVAL; + } - BcmFlash2xCorruptSig(Adapter, sFlash2xWrite.Section); - do { - Status = copy_from_user(pWriteBuff, InputAddr, WriteBytes); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy to user failed with status :%d", Status); - up(&Adapter->NVMRdmWrmLock); - kfree(pWriteBuff); - return -EFAULT; - } - BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, pWriteBuff, WriteBytes); + Status = copy_from_user(&IoBuffer, argp, + sizeof(struct bcm_ioctl_buffer)); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Copy of IOCTL BUFFER failed"); + return -EFAULT; + } - /* Writing the data from Flash 2.x */ - Status = BcmFlash2xBulkWrite(Adapter, (PUINT)pWriteBuff, sFlash2xWrite.Section, WriteOffset, WriteBytes, sFlash2xWrite.bVerify); + Status = copy_from_user(&eFlash2xSectionVal, + IoBuffer.InputBuffer, sizeof(INT)); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Copy of flash section val failed"); + return -EFAULT; + } - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash 2x read err with Status :%d", Status); - break; - } + down(&Adapter->NVMRdmWrmLock); - NOB = NOB - WriteBytes; - if (NOB) { - WriteOffset = WriteOffset + WriteBytes; - InputAddr = InputAddr + WriteBytes; - if (NOB > Adapter->uiSectorSize) - WriteBytes = Adapter->uiSectorSize; - else - WriteBytes = NOB; - } - } while (NOB > 0); + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { - BcmFlash2xWriteSig(Adapter, sFlash2xWrite.Section); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "Device is in Idle/Shutdown Mode\n"); up(&Adapter->NVMRdmWrmLock); - kfree(pWriteBuff); + return -EACCES; } - break; - - case IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP: { - struct bcm_flash2x_bitmap *psFlash2xBitMap; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP Called"); - - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - if (IoBuffer.OutputLength != sizeof(struct bcm_flash2x_bitmap)) - return -EINVAL; + Status = BcmSetActiveSection(Adapter, eFlash2xSectionVal); + if (Status) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Failed to make it's priority Highest. Status %d", + Status); - psFlash2xBitMap = kzalloc(sizeof(struct bcm_flash2x_bitmap), GFP_KERNEL); - if (psFlash2xBitMap == NULL) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Memory is not available"); - return -ENOMEM; - } + up(&Adapter->NVMRdmWrmLock); - /* Reading the Flash Sectio Bit map */ - down(&Adapter->NVMRdmWrmLock); + return Status; +} - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { +static int bcm_char_ioctl_copy_section(void __user *argp, + struct bcm_mini_adapter *Adapter) +{ + struct bcm_flash2x_copy_section sCopySectStrut = {0}; + struct bcm_ioctl_buffer IoBuffer; + INT Status = STATUS_SUCCESS; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); - up(&Adapter->NVMRdmWrmLock); - kfree(psFlash2xBitMap); - return -EACCES; - } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "IOCTL_BCM_COPY_SECTION Called"); - BcmGetFlash2xSectionalBitMap(Adapter, psFlash2xBitMap); - up(&Adapter->NVMRdmWrmLock); - if (copy_to_user(IoBuffer.OutputBuffer, psFlash2xBitMap, sizeof(struct bcm_flash2x_bitmap))) { - kfree(psFlash2xBitMap); - return -EFAULT; - } + Adapter->bAllDSDWriteAllow = false; + if (IsFlash2x(Adapter) != TRUE) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Flash Does not have 2.x map"); + return -EINVAL; + } - kfree(psFlash2xBitMap); + Status = copy_from_user(&IoBuffer, argp, + sizeof(struct bcm_ioctl_buffer)); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Copy of IOCTL BUFFER failed Status :%d", + Status); + return -EFAULT; } - break; - case IOCTL_BCM_SET_ACTIVE_SECTION: { - enum bcm_flash2x_section_val eFlash2xSectionVal = 0; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SET_ACTIVE_SECTION Called"); + Status = copy_from_user(&sCopySectStrut, IoBuffer.InputBuffer, + sizeof(struct bcm_flash2x_copy_section)); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Copy of Copy_Section_Struct failed with Status :%d", + Status); + return -EFAULT; + } - if (IsFlash2x(Adapter) != TRUE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Does not have 2.x map"); - return -EINVAL; - } + 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, + "offset :%x", sCopySectStrut.offset); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "NOB :%x", sCopySectStrut.numOfBytes); - Status = copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer)); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); - return -EFAULT; - } + if (IsSectionExistInFlash(Adapter, sCopySectStrut.SrcSection) == false) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Source Section<%x> does not exist in Flash ", + sCopySectStrut.SrcSection); + return -EINVAL; + } - Status = copy_from_user(&eFlash2xSectionVal, IoBuffer.InputBuffer, sizeof(INT)); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of flash section val failed"); - return -EFAULT; - } + if (IsSectionExistInFlash(Adapter, sCopySectStrut.DstSection) == false) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Destinatio Section<%x> does not exist in Flash ", + sCopySectStrut.DstSection); + return -EINVAL; + } - down(&Adapter->NVMRdmWrmLock); + if (sCopySectStrut.SrcSection == sCopySectStrut.DstSection) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "Source and Destination section should be different"); + return -EINVAL; + } - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { + down(&Adapter->NVMRdmWrmLock); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); - up(&Adapter->NVMRdmWrmLock); - return -EACCES; - } + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { - Status = BcmSetActiveSection(Adapter, eFlash2xSectionVal); - if (Status) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Failed to make it's priority Highest. Status %d", Status); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "Device is in Idle/Shutdown Mode\n"); + up(&Adapter->NVMRdmWrmLock); + return -EACCES; + } + if (sCopySectStrut.SrcSection == ISO_IMAGE1 || + sCopySectStrut.SrcSection == ISO_IMAGE2) { + if (IsNonCDLessDevice(Adapter)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Device is Non-CDLess hence won't have ISO !!"); + Status = -EINVAL; + } else if (sCopySectStrut.numOfBytes == 0) { + Status = BcmCopyISO(Adapter, sCopySectStrut); + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Partial Copy of ISO section is not Allowed.."); + Status = STATUS_FAILURE; + } up(&Adapter->NVMRdmWrmLock); + return Status; } - break; - case IOCTL_BCM_IDENTIFY_ACTIVE_SECTION: { - /* Right Now we are taking care of only DSD */ - Adapter->bAllDSDWriteAllow = false; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_IDENTIFY_ACTIVE_SECTION called"); - Status = STATUS_SUCCESS; + Status = BcmCopySection(Adapter, sCopySectStrut.SrcSection, + sCopySectStrut.DstSection, + sCopySectStrut.offset, + sCopySectStrut.numOfBytes); + up(&Adapter->NVMRdmWrmLock); + return Status; +} + +static int bcm_char_ioctl_get_flash_cs_info(void __user *argp, + struct bcm_mini_adapter *Adapter) +{ + struct bcm_ioctl_buffer IoBuffer; + INT Status = STATUS_SUCCESS; + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + " IOCTL_BCM_GET_FLASH_CS_INFO Called"); + + Status = copy_from_user(&IoBuffer, argp, + sizeof(struct bcm_ioctl_buffer)); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Copy of IOCTL BUFFER failed"); + return -EFAULT; } - break; - case IOCTL_BCM_COPY_SECTION: { - struct bcm_flash2x_copy_section sCopySectStrut = {0}; - Status = STATUS_SUCCESS; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_COPY_SECTION Called"); + if (Adapter->eNVMType != NVM_FLASH) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Connected device does not have flash"); + return -EINVAL; + } - Adapter->bAllDSDWriteAllow = false; - if (IsFlash2x(Adapter) != TRUE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Does not have 2.x map"); + if (IsFlash2x(Adapter) == TRUE) { + if (IoBuffer.OutputLength < sizeof(struct bcm_flash2x_cs_info)) return -EINVAL; - } - Status = copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer)); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed Status :%d", Status); + if (copy_to_user(IoBuffer.OutputBuffer, + Adapter->psFlash2xCSInfo, + sizeof(struct bcm_flash2x_cs_info))) return -EFAULT; - } + } else { + if (IoBuffer.OutputLength < sizeof(struct bcm_flash_cs_info)) + return -EINVAL; - Status = copy_from_user(&sCopySectStrut, IoBuffer.InputBuffer, sizeof(struct bcm_flash2x_copy_section)); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of Copy_Section_Struct failed with Status :%d", Status); + if (copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlashCSInfo, + sizeof(struct bcm_flash_cs_info))) return -EFAULT; - } + } + return Status; +} - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Source SEction :%x", sCopySectStrut.SrcSection); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Destination SEction :%x", sCopySectStrut.DstSection); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "offset :%x", sCopySectStrut.offset); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "NOB :%x", sCopySectStrut.numOfBytes); +static int bcm_char_ioctl_select_dsd(void __user *argp, + struct bcm_mini_adapter *Adapter) +{ + struct bcm_ioctl_buffer IoBuffer; + INT Status = STATUS_FAILURE; + UINT SectOfset = 0; + enum bcm_flash2x_section_val eFlash2xSectionVal; - if (IsSectionExistInFlash(Adapter, sCopySectStrut.SrcSection) == false) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Source Section<%x> does not exist in Flash ", sCopySectStrut.SrcSection); - return -EINVAL; - } + eFlash2xSectionVal = NO_SECTION_VAL; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "IOCTL_BCM_SELECT_DSD Called"); - if (IsSectionExistInFlash(Adapter, sCopySectStrut.DstSection) == false) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Destinatio Section<%x> does not exist in Flash ", sCopySectStrut.DstSection); - return -EINVAL; - } + if (IsFlash2x(Adapter) != TRUE) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Flash Does not have 2.x map"); + return -EINVAL; + } - if (sCopySectStrut.SrcSection == sCopySectStrut.DstSection) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Source and Destination section should be different"); - return -EINVAL; - } + Status = copy_from_user(&IoBuffer, argp, + sizeof(struct bcm_ioctl_buffer)); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Copy of IOCTL BUFFER failed"); + return -EFAULT; + } + Status = copy_from_user(&eFlash2xSectionVal, IoBuffer.InputBuffer, + sizeof(INT)); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Copy of flash section val failed"); + return -EFAULT; + } - down(&Adapter->NVMRdmWrmLock); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "Read Section :%d", eFlash2xSectionVal); + if ((eFlash2xSectionVal != DSD0) && + (eFlash2xSectionVal != DSD1) && + (eFlash2xSectionVal != DSD2)) { - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Passed section<%x> is not DSD section", + eFlash2xSectionVal); + return STATUS_FAILURE; + } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); - up(&Adapter->NVMRdmWrmLock); - return -EACCES; - } + SectOfset = BcmGetSectionValStartOffset(Adapter, eFlash2xSectionVal); + if (SectOfset == INVALID_OFFSET) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Provided Section val <%d> does not exist in Flash 2.x", + eFlash2xSectionVal); + return -EINVAL; + } - if (sCopySectStrut.SrcSection == ISO_IMAGE1 || sCopySectStrut.SrcSection == ISO_IMAGE2) { - if (IsNonCDLessDevice(Adapter)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Device is Non-CDLess hence won't have ISO !!"); - Status = -EINVAL; - } else if (sCopySectStrut.numOfBytes == 0) { - Status = BcmCopyISO(Adapter, sCopySectStrut); - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Partial Copy of ISO section is not Allowed.."); - Status = STATUS_FAILURE; - } - up(&Adapter->NVMRdmWrmLock); - return Status; - } + Adapter->bAllDSDWriteAllow = TRUE; + Adapter->ulFlashCalStart = SectOfset; + Adapter->eActiveDSD = eFlash2xSectionVal; - Status = BcmCopySection(Adapter, sCopySectStrut.SrcSection, - sCopySectStrut.DstSection, sCopySectStrut.offset, sCopySectStrut.numOfBytes); - up(&Adapter->NVMRdmWrmLock); + return STATUS_SUCCESS; +} + +static int bcm_char_ioctl_nvm_raw_read(void __user *argp, + struct bcm_mini_adapter *Adapter) +{ + struct bcm_nvm_readwrite stNVMRead; + struct bcm_ioctl_buffer IoBuffer; + unsigned int NOB; + INT BuffSize; + INT ReadOffset = 0; + UINT ReadBytes = 0; + PUCHAR pReadBuff; + void __user *OutPutBuff; + INT Status = STATUS_FAILURE; + + if (Adapter->eNVMType != NVM_FLASH) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "NVM TYPE is not Flash"); + return -EINVAL; } - break; - case IOCTL_BCM_GET_FLASH_CS_INFO: { - Status = STATUS_SUCCESS; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, " IOCTL_BCM_GET_FLASH_CS_INFO Called"); + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "copy_from_user 1 failed\n"); + return -EFAULT; + } - Status = copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer)); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); - return -EFAULT; - } + if (copy_from_user(&stNVMRead, IoBuffer.OutputBuffer, + sizeof(struct bcm_nvm_readwrite))) + return -EFAULT; - if (Adapter->eNVMType != NVM_FLASH) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Connected device does not have flash"); - Status = -EINVAL; - break; - } + NOB = stNVMRead.uiNumBytes; + /* In Raw-Read max Buff size : 64MB */ - if (IsFlash2x(Adapter) == TRUE) { - if (IoBuffer.OutputLength < sizeof(struct bcm_flash2x_cs_info)) - return -EINVAL; + if (NOB > DEFAULT_BUFF_SIZE) + BuffSize = DEFAULT_BUFF_SIZE; + else + BuffSize = NOB; - if (copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlash2xCSInfo, sizeof(struct bcm_flash2x_cs_info))) - return -EFAULT; - } else { - if (IoBuffer.OutputLength < sizeof(struct bcm_flash_cs_info)) - return -EINVAL; + ReadOffset = stNVMRead.uiOffset; + OutPutBuff = stNVMRead.pBuffer; - if (copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlashCSInfo, sizeof(struct bcm_flash_cs_info))) - return -EFAULT; - } + pReadBuff = kzalloc(BuffSize , GFP_KERNEL); + if (pReadBuff == NULL) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Memory allocation failed for Flash 2.x Read Structure"); + return -ENOMEM; } - break; + down(&Adapter->NVMRdmWrmLock); - case IOCTL_BCM_SELECT_DSD: { - UINT SectOfset = 0; - enum bcm_flash2x_section_val eFlash2xSectionVal; - eFlash2xSectionVal = NO_SECTION_VAL; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SELECT_DSD Called"); + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { - if (IsFlash2x(Adapter) != TRUE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Does not have 2.x map"); - return -EINVAL; - } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "Device is in Idle/Shutdown Mode\n"); + kfree(pReadBuff); + up(&Adapter->NVMRdmWrmLock); + return -EACCES; + } + + Adapter->bFlashRawRead = TRUE; - Status = copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer)); + while (NOB) { + if (NOB > DEFAULT_BUFF_SIZE) + ReadBytes = DEFAULT_BUFF_SIZE; + else + ReadBytes = NOB; + + /* Reading the data from Flash 2.x */ + Status = BeceemNVMRead(Adapter, (PUINT)pReadBuff, + ReadOffset, ReadBytes); if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); - return -EFAULT; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Flash 2x read err with Status :%d", + Status); + break; } - Status = copy_from_user(&eFlash2xSectionVal, IoBuffer.InputBuffer, sizeof(INT)); + + BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, + DBG_LVL_ALL, pReadBuff, ReadBytes); + + Status = copy_to_user(OutPutBuff, pReadBuff, ReadBytes); if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of flash section val failed"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Copy to use failed with status :%d", + Status); + up(&Adapter->NVMRdmWrmLock); + kfree(pReadBuff); return -EFAULT; } + NOB = NOB - ReadBytes; + if (NOB) { + ReadOffset = ReadOffset + ReadBytes; + OutPutBuff = OutPutBuff + ReadBytes; + } + } + Adapter->bFlashRawRead = false; + up(&Adapter->NVMRdmWrmLock); + kfree(pReadBuff); + return Status; +} - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Read Section :%d", eFlash2xSectionVal); - if ((eFlash2xSectionVal != DSD0) && - (eFlash2xSectionVal != DSD1) && - (eFlash2xSectionVal != DSD2)) { +static int bcm_char_ioctl_cntrlmsg_mask(void __user *argp, + struct bcm_mini_adapter *Adapter, struct bcm_tarang_data *pTarang) +{ + struct bcm_ioctl_buffer IoBuffer; + INT Status = STATUS_FAILURE; + ULONG RxCntrlMsgBitMask = 0; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Passed section<%x> is not DSD section", eFlash2xSectionVal); - return STATUS_FAILURE; - } + /* Copy Ioctl Buffer structure */ + Status = copy_from_user(&IoBuffer, argp, + sizeof(struct bcm_ioctl_buffer)); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "copy of Ioctl buffer is failed from user space"); + return -EFAULT; + } - SectOfset = BcmGetSectionValStartOffset(Adapter, eFlash2xSectionVal); - if (SectOfset == INVALID_OFFSET) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Provided Section val <%d> does not exist in Flash 2.x", eFlash2xSectionVal); - return -EINVAL; - } + if (IoBuffer.InputLength != sizeof(unsigned long)) + return -EINVAL; - Adapter->bAllDSDWriteAllow = TRUE; - Adapter->ulFlashCalStart = SectOfset; - Adapter->eActiveDSD = eFlash2xSectionVal; + Status = copy_from_user(&RxCntrlMsgBitMask, IoBuffer.InputBuffer, + IoBuffer.InputLength); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "copy of control bit mask failed from user space"); + return -EFAULT; } - Status = STATUS_SUCCESS; - break; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "\n Got user defined cntrl msg bit mask :%lx", + RxCntrlMsgBitMask); + pTarang->RxCntrlMsgBitMask = RxCntrlMsgBitMask; - case IOCTL_BCM_NVM_RAW_READ: { - struct bcm_nvm_readwrite stNVMRead; - INT NOB; - INT BuffSize; - INT ReadOffset = 0; - UINT ReadBytes = 0; - PUCHAR pReadBuff; - void __user *OutPutBuff; + return Status; +} - if (Adapter->eNVMType != NVM_FLASH) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "NVM TYPE is not Flash"); - return -EINVAL; - } +static int bcm_char_ioctl_get_device_driver_info(void __user *argp, + struct bcm_mini_adapter *Adapter) +{ + struct bcm_driver_info DevInfo; + struct bcm_ioctl_buffer IoBuffer; - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "copy_from_user 1 failed\n"); - return -EFAULT; - } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "Called IOCTL_BCM_GET_DEVICE_DRIVER_INFO\n"); - if (copy_from_user(&stNVMRead, IoBuffer.OutputBuffer, sizeof(struct bcm_nvm_readwrite))) - return -EFAULT; + memset(&DevInfo, 0, sizeof(DevInfo)); + DevInfo.MaxRDMBufferSize = BUFFER_4K; + DevInfo.u32DSDStartOffset = EEPROM_CALPARAM_START; + DevInfo.u32RxAlignmentCorrection = 0; + DevInfo.u32NVMType = Adapter->eNVMType; + DevInfo.u32InterfaceType = BCM_USB; - NOB = stNVMRead.uiNumBytes; - /* In Raw-Read max Buff size : 64MB */ + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; - if (NOB > DEFAULT_BUFF_SIZE) - BuffSize = DEFAULT_BUFF_SIZE; - else - BuffSize = NOB; + if (IoBuffer.OutputLength < sizeof(DevInfo)) + return -EINVAL; - ReadOffset = stNVMRead.uiOffset; - OutPutBuff = stNVMRead.pBuffer; + if (copy_to_user(IoBuffer.OutputBuffer, &DevInfo, sizeof(DevInfo))) + return -EFAULT; - pReadBuff = kzalloc(BuffSize , GFP_KERNEL); - if (pReadBuff == NULL) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Memory allocation failed for Flash 2.x Read Structure"); - Status = -ENOMEM; - break; - } - down(&Adapter->NVMRdmWrmLock); + return STATUS_SUCCESS; +} - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { +static int bcm_char_ioctl_time_since_net_entry(void __user *argp, + struct bcm_mini_adapter *Adapter) +{ + struct bcm_time_elapsed stTimeElapsedSinceNetEntry = {0}; + struct bcm_ioctl_buffer IoBuffer; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); - kfree(pReadBuff); - up(&Adapter->NVMRdmWrmLock); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "IOCTL_BCM_TIME_SINCE_NET_ENTRY called"); + + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; + + if (IoBuffer.OutputLength < sizeof(struct bcm_time_elapsed)) + return -EINVAL; + + stTimeElapsedSinceNetEntry.ul64TimeElapsedSinceNetEntry = + get_seconds() - Adapter->liTimeSinceLastNetEntry; + + if (copy_to_user(IoBuffer.OutputBuffer, &stTimeElapsedSinceNetEntry, + sizeof(struct bcm_time_elapsed))) + return -EFAULT; + + return STATUS_SUCCESS; +} + + +static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) +{ + struct bcm_tarang_data *pTarang = filp->private_data; + void __user *argp = (void __user *)arg; + struct bcm_mini_adapter *Adapter = pTarang->Adapter; + INT Status = STATUS_FAILURE; + + 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); + + if (_IOC_TYPE(cmd) != BCM_IOCTL) + return -EFAULT; + if (_IOC_DIR(cmd) & _IOC_READ) + Status = !access_ok(VERIFY_WRITE, argp, _IOC_SIZE(cmd)); + else if (_IOC_DIR(cmd) & _IOC_WRITE) + Status = !access_ok(VERIFY_READ, argp, _IOC_SIZE(cmd)); + else if (_IOC_NONE == (_IOC_DIR(cmd) & _IOC_NONE)) + Status = STATUS_SUCCESS; + + if (Status) + return -EFAULT; + + if (Adapter->device_removed) + return -EFAULT; + + if (false == Adapter->fw_download_done) { + switch (cmd) { + case IOCTL_MAC_ADDR_REQ: + case IOCTL_LINK_REQ: + case IOCTL_CM_REQUEST: + case IOCTL_SS_INFO_REQ: + case IOCTL_SEND_CONTROL_MESSAGE: + case IOCTL_IDLE_REQ: + case IOCTL_BCM_GPIO_SET_REQUEST: + case IOCTL_BCM_GPIO_STATUS_REQUEST: return -EACCES; + default: + break; } + } - Adapter->bFlashRawRead = TRUE; + Status = vendorextnIoctl(Adapter, cmd, arg); + if (Status != CONTINUE_COMMON_PATH) + return Status; - while (NOB) { - if (NOB > DEFAULT_BUFF_SIZE) - ReadBytes = DEFAULT_BUFF_SIZE; - else - ReadBytes = NOB; + switch (cmd) { + /* Rdms for Swin Idle... */ + case IOCTL_BCM_REGISTER_READ_PRIVATE: + Status = bcm_char_ioctl_reg_read_private(argp, Adapter); + return Status; - /* Reading the data from Flash 2.x */ - Status = BeceemNVMRead(Adapter, (PUINT)pReadBuff, ReadOffset, ReadBytes); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash 2x read err with Status :%d", Status); - break; - } + case IOCTL_BCM_REGISTER_WRITE_PRIVATE: + Status = bcm_char_ioctl_reg_write_private(argp, Adapter); + return Status; - BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, pReadBuff, ReadBytes); + case IOCTL_BCM_REGISTER_READ: + case IOCTL_BCM_EEPROM_REGISTER_READ: + Status = bcm_char_ioctl_eeprom_reg_read(argp, Adapter); + return Status; - Status = copy_to_user(OutPutBuff, pReadBuff, ReadBytes); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy to use failed with status :%d", Status); - up(&Adapter->NVMRdmWrmLock); - kfree(pReadBuff); - return -EFAULT; - } - NOB = NOB - ReadBytes; - if (NOB) { - ReadOffset = ReadOffset + ReadBytes; - OutPutBuff = OutPutBuff + ReadBytes; - } - } - Adapter->bFlashRawRead = false; - up(&Adapter->NVMRdmWrmLock); - kfree(pReadBuff); + case IOCTL_BCM_REGISTER_WRITE: + case IOCTL_BCM_EEPROM_REGISTER_WRITE: + Status = bcm_char_ioctl_eeprom_reg_write(argp, Adapter, cmd); + return Status; + + case IOCTL_BCM_GPIO_SET_REQUEST: + Status = bcm_char_ioctl_gpio_set_request(argp, Adapter); + return Status; + + case BCM_LED_THREAD_STATE_CHANGE_REQ: + Status = bcm_char_ioctl_led_thread_state_change_req(argp, + Adapter); + return Status; + + case IOCTL_BCM_GPIO_STATUS_REQUEST: + Status = bcm_char_ioctl_gpio_status_request(argp, Adapter); + return Status; + + case IOCTL_BCM_GPIO_MULTI_REQUEST: + Status = bcm_char_ioctl_gpio_multi_request(argp, Adapter); + return Status; + + case IOCTL_BCM_GPIO_MODE_REQUEST: + Status = bcm_char_ioctl_gpio_mode_request(argp, Adapter); + return Status; + + case IOCTL_MAC_ADDR_REQ: + case IOCTL_LINK_REQ: + case IOCTL_CM_REQUEST: + case IOCTL_SS_INFO_REQ: + case IOCTL_SEND_CONTROL_MESSAGE: + case IOCTL_IDLE_REQ: + Status = bcm_char_ioctl_misc_request(argp, Adapter); + return Status; + + case IOCTL_BCM_BUFFER_DOWNLOAD_START: + Status = bcm_char_ioctl_buffer_download_start(Adapter); + return Status; + + case IOCTL_BCM_BUFFER_DOWNLOAD: + Status = bcm_char_ioctl_buffer_download(argp, Adapter); + return Status; + + case IOCTL_BCM_BUFFER_DOWNLOAD_STOP: + Status = bcm_char_ioctl_buffer_download_stop(argp, Adapter); + return Status; + + + case IOCTL_BE_BUCKET_SIZE: + Status = 0; + if (get_user(Adapter->BEBucketSize, + (unsigned long __user *)arg)) + Status = -EFAULT; break; - } - case IOCTL_BCM_CNTRLMSG_MASK: { - ULONG RxCntrlMsgBitMask = 0; + case IOCTL_RTPS_BUCKET_SIZE: + Status = 0; + if (get_user(Adapter->rtPSBucketSize, + (unsigned long __user *)arg)) + Status = -EFAULT; + break; - /* Copy Ioctl Buffer structure */ - Status = copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer)); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "copy of Ioctl buffer is failed from user space"); - return -EFAULT; - } + case IOCTL_CHIP_RESET: + Status = bcm_char_ioctl_chip_reset(Adapter); + return Status; - if (IoBuffer.InputLength != sizeof(unsigned long)) { - Status = -EINVAL; - break; - } + case IOCTL_QOS_THRESHOLD: + Status = bcm_char_ioctl_qos_threshold(arg, Adapter); + return Status; - Status = copy_from_user(&RxCntrlMsgBitMask, IoBuffer.InputBuffer, IoBuffer.InputLength); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "copy of control bit mask failed from user space"); + case IOCTL_DUMP_PACKET_INFO: + DumpPackInfo(Adapter); + DumpPhsRules(&Adapter->stBCMPhsContext); + Status = STATUS_SUCCESS; + break; + + case IOCTL_GET_PACK_INFO: + if (copy_to_user(argp, &Adapter->PackInfo, + sizeof(struct bcm_packet_info)*NO_OF_QUEUES)) return -EFAULT; + Status = STATUS_SUCCESS; + break; + + case IOCTL_BCM_SWITCH_TRANSFER_MODE: + Status = bcm_char_ioctl_switch_transfer_mode(argp, Adapter); + return Status; + + case IOCTL_BCM_GET_DRIVER_VERSION: + Status = bcm_char_ioctl_get_driver_version(argp); + return Status; + + case IOCTL_BCM_GET_CURRENT_STATUS: + Status = bcm_char_ioctl_get_current_status(argp, Adapter); + return Status; + + case IOCTL_BCM_SET_MAC_TRACING: + Status = bcm_char_ioctl_set_mac_tracing(argp, Adapter); + return Status; + + case IOCTL_BCM_GET_DSX_INDICATION: + Status = bcm_char_ioctl_get_dsx_indication(argp, Adapter); + return Status; + + case IOCTL_BCM_GET_HOST_MIBS: + Status = bcm_char_ioctl_get_host_mibs(argp, Adapter, pTarang); + return Status; + + case IOCTL_BCM_WAKE_UP_DEVICE_FROM_IDLE: + if ((false == Adapter->bTriedToWakeUpFromlowPowerMode) && + (TRUE == Adapter->IdleMode)) { + Adapter->usIdleModePattern = ABORT_IDLE_MODE; + Adapter->bWakeUpDevice = TRUE; + wake_up(&Adapter->process_rx_cntrlpkt); } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\n Got user defined cntrl msg bit mask :%lx", RxCntrlMsgBitMask); - pTarang->RxCntrlMsgBitMask = RxCntrlMsgBitMask; - } - break; - case IOCTL_BCM_GET_DEVICE_DRIVER_INFO: { - struct bcm_driver_info DevInfo; + Status = STATUS_SUCCESS; + break; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Called IOCTL_BCM_GET_DEVICE_DRIVER_INFO\n"); + case IOCTL_BCM_BULK_WRM: + Status = bcm_char_ioctl_bulk_wrm(argp, Adapter, cmd); + return Status; - memset(&DevInfo, 0, sizeof(DevInfo)); - DevInfo.MaxRDMBufferSize = BUFFER_4K; - DevInfo.u32DSDStartOffset = EEPROM_CALPARAM_START; - DevInfo.u32RxAlignmentCorrection = 0; - DevInfo.u32NVMType = Adapter->eNVMType; - DevInfo.u32InterfaceType = BCM_USB; + case IOCTL_BCM_GET_NVM_SIZE: + Status = bcm_char_ioctl_get_nvm_size(argp, Adapter); + return Status; - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; + case IOCTL_BCM_CAL_INIT: + Status = bcm_char_ioctl_cal_init(argp, Adapter); + return Status; - if (IoBuffer.OutputLength < sizeof(DevInfo)) - return -EINVAL; + case IOCTL_BCM_SET_DEBUG: + Status = bcm_char_ioctl_set_debug(argp, Adapter); + return Status; - if (copy_to_user(IoBuffer.OutputBuffer, &DevInfo, sizeof(DevInfo))) - return -EFAULT; - } - break; + case IOCTL_BCM_NVM_READ: + case IOCTL_BCM_NVM_WRITE: + Status = bcm_char_ioctl_nvm_rw(argp, Adapter, cmd); + return Status; + + case IOCTL_BCM_FLASH2X_SECTION_READ: + Status = bcm_char_ioctl_flash2x_section_read(argp, Adapter); + return Status; - case IOCTL_BCM_TIME_SINCE_NET_ENTRY: { - struct bcm_time_elapsed stTimeElapsedSinceNetEntry = {0}; + case IOCTL_BCM_FLASH2X_SECTION_WRITE: + Status = bcm_char_ioctl_flash2x_section_write(argp, Adapter); + return Status; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_TIME_SINCE_NET_ENTRY called"); + case IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP: + Status = bcm_char_ioctl_flash2x_section_bitmap(argp, Adapter); + return Status; - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; + case IOCTL_BCM_SET_ACTIVE_SECTION: + Status = bcm_char_ioctl_set_active_section(argp, Adapter); + return Status; - if (IoBuffer.OutputLength < sizeof(struct bcm_time_elapsed)) - return -EINVAL; + case IOCTL_BCM_IDENTIFY_ACTIVE_SECTION: + /* Right Now we are taking care of only DSD */ + Adapter->bAllDSDWriteAllow = false; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "IOCTL_BCM_IDENTIFY_ACTIVE_SECTION called"); + Status = STATUS_SUCCESS; + break; - stTimeElapsedSinceNetEntry.ul64TimeElapsedSinceNetEntry = get_seconds() - Adapter->liTimeSinceLastNetEntry; + case IOCTL_BCM_COPY_SECTION: + Status = bcm_char_ioctl_copy_section(argp, Adapter); + return Status; - if (copy_to_user(IoBuffer.OutputBuffer, &stTimeElapsedSinceNetEntry, sizeof(struct bcm_time_elapsed))) - return -EFAULT; - } - break; + case IOCTL_BCM_GET_FLASH_CS_INFO: + Status = bcm_char_ioctl_get_flash_cs_info(argp, Adapter); + return Status; + + case IOCTL_BCM_SELECT_DSD: + Status = bcm_char_ioctl_select_dsd(argp, Adapter); + return Status; + + case IOCTL_BCM_NVM_RAW_READ: + Status = bcm_char_ioctl_nvm_raw_read(argp, Adapter); + return Status; + + case IOCTL_BCM_CNTRLMSG_MASK: + Status = bcm_char_ioctl_cntrlmsg_mask(argp, Adapter, pTarang); + return Status; + + case IOCTL_BCM_GET_DEVICE_DRIVER_INFO: + Status = bcm_char_ioctl_get_device_driver_info(argp, Adapter); + return Status; + + case IOCTL_BCM_TIME_SINCE_NET_ENTRY: + Status = bcm_char_ioctl_time_since_net_entry(argp, Adapter); + return Status; case IOCTL_CLOSE_NOTIFICATION: - 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, + "IOCTL_CLOSE_NOTIFICATION"); break; default: @@ -2080,8 +2630,8 @@ int register_control_device_interface(struct bcm_mini_adapter *Adapter) } Adapter->pstCreatedClassDevice = device_create(bcm_class, NULL, - MKDEV(Adapter->major, 0), - Adapter, DEV_NAME); + MKDEV(Adapter->major, 0), + Adapter, DEV_NAME); if (IS_ERR(Adapter->pstCreatedClassDevice)) { pr_err(DRV_NAME ": class device create failed\n"); diff --git a/drivers/staging/bcm/Bcmnet.c b/drivers/staging/bcm/Bcmnet.c index 8dfdd2732bd..95a2358267b 100644 --- a/drivers/staging/bcm/Bcmnet.c +++ b/drivers/staging/bcm/Bcmnet.c @@ -40,7 +40,7 @@ static INT bcm_close(struct net_device *dev) } static u16 bcm_select_queue(struct net_device *dev, struct sk_buff *skb, - void *accel_priv) + void *accel_priv, select_queue_fallback_t fallback) { return ClassifyPacket(netdev_priv(dev), skb); } diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index cc91b5e934a..fb1d932c5d7 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -13,7 +13,19 @@ enum E_CLASSIFIER_ACTION { eDeleteClassifier }; -static ULONG GetNextTargetBufferLocation(struct bcm_mini_adapter *Adapter, B_UINT16 tid); +static ULONG GetNextTargetBufferLocation(struct bcm_mini_adapter *Adapter, + B_UINT16 tid); +static void restore_endianess_of_pstClassifierEntry( + struct bcm_classifier_rule *pstClassifierEntry, + enum bcm_ipaddr_context eIpAddrContext); + +static void apply_phs_rule_to_all_classifiers( + register struct bcm_mini_adapter *Adapter, + register UINT uiSearchRuleIndex, + USHORT uVCID, + struct bcm_phs_rule *sPhsRule, + struct bcm_phs_rules *cPhsRule, + struct bcm_add_indication_alt *pstAddIndication); /************************************************************ * Function - SearchSfid @@ -67,13 +79,16 @@ static int SearchFreeSfid(struct bcm_mini_adapter *Adapter) * B_UINT16 uiClassifierID - The classifier ID to be searched * Return: int :Classifier table index of matching entry */ -static int SearchClsid(struct bcm_mini_adapter *Adapter, ULONG ulSFID, B_UINT16 uiClassifierID) +static int SearchClsid(struct bcm_mini_adapter *Adapter, + ULONG ulSFID, + B_UINT16 uiClassifierID) { int i; for (i = 0; i < MAX_CLASSIFIERS; i++) { if ((Adapter->astClassifierTable[i].bUsed) && - (Adapter->astClassifierTable[i].uiClassifierRuleIndex == uiClassifierID) && + (Adapter->astClassifierTable[i].uiClassifierRuleIndex + == uiClassifierID) && (Adapter->astClassifierTable[i].ulSFID == ulSFID)) return i; } @@ -98,7 +113,8 @@ static int SearchFreeClsid(struct bcm_mini_adapter *Adapter /**Adapter Context*/ return MAX_CLASSIFIERS+1; } -static VOID deleteSFBySfid(struct bcm_mini_adapter *Adapter, UINT uiSearchRuleIndex) +static VOID deleteSFBySfid(struct bcm_mini_adapter *Adapter, + UINT uiSearchRuleIndex) { /* deleting all the packet held in the SF */ flush_queue(Adapter, uiSearchRuleIndex); @@ -107,7 +123,8 @@ static VOID deleteSFBySfid(struct bcm_mini_adapter *Adapter, UINT uiSearchRuleIn DeleteAllClassifiersForSF(Adapter, uiSearchRuleIndex); /* Resetting only MIBS related entries in the SF */ - memset((PVOID)&Adapter->PackInfo[uiSearchRuleIndex], 0, sizeof(struct bcm_mibs_table)); + memset((PVOID)&Adapter->PackInfo[uiSearchRuleIndex], 0, + sizeof(struct bcm_mibs_table)); } static inline VOID @@ -125,70 +142,109 @@ CopyIpAddrToClassifier(struct bcm_classifier_rule *pstClassifierEntry, nSizeOfIPAddressInBytes = IPV6_ADDRESS_SIZEINBYTES; /* Destination Ip Address */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Ip Address Range Length:0x%X ", u8IpAddressLen); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Ip Address Range Length:0x%X ", u8IpAddressLen); if ((bIpVersion6 ? (IPV6_ADDRESS_SIZEINBYTES * MAX_IP_RANGE_LENGTH * 2) : (TOTAL_MASKED_ADDRESS_IN_BYTES)) >= u8IpAddressLen) { + + union u_ip_address *st_dest_ip = + &pstClassifierEntry->stDestIpAddress; + + union u_ip_address *st_src_ip = + &pstClassifierEntry->stSrcIpAddress; + /* * checking both the mask and address togethor in Classification. * So length will be : TotalLengthInBytes/nSizeOfIPAddressInBytes * 2 * (nSizeOfIPAddressInBytes for address and nSizeOfIPAddressInBytes for mask) */ if (eIpAddrContext == eDestIpAddress) { - pstClassifierEntry->ucIPDestinationAddressLength = u8IpAddressLen/(nSizeOfIPAddressInBytes * 2); + pstClassifierEntry->ucIPDestinationAddressLength = + u8IpAddressLen/(nSizeOfIPAddressInBytes * 2); if (bIpVersion6) { - ptrClassifierIpAddress = pstClassifierEntry->stDestIpAddress.ucIpv6Address; - ptrClassifierIpMask = pstClassifierEntry->stDestIpAddress.ucIpv6Mask; + ptrClassifierIpAddress = + st_dest_ip->ucIpv6Address; + ptrClassifierIpMask = + st_dest_ip->ucIpv6Mask; } else { - ptrClassifierIpAddress = pstClassifierEntry->stDestIpAddress.ucIpv4Address; - ptrClassifierIpMask = pstClassifierEntry->stDestIpAddress.ucIpv4Mask; + ptrClassifierIpAddress = + st_dest_ip->ucIpv4Address; + ptrClassifierIpMask = + st_dest_ip->ucIpv4Mask; } } else if (eIpAddrContext == eSrcIpAddress) { - pstClassifierEntry->ucIPSourceAddressLength = u8IpAddressLen/(nSizeOfIPAddressInBytes * 2); + pstClassifierEntry->ucIPSourceAddressLength = + u8IpAddressLen/(nSizeOfIPAddressInBytes * 2); if (bIpVersion6) { - ptrClassifierIpAddress = pstClassifierEntry->stSrcIpAddress.ucIpv6Address; - ptrClassifierIpMask = pstClassifierEntry->stSrcIpAddress.ucIpv6Mask; + ptrClassifierIpAddress = + st_src_ip->ucIpv6Address; + ptrClassifierIpMask = st_src_ip->ucIpv6Mask; } else { - ptrClassifierIpAddress = pstClassifierEntry->stSrcIpAddress.ucIpv4Address; - ptrClassifierIpMask = pstClassifierEntry->stSrcIpAddress.ucIpv4Mask; + ptrClassifierIpAddress = + st_src_ip->ucIpv4Address; + ptrClassifierIpMask = st_src_ip->ucIpv4Mask; } } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Address Length:0x%X\n", pstClassifierEntry->ucIPDestinationAddressLength); - while ((u8IpAddressLen >= nSizeOfIPAddressInBytes) && (i < MAX_IP_RANGE_LENGTH)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Address Length:0x%X\n", + pstClassifierEntry->ucIPDestinationAddressLength); + while ((u8IpAddressLen >= nSizeOfIPAddressInBytes) + && (i < MAX_IP_RANGE_LENGTH)) { memcpy(ptrClassifierIpAddress + (i * nSizeOfIPAddressInBytes), - (pu8IpAddressMaskSrc+(i*nSizeOfIPAddressInBytes*2)), + (pu8IpAddressMaskSrc + + (i * nSizeOfIPAddressInBytes * 2)), nSizeOfIPAddressInBytes); if (!bIpVersion6) { if (eIpAddrContext == eSrcIpAddress) { - pstClassifierEntry->stSrcIpAddress.ulIpv4Addr[i] = ntohl(pstClassifierEntry->stSrcIpAddress.ulIpv4Addr[i]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Src Ip Address:0x%luX ", - pstClassifierEntry->stSrcIpAddress.ulIpv4Addr[i]); + st_src_ip->ulIpv4Addr[i] = + ntohl(st_src_ip->ulIpv4Addr[i]); + BCM_DEBUG_PRINT(Adapter, + DBG_TYPE_OTHERS, + CONN_MSG, + DBG_LVL_ALL, + "Src Ip Address:0x%luX ", + st_src_ip->ulIpv4Addr[i]); } else if (eIpAddrContext == eDestIpAddress) { - pstClassifierEntry->stDestIpAddress.ulIpv4Addr[i] = ntohl(pstClassifierEntry->stDestIpAddress.ulIpv4Addr[i]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Dest Ip Address:0x%luX ", - pstClassifierEntry->stDestIpAddress.ulIpv4Addr[i]); + st_dest_ip->ulIpv4Addr[i] = + ntohl(st_dest_ip->ulIpv4Addr[i]); + BCM_DEBUG_PRINT(Adapter, + DBG_TYPE_OTHERS, + CONN_MSG, + DBG_LVL_ALL, + "Dest Ip Address:0x%luX ", + st_dest_ip->ulIpv4Addr[i]); } } u8IpAddressLen -= nSizeOfIPAddressInBytes; if (u8IpAddressLen >= nSizeOfIPAddressInBytes) { memcpy(ptrClassifierIpMask + (i * nSizeOfIPAddressInBytes), - (pu8IpAddressMaskSrc+nSizeOfIPAddressInBytes + - (i*nSizeOfIPAddressInBytes*2)), + (pu8IpAddressMaskSrc + + nSizeOfIPAddressInBytes + + (i * nSizeOfIPAddressInBytes * 2)), nSizeOfIPAddressInBytes); if (!bIpVersion6) { if (eIpAddrContext == eSrcIpAddress) { - pstClassifierEntry->stSrcIpAddress.ulIpv4Mask[i] = - ntohl(pstClassifierEntry->stSrcIpAddress.ulIpv4Mask[i]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Src Ip Mask Address:0x%luX ", - pstClassifierEntry->stSrcIpAddress.ulIpv4Mask[i]); + st_src_ip->ulIpv4Mask[i] = + ntohl(st_src_ip->ulIpv4Mask[i]); + BCM_DEBUG_PRINT(Adapter, + DBG_TYPE_OTHERS, + CONN_MSG, + DBG_LVL_ALL, + "Src Ip Mask Address:0x%luX ", + st_src_ip->ulIpv4Mask[i]); } else if (eIpAddrContext == eDestIpAddress) { - pstClassifierEntry->stDestIpAddress.ulIpv4Mask[i] = - ntohl(pstClassifierEntry->stDestIpAddress.ulIpv4Mask[i]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Dest Ip Mask Address:0x%luX ", - pstClassifierEntry->stDestIpAddress.ulIpv4Mask[i]); + st_dest_ip->ulIpv4Mask[i] = + ntohl(st_dest_ip->ulIpv4Mask[i]); + BCM_DEBUG_PRINT(Adapter, + DBG_TYPE_OTHERS, + CONN_MSG, + DBG_LVL_ALL, + "Dest Ip Mask Address:0x%luX ", + st_dest_ip->ulIpv4Mask[i]); } } u8IpAddressLen -= nSizeOfIPAddressInBytes; @@ -200,15 +256,10 @@ CopyIpAddrToClassifier(struct bcm_classifier_rule *pstClassifierEntry, } if (bIpVersion6) { /* Restore EndianNess of Struct */ - for (i = 0; i < MAX_IP_RANGE_LENGTH * 4; i++) { - if (eIpAddrContext == eSrcIpAddress) { - pstClassifierEntry->stSrcIpAddress.ulIpv6Addr[i] = ntohl(pstClassifierEntry->stSrcIpAddress.ulIpv6Addr[i]); - pstClassifierEntry->stSrcIpAddress.ulIpv6Mask[i] = ntohl(pstClassifierEntry->stSrcIpAddress.ulIpv6Mask[i]); - } else if (eIpAddrContext == eDestIpAddress) { - pstClassifierEntry->stDestIpAddress.ulIpv6Addr[i] = ntohl(pstClassifierEntry->stDestIpAddress.ulIpv6Addr[i]); - pstClassifierEntry->stDestIpAddress.ulIpv6Mask[i] = ntohl(pstClassifierEntry->stDestIpAddress.ulIpv6Mask[i]); - } - } + restore_endianess_of_pstClassifierEntry( + pstClassifierEntry, + eIpAddrContext + ); } } } @@ -216,16 +267,20 @@ CopyIpAddrToClassifier(struct bcm_classifier_rule *pstClassifierEntry, void ClearTargetDSXBuffer(struct bcm_mini_adapter *Adapter, B_UINT16 TID, bool bFreeAll) { int i; + struct bcm_targetdsx_buffer *curr_buf; for (i = 0; i < Adapter->ulTotalTargetBuffersAvailable; i++) { - if (Adapter->astTargetDsxBuffer[i].valid) + curr_buf = &Adapter->astTargetDsxBuffer[i]; + + if (curr_buf->valid) continue; - if ((bFreeAll) || (Adapter->astTargetDsxBuffer[i].tid == TID)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "ClearTargetDSXBuffer: found tid %d buffer cleared %lx\n", - TID, Adapter->astTargetDsxBuffer[i].ulTargetDsxBuffer); - Adapter->astTargetDsxBuffer[i].valid = 1; - Adapter->astTargetDsxBuffer[i].tid = 0; + if ((bFreeAll) || (curr_buf->tid == TID)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "ClearTargetDSXBuffer: found tid %d buffer cleared %lx\n", + TID, curr_buf->ulTargetDsxBuffer); + curr_buf->valid = 1; + curr_buf->tid = 0; Adapter->ulFreeTargetBufferCnt++; } } @@ -235,7 +290,10 @@ void ClearTargetDSXBuffer(struct bcm_mini_adapter *Adapter, B_UINT16 TID, bool b * @ingroup ctrl_pkt_functions * copy classifier rule into the specified SF index */ -static inline VOID CopyClassifierRuleToSF(struct bcm_mini_adapter *Adapter, struct bcm_convergence_types *psfCSType, UINT uiSearchRuleIndex, UINT nClassifierIndex) +static inline VOID CopyClassifierRuleToSF(struct bcm_mini_adapter *Adapter, + struct bcm_convergence_types *psfCSType, + UINT uiSearchRuleIndex, + UINT nClassifierIndex) { struct bcm_classifier_rule *pstClassifierEntry = NULL; /* VOID *pvPhsContext = NULL; */ @@ -243,12 +301,16 @@ static inline VOID CopyClassifierRuleToSF(struct bcm_mini_adapter *Adapter, stru /* UCHAR ucProtocolLength=0; */ /* ULONG ulPhsStatus; */ + struct bcm_packet_class_rules *pack_class_rule = + &psfCSType->cCPacketClassificationRule; + if (Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value == 0 || nClassifierIndex > (MAX_CLASSIFIERS-1)) return; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Storing Classifier Rule Index : %X", - ntohs(psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex)); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Storing Classifier Rule Index : %X", + ntohs(pack_class_rule->u16PacketClassificationRuleIndex)); if (nClassifierIndex > MAX_CLASSIFIERS-1) return; @@ -256,106 +318,152 @@ static inline VOID CopyClassifierRuleToSF(struct bcm_mini_adapter *Adapter, stru pstClassifierEntry = &Adapter->astClassifierTable[nClassifierIndex]; if (pstClassifierEntry) { /* Store if Ipv6 */ - pstClassifierEntry->bIpv6Protocol = (Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion == IPV6) ? TRUE : false; + pstClassifierEntry->bIpv6Protocol = + (Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion == IPV6) ? TRUE : false; /* Destinaiton Port */ - pstClassifierEntry->ucDestPortRangeLength = psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRangeLength / 4; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Destination Port Range Length:0x%X ", pstClassifierEntry->ucDestPortRangeLength); + pstClassifierEntry->ucDestPortRangeLength = + pack_class_rule->u8ProtocolDestPortRangeLength / 4; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Destination Port Range Length:0x%X ", + pstClassifierEntry->ucDestPortRangeLength); - if (psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRangeLength <= MAX_PORT_RANGE) { + if (pack_class_rule->u8ProtocolDestPortRangeLength <= MAX_PORT_RANGE) { for (i = 0; i < (pstClassifierEntry->ucDestPortRangeLength); i++) { - pstClassifierEntry->usDestPortRangeLo[i] = *((PUSHORT)(psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange+i)); + pstClassifierEntry->usDestPortRangeLo[i] = + *((PUSHORT)(pack_class_rule->u8ProtocolDestPortRange+i)); pstClassifierEntry->usDestPortRangeHi[i] = - *((PUSHORT)(psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange+2+i)); - pstClassifierEntry->usDestPortRangeLo[i] = ntohs(pstClassifierEntry->usDestPortRangeLo[i]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Destination Port Range Lo:0x%X ", + *((PUSHORT)(pack_class_rule->u8ProtocolDestPortRange+2+i)); + pstClassifierEntry->usDestPortRangeLo[i] = + ntohs(pstClassifierEntry->usDestPortRangeLo[i]); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + CONN_MSG, DBG_LVL_ALL, + "Destination Port Range Lo:0x%X ", pstClassifierEntry->usDestPortRangeLo[i]); - pstClassifierEntry->usDestPortRangeHi[i] = ntohs(pstClassifierEntry->usDestPortRangeHi[i]); + pstClassifierEntry->usDestPortRangeHi[i] = + ntohs(pstClassifierEntry->usDestPortRangeHi[i]); } } else { pstClassifierEntry->ucDestPortRangeLength = 0; } /* Source Port */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Source Port Range Length:0x%X ", - psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRangeLength); - if (psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRangeLength <= MAX_PORT_RANGE) { - pstClassifierEntry->ucSrcPortRangeLength = psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRangeLength/4; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Source Port Range Length:0x%X ", + pack_class_rule->u8ProtocolSourcePortRangeLength); + if (pack_class_rule->u8ProtocolSourcePortRangeLength <= MAX_PORT_RANGE) { + pstClassifierEntry->ucSrcPortRangeLength = + pack_class_rule->u8ProtocolSourcePortRangeLength/4; for (i = 0; i < (pstClassifierEntry->ucSrcPortRangeLength); i++) { pstClassifierEntry->usSrcPortRangeLo[i] = - *((PUSHORT)(psfCSType->cCPacketClassificationRule. + *((PUSHORT)(pack_class_rule-> u8ProtocolSourcePortRange+i)); pstClassifierEntry->usSrcPortRangeHi[i] = - *((PUSHORT)(psfCSType->cCPacketClassificationRule. + *((PUSHORT)(pack_class_rule-> u8ProtocolSourcePortRange+2+i)); pstClassifierEntry->usSrcPortRangeLo[i] = ntohs(pstClassifierEntry->usSrcPortRangeLo[i]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Source Port Range Lo:0x%X ", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + CONN_MSG, DBG_LVL_ALL, + "Source Port Range Lo:0x%X ", pstClassifierEntry->usSrcPortRangeLo[i]); - pstClassifierEntry->usSrcPortRangeHi[i] = ntohs(pstClassifierEntry->usSrcPortRangeHi[i]); + pstClassifierEntry->usSrcPortRangeHi[i] = + ntohs(pstClassifierEntry->usSrcPortRangeHi[i]); } } /* Destination Ip Address and Mask */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Ip Destination Parameters : "); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Ip Destination Parameters : "); CopyIpAddrToClassifier(pstClassifierEntry, - psfCSType->cCPacketClassificationRule.u8IPDestinationAddressLength, - psfCSType->cCPacketClassificationRule.u8IPDestinationAddress, + pack_class_rule->u8IPDestinationAddressLength, + pack_class_rule->u8IPDestinationAddress, (Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion == IPV6) ? TRUE : false, eDestIpAddress); /* Source Ip Address and Mask */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Ip Source Parameters : "); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Ip Source Parameters : "); CopyIpAddrToClassifier(pstClassifierEntry, - psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddressLength, - psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddress, + pack_class_rule->u8IPMaskedSourceAddressLength, + pack_class_rule->u8IPMaskedSourceAddress, (Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion == IPV6) ? TRUE : false, eSrcIpAddress); /* TOS */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "TOS Length:0x%X ", psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength); - if (psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength == 3) { - pstClassifierEntry->ucIPTypeOfServiceLength = psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength; - pstClassifierEntry->ucTosLow = psfCSType->cCPacketClassificationRule.u8IPTypeOfService[0]; - pstClassifierEntry->ucTosHigh = psfCSType->cCPacketClassificationRule.u8IPTypeOfService[1]; - pstClassifierEntry->ucTosMask = psfCSType->cCPacketClassificationRule.u8IPTypeOfService[2]; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "TOS Length:0x%X ", + pack_class_rule->u8IPTypeOfServiceLength); + if (pack_class_rule->u8IPTypeOfServiceLength == 3) { + pstClassifierEntry->ucIPTypeOfServiceLength = + pack_class_rule->u8IPTypeOfServiceLength; + pstClassifierEntry->ucTosLow = + pack_class_rule->u8IPTypeOfService[0]; + pstClassifierEntry->ucTosHigh = + pack_class_rule->u8IPTypeOfService[1]; + pstClassifierEntry->ucTosMask = + pack_class_rule->u8IPTypeOfService[2]; pstClassifierEntry->bTOSValid = TRUE; } - if (psfCSType->cCPacketClassificationRule.u8Protocol == 0) { + if (pack_class_rule->u8Protocol == 0) { /* we didn't get protocol field filled in by the BS */ pstClassifierEntry->ucProtocolLength = 0; } else { pstClassifierEntry->ucProtocolLength = 1; /* 1 valid protocol */ } - pstClassifierEntry->ucProtocol[0] = psfCSType->cCPacketClassificationRule.u8Protocol; - pstClassifierEntry->u8ClassifierRulePriority = psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority; + pstClassifierEntry->ucProtocol[0] = pack_class_rule->u8Protocol; + pstClassifierEntry->u8ClassifierRulePriority = + pack_class_rule->u8ClassifierRulePriority; /* store the classifier rule ID and set this classifier entry as valid */ - pstClassifierEntry->ucDirection = Adapter->PackInfo[uiSearchRuleIndex].ucDirection; - pstClassifierEntry->uiClassifierRuleIndex = ntohs(psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex); - pstClassifierEntry->usVCID_Value = Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value; - pstClassifierEntry->ulSFID = Adapter->PackInfo[uiSearchRuleIndex].ulSFID; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Search Index %d Dir: %d, Index: %d, Vcid: %d\n", - uiSearchRuleIndex, pstClassifierEntry->ucDirection, + pstClassifierEntry->ucDirection = + Adapter->PackInfo[uiSearchRuleIndex].ucDirection; + pstClassifierEntry->uiClassifierRuleIndex = + ntohs(pack_class_rule->u16PacketClassificationRuleIndex); + pstClassifierEntry->usVCID_Value = + Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value; + pstClassifierEntry->ulSFID = + Adapter->PackInfo[uiSearchRuleIndex].ulSFID; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Search Index %d Dir: %d, Index: %d, Vcid: %d\n", + uiSearchRuleIndex, + pstClassifierEntry->ucDirection, pstClassifierEntry->uiClassifierRuleIndex, pstClassifierEntry->usVCID_Value); - if (psfCSType->cCPacketClassificationRule.u8AssociatedPHSI) - pstClassifierEntry->u8AssociatedPHSI = psfCSType->cCPacketClassificationRule.u8AssociatedPHSI; + if (pack_class_rule->u8AssociatedPHSI) + pstClassifierEntry->u8AssociatedPHSI = + pack_class_rule->u8AssociatedPHSI; /* Copy ETH CS Parameters */ - pstClassifierEntry->ucEthCSSrcMACLen = (psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddressLength); - memcpy(pstClassifierEntry->au8EThCSSrcMAC, psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress, MAC_ADDRESS_SIZE); - memcpy(pstClassifierEntry->au8EThCSSrcMACMask, psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress + MAC_ADDRESS_SIZE, MAC_ADDRESS_SIZE); - pstClassifierEntry->ucEthCSDestMACLen = (psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength); - memcpy(pstClassifierEntry->au8EThCSDestMAC, psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress, MAC_ADDRESS_SIZE); - memcpy(pstClassifierEntry->au8EThCSDestMACMask, psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress + MAC_ADDRESS_SIZE, MAC_ADDRESS_SIZE); - pstClassifierEntry->ucEtherTypeLen = (psfCSType->cCPacketClassificationRule.u8EthertypeLength); - memcpy(pstClassifierEntry->au8EthCSEtherType, psfCSType->cCPacketClassificationRule.u8Ethertype, NUM_ETHERTYPE_BYTES); - memcpy(pstClassifierEntry->usUserPriority, &psfCSType->cCPacketClassificationRule.u16UserPriority, 2); - pstClassifierEntry->usVLANID = ntohs(psfCSType->cCPacketClassificationRule.u16VLANID); - pstClassifierEntry->usValidityBitMap = ntohs(psfCSType->cCPacketClassificationRule.u16ValidityBitMap); + pstClassifierEntry->ucEthCSSrcMACLen = + (pack_class_rule->u8EthernetSourceMACAddressLength); + memcpy(pstClassifierEntry->au8EThCSSrcMAC, + pack_class_rule->u8EthernetSourceMACAddress, + MAC_ADDRESS_SIZE); + memcpy(pstClassifierEntry->au8EThCSSrcMACMask, + pack_class_rule->u8EthernetSourceMACAddress + + MAC_ADDRESS_SIZE, MAC_ADDRESS_SIZE); + pstClassifierEntry->ucEthCSDestMACLen = + (pack_class_rule->u8EthernetDestMacAddressLength); + memcpy(pstClassifierEntry->au8EThCSDestMAC, + pack_class_rule->u8EthernetDestMacAddress, + MAC_ADDRESS_SIZE); + memcpy(pstClassifierEntry->au8EThCSDestMACMask, + pack_class_rule->u8EthernetDestMacAddress + + MAC_ADDRESS_SIZE, MAC_ADDRESS_SIZE); + pstClassifierEntry->ucEtherTypeLen = + (pack_class_rule->u8EthertypeLength); + memcpy(pstClassifierEntry->au8EthCSEtherType, + pack_class_rule->u8Ethertype, + NUM_ETHERTYPE_BYTES); + memcpy(pstClassifierEntry->usUserPriority, + &pack_class_rule->u16UserPriority, 2); + pstClassifierEntry->usVLANID = + ntohs(pack_class_rule->u16VLANID); + pstClassifierEntry->usValidityBitMap = + ntohs(pack_class_rule->u16ValidityBitMap); pstClassifierEntry->bUsed = TRUE; } @@ -364,7 +472,8 @@ static inline VOID CopyClassifierRuleToSF(struct bcm_mini_adapter *Adapter, stru /* * @ingroup ctrl_pkt_functions */ -static inline VOID DeleteClassifierRuleFromSF(struct bcm_mini_adapter *Adapter, UINT uiSearchRuleIndex, UINT nClassifierIndex) +static inline VOID DeleteClassifierRuleFromSF(struct bcm_mini_adapter *Adapter, + UINT uiSearchRuleIndex, UINT nClassifierIndex) { struct bcm_classifier_rule *pstClassifierEntry = NULL; B_UINT16 u16PacketClassificationRuleIndex; @@ -380,22 +489,26 @@ static inline VOID DeleteClassifierRuleFromSF(struct bcm_mini_adapter *Adapter, if (usVCID == 0) return; - u16PacketClassificationRuleIndex = Adapter->astClassifierTable[nClassifierIndex].uiClassifierRuleIndex; + u16PacketClassificationRuleIndex = + Adapter->astClassifierTable[nClassifierIndex].uiClassifierRuleIndex; pstClassifierEntry = &Adapter->astClassifierTable[nClassifierIndex]; if (pstClassifierEntry) { pstClassifierEntry->bUsed = false; pstClassifierEntry->uiClassifierRuleIndex = 0; - memset(pstClassifierEntry, 0, sizeof(struct bcm_classifier_rule)); + memset(pstClassifierEntry, 0, + sizeof(struct bcm_classifier_rule)); /* Delete the PHS Rule for this classifier */ - PhsDeleteClassifierRule(&Adapter->stBCMPhsContext, usVCID, u16PacketClassificationRuleIndex); + PhsDeleteClassifierRule(&Adapter->stBCMPhsContext, usVCID, + u16PacketClassificationRuleIndex); } } /* * @ingroup ctrl_pkt_functions */ -VOID DeleteAllClassifiersForSF(struct bcm_mini_adapter *Adapter, UINT uiSearchRuleIndex) +VOID DeleteAllClassifiersForSF(struct bcm_mini_adapter *Adapter, + UINT uiSearchRuleIndex) { struct bcm_classifier_rule *pstClassifierEntry = NULL; int i; @@ -414,7 +527,8 @@ VOID DeleteAllClassifiersForSF(struct bcm_mini_adapter *Adapter, UINT uiSearchRu pstClassifierEntry = &Adapter->astClassifierTable[i]; if (pstClassifierEntry->bUsed) - DeleteClassifierRuleFromSF(Adapter, uiSearchRuleIndex, i); + DeleteClassifierRuleFromSF(Adapter, + uiSearchRuleIndex, i); } } @@ -441,324 +555,262 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* <Pointer int i; struct bcm_convergence_types *psfCSType = NULL; struct bcm_phs_rule sPhsRule; - USHORT uVCID = Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value; + struct bcm_packet_info *curr_packinfo = + &Adapter->PackInfo[uiSearchRuleIndex]; + USHORT uVCID = curr_packinfo->usVCID_Value; UINT UGIValue = 0; - Adapter->PackInfo[uiSearchRuleIndex].bValid = TRUE; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Search Rule Index = %d\n", uiSearchRuleIndex); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "%s: SFID= %x ", __func__, ntohl(psfLocalSet->u32SFID)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Updating Queue %d", uiSearchRuleIndex); + curr_packinfo->bValid = TRUE; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Search Rule Index = %d\n", uiSearchRuleIndex); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "%s: SFID= %x ", __func__, ntohl(psfLocalSet->u32SFID)); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Updating Queue %d", uiSearchRuleIndex); ulSFID = ntohl(psfLocalSet->u32SFID); /* Store IP Version used */ /* Get The Version Of IP used (IPv6 or IPv4) from CSSpecification field of SF */ - Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = 0; - Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = 0; + curr_packinfo->bIPCSSupport = 0; + curr_packinfo->bEthCSSupport = 0; /* Enable IP/ETh CS Support As Required */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "CopyToAdapter : u8CSSpecification : %X\n", psfLocalSet->u8CSSpecification); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "CopyToAdapter : u8CSSpecification : %X\n", + psfLocalSet->u8CSSpecification); switch (psfLocalSet->u8CSSpecification) { case eCSPacketIPV4: - { - Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV4_CS; + curr_packinfo->bIPCSSupport = IPV4_CS; break; - } case eCSPacketIPV6: - { - Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV6_CS; + curr_packinfo->bIPCSSupport = IPV6_CS; break; - } case eCS802_3PacketEthernet: case eCS802_1QPacketVLAN: - { - Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = ETH_CS_802_3; + curr_packinfo->bEthCSSupport = ETH_CS_802_3; break; - } case eCSPacketIPV4Over802_1QVLAN: case eCSPacketIPV4Over802_3Ethernet: - { - Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV4_CS; - Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = ETH_CS_802_3; + curr_packinfo->bIPCSSupport = IPV4_CS; + curr_packinfo->bEthCSSupport = ETH_CS_802_3; break; - } case eCSPacketIPV6Over802_1QVLAN: case eCSPacketIPV6Over802_3Ethernet: - { - Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV6_CS; - Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = ETH_CS_802_3; + curr_packinfo->bIPCSSupport = IPV6_CS; + curr_packinfo->bEthCSSupport = ETH_CS_802_3; break; - } default: - { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Error in value of CS Classification.. setting default to IP CS\n"); - Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV4_CS; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Error in value of CS Classification.. setting default to IP CS\n"); + curr_packinfo->bIPCSSupport = IPV4_CS; break; } - } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "CopyToAdapter : Queue No : %X ETH CS Support : %X , IP CS Support : %X\n", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "CopyToAdapter : Queue No : %X ETH CS Support : %X , IP CS Support : %X\n", uiSearchRuleIndex, - Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport, - Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport); + curr_packinfo->bEthCSSupport, + curr_packinfo->bIPCSSupport); /* Store IP Version used */ /* Get The Version Of IP used (IPv6 or IPv4) from CSSpecification field of SF */ - if (Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport == IPV6_CS) - Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion = IPV6; + if (curr_packinfo->bIPCSSupport == IPV6_CS) + curr_packinfo->ucIpVersion = IPV6; else - Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion = IPV4; + curr_packinfo->ucIpVersion = IPV4; /* To ensure that the ETH CS code doesn't gets executed if the BS doesn't supports ETH CS */ if (!Adapter->bETHCSEnabled) - Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = 0; + curr_packinfo->bEthCSSupport = 0; if (psfLocalSet->u8ServiceClassNameLength > 0 && psfLocalSet->u8ServiceClassNameLength < 32) - memcpy(Adapter->PackInfo[uiSearchRuleIndex].ucServiceClassName, psfLocalSet->u8ServiceClassName, psfLocalSet->u8ServiceClassNameLength); + memcpy(curr_packinfo->ucServiceClassName, + psfLocalSet->u8ServiceClassName, + psfLocalSet->u8ServiceClassNameLength); - Adapter->PackInfo[uiSearchRuleIndex].u8QueueType = psfLocalSet->u8ServiceFlowSchedulingType; + curr_packinfo->u8QueueType = psfLocalSet->u8ServiceFlowSchedulingType; - if (Adapter->PackInfo[uiSearchRuleIndex].u8QueueType == BE && Adapter->PackInfo[uiSearchRuleIndex].ucDirection) + if (curr_packinfo->u8QueueType == BE && curr_packinfo->ucDirection) Adapter->usBestEffortQueueIndex = uiSearchRuleIndex; - Adapter->PackInfo[uiSearchRuleIndex].ulSFID = ntohl(psfLocalSet->u32SFID); + curr_packinfo->ulSFID = ntohl(psfLocalSet->u32SFID); - Adapter->PackInfo[uiSearchRuleIndex].u8TrafficPriority = psfLocalSet->u8TrafficPriority; + curr_packinfo->u8TrafficPriority = psfLocalSet->u8TrafficPriority; /* copy all the classifier in the Service Flow param structure */ for (i = 0; i < psfLocalSet->u8TotalClassifiers; i++) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Classifier index =%d", i); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Classifier index =%d", i); psfCSType = &psfLocalSet->cConvergenceSLTypes[i]; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Classifier index =%d", i); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Classifier index =%d", i); if (psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority) - Adapter->PackInfo[uiSearchRuleIndex].bClassifierPriority = TRUE; + curr_packinfo->bClassifierPriority = TRUE; if (psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority) - Adapter->PackInfo[uiSearchRuleIndex].bClassifierPriority = TRUE; + curr_packinfo->bClassifierPriority = TRUE; if (ucDsxType == DSA_ACK) { eClassifierAction = eAddClassifier; } else if (ucDsxType == DSC_ACK) { switch (psfCSType->u8ClassfierDSCAction) { case 0: /* DSC Add Classifier */ - { eClassifierAction = eAddClassifier; - } - break; + break; case 1: /* DSC Replace Classifier */ - { eClassifierAction = eReplaceClassifier; - } - break; + break; case 2: /* DSC Delete Classifier */ - { eClassifierAction = eDeleteClassifier; - } - break; + break; default: - { eClassifierAction = eInvalidClassifierAction; } - } } u16PacketClassificationRuleIndex = ntohs(psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex); switch (eClassifierAction) { case eAddClassifier: - { /* Get a Free Classifier Index From Classifier table for this SF to add the Classifier */ /* Contained in this message */ - nClassifierIndex = SearchClsid(Adapter, ulSFID, u16PacketClassificationRuleIndex); + nClassifierIndex = SearchClsid(Adapter, + ulSFID, + u16PacketClassificationRuleIndex); if (nClassifierIndex > MAX_CLASSIFIERS) { nClassifierIndex = SearchFreeClsid(Adapter); if (nClassifierIndex > MAX_CLASSIFIERS) { /* Failed To get a free Entry */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Error Failed To get a free Classifier Entry"); + BCM_DEBUG_PRINT(Adapter, + DBG_TYPE_OTHERS, + CONN_MSG, + DBG_LVL_ALL, + "Error Failed To get a free Classifier Entry"); break; } /* Copy the Classifier Rule for this service flow into our Classifier table maintained per SF. */ - CopyClassifierRuleToSF(Adapter, psfCSType, uiSearchRuleIndex, nClassifierIndex); + CopyClassifierRuleToSF(Adapter, psfCSType, + uiSearchRuleIndex, + nClassifierIndex); } else { /* This Classifier Already Exists and it is invalid to Add Classifier with existing PCRI */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + CONN_MSG, + DBG_LVL_ALL, "CopyToAdapter: Error The Specified Classifier Already Exists and attempted To Add Classifier with Same PCRI : 0x%x\n", u16PacketClassificationRuleIndex); } - } - break; + break; case eReplaceClassifier: - { /* Get the Classifier Index From Classifier table for this SF and replace existing Classifier */ /* with the new classifier Contained in this message */ - nClassifierIndex = SearchClsid(Adapter, ulSFID, u16PacketClassificationRuleIndex); + nClassifierIndex = SearchClsid(Adapter, ulSFID, + u16PacketClassificationRuleIndex); if (nClassifierIndex > MAX_CLASSIFIERS) { /* Failed To search the classifier */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Error Search for Classifier To be replaced failed"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + CONN_MSG, DBG_LVL_ALL, + "Error Search for Classifier To be replaced failed"); break; } /* Copy the Classifier Rule for this service flow into our Classifier table maintained per SF. */ - CopyClassifierRuleToSF(Adapter, psfCSType, uiSearchRuleIndex, nClassifierIndex); - } - break; + CopyClassifierRuleToSF(Adapter, psfCSType, + uiSearchRuleIndex, nClassifierIndex); + break; case eDeleteClassifier: - { /* Get the Classifier Index From Classifier table for this SF and replace existing Classifier */ /* with the new classifier Contained in this message */ - nClassifierIndex = SearchClsid(Adapter, ulSFID, u16PacketClassificationRuleIndex); + nClassifierIndex = SearchClsid(Adapter, ulSFID, + u16PacketClassificationRuleIndex); if (nClassifierIndex > MAX_CLASSIFIERS) { /* Failed To search the classifier */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Error Search for Classifier To be deleted failed"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + CONN_MSG, DBG_LVL_ALL, + "Error Search for Classifier To be deleted failed"); break; } /* Delete This classifier */ - DeleteClassifierRuleFromSF(Adapter, uiSearchRuleIndex, nClassifierIndex); - } - break; + DeleteClassifierRuleFromSF(Adapter, uiSearchRuleIndex, + nClassifierIndex); + break; default: - { /* Invalid Action for classifier */ break; } - } } /* Repeat parsing Classification Entries to process PHS Rules */ for (i = 0; i < psfLocalSet->u8TotalClassifiers; i++) { psfCSType = &psfLocalSet->cConvergenceSLTypes[i]; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "psfCSType->u8PhsDSCAction : 0x%x\n", psfCSType->u8PhsDSCAction); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "psfCSType->u8PhsDSCAction : 0x%x\n", + psfCSType->u8PhsDSCAction); switch (psfCSType->u8PhsDSCAction) { case eDeleteAllPHSRules: - { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Deleting All PHS Rules For VCID: 0x%X\n", uVCID); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, + DBG_LVL_ALL, + "Deleting All PHS Rules For VCID: 0x%X\n", + uVCID); /* Delete All the PHS rules for this Service flow */ PhsDeleteSFRules(&Adapter->stBCMPhsContext, uVCID); break; - } case eDeletePHSRule: - { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "PHS DSC Action = Delete PHS Rule\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, + DBG_LVL_ALL, + "PHS DSC Action = Delete PHS Rule\n"); if (psfCSType->cPhsRule.u8PHSI) - PhsDeletePHSRule(&Adapter->stBCMPhsContext, uVCID, psfCSType->cCPacketClassificationRule.u8AssociatedPHSI); + PhsDeletePHSRule(&Adapter->stBCMPhsContext, + uVCID, + psfCSType->cCPacketClassificationRule.u8AssociatedPHSI); break; - } default: - { if (ucDsxType == DSC_ACK) { /* BCM_DEBUG_PRINT(CONN_MSG,("Invalid PHS DSC Action For DSC\n",psfCSType->cPhsRule.u8PHSI)); */ break; /* FOr DSC ACK Case PHS DSC Action must be in valid set */ } - } /* Proceed To Add PHS rule for DSA_ACK case even if PHS DSC action is unspecified */ /* No Break Here . Intentionally! */ case eAddPHSRule: case eSetPHSRule: - { if (psfCSType->cPhsRule.u8PHSI) { /* Apply This PHS Rule to all classifiers whose Associated PHSI Match */ - unsigned int uiClassifierIndex = 0; - if (pstAddIndication->u8Direction == UPLINK_DIR) { - for (uiClassifierIndex = 0; uiClassifierIndex < MAX_CLASSIFIERS; uiClassifierIndex++) { - if ((Adapter->astClassifierTable[uiClassifierIndex].bUsed) && - (Adapter->astClassifierTable[uiClassifierIndex].ulSFID == Adapter->PackInfo[uiSearchRuleIndex].ulSFID) && - (Adapter->astClassifierTable[uiClassifierIndex].u8AssociatedPHSI == psfCSType->cPhsRule.u8PHSI)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "Adding PHS Rule For Classifier: 0x%x cPhsRule.u8PHSI: 0x%x\n", - Adapter->astClassifierTable[uiClassifierIndex].uiClassifierRuleIndex, - psfCSType->cPhsRule.u8PHSI); - /* Update The PHS Rule for this classifier as Associated PHSI id defined */ - - /* Copy the PHS Rule */ - sPhsRule.u8PHSI = psfCSType->cPhsRule.u8PHSI; - sPhsRule.u8PHSFLength = psfCSType->cPhsRule.u8PHSFLength; - sPhsRule.u8PHSMLength = psfCSType->cPhsRule.u8PHSMLength; - sPhsRule.u8PHSS = psfCSType->cPhsRule.u8PHSS; - sPhsRule.u8PHSV = psfCSType->cPhsRule.u8PHSV; - memcpy(sPhsRule.u8PHSF, psfCSType->cPhsRule.u8PHSF, MAX_PHS_LENGTHS); - memcpy(sPhsRule.u8PHSM, psfCSType->cPhsRule.u8PHSM, MAX_PHS_LENGTHS); - sPhsRule.u8RefCnt = 0; - sPhsRule.bUnclassifiedPHSRule = false; - sPhsRule.PHSModifiedBytes = 0; - sPhsRule.PHSModifiedNumPackets = 0; - sPhsRule.PHSErrorNumPackets = 0; - - /* bPHSRuleAssociated = TRUE; */ - /* Store The PHS Rule for this classifier */ - - PhsUpdateClassifierRule( - &Adapter->stBCMPhsContext, - uVCID, - Adapter->astClassifierTable[uiClassifierIndex].uiClassifierRuleIndex, - &sPhsRule, - Adapter->astClassifierTable[uiClassifierIndex].u8AssociatedPHSI); - - /* Update PHS Rule For the Classifier */ - if (sPhsRule.u8PHSI) { - Adapter->astClassifierTable[uiClassifierIndex].u32PHSRuleID = sPhsRule.u8PHSI; - memcpy(&Adapter->astClassifierTable[uiClassifierIndex].sPhsRule, &sPhsRule, sizeof(struct bcm_phs_rule)); - } - } - } - } else { - /* Error PHS Rule specified in signaling could not be applied to any classifier */ - - /* Copy the PHS Rule */ - sPhsRule.u8PHSI = psfCSType->cPhsRule.u8PHSI; - sPhsRule.u8PHSFLength = psfCSType->cPhsRule.u8PHSFLength; - sPhsRule.u8PHSMLength = psfCSType->cPhsRule.u8PHSMLength; - sPhsRule.u8PHSS = psfCSType->cPhsRule.u8PHSS; - sPhsRule.u8PHSV = psfCSType->cPhsRule.u8PHSV; - memcpy(sPhsRule.u8PHSF, psfCSType->cPhsRule.u8PHSF, MAX_PHS_LENGTHS); - memcpy(sPhsRule.u8PHSM, psfCSType->cPhsRule.u8PHSM, MAX_PHS_LENGTHS); - sPhsRule.u8RefCnt = 0; - sPhsRule.bUnclassifiedPHSRule = TRUE; - sPhsRule.PHSModifiedBytes = 0; - sPhsRule.PHSModifiedNumPackets = 0; - sPhsRule.PHSErrorNumPackets = 0; - /* Store The PHS Rule for this classifier */ - - /* - * Passing the argument u8PHSI instead of clsid. Because for DL with no classifier rule, - * clsid will be zero hence we can't have multiple PHS rules for the same SF. - * To support multiple PHS rule, passing u8PHSI. - */ - PhsUpdateClassifierRule( - &Adapter->stBCMPhsContext, + apply_phs_rule_to_all_classifiers(Adapter, + uiSearchRuleIndex, uVCID, - sPhsRule.u8PHSI, &sPhsRule, - sPhsRule.u8PHSI); - } + &psfCSType->cPhsRule, + pstAddIndication); } - } - break; + break; } } if (psfLocalSet->u32MaxSustainedTrafficRate == 0) { /* No Rate Limit . Set Max Sustained Traffic Rate to Maximum */ - Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate = WIMAX_MAX_ALLOWED_RATE; + curr_packinfo->uiMaxAllowedRate = WIMAX_MAX_ALLOWED_RATE; } else if (ntohl(psfLocalSet->u32MaxSustainedTrafficRate) > WIMAX_MAX_ALLOWED_RATE) { /* Too large Allowed Rate specified. Limiting to Wi Max Allowed rate */ - Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate = WIMAX_MAX_ALLOWED_RATE; + curr_packinfo->uiMaxAllowedRate = WIMAX_MAX_ALLOWED_RATE; } else { - Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate = ntohl(psfLocalSet->u32MaxSustainedTrafficRate); + curr_packinfo->uiMaxAllowedRate = + ntohl(psfLocalSet->u32MaxSustainedTrafficRate); } - Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency = ntohl(psfLocalSet->u32MaximumLatency); - if (Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency == 0) /* 0 should be treated as infinite */ - Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency = MAX_LATENCY_ALLOWED; + curr_packinfo->uiMaxLatency = ntohl(psfLocalSet->u32MaximumLatency); + if (curr_packinfo->uiMaxLatency == 0) /* 0 should be treated as infinite */ + curr_packinfo->uiMaxLatency = MAX_LATENCY_ALLOWED; - if ((Adapter->PackInfo[uiSearchRuleIndex].u8QueueType == ERTPS || - Adapter->PackInfo[uiSearchRuleIndex].u8QueueType == UGS)) + if ((curr_packinfo->u8QueueType == ERTPS || + curr_packinfo->u8QueueType == UGS)) UGIValue = ntohs(psfLocalSet->u16UnsolicitedGrantInterval); if (UGIValue == 0) @@ -770,42 +822,45 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* <Pointer * The extra amount of token is to ensure that a large amount of jitter won't have loss in throughput... * In case of non-UGI based connection, 200 frames worth of data is the max token count at host... */ - Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize = - (DEFAULT_UGI_FACTOR*Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate*UGIValue)/1000; + curr_packinfo->uiMaxBucketSize = + (DEFAULT_UGI_FACTOR*curr_packinfo->uiMaxAllowedRate*UGIValue)/1000; - if (Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize < WIMAX_MAX_MTU*8) { + if (curr_packinfo->uiMaxBucketSize < WIMAX_MAX_MTU*8) { UINT UGIFactor = 0; /* Special Handling to ensure the biggest size of packet can go out from host to FW as follows: * 1. Any packet from Host to FW can go out in different packet size. * 2. So in case the Bucket count is smaller than MTU, the packets of size (Size > TokenCount), will get dropped. * 3. We can allow packets of MaxSize from Host->FW that can go out from FW in multiple SDUs by fragmentation at Wimax Layer */ - UGIFactor = (Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency/UGIValue + 1); + UGIFactor = (curr_packinfo->uiMaxLatency/UGIValue + 1); if (UGIFactor > DEFAULT_UGI_FACTOR) - Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize = - (UGIFactor*Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate*UGIValue)/1000; + curr_packinfo->uiMaxBucketSize = + (UGIFactor*curr_packinfo->uiMaxAllowedRate*UGIValue)/1000; - if (Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize > WIMAX_MAX_MTU*8) - Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize = WIMAX_MAX_MTU*8; + if (curr_packinfo->uiMaxBucketSize > WIMAX_MAX_MTU*8) + curr_packinfo->uiMaxBucketSize = WIMAX_MAX_MTU*8; } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "LAT: %d, UGI: %d\n", Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency, UGIValue); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "uiMaxAllowedRate: 0x%x, u32MaxSustainedTrafficRate: 0x%x ,uiMaxBucketSize: 0x%x", - Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate, + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "LAT: %d, UGI: %d\n", curr_packinfo->uiMaxLatency, + UGIValue); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "uiMaxAllowedRate: 0x%x, u32MaxSustainedTrafficRate: 0x%x ,uiMaxBucketSize: 0x%x", + curr_packinfo->uiMaxAllowedRate, ntohl(psfLocalSet->u32MaxSustainedTrafficRate), - Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize); + curr_packinfo->uiMaxBucketSize); /* copy the extended SF Parameters to Support MIBS */ CopyMIBSExtendedSFParameters(Adapter, psfLocalSet, uiSearchRuleIndex); /* store header suppression enabled flag per SF */ - Adapter->PackInfo[uiSearchRuleIndex].bHeaderSuppressionEnabled = + curr_packinfo->bHeaderSuppressionEnabled = !(psfLocalSet->u8RequesttransmissionPolicy & MASK_DISABLE_HEADER_SUPPRESSION); - kfree(Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication); - Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication = pstAddIndication; + kfree(curr_packinfo->pstSFIndication); + curr_packinfo->pstSFIndication = pstAddIndication; /* Re Sort the SF list in PackInfo according to Traffic Priority */ SortPackInfo(Adapter); @@ -815,7 +870,8 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* <Pointer */ SortClassifiers(Adapter); DumpPhsRules(&Adapter->stBCMPhsContext); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "%s <=====", __func__); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "%s <=====", __func__); } /*********************************************************************** @@ -975,8 +1031,8 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, "u8EthernetSourceMACAddress[6]: " - "%pM", psfCSType->cCPacketClassificationRule. + DBG_LVL_ALL, "u8EthernetSourceMACAddress[6]: %pM", + psfCSType->cCPacketClassificationRule. u8EthernetSourceMACAddress); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthertypeLength: 0x%02X ", @@ -1092,18 +1148,16 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRangeLength); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, "u8ProtocolSourcePortRange[4]: " - "0x%*ph ", 4, psfCSType-> - cCPacketClassificationRule. + DBG_LVL_ALL, "u8ProtocolSourcePortRange[4]: 0x%*ph ", + 4, psfCSType->cCPacketClassificationRule. u8ProtocolSourcePortRange); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolDestPortRangeLength: 0x%02X ", psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRangeLength); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, "u8ProtocolDestPortRange[4]: " - "0x%*ph ", 4, psfCSType-> - cCPacketClassificationRule. + DBG_LVL_ALL, "u8ProtocolDestPortRange[4]: 0x%*ph ", + 4, psfCSType->cCPacketClassificationRule. u8ProtocolDestPortRange); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetDestMacAddressLength: 0x%02X ", @@ -1118,8 +1172,8 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, "u8EthernetSourceMACAddress[6]: " - "%pM", psfCSType->cCPacketClassificationRule. + DBG_LVL_ALL, "u8EthernetSourceMACAddress[6]: %pM", + psfCSType->cCPacketClassificationRule. u8EthernetSourceMACAddress); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthertypeLength: 0x%02X ", psfCSType->cCPacketClassificationRule.u8EthertypeLength); @@ -1199,123 +1253,179 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) for (nIndex = 0; nIndex < nCurClassifierCnt; nIndex++) { struct bcm_convergence_types *psfCSType = NULL; + struct bcm_packet_class_rules *clsRule = NULL; - psfCSType = &pstAddIndication->sfActiveSet.cConvergenceSLTypes[nIndex]; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " CCPacketClassificationRuleSI====>"); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ClassifierRulePriority: 0x%X ", - psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPTypeOfServiceLength: 0x%X ", - psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPTypeOfService[3]: 0x%X ,0x%X ,0x%X ", - psfCSType->cCPacketClassificationRule.u8IPTypeOfService[0], - psfCSType->cCPacketClassificationRule.u8IPTypeOfService[1], - psfCSType->cCPacketClassificationRule.u8IPTypeOfService[2]); + psfCSType = &pstAddIndication->sfActiveSet.cConvergenceSLTypes[nIndex]; + clsRule = &psfCSType->cCPacketClassificationRule; + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, " CCPacketClassificationRuleSI====>"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, " u8ClassifierRulePriority: 0x%X ", + clsRule->u8ClassifierRulePriority); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, " u8IPTypeOfServiceLength: 0x%X ", + clsRule->u8IPTypeOfServiceLength); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u8IPTypeOfService[3]: 0x%X ,0x%X ,0x%X ", + clsRule->u8IPTypeOfService[0], + clsRule->u8IPTypeOfService[1], + clsRule->u8IPTypeOfService[2]); for (uiLoopIndex = 0; uiLoopIndex < 1; uiLoopIndex++) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8Protocol: 0x%X ", psfCSType->cCPacketClassificationRule.u8Protocol); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u8Protocol: 0x%X ", + clsRule->u8Protocol); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddressLength: 0x%X ", - psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddressLength); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + "u8IPMaskedSourceAddressLength: 0x%X ", + clsRule->u8IPMaskedSourceAddressLength); for (uiLoopIndex = 0; uiLoopIndex < 32; uiLoopIndex++) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddress[32]: 0x%X ", - psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddress[uiLoopIndex]); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + "u8IPMaskedSourceAddress[32]: 0x%X ", + clsRule->u8IPMaskedSourceAddress[uiLoopIndex]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPDestinationAddressLength: 0x%02X ", - psfCSType->cCPacketClassificationRule.u8IPDestinationAddressLength); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + "u8IPDestinationAddressLength: 0x%02X ", + clsRule->u8IPDestinationAddressLength); for (uiLoopIndex = 0; uiLoopIndex < 32; uiLoopIndex++) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPDestinationAddress[32]:0x%X ", - psfCSType->cCPacketClassificationRule.u8IPDestinationAddress[uiLoopIndex]); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u8IPDestinationAddress[32]:0x%X ", + clsRule->u8IPDestinationAddress[uiLoopIndex]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ProtocolSourcePortRangeLength: 0x%X ", - psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRangeLength); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u8ProtocolSourcePortRangeLength: 0x%X ", + clsRule->u8ProtocolSourcePortRangeLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ProtocolSourcePortRange[4]: 0x%X ,0x%X ,0x%X ,0x%X ", - psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[0], - psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[1], - psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[2], - psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[3]); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u8ProtocolSourcePortRange[4]: 0x%X ,0x%X ,0x%X ,0x%X ", + clsRule->u8ProtocolSourcePortRange[0], + clsRule->u8ProtocolSourcePortRange[1], + clsRule->u8ProtocolSourcePortRange[2], + clsRule->u8ProtocolSourcePortRange[3]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ProtocolDestPortRangeLength: 0x%X ", - psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRangeLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ProtocolDestPortRange[4]: 0x%X ,0x%X ,0x%X ,0x%X ", - psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[0], - psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[1], - psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[2], - psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[3]); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u8ProtocolDestPortRangeLength: 0x%X ", + clsRule->u8ProtocolDestPortRangeLength); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u8ProtocolDestPortRange[4]: 0x%X ,0x%X ,0x%X ,0x%X ", + clsRule->u8ProtocolDestPortRange[0], + clsRule->u8ProtocolDestPortRange[1], + clsRule->u8ProtocolDestPortRange[2], + clsRule->u8ProtocolDestPortRange[3]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8EthernetDestMacAddressLength: 0x%X ", - psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8EthernetDestMacAddress[6]: 0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X", - psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[0], - psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[1], - psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[2], - psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[3], - psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[4], - psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[5]); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8EthernetSourceMACAddressLength: 0x%X ", - psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddress[6]: 0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X", - psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[0], - psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[1], - psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[2], - psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[3], - psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[4], - psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[5]); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8EthertypeLength: 0x%X ", - psfCSType->cCPacketClassificationRule.u8EthertypeLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8Ethertype[3]: 0x%X ,0x%X ,0x%X ", - psfCSType->cCPacketClassificationRule.u8Ethertype[0], - psfCSType->cCPacketClassificationRule.u8Ethertype[1], - psfCSType->cCPacketClassificationRule.u8Ethertype[2]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16UserPriority: 0x%X ", - psfCSType->cCPacketClassificationRule.u16UserPriority); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16VLANID: 0x%X ", psfCSType->cCPacketClassificationRule.u16VLANID); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8AssociatedPHSI: 0x%X ", psfCSType->cCPacketClassificationRule.u8AssociatedPHSI); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16PacketClassificationRuleIndex:0x%X ", - psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u8EthernetDestMacAddressLength: 0x%X ", + clsRule->u8EthernetDestMacAddressLength); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u8EthernetDestMacAddress[6]: 0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X", + clsRule->u8EthernetDestMacAddress[0], + clsRule->u8EthernetDestMacAddress[1], + clsRule->u8EthernetDestMacAddress[2], + clsRule->u8EthernetDestMacAddress[3], + clsRule->u8EthernetDestMacAddress[4], + clsRule->u8EthernetDestMacAddress[5]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8VendorSpecificClassifierParamLength:0x%X ", - psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParamLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8VendorSpecificClassifierParam[1]:0x%X ", - psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParam[0]); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u8EthernetSourceMACAddressLength: 0x%X ", + clsRule->u8EthernetDestMacAddressLength); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + "u8EthernetSourceMACAddress[6]: 0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X", + clsRule->u8EthernetSourceMACAddress[0], + clsRule->u8EthernetSourceMACAddress[1], + clsRule->u8EthernetSourceMACAddress[2], + clsRule->u8EthernetSourceMACAddress[3], + clsRule->u8EthernetSourceMACAddress[4], + clsRule->u8EthernetSourceMACAddress[5]); + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, " u8EthertypeLength: 0x%X ", + clsRule->u8EthertypeLength); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u8Ethertype[3]: 0x%X ,0x%X ,0x%X ", + clsRule->u8Ethertype[0], + clsRule->u8Ethertype[1], + clsRule->u8Ethertype[2]); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, " u16UserPriority: 0x%X ", + clsRule->u16UserPriority); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, " u16VLANID: 0x%X ", + clsRule->u16VLANID); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, " u8AssociatedPHSI: 0x%X ", + clsRule->u8AssociatedPHSI); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u16PacketClassificationRuleIndex:0x%X ", + clsRule->u16PacketClassificationRuleIndex); + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u8VendorSpecificClassifierParamLength:0x%X ", + clsRule->u8VendorSpecificClassifierParamLength); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u8VendorSpecificClassifierParam[1]:0x%X ", + clsRule->u8VendorSpecificClassifierParam[0]); #ifdef VERSION_D5 - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPv6FlowLableLength: 0x%X ", - psfCSType->cCPacketClassificationRule.u8IPv6FlowLableLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPv6FlowLable[6]: 0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X ", - psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[0], - psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[1], - psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[2], - psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[3], - psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[4], - psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[5]); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, " u8IPv6FlowLableLength: 0x%X ", + clsRule->u8IPv6FlowLableLength); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u8IPv6FlowLable[6]: 0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X ", + clsRule->u8IPv6FlowLable[0], + clsRule->u8IPv6FlowLable[1], + clsRule->u8IPv6FlowLable[2], + clsRule->u8IPv6FlowLable[3], + clsRule->u8IPv6FlowLable[4], + clsRule->u8IPv6FlowLable[5]); #endif } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " bValid: 0x%X", pstAddIndication->sfActiveSet.bValid); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, + " bValid: 0x%X", pstAddIndication->sfActiveSet.bValid); } -static inline ULONG RestoreSFParam(struct bcm_mini_adapter *Adapter, ULONG ulAddrSFParamSet, PUCHAR pucDestBuffer) +static inline ULONG RestoreSFParam(struct bcm_mini_adapter *Adapter, + ULONG ulAddrSFParamSet, PUCHAR pucDestBuffer) { UINT nBytesToRead = sizeof(struct bcm_connect_mgr_params); if (ulAddrSFParamSet == 0 || NULL == pucDestBuffer) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Got Param address as 0!!"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Got Param address as 0!!"); return 0; } ulAddrSFParamSet = ntohl(ulAddrSFParamSet); /* Read out the SF Param Set At the indicated Location */ - if (rdm(Adapter, ulAddrSFParamSet, (PUCHAR)pucDestBuffer, nBytesToRead) < 0) + if (rdm(Adapter, ulAddrSFParamSet,(PUCHAR)pucDestBuffer, nBytesToRead) < 0) return STATUS_FAILURE; return 1; } -static ULONG StoreSFParam(struct bcm_mini_adapter *Adapter, PUCHAR pucSrcBuffer, ULONG ulAddrSFParamSet) +static ULONG StoreSFParam(struct bcm_mini_adapter *Adapter, PUCHAR pucSrcBuffer, + ULONG ulAddrSFParamSet) { UINT nBytesToWrite = sizeof(struct bcm_connect_mgr_params); int ret = 0; @@ -1325,13 +1435,15 @@ static ULONG StoreSFParam(struct bcm_mini_adapter *Adapter, PUCHAR pucSrcBuffer, ret = wrm(Adapter, ulAddrSFParamSet, (u8 *)pucSrcBuffer, nBytesToWrite); if (ret < 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "%s:%d WRM failed", __func__, __LINE__); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "%s:%d WRM failed", __func__, __LINE__); return ret; } return 1; } -ULONG StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, PVOID pvBuffer, UINT *puBufferLength) +ULONG StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, + PVOID pvBuffer, UINT *puBufferLength) { struct bcm_add_indication_alt *pstAddIndicationAlt = NULL; struct bcm_add_indication *pstAddIndication = NULL; @@ -1365,13 +1477,15 @@ ULONG StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, PVOID pvBu } /* For DSA_REQ, only up to "psfAuthorizedSet" parameter should be accessed by driver! */ - pstAddIndication = kmalloc(sizeof(struct bcm_add_indication), GFP_KERNEL); + pstAddIndication = kmalloc(sizeof(struct bcm_add_indication), + GFP_KERNEL); if (pstAddIndication == NULL) return 0; /* AUTHORIZED SET */ pstAddIndication->psfAuthorizedSet = (struct bcm_connect_mgr_params *) - GetNextTargetBufferLocation(Adapter, pstAddIndicationAlt->u16TID); + GetNextTargetBufferLocation(Adapter, + pstAddIndicationAlt->u16TID); if (!pstAddIndication->psfAuthorizedSet) { kfree(pstAddIndication); return 0; @@ -1384,7 +1498,9 @@ ULONG StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, PVOID pvBu } /* this can't possibly be right */ - pstAddIndication->psfAuthorizedSet = (struct bcm_connect_mgr_params *)ntohl((ULONG)pstAddIndication->psfAuthorizedSet); + pstAddIndication->psfAuthorizedSet = + (struct bcm_connect_mgr_params *) ntohl( + (ULONG)pstAddIndication->psfAuthorizedSet); if (pstAddIndicationAlt->u8Type == DSA_REQ) { struct bcm_add_request AddRequest; @@ -1413,31 +1529,39 @@ ULONG StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, PVOID pvBu /* ADMITTED SET */ pstAddIndication->psfAdmittedSet = (struct bcm_connect_mgr_params *) - GetNextTargetBufferLocation(Adapter, pstAddIndicationAlt->u16TID); + GetNextTargetBufferLocation(Adapter, + pstAddIndicationAlt->u16TID); if (!pstAddIndication->psfAdmittedSet) { kfree(pstAddIndication); return 0; } - if (StoreSFParam(Adapter, (PUCHAR)&pstAddIndicationAlt->sfAdmittedSet, (ULONG)pstAddIndication->psfAdmittedSet) != 1) { + if (StoreSFParam(Adapter, (PUCHAR)&pstAddIndicationAlt->sfAdmittedSet, + (ULONG)pstAddIndication->psfAdmittedSet) != 1) { kfree(pstAddIndication); return 0; } - pstAddIndication->psfAdmittedSet = (struct bcm_connect_mgr_params *)ntohl((ULONG)pstAddIndication->psfAdmittedSet); + pstAddIndication->psfAdmittedSet = + (struct bcm_connect_mgr_params *) ntohl( + (ULONG) pstAddIndication->psfAdmittedSet); /* ACTIVE SET */ pstAddIndication->psfActiveSet = (struct bcm_connect_mgr_params *) - GetNextTargetBufferLocation(Adapter, pstAddIndicationAlt->u16TID); + GetNextTargetBufferLocation(Adapter, + pstAddIndicationAlt->u16TID); if (!pstAddIndication->psfActiveSet) { kfree(pstAddIndication); return 0; } - if (StoreSFParam(Adapter, (PUCHAR)&pstAddIndicationAlt->sfActiveSet, (ULONG)pstAddIndication->psfActiveSet) != 1) { + if (StoreSFParam(Adapter, (PUCHAR)&pstAddIndicationAlt->sfActiveSet, + (ULONG)pstAddIndication->psfActiveSet) != 1) { kfree(pstAddIndication); return 0; } - pstAddIndication->psfActiveSet = (struct bcm_connect_mgr_params *)ntohl((ULONG)pstAddIndication->psfActiveSet); + pstAddIndication->psfActiveSet = + (struct bcm_connect_mgr_params *) ntohl( + (ULONG)pstAddIndication->psfActiveSet); (*puBufferLength) = sizeof(struct bcm_add_indication); *(struct bcm_add_indication *)pvBuffer = *pstAddIndication; @@ -1446,40 +1570,63 @@ ULONG StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, PVOID pvBu } static inline struct bcm_add_indication_alt -*RestoreCmControlResponseMessage(register struct bcm_mini_adapter *Adapter, register PVOID pvBuffer) +*RestoreCmControlResponseMessage(register struct bcm_mini_adapter *Adapter, + register PVOID pvBuffer) { ULONG ulStatus = 0; struct bcm_add_indication *pstAddIndication = NULL; struct bcm_add_indication_alt *pstAddIndicationDest = NULL; pstAddIndication = pvBuffer; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "=====>"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "=====>"); if ((pstAddIndication->u8Type == DSD_REQ) || (pstAddIndication->u8Type == DSD_RSP) || (pstAddIndication->u8Type == DSD_ACK)) return pvBuffer; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Inside RestoreCmControlResponseMessage "); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Inside RestoreCmControlResponseMessage "); /* * Need to Allocate memory to contain the SUPER Large structures * Our driver can't create these structures on Stack :( */ - pstAddIndicationDest = kmalloc(sizeof(struct bcm_add_indication_alt), GFP_KERNEL); + pstAddIndicationDest = kmalloc(sizeof(struct bcm_add_indication_alt), + GFP_KERNEL); if (pstAddIndicationDest) { - memset(pstAddIndicationDest, 0, sizeof(struct bcm_add_indication_alt)); + memset(pstAddIndicationDest, 0, + sizeof(struct bcm_add_indication_alt)); } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Failed to allocate memory for SF Add Indication Structure "); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, + DBG_LVL_ALL, + "Failed to allocate memory for SF Add Indication Structure "); return NULL; } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u8Type : 0x%X", pstAddIndication->u8Type); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u8Direction : 0x%X", pstAddIndication->eConnectionDir); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u8TID : 0x%X", ntohs(pstAddIndication->u16TID)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u8CID : 0x%X", ntohs(pstAddIndication->u16CID)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u16VCID : 0x%X", ntohs(pstAddIndication->u16VCID)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-autorized set loc : %p", pstAddIndication->psfAuthorizedSet); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-admitted set loc : %p", pstAddIndication->psfAdmittedSet); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-Active set loc : %p", pstAddIndication->psfActiveSet); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "AddIndication-u8Type : 0x%X", + pstAddIndication->u8Type); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "AddIndication-u8Direction : 0x%X", + pstAddIndication->eConnectionDir); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "AddIndication-u8TID : 0x%X", + ntohs(pstAddIndication->u16TID)); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "AddIndication-u8CID : 0x%X", + ntohs(pstAddIndication->u16CID)); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "AddIndication-u16VCID : 0x%X", + ntohs(pstAddIndication->u16VCID)); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "AddIndication-autorized set loc : %p", + pstAddIndication->psfAuthorizedSet); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "AddIndication-admitted set loc : %p", + pstAddIndication->psfAdmittedSet); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "AddIndication-Active set loc : %p", + pstAddIndication->psfActiveSet); pstAddIndicationDest->u8Type = pstAddIndication->u8Type; pstAddIndicationDest->u8Direction = pstAddIndication->eConnectionDir; @@ -1488,39 +1635,60 @@ static inline struct bcm_add_indication_alt pstAddIndicationDest->u16VCID = pstAddIndication->u16VCID; pstAddIndicationDest->u8CC = pstAddIndication->u8CC; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Restoring Active Set "); - ulStatus = RestoreSFParam(Adapter, (ULONG)pstAddIndication->psfActiveSet, (PUCHAR)&pstAddIndicationDest->sfActiveSet); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Restoring Active Set "); + ulStatus = RestoreSFParam(Adapter, + (ULONG)pstAddIndication->psfActiveSet, + (PUCHAR)&pstAddIndicationDest->sfActiveSet); if (ulStatus != 1) goto failed_restore_sf_param; if (pstAddIndicationDest->sfActiveSet.u8TotalClassifiers > MAX_CLASSIFIERS_IN_SF) - pstAddIndicationDest->sfActiveSet.u8TotalClassifiers = MAX_CLASSIFIERS_IN_SF; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Restoring Admitted Set "); - ulStatus = RestoreSFParam(Adapter, (ULONG)pstAddIndication->psfAdmittedSet, (PUCHAR)&pstAddIndicationDest->sfAdmittedSet); + pstAddIndicationDest->sfActiveSet.u8TotalClassifiers = + MAX_CLASSIFIERS_IN_SF; + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Restoring Admitted Set "); + ulStatus = RestoreSFParam(Adapter, + (ULONG)pstAddIndication->psfAdmittedSet, + (PUCHAR)&pstAddIndicationDest->sfAdmittedSet); if (ulStatus != 1) goto failed_restore_sf_param; if (pstAddIndicationDest->sfAdmittedSet.u8TotalClassifiers > MAX_CLASSIFIERS_IN_SF) - pstAddIndicationDest->sfAdmittedSet.u8TotalClassifiers = MAX_CLASSIFIERS_IN_SF; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Restoring Authorized Set "); - ulStatus = RestoreSFParam(Adapter, (ULONG)pstAddIndication->psfAuthorizedSet, (PUCHAR)&pstAddIndicationDest->sfAuthorizedSet); + pstAddIndicationDest->sfAdmittedSet.u8TotalClassifiers = + MAX_CLASSIFIERS_IN_SF; + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Restoring Authorized Set "); + ulStatus = RestoreSFParam(Adapter, + (ULONG)pstAddIndication->psfAuthorizedSet, + (PUCHAR)&pstAddIndicationDest->sfAuthorizedSet); if (ulStatus != 1) goto failed_restore_sf_param; if (pstAddIndicationDest->sfAuthorizedSet.u8TotalClassifiers > MAX_CLASSIFIERS_IN_SF) - pstAddIndicationDest->sfAuthorizedSet.u8TotalClassifiers = MAX_CLASSIFIERS_IN_SF; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Dumping the whole raw packet"); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "============================================================"); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " pstAddIndicationDest->sfActiveSet size %zx %p", sizeof(*pstAddIndicationDest), pstAddIndicationDest); - /* BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, (unsigned char *)pstAddIndicationDest, sizeof(*pstAddIndicationDest)); */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "============================================================"); + pstAddIndicationDest->sfAuthorizedSet.u8TotalClassifiers = + MAX_CLASSIFIERS_IN_SF; + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Dumping the whole raw packet"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "============================================================"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + " pstAddIndicationDest->sfActiveSet size %zx %p", + sizeof(*pstAddIndicationDest), pstAddIndicationDest); + /* BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, CONN_MSG, + * DBG_LVL_ALL, (unsigned char *)pstAddIndicationDest, + * sizeof(*pstAddIndicationDest)); + */ + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "============================================================"); return pstAddIndicationDest; failed_restore_sf_param: 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; } @@ -1532,31 +1700,44 @@ ULONG SetUpTargetDsxBuffers(struct bcm_mini_adapter *Adapter) int Status; if (!Adapter) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Adapter was NULL!!!"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Adapter was NULL!!!"); return 0; } if (Adapter->astTargetDsxBuffer[0].ulTargetDsxBuffer) return 1; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Size of Each DSX Buffer(Also size of connection manager parameters): %zx ", sizeof(struct bcm_connect_mgr_params)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Reading DSX buffer From Target location %x ", DSX_MESSAGE_EXCHANGE_BUFFER); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Size of Each DSX Buffer(Also size of connection manager parameters): %zx ", + sizeof(struct bcm_connect_mgr_params)); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Reading DSX buffer From Target location %x ", + DSX_MESSAGE_EXCHANGE_BUFFER); - Status = rdmalt(Adapter, DSX_MESSAGE_EXCHANGE_BUFFER, (PUINT)&ulTargetDsxBuffersBase, sizeof(UINT)); + Status = rdmalt(Adapter, DSX_MESSAGE_EXCHANGE_BUFFER, + (PUINT)&ulTargetDsxBuffersBase, sizeof(UINT)); if (Status < 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "RDM failed!!"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "RDM failed!!"); return 0; } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Base Address Of DSX Target Buffer : 0x%lx", ulTargetDsxBuffersBase); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Tgt Buffer is Now %lx :", ulTargetDsxBuffersBase); - ulCntTargetBuffers = DSX_MESSAGE_EXCHANGE_BUFFER_SIZE / sizeof(struct bcm_connect_mgr_params); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Base Address Of DSX Target Buffer : 0x%lx", + ulTargetDsxBuffersBase); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Tgt Buffer is Now %lx :", ulTargetDsxBuffersBase); + ulCntTargetBuffers = DSX_MESSAGE_EXCHANGE_BUFFER_SIZE / + sizeof(struct bcm_connect_mgr_params); Adapter->ulTotalTargetBuffersAvailable = ulCntTargetBuffers > MAX_TARGET_DSX_BUFFERS ? MAX_TARGET_DSX_BUFFERS : ulCntTargetBuffers; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " Total Target DSX Buffer setup %lx ", Adapter->ulTotalTargetBuffersAvailable); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + " Total Target DSX Buffer setup %lx ", + Adapter->ulTotalTargetBuffersAvailable); for (i = 0; i < Adapter->ulTotalTargetBuffersAvailable; i++) { Adapter->astTargetDsxBuffer[i].ulTargetDsxBuffer = ulTargetDsxBuffersBase; @@ -1571,12 +1752,14 @@ ULONG SetUpTargetDsxBuffers(struct bcm_mini_adapter *Adapter) return 1; } -static ULONG GetNextTargetBufferLocation(struct bcm_mini_adapter *Adapter, B_UINT16 tid) +static ULONG GetNextTargetBufferLocation(struct bcm_mini_adapter *Adapter, + B_UINT16 tid) { ULONG dsx_buf; ULONG idx, max_try; - if ((Adapter->ulTotalTargetBuffersAvailable == 0) || (Adapter->ulFreeTargetBufferCnt == 0)) { + if ((Adapter->ulTotalTargetBuffersAvailable == 0) + || (Adapter->ulFreeTargetBufferCnt == 0)) { ClearTargetDSXBuffer(Adapter, tid, false); return 0; } @@ -1589,7 +1772,9 @@ static ULONG GetNextTargetBufferLocation(struct bcm_mini_adapter *Adapter, B_UIN } if (max_try == 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "\n GetNextTargetBufferLocation : Error No Free Target DSX Buffers FreeCnt : %lx ", Adapter->ulFreeTargetBufferCnt); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "\n GetNextTargetBufferLocation : Error No Free Target DSX Buffers FreeCnt : %lx ", + Adapter->ulFreeTargetBufferCnt); ClearTargetDSXBuffer(Adapter, tid, false); return 0; } @@ -1600,7 +1785,9 @@ static ULONG GetNextTargetBufferLocation(struct bcm_mini_adapter *Adapter, B_UIN Adapter->ulFreeTargetBufferCnt--; idx = (idx+1)%Adapter->ulTotalTargetBuffersAvailable; Adapter->ulCurrentTargetBuffer = idx; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "GetNextTargetBufferLocation :Returning address %lx tid %d\n", dsx_buf, tid); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "GetNextTargetBufferLocation :Returning address %lx tid %d\n", + dsx_buf, tid); return dsx_buf; } @@ -1611,7 +1798,8 @@ int AllocAdapterDsxBuffer(struct bcm_mini_adapter *Adapter) * Need to Allocate memory to contain the SUPER Large structures * Our driver can't create these structures on Stack */ - Adapter->caDsxReqResp = kmalloc(sizeof(struct bcm_add_indication_alt)+LEADER_SIZE, GFP_KERNEL); + Adapter->caDsxReqResp = kmalloc(sizeof(struct bcm_add_indication_alt) + + LEADER_SIZE, GFP_KERNEL); if (!Adapter->caDsxReqResp) return -ENOMEM; @@ -1637,6 +1825,8 @@ bool CmControlResponseMessage(struct bcm_mini_adapter *Adapter, /* <Pointer to struct bcm_add_indication_alt *pstAddIndication = NULL; struct bcm_change_indication *pstChangeIndication = NULL; struct bcm_leader *pLeader = NULL; + INT uiSearchRuleIndex = 0; + ULONG ulSFID; /* * Otherwise the message contains a target address from where we need to @@ -1660,7 +1850,6 @@ bool CmControlResponseMessage(struct bcm_mini_adapter *Adapter, /* <Pointer to BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "### TID RECEIVED %d\n", pstAddIndication->u16TID); switch (pstAddIndication->u8Type) { case DSA_REQ: - { pLeader->PLength = sizeof(struct bcm_add_indication_alt); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Sending DSA Response....\n"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSA RESPONSE TO MAC %d", pLeader->PLength); @@ -1671,22 +1860,16 @@ bool CmControlResponseMessage(struct bcm_mini_adapter *Adapter, /* <Pointer to BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " VCID = %x", ntohs(pstAddIndication->u16VCID)); CopyBufferToControlPacket(Adapter, (PVOID)Adapter->caDsxReqResp); kfree(pstAddIndication); - } - break; + break; case DSA_RSP: - { pLeader->PLength = sizeof(struct bcm_add_indication_alt); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSA ACK TO MAC %d", pLeader->PLength); *((struct bcm_add_indication_alt *)&(Adapter->caDsxReqResp[LEADER_SIZE])) = *pstAddIndication; ((struct bcm_add_indication_alt *)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSA_ACK; - - } /* no break here..we should go down. */ + /* FALLTHROUGH */ case DSA_ACK: - { - UINT uiSearchRuleIndex = 0; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "VCID:0x%X", ntohs(pstAddIndication->u16VCID)); uiSearchRuleIndex = SearchFreeSfid(Adapter); @@ -1694,7 +1877,7 @@ bool CmControlResponseMessage(struct bcm_mini_adapter *Adapter, /* <Pointer to uiSearchRuleIndex); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Direction:0x%X ", pstAddIndication->u8Direction); - if ((uiSearchRuleIndex < NO_OF_QUEUES)) { + if (uiSearchRuleIndex < NO_OF_QUEUES) { Adapter->PackInfo[uiSearchRuleIndex].ucDirection = pstAddIndication->u8Direction; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "bValid:0x%X ", @@ -1769,10 +1952,8 @@ bool CmControlResponseMessage(struct bcm_mini_adapter *Adapter, /* <Pointer to kfree(pstAddIndication); return false; } - } - break; + break; case DSC_REQ: - { pLeader->PLength = sizeof(struct bcm_change_indication); pstChangeIndication = (struct bcm_change_indication *)pstAddIndication; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSC RESPONSE TO MAC %d", pLeader->PLength); @@ -1782,26 +1963,21 @@ bool CmControlResponseMessage(struct bcm_mini_adapter *Adapter, /* <Pointer to CopyBufferToControlPacket(Adapter, (PVOID)Adapter->caDsxReqResp); kfree(pstAddIndication); - } - break; + break; case DSC_RSP: - { pLeader->PLength = sizeof(struct bcm_change_indication); pstChangeIndication = (struct bcm_change_indication *)pstAddIndication; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSC ACK TO MAC %d", pLeader->PLength); *((struct bcm_change_indication *)&(Adapter->caDsxReqResp[LEADER_SIZE])) = *pstChangeIndication; ((struct bcm_change_indication *)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSC_ACK; - } + /* FALLTHROUGH */ case DSC_ACK: - { - UINT uiSearchRuleIndex = 0; - pstChangeIndication = (struct bcm_change_indication *)pstAddIndication; uiSearchRuleIndex = SearchSfid(Adapter, ntohl(pstChangeIndication->sfActiveSet.u32SFID)); if (uiSearchRuleIndex > NO_OF_QUEUES-1) BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "SF doesn't exist for which DSC_ACK is received"); - if ((uiSearchRuleIndex < NO_OF_QUEUES)) { + if (uiSearchRuleIndex < NO_OF_QUEUES) { Adapter->PackInfo[uiSearchRuleIndex].ucDirection = pstChangeIndication->u8Direction; if (pstChangeIndication->sfActiveSet.bValid == TRUE) Adapter->PackInfo[uiSearchRuleIndex].bActiveSet = TRUE; @@ -1849,13 +2025,8 @@ bool CmControlResponseMessage(struct bcm_mini_adapter *Adapter, /* <Pointer to kfree(pstAddIndication); return false; } - } - break; + break; case DSD_REQ: - { - UINT uiSearchRuleIndex; - ULONG ulSFID; - pLeader->PLength = sizeof(struct bcm_del_indication); *((struct bcm_del_indication *)&(Adapter->caDsxReqResp[LEADER_SIZE])) = *((struct bcm_del_indication *)pstAddIndication); @@ -1872,12 +2043,10 @@ bool CmControlResponseMessage(struct bcm_mini_adapter *Adapter, /* <Pointer to BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSD RESPONSE TO MAC"); ((struct bcm_del_indication *)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSD_RSP; CopyBufferToControlPacket(Adapter, (PVOID)Adapter->caDsxReqResp); - } + /* FALLTHROUGH */ case DSD_RSP: - { /* Do nothing as SF has already got Deleted */ - } - break; + break; case DSD_ACK: BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "DSD ACK Rcd, let App handle it\n"); break; @@ -1888,29 +2057,37 @@ bool CmControlResponseMessage(struct bcm_mini_adapter *Adapter, /* <Pointer to return TRUE; } -int get_dsx_sf_data_to_application(struct bcm_mini_adapter *Adapter, UINT uiSFId, void __user *user_buffer) +int get_dsx_sf_data_to_application(struct bcm_mini_adapter *Adapter, + UINT uiSFId, void __user *user_buffer) { int status = 0; struct bcm_packet_info *psSfInfo = NULL; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "status =%d", status); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "status =%d", status); status = SearchSfid(Adapter, uiSFId); if (status >= NO_OF_QUEUES) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SFID %d not present in queue !!!", uiSFId); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "SFID %d not present in queue !!!", uiSFId); return -EINVAL; } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "status =%d", status); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "status =%d", status); psSfInfo = &Adapter->PackInfo[status]; - if (psSfInfo->pstSFIndication && copy_to_user(user_buffer, - psSfInfo->pstSFIndication, sizeof(struct bcm_add_indication_alt))) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "copy to user failed SFID %d, present in queue !!!", uiSFId); + if (psSfInfo->pstSFIndication + && copy_to_user(user_buffer, psSfInfo->pstSFIndication, + sizeof(struct bcm_add_indication_alt))) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "copy to user failed SFID %d, present in queue !!!", + uiSFId); status = -EFAULT; return status; } return STATUS_SUCCESS; } -VOID OverrideServiceFlowParams(struct bcm_mini_adapter *Adapter, PUINT puiBuffer) +VOID OverrideServiceFlowParams(struct bcm_mini_adapter *Adapter, + PUINT puiBuffer) { B_UINT32 u32NumofSFsinMsg = ntohl(*(puiBuffer + 1)); struct bcm_stim_sfhostnotify *pHostInfo = NULL; @@ -1918,7 +2095,8 @@ VOID OverrideServiceFlowParams(struct bcm_mini_adapter *Adapter, PUINT puiBuffer ULONG ulSFID = 0; puiBuffer += 2; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32NumofSFsinMsg: 0x%x\n", u32NumofSFsinMsg); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "u32NumofSFsinMsg: 0x%x\n", u32NumofSFsinMsg); while (u32NumofSFsinMsg != 0 && u32NumofSFsinMsg < NO_OF_QUEUES) { u32NumofSFsinMsg--; @@ -1927,31 +2105,149 @@ VOID OverrideServiceFlowParams(struct bcm_mini_adapter *Adapter, PUINT puiBuffer ulSFID = ntohl(pHostInfo->SFID); uiSearchRuleIndex = SearchSfid(Adapter, ulSFID); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SFID: 0x%lx\n", ulSFID); - - if (uiSearchRuleIndex >= NO_OF_QUEUES || uiSearchRuleIndex == HiPriority) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "The SFID <%lx> doesn't exist in host entry or is Invalid\n", ulSFID); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "SFID: 0x%lx\n", ulSFID); + + if (uiSearchRuleIndex >= NO_OF_QUEUES + || uiSearchRuleIndex == HiPriority) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, + DBG_LVL_ALL, + "The SFID <%lx> doesn't exist in host entry or is Invalid\n", + ulSFID); continue; } if (pHostInfo->RetainSF == false) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Going to Delete SF"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, + DBG_LVL_ALL, "Going to Delete SF"); deleteSFBySfid(Adapter, uiSearchRuleIndex); } else { - Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value = ntohs(pHostInfo->VCID); - Adapter->PackInfo[uiSearchRuleIndex].usCID = ntohs(pHostInfo->newCID); - Adapter->PackInfo[uiSearchRuleIndex].bActive = false; + struct bcm_packet_info *packinfo = + &Adapter->PackInfo[uiSearchRuleIndex]; + + packinfo->usVCID_Value = ntohs(pHostInfo->VCID); + packinfo->usCID = ntohs(pHostInfo->newCID); + packinfo->bActive = false; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "pHostInfo->QoSParamSet: 0x%x\n", pHostInfo->QoSParamSet); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, + DBG_LVL_ALL, + "pHostInfo->QoSParamSet: 0x%x\n", + pHostInfo->QoSParamSet); if (pHostInfo->QoSParamSet & 0x1) - Adapter->PackInfo[uiSearchRuleIndex].bAuthorizedSet = TRUE; + packinfo->bAuthorizedSet = TRUE; if (pHostInfo->QoSParamSet & 0x2) - Adapter->PackInfo[uiSearchRuleIndex].bAdmittedSet = TRUE; + packinfo->bAdmittedSet = TRUE; if (pHostInfo->QoSParamSet & 0x4) { - Adapter->PackInfo[uiSearchRuleIndex].bActiveSet = TRUE; - Adapter->PackInfo[uiSearchRuleIndex].bActive = TRUE; + packinfo->bActiveSet = TRUE; + packinfo->bActive = TRUE; } } } } + +static void restore_endianess_of_pstClassifierEntry( + struct bcm_classifier_rule *pstClassifierEntry, + enum bcm_ipaddr_context eIpAddrContext) +{ + int i; + union u_ip_address *stSrc = &pstClassifierEntry->stSrcIpAddress; + union u_ip_address *stDest = &pstClassifierEntry->stDestIpAddress; + + for (i = 0; i < MAX_IP_RANGE_LENGTH * 4; i++) { + if (eIpAddrContext == eSrcIpAddress) { + stSrc->ulIpv6Addr[i] = ntohl(stSrc->ulIpv6Addr[i]); + stSrc->ulIpv6Mask[i] = ntohl(stSrc->ulIpv6Mask[i]); + } else if (eIpAddrContext == eDestIpAddress) { + stDest->ulIpv6Addr[i] = ntohl(stDest->ulIpv6Addr[i]); + stDest->ulIpv6Mask[i] = ntohl(stDest->ulIpv6Mask[i]); + } + } +} + +static void apply_phs_rule_to_all_classifiers( + register struct bcm_mini_adapter *Adapter, /* <Pointer to the Adapter structure */ + register UINT uiSearchRuleIndex, /* <Index of Queue, to which this data belongs */ + USHORT uVCID, + struct bcm_phs_rule *sPhsRule, + struct bcm_phs_rules *cPhsRule, + struct bcm_add_indication_alt *pstAddIndication) +{ + unsigned int uiClassifierIndex = 0; + struct bcm_classifier_rule *curr_classifier = NULL; + + if (pstAddIndication->u8Direction == UPLINK_DIR) { + for (uiClassifierIndex = 0; uiClassifierIndex < MAX_CLASSIFIERS; uiClassifierIndex++) { + curr_classifier = + &Adapter->astClassifierTable[uiClassifierIndex]; + if ((curr_classifier->bUsed) && + (curr_classifier->ulSFID == Adapter->PackInfo[uiSearchRuleIndex].ulSFID) && + (curr_classifier->u8AssociatedPHSI == cPhsRule->u8PHSI)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Adding PHS Rule For Classifier: 0x%x cPhsRule.u8PHSI: 0x%x\n", + curr_classifier->uiClassifierRuleIndex, + cPhsRule->u8PHSI); + /* Update The PHS Rule for this classifier as Associated PHSI id defined */ + + /* Copy the PHS Rule */ + sPhsRule->u8PHSI = cPhsRule->u8PHSI; + sPhsRule->u8PHSFLength = cPhsRule->u8PHSFLength; + sPhsRule->u8PHSMLength = cPhsRule->u8PHSMLength; + sPhsRule->u8PHSS = cPhsRule->u8PHSS; + sPhsRule->u8PHSV = cPhsRule->u8PHSV; + memcpy(sPhsRule->u8PHSF, cPhsRule->u8PHSF, MAX_PHS_LENGTHS); + memcpy(sPhsRule->u8PHSM, cPhsRule->u8PHSM, MAX_PHS_LENGTHS); + sPhsRule->u8RefCnt = 0; + sPhsRule->bUnclassifiedPHSRule = false; + sPhsRule->PHSModifiedBytes = 0; + sPhsRule->PHSModifiedNumPackets = 0; + sPhsRule->PHSErrorNumPackets = 0; + + /* bPHSRuleAssociated = TRUE; */ + /* Store The PHS Rule for this classifier */ + + PhsUpdateClassifierRule( + &Adapter->stBCMPhsContext, + uVCID, + curr_classifier->uiClassifierRuleIndex, + sPhsRule, + curr_classifier->u8AssociatedPHSI); + + /* Update PHS Rule For the Classifier */ + if (sPhsRule->u8PHSI) { + curr_classifier->u32PHSRuleID = sPhsRule->u8PHSI; + memcpy(&curr_classifier->sPhsRule, sPhsRule, sizeof(struct bcm_phs_rule)); + } + } + } + } else { + /* Error PHS Rule specified in signaling could not be applied to any classifier */ + + /* Copy the PHS Rule */ + sPhsRule->u8PHSI = cPhsRule->u8PHSI; + sPhsRule->u8PHSFLength = cPhsRule->u8PHSFLength; + sPhsRule->u8PHSMLength = cPhsRule->u8PHSMLength; + sPhsRule->u8PHSS = cPhsRule->u8PHSS; + sPhsRule->u8PHSV = cPhsRule->u8PHSV; + memcpy(sPhsRule->u8PHSF, cPhsRule->u8PHSF, MAX_PHS_LENGTHS); + memcpy(sPhsRule->u8PHSM, cPhsRule->u8PHSM, MAX_PHS_LENGTHS); + sPhsRule->u8RefCnt = 0; + sPhsRule->bUnclassifiedPHSRule = TRUE; + sPhsRule->PHSModifiedBytes = 0; + sPhsRule->PHSModifiedNumPackets = 0; + sPhsRule->PHSErrorNumPackets = 0; + /* Store The PHS Rule for this classifier */ + + /* + * Passing the argument u8PHSI instead of clsid. Because for DL with no classifier rule, + * clsid will be zero hence we can't have multiple PHS rules for the same SF. + * To support multiple PHS rule, passing u8PHSI. + */ + PhsUpdateClassifierRule( + &Adapter->stBCMPhsContext, + uVCID, + sPhsRule->u8PHSI, + sPhsRule, + sPhsRule->u8PHSI); + } +} diff --git a/drivers/staging/bcm/DDRInit.c b/drivers/staging/bcm/DDRInit.c index ed285b2d892..f1d7cb82fd7 100644 --- a/drivers/staging/bcm/DDRInit.c +++ b/drivers/staging/bcm/DDRInit.c @@ -3,7 +3,7 @@ #define DDR_DUMP_INTERNAL_DEVICE_MEMORY 0xBFC02B00 -#define MIPS_CLOCK_REG 0x0f000820 +#define MIPS_CLOCK_REG 0x0f000820 /* DDR INIT-133Mhz */ #define T3_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 12 /* index for 0x0F007000 */ @@ -818,13 +818,13 @@ int ddr_init(struct bcm_mini_adapter *Adapter) if ((Adapter->chip_id != BCS220_2) && (Adapter->chip_id != BCS220_2BC) && (Adapter->chip_id != BCS220_3)) { - retval = rdmalt(Adapter,(UINT)0x0f000830, &uiResetValue, sizeof(uiResetValue)); + retval = rdmalt(Adapter, (UINT)0x0f000830, &uiResetValue, sizeof(uiResetValue)); if (retval < 0) { BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } uiResetValue |= 0x44; - retval = wrmalt(Adapter,(UINT)0x0f000830, &uiResetValue, sizeof(uiResetValue)); + retval = wrmalt(Adapter, (UINT)0x0f000830, &uiResetValue, sizeof(uiResetValue)); if (retval < 0) { BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; @@ -871,7 +871,7 @@ int ddr_init(struct bcm_mini_adapter *Adapter) case 0xbece0121: case 0xbece0130: case 0xbece0300: - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "DDR Setting: %x\n", Adapter->DDRSetting); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "DDR Setting: %x\n", Adapter->DDRSetting); switch (Adapter->DDRSetting) { case DDR_80_MHZ: psDDRSetting = asT3_DDRSetting80MHz; @@ -933,7 +933,7 @@ int ddr_init(struct bcm_mini_adapter *Adapter) } value = 0; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Register Count is =%lu\n", RegCount); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Register Count is =%lu\n", RegCount); while (RegCount && !retval) { if (uiClockSetting && psDDRSetting->ulRegAddress == MIPS_CLOCK_REG) value = uiClockSetting; @@ -990,12 +990,12 @@ int ddr_init(struct bcm_mini_adapter *Adapter) * we will change this when we will have internal PMU. */ if (Adapter->PmuMode == HYBRID_MODE_7C) { - retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); + retval = rdmalt(Adapter, (UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); if (retval < 0) { BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } - retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); + retval = rdmalt(Adapter, (UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); if (retval < 0) { BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; @@ -1006,12 +1006,12 @@ int ddr_init(struct bcm_mini_adapter *Adapter) BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } - retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); + retval = rdmalt(Adapter, (UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); if (retval < 0) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } - retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); + retval = rdmalt(Adapter, (UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); if (retval < 0) { BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; @@ -1024,12 +1024,12 @@ int ddr_init(struct bcm_mini_adapter *Adapter) } } else if (Adapter->PmuMode == HYBRID_MODE_6) { - retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); + retval = rdmalt(Adapter, (UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); if (retval < 0) { BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } - retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); + retval = rdmalt(Adapter, (UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); if (retval < 0) { BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; @@ -1040,12 +1040,12 @@ int ddr_init(struct bcm_mini_adapter *Adapter) BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } - retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); + retval = rdmalt(Adapter, (UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); if (retval < 0) { BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } - retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); + retval = rdmalt(Adapter, (UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); if (retval < 0) { BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; @@ -1094,8 +1094,8 @@ int download_ddr_settings(struct bcm_mini_adapter *Adapter) RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ; psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ; break; - default: - return -EINVAL; + default: + return -EINVAL; } break; @@ -1215,7 +1215,7 @@ int download_ddr_settings(struct bcm_mini_adapter *Adapter) ul_ddr_setting_load_addr += sizeof(ULONG); if (!retval) { if (bOverrideSelfRefresh && (psDDRSetting->ulRegAddress == 0x0F007018)) { - value = (psDDRSetting->ulRegValue |(1<<8)); + value = (psDDRSetting->ulRegValue | (1<<8)); if (STATUS_SUCCESS != wrmalt(Adapter, ul_ddr_setting_load_addr, &value, sizeof(value))) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "%s:%d\n", __func__, __LINE__); diff --git a/drivers/staging/bcm/InterfaceDld.c b/drivers/staging/bcm/InterfaceDld.c index 005e4607b26..e1925bdc127 100644 --- a/drivers/staging/bcm/InterfaceDld.c +++ b/drivers/staging/bcm/InterfaceDld.c @@ -53,8 +53,8 @@ int InterfaceFileReadbackFromChip(PVOID arg, struct file *flp, struct bcm_interface_adapter *psIntfAdapter = arg; int bytes; - buff = kmalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_DMA); - buff_readback = kmalloc(MAX_TRANSFER_CTRL_BYTE_USB , GFP_DMA); + buff = kzalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_DMA); + buff_readback = kzalloc(MAX_TRANSFER_CTRL_BYTE_USB , GFP_DMA); if (!buff || !buff_readback) { kfree(buff); kfree(buff_readback); @@ -64,8 +64,6 @@ int InterfaceFileReadbackFromChip(PVOID arg, struct file *flp, is_config_file = (on_chip_loc == CONFIG_BEGIN_ADDR) ? 1 : 0; - memset(buff_readback, 0, MAX_TRANSFER_CTRL_BYTE_USB); - memset(buff, 0, MAX_TRANSFER_CTRL_BYTE_USB); while (1) { oldfs = get_fs(); set_fs(get_ds()); diff --git a/drivers/staging/bcm/InterfaceIdleMode.c b/drivers/staging/bcm/InterfaceIdleMode.c index fecf81ffe06..c84ee494f55 100644 --- a/drivers/staging/bcm/InterfaceIdleMode.c +++ b/drivers/staging/bcm/InterfaceIdleMode.c @@ -223,7 +223,6 @@ static int InterfaceAbortIdlemode(struct bcm_mini_adapter *Adapter, } int InterfaceIdleModeWakeup(struct bcm_mini_adapter *Adapter) { - ULONG Status = 0; if (Adapter->bTriedToWakeUpFromlowPowerMode) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, @@ -233,7 +232,7 @@ int InterfaceIdleModeWakeup(struct bcm_mini_adapter *Adapter) InterfaceAbortIdlemode(Adapter, Adapter->usIdleModePattern); } - return Status; + return 0; } void InterfaceHandleShutdownModeWakeup(struct bcm_mini_adapter *Adapter) diff --git a/drivers/staging/bcm/InterfaceInit.c b/drivers/staging/bcm/InterfaceInit.c index 94f32728f7c..7c04c73e3bc 100644 --- a/drivers/staging/bcm/InterfaceInit.c +++ b/drivers/staging/bcm/InterfaceInit.c @@ -1,5 +1,5 @@ #include "headers.h" - +#include <linux/usb/ch9.h> static struct usb_device_id InterfaceUsbtable[] = { { USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3) }, { USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3B) }, @@ -30,19 +30,22 @@ static void InterfaceAdapterFree(struct bcm_interface_adapter *psIntfAdapter) int i = 0; /* Wake up the wait_queue... */ - if (psIntfAdapter->psAdapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { + if (psIntfAdapter->psAdapter->LEDInfo.led_thread_running & + BCM_LED_THREAD_RUNNING_ACTIVELY) { psIntfAdapter->psAdapter->DriverState = DRIVER_HALT; wake_up(&psIntfAdapter->psAdapter->LEDInfo.notify_led_event); } reset_card_proc(psIntfAdapter->psAdapter); /* - * worst case time taken by the RDM/WRM will be 5 sec. will check after every 100 ms - * to accertain the device is not being accessed. After this No RDM/WRM should be made. + * worst case time taken by the RDM/WRM will be 5 sec. will check after + * every 100 ms to accertain the device is not being accessed. After + * this No RDM/WRM should be made. */ while (psIntfAdapter->psAdapter->DeviceAccess) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, - "Device is being accessed.\n"); + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, + DRV_ENTRY, DBG_LVL_ALL, + "Device is being accessed.\n"); msleep(100); } /* Free interrupt URB */ @@ -71,6 +74,7 @@ static void ConfigureEndPointTypesThroughEEPROM(struct bcm_mini_adapter *Adapter { u32 ulReg; int bytes; + struct bcm_interface_adapter *interfaceAdapter; /* Program EP2 MAX_PKT_SIZE */ ulReg = ntohl(EP2_MPS_REG); @@ -80,7 +84,9 @@ static void ConfigureEndPointTypesThroughEEPROM(struct bcm_mini_adapter *Adapter ulReg = ntohl(EP2_CFG_REG); BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x132, 4, TRUE); - if (((struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter))->bHighSpeedDevice == TRUE) { + interfaceAdapter = + (struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter); + if (interfaceAdapter->bHighSpeedDevice) { ulReg = ntohl(EP2_CFG_INT); BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x136, 4, TRUE); } else { @@ -98,8 +104,8 @@ static void ConfigureEndPointTypesThroughEEPROM(struct bcm_mini_adapter *Adapter /* Program TX EP as interrupt(Alternate Setting) */ bytes = rdmalt(Adapter, 0x0F0110F8, &ulReg, sizeof(u32)); if (bytes < 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, - "reading of Tx EP failed\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, DRV_ENTRY, + DBG_LVL_ALL, "reading of Tx EP failed\n"); return; } ulReg |= 0x6; @@ -150,7 +156,8 @@ static int usbbcm_device_probe(struct usb_interface *intf, const struct usb_devi struct net_device *ndev; /* Reserve one extra queue for the bit-bucket */ - ndev = alloc_etherdev_mq(sizeof(struct bcm_mini_adapter), NO_OF_QUEUES+1); + ndev = alloc_etherdev_mq(sizeof(struct bcm_mini_adapter), + NO_OF_QUEUES + 1); if (ndev == NULL) { dev_err(&udev->dev, DRV_NAME ": no memory for device\n"); return -ENOMEM; @@ -169,13 +176,14 @@ static int usbbcm_device_probe(struct usb_interface *intf, const struct usb_devi /* * Technically, one can start using BCM_DEBUG_PRINT after this point. - * However, realize that by default the Type/Subtype bitmaps are all zero now; - * so no prints will actually appear until the TestApp turns on debug paths via - * the ioctl(); so practically speaking, in early init, no logging happens. + * However, realize that by default the Type/Subtype bitmaps are all + * zero now; so no prints will actually appear until the TestApp turns + * on debug paths via the ioctl(); so practically speaking, in early + * init, no logging happens. * - * A solution (used below): we explicitly set the bitmaps to 1 for Type=DBG_TYPE_INITEXIT - * and ALL subtype's of the same. Now all bcm debug statements get logged, enabling debug - * during early init. + * A solution (used below): we explicitly set the bitmaps to 1 for + * Type=DBG_TYPE_INITEXIT and ALL subtype's of the same. Now all bcm + * debug statements get logged, enabling debug during early init. * Further, we turn this OFF once init_module() completes. */ @@ -191,7 +199,7 @@ static int usbbcm_device_probe(struct usb_interface *intf, const struct usb_devi /* Allocate interface adapter structure */ psIntfAdapter = kzalloc(sizeof(struct bcm_interface_adapter), - GFP_KERNEL); + GFP_KERNEL); if (psIntfAdapter == NULL) { AdapterFree(psAdapter); return -ENOMEM; @@ -205,7 +213,7 @@ static int usbbcm_device_probe(struct usb_interface *intf, const struct usb_devi usb_set_intfdata(intf, psIntfAdapter); BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, - "psIntfAdapter 0x%p\n", psIntfAdapter); + "psIntfAdapter 0x%p\n", psIntfAdapter); retval = InterfaceAdapterInit(psIntfAdapter); if (retval) { /* If the Firmware/Cfg File is not present @@ -213,12 +221,13 @@ static int usbbcm_device_probe(struct usb_interface *intf, const struct usb_devi * download the files. */ if (-ENOENT == retval) { - BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, - "File Not Found. Use app to download.\n"); + BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, + DBG_LVL_ALL, + "File Not Found. Use app to download.\n"); return STATUS_SUCCESS; } - BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, - "InterfaceAdapterInit failed.\n"); + BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, + DBG_LVL_ALL, "InterfaceAdapterInit failed.\n"); usb_set_intfdata(intf, NULL); udev = interface_to_usbdev(intf); usb_put_dev(udev); @@ -228,7 +237,10 @@ static int usbbcm_device_probe(struct usb_interface *intf, const struct usb_devi if (psAdapter->chip_id > T3) { uint32_t uiNackZeroLengthInt = 4; - retval = wrmalt(psAdapter, DISABLE_USB_ZERO_LEN_INT, &uiNackZeroLengthInt, sizeof(uiNackZeroLengthInt)); + retval = + wrmalt(psAdapter, DISABLE_USB_ZERO_LEN_INT, + &uiNackZeroLengthInt, + sizeof(uiNackZeroLengthInt)); if (retval) return retval; } @@ -242,9 +254,11 @@ static int usbbcm_device_probe(struct usb_interface *intf, const struct usb_devi intf->needs_remote_wakeup = 1; usb_enable_autosuspend(udev); device_init_wakeup(&intf->dev, 1); - INIT_WORK(&psIntfAdapter->usbSuspendWork, putUsbSuspend); - BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, - "Enabling USB Auto-Suspend\n"); + INIT_WORK(&psIntfAdapter->usbSuspendWork, + putUsbSuspend); + BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, + DBG_LVL_ALL, + "Enabling USB Auto-Suspend\n"); #endif } else { intf->needs_remote_wakeup = 0; @@ -271,7 +285,7 @@ static void usbbcm_disconnect(struct usb_interface *intf) if (psAdapter->bDoSuspend) intf->needs_remote_wakeup = 0; - psAdapter->device_removed = TRUE ; + psAdapter->device_removed = TRUE; usb_set_intfdata(intf, NULL); InterfaceAdapterFree(psIntfAdapter); usb_put_dev(udev); @@ -285,8 +299,10 @@ static int AllocUsbCb(struct bcm_interface_adapter *psIntfAdapter) psIntfAdapter->asUsbTcb[i].urb = usb_alloc_urb(0, GFP_KERNEL); if (psIntfAdapter->asUsbTcb[i].urb == NULL) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, - "Can't allocate Tx urb for index %d\n", i); + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, + DBG_TYPE_PRINTK, 0, 0, + "Can't allocate Tx urb for index %d\n", + i); return -ENOMEM; } } @@ -295,19 +311,25 @@ static int AllocUsbCb(struct bcm_interface_adapter *psIntfAdapter) psIntfAdapter->asUsbRcb[i].urb = usb_alloc_urb(0, GFP_KERNEL); if (psIntfAdapter->asUsbRcb[i].urb == NULL) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, - "Can't allocate Rx urb for index %d\n", i); + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, + DBG_TYPE_PRINTK, 0, 0, + "Can't allocate Rx urb for index %d\n", + i); return -ENOMEM; } - psIntfAdapter->asUsbRcb[i].urb->transfer_buffer = kmalloc(MAX_DATA_BUFFER_SIZE, GFP_KERNEL); + psIntfAdapter->asUsbRcb[i].urb->transfer_buffer = + kmalloc(MAX_DATA_BUFFER_SIZE, GFP_KERNEL); if (psIntfAdapter->asUsbRcb[i].urb->transfer_buffer == NULL) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, - "Can't allocate Rx buffer for index %d\n", i); + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, + DBG_TYPE_PRINTK, 0, 0, + "Can't allocate Rx buffer for index %d\n", + i); return -ENOMEM; } - psIntfAdapter->asUsbRcb[i].urb->transfer_buffer_length = MAX_DATA_BUFFER_SIZE; + psIntfAdapter->asUsbRcb[i].urb->transfer_buffer_length = + MAX_DATA_BUFFER_SIZE; } return 0; } @@ -322,24 +344,29 @@ static int device_run(struct bcm_interface_adapter *psIntfAdapter) pr_err(DRV_NAME "InitCardAndDownloadFirmware failed.\n"); return status; } - if (TRUE == psIntfAdapter->psAdapter->fw_download_done) { + if (psIntfAdapter->psAdapter->fw_download_done) { if (StartInterruptUrb(psIntfAdapter)) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, - "Cannot send interrupt in URB\n"); + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, + DBG_TYPE_INITEXIT, DRV_ENTRY, + DBG_LVL_ALL, + "Cannot send interrupt in URB\n"); } /* - * now register the cntrl interface. - * after downloading the f/w waiting for 5 sec to get the mailbox interrupt. + * now register the cntrl interface. after downloading the f/w + * waiting for 5 sec to get the mailbox interrupt. */ psIntfAdapter->psAdapter->waiting_to_fw_download_done = false; - value = wait_event_timeout(psIntfAdapter->psAdapter->ioctl_fw_dnld_wait_queue, - psIntfAdapter->psAdapter->waiting_to_fw_download_done, 5*HZ); + value = wait_event_timeout( + psIntfAdapter->psAdapter->ioctl_fw_dnld_wait_queue, + psIntfAdapter->psAdapter->waiting_to_fw_download_done, + 5 * HZ); if (value == 0) pr_err(DRV_NAME ": Timeout waiting for mailbox interrupt.\n"); - if (register_control_device_interface(psIntfAdapter->psAdapter) < 0) { + if (register_control_device_interface( + psIntfAdapter->psAdapter) < 0) { pr_err(DRV_NAME ": Register Control Device failed.\n"); return -EIO; } @@ -347,81 +374,6 @@ static int device_run(struct bcm_interface_adapter *psIntfAdapter) return 0; } - -static inline int bcm_usb_endpoint_num(const struct usb_endpoint_descriptor *epd) -{ - return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; -} - -static inline int bcm_usb_endpoint_type(const struct usb_endpoint_descriptor *epd) -{ - return epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; -} - -static inline int bcm_usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd) -{ - return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN); -} - -static inline int bcm_usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd) -{ - return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT); -} - -static inline int bcm_usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd) -{ - return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == - USB_ENDPOINT_XFER_BULK); -} - -static inline int bcm_usb_endpoint_xfer_control(const struct usb_endpoint_descriptor *epd) -{ - return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == - USB_ENDPOINT_XFER_CONTROL); -} - -static inline int bcm_usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd) -{ - return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == - USB_ENDPOINT_XFER_INT); -} - -static inline int bcm_usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd) -{ - return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == - USB_ENDPOINT_XFER_ISOC); -} - -static inline int bcm_usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd) -{ - return bcm_usb_endpoint_xfer_bulk(epd) && bcm_usb_endpoint_dir_in(epd); -} - -static inline int bcm_usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd) -{ - return bcm_usb_endpoint_xfer_bulk(epd) && bcm_usb_endpoint_dir_out(epd); -} - -static inline int bcm_usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd) -{ - return bcm_usb_endpoint_xfer_int(epd) && bcm_usb_endpoint_dir_in(epd); -} - -static inline int bcm_usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *epd) -{ - return bcm_usb_endpoint_xfer_int(epd) && bcm_usb_endpoint_dir_out(epd); -} - -static inline int bcm_usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *epd) -{ - return bcm_usb_endpoint_xfer_isoc(epd) && bcm_usb_endpoint_dir_in(epd); -} - -static inline int bcm_usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor *epd) -{ - return bcm_usb_endpoint_xfer_isoc(epd) && bcm_usb_endpoint_dir_out(epd); -} - static int InterfaceAdapterInit(struct bcm_interface_adapter *psIntfAdapter) { struct usb_host_interface *iface_desc; @@ -429,23 +381,27 @@ static int InterfaceAdapterInit(struct bcm_interface_adapter *psIntfAdapter) size_t buffer_size; unsigned long value; int retval = 0; - int usedIntOutForBulkTransfer = 0 ; + int usedIntOutForBulkTransfer = 0; bool bBcm16 = false; UINT uiData = 0; int bytes; /* Store the usb dev into interface adapter */ - psIntfAdapter->udev = usb_get_dev(interface_to_usbdev(psIntfAdapter->interface)); + psIntfAdapter->udev = + usb_get_dev(interface_to_usbdev(psIntfAdapter->interface)); - psIntfAdapter->bHighSpeedDevice = (psIntfAdapter->udev->speed == USB_SPEED_HIGH); + psIntfAdapter->bHighSpeedDevice = + (psIntfAdapter->udev->speed == USB_SPEED_HIGH); psIntfAdapter->psAdapter->interface_rdm = BcmRDM; psIntfAdapter->psAdapter->interface_wrm = BcmWRM; bytes = rdmalt(psIntfAdapter->psAdapter, CHIP_ID_REG, - (u32 *)&(psIntfAdapter->psAdapter->chip_id), sizeof(u32)); + (u32 *) &(psIntfAdapter->psAdapter->chip_id), + sizeof(u32)); if (bytes < 0) { retval = bytes; - 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 retval; } @@ -453,81 +409,119 @@ static int InterfaceAdapterInit(struct bcm_interface_adapter *psIntfAdapter) psIntfAdapter->psAdapter->chip_id &= ~0xF0; dev_info(&psIntfAdapter->udev->dev, "RDM Chip ID 0x%lx\n", - psIntfAdapter->psAdapter->chip_id); + psIntfAdapter->psAdapter->chip_id); iface_desc = psIntfAdapter->interface->cur_altsetting; 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); if (uiData == BECM) bBcm16 = TRUE; - dev_info(&psIntfAdapter->udev->dev, "number of alternate setting %d\n", - psIntfAdapter->interface->num_altsetting); + dev_info(&psIntfAdapter->udev->dev, + "number of alternate setting %d\n", + psIntfAdapter->interface->num_altsetting); if (bBcm16 == TRUE) { - /* selecting alternate setting one as a default setting for High Speed modem. */ + /* selecting alternate setting one as a default setting + * for High Speed modem. */ if (psIntfAdapter->bHighSpeedDevice) - retval = usb_set_interface(psIntfAdapter->udev, DEFAULT_SETTING_0, ALTERNATE_SETTING_1); - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, - "BCM16 is applicable on this dongle\n"); - if (retval || (psIntfAdapter->bHighSpeedDevice == false)) { - usedIntOutForBulkTransfer = EP2 ; + retval = usb_set_interface(psIntfAdapter->udev, + DEFAULT_SETTING_0, + ALTERNATE_SETTING_1); + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, + DBG_TYPE_INITEXIT, DRV_ENTRY, + DBG_LVL_ALL, + "BCM16 is applicable on this dongle\n"); + if (retval || !psIntfAdapter->bHighSpeedDevice) { + usedIntOutForBulkTransfer = EP2; endpoint = &iface_desc->endpoint[EP2].desc; - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, - "Interface altsetting failed or modem is configured to Full Speed, hence will work on default setting 0\n"); + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, + DBG_TYPE_INITEXIT, DRV_ENTRY, + DBG_LVL_ALL, + "Interface altsetting failed or modem is configured to Full Speed, hence will work on default setting 0\n"); /* - * If Modem is high speed device EP2 should be INT OUT End point - * If Mode is FS then EP2 should be bulk end point + * If Modem is high speed device EP2 should be + * INT OUT End point + * + * If Mode is FS then EP2 should be bulk end + * point */ - if (((psIntfAdapter->bHighSpeedDevice == TRUE) && (bcm_usb_endpoint_is_int_out(endpoint) == false)) - || ((psIntfAdapter->bHighSpeedDevice == false) && (bcm_usb_endpoint_is_bulk_out(endpoint) == false))) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, - "Configuring the EEPROM\n"); + if ((psIntfAdapter->bHighSpeedDevice && + !usb_endpoint_is_int_out(endpoint)) || + (!psIntfAdapter->bHighSpeedDevice && + !usb_endpoint_is_bulk_out(endpoint))) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, + DBG_TYPE_INITEXIT, + DRV_ENTRY, DBG_LVL_ALL, + "Configuring the EEPROM\n"); /* change the EP2, EP4 to INT OUT end point */ - ConfigureEndPointTypesThroughEEPROM(psIntfAdapter->psAdapter); + ConfigureEndPointTypesThroughEEPROM( + psIntfAdapter->psAdapter); /* - * It resets the device and if any thing gets changed - * in USB descriptor it will show fail and re-enumerate - * the device + * It resets the device and if any thing + * gets changed in USB descriptor it + * will show fail and re-enumerate the + * device */ - retval = usb_reset_device(psIntfAdapter->udev); + retval = usb_reset_device( + psIntfAdapter->udev); if (retval) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, - "reset failed. Re-enumerating the device.\n"); - return retval ; + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, + DBG_TYPE_INITEXIT, + DRV_ENTRY, + DBG_LVL_ALL, + "reset failed. Re-enumerating the device.\n"); + return retval; } } - if ((psIntfAdapter->bHighSpeedDevice == false) && bcm_usb_endpoint_is_bulk_out(endpoint)) { + if (!psIntfAdapter->bHighSpeedDevice && + usb_endpoint_is_bulk_out(endpoint)) { /* Once BULK is selected in FS mode. Revert it back to INT. Else USB_IF will fail. */ UINT _uiData = ntohl(EP2_CFG_INT); - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, - "Reverting Bulk to INT as it is in Full Speed mode.\n"); - BeceemEEPROMBulkWrite(psIntfAdapter->psAdapter, (PUCHAR)&_uiData, 0x136, 4, TRUE); + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, + DBG_TYPE_INITEXIT, + DRV_ENTRY, DBG_LVL_ALL, + "Reverting Bulk to INT as it is in Full Speed mode.\n"); + BeceemEEPROMBulkWrite( + psIntfAdapter->psAdapter, + (PUCHAR) & _uiData, + 0x136, 4, TRUE); } } else { - usedIntOutForBulkTransfer = EP4 ; + usedIntOutForBulkTransfer = EP4; endpoint = &iface_desc->endpoint[EP4].desc; - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, - "Choosing AltSetting as a default setting.\n"); - if (bcm_usb_endpoint_is_int_out(endpoint) == false) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, - "Dongle does not have BCM16 Fix.\n"); + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, + DBG_TYPE_INITEXIT, DRV_ENTRY, + DBG_LVL_ALL, + "Choosing AltSetting as a default setting.\n"); + if (!usb_endpoint_is_int_out(endpoint)) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, + DBG_TYPE_INITEXIT, + DRV_ENTRY, DBG_LVL_ALL, + "Dongle does not have BCM16 Fix.\n"); /* change the EP2, EP4 to INT OUT end point and use EP4 in altsetting */ - ConfigureEndPointTypesThroughEEPROM(psIntfAdapter->psAdapter); + ConfigureEndPointTypesThroughEEPROM( + psIntfAdapter->psAdapter); /* - * It resets the device and if any thing gets changed in - * USB descriptor it will show fail and re-enumerate the + * It resets the device and if any thing + * gets changed in USB descriptor it + * will show fail and re-enumerate the * device */ - retval = usb_reset_device(psIntfAdapter->udev); + retval = usb_reset_device( + psIntfAdapter->udev); if (retval) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, - "reset failed. Re-enumerating the device.\n"); + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, + DBG_TYPE_INITEXIT, + DRV_ENTRY, + DBG_LVL_ALL, + "reset failed. Re-enumerating the device.\n"); return retval; } @@ -541,49 +535,69 @@ static int InterfaceAdapterInit(struct bcm_interface_adapter *psIntfAdapter) for (value = 0; value < iface_desc->desc.bNumEndpoints; ++value) { endpoint = &iface_desc->endpoint[value].desc; - if (!psIntfAdapter->sBulkIn.bulk_in_endpointAddr && bcm_usb_endpoint_is_bulk_in(endpoint)) { + if (!psIntfAdapter->sBulkIn.bulk_in_endpointAddr && + usb_endpoint_is_bulk_in(endpoint)) { buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); psIntfAdapter->sBulkIn.bulk_in_size = buffer_size; - psIntfAdapter->sBulkIn.bulk_in_endpointAddr = endpoint->bEndpointAddress; - psIntfAdapter->sBulkIn.bulk_in_pipe = - usb_rcvbulkpipe(psIntfAdapter->udev, - psIntfAdapter->sBulkIn.bulk_in_endpointAddr); + psIntfAdapter->sBulkIn.bulk_in_endpointAddr = + endpoint->bEndpointAddress; + psIntfAdapter->sBulkIn.bulk_in_pipe = usb_rcvbulkpipe( + psIntfAdapter->udev, + psIntfAdapter->sBulkIn.bulk_in_endpointAddr); } - if (!psIntfAdapter->sBulkOut.bulk_out_endpointAddr && bcm_usb_endpoint_is_bulk_out(endpoint)) { - psIntfAdapter->sBulkOut.bulk_out_endpointAddr = endpoint->bEndpointAddress; - psIntfAdapter->sBulkOut.bulk_out_pipe = - usb_sndbulkpipe(psIntfAdapter->udev, + if (!psIntfAdapter->sBulkOut.bulk_out_endpointAddr && + usb_endpoint_is_bulk_out(endpoint)) { + psIntfAdapter->sBulkOut.bulk_out_endpointAddr = + endpoint->bEndpointAddress; + psIntfAdapter->sBulkOut.bulk_out_pipe = usb_sndbulkpipe( + psIntfAdapter->udev, psIntfAdapter->sBulkOut.bulk_out_endpointAddr); } - if (!psIntfAdapter->sIntrIn.int_in_endpointAddr && bcm_usb_endpoint_is_int_in(endpoint)) { + if (!psIntfAdapter->sIntrIn.int_in_endpointAddr && + usb_endpoint_is_int_in(endpoint)) { buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); psIntfAdapter->sIntrIn.int_in_size = buffer_size; - psIntfAdapter->sIntrIn.int_in_endpointAddr = endpoint->bEndpointAddress; - psIntfAdapter->sIntrIn.int_in_interval = endpoint->bInterval; + psIntfAdapter->sIntrIn.int_in_endpointAddr = + endpoint->bEndpointAddress; + psIntfAdapter->sIntrIn.int_in_interval = + endpoint->bInterval; psIntfAdapter->sIntrIn.int_in_buffer = - kmalloc(buffer_size, GFP_KERNEL); + kmalloc(buffer_size, GFP_KERNEL); if (!psIntfAdapter->sIntrIn.int_in_buffer) return -EINVAL; } - if (!psIntfAdapter->sIntrOut.int_out_endpointAddr && bcm_usb_endpoint_is_int_out(endpoint)) { + if (!psIntfAdapter->sIntrOut.int_out_endpointAddr && + usb_endpoint_is_int_out(endpoint)) { if (!psIntfAdapter->sBulkOut.bulk_out_endpointAddr && - (psIntfAdapter->psAdapter->chip_id == T3B) && (value == usedIntOutForBulkTransfer)) { + (psIntfAdapter->psAdapter->chip_id == T3B) && + (value == usedIntOutForBulkTransfer)) { /* use first intout end point as a bulk out end point */ - buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); - psIntfAdapter->sBulkOut.bulk_out_size = buffer_size; - psIntfAdapter->sBulkOut.bulk_out_endpointAddr = endpoint->bEndpointAddress; - psIntfAdapter->sBulkOut.bulk_out_pipe = usb_sndintpipe(psIntfAdapter->udev, - psIntfAdapter->sBulkOut.bulk_out_endpointAddr); - psIntfAdapter->sBulkOut.int_out_interval = endpoint->bInterval; + buffer_size = + le16_to_cpu(endpoint->wMaxPacketSize); + psIntfAdapter->sBulkOut.bulk_out_size = + buffer_size; + psIntfAdapter->sBulkOut.bulk_out_endpointAddr = + endpoint->bEndpointAddress; + psIntfAdapter->sBulkOut.bulk_out_pipe = + usb_sndintpipe(psIntfAdapter->udev, + psIntfAdapter->sBulkOut + .bulk_out_endpointAddr); + psIntfAdapter->sBulkOut.int_out_interval = + endpoint->bInterval; } else if (value == EP6) { - buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); - psIntfAdapter->sIntrOut.int_out_size = buffer_size; - psIntfAdapter->sIntrOut.int_out_endpointAddr = endpoint->bEndpointAddress; - psIntfAdapter->sIntrOut.int_out_interval = endpoint->bInterval; - psIntfAdapter->sIntrOut.int_out_buffer = kmalloc(buffer_size, GFP_KERNEL); + buffer_size = + le16_to_cpu(endpoint->wMaxPacketSize); + psIntfAdapter->sIntrOut.int_out_size = + buffer_size; + psIntfAdapter->sIntrOut.int_out_endpointAddr = + endpoint->bEndpointAddress; + psIntfAdapter->sIntrOut.int_out_interval = + endpoint->bInterval; + psIntfAdapter->sIntrOut.int_out_buffer = + kmalloc(buffer_size, GFP_KERNEL); if (!psIntfAdapter->sIntrOut.int_out_buffer) return -EINVAL; } @@ -594,14 +608,14 @@ static int InterfaceAdapterInit(struct bcm_interface_adapter *psIntfAdapter) psIntfAdapter->psAdapter->bcm_file_download = InterfaceFileDownload; psIntfAdapter->psAdapter->bcm_file_readback_from_chip = - InterfaceFileReadbackFromChip; + InterfaceFileReadbackFromChip; psIntfAdapter->psAdapter->interface_transmit = InterfaceTransmitPacket; retval = CreateInterruptUrb(psIntfAdapter); if (retval) { BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, - "Cannot create interrupt urb\n"); + "Cannot create interrupt urb\n"); return retval; } @@ -618,17 +632,21 @@ static int InterfaceSuspend(struct usb_interface *intf, pm_message_t message) psIntfAdapter->bSuspended = TRUE; - if (TRUE == psIntfAdapter->bPreparingForBusSuspend) { + if (psIntfAdapter->bPreparingForBusSuspend) { psIntfAdapter->bPreparingForBusSuspend = false; if (psIntfAdapter->psAdapter->LinkStatus == LINKUP_DONE) { - psIntfAdapter->psAdapter->IdleMode = TRUE ; - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, - "Host Entered in PMU Idle Mode.\n"); + psIntfAdapter->psAdapter->IdleMode = TRUE; + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, + DBG_TYPE_INITEXIT, DRV_ENTRY, + DBG_LVL_ALL, + "Host Entered in PMU Idle Mode.\n"); } else { psIntfAdapter->psAdapter->bShutStatus = TRUE; - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, - "Host Entered in PMU Shutdown Mode.\n"); + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, + DBG_TYPE_INITEXIT, DRV_ENTRY, + DBG_LVL_ALL, + "Host Entered in PMU Shutdown Mode.\n"); } } psIntfAdapter->psAdapter->bPreparingForLowPowerMode = false; diff --git a/drivers/staging/bcm/InterfaceIsr.c b/drivers/staging/bcm/InterfaceIsr.c index 7b39f4f5f1a..b9f8a7aa24f 100644 --- a/drivers/staging/bcm/InterfaceIsr.c +++ b/drivers/staging/bcm/InterfaceIsr.c @@ -4,108 +4,126 @@ static void read_int_callback(struct urb *urb/*, struct pt_regs *regs*/) { int status = urb->status; - struct bcm_interface_adapter *psIntfAdapter = (struct bcm_interface_adapter *)urb->context; - struct bcm_mini_adapter *Adapter = psIntfAdapter->psAdapter ; + struct bcm_interface_adapter *psIntfAdapter = + (struct bcm_interface_adapter *)urb->context; + struct bcm_mini_adapter *Adapter = psIntfAdapter->psAdapter; if (netif_msg_intr(Adapter)) pr_info(PFX "%s: interrupt status %d\n", - Adapter->dev->name, status); + Adapter->dev->name, status); - if(Adapter->device_removed == TRUE) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Device has Got Removed."); - return ; + if (Adapter->device_removed) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, + DBG_LVL_ALL, "Device has Got Removed."); + return; } - if(((Adapter->bPreparingForLowPowerMode == TRUE) && (Adapter->bDoSuspend == TRUE)) || - psIntfAdapter->bSuspended || - psIntfAdapter->bPreparingForBusSuspend) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Interrupt call back is called while suspending the device"); - return ; + if ((Adapter->bPreparingForLowPowerMode && Adapter->bDoSuspend) || + psIntfAdapter->bSuspended || + psIntfAdapter->bPreparingForBusSuspend) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, + DBG_LVL_ALL, + "Interrupt call back is called while suspending the device"); + return; } - //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "interrupt urb status %d", status); switch (status) { - /* success */ - case STATUS_SUCCESS: - if ( urb->actual_length ) - { - - if(psIntfAdapter->ulInterruptData[1] & 0xFF) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "Got USIM interrupt"); + /* success */ + case STATUS_SUCCESS: + if (urb->actual_length) { + + if (psIntfAdapter->ulInterruptData[1] & 0xFF) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + INTF_INIT, DBG_LVL_ALL, + "Got USIM interrupt"); } - if(psIntfAdapter->ulInterruptData[1] & 0xFF00) - { + if (psIntfAdapter->ulInterruptData[1] & 0xFF00) { atomic_set(&Adapter->CurrNumFreeTxDesc, - (psIntfAdapter->ulInterruptData[1] & 0xFF00) >> 8); - atomic_set (&Adapter->uiMBupdate, TRUE); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "TX mailbox contains %d", + (psIntfAdapter->ulInterruptData[1] & + 0xFF00) >> 8); + atomic_set(&Adapter->uiMBupdate, TRUE); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + INTF_INIT, DBG_LVL_ALL, + "TX mailbox contains %d", atomic_read(&Adapter->CurrNumFreeTxDesc)); } - if(psIntfAdapter->ulInterruptData[1] >> 16) - { - Adapter->CurrNumRecvDescs= + if (psIntfAdapter->ulInterruptData[1] >> 16) { + Adapter->CurrNumRecvDescs = (psIntfAdapter->ulInterruptData[1] >> 16); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"RX mailbox contains %d", - Adapter->CurrNumRecvDescs); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + INTF_INIT, DBG_LVL_ALL, + "RX mailbox contains %d", + Adapter->CurrNumRecvDescs); InterfaceRx(psIntfAdapter); } - if(Adapter->fw_download_done && + if (Adapter->fw_download_done && !Adapter->downloadDDR && - atomic_read(&Adapter->CurrNumFreeTxDesc)) - { - psIntfAdapter->psAdapter->downloadDDR +=1; + atomic_read(&Adapter->CurrNumFreeTxDesc)) { + + psIntfAdapter->psAdapter->downloadDDR += 1; wake_up(&Adapter->tx_packet_wait_queue); } - if(false == Adapter->waiting_to_fw_download_done) - { + if (!Adapter->waiting_to_fw_download_done) { Adapter->waiting_to_fw_download_done = TRUE; wake_up(&Adapter->ioctl_fw_dnld_wait_queue); } - if(!atomic_read(&Adapter->TxPktAvail)) - { + if (!atomic_read(&Adapter->TxPktAvail)) { atomic_set(&Adapter->TxPktAvail, 1); wake_up(&Adapter->tx_packet_wait_queue); } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Firing interrupt in URB"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, + DBG_LVL_ALL, "Firing interrupt in URB"); } break; - case -ENOENT : - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"URB has got disconnected ...."); - return ; - } - case -EINPROGRESS: - { - //This situation may happened when URBunlink is used. for detail check usb_unlink_urb documentation. - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Impossibe condition has occurred... something very bad is going on"); - break ; - //return; - } - case -EPIPE: - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Interrupt IN endPoint has got halted/stalled...need to clear this"); - Adapter->bEndPointHalted = TRUE ; - wake_up(&Adapter->tx_packet_wait_queue); - urb->status = STATUS_SUCCESS ; - return; - } - /* software-driven interface shutdown */ - case -ECONNRESET: //URB got unlinked. - case -ESHUTDOWN: // hardware gone. this is the serious problem. - //Occurs only when something happens with the host controller device - case -ENODEV : //Device got removed - case -EINVAL : //Some thing very bad happened with the URB. No description is available. - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"interrupt urb error %d", status); - urb->status = STATUS_SUCCESS ; - break ; - //return; - default: - //This is required to check what is the defaults conditions when it occurs.. - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,"GOT DEFAULT INTERRUPT URB STATUS :%d..Please Analyze it...", status); + case -ENOENT: + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, + DBG_LVL_ALL, "URB has got disconnected...."); + return; + case -EINPROGRESS: + /* + * This situation may happened when URBunlink is used. for + * detail check usb_unlink_urb documentation. + */ + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, + DBG_LVL_ALL, + "Impossibe condition has occurred... something very bad is going on"); + break; + /* return; */ + case -EPIPE: + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, + DBG_LVL_ALL, + "Interrupt IN endPoint has got halted/stalled...need to clear this"); + Adapter->bEndPointHalted = TRUE; + wake_up(&Adapter->tx_packet_wait_queue); + urb->status = STATUS_SUCCESS; + return; + /* software-driven interface shutdown */ + case -ECONNRESET: /* URB got unlinked */ + case -ESHUTDOWN: /* hardware gone. this is the serious problem */ + /* + * Occurs only when something happens with the + * host controller device + */ + case -ENODEV: /* Device got removed */ + case -EINVAL: + /* + * Some thing very bad happened with the URB. No + * description is available. + */ + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, + DBG_LVL_ALL, "interrupt urb error %d", status); + urb->status = STATUS_SUCCESS; + break; + /* return; */ + default: + /* + * This is required to check what is the defaults conditions + * when it occurs.. + */ + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, + "GOT DEFAULT INTERRUPT URB STATUS :%d..Please Analyze it...", + status); break; } @@ -117,28 +135,30 @@ static void read_int_callback(struct urb *urb/*, struct pt_regs *regs*/) int CreateInterruptUrb(struct bcm_interface_adapter *psIntfAdapter) { psIntfAdapter->psInterruptUrb = usb_alloc_urb(0, GFP_KERNEL); - if (!psIntfAdapter->psInterruptUrb) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Cannot allocate interrupt urb"); + if (!psIntfAdapter->psInterruptUrb) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, + INTF_INIT, DBG_LVL_ALL, + "Cannot allocate interrupt urb"); return -ENOMEM; } psIntfAdapter->psInterruptUrb->transfer_buffer = - psIntfAdapter->ulInterruptData; + psIntfAdapter->ulInterruptData; psIntfAdapter->psInterruptUrb->transfer_buffer_length = - sizeof(psIntfAdapter->ulInterruptData); + sizeof(psIntfAdapter->ulInterruptData); psIntfAdapter->sIntrIn.int_in_pipe = usb_rcvintpipe(psIntfAdapter->udev, - psIntfAdapter->sIntrIn.int_in_endpointAddr); + psIntfAdapter->sIntrIn.int_in_endpointAddr); usb_fill_int_urb(psIntfAdapter->psInterruptUrb, psIntfAdapter->udev, - psIntfAdapter->sIntrIn.int_in_pipe, - psIntfAdapter->psInterruptUrb->transfer_buffer, - psIntfAdapter->psInterruptUrb->transfer_buffer_length, - read_int_callback, psIntfAdapter, - psIntfAdapter->sIntrIn.int_in_interval); - - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Interrupt Interval: %d\n", - psIntfAdapter->sIntrIn.int_in_interval); + psIntfAdapter->sIntrIn.int_in_pipe, + psIntfAdapter->psInterruptUrb->transfer_buffer, + psIntfAdapter->psInterruptUrb->transfer_buffer_length, + read_int_callback, psIntfAdapter, + psIntfAdapter->sIntrIn.int_in_interval); + + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, INTF_INIT, + DBG_LVL_ALL, "Interrupt Interval: %d\n", + psIntfAdapter->sIntrIn.int_in_interval); return 0; } @@ -147,19 +167,20 @@ INT StartInterruptUrb(struct bcm_interface_adapter *psIntfAdapter) { INT status = 0; - if( false == psIntfAdapter->psAdapter->device_removed && - false == psIntfAdapter->psAdapter->bEndPointHalted && - false == psIntfAdapter->bSuspended && - false == psIntfAdapter->bPreparingForBusSuspend && - false == psIntfAdapter->psAdapter->StopAllXaction) - { - status = usb_submit_urb(psIntfAdapter->psInterruptUrb, GFP_ATOMIC); - if (status) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Cannot send int urb %d\n", status); - if(status == -EPIPE) - { - psIntfAdapter->psAdapter->bEndPointHalted = TRUE ; + if (!(psIntfAdapter->psAdapter->device_removed || + psIntfAdapter->psAdapter->bEndPointHalted || + psIntfAdapter->bSuspended || + psIntfAdapter->bPreparingForBusSuspend || + psIntfAdapter->psAdapter->StopAllXaction)) { + status = + usb_submit_urb(psIntfAdapter->psInterruptUrb, GFP_ATOMIC); + if (status) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, + DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, + "Cannot send inturb %d\n", status); + if (status == -EPIPE) { + psIntfAdapter->psAdapter->bEndPointHalted = + TRUE; wake_up(&psIntfAdapter->psAdapter->tx_packet_wait_queue); } } diff --git a/drivers/staging/bcm/InterfaceMisc.h b/drivers/staging/bcm/InterfaceMisc.h index bce6869a747..efb68604615 100644 --- a/drivers/staging/bcm/InterfaceMisc.h +++ b/drivers/staging/bcm/InterfaceMisc.h @@ -14,13 +14,13 @@ InterfaceWRM(struct bcm_interface_adapter *psIntfAdapter, INT len); -int InterfaceFileDownload( PVOID psIntfAdapter, - struct file *flp, - unsigned int on_chip_loc); +int InterfaceFileDownload(PVOID psIntfAdapter, + struct file *flp, + unsigned int on_chip_loc); -int InterfaceFileReadbackFromChip( PVOID psIntfAdapter, - struct file *flp, - unsigned int on_chip_loc); +int InterfaceFileReadbackFromChip(PVOID psIntfAdapter, + struct file *flp, + unsigned int on_chip_loc); int BcmRDM(PVOID arg, diff --git a/drivers/staging/bcm/Kconfig b/drivers/staging/bcm/Kconfig index 83c9752504d..8acf4b24a7c 100644 --- a/drivers/staging/bcm/Kconfig +++ b/drivers/staging/bcm/Kconfig @@ -1,7 +1,6 @@ config BCM_WIMAX tristate "Beceem BCS200/BCS220-3 and BCSM250 wimax support" depends on USB && NET - default N help This is an experimental driver for the Beceem WIMAX chipset used by Sprint 4G. diff --git a/drivers/staging/bcm/PHSModule.c b/drivers/staging/bcm/PHSModule.c index afc7bcc3e54..07c5a0bae1e 100644 --- a/drivers/staging/bcm/PHSModule.c +++ b/drivers/staging/bcm/PHSModule.c @@ -409,7 +409,6 @@ ULONG PhsUpdateClassifierRule(IN void *pvContext, */ ULONG PhsDeletePHSRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT8 u8PHSI) { - ULONG lStatus = 0; UINT nSFIndex = 0, nClsidIndex = 0; struct bcm_phs_entry *pstServiceFlowEntry = NULL; struct bcm_phs_classifier_table *pstClassifierRulesTable = NULL; @@ -446,7 +445,7 @@ ULONG PhsDeletePHSRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT8 u8PHSI } } } - return lStatus; + return 0; } /* @@ -467,7 +466,6 @@ ULONG PhsDeletePHSRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT8 u8PHSI */ ULONG PhsDeleteClassifierRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT16 uiClsId) { - ULONG lStatus = 0; UINT nSFIndex = 0, nClsidIndex = 0; struct bcm_phs_entry *pstServiceFlowEntry = NULL; struct bcm_phs_classifier_entry *pstClassifierEntry = NULL; @@ -504,7 +502,7 @@ ULONG PhsDeleteClassifierRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT1 memset(pstClassifierEntry, 0, sizeof(struct bcm_phs_classifier_entry)); } } - return lStatus; + return 0; } /* @@ -524,7 +522,6 @@ ULONG PhsDeleteClassifierRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT1 */ ULONG PhsDeleteSFRules(IN void *pvContext, IN B_UINT16 uiVcid) { - ULONG lStatus = 0; UINT nSFIndex = 0, nClsidIndex = 0; struct bcm_phs_entry *pstServiceFlowEntry = NULL; struct bcm_phs_classifier_table *pstClassifierRulesTable = NULL; @@ -573,7 +570,7 @@ ULONG PhsDeleteSFRules(IN void *pvContext, IN B_UINT16 uiVcid) pstServiceFlowEntry->uiVcid = 0; } - return lStatus; + return 0; } /* diff --git a/drivers/staging/bcm/Qos.c b/drivers/staging/bcm/Qos.c index 0727599bf5f..0c742da8c6b 100644 --- a/drivers/staging/bcm/Qos.c +++ b/drivers/staging/bcm/Qos.c @@ -4,11 +4,18 @@ This file contains the routines related to Quality of Service. */ #include "headers.h" -static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter, PVOID pvEthPayload, struct bcm_eth_packet_info *pstEthCsPktInfo); -static bool EThCSClassifyPkt(struct bcm_mini_adapter *Adapter, struct sk_buff* skb, struct bcm_eth_packet_info *pstEthCsPktInfo, struct bcm_classifier_rule *pstClassifierRule, B_UINT8 EthCSCupport); +static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter, + PVOID pvEthPayload, + struct bcm_eth_packet_info *pstEthCsPktInfo); -static USHORT IpVersion4(struct bcm_mini_adapter *Adapter, struct iphdr *iphd, - struct bcm_classifier_rule *pstClassifierRule); +static bool EThCSClassifyPkt(struct bcm_mini_adapter *Adapter, + struct sk_buff *skb, + struct bcm_eth_packet_info *pstEthCsPktInfo, + struct bcm_classifier_rule *pstClassifierRule, + B_UINT8 EthCSCupport); + +static USHORT IpVersion4(struct bcm_mini_adapter *Adapter, struct iphdr *iphd, + struct bcm_classifier_rule *pstClassifierRule); static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex); @@ -33,14 +40,11 @@ static bool MatchSrcIpAddress(struct bcm_classifier_rule *pstClassifierRule, ULO ulSrcIP = ntohl(ulSrcIP); if (0 == pstClassifierRule->ucIPSourceAddressLength) return TRUE; - for (ucLoopIndex = 0; ucLoopIndex < (pstClassifierRule->ucIPSourceAddressLength); ucLoopIndex++) - { + for (ucLoopIndex = 0; ucLoopIndex < (pstClassifierRule->ucIPSourceAddressLength); ucLoopIndex++) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Ip Address Mask:0x%x PacketIp:0x%x and Classification:0x%x", (UINT)pstClassifierRule->stSrcIpAddress.ulIpv4Mask[ucLoopIndex], (UINT)ulSrcIP, (UINT)pstClassifierRule->stSrcIpAddress.ulIpv6Addr[ucLoopIndex]); if ((pstClassifierRule->stSrcIpAddress.ulIpv4Mask[ucLoopIndex] & ulSrcIP) == (pstClassifierRule->stSrcIpAddress.ulIpv4Addr[ucLoopIndex] & pstClassifierRule->stSrcIpAddress.ulIpv4Mask[ucLoopIndex])) - { return TRUE; - } } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Ip Address Not Matched"); return false; @@ -68,13 +72,10 @@ static bool MatchDestIpAddress(struct bcm_classifier_rule *pstClassifierRule, UL return TRUE; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Destination Ip Address 0x%x 0x%x 0x%x ", (UINT)ulDestIP, (UINT)pstClassifierRule->stDestIpAddress.ulIpv4Mask[ucLoopIndex], (UINT)pstClassifierRule->stDestIpAddress.ulIpv4Addr[ucLoopIndex]); - for (ucLoopIndex = 0; ucLoopIndex < (pstClassifierRule->ucIPDestinationAddressLength); ucLoopIndex++) - { + for (ucLoopIndex = 0; ucLoopIndex < (pstClassifierRule->ucIPDestinationAddressLength); ucLoopIndex++) { if ((pstClassifierRule->stDestIpAddress.ulIpv4Mask[ucLoopIndex] & ulDestIP) == (pstClassifierRule->stDestIpAddress.ulIpv4Addr[ucLoopIndex] & pstClassifierRule->stDestIpAddress.ulIpv4Mask[ucLoopIndex])) - { return TRUE; - } } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Destination Ip Address Not Matched"); return false; @@ -99,9 +100,8 @@ static bool MatchTos(struct bcm_classifier_rule *pstClassifierRule, UCHAR ucType return TRUE; if (((pstClassifierRule->ucTosMask & ucTypeOfService) <= pstClassifierRule->ucTosHigh) && ((pstClassifierRule->ucTosMask & ucTypeOfService) >= pstClassifierRule->ucTosLow)) - { return TRUE; - } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Type Of Service Not Matched"); return false; } @@ -123,13 +123,10 @@ bool MatchProtocol(struct bcm_classifier_rule *pstClassifierRule, UCHAR ucProtoc struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); if (0 == pstClassifierRule->ucProtocolLength) return TRUE; - for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucProtocolLength; ucLoopIndex++) - { + for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucProtocolLength; ucLoopIndex++) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Protocol:0x%X Classification Protocol:0x%X", ucProtocol, pstClassifierRule->ucProtocol[ucLoopIndex]); if (pstClassifierRule->ucProtocol[ucLoopIndex] == ucProtocol) - { return TRUE; - } } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Protocol Not Matched"); return false; @@ -155,13 +152,10 @@ bool MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule, USHORT ushSrcPo if (0 == pstClassifierRule->ucSrcPortRangeLength) return TRUE; - for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucSrcPortRangeLength; ucLoopIndex++) - { + for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucSrcPortRangeLength; ucLoopIndex++) { if (ushSrcPort <= pstClassifierRule->usSrcPortRangeHi[ucLoopIndex] && ushSrcPort >= pstClassifierRule->usSrcPortRangeLo[ucLoopIndex]) - { return TRUE; - } } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Port: %x Not Matched ", ushSrcPort); return false; @@ -186,15 +180,12 @@ bool MatchDestPort(struct bcm_classifier_rule *pstClassifierRule, USHORT ushDest if (0 == pstClassifierRule->ucDestPortRangeLength) return TRUE; - for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucDestPortRangeLength; ucLoopIndex++) - { + for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucDestPortRangeLength; ucLoopIndex++) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Matching Port:0x%X 0x%X 0x%X", ushDestPort, pstClassifierRule->usDestPortRangeLo[ucLoopIndex], pstClassifierRule->usDestPortRangeHi[ucLoopIndex]); if (ushDestPort <= pstClassifierRule->usDestPortRangeHi[ucLoopIndex] && ushDestPort >= pstClassifierRule->usDestPortRangeLo[ucLoopIndex]) - { return TRUE; - } } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Dest Port: %x Not Matched", ushDestPort); return false; @@ -222,10 +213,7 @@ static USHORT IpVersion4(struct bcm_mini_adapter *Adapter, //Checking classifier validity if (!pstClassifierRule->bUsed || pstClassifierRule->ucDirection == DOWNLINK_DIR) - { - bClassificationSucceed = false; break; - } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "is IPv6 check!"); if (pstClassifierRule->bIpv6Protocol) @@ -233,68 +221,56 @@ static USHORT IpVersion4(struct bcm_mini_adapter *Adapter, //**************Checking IP header parameter**************************// BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Trying to match Source IP Address"); - if (false == (bClassificationSucceed = - MatchSrcIpAddress(pstClassifierRule, iphd->saddr))) + if (!MatchSrcIpAddress(pstClassifierRule, iphd->saddr)) break; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Source IP Address Matched"); - if (false == (bClassificationSucceed = - MatchDestIpAddress(pstClassifierRule, iphd->daddr))) + if (!MatchDestIpAddress(pstClassifierRule, iphd->daddr)) break; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Destination IP Address Matched"); - if (false == (bClassificationSucceed = - MatchTos(pstClassifierRule, iphd->tos))) - { + if (!MatchTos(pstClassifierRule, iphd->tos)) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "TOS Match failed\n"); break; } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "TOS Matched"); - if (false == (bClassificationSucceed = - MatchProtocol(pstClassifierRule, iphd->protocol))) + if (!MatchProtocol(pstClassifierRule, iphd->protocol)) break; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Protocol Matched"); //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) { + bClassificationSucceed = TRUE; break; + } //******************Checking Transport Layer Header field if present *****************// BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Source Port %04x", (iphd->protocol == UDP) ? xprt_hdr->uhdr.source : xprt_hdr->thdr.source); - if (false == (bClassificationSucceed = - MatchSrcPort(pstClassifierRule, - ntohs((iphd->protocol == UDP) ? - xprt_hdr->uhdr.source : xprt_hdr->thdr.source)))) + if (!MatchSrcPort(pstClassifierRule, + ntohs((iphd->protocol == UDP) ? + xprt_hdr->uhdr.source : xprt_hdr->thdr.source))) break; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Port Matched"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Destination Port %04x", (iphd->protocol == UDP) ? xprt_hdr->uhdr.dest : xprt_hdr->thdr.dest); - if (false == (bClassificationSucceed = - MatchDestPort(pstClassifierRule, - ntohs((iphd->protocol == UDP) ? - xprt_hdr->uhdr.dest : xprt_hdr->thdr.dest)))) + if (!MatchDestPort(pstClassifierRule, + ntohs((iphd->protocol == UDP) ? + xprt_hdr->uhdr.dest : xprt_hdr->thdr.dest))) break; + bClassificationSucceed = TRUE; } while (0); - if (TRUE == bClassificationSucceed) - { + if (TRUE == bClassificationSucceed) { INT iMatchedSFQueueIndex = 0; iMatchedSFQueueIndex = SearchSfid(Adapter, pstClassifierRule->ulSFID); if (iMatchedSFQueueIndex >= NO_OF_QUEUES) - { bClassificationSucceed = false; - } - else - { - if (false == Adapter->PackInfo[iMatchedSFQueueIndex].bActive) - { - bClassificationSucceed = false; - } - } + else if (false == Adapter->PackInfo[iMatchedSFQueueIndex].bActive) + bClassificationSucceed = false; } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "IpVersion4 <=========="); @@ -306,8 +282,7 @@ VOID PruneQueueAllSF(struct bcm_mini_adapter *Adapter) { UINT iIndex = 0; - for (iIndex = 0; iIndex < HiPriority; iIndex++) - { + for (iIndex = 0; iIndex < HiPriority; iIndex++) { if (!Adapter->PackInfo[iIndex].bValid) continue; @@ -341,10 +316,10 @@ static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex) spin_lock_bh(&Adapter->PackInfo[iIndex].SFQueueLock); - while (1) + while (1) { // while((UINT)Adapter->PackInfo[iIndex].uiCurrentPacketsOnHost > -// SF_MAX_ALLOWED_PACKETS_TO_BACKUP) - { +// SF_MAX_ALLOWED_PACKETS_TO_BACKUP) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "uiCurrentBytesOnHost:%x uiMaxBucketSize :%x", Adapter->PackInfo[iIndex].uiCurrentBytesOnHost, Adapter->PackInfo[iIndex].uiMaxBucketSize); @@ -357,8 +332,7 @@ static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex) ((1000*(jiffies - *((B_UINT32 *)(PacketToDrop->cb)+SKB_CB_LATENCY_OFFSET))/HZ) <= Adapter->PackInfo[iIndex].uiMaxLatency)) break; - if (PacketToDrop) - { + if (PacketToDrop) { if (netif_msg_tx_err(Adapter)) pr_info(PFX "%s: tx queue %d overlimit\n", Adapter->dev->name, iIndex); @@ -401,20 +375,16 @@ VOID flush_all_queues(struct bcm_mini_adapter *Adapter) BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "=====>"); // down(&Adapter->data_packet_queue_lock); - for (iQIndex = LowPriority; iQIndex < HiPriority; iQIndex++) - { + for (iQIndex = LowPriority; iQIndex < HiPriority; iQIndex++) { struct net_device_stats *netstats = &Adapter->dev->stats; spin_lock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock); - while (Adapter->PackInfo[iQIndex].FirstTxQueue) - { + while (Adapter->PackInfo[iQIndex].FirstTxQueue) { PacketToDrop = Adapter->PackInfo[iQIndex].FirstTxQueue; - if (PacketToDrop) - { + if (PacketToDrop) { uiTotalPacketLength = PacketToDrop->len; netstats->tx_dropped++; - } - else + } else uiTotalPacketLength = 0; DEQUEUEPACKET(Adapter->PackInfo[iQIndex].FirstTxQueue, @@ -462,58 +432,42 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb) *((UINT32*) (skb->cb) +SKB_CB_TCPACK_OFFSET) = 0; EThCSGetPktInfo(Adapter, pvEThPayload, &stEthCsPktInfo); - switch (stEthCsPktInfo.eNwpktEthFrameType) - { + switch (stEthCsPktInfo.eNwpktEthFrameType) { case eEth802LLCFrame: - { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : 802LLCFrame\n"); pIpHeader = pvEThPayload + sizeof(struct bcm_eth_llc_frame); break; - } - case eEth802LLCSNAPFrame: - { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : 802LLC SNAP Frame\n"); pIpHeader = pvEThPayload + sizeof(struct bcm_eth_llc_snap_frame); break; - } case eEth802QVLANFrame: - { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : 802.1Q VLANFrame\n"); pIpHeader = pvEThPayload + sizeof(struct bcm_eth_q_frame); break; - } case eEthOtherFrame: - { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : ETH Other Frame\n"); pIpHeader = pvEThPayload + sizeof(struct bcm_ethernet2_frame); break; - } default: - { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : Unrecognized ETH Frame\n"); pIpHeader = pvEThPayload + sizeof(struct bcm_ethernet2_frame); break; - } } - if (stEthCsPktInfo.eNwpktIPFrameType == eIPv4Packet) - { + if (stEthCsPktInfo.eNwpktIPFrameType == eIPv4Packet) { usCurrFragment = (ntohs(pIpHeader->frag_off) & IP_OFFSET); if ((ntohs(pIpHeader->frag_off) & IP_MF) || usCurrFragment) bFragmentedPkt = TRUE; - if (bFragmentedPkt) - { + if (bFragmentedPkt) { //Fragmented Packet. Get Frag Classifier Entry. pstClassifierRule = GetFragIPClsEntry(Adapter, pIpHeader->id, pIpHeader->saddr); - if (pstClassifierRule) - { + if (pstClassifierRule) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "It is next Fragmented pkt"); bClassificationSucceed = TRUE; } - if (!(ntohs(pIpHeader->frag_off) & IP_MF)) - { + if (!(ntohs(pIpHeader->frag_off) & IP_MF)) { //Fragmented Last packet . Remove Frag Classifier Entry BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "This is the last fragmented Pkt"); DelFragIPClsEntry(Adapter, pIpHeader->id, pIpHeader->saddr); @@ -521,23 +475,19 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb) } } - for (uiLoopIndex = MAX_CLASSIFIERS - 1; uiLoopIndex >= 0; uiLoopIndex--) - { + for (uiLoopIndex = MAX_CLASSIFIERS - 1; uiLoopIndex >= 0; uiLoopIndex--) { if (bClassificationSucceed) break; //Iterate through all classifiers which are already in order of priority //to classify the packet until match found - do - { - if (false == Adapter->astClassifierTable[uiLoopIndex].bUsed) - { + do { + if (false == Adapter->astClassifierTable[uiLoopIndex].bUsed) { bClassificationSucceed = false; break; } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Adapter->PackInfo[%d].bvalid=True\n", uiLoopIndex); - if (0 == Adapter->astClassifierTable[uiLoopIndex].ucDirection) - { + if (0 == Adapter->astClassifierTable[uiLoopIndex].ucDirection) { bClassificationSucceed = false;//cannot be processed for classification. break; // it is a down link connection } @@ -550,11 +500,9 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb) break; } - if (Adapter->PackInfo[uiSfIndex].bEthCSSupport) - { + if (Adapter->PackInfo[uiSfIndex].bEthCSSupport) { - if (eEthUnsupportedFrame == stEthCsPktInfo.eNwpktEthFrameType) - { + if (eEthUnsupportedFrame == stEthCsPktInfo.eNwpktEthFrameType) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, " ClassifyPacket : Packet Not a Valid Supported Ethernet Frame\n"); bClassificationSucceed = false; break; @@ -565,17 +513,12 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb) BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Performing ETH CS Classification on Classifier Rule ID : %x Service Flow ID : %lx\n", pstClassifierRule->uiClassifierRuleIndex, Adapter->PackInfo[uiSfIndex].ulSFID); bClassificationSucceed = EThCSClassifyPkt(Adapter, skb, &stEthCsPktInfo, pstClassifierRule, Adapter->PackInfo[uiSfIndex].bEthCSSupport); - if (!bClassificationSucceed) - { + if (!bClassificationSucceed) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : Ethernet CS Classification Failed\n"); break; } - } - - else // No ETH Supported on this SF - { - if (eEthOtherFrame != stEthCsPktInfo.eNwpktEthFrameType) - { + } else { // No ETH Supported on this SF + if (eEthOtherFrame != stEthCsPktInfo.eNwpktEthFrameType) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, " ClassifyPacket : Packet Not a 802.3 Ethernet Frame... hence not allowed over non-ETH CS SF\n"); bClassificationSucceed = false; break; @@ -584,11 +527,9 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb) BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Proceeding to IP CS Clasification"); - if (Adapter->PackInfo[uiSfIndex].bIPCSSupport) - { + if (Adapter->PackInfo[uiSfIndex].bIPCSSupport) { - if (stEthCsPktInfo.eNwpktIPFrameType == eNonIPPacket) - { + if (stEthCsPktInfo.eNwpktIPFrameType == eNonIPPacket) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, " ClassifyPacket : Packet is Not an IP Packet\n"); bClassificationSucceed = false; break; @@ -605,31 +546,26 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb) } while (0); } - if (bClassificationSucceed == TRUE) - { + if (bClassificationSucceed == TRUE) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "CF id : %d, SF ID is =%lu", pstClassifierRule->uiClassifierRuleIndex, pstClassifierRule->ulSFID); //Store The matched Classifier in SKB *((UINT32*)(skb->cb)+SKB_CB_CLASSIFICATION_OFFSET) = pstClassifierRule->uiClassifierRuleIndex; - if ((TCP == pIpHeader->protocol) && !bFragmentedPkt && (ETH_AND_IP_HEADER_LEN + TCP_HEADER_LEN <= skb->len)) - { + if ((TCP == pIpHeader->protocol) && !bFragmentedPkt && (ETH_AND_IP_HEADER_LEN + TCP_HEADER_LEN <= skb->len)) { IpHeaderLength = pIpHeader->ihl; pTcpHeader = (struct bcm_tcp_header *)(((PUCHAR)pIpHeader)+(IpHeaderLength*4)); TcpHeaderLength = GET_TCP_HEADER_LEN(pTcpHeader->HeaderLength); if ((pTcpHeader->ucFlags & TCP_ACK) && (ntohs(pIpHeader->tot_len) == (IpHeaderLength*4)+(TcpHeaderLength*4))) - { *((UINT32*) (skb->cb) + SKB_CB_TCPACK_OFFSET) = TCP_ACK; - } } usIndex = SearchSfid(Adapter, pstClassifierRule->ulSFID); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "index is =%d", usIndex); //If this is the first fragment of a Fragmented pkt, add this CF. Only This CF should be used for all other fragment of this Pkt. - if (bFragmentedPkt && (usCurrFragment == 0)) - { + if (bFragmentedPkt && (usCurrFragment == 0)) { //First Fragment of Fragmented Packet. Create Frag CLS Entry struct bcm_fragmented_packet_info stFragPktInfo; stFragPktInfo.bUsed = TRUE; @@ -655,9 +591,8 @@ static bool EthCSMatchSrcMACAddress(struct bcm_classifier_rule *pstClassifierRul struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); if (pstClassifierRule->ucEthCSSrcMACLen == 0) return TRUE; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s\n", __FUNCTION__); - for (i = 0; i < MAC_ADDRESS_SIZE; i++) - { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s\n", __func__); + for (i = 0; i < MAC_ADDRESS_SIZE; i++) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "SRC MAC[%x] = %x ClassifierRuleSrcMAC = %x Mask : %x\n", i, Mac[i], pstClassifierRule->au8EThCSSrcMAC[i], pstClassifierRule->au8EThCSSrcMACMask[i]); if ((pstClassifierRule->au8EThCSSrcMAC[i] & pstClassifierRule->au8EThCSSrcMACMask[i]) != (Mac[i] & pstClassifierRule->au8EThCSSrcMACMask[i])) @@ -672,9 +607,8 @@ static bool EthCSMatchDestMACAddress(struct bcm_classifier_rule *pstClassifierRu struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); if (pstClassifierRule->ucEthCSDestMACLen == 0) return TRUE; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s\n", __FUNCTION__); - for (i = 0; i < MAC_ADDRESS_SIZE; i++) - { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s\n", __func__); + for (i = 0; i < MAC_ADDRESS_SIZE; i++) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "SRC MAC[%x] = %x ClassifierRuleSrcMAC = %x Mask : %x\n", i, Mac[i], pstClassifierRule->au8EThCSDestMAC[i], pstClassifierRule->au8EThCSDestMACMask[i]); if ((pstClassifierRule->au8EThCSDestMAC[i] & pstClassifierRule->au8EThCSDestMACMask[i]) != (Mac[i] & pstClassifierRule->au8EThCSDestMACMask[i])) @@ -690,10 +624,9 @@ static bool EthCSMatchEThTypeSAP(struct bcm_classifier_rule *pstClassifierRule, (pstClassifierRule->au8EthCSEtherType[0] == 0)) return TRUE; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s SrcEtherType:%x CLS EtherType[0]:%x\n", __FUNCTION__, pstEthCsPktInfo->usEtherType, pstClassifierRule->au8EthCSEtherType[0]); - if (pstClassifierRule->au8EthCSEtherType[0] == 1) - { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s CLS EtherType[1]:%x EtherType[2]:%x\n", __FUNCTION__, pstClassifierRule->au8EthCSEtherType[1], pstClassifierRule->au8EthCSEtherType[2]); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s SrcEtherType:%x CLS EtherType[0]:%x\n", __func__, pstEthCsPktInfo->usEtherType, pstClassifierRule->au8EthCSEtherType[0]); + if (pstClassifierRule->au8EthCSEtherType[0] == 1) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s CLS EtherType[1]:%x EtherType[2]:%x\n", __func__, pstClassifierRule->au8EthCSEtherType[1], pstClassifierRule->au8EthCSEtherType[2]); if (memcmp(&pstEthCsPktInfo->usEtherType, &pstClassifierRule->au8EthCSEtherType[1], 2) == 0) return TRUE; @@ -701,12 +634,11 @@ static bool EthCSMatchEThTypeSAP(struct bcm_classifier_rule *pstClassifierRule, return false; } - if (pstClassifierRule->au8EthCSEtherType[0] == 2) - { + if (pstClassifierRule->au8EthCSEtherType[0] == 2) { if (eEth802LLCFrame != pstEthCsPktInfo->eNwpktEthFrameType) return false; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s EthCS DSAP:%x EtherType[2]:%x\n", __FUNCTION__, pstEthCsPktInfo->ucDSAP, pstClassifierRule->au8EthCSEtherType[2]); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s EthCS DSAP:%x EtherType[2]:%x\n", __func__, pstEthCsPktInfo->ucDSAP, pstClassifierRule->au8EthCSEtherType[2]); if (pstEthCsPktInfo->ucDSAP == pstClassifierRule->au8EthCSEtherType[2]) return TRUE; else @@ -725,11 +657,10 @@ static bool EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule, s B_UINT8 uPriority = 0; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s CLS UserPrio:%x CLS VLANID:%x\n", __FUNCTION__, ntohs(*((USHORT *)pstClassifierRule->usUserPriority)), pstClassifierRule->usVLANID); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s CLS UserPrio:%x CLS VLANID:%x\n", __func__, ntohs(*((USHORT *)pstClassifierRule->usUserPriority)), pstClassifierRule->usVLANID); /* In case FW didn't receive the TLV, the priority field should be ignored */ - if (pstClassifierRule->usValidityBitMap & (1<<PKT_CLASSIFICATION_USER_PRIORITY_VALID)) - { + if (pstClassifierRule->usValidityBitMap & (1<<PKT_CLASSIFICATION_USER_PRIORITY_VALID)) { if (pstEthCsPktInfo->eNwpktEthFrameType != eEth802QVLANFrame) return false; @@ -746,14 +677,13 @@ static bool EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule, s bClassificationSucceed = false; - if (pstClassifierRule->usValidityBitMap & (1<<PKT_CLASSIFICATION_VLANID_VALID)) - { + if (pstClassifierRule->usValidityBitMap & (1<<PKT_CLASSIFICATION_VLANID_VALID)) { if (pstEthCsPktInfo->eNwpktEthFrameType != eEth802QVLANFrame) return false; usVLANID = ntohs(*(USHORT *)(skb->data + sizeof(struct bcm_eth_header))) & 0xFFF; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s Pkt VLANID %x Priority: %d\n", __FUNCTION__, usVLANID, uPriority); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s Pkt VLANID %x Priority: %d\n", __func__, usVLANID, uPriority); if (usVLANID == ((pstClassifierRule->usVLANID & 0xFFF0) >> 4)) bClassificationSucceed = TRUE; @@ -807,32 +737,24 @@ static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter, PVOID pvEthPayload USHORT u16Etype = ntohs(((struct bcm_eth_header *)pvEthPayload)->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) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCSGetPktInfo : ETH2 Frame\n"); //ETH2 Frame - if (u16Etype == ETHERNET_FRAMETYPE_802QVLAN) - { + if (u16Etype == ETHERNET_FRAMETYPE_802QVLAN) { //802.1Q VLAN Header pstEthCsPktInfo->eNwpktEthFrameType = eEth802QVLANFrame; u16Etype = ((struct bcm_eth_q_frame *)pvEthPayload)->EthType; //((ETH_CS_802_Q_FRAME*)pvEthPayload)->UserPriority - } - else - { + } else { pstEthCsPktInfo->eNwpktEthFrameType = eEthOtherFrame; u16Etype = ntohs(u16Etype); } - - } - else - { + } else { //802.2 LLC BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "802.2 LLC Frame\n"); pstEthCsPktInfo->eNwpktEthFrameType = eEth802LLCFrame; pstEthCsPktInfo->ucDSAP = ((struct bcm_eth_llc_frame *)pvEthPayload)->DSAP; - if (pstEthCsPktInfo->ucDSAP == 0xAA && ((struct bcm_eth_llc_frame *)pvEthPayload)->SSAP == 0xAA) - { + if (pstEthCsPktInfo->ucDSAP == 0xAA && ((struct bcm_eth_llc_frame *)pvEthPayload)->SSAP == 0xAA) { //SNAP Frame pstEthCsPktInfo->eNwpktEthFrameType = eEth802LLCSNAPFrame; u16Etype = ((struct bcm_eth_llc_snap_frame *)pvEthPayload)->usEtherType; diff --git a/drivers/staging/bcm/Transmit.c b/drivers/staging/bcm/Transmit.c index 2ed4836b965..49767468ac2 100644 --- a/drivers/staging/bcm/Transmit.c +++ b/drivers/staging/bcm/Transmit.c @@ -46,12 +46,14 @@ int SendControlPacket(struct bcm_mini_adapter *Adapter, char *pControlPacket) BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Tx"); if (!pControlPacket || !Adapter) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Got NULL Control Packet or Adapter"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, + "Got NULL Control Packet or Adapter"); return STATUS_FAILURE; } if ((atomic_read(&Adapter->CurrNumFreeTxDesc) < ((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"); return STATUS_FAILURE; } @@ -109,7 +111,8 @@ int SetupNextSend(struct bcm_mini_adapter *Adapter, struct sk_buff *Packet, USH (UINT *)&Packet->len, Adapter->PackInfo[QueueIndex].bEthCSSupport); if (status != STATUS_SUCCESS) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "PHS Transmit failed..\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, + "PHS Transmit failed..\n"); goto errExit; } @@ -217,12 +220,15 @@ int tx_pkt_handler(struct bcm_mini_adapter *Adapter /**< pointer to adapter obje Adapter->LinkStatus == SYNC_UP_REQUEST && !Adapter->bSyncUpRequestSent) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Calling LinkMessage"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, + DBG_LVL_ALL, "Calling LinkMessage"); LinkMessage(Adapter); } if ((Adapter->IdleMode || Adapter->bShutStatus) && atomic_read(&Adapter->TotalPacketCount)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Device in Low Power mode...waking up"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, + TX_PACKETS, DBG_LVL_ALL, + "Device in Low Power mode...waking up"); Adapter->usIdleModePattern = ABORT_IDLE_MODE; Adapter->bWakeUpDevice = TRUE; wake_up(&Adapter->process_rx_cntrlpkt); @@ -232,7 +238,8 @@ int tx_pkt_handler(struct bcm_mini_adapter *Adapter /**< pointer to adapter obje atomic_set(&Adapter->TxPktAvail, 0); } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Exiting the tx thread..\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, + "Exiting the tx thread..\n"); Adapter->transmit_packet_thread = NULL; return 0; } diff --git a/drivers/staging/bcm/Typedefs.h b/drivers/staging/bcm/Typedefs.h index 832adcfd1e3..90b3b25dd60 100644 --- a/drivers/staging/bcm/Typedefs.h +++ b/drivers/staging/bcm/Typedefs.h @@ -25,16 +25,16 @@ typedef unsigned int B_UINT32; typedef unsigned long ULONG; typedef unsigned long DWORD; -typedef char* PCHAR; -typedef short* PSHORT; -typedef int* PINT; -typedef long* PLONG; -typedef void* PVOID; - -typedef unsigned char* PUCHAR; -typedef unsigned short* PUSHORT; -typedef unsigned int* PUINT; -typedef unsigned long* PULONG; +typedef char *PCHAR; +typedef short *PSHORT; +typedef int *PINT; +typedef long *PLONG; +typedef void *PVOID; + +typedef unsigned char *PUCHAR; +typedef unsigned short *PUSHORT; +typedef unsigned int *PUINT; +typedef unsigned long *PULONG; typedef unsigned long long ULONG64; typedef unsigned long long LARGE_INTEGER; typedef unsigned int UINT32; @@ -43,5 +43,5 @@ typedef unsigned int UINT32; #endif -#endif //__TYPEDEFS_H__ +#endif /* __TYPEDEFS_H__ */ diff --git a/drivers/staging/bcm/headers.h b/drivers/staging/bcm/headers.h index 7fd21c6923c..6f3270cc417 100644 --- a/drivers/staging/bcm/headers.h +++ b/drivers/staging/bcm/headers.h @@ -34,7 +34,7 @@ #include <linux/tcp.h> #include <linux/udp.h> #include <linux/usb.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <net/ip.h> #include "Typedefs.h" diff --git a/drivers/staging/bcm/hostmibs.c b/drivers/staging/bcm/hostmibs.c index f55300db1d4..42d9004e357 100644 --- a/drivers/staging/bcm/hostmibs.c +++ b/drivers/staging/bcm/hostmibs.c @@ -9,37 +9,40 @@ #include "headers.h" -INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, struct bcm_host_stats_mibs *pstHostMibs) +INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, + struct bcm_host_stats_mibs *pstHostMibs) { struct bcm_phs_entry *pstServiceFlowEntry = NULL; struct bcm_phs_rule *pstPhsRule = NULL; struct bcm_phs_classifier_table *pstClassifierTable = NULL; struct bcm_phs_classifier_entry *pstClassifierRule = NULL; - struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *) &Adapter->stBCMPhsContext; - - UINT nClassifierIndex = 0, nPhsTableIndex = 0, nSfIndex = 0, uiIndex = 0; + struct bcm_phs_extension *pDeviceExtension = &Adapter->stBCMPhsContext; + UINT nClassifierIndex = 0; + UINT nPhsTableIndex = 0; + UINT nSfIndex = 0; + UINT uiIndex = 0; if (pDeviceExtension == NULL) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, HOST_MIBS, DBG_LVL_ALL, "Invalid Device Extension\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, HOST_MIBS, + DBG_LVL_ALL, "Invalid Device Extension\n"); return STATUS_FAILURE; } /* Copy the classifier Table */ - for (nClassifierIndex = 0; nClassifierIndex < MAX_CLASSIFIERS; nClassifierIndex++) { + for (nClassifierIndex = 0; nClassifierIndex < MAX_CLASSIFIERS; + nClassifierIndex++) { if (Adapter->astClassifierTable[nClassifierIndex].bUsed == TRUE) - memcpy((PVOID) & pstHostMibs-> - astClassifierTable[nClassifierIndex], - (PVOID) & Adapter-> - astClassifierTable[nClassifierIndex], + memcpy(&pstHostMibs->astClassifierTable[nClassifierIndex], + &Adapter->astClassifierTable[nClassifierIndex], sizeof(struct bcm_mibs_classifier_rule)); } /* Copy the SF Table */ for (nSfIndex = 0; nSfIndex < NO_OF_QUEUES; nSfIndex++) { if (Adapter->PackInfo[nSfIndex].bValid) { - memcpy((PVOID) & pstHostMibs->astSFtable[nSfIndex], - (PVOID) & Adapter->PackInfo[nSfIndex], - sizeof(struct bcm_mibs_table)); + memcpy(&pstHostMibs->astSFtable[nSfIndex], + &Adapter->PackInfo[nSfIndex], + sizeof(struct bcm_mibs_table)); } else { /* If index in not valid, * don't process this for the PHS table. @@ -68,9 +71,9 @@ INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, struct bcm_host_stats_m pstHostMibs->astPhsRulesTable[nPhsTableIndex]. ulSFID = Adapter->PackInfo[nSfIndex].ulSFID; - memcpy(&pstHostMibs-> - astPhsRulesTable[nPhsTableIndex].u8PHSI, - &pstPhsRule->u8PHSI, sizeof(struct bcm_phs_rule)); + memcpy(&pstHostMibs->astPhsRulesTable[nPhsTableIndex].u8PHSI, + &pstPhsRule->u8PHSI, + sizeof(struct bcm_phs_rule)); nPhsTableIndex++; } @@ -82,26 +85,32 @@ INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, struct bcm_host_stats_m /* Copy other Host Statistics parameters */ pstHostMibs->stHostInfo.GoodTransmits = Adapter->dev->stats.tx_packets; pstHostMibs->stHostInfo.GoodReceives = Adapter->dev->stats.rx_packets; - pstHostMibs->stHostInfo.CurrNumFreeDesc = atomic_read(&Adapter->CurrNumFreeTxDesc); + pstHostMibs->stHostInfo.CurrNumFreeDesc = + atomic_read(&Adapter->CurrNumFreeTxDesc); pstHostMibs->stHostInfo.BEBucketSize = Adapter->BEBucketSize; pstHostMibs->stHostInfo.rtPSBucketSize = Adapter->rtPSBucketSize; pstHostMibs->stHostInfo.TimerActive = Adapter->TimerActive; pstHostMibs->stHostInfo.u32TotalDSD = Adapter->u32TotalDSD; - memcpy(pstHostMibs->stHostInfo.aTxPktSizeHist, Adapter->aTxPktSizeHist, sizeof(UINT32) * MIBS_MAX_HIST_ENTRIES); - memcpy(pstHostMibs->stHostInfo.aRxPktSizeHist, Adapter->aRxPktSizeHist, sizeof(UINT32) * MIBS_MAX_HIST_ENTRIES); + memcpy(pstHostMibs->stHostInfo.aTxPktSizeHist, Adapter->aTxPktSizeHist, + sizeof(UINT32) * MIBS_MAX_HIST_ENTRIES); + memcpy(pstHostMibs->stHostInfo.aRxPktSizeHist, Adapter->aRxPktSizeHist, + sizeof(UINT32) * MIBS_MAX_HIST_ENTRIES); return STATUS_SUCCESS; } -VOID GetDroppedAppCntrlPktMibs(struct bcm_host_stats_mibs *pstHostMibs, struct bcm_tarang_data *pTarang) +VOID GetDroppedAppCntrlPktMibs(struct bcm_host_stats_mibs *pstHostMibs, + struct bcm_tarang_data *pTarang) { memcpy(&(pstHostMibs->stDroppedAppCntrlMsgs), &(pTarang->stDroppedAppCntrlMsgs), sizeof(struct bcm_mibs_dropped_cntrl_msg)); } -VOID CopyMIBSExtendedSFParameters(struct bcm_mini_adapter *Adapter, struct bcm_connect_mgr_params *psfLocalSet, UINT uiSearchRuleIndex) +VOID CopyMIBSExtendedSFParameters(struct bcm_mini_adapter *Adapter, + struct bcm_connect_mgr_params *psfLocalSet, + UINT uiSearchRuleIndex) { struct bcm_mibs_parameters *t = &Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable; diff --git a/drivers/staging/bcm/nvm.c b/drivers/staging/bcm/nvm.c index fca164f51f4..63be3be62eb 100644 --- a/drivers/staging/bcm/nvm.c +++ b/drivers/staging/bcm/nvm.c @@ -122,7 +122,7 @@ static UCHAR ReadEEPROMStatusRegister(struct bcm_mini_adapter *Adapter) * OSAL_STATUS_CODE: */ -int ReadBeceemEEPROMBulk(struct bcm_mini_adapter *Adapter, +static int ReadBeceemEEPROMBulk(struct bcm_mini_adapter *Adapter, DWORD dwAddress, DWORD *pdwData, DWORD dwNumWords) @@ -2698,7 +2698,7 @@ int BcmGetSectionValStartOffset(struct bcm_mini_adapter *Adapter, enum bcm_flash * On Failure -returns STATUS_FAILURE */ -int BcmGetSectionValEndOffset(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectionVal) +static int BcmGetSectionValEndOffset(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectionVal) { int SectEndOffset = 0; @@ -2980,7 +2980,7 @@ static int BcmGetActiveISO(struct bcm_mini_adapter *Adapter) * */ -B_UINT8 IsOffsetWritable(struct bcm_mini_adapter *Adapter, unsigned int uiOffset) +static B_UINT8 IsOffsetWritable(struct bcm_mini_adapter *Adapter, unsigned int uiOffset) { unsigned int uiSectorNum = 0; unsigned int uiWordOfSectorPermission = 0; @@ -3374,7 +3374,7 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_secti case DSD2: if (ReadDSDSignature(Adapter, eFlash2xSectVal) == DSD_IMAGE_MAGIC_NUMBER) { HighestPriDSD = getHighestPriDSD(Adapter); - if ((HighestPriDSD == eFlash2xSectVal)) { + if (HighestPriDSD == eFlash2xSectVal) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Given DSD<%x> already has highest priority", eFlash2xSectVal); Status = STATUS_SUCCESS; break; @@ -3402,7 +3402,7 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_secti HighestPriDSD = getHighestPriDSD(Adapter); - if ((HighestPriDSD == eFlash2xSectVal)) { + if (HighestPriDSD == eFlash2xSectVal) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Made the DSD: %x highest by reducing priority of other\n", eFlash2xSectVal); Status = STATUS_SUCCESS; break; @@ -3421,7 +3421,7 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_secti } HighestPriDSD = getHighestPriDSD(Adapter); - if ((HighestPriDSD == eFlash2xSectVal)) { + if (HighestPriDSD == eFlash2xSectVal) { Status = STATUS_SUCCESS; break; } @@ -4074,7 +4074,7 @@ int BcmCopySection(struct bcm_mini_adapter *Adapter, * Faillure :- Return negative error code */ -int SaveHeaderIfPresent(struct bcm_mini_adapter *Adapter, PUCHAR pBuff, unsigned int uiOffset) +static int SaveHeaderIfPresent(struct bcm_mini_adapter *Adapter, PUCHAR pBuff, unsigned int uiOffset) { unsigned int offsetToProtect = 0, HeaderSizeToProtect = 0; bool bHasHeader = false; @@ -4213,7 +4213,7 @@ static int BcmDoChipSelect(struct bcm_mini_adapter *Adapter, unsigned int offset return STATUS_SUCCESS; } -int ReadDSDSignature(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val dsd) +static int ReadDSDSignature(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val dsd) { unsigned int uiDSDsig = 0; /* unsigned int sigoffsetInMap = 0; @@ -4238,7 +4238,7 @@ int ReadDSDSignature(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_ return uiDSDsig; } -int ReadDSDPriority(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val dsd) +static int ReadDSDPriority(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val dsd) { /* unsigned int priOffsetInMap = 0 ; */ unsigned int uiDSDPri = STATUS_FAILURE; @@ -4261,7 +4261,7 @@ int ReadDSDPriority(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_v return uiDSDPri; } -enum bcm_flash2x_section_val getHighestPriDSD(struct bcm_mini_adapter *Adapter) +static enum bcm_flash2x_section_val getHighestPriDSD(struct bcm_mini_adapter *Adapter) { int DSDHighestPri = STATUS_FAILURE; int DsdPri = 0; @@ -4293,7 +4293,7 @@ enum bcm_flash2x_section_val getHighestPriDSD(struct bcm_mini_adapter *Adapter) return HighestPriDSD; } -int ReadISOSignature(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val iso) +static int ReadISOSignature(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val iso) { unsigned int uiISOsig = 0; /* unsigned int sigoffsetInMap = 0; @@ -4316,7 +4316,7 @@ int ReadISOSignature(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_ return uiISOsig; } -int ReadISOPriority(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val iso) +static int ReadISOPriority(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val iso) { unsigned int ISOPri = STATUS_FAILURE; if (IsSectionWritable(Adapter, iso)) { @@ -4335,7 +4335,7 @@ int ReadISOPriority(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_v return ISOPri; } -enum bcm_flash2x_section_val getHighestPriISO(struct bcm_mini_adapter *Adapter) +static enum bcm_flash2x_section_val getHighestPriISO(struct bcm_mini_adapter *Adapter) { int ISOHighestPri = STATUS_FAILURE; int ISOPri = 0; @@ -4359,7 +4359,7 @@ enum bcm_flash2x_section_val getHighestPriISO(struct bcm_mini_adapter *Adapter) return HighestPriISO; } -int WriteToFlashWithoutSectorErase(struct bcm_mini_adapter *Adapter, +static int WriteToFlashWithoutSectorErase(struct bcm_mini_adapter *Adapter, PUINT pBuff, enum bcm_flash2x_section_val eFlash2xSectionVal, unsigned int uiOffset, @@ -4472,7 +4472,7 @@ bool IsSectionExistInFlash(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_se return SectionPresent; } -int IsSectionWritable(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val Section) +static int IsSectionWritable(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val Section) { int offset = STATUS_FAILURE; int Status = false; |
