carl9170 firmware: initial WoWLAN support
[carl9170fw.git] / include / shared / fwdesc.h
index cbf2fd129f05620a07b3d92614926eec4e1a8e1f..a4769e9cee7c486e0840b59380a37515cf6e81fe 100644 (file)
@@ -1,7 +1,9 @@
 /*
- * Firmware Descriptor definitions
+ * Shared CARL9170 Header
  *
- * Copyright 2009, 2010, Christian Lamparter <chunkeey@googlemail.com>
+ * Firmware descriptor format
+ *
+ * Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,6 +27,24 @@ enum carl9170fw_feature_list {
        /* Always set */
        CARL9170FW_DUMMY_FEATURE,
 
+       /*
+        * Indicates that this image has special boot block which prevents
+        * legacy drivers to drive the firmware.
+        */
+       CARL9170FW_MINIBOOT,
+
+       /* usb registers are initialized by the firmware */
+       CARL9170FW_USB_INIT_FIRMWARE,
+
+       /* command traps & notifications are send through EP2 */
+       CARL9170FW_USB_RESP_EP2,
+
+       /* usb download (app -> fw) stream */
+       CARL9170FW_USB_DOWN_STREAM,
+
+       /* usb upload (fw -> app) stream */
+       CARL9170FW_USB_UP_STREAM,
+
        /* unusable - reserved to flag non-functional debug firmwares */
        CARL9170FW_UNUSABLE,
 
@@ -46,45 +66,23 @@ enum carl9170fw_feature_list {
        /* Firmware PSM support | CARL9170_CMD_PSM */
        CARL9170FW_PSM,
 
-       /* KEEP LAST */
-       __CARL9170FW_FEATURE_NUM
-};
-
-enum carl9170fw_usb_feature_list {
-       /* Always set */
-       CARL9170FW_USB_DUMMY_FEATURE,
-
-       /*
-        * Indicates that this image has special boot block which prevents
-        * legacy drivers to drive the firmware.
-        */
-       CARL9170FW_USB_MINIBOOT,
-
-       /* usb registers are initialized by the firmware */
-       CARL9170FW_USB_INIT_FIRMWARE,
+       /* Firmware RX filter | CARL9170_CMD_RX_FILTER */
+       CARL9170FW_RX_FILTER,
 
-       /* command traps & notifications are send through EP2 */
-       CARL9170FW_USB_RESP_EP2,
-
-       /* usb download (app -> fw) stream */
-       CARL9170FW_USB_DOWN_STREAM,
-
-       /* usb upload (fw -> app) stream */
-       CARL9170FW_USB_UP_STREAM,
-
-       /* USB Watchdog */
-       CARL9170FW_USB_WATCHDOG,
+       /* Wake up on WLAN */
+       CARL9170FW_WOL,
 
        /* KEEP LAST */
-       __CARL9170FW_USB_FEATURE_NUM
+       __CARL9170FW_FEATURE_NUM
 };
 
 #define OTUS_MAGIC     "OTAR"
-#define USB_MAGIC      "USB\0"
 #define MOTD_MAGIC     "MOTD"
 #define FIX_MAGIC      "FIX\0"
 #define DBG_MAGIC      "DBG\0"
 #define CHK_MAGIC      "CHK\0"
+#define TXSQ_MAGIC     "TXSQ"
+#define WOL_MAGIC      "WOL\0"
 #define LAST_MAGIC     "LAST"
 
 #define CARL9170FW_SET_DAY(d) (((d) - 1) % 31)
