diff options
Diffstat (limited to 'drivers/staging/bcm')
48 files changed, 8198 insertions, 8340 deletions
diff --git a/drivers/staging/bcm/Adapter.h b/drivers/staging/bcm/Adapter.h index 4d490a99110..1b2d9f3bd55 100644 --- a/drivers/staging/bcm/Adapter.h +++ b/drivers/staging/bcm/Adapter.h @@ -35,10 +35,12 @@ struct bcm_link_request { #define MAX_PROTOCOL_LENGTH 32 #define IPV6_ADDRESS_SIZEINBYTES 0x10 -typedef union _U_IP_ADDRESS { +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 */ @@ -52,7 +54,7 @@ typedef union _U_IP_ADDRESS { UCHAR ucIpv6Address[MAX_IP_RANGE_LENGTH * IPV6_ADDRESS_SIZEINBYTES]; UCHAR ucIpv6Mask[MAX_IP_RANGE_LENGTH * IPV6_ADDRESS_SIZEINBYTES]; }; -} U_IP_ADDRESS; +}; struct bcm_hdr_suppression_contextinfo { UCHAR ucaHdrSuppressionInBuf[MAX_PHS_LENGTHS]; /* Intermediate buffer to accumulate pkt Header for PHS */ @@ -63,13 +65,13 @@ struct bcm_classifier_rule { ULONG ulSFID; UCHAR ucReserved[2]; B_UINT16 uiClassifierRuleIndex; - BOOLEAN bUsed; + bool bUsed; USHORT usVCID_Value; B_UINT8 u8ClassifierRulePriority; /* This field detemines the Classifier Priority */ - U_IP_ADDRESS stSrcIpAddress; + union u_ip_address stSrcIpAddress; UCHAR ucIPSourceAddressLength; /* Ip Source Address Length */ - U_IP_ADDRESS stDestIpAddress; + union u_ip_address stDestIpAddress; UCHAR ucIPDestinationAddressLength; /* Ip Destination Address Length */ UCHAR ucIPTypeOfServiceLength; /* Type of service Length */ UCHAR ucTosLow; /* Tos Low */ @@ -86,16 +88,16 @@ struct bcm_classifier_rule { USHORT usDestPortRangeHi[MAX_PORT_RANGE]; UCHAR ucDestPortRangeLength; - BOOLEAN bProtocolValid; - BOOLEAN bTOSValid; - BOOLEAN bDestIpValid; - BOOLEAN bSrcIpValid; + bool bProtocolValid; + bool bTOSValid; + bool bDestIpValid; + bool bSrcIpValid; /* For IPv6 Addressing */ UCHAR ucDirection; - BOOLEAN bIpv6Protocol; + bool bIpv6Protocol; UINT32 u32PHSRuleID; - S_PHS_RULE sPhsRule; + struct bcm_phs_rule sPhsRule; UCHAR u8AssociatedPHSI; /* Classification fields for ETH CS */ @@ -113,11 +115,11 @@ struct bcm_classifier_rule { }; struct bcm_fragmented_packet_info { - BOOLEAN bUsed; + bool bUsed; ULONG ulSrcIpAddress; USHORT usIpIdentification; struct bcm_classifier_rule *pstMatchedClassifierEntry; - BOOLEAN bOutOfOrderFragment; + bool bOutOfOrderFragment; }; struct bcm_packet_info { @@ -128,9 +130,9 @@ struct bcm_packet_info { /* This field determines the priority of the SF Queues */ B_UINT8 u8TrafficPriority; - BOOLEAN bValid; - BOOLEAN bActive; - BOOLEAN bActivateRequestSent; + bool bValid; + bool bActive; + bool bActivateRequestSent; B_UINT8 u8QueueType; /* BE or rtPS */ @@ -151,7 +153,7 @@ struct bcm_packet_info { UINT NumOfPacketsSent; UCHAR ucDirection; USHORT usCID; - S_MIBS_EXTSERVICEFLOW_PARAMETERS stMibsExtServiceFlowTable; + struct bcm_mibs_parameters stMibsExtServiceFlowTable; UINT uiCurrentRxRate; UINT uiThisPeriodRxBytes; UINT uiTotalRxBytes; @@ -170,17 +172,17 @@ struct bcm_packet_info { }; }; - BOOLEAN bProtocolValid; - BOOLEAN bTOSValid; - BOOLEAN bDestIpValid; - BOOLEAN bSrcIpValid; + bool bProtocolValid; + bool bTOSValid; + bool bDestIpValid; + bool bSrcIpValid; - BOOLEAN bActiveSet; - BOOLEAN bAdmittedSet; - BOOLEAN bAuthorizedSet; - BOOLEAN bClassifierPriority; + bool bActiveSet; + bool bAdmittedSet; + bool bAuthorizedSet; + bool bClassifierPriority; UCHAR ucServiceClassName[MAX_CLASS_NAME_LENGTH]; - BOOLEAN bHeaderSuppressionEnabled; + bool bHeaderSuppressionEnabled; spinlock_t SFQueueLock; void *pstSFIndication; struct timeval stLastUpdateTokenAt; @@ -196,16 +198,16 @@ struct bcm_tarang_data { struct sk_buff *RxAppControlHead; struct sk_buff *RxAppControlTail; int AppCtrlQueueLen; - BOOLEAN MacTracingEnabled; - BOOLEAN bApplicationToExit; - S_MIBS_DROPPED_APP_CNTRL_MESSAGES stDroppedAppCntrlMsgs; + bool MacTracingEnabled; + bool bApplicationToExit; + struct bcm_mibs_dropped_cntrl_msg stDroppedAppCntrlMsgs; ULONG RxCntrlMsgBitMask; }; struct bcm_targetdsx_buffer { ULONG ulTargetDsxBuffer; B_UINT16 tid; - BOOLEAN valid; + bool valid; }; typedef int (*FP_FLASH_WRITE)(struct bcm_mini_adapter *, UINT, PVOID); @@ -221,11 +223,11 @@ struct bcm_mini_adapter { u32 msg_enable; CHAR *caDsxReqResp; atomic_t ApplicationRunning; - BOOLEAN AppCtrlQueueOverFlow; + bool AppCtrlQueueOverFlow; atomic_t CurrentApplicationCount; atomic_t RegisteredApplicationCount; - BOOLEAN LinkUpStatus; - BOOLEAN TimerActive; + bool LinkUpStatus; + bool TimerActive; u32 StatisticsPointer; struct sk_buff *RxControlHead; struct sk_buff *RxControlTail; @@ -249,25 +251,25 @@ struct bcm_mini_adapter { UINT u32TotalDSD; struct bcm_packet_info PackInfo[NO_OF_QUEUES]; struct bcm_classifier_rule astClassifierTable[MAX_CLASSIFIERS]; - BOOLEAN TransferMode; + bool TransferMode; /*************** qos ******************/ - BOOLEAN bETHCSEnabled; + bool bETHCSEnabled; ULONG BEBucketSize; ULONG rtPSBucketSize; UCHAR LinkStatus; - BOOLEAN AutoLinkUp; - BOOLEAN AutoSyncup; + bool AutoLinkUp; + bool AutoSyncup; int major; int minor; wait_queue_head_t tx_packet_wait_queue; wait_queue_head_t process_rx_cntrlpkt; atomic_t process_waiting; - BOOLEAN fw_download_done; + bool fw_download_done; char *txctlpacket[MAX_CNTRL_PKTS]; - atomic_t cntrlpktCnt ; + atomic_t cntrlpktCnt; atomic_t index_app_read_cntrlpkt; atomic_t index_wr_txcntrlpkt; atomic_t index_rd_txcntrlpkt; @@ -280,19 +282,19 @@ struct bcm_mini_adapter { ULONG ulTotalTargetBuffersAvailable; unsigned long chip_id; wait_queue_head_t lowpower_mode_wait_queue; - BOOLEAN bFlashBoot; - BOOLEAN bBinDownloaded; - BOOLEAN bCfgDownloaded; - BOOLEAN bSyncUpRequestSent; + bool bFlashBoot; + bool bBinDownloaded; + bool bCfgDownloaded; + bool bSyncUpRequestSent; USHORT usBestEffortQueueIndex; wait_queue_head_t ioctl_fw_dnld_wait_queue; - BOOLEAN waiting_to_fw_download_done; + bool waiting_to_fw_download_done; pid_t fw_download_process_pid; - PSTARGETPARAMS pstargetparams; - BOOLEAN device_removed; - BOOLEAN DeviceAccess; - BOOLEAN bIsAutoCorrectEnabled; - BOOLEAN bDDRInitDone; + struct bcm_target_params *pstargetparams; + bool device_removed; + bool DeviceAccess; + bool bIsAutoCorrectEnabled; + bool bDDRInitDone; int DDRSetting; ULONG ulPowerSaveMode; spinlock_t txtransmitlock; @@ -303,10 +305,10 @@ struct bcm_mini_adapter { struct task_struct *transmit_packet_thread; /* LED Related Structures */ - LED_INFO_STRUCT LEDInfo; + struct bcm_led_info LEDInfo; /* Driver State for LED Blinking */ - LedEventInfo_t DriverState; + enum bcm_led_events DriverState; /* Interface Specific */ PVOID pvInterfaceAdapter; int (*bcm_file_download)(PVOID, @@ -324,32 +326,32 @@ struct bcm_mini_adapter { PVOID, int); int (*interface_transmit)(PVOID, PVOID , UINT); - BOOLEAN IdleMode; - BOOLEAN bDregRequestSentInIdleMode; - BOOLEAN bTriedToWakeUpFromlowPowerMode; - BOOLEAN bShutStatus; - BOOLEAN bWakeUpDevice; + bool IdleMode; + bool bDregRequestSentInIdleMode; + bool bTriedToWakeUpFromlowPowerMode; + bool bShutStatus; + bool bWakeUpDevice; unsigned int usIdleModePattern; /* BOOLEAN bTriedToWakeUpFromShutdown; */ - BOOLEAN bLinkDownRequested; + bool bLinkDownRequested; int downloadDDR; - PHS_DEVICE_EXTENSION stBCMPhsContext; + struct bcm_phs_extension stBCMPhsContext; struct bcm_hdr_suppression_contextinfo stPhsTxContextInfo; uint8_t ucaPHSPktRestoreBuf[2048]; uint8_t bPHSEnabled; - BOOLEAN AutoFirmDld; - BOOLEAN bMipsConfig; - BOOLEAN bDPLLConfig; + bool AutoFirmDld; + bool bMipsConfig; + bool bDPLLConfig; UINT32 aTxPktSizeHist[MIBS_MAX_HIST_ENTRIES]; UINT32 aRxPktSizeHist[MIBS_MAX_HIST_ENTRIES]; struct bcm_fragmented_packet_info astFragmentedPktClassifierTable[MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES]; atomic_t uiMBupdate; UINT32 PmuMode; - NVM_TYPE eNVMType; + enum bcm_nvm_type eNVMType; UINT uiSectorSize; UINT uiSectorSizeInCFG; - BOOLEAN bSectorSizeOverride; - BOOLEAN bStatusWrite; + bool bSectorSizeOverride; + bool bStatusWrite; UINT uiNVMDSDSize; UINT uiVendorExtnFlag; /* it will always represent chosen DSD at any point of time. @@ -366,33 +368,33 @@ struct bcm_mini_adapter { struct device *pstCreatedClassDevice; /* BOOLEAN InterfaceUpStatus; */ - PFLASH2X_CS_INFO psFlash2xCSInfo; - PFLASH_CS_INFO psFlashCSInfo; - PFLASH2X_VENDORSPECIFIC_INFO psFlash2xVendorInfo; + struct bcm_flash2x_cs_info *psFlash2xCSInfo; + struct bcm_flash_cs_info *psFlashCSInfo; + struct bcm_flash2x_vendor_info *psFlash2xVendorInfo; UINT uiFlashBaseAdd; /* Flash start address */ UINT uiActiveISOOffset; /* Active ISO offset chosen before f/w download */ - FLASH2X_SECTION_VAL eActiveISO; /* Active ISO section val */ - FLASH2X_SECTION_VAL eActiveDSD; /* Active DSD val chosen before f/w download */ + enum bcm_flash2x_section_val eActiveISO; /* Active ISO section val */ + enum bcm_flash2x_section_val eActiveDSD; /* Active DSD val chosen before f/w download */ UINT uiActiveDSDOffsetAtFwDld; /* For accessing Active DSD chosen before f/w download */ UINT uiFlashLayoutMajorVersion; UINT uiFlashLayoutMinorVersion; - BOOLEAN bAllDSDWriteAllow; - BOOLEAN bSigCorrupted; - /* this should be set who so ever want to change the Headers. after Wrtie it should be reset immediately. */ - BOOLEAN bHeaderChangeAllowed; + bool bAllDSDWriteAllow; + bool bSigCorrupted; + /* this should be set who so ever want to change the Headers. after Write it should be reset immediately. */ + bool bHeaderChangeAllowed; int SelectedChip; - BOOLEAN bEndPointHalted; + bool bEndPointHalted; /* while bFlashRawRead will be true, Driver ignore map lay out and consider flash as of without any map. */ - BOOLEAN bFlashRawRead; - BOOLEAN bPreparingForLowPowerMode; - BOOLEAN bDoSuspend; + bool bFlashRawRead; + bool bPreparingForLowPowerMode; + bool bDoSuspend; UINT syscfgBefFwDld; - BOOLEAN StopAllXaction; + bool StopAllXaction; UINT32 liTimeSinceLastNetEntry; /* Used to Support extended CAPI requirements from */ struct semaphore LowPowerModeSync; ULONG liDrainCalculated; UINT gpioBitMap; - S_BCM_DEBUG_STATE stDebugState; + struct bcm_debug_state stDebugState; }; #define GET_BCM_ADAPTER(net_dev) netdev_priv(net_dev) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 3d02c2ebfb8..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() * @@ -13,7 +101,7 @@ * Returns - Zero(Success) ****************************************************************/ -static int bcm_char_open(struct inode *inode, struct file * filp) +static int bcm_char_open(struct inode *inode, struct file *filp) { struct bcm_mini_adapter *Adapter = NULL; struct bcm_tarang_data *pTarang = NULL; @@ -49,11 +137,8 @@ static int bcm_char_release(struct inode *inode, struct file *filp) pTarang = (struct bcm_tarang_data *)filp->private_data; - if (pTarang == NULL) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "ptarang is null\n"); + if (pTarang == NULL) return 0; - } Adapter = pTarang->Adapter; @@ -104,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"); @@ -119,7 +206,7 @@ static ssize_t bcm_char_read(struct file *filp, char __user *buf, size_t size, return -ENODEV; } - if (FALSE == Adapter->fw_download_done) + if (false == Adapter->fw_download_done) return -EACCES; down(&Adapter->RxAppControlQueuelock); @@ -153,1849 +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; + struct bcm_rdm_buffer sRdmBuffer = {0}; + struct bcm_ioctl_buffer IoBuffer; + PCHAR temp_buff; INT Status = STATUS_FAILURE; - int timeout = 0; - IOCTL_BUFFER IoBuffer; + 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: { - RDM_BUFFER sRdmBuffer = {0}; - PCHAR temp_buff; - UINT Bufflen; - u16 temp_value; - - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&IoBuffer, argp, sizeof(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: { - 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(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: { - 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(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; - } - case IOCTL_BCM_REGISTER_WRITE: - case IOCTL_BCM_EEPROM_REGISTER_WRITE: { - WRM_BUFFER sWrmBuffer = {0}; - UINT uiTempVar = 0; - 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_PRINTK, 0, 0, "Device in Idle Mode, Blocking Wrms\n"); - return -EACCES; - } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Device in Idle Mode, Blocking Wrms\n"); + return -EACCES; + } - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; - if (IoBuffer.InputLength > sizeof(sWrmBuffer)) - return -EINVAL; + if (IoBuffer.InputLength > sizeof(sWrmBuffer)) + return -EINVAL; - /* Get WrmBuffer structure */ - if (copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; + /* Get WrmBuffer structure */ + if (copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer, + IoBuffer.InputLength)) + return -EFAULT; - if ((((ULONG)sWrmBuffer.Register & 0x0F000000) != 0x0F000000) || - ((ULONG)sWrmBuffer.Register & 0x3)) { + if ((((ULONG)sWrmBuffer.Register & 0x0F000000) != 0x0F000000) || + ((ULONG)sWrmBuffer.Register & 0x3)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "WRM Done On invalid Address : %x Access Denied.\n", (int)sWrmBuffer.Register); - return -EINVAL; - } + 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)) { + 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; - } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "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; + return Status; +} - GPIO_INFO gpio_info = {0}; - 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(IOCTL_BUFFER))) - return -EFAULT; - - if (IoBuffer.InputLength > sizeof(gpio_info)) - return -EINVAL; + 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 (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; - uiOperation = gpio_info.uiGpioValue; - value = (1<<uiBit); + if (IoBuffer.InputLength > sizeof(gpio_info)) + return -EINVAL; - 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; - } + if (copy_from_user(&gpio_info, IoBuffer.InputBuffer, + IoBuffer.InputLength)) + return -EFAULT; - /* Set - setting 1 */ - if (uiOperation) { - /* Set the gpio output register */ - Status = wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_SET_REG, (PUINT)(&value), sizeof(UINT)); + uiBit = gpio_info.uiGpioNumber; + uiOperation = gpio_info.uiGpioValue; + value = (1<<uiBit); - 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: { - USER_THREAD_REQ threadReq = {0}; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "User made LED thread InActive"); + 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"); + 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(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]; - GPIO_INFO gpio_info = {0}; - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) - return -EACCES; - - if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; - - if (IoBuffer.InputLength > sizeof(gpio_info)) - return -EINVAL; - - if (copy_from_user(&gpio_info, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; + 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]; - GPIO_MULTI_INFO gpio_multi_info[MAX_IDX]; - PGPIO_MULTI_INFO pgpio_multi_info = (PGPIO_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(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(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]; - GPIO_MULTI_MODE gpio_multi_mode[MAX_IDX]; - PGPIO_MULTI_MODE pgpio_multi_mode = (PGPIO_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(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(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(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; + "IOCTL: Configuration File Upload Failed\n"); + else + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "IOCTL: Firmware File Upload Failed\n"); - /* setting the Mips to Run */ - Status = run_card_proc(Adapter); + /* up(&Adapter->fw_download_sema); */ - 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"); - } - - mdelay(10); - - /* Wait for MailBox Interrupt */ - if (StartInterruptUrb((PS_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 (!timeout) - Status = -ENODEV; + if (Status != STATUS_SUCCESS) + up(&Adapter->fw_download_sema); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, OSAL_DBG, DBG_LVL_ALL, + "IOCTL: Firmware File Uploaded\n"); + 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(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(VER_FILEVERSION_STR) + 1); +static int bcm_char_ioctl_qos_threshold(ULONG arg, + struct bcm_mini_adapter *Adapter) +{ + USHORT uiLoopIndex; - if (copy_to_user(IoBuffer.OutputBuffer, VER_FILEVERSION_STR, 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: { - 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(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(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; - case IOCTL_BCM_GET_DSX_INDICATION: { - ULONG ulSFId = 0; - if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; + /* 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 (IoBuffer.OutputLength < sizeof(stLocalSFAddIndicationAlt)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Mismatch req: %lx needed is =0x%zx!!!", - IoBuffer.OutputLength, sizeof(stLocalSFAddIndicationAlt)); - return -EINVAL; - } + if (IoBuffer.OutputLength != sizeof(link_state)) + return -EINVAL; - if (copy_from_user(&ulSFId, IoBuffer.InputBuffer, sizeof(ulSFId))) - return -EFAULT; + memset(&link_state, 0, sizeof(link_state)); + link_state.bIdleMode = Adapter->IdleMode; + link_state.bShutdownMode = Adapter->bShutStatus; + link_state.ucLinkStatus = Adapter->LinkStatus; - 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(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(S_MIBS_HOST_STATS_MIBS)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Length Check failed %lu %zd\n", - IoBuffer.OutputLength, sizeof(S_MIBS_HOST_STATS_MIBS)); - return -EINVAL; - } + /* 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(S_MIBS_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(S_MIBS_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: { - PBULKWRM_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(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 = (PBULKWRM_BUFFER)pvBuffer; + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { - if (((ULONG)pBulkBuffer->Register & 0x0F000000) != 0x0F000000 || - ((ULONG)pBulkBuffer->Register & 0x3)) { - kfree(pvBuffer); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "WRM Done On invalid Address : %x Access Denied.\n", (int)pBulkBuffer->Register); - Status = -EINVAL; - break; - } + 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(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(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 - { - USER_BCM_DBG_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(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(USER_BCM_DBG_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; +} - BCM_SHOW_DEBUG_BITMAP(Adapter); +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; + + 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: { - 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(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(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: { - 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(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(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); + + 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; + } - /* 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 (validateFlash2xReadWrite(Adapter, &sFlash2xWrite) == false) + return STATUS_FAILURE; - NOB = sFlash2xRead.numOfBytes; - if (NOB > Adapter->uiSectorSize) - BuffSize = Adapter->uiSectorSize; - else - BuffSize = NOB; + InputAddr = sFlash2xWrite.pDataBuff; + WriteOffset = sFlash2xWrite.offset; + NOB = sFlash2xWrite.numOfBytes; - ReadOffset = sFlash2xRead.offset ; - OutPutBuff = IoBuffer.OutputBuffer; - pReadBuff = (PCHAR)kzalloc(BuffSize , GFP_KERNEL); + if (NOB > Adapter->uiSectorSize) + BuffSize = Adapter->uiSectorSize; + else + BuffSize = NOB; - 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); + pWriteBuff = kmalloc(BuffSize, GFP_KERNEL); - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { + if (pWriteBuff == NULL) + return -ENOMEM; + + /* extracting the remainder of the given offset. */ + WriteBytes = Adapter->uiSectorSize; + if (WriteOffset % Adapter->uiSectorSize) { + WriteBytes = Adapter->uiSectorSize - + (WriteOffset % Adapter->uiSectorSize); + } + + if (NOB < WriteBytes) + WriteBytes = NOB; + + 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(pWriteBuff); + return -EACCES; + } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); + 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(pReadBuff); - return -EACCES; + kfree(pWriteBuff); + return -EFAULT; } + BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, + OSAL_DBG, DBG_LVL_ALL, pWriteBuff, WriteBytes); - while (NOB) { + /* Writing the data from Flash 2.x */ + Status = BcmFlash2xBulkWrite(Adapter, (PUINT)pWriteBuff, + sFlash2xWrite.Section, + WriteOffset, + WriteBytes, + sFlash2xWrite.bVerify); + + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Flash 2x read err with Status :%d", Status); + break; + } + + NOB = NOB - WriteBytes; + if (NOB) { + WriteOffset = WriteOffset + WriteBytes; + InputAddr = InputAddr + WriteBytes; if (NOB > Adapter->uiSectorSize) - ReadBytes = Adapter->uiSectorSize; + WriteBytes = Adapter->uiSectorSize; else - ReadBytes = NOB; + WriteBytes = NOB; + } + } while (NOB > 0); - /* 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; - } + BcmFlash2xWriteSig(Adapter, sFlash2xWrite.Section); + up(&Adapter->NVMRdmWrmLock); + kfree(pWriteBuff); + return Status; +} - BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, pReadBuff, ReadBytes); +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; - 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 ; - } - } +BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP Called"); - up(&Adapter->NVMRdmWrmLock); - kfree(pReadBuff); - } - break; + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; - case IOCTL_BCM_FLASH2X_SECTION_WRITE: { - FLASH2X_READWRITE sFlash2xWrite = {0}; - PUCHAR pWriteBuff; - void __user *InputAddr; - UINT NOB = 0; - UINT BuffSize = 0; - UINT WriteOffset = 0; - UINT WriteBytes = 0; + if (IoBuffer.OutputLength != sizeof(struct bcm_flash2x_bitmap)) + return -EINVAL; - if (IsFlash2x(Adapter) != TRUE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Does not have 2.x map"); - return -EINVAL; - } + psFlash2xBitMap = kzalloc(sizeof(struct bcm_flash2x_bitmap), + GFP_KERNEL); - /* First make this False so that we can enable the Sector Permission Check in BeceemFlashBulkWrite */ - Adapter->bAllDSDWriteAllow = FALSE; + if (psFlash2xBitMap == NULL) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Memory is not available"); + return -ENOMEM; + } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_FLASH2X_SECTION_WRITE Called"); + /* Reading the Flash Sectio Bit map */ + down(&Adapter->NVMRdmWrmLock); - if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { - /* Reading FLASH 2.x READ structure */ - if (copy_from_user(&sFlash2xWrite, IoBuffer.InputBuffer, sizeof(FLASH2X_READWRITE))) - return -EFAULT; + 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, "\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); + BcmGetFlash2xSectionalBitMap(Adapter, psFlash2xBitMap); + up(&Adapter->NVMRdmWrmLock); + if (copy_to_user(IoBuffer.OutputBuffer, psFlash2xBitMap, + sizeof(struct bcm_flash2x_bitmap))) { + kfree(psFlash2xBitMap); + 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; - } + kfree(psFlash2xBitMap); + return STATUS_FAILURE; +} - if (validateFlash2xReadWrite(Adapter, &sFlash2xWrite) == FALSE) - return STATUS_FAILURE; +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; - InputAddr = sFlash2xWrite.pDataBuff; - WriteOffset = sFlash2xWrite.offset; - NOB = sFlash2xWrite.numOfBytes; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "IOCTL_BCM_SET_ACTIVE_SECTION Called"); - if (NOB > Adapter->uiSectorSize) - BuffSize = Adapter->uiSectorSize; - else - BuffSize = NOB ; + if (IsFlash2x(Adapter) != TRUE) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Flash Does not have 2.x map"); + return -EINVAL; + } - pWriteBuff = kmalloc(BuffSize, GFP_KERNEL); + 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 (pWriteBuff == NULL) - return -ENOMEM; + 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; + } - /* extracting the remainder of the given offset. */ - WriteBytes = Adapter->uiSectorSize; - if (WriteOffset % Adapter->uiSectorSize) - WriteBytes = Adapter->uiSectorSize - (WriteOffset % Adapter->uiSectorSize); + down(&Adapter->NVMRdmWrmLock); - if (NOB < WriteBytes) - WriteBytes = NOB; + 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); - kfree(pWriteBuff); - return -EACCES; - } + up(&Adapter->NVMRdmWrmLock); - 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); + return Status; +} - /* Writing the data from Flash 2.x */ - Status = BcmFlash2xBulkWrite(Adapter, (PUINT)pWriteBuff, sFlash2xWrite.Section, WriteOffset, WriteBytes, sFlash2xWrite.bVerify); +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; - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash 2x read err with Status :%d", Status); - break; - } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "IOCTL_BCM_COPY_SECTION Called"); - NOB = NOB - WriteBytes; - if (NOB) { - WriteOffset = WriteOffset + WriteBytes; - InputAddr = InputAddr + WriteBytes; - if (NOB > Adapter->uiSectorSize) - WriteBytes = Adapter->uiSectorSize; - else - WriteBytes = NOB; - } - } while (NOB > 0); + 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; + } - BcmFlash2xWriteSig(Adapter, sFlash2xWrite.Section); - up(&Adapter->NVMRdmWrmLock); - kfree(pWriteBuff); + 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_GET_FLASH2X_SECTION_BITMAP: { - PFLASH2X_BITMAP psFlash2xBitMap; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP Called"); + Status = copy_from_user(&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 (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; + 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); - if (IoBuffer.OutputLength != sizeof(FLASH2X_BITMAP)) - return -EINVAL; + 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; + } - psFlash2xBitMap = kzalloc(sizeof(FLASH2X_BITMAP), GFP_KERNEL); - if (psFlash2xBitMap == NULL) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Memory is not available"); - return -ENOMEM; - } + 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; + } - /* Reading the Flash Sectio Bit map */ - 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); - kfree(psFlash2xBitMap); - return -EACCES; - } + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { - BcmGetFlash2xSectionalBitMap(Adapter, psFlash2xBitMap); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "Device is in Idle/Shutdown Mode\n"); up(&Adapter->NVMRdmWrmLock); - if (copy_to_user(IoBuffer.OutputBuffer, psFlash2xBitMap, sizeof(FLASH2X_BITMAP))) { - kfree(psFlash2xBitMap); - return -EFAULT; + 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; + } - kfree(psFlash2xBitMap); + 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_SET_ACTIVE_SECTION: { - FLASH2X_SECTION_VAL eFlash2xSectionVal = 0; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SET_ACTIVE_SECTION Called"); + if (Adapter->eNVMType != NVM_FLASH) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Connected device does not have flash"); + return -EINVAL; + } - 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(IOCTL_BUFFER)); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); + 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(&eFlash2xSectionVal, IoBuffer.InputBuffer, sizeof(INT)); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of flash section val failed"); + if (copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlashCSInfo, + sizeof(struct bcm_flash_cs_info))) return -EFAULT; - } - - down(&Adapter->NVMRdmWrmLock); + } + return Status; +} - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { +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; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); - up(&Adapter->NVMRdmWrmLock); - return -EACCES; - } + eFlash2xSectionVal = NO_SECTION_VAL; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "IOCTL_BCM_SELECT_DSD Called"); - 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); + if (IsFlash2x(Adapter) != TRUE) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Flash Does not have 2.x map"); + return -EINVAL; + } - up(&Adapter->NVMRdmWrmLock); + 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; } - 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; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "Read Section :%d", eFlash2xSectionVal); + if ((eFlash2xSectionVal != DSD0) && + (eFlash2xSectionVal != DSD1) && + (eFlash2xSectionVal != DSD2)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Passed section<%x> is not DSD section", + eFlash2xSectionVal); + return STATUS_FAILURE; } - break; - case IOCTL_BCM_COPY_SECTION: { - 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"); + 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; + } - 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; - } + Adapter->bAllDSDWriteAllow = TRUE; + Adapter->ulFlashCalStart = SectOfset; + Adapter->eActiveDSD = eFlash2xSectionVal; - Status = copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed Status :%d", Status); - return -EFAULT; - } + return STATUS_SUCCESS; +} - Status = copy_from_user(&sCopySectStrut, IoBuffer.InputBuffer, sizeof(FLASH2X_COPY_SECTION)); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of Copy_Section_Struct failed with Status :%d", Status); - return -EFAULT; - } +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; - 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); + if (Adapter->eNVMType != NVM_FLASH) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "NVM TYPE is not Flash"); + return -EINVAL; + } - if (IsSectionExistInFlash(Adapter, sCopySectStrut.SrcSection) == FALSE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Source Section<%x> does not exixt in Flash ", sCopySectStrut.SrcSection); - return -EINVAL; - } + /* 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; + } - if (IsSectionExistInFlash(Adapter, sCopySectStrut.DstSection) == FALSE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Destinatio Section<%x> does not exixt in Flash ", sCopySectStrut.DstSection); - return -EINVAL; - } + if (copy_from_user(&stNVMRead, IoBuffer.OutputBuffer, + sizeof(struct bcm_nvm_readwrite))) + return -EFAULT; - 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; - } + NOB = stNVMRead.uiNumBytes; + /* In Raw-Read max Buff size : 64MB */ - down(&Adapter->NVMRdmWrmLock); + if (NOB > DEFAULT_BUFF_SIZE) + BuffSize = DEFAULT_BUFF_SIZE; + else + BuffSize = NOB; - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { + ReadOffset = stNVMRead.uiOffset; + OutPutBuff = stNVMRead.pBuffer; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); - up(&Adapter->NVMRdmWrmLock); - return -EACCES; - } + 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; + } + down(&Adapter->NVMRdmWrmLock); - 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; - } + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { - Status = BcmCopySection(Adapter, sCopySectStrut.SrcSection, - sCopySectStrut.DstSection, sCopySectStrut.offset, sCopySectStrut.numOfBytes); + 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; } - 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"); + Adapter->bFlashRawRead = TRUE; + + while (NOB) { + if (NOB > DEFAULT_BUFF_SIZE) + ReadBytes = DEFAULT_BUFF_SIZE; + else + ReadBytes = NOB; - Status = copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)); + /* 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; } - if (Adapter->eNVMType != NVM_FLASH) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Connected device does not have flash"); - Status = -EINVAL; - break; + BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, + DBG_LVL_ALL, pReadBuff, ReadBytes); + + Status = copy_to_user(OutPutBuff, pReadBuff, ReadBytes); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Copy to use failed with status :%d", + Status); + 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; +} - if (IsFlash2x(Adapter) == TRUE) { - if (IoBuffer.OutputLength < sizeof(FLASH2X_CS_INFO)) - return -EINVAL; +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; - if (copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlash2xCSInfo, sizeof(FLASH2X_CS_INFO))) - return -EFAULT; - } else { - if (IoBuffer.OutputLength < sizeof(FLASH_CS_INFO)) - return -EINVAL; + /* 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; + } - if (copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlashCSInfo, sizeof(FLASH_CS_INFO))) - return -EFAULT; - } + if (IoBuffer.InputLength != sizeof(unsigned long)) + return -EINVAL; + + 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; } - 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_SELECT_DSD: { - UINT SectOfset = 0; - 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"); + return Status; +} - if (IsFlash2x(Adapter) != TRUE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Does not have 2.x map"); - 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; - Status = copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); - 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; - } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "Called IOCTL_BCM_GET_DEVICE_DRIVER_INFO\n"); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Read Section :%d", eFlash2xSectionVal); - if ((eFlash2xSectionVal != DSD0) && - (eFlash2xSectionVal != DSD1) && - (eFlash2xSectionVal != DSD2)) { + 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; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Passed section<%x> is not DSD section", eFlash2xSectionVal); - return STATUS_FAILURE; - } + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + 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 exixt in Flash 2.x", eFlash2xSectionVal); - return -EINVAL; - } + if (IoBuffer.OutputLength < sizeof(DevInfo)) + return -EINVAL; - Adapter->bAllDSDWriteAllow = TRUE; - Adapter->ulFlashCalStart = SectOfset; - Adapter->eActiveDSD = eFlash2xSectionVal; - } - Status = STATUS_SUCCESS; - break; + if (copy_to_user(IoBuffer.OutputBuffer, &DevInfo, sizeof(DevInfo))) + return -EFAULT; - case IOCTL_BCM_NVM_RAW_READ: { - NVM_READWRITE stNVMRead; - INT NOB ; - INT BuffSize ; - INT ReadOffset = 0; - UINT ReadBytes = 0 ; - PUCHAR pReadBuff; - void __user *OutPutBuff; + return STATUS_SUCCESS; +} - 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_time_since_net_entry(void __user *argp, + struct bcm_mini_adapter *Adapter) +{ + struct bcm_time_elapsed stTimeElapsedSinceNetEntry = {0}; + struct bcm_ioctl_buffer IoBuffer; - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "copy_from_user 1 failed\n"); - return -EFAULT; - } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "IOCTL_BCM_TIME_SINCE_NET_ENTRY called"); - if (copy_from_user(&stNVMRead, IoBuffer.OutputBuffer, sizeof(NVM_READWRITE))) - return -EFAULT; + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; - NOB = stNVMRead.uiNumBytes; - /* In Raw-Read max Buff size : 64MB */ + if (IoBuffer.OutputLength < sizeof(struct bcm_time_elapsed)) + return -EINVAL; - if (NOB > DEFAULT_BUFF_SIZE) - BuffSize = DEFAULT_BUFF_SIZE; - else - BuffSize = NOB; + stTimeElapsedSinceNetEntry.ul64TimeElapsedSinceNetEntry = + get_seconds() - Adapter->liTimeSinceLastNetEntry; - ReadOffset = stNVMRead.uiOffset; - OutPutBuff = stNVMRead.pBuffer; + if (copy_to_user(IoBuffer.OutputBuffer, &stTimeElapsedSinceNetEntry, + sizeof(struct bcm_time_elapsed))) + 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)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); - kfree(pReadBuff); - up(&Adapter->NVMRdmWrmLock); +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_RTPS_BUCKET_SIZE: + Status = 0; + if (get_user(Adapter->rtPSBucketSize, + (unsigned long __user *)arg)) + Status = -EFAULT; break; - } - case IOCTL_BCM_CNTRLMSG_MASK: { - ULONG RxCntrlMsgBitMask = 0; + case IOCTL_CHIP_RESET: + Status = bcm_char_ioctl_chip_reset(Adapter); + return Status; - /* Copy Ioctl Buffer structure */ - Status = copy_from_user(&IoBuffer, argp, sizeof(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_QOS_THRESHOLD: + Status = bcm_char_ioctl_qos_threshold(arg, Adapter); + return Status; - if (IoBuffer.InputLength != sizeof(unsigned long)) { - Status = -EINVAL; - break; - } + case IOCTL_DUMP_PACKET_INFO: + DumpPackInfo(Adapter); + DumpPhsRules(&Adapter->stBCMPhsContext); + Status = STATUS_SUCCESS; + break; - 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_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: { - DEVICE_DRIVER_INFO DevInfo; + Status = STATUS_SUCCESS; + break; + + case IOCTL_BCM_BULK_WRM: + Status = bcm_char_ioctl_bulk_wrm(argp, Adapter, cmd); + return Status; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Called IOCTL_BCM_GET_DEVICE_DRIVER_INFO\n"); + case IOCTL_BCM_GET_NVM_SIZE: + Status = bcm_char_ioctl_get_nvm_size(argp, Adapter); + return Status; - DevInfo.MaxRDMBufferSize = BUFFER_4K; - DevInfo.u32DSDStartOffset = EEPROM_CALPARAM_START; - DevInfo.u32RxAlignmentCorrection = 0; - DevInfo.u32NVMType = Adapter->eNVMType; - DevInfo.u32InterfaceType = BCM_USB; + case IOCTL_BCM_CAL_INIT: + Status = bcm_char_ioctl_cal_init(argp, Adapter); + return Status; - if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER))) - return -EFAULT; + case IOCTL_BCM_SET_DEBUG: + Status = bcm_char_ioctl_set_debug(argp, Adapter); + return Status; - if (IoBuffer.OutputLength < sizeof(DevInfo)) - return -EINVAL; + case IOCTL_BCM_NVM_READ: + case IOCTL_BCM_NVM_WRITE: + Status = bcm_char_ioctl_nvm_rw(argp, Adapter, cmd); + return Status; - if (copy_to_user(IoBuffer.OutputBuffer, &DevInfo, sizeof(DevInfo))) - return -EFAULT; - } - break; + case IOCTL_BCM_FLASH2X_SECTION_READ: + Status = bcm_char_ioctl_flash2x_section_read(argp, Adapter); + return Status; - case IOCTL_BCM_TIME_SINCE_NET_ENTRY: { - ST_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(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(ST_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; + + case IOCTL_BCM_COPY_SECTION: + Status = bcm_char_ioctl_copy_section(argp, Adapter); + return Status; - stTimeElapsedSinceNetEntry.ul64TimeElapsedSinceNetEntry = get_seconds() - Adapter->liTimeSinceLastNetEntry; + case IOCTL_BCM_GET_FLASH_CS_INFO: + Status = bcm_char_ioctl_get_flash_cs_info(argp, Adapter); + return Status; - if (copy_to_user(IoBuffer.OutputBuffer, &stTimeElapsedSinceNetEntry, sizeof(ST_TIME_ELAPSED))) - return -EFAULT; - } - break; + 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: @@ -2029,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 6e8c7f52321..95a2358267b 100644 --- a/drivers/staging/bcm/Bcmnet.c +++ b/drivers/staging/bcm/Bcmnet.c @@ -6,7 +6,7 @@ static INT bcm_open(struct net_device *dev) { struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(dev); - if (Adapter->fw_download_done == FALSE) { + if (Adapter->fw_download_done == false) { pr_notice(PFX "%s: link up failed (download in progress)\n", dev->name); return -EBUSY; @@ -39,7 +39,8 @@ static INT bcm_close(struct net_device *dev) return 0; } -static u16 bcm_select_queue(struct net_device *dev, struct sk_buff *skb) +static u16 bcm_select_queue(struct net_device *dev, struct sk_buff *skb, + void *accel_priv, select_queue_fallback_t fallback) { return ClassifyPacket(netdev_priv(dev), skb); } @@ -142,11 +143,12 @@ static void bcm_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(dev); - PS_INTERFACE_ADAPTER psIntfAdapter = Adapter->pvInterfaceAdapter; + struct bcm_interface_adapter *psIntfAdapter = + Adapter->pvInterfaceAdapter; struct usb_device *udev = interface_to_usbdev(psIntfAdapter->interface); - strcpy(info->driver, DRV_NAME); - strcpy(info->version, DRV_VERSION); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); snprintf(info->fw_version, sizeof(info->fw_version), "%u.%u", Adapter->uiFlashLayoutMajorVersion, Adapter->uiFlashLayoutMinorVersion); @@ -186,7 +188,7 @@ static const struct ethtool_ops bcm_ethtool_ops = { int register_networkdev(struct bcm_mini_adapter *Adapter) { struct net_device *net = Adapter->dev; - PS_INTERFACE_ADAPTER IntfAdapter = Adapter->pvInterfaceAdapter; + struct bcm_interface_adapter *IntfAdapter = Adapter->pvInterfaceAdapter; struct usb_interface *udev = IntfAdapter->interface; struct usb_device *xdev = IntfAdapter->udev; @@ -227,7 +229,7 @@ int register_networkdev(struct bcm_mini_adapter *Adapter) void unregister_networkdev(struct bcm_mini_adapter *Adapter) { struct net_device *net = Adapter->dev; - PS_INTERFACE_ADAPTER IntfAdapter = Adapter->pvInterfaceAdapter; + struct bcm_interface_adapter *IntfAdapter = Adapter->pvInterfaceAdapter; struct usb_interface *udev = IntfAdapter->interface; struct usb_device *xdev = IntfAdapter->udev; diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index 325b592fd41..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,13 +123,14 @@ 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(S_MIBS_SERVICEFLOW_TABLE)); + memset((PVOID)&Adapter->PackInfo[uiSearchRuleIndex], 0, + sizeof(struct bcm_mibs_table)); } static inline VOID CopyIpAddrToClassifier(struct bcm_classifier_rule *pstClassifierEntry, B_UINT8 u8IpAddressLen, B_UINT8 *pu8IpAddressMaskSrc, - BOOLEAN bIpVersion6, E_IPADDR_CONTEXT eIpAddrContext) + bool bIpVersion6, enum bcm_ipaddr_context eIpAddrContext) { int i = 0; UINT nSizeOfIPAddressInBytes = IP_LENGTH_OF_ADDRESS; @@ -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,32 +256,31 @@ 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 + ); } } } -void ClearTargetDSXBuffer(struct bcm_mini_adapter *Adapter, B_UINT16 TID, BOOLEAN bFreeAll) +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, BOOLEA * @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); + 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, - (Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion == IPV6) ? TRUE : FALSE, + 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->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); } } @@ -431,7 +545,7 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* <Pointer register struct bcm_connect_mgr_params *psfLocalSet, /* Pointer to the connection manager parameters structure */ register UINT uiSearchRuleIndex, /* <Index of Queue, to which this data belongs */ register UCHAR ucDsxType, - stLocalSFAddIndicationAlt *pstAddIndication) { + struct bcm_add_indication_alt *pstAddIndication) { /* UCHAR ucProtocolLength = 0; */ ULONG ulSFID; @@ -440,325 +554,263 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* <Pointer B_UINT16 u16PacketClassificationRuleIndex = 0; int i; struct bcm_convergence_types *psfCSType = NULL; - S_PHS_RULE sPhsRule; - USHORT uVCID = Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value; + struct bcm_phs_rule sPhsRule; + 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(S_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__); } /*********************************************************************** @@ -833,11 +889,11 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) { int uiLoopIndex; int nIndex; - stLocalSFAddIndicationAlt *pstAddIndication; + struct bcm_add_indication_alt *pstAddIndication; UINT nCurClassifierCnt; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - pstAddIndication = (stLocalSFAddIndicationAlt *)pvBuffer; + pstAddIndication = pvBuffer; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "======>"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Type: 0x%X", pstAddIndication->u8Type); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Direction: 0x%X", pstAddIndication->u8Direction); @@ -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,28 +1435,30 @@ 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) { - stLocalSFAddIndicationAlt *pstAddIndicationAlt = NULL; + struct bcm_add_indication_alt *pstAddIndicationAlt = NULL; struct bcm_add_indication *pstAddIndication = NULL; struct bcm_del_request *pstDeletionRequest; UINT uiSearchRuleIndex; ULONG ulSFID; - pstAddIndicationAlt = (stLocalSFAddIndicationAlt *)(pvBuffer); + pstAddIndicationAlt = pvBuffer; /* * In case of DSD Req By MS, we should immediately delete this SF so that * we can stop the further classifying the pkt for this SF. */ if (pstAddIndicationAlt->u8Type == DSD_REQ) { - pstDeletionRequest = (struct bcm_del_request *)pvBuffer; + pstDeletionRequest = pvBuffer; ulSFID = ntohl(pstDeletionRequest->u32SFID); uiSearchRuleIndex = SearchSfid(Adapter, ulSFID); @@ -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; @@ -1445,41 +1569,64 @@ ULONG StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, PVOID pvBu return 1; } -static inline stLocalSFAddIndicationAlt -*RestoreCmControlResponseMessage(register struct bcm_mini_adapter *Adapter, register PVOID pvBuffer) +static inline struct bcm_add_indication_alt +*RestoreCmControlResponseMessage(register struct bcm_mini_adapter *Adapter, + register PVOID pvBuffer) { ULONG ulStatus = 0; struct bcm_add_indication *pstAddIndication = NULL; - stLocalSFAddIndicationAlt *pstAddIndicationDest = NULL; + struct bcm_add_indication_alt *pstAddIndicationDest = NULL; - pstAddIndication = (struct bcm_add_indication *)(pvBuffer); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "=====>"); + pstAddIndication = pvBuffer; + 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 (stLocalSFAddIndicationAlt *)pvBuffer; + 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(stLocalSFAddIndicationAlt), GFP_KERNEL); + pstAddIndicationDest = kmalloc(sizeof(struct bcm_add_indication_alt), + GFP_KERNEL); if (pstAddIndicationDest) { - memset(pstAddIndicationDest, 0, sizeof(stLocalSFAddIndicationAlt)); + 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 stLocalSFAddIndicationAlt 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,38 +1752,44 @@ 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 ulTargetDSXBufferAddress; - ULONG ulTargetDsxBufferIndexToUse, ulMaxTry; + ULONG dsx_buf; + ULONG idx, max_try; - if ((Adapter->ulTotalTargetBuffersAvailable == 0) || (Adapter->ulFreeTargetBufferCnt == 0)) { - ClearTargetDSXBuffer(Adapter, tid, FALSE); + if ((Adapter->ulTotalTargetBuffersAvailable == 0) + || (Adapter->ulFreeTargetBufferCnt == 0)) { + ClearTargetDSXBuffer(Adapter, tid, false); return 0; } - ulTargetDsxBufferIndexToUse = Adapter->ulCurrentTargetBuffer; - ulMaxTry = Adapter->ulTotalTargetBuffersAvailable; - while ((ulMaxTry) && (Adapter->astTargetDsxBuffer[ulTargetDsxBufferIndexToUse].valid != 1)) { - ulTargetDsxBufferIndexToUse = (ulTargetDsxBufferIndexToUse+1) % Adapter->ulTotalTargetBuffersAvailable; - ulMaxTry--; + idx = Adapter->ulCurrentTargetBuffer; + max_try = Adapter->ulTotalTargetBuffersAvailable; + while ((max_try) && (Adapter->astTargetDsxBuffer[idx].valid != 1)) { + idx = (idx+1) % Adapter->ulTotalTargetBuffersAvailable; + max_try--; } - if (ulMaxTry == 0) { - 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); + 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); + ClearTargetDSXBuffer(Adapter, tid, false); return 0; } - ulTargetDSXBufferAddress = Adapter->astTargetDsxBuffer[ulTargetDsxBufferIndexToUse].ulTargetDsxBuffer; - Adapter->astTargetDsxBuffer[ulTargetDsxBufferIndexToUse].valid = 0; - Adapter->astTargetDsxBuffer[ulTargetDsxBufferIndexToUse].tid = tid; + dsx_buf = Adapter->astTargetDsxBuffer[idx].ulTargetDsxBuffer; + Adapter->astTargetDsxBuffer[idx].valid = 0; + Adapter->astTargetDsxBuffer[idx].tid = tid; Adapter->ulFreeTargetBufferCnt--; - ulTargetDsxBufferIndexToUse = (ulTargetDsxBufferIndexToUse+1)%Adapter->ulTotalTargetBuffersAvailable; - Adapter->ulCurrentTargetBuffer = ulTargetDsxBufferIndexToUse; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "GetNextTargetBufferLocation :Returning address %lx tid %d\n", ulTargetDSXBufferAddress, tid); + 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); - return ulTargetDSXBufferAddress; + return dsx_buf; } int AllocAdapterDsxBuffer(struct bcm_mini_adapter *Adapter) @@ -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(stLocalSFAddIndicationAlt)+LEADER_SIZE, GFP_KERNEL); + Adapter->caDsxReqResp = kmalloc(sizeof(struct bcm_add_indication_alt) + + LEADER_SIZE, GFP_KERNEL); if (!Adapter->caDsxReqResp) return -ENOMEM; @@ -1630,13 +1818,15 @@ int FreeAdapterDsxBuffer(struct bcm_mini_adapter *Adapter) * for the Connection Management. * @return - Queue index for the free SFID else returns Invalid Index. */ -BOOLEAN CmControlResponseMessage(struct bcm_mini_adapter *Adapter, /* <Pointer to the Adapter structure */ +bool CmControlResponseMessage(struct bcm_mini_adapter *Adapter, /* <Pointer to the Adapter structure */ PVOID pvBuffer /* Starting Address of the Buffer, that contains the AddIndication Data */) { struct bcm_connect_mgr_params *psfLocalSet = NULL; - stLocalSFAddIndicationAlt *pstAddIndication = NULL; - stLocalSFChangeIndicationAlt *pstChangeIndication = NULL; + 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 @@ -1644,9 +1834,9 @@ BOOLEAN CmControlResponseMessage(struct bcm_mini_adapter *Adapter, /* <Pointer */ pstAddIndication = RestoreCmControlResponseMessage(Adapter, pvBuffer); if (pstAddIndication == NULL) { - ClearTargetDSXBuffer(Adapter, ((struct bcm_add_indication *)pvBuffer)->u16TID, FALSE); + ClearTargetDSXBuffer(Adapter, ((struct bcm_add_indication *)pvBuffer)->u16TID, false); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Error in restoring Service Flow param structure from DSx message"); - return FALSE; + return false; } DumpCmControlPacket(pstAddIndication); @@ -1656,37 +1846,30 @@ BOOLEAN CmControlResponseMessage(struct bcm_mini_adapter *Adapter, /* <Pointer pLeader->Status = CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ; pLeader->Vcid = 0; - ClearTargetDSXBuffer(Adapter, pstAddIndication->u16TID, FALSE); + ClearTargetDSXBuffer(Adapter, pstAddIndication->u16TID, false); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "### TID RECEIVED %d\n", pstAddIndication->u16TID); switch (pstAddIndication->u8Type) { case DSA_REQ: - { - pLeader->PLength = sizeof(stLocalSFAddIndicationAlt); + 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); - *((stLocalSFAddIndicationAlt *)&(Adapter->caDsxReqResp[LEADER_SIZE])) + *((struct bcm_add_indication_alt *)&(Adapter->caDsxReqResp[LEADER_SIZE])) = *pstAddIndication; - ((stLocalSFAddIndicationAlt *)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSA_RSP; + ((struct bcm_add_indication_alt *)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSA_RSP; 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(stLocalSFAddIndicationAlt); + 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); - *((stLocalSFAddIndicationAlt *)&(Adapter->caDsxReqResp[LEADER_SIZE])) + *((struct bcm_add_indication_alt *)&(Adapter->caDsxReqResp[LEADER_SIZE])) = *pstAddIndication; - ((stLocalSFAddIndicationAlt *)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSA_ACK; - - } /* no break here..we should go down. */ + ((struct bcm_add_indication_alt *)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSA_ACK; + /* 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 @@ BOOLEAN CmControlResponseMessage(struct bcm_mini_adapter *Adapter, /* <Pointer 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 ", @@ -1708,9 +1891,9 @@ BOOLEAN CmControlResponseMessage(struct bcm_mini_adapter *Adapter, /* <Pointer if (pstAddIndication->sfAdmittedSet.bValid == TRUE) Adapter->PackInfo[uiSearchRuleIndex].bAdmittedSet = TRUE; - if (pstAddIndication->sfActiveSet.bValid == FALSE) { - Adapter->PackInfo[uiSearchRuleIndex].bActive = FALSE; - Adapter->PackInfo[uiSearchRuleIndex].bActivateRequestSent = FALSE; + if (pstAddIndication->sfActiveSet.bValid == false) { + Adapter->PackInfo[uiSearchRuleIndex].bActive = false; + Adapter->PackInfo[uiSearchRuleIndex].bActivateRequestSent = false; if (pstAddIndication->sfAdmittedSet.bValid) psfLocalSet = &pstAddIndication->sfAdmittedSet; else if (pstAddIndication->sfAuthorizedSet.bValid) @@ -1722,8 +1905,8 @@ BOOLEAN CmControlResponseMessage(struct bcm_mini_adapter *Adapter, /* <Pointer if (!psfLocalSet) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "No set is valid\n"); - Adapter->PackInfo[uiSearchRuleIndex].bActive = FALSE; - Adapter->PackInfo[uiSearchRuleIndex].bValid = FALSE; + Adapter->PackInfo[uiSearchRuleIndex].bActive = false; + Adapter->PackInfo[uiSearchRuleIndex].bValid = false; Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value = 0; kfree(pstAddIndication); } else if (psfLocalSet->bValid && (pstAddIndication->u8CC == 0)) { @@ -1759,49 +1942,42 @@ BOOLEAN CmControlResponseMessage(struct bcm_mini_adapter *Adapter, /* <Pointer } } } else { - Adapter->PackInfo[uiSearchRuleIndex].bActive = FALSE; - Adapter->PackInfo[uiSearchRuleIndex].bValid = FALSE; + Adapter->PackInfo[uiSearchRuleIndex].bActive = false; + Adapter->PackInfo[uiSearchRuleIndex].bValid = false; Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value = 0; kfree(pstAddIndication); } } else { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "DSA ACK did not get valid SFID"); kfree(pstAddIndication); - return FALSE; + return false; } - } - break; + break; case DSC_REQ: - { - pLeader->PLength = sizeof(stLocalSFChangeIndicationAlt); - pstChangeIndication = (stLocalSFChangeIndicationAlt *)pstAddIndication; + 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); - *((stLocalSFChangeIndicationAlt *)&(Adapter->caDsxReqResp[LEADER_SIZE])) = *pstChangeIndication; - ((stLocalSFChangeIndicationAlt *)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSC_RSP; + *((struct bcm_change_indication *)&(Adapter->caDsxReqResp[LEADER_SIZE])) = *pstChangeIndication; + ((struct bcm_change_indication *)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSC_RSP; CopyBufferToControlPacket(Adapter, (PVOID)Adapter->caDsxReqResp); kfree(pstAddIndication); - } - break; + break; case DSC_RSP: - { - pLeader->PLength = sizeof(stLocalSFChangeIndicationAlt); - pstChangeIndication = (stLocalSFChangeIndicationAlt *)pstAddIndication; + 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); - *((stLocalSFChangeIndicationAlt *)&(Adapter->caDsxReqResp[LEADER_SIZE])) = *pstChangeIndication; - ((stLocalSFChangeIndicationAlt *)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSC_ACK; - } + *((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 = (stLocalSFChangeIndicationAlt *)pstAddIndication; + 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; @@ -1812,9 +1988,9 @@ BOOLEAN CmControlResponseMessage(struct bcm_mini_adapter *Adapter, /* <Pointer if (pstChangeIndication->sfAdmittedSet.bValid == TRUE) Adapter->PackInfo[uiSearchRuleIndex].bAdmittedSet = TRUE; - if (pstChangeIndication->sfActiveSet.bValid == FALSE) { - Adapter->PackInfo[uiSearchRuleIndex].bActive = FALSE; - Adapter->PackInfo[uiSearchRuleIndex].bActivateRequestSent = FALSE; + if (pstChangeIndication->sfActiveSet.bValid == false) { + Adapter->PackInfo[uiSearchRuleIndex].bActive = false; + Adapter->PackInfo[uiSearchRuleIndex].bActivateRequestSent = false; if (pstChangeIndication->sfAdmittedSet.bValid) psfLocalSet = &pstChangeIndication->sfAdmittedSet; @@ -1827,8 +2003,8 @@ BOOLEAN CmControlResponseMessage(struct bcm_mini_adapter *Adapter, /* <Pointer if (!psfLocalSet) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "No set is valid\n"); - Adapter->PackInfo[uiSearchRuleIndex].bActive = FALSE; - Adapter->PackInfo[uiSearchRuleIndex].bValid = FALSE; + Adapter->PackInfo[uiSearchRuleIndex].bActive = false; + Adapter->PackInfo[uiSearchRuleIndex].bValid = false; Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value = 0; kfree(pstAddIndication); } else if (psfLocalSet->bValid && (pstChangeIndication->u8CC == 0)) { @@ -1847,15 +2023,10 @@ BOOLEAN CmControlResponseMessage(struct bcm_mini_adapter *Adapter, /* <Pointer } else { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "DSC ACK did not get valid SFID"); kfree(pstAddIndication); - return FALSE; + 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,45 +2043,51 @@ BOOLEAN CmControlResponseMessage(struct bcm_mini_adapter *Adapter, /* <Pointer 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; default: kfree(pstAddIndication); - return FALSE; + return false; } 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(stLocalSFAddIndicationAlt))) { - 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"); + if (pHostInfo->RetainSF == false) { + 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/CmHost.h b/drivers/staging/bcm/CmHost.h index 1c5a07c7bbe..0887d3f49e2 100644 --- a/drivers/staging/bcm/CmHost.h +++ b/drivers/staging/bcm/CmHost.h @@ -1,147 +1,62 @@ -/// ************************************************************************** -/// (c) Beceem Communications Inc. -/// All Rights Reserved -/// -/// \file : CmHost.h -/// \author : Rajeev Tirumala -/// \date : September 8 , 2006 -/// \brief : Definitions for Connection Management Requests structure -/// which we will use to setup our connection structures.Its high -/// time we had a header file for CmHost.cpp to isolate the way -/// f/w sends DSx messages and the way we interpret them in code. -/// Revision History -/// -/// Date Author Version Description -/// 08-Sep-06 Rajeev 0.1 Created -/// ************************************************************************** +/*************************************************************************** + * (c) Beceem Communications Inc. + * All Rights Reserved + * + * file : CmHost.h + * author: Rajeev Tirumala + * date : September 8 , 2006 + * brief : Definitions for Connection Management Requests structure + * which we will use to setup our connection structures.Its high + * time we had a header file for CmHost.cpp to isolate the way + * f/w sends DSx messages and the way we interpret them in code. + * Revision History + * + * Date Author Version Description + * 08-Sep-06 Rajeev 0.1 Created + ***************************************************************************/ #ifndef _CM_HOST_H #define _CM_HOST_H #pragma once -#pragma pack (push,4) +#pragma pack(push, 4) -#define DSX_MESSAGE_EXCHANGE_BUFFER 0xBF60AC84 // This contains the pointer -#define DSX_MESSAGE_EXCHANGE_BUFFER_SIZE 72000 // 24 K Bytes +#define DSX_MESSAGE_EXCHANGE_BUFFER 0xBF60AC84 /* This contains the pointer */ +#define DSX_MESSAGE_EXCHANGE_BUFFER_SIZE 72000 /* 24 K Bytes */ -/// \brief structure stLocalSFAddRequest -typedef struct stLocalSFAddRequestAlt{ - B_UINT8 u8Type; - B_UINT8 u8Direction; - - B_UINT16 u16TID; - /// \brief 16bitCID - B_UINT16 u16CID; - /// \brief 16bitVCID - B_UINT16 u16VCID; - - - struct bcm_connect_mgr_params sfParameterSet; - - //USE_MEMORY_MANAGER(); -}stLocalSFAddRequestAlt; - -/// \brief structure stLocalSFAddIndication -typedef struct stLocalSFAddIndicationAlt{ - B_UINT8 u8Type; - B_UINT8 u8Direction; - B_UINT16 u16TID; - /// \brief 16bitCID - B_UINT16 u16CID; - /// \brief 16bitVCID - B_UINT16 u16VCID; - struct bcm_connect_mgr_params sfAuthorizedSet; - struct bcm_connect_mgr_params sfAdmittedSet; - struct bcm_connect_mgr_params sfActiveSet; - - B_UINT8 u8CC; /**< Confirmation Code*/ - B_UINT8 u8Padd; /**< 8-bit Padding */ - B_UINT16 u16Padd; /**< 16 bit Padding */ -// USE_MEMORY_MANAGER(); -}stLocalSFAddIndicationAlt; - -/// \brief structure stLocalSFAddConfirmation -typedef struct stLocalSFAddConfirmationAlt{ - B_UINT8 u8Type; - B_UINT8 u8Direction; - B_UINT16 u16TID; - /// \brief 16bitCID - B_UINT16 u16CID; - /// \brief 16bitVCID - B_UINT16 u16VCID; +struct bcm_add_indication_alt { + u8 u8Type; + u8 u8Direction; + u16 u16TID; + u16 u16CID; + u16 u16VCID; struct bcm_connect_mgr_params sfAuthorizedSet; struct bcm_connect_mgr_params sfAdmittedSet; struct bcm_connect_mgr_params sfActiveSet; -}stLocalSFAddConfirmationAlt; - - -/// \brief structure stLocalSFChangeRequest -typedef struct stLocalSFChangeRequestAlt{ - B_UINT8 u8Type; - B_UINT8 u8Direction; - B_UINT16 u16TID; - /// \brief 16bitCID - B_UINT16 u16CID; - /// \brief 16bitVCID - B_UINT16 u16VCID; - /* - //Pointer location at which following connection manager param Structure can be read - //from the target. We only get the address location and we need to read out the - //entire connection manager param structure at the given location on target - */ + u8 u8CC; /* < Confirmation Code */ + u8 u8Padd; + u16 u16Padd; +}; + +struct bcm_change_indication { + u8 u8Type; + u8 u8Direction; + u16 u16TID; + u16 u16CID; + u16 u16VCID; struct bcm_connect_mgr_params sfAuthorizedSet; struct bcm_connect_mgr_params sfAdmittedSet; struct bcm_connect_mgr_params sfActiveSet; - - B_UINT8 u8CC; /**< Confirmation Code*/ - B_UINT8 u8Padd; /**< 8-bit Padding */ - B_UINT16 u16Padd; /**< 16 bit */ - -}stLocalSFChangeRequestAlt; - -/// \brief structure stLocalSFChangeConfirmation -typedef struct stLocalSFChangeConfirmationAlt{ - B_UINT8 u8Type; - B_UINT8 u8Direction; - B_UINT16 u16TID; - /// \brief 16bitCID - B_UINT16 u16CID; - /// \brief 16bitVCID - B_UINT16 u16VCID; - struct bcm_connect_mgr_params sfAuthorizedSet; - struct bcm_connect_mgr_params sfAdmittedSet; - struct bcm_connect_mgr_params sfActiveSet; - -}stLocalSFChangeConfirmationAlt; - -/// \brief structure stLocalSFChangeIndication -typedef struct stLocalSFChangeIndicationAlt{ - B_UINT8 u8Type; - B_UINT8 u8Direction; - B_UINT16 u16TID; - /// \brief 16bitCID - B_UINT16 u16CID; - /// \brief 16bitVCID - B_UINT16 u16VCID; - struct bcm_connect_mgr_params sfAuthorizedSet; - struct bcm_connect_mgr_params sfAdmittedSet; - struct bcm_connect_mgr_params sfActiveSet; - - B_UINT8 u8CC; /**< Confirmation Code*/ - B_UINT8 u8Padd; /**< 8-bit Padding */ - B_UINT16 u16Padd; /**< 16 bit */ - -}stLocalSFChangeIndicationAlt; - -ULONG StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, PVOID pvBuffer,UINT *puBufferLength); - -INT AllocAdapterDsxBuffer(struct bcm_mini_adapter *Adapter); - -INT FreeAdapterDsxBuffer(struct bcm_mini_adapter *Adapter); -ULONG SetUpTargetDsxBuffers(struct bcm_mini_adapter *Adapter); - -BOOLEAN CmControlResponseMessage(struct bcm_mini_adapter *Adapter, PVOID pvBuffer); - - -#pragma pack (pop) + u8 u8CC; /* < Confirmation Code */ + u8 u8Padd; + u16 u16Padd; +}; + +unsigned long StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, void *pvBuffer, unsigned int *puBufferLength); +int AllocAdapterDsxBuffer(struct bcm_mini_adapter *Adapter); +int FreeAdapterDsxBuffer(struct bcm_mini_adapter *Adapter); +unsigned long SetUpTargetDsxBuffers(struct bcm_mini_adapter *Adapter); +bool CmControlResponseMessage(struct bcm_mini_adapter *Adapter, void *pvBuffer); + +#pragma pack(pop) #endif diff --git a/drivers/staging/bcm/DDRInit.c b/drivers/staging/bcm/DDRInit.c index 8c696b64ab2..f1d7cb82fd7 100644 --- a/drivers/staging/bcm/DDRInit.c +++ b/drivers/staging/bcm/DDRInit.c @@ -3,884 +3,867 @@ #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 -static struct bcm_ddr_setting asT3_DDRSetting133MHz[]= {// # DPLL Clock Setting - {0x0F000800,0x00007212}, - {0x0f000820,0x07F13FFF}, - {0x0f000810,0x00000F95}, - {0x0f000860,0x00000000}, - {0x0f000880,0x000003DD}, - // Changed source for X-bar and MIPS clock to APLL - {0x0f000840,0x0FFF1B00}, - {0x0f000870,0x00000002}, - {0x0F00a044,0x1fffffff}, - {0x0F00a040,0x1f000000}, - {0x0F00a084,0x1Cffffff}, - {0x0F00a080,0x1C000000}, - {0x0F00a04C,0x0000000C}, - //Memcontroller Default values - {0x0F007000,0x00010001}, - {0x0F007004,0x01010100}, - {0x0F007008,0x01000001}, - {0x0F00700c,0x00000000}, - {0x0F007010,0x01000000}, - {0x0F007014,0x01000100}, - {0x0F007018,0x01000000}, - {0x0F00701c,0x01020001},// POP - 0x00020001 Normal 0x01020001 - {0x0F007020,0x04030107}, //Normal - 0x04030107 POP - 0x05030107 - {0x0F007024,0x02000007}, - {0x0F007028,0x02020202}, - {0x0F00702c,0x0206060a},//ROB- 0x0205050a,//0x0206060a - {0x0F007030,0x05000000}, - {0x0F007034,0x00000003}, - {0x0F007038,0x110a0200},//ROB - 0x110a0200,//0x180a0200,// 0x1f0a0200 - {0x0F00703C,0x02101010},//ROB - 0x02101010,//0x02101018}, - {0x0F007040,0x45751200},//ROB - 0x45751200,//0x450f1200}, - {0x0F007044,0x110a0d00},//ROB - 0x110a0d00//0x111f0d00 - {0x0F007048,0x081b0306}, - {0x0F00704c,0x00000000}, - {0x0F007050,0x0000001c}, - {0x0F007054,0x00000000}, - {0x0F007058,0x00000000}, - {0x0F00705c,0x00000000}, - {0x0F007060,0x0010246c}, - {0x0F007064,0x00000010}, - {0x0F007068,0x00000000}, - {0x0F00706c,0x00000001}, - {0x0F007070,0x00007000}, - {0x0F007074,0x00000000}, - {0x0F007078,0x00000000}, - {0x0F00707C,0x00000000}, - {0x0F007080,0x00000000}, - {0x0F007084,0x00000000}, - //# Enable BW improvement within memory controller - {0x0F007094,0x00000104}, - //# Enable 2 ports within X-bar - {0x0F00A000,0x00000016}, - //# Enable start bit within memory controller - {0x0F007018,0x01010000} - }; -//80Mhz -#define T3_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 10 //index for 0x0F007000 -static struct bcm_ddr_setting asT3_DDRSetting80MHz[]= {// # DPLL Clock Setting - {0x0f000810,0x00000F95}, - {0x0f000820,0x07f1ffff}, - {0x0f000860,0x00000000}, - {0x0f000880,0x000003DD}, - {0x0F00a044,0x1fffffff}, - {0x0F00a040,0x1f000000}, - {0x0F00a084,0x1Cffffff}, - {0x0F00a080,0x1C000000}, - {0x0F00a000,0x00000016}, - {0x0F00a04C,0x0000000C}, - //Memcontroller Default values - {0x0F007000,0x00010001}, - {0x0F007004,0x01000000}, - {0x0F007008,0x01000001}, - {0x0F00700c,0x00000000}, - {0x0F007010,0x01000000}, - {0x0F007014,0x01000100}, - {0x0F007018,0x01000000}, - {0x0F00701c,0x01020000}, - {0x0F007020,0x04020107}, - {0x0F007024,0x00000007}, - {0x0F007028,0x02020201}, - {0x0F00702c,0x0204040a}, - {0x0F007030,0x04000000}, - {0x0F007034,0x00000002}, - {0x0F007038,0x1F060200}, - {0x0F00703C,0x1C22221F}, - {0x0F007040,0x8A006600}, - {0x0F007044,0x221a0800}, - {0x0F007048,0x02690204}, - {0x0F00704c,0x00000000}, - {0x0F007050,0x0000001c}, - {0x0F007054,0x00000000}, - {0x0F007058,0x00000000}, - {0x0F00705c,0x00000000}, - {0x0F007060,0x000A15D6}, - {0x0F007064,0x0000000A}, - {0x0F007068,0x00000000}, - {0x0F00706c,0x00000001}, - {0x0F007070,0x00004000}, - {0x0F007074,0x00000000}, - {0x0F007078,0x00000000}, - {0x0F00707C,0x00000000}, - {0x0F007080,0x00000000}, - {0x0F007084,0x00000000}, - {0x0F007094,0x00000104}, - //# Enable start bit within memory controller - {0x0F007018,0x01010000} - }; -//100Mhz -#define T3_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 13 //index for 0x0F007000 -static struct bcm_ddr_setting asT3_DDRSetting100MHz[]= {// # DPLL Clock Setting - {0x0F000800,0x00007008}, - {0x0f000810,0x00000F95}, - {0x0f000820,0x07F13E3F}, - {0x0f000860,0x00000000}, - {0x0f000880,0x000003DD}, - // Changed source for X-bar and MIPS clock to APLL - //0x0f000840,0x0FFF1800, - {0x0f000840,0x0FFF1B00}, - {0x0f000870,0x00000002}, - {0x0F00a044,0x1fffffff}, - {0x0F00a040,0x1f000000}, - {0x0F00a084,0x1Cffffff}, - {0x0F00a080,0x1C000000}, - {0x0F00a04C,0x0000000C}, - //# Enable 2 ports within X-bar - {0x0F00A000,0x00000016}, - //Memcontroller Default values - {0x0F007000,0x00010001}, - {0x0F007004,0x01010100}, - {0x0F007008,0x01000001}, - {0x0F00700c,0x00000000}, - {0x0F007010,0x01000000}, - {0x0F007014,0x01000100}, - {0x0F007018,0x01000000}, - {0x0F00701c,0x01020001}, // POP - 0x00020000 Normal 0x01020000 - {0x0F007020,0x04020107},//Normal - 0x04030107 POP - 0x05030107 - {0x0F007024,0x00000007}, - {0x0F007028,0x01020201}, - {0x0F00702c,0x0204040A}, - {0x0F007030,0x06000000}, - {0x0F007034,0x00000004}, - {0x0F007038,0x20080200}, - {0x0F00703C,0x02030320}, - {0x0F007040,0x6E7F1200}, - {0x0F007044,0x01190A00}, - {0x0F007048,0x06120305},//0x02690204 // 0x06120305 - {0x0F00704c,0x00000000}, - {0x0F007050,0x0000001C}, - {0x0F007054,0x00000000}, - {0x0F007058,0x00000000}, - {0x0F00705c,0x00000000}, - {0x0F007060,0x00082ED6}, - {0x0F007064,0x0000000A}, - {0x0F007068,0x00000000}, - {0x0F00706c,0x00000001}, - {0x0F007070,0x00005000}, - {0x0F007074,0x00000000}, - {0x0F007078,0x00000000}, - {0x0F00707C,0x00000000}, - {0x0F007080,0x00000000}, - {0x0F007084,0x00000000}, - //# Enable BW improvement within memory controller - {0x0F007094,0x00000104}, - //# Enable start bit within memory controller - {0x0F007018,0x01010000} - }; +/* DDR INIT-133Mhz */ +#define T3_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 12 /* index for 0x0F007000 */ +static struct bcm_ddr_setting asT3_DDRSetting133MHz[] = { /* DPLL Clock Setting */ + {0x0F000800, 0x00007212}, + {0x0f000820, 0x07F13FFF}, + {0x0f000810, 0x00000F95}, + {0x0f000860, 0x00000000}, + {0x0f000880, 0x000003DD}, + /* Changed source for X-bar and MIPS clock to APLL */ + {0x0f000840, 0x0FFF1B00}, + {0x0f000870, 0x00000002}, + {0x0F00a044, 0x1fffffff}, + {0x0F00a040, 0x1f000000}, + {0x0F00a084, 0x1Cffffff}, + {0x0F00a080, 0x1C000000}, + {0x0F00a04C, 0x0000000C}, + /* Memcontroller Default values */ + {0x0F007000, 0x00010001}, + {0x0F007004, 0x01010100}, + {0x0F007008, 0x01000001}, + {0x0F00700c, 0x00000000}, + {0x0F007010, 0x01000000}, + {0x0F007014, 0x01000100}, + {0x0F007018, 0x01000000}, + {0x0F00701c, 0x01020001}, + {0x0F007020, 0x04030107}, + {0x0F007024, 0x02000007}, + {0x0F007028, 0x02020202}, + {0x0F00702c, 0x0206060a}, + {0x0F007030, 0x05000000}, + {0x0F007034, 0x00000003}, + {0x0F007038, 0x110a0200}, + {0x0F00703C, 0x02101010}, + {0x0F007040, 0x45751200}, + {0x0F007044, 0x110a0d00}, + {0x0F007048, 0x081b0306}, + {0x0F00704c, 0x00000000}, + {0x0F007050, 0x0000001c}, + {0x0F007054, 0x00000000}, + {0x0F007058, 0x00000000}, + {0x0F00705c, 0x00000000}, + {0x0F007060, 0x0010246c}, + {0x0F007064, 0x00000010}, + {0x0F007068, 0x00000000}, + {0x0F00706c, 0x00000001}, + {0x0F007070, 0x00007000}, + {0x0F007074, 0x00000000}, + {0x0F007078, 0x00000000}, + {0x0F00707C, 0x00000000}, + {0x0F007080, 0x00000000}, + {0x0F007084, 0x00000000}, + /* Enable BW improvement within memory controller */ + {0x0F007094, 0x00000104}, + /* Enable 2 ports within X-bar */ + {0x0F00A000, 0x00000016}, + /* Enable start bit within memory controller */ + {0x0F007018, 0x01010000} +}; +/* 80Mhz */ +#define T3_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 10 /* index for 0x0F007000 */ +static struct bcm_ddr_setting asT3_DDRSetting80MHz[] = { /* DPLL Clock Setting */ + {0x0f000810, 0x00000F95}, + {0x0f000820, 0x07f1ffff}, + {0x0f000860, 0x00000000}, + {0x0f000880, 0x000003DD}, + {0x0F00a044, 0x1fffffff}, + {0x0F00a040, 0x1f000000}, + {0x0F00a084, 0x1Cffffff}, + {0x0F00a080, 0x1C000000}, + {0x0F00a000, 0x00000016}, + {0x0F00a04C, 0x0000000C}, + /* Memcontroller Default values */ + {0x0F007000, 0x00010001}, + {0x0F007004, 0x01000000}, + {0x0F007008, 0x01000001}, + {0x0F00700c, 0x00000000}, + {0x0F007010, 0x01000000}, + {0x0F007014, 0x01000100}, + {0x0F007018, 0x01000000}, + {0x0F00701c, 0x01020000}, + {0x0F007020, 0x04020107}, + {0x0F007024, 0x00000007}, + {0x0F007028, 0x02020201}, + {0x0F00702c, 0x0204040a}, + {0x0F007030, 0x04000000}, + {0x0F007034, 0x00000002}, + {0x0F007038, 0x1F060200}, + {0x0F00703C, 0x1C22221F}, + {0x0F007040, 0x8A006600}, + {0x0F007044, 0x221a0800}, + {0x0F007048, 0x02690204}, + {0x0F00704c, 0x00000000}, + {0x0F007050, 0x0000001c}, + {0x0F007054, 0x00000000}, + {0x0F007058, 0x00000000}, + {0x0F00705c, 0x00000000}, + {0x0F007060, 0x000A15D6}, + {0x0F007064, 0x0000000A}, + {0x0F007068, 0x00000000}, + {0x0F00706c, 0x00000001}, + {0x0F007070, 0x00004000}, + {0x0F007074, 0x00000000}, + {0x0F007078, 0x00000000}, + {0x0F00707C, 0x00000000}, + {0x0F007080, 0x00000000}, + {0x0F007084, 0x00000000}, + {0x0F007094, 0x00000104}, + /* Enable start bit within memory controller */ + {0x0F007018, 0x01010000} +}; +/* 100Mhz */ +#define T3_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 13 /* index for 0x0F007000 */ +static struct bcm_ddr_setting asT3_DDRSetting100MHz[] = { /* DPLL Clock Setting */ + {0x0F000800, 0x00007008}, + {0x0f000810, 0x00000F95}, + {0x0f000820, 0x07F13E3F}, + {0x0f000860, 0x00000000}, + {0x0f000880, 0x000003DD}, + /* Changed source for X-bar and MIPS clock to APLL */ + {0x0f000840, 0x0FFF1B00}, + {0x0f000870, 0x00000002}, + {0x0F00a044, 0x1fffffff}, + {0x0F00a040, 0x1f000000}, + {0x0F00a084, 0x1Cffffff}, + {0x0F00a080, 0x1C000000}, + {0x0F00a04C, 0x0000000C}, + /* Enable 2 ports within X-bar */ + {0x0F00A000, 0x00000016}, + /* Memcontroller Default values */ + {0x0F007000, 0x00010001}, + {0x0F007004, 0x01010100}, + {0x0F007008, 0x01000001}, + {0x0F00700c, 0x00000000}, + {0x0F007010, 0x01000000}, + {0x0F007014, 0x01000100}, + {0x0F007018, 0x01000000}, + {0x0F00701c, 0x01020001}, + {0x0F007020, 0x04020107}, + {0x0F007024, 0x00000007}, + {0x0F007028, 0x01020201}, + {0x0F00702c, 0x0204040A}, + {0x0F007030, 0x06000000}, + {0x0F007034, 0x00000004}, + {0x0F007038, 0x20080200}, + {0x0F00703C, 0x02030320}, + {0x0F007040, 0x6E7F1200}, + {0x0F007044, 0x01190A00}, + {0x0F007048, 0x06120305}, + {0x0F00704c, 0x00000000}, + {0x0F007050, 0x0000001C}, + {0x0F007054, 0x00000000}, + {0x0F007058, 0x00000000}, + {0x0F00705c, 0x00000000}, + {0x0F007060, 0x00082ED6}, + {0x0F007064, 0x0000000A}, + {0x0F007068, 0x00000000}, + {0x0F00706c, 0x00000001}, + {0x0F007070, 0x00005000}, + {0x0F007074, 0x00000000}, + {0x0F007078, 0x00000000}, + {0x0F00707C, 0x00000000}, + {0x0F007080, 0x00000000}, + {0x0F007084, 0x00000000}, + /* Enable BW improvement within memory controller */ + {0x0F007094, 0x00000104}, + /* Enable start bit within memory controller */ + {0x0F007018, 0x01010000} +}; -//Net T3B DDR Settings -//DDR INIT-133Mhz +/* Net T3B DDR Settings + * DDR INIT-133Mhz + */ static struct bcm_ddr_setting asDPLL_266MHZ[] = { - {0x0F000800,0x00007212}, - {0x0f000820,0x07F13FFF}, - {0x0f000810,0x00000F95}, - {0x0f000860,0x00000000}, - {0x0f000880,0x000003DD}, - // Changed source for X-bar and MIPS clock to APLL - {0x0f000840,0x0FFF1B00}, - {0x0f000870,0x00000002} - }; + {0x0F000800, 0x00007212}, + {0x0f000820, 0x07F13FFF}, + {0x0f000810, 0x00000F95}, + {0x0f000860, 0x00000000}, + {0x0f000880, 0x000003DD}, + /* Changed source for X-bar and MIPS clock to APLL */ + {0x0f000840, 0x0FFF1B00}, + {0x0f000870, 0x00000002} +}; -#define T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 11 //index for 0x0F007000 -static struct bcm_ddr_setting asT3B_DDRSetting133MHz[] = {// # DPLL Clock Setting - {0x0f000810,0x00000F95}, - {0x0f000810,0x00000F95}, - {0x0f000810,0x00000F95}, - {0x0f000820,0x07F13652}, - {0x0f000840,0x0FFF0800}, - // Changed source for X-bar and MIPS clock to APLL - {0x0f000880,0x000003DD}, - {0x0f000860,0x00000000}, - // Changed source for X-bar and MIPS clock to APLL - {0x0F00a044,0x1fffffff}, - {0x0F00a040,0x1f000000}, - {0x0F00a084,0x1Cffffff}, - {0x0F00a080,0x1C000000}, - //# Enable 2 ports within X-bar - {0x0F00A000,0x00000016}, - //Memcontroller Default values - {0x0F007000,0x00010001}, - {0x0F007004,0x01010100}, - {0x0F007008,0x01000001}, - {0x0F00700c,0x00000000}, - {0x0F007010,0x01000000}, - {0x0F007014,0x01000100}, - {0x0F007018,0x01000000}, - {0x0F00701c,0x01020001},// POP - 0x00020001 Normal 0x01020001 - {0x0F007020,0x04030107}, //Normal - 0x04030107 POP - 0x05030107 - {0x0F007024,0x02000007}, - {0x0F007028,0x02020202}, - {0x0F00702c,0x0206060a},//ROB- 0x0205050a,//0x0206060a - {0x0F007030,0x05000000}, - {0x0F007034,0x00000003}, - {0x0F007038,0x130a0200},//ROB - 0x110a0200,//0x180a0200,// 0x1f0a0200 - {0x0F00703C,0x02101012},//ROB - 0x02101010,//0x02101018}, - {0x0F007040,0x457D1200},//ROB - 0x45751200,//0x450f1200}, - {0x0F007044,0x11130d00},//ROB - 0x110a0d00//0x111f0d00 - {0x0F007048,0x040D0306}, - {0x0F00704c,0x00000000}, - {0x0F007050,0x0000001c}, - {0x0F007054,0x00000000}, - {0x0F007058,0x00000000}, - {0x0F00705c,0x00000000}, - {0x0F007060,0x0010246c}, - {0x0F007064,0x00000012}, - {0x0F007068,0x00000000}, - {0x0F00706c,0x00000001}, - {0x0F007070,0x00007000}, - {0x0F007074,0x00000000}, - {0x0F007078,0x00000000}, - {0x0F00707C,0x00000000}, - {0x0F007080,0x00000000}, - {0x0F007084,0x00000000}, - //# Enable BW improvement within memory controller - {0x0F007094,0x00000104}, - //# Enable start bit within memory controller - {0x0F007018,0x01010000}, - }; +#define T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 11 /* index for 0x0F007000 */ +static struct bcm_ddr_setting asT3B_DDRSetting133MHz[] = { /* DPLL Clock Setting */ + {0x0f000810, 0x00000F95}, + {0x0f000810, 0x00000F95}, + {0x0f000810, 0x00000F95}, + {0x0f000820, 0x07F13652}, + {0x0f000840, 0x0FFF0800}, + /* Changed source for X-bar and MIPS clock to APLL */ + {0x0f000880, 0x000003DD}, + {0x0f000860, 0x00000000}, + /* Changed source for X-bar and MIPS clock to APLL */ + {0x0F00a044, 0x1fffffff}, + {0x0F00a040, 0x1f000000}, + {0x0F00a084, 0x1Cffffff}, + {0x0F00a080, 0x1C000000}, + /* Enable 2 ports within X-bar */ + {0x0F00A000, 0x00000016}, + /* Memcontroller Default values */ + {0x0F007000, 0x00010001}, + {0x0F007004, 0x01010100}, + {0x0F007008, 0x01000001}, + {0x0F00700c, 0x00000000}, + {0x0F007010, 0x01000000}, + {0x0F007014, 0x01000100}, + {0x0F007018, 0x01000000}, + {0x0F00701c, 0x01020001}, + {0x0F007020, 0x04030107}, + {0x0F007024, 0x02000007}, + {0x0F007028, 0x02020202}, + {0x0F00702c, 0x0206060a}, + {0x0F007030, 0x05000000}, + {0x0F007034, 0x00000003}, + {0x0F007038, 0x130a0200}, + {0x0F00703C, 0x02101012}, + {0x0F007040, 0x457D1200}, + {0x0F007044, 0x11130d00}, + {0x0F007048, 0x040D0306}, + {0x0F00704c, 0x00000000}, + {0x0F007050, 0x0000001c}, + {0x0F007054, 0x00000000}, + {0x0F007058, 0x00000000}, + {0x0F00705c, 0x00000000}, + {0x0F007060, 0x0010246c}, + {0x0F007064, 0x00000012}, + {0x0F007068, 0x00000000}, + {0x0F00706c, 0x00000001}, + {0x0F007070, 0x00007000}, + {0x0F007074, 0x00000000}, + {0x0F007078, 0x00000000}, + {0x0F00707C, 0x00000000}, + {0x0F007080, 0x00000000}, + {0x0F007084, 0x00000000}, + /* Enable BW improvement within memory controller */ + {0x0F007094, 0x00000104}, + /* Enable start bit within memory controller */ + {0x0F007018, 0x01010000}, + }; -#define T3B_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 9 //index for 0x0F007000 -static struct bcm_ddr_setting asT3B_DDRSetting80MHz[] = {// # DPLL Clock Setting - {0x0f000810,0x00000F95}, - {0x0f000820,0x07F13FFF}, - {0x0f000840,0x0FFF1F00}, - {0x0f000880,0x000003DD}, - {0x0f000860,0x00000000}, +#define T3B_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 9 /* index for 0x0F007000 */ +static struct bcm_ddr_setting asT3B_DDRSetting80MHz[] = { /* DPLL Clock Setting */ + {0x0f000810, 0x00000F95}, + {0x0f000820, 0x07F13FFF}, + {0x0f000840, 0x0FFF1F00}, + {0x0f000880, 0x000003DD}, + {0x0f000860, 0x00000000}, - {0x0F00a044,0x1fffffff}, - {0x0F00a040,0x1f000000}, - {0x0F00a084,0x1Cffffff}, - {0x0F00a080,0x1C000000}, - {0x0F00a000,0x00000016}, - //Memcontroller Default values - {0x0F007000,0x00010001}, - {0x0F007004,0x01000000}, - {0x0F007008,0x01000001}, - {0x0F00700c,0x00000000}, - {0x0F007010,0x01000000}, - {0x0F007014,0x01000100}, - {0x0F007018,0x01000000}, - {0x0F00701c,0x01020000}, - {0x0F007020,0x04020107}, - {0x0F007024,0x00000007}, - {0x0F007028,0x02020201}, - {0x0F00702c,0x0204040a}, - {0x0F007030,0x04000000}, - {0x0F007034,0x02000002}, - {0x0F007038,0x1F060202}, - {0x0F00703C,0x1C22221F}, - {0x0F007040,0x8A006600}, - {0x0F007044,0x221a0800}, - {0x0F007048,0x02690204}, - {0x0F00704c,0x00000000}, - {0x0F007050,0x0100001c}, - {0x0F007054,0x00000000}, - {0x0F007058,0x00000000}, - {0x0F00705c,0x00000000}, - {0x0F007060,0x000A15D6}, - {0x0F007064,0x0000000A}, - {0x0F007068,0x00000000}, - {0x0F00706c,0x00000001}, - {0x0F007070,0x00004000}, - {0x0F007074,0x00000000}, - {0x0F007078,0x00000000}, - {0x0F00707C,0x00000000}, - {0x0F007080,0x00000000}, - {0x0F007084,0x00000000}, - {0x0F007094,0x00000104}, - //# Enable start bit within memory controller - {0x0F007018,0x01010000} - }; + {0x0F00a044, 0x1fffffff}, + {0x0F00a040, 0x1f000000}, + {0x0F00a084, 0x1Cffffff}, + {0x0F00a080, 0x1C000000}, + {0x0F00a000, 0x00000016}, + /* Memcontroller Default values */ + {0x0F007000, 0x00010001}, + {0x0F007004, 0x01000000}, + {0x0F007008, 0x01000001}, + {0x0F00700c, 0x00000000}, + {0x0F007010, 0x01000000}, + {0x0F007014, 0x01000100}, + {0x0F007018, 0x01000000}, + {0x0F00701c, 0x01020000}, + {0x0F007020, 0x04020107}, + {0x0F007024, 0x00000007}, + {0x0F007028, 0x02020201}, + {0x0F00702c, 0x0204040a}, + {0x0F007030, 0x04000000}, + {0x0F007034, 0x02000002}, + {0x0F007038, 0x1F060202}, + {0x0F00703C, 0x1C22221F}, + {0x0F007040, 0x8A006600}, + {0x0F007044, 0x221a0800}, + {0x0F007048, 0x02690204}, + {0x0F00704c, 0x00000000}, + {0x0F007050, 0x0100001c}, + {0x0F007054, 0x00000000}, + {0x0F007058, 0x00000000}, + {0x0F00705c, 0x00000000}, + {0x0F007060, 0x000A15D6}, + {0x0F007064, 0x0000000A}, + {0x0F007068, 0x00000000}, + {0x0F00706c, 0x00000001}, + {0x0F007070, 0x00004000}, + {0x0F007074, 0x00000000}, + {0x0F007078, 0x00000000}, + {0x0F00707C, 0x00000000}, + {0x0F007080, 0x00000000}, + {0x0F007084, 0x00000000}, + {0x0F007094, 0x00000104}, + /* Enable start bit within memory controller */ + {0x0F007018, 0x01010000} +}; -//100Mhz -#define T3B_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 9 //index for 0x0F007000 -static struct bcm_ddr_setting asT3B_DDRSetting100MHz[] = {// # DPLL Clock Setting - {0x0f000810,0x00000F95}, - {0x0f000820,0x07F1369B}, - {0x0f000840,0x0FFF0800}, - {0x0f000880,0x000003DD}, - {0x0f000860,0x00000000}, - {0x0F00a044,0x1fffffff}, - {0x0F00a040,0x1f000000}, - {0x0F00a084,0x1Cffffff}, - {0x0F00a080,0x1C000000}, - //# Enable 2 ports within X-bar - {0x0F00A000,0x00000016}, - //Memcontroller Default values - {0x0F007000,0x00010001}, - {0x0F007004,0x01010100}, - {0x0F007008,0x01000001}, - {0x0F00700c,0x00000000}, - {0x0F007010,0x01000000}, - {0x0F007014,0x01000100}, - {0x0F007018,0x01000000}, - {0x0F00701c,0x01020000}, // POP - 0x00020000 Normal 0x01020000 - {0x0F007020,0x04020107},//Normal - 0x04030107 POP - 0x05030107 - {0x0F007024,0x00000007}, - {0x0F007028,0x01020201}, - {0x0F00702c,0x0204040A}, - {0x0F007030,0x06000000}, - {0x0F007034,0x02000004}, - {0x0F007038,0x20080200}, - {0x0F00703C,0x02030320}, - {0x0F007040,0x6E7F1200}, - {0x0F007044,0x01190A00}, - {0x0F007048,0x06120305},//0x02690204 // 0x06120305 - {0x0F00704c,0x00000000}, - {0x0F007050,0x0100001C}, - {0x0F007054,0x00000000}, - {0x0F007058,0x00000000}, - {0x0F00705c,0x00000000}, - {0x0F007060,0x00082ED6}, - {0x0F007064,0x0000000A}, - {0x0F007068,0x00000000}, - {0x0F00706c,0x00000001}, - {0x0F007070,0x00005000}, - {0x0F007074,0x00000000}, - {0x0F007078,0x00000000}, - {0x0F00707C,0x00000000}, - {0x0F007080,0x00000000}, - {0x0F007084,0x00000000}, - //# Enable BW improvement within memory controller - {0x0F007094,0x00000104}, - //# Enable start bit within memory controller - {0x0F007018,0x01010000} - }; +/* 100Mhz */ +#define T3B_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 9 /* index for 0x0F007000 */ +static struct bcm_ddr_setting asT3B_DDRSetting100MHz[] = { /* DPLL Clock Setting */ + {0x0f000810, 0x00000F95}, + {0x0f000820, 0x07F1369B}, + {0x0f000840, 0x0FFF0800}, + {0x0f000880, 0x000003DD}, + {0x0f000860, 0x00000000}, + {0x0F00a044, 0x1fffffff}, + {0x0F00a040, 0x1f000000}, + {0x0F00a084, 0x1Cffffff}, + {0x0F00a080, 0x1C000000}, + /* Enable 2 ports within X-bar */ + {0x0F00A000, 0x00000016}, + /* Memcontroller Default values */ + {0x0F007000, 0x00010001}, + {0x0F007004, 0x01010100}, + {0x0F007008, 0x01000001}, + {0x0F00700c, 0x00000000}, + {0x0F007010, 0x01000000}, + {0x0F007014, 0x01000100}, + {0x0F007018, 0x01000000}, + {0x0F00701c, 0x01020000}, + {0x0F007020, 0x04020107}, + {0x0F007024, 0x00000007}, + {0x0F007028, 0x01020201}, + {0x0F00702c, 0x0204040A}, + {0x0F007030, 0x06000000}, + {0x0F007034, 0x02000004}, + {0x0F007038, 0x20080200}, + {0x0F00703C, 0x02030320}, + {0x0F007040, 0x6E7F1200}, + {0x0F007044, 0x01190A00}, + {0x0F007048, 0x06120305}, + {0x0F00704c, 0x00000000}, + {0x0F007050, 0x0100001C}, + {0x0F007054, 0x00000000}, + {0x0F007058, 0x00000000}, + {0x0F00705c, 0x00000000}, + {0x0F007060, 0x00082ED6}, + {0x0F007064, 0x0000000A}, + {0x0F007068, 0x00000000}, + {0x0F00706c, 0x00000001}, + {0x0F007070, 0x00005000}, + {0x0F007074, 0x00000000}, + {0x0F007078, 0x00000000}, + {0x0F00707C, 0x00000000}, + {0x0F007080, 0x00000000}, + {0x0F007084, 0x00000000}, + /* Enable BW improvement within memory controller */ + {0x0F007094, 0x00000104}, + /* Enable start bit within memory controller */ + {0x0F007018, 0x01010000} +}; -#define T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 9 //index for 0x0F007000 -static struct bcm_ddr_setting asT3LP_DDRSetting133MHz[]= {// # DPLL Clock Setting - {0x0f000820,0x03F1365B}, - {0x0f000810,0x00002F95}, - {0x0f000880,0x000003DD}, - // Changed source for X-bar and MIPS clock to APLL - {0x0f000840,0x0FFF0000}, - {0x0f000860,0x00000000}, - {0x0F00a044,0x1fffffff}, - {0x0F00a040,0x1f000000}, - {0x0F00a084,0x1Cffffff}, - {0x0F00a080,0x1C000000}, - {0x0F00A000,0x00000016}, - //Memcontroller Default values - {0x0F007000,0x00010001}, - {0x0F007004,0x01010100}, - {0x0F007008,0x01000001}, - {0x0F00700c,0x00000000}, - {0x0F007010,0x01000000}, - {0x0F007014,0x01000100}, - {0x0F007018,0x01000000}, - {0x0F00701c,0x01020001},// POP - 0x00020001 Normal 0x01020001 - {0x0F007020,0x04030107}, //Normal - 0x04030107 POP - 0x05030107 - {0x0F007024,0x02000007}, - {0x0F007028,0x02020200}, - {0x0F00702c,0x0206060a},//ROB- 0x0205050a,//0x0206060a - {0x0F007030,0x05000000}, - {0x0F007034,0x00000003}, - {0x0F007038,0x200a0200},//ROB - 0x110a0200,//0x180a0200,// 0x1f0a0200 - {0x0F00703C,0x02101020},//ROB - 0x02101010,//0x02101018, - {0x0F007040,0x45711200},//ROB - 0x45751200,//0x450f1200, - {0x0F007044,0x110D0D00},//ROB - 0x110a0d00//0x111f0d00 - {0x0F007048,0x04080306}, - {0x0F00704c,0x00000000}, - {0x0F007050,0x0100001c}, - {0x0F007054,0x00000000}, - {0x0F007058,0x00000000}, - {0x0F00705c,0x00000000}, - {0x0F007060,0x0010245F}, - {0x0F007064,0x00000010}, - {0x0F007068,0x00000000}, - {0x0F00706c,0x00000001}, - {0x0F007070,0x00007000}, - {0x0F007074,0x00000000}, - {0x0F007078,0x00000000}, - {0x0F00707C,0x00000000}, - {0x0F007080,0x00000000}, - {0x0F007084,0x00000000}, - {0x0F007088,0x01000001}, - {0x0F00708c,0x00000101}, - {0x0F007090,0x00000000}, - //# Enable BW improvement within memory controller - {0x0F007094,0x00040000}, - {0x0F007098,0x00000000}, - {0x0F0070c8,0x00000104}, - //# Enable 2 ports within X-bar - //# Enable start bit within memory controller - {0x0F007018,0x01010000} +#define T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 9 /* index for 0x0F007000 */ +static struct bcm_ddr_setting asT3LP_DDRSetting133MHz[] = { /* DPLL Clock Setting */ + {0x0f000820, 0x03F1365B}, + {0x0f000810, 0x00002F95}, + {0x0f000880, 0x000003DD}, + /* Changed source for X-bar and MIPS clock to APLL */ + {0x0f000840, 0x0FFF0000}, + {0x0f000860, 0x00000000}, + {0x0F00a044, 0x1fffffff}, + {0x0F00a040, 0x1f000000}, + {0x0F00a084, 0x1Cffffff}, + {0x0F00a080, 0x1C000000}, + {0x0F00A000, 0x00000016}, + /* Memcontroller Default values */ + {0x0F007000, 0x00010001}, + {0x0F007004, 0x01010100}, + {0x0F007008, 0x01000001}, + {0x0F00700c, 0x00000000}, + {0x0F007010, 0x01000000}, + {0x0F007014, 0x01000100}, + {0x0F007018, 0x01000000}, + {0x0F00701c, 0x01020001}, + {0x0F007020, 0x04030107}, + {0x0F007024, 0x02000007}, + {0x0F007028, 0x02020200}, + {0x0F00702c, 0x0206060a}, + {0x0F007030, 0x05000000}, + {0x0F007034, 0x00000003}, + {0x0F007038, 0x200a0200}, + {0x0F00703C, 0x02101020}, + {0x0F007040, 0x45711200}, + {0x0F007044, 0x110D0D00}, + {0x0F007048, 0x04080306}, + {0x0F00704c, 0x00000000}, + {0x0F007050, 0x0100001c}, + {0x0F007054, 0x00000000}, + {0x0F007058, 0x00000000}, + {0x0F00705c, 0x00000000}, + {0x0F007060, 0x0010245F}, + {0x0F007064, 0x00000010}, + {0x0F007068, 0x00000000}, + {0x0F00706c, 0x00000001}, + {0x0F007070, 0x00007000}, + {0x0F007074, 0x00000000}, + {0x0F007078, 0x00000000}, + {0x0F00707C, 0x00000000}, + {0x0F007080, 0x00000000}, + {0x0F007084, 0x00000000}, + {0x0F007088, 0x01000001}, + {0x0F00708c, 0x00000101}, + {0x0F007090, 0x00000000}, + /* Enable BW improvement within memory controller */ + {0x0F007094, 0x00040000}, + {0x0F007098, 0x00000000}, + {0x0F0070c8, 0x00000104}, + /* Enable 2 ports within X-bar */ + /* Enable start bit within memory controller */ + {0x0F007018, 0x01010000} }; -#define T3LP_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 11 //index for 0x0F007000 -static struct bcm_ddr_setting asT3LP_DDRSetting100MHz[]= {// # DPLL Clock Setting - {0x0f000810,0x00002F95}, - {0x0f000820,0x03F1369B}, - {0x0f000840,0x0fff0000}, - {0x0f000860,0x00000000}, - {0x0f000880,0x000003DD}, - // Changed source for X-bar and MIPS clock to APLL - {0x0f000840,0x0FFF0000}, - {0x0F00a044,0x1fffffff}, - {0x0F00a040,0x1f000000}, - {0x0F00a084,0x1Cffffff}, - {0x0F00a080,0x1C000000}, - //Memcontroller Default values - {0x0F007000,0x00010001}, - {0x0F007004,0x01010100}, - {0x0F007008,0x01000001}, - {0x0F00700c,0x00000000}, - {0x0F007010,0x01000000}, - {0x0F007014,0x01000100}, - {0x0F007018,0x01000000}, - {0x0F00701c,0x01020000},// POP - 0x00020001 Normal 0x01020001 - {0x0F007020,0x04020107}, //Normal - 0x04030107 POP - 0x05030107 - {0x0F007024,0x00000007}, - {0x0F007028,0x01020200}, - {0x0F00702c,0x0204040a},//ROB- 0x0205050a,//0x0206060a - {0x0F007030,0x06000000}, - {0x0F007034,0x00000004}, - {0x0F007038,0x1F080200},//ROB - 0x110a0200,//0x180a0200,// 0x1f0a0200 - {0x0F00703C,0x0203031F},//ROB - 0x02101010,//0x02101018, - {0x0F007040,0x6e001200},//ROB - 0x45751200,//0x450f1200, - {0x0F007044,0x011a0a00},//ROB - 0x110a0d00//0x111f0d00 - {0x0F007048,0x03000305}, - {0x0F00704c,0x00000000}, - {0x0F007050,0x0100001c}, - {0x0F007054,0x00000000}, - {0x0F007058,0x00000000}, - {0x0F00705c,0x00000000}, - {0x0F007060,0x00082ED6}, - {0x0F007064,0x0000000A}, - {0x0F007068,0x00000000}, - {0x0F00706c,0x00000001}, - {0x0F007070,0x00005000}, - {0x0F007074,0x00000000}, - {0x0F007078,0x00000000}, - {0x0F00707C,0x00000000}, - {0x0F007080,0x00000000}, - {0x0F007084,0x00000000}, - {0x0F007088,0x01000001}, - {0x0F00708c,0x00000101}, - {0x0F007090,0x00000000}, - {0x0F007094,0x00010000}, - {0x0F007098,0x00000000}, - {0x0F0070C8,0x00000104}, - //# Enable 2 ports within X-bar - {0x0F00A000,0x00000016}, - //# Enable start bit within memory controller - {0x0F007018,0x01010000} +#define T3LP_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 11 /* index for 0x0F007000 */ +static struct bcm_ddr_setting asT3LP_DDRSetting100MHz[] = { /* DPLL Clock Setting */ + {0x0f000810, 0x00002F95}, + {0x0f000820, 0x03F1369B}, + {0x0f000840, 0x0fff0000}, + {0x0f000860, 0x00000000}, + {0x0f000880, 0x000003DD}, + /* Changed source for X-bar and MIPS clock to APLL */ + {0x0f000840, 0x0FFF0000}, + {0x0F00a044, 0x1fffffff}, + {0x0F00a040, 0x1f000000}, + {0x0F00a084, 0x1Cffffff}, + {0x0F00a080, 0x1C000000}, + /* Memcontroller Default values */ + {0x0F007000, 0x00010001}, + {0x0F007004, 0x01010100}, + {0x0F007008, 0x01000001}, + {0x0F00700c, 0x00000000}, + {0x0F007010, 0x01000000}, + {0x0F007014, 0x01000100}, + {0x0F007018, 0x01000000}, + {0x0F00701c, 0x01020000}, + {0x0F007020, 0x04020107}, + {0x0F007024, 0x00000007}, + {0x0F007028, 0x01020200}, + {0x0F00702c, 0x0204040a}, + {0x0F007030, 0x06000000}, + {0x0F007034, 0x00000004}, + {0x0F007038, 0x1F080200}, + {0x0F00703C, 0x0203031F}, + {0x0F007040, 0x6e001200}, + {0x0F007044, 0x011a0a00}, + {0x0F007048, 0x03000305}, + {0x0F00704c, 0x00000000}, + {0x0F007050, 0x0100001c}, + {0x0F007054, 0x00000000}, + {0x0F007058, 0x00000000}, + {0x0F00705c, 0x00000000}, + {0x0F007060, 0x00082ED6}, + {0x0F007064, 0x0000000A}, + {0x0F007068, 0x00000000}, + {0x0F00706c, 0x00000001}, + {0x0F007070, 0x00005000}, + {0x0F007074, 0x00000000}, + {0x0F007078, 0x00000000}, + {0x0F00707C, 0x00000000}, + {0x0F007080, 0x00000000}, + {0x0F007084, 0x00000000}, + {0x0F007088, 0x01000001}, + {0x0F00708c, 0x00000101}, + {0x0F007090, 0x00000000}, + {0x0F007094, 0x00010000}, + {0x0F007098, 0x00000000}, + {0x0F0070C8, 0x00000104}, + /* Enable 2 ports within X-bar */ + {0x0F00A000, 0x00000016}, + /* Enable start bit within memory controller */ + {0x0F007018, 0x01010000} }; -#define T3LP_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 9 //index for 0x0F007000 -static struct bcm_ddr_setting asT3LP_DDRSetting80MHz[]= {// # DPLL Clock Setting - {0x0f000820,0x07F13FFF}, - {0x0f000810,0x00002F95}, - {0x0f000860,0x00000000}, - {0x0f000880,0x000003DD}, - {0x0f000840,0x0FFF1F00}, - {0x0F00a044,0x1fffffff}, - {0x0F00a040,0x1f000000}, - {0x0F00a084,0x1Cffffff}, - {0x0F00a080,0x1C000000}, - {0x0F00A000,0x00000016}, - {0x0f007000,0x00010001}, - {0x0f007004,0x01000000}, - {0x0f007008,0x01000001}, - {0x0f00700c,0x00000000}, - {0x0f007010,0x01000000}, - {0x0f007014,0x01000100}, - {0x0f007018,0x01000000}, - {0x0f00701c,0x01020000}, - {0x0f007020,0x04020107}, - {0x0f007024,0x00000007}, - {0x0f007028,0x02020200}, - {0x0f00702c,0x0204040a}, - {0x0f007030,0x04000000}, - {0x0f007034,0x00000002}, - {0x0f007038,0x1d060200}, - {0x0f00703c,0x1c22221d}, - {0x0f007040,0x8A116600}, - {0x0f007044,0x222d0800}, - {0x0f007048,0x02690204}, - {0x0f00704c,0x00000000}, - {0x0f007050,0x0100001c}, - {0x0f007054,0x00000000}, - {0x0f007058,0x00000000}, - {0x0f00705c,0x00000000}, - {0x0f007060,0x000A15D6}, - {0x0f007064,0x0000000A}, - {0x0f007068,0x00000000}, - {0x0f00706c,0x00000001}, - {0x0f007070,0x00004000}, - {0x0f007074,0x00000000}, - {0x0f007078,0x00000000}, - {0x0f00707c,0x00000000}, - {0x0f007080,0x00000000}, - {0x0f007084,0x00000000}, - {0x0f007088,0x01000001}, - {0x0f00708c,0x00000101}, - {0x0f007090,0x00000000}, - {0x0f007094,0x00010000}, - {0x0f007098,0x00000000}, - {0x0F0070C8,0x00000104}, - {0x0F007018,0x01010000} +#define T3LP_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 9 /* index for 0x0F007000 */ +static struct bcm_ddr_setting asT3LP_DDRSetting80MHz[] = { /* DPLL Clock Setting */ + {0x0f000820, 0x07F13FFF}, + {0x0f000810, 0x00002F95}, + {0x0f000860, 0x00000000}, + {0x0f000880, 0x000003DD}, + {0x0f000840, 0x0FFF1F00}, + {0x0F00a044, 0x1fffffff}, + {0x0F00a040, 0x1f000000}, + {0x0F00a084, 0x1Cffffff}, + {0x0F00a080, 0x1C000000}, + {0x0F00A000, 0x00000016}, + {0x0f007000, 0x00010001}, + {0x0f007004, 0x01000000}, + {0x0f007008, 0x01000001}, + {0x0f00700c, 0x00000000}, + {0x0f007010, 0x01000000}, + {0x0f007014, 0x01000100}, + {0x0f007018, 0x01000000}, + {0x0f00701c, 0x01020000}, + {0x0f007020, 0x04020107}, + {0x0f007024, 0x00000007}, + {0x0f007028, 0x02020200}, + {0x0f00702c, 0x0204040a}, + {0x0f007030, 0x04000000}, + {0x0f007034, 0x00000002}, + {0x0f007038, 0x1d060200}, + {0x0f00703c, 0x1c22221d}, + {0x0f007040, 0x8A116600}, + {0x0f007044, 0x222d0800}, + {0x0f007048, 0x02690204}, + {0x0f00704c, 0x00000000}, + {0x0f007050, 0x0100001c}, + {0x0f007054, 0x00000000}, + {0x0f007058, 0x00000000}, + {0x0f00705c, 0x00000000}, + {0x0f007060, 0x000A15D6}, + {0x0f007064, 0x0000000A}, + {0x0f007068, 0x00000000}, + {0x0f00706c, 0x00000001}, + {0x0f007070, 0x00004000}, + {0x0f007074, 0x00000000}, + {0x0f007078, 0x00000000}, + {0x0f00707c, 0x00000000}, + {0x0f007080, 0x00000000}, + {0x0f007084, 0x00000000}, + {0x0f007088, 0x01000001}, + {0x0f00708c, 0x00000101}, + {0x0f007090, 0x00000000}, + {0x0f007094, 0x00010000}, + {0x0f007098, 0x00000000}, + {0x0F0070C8, 0x00000104}, + {0x0F007018, 0x01010000} }; -///T3 LP-B (UMA-B) +/* T3 LP-B (UMA-B) */ -#define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_160MHZ 7 //index for 0x0F007000 -static struct bcm_ddr_setting asT3LPB_DDRSetting160MHz[]= {// # DPLL Clock Setting - - {0x0f000820,0x03F137DB}, - {0x0f000810,0x01842795}, - {0x0f000860,0x00000000}, - {0x0f000880,0x000003DD}, - {0x0f000840,0x0FFF0400}, - {0x0F00a044,0x1fffffff}, - {0x0F00a040,0x1f000000}, - {0x0f003050,0x00000021},//this is flash/eeprom clock divisor which set the flash clock to 20 MHz - {0x0F00a084,0x1Cffffff},//Now dump from her in internal memory - {0x0F00a080,0x1C000000}, - {0x0F00A000,0x00000016}, - {0x0f007000,0x00010001}, - {0x0f007004,0x01000001}, - {0x0f007008,0x01000101}, - {0x0f00700c,0x00000000}, - {0x0f007010,0x01000100}, - {0x0f007014,0x01000100}, - {0x0f007018,0x01000000}, - {0x0f00701c,0x01020000}, - {0x0f007020,0x04030107}, - {0x0f007024,0x02000007}, - {0x0f007028,0x02020200}, - {0x0f00702c,0x0206060a}, - {0x0f007030,0x050d0d00}, - {0x0f007034,0x00000003}, - {0x0f007038,0x170a0200}, - {0x0f00703c,0x02101012}, - {0x0f007040,0x45161200}, - {0x0f007044,0x11250c00}, - {0x0f007048,0x04da0307}, - {0x0f00704c,0x00000000}, - {0x0f007050,0x0000001c}, - {0x0f007054,0x00000000}, - {0x0f007058,0x00000000}, - {0x0f00705c,0x00000000}, - {0x0f007060,0x00142bb6}, - {0x0f007064,0x20430014}, - {0x0f007068,0x00000000}, - {0x0f00706c,0x00000001}, - {0x0f007070,0x00009000}, - {0x0f007074,0x00000000}, - {0x0f007078,0x00000000}, - {0x0f00707c,0x00000000}, - {0x0f007080,0x00000000}, - {0x0f007084,0x00000000}, - {0x0f007088,0x01000001}, - {0x0f00708c,0x00000101}, - {0x0f007090,0x00000000}, - {0x0f007094,0x00040000}, - {0x0f007098,0x00000000}, - {0x0F0070C8,0x00000104}, - {0x0F007018,0x01010000} +#define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_160MHZ 7 /* index for 0x0F007000 */ +static struct bcm_ddr_setting asT3LPB_DDRSetting160MHz[] = { /* DPLL Clock Setting */ + {0x0f000820, 0x03F137DB}, + {0x0f000810, 0x01842795}, + {0x0f000860, 0x00000000}, + {0x0f000880, 0x000003DD}, + {0x0f000840, 0x0FFF0400}, + {0x0F00a044, 0x1fffffff}, + {0x0F00a040, 0x1f000000}, + {0x0f003050, 0x00000021}, /* this is flash/eeprom clock divisor which set the flash clock to 20 MHz */ + {0x0F00a084, 0x1Cffffff}, /* Now dump from her in internal memory */ + {0x0F00a080, 0x1C000000}, + {0x0F00A000, 0x00000016}, + {0x0f007000, 0x00010001}, + {0x0f007004, 0x01000001}, + {0x0f007008, 0x01000101}, + {0x0f00700c, 0x00000000}, + {0x0f007010, 0x01000100}, + {0x0f007014, 0x01000100}, + {0x0f007018, 0x01000000}, + {0x0f00701c, 0x01020000}, + {0x0f007020, 0x04030107}, + {0x0f007024, 0x02000007}, + {0x0f007028, 0x02020200}, + {0x0f00702c, 0x0206060a}, + {0x0f007030, 0x050d0d00}, + {0x0f007034, 0x00000003}, + {0x0f007038, 0x170a0200}, + {0x0f00703c, 0x02101012}, + {0x0f007040, 0x45161200}, + {0x0f007044, 0x11250c00}, + {0x0f007048, 0x04da0307}, + {0x0f00704c, 0x00000000}, + {0x0f007050, 0x0000001c}, + {0x0f007054, 0x00000000}, + {0x0f007058, 0x00000000}, + {0x0f00705c, 0x00000000}, + {0x0f007060, 0x00142bb6}, + {0x0f007064, 0x20430014}, + {0x0f007068, 0x00000000}, + {0x0f00706c, 0x00000001}, + {0x0f007070, 0x00009000}, + {0x0f007074, 0x00000000}, + {0x0f007078, 0x00000000}, + {0x0f00707c, 0x00000000}, + {0x0f007080, 0x00000000}, + {0x0f007084, 0x00000000}, + {0x0f007088, 0x01000001}, + {0x0f00708c, 0x00000101}, + {0x0f007090, 0x00000000}, + {0x0f007094, 0x00040000}, + {0x0f007098, 0x00000000}, + {0x0F0070C8, 0x00000104}, + {0x0F007018, 0x01010000} }; -#define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 7 //index for 0x0F007000 -static struct bcm_ddr_setting asT3LPB_DDRSetting133MHz[]= {// # DPLL Clock Setting - {0x0f000820,0x03F1365B}, - {0x0f000810,0x00002F95}, - {0x0f000880,0x000003DD}, - // Changed source for X-bar and MIPS clock to APLL - {0x0f000840,0x0FFF0000}, - {0x0f000860,0x00000000}, - {0x0F00a044,0x1fffffff}, - {0x0F00a040,0x1f000000}, - {0x0f003050,0x00000021},//flash/eeprom clock divisor which set the flash clock to 20 MHz - {0x0F00a084,0x1Cffffff},//dump from here in internal memory - {0x0F00a080,0x1C000000}, - {0x0F00A000,0x00000016}, - //Memcontroller Default values - {0x0F007000,0x00010001}, - {0x0F007004,0x01010100}, - {0x0F007008,0x01000001}, - {0x0F00700c,0x00000000}, - {0x0F007010,0x01000000}, - {0x0F007014,0x01000100}, - {0x0F007018,0x01000000}, - {0x0F00701c,0x01020001},// POP - 0x00020001 Normal 0x01020001 - {0x0F007020,0x04030107}, //Normal - 0x04030107 POP - 0x05030107 - {0x0F007024,0x02000007}, - {0x0F007028,0x02020200}, - {0x0F00702c,0x0206060a},//ROB- 0x0205050a,//0x0206060a - {0x0F007030,0x05000000}, - {0x0F007034,0x00000003}, - {0x0F007038,0x190a0200},//ROB - 0x110a0200,//0x180a0200,// 0x1f0a0200 - {0x0F00703C,0x02101017},//ROB - 0x02101010,//0x02101018, - {0x0F007040,0x45171200},//ROB - 0x45751200,//0x450f1200, - {0x0F007044,0x11290D00},//ROB - 0x110a0d00//0x111f0d00 - {0x0F007048,0x04080306}, - {0x0F00704c,0x00000000}, - {0x0F007050,0x0100001c}, - {0x0F007054,0x00000000}, - {0x0F007058,0x00000000}, - {0x0F00705c,0x00000000}, - {0x0F007060,0x0010245F}, - {0x0F007064,0x00000010}, - {0x0F007068,0x00000000}, - {0x0F00706c,0x00000001}, - {0x0F007070,0x00007000}, - {0x0F007074,0x00000000}, - {0x0F007078,0x00000000}, - {0x0F00707C,0x00000000}, - {0x0F007080,0x00000000}, - {0x0F007084,0x00000000}, - {0x0F007088,0x01000001}, - {0x0F00708c,0x00000101}, - {0x0F007090,0x00000000}, - //# Enable BW improvement within memory controller - {0x0F007094,0x00040000}, - {0x0F007098,0x00000000}, - {0x0F0070c8,0x00000104}, - //# Enable 2 ports within X-bar - //# Enable start bit within memory controller - {0x0F007018,0x01010000} +#define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 7 /* index for 0x0F007000 */ +static struct bcm_ddr_setting asT3LPB_DDRSetting133MHz[] = { /* DPLL Clock Setting */ + {0x0f000820, 0x03F1365B}, + {0x0f000810, 0x00002F95}, + {0x0f000880, 0x000003DD}, + /* Changed source for X-bar and MIPS clock to APLL */ + {0x0f000840, 0x0FFF0000}, + {0x0f000860, 0x00000000}, + {0x0F00a044, 0x1fffffff}, + {0x0F00a040, 0x1f000000}, + {0x0f003050, 0x00000021}, /* flash/eeprom clock divisor which set the flash clock to 20 MHz */ + {0x0F00a084, 0x1Cffffff}, /* dump from here in internal memory */ + {0x0F00a080, 0x1C000000}, + {0x0F00A000, 0x00000016}, + /* Memcontroller Default values */ + {0x0F007000, 0x00010001}, + {0x0F007004, 0x01010100}, + {0x0F007008, 0x01000001}, + {0x0F00700c, 0x00000000}, + {0x0F007010, 0x01000000}, + {0x0F007014, 0x01000100}, + {0x0F007018, 0x01000000}, + {0x0F00701c, 0x01020001}, + {0x0F007020, 0x04030107}, + {0x0F007024, 0x02000007}, + {0x0F007028, 0x02020200}, + {0x0F00702c, 0x0206060a}, + {0x0F007030, 0x05000000}, + {0x0F007034, 0x00000003}, + {0x0F007038, 0x190a0200}, + {0x0F00703C, 0x02101017}, + {0x0F007040, 0x45171200}, + {0x0F007044, 0x11290D00}, + {0x0F007048, 0x04080306}, + {0x0F00704c, 0x00000000}, + {0x0F007050, 0x0100001c}, + {0x0F007054, 0x00000000}, + {0x0F007058, 0x00000000}, + {0x0F00705c, 0x00000000}, + {0x0F007060, 0x0010245F}, + {0x0F007064, 0x00000010}, + {0x0F007068, 0x00000000}, + {0x0F00706c, 0x00000001}, + {0x0F007070, 0x00007000}, + {0x0F007074, 0x00000000}, + {0x0F007078, 0x00000000}, + {0x0F00707C, 0x00000000}, + {0x0F007080, 0x00000000}, + {0x0F007084, 0x00000000}, + {0x0F007088, 0x01000001}, + {0x0F00708c, 0x00000101}, + {0x0F007090, 0x00000000}, + /* Enable BW improvement within memory controller */ + {0x0F007094, 0x00040000}, + {0x0F007098, 0x00000000}, + {0x0F0070c8, 0x00000104}, + /* Enable 2 ports within X-bar */ + /* Enable start bit within memory controller */ + {0x0F007018, 0x01010000} }; -#define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 8 //index for 0x0F007000 -static struct bcm_ddr_setting asT3LPB_DDRSetting100MHz[]= {// # DPLL Clock Setting - {0x0f000810,0x00002F95}, - {0x0f000820,0x03F1369B}, - {0x0f000840,0x0fff0000}, - {0x0f000860,0x00000000}, - {0x0f000880,0x000003DD}, - // Changed source for X-bar and MIPS clock to APLL - {0x0f000840,0x0FFF0000}, - {0x0F00a044,0x1fffffff}, - {0x0F00a040,0x1f000000}, - {0x0f003050,0x00000021},//flash/eeprom clock divisor which set the flash clock to 20 MHz - {0x0F00a084,0x1Cffffff}, //dump from here in internal memory - {0x0F00a080,0x1C000000}, - //Memcontroller Default values - {0x0F007000,0x00010001}, - {0x0F007004,0x01010100}, - {0x0F007008,0x01000001}, - {0x0F00700c,0x00000000}, - {0x0F007010,0x01000000}, - {0x0F007014,0x01000100}, - {0x0F007018,0x01000000}, - {0x0F00701c,0x01020000},// POP - 0x00020001 Normal 0x01020001 - {0x0F007020,0x04020107}, //Normal - 0x04030107 POP - 0x05030107 - {0x0F007024,0x00000007}, - {0x0F007028,0x01020200}, - {0x0F00702c,0x0204040a},//ROB- 0x0205050a,//0x0206060a - {0x0F007030,0x06000000}, - {0x0F007034,0x00000004}, - {0x0F007038,0x1F080200},//ROB - 0x110a0200,//0x180a0200,// 0x1f0a0200 - {0x0F00703C,0x0203031F},//ROB - 0x02101010,//0x02101018, - {0x0F007040,0x6e001200},//ROB - 0x45751200,//0x450f1200, - {0x0F007044,0x011a0a00},//ROB - 0x110a0d00//0x111f0d00 - {0x0F007048,0x03000305}, - {0x0F00704c,0x00000000}, - {0x0F007050,0x0100001c}, - {0x0F007054,0x00000000}, - {0x0F007058,0x00000000}, - {0x0F00705c,0x00000000}, - {0x0F007060,0x00082ED6}, - {0x0F007064,0x0000000A}, - {0x0F007068,0x00000000}, - {0x0F00706c,0x00000001}, - {0x0F007070,0x00005000}, - {0x0F007074,0x00000000}, - {0x0F007078,0x00000000}, - {0x0F00707C,0x00000000}, - {0x0F007080,0x00000000}, - {0x0F007084,0x00000000}, - {0x0F007088,0x01000001}, - {0x0F00708c,0x00000101}, - {0x0F007090,0x00000000}, - {0x0F007094,0x00010000}, - {0x0F007098,0x00000000}, - {0x0F0070C8,0x00000104}, - //# Enable 2 ports within X-bar - {0x0F00A000,0x00000016}, - //# Enable start bit within memory controller - {0x0F007018,0x01010000} +#define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 8 /* index for 0x0F007000 */ +static struct bcm_ddr_setting asT3LPB_DDRSetting100MHz[] = { /* DPLL Clock Setting */ + {0x0f000810, 0x00002F95}, + {0x0f000820, 0x03F1369B}, + {0x0f000840, 0x0fff0000}, + {0x0f000860, 0x00000000}, + {0x0f000880, 0x000003DD}, + /* Changed source for X-bar and MIPS clock to APLL */ + {0x0f000840, 0x0FFF0000}, + {0x0F00a044, 0x1fffffff}, + {0x0F00a040, 0x1f000000}, + {0x0f003050, 0x00000021}, /* flash/eeprom clock divisor which set the flash clock to 20 MHz */ + {0x0F00a084, 0x1Cffffff}, /* dump from here in internal memory */ + {0x0F00a080, 0x1C000000}, + /* Memcontroller Default values */ + {0x0F007000, 0x00010001}, + {0x0F007004, 0x01010100}, + {0x0F007008, 0x01000001}, + {0x0F00700c, 0x00000000}, + {0x0F007010, 0x01000000}, + {0x0F007014, 0x01000100}, + {0x0F007018, 0x01000000}, + {0x0F00701c, 0x01020000}, + {0x0F007020, 0x04020107}, + {0x0F007024, 0x00000007}, + {0x0F007028, 0x01020200}, + {0x0F00702c, 0x0204040a}, + {0x0F007030, 0x06000000}, + {0x0F007034, 0x00000004}, + {0x0F007038, 0x1F080200}, + {0x0F00703C, 0x0203031F}, + {0x0F007040, 0x6e001200}, + {0x0F007044, 0x011a0a00}, + {0x0F007048, 0x03000305}, + {0x0F00704c, 0x00000000}, + {0x0F007050, 0x0100001c}, + {0x0F007054, 0x00000000}, + {0x0F007058, 0x00000000}, + {0x0F00705c, 0x00000000}, + {0x0F007060, 0x00082ED6}, + {0x0F007064, 0x0000000A}, + {0x0F007068, 0x00000000}, + {0x0F00706c, 0x00000001}, + {0x0F007070, 0x00005000}, + {0x0F007074, 0x00000000}, + {0x0F007078, 0x00000000}, + {0x0F00707C, 0x00000000}, + {0x0F007080, 0x00000000}, + {0x0F007084, 0x00000000}, + {0x0F007088, 0x01000001}, + {0x0F00708c, 0x00000101}, + {0x0F007090, 0x00000000}, + {0x0F007094, 0x00010000}, + {0x0F007098, 0x00000000}, + {0x0F0070C8, 0x00000104}, + /* Enable 2 ports within X-bar */ + {0x0F00A000, 0x00000016}, + /* Enable start bit within memory controller */ + {0x0F007018, 0x01010000} }; -#define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 7 //index for 0x0F007000 -static struct bcm_ddr_setting asT3LPB_DDRSetting80MHz[]= {// # DPLL Clock Setting - {0x0f000820,0x07F13FFF}, - {0x0f000810,0x00002F95}, - {0x0f000860,0x00000000}, - {0x0f000880,0x000003DD}, - {0x0f000840,0x0FFF1F00}, - {0x0F00a044,0x1fffffff}, - {0x0F00a040,0x1f000000}, - {0x0f003050,0x00000021},//flash/eeprom clock divisor which set the flash clock to 20 MHz - {0x0F00a084,0x1Cffffff},// dump from here in internal memory - {0x0F00a080,0x1C000000}, - {0x0F00A000,0x00000016}, - {0x0f007000,0x00010001}, - {0x0f007004,0x01000000}, - {0x0f007008,0x01000001}, - {0x0f00700c,0x00000000}, - {0x0f007010,0x01000000}, - {0x0f007014,0x01000100}, - {0x0f007018,0x01000000}, - {0x0f00701c,0x01020000}, - {0x0f007020,0x04020107}, - {0x0f007024,0x00000007}, - {0x0f007028,0x02020200}, - {0x0f00702c,0x0204040a}, - {0x0f007030,0x04000000}, - {0x0f007034,0x00000002}, - {0x0f007038,0x1d060200}, - {0x0f00703c,0x1c22221d}, - {0x0f007040,0x8A116600}, - {0x0f007044,0x222d0800}, - {0x0f007048,0x02690204}, - {0x0f00704c,0x00000000}, - {0x0f007050,0x0100001c}, - {0x0f007054,0x00000000}, - {0x0f007058,0x00000000}, - {0x0f00705c,0x00000000}, - {0x0f007060,0x000A15D6}, - {0x0f007064,0x0000000A}, - {0x0f007068,0x00000000}, - {0x0f00706c,0x00000001}, - {0x0f007070,0x00004000}, - {0x0f007074,0x00000000}, - {0x0f007078,0x00000000}, - {0x0f00707c,0x00000000}, - {0x0f007080,0x00000000}, - {0x0f007084,0x00000000}, - {0x0f007088,0x01000001}, - {0x0f00708c,0x00000101}, - {0x0f007090,0x00000000}, - {0x0f007094,0x00010000}, - {0x0f007098,0x00000000}, - {0x0F0070C8,0x00000104}, - {0x0F007018,0x01010000} +#define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 7 /* index for 0x0F007000 */ +static struct bcm_ddr_setting asT3LPB_DDRSetting80MHz[] = { /* DPLL Clock Setting */ + {0x0f000820, 0x07F13FFF}, + {0x0f000810, 0x00002F95}, + {0x0f000860, 0x00000000}, + {0x0f000880, 0x000003DD}, + {0x0f000840, 0x0FFF1F00}, + {0x0F00a044, 0x1fffffff}, + {0x0F00a040, 0x1f000000}, + {0x0f003050, 0x00000021}, /* flash/eeprom clock divisor which set the flash clock to 20 MHz */ + {0x0F00a084, 0x1Cffffff}, /* dump from here in internal memory */ + {0x0F00a080, 0x1C000000}, + {0x0F00A000, 0x00000016}, + {0x0f007000, 0x00010001}, + {0x0f007004, 0x01000000}, + {0x0f007008, 0x01000001}, + {0x0f00700c, 0x00000000}, + {0x0f007010, 0x01000000}, + {0x0f007014, 0x01000100}, + {0x0f007018, 0x01000000}, + {0x0f00701c, 0x01020000}, + {0x0f007020, 0x04020107}, + {0x0f007024, 0x00000007}, + {0x0f007028, 0x02020200}, + {0x0f00702c, 0x0204040a}, + {0x0f007030, 0x04000000}, + {0x0f007034, 0x00000002}, + {0x0f007038, 0x1d060200}, + {0x0f00703c, 0x1c22221d}, + {0x0f007040, 0x8A116600}, + {0x0f007044, 0x222d0800}, + {0x0f007048, 0x02690204}, + {0x0f00704c, 0x00000000}, + {0x0f007050, 0x0100001c}, + {0x0f007054, 0x00000000}, + {0x0f007058, 0x00000000}, + {0x0f00705c, 0x00000000}, + {0x0f007060, 0x000A15D6}, + {0x0f007064, 0x0000000A}, + {0x0f007068, 0x00000000}, + {0x0f00706c, 0x00000001}, + {0x0f007070, 0x00004000}, + {0x0f007074, 0x00000000}, + {0x0f007078, 0x00000000}, + {0x0f00707c, 0x00000000}, + {0x0f007080, 0x00000000}, + {0x0f007084, 0x00000000}, + {0x0f007088, 0x01000001}, + {0x0f00708c, 0x00000101}, + {0x0f007090, 0x00000000}, + {0x0f007094, 0x00010000}, + {0x0f007098, 0x00000000}, + {0x0F0070C8, 0x00000104}, + {0x0F007018, 0x01010000} }; int ddr_init(struct bcm_mini_adapter *Adapter) { - struct bcm_ddr_setting *psDDRSetting=NULL; - ULONG RegCount=0; + struct bcm_ddr_setting *psDDRSetting = NULL; + ULONG RegCount = 0; UINT value = 0; UINT uiResetValue = 0; UINT uiClockSetting = 0; int retval = STATUS_SUCCESS; - switch (Adapter->chip_id) - { + switch (Adapter->chip_id) { case 0xbece3200: - switch (Adapter->DDRSetting) - { - case DDR_80_MHZ: - psDDRSetting=asT3LP_DDRSetting80MHz; - RegCount=(sizeof(asT3LP_DDRSetting80MHz)/ - sizeof(struct bcm_ddr_setting)); - break; - case DDR_100_MHZ: - psDDRSetting=asT3LP_DDRSetting100MHz; - RegCount=(sizeof(asT3LP_DDRSetting100MHz)/ - sizeof(struct bcm_ddr_setting)); - break; - case DDR_133_MHZ: - psDDRSetting=asT3LP_DDRSetting133MHz; - RegCount=(sizeof(asT3LP_DDRSetting133MHz)/ - sizeof(struct bcm_ddr_setting)); - if(Adapter->bMipsConfig == MIPS_200_MHZ) - { - uiClockSetting = 0x03F13652; - } - else - { - uiClockSetting = 0x03F1365B; - } - break; - default: - return -EINVAL; - } + switch (Adapter->DDRSetting) { + case DDR_80_MHZ: + psDDRSetting = asT3LP_DDRSetting80MHz; + RegCount = (sizeof(asT3LP_DDRSetting80MHz)/ + sizeof(struct bcm_ddr_setting)); + break; + case DDR_100_MHZ: + psDDRSetting = asT3LP_DDRSetting100MHz; + RegCount = (sizeof(asT3LP_DDRSetting100MHz)/ + sizeof(struct bcm_ddr_setting)); + break; + case DDR_133_MHZ: + psDDRSetting = asT3LP_DDRSetting133MHz; + RegCount = (sizeof(asT3LP_DDRSetting133MHz)/ + sizeof(struct bcm_ddr_setting)); + if (Adapter->bMipsConfig == MIPS_200_MHZ) + uiClockSetting = 0x03F13652; + else + uiClockSetting = 0x03F1365B; + break; + default: + return -EINVAL; + } break; case T3LPB: case BCS220_2: case BCS220_2BC: case BCS250_BC: - case BCS220_3 : + case BCS220_3: /* Set bit 2 and bit 6 to 1 for BBIC 2mA drive * (please check current value and additionally set these bits) */ - if( (Adapter->chip_id != BCS220_2) && - (Adapter->chip_id != BCS220_2BC) && - (Adapter->chip_id != BCS220_3) ) - { - 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", __FUNCTION__, __LINE__); - return retval; - } - uiResetValue |= 0x44; - retval = wrmalt(Adapter,(UINT)0x0f000830, &uiResetValue, sizeof(uiResetValue)); - if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, WRM, DBG_LVL_ALL, "%s:%d WRM failed\n", __FUNCTION__, __LINE__); - return retval; - } + if ((Adapter->chip_id != BCS220_2) && + (Adapter->chip_id != BCS220_2BC) && + (Adapter->chip_id != BCS220_3)) { + 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; } - switch(Adapter->DDRSetting) - { + uiResetValue |= 0x44; + 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; + } + } + switch (Adapter->DDRSetting) { - case DDR_80_MHZ: - psDDRSetting = asT3LPB_DDRSetting80MHz; - RegCount=(sizeof(asT3B_DDRSetting80MHz)/ - sizeof(struct bcm_ddr_setting)); + case DDR_80_MHZ: + psDDRSetting = asT3LPB_DDRSetting80MHz; + RegCount = (sizeof(asT3B_DDRSetting80MHz)/ + sizeof(struct bcm_ddr_setting)); break; - case DDR_100_MHZ: - psDDRSetting=asT3LPB_DDRSetting100MHz; - RegCount=(sizeof(asT3B_DDRSetting100MHz)/ - sizeof(struct bcm_ddr_setting)); + case DDR_100_MHZ: + psDDRSetting = asT3LPB_DDRSetting100MHz; + RegCount = (sizeof(asT3B_DDRSetting100MHz)/ + sizeof(struct bcm_ddr_setting)); break; - case DDR_133_MHZ: - psDDRSetting = asT3LPB_DDRSetting133MHz; - RegCount=(sizeof(asT3B_DDRSetting133MHz)/ - sizeof(struct bcm_ddr_setting)); + case DDR_133_MHZ: + psDDRSetting = asT3LPB_DDRSetting133MHz; + RegCount = (sizeof(asT3B_DDRSetting133MHz)/ + sizeof(struct bcm_ddr_setting)); - if(Adapter->bMipsConfig == MIPS_200_MHZ) - { - uiClockSetting = 0x03F13652; - } - else - { - uiClockSetting = 0x03F1365B; - } + if (Adapter->bMipsConfig == MIPS_200_MHZ) + uiClockSetting = 0x03F13652; + else + uiClockSetting = 0x03F1365B; break; - case DDR_160_MHZ: - psDDRSetting = asT3LPB_DDRSetting160MHz; - RegCount = sizeof(asT3LPB_DDRSetting160MHz)/sizeof(struct bcm_ddr_setting); + case DDR_160_MHZ: + psDDRSetting = asT3LPB_DDRSetting160MHz; + RegCount = sizeof(asT3LPB_DDRSetting160MHz)/sizeof(struct bcm_ddr_setting); - if(Adapter->bMipsConfig == MIPS_200_MHZ) - { - uiClockSetting = 0x03F137D2; - } - else - { - uiClockSetting = 0x03F137DB; - } - } + if (Adapter->bMipsConfig == MIPS_200_MHZ) + uiClockSetting = 0x03F137D2; + else + uiClockSetting = 0x03F137DB; + } break; case 0xbece0110: @@ -888,68 +871,59 @@ 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); - switch (Adapter->DDRSetting) - { - case DDR_80_MHZ: - psDDRSetting = asT3_DDRSetting80MHz; - RegCount = (sizeof(asT3_DDRSetting80MHz)/ - sizeof(struct bcm_ddr_setting)); - break; - case DDR_100_MHZ: - psDDRSetting = asT3_DDRSetting100MHz; - RegCount = (sizeof(asT3_DDRSetting100MHz)/ - sizeof(struct bcm_ddr_setting)); - break; - case DDR_133_MHZ: - psDDRSetting = asT3_DDRSetting133MHz; - RegCount = (sizeof(asT3_DDRSetting133MHz)/ - sizeof(struct bcm_ddr_setting)); - break; - default: - return -EINVAL; - } + 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; + RegCount = (sizeof(asT3_DDRSetting80MHz)/ + sizeof(struct bcm_ddr_setting)); + break; + case DDR_100_MHZ: + psDDRSetting = asT3_DDRSetting100MHz; + RegCount = (sizeof(asT3_DDRSetting100MHz)/ + sizeof(struct bcm_ddr_setting)); + break; + case DDR_133_MHZ: + psDDRSetting = asT3_DDRSetting133MHz; + RegCount = (sizeof(asT3_DDRSetting133MHz)/ + sizeof(struct bcm_ddr_setting)); + break; + default: + return -EINVAL; + } case 0xbece0310: { - switch (Adapter->DDRSetting) - { - case DDR_80_MHZ: - psDDRSetting = asT3B_DDRSetting80MHz; - RegCount=(sizeof(asT3B_DDRSetting80MHz)/ - sizeof(struct bcm_ddr_setting)); - break; - case DDR_100_MHZ: - psDDRSetting=asT3B_DDRSetting100MHz; - RegCount=(sizeof(asT3B_DDRSetting100MHz)/ - sizeof(struct bcm_ddr_setting)); + switch (Adapter->DDRSetting) { + case DDR_80_MHZ: + psDDRSetting = asT3B_DDRSetting80MHz; + RegCount = (sizeof(asT3B_DDRSetting80MHz)/ + sizeof(struct bcm_ddr_setting)); + break; + case DDR_100_MHZ: + psDDRSetting = asT3B_DDRSetting100MHz; + RegCount = (sizeof(asT3B_DDRSetting100MHz)/ + sizeof(struct bcm_ddr_setting)); break; - case DDR_133_MHZ: + case DDR_133_MHZ: - if(Adapter->bDPLLConfig == PLL_266_MHZ)//266Mhz PLL selected. - { - memcpy(asT3B_DDRSetting133MHz, asDPLL_266MHZ, - sizeof(asDPLL_266MHZ)); - psDDRSetting = asT3B_DDRSetting133MHz; - RegCount=(sizeof(asT3B_DDRSetting133MHz)/ - sizeof(struct bcm_ddr_setting)); - } + if (Adapter->bDPLLConfig == PLL_266_MHZ) { /* 266Mhz PLL selected. */ + memcpy(asT3B_DDRSetting133MHz, asDPLL_266MHZ, + sizeof(asDPLL_266MHZ)); + psDDRSetting = asT3B_DDRSetting133MHz; + RegCount = (sizeof(asT3B_DDRSetting133MHz)/ + sizeof(struct bcm_ddr_setting)); + } else { + psDDRSetting = asT3B_DDRSetting133MHz; + RegCount = (sizeof(asT3B_DDRSetting133MHz)/ + sizeof(struct bcm_ddr_setting)); + if (Adapter->bMipsConfig == MIPS_200_MHZ) + uiClockSetting = 0x07F13652; else - { - psDDRSetting = asT3B_DDRSetting133MHz; - RegCount=(sizeof(asT3B_DDRSetting133MHz)/ - sizeof(struct bcm_ddr_setting)); - if(Adapter->bMipsConfig == MIPS_200_MHZ) - { - uiClockSetting = 0x07F13652; - } - else - { - uiClockSetting = 0x07F1365B; - } - } - break; - default: - return -EINVAL; + uiClockSetting = 0x07F1365B; + } + break; + default: + return -EINVAL; } break; @@ -958,21 +932,16 @@ int ddr_init(struct bcm_mini_adapter *Adapter) return -EINVAL; } - value=0; - 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 = 0; + 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; - } else - { value = psDDRSetting->ulRegValue; - } retval = wrmalt(Adapter, psDDRSetting->ulRegAddress, &value, sizeof(value)); - if(STATUS_SUCCESS != retval) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"%s:%d\n", __FUNCTION__, __LINE__); + if (STATUS_SUCCESS != retval) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "%s:%d\n", __func__, __LINE__); break; } @@ -980,37 +949,35 @@ int ddr_init(struct bcm_mini_adapter *Adapter) psDDRSetting++; } - if(Adapter->chip_id >= 0xbece3300 ) - { + if (Adapter->chip_id >= 0xbece3300) { mdelay(3); - if( (Adapter->chip_id != BCS220_2)&& - (Adapter->chip_id != BCS220_2BC)&& - (Adapter->chip_id != BCS220_3)) - { + if ((Adapter->chip_id != BCS220_2) && + (Adapter->chip_id != BCS220_2BC) && + (Adapter->chip_id != BCS220_3)) { /* drive MDDR to half in case of UMA-B: */ uiResetValue = 0x01010001; retval = wrmalt(Adapter, (UINT)0x0F007018, &uiResetValue, sizeof(uiResetValue)); - if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + if (retval < 0) { + BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } uiResetValue = 0x00040020; retval = wrmalt(Adapter, (UINT)0x0F007094, &uiResetValue, sizeof(uiResetValue)); - if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + if (retval < 0) { + BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } uiResetValue = 0x01020101; retval = wrmalt(Adapter, (UINT)0x0F00701c, &uiResetValue, sizeof(uiResetValue)); - if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + if (retval < 0) { + BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } uiResetValue = 0x01010000; retval = wrmalt(Adapter, (UINT)0x0F007018, &uiResetValue, sizeof(uiResetValue)); - if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + if (retval < 0) { + BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } } @@ -1020,76 +987,73 @@ int ddr_init(struct bcm_mini_adapter *Adapter) * This is to be done only for Hybrid PMU mode. * with the current h/w there is no way to detect this. * and since we dont have internal PMU lets do it under UMA-B chip id. - * we will change this when we will have internal PMU. - */ - if(Adapter->PmuMode == HYBRID_MODE_7C) - { - 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", __FUNCTION__, __LINE__); + * we will change this when we will have internal PMU. + */ + if (Adapter->PmuMode == HYBRID_MODE_7C) { + 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)); - if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + 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; } uiResetValue = 0x1322a8; retval = wrmalt(Adapter, (UINT)0x0f000d1c, &uiResetValue, sizeof(uiResetValue)); - if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + 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)); - if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + 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)); - if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + 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; } uiResetValue = 0x132296; retval = wrmalt(Adapter, (UINT)0x0f000d14, &uiResetValue, sizeof(uiResetValue)); - if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + if (retval < 0) { + BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } - } - else if(Adapter->PmuMode == HYBRID_MODE_6 ) - { + } else if (Adapter->PmuMode == HYBRID_MODE_6) { - 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", __FUNCTION__, __LINE__); + 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)); - if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + 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; } uiResetValue = 0x6003229a; retval = wrmalt(Adapter, (UINT)0x0f000d14, &uiResetValue, sizeof(uiResetValue)); - if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + 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)); - if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + 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)); - if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + 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; } uiResetValue = 0x1322a8; retval = wrmalt(Adapter, (UINT)0x0f000d1c, &uiResetValue, sizeof(uiResetValue)); - if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + if (retval < 0) { + BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } } @@ -1101,189 +1065,175 @@ int ddr_init(struct bcm_mini_adapter *Adapter) int download_ddr_settings(struct bcm_mini_adapter *Adapter) { - struct bcm_ddr_setting *psDDRSetting=NULL; - ULONG RegCount=0; + struct bcm_ddr_setting *psDDRSetting = NULL; + ULONG RegCount = 0; unsigned long ul_ddr_setting_load_addr = DDR_DUMP_INTERNAL_DEVICE_MEMORY; UINT value = 0; int retval = STATUS_SUCCESS; - BOOLEAN bOverrideSelfRefresh = FALSE; + bool bOverrideSelfRefresh = false; - switch (Adapter->chip_id) - { + switch (Adapter->chip_id) { case 0xbece3200: - switch (Adapter->DDRSetting) - { - case DDR_80_MHZ: - psDDRSetting = asT3LP_DDRSetting80MHz; - RegCount = ARRAY_SIZE(asT3LP_DDRSetting80MHz); - RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_80MHZ ; - psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_80MHZ; + switch (Adapter->DDRSetting) { + case DDR_80_MHZ: + psDDRSetting = asT3LP_DDRSetting80MHz; + RegCount = ARRAY_SIZE(asT3LP_DDRSetting80MHz); + RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_80MHZ; + psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_80MHZ; break; - case DDR_100_MHZ: - psDDRSetting = asT3LP_DDRSetting100MHz; - RegCount = ARRAY_SIZE(asT3LP_DDRSetting100MHz); - RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_100MHZ ; - psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_100MHZ; - break; - case DDR_133_MHZ: - bOverrideSelfRefresh = TRUE; - psDDRSetting = asT3LP_DDRSetting133MHz; - RegCount = ARRAY_SIZE(asT3LP_DDRSetting133MHz); - RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ; - psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ; - break; - default: - return -EINVAL; - } + case DDR_100_MHZ: + psDDRSetting = asT3LP_DDRSetting100MHz; + RegCount = ARRAY_SIZE(asT3LP_DDRSetting100MHz); + RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_100MHZ; + psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_100MHZ; + break; + case DDR_133_MHZ: + bOverrideSelfRefresh = TRUE; + psDDRSetting = asT3LP_DDRSetting133MHz; + RegCount = ARRAY_SIZE(asT3LP_DDRSetting133MHz); + RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ; + psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ; + break; + default: + return -EINVAL; + } break; case T3LPB: case BCS220_2: case BCS220_2BC: case BCS250_BC: - case BCS220_3 : - switch (Adapter->DDRSetting) - { - case DDR_80_MHZ: - psDDRSetting = asT3LPB_DDRSetting80MHz; - RegCount=ARRAY_SIZE(asT3LPB_DDRSetting80MHz); - RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_80MHZ ; - psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_80MHZ; + case BCS220_3: + switch (Adapter->DDRSetting) { + case DDR_80_MHZ: + psDDRSetting = asT3LPB_DDRSetting80MHz; + RegCount = ARRAY_SIZE(asT3LPB_DDRSetting80MHz); + RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_80MHZ; + psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_80MHZ; + break; + case DDR_100_MHZ: + psDDRSetting = asT3LPB_DDRSetting100MHz; + RegCount = ARRAY_SIZE(asT3LPB_DDRSetting100MHz); + RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_100MHZ; + psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_100MHZ; + break; + case DDR_133_MHZ: + bOverrideSelfRefresh = TRUE; + psDDRSetting = asT3LPB_DDRSetting133MHz; + RegCount = ARRAY_SIZE(asT3LPB_DDRSetting133MHz); + RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_133MHZ; + psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_133MHZ; break; - case DDR_100_MHZ: - psDDRSetting = asT3LPB_DDRSetting100MHz; - RegCount = ARRAY_SIZE(asT3LPB_DDRSetting100MHz); - RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_100MHZ ; - psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_100MHZ; - break; - case DDR_133_MHZ: - bOverrideSelfRefresh = TRUE; - psDDRSetting = asT3LPB_DDRSetting133MHz; - RegCount = ARRAY_SIZE(asT3LPB_DDRSetting133MHz); - RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ; - psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_133MHZ; - break; - case DDR_160_MHZ: - bOverrideSelfRefresh = TRUE; - psDDRSetting = asT3LPB_DDRSetting160MHz; - RegCount = ARRAY_SIZE(asT3LPB_DDRSetting160MHz); - RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_160MHZ; - psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_160MHZ; + case DDR_160_MHZ: + bOverrideSelfRefresh = TRUE; + psDDRSetting = asT3LPB_DDRSetting160MHz; + RegCount = ARRAY_SIZE(asT3LPB_DDRSetting160MHz); + RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_160MHZ; + psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_160MHZ; - break; - default: - return -EINVAL; - } + break; + default: + return -EINVAL; + } break; case 0xbece0300: - switch (Adapter->DDRSetting) - { - case DDR_80_MHZ: - psDDRSetting = asT3_DDRSetting80MHz; - RegCount = ARRAY_SIZE(asT3_DDRSetting80MHz); - RegCount-=T3_SKIP_CLOCK_PROGRAM_DUMP_80MHZ ; - psDDRSetting += T3_SKIP_CLOCK_PROGRAM_DUMP_80MHZ; + switch (Adapter->DDRSetting) { + case DDR_80_MHZ: + psDDRSetting = asT3_DDRSetting80MHz; + RegCount = ARRAY_SIZE(asT3_DDRSetting80MHz); + RegCount -= T3_SKIP_CLOCK_PROGRAM_DUMP_80MHZ; + psDDRSetting += T3_SKIP_CLOCK_PROGRAM_DUMP_80MHZ; break; - case DDR_100_MHZ: - psDDRSetting = asT3_DDRSetting100MHz; - RegCount = ARRAY_SIZE(asT3_DDRSetting100MHz); - RegCount-=T3_SKIP_CLOCK_PROGRAM_DUMP_100MHZ ; - psDDRSetting += T3_SKIP_CLOCK_PROGRAM_DUMP_100MHZ; - break; - case DDR_133_MHZ: - psDDRSetting = asT3_DDRSetting133MHz; - RegCount = ARRAY_SIZE(asT3_DDRSetting133MHz); - RegCount-=T3_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ; - psDDRSetting += T3_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ; - break; - default: - return -EINVAL; - } + case DDR_100_MHZ: + psDDRSetting = asT3_DDRSetting100MHz; + RegCount = ARRAY_SIZE(asT3_DDRSetting100MHz); + RegCount -= T3_SKIP_CLOCK_PROGRAM_DUMP_100MHZ; + psDDRSetting += T3_SKIP_CLOCK_PROGRAM_DUMP_100MHZ; + break; + case DDR_133_MHZ: + psDDRSetting = asT3_DDRSetting133MHz; + RegCount = ARRAY_SIZE(asT3_DDRSetting133MHz); + RegCount -= T3_SKIP_CLOCK_PROGRAM_DUMP_133MHZ; + psDDRSetting += T3_SKIP_CLOCK_PROGRAM_DUMP_133MHZ; + break; + default: + return -EINVAL; + } break; case 0xbece0310: { - switch (Adapter->DDRSetting) - { - case DDR_80_MHZ: - psDDRSetting = asT3B_DDRSetting80MHz; - RegCount = ARRAY_SIZE(asT3B_DDRSetting80MHz); - RegCount -= T3B_SKIP_CLOCK_PROGRAM_DUMP_80MHZ ; - psDDRSetting += T3B_SKIP_CLOCK_PROGRAM_DUMP_80MHZ; - break; - case DDR_100_MHZ: - psDDRSetting = asT3B_DDRSetting100MHz; - RegCount = ARRAY_SIZE(asT3B_DDRSetting100MHz); - RegCount -= T3B_SKIP_CLOCK_PROGRAM_DUMP_100MHZ ; - psDDRSetting += T3B_SKIP_CLOCK_PROGRAM_DUMP_100MHZ; - break; - case DDR_133_MHZ: - bOverrideSelfRefresh = TRUE; - psDDRSetting = asT3B_DDRSetting133MHz; - RegCount = ARRAY_SIZE(asT3B_DDRSetting133MHz); - RegCount -= T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ; - psDDRSetting += T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ; - break; - } - break; + switch (Adapter->DDRSetting) { + case DDR_80_MHZ: + psDDRSetting = asT3B_DDRSetting80MHz; + RegCount = ARRAY_SIZE(asT3B_DDRSetting80MHz); + RegCount -= T3B_SKIP_CLOCK_PROGRAM_DUMP_80MHZ; + psDDRSetting += T3B_SKIP_CLOCK_PROGRAM_DUMP_80MHZ; + break; + case DDR_100_MHZ: + psDDRSetting = asT3B_DDRSetting100MHz; + RegCount = ARRAY_SIZE(asT3B_DDRSetting100MHz); + RegCount -= T3B_SKIP_CLOCK_PROGRAM_DUMP_100MHZ; + psDDRSetting += T3B_SKIP_CLOCK_PROGRAM_DUMP_100MHZ; + break; + case DDR_133_MHZ: + bOverrideSelfRefresh = TRUE; + psDDRSetting = asT3B_DDRSetting133MHz; + RegCount = ARRAY_SIZE(asT3B_DDRSetting133MHz); + RegCount -= T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ; + psDDRSetting += T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ; + break; + } + break; } default: return -EINVAL; } - //total number of Register that has to be dumped - value =RegCount ; + /* total number of Register that has to be dumped */ + value = RegCount; retval = wrmalt(Adapter, ul_ddr_setting_load_addr, &value, sizeof(value)); - if(retval) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"%s:%d\n", __FUNCTION__, __LINE__); + if (retval) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "%s:%d\n", __func__, __LINE__); return retval; } - ul_ddr_setting_load_addr+=sizeof(ULONG); - /*signature */ - value =(0x1d1e0dd0); + ul_ddr_setting_load_addr += sizeof(ULONG); + /* signature */ + value = (0x1d1e0dd0); retval = wrmalt(Adapter, ul_ddr_setting_load_addr, &value, sizeof(value)); - if(retval) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"%s:%d\n", __FUNCTION__, __LINE__); + if (retval) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "%s:%d\n", __func__, __LINE__); return retval; } - ul_ddr_setting_load_addr+=sizeof(ULONG); - RegCount*=(sizeof(struct bcm_ddr_setting)/sizeof(ULONG)); + ul_ddr_setting_load_addr += sizeof(ULONG); + RegCount *= (sizeof(struct bcm_ddr_setting)/sizeof(ULONG)); - while(RegCount && !retval) - { - value = psDDRSetting->ulRegAddress ; - retval = wrmalt( Adapter, ul_ddr_setting_load_addr, &value, sizeof(value)); - ul_ddr_setting_load_addr+=sizeof(ULONG); - if(!retval) - { - if(bOverrideSelfRefresh && (psDDRSetting->ulRegAddress == 0x0F007018)) - { - 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", __FUNCTION__, __LINE__); - break; - } + while (RegCount && !retval) { + value = psDDRSetting->ulRegAddress; + retval = wrmalt(Adapter, ul_ddr_setting_load_addr, &value, sizeof(value)); + ul_ddr_setting_load_addr += sizeof(ULONG); + if (!retval) { + if (bOverrideSelfRefresh && (psDDRSetting->ulRegAddress == 0x0F007018)) { + 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__); + break; } - else - { + } else { value = psDDRSetting->ulRegValue; - 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", __FUNCTION__, __LINE__); + 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__); break; } } } - ul_ddr_setting_load_addr+=sizeof(ULONG); + ul_ddr_setting_load_addr += sizeof(ULONG); RegCount--; psDDRSetting++; } - return retval; + return retval; } - - diff --git a/drivers/staging/bcm/Debug.h b/drivers/staging/bcm/Debug.h index 8018a189f81..7b331215c1a 100644 --- a/drivers/staging/bcm/Debug.h +++ b/drivers/staging/bcm/Debug.h @@ -9,142 +9,129 @@ #include <linux/string.h> #define NONE 0xFFFF - -//-------------------------------------------------------------------------------- - /* TYPE and SUBTYPE * Define valid TYPE (or category or code-path, however you like to think of it) * and SUBTYPE s. * Type and SubType are treated as bitmasks. */ -/*-----------------BEGIN TYPEs------------------------------------------*/ -#define DBG_TYPE_INITEXIT (1 << 0) // 1 -#define DBG_TYPE_TX (1 << 1) // 2 -#define DBG_TYPE_RX (1 << 2) // 4 -#define DBG_TYPE_OTHERS (1 << 3) // 8 -/*-----------------END TYPEs------------------------------------------*/ -#define NUMTYPES 4 // careful! - -/*-----------------BEGIN SUBTYPEs---------------------------------------*/ - -/*-SUBTYPEs for TX : TYPE is DBG_TYPE_TX -----// - Transmit.c ,Arp.c, LeakyBucket.c, And Qos.c - total 17 macros */ -// Transmit.c -#define TX 1 -#define MP_SEND (TX<<0) -#define NEXT_SEND (TX<<1) -#define TX_FIFO (TX<<2) -#define TX_CONTROL (TX<<3) - -// Arp.c -#define IP_ADDR (TX<<4) -#define ARP_REQ (TX<<5) -#define ARP_RESP (TX<<6) - -// Leakybucket.c -#define TOKEN_COUNTS (TX<<8) -#define CHECK_TOKENS (TX<<9) -#define TX_PACKETS (TX<<10) -#define TIMER (TX<<11) - -// Qos.c -#define QOS TX -#define QUEUE_INDEX (QOS<<12) -#define IPV4_DBG (QOS<<13) -#define IPV6_DBG (QOS<<14) -#define PRUNE_QUEUE (QOS<<15) -#define SEND_QUEUE (QOS<<16) - -//TX_Misc -#define TX_OSAL_DBG (TX<<17) - - -//--SUBTYPEs for ------INIT & EXIT--------------------- -/*------------ TYPE is DBG_TYPE_INITEXIT -----// -DriverEntry.c, bcmfwup.c, ChipDetectTask.c, HaltnReset.c, InterfaceDDR.c */ -#define MP 1 -#define DRV_ENTRY (MP<<0) -#define MP_INIT (MP<<1) -#define READ_REG (MP<<3) -#define DISPATCH (MP<<2) -#define CLAIM_ADAP (MP<<4) -#define REG_IO_PORT (MP<<5) -#define INIT_DISP (MP<<6) -#define RX_INIT (MP<<7) - - -//-SUBTYPEs for --RX---------------------------------- -//------------RX : TYPE is DBG_TYPE_RX -----// -// Receive.c -#define RX 1 -#define RX_DPC (RX<<0) -#define RX_CTRL (RX<<3) -#define RX_DATA (RX<<4) -#define MP_RETURN (RX<<1) -#define LINK_MSG (RX<<2) - - -//-SUBTYPEs for ----OTHER ROUTINES------------------ -//------------OTHERS : TYPE is DBG_TYPE_OTHER -----// -// HaltnReset,CheckForHang,PnP,Misc,CmHost -// total 12 macros -#define OTHERS 1 -// ??ISR.C - -#define ISR OTHERS -#define MP_DPC (ISR<<0) - -// HaltnReset.c -#define HALT OTHERS -#define MP_HALT (HALT<<1) -#define CHECK_HANG (HALT<<2) -#define MP_RESET (HALT<<3) -#define MP_SHUTDOWN (HALT<<4) - -// pnp.c -#define PNP OTHERS -#define MP_PNP (PNP<<5) - -// Misc.c -#define MISC OTHERS -#define DUMP_INFO (MISC<<6) -#define CLASSIFY (MISC<<7) -#define LINK_UP_MSG (MISC<<8) -#define CP_CTRL_PKT (MISC<<9) -#define DUMP_CONTROL (MISC<<10) -#define LED_DUMP_INFO (MISC<<11) - -// CmHost.c -#define CMHOST OTHERS - - -#define SERIAL (OTHERS<<12) -#define IDLE_MODE (OTHERS<<13) - -#define WRM (OTHERS<<14) -#define RDM (OTHERS<<15) - -// TODO - put PHS_SEND in Tx PHS_RECEIVE in Rx path ? -#define PHS_SEND (OTHERS<<16) -#define PHS_RECEIVE (OTHERS<<17) -#define PHS_MODULE (OTHERS<<18) - -#define INTF_INIT (OTHERS<<19) -#define INTF_ERR (OTHERS<<20) -#define INTF_WARN (OTHERS<<21) -#define INTF_NORM (OTHERS<<22) - -#define IRP_COMPLETION (OTHERS<<23) -#define SF_DESCRIPTOR_CNTS (OTHERS<<24) -#define PHS_DISPATCH (OTHERS << 25) -#define OSAL_DBG (OTHERS << 26) -#define NVM_RW (OTHERS << 27) - -#define HOST_MIBS (OTHERS << 28) -#define CONN_MSG (CMHOST << 29) -/*-----------------END SUBTYPEs------------------------------------------*/ - +#define DBG_TYPE_INITEXIT (1 << 0) /* 1 */ +#define DBG_TYPE_TX (1 << 1) /* 2 */ +#define DBG_TYPE_RX (1 << 2) /* 4 */ +#define DBG_TYPE_OTHERS (1 << 3) /* 8 */ +#define NUMTYPES 4 + +/* -SUBTYPEs for TX : TYPE is DBG_TYPE_TX -----// + * Transmit.c ,Arp.c, LeakyBucket.c, And Qos.c + * total 17 macros + */ +/* Transmit.c */ +#define TX 1 +#define MP_SEND (TX << 0) +#define NEXT_SEND (TX << 1) +#define TX_FIFO (TX << 2) +#define TX_CONTROL (TX << 3) + +/* Arp.c */ +#define IP_ADDR (TX << 4) +#define ARP_REQ (TX << 5) +#define ARP_RESP (TX << 6) + +/* Leakybucket.c */ +#define TOKEN_COUNTS (TX << 8) +#define CHECK_TOKENS (TX << 9) +#define TX_PACKETS (TX << 10) +#define TIMER (TX << 11) + +/* Qos.c */ +#define QOS TX +#define QUEUE_INDEX (QOS << 12) +#define IPV4_DBG (QOS << 13) +#define IPV6_DBG (QOS << 14) +#define PRUNE_QUEUE (QOS << 15) +#define SEND_QUEUE (QOS << 16) + +/* TX_Misc */ +#define TX_OSAL_DBG (TX << 17) + +/* --SUBTYPEs for ------INIT & EXIT--------------------- + * ------------ TYPE is DBG_TYPE_INITEXIT -----// + * DriverEntry.c, bcmfwup.c, ChipDetectTask.c, HaltnReset.c, InterfaceDDR.c + */ +#define MP 1 +#define DRV_ENTRY (MP << 0) +#define MP_INIT (MP << 1) +#define READ_REG (MP << 3) +#define DISPATCH (MP << 2) +#define CLAIM_ADAP (MP << 4) +#define REG_IO_PORT (MP << 5) +#define INIT_DISP (MP << 6) +#define RX_INIT (MP << 7) + +/* -SUBTYPEs for --RX---------------------------------- + * ------------RX : TYPE is DBG_TYPE_RX -----// + * Receive.c + */ +#define RX 1 +#define RX_DPC (RX << 0) +#define RX_CTRL (RX << 3) +#define RX_DATA (RX << 4) +#define MP_RETURN (RX << 1) +#define LINK_MSG (RX << 2) + +/* -SUBTYPEs for ----OTHER ROUTINES------------------ + * ------------OTHERS : TYPE is DBG_TYPE_OTHER -----// + * HaltnReset,CheckForHang,PnP,Misc,CmHost + * total 12 macros + */ +#define OTHERS 1 +#define ISR OTHERS +#define MP_DPC (ISR << 0) + +/* HaltnReset.c */ +#define HALT OTHERS +#define MP_HALT (HALT << 1) +#define CHECK_HANG (HALT << 2) +#define MP_RESET (HALT << 3) +#define MP_SHUTDOWN (HALT << 4) + +/* pnp.c */ +#define PNP OTHERS +#define MP_PNP (PNP << 5) + +/* Misc.c */ +#define MISC OTHERS +#define DUMP_INFO (MISC << 6) +#define CLASSIFY (MISC << 7) +#define LINK_UP_MSG (MISC << 8) +#define CP_CTRL_PKT (MISC << 9) +#define DUMP_CONTROL (MISC << 10) +#define LED_DUMP_INFO (MISC << 11) + +/* CmHost.c */ +#define CMHOST OTHERS +#define SERIAL (OTHERS << 12) +#define IDLE_MODE (OTHERS << 13) +#define WRM (OTHERS << 14) +#define RDM (OTHERS << 15) + +/* TODO - put PHS_SEND in Tx PHS_RECEIVE in Rx path ? */ +#define PHS_SEND (OTHERS << 16) +#define PHS_RECEIVE (OTHERS << 17) +#define PHS_MODULE (OTHERS << 18) + +#define INTF_INIT (OTHERS << 19) +#define INTF_ERR (OTHERS << 20) +#define INTF_WARN (OTHERS << 21) +#define INTF_NORM (OTHERS << 22) + +#define IRP_COMPLETION (OTHERS << 23) +#define SF_DESCRIPTOR_CNTS (OTHERS << 24) +#define PHS_DISPATCH (OTHERS << 25) +#define OSAL_DBG (OTHERS << 26) +#define NVM_RW (OTHERS << 27) + +#define HOST_MIBS (OTHERS << 28) +#define CONN_MSG (CMHOST << 29) /* Debug level * We have 8 debug levels, in (numerical) increasing order of verbosity. @@ -157,57 +144,58 @@ DriverEntry.c, bcmfwup.c, ChipDetectTask.c, HaltnReset.c, InterfaceDDR.c */ * You can compile-time change that to any of the below, if you wish to. However, as of now, there's * no dynamic facility to have the userspace 'TestApp' set debug_level. Slated for future expansion. */ -#define BCM_ALL 7 -#define BCM_LOW 6 -#define BCM_PRINT 5 -#define BCM_NORMAL 4 -#define BCM_MEDIUM 3 -#define BCM_SCREAM 2 -#define BCM_ERR 1 +#define BCM_ALL 7 +#define BCM_LOW 6 +#define BCM_PRINT 5 +#define BCM_NORMAL 4 +#define BCM_MEDIUM 3 +#define BCM_SCREAM 2 +#define BCM_ERR 1 /* Not meant for developer in debug prints. - * To be used to disable all prints by setting the DBG_LVL_CURR to this value */ -#define BCM_NONE 0 + * To be used to disable all prints by setting the DBG_LVL_CURR to this value + */ +#define BCM_NONE 0 /* The current driver logging level. * Everything at this level and (numerically) lower (meaning higher prio) * is logged. -* Replace 'BCM_ALL' in the DBG_LVL_CURR macro with the logging level desired. + * Replace 'BCM_ALL' in the DBG_LVL_CURR macro with the logging level desired. * For eg. to set the logging level to 'errors only' use: * #define DBG_LVL_CURR (BCM_ERR) */ #define DBG_LVL_CURR (BCM_ALL) -#define DBG_LVL_ALL BCM_ALL +#define DBG_LVL_ALL BCM_ALL -/*---Userspace mapping of Debug State. +/* ---Userspace mapping of Debug State. * Delibrately matches that of the Windows driver.. * The TestApp's ioctl passes this struct to us. */ -typedef struct -{ +struct bcm_user_debug_state { unsigned int Subtype, Type; unsigned int OnOff; -// unsigned int debug_level; /* future expansion */ -} __attribute__((packed)) USER_BCM_DBG_STATE; +/* unsigned int debug_level; future expansion */ +} __packed; -//---Kernel-space mapping of Debug State -typedef struct _S_BCM_DEBUG_STATE { - UINT type; +/* ---Kernel-space mapping of Debug State */ +struct bcm_debug_state { + unsigned int type; /* A bitmap of 32 bits for Subtype per Type. * Valid indexes in 'subtype' array are *only* 1,2,4 and 8, * corresponding to valid Type values. Hence we use the 'Type' field * as the index value, ignoring the array entries 0,3,5,6,7 ! */ - UINT subtype[(NUMTYPES*2)+1]; - UINT debug_level; -} S_BCM_DEBUG_STATE; -/* Instantiated in the Adapter structure */ -/* We'll reuse the debug level parameter to include a bit (the MSB) to indicate whether or not - * we want the function's name printed. */ -#define DBG_NO_FUNC_PRINT 1 << 31 + unsigned int subtype[(NUMTYPES*2)+1]; + unsigned int debug_level; +}; +/* Instantiated in the Adapter structure + * We'll reuse the debug level parameter to include a bit (the MSB) to indicate whether or not + * we want the function's name printed. + */ +#define DBG_NO_FUNC_PRINT (1 << 31) #define DBG_LVL_BITMASK 0xFF -//--- Only for direct printk's; "hidden" to API. +/* --- Only for direct printk's; "hidden" to API. */ #define DBG_TYPE_PRINTK 3 #define BCM_DEBUG_PRINT(Adapter, Type, SubType, dbg_level, string, args...) \ @@ -215,40 +203,40 @@ typedef struct _S_BCM_DEBUG_STATE { if (DBG_TYPE_PRINTK == Type) \ pr_info("%s:" string, __func__, ##args); \ else if (Adapter && \ - (dbg_level & DBG_LVL_BITMASK) <= Adapter->stDebugState.debug_level && \ - (Type & Adapter->stDebugState.type) && \ - (SubType & Adapter->stDebugState.subtype[Type])) { \ + (dbg_level & DBG_LVL_BITMASK) <= Adapter->stDebugState.debug_level && \ + (Type & Adapter->stDebugState.type) && \ + (SubType & Adapter->stDebugState.subtype[Type])) { \ if (dbg_level & DBG_NO_FUNC_PRINT) \ - printk(KERN_DEBUG string, ##args); \ + pr_debug("%s:\n", string); \ else \ - printk(KERN_DEBUG "%s:" string, __func__, ##args); \ + pr_debug("%s:\n" string, __func__, ##args); \ } \ } while (0) -#define BCM_DEBUG_PRINT_BUFFER(Adapter, Type, SubType, dbg_level, buffer, bufferlen) do { \ - if (DBG_TYPE_PRINTK == Type || \ - (Adapter && \ - (dbg_level & DBG_LVL_BITMASK) <= Adapter->stDebugState.debug_level && \ - (Type & Adapter->stDebugState.type) && \ - (SubType & Adapter->stDebugState.subtype[Type]))) { \ - printk(KERN_DEBUG "%s:\n", __func__); \ - print_hex_dump(KERN_DEBUG, " ", DUMP_PREFIX_OFFSET, \ - 16, 1, buffer, bufferlen, false); \ - } \ -} while(0) - - -#define BCM_SHOW_DEBUG_BITMAP(Adapter) do { \ - int i; \ - for (i=0; i<(NUMTYPES*2)+1; i++) { \ +#define BCM_DEBUG_PRINT_BUFFER(Adapter, Type, SubType, dbg_level, buffer, bufferlen) \ + do { \ + if (DBG_TYPE_PRINTK == Type || \ + (Adapter && \ + (dbg_level & DBG_LVL_BITMASK) <= Adapter->stDebugState.debug_level && \ + (Type & Adapter->stDebugState.type) && \ + (SubType & Adapter->stDebugState.subtype[Type]))) { \ + pr_debug("%s:\n", __func__); \ + print_hex_dump(KERN_DEBUG, " ", DUMP_PREFIX_OFFSET, \ + 16, 1, buffer, bufferlen, false); \ + } \ + } while (0) + +#define BCM_SHOW_DEBUG_BITMAP(Adapter) do { \ + int i; \ + for (i = 0; i < (NUMTYPES * 2) + 1; i++) { \ if ((i == 1) || (i == 2) || (i == 4) || (i == 8)) { \ - /* CAUTION! Forcefully turn on ALL debug paths and subpaths! \ - Adapter->stDebugState.subtype[i] = 0xffffffff; */ \ - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "subtype[%d] = 0x%08x\n", \ - i, Adapter->stDebugState.subtype[i]); \ + /* CAUTION! Forcefully turn on ALL debug paths and subpaths! \ + * Adapter->stDebugState.subtype[i] = 0xffffffff; \ + */ \ + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "subtype[%d] = 0x%08x\n", \ + i, Adapter->stDebugState.subtype[i]); \ } \ } \ } while (0) #endif - diff --git a/drivers/staging/bcm/HandleControlPacket.c b/drivers/staging/bcm/HandleControlPacket.c index 25e5c68bfe8..495fe3dc514 100644 --- a/drivers/staging/bcm/HandleControlPacket.c +++ b/drivers/staging/bcm/HandleControlPacket.c @@ -14,10 +14,10 @@ static VOID handle_rx_control_packet(struct bcm_mini_adapter *Adapter, struct sk_buff *skb) { struct bcm_tarang_data *pTarang = NULL; - BOOLEAN HighPriorityMessage = FALSE; + bool HighPriorityMessage = false; struct sk_buff *newPacket = NULL; CHAR cntrl_msg_mask_bit = 0; - BOOLEAN drop_pkt_flag = TRUE; + bool drop_pkt_flag = TRUE; USHORT usStatus = *(PUSHORT)(skb->data); if (netif_msg_pktdata(Adapter)) @@ -91,13 +91,13 @@ static VOID handle_rx_control_packet(struct bcm_mini_adapter *Adapter, struct sk * cntrl_msg_mask_bit); */ if (pTarang->RxCntrlMsgBitMask & (1 << cntrl_msg_mask_bit)) - drop_pkt_flag = FALSE; + drop_pkt_flag = false; if ((drop_pkt_flag == TRUE) || (pTarang->AppCtrlQueueLen > MAX_APP_QUEUE_LEN) || ((pTarang->AppCtrlQueueLen > MAX_APP_QUEUE_LEN / 2) && - (HighPriorityMessage == FALSE))) { + (HighPriorityMessage == false))) { /* * Assumption:- * 1. every tarang manages it own dropped pkt @@ -175,8 +175,8 @@ int control_packet_handler(struct bcm_mini_adapter *Adapter /* pointer to adapte return 0; } if (TRUE == Adapter->bWakeUpDevice) { - Adapter->bWakeUpDevice = FALSE; - if ((FALSE == Adapter->bTriedToWakeUpFromlowPowerMode) + Adapter->bWakeUpDevice = false; + if ((false == Adapter->bTriedToWakeUpFromlowPowerMode) && ((TRUE == Adapter->IdleMode) || (TRUE == Adapter->bShutStatus))) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, @@ -226,7 +226,7 @@ INT flushAllAppQ(void) pTarang->AppCtrlQueueLen = 0; /* dropped contrl packet statistics also should be reset. */ memset((PVOID)&pTarang->stDroppedAppCntrlMsgs, 0, - sizeof(S_MIBS_DROPPED_APP_CNTRL_MESSAGES)); + sizeof(struct bcm_mibs_dropped_cntrl_msg)); } return STATUS_SUCCESS; diff --git a/drivers/staging/bcm/HostMIBSInterface.h b/drivers/staging/bcm/HostMIBSInterface.h index e34531b638e..f922ac49b70 100644 --- a/drivers/staging/bcm/HostMIBSInterface.h +++ b/drivers/staging/bcm/HostMIBSInterface.h @@ -1,5 +1,3 @@ - - #ifndef _HOST_MIBSINTERFACE_H #define _HOST_MIBSINTERFACE_H @@ -10,221 +8,185 @@ * statistics used for the MIBS. */ -#define MIBS_MAX_CLASSIFIERS 100 -#define MIBS_MAX_PHSRULES 100 -#define MIBS_MAX_SERVICEFLOWS 17 -#define MIBS_MAX_IP_RANGE_LENGTH 4 -#define MIBS_MAX_PORT_RANGE 4 -#define MIBS_MAX_PROTOCOL_LENGTH 32 -#define MIBS_MAX_PHS_LENGTHS 255 -#define MIBS_IPV6_ADDRESS_SIZEINBYTES 0x10 +#define MIBS_MAX_CLASSIFIERS 100 +#define MIBS_MAX_PHSRULES 100 +#define MIBS_MAX_SERVICEFLOWS 17 +#define MIBS_MAX_IP_RANGE_LENGTH 4 +#define MIBS_MAX_PORT_RANGE 4 +#define MIBS_MAX_PROTOCOL_LENGTH 32 +#define MIBS_MAX_PHS_LENGTHS 255 +#define MIBS_IPV6_ADDRESS_SIZEINBYTES 0x10 #define MIBS_IP_LENGTH_OF_ADDRESS 4 -#define MIBS_MAX_HIST_ENTRIES 12 -#define MIBS_PKTSIZEHIST_RANGE 128 - -typedef union _U_MIBS_IP_ADDRESS -{ - struct - { - //Source Ip Address Range - ULONG ulIpv4Addr[MIBS_MAX_IP_RANGE_LENGTH]; - //Source Ip Mask Address Range - ULONG ulIpv4Mask[MIBS_MAX_IP_RANGE_LENGTH]; +#define MIBS_MAX_HIST_ENTRIES 12 +#define MIBS_PKTSIZEHIST_RANGE 128 + +union bcm_mibs_ip_addr { + struct { + /* Source Ip Address Range */ + unsigned long ulIpv4Addr[MIBS_MAX_IP_RANGE_LENGTH]; + /* Source Ip Mask Address Range */ + unsigned long ulIpv4Mask[MIBS_MAX_IP_RANGE_LENGTH]; }; - struct - { - //Source Ip Address Range - ULONG ulIpv6Addr[MIBS_MAX_IP_RANGE_LENGTH * 4]; - //Source Ip Mask Address Range - ULONG ulIpv6Mask[MIBS_MAX_IP_RANGE_LENGTH * 4]; - + struct { + /* Source Ip Address Range */ + unsigned long ulIpv6Addr[MIBS_MAX_IP_RANGE_LENGTH * 4]; + /* Source Ip Mask Address Range */ + unsigned long ulIpv6Mask[MIBS_MAX_IP_RANGE_LENGTH * 4]; }; - struct - { - UCHAR ucIpv4Address[MIBS_MAX_IP_RANGE_LENGTH * - MIBS_IP_LENGTH_OF_ADDRESS]; - UCHAR ucIpv4Mask[MIBS_MAX_IP_RANGE_LENGTH * - MIBS_IP_LENGTH_OF_ADDRESS]; + struct { + unsigned char ucIpv4Address[MIBS_MAX_IP_RANGE_LENGTH * MIBS_IP_LENGTH_OF_ADDRESS]; + unsigned char ucIpv4Mask[MIBS_MAX_IP_RANGE_LENGTH * MIBS_IP_LENGTH_OF_ADDRESS]; }; - struct - { - UCHAR ucIpv6Address[MIBS_MAX_IP_RANGE_LENGTH * MIBS_IPV6_ADDRESS_SIZEINBYTES]; - UCHAR ucIpv6Mask[MIBS_MAX_IP_RANGE_LENGTH * MIBS_IPV6_ADDRESS_SIZEINBYTES]; + struct { + unsigned char ucIpv6Address[MIBS_MAX_IP_RANGE_LENGTH * MIBS_IPV6_ADDRESS_SIZEINBYTES]; + unsigned char ucIpv6Mask[MIBS_MAX_IP_RANGE_LENGTH * MIBS_IPV6_ADDRESS_SIZEINBYTES]; }; -}U_MIBS_IP_ADDRESS; - - -typedef struct _S_MIBS_HOST_INFO -{ - ULONG64 GoodTransmits; - ULONG64 GoodReceives; - // this to keep track of the Tx and Rx MailBox Registers. - ULONG NumDesUsed; - ULONG CurrNumFreeDesc; - ULONG PrevNumFreeDesc; - // to keep track the no of byte received - ULONG PrevNumRcevBytes; - ULONG CurrNumRcevBytes; - +}; + +struct bcm_mibs_host_info { + u64 GoodTransmits; + u64 GoodReceives; + /* this to keep track of the Tx and Rx MailBox Registers. */ + unsigned long NumDesUsed; + unsigned long CurrNumFreeDesc; + unsigned long PrevNumFreeDesc; + /* to keep track the no of byte received */ + unsigned long PrevNumRcevBytes; + unsigned long CurrNumRcevBytes; /* QOS Related */ - ULONG BEBucketSize; - ULONG rtPSBucketSize; - ULONG LastTxQueueIndex; - BOOLEAN TxOutofDescriptors; - BOOLEAN TimerActive; - UINT32 u32TotalDSD; - UINT32 aTxPktSizeHist[MIBS_MAX_HIST_ENTRIES]; - UINT32 aRxPktSizeHist[MIBS_MAX_HIST_ENTRIES]; -}S_MIBS_HOST_INFO; - -typedef struct _S_MIBS_CLASSIFIER_RULE -{ - ULONG ulSFID; - UCHAR ucReserved[2]; - B_UINT16 uiClassifierRuleIndex; - BOOLEAN bUsed; - USHORT usVCID_Value; - // This field detemines the Classifier Priority - B_UINT8 u8ClassifierRulePriority; - U_MIBS_IP_ADDRESS stSrcIpAddress; - /*IP Source Address Length*/ - UCHAR ucIPSourceAddressLength; - - U_MIBS_IP_ADDRESS stDestIpAddress; + unsigned long BEBucketSize; + unsigned long rtPSBucketSize; + unsigned long LastTxQueueIndex; + bool TxOutofDescriptors; + bool TimerActive; + u32 u32TotalDSD; + u32 aTxPktSizeHist[MIBS_MAX_HIST_ENTRIES]; + u32 aRxPktSizeHist[MIBS_MAX_HIST_ENTRIES]; +}; + +struct bcm_mibs_classifier_rule { + unsigned long ulSFID; + unsigned char ucReserved[2]; + u16 uiClassifierRuleIndex; + bool bUsed; + unsigned short usVCID_Value; + u8 u8ClassifierRulePriority; + union bcm_mibs_ip_addr stSrcIpAddress; + /* IP Source Address Length */ + unsigned char ucIPSourceAddressLength; + union bcm_mibs_ip_addr stDestIpAddress; /* IP Destination Address Length */ - UCHAR ucIPDestinationAddressLength; - UCHAR ucIPTypeOfServiceLength;//Type of service Length - UCHAR ucTosLow;//Tos Low - UCHAR ucTosHigh;//Tos High - UCHAR ucTosMask;//Tos Mask - UCHAR ucProtocolLength;//protocol Length - UCHAR ucProtocol[MIBS_MAX_PROTOCOL_LENGTH];//protocol Length - USHORT usSrcPortRangeLo[MIBS_MAX_PORT_RANGE]; - USHORT usSrcPortRangeHi[MIBS_MAX_PORT_RANGE]; - UCHAR ucSrcPortRangeLength; - USHORT usDestPortRangeLo[MIBS_MAX_PORT_RANGE]; - USHORT usDestPortRangeHi[MIBS_MAX_PORT_RANGE]; - UCHAR ucDestPortRangeLength; - BOOLEAN bProtocolValid; - BOOLEAN bTOSValid; - BOOLEAN bDestIpValid; - BOOLEAN bSrcIpValid; - UCHAR ucDirection; - BOOLEAN bIpv6Protocol; - UINT32 u32PHSRuleID; -}S_MIBS_CLASSIFIER_RULE; - - -typedef struct _S_MIBS_PHS_RULE -{ - ULONG ulSFID; - /// brief 8bit PHSI Of The Service Flow - B_UINT8 u8PHSI; - /// brief PHSF Of The Service Flow - B_UINT8 u8PHSFLength; - B_UINT8 u8PHSF[MIBS_MAX_PHS_LENGTHS]; - /// brief PHSM Of The Service Flow - B_UINT8 u8PHSMLength; - B_UINT8 u8PHSM[MIBS_MAX_PHS_LENGTHS]; - /// brief 8bit PHSS Of The Service Flow - B_UINT8 u8PHSS; - /// brief 8bit PHSV Of The Service Flow - B_UINT8 u8PHSV; - // Reserved bytes are 5, so that it is similar to S_PHS_RULE structure. - B_UINT8 reserved[5]; + unsigned char ucIPDestinationAddressLength; + unsigned char ucIPTypeOfServiceLength; + unsigned char ucTosLow; + unsigned char ucTosHigh; + unsigned char ucTosMask; + unsigned char ucProtocolLength; + unsigned char ucProtocol[MIBS_MAX_PROTOCOL_LENGTH]; + unsigned short usSrcPortRangeLo[MIBS_MAX_PORT_RANGE]; + unsigned short usSrcPortRangeHi[MIBS_MAX_PORT_RANGE]; + unsigned char ucSrcPortRangeLength; + unsigned short usDestPortRangeLo[MIBS_MAX_PORT_RANGE]; + unsigned short usDestPortRangeHi[MIBS_MAX_PORT_RANGE]; + unsigned char ucDestPortRangeLength; + bool bProtocolValid; + bool bTOSValid; + bool bDestIpValid; + bool bSrcIpValid; + unsigned char ucDirection; + bool bIpv6Protocol; + u32 u32PHSRuleID; +}; + +struct bcm_mibs_phs_rule { + unsigned long ulSFID; + u8 u8PHSI; + u8 u8PHSFLength; + u8 u8PHSF[MIBS_MAX_PHS_LENGTHS]; + u8 u8PHSMLength; + u8 u8PHSM[MIBS_MAX_PHS_LENGTHS]; + u8 u8PHSS; + u8 u8PHSV; + u8 reserved[5]; + long PHSModifiedBytes; + unsigned long PHSModifiedNumPackets; + unsigned long PHSErrorNumPackets; +}; + +struct bcm_mibs_parameters { + u32 wmanIfSfid; + u32 wmanIfCmnCpsSfState; + u32 wmanIfCmnCpsMaxSustainedRate; + u32 wmanIfCmnCpsMaxTrafficBurst; + u32 wmanIfCmnCpsMinReservedRate; + u32 wmanIfCmnCpsToleratedJitter; + u32 wmanIfCmnCpsMaxLatency; + u32 wmanIfCmnCpsFixedVsVariableSduInd; + u32 wmanIfCmnCpsSduSize; + u32 wmanIfCmnCpsSfSchedulingType; + u32 wmanIfCmnCpsArqEnable; + u32 wmanIfCmnCpsArqWindowSize; + u32 wmanIfCmnCpsArqBlockLifetime; + u32 wmanIfCmnCpsArqSyncLossTimeout; + u32 wmanIfCmnCpsArqDeliverInOrder; + u32 wmanIfCmnCpsArqRxPurgeTimeout; + u32 wmanIfCmnCpsArqBlockSize; + u32 wmanIfCmnCpsMinRsvdTolerableRate; + u32 wmanIfCmnCpsReqTxPolicy; + u32 wmanIfCmnSfCsSpecification; + u32 wmanIfCmnCpsTargetSaid; +}; + +struct bcm_mibs_table { + unsigned long ulSFID; + unsigned short usVCID_Value; + unsigned int uiThreshold; + u8 u8TrafficPriority; + bool bValid; + bool bActive; + bool bActivateRequestSent; + u8 u8QueueType; + unsigned int uiMaxBucketSize; + unsigned int uiCurrentQueueDepthOnTarget; + unsigned int uiCurrentBytesOnHost; + unsigned int uiCurrentPacketsOnHost; + unsigned int uiDroppedCountBytes; + unsigned int uiDroppedCountPackets; + unsigned int uiSentBytes; + unsigned int uiSentPackets; + unsigned int uiCurrentDrainRate; + unsigned int uiThisPeriodSentBytes; + u64 liDrainCalculated; + unsigned int uiCurrentTokenCount; + u64 liLastUpdateTokenAt; + unsigned int uiMaxAllowedRate; + unsigned int NumOfPacketsSent; + unsigned char ucDirection; + unsigned short usCID; + struct bcm_mibs_parameters stMibsExtServiceFlowTable; + unsigned int uiCurrentRxRate; + unsigned int uiThisPeriodRxBytes; + unsigned int uiTotalRxBytes; + unsigned int uiTotalTxBytes; +}; + +struct bcm_mibs_dropped_cntrl_msg { + unsigned long cm_responses; + unsigned long cm_control_newdsx_multiclassifier_resp; + unsigned long link_control_resp; + unsigned long status_rsp; + unsigned long stats_pointer_resp; + unsigned long idle_mode_status; + unsigned long auth_ss_host_msg; + unsigned long low_priority_message; +}; + +struct bcm_host_stats_mibs { + struct bcm_mibs_host_info stHostInfo; + struct bcm_mibs_classifier_rule astClassifierTable[MIBS_MAX_CLASSIFIERS]; + struct bcm_mibs_table astSFtable[MIBS_MAX_SERVICEFLOWS]; + struct bcm_mibs_phs_rule astPhsRulesTable[MIBS_MAX_PHSRULES]; + struct bcm_mibs_dropped_cntrl_msg stDroppedAppCntrlMsgs; +}; - LONG PHSModifiedBytes; - ULONG PHSModifiedNumPackets; - ULONG PHSErrorNumPackets; -}S_MIBS_PHS_RULE; - -typedef struct _S_MIBS_EXTSERVICEFLOW_PARAMETERS -{ - UINT32 wmanIfSfid; - UINT32 wmanIfCmnCpsSfState; - UINT32 wmanIfCmnCpsMaxSustainedRate; - UINT32 wmanIfCmnCpsMaxTrafficBurst; - UINT32 wmanIfCmnCpsMinReservedRate; - UINT32 wmanIfCmnCpsToleratedJitter; - UINT32 wmanIfCmnCpsMaxLatency; - UINT32 wmanIfCmnCpsFixedVsVariableSduInd; - UINT32 wmanIfCmnCpsSduSize; - UINT32 wmanIfCmnCpsSfSchedulingType; - UINT32 wmanIfCmnCpsArqEnable; - UINT32 wmanIfCmnCpsArqWindowSize; - UINT32 wmanIfCmnCpsArqBlockLifetime; - UINT32 wmanIfCmnCpsArqSyncLossTimeout; - UINT32 wmanIfCmnCpsArqDeliverInOrder; - UINT32 wmanIfCmnCpsArqRxPurgeTimeout; - UINT32 wmanIfCmnCpsArqBlockSize; - UINT32 wmanIfCmnCpsMinRsvdTolerableRate; - UINT32 wmanIfCmnCpsReqTxPolicy; - UINT32 wmanIfCmnSfCsSpecification; - UINT32 wmanIfCmnCpsTargetSaid; - -}S_MIBS_EXTSERVICEFLOW_PARAMETERS; - - -typedef struct _S_MIBS_SERVICEFLOW_TABLE -{ - //classification extension Rule - ULONG ulSFID; - USHORT usVCID_Value; - UINT uiThreshold; - // This field determines the priority of the SF Queues - B_UINT8 u8TrafficPriority; - - BOOLEAN bValid; - BOOLEAN bActive; - BOOLEAN bActivateRequestSent; - //BE or rtPS - B_UINT8 u8QueueType; - //maximum size of the bucket for the queue - UINT uiMaxBucketSize; - UINT uiCurrentQueueDepthOnTarget; - UINT uiCurrentBytesOnHost; - UINT uiCurrentPacketsOnHost; - UINT uiDroppedCountBytes; - UINT uiDroppedCountPackets; - UINT uiSentBytes; - UINT uiSentPackets; - UINT uiCurrentDrainRate; - UINT uiThisPeriodSentBytes; - LARGE_INTEGER liDrainCalculated; - UINT uiCurrentTokenCount; - LARGE_INTEGER liLastUpdateTokenAt; - UINT uiMaxAllowedRate; - UINT NumOfPacketsSent; - UCHAR ucDirection; - USHORT usCID; - S_MIBS_EXTSERVICEFLOW_PARAMETERS stMibsExtServiceFlowTable; - UINT uiCurrentRxRate; - UINT uiThisPeriodRxBytes; - UINT uiTotalRxBytes; - UINT uiTotalTxBytes; -}S_MIBS_SERVICEFLOW_TABLE; - -typedef struct _S_MIBS_DROPPED_APP_CNTRL_MESSAGES -{ - ULONG cm_responses; - ULONG cm_control_newdsx_multiclassifier_resp; - ULONG link_control_resp; - ULONG status_rsp; - ULONG stats_pointer_resp; - ULONG idle_mode_status; - ULONG auth_ss_host_msg; - ULONG low_priority_message; - -}S_MIBS_DROPPED_APP_CNTRL_MESSAGES; - -typedef struct _S_MIBS_HOST_STATS_MIBS -{ - S_MIBS_HOST_INFO stHostInfo; - S_MIBS_CLASSIFIER_RULE astClassifierTable[MIBS_MAX_CLASSIFIERS]; - S_MIBS_SERVICEFLOW_TABLE astSFtable[MIBS_MAX_SERVICEFLOWS]; - S_MIBS_PHS_RULE astPhsRulesTable[MIBS_MAX_PHSRULES]; - S_MIBS_DROPPED_APP_CNTRL_MESSAGES stDroppedAppCntrlMsgs; -}S_MIBS_HOST_STATS_MIBS; #endif - - diff --git a/drivers/staging/bcm/IPv6Protocol.c b/drivers/staging/bcm/IPv6Protocol.c index 4745ddd62f5..cd160670e02 100644 --- a/drivers/staging/bcm/IPv6Protocol.c +++ b/drivers/staging/bcm/IPv6Protocol.c @@ -1,13 +1,13 @@ #include "headers.h" -static BOOLEAN MatchSrcIpv6Address(struct bcm_classifier_rule *pstClassifierRule, - IPV6Header *pstIpv6Header); -static BOOLEAN MatchDestIpv6Address(struct bcm_classifier_rule *pstClassifierRule, - IPV6Header *pstIpv6Header); -static VOID DumpIpv6Header(IPV6Header *pstIpv6Header); +static bool MatchSrcIpv6Address(struct bcm_classifier_rule *pstClassifierRule, + struct bcm_ipv6_hdr *pstIpv6Header); +static bool MatchDestIpv6Address(struct bcm_classifier_rule *pstClassifierRule, + struct bcm_ipv6_hdr *pstIpv6Header); +static VOID DumpIpv6Header(struct bcm_ipv6_hdr *pstIpv6Header); static UCHAR *GetNextIPV6ChainedHeader(UCHAR **ppucPayload, - UCHAR *pucNextHeader, BOOLEAN *bParseDone, USHORT *pusPayloadLength) + UCHAR *pucNextHeader, bool *bParseDone, USHORT *pusPayloadLength) { UCHAR *pucRetHeaderPtr = NULL; UCHAR *pucPayloadPtr = NULL; @@ -29,7 +29,7 @@ static UCHAR *GetNextIPV6ChainedHeader(UCHAR **ppucPayload, } /* Get the Nextt Header Type */ - *bParseDone = FALSE; + *bParseDone = false; switch (*pucNextHeader) { @@ -38,17 +38,17 @@ static UCHAR *GetNextIPV6ChainedHeader(UCHAR **ppucPayload, BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 HopByHop Header"); - usNextHeaderOffset += sizeof(IPV6HopByHopOptionsHeader); + usNextHeaderOffset += sizeof(struct bcm_ipv6_options_hdr); } break; case IPV6HDR_TYPE_ROUTING: { - IPV6RoutingHeader *pstIpv6RoutingHeader; + struct bcm_ipv6_routing_hdr *pstIpv6RoutingHeader; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Routing Header"); - pstIpv6RoutingHeader = (IPV6RoutingHeader *)pucPayloadPtr; - usNextHeaderOffset += sizeof(IPV6RoutingHeader); + pstIpv6RoutingHeader = (struct bcm_ipv6_routing_hdr *)pucPayloadPtr; + usNextHeaderOffset += sizeof(struct bcm_ipv6_routing_hdr); usNextHeaderOffset += pstIpv6RoutingHeader->ucNumAddresses * IPV6_ADDRESS_SIZEINBYTES; } @@ -58,25 +58,25 @@ static UCHAR *GetNextIPV6ChainedHeader(UCHAR **ppucPayload, BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Fragmentation Header"); - usNextHeaderOffset += sizeof(IPV6FragmentHeader); + usNextHeaderOffset += sizeof(struct bcm_ipv6_fragment_hdr); } break; case IPV6HDR_TYPE_DESTOPTS: { - IPV6DestOptionsHeader *pstIpv6DestOptsHdr = (IPV6DestOptionsHeader *)pucPayloadPtr; + struct bcm_ipv6_dest_options_hdr *pstIpv6DestOptsHdr = (struct bcm_ipv6_dest_options_hdr *)pucPayloadPtr; int nTotalOptions = pstIpv6DestOptsHdr->ucHdrExtLen; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 DestOpts Header Header"); - usNextHeaderOffset += sizeof(IPV6DestOptionsHeader); + usNextHeaderOffset += sizeof(struct bcm_ipv6_dest_options_hdr); usNextHeaderOffset += nTotalOptions * IPV6_DESTOPTS_HDR_OPTIONSIZE ; } break; case IPV6HDR_TYPE_AUTHENTICATION: { - IPV6AuthenticationHeader *pstIpv6AuthHdr = (IPV6AuthenticationHeader *)pucPayloadPtr; + struct bcm_ipv6_authentication_hdr *pstIpv6AuthHdr = (struct bcm_ipv6_authentication_hdr *)pucPayloadPtr; int nHdrLen = pstIpv6AuthHdr->ucLength; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, @@ -124,7 +124,7 @@ static UCHAR *GetNextIPV6ChainedHeader(UCHAR **ppucPayload, } - if (*bParseDone == FALSE) { + if (*bParseDone == false) { if (*pusPayloadLength <= usNextHeaderOffset) { *bParseDone = TRUE; } else { @@ -144,7 +144,7 @@ static UCHAR GetIpv6ProtocolPorts(UCHAR *pucPayload, USHORT *pusSrcPort, USHORT *pusDestPort, USHORT usPayloadLength, UCHAR ucNextHeader) { UCHAR *pIpv6HdrScanContext = pucPayload; - BOOLEAN bDone = FALSE; + bool bDone = false; UCHAR ucHeaderType = 0; UCHAR *pucNextHeader = NULL; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); @@ -186,13 +186,13 @@ USHORT IpVersion6(struct bcm_mini_adapter *Adapter, PVOID pcIpHeader, USHORT ushDestPort = 0; USHORT ushSrcPort = 0; UCHAR ucNextProtocolAboveIP = 0; - IPV6Header *pstIpv6Header = NULL; - BOOLEAN bClassificationSucceed = FALSE; + struct bcm_ipv6_hdr *pstIpv6Header = NULL; + bool bClassificationSucceed = false; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "IpVersion6 ==========>\n"); - pstIpv6Header = (IPV6Header *)pcIpHeader; + pstIpv6Header = pcIpHeader; DumpIpv6Header(pstIpv6Header); @@ -200,7 +200,7 @@ USHORT IpVersion6(struct bcm_mini_adapter *Adapter, PVOID pcIpHeader, * Try to get the next higher layer protocol * and the Ports Nos if TCP or UDP */ - ucNextProtocolAboveIP = GetIpv6ProtocolPorts((UCHAR *)(pcIpHeader + sizeof(IPV6Header)), + ucNextProtocolAboveIP = GetIpv6ProtocolPorts((UCHAR *)(pcIpHeader + sizeof(struct bcm_ipv6_hdr)), &ushSrcPort, &ushDestPort, pstIpv6Header->usPayloadLength, @@ -277,10 +277,10 @@ USHORT IpVersion6(struct bcm_mini_adapter *Adapter, PVOID pcIpHeader, INT iMatchedSFQueueIndex = 0; iMatchedSFQueueIndex = SearchSfid(Adapter, pstClassifierRule->ulSFID); if (iMatchedSFQueueIndex >= NO_OF_QUEUES) { - bClassificationSucceed = FALSE; + bClassificationSucceed = false; } else { - if (Adapter->PackInfo[iMatchedSFQueueIndex].bActive == FALSE) - bClassificationSucceed = FALSE; + if (Adapter->PackInfo[iMatchedSFQueueIndex].bActive == false) + bClassificationSucceed = false; } } @@ -288,8 +288,8 @@ USHORT IpVersion6(struct bcm_mini_adapter *Adapter, PVOID pcIpHeader, } -static BOOLEAN MatchSrcIpv6Address(struct bcm_classifier_rule *pstClassifierRule, - IPV6Header *pstIpv6Header) +static bool MatchSrcIpv6Address(struct bcm_classifier_rule *pstClassifierRule, + struct bcm_ipv6_hdr *pstIpv6Header) { UINT uiLoopIndex = 0; UINT uiIpv6AddIndex = 0; @@ -341,11 +341,11 @@ static BOOLEAN MatchSrcIpv6Address(struct bcm_classifier_rule *pstClassifierRule } } } - return FALSE; + return false; } -static BOOLEAN MatchDestIpv6Address(struct bcm_classifier_rule *pstClassifierRule, - IPV6Header *pstIpv6Header) +static bool MatchDestIpv6Address(struct bcm_classifier_rule *pstClassifierRule, + struct bcm_ipv6_hdr *pstIpv6Header) { UINT uiLoopIndex = 0; UINT uiIpv6AddIndex = 0; @@ -398,7 +398,7 @@ static BOOLEAN MatchDestIpv6Address(struct bcm_classifier_rule *pstClassifierRul } } } - return FALSE; + return false; } @@ -414,7 +414,7 @@ VOID DumpIpv6Address(ULONG *puIpv6Address) } -static VOID DumpIpv6Header(IPV6Header *pstIpv6Header) +static VOID DumpIpv6Header(struct bcm_ipv6_hdr *pstIpv6Header) { UCHAR ucVersion; UCHAR ucPrio; diff --git a/drivers/staging/bcm/IPv6ProtocolHdr.h b/drivers/staging/bcm/IPv6ProtocolHdr.h index 8ba88a5b081..96b36a579af 100644 --- a/drivers/staging/bcm/IPv6ProtocolHdr.h +++ b/drivers/staging/bcm/IPv6ProtocolHdr.h @@ -1,7 +1,6 @@ #ifndef _IPV6_PROTOCOL_DEFINES_ #define _IPV6_PROTOCOL_DEFINES_ - #define IPV6HDR_TYPE_HOPBYHOP 0x0 #define IPV6HDR_TYPE_ROUTING 0x2B #define IPV6HDR_TYPE_FRAGMENTATION 0x2C @@ -10,107 +9,77 @@ #define IPV6HDR_TYPE_ENCRYPTEDSECURITYPAYLOAD 0x34 #define MASK_IPV6_CS_SPEC 0x2 - -#define TCP_HEADER_TYPE 0x6 -#define UDP_HEADER_TYPE 0x11 +#define TCP_HEADER_TYPE 0x6 +#define UDP_HEADER_TYPE 0x11 #define IPV6_ICMP_HDR_TYPE 0x2 #define IPV6_FLOWLABEL_BITOFFSET 9 #define IPV6_MAX_CHAINEDHDR_BUFFBYTES 0x64 /* -// Size of Dest Options field of Destinations Options Header -// in bytes. -*/ + * Size of Dest Options field of Destinations Options Header + * in bytes. + */ #define IPV6_DESTOPTS_HDR_OPTIONSIZE 0x8 -//typedef unsigned char UCHAR; -//typedef unsigned short USHORT; -//typedef unsigned long int ULONG; - -typedef struct IPV6HeaderFormatTag -{ - UCHAR ucVersionPrio; - UCHAR aucFlowLabel[3]; - USHORT usPayloadLength; - UCHAR ucNextHeader; - UCHAR ucHopLimit; - ULONG ulSrcIpAddress[4]; - ULONG ulDestIpAddress[4]; -}IPV6Header; - -typedef struct IPV6RoutingHeaderFormatTag -{ - UCHAR ucNextHeader; - UCHAR ucRoutingType; - UCHAR ucNumAddresses; - UCHAR ucNextAddress; - ULONG ulReserved; - //UCHAR aucAddressList[0]; - -}IPV6RoutingHeader; - -typedef struct IPV6FragmentHeaderFormatTag -{ - UCHAR ucNextHeader; - UCHAR ucReserved; - USHORT usFragmentOffset; - ULONG ulIdentification; -}IPV6FragmentHeader; - -typedef struct IPV6DestOptionsHeaderFormatTag -{ - UCHAR ucNextHeader; - UCHAR ucHdrExtLen; - UCHAR ucDestOptions[6]; - //UCHAR udExtDestOptions[0]; -}IPV6DestOptionsHeader; - -typedef struct IPV6HopByHopOptionsHeaderFormatTag -{ - UCHAR ucNextHeader; - UCHAR ucMisc[3]; - ULONG ulJumboPayloadLen; -}IPV6HopByHopOptionsHeader; - -typedef struct IPV6AuthenticationHeaderFormatTag -{ - UCHAR ucNextHeader; - UCHAR ucLength; - USHORT usReserved; - ULONG ulSecurityParametersIndex; - //UCHAR ucAuthenticationData[0]; - -}IPV6AuthenticationHeader; - -typedef struct IPV6IcmpHeaderFormatTag -{ - UCHAR ucType; - UCHAR ucCode; - USHORT usChecksum; - //UCHAR ucIcmpMsg[0]; - -}IPV6IcmpHeader; - -typedef enum _E_IPADDR_CONTEXT -{ +struct bcm_ipv6_hdr { + unsigned char ucVersionPrio; + unsigned char aucFlowLabel[3]; + unsigned short usPayloadLength; + unsigned char ucNextHeader; + unsigned char ucHopLimit; + unsigned long ulSrcIpAddress[4]; + unsigned long ulDestIpAddress[4]; +}; + +struct bcm_ipv6_routing_hdr { + unsigned char ucNextHeader; + unsigned char ucRoutingType; + unsigned char ucNumAddresses; + unsigned char ucNextAddress; + unsigned long ulReserved; +}; + +struct bcm_ipv6_fragment_hdr { + unsigned char ucNextHeader; + unsigned char ucReserved; + unsigned short usFragmentOffset; + unsigned long ulIdentification; +}; + +struct bcm_ipv6_dest_options_hdr { + unsigned char ucNextHeader; + unsigned char ucHdrExtLen; + unsigned char ucDestOptions[6]; +}; + +struct bcm_ipv6_options_hdr { + unsigned char ucNextHeader; + unsigned char ucMisc[3]; + unsigned long ulJumboPayloadLen; +}; + +struct bcm_ipv6_authentication_hdr { + unsigned char ucNextHeader; + unsigned char ucLength; + unsigned short usReserved; + unsigned long ulSecurityParametersIndex; +}; + +enum bcm_ipaddr_context { eSrcIpAddress, eDestIpAddress +}; -}E_IPADDR_CONTEXT; - - - -//Function Prototypes - -USHORT IpVersion6(struct bcm_mini_adapter *Adapter, /**< Pointer to the driver control structure */ - PVOID pcIpHeader, /**<Pointer to the IP Hdr of the packet*/ - struct bcm_classifier_rule *pstClassifierRule ); +/* Function Prototypes */ -VOID DumpIpv6Address(ULONG *puIpv6Address); +unsigned short IpVersion6(struct bcm_mini_adapter *Adapter, /* < Pointer to the driver control structure */ + void *pcIpHeader, /* <Pointer to the IP Hdr of the packet */ + struct bcm_classifier_rule *pstClassifierRule); -extern BOOLEAN MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort); -extern BOOLEAN MatchDestPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort); -extern BOOLEAN MatchProtocol(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucProtocol); +void DumpIpv6Address(unsigned long *puIpv6Address); +extern bool MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule, unsigned short ushSrcPort); +extern bool MatchDestPort(struct bcm_classifier_rule *pstClassifierRule, unsigned short ushSrcPort); +extern bool MatchProtocol(struct bcm_classifier_rule *pstClassifierRule, unsigned char ucProtocol); #endif diff --git a/drivers/staging/bcm/InterfaceAdapter.h b/drivers/staging/bcm/InterfaceAdapter.h index 4607c265d98..06a6b18bca4 100644 --- a/drivers/staging/bcm/InterfaceAdapter.h +++ b/drivers/staging/bcm/InterfaceAdapter.h @@ -1,97 +1,79 @@ #ifndef _INTERFACE_ADAPTER_H #define _INTERFACE_ADAPTER_H -typedef struct _BULK_ENDP_IN -{ - PCHAR bulk_in_buffer; - size_t bulk_in_size; - UCHAR bulk_in_endpointAddr; - UINT bulk_in_pipe; -}BULK_ENDP_IN, *PBULK_ENDP_IN; - - -typedef struct _BULK_ENDP_OUT -{ - UCHAR bulk_out_buffer; - size_t bulk_out_size; - UCHAR bulk_out_endpointAddr; - UINT bulk_out_pipe; - //this is used when int out endpoint is used as bulk out end point - UCHAR int_out_interval; -}BULK_ENDP_OUT, *PBULK_ENDP_OUT; - -typedef struct _INTR_ENDP_IN -{ - PCHAR int_in_buffer; - size_t int_in_size; - UCHAR int_in_endpointAddr; - UCHAR int_in_interval; - UINT int_in_pipe; -}INTR_ENDP_IN, *PINTR_ENDP_IN; - -typedef struct _INTR_ENDP_OUT -{ - PCHAR int_out_buffer; - size_t int_out_size; - UCHAR int_out_endpointAddr; - UCHAR int_out_interval; - UINT int_out_pipe; -}INTR_ENDP_OUT, *PINTR_ENDP_OUT; - - -typedef struct _USB_TCB -{ +struct bcm_bulk_endpoint_in { + char *bulk_in_buffer; + size_t bulk_in_size; + unsigned char bulk_in_endpointAddr; + unsigned int bulk_in_pipe; +}; + +struct bcm_bulk_endpoint_out { + unsigned char bulk_out_buffer; + size_t bulk_out_size; + unsigned char bulk_out_endpointAddr; + unsigned int bulk_out_pipe; + /* this is used when int out endpoint is used as bulk out end point */ + unsigned char int_out_interval; +}; + +struct bcm_intr_endpoint_in { + char *int_in_buffer; + size_t int_in_size; + unsigned char int_in_endpointAddr; + unsigned char int_in_interval; + unsigned int int_in_pipe; +}; + +struct bcm_intr_endpoint_out { + char *int_out_buffer; + size_t int_out_size; + unsigned char int_out_endpointAddr; + unsigned char int_out_interval; + unsigned int int_out_pipe; +}; + +struct bcm_usb_tcb { struct urb *urb; - PVOID psIntfAdapter; - BOOLEAN bUsed; -}USB_TCB, *PUSB_TCB; + void *psIntfAdapter; + bool bUsed; +}; - -typedef struct _USB_RCB -{ +struct bcm_usb_rcb { struct urb *urb; - PVOID psIntfAdapter; - BOOLEAN bUsed; -}USB_RCB, *PUSB_RCB; + void *psIntfAdapter; + bool bUsed; +}; /* -//This is the interface specific Sub-Adapter -//Structure. -*/ -typedef struct _S_INTERFACE_ADAPTER -{ - struct usb_device * udev; - struct usb_interface * interface; - + * This is the interface specific Sub-Adapter + * Structure. + */ +struct bcm_interface_adapter { + struct usb_device *udev; + struct usb_interface *interface; /* Bulk endpoint in info */ - BULK_ENDP_IN sBulkIn; + struct bcm_bulk_endpoint_in sBulkIn; /* Bulk endpoint out info */ - BULK_ENDP_OUT sBulkOut; + struct bcm_bulk_endpoint_out sBulkOut; /* Interrupt endpoint in info */ - INTR_ENDP_IN sIntrIn; + struct bcm_intr_endpoint_in sIntrIn; /* Interrupt endpoint out info */ - INTR_ENDP_OUT sIntrOut; - - - - ULONG ulInterruptData[2]; - + struct bcm_intr_endpoint_out sIntrOut; + unsigned long ulInterruptData[2]; struct urb *psInterruptUrb; - - USB_TCB asUsbTcb[MAXIMUM_USB_TCB]; - USB_RCB asUsbRcb[MAXIMUM_USB_RCB]; - atomic_t uNumTcbUsed; - atomic_t uCurrTcb; - atomic_t uNumRcbUsed; - atomic_t uCurrRcb; - + struct bcm_usb_tcb asUsbTcb[MAXIMUM_USB_TCB]; + struct bcm_usb_rcb asUsbRcb[MAXIMUM_USB_RCB]; + atomic_t uNumTcbUsed; + atomic_t uCurrTcb; + atomic_t uNumRcbUsed; + atomic_t uCurrRcb; struct bcm_mini_adapter *psAdapter; - BOOLEAN bFlashBoot; - BOOLEAN bHighSpeedDevice ; - - BOOLEAN bSuspended; - BOOLEAN bPreparingForBusSuspend; + bool bFlashBoot; + bool bHighSpeedDevice; + bool bSuspended; + bool bPreparingForBusSuspend; struct work_struct usbSuspendWork; -}S_INTERFACE_ADAPTER,*PS_INTERFACE_ADAPTER; +}; #endif diff --git a/drivers/staging/bcm/InterfaceDld.c b/drivers/staging/bcm/InterfaceDld.c index 3a89e33733e..e1925bdc127 100644 --- a/drivers/staging/bcm/InterfaceDld.c +++ b/drivers/staging/bcm/InterfaceDld.c @@ -6,7 +6,7 @@ int InterfaceFileDownload(PVOID arg, struct file *flp, unsigned int on_chip_loc) mm_segment_t oldfs = {0}; int errno = 0, len = 0; /* ,is_config_file = 0 */ loff_t pos = 0; - PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)arg; + struct bcm_interface_adapter *psIntfAdapter = arg; /* struct bcm_mini_adapter *Adapter = psIntfAdapter->psAdapter; */ char *buff = kmalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_KERNEL); @@ -20,18 +20,10 @@ int InterfaceFileDownload(PVOID arg, struct file *flp, unsigned int on_chip_loc) MAX_TRANSFER_CTRL_BYTE_USB, &pos); set_fs(oldfs); if (len <= 0) { - if (len < 0) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, - DBG_TYPE_INITEXIT, MP_INIT, - DBG_LVL_ALL, "len < 0"); + if (len < 0) errno = len; - } else { + else errno = 0; - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, - DBG_TYPE_INITEXIT, MP_INIT, - DBG_LVL_ALL, - "Got end of file!"); - } break; } /* BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_INITEXIT, MP_INIT, @@ -39,12 +31,8 @@ int InterfaceFileDownload(PVOID arg, struct file *flp, unsigned int on_chip_loc) * MAX_TRANSFER_CTRL_BYTE_USB); */ errno = InterfaceWRM(psIntfAdapter, on_chip_loc, buff, len); - if (errno) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, - DBG_TYPE_PRINTK, 0, 0, - "WRM Failed! status: %d", errno); + if (errno) break; - } on_chip_loc += MAX_TRANSFER_CTRL_BYTE_USB; } @@ -52,7 +40,8 @@ int InterfaceFileDownload(PVOID arg, struct file *flp, unsigned int on_chip_loc) return errno; } -int InterfaceFileReadbackFromChip(PVOID arg, struct file *flp, unsigned int on_chip_loc) +int InterfaceFileReadbackFromChip(PVOID arg, struct file *flp, + unsigned int on_chip_loc) { char *buff, *buff_readback; unsigned int reg = 0; @@ -61,11 +50,11 @@ int InterfaceFileReadbackFromChip(PVOID arg, struct file *flp, unsigned int on_c loff_t pos = 0; static int fw_down; INT Status = STATUS_SUCCESS; - PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)arg; + 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); @@ -75,37 +64,31 @@ int InterfaceFileReadbackFromChip(PVOID arg, struct file *flp, unsigned int on_c 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()); - len = vfs_read(flp, (void __force __user *)buff, MAX_TRANSFER_CTRL_BYTE_USB, &pos); + len = vfs_read(flp, (void __force __user *)buff, + MAX_TRANSFER_CTRL_BYTE_USB, &pos); set_fs(oldfs); fw_down++; if (len <= 0) { - if (len < 0) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "len < 0"); + if (len < 0) errno = len; - } else { + else errno = 0; - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Got end of file!"); - } break; } - bytes = InterfaceRDM(psIntfAdapter, on_chip_loc, buff_readback, len); + bytes = InterfaceRDM(psIntfAdapter, on_chip_loc, + buff_readback, len); if (bytes < 0) { Status = bytes; - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "RDM of len %d Failed! %d", len, reg); goto exit; } reg++; if ((len-sizeof(unsigned int)) < 4) { if (memcmp(buff_readback, buff, len)) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Firmware Download is not proper %d", fw_down); - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Length is: %d", len); Status = -EIO; goto exit; } @@ -113,10 +96,8 @@ int InterfaceFileReadbackFromChip(PVOID arg, struct file *flp, unsigned int on_c len -= 4; while (len) { - if (*(unsigned int *)&buff_readback[len] != *(unsigned int *)&buff[len]) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Firmware Download is not proper %d", fw_down); - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Val from Binary %x, Val From Read Back %x ", *(unsigned int *)&buff[len], *(unsigned int*)&buff_readback[len]); - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "len =%x!!!", len); + if (*(unsigned int *)&buff_readback[len] != + *(unsigned int *)&buff[len]) { Status = -EIO; goto exit; } @@ -132,21 +113,25 @@ exit: return Status; } -static int bcm_download_config_file(struct bcm_mini_adapter *Adapter, struct bcm_firmware_info *psFwInfo) +static int bcm_download_config_file(struct bcm_mini_adapter *Adapter, + struct bcm_firmware_info *psFwInfo) { int retval = STATUS_SUCCESS; B_UINT32 value = 0; if (Adapter->pstargetparams == NULL) { - Adapter->pstargetparams = kmalloc(sizeof(STARGETPARAMS), GFP_KERNEL); + Adapter->pstargetparams = + kmalloc(sizeof(struct bcm_target_params), GFP_KERNEL); if (Adapter->pstargetparams == NULL) return -ENOMEM; } - if (psFwInfo->u32FirmwareLength != sizeof(STARGETPARAMS)) + if (psFwInfo->u32FirmwareLength != sizeof(struct bcm_target_params)) return -EIO; - retval = copy_from_user(Adapter->pstargetparams, psFwInfo->pvMappedFirmwareAddress, psFwInfo->u32FirmwareLength); + retval = copy_from_user(Adapter->pstargetparams, + psFwInfo->pvMappedFirmwareAddress, + psFwInfo->u32FirmwareLength); if (retval) { kfree(Adapter->pstargetparams); Adapter->pstargetparams = NULL; @@ -160,76 +145,54 @@ static int bcm_download_config_file(struct bcm_mini_adapter *Adapter, struct bcm BcmInitNVM(Adapter); retval = InitLedSettings(Adapter); - if (retval) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "INIT LED Failed\n"); + if (retval) return retval; - } - if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { - Adapter->LEDInfo.bLedInitDone = FALSE; + if (Adapter->LEDInfo.led_thread_running & + BCM_LED_THREAD_RUNNING_ACTIVELY) { + Adapter->LEDInfo.bLedInitDone = false; Adapter->DriverState = DRIVER_INIT; wake_up(&Adapter->LEDInfo.notify_led_event); } - if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { + if (Adapter->LEDInfo.led_thread_running & + BCM_LED_THREAD_RUNNING_ACTIVELY) { Adapter->DriverState = FW_DOWNLOAD; wake_up(&Adapter->LEDInfo.notify_led_event); } /* Initialize the DDR Controller */ retval = ddr_init(Adapter); - if (retval) { - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "DDR Init Failed\n"); + if (retval) return retval; - } value = 0; - wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 4, &value, sizeof(value)); - wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 8, &value, sizeof(value)); + wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 4, + &value, sizeof(value)); + wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 8, + &value, sizeof(value)); if (Adapter->eNVMType == NVM_FLASH) { retval = PropagateCalParamsFromFlashToMemory(Adapter); - if (retval) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "propagaion of cal param failed with status :%d", retval); + if (retval) return retval; - } } - retval = buffDnldVerify(Adapter, (PUCHAR)Adapter->pstargetparams, sizeof(STARGETPARAMS), CONFIG_BEGIN_ADDR); + retval = buffDnldVerify(Adapter, (PUCHAR)Adapter->pstargetparams, + sizeof(struct bcm_target_params), CONFIG_BEGIN_ADDR); if (retval) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "configuration file not downloaded properly"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, + MP_INIT, DBG_LVL_ALL, + "configuration file not downloaded properly"); else Adapter->bCfgDownloaded = TRUE; return retval; } -static int bcm_compare_buff_contents(unsigned char *readbackbuff, unsigned char *buff, unsigned int len) -{ - int retval = STATUS_SUCCESS; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - if ((len-sizeof(unsigned int)) < 4) { - if (memcmp(readbackbuff , buff, len)) - retval = -EINVAL; - } else { - len -= 4; - - while (len) { - if (*(unsigned int *)&readbackbuff[len] != *(unsigned int *)&buff[len]) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Firmware Download is not proper"); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Val from Binary %x, Val From Read Back %x ", *(unsigned int *)&buff[len], *(unsigned int*)&readbackbuff[len]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "len =%x!!!", len); - retval = -EINVAL; - break; - } - len -= 4; - } - } - return retval; -} - -int bcm_ioctl_fw_download(struct bcm_mini_adapter *Adapter, struct bcm_firmware_info *psFwInfo) +int bcm_ioctl_fw_download(struct bcm_mini_adapter *Adapter, + struct bcm_firmware_info *psFwInfo) { int retval = STATUS_SUCCESS; PUCHAR buff = NULL; @@ -238,10 +201,10 @@ int bcm_ioctl_fw_download(struct bcm_mini_adapter *Adapter, struct bcm_firmware_ * Firmware. Check for the Config file to be first to be sent from the * Application */ - atomic_set(&Adapter->uiMBupdate, FALSE); - if (!Adapter->bCfgDownloaded && psFwInfo->u32StartingAddress != CONFIG_BEGIN_ADDR) { + atomic_set(&Adapter->uiMBupdate, false); + if (!Adapter->bCfgDownloaded && + psFwInfo->u32StartingAddress != CONFIG_BEGIN_ADDR) { /* Can't Download Firmware. */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Download the config File first\n"); return -EINVAL; } @@ -250,14 +213,13 @@ int bcm_ioctl_fw_download(struct bcm_mini_adapter *Adapter, struct bcm_firmware_ retval = bcm_download_config_file(Adapter, psFwInfo); } else { buff = kzalloc(psFwInfo->u32FirmwareLength, GFP_KERNEL); - if (buff == NULL) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed in allocation memory"); + if (buff == NULL) return -ENOMEM; - } - retval = copy_from_user(buff, psFwInfo->pvMappedFirmwareAddress, psFwInfo->u32FirmwareLength); + retval = copy_from_user(buff, + psFwInfo->pvMappedFirmwareAddress, + psFwInfo->u32FirmwareLength); if (retval != STATUS_SUCCESS) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "copying buffer from user space failed"); retval = -EFAULT; goto error; } @@ -267,10 +229,8 @@ int bcm_ioctl_fw_download(struct bcm_mini_adapter *Adapter, struct bcm_firmware_ psFwInfo->u32FirmwareLength, psFwInfo->u32StartingAddress); - if (retval != STATUS_SUCCESS) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "f/w download failed status :%d", retval); + if (retval != STATUS_SUCCESS) goto error; - } } error: @@ -278,7 +238,9 @@ error: return retval; } -static INT buffDnld(struct bcm_mini_adapter *Adapter, PUCHAR mappedbuffer, UINT u32FirmwareLength, ULONG u32StartingAddress) +static INT buffDnld(struct bcm_mini_adapter *Adapter, + PUCHAR mappedbuffer, UINT u32FirmwareLength, + ULONG u32StartingAddress) { unsigned int len = 0; int retval = STATUS_SUCCESS; @@ -288,10 +250,8 @@ static INT buffDnld(struct bcm_mini_adapter *Adapter, PUCHAR mappedbuffer, UINT len = MIN_VAL(u32FirmwareLength, MAX_TRANSFER_CTRL_BYTE_USB); retval = wrm(Adapter, u32StartingAddress, mappedbuffer, len); - if (retval) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "wrm failed with status :%d", retval); + if (retval) break; - } u32StartingAddress += len; u32FirmwareLength -= len; mappedbuffer += len; @@ -299,17 +259,17 @@ static INT buffDnld(struct bcm_mini_adapter *Adapter, PUCHAR mappedbuffer, UINT return retval; } -static INT buffRdbkVerify(struct bcm_mini_adapter *Adapter, PUCHAR mappedbuffer, UINT u32FirmwareLength, ULONG u32StartingAddress) +static INT buffRdbkVerify(struct bcm_mini_adapter *Adapter, + PUCHAR mappedbuffer, UINT u32FirmwareLength, + ULONG u32StartingAddress) { UINT len = u32FirmwareLength; INT retval = STATUS_SUCCESS; PUCHAR readbackbuff = kzalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_KERNEL); int bytes; - if (NULL == readbackbuff) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "MEMORY ALLOCATION FAILED"); + if (NULL == readbackbuff) return -ENOMEM; - } while (u32FirmwareLength && !retval) { len = MIN_VAL(u32FirmwareLength, MAX_TRANSFER_CTRL_BYTE_USB); @@ -317,13 +277,14 @@ static INT buffRdbkVerify(struct bcm_mini_adapter *Adapter, PUCHAR mappedbuffer, if (bytes < 0) { retval = bytes; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "rdm failed with status %d", retval); break; } - retval = bcm_compare_buff_contents(readbackbuff, mappedbuffer, len); - if (STATUS_SUCCESS != retval) - break; + if (memcmp(readbackbuff, mappedbuffer, len) != 0) { + pr_err("%s() failed. The firmware doesn't match what was written", + __func__); + retval = -EIO; + } u32StartingAddress += len; u32FirmwareLength -= len; @@ -334,21 +295,22 @@ static INT buffRdbkVerify(struct bcm_mini_adapter *Adapter, PUCHAR mappedbuffer, return retval; } -INT buffDnldVerify(struct bcm_mini_adapter *Adapter, unsigned char *mappedbuffer, unsigned int u32FirmwareLength, unsigned long u32StartingAddress) +INT buffDnldVerify(struct bcm_mini_adapter *Adapter, + unsigned char *mappedbuffer, + unsigned int u32FirmwareLength, + unsigned long u32StartingAddress) { INT status = STATUS_SUCCESS; - status = buffDnld(Adapter, mappedbuffer, u32FirmwareLength, u32StartingAddress); - if (status != STATUS_SUCCESS) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Buffer download failed"); + status = buffDnld(Adapter, mappedbuffer, + u32FirmwareLength, u32StartingAddress); + if (status != STATUS_SUCCESS) goto error; - } - status = buffRdbkVerify(Adapter, mappedbuffer, u32FirmwareLength, u32StartingAddress); - if (status != STATUS_SUCCESS) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Buffer readback verifier failed"); + status = buffRdbkVerify(Adapter, mappedbuffer, + u32FirmwareLength, u32StartingAddress); + if (status != STATUS_SUCCESS) goto error; - } error: return status; } diff --git a/drivers/staging/bcm/InterfaceIdleMode.c b/drivers/staging/bcm/InterfaceIdleMode.c index 4f2f490921e..c84ee494f55 100644 --- a/drivers/staging/bcm/InterfaceIdleMode.c +++ b/drivers/staging/bcm/InterfaceIdleMode.c @@ -1,32 +1,37 @@ #include "headers.h" /* -Function: InterfaceIdleModeWakeup +Function: InterfaceIdleModeWakeup -Description: This is the hardware specific Function for waking up HW device from Idle mode. - A software abort pattern is written to the device to wake it and necessary power state - transitions from host are performed here. +Description: This is the hardware specific Function for + waking up HW device from Idle mode. + A software abort pattern is written to the + device to wake it and necessary power state + transitions from host are performed here. -Input parameters: IN struct bcm_mini_adapter *Adapter - Miniport Adapter Context +Input parameters: IN struct bcm_mini_adapter *Adapter + - Miniport Adapter Context - -Return: BCM_STATUS_SUCCESS - If Wakeup of the HW Interface was successful. - Other - If an error occurred. +Return: BCM_STATUS_SUCCESS - If Wakeup of the HW Interface + was successful. + Other - If an error occurred. */ - /* -Function: InterfaceIdleModeRespond +Function: InterfaceIdleModeRespond -Description: This is the hardware specific Function for responding to Idle mode request from target. - Necessary power state transitions from host for idle mode or other device specific - initializations are performed here. +Description: This is the hardware specific Function for + responding to Idle mode request from target. + Necessary power state transitions from host for + idle mode or other device specific initializations + are performed here. -Input parameters: IN struct bcm_mini_adapter * Adapter - Miniport Adapter Context +Input parameters: IN struct bcm_mini_adapter * Adapter + - Miniport Adapter Context - -Return: BCM_STATUS_SUCCESS - If Idle mode response related HW configuration was successful. - Other - If an error occurred. +Return: BCM_STATUS_SUCCESS - If Idle mode response related + HW configuration was successful. + Other - If an error occurred. */ /* @@ -36,231 +41,198 @@ this value will be at address bfc02fa4.just before value d0ea1dle. Set time value by writing at bfc02f98 7d0 checking the Ack timer expire on kannon by running command -d qcslog .. if it shows e means host has not send response to f/w with in 200 ms. Response should be +d qcslog .. if it shows e means host has not send response +to f/w with in 200 ms. Response should be send to f/w with in 200 ms after the Idle/Shutdown req issued */ -int InterfaceIdleModeRespond(struct bcm_mini_adapter *Adapter, unsigned int* puiBuffer) +int InterfaceIdleModeRespond(struct bcm_mini_adapter *Adapter, + unsigned int *puiBuffer) { int status = STATUS_SUCCESS; unsigned int uiRegRead = 0; int bytes; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"SubType of Message :0x%X", ntohl(*puiBuffer)); - - if(ntohl(*puiBuffer) == GO_TO_IDLE_MODE_PAYLOAD) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL," Got GO_TO_IDLE_MODE_PAYLOAD(210) Msg Subtype"); - if(ntohl(*(puiBuffer+1)) == 0 ) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"Got IDLE MODE WAKE UP Response From F/W"); + if (ntohl(*puiBuffer) == GO_TO_IDLE_MODE_PAYLOAD) { + if (ntohl(*(puiBuffer+1)) == 0) { - status = wrmalt (Adapter,SW_ABORT_IDLEMODE_LOC, &uiRegRead, sizeof(uiRegRead)); - if(status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "wrm failed while clearing Idle Mode Reg"); + status = wrmalt(Adapter, SW_ABORT_IDLEMODE_LOC, + &uiRegRead, sizeof(uiRegRead)); + if (status) return status; - } - if(Adapter->ulPowerSaveMode == DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING) - { - uiRegRead = 0x00000000 ; - status = wrmalt (Adapter,DEBUG_INTERRUPT_GENERATOR_REGISTOR, &uiRegRead, sizeof(uiRegRead)); - if(status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "wrm failed while clearing Idle Mode Reg"); + if (Adapter->ulPowerSaveMode == + DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING) { + uiRegRead = 0x00000000; + status = wrmalt(Adapter, + DEBUG_INTERRUPT_GENERATOR_REGISTOR, + &uiRegRead, sizeof(uiRegRead)); + if (status) return status; - } } - //Below Register should not br read in case of Manual and Protocol Idle mode. - else if(Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE) - { - //clear on read Register - bytes = rdmalt(Adapter, DEVICE_INT_OUT_EP_REG0, &uiRegRead, sizeof(uiRegRead)); + /* Below Register should not br read in case of + * Manual and Protocol Idle mode */ + else if (Adapter->ulPowerSaveMode != + DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE) { + /* clear on read Register */ + bytes = rdmalt(Adapter, DEVICE_INT_OUT_EP_REG0, + &uiRegRead, sizeof(uiRegRead)); if (bytes < 0) { status = bytes; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "rdm failed while clearing H/W Abort Reg0"); return status; } - //clear on read Register - bytes = rdmalt(Adapter, DEVICE_INT_OUT_EP_REG1, &uiRegRead, sizeof(uiRegRead)); + /* clear on read Register */ + bytes = rdmalt(Adapter, DEVICE_INT_OUT_EP_REG1, + &uiRegRead, sizeof(uiRegRead)); if (bytes < 0) { status = bytes; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "rdm failed while clearing H/W Abort Reg1"); return status; } } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "Device Up from Idle Mode"); - // Set Idle Mode Flag to False and Clear IdleMode reg. - Adapter->IdleMode = FALSE; - Adapter->bTriedToWakeUpFromlowPowerMode = FALSE; + /* Set Idle Mode Flag to False and + * Clear IdleMode reg. */ + Adapter->IdleMode = false; + Adapter->bTriedToWakeUpFromlowPowerMode = false; wake_up(&Adapter->lowpower_mode_wait_queue); - } - else - { - if(TRUE == Adapter->IdleMode) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"Device is already in Idle mode...."); - return status ; - } + } else { + if (TRUE == Adapter->IdleMode) + return status; uiRegRead = 0; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "Got Req from F/W to go in IDLE mode \n"); - if (Adapter->chip_id== BCS220_2 || + if (Adapter->chip_id == BCS220_2 || Adapter->chip_id == BCS220_2BC || - Adapter->chip_id== BCS250_BC || - Adapter->chip_id== BCS220_3) - { + Adapter->chip_id == BCS250_BC || + Adapter->chip_id == BCS220_3) { - bytes = rdmalt(Adapter, HPM_CONFIG_MSW, &uiRegRead, sizeof(uiRegRead)); + bytes = rdmalt(Adapter, HPM_CONFIG_MSW, + &uiRegRead, sizeof(uiRegRead)); if (bytes < 0) { status = bytes; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "rdm failed while Reading HPM_CONFIG_LDO145 Reg 0\n"); return status; } uiRegRead |= (1<<17); - status = wrmalt (Adapter,HPM_CONFIG_MSW, &uiRegRead, sizeof(uiRegRead)); - if(status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "wrm failed while clearing Idle Mode Reg\n"); + status = wrmalt(Adapter, HPM_CONFIG_MSW, + &uiRegRead, sizeof(uiRegRead)); + if (status) return status; - } - } SendIdleModeResponse(Adapter); } - } - else if(ntohl(*puiBuffer) == IDLE_MODE_SF_UPDATE_MSG) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "OverRiding Service Flow Params"); - OverrideServiceFlowParams(Adapter,puiBuffer); + } else if (ntohl(*puiBuffer) == IDLE_MODE_SF_UPDATE_MSG) { + OverrideServiceFlowParams(Adapter, puiBuffer); } return status; } -static int InterfaceAbortIdlemode(struct bcm_mini_adapter *Adapter, unsigned int Pattern) +static int InterfaceAbortIdlemode(struct bcm_mini_adapter *Adapter, + unsigned int Pattern) { - int status = STATUS_SUCCESS; + int status = STATUS_SUCCESS; unsigned int value; - unsigned int chip_id ; - unsigned long timeout = 0 ,itr = 0; - - int lenwritten = 0; - unsigned char aucAbortPattern[8]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; - PS_INTERFACE_ADAPTER psInterfaceAdapter = Adapter->pvInterfaceAdapter; - - //Abort Bus suspend if its already suspended - if((TRUE == psInterfaceAdapter->bSuspended) && (TRUE == Adapter->bDoSuspend)) - { - status = usb_autopm_get_interface(psInterfaceAdapter->interface); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"Bus got wakeup..Aborting Idle mode... status:%d \n",status); - - } - - if((Adapter->ulPowerSaveMode == DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING) - || - (Adapter->ulPowerSaveMode == DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE)) - { - //write the SW abort pattern. - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "Writing pattern<%d> to SW_ABORT_IDLEMODE_LOC\n", Pattern); - status = wrmalt(Adapter,SW_ABORT_IDLEMODE_LOC, &Pattern, sizeof(Pattern)); - if(status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"WRM to Register SW_ABORT_IDLEMODE_LOC failed.."); - return status; - } + unsigned int chip_id; + unsigned long timeout = 0, itr = 0; + + int lenwritten = 0; + unsigned char aucAbortPattern[8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF}; + struct bcm_interface_adapter *psInterfaceAdapter = + Adapter->pvInterfaceAdapter; + + /* Abort Bus suspend if its already suspended */ + if ((TRUE == psInterfaceAdapter->bSuspended) && + (TRUE == Adapter->bDoSuspend)) + status = usb_autopm_get_interface( + psInterfaceAdapter->interface); + + if ((Adapter->ulPowerSaveMode == + DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING) || + (Adapter->ulPowerSaveMode == + DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE)) { + /* write the SW abort pattern. */ + status = wrmalt(Adapter, SW_ABORT_IDLEMODE_LOC, + &Pattern, sizeof(Pattern)); + if (status) + return status; } - if(Adapter->ulPowerSaveMode == DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING) - { + if (Adapter->ulPowerSaveMode == + DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING) { value = 0x80000000; - status = wrmalt(Adapter,DEBUG_INTERRUPT_GENERATOR_REGISTOR, &value, sizeof(value)); - if(status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"WRM to DEBUG_INTERRUPT_GENERATOR_REGISTOR Register failed"); + status = wrmalt(Adapter, + DEBUG_INTERRUPT_GENERATOR_REGISTOR, + &value, sizeof(value)); + if (status) return status; - } - } - else if(Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE) - { + } else if (Adapter->ulPowerSaveMode != + DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE) { /* * Get a Interrupt Out URB and send 8 Bytes Down * To be Done in Thread Context. * Not using Asynchronous Mechanism. */ - status = usb_interrupt_msg (psInterfaceAdapter->udev, + status = usb_interrupt_msg(psInterfaceAdapter->udev, usb_sndintpipe(psInterfaceAdapter->udev, psInterfaceAdapter->sIntrOut.int_out_endpointAddr), aucAbortPattern, 8, &lenwritten, 5000); - if(status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "Sending Abort pattern down fails with status:%d..\n",status); + if (status) return status; - } else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "NOB Sent down :%d", lenwritten); - } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + IDLE_MODE, DBG_LVL_ALL, + "NOB Sent down :%d", lenwritten); - //mdelay(25); + /* mdelay(25); */ - timeout= jiffies + msecs_to_jiffies(50) ; - while( timeout > jiffies ) - { - itr++ ; + timeout = jiffies + msecs_to_jiffies(50); + while (time_after(timeout, jiffies)) { + itr++; rdmalt(Adapter, CHIP_ID_REG, &chip_id, sizeof(UINT)); - if(0xbece3200==(chip_id&~(0xF0))) - { + if (0xbece3200 == (chip_id&~(0xF0))) chip_id = chip_id&~(0xF0); - } - if(chip_id == Adapter->chip_id) + if (chip_id == Adapter->chip_id) break; } - if(timeout < jiffies ) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"Not able to read chip-id even after 25 msec"); - } + if (time_before(timeout, jiffies)) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + IDLE_MODE, DBG_LVL_ALL, + "Not able to read chip-id even after 25 msec"); else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"Number of completed iteration to read chip-id :%lu", itr); - } - - status = wrmalt(Adapter,SW_ABORT_IDLEMODE_LOC, &Pattern, sizeof(status)); - if(status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"WRM to Register SW_ABORT_IDLEMODE_LOC failed.."); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + IDLE_MODE, DBG_LVL_ALL, + "Number of completed iteration to" + "read chip-id :%lu", itr); + + status = wrmalt(Adapter, SW_ABORT_IDLEMODE_LOC, + &Pattern, sizeof(status)); + if (status) return status; - } } return status; } 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, "Wake up already attempted.. ignoring\n"); - } - else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"Writing Low Power Mode Abort pattern to the Device\n"); + if (Adapter->bTriedToWakeUpFromlowPowerMode) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + IDLE_MODE, DBG_LVL_ALL, + "Wake up already attempted.. ignoring\n"); + } else { Adapter->bTriedToWakeUpFromlowPowerMode = TRUE; InterfaceAbortIdlemode(Adapter, Adapter->usIdleModePattern); } - return Status; + return 0; } void InterfaceHandleShutdownModeWakeup(struct bcm_mini_adapter *Adapter) @@ -269,33 +241,33 @@ void InterfaceHandleShutdownModeWakeup(struct bcm_mini_adapter *Adapter) INT Status = 0; int bytes; - if(Adapter->ulPowerSaveMode == DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING) - { - // clear idlemode interrupt. + if (Adapter->ulPowerSaveMode == + DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING) { + /* clear idlemode interrupt. */ uiRegVal = 0; - Status =wrmalt(Adapter,DEBUG_INTERRUPT_GENERATOR_REGISTOR, &uiRegVal, sizeof(uiRegVal)); - if(Status) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"WRM to DEBUG_INTERRUPT_GENERATOR_REGISTOR Failed with err :%d", Status); + Status = wrmalt(Adapter, + DEBUG_INTERRUPT_GENERATOR_REGISTOR, + &uiRegVal, sizeof(uiRegVal)); + if (Status) return; - } } - else - { + else { - //clear Interrupt EP registers. - bytes = rdmalt(Adapter,DEVICE_INT_OUT_EP_REG0, &uiRegVal, sizeof(uiRegVal)); +/* clear Interrupt EP registers. */ + bytes = rdmalt(Adapter, + DEVICE_INT_OUT_EP_REG0, + &uiRegVal, sizeof(uiRegVal)); if (bytes < 0) { Status = bytes; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"RDM of DEVICE_INT_OUT_EP_REG0 failed with Err :%d", Status); return; } - bytes = rdmalt(Adapter,DEVICE_INT_OUT_EP_REG1, &uiRegVal, sizeof(uiRegVal)); + bytes = rdmalt(Adapter, + DEVICE_INT_OUT_EP_REG1, + &uiRegVal, sizeof(uiRegVal)); if (bytes < 0) { Status = bytes; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"RDM of DEVICE_INT_OUT_EP_REG1 failed with Err :%d", Status); return; } } diff --git a/drivers/staging/bcm/InterfaceIdleMode.h b/drivers/staging/bcm/InterfaceIdleMode.h index c3338c8a1dc..2ef64003aa8 100644 --- a/drivers/staging/bcm/InterfaceIdleMode.h +++ b/drivers/staging/bcm/InterfaceIdleMode.h @@ -3,11 +3,12 @@ INT InterfaceIdleModeWakeup(struct bcm_mini_adapter *Adapter); -INT InterfaceIdleModeRespond(struct bcm_mini_adapter *Adapter, unsigned int *puiBuffer); +INT InterfaceIdleModeRespond(struct bcm_mini_adapter *Adapter, + unsigned int *puiBuffer); VOID InterfaceWriteIdleModeWakePattern(struct bcm_mini_adapter *Adapter); -INT InterfaceWakeUp(struct bcm_mini_adapter * Adapter); +INT InterfaceWakeUp(struct bcm_mini_adapter *Adapter); VOID InterfaceHandleShutdownModeWakeup(struct bcm_mini_adapter *Adapter); #endif diff --git a/drivers/staging/bcm/InterfaceInit.c b/drivers/staging/bcm/InterfaceInit.c index b05f5f73548..7c04c73e3bc 100644 --- a/drivers/staging/bcm/InterfaceInit.c +++ b/drivers/staging/bcm/InterfaceInit.c @@ -1,14 +1,15 @@ #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) }, { USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3L) }, - { USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_SM250) }, + { USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_SYM) }, { USB_DEVICE(BCM_USB_VENDOR_ID_ZTE, BCM_USB_PRODUCT_ID_226) }, { USB_DEVICE(BCM_USB_VENDOR_ID_FOXCONN, BCM_USB_PRODUCT_ID_1901) }, { USB_DEVICE(BCM_USB_VENDOR_ID_ZTE, BCM_USB_PRODUCT_ID_ZTE_TU25) }, { USB_DEVICE(BCM_USB_VENDOR_ID_ZTE, BCM_USB_PRODUCT_ID_ZTE_226) }, + { USB_DEVICE(BCM_USB_VENDOR_ID_ZTE, BCM_USB_PRODUCT_ID_ZTE_326) }, { } }; MODULE_DEVICE_TABLE(usb, InterfaceUsbtable); @@ -22,26 +23,29 @@ static const u32 default_msg = | NETIF_MSG_TIMER | NETIF_MSG_TX_ERR | NETIF_MSG_RX_ERR | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN; -static int InterfaceAdapterInit(PS_INTERFACE_ADAPTER Adapter); +static int InterfaceAdapterInit(struct bcm_interface_adapter *Adapter); -static void InterfaceAdapterFree(PS_INTERFACE_ADAPTER psIntfAdapter) +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 */ @@ -68,8 +72,9 @@ static void InterfaceAdapterFree(PS_INTERFACE_ADAPTER psIntfAdapter) static void ConfigureEndPointTypesThroughEEPROM(struct bcm_mini_adapter *Adapter) { - unsigned long ulReg = 0; + u32 ulReg; int bytes; + struct bcm_interface_adapter *interfaceAdapter; /* Program EP2 MAX_PKT_SIZE */ ulReg = ntohl(EP2_MPS_REG); @@ -79,7 +84,9 @@ static void ConfigureEndPointTypesThroughEEPROM(struct bcm_mini_adapter *Adapter ulReg = ntohl(EP2_CFG_REG); BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x132, 4, TRUE); - if (((PS_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 { @@ -95,10 +102,10 @@ static void ConfigureEndPointTypesThroughEEPROM(struct bcm_mini_adapter *Adapter BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x140, 4, TRUE); /* Program TX EP as interrupt(Alternate Setting) */ - bytes = rdmalt(Adapter, 0x0F0110F8, (u32 *)&ulReg, sizeof(u32)); + 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; @@ -118,18 +125,18 @@ static void ConfigureEndPointTypesThroughEEPROM(struct bcm_mini_adapter *Adapter * Update EEPROM Version. * Read 4 bytes from 508 and modify 511 and 510. */ - ReadBeceemEEPROM(Adapter, 0x1FC, (PUINT)&ulReg); + ReadBeceemEEPROM(Adapter, 0x1FC, &ulReg); ulReg &= 0x0101FFFF; BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x1FC, 4, TRUE); /* Update length field if required. Also make the string NULL terminated. */ - ReadBeceemEEPROM(Adapter, 0xA8, (PUINT)&ulReg); + ReadBeceemEEPROM(Adapter, 0xA8, &ulReg); if ((ulReg&0x00FF0000)>>16 > 0x30) { ulReg = (ulReg&0xFF00FFFF)|(0x30<<16); BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0xA8, 4, TRUE); } - ReadBeceemEEPROM(Adapter, 0x148, (PUINT)&ulReg); + ReadBeceemEEPROM(Adapter, 0x148, &ulReg); if ((ulReg&0x00FF0000)>>16 > 0x30) { ulReg = (ulReg&0xFF00FFFF)|(0x30<<16); BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x148, 4, TRUE); @@ -145,11 +152,12 @@ static int usbbcm_device_probe(struct usb_interface *intf, const struct usb_devi struct usb_device *udev = interface_to_usbdev(intf); int retval; struct bcm_mini_adapter *psAdapter; - PS_INTERFACE_ADAPTER psIntfAdapter; + struct bcm_interface_adapter *psIntfAdapter; 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; @@ -168,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. */ @@ -189,9 +198,9 @@ static int usbbcm_device_probe(struct usb_interface *intf, const struct usb_devi } /* Allocate interface adapter structure */ - psIntfAdapter = kzalloc(sizeof(S_INTERFACE_ADAPTER), GFP_KERNEL); + psIntfAdapter = kzalloc(sizeof(struct bcm_interface_adapter), + GFP_KERNEL); if (psIntfAdapter == NULL) { - dev_err(&udev->dev, DRV_NAME ": no memory for Interface adapter\n"); AdapterFree(psAdapter); return -ENOMEM; } @@ -204,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 @@ -212,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); @@ -227,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; } @@ -241,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; @@ -257,7 +272,7 @@ static int usbbcm_device_probe(struct usb_interface *intf, const struct usb_devi static void usbbcm_disconnect(struct usb_interface *intf) { - PS_INTERFACE_ADAPTER psIntfAdapter = usb_get_intfdata(intf); + struct bcm_interface_adapter *psIntfAdapter = usb_get_intfdata(intf); struct bcm_mini_adapter *psAdapter; struct usb_device *udev = interface_to_usbdev(intf); @@ -270,13 +285,13 @@ 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); } -static int AllocUsbCb(PS_INTERFACE_ADAPTER psIntfAdapter) +static int AllocUsbCb(struct bcm_interface_adapter *psIntfAdapter) { int i = 0; @@ -284,8 +299,10 @@ static int AllocUsbCb(PS_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; } } @@ -294,24 +311,30 @@ static int AllocUsbCb(PS_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; } -static int device_run(PS_INTERFACE_ADAPTER psIntfAdapter) +static int device_run(struct bcm_interface_adapter *psIntfAdapter) { int value = 0; UINT status = STATUS_SUCCESS; @@ -321,24 +344,29 @@ static int device_run(PS_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); + psIntfAdapter->psAdapter->waiting_to_fw_download_done = false; + value = wait_event_timeout( + psIntfAdapter->psAdapter->ioctl_fw_dnld_wait_queue, + psIntfAdapter->psAdapter->waiting_to_fw_download_done, + 5 * HZ); if (value == 0) 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; } @@ -346,105 +374,34 @@ static int device_run(PS_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(PS_INTERFACE_ADAPTER psIntfAdapter) +static int InterfaceAdapterInit(struct bcm_interface_adapter *psIntfAdapter) { struct usb_host_interface *iface_desc; struct usb_endpoint_descriptor *endpoint; size_t buffer_size; unsigned long value; int retval = 0; - int usedIntOutForBulkTransfer = 0 ; - BOOLEAN bBcm16 = FALSE; + 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; } @@ -452,81 +409,119 @@ static int InterfaceAdapterInit(PS_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; } @@ -540,57 +535,71 @@ static int InterfaceAdapterInit(PS_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); - if (!psIntfAdapter->sIntrIn.int_in_buffer) { - dev_err(&psIntfAdapter->udev->dev, - "could not allocate interrupt_in_buffer\n"); + 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); - if (!psIntfAdapter->sIntrOut.int_out_buffer) { - dev_err(&psIntfAdapter->udev->dev, - "could not allocate interrupt_out_buffer\n"); + 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; - } } } } @@ -599,14 +608,14 @@ static int InterfaceAdapterInit(PS_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; } @@ -619,24 +628,28 @@ static int InterfaceAdapterInit(PS_INTERFACE_ADAPTER psIntfAdapter) static int InterfaceSuspend(struct usb_interface *intf, pm_message_t message) { - PS_INTERFACE_ADAPTER psIntfAdapter = usb_get_intfdata(intf); + struct bcm_interface_adapter *psIntfAdapter = usb_get_intfdata(intf); psIntfAdapter->bSuspended = TRUE; - if (TRUE == psIntfAdapter->bPreparingForBusSuspend) { - psIntfAdapter->bPreparingForBusSuspend = FALSE; + 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; + psIntfAdapter->psAdapter->bPreparingForLowPowerMode = false; /* Signaling the control pkt path */ wake_up(&psIntfAdapter->psAdapter->lowpower_mode_wait_queue); @@ -646,10 +659,10 @@ static int InterfaceSuspend(struct usb_interface *intf, pm_message_t message) static int InterfaceResume(struct usb_interface *intf) { - PS_INTERFACE_ADAPTER psIntfAdapter = usb_get_intfdata(intf); + struct bcm_interface_adapter *psIntfAdapter = usb_get_intfdata(intf); mdelay(100); - psIntfAdapter->bSuspended = FALSE; + psIntfAdapter->bSuspended = false; StartInterruptUrb(psIntfAdapter); InterfaceRx(psIntfAdapter); diff --git a/drivers/staging/bcm/InterfaceInit.h b/drivers/staging/bcm/InterfaceInit.h index 866924e35f9..ffa6e9667ec 100644 --- a/drivers/staging/bcm/InterfaceInit.h +++ b/drivers/staging/bcm/InterfaceInit.h @@ -8,11 +8,11 @@ #define BCM_USB_PRODUCT_ID_T3 0x0300 #define BCM_USB_PRODUCT_ID_T3B 0x0210 #define BCM_USB_PRODUCT_ID_T3L 0x0220 -#define BCM_USB_PRODUCT_ID_SM250 0xbccd #define BCM_USB_PRODUCT_ID_SYM 0x15E #define BCM_USB_PRODUCT_ID_1901 0xe017 #define BCM_USB_PRODUCT_ID_226 0x0132 /* not sure if this is valid */ #define BCM_USB_PRODUCT_ID_ZTE_226 0x172 +#define BCM_USB_PRODUCT_ID_ZTE_326 0x173 /* ZTE AX326 */ #define BCM_USB_PRODUCT_ID_ZTE_TU25 0x0007 #define BCM_USB_MINOR_BASE 192 @@ -21,6 +21,6 @@ int InterfaceInitialize(void); int InterfaceExit(void); -int usbbcm_worker_thread(PS_INTERFACE_ADAPTER psIntfAdapter); +int usbbcm_worker_thread(struct bcm_interface_adapter *psIntfAdapter); #endif diff --git a/drivers/staging/bcm/InterfaceIsr.c b/drivers/staging/bcm/InterfaceIsr.c index 6ee3428daa5..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; - PS_INTERFACE_ADAPTER psIntfAdapter = (PS_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; } @@ -114,52 +132,55 @@ static void read_int_callback(struct urb *urb/*, struct pt_regs *regs*/) } -int CreateInterruptUrb(PS_INTERFACE_ADAPTER psIntfAdapter) +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; } -INT StartInterruptUrb(PS_INTERFACE_ADAPTER psIntfAdapter) +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/InterfaceIsr.h b/drivers/staging/bcm/InterfaceIsr.h index 40399788c41..3073bd71cfe 100644 --- a/drivers/staging/bcm/InterfaceIsr.h +++ b/drivers/staging/bcm/InterfaceIsr.h @@ -1,10 +1,10 @@ #ifndef _INTERFACE_ISR_H #define _INTERFACE_ISR_H -int CreateInterruptUrb(PS_INTERFACE_ADAPTER psIntfAdapter); +int CreateInterruptUrb(struct bcm_interface_adapter *psIntfAdapter); -INT StartInterruptUrb(PS_INTERFACE_ADAPTER psIntfAdapter); +INT StartInterruptUrb(struct bcm_interface_adapter *psIntfAdapter); VOID InterfaceEnableInterrupt(struct bcm_mini_adapter *Adapter); diff --git a/drivers/staging/bcm/InterfaceMisc.c b/drivers/staging/bcm/InterfaceMisc.c index bbe90994609..4173fd7d671 100644 --- a/drivers/staging/bcm/InterfaceMisc.c +++ b/drivers/staging/bcm/InterfaceMisc.c @@ -1,17 +1,14 @@ #include "headers.h" -INT InterfaceRDM(PS_INTERFACE_ADAPTER psIntfAdapter, - UINT addr, - PVOID buff, - INT len) +int InterfaceRDM(struct bcm_interface_adapter *psIntfAdapter, + unsigned int addr, + void *buff, + int len) { int bytes; - USHORT usRetries = 0; - if (psIntfAdapter == NULL) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, "Interface Adapter is NULL"); + if (!psIntfAdapter) return -EINVAL; - } if (psIntfAdapter->psAdapter->device_removed == TRUE) { BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, "Device got removed"); @@ -29,46 +26,37 @@ INT InterfaceRDM(PS_INTERFACE_ADAPTER psIntfAdapter, } psIntfAdapter->psAdapter->DeviceAccess = TRUE; - do { - bytes = usb_control_msg(psIntfAdapter->udev, - usb_rcvctrlpipe(psIntfAdapter->udev, 0), - 0x02, - 0xC2, - (addr & 0xFFFF), - ((addr >> 16) & 0xFFFF), - buff, - len, - 5000); - - usRetries++; - if (-ENODEV == bytes) { - psIntfAdapter->psAdapter->device_removed = TRUE; - break; - } + bytes = usb_control_msg(psIntfAdapter->udev, + usb_rcvctrlpipe(psIntfAdapter->udev, 0), + 0x02, + 0xC2, + (addr & 0xFFFF), + ((addr >> 16) & 0xFFFF), + buff, + len, + 5000); - } while ((bytes < 0) && (usRetries < MAX_RDM_WRM_RETIRES)); + if (-ENODEV == bytes) + psIntfAdapter->psAdapter->device_removed = TRUE; if (bytes < 0) - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, RDM, DBG_LVL_ALL, "RDM failed status :%d, retires :%d", bytes, usRetries); + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, RDM, DBG_LVL_ALL, "RDM failed status :%d", bytes); else BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, RDM, DBG_LVL_ALL, "RDM sent %d", bytes); - psIntfAdapter->psAdapter->DeviceAccess = FALSE; + psIntfAdapter->psAdapter->DeviceAccess = false; return bytes; } -INT InterfaceWRM(PS_INTERFACE_ADAPTER psIntfAdapter, - UINT addr, - PVOID buff, - INT len) +int InterfaceWRM(struct bcm_interface_adapter *psIntfAdapter, + unsigned int addr, + void *buff, + int len) { int retval = 0; - USHORT usRetries = 0; - if (psIntfAdapter == NULL) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, "Interface Adapter is NULL"); + if (!psIntfAdapter) return -EINVAL; - } if (psIntfAdapter->psAdapter->device_removed == TRUE) { BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, "Device got removed"); @@ -87,56 +75,50 @@ INT InterfaceWRM(PS_INTERFACE_ADAPTER psIntfAdapter, psIntfAdapter->psAdapter->DeviceAccess = TRUE; - do { - retval = usb_control_msg(psIntfAdapter->udev, - usb_sndctrlpipe(psIntfAdapter->udev, 0), - 0x01, - 0x42, - (addr & 0xFFFF), - ((addr >> 16) & 0xFFFF), - buff, - len, - 5000); - - usRetries++; - if (-ENODEV == retval) { - psIntfAdapter->psAdapter->device_removed = TRUE; - break; - } + retval = usb_control_msg(psIntfAdapter->udev, + usb_sndctrlpipe(psIntfAdapter->udev, 0), + 0x01, + 0x42, + (addr & 0xFFFF), + ((addr >> 16) & 0xFFFF), + buff, + len, + 5000); - } while ((retval < 0) && (usRetries < MAX_RDM_WRM_RETIRES)); + if (-ENODEV == retval) + psIntfAdapter->psAdapter->device_removed = TRUE; if (retval < 0) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, WRM, DBG_LVL_ALL, "WRM failed status :%d, retires :%d", retval, usRetries); - psIntfAdapter->psAdapter->DeviceAccess = FALSE; + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, WRM, DBG_LVL_ALL, "WRM failed status :%d", retval); + psIntfAdapter->psAdapter->DeviceAccess = false; return retval; } else { - psIntfAdapter->psAdapter->DeviceAccess = FALSE; + psIntfAdapter->psAdapter->DeviceAccess = false; BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, WRM, DBG_LVL_ALL, "WRM sent %d", retval); return STATUS_SUCCESS; } } -INT BcmRDM(PVOID arg, - UINT addr, - PVOID buff, - INT len) +int BcmRDM(void *arg, + unsigned int addr, + void *buff, + int len) { - return InterfaceRDM((PS_INTERFACE_ADAPTER)arg, addr, buff, len); + return InterfaceRDM((struct bcm_interface_adapter *)arg, addr, buff, len); } -INT BcmWRM(PVOID arg, - UINT addr, - PVOID buff, - INT len) +int BcmWRM(void *arg, + unsigned int addr, + void *buff, + int len) { - return InterfaceWRM((PS_INTERFACE_ADAPTER)arg, addr, buff, len); + return InterfaceWRM((struct bcm_interface_adapter *)arg, addr, buff, len); } -INT Bcm_clear_halt_of_endpoints(struct bcm_mini_adapter *Adapter) +int Bcm_clear_halt_of_endpoints(struct bcm_mini_adapter *Adapter) { - PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter); - INT status = STATUS_SUCCESS; + struct bcm_interface_adapter *psIntfAdapter = (struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter); + int status = STATUS_SUCCESS; /* * usb_clear_halt - tells device to clear endpoint halt/stall condition @@ -172,10 +154,10 @@ INT Bcm_clear_halt_of_endpoints(struct bcm_mini_adapter *Adapter) return status; } -VOID Bcm_kill_all_URBs(PS_INTERFACE_ADAPTER psIntfAdapter) +void Bcm_kill_all_URBs(struct bcm_interface_adapter *psIntfAdapter) { struct urb *tempUrb = NULL; - UINT i; + unsigned int i; /* * usb_kill_urb - cancel a transfer request and wait for it to finish @@ -193,7 +175,7 @@ VOID Bcm_kill_all_URBs(PS_INTERFACE_ADAPTER psIntfAdapter) */ /* Cancel submitted Interrupt-URB's */ - if (psIntfAdapter->psInterruptUrb != NULL) { + if (psIntfAdapter->psInterruptUrb) { if (psIntfAdapter->psInterruptUrb->status == -EINPROGRESS) usb_kill_urb(psIntfAdapter->psInterruptUrb); } @@ -222,14 +204,14 @@ VOID Bcm_kill_all_URBs(PS_INTERFACE_ADAPTER psIntfAdapter) atomic_set(&psIntfAdapter->uCurrRcb, 0); } -VOID putUsbSuspend(struct work_struct *work) +void putUsbSuspend(struct work_struct *work) { - PS_INTERFACE_ADAPTER psIntfAdapter = NULL; + struct bcm_interface_adapter *psIntfAdapter = NULL; struct usb_interface *intf = NULL; - psIntfAdapter = container_of(work, S_INTERFACE_ADAPTER, usbSuspendWork); + psIntfAdapter = container_of(work, struct bcm_interface_adapter, usbSuspendWork); intf = psIntfAdapter->interface; - if (psIntfAdapter->bSuspended == FALSE) + if (psIntfAdapter->bSuspended == false) usb_autopm_put_interface(intf); } diff --git a/drivers/staging/bcm/InterfaceMisc.h b/drivers/staging/bcm/InterfaceMisc.h index 1dfabdc3aad..efb68604615 100644 --- a/drivers/staging/bcm/InterfaceMisc.h +++ b/drivers/staging/bcm/InterfaceMisc.h @@ -2,25 +2,25 @@ #define __INTERFACE_MISC_H INT -InterfaceRDM(PS_INTERFACE_ADAPTER psIntfAdapter, +InterfaceRDM(struct bcm_interface_adapter *psIntfAdapter, UINT addr, PVOID buff, INT len); INT -InterfaceWRM(PS_INTERFACE_ADAPTER psIntfAdapter, +InterfaceWRM(struct bcm_interface_adapter *psIntfAdapter, UINT addr, PVOID buff, 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, @@ -35,7 +35,7 @@ int BcmWRM(PVOID arg, INT Bcm_clear_halt_of_endpoints(struct bcm_mini_adapter *Adapter); -VOID Bcm_kill_all_URBs(PS_INTERFACE_ADAPTER psIntfAdapter); +VOID Bcm_kill_all_URBs(struct bcm_interface_adapter *psIntfAdapter); #define DISABLE_USB_ZERO_LEN_INT 0x0F011878 diff --git a/drivers/staging/bcm/InterfaceRx.c b/drivers/staging/bcm/InterfaceRx.c index 8a9f90fbdf1..11008173f91 100644 --- a/drivers/staging/bcm/InterfaceRx.c +++ b/drivers/staging/bcm/InterfaceRx.c @@ -1,32 +1,31 @@ #include "headers.h" -static int SearchVcid(struct bcm_mini_adapter *Adapter,unsigned short usVcid) +static int SearchVcid(struct bcm_mini_adapter *Adapter, unsigned short usVcid) { - int iIndex=0; + int iIndex = 0; - for(iIndex=(NO_OF_QUEUES-1);iIndex>=0;iIndex--) - if(Adapter->PackInfo[iIndex].usVCID_Value == usVcid) + for (iIndex = (NO_OF_QUEUES-1); iIndex >= 0; iIndex--) + if (Adapter->PackInfo[iIndex].usVCID_Value == usVcid) return iIndex; return NO_OF_QUEUES+1; } -static PUSB_RCB -GetBulkInRcb(PS_INTERFACE_ADAPTER psIntfAdapter) +static struct bcm_usb_rcb * +GetBulkInRcb(struct bcm_interface_adapter *psIntfAdapter) { - PUSB_RCB pRcb = NULL; + struct bcm_usb_rcb *pRcb = NULL; UINT index = 0; - if((atomic_read(&psIntfAdapter->uNumRcbUsed) < MAXIMUM_USB_RCB) && - (psIntfAdapter->psAdapter->StopAllXaction == FALSE)) - { + if ((atomic_read(&psIntfAdapter->uNumRcbUsed) < MAXIMUM_USB_RCB) && + (psIntfAdapter->psAdapter->StopAllXaction == false)) { index = atomic_read(&psIntfAdapter->uCurrRcb); pRcb = &psIntfAdapter->asUsbRcb[index]; pRcb->bUsed = TRUE; - pRcb->psIntfAdapter= psIntfAdapter; - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "Got Rx desc %d used %d", - index, atomic_read(&psIntfAdapter->uNumRcbUsed)); + pRcb->psIntfAdapter = psIntfAdapter; + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "Got Rx desc %d used %d", + index, atomic_read(&psIntfAdapter->uNumRcbUsed)); index = (index + 1) % MAXIMUM_USB_RCB; atomic_set(&psIntfAdapter->uCurrRcb, index); atomic_inc(&psIntfAdapter->uNumRcbUsed); @@ -38,13 +37,12 @@ GetBulkInRcb(PS_INTERFACE_ADAPTER psIntfAdapter) static void read_bulk_callback(struct urb *urb) { struct sk_buff *skb = NULL; - BOOLEAN bHeaderSupressionEnabled = FALSE; + bool bHeaderSupressionEnabled = false; int QueueIndex = NO_OF_QUEUES + 1; - UINT uiIndex=0; + UINT uiIndex = 0; int process_done = 1; - //int idleflag = 0 ; - PUSB_RCB pRcb = (PUSB_RCB)urb->context; - PS_INTERFACE_ADAPTER psIntfAdapter = pRcb->psIntfAdapter; + struct bcm_usb_rcb *pRcb = (struct bcm_usb_rcb *)urb->context; + struct bcm_interface_adapter *psIntfAdapter = pRcb->psIntfAdapter; struct bcm_mini_adapter *Adapter = psIntfAdapter->psAdapter; struct bcm_leader *pLeader = urb->transfer_buffer; @@ -52,49 +50,40 @@ static void read_bulk_callback(struct urb *urb) pr_info(PFX "%s: rx urb status %d length %d\n", Adapter->dev->name, urb->status, urb->actual_length); - if((Adapter->device_removed == TRUE) || - (TRUE == Adapter->bEndPointHalted) || - (0 == urb->actual_length) - ) - { - pRcb->bUsed = FALSE; - atomic_dec(&psIntfAdapter->uNumRcbUsed); + if ((Adapter->device_removed == TRUE) || + (TRUE == Adapter->bEndPointHalted) || + (0 == urb->actual_length)) { + pRcb->bUsed = false; + atomic_dec(&psIntfAdapter->uNumRcbUsed); return; } - if(urb->status != STATUS_SUCCESS) - { - if(urb->status == -EPIPE) - { - Adapter->bEndPointHalted = TRUE ; + if (urb->status != STATUS_SUCCESS) { + if (urb->status == -EPIPE) { + Adapter->bEndPointHalted = TRUE; wake_up(&Adapter->tx_packet_wait_queue); + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "Rx URB has got cancelled. status :%d", urb->status); } - else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL,"Rx URB has got cancelled. status :%d", urb->status); - } - pRcb->bUsed = FALSE; - atomic_dec(&psIntfAdapter->uNumRcbUsed); - urb->status = STATUS_SUCCESS ; - return ; + pRcb->bUsed = false; + atomic_dec(&psIntfAdapter->uNumRcbUsed); + urb->status = STATUS_SUCCESS; + return; } - if(Adapter->bDoSuspend && (Adapter->bPreparingForLowPowerMode)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL,"device is going in low power mode while PMU option selected..hence rx packet should not be process"); - return ; + if (Adapter->bDoSuspend && (Adapter->bPreparingForLowPowerMode)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "device is going in low power mode while PMU option selected..hence rx packet should not be process"); + return; } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "Read back done len %d\n", pLeader->PLength); - if(!pLeader->PLength) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "Leader Length 0"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "Read back done len %d\n", pLeader->PLength); + if (!pLeader->PLength) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "Leader Length 0"); atomic_dec(&psIntfAdapter->uNumRcbUsed); return; } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "Leader Status:0x%hX, Length:0x%hX, VCID:0x%hX", pLeader->Status,pLeader->PLength,pLeader->Vcid); - if(MAX_CNTL_PKT_SIZE < pLeader->PLength) - { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "Leader Status:0x%hX, Length:0x%hX, VCID:0x%hX", pLeader->Status, pLeader->PLength, pLeader->Vcid); + if (MAX_CNTL_PKT_SIZE < pLeader->PLength) { if (netif_msg_rx_err(Adapter)) pr_info(PFX "%s: corrupted leader length...%d\n", Adapter->dev->name, pLeader->PLength); @@ -103,65 +92,58 @@ static void read_bulk_callback(struct urb *urb) return; } - QueueIndex = SearchVcid( Adapter,pLeader->Vcid); - if(QueueIndex < NO_OF_QUEUES) - { + QueueIndex = SearchVcid(Adapter, pLeader->Vcid); + if (QueueIndex < NO_OF_QUEUES) { bHeaderSupressionEnabled = Adapter->PackInfo[QueueIndex].bHeaderSuppressionEnabled; bHeaderSupressionEnabled = bHeaderSupressionEnabled & Adapter->bPHSEnabled; } - skb = dev_alloc_skb (pLeader->PLength + SKB_RESERVE_PHS_BYTES + SKB_RESERVE_ETHERNET_HEADER);//2 //2 for allignment - if(!skb) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "NO SKBUFF!!! Dropping the Packet"); + skb = dev_alloc_skb(pLeader->PLength + SKB_RESERVE_PHS_BYTES + SKB_RESERVE_ETHERNET_HEADER); + if (!skb) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "NO SKBUFF!!! Dropping the Packet"); atomic_dec(&psIntfAdapter->uNumRcbUsed); return; } - /* If it is a control Packet, then call handle_bcm_packet ()*/ - if((ntohs(pLeader->Vcid) == VCID_CONTROL_PACKET) || - (!(pLeader->Status >= 0x20 && pLeader->Status <= 0x3F))) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_RX, RX_CTRL, DBG_LVL_ALL, "Received control pkt..."); + /* If it is a control Packet, then call handle_bcm_packet ()*/ + if ((ntohs(pLeader->Vcid) == VCID_CONTROL_PACKET) || + (!(pLeader->Status >= 0x20 && pLeader->Status <= 0x3F))) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_RX, RX_CTRL, DBG_LVL_ALL, "Received control pkt..."); *(PUSHORT)skb->data = pLeader->Status; - memcpy(skb->data+sizeof(USHORT), urb->transfer_buffer + - (sizeof(struct bcm_leader)), pLeader->PLength); + memcpy(skb->data+sizeof(USHORT), urb->transfer_buffer + + (sizeof(struct bcm_leader)), pLeader->PLength); skb->len = pLeader->PLength + sizeof(USHORT); spin_lock(&Adapter->control_queue_lock); - ENQUEUEPACKET(Adapter->RxControlHead,Adapter->RxControlTail,skb); + ENQUEUEPACKET(Adapter->RxControlHead, Adapter->RxControlTail, skb); spin_unlock(&Adapter->control_queue_lock); atomic_inc(&Adapter->cntrlpktCnt); wake_up(&Adapter->process_rx_cntrlpkt); - } - else - { + } else { /* - * Data Packet, Format a proper Ethernet Header - * and give it to the stack - */ - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_RX, RX_DATA, DBG_LVL_ALL, "Received Data pkt..."); + * Data Packet, Format a proper Ethernet Header + * and give it to the stack + */ + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_RX, RX_DATA, DBG_LVL_ALL, "Received Data pkt..."); skb_reserve(skb, 2 + SKB_RESERVE_PHS_BYTES); memcpy(skb->data+ETH_HLEN, (PUCHAR)urb->transfer_buffer + sizeof(struct bcm_leader), pLeader->PLength); skb->dev = Adapter->dev; /* currently skb->len has extra ETH_HLEN bytes in the beginning */ - skb_put (skb, pLeader->PLength + ETH_HLEN); - Adapter->PackInfo[QueueIndex].uiTotalRxBytes+=pLeader->PLength; - Adapter->PackInfo[QueueIndex].uiThisPeriodRxBytes+= pLeader->PLength; - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_RX, RX_DATA, DBG_LVL_ALL, "Received Data pkt of len :0x%X", pLeader->PLength); + skb_put(skb, pLeader->PLength + ETH_HLEN); + Adapter->PackInfo[QueueIndex].uiTotalRxBytes += pLeader->PLength; + Adapter->PackInfo[QueueIndex].uiThisPeriodRxBytes += pLeader->PLength; + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_RX, RX_DATA, DBG_LVL_ALL, "Received Data pkt of len :0x%X", pLeader->PLength); - if(netif_running(Adapter->dev)) - { + if (netif_running(Adapter->dev)) { /* Moving ahead by ETH_HLEN to the data ptr as received from FW */ skb_pull(skb, ETH_HLEN); PHSReceive(Adapter, pLeader->Vcid, skb, &skb->len, - NULL,bHeaderSupressionEnabled); + NULL, bHeaderSupressionEnabled); - if(!Adapter->PackInfo[QueueIndex].bEthCSSupport) - { + if (!Adapter->PackInfo[QueueIndex].bEthCSSupport) { skb_push(skb, ETH_HLEN); memcpy(skb->data, skb->dev->dev_addr, 6); @@ -169,55 +151,47 @@ static void read_bulk_callback(struct urb *urb) (*(skb->data+11))++; *(skb->data+12) = 0x08; *(skb->data+13) = 0x00; - pLeader->PLength+=ETH_HLEN; + pLeader->PLength += ETH_HLEN; } skb->protocol = eth_type_trans(skb, Adapter->dev); process_done = netif_rx(skb); - } - else - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_RX, RX_DATA, DBG_LVL_ALL, "i/f not up hance freeing SKB..."); + } else { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_RX, RX_DATA, DBG_LVL_ALL, "i/f not up hance freeing SKB..."); dev_kfree_skb(skb); } ++Adapter->dev->stats.rx_packets; Adapter->dev->stats.rx_bytes += pLeader->PLength; - for(uiIndex = 0 ; uiIndex < MIBS_MAX_HIST_ENTRIES ; uiIndex++) - { - if((pLeader->PLength <= MIBS_PKTSIZEHIST_RANGE*(uiIndex+1)) - && (pLeader->PLength > MIBS_PKTSIZEHIST_RANGE*(uiIndex))) + for (uiIndex = 0; uiIndex < MIBS_MAX_HIST_ENTRIES; uiIndex++) { + if ((pLeader->PLength <= MIBS_PKTSIZEHIST_RANGE*(uiIndex+1)) && + (pLeader->PLength > MIBS_PKTSIZEHIST_RANGE*(uiIndex))) Adapter->aRxPktSizeHist[uiIndex]++; } } - Adapter->PrevNumRecvDescs++; - pRcb->bUsed = FALSE; + Adapter->PrevNumRecvDescs++; + pRcb->bUsed = false; atomic_dec(&psIntfAdapter->uNumRcbUsed); } -static int ReceiveRcb(PS_INTERFACE_ADAPTER psIntfAdapter, PUSB_RCB pRcb) +static int ReceiveRcb(struct bcm_interface_adapter *psIntfAdapter, struct bcm_usb_rcb *pRcb) { struct urb *urb = pRcb->urb; int retval = 0; - usb_fill_bulk_urb(urb, psIntfAdapter->udev, usb_rcvbulkpipe( - psIntfAdapter->udev, psIntfAdapter->sBulkIn.bulk_in_endpointAddr), - urb->transfer_buffer, BCM_USB_MAX_READ_LENGTH, read_bulk_callback, - pRcb); - if(FALSE == psIntfAdapter->psAdapter->device_removed && - FALSE == psIntfAdapter->psAdapter->bEndPointHalted && - FALSE == psIntfAdapter->bSuspended && - FALSE == psIntfAdapter->bPreparingForBusSuspend) - { + usb_fill_bulk_urb(urb, psIntfAdapter->udev, usb_rcvbulkpipe(psIntfAdapter->udev, psIntfAdapter->sBulkIn.bulk_in_endpointAddr), + urb->transfer_buffer, BCM_USB_MAX_READ_LENGTH, read_bulk_callback, pRcb); + if (false == psIntfAdapter->psAdapter->device_removed && + false == psIntfAdapter->psAdapter->bEndPointHalted && + false == psIntfAdapter->bSuspended && + false == psIntfAdapter->bPreparingForBusSuspend) { retval = usb_submit_urb(urb, GFP_ATOMIC); - if (retval) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "failed submitting read urb, error %d", retval); - //if this return value is because of pipe halt. need to clear this. - if(retval == -EPIPE) - { - psIntfAdapter->psAdapter->bEndPointHalted = TRUE ; + if (retval) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "failed submitting read urb, error %d", retval); + /* if this return value is because of pipe halt. need to clear this. */ + if (retval == -EPIPE) { + psIntfAdapter->psAdapter->bEndPointHalted = TRUE; wake_up(&psIntfAdapter->psAdapter->tx_packet_wait_queue); } @@ -240,25 +214,20 @@ Return: TRUE - If Rx was successful. Other - If an error occurred. */ -BOOLEAN InterfaceRx (PS_INTERFACE_ADAPTER psIntfAdapter) +bool InterfaceRx(struct bcm_interface_adapter *psIntfAdapter) { USHORT RxDescCount = NUM_RX_DESC - atomic_read(&psIntfAdapter->uNumRcbUsed); - PUSB_RCB pRcb = NULL; + struct bcm_usb_rcb *pRcb = NULL; -// RxDescCount = psIntfAdapter->psAdapter->CurrNumRecvDescs - -// psIntfAdapter->psAdapter->PrevNumRecvDescs; - while(RxDescCount) - { + while (RxDescCount) { pRcb = GetBulkInRcb(psIntfAdapter); - if(pRcb == NULL) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Unable to get Rcb pointer"); - return FALSE; + if (pRcb == NULL) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, "Unable to get Rcb pointer"); + return false; } - //atomic_inc(&psIntfAdapter->uNumRcbUsed); ReceiveRcb(psIntfAdapter, pRcb); RxDescCount--; - } + } return TRUE; } diff --git a/drivers/staging/bcm/InterfaceRx.h b/drivers/staging/bcm/InterfaceRx.h index 96e81a1d37b..b4e858bcda3 100644 --- a/drivers/staging/bcm/InterfaceRx.h +++ b/drivers/staging/bcm/InterfaceRx.h @@ -1,7 +1,7 @@ #ifndef _INTERFACE_RX_H #define _INTERFACE_RX_H -BOOLEAN InterfaceRx(PS_INTERFACE_ADAPTER Adapter); +bool InterfaceRx(struct bcm_interface_adapter *Adapter); #endif diff --git a/drivers/staging/bcm/InterfaceTx.c b/drivers/staging/bcm/InterfaceTx.c index 7e2b53be4d9..ea7707b8e60 100644 --- a/drivers/staging/bcm/InterfaceTx.c +++ b/drivers/staging/bcm/InterfaceTx.c @@ -3,97 +3,83 @@ /*this is transmit call-back(BULK OUT)*/ static void write_bulk_callback(struct urb *urb/*, struct pt_regs *regs*/) { - PUSB_TCB pTcb= (PUSB_TCB)urb->context; - PS_INTERFACE_ADAPTER psIntfAdapter = pTcb->psIntfAdapter; + struct bcm_usb_tcb *pTcb = (struct bcm_usb_tcb *)urb->context; + struct bcm_interface_adapter *psIntfAdapter = pTcb->psIntfAdapter; struct bcm_link_request *pControlMsg = (struct bcm_link_request *)urb->transfer_buffer; - struct bcm_mini_adapter *psAdapter = psIntfAdapter->psAdapter ; - BOOLEAN bpowerDownMsg = FALSE ; + struct bcm_mini_adapter *psAdapter = psIntfAdapter->psAdapter; + bool bpowerDownMsg = false; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - if (unlikely(netif_msg_tx_done(Adapter))) - pr_info(PFX "%s: transmit status %d\n", Adapter->dev->name, urb->status); + if (unlikely(netif_msg_tx_done(Adapter))) + pr_info(PFX "%s: transmit status %d\n", Adapter->dev->name, urb->status); - if(urb->status != STATUS_SUCCESS) - { - if(urb->status == -EPIPE) - { - psIntfAdapter->psAdapter->bEndPointHalted = TRUE ; + if (urb->status != STATUS_SUCCESS) { + if (urb->status == -EPIPE) { + psIntfAdapter->psAdapter->bEndPointHalted = TRUE; wake_up(&psIntfAdapter->psAdapter->tx_packet_wait_queue); - } - else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,"Tx URB has got cancelled. status :%d", urb->status); + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Tx URB has got cancelled. status :%d", urb->status); } } - pTcb->bUsed = FALSE; + pTcb->bUsed = false; atomic_dec(&psIntfAdapter->uNumTcbUsed); - if(TRUE == psAdapter->bPreparingForLowPowerMode) - { - - if(((pControlMsg->szData[0] == GO_TO_IDLE_MODE_PAYLOAD) && - (pControlMsg->szData[1] == TARGET_CAN_GO_TO_IDLE_MODE))) + if (TRUE == psAdapter->bPreparingForLowPowerMode) { - { - bpowerDownMsg = TRUE ; - //This covers the bus err while Idle Request msg sent down. - if(urb->status != STATUS_SUCCESS) - { - psAdapter->bPreparingForLowPowerMode = FALSE ; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,"Idle Mode Request msg failed to reach to Modem"); - //Signalling the cntrl pkt path in Ioctl + if (((pControlMsg->szData[0] == GO_TO_IDLE_MODE_PAYLOAD) && + (pControlMsg->szData[1] == TARGET_CAN_GO_TO_IDLE_MODE))) { + bpowerDownMsg = TRUE; + /* This covers the bus err while Idle Request msg sent down. */ + if (urb->status != STATUS_SUCCESS) { + psAdapter->bPreparingForLowPowerMode = false; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Idle Mode Request msg failed to reach to Modem"); + /* Signalling the cntrl pkt path in Ioctl */ wake_up(&psAdapter->lowpower_mode_wait_queue); StartInterruptUrb(psIntfAdapter); goto err_exit; } - if(psAdapter->bDoSuspend == FALSE) - { + if (psAdapter->bDoSuspend == false) { psAdapter->IdleMode = TRUE; - //since going in Idle mode completed hence making this var false; - psAdapter->bPreparingForLowPowerMode = FALSE ; + /* since going in Idle mode completed hence making this var false */ + psAdapter->bPreparingForLowPowerMode = false; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Host Entered in Idle Mode State..."); - //Signalling the cntrl pkt path in Ioctl + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Host Entered in Idle Mode State..."); + /* Signalling the cntrl pkt path in Ioctl*/ wake_up(&psAdapter->lowpower_mode_wait_queue); } - } - else if((pControlMsg->Leader.Status == LINK_UP_CONTROL_REQ) && + } else if ((pControlMsg->Leader.Status == LINK_UP_CONTROL_REQ) && (pControlMsg->szData[0] == LINK_UP_ACK) && (pControlMsg->szData[1] == LINK_SHUTDOWN_REQ_FROM_FIRMWARE) && - (pControlMsg->szData[2] == SHUTDOWN_ACK_FROM_DRIVER)) - { - //This covers the bus err while shutdown Request msg sent down. - if(urb->status != STATUS_SUCCESS) - { - psAdapter->bPreparingForLowPowerMode = FALSE ; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,"Shutdown Request Msg failed to reach to Modem"); - //Signalling the cntrl pkt path in Ioctl + (pControlMsg->szData[2] == SHUTDOWN_ACK_FROM_DRIVER)) { + /* This covers the bus err while shutdown Request msg sent down. */ + if (urb->status != STATUS_SUCCESS) { + psAdapter->bPreparingForLowPowerMode = false; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Shutdown Request Msg failed to reach to Modem"); + /* Signalling the cntrl pkt path in Ioctl */ wake_up(&psAdapter->lowpower_mode_wait_queue); StartInterruptUrb(psIntfAdapter); goto err_exit; } - bpowerDownMsg = TRUE ; - if(psAdapter->bDoSuspend == FALSE) - { + bpowerDownMsg = TRUE; + if (psAdapter->bDoSuspend == false) { psAdapter->bShutStatus = TRUE; - //since going in shutdown mode completed hence making this var false; - psAdapter->bPreparingForLowPowerMode = FALSE ; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,"Host Entered in shutdown Mode State..."); - //Signalling the cntrl pkt path in Ioctl + /* since going in shutdown mode completed hence making this var false */ + psAdapter->bPreparingForLowPowerMode = false; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Host Entered in shutdown Mode State..."); + /* Signalling the cntrl pkt path in Ioctl */ wake_up(&psAdapter->lowpower_mode_wait_queue); } } - if(psAdapter->bDoSuspend && bpowerDownMsg) - { - //issuing bus suspend request - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,"Issuing the Bus suspend request to USB stack"); + if (psAdapter->bDoSuspend && bpowerDownMsg) { + /* issuing bus suspend request */ + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Issuing the Bus suspend request to USB stack"); psIntfAdapter->bPreparingForBusSuspend = TRUE; schedule_work(&psIntfAdapter->usbSuspendWork); @@ -101,25 +87,24 @@ static void write_bulk_callback(struct urb *urb/*, struct pt_regs *regs*/) } -err_exit : +err_exit: usb_free_coherent(urb->dev, urb->transfer_buffer_length, - urb->transfer_buffer, urb->transfer_dma); + urb->transfer_buffer, urb->transfer_dma); } -static PUSB_TCB GetBulkOutTcb(PS_INTERFACE_ADAPTER psIntfAdapter) +static struct bcm_usb_tcb *GetBulkOutTcb(struct bcm_interface_adapter *psIntfAdapter) { - PUSB_TCB pTcb = NULL; + struct bcm_usb_tcb *pTcb = NULL; UINT index = 0; - if((atomic_read(&psIntfAdapter->uNumTcbUsed) < MAXIMUM_USB_TCB) && - (psIntfAdapter->psAdapter->StopAllXaction ==FALSE)) - { + if ((atomic_read(&psIntfAdapter->uNumTcbUsed) < MAXIMUM_USB_TCB) && + (psIntfAdapter->psAdapter->StopAllXaction == false)) { index = atomic_read(&psIntfAdapter->uCurrTcb); pTcb = &psIntfAdapter->asUsbTcb[index]; pTcb->bUsed = TRUE; - pTcb->psIntfAdapter= psIntfAdapter; - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Got Tx desc %d used %d", + pTcb->psIntfAdapter = psIntfAdapter; + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Got Tx desc %d used %d", index, atomic_read(&psIntfAdapter->uNumTcbUsed)); index = (index + 1) % MAXIMUM_USB_TCB; atomic_set(&psIntfAdapter->uCurrTcb, index); @@ -128,51 +113,44 @@ static PUSB_TCB GetBulkOutTcb(PS_INTERFACE_ADAPTER psIntfAdapter) return pTcb; } -static int TransmitTcb(PS_INTERFACE_ADAPTER psIntfAdapter, PUSB_TCB pTcb, PVOID data, int len) +static int TransmitTcb(struct bcm_interface_adapter *psIntfAdapter, struct bcm_usb_tcb *pTcb, PVOID data, int len) { struct urb *urb = pTcb->urb; int retval = 0; urb->transfer_buffer = usb_alloc_coherent(psIntfAdapter->udev, len, - GFP_ATOMIC, &urb->transfer_dma); - if (!urb->transfer_buffer) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Error allocating memory\n"); + GFP_ATOMIC, &urb->transfer_dma); + if (!urb->transfer_buffer) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, "Error allocating memory\n"); return -ENOMEM; } memcpy(urb->transfer_buffer, data, len); urb->transfer_buffer_length = len; - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Sending Bulk out packet\n"); - //For T3B,INT OUT end point will be used as bulk out end point - if((psIntfAdapter->psAdapter->chip_id == T3B) && (psIntfAdapter->bHighSpeedDevice == TRUE)) - { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Sending Bulk out packet\n"); + /* For T3B,INT OUT end point will be used as bulk out end point */ + if ((psIntfAdapter->psAdapter->chip_id == T3B) && (psIntfAdapter->bHighSpeedDevice == TRUE)) { usb_fill_int_urb(urb, psIntfAdapter->udev, - psIntfAdapter->sBulkOut.bulk_out_pipe, + psIntfAdapter->sBulkOut.bulk_out_pipe, urb->transfer_buffer, len, write_bulk_callback, pTcb, psIntfAdapter->sBulkOut.int_out_interval); - } - else - { + } else { usb_fill_bulk_urb(urb, psIntfAdapter->udev, psIntfAdapter->sBulkOut.bulk_out_pipe, urb->transfer_buffer, len, write_bulk_callback, pTcb); } urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; /* For DMA transfer */ - if(FALSE == psIntfAdapter->psAdapter->device_removed && - FALSE == psIntfAdapter->psAdapter->bEndPointHalted && - FALSE == psIntfAdapter->bSuspended && - FALSE == psIntfAdapter->bPreparingForBusSuspend) - { + if (false == psIntfAdapter->psAdapter->device_removed && + false == psIntfAdapter->psAdapter->bEndPointHalted && + false == psIntfAdapter->bSuspended && + false == psIntfAdapter->bPreparingForBusSuspend) { retval = usb_submit_urb(urb, GFP_ATOMIC); - if (retval) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "failed submitting write urb, error %d", retval); - if(retval == -EPIPE) - { - psIntfAdapter->psAdapter->bEndPointHalted = TRUE ; + if (retval) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "failed submitting write urb, error %d", retval); + if (retval == -EPIPE) { + psIntfAdapter->psAdapter->bEndPointHalted = TRUE; wake_up(&psIntfAdapter->psAdapter->tx_packet_wait_queue); } } @@ -182,13 +160,12 @@ static int TransmitTcb(PS_INTERFACE_ADAPTER psIntfAdapter, PUSB_TCB pTcb, PVOID int InterfaceTransmitPacket(PVOID arg, PVOID data, UINT len) { - PUSB_TCB pTcb= NULL; + struct bcm_usb_tcb *pTcb = NULL; - PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)arg; - pTcb= GetBulkOutTcb(psIntfAdapter); - if(pTcb == NULL) - { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "No URB to transmit packet, dropping packet"); + struct bcm_interface_adapter *psIntfAdapter = arg; + pTcb = GetBulkOutTcb(psIntfAdapter); + if (pTcb == NULL) { + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, "No URB to transmit packet, dropping packet"); return -EFAULT; } return TransmitTcb(psIntfAdapter, pTcb, data, len); diff --git a/drivers/staging/bcm/Ioctl.h b/drivers/staging/bcm/Ioctl.h index f859cf1c47b..797f862b90c 100644 --- a/drivers/staging/bcm/Ioctl.h +++ b/drivers/staging/bcm/Ioctl.h @@ -1,247 +1,136 @@ #ifndef _IOCTL_H_ #define _IOCTL_H_ -typedef struct rdmbuffer -{ - ULONG Register; - ULONG Length; -}__attribute__((packed)) RDM_BUFFER, *PRDM_BUFFER; - - -typedef struct wrmbuffer -{ - ULONG Register; - ULONG Length; - UCHAR Data[4]; -}__attribute__((packed)) WRM_BUFFER, *PWRM_BUFFER; - - -typedef struct ioctlbuffer -{ +struct bcm_rdm_buffer { + unsigned long Register; + unsigned long Length; +} __packed; + +struct bcm_wrm_buffer { + unsigned long Register; + unsigned long Length; + unsigned char Data[4]; +} __packed; + +struct bcm_ioctl_buffer { void __user *InputBuffer; - ULONG InputLength; + unsigned long InputLength; void __user *OutputBuffer; - ULONG OutputLength; -}__attribute__((packed)) IOCTL_BUFFER, *PIOCTL_BUFFER; - -typedef struct stGPIOInfo -{ - UINT uiGpioNumber ; /* valid numbers 0-15 */ - UINT uiGpioValue; /* 1 set ; 0 not set */ -}__attribute__((packed))GPIO_INFO,*PGPIO_INFO; -typedef struct stUserThreadReq -{ - //0->Inactivate LED thread. - //1->Activate the LED thread - UINT ThreadState; -}__attribute__((packed))USER_THREAD_REQ,*PUSER_THREAD_REQ; -#define LED_THREAD_ACTIVATION_REQ 1 - - -////********** ioctl codes ***********//// - -#define BCM_IOCTL 'k' - -//1.Control code for CONTROL MESSAGES - -#define IOCTL_SEND_CONTROL_MESSAGE _IOW(BCM_IOCTL, 0x801,int) - -//2.Control code to write a particular value to a particular register -#define IOCTL_BCM_REGISTER_WRITE _IOW(BCM_IOCTL, 0x802, int) // - -//3. -#define IOCTL_BCM_REGISTER_READ _IOR(BCM_IOCTL, 0x803, int) // + unsigned long OutputLength; +} __packed; -//4.Control code to write x number of bytes to common memory -//starting from address y -#define IOCTL_BCM_COMMON_MEMORY_WRITE _IOW(BCM_IOCTL, 0x804, int)// +struct bcm_gpio_info { + unsigned int uiGpioNumber; /* valid numbers 0-15 */ + unsigned int uiGpioValue; /* 1 set ; 0 not set */ +} __packed; -//5.Control code to write x number of bytes to common memory -//starting from address y -#define IOCTL_BCM_COMMON_MEMORY_READ _IOR(BCM_IOCTL, 0x805, int)// - -//6.Control code for CONTROL MESSAGES -#define IOCTL_GET_CONTROL_MESSAGE _IOR(BCM_IOCTL, 0x806, int)// - -//7.Control code for FIRMWARE DOWNLOAD -#define IOCTL_BCM_FIRMWARE_DOWNLOAD _IOW(BCM_IOCTL, 0x807, int)// - -#define IOCTL_BCM_SET_SEND_VCID _IOW(BCM_IOCTL, 0x808, int) - -//9.Control code for TRANSFER MODE SWITCHING -#define IOCTL_BCM_SWITCH_TRANSFER_MODE _IOW(BCM_IOCTL, 0x809, int) -//10.Control code for LINK UP -#define IOCTL_LINK_REQ _IOW(BCM_IOCTL, 0x80A, int) - -//11.Control code for RSSI Level Request -#define IOCTL_RSSI_LEVEL_REQ _IOW(BCM_IOCTL, 0x80B, int) -//12.Control code for IDLE MODE CONTROL -#define IOCTL_IDLE_REQ _IOW(BCM_IOCTL, 0x80C, int) -//13.Control code for SS/BS info -#define IOCTL_SS_INFO_REQ _IOW(BCM_IOCTL, 0x80D, int) +struct bcm_user_thread_req { + /* 0->Inactivate LED thread. */ + /* 1->Activate the LED thread */ + unsigned int ThreadState; +} __packed; +#define LED_THREAD_ACTIVATION_REQ 1 +#define BCM_IOCTL 'k' +#define IOCTL_SEND_CONTROL_MESSAGE _IOW(BCM_IOCTL, 0x801, int) +#define IOCTL_BCM_REGISTER_WRITE _IOW(BCM_IOCTL, 0x802, int) +#define IOCTL_BCM_REGISTER_READ _IOR(BCM_IOCTL, 0x803, int) +#define IOCTL_BCM_COMMON_MEMORY_WRITE _IOW(BCM_IOCTL, 0x804, int) +#define IOCTL_BCM_COMMON_MEMORY_READ _IOR(BCM_IOCTL, 0x805, int) +#define IOCTL_GET_CONTROL_MESSAGE _IOR(BCM_IOCTL, 0x806, int) +#define IOCTL_BCM_FIRMWARE_DOWNLOAD _IOW(BCM_IOCTL, 0x807, int) +#define IOCTL_BCM_SET_SEND_VCID _IOW(BCM_IOCTL, 0x808, int) +#define IOCTL_BCM_SWITCH_TRANSFER_MODE _IOW(BCM_IOCTL, 0x809, int) +#define IOCTL_LINK_REQ _IOW(BCM_IOCTL, 0x80A, int) +#define IOCTL_RSSI_LEVEL_REQ _IOW(BCM_IOCTL, 0x80B, int) +#define IOCTL_IDLE_REQ _IOW(BCM_IOCTL, 0x80C, int) +#define IOCTL_SS_INFO_REQ _IOW(BCM_IOCTL, 0x80D, int) #define IOCTL_GET_STATISTICS_POINTER _IOW(BCM_IOCTL, 0x80E, int) - -#define IOCTL_CM_REQUEST _IOW(BCM_IOCTL, 0x80F, int) - -#define IOCTL_INIT_PARAM_REQ _IOW(BCM_IOCTL, 0x810, int) - -#define IOCTL_MAC_ADDR_REQ _IOW(BCM_IOCTL, 0x811, int) - -#define IOCTL_MAC_ADDR_RESP _IOWR(BCM_IOCTL, 0x812, int) - -#define IOCTL_CLASSIFICATION_RULE _IOW(BCM_IOCTL, 0x813, char) - +#define IOCTL_CM_REQUEST _IOW(BCM_IOCTL, 0x80F, int) +#define IOCTL_INIT_PARAM_REQ _IOW(BCM_IOCTL, 0x810, int) +#define IOCTL_MAC_ADDR_REQ _IOW(BCM_IOCTL, 0x811, int) +#define IOCTL_MAC_ADDR_RESP _IOWR(BCM_IOCTL, 0x812, int) +#define IOCTL_CLASSIFICATION_RULE _IOW(BCM_IOCTL, 0x813, char) #define IOCTL_CLOSE_NOTIFICATION _IO(BCM_IOCTL, 0x814) - -#define IOCTL_LINK_UP _IO(BCM_IOCTL, 0x815) - -#define IOCTL_LINK_DOWN _IO(BCM_IOCTL, 0x816, IOCTL_BUFFER) - -#define IOCTL_CHIP_RESET _IO(BCM_IOCTL, 0x816) - +#define IOCTL_LINK_UP _IO(BCM_IOCTL, 0x815) +#define IOCTL_LINK_DOWN _IO(BCM_IOCTL, 0x816, struct bcm_ioctl_buffer) +#define IOCTL_CHIP_RESET _IO(BCM_IOCTL, 0x816) #define IOCTL_CINR_LEVEL_REQ _IOW(BCM_IOCTL, 0x817, char) - -#define IOCTL_WTM_CONTROL_REQ _IOW(BCM_IOCTL, 0x817,char) - +#define IOCTL_WTM_CONTROL_REQ _IOW(BCM_IOCTL, 0x817, char) #define IOCTL_BE_BUCKET_SIZE _IOW(BCM_IOCTL, 0x818, unsigned long) - #define IOCTL_RTPS_BUCKET_SIZE _IOW(BCM_IOCTL, 0x819, unsigned long) - -#define IOCTL_QOS_THRESHOLD _IOW(BCM_IOCTL, 0x820, unsigned long) - -#define IOCTL_DUMP_PACKET_INFO _IO(BCM_IOCTL, 0x821) - -#define IOCTL_GET_PACK_INFO _IOR(BCM_IOCTL, 0x823, int) - +#define IOCTL_QOS_THRESHOLD _IOW(BCM_IOCTL, 0x820, unsigned long) +#define IOCTL_DUMP_PACKET_INFO _IO(BCM_IOCTL, 0x821) +#define IOCTL_GET_PACK_INFO _IOR(BCM_IOCTL, 0x823, int) #define IOCTL_BCM_GET_DRIVER_VERSION _IOR(BCM_IOCTL, 0x829, int) - -#define IOCTL_BCM_GET_CURRENT_STATUS _IOW(BCM_IOCTL, 0x828, int) - -#define IOCTL_BCM_GPIO_SET_REQUEST _IOW(BCM_IOCTL, 0x82A, int) - -#define IOCTL_BCM_GPIO_STATUS_REQUEST _IOW(BCM_IOCTL, 0x82b, int) - -#define IOCTL_BCM_GET_DSX_INDICATION _IOR(BCM_IOCTL, 0x854, int) - -#define IOCTL_BCM_BUFFER_DOWNLOAD_START _IOW(BCM_IOCTL, 0x855, int) - -#define IOCTL_BCM_BUFFER_DOWNLOAD _IOW(BCM_IOCTL, 0x856, int) - -#define IOCTL_BCM_BUFFER_DOWNLOAD_STOP _IOW(BCM_IOCTL, 0x857, int) - -#define IOCTL_BCM_REGISTER_WRITE_PRIVATE _IOW(BCM_IOCTL, 0x826, char) - +#define IOCTL_BCM_GET_CURRENT_STATUS _IOW(BCM_IOCTL, 0x828, int) +#define IOCTL_BCM_GPIO_SET_REQUEST _IOW(BCM_IOCTL, 0x82A, int) +#define IOCTL_BCM_GPIO_STATUS_REQUEST _IOW(BCM_IOCTL, 0x82b, int) +#define IOCTL_BCM_GET_DSX_INDICATION _IOR(BCM_IOCTL, 0x854, int) +#define IOCTL_BCM_BUFFER_DOWNLOAD_START _IOW(BCM_IOCTL, 0x855, int) +#define IOCTL_BCM_BUFFER_DOWNLOAD _IOW(BCM_IOCTL, 0x856, int) +#define IOCTL_BCM_BUFFER_DOWNLOAD_STOP _IOW(BCM_IOCTL, 0x857, int) +#define IOCTL_BCM_REGISTER_WRITE_PRIVATE _IOW(BCM_IOCTL, 0x826, char) #define IOCTL_BCM_REGISTER_READ_PRIVATE _IOW(BCM_IOCTL, 0x827, char) - -#define IOCTL_BCM_SET_DEBUG _IOW(BCM_IOCTL, 0x824, IOCTL_BUFFER) - -#define IOCTL_BCM_EEPROM_REGISTER_WRITE _IOW(BCM_IOCTL, 0x858, int) - -#define IOCTL_BCM_EEPROM_REGISTER_READ _IOR(BCM_IOCTL, 0x859, int) - +#define IOCTL_BCM_SET_DEBUG _IOW(BCM_IOCTL, 0x824, struct bcm_ioctl_buffer) +#define IOCTL_BCM_EEPROM_REGISTER_WRITE _IOW(BCM_IOCTL, 0x858, int) +#define IOCTL_BCM_EEPROM_REGISTER_READ _IOR(BCM_IOCTL, 0x859, int) #define IOCTL_BCM_WAKE_UP_DEVICE_FROM_IDLE _IOR(BCM_IOCTL, 0x860, int) - -#define IOCTL_BCM_SET_MAC_TRACING _IOW(BCM_IOCTL, 0x82c, int) - -#define IOCTL_BCM_GET_HOST_MIBS _IOW(BCM_IOCTL, 0x853, int) - -#define IOCTL_BCM_NVM_READ _IOR(BCM_IOCTL, 0x861, int) - -#define IOCTL_BCM_NVM_WRITE _IOW(BCM_IOCTL, 0x862, int) - -#define IOCTL_BCM_GET_NVM_SIZE _IOR(BCM_IOCTL, 0x863, int) - -#define IOCTL_BCM_CAL_INIT _IOR(BCM_IOCTL, 0x864, int) - -#define IOCTL_BCM_BULK_WRM _IOW(BCM_IOCTL, 0x90B, int) - -#define IOCTL_BCM_FLASH2X_SECTION_READ _IOR(BCM_IOCTL, 0x865, int) - +#define IOCTL_BCM_SET_MAC_TRACING _IOW(BCM_IOCTL, 0x82c, int) +#define IOCTL_BCM_GET_HOST_MIBS _IOW(BCM_IOCTL, 0x853, int) +#define IOCTL_BCM_NVM_READ _IOR(BCM_IOCTL, 0x861, int) +#define IOCTL_BCM_NVM_WRITE _IOW(BCM_IOCTL, 0x862, int) +#define IOCTL_BCM_GET_NVM_SIZE _IOR(BCM_IOCTL, 0x863, int) +#define IOCTL_BCM_CAL_INIT _IOR(BCM_IOCTL, 0x864, int) +#define IOCTL_BCM_BULK_WRM _IOW(BCM_IOCTL, 0x90B, int) +#define IOCTL_BCM_FLASH2X_SECTION_READ _IOR(BCM_IOCTL, 0x865, int) #define IOCTL_BCM_FLASH2X_SECTION_WRITE _IOW(BCM_IOCTL, 0x866, int) +#define IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP _IOR(BCM_IOCTL, 0x867, int) +#define IOCTL_BCM_SET_ACTIVE_SECTION _IOW(BCM_IOCTL, 0x868, int) +#define IOCTL_BCM_IDENTIFY_ACTIVE_SECTION _IO(BCM_IOCTL, 0x869) +#define IOCTL_BCM_COPY_SECTION _IOW(BCM_IOCTL, 0x870, int) +#define IOCTL_BCM_GET_FLASH_CS_INFO _IOR(BCM_IOCTL, 0x871, int) +#define IOCTL_BCM_SELECT_DSD _IOW(BCM_IOCTL, 0x872, int) +#define IOCTL_BCM_NVM_RAW_READ _IOR(BCM_IOCTL, 0x875, int) +#define IOCTL_BCM_CNTRLMSG_MASK _IOW(BCM_IOCTL, 0x874, int) +#define IOCTL_BCM_GET_DEVICE_DRIVER_INFO _IOR(BCM_IOCTL, 0x877, int) +#define IOCTL_BCM_TIME_SINCE_NET_ENTRY _IOR(BCM_IOCTL, 0x876, int) +#define BCM_LED_THREAD_STATE_CHANGE_REQ _IOW(BCM_IOCTL, 0x878, int) +#define IOCTL_BCM_GPIO_MULTI_REQUEST _IOW(BCM_IOCTL, 0x82D, struct bcm_ioctl_buffer) +#define IOCTL_BCM_GPIO_MODE_REQUEST _IOW(BCM_IOCTL, 0x82E, struct bcm_ioctl_buffer) + +enum bcm_interface_type { + BCM_MII, + BCM_CARDBUS, + BCM_USB, + BCM_SDIO, + BCM_PCMCIA +}; -#define IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP _IOR(BCM_IOCTL,0x867, int) - -#define IOCTL_BCM_SET_ACTIVE_SECTION _IOW(BCM_IOCTL,0x868, int) - -#define IOCTL_BCM_IDENTIFY_ACTIVE_SECTION _IO(BCM_IOCTL,0x869) - -#define IOCTL_BCM_COPY_SECTION _IOW(BCM_IOCTL, 0x870,int) - -#define IOCTL_BCM_GET_FLASH_CS_INFO _IOR(BCM_IOCTL, 0x871, int) - -#define IOCTL_BCM_SELECT_DSD _IOW(BCM_IOCTL, 0x872, int) - -#define IOCTL_BCM_NVM_RAW_READ _IOR(BCM_IOCTL, 0x875, int) - -#define IOCTL_BCM_CNTRLMSG_MASK _IOW(BCM_IOCTL, 0x874, int) - -#define IOCTL_BCM_GET_DEVICE_DRIVER_INFO _IOR(BCM_IOCTL, 0x877, int) - -#define IOCTL_BCM_TIME_SINCE_NET_ENTRY _IOR(BCM_IOCTL, 0x876, int) - -#define BCM_LED_THREAD_STATE_CHANGE_REQ _IOW(BCM_IOCTL, 0x878, int) - -#define IOCTL_BCM_GPIO_MULTI_REQUEST _IOW(BCM_IOCTL, 0x82D, IOCTL_BUFFER) -#define IOCTL_BCM_GPIO_MODE_REQUEST _IOW(BCM_IOCTL, 0x82E, IOCTL_BUFFER) - - - -typedef enum _BCM_INTERFACE_TYPE -{ - BCM_MII, - BCM_CARDBUS, - BCM_USB, - BCM_SDIO, - BCM_PCMCIA -}BCM_INTERFACE_TYPE; - -typedef struct _DEVICE_DRIVER_INFO -{ - NVM_TYPE u32NVMType; - UINT MaxRDMBufferSize; - BCM_INTERFACE_TYPE u32InterfaceType; - UINT u32DSDStartOffset; - UINT u32RxAlignmentCorrection; - UINT u32Reserved[10]; -} DEVICE_DRIVER_INFO; - -typedef struct _NVM_READWRITE -{ +struct bcm_driver_info { + enum bcm_nvm_type u32NVMType; + unsigned int MaxRDMBufferSize; + enum bcm_interface_type u32InterfaceType; + unsigned int u32DSDStartOffset; + unsigned int u32RxAlignmentCorrection; + unsigned int u32Reserved[10]; +}; +struct bcm_nvm_readwrite { void __user *pBuffer; -// Data to be written from|read to. Memory should be allocated by the caller. - uint32_t uiOffset; -// offset at which data should be written to or read from. - - uint32_t uiNumBytes; -// No. of bytes to be written or read. - - bool bVerify; -// Applicable only for write. If set verification of written data will be done. - -} NVM_READWRITE,*PNVM_READWRITE; -typedef struct bulkwrmbuffer -{ - ULONG Register; - ULONG SwapEndian; - ULONG Values[1]; - -}BULKWRM_BUFFER,*PBULKWRM_BUFFER; - - -/***********Structure used for FlashMap2.x *******************************/ + uint32_t uiNumBytes; + bool bVerify; +}; -/* -* These are Sction present inside the Flash. -* There is sectional RD/WR for flash Map 2.x. -* hence these section will be used in read/write API. -*/ +struct bcm_bulk_wrm_buffer { + unsigned long Register; + unsigned long SwapEndian; + unsigned long Values[1]; +}; -typedef enum _FLASH2X_SECTION_VAL -{ - NO_SECTION_VAL = 0, //no section is chosen when absolute offset is given for RD/WR +enum bcm_flash2x_section_val { + NO_SECTION_VAL = 0, /* no section is chosen when absolute offset is given for RD/WR */ ISO_IMAGE1, ISO_IMAGE2, DSD0, @@ -257,104 +146,81 @@ typedef enum _FLASH2X_SECTION_VAL ISO_IMAGE2_PART2, ISO_IMAGE2_PART3, TOTAL_SECTIONS -}FLASH2X_SECTION_VAL; +}; /* -* Structure used for READ/WRITE Flash Map2.x -*/ -typedef struct _FLASH2X_READWRITE -{ - - FLASH2X_SECTION_VAL Section; //which section has to be read/written - B_UINT32 offset; //Offset within Section. - B_UINT32 numOfBytes; //NOB from the offset - B_UINT32 bVerify; - void __user *pDataBuff; //Buffer for reading/writing + * Structure used for READ/WRITE Flash Map2.x + */ +struct bcm_flash2x_readwrite { + enum bcm_flash2x_section_val Section; /* which section has to be read/written */ + u32 offset; /* Offset within Section. */ + u32 numOfBytes; /* NOB from the offset */ + u32 bVerify; + void __user *pDataBuff; /* Buffer for reading/writing */ +}; -}FLASH2X_READWRITE, *PFLASH2X_READWRITE; /* -* This structure is used for coping one section to other. -* there are two ways to copy one section to other. -* it NOB =0, complete section will be copied on to other. -* if NOB !=0, only NOB will be copied from the given offset. -*/ - -typedef struct _FLASH2X_COPY_SECTION -{ - //Src Section from which Data has to be copied to DstSection - FLASH2X_SECTION_VAL SrcSection; - - //Destination Section from where Data has to be coppied. - FLASH2X_SECTION_VAL DstSection; - - //Offset within Section. if NOB =0 it will be ignored and data will be coped from offset 0. - B_UINT32 offset; - - //NOB from the offset. if NOB = 0 complete src section will be copied to Destination section. - B_UINT32 numOfBytes; -} FLASH2X_COPY_SECTION, *PFLASH2X_COPY_SECTION; - - -typedef enum _SECTION_TYPE -{ - ISO = 0, - VSA = 1, - DSD = 2 -} SECTION_TYPE, *PSECTION_TYPE; + * This structure is used for coping one section to other. + * there are two ways to copy one section to other. + * it NOB =0, complete section will be copied on to other. + * if NOB !=0, only NOB will be copied from the given offset. + */ + +struct bcm_flash2x_copy_section { + enum bcm_flash2x_section_val SrcSection; + enum bcm_flash2x_section_val DstSection; + u32 offset; + u32 numOfBytes; +}; /* -* This section provide the complete bitmap of the Flash. -* using this map lib/APP will isssue read/write command. - Fields are defined as : - Bit [0] = section is present //1:present, 0: Not present -* Bit [1] = section is valid //1: valid, 0: not valid -* Bit [2] = Section is R/W //0: RW, 1: RO -* Bit [3] = Section is Active or not 1 means Active, 0->inactive -* Bit [7...3] = Reserved -*/ - -typedef struct _FLASH2X_BITMAP -{ - UCHAR ISO_IMAGE1; - UCHAR ISO_IMAGE2; - UCHAR DSD0; - UCHAR DSD1; - UCHAR DSD2; - UCHAR VSA0; - UCHAR VSA1; - UCHAR VSA2; - UCHAR SCSI; - UCHAR CONTROL_SECTION; - //Reserved for future use - UCHAR Reserved0; - UCHAR Reserved1; - UCHAR Reserved2; -}FLASH2X_BITMAP, *PFLASH2X_BITMAP; + * This section provide the complete bitmap of the Flash. + * using this map lib/APP will issue read/write command. + * Fields are defined as : + * Bit [0] = section is present //1:present, 0: Not present + * Bit [1] = section is valid //1: valid, 0: not valid + * Bit [2] = Section is R/W //0: RW, 1: RO + * Bit [3] = Section is Active or not 1 means Active, 0->inactive + * Bit [7...3] = Reserved + */ + +struct bcm_flash2x_bitmap { + unsigned char ISO_IMAGE1; + unsigned char ISO_IMAGE2; + unsigned char DSD0; + unsigned char DSD1; + unsigned char DSD2; + unsigned char VSA0; + unsigned char VSA1; + unsigned char VSA2; + unsigned char SCSI; + unsigned char CONTROL_SECTION; + /* Reserved for future use */ + unsigned char Reserved0; + unsigned char Reserved1; + unsigned char Reserved2; +}; -//for net entry time check -typedef struct _ST_TIME_ELAPSED_ -{ - ULONG64 ul64TimeElapsedSinceNetEntry; - UINT32 uiReserved[4]; //By chance if required for future proofing -}ST_TIME_ELAPSED,*PST_TIME_ELAPSED; +struct bcm_time_elapsed { + u64 ul64TimeElapsedSinceNetEntry; + u32 uiReserved[4]; +}; enum { - WIMAX_IDX=0, /*To access WiMAX chip GPIO's for GPIO_MULTI_INFO or GPIO_MULTI_MODE*/ - HOST_IDX, /*To access Host chip GPIO's for GPIO_MULTI_INFO or GPIO_MULTI_MODE*/ - MAX_IDX + WIMAX_IDX = 0, /* To access WiMAX chip GPIO's for GPIO_MULTI_INFO or GPIO_MULTI_MODE */ + HOST_IDX, /* To access Host chip GPIO's for GPIO_MULTI_INFO or GPIO_MULTI_MODE */ + MAX_IDX }; -typedef struct stGPIOMultiInfo -{ - UINT uiGPIOCommand; /* 1 for set and 0 for get*/ - UINT uiGPIOMask; /* set the correspondig bit to 1 to access GPIO*/ - UINT uiGPIOValue; /* 0 or 1; value to be set when command is 1.*/ -}__attribute__((packed))GPIO_MULTI_INFO , *PGPIO_MULTI_INFO; -typedef struct stGPIOMultiMode -{ - UINT uiGPIOMode; /* 1 for OUT mode, 0 for IN mode*/ - UINT uiGPIOMask; /* GPIO mask to set mode*/ -}__attribute__((packed))GPIO_MULTI_MODE, *PGPIO_MULTI_MODE; +struct bcm_gpio_multi_info { + unsigned int uiGPIOCommand; /* 1 for set and 0 for get */ + unsigned int uiGPIOMask; /* set the correspondig bit to 1 to access GPIO */ + unsigned int uiGPIOValue; /* 0 or 1; value to be set when command is 1. */ +} __packed; +struct bcm_gpio_multi_mode { + unsigned int uiGPIOMode; /* 1 for OUT mode, 0 for IN mode */ + unsigned int uiGPIOMask; /* GPIO mask to set mode */ +} __packed; #endif 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/LeakyBucket.c b/drivers/staging/bcm/LeakyBucket.c index 6e8a3279698..f95b06713a2 100644 --- a/drivers/staging/bcm/LeakyBucket.c +++ b/drivers/staging/bcm/LeakyBucket.c @@ -17,45 +17,42 @@ static VOID UpdateTokenCount(register struct bcm_mini_adapter *Adapter) { - ULONG liCurrentTime; - INT i = 0; + ULONG liCurrentTime; + INT i = 0; struct timeval tv; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "=====>\n"); - if(NULL == Adapter) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "Adapter found NULL!\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, + "=====>\n"); + if (NULL == Adapter) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, + DBG_LVL_ALL, "Adapter found NULL!\n"); return; } do_gettimeofday(&tv); - for(i = 0; i < NO_OF_QUEUES; i++) - { - if(TRUE == Adapter->PackInfo[i].bValid && - (1 == Adapter->PackInfo[i].ucDirection)) - { + for (i = 0; i < NO_OF_QUEUES; i++) { + if (TRUE == Adapter->PackInfo[i].bValid && + (1 == Adapter->PackInfo[i].ucDirection)) { liCurrentTime = ((tv.tv_sec- Adapter->PackInfo[i].stLastUpdateTokenAt.tv_sec)*1000 + (tv.tv_usec-Adapter->PackInfo[i].stLastUpdateTokenAt.tv_usec)/ 1000); - if(0!=liCurrentTime) - { + if (0 != liCurrentTime) { Adapter->PackInfo[i].uiCurrentTokenCount += (ULONG) ((Adapter->PackInfo[i].uiMaxAllowedRate) * ((ULONG)((liCurrentTime)))/1000); memcpy(&Adapter->PackInfo[i].stLastUpdateTokenAt, &tv, sizeof(struct timeval)); Adapter->PackInfo[i].liLastUpdateTokenAt = liCurrentTime; - if((Adapter->PackInfo[i].uiCurrentTokenCount) >= - Adapter->PackInfo[i].uiMaxBucketSize) - { + if (Adapter->PackInfo[i].uiCurrentTokenCount >= + Adapter->PackInfo[i].uiMaxBucketSize) { Adapter->PackInfo[i].uiCurrentTokenCount = Adapter->PackInfo[i].uiMaxBucketSize; } } } } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "<=====\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "<=====\n"); return; } @@ -77,33 +74,26 @@ static VOID UpdateTokenCount(register struct bcm_mini_adapter *Adapter) ***********************************************************************/ static ULONG GetSFTokenCount(struct bcm_mini_adapter *Adapter, struct bcm_packet_info *psSF) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IsPacketAllowedForFlow ===>"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IsPacketAllowedForFlow ===>"); /* Validate the parameters */ - if(NULL == Adapter || (psSF < Adapter->PackInfo && - (uintptr_t)psSF > (uintptr_t) &Adapter->PackInfo[HiPriority])) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IPAFF: Got wrong Parameters:Adapter: %p, QIndex: %zd\n", Adapter, (psSF-Adapter->PackInfo)); + if (NULL == Adapter || (psSF < Adapter->PackInfo && + (uintptr_t)psSF > (uintptr_t) &Adapter->PackInfo[HiPriority])) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IPAFF: Got wrong Parameters:Adapter: %p, QIndex: %zd\n", Adapter, (psSF-Adapter->PackInfo)); return 0; } - if(FALSE != psSF->bValid && psSF->ucDirection) - { - if(0 != psSF->uiCurrentTokenCount) - { + if (false != psSF->bValid && psSF->ucDirection) { + if (0 != psSF->uiCurrentTokenCount) { return psSF->uiCurrentTokenCount; - } - else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "Not enough tokens in queue %zd Available %u\n", + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "Not enough tokens in queue %zd Available %u\n", psSF-Adapter->PackInfo, psSF->uiCurrentTokenCount); psSF->uiPendedLast = 1; } + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IPAFF: Queue %zd not valid\n", psSF-Adapter->PackInfo); } - else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IPAFF: Queue %zd not valid\n", psSF-Adapter->PackInfo); - } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IsPacketAllowedForFlow <==="); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IsPacketAllowedForFlow <==="); return 0; } @@ -114,33 +104,29 @@ This function despatches packet from the specified queue. */ static INT SendPacketFromQueue(struct bcm_mini_adapter *Adapter,/**<Logical Adapter*/ struct bcm_packet_info *psSF, /**<Queue identifier*/ - struct sk_buff* Packet) /**<Pointer to the packet to be sent*/ + struct sk_buff *Packet) /**<Pointer to the packet to be sent*/ { - INT Status=STATUS_FAILURE; - UINT uiIndex =0,PktLen = 0; + INT Status = STATUS_FAILURE; + UINT uiIndex = 0, PktLen = 0; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, SEND_QUEUE, DBG_LVL_ALL, "=====>"); - if(!Adapter || !Packet || !psSF) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, SEND_QUEUE, DBG_LVL_ALL, "Got NULL Adapter or Packet"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, SEND_QUEUE, DBG_LVL_ALL, "=====>"); + if (!Adapter || !Packet || !psSF) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, SEND_QUEUE, DBG_LVL_ALL, "Got NULL Adapter or Packet"); return -EINVAL; } - if(psSF->liDrainCalculated==0) - { + if (psSF->liDrainCalculated == 0) psSF->liDrainCalculated = jiffies; - } - ///send the packet to the fifo.. + /* send the packet to the fifo.. */ PktLen = Packet->len; Status = SetupNextSend(Adapter, Packet, psSF->usVCID_Value); - if(Status == 0) - { - for(uiIndex = 0 ; uiIndex < MIBS_MAX_HIST_ENTRIES ; uiIndex++) - { if((PktLen <= MIBS_PKTSIZEHIST_RANGE*(uiIndex+1)) && (PktLen > MIBS_PKTSIZEHIST_RANGE*(uiIndex))) + if (Status == 0) { + for (uiIndex = 0; uiIndex < MIBS_MAX_HIST_ENTRIES; uiIndex++) { + if ((PktLen <= MIBS_PKTSIZEHIST_RANGE*(uiIndex+1)) && (PktLen > MIBS_PKTSIZEHIST_RANGE*(uiIndex))) Adapter->aTxPktSizeHist[uiIndex]++; } } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, SEND_QUEUE, DBG_LVL_ALL, "<====="); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, SEND_QUEUE, DBG_LVL_ALL, "<====="); return Status; } @@ -158,107 +144,93 @@ static INT SendPacketFromQueue(struct bcm_mini_adapter *Adapter,/**<Logical Adap ****************************************************************************/ static VOID CheckAndSendPacketFromIndex(struct bcm_mini_adapter *Adapter, struct bcm_packet_info *psSF) { - struct sk_buff *QueuePacket=NULL; - char *pControlPacket = NULL; - INT Status=0; - int iPacketLen=0; + struct sk_buff *QueuePacket = NULL; + char *pControlPacket = NULL; + INT Status = 0; + int iPacketLen = 0; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "%zd ====>", (psSF-Adapter->PackInfo)); - if((psSF != &Adapter->PackInfo[HiPriority]) && Adapter->LinkUpStatus && atomic_read(&psSF->uiPerSFTxResourceCount))//Get data packet - { - if(!psSF->ucDirection ) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "%zd ====>", (psSF-Adapter->PackInfo)); + if ((psSF != &Adapter->PackInfo[HiPriority]) && Adapter->LinkUpStatus && atomic_read(&psSF->uiPerSFTxResourceCount)) { /* Get data packet */ + if (!psSF->ucDirection) return; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "UpdateTokenCount "); - if(Adapter->IdleMode || Adapter->bPreparingForLowPowerMode) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "UpdateTokenCount "); + if (Adapter->IdleMode || Adapter->bPreparingForLowPowerMode) return; /* in idle mode */ - // Check for Free Descriptors - if(atomic_read(&Adapter->CurrNumFreeTxDesc) <= MINIMUM_PENDING_DESCRIPTORS) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, " No Free Tx Descriptor(%d) is available for Data pkt..",atomic_read(&Adapter->CurrNumFreeTxDesc)); - return ; + /* Check for Free Descriptors */ + if (atomic_read(&Adapter->CurrNumFreeTxDesc) <= MINIMUM_PENDING_DESCRIPTORS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, " No Free Tx Descriptor(%d) is available for Data pkt..", atomic_read(&Adapter->CurrNumFreeTxDesc)); + return; } spin_lock_bh(&psSF->SFQueueLock); - QueuePacket=psSF->FirstTxQueue; + QueuePacket = psSF->FirstTxQueue; - if(QueuePacket) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Dequeuing Data Packet"); + if (QueuePacket) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Dequeuing Data Packet"); - if(psSF->bEthCSSupport) + if (psSF->bEthCSSupport) iPacketLen = QueuePacket->len; else iPacketLen = QueuePacket->len-ETH_HLEN; - iPacketLen<<=3; - if(iPacketLen <= GetSFTokenCount(Adapter, psSF)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Allowed bytes %d", + iPacketLen <<= 3; + if (iPacketLen <= GetSFTokenCount(Adapter, psSF)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Allowed bytes %d", (iPacketLen >> 3)); - DEQUEUEPACKET(psSF->FirstTxQueue,psSF->LastTxQueue); + DEQUEUEPACKET(psSF->FirstTxQueue, psSF->LastTxQueue); psSF->uiCurrentBytesOnHost -= (QueuePacket->len); psSF->uiCurrentPacketsOnHost--; atomic_dec(&Adapter->TotalPacketCount); spin_unlock_bh(&psSF->SFQueueLock); - Status = SendPacketFromQueue(Adapter, psSF, QueuePacket); - psSF->uiPendedLast = FALSE; - } - else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "For Queue: %zd\n", psSF-Adapter->PackInfo); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "\nAvailable Tokens = %d required = %d\n", + Status = SendPacketFromQueue(Adapter, psSF, QueuePacket); + psSF->uiPendedLast = false; + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "For Queue: %zd\n", psSF-Adapter->PackInfo); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "\nAvailable Tokens = %d required = %d\n", psSF->uiCurrentTokenCount, iPacketLen); - //this part indicates that because of non-availability of the tokens - //pkt has not been send out hence setting the pending flag indicating the host to send it out - //first next iteration . + /* + this part indicates that because of non-availability of the tokens + pkt has not been send out hence setting the pending flag indicating the host to send it out + first next iteration. + */ psSF->uiPendedLast = TRUE; spin_unlock_bh(&psSF->SFQueueLock); } - } - else - { + } else { spin_unlock_bh(&psSF->SFQueueLock); } - } - else - { - - if((atomic_read(&Adapter->CurrNumFreeTxDesc) > 0 ) && - (atomic_read(&Adapter->index_rd_txcntrlpkt) != - atomic_read(&Adapter->index_wr_txcntrlpkt)) - ) - { + } else { + + if ((atomic_read(&Adapter->CurrNumFreeTxDesc) > 0) && + (atomic_read(&Adapter->index_rd_txcntrlpkt) != + atomic_read(&Adapter->index_wr_txcntrlpkt))) { pControlPacket = Adapter->txctlpacket [(atomic_read(&Adapter->index_rd_txcntrlpkt)%MAX_CNTRL_PKTS)]; - if(pControlPacket) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Sending Control packet"); + if (pControlPacket) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Sending Control packet"); Status = SendControlPacket(Adapter, pControlPacket); - if(STATUS_SUCCESS==Status) - { + if (STATUS_SUCCESS == Status) { spin_lock_bh(&psSF->SFQueueLock); psSF->NumOfPacketsSent++; - psSF->uiSentBytes+=((struct bcm_leader *)pControlPacket)->PLength; + psSF->uiSentBytes += ((struct bcm_leader *)pControlPacket)->PLength; psSF->uiSentPackets++; atomic_dec(&Adapter->TotalPacketCount); psSF->uiCurrentBytesOnHost -= ((struct bcm_leader *)pControlPacket)->PLength; psSF->uiCurrentPacketsOnHost--; atomic_inc(&Adapter->index_rd_txcntrlpkt); spin_unlock_bh(&psSF->SFQueueLock); + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "SendControlPacket Failed\n"); } - else - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "SendControlPacket Failed\n"); - } - else - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, " Control Pkt is not available, Indexing is wrong...."); + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, " Control Pkt is not available, Indexing is wrong...."); } - } + } } } @@ -275,79 +247,71 @@ static VOID CheckAndSendPacketFromIndex(struct bcm_mini_adapter *Adapter, struct ********************************************************************/ VOID transmit_packets(struct bcm_mini_adapter *Adapter) { - UINT uiPrevTotalCount = 0; + UINT uiPrevTotalCount = 0; int iIndex = 0; - BOOLEAN exit_flag = TRUE ; + bool exit_flag = TRUE; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "=====>"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "=====>"); - if(NULL == Adapter) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX,TX_PACKETS, DBG_LVL_ALL, "Got NULL Adapter"); + if (NULL == Adapter) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Got NULL Adapter"); return; } - if(Adapter->device_removed == TRUE) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Device removed"); + if (Adapter->device_removed == TRUE) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Device removed"); return; } - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "\nUpdateTokenCount ====>\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "\nUpdateTokenCount ====>\n"); UpdateTokenCount(Adapter); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "\nPruneQueueAllSF ====>\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "\nPruneQueueAllSF ====>\n"); PruneQueueAllSF(Adapter); uiPrevTotalCount = atomic_read(&Adapter->TotalPacketCount); - for(iIndex=HiPriority;iIndex>=0;iIndex--) - { - if( !uiPrevTotalCount || (TRUE == Adapter->device_removed)) + for (iIndex = HiPriority; iIndex >= 0; iIndex--) { + if (!uiPrevTotalCount || (TRUE == Adapter->device_removed)) break; - if(Adapter->PackInfo[iIndex].bValid && - Adapter->PackInfo[iIndex].uiPendedLast && - Adapter->PackInfo[iIndex].uiCurrentBytesOnHost) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Calling CheckAndSendPacketFromIndex.."); + if (Adapter->PackInfo[iIndex].bValid && + Adapter->PackInfo[iIndex].uiPendedLast && + Adapter->PackInfo[iIndex].uiCurrentBytesOnHost) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Calling CheckAndSendPacketFromIndex.."); CheckAndSendPacketFromIndex(Adapter, &Adapter->PackInfo[iIndex]); uiPrevTotalCount--; } } - while(uiPrevTotalCount > 0 && !Adapter->device_removed) - { - exit_flag = TRUE ; - //second iteration to parse non-pending queues - for(iIndex=HiPriority;iIndex>=0;iIndex--) - { - if( !uiPrevTotalCount || (TRUE == Adapter->device_removed)) - break; - - if(Adapter->PackInfo[iIndex].bValid && - Adapter->PackInfo[iIndex].uiCurrentBytesOnHost && - !Adapter->PackInfo[iIndex].uiPendedLast ) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Calling CheckAndSendPacketFromIndex.."); + while (uiPrevTotalCount > 0 && !Adapter->device_removed) { + exit_flag = TRUE; + /* second iteration to parse non-pending queues */ + for (iIndex = HiPriority; iIndex >= 0; iIndex--) { + if (!uiPrevTotalCount || (TRUE == Adapter->device_removed)) + break; + + if (Adapter->PackInfo[iIndex].bValid && + Adapter->PackInfo[iIndex].uiCurrentBytesOnHost && + !Adapter->PackInfo[iIndex].uiPendedLast) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Calling CheckAndSendPacketFromIndex.."); CheckAndSendPacketFromIndex(Adapter, &Adapter->PackInfo[iIndex]); uiPrevTotalCount--; - exit_flag = FALSE; + exit_flag = false; } } - if(Adapter->IdleMode || Adapter->bPreparingForLowPowerMode) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "In Idle Mode\n"); + if (Adapter->IdleMode || Adapter->bPreparingForLowPowerMode) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "In Idle Mode\n"); break; } - if(exit_flag == TRUE ) - break ; - }/* end of inner while loop */ + if (exit_flag == TRUE) + break; + } /* end of inner while loop */ - update_per_cid_rx (Adapter); + update_per_cid_rx(Adapter); Adapter->txtransmit_running = 0; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "<======"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "<======"); } diff --git a/drivers/staging/bcm/Macros.h b/drivers/staging/bcm/Macros.h index 46f5f0feea8..dc01e3016d4 100644 --- a/drivers/staging/bcm/Macros.h +++ b/drivers/staging/bcm/Macros.h @@ -162,13 +162,11 @@ #define GPIO_MODE_REGISTER 0x0F000034 #define GPIO_PIN_STATE_REGISTER 0x0F000038 - -typedef struct _LINK_STATE { - UCHAR ucLinkStatus; - UCHAR bIdleMode; - UCHAR bShutdownMode; -} LINK_STATE, *PLINK_STATE; - +struct bcm_link_state { + unsigned char ucLinkStatus; + unsigned char bIdleMode; + unsigned char bShutdownMode; +}; enum enLinkStatus { WAIT_FOR_SYNC = 1, @@ -182,13 +180,12 @@ enum enLinkStatus { COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW = 9 }; -typedef enum _E_PHS_DSC_ACTION { +enum bcm_phs_dsc_action { eAddPHSRule = 0, eSetPHSRule, eDeletePHSRule, eDeleteAllPHSRules -} E_PHS_DSC_ACTION; - +}; #define CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ 0x89 /* Host to Mac */ #define CM_CONTROL_NEWDSX_MULTICLASSIFIER_RESP 0xA9 /* Mac to Host */ @@ -324,18 +321,18 @@ typedef enum _E_PHS_DSC_ACTION { #define HPM_CONFIG_MSW 0x0F000D58 #define T3B 0xbece0310 -typedef enum eNVM_TYPE { +enum bcm_nvm_type { NVM_AUTODETECT = 0, NVM_EEPROM, NVM_FLASH, NVM_UNKNOWN -} NVM_TYPE; +}; -typedef enum ePMU_MODES { +enum bcm_pmu_modes { HYBRID_MODE_7C = 0, INTERNAL_MODE_6 = 1, HYBRID_MODE_6 = 2 -} PMU_MODE; +}; #define MAX_RDM_WRM_RETIRES 1 diff --git a/drivers/staging/bcm/Misc.c b/drivers/staging/bcm/Misc.c index f13a9582a82..7b2fa0f4a2e 100644 --- a/drivers/staging/bcm/Misc.c +++ b/drivers/staging/bcm/Misc.c @@ -1,14 +1,14 @@ #include "headers.h" static int BcmFileDownload(struct bcm_mini_adapter *Adapter, const char *path, unsigned int loc); -static VOID doPowerAutoCorrection(struct bcm_mini_adapter *psAdapter); +static void doPowerAutoCorrection(struct bcm_mini_adapter *psAdapter); static void HandleShutDownModeRequest(struct bcm_mini_adapter *Adapter, PUCHAR pucBuffer); static int bcm_parse_target_params(struct bcm_mini_adapter *Adapter); static void beceem_protocol_reset(struct bcm_mini_adapter *Adapter); -static VOID default_wimax_protocol_initialize(struct bcm_mini_adapter *Adapter) +static void default_wimax_protocol_initialize(struct bcm_mini_adapter *Adapter) { - UINT uiLoopIndex; + unsigned int uiLoopIndex; for (uiLoopIndex = 0; uiLoopIndex < NO_OF_QUEUES-1; uiLoopIndex++) { Adapter->PackInfo[uiLoopIndex].uiThreshold = TX_PACKET_THRESHOLD; @@ -24,10 +24,10 @@ static VOID default_wimax_protocol_initialize(struct bcm_mini_adapter *Adapter) return; } -INT InitAdapter(struct bcm_mini_adapter *psAdapter) +int InitAdapter(struct bcm_mini_adapter *psAdapter) { int i = 0; - INT Status = STATUS_SUCCESS; + int Status = STATUS_SUCCESS; BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Initialising Adapter = %p", psAdapter); if (psAdapter == NULL) { @@ -53,7 +53,7 @@ INT InitAdapter(struct bcm_mini_adapter *psAdapter) init_waitqueue_head(&psAdapter->ioctl_fw_dnld_wait_queue); init_waitqueue_head(&psAdapter->lowpower_mode_wait_queue); psAdapter->waiting_to_fw_download_done = TRUE; - psAdapter->fw_download_done = FALSE; + psAdapter->fw_download_done = false; default_wimax_protocol_initialize(psAdapter); for (i = 0; i < MAX_CNTRL_PKTS; i++) { @@ -93,7 +93,7 @@ INT InitAdapter(struct bcm_mini_adapter *psAdapter) return STATUS_SUCCESS; } -VOID AdapterFree(struct bcm_mini_adapter *Adapter) +void AdapterFree(struct bcm_mini_adapter *Adapter) { int count; beceem_protocol_reset(Adapter); @@ -185,7 +185,7 @@ static int BcmFileDownload(struct bcm_mini_adapter *Adapter, const char *path, u BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Unable to Open %s\n", path); return -ENOENT; } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Opened file is = %s and length =0x%lx to be downloaded at =0x%x", path, (unsigned long)flp->f_dentry->d_inode->i_size, loc); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Opened file is = %s and length =0x%lx to be downloaded at =0x%x", path, (unsigned long)file_inode(flp)->i_size, loc); do_gettimeofday(&tv); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "download start %lx", ((tv.tv_sec * 1000) + (tv.tv_usec / 1000))); @@ -210,18 +210,18 @@ exit_download: * @ingroup ctrl_pkt_functions * This function copies the contents of given buffer * to the control packet and queues it for transmission. - * @note Do not acquire the spinock, as it it already acquired. + * @note Do not acquire the spinlock, as it it already acquired. * @return SUCCESS/FAILURE. * Arguments: * Logical Adapter * Control Packet Buffer */ -INT CopyBufferToControlPacket(struct bcm_mini_adapter *Adapter, PVOID ioBuffer) +int CopyBufferToControlPacket(struct bcm_mini_adapter *Adapter, void *ioBuffer) { struct bcm_leader *pLeader = NULL; - INT Status = 0; - unsigned char *ctrl_buff = NULL; - UINT pktlen = 0; + int Status = 0; + unsigned char *ctrl_buff; + unsigned int pktlen = 0; struct bcm_link_request *pLinkReq = NULL; PUCHAR pucAddIndication = NULL; @@ -253,9 +253,9 @@ INT CopyBufferToControlPacket(struct bcm_mini_adapter *Adapter, PVOID ioBuffer) return STATUS_FAILURE; } - if (TRUE == Adapter->bShutStatus) { + if (Adapter->bShutStatus == TRUE) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "SYNC UP IN SHUTDOWN..Device WakeUp\n"); - if (Adapter->bTriedToWakeUpFromlowPowerMode == FALSE) { + if (Adapter->bTriedToWakeUpFromlowPowerMode == false) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Waking up for the First Time..\n"); Adapter->usIdleModePattern = ABORT_SHUTDOWN_MODE; /* change it to 1 for current support. */ Adapter->bWakeUpDevice = TRUE; @@ -275,7 +275,7 @@ INT CopyBufferToControlPacket(struct bcm_mini_adapter *Adapter, PVOID ioBuffer) } } - if (TRUE == Adapter->IdleMode) { + if (Adapter->IdleMode == TRUE) { /* BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Device is in Idle mode ... hence\n"); */ if (pLeader->Status == LINK_UP_CONTROL_REQ || pLeader->Status == 0x80 || pLeader->Status == CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ) { @@ -325,64 +325,66 @@ INT CopyBufferToControlPacket(struct bcm_mini_adapter *Adapter, PVOID ioBuffer) pktlen = pLeader->PLength; ctrl_buff = (char *)Adapter->txctlpacket[atomic_read(&Adapter->index_wr_txcntrlpkt)%MAX_CNTRL_PKTS]; + if (!ctrl_buff) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "mem allocation Failed"); + return -ENOMEM; + } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Control packet to be taken =%d and address is =%pincoming address is =%p and packet len=%x", atomic_read(&Adapter->index_wr_txcntrlpkt), ctrl_buff, ioBuffer, pktlen); - if (ctrl_buff) { - if (pLeader) { - if ((pLeader->Status == 0x80) || - (pLeader->Status == CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ)) { - /* - * Restructure the DSX message to handle Multiple classifier Support - * Write the Service Flow param Structures directly to the target - * and embed the pointers in the DSX messages sent to target. - */ - /* Lets store the current length of the control packet we are transmitting */ - pucAddIndication = (PUCHAR)ioBuffer + LEADER_SIZE; - pktlen = pLeader->PLength; - Status = StoreCmControlResponseMessage(Adapter, pucAddIndication, &pktlen); - if (Status != 1) { - ClearTargetDSXBuffer(Adapter, ((stLocalSFAddIndicationAlt *)pucAddIndication)->u16TID, FALSE); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, " Error Restoring The DSX Control Packet. Dsx Buffers on Target may not be Setup Properly "); - return STATUS_FAILURE; - } - /* - * update the leader to use the new length - * The length of the control packet is length of message being sent + Leader length - */ - pLeader->PLength = pktlen; + + if (pLeader) { + if ((pLeader->Status == 0x80) || + (pLeader->Status == CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ)) { + /* + * Restructure the DSX message to handle Multiple classifier Support + * Write the Service Flow param Structures directly to the target + * and embed the pointers in the DSX messages sent to target. + */ + /* Lets store the current length of the control packet we are transmitting */ + pucAddIndication = (PUCHAR)ioBuffer + LEADER_SIZE; + pktlen = pLeader->PLength; + Status = StoreCmControlResponseMessage(Adapter, pucAddIndication, &pktlen); + if (Status != 1) { + ClearTargetDSXBuffer(Adapter, ((struct bcm_add_indication_alt *)pucAddIndication)->u16TID, false); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, " Error Restoring The DSX Control Packet. Dsx Buffers on Target may not be Setup Properly "); + return STATUS_FAILURE; } + /* + * update the leader to use the new length + * The length of the control packet is length of message being sent + Leader length + */ + pLeader->PLength = pktlen; } - - if (pktlen + LEADER_SIZE > MAX_CNTL_PKT_SIZE) - return -EINVAL; - - memset(ctrl_buff, 0, pktlen+LEADER_SIZE); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Copying the Control Packet Buffer with length=%d\n", pLeader->PLength); - *(struct bcm_leader *)ctrl_buff = *pLeader; - memcpy(ctrl_buff + LEADER_SIZE, ((PUCHAR)ioBuffer + LEADER_SIZE), pLeader->PLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Enqueuing the Control Packet"); - - /* Update the statistics counters */ - spin_lock_bh(&Adapter->PackInfo[HiPriority].SFQueueLock); - Adapter->PackInfo[HiPriority].uiCurrentBytesOnHost += pLeader->PLength; - Adapter->PackInfo[HiPriority].uiCurrentPacketsOnHost++; - atomic_inc(&Adapter->TotalPacketCount); - spin_unlock_bh(&Adapter->PackInfo[HiPriority].SFQueueLock); - Adapter->PackInfo[HiPriority].bValid = TRUE; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "CurrBytesOnHost: %x bValid: %x", - Adapter->PackInfo[HiPriority].uiCurrentBytesOnHost, - Adapter->PackInfo[HiPriority].bValid); - Status = STATUS_SUCCESS; - /*Queue the packet for transmission */ - atomic_inc(&Adapter->index_wr_txcntrlpkt); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Calling transmit_packets"); - atomic_set(&Adapter->TxPktAvail, 1); - wake_up(&Adapter->tx_packet_wait_queue); - } else { - Status = -ENOMEM; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "mem allocation Failed"); } + + if (pktlen + LEADER_SIZE > MAX_CNTL_PKT_SIZE) + return -EINVAL; + + memset(ctrl_buff, 0, pktlen+LEADER_SIZE); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Copying the Control Packet Buffer with length=%d\n", pLeader->PLength); + *(struct bcm_leader *)ctrl_buff = *pLeader; + memcpy(ctrl_buff + LEADER_SIZE, ((PUCHAR)ioBuffer + LEADER_SIZE), pLeader->PLength); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Enqueuing the Control Packet"); + + /* Update the statistics counters */ + spin_lock_bh(&Adapter->PackInfo[HiPriority].SFQueueLock); + Adapter->PackInfo[HiPriority].uiCurrentBytesOnHost += pLeader->PLength; + Adapter->PackInfo[HiPriority].uiCurrentPacketsOnHost++; + atomic_inc(&Adapter->TotalPacketCount); + spin_unlock_bh(&Adapter->PackInfo[HiPriority].SFQueueLock); + Adapter->PackInfo[HiPriority].bValid = TRUE; + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "CurrBytesOnHost: %x bValid: %x", + Adapter->PackInfo[HiPriority].uiCurrentBytesOnHost, + Adapter->PackInfo[HiPriority].bValid); + Status = STATUS_SUCCESS; + /*Queue the packet for transmission */ + atomic_inc(&Adapter->index_wr_txcntrlpkt); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Calling transmit_packets"); + atomic_set(&Adapter->TxPktAvail, 1); + wake_up(&Adapter->tx_packet_wait_queue); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "<===="); return Status; } @@ -397,7 +399,7 @@ INT CopyBufferToControlPacket(struct bcm_mini_adapter *Adapter, PVOID ioBuffer) * * Returns - None. *******************************************************************/ -VOID LinkMessage(struct bcm_mini_adapter *Adapter) +void LinkMessage(struct bcm_mini_adapter *Adapter) { struct bcm_link_request *pstLinkRequest = NULL; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "=====>"); @@ -448,11 +450,11 @@ VOID LinkMessage(struct bcm_mini_adapter *Adapter) * * Returns - None. ************************************************************************/ -VOID StatisticsResponse(struct bcm_mini_adapter *Adapter, PVOID pvBuffer) +void StatisticsResponse(struct bcm_mini_adapter *Adapter, void *pvBuffer) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s====>", __func__); Adapter->StatisticsPointer = ntohl(*(__be32 *)pvBuffer); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Stats at %x", (UINT)Adapter->StatisticsPointer); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Stats at %x", (unsigned int)Adapter->StatisticsPointer); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s <====", __func__); return; } @@ -467,7 +469,7 @@ VOID StatisticsResponse(struct bcm_mini_adapter *Adapter, PVOID pvBuffer) * * Returns - None. ***********************************************************************/ -VOID LinkControlResponseMessage(struct bcm_mini_adapter *Adapter, PUCHAR pucBuffer) +void LinkControlResponseMessage(struct bcm_mini_adapter *Adapter, PUCHAR pucBuffer) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "=====>"); @@ -497,7 +499,7 @@ VOID LinkControlResponseMessage(struct bcm_mini_adapter *Adapter, PUCHAR pucBuff Adapter->bETHCSEnabled = *(pucBuffer+4) & ETH_CS_MASK; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "PHS Support Status Received In LinkUp Ack : %x\n", Adapter->bPHSEnabled); - if ((FALSE == Adapter->bShutStatus) && (FALSE == Adapter->IdleMode)) { + if ((false == Adapter->bShutStatus) && (false == Adapter->IdleMode)) { if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { Adapter->DriverState = NORMAL_OPERATION; wake_up(&Adapter->LEDInfo.notify_led_event); @@ -515,8 +517,8 @@ VOID LinkControlResponseMessage(struct bcm_mini_adapter *Adapter, PUCHAR pucBuff Adapter->LinkUpStatus = 0; Adapter->LinkStatus = 0; Adapter->usBestEffortQueueIndex = INVALID_QUEUE_INDEX; - Adapter->bTriedToWakeUpFromlowPowerMode = FALSE; - Adapter->IdleMode = FALSE; + Adapter->bTriedToWakeUpFromlowPowerMode = false; + Adapter->IdleMode = false; beceem_protocol_reset(Adapter); break; @@ -543,7 +545,7 @@ VOID LinkControlResponseMessage(struct bcm_mini_adapter *Adapter, PUCHAR pucBuff void SendIdleModeResponse(struct bcm_mini_adapter *Adapter) { - INT status = 0, NVMAccess = 0, lowPwrAbortMsg = 0; + int status = 0, NVMAccess = 0, lowPwrAbortMsg = 0; struct timeval tv; struct bcm_link_request stIdleResponse = {{0} }; memset(&tv, 0, sizeof(tv)); @@ -576,14 +578,14 @@ void SendIdleModeResponse(struct bcm_mini_adapter *Adapter) stIdleResponse.szData[1] = TARGET_CAN_NOT_GO_TO_IDLE_MODE; /* NACK- device access is going on. */ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "HOST IS NACKING Idle mode To F/W!!!!!!!!"); - Adapter->bPreparingForLowPowerMode = FALSE; + Adapter->bPreparingForLowPowerMode = false; } else { stIdleResponse.szData[1] = TARGET_CAN_GO_TO_IDLE_MODE; /* 2; Idle ACK */ Adapter->StatisticsPointer = 0; /* Wait for the LED to TURN OFF before sending ACK response */ if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { - INT iRetVal = 0; + int iRetVal = 0; /* Wake the LED Thread with IDLEMODE_ENTER State */ Adapter->DriverState = LOWPOWER_MODE_ENTER; @@ -609,9 +611,9 @@ void SendIdleModeResponse(struct bcm_mini_adapter *Adapter) up(&Adapter->rdmwrmsync); /* Killing all URBS. */ if (Adapter->bDoSuspend == TRUE) - Bcm_kill_all_URBs((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter)); + Bcm_kill_all_URBs((struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter)); } else { - Adapter->bPreparingForLowPowerMode = FALSE; + Adapter->bPreparingForLowPowerMode = false; } if (!NVMAccess) @@ -624,8 +626,8 @@ void SendIdleModeResponse(struct bcm_mini_adapter *Adapter) status = CopyBufferToControlPacket(Adapter, &stIdleResponse); if ((status != STATUS_SUCCESS)) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "fail to send the Idle mode Request\n"); - Adapter->bPreparingForLowPowerMode = FALSE; - StartInterruptUrb((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter)); + Adapter->bPreparingForLowPowerMode = false; + StartInterruptUrb((struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter)); } do_gettimeofday(&tv); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "IdleMode Msg submitter to Q :%ld ms", tv.tv_sec * 1000 + tv.tv_usec / 1000); @@ -640,17 +642,17 @@ void SendIdleModeResponse(struct bcm_mini_adapter *Adapter) * * Returns - None. *******************************************************************/ -VOID DumpPackInfo(struct bcm_mini_adapter *Adapter) +void DumpPackInfo(struct bcm_mini_adapter *Adapter) { - UINT uiLoopIndex = 0; - UINT uiIndex = 0; - UINT uiClsfrIndex = 0; + unsigned int uiLoopIndex = 0; + unsigned int uiIndex = 0; + unsigned int uiClsfrIndex = 0; struct bcm_classifier_rule *pstClassifierEntry = NULL; for (uiLoopIndex = 0; uiLoopIndex < NO_OF_QUEUES; uiLoopIndex++) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "*********** Showing Details Of Queue %d***** ******", uiLoopIndex); - if (FALSE == Adapter->PackInfo[uiLoopIndex].bValid) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "bValid is FALSE for %X index\n", uiLoopIndex); + if (false == Adapter->PackInfo[uiLoopIndex].bValid) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "bValid is false for %X index\n", uiLoopIndex); continue; } @@ -776,12 +778,12 @@ int reset_card_proc(struct bcm_mini_adapter *ps_adapter) { int retval = STATUS_SUCCESS; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - PS_INTERFACE_ADAPTER psIntfAdapter = NULL; + struct bcm_interface_adapter *psIntfAdapter = NULL; unsigned int value = 0, uiResetValue = 0; int bytes; - psIntfAdapter = ((PS_INTERFACE_ADAPTER)(ps_adapter->pvInterfaceAdapter)); - ps_adapter->bDDRInitDone = FALSE; + psIntfAdapter = ((struct bcm_interface_adapter *)(ps_adapter->pvInterfaceAdapter)); + ps_adapter->bDDRInitDone = false; if (ps_adapter->chip_id >= T3LPB) { /* SYS_CFG register is write protected hence for modifying this reg value, it should be read twice before */ @@ -801,7 +803,7 @@ int reset_card_proc(struct bcm_mini_adapter *ps_adapter) if (ps_adapter->chip_id >= T3LPB) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Resetting UMA-B\n"); retval = usb_reset_device(psIntfAdapter->udev); - psIntfAdapter->psAdapter->StopAllXaction = FALSE; + psIntfAdapter->psAdapter->StopAllXaction = false; if (retval != STATUS_SUCCESS) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Reset failed with ret value :%d", retval); @@ -886,7 +888,7 @@ int reset_card_proc(struct bcm_mini_adapter *ps_adapter) wrmalt(ps_adapter, 0x0f01186c, &uiResetValue, sizeof(uiResetValue)); err_exit: - psIntfAdapter->psAdapter->StopAllXaction = FALSE; + psIntfAdapter->psAdapter->StopAllXaction = false; return retval; } @@ -920,7 +922,7 @@ int run_card_proc(struct bcm_mini_adapter *ps_adapter) int InitCardAndDownloadFirmware(struct bcm_mini_adapter *ps_adapter) { int status; - UINT value = 0; + unsigned int value = 0; /* * Create the threads first and then download the * Firm/DDR Settings.. @@ -954,7 +956,7 @@ int InitCardAndDownloadFirmware(struct bcm_mini_adapter *ps_adapter) /* Download cfg file */ status = buffDnldVerify(ps_adapter, (PUCHAR)ps_adapter->pstargetparams, - sizeof(STARGETPARAMS), + sizeof(struct bcm_target_params), CONFIG_BEGIN_ADDR); if (status) { BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Error downloading CFG file"); @@ -966,7 +968,7 @@ int InitCardAndDownloadFirmware(struct bcm_mini_adapter *ps_adapter) return -EIO; } - if (FALSE == ps_adapter->AutoFirmDld) { + if (false == ps_adapter->AutoFirmDld) { BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "AutoFirmDld Disabled in CFG File..\n"); /* If Auto f/w download is disable, register the control interface, */ /* register the control interface after the mailbox. */ @@ -1051,7 +1053,7 @@ static int bcm_parse_target_params(struct bcm_mini_adapter *Adapter) if (!buff) return -ENOMEM; - Adapter->pstargetparams = kmalloc(sizeof(STARGETPARAMS), GFP_KERNEL); + Adapter->pstargetparams = kmalloc(sizeof(struct bcm_target_params), GFP_KERNEL); if (Adapter->pstargetparams == NULL) { kfree(buff); return -ENOMEM; @@ -1068,7 +1070,7 @@ static int bcm_parse_target_params(struct bcm_mini_adapter *Adapter) len = kernel_read(flp, 0, buff, BUFFER_1K); filp_close(flp, NULL); - if (len != sizeof(STARGETPARAMS)) { + if (len != sizeof(struct bcm_target_params)) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Mismatch in Target Param Structure!\n"); kfree(buff); kfree(Adapter->pstargetparams); @@ -1080,7 +1082,7 @@ static int bcm_parse_target_params(struct bcm_mini_adapter *Adapter) /* * Values in Adapter->pstargetparams are in network byte order */ - memcpy(Adapter->pstargetparams, buff, sizeof(STARGETPARAMS)); + memcpy(Adapter->pstargetparams, buff, sizeof(struct bcm_target_params)); kfree(buff); beceem_parse_target_struct(Adapter); return STATUS_SUCCESS; @@ -1088,11 +1090,11 @@ static int bcm_parse_target_params(struct bcm_mini_adapter *Adapter) void beceem_parse_target_struct(struct bcm_mini_adapter *Adapter) { - UINT uiHostDrvrCfg6 = 0, uiEEPROMFlag = 0; + unsigned int uiHostDrvrCfg6 = 0, uiEEPROMFlag = 0; if (ntohl(Adapter->pstargetparams->m_u32PhyParameter2) & AUTO_SYNC_DISABLE) { pr_info(DRV_NAME ": AutoSyncup is Disabled\n"); - Adapter->AutoSyncup = FALSE; + Adapter->AutoSyncup = false; } else { pr_info(DRV_NAME ": AutoSyncup is Enabled\n"); Adapter->AutoSyncup = TRUE; @@ -1103,7 +1105,7 @@ void beceem_parse_target_struct(struct bcm_mini_adapter *Adapter) Adapter->AutoLinkUp = TRUE; } else { pr_info(DRV_NAME ": Disabling autolink up"); - Adapter->AutoLinkUp = FALSE; + Adapter->AutoLinkUp = false; } /* Setting the DDR Setting.. */ Adapter->DDRSetting = (ntohl(Adapter->pstargetparams->HostDrvrConfig6) >> 8)&0x0F; @@ -1115,7 +1117,7 @@ void beceem_parse_target_struct(struct bcm_mini_adapter *Adapter) Adapter->AutoFirmDld = TRUE; } else { pr_info(DRV_NAME ": Disabling Auto Firmware Download\n"); - Adapter->AutoFirmDld = FALSE; + Adapter->AutoFirmDld = false; } uiHostDrvrCfg6 = ntohl(Adapter->pstargetparams->HostDrvrConfig6); Adapter->bMipsConfig = (uiHostDrvrCfg6>>20)&0x01; @@ -1132,7 +1134,7 @@ void beceem_parse_target_struct(struct bcm_mini_adapter *Adapter) uiEEPROMFlag = ntohl(Adapter->pstargetparams->m_u32EEPROMFlag); pr_info(DRV_NAME ": uiEEPROMFlag : 0x%X\n", uiEEPROMFlag); - Adapter->eNVMType = (NVM_TYPE)((uiEEPROMFlag>>4)&0x3); + Adapter->eNVMType = (enum bcm_nvm_type)((uiEEPROMFlag>>4)&0x3); Adapter->bStatusWrite = (uiEEPROMFlag>>6)&0x1; Adapter->uiSectorSizeInCFG = 1024*(0xFFFF & ntohl(Adapter->pstargetparams->HostDrvrConfig4)); Adapter->bSectorSizeOverride = (bool) ((ntohl(Adapter->pstargetparams->HostDrvrConfig4))>>16)&0x1; @@ -1144,30 +1146,30 @@ void beceem_parse_target_struct(struct bcm_mini_adapter *Adapter) doPowerAutoCorrection(Adapter); } -static VOID doPowerAutoCorrection(struct bcm_mini_adapter *psAdapter) +static void doPowerAutoCorrection(struct bcm_mini_adapter *psAdapter) { - UINT reporting_mode; + unsigned int reporting_mode; reporting_mode = ntohl(psAdapter->pstargetparams->m_u32PowerSavingModeOptions) & 0x02; psAdapter->bIsAutoCorrectEnabled = !((char)(psAdapter->ulPowerSaveMode >> 3) & 0x1); if (reporting_mode == TRUE) { BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "can't do suspen/resume as reporting mode is enable"); - psAdapter->bDoSuspend = FALSE; + psAdapter->bDoSuspend = false; } if (psAdapter->bIsAutoCorrectEnabled && (psAdapter->chip_id >= T3LPB)) { /* If reporting mode is enable, switch PMU to PMC */ { psAdapter->ulPowerSaveMode = DEVICE_POWERSAVE_MODE_AS_PMU_CLOCK_GATING; - psAdapter->bDoSuspend = FALSE; + psAdapter->bDoSuspend = false; } /* clearing space bit[15..12] */ psAdapter->pstargetparams->HostDrvrConfig6 &= ~(htonl((0xF << 12))); /* placing the power save mode option */ psAdapter->pstargetparams->HostDrvrConfig6 |= htonl((psAdapter->ulPowerSaveMode << 12)); - } else if (psAdapter->bIsAutoCorrectEnabled == FALSE) { + } else if (psAdapter->bIsAutoCorrectEnabled == false) { /* remove the autocorrect disable bit set before dumping. */ psAdapter->ulPowerSaveMode &= ~(1 << 3); psAdapter->pstargetparams->HostDrvrConfig6 &= ~(htonl(1 << 15)); @@ -1175,26 +1177,26 @@ static VOID doPowerAutoCorrection(struct bcm_mini_adapter *psAdapter) } } -static void convertEndian(B_UINT8 rwFlag, PUINT puiBuffer, UINT uiByteCount) +static void convertEndian(unsigned char rwFlag, unsigned int *puiBuffer, unsigned int uiByteCount) { - UINT uiIndex = 0; + unsigned int uiIndex = 0; if (RWM_WRITE == rwFlag) { - for (uiIndex = 0; uiIndex < (uiByteCount/sizeof(UINT)); uiIndex++) + for (uiIndex = 0; uiIndex < (uiByteCount/sizeof(unsigned int)); uiIndex++) puiBuffer[uiIndex] = htonl(puiBuffer[uiIndex]); } else { - for (uiIndex = 0; uiIndex < (uiByteCount/sizeof(UINT)); uiIndex++) + for (uiIndex = 0; uiIndex < (uiByteCount/sizeof(unsigned int)); uiIndex++) puiBuffer[uiIndex] = ntohl(puiBuffer[uiIndex]); } } -int rdm(struct bcm_mini_adapter *Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize) +int rdm(struct bcm_mini_adapter *Adapter, unsigned int uiAddress, PCHAR pucBuff, size_t sSize) { return Adapter->interface_rdm(Adapter->pvInterfaceAdapter, uiAddress, pucBuff, sSize); } -int wrm(struct bcm_mini_adapter *Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize) +int wrm(struct bcm_mini_adapter *Adapter, unsigned int uiAddress, PCHAR pucBuff, size_t sSize) { int iRetVal; @@ -1203,25 +1205,25 @@ int wrm(struct bcm_mini_adapter *Adapter, UINT uiAddress, PCHAR pucBuff, size_t return iRetVal; } -int wrmalt(struct bcm_mini_adapter *Adapter, UINT uiAddress, PUINT pucBuff, size_t size) +int wrmalt(struct bcm_mini_adapter *Adapter, unsigned int uiAddress, unsigned int *pucBuff, size_t size) { convertEndian(RWM_WRITE, pucBuff, size); return wrm(Adapter, uiAddress, (PUCHAR)pucBuff, size); } -int rdmalt(struct bcm_mini_adapter *Adapter, UINT uiAddress, PUINT pucBuff, size_t size) +int rdmalt(struct bcm_mini_adapter *Adapter, unsigned int uiAddress, unsigned int *pucBuff, size_t size) { - INT uiRetVal = 0; + int uiRetVal = 0; uiRetVal = rdm(Adapter, uiAddress, (PUCHAR)pucBuff, size); - convertEndian(RWM_READ, (PUINT)pucBuff, size); + convertEndian(RWM_READ, (unsigned int *)pucBuff, size); return uiRetVal; } -int wrmWithLock(struct bcm_mini_adapter *Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize) +int wrmWithLock(struct bcm_mini_adapter *Adapter, unsigned int uiAddress, PCHAR pucBuff, size_t sSize) { - INT status = STATUS_SUCCESS; + int status = STATUS_SUCCESS; down(&Adapter->rdmwrmsync); if ((Adapter->IdleMode == TRUE) || @@ -1238,7 +1240,7 @@ exit: return status; } -int wrmaltWithLock(struct bcm_mini_adapter *Adapter, UINT uiAddress, PUINT pucBuff, size_t size) +int wrmaltWithLock(struct bcm_mini_adapter *Adapter, unsigned int uiAddress, unsigned int *pucBuff, size_t size) { int iRetVal = STATUS_SUCCESS; @@ -1258,9 +1260,9 @@ exit: return iRetVal; } -int rdmaltWithLock(struct bcm_mini_adapter *Adapter, UINT uiAddress, PUINT pucBuff, size_t size) +int rdmaltWithLock(struct bcm_mini_adapter *Adapter, unsigned int uiAddress, unsigned int *pucBuff, size_t size) { - INT uiRetVal = STATUS_SUCCESS; + int uiRetVal = STATUS_SUCCESS; down(&Adapter->rdmwrmsync); if ((Adapter->IdleMode == TRUE) || @@ -1277,13 +1279,13 @@ exit: return uiRetVal; } -static VOID HandleShutDownModeWakeup(struct bcm_mini_adapter *Adapter) +static void HandleShutDownModeWakeup(struct bcm_mini_adapter *Adapter) { int clear_abort_pattern = 0, Status = 0; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "====>\n"); /* target has woken up From Shut Down */ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "Clearing Shut Down Software abort pattern\n"); - Status = wrmalt(Adapter, SW_ABORT_IDLEMODE_LOC, (PUINT)&clear_abort_pattern, sizeof(clear_abort_pattern)); + Status = wrmalt(Adapter, SW_ABORT_IDLEMODE_LOC, (unsigned int *)&clear_abort_pattern, sizeof(clear_abort_pattern)); if (Status) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "WRM to SW_ABORT_IDLEMODE_LOC failed with err:%d", Status); return; @@ -1300,17 +1302,17 @@ static VOID HandleShutDownModeWakeup(struct bcm_mini_adapter *Adapter) wake_up(&Adapter->LEDInfo.notify_led_event); } - Adapter->bTriedToWakeUpFromlowPowerMode = FALSE; - Adapter->bShutStatus = FALSE; + Adapter->bTriedToWakeUpFromlowPowerMode = false; + Adapter->bShutStatus = false; wake_up(&Adapter->lowpower_mode_wait_queue); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "<====\n"); } -static VOID SendShutModeResponse(struct bcm_mini_adapter *Adapter) +static void SendShutModeResponse(struct bcm_mini_adapter *Adapter) { struct bcm_link_request stShutdownResponse; - UINT NVMAccess = 0, lowPwrAbortMsg = 0; - UINT Status = 0; + unsigned int NVMAccess = 0, lowPwrAbortMsg = 0; + unsigned int Status = 0; memset(&stShutdownResponse, 0, sizeof(struct bcm_link_request)); stShutdownResponse.Leader.Status = LINK_UP_CONTROL_REQ; @@ -1339,14 +1341,14 @@ static VOID SendShutModeResponse(struct bcm_mini_adapter *Adapter) BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "Device Access is going on NACK the Shut Down MODE\n"); stShutdownResponse.szData[2] = SHUTDOWN_NACK_FROM_DRIVER; /* NACK- device access is going on. */ - Adapter->bPreparingForLowPowerMode = FALSE; + Adapter->bPreparingForLowPowerMode = false; } else { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "Sending SHUTDOWN MODE ACK\n"); stShutdownResponse.szData[2] = SHUTDOWN_ACK_FROM_DRIVER; /* ShutDown ACK */ /* Wait for the LED to TURN OFF before sending ACK response */ if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { - INT iRetVal = 0; + int iRetVal = 0; /* Wake the LED Thread with LOWPOWER_MODE_ENTER State */ Adapter->DriverState = LOWPOWER_MODE_ENTER; @@ -1370,9 +1372,9 @@ static VOID SendShutModeResponse(struct bcm_mini_adapter *Adapter) up(&Adapter->rdmwrmsync); /* Killing all URBS. */ if (Adapter->bDoSuspend == TRUE) - Bcm_kill_all_URBs((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter)); + Bcm_kill_all_URBs((struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter)); } else { - Adapter->bPreparingForLowPowerMode = FALSE; + Adapter->bPreparingForLowPowerMode = false; } if (!NVMAccess) @@ -1385,14 +1387,14 @@ static VOID SendShutModeResponse(struct bcm_mini_adapter *Adapter) Status = CopyBufferToControlPacket(Adapter, &stShutdownResponse); if ((Status != STATUS_SUCCESS)) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "fail to send the Idle mode Request\n"); - Adapter->bPreparingForLowPowerMode = FALSE; - StartInterruptUrb((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter)); + Adapter->bPreparingForLowPowerMode = false; + StartInterruptUrb((struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter)); } } static void HandleShutDownModeRequest(struct bcm_mini_adapter *Adapter, PUCHAR pucBuffer) { - B_UINT32 uiResetValue = 0; + unsigned int uiResetValue = 0; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "====>\n"); @@ -1412,14 +1414,14 @@ static void HandleShutDownModeRequest(struct bcm_mini_adapter *Adapter, PUCHAR p } SendShutModeResponse(Adapter); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "ShutDownModeResponse:Notification received: Sending the response(Ack/Nack)\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "ShutDownModeResponse:Notification received: Sending the response(Ack/Nack)\n"); } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "<====\n"); return; } -VOID ResetCounters(struct bcm_mini_adapter *Adapter) +void ResetCounters(struct bcm_mini_adapter *Adapter) { beceem_protocol_reset(Adapter); Adapter->CurrNumRecvDescs = 0; @@ -1428,16 +1430,16 @@ VOID ResetCounters(struct bcm_mini_adapter *Adapter) Adapter->LinkStatus = 0; atomic_set(&Adapter->cntrlpktCnt, 0); atomic_set(&Adapter->TotalPacketCount, 0); - Adapter->fw_download_done = FALSE; + Adapter->fw_download_done = false; Adapter->LinkStatus = 0; - Adapter->AutoLinkUp = FALSE; - Adapter->IdleMode = FALSE; - Adapter->bShutStatus = FALSE; + Adapter->AutoLinkUp = false; + Adapter->IdleMode = false; + Adapter->bShutStatus = false; } struct bcm_classifier_rule *GetFragIPClsEntry(struct bcm_mini_adapter *Adapter, USHORT usIpIdentification, ULONG SrcIP) { - UINT uiIndex = 0; + unsigned int uiIndex = 0; for (uiIndex = 0; uiIndex < MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES; uiIndex++) { if ((Adapter->astFragmentedPktClassifierTable[uiIndex].bUsed) && (Adapter->astFragmentedPktClassifierTable[uiIndex].usIpIdentification == usIpIdentification) && @@ -1451,7 +1453,7 @@ struct bcm_classifier_rule *GetFragIPClsEntry(struct bcm_mini_adapter *Adapter, void AddFragIPClsEntry(struct bcm_mini_adapter *Adapter, struct bcm_fragmented_packet_info *psFragPktInfo) { - UINT uiIndex = 0; + unsigned int uiIndex = 0; for (uiIndex = 0; uiIndex < MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES; uiIndex++) { if (!Adapter->astFragmentedPktClassifierTable[uiIndex].bUsed) { memcpy(&Adapter->astFragmentedPktClassifierTable[uiIndex], psFragPktInfo, sizeof(struct bcm_fragmented_packet_info)); @@ -1462,7 +1464,7 @@ void AddFragIPClsEntry(struct bcm_mini_adapter *Adapter, struct bcm_fragmented_p void DelFragIPClsEntry(struct bcm_mini_adapter *Adapter, USHORT usIpIdentification, ULONG SrcIp) { - UINT uiIndex = 0; + unsigned int uiIndex = 0; for (uiIndex = 0; uiIndex < MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES; uiIndex++) { if ((Adapter->astFragmentedPktClassifierTable[uiIndex].bUsed) && (Adapter->astFragmentedPktClassifierTable[uiIndex].usIpIdentification == usIpIdentification) && @@ -1474,7 +1476,7 @@ void DelFragIPClsEntry(struct bcm_mini_adapter *Adapter, USHORT usIpIdentificati void update_per_cid_rx(struct bcm_mini_adapter *Adapter) { - UINT qindex = 0; + unsigned int qindex = 0; if ((jiffies - Adapter->liDrainCalculated) < XSECONDS) return; @@ -1498,14 +1500,14 @@ void update_per_cid_rx(struct bcm_mini_adapter *Adapter) void update_per_sf_desc_cnts(struct bcm_mini_adapter *Adapter) { - INT iIndex = 0; + int iIndex = 0; u32 uibuff[MAX_TARGET_DSX_BUFFERS]; int bytes; if (!atomic_read(&Adapter->uiMBupdate)) return; - bytes = rdmaltWithLock(Adapter, TARGET_SFID_TXDESC_MAP_LOC, (PUINT)uibuff, sizeof(UINT) * MAX_TARGET_DSX_BUFFERS); + bytes = rdmaltWithLock(Adapter, TARGET_SFID_TXDESC_MAP_LOC, (unsigned int *)uibuff, sizeof(unsigned int) * MAX_TARGET_DSX_BUFFERS); if (bytes < 0) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "rdm failed\n"); return; @@ -1519,10 +1521,10 @@ void update_per_sf_desc_cnts(struct bcm_mini_adapter *Adapter) BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Invalid VCID : %x\n", Adapter->PackInfo[iIndex].usVCID_Value); } } - atomic_set(&Adapter->uiMBupdate, FALSE); + atomic_set(&Adapter->uiMBupdate, false); } -void flush_queue(struct bcm_mini_adapter *Adapter, UINT iQIndex) +void flush_queue(struct bcm_mini_adapter *Adapter, unsigned int iQIndex) { struct sk_buff *PacketToDrop = NULL; struct net_device_stats *netstats = &Adapter->dev->stats; @@ -1555,8 +1557,8 @@ static void beceem_protocol_reset(struct bcm_mini_adapter *Adapter) netif_carrier_off(Adapter->dev); netif_stop_queue(Adapter->dev); - Adapter->IdleMode = FALSE; - Adapter->LinkUpStatus = FALSE; + Adapter->IdleMode = false; + Adapter->LinkUpStatus = false; ClearTargetDSXBuffer(Adapter, 0, TRUE); /* Delete All Classifier Rules */ @@ -1566,13 +1568,13 @@ static void beceem_protocol_reset(struct bcm_mini_adapter *Adapter) flush_all_queues(Adapter); if (Adapter->TimerActive == TRUE) - Adapter->TimerActive = FALSE; + Adapter->TimerActive = false; memset(Adapter->astFragmentedPktClassifierTable, 0, sizeof(struct bcm_fragmented_packet_info) * MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES); for (i = 0; i < HiPriority; i++) { /* resetting only the first size (S_MIBS_SERVICEFLOW_TABLE) for the SF. */ /* It is same between MIBs and SF. */ - memset(&Adapter->PackInfo[i].stMibsExtServiceFlowTable, 0, sizeof(S_MIBS_EXTSERVICEFLOW_PARAMETERS)); + memset(&Adapter->PackInfo[i].stMibsExtServiceFlowTable, 0, sizeof(struct bcm_mibs_parameters)); } } diff --git a/drivers/staging/bcm/PHSDefines.h b/drivers/staging/bcm/PHSDefines.h index 6016fc502d2..cd78ee4ffa2 100644 --- a/drivers/staging/bcm/PHSDefines.h +++ b/drivers/staging/bcm/PHSDefines.h @@ -1,124 +1,94 @@ #ifndef BCM_PHS_DEFINES_H #define BCM_PHS_DEFINES_H -#define PHS_INVALID_TABLE_INDEX 0xffffffff - -/************************* MACROS **********************************************/ +#define PHS_INVALID_TABLE_INDEX 0xffffffff #define PHS_MEM_TAG "_SHP" - - -//PHS Defines -#define STATUS_PHS_COMPRESSED 0xa1 -#define STATUS_PHS_NOCOMPRESSION 0xa2 -#define APPLY_PHS 1 -#define MAX_NO_BIT 7 -#define ZERO_PHSI 0 -#define VERIFY 0 -#define SIZE_MULTIPLE_32 4 -#define UNCOMPRESSED_PACKET 0 -#define DYNAMIC 0 -#define SUPPRESS 0x80 -#define NO_CLASSIFIER_MATCH 0 -#define SEND_PACKET_UNCOMPRESSED 0 -#define PHSI_IS_ZERO 0 -#define PHSI_LEN 1 -#define ERROR_LEN 0 -#define PHS_BUFFER_SIZE 1532 - - -#define MAX_PHSRULE_PER_SF 20 -#define MAX_SERVICEFLOWS 17 - -//PHS Error Defines -#define PHS_SUCCESS 0 -#define ERR_PHS_INVALID_DEVICE_EXETENSION 0x800 -#define ERR_PHS_INVALID_PHS_RULE 0x801 -#define ERR_PHS_RULE_ALREADY_EXISTS 0x802 -#define ERR_SF_MATCH_FAIL 0x803 -#define ERR_INVALID_CLASSIFIERTABLE_FOR_SF 0x804 -#define ERR_SFTABLE_FULL 0x805 -#define ERR_CLSASSIFIER_TABLE_FULL 0x806 -#define ERR_PHSRULE_MEMALLOC_FAIL 0x807 -#define ERR_CLSID_MATCH_FAIL 0x808 -#define ERR_PHSRULE_MATCH_FAIL 0x809 - -typedef struct _S_PHS_RULE -{ - /// brief 8bit PHSI Of The Service Flow - B_UINT8 u8PHSI; - /// brief PHSF Of The Service Flow - B_UINT8 u8PHSFLength; - B_UINT8 u8PHSF[MAX_PHS_LENGTHS]; - /// brief PHSM Of The Service Flow - B_UINT8 u8PHSMLength; - B_UINT8 u8PHSM[MAX_PHS_LENGTHS]; - /// brief 8bit PHSS Of The Service Flow - B_UINT8 u8PHSS; - /// brief 8bit PHSV Of The Service Flow - B_UINT8 u8PHSV; - //Reference Count for this PHS Rule - B_UINT8 u8RefCnt; - //Flag to Store Unclassified PHS rules only in DL - B_UINT8 bUnclassifiedPHSRule; - - B_UINT8 u8Reserved[3]; - - LONG PHSModifiedBytes; - ULONG PHSModifiedNumPackets; - ULONG PHSErrorNumPackets; -}S_PHS_RULE; - - -typedef enum _E_CLASSIFIER_ENTRY_CONTEXT -{ +/* PHS Defines */ +#define STATUS_PHS_COMPRESSED 0xa1 +#define STATUS_PHS_NOCOMPRESSION 0xa2 +#define APPLY_PHS 1 +#define MAX_NO_BIT 7 +#define ZERO_PHSI 0 +#define VERIFY 0 +#define SIZE_MULTIPLE_32 4 +#define UNCOMPRESSED_PACKET 0 +#define DYNAMIC 0 +#define SUPPRESS 0x80 +#define NO_CLASSIFIER_MATCH 0 +#define SEND_PACKET_UNCOMPRESSED 0 +#define PHSI_IS_ZERO 0 +#define PHSI_LEN 1 +#define ERROR_LEN 0 +#define PHS_BUFFER_SIZE 1532 +#define MAX_PHSRULE_PER_SF 20 +#define MAX_SERVICEFLOWS 17 + +/* PHS Error Defines */ +#define PHS_SUCCESS 0 +#define ERR_PHS_INVALID_DEVICE_EXETENSION 0x800 +#define ERR_PHS_INVALID_PHS_RULE 0x801 +#define ERR_PHS_RULE_ALREADY_EXISTS 0x802 +#define ERR_SF_MATCH_FAIL 0x803 +#define ERR_INVALID_CLASSIFIERTABLE_FOR_SF 0x804 +#define ERR_SFTABLE_FULL 0x805 +#define ERR_CLSASSIFIER_TABLE_FULL 0x806 +#define ERR_PHSRULE_MEMALLOC_FAIL 0x807 +#define ERR_CLSID_MATCH_FAIL 0x808 +#define ERR_PHSRULE_MATCH_FAIL 0x809 + +struct bcm_phs_rule { + u8 u8PHSI; + u8 u8PHSFLength; + u8 u8PHSF[MAX_PHS_LENGTHS]; + u8 u8PHSMLength; + u8 u8PHSM[MAX_PHS_LENGTHS]; + u8 u8PHSS; + u8 u8PHSV; + u8 u8RefCnt; + u8 bUnclassifiedPHSRule; + u8 u8Reserved[3]; + long PHSModifiedBytes; + unsigned long PHSModifiedNumPackets; + unsigned long PHSErrorNumPackets; +}; + +enum bcm_phs_classifier_context { eActiveClassifierRuleContext, eOldClassifierRuleContext -}E_CLASSIFIER_ENTRY_CONTEXT; - -typedef struct _S_CLASSIFIER_ENTRY -{ - B_UINT8 bUsed; - B_UINT16 uiClassifierRuleId; - B_UINT8 u8PHSI; - S_PHS_RULE *pstPhsRule; - B_UINT8 bUnclassifiedPHSRule; - -}S_CLASSIFIER_ENTRY; - - -typedef struct _S_CLASSIFIER_TABLE -{ - B_UINT16 uiTotalClassifiers; - S_CLASSIFIER_ENTRY stActivePhsRulesList[MAX_PHSRULE_PER_SF]; - S_CLASSIFIER_ENTRY stOldPhsRulesList[MAX_PHSRULE_PER_SF]; - B_UINT16 uiOldestPhsRuleIndex; - -}S_CLASSIFIER_TABLE; - - -typedef struct _S_SERVICEFLOW_ENTRY -{ - B_UINT8 bUsed; - B_UINT16 uiVcid; - S_CLASSIFIER_TABLE *pstClassifierTable; -}S_SERVICEFLOW_ENTRY; - -typedef struct _S_SERVICEFLOW_TABLE -{ - B_UINT16 uiTotalServiceFlows; - S_SERVICEFLOW_ENTRY stSFList[MAX_SERVICEFLOWS]; - -}S_SERVICEFLOW_TABLE; - - -typedef struct _PHS_DEVICE_EXTENSION -{ - /* PHS Specific data*/ - S_SERVICEFLOW_TABLE *pstServiceFlowPhsRulesTable; - void *CompressedTxBuffer; - void *UnCompressedRxBuffer; -}PHS_DEVICE_EXTENSION,*PPHS_DEVICE_EXTENSION; - +}; + +struct bcm_phs_classifier_entry { + u8 bUsed; + u16 uiClassifierRuleId; + u8 u8PHSI; + struct bcm_phs_rule *pstPhsRule; + u8 bUnclassifiedPHSRule; +}; + +struct bcm_phs_classifier_table { + u16 uiTotalClassifiers; + struct bcm_phs_classifier_entry stActivePhsRulesList[MAX_PHSRULE_PER_SF]; + struct bcm_phs_classifier_entry stOldPhsRulesList[MAX_PHSRULE_PER_SF]; + u16 uiOldestPhsRuleIndex; +}; + +struct bcm_phs_entry { + u8 bUsed; + u16 uiVcid; + struct bcm_phs_classifier_table *pstClassifierTable; +}; + +struct bcm_phs_table { + u16 uiTotalServiceFlows; + struct bcm_phs_entry stSFList[MAX_SERVICEFLOWS]; +}; + +struct bcm_phs_extension { + /* PHS Specific data */ + struct bcm_phs_table *pstServiceFlowPhsRulesTable; + void *CompressedTxBuffer; + void *UnCompressedRxBuffer; +}; #endif diff --git a/drivers/staging/bcm/PHSModule.c b/drivers/staging/bcm/PHSModule.c index 6dc0bbcfeab..07c5a0bae1e 100644 --- a/drivers/staging/bcm/PHSModule.c +++ b/drivers/staging/bcm/PHSModule.c @@ -1,263 +1,238 @@ #include "headers.h" -static UINT CreateSFToClassifierRuleMapping(B_UINT16 uiVcid,B_UINT16 uiClsId,S_SERVICEFLOW_TABLE *psServiceFlowTable,S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI); +static UINT CreateSFToClassifierRuleMapping(B_UINT16 uiVcid, B_UINT16 uiClsId, struct bcm_phs_table *psServiceFlowTable, struct bcm_phs_rule *psPhsRule, B_UINT8 u8AssociatedPHSI); -static UINT CreateClassiferToPHSRuleMapping(B_UINT16 uiVcid,B_UINT16 uiClsId,S_SERVICEFLOW_ENTRY *pstServiceFlowEntry,S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI); +static UINT CreateClassiferToPHSRuleMapping(B_UINT16 uiVcid, B_UINT16 uiClsId, struct bcm_phs_entry *pstServiceFlowEntry, struct bcm_phs_rule *psPhsRule, B_UINT8 u8AssociatedPHSI); -static UINT CreateClassifierPHSRule(B_UINT16 uiClsId,S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule,E_CLASSIFIER_ENTRY_CONTEXT eClsContext,B_UINT8 u8AssociatedPHSI); +static UINT CreateClassifierPHSRule(B_UINT16 uiClsId, struct bcm_phs_classifier_table *psaClassifiertable, struct bcm_phs_rule *psPhsRule, enum bcm_phs_classifier_context eClsContext, B_UINT8 u8AssociatedPHSI); -static UINT UpdateClassifierPHSRule(B_UINT16 uiClsId,S_CLASSIFIER_ENTRY *pstClassifierEntry,S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI); +static UINT UpdateClassifierPHSRule(B_UINT16 uiClsId, struct bcm_phs_classifier_entry *pstClassifierEntry, struct bcm_phs_classifier_table *psaClassifiertable, struct bcm_phs_rule *psPhsRule, B_UINT8 u8AssociatedPHSI); -static BOOLEAN ValidatePHSRuleComplete(S_PHS_RULE *psPhsRule); +static bool ValidatePHSRuleComplete(struct bcm_phs_rule *psPhsRule); -static BOOLEAN DerefPhsRule(B_UINT16 uiClsId,S_CLASSIFIER_TABLE *psaClassifiertable,S_PHS_RULE *pstPhsRule); +static bool DerefPhsRule(B_UINT16 uiClsId, struct bcm_phs_classifier_table *psaClassifiertable, struct bcm_phs_rule *pstPhsRule); -static UINT GetClassifierEntry(S_CLASSIFIER_TABLE *pstClassifierTable,B_UINT32 uiClsid,E_CLASSIFIER_ENTRY_CONTEXT eClsContext, S_CLASSIFIER_ENTRY **ppstClassifierEntry); +static UINT GetClassifierEntry(struct bcm_phs_classifier_table *pstClassifierTable, B_UINT32 uiClsid, enum bcm_phs_classifier_context eClsContext, struct bcm_phs_classifier_entry **ppstClassifierEntry); -static UINT GetPhsRuleEntry(S_CLASSIFIER_TABLE *pstClassifierTable,B_UINT32 uiPHSI,E_CLASSIFIER_ENTRY_CONTEXT eClsContext,S_PHS_RULE **ppstPhsRule); +static UINT GetPhsRuleEntry(struct bcm_phs_classifier_table *pstClassifierTable, B_UINT32 uiPHSI, enum bcm_phs_classifier_context eClsContext, struct bcm_phs_rule **ppstPhsRule); -static void free_phs_serviceflow_rules(S_SERVICEFLOW_TABLE *psServiceFlowRulesTable); +static void free_phs_serviceflow_rules(struct bcm_phs_table *psServiceFlowRulesTable); -static int phs_compress(S_PHS_RULE *phs_members,unsigned char *in_buf, - unsigned char *out_buf,unsigned int *header_size,UINT *new_header_size ); +static int phs_compress(struct bcm_phs_rule *phs_members, unsigned char *in_buf, + unsigned char *out_buf, unsigned int *header_size, UINT *new_header_size); +static int verify_suppress_phsf(unsigned char *in_buffer, unsigned char *out_buffer, + unsigned char *phsf, unsigned char *phsm, unsigned int phss, unsigned int phsv, UINT *new_header_size); -static int verify_suppress_phsf(unsigned char *in_buffer,unsigned char *out_buffer, - unsigned char *phsf,unsigned char *phsm,unsigned int phss,unsigned int phsv,UINT *new_header_size ); - -static int phs_decompress(unsigned char *in_buf,unsigned char *out_buf,\ - S_PHS_RULE *phs_rules,UINT *header_size); - - -static ULONG PhsCompress(void* pvContext, - B_UINT16 uiVcid, - B_UINT16 uiClsId, - void *pvInputBuffer, - void *pvOutputBuffer, - UINT *pOldHeaderSize, - UINT *pNewHeaderSize ); - -static ULONG PhsDeCompress(void* pvContext, - B_UINT16 uiVcid, - void *pvInputBuffer, - void *pvOutputBuffer, - UINT *pInHeaderSize, - UINT *pOutHeaderSize); +static int phs_decompress(unsigned char *in_buf, unsigned char *out_buf, + struct bcm_phs_rule *phs_rules, UINT *header_size); +static ULONG PhsCompress(void *pvContext, + B_UINT16 uiVcid, + B_UINT16 uiClsId, + void *pvInputBuffer, + void *pvOutputBuffer, + UINT *pOldHeaderSize, + UINT *pNewHeaderSize); +static ULONG PhsDeCompress(void *pvContext, + B_UINT16 uiVcid, + void *pvInputBuffer, + void *pvOutputBuffer, + UINT *pInHeaderSize, + UINT *pOutHeaderSize); #define IN #define OUT /* -Function: PHSTransmit - -Description: This routine handle PHS(Payload Header Suppression for Tx path. - It extracts a fragment of the NDIS_PACKET containing the header - to be suppressed. It then suppresses the header by invoking PHS exported compress routine. - The header data after suppression is copied back to the NDIS_PACKET. - - -Input parameters: IN struct bcm_mini_adapter *Adapter - Miniport Adapter Context - IN Packet - NDIS packet containing data to be transmitted - IN USHORT Vcid - vcid pertaining to connection on which the packet is being sent.Used to - identify PHS rule to be applied. - B_UINT16 uiClassifierRuleID - Classifier Rule ID - BOOLEAN bHeaderSuppressionEnabled - indicates if header suprression is enabled for SF. - -Return: STATUS_SUCCESS - If the send was successful. - Other - If an error occurred. -*/ + * Function: PHSTransmit + * Description: This routine handle PHS(Payload Header Suppression for Tx path. + * It extracts a fragment of the NDIS_PACKET containing the header + * to be suppressed. It then suppresses the header by invoking PHS exported compress routine. + * The header data after suppression is copied back to the NDIS_PACKET. + * + * Input parameters: IN struct bcm_mini_adapter *Adapter - Miniport Adapter Context + * IN Packet - NDIS packet containing data to be transmitted + * IN USHORT Vcid - vcid pertaining to connection on which the packet is being sent.Used to + * identify PHS rule to be applied. + * B_UINT16 uiClassifierRuleID - Classifier Rule ID + * BOOLEAN bHeaderSuppressionEnabled - indicates if header suprression is enabled for SF. + * + * Return: STATUS_SUCCESS - If the send was successful. + * Other - If an error occurred. + */ int PHSTransmit(struct bcm_mini_adapter *Adapter, - struct sk_buff **pPacket, - USHORT Vcid, - B_UINT16 uiClassifierRuleID, - BOOLEAN bHeaderSuppressionEnabled, - UINT *PacketLen, - UCHAR bEthCSSupport) + struct sk_buff **pPacket, + USHORT Vcid, + B_UINT16 uiClassifierRuleID, + bool bHeaderSuppressionEnabled, + UINT *PacketLen, + UCHAR bEthCSSupport) { - - //PHS Sepcific - UINT unPHSPktHdrBytesCopied = 0; - UINT unPhsOldHdrSize = 0; - UINT unPHSNewPktHeaderLen = 0; + /* PHS Sepcific */ + UINT unPHSPktHdrBytesCopied = 0; + UINT unPhsOldHdrSize = 0; + UINT unPHSNewPktHeaderLen = 0; /* Pointer to PHS IN Hdr Buffer */ - PUCHAR pucPHSPktHdrInBuf = - Adapter->stPhsTxContextInfo.ucaHdrSuppressionInBuf; + PUCHAR pucPHSPktHdrInBuf = Adapter->stPhsTxContextInfo.ucaHdrSuppressionInBuf; /* Pointer to PHS OUT Hdr Buffer */ - PUCHAR pucPHSPktHdrOutBuf = - Adapter->stPhsTxContextInfo.ucaHdrSuppressionOutBuf; - UINT usPacketType; - UINT BytesToRemove=0; - BOOLEAN bPHSI = 0; + PUCHAR pucPHSPktHdrOutBuf = Adapter->stPhsTxContextInfo.ucaHdrSuppressionOutBuf; + UINT usPacketType; + UINT BytesToRemove = 0; + bool bPHSI = 0; LONG ulPhsStatus = 0; - UINT numBytesCompressed = 0; + UINT numBytesCompressed = 0; struct sk_buff *newPacket = NULL; struct sk_buff *Packet = *pPacket; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "In PHSTransmit"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "In PHSTransmit"); - if(!bEthCSSupport) - BytesToRemove=ETH_HLEN; + if (!bEthCSSupport) + BytesToRemove = ETH_HLEN; /* - Accumulate the header upto the size we support suppression - from NDIS packet - */ - - usPacketType=((struct ethhdr *)(Packet->data))->h_proto; + * Accumulate the header upto the size we support suppression + * from NDIS packet + */ + usPacketType = ((struct ethhdr *)(Packet->data))->h_proto; pucPHSPktHdrInBuf = Packet->data + BytesToRemove; - //considering data after ethernet header - if((*PacketLen - BytesToRemove) < MAX_PHS_LENGTHS) - { - + /* considering data after ethernet header */ + if ((*PacketLen - BytesToRemove) < MAX_PHS_LENGTHS) unPHSPktHdrBytesCopied = (*PacketLen - BytesToRemove); - } else - { unPHSPktHdrBytesCopied = MAX_PHS_LENGTHS; - } - if( (unPHSPktHdrBytesCopied > 0 ) && - (unPHSPktHdrBytesCopied <= MAX_PHS_LENGTHS)) - { - - - // Step 2 Suppress Header using PHS and fill into intermediate ucaPHSPktHdrOutBuf. - // Suppress only if IP Header and PHS Enabled For the Service Flow - if(((usPacketType == ETHERNET_FRAMETYPE_IPV4) || - (usPacketType == ETHERNET_FRAMETYPE_IPV6)) && - (bHeaderSuppressionEnabled)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nTrying to PHS Compress Using Classifier rule 0x%X",uiClassifierRuleID); - - - unPHSNewPktHeaderLen = unPHSPktHdrBytesCopied; - ulPhsStatus = PhsCompress(&Adapter->stBCMPhsContext, - Vcid, - uiClassifierRuleID, - pucPHSPktHdrInBuf, - pucPHSPktHdrOutBuf, - &unPhsOldHdrSize, - &unPHSNewPktHeaderLen); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nPHS Old header Size : %d New Header Size %d\n",unPhsOldHdrSize,unPHSNewPktHeaderLen); - - if(unPHSNewPktHeaderLen == unPhsOldHdrSize) - { - if( ulPhsStatus == STATUS_PHS_COMPRESSED) - bPHSI = *pucPHSPktHdrOutBuf; - ulPhsStatus = STATUS_PHS_NOCOMPRESSION; - } - - if( ulPhsStatus == STATUS_PHS_COMPRESSED) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"PHS Sending packet Compressed"); + if ((unPHSPktHdrBytesCopied > 0) && + (unPHSPktHdrBytesCopied <= MAX_PHS_LENGTHS)) { - if(skb_cloned(Packet)) - { - newPacket = skb_copy(Packet, GFP_ATOMIC); + /* + * Step 2 Suppress Header using PHS and fill into intermediate ucaPHSPktHdrOutBuf. + * Suppress only if IP Header and PHS Enabled For the Service Flow + */ + if (((usPacketType == ETHERNET_FRAMETYPE_IPV4) || + (usPacketType == ETHERNET_FRAMETYPE_IPV6)) && + (bHeaderSuppressionEnabled)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "\nTrying to PHS Compress Using Classifier rule 0x%X", uiClassifierRuleID); + unPHSNewPktHeaderLen = unPHSPktHdrBytesCopied; + ulPhsStatus = PhsCompress(&Adapter->stBCMPhsContext, + Vcid, + uiClassifierRuleID, + pucPHSPktHdrInBuf, + pucPHSPktHdrOutBuf, + &unPhsOldHdrSize, + &unPHSNewPktHeaderLen); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "\nPHS Old header Size : %d New Header Size %d\n", unPhsOldHdrSize, unPHSNewPktHeaderLen); + + if (unPHSNewPktHeaderLen == unPhsOldHdrSize) { + + if (ulPhsStatus == STATUS_PHS_COMPRESSED) + bPHSI = *pucPHSPktHdrOutBuf; + + ulPhsStatus = STATUS_PHS_NOCOMPRESSION; + } - if(newPacket == NULL) - return STATUS_FAILURE; + if (ulPhsStatus == STATUS_PHS_COMPRESSED) { - dev_kfree_skb(Packet); - *pPacket = Packet = newPacket; - pucPHSPktHdrInBuf = Packet->data + BytesToRemove; - } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "PHS Sending packet Compressed"); - numBytesCompressed = unPhsOldHdrSize - (unPHSNewPktHeaderLen+PHSI_LEN); + if (skb_cloned(Packet)) { + newPacket = skb_copy(Packet, GFP_ATOMIC); - memcpy(pucPHSPktHdrInBuf + numBytesCompressed, pucPHSPktHdrOutBuf, unPHSNewPktHeaderLen + PHSI_LEN); - memcpy(Packet->data + numBytesCompressed, Packet->data, BytesToRemove); - skb_pull(Packet, numBytesCompressed); + if (newPacket == NULL) + return STATUS_FAILURE; - return STATUS_SUCCESS; + dev_kfree_skb(Packet); + *pPacket = Packet = newPacket; + pucPHSPktHdrInBuf = Packet->data + BytesToRemove; } - else - { - //if one byte headroom is not available, increase it through skb_cow - if(!(skb_headroom(Packet) > 0)) - { - if(skb_cow(Packet, 1)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "SKB Cow Failed\n"); - return STATUS_FAILURE; - } - } - skb_push(Packet, 1); + numBytesCompressed = unPhsOldHdrSize - (unPHSNewPktHeaderLen + PHSI_LEN); - // CAUTION: The MAC Header is getting corrupted here for IP CS - can be saved by copying 14 Bytes. not needed .... hence corrupting it. - *(Packet->data + BytesToRemove) = bPHSI; - return STATUS_SUCCESS; - } - } - else - { - if(!bHeaderSuppressionEnabled) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nHeader Suppression Disabled For SF: No PHS\n"); + memcpy(pucPHSPktHdrInBuf + numBytesCompressed, pucPHSPktHdrOutBuf, unPHSNewPktHeaderLen + PHSI_LEN); + memcpy(Packet->data + numBytesCompressed, Packet->data, BytesToRemove); + skb_pull(Packet, numBytesCompressed); + + return STATUS_SUCCESS; + } else { + /* if one byte headroom is not available, increase it through skb_cow */ + if (!(skb_headroom(Packet) > 0)) { + + if (skb_cow(Packet, 1)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "SKB Cow Failed\n"); + return STATUS_FAILURE; + } + } + skb_push(Packet, 1); + + /* + * CAUTION: The MAC Header is getting corrupted + * here for IP CS - can be saved by copying 14 + * Bytes. not needed .... hence corrupting it. + */ + *(Packet->data + BytesToRemove) = bPHSI; + return STATUS_SUCCESS; } + } else { + + if (!bHeaderSuppressionEnabled) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "\nHeader Suppression Disabled For SF: No PHS\n"); return STATUS_SUCCESS; } } - //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"PHSTransmit : Dumping data packet After PHS"); + /* BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"PHSTransmit : Dumping data packet After PHS"); */ return STATUS_SUCCESS; } int PHSReceive(struct bcm_mini_adapter *Adapter, - USHORT usVcid, - struct sk_buff *packet, - UINT *punPacketLen, - UCHAR *pucEthernetHdr, - UINT bHeaderSuppressionEnabled) + USHORT usVcid, + struct sk_buff *packet, + UINT *punPacketLen, + UCHAR *pucEthernetHdr, + UINT bHeaderSuppressionEnabled) { - u32 nStandardPktHdrLen = 0; - u32 nTotalsuppressedPktHdrBytes = 0; - int ulPhsStatus = 0; - PUCHAR pucInBuff = NULL ; + u32 nStandardPktHdrLen = 0; + u32 nTotalsuppressedPktHdrBytes = 0; + int ulPhsStatus = 0; + PUCHAR pucInBuff = NULL; UINT TotalBytesAdded = 0; - if(!bHeaderSuppressionEnabled) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL,"\nPhs Disabled for incoming packet"); + + if (!bHeaderSuppressionEnabled) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, "\nPhs Disabled for incoming packet"); return ulPhsStatus; } pucInBuff = packet->data; - //Restore PHS suppressed header + /* Restore PHS suppressed header */ nStandardPktHdrLen = packet->len; ulPhsStatus = PhsDeCompress(&Adapter->stBCMPhsContext, - usVcid, - pucInBuff, - Adapter->ucaPHSPktRestoreBuf, - &nTotalsuppressedPktHdrBytes, - &nStandardPktHdrLen); + usVcid, + pucInBuff, + Adapter->ucaPHSPktRestoreBuf, + &nTotalsuppressedPktHdrBytes, + &nStandardPktHdrLen); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL,"\nSuppressed PktHdrLen : 0x%x Restored PktHdrLen : 0x%x", - nTotalsuppressedPktHdrBytes,nStandardPktHdrLen); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, "\nSuppressed PktHdrLen : 0x%x Restored PktHdrLen : 0x%x", + nTotalsuppressedPktHdrBytes, nStandardPktHdrLen); - if(ulPhsStatus != STATUS_PHS_COMPRESSED) - { + if (ulPhsStatus != STATUS_PHS_COMPRESSED) { skb_pull(packet, 1); return STATUS_SUCCESS; - } - else - { + } else { TotalBytesAdded = nStandardPktHdrLen - nTotalsuppressedPktHdrBytes - PHSI_LEN; - if(TotalBytesAdded) - { - if(skb_headroom(packet) >= (SKB_RESERVE_ETHERNET_HEADER + TotalBytesAdded)) + + if (TotalBytesAdded) { + if (skb_headroom(packet) >= (SKB_RESERVE_ETHERNET_HEADER + TotalBytesAdded)) skb_push(packet, TotalBytesAdded); - else - { - if(skb_cow(packet, skb_headroom(packet) + TotalBytesAdded)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "cow failed in receive\n"); + else { + if (skb_cow(packet, skb_headroom(packet) + TotalBytesAdded)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "cow failed in receive\n"); return STATUS_FAILURE; } @@ -271,90 +246,80 @@ int PHSReceive(struct bcm_mini_adapter *Adapter, return STATUS_SUCCESS; } -void DumpFullPacket(UCHAR *pBuf,UINT nPktLen) +void DumpFullPacket(UCHAR *pBuf, UINT nPktLen) { struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,"Dumping Data Packet"); - BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,pBuf,nPktLen); + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Dumping Data Packet"); + BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, pBuf, nPktLen); } -//----------------------------------------------------------------------------- -// Procedure: phs_init -// -// Description: This routine is responsible for allocating memory for classifier and -// PHS rules. -// -// Arguments: -// pPhsdeviceExtension - ptr to Device extension containing PHS Classifier rules and PHS Rules , RX, TX buffer etc -// -// Returns: -// TRUE(1) -If allocation of memory was success full. -// FALSE -If allocation of memory fails. -//----------------------------------------------------------------------------- -int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension, struct bcm_mini_adapter *Adapter) +/* + * Procedure: phs_init + * + * Description: This routine is responsible for allocating memory for classifier and + * PHS rules. + * + * Arguments: + * pPhsdeviceExtension - ptr to Device extension containing PHS Classifier rules and PHS Rules , RX, TX buffer etc + * + * Returns: + * TRUE(1) -If allocation of memory was successful. + * FALSE -If allocation of memory fails. + */ +int phs_init(struct bcm_phs_extension *pPhsdeviceExtension, struct bcm_mini_adapter *Adapter) { int i; - S_SERVICEFLOW_TABLE *pstServiceFlowTable; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nPHS:phs_init function "); + struct bcm_phs_table *pstServiceFlowTable; + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nPHS:phs_init function"); - if(pPhsdeviceExtension->pstServiceFlowPhsRulesTable) + if (pPhsdeviceExtension->pstServiceFlowPhsRulesTable) return -EINVAL; - pPhsdeviceExtension->pstServiceFlowPhsRulesTable = - kzalloc(sizeof(S_SERVICEFLOW_TABLE), GFP_KERNEL); + pPhsdeviceExtension->pstServiceFlowPhsRulesTable = kzalloc(sizeof(struct bcm_phs_table), GFP_KERNEL); - if(!pPhsdeviceExtension->pstServiceFlowPhsRulesTable) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation ServiceFlowPhsRulesTable failed"); + if (!pPhsdeviceExtension->pstServiceFlowPhsRulesTable) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation ServiceFlowPhsRulesTable failed"); return -ENOMEM; } pstServiceFlowTable = pPhsdeviceExtension->pstServiceFlowPhsRulesTable; - for(i=0;i<MAX_SERVICEFLOWS;i++) - { - S_SERVICEFLOW_ENTRY sServiceFlow = pstServiceFlowTable->stSFList[i]; - sServiceFlow.pstClassifierTable = kzalloc(sizeof(S_CLASSIFIER_TABLE), GFP_KERNEL); - if(!sServiceFlow.pstClassifierTable) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation failed"); - free_phs_serviceflow_rules(pPhsdeviceExtension-> - pstServiceFlowPhsRulesTable); + for (i = 0; i < MAX_SERVICEFLOWS; i++) { + struct bcm_phs_entry sServiceFlow = pstServiceFlowTable->stSFList[i]; + sServiceFlow.pstClassifierTable = kzalloc(sizeof(struct bcm_phs_classifier_table), GFP_KERNEL); + if (!sServiceFlow.pstClassifierTable) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation failed"); + free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable); pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL; return -ENOMEM; } } pPhsdeviceExtension->CompressedTxBuffer = kmalloc(PHS_BUFFER_SIZE, GFP_KERNEL); - - if(pPhsdeviceExtension->CompressedTxBuffer == NULL) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation failed"); + if (pPhsdeviceExtension->CompressedTxBuffer == NULL) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation failed"); free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable); pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL; return -ENOMEM; } - pPhsdeviceExtension->UnCompressedRxBuffer = kmalloc(PHS_BUFFER_SIZE, GFP_KERNEL); - if(pPhsdeviceExtension->UnCompressedRxBuffer == NULL) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation failed"); + pPhsdeviceExtension->UnCompressedRxBuffer = kmalloc(PHS_BUFFER_SIZE, GFP_KERNEL); + if (pPhsdeviceExtension->UnCompressedRxBuffer == NULL) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation failed"); kfree(pPhsdeviceExtension->CompressedTxBuffer); free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable); pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL; return -ENOMEM; } - - - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\n phs_init Successful"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\n phs_init Successful"); return STATUS_SUCCESS; } - -int PhsCleanup(IN PPHS_DEVICE_EXTENSION pPHSDeviceExt) +int PhsCleanup(IN struct bcm_phs_extension *pPHSDeviceExt) { - if(pPHSDeviceExt->pstServiceFlowPhsRulesTable) - { + if (pPHSDeviceExt->pstServiceFlowPhsRulesTable) { free_phs_serviceflow_rules(pPHSDeviceExt->pstServiceFlowPhsRulesTable); pPHSDeviceExt->pstServiceFlowPhsRulesTable = NULL; } @@ -368,462 +333,394 @@ int PhsCleanup(IN PPHS_DEVICE_EXTENSION pPHSDeviceExt) return 0; } - - -//PHS functions -/*++ -PhsUpdateClassifierRule - -Routine Description: - Exported function to add or modify a PHS Rule. - -Arguments: - IN void* pvContext - PHS Driver Specific Context - IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rule applies - IN B_UINT16 uiClsId - The Classifier ID within the Service Flow for which the PHS rule applies. - IN S_PHS_RULE *psPhsRule - The PHS Rule strcuture to be added to the PHS Rule table. - -Return Value: - - 0 if successful, - >0 Error. - ---*/ -ULONG PhsUpdateClassifierRule(IN void* pvContext, - IN B_UINT16 uiVcid , - IN B_UINT16 uiClsId , - IN S_PHS_RULE *psPhsRule, - IN B_UINT8 u8AssociatedPHSI) +/* + * PHS functions + * PhsUpdateClassifierRule + * + * Routine Description: + * Exported function to add or modify a PHS Rule. + * + * Arguments: + * IN void* pvContext - PHS Driver Specific Context + * IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rule applies + * IN B_UINT16 uiClsId - The Classifier ID within the Service Flow for which the PHS rule applies. + * IN struct bcm_phs_rule *psPhsRule - The PHS Rule strcuture to be added to the PHS Rule table. + * + * Return Value: + * + * 0 if successful, + * >0 Error. + */ +ULONG PhsUpdateClassifierRule(IN void *pvContext, + IN B_UINT16 uiVcid , + IN B_UINT16 uiClsId , + IN struct bcm_phs_rule *psPhsRule, + IN B_UINT8 u8AssociatedPHSI) { - ULONG lStatus =0; - UINT nSFIndex =0 ; - S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL; + ULONG lStatus = 0; + UINT nSFIndex = 0; + struct bcm_phs_entry *pstServiceFlowEntry = NULL; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); + struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *)pvContext; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "PHS With Corr2 Changes\n"); - - PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext; - - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"PHS With Corr2 Changes \n"); - - if(pDeviceExtension == NULL) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"Invalid Device Extension\n"); + if (pDeviceExtension == NULL) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "Invalid Device Extension\n"); return ERR_PHS_INVALID_DEVICE_EXETENSION; } - - if(u8AssociatedPHSI == 0) - { + if (u8AssociatedPHSI == 0) return ERR_PHS_INVALID_PHS_RULE; - } /* Retrieve the SFID Entry Index for requested Service Flow */ - nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, - uiVcid,&pstServiceFlowEntry); + uiVcid, &pstServiceFlowEntry); - if(nSFIndex == PHS_INVALID_TABLE_INDEX) - { + if (nSFIndex == PHS_INVALID_TABLE_INDEX) { /* This is a new SF. Create a mapping entry for this */ lStatus = CreateSFToClassifierRuleMapping(uiVcid, uiClsId, - pDeviceExtension->pstServiceFlowPhsRulesTable, psPhsRule, u8AssociatedPHSI); + pDeviceExtension->pstServiceFlowPhsRulesTable, psPhsRule, u8AssociatedPHSI); return lStatus; } /* SF already Exists Add PHS Rule to existing SF */ - lStatus = CreateClassiferToPHSRuleMapping(uiVcid, uiClsId, - pstServiceFlowEntry, psPhsRule, u8AssociatedPHSI); + lStatus = CreateClassiferToPHSRuleMapping(uiVcid, uiClsId, + pstServiceFlowEntry, psPhsRule, u8AssociatedPHSI); - return lStatus; + return lStatus; } -/*++ -PhsDeletePHSRule - -Routine Description: - Deletes the specified phs Rule within Vcid - -Arguments: - IN void* pvContext - PHS Driver Specific Context - IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rule applies - IN B_UINT8 u8PHSI - the PHS Index identifying PHS rule to be deleted. - -Return Value: - - 0 if successful, - >0 Error. - ---*/ - -ULONG PhsDeletePHSRule(IN void* pvContext,IN B_UINT16 uiVcid,IN B_UINT8 u8PHSI) +/* + * PhsDeletePHSRule + * + * Routine Description: + * Deletes the specified phs Rule within Vcid + * + * Arguments: + * IN void* pvContext - PHS Driver Specific Context + * IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rule applies + * IN B_UINT8 u8PHSI - the PHS Index identifying PHS rule to be deleted. + * + * Return Value: + * + * 0 if successful, + * >0 Error. + */ +ULONG PhsDeletePHSRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT8 u8PHSI) { - ULONG lStatus =0; - UINT nSFIndex =0, nClsidIndex =0 ; - S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL; - S_CLASSIFIER_TABLE *pstClassifierRulesTable = NULL; + UINT nSFIndex = 0, nClsidIndex = 0; + struct bcm_phs_entry *pstServiceFlowEntry = NULL; + struct bcm_phs_classifier_table *pstClassifierRulesTable = NULL; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); + struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *)pvContext; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "======>\n"); - PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext; - - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "======>\n"); + if (pDeviceExtension) { + /* Retrieve the SFID Entry Index for requested Service Flow */ + nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, uiVcid, &pstServiceFlowEntry); - if(pDeviceExtension) - { - - //Retrieve the SFID Entry Index for requested Service Flow - nSFIndex = GetServiceFlowEntry(pDeviceExtension - ->pstServiceFlowPhsRulesTable,uiVcid,&pstServiceFlowEntry); - - if(nSFIndex == PHS_INVALID_TABLE_INDEX) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "SFID Match Failed\n"); + if (nSFIndex == PHS_INVALID_TABLE_INDEX) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "SFID Match Failed\n"); return ERR_SF_MATCH_FAIL; } - pstClassifierRulesTable=pstServiceFlowEntry->pstClassifierTable; - if(pstClassifierRulesTable) - { - for(nClsidIndex=0;nClsidIndex<MAX_PHSRULE_PER_SF;nClsidIndex++) - { - if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].bUsed && pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule) - { - if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8PHSI == u8PHSI) { - if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt) + pstClassifierRulesTable = pstServiceFlowEntry->pstClassifierTable; + if (pstClassifierRulesTable) { + for (nClsidIndex = 0; nClsidIndex < MAX_PHSRULE_PER_SF; nClsidIndex++) { + if (pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].bUsed && pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule) { + if (pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8PHSI == u8PHSI) { + + if (pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt) pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt--; - if(0 == pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt) + + if (0 == pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt) kfree(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule); + memset(&pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex], 0, - sizeof(S_CLASSIFIER_ENTRY)); + sizeof(struct bcm_phs_classifier_entry)); } } } } - } - return lStatus; + return 0; } -/*++ -PhsDeleteClassifierRule - -Routine Description: - Exported function to Delete a PHS Rule for the SFID,CLSID Pair. - -Arguments: - IN void* pvContext - PHS Driver Specific Context - IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rule applies - IN B_UINT16 uiClsId - The Classifier ID within the Service Flow for which the PHS rule applies. - -Return Value: - - 0 if successful, - >0 Error. - ---*/ -ULONG PhsDeleteClassifierRule(IN void* pvContext,IN B_UINT16 uiVcid ,IN B_UINT16 uiClsId) +/* + * PhsDeleteClassifierRule + * + * Routine Description: + * Exported function to Delete a PHS Rule for the SFID,CLSID Pair. + * + * Arguments: + * IN void* pvContext - PHS Driver Specific Context + * IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rule applies + * IN B_UINT16 uiClsId - The Classifier ID within the Service Flow for which the PHS rule applies. + * + * Return Value: + * + * 0 if successful, + * >0 Error. + */ +ULONG PhsDeleteClassifierRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT16 uiClsId) { - ULONG lStatus =0; - UINT nSFIndex =0, nClsidIndex =0 ; - S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL; - S_CLASSIFIER_ENTRY *pstClassifierEntry = NULL; + UINT nSFIndex = 0, nClsidIndex = 0; + struct bcm_phs_entry *pstServiceFlowEntry = NULL; + struct bcm_phs_classifier_entry *pstClassifierEntry = NULL; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext; - - if(pDeviceExtension) - { - //Retrieve the SFID Entry Index for requested Service Flow - nSFIndex = GetServiceFlowEntry(pDeviceExtension - ->pstServiceFlowPhsRulesTable, uiVcid, &pstServiceFlowEntry); - if(nSFIndex == PHS_INVALID_TABLE_INDEX) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"SFID Match Failed\n"); + struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *)pvContext; + + if (pDeviceExtension) { + /* Retrieve the SFID Entry Index for requested Service Flow */ + nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, uiVcid, &pstServiceFlowEntry); + if (nSFIndex == PHS_INVALID_TABLE_INDEX) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "SFID Match Failed\n"); return ERR_SF_MATCH_FAIL; } nClsidIndex = GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable, - uiClsId, eActiveClassifierRuleContext, &pstClassifierEntry); - if((nClsidIndex != PHS_INVALID_TABLE_INDEX) && (!pstClassifierEntry->bUnclassifiedPHSRule)) - { - if(pstClassifierEntry->pstPhsRule) - { - if(pstClassifierEntry->pstPhsRule->u8RefCnt) - pstClassifierEntry->pstPhsRule->u8RefCnt--; - if(0==pstClassifierEntry->pstPhsRule->u8RefCnt) - kfree(pstClassifierEntry->pstPhsRule); + uiClsId, eActiveClassifierRuleContext, &pstClassifierEntry); + + if ((nClsidIndex != PHS_INVALID_TABLE_INDEX) && (!pstClassifierEntry->bUnclassifiedPHSRule)) { + if (pstClassifierEntry->pstPhsRule) { + if (pstClassifierEntry->pstPhsRule->u8RefCnt) + pstClassifierEntry->pstPhsRule->u8RefCnt--; + if (0 == pstClassifierEntry->pstPhsRule->u8RefCnt) + kfree(pstClassifierEntry->pstPhsRule); } - memset(pstClassifierEntry, 0, sizeof(S_CLASSIFIER_ENTRY)); + memset(pstClassifierEntry, 0, sizeof(struct bcm_phs_classifier_entry)); } nClsidIndex = GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable, - uiClsId,eOldClassifierRuleContext,&pstClassifierEntry); + uiClsId, eOldClassifierRuleContext, &pstClassifierEntry); - if((nClsidIndex != PHS_INVALID_TABLE_INDEX) && (!pstClassifierEntry->bUnclassifiedPHSRule)) - { + if ((nClsidIndex != PHS_INVALID_TABLE_INDEX) && (!pstClassifierEntry->bUnclassifiedPHSRule)) { kfree(pstClassifierEntry->pstPhsRule); - memset(pstClassifierEntry, 0, sizeof(S_CLASSIFIER_ENTRY)); + memset(pstClassifierEntry, 0, sizeof(struct bcm_phs_classifier_entry)); } } - return lStatus; + return 0; } -/*++ -PhsDeleteSFRules - -Routine Description: - Exported function to Delete a all PHS Rules for the SFID. - -Arguments: - IN void* pvContext - PHS Driver Specific Context - IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rules need to be deleted - -Return Value: - - 0 if successful, - >0 Error. - ---*/ -ULONG PhsDeleteSFRules(IN void* pvContext,IN B_UINT16 uiVcid) +/* + * PhsDeleteSFRules + * + * Routine Description: + * Exported function to Delete a all PHS Rules for the SFID. + * + * Arguments: + * IN void* pvContext - PHS Driver Specific Context + * IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rules need to be deleted + * + * Return Value: + * + * 0 if successful, + * >0 Error. + */ +ULONG PhsDeleteSFRules(IN void *pvContext, IN B_UINT16 uiVcid) { - - ULONG lStatus =0; - UINT nSFIndex =0, nClsidIndex =0 ; - S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL; - S_CLASSIFIER_TABLE *pstClassifierRulesTable = NULL; + UINT nSFIndex = 0, nClsidIndex = 0; + struct bcm_phs_entry *pstServiceFlowEntry = NULL; + struct bcm_phs_classifier_table *pstClassifierRulesTable = NULL; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"====> \n"); + struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *)pvContext; + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "====>\n"); - if(pDeviceExtension) - { - //Retrieve the SFID Entry Index for requested Service Flow + if (pDeviceExtension) { + /* Retrieve the SFID Entry Index for requested Service Flow */ nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, - uiVcid,&pstServiceFlowEntry); - if(nSFIndex == PHS_INVALID_TABLE_INDEX) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "SFID Match Failed\n"); + uiVcid, &pstServiceFlowEntry); + if (nSFIndex == PHS_INVALID_TABLE_INDEX) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "SFID Match Failed\n"); return ERR_SF_MATCH_FAIL; } - pstClassifierRulesTable=pstServiceFlowEntry->pstClassifierTable; - if(pstClassifierRulesTable) - { - for(nClsidIndex=0;nClsidIndex<MAX_PHSRULE_PER_SF;nClsidIndex++) - { - if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule) - { - if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex] - .pstPhsRule->u8RefCnt) - pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex] - .pstPhsRule->u8RefCnt--; - if(0==pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex] - .pstPhsRule->u8RefCnt) + pstClassifierRulesTable = pstServiceFlowEntry->pstClassifierTable; + if (pstClassifierRulesTable) { + for (nClsidIndex = 0; nClsidIndex < MAX_PHSRULE_PER_SF; nClsidIndex++) { + if (pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule) { + + if (pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt) + pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt--; + + if (0 == pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt) kfree(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule); - pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex] - .pstPhsRule = NULL; + + pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule = NULL; } - memset(&pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex], 0, sizeof(S_CLASSIFIER_ENTRY)); - if(pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex].pstPhsRule) - { - if(pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex] - .pstPhsRule->u8RefCnt) - pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex] - .pstPhsRule->u8RefCnt--; - if(0 == pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex] - .pstPhsRule->u8RefCnt) - kfree(pstClassifierRulesTable - ->stOldPhsRulesList[nClsidIndex].pstPhsRule); - pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex] - .pstPhsRule = NULL; + memset(&pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex], 0, sizeof(struct bcm_phs_classifier_entry)); + if (pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex].pstPhsRule) { + + if (pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt) + pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt--; + + if (0 == pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt) + kfree(pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex].pstPhsRule); + + pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex].pstPhsRule = NULL; } - memset(&pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex], 0, sizeof(S_CLASSIFIER_ENTRY)); + memset(&pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex], 0, sizeof(struct bcm_phs_classifier_entry)); } } - pstServiceFlowEntry->bUsed = FALSE; + pstServiceFlowEntry->bUsed = false; pstServiceFlowEntry->uiVcid = 0; - } - return lStatus; + return 0; } - -/*++ -PhsCompress - -Routine Description: - Exported function to compress the data using PHS. - -Arguments: - IN void* pvContext - PHS Driver Specific Context. - IN B_UINT16 uiVcid - The Service Flow ID to which current packet header compression applies. - IN UINT uiClsId - The Classifier ID to which current packet header compression applies. - IN void *pvInputBuffer - The Input buffer containg packet header data - IN void *pvOutputBuffer - The output buffer returned by this function after PHS - IN UINT *pOldHeaderSize - The actual size of the header before PHS - IN UINT *pNewHeaderSize - The new size of the header after applying PHS - -Return Value: - - 0 if successful, - >0 Error. - ---*/ -ULONG PhsCompress(IN void* pvContext, - IN B_UINT16 uiVcid, - IN B_UINT16 uiClsId, - IN void *pvInputBuffer, - OUT void *pvOutputBuffer, - OUT UINT *pOldHeaderSize, - OUT UINT *pNewHeaderSize ) +/* + * PhsCompress + * + * Routine Description: + * Exported function to compress the data using PHS. + * + * Arguments: + * IN void* pvContext - PHS Driver Specific Context. + * IN B_UINT16 uiVcid - The Service Flow ID to which current packet header compression applies. + * IN UINT uiClsId - The Classifier ID to which current packet header compression applies. + * IN void *pvInputBuffer - The Input buffer containg packet header data + * IN void *pvOutputBuffer - The output buffer returned by this function after PHS + * IN UINT *pOldHeaderSize - The actual size of the header before PHS + * IN UINT *pNewHeaderSize - The new size of the header after applying PHS + * + * Return Value: + * + * 0 if successful, + * >0 Error. + */ +static ULONG PhsCompress(IN void *pvContext, + IN B_UINT16 uiVcid, + IN B_UINT16 uiClsId, + IN void *pvInputBuffer, + OUT void *pvOutputBuffer, + OUT UINT *pOldHeaderSize, + OUT UINT *pNewHeaderSize) { - UINT nSFIndex =0, nClsidIndex =0 ; - S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL; - S_CLASSIFIER_ENTRY *pstClassifierEntry = NULL; - S_PHS_RULE *pstPhsRule = NULL; - ULONG lStatus =0; + UINT nSFIndex = 0, nClsidIndex = 0; + struct bcm_phs_entry *pstServiceFlowEntry = NULL; + struct bcm_phs_classifier_entry *pstClassifierEntry = NULL; + struct bcm_phs_rule *pstPhsRule = NULL; + ULONG lStatus = 0; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); + struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *)pvContext; - - - PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext; - - - if(pDeviceExtension == NULL) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"Invalid Device Extension\n"); - lStatus = STATUS_PHS_NOCOMPRESSION ; + if (pDeviceExtension == NULL) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "Invalid Device Extension\n"); + lStatus = STATUS_PHS_NOCOMPRESSION; return lStatus; - } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"Suppressing header \n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "Suppressing header\n"); - - //Retrieve the SFID Entry Index for requested Service Flow + /* Retrieve the SFID Entry Index for requested Service Flow */ nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, - uiVcid,&pstServiceFlowEntry); - if(nSFIndex == PHS_INVALID_TABLE_INDEX) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"SFID Match Failed\n"); - lStatus = STATUS_PHS_NOCOMPRESSION ; + uiVcid, &pstServiceFlowEntry); + if (nSFIndex == PHS_INVALID_TABLE_INDEX) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "SFID Match Failed\n"); + lStatus = STATUS_PHS_NOCOMPRESSION; return lStatus; } nClsidIndex = GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable, - uiClsId,eActiveClassifierRuleContext,&pstClassifierEntry); + uiClsId, eActiveClassifierRuleContext, &pstClassifierEntry); - if(nClsidIndex == PHS_INVALID_TABLE_INDEX) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"No PHS Rule Defined For Classifier\n"); - lStatus = STATUS_PHS_NOCOMPRESSION ; + if (nClsidIndex == PHS_INVALID_TABLE_INDEX) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "No PHS Rule Defined For Classifier\n"); + lStatus = STATUS_PHS_NOCOMPRESSION; return lStatus; } - - //get rule from SF id,Cls ID pair and proceed - pstPhsRule = pstClassifierEntry->pstPhsRule; - - if(!ValidatePHSRuleComplete(pstPhsRule)) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"PHS Rule Defined For Classifier But Not Complete\n"); - lStatus = STATUS_PHS_NOCOMPRESSION ; + /* get rule from SF id,Cls ID pair and proceed */ + pstPhsRule = pstClassifierEntry->pstPhsRule; + if (!ValidatePHSRuleComplete(pstPhsRule)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "PHS Rule Defined For Classifier But Not Complete\n"); + lStatus = STATUS_PHS_NOCOMPRESSION; return lStatus; } - //Compress Packet - lStatus = phs_compress(pstPhsRule,(PUCHAR)pvInputBuffer, - (PUCHAR)pvOutputBuffer, pOldHeaderSize,pNewHeaderSize); + /* Compress Packet */ + lStatus = phs_compress(pstPhsRule, (PUCHAR)pvInputBuffer, + (PUCHAR)pvOutputBuffer, pOldHeaderSize, pNewHeaderSize); - if(lStatus == STATUS_PHS_COMPRESSED) - { + if (lStatus == STATUS_PHS_COMPRESSED) { pstPhsRule->PHSModifiedBytes += *pOldHeaderSize - *pNewHeaderSize - 1; pstPhsRule->PHSModifiedNumPackets++; - } - else + } else pstPhsRule->PHSErrorNumPackets++; return lStatus; } -/*++ -PhsDeCompress - -Routine Description: - Exported function to restore the packet header in Rx path. - -Arguments: - IN void* pvContext - PHS Driver Specific Context. - IN B_UINT16 uiVcid - The Service Flow ID to which current packet header restoration applies. - IN void *pvInputBuffer - The Input buffer containg suppressed packet header data - OUT void *pvOutputBuffer - The output buffer returned by this function after restoration - OUT UINT *pHeaderSize - The packet header size after restoration is returned in this parameter. - -Return Value: - - 0 if successful, - >0 Error. - ---*/ -ULONG PhsDeCompress(IN void* pvContext, - IN B_UINT16 uiVcid, - IN void *pvInputBuffer, - OUT void *pvOutputBuffer, - OUT UINT *pInHeaderSize, - OUT UINT *pOutHeaderSize ) +/* + * PhsDeCompress + * + * Routine Description: + * Exported function to restore the packet header in Rx path. + * + * Arguments: + * IN void* pvContext - PHS Driver Specific Context. + * IN B_UINT16 uiVcid - The Service Flow ID to which current packet header restoration applies. + * IN void *pvInputBuffer - The Input buffer containg suppressed packet header data + * OUT void *pvOutputBuffer - The output buffer returned by this function after restoration + * OUT UINT *pHeaderSize - The packet header size after restoration is returned in this parameter. + * + * Return Value: + * + * 0 if successful, + * >0 Error. + */ +static ULONG PhsDeCompress(IN void *pvContext, + IN B_UINT16 uiVcid, + IN void *pvInputBuffer, + OUT void *pvOutputBuffer, + OUT UINT *pInHeaderSize, + OUT UINT *pOutHeaderSize) { - UINT nSFIndex =0, nPhsRuleIndex =0 ; - S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL; - S_PHS_RULE *pstPhsRule = NULL; + UINT nSFIndex = 0, nPhsRuleIndex = 0; + struct bcm_phs_entry *pstServiceFlowEntry = NULL; + struct bcm_phs_rule *pstPhsRule = NULL; UINT phsi; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - PPHS_DEVICE_EXTENSION pDeviceExtension= - (PPHS_DEVICE_EXTENSION)pvContext; + struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *)pvContext; *pInHeaderSize = 0; - - if(pDeviceExtension == NULL) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL,"Invalid Device Extension\n"); + if (pDeviceExtension == NULL) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, "Invalid Device Extension\n"); return ERR_PHS_INVALID_DEVICE_EXETENSION; } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL,"Restoring header\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, "Restoring header\n"); phsi = *((unsigned char *)(pvInputBuffer)); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL,"PHSI To Be Used For restore : %x\n",phsi); - if(phsi == UNCOMPRESSED_PACKET ) - { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, "PHSI To Be Used For restore : %x\n", phsi); + if (phsi == UNCOMPRESSED_PACKET) return STATUS_PHS_NOCOMPRESSION; - } - //Retrieve the SFID Entry Index for requested Service Flow + /* Retrieve the SFID Entry Index for requested Service Flow */ nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, - uiVcid,&pstServiceFlowEntry); - if(nSFIndex == PHS_INVALID_TABLE_INDEX) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL,"SFID Match Failed During Lookup\n"); + uiVcid, &pstServiceFlowEntry); + if (nSFIndex == PHS_INVALID_TABLE_INDEX) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, "SFID Match Failed During Lookup\n"); return ERR_SF_MATCH_FAIL; } - nPhsRuleIndex = GetPhsRuleEntry(pstServiceFlowEntry->pstClassifierTable,phsi, - eActiveClassifierRuleContext,&pstPhsRule); - if(nPhsRuleIndex == PHS_INVALID_TABLE_INDEX) - { - //Phs Rule does not exist in active rules table. Lets try in the old rules table. + nPhsRuleIndex = GetPhsRuleEntry(pstServiceFlowEntry->pstClassifierTable, phsi, + eActiveClassifierRuleContext, &pstPhsRule); + if (nPhsRuleIndex == PHS_INVALID_TABLE_INDEX) { + /* Phs Rule does not exist in active rules table. Lets try in the old rules table. */ nPhsRuleIndex = GetPhsRuleEntry(pstServiceFlowEntry->pstClassifierTable, - phsi,eOldClassifierRuleContext,&pstPhsRule); - if(nPhsRuleIndex == PHS_INVALID_TABLE_INDEX) - { + phsi, eOldClassifierRuleContext, &pstPhsRule); + if (nPhsRuleIndex == PHS_INVALID_TABLE_INDEX) return ERR_PHSRULE_MATCH_FAIL; - } - } *pInHeaderSize = phs_decompress((PUCHAR)pvInputBuffer, - (PUCHAR)pvOutputBuffer,pstPhsRule,pOutHeaderSize); + (PUCHAR)pvOutputBuffer, pstPhsRule, pOutHeaderSize); pstPhsRule->PHSModifiedBytes += *pOutHeaderSize - *pInHeaderSize - 1; @@ -831,112 +728,94 @@ ULONG PhsDeCompress(IN void* pvContext, return STATUS_PHS_COMPRESSED; } - -//----------------------------------------------------------------------------- -// Procedure: free_phs_serviceflow_rules -// -// Description: This routine is responsible for freeing memory allocated for PHS rules. -// -// Arguments: -// rules - ptr to S_SERVICEFLOW_TABLE structure. -// -// Returns: -// Does not return any value. -//----------------------------------------------------------------------------- - -static void free_phs_serviceflow_rules(S_SERVICEFLOW_TABLE *psServiceFlowRulesTable) +/* + * Procedure: free_phs_serviceflow_rules + * + * Description: This routine is responsible for freeing memory allocated for PHS rules. + * + * Arguments: + * rules - ptr to S_SERVICEFLOW_TABLE structure. + * + * Returns: + * Does not return any value. + */ +static void free_phs_serviceflow_rules(struct bcm_phs_table *psServiceFlowRulesTable) { - int i,j; + int i, j; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "=======>\n"); - if(psServiceFlowRulesTable) - { - for(i=0;i<MAX_SERVICEFLOWS;i++) - { - S_SERVICEFLOW_ENTRY stServiceFlowEntry = - psServiceFlowRulesTable->stSFList[i]; - S_CLASSIFIER_TABLE *pstClassifierRulesTable = - stServiceFlowEntry.pstClassifierTable; - - if(pstClassifierRulesTable) - { - for(j=0;j<MAX_PHSRULE_PER_SF;j++) - { - if(pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule) - { - if(pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule - ->u8RefCnt) - pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule - ->u8RefCnt--; - if(0==pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule - ->u8RefCnt) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "=======>\n"); + + if (psServiceFlowRulesTable) { + for (i = 0; i < MAX_SERVICEFLOWS; i++) { + struct bcm_phs_entry stServiceFlowEntry = psServiceFlowRulesTable->stSFList[i]; + struct bcm_phs_classifier_table *pstClassifierRulesTable = stServiceFlowEntry.pstClassifierTable; + + if (pstClassifierRulesTable) { + for (j = 0; j < MAX_PHSRULE_PER_SF; j++) { + if (pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule) { + + if (pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule->u8RefCnt) + pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule->u8RefCnt--; + + if (0 == pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule->u8RefCnt) kfree(pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule); + pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule = NULL; } - if(pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule) - { - if(pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule - ->u8RefCnt) - pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule - ->u8RefCnt--; - if(0==pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule - ->u8RefCnt) + + if (pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule) { + + if (pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule->u8RefCnt) + pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule->u8RefCnt--; + + if (0 == pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule->u8RefCnt) kfree(pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule); + pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule = NULL; } } kfree(pstClassifierRulesTable); - stServiceFlowEntry.pstClassifierTable = pstClassifierRulesTable = NULL; + stServiceFlowEntry.pstClassifierTable = pstClassifierRulesTable = NULL; } } } - kfree(psServiceFlowRulesTable); - psServiceFlowRulesTable = NULL; + kfree(psServiceFlowRulesTable); + psServiceFlowRulesTable = NULL; } - - -static BOOLEAN ValidatePHSRuleComplete(IN S_PHS_RULE *psPhsRule) +static bool ValidatePHSRuleComplete(IN struct bcm_phs_rule *psPhsRule) { - if(psPhsRule) - { - if(!psPhsRule->u8PHSI) - { - // PHSI is not valid - return FALSE; + if (psPhsRule) { + if (!psPhsRule->u8PHSI) { + /* PHSI is not valid */ + return false; } - if(!psPhsRule->u8PHSS) - { - //PHSS Is Undefined - return FALSE; + if (!psPhsRule->u8PHSS) { + /* PHSS Is Undefined */ + return false; } - //Check if PHSF is defines for the PHS Rule - if(!psPhsRule->u8PHSFLength) // If any part of PHSF is valid then Rule contains valid PHSF - { - return FALSE; - } + /* Check if PHSF is defines for the PHS Rule */ + if (!psPhsRule->u8PHSFLength) /* If any part of PHSF is valid then Rule contains valid PHSF */ + return false; + return TRUE; - } - else - { - return FALSE; - } + } else + return false; } -UINT GetServiceFlowEntry(IN S_SERVICEFLOW_TABLE *psServiceFlowTable, - IN B_UINT16 uiVcid,S_SERVICEFLOW_ENTRY **ppstServiceFlowEntry) +UINT GetServiceFlowEntry(IN struct bcm_phs_table *psServiceFlowTable, + IN B_UINT16 uiVcid, + struct bcm_phs_entry **ppstServiceFlowEntry) { - int i; - for(i=0;i<MAX_SERVICEFLOWS;i++) - { - if(psServiceFlowTable->stSFList[i].bUsed) - { - if(psServiceFlowTable->stSFList[i].uiVcid == uiVcid) - { + int i; + + for (i = 0; i < MAX_SERVICEFLOWS; i++) { + if (psServiceFlowTable->stSFList[i].bUsed) { + if (psServiceFlowTable->stSFList[i].uiVcid == uiVcid) { *ppstServiceFlowEntry = &psServiceFlowTable->stSFList[i]; return i; } @@ -947,289 +826,254 @@ UINT GetServiceFlowEntry(IN S_SERVICEFLOW_TABLE *psServiceFlowTable, return PHS_INVALID_TABLE_INDEX; } - -UINT GetClassifierEntry(IN S_CLASSIFIER_TABLE *pstClassifierTable, - IN B_UINT32 uiClsid,E_CLASSIFIER_ENTRY_CONTEXT eClsContext, - OUT S_CLASSIFIER_ENTRY **ppstClassifierEntry) +static UINT GetClassifierEntry(IN struct bcm_phs_classifier_table *pstClassifierTable, + IN B_UINT32 uiClsid, enum bcm_phs_classifier_context eClsContext, + OUT struct bcm_phs_classifier_entry **ppstClassifierEntry) { int i; - S_CLASSIFIER_ENTRY *psClassifierRules = NULL; - for(i=0;i<MAX_PHSRULE_PER_SF;i++) - { + struct bcm_phs_classifier_entry *psClassifierRules = NULL; + + for (i = 0; i < MAX_PHSRULE_PER_SF; i++) { - if(eClsContext == eActiveClassifierRuleContext) - { + if (eClsContext == eActiveClassifierRuleContext) psClassifierRules = &pstClassifierTable->stActivePhsRulesList[i]; - } else - { psClassifierRules = &pstClassifierTable->stOldPhsRulesList[i]; - } - if(psClassifierRules->bUsed) - { - if(psClassifierRules->uiClassifierRuleId == uiClsid) - { + if (psClassifierRules->bUsed) { + if (psClassifierRules->uiClassifierRuleId == uiClsid) { *ppstClassifierEntry = psClassifierRules; return i; } } - } *ppstClassifierEntry = NULL; return PHS_INVALID_TABLE_INDEX; } -static UINT GetPhsRuleEntry(IN S_CLASSIFIER_TABLE *pstClassifierTable, - IN B_UINT32 uiPHSI,E_CLASSIFIER_ENTRY_CONTEXT eClsContext, - OUT S_PHS_RULE **ppstPhsRule) +static UINT GetPhsRuleEntry(IN struct bcm_phs_classifier_table *pstClassifierTable, + IN B_UINT32 uiPHSI, enum bcm_phs_classifier_context eClsContext, + OUT struct bcm_phs_rule **ppstPhsRule) { int i; - S_CLASSIFIER_ENTRY *pstClassifierRule = NULL; - for(i=0;i<MAX_PHSRULE_PER_SF;i++) - { - if(eClsContext == eActiveClassifierRuleContext) - { + struct bcm_phs_classifier_entry *pstClassifierRule = NULL; + + for (i = 0; i < MAX_PHSRULE_PER_SF; i++) { + if (eClsContext == eActiveClassifierRuleContext) pstClassifierRule = &pstClassifierTable->stActivePhsRulesList[i]; - } else - { pstClassifierRule = &pstClassifierTable->stOldPhsRulesList[i]; - } - if(pstClassifierRule->bUsed) - { - if(pstClassifierRule->u8PHSI == uiPHSI) - { + + if (pstClassifierRule->bUsed) { + if (pstClassifierRule->u8PHSI == uiPHSI) { *ppstPhsRule = pstClassifierRule->pstPhsRule; return i; } } - } *ppstPhsRule = NULL; return PHS_INVALID_TABLE_INDEX; } -UINT CreateSFToClassifierRuleMapping(IN B_UINT16 uiVcid,IN B_UINT16 uiClsId, - IN S_SERVICEFLOW_TABLE *psServiceFlowTable,S_PHS_RULE *psPhsRule, - B_UINT8 u8AssociatedPHSI) +static UINT CreateSFToClassifierRuleMapping(IN B_UINT16 uiVcid, IN B_UINT16 uiClsId, + IN struct bcm_phs_table *psServiceFlowTable, + struct bcm_phs_rule *psPhsRule, + B_UINT8 u8AssociatedPHSI) { - - S_CLASSIFIER_TABLE *psaClassifiertable = NULL; + struct bcm_phs_classifier_table *psaClassifiertable = NULL; UINT uiStatus = 0; int iSfIndex; - BOOLEAN bFreeEntryFound =FALSE; - //Check for a free entry in SFID table - for(iSfIndex=0;iSfIndex < MAX_SERVICEFLOWS;iSfIndex++) - { - if(!psServiceFlowTable->stSFList[iSfIndex].bUsed) - { + bool bFreeEntryFound = false; + + /* Check for a free entry in SFID table */ + for (iSfIndex = 0; iSfIndex < MAX_SERVICEFLOWS; iSfIndex++) { + if (!psServiceFlowTable->stSFList[iSfIndex].bUsed) { bFreeEntryFound = TRUE; break; } } - if(!bFreeEntryFound) + if (!bFreeEntryFound) return ERR_SFTABLE_FULL; - psaClassifiertable = psServiceFlowTable->stSFList[iSfIndex].pstClassifierTable; - uiStatus = CreateClassifierPHSRule(uiClsId,psaClassifiertable,psPhsRule, - eActiveClassifierRuleContext,u8AssociatedPHSI); - if(uiStatus == PHS_SUCCESS) - { - //Add entry at free index to the SF + uiStatus = CreateClassifierPHSRule(uiClsId, psaClassifiertable, psPhsRule, + eActiveClassifierRuleContext, u8AssociatedPHSI); + if (uiStatus == PHS_SUCCESS) { + /* Add entry at free index to the SF */ psServiceFlowTable->stSFList[iSfIndex].bUsed = TRUE; psServiceFlowTable->stSFList[iSfIndex].uiVcid = uiVcid; } return uiStatus; - } -UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid, - IN B_UINT16 uiClsId,IN S_SERVICEFLOW_ENTRY *pstServiceFlowEntry, - S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI) +static UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid, + IN B_UINT16 uiClsId, + IN struct bcm_phs_entry *pstServiceFlowEntry, + struct bcm_phs_rule *psPhsRule, + B_UINT8 u8AssociatedPHSI) { - S_CLASSIFIER_ENTRY *pstClassifierEntry = NULL; - UINT uiStatus =PHS_SUCCESS; + struct bcm_phs_classifier_entry *pstClassifierEntry = NULL; + UINT uiStatus = PHS_SUCCESS; UINT nClassifierIndex = 0; - S_CLASSIFIER_TABLE *psaClassifiertable = NULL; + struct bcm_phs_classifier_table *psaClassifiertable = NULL; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - psaClassifiertable = pstServiceFlowEntry->pstClassifierTable; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "==>"); + psaClassifiertable = pstServiceFlowEntry->pstClassifierTable; + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "==>"); /* Check if the supplied Classifier already exists */ - nClassifierIndex =GetClassifierEntry( - pstServiceFlowEntry->pstClassifierTable,uiClsId, - eActiveClassifierRuleContext,&pstClassifierEntry); - if(nClassifierIndex == PHS_INVALID_TABLE_INDEX) - { + nClassifierIndex = GetClassifierEntry( + pstServiceFlowEntry->pstClassifierTable, + uiClsId, + eActiveClassifierRuleContext, + &pstClassifierEntry); + + if (nClassifierIndex == PHS_INVALID_TABLE_INDEX) { /* - The Classifier doesn't exist. So its a new classifier being added. - Add new entry to associate PHS Rule to the Classifier - */ + * The Classifier doesn't exist. So its a new classifier being added. + * Add new entry to associate PHS Rule to the Classifier + */ - uiStatus = CreateClassifierPHSRule(uiClsId,psaClassifiertable, - psPhsRule,eActiveClassifierRuleContext,u8AssociatedPHSI); + uiStatus = CreateClassifierPHSRule(uiClsId, psaClassifiertable, + psPhsRule, + eActiveClassifierRuleContext, + u8AssociatedPHSI); return uiStatus; } /* - The Classifier exists.The PHS Rule for this classifier - is being modified - */ - if(pstClassifierEntry->u8PHSI == psPhsRule->u8PHSI) - { - if(pstClassifierEntry->pstPhsRule == NULL) + * The Classifier exists.The PHS Rule for this classifier + * is being modified + */ + + if (pstClassifierEntry->u8PHSI == psPhsRule->u8PHSI) { + if (pstClassifierEntry->pstPhsRule == NULL) return ERR_PHS_INVALID_PHS_RULE; /* - This rule already exists if any fields are changed for this PHS - rule update them. + * This rule already exists if any fields are changed for this PHS + * rule update them. */ - /* If any part of PHSF is valid then we update PHSF */ - if(psPhsRule->u8PHSFLength) - { - //update PHSF + /* If any part of PHSF is valid then we update PHSF */ + if (psPhsRule->u8PHSFLength) { + /* update PHSF */ memcpy(pstClassifierEntry->pstPhsRule->u8PHSF, - psPhsRule->u8PHSF , MAX_PHS_LENGTHS); + psPhsRule->u8PHSF, MAX_PHS_LENGTHS); } - if(psPhsRule->u8PHSFLength) - { - //update PHSFLen - pstClassifierEntry->pstPhsRule->u8PHSFLength = - psPhsRule->u8PHSFLength; + + if (psPhsRule->u8PHSFLength) { + /* update PHSFLen */ + pstClassifierEntry->pstPhsRule->u8PHSFLength = psPhsRule->u8PHSFLength; } - if(psPhsRule->u8PHSMLength) - { - //update PHSM + + if (psPhsRule->u8PHSMLength) { + /* update PHSM */ memcpy(pstClassifierEntry->pstPhsRule->u8PHSM, - psPhsRule->u8PHSM, MAX_PHS_LENGTHS); + psPhsRule->u8PHSM, MAX_PHS_LENGTHS); } - if(psPhsRule->u8PHSMLength) - { - //update PHSM Len + + if (psPhsRule->u8PHSMLength) { + /* update PHSM Len */ pstClassifierEntry->pstPhsRule->u8PHSMLength = - psPhsRule->u8PHSMLength; + psPhsRule->u8PHSMLength; } - if(psPhsRule->u8PHSS) - { - //update PHSS + + if (psPhsRule->u8PHSS) { + /* update PHSS */ pstClassifierEntry->pstPhsRule->u8PHSS = psPhsRule->u8PHSS; } - //update PHSV + /* update PHSV */ pstClassifierEntry->pstPhsRule->u8PHSV = psPhsRule->u8PHSV; - - } - else - { - /* - A new rule is being set for this classifier. - */ - uiStatus=UpdateClassifierPHSRule( uiClsId, pstClassifierEntry, - psaClassifiertable, psPhsRule, u8AssociatedPHSI); + } else { + /* A new rule is being set for this classifier. */ + uiStatus = UpdateClassifierPHSRule(uiClsId, pstClassifierEntry, + psaClassifiertable, psPhsRule, u8AssociatedPHSI); } - - return uiStatus; } static UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId, - S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule, - E_CLASSIFIER_ENTRY_CONTEXT eClsContext,B_UINT8 u8AssociatedPHSI) + struct bcm_phs_classifier_table *psaClassifiertable, + struct bcm_phs_rule *psPhsRule, + enum bcm_phs_classifier_context eClsContext, + B_UINT8 u8AssociatedPHSI) { UINT iClassifierIndex = 0; - BOOLEAN bFreeEntryFound = FALSE; - S_CLASSIFIER_ENTRY *psClassifierRules = NULL; + bool bFreeEntryFound = false; + struct bcm_phs_classifier_entry *psClassifierRules = NULL; UINT nStatus = PHS_SUCCESS; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"Inside CreateClassifierPHSRule"); - if(psaClassifiertable == NULL) - { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "Inside CreateClassifierPHSRule"); + + if (psaClassifiertable == NULL) return ERR_INVALID_CLASSIFIERTABLE_FOR_SF; - } - if(eClsContext == eOldClassifierRuleContext) - { - /* If An Old Entry for this classifier ID already exists in the - old rules table replace it. */ + if (eClsContext == eOldClassifierRuleContext) { + /* + * If An Old Entry for this classifier ID already exists in the + * old rules table replace it. + */ iClassifierIndex = - GetClassifierEntry(psaClassifiertable, uiClsId, - eClsContext,&psClassifierRules); - if(iClassifierIndex != PHS_INVALID_TABLE_INDEX) - { + GetClassifierEntry(psaClassifiertable, uiClsId, + eClsContext, &psClassifierRules); + + if (iClassifierIndex != PHS_INVALID_TABLE_INDEX) { /* - The Classifier already exists in the old rules table - Lets replace the old classifier with the new one. - */ + * The Classifier already exists in the old rules table + * Lets replace the old classifier with the new one. + */ bFreeEntryFound = TRUE; } } - if(!bFreeEntryFound) - { - /* - Continue to search for a free location to add the rule - */ - for(iClassifierIndex = 0; iClassifierIndex < - MAX_PHSRULE_PER_SF; iClassifierIndex++) - { - if(eClsContext == eActiveClassifierRuleContext) - { - psClassifierRules = - &psaClassifiertable->stActivePhsRulesList[iClassifierIndex]; - } + if (!bFreeEntryFound) { + /* Continue to search for a free location to add the rule */ + for (iClassifierIndex = 0; iClassifierIndex < + MAX_PHSRULE_PER_SF; iClassifierIndex++) { + if (eClsContext == eActiveClassifierRuleContext) + psClassifierRules = &psaClassifiertable->stActivePhsRulesList[iClassifierIndex]; else - { - psClassifierRules = - &psaClassifiertable->stOldPhsRulesList[iClassifierIndex]; - } + psClassifierRules = &psaClassifiertable->stOldPhsRulesList[iClassifierIndex]; - if(!psClassifierRules->bUsed) - { + if (!psClassifierRules->bUsed) { bFreeEntryFound = TRUE; break; } } } - if(!bFreeEntryFound) - { - if(eClsContext == eActiveClassifierRuleContext) - { + if (!bFreeEntryFound) { + + if (eClsContext == eActiveClassifierRuleContext) return ERR_CLSASSIFIER_TABLE_FULL; - } - else - { - //Lets replace the oldest rule if we are looking in old Rule table - if(psaClassifiertable->uiOldestPhsRuleIndex >= - MAX_PHSRULE_PER_SF) - { - psaClassifiertable->uiOldestPhsRuleIndex =0; - } + else { + /* Lets replace the oldest rule if we are looking in old Rule table */ + if (psaClassifiertable->uiOldestPhsRuleIndex >= MAX_PHSRULE_PER_SF) + psaClassifiertable->uiOldestPhsRuleIndex = 0; iClassifierIndex = psaClassifiertable->uiOldestPhsRuleIndex; - psClassifierRules = - &psaClassifiertable->stOldPhsRulesList[iClassifierIndex]; + psClassifierRules = &psaClassifiertable->stOldPhsRulesList[iClassifierIndex]; - (psaClassifiertable->uiOldestPhsRuleIndex)++; + (psaClassifiertable->uiOldestPhsRuleIndex)++; } } - if(eClsContext == eOldClassifierRuleContext) - { - if(psClassifierRules->pstPhsRule == NULL) - { - psClassifierRules->pstPhsRule = kmalloc(sizeof(S_PHS_RULE),GFP_KERNEL); + if (eClsContext == eOldClassifierRuleContext) { + + if (psClassifierRules->pstPhsRule == NULL) { - if(NULL == psClassifierRules->pstPhsRule) + psClassifierRules->pstPhsRule = kmalloc(sizeof(struct bcm_phs_rule), GFP_KERNEL); + + if (NULL == psClassifierRules->pstPhsRule) return ERR_PHSRULE_MEMALLOC_FAIL; } @@ -1238,70 +1082,62 @@ static UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId, psClassifierRules->u8PHSI = psPhsRule->u8PHSI; psClassifierRules->bUnclassifiedPHSRule = psPhsRule->bUnclassifiedPHSRule; - /* Update The PHS rule */ - memcpy(psClassifierRules->pstPhsRule, - psPhsRule, sizeof(S_PHS_RULE)); - } - else - { - nStatus = UpdateClassifierPHSRule(uiClsId,psClassifierRules, - psaClassifiertable,psPhsRule,u8AssociatedPHSI); - } + /* Update The PHS rule */ + memcpy(psClassifierRules->pstPhsRule, psPhsRule, sizeof(struct bcm_phs_rule)); + } else + nStatus = UpdateClassifierPHSRule(uiClsId, psClassifierRules, + psaClassifiertable, psPhsRule, u8AssociatedPHSI); + return nStatus; } - static UINT UpdateClassifierPHSRule(IN B_UINT16 uiClsId, - IN S_CLASSIFIER_ENTRY *pstClassifierEntry, - S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule, - B_UINT8 u8AssociatedPHSI) + IN struct bcm_phs_classifier_entry *pstClassifierEntry, + struct bcm_phs_classifier_table *psaClassifiertable, + struct bcm_phs_rule *psPhsRule, + B_UINT8 u8AssociatedPHSI) { - S_PHS_RULE *pstAddPhsRule = NULL; - UINT nPhsRuleIndex = 0; - BOOLEAN bPHSRuleOrphaned = FALSE; + struct bcm_phs_rule *pstAddPhsRule = NULL; + UINT nPhsRuleIndex = 0; + bool bPHSRuleOrphaned = false; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - psPhsRule->u8RefCnt =0; - - /* Step 1 Deref Any Exisiting PHS Rule in this classifier Entry*/ - bPHSRuleOrphaned = DerefPhsRule( uiClsId, psaClassifiertable, - pstClassifierEntry->pstPhsRule); - - //Step 2 Search if there is a PHS Rule with u8AssociatedPHSI in Classifier table for this SF - nPhsRuleIndex =GetPhsRuleEntry(psaClassifiertable,u8AssociatedPHSI, - eActiveClassifierRuleContext, &pstAddPhsRule); - if(PHS_INVALID_TABLE_INDEX == nPhsRuleIndex) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAdding New PHSRuleEntry For Classifier"); - - if(psPhsRule->u8PHSI == 0) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nError PHSI is Zero\n"); + + psPhsRule->u8RefCnt = 0; + + /* Step 1 Deref Any Exisiting PHS Rule in this classifier Entry */ + bPHSRuleOrphaned = DerefPhsRule(uiClsId, psaClassifiertable, + pstClassifierEntry->pstPhsRule); + + /* Step 2 Search if there is a PHS Rule with u8AssociatedPHSI in Classifier table for this SF */ + nPhsRuleIndex = GetPhsRuleEntry(psaClassifiertable, u8AssociatedPHSI, + eActiveClassifierRuleContext, &pstAddPhsRule); + if (PHS_INVALID_TABLE_INDEX == nPhsRuleIndex) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAdding New PHSRuleEntry For Classifier"); + + if (psPhsRule->u8PHSI == 0) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nError PHSI is Zero\n"); return ERR_PHS_INVALID_PHS_RULE; } - //Step 2.a PHS Rule Does Not Exist .Create New PHS Rule for uiClsId - if(FALSE == bPHSRuleOrphaned) - { - pstClassifierEntry->pstPhsRule = kmalloc(sizeof(S_PHS_RULE), GFP_KERNEL); - if(NULL == pstClassifierEntry->pstPhsRule) - { + + /* Step 2.a PHS Rule Does Not Exist .Create New PHS Rule for uiClsId */ + if (false == bPHSRuleOrphaned) { + + pstClassifierEntry->pstPhsRule = kmalloc(sizeof(struct bcm_phs_rule), GFP_KERNEL); + if (NULL == pstClassifierEntry->pstPhsRule) return ERR_PHSRULE_MEMALLOC_FAIL; - } } - memcpy(pstClassifierEntry->pstPhsRule, psPhsRule, sizeof(S_PHS_RULE)); - - } - else - { - //Step 2.b PHS Rule Exists Tie uiClsId with the existing PHS Rule - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nTying Classifier to Existing PHS Rule"); - if(bPHSRuleOrphaned) - { + memcpy(pstClassifierEntry->pstPhsRule, psPhsRule, sizeof(struct bcm_phs_rule)); + } else { + /* Step 2.b PHS Rule Exists Tie uiClsId with the existing PHS Rule */ + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nTying Classifier to Existing PHS Rule"); + if (bPHSRuleOrphaned) { kfree(pstClassifierEntry->pstPhsRule); pstClassifierEntry->pstPhsRule = NULL; } pstClassifierEntry->pstPhsRule = pstAddPhsRule; - } + pstClassifierEntry->bUsed = TRUE; pstClassifierEntry->u8PHSI = pstClassifierEntry->pstPhsRule->u8PHSI; pstClassifierEntry->uiClassifierRuleId = uiClsId; @@ -1309,79 +1145,74 @@ static UINT UpdateClassifierPHSRule(IN B_UINT16 uiClsId, pstClassifierEntry->bUnclassifiedPHSRule = pstClassifierEntry->pstPhsRule->bUnclassifiedPHSRule; return PHS_SUCCESS; - } -static BOOLEAN DerefPhsRule(IN B_UINT16 uiClsId,S_CLASSIFIER_TABLE *psaClassifiertable,S_PHS_RULE *pstPhsRule) +static bool DerefPhsRule(IN B_UINT16 uiClsId, struct bcm_phs_classifier_table *psaClassifiertable, struct bcm_phs_rule *pstPhsRule) { - if(pstPhsRule==NULL) - return FALSE; - if(pstPhsRule->u8RefCnt) + if (pstPhsRule == NULL) + return false; + + if (pstPhsRule->u8RefCnt) pstPhsRule->u8RefCnt--; - if(0==pstPhsRule->u8RefCnt) - { - /*if(pstPhsRule->u8PHSI) - //Store the currently active rule into the old rules list - CreateClassifierPHSRule(uiClsId,psaClassifiertable,pstPhsRule,eOldClassifierRuleContext,pstPhsRule->u8PHSI);*/ + + if (0 == pstPhsRule->u8RefCnt) { + /* + * if(pstPhsRule->u8PHSI) + * Store the currently active rule into the old rules list + * CreateClassifierPHSRule(uiClsId,psaClassifiertable,pstPhsRule,eOldClassifierRuleContext,pstPhsRule->u8PHSI); + */ return TRUE; - } - else - { - return FALSE; - } + } else + return false; } -void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension) +void DumpPhsRules(struct bcm_phs_extension *pDeviceExtension) { - int i,j,k,l; + int i, j, k, l; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n Dumping PHS Rules : \n"); - for(i=0;i<MAX_SERVICEFLOWS;i++) - { - S_SERVICEFLOW_ENTRY stServFlowEntry = - pDeviceExtension->pstServiceFlowPhsRulesTable->stSFList[i]; - if(stServFlowEntry.bUsed) - { - for(j=0;j<MAX_PHSRULE_PER_SF;j++) - { - for(l=0;l<2;l++) - { - S_CLASSIFIER_ENTRY stClsEntry; - if(l==0) - { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n Dumping PHS Rules :\n"); + + for (i = 0; i < MAX_SERVICEFLOWS; i++) { + + struct bcm_phs_entry stServFlowEntry = + pDeviceExtension->pstServiceFlowPhsRulesTable->stSFList[i]; + if (stServFlowEntry.bUsed) { + + for (j = 0; j < MAX_PHSRULE_PER_SF; j++) { + + for (l = 0; l < 2; l++) { + struct bcm_phs_classifier_entry stClsEntry; + + if (l == 0) { stClsEntry = stServFlowEntry.pstClassifierTable->stActivePhsRulesList[j]; - if(stClsEntry.bUsed) - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n Active PHS Rule : \n"); - } - else - { + if (stClsEntry.bUsed) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n Active PHS Rule :\n"); + } else { stClsEntry = stServFlowEntry.pstClassifierTable->stOldPhsRulesList[j]; - if(stClsEntry.bUsed) - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n Old PHS Rule : \n"); + if (stClsEntry.bUsed) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n Old PHS Rule :\n"); } - if(stClsEntry.bUsed) - { - - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n VCID : %#X",stServFlowEntry.uiVcid); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n ClassifierID : %#X",stClsEntry.uiClassifierRuleId); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSRuleID : %#X",stClsEntry.u8PHSI); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n****************PHS Rule********************\n"); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSI : %#X",stClsEntry.pstPhsRule->u8PHSI); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSFLength : %#X ",stClsEntry.pstPhsRule->u8PHSFLength); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSF : "); - for(k=0;k<stClsEntry.pstPhsRule->u8PHSFLength;k++) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "%#X ",stClsEntry.pstPhsRule->u8PHSF[k]); - } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSMLength : %#X",stClsEntry.pstPhsRule->u8PHSMLength); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSM :"); - for(k=0;k<stClsEntry.pstPhsRule->u8PHSMLength;k++) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "%#X ",stClsEntry.pstPhsRule->u8PHSM[k]); - } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSS : %#X ",stClsEntry.pstPhsRule->u8PHSS); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSV : %#X",stClsEntry.pstPhsRule->u8PHSV); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n********************************************\n"); + + if (stClsEntry.bUsed) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n VCID : %#X", stServFlowEntry.uiVcid); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n ClassifierID : %#X", stClsEntry.uiClassifierRuleId); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSRuleID : %#X", stClsEntry.u8PHSI); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n****************PHS Rule********************\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSI : %#X", stClsEntry.pstPhsRule->u8PHSI); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSFLength : %#X ", stClsEntry.pstPhsRule->u8PHSFLength); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSF : "); + + for (k = 0 ; k < stClsEntry.pstPhsRule->u8PHSFLength; k++) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "%#X ", stClsEntry.pstPhsRule->u8PHSF[k]); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSMLength : %#X", stClsEntry.pstPhsRule->u8PHSMLength); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSM :"); + + for (k = 0; k < stClsEntry.pstPhsRule->u8PHSMLength; k++) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "%#X ", stClsEntry.pstPhsRule->u8PHSM[k]); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSS : %#X ", stClsEntry.pstPhsRule->u8PHSS); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSV : %#X", stClsEntry.pstPhsRule->u8PHSV); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n********************************************\n"); } } } @@ -1389,66 +1220,69 @@ void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension) } } - -//----------------------------------------------------------------------------- -// Procedure: phs_decompress -// -// Description: This routine restores the static fields within the packet. -// -// Arguments: -// in_buf - ptr to incoming packet buffer. -// out_buf - ptr to output buffer where the suppressed header is copied. -// decomp_phs_rules - ptr to PHS rule. -// header_size - ptr to field which holds the phss or phsf_length. -// -// Returns: -// size -The number of bytes of dynamic fields present with in the incoming packet -// header. -// 0 -If PHS rule is NULL.If PHSI is 0 indicateing packet as uncompressed. -//----------------------------------------------------------------------------- - -int phs_decompress(unsigned char *in_buf,unsigned char *out_buf, - S_PHS_RULE *decomp_phs_rules,UINT *header_size) +/* + * Procedure: phs_decompress + * + * Description: This routine restores the static fields within the packet. + * + * Arguments: + * in_buf - ptr to incoming packet buffer. + * out_buf - ptr to output buffer where the suppressed header is copied. + * decomp_phs_rules - ptr to PHS rule. + * header_size - ptr to field which holds the phss or phsf_length. + * + * Returns: + * size -The number of bytes of dynamic fields present with in the incoming packet + * header. + * 0 -If PHS rule is NULL.If PHSI is 0 indicateing packet as uncompressed. + */ +static int phs_decompress(unsigned char *in_buf, + unsigned char *out_buf, + struct bcm_phs_rule *decomp_phs_rules, + UINT *header_size) { - int phss,size=0; - S_PHS_RULE *tmp_memb; - int bit,i=0; - unsigned char *phsf,*phsm; - int in_buf_len = *header_size-1; + int phss, size = 0; + struct bcm_phs_rule *tmp_memb; + int bit, i = 0; + unsigned char *phsf, *phsm; + int in_buf_len = *header_size - 1; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); + in_buf++; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL,"====>\n"); + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, "====>\n"); *header_size = 0; - if((decomp_phs_rules == NULL )) + if ((decomp_phs_rules == NULL)) return 0; - tmp_memb = decomp_phs_rules; - //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL,"\nDECOMP:In phs_decompress PHSI 1 %d",phsi)); - //*header_size = tmp_memb->u8PHSFLength; - phss = tmp_memb->u8PHSS; - phsf = tmp_memb->u8PHSF; - phsm = tmp_memb->u8PHSM; - - if(phss > MAX_PHS_LENGTHS) + /* + * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL,"\nDECOMP:In phs_decompress PHSI 1 %d",phsi)); + * header_size = tmp_memb->u8PHSFLength; + */ + phss = tmp_memb->u8PHSS; + phsf = tmp_memb->u8PHSF; + phsm = tmp_memb->u8PHSM; + + if (phss > MAX_PHS_LENGTHS) phss = MAX_PHS_LENGTHS; - //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL,"\nDECOMP:In phs_decompress PHSI %d phss %d index %d",phsi,phss,index)); - while((phss > 0) && (size < in_buf_len)) - { - bit = ((*phsm << i)& SUPPRESS); - if(bit == SUPPRESS) - { + /* + * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL,"\nDECOMP: + * In phs_decompress PHSI %d phss %d index %d",phsi,phss,index)); + */ + while ((phss > 0) && (size < in_buf_len)) { + bit = ((*phsm << i) & SUPPRESS); + + if (bit == SUPPRESS) { *out_buf = *phsf; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL,"\nDECOMP:In phss %d phsf %d ouput %d", - phss,*phsf,*out_buf); - } - else - { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, "\nDECOMP:In phss %d phsf %d output %d", + phss, *phsf, *out_buf); + } else { *out_buf = *in_buf; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL,"\nDECOMP:In phss %d input %d ouput %d", - phss,*in_buf,*out_buf); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, "\nDECOMP:In phss %d input %d output %d", + phss, *in_buf, *out_buf); in_buf++; size++; } @@ -1456,156 +1290,159 @@ int phs_decompress(unsigned char *in_buf,unsigned char *out_buf, phsf++; phss--; i++; - *header_size=*header_size + 1; + *header_size = *header_size + 1; - if(i > MAX_NO_BIT) - { - i=0; + if (i > MAX_NO_BIT) { + i = 0; phsm++; } } + return size; } - - - -//----------------------------------------------------------------------------- -// Procedure: phs_compress -// -// Description: This routine suppresses the static fields within the packet.Before -// that it will verify the fields to be suppressed with the corresponding fields in the -// phsf. For verification it checks the phsv field of PHS rule. If set and verification -// succeeds it suppresses the field.If any one static field is found different none of -// the static fields are suppressed then the packet is sent as uncompressed packet with -// phsi=0. -// -// Arguments: -// phs_rule - ptr to PHS rule. -// in_buf - ptr to incoming packet buffer. -// out_buf - ptr to output buffer where the suppressed header is copied. -// header_size - ptr to field which holds the phss. -// -// Returns: -// size-The number of bytes copied into the output buffer i.e dynamic fields -// 0 -If PHS rule is NULL.If PHSV field is not set.If the verification fails. -//----------------------------------------------------------------------------- -static int phs_compress(S_PHS_RULE *phs_rule,unsigned char *in_buf - ,unsigned char *out_buf,UINT *header_size,UINT *new_header_size) +/* + * Procedure: phs_compress + * + * Description: This routine suppresses the static fields within the packet.Before + * that it will verify the fields to be suppressed with the corresponding fields in the + * phsf. For verification it checks the phsv field of PHS rule. If set and verification + * succeeds it suppresses the field.If any one static field is found different none of + * the static fields are suppressed then the packet is sent as uncompressed packet with + * phsi=0. + * + * Arguments: + * phs_rule - ptr to PHS rule. + * in_buf - ptr to incoming packet buffer. + * out_buf - ptr to output buffer where the suppressed header is copied. + * header_size - ptr to field which holds the phss. + * + * Returns: + * size-The number of bytes copied into the output buffer i.e dynamic fields + * 0 -If PHS rule is NULL.If PHSV field is not set.If the verification fails. + */ +static int phs_compress(struct bcm_phs_rule *phs_rule, + unsigned char *in_buf, + unsigned char *out_buf, + UINT *header_size, + UINT *new_header_size) { unsigned char *old_addr = out_buf; int suppress = 0; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - if(phs_rule == NULL) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nphs_compress(): phs_rule null!"); + + if (phs_rule == NULL) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "\nphs_compress(): phs_rule null!"); *out_buf = ZERO_PHSI; return STATUS_PHS_NOCOMPRESSION; } - - if(phs_rule->u8PHSS <= *new_header_size) - { + if (phs_rule->u8PHSS <= *new_header_size) *header_size = phs_rule->u8PHSS; - } else - { *header_size = *new_header_size; - } - //To copy PHSI + + /* To copy PHSI */ out_buf++; - suppress = verify_suppress_phsf(in_buf,out_buf,phs_rule->u8PHSF, - phs_rule->u8PHSM, phs_rule->u8PHSS, phs_rule->u8PHSV,new_header_size); + suppress = verify_suppress_phsf(in_buf, out_buf, phs_rule->u8PHSF, + phs_rule->u8PHSM, phs_rule->u8PHSS, + phs_rule->u8PHSV, new_header_size); - if(suppress == STATUS_PHS_COMPRESSED) - { + if (suppress == STATUS_PHS_COMPRESSED) { *old_addr = (unsigned char)phs_rule->u8PHSI; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In phs_compress phsi %d",phs_rule->u8PHSI); - } - else - { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "\nCOMP:In phs_compress phsi %d", phs_rule->u8PHSI); + } else { *old_addr = ZERO_PHSI; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In phs_compress PHSV Verification failed"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "\nCOMP:In phs_compress PHSV Verification failed"); } + return suppress; } - -//----------------------------------------------------------------------------- -// Procedure: verify_suppress_phsf -// -// Description: This routine verifies the fields of the packet and if all the -// static fields are equal it adds the phsi of that PHS rule.If any static -// field differs it woun't suppress any field. -// -// Arguments: -// rules_set - ptr to classifier_rules. -// in_buffer - ptr to incoming packet buffer. -// out_buffer - ptr to output buffer where the suppressed header is copied. -// phsf - ptr to phsf. -// phsm - ptr to phsm. -// phss - variable holding phss. -// -// Returns: -// size-The number of bytes copied into the output buffer i.e dynamic fields. -// 0 -Packet has failed the verification. -//----------------------------------------------------------------------------- - -static int verify_suppress_phsf(unsigned char *in_buffer,unsigned char *out_buffer, - unsigned char *phsf,unsigned char *phsm,unsigned int phss, - unsigned int phsv,UINT* new_header_size) +/* + * Procedure: verify_suppress_phsf + * + * Description: This routine verifies the fields of the packet and if all the + * static fields are equal it adds the phsi of that PHS rule.If any static + * field differs it woun't suppress any field. + * + * Arguments: + * rules_set - ptr to classifier_rules. + * in_buffer - ptr to incoming packet buffer. + * out_buffer - ptr to output buffer where the suppressed header is copied. + * phsf - ptr to phsf. + * phsm - ptr to phsm. + * phss - variable holding phss. + * + * Returns: + * size-The number of bytes copied into the output buffer i.e dynamic fields. + * 0 -Packet has failed the verification. + */ +static int verify_suppress_phsf(unsigned char *in_buffer, + unsigned char *out_buffer, + unsigned char *phsf, + unsigned char *phsm, + unsigned int phss, + unsigned int phsv, + UINT *new_header_size) { - unsigned int size=0; - int bit,i=0; + unsigned int size = 0; + int bit, i = 0; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In verify_phsf PHSM - 0x%X",*phsm); - - if(phss>(*new_header_size)) - { - phss=*new_header_size; - } - while(phss > 0) - { - bit = ((*phsm << i)& SUPPRESS); - if(bit == SUPPRESS) - { - - if(*in_buffer != *phsf) - { - if(phsv == VERIFY) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In verify_phsf failed for field %d buf %d phsf %d",phss,*in_buffer,*phsf); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "\nCOMP:In verify_phsf PHSM - 0x%X", *phsm); + + if (phss > (*new_header_size)) + phss = *new_header_size; + + while (phss > 0) { + bit = ((*phsm << i) & SUPPRESS); + if (bit == SUPPRESS) { + if (*in_buffer != *phsf) { + if (phsv == VERIFY) { + BCM_DEBUG_PRINT(Adapter, + DBG_TYPE_OTHERS, + PHS_SEND, + DBG_LVL_ALL, + "\nCOMP:In verify_phsf failed for field %d buf %d phsf %d", + phss, + *in_buffer, + *phsf); return STATUS_PHS_NOCOMPRESSION; } - } - else - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In verify_phsf success for field %d buf %d phsf %d",phss,*in_buffer,*phsf); - } - else - { + } else + BCM_DEBUG_PRINT(Adapter, + DBG_TYPE_OTHERS, + PHS_SEND, + DBG_LVL_ALL, + "\nCOMP:In verify_phsf success for field %d buf %d phsf %d", + phss, + *in_buffer, + *phsf); + } else { *out_buffer = *in_buffer; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In copying_header input %d out %d",*in_buffer,*out_buffer); + BCM_DEBUG_PRINT(Adapter, + DBG_TYPE_OTHERS, + PHS_SEND, + DBG_LVL_ALL, + "\nCOMP:In copying_header input %d out %d", + *in_buffer, + *out_buffer); out_buffer++; size++; } + in_buffer++; phsf++; phss--; i++; - if(i > MAX_NO_BIT) - { - i=0; + + if (i > MAX_NO_BIT) { + i = 0; phsm++; } } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In verify_phsf success"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "\nCOMP:In verify_phsf success"); *new_header_size = size; return STATUS_PHS_COMPRESSED; } - - - - - - diff --git a/drivers/staging/bcm/PHSModule.h b/drivers/staging/bcm/PHSModule.h index b5f21157ac4..d697f9c860c 100644 --- a/drivers/staging/bcm/PHSModule.h +++ b/drivers/staging/bcm/PHSModule.h @@ -5,7 +5,7 @@ int PHSTransmit(struct bcm_mini_adapter *Adapter, struct sk_buff **pPacket, USHORT Vcid, B_UINT16 uiClassifierRuleID, - BOOLEAN bHeaderSuppressionEnabled, + bool bHeaderSuppressionEnabled, PUINT PacketLen, UCHAR bEthCSSupport); @@ -22,15 +22,15 @@ void DumpDataPacketHeader(PUCHAR pPkt); void DumpFullPacket(UCHAR *pBuf,UINT nPktLen); -void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension); +void DumpPhsRules(struct bcm_phs_extension *pDeviceExtension); -int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension,struct bcm_mini_adapter *Adapter); +int phs_init(struct bcm_phs_extension *pPhsdeviceExtension,struct bcm_mini_adapter *Adapter); -int PhsCleanup(PPHS_DEVICE_EXTENSION pPHSDeviceExt); +int PhsCleanup(struct bcm_phs_extension *pPHSDeviceExt); //Utility Functions -ULONG PhsUpdateClassifierRule(void* pvContext,B_UINT16 uiVcid,B_UINT16 uiClsId,S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI ); +ULONG PhsUpdateClassifierRule(void* pvContext,B_UINT16 uiVcid,B_UINT16 uiClsId, struct bcm_phs_rule *psPhsRule,B_UINT8 u8AssociatedPHSI ); ULONG PhsDeletePHSRule(void* pvContext,B_UINT16 uiVcid,B_UINT8 u8PHSI); @@ -39,12 +39,12 @@ ULONG PhsDeleteClassifierRule(void* pvContext, B_UINT16 uiVcid ,B_UINT16 uiClsI ULONG PhsDeleteSFRules(void* pvContext,B_UINT16 uiVcid) ; -BOOLEAN ValidatePHSRule(S_PHS_RULE *psPhsRule); +bool ValidatePHSRule(struct bcm_phs_rule *psPhsRule); -UINT GetServiceFlowEntry(S_SERVICEFLOW_TABLE *psServiceFlowTable,B_UINT16 uiVcid,S_SERVICEFLOW_ENTRY **ppstServiceFlowEntry); +UINT GetServiceFlowEntry(struct bcm_phs_table *psServiceFlowTable,B_UINT16 uiVcid, struct bcm_phs_entry **ppstServiceFlowEntry); -void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension); +void DumpPhsRules(struct bcm_phs_extension *pDeviceExtension); #endif diff --git a/drivers/staging/bcm/Protocol.h b/drivers/staging/bcm/Protocol.h index 562d4dd81a7..9818128d932 100644 --- a/drivers/staging/bcm/Protocol.h +++ b/drivers/staging/bcm/Protocol.h @@ -1,98 +1,83 @@ /************************************ -* Protocol.h +* Protocol.h *************************************/ #ifndef __PROTOCOL_H__ #define __PROTOCOL_H__ - -#define IPV4 4 -#define IPV6 6 - +#define IPV4 4 +#define IPV6 6 struct ArpHeader { - struct arphdr arp; - unsigned char ar_sha[ETH_ALEN]; /* sender hardware address */ - unsigned char ar_sip[4]; /* sender IP address */ - unsigned char ar_tha[ETH_ALEN]; /* target hardware address */ - unsigned char ar_tip[4]; /* target IP address */ -}/*__attribute__((packed))*/; - - -struct TransportHeaderT -{ - union - { + struct arphdr arp; + unsigned char ar_sha[ETH_ALEN]; /* sender hardware address */ + unsigned char ar_sip[4]; /* sender IP address */ + unsigned char ar_tha[ETH_ALEN]; /* target hardware address */ + unsigned char ar_tip[4]; /* target IP address */ +}; + +struct bcm_transport_header { + union { struct udphdr uhdr; struct tcphdr thdr; }; -} __attribute__((packed)); -typedef struct TransportHeaderT xporthdr; - +} __packed; -typedef enum _E_NWPKT_IPFRAME_TYPE -{ +enum bcm_ip_frame_type { eNonIPPacket, eIPv4Packet, eIPv6Packet -}E_NWPKT_IPFRAME_TYPE; +}; -typedef enum _E_NWPKT_ETHFRAME_TYPE -{ +enum bcm_eth_frame_type { eEthUnsupportedFrame, eEth802LLCFrame, eEth802LLCSNAPFrame, eEth802QVLANFrame, eEthOtherFrame -} E_NWPKT_ETHFRAME_TYPE; - -typedef struct _S_ETHCS_PKT_INFO -{ - E_NWPKT_IPFRAME_TYPE eNwpktIPFrameType; - E_NWPKT_ETHFRAME_TYPE eNwpktEthFrameType; - USHORT usEtherType; - UCHAR ucDSAP; -}S_ETHCS_PKT_INFO,*PS_ETHCS_PKT_INFO; - -typedef struct _ETH_CS_802_Q_FRAME -{ +}; + +struct bcm_eth_packet_info { + enum bcm_ip_frame_type eNwpktIPFrameType; + enum bcm_eth_frame_type eNwpktEthFrameType; + unsigned short usEtherType; + unsigned char ucDSAP; +}; + +struct bcm_eth_q_frame { struct bcm_eth_header EThHdr; - USHORT UserPriority:3; - USHORT CFI:1; - USHORT VLANID:12; - USHORT EthType; -} __attribute__((packed)) ETH_CS_802_Q_FRAME; - -typedef struct _ETH_CS_802_LLC_FRAME -{ + unsigned short UserPriority:3; + unsigned short CFI:1; + unsigned short VLANID:12; + unsigned short EthType; +} __packed; + +struct bcm_eth_llc_frame { struct bcm_eth_header EThHdr; unsigned char DSAP; unsigned char SSAP; unsigned char Control; -}__attribute__((packed)) ETH_CS_802_LLC_FRAME; +} __packed; -typedef struct _ETH_CS_802_LLC_SNAP_FRAME -{ +struct bcm_eth_llc_snap_frame { struct bcm_eth_header EThHdr; unsigned char DSAP; unsigned char SSAP; unsigned char Control; unsigned char OUI[3]; unsigned short usEtherType; -} __attribute__((packed)) ETH_CS_802_LLC_SNAP_FRAME; +} __packed; -typedef struct _ETH_CS_ETH2_FRAME -{ +struct bcm_ethernet2_frame { struct bcm_eth_header EThHdr; -} __attribute__((packed)) ETH_CS_ETH2_FRAME; +} __packed; #define ETHERNET_FRAMETYPE_IPV4 ntohs(0x0800) -#define ETHERNET_FRAMETYPE_IPV6 ntohs(0x86dd) -#define ETHERNET_FRAMETYPE_802QVLAN ntohs(0x8100) +#define ETHERNET_FRAMETYPE_IPV6 ntohs(0x86dd) +#define ETHERNET_FRAMETYPE_802QVLAN ntohs(0x8100) -//Per SF CS Specification Encodings -typedef enum _E_SERVICEFLOW_CS_SPEC_ -{ - eCSSpecUnspecified =0, +/* Per SF CS Specification Encodings */ +enum bcm_spec_encoding { + eCSSpecUnspecified = 0, eCSPacketIPV4, eCSPacketIPV6, eCS802_3PacketEthernet, @@ -102,50 +87,42 @@ typedef enum _E_SERVICEFLOW_CS_SPEC_ eCSPacketIPV4Over802_1QVLAN, eCSPacketIPV6Over802_1QVLAN, eCSPacketUnsupported -}E_SERVICEFLOW_CS_SPEC; - - -#define IP6_HEADER_LEN 40 - -#define IP_VERSION(byte) (((byte&0xF0)>>4)) - +}; +#define IP6_HEADER_LEN 40 +#define IP_VERSION(byte) (((byte&0xF0)>>4)) #define MAC_ADDRESS_SIZE 6 -#define ETH_AND_IP_HEADER_LEN 14 + 20 -#define L4_SRC_PORT_LEN 2 -#define L4_DEST_PORT_LEN 2 - - - -#define CTRL_PKT_LEN 8 + ETH_AND_IP_HEADER_LEN - -#define ETH_ARP_FRAME 0x806 -#define ETH_IPV4_FRAME 0x800 -#define ETH_IPV6_FRAME 0x86DD -#define UDP 0x11 -#define TCP 0x06 - -#define ARP_OP_REQUEST 0x01 -#define ARP_OP_REPLY 0x02 -#define ARP_PKT_SIZE 60 - -// This is the format for the TCP packet header -typedef struct _TCP_HEADER -{ - USHORT usSrcPort; - USHORT usDestPort; - ULONG ulSeqNumber; - ULONG ulAckNumber; - UCHAR HeaderLength; - UCHAR ucFlags; - USHORT usWindowsSize; - USHORT usChkSum; - USHORT usUrgetPtr; -} TCP_HEADER,*PTCP_HEADER; -#define TCP_HEADER_LEN sizeof(TCP_HEADER) -#define TCP_ACK 0x10 //Bit 4 in tcpflags field. +#define ETH_AND_IP_HEADER_LEN (14 + 20) +#define L4_SRC_PORT_LEN 2 +#define L4_DEST_PORT_LEN 2 +#define CTRL_PKT_LEN (8 + ETH_AND_IP_HEADER_LEN) + +#define ETH_ARP_FRAME 0x806 +#define ETH_IPV4_FRAME 0x800 +#define ETH_IPV6_FRAME 0x86DD +#define UDP 0x11 +#define TCP 0x06 + +#define ARP_OP_REQUEST 0x01 +#define ARP_OP_REPLY 0x02 +#define ARP_PKT_SIZE 60 + +/* This is the format for the TCP packet header */ +struct bcm_tcp_header { + unsigned short usSrcPort; + unsigned short usDestPort; + unsigned long ulSeqNumber; + unsigned long ulAckNumber; + unsigned char HeaderLength; + unsigned char ucFlags; + unsigned short usWindowsSize; + unsigned short usChkSum; + unsigned short usUrgetPtr; +}; + +#define TCP_HEADER_LEN sizeof(struct bcm_tcp_header) +#define TCP_ACK 0x10 /* Bit 4 in tcpflags field. */ #define GET_TCP_HEADER_LEN(byte) ((byte&0xF0)>>4) - -#endif //__PROTOCOL_H__ +#endif /* __PROTOCOL_H__ */ diff --git a/drivers/staging/bcm/Prototypes.h b/drivers/staging/bcm/Prototypes.h index 3ec8f800a5b..fb53a00591e 100644 --- a/drivers/staging/bcm/Prototypes.h +++ b/drivers/staging/bcm/Prototypes.h @@ -33,9 +33,9 @@ INT SearchSfid(struct bcm_mini_adapter *Adapter,UINT uiSfid); USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter,struct sk_buff* skb); -BOOLEAN MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort); -BOOLEAN MatchDestPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort); -BOOLEAN MatchProtocol(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucProtocol); +bool MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort); +bool MatchDestPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort); +bool MatchProtocol(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucProtocol); INT SetupNextSend(struct bcm_mini_adapter *Adapter, /**<Logical Adapter*/ @@ -79,17 +79,17 @@ int rdm(struct bcm_mini_adapter *Adapter, UINT uiAddress, PCHAR pucBuff, size_t int wrm(struct bcm_mini_adapter *Adapter, UINT uiAddress, PCHAR pucBuff, size_t size); -int wrmalt (struct bcm_mini_adapter *Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize); +int wrmalt (struct bcm_mini_adapter *Adapter, UINT uiAddress, unsigned int *pucBuff, size_t sSize); -int rdmalt (struct bcm_mini_adapter *Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize); +int rdmalt (struct bcm_mini_adapter *Adapter, UINT uiAddress, unsigned int *pucBuff, size_t sSize); int get_dsx_sf_data_to_application(struct bcm_mini_adapter *Adapter, UINT uiSFId, void __user * user_buffer); void SendIdleModeResponse(struct bcm_mini_adapter *Adapter); -int ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, S_MIBS_HOST_STATS_MIBS *buf); -void GetDroppedAppCntrlPktMibs(S_MIBS_HOST_STATS_MIBS *ioBuffer, struct bcm_tarang_data *pTarang); +int ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, struct bcm_host_stats_mibs *buf); +void GetDroppedAppCntrlPktMibs(struct bcm_host_stats_mibs *ioBuffer, struct bcm_tarang_data *pTarang); void beceem_parse_target_struct(struct bcm_mini_adapter *Adapter); int bcm_ioctl_fw_download(struct bcm_mini_adapter *Adapter, struct bcm_firmware_info *psFwInfo); @@ -111,7 +111,7 @@ void update_per_cid_rx (struct bcm_mini_adapter *Adapter); void update_per_sf_desc_cnts( struct bcm_mini_adapter *Adapter); -void ClearTargetDSXBuffer(struct bcm_mini_adapter *Adapter,B_UINT16 TID,BOOLEAN bFreeAll); +void ClearTargetDSXBuffer(struct bcm_mini_adapter *Adapter,B_UINT16 TID,bool bFreeAll); void flush_queue(struct bcm_mini_adapter *Adapter, UINT iQIndex); @@ -138,7 +138,7 @@ INT BeceemEEPROMBulkWrite( PUCHAR pBuffer, UINT uiOffset, UINT uiNumBytes, - BOOLEAN bVerify); + bool bVerify); INT ReadBeceemEEPROM(struct bcm_mini_adapter *Adapter,UINT dwAddress, UINT *pdwData); @@ -155,20 +155,20 @@ INT BeceemNVMWrite( PUINT pBuffer, UINT uiOffset, UINT uiNumBytes, - BOOLEAN bVerify); + bool bVerify); INT BcmInitNVM(struct bcm_mini_adapter *Adapter); INT BcmUpdateSectorSize(struct bcm_mini_adapter *Adapter,UINT uiSectorSize); -BOOLEAN IsSectionExistInFlash(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL section); +bool IsSectionExistInFlash(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val section); -INT BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, PFLASH2X_BITMAP psFlash2xBitMap); +INT BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, struct bcm_flash2x_bitmap *psFlash2xBitMap); INT BcmFlash2xBulkWrite( struct bcm_mini_adapter *Adapter, PUINT pBuffer, - FLASH2X_SECTION_VAL eFlashSectionVal, + enum bcm_flash2x_section_val eFlashSectionVal, UINT uiOffset, UINT uiNumBytes, UINT bVerify); @@ -176,35 +176,35 @@ INT BcmFlash2xBulkWrite( INT BcmFlash2xBulkRead( struct bcm_mini_adapter *Adapter, PUINT pBuffer, - FLASH2X_SECTION_VAL eFlashSectionVal, + enum bcm_flash2x_section_val eFlashSectionVal, UINT uiOffsetWithinSectionVal, UINT uiNumBytes); -INT BcmGetSectionValStartOffset(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlashSectionVal); +INT BcmGetSectionValStartOffset(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlashSectionVal); -INT BcmSetActiveSection(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlash2xSectVal); +INT BcmSetActiveSection(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectVal); INT BcmAllocFlashCSStructure(struct bcm_mini_adapter *psAdapter); INT BcmDeAllocFlashCSStructure(struct bcm_mini_adapter *psAdapter); -INT BcmCopyISO(struct bcm_mini_adapter *Adapter, FLASH2X_COPY_SECTION sCopySectStrut); -INT BcmFlash2xCorruptSig(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal); -INT BcmFlash2xWriteSig(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlashSectionVal); -INT validateFlash2xReadWrite(struct bcm_mini_adapter *Adapter, PFLASH2X_READWRITE psFlash2xReadWrite); +INT BcmCopyISO(struct bcm_mini_adapter *Adapter, struct bcm_flash2x_copy_section sCopySectStrut); +INT BcmFlash2xCorruptSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectionVal); +INT BcmFlash2xWriteSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlashSectionVal); +INT validateFlash2xReadWrite(struct bcm_mini_adapter *Adapter, struct bcm_flash2x_readwrite *psFlash2xReadWrite); INT IsFlash2x(struct bcm_mini_adapter *Adapter); INT BcmCopySection(struct bcm_mini_adapter *Adapter, - FLASH2X_SECTION_VAL SrcSection, - FLASH2X_SECTION_VAL DstSection, + enum bcm_flash2x_section_val SrcSection, + enum bcm_flash2x_section_val DstSection, UINT offset, UINT numOfBytes); -BOOLEAN IsNonCDLessDevice(struct bcm_mini_adapter *Adapter); +bool IsNonCDLessDevice(struct bcm_mini_adapter *Adapter); VOID OverrideServiceFlowParams(struct bcm_mini_adapter *Adapter,PUINT puiBuffer); -int wrmaltWithLock (struct bcm_mini_adapter *Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize); -int rdmaltWithLock (struct bcm_mini_adapter *Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize); +int wrmaltWithLock (struct bcm_mini_adapter *Adapter, UINT uiAddress, unsigned int *pucBuff, size_t sSize); +int rdmaltWithLock (struct bcm_mini_adapter *Adapter, UINT uiAddress, unsigned int *pucBuff, size_t sSize); int wrmWithLock(struct bcm_mini_adapter *Adapter, UINT uiAddress, PCHAR pucBuff, size_t size); INT buffDnldVerify(struct bcm_mini_adapter *Adapter, unsigned char *mappedbuffer, unsigned int u32FirmwareLength, @@ -212,7 +212,7 @@ INT buffDnldVerify(struct bcm_mini_adapter *Adapter, unsigned char *mappedbuffer VOID putUsbSuspend(struct work_struct *work); -BOOLEAN IsReqGpioIsLedInNVM(struct bcm_mini_adapter *Adapter, UINT gpios); +bool IsReqGpioIsLedInNVM(struct bcm_mini_adapter *Adapter, UINT gpios); #endif diff --git a/drivers/staging/bcm/Qos.c b/drivers/staging/bcm/Qos.c index 1b857bd887f..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,PS_ETHCS_PKT_INFO pstEthCsPktInfo); -static BOOLEAN EThCSClassifyPkt(struct bcm_mini_adapter *Adapter,struct sk_buff* skb,PS_ETHCS_PKT_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); @@ -20,30 +27,27 @@ static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex); * matches with that of Queue. * * Parameters - pstClassifierRule: Pointer to the packet info structure. -* - ulSrcIP : Source IP address from the packet. +* - ulSrcIP : Source IP address from the packet. * * Returns - TRUE(If address matches) else FAIL . *********************************************************************/ -BOOLEAN MatchSrcIpAddress(struct bcm_classifier_rule *pstClassifierRule,ULONG ulSrcIP) +static bool MatchSrcIpAddress(struct bcm_classifier_rule *pstClassifierRule, ULONG ulSrcIP) { - UCHAR ucLoopIndex=0; - - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - - ulSrcIP=ntohl(ulSrcIP); - if(0 == pstClassifierRule->ucIPSourceAddressLength) - return TRUE; - 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; + UCHAR ucLoopIndex = 0; + + struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); + + ulSrcIP = ntohl(ulSrcIP); + if (0 == pstClassifierRule->ucIPSourceAddressLength) + return TRUE; + 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; } @@ -54,30 +58,27 @@ BOOLEAN MatchSrcIpAddress(struct bcm_classifier_rule *pstClassifierRule,ULONG ul * matches with that of Queue. * * Parameters - pstClassifierRule: Pointer to the packet info structure. -* - ulDestIP : Destination IP address from the packet. +* - ulDestIP : Destination IP address from the packet. * * Returns - TRUE(If address matches) else FAIL . *********************************************************************/ -BOOLEAN MatchDestIpAddress(struct bcm_classifier_rule *pstClassifierRule,ULONG ulDestIP) +static bool MatchDestIpAddress(struct bcm_classifier_rule *pstClassifierRule, ULONG ulDestIP) { - UCHAR ucLoopIndex=0; + UCHAR ucLoopIndex = 0; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - ulDestIP=ntohl(ulDestIP); - if(0 == pstClassifierRule->ucIPDestinationAddressLength) - 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++) - { - 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; + ulDestIP = ntohl(ulDestIP); + if (0 == pstClassifierRule->ucIPDestinationAddressLength) + 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++) { + 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; } @@ -87,23 +88,22 @@ BOOLEAN MatchDestIpAddress(struct bcm_classifier_rule *pstClassifierRule,ULONG u * Description - Checks the TOS from the packet matches with that of queue. * * Parameters - pstClassifierRule : Pointer to the packet info structure. -* - ucTypeOfService: TOS from the packet. +* - ucTypeOfService: TOS from the packet. * * Returns - TRUE(If address matches) else FAIL. **************************************************************************/ -BOOLEAN MatchTos(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucTypeOfService) +static bool MatchTos(struct bcm_classifier_rule *pstClassifierRule, UCHAR ucTypeOfService) { struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - if( 3 != pstClassifierRule->ucIPTypeOfServiceLength ) - 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; + if (3 != pstClassifierRule->ucIPTypeOfServiceLength) + 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; } @@ -113,26 +113,23 @@ BOOLEAN MatchTos(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucTypeOfSer * Description - Checks the protocol from the packet matches with that of queue. * * Parameters - pstClassifierRule: Pointer to the packet info structure. -* - ucProtocol : Protocol from the packet. +* - ucProtocol : Protocol from the packet. * * Returns - TRUE(If address matches) else FAIL. ****************************************************************************/ -BOOLEAN MatchProtocol(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucProtocol) +bool MatchProtocol(struct bcm_classifier_rule *pstClassifierRule, UCHAR ucProtocol) { - UCHAR ucLoopIndex=0; + UCHAR ucLoopIndex = 0; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - if(0 == pstClassifierRule->ucProtocolLength) - return TRUE; - 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; + if (0 == pstClassifierRule->ucProtocolLength) + return TRUE; + 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; } @@ -142,29 +139,26 @@ BOOLEAN MatchProtocol(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucProt * Description - Checks, Source port from the packet matches with that of queue. * * Parameters - pstClassifierRule: Pointer to the packet info structure. -* - ushSrcPort : Source port from the packet. +* - ushSrcPort : Source port from the packet. * * Returns - TRUE(If address matches) else FAIL. ***************************************************************************/ -BOOLEAN MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort) +bool MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule, USHORT ushSrcPort) { - UCHAR ucLoopIndex=0; + UCHAR ucLoopIndex = 0; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - if(0 == pstClassifierRule->ucSrcPortRangeLength) - return TRUE; - 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; + if (0 == pstClassifierRule->ucSrcPortRangeLength) + return TRUE; + 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; } @@ -174,30 +168,27 @@ BOOLEAN MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrc * Description - Checks, Destination port from packet matches with that of queue. * * Parameters - pstClassifierRule: Pointer to the packet info structure. -* - ushDestPort : Destination port from the packet. +* - ushDestPort : Destination port from the packet. * * Returns - TRUE(If address matches) else FAIL. ***************************************************************************/ -BOOLEAN MatchDestPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushDestPort) +bool MatchDestPort(struct bcm_classifier_rule *pstClassifierRule, USHORT ushDestPort) { - UCHAR ucLoopIndex=0; + UCHAR ucLoopIndex = 0; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - if(0 == pstClassifierRule->ucDestPortRangeLength) - return TRUE; - - 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; + if (0 == pstClassifierRule->ucDestPortRangeLength) + return TRUE; + + 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; } /** @ingroup tx_functions @@ -208,96 +199,81 @@ static USHORT IpVersion4(struct bcm_mini_adapter *Adapter, struct iphdr *iphd, struct bcm_classifier_rule *pstClassifierRule) { - xporthdr *xprt_hdr=NULL; - BOOLEAN bClassificationSucceed=FALSE; + struct bcm_transport_header *xprt_hdr = NULL; + bool bClassificationSucceed = false; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "========>"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "========>"); - xprt_hdr=(xporthdr *)((PUCHAR)iphd + sizeof(struct iphdr)); + xprt_hdr = (struct bcm_transport_header *)((PUCHAR)iphd + sizeof(struct iphdr)); do { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Trying to see Direction = %d %d", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Trying to see Direction = %d %d", pstClassifierRule->ucDirection, pstClassifierRule->usVCID_Value); //Checking classifier validity - if(!pstClassifierRule->bUsed || pstClassifierRule->ucDirection == DOWNLINK_DIR) - { - bClassificationSucceed = FALSE; + if (!pstClassifierRule->bUsed || pstClassifierRule->ucDirection == DOWNLINK_DIR) break; - } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "is IPv6 check!"); - if(pstClassifierRule->bIpv6Protocol) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "is IPv6 check!"); + if (pstClassifierRule->bIpv6Protocol) break; //**************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))) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Trying to match Source IP Address"); + if (!MatchSrcIpAddress(pstClassifierRule, iphd->saddr)) break; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Source IP Address Matched"); + 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"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Destination IP Address Matched"); - if(FALSE == (bClassificationSucceed = - MatchTos(pstClassifierRule, iphd->tos))) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "TOS Match failed\n"); + 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"); + 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"); + 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); + 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, "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: + 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; - } while(0); + 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; - } - } + iMatchedSFQueueIndex = SearchSfid(Adapter, pstClassifierRule->ulSFID); + if (iMatchedSFQueueIndex >= NO_OF_QUEUES) + bClassificationSucceed = false; + else if (false == Adapter->PackInfo[iMatchedSFQueueIndex].bActive) + bClassificationSucceed = false; } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "IpVersion4 <=========="); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "IpVersion4 <=========="); return bClassificationSucceed; } @@ -306,9 +282,8 @@ VOID PruneQueueAllSF(struct bcm_mini_adapter *Adapter) { UINT iIndex = 0; - for(iIndex = 0; iIndex < HiPriority; iIndex++) - { - if(!Adapter->PackInfo[iIndex].bValid) + for (iIndex = 0; iIndex < HiPriority; iIndex++) { + if (!Adapter->PackInfo[iIndex].bValid) continue; PruneQueue(Adapter, iIndex); @@ -325,15 +300,15 @@ less than or equal to max queue size for the queue. */ static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex) { - struct sk_buff* PacketToDrop=NULL; + struct sk_buff* PacketToDrop = NULL; struct net_device_stats *netstats; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "=====> Index %d",iIndex); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "=====> Index %d", iIndex); - if(iIndex == HiPriority) + if (iIndex == HiPriority) return; - if(!Adapter || (iIndex < 0) || (iIndex > HiPriority)) + if (!Adapter || (iIndex < 0) || (iIndex > HiPriority)) return; /* To Store the netdevice statistic */ @@ -341,26 +316,25 @@ 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) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "uiCurrentBytesOnHost:%x uiMaxBucketSize :%x", +// 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); PacketToDrop = Adapter->PackInfo[iIndex].FirstTxQueue; - if(PacketToDrop == NULL) + if (PacketToDrop == NULL) break; - if((Adapter->PackInfo[iIndex].uiCurrentPacketsOnHost < SF_MAX_ALLOWED_PACKETS_TO_BACKUP) && + if ((Adapter->PackInfo[iIndex].uiCurrentPacketsOnHost < SF_MAX_ALLOWED_PACKETS_TO_BACKUP) && ((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", + pr_info(PFX "%s: tx queue %d overlimit\n", Adapter->dev->name, iIndex); netstats->tx_dropped++; @@ -378,7 +352,7 @@ static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex) } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "Dropped Bytes:%x Dropped Packets:%x", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "Dropped Bytes:%x Dropped Packets:%x", Adapter->PackInfo[iIndex].uiDroppedCountBytes, Adapter->PackInfo[iIndex].uiDroppedCountPackets); @@ -387,34 +361,30 @@ static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex) spin_unlock_bh(&Adapter->PackInfo[iIndex].SFQueueLock); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "TotalPacketCount:%x", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "TotalPacketCount:%x", atomic_read(&Adapter->TotalPacketCount)); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "<====="); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "<====="); } VOID flush_all_queues(struct bcm_mini_adapter *Adapter) { INT iQIndex; UINT uiTotalPacketLength; - struct sk_buff* PacketToDrop=NULL; + struct sk_buff* PacketToDrop = NULL; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "=====>"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "=====>"); // 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, @@ -431,7 +401,7 @@ VOID flush_all_queues(struct bcm_mini_adapter *Adapter) Adapter->PackInfo[iQIndex].uiDroppedCountBytes += uiTotalPacketLength; Adapter->PackInfo[iQIndex].uiDroppedCountPackets++; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Dropped Bytes:%x Dropped Packets:%x", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Dropped Bytes:%x Dropped Packets:%x", Adapter->PackInfo[iQIndex].uiDroppedCountBytes, Adapter->PackInfo[iQIndex].uiDroppedCountPackets); atomic_dec(&Adapter->TotalPacketCount); @@ -439,327 +409,287 @@ VOID flush_all_queues(struct bcm_mini_adapter *Adapter) spin_unlock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock); } // up(&Adapter->data_packet_queue_lock); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "<====="); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "<====="); } -USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter,struct sk_buff* skb) +USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb) { - INT uiLoopIndex=0; + INT uiLoopIndex = 0; struct bcm_classifier_rule *pstClassifierRule = NULL; - S_ETHCS_PKT_INFO stEthCsPktInfo; + struct bcm_eth_packet_info stEthCsPktInfo; PVOID pvEThPayload = NULL; - struct iphdr *pIpHeader = NULL; - INT uiSfIndex=0; - USHORT usIndex=Adapter->usBestEffortQueueIndex; - BOOLEAN bFragmentedPkt=FALSE,bClassificationSucceed=FALSE; - USHORT usCurrFragment =0; + struct iphdr *pIpHeader = NULL; + INT uiSfIndex = 0; + USHORT usIndex = Adapter->usBestEffortQueueIndex; + bool bFragmentedPkt = false, bClassificationSucceed = false; + USHORT usCurrFragment = 0; - PTCP_HEADER pTcpHeader; + struct bcm_tcp_header *pTcpHeader; UCHAR IpHeaderLength; UCHAR TcpHeaderLength; pvEThPayload = skb->data; - *((UINT32*) (skb->cb) +SKB_CB_TCPACK_OFFSET ) = 0; - EThCSGetPktInfo(Adapter,pvEThPayload,&stEthCsPktInfo); + *((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(ETH_CS_802_LLC_FRAME); + 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(ETH_CS_802_LLC_SNAP_FRAME); + 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(ETH_CS_802_Q_FRAME); + 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(ETH_CS_ETH2_FRAME); + 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(ETH_CS_ETH2_FRAME); + 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) + 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) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,"It is next Fragmented pkt"); - bClassificationSucceed=TRUE; + pstClassifierRule = GetFragIPClsEntry(Adapter, pIpHeader->id, pIpHeader->saddr); + 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); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "This is the last fragmented Pkt"); + DelFragIPClsEntry(Adapter, pIpHeader->id, pIpHeader->saddr); } } } - for(uiLoopIndex = MAX_CLASSIFIERS - 1; uiLoopIndex >= 0; uiLoopIndex--) - { - if(bClassificationSucceed) + 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) - { - bClassificationSucceed=FALSE; + 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); + 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) - { - bClassificationSucceed=FALSE;//cannot be processed for classification. + if (0 == Adapter->astClassifierTable[uiLoopIndex].ucDirection) { + bClassificationSucceed = false;//cannot be processed for classification. break; // it is a down link connection } pstClassifierRule = &Adapter->astClassifierTable[uiLoopIndex]; - uiSfIndex = SearchSfid(Adapter,pstClassifierRule->ulSFID); + uiSfIndex = SearchSfid(Adapter, pstClassifierRule->ulSFID); if (uiSfIndex >= NO_OF_QUEUES) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Queue Not Valid. SearchSfid for this classifier Failed\n"); break; } - if(Adapter->PackInfo[uiSfIndex].bEthCSSupport) - { + if (Adapter->PackInfo[uiSfIndex].bEthCSSupport) { - 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; + 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; } - 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); + 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) - { - 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; + } 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; } } 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) - { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, " ClassifyPacket : Packet is Not an IP Packet \n"); - bClassificationSucceed = FALSE; + 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; } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Dump IP Header : \n"); - DumpFullPacket((PUCHAR)pIpHeader,20); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Dump IP Header :\n"); + DumpFullPacket((PUCHAR)pIpHeader, 20); - if(stEthCsPktInfo.eNwpktIPFrameType == eIPv4Packet) - bClassificationSucceed = IpVersion4(Adapter,pIpHeader,pstClassifierRule); - else if(stEthCsPktInfo.eNwpktIPFrameType == eIPv6Packet) - bClassificationSucceed = IpVersion6(Adapter,pIpHeader,pstClassifierRule); + if (stEthCsPktInfo.eNwpktIPFrameType == eIPv4Packet) + bClassificationSucceed = IpVersion4(Adapter, pIpHeader, pstClassifierRule); + else if (stEthCsPktInfo.eNwpktIPFrameType == eIPv6Packet) + bClassificationSucceed = IpVersion6(Adapter, pIpHeader, pstClassifierRule); } - }while(0); + } while (0); } - 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); + 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 = (PTCP_HEADER)(((PUCHAR)pIpHeader)+(IpHeaderLength*4)); + pTcpHeader = (struct bcm_tcp_header *)(((PUCHAR)pIpHeader)+(IpHeaderLength*4)); TcpHeaderLength = GET_TCP_HEADER_LEN(pTcpHeader->HeaderLength); - if((pTcpHeader->ucFlags & TCP_ACK) && + if ((pTcpHeader->ucFlags & TCP_ACK) && (ntohs(pIpHeader->tot_len) == (IpHeaderLength*4)+(TcpHeaderLength*4))) - { - *((UINT32*) (skb->cb) +SKB_CB_TCPACK_OFFSET ) = TCP_ACK; - } + *((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); + 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; stFragPktInfo.ulSrcIpAddress = pIpHeader->saddr; stFragPktInfo.usIpIdentification = pIpHeader->id; stFragPktInfo.pstMatchedClassifierEntry = pstClassifierRule; - stFragPktInfo.bOutOfOrderFragment = FALSE; - AddFragIPClsEntry(Adapter,&stFragPktInfo); + stFragPktInfo.bOutOfOrderFragment = false; + AddFragIPClsEntry(Adapter, &stFragPktInfo); } } - if(bClassificationSucceed) + if (bClassificationSucceed) return usIndex; else return INVALID_QUEUE_INDEX; } -static BOOLEAN EthCSMatchSrcMACAddress(struct bcm_classifier_rule *pstClassifierRule,PUCHAR Mac) +static bool EthCSMatchSrcMACAddress(struct bcm_classifier_rule *pstClassifierRule, PUCHAR Mac) { - UINT i=0; + UINT i = 0; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - if(pstClassifierRule->ucEthCSSrcMACLen==0) + 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, "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])!= + 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])) - return FALSE; + return false; } return TRUE; } -static BOOLEAN EthCSMatchDestMACAddress(struct bcm_classifier_rule *pstClassifierRule,PUCHAR Mac) +static bool EthCSMatchDestMACAddress(struct bcm_classifier_rule *pstClassifierRule, PUCHAR Mac) { - UINT i=0; + UINT i = 0; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - if(pstClassifierRule->ucEthCSDestMACLen==0) + 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, "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])!= + 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])) - return FALSE; + return false; } return TRUE; } -static BOOLEAN EthCSMatchEThTypeSAP(struct bcm_classifier_rule *pstClassifierRule,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo) +static bool EthCSMatchEThTypeSAP(struct bcm_classifier_rule *pstClassifierRule, struct sk_buff* skb, struct bcm_eth_packet_info *pstEthCsPktInfo) { struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - if((pstClassifierRule->ucEtherTypeLen==0)|| + if ((pstClassifierRule->ucEtherTypeLen == 0) || (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) + if (memcmp(&pstEthCsPktInfo->usEtherType, &pstClassifierRule->au8EthCSEtherType[1], 2) == 0) return TRUE; else - return FALSE; + return false; } - if(pstClassifierRule->au8EthCSEtherType[0] == 2) - { - if(eEth802LLCFrame != pstEthCsPktInfo->eNwpktEthFrameType) - return FALSE; + 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]); - if(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 - return FALSE; + return false; } - return FALSE; + return false; } -static BOOLEAN EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo) +static bool EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule, struct sk_buff* skb, struct bcm_eth_packet_info *pstEthCsPktInfo) { - BOOLEAN bClassificationSucceed = FALSE; + bool bClassificationSucceed = false; USHORT usVLANID; 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(pstEthCsPktInfo->eNwpktEthFrameType!=eEth802QVLANFrame) - return FALSE; + if (pstClassifierRule->usValidityBitMap & (1<<PKT_CLASSIFICATION_USER_PRIORITY_VALID)) { + if (pstEthCsPktInfo->eNwpktEthFrameType != eEth802QVLANFrame) + return false; uPriority = (ntohs(*(USHORT *)(skb->data + sizeof(struct bcm_eth_header))) & 0xF000) >> 13; - if((uPriority >= pstClassifierRule->usUserPriority[0]) && (uPriority <= pstClassifierRule->usUserPriority[1])) + if ((uPriority >= pstClassifierRule->usUserPriority[0]) && (uPriority <= pstClassifierRule->usUserPriority[1])) bClassificationSucceed = TRUE; - if(!bClassificationSucceed) - return FALSE; + if (!bClassificationSucceed) + return false; } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ETH CS 802.1 D User Priority Rule Matched\n"); - bClassificationSucceed = FALSE; + bClassificationSucceed = false; - if(pstClassifierRule->usValidityBitMap & (1<<PKT_CLASSIFICATION_VLANID_VALID)) - { - if(pstEthCsPktInfo->eNwpktEthFrameType!=eEth802QVLANFrame) - return FALSE; + 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)) + if (usVLANID == ((pstClassifierRule->usVLANID & 0xFFF0) >> 4)) bClassificationSucceed = TRUE; - if(!bClassificationSucceed) - return FALSE; + if (!bClassificationSucceed) + return false; } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ETH CS 802.1 Q VLAN ID Rule Matched\n"); @@ -768,87 +698,79 @@ static BOOLEAN EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule } -static BOOLEAN EThCSClassifyPkt(struct bcm_mini_adapter *Adapter,struct sk_buff* skb, - PS_ETHCS_PKT_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) { - BOOLEAN bClassificationSucceed = FALSE; - bClassificationSucceed = EthCSMatchSrcMACAddress(pstClassifierRule,((struct bcm_eth_header *)(skb->data))->au8SourceAddress); - if(!bClassificationSucceed) - return FALSE; + bool bClassificationSucceed = false; + bClassificationSucceed = EthCSMatchSrcMACAddress(pstClassifierRule, ((struct bcm_eth_header *)(skb->data))->au8SourceAddress); + if (!bClassificationSucceed) + return false; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ETH CS SrcMAC Matched\n"); - bClassificationSucceed = EthCSMatchDestMACAddress(pstClassifierRule,((struct bcm_eth_header *)(skb->data))->au8DestinationAddress); - if(!bClassificationSucceed) - return FALSE; + bClassificationSucceed = EthCSMatchDestMACAddress(pstClassifierRule, ((struct bcm_eth_header *)(skb->data))->au8DestinationAddress); + if (!bClassificationSucceed) + return false; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ETH CS DestMAC Matched\n"); //classify on ETHType/802.2SAP TLV - bClassificationSucceed = EthCSMatchEThTypeSAP(pstClassifierRule,skb,pstEthCsPktInfo); - if(!bClassificationSucceed) - return FALSE; + bClassificationSucceed = EthCSMatchEThTypeSAP(pstClassifierRule, skb, pstEthCsPktInfo); + if (!bClassificationSucceed) + return false; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ETH CS EthType/802.2SAP Matched\n"); //classify on 802.1VLAN Header Parameters - bClassificationSucceed = EthCSMatchVLANRules(pstClassifierRule,skb,pstEthCsPktInfo); - if(!bClassificationSucceed) - return FALSE; + bClassificationSucceed = EthCSMatchVLANRules(pstClassifierRule, skb, pstEthCsPktInfo); + if (!bClassificationSucceed) + return false; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ETH CS 802.1 VLAN Rules Matched\n"); return bClassificationSucceed; } -static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter,PVOID pvEthPayload, - PS_ETHCS_PKT_INFO pstEthCsPktInfo) +static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter, PVOID pvEthPayload, + struct bcm_eth_packet_info *pstEthCsPktInfo) { 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) - { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCSGetPktInfo : ETH2 Frame \n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCSGetPktInfo : Eth Hdr Type : %X\n", u16Etype); + 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 = ((ETH_CS_802_Q_FRAME*)pvEthPayload)->EthType; + 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"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "802.2 LLC Frame\n"); pstEthCsPktInfo->eNwpktEthFrameType = eEth802LLCFrame; - pstEthCsPktInfo->ucDSAP = ((ETH_CS_802_LLC_FRAME*)pvEthPayload)->DSAP; - if(pstEthCsPktInfo->ucDSAP == 0xAA && ((ETH_CS_802_LLC_FRAME*)pvEthPayload)->SSAP == 0xAA) - { + pstEthCsPktInfo->ucDSAP = ((struct bcm_eth_llc_frame *)pvEthPayload)->DSAP; + if (pstEthCsPktInfo->ucDSAP == 0xAA && ((struct bcm_eth_llc_frame *)pvEthPayload)->SSAP == 0xAA) { //SNAP Frame pstEthCsPktInfo->eNwpktEthFrameType = eEth802LLCSNAPFrame; - u16Etype = ((ETH_CS_802_LLC_SNAP_FRAME*)pvEthPayload)->usEtherType; + u16Etype = ((struct bcm_eth_llc_snap_frame *)pvEthPayload)->usEtherType; } } - if(u16Etype == ETHERNET_FRAMETYPE_IPV4) + if (u16Etype == ETHERNET_FRAMETYPE_IPV4) pstEthCsPktInfo->eNwpktIPFrameType = eIPv4Packet; - else if(u16Etype == ETHERNET_FRAMETYPE_IPV6) + else if (u16Etype == ETHERNET_FRAMETYPE_IPV6) pstEthCsPktInfo->eNwpktIPFrameType = eIPv6Packet; else pstEthCsPktInfo->eNwpktIPFrameType = eNonIPPacket; pstEthCsPktInfo->usEtherType = ((struct bcm_eth_header *)pvEthPayload)->u16Etype; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCsPktInfo->eNwpktIPFrameType : %x\n",pstEthCsPktInfo->eNwpktIPFrameType); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCsPktInfo->eNwpktEthFrameType : %x\n",pstEthCsPktInfo->eNwpktEthFrameType); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCsPktInfo->usEtherType : %x\n",pstEthCsPktInfo->usEtherType); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCsPktInfo->eNwpktIPFrameType : %x\n", pstEthCsPktInfo->eNwpktIPFrameType); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCsPktInfo->eNwpktEthFrameType : %x\n", pstEthCsPktInfo->eNwpktEthFrameType); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCsPktInfo->usEtherType : %x\n", pstEthCsPktInfo->usEtherType); } diff --git a/drivers/staging/bcm/Transmit.c b/drivers/staging/bcm/Transmit.c index 27e8c890777..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; } @@ -84,7 +86,7 @@ int SendControlPacket(struct bcm_mini_adapter *Adapter, char *pControlPacket) int SetupNextSend(struct bcm_mini_adapter *Adapter, struct sk_buff *Packet, USHORT Vcid) { int status = 0; - BOOLEAN bHeaderSupressionEnabled = FALSE; + bool bHeaderSupressionEnabled = false; B_UINT16 uiClassifierRuleID; u16 QueueIndex = skb_get_queue_mapping(Packet); struct bcm_leader Leader = {0}; @@ -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; } @@ -204,8 +207,8 @@ int tx_pkt_handler(struct bcm_mini_adapter *Adapter /**< pointer to adapter obje /* Check end point for halt/stall. */ if (Adapter->bEndPointHalted == TRUE) { Bcm_clear_halt_of_endpoints(Adapter); - Adapter->bEndPointHalted = FALSE; - StartInterruptUrb((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter)); + Adapter->bEndPointHalted = false; + StartInterruptUrb((struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter)); } if (Adapter->LinkUpStatus && !Adapter->IdleMode) { @@ -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 a985abf194f..90b3b25dd60 100644 --- a/drivers/staging/bcm/Typedefs.h +++ b/drivers/staging/bcm/Typedefs.h @@ -6,10 +6,10 @@ #define STATUS_SUCCESS 0 #define STATUS_FAILURE -1 -#define FALSE 0 + #define TRUE 1 -typedef char BOOLEAN; + typedef char CHAR; typedef int INT; typedef short SHORT; @@ -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 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 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/Version.h b/drivers/staging/bcm/Version.h deleted file mode 100644 index a07b956b9ff..00000000000 --- a/drivers/staging/bcm/Version.h +++ /dev/null @@ -1,35 +0,0 @@ - -/*Copyright (c) 2005 Beceem Communications Inc. - -Module Name: - - Version.h - -Abstract: - - ---*/ - -#ifndef VERSION_H -#define VERSION_H - - -#define VER_FILETYPE VFT_DRV -#define VER_FILESUBTYPE VFT2_DRV_NETWORK - - -#define VER_FILEVERSION 5.2.45 -#define VER_FILEVERSION_STR "5.2.45" - -#undef VER_PRODUCTVERSION -#define VER_PRODUCTVERSION VER_FILEVERSION - -#undef VER_PRODUCTVERSION_STR -#define VER_PRODUCTVERSION_STR VER_FILEVERSION_STR - - - - -//#include "common.ver" - -#endif //VERSION_H diff --git a/drivers/staging/bcm/cntrl_SignalingInterface.h b/drivers/staging/bcm/cntrl_SignalingInterface.h index 990e809e968..8683c2d4276 100644 --- a/drivers/staging/bcm/cntrl_SignalingInterface.h +++ b/drivers/staging/bcm/cntrl_SignalingInterface.h @@ -36,91 +36,91 @@ struct bcm_packet_class_rules { /* 16bit UserPriority Of The Service Flow */ - B_UINT16 u16UserPriority; + u16 u16UserPriority; /* 16bit VLANID Of The Service Flow */ - B_UINT16 u16VLANID; + u16 u16VLANID; /* 16bit Packet Classification RuleIndex Of The Service Flow */ - B_UINT16 u16PacketClassificationRuleIndex; + u16 u16PacketClassificationRuleIndex; /* 8bit Classifier Rule Priority Of The Service Flow */ - B_UINT8 u8ClassifierRulePriority; + u8 u8ClassifierRulePriority; /* Length of IP TypeOfService field */ - B_UINT8 u8IPTypeOfServiceLength; + u8 u8IPTypeOfServiceLength; /* 3bytes IP TypeOfService */ - B_UINT8 u8IPTypeOfService[TYPE_OF_SERVICE_LENGTH]; + u8 u8IPTypeOfService[TYPE_OF_SERVICE_LENGTH]; /* Protocol used in classification of Service Flow */ - B_UINT8 u8Protocol; + u8 u8Protocol; /* Length of IP Masked Source Address */ - B_UINT8 u8IPMaskedSourceAddressLength; + u8 u8IPMaskedSourceAddressLength; /* IP Masked Source Address used in classification for the Service Flow */ - B_UINT8 u8IPMaskedSourceAddress[IP_MASKED_SRC_ADDRESS_LENGTH]; + u8 u8IPMaskedSourceAddress[IP_MASKED_SRC_ADDRESS_LENGTH]; /* Length of IP Destination Address */ - B_UINT8 u8IPDestinationAddressLength; + u8 u8IPDestinationAddressLength; /* IP Destination Address used in classification for the Service Flow */ - B_UINT8 u8IPDestinationAddress[IP_MASKED_DEST_ADDRESS_LENGTH]; + u8 u8IPDestinationAddress[IP_MASKED_DEST_ADDRESS_LENGTH]; /* Length of Protocol Source Port Range */ - B_UINT8 u8ProtocolSourcePortRangeLength; + u8 u8ProtocolSourcePortRangeLength; /* Protocol Source Port Range used in the Service Flow */ - B_UINT8 u8ProtocolSourcePortRange[PROTOCOL_SRC_PORT_RANGE_LENGTH]; + u8 u8ProtocolSourcePortRange[PROTOCOL_SRC_PORT_RANGE_LENGTH]; /* Length of Protocol Dest Port Range */ - B_UINT8 u8ProtocolDestPortRangeLength; + u8 u8ProtocolDestPortRangeLength; /* Protocol Dest Port Range used in the Service Flow */ - B_UINT8 u8ProtocolDestPortRange[PROTOCOL_DEST_PORT_RANGE_LENGTH]; + u8 u8ProtocolDestPortRange[PROTOCOL_DEST_PORT_RANGE_LENGTH]; /* Length of Ethernet Destination MAC Address */ - B_UINT8 u8EthernetDestMacAddressLength; + u8 u8EthernetDestMacAddressLength; /* Ethernet Destination MAC Address used in classification of the Service Flow */ - B_UINT8 u8EthernetDestMacAddress[ETHERNET_DEST_MAC_ADDR_LENGTH]; + u8 u8EthernetDestMacAddress[ETHERNET_DEST_MAC_ADDR_LENGTH]; /* Length of Ethernet Source MAC Address */ - B_UINT8 u8EthernetSourceMACAddressLength; + u8 u8EthernetSourceMACAddressLength; /* Ethernet Source MAC Address used in classification of the Service Flow */ - B_UINT8 u8EthernetSourceMACAddress[ETHERNET_SRC_MAC_ADDR_LENGTH]; + u8 u8EthernetSourceMACAddress[ETHERNET_SRC_MAC_ADDR_LENGTH]; /* Length of Ethertype */ - B_UINT8 u8EthertypeLength; + u8 u8EthertypeLength; /* 3bytes Ethertype Of The Service Flow */ - B_UINT8 u8Ethertype[NUM_ETHERTYPE_BYTES]; + u8 u8Ethertype[NUM_ETHERTYPE_BYTES]; /* 8bit Associated PHSI Of The Service Flow */ - B_UINT8 u8AssociatedPHSI; + u8 u8AssociatedPHSI; /* Length of Vendor Specific Classifier Param length Of The Service Flow */ - B_UINT8 u8VendorSpecificClassifierParamLength; + u8 u8VendorSpecificClassifierParamLength; /* Vendor Specific Classifier Param Of The Service Flow */ - B_UINT8 u8VendorSpecificClassifierParam[VENDOR_CLASSIFIER_PARAM_LENGTH]; + u8 u8VendorSpecificClassifierParam[VENDOR_CLASSIFIER_PARAM_LENGTH]; /* Length Of IPv6 Flow Lable of the Service Flow */ - B_UINT8 u8IPv6FlowLableLength; + u8 u8IPv6FlowLableLength; /* IPv6 Flow Lable Of The Service Flow */ - B_UINT8 u8IPv6FlowLable[NUM_IPV6_FLOWLABLE_BYTES]; + u8 u8IPv6FlowLable[NUM_IPV6_FLOWLABLE_BYTES]; /* Action associated with the classifier rule */ - B_UINT8 u8ClassifierActionRule; - B_UINT16 u16ValidityBitMap; + u8 u8ClassifierActionRule; + u16 u16ValidityBitMap; }; struct bcm_phs_rules { /* 8bit PHS Index Of The Service Flow */ - B_UINT8 u8PHSI; + u8 u8PHSI; /* PHSF Length Of The Service Flow */ - B_UINT8 u8PHSFLength; + u8 u8PHSFLength; /* String of bytes containing header information to be suppressed by the sending CS and reconstructed by the receiving CS */ - B_UINT8 u8PHSF[MAX_PHS_LENGTHS]; + u8 u8PHSF[MAX_PHS_LENGTHS]; /* PHSM Length Of The Service Flow */ - B_UINT8 u8PHSMLength; + u8 u8PHSMLength; /* PHS Mask for the SF */ - B_UINT8 u8PHSM[MAX_PHS_LENGTHS]; + u8 u8PHSM[MAX_PHS_LENGTHS]; /* 8bit Total number of bytes to be suppressed for the Service Flow */ - B_UINT8 u8PHSS; + u8 u8PHSS; /* 8bit Indicates whether or not Packet Header contents need to be verified prior to suppression */ - B_UINT8 u8PHSV; + u8 u8PHSV; /* Vendor Specific PHS param Length Of The Service Flow */ - B_UINT8 u8VendorSpecificPHSParamsLength; + u8 u8VendorSpecificPHSParamsLength; /* Vendor Specific PHS param Of The Service Flow */ - B_UINT8 u8VendorSpecificPHSParams[VENDOR_PHS_PARAM_LENGTH]; - B_UINT8 u8Padding[2]; + u8 u8VendorSpecificPHSParams[VENDOR_PHS_PARAM_LENGTH]; + u8 u8Padding[2]; }; struct bcm_convergence_types { /* 8bit Phs Classfier Action Of The Service Flow */ - B_UINT8 u8ClassfierDSCAction; + u8 u8ClassfierDSCAction; /* 8bit Phs DSC Action Of The Service Flow */ - B_UINT8 u8PhsDSCAction; + u8 u8PhsDSCAction; /* 16bit Padding */ - B_UINT8 u8Padding[2]; + u8 u8Padding[2]; /* Packet classification rules structure */ struct bcm_packet_class_rules cCPacketClassificationRule; /* Payload header suppression rules structure */ @@ -129,118 +129,118 @@ struct bcm_convergence_types { struct bcm_connect_mgr_params { /* 32bitSFID Of The Service Flow */ - B_UINT32 u32SFID; + u32 u32SFID; /* 32bit Maximum Sustained Traffic Rate of the Service Flow */ - B_UINT32 u32MaxSustainedTrafficRate; + u32 u32MaxSustainedTrafficRate; /* 32bit Maximum Traffic Burst allowed for the Service Flow */ - B_UINT32 u32MaxTrafficBurst; + u32 u32MaxTrafficBurst; /* 32bit Minimum Reserved Traffic Rate of the Service Flow */ - B_UINT32 u32MinReservedTrafficRate; + u32 u32MinReservedTrafficRate; /* 32bit Tolerated Jitter of the Service Flow */ - B_UINT32 u32ToleratedJitter; + u32 u32ToleratedJitter; /* 32bit Maximum Latency of the Service Flow */ - B_UINT32 u32MaximumLatency; + u32 u32MaximumLatency; /* 16bitCID Of The Service Flow */ - B_UINT16 u16CID; + u16 u16CID; /* 16bit SAID on which the service flow being set up shall be mapped */ - B_UINT16 u16TargetSAID; + u16 u16TargetSAID; /* 16bit ARQ window size negotiated */ - B_UINT16 u16ARQWindowSize; + u16 u16ARQWindowSize; /* 16bit Total Tx delay incl sending, receiving & processing delays */ - B_UINT16 u16ARQRetryTxTimeOut; + u16 u16ARQRetryTxTimeOut; /* 16bit Total Rx delay incl sending, receiving & processing delays */ - B_UINT16 u16ARQRetryRxTimeOut; + u16 u16ARQRetryRxTimeOut; /* 16bit ARQ block lifetime */ - B_UINT16 u16ARQBlockLifeTime; + u16 u16ARQBlockLifeTime; /* 16bit ARQ Sync loss timeout */ - B_UINT16 u16ARQSyncLossTimeOut; + u16 u16ARQSyncLossTimeOut; /* 16bit ARQ Purge timeout */ - B_UINT16 u16ARQRxPurgeTimeOut; + u16 u16ARQRxPurgeTimeOut; /* TODO::Remove this once we move to a new CORR2 driver * brief Size of an ARQ block */ - B_UINT16 u16ARQBlockSize; + u16 u16ARQBlockSize; /* #endif */ /* 16bit Nominal interval b/w consecutive SDU arrivals at MAC SAP */ - B_UINT16 u16SDUInterArrivalTime; + u16 u16SDUInterArrivalTime; /* 16bit Specifies the time base for rate measurement */ - B_UINT16 u16TimeBase; + u16 u16TimeBase; /* 16bit Interval b/w Successive Grant oppurtunities */ - B_UINT16 u16UnsolicitedGrantInterval; + u16 u16UnsolicitedGrantInterval; /* 16bit Interval b/w Successive Polling grant oppurtunities */ - B_UINT16 u16UnsolicitedPollingInterval; + u16 u16UnsolicitedPollingInterval; /* internal var to get the overhead */ - B_UINT16 u16MacOverhead; + u16 u16MacOverhead; /* MBS contents Identifier */ - B_UINT16 u16MBSContentsID[MBS_CONTENTS_ID_LENGTH]; + u16 u16MBSContentsID[MBS_CONTENTS_ID_LENGTH]; /* MBS contents Identifier length */ - B_UINT8 u8MBSContentsIDLength; + u8 u8MBSContentsIDLength; /* ServiceClassName Length Of The Service Flow */ - B_UINT8 u8ServiceClassNameLength; + u8 u8ServiceClassNameLength; /* 32bytes ServiceClassName Of The Service Flow */ - B_UINT8 u8ServiceClassName[32]; + u8 u8ServiceClassName[32]; /* 8bit Indicates whether or not MBS service is requested for this Serivce Flow */ - B_UINT8 u8MBSService; + u8 u8MBSService; /* 8bit QOS Parameter Set specifies proper application of QoS parameters to Provisioned, Admitted and Active sets */ - B_UINT8 u8QosParamSet; + u8 u8QosParamSet; /* 8bit Traffic Priority Of the Service Flow */ - B_UINT8 u8TrafficPriority; + u8 u8TrafficPriority; /* 8bit Uplink Grant Scheduling Type of The Service Flow */ - B_UINT8 u8ServiceFlowSchedulingType; + u8 u8ServiceFlowSchedulingType; /* 8bit Request transmission Policy of the Service Flow */ - B_UINT8 u8RequesttransmissionPolicy; + u8 u8RequesttransmissionPolicy; /* 8bit Specifies whether SDUs for this Service flow are of FixedLength or Variable length */ - B_UINT8 u8FixedLengthVSVariableLengthSDUIndicator; + u8 u8FixedLengthVSVariableLengthSDUIndicator; /* 8bit Length of the SDU for a fixed length SDU service flow */ - B_UINT8 u8SDUSize; + u8 u8SDUSize; /* 8bit Indicates whether or not ARQ is requested for this connection */ - B_UINT8 u8ARQEnable; + u8 u8ARQEnable; /* < 8bit Indicates whether or not data has tobe delivered in order to higher layer */ - B_UINT8 u8ARQDeliverInOrder; + u8 u8ARQDeliverInOrder; /* 8bit Receiver ARQ ACK processing time */ - B_UINT8 u8RxARQAckProcessingTime; + u8 u8RxARQAckProcessingTime; /* 8bit Convergence Sublayer Specification Of The Service Flow */ - B_UINT8 u8CSSpecification; + u8 u8CSSpecification; /* 8 bit Type of data delivery service */ - B_UINT8 u8TypeOfDataDeliveryService; + u8 u8TypeOfDataDeliveryService; /* 8bit Specifies whether a service flow may generate Paging */ - B_UINT8 u8PagingPreference; + u8 u8PagingPreference; /* 8bit Indicates the MBS Zone through which the connection or virtual connection is valid */ - B_UINT8 u8MBSZoneIdentifierassignment; + u8 u8MBSZoneIdentifierassignment; /* 8bit Specifies whether traffic on SF should generate MOB_TRF_IND to MS in sleep mode */ - B_UINT8 u8TrafficIndicationPreference; + u8 u8TrafficIndicationPreference; /* 8bit Speciifes the length of predefined Global QoS parameter set encoding for this SF */ - B_UINT8 u8GlobalServicesClassNameLength; + u8 u8GlobalServicesClassNameLength; /* 6 byte Speciifes the predefined Global QoS parameter set encoding for this SF */ - B_UINT8 u8GlobalServicesClassName[GLOBAL_SF_CLASSNAME_LENGTH]; + u8 u8GlobalServicesClassName[GLOBAL_SF_CLASSNAME_LENGTH]; /* 8bit Indicates whether or not SN feedback is enabled for the conn */ - B_UINT8 u8SNFeedbackEnabled; + u8 u8SNFeedbackEnabled; /* Indicates the size of the Fragment Sequence Number for the connection */ - B_UINT8 u8FSNSize; + u8 u8FSNSize; /* 8bit Number of CIDs in active BS list */ - B_UINT8 u8CIDAllocation4activeBSsLength; + u8 u8CIDAllocation4activeBSsLength; /* CIDs of BS in the active list */ - B_UINT8 u8CIDAllocation4activeBSs[MAX_NUM_ACTIVE_BS]; + u8 u8CIDAllocation4activeBSs[MAX_NUM_ACTIVE_BS]; /* Specifies if PDU extended subheader should be applied on every PDU on this conn */ - B_UINT8 u8PDUSNExtendedSubheader4HarqReordering; + u8 u8PDUSNExtendedSubheader4HarqReordering; /* 8bit Specifies whether the connection uses HARQ or not */ - B_UINT8 u8HARQServiceFlows; + u8 u8HARQServiceFlows; /* Specifies the length of Authorization token */ - B_UINT8 u8AuthTokenLength; + u8 u8AuthTokenLength; /* Specifies the Authorization token */ - B_UINT8 u8AuthToken[AUTH_TOKEN_LENGTH]; + u8 u8AuthToken[AUTH_TOKEN_LENGTH]; /* specifes Number of HARQ channels used to carry data length */ - B_UINT8 u8HarqChannelMappingLength; + u8 u8HarqChannelMappingLength; /* specifes HARQ channels used to carry data */ - B_UINT8 u8HARQChannelMapping[NUM_HARQ_CHANNELS]; + u8 u8HARQChannelMapping[NUM_HARQ_CHANNELS]; /* 8bit Length of Vendor Specific QoS Params */ - B_UINT8 u8VendorSpecificQoSParamLength; + u8 u8VendorSpecificQoSParamLength; /* 1byte Vendor Specific QoS Param Of The Service Flow */ - B_UINT8 u8VendorSpecificQoSParam[VENDOR_SPECIF_QOS_PARAM]; + u8 u8VendorSpecificQoSParam[VENDOR_SPECIF_QOS_PARAM]; /* indicates total classifiers in the SF */ - B_UINT8 u8TotalClassifiers; /* < Total number of valid classifiers */ - B_UINT8 bValid; /* < Validity flag */ - B_UINT8 u8Padding; /* < Padding byte */ + u8 u8TotalClassifiers; /* < Total number of valid classifiers */ + u8 bValid; /* < Validity flag */ + u8 u8Padding; /* < Padding byte */ /* * Structure for Convergence SubLayer Types with a maximum of 4 classifiers */ @@ -248,64 +248,64 @@ struct bcm_connect_mgr_params { }; struct bcm_add_request { - B_UINT8 u8Type; /* < Type */ - B_UINT8 eConnectionDir; /* < Connection direction */ + u8 u8Type; /* < Type */ + u8 eConnectionDir; /* < Connection direction */ /* brief 16 bit TID */ - B_UINT16 u16TID; /* < 16bit TID */ + u16 u16TID; /* < 16bit TID */ /* brief 16bitCID */ - B_UINT16 u16CID; /* < 16bit CID */ + u16 u16CID; /* < 16bit CID */ /* brief 16bitVCID */ - B_UINT16 u16VCID; /* < 16bit VCID */ + u16 u16VCID; /* < 16bit VCID */ struct bcm_connect_mgr_params *psfParameterSet; /* < connection manager parameters */ }; struct bcm_add_indication { - B_UINT8 u8Type; /* < Type */ - B_UINT8 eConnectionDir; /* < Connection Direction */ + u8 u8Type; /* < Type */ + u8 eConnectionDir; /* < Connection Direction */ /* brief 16 bit TID */ - B_UINT16 u16TID; /* < TID */ + u16 u16TID; /* < TID */ /* brief 16bitCID */ - B_UINT16 u16CID; /* < 16bitCID */ + u16 u16CID; /* < 16bitCID */ /* brief 16bitVCID */ - B_UINT16 u16VCID; /* < 16bitVCID */ + u16 u16VCID; /* < 16bitVCID */ struct bcm_connect_mgr_params *psfAuthorizedSet; /* Authorized set of connection manager parameters */ struct bcm_connect_mgr_params *psfAdmittedSet; /* Admitted set of connection manager parameters */ struct bcm_connect_mgr_params *psfActiveSet; /* Activeset of connection manager parameters */ - B_UINT8 u8CC; /* <Confirmation Code */ - B_UINT8 u8Padd; /* < 8-bit Padding */ - B_UINT16 u16Padd; /* < 16 bit Padding */ + u8 u8CC; /* <Confirmation Code */ + u8 u8Padd; /* < 8-bit Padding */ + u16 u16Padd; /* < 16 bit Padding */ }; struct bcm_del_request { - B_UINT8 u8Type; /* < Type */ - B_UINT8 u8Padding; /* < Padding byte */ - B_UINT16 u16TID; /* < TID */ + u8 u8Type; /* < Type */ + u8 u8Padding; /* < Padding byte */ + u16 u16TID; /* < TID */ /* brief 32bitSFID */ - B_UINT32 u32SFID; /* < SFID */ + u32 u32SFID; /* < SFID */ }; struct bcm_del_indication { - B_UINT8 u8Type; /* < Type */ - B_UINT8 u8Padding; /* < Padding */ - B_UINT16 u16TID; /* < TID */ + u8 u8Type; /* < Type */ + u8 u8Padding; /* < Padding */ + u16 u16TID; /* < TID */ /* brief 16bitCID */ - B_UINT16 u16CID; /* < CID */ + u16 u16CID; /* < CID */ /* brief 16bitVCID */ - B_UINT16 u16VCID; /* < VCID */ + u16 u16VCID; /* < VCID */ /* brief 32bitSFID */ - B_UINT32 u32SFID; /* < SFID */ + u32 u32SFID; /* < SFID */ /* brief 8bit Confirmation code */ - B_UINT8 u8ConfirmationCode; /* < Confirmation code */ - B_UINT8 u8Padding1[3]; /* < 3 byte Padding */ + u8 u8ConfirmationCode; /* < Confirmation code */ + u8 u8Padding1[3]; /* < 3 byte Padding */ }; struct bcm_stim_sfhostnotify { - B_UINT32 SFID; /* SFID of the service flow */ - B_UINT16 newCID; /* the new/changed CID */ - B_UINT16 VCID; /* Get new Vcid if the flow has been made active in CID update TLV, but was inactive earlier or the orig vcid */ - B_UINT8 RetainSF; /* Indication to Host if the SF is to be retained or deleted; if TRUE-retain else delete */ - B_UINT8 QoSParamSet; /* QoS paramset of the retained SF */ - B_UINT16 u16reserved; /* For byte alignment */ + u32 SFID; /* SFID of the service flow */ + u16 newCID; /* the new/changed CID */ + u16 VCID; /* Get new Vcid if the flow has been made active in CID update TLV, but was inactive earlier or the orig vcid */ + u8 RetainSF; /* Indication to Host if the SF is to be retained or deleted; if TRUE-retain else delete */ + u8 QoSParamSet; /* QoS paramset of the retained SF */ + u16 u16reserved; /* For byte alignment */ }; #endif diff --git a/drivers/staging/bcm/headers.h b/drivers/staging/bcm/headers.h index da47db8c8f2..6f3270cc417 100644 --- a/drivers/staging/bcm/headers.h +++ b/drivers/staging/bcm/headers.h @@ -34,11 +34,10 @@ #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" -#include "Version.h" #include "Macros.h" #include "HostMIBSInterface.h" #include "cntrl_SignalingInterface.h" @@ -71,7 +70,7 @@ #define DEV_NAME "tarang" #define DRV_DESCRIPTION "Beceem Communications Inc. WiMAX driver" #define DRV_COPYRIGHT "Copyright 2010. Beceem Communications Inc" -#define DRV_VERSION VER_FILEVERSION_STR +#define DRV_VERSION "5.2.45" #define PFX DRV_NAME " " extern struct class *bcm_class; diff --git a/drivers/staging/bcm/hostmibs.c b/drivers/staging/bcm/hostmibs.c index 10361bb3505..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, S_MIBS_HOST_STATS_MIBS *pstHostMibs) +INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, + struct bcm_host_stats_mibs *pstHostMibs) { - S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL; - S_PHS_RULE *pstPhsRule = NULL; - S_CLASSIFIER_TABLE *pstClassifierTable = NULL; - S_CLASSIFIER_ENTRY *pstClassifierRule = NULL; - PPHS_DEVICE_EXTENSION pDeviceExtension = (PPHS_DEVICE_EXTENSION) &Adapter->stBCMPhsContext; - - UINT nClassifierIndex = 0, nPhsTableIndex = 0, nSfIndex = 0, uiIndex = 0; + 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 = &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], - sizeof(S_MIBS_CLASSIFIER_RULE)); + 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(S_MIBS_SERVICEFLOW_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, S_MIBS_HOST_STATS_MIBS pstHostMibs->astPhsRulesTable[nPhsTableIndex]. ulSFID = Adapter->PackInfo[nSfIndex].ulSFID; - memcpy(&pstHostMibs-> - astPhsRulesTable[nPhsTableIndex].u8PHSI, - &pstPhsRule->u8PHSI, sizeof(S_PHS_RULE)); + memcpy(&pstHostMibs->astPhsRulesTable[nPhsTableIndex].u8PHSI, + &pstPhsRule->u8PHSI, + sizeof(struct bcm_phs_rule)); nPhsTableIndex++; } @@ -82,28 +85,34 @@ INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, S_MIBS_HOST_STATS_MIBS /* 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(S_MIBS_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(S_MIBS_DROPPED_APP_CNTRL_MESSAGES)); + 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) { - S_MIBS_EXTSERVICEFLOW_PARAMETERS *t = &Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable; + struct bcm_mibs_parameters *t = &Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable; t->wmanIfSfid = psfLocalSet->u32SFID; t->wmanIfCmnCpsMaxSustainedRate = psfLocalSet->u32MaxSustainedTrafficRate; diff --git a/drivers/staging/bcm/led_control.c b/drivers/staging/bcm/led_control.c index 252a1b31d61..eee4f4795a7 100644 --- a/drivers/staging/bcm/led_control.c +++ b/drivers/staging/bcm/led_control.c @@ -13,21 +13,21 @@ static B_UINT16 CFG_CalculateChecksum(B_UINT8 *pu8Buffer, B_UINT32 u32Size) return u16CheckSum; } -BOOLEAN IsReqGpioIsLedInNVM(struct bcm_mini_adapter *Adapter, UINT gpios) +bool IsReqGpioIsLedInNVM(struct bcm_mini_adapter *Adapter, UINT gpios) { INT Status; Status = (Adapter->gpioBitMap & gpios) ^ gpios; if (Status) - return FALSE; + return false; else return TRUE; } static INT LED_Blink(struct bcm_mini_adapter *Adapter, UINT GPIO_Num, UCHAR uiLedIndex, - ULONG timeout, INT num_of_time, LedEventInfo_t currdriverstate) + ULONG timeout, INT num_of_time, enum bcm_led_events currdriverstate) { int Status = STATUS_SUCCESS; - BOOLEAN bInfinite = FALSE; + bool bInfinite = false; /* Check if num_of_time is -ve. If yes, blink led in infinite loop */ if (num_of_time < 0) { @@ -67,7 +67,7 @@ static INT LED_Blink(struct bcm_mini_adapter *Adapter, UINT GPIO_Num, UCHAR uiLe currdriverstate != Adapter->DriverState || kthread_should_stop(), msecs_to_jiffies(timeout)); - if (bInfinite == FALSE) + if (bInfinite == false) num_of_time--; } return Status; @@ -97,7 +97,7 @@ static INT ScaleRateofTransfer(ULONG rate) static INT LED_Proportional_Blink(struct bcm_mini_adapter *Adapter, UCHAR GPIO_Num_tx, UCHAR uiTxLedIndex, UCHAR GPIO_Num_rx, UCHAR uiRxLedIndex, - LedEventInfo_t currdriverstate) + enum bcm_led_events currdriverstate) { /* Initial values of TX and RX packets */ ULONG64 Initial_num_of_packts_tx = 0, Initial_num_of_packts_rx = 0; @@ -108,7 +108,7 @@ static INT LED_Proportional_Blink(struct bcm_mini_adapter *Adapter, UCHAR GPIO_N int Status = STATUS_SUCCESS; INT num_of_time = 0, num_of_time_tx = 0, num_of_time_rx = 0; UINT remDelay = 0; - BOOLEAN bBlinkBothLED = TRUE; + bool bBlinkBothLED = TRUE; /* UINT GPIO_num = DISABLE_GPIO_NUM; */ ulong timeout = 0; @@ -120,7 +120,7 @@ static INT LED_Proportional_Blink(struct bcm_mini_adapter *Adapter, UCHAR GPIO_N num_of_time_tx = ScaleRateofTransfer((ULONG)rate_of_transfer_tx); num_of_time_rx = ScaleRateofTransfer((ULONG)rate_of_transfer_rx); - while ((Adapter->device_removed == FALSE)) { + while ((Adapter->device_removed == false)) { timeout = 50; /* * Blink Tx and Rx LED when both Tx and Rx is @@ -478,7 +478,7 @@ static int ReadLEDInformationFromEEPROM(struct bcm_mini_adapter *Adapter, static int ReadConfigFileStructure(struct bcm_mini_adapter *Adapter, - BOOLEAN *bEnableThread) + bool *bEnableThread) { int Status = STATUS_SUCCESS; /* Array to store GPIO numbers from EEPROM */ @@ -499,10 +499,10 @@ static int ReadConfigFileStructure(struct bcm_mini_adapter *Adapter, /* Read the GPIO numbers from EEPROM */ Status = ReadLEDInformationFromEEPROM(Adapter, GPIO_Array); if (Status == STATUS_IMAGE_CHECKSUM_MISMATCH) { - *bEnableThread = FALSE; + *bEnableThread = false; return STATUS_SUCCESS; } else if (Status) { - *bEnableThread = FALSE; + *bEnableThread = false; return Status; } @@ -561,7 +561,7 @@ static int ReadConfigFileStructure(struct bcm_mini_adapter *Adapter, uiNum_of_LED_Type++; } if (uiNum_of_LED_Type >= NUM_OF_LEDS) - *bEnableThread = FALSE; + *bEnableThread = false; return Status; } @@ -602,12 +602,12 @@ static VOID LedGpioInit(struct bcm_mini_adapter *Adapter) BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL, "LED Thread: WRM Failed\n"); - Adapter->LEDInfo.bIdle_led_off = FALSE; + Adapter->LEDInfo.bIdle_led_off = false; } static INT BcmGetGPIOPinInfo(struct bcm_mini_adapter *Adapter, UCHAR *GPIO_num_tx, UCHAR *GPIO_num_rx, UCHAR *uiLedTxIndex, UCHAR *uiLedRxIndex, - LedEventInfo_t currdriverstate) + enum bcm_led_events currdriverstate) { UINT uiIndex = 0; @@ -651,7 +651,7 @@ static VOID LEDControlThread(struct bcm_mini_adapter *Adapter) UCHAR GPIO_num = 0; UCHAR uiLedIndex = 0; UINT uiResetValue = 0; - LedEventInfo_t currdriverstate = 0; + enum bcm_led_events currdriverstate = 0; ulong timeout = 0; INT Status = 0; @@ -660,7 +660,7 @@ static VOID LEDControlThread(struct bcm_mini_adapter *Adapter) UCHAR dummyIndex = 0; /* currdriverstate = Adapter->DriverState; */ - Adapter->LEDInfo.bIdleMode_tx_from_host = FALSE; + Adapter->LEDInfo.bIdleMode_tx_from_host = false; /* * Wait till event is triggered @@ -698,7 +698,7 @@ static VOID LEDControlThread(struct bcm_mini_adapter *Adapter) if (GPIO_num != DISABLE_GPIO_NUM) TURN_OFF_LED(1 << GPIO_num, uiLedIndex); - if (Adapter->LEDInfo.bLedInitDone == FALSE) { + if (Adapter->LEDInfo.bLedInitDone == false) { LedGpioInit(Adapter); Adapter->LEDInfo.bLedInitDone = TRUE; } @@ -757,7 +757,7 @@ static VOID LEDControlThread(struct bcm_mini_adapter *Adapter) UCHAR uiLEDTx = 0; UCHAR uiLEDRx = 0; currdriverstate = NORMAL_OPERATION; - Adapter->LEDInfo.bIdle_led_off = FALSE; + Adapter->LEDInfo.bIdle_led_off = false; BcmGetGPIOPinInfo(Adapter, &GPIO_num_tx, &GPIO_num_rx, &uiLEDTx, &uiLEDRx, @@ -803,7 +803,7 @@ static VOID LEDControlThread(struct bcm_mini_adapter *Adapter) } /* Turn off LED And WAKE-UP for Sendinf IDLE mode ACK */ - Adapter->LEDInfo.bLedInitDone = FALSE; + Adapter->LEDInfo.bLedInitDone = false; Adapter->LEDInfo.bIdle_led_off = TRUE; wake_up(&Adapter->LEDInfo.idleModeSyncEvent); GPIO_num = DISABLE_GPIO_NUM; @@ -830,7 +830,7 @@ static VOID LEDControlThread(struct bcm_mini_adapter *Adapter) currdriverstate = LED_THREAD_INACTIVE; Adapter->LEDInfo.led_thread_running = BCM_LED_THREAD_RUNNING_INACTIVELY; - Adapter->LEDInfo.bLedInitDone = FALSE; + Adapter->LEDInfo.bLedInitDone = false; /* disable ALL LED */ for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) { if (Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num @@ -841,7 +841,7 @@ static VOID LEDControlThread(struct bcm_mini_adapter *Adapter) case LED_THREAD_ACTIVE: BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL, "Activating LED thread again..."); - if (Adapter->LinkUpStatus == FALSE) + if (Adapter->LinkUpStatus == false) Adapter->DriverState = NO_NETWORK_ENTRY; else Adapter->DriverState = NORMAL_OPERATION; @@ -860,7 +860,7 @@ static VOID LEDControlThread(struct bcm_mini_adapter *Adapter) int InitLedSettings(struct bcm_mini_adapter *Adapter) { int Status = STATUS_SUCCESS; - BOOLEAN bEnableThread = TRUE; + bool bEnableThread = TRUE; UCHAR uiIndex = 0; /* @@ -899,7 +899,7 @@ int InitLedSettings(struct bcm_mini_adapter *Adapter) init_waitqueue_head(&Adapter->LEDInfo.idleModeSyncEvent); Adapter->LEDInfo.led_thread_running = BCM_LED_THREAD_RUNNING_ACTIVELY; - Adapter->LEDInfo.bIdle_led_off = FALSE; + Adapter->LEDInfo.bIdle_led_off = false; Adapter->LEDInfo.led_cntrl_threadid = kthread_run((int (*)(void *)) LEDControlThread, Adapter, "led_control_thread"); diff --git a/drivers/staging/bcm/led_control.h b/drivers/staging/bcm/led_control.h index ed8fbc09111..bae40e22e11 100644 --- a/drivers/staging/bcm/led_control.h +++ b/drivers/staging/bcm/led_control.h @@ -1,102 +1,84 @@ #ifndef _LED_CONTROL_H #define _LED_CONTROL_H -/*************************TYPE DEF**********************/ -#define NUM_OF_LEDS 4 - +#define NUM_OF_LEDS 4 #define DSD_START_OFFSET 0x0200 #define EEPROM_VERSION_OFFSET 0x020E #define EEPROM_HW_PARAM_POINTER_ADDRESS 0x0218 #define EEPROM_HW_PARAM_POINTER_ADDRRES_MAP5 0x0220 #define GPIO_SECTION_START_OFFSET 0x03 - -#define COMPATIBILITY_SECTION_LENGTH 42 -#define COMPATIBILITY_SECTION_LENGTH_MAP5 84 - - -#define EEPROM_MAP5_MAJORVERSION 5 -#define EEPROM_MAP5_MINORVERSION 0 - - +#define COMPATIBILITY_SECTION_LENGTH 42 +#define COMPATIBILITY_SECTION_LENGTH_MAP5 84 +#define EEPROM_MAP5_MAJORVERSION 5 +#define EEPROM_MAP5_MINORVERSION 0 #define MAX_NUM_OF_BLINKS 10 #define NUM_OF_GPIO_PINS 16 - #define DISABLE_GPIO_NUM 0xFF #define EVENT_SIGNALED 1 - #define MAX_FILE_NAME_BUFFER_SIZE 100 -#define TURN_ON_LED(GPIO, index) do { \ - UINT gpio_val = GPIO; \ - (Adapter->LEDInfo.LEDState[index].BitPolarity == 1) ? \ - wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_SET_REG, &gpio_val, sizeof(gpio_val)) : \ - wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_CLR_REG, &gpio_val, sizeof(gpio_val)); \ - } while (0); - -#define TURN_OFF_LED(GPIO, index) do { \ - UINT gpio_val = GPIO; \ - (Adapter->LEDInfo.LEDState[index].BitPolarity == 1) ? \ - wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_CLR_REG, &gpio_val, sizeof(gpio_val)) : \ - wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_SET_REG, &gpio_val, sizeof(gpio_val)); \ - } while (0); - -#define B_ULONG32 unsigned long - -/*******************************************************/ - - -typedef enum _LEDColors{ - RED_LED = 1, - BLUE_LED = 2, - YELLOW_LED = 3, - GREEN_LED = 4 -} LEDColors; /*Enumerated values of different LED types*/ - -typedef enum LedEvents { - SHUTDOWN_EXIT = 0x00, - DRIVER_INIT = 0x1, - FW_DOWNLOAD = 0x2, - FW_DOWNLOAD_DONE = 0x4, - NO_NETWORK_ENTRY = 0x8, - NORMAL_OPERATION = 0x10, - LOWPOWER_MODE_ENTER = 0x20, - IDLEMODE_CONTINUE = 0x40, - IDLEMODE_EXIT = 0x80, - LED_THREAD_INACTIVE = 0x100, /* Makes the LED thread Inactivce. It wil be equivallent to putting the thread on hold. */ - LED_THREAD_ACTIVE = 0x200, /* Makes the LED Thread Active back. */ - DRIVER_HALT = 0xff -} LedEventInfo_t; /* Enumerated values of different driver states */ +#define TURN_ON_LED(GPIO, index) do { \ + unsigned int gpio_val = GPIO; \ + (Adapter->LEDInfo.LEDState[index].BitPolarity == 1) ? \ + wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_SET_REG, &gpio_val, sizeof(gpio_val)) : \ + wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_CLR_REG, &gpio_val, sizeof(gpio_val)); \ + } while (0) + +#define TURN_OFF_LED(GPIO, index) do { \ + unsigned int gpio_val = GPIO; \ + (Adapter->LEDInfo.LEDState[index].BitPolarity == 1) ? \ + wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_CLR_REG, &gpio_val, sizeof(gpio_val)) : \ + wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_SET_REG, &gpio_val, sizeof(gpio_val)); \ + } while (0) + +enum bcm_led_colors { + RED_LED = 1, + BLUE_LED = 2, + YELLOW_LED = 3, + GREEN_LED = 4 +}; + +enum bcm_led_events { + SHUTDOWN_EXIT = 0x00, + DRIVER_INIT = 0x1, + FW_DOWNLOAD = 0x2, + FW_DOWNLOAD_DONE = 0x4, + NO_NETWORK_ENTRY = 0x8, + NORMAL_OPERATION = 0x10, + LOWPOWER_MODE_ENTER = 0x20, + IDLEMODE_CONTINUE = 0x40, + IDLEMODE_EXIT = 0x80, + LED_THREAD_INACTIVE = 0x100, /* Makes the LED thread Inactivce. It wil be equivallent to putting the thread on hold. */ + LED_THREAD_ACTIVE = 0x200, /* Makes the LED Thread Active back. */ + DRIVER_HALT = 0xff +}; /* Enumerated values of different driver states */ /* * Structure which stores the information of different LED types * and corresponding LED state information of driver states */ -typedef struct LedStateInfo_t { - UCHAR LED_Type; /* specify GPIO number - use 0xFF if not used */ - UCHAR LED_On_State; /* Bits set or reset for different states */ - UCHAR LED_Blink_State; /* Bits set or reset for blinking LEDs for different states */ - UCHAR GPIO_Num; - UCHAR BitPolarity; /* To represent whether H/W is normal polarity or reverse polarity */ -} LEDStateInfo, *pLEDStateInfo; - - -typedef struct _LED_INFO_STRUCT { - LEDStateInfo LEDState[NUM_OF_LEDS]; - BOOLEAN bIdleMode_tx_from_host; /* Variable to notify whether driver came out from idlemode due to Host or target*/ - BOOLEAN bIdle_led_off; - wait_queue_head_t notify_led_event; +struct bcm_led_state_info { + unsigned char LED_Type; /* specify GPIO number - use 0xFF if not used */ + unsigned char LED_On_State; /* Bits set or reset for different states */ + unsigned char LED_Blink_State; /* Bits set or reset for blinking LEDs for different states */ + unsigned char GPIO_Num; + unsigned char BitPolarity; /* To represent whether H/W is normal polarity or reverse polarity */ +}; + +struct bcm_led_info { + struct bcm_led_state_info LEDState[NUM_OF_LEDS]; + bool bIdleMode_tx_from_host; /* Variable to notify whether driver came out from idlemode due to Host or target */ + bool bIdle_led_off; + wait_queue_head_t notify_led_event; wait_queue_head_t idleModeSyncEvent; - struct task_struct *led_cntrl_threadid; - int led_thread_running; - BOOLEAN bLedInitDone; + struct task_struct *led_cntrl_threadid; + int led_thread_running; + bool bLedInitDone; +}; -} LED_INFO_STRUCT, *PLED_INFO_STRUCT; /* LED Thread state. */ -#define BCM_LED_THREAD_DISABLED 0 /* LED Thread is not running. */ -#define BCM_LED_THREAD_RUNNING_ACTIVELY 1 /* LED thread is running. */ -#define BCM_LED_THREAD_RUNNING_INACTIVELY 2 /*LED thread has been put on hold*/ - - +#define BCM_LED_THREAD_DISABLED 0 /* LED Thread is not running. */ +#define BCM_LED_THREAD_RUNNING_ACTIVELY 1 /* LED thread is running. */ +#define BCM_LED_THREAD_RUNNING_INACTIVELY 2 /* LED thread has been put on hold */ #endif - diff --git a/drivers/staging/bcm/nvm.c b/drivers/staging/bcm/nvm.c index b034eb5fa6b..63be3be62eb 100644 --- a/drivers/staging/bcm/nvm.c +++ b/drivers/staging/bcm/nvm.c @@ -12,27 +12,27 @@ static unsigned int BcmGetFlashSectorSize(struct bcm_mini_adapter *Adapter, unsi static VOID BcmValidateNvmType(struct bcm_mini_adapter *Adapter); static int BcmGetNvmSize(struct bcm_mini_adapter *Adapter); static unsigned int BcmGetFlashSize(struct bcm_mini_adapter *Adapter); -static NVM_TYPE BcmGetNvmType(struct bcm_mini_adapter *Adapter); +static enum bcm_nvm_type BcmGetNvmType(struct bcm_mini_adapter *Adapter); -static int BcmGetSectionValEndOffset(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal); +static int BcmGetSectionValEndOffset(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectionVal); static B_UINT8 IsOffsetWritable(struct bcm_mini_adapter *Adapter, unsigned int uiOffset); -static int IsSectionWritable(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL Section); -static int IsSectionExistInVendorInfo(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL section); +static int IsSectionWritable(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val Section); +static int IsSectionExistInVendorInfo(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val section); -static int ReadDSDPriority(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL dsd); -static int ReadDSDSignature(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL dsd); -static int ReadISOPriority(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL iso); -static int ReadISOSignature(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL iso); +static int ReadDSDPriority(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); +static int ReadISOPriority(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); -static int CorruptDSDSig(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal); -static int CorruptISOSig(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal); +static int CorruptDSDSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectionVal); +static int CorruptISOSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectionVal); static int SaveHeaderIfPresent(struct bcm_mini_adapter *Adapter, PUCHAR pBuff, unsigned int uiSectAlignAddr); static int WriteToFlashWithoutSectorErase(struct bcm_mini_adapter *Adapter, PUINT pBuff, - FLASH2X_SECTION_VAL eFlash2xSectionVal, + enum bcm_flash2x_section_val eFlash2xSectionVal, unsigned int uiOffset, unsigned int uiNumBytes); -static FLASH2X_SECTION_VAL getHighestPriDSD(struct bcm_mini_adapter *Adapter); -static FLASH2X_SECTION_VAL getHighestPriISO(struct bcm_mini_adapter *Adapter); +static enum bcm_flash2x_section_val getHighestPriDSD(struct bcm_mini_adapter *Adapter); +static enum bcm_flash2x_section_val getHighestPriISO(struct bcm_mini_adapter *Adapter); static int BeceemFlashBulkRead( struct bcm_mini_adapter *Adapter, @@ -45,7 +45,7 @@ static int BeceemFlashBulkWrite( PUINT pBuffer, unsigned int uiOffset, unsigned int uiNumBytes, - BOOLEAN bVerify); + bool bVerify); static int GetFlashBaseAddr(struct bcm_mini_adapter *Adapter); @@ -103,7 +103,7 @@ static UCHAR ReadEEPROMStatusRegister(struct bcm_mini_adapter *Adapter) } if (!(dwRetries%RETRIES_PER_DELAY)) udelay(1000); - uiStatus = 0 ; + uiStatus = 0; } return uiData; } /* ReadEEPROMStatusRegister */ @@ -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) @@ -472,7 +472,7 @@ static int BeceemFlashBulkRead(struct bcm_mini_adapter *Adapter, static unsigned int BcmGetFlashSize(struct bcm_mini_adapter *Adapter) { if (IsFlash2x(Adapter)) - return Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER); + return Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(struct bcm_dsd_header); else return 32 * 1024; } @@ -1034,7 +1034,7 @@ static int BeceemFlashBulkWrite(struct bcm_mini_adapter *Adapter, PUINT pBuffer, unsigned int uiOffset, unsigned int uiNumBytes, - BOOLEAN bVerify) + bool bVerify) { PCHAR pTempBuff = NULL; PUCHAR pcBuffer = (PUCHAR)pBuffer; @@ -1084,18 +1084,18 @@ static int BeceemFlashBulkWrite(struct bcm_mini_adapter *Adapter, * for DSD calibration, allow it without checking of sector permission */ - if (IsFlash2x(Adapter) && (Adapter->bAllDSDWriteAllow == FALSE)) { + if (IsFlash2x(Adapter) && (Adapter->bAllDSDWriteAllow == false)) { index = 0; uiTemp = uiNumSectTobeRead; while (uiTemp) { - if (IsOffsetWritable(Adapter, uiOffsetFromSectStart + index * Adapter->uiSectorSize) == FALSE) { + if (IsOffsetWritable(Adapter, uiOffsetFromSectStart + index * Adapter->uiSectorSize) == false) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Sector Starting at offset <0X%X> is not writable", (uiOffsetFromSectStart + index * Adapter->uiSectorSize)); Status = SECTOR_IS_NOT_WRITABLE; goto BeceemFlashBulkWrite_EXIT; } uiTemp = uiTemp - 1; - index = index + 1 ; + index = index + 1; } } Adapter->SelectedChip = RESET_CHIP_SELECT; @@ -1222,7 +1222,7 @@ static int BeceemFlashBulkWriteStatus(struct bcm_mini_adapter *Adapter, PUINT pBuffer, unsigned int uiOffset, unsigned int uiNumBytes, - BOOLEAN bVerify) + bool bVerify) { PCHAR pTempBuff = NULL; PUCHAR pcBuffer = (PUCHAR)pBuffer; @@ -1265,18 +1265,18 @@ static int BeceemFlashBulkWriteStatus(struct bcm_mini_adapter *Adapter, uiNumSectTobeRead++; } - if (IsFlash2x(Adapter) && (Adapter->bAllDSDWriteAllow == FALSE)) { + if (IsFlash2x(Adapter) && (Adapter->bAllDSDWriteAllow == false)) { index = 0; uiTemp = uiNumSectTobeRead; while (uiTemp) { - if (IsOffsetWritable(Adapter, uiOffsetFromSectStart + index * Adapter->uiSectorSize) == FALSE) { + if (IsOffsetWritable(Adapter, uiOffsetFromSectStart + index * Adapter->uiSectorSize) == false) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Sector Starting at offset <0X%x> is not writable", (uiOffsetFromSectStart + index * Adapter->uiSectorSize)); Status = SECTOR_IS_NOT_WRITABLE; goto BeceemFlashBulkWriteStatus_EXIT; } uiTemp = uiTemp - 1; - index = index + 1 ; + index = index + 1; } } @@ -1355,67 +1355,6 @@ BeceemFlashBulkWriteStatus_EXIT: } /* - * Procedure: PropagateCalParamsFromEEPROMToMemory - * - * Description: Dumps the calibration section of EEPROM to DDR. - * - * Arguments: - * Adapter - ptr to Adapter object instance - * Returns: - * OSAL_STATUS_CODE - * - */ - -int PropagateCalParamsFromEEPROMToMemory(struct bcm_mini_adapter *Adapter) -{ - PCHAR pBuff = kmalloc(BUFFER_4K, GFP_KERNEL); - unsigned int uiEepromSize = 0; - unsigned int uiIndex = 0; - unsigned int uiBytesToCopy = 0; - unsigned int uiCalStartAddr = EEPROM_CALPARAM_START; - unsigned int uiMemoryLoc = EEPROM_CAL_DATA_INTERNAL_LOC; - unsigned int value; - int Status = 0; - - if (!pBuff) - return -ENOMEM; - - if (0 != BeceemEEPROMBulkRead(Adapter, &uiEepromSize, EEPROM_SIZE_OFFSET, 4)) { - kfree(pBuff); - return -1; - } - - uiEepromSize >>= 16; - if (uiEepromSize > 1024 * 1024) { - kfree(pBuff); - return -1; - } - - uiBytesToCopy = MIN(BUFFER_4K, uiEepromSize); - - while (uiBytesToCopy) { - if (0 != BeceemEEPROMBulkRead(Adapter, (PUINT)pBuff, uiCalStartAddr, uiBytesToCopy)) { - Status = -1; - break; - } - wrm(Adapter, uiMemoryLoc, (PCHAR)(((PULONG)pBuff) + uiIndex), uiBytesToCopy); - uiMemoryLoc += uiBytesToCopy; - uiEepromSize -= uiBytesToCopy; - uiCalStartAddr += uiBytesToCopy; - uiIndex += uiBytesToCopy / 4; - uiBytesToCopy = MIN(BUFFER_4K, uiEepromSize); - - } - value = 0xbeadbead; - wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 4, &value, sizeof(value)); - value = 0xbeadbead; - wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 8, &value, sizeof(value)); - kfree(pBuff); - - return Status; -} - -/* * Procedure: PropagateCalParamsFromFlashToMemory * * Description: Dumps the calibration section of EEPROM to DDR. @@ -1525,7 +1464,7 @@ static int BeceemEEPROMReadBackandVerify(struct bcm_mini_adapter *Adapter, if (memcmp(&pBuffer[uiIndex], &auiData[0], MAX_RW_SIZE)) { /* re-write */ - BeceemEEPROMBulkWrite(Adapter, (PUCHAR)(pBuffer + uiIndex), uiOffset, MAX_RW_SIZE, FALSE); + BeceemEEPROMBulkWrite(Adapter, (PUCHAR)(pBuffer + uiIndex), uiOffset, MAX_RW_SIZE, false); mdelay(3); BeceemEEPROMBulkRead(Adapter, &auiData[0], uiOffset, MAX_RW_SIZE); @@ -1539,7 +1478,7 @@ static int BeceemEEPROMReadBackandVerify(struct bcm_mini_adapter *Adapter, BeceemEEPROMBulkRead(Adapter, &uiData, uiOffset, 4); if (uiData != pBuffer[uiIndex]) { /* re-write */ - BeceemEEPROMBulkWrite(Adapter, (PUCHAR)(pBuffer + uiIndex), uiOffset, 4, FALSE); + BeceemEEPROMBulkWrite(Adapter, (PUCHAR)(pBuffer + uiIndex), uiOffset, 4, false); mdelay(3); BeceemEEPROMBulkRead(Adapter, &uiData, uiOffset, 4); if (uiData != pBuffer[uiIndex]) @@ -1724,7 +1663,7 @@ int BeceemEEPROMBulkWrite(struct bcm_mini_adapter *Adapter, PUCHAR pBuffer, unsigned int uiOffset, unsigned int uiNumBytes, - BOOLEAN bVerify) + bool bVerify) { unsigned int uiBytesToCopy = uiNumBytes; /* unsigned int uiRdbk = 0; */ @@ -1819,7 +1758,7 @@ int BeceemNVMRead(struct bcm_mini_adapter *Adapter, #endif if (Adapter->eNVMType == NVM_FLASH) { - if (Adapter->bFlashRawRead == FALSE) { + if (Adapter->bFlashRawRead == false) { if (IsSectionExistInVendorInfo(Adapter, Adapter->eActiveDSD)) return vendorextnReadSection(Adapter, (PUCHAR)pBuffer, Adapter->eActiveDSD, uiOffset, uiNumBytes); @@ -1870,7 +1809,7 @@ int BeceemNVMWrite(struct bcm_mini_adapter *Adapter, PUINT pBuffer, unsigned int uiOffset, unsigned int uiNumBytes, - BOOLEAN bVerify) + bool bVerify) { int Status = 0; unsigned int uiTemp = 0; @@ -1978,7 +1917,7 @@ int BeceemNVMWrite(struct bcm_mini_adapter *Adapter, int BcmUpdateSectorSize(struct bcm_mini_adapter *Adapter, unsigned int uiSectorSize) { int Status = -1; - FLASH_CS_INFO sFlashCsInfo = {0}; + struct bcm_flash_cs_info sFlashCsInfo = {0}; unsigned int uiTemp = 0; unsigned int uiSectorSig = 0; unsigned int uiCurrentSectorSize = 0; @@ -2228,20 +2167,20 @@ int BcmAllocFlashCSStructure(struct bcm_mini_adapter *psAdapter) BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_PRINTK, 0, 0, "Adapter structure point is NULL"); return -EINVAL; } - psAdapter->psFlashCSInfo = (PFLASH_CS_INFO)kzalloc(sizeof(FLASH_CS_INFO), GFP_KERNEL); + psAdapter->psFlashCSInfo = kzalloc(sizeof(struct bcm_flash_cs_info), GFP_KERNEL); if (psAdapter->psFlashCSInfo == NULL) { BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_PRINTK, 0, 0, "Can't Allocate memory for Flash 1.x"); return -ENOMEM; } - psAdapter->psFlash2xCSInfo = (PFLASH2X_CS_INFO)kzalloc(sizeof(FLASH2X_CS_INFO), GFP_KERNEL); + psAdapter->psFlash2xCSInfo = kzalloc(sizeof(struct bcm_flash2x_cs_info), GFP_KERNEL); if (!psAdapter->psFlash2xCSInfo) { BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_PRINTK, 0, 0, "Can't Allocate memory for Flash 2.x"); kfree(psAdapter->psFlashCSInfo); return -ENOMEM; } - psAdapter->psFlash2xVendorInfo = (PFLASH2X_VENDORSPECIFIC_INFO)kzalloc(sizeof(FLASH2X_VENDORSPECIFIC_INFO), GFP_KERNEL); + psAdapter->psFlash2xVendorInfo = kzalloc(sizeof(struct bcm_flash2x_vendor_info), GFP_KERNEL); if (!psAdapter->psFlash2xVendorInfo) { BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_PRINTK, 0, 0, "Can't Allocate Vendor Info Memory for Flash 2.x"); kfree(psAdapter->psFlashCSInfo); @@ -2264,7 +2203,7 @@ int BcmDeAllocFlashCSStructure(struct bcm_mini_adapter *psAdapter) return STATUS_SUCCESS; } -static int BcmDumpFlash2XCSStructure(PFLASH2X_CS_INFO psFlash2xCSInfo, struct bcm_mini_adapter *Adapter) +static int BcmDumpFlash2XCSStructure(struct bcm_flash2x_cs_info *psFlash2xCSInfo, struct bcm_mini_adapter *Adapter) { unsigned int Index = 0; @@ -2324,7 +2263,7 @@ static int BcmDumpFlash2XCSStructure(PFLASH2X_CS_INFO psFlash2xCSInfo, struct bc return STATUS_SUCCESS; } -static int ConvertEndianOf2XCSStructure(PFLASH2X_CS_INFO psFlash2xCSInfo) +static int ConvertEndianOf2XCSStructure(struct bcm_flash2x_cs_info *psFlash2xCSInfo) { unsigned int Index = 0; @@ -2381,7 +2320,7 @@ static int ConvertEndianOf2XCSStructure(PFLASH2X_CS_INFO psFlash2xCSInfo) return STATUS_SUCCESS; } -static int ConvertEndianOfCSStructure(PFLASH_CS_INFO psFlashCSInfo) +static int ConvertEndianOfCSStructure(struct bcm_flash_cs_info *psFlashCSInfo) { /* unsigned int Index = 0; */ psFlashCSInfo->MagicNumber = ntohl(psFlashCSInfo->MagicNumber); @@ -2413,7 +2352,7 @@ static int ConvertEndianOfCSStructure(PFLASH_CS_INFO psFlashCSInfo) return STATUS_SUCCESS; } -static int IsSectionExistInVendorInfo(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL section) +static int IsSectionExistInVendorInfo(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val section) { return (Adapter->uiVendorExtnFlag && (Adapter->psFlash2xVendorInfo->VendorSection[section].AccessFlags & FLASH2X_SECTION_PRESENT) && @@ -2425,7 +2364,7 @@ static VOID UpdateVendorInfo(struct bcm_mini_adapter *Adapter) B_UINT32 i = 0; unsigned int uiSizeSection = 0; - Adapter->uiVendorExtnFlag = FALSE; + Adapter->uiVendorExtnFlag = false; for (i = 0; i < TOTAL_SECTIONS; i++) Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart = UNINIT_PTR_IN_CS; @@ -2446,7 +2385,7 @@ static VOID UpdateVendorInfo(struct bcm_mini_adapter *Adapter) switch (i) { case DSD0: - if ((uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER))) && + if ((uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(struct bcm_dsd_header))) && (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart)) Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDEnd = VENDOR_PTR_IN_CS; else @@ -2454,7 +2393,7 @@ static VOID UpdateVendorInfo(struct bcm_mini_adapter *Adapter) break; case DSD1: - if ((uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER))) && + if ((uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(struct bcm_dsd_header))) && (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart)) Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1End = VENDOR_PTR_IN_CS; else @@ -2462,7 +2401,7 @@ static VOID UpdateVendorInfo(struct bcm_mini_adapter *Adapter) break; case DSD2: - if ((uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER))) && + if ((uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(struct bcm_dsd_header))) && (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart)) Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2End = VENDOR_PTR_IN_CS; else @@ -2509,7 +2448,7 @@ static VOID UpdateVendorInfo(struct bcm_mini_adapter *Adapter) static int BcmGetFlashCSInfo(struct bcm_mini_adapter *Adapter) { - /* FLASH_CS_INFO sFlashCsInfo = {0}; */ + /* struct bcm_flash_cs_info sFlashCsInfo = {0}; */ #if !defined(BCM_SHM_INTERFACE) || defined(FLASH_DIRECT_ACCESS) unsigned int value; @@ -2522,8 +2461,8 @@ static int BcmGetFlashCSInfo(struct bcm_mini_adapter *Adapter) Adapter->uiFlashBaseAdd = 0; Adapter->ulFlashCalStart = 0; - memset(Adapter->psFlashCSInfo, 0 , sizeof(FLASH_CS_INFO)); - memset(Adapter->psFlash2xCSInfo, 0 , sizeof(FLASH2X_CS_INFO)); + memset(Adapter->psFlashCSInfo, 0 , sizeof(struct bcm_flash_cs_info)); + memset(Adapter->psFlash2xCSInfo, 0 , sizeof(struct bcm_flash2x_cs_info)); if (!Adapter->bDDRInitDone) { value = FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT; @@ -2551,7 +2490,7 @@ static int BcmGetFlashCSInfo(struct bcm_mini_adapter *Adapter) BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FLASH LAYOUT MAJOR VERSION :%X", uiFlashLayoutMajorVersion); if (uiFlashLayoutMajorVersion < FLASH_2X_MAJOR_NUMBER) { - BeceemFlashBulkRead(Adapter, (PUINT)Adapter->psFlashCSInfo, Adapter->ulFlashControlSectionStart, sizeof(FLASH_CS_INFO)); + BeceemFlashBulkRead(Adapter, (PUINT)Adapter->psFlashCSInfo, Adapter->ulFlashControlSectionStart, sizeof(struct bcm_flash_cs_info)); ConvertEndianOfCSStructure(Adapter->psFlashCSInfo); Adapter->ulFlashCalStart = (Adapter->psFlashCSInfo->OffsetFromZeroForCalibrationStart); @@ -2576,7 +2515,7 @@ static int BcmGetFlashCSInfo(struct bcm_mini_adapter *Adapter) Adapter->uiFlashBaseAdd = Adapter->psFlashCSInfo->FlashBaseAddr & 0xFCFFFFFF; } else { if (BcmFlash2xBulkRead(Adapter, (PUINT)Adapter->psFlash2xCSInfo, NO_SECTION_VAL, - Adapter->ulFlashControlSectionStart, sizeof(FLASH2X_CS_INFO))) { + Adapter->ulFlashControlSectionStart, sizeof(struct bcm_flash2x_cs_info))) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Unable to read CS structure\n"); return STATUS_FAILURE; } @@ -2629,7 +2568,7 @@ static int BcmGetFlashCSInfo(struct bcm_mini_adapter *Adapter) * */ -static NVM_TYPE BcmGetNvmType(struct bcm_mini_adapter *Adapter) +static enum bcm_nvm_type BcmGetNvmType(struct bcm_mini_adapter *Adapter) { unsigned int uiData = 0; @@ -2660,14 +2599,14 @@ static NVM_TYPE BcmGetNvmType(struct bcm_mini_adapter *Adapter) /* * BcmGetSectionValStartOffset - this will calculate the section's starting offset if section val is given * @Adapter : Drivers Private Data structure - * @eFlashSectionVal : Flash secion value defined in enum FLASH2X_SECTION_VAL + * @eFlashSectionVal : Flash secion value defined in enum bcm_flash2x_section_val * * Return value:- * On success it return the start offset of the provided section val * On Failure -returns STATUS_FAILURE */ -int BcmGetSectionValStartOffset(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlashSectionVal) +int BcmGetSectionValStartOffset(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlashSectionVal) { /* * Considering all the section for which end offset can be calculated or directly given @@ -2685,12 +2624,12 @@ int BcmGetSectionValStartOffset(struct bcm_mini_adapter *Adapter, FLASH2X_SECTIO switch (eFlashSectionVal) { case ISO_IMAGE1: if ((Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start != UNINIT_PTR_IN_CS) && - (IsNonCDLessDevice(Adapter) == FALSE)) + (IsNonCDLessDevice(Adapter) == false)) SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start); break; case ISO_IMAGE2: if ((Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start != UNINIT_PTR_IN_CS) && - (IsNonCDLessDevice(Adapter) == FALSE)) + (IsNonCDLessDevice(Adapter) == false)) SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start); break; case DSD0: @@ -2752,14 +2691,14 @@ int BcmGetSectionValStartOffset(struct bcm_mini_adapter *Adapter, FLASH2X_SECTIO /* * BcmGetSectionValEndOffset - this will calculate the section's Ending offset if section val is given * @Adapter : Drivers Private Data structure - * @eFlashSectionVal : Flash secion value defined in enum FLASH2X_SECTION_VAL + * @eFlashSectionVal : Flash secion value defined in enum bcm_flash2x_section_val * * Return value:- * On success it return the end offset of the provided section val * On Failure -returns STATUS_FAILURE */ -int BcmGetSectionValEndOffset(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal) +static int BcmGetSectionValEndOffset(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectionVal) { int SectEndOffset = 0; @@ -2770,12 +2709,12 @@ int BcmGetSectionValEndOffset(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_ switch (eFlash2xSectionVal) { case ISO_IMAGE1: if ((Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End != UNINIT_PTR_IN_CS) && - (IsNonCDLessDevice(Adapter) == FALSE)) + (IsNonCDLessDevice(Adapter) == false)) SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End); break; case ISO_IMAGE2: if ((Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End != UNINIT_PTR_IN_CS) && - (IsNonCDLessDevice(Adapter) == FALSE)) + (IsNonCDLessDevice(Adapter) == false)) SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End); break; case DSD0: @@ -2810,6 +2749,7 @@ int BcmGetSectionValEndOffset(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_ case CONTROL_SECTION: /* Not Clear So Putting failure. confirm and fix it. */ SectEndOffset = STATUS_FAILURE; + break; case ISO_IMAGE1_PART2: if (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End != UNINIT_PTR_IN_CS) SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End); @@ -2830,14 +2770,14 @@ int BcmGetSectionValEndOffset(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_ SectEndOffset = INVALID_OFFSET; } - return SectEndOffset ; + return SectEndOffset; } /* * BcmFlash2xBulkRead:- Read API for Flash Map 2.x . * @Adapter :Driver Private Data Structure * @pBuffer : Buffer where data has to be put after reading - * @eFlashSectionVal :Flash Section Val defined in FLASH2X_SECTION_VAL + * @eFlashSectionVal :Flash Section Val defined in enum bcm_flash2x_section_val * @uiOffsetWithinSectionVal :- Offset with in provided section * @uiNumBytes : Number of Bytes for Read * @@ -2847,7 +2787,7 @@ int BcmGetSectionValEndOffset(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_ int BcmFlash2xBulkRead(struct bcm_mini_adapter *Adapter, PUINT pBuffer, - FLASH2X_SECTION_VAL eFlash2xSectionVal, + enum bcm_flash2x_section_val eFlash2xSectionVal, unsigned int uiOffsetWithinSectionVal, unsigned int uiNumBytes) { @@ -2872,7 +2812,7 @@ int BcmFlash2xBulkRead(struct bcm_mini_adapter *Adapter, SectionStartOffset = BcmGetSectionValStartOffset(Adapter, eFlash2xSectionVal); if (SectionStartOffset == STATUS_FAILURE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "This Section<%d> does not exixt in Flash 2.x Map ", eFlash2xSectionVal); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "This Section<%d> does not exist in Flash 2.x Map ", eFlash2xSectionVal); return -EINVAL; } @@ -2898,7 +2838,7 @@ int BcmFlash2xBulkRead(struct bcm_mini_adapter *Adapter, * BcmFlash2xBulkWrite :-API for Writing on the Flash Map 2.x. * @Adapter :Driver Private Data Structure * @pBuffer : Buffer From where data has to taken for writing - * @eFlashSectionVal :Flash Section Val defined in FLASH2X_SECTION_VAL + * @eFlashSectionVal :Flash Section Val defined in enum bcm_flash2x_section_val * @uiOffsetWithinSectionVal :- Offset with in provided section * @uiNumBytes : Number of Bytes for Write * @@ -2909,7 +2849,7 @@ int BcmFlash2xBulkRead(struct bcm_mini_adapter *Adapter, int BcmFlash2xBulkWrite(struct bcm_mini_adapter *Adapter, PUINT pBuffer, - FLASH2X_SECTION_VAL eFlash2xSectVal, + enum bcm_flash2x_section_val eFlash2xSectVal, unsigned int uiOffset, unsigned int uiNumBytes, unsigned int bVerify) @@ -2935,7 +2875,7 @@ int BcmFlash2xBulkWrite(struct bcm_mini_adapter *Adapter, FlashSectValStartOffset = BcmGetSectionValStartOffset(Adapter, eFlash2xSectVal); if (FlashSectValStartOffset == STATUS_FAILURE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "This Section<%d> does not exixt in Flash Map 2.x", eFlash2xSectVal); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "This Section<%d> does not exist in Flash Map 2.x", eFlash2xSectVal); return -EINVAL; } @@ -2965,13 +2905,13 @@ int BcmFlash2xBulkWrite(struct bcm_mini_adapter *Adapter, * @Adapter :-Drivers private Data Structure * * Return Value:- - * Return STATUS_SUCESS if get success in setting the right DSD else negaive error code + * Return STATUS_SUCESS if get success in setting the right DSD else negative error code * */ static int BcmGetActiveDSD(struct bcm_mini_adapter *Adapter) { - FLASH2X_SECTION_VAL uiHighestPriDSD = 0; + enum bcm_flash2x_section_val uiHighestPriDSD = 0; uiHighestPriDSD = getHighestPriDSD(Adapter); Adapter->eActiveDSD = uiHighestPriDSD; @@ -3036,11 +2976,11 @@ static int BcmGetActiveISO(struct bcm_mini_adapter *Adapter) * * Return Value:- * Success:-TRUE , offset is writable - * Failure:-FALSE, offset is RO + * Failure:-false, offset is RO * */ -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; @@ -3061,10 +3001,10 @@ B_UINT8 IsOffsetWritable(struct bcm_mini_adapter *Adapter, unsigned int uiOffset if (permissionBits == SECTOR_READWRITE_PERMISSION) return TRUE; else - return FALSE; + return false; } -static int BcmDumpFlash2xSectionBitMap(PFLASH2X_BITMAP psFlash2xBitMap) +static int BcmDumpFlash2xSectionBitMap(struct bcm_flash2x_bitmap *psFlash2xBitMap) { struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); @@ -3099,18 +3039,18 @@ static int BcmDumpFlash2xSectionBitMap(PFLASH2X_BITMAP psFlash2xBitMap) * Failure:- negative error code */ -int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, PFLASH2X_BITMAP psFlash2xBitMap) +int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, struct bcm_flash2x_bitmap *psFlash2xBitMap) { - PFLASH2X_CS_INFO psFlash2xCSInfo = Adapter->psFlash2xCSInfo; - FLASH2X_SECTION_VAL uiHighestPriDSD = 0; - FLASH2X_SECTION_VAL uiHighestPriISO = 0; - BOOLEAN SetActiveDSDDone = FALSE; - BOOLEAN SetActiveISODone = FALSE; + struct bcm_flash2x_cs_info *psFlash2xCSInfo = Adapter->psFlash2xCSInfo; + enum bcm_flash2x_section_val uiHighestPriDSD = 0; + enum bcm_flash2x_section_val uiHighestPriISO = 0; + bool SetActiveDSDDone = false; + bool SetActiveISODone = false; /* For 1.x map all the section except DSD0 will be shown as not present * This part will be used by calibration tool to detect the number of DSD present in Flash. */ - if (IsFlash2x(Adapter) == FALSE) { + if (IsFlash2x(Adapter) == false) { psFlash2xBitMap->ISO_IMAGE2 = 0; psFlash2xBitMap->ISO_IMAGE1 = 0; psFlash2xBitMap->DSD0 = FLASH2X_SECTION_VALID | FLASH2X_SECTION_ACT | FLASH2X_SECTION_PRESENT; /* 0xF; 0000(Reseved)1(Active)0(RW)1(valid)1(present) */ @@ -3142,10 +3082,10 @@ int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, PFLASH2X_BITM psFlash2xBitMap->ISO_IMAGE2 |= FLASH2X_SECTION_VALID; /* Calculation for extrating the Access permission */ - if (IsSectionWritable(Adapter, ISO_IMAGE2) == FALSE) + if (IsSectionWritable(Adapter, ISO_IMAGE2) == false) psFlash2xBitMap->ISO_IMAGE2 |= FLASH2X_SECTION_RO; - if (SetActiveISODone == FALSE && uiHighestPriISO == ISO_IMAGE2) { + if (SetActiveISODone == false && uiHighestPriISO == ISO_IMAGE2) { psFlash2xBitMap->ISO_IMAGE2 |= FLASH2X_SECTION_ACT; SetActiveISODone = TRUE; } @@ -3162,10 +3102,10 @@ int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, PFLASH2X_BITM psFlash2xBitMap->ISO_IMAGE1 |= FLASH2X_SECTION_VALID; /* Calculation for extrating the Access permission */ - if (IsSectionWritable(Adapter, ISO_IMAGE1) == FALSE) + if (IsSectionWritable(Adapter, ISO_IMAGE1) == false) psFlash2xBitMap->ISO_IMAGE1 |= FLASH2X_SECTION_RO; - if (SetActiveISODone == FALSE && uiHighestPriISO == ISO_IMAGE1) { + if (SetActiveISODone == false && uiHighestPriISO == ISO_IMAGE1) { psFlash2xBitMap->ISO_IMAGE1 |= FLASH2X_SECTION_ACT; SetActiveISODone = TRUE; } @@ -3182,11 +3122,11 @@ int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, PFLASH2X_BITM psFlash2xBitMap->DSD2 |= FLASH2X_SECTION_VALID; /* Calculation for extrating the Access permission */ - if (IsSectionWritable(Adapter, DSD2) == FALSE) { + if (IsSectionWritable(Adapter, DSD2) == false) { psFlash2xBitMap->DSD2 |= FLASH2X_SECTION_RO; } else { /* Means section is writable */ - if ((SetActiveDSDDone == FALSE) && (uiHighestPriDSD == DSD2)) { + if ((SetActiveDSDDone == false) && (uiHighestPriDSD == DSD2)) { psFlash2xBitMap->DSD2 |= FLASH2X_SECTION_ACT; SetActiveDSDDone = TRUE; } @@ -3204,11 +3144,11 @@ int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, PFLASH2X_BITM psFlash2xBitMap->DSD1 |= FLASH2X_SECTION_VALID; /* Calculation for extrating the Access permission */ - if (IsSectionWritable(Adapter, DSD1) == FALSE) { + if (IsSectionWritable(Adapter, DSD1) == false) { psFlash2xBitMap->DSD1 |= FLASH2X_SECTION_RO; } else { /* Means section is writable */ - if ((SetActiveDSDDone == FALSE) && (uiHighestPriDSD == DSD1)) { + if ((SetActiveDSDDone == false) && (uiHighestPriDSD == DSD1)) { psFlash2xBitMap->DSD1 |= FLASH2X_SECTION_ACT; SetActiveDSDDone = TRUE; } @@ -3226,11 +3166,11 @@ int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, PFLASH2X_BITM psFlash2xBitMap->DSD0 |= FLASH2X_SECTION_VALID; /* Setting Access permission */ - if (IsSectionWritable(Adapter, DSD0) == FALSE) { + if (IsSectionWritable(Adapter, DSD0) == false) { psFlash2xBitMap->DSD0 |= FLASH2X_SECTION_RO; } else { /* Means section is writable */ - if ((SetActiveDSDDone == FALSE) && (uiHighestPriDSD == DSD0)) { + if ((SetActiveDSDDone == false) && (uiHighestPriDSD == DSD0)) { psFlash2xBitMap->DSD0 |= FLASH2X_SECTION_ACT; SetActiveDSDDone = TRUE; } @@ -3248,7 +3188,7 @@ int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, PFLASH2X_BITM psFlash2xBitMap->VSA0 |= FLASH2X_SECTION_VALID; /* Calculation for extrating the Access permission */ - if (IsSectionWritable(Adapter, VSA0) == FALSE) + if (IsSectionWritable(Adapter, VSA0) == false) psFlash2xBitMap->VSA0 |= FLASH2X_SECTION_RO; /* By Default section is Active */ @@ -3266,7 +3206,7 @@ int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, PFLASH2X_BITM psFlash2xBitMap->VSA1 |= FLASH2X_SECTION_VALID; /* Checking For Access permission */ - if (IsSectionWritable(Adapter, VSA1) == FALSE) + if (IsSectionWritable(Adapter, VSA1) == false) psFlash2xBitMap->VSA1 |= FLASH2X_SECTION_RO; /* By Default section is Active */ @@ -3284,7 +3224,7 @@ int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, PFLASH2X_BITM psFlash2xBitMap->VSA2 |= FLASH2X_SECTION_VALID; /* Checking For Access permission */ - if (IsSectionWritable(Adapter, VSA2) == FALSE) + if (IsSectionWritable(Adapter, VSA2) == false) psFlash2xBitMap->VSA2 |= FLASH2X_SECTION_RO; /* By Default section is Active */ @@ -3302,7 +3242,7 @@ int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, PFLASH2X_BITM psFlash2xBitMap->SCSI |= FLASH2X_SECTION_VALID; /* Checking For Access permission */ - if (IsSectionWritable(Adapter, SCSI) == FALSE) + if (IsSectionWritable(Adapter, SCSI) == false) psFlash2xBitMap->SCSI |= FLASH2X_SECTION_RO; /* By Default section is Active */ @@ -3320,7 +3260,7 @@ int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, PFLASH2X_BITM psFlash2xBitMap->CONTROL_SECTION |= FLASH2X_SECTION_VALID; /* Checking For Access permission */ - if (IsSectionWritable(Adapter, CONTROL_SECTION) == FALSE) + if (IsSectionWritable(Adapter, CONTROL_SECTION) == false) psFlash2xBitMap->CONTROL_SECTION |= FLASH2X_SECTION_RO; /* By Default section is Active */ @@ -3349,15 +3289,15 @@ int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, PFLASH2X_BITM * */ -int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlash2xSectVal) +int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectVal) { unsigned int SectImagePriority = 0; int Status = STATUS_SUCCESS; - /* DSD_HEADER sDSD = {0}; - * ISO_HEADER sISO = {0}; + /* struct bcm_dsd_header sDSD = {0}; + * struct bcm_iso_header sISO = {0}; */ - int HighestPriDSD = 0 ; + int HighestPriDSD = 0; int HighestPriISO = 0; Status = IsSectionWritable(Adapter, eFlash2xSectVal); @@ -3391,7 +3331,7 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eF Status = BcmFlash2xBulkWrite(Adapter, &SectImagePriority, HighestPriISO, - 0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImagePriority), + 0 + FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImagePriority), SIGNATURE_SIZE, TRUE); if (Status) { @@ -3416,7 +3356,7 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eF Status = BcmFlash2xBulkWrite(Adapter, &SectImagePriority, eFlash2xSectVal, - 0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImagePriority), + 0 + FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImagePriority), SIGNATURE_SIZE, TRUE); if (Status) { @@ -3434,7 +3374,7 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eF 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; @@ -3452,7 +3392,7 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eF Status = BcmFlash2xBulkWrite(Adapter, &SectImagePriority, HighestPriDSD, - Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImagePriority), + Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImagePriority), SIGNATURE_SIZE, TRUE); if (Status) { @@ -3462,7 +3402,7 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eF 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; @@ -3472,7 +3412,7 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eF Status = BcmFlash2xBulkWrite(Adapter, &SectImagePriority, HighestPriDSD, - Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImagePriority), + Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImagePriority), SIGNATURE_SIZE, TRUE); if (Status) { @@ -3481,7 +3421,7 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eF } HighestPriDSD = getHighestPriDSD(Adapter); - if ((HighestPriDSD == eFlash2xSectVal)) { + if (HighestPriDSD == eFlash2xSectVal) { Status = STATUS_SUCCESS; break; } @@ -3492,7 +3432,7 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eF Status = BcmFlash2xBulkWrite(Adapter, &SectImagePriority, eFlash2xSectVal, - Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImagePriority), + Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImagePriority), SIGNATURE_SIZE, TRUE); if (Status) { @@ -3516,7 +3456,7 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eF break; } - Adapter->bHeaderChangeAllowed = FALSE; + Adapter->bHeaderChangeAllowed = false; return Status; } @@ -3529,13 +3469,13 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eF * */ -int BcmCopyISO(struct bcm_mini_adapter *Adapter, FLASH2X_COPY_SECTION sCopySectStrut) +int BcmCopyISO(struct bcm_mini_adapter *Adapter, struct bcm_flash2x_copy_section sCopySectStrut) { PCHAR Buff = NULL; - FLASH2X_SECTION_VAL eISOReadPart = 0, eISOWritePart = 0; + enum bcm_flash2x_section_val eISOReadPart = 0, eISOWritePart = 0; unsigned int uiReadOffsetWithinPart = 0, uiWriteOffsetWithinPart = 0; unsigned int uiTotalDataToCopy = 0; - BOOLEAN IsThisHeaderSector = FALSE; + bool IsThisHeaderSector = false; unsigned int sigOffset = 0; unsigned int ISOLength = 0; unsigned int Status = STATUS_SUCCESS; @@ -3550,7 +3490,7 @@ int BcmCopyISO(struct bcm_mini_adapter *Adapter, FLASH2X_COPY_SECTION sCopySectS Status = BcmFlash2xBulkRead(Adapter, &ISOLength, sCopySectStrut.SrcSection, - 0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImageSize), + 0 + FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImageSize), 4); if (Status) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Read failed while copying ISO\n"); @@ -3561,7 +3501,7 @@ int BcmCopyISO(struct bcm_mini_adapter *Adapter, FLASH2X_COPY_SECTION sCopySectS if (ISOLength % Adapter->uiSectorSize) ISOLength = Adapter->uiSectorSize * (1 + ISOLength/Adapter->uiSectorSize); - sigOffset = FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImageMagicNumber); + sigOffset = FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImageMagicNumber); Buff = kzalloc(Adapter->uiSectorSize, GFP_KERNEL); @@ -3668,14 +3608,14 @@ int BcmCopyISO(struct bcm_mini_adapter *Adapter, FLASH2X_COPY_SECTION sCopySectS break; } - Adapter->bHeaderChangeAllowed = FALSE; + Adapter->bHeaderChangeAllowed = false; if (IsThisHeaderSector == TRUE) { WriteToFlashWithoutSectorErase(Adapter, SigBuff, eISOWritePart, sigOffset, MAX_RW_SIZE); - IsThisHeaderSector = FALSE; + IsThisHeaderSector = false; } /* subtracting the written Data */ uiTotalDataToCopy = uiTotalDataToCopy - Adapter->uiSectorSize; @@ -3781,7 +3721,7 @@ int BcmCopyISO(struct bcm_mini_adapter *Adapter, FLASH2X_COPY_SECTION sCopySectS break; } - Adapter->bHeaderChangeAllowed = FALSE; + Adapter->bHeaderChangeAllowed = false; if (IsThisHeaderSector == TRUE) { WriteToFlashWithoutSectorErase(Adapter, SigBuff, @@ -3789,7 +3729,7 @@ int BcmCopyISO(struct bcm_mini_adapter *Adapter, FLASH2X_COPY_SECTION sCopySectS sigOffset, MAX_RW_SIZE); - IsThisHeaderSector = FALSE; + IsThisHeaderSector = false; } /* subtracting the written Data */ @@ -3813,7 +3753,7 @@ out: * Failure :-Return negative error code */ -int BcmFlash2xCorruptSig(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal) +int BcmFlash2xCorruptSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectionVal) { int Status = STATUS_SUCCESS; @@ -3841,19 +3781,19 @@ int BcmFlash2xCorruptSig(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL e * Failure :-Return negative error code */ -int BcmFlash2xWriteSig(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlashSectionVal) +int BcmFlash2xWriteSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlashSectionVal) { unsigned int uiSignature = 0; unsigned int uiOffset = 0; - /* DSD_HEADER dsdHeader = {0}; */ - if (Adapter->bSigCorrupted == FALSE) { + /* struct bcm_dsd_header dsdHeader = {0}; */ + if (Adapter->bSigCorrupted == false) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Signature is not corrupted by driver, hence not restoring\n"); return STATUS_SUCCESS; } - if (Adapter->bAllDSDWriteAllow == FALSE) { - if (IsSectionWritable(Adapter, eFlashSectionVal) == FALSE) { + if (Adapter->bAllDSDWriteAllow == false) { + if (IsSectionWritable(Adapter, eFlashSectionVal) == false) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section is not Writable...Hence can't Write signature"); return SECTOR_IS_NOT_WRITABLE; } @@ -3863,7 +3803,7 @@ int BcmFlash2xWriteSig(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFl uiSignature = htonl(DSD_IMAGE_MAGIC_NUMBER); uiOffset = Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader; - uiOffset += FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImageMagicNumber); + uiOffset += FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImageMagicNumber); if ((ReadDSDSignature(Adapter, eFlashSectionVal) & 0xFF000000) != CORRUPTED_PATTERN) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Corrupted Pattern is not there. Hence won't write sig"); @@ -3872,7 +3812,7 @@ int BcmFlash2xWriteSig(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFl } else if ((eFlashSectionVal == ISO_IMAGE1) || (eFlashSectionVal == ISO_IMAGE2)) { uiSignature = htonl(ISO_IMAGE_MAGIC_NUMBER); /* uiOffset = 0; */ - uiOffset = FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImageMagicNumber); + uiOffset = FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImageMagicNumber); if ((ReadISOSignature(Adapter, eFlashSectionVal) & 0xFF000000) != CORRUPTED_PATTERN) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Currupted Pattern is not there. Hence won't write sig"); return STATUS_FAILURE; @@ -3885,9 +3825,9 @@ int BcmFlash2xWriteSig(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFl BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Restoring the signature"); Adapter->bHeaderChangeAllowed = TRUE; - Adapter->bSigCorrupted = FALSE; + Adapter->bSigCorrupted = false; BcmFlash2xBulkWrite(Adapter, &uiSignature, eFlashSectionVal, uiOffset, SIGNATURE_SIZE, TRUE); - Adapter->bHeaderChangeAllowed = FALSE; + Adapter->bHeaderChangeAllowed = false; return STATUS_SUCCESS; } @@ -3898,10 +3838,10 @@ int BcmFlash2xWriteSig(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFl * @Adapater :- Bcm Driver Private Data Structure * @psFlash2xReadWrite :-Flash2x Read/write structure pointer * - * Return values:-Return TRUE is request is valid else FALSE. + * Return values:-Return TRUE is request is valid else false. */ -int validateFlash2xReadWrite(struct bcm_mini_adapter *Adapter, PFLASH2X_READWRITE psFlash2xReadWrite) +int validateFlash2xReadWrite(struct bcm_mini_adapter *Adapter, struct bcm_flash2x_readwrite *psFlash2xReadWrite) { unsigned int uiNumOfBytes = 0; unsigned int uiSectStartOffset = 0; @@ -3910,8 +3850,8 @@ int validateFlash2xReadWrite(struct bcm_mini_adapter *Adapter, PFLASH2X_READWRIT uiNumOfBytes = psFlash2xReadWrite->numOfBytes; if (IsSectionExistInFlash(Adapter, psFlash2xReadWrite->Section) != TRUE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section<%x> does not exixt in Flash", psFlash2xReadWrite->Section); - return FALSE; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section<%x> does not exist in Flash", psFlash2xReadWrite->Section); + return false; } uiSectStartOffset = BcmGetSectionValStartOffset(Adapter, psFlash2xReadWrite->Section); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Start offset :%x ,section :%d\n", uiSectStartOffset, psFlash2xReadWrite->Section); @@ -3943,12 +3883,21 @@ int validateFlash2xReadWrite(struct bcm_mini_adapter *Adapter, PFLASH2X_READWRIT BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "End offset :%x\n", uiSectEndOffset); + /* psFlash2xReadWrite->offset and uiNumOfBytes are user controlled and can lead to integer overflows */ + if (psFlash2xReadWrite->offset > uiSectEndOffset) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Invalid Request...."); + return false; + } + if (uiNumOfBytes > uiSectEndOffset) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Invalid Request...."); + return false; + } /* Checking the boundary condition */ if ((uiSectStartOffset + psFlash2xReadWrite->offset + uiNumOfBytes) <= uiSectEndOffset) return TRUE; else { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Invalid Request...."); - return FALSE; + return false; } } @@ -3965,7 +3914,7 @@ int IsFlash2x(struct bcm_mini_adapter *Adapter) if (Adapter->uiFlashLayoutMajorVersion >= FLASH_2X_MAJOR_NUMBER) return TRUE; else - return FALSE; + return false; } /* @@ -3985,7 +3934,7 @@ static int GetFlashBaseAddr(struct bcm_mini_adapter *Adapter) * For All Valid Flash Versions... except 1.1, take the value from FlashBaseAddr * In case of Raw Read... use the default value */ - if (Adapter->uiFlashLayoutMajorVersion && (Adapter->bFlashRawRead == FALSE) && + if (Adapter->uiFlashLayoutMajorVersion && (Adapter->bFlashRawRead == false) && !((Adapter->uiFlashLayoutMajorVersion == 1) && (Adapter->uiFlashLayoutMinorVersion == 1))) uiBaseAddr = Adapter->uiFlashBaseAdd; else @@ -3995,7 +3944,7 @@ static int GetFlashBaseAddr(struct bcm_mini_adapter *Adapter) * For All Valid Flash Versions... except 1.1, take the value from FlashBaseAddr * In case of Raw Read... use the default value */ - if (Adapter->uiFlashLayoutMajorVersion && (Adapter->bFlashRawRead == FALSE) && + if (Adapter->uiFlashLayoutMajorVersion && (Adapter->bFlashRawRead == false) && !((Adapter->uiFlashLayoutMajorVersion == 1) && (Adapter->uiFlashLayoutMinorVersion == 1))) uiBaseAddr = Adapter->uiFlashBaseAdd | FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT; else @@ -4021,8 +3970,8 @@ static int GetFlashBaseAddr(struct bcm_mini_adapter *Adapter) */ int BcmCopySection(struct bcm_mini_adapter *Adapter, - FLASH2X_SECTION_VAL SrcSection, - FLASH2X_SECTION_VAL DstSection, + enum bcm_flash2x_section_val SrcSection, + enum bcm_flash2x_section_val DstSection, unsigned int offset, unsigned int numOfBytes) { @@ -4073,7 +4022,7 @@ int BcmCopySection(struct bcm_mini_adapter *Adapter, else BuffSize = numOfBytes; - pBuff = (PCHAR)kzalloc(BuffSize, GFP_KERNEL); + pBuff = kzalloc(BuffSize, GFP_KERNEL); if (!pBuff) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Memory allocation failed.. "); return -ENOMEM; @@ -4093,7 +4042,7 @@ int BcmCopySection(struct bcm_mini_adapter *Adapter, BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Read failed at offset :%d for NOB :%d", SrcSection, BytesToBeCopied); break; } - Status = BcmFlash2xBulkWrite(Adapter, (PUINT)pBuff, DstSection, offset, BytesToBeCopied, FALSE); + Status = BcmFlash2xBulkWrite(Adapter, (PUINT)pBuff, DstSection, offset, BytesToBeCopied, false); if (Status) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Write failed at offset :%d for NOB :%d", DstSection, BytesToBeCopied); break; @@ -4109,7 +4058,7 @@ int BcmCopySection(struct bcm_mini_adapter *Adapter, } while (numOfBytes > 0); kfree(pBuff); - Adapter->bHeaderChangeAllowed = FALSE; + Adapter->bHeaderChangeAllowed = false; return Status; } @@ -4125,10 +4074,10 @@ 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; - BOOLEAN bHasHeader = FALSE; + bool bHasHeader = false; PUCHAR pTempBuff = NULL; unsigned int uiSectAlignAddr = 0; unsigned int sig = 0; @@ -4141,19 +4090,19 @@ int SaveHeaderIfPresent(struct bcm_mini_adapter *Adapter, PUCHAR pBuff, unsigned (uiSectAlignAddr == BcmGetSectionValEndOffset(Adapter, DSD0) - Adapter->uiSectorSize)) { /* offset from the sector boundary having the header map */ offsetToProtect = Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader % Adapter->uiSectorSize; - HeaderSizeToProtect = sizeof(DSD_HEADER); + HeaderSizeToProtect = sizeof(struct bcm_dsd_header); bHasHeader = TRUE; } if (uiSectAlignAddr == BcmGetSectionValStartOffset(Adapter, ISO_IMAGE1) || uiSectAlignAddr == BcmGetSectionValStartOffset(Adapter, ISO_IMAGE2)) { offsetToProtect = 0; - HeaderSizeToProtect = sizeof(ISO_HEADER); + HeaderSizeToProtect = sizeof(struct bcm_iso_header); bHasHeader = TRUE; } /* If Header is present overwrite passed buffer with this */ - if (bHasHeader && (Adapter->bHeaderChangeAllowed == FALSE)) { - pTempBuff = (PUCHAR)kzalloc(HeaderSizeToProtect, GFP_KERNEL); + if (bHasHeader && (Adapter->bHeaderChangeAllowed == false)) { + pTempBuff = kzalloc(HeaderSizeToProtect, GFP_KERNEL); if (!pTempBuff) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Memory allocation failed"); return -ENOMEM; @@ -4167,17 +4116,17 @@ int SaveHeaderIfPresent(struct bcm_mini_adapter *Adapter, PUCHAR pBuff, unsigned kfree(pTempBuff); } if (bHasHeader && Adapter->bSigCorrupted) { - sig = *((PUINT)(pBuff + offsetToProtect + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImageMagicNumber))); + sig = *((PUINT)(pBuff + offsetToProtect + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImageMagicNumber))); sig = ntohl(sig); if ((sig & 0xFF000000) != CORRUPTED_PATTERN) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Desired pattern is not at sig offset. Hence won't restore"); - Adapter->bSigCorrupted = FALSE; + Adapter->bSigCorrupted = false; return STATUS_SUCCESS; } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, " Corrupted sig is :%X", sig); - *((PUINT)(pBuff + offsetToProtect + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImageMagicNumber))) = htonl(DSD_IMAGE_MAGIC_NUMBER); + *((PUINT)(pBuff + offsetToProtect + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImageMagicNumber))) = htonl(DSD_IMAGE_MAGIC_NUMBER); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Restoring the signature in Header Write only"); - Adapter->bSigCorrupted = FALSE; + Adapter->bSigCorrupted = false; } return STATUS_SUCCESS; @@ -4264,11 +4213,11 @@ static int BcmDoChipSelect(struct bcm_mini_adapter *Adapter, unsigned int offset return STATUS_SUCCESS; } -int ReadDSDSignature(struct bcm_mini_adapter *Adapter, 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; - * DSD_HEADER dsdHeader = {0}; + * struct bcm_dsd_header dsdHeader = {0}; */ /* sigoffsetInMap =(PUCHAR)&(dsdHeader.DSDImageMagicNumber) -(PUCHAR)&dsdHeader; */ @@ -4280,7 +4229,7 @@ int ReadDSDSignature(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL dsd) BcmFlash2xBulkRead(Adapter, &uiDSDsig, dsd, - Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImageMagicNumber), + Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImageMagicNumber), SIGNATURE_SIZE); uiDSDsig = ntohl(uiDSDsig); @@ -4289,11 +4238,11 @@ int ReadDSDSignature(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL dsd) return uiDSDsig; } -int ReadDSDPriority(struct bcm_mini_adapter *Adapter, 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; - /* DSD_HEADER dsdHeader = {0}; + /* struct bcm_dsd_header dsdHeader = {0}; * priOffsetInMap = (PUCHAR)&(dsdHeader.DSDImagePriority) -(PUCHAR)&dsdHeader; */ if (IsSectionWritable(Adapter, dsd)) { @@ -4301,7 +4250,7 @@ int ReadDSDPriority(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL dsd) BcmFlash2xBulkRead(Adapter, &uiDSDPri, dsd, - Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImagePriority), + Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImagePriority), 4); uiDSDPri = ntohl(uiDSDPri); @@ -4312,11 +4261,11 @@ int ReadDSDPriority(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL dsd) return uiDSDPri; } -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; - FLASH2X_SECTION_VAL HighestPriDSD = 0; + enum bcm_flash2x_section_val HighestPriDSD = 0; if (IsSectionWritable(Adapter, DSD2)) { DSDHighestPri = ReadDSDPriority(Adapter, DSD2); @@ -4344,11 +4293,11 @@ FLASH2X_SECTION_VAL getHighestPriDSD(struct bcm_mini_adapter *Adapter) return HighestPriDSD; } -int ReadISOSignature(struct bcm_mini_adapter *Adapter, 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; - * ISO_HEADER ISOHeader = {0}; + * struct bcm_iso_header ISOHeader = {0}; * sigoffsetInMap =(PUCHAR)&(ISOHeader.ISOImageMagicNumber) -(PUCHAR)&ISOHeader; */ if (iso != ISO_IMAGE1 && iso != ISO_IMAGE2) { @@ -4358,7 +4307,7 @@ int ReadISOSignature(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL iso) BcmFlash2xBulkRead(Adapter, &uiISOsig, iso, - 0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImageMagicNumber), + 0 + FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImageMagicNumber), SIGNATURE_SIZE); uiISOsig = ntohl(uiISOsig); @@ -4367,7 +4316,7 @@ int ReadISOSignature(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL iso) return uiISOsig; } -int ReadISOPriority(struct bcm_mini_adapter *Adapter, 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)) { @@ -4375,7 +4324,7 @@ int ReadISOPriority(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL iso) BcmFlash2xBulkRead(Adapter, &ISOPri, iso, - 0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImagePriority), + 0 + FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImagePriority), 4); ISOPri = ntohl(ISOPri); @@ -4386,11 +4335,11 @@ int ReadISOPriority(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL iso) return ISOPri; } -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; - FLASH2X_SECTION_VAL HighestPriISO = NO_SECTION_VAL; + enum bcm_flash2x_section_val HighestPriISO = NO_SECTION_VAL; if (IsSectionWritable(Adapter, ISO_IMAGE2)) { ISOHighestPri = ReadISOPriority(Adapter, ISO_IMAGE2); @@ -4410,9 +4359,9 @@ 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, - FLASH2X_SECTION_VAL eFlash2xSectionVal, + enum bcm_flash2x_section_val eFlash2xSectionVal, unsigned int uiOffset, unsigned int uiNumBytes) { @@ -4449,7 +4398,7 @@ int WriteToFlashWithoutSectorErase(struct bcm_mini_adapter *Adapter, BcmDoChipSelect(Adapter, uiOffset); uiPartOffset = (uiOffset & (FLASH_PART_SIZE - 1)) + GetFlashBaseAddr(Adapter); - for (i = 0 ; i < uiNumBytes; i += Adapter->ulFlashWriteSize) { + for (i = 0; i < uiNumBytes; i += Adapter->ulFlashWriteSize) { if (Adapter->ulFlashWriteSize == BYTE_WRITE_SUPPORT) Status = flashByteWrite(Adapter, uiPartOffset, pcBuff); else @@ -4468,19 +4417,19 @@ int WriteToFlashWithoutSectorErase(struct bcm_mini_adapter *Adapter, return Status; } -BOOLEAN IsSectionExistInFlash(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL section) +bool IsSectionExistInFlash(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val section) { - BOOLEAN SectionPresent = FALSE; + bool SectionPresent = false; switch (section) { case ISO_IMAGE1: if ((Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start != UNINIT_PTR_IN_CS) && - (IsNonCDLessDevice(Adapter) == FALSE)) + (IsNonCDLessDevice(Adapter) == false)) SectionPresent = TRUE; break; case ISO_IMAGE2: if ((Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start != UNINIT_PTR_IN_CS) && - (IsNonCDLessDevice(Adapter) == FALSE)) + (IsNonCDLessDevice(Adapter) == false)) SectionPresent = TRUE; break; case DSD0: @@ -4517,26 +4466,26 @@ BOOLEAN IsSectionExistInFlash(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_ break; default: BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section Does not exist in Flash 2.x"); - SectionPresent = FALSE; + SectionPresent = false; } return SectionPresent; } -int IsSectionWritable(struct bcm_mini_adapter *Adapter, 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; + int Status = false; - if (IsSectionExistInFlash(Adapter, Section) == FALSE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section <%d> does not exixt", Section); - return FALSE; + if (IsSectionExistInFlash(Adapter, Section) == false) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section <%d> does not exist", Section); + return false; } offset = BcmGetSectionValStartOffset(Adapter, Section); if (offset == INVALID_OFFSET) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section<%d> does not exixt", Section); - return FALSE; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section<%d> does not exist", Section); + return false; } if (IsSectionExistInVendorInfo(Adapter, Section)) @@ -4546,7 +4495,7 @@ int IsSectionWritable(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL Sect return Status; } -static int CorruptDSDSig(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal) +static int CorruptDSDSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectionVal) { PUCHAR pBuff = NULL; unsigned int sig = 0; @@ -4554,21 +4503,21 @@ static int CorruptDSDSig(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL e unsigned int BlockStatus = 0; unsigned int uiSectAlignAddr = 0; - Adapter->bSigCorrupted = FALSE; - if (Adapter->bAllDSDWriteAllow == FALSE) { + Adapter->bSigCorrupted = false; + if (Adapter->bAllDSDWriteAllow == false) { if (IsSectionWritable(Adapter, eFlash2xSectionVal) != TRUE) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section is not Writable...Hence can't Corrupt signature"); return SECTOR_IS_NOT_WRITABLE; } } - pBuff = (PUCHAR)kzalloc(MAX_RW_SIZE, GFP_KERNEL); + pBuff = kzalloc(MAX_RW_SIZE, GFP_KERNEL); if (!pBuff) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Can't allocate memorey"); return -ENOMEM; } - uiOffset = Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER); + uiOffset = Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(struct bcm_dsd_header); uiOffset -= MAX_RW_SIZE; BcmFlash2xBulkRead(Adapter, (PUINT)pBuff, eFlash2xSectionVal, uiOffset, MAX_RW_SIZE); @@ -4608,20 +4557,20 @@ static int CorruptDSDSig(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL e return STATUS_SUCCESS; } -static int CorruptISOSig(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal) +static int CorruptISOSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectionVal) { PUCHAR pBuff = NULL; unsigned int sig = 0; unsigned int uiOffset = 0; - Adapter->bSigCorrupted = FALSE; + Adapter->bSigCorrupted = false; if (IsSectionWritable(Adapter, eFlash2xSectionVal) != TRUE) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section is not Writable...Hence can't Corrupt signature"); return SECTOR_IS_NOT_WRITABLE; } - pBuff = (PUCHAR)kzalloc(MAX_RW_SIZE, GFP_KERNEL); + pBuff = kzalloc(MAX_RW_SIZE, GFP_KERNEL); if (!pBuff) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Can't allocate memorey"); return -ENOMEM; @@ -4655,10 +4604,10 @@ static int CorruptISOSig(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL e return STATUS_SUCCESS; } -BOOLEAN IsNonCDLessDevice(struct bcm_mini_adapter *Adapter) +bool IsNonCDLessDevice(struct bcm_mini_adapter *Adapter) { if (Adapter->psFlash2xCSInfo->IsCDLessDeviceBootSig == NON_CDLESS_DEVICE_BOOT_SIG) return TRUE; else - return FALSE; + return false; } diff --git a/drivers/staging/bcm/nvm.h b/drivers/staging/bcm/nvm.h index 651b5a455b3..e765cca5d96 100644 --- a/drivers/staging/bcm/nvm.h +++ b/drivers/staging/bcm/nvm.h @@ -1,409 +1,286 @@ /*************************************************************************************** -// -// Copyright (c) Beceem Communications Inc. -// -// Module Name: -// NVM.h -// -// Abstract: -// This file has the prototypes,preprocessors and definitions various NVM libraries. -// -// -// Revision History: -// Who When What -// -------- -------- ---------------------------------------------- -// Name Date Created/reviewed/modified -// -// Notes: -// -****************************************************************************************/ - + * + * Copyright (c) Beceem Communications Inc. + * + * Module Name: + * NVM.h + * + * Abstract: + * This file has the prototypes,preprocessors and definitions various NVM libraries. + * + * + * Revision History: + * Who When What + * -------- -------- ---------------------------------------------- + * Name Date Created/reviewed/modified + * + * Notes: + * + ****************************************************************************************/ #ifndef _NVM_H_ #define _NVM_H_ -typedef struct _FLASH_SECTOR_INFO -{ - UINT uiSectorSig; - UINT uiSectorSize; - -}FLASH_SECTOR_INFO,*PFLASH_SECTOR_INFO; - -typedef struct _FLASH_CS_INFO -{ - B_UINT32 MagicNumber; -// let the magic number be 0xBECE-F1A5 - F1A5 for "flas-h" - - B_UINT32 FlashLayoutVersion ; - - // ISO Image/Format/BuildTool versioning - B_UINT32 ISOImageVersion; - - // SCSI/Flash BootLoader versioning - B_UINT32 SCSIFirmwareVersion; - - - B_UINT32 OffsetFromZeroForPart1ISOImage; -// typically 0 - - B_UINT32 OffsetFromZeroForScsiFirmware; -//typically at 12MB - - B_UINT32 SizeOfScsiFirmware ; -//size of the firmware - depends on binary size - - B_UINT32 OffsetFromZeroForPart2ISOImage; -// typically at first Word Aligned offset 12MB + sizeOfScsiFirmware. - - B_UINT32 OffsetFromZeroForCalibrationStart; -// typically at 15MB - - B_UINT32 OffsetFromZeroForCalibrationEnd; - -// VSA0 offsets - B_UINT32 OffsetFromZeroForVSAStart; - B_UINT32 OffsetFromZeroForVSAEnd; - -// Control Section offsets - B_UINT32 OffsetFromZeroForControlSectionStart; - B_UINT32 OffsetFromZeroForControlSectionData; - -// NO Data Activity timeout to switch from MSC to NW Mode - B_UINT32 CDLessInactivityTimeout; - -// New ISO Image Signature - B_UINT32 NewImageSignature; - -// Signature to validate the sector size. - B_UINT32 FlashSectorSizeSig; - -// Sector Size - B_UINT32 FlashSectorSize; - -// Write Size Support - B_UINT32 FlashWriteSupportSize; - -// Total Flash Size - B_UINT32 TotalFlashSize; - -// Flash Base Address for offset specified - B_UINT32 FlashBaseAddr; - -// Flash Part Max Size - B_UINT32 FlashPartMaxSize; - -// Is CDLess or Flash Bootloader - B_UINT32 IsCDLessDeviceBootSig; - -// MSC Timeout after reset to switch from MSC to NW Mode - B_UINT32 MassStorageTimeout; - - -}FLASH_CS_INFO,*PFLASH_CS_INFO; - -#define FLASH2X_TOTAL_SIZE (64*1024*1024) -#define DEFAULT_SECTOR_SIZE (64*1024) - -typedef struct _FLASH_2X_CS_INFO -{ - - // magic number as 0xBECE-F1A5 - F1A5 for "flas-h" - B_UINT32 MagicNumber; - - B_UINT32 FlashLayoutVersion ; - - // ISO Image/Format/BuildTool versioning - B_UINT32 ISOImageVersion; - - // SCSI/Flash BootLoader versioning - B_UINT32 SCSIFirmwareVersion; - - // ISO Image1 Part1/SCSI Firmware/Flash Bootloader Start offset, size - B_UINT32 OffsetFromZeroForPart1ISOImage; - B_UINT32 OffsetFromZeroForScsiFirmware; - B_UINT32 SizeOfScsiFirmware ; - - // ISO Image1 Part2 start offset - B_UINT32 OffsetFromZeroForPart2ISOImage; - - - // DSD0 offset - B_UINT32 OffsetFromZeroForDSDStart; - B_UINT32 OffsetFromZeroForDSDEnd; - - // VSA0 offset - B_UINT32 OffsetFromZeroForVSAStart; - B_UINT32 OffsetFromZeroForVSAEnd; - - // Control Section offset - B_UINT32 OffsetFromZeroForControlSectionStart; - B_UINT32 OffsetFromZeroForControlSectionData; - - // NO Data Activity timeout to switch from MSC to NW Mode - B_UINT32 CDLessInactivityTimeout; - - // New ISO Image Signature - B_UINT32 NewImageSignature; - - B_UINT32 FlashSectorSizeSig; // Sector Size Signature - B_UINT32 FlashSectorSize; // Sector Size - B_UINT32 FlashWriteSupportSize; // Write Size Support - - B_UINT32 TotalFlashSize; // Total Flash Size - - // Flash Base Address for offset specified - B_UINT32 FlashBaseAddr; - B_UINT32 FlashPartMaxSize; // Flash Part Max Size - - // Is CDLess or Flash Bootloader - B_UINT32 IsCDLessDeviceBootSig; - - // MSC Timeout after reset to switch from MSC to NW Mode - B_UINT32 MassStorageTimeout; - +struct bcm_flash_cs_info { + u32 MagicNumber; + /* let the magic number be 0xBECE-F1A5 - F1A5 for "flas-h" */ + u32 FlashLayoutVersion; + u32 ISOImageVersion; + u32 SCSIFirmwareVersion; + u32 OffsetFromZeroForPart1ISOImage; + u32 OffsetFromZeroForScsiFirmware; + u32 SizeOfScsiFirmware; + u32 OffsetFromZeroForPart2ISOImage; + u32 OffsetFromZeroForCalibrationStart; + u32 OffsetFromZeroForCalibrationEnd; + u32 OffsetFromZeroForVSAStart; + u32 OffsetFromZeroForVSAEnd; + u32 OffsetFromZeroForControlSectionStart; + u32 OffsetFromZeroForControlSectionData; + u32 CDLessInactivityTimeout; + u32 NewImageSignature; + u32 FlashSectorSizeSig; + u32 FlashSectorSize; + u32 FlashWriteSupportSize; + u32 TotalFlashSize; + u32 FlashBaseAddr; + u32 FlashPartMaxSize; + u32 IsCDLessDeviceBootSig; + /* MSC Timeout after reset to switch from MSC to NW Mode */ + u32 MassStorageTimeout; +}; + +#define FLASH2X_TOTAL_SIZE (64 * 1024 * 1024) +#define DEFAULT_SECTOR_SIZE (64 * 1024) + +struct bcm_flash2x_cs_info { + /* magic number as 0xBECE-F1A5 - F1A5 for "flas-h" */ + u32 MagicNumber; + u32 FlashLayoutVersion; + u32 ISOImageVersion; + u32 SCSIFirmwareVersion; + u32 OffsetFromZeroForPart1ISOImage; + u32 OffsetFromZeroForScsiFirmware; + u32 SizeOfScsiFirmware; + u32 OffsetFromZeroForPart2ISOImage; + u32 OffsetFromZeroForDSDStart; + u32 OffsetFromZeroForDSDEnd; + u32 OffsetFromZeroForVSAStart; + u32 OffsetFromZeroForVSAEnd; + u32 OffsetFromZeroForControlSectionStart; + u32 OffsetFromZeroForControlSectionData; + /* NO Data Activity timeout to switch from MSC to NW Mode */ + u32 CDLessInactivityTimeout; + u32 NewImageSignature; + u32 FlashSectorSizeSig; + u32 FlashSectorSize; + u32 FlashWriteSupportSize; + u32 TotalFlashSize; + u32 FlashBaseAddr; + u32 FlashPartMaxSize; + u32 IsCDLessDeviceBootSig; + /* MSC Timeout after reset to switch from MSC to NW Mode */ + u32 MassStorageTimeout; /* Flash Map 2.0 Field */ - B_UINT32 OffsetISOImage1Part1Start; // ISO Image1 Part1 offset - B_UINT32 OffsetISOImage1Part1End; - B_UINT32 OffsetISOImage1Part2Start; // ISO Image1 Part2 offset - B_UINT32 OffsetISOImage1Part2End; - B_UINT32 OffsetISOImage1Part3Start; // ISO Image1 Part3 offset - B_UINT32 OffsetISOImage1Part3End; - - B_UINT32 OffsetISOImage2Part1Start; // ISO Image2 Part1 offset - B_UINT32 OffsetISOImage2Part1End; - B_UINT32 OffsetISOImage2Part2Start; // ISO Image2 Part2 offset - B_UINT32 OffsetISOImage2Part2End; - B_UINT32 OffsetISOImage2Part3Start; // ISO Image2 Part3 offset - B_UINT32 OffsetISOImage2Part3End; - - - // DSD Header offset from start of DSD - B_UINT32 OffsetFromDSDStartForDSDHeader; - B_UINT32 OffsetFromZeroForDSD1Start; // DSD 1 offset - B_UINT32 OffsetFromZeroForDSD1End; - B_UINT32 OffsetFromZeroForDSD2Start; // DSD 2 offset - B_UINT32 OffsetFromZeroForDSD2End; - - B_UINT32 OffsetFromZeroForVSA1Start; // VSA 1 offset - B_UINT32 OffsetFromZeroForVSA1End; - B_UINT32 OffsetFromZeroForVSA2Start; // VSA 2 offset - B_UINT32 OffsetFromZeroForVSA2End; - + u32 OffsetISOImage1Part1Start; + u32 OffsetISOImage1Part1End; + u32 OffsetISOImage1Part2Start; + u32 OffsetISOImage1Part2End; + u32 OffsetISOImage1Part3Start; + u32 OffsetISOImage1Part3End; + u32 OffsetISOImage2Part1Start; + u32 OffsetISOImage2Part1End; + u32 OffsetISOImage2Part2Start; + u32 OffsetISOImage2Part2End; + u32 OffsetISOImage2Part3Start; + u32 OffsetISOImage2Part3End; + /* DSD Header offset from start of DSD */ + u32 OffsetFromDSDStartForDSDHeader; + u32 OffsetFromZeroForDSD1Start; + u32 OffsetFromZeroForDSD1End; + u32 OffsetFromZeroForDSD2Start; + u32 OffsetFromZeroForDSD2End; + u32 OffsetFromZeroForVSA1Start; + u32 OffsetFromZeroForVSA1End; + u32 OffsetFromZeroForVSA2Start; + u32 OffsetFromZeroForVSA2End; /* -* ACCESS_BITS_PER_SECTOR 2 -* ACCESS_RW 0 -* ACCESS_RO 1 -* ACCESS_RESVD 2 -* ACCESS_RESVD 3 -* */ - B_UINT32 SectorAccessBitMap[FLASH2X_TOTAL_SIZE/(DEFAULT_SECTOR_SIZE *16)]; - -// All expansions to the control data structure should add here - -}FLASH2X_CS_INFO,*PFLASH2X_CS_INFO; - -typedef struct _VENDOR_SECTION_INFO -{ - B_UINT32 OffsetFromZeroForSectionStart; - B_UINT32 OffsetFromZeroForSectionEnd; - B_UINT32 AccessFlags; - B_UINT32 Reserved[16]; - -} VENDOR_SECTION_INFO, *PVENDOR_SECTION_INFO; - -typedef struct _FLASH2X_VENDORSPECIFIC_INFO -{ - VENDOR_SECTION_INFO VendorSection[TOTAL_SECTIONS]; - B_UINT32 Reserved[16]; - -} FLASH2X_VENDORSPECIFIC_INFO, *PFLASH2X_VENDORSPECIFIC_INFO; - -typedef struct _DSD_HEADER -{ - B_UINT32 DSDImageSize; - B_UINT32 DSDImageCRC; - B_UINT32 DSDImagePriority; - //We should not consider right now. Reading reserve is worthless. - B_UINT32 Reserved[252]; // Resvd for DSD Header - B_UINT32 DSDImageMagicNumber; - -}DSD_HEADER, *PDSD_HEADER; - -typedef struct _ISO_HEADER -{ - B_UINT32 ISOImageMagicNumber; - B_UINT32 ISOImageSize; - B_UINT32 ISOImageCRC; - B_UINT32 ISOImagePriority; - //We should not consider right now. Reading reserve is worthless. - B_UINT32 Reserved[60]; //Resvd for ISO Header extension - -}ISO_HEADER, *PISO_HEADER; - -#define EEPROM_BEGIN_CIS (0) -#define EEPROM_BEGIN_NON_CIS (0x200) -#define EEPROM_END (0x2000) - -#define INIT_PARAMS_SIGNATURE (0x95a7a597) - -#define MAX_INIT_PARAMS_LENGTH (2048) - - -#define MAC_ADDRESS_OFFSET 0x200 - - -#define INIT_PARAMS_1_SIGNATURE_ADDRESS EEPROM_BEGIN_NON_CIS -#define INIT_PARAMS_1_DATA_ADDRESS (INIT_PARAMS_1_SIGNATURE_ADDRESS+16) -#define INIT_PARAMS_1_MACADDRESS_ADDRESS (MAC_ADDRESS_OFFSET) -#define INIT_PARAMS_1_LENGTH_ADDRESS (INIT_PARAMS_1_SIGNATURE_ADDRESS+4) - -#define INIT_PARAMS_2_SIGNATURE_ADDRESS (EEPROM_BEGIN_NON_CIS+2048+16) -#define INIT_PARAMS_2_DATA_ADDRESS (INIT_PARAMS_2_SIGNATURE_ADDRESS+16) -#define INIT_PARAMS_2_MACADDRESS_ADDRESS (INIT_PARAMS_2_SIGNATURE_ADDRESS+8) -#define INIT_PARAMS_2_LENGTH_ADDRESS (INIT_PARAMS_2_SIGNATURE_ADDRESS+4) - -#define EEPROM_SPI_DEV_CONFIG_REG 0x0F003000 -#define EEPROM_SPI_Q_STATUS1_REG 0x0F003004 -#define EEPROM_SPI_Q_STATUS1_MASK_REG 0x0F00300C - -#define EEPROM_SPI_Q_STATUS_REG 0x0F003008 -#define EEPROM_CMDQ_SPI_REG 0x0F003018 -#define EEPROM_WRITE_DATAQ_REG 0x0F00301C -#define EEPROM_READ_DATAQ_REG 0x0F003020 -#define SPI_FLUSH_REG 0x0F00304C - -#define EEPROM_WRITE_ENABLE 0x06000000 -#define EEPROM_READ_STATUS_REGISTER 0x05000000 -#define EEPROM_16_BYTE_PAGE_WRITE 0xFA000000 -#define EEPROM_WRITE_QUEUE_EMPTY 0x00001000 -#define EEPROM_WRITE_QUEUE_AVAIL 0x00002000 -#define EEPROM_WRITE_QUEUE_FULL 0x00004000 -#define EEPROM_16_BYTE_PAGE_READ 0xFB000000 -#define EEPROM_4_BYTE_PAGE_READ 0x3B000000 - -#define EEPROM_CMD_QUEUE_FLUSH 0x00000001 -#define EEPROM_WRITE_QUEUE_FLUSH 0x00000002 -#define EEPROM_READ_QUEUE_FLUSH 0x00000004 -#define EEPROM_ETH_QUEUE_FLUSH 0x00000008 -#define EEPROM_ALL_QUEUE_FLUSH 0x0000000f -#define EEPROM_READ_ENABLE 0x06000000 -#define EEPROM_16_BYTE_PAGE_WRITE 0xFA000000 -#define EEPROM_READ_DATA_FULL 0x00000010 -#define EEPROM_READ_DATA_AVAIL 0x00000020 -#define EEPROM_READ_QUEUE_EMPTY 0x00000002 -#define EEPROM_CMD_QUEUE_EMPTY 0x00000100 -#define EEPROM_CMD_QUEUE_AVAIL 0x00000200 -#define EEPROM_CMD_QUEUE_FULL 0x00000400 + * ACCESS_BITS_PER_SECTOR 2 + * ACCESS_RW 0 + * ACCESS_RO 1 + * ACCESS_RESVD 2 + * ACCESS_RESVD 3 + */ + u32 SectorAccessBitMap[FLASH2X_TOTAL_SIZE / (DEFAULT_SECTOR_SIZE * 16)]; + /* All expansions to the control data structure should add here */ +}; + +struct bcm_vendor_section_info { + u32 OffsetFromZeroForSectionStart; + u32 OffsetFromZeroForSectionEnd; + u32 AccessFlags; + u32 Reserved[16]; +}; + +struct bcm_flash2x_vendor_info { + struct bcm_vendor_section_info VendorSection[TOTAL_SECTIONS]; + u32 Reserved[16]; +}; + +struct bcm_dsd_header { + u32 DSDImageSize; + u32 DSDImageCRC; + u32 DSDImagePriority; + /* We should not consider right now. Reading reserve is worthless. */ + u32 Reserved[252]; /* Resvd for DSD Header */ + u32 DSDImageMagicNumber; +}; + +struct bcm_iso_header { + u32 ISOImageMagicNumber; + u32 ISOImageSize; + u32 ISOImageCRC; + u32 ISOImagePriority; + /* We should not consider right now. Reading reserve is worthless. */ + u32 Reserved[60]; /* Resvd for ISO Header extension */ +}; + +#define EEPROM_BEGIN_CIS (0) +#define EEPROM_BEGIN_NON_CIS (0x200) +#define EEPROM_END (0x2000) +#define INIT_PARAMS_SIGNATURE (0x95a7a597) +#define MAX_INIT_PARAMS_LENGTH (2048) +#define MAC_ADDRESS_OFFSET 0x200 + +#define INIT_PARAMS_1_SIGNATURE_ADDRESS EEPROM_BEGIN_NON_CIS +#define INIT_PARAMS_1_DATA_ADDRESS (INIT_PARAMS_1_SIGNATURE_ADDRESS+16) +#define INIT_PARAMS_1_MACADDRESS_ADDRESS (MAC_ADDRESS_OFFSET) +#define INIT_PARAMS_1_LENGTH_ADDRESS (INIT_PARAMS_1_SIGNATURE_ADDRESS+4) + +#define INIT_PARAMS_2_SIGNATURE_ADDRESS (EEPROM_BEGIN_NON_CIS + 2048 + 16) +#define INIT_PARAMS_2_DATA_ADDRESS (INIT_PARAMS_2_SIGNATURE_ADDRESS + 16) +#define INIT_PARAMS_2_MACADDRESS_ADDRESS (INIT_PARAMS_2_SIGNATURE_ADDRESS + 8) +#define INIT_PARAMS_2_LENGTH_ADDRESS (INIT_PARAMS_2_SIGNATURE_ADDRESS + 4) + +#define EEPROM_SPI_DEV_CONFIG_REG 0x0F003000 +#define EEPROM_SPI_Q_STATUS1_REG 0x0F003004 +#define EEPROM_SPI_Q_STATUS1_MASK_REG 0x0F00300C + +#define EEPROM_SPI_Q_STATUS_REG 0x0F003008 +#define EEPROM_CMDQ_SPI_REG 0x0F003018 +#define EEPROM_WRITE_DATAQ_REG 0x0F00301C +#define EEPROM_READ_DATAQ_REG 0x0F003020 +#define SPI_FLUSH_REG 0x0F00304C + +#define EEPROM_WRITE_ENABLE 0x06000000 +#define EEPROM_READ_STATUS_REGISTER 0x05000000 +#define EEPROM_16_BYTE_PAGE_WRITE 0xFA000000 +#define EEPROM_WRITE_QUEUE_EMPTY 0x00001000 +#define EEPROM_WRITE_QUEUE_AVAIL 0x00002000 +#define EEPROM_WRITE_QUEUE_FULL 0x00004000 +#define EEPROM_16_BYTE_PAGE_READ 0xFB000000 +#define EEPROM_4_BYTE_PAGE_READ 0x3B000000 + +#define EEPROM_CMD_QUEUE_FLUSH 0x00000001 +#define EEPROM_WRITE_QUEUE_FLUSH 0x00000002 +#define EEPROM_READ_QUEUE_FLUSH 0x00000004 +#define EEPROM_ETH_QUEUE_FLUSH 0x00000008 +#define EEPROM_ALL_QUEUE_FLUSH 0x0000000f +#define EEPROM_READ_ENABLE 0x06000000 +#define EEPROM_16_BYTE_PAGE_WRITE 0xFA000000 +#define EEPROM_READ_DATA_FULL 0x00000010 +#define EEPROM_READ_DATA_AVAIL 0x00000020 +#define EEPROM_READ_QUEUE_EMPTY 0x00000002 +#define EEPROM_CMD_QUEUE_EMPTY 0x00000100 +#define EEPROM_CMD_QUEUE_AVAIL 0x00000200 +#define EEPROM_CMD_QUEUE_FULL 0x00000400 /* Most EEPROM status register bit 0 indicates if the EEPROM is busy * with a write if set 1. See the details of the EEPROM Status Register - * in the EEPROM data sheet. */ -#define EEPROM_STATUS_REG_WRITE_BUSY 0x00000001 - -// We will have 1 mSec for every RETRIES_PER_DELAY count and have a max attempts of MAX_EEPROM_RETRIES -// This will give us 80 mSec minimum of delay = 80mSecs -#define MAX_EEPROM_RETRIES 80 -#define RETRIES_PER_DELAY 64 - - -#define MAX_RW_SIZE 0x10 -#define MAX_READ_SIZE 0x10 -#define MAX_SECTOR_SIZE (512*1024) -#define MIN_SECTOR_SIZE (1024) -#define FLASH_SECTOR_SIZE_OFFSET 0xEFFFC -#define FLASH_SECTOR_SIZE_SIG_OFFSET 0xEFFF8 -#define FLASH_SECTOR_SIZE_SIG 0xCAFEBABE -#define FLASH_CS_INFO_START_ADDR 0xFF0000 -#define FLASH_CONTROL_STRUCT_SIGNATURE 0xBECEF1A5 -#define SCSI_FIRMWARE_MAJOR_VERSION 0x1 -#define SCSI_FIRMWARE_MINOR_VERSION 0x5 -#define BYTE_WRITE_SUPPORT 0x1 - -#define FLASH_AUTO_INIT_BASE_ADDR 0xF00000 - - - - -#define FLASH_CONTIGIOUS_START_ADDR_AFTER_INIT 0x1C000000 -#define FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT 0x1F000000 - -#define FLASH_CONTIGIOUS_START_ADDR_BCS350 0x08000000 -#define FLASH_CONTIGIOUS_END_ADDR_BCS350 0x08FFFFFF - - - -#define FLASH_SIZE_ADDR 0xFFFFEC - -#define FLASH_SPI_CMDQ_REG 0xAF003040 -#define FLASH_SPI_WRITEQ_REG 0xAF003044 -#define FLASH_SPI_READQ_REG 0xAF003048 -#define FLASH_CONFIG_REG 0xAF003050 -#define FLASH_GPIO_CONFIG_REG 0xAF000030 - -#define FLASH_CMD_WRITE_ENABLE 0x06 -#define FLASH_CMD_READ_ENABLE 0x03 -#define FLASH_CMD_RESET_WRITE_ENABLE 0x04 -#define FLASH_CMD_STATUS_REG_READ 0x05 -#define FLASH_CMD_STATUS_REG_WRITE 0x01 -#define FLASH_CMD_READ_ID 0x9F - -#define PAD_SELECT_REGISTER 0xAF000410 - -#define FLASH_PART_SST25VF080B 0xBF258E - -#define EEPROM_CAL_DATA_INTERNAL_LOC 0xbFB00008 - -#define EEPROM_CALPARAM_START 0x200 -#define EEPROM_SIZE_OFFSET 524 - -//As Read/Write time vaires from 1.5 to 3.0 ms. -//so After Ignoring the rdm/wrm time(that is dependent on many factor like interface etc.), -//here time calculated meets the worst case delay, 3.0 ms -#define MAX_FLASH_RETRIES 4 -#define FLASH_PER_RETRIES_DELAY 16 - - -#define EEPROM_MAX_CAL_AREA_SIZE 0xF0000 - - - -#define BECM ntohl(0x4245434d) - -#define FLASH_2X_MAJOR_NUMBER 0x2 -#define DSD_IMAGE_MAGIC_NUMBER 0xBECE0D5D -#define ISO_IMAGE_MAGIC_NUMBER 0xBECE0150 -#define NON_CDLESS_DEVICE_BOOT_SIG 0xBECEB007 -#define MINOR_VERSION(x) ((x >>16) & 0xFFFF) + * in the EEPROM data sheet. + */ +#define EEPROM_STATUS_REG_WRITE_BUSY 0x00000001 + +/* We will have 1 mSec for every RETRIES_PER_DELAY count and have a max attempts of MAX_EEPROM_RETRIES + * This will give us 80 mSec minimum of delay = 80mSecs + */ +#define MAX_EEPROM_RETRIES 80 +#define RETRIES_PER_DELAY 64 +#define MAX_RW_SIZE 0x10 +#define MAX_READ_SIZE 0x10 +#define MAX_SECTOR_SIZE (512 * 1024) +#define MIN_SECTOR_SIZE (1024) +#define FLASH_SECTOR_SIZE_OFFSET 0xEFFFC +#define FLASH_SECTOR_SIZE_SIG_OFFSET 0xEFFF8 +#define FLASH_SECTOR_SIZE_SIG 0xCAFEBABE +#define FLASH_CS_INFO_START_ADDR 0xFF0000 +#define FLASH_CONTROL_STRUCT_SIGNATURE 0xBECEF1A5 +#define SCSI_FIRMWARE_MAJOR_VERSION 0x1 +#define SCSI_FIRMWARE_MINOR_VERSION 0x5 +#define BYTE_WRITE_SUPPORT 0x1 +#define FLASH_AUTO_INIT_BASE_ADDR 0xF00000 +#define FLASH_CONTIGIOUS_START_ADDR_AFTER_INIT 0x1C000000 +#define FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT 0x1F000000 +#define FLASH_CONTIGIOUS_START_ADDR_BCS350 0x08000000 +#define FLASH_CONTIGIOUS_END_ADDR_BCS350 0x08FFFFFF +#define FLASH_SIZE_ADDR 0xFFFFEC +#define FLASH_SPI_CMDQ_REG 0xAF003040 +#define FLASH_SPI_WRITEQ_REG 0xAF003044 +#define FLASH_SPI_READQ_REG 0xAF003048 +#define FLASH_CONFIG_REG 0xAF003050 +#define FLASH_GPIO_CONFIG_REG 0xAF000030 +#define FLASH_CMD_WRITE_ENABLE 0x06 +#define FLASH_CMD_READ_ENABLE 0x03 +#define FLASH_CMD_RESET_WRITE_ENABLE 0x04 +#define FLASH_CMD_STATUS_REG_READ 0x05 +#define FLASH_CMD_STATUS_REG_WRITE 0x01 +#define FLASH_CMD_READ_ID 0x9F +#define PAD_SELECT_REGISTER 0xAF000410 +#define FLASH_PART_SST25VF080B 0xBF258E +#define EEPROM_CAL_DATA_INTERNAL_LOC 0xbFB00008 +#define EEPROM_CALPARAM_START 0x200 +#define EEPROM_SIZE_OFFSET 524 + +/* As Read/Write time vaires from 1.5 to 3.0 ms. + * so After Ignoring the rdm/wrm time(that is dependent on many factor like interface etc.), + * here time calculated meets the worst case delay, 3.0 ms + */ +#define MAX_FLASH_RETRIES 4 +#define FLASH_PER_RETRIES_DELAY 16 +#define EEPROM_MAX_CAL_AREA_SIZE 0xF0000 +#define BECM ntohl(0x4245434d) +#define FLASH_2X_MAJOR_NUMBER 0x2 +#define DSD_IMAGE_MAGIC_NUMBER 0xBECE0D5D +#define ISO_IMAGE_MAGIC_NUMBER 0xBECE0150 +#define NON_CDLESS_DEVICE_BOOT_SIG 0xBECEB007 + +#define MINOR_VERSION(x) ((x >> 16) & 0xFFFF) #define MAJOR_VERSION(x) (x & 0xFFFF) -#define CORRUPTED_PATTERN 0x0 -#define UNINIT_PTR_IN_CS 0xBBBBDDDD - -#define VENDOR_PTR_IN_CS 0xAAAACCCC - - -#define FLASH2X_SECTION_PRESENT 1<<0 -#define FLASH2X_SECTION_VALID 1<<1 -#define FLASH2X_SECTION_RO 1<<2 -#define FLASH2X_SECTION_ACT 1<<3 -#define SECTOR_IS_NOT_WRITABLE STATUS_FAILURE -#define INVALID_OFFSET STATUS_FAILURE -#define INVALID_SECTION STATUS_FAILURE -#define SECTOR_1K 1024 -#define SECTOR_64K (64 *SECTOR_1K) -#define SECTOR_128K (2 * SECTOR_64K) -#define SECTOR_256k (2 * SECTOR_128K) -#define SECTOR_512K (2 * SECTOR_256k) -#define FLASH_PART_SIZE (16 * 1024 * 1024) -#define RESET_CHIP_SELECT -1 -#define CHIP_SELECT_BIT12 12 - -#define SECTOR_READWRITE_PERMISSION 0 -#define SECTOR_READONLY 1 -#define SIGNATURE_SIZE 4 -#define DEFAULT_BUFF_SIZE 0x10000 - -#define FIELD_OFFSET_IN_HEADER(HeaderPointer,Field) ((PUCHAR)&((HeaderPointer)(NULL))->Field - (PUCHAR)(NULL)) +#define CORRUPTED_PATTERN 0x0 +#define UNINIT_PTR_IN_CS 0xBBBBDDDD +#define VENDOR_PTR_IN_CS 0xAAAACCCC +#define FLASH2X_SECTION_PRESENT (1 << 0) +#define FLASH2X_SECTION_VALID (1 << 1) +#define FLASH2X_SECTION_RO (1 << 2) +#define FLASH2X_SECTION_ACT (1 << 3) +#define SECTOR_IS_NOT_WRITABLE STATUS_FAILURE +#define INVALID_OFFSET STATUS_FAILURE +#define INVALID_SECTION STATUS_FAILURE +#define SECTOR_1K 1024 +#define SECTOR_64K (64 * SECTOR_1K) +#define SECTOR_128K (2 * SECTOR_64K) +#define SECTOR_256k (2 * SECTOR_128K) +#define SECTOR_512K (2 * SECTOR_256k) +#define FLASH_PART_SIZE (16 * 1024 * 1024) +#define RESET_CHIP_SELECT -1 +#define CHIP_SELECT_BIT12 12 +#define SECTOR_READWRITE_PERMISSION 0 +#define SECTOR_READONLY 1 +#define SIGNATURE_SIZE 4 +#define DEFAULT_BUFF_SIZE 0x10000 + +#define FIELD_OFFSET_IN_HEADER(HeaderPointer, Field) ((u8 *)&((HeaderPointer)(NULL))->Field - (u8 *)(NULL)) #endif diff --git a/drivers/staging/bcm/target_params.h b/drivers/staging/bcm/target_params.h index ad7ec005493..dc45f9ab854 100644 --- a/drivers/staging/bcm/target_params.h +++ b/drivers/staging/bcm/target_params.h @@ -1,81 +1,57 @@ #ifndef TARGET_PARAMS_H #define TARGET_PARAMS_H -typedef struct _TARGET_PARAMS -{ - B_UINT32 m_u32CfgVersion; - - // Scanning Related Params - B_UINT32 m_u32CenterFrequency; - B_UINT32 m_u32BandAScan; - B_UINT32 m_u32BandBScan; - B_UINT32 m_u32BandCScan; - - - // QoS Params - B_UINT32 m_u32ErtpsOptions; - - B_UINT32 m_u32PHSEnable; - - - // HO Params - B_UINT32 m_u32HoEnable; - - B_UINT32 m_u32HoReserved1; - B_UINT32 m_u32HoReserved2; - // Power Control Params - - B_UINT32 m_u32MimoEnable; - - B_UINT32 m_u32SecurityEnable; - - B_UINT32 m_u32PowerSavingModesEnable; //bit 1: 1 Idlemode enable; bit2: 1 Sleepmode Enable - /* PowerSaving Mode Options: - bit 0 = 1: CPE mode - to keep pcmcia if alive; - bit 1 = 1: CINR reporting in Idlemode Msg - bit 2 = 1: Default PSC Enable in sleepmode*/ - B_UINT32 m_u32PowerSavingModeOptions; - - B_UINT32 m_u32ArqEnable; - - // From Version #3, the HARQ section renamed as general - B_UINT32 m_u32HarqEnable; - // EEPROM Param Location - B_UINT32 m_u32EEPROMFlag; - // BINARY TYPE - 4th MSByte: Interface Type - 3rd MSByte: Vendor Type - 2nd MSByte - // Unused - LSByte - B_UINT32 m_u32Customize; - B_UINT32 m_u32ConfigBW; /* In Hz */ - B_UINT32 m_u32ShutDownInitThresholdTimer; - - B_UINT32 m_u32RadioParameter; - B_UINT32 m_u32PhyParameter1; - B_UINT32 m_u32PhyParameter2; - B_UINT32 m_u32PhyParameter3; - - B_UINT32 m_u32TestOptions; // in eval mode only; lower 16bits = basic cid for testing; then bit 16 is test cqich,bit 17 test init rang; bit 18 test periodic rang and bit 19 is test harq ack/nack - - B_UINT32 m_u32MaxMACDataperDLFrame; - B_UINT32 m_u32MaxMACDataperULFrame; - - B_UINT32 m_u32Corr2MacFlags; - - //adding driver params. - B_UINT32 HostDrvrConfig1; - B_UINT32 HostDrvrConfig2; - B_UINT32 HostDrvrConfig3; - B_UINT32 HostDrvrConfig4; - B_UINT32 HostDrvrConfig5; - B_UINT32 HostDrvrConfig6; - B_UINT32 m_u32SegmentedPUSCenable; - - // removed SHUT down related 'unused' params from here to sync 4.x and 5.x CFG files.. - - //BAMC Related Parameters - //Bit 0-15 Band AMC signaling configuration: Bit 1 = 1 Enable Band AMC signaling. - //bit 16-31 Band AMC Data configuration: Bit 16 = 1 Band AMC 2x3 support. - B_UINT32 m_u32BandAMCEnable; - -} stTargetParams,TARGET_PARAMS,*PTARGET_PARAMS, STARGETPARAMS, *PSTARGETPARAMS; +struct bcm_target_params { + u32 m_u32CfgVersion; + u32 m_u32CenterFrequency; + u32 m_u32BandAScan; + u32 m_u32BandBScan; + u32 m_u32BandCScan; + u32 m_u32ErtpsOptions; + u32 m_u32PHSEnable; + u32 m_u32HoEnable; + u32 m_u32HoReserved1; + u32 m_u32HoReserved2; + u32 m_u32MimoEnable; + u32 m_u32SecurityEnable; + u32 m_u32PowerSavingModesEnable; /* bit 1: 1 Idlemode enable; bit2: 1 Sleepmode Enable */ + /* PowerSaving Mode Options: + * bit 0 = 1: CPE mode - to keep pcmcia if alive; + * bit 1 = 1: CINR reporting in Idlemode Msg + * bit 2 = 1: Default PSC Enable in sleepmode + */ + u32 m_u32PowerSavingModeOptions; + u32 m_u32ArqEnable; + /* From Version #3, the HARQ section renamed as general */ + u32 m_u32HarqEnable; + u32 m_u32EEPROMFlag; + /* BINARY TYPE - 4th MSByte: Interface Type - 3rd MSByte: Vendor Type - 2nd MSByte + * Unused - LSByte + */ + u32 m_u32Customize; + u32 m_u32ConfigBW; /* In Hz */ + u32 m_u32ShutDownInitThresholdTimer; + u32 m_u32RadioParameter; + u32 m_u32PhyParameter1; + u32 m_u32PhyParameter2; + u32 m_u32PhyParameter3; + u32 m_u32TestOptions; /* in eval mode only; lower 16bits = basic cid for testing; then bit 16 is test cqich,bit 17 test init rang; bit 18 test periodic rang and bit 19 is test harq ack/nack */ + u32 m_u32MaxMACDataperDLFrame; + u32 m_u32MaxMACDataperULFrame; + u32 m_u32Corr2MacFlags; + u32 HostDrvrConfig1; + u32 HostDrvrConfig2; + u32 HostDrvrConfig3; + u32 HostDrvrConfig4; + u32 HostDrvrConfig5; + u32 HostDrvrConfig6; + u32 m_u32SegmentedPUSCenable; + /* removed SHUT down related 'unused' params from here to sync 4.x and 5.x CFG files.. + * BAMC Related Parameters + * Bit 0-15 Band AMC signaling configuration: Bit 1 = 1 Enable Band AMC signaling. + * bit 16-31 Band AMC Data configuration: Bit 16 = 1 Band AMC 2x3 support. + */ + u32 m_u32BandAMCEnable; +}; #endif diff --git a/drivers/staging/bcm/vendorspecificextn.c b/drivers/staging/bcm/vendorspecificextn.c index 833883c21a2..2c57a16788c 100644 --- a/drivers/staging/bcm/vendorspecificextn.c +++ b/drivers/staging/bcm/vendorspecificextn.c @@ -1,70 +1,70 @@ #include "headers.h" -//----------------------------------------------------------------------------- -// Procedure: vendorextnGetSectionInfo -// -// Description: Finds the type of NVM used. -// -// Arguments: -// Adapter - ptr to Adapter object instance -// pNVMType - ptr to NVM type. -// Returns: -// STATUS_SUCCESS/STATUS_FAILURE -// -//----------------------------------------------------------------------------- -INT vendorextnGetSectionInfo(PVOID pContext,PFLASH2X_VENDORSPECIFIC_INFO pVendorInfo) +/* + * Procedure: vendorextnGetSectionInfo + * + * Description: Finds the type of NVM used. + * + * Arguments: + * Adapter - ptr to Adapter object instance + * pNVMType - ptr to NVM type. + * Returns: + * STATUS_SUCCESS/STATUS_FAILURE + * + */ +INT vendorextnGetSectionInfo(PVOID pContext, struct bcm_flash2x_vendor_info *pVendorInfo) { return STATUS_FAILURE; } -//----------------------------------------------------------------------------- -// Procedure: vendorextnInit -// -// Description: Initializing the vendor extension NVM interface -// -// Arguments: -// Adapter - Pointer to MINI Adapter Structure. - -// Returns: -// STATUS_SUCCESS/STATUS_FAILURE -// -//----------------------------------------------------------------------------- +/* + * Procedure: vendorextnInit + * + * Description: Initializing the vendor extension NVM interface + * + * Arguments: + * Adapter - Pointer to MINI Adapter Structure + * Returns: + * STATUS_SUCCESS/STATUS_FAILURE + * + * + */ INT vendorextnInit(struct bcm_mini_adapter *Adapter) { return STATUS_SUCCESS; } -//----------------------------------------------------------------------------- -// Procedure: vendorextnExit -// -// Description: Free the resource associated with vendor extension NVM interface -// -// Arguments: -// Adapter - Pointer to MINI Adapter Structure. - -// Returns: -// STATUS_SUCCESS/STATUS_FAILURE -// -//----------------------------------------------------------------------------- +/* + * Procedure: vendorextnExit + * + * Description: Free the resource associated with vendor extension NVM interface + * + * Arguments: + * + * Returns: + * STATUS_SUCCESS/STATUS_FAILURE + * + * + */ INT vendorextnExit(struct bcm_mini_adapter *Adapter) { return STATUS_SUCCESS; } -//------------------------------------------------------------------------ -// Procedure: vendorextnIoctl -// -// Description: execute the vendor extension specific ioctl -// -//Arguments: -// Adapter -Beceem private Adapter Structure -// cmd -vendor extension specific Ioctl commad -// arg -input parameter sent by vendor -// -// Returns: -// CONTINUE_COMMON_PATH in case it is not meant to be processed by vendor ioctls -// STATUS_SUCCESS/STATUS_FAILURE as per the IOCTL return value -// -//-------------------------------------------------------------------------- +/* + * Procedure: vendorextnIoctl + * + * Description: execute the vendor extension specific ioctl + * + * Arguments: + * Adapter -Beceem private Adapter Structure + * cmd -vendor extension specific Ioctl commad + * arg -input parameter sent by vendor + * + * Returns: + * CONTINUE_COMMON_PATH in case it is not meant to be processed by vendor ioctls + * STATUS_SUCCESS/STATUS_FAILURE as per the IOCTL return value + */ + INT vendorextnIoctl(struct bcm_mini_adapter *Adapter, UINT cmd, ULONG arg) { return CONTINUE_COMMON_PATH; @@ -72,24 +72,23 @@ INT vendorextnIoctl(struct bcm_mini_adapter *Adapter, UINT cmd, ULONG arg) -//------------------------------------------------------------------ -// Procedure: vendorextnReadSection -// -// Description: Reads from a section of NVM -// -// Arguments: -// pContext - ptr to Adapter object instance -// pBuffer - Read the data from Vendor Area to this buffer -// SectionVal - Value of type of Section -// Offset - Read from the Offset of the Vendor Section. -// numOfBytes - Read numOfBytes from the Vendor section to Buffer -// -// Returns: -// STATUS_SUCCESS/STATUS_FAILURE -// -//------------------------------------------------------------------ - -INT vendorextnReadSection(PVOID pContext, PUCHAR pBuffer, FLASH2X_SECTION_VAL SectionVal, +/* + * Procedure: vendorextnReadSection + * + * Description: Reads from a section of NVM + * + * Arguments: + * pContext - ptr to Adapter object instance + * pBuffer - Read the data from Vendor Area to this buffer + * SectionVal - Value of type of Section + * Offset - Read from the Offset of the Vendor Section. + * numOfBytes - Read numOfBytes from the Vendor section to Buffer + * + * Returns: + * STATUS_SUCCESS/STATUS_FAILURE + */ + +INT vendorextnReadSection(PVOID pContext, PUCHAR pBuffer, enum bcm_flash2x_section_val SectionVal, UINT offset, UINT numOfBytes) { return STATUS_FAILURE; @@ -97,50 +96,47 @@ INT vendorextnReadSection(PVOID pContext, PUCHAR pBuffer, FLASH2X_SECTION_VAL S -//------------------------------------------------------------------ -// Procedure: vendorextnWriteSection -// -// Description: Write to a Section of NVM -// -// Arguments: -// pContext - ptr to Adapter object instance -// pBuffer - Write the data provided in the buffer -// SectionVal - Value of type of Section -// Offset - Writes to the Offset of the Vendor Section. -// numOfBytes - Write num Bytes after reading from pBuffer. -// bVerify - the Buffer Written should be verified. -// -// Returns: -// STATUS_SUCCESS/STATUS_FAILURE -// -//------------------------------------------------------------------ -INT vendorextnWriteSection(PVOID pContext, PUCHAR pBuffer, FLASH2X_SECTION_VAL SectionVal, - UINT offset, UINT numOfBytes, BOOLEAN bVerify) +/* + * Procedure: vendorextnWriteSection + * + * Description: Write to a Section of NVM + * + * Arguments: + * pContext - ptr to Adapter object instance + * pBuffer - Write the data provided in the buffer + * SectionVal - Value of type of Section + * Offset - Writes to the Offset of the Vendor Section. + * numOfBytes - Write num Bytes after reading from pBuffer. + * bVerify - the Buffer Written should be verified. + * + * Returns: + * STATUS_SUCCESS/STATUS_FAILURE + */ +INT vendorextnWriteSection(PVOID pContext, PUCHAR pBuffer, enum bcm_flash2x_section_val SectionVal, + UINT offset, UINT numOfBytes, bool bVerify) { return STATUS_FAILURE; } -//------------------------------------------------------------------ -// Procedure: vendorextnWriteSectionWithoutErase -// -// Description: Write to a Section of NVM without erasing the sector -// -// Arguments: -// pContext - ptr to Adapter object instance -// pBuffer - Write the data provided in the buffer -// SectionVal - Value of type of Section -// Offset - Writes to the Offset of the Vendor Section. -// numOfBytes - Write num Bytes after reading from pBuffer. -// -// Returns: -// STATUS_SUCCESS/STATUS_FAILURE -// -//------------------------------------------------------------------ -INT vendorextnWriteSectionWithoutErase(PVOID pContext, PUCHAR pBuffer, FLASH2X_SECTION_VAL SectionVal, +/* + * Procedure: vendorextnWriteSectionWithoutErase + * + * Description: Write to a Section of NVM without erasing the sector + * + * Arguments: + * pContext - ptr to Adapter object instance + * pBuffer - Write the data provided in the buffer + * SectionVal - Value of type of Section + * Offset - Writes to the Offset of the Vendor Section. + * numOfBytes - Write num Bytes after reading from pBuffer. + * + * Returns: + * STATUS_SUCCESS/STATUS_FAILURE + */ +INT vendorextnWriteSectionWithoutErase(PVOID pContext, PUCHAR pBuffer, enum bcm_flash2x_section_val SectionVal, UINT offset, UINT numOfBytes) { return STATUS_FAILURE; } - diff --git a/drivers/staging/bcm/vendorspecificextn.h b/drivers/staging/bcm/vendorspecificextn.h index f237891b9f2..ff57f057045 100644 --- a/drivers/staging/bcm/vendorspecificextn.h +++ b/drivers/staging/bcm/vendorspecificextn.h @@ -4,15 +4,15 @@ #define CONTINUE_COMMON_PATH 0xFFFF -INT vendorextnGetSectionInfo(PVOID pContext,PFLASH2X_VENDORSPECIFIC_INFO pVendorInfo); +INT vendorextnGetSectionInfo(PVOID pContext, struct bcm_flash2x_vendor_info *pVendorInfo); INT vendorextnExit(struct bcm_mini_adapter *Adapter); INT vendorextnInit(struct bcm_mini_adapter *Adapter); INT vendorextnIoctl(struct bcm_mini_adapter *Adapter, UINT cmd, ULONG arg); -INT vendorextnReadSection(PVOID pContext, PUCHAR pBuffer, FLASH2X_SECTION_VAL SectionVal, +INT vendorextnReadSection(PVOID pContext, PUCHAR pBuffer, enum bcm_flash2x_section_val SectionVal, UINT offset, UINT numOfBytes); -INT vendorextnWriteSection(PVOID pContext, PUCHAR pBuffer, FLASH2X_SECTION_VAL SectionVal, - UINT offset, UINT numOfBytes, BOOLEAN bVerify); -INT vendorextnWriteSectionWithoutErase(PVOID pContext, PUCHAR pBuffer, FLASH2X_SECTION_VAL SectionVal, +INT vendorextnWriteSection(PVOID pContext, PUCHAR pBuffer, enum bcm_flash2x_section_val SectionVal, + UINT offset, UINT numOfBytes, bool bVerify); +INT vendorextnWriteSectionWithoutErase(PVOID pContext, PUCHAR pBuffer, enum bcm_flash2x_section_val SectionVal, UINT offset, UINT numOfBytes); #endif /* */ |
