hfa384x.c
来自「Linux的无线局域网方案是一个Linux设备驱动程序和子系统 一揽子方案的用」· C语言 代码 · 共 2,425 行 · 第 1/5 页
C
2,425 行
DBFENTER; cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_ENABLE) | HFA384x_CMD_MACPORT_SET(macport); result = hfa384x_docmd_wait(hw, cmd, 0,0,0); DBFEXIT; return result;}/*----------------------------------------------------------------* 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 thread ----------------------------------------------------------------*/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_cmd_disable** Issues the command to disable a port.** 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 thread ----------------------------------------------------------------*/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_wait(hw, cmd, 0,0,0); DBFEXIT; return result;}/*----------------------------------------------------------------* hfa384x_cmd_diagnose** Issues the diagnose command to test the: register interface,* MAC controller (including loopback), External RAM, Non-volatile* memory integrity, and synthesizers. Following execution of this* command, MAC/firmware are in the 'initial state'. Therefore,* the Initialize command should be issued after successful* completion of this command. This function may only be called* when the MAC is in the 'communication disabled' state.** Arguments:* hw device structure** Returns: * 0 success* >0 f/w reported failure - f/w status code* <0 driver reported error (timeout|bad arg)** Side effects:** Call context:* process thread ----------------------------------------------------------------*/#define DIAG_PATTERNA ((UINT16)0xaaaa)#define DIAG_PATTERNB ((UINT16)~0xaaaa)int hfa384x_cmd_diagnose(hfa384x_t *hw){ int result = 0; UINT16 cmd; DBFENTER; cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_DIAG); result = hfa384x_docmd_wait(hw, cmd, DIAG_PATTERNA, DIAG_PATTERNB, 0); DBFEXIT; return result;}/*----------------------------------------------------------------* hfa384x_cmd_allocate** Issues the allocate command instructing the firmware to allocate* a 'frame structure buffer' in MAC controller RAM. This command* does not provide the result, it only initiates one of the f/w's* asynchronous processes to construct the buffer. When the * allocation is complete, it will be indicated via the Alloc* bit in the EvStat register and the FID identifying the allocated* space will be available from the AllocFID register. Some care* should be taken when waiting for the Alloc event. If a Tx or * Notify command w/ Reclaim has been previously executed, it's* possible the first Alloc event after execution of this command* will be for the reclaimed buffer and not the one you asked for.* This case must be handled in the Alloc event handler.** Arguments:* hw device structure* len allocation length, must be an even value* in the range [4-2400]. (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 thread ----------------------------------------------------------------*/int hfa384x_cmd_allocate(hfa384x_t *hw, UINT16 len){ int result = 0; UINT16 cmd; DBFENTER; if ( (len % 2) || len < HFA384x_CMD_ALLOC_LEN_MIN || len > HFA384x_CMD_ALLOC_LEN_MAX ) { result = -EINVAL; } else { cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_ALLOC); result = hfa384x_docmd_wait(hw, cmd, len, 0, 0); } DBFEXIT; return result;}/*----------------------------------------------------------------* hfa384x_cmd_transmit** Instructs the firmware to transmit a frame previously copied* to a given buffer. This function returns immediately, the Tx* results are available via the Tx or TxExc events (if the frame* control bits are set). The reclaim argument specifies if the * FID passed will be used by the f/w tx process or returned for* use w/ another transmit command. If reclaim is set, expect an * Alloc event signalling the availibility of the FID for reuse.** Arguments:* hw device structure* reclaim [0|1] indicates whether the given FID will* be handed back (via Alloc event) for reuse.* (host order)* qos [0-3] Value to put in the QoS field of the * tx command, identifies a queue to place the * outgoing frame in.* (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 tx* process. If reclaim==0, resp0 will be the same as the fid* argument. If reclaim==1, resp0 will be the different and* is the value to watch for in the Tx|TxExc to indicate completion* of the frame passed in fid.** Call context:* process thread ----------------------------------------------------------------*/int hfa384x_cmd_transmit(hfa384x_t *hw, UINT16 reclaim, UINT16 qos, UINT16 fid){ int result = 0; UINT16 cmd; DBFENTER; cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_TX) | HFA384x_CMD_RECL_SET(reclaim) | HFA384x_CMD_QOS_SET(qos); result = hfa384x_docmd_wait(hw, cmd, fid, 0, 0); DBFEXIT; return result;}/*----------------------------------------------------------------* hfa384x_cmd_clearpersist** Instructs the firmware to clear the persistence bit in a given* FID. This has the effect of telling the firmware to drop the* persistent frame. The FID must be one that was previously used* to transmit a PRST frame.** Arguments:* hw device structure* fid FID of the persistent frame (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 thread ----------------------------------------------------------------*/int hfa384x_cmd_clearpersist(hfa384x_t *hw, UINT16 fid){ int result = 0; UINT16 cmd; DBFENTER; cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_CLRPRST); result = hfa384x_docmd_wait(hw, cmd, fid, 0, 0); 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 thread ----------------------------------------------------------------*/int hfa384x_cmd_notify(hfa384x_t *hw, UINT16 reclaim, UINT16 fid){ 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;}/*----------------------------------------------------------------* 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 thread ----------------------------------------------------------------*/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_wait(hw, cmd, fid, 0, 0); DBFEXIT; return result;}/*----------------------------------------------------------------* hfa384x_cmd_access** Requests that a given record be copied to/from the record * buffer. If we're writing from the record buffer, the contents* must previously have been written to the record buffer via the * bap. If we're reading into the record buffer, the record can* be read out of the record buffer after this call.** Arguments:* hw device structure* write [0|1] copy the record buffer to the given* configuration record. (host order)* rid RID of the record to read/write. (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 thread ----------------------------------------------------------------*/int hfa384x_cmd_access(hfa384x_t *hw, UINT16 write, UINT16 rid){ int result = 0; UINT16 cmd; DBFENTER; cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_ACCESS) | HFA384x_CMD_WRITE_SET(write); result = hfa384x_docmd_wait(hw, cmd, rid, 0, 0); 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 thread ----------------------------------------------------------------*/int hfa384x_cmd_monitor(hfa384x_t *hw, UINT16 enable){ 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;}/*----------------------------------------------------------------* 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 address args are in 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 thread ----------------------------------------------------------------*/int hfa384x_cmd_download(hfa384x_t *hw, UINT16 mode, UINT16 lowaddr, UINT16 highaddr, UINT16 codelen){ int result = 0; UINT16 cmd; DBFENTER; cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_DOWNLD) | HFA384x_CMD_PROGMODE_SET(mode); result = hfa384x_dl_docmd_wait(hw, cmd, lowaddr, highaddr, codelen); DBFEXIT; return result;}/*----------------------------------------------------------------* hfa384x_cmd_aux_enable** Goes through the process of enabling the auxilary port. This * is necessary prior to raw reads/writes to card data space. * Direct access to the card data space is only used for downloading* code and debugging.* Note that a call to this function is required before attempting* a download.*
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?