hfa384x_usb.c

来自「Linux的无线局域网方案是一个Linux设备驱动程序和子系统 一揽子方案的用」· C语言 代码 · 共 2,513 行 · 第 1/5 页

C
2,513
字号
	DBFENTER;	if ( ctlx->usercb != NULL ) {		memset(&rridresult, 0, sizeof(rridresult));		result = ctlx->state;			if (ctlx->state == HFA384x_USBCTLX_COMPLETE) {			rridresult.rid = 				hfa384x2host_16(ctlx->inbuf.rridresp.rid);			rridresult.riddata = ctlx->inbuf.rridresp.data;			rridresult.riddata_len = 			((hfa384x2host_16(ctlx->inbuf.rridresp.frmlen)-1)*2);		}		(*ctlx->usercb)(hw, result, &rridresult, ctlx->usercb_data);	}	kfree(ctlx);	DBFEXIT;	return;}/*----------------------------------------------------------------* hfa384x_cbwrid** CTLX completion handler for async WRID type control exchanges.** Note: If the handling is changed here, it should probably be *       changed in dowrid as well.** Arguments:*	hw		hw struct*	ctlx		complete CTLX** Returns: *	nothing** Side effects:** Call context:*	interrupt----------------------------------------------------------------*/voidhfa384x_cbwrid(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx){	UINT				result;	hfa384x_async_wridresult_t	wridresult;	DBFENTER;	if ( ctlx->usercb != NULL ) {		memset(&wridresult, 0, sizeof(wridresult));		result = ctlx->state;		if (ctlx->state == HFA384x_USBCTLX_COMPLETE) {			wridresult.status = 				hfa384x2host_16(ctlx->inbuf.wridresp.status);			wridresult.resp0 = 				hfa384x2host_16(ctlx->inbuf.wridresp.resp0);			wridresult.resp1 = 				hfa384x2host_16(ctlx->inbuf.wridresp.resp1);			wridresult.resp2 = 				hfa384x2host_16(ctlx->inbuf.wridresp.resp2);		}		(*ctlx->usercb)(hw, result, &wridresult, ctlx->usercb_data);	}	kfree(ctlx);	DBFEXIT;	return;}/*----------------------------------------------------------------* hfa384x_cbrmem** CTLX completion handler for async RMEM type control exchanges.** Note: If the handling is changed here, it should probably be *       changed in dormem as well.** Arguments:*	hw		hw struct*	ctlx		complete CTLX** Returns: *	nothing** Side effects:** Call context:*	interrupt----------------------------------------------------------------*/voidhfa384x_cbrmem(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx){	DBFENTER;	DBFEXIT;	return;}/*----------------------------------------------------------------* hfa384x_cbwmem** CTLX completion handler for async WMEM type control exchanges.** Note: If the handling is changed here, it should probably be *       changed in dowmem as well.** Arguments:*	hw		hw struct*	ctlx		complete CTLX** Returns: *	nothing** Side effects:** Call context:*	interrupt----------------------------------------------------------------*/voidhfa384x_cbwmem(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx){	DBFENTER;	DBFEXIT;	return;}/*----------------------------------------------------------------* hfa384x_cmd_initialize** Issues the initialize command and sets the hw->state based* on the result.** Arguments:*	hw		device structure** Returns: *	0		success*	>0		f/w reported error - f/w status code*	<0		driver reported error** Side effects:** Call context:*	process----------------------------------------------------------------*/inthfa384x_cmd_initialize(hfa384x_t *hw){	int	result = 0;	int	i;	DBFENTER;	result = hfa384x_docmd(hw, DOWAIT, 			HFA384x_CMDCODE_INIT, 0,0,0,			NULL, NULL);	WLAN_LOG_DEBUG4(3,"cmdresp.init: "		"status=0x%04x, resp0=0x%04x, "		"resp1=0x%04x, resp2=0x%04x\n",		hw->status, hw->resp0, hw->resp1, hw->resp2);	if ( result == 0 ) {		for ( i = 0; i < HFA384x_NUMPORTS_MAX; i++) {			hw->port_enabled[i] = 0;		}	}	DBFEXIT;	return result;}/*----------------------------------------------------------------* hfa384x_cmd_disable** Issues the disable command to stop communications on one of * the MACs 'ports'.** Arguments:*	hw		device structure*	macport		MAC port number (host order)** Returns: *	0		success*	>0		f/w reported failure - f/w status code*	<0		driver reported error (timeout|bad arg)** Side effects:** Call context:*	process ----------------------------------------------------------------*/int hfa384x_cmd_disable(hfa384x_t *hw, UINT16 macport){	int	result = 0;	UINT16	cmd;	DBFENTER;	cmd =	HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_DISABLE) |		HFA384x_CMD_MACPORT_SET(macport);	result = hfa384x_docmd(hw, DOWAIT, cmd, 0,0,0, NULL, NULL);	DBFEXIT;	return result;}/*----------------------------------------------------------------* hfa384x_cmd_enable** Issues the enable command to enable communications on one of * the MACs 'ports'.** Arguments:*	hw		device structure*	macport		MAC port number** Returns: *	0		success*	>0		f/w reported failure - f/w status code*	<0		driver reported error (timeout|bad arg)** Side effects:** Call context:*	process ----------------------------------------------------------------*/int hfa384x_cmd_enable(hfa384x_t *hw, UINT16 macport){	int	result = 0;	UINT16	cmd;	DBFENTER;	cmd =	HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_ENABLE) |		HFA384x_CMD_MACPORT_SET(macport);	result = hfa384x_docmd(hw, DOWAIT, cmd, 0,0,0, NULL, NULL);	DBFEXIT;	return result;}/*----------------------------------------------------------------* hfa384x_cmd_notify** Sends an info frame to the firmware to alter the behavior* of the f/w asynch processes.  Can only be called when the MAC* is in the enabled state.** Arguments:*	hw		device structure*	reclaim		[0|1] indicates whether the given FID will*			be handed back (via Alloc event) for reuse.*			(host order)*	fid		FID of buffer containing the frame that was*			previously copied to MAC memory via the bap.*			(host order)** Returns: *	0		success*	>0		f/w reported failure - f/w status code*	<0		driver reported error (timeout|bad arg)** Side effects:*	hw->resp0 will contain the FID being used by async notify*	process.  If reclaim==0, resp0 will be the same as the fid*	argument.  If reclaim==1, resp0 will be the different.** Call context:*	process ----------------------------------------------------------------*/int hfa384x_cmd_notify(hfa384x_t *hw, UINT16 reclaim, UINT16 fid){#if 0	int	result = 0;	UINT16	cmd;	DBFENTER;	cmd =	HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_NOTIFY) |		HFA384x_CMD_RECL_SET(reclaim);	result = hfa384x_docmd_wait(hw, cmd, fid, 0, 0);		DBFEXIT;	return result;#endifreturn 0;}/*----------------------------------------------------------------* hfa384x_cmd_inquiry** Requests an info frame from the firmware.  The info frame will* be delivered asynchronously via the Info event.** Arguments:*	hw		device structure*	fid		FID of the info frame requested. (host order)** Returns: *	0		success*	>0		f/w reported failure - f/w status code*	<0		driver reported error (timeout|bad arg)** Side effects:** Call context:*	process ----------------------------------------------------------------*/int hfa384x_cmd_inquiry(hfa384x_t *hw, UINT16 fid){	int	result = 0;	UINT16	cmd;	DBFENTER;	cmd =	HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_INQ);	result = hfa384x_docmd(hw, DOWAIT, cmd, 0,0,0, NULL, NULL);		DBFEXIT;	return result;}/*----------------------------------------------------------------* hfa384x_cmd_monitor** Enables the 'monitor mode' of the MAC.  Here's the description of* monitor mode that I've received thus far:**  "The "monitor mode" of operation is that the MAC passes all *  frames for which the PLCP checks are correct. All received *  MPDUs are passed to the host with MAC Port = 7, with a  *  receive status of good, FCS error, or undecryptable. Passing *  certain MPDUs is a violation of the 802.11 standard, but useful *  for a debugging tool."  Normal communication is not possible*  while monitor mode is enabled.** Arguments:*	hw		device structure*	enable		a code (0x0b|0x0f) that enables/disables*			monitor mode. (host order)** Returns: *	0		success*	>0		f/w reported failure - f/w status code*	<0		driver reported error (timeout|bad arg)** Side effects:** Call context:*	process ----------------------------------------------------------------*/int hfa384x_cmd_monitor(hfa384x_t *hw, UINT16 enable){#if 0	int	result = 0;	UINT16	cmd;	DBFENTER;	cmd =	HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) |		HFA384x_CMD_AINFO_SET(enable);	result = hfa384x_docmd_wait(hw, cmd, 0, 0, 0);		DBFEXIT;	return result;#endifreturn 0;}/*----------------------------------------------------------------* hfa384x_cmd_download** Sets the controls for the MAC controller code/data download* process.  The arguments set the mode and address associated * with a download.  Note that the aux registers should be enabled* prior to setting one of the download enable modes.** Arguments:*	hw		device structure*	mode		0 - Disable programming and begin code exec*			1 - Enable volatile mem programming*			2 - Enable non-volatile mem programming*			3 - Program non-volatile section from NV download*			    buffer. *			(host order)*	lowaddr		*	highaddr	For mode 1, sets the high & low order bits of *			the "destination address".  This address will be*			the execution start address when download is*			subsequently disabled.*			For mode 2, sets the high & low order bits of *			the destination in NV ram.*			For modes 0 & 3, should be zero. (host order)*			NOTE: these are CMD format.*	codelen		Length of the data to write in mode 2, *			zero otherwise. (host order)** Returns: *	0		success*	>0		f/w reported failure - f/w status code*	<0		driver reported error (timeout|bad arg)** Side effects:** Call context:*	process ----------------------------------------------------------------*/int hfa384x_cmd_download(hfa384x_t *hw, UINT16 mode, UINT16 lowaddr, 				UINT16 highaddr, UINT16 codelen){	int	result = 0;	DBFENTER;	WLAN_LOG_DEBUG4(5,		"mode=%d, lowaddr=0x%04x, highaddr=0x%04x, codelen=%d\n",		mode, lowaddr, highaddr, codelen);	result = hfa384x_docmd(hw, 			DOWAIT, 			(HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_DOWNLD) |			 HFA384x_CMD_PROGMODE_SET(mode)),			lowaddr, 			highaddr, 			codelen,			NULL, NULL);		DBFEXIT;	return result;}/*----------------------------------------------------------------* hfa384x_copy_from_aux** Copies a collection of bytes from the controller memory.  The* Auxiliary port MUST be enabled prior to calling this function.* We _might_ be in a download state.** Arguments:*	hw		device structure*	cardaddr	address in hfa384x data space to read*	auxctl		address space select*	buf		ptr to destination host buffer*	len		length of data to transfer (in bytes)** Returns: *	nothing** Side effects:*	buf contains the data copied** Call context:*	process*	interrupt----------------------------------------------------------------*/void hfa384x_copy_from_aux(	hfa384x_t *hw, UINT32 cardaddr, UINT32 auxctl, void *buf, UINT len){	DBFENTER;	WLAN_LOG_INFO0(__FUNCTION__": not used in USB.\n");	DBFEXIT;}/*----------------------------------------------------------------* hfa384x_copy_to_aux** Copies a collection of bytes to the controller memory.  The* Auxiliary port MUST be enabled prior to calling this function.* We _might_ be in a download state.** Arguments:*	hw		device structure*	cardaddr	address in hfa384x data space to read*	auxctl		address space select*	buf		ptr to destination host buffer*	len		length of data to transfer (in bytes)** Returns: *	nothing** Side effects:*	Controller memory now contains a copy of buf** Call context:*	process*	interrupt----------------------------------------------------------------*/void hfa384x_copy_to_aux(	hfa384x_t *hw, UINT32 cardaddr, UINT32 auxctl, void *buf, UINT len){	DBFENTER;	WLAN_LOG_INFO0(__FUNCTION__": not used in USB.\n");	DBFEXIT;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?