@@ -95,8 +93,10 @@ enum carl9170fw_usb_feature_list {
 #define CARL9170FW_GET_MONTH(m) ((((m) / 31) % 12) + 1)
 #define CARL9170FW_GET_YEAR(y) ((y) / 372 + 10)
 
+#define CARL9170FW_MAGIC_SIZE                  4
+
 struct carl9170fw_desc_head {
-       u8      magic[4];
+       u8      magic[CARL9170FW_MAGIC_SIZE];
        __le16 length;
        u8 min_ver;
        u8 cur_ver;
@@ -104,33 +104,24 @@ struct carl9170fw_desc_head {
 #define CARL9170FW_DESC_HEAD_SIZE                      \
        (sizeof(struct carl9170fw_desc_head))
 
-#define CARL9170FW_OTUS_DESC_MIN_VER           2
-#define CARL9170FW_OTUS_DESC_CUR_VER           2
+#define CARL9170FW_OTUS_DESC_MIN_VER           6
+#define CARL9170FW_OTUS_DESC_CUR_VER           7
 struct carl9170fw_otus_desc {
        struct carl9170fw_desc_head head;
-       __le32 fw_feature_set;
+       __le32 feature_set;
+       __le32 fw_address;
        __le32 bcn_addr;
        __le16 bcn_len;
-       u8 api_ver;
-       u8 vif_num;
-} __packed;
-#define CARL9170FW_OTUS_DESC_SIZE                      \
-       (sizeof(struct carl9170fw_otus_desc))
-
-#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;
-       __le32 fw_address;
+       __le16 miniboot_size;
        __le16 tx_frag_len;
        __le16 rx_max_frame_len;
-       __le16 miniboot_size;
        u8 tx_descs;
        u8 cmd_bufs;
+       u8 api_ver;
+       u8 vif_num;
 } __packed;
-#define CARL9170FW_USB_DESC_SIZE                       \
-       (sizeof(struct carl9170fw_usb_desc))
+#define CARL9170FW_OTUS_DESC_SIZE                      \
+       (sizeof(struct carl9170fw_otus_desc))
 
 #define CARL9170FW_MOTD_STRING_LEN                     24
 #define CARL9170FW_MOTD_RELEASE_LEN                    20
@@ -161,7 +152,7 @@ struct carl9170fw_fix_desc {
        (sizeof(struct carl9170fw_fix_desc))
 
 #define CARL9170FW_DBG_DESC_MIN_VER                    1
-#define CARL9170FW_DBG_DESC_CUR_VER                    2
+#define CARL9170FW_DBG_DESC_CUR_VER                    3
 struct carl9170fw_dbg_desc {
        struct carl9170fw_desc_head head;
 
@@ -169,6 +160,7 @@ struct carl9170fw_dbg_desc {
        __le32 counter_addr;
        __le32 rx_total_addr;
        __le32 rx_overrun_addr;
+       __le32 rx_filter;
 
        /* Put your debugging definitions here */
 } __packed;
@@ -185,6 +177,26 @@ struct carl9170fw_chk_desc {
 #define CARL9170FW_CHK_DESC_SIZE                       \
        (sizeof(struct carl9170fw_chk_desc))
 
+#define CARL9170FW_TXSQ_DESC_MIN_VER                   1
+#define CARL9170FW_TXSQ_DESC_CUR_VER                   1
+struct carl9170fw_txsq_desc {
+       struct carl9170fw_desc_head head;
+
+       __le32 seq_table_addr;
+} __packed;
+#define CARL9170FW_TXSQ_DESC_SIZE                      \
+       (sizeof(struct carl9170fw_txsq_desc))
+
+#define CARL9170FW_WOL_DESC_MIN_VER                    1
+#define CARL9170FW_WOL_DESC_CUR_VER                    1
+struct carl9170fw_wol_desc {
+       struct carl9170fw_desc_head head;
+
+       __le32 supported_triggers;      /* CARL9170_WOL_ */
+} __packed;
+#define CARL9170FW_WOL_DESC_SIZE                       \
+       (sizeof(struct carl9170fw_wol_desc))
+
 #define CARL9170FW_LAST_DESC_MIN_VER                   1
 #define CARL9170FW_LAST_DESC_CUR_VER                   2
 struct carl9170fw_last_desc {
@@ -204,8 +216,8 @@ struct carl9170fw_last_desc {
        }
 
 static inline void carl9170fw_fill_desc(struct carl9170fw_desc_head *head,
-                                        u8 magic[4], __le16 length,
-                                        u8 min_ver, u8 cur_ver)
+                                        u8 magic[CARL9170FW_MAGIC_SIZE],
+                                        __le16 length, u8 min_ver, u8 cur_ver)
 {
        head->magic[0] = magic[0];
        head->magic[1] = magic[1];
@@ -219,7 +231,7 @@ static inline void carl9170fw_fill_desc(struct carl9170fw_desc_head *head,
 
 #define carl9170fw_for_each_hdr(desc, fw_desc)                         \
        for (desc = fw_desc;                                            \
-            memcmp(desc->magic, LAST_MAGIC, 4) &&                      \
+            memcmp(desc->magic, LAST_MAGIC, CARL9170FW_MAGIC_SIZE) &&  \
             le16_to_cpu(desc->length) >= CARL9170FW_DESC_HEAD_SIZE &&  \
             le16_to_cpu(desc->length) < CARL9170FW_DESC_MAX_LENGTH;    \
             desc = (void *)((unsigned long)desc + le16_to_cpu(desc->length)))
@@ -233,8 +245,8 @@ static inline bool carl9170fw_supports(__le32 list, u8 feature)
 }
 
 static inline bool carl9170fw_desc_cmp(const struct carl9170fw_desc_head *head,
-                                      const u8 descid[4], u16 min_len,
-                                      u8 compatible_revision)
+                                      const u8 descid[CARL9170FW_MAGIC_SIZE],
+                                      u16 min_len, u8 compatible_revision)
 {
        if (descid[0] == head->magic[0] && descid[1] == head->magic[1] &&
            descid[2] == head->magic[2] && descid[3] == head->magic[3] &&