From: Christian Lamparter Date: Thu, 29 Jul 2010 12:51:28 +0000 (+0200) Subject: carl9170 firmware: implement command sequence counter X-Git-Tag: 1.7.4~2 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=acca5dfdf46f522105f8181c8aff4392eecce8de;p=carl9170fw.git carl9170 firmware: implement command sequence counter The sequence is useful to detect the loss of a command response/trap. Signed-off-by: Christian Lamparter --- diff --git a/carlfw/src/cmd.c b/carlfw/src/cmd.c index f5bbad8..7652214 100644 --- a/carlfw/src/cmd.c +++ b/carlfw/src/cmd.c @@ -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: diff --git a/carlfw/src/fw.c b/carlfw/src/fw.c index 00dd221..7c33106 100644 --- a/carlfw/src/fw.c +++ b/carlfw/src/fw.c @@ -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), diff --git a/carlfw/usb/main.c b/carlfw/usb/main.c index d07eb25..1429607 100644 --- a/carlfw/usb/main.c +++ b/carlfw/usb/main.c @@ -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++; diff --git a/include/shared/fwdesc.h b/include/shared/fwdesc.h index c079b33..cbf2fd1 100644 --- a/include/shared/fwdesc.h +++ b/include/shared/fwdesc.h @@ -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)) diff --git a/tools/src/fwinfo.c b/tools/src/fwinfo.c index 1e64c5b..28ddaca 100644 --- a/tools/src/fwinfo.c +++ b/tools/src/fwinfo.c @@ -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",