📄 hfa384x_usb.c
字号:
void *usercb_data){ int result; hfa384x_usbctlx_t *ctlx; DBFENTER; ctlx = usbctlx_alloc(); if ( ctlx == NULL ) { result = -ENOMEM; goto done; } /* Initialize the command */ ctlx->outbuf.wridreq.type = host2hfa384x_16(HFA384x_USB_WRIDREQ); ctlx->outbuf.wridreq.frmlen = host2hfa384x_16( (sizeof(ctlx->outbuf.wridreq.rid) + riddatalen + 1) / 2); ctlx->outbuf.wridreq.rid = host2hfa384x_16(rid); memcpy(ctlx->outbuf.wridreq.data, riddata, riddatalen); ctlx->outbufsize = sizeof(ctlx->outbuf.wridreq.type) + sizeof(ctlx->outbuf.wridreq.frmlen) + sizeof(ctlx->outbuf.wridreq.rid) + riddatalen; ctlx->reapable = mode; ctlx->cmdcb = cmdcb; ctlx->usercb = usercb; ctlx->usercb_data = usercb_data; /* Submit the CTLX */ result = hfa384x_usbctlx_submit(hw, ctlx); if (result != 0) { kfree(ctlx); } else if (mode == DOWAIT) { usbctlx_wrid_completor_t completor; hfa384x_cmdresult_t wridresult; result = hfa384x_usbctlx_complete_sync( hw, ctlx, init_wrid_completor(&completor, &ctlx->inbuf.wridresp, &wridresult) ); }done: DBFEXIT; return result;}/*----------------------------------------------------------------* hfa384x_dormem** Constructs a readmem CTLX and issues it.** NOTE: Any changes to the 'post-submit' code in this function * need to be carried over to hfa384x_cbrmem() since the handling* is virtually identical.** Arguments:* hw device structure* mode DOWAIT or DOASYNC* page MAC address space page (CMD format)* offset MAC address space offset* data Ptr to data buffer to receive read* len Length of the data to read (max == 2048)* cmdcb command callback for async calls, NULL for DOWAIT calls* usercb user callback for async calls, NULL for DOWAIT calls* usercb_data user supplied data pointer for async calls** Returns: * 0 success* -ETIMEDOUT timed out waiting for register ready or* command completion* >0 command indicated error, Status and Resp0-2 are* in hw structure.** Side effects:* * Call context:* interrupt (DOASYNC)* process (DOWAIT or DOASYNC)----------------------------------------------------------------*/inthfa384x_dormem( hfa384x_t *hw, CMD_MODE mode, UINT16 page, UINT16 offset, void *data, UINT len, ctlx_cmdcb_t cmdcb, ctlx_usercb_t usercb, void *usercb_data){ int result; hfa384x_usbctlx_t *ctlx; DBFENTER; ctlx = usbctlx_alloc(); if ( ctlx == NULL ) { result = -ENOMEM; goto done; } /* Initialize the command */ ctlx->outbuf.rmemreq.type = host2hfa384x_16(HFA384x_USB_RMEMREQ); ctlx->outbuf.rmemreq.frmlen = host2hfa384x_16( sizeof(ctlx->outbuf.rmemreq.offset) + sizeof(ctlx->outbuf.rmemreq.page) + len); ctlx->outbuf.rmemreq.offset = host2hfa384x_16(offset); ctlx->outbuf.rmemreq.page = host2hfa384x_16(page); ctlx->outbufsize = sizeof(ctlx->outbuf.rmemreq); WLAN_LOG_DEBUG(4, "type=0x%04x frmlen=%d offset=0x%04x page=0x%04x\n", ctlx->outbuf.rmemreq.type, ctlx->outbuf.rmemreq.frmlen, ctlx->outbuf.rmemreq.offset, ctlx->outbuf.rmemreq.page); WLAN_LOG_DEBUG(4,"pktsize=%zd\n", ROUNDUP64(sizeof(ctlx->outbuf.rmemreq))); ctlx->reapable = mode; ctlx->cmdcb = cmdcb; ctlx->usercb = usercb; ctlx->usercb_data = usercb_data; result = hfa384x_usbctlx_submit(hw, ctlx); if (result != 0) { kfree(ctlx); } else if ( mode == DOWAIT ) { usbctlx_rmem_completor_t completor; result = hfa384x_usbctlx_complete_sync( hw, ctlx, init_rmem_completor(&completor, &ctlx->inbuf.rmemresp, data, len) ); }done: DBFEXIT; return result;} /*----------------------------------------------------------------* hfa384x_dowmem** Constructs a writemem CTLX and issues it.** NOTE: Any changes to the 'post-submit' code in this function * need to be carried over to hfa384x_cbwmem() since the handling* is virtually identical.** Arguments:* hw device structure* mode DOWAIT or DOASYNC* page MAC address space page (CMD format)* offset MAC address space offset* data Ptr to data buffer containing write data* len Length of the data to read (max == 2048)* cmdcb command callback for async calls, NULL for DOWAIT calls* usercb user callback for async calls, NULL for DOWAIT calls* usercb_data user supplied data pointer for async calls.** Returns: * 0 success* -ETIMEDOUT timed out waiting for register ready or* command completion* >0 command indicated error, Status and Resp0-2 are* in hw structure.** Side effects:* * Call context:* interrupt (DOWAIT)* process (DOWAIT or DOASYNC)----------------------------------------------------------------*/inthfa384x_dowmem( hfa384x_t *hw, CMD_MODE mode, UINT16 page, UINT16 offset, void *data, UINT len, ctlx_cmdcb_t cmdcb, ctlx_usercb_t usercb, void *usercb_data){ int result; hfa384x_usbctlx_t *ctlx; DBFENTER; WLAN_LOG_DEBUG(5, "page=0x%04x offset=0x%04x len=%d\n", page,offset,len); ctlx = usbctlx_alloc(); if ( ctlx == NULL ) { result = -ENOMEM; goto done; } /* Initialize the command */ ctlx->outbuf.wmemreq.type = host2hfa384x_16(HFA384x_USB_WMEMREQ); ctlx->outbuf.wmemreq.frmlen = host2hfa384x_16( sizeof(ctlx->outbuf.wmemreq.offset) + sizeof(ctlx->outbuf.wmemreq.page) + len); ctlx->outbuf.wmemreq.offset = host2hfa384x_16(offset); ctlx->outbuf.wmemreq.page = host2hfa384x_16(page); memcpy(ctlx->outbuf.wmemreq.data, data, len); ctlx->outbufsize = sizeof(ctlx->outbuf.wmemreq.type) + sizeof(ctlx->outbuf.wmemreq.frmlen) + sizeof(ctlx->outbuf.wmemreq.offset) + sizeof(ctlx->outbuf.wmemreq.page) + len; ctlx->reapable = mode; ctlx->cmdcb = cmdcb; ctlx->usercb = usercb; ctlx->usercb_data = usercb_data; result = hfa384x_usbctlx_submit(hw, ctlx); if (result != 0) { kfree(ctlx); } else if ( mode == DOWAIT ) { usbctlx_wmem_completor_t completor; hfa384x_cmdresult_t wmemresult; result = hfa384x_usbctlx_complete_sync( hw, ctlx, init_wmem_completor(&completor, &ctlx->inbuf.wmemresp, &wmemresult) ); }done: DBFEXIT; return result;} /*----------------------------------------------------------------* hfa384x_drvr_commtallies** Send a commtallies inquiry to the MAC. Note that this is an async* call that will result in an info frame arriving sometime later.** Arguments:* hw device structure** Returns: * zero success.** Side effects:** Call context:* process----------------------------------------------------------------*/int hfa384x_drvr_commtallies( hfa384x_t *hw ){ hfa384x_metacmd_t cmd; DBFENTER; cmd.cmd = HFA384x_CMDCODE_INQ; cmd.parm0 = HFA384x_IT_COMMTALLIES; cmd.parm1 = 0; cmd.parm2 = 0; hfa384x_docmd_async(hw, &cmd, NULL, NULL, NULL); DBFEXIT; return 0;}/*----------------------------------------------------------------* hfa384x_drvr_disable** Issues the disable command to stop communications on one of * the MACs 'ports'. Only macport 0 is valid for stations.* APs may also disable macports 1-6. Only ports that have been* previously enabled may be disabled.** 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_drvr_disable(hfa384x_t *hw, UINT16 macport){ int result = 0; DBFENTER; if ((!hw->isap && macport != 0) || (hw->isap && !(macport <= HFA384x_PORTID_MAX)) || !(hw->port_enabled[macport]) ){ result = -EINVAL; } else { result = hfa384x_cmd_disable(hw, macport); if ( result == 0 ) { hw->port_enabled[macport] = 0; } } DBFEXIT; return result;}/*----------------------------------------------------------------* hfa384x_drvr_enable** Issues the enable command to enable communications on one of * the MACs 'ports'. Only macport 0 is valid for stations.* APs may also enable macports 1-6. Only ports that are currently* disabled may be enabled.** 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_drvr_enable(hfa384x_t *hw, UINT16 macport){ int result = 0; DBFENTER; if ((!hw->isap && macport != 0) || (hw->isap && !(macport <= HFA384x_PORTID_MAX)) || (hw->port_enabled[macport]) ){ result = -EINVAL; } else { result = hfa384x_cmd_enable(hw, macport); if ( result == 0 ) { hw->port_enabled[macport] = 1; } } DBFEXIT; return result;}/*----------------------------------------------------------------* hfa384x_drvr_flashdl_enable** Begins the flash download state. Checks to see that we're not* already in a download state and that a port isn't enabled.* Sets the download state and retrieves the flash download* buffer location, buffer size, and timeout length.** 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 ----------------------------------------------------------------*/int hfa384x_drvr_flashdl_enable(hfa384x_t *hw){ int result = 0; int i; DBFENTER; /* Check that a port isn't active */ for ( i = 0; i < HFA384x_PORTID_MAX; i++) { if ( hw->port_enabled[i] ) { WLAN_LOG_DEBUG(1,"called when port enabled.\n"); return -EINVAL; } } /* Check that we're not already in a download state */ if ( hw->dlstate != HFA384x_DLSTATE_DISABLED ) { return -EINVAL; } /* Retrieve the buffer loc&size and timeout */ if ( (result = hfa384x_drvr_getconfig(hw, HFA384x_RID_DOWNLOADBUFFER, &(hw->bufinfo), sizeof(hw->bufinfo))) ) { return result; } hw->bufinfo.page = hfa384x2host_16(hw->bufinfo.page); hw->bufinfo.offset = hfa384x2host_16(hw->bufinfo.offset); hw->bufinfo.len = hfa384x2host_16(hw->bufinfo.len); if ( (result = hfa384x_drvr_getconfig16(hw, HFA384x_RID_MAXLOADTIME, &(hw->dltimeout))) ) { return result; } hw->dltimeout = hfa384x2host_16(hw->dltimeout); WLAN_LOG_DEBUG(1,"flashdl_enable\n"); hw->dlstate = HFA384x_DLSTATE_FLASHENABLED; DBFEXIT; return result;}/*----------------------------------------------------------------* hfa384x_drvr_flashdl_disable** Ends the flash download state. Note that this will cause the MAC* firmware to restart.** 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 ----------------------------------------------------------------*/int hfa384x_drvr_flashdl_disable(hfa384x_t *hw){ DBFENTER; /* Check that we're already in the download state */ if ( hw->dlstate != HFA384x_DLSTATE_FLASHENABLED ) { return -EINVAL; } WLAN_LOG_DEBUG(1,"flashdl_enable\n"); /* There isn't much we can do at this point, so I don't */ /* bother w/ the return value */ hfa384x_cmd_download(hw, HFA384x_PROGMODE_DISABLE, 0, 0 , 0); hw->dlstate = HFA384x_DLSTATE_DISABLED; DBFEXIT; return 0;}/*----------------------------------------------------------------* hfa384x_drvr_flashdl_write** Performs a FLASH download of a chunk of data. First checks to see* that we're in the FLASH download state, then sets the download* mode, uses the aux functions to 1) copy the data to the flash* buffer, 2) sets the download 'write flash' mode, 3) readback and * compare. Lather rinse, repeat as many times an necessary to get* all the given data into flash. * When all data has been written using this function (possibly * repeatedly), call drvr_flashdl_disable() to end the download state* and restart the MAC.** Arguments:* hw device structure* daddr Card address to write to. (host order)* buf Ptr to data to write.* len Length of data (host order).** Returns: * 0 success* >0 f/w reported error - f/w status code* <0 driver reported error** Side effects:** Call context:* process ----------------------------------------------------------------*/inthfa384x_drvr_flashdl_write( hfa
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -