carl9170 firmware: implement command sequence counter
authorChristian Lamparter <chunkeey@googlemail.com>
Thu, 29 Jul 2010 12:51:28 +0000 (14:51 +0200)
committerChristian Lamparter <chunkeey@googlemail.com>
Sat, 31 Jul 2010 20:11:45 +0000 (22:11 +0200)
The sequence is useful to detect the loss of a command
response/trap.

Signed-off-by: Christian Lamparter <chunkeey@googlemail.com>
carlfw/src/cmd.c
carlfw/src/fw.c
carlfw/usb/main.c
include/shared/fwdesc.h
tools/src/fwinfo.c

index f5bbad86f8e5393083881f3b5c7f5129c9a56e72..7652214f476a5d4a0df9298bc80889c626c78e3a 100644 (file)
@@ -37,7 +37,10 @@ void handle_cmd(struct carl9170_rsp *resp)
        unsigned int i;
 
        /* copies cmd, len and extra fields */
-       resp->hdr.hdr_data = cmd->hdr.hdr_data;
+       resp->hdr.len = cmd->hdr.len;
+       resp->hdr.cmd = cmd->hdr.cmd;
+       resp->hdr.ext = cmd->hdr.ext;
+       resp->hdr.seq |= cmd->hdr.seq;
 
        switch (cmd->hdr.cmd) {
        case CARL9170_CMD_RREG:
index 00dd221ae93dd97d2b8941bab8096fb2f859d6cf..7c3310627a8b2ea80e2b71a5f0d9639613fb397b 100644 (file)
@@ -81,6 +81,7 @@ const struct carl9170_firmware_descriptor __section(fwdsc) carl9170fw_desc = {
 
             .miniboot_size = cpu_to_le16(0),
             .tx_descs = AR9170_TX_BLOCK_NUMBER,
+            .cmd_bufs = CARL9170_INT_RQ_CACHES,
             .rx_max_frame_len = cpu_to_le16(CONFIG_CARL9170FW_RX_FRAME_LEN),
             .tx_frag_len = cpu_to_le16(AR9170_BLOCK_SIZE),
             .fw_address = cpu_to_le32(AR9170_PRAM_OFFSET),
index d07eb25272c7ee3fc1dc54a9be4e5300ce74928a..1429607f891a1a7514457d797d247b3f669d6736 100644 (file)
@@ -65,7 +65,14 @@ static struct carl9170_rsp *get_int_buf(void)
 {
        struct carl9170_rsp *tmp;
 
-       tmp = &fw.usb.int_buf[fw.usb.int_tail_index++];
+       /* fetch the _oldest_ buffer from the ring */
+       tmp = &fw.usb.int_buf[fw.usb.int_tail_index];
+
+       /* assign a unique sequence for every response/trap */
+       tmp->hdr.seq = fw.usb.int_tail_index;
+
+       fw.usb.int_tail_index++;
+
        fw.usb.int_tail_index %= CARL9170_INT_RQ_CACHES;
        if (fw.usb.int_pending != CARL9170_INT_RQ_CACHES)
                fw.usb.int_pending++;
index c079b3371e13c7759d315530826fdb9ff5408b89..cbf2fd129f05620a07b3d92614926eec4e1a8e1f 100644 (file)
@@ -117,8 +117,8 @@ struct carl9170fw_otus_desc {
 #define CARL9170FW_OTUS_DESC_SIZE                      \
        (sizeof(struct carl9170fw_otus_desc))
 
-#define CARL9170FW_USB_DESC_MIN_VER            2
-#define CARL9170FW_USB_DESC_CUR_VER            2
+#define CARL9170FW_USB_DESC_MIN_VER            3
+#define CARL9170FW_USB_DESC_CUR_VER            3
 struct carl9170fw_usb_desc {
        struct carl9170fw_desc_head head;
        __le32 usb_feature_set;
@@ -127,7 +127,7 @@ struct carl9170fw_usb_desc {
        __le16 rx_max_frame_len;
        __le16 miniboot_size;
        u8 tx_descs;
-       u8 free;
+       u8 cmd_bufs;
 } __packed;
 #define CARL9170FW_USB_DESC_SIZE                       \
        (sizeof(struct carl9170fw_usb_desc))
index 1e64c5ba5fe633a5794f8a62773b0ba7e2714c59..28ddaca90ef72c4d6617d5c7487a49d4906124d6 100644 (file)
@@ -118,6 +118,7 @@ static void show_usb_desc(const struct carl9170fw_desc_head *head,
                usb->tx_frag_len, usb->tx_descs);
        fprintf(stdout, "\t=> %d Bytes are reserved for the TX queues\n",
                usb->tx_frag_len * usb->tx_descs);
+       fprintf(stdout, "\tCommand response buffers:%d\n", usb->cmd_bufs);
        fprintf(stdout, "\tMax. RX stream block size:%d Bytes\n",
                usb->rx_max_frame_len);
        fprintf(stdout, "\tFirmware upload pointer: 0x%x\n",