iwm - Update alive response handling, add v4 and remove old versions.
authorImre Vadász <imre@vdsz.com>
Fri, 21 Sep 2018 11:43:11 +0000 (13:43 +0200)
committerImre Vadász <imre@vdsz.com>
Sat, 22 Sep 2018 10:23:14 +0000 (12:23 +0200)
sys/dev/netif/iwm/if_iwm.c
sys/dev/netif/iwm/if_iwmreg.h
sys/dev/netif/iwm/if_iwmvar.h

index 1630ca7..6f869b1 100644 (file)
@@ -2771,75 +2771,48 @@ static int
 iwm_alive_fn(struct iwm_softc *sc, struct iwm_rx_packet *pkt, void *data)
 {
        struct iwm_mvm_alive_data *alive_data = data;
-       struct iwm_mvm_alive_resp_ver1 *palive1;
-       struct iwm_mvm_alive_resp_ver2 *palive2;
+       struct iwm_mvm_alive_resp_v3 *palive3;
        struct iwm_mvm_alive_resp *palive;
+       struct iwm_umac_alive *umac;
+       struct iwm_lmac_alive *lmac1;
+       struct iwm_lmac_alive *lmac2 = NULL;
+       uint16_t status;
 
-       if (iwm_rx_packet_payload_len(pkt) == sizeof(*palive1)) {
-               palive1 = (void *)pkt->data;
-
-               sc->support_umac_log = FALSE;
-                sc->error_event_table =
-                        le32toh(palive1->error_event_table_ptr);
-                sc->log_event_table =
-                        le32toh(palive1->log_event_table_ptr);
-                alive_data->scd_base_addr = le32toh(palive1->scd_base_ptr);
-
-                alive_data->valid = le16toh(palive1->status) ==
-                                    IWM_ALIVE_STATUS_OK;
-                IWM_DPRINTF(sc, IWM_DEBUG_RESET,
-                           "Alive VER1 ucode status 0x%04x revision 0x%01X 0x%01X flags 0x%01X\n",
-                            le16toh(palive1->status), palive1->ver_type,
-                             palive1->ver_subtype, palive1->flags);
-       } else if (iwm_rx_packet_payload_len(pkt) == sizeof(*palive2)) {
-               palive2 = (void *)pkt->data;
-               sc->error_event_table =
-                       le32toh(palive2->error_event_table_ptr);
-               sc->log_event_table =
-                       le32toh(palive2->log_event_table_ptr);
-               alive_data->scd_base_addr = le32toh(palive2->scd_base_ptr);
-               sc->umac_error_event_table =
-                        le32toh(palive2->error_info_addr);
-
-               alive_data->valid = le16toh(palive2->status) ==
-                                   IWM_ALIVE_STATUS_OK;
-               if (sc->umac_error_event_table)
-                       sc->support_umac_log = TRUE;
-
-               IWM_DPRINTF(sc, IWM_DEBUG_RESET,
-                           "Alive VER2 ucode status 0x%04x revision 0x%01X 0x%01X flags 0x%01X\n",
-                           le16toh(palive2->status), palive2->ver_type,
-                           palive2->ver_subtype, palive2->flags);
-
-               IWM_DPRINTF(sc, IWM_DEBUG_RESET,
-                           "UMAC version: Major - 0x%x, Minor - 0x%x\n",
-                           palive2->umac_major, palive2->umac_minor);
-       } else if (iwm_rx_packet_payload_len(pkt) == sizeof(*palive)) {
+       if (iwm_rx_packet_payload_len(pkt) == sizeof(*palive)) {
                palive = (void *)pkt->data;
+               umac = &palive->umac_data;
+               lmac1 = &palive->lmac_data[0];
+               lmac2 = &palive->lmac_data[1];
+               status = le16toh(palive->status);
+       } else {
+               palive3 = (void *)pkt->data;
+               umac = &palive3->umac_data;
+               lmac1 = &palive3->lmac_data;
+               status = le16toh(palive3->status);
+       }
+
+       sc->error_event_table[0] = le32toh(lmac1->error_event_table_ptr);
+       if (lmac2)
+               sc->error_event_table[1] =
+                       le32toh(lmac2->error_event_table_ptr);
+       sc->log_event_table = le32toh(lmac1->log_event_table_ptr);
+       sc->umac_error_event_table = le32toh(umac->error_info_addr);
+       alive_data->scd_base_addr = le32toh(lmac1->scd_base_ptr);
+       alive_data->valid = status == IWM_ALIVE_STATUS_OK;
+       if (sc->umac_error_event_table)
+               sc->support_umac_log = TRUE;
 
-               sc->error_event_table =
-                       le32toh(palive->error_event_table_ptr);
-               sc->log_event_table =
-                       le32toh(palive->log_event_table_ptr);
-               alive_data->scd_base_addr = le32toh(palive->scd_base_ptr);
-               sc->umac_error_event_table =
-                       le32toh(palive->error_info_addr);
-
-               alive_data->valid = le16toh(palive->status) ==
-                                   IWM_ALIVE_STATUS_OK;
-               if (sc->umac_error_event_table)
-                       sc->support_umac_log = TRUE;
+       IWM_DPRINTF(sc, IWM_DEBUG_FW,
+                   "Alive ucode status 0x%04x revision 0x%01X 0x%01X\n",
+                   status, lmac1->ver_type, lmac1->ver_subtype);
 
-               IWM_DPRINTF(sc, IWM_DEBUG_RESET,
-                           "Alive VER3 ucode status 0x%04x revision 0x%01X 0x%01X flags 0x%01X\n",
-                           le16toh(palive->status), palive->ver_type,
-                           palive->ver_subtype, palive->flags);
+       if (lmac2)
+               IWM_DPRINTF(sc, IWM_DEBUG_FW, "Alive ucode CDB\n");
 
-               IWM_DPRINTF(sc, IWM_DEBUG_RESET,
-                           "UMAC version: Major - 0x%x, Minor - 0x%x\n",
-                           le32toh(palive->umac_major),
-                           le32toh(palive->umac_minor));
-       }
+       IWM_DPRINTF(sc, IWM_DEBUG_FW,
+                   "UMAC version: Major - 0x%x, Minor - 0x%x\n",
+                   le32toh(umac->umac_major),
+                   le32toh(umac->umac_minor));
 
        return TRUE;
 }
