diff options
Diffstat (limited to 'drivers/staging/bcm')
32 files changed, 5058 insertions, 4350 deletions
diff --git a/drivers/staging/bcm/Adapter.h b/drivers/staging/bcm/Adapter.h index 1d8bf08b5bf..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,14 +88,14 @@ 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;  	struct bcm_phs_rule sPhsRule;  	UCHAR		u8AssociatedPHSI; @@ -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 */ @@ -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,8 +198,8 @@ struct bcm_tarang_data {  	struct sk_buff		*RxAppControlHead;  	struct sk_buff		*RxAppControlTail;  	int			AppCtrlQueueLen; -	BOOLEAN			MacTracingEnabled; -	BOOLEAN			bApplicationToExit; +	bool			MacTracingEnabled; +	bool			bApplicationToExit;  	struct bcm_mibs_dropped_cntrl_msg stDroppedAppCntrlMsgs;  	ULONG			RxCntrlMsgBitMask;  }; @@ -205,7 +207,7 @@ struct bcm_tarang_data {  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;  	struct bcm_target_params *pstargetparams; -	BOOLEAN			device_removed; -	BOOLEAN			DeviceAccess; -	BOOLEAN			bIsAutoCorrectEnabled; -	BOOLEAN			bDDRInitDone; +	bool			device_removed; +	bool			DeviceAccess; +	bool			bIsAutoCorrectEnabled; +	bool			bDDRInitDone;  	int			DDRSetting;  	ULONG			ulPowerSaveMode;  	spinlock_t		txtransmitlock; @@ -324,22 +326,22 @@ 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;  	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]; @@ -348,8 +350,8 @@ struct bcm_mini_adapter {  	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. @@ -376,18 +378,18 @@ struct bcm_mini_adapter {  	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; diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index f91bc1fdd89..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()  * @@ -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,1850 +240,2363 @@ static ssize_t bcm_char_read(struct file *filp, char __user *buf, size_t size,  	return PktLen;  } -static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) +static int bcm_char_ioctl_reg_read_private(void __user *argp, +					   struct bcm_mini_adapter *Adapter)  { -	struct bcm_tarang_data *pTarang = filp->private_data; -	void __user *argp = (void __user *)arg; -	struct bcm_mini_adapter *Adapter = pTarang->Adapter; -	INT Status = STATUS_FAILURE; -	int timeout = 0; +	struct bcm_rdm_buffer sRdmBuffer = {0};  	struct bcm_ioctl_buffer IoBuffer; +	PCHAR temp_buff; +	INT Status = STATUS_FAILURE; +	UINT Bufflen; +	u16 temp_value;  	int bytes; -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Parameters Passed to control IOCTL cmd=0x%X arg=0x%lX", cmd, arg); - -	if (_IOC_TYPE(cmd) != BCM_IOCTL) +	/* Copy Ioctl Buffer structure */ +	if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer)))  		return -EFAULT; -	if (_IOC_DIR(cmd) & _IOC_READ) -		Status = !access_ok(VERIFY_WRITE, argp, _IOC_SIZE(cmd)); -	else if (_IOC_DIR(cmd) & _IOC_WRITE) -		Status = !access_ok(VERIFY_READ, argp, _IOC_SIZE(cmd)); -	else if (_IOC_NONE == (_IOC_DIR(cmd) & _IOC_NONE)) -		Status = STATUS_SUCCESS; -	if (Status) -		return -EFAULT; +	if (IoBuffer.InputLength > sizeof(sRdmBuffer)) +		return -EINVAL; -	if (Adapter->device_removed) +	if (copy_from_user(&sRdmBuffer, IoBuffer.InputBuffer, +		IoBuffer.InputLength))  		return -EFAULT; -	if (FALSE == Adapter->fw_download_done) { -		switch (cmd) { -		case IOCTL_MAC_ADDR_REQ: -		case IOCTL_LINK_REQ: -		case IOCTL_CM_REQUEST: -		case IOCTL_SS_INFO_REQ: -		case IOCTL_SEND_CONTROL_MESSAGE: -		case IOCTL_IDLE_REQ: -		case IOCTL_BCM_GPIO_SET_REQUEST: -		case IOCTL_BCM_GPIO_STATUS_REQUEST: -			return -EACCES; -		default: -			break; -		} +	if (IoBuffer.OutputLength > USHRT_MAX || +		IoBuffer.OutputLength == 0) { +		return -EINVAL;  	} -	Status = vendorextnIoctl(Adapter, cmd, arg); -	if (Status != CONTINUE_COMMON_PATH) -		return Status; +	Bufflen = IoBuffer.OutputLength; +	temp_value = 4 - (Bufflen % 4); +	Bufflen += temp_value % 4; -	switch (cmd) { -	/* Rdms for Swin Idle... */ -	case IOCTL_BCM_REGISTER_READ_PRIVATE: { -		struct bcm_rdm_buffer sRdmBuffer = {0}; -		PCHAR temp_buff; -		UINT Bufflen; -		u16 temp_value; - -		/* Copy Ioctl Buffer structure */ -		if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) -			return -EFAULT; - -		if (IoBuffer.InputLength > sizeof(sRdmBuffer)) -			return -EINVAL; +	temp_buff = kmalloc(Bufflen, GFP_KERNEL); +	if (!temp_buff) +		return -ENOMEM; -		if (copy_from_user(&sRdmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) +	bytes = rdmalt(Adapter, (UINT)sRdmBuffer.Register, +			(PUINT)temp_buff, Bufflen); +	if (bytes > 0) { +		Status = STATUS_SUCCESS; +		if (copy_to_user(IoBuffer.OutputBuffer, temp_buff, bytes)) { +			kfree(temp_buff);  			return -EFAULT; - -		if (IoBuffer.OutputLength > USHRT_MAX || -			IoBuffer.OutputLength == 0) { -			return -EINVAL; -		} - -		Bufflen = IoBuffer.OutputLength; -		temp_value = 4 - (Bufflen % 4); -		Bufflen += temp_value % 4; - -		temp_buff = kmalloc(Bufflen, GFP_KERNEL); -		if (!temp_buff) -			return -ENOMEM; - -		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;  		} - -		kfree(temp_buff); -		break; +	} else { +		Status = bytes;  	} -	case IOCTL_BCM_REGISTER_WRITE_PRIVATE: { -		struct bcm_wrm_buffer sWrmBuffer = {0}; -		UINT uiTempVar = 0; -		/* Copy Ioctl Buffer structure */ +	kfree(temp_buff); +	return Status; +} -		if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) -			return -EFAULT; +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; -		if (IoBuffer.InputLength > sizeof(sWrmBuffer)) -			return -EINVAL; +	/* Copy Ioctl Buffer structure */ -		/* Get WrmBuffer structure */ -		if (copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) -			return -EFAULT; +	if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) +		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))) { +	if (IoBuffer.InputLength > sizeof(sWrmBuffer)) +		return -EINVAL; -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "EEPROM Access Denied, not in VSG Mode\n"); -			return -EFAULT; -		} +	/* Get WrmBuffer structure */ +	if (copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer, +		IoBuffer.InputLength)) +		return -EFAULT; -		Status = wrmalt(Adapter, (UINT)sWrmBuffer.Register, -				(PUINT)sWrmBuffer.Data, sizeof(ULONG)); +	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))) { -		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; +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +				"EEPROM Access Denied, not in VSG Mode\n"); +		return -EFAULT;  	} -	case IOCTL_BCM_REGISTER_READ: -	case IOCTL_BCM_EEPROM_REGISTER_READ: { -		struct bcm_rdm_buffer sRdmBuffer = {0}; -		PCHAR temp_buff = NULL; -		UINT uiTempVar = 0; -		if ((Adapter->IdleMode == TRUE) || -			(Adapter->bShutStatus == TRUE) || -			(Adapter->bPreparingForLowPowerMode == TRUE)) { +	Status = wrmalt(Adapter, (UINT)sWrmBuffer.Register, +			(PUINT)sWrmBuffer.Data, sizeof(ULONG)); -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Device in Idle Mode, Blocking Rdms\n"); -			return -EACCES; -		} +	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; +} -		/* Copy Ioctl Buffer structure */ -		if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) -			return -EFAULT; +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 (IoBuffer.InputLength > sizeof(sRdmBuffer)) -			return -EINVAL; +	if ((Adapter->IdleMode == TRUE) || +		(Adapter->bShutStatus == TRUE) || +		(Adapter->bPreparingForLowPowerMode == TRUE)) { -		if (copy_from_user(&sRdmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) -			return -EFAULT; +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +				"Device in Idle Mode, Blocking Rdms\n"); +		return -EACCES; +	} -		if (IoBuffer.OutputLength > USHRT_MAX || -			IoBuffer.OutputLength == 0) { -			return -EINVAL; -		} +	/* Copy Ioctl Buffer structure */ +	if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) +		return -EFAULT; -		temp_buff = kmalloc(IoBuffer.OutputLength, GFP_KERNEL); -		if (!temp_buff) -			return STATUS_FAILURE; +	if (IoBuffer.InputLength > sizeof(sRdmBuffer)) +		return -EINVAL; -		if ((((ULONG)sRdmBuffer.Register & 0x0F000000) != 0x0F000000) || -			((ULONG)sRdmBuffer.Register & 0x3)) { +	if (copy_from_user(&sRdmBuffer, IoBuffer.InputBuffer, +		IoBuffer.InputLength)) +		return -EFAULT; -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "RDM Done On invalid Address : %x Access Denied.\n", -					(int)sRdmBuffer.Register); +	if (IoBuffer.OutputLength > USHRT_MAX || +		IoBuffer.OutputLength == 0) { +		return -EINVAL; +	} -			kfree(temp_buff); -			return -EINVAL; -		} +	temp_buff = kmalloc(IoBuffer.OutputLength, GFP_KERNEL); +	if (!temp_buff) +		return STATUS_FAILURE; -		uiTempVar = sRdmBuffer.Register & EEPROM_REJECT_MASK; -		bytes = rdmaltWithLock(Adapter, (UINT)sRdmBuffer.Register, (PUINT)temp_buff, IoBuffer.OutputLength); +	if ((((ULONG)sRdmBuffer.Register & 0x0F000000) != 0x0F000000) || +		((ULONG)sRdmBuffer.Register & 0x3)) { -		if (bytes > 0) { -			Status = STATUS_SUCCESS; -			if (copy_to_user(IoBuffer.OutputBuffer, temp_buff, bytes)) { -				kfree(temp_buff); -				return -EFAULT; -			} -		} else { -			Status = bytes; -		} +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +				"RDM Done On invalid Address : %x Access Denied.\n", +				(int)sRdmBuffer.Register);  		kfree(temp_buff); -		break; +		return -EINVAL;  	} -	case IOCTL_BCM_REGISTER_WRITE: -	case IOCTL_BCM_EEPROM_REGISTER_WRITE: { -		struct bcm_wrm_buffer sWrmBuffer = {0}; -		UINT uiTempVar = 0; -		if ((Adapter->IdleMode == TRUE) || -			(Adapter->bShutStatus == TRUE) || -			(Adapter->bPreparingForLowPowerMode == TRUE)) { +	uiTempVar = sRdmBuffer.Register & EEPROM_REJECT_MASK; +	bytes = rdmaltWithLock(Adapter, (UINT)sRdmBuffer.Register, +			       (PUINT)temp_buff, IoBuffer.OutputLength); -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Device in Idle Mode, Blocking Wrms\n"); -			return -EACCES; +	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 */ -		if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) -			return -EFAULT; +	kfree(temp_buff); +	return Status; +} -		if (IoBuffer.InputLength > sizeof(sWrmBuffer)) -			return -EINVAL; +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; -		/* Get WrmBuffer structure */ -		if (copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) -			return -EFAULT; +	if ((Adapter->IdleMode == TRUE) || +		(Adapter->bShutStatus == TRUE) || +		(Adapter->bPreparingForLowPowerMode == TRUE)) { -		if ((((ULONG)sWrmBuffer.Register & 0x0F000000) != 0x0F000000) || -			((ULONG)sWrmBuffer.Register & 0x3)) { +		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, "WRM Done On invalid Address : %x Access Denied.\n", (int)sWrmBuffer.Register); -			return -EINVAL; -		} +	/* Copy Ioctl Buffer structure */ +	if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) +		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)) && -				(cmd == IOCTL_BCM_REGISTER_WRITE)) { +	if (IoBuffer.InputLength > sizeof(sWrmBuffer)) +		return -EINVAL; -				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "EEPROM Access Denied, not in VSG Mode\n"); -				return -EFAULT; -		} +	/* Get WrmBuffer structure */ +	if (copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer, +		IoBuffer.InputLength)) +		return -EFAULT; -		Status = wrmaltWithLock(Adapter, (UINT)sWrmBuffer.Register, -					(PUINT)sWrmBuffer.Data, sWrmBuffer.Length); +	if ((((ULONG)sWrmBuffer.Register & 0x0F000000) != 0x0F000000) || +		((ULONG)sWrmBuffer.Register & 0x3)) { -		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; +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +				"WRM Done On invalid Address : %x Access Denied.\n", +				(int)sWrmBuffer.Register); +		return -EINVAL;  	} -	case IOCTL_BCM_GPIO_SET_REQUEST: { -		UCHAR ucResetValue[4]; -		UINT value = 0; -		UINT uiBit = 0; -		UINT uiOperation = 0; -		struct bcm_gpio_info gpio_info = {0}; - -		if ((Adapter->IdleMode == TRUE) || -			(Adapter->bShutStatus == TRUE) || -			(Adapter->bPreparingForLowPowerMode == TRUE)) { -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "GPIO Can't be set/clear in Low power Mode"); -			return -EACCES; -		} +	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)) { -		if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) +			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +					"EEPROM Access Denied, not in VSG Mode\n");  			return -EFAULT; +	} -		if (IoBuffer.InputLength > sizeof(gpio_info)) -			return -EINVAL; +	Status = wrmaltWithLock(Adapter, (UINT)sWrmBuffer.Register, +				(PUINT)sWrmBuffer.Data, +				sWrmBuffer.Length); -		if (copy_from_user(&gpio_info, IoBuffer.InputBuffer, IoBuffer.InputLength)) -			return -EFAULT; +	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; +	} +	return Status; +} -		uiBit  = gpio_info.uiGpioNumber; -		uiOperation = gpio_info.uiGpioValue; -		value = (1<<uiBit); +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; -		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 ((Adapter->IdleMode == TRUE) || +		(Adapter->bShutStatus == TRUE) || +		(Adapter->bPreparingForLowPowerMode == TRUE)) { -		/* Set - setting 1 */ -		if (uiOperation) { -			/* Set the gpio output register */ -			Status = wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_SET_REG, (PUINT)(&value), sizeof(UINT)); +		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 (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 (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) +		return -EFAULT; -			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; -			} -		} +	if (IoBuffer.InputLength > sizeof(gpio_info)) +		return -EINVAL; -		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 (copy_from_user(&gpio_info, IoBuffer.InputBuffer, +			   IoBuffer.InputLength)) +		return -EFAULT; + +	uiBit  = gpio_info.uiGpioNumber; +	uiOperation = gpio_info.uiGpioValue; +	value = (1<<uiBit); + +	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; +	} + +	/* Set - setting 1 */ +	if (uiOperation) { +		/* Set the gpio output register */ +		Status = wrmaltWithLock(Adapter, +					BCM_GPIO_OUTPUT_SET_REG, +					(PUINT)(&value), sizeof(UINT)); + +		if (Status == STATUS_SUCCESS) { +			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, +					OSAL_DBG, DBG_LVL_ALL, +					"Set the GPIO bit\n");  		} else { -			Status = STATUS_SUCCESS; +			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, +					OSAL_DBG, DBG_LVL_ALL, +					"Failed to set the %dth GPIO\n", +					uiBit); +			return Status;  		} - -		/* Set the gpio mode register to output */ -		*(UINT *)ucResetValue |= (1<<uiBit); -		Status = wrmaltWithLock(Adapter, GPIO_MODE_REGISTER, -					(PUINT)ucResetValue, sizeof(UINT)); +	} else { +		/* Set the gpio output register */ +		Status = wrmaltWithLock(Adapter, +					BCM_GPIO_OUTPUT_CLR_REG, +					(PUINT)(&value), sizeof(UINT));  		if (Status == STATUS_SUCCESS) { -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Set the GPIO to output Mode\n"); +			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, +					OSAL_DBG, DBG_LVL_ALL, +					"Set the GPIO bit\n");  		} else { -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Failed to put GPIO in Output Mode\n"); -			break; +			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, +					OSAL_DBG, DBG_LVL_ALL, +					"Failed to clear the %dth GPIO\n", +					uiBit); +			return Status;  		}  	} -	break; -	case BCM_LED_THREAD_STATE_CHANGE_REQ: { -		struct bcm_user_thread_req threadReq = {0}; -		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(struct bcm_ioctl_buffer))) -			return -EFAULT; +	return Status; +} -		if (IoBuffer.InputLength > sizeof(threadReq)) -			return -EINVAL; +static int bcm_char_ioctl_led_thread_state_change_req(void __user *argp, +		struct bcm_mini_adapter *Adapter) +{ +	struct bcm_user_thread_req threadReq = {0}; +	struct bcm_ioctl_buffer IoBuffer; -		if (copy_from_user(&threadReq, IoBuffer.InputBuffer, IoBuffer.InputLength)) -			return -EFAULT; +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, +			"User made LED thread InActive"); -		/* if LED thread is running(Actively or Inactively) set it state to make inactive */ -		if (Adapter->LEDInfo.led_thread_running) { -			if (threadReq.ThreadState == LED_THREAD_ACTIVATION_REQ) { -				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Activating thread req"); -				Adapter->DriverState = LED_THREAD_ACTIVE; -			} else { -				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "DeActivating Thread req....."); -				Adapter->DriverState = LED_THREAD_INACTIVE; -			} +	if ((Adapter->IdleMode == TRUE) || +		(Adapter->bShutStatus == TRUE) || +		(Adapter->bPreparingForLowPowerMode == TRUE)) { -			/* signal thread. */ -			wake_up(&Adapter->LEDInfo.notify_led_event); -		} +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, +				DBG_LVL_ALL, +				"GPIO Can't be set/clear in Low power Mode"); +		return -EACCES;  	} -	break; - -	case IOCTL_BCM_GPIO_STATUS_REQUEST: { -		ULONG uiBit = 0; -		UCHAR ucRead[4]; -		struct bcm_gpio_info gpio_info = {0}; -		if ((Adapter->IdleMode == TRUE) || -			(Adapter->bShutStatus == TRUE) || -			(Adapter->bPreparingForLowPowerMode == TRUE)) -			return -EACCES; - -		if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) -			return -EFAULT; - -		if (IoBuffer.InputLength > sizeof(gpio_info)) -			return -EINVAL; - -		if (copy_from_user(&gpio_info, IoBuffer.InputBuffer, IoBuffer.InputLength)) -			return -EFAULT; +	if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) +		return -EFAULT; -		uiBit = gpio_info.uiGpioNumber; +	if (IoBuffer.InputLength > sizeof(threadReq)) +		return -EINVAL; -		/* Set the gpio output register */ -		bytes = rdmaltWithLock(Adapter, (UINT)GPIO_PIN_STATE_REGISTER, -					(PUINT)ucRead, sizeof(UINT)); +	if (copy_from_user(&threadReq, IoBuffer.InputBuffer, +			   IoBuffer.InputLength)) +		return -EFAULT; -		if (bytes < 0) { -			Status = bytes; -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "RDM Failed\n"); -			return Status; +	/* if LED thread is running(Actively or Inactively) +	 * set it state to make inactive +	 */ +	if (Adapter->LEDInfo.led_thread_running) { +		if (threadReq.ThreadState == LED_THREAD_ACTIVATION_REQ) { +			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, +					OSAL_DBG, DBG_LVL_ALL, +					"Activating thread req"); +			Adapter->DriverState = LED_THREAD_ACTIVE;  		} else { -			Status = STATUS_SUCCESS; +			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, +					OSAL_DBG, DBG_LVL_ALL, +					"DeActivating Thread req....."); +			Adapter->DriverState = LED_THREAD_INACTIVE;  		} + +		/* signal thread. */ +		wake_up(&Adapter->LEDInfo.notify_led_event);  	} -	break; +	return STATUS_SUCCESS; +} -	case IOCTL_BCM_GPIO_MULTI_REQUEST: { -		UCHAR ucResetValue[4]; -		struct bcm_gpio_multi_info gpio_multi_info[MAX_IDX]; -		struct bcm_gpio_multi_info *pgpio_multi_info = (struct bcm_gpio_multi_info *)gpio_multi_info; +static int bcm_char_ioctl_gpio_status_request(void __user *argp, +		struct bcm_mini_adapter *Adapter) +{ +	struct bcm_gpio_info gpio_info = {0}; +	struct bcm_ioctl_buffer IoBuffer; +	ULONG uiBit = 0; +	UCHAR ucRead[4]; +	INT Status; +	int bytes; -		memset(pgpio_multi_info, 0, MAX_IDX * sizeof(struct bcm_gpio_multi_info)); +	if ((Adapter->IdleMode == TRUE) || +		(Adapter->bShutStatus == TRUE) || +		(Adapter->bPreparingForLowPowerMode == TRUE)) +		return -EACCES; -		if ((Adapter->IdleMode == TRUE) || -			(Adapter->bShutStatus == TRUE) || -			(Adapter->bPreparingForLowPowerMode == TRUE)) -			return -EINVAL; +	if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) +		return -EFAULT; -		if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) -			return -EFAULT; +	if (IoBuffer.InputLength > sizeof(gpio_info)) +		return -EINVAL; -		if (IoBuffer.InputLength > sizeof(gpio_multi_info)) -			return -EINVAL; +	if (copy_from_user(&gpio_info, IoBuffer.InputBuffer, +		IoBuffer.InputLength)) +		return -EFAULT; -		if (copy_from_user(&gpio_multi_info, IoBuffer.InputBuffer, IoBuffer.InputLength)) -			return -EFAULT; +	uiBit = gpio_info.uiGpioNumber; -		if (IsReqGpioIsLedInNVM(Adapter, pgpio_multi_info[WIMAX_IDX].uiGPIOMask) == FALSE) { -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, -					"Sorry, Requested GPIO<0x%X> is not correspond to NVM LED bit map<0x%X>!!!", -					pgpio_multi_info[WIMAX_IDX].uiGPIOMask, Adapter->gpioBitMap); -			Status = -EINVAL; -			break; -		} +	/* Set the gpio output register */ +	bytes = rdmaltWithLock(Adapter, (UINT)GPIO_PIN_STATE_REGISTER, +				(PUINT)ucRead, sizeof(UINT)); -		/* Set the gpio output register */ -		if ((pgpio_multi_info[WIMAX_IDX].uiGPIOMask) & -			(pgpio_multi_info[WIMAX_IDX].uiGPIOCommand)) { -			/* Set 1's in GPIO OUTPUT REGISTER */ -			*(UINT *)ucResetValue =  pgpio_multi_info[WIMAX_IDX].uiGPIOMask & -				pgpio_multi_info[WIMAX_IDX].uiGPIOCommand & -				pgpio_multi_info[WIMAX_IDX].uiGPIOValue; - -			if (*(UINT *) ucResetValue) -				Status = wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_SET_REG, -							(PUINT)ucResetValue, sizeof(ULONG)); - -			if (Status != STATUS_SUCCESS) { -				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "WRM to BCM_GPIO_OUTPUT_SET_REG Failed."); -				return Status; -			} +	if (bytes < 0) { +		Status = bytes; +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +				"RDM Failed\n"); +		return Status; +	} else { +		Status = STATUS_SUCCESS; +	} +	return Status; +} -			/* Clear to 0's in GPIO OUTPUT REGISTER */ -			*(UINT *)ucResetValue = (pgpio_multi_info[WIMAX_IDX].uiGPIOMask & -						pgpio_multi_info[WIMAX_IDX].uiGPIOCommand & -						(~(pgpio_multi_info[WIMAX_IDX].uiGPIOValue))); +static int bcm_char_ioctl_gpio_multi_request(void __user *argp, +		struct bcm_mini_adapter *Adapter) +{ +	struct bcm_gpio_multi_info gpio_multi_info[MAX_IDX]; +	struct bcm_gpio_multi_info *pgpio_multi_info = +		(struct bcm_gpio_multi_info *)gpio_multi_info; +	struct bcm_ioctl_buffer IoBuffer; +	UCHAR ucResetValue[4]; +	INT Status = STATUS_FAILURE; +	int bytes; -			if (*(UINT *) ucResetValue) -				Status = wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_CLR_REG, (PUINT)ucResetValue, sizeof(ULONG)); +	memset(pgpio_multi_info, 0, +	       MAX_IDX * sizeof(struct bcm_gpio_multi_info)); -			if (Status != STATUS_SUCCESS) { -				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "WRM to BCM_GPIO_OUTPUT_CLR_REG Failed."); -				return Status; -			} -		} +	if ((Adapter->IdleMode == TRUE) || +		(Adapter->bShutStatus == TRUE) || +		(Adapter->bPreparingForLowPowerMode == TRUE)) +		return -EINVAL; -		if (pgpio_multi_info[WIMAX_IDX].uiGPIOMask) { -			bytes = rdmaltWithLock(Adapter, (UINT)GPIO_PIN_STATE_REGISTER, (PUINT)ucResetValue, sizeof(UINT)); +	if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) +		return -EFAULT; -			if (bytes < 0) { -				Status = bytes; -				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "RDM to GPIO_PIN_STATE_REGISTER Failed."); -				return Status; -			} else { -				Status = STATUS_SUCCESS; -			} +	if (IoBuffer.InputLength > sizeof(gpio_multi_info)) +		return -EINVAL; +	if (IoBuffer.OutputLength > sizeof(gpio_multi_info)) +		IoBuffer.OutputLength = sizeof(gpio_multi_info); -			pgpio_multi_info[WIMAX_IDX].uiGPIOValue = (*(UINT *)ucResetValue & -								pgpio_multi_info[WIMAX_IDX].uiGPIOMask); -		} +	if (copy_from_user(&gpio_multi_info, IoBuffer.InputBuffer, +			   IoBuffer.InputLength)) +		return -EFAULT; -		Status = copy_to_user(IoBuffer.OutputBuffer, &gpio_multi_info, IoBuffer.OutputLength); -		if (Status) { -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, -					"Failed while copying Content to IOBufer for user space err:%d", Status); -			return -EFAULT; -		} +	if (IsReqGpioIsLedInNVM(Adapter, pgpio_multi_info[WIMAX_IDX].uiGPIOMask) +			== false) { +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, +				DBG_LVL_ALL, +				"Sorry, Requested GPIO<0x%X> is not correspond to NVM LED bit map<0x%X>!!!", +				pgpio_multi_info[WIMAX_IDX].uiGPIOMask, +				Adapter->gpioBitMap); +		return -EINVAL;  	} -	break; -	case IOCTL_BCM_GPIO_MODE_REQUEST: { -		UCHAR ucResetValue[4]; -		struct bcm_gpio_multi_mode gpio_multi_mode[MAX_IDX]; -		struct bcm_gpio_multi_mode *pgpio_multi_mode = (struct bcm_gpio_multi_mode *)gpio_multi_mode; +	/* Set the gpio output register */ +	if ((pgpio_multi_info[WIMAX_IDX].uiGPIOMask) & +		(pgpio_multi_info[WIMAX_IDX].uiGPIOCommand)) { +		/* Set 1's in GPIO OUTPUT REGISTER */ +		*(UINT *)ucResetValue = pgpio_multi_info[WIMAX_IDX].uiGPIOMask & +			pgpio_multi_info[WIMAX_IDX].uiGPIOCommand & +			pgpio_multi_info[WIMAX_IDX].uiGPIOValue; -		if ((Adapter->IdleMode == TRUE) || -			(Adapter->bShutStatus == TRUE) || -			(Adapter->bPreparingForLowPowerMode == TRUE)) -			return -EINVAL; +		if (*(UINT *) ucResetValue) +			Status = wrmaltWithLock(Adapter, +				BCM_GPIO_OUTPUT_SET_REG, +				(PUINT)ucResetValue, sizeof(ULONG)); -		if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) -			return -EFAULT; +		if (Status != STATUS_SUCCESS) { +			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +				"WRM to BCM_GPIO_OUTPUT_SET_REG Failed."); +			return Status; +		} -		if (IoBuffer.InputLength > sizeof(gpio_multi_mode)) -			return -EINVAL; +		/* Clear to 0's in GPIO OUTPUT REGISTER */ +		*(UINT *)ucResetValue = +			(pgpio_multi_info[WIMAX_IDX].uiGPIOMask & +			pgpio_multi_info[WIMAX_IDX].uiGPIOCommand & +			(~(pgpio_multi_info[WIMAX_IDX].uiGPIOValue))); -		if (copy_from_user(&gpio_multi_mode, IoBuffer.InputBuffer, IoBuffer.InputLength)) -			return -EFAULT; +		if (*(UINT *) ucResetValue) +			Status = wrmaltWithLock(Adapter, +				BCM_GPIO_OUTPUT_CLR_REG, (PUINT)ucResetValue, +				sizeof(ULONG)); + +		if (Status != STATUS_SUCCESS) { +			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +					"WRM to BCM_GPIO_OUTPUT_CLR_REG Failed."); +			return Status; +		} +	} -		bytes = rdmaltWithLock(Adapter, (UINT)GPIO_MODE_REGISTER, (PUINT)ucResetValue, sizeof(UINT)); +	if (pgpio_multi_info[WIMAX_IDX].uiGPIOMask) { +		bytes = rdmaltWithLock(Adapter, (UINT)GPIO_PIN_STATE_REGISTER, +				       (PUINT)ucResetValue, sizeof(UINT));  		if (bytes < 0) {  			Status = bytes; -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Read of GPIO_MODE_REGISTER failed"); +			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +					"RDM to GPIO_PIN_STATE_REGISTER Failed.");  			return Status;  		} else {  			Status = STATUS_SUCCESS;  		} -		/* Validating the request */ -		if (IsReqGpioIsLedInNVM(Adapter, pgpio_multi_mode[WIMAX_IDX].uiGPIOMask) == FALSE) { -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, -					"Sorry, Requested GPIO<0x%X> is not correspond to NVM LED bit map<0x%X>!!!", -					pgpio_multi_mode[WIMAX_IDX].uiGPIOMask, Adapter->gpioBitMap); -			Status = -EINVAL; -			break; -		} +		pgpio_multi_info[WIMAX_IDX].uiGPIOValue = +			(*(UINT *)ucResetValue & +			pgpio_multi_info[WIMAX_IDX].uiGPIOMask); +	} -		if (pgpio_multi_mode[WIMAX_IDX].uiGPIOMask) { -			/* write all OUT's (1's) */ -			*(UINT *) ucResetValue |= (pgpio_multi_mode[WIMAX_IDX].uiGPIOMode & -						pgpio_multi_mode[WIMAX_IDX].uiGPIOMask); +	Status = copy_to_user(IoBuffer.OutputBuffer, &gpio_multi_info, +		IoBuffer.OutputLength); +	if (Status) { +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +			"Failed while copying Content to IOBufer for user space err:%d", +			Status); +		return -EFAULT; +	} +	return Status; +} -			/* write all IN's (0's) */ -			*(UINT *) ucResetValue &= ~((~pgpio_multi_mode[WIMAX_IDX].uiGPIOMode) & -						pgpio_multi_mode[WIMAX_IDX].uiGPIOMask); +static int bcm_char_ioctl_gpio_mode_request(void __user *argp, +		struct bcm_mini_adapter *Adapter) +{ +	struct bcm_gpio_multi_mode gpio_multi_mode[MAX_IDX]; +	struct bcm_gpio_multi_mode *pgpio_multi_mode = +		(struct bcm_gpio_multi_mode *)gpio_multi_mode; +	struct bcm_ioctl_buffer IoBuffer; +	UCHAR ucResetValue[4]; +	INT Status; +	int bytes; -			/* Currently implemented return the modes of all GPIO's -			 * else needs to bit AND with  mask -			 */ -			pgpio_multi_mode[WIMAX_IDX].uiGPIOMode = *(UINT *)ucResetValue; +	if ((Adapter->IdleMode == TRUE) || +		(Adapter->bShutStatus == TRUE) || +		(Adapter->bPreparingForLowPowerMode == TRUE)) +		return -EINVAL; -			Status = wrmaltWithLock(Adapter, GPIO_MODE_REGISTER, (PUINT)ucResetValue, sizeof(ULONG)); -			if (Status == STATUS_SUCCESS) { -				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, -						"WRM to GPIO_MODE_REGISTER Done"); -			} else { -				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, -						"WRM to GPIO_MODE_REGISTER Failed"); -				Status = -EFAULT; -				break; -			} -		} else { -/* if uiGPIOMask is 0 then return mode register configuration */ -			pgpio_multi_mode[WIMAX_IDX].uiGPIOMode = *(UINT *)ucResetValue; -		} +	if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) +		return -EFAULT; -		Status = copy_to_user(IoBuffer.OutputBuffer, &gpio_multi_mode, IoBuffer.OutputLength); -		if (Status) { +	if (IoBuffer.InputLength > sizeof(gpio_multi_mode)) +		return -EINVAL; +	if (IoBuffer.OutputLength > sizeof(gpio_multi_mode)) +		IoBuffer.OutputLength = sizeof(gpio_multi_mode); + +	if (copy_from_user(&gpio_multi_mode, IoBuffer.InputBuffer, +		IoBuffer.InputLength)) +		return -EFAULT; + +	bytes = rdmaltWithLock(Adapter, (UINT)GPIO_MODE_REGISTER, +		(PUINT)ucResetValue, sizeof(UINT)); + +	if (bytes < 0) { +		Status = bytes; +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +			"Read of GPIO_MODE_REGISTER failed"); +		return Status; +	} else { +		Status = STATUS_SUCCESS; +	} + +	/* Validating the request */ +	if (IsReqGpioIsLedInNVM(Adapter, pgpio_multi_mode[WIMAX_IDX].uiGPIOMask) +			== false) { +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, +				"Sorry, Requested GPIO<0x%X> is not correspond to NVM LED bit map<0x%X>!!!", +				pgpio_multi_mode[WIMAX_IDX].uiGPIOMask, +				Adapter->gpioBitMap); +		return -EINVAL; +	} + +	if (pgpio_multi_mode[WIMAX_IDX].uiGPIOMask) { +		/* write all OUT's (1's) */ +		*(UINT *) ucResetValue |= +			(pgpio_multi_mode[WIMAX_IDX].uiGPIOMode & +					pgpio_multi_mode[WIMAX_IDX].uiGPIOMask); + +		/* write all IN's (0's) */ +		*(UINT *) ucResetValue &= +			~((~pgpio_multi_mode[WIMAX_IDX].uiGPIOMode) & +					pgpio_multi_mode[WIMAX_IDX].uiGPIOMask); + +		/* Currently implemented return the modes of all GPIO's +		 * else needs to bit AND with  mask +		 */ +		pgpio_multi_mode[WIMAX_IDX].uiGPIOMode = *(UINT *)ucResetValue; + +		Status = wrmaltWithLock(Adapter, GPIO_MODE_REGISTER, +			(PUINT)ucResetValue, sizeof(ULONG)); +		if (Status == STATUS_SUCCESS) { +			BCM_DEBUG_PRINT(Adapter, +				DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, +				"WRM to GPIO_MODE_REGISTER Done"); +		} else {  			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, -					"Failed while copying Content to IOBufer for user space err:%d", Status); +					"WRM to GPIO_MODE_REGISTER Failed");  			return -EFAULT;  		} +	} else { +		/* if uiGPIOMask is 0 then return mode register configuration */ +		pgpio_multi_mode[WIMAX_IDX].uiGPIOMode = *(UINT *)ucResetValue;  	} -	break; -	case IOCTL_MAC_ADDR_REQ: -	case IOCTL_LINK_REQ: -	case IOCTL_CM_REQUEST: -	case IOCTL_SS_INFO_REQ: -	case IOCTL_SEND_CONTROL_MESSAGE: -	case IOCTL_IDLE_REQ: { -		PVOID pvBuffer = NULL; +	Status = copy_to_user(IoBuffer.OutputBuffer, &gpio_multi_mode, +		IoBuffer.OutputLength); +	if (Status) { +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +			"Failed while copying Content to IOBufer for user space err:%d", +			Status); +		return -EFAULT; +	} +	return Status; +} -		/* Copy Ioctl Buffer structure */ -		if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) -			return -EFAULT; +static int bcm_char_ioctl_misc_request(void __user *argp, +		struct bcm_mini_adapter *Adapter) +{ +	struct bcm_ioctl_buffer IoBuffer; +	PVOID pvBuffer = NULL; +	INT Status; -		if (IoBuffer.InputLength < sizeof(struct bcm_link_request)) -			return -EINVAL; +	/* Copy Ioctl Buffer structure */ +	if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) +		return -EFAULT; -		if (IoBuffer.InputLength > MAX_CNTL_PKT_SIZE) -			return -EINVAL; +	if (IoBuffer.InputLength < sizeof(struct bcm_link_request)) +		return -EINVAL; -		pvBuffer = memdup_user(IoBuffer.InputBuffer, -				       IoBuffer.InputLength); -		if (IS_ERR(pvBuffer)) -			return PTR_ERR(pvBuffer); - -		down(&Adapter->LowPowerModeSync); -		Status = wait_event_interruptible_timeout(Adapter->lowpower_mode_wait_queue, -							!Adapter->bPreparingForLowPowerMode, -							(1 * HZ)); -		if (Status == -ERESTARTSYS) -			goto cntrlEnd; - -		if (Adapter->bPreparingForLowPowerMode) { -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, -					"Preparing Idle Mode is still True - Hence Rejecting control message\n"); -			Status = STATUS_FAILURE; -			goto cntrlEnd; -		} -		Status = CopyBufferToControlPacket(Adapter, (PVOID)pvBuffer); +	if (IoBuffer.InputLength > MAX_CNTL_PKT_SIZE) +		return -EINVAL; -cntrlEnd: -		up(&Adapter->LowPowerModeSync); -		kfree(pvBuffer); -		break; -	} +	pvBuffer = memdup_user(IoBuffer.InputBuffer, +			       IoBuffer.InputLength); +	if (IS_ERR(pvBuffer)) +		return PTR_ERR(pvBuffer); -	case IOCTL_BCM_BUFFER_DOWNLOAD_START: { -		if (down_trylock(&Adapter->NVMRdmWrmLock)) { -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, -					"IOCTL_BCM_CHIP_RESET not allowed as EEPROM Read/Write is in progress\n"); -			return -EACCES; -		} +	down(&Adapter->LowPowerModeSync); +	Status = wait_event_interruptible_timeout( +			Adapter->lowpower_mode_wait_queue, +			!Adapter->bPreparingForLowPowerMode, +			(1 * HZ)); -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, -				"Starting the firmware download PID =0x%x!!!!\n", current->pid); - -		if (down_trylock(&Adapter->fw_download_sema)) -			return -EBUSY; - -		Adapter->bBinDownloaded = FALSE; -		Adapter->fw_download_process_pid = current->pid; -		Adapter->bCfgDownloaded = FALSE; -		Adapter->fw_download_done = FALSE; -		netif_carrier_off(Adapter->dev); -		netif_stop_queue(Adapter->dev); -		Status = reset_card_proc(Adapter); -		if (Status) { -			pr_err(PFX "%s: reset_card_proc Failed!\n", Adapter->dev->name); -			up(&Adapter->fw_download_sema); -			up(&Adapter->NVMRdmWrmLock); -			return Status; -		} -		mdelay(10); +	if (Status == -ERESTARTSYS) +		goto cntrlEnd; -		up(&Adapter->NVMRdmWrmLock); -		return Status; +	if (Adapter->bPreparingForLowPowerMode) { +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, +				"Preparing Idle Mode is still True - Hence Rejecting control message\n"); +		Status = STATUS_FAILURE; +		goto cntrlEnd;  	} +	Status = CopyBufferToControlPacket(Adapter, (PVOID)pvBuffer); -	case IOCTL_BCM_BUFFER_DOWNLOAD: { -		struct bcm_firmware_info *psFwInfo = NULL; -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Starting the firmware download PID =0x%x!!!!\n", current->pid); +cntrlEnd: +	up(&Adapter->LowPowerModeSync); +	kfree(pvBuffer); +	return Status; +} -		if (!down_trylock(&Adapter->fw_download_sema)) { -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, -					"Invalid way to download buffer. Use Start and then call this!!!\n"); -			up(&Adapter->fw_download_sema); -			Status = -EINVAL; -			return Status; -		} +static int bcm_char_ioctl_buffer_download_start( +		struct bcm_mini_adapter *Adapter) +{ +	INT Status; -		/* Copy Ioctl Buffer structure */ -		if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) { -			up(&Adapter->fw_download_sema); -			return -EFAULT; -		} +	if (down_trylock(&Adapter->NVMRdmWrmLock)) { +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, +				"IOCTL_BCM_CHIP_RESET not allowed as EEPROM Read/Write is in progress\n"); +		return -EACCES; +	} -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, -				"Length for FW DLD is : %lx\n", IoBuffer.InputLength); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +			"Starting the firmware download PID =0x%x!!!!\n", +			current->pid); + +	if (down_trylock(&Adapter->fw_download_sema)) +		return -EBUSY; + +	Adapter->bBinDownloaded = false; +	Adapter->fw_download_process_pid = current->pid; +	Adapter->bCfgDownloaded = false; +	Adapter->fw_download_done = false; +	netif_carrier_off(Adapter->dev); +	netif_stop_queue(Adapter->dev); +	Status = reset_card_proc(Adapter); +	if (Status) { +		pr_err(PFX "%s: reset_card_proc Failed!\n", Adapter->dev->name); +		up(&Adapter->fw_download_sema); +		up(&Adapter->NVMRdmWrmLock); +		return Status; +	} +	mdelay(10); -		if (IoBuffer.InputLength > sizeof(struct bcm_firmware_info)) { -			up(&Adapter->fw_download_sema); -			return -EINVAL; -		} +	up(&Adapter->NVMRdmWrmLock); +	return Status; +} -		psFwInfo = kmalloc(sizeof(*psFwInfo), GFP_KERNEL); -		if (!psFwInfo) { -			up(&Adapter->fw_download_sema); -			return -ENOMEM; -		} +static int bcm_char_ioctl_buffer_download(void __user *argp, +		struct bcm_mini_adapter *Adapter) +{ +	struct bcm_firmware_info *psFwInfo = NULL; +	struct bcm_ioctl_buffer IoBuffer; +	INT Status; -		if (copy_from_user(psFwInfo, IoBuffer.InputBuffer, IoBuffer.InputLength)) { -			up(&Adapter->fw_download_sema); -			kfree(psFwInfo); -			return -EFAULT; -		} +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +		"Starting the firmware download PID =0x%x!!!!\n", current->pid); -		if (!psFwInfo->pvMappedFirmwareAddress || -			(psFwInfo->u32FirmwareLength == 0)) { +	if (!down_trylock(&Adapter->fw_download_sema)) { +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +				"Invalid way to download buffer. Use Start and then call this!!!\n"); +		up(&Adapter->fw_download_sema); +		return -EINVAL; +	} -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Something else is wrong %lu\n", -					psFwInfo->u32FirmwareLength); -			up(&Adapter->fw_download_sema); -			kfree(psFwInfo); -			Status = -EINVAL; -			return Status; -		} +	/* Copy Ioctl Buffer structure */ +	if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) { +		up(&Adapter->fw_download_sema); +		return -EFAULT; +	} -		Status = bcm_ioctl_fw_download(Adapter, psFwInfo); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +			"Length for FW DLD is : %lx\n", IoBuffer.InputLength); -		if (Status != STATUS_SUCCESS) { -			if (psFwInfo->u32StartingAddress == CONFIG_BEGIN_ADDR) -				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "IOCTL: Configuration File Upload Failed\n"); -			else -				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0,	"IOCTL: Firmware File Upload Failed\n"); +	if (IoBuffer.InputLength > sizeof(struct bcm_firmware_info)) { +		up(&Adapter->fw_download_sema); +		return -EINVAL; +	} -			/* up(&Adapter->fw_download_sema); */ +	psFwInfo = kmalloc(sizeof(*psFwInfo), GFP_KERNEL); +	if (!psFwInfo) { +		up(&Adapter->fw_download_sema); +		return -ENOMEM; +	} -			if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { -				Adapter->DriverState = DRIVER_INIT; -				Adapter->LEDInfo.bLedInitDone = FALSE; -				wake_up(&Adapter->LEDInfo.notify_led_event); -			} -		} +	if (copy_from_user(psFwInfo, IoBuffer.InputBuffer, +		IoBuffer.InputLength)) { +		up(&Adapter->fw_download_sema); +		kfree(psFwInfo); +		return -EFAULT; +	} -		if (Status != STATUS_SUCCESS) -			up(&Adapter->fw_download_sema); +	if (!psFwInfo->pvMappedFirmwareAddress || +		(psFwInfo->u32FirmwareLength == 0)) { -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, OSAL_DBG, DBG_LVL_ALL, "IOCTL: Firmware File Uploaded\n"); +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +				"Something else is wrong %lu\n", +				psFwInfo->u32FirmwareLength); +		up(&Adapter->fw_download_sema);  		kfree(psFwInfo); +		Status = -EINVAL;  		return Status;  	} -	case IOCTL_BCM_BUFFER_DOWNLOAD_STOP: { -		if (!down_trylock(&Adapter->fw_download_sema)) { -			up(&Adapter->fw_download_sema); -			return -EINVAL; -		} +	Status = bcm_ioctl_fw_download(Adapter, psFwInfo); -		if (down_trylock(&Adapter->NVMRdmWrmLock)) { +	if (Status != STATUS_SUCCESS) { +		if (psFwInfo->u32StartingAddress == CONFIG_BEGIN_ADDR)  			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, -					"FW download blocked as EEPROM Read/Write is in progress\n"); -			up(&Adapter->fw_download_sema); -			return -EACCES; -		} - -		Adapter->bBinDownloaded = TRUE; -		Adapter->bCfgDownloaded = TRUE; -		atomic_set(&Adapter->CurrNumFreeTxDesc, 0); -		Adapter->CurrNumRecvDescs = 0; -		Adapter->downloadDDR = 0; +				"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((struct bcm_interface_adapter *)Adapter->pvInterfaceAdapter)) -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Unable to send interrupt...\n"); - -		timeout = 5*HZ; -		Adapter->waiting_to_fw_download_done = FALSE; -		wait_event_timeout(Adapter->ioctl_fw_dnld_wait_queue, -				Adapter->waiting_to_fw_download_done, timeout); -		Adapter->fw_download_process_pid = INVALID_PID; -		Adapter->fw_download_done = TRUE; -		atomic_set(&Adapter->CurrNumFreeTxDesc, 0); -		Adapter->CurrNumRecvDescs = 0; -		Adapter->PrevNumRecvDescs = 0; -		atomic_set(&Adapter->cntrlpktCnt, 0); -		Adapter->LinkUpStatus = 0; -		Adapter->LinkStatus = 0; - -		if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { -			Adapter->DriverState = FW_DOWNLOAD_DONE; +		if (Adapter->LEDInfo.led_thread_running & +			BCM_LED_THREAD_RUNNING_ACTIVELY) { +			Adapter->DriverState = DRIVER_INIT; +			Adapter->LEDInfo.bLedInitDone = false;  			wake_up(&Adapter->LEDInfo.notify_led_event);  		} +	} + +	if (Status != STATUS_SUCCESS) +		up(&Adapter->fw_download_sema); + +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, OSAL_DBG, DBG_LVL_ALL, +		"IOCTL: Firmware File Uploaded\n"); +	kfree(psFwInfo); +	return Status; +} -		if (!timeout) -			Status = -ENODEV; +static int bcm_char_ioctl_buffer_download_stop(void __user *argp, +		struct bcm_mini_adapter *Adapter) +{ +	INT Status; +	int timeout = 0; +	if (!down_trylock(&Adapter->fw_download_sema)) {  		up(&Adapter->fw_download_sema); -		up(&Adapter->NVMRdmWrmLock); -		return Status; +		return -EINVAL;  	} -	case IOCTL_BE_BUCKET_SIZE: -		Status = 0; -		if (get_user(Adapter->BEBucketSize, (unsigned long __user *)arg)) -			Status = -EFAULT; -		break; +	if (down_trylock(&Adapter->NVMRdmWrmLock)) { +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +				"FW download blocked as EEPROM Read/Write is in progress\n"); +		up(&Adapter->fw_download_sema); +		return -EACCES; +	} -	case IOCTL_RTPS_BUCKET_SIZE: -		Status = 0; -		if (get_user(Adapter->rtPSBucketSize, (unsigned long __user *)arg)) -			Status = -EFAULT; -		break; +	Adapter->bBinDownloaded = TRUE; +	Adapter->bCfgDownloaded = TRUE; +	atomic_set(&Adapter->CurrNumFreeTxDesc, 0); +	Adapter->CurrNumRecvDescs = 0; +	Adapter->downloadDDR = 0; -	case IOCTL_CHIP_RESET: { -		INT NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock); -		if (NVMAccess) { -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, " IOCTL_BCM_CHIP_RESET not allowed as EEPROM Read/Write is in progress\n"); -			return -EACCES; -		} +	/* setting the Mips to Run */ +	Status = run_card_proc(Adapter); -		down(&Adapter->RxAppControlQueuelock); -		Status = reset_card_proc(Adapter); -		flushAllAppQ(); -		up(&Adapter->RxAppControlQueuelock); +	if (Status) { +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +			"Firm Download Failed\n"); +		up(&Adapter->fw_download_sema);  		up(&Adapter->NVMRdmWrmLock); -		ResetCounters(Adapter); -		break; +		return Status; +	} else { +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, +				DBG_LVL_ALL, "Firm Download Over...\n");  	} -	case IOCTL_QOS_THRESHOLD: { -		USHORT uiLoopIndex; +	mdelay(10); -		Status = 0; -		for (uiLoopIndex = 0; uiLoopIndex < NO_OF_QUEUES; uiLoopIndex++) { -			if (get_user(Adapter->PackInfo[uiLoopIndex].uiThreshold, -					(unsigned long __user *)arg)) { -				Status = -EFAULT; -				break; -			} -		} -		break; +	/* Wait for MailBox Interrupt */ +	if (StartInterruptUrb((struct bcm_interface_adapter *)Adapter->pvInterfaceAdapter)) +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +			"Unable to send interrupt...\n"); + +	timeout = 5*HZ; +	Adapter->waiting_to_fw_download_done = false; +	wait_event_timeout(Adapter->ioctl_fw_dnld_wait_queue, +			Adapter->waiting_to_fw_download_done, timeout); +	Adapter->fw_download_process_pid = INVALID_PID; +	Adapter->fw_download_done = TRUE; +	atomic_set(&Adapter->CurrNumFreeTxDesc, 0); +	Adapter->CurrNumRecvDescs = 0; +	Adapter->PrevNumRecvDescs = 0; +	atomic_set(&Adapter->cntrlpktCnt, 0); +	Adapter->LinkUpStatus = 0; +	Adapter->LinkStatus = 0; + +	if (Adapter->LEDInfo.led_thread_running & +		BCM_LED_THREAD_RUNNING_ACTIVELY) { +		Adapter->DriverState = FW_DOWNLOAD_DONE; +		wake_up(&Adapter->LEDInfo.notify_led_event);  	} -	case IOCTL_DUMP_PACKET_INFO: -		DumpPackInfo(Adapter); -		DumpPhsRules(&Adapter->stBCMPhsContext); -		Status = STATUS_SUCCESS; -		break; +	if (!timeout) +		Status = -ENODEV; -	case IOCTL_GET_PACK_INFO: -		if (copy_to_user(argp, &Adapter->PackInfo, sizeof(struct bcm_packet_info)*NO_OF_QUEUES)) -			return -EFAULT; -		Status = STATUS_SUCCESS; -		break; +	up(&Adapter->fw_download_sema); +	up(&Adapter->NVMRdmWrmLock); +	return Status; +} -	case IOCTL_BCM_SWITCH_TRANSFER_MODE: { -		UINT uiData = 0; -		if (copy_from_user(&uiData, argp, sizeof(UINT))) -			return -EFAULT; +static int bcm_char_ioctl_chip_reset(struct bcm_mini_adapter *Adapter) +{ +	INT Status; +	INT NVMAccess; -		if (uiData) { -			/* Allow All Packets */ -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SWITCH_TRANSFER_MODE: ETH_PACKET_TUNNELING_MODE\n"); -				Adapter->TransferMode = ETH_PACKET_TUNNELING_MODE; -		} else { -			/* Allow IP only Packets */ -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SWITCH_TRANSFER_MODE: IP_PACKET_ONLY_MODE\n"); -			Adapter->TransferMode = IP_PACKET_ONLY_MODE; -		} -		Status = STATUS_SUCCESS; -		break; +	NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock); +	if (NVMAccess) { +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +			" IOCTL_BCM_CHIP_RESET not allowed as EEPROM Read/Write is in progress\n"); +		return -EACCES;  	} -	case IOCTL_BCM_GET_DRIVER_VERSION: { -		ulong len; - -		/* Copy Ioctl Buffer structure */ -		if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) -			return -EFAULT; +	down(&Adapter->RxAppControlQueuelock); +	Status = reset_card_proc(Adapter); +	flushAllAppQ(); +	up(&Adapter->RxAppControlQueuelock); +	up(&Adapter->NVMRdmWrmLock); +	ResetCounters(Adapter); +	return Status; +} -		len = min_t(ulong, IoBuffer.OutputLength, strlen(DRV_VERSION) + 1); +static int bcm_char_ioctl_qos_threshold(ULONG arg, +					struct bcm_mini_adapter *Adapter) +{ +	USHORT uiLoopIndex; -		if (copy_to_user(IoBuffer.OutputBuffer, DRV_VERSION, len)) +	for (uiLoopIndex = 0; uiLoopIndex < NO_OF_QUEUES; uiLoopIndex++) { +		if (get_user(Adapter->PackInfo[uiLoopIndex].uiThreshold, +				(unsigned long __user *)arg)) {  			return -EFAULT; -		Status = STATUS_SUCCESS; -		break; +		}  	} +	return 0; +} -	case IOCTL_BCM_GET_CURRENT_STATUS: { -		struct bcm_link_state link_state; +static int bcm_char_ioctl_switch_transfer_mode(void __user *argp, +	struct bcm_mini_adapter *Adapter) +{ +	UINT uiData = 0; -		/* Copy Ioctl Buffer structure */ -		if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) { -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "copy_from_user failed..\n"); -			return -EFAULT; -		} +	if (copy_from_user(&uiData, argp, sizeof(UINT))) +		return -EFAULT; -		if (IoBuffer.OutputLength != sizeof(link_state)) { -			Status = -EINVAL; -			break; -		} +	if (uiData) { +		/* Allow All Packets */ +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, +			"IOCTL_BCM_SWITCH_TRANSFER_MODE: ETH_PACKET_TUNNELING_MODE\n"); +			Adapter->TransferMode = ETH_PACKET_TUNNELING_MODE; +	} else { +		/* Allow IP only Packets */ +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, +			"IOCTL_BCM_SWITCH_TRANSFER_MODE: IP_PACKET_ONLY_MODE\n"); +		Adapter->TransferMode = IP_PACKET_ONLY_MODE; +	} +	return STATUS_SUCCESS; +} -		memset(&link_state, 0, sizeof(link_state)); -		link_state.bIdleMode = Adapter->IdleMode; -		link_state.bShutdownMode = Adapter->bShutStatus; -		link_state.ucLinkStatus = Adapter->LinkStatus; +static int bcm_char_ioctl_get_driver_version(void __user *argp) +{ +	struct bcm_ioctl_buffer IoBuffer; +	ulong len; -		if (copy_to_user(IoBuffer.OutputBuffer, &link_state, min_t(size_t, sizeof(link_state), IoBuffer.OutputLength))) { -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy_to_user Failed..\n"); -			return -EFAULT; -		} -		Status = STATUS_SUCCESS; -		break; -	} +	/* Copy Ioctl Buffer structure */ +	if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) +		return -EFAULT; -	case IOCTL_BCM_SET_MAC_TRACING: { -		UINT  tracing_flag; +	len = min_t(ulong, IoBuffer.OutputLength, strlen(DRV_VERSION) + 1); -		/* copy ioctl Buffer structure */ -		if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) -			return -EFAULT; +	if (copy_to_user(IoBuffer.OutputBuffer, DRV_VERSION, len)) +		return -EFAULT; -		if (copy_from_user(&tracing_flag, IoBuffer.InputBuffer, sizeof(UINT))) -			return -EFAULT; +	return STATUS_SUCCESS; +} -		if (tracing_flag) -			Adapter->pTarangs->MacTracingEnabled = TRUE; -		else -			Adapter->pTarangs->MacTracingEnabled = FALSE; -		break; -	} +static int bcm_char_ioctl_get_current_status(void __user *argp, +	struct bcm_mini_adapter *Adapter) +{ +	struct bcm_link_state link_state; +	struct bcm_ioctl_buffer IoBuffer; -	case IOCTL_BCM_GET_DSX_INDICATION: { -		ULONG ulSFId = 0; -		if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_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(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; -		} +	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(struct bcm_ioctl_buffer))) -			return -EFAULT; +static int bcm_char_ioctl_set_mac_tracing(void __user *argp, +	struct bcm_mini_adapter *Adapter) +{ +	struct bcm_ioctl_buffer IoBuffer; +	UINT tracing_flag; -		if (IoBuffer.OutputLength != sizeof(struct bcm_host_stats_mibs)) { -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, -					"Length Check failed %lu %zd\n", -					IoBuffer.OutputLength, sizeof(struct bcm_host_stats_mibs)); -			return -EINVAL; -		} +	/* copy ioctl Buffer structure */ +	if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) +		return -EFAULT; -		/* FIXME: HOST_STATS are too big for kmalloc (122048)! */ -		temp_buff = kzalloc(sizeof(struct bcm_host_stats_mibs), GFP_KERNEL); -		if (!temp_buff) -			return STATUS_FAILURE; +	if (copy_from_user(&tracing_flag, IoBuffer.InputBuffer, sizeof(UINT))) +		return -EFAULT; -		Status = ProcessGetHostMibs(Adapter, temp_buff); -		GetDroppedAppCntrlPktMibs(temp_buff, pTarang); +	if (tracing_flag) +		Adapter->pTarangs->MacTracingEnabled = TRUE; +	else +		Adapter->pTarangs->MacTracingEnabled = false; -		if (Status != STATUS_FAILURE) -			if (copy_to_user(IoBuffer.OutputBuffer, temp_buff, sizeof(struct bcm_host_stats_mibs))) { -				kfree(temp_buff); -				return -EFAULT; -			} +	return STATUS_SUCCESS; +} -		kfree(temp_buff); -		break; +static int bcm_char_ioctl_get_dsx_indication(void __user *argp, +	struct bcm_mini_adapter *Adapter) +{ +	struct bcm_ioctl_buffer IoBuffer; +	ULONG ulSFId = 0; + +	if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) +		return -EFAULT; + +	if (IoBuffer.OutputLength < sizeof(struct bcm_add_indication_alt)) { +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +			"Mismatch req: %lx needed is =0x%zx!!!", +			IoBuffer.OutputLength, +			sizeof(struct bcm_add_indication_alt)); +		return -EINVAL;  	} -	case IOCTL_BCM_WAKE_UP_DEVICE_FROM_IDLE: -		if ((FALSE == Adapter->bTriedToWakeUpFromlowPowerMode) && (TRUE == Adapter->IdleMode)) { -			Adapter->usIdleModePattern = ABORT_IDLE_MODE; -			Adapter->bWakeUpDevice = TRUE; -			wake_up(&Adapter->process_rx_cntrlpkt); -		} +	if (copy_from_user(&ulSFId, IoBuffer.InputBuffer, sizeof(ulSFId))) +		return -EFAULT; -		Status = STATUS_SUCCESS; -		break; +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, +		"Get DSX Data SF ID is =%lx\n", ulSFId); +	get_dsx_sf_data_to_application(Adapter, ulSFId, IoBuffer.OutputBuffer); +	return STATUS_SUCCESS; +} -	case IOCTL_BCM_BULK_WRM: { -		struct bcm_bulk_wrm_buffer *pBulkBuffer; -		UINT uiTempVar = 0; -		PCHAR pvBuffer = NULL; +static int bcm_char_ioctl_get_host_mibs(void __user *argp, +	struct bcm_mini_adapter *Adapter, struct bcm_tarang_data *pTarang) +{ +	struct bcm_ioctl_buffer IoBuffer; +	INT Status = STATUS_FAILURE; +	PVOID temp_buff; -		if ((Adapter->IdleMode == TRUE) || -			(Adapter->bShutStatus == TRUE) || -			(Adapter->bPreparingForLowPowerMode == TRUE)) { +	if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) +		return -EFAULT; -			BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "Device in Idle/Shutdown Mode, Blocking Wrms\n"); -			Status = -EACCES; -			break; -		} +	if (IoBuffer.OutputLength != sizeof(struct bcm_host_stats_mibs)) { +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +			"Length Check failed %lu %zd\n", IoBuffer.OutputLength, +			sizeof(struct bcm_host_stats_mibs)); +		return -EINVAL; +	} + +	/* FIXME: HOST_STATS are too big for kmalloc (122048)! */ +	temp_buff = kzalloc(sizeof(struct bcm_host_stats_mibs), GFP_KERNEL); +	if (!temp_buff) +		return STATUS_FAILURE; -		/* Copy Ioctl Buffer structure */ -		if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) +	Status = ProcessGetHostMibs(Adapter, temp_buff); +	GetDroppedAppCntrlPktMibs(temp_buff, pTarang); + +	if (Status != STATUS_FAILURE) { +		if (copy_to_user(IoBuffer.OutputBuffer, temp_buff, +			sizeof(struct bcm_host_stats_mibs))) { +			kfree(temp_buff);  			return -EFAULT; +		} +	} -		if (IoBuffer.InputLength < sizeof(ULONG) * 2) -			return -EINVAL; +	kfree(temp_buff); +	return Status; +} -		pvBuffer = memdup_user(IoBuffer.InputBuffer, -				       IoBuffer.InputLength); -		if (IS_ERR(pvBuffer)) -			return PTR_ERR(pvBuffer); +static int bcm_char_ioctl_bulk_wrm(void __user *argp, +	struct bcm_mini_adapter *Adapter, UINT cmd) +{ +	struct bcm_bulk_wrm_buffer *pBulkBuffer; +	struct bcm_ioctl_buffer IoBuffer; +	UINT uiTempVar = 0; +	INT Status = STATUS_FAILURE; +	PCHAR pvBuffer = NULL; -		pBulkBuffer = (struct bcm_bulk_wrm_buffer *)pvBuffer; +	if ((Adapter->IdleMode == TRUE) || +		(Adapter->bShutStatus == TRUE) || +		(Adapter->bPreparingForLowPowerMode == TRUE)) { -		if (((ULONG)pBulkBuffer->Register & 0x0F000000) != 0x0F000000 || -			((ULONG)pBulkBuffer->Register & 0x3)) { -			BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "WRM Done On invalid Address : %x Access Denied.\n", (int)pBulkBuffer->Register); -			kfree(pvBuffer); -			Status = -EINVAL; -			break; -		} +		BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, +			"Device in Idle/Shutdown Mode, Blocking Wrms\n"); +		return -EACCES; +	} -		uiTempVar = pBulkBuffer->Register & EEPROM_REJECT_MASK; -		if (!((Adapter->pstargetparams->m_u32Customize)&VSG_MODE) && -			((uiTempVar == EEPROM_REJECT_REG_1) || -				(uiTempVar == EEPROM_REJECT_REG_2) || -				(uiTempVar == EEPROM_REJECT_REG_3) || -				(uiTempVar == EEPROM_REJECT_REG_4)) && -			(cmd == IOCTL_BCM_REGISTER_WRITE)) { +	/* Copy Ioctl Buffer structure */ +	if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) +		return -EFAULT; -			kfree(pvBuffer); -			BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "EEPROM Access Denied, not in VSG Mode\n"); -			Status = -EFAULT; -			break; -		} +	if (IoBuffer.InputLength < sizeof(ULONG) * 2) +		return -EINVAL; -		if (pBulkBuffer->SwapEndian == FALSE) -			Status = wrmWithLock(Adapter, (UINT)pBulkBuffer->Register, (PCHAR)pBulkBuffer->Values, IoBuffer.InputLength - 2*sizeof(ULONG)); -		else -			Status = wrmaltWithLock(Adapter, (UINT)pBulkBuffer->Register, (PUINT)pBulkBuffer->Values, IoBuffer.InputLength - 2*sizeof(ULONG)); +	pvBuffer = memdup_user(IoBuffer.InputBuffer, +			       IoBuffer.InputLength); +	if (IS_ERR(pvBuffer)) +		return PTR_ERR(pvBuffer); -		if (Status != STATUS_SUCCESS) -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "WRM Failed\n"); +	pBulkBuffer = (struct bcm_bulk_wrm_buffer *)pvBuffer; +	if (((ULONG)pBulkBuffer->Register & 0x0F000000) != 0x0F000000 || +		((ULONG)pBulkBuffer->Register & 0x3)) { +		BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, +			"WRM Done On invalid Address : %x Access Denied.\n", +			(int)pBulkBuffer->Register);  		kfree(pvBuffer); -		break; +		return -EINVAL;  	} -	case IOCTL_BCM_GET_NVM_SIZE: -		if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) +	uiTempVar = pBulkBuffer->Register & EEPROM_REJECT_MASK; +	if (!((Adapter->pstargetparams->m_u32Customize)&VSG_MODE) && +		((uiTempVar == EEPROM_REJECT_REG_1) || +			(uiTempVar == EEPROM_REJECT_REG_2) || +			(uiTempVar == EEPROM_REJECT_REG_3) || +			(uiTempVar == EEPROM_REJECT_REG_4)) && +		(cmd == IOCTL_BCM_REGISTER_WRITE)) { + +		kfree(pvBuffer); +		BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, +			"EEPROM Access Denied, not in VSG Mode\n"); +		return -EFAULT; +	} + +	if (pBulkBuffer->SwapEndian == false) +		Status = wrmWithLock(Adapter, (UINT)pBulkBuffer->Register, +			(PCHAR)pBulkBuffer->Values, +			IoBuffer.InputLength - 2*sizeof(ULONG)); +	else +		Status = wrmaltWithLock(Adapter, (UINT)pBulkBuffer->Register, +			(PUINT)pBulkBuffer->Values, +			IoBuffer.InputLength - 2*sizeof(ULONG)); + +	if (Status != STATUS_SUCCESS) +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "WRM Failed\n"); + +	kfree(pvBuffer); +	return Status; +} + +static int bcm_char_ioctl_get_nvm_size(void __user *argp, +	struct bcm_mini_adapter *Adapter) +{ +	struct bcm_ioctl_buffer IoBuffer; + +	if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) +		return -EFAULT; + +	if (Adapter->eNVMType == NVM_EEPROM || Adapter->eNVMType == NVM_FLASH) { +		if (copy_to_user(IoBuffer.OutputBuffer, &Adapter->uiNVMDSDSize, +			sizeof(UINT)))  			return -EFAULT; +	} -		if (Adapter->eNVMType == NVM_EEPROM || Adapter->eNVMType == NVM_FLASH) { -			if (copy_to_user(IoBuffer.OutputBuffer, &Adapter->uiNVMDSDSize, sizeof(UINT))) -				return -EFAULT; -		} +	return STATUS_SUCCESS; +} -		Status = STATUS_SUCCESS; -		break; +static int bcm_char_ioctl_cal_init(void __user *argp, +	struct bcm_mini_adapter *Adapter) +{ +	struct bcm_ioctl_buffer IoBuffer; +	UINT uiSectorSize = 0; +	INT Status = STATUS_FAILURE; -	case IOCTL_BCM_CAL_INIT: { -		UINT uiSectorSize = 0 ; -		if (Adapter->eNVMType == NVM_FLASH) { -			if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) -				return -EFAULT; +	if (Adapter->eNVMType == NVM_FLASH) { +		if (copy_from_user(&IoBuffer, argp, +			sizeof(struct bcm_ioctl_buffer))) +			return -EFAULT; -			if (copy_from_user(&uiSectorSize, IoBuffer.InputBuffer, sizeof(UINT))) -				return -EFAULT; +		if (copy_from_user(&uiSectorSize, IoBuffer.InputBuffer, +			sizeof(UINT))) +			return -EFAULT; -			if ((uiSectorSize < MIN_SECTOR_SIZE) || (uiSectorSize > MAX_SECTOR_SIZE)) { -				if (copy_to_user(IoBuffer.OutputBuffer, &Adapter->uiSectorSize, -							sizeof(UINT))) +		if ((uiSectorSize < MIN_SECTOR_SIZE) || +			(uiSectorSize > MAX_SECTOR_SIZE)) { +			if (copy_to_user(IoBuffer.OutputBuffer, +				&Adapter->uiSectorSize, sizeof(UINT))) +				return -EFAULT; +		} else { +			if (IsFlash2x(Adapter)) { +				if (copy_to_user(IoBuffer.OutputBuffer, +					&Adapter->uiSectorSize, sizeof(UINT)))  					return -EFAULT;  			} else { -				if (IsFlash2x(Adapter)) { -					if (copy_to_user(IoBuffer.OutputBuffer,	&Adapter->uiSectorSize, sizeof(UINT))) -						return -EFAULT; -				} else { -					if ((TRUE == Adapter->bShutStatus) || (TRUE == Adapter->IdleMode)) { -						BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Device is in Idle/Shutdown Mode\n"); -						return -EACCES; -					} - -					Adapter->uiSectorSize = uiSectorSize; -					BcmUpdateSectorSize(Adapter, Adapter->uiSectorSize); +				if ((TRUE == Adapter->bShutStatus) || +					(TRUE == Adapter->IdleMode)) { +					BCM_DEBUG_PRINT(Adapter, +						DBG_TYPE_PRINTK, 0, 0, +						"Device is in Idle/Shutdown Mode\n"); +					return -EACCES;  				} + +				Adapter->uiSectorSize = uiSectorSize; +				BcmUpdateSectorSize(Adapter, +					Adapter->uiSectorSize);  			} -			Status = STATUS_SUCCESS; -		} else { -			Status = STATUS_FAILURE;  		} +		Status = STATUS_SUCCESS; +	} else { +		Status = STATUS_FAILURE;  	} -	break; +	return Status; +} -	case IOCTL_BCM_SET_DEBUG: +static int bcm_char_ioctl_set_debug(void __user *argp, +	struct bcm_mini_adapter *Adapter) +{  #ifdef DEBUG -	{ -		struct bcm_user_debug_state sUserDebugState; +	struct bcm_ioctl_buffer IoBuffer; +	struct bcm_user_debug_state sUserDebugState; -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "In SET_DEBUG ioctl\n"); -		if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) -			return -EFAULT; +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, +		"In SET_DEBUG ioctl\n"); +	if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) +		return -EFAULT; -		if (copy_from_user(&sUserDebugState, IoBuffer.InputBuffer, sizeof(struct bcm_user_debug_state))) -			return -EFAULT; +	if (copy_from_user(&sUserDebugState, IoBuffer.InputBuffer, +		sizeof(struct bcm_user_debug_state))) +		return -EFAULT; -		BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "IOCTL_BCM_SET_DEBUG: OnOff=%d Type = 0x%x ", -				sUserDebugState.OnOff, sUserDebugState.Type); -		/* sUserDebugState.Subtype <<= 1; */ -		sUserDebugState.Subtype = 1 << sUserDebugState.Subtype; -		BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "actual Subtype=0x%x\n", sUserDebugState.Subtype); - -		/* Update new 'DebugState' in the Adapter */ -		Adapter->stDebugState.type |= sUserDebugState.Type; -		/* Subtype: A bitmap of 32 bits for Subtype per Type. -		 * Valid indexes in 'subtype' array: 1,2,4,8 -		 * corresponding to valid Type values. Hence we can use the 'Type' field -		 * as the index value, ignoring the array entries 0,3,5,6,7 ! -		 */ -		if (sUserDebugState.OnOff) -			Adapter->stDebugState.subtype[sUserDebugState.Type] |= sUserDebugState.Subtype; -		else -			Adapter->stDebugState.subtype[sUserDebugState.Type] &= ~sUserDebugState.Subtype; +	BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, +			"IOCTL_BCM_SET_DEBUG: OnOff=%d Type = 0x%x ", +			sUserDebugState.OnOff, sUserDebugState.Type); +	/* sUserDebugState.Subtype <<= 1; */ +	sUserDebugState.Subtype = 1 << sUserDebugState.Subtype; +	BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, +		"actual Subtype=0x%x\n", sUserDebugState.Subtype); + +	/* Update new 'DebugState' in the Adapter */ +	Adapter->stDebugState.type |= sUserDebugState.Type; +	/* Subtype: A bitmap of 32 bits for Subtype per Type. +	 * Valid indexes in 'subtype' array: 1,2,4,8 +	 * corresponding to valid Type values. Hence we can use the 'Type' field +	 * as the index value, ignoring the array entries 0,3,5,6,7 ! +	 */ +	if (sUserDebugState.OnOff) +		Adapter->stDebugState.subtype[sUserDebugState.Type] |= +			sUserDebugState.Subtype; +	else +		Adapter->stDebugState.subtype[sUserDebugState.Type] &= +			~sUserDebugState.Subtype; + +	BCM_SHOW_DEBUG_BITMAP(Adapter); +#endif +	return STATUS_SUCCESS; +} + +static int bcm_char_ioctl_nvm_rw(void __user *argp, +	struct bcm_mini_adapter *Adapter, UINT cmd) +{ +	struct bcm_nvm_readwrite stNVMReadWrite; +	struct timeval tv0, tv1; +	struct bcm_ioctl_buffer IoBuffer; +	PUCHAR pReadData = NULL; +	INT Status = STATUS_FAILURE; -		BCM_SHOW_DEBUG_BITMAP(Adapter); +	memset(&tv0, 0, sizeof(struct timeval)); +	memset(&tv1, 0, sizeof(struct timeval)); +	if ((Adapter->eNVMType == NVM_FLASH) && +		(Adapter->uiFlashLayoutMajorVersion == 0)) { +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +			"The Flash Control Section is Corrupted. Hence Rejection on NVM Read/Write\n"); +		return -EFAULT;  	} -#endif -	break; -	case IOCTL_BCM_NVM_READ: -	case IOCTL_BCM_NVM_WRITE: { -		struct bcm_nvm_readwrite stNVMReadWrite; -		PUCHAR pReadData = NULL; -		ULONG ulDSDMagicNumInUsrBuff = 0; -		struct timeval tv0, tv1; -		memset(&tv0, 0, sizeof(struct timeval)); -		memset(&tv1, 0, sizeof(struct timeval)); -		if ((Adapter->eNVMType == NVM_FLASH) && (Adapter->uiFlashLayoutMajorVersion == 0)) { -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "The Flash Control Section is Corrupted. Hence Rejection on NVM Read/Write\n"); -			return -EFAULT; +	if (IsFlash2x(Adapter)) { +		if ((Adapter->eActiveDSD != DSD0) && +			(Adapter->eActiveDSD != DSD1) && +			(Adapter->eActiveDSD != DSD2)) { + +			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +				"No DSD is active..hence NVM Command is blocked"); +			return STATUS_FAILURE;  		} +	} -		if (IsFlash2x(Adapter)) { -			if ((Adapter->eActiveDSD != DSD0) && -				(Adapter->eActiveDSD != DSD1) && -				(Adapter->eActiveDSD != DSD2)) { +	/* Copy Ioctl Buffer structure */ +	if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) +		return -EFAULT; -				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "No DSD is active..hence NVM Command is blocked"); -				return STATUS_FAILURE; -			} +	if (copy_from_user(&stNVMReadWrite, +				(IOCTL_BCM_NVM_READ == cmd) ? +				IoBuffer.OutputBuffer : IoBuffer.InputBuffer, +				sizeof(struct bcm_nvm_readwrite))) +		return -EFAULT; + +	/* +	 * Deny the access if the offset crosses the cal area limit. +	 */ +	if (stNVMReadWrite.uiNumBytes > Adapter->uiNVMDSDSize) +		return STATUS_FAILURE; + +	if (stNVMReadWrite.uiOffset > +		Adapter->uiNVMDSDSize - stNVMReadWrite.uiNumBytes) +		return STATUS_FAILURE; + +	pReadData = memdup_user(stNVMReadWrite.pBuffer, +				stNVMReadWrite.uiNumBytes); +	if (IS_ERR(pReadData)) +		return PTR_ERR(pReadData); + +	do_gettimeofday(&tv0); +	if (IOCTL_BCM_NVM_READ == cmd) { +		int ret = bcm_handle_nvm_read_cmd(Adapter, pReadData, +				&stNVMReadWrite); +		if (ret != STATUS_SUCCESS) +			return ret; +	} else { +		down(&Adapter->NVMRdmWrmLock); + +		if ((Adapter->IdleMode == TRUE) || +			(Adapter->bShutStatus == TRUE) || +			(Adapter->bPreparingForLowPowerMode == TRUE)) { + +			BCM_DEBUG_PRINT(Adapter, +				DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, +				"Device is in Idle/Shutdown Mode\n"); +			up(&Adapter->NVMRdmWrmLock); +			kfree(pReadData); +			return -EACCES;  		} -		/* Copy Ioctl Buffer structure */ -		if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) -			return -EFAULT; +		Adapter->bHeaderChangeAllowed = TRUE; +		if (IsFlash2x(Adapter)) { +			int ret = handle_flash2x_adapter(Adapter, +							pReadData, +							&stNVMReadWrite); +			if (ret != STATUS_SUCCESS) +				return ret; +		} -		if (copy_from_user(&stNVMReadWrite, -					(IOCTL_BCM_NVM_READ == cmd) ? IoBuffer.OutputBuffer : IoBuffer.InputBuffer, -					sizeof(struct bcm_nvm_readwrite))) -			return -EFAULT; +		Status = BeceemNVMWrite(Adapter, (PUINT)pReadData, +			stNVMReadWrite.uiOffset, stNVMReadWrite.uiNumBytes, +			stNVMReadWrite.bVerify); +		if (IsFlash2x(Adapter)) +			BcmFlash2xWriteSig(Adapter, Adapter->eActiveDSD); -		/* -		 * Deny the access if the offset crosses the cal area limit. -		 */ -		if (stNVMReadWrite.uiNumBytes > Adapter->uiNVMDSDSize) -			return STATUS_FAILURE; +		Adapter->bHeaderChangeAllowed = false; -		if (stNVMReadWrite.uiOffset > Adapter->uiNVMDSDSize - stNVMReadWrite.uiNumBytes) { -			/* BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Can't allow access beyond NVM Size: 0x%x 0x%x\n", stNVMReadWrite.uiOffset, stNVMReadWrite.uiNumBytes); */ -			return STATUS_FAILURE; +		up(&Adapter->NVMRdmWrmLock); + +		if (Status != STATUS_SUCCESS) { +			kfree(pReadData); +			return Status;  		} +	} -		pReadData = memdup_user(stNVMReadWrite.pBuffer, -					stNVMReadWrite.uiNumBytes); -		if (IS_ERR(pReadData)) -			return PTR_ERR(pReadData); +	do_gettimeofday(&tv1); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, +		" timetaken by Write/read :%ld msec\n", +		(tv1.tv_sec - tv0.tv_sec)*1000 + +		(tv1.tv_usec - tv0.tv_usec)/1000); -		do_gettimeofday(&tv0); -		if (IOCTL_BCM_NVM_READ == cmd) { -			down(&Adapter->NVMRdmWrmLock); +	kfree(pReadData); +	return STATUS_SUCCESS; +} -			if ((Adapter->IdleMode == TRUE) || -				(Adapter->bShutStatus == TRUE) || -				(Adapter->bPreparingForLowPowerMode == TRUE)) { +static int bcm_char_ioctl_flash2x_section_read(void __user *argp, +	struct bcm_mini_adapter *Adapter) +{ +	struct bcm_flash2x_readwrite sFlash2xRead = {0}; +	struct bcm_ioctl_buffer IoBuffer; +	PUCHAR pReadBuff = NULL; +	UINT NOB = 0; +	UINT BuffSize = 0; +	UINT ReadBytes = 0; +	UINT ReadOffset = 0; +	INT Status = STATUS_FAILURE; +	void __user *OutPutBuff; -				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); -				up(&Adapter->NVMRdmWrmLock); -				kfree(pReadData); -				return -EACCES; -			} +	if (IsFlash2x(Adapter) != TRUE)	{ +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +			"Flash Does not have 2.x map"); +		return -EINVAL; +	} -			Status = BeceemNVMRead(Adapter, (PUINT)pReadData, stNVMReadWrite.uiOffset, stNVMReadWrite.uiNumBytes); -			up(&Adapter->NVMRdmWrmLock); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, +		DBG_LVL_ALL, "IOCTL_BCM_FLASH2X_SECTION_READ Called"); +	if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) +		return -EFAULT; -			if (Status != STATUS_SUCCESS) { -				kfree(pReadData); -				return Status; -			} +	/* Reading FLASH 2.x READ structure */ +	if (copy_from_user(&sFlash2xRead, IoBuffer.InputBuffer, +		sizeof(struct bcm_flash2x_readwrite))) +		return -EFAULT; -			if (copy_to_user(stNVMReadWrite.pBuffer, pReadData, stNVMReadWrite.uiNumBytes)) { -				kfree(pReadData); -				return -EFAULT; -			} -		} else { -			down(&Adapter->NVMRdmWrmLock); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, +			"\nsFlash2xRead.Section :%x", +			sFlash2xRead.Section); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, +			"\nsFlash2xRead.offset :%x", +			sFlash2xRead.offset); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, +			"\nsFlash2xRead.numOfBytes :%x", +			sFlash2xRead.numOfBytes); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, +			"\nsFlash2xRead.bVerify :%x\n", +			sFlash2xRead.bVerify); + +	/* This was internal to driver for raw read. +	 * now it has ben exposed to user space app. +	 */ +	if (validateFlash2xReadWrite(Adapter, &sFlash2xRead) == false) +		return STATUS_FAILURE; + +	NOB = sFlash2xRead.numOfBytes; +	if (NOB > Adapter->uiSectorSize) +		BuffSize = Adapter->uiSectorSize; +	else +		BuffSize = NOB; + +	ReadOffset = sFlash2xRead.offset; +	OutPutBuff = IoBuffer.OutputBuffer; +	pReadBuff = (PCHAR)kzalloc(BuffSize , GFP_KERNEL); + +	if (pReadBuff == NULL) { +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +				"Memory allocation failed for Flash 2.x Read Structure"); +		return -ENOMEM; +	} +	down(&Adapter->NVMRdmWrmLock); -			if ((Adapter->IdleMode == TRUE) || -				(Adapter->bShutStatus == TRUE) || -				(Adapter->bPreparingForLowPowerMode == TRUE)) { +	if ((Adapter->IdleMode == TRUE) || +		(Adapter->bShutStatus == TRUE) || +		(Adapter->bPreparingForLowPowerMode == TRUE)) { -				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); -				up(&Adapter->NVMRdmWrmLock); -				kfree(pReadData); -				return -EACCES; -			} +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, +				DBG_LVL_ALL, +				"Device is in Idle/Shutdown Mode\n"); +		up(&Adapter->NVMRdmWrmLock); +		kfree(pReadBuff); +		return -EACCES; +	} -			Adapter->bHeaderChangeAllowed = TRUE; -			if (IsFlash2x(Adapter)) { -				/* -				 *			New Requirement:- -				 *			DSD section updation will be allowed in two case:- -				 *			1.  if DSD sig is present in DSD header means dongle is ok and updation is fruitfull -				 *			2.  if point 1 failes then user buff should have DSD sig. this point ensures that if dongle is -				 *			      corrupted then user space program first modify the DSD header with valid DSD sig so -				 *			      that this as well as further write may be worthwhile. -				 * -				 *			 This restriction has been put assuming that if DSD sig is corrupted, DSD -				 *			 data won't be considered valid. -				 */ - -				Status = BcmFlash2xCorruptSig(Adapter, Adapter->eActiveDSD); -				if (Status != STATUS_SUCCESS) { -					if (((stNVMReadWrite.uiOffset + stNVMReadWrite.uiNumBytes) != Adapter->uiNVMDSDSize) || -						(stNVMReadWrite.uiNumBytes < SIGNATURE_SIZE)) { - -						BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "DSD Sig is present neither in Flash nor User provided Input.."); -						up(&Adapter->NVMRdmWrmLock); -						kfree(pReadData); -						return Status; -					} - -					ulDSDMagicNumInUsrBuff = ntohl(*(PUINT)(pReadData + stNVMReadWrite.uiNumBytes - SIGNATURE_SIZE)); -					if (ulDSDMagicNumInUsrBuff != DSD_IMAGE_MAGIC_NUMBER) { -						BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "DSD Sig is present neither in Flash nor User provided Input.."); -						up(&Adapter->NVMRdmWrmLock); -						kfree(pReadData); -						return Status; -					} -				} -			} +	while (NOB) { +		if (NOB > Adapter->uiSectorSize) +			ReadBytes = Adapter->uiSectorSize; +		else +			ReadBytes = NOB; -			Status = BeceemNVMWrite(Adapter, (PUINT)pReadData, stNVMReadWrite.uiOffset, stNVMReadWrite.uiNumBytes, stNVMReadWrite.bVerify); -			if (IsFlash2x(Adapter)) -				BcmFlash2xWriteSig(Adapter, Adapter->eActiveDSD); +		/* Reading the data from Flash 2.x */ +		Status = BcmFlash2xBulkRead(Adapter, (PUINT)pReadBuff, +			sFlash2xRead.Section, ReadOffset, ReadBytes); +		if (Status) { +			BCM_DEBUG_PRINT(Adapter, +				DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, +				"Flash 2x read err with Status :%d", +				Status); +			break; +		} -			Adapter->bHeaderChangeAllowed = FALSE; +		BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, +			DBG_LVL_ALL, pReadBuff, ReadBytes); +		Status = copy_to_user(OutPutBuff, pReadBuff, ReadBytes); +		if (Status) { +			BCM_DEBUG_PRINT(Adapter, +				DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, +				"Copy to use failed with status :%d", Status);  			up(&Adapter->NVMRdmWrmLock); - -			if (Status != STATUS_SUCCESS) { -				kfree(pReadData); -				return Status; -			} +			kfree(pReadBuff); +			return -EFAULT; +		} +		NOB = NOB - ReadBytes; +		if (NOB) { +			ReadOffset = ReadOffset + ReadBytes; +			OutPutBuff = OutPutBuff + ReadBytes;  		} +	} -		do_gettimeofday(&tv1); -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, " timetaken by Write/read :%ld msec\n", (tv1.tv_sec - tv0.tv_sec)*1000 + (tv1.tv_usec - tv0.tv_usec)/1000); +	up(&Adapter->NVMRdmWrmLock); +	kfree(pReadBuff); +	return Status; +} -		kfree(pReadData); -		return STATUS_SUCCESS; +static int bcm_char_ioctl_flash2x_section_write(void __user *argp, +	struct bcm_mini_adapter *Adapter) +{ +	struct bcm_flash2x_readwrite sFlash2xWrite = {0}; +	struct bcm_ioctl_buffer IoBuffer; +	PUCHAR pWriteBuff; +	void __user *InputAddr; +	UINT NOB = 0; +	UINT BuffSize = 0; +	UINT WriteOffset = 0; +	UINT WriteBytes = 0; +	INT Status = STATUS_FAILURE; + +	if (IsFlash2x(Adapter) != TRUE) { +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +			"Flash Does not have 2.x map"); +		return -EINVAL;  	} -	case IOCTL_BCM_FLASH2X_SECTION_READ: { -		struct bcm_flash2x_readwrite sFlash2xRead = {0}; -		PUCHAR pReadBuff = NULL ; -		UINT NOB = 0; -		UINT BuffSize = 0; -		UINT ReadBytes = 0; -		UINT ReadOffset = 0; -		void __user *OutPutBuff; +	/* First make this False so that we can enable the Sector +	 * Permission Check in BeceemFlashBulkWrite +	 */ +	Adapter->bAllDSDWriteAllow = false; -		if (IsFlash2x(Adapter) != TRUE)	{ -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Does not have 2.x map"); -			return -EINVAL; -		} +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, +		"IOCTL_BCM_FLASH2X_SECTION_WRITE Called"); -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_FLASH2X_SECTION_READ Called"); -		if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) -			return -EFAULT; +	if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) +		return -EFAULT; -		/* Reading FLASH 2.x READ structure */ -		if (copy_from_user(&sFlash2xRead, IoBuffer.InputBuffer, sizeof(struct bcm_flash2x_readwrite))) -			return -EFAULT; +	/* Reading FLASH 2.x READ structure */ +	if (copy_from_user(&sFlash2xWrite, IoBuffer.InputBuffer, +		sizeof(struct bcm_flash2x_readwrite))) +		return -EFAULT; -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.Section :%x", sFlash2xRead.Section); -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.offset :%x", sFlash2xRead.offset); -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.numOfBytes :%x", sFlash2xRead.numOfBytes); -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.bVerify :%x\n", sFlash2xRead.bVerify); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, +		"\nsFlash2xRead.Section :%x", sFlash2xWrite.Section); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, +		"\nsFlash2xRead.offset :%d", sFlash2xWrite.offset); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, +		"\nsFlash2xRead.numOfBytes :%x", sFlash2xWrite.numOfBytes); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, +		"\nsFlash2xRead.bVerify :%x\n", sFlash2xWrite.bVerify); + +	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); -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); +	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; +	} + +	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); + +		/* 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;  		} -		while (NOB) { +		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: { -		struct bcm_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(struct bcm_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(struct bcm_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: { -		struct bcm_flash2x_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(struct bcm_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(struct bcm_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(struct bcm_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(struct bcm_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: { -		enum bcm_flash2x_section_val eFlash2xSectionVal = 0; -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SET_ACTIVE_SECTION Called"); +	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(struct bcm_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: { -		struct bcm_flash2x_copy_section sCopySectStrut = {0}; -		Status = STATUS_SUCCESS; -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_COPY_SECTION  Called"); +	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(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; -		} +	return STATUS_SUCCESS; +} -		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; -		} +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; -		Status = copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer)); +	while (NOB) { +		if (NOB > DEFAULT_BUFF_SIZE) +			ReadBytes = DEFAULT_BUFF_SIZE; +		else +			ReadBytes = NOB; + +		/* Reading the data from Flash 2.x */ +		Status = BeceemNVMRead(Adapter, (PUINT)pReadBuff, +			ReadOffset, ReadBytes);  		if (Status) { -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); -			return -EFAULT; +			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +					"Flash 2x read err with Status :%d", +					Status); +			break;  		} -		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(struct bcm_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(struct bcm_flash2x_cs_info))) -				return -EFAULT; -		} else { -			if (IoBuffer.OutputLength < sizeof(struct bcm_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(struct bcm_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; -		enum bcm_flash2x_section_val eFlash2xSectionVal; -		eFlash2xSectionVal = NO_SECTION_VAL; -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SELECT_DSD Called"); +	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(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; -		} +	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: { -		struct bcm_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(struct bcm_ioctl_buffer))) { -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "copy_from_user 1 failed\n"); -			return -EFAULT; -		} +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, +			"IOCTL_BCM_TIME_SINCE_NET_ENTRY called"); -		if (copy_from_user(&stNVMRead, IoBuffer.OutputBuffer, sizeof(struct bcm_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; + +	case IOCTL_BCM_REGISTER_READ: +	case IOCTL_BCM_EEPROM_REGISTER_READ: +		Status = bcm_char_ioctl_eeprom_reg_read(argp, Adapter); +		return Status; -			BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, pReadBuff, ReadBytes); +	case IOCTL_BCM_REGISTER_WRITE: +	case IOCTL_BCM_EEPROM_REGISTER_WRITE: +		Status = bcm_char_ioctl_eeprom_reg_write(argp, Adapter, cmd); +		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_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(struct bcm_ioctl_buffer)); -		if (Status) { -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "copy of Ioctl buffer is failed from user space"); -			return -EFAULT; -		} +	case IOCTL_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: { -		struct bcm_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(struct bcm_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: { -		struct bcm_time_elapsed stTimeElapsedSinceNetEntry = {0}; +	case IOCTL_BCM_FLASH2X_SECTION_WRITE: +		Status = bcm_char_ioctl_flash2x_section_write(argp, Adapter); +		return Status; -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_TIME_SINCE_NET_ENTRY called"); +	case IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP: +		Status = bcm_char_ioctl_flash2x_section_bitmap(argp, Adapter); +		return Status; -		if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) -			return -EFAULT; +	case IOCTL_BCM_SET_ACTIVE_SECTION: +		Status = bcm_char_ioctl_set_active_section(argp, Adapter); +		return Status; -		if (IoBuffer.OutputLength < sizeof(struct bcm_time_elapsed)) -			return -EINVAL; +	case IOCTL_BCM_IDENTIFY_ACTIVE_SECTION: +		/* Right Now we are taking care of only DSD */ +		Adapter->bAllDSDWriteAllow = false; +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, +				"IOCTL_BCM_IDENTIFY_ACTIVE_SECTION called"); +		Status = STATUS_SUCCESS; +		break; + +	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(struct bcm_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: @@ -2030,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 4e470d4bb4e..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,7 +143,8 @@ static void bcm_get_drvinfo(struct net_device *dev,  			    struct ethtool_drvinfo *info)  {  	struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(dev); -	struct bcm_interface_adapter *psIntfAdapter = Adapter->pvInterfaceAdapter; +	struct bcm_interface_adapter *psIntfAdapter = +						Adapter->pvInterfaceAdapter;  	struct usb_device *udev = interface_to_usbdev(psIntfAdapter->interface);  	strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index 97651450292..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(struct bcm_mibs_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, enum bcm_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);  		}  	} @@ -441,324 +555,262 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* <Pointer  	int i;  	struct bcm_convergence_types *psfCSType = NULL;  	struct bcm_phs_rule sPhsRule; -	USHORT uVCID = Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value; +	struct bcm_packet_info *curr_packinfo = +		&Adapter->PackInfo[uiSearchRuleIndex]; +	USHORT uVCID = curr_packinfo->usVCID_Value;  	UINT UGIValue = 0; -	Adapter->PackInfo[uiSearchRuleIndex].bValid = TRUE; -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Search Rule Index = %d\n", uiSearchRuleIndex); -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "%s: SFID= %x ", __func__, ntohl(psfLocalSet->u32SFID)); -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Updating Queue %d", uiSearchRuleIndex); +	curr_packinfo->bValid = TRUE; +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			"Search Rule Index = %d\n", uiSearchRuleIndex); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			"%s: SFID= %x ", __func__, ntohl(psfLocalSet->u32SFID)); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			"Updating Queue %d", uiSearchRuleIndex);  	ulSFID = ntohl(psfLocalSet->u32SFID);  	/* Store IP Version used */  	/* Get The Version Of IP used (IPv6 or IPv4) from CSSpecification field of SF */ -	Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = 0; -	Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = 0; +	curr_packinfo->bIPCSSupport = 0; +	curr_packinfo->bEthCSSupport = 0;  	/* Enable IP/ETh CS Support As Required */ -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "CopyToAdapter : u8CSSpecification : %X\n", psfLocalSet->u8CSSpecification); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			"CopyToAdapter : u8CSSpecification : %X\n", +			psfLocalSet->u8CSSpecification);  	switch (psfLocalSet->u8CSSpecification) {  	case eCSPacketIPV4: -	{ -		Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV4_CS; +		curr_packinfo->bIPCSSupport = IPV4_CS;  		break; -	}  	case eCSPacketIPV6: -	{ -		Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV6_CS; +		curr_packinfo->bIPCSSupport = IPV6_CS;  		break; -	}  	case eCS802_3PacketEthernet:  	case eCS802_1QPacketVLAN: -	{ -		Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = ETH_CS_802_3; +		curr_packinfo->bEthCSSupport = ETH_CS_802_3;  		break; -	}  	case eCSPacketIPV4Over802_1QVLAN:  	case eCSPacketIPV4Over802_3Ethernet: -	{ -		Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV4_CS; -		Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = ETH_CS_802_3; +		curr_packinfo->bIPCSSupport = IPV4_CS; +		curr_packinfo->bEthCSSupport = ETH_CS_802_3;  		break; -	}  	case eCSPacketIPV6Over802_1QVLAN:  	case eCSPacketIPV6Over802_3Ethernet: -	{ -		Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV6_CS; -		Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = ETH_CS_802_3; +		curr_packinfo->bIPCSSupport = IPV6_CS; +		curr_packinfo->bEthCSSupport = ETH_CS_802_3;  		break; -	}  	default: -	{ -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Error in value of CS Classification.. setting default to IP CS\n"); -		Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV4_CS; +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +				"Error in value of CS Classification.. setting default to IP CS\n"); +		curr_packinfo->bIPCSSupport = IPV4_CS;  		break;  	} -	} -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "CopyToAdapter : Queue No : %X ETH CS Support :  %X  , IP CS Support : %X\n", +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			"CopyToAdapter : Queue No : %X ETH CS Support :  %X  , IP CS Support : %X\n",  			uiSearchRuleIndex, -			Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport, -			Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport); +			curr_packinfo->bEthCSSupport, +			curr_packinfo->bIPCSSupport);  	/* Store IP Version used */  	/* Get The Version Of IP used (IPv6 or IPv4) from CSSpecification field of SF */ -	if (Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport == IPV6_CS) -		Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion = IPV6; +	if (curr_packinfo->bIPCSSupport == IPV6_CS) +		curr_packinfo->ucIpVersion = IPV6;  	else -		Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion = IPV4; +		curr_packinfo->ucIpVersion = IPV4;  	/* To ensure that the ETH CS code doesn't gets executed if the BS doesn't supports ETH CS */  	if (!Adapter->bETHCSEnabled) -		Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = 0; +		curr_packinfo->bEthCSSupport = 0;  	if (psfLocalSet->u8ServiceClassNameLength > 0 && psfLocalSet->u8ServiceClassNameLength < 32) -		memcpy(Adapter->PackInfo[uiSearchRuleIndex].ucServiceClassName,	psfLocalSet->u8ServiceClassName, psfLocalSet->u8ServiceClassNameLength); +		memcpy(curr_packinfo->ucServiceClassName, +				psfLocalSet->u8ServiceClassName, +				psfLocalSet->u8ServiceClassNameLength); -	Adapter->PackInfo[uiSearchRuleIndex].u8QueueType = psfLocalSet->u8ServiceFlowSchedulingType; +	curr_packinfo->u8QueueType = psfLocalSet->u8ServiceFlowSchedulingType; -	if (Adapter->PackInfo[uiSearchRuleIndex].u8QueueType == BE && Adapter->PackInfo[uiSearchRuleIndex].ucDirection) +	if (curr_packinfo->u8QueueType == BE && curr_packinfo->ucDirection)  		Adapter->usBestEffortQueueIndex = uiSearchRuleIndex; -	Adapter->PackInfo[uiSearchRuleIndex].ulSFID = ntohl(psfLocalSet->u32SFID); +	curr_packinfo->ulSFID = ntohl(psfLocalSet->u32SFID); -	Adapter->PackInfo[uiSearchRuleIndex].u8TrafficPriority = psfLocalSet->u8TrafficPriority; +	curr_packinfo->u8TrafficPriority = psfLocalSet->u8TrafficPriority;  	/* copy all the classifier in the Service Flow param  structure */  	for (i = 0; i < psfLocalSet->u8TotalClassifiers; i++) { -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Classifier index =%d", i); +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +				"Classifier index =%d", i);  		psfCSType = &psfLocalSet->cConvergenceSLTypes[i]; -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Classifier index =%d", i); +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +				"Classifier index =%d", i);  		if (psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority) -			Adapter->PackInfo[uiSearchRuleIndex].bClassifierPriority = TRUE; +			curr_packinfo->bClassifierPriority = TRUE;  		if (psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority) -			Adapter->PackInfo[uiSearchRuleIndex].bClassifierPriority = TRUE; +			curr_packinfo->bClassifierPriority = TRUE;  		if (ucDsxType == DSA_ACK) {  			eClassifierAction = eAddClassifier;  		} else if (ucDsxType == DSC_ACK) {  			switch (psfCSType->u8ClassfierDSCAction) {  			case 0: /* DSC Add Classifier */ -			{  				eClassifierAction = eAddClassifier; -			} -			break; +				break;  			case 1: /* DSC Replace Classifier */ -			{  				eClassifierAction = eReplaceClassifier; -			} -			break; +				break;  			case 2: /* DSC Delete Classifier */ -			{  				eClassifierAction = eDeleteClassifier; -			} -			break; +				break;  			default: -			{  				eClassifierAction = eInvalidClassifierAction;  			} -			}  		}  		u16PacketClassificationRuleIndex = ntohs(psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex);  		switch (eClassifierAction) {  		case eAddClassifier: -		{  			/* Get a Free Classifier Index From Classifier table for this SF to add the Classifier */  			/* Contained in this message */ -			nClassifierIndex = SearchClsid(Adapter, ulSFID, u16PacketClassificationRuleIndex); +			nClassifierIndex = SearchClsid(Adapter, +					ulSFID, +					u16PacketClassificationRuleIndex);  			if (nClassifierIndex > MAX_CLASSIFIERS) {  				nClassifierIndex = SearchFreeClsid(Adapter);  				if (nClassifierIndex > MAX_CLASSIFIERS) {  					/* Failed To get a free Entry */ -					BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Error Failed To get a free Classifier Entry"); +					BCM_DEBUG_PRINT(Adapter, +							DBG_TYPE_OTHERS, +							CONN_MSG, +							DBG_LVL_ALL, +							"Error Failed To get a free Classifier Entry");  					break;  				}  				/* Copy the Classifier Rule for this service flow into our Classifier table maintained per SF. */ -				CopyClassifierRuleToSF(Adapter, psfCSType, uiSearchRuleIndex, nClassifierIndex); +				CopyClassifierRuleToSF(Adapter, psfCSType, +						uiSearchRuleIndex, +						nClassifierIndex);  			} else {  				/* This Classifier Already Exists and it is invalid to Add Classifier with existing PCRI */ -				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, +						CONN_MSG, +						DBG_LVL_ALL,  						"CopyToAdapter: Error The Specified Classifier Already Exists and attempted To Add Classifier with Same PCRI : 0x%x\n",  						u16PacketClassificationRuleIndex);  			} -		} -		break; +			break;  		case eReplaceClassifier: -		{  			/* Get the Classifier Index From Classifier table for this SF and replace existing  Classifier */  			/* with the new classifier Contained in this message */ -			nClassifierIndex = SearchClsid(Adapter, ulSFID, u16PacketClassificationRuleIndex); +			nClassifierIndex = SearchClsid(Adapter, ulSFID, +					u16PacketClassificationRuleIndex);  			if (nClassifierIndex > MAX_CLASSIFIERS) {  				/* Failed To search the classifier */ -				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Error Search for Classifier To be replaced failed"); +				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, +						CONN_MSG, DBG_LVL_ALL, +						"Error Search for Classifier To be replaced failed");  				break;  			}  			/* Copy the Classifier Rule for this service flow into our Classifier table maintained per SF. */ -			CopyClassifierRuleToSF(Adapter, psfCSType, uiSearchRuleIndex, nClassifierIndex); -		} -		break; +			CopyClassifierRuleToSF(Adapter, psfCSType, +					uiSearchRuleIndex, nClassifierIndex); +			break;  		case eDeleteClassifier: -		{  			/* Get the Classifier Index From Classifier table for this SF and replace existing  Classifier */  			/* with the new classifier Contained in this message */ -			nClassifierIndex = SearchClsid(Adapter, ulSFID, u16PacketClassificationRuleIndex); +			nClassifierIndex = SearchClsid(Adapter, ulSFID, +					u16PacketClassificationRuleIndex);  			if (nClassifierIndex > MAX_CLASSIFIERS)	{  				/* Failed To search the classifier */ -				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Error Search for Classifier To be deleted failed"); +				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, +						CONN_MSG, DBG_LVL_ALL, +						"Error Search for Classifier To be deleted failed");  				break;  			}  			/* Delete This classifier */ -			DeleteClassifierRuleFromSF(Adapter, uiSearchRuleIndex, nClassifierIndex); -		} -		break; +			DeleteClassifierRuleFromSF(Adapter, uiSearchRuleIndex, +					nClassifierIndex); +			break;  		default: -		{  			/* Invalid Action for classifier */  			break;  		} -		}  	}  	/* Repeat parsing Classification Entries to process PHS Rules */  	for (i = 0; i < psfLocalSet->u8TotalClassifiers; i++) {  		psfCSType = &psfLocalSet->cConvergenceSLTypes[i]; -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "psfCSType->u8PhsDSCAction : 0x%x\n", psfCSType->u8PhsDSCAction); +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +				"psfCSType->u8PhsDSCAction : 0x%x\n", +				psfCSType->u8PhsDSCAction);  		switch (psfCSType->u8PhsDSCAction) {  		case eDeleteAllPHSRules: -		{ -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Deleting All PHS Rules For VCID: 0x%X\n", uVCID); +			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, +					DBG_LVL_ALL, +					"Deleting All PHS Rules For VCID: 0x%X\n", +					uVCID);  			/* Delete All the PHS rules for this Service flow */  			PhsDeleteSFRules(&Adapter->stBCMPhsContext, uVCID);  			break; -		}  		case eDeletePHSRule: -		{ -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "PHS DSC Action = Delete PHS Rule\n"); +			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, +					DBG_LVL_ALL, +					"PHS DSC Action = Delete PHS Rule\n");  			if (psfCSType->cPhsRule.u8PHSI) -				PhsDeletePHSRule(&Adapter->stBCMPhsContext, uVCID, psfCSType->cCPacketClassificationRule.u8AssociatedPHSI); +				PhsDeletePHSRule(&Adapter->stBCMPhsContext, +						uVCID, +						psfCSType->cCPacketClassificationRule.u8AssociatedPHSI);  			break; -		}  		default: -		{  			if (ucDsxType == DSC_ACK) {  				/* BCM_DEBUG_PRINT(CONN_MSG,("Invalid PHS DSC Action For DSC\n",psfCSType->cPhsRule.u8PHSI)); */  				break; /* FOr DSC ACK Case PHS DSC Action must be in valid set */  			} -		}  		/* Proceed To Add PHS rule for DSA_ACK case even if PHS DSC action is unspecified */  		/* No Break Here . Intentionally! */  		case eAddPHSRule:  		case eSetPHSRule: -		{  			if (psfCSType->cPhsRule.u8PHSI)	{  				/* Apply This PHS Rule to all classifiers whose Associated PHSI Match */ -				unsigned int uiClassifierIndex = 0; -				if (pstAddIndication->u8Direction == UPLINK_DIR) { -					for (uiClassifierIndex = 0; uiClassifierIndex < MAX_CLASSIFIERS; uiClassifierIndex++) { -						if ((Adapter->astClassifierTable[uiClassifierIndex].bUsed) && -							(Adapter->astClassifierTable[uiClassifierIndex].ulSFID == Adapter->PackInfo[uiSearchRuleIndex].ulSFID) && -							(Adapter->astClassifierTable[uiClassifierIndex].u8AssociatedPHSI == psfCSType->cPhsRule.u8PHSI)) { -							BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, -									"Adding PHS Rule For Classifier: 0x%x cPhsRule.u8PHSI: 0x%x\n", -									Adapter->astClassifierTable[uiClassifierIndex].uiClassifierRuleIndex, -									psfCSType->cPhsRule.u8PHSI); -							/* Update The PHS Rule for this classifier as Associated PHSI id defined */ - -							/* Copy the PHS Rule */ -							sPhsRule.u8PHSI = psfCSType->cPhsRule.u8PHSI; -							sPhsRule.u8PHSFLength = psfCSType->cPhsRule.u8PHSFLength; -							sPhsRule.u8PHSMLength = psfCSType->cPhsRule.u8PHSMLength; -							sPhsRule.u8PHSS = psfCSType->cPhsRule.u8PHSS; -							sPhsRule.u8PHSV = psfCSType->cPhsRule.u8PHSV; -							memcpy(sPhsRule.u8PHSF, psfCSType->cPhsRule.u8PHSF, MAX_PHS_LENGTHS); -							memcpy(sPhsRule.u8PHSM, psfCSType->cPhsRule.u8PHSM, MAX_PHS_LENGTHS); -							sPhsRule.u8RefCnt = 0; -							sPhsRule.bUnclassifiedPHSRule = FALSE; -							sPhsRule.PHSModifiedBytes = 0; -							sPhsRule.PHSModifiedNumPackets = 0; -							sPhsRule.PHSErrorNumPackets = 0; - -							/* bPHSRuleAssociated = TRUE; */ -							/* Store The PHS Rule for this classifier */ - -							PhsUpdateClassifierRule( -								&Adapter->stBCMPhsContext, -								uVCID, -								Adapter->astClassifierTable[uiClassifierIndex].uiClassifierRuleIndex, -								&sPhsRule, -								Adapter->astClassifierTable[uiClassifierIndex].u8AssociatedPHSI); - -							/* Update PHS Rule For the Classifier */ -							if (sPhsRule.u8PHSI) { -								Adapter->astClassifierTable[uiClassifierIndex].u32PHSRuleID = sPhsRule.u8PHSI; -								memcpy(&Adapter->astClassifierTable[uiClassifierIndex].sPhsRule, &sPhsRule, sizeof(struct bcm_phs_rule)); -							} -						} -					} -				} else { -					/* Error PHS Rule specified in signaling could not be applied to any classifier */ - -					/* Copy the PHS Rule */ -					sPhsRule.u8PHSI = psfCSType->cPhsRule.u8PHSI; -					sPhsRule.u8PHSFLength = psfCSType->cPhsRule.u8PHSFLength; -					sPhsRule.u8PHSMLength = psfCSType->cPhsRule.u8PHSMLength; -					sPhsRule.u8PHSS = psfCSType->cPhsRule.u8PHSS; -					sPhsRule.u8PHSV = psfCSType->cPhsRule.u8PHSV; -					memcpy(sPhsRule.u8PHSF, psfCSType->cPhsRule.u8PHSF, MAX_PHS_LENGTHS); -					memcpy(sPhsRule.u8PHSM, psfCSType->cPhsRule.u8PHSM, MAX_PHS_LENGTHS); -					sPhsRule.u8RefCnt = 0; -					sPhsRule.bUnclassifiedPHSRule = TRUE; -					sPhsRule.PHSModifiedBytes = 0; -					sPhsRule.PHSModifiedNumPackets = 0; -					sPhsRule.PHSErrorNumPackets = 0; -					/* Store The PHS Rule for this classifier */ - -					/* -					 * Passing the argument u8PHSI instead of clsid. Because for DL with no classifier rule, -					 * clsid will be zero hence we can't have multiple PHS rules for the same SF. -					 * To support multiple PHS rule, passing u8PHSI. -					 */ -					PhsUpdateClassifierRule( -						&Adapter->stBCMPhsContext, +				apply_phs_rule_to_all_classifiers(Adapter, +						uiSearchRuleIndex,  						uVCID, -						sPhsRule.u8PHSI,  						&sPhsRule, -						sPhsRule.u8PHSI); -				} +						&psfCSType->cPhsRule, +						pstAddIndication);  			} -		} -		break; +			break;  		}  	}  	if (psfLocalSet->u32MaxSustainedTrafficRate == 0) {  		/* No Rate Limit . Set Max Sustained Traffic Rate to Maximum */ -		Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate = WIMAX_MAX_ALLOWED_RATE; +		curr_packinfo->uiMaxAllowedRate = WIMAX_MAX_ALLOWED_RATE;  	} else if (ntohl(psfLocalSet->u32MaxSustainedTrafficRate) > WIMAX_MAX_ALLOWED_RATE) {  		/* Too large Allowed Rate specified. Limiting to Wi Max  Allowed rate */ -		Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate = WIMAX_MAX_ALLOWED_RATE; +		curr_packinfo->uiMaxAllowedRate = WIMAX_MAX_ALLOWED_RATE;  	} else { -		Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate =  ntohl(psfLocalSet->u32MaxSustainedTrafficRate); +		curr_packinfo->uiMaxAllowedRate = +			ntohl(psfLocalSet->u32MaxSustainedTrafficRate);  	} -	Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency = ntohl(psfLocalSet->u32MaximumLatency); -	if (Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency == 0) /* 0 should be treated as infinite */ -		Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency = MAX_LATENCY_ALLOWED; +	curr_packinfo->uiMaxLatency = ntohl(psfLocalSet->u32MaximumLatency); +	if (curr_packinfo->uiMaxLatency == 0) /* 0 should be treated as infinite */ +		curr_packinfo->uiMaxLatency = MAX_LATENCY_ALLOWED; -	if ((Adapter->PackInfo[uiSearchRuleIndex].u8QueueType == ERTPS || -			Adapter->PackInfo[uiSearchRuleIndex].u8QueueType == UGS)) +	if ((curr_packinfo->u8QueueType == ERTPS || +			curr_packinfo->u8QueueType == UGS))  		UGIValue = ntohs(psfLocalSet->u16UnsolicitedGrantInterval);  	if (UGIValue == 0) @@ -770,42 +822,45 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* <Pointer  	 * The extra amount of token is to ensure that a large amount of jitter won't have loss in throughput...  	 * In case of non-UGI based connection, 200 frames worth of data is the max token count at host...  	 */ -	Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize = -		(DEFAULT_UGI_FACTOR*Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate*UGIValue)/1000; +	curr_packinfo->uiMaxBucketSize = +		(DEFAULT_UGI_FACTOR*curr_packinfo->uiMaxAllowedRate*UGIValue)/1000; -	if (Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize < WIMAX_MAX_MTU*8) { +	if (curr_packinfo->uiMaxBucketSize < WIMAX_MAX_MTU*8) {  		UINT UGIFactor = 0;  		/* Special Handling to ensure the biggest size of packet can go out from host to FW as follows:  		 * 1. Any packet from Host to FW can go out in different packet size.  		 * 2. So in case the Bucket count is smaller than MTU, the packets of size (Size > TokenCount), will get dropped.  		 * 3. We can allow packets of MaxSize from Host->FW that can go out from FW in multiple SDUs by fragmentation at Wimax Layer  		 */ -		UGIFactor = (Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency/UGIValue + 1); +		UGIFactor = (curr_packinfo->uiMaxLatency/UGIValue + 1);  		if (UGIFactor > DEFAULT_UGI_FACTOR) -			Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize = -				(UGIFactor*Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate*UGIValue)/1000; +			curr_packinfo->uiMaxBucketSize = +				(UGIFactor*curr_packinfo->uiMaxAllowedRate*UGIValue)/1000; -		if (Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize > WIMAX_MAX_MTU*8) -			Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize = WIMAX_MAX_MTU*8; +		if (curr_packinfo->uiMaxBucketSize > WIMAX_MAX_MTU*8) +			curr_packinfo->uiMaxBucketSize = WIMAX_MAX_MTU*8;  	} -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "LAT: %d, UGI: %d\n", Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency, UGIValue); -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "uiMaxAllowedRate: 0x%x, u32MaxSustainedTrafficRate: 0x%x ,uiMaxBucketSize: 0x%x", -			Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate, +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			"LAT: %d, UGI: %d\n", curr_packinfo->uiMaxLatency, +			UGIValue); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			"uiMaxAllowedRate: 0x%x, u32MaxSustainedTrafficRate: 0x%x ,uiMaxBucketSize: 0x%x", +			curr_packinfo->uiMaxAllowedRate,  			ntohl(psfLocalSet->u32MaxSustainedTrafficRate), -			Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize); +			curr_packinfo->uiMaxBucketSize);  	/* copy the extended SF Parameters to Support MIBS */  	CopyMIBSExtendedSFParameters(Adapter, psfLocalSet, uiSearchRuleIndex);  	/* store header suppression enabled flag per SF */ -	Adapter->PackInfo[uiSearchRuleIndex].bHeaderSuppressionEnabled = +	curr_packinfo->bHeaderSuppressionEnabled =  		!(psfLocalSet->u8RequesttransmissionPolicy &  			MASK_DISABLE_HEADER_SUPPRESSION); -	kfree(Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication); -	Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication = pstAddIndication; +	kfree(curr_packinfo->pstSFIndication); +	curr_packinfo->pstSFIndication = pstAddIndication;  	/* Re Sort the SF list in PackInfo according to Traffic Priority */  	SortPackInfo(Adapter); @@ -815,7 +870,8 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* <Pointer  	 */  	SortClassifiers(Adapter);  	DumpPhsRules(&Adapter->stBCMPhsContext); -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "%s <=====", __func__); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			"%s <=====", __func__);  }  /*********************************************************************** @@ -837,7 +893,7 @@ static VOID DumpCmControlPacket(PVOID pvBuffer)  	UINT nCurClassifierCnt;  	struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); -	pstAddIndication = (struct bcm_add_indication_alt *)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,13 +1435,15 @@ static ULONG StoreSFParam(struct bcm_mini_adapter *Adapter, PUCHAR pucSrcBuffer,  	ret = wrm(Adapter, ulAddrSFParamSet, (u8 *)pucSrcBuffer, nBytesToWrite);  	if (ret < 0) { -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "%s:%d WRM failed", __func__, __LINE__); +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +				"%s:%d WRM failed", __func__, __LINE__);  		return ret;  	}  	return 1;  } -ULONG StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, PVOID pvBuffer, UINT *puBufferLength) +ULONG StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, +		PVOID pvBuffer, UINT *puBufferLength)  {  	struct bcm_add_indication_alt *pstAddIndicationAlt = NULL;  	struct bcm_add_indication *pstAddIndication = NULL; @@ -1339,14 +1451,14 @@ ULONG StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, PVOID pvBu  	UINT uiSearchRuleIndex;  	ULONG ulSFID; -	pstAddIndicationAlt = (struct bcm_add_indication_alt *)(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; @@ -1446,40 +1570,63 @@ ULONG StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, PVOID pvBu  }  static inline struct bcm_add_indication_alt -*RestoreCmControlResponseMessage(register struct bcm_mini_adapter *Adapter, register PVOID pvBuffer) +*RestoreCmControlResponseMessage(register struct bcm_mini_adapter *Adapter, +		register PVOID pvBuffer)  {  	ULONG ulStatus = 0;  	struct bcm_add_indication *pstAddIndication = NULL;  	struct bcm_add_indication_alt *pstAddIndicationDest = NULL; -	pstAddIndication = (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 (struct bcm_add_indication_alt *)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(struct bcm_add_indication_alt), GFP_KERNEL); +	pstAddIndicationDest = kmalloc(sizeof(struct bcm_add_indication_alt), +			GFP_KERNEL);  	if (pstAddIndicationDest) { -		memset(pstAddIndicationDest, 0, sizeof(struct bcm_add_indication_alt)); +		memset(pstAddIndicationDest, 0, +				sizeof(struct bcm_add_indication_alt));  	} else { -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Failed to allocate memory for SF Add Indication Structure "); +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, +				DBG_LVL_ALL, +				"Failed to allocate memory for SF Add Indication Structure ");  		return NULL;  	} -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u8Type : 0x%X", pstAddIndication->u8Type); -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u8Direction : 0x%X", pstAddIndication->eConnectionDir); -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u8TID : 0x%X", ntohs(pstAddIndication->u16TID)); -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u8CID : 0x%X", ntohs(pstAddIndication->u16CID)); -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u16VCID : 0x%X", ntohs(pstAddIndication->u16VCID)); -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-autorized set loc : %p", pstAddIndication->psfAuthorizedSet); -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-admitted set loc : %p", pstAddIndication->psfAdmittedSet); -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-Active set loc : %p", pstAddIndication->psfActiveSet); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			"AddIndication-u8Type : 0x%X", +			pstAddIndication->u8Type); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			"AddIndication-u8Direction : 0x%X", +			pstAddIndication->eConnectionDir); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			"AddIndication-u8TID : 0x%X", +			ntohs(pstAddIndication->u16TID)); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			"AddIndication-u8CID : 0x%X", +			ntohs(pstAddIndication->u16CID)); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			"AddIndication-u16VCID : 0x%X", +			ntohs(pstAddIndication->u16VCID)); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			"AddIndication-autorized set loc : %p", +			pstAddIndication->psfAuthorizedSet); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			"AddIndication-admitted set loc : %p", +			pstAddIndication->psfAdmittedSet); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			"AddIndication-Active set loc : %p", +			pstAddIndication->psfActiveSet);  	pstAddIndicationDest->u8Type = pstAddIndication->u8Type;  	pstAddIndicationDest->u8Direction = pstAddIndication->eConnectionDir; @@ -1488,39 +1635,60 @@ static inline struct bcm_add_indication_alt  	pstAddIndicationDest->u16VCID = pstAddIndication->u16VCID;  	pstAddIndicationDest->u8CC = pstAddIndication->u8CC; -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,  "Restoring Active Set "); -	ulStatus = RestoreSFParam(Adapter, (ULONG)pstAddIndication->psfActiveSet, (PUCHAR)&pstAddIndicationDest->sfActiveSet); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			"Restoring Active Set "); +	ulStatus = RestoreSFParam(Adapter, +			(ULONG)pstAddIndication->psfActiveSet, +			(PUCHAR)&pstAddIndicationDest->sfActiveSet);  	if (ulStatus != 1)  		goto failed_restore_sf_param;  	if (pstAddIndicationDest->sfActiveSet.u8TotalClassifiers > MAX_CLASSIFIERS_IN_SF) -		pstAddIndicationDest->sfActiveSet.u8TotalClassifiers = MAX_CLASSIFIERS_IN_SF; - -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,  "Restoring Admitted Set "); -	ulStatus = RestoreSFParam(Adapter, (ULONG)pstAddIndication->psfAdmittedSet, (PUCHAR)&pstAddIndicationDest->sfAdmittedSet); +		pstAddIndicationDest->sfActiveSet.u8TotalClassifiers = +			MAX_CLASSIFIERS_IN_SF; + +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			"Restoring Admitted Set "); +	ulStatus = RestoreSFParam(Adapter, +			(ULONG)pstAddIndication->psfAdmittedSet, +			(PUCHAR)&pstAddIndicationDest->sfAdmittedSet);  	if (ulStatus != 1)  		goto failed_restore_sf_param;  	if (pstAddIndicationDest->sfAdmittedSet.u8TotalClassifiers > MAX_CLASSIFIERS_IN_SF) -		pstAddIndicationDest->sfAdmittedSet.u8TotalClassifiers = MAX_CLASSIFIERS_IN_SF; - -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,  "Restoring Authorized Set "); -	ulStatus = RestoreSFParam(Adapter, (ULONG)pstAddIndication->psfAuthorizedSet, (PUCHAR)&pstAddIndicationDest->sfAuthorizedSet); +		pstAddIndicationDest->sfAdmittedSet.u8TotalClassifiers = +			MAX_CLASSIFIERS_IN_SF; + +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			"Restoring Authorized Set "); +	ulStatus = RestoreSFParam(Adapter, +			(ULONG)pstAddIndication->psfAuthorizedSet, +			(PUCHAR)&pstAddIndicationDest->sfAuthorizedSet);  	if (ulStatus != 1)  		goto failed_restore_sf_param;  	if (pstAddIndicationDest->sfAuthorizedSet.u8TotalClassifiers > MAX_CLASSIFIERS_IN_SF) -		pstAddIndicationDest->sfAuthorizedSet.u8TotalClassifiers = MAX_CLASSIFIERS_IN_SF; - -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Dumping the whole raw packet"); -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "============================================================"); -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " pstAddIndicationDest->sfActiveSet size  %zx %p", sizeof(*pstAddIndicationDest), pstAddIndicationDest); -	/* BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, (unsigned char *)pstAddIndicationDest, sizeof(*pstAddIndicationDest)); */ -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "============================================================"); +		pstAddIndicationDest->sfAuthorizedSet.u8TotalClassifiers = +			MAX_CLASSIFIERS_IN_SF; + +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			"Dumping the whole raw packet"); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +		"============================================================"); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			" pstAddIndicationDest->sfActiveSet size  %zx %p", +			sizeof(*pstAddIndicationDest), pstAddIndicationDest); +	/* BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, CONN_MSG, +	 *		DBG_LVL_ALL, (unsigned char *)pstAddIndicationDest, +	 *		sizeof(*pstAddIndicationDest)); +	 */ +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			"============================================================");  	return pstAddIndicationDest;  failed_restore_sf_param:  	kfree(pstAddIndicationDest); -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "<====="); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			"<=====");  	return NULL;  } @@ -1532,31 +1700,44 @@ ULONG SetUpTargetDsxBuffers(struct bcm_mini_adapter *Adapter)  	int Status;  	if (!Adapter) { -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Adapter was NULL!!!"); +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +				"Adapter was NULL!!!");  		return 0;  	}  	if (Adapter->astTargetDsxBuffer[0].ulTargetDsxBuffer)  		return 1; -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Size of Each DSX Buffer(Also size of connection manager parameters): %zx ", sizeof(struct bcm_connect_mgr_params)); -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Reading DSX buffer From Target location %x ", DSX_MESSAGE_EXCHANGE_BUFFER); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			"Size of Each DSX Buffer(Also size of connection manager parameters): %zx ", +			sizeof(struct bcm_connect_mgr_params)); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			"Reading DSX buffer From Target location %x ", +			DSX_MESSAGE_EXCHANGE_BUFFER); -	Status = rdmalt(Adapter, DSX_MESSAGE_EXCHANGE_BUFFER, (PUINT)&ulTargetDsxBuffersBase, sizeof(UINT)); +	Status = rdmalt(Adapter, DSX_MESSAGE_EXCHANGE_BUFFER, +			(PUINT)&ulTargetDsxBuffersBase, sizeof(UINT));  	if (Status < 0) { -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "RDM failed!!"); +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +				"RDM failed!!");  		return 0;  	} -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Base Address Of DSX  Target Buffer : 0x%lx", ulTargetDsxBuffersBase); -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,  "Tgt Buffer is Now %lx :", ulTargetDsxBuffersBase); -	ulCntTargetBuffers = DSX_MESSAGE_EXCHANGE_BUFFER_SIZE / sizeof(struct bcm_connect_mgr_params); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			"Base Address Of DSX  Target Buffer : 0x%lx", +			ulTargetDsxBuffersBase); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			"Tgt Buffer is Now %lx :", ulTargetDsxBuffersBase); +	ulCntTargetBuffers = DSX_MESSAGE_EXCHANGE_BUFFER_SIZE / +		sizeof(struct bcm_connect_mgr_params);  	Adapter->ulTotalTargetBuffersAvailable =  		ulCntTargetBuffers > MAX_TARGET_DSX_BUFFERS ?  		MAX_TARGET_DSX_BUFFERS : ulCntTargetBuffers; -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " Total Target DSX Buffer setup %lx ", Adapter->ulTotalTargetBuffersAvailable); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			" Total Target DSX Buffer setup %lx ", +			Adapter->ulTotalTargetBuffersAvailable);  	for (i = 0; i < Adapter->ulTotalTargetBuffersAvailable; i++) {  		Adapter->astTargetDsxBuffer[i].ulTargetDsxBuffer = ulTargetDsxBuffersBase; @@ -1571,13 +1752,15 @@ ULONG SetUpTargetDsxBuffers(struct bcm_mini_adapter *Adapter)  	return 1;  } -static ULONG GetNextTargetBufferLocation(struct bcm_mini_adapter *Adapter, B_UINT16 tid) +static ULONG GetNextTargetBufferLocation(struct bcm_mini_adapter *Adapter, +		B_UINT16 tid)  {  	ULONG dsx_buf;  	ULONG idx, max_try; -	if ((Adapter->ulTotalTargetBuffersAvailable == 0) || (Adapter->ulFreeTargetBufferCnt == 0)) { -		ClearTargetDSXBuffer(Adapter, tid, FALSE); +	if ((Adapter->ulTotalTargetBuffersAvailable == 0) +			|| (Adapter->ulFreeTargetBufferCnt == 0)) { +		ClearTargetDSXBuffer(Adapter, tid, false);  		return 0;  	} @@ -1589,8 +1772,10 @@ static ULONG GetNextTargetBufferLocation(struct bcm_mini_adapter *Adapter, B_UIN  	}  	if (max_try == 0) { -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "\n GetNextTargetBufferLocation : Error No Free Target DSX Buffers FreeCnt : %lx ", Adapter->ulFreeTargetBufferCnt); -		ClearTargetDSXBuffer(Adapter, tid, FALSE); +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +				"\n GetNextTargetBufferLocation : Error No Free Target DSX Buffers FreeCnt : %lx ", +				Adapter->ulFreeTargetBufferCnt); +		ClearTargetDSXBuffer(Adapter, tid, false);  		return 0;  	} @@ -1600,7 +1785,9 @@ static ULONG GetNextTargetBufferLocation(struct bcm_mini_adapter *Adapter, B_UIN  	Adapter->ulFreeTargetBufferCnt--;  	idx = (idx+1)%Adapter->ulTotalTargetBuffersAvailable;  	Adapter->ulCurrentTargetBuffer = idx; -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "GetNextTargetBufferLocation :Returning address %lx tid %d\n", dsx_buf, tid); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +			"GetNextTargetBufferLocation :Returning address %lx tid %d\n", +			dsx_buf, tid);  	return dsx_buf;  } @@ -1611,7 +1798,8 @@ int AllocAdapterDsxBuffer(struct bcm_mini_adapter *Adapter)  	 * Need to Allocate memory to contain the SUPER Large structures  	 * Our driver can't create these structures on Stack  	 */ -	Adapter->caDsxReqResp = kmalloc(sizeof(struct bcm_add_indication_alt)+LEADER_SIZE, GFP_KERNEL); +	Adapter->caDsxReqResp = kmalloc(sizeof(struct bcm_add_indication_alt) +			+ LEADER_SIZE, GFP_KERNEL);  	if (!Adapter->caDsxReqResp)  		return -ENOMEM; @@ -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;  	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,11 +1846,10 @@ 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(struct bcm_add_indication_alt);  		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Sending DSA Response....\n");  		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSA RESPONSE TO MAC %d", pLeader->PLength); @@ -1671,22 +1860,16 @@ BOOLEAN CmControlResponseMessage(struct bcm_mini_adapter *Adapter,  /* <Pointer  		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " VCID = %x", ntohs(pstAddIndication->u16VCID));  		CopyBufferToControlPacket(Adapter, (PVOID)Adapter->caDsxReqResp);  		kfree(pstAddIndication); -	} -	break; +		break;  	case DSA_RSP: -	{  		pLeader->PLength = sizeof(struct bcm_add_indication_alt);  		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSA ACK TO MAC %d",  				pLeader->PLength);  		*((struct bcm_add_indication_alt *)&(Adapter->caDsxReqResp[LEADER_SIZE]))  			= *pstAddIndication;  		((struct bcm_add_indication_alt *)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSA_ACK; - -	} /* no break here..we should go down. */ +		/* FALLTHROUGH */  	case DSA_ACK: -	{ -		UINT uiSearchRuleIndex = 0; -  		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "VCID:0x%X",  				ntohs(pstAddIndication->u16VCID));  		uiSearchRuleIndex = SearchFreeSfid(Adapter); @@ -1694,7 +1877,7 @@ 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,20 +1942,18 @@ 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(struct bcm_change_indication);  		pstChangeIndication = (struct bcm_change_indication *)pstAddIndication;  		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSC RESPONSE TO MAC %d", pLeader->PLength); @@ -1782,26 +1963,21 @@ BOOLEAN CmControlResponseMessage(struct bcm_mini_adapter *Adapter,  /* <Pointer  		CopyBufferToControlPacket(Adapter, (PVOID)Adapter->caDsxReqResp);  		kfree(pstAddIndication); -	} -	break; +		break;  	case DSC_RSP: -	{  		pLeader->PLength = sizeof(struct bcm_change_indication);  		pstChangeIndication = (struct bcm_change_indication *)pstAddIndication;  		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSC ACK TO MAC %d", pLeader->PLength);  		*((struct bcm_change_indication *)&(Adapter->caDsxReqResp[LEADER_SIZE])) = *pstChangeIndication;  		((struct bcm_change_indication *)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSC_ACK; -	} +		/* FALLTHROUGH */  	case DSC_ACK: -	{ -		UINT uiSearchRuleIndex = 0; -  		pstChangeIndication = (struct bcm_change_indication *)pstAddIndication;  		uiSearchRuleIndex = SearchSfid(Adapter, ntohl(pstChangeIndication->sfActiveSet.u32SFID));  		if (uiSearchRuleIndex > NO_OF_QUEUES-1)  			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "SF doesn't exist for which DSC_ACK is received"); -		if ((uiSearchRuleIndex < NO_OF_QUEUES)) { +		if (uiSearchRuleIndex < NO_OF_QUEUES) {  			Adapter->PackInfo[uiSearchRuleIndex].ucDirection = pstChangeIndication->u8Direction;  			if (pstChangeIndication->sfActiveSet.bValid == TRUE)  				Adapter->PackInfo[uiSearchRuleIndex].bActiveSet = TRUE; @@ -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(struct bcm_add_indication_alt))) { -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "copy to user failed SFID %d, present in queue !!!", uiSFId); +	if (psSfInfo->pstSFIndication +			&& copy_to_user(user_buffer, psSfInfo->pstSFIndication, +				sizeof(struct bcm_add_indication_alt))) { +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, +				"copy to user failed SFID %d, present in queue !!!", +				uiSFId);  		status = -EFAULT;  		return status;  	}  	return STATUS_SUCCESS;  } -VOID OverrideServiceFlowParams(struct bcm_mini_adapter *Adapter, PUINT puiBuffer) +VOID OverrideServiceFlowParams(struct bcm_mini_adapter *Adapter, +		PUINT puiBuffer)  {  	B_UINT32 u32NumofSFsinMsg = ntohl(*(puiBuffer + 1));  	struct bcm_stim_sfhostnotify *pHostInfo = NULL; @@ -1918,7 +2095,8 @@ VOID OverrideServiceFlowParams(struct bcm_mini_adapter *Adapter, PUINT puiBuffer  	ULONG ulSFID = 0;  	puiBuffer += 2; -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32NumofSFsinMsg: 0x%x\n", u32NumofSFsinMsg); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +			"u32NumofSFsinMsg: 0x%x\n", u32NumofSFsinMsg);  	while (u32NumofSFsinMsg != 0 && u32NumofSFsinMsg < NO_OF_QUEUES) {  		u32NumofSFsinMsg--; @@ -1927,31 +2105,149 @@ VOID OverrideServiceFlowParams(struct bcm_mini_adapter *Adapter, PUINT puiBuffer  		ulSFID = ntohl(pHostInfo->SFID);  		uiSearchRuleIndex = SearchSfid(Adapter, ulSFID); -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SFID: 0x%lx\n", ulSFID); - -		if (uiSearchRuleIndex >= NO_OF_QUEUES || uiSearchRuleIndex == HiPriority) { -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "The SFID <%lx> doesn't exist in host entry or is Invalid\n", ulSFID); +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, +				"SFID: 0x%lx\n", ulSFID); + +		if (uiSearchRuleIndex >= NO_OF_QUEUES +				|| uiSearchRuleIndex == HiPriority) { +			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, +					DBG_LVL_ALL, +					"The SFID <%lx> doesn't exist in host entry or is Invalid\n", +					ulSFID);  			continue;  		} -		if (pHostInfo->RetainSF == FALSE) { -			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Going to Delete SF"); +		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 4ddfc3d45bc..0887d3f49e2 100644 --- a/drivers/staging/bcm/CmHost.h +++ b/drivers/staging/bcm/CmHost.h @@ -55,7 +55,7 @@ unsigned long StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, vo  int AllocAdapterDsxBuffer(struct bcm_mini_adapter *Adapter);  int FreeAdapterDsxBuffer(struct bcm_mini_adapter *Adapter);  unsigned long SetUpTargetDsxBuffers(struct bcm_mini_adapter *Adapter); -BOOLEAN CmControlResponseMessage(struct bcm_mini_adapter *Adapter, void *pvBuffer); +bool CmControlResponseMessage(struct bcm_mini_adapter *Adapter, void *pvBuffer);  #pragma pack(pop) diff --git a/drivers/staging/bcm/DDRInit.c b/drivers/staging/bcm/DDRInit.c index f5eda96f0f8..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", __func__, __LINE__); -					return retval; -				} -				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; -				} +	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_133_MHZ: +		case DDR_100_MHZ: +			psDDRSetting = asT3B_DDRSetting100MHz; +			RegCount = (sizeof(asT3B_DDRSetting100MHz)/ +			sizeof(struct bcm_ddr_setting)); +			break; +		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,20 +932,15 @@ 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) { +		if (STATUS_SUCCESS != retval) {  			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "%s:%d\n", __func__, __LINE__);  			break;  		} @@ -980,36 +949,34 @@ 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) { +			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) { +			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) { +			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) { +			if (retval < 0) {  				BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__);  				return retval;  			} @@ -1020,75 +987,72 @@ 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) { +		 * 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) { +			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) { +			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) { +			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) { +			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) { +			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) { +			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) { +			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) { +			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) { +			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) { +			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) { +			if (retval < 0) {  				BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__);  				return retval;  			} @@ -1101,179 +1065,167 @@ 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) -	{ +	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); +	/* signature */ +	value = (0x1d1e0dd0);  	retval = wrmalt(Adapter, ul_ddr_setting_load_addr, &value, sizeof(value)); -	if(retval) -	{ +	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)); +	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)); +	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; -				} +		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))){ +				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;  				} @@ -1283,7 +1235,5 @@ int download_ddr_settings(struct bcm_mini_adapter *Adapter)  		RegCount--;  		psDDRSetting++;  	} -	return retval; +		return retval;  } - - diff --git a/drivers/staging/bcm/HandleControlPacket.c b/drivers/staging/bcm/HandleControlPacket.c index 1bb53e247a6..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, diff --git a/drivers/staging/bcm/IPv6Protocol.c b/drivers/staging/bcm/IPv6Protocol.c index 6d803e7b094..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, +static bool MatchSrcIpv6Address(struct bcm_classifier_rule *pstClassifierRule,  	struct bcm_ipv6_hdr *pstIpv6Header); -static BOOLEAN MatchDestIpv6Address(struct bcm_classifier_rule *pstClassifierRule, +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) { @@ -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); @@ -187,12 +187,12 @@ USHORT	IpVersion6(struct bcm_mini_adapter *Adapter, PVOID pcIpHeader,  	USHORT	ushSrcPort = 0;  	UCHAR   ucNextProtocolAboveIP = 0;  	struct bcm_ipv6_hdr *pstIpv6Header = NULL; -	BOOLEAN bClassificationSucceed = FALSE; +	bool bClassificationSucceed = false;  	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,  			DBG_LVL_ALL, "IpVersion6 ==========>\n"); -	pstIpv6Header = (struct bcm_ipv6_hdr *)pcIpHeader; +	pstIpv6Header = pcIpHeader;  	DumpIpv6Header(pstIpv6Header); @@ -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,7 +288,7 @@ USHORT	IpVersion6(struct bcm_mini_adapter *Adapter, PVOID pcIpHeader,  } -static BOOLEAN MatchSrcIpv6Address(struct bcm_classifier_rule *pstClassifierRule, +static bool MatchSrcIpv6Address(struct bcm_classifier_rule *pstClassifierRule,  	struct bcm_ipv6_hdr *pstIpv6Header)  {  	UINT uiLoopIndex = 0; @@ -341,10 +341,10 @@ static BOOLEAN MatchSrcIpv6Address(struct bcm_classifier_rule *pstClassifierRule  			}  		}  	} -	return FALSE; +	return false;  } -static BOOLEAN MatchDestIpv6Address(struct bcm_classifier_rule *pstClassifierRule, +static bool MatchDestIpv6Address(struct bcm_classifier_rule *pstClassifierRule,  	struct bcm_ipv6_hdr *pstIpv6Header)  {  	UINT uiLoopIndex = 0; @@ -398,7 +398,7 @@ static BOOLEAN MatchDestIpv6Address(struct bcm_classifier_rule *pstClassifierRul  			}  		}  	} -	return FALSE; +	return false;  } diff --git a/drivers/staging/bcm/InterfaceDld.c b/drivers/staging/bcm/InterfaceDld.c index 348ad75b340..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; -	struct bcm_interface_adapter *psIntfAdapter = (struct bcm_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; -	struct bcm_interface_adapter *psIntfAdapter = (struct bcm_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,13 +113,15 @@ 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(struct bcm_target_params), GFP_KERNEL); +		Adapter->pstargetparams = +			kmalloc(sizeof(struct bcm_target_params), GFP_KERNEL);  		if (Adapter->pstargetparams == NULL)  			return -ENOMEM;  	} @@ -146,7 +129,9 @@ static int bcm_download_config_file(struct bcm_mini_adapter *Adapter, struct bcm  	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,52 +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(struct bcm_target_params), 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;  } -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; @@ -214,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;  	} @@ -226,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;  		} @@ -243,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: @@ -254,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; @@ -264,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; @@ -275,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); @@ -293,7 +277,6 @@ 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;  		} @@ -312,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 53478286604..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,199 +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+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) { +			/* 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)); +				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)); +				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 ; -			} +				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 ||  				Adapter->chip_id == BCS220_2BC ||  					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);  	}  	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 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; +	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); -		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)) { +	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. */ -		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; -		} +		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)); +		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");  			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); -		} +		else +			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, +				IDLE_MODE, DBG_LVL_ALL, +				"NOB Sent down :%d", lenwritten);  		/* 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)))  				chip_id = chip_id&~(0xF0);  			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); +			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.."); +		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"); +		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");  		Adapter->bTriedToWakeUpFromlowPowerMode = TRUE;  		InterfaceAbortIdlemode(Adapter, Adapter->usIdleModePattern);  	} -	return Status; +	return 0;  }  void InterfaceHandleShutdownModeWakeup(struct bcm_mini_adapter *Adapter) @@ -237,30 +241,33 @@ void InterfaceHandleShutdownModeWakeup(struct bcm_mini_adapter *Adapter)  	INT Status = 0;  	int bytes; -	if (Adapter->ulPowerSaveMode == DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING) { +	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/InterfaceInit.c b/drivers/staging/bcm/InterfaceInit.c index 79058ce5b33..7c04c73e3bc 100644 --- a/drivers/staging/bcm/InterfaceInit.c +++ b/drivers/staging/bcm/InterfaceInit.c @@ -1,5 +1,5 @@  #include "headers.h" - +#include <linux/usb/ch9.h>  static struct usb_device_id InterfaceUsbtable[] = {  	{ USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3) },  	{ USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3B) }, @@ -30,19 +30,22 @@ static void InterfaceAdapterFree(struct bcm_interface_adapter *psIntfAdapter)  	int i = 0;  	/* Wake up the wait_queue... */ -	if (psIntfAdapter->psAdapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { +	if (psIntfAdapter->psAdapter->LEDInfo.led_thread_running & +			BCM_LED_THREAD_RUNNING_ACTIVELY) {  		psIntfAdapter->psAdapter->DriverState = DRIVER_HALT;  		wake_up(&psIntfAdapter->psAdapter->LEDInfo.notify_led_event);  	}  	reset_card_proc(psIntfAdapter->psAdapter);  	/* -	 * worst case time taken by the RDM/WRM will be 5 sec. will check after every 100 ms -	 * to accertain the device is not being accessed. After this No RDM/WRM should be made. +	 * worst case time taken by the RDM/WRM will be 5 sec. will check after +	 * every 100 ms to accertain the device is not being accessed. After +	 * this No RDM/WRM should be made.  	 */  	while (psIntfAdapter->psAdapter->DeviceAccess) { -		BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, -			"Device is being accessed.\n"); +		BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, +				DRV_ENTRY, DBG_LVL_ALL, +				"Device is being accessed.\n");  		msleep(100);  	}  	/* Free interrupt URB */ @@ -69,8 +72,9 @@ static void InterfaceAdapterFree(struct bcm_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); @@ -80,7 +84,9 @@ static void ConfigureEndPointTypesThroughEEPROM(struct bcm_mini_adapter *Adapter  	ulReg = ntohl(EP2_CFG_REG);  	BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x132, 4, TRUE); -	if (((struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter))->bHighSpeedDevice == TRUE) { +	interfaceAdapter = +		(struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter); +	if (interfaceAdapter->bHighSpeedDevice) {  		ulReg = ntohl(EP2_CFG_INT);  		BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x136, 4, TRUE);  	} else { @@ -96,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; @@ -119,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); @@ -150,7 +156,8 @@ static int usbbcm_device_probe(struct usb_interface *intf, const struct usb_devi  	struct net_device *ndev;  	/* Reserve one extra queue for the bit-bucket */ -	ndev = alloc_etherdev_mq(sizeof(struct bcm_mini_adapter), NO_OF_QUEUES+1); +	ndev = alloc_etherdev_mq(sizeof(struct bcm_mini_adapter), +			NO_OF_QUEUES + 1);  	if (ndev == NULL) {  		dev_err(&udev->dev, DRV_NAME ": no memory for device\n");  		return -ENOMEM; @@ -169,13 +176,14 @@ static int usbbcm_device_probe(struct usb_interface *intf, const struct usb_devi  	/*  	 * Technically, one can start using BCM_DEBUG_PRINT after this point. -	 * However, realize that by default the Type/Subtype bitmaps are all zero now; -	 * so no prints will actually appear until the TestApp turns on debug paths via -	 * the ioctl(); so practically speaking, in early init, no logging happens. +	 * However, realize that by default the Type/Subtype bitmaps are all +	 * zero now; so no prints will actually appear until the TestApp turns +	 * on debug paths via the ioctl(); so practically speaking, in early +	 * init, no logging happens.  	 * -	 * A solution (used below): we explicitly set the bitmaps to 1 for Type=DBG_TYPE_INITEXIT -	 * and ALL subtype's of the same. Now all bcm debug statements get logged, enabling debug -	 * during early init. +	 * A solution (used below): we explicitly set the bitmaps to 1 for +	 * Type=DBG_TYPE_INITEXIT and ALL subtype's of the same. Now all bcm +	 * debug statements get logged, enabling debug during early init.  	 * Further, we turn this OFF once init_module() completes.  	 */ @@ -191,7 +199,7 @@ static int usbbcm_device_probe(struct usb_interface *intf, const struct usb_devi  	/* Allocate interface adapter structure */  	psIntfAdapter = kzalloc(sizeof(struct bcm_interface_adapter), -				GFP_KERNEL); +			GFP_KERNEL);  	if (psIntfAdapter == NULL) {  		AdapterFree(psAdapter);  		return -ENOMEM; @@ -205,7 +213,7 @@ static int usbbcm_device_probe(struct usb_interface *intf, const struct usb_devi  	usb_set_intfdata(intf, psIntfAdapter);  	BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, -		"psIntfAdapter 0x%p\n", psIntfAdapter); +			"psIntfAdapter 0x%p\n", psIntfAdapter);  	retval = InterfaceAdapterInit(psIntfAdapter);  	if (retval) {  		/* If the Firmware/Cfg File is not present @@ -213,12 +221,13 @@ static int usbbcm_device_probe(struct usb_interface *intf, const struct usb_devi  		 * download the files.  		 */  		if (-ENOENT == retval) { -			BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, -				"File Not Found.  Use app to download.\n"); +			BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, +					DBG_LVL_ALL, +					"File Not Found.  Use app to download.\n");  			return STATUS_SUCCESS;  		} -		BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, -			"InterfaceAdapterInit failed.\n"); +		BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, +				DBG_LVL_ALL, "InterfaceAdapterInit failed.\n");  		usb_set_intfdata(intf, NULL);  		udev = interface_to_usbdev(intf);  		usb_put_dev(udev); @@ -228,7 +237,10 @@ static int usbbcm_device_probe(struct usb_interface *intf, const struct usb_devi  	if (psAdapter->chip_id > T3) {  		uint32_t uiNackZeroLengthInt = 4; -		retval = wrmalt(psAdapter, DISABLE_USB_ZERO_LEN_INT, &uiNackZeroLengthInt, sizeof(uiNackZeroLengthInt)); +		retval = +			wrmalt(psAdapter, DISABLE_USB_ZERO_LEN_INT, +					&uiNackZeroLengthInt, +					sizeof(uiNackZeroLengthInt));  		if (retval)  			return retval;  	} @@ -242,9 +254,11 @@ static int usbbcm_device_probe(struct usb_interface *intf, const struct usb_devi  			intf->needs_remote_wakeup = 1;  			usb_enable_autosuspend(udev);  			device_init_wakeup(&intf->dev, 1); -			INIT_WORK(&psIntfAdapter->usbSuspendWork, putUsbSuspend); -			BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, -				"Enabling USB Auto-Suspend\n"); +			INIT_WORK(&psIntfAdapter->usbSuspendWork, +					putUsbSuspend); +			BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, +					DBG_LVL_ALL, +					"Enabling USB Auto-Suspend\n");  #endif  		} else {  			intf->needs_remote_wakeup = 0; @@ -271,7 +285,7 @@ static void usbbcm_disconnect(struct usb_interface *intf)  	if (psAdapter->bDoSuspend)  		intf->needs_remote_wakeup = 0; -	psAdapter->device_removed = TRUE ; +	psAdapter->device_removed = TRUE;  	usb_set_intfdata(intf, NULL);  	InterfaceAdapterFree(psIntfAdapter);  	usb_put_dev(udev); @@ -285,8 +299,10 @@ static int AllocUsbCb(struct bcm_interface_adapter *psIntfAdapter)  		psIntfAdapter->asUsbTcb[i].urb = usb_alloc_urb(0, GFP_KERNEL);  		if (psIntfAdapter->asUsbTcb[i].urb == NULL) { -			BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, -				"Can't allocate Tx urb for index %d\n", i); +			BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, +					DBG_TYPE_PRINTK, 0, 0, +					"Can't allocate Tx urb for index %d\n", +					i);  			return -ENOMEM;  		}  	} @@ -295,19 +311,25 @@ static int AllocUsbCb(struct bcm_interface_adapter *psIntfAdapter)  		psIntfAdapter->asUsbRcb[i].urb = usb_alloc_urb(0, GFP_KERNEL);  		if (psIntfAdapter->asUsbRcb[i].urb == NULL) { -			BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, -				"Can't allocate Rx urb for index %d\n", i); +			BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, +					DBG_TYPE_PRINTK, 0, 0, +					"Can't allocate Rx urb for index %d\n", +					i);  			return -ENOMEM;  		} -		psIntfAdapter->asUsbRcb[i].urb->transfer_buffer = kmalloc(MAX_DATA_BUFFER_SIZE, GFP_KERNEL); +		psIntfAdapter->asUsbRcb[i].urb->transfer_buffer = +			kmalloc(MAX_DATA_BUFFER_SIZE, GFP_KERNEL);  		if (psIntfAdapter->asUsbRcb[i].urb->transfer_buffer == NULL) { -			BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, -				"Can't allocate Rx buffer for index %d\n", i); +			BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, +					DBG_TYPE_PRINTK, 0, 0, +					"Can't allocate Rx buffer for index %d\n", +					i);  			return -ENOMEM;  		} -		psIntfAdapter->asUsbRcb[i].urb->transfer_buffer_length = MAX_DATA_BUFFER_SIZE; +		psIntfAdapter->asUsbRcb[i].urb->transfer_buffer_length = +			MAX_DATA_BUFFER_SIZE;  	}  	return 0;  } @@ -322,24 +344,29 @@ static int device_run(struct bcm_interface_adapter *psIntfAdapter)  		pr_err(DRV_NAME "InitCardAndDownloadFirmware failed.\n");  		return status;  	} -	if (TRUE == psIntfAdapter->psAdapter->fw_download_done) { +	if (psIntfAdapter->psAdapter->fw_download_done) {  		if (StartInterruptUrb(psIntfAdapter)) { -			BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, -			"Cannot send interrupt in URB\n"); +			BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, +					DBG_TYPE_INITEXIT, DRV_ENTRY, +					DBG_LVL_ALL, +					"Cannot send interrupt in URB\n");  		}  		/* -		 * now register the cntrl interface. -		 * after downloading the f/w waiting for 5 sec to get the mailbox interrupt. +		 * now register the cntrl interface.  after downloading the f/w +		 * waiting for 5 sec to get the mailbox interrupt.  		 */ -		psIntfAdapter->psAdapter->waiting_to_fw_download_done = FALSE; -		value = wait_event_timeout(psIntfAdapter->psAdapter->ioctl_fw_dnld_wait_queue, -					psIntfAdapter->psAdapter->waiting_to_fw_download_done, 5*HZ); +		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;  		} @@ -347,81 +374,6 @@ static int device_run(struct bcm_interface_adapter *psIntfAdapter)  	return 0;  } - -static inline int bcm_usb_endpoint_num(const struct usb_endpoint_descriptor *epd) -{ -	return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; -} - -static inline int bcm_usb_endpoint_type(const struct usb_endpoint_descriptor *epd) -{ -	return epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; -} - -static inline int bcm_usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd) -{ -	return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN); -} - -static inline int bcm_usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd) -{ -	return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT); -} - -static inline int bcm_usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd) -{ -	return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == -		USB_ENDPOINT_XFER_BULK); -} - -static inline int bcm_usb_endpoint_xfer_control(const struct usb_endpoint_descriptor *epd) -{ -	return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == -		USB_ENDPOINT_XFER_CONTROL); -} - -static inline int bcm_usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd) -{ -	return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == -		USB_ENDPOINT_XFER_INT); -} - -static inline int bcm_usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd) -{ -	return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == -		USB_ENDPOINT_XFER_ISOC); -} - -static inline int bcm_usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd) -{ -	return bcm_usb_endpoint_xfer_bulk(epd) && bcm_usb_endpoint_dir_in(epd); -} - -static inline int bcm_usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd) -{ -	return bcm_usb_endpoint_xfer_bulk(epd) && bcm_usb_endpoint_dir_out(epd); -} - -static inline int bcm_usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd) -{ -	return bcm_usb_endpoint_xfer_int(epd) && bcm_usb_endpoint_dir_in(epd); -} - -static inline int bcm_usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *epd) -{ -	return bcm_usb_endpoint_xfer_int(epd) && bcm_usb_endpoint_dir_out(epd); -} - -static inline int bcm_usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *epd) -{ -	return bcm_usb_endpoint_xfer_isoc(epd) && bcm_usb_endpoint_dir_in(epd); -} - -static inline int bcm_usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor *epd) -{ -	return bcm_usb_endpoint_xfer_isoc(epd) && bcm_usb_endpoint_dir_out(epd); -} -  static int InterfaceAdapterInit(struct bcm_interface_adapter *psIntfAdapter)  {  	struct usb_host_interface *iface_desc; @@ -429,23 +381,27 @@ static int InterfaceAdapterInit(struct bcm_interface_adapter *psIntfAdapter)  	size_t buffer_size;  	unsigned long value;  	int retval = 0; -	int usedIntOutForBulkTransfer = 0 ; -	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;  	} @@ -453,81 +409,119 @@ static int InterfaceAdapterInit(struct bcm_interface_adapter *psIntfAdapter)  		psIntfAdapter->psAdapter->chip_id &= ~0xF0;  	dev_info(&psIntfAdapter->udev->dev, "RDM Chip ID 0x%lx\n", -		 psIntfAdapter->psAdapter->chip_id); +			psIntfAdapter->psAdapter->chip_id);  	iface_desc = psIntfAdapter->interface->cur_altsetting;  	if (psIntfAdapter->psAdapter->chip_id == T3B) { -		/* T3B device will have EEPROM, check if EEPROM is proper and BCM16 can be done or not. */ +		/* T3B device will have EEPROM, check if EEPROM is proper and +		 * BCM16 can be done or not. */  		BeceemEEPROMBulkRead(psIntfAdapter->psAdapter, &uiData, 0x0, 4);  		if (uiData == BECM)  			bBcm16 = TRUE; -		dev_info(&psIntfAdapter->udev->dev, "number of alternate setting %d\n", -			 psIntfAdapter->interface->num_altsetting); +		dev_info(&psIntfAdapter->udev->dev, +				"number of alternate setting %d\n", +				psIntfAdapter->interface->num_altsetting);  		if (bBcm16 == TRUE) { -			/* selecting alternate setting one as a default setting for High Speed  modem. */ +			/* selecting alternate setting one as a default setting +			 * for High Speed  modem. */  			if (psIntfAdapter->bHighSpeedDevice) -				retval = usb_set_interface(psIntfAdapter->udev, DEFAULT_SETTING_0, ALTERNATE_SETTING_1); -			BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, -				"BCM16 is applicable on this dongle\n"); -			if (retval || (psIntfAdapter->bHighSpeedDevice == FALSE)) { -				usedIntOutForBulkTransfer = EP2 ; +				retval = usb_set_interface(psIntfAdapter->udev, +						DEFAULT_SETTING_0, +						ALTERNATE_SETTING_1); +			BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, +					DBG_TYPE_INITEXIT, DRV_ENTRY, +					DBG_LVL_ALL, +					"BCM16 is applicable on this dongle\n"); +			if (retval || !psIntfAdapter->bHighSpeedDevice) { +				usedIntOutForBulkTransfer = EP2;  				endpoint = &iface_desc->endpoint[EP2].desc; -				BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, -					 "Interface altsetting failed or modem is configured to Full Speed, hence will work on default setting 0\n"); +				BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, +						DBG_TYPE_INITEXIT, DRV_ENTRY, +						DBG_LVL_ALL, +						"Interface altsetting failed or modem is configured to Full Speed, hence will work on default setting 0\n");  				/* -				 * If Modem is high speed device EP2 should be INT OUT End point -				 * If Mode is FS then EP2 should be bulk end point +				 * If Modem is high speed device EP2 should be +				 * INT OUT End point +				 * +				 * If Mode is FS then EP2 should be bulk end +				 * point  				 */ -				if (((psIntfAdapter->bHighSpeedDevice == TRUE) && (bcm_usb_endpoint_is_int_out(endpoint) == FALSE)) -					|| ((psIntfAdapter->bHighSpeedDevice == FALSE) && (bcm_usb_endpoint_is_bulk_out(endpoint) == FALSE))) { -					BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, -						"Configuring the EEPROM\n"); +				if ((psIntfAdapter->bHighSpeedDevice && +							!usb_endpoint_is_int_out(endpoint)) || +						(!psIntfAdapter->bHighSpeedDevice && +						 !usb_endpoint_is_bulk_out(endpoint))) { +					BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, +							DBG_TYPE_INITEXIT, +							DRV_ENTRY, DBG_LVL_ALL, +							"Configuring the EEPROM\n");  					/* change the EP2, EP4 to INT OUT end point */ -					ConfigureEndPointTypesThroughEEPROM(psIntfAdapter->psAdapter); +					ConfigureEndPointTypesThroughEEPROM( +							psIntfAdapter->psAdapter);  					/* -					 * It resets the device and if any thing gets changed -					 *  in USB descriptor it will show fail and re-enumerate -					 * the device +					 * It resets the device and if any thing +					 * gets changed in USB descriptor it +					 * will show fail and re-enumerate the +					 * device  					 */ -					retval = usb_reset_device(psIntfAdapter->udev); +					retval = usb_reset_device( +							psIntfAdapter->udev);  					if (retval) { -						BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, -							"reset failed.  Re-enumerating the device.\n"); -						return retval ; +						BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, +								DBG_TYPE_INITEXIT, +								DRV_ENTRY, +								DBG_LVL_ALL, +								"reset failed.  Re-enumerating the device.\n"); +						return retval;  					}  				} -				if ((psIntfAdapter->bHighSpeedDevice == FALSE) && bcm_usb_endpoint_is_bulk_out(endpoint)) { +				if (!psIntfAdapter->bHighSpeedDevice && +				    usb_endpoint_is_bulk_out(endpoint)) {  					/* Once BULK is selected in FS mode. Revert it back to INT. Else USB_IF will fail. */  					UINT _uiData = ntohl(EP2_CFG_INT); -					BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, -						"Reverting Bulk to INT as it is in Full Speed mode.\n"); -					BeceemEEPROMBulkWrite(psIntfAdapter->psAdapter, (PUCHAR)&_uiData, 0x136, 4, TRUE); +					BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, +							DBG_TYPE_INITEXIT, +							DRV_ENTRY, DBG_LVL_ALL, +							"Reverting Bulk to INT as it is in Full Speed mode.\n"); +					BeceemEEPROMBulkWrite( +							psIntfAdapter->psAdapter, +							(PUCHAR) & _uiData, +							0x136, 4, TRUE);  				}  			} else { -				usedIntOutForBulkTransfer = EP4 ; +				usedIntOutForBulkTransfer = EP4;  				endpoint = &iface_desc->endpoint[EP4].desc; -				BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, -					"Choosing AltSetting as a default setting.\n"); -				if (bcm_usb_endpoint_is_int_out(endpoint) == FALSE) { -					BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, -						"Dongle does not have BCM16 Fix.\n"); +				BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, +						DBG_TYPE_INITEXIT, DRV_ENTRY, +						DBG_LVL_ALL, +						"Choosing AltSetting as a default setting.\n"); +				if (!usb_endpoint_is_int_out(endpoint)) { +					BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, +							DBG_TYPE_INITEXIT, +							DRV_ENTRY, DBG_LVL_ALL, +							"Dongle does not have BCM16 Fix.\n");  					/* change the EP2, EP4 to INT OUT end point and use EP4 in altsetting */ -					ConfigureEndPointTypesThroughEEPROM(psIntfAdapter->psAdapter); +					ConfigureEndPointTypesThroughEEPROM( +							psIntfAdapter->psAdapter);  					/* -					 * It resets the device and if any thing gets changed in -					 *  USB descriptor it will show fail and re-enumerate the +					 * It resets the device and if any thing +					 * gets changed in USB descriptor it +					 * will show fail and re-enumerate the  					 * device  					 */ -					retval = usb_reset_device(psIntfAdapter->udev); +					retval = usb_reset_device( +							psIntfAdapter->udev);  					if (retval) { -						BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, -							"reset failed.  Re-enumerating the device.\n"); +						BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, +								DBG_TYPE_INITEXIT, +								DRV_ENTRY, +								DBG_LVL_ALL, +								"reset failed.  Re-enumerating the device.\n");  						return retval;  					} @@ -541,49 +535,69 @@ static int InterfaceAdapterInit(struct bcm_interface_adapter *psIntfAdapter)  	for (value = 0; value < iface_desc->desc.bNumEndpoints; ++value) {  		endpoint = &iface_desc->endpoint[value].desc; -		if (!psIntfAdapter->sBulkIn.bulk_in_endpointAddr && bcm_usb_endpoint_is_bulk_in(endpoint)) { +		if (!psIntfAdapter->sBulkIn.bulk_in_endpointAddr && +				usb_endpoint_is_bulk_in(endpoint)) {  			buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);  			psIntfAdapter->sBulkIn.bulk_in_size = buffer_size; -			psIntfAdapter->sBulkIn.bulk_in_endpointAddr = endpoint->bEndpointAddress; -			psIntfAdapter->sBulkIn.bulk_in_pipe = -					usb_rcvbulkpipe(psIntfAdapter->udev, -								psIntfAdapter->sBulkIn.bulk_in_endpointAddr); +			psIntfAdapter->sBulkIn.bulk_in_endpointAddr = +				endpoint->bEndpointAddress; +			psIntfAdapter->sBulkIn.bulk_in_pipe = usb_rcvbulkpipe( +					psIntfAdapter->udev, +					psIntfAdapter->sBulkIn.bulk_in_endpointAddr);  		} -		if (!psIntfAdapter->sBulkOut.bulk_out_endpointAddr && bcm_usb_endpoint_is_bulk_out(endpoint)) { -			psIntfAdapter->sBulkOut.bulk_out_endpointAddr = endpoint->bEndpointAddress; -			psIntfAdapter->sBulkOut.bulk_out_pipe = -				usb_sndbulkpipe(psIntfAdapter->udev, +		if (!psIntfAdapter->sBulkOut.bulk_out_endpointAddr && +				usb_endpoint_is_bulk_out(endpoint)) { +			psIntfAdapter->sBulkOut.bulk_out_endpointAddr = +				endpoint->bEndpointAddress; +			psIntfAdapter->sBulkOut.bulk_out_pipe = usb_sndbulkpipe( +					psIntfAdapter->udev,  					psIntfAdapter->sBulkOut.bulk_out_endpointAddr);  		} -		if (!psIntfAdapter->sIntrIn.int_in_endpointAddr && bcm_usb_endpoint_is_int_in(endpoint)) { +		if (!psIntfAdapter->sIntrIn.int_in_endpointAddr && +				usb_endpoint_is_int_in(endpoint)) {  			buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);  			psIntfAdapter->sIntrIn.int_in_size = buffer_size; -			psIntfAdapter->sIntrIn.int_in_endpointAddr = endpoint->bEndpointAddress; -			psIntfAdapter->sIntrIn.int_in_interval = endpoint->bInterval; +			psIntfAdapter->sIntrIn.int_in_endpointAddr = +				endpoint->bEndpointAddress; +			psIntfAdapter->sIntrIn.int_in_interval = +				endpoint->bInterval;  			psIntfAdapter->sIntrIn.int_in_buffer = -						kmalloc(buffer_size, GFP_KERNEL); +				kmalloc(buffer_size, GFP_KERNEL);  			if (!psIntfAdapter->sIntrIn.int_in_buffer)  				return -EINVAL;  		} -		if (!psIntfAdapter->sIntrOut.int_out_endpointAddr && bcm_usb_endpoint_is_int_out(endpoint)) { +		if (!psIntfAdapter->sIntrOut.int_out_endpointAddr && +				usb_endpoint_is_int_out(endpoint)) {  			if (!psIntfAdapter->sBulkOut.bulk_out_endpointAddr && -				(psIntfAdapter->psAdapter->chip_id == T3B) && (value == usedIntOutForBulkTransfer)) { +					(psIntfAdapter->psAdapter->chip_id == T3B) && +					(value == usedIntOutForBulkTransfer)) {  				/* use first intout end point as a bulk out end point */ -				buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); -				psIntfAdapter->sBulkOut.bulk_out_size = buffer_size; -				psIntfAdapter->sBulkOut.bulk_out_endpointAddr = endpoint->bEndpointAddress; -				psIntfAdapter->sBulkOut.bulk_out_pipe = usb_sndintpipe(psIntfAdapter->udev, -									psIntfAdapter->sBulkOut.bulk_out_endpointAddr); -				psIntfAdapter->sBulkOut.int_out_interval = endpoint->bInterval; +				buffer_size = +					le16_to_cpu(endpoint->wMaxPacketSize); +				psIntfAdapter->sBulkOut.bulk_out_size = +					buffer_size; +				psIntfAdapter->sBulkOut.bulk_out_endpointAddr = +					endpoint->bEndpointAddress; +				psIntfAdapter->sBulkOut.bulk_out_pipe = +					usb_sndintpipe(psIntfAdapter->udev, +							psIntfAdapter->sBulkOut +							.bulk_out_endpointAddr); +				psIntfAdapter->sBulkOut.int_out_interval = +					endpoint->bInterval;  			} else if (value == EP6) { -				buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); -				psIntfAdapter->sIntrOut.int_out_size = buffer_size; -				psIntfAdapter->sIntrOut.int_out_endpointAddr = endpoint->bEndpointAddress; -				psIntfAdapter->sIntrOut.int_out_interval = endpoint->bInterval; -				psIntfAdapter->sIntrOut.int_out_buffer = kmalloc(buffer_size, GFP_KERNEL); +				buffer_size = +					le16_to_cpu(endpoint->wMaxPacketSize); +				psIntfAdapter->sIntrOut.int_out_size = +					buffer_size; +				psIntfAdapter->sIntrOut.int_out_endpointAddr = +					endpoint->bEndpointAddress; +				psIntfAdapter->sIntrOut.int_out_interval = +					endpoint->bInterval; +				psIntfAdapter->sIntrOut.int_out_buffer = +					kmalloc(buffer_size, GFP_KERNEL);  				if (!psIntfAdapter->sIntrOut.int_out_buffer)  					return -EINVAL;  			} @@ -594,14 +608,14 @@ static int InterfaceAdapterInit(struct bcm_interface_adapter *psIntfAdapter)  	psIntfAdapter->psAdapter->bcm_file_download = InterfaceFileDownload;  	psIntfAdapter->psAdapter->bcm_file_readback_from_chip = -				InterfaceFileReadbackFromChip; +		InterfaceFileReadbackFromChip;  	psIntfAdapter->psAdapter->interface_transmit = InterfaceTransmitPacket;  	retval = CreateInterruptUrb(psIntfAdapter);  	if (retval) {  		BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, -			"Cannot create interrupt urb\n"); +				"Cannot create interrupt urb\n");  		return retval;  	} @@ -618,20 +632,24 @@ static int InterfaceSuspend(struct usb_interface *intf, pm_message_t message)  	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); @@ -644,7 +662,7 @@ static int InterfaceResume(struct usb_interface *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/InterfaceIsr.c b/drivers/staging/bcm/InterfaceIsr.c index 8322f1b76e2..b9f8a7aa24f 100644 --- a/drivers/staging/bcm/InterfaceIsr.c +++ b/drivers/staging/bcm/InterfaceIsr.c @@ -4,108 +4,126 @@  static void read_int_callback(struct urb *urb/*, struct pt_regs *regs*/)  {  	int		status = urb->status; -	struct bcm_interface_adapter *psIntfAdapter = (struct bcm_interface_adapter *)urb->context; -	struct bcm_mini_adapter *Adapter = psIntfAdapter->psAdapter ; +	struct bcm_interface_adapter *psIntfAdapter = +		(struct bcm_interface_adapter *)urb->context; +	struct bcm_mini_adapter *Adapter = psIntfAdapter->psAdapter;  	if (netif_msg_intr(Adapter))  		pr_info(PFX "%s: interrupt status %d\n", -			Adapter->dev->name, status); +				Adapter->dev->name, status); -	if(Adapter->device_removed == TRUE) -	{ -		BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Device has Got Removed."); -		return ; +	if (Adapter->device_removed) { +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, +				DBG_LVL_ALL, "Device has Got Removed."); +		return;  	} -	if(((Adapter->bPreparingForLowPowerMode == TRUE) && (Adapter->bDoSuspend == TRUE)) || -		psIntfAdapter->bSuspended || -		psIntfAdapter->bPreparingForBusSuspend) -	{ -			BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Interrupt call back is called while suspending the device"); -			return ; +	if ((Adapter->bPreparingForLowPowerMode && Adapter->bDoSuspend) || +			psIntfAdapter->bSuspended || +			psIntfAdapter->bPreparingForBusSuspend) { +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, +				DBG_LVL_ALL, +				"Interrupt call back is called while suspending the device"); +		return;  	} -	//BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "interrupt urb status %d", status);  	switch (status) { -	    /* success */ -	    case STATUS_SUCCESS: -		if ( urb->actual_length ) -		{ - -			if(psIntfAdapter->ulInterruptData[1] & 0xFF) -			{ -				BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "Got USIM interrupt"); +	/* success */ +	case STATUS_SUCCESS: +		if (urb->actual_length) { + +			if (psIntfAdapter->ulInterruptData[1] & 0xFF) { +				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, +						INTF_INIT, DBG_LVL_ALL, +						"Got USIM interrupt");  			} -			if(psIntfAdapter->ulInterruptData[1] & 0xFF00) -			{ +			if (psIntfAdapter->ulInterruptData[1] & 0xFF00) {  				atomic_set(&Adapter->CurrNumFreeTxDesc, -					(psIntfAdapter->ulInterruptData[1] & 0xFF00) >> 8); -				atomic_set (&Adapter->uiMBupdate, TRUE); -				BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "TX mailbox contains %d", +					(psIntfAdapter->ulInterruptData[1] & +					 0xFF00) >> 8); +				atomic_set(&Adapter->uiMBupdate, TRUE); +				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, +					INTF_INIT, DBG_LVL_ALL, +					"TX mailbox contains %d",  					atomic_read(&Adapter->CurrNumFreeTxDesc));  			} -			if(psIntfAdapter->ulInterruptData[1] >> 16) -			{ -				Adapter->CurrNumRecvDescs= +			if (psIntfAdapter->ulInterruptData[1] >> 16) { +				Adapter->CurrNumRecvDescs =  					(psIntfAdapter->ulInterruptData[1]  >> 16); -				BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"RX mailbox contains %d", -					Adapter->CurrNumRecvDescs); +				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, +						INTF_INIT, DBG_LVL_ALL, +						"RX mailbox contains %d", +						Adapter->CurrNumRecvDescs);  				InterfaceRx(psIntfAdapter);  			} -			if(Adapter->fw_download_done && +			if (Adapter->fw_download_done &&  				!Adapter->downloadDDR && -				atomic_read(&Adapter->CurrNumFreeTxDesc)) -			{ -				psIntfAdapter->psAdapter->downloadDDR +=1; +				atomic_read(&Adapter->CurrNumFreeTxDesc)) { + +				psIntfAdapter->psAdapter->downloadDDR += 1;  				wake_up(&Adapter->tx_packet_wait_queue);  			} -			if(FALSE == Adapter->waiting_to_fw_download_done) -			{ +			if (!Adapter->waiting_to_fw_download_done) {  				Adapter->waiting_to_fw_download_done = TRUE;  				wake_up(&Adapter->ioctl_fw_dnld_wait_queue);  			} -			if(!atomic_read(&Adapter->TxPktAvail)) -			{ +			if (!atomic_read(&Adapter->TxPktAvail)) {  				atomic_set(&Adapter->TxPktAvail, 1);  				wake_up(&Adapter->tx_packet_wait_queue);  			} -			BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Firing interrupt in URB"); +			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, +					DBG_LVL_ALL, "Firing interrupt in URB");  		}  		break; -		case -ENOENT : -		{ -			BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"URB has got disconnected ...."); -			return ; -		} -		case -EINPROGRESS: -		{ -			//This situation may happened when URBunlink is used. for detail check usb_unlink_urb documentation. -			BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Impossibe condition has occurred... something very bad is going on"); -			break ; -			//return; -		} -		case -EPIPE: -		{ -				BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Interrupt IN endPoint  has got halted/stalled...need to clear this"); -				Adapter->bEndPointHalted = TRUE ; -				wake_up(&Adapter->tx_packet_wait_queue); -				urb->status = STATUS_SUCCESS ; -				return; -		} -	    /* software-driven interface shutdown */ -	    case -ECONNRESET: //URB got unlinked. -	    case -ESHUTDOWN:		// hardware gone. this is the serious problem. -	    						//Occurs only when something happens with the host controller device -	    case -ENODEV : //Device got removed -		case -EINVAL : //Some thing very bad happened with the URB. No description is available. -	    	BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"interrupt urb error %d", status); -			urb->status = STATUS_SUCCESS ; -			break ; -			//return; -	    default: -			//This is required to check what is the defaults conditions when it occurs.. -			BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,"GOT DEFAULT INTERRUPT URB STATUS :%d..Please Analyze it...", status); +	case -ENOENT: +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, +				DBG_LVL_ALL, "URB has got disconnected...."); +		return; +	case -EINPROGRESS: +		/* +		 * This situation may happened when URBunlink is used.  for +		 * detail check usb_unlink_urb documentation. +		 */ +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, +				DBG_LVL_ALL, +				"Impossibe condition has occurred... something very bad is going on"); +		break; +		/* return; */ +	case -EPIPE: +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, +				DBG_LVL_ALL, +				"Interrupt IN endPoint has got halted/stalled...need to clear this"); +		Adapter->bEndPointHalted = TRUE; +		wake_up(&Adapter->tx_packet_wait_queue); +		urb->status = STATUS_SUCCESS; +		return; +	/* software-driven interface shutdown */ +	case -ECONNRESET:	/* URB got unlinked */ +	case -ESHUTDOWN:	/* hardware gone. this is the serious problem */ +		/* +		 * Occurs only when something happens with the +		 * host controller device +		 */ +	case -ENODEV: /* Device got removed */ +	case -EINVAL: +		/* +		 * Some thing very bad happened with the URB. No +		 * description is available. +		 */ +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, +				DBG_LVL_ALL, "interrupt urb error %d", status); +		urb->status = STATUS_SUCCESS; +		break; +		/* return; */ +	default: +		/* +		 * This is required to check what is the defaults conditions +		 * when it occurs.. +		 */ +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, +				"GOT DEFAULT INTERRUPT URB STATUS :%d..Please Analyze it...", +				status);  		break;  	} @@ -117,28 +135,30 @@ static void read_int_callback(struct urb *urb/*, struct pt_regs *regs*/)  int CreateInterruptUrb(struct bcm_interface_adapter *psIntfAdapter)  {  	psIntfAdapter->psInterruptUrb = usb_alloc_urb(0, GFP_KERNEL); -	if (!psIntfAdapter->psInterruptUrb) -	{ -		BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Cannot allocate interrupt urb"); +	if (!psIntfAdapter->psInterruptUrb) { +		BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, +				INTF_INIT, DBG_LVL_ALL, +				"Cannot allocate interrupt urb");  		return -ENOMEM;  	}  	psIntfAdapter->psInterruptUrb->transfer_buffer = -								psIntfAdapter->ulInterruptData; +		psIntfAdapter->ulInterruptData;  	psIntfAdapter->psInterruptUrb->transfer_buffer_length = -							sizeof(psIntfAdapter->ulInterruptData); +		sizeof(psIntfAdapter->ulInterruptData);  	psIntfAdapter->sIntrIn.int_in_pipe = usb_rcvintpipe(psIntfAdapter->udev, -						psIntfAdapter->sIntrIn.int_in_endpointAddr); +			psIntfAdapter->sIntrIn.int_in_endpointAddr);  	usb_fill_int_urb(psIntfAdapter->psInterruptUrb, psIntfAdapter->udev, -					psIntfAdapter->sIntrIn.int_in_pipe, -					psIntfAdapter->psInterruptUrb->transfer_buffer, -					psIntfAdapter->psInterruptUrb->transfer_buffer_length, -					read_int_callback, psIntfAdapter, -					psIntfAdapter->sIntrIn.int_in_interval); - -	BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Interrupt Interval: %d\n", -				psIntfAdapter->sIntrIn.int_in_interval); +			psIntfAdapter->sIntrIn.int_in_pipe, +			psIntfAdapter->psInterruptUrb->transfer_buffer, +			psIntfAdapter->psInterruptUrb->transfer_buffer_length, +			read_int_callback, psIntfAdapter, +			psIntfAdapter->sIntrIn.int_in_interval); + +	BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, INTF_INIT, +			DBG_LVL_ALL, "Interrupt Interval: %d\n", +			psIntfAdapter->sIntrIn.int_in_interval);  	return 0;  } @@ -147,19 +167,20 @@ INT StartInterruptUrb(struct bcm_interface_adapter *psIntfAdapter)  {  	INT status = 0; -	if( FALSE == psIntfAdapter->psAdapter->device_removed && -		FALSE == psIntfAdapter->psAdapter->bEndPointHalted && -		FALSE == psIntfAdapter->bSuspended && -		FALSE == psIntfAdapter->bPreparingForBusSuspend && -		FALSE == psIntfAdapter->psAdapter->StopAllXaction) -	{ -		status = usb_submit_urb(psIntfAdapter->psInterruptUrb, GFP_ATOMIC); -		if (status) -		{ -			BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Cannot send int urb %d\n", status); -			if(status == -EPIPE) -			{ -				psIntfAdapter->psAdapter->bEndPointHalted = TRUE ; +	if (!(psIntfAdapter->psAdapter->device_removed || +				psIntfAdapter->psAdapter->bEndPointHalted || +				psIntfAdapter->bSuspended || +				psIntfAdapter->bPreparingForBusSuspend || +				psIntfAdapter->psAdapter->StopAllXaction)) { +		status = +			usb_submit_urb(psIntfAdapter->psInterruptUrb, GFP_ATOMIC); +		if (status) { +			BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, +					DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, +					"Cannot send inturb %d\n", status); +			if (status == -EPIPE) { +				psIntfAdapter->psAdapter->bEndPointHalted = +					TRUE;  				wake_up(&psIntfAdapter->psAdapter->tx_packet_wait_queue);  			}  		} diff --git a/drivers/staging/bcm/InterfaceMisc.c b/drivers/staging/bcm/InterfaceMisc.c index afca010f9db..4173fd7d671 100644 --- a/drivers/staging/bcm/InterfaceMisc.c +++ b/drivers/staging/bcm/InterfaceMisc.c @@ -44,7 +44,7 @@ int InterfaceRDM(struct bcm_interface_adapter *psIntfAdapter,  	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;  } @@ -90,10 +90,10 @@ int InterfaceWRM(struct bcm_interface_adapter *psIntfAdapter,  	if (retval < 0)	{  		BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, WRM, DBG_LVL_ALL, "WRM failed status :%d", retval); -		psIntfAdapter->psAdapter->DeviceAccess = FALSE; +		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;  	} @@ -104,7 +104,7 @@ int BcmRDM(void *arg,  	void *buff,  	int len)  { -	return InterfaceRDM((struct bcm_interface_adapter*)arg, addr, buff, len); +	return InterfaceRDM((struct bcm_interface_adapter *)arg, addr, buff, len);  }  int BcmWRM(void *arg, @@ -211,7 +211,7 @@ void putUsbSuspend(struct work_struct *work)  	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 bce6869a747..efb68604615 100644 --- a/drivers/staging/bcm/InterfaceMisc.h +++ b/drivers/staging/bcm/InterfaceMisc.h @@ -14,13 +14,13 @@ InterfaceWRM(struct bcm_interface_adapter *psIntfAdapter,  			INT len); -int InterfaceFileDownload( PVOID psIntfAdapter, -                        struct file *flp, -                        unsigned int on_chip_loc); +int InterfaceFileDownload(PVOID psIntfAdapter, +			struct file *flp, +			unsigned int on_chip_loc); -int InterfaceFileReadbackFromChip( PVOID psIntfAdapter, -                        struct file *flp, -                        unsigned int on_chip_loc); +int InterfaceFileReadbackFromChip(PVOID psIntfAdapter, +			struct file *flp, +			unsigned int on_chip_loc);  int BcmRDM(PVOID arg, diff --git a/drivers/staging/bcm/InterfaceRx.c b/drivers/staging/bcm/InterfaceRx.c index 26f5bc76111..11008173f91 100644 --- a/drivers/staging/bcm/InterfaceRx.c +++ b/drivers/staging/bcm/InterfaceRx.c @@ -1,11 +1,11 @@  #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; @@ -18,15 +18,14 @@ GetBulkInRcb(struct bcm_interface_adapter *psIntfAdapter)  	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,11 +37,10 @@ GetBulkInRcb(struct bcm_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 ;  	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; @@ -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,30 +151,27 @@ 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);  } @@ -201,23 +180,18 @@ static int ReceiveRcb(struct bcm_interface_adapter *psIntfAdapter, struct bcm_us  	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 (struct bcm_interface_adapter *psIntfAdapter) +bool InterfaceRx(struct bcm_interface_adapter *psIntfAdapter)  {  	USHORT RxDescCount = NUM_RX_DESC - atomic_read(&psIntfAdapter->uNumRcbUsed);  	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 424645e9e47..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(struct bcm_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 b8c785556dd..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*/)  { -	struct bcm_usb_tcb *pTcb= (struct bcm_usb_tcb *)urb->context; +	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,9 +87,9 @@ 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);  } @@ -112,14 +98,13 @@ static struct bcm_usb_tcb *GetBulkOutTcb(struct bcm_interface_adapter *psIntfAda  	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); @@ -135,44 +120,37 @@ static int TransmitTcb(struct bcm_interface_adapter *psIntfAdapter, struct bcm_u  	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(struct bcm_interface_adapter *psIntfAdapter, struct bcm_u  int InterfaceTransmitPacket(PVOID arg, PVOID data, UINT len)  { -	struct bcm_usb_tcb *pTcb= NULL; +	struct bcm_usb_tcb *pTcb = NULL; -	struct bcm_interface_adapter *psIntfAdapter = (struct bcm_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/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 bc486163332..f95b06713a2 100644 --- a/drivers/staging/bcm/LeakyBucket.c +++ b/drivers/staging/bcm/LeakyBucket.c @@ -82,7 +82,7 @@ static ULONG GetSFTokenCount(struct bcm_mini_adapter *Adapter, struct bcm_packet  		return 0;  	} -	if (FALSE != psSF->bValid && psSF->ucDirection) { +	if (false != psSF->bValid && psSF->ucDirection) {  		if (0 != psSF->uiCurrentTokenCount) {  				return psSF->uiCurrentTokenCount;  		} else { @@ -188,7 +188,7 @@ static VOID CheckAndSendPacketFromIndex(struct bcm_mini_adapter *Adapter, struct  				spin_unlock_bh(&psSF->SFQueueLock);  				Status = SendPacketFromQueue(Adapter, psSF, QueuePacket); -				psSF->uiPendedLast = FALSE; +				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", @@ -250,7 +250,7 @@ VOID transmit_packets(struct bcm_mini_adapter *Adapter)  	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, "=====>"); @@ -299,7 +299,7 @@ VOID transmit_packets(struct bcm_mini_adapter *Adapter)  				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;  			}  		} diff --git a/drivers/staging/bcm/Misc.c b/drivers/staging/bcm/Misc.c index 4cfc2c33c69..7b2fa0f4a2e 100644 --- a/drivers/staging/bcm/Misc.c +++ b/drivers/staging/bcm/Misc.c @@ -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++) { @@ -255,7 +255,7 @@ int CopyBufferToControlPacket(struct bcm_mini_adapter *Adapter, void *ioBuffer)  		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; @@ -346,7 +346,7 @@ int CopyBufferToControlPacket(struct bcm_mini_adapter *Adapter, void *ioBuffer)  			pktlen = pLeader->PLength;  			Status = StoreCmControlResponseMessage(Adapter, pucAddIndication, &pktlen);  			if (Status != 1) { -				ClearTargetDSXBuffer(Adapter, ((struct bcm_add_indication_alt *)pucAddIndication)->u16TID, FALSE); +				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;  			} @@ -499,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); @@ -517,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; @@ -578,7 +578,7 @@ 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; @@ -613,7 +613,7 @@ void SendIdleModeResponse(struct bcm_mini_adapter *Adapter)  			if (Adapter->bDoSuspend == TRUE)  				Bcm_kill_all_URBs((struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter));  		} else { -			Adapter->bPreparingForLowPowerMode = FALSE; +			Adapter->bPreparingForLowPowerMode = false;  		}  		if (!NVMAccess) @@ -626,7 +626,7 @@ 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; +		Adapter->bPreparingForLowPowerMode = false;  		StartInterruptUrb((struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter));  	}  	do_gettimeofday(&tv); @@ -651,8 +651,8 @@ void DumpPackInfo(struct bcm_mini_adapter *Adapter)  	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;  		} @@ -783,7 +783,7 @@ int reset_card_proc(struct bcm_mini_adapter *ps_adapter)  	int bytes;  	psIntfAdapter = ((struct bcm_interface_adapter *)(ps_adapter->pvInterfaceAdapter)); -	ps_adapter->bDDRInitDone = FALSE; +	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 */ @@ -803,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); @@ -888,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;  } @@ -968,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. */ @@ -1094,7 +1094,7 @@ void beceem_parse_target_struct(struct bcm_mini_adapter *Adapter)  	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; @@ -1105,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; @@ -1117,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; @@ -1155,21 +1155,21 @@ static void doPowerAutoCorrection(struct bcm_mini_adapter *psAdapter)  	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)); @@ -1302,8 +1302,8 @@ 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");  } @@ -1341,7 +1341,7 @@ 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 */ @@ -1374,7 +1374,7 @@ static void SendShutModeResponse(struct bcm_mini_adapter *Adapter)  			if (Adapter->bDoSuspend == TRUE)  				Bcm_kill_all_URBs((struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter));  		} else { -			Adapter->bPreparingForLowPowerMode = FALSE; +			Adapter->bPreparingForLowPowerMode = false;  		}  		if (!NVMAccess) @@ -1387,7 +1387,7 @@ 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; +		Adapter->bPreparingForLowPowerMode = false;  		StartInterruptUrb((struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter));  	}  } @@ -1430,11 +1430,11 @@ 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) @@ -1521,7 +1521,7 @@ 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, unsigned int iQIndex) @@ -1557,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 */ @@ -1568,7 +1568,7 @@ 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); diff --git a/drivers/staging/bcm/PHSModule.c b/drivers/staging/bcm/PHSModule.c index af5d22faa7f..07c5a0bae1e 100644 --- a/drivers/staging/bcm/PHSModule.c +++ b/drivers/staging/bcm/PHSModule.c @@ -8,9 +8,9 @@ static UINT CreateClassifierPHSRule(B_UINT16  uiClsId, struct bcm_phs_classifier  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(struct bcm_phs_rule *psPhsRule); +static bool ValidatePHSRuleComplete(struct bcm_phs_rule *psPhsRule); -static BOOLEAN DerefPhsRule(B_UINT16 uiClsId, struct bcm_phs_classifier_table *psaClassifiertable, struct bcm_phs_rule *pstPhsRule); +static bool DerefPhsRule(B_UINT16 uiClsId, struct bcm_phs_classifier_table *psaClassifiertable, struct bcm_phs_rule *pstPhsRule);  static UINT GetClassifierEntry(struct bcm_phs_classifier_table *pstClassifierTable, B_UINT32 uiClsid, enum bcm_phs_classifier_context eClsContext, struct bcm_phs_classifier_entry **ppstClassifierEntry); @@ -67,7 +67,7 @@ int PHSTransmit(struct bcm_mini_adapter *Adapter,  		struct sk_buff **pPacket,  		USHORT Vcid,  		B_UINT16 uiClassifierRuleID, -		BOOLEAN bHeaderSuppressionEnabled, +		bool bHeaderSuppressionEnabled,  		UINT *PacketLen,  		UCHAR bEthCSSupport)  { @@ -81,7 +81,7 @@ int PHSTransmit(struct bcm_mini_adapter *Adapter,  	PUCHAR pucPHSPktHdrOutBuf = Adapter->stPhsTxContextInfo.ucaHdrSuppressionOutBuf;  	UINT usPacketType;  	UINT BytesToRemove = 0; -	BOOLEAN bPHSI = 0; +	bool bPHSI = 0;  	LONG ulPhsStatus = 0;  	UINT numBytesCompressed = 0;  	struct sk_buff *newPacket = NULL; @@ -409,7 +409,6 @@ ULONG PhsUpdateClassifierRule(IN void *pvContext,   */  ULONG PhsDeletePHSRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT8 u8PHSI)  { -	ULONG lStatus = 0;  	UINT nSFIndex = 0, nClsidIndex = 0;  	struct bcm_phs_entry *pstServiceFlowEntry = NULL;  	struct bcm_phs_classifier_table *pstClassifierRulesTable = NULL; @@ -446,7 +445,7 @@ ULONG PhsDeletePHSRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT8 u8PHSI  			}  		}  	} -	return lStatus; +	return 0;  }  /* @@ -467,7 +466,6 @@ ULONG PhsDeletePHSRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT8 u8PHSI   */  ULONG PhsDeleteClassifierRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT16 uiClsId)  { -	ULONG lStatus = 0;  	UINT nSFIndex = 0, nClsidIndex = 0;  	struct bcm_phs_entry *pstServiceFlowEntry = NULL;  	struct bcm_phs_classifier_entry *pstClassifierEntry = NULL; @@ -504,7 +502,7 @@ ULONG PhsDeleteClassifierRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT1  			memset(pstClassifierEntry, 0, sizeof(struct bcm_phs_classifier_entry));  		}  	} -	return lStatus; +	return 0;  }  /* @@ -524,7 +522,6 @@ ULONG PhsDeleteClassifierRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT1   */  ULONG PhsDeleteSFRules(IN void *pvContext, IN B_UINT16 uiVcid)  { -	ULONG lStatus = 0;  	UINT nSFIndex = 0, nClsidIndex = 0;  	struct bcm_phs_entry *pstServiceFlowEntry = NULL;  	struct bcm_phs_classifier_table *pstClassifierRulesTable = NULL; @@ -569,11 +566,11 @@ ULONG PhsDeleteSFRules(IN void *pvContext, IN B_UINT16 uiVcid)  				memset(&pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex], 0, sizeof(struct bcm_phs_classifier_entry));  			}  		} -		pstServiceFlowEntry->bUsed = FALSE; +		pstServiceFlowEntry->bUsed = false;  		pstServiceFlowEntry->uiVcid = 0;  	} -	return lStatus; +	return 0;  }  /* @@ -596,7 +593,7 @@ ULONG PhsDeleteSFRules(IN void *pvContext, IN B_UINT16 uiVcid)   * 0 if successful,   * >0 Error.   */ -ULONG PhsCompress(IN void *pvContext, +static ULONG PhsCompress(IN void *pvContext,  		IN B_UINT16 uiVcid,  		IN B_UINT16 uiClsId,  		IN void *pvInputBuffer, @@ -677,7 +674,7 @@ ULONG PhsCompress(IN void *pvContext,   * 0 if successful,   * >0 Error.   */ -ULONG PhsDeCompress(IN void *pvContext, +static ULONG PhsDeCompress(IN void *pvContext,  		IN B_UINT16 uiVcid,  		IN void *pvInputBuffer,  		OUT void *pvOutputBuffer, @@ -788,26 +785,26 @@ static void free_phs_serviceflow_rules(struct bcm_phs_table *psServiceFlowRulesT  	psServiceFlowRulesTable = NULL;  } -static BOOLEAN ValidatePHSRuleComplete(IN struct bcm_phs_rule *psPhsRule) +static bool ValidatePHSRuleComplete(IN struct bcm_phs_rule *psPhsRule)  {  	if (psPhsRule) {  		if (!psPhsRule->u8PHSI) {  			/* PHSI is not valid */ -			return FALSE; +			return false;  		}  		if (!psPhsRule->u8PHSS) {  			/* PHSS Is Undefined */ -			return FALSE; +			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 false;  		return TRUE;  	} else -		return FALSE; +		return false;  }  UINT GetServiceFlowEntry(IN struct bcm_phs_table *psServiceFlowTable, @@ -829,7 +826,7 @@ UINT GetServiceFlowEntry(IN struct bcm_phs_table *psServiceFlowTable,  	return PHS_INVALID_TABLE_INDEX;  } -UINT GetClassifierEntry(IN struct bcm_phs_classifier_table *pstClassifierTable, +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)  { @@ -880,7 +877,7 @@ static UINT GetPhsRuleEntry(IN struct bcm_phs_classifier_table *pstClassifierTab  	return PHS_INVALID_TABLE_INDEX;  } -UINT CreateSFToClassifierRuleMapping(IN B_UINT16 uiVcid, IN B_UINT16  uiClsId, +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) @@ -888,7 +885,7 @@ UINT CreateSFToClassifierRuleMapping(IN B_UINT16 uiVcid, IN B_UINT16  uiClsId,  	struct bcm_phs_classifier_table *psaClassifiertable = NULL;  	UINT uiStatus = 0;  	int iSfIndex; -	BOOLEAN bFreeEntryFound = FALSE; +	bool bFreeEntryFound = false;  	/* Check for a free entry in SFID table */  	for (iSfIndex = 0; iSfIndex < MAX_SERVICEFLOWS; iSfIndex++) { @@ -913,7 +910,7 @@ UINT CreateSFToClassifierRuleMapping(IN B_UINT16 uiVcid, IN B_UINT16  uiClsId,  	return uiStatus;  } -UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid, +static UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid,  				IN B_UINT16 uiClsId,  				IN struct bcm_phs_entry *pstServiceFlowEntry,  				struct bcm_phs_rule *psPhsRule, @@ -1009,7 +1006,7 @@ static UINT CreateClassifierPHSRule(IN B_UINT16  uiClsId,  				B_UINT8 u8AssociatedPHSI)  {  	UINT iClassifierIndex = 0; -	BOOLEAN bFreeEntryFound = FALSE; +	bool bFreeEntryFound = false;  	struct bcm_phs_classifier_entry *psClassifierRules = NULL;  	UINT nStatus = PHS_SUCCESS;  	struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); @@ -1102,7 +1099,7 @@ static UINT UpdateClassifierPHSRule(IN B_UINT16  uiClsId,  {  	struct bcm_phs_rule *pstAddPhsRule = NULL;  	UINT nPhsRuleIndex = 0; -	BOOLEAN bPHSRuleOrphaned = FALSE; +	bool bPHSRuleOrphaned = false;  	struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);  	psPhsRule->u8RefCnt = 0; @@ -1124,7 +1121,7 @@ static UINT UpdateClassifierPHSRule(IN B_UINT16  uiClsId,  		}  		/* Step 2.a PHS Rule Does Not Exist .Create New PHS Rule for uiClsId */ -		if (FALSE == bPHSRuleOrphaned) { +		if (false == bPHSRuleOrphaned) {  			pstClassifierEntry->pstPhsRule = kmalloc(sizeof(struct bcm_phs_rule), GFP_KERNEL);  			if (NULL == pstClassifierEntry->pstPhsRule) @@ -1150,10 +1147,10 @@ static UINT UpdateClassifierPHSRule(IN B_UINT16  uiClsId,  	return PHS_SUCCESS;  } -static BOOLEAN DerefPhsRule(IN B_UINT16  uiClsId, struct bcm_phs_classifier_table *psaClassifiertable, struct bcm_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; +		return false;  	if (pstPhsRule->u8RefCnt)  		pstPhsRule->u8RefCnt--; @@ -1166,7 +1163,7 @@ static BOOLEAN DerefPhsRule(IN B_UINT16  uiClsId, struct bcm_phs_classifier_tabl  		 */  		return TRUE;  	} else -		return FALSE; +		return false;  }  void DumpPhsRules(struct bcm_phs_extension *pDeviceExtension) @@ -1239,7 +1236,7 @@ void DumpPhsRules(struct bcm_phs_extension *pDeviceExtension)   *			header.   *	0	-If PHS rule is NULL.If PHSI is 0 indicateing packet as uncompressed.   */ -int phs_decompress(unsigned char *in_buf, +static int phs_decompress(unsigned char *in_buf,  		unsigned char *out_buf,  		struct bcm_phs_rule *decomp_phs_rules,  		UINT *header_size) @@ -1280,11 +1277,11 @@ int phs_decompress(unsigned char *in_buf,  		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", +			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", +			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++; diff --git a/drivers/staging/bcm/PHSModule.h b/drivers/staging/bcm/PHSModule.h index 82d86828418..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); @@ -39,7 +39,7 @@ ULONG PhsDeleteClassifierRule(void* pvContext, B_UINT16 uiVcid ,B_UINT16  uiClsI  ULONG PhsDeleteSFRules(void* pvContext,B_UINT16 uiVcid) ; -BOOLEAN ValidatePHSRule(struct bcm_phs_rule *psPhsRule); +bool ValidatePHSRule(struct bcm_phs_rule *psPhsRule);  UINT GetServiceFlowEntry(struct bcm_phs_table *psServiceFlowTable,B_UINT16 uiVcid, struct bcm_phs_entry **ppstServiceFlowEntry); diff --git a/drivers/staging/bcm/Prototypes.h b/drivers/staging/bcm/Prototypes.h index 2a673b125f0..fb53a00591e 100644 --- a/drivers/staging/bcm/Prototypes.h +++ b/drivers/staging/bcm/Prototypes.h @@ -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,13 +155,13 @@ 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, enum bcm_flash2x_section_val section); +bool IsSectionExistInFlash(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val section);  INT BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, struct bcm_flash2x_bitmap *psFlash2xBitMap); @@ -198,7 +198,7 @@ INT	BcmCopySection(struct bcm_mini_adapter *Adapter,  						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); @@ -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 2d4a77cca91..0c742da8c6b 100644 --- a/drivers/staging/bcm/Qos.c +++ b/drivers/staging/bcm/Qos.c @@ -4,11 +4,18 @@ This file contains the routines related to Quality of Service.  */  #include "headers.h" -static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter, PVOID pvEthPayload, struct bcm_eth_packet_info *pstEthCsPktInfo); -static BOOLEAN EThCSClassifyPkt(struct bcm_mini_adapter *Adapter, struct sk_buff* skb, struct bcm_eth_packet_info *pstEthCsPktInfo, struct bcm_classifier_rule *pstClassifierRule, B_UINT8 EthCSCupport); +static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter, +			    PVOID pvEthPayload, +			    struct bcm_eth_packet_info *pstEthCsPktInfo); -static USHORT	IpVersion4(struct bcm_mini_adapter *Adapter, struct iphdr *iphd, -			   struct bcm_classifier_rule *pstClassifierRule); +static bool EThCSClassifyPkt(struct bcm_mini_adapter *Adapter, +			     struct sk_buff *skb, +			     struct bcm_eth_packet_info *pstEthCsPktInfo, +			     struct bcm_classifier_rule *pstClassifierRule, +			     B_UINT8 EthCSCupport); + +static USHORT IpVersion4(struct bcm_mini_adapter *Adapter, struct iphdr *iphd, +			 struct bcm_classifier_rule *pstClassifierRule);  static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex); @@ -24,7 +31,7 @@ static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex);  *  * 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; @@ -33,17 +40,14 @@ BOOLEAN MatchSrcIpAddress(struct bcm_classifier_rule *pstClassifierRule, ULONG u  	ulSrcIP = ntohl(ulSrcIP);  	if (0 == pstClassifierRule->ucIPSourceAddressLength)  		return TRUE; -	for (ucLoopIndex = 0; ucLoopIndex < (pstClassifierRule->ucIPSourceAddressLength); ucLoopIndex++) -	{ +	for (ucLoopIndex = 0; ucLoopIndex < (pstClassifierRule->ucIPSourceAddressLength); ucLoopIndex++) {  		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Ip Address Mask:0x%x PacketIp:0x%x and Classification:0x%x", (UINT)pstClassifierRule->stSrcIpAddress.ulIpv4Mask[ucLoopIndex], (UINT)ulSrcIP, (UINT)pstClassifierRule->stSrcIpAddress.ulIpv6Addr[ucLoopIndex]);  		if ((pstClassifierRule->stSrcIpAddress.ulIpv4Mask[ucLoopIndex] & ulSrcIP) ==  				(pstClassifierRule->stSrcIpAddress.ulIpv4Addr[ucLoopIndex] & pstClassifierRule->stSrcIpAddress.ulIpv4Mask[ucLoopIndex])) -		{  			return TRUE; -		}  	}  	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Ip Address Not Matched"); -	return FALSE; +	return false;  } @@ -58,7 +62,7 @@ BOOLEAN MatchSrcIpAddress(struct bcm_classifier_rule *pstClassifierRule, ULONG u  *  * 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;  	struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); @@ -68,16 +72,13 @@ BOOLEAN MatchDestIpAddress(struct bcm_classifier_rule *pstClassifierRule, ULONG  		return TRUE;  	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Destination Ip Address 0x%x 0x%x 0x%x  ", (UINT)ulDestIP, (UINT)pstClassifierRule->stDestIpAddress.ulIpv4Mask[ucLoopIndex], (UINT)pstClassifierRule->stDestIpAddress.ulIpv4Addr[ucLoopIndex]); -	for (ucLoopIndex = 0; ucLoopIndex < (pstClassifierRule->ucIPDestinationAddressLength); ucLoopIndex++) -	{ +	for (ucLoopIndex = 0; ucLoopIndex < (pstClassifierRule->ucIPDestinationAddressLength); ucLoopIndex++) {  		if ((pstClassifierRule->stDestIpAddress.ulIpv4Mask[ucLoopIndex] & ulDestIP) ==  				(pstClassifierRule->stDestIpAddress.ulIpv4Addr[ucLoopIndex] & pstClassifierRule->stDestIpAddress.ulIpv4Mask[ucLoopIndex])) -		{  			return TRUE; -		}  	}  	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Destination Ip Address Not Matched"); -	return FALSE; +	return false;  } @@ -91,7 +92,7 @@ BOOLEAN MatchDestIpAddress(struct bcm_classifier_rule *pstClassifierRule, ULONG  *  * 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); @@ -99,11 +100,10 @@ BOOLEAN MatchTos(struct bcm_classifier_rule *pstClassifierRule, UCHAR ucTypeOfSe  		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; +	return false;  } @@ -123,16 +123,13 @@ bool MatchProtocol(struct bcm_classifier_rule *pstClassifierRule, UCHAR ucProtoc  	struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);  	if (0 == pstClassifierRule->ucProtocolLength)  		return TRUE; -	for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucProtocolLength; ucLoopIndex++) -	{ +	for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucProtocolLength; ucLoopIndex++) {  		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Protocol:0x%X Classification Protocol:0x%X", ucProtocol, pstClassifierRule->ucProtocol[ucLoopIndex]);  		if (pstClassifierRule->ucProtocol[ucLoopIndex] == ucProtocol) -		{  			return TRUE; -		}  	}  	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Protocol Not Matched"); -	return FALSE; +	return false;  } @@ -155,16 +152,13 @@ bool MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule, USHORT ushSrcPo  	if (0 == pstClassifierRule->ucSrcPortRangeLength)  		return TRUE; -	for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucSrcPortRangeLength; ucLoopIndex++) -	{ +	for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucSrcPortRangeLength; ucLoopIndex++) {  		if (ushSrcPort <= pstClassifierRule->usSrcPortRangeHi[ucLoopIndex] &&  			ushSrcPort >= pstClassifierRule->usSrcPortRangeLo[ucLoopIndex]) -		{  			return TRUE; -		}  	}  	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Port: %x Not Matched ", ushSrcPort); -	return FALSE; +	return false;  } @@ -186,18 +180,15 @@ bool MatchDestPort(struct bcm_classifier_rule *pstClassifierRule, USHORT ushDest  	if (0 == pstClassifierRule->ucDestPortRangeLength)  		return TRUE; -	for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucDestPortRangeLength; ucLoopIndex++) -	{ +	for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucDestPortRangeLength; ucLoopIndex++) {  		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Matching Port:0x%X   0x%X  0x%X", ushDestPort, pstClassifierRule->usDestPortRangeLo[ucLoopIndex], pstClassifierRule->usDestPortRangeHi[ucLoopIndex]);  		if (ushDestPort <= pstClassifierRule->usDestPortRangeHi[ucLoopIndex] &&  			ushDestPort >= pstClassifierRule->usDestPortRangeLo[ucLoopIndex]) -		{  			return TRUE; -		}  	}  	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Dest Port: %x Not Matched", ushDestPort); -	return FALSE; +	return false;  }  /**  @ingroup tx_functions @@ -209,7 +200,7 @@ static USHORT	IpVersion4(struct bcm_mini_adapter *Adapter,  			   struct bcm_classifier_rule *pstClassifierRule)  {  	struct bcm_transport_header *xprt_hdr = NULL; -	BOOLEAN	bClassificationSucceed = FALSE; +	bool	bClassificationSucceed = false;  	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "========>"); @@ -222,10 +213,7 @@ static USHORT	IpVersion4(struct bcm_mini_adapter *Adapter,  		//Checking classifier validity  		if (!pstClassifierRule->bUsed || pstClassifierRule->ucDirection == DOWNLINK_DIR) -		{ -			bClassificationSucceed = FALSE;  			break; -		}  		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "is IPv6 check!");  		if (pstClassifierRule->bIpv6Protocol) @@ -233,68 +221,56 @@ static USHORT	IpVersion4(struct bcm_mini_adapter *Adapter,  		//**************Checking IP header parameter**************************//  		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Trying to match Source IP Address"); -		if (FALSE == (bClassificationSucceed = -			MatchSrcIpAddress(pstClassifierRule, iphd->saddr))) +		if (!MatchSrcIpAddress(pstClassifierRule, iphd->saddr))  			break;  		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Source IP Address Matched"); -		if (FALSE == (bClassificationSucceed = -			MatchDestIpAddress(pstClassifierRule, iphd->daddr))) +		if (!MatchDestIpAddress(pstClassifierRule, iphd->daddr))  			break;  		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Destination IP Address Matched"); -		if (FALSE == (bClassificationSucceed = -			MatchTos(pstClassifierRule, iphd->tos))) -		{ +		if (!MatchTos(pstClassifierRule, iphd->tos)) {  			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "TOS Match failed\n");  			break;  		}  		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "TOS Matched"); -		if (FALSE == (bClassificationSucceed = -			MatchProtocol(pstClassifierRule, iphd->protocol))) +		if (!MatchProtocol(pstClassifierRule, iphd->protocol))  			break;  		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Protocol Matched");  		//if protocol is not TCP or UDP then no need of comparing source port and destination port -		if (iphd->protocol != TCP && iphd->protocol != UDP) +		if (iphd->protocol != TCP && iphd->protocol != UDP) { +			bClassificationSucceed = TRUE;  			break; +		}  		//******************Checking Transport Layer Header field if present *****************//  		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Source Port %04x",  			(iphd->protocol == UDP) ? xprt_hdr->uhdr.source : xprt_hdr->thdr.source); -		if (FALSE == (bClassificationSucceed = -			MatchSrcPort(pstClassifierRule, -				ntohs((iphd->protocol == UDP) ? -				xprt_hdr->uhdr.source : xprt_hdr->thdr.source)))) +		if (!MatchSrcPort(pstClassifierRule, +				  ntohs((iphd->protocol == UDP) ? +				  xprt_hdr->uhdr.source : xprt_hdr->thdr.source)))  			break;  		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Port Matched");  		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Destination Port %04x",  			(iphd->protocol == UDP) ? xprt_hdr->uhdr.dest :  			xprt_hdr->thdr.dest); -		if (FALSE == (bClassificationSucceed = -			MatchDestPort(pstClassifierRule, -			ntohs((iphd->protocol == UDP) ? -			xprt_hdr->uhdr.dest : xprt_hdr->thdr.dest)))) +		if (!MatchDestPort(pstClassifierRule, +				   ntohs((iphd->protocol == UDP) ? +				   xprt_hdr->uhdr.dest : xprt_hdr->thdr.dest)))  			break; +		bClassificationSucceed = TRUE;  	} while (0); -	if (TRUE == bClassificationSucceed) -	{ +	if (TRUE == bClassificationSucceed) {  		INT iMatchedSFQueueIndex = 0;  		iMatchedSFQueueIndex = SearchSfid(Adapter, pstClassifierRule->ulSFID);  		if (iMatchedSFQueueIndex >= NO_OF_QUEUES) -		{ -			bClassificationSucceed = FALSE; -		} -		else -		{ -			if (FALSE == Adapter->PackInfo[iMatchedSFQueueIndex].bActive) -			{ -				bClassificationSucceed = FALSE; -			} -		} +			bClassificationSucceed = false; +		else if (false == Adapter->PackInfo[iMatchedSFQueueIndex].bActive) +			bClassificationSucceed = false;  	}  	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "IpVersion4 <=========="); @@ -306,8 +282,7 @@ VOID PruneQueueAllSF(struct bcm_mini_adapter *Adapter)  {  	UINT iIndex = 0; -	for (iIndex = 0; iIndex < HiPriority; iIndex++) -	{ +	for (iIndex = 0; iIndex < HiPriority; iIndex++) {  		if (!Adapter->PackInfo[iIndex].bValid)  			continue; @@ -341,10 +316,10 @@ static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex)  	spin_lock_bh(&Adapter->PackInfo[iIndex].SFQueueLock); -	while (1) +	while (1) {  //	while((UINT)Adapter->PackInfo[iIndex].uiCurrentPacketsOnHost > -//		SF_MAX_ALLOWED_PACKETS_TO_BACKUP) -	{ +//		SF_MAX_ALLOWED_PACKETS_TO_BACKUP) { +  		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "uiCurrentBytesOnHost:%x uiMaxBucketSize :%x",  		Adapter->PackInfo[iIndex].uiCurrentBytesOnHost,  		Adapter->PackInfo[iIndex].uiMaxBucketSize); @@ -357,8 +332,7 @@ static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex)  			((1000*(jiffies - *((B_UINT32 *)(PacketToDrop->cb)+SKB_CB_LATENCY_OFFSET))/HZ) <= Adapter->PackInfo[iIndex].uiMaxLatency))  			break; -		if (PacketToDrop) -		{ +		if (PacketToDrop) {  			if (netif_msg_tx_err(Adapter))  				pr_info(PFX "%s: tx queue %d overlimit\n",  					Adapter->dev->name, iIndex); @@ -401,20 +375,16 @@ VOID flush_all_queues(struct bcm_mini_adapter *Adapter)  	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "=====>");  //	down(&Adapter->data_packet_queue_lock); -	for (iQIndex = LowPriority; iQIndex < HiPriority; iQIndex++) -	{ +	for (iQIndex = LowPriority; iQIndex < HiPriority; iQIndex++) {  		struct net_device_stats *netstats = &Adapter->dev->stats;  		spin_lock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock); -		while (Adapter->PackInfo[iQIndex].FirstTxQueue) -		{ +		while (Adapter->PackInfo[iQIndex].FirstTxQueue) {  			PacketToDrop = Adapter->PackInfo[iQIndex].FirstTxQueue; -			if (PacketToDrop) -			{ +			if (PacketToDrop) {  				uiTotalPacketLength = PacketToDrop->len;  				netstats->tx_dropped++; -			} -			else +			} else  				uiTotalPacketLength = 0;  			DEQUEUEPACKET(Adapter->PackInfo[iQIndex].FirstTxQueue, @@ -451,7 +421,7 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb)  	struct iphdr *pIpHeader = NULL;  	INT	  uiSfIndex = 0;  	USHORT	usIndex = Adapter->usBestEffortQueueIndex; -	BOOLEAN	bFragmentedPkt = FALSE, bClassificationSucceed = FALSE; +	bool	bFragmentedPkt = false, bClassificationSucceed = false;  	USHORT	usCurrFragment = 0;  	struct bcm_tcp_header *pTcpHeader; @@ -462,58 +432,42 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb)  	*((UINT32*) (skb->cb) +SKB_CB_TCPACK_OFFSET) = 0;  	EThCSGetPktInfo(Adapter, pvEThPayload, &stEthCsPktInfo); -	switch (stEthCsPktInfo.eNwpktEthFrameType) -	{ +	switch (stEthCsPktInfo.eNwpktEthFrameType) {  		case eEth802LLCFrame: -		{  			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : 802LLCFrame\n");  			pIpHeader = pvEThPayload + sizeof(struct bcm_eth_llc_frame);  			break; -		} -  		case eEth802LLCSNAPFrame: -		{  			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : 802LLC SNAP Frame\n");  			pIpHeader = pvEThPayload + sizeof(struct bcm_eth_llc_snap_frame);  			break; -		}  		case eEth802QVLANFrame: -		{  			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : 802.1Q VLANFrame\n");  			pIpHeader = pvEThPayload + sizeof(struct bcm_eth_q_frame);  			break; -		}  		case eEthOtherFrame: -		{  			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : ETH Other Frame\n");  			pIpHeader = pvEThPayload + sizeof(struct bcm_ethernet2_frame);  			break; -		}  		default: -		{  			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : Unrecognized ETH Frame\n");  			pIpHeader = pvEThPayload + sizeof(struct bcm_ethernet2_frame);  			break; -		}  	} -	if (stEthCsPktInfo.eNwpktIPFrameType == eIPv4Packet) -	{ +	if (stEthCsPktInfo.eNwpktIPFrameType == eIPv4Packet) {  		usCurrFragment = (ntohs(pIpHeader->frag_off) & IP_OFFSET);  		if ((ntohs(pIpHeader->frag_off) & IP_MF) || usCurrFragment)  			bFragmentedPkt = TRUE; -		if (bFragmentedPkt) -		{ +		if (bFragmentedPkt) {  				//Fragmented  Packet. Get Frag Classifier Entry.  			pstClassifierRule = GetFragIPClsEntry(Adapter, pIpHeader->id, pIpHeader->saddr); -			if (pstClassifierRule) -			{ +			if (pstClassifierRule) {  					BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "It is next Fragmented pkt");  					bClassificationSucceed = TRUE;  			} -			if (!(ntohs(pIpHeader->frag_off) & IP_MF)) -			{ +			if (!(ntohs(pIpHeader->frag_off) & IP_MF)) {  				//Fragmented Last packet . Remove Frag Classifier Entry  				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "This is the last fragmented Pkt");  				DelFragIPClsEntry(Adapter, pIpHeader->id, pIpHeader->saddr); @@ -521,24 +475,20 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb)  		}  	} -	for (uiLoopIndex = MAX_CLASSIFIERS - 1; uiLoopIndex >= 0; uiLoopIndex--) -	{ +	for (uiLoopIndex = MAX_CLASSIFIERS - 1; uiLoopIndex >= 0; uiLoopIndex--) {  		if (bClassificationSucceed)  			break;  		//Iterate through all classifiers which are already in order of priority  		//to classify the packet until match found -		do -		{ -			if (FALSE == Adapter->astClassifierTable[uiLoopIndex].bUsed) -			{ -				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); -			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  			} @@ -550,13 +500,11 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb)  				break;  			} -			if (Adapter->PackInfo[uiSfIndex].bEthCSSupport) -			{ +			if (Adapter->PackInfo[uiSfIndex].bEthCSSupport) { -				if (eEthUnsupportedFrame == stEthCsPktInfo.eNwpktEthFrameType) -				{ +				if (eEthUnsupportedFrame == stEthCsPktInfo.eNwpktEthFrameType) {  					BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, " ClassifyPacket : Packet Not a Valid Supported Ethernet Frame\n"); -					bClassificationSucceed = FALSE; +					bClassificationSucceed = false;  					break;  				} @@ -565,32 +513,25 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb)  				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,  "Performing ETH CS Classification on Classifier Rule ID : %x Service Flow ID : %lx\n", pstClassifierRule->uiClassifierRuleIndex, Adapter->PackInfo[uiSfIndex].ulSFID);  				bClassificationSucceed = EThCSClassifyPkt(Adapter, skb, &stEthCsPktInfo, pstClassifierRule, Adapter->PackInfo[uiSfIndex].bEthCSSupport); -				if (!bClassificationSucceed) -				{ +				if (!bClassificationSucceed) {  					BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,  "ClassifyPacket : Ethernet CS Classification Failed\n");  					break;  				} -			} - -			else // No ETH Supported on this SF -			{ -				if (eEthOtherFrame != stEthCsPktInfo.eNwpktEthFrameType) -				{ +			} else {	// No ETH Supported on this SF +				if (eEthOtherFrame != stEthCsPktInfo.eNwpktEthFrameType) {  					BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, " ClassifyPacket : Packet Not a 802.3 Ethernet Frame... hence not allowed over non-ETH CS SF\n"); -					bClassificationSucceed = FALSE; +					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) -				{ +				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; +					bClassificationSucceed = false;  					break;  				}  				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Dump IP Header :\n"); @@ -605,38 +546,33 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb)  		} while (0);  	} -	if (bClassificationSucceed == TRUE) -	{ +	if (bClassificationSucceed == TRUE) {  		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "CF id : %d, SF ID is =%lu", pstClassifierRule->uiClassifierRuleIndex, pstClassifierRule->ulSFID);  		//Store The matched Classifier in SKB  		*((UINT32*)(skb->cb)+SKB_CB_CLASSIFICATION_OFFSET) = pstClassifierRule->uiClassifierRuleIndex; -		if ((TCP == pIpHeader->protocol) && !bFragmentedPkt && (ETH_AND_IP_HEADER_LEN + TCP_HEADER_LEN <= skb->len)) -		{ +		if ((TCP == pIpHeader->protocol) && !bFragmentedPkt && (ETH_AND_IP_HEADER_LEN + TCP_HEADER_LEN <= skb->len)) {  			 IpHeaderLength   = pIpHeader->ihl;  			 pTcpHeader = (struct bcm_tcp_header *)(((PUCHAR)pIpHeader)+(IpHeaderLength*4));  			 TcpHeaderLength  = GET_TCP_HEADER_LEN(pTcpHeader->HeaderLength);  			if ((pTcpHeader->ucFlags & TCP_ACK) &&  			   (ntohs(pIpHeader->tot_len) == (IpHeaderLength*4)+(TcpHeaderLength*4))) -			{  				*((UINT32*) (skb->cb) + SKB_CB_TCPACK_OFFSET) = TCP_ACK; -			}  		}  		usIndex = SearchSfid(Adapter, pstClassifierRule->ulSFID);  		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "index is	=%d", usIndex);  		//If this is the first fragment of a Fragmented pkt, add this CF. Only This CF should be used for all other fragment of this Pkt. -		if (bFragmentedPkt && (usCurrFragment == 0)) -		{ +		if (bFragmentedPkt && (usCurrFragment == 0)) {  			//First Fragment of Fragmented Packet. Create Frag CLS Entry  			struct bcm_fragmented_packet_info stFragPktInfo;  			stFragPktInfo.bUsed = TRUE;  			stFragPktInfo.ulSrcIpAddress = pIpHeader->saddr;  			stFragPktInfo.usIpIdentification = pIpHeader->id;  			stFragPktInfo.pstMatchedClassifierEntry = pstClassifierRule; -			stFragPktInfo.bOutOfOrderFragment = FALSE; +			stFragPktInfo.bOutOfOrderFragment = false;  			AddFragIPClsEntry(Adapter, &stFragPktInfo);  		} @@ -649,89 +585,84 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb)  		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;  	struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);  	if (pstClassifierRule->ucEthCSSrcMACLen == 0)  		return TRUE; -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,  "%s\n", __FUNCTION__); -	for (i = 0; i < MAC_ADDRESS_SIZE; i++) -	{ +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,  "%s\n", __func__); +	for (i = 0; i < MAC_ADDRESS_SIZE; i++) {  		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,  "SRC MAC[%x] = %x ClassifierRuleSrcMAC = %x Mask : %x\n", i, Mac[i], pstClassifierRule->au8EThCSSrcMAC[i], pstClassifierRule->au8EThCSSrcMACMask[i]);  		if ((pstClassifierRule->au8EThCSSrcMAC[i] & pstClassifierRule->au8EThCSSrcMACMask[i]) !=  			(Mac[i] & pstClassifierRule->au8EThCSSrcMACMask[i])) -			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;  	struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);  	if (pstClassifierRule->ucEthCSDestMACLen == 0)  		return TRUE; -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s\n", __FUNCTION__); -	for (i = 0; i < MAC_ADDRESS_SIZE; i++) -	{ +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s\n", __func__); +	for (i = 0; i < MAC_ADDRESS_SIZE; i++) {  		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "SRC MAC[%x] = %x ClassifierRuleSrcMAC = %x Mask : %x\n", i, Mac[i], pstClassifierRule->au8EThCSDestMAC[i], pstClassifierRule->au8EThCSDestMACMask[i]);  		if ((pstClassifierRule->au8EThCSDestMAC[i] & pstClassifierRule->au8EThCSDestMACMask[i]) !=  			(Mac[i] & pstClassifierRule->au8EThCSDestMACMask[i])) -			return FALSE; +			return false;  	}  	return TRUE;  } -static BOOLEAN EthCSMatchEThTypeSAP(struct bcm_classifier_rule *pstClassifierRule, struct sk_buff* skb, struct bcm_eth_packet_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) ||  		(pstClassifierRule->au8EthCSEtherType[0] == 0))  		return TRUE; -	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,  "%s SrcEtherType:%x CLS EtherType[0]:%x\n", __FUNCTION__, pstEthCsPktInfo->usEtherType, pstClassifierRule->au8EthCSEtherType[0]); -	if (pstClassifierRule->au8EthCSEtherType[0] == 1) -	{ -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,  "%s  CLS EtherType[1]:%x EtherType[2]:%x\n", __FUNCTION__, pstClassifierRule->au8EthCSEtherType[1], pstClassifierRule->au8EthCSEtherType[2]); +	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,  "%s SrcEtherType:%x CLS EtherType[0]:%x\n", __func__, pstEthCsPktInfo->usEtherType, pstClassifierRule->au8EthCSEtherType[0]); +	if (pstClassifierRule->au8EthCSEtherType[0] == 1) { +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,  "%s  CLS EtherType[1]:%x EtherType[2]:%x\n", __func__, pstClassifierRule->au8EthCSEtherType[1], pstClassifierRule->au8EthCSEtherType[2]);  		if (memcmp(&pstEthCsPktInfo->usEtherType, &pstClassifierRule->au8EthCSEtherType[1], 2) == 0)  			return TRUE;  		else -			return FALSE; +			return false;  	} -	if (pstClassifierRule->au8EthCSEtherType[0] == 2) -	{ +	if (pstClassifierRule->au8EthCSEtherType[0] == 2) {  		if (eEth802LLCFrame != pstEthCsPktInfo->eNwpktEthFrameType) -			return FALSE; +			return false; -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,  "%s  EthCS DSAP:%x EtherType[2]:%x\n", __FUNCTION__, pstEthCsPktInfo->ucDSAP, pstClassifierRule->au8EthCSEtherType[2]); +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,  "%s  EthCS DSAP:%x EtherType[2]:%x\n", __func__, pstEthCsPktInfo->ucDSAP, pstClassifierRule->au8EthCSEtherType[2]);  		if (pstEthCsPktInfo->ucDSAP == pstClassifierRule->au8EthCSEtherType[2])  			return TRUE;  		else -			return FALSE; +			return false;  	} -	return FALSE; +	return false;  } -static BOOLEAN EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule, struct sk_buff* skb, struct bcm_eth_packet_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 (pstClassifierRule->usValidityBitMap & (1<<PKT_CLASSIFICATION_USER_PRIORITY_VALID)) {  		if (pstEthCsPktInfo->eNwpktEthFrameType != eEth802QVLANFrame) -				return FALSE; +				return false;  		uPriority = (ntohs(*(USHORT *)(skb->data + sizeof(struct bcm_eth_header))) & 0xF000) >> 13; @@ -739,27 +670,26 @@ static BOOLEAN EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule  				bClassificationSucceed = TRUE;  		if (!bClassificationSucceed) -			return FALSE; +			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 (pstClassifierRule->usValidityBitMap & (1<<PKT_CLASSIFICATION_VLANID_VALID)) {  		if (pstEthCsPktInfo->eNwpktEthFrameType != eEth802QVLANFrame) -				return FALSE; +				return false;  		usVLANID = ntohs(*(USHORT *)(skb->data + sizeof(struct bcm_eth_header))) & 0xFFF; -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,  "%s  Pkt VLANID %x Priority: %d\n", __FUNCTION__, usVLANID, uPriority); +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,  "%s  Pkt VLANID %x Priority: %d\n", __func__, usVLANID, uPriority);  		if (usVLANID == ((pstClassifierRule->usVLANID & 0xFFF0) >> 4))  			bClassificationSucceed = TRUE;  		if (!bClassificationSucceed) -			return FALSE; +			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,26 +698,26 @@ static BOOLEAN EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule  } -static BOOLEAN EThCSClassifyPkt(struct bcm_mini_adapter *Adapter, struct sk_buff* skb, +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; +	bool bClassificationSucceed = false;  	bClassificationSucceed = EthCSMatchSrcMACAddress(pstClassifierRule, ((struct bcm_eth_header *)(skb->data))->au8SourceAddress);  	if (!bClassificationSucceed) -		return FALSE; +		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; +		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; +		return false;  	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,  "ETH CS EthType/802.2SAP Matched\n"); @@ -795,7 +725,7 @@ static BOOLEAN EThCSClassifyPkt(struct bcm_mini_adapter *Adapter, struct sk_buff  	bClassificationSucceed = EthCSMatchVLANRules(pstClassifierRule, skb, pstEthCsPktInfo);  	if (!bClassificationSucceed) -		return FALSE; +		return false;  	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,  "ETH CS 802.1 VLAN Rules Matched\n");  	return bClassificationSucceed; @@ -807,32 +737,24 @@ static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter, PVOID pvEthPayload  	USHORT u16Etype = ntohs(((struct bcm_eth_header *)pvEthPayload)->u16Etype);  	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,  "EthCSGetPktInfo : Eth Hdr Type : %X\n", u16Etype); -	if (u16Etype > 0x5dc) -	{ +	if (u16Etype > 0x5dc) {  		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCSGetPktInfo : ETH2 Frame\n");  		//ETH2 Frame -		if (u16Etype == ETHERNET_FRAMETYPE_802QVLAN) -		{ +		if (u16Etype == ETHERNET_FRAMETYPE_802QVLAN) {  			//802.1Q VLAN Header  			pstEthCsPktInfo->eNwpktEthFrameType = eEth802QVLANFrame;  			u16Etype = ((struct bcm_eth_q_frame *)pvEthPayload)->EthType;  			//((ETH_CS_802_Q_FRAME*)pvEthPayload)->UserPriority -		} -		else -		{ +		} else {  			pstEthCsPktInfo->eNwpktEthFrameType = eEthOtherFrame;  			u16Etype = ntohs(u16Etype);  		} - -	} -	else -	{ +	} else {  		//802.2 LLC  		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "802.2 LLC Frame\n");  		pstEthCsPktInfo->eNwpktEthFrameType = eEth802LLCFrame;  		pstEthCsPktInfo->ucDSAP = ((struct bcm_eth_llc_frame *)pvEthPayload)->DSAP; -		if (pstEthCsPktInfo->ucDSAP == 0xAA && ((struct bcm_eth_llc_frame *)pvEthPayload)->SSAP == 0xAA) -		{ +		if (pstEthCsPktInfo->ucDSAP == 0xAA && ((struct bcm_eth_llc_frame *)pvEthPayload)->SSAP == 0xAA) {  			//SNAP Frame  			pstEthCsPktInfo->eNwpktEthFrameType = eEth802LLCSNAPFrame;  			u16Etype = ((struct bcm_eth_llc_snap_frame *)pvEthPayload)->usEtherType; diff --git a/drivers/staging/bcm/Transmit.c b/drivers/staging/bcm/Transmit.c index f8dc3e20b47..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,7 +207,7 @@ 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; +			Adapter->bEndPointHalted = false;  			StartInterruptUrb((struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter));  		} @@ -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/headers.h b/drivers/staging/bcm/headers.h index 7fd21c6923c..6f3270cc417 100644 --- a/drivers/staging/bcm/headers.h +++ b/drivers/staging/bcm/headers.h @@ -34,7 +34,7 @@  #include <linux/tcp.h>  #include <linux/udp.h>  #include <linux/usb.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h>  #include <net/ip.h>  #include "Typedefs.h" diff --git a/drivers/staging/bcm/hostmibs.c b/drivers/staging/bcm/hostmibs.c index f55300db1d4..42d9004e357 100644 --- a/drivers/staging/bcm/hostmibs.c +++ b/drivers/staging/bcm/hostmibs.c @@ -9,37 +9,40 @@  #include "headers.h" -INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, struct bcm_host_stats_mibs *pstHostMibs) +INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, +		       struct bcm_host_stats_mibs *pstHostMibs)  {  	struct bcm_phs_entry *pstServiceFlowEntry = NULL;  	struct bcm_phs_rule *pstPhsRule = NULL;  	struct bcm_phs_classifier_table *pstClassifierTable = NULL;  	struct bcm_phs_classifier_entry *pstClassifierRule = NULL; -	struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *) &Adapter->stBCMPhsContext; - -	UINT nClassifierIndex = 0, nPhsTableIndex = 0, nSfIndex = 0, uiIndex = 0; +	struct bcm_phs_extension *pDeviceExtension = &Adapter->stBCMPhsContext; +	UINT nClassifierIndex = 0; +	UINT nPhsTableIndex = 0; +	UINT nSfIndex = 0; +	UINT uiIndex = 0;  	if (pDeviceExtension == NULL) { -		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, HOST_MIBS, DBG_LVL_ALL, "Invalid Device Extension\n"); +		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, HOST_MIBS, +				DBG_LVL_ALL, "Invalid Device Extension\n");  		return STATUS_FAILURE;  	}  	/* Copy the classifier Table */ -	for (nClassifierIndex = 0; nClassifierIndex < MAX_CLASSIFIERS; nClassifierIndex++) { +	for (nClassifierIndex = 0; nClassifierIndex < MAX_CLASSIFIERS; +							nClassifierIndex++) {  		if (Adapter->astClassifierTable[nClassifierIndex].bUsed == TRUE) -			memcpy((PVOID) & pstHostMibs-> -			       astClassifierTable[nClassifierIndex], -			       (PVOID) & Adapter-> -			       astClassifierTable[nClassifierIndex], +			memcpy(&pstHostMibs->astClassifierTable[nClassifierIndex], +			       &Adapter->astClassifierTable[nClassifierIndex],  			       sizeof(struct bcm_mibs_classifier_rule));  	}  	/* Copy the SF Table */  	for (nSfIndex = 0; nSfIndex < NO_OF_QUEUES; nSfIndex++) {  		if (Adapter->PackInfo[nSfIndex].bValid) { -			memcpy((PVOID) & pstHostMibs->astSFtable[nSfIndex], -			       (PVOID) & Adapter->PackInfo[nSfIndex], -				sizeof(struct bcm_mibs_table)); +			memcpy(&pstHostMibs->astSFtable[nSfIndex], +			       &Adapter->PackInfo[nSfIndex], +			       sizeof(struct bcm_mibs_table));  		} else {  			/* If index in not valid,  			 * don't process this for the PHS table. @@ -68,9 +71,9 @@ INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, struct bcm_host_stats_m  				pstHostMibs->astPhsRulesTable[nPhsTableIndex].  				    ulSFID = Adapter->PackInfo[nSfIndex].ulSFID; -				memcpy(&pstHostMibs-> -				       astPhsRulesTable[nPhsTableIndex].u8PHSI, -				       &pstPhsRule->u8PHSI, sizeof(struct bcm_phs_rule)); +				memcpy(&pstHostMibs->astPhsRulesTable[nPhsTableIndex].u8PHSI, +				       &pstPhsRule->u8PHSI, +				       sizeof(struct bcm_phs_rule));  				nPhsTableIndex++;  			} @@ -82,26 +85,32 @@ INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, struct bcm_host_stats_m  	/* Copy other Host Statistics parameters */  	pstHostMibs->stHostInfo.GoodTransmits = Adapter->dev->stats.tx_packets;  	pstHostMibs->stHostInfo.GoodReceives = Adapter->dev->stats.rx_packets; -	pstHostMibs->stHostInfo.CurrNumFreeDesc = atomic_read(&Adapter->CurrNumFreeTxDesc); +	pstHostMibs->stHostInfo.CurrNumFreeDesc = +				atomic_read(&Adapter->CurrNumFreeTxDesc);  	pstHostMibs->stHostInfo.BEBucketSize = Adapter->BEBucketSize;  	pstHostMibs->stHostInfo.rtPSBucketSize = Adapter->rtPSBucketSize;  	pstHostMibs->stHostInfo.TimerActive = Adapter->TimerActive;  	pstHostMibs->stHostInfo.u32TotalDSD = Adapter->u32TotalDSD; -	memcpy(pstHostMibs->stHostInfo.aTxPktSizeHist, Adapter->aTxPktSizeHist, sizeof(UINT32) * MIBS_MAX_HIST_ENTRIES); -	memcpy(pstHostMibs->stHostInfo.aRxPktSizeHist, Adapter->aRxPktSizeHist, sizeof(UINT32) * MIBS_MAX_HIST_ENTRIES); +	memcpy(pstHostMibs->stHostInfo.aTxPktSizeHist, Adapter->aTxPktSizeHist, +	       sizeof(UINT32) * MIBS_MAX_HIST_ENTRIES); +	memcpy(pstHostMibs->stHostInfo.aRxPktSizeHist, Adapter->aRxPktSizeHist, +	       sizeof(UINT32) * MIBS_MAX_HIST_ENTRIES);  	return STATUS_SUCCESS;  } -VOID GetDroppedAppCntrlPktMibs(struct bcm_host_stats_mibs *pstHostMibs, struct bcm_tarang_data *pTarang) +VOID GetDroppedAppCntrlPktMibs(struct bcm_host_stats_mibs *pstHostMibs, +			       struct bcm_tarang_data *pTarang)  {  	memcpy(&(pstHostMibs->stDroppedAppCntrlMsgs),  	       &(pTarang->stDroppedAppCntrlMsgs),  	       sizeof(struct bcm_mibs_dropped_cntrl_msg));  } -VOID CopyMIBSExtendedSFParameters(struct bcm_mini_adapter *Adapter, struct bcm_connect_mgr_params *psfLocalSet, UINT uiSearchRuleIndex) +VOID CopyMIBSExtendedSFParameters(struct bcm_mini_adapter *Adapter, +				  struct bcm_connect_mgr_params *psfLocalSet, +				  UINT uiSearchRuleIndex)  {  	struct bcm_mibs_parameters *t = &Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable; diff --git a/drivers/staging/bcm/led_control.c b/drivers/staging/bcm/led_control.c index 05a948a3698..eee4f4795a7 100644 --- a/drivers/staging/bcm/led_control.c +++ b/drivers/staging/bcm/led_control.c @@ -13,12 +13,12 @@ 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;  } @@ -27,7 +27,7 @@ static INT LED_Blink(struct bcm_mini_adapter *Adapter, UINT GPIO_Num, UCHAR uiLe  		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; @@ -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,7 +602,7 @@ 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, @@ -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/nvm.c b/drivers/staging/bcm/nvm.c index 91a5715964b..63be3be62eb 100644 --- a/drivers/staging/bcm/nvm.c +++ b/drivers/staging/bcm/nvm.c @@ -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) @@ -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; @@ -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; @@ -2685,12 +2624,12 @@ int BcmGetSectionValStartOffset(struct bcm_mini_adapter *Adapter, enum bcm_flash  	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: @@ -2759,7 +2698,7 @@ int BcmGetSectionValStartOffset(struct bcm_mini_adapter *Adapter, enum bcm_flash   * On Failure -returns STATUS_FAILURE   */ -int BcmGetSectionValEndOffset(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectionVal) +static int BcmGetSectionValEndOffset(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectionVal)  {  	int SectEndOffset = 0; @@ -2770,12 +2709,12 @@ int BcmGetSectionValEndOffset(struct bcm_mini_adapter *Adapter, enum bcm_flash2x  	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: @@ -2831,7 +2770,7 @@ int BcmGetSectionValEndOffset(struct bcm_mini_adapter *Adapter, enum bcm_flash2x  		SectEndOffset = INVALID_OFFSET;  	} -	return SectEndOffset ; +	return SectEndOffset;  }  /* @@ -2873,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;  	} @@ -2936,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;  	} @@ -3037,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; @@ -3062,7 +3001,7 @@ 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(struct bcm_flash2x_bitmap *psFlash2xBitMap) @@ -3105,13 +3044,13 @@ int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, struct bcm_fl  	struct bcm_flash2x_cs_info *psFlash2xCSInfo = Adapter->psFlash2xCSInfo;  	enum bcm_flash2x_section_val uiHighestPriDSD = 0;  	enum bcm_flash2x_section_val uiHighestPriISO = 0; -	BOOLEAN SetActiveDSDDone = FALSE; -	BOOLEAN SetActiveISODone = FALSE; +	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) */ @@ -3143,10 +3082,10 @@ int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, struct bcm_fl  			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;  		} @@ -3163,10 +3102,10 @@ int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, struct bcm_fl  			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;  		} @@ -3183,11 +3122,11 @@ int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, struct bcm_fl  			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;  			} @@ -3205,11 +3144,11 @@ int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, struct bcm_fl  			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;  			} @@ -3227,11 +3166,11 @@ int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, struct bcm_fl  			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;  			} @@ -3249,7 +3188,7 @@ int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, struct bcm_fl  		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 */ @@ -3267,7 +3206,7 @@ int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, struct bcm_fl  		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 */ @@ -3285,7 +3224,7 @@ int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, struct bcm_fl  		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 */ @@ -3303,7 +3242,7 @@ int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, struct bcm_fl  		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 */ @@ -3321,7 +3260,7 @@ int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, struct bcm_fl  		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 */ @@ -3358,7 +3297,7 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_secti  	/* 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); @@ -3435,7 +3374,7 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_secti  	case DSD2:  		if (ReadDSDSignature(Adapter, eFlash2xSectVal) == DSD_IMAGE_MAGIC_NUMBER) {  			HighestPriDSD = getHighestPriDSD(Adapter); -			if ((HighestPriDSD == eFlash2xSectVal)) { +			if (HighestPriDSD == eFlash2xSectVal) {  				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Given DSD<%x> already has highest priority", eFlash2xSectVal);  				Status = STATUS_SUCCESS;  				break; @@ -3463,7 +3402,7 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_secti  				HighestPriDSD = getHighestPriDSD(Adapter); -				if ((HighestPriDSD == eFlash2xSectVal)) { +				if (HighestPriDSD == eFlash2xSectVal) {  					BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Made the DSD: %x highest by reducing priority of other\n", eFlash2xSectVal);  					Status = STATUS_SUCCESS;  					break; @@ -3482,7 +3421,7 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_secti  				}  				HighestPriDSD = getHighestPriDSD(Adapter); -				if ((HighestPriDSD == eFlash2xSectVal)) { +				if (HighestPriDSD == eFlash2xSectVal) {  					Status = STATUS_SUCCESS;  					break;  				} @@ -3517,7 +3456,7 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_secti  		break;  	} -	Adapter->bHeaderChangeAllowed = FALSE; +	Adapter->bHeaderChangeAllowed = false;  	return Status;  } @@ -3536,7 +3475,7 @@ int BcmCopyISO(struct bcm_mini_adapter *Adapter, struct bcm_flash2x_copy_section  	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; @@ -3669,14 +3608,14 @@ int BcmCopyISO(struct bcm_mini_adapter *Adapter, struct bcm_flash2x_copy_section  				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; @@ -3782,7 +3721,7 @@ int BcmCopyISO(struct bcm_mini_adapter *Adapter, struct bcm_flash2x_copy_section  				break;  			} -			Adapter->bHeaderChangeAllowed = FALSE; +			Adapter->bHeaderChangeAllowed = false;  			if (IsThisHeaderSector == TRUE) {  				WriteToFlashWithoutSectorErase(Adapter,  							SigBuff, @@ -3790,7 +3729,7 @@ int BcmCopyISO(struct bcm_mini_adapter *Adapter, struct bcm_flash2x_copy_section  							sigOffset,  							MAX_RW_SIZE); -				IsThisHeaderSector = FALSE; +				IsThisHeaderSector = false;  			}  			/* subtracting the written Data */ @@ -3848,13 +3787,13 @@ int BcmFlash2xWriteSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_sectio  	unsigned int uiOffset = 0;  	/* struct bcm_dsd_header dsdHeader = {0}; */ -	if (Adapter->bSigCorrupted == FALSE) { +	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;  		} @@ -3886,9 +3825,9 @@ int BcmFlash2xWriteSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_sectio  	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;  } @@ -3899,7 +3838,7 @@ int BcmFlash2xWriteSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_sectio   * @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, struct bcm_flash2x_readwrite *psFlash2xReadWrite) @@ -3911,8 +3850,8 @@ int validateFlash2xReadWrite(struct bcm_mini_adapter *Adapter, struct bcm_flash2  	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); @@ -3944,12 +3883,21 @@ int validateFlash2xReadWrite(struct bcm_mini_adapter *Adapter, struct bcm_flash2  	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;  	}  } @@ -3966,7 +3914,7 @@ int IsFlash2x(struct bcm_mini_adapter *Adapter)  	if (Adapter->uiFlashLayoutMajorVersion >= FLASH_2X_MAJOR_NUMBER)  		return TRUE;  	else -		return FALSE; +		return false;  }  /* @@ -3986,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 @@ -3996,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 @@ -4094,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; @@ -4110,7 +4058,7 @@ int BcmCopySection(struct bcm_mini_adapter *Adapter,  	} while (numOfBytes > 0);  	kfree(pBuff); -	Adapter->bHeaderChangeAllowed = FALSE; +	Adapter->bHeaderChangeAllowed = false;  	return Status;  } @@ -4126,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; @@ -4153,7 +4101,7 @@ int SaveHeaderIfPresent(struct bcm_mini_adapter *Adapter, PUCHAR pBuff, unsigned  		bHasHeader = TRUE;  	}  	/* If Header is present overwrite passed buffer with this */ -	if (bHasHeader && (Adapter->bHeaderChangeAllowed == FALSE)) { +	if (bHasHeader && (Adapter->bHeaderChangeAllowed == false)) {  		pTempBuff = kzalloc(HeaderSizeToProtect, GFP_KERNEL);  		if (!pTempBuff) {  			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Memory allocation failed"); @@ -4172,13 +4120,13 @@ int SaveHeaderIfPresent(struct bcm_mini_adapter *Adapter, PUCHAR pBuff, unsigned  		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(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; @@ -4265,7 +4213,7 @@ static int BcmDoChipSelect(struct bcm_mini_adapter *Adapter, unsigned int offset  	return STATUS_SUCCESS;  } -int ReadDSDSignature(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val dsd) +static int ReadDSDSignature(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val dsd)  {  	unsigned int uiDSDsig = 0;  	/* unsigned int sigoffsetInMap = 0; @@ -4290,7 +4238,7 @@ int ReadDSDSignature(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_  	return uiDSDsig;  } -int ReadDSDPriority(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val dsd) +static int ReadDSDPriority(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val dsd)  {  	/* unsigned int priOffsetInMap = 0 ; */  	unsigned int uiDSDPri = STATUS_FAILURE; @@ -4313,7 +4261,7 @@ int ReadDSDPriority(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_v  	return uiDSDPri;  } -enum bcm_flash2x_section_val getHighestPriDSD(struct bcm_mini_adapter *Adapter) +static enum bcm_flash2x_section_val getHighestPriDSD(struct bcm_mini_adapter *Adapter)  {  	int DSDHighestPri = STATUS_FAILURE;  	int DsdPri = 0; @@ -4345,7 +4293,7 @@ enum bcm_flash2x_section_val getHighestPriDSD(struct bcm_mini_adapter *Adapter)  	return  HighestPriDSD;  } -int ReadISOSignature(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val iso) +static int ReadISOSignature(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val iso)  {  	unsigned int uiISOsig = 0;  	/* unsigned int sigoffsetInMap = 0; @@ -4368,7 +4316,7 @@ int ReadISOSignature(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_  	return uiISOsig;  } -int ReadISOPriority(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val iso) +static int ReadISOPriority(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val iso)  {  	unsigned int ISOPri = STATUS_FAILURE;  	if (IsSectionWritable(Adapter, iso)) { @@ -4387,7 +4335,7 @@ int ReadISOPriority(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_v  	return ISOPri;  } -enum bcm_flash2x_section_val getHighestPriISO(struct bcm_mini_adapter *Adapter) +static enum bcm_flash2x_section_val getHighestPriISO(struct bcm_mini_adapter *Adapter)  {  	int ISOHighestPri = STATUS_FAILURE;  	int ISOPri = 0; @@ -4411,7 +4359,7 @@ enum bcm_flash2x_section_val getHighestPriISO(struct bcm_mini_adapter *Adapter)  	return HighestPriISO;  } -int WriteToFlashWithoutSectorErase(struct bcm_mini_adapter *Adapter, +static int WriteToFlashWithoutSectorErase(struct bcm_mini_adapter *Adapter,  				PUINT pBuff,  				enum bcm_flash2x_section_val eFlash2xSectionVal,  				unsigned int uiOffset, @@ -4450,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 @@ -4469,19 +4417,19 @@ int WriteToFlashWithoutSectorErase(struct bcm_mini_adapter *Adapter,  	return Status;  } -BOOLEAN IsSectionExistInFlash(struct bcm_mini_adapter *Adapter, enum bcm_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: @@ -4518,26 +4466,26 @@ BOOLEAN IsSectionExistInFlash(struct bcm_mini_adapter *Adapter, enum bcm_flash2x  		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, enum bcm_flash2x_section_val Section) +static int IsSectionWritable(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val Section)  {  	int offset = STATUS_FAILURE; -	int Status = FALSE; +	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)) @@ -4555,8 +4503,8 @@ static int CorruptDSDSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_sect  	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; @@ -4615,7 +4563,7 @@ static int CorruptISOSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_sect  	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"); @@ -4656,10 +4604,10 @@ static int CorruptISOSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_sect  	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/vendorspecificextn.c b/drivers/staging/bcm/vendorspecificextn.c index d38a06f762d..2c57a16788c 100644 --- a/drivers/staging/bcm/vendorspecificextn.c +++ b/drivers/staging/bcm/vendorspecificextn.c @@ -113,7 +113,7 @@ INT vendorextnReadSection(PVOID  pContext, PUCHAR pBuffer, enum bcm_flash2x_sect   *		STATUS_SUCCESS/STATUS_FAILURE   */  INT vendorextnWriteSection(PVOID  pContext, PUCHAR pBuffer, enum bcm_flash2x_section_val SectionVal, -			UINT offset, UINT numOfBytes, BOOLEAN bVerify) +			UINT offset, UINT numOfBytes, bool bVerify)  {  	return STATUS_FAILURE;  } diff --git a/drivers/staging/bcm/vendorspecificextn.h b/drivers/staging/bcm/vendorspecificextn.h index 52890d216ed..ff57f057045 100644 --- a/drivers/staging/bcm/vendorspecificextn.h +++ b/drivers/staging/bcm/vendorspecificextn.h @@ -11,7 +11,7 @@ INT vendorextnIoctl(struct bcm_mini_adapter *Adapter, UINT cmd, ULONG arg);  INT vendorextnReadSection(PVOID  pContext, PUCHAR pBuffer, enum bcm_flash2x_section_val SectionVal,  			UINT offset, UINT numOfBytes);  INT vendorextnWriteSection(PVOID  pContext, PUCHAR pBuffer, enum bcm_flash2x_section_val SectionVal, -			UINT offset, UINT numOfBytes, BOOLEAN bVerify); +			UINT offset, UINT numOfBytes, bool bVerify);  INT vendorextnWriteSectionWithoutErase(PVOID  pContext, PUCHAR pBuffer, enum bcm_flash2x_section_val SectionVal,  			UINT offset, UINT numOfBytes);  | 
