Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 79166
b: refs/heads/master
c: ddac452
h: refs/heads/master
v: v3
  • Loading branch information
Dan Williams authored and David S. Miller committed Jan 28, 2008
1 parent 7b0afe0 commit 9e7b9d9
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 101 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c9cd6f9d630c4422d5f7eb8018b28846e25dba20
refs/heads/master: ddac452680a5164bb47d61ea54f596ddaf3aea7d
133 changes: 57 additions & 76 deletions trunk/drivers/net/wireless/libertas/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1028,24 +1028,18 @@ void lbs_queue_cmd(struct lbs_private *priv,
u8 addtail)
{
unsigned long flags;
struct cmd_ds_command *cmdptr;

lbs_deb_enter(LBS_DEB_HOST);

if (!cmdnode) {
lbs_deb_host("QUEUE_CMD: cmdnode is NULL\n");
goto done;
}

cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr;
if (!cmdptr) {
lbs_deb_host("QUEUE_CMD: cmdptr is NULL\n");
if (!cmdnode || !cmdnode->cmdbuf) {
lbs_deb_host("QUEUE_CMD: cmdnode or cmdbuf is NULL\n");
goto done;
}

/* Exit_PS command needs to be queued in the header always. */
if (le16_to_cpu(cmdptr->command) == CMD_802_11_PS_MODE) {
struct cmd_ds_802_11_ps_mode *psm = &cmdptr->params.psmode;
if (le16_to_cpu(cmdnode->cmdbuf->command) == CMD_802_11_PS_MODE) {
struct cmd_ds_802_11_ps_mode *psm = (void *) cmdnode->cmdbuf;

if (psm->action == cpu_to_le16(CMD_SUBCMD_EXIT_PS)) {
if (priv->psstate != PS_STATE_FULL_POWER)
addtail = 0;
Expand All @@ -1062,7 +1056,7 @@ void lbs_queue_cmd(struct lbs_private *priv,
spin_unlock_irqrestore(&priv->driver_lock, flags);

lbs_deb_host("QUEUE_CMD: inserted command 0x%04x into cmdpendingq\n",
le16_to_cpu(((struct cmd_ds_gen*)cmdnode->bufvirtualaddr)->command));
le16_to_cpu(cmdnode->cmdbuf->command));

done:
lbs_deb_leave(LBS_DEB_HOST);
Expand All @@ -1079,7 +1073,7 @@ static int DownloadcommandToStation(struct lbs_private *priv,
struct cmd_ctrl_node *cmdnode)
{
unsigned long flags;
struct cmd_ds_command *cmdptr;
struct cmd_header *cmd;
int ret = -1;
u16 cmdsize;
u16 command;
Expand All @@ -1091,10 +1085,10 @@ static int DownloadcommandToStation(struct lbs_private *priv,
goto done;
}

cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr;
cmd = cmdnode->cmdbuf;

spin_lock_irqsave(&priv->driver_lock, flags);
if (!cmdptr || !cmdptr->size) {
if (!cmd || !cmd->size) {
lbs_deb_host("DNLD_CMD: cmdptr is NULL or zero\n");
__lbs_cleanup_and_insert_cmd(priv, cmdnode);
spin_unlock_irqrestore(&priv->driver_lock, flags);
Expand All @@ -1105,16 +1099,16 @@ static int DownloadcommandToStation(struct lbs_private *priv,
priv->cur_cmd_retcode = 0;
spin_unlock_irqrestore(&priv->driver_lock, flags);

cmdsize = le16_to_cpu(cmdptr->size);
command = le16_to_cpu(cmdptr->command);
cmdsize = le16_to_cpu(cmd->size);
command = le16_to_cpu(cmd->command);

lbs_deb_host("DNLD_CMD: command 0x%04x, size %d, jiffies %lu\n",
command, cmdsize, jiffies);
lbs_deb_hex(LBS_DEB_HOST, "DNLD_CMD", cmdnode->bufvirtualaddr, cmdsize);
lbs_deb_hex(LBS_DEB_HOST, "DNLD_CMD", (void *) cmdnode->cmdbuf, cmdsize);

cmdnode->cmdwaitqwoken = 0;

ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) cmdptr, cmdsize);
ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) cmd, cmdsize);

if (ret != 0) {
lbs_deb_host("DNLD_CMD: hw_host_to_card failed\n");
Expand Down Expand Up @@ -1265,7 +1259,7 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,

lbs_set_cmd_ctrl_node(priv, cmdnode, wait_option, pdata_buf);

cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr;
cmdptr = (struct cmd_ds_command *)cmdnode->cmdbuf;

lbs_deb_host("PREP_CMD: command 0x%04x\n", cmd_no);

Expand Down Expand Up @@ -1556,41 +1550,35 @@ EXPORT_SYMBOL_GPL(lbs_prepare_and_send_command);
int lbs_allocate_cmd_buffer(struct lbs_private *priv)
{
int ret = 0;
u32 ulbufsize;
u32 bufsize;
u32 i;
struct cmd_ctrl_node *tempcmd_array;
u8 *ptempvirtualaddr;
struct cmd_ctrl_node *cmdarray;

lbs_deb_enter(LBS_DEB_HOST);

/* Allocate and initialize cmdCtrlNode */
ulbufsize = sizeof(struct cmd_ctrl_node) * MRVDRV_NUM_OF_CMD_BUFFER;

if (!(tempcmd_array = kzalloc(ulbufsize, GFP_KERNEL))) {
/* Allocate and initialize the command array */
bufsize = sizeof(struct cmd_ctrl_node) * LBS_NUM_CMD_BUFFERS;
if (!(cmdarray = kzalloc(bufsize, GFP_KERNEL))) {
lbs_deb_host("ALLOC_CMD_BUF: tempcmd_array is NULL\n");
ret = -1;
goto done;
}
priv->cmd_array = tempcmd_array;
priv->cmd_array = cmdarray;

/* Allocate and initialize command buffers */
ulbufsize = MRVDRV_SIZE_OF_CMD_BUFFER;
for (i = 0; i < MRVDRV_NUM_OF_CMD_BUFFER; i++) {
if (!(ptempvirtualaddr = kzalloc(ulbufsize, GFP_KERNEL))) {
/* Allocate and initialize each command buffer in the command array */
for (i = 0; i < LBS_NUM_CMD_BUFFERS; i++) {
cmdarray[i].cmdbuf = kzalloc(LBS_CMD_BUFFER_SIZE, GFP_KERNEL);
if (!cmdarray[i].cmdbuf) {
lbs_deb_host("ALLOC_CMD_BUF: ptempvirtualaddr is NULL\n");
ret = -1;
goto done;
}

/* Update command buffer virtual */
tempcmd_array[i].bufvirtualaddr = ptempvirtualaddr;
}

for (i = 0; i < MRVDRV_NUM_OF_CMD_BUFFER; i++) {
init_waitqueue_head(&tempcmd_array[i].cmdwait_q);
lbs_cleanup_and_insert_cmd(priv, &tempcmd_array[i]);
for (i = 0; i < LBS_NUM_CMD_BUFFERS; i++) {
init_waitqueue_head(&cmdarray[i].cmdwait_q);
lbs_cleanup_and_insert_cmd(priv, &cmdarray[i]);
}

ret = 0;

done:
Expand All @@ -1606,9 +1594,8 @@ int lbs_allocate_cmd_buffer(struct lbs_private *priv)
*/
int lbs_free_cmd_buffer(struct lbs_private *priv)
{
u32 ulbufsize; /* Someone needs to die for this. Slowly and painfully */
struct cmd_ctrl_node *cmdarray;
unsigned int i;
struct cmd_ctrl_node *tempcmd_array;

lbs_deb_enter(LBS_DEB_HOST);

Expand All @@ -1618,14 +1605,13 @@ int lbs_free_cmd_buffer(struct lbs_private *priv)
goto done;
}

tempcmd_array = priv->cmd_array;
cmdarray = priv->cmd_array;

/* Release shared memory buffers */
ulbufsize = MRVDRV_SIZE_OF_CMD_BUFFER;
for (i = 0; i < MRVDRV_NUM_OF_CMD_BUFFER; i++) {
if (tempcmd_array[i].bufvirtualaddr) {
kfree(tempcmd_array[i].bufvirtualaddr);
tempcmd_array[i].bufvirtualaddr = NULL;
for (i = 0; i < LBS_NUM_CMD_BUFFERS; i++) {
if (cmdarray[i].cmdbuf) {
kfree(cmdarray[i].cmdbuf);
cmdarray[i].cmdbuf = NULL;
}
}

Expand Down Expand Up @@ -1683,21 +1669,21 @@ struct cmd_ctrl_node *lbs_get_cmd_ctrl_node(struct lbs_private *priv)
* @param ptempnode A pointer to cmdCtrlNode structure
* @return n/a
*/
static void cleanup_cmdnode(struct cmd_ctrl_node *ptempnode)
static void cleanup_cmdnode(struct cmd_ctrl_node *cmdnode)
{
lbs_deb_enter(LBS_DEB_HOST);

if (!ptempnode)
if (!cmdnode)
return;
ptempnode->cmdwaitqwoken = 1;
wake_up_interruptible(&ptempnode->cmdwait_q);
ptempnode->wait_option = 0;
ptempnode->pdata_buf = NULL;
ptempnode->callback = NULL;
ptempnode->callback_arg = 0;
cmdnode->cmdwaitqwoken = 1;
wake_up_interruptible(&cmdnode->cmdwait_q);
cmdnode->wait_option = 0;
cmdnode->pdata_buf = NULL;
cmdnode->callback = NULL;
cmdnode->callback_arg = 0;

if (ptempnode->bufvirtualaddr != NULL)
memset(ptempnode->bufvirtualaddr, 0, MRVDRV_SIZE_OF_CMD_BUFFER);
if (cmdnode->cmdbuf != NULL)
memset(cmdnode->cmdbuf, 0, LBS_CMD_BUFFER_SIZE);

lbs_deb_leave(LBS_DEB_HOST);
}
Expand Down Expand Up @@ -1739,7 +1725,7 @@ void lbs_set_cmd_ctrl_node(struct lbs_private *priv,
int lbs_execute_next_command(struct lbs_private *priv)
{
struct cmd_ctrl_node *cmdnode = NULL;
struct cmd_ds_command *cmdptr;
struct cmd_header *cmd;
unsigned long flags;
int ret = 0;

Expand All @@ -1765,22 +1751,21 @@ int lbs_execute_next_command(struct lbs_private *priv)
spin_unlock_irqrestore(&priv->driver_lock, flags);

if (cmdnode) {
cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr;
cmd = cmdnode->cmdbuf;

if (is_command_allowed_in_ps(le16_to_cpu(cmdptr->command))) {
if (is_command_allowed_in_ps(le16_to_cpu(cmd->command))) {
if ((priv->psstate == PS_STATE_SLEEP) ||
(priv->psstate == PS_STATE_PRE_SLEEP)) {
lbs_deb_host(
"EXEC_NEXT_CMD: cannot send cmd 0x%04x in psstate %d\n",
le16_to_cpu(cmdptr->command),
le16_to_cpu(cmd->command),
priv->psstate);
ret = -1;
goto done;
}
lbs_deb_host("EXEC_NEXT_CMD: OK to send command "
"0x%04x in psstate %d\n",
le16_to_cpu(cmdptr->command),
priv->psstate);
"0x%04x in psstate %d\n",
le16_to_cpu(cmd->command), priv->psstate);
} else if (priv->psstate != PS_STATE_FULL_POWER) {
/*
* 1. Non-PS command:
Expand All @@ -1793,8 +1778,7 @@ int lbs_execute_next_command(struct lbs_private *priv)
* otherwise send this command down to firmware
* immediately.
*/
if (cmdptr->command !=
cpu_to_le16(CMD_802_11_PS_MODE)) {
if (cmd->command != cpu_to_le16(CMD_802_11_PS_MODE)) {
/* Prepare to send Exit PS,
* this non PS command will be sent later */
if ((priv->psstate == PS_STATE_SLEEP)
Expand All @@ -1813,8 +1797,7 @@ int lbs_execute_next_command(struct lbs_private *priv)
* PS command. Ignore it if it is not Exit_PS.
* otherwise send it down immediately.
*/
struct cmd_ds_802_11_ps_mode *psm =
&cmdptr->params.psmode;
struct cmd_ds_802_11_ps_mode *psm = (void *)cmd;

lbs_deb_host(
"EXEC_NEXT_CMD: PS cmd, action 0x%02x\n",
Expand Down Expand Up @@ -1848,7 +1831,7 @@ int lbs_execute_next_command(struct lbs_private *priv)
}
list_del(&cmdnode->list);
lbs_deb_host("EXEC_NEXT_CMD: sending command 0x%04x\n",
le16_to_cpu(cmdptr->command));
le16_to_cpu(cmd->command));
DownloadcommandToStation(priv, cmdnode);
} else {
/*
Expand Down Expand Up @@ -2079,7 +2062,6 @@ int __lbs_cmd(struct lbs_private *priv, uint16_t command,
unsigned long callback_arg)
{
struct cmd_ctrl_node *cmdnode;
struct cmd_header *send_cmd;
unsigned long flags;
int ret = 0;

Expand Down Expand Up @@ -2107,20 +2089,19 @@ int __lbs_cmd(struct lbs_private *priv, uint16_t command,
goto done;
}

send_cmd = (struct cmd_header *) cmdnode->bufvirtualaddr;
cmdnode->wait_option = CMD_OPTION_WAITFORRSP;
cmdnode->callback = callback;
cmdnode->callback_arg = callback_arg;

/* Copy the incoming command to the buffer */
memcpy(send_cmd, in_cmd, in_cmd_size);
memcpy(cmdnode->cmdbuf, in_cmd, in_cmd_size);

/* Set sequence number, clean result, move to buffer */
priv->seqnum++;
send_cmd->command = cpu_to_le16(command);
send_cmd->size = cpu_to_le16(in_cmd_size);
send_cmd->seqnum = cpu_to_le16(priv->seqnum);
send_cmd->result = 0;
cmdnode->cmdbuf->command = cpu_to_le16(command);
cmdnode->cmdbuf->size = cpu_to_le16(in_cmd_size);
cmdnode->cmdbuf->seqnum = cpu_to_le16(priv->seqnum);
cmdnode->cmdbuf->result = 0;

lbs_deb_host("PREP_CMD: command 0x%04x\n", command);

Expand Down
14 changes: 7 additions & 7 deletions trunk/drivers/net/wireless/libertas/cmdresp.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,9 @@ static int lbs_ret_802_11_subscribe_event(struct lbs_private *priv,

static inline int handle_cmd_response(struct lbs_private *priv,
unsigned long dummy,
struct cmd_ds_command *resp)
struct cmd_header *cmd_response)
{
struct cmd_ds_command *resp = (struct cmd_ds_command *) cmd_response;
int ret = 0;
unsigned long flags;
uint16_t respcmd = le16_to_cpu(resp->command);
Expand Down Expand Up @@ -673,7 +674,7 @@ static inline int handle_cmd_response(struct lbs_private *priv,
int lbs_process_rx_command(struct lbs_private *priv)
{
u16 respcmd;
struct cmd_ds_command *resp;
struct cmd_header *resp;
int ret = 0;
ulong flags;
u16 result;
Expand All @@ -692,15 +693,14 @@ int lbs_process_rx_command(struct lbs_private *priv)
spin_unlock_irqrestore(&priv->driver_lock, flags);
goto done;
}
resp = (struct cmd_ds_command *)(priv->cur_cmd->bufvirtualaddr);
resp = priv->cur_cmd->cmdbuf;

respcmd = le16_to_cpu(resp->command);
result = le16_to_cpu(resp->result);

lbs_deb_host("CMD_RESP: response 0x%04x, size %d, jiffies %lu\n",
respcmd, priv->upld_len, jiffies);
lbs_deb_hex(LBS_DEB_HOST, "CMD_RESP", priv->cur_cmd->bufvirtualaddr,
priv->upld_len);
lbs_deb_hex(LBS_DEB_HOST, "CMD_RESP", (void *) resp, priv->upld_len);

if (!(respcmd & 0x8000)) {
lbs_deb_host("invalid response!\n");
Expand All @@ -716,7 +716,7 @@ int lbs_process_rx_command(struct lbs_private *priv)
priv->cur_cmd_retcode = result;

if (respcmd == CMD_RET(CMD_802_11_PS_MODE)) {
struct cmd_ds_802_11_ps_mode *psmode = &resp->params.psmode;
struct cmd_ds_802_11_ps_mode *psmode = (void *) resp;
u16 action = le16_to_cpu(psmode->action);

lbs_deb_host(
Expand Down Expand Up @@ -796,7 +796,7 @@ int lbs_process_rx_command(struct lbs_private *priv)

if (priv->cur_cmd && priv->cur_cmd->callback) {
ret = priv->cur_cmd->callback(priv, priv->cur_cmd->callback_arg,
(struct cmd_header *) resp);
resp);
} else
ret = handle_cmd_response(priv, 0, resp);

Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/net/wireless/libertas/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ static inline void lbs_deb_hex(unsigned int grp, const char *prompt, u8 *buf, in
*/

#define MRVDRV_MAX_MULTICAST_LIST_SIZE 32
#define MRVDRV_NUM_OF_CMD_BUFFER 10
#define MRVDRV_SIZE_OF_CMD_BUFFER (2 * 1024)
#define LBS_NUM_CMD_BUFFERS 10
#define LBS_CMD_BUFFER_SIZE (2 * 1024)
#define MRVDRV_MAX_CHANNEL_SIZE 14
#define MRVDRV_ASSOCIATION_TIME_OUT 255
#define MRVDRV_SNAP_HEADER_LEN 8
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/net/wireless/libertas/hostcmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct cmd_ctrl_node {
int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *);
unsigned long callback_arg;
/* command data */
u8 *bufvirtualaddr;
struct cmd_header *cmdbuf;
/* wait queue */
u16 cmdwaitqwoken;
wait_queue_head_t cmdwait_q;
Expand Down
Loading

0 comments on commit 9e7b9d9

Please sign in to comment.