@@ -5078,7 +5051,7 @@ iwm_nic_error(struct iwm_softc *sc)
        uint32_t base;
 
        device_printf(sc->sc_dev, "dumping device error log\n");
-       base = sc->error_event_table;
+       base = sc->error_event_table[0];
        if (base < 0x800000) {
                device_printf(sc->sc_dev,
                    "Invalid error log pointer 0x%08x\n", base);
index ecccbe4..a6ffc21 100644 (file)
@@ -2100,41 +2100,13 @@ enum {
 
 #define IWM_ALIVE_FLG_RFKILL   (1 << 0)
 
-struct iwm_mvm_alive_resp_ver1 {
-       uint16_t status;
-       uint16_t flags;
-       uint8_t ucode_minor;
-       uint8_t ucode_major;
-       uint16_t id;
-       uint8_t api_minor;
-       uint8_t api_major;
-       uint8_t ver_subtype;
-       uint8_t ver_type;
-       uint8_t mac;
-       uint8_t opt;
-       uint16_t reserved2;
-       uint32_t timestamp;
-       uint32_t error_event_table_ptr; /* SRAM address for error log */
-       uint32_t log_event_table_ptr;   /* SRAM address for event log */
-       uint32_t cpu_register_ptr;
-       uint32_t dbgm_config_ptr;
-       uint32_t alive_counter_ptr;
-       uint32_t scd_base_ptr;          /* SRAM address for SCD */
-} __packed; /* IWM_ALIVE_RES_API_S_VER_1 */
-
-struct iwm_mvm_alive_resp_ver2 {
-       uint16_t status;
-       uint16_t flags;
-       uint8_t ucode_minor;
-       uint8_t ucode_major;
-       uint16_t id;
-       uint8_t api_minor;
-       uint8_t api_major;
+struct iwm_lmac_alive {
+       uint32_t ucode_major;
+       uint32_t ucode_minor;
        uint8_t ver_subtype;
        uint8_t ver_type;
        uint8_t mac;
        uint8_t opt;
-       uint16_t reserved2;
        uint32_t timestamp;
        uint32_t error_event_table_ptr; /* SRAM address for error log */
        uint32_t log_event_table_ptr;   /* SRAM address for LMAC event log */
@@ -2144,37 +2116,29 @@ struct iwm_mvm_alive_resp_ver2 {
        uint32_t scd_base_ptr;          /* SRAM address for SCD */
        uint32_t st_fwrd_addr;          /* pointer to Store and forward */
        uint32_t st_fwrd_size;
-       uint8_t umac_minor;             /* UMAC version: minor */
-       uint8_t umac_major;             /* UMAC version: major */
-       uint16_t umac_id;               /* UMAC version: id */
+} __packed; /* UCODE_ALIVE_NTFY_API_S_VER_3 */
+
+struct iwm_umac_alive {
+       uint32_t umac_major;            /* UMAC version: major */
+       uint32_t umac_minor;            /* UMAC version: minor */
        uint32_t error_info_addr;       /* SRAM address for UMAC error log */
        uint32_t dbg_print_buff_addr;
-} __packed; /* ALIVE_RES_API_S_VER_2 */
+} __packed; /* UMAC_ALIVE_DATA_API_S_VER_2 */
 
-struct iwm_mvm_alive_resp {
+struct iwm_mvm_alive_resp_v3 {
        uint16_t status;
        uint16_t flags;
-       uint32_t ucode_minor;
-       uint32_t ucode_major;
-       uint8_t ver_subtype;
-       uint8_t ver_type;
-       uint8_t mac;
-       uint8_t opt;
-       uint32_t timestamp;
-       uint32_t error_event_table_ptr; /* SRAM address for error log */
-       uint32_t log_event_table_ptr;   /* SRAM address for LMAC event log */
-       uint32_t cpu_register_ptr;
-       uint32_t dbgm_config_ptr;
-       uint32_t alive_counter_ptr;
-       uint32_t scd_base_ptr;          /* SRAM address for SCD */
-       uint32_t st_fwrd_addr;          /* pointer to Store and forward */
-       uint32_t st_fwrd_size;
-       uint32_t umac_minor;            /* UMAC version: minor */
-       uint32_t umac_major;            /* UMAC version: major */
-       uint32_t error_info_addr;       /* SRAM address for UMAC error log */
-       uint32_t dbg_print_buff_addr;
+       struct iwm_lmac_alive lmac_data;
+       struct iwm_umac_alive umac_data;
 } __packed; /* ALIVE_RES_API_S_VER_3 */
 
+struct iwm_mvm_alive_resp {
+       uint16_t status;
+       uint16_t flags;
+       struct iwm_lmac_alive lmac_data[2];
+       struct iwm_umac_alive umac_data;
+} __packed; /* ALIVE_RES_API_S_VER_4 */
+
 /* Error response/notification */
 enum {
        IWM_FW_ERR_UNKNOWN_CMD = 0x0,
index 7699056..2e0cc5c 100644 (file)
@@ -537,7 +537,7 @@ struct iwm_softc {
        int                     cmd_hold_nic_awake;
 
        /* Firmware status */
-       uint32_t                error_event_table;
+       uint32_t                error_event_table[2];
        uint32_t                log_event_table;
        uint32_t                umac_error_event_table;
        int                     support_umac_log;