aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/libertas/cmdresp.c
diff options
context:
space:
mode:
authorHolger Schurig <hs4233@mail.mn-solutions.de>2008-04-01 08:50:43 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-04-16 15:59:56 -0400
commit7919b89c8276d657976d4d4d6b7cb58ea1aa08c3 (patch)
tree31fc24e2f8b7d8eeee67347333e078591796d4b7 /drivers/net/wireless/libertas/cmdresp.c
parent98dd6a575928ed9c42130d208e6bfb0f7a914d5a (diff)
libertas: convert libertas driver to use an event/cmdresp queue
This patch (co-developed by Dan Williams and Holger Schurig) uses a kfifo object for events and a swapping buffer scheme for the command response to preserve the zero-copy semantics of the CF driver and keep memory usage low. The main thread should only ever touch the buffer indexed by priv->resp_idx, while the interface code is free to write to the second buffer, then swap priv->resp_idx under the driver spinlock. The firmware specs only permit one in-flight command, so there will only ever be one command response to process at a time. Signed-off-by: Holger Schurig <hs4233@mail.mn-solutions.de> Signed-off-by: Dan Williams <dcbw@redhat.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/libertas/cmdresp.c')
-rw-r--r--drivers/net/wireless/libertas/cmdresp.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/drivers/net/wireless/libertas/cmdresp.c b/drivers/net/wireless/libertas/cmdresp.c
index 245d3c3a9274..5abecb7673e6 100644
--- a/drivers/net/wireless/libertas/cmdresp.c
+++ b/drivers/net/wireless/libertas/cmdresp.c
@@ -384,7 +384,7 @@ static inline int handle_cmd_response(struct lbs_private *priv,
384 return ret; 384 return ret;
385} 385}
386 386
387int lbs_process_rx_command(struct lbs_private *priv) 387int lbs_process_command_response(struct lbs_private *priv, u8 *data, u32 len)
388{ 388{
389 uint16_t respcmd, curcmd; 389 uint16_t respcmd, curcmd;
390 struct cmd_header *resp; 390 struct cmd_header *resp;
@@ -404,14 +404,14 @@ int lbs_process_rx_command(struct lbs_private *priv)
404 goto done; 404 goto done;
405 } 405 }
406 406
407 resp = (void *)priv->upld_buf; 407 resp = (void *)data;
408 curcmd = le16_to_cpu(priv->cur_cmd->cmdbuf->command); 408 curcmd = le16_to_cpu(priv->cur_cmd->cmdbuf->command);
409 respcmd = le16_to_cpu(resp->command); 409 respcmd = le16_to_cpu(resp->command);
410 result = le16_to_cpu(resp->result); 410 result = le16_to_cpu(resp->result);
411 411
412 lbs_deb_cmd("CMD_RESP: response 0x%04x, seq %d, size %d\n", 412 lbs_deb_cmd("CMD_RESP: response 0x%04x, seq %d, size %d\n",
413 respcmd, le16_to_cpu(resp->seqnum), priv->upld_len); 413 respcmd, le16_to_cpu(resp->seqnum), len);
414 lbs_deb_hex(LBS_DEB_CMD, "CMD_RESP", (void *) resp, priv->upld_len); 414 lbs_deb_hex(LBS_DEB_CMD, "CMD_RESP", (void *) resp, len);
415 415
416 if (resp->seqnum != priv->cur_cmd->cmdbuf->seqnum) { 416 if (resp->seqnum != priv->cur_cmd->cmdbuf->seqnum) {
417 lbs_pr_info("Received CMD_RESP with invalid sequence %d (expected %d)\n", 417 lbs_pr_info("Received CMD_RESP with invalid sequence %d (expected %d)\n",
@@ -569,18 +569,13 @@ static int lbs_send_confirmwake(struct lbs_private *priv)
569 return ret; 569 return ret;
570} 570}
571 571
572int lbs_process_event(struct lbs_private *priv) 572int lbs_process_event(struct lbs_private *priv, u32 event)
573{ 573{
574 int ret = 0; 574 int ret = 0;
575 u32 eventcause;
576 575
577 lbs_deb_enter(LBS_DEB_CMD); 576 lbs_deb_enter(LBS_DEB_CMD);
578 577
579 spin_lock_irq(&priv->driver_lock); 578 switch (event) {
580 eventcause = priv->eventcause >> SBI_EVENT_CAUSE_SHIFT;
581 spin_unlock_irq(&priv->driver_lock);
582
583 switch (eventcause) {
584 case MACREG_INT_CODE_LINK_SENSED: 579 case MACREG_INT_CODE_LINK_SENSED:
585 lbs_deb_cmd("EVENT: link sensed\n"); 580 lbs_deb_cmd("EVENT: link sensed\n");
586 break; 581 break;
@@ -696,14 +691,10 @@ int lbs_process_event(struct lbs_private *priv)
696 break; 691 break;
697 692
698 default: 693 default:
699 lbs_pr_alert("EVENT: unknown event id %d\n", eventcause); 694 lbs_pr_alert("EVENT: unknown event id %d\n", event);
700 break; 695 break;
701 } 696 }
702 697
703 spin_lock_irq(&priv->driver_lock);
704 priv->eventcause = 0;
705 spin_unlock_irq(&priv->driver_lock);
706
707 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); 698 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
708 return ret; 699 return ret;
709} 700}