Docmd_* rewrite.

origin
solomon 2002-07-31 13:56:32 +00:00
parent 60f5bf8e94
commit f452f8a47e
5 changed files with 311 additions and 349 deletions

View File

@ -41,6 +41,7 @@
* Intersil Corporation as part of PRISM(R) chipset product development.
*
* --------------------------------------------------------------------
- Restructure of the docmd_* functions
-pre1
- Host-based WEP decryption and encryption
- Partial rewrite of copy_to_bap.

View File

@ -235,21 +235,9 @@ static void hfa384x_int_rxmonitor( wlandevice_t *wlandev,
static int hfa384x_int_rx_typedrop( wlandevice_t *wlandev, UINT16 fc);
static void hfa384x_int_alloc(wlandevice_t *wlandev);
static int
hfa384x_docmd_wait(
hfa384x_t *hw,
UINT16 cmd,
UINT16 parm0,
UINT16 parm1,
UINT16 parm2);
static int hfa384x_docmd_wait( hfa384x_t *hw, hfa384x_metacmd_t *cmd);
static int
hfa384x_dl_docmd_wait(
hfa384x_t *hw,
UINT16 cmd,
UINT16 parm0,
UINT16 parm1,
UINT16 parm2);
static int hfa384x_dl_docmd_wait( hfa384x_t *hw, hfa384x_metacmd_t *cmd);
static UINT16
hfa384x_mkcrc16(UINT8 *p, int len);
@ -1331,8 +1319,16 @@ int hfa384x_cmd_initialize(hfa384x_t *hw)
{
int result = 0;
int i;
hfa384x_metacmd_t cmd;
DBFENTER;
result = hfa384x_docmd_wait(hw, HFA384x_CMDCODE_INIT, 0,0,0);
cmd.cmd = HFA384x_CMDCODE_INIT;
cmd.parm0 = 0;
cmd.parm1 = 0;
cmd.parm2 = 0;
result = hfa384x_docmd_wait(hw, &cmd);
if ( result == 0 ) {
for ( i = 0; i < HFA384x_NUMPORTS_MAX; i++) {
hw->port_enabled[i] = 0;
@ -1362,11 +1358,16 @@ int hfa384x_cmd_initialize(hfa384x_t *hw)
----------------------------------------------------------------*/
int hfa384x_drvr_commtallies( hfa384x_t *hw )
{
hfa384x_metacmd_t cmd;
DBFENTER;
hfa384x_docmd_wait(hw,
HFA384x_CMDCODE_INQ,
HFA384x_IT_COMMTALLIES,
0,0);
cmd.cmd = HFA384x_CMDCODE_INQ;
cmd.parm0 = HFA384x_IT_COMMTALLIES;
cmd.parm1 = 0;
cmd.parm2 = 0;
hfa384x_docmd_wait(hw, &cmd);
DBFEXIT;
return 0;
@ -1438,13 +1439,17 @@ int hfa384x_drvr_enable(hfa384x_t *hw, UINT16 macport)
int hfa384x_cmd_enable(hfa384x_t *hw, UINT16 macport)
{
int result = 0;
UINT16 cmd;
hfa384x_metacmd_t cmd;
DBFENTER;
cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_ENABLE) |
HFA384x_CMD_MACPORT_SET(macport);
result = hfa384x_docmd_wait(hw, cmd, 0,0,0);
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;
@ -1515,12 +1520,18 @@ int hfa384x_drvr_disable(hfa384x_t *hw, UINT16 macport)
int hfa384x_cmd_disable(hfa384x_t *hw, UINT16 macport)
{
int result = 0;
UINT16 cmd;
hfa384x_metacmd_t cmd;
DBFENTER;
cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_DISABLE) |
HFA384x_CMD_MACPORT_SET(macport);
result = hfa384x_docmd_wait(hw, cmd, 0,0,0);
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;
}
@ -1556,11 +1567,16 @@ int hfa384x_cmd_disable(hfa384x_t *hw, UINT16 macport)
int hfa384x_cmd_diagnose(hfa384x_t *hw)
{
int result = 0;
UINT16 cmd;
hfa384x_metacmd_t cmd;
DBFENTER;
cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_DIAG);
result = hfa384x_docmd_wait(hw, cmd, DIAG_PATTERNA, DIAG_PATTERNB, 0);
cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_DIAG);
cmd.parm0 = DIAG_PATTERNA;
cmd.parm1 = DIAG_PATTERNB;
cmd.parm2 = 0;
result = hfa384x_docmd_wait(hw, &cmd);
DBFEXIT;
return result;
}
@ -1600,15 +1616,20 @@ int hfa384x_cmd_diagnose(hfa384x_t *hw)
int hfa384x_cmd_allocate(hfa384x_t *hw, UINT16 len)
{
int result = 0;
UINT16 cmd;
hfa384x_metacmd_t 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);
cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_ALLOC);
cmd.parm0 = len;
cmd.parm1 = 0;
cmd.parm2 = 0;
result = hfa384x_docmd_wait(hw, &cmd);
}
DBFEXIT;
return result;
@ -1657,12 +1678,17 @@ int hfa384x_cmd_allocate(hfa384x_t *hw, UINT16 len)
int hfa384x_cmd_transmit(hfa384x_t *hw, UINT16 reclaim, UINT16 qos, UINT16 fid)
{
int result = 0;
UINT16 cmd;
hfa384x_metacmd_t cmd;
DBFENTER;
cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_TX) |
cmd.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);
cmd.parm0 = fid;
cmd.parm1 = 0;
cmd.parm2 = 0;
result = hfa384x_docmd_wait(hw, &cmd);
DBFEXIT;
return result;
@ -1694,10 +1720,16 @@ int hfa384x_cmd_transmit(hfa384x_t *hw, UINT16 reclaim, UINT16 qos, UINT16 fid)
int hfa384x_cmd_clearpersist(hfa384x_t *hw, UINT16 fid)
{
int result = 0;
UINT16 cmd;
hfa384x_metacmd_t cmd;
DBFENTER;
cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_CLRPRST);
result = hfa384x_docmd_wait(hw, cmd, fid, 0, 0);
cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_CLRPRST);
cmd.parm0 = fid;
cmd.parm1 = 0;
cmd.parm2 = 0;
result = hfa384x_docmd_wait(hw, &cmd);
DBFEXIT;
return result;
@ -1735,11 +1767,16 @@ int hfa384x_cmd_clearpersist(hfa384x_t *hw, UINT16 fid)
int hfa384x_cmd_notify(hfa384x_t *hw, UINT16 reclaim, UINT16 fid)
{
int result = 0;
UINT16 cmd;
hfa384x_metacmd_t cmd;
DBFENTER;
cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_NOTIFY) |
cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_NOTIFY) |
HFA384x_CMD_RECL_SET(reclaim);
result = hfa384x_docmd_wait(hw, cmd, fid, 0, 0);
cmd.parm0 = fid;
cmd.parm1 = 0;
cmd.parm2 = 0;
result = hfa384x_docmd_wait(hw, &cmd);
DBFEXIT;
return result;
@ -1769,10 +1806,16 @@ int hfa384x_cmd_notify(hfa384x_t *hw, UINT16 reclaim, UINT16 fid)
int hfa384x_cmd_inquiry(hfa384x_t *hw, UINT16 fid)
{
int result = 0;
UINT16 cmd;
hfa384x_metacmd_t cmd;
DBFENTER;
cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_INQ);
result = hfa384x_docmd_wait(hw, cmd, fid, 0, 0);
cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_INQ);
cmd.parm0 = fid;
cmd.parm1 = 0;
cmd.parm2 = 0;
result = hfa384x_docmd_wait(hw, &cmd);
DBFEXIT;
return result;
@ -1807,11 +1850,17 @@ int hfa384x_cmd_inquiry(hfa384x_t *hw, UINT16 fid)
int hfa384x_cmd_access(hfa384x_t *hw, UINT16 write, UINT16 rid)
{
int result = 0;
UINT16 cmd;
hfa384x_metacmd_t cmd;
DBFENTER;
cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_ACCESS) |
cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_ACCESS) |
HFA384x_CMD_WRITE_SET(write);
result = hfa384x_docmd_wait(hw, cmd, rid, 0, 0);
cmd.parm0 = rid;
cmd.parm1 = 0;
cmd.parm2 = 0;
result = hfa384x_docmd_wait(hw, &cmd);
DBFEXIT;
return result;
@ -1850,11 +1899,17 @@ int hfa384x_cmd_access(hfa384x_t *hw, UINT16 write, UINT16 rid)
int hfa384x_cmd_monitor(hfa384x_t *hw, UINT16 enable)
{
int result = 0;
UINT16 cmd;
hfa384x_metacmd_t cmd;
DBFENTER;
cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) |
cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) |
HFA384x_CMD_AINFO_SET(enable);
result = hfa384x_docmd_wait(hw, cmd, 0, 0, 0);
cmd.parm0 = 0;
cmd.parm1 = 0;
cmd.parm2 = 0;
result = hfa384x_docmd_wait(hw, &cmd);
DBFEXIT;
return result;
@ -1903,11 +1958,17 @@ int hfa384x_cmd_download(hfa384x_t *hw, UINT16 mode, UINT16 lowaddr,
UINT16 highaddr, UINT16 codelen)
{
int result = 0;
UINT16 cmd;
hfa384x_metacmd_t cmd;
DBFENTER;
cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_DOWNLD) |
cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_DOWNLD) |
HFA384x_CMD_PROGMODE_SET(mode);
result = hfa384x_dl_docmd_wait(hw, cmd, lowaddr, highaddr, codelen);
cmd.parm0 = lowaddr;
cmd.parm1 = highaddr;
cmd.parm2 = codelen;
result = hfa384x_dl_docmd_wait(hw, &cmd);
DBFEXIT;
return result;
@ -2046,54 +2107,34 @@ int hfa384x_cmd_aux_disable(hfa384x_t *hw)
return result;
}
/*----------------------------------------------------------------
* hfa384x_drvr_low_level
*
* Write test commands to the card. Some test commands don't make
* sense without prior set-up. For example, continous TX isn't very
* useful until you set the channel. That functionality should be
* enforced at a higher level.
*
* Arguments:
* hw device structure
* test_mode The test command code to use.
* test_param A parameter needed for the test mode being used.
*
* Returns:
* 0 success
* >0 f/w reported error - f/w status code
* <0 driver reported error
*
* Side effects:
*
* Call context:
* process thread
----------------------------------------------------------------*/
int hfa384x_drvr_low_level(hfa384x_t *hw, UINT32 command,
UINT32 param0,
UINT32 param1,
UINT32 param2)
* process thread
* -----------------------------------------------------------------*/
int hfa384x_drvr_low_level(hfa384x_t *hw, hfa384x_metacmd_t *cmd)
{
int result = 0;
UINT16 cmd = (UINT16) command;
UINT16 p0 = (UINT16) param0;
UINT16 p1 = (UINT16) param1;
UINT16 p2 = (UINT16) param2;
int result = 0;
DBFENTER;
/* Do i need a host2hfa... conversion ? */
#if 0
printk(KERN_INFO "%#x %#x %#x %#x\n", cmd, p0, p1, p2);
printk(KERN_INFO "%#x %#x %#x %#x\n", cmd->cmd, cmd->parm0, cmd->parm1, cmd->parm2);
#endif
result = hfa384x_docmd_wait(hw, cmd, p0, p1, p2);
result = hfa384x_docmd_wait(hw, cmd);
DBFEXIT;
return result;
}
/* TODO: determine if these will ever be needed */
#if 0
int hfa384x_cmd_readmif(hfa384x_t *hw)
@ -2112,43 +2153,6 @@ int hfa384x_cmd_writemif(hfa384x_t *hw)
}
#endif
/*----------------------------------------------------------------
* hfa384x_drvr_test_command
*
* Write test commands to the card. Some test commands don't make
* sense without prior set-up. For example, continous TX isn't very
* useful until you set the channel. That functionality should be
* enforced at a higher level.
*
* Arguments:
* hw device structure
* test_mode The test command code to use.
* test_param A parameter needed for the test mode being used.
*
* Returns:
* 0 success
* >0 f/w reported error - f/w status code
* <0 driver reported error
*
* Side effects:
*
* Call context:
* process thread
----------------------------------------------------------------*/
int hfa384x_drvr_test_command(hfa384x_t *hw, UINT32 test_mode,
UINT32 test_param)
{
int result = 0;
UINT16 cmd = ((UINT16) test_mode) << 8 | 0x38;
UINT16 param = (UINT16)test_param;
DBFENTER;
result = hfa384x_docmd_wait(hw, cmd, param, 0, 0);
DBFEXIT;
return result;
}
/*----------------------------------------------------------------
* hfa384x_drvr_mmi_read
*
@ -2169,15 +2173,21 @@ int hfa384x_drvr_test_command(hfa384x_t *hw, UINT32 test_mode,
* Call context:
* process thread
----------------------------------------------------------------*/
int hfa384x_drvr_mmi_read(hfa384x_t *hw, UINT32 addr)
int hfa384x_drvr_mmi_read(hfa384x_t *hw, UINT32 addr, UINT32 *resp)
{
int result = 0;
UINT16 cmd_code = (UINT16) 0x30;
UINT16 param = (UINT16) addr;
hfa384x_metacmd_t cmd;
DBFENTER;
cmd.cmd = (UINT16) 0x30;
cmd.parm0 = (UINT16) addr;
cmd.parm1 = 0;
cmd.parm2 = 0;
/* Do i need a host2hfa... conversion ? */
result = hfa384x_docmd_wait(hw, cmd_code, param, 0, 0);
result = hfa384x_docmd_wait(hw, &cmd);
*resp = (UINT32) cmd.resp0;
DBFEXIT;
return result;
@ -2209,16 +2219,19 @@ int
hfa384x_drvr_mmi_write(hfa384x_t *hw, UINT32 addr, UINT32 data)
{
int result = 0;
UINT16 cmd_code = (UINT16) 0x31;
UINT16 param0 = (UINT16) addr;
UINT16 param1 = (UINT16) data;
hfa384x_metacmd_t cmd;
DBFENTER;
cmd.cmd = (UINT16) 0x31;
cmd.parm0 = (UINT16) addr;
cmd.parm1 = (UINT16) data;
cmd.parm2 = 0;
WLAN_LOG_DEBUG1(1,"mmi write : addr = 0x%08lx\n", addr);
WLAN_LOG_DEBUG1(1,"mmi write : data = 0x%08lx\n", data);
/* Do i need a host2hfa... conversion ? */
result = hfa384x_docmd_wait(hw, cmd_code, param0, param1, 0);
result = hfa384x_docmd_wait(hw, &cmd);
DBFEXIT;
return result;
@ -2665,10 +2678,8 @@ hfa384x_copy_to_aux(
*
* Arguments:
* wlandev device structure
* cmd Command in host order
* parm0 Parameter0 in host order
* parm1 Parameter1 in host order
* parm2 Parameter2 in host order
* cmd cmd structure. Includes all arguments and result
* data points. All in host order.
*
* Returns:
* 0 success
@ -2683,13 +2694,11 @@ hfa384x_copy_to_aux(
* Call context:
* process thread
----------------------------------------------------------------*/
int hfa384x_docmd_wait( hfa384x_t *hw, UINT16 cmd, UINT16 parm0, UINT16 parm1, UINT16 parm2)
int hfa384x_docmd_wait( hfa384x_t *hw, hfa384x_metacmd_t *cmd)
{
int result = -ETIMEDOUT;
#ifndef CMD_IRQ
wlan_flags_t flags;
#endif
UINT16 reg = 0;
UINT16 counter;
@ -2697,13 +2706,10 @@ int hfa384x_docmd_wait( hfa384x_t *hw, UINT16 cmd, UINT16 parm0, UINT16 parm1, U
DBFENTER;
/* acquire the lock */
#ifdef CMD_IRQ
spin_lock(&hw->cmdlock);
#else
spin_lock_irqsave(&(hw->cmdlock), flags);
#endif
hw->cmdflag = 0;
hw->cmddata = cmd;
/* wait for the busy bit to clear */
counter = 0;
@ -2723,11 +2729,10 @@ int hfa384x_docmd_wait( hfa384x_t *hw, UINT16 cmd, UINT16 parm0, UINT16 parm1, U
}
if (!HFA384x_CMD_ISBUSY(reg)) {
/* busy bit clear, write command */
hfa384x_setreg(hw, parm0, HFA384x_PARAM0);
hfa384x_setreg(hw, parm1, HFA384x_PARAM1);
hfa384x_setreg(hw, parm2, HFA384x_PARAM2);
hw->lastcmd = cmd;
hfa384x_setreg(hw, cmd, HFA384x_CMD);
hfa384x_setreg(hw, cmd->parm0, HFA384x_PARAM0);
hfa384x_setreg(hw, cmd->parm1, HFA384x_PARAM1);
hfa384x_setreg(hw, cmd->parm2, HFA384x_PARAM2);
hfa384x_setreg(hw, cmd->cmd, HFA384x_CMD);
#ifdef CMD_IRQ
@ -2737,8 +2742,8 @@ int hfa384x_docmd_wait( hfa384x_t *hw, UINT16 cmd, UINT16 parm0, UINT16 parm1, U
#else
wait_event_interruptible(hw->cmdq, hw->cmdflag);
#endif
result = HFA384x_STATUS_RESULT_GET(hw->status);
#else
result = HFA384x_STATUS_RESULT_GET(cmd->status);
#else // CMD_IRQ
/* Now wait for completion */
counter = 0;
reg = hfa384x_getreg(hw, HFA384x_EVSTAT);
@ -2757,13 +2762,13 @@ int hfa384x_docmd_wait( hfa384x_t *hw, UINT16 cmd, UINT16 parm0, UINT16 parm1, U
#endif
if ( HFA384x_EVSTAT_ISCMD(reg) ) {
result = 0;
hw->status = hfa384x_getreg(hw, HFA384x_STATUS);
hw->resp0 = hfa384x_getreg(hw, HFA384x_RESP0);
hw->resp1 = hfa384x_getreg(hw, HFA384x_RESP1);
hw->resp2 = hfa384x_getreg(hw, HFA384x_RESP2);
cmd->status = hfa384x_getreg(hw, HFA384x_STATUS);
cmd->resp0 = hfa384x_getreg(hw, HFA384x_RESP0);
cmd->resp1 = hfa384x_getreg(hw, HFA384x_RESP1);
cmd->resp2 = hfa384x_getreg(hw, HFA384x_RESP2);
hfa384x_setreg(hw, HFA384x_EVACK_CMD,
HFA384x_EVACK);
result = HFA384x_STATUS_RESULT_GET(hw->status);
result = HFA384x_STATUS_RESULT_GET(cmd->status);
} else {
WLAN_LOG_ERROR1("hfa384x_cmd timeout(2), reg=0x%0hx.\n", reg);
}
@ -2772,11 +2777,8 @@ int hfa384x_docmd_wait( hfa384x_t *hw, UINT16 cmd, UINT16 parm0, UINT16 parm1, U
failed:
hw->cmdflag = 0;
#ifdef CMD_IRQ
spin_unlock(&hw->cmdlock);
#else
hw->cmddata = NULL;
spin_unlock_irqrestore( &(hw->cmdlock), flags);
#endif
DBFEXIT;
return result;
@ -2797,10 +2799,8 @@ int hfa384x_docmd_wait( hfa384x_t *hw, UINT16 cmd, UINT16 parm0, UINT16 parm1, U
*
* Arguments:
* wlandev device structure
* cmd Command in host order
* parm0 Parameter0 in host order
* parm1 Parameter1 in host order
* parm2 Parameter2 in host order
* cmd cmd structure. Includes all arguments and result
* data points. All in host order.
*
* Returns:
* 0 success
@ -2815,7 +2815,7 @@ int hfa384x_docmd_wait( hfa384x_t *hw, UINT16 cmd, UINT16 parm0, UINT16 parm1, U
* Call context:
* process thread
----------------------------------------------------------------*/
int hfa384x_dl_docmd_wait( hfa384x_t *hw, UINT16 cmd, UINT16 parm0, UINT16 parm1, UINT16 parm2)
int hfa384x_dl_docmd_wait( hfa384x_t *hw, hfa384x_metacmd_t *cmd)
{
int result = -ETIMEDOUT;
UINT32 timeout;
@ -2836,14 +2836,13 @@ int hfa384x_dl_docmd_wait( hfa384x_t *hw, UINT16 cmd, UINT16 parm0, UINT16 parm1
if (!HFA384x_CMD_ISBUSY(reg)) {
/* busy bit clear, write command */
hfa384x_setreg(hw, parm0, HFA384x_PARAM0);
hfa384x_setreg(hw, parm1, HFA384x_PARAM1);
hfa384x_setreg(hw, parm2, HFA384x_PARAM2);
hw->lastcmd = cmd;
hfa384x_setreg(hw, cmd, HFA384x_CMD);
hfa384x_setreg(hw, cmd->parm0, HFA384x_PARAM0);
hfa384x_setreg(hw, cmd->parm1, HFA384x_PARAM1);
hfa384x_setreg(hw, cmd->parm2, HFA384x_PARAM2);
hfa384x_setreg(hw, cmd->cmd, HFA384x_CMD);
/* Now wait for completion */
if ( (HFA384x_CMD_CMDCODE_GET(hw->lastcmd) == HFA384x_CMDCODE_DOWNLD) ) {
if ( (HFA384x_CMD_CMDCODE_GET(cmd->cmd) == HFA384x_CMDCODE_DOWNLD) ) {
/* dltimeout is in ms */
timeout = (((UINT32)hw->dltimeout) / 1000UL) * HZ;
if ( timeout > 0 ) {
@ -2861,14 +2860,15 @@ int hfa384x_dl_docmd_wait( hfa384x_t *hw, UINT16 cmd, UINT16 parm0, UINT16 parm1
}
if ( HFA384x_EVSTAT_ISCMD(reg) ) {
result = 0;
hw->status = hfa384x_getreg(hw, HFA384x_STATUS);
hw->resp0 = hfa384x_getreg(hw, HFA384x_RESP0);
hw->resp1 = hfa384x_getreg(hw, HFA384x_RESP1);
hw->resp2 = hfa384x_getreg(hw, HFA384x_RESP2);
cmd->status = hfa384x_getreg(hw, HFA384x_STATUS);
cmd->resp0 = hfa384x_getreg(hw, HFA384x_RESP0);
cmd->resp1 = hfa384x_getreg(hw, HFA384x_RESP1);
cmd->resp2 = hfa384x_getreg(hw, HFA384x_RESP2);
hfa384x_setreg(hw, HFA384x_EVACK_CMD, HFA384x_EVACK);
result = HFA384x_STATUS_RESULT_GET(hw->status);
result = HFA384x_STATUS_RESULT_GET(cmd->status);
}
}
failed:
DBFEXIT;
return result;
@ -3342,7 +3342,7 @@ dmpmem(skb->data, skb->len);
#else
txfid_queue_add(hw, fid);
#endif
WLAN_LOG_DEBUG2(1,"cmd_tx(%04x) failed, result=%d",
WLAN_LOG_DEBUG2(1,"cmd_tx(%04x) failed, result=%d\n",
fid, result);
result = 3;
goto failed;
@ -3522,7 +3522,6 @@ void hfa384x_interrupt(int irq, void *dev_id, struct pt_regs *regs)
return;
}
#ifdef CMD_IRQ
/*----------------------------------------------------------------
* hfa384x_int_cmd
*
@ -3545,27 +3544,25 @@ void hfa384x_int_cmd(wlandevice_t *wlandev)
hfa384x_t *hw = priv->hw;
DBFENTER;
hw->status = hfa384x_getreg(hw, HFA384x_STATUS);
hw->resp0 = hfa384x_getreg(hw, HFA384x_RESP0);
hw->resp1 = hfa384x_getreg(hw, HFA384x_RESP1);
hw->resp2 = hfa384x_getreg(hw, HFA384x_RESP2);
// check to make sure it's the right command?
if (hw->cmddata) {
hw->cmddata->status = hfa384x_getreg(hw, HFA384x_STATUS);
hw->cmddata->resp0 = hfa384x_getreg(hw, HFA384x_RESP0);
hw->cmddata->resp1 = hfa384x_getreg(hw, HFA384x_RESP1);
hw->cmddata->resp2 = hfa384x_getreg(hw, HFA384x_RESP2);
}
hw->cmdflag = 1;
printk(KERN_INFO, "um. int_cmd\n");
printk(KERN_INFO "um. int_cmd\n");
wake_up_interruptible(&hw->cmdq);
// XXXX rewrite so that it uses a 'resultstruct'.
// XXXX perform a bap copy too?
DBFEXIT;
return;
}
#endif
/*----------------------------------------------------------------
* hfa384x_int_dtim
*

View File

@ -269,10 +269,7 @@ static int
hfa384x_docmd(
hfa384x_t *hw,
UINT wait,
UINT16 cmd,
UINT16 parm0,
UINT16 parm1,
UINT16 parm2,
hfa384x_metacmd_t *cmd,
ctlx_usercb_t usercb,
void *usercb_data);
@ -662,17 +659,23 @@ hfa384x_cmd_initialize(hfa384x_t *hw)
{
int result = 0;
int i;
hfa384x_metacmd_t cmd;
DBFENTER;
result = hfa384x_docmd(hw, DOWAIT,
HFA384x_CMDCODE_INIT, 0,0,0,
NULL, NULL);
cmd.cmd = HFA384x_CMDCODE_INIT;
cmd.parm0 = 0;
cmd.parm1 = 0;
cmd.parm2 = 0;
result = hfa384x_docmd(hw, DOWAIT, &cmd, 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);
cmd.status, cmd.resp0, cmd.resp1, cmd.resp2);
if ( result == 0 ) {
for ( i = 0; i < HFA384x_NUMPORTS_MAX; i++) {
hw->port_enabled[i] = 0;
@ -707,12 +710,17 @@ hfa384x_cmd_initialize(hfa384x_t *hw)
int hfa384x_cmd_disable(hfa384x_t *hw, UINT16 macport)
{
int result = 0;
UINT16 cmd;
hfa384x_metacmd_t 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);
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(hw, DOWAIT, &cmd, NULL, NULL);
DBFEXIT;
return result;
@ -742,13 +750,17 @@ int hfa384x_cmd_disable(hfa384x_t *hw, UINT16 macport)
int hfa384x_cmd_enable(hfa384x_t *hw, UINT16 macport)
{
int result = 0;
UINT16 cmd;
hfa384x_metacmd_t 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);
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(hw, DOWAIT, &cmd, NULL, NULL);
DBFEXIT;
return result;
@ -824,10 +836,16 @@ return 0;
int hfa384x_cmd_inquiry(hfa384x_t *hw, UINT16 fid)
{
int result = 0;
UINT16 cmd;
hfa384x_metacmd_t cmd;
DBFENTER;
cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_INQ);
result = hfa384x_docmd(hw, DOWAIT, cmd, 0,0,0, NULL, NULL);
cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_INQ);
cmd.parm0 = 0;
cmd.parm1 = 0;
cmd.parm2 = 0;
result = hfa384x_docmd(hw, DOWAIT, &cmd, NULL, NULL);
DBFEXIT;
return result;
@ -866,11 +884,17 @@ int hfa384x_cmd_inquiry(hfa384x_t *hw, UINT16 fid)
int hfa384x_cmd_monitor(hfa384x_t *hw, UINT16 enable)
{
int result = 0;
UINT16 cmd;
hfa384x_metacmd_t cmd;
DBFENTER;
cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) |
cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) |
HFA384x_CMD_AINFO_SET(enable);
result = hfa384x_docmd(hw, 1, cmd, 0, 0, 0, NULL, NULL);
cmd.parm0 = 0;
cmd.parm1 = 0;
cmd.parm2 = 0;
result = hfa384x_docmd(hw, DOWAIT, &cmd, NULL, NULL);
DBFEXIT;
return result;
@ -919,20 +943,22 @@ 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_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);
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(hw, DOWAIT, &cmd, NULL, NULL);
DBFEXIT;
return result;
}
@ -1105,10 +1131,9 @@ done:
* Arguments:
* hw device structure
* wait 1=wait for completion, 0=async
* cmd Command in host order
* parm0 Parameter0 in host order
* parm1 Parameter1 in host order
* parm2 Parameter2 in host order
* cmd cmd structure. Includes all arguments and result
* data points. All in host order. in host order
* usercb user callback for async calls, NULL for wait==1 calls
* usercb_data user supplied data pointer for async calls, NULL
* for wait==1 calls
@ -1130,10 +1155,7 @@ int
hfa384x_docmd(
hfa384x_t *hw,
UINT wait,
UINT16 p2cmd,
UINT16 parm0,
UINT16 parm1,
UINT16 parm2,
hfa384x_metacmd_t *cmd,
ctlx_usercb_t usercb,
void *usercb_data)
{
@ -1151,18 +1173,17 @@ hfa384x_docmd(
/* Initialize the command */
ctlx->outbuf.cmdreq.type = host2hfa384x_16(HFA384x_USB_CMDREQ);
ctlx->outbuf.cmdreq.cmd = host2hfa384x_16(p2cmd);
ctlx->outbuf.cmdreq.parm0 = host2hfa384x_16(parm0);
ctlx->outbuf.cmdreq.parm1 = host2hfa384x_16(parm1);
ctlx->outbuf.cmdreq.parm2 = host2hfa384x_16(parm2);
hw->lastcmd = host2hfa384x_16(p2cmd);
ctlx->outbuf.cmdreq.cmd = host2hfa384x_16(cmd->cmd);
ctlx->outbuf.cmdreq.parm0 = host2hfa384x_16(cmd->parm0);
ctlx->outbuf.cmdreq.parm1 = host2hfa384x_16(cmd->parm1);
ctlx->outbuf.cmdreq.parm2 = host2hfa384x_16(cmd->parm2);
WLAN_LOG_DEBUG4(4, "cmdreq: cmd=0x%04x "
"parm0=0x%04x parm1=0x%04x parm2=0x%04x\n",
p2cmd,
parm0,
parm1,
parm2);
cmd->cmd,
cmd->parm0,
cmd->parm1,
cmd->parm2);
/* Fill the out packet */
FILL_BULK_URB( &(ctlx->outurb), hw->usb,
@ -1185,16 +1206,16 @@ hfa384x_docmd(
result = hfa384x2host_16(ctlx->inbuf.cmdresp.status);
result &= HFA384x_STATUS_RESULT;
hw->status = hfa384x2host_16(ctlx->inbuf.cmdresp.status);
hw->resp0 = hfa384x2host_16(ctlx->inbuf.cmdresp.resp0);
hw->resp1 = hfa384x2host_16(ctlx->inbuf.cmdresp.resp1);
hw->resp2 = hfa384x2host_16(ctlx->inbuf.cmdresp.resp2);
cmd->status = hfa384x2host_16(ctlx->inbuf.cmdresp.status);
cmd->resp0 = hfa384x2host_16(ctlx->inbuf.cmdresp.resp0);
cmd->resp1 = hfa384x2host_16(ctlx->inbuf.cmdresp.resp1);
cmd->resp2 = hfa384x2host_16(ctlx->inbuf.cmdresp.resp2);
WLAN_LOG_DEBUG4(4, "cmdresp:status=0x%04x "
"resp0=0x%04x resp1=0x%04x resp2=0x%04x\n",
hw->status,
hw->resp0,
hw->resp1,
hw->resp2);
cmd->status,
cmd->resp0,
cmd->resp1,
cmd->resp2);
break;
case HFA384x_USBCTLX_REQSUBMIT_FAIL:
WLAN_LOG_WARNING0(__FUNCTION__":ctlx failure=REQSUBMIT_FAIL\n");
@ -1450,10 +1471,13 @@ hfa384x_dowrid(
case HFA384x_USBCTLX_COMPLETE:
result = hfa384x2host_16(ctlx->inbuf.wridresp.status);
result &= HFA384x_STATUS_RESULT;
/*
hw->status = hfa384x2host_16(ctlx->inbuf.wridresp.status);
hw->resp0 = hfa384x2host_16(ctlx->inbuf.wridresp.resp0);
hw->resp1 = hfa384x2host_16(ctlx->inbuf.wridresp.resp1);
hw->resp2 = hfa384x2host_16(ctlx->inbuf.wridresp.resp2);
*/
break;
case HFA384x_USBCTLX_REQSUBMIT_FAIL:
@ -1716,10 +1740,12 @@ hfa384x_dowmem(
switch(ctlx->state) {
case HFA384x_USBCTLX_COMPLETE:
result = hfa384x2host_16(ctlx->inbuf.wmemresp.status);
/*
hw->status = hfa384x2host_16(ctlx->inbuf.wmemresp.status);
hw->resp0 = hfa384x2host_16(ctlx->inbuf.wmemresp.resp0);
hw->resp1 = hfa384x2host_16(ctlx->inbuf.wmemresp.resp1);
hw->resp2 = hfa384x2host_16(ctlx->inbuf.wmemresp.resp2);
*/
break;
case HFA384x_USBCTLX_REQSUBMIT_FAIL:
WLAN_LOG_WARNING0(__FUNCTION__":ctlx failure=REQSUBMIT_FAIL\n");
@ -1775,12 +1801,16 @@ done:
----------------------------------------------------------------*/
int hfa384x_drvr_commtallies( hfa384x_t *hw )
{
hfa384x_metacmd_t cmd;
DBFENTER;
hfa384x_docmd(hw,
DOASYNC,
HFA384x_CMDCODE_INQ,
HFA384x_IT_COMMTALLIES,
0,0, NULL, NULL);
cmd.cmd = HFA384x_CMDCODE_INQ;
cmd.parm0 = HFA384x_IT_COMMTALLIES;
cmd.parm1 = 0;
cmd.parm2 = 0;
hfa384x_docmd(hw, DOASYNC, &cmd, NULL, NULL);
DBFEXIT;
return 0;
@ -2339,57 +2369,33 @@ int hfa384x_drvr_handover( hfa384x_t *hw, UINT8 *addr)
return -EIO;
}
/*----------------------------------------------------------------
* hfa384x_drvr_low_level
*
* Write test commands to the card. Some test commands don't make
* sense without prior set-up. For example, continous TX isn't very
* useful until you set the channel. That functionality should be
* enforced at a higher level.
*
* Arguments:
* hw device structure
* test_mode The test command code to use.
* test_param A parameter needed for the test mode being used.
*
* Returns:
* 0 success
* >0 f/w reported error - f/w status code
* <0 driver reported error
*
* Side effects:
*
* Call context:
* process
----------------------------------------------------------------*/
int hfa384x_drvr_low_level(hfa384x_t *hw, UINT32 command,
UINT32 param0,
UINT32 param1,
UINT32 param2)
* process thread
* -----------------------------------------------------------------*/
int hfa384x_drvr_low_level(hfa384x_t *hw, hfa384x_metacmd_t *cmd)
{
#if 0
int result = 0;
UINT16 cmd = (UINT16) command;
UINT16 p0 = (UINT16) param0;
UINT16 p1 = (UINT16) param1;
UINT16 p2 = (UINT16) param2;
int result = 0;
DBFENTER;
/* Do i need a host2hfa... conversion ? */
#if 0
printk(KERN_INFO "%#x %#x %#x %#x\n", cmd, p0, p1, p2);
printk(KERN_INFO "%#x %#x %#x %#x\n", cmd->cmd, cmd->param0, cmd->param1, cmd->param2);
#endif
result = hfa384x_docmd_wait(hw, cmd, p0, p1, p2);
result = hfa384x_drvr_low_level(hw, cmd);
DBFEXIT;
return result;
#endif
return 0;
}
/*----------------------------------------------------------------
* hfa384x_drvr_mmi_read
*
@ -2410,7 +2416,7 @@ return 0;
* Call context:
* process
----------------------------------------------------------------*/
int hfa384x_drvr_mmi_read(hfa384x_t *hw, UINT32 addr)
int hfa384x_drvr_mmi_read(hfa384x_t *hw, UINT32 addr, UINT32 *resp)
{
#if 0
int result = 0;
@ -3073,48 +3079,6 @@ hfa384x_drvr_stop(hfa384x_t *hw)
return result;
}
/*----------------------------------------------------------------
* hfa384x_drvr_test_command
*
* Write test commands to the card. Some test commands don't make
* sense without prior set-up. For example, continous TX isn't very
* useful until you set the channel. That functionality should be
* enforced at a higher level.
*
* Arguments:
* hw device structure
* test_mode The test command code to use.
* test_param A parameter needed for the test mode being used.
*
* Returns:
* 0 success
* >0 f/w reported error - f/w status code
* <0 driver reported error
*
* Side effects:
*
* Call context:
* process
----------------------------------------------------------------*/
int hfa384x_drvr_test_command(hfa384x_t *hw, UINT32 test_mode,
UINT32 test_param)
{
#if 0
int result = 0;
UINT16 cmd = (UINT16) test_mode;
UINT16 param = (UINT16) test_param;
DBFENTER;
/* Do i need a host2hfa... conversion ? */
result = hfa384x_docmd_wait(hw, cmd, param, 0, 0);
DBFEXIT;
return result;
#endif
return 0;
}
/*----------------------------------------------------------------
* hfa384x_drvr_txframe
*
@ -4014,7 +3978,7 @@ printk("\n");
switch( HFA384x_RXSTATUS_MACPORT_GET(usbin->rxfrm.desc.status))
{
case 0:
w_hdr = &(usbin->rxfrm.desc.frame_control);
w_hdr = (p80211_hdr_t *) &(usbin->rxfrm.desc.frame_control);
/* see if we should drop or ignore the frame */
result = hfa384x_rx_typedrop(wlandev, ieee2host16(usbin->rxfrm.desc.frame_control));

View File

@ -1543,21 +1543,22 @@ int prism2mgmt_low_level(wlandevice_t *wlandev, void *msgp)
prism2sta_priv_t *priv = (prism2sta_priv_t*)wlandev->priv;
hfa384x_t *hw = priv->hw;
p80211msg_p2req_low_level_t *msg = msgp;
hfa384x_metacmd_t cmd;
DBFENTER;
msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
/* call some routine to execute the test command */
cmd.cmd = (UINT16) msg->command.data;
cmd.parm0 = (UINT16) msg->param0.data;
cmd.parm1 = (UINT16) msg->param1.data;
cmd.parm2 = (UINT16) msg->param2.data;
hfa384x_drvr_low_level(hw,
msg->command.data,
msg->param0.data,
msg->param1.data,
msg->param2.data);
hfa384x_drvr_low_level(hw,&cmd);
msg->resp0.data = (UINT32) hw->resp0;
msg->resp1.data = (UINT32) hw->resp1;
msg->resp2.data = (UINT32) hw->resp2;
msg->resp0.data = (UINT32) cmd.resp0;
msg->resp1.data = (UINT32) cmd.resp1;
msg->resp2.data = (UINT32) cmd.resp2;
msg->resultcode.data = P80211ENUM_resultcode_success;
@ -1588,24 +1589,30 @@ int prism2mgmt_test_command(wlandevice_t *wlandev, void *msgp)
prism2sta_priv_t *priv = (prism2sta_priv_t*)wlandev->priv;
hfa384x_t *hw = priv->hw;
p80211msg_p2req_test_command_t *msg = msgp;
hfa384x_metacmd_t cmd;
DBFENTER;
cmd.cmd = ((UINT16) msg->testcode.data) << 8 | 0x38;
cmd.parm0 = (UINT16) msg->testparam.data;
cmd.parm1 = 0;
cmd.parm2 = 0;
/* call some routine to execute the test command */
hfa384x_drvr_test_command(hw, msg->testcode.data, msg->testparam.data);
hfa384x_drvr_low_level(hw,&cmd);
msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
msg->resultcode.data = P80211ENUM_resultcode_success;
msg->status.status = P80211ENUM_msgitem_status_data_ok;
msg->status.data = hw->status;
msg->status.data = cmd.status;
msg->resp0.status = P80211ENUM_msgitem_status_data_ok;
msg->resp0.data = hw->resp0;
msg->resp0.data = cmd.resp0;
msg->resp1.status = P80211ENUM_msgitem_status_data_ok;
msg->resp1.data = hw->resp1;
msg->resp1.data = cmd.resp1;
msg->resp2.status = P80211ENUM_msgitem_status_data_ok;
msg->resp2.data = hw->resp2;
msg->resp2.data = cmd.resp2;
DBFEXIT;
return 0;
@ -1635,6 +1642,7 @@ int prism2mgmt_mmi_read(wlandevice_t *wlandev, void *msgp)
prism2sta_priv_t *priv = (prism2sta_priv_t*)wlandev->priv;
hfa384x_t *hw = priv->hw;
p80211msg_p2req_mmi_read_t *msg = msgp;
UINT32 resp;
DBFENTER;
@ -1642,13 +1650,13 @@ int prism2mgmt_mmi_read(wlandevice_t *wlandev, void *msgp)
/* call some routine to execute the test command */
hfa384x_drvr_mmi_read(hw, msg->addr.data);
hfa384x_drvr_mmi_read(hw, msg->addr.data, &resp);
/* I'm not sure if this is "architecturally" correct, but it
is expedient. */
msg->value.status = P80211ENUM_msgitem_status_data_ok;
msg->value.data = (UINT32) hw->resp0;
msg->value.data = resp;
msg->resultcode.data = P80211ENUM_resultcode_success;
DBFEXIT;

View File

@ -2322,15 +2322,21 @@ typedef struct hfa384x_usbctlxq
typedef struct hfa484x_metacmd
{
UINT16 cmd;
UINT16 parm0;
UINT16 parm1;
UINT16 parm2;
UINT16 status; /* in host order */
UINT16 resp0; /* in host order */
UINT16 resp1; /* in host order */
UINT16 resp2; /* in host order */
#if 0 //XXX cmd irq stuff
UINT16 bulkid; /* what RID/FID to copy down. */
int bulklen; /* how much to copy from BAP */
char *bulkdata; /* And to where? */
#endif
} hfa384x_metacmd_t;
/* Define to use stack based FID storage, otherwise use queue based */
@ -2379,13 +2385,6 @@ typedef struct hfa384x
hfa384x_downloadbuffer_t bufinfo;
UINT16 dltimeout;
/* Command support */
UINT16 lastcmd;
UINT16 status; /* in host order */
UINT16 resp0; /* in host order */
UINT16 resp1; /* in host order */
UINT16 resp2; /* in host order */
#if (WLAN_HOSTIF != WLAN_USB)
spinlock_t cmdlock;
int cmdflag; /* wait queue flag */
@ -2471,14 +2470,9 @@ hfa384x_drvr_handover( hfa384x_t *hw, UINT8 *addr);
int
hfa384x_drvr_hostscanresults( hfa384x_t *hw);
int
hfa384x_drvr_low_level(
hfa384x_t *hw,
UINT32 command,
UINT32 param0,
UINT32 param1,
UINT32 param2);
hfa384x_drvr_low_level(hfa384x_t *hw, hfa384x_metacmd_t *cmd);
int
hfa384x_drvr_mmi_read(hfa384x_t *hw, UINT32 address);
hfa384x_drvr_mmi_read(hfa384x_t *hw, UINT32 address, UINT32 *result);
int
hfa384x_drvr_mmi_write(hfa384x_t *hw, UINT32 address, UINT32 data);
int
@ -2510,8 +2504,6 @@ hfa384x_drvr_start(hfa384x_t *hw);
int
hfa384x_drvr_stop(hfa384x_t *hw);
int
hfa384x_drvr_test_command(hfa384x_t *hw, UINT32 test_code, UINT32 test_param);
int
hfa384x_drvr_txframe(hfa384x_t *hw, struct sk_buff *skb, p80211_hdr_t *p80211_hdr, p80211_metawep_t *p80211_wep);