📄 hfa384x_usb.c
字号:
* Call context:* interrupt----------------------------------------------------------------*/voidhfa384x_cb_rrid(hfa384x_t *hw, const hfa384x_usbctlx_t *ctlx){ DBFENTER; if ( ctlx->usercb != NULL ) { hfa384x_rridresult_t rridresult; if (ctlx->state != CTLX_COMPLETE) { memset(&rridresult, 0, sizeof(rridresult)); rridresult.rid = hfa384x2host_16(ctlx->outbuf.rridreq.rid); } else { usbctlx_get_rridresult(&ctlx->inbuf.rridresp, &rridresult); } ctlx->usercb(hw, &rridresult, ctlx->usercb_data); } DBFEXIT;}static inline inthfa384x_docmd_wait(hfa384x_t *hw, hfa384x_metacmd_t *cmd){ return hfa384x_docmd(hw, DOWAIT, cmd, NULL, NULL, NULL);}static inline inthfa384x_docmd_async(hfa384x_t *hw, hfa384x_metacmd_t *cmd, ctlx_cmdcb_t cmdcb, ctlx_usercb_t usercb, void *usercb_data){ return hfa384x_docmd(hw, DOASYNC, cmd, cmdcb, usercb, usercb_data);}static inline inthfa384x_dorrid_wait(hfa384x_t *hw, UINT16 rid, void *riddata, UINT riddatalen){ return hfa384x_dorrid(hw, DOWAIT, rid, riddata, riddatalen, NULL, NULL, NULL);}static inline inthfa384x_dorrid_async(hfa384x_t *hw, UINT16 rid, void *riddata, UINT riddatalen, ctlx_cmdcb_t cmdcb, ctlx_usercb_t usercb, void *usercb_data){ return hfa384x_dorrid(hw, DOASYNC, rid, riddata, riddatalen, cmdcb, usercb, usercb_data);}static inline inthfa384x_dowrid_wait(hfa384x_t *hw, UINT16 rid, void *riddata, UINT riddatalen){ return hfa384x_dowrid(hw, DOWAIT, rid, riddata, riddatalen, NULL, NULL, NULL);}static inline inthfa384x_dowrid_async(hfa384x_t *hw, UINT16 rid, void *riddata, UINT riddatalen, ctlx_cmdcb_t cmdcb, ctlx_usercb_t usercb, void *usercb_data){ return hfa384x_dowrid(hw, DOASYNC, rid, riddata, riddatalen, cmdcb, usercb, usercb_data);}static inline inthfa384x_dormem_wait(hfa384x_t *hw, UINT16 page, UINT16 offset, void *data, UINT len){ return hfa384x_dormem(hw, DOWAIT, page, offset, data, len, NULL, NULL, NULL);}static inline inthfa384x_dormem_async(hfa384x_t *hw, UINT16 page, UINT16 offset, void *data, UINT len, ctlx_cmdcb_t cmdcb, ctlx_usercb_t usercb, void *usercb_data){ return hfa384x_dormem(hw, DOASYNC, page, offset, data, len, cmdcb, usercb, usercb_data);}static inline inthfa384x_dowmem_wait( hfa384x_t *hw, UINT16 page, UINT16 offset, void *data, UINT len){ return hfa384x_dowmem(hw, DOWAIT, page, offset, data, len, NULL, NULL, NULL);}static inline inthfa384x_dowmem_async( hfa384x_t *hw, UINT16 page, UINT16 offset, void *data, UINT len, ctlx_cmdcb_t cmdcb, ctlx_usercb_t usercb, void *usercb_data){ return hfa384x_dowmem(hw, DOASYNC, page, offset, data, len, cmdcb, usercb, usercb_data);}/*----------------------------------------------------------------* 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; hfa384x_metacmd_t cmd; DBFENTER; cmd.cmd = HFA384x_CMDCODE_INIT; cmd.parm0 = 0; cmd.parm1 = 0; cmd.parm2 = 0; result = hfa384x_docmd_wait(hw, &cmd); WLAN_LOG_DEBUG(3,"cmdresp.init: " "status=0x%04x, resp0=0x%04x, " "resp1=0x%04x, resp2=0x%04x\n", cmd.result.status, cmd.result.resp0, cmd.result.resp1, cmd.result.resp2); if ( result == 0 ) { for ( i = 0; i < HFA384x_NUMPORTS_MAX; i++) { hw->port_enabled[i] = 0; } } hw->link_status = HFA384x_LINK_NOTCONNECTED; 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; hfa384x_metacmd_t cmd; DBFENTER; cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_DISABLE) | HFA384x_CMD_MACPORT_SET(macport); cmd.parm0 = 0; cmd.parm1 = 0; cmd.parm2 = 0; result = hfa384x_docmd_wait(hw, &cmd); 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; hfa384x_metacmd_t cmd; DBFENTER; cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_ENABLE) | HFA384x_CMD_MACPORT_SET(macport); cmd.parm0 = 0; cmd.parm1 = 0; cmd.parm2 = 0; result = hfa384x_docmd_wait(hw, &cmd); 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, void *buf, UINT16 len){#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); 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; hfa384x_metacmd_t cmd; DBFENTER; cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_INQ); cmd.parm0 = 0; cmd.parm1 = 0; cmd.parm2 = 0; result = hfa384x_docmd_wait(hw, &cmd); 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){ int result = 0; hfa384x_metacmd_t cmd; DBFENTER; cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | HFA384x_CMD_AINFO_SET(enable); cmd.parm0 = 0; cmd.parm1 = 0; cmd.parm2 = 0; result = hfa384x_docmd_wait(hw, &cmd); DBFEXIT; return result;}/*----------------------------------------------------------------* 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; hfa384x_metacmd_t cmd; DBFENTER; WLAN_LOG_DEBUG(5, "mode=%d, lowaddr=0x%04x, highaddr=0x%04x, codelen=%d\n", mode, lowaddr, highaddr, codelen); cmd.cmd = (HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_DOWNLD) | HFA384x_CMD_PROGMODE_SET(mode)); cmd.parm0 = lowaddr; cmd.parm1 = highaddr; cmd.parm2 = codelen; result = hfa384x_docmd_wait(hw, &cmd); 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_ERROR("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.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -