This diff addresses some of my nitpicks in iwm:

Move some declarations to if_iwmreg.h so we can use iwm_phy_db_* prototypes.
Remove redundant declaration of iwm_send_phy_db_data().
Remove pointless iwm_fw_alive(); just call iwm_post_alive() directly.
Simplify iwm_prepare_card_hw() and iwm_mvm_add_sta().
Return timeout error from iwm_apm_init().
Print a message when init (i.e. boot) firmware fails to load.
Remove some commented-out code which wouldn't compile anyway.
Move iwm_mvm_tx_fifo to if_iwmreg.h and remove an unused macro.

Index: if_iwm.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/if_iwm.c,v
retrieving revision 1.79
diff -u -p -r1.79 if_iwm.c
--- if_iwm.c    13 Apr 2016 10:34:32 -0000      1.79
+++ if_iwm.c    17 May 2016 16:43:53 -0000
@@ -261,12 +261,10 @@ int       iwm_nic_tx_init(struct iwm_softc *);
 int    iwm_nic_init(struct iwm_softc *);
 void   iwm_enable_txq(struct iwm_softc *, int, int);
 int    iwm_post_alive(struct iwm_softc *);
-#ifdef notyet
 struct iwm_phy_db_entry *iwm_phy_db_get_section(struct iwm_softc *,
                                        enum iwm_phy_db_section_type, uint16_t);
 int    iwm_phy_db_set_section(struct iwm_softc *,
                                struct iwm_calib_res_notif_phy_db *);
-#endif
 int    iwm_is_valid_channel(uint16_t);
 uint8_t        iwm_ch_id_to_ch_index(uint16_t);
 uint16_t iwm_channel_id_to_papd(uint16_t);
@@ -274,11 +272,8 @@ uint16_t iwm_channel_id_to_txp(struct iw
 int    iwm_phy_db_get_section_data(struct iwm_softc *, uint32_t, uint8_t **,
                                        uint16_t *, uint16_t);
 int    iwm_send_phy_db_cmd(struct iwm_softc *, uint16_t, uint16_t, void *);
-#ifdef notyet
 int    iwm_phy_db_send_all_channel_groups(struct iwm_softc *,
                enum iwm_phy_db_section_type, uint8_t);
-#endif
-int    iwm_send_phy_db_data(struct iwm_softc *);
 int    iwm_send_phy_db_data(struct iwm_softc *);
 void   iwm_mvm_te_v2_to_v1(const struct iwm_time_event_cmd_v2 *,
                                struct iwm_time_event_cmd_v1 *);
@@ -321,7 +316,6 @@ int iwm_firmware_load_chunk(struct iwm_s
                                uint32_t);
 int    iwm_load_firmware(struct iwm_softc *, enum iwm_ucode_type);
 int    iwm_start_fw(struct iwm_softc *, enum iwm_ucode_type);
-int    iwm_fw_alive(struct iwm_softc *, uint32_t);
 int    iwm_send_tx_ant_cfg(struct iwm_softc *, uint8_t);
 int    iwm_send_phy_cfg_cmd(struct iwm_softc *);
 int    iwm_mvm_load_ucode_wait_alive(struct iwm_softc *, enum iwm_ucode_type);
@@ -1318,11 +1312,12 @@ iwm_set_hw_ready(struct iwm_softc *sc)
 int
 iwm_prepare_card_hw(struct iwm_softc *sc)
 {
-       int rv = 0;
        int t = 0;
 
        if (iwm_set_hw_ready(sc))
-               goto out;
+               return 0;
+
+       DELAY(100);
 
        /* If HW is not ready, prepare the conditions to check again */
        IWM_SETBITS(sc, IWM_CSR_HW_IF_CONFIG_REG,
@@ -1330,15 +1325,12 @@ iwm_prepare_card_hw(struct iwm_softc *sc
 
        do {
                if (iwm_set_hw_ready(sc))
-                       goto out;
+                       return 0;
                DELAY(200);
                t += 200;
        } while (t < 150000);
 
-       rv = ETIMEDOUT;
-
- out:
-       return rv;
+       return ETIMEDOUT;
 }
 
 void
@@ -1417,6 +1409,7 @@ iwm_apm_init(struct iwm_softc *sc)
            IWM_CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000)) {
                printf("%s: timeout waiting for clock stabilization\n",
                    DEVNAME(sc));
+               error = ETIMEDOUT;
                goto out;
        }
 
@@ -1732,14 +1725,6 @@ iwm_nic_init(struct iwm_softc *sc)
        return 0;
 }
 
-enum iwm_mvm_tx_fifo {
-       IWM_MVM_TX_FIFO_BK = 0,
-       IWM_MVM_TX_FIFO_BE,
-       IWM_MVM_TX_FIFO_VI,
-       IWM_MVM_TX_FIFO_VO,
-       IWM_MVM_TX_FIFO_MCAST = 5,
-};
-
 const uint8_t iwm_mvm_ac_to_tx_fifo[] = {
        IWM_MVM_TX_FIFO_VO,
        IWM_MVM_TX_FIFO_VI,
@@ -1847,45 +1832,6 @@ iwm_post_alive(struct iwm_softc *sc)
 }
 
 /*
- * PHY db
- */
-
-enum iwm_phy_db_section_type {
-       IWM_PHY_DB_CFG = 1,
-       IWM_PHY_DB_CALIB_NCH,
-       IWM_PHY_DB_UNUSED,
-       IWM_PHY_DB_CALIB_CHG_PAPD,
-       IWM_PHY_DB_CALIB_CHG_TXP,
-       IWM_PHY_DB_MAX
-};
-
-#define IWM_PHY_DB_CMD 0x6c /* TEMP API - The actual is 0x8c */
-
-/*
- * phy db - configure operational ucode
- */
-struct iwm_phy_db_cmd {
-       uint16_t type;
-       uint16_t length;
-       uint8_t data[];
-} __packed;
-
-/* for parsing of tx power channel group data that comes from the firmware*/
-struct iwm_phy_db_chg_txp {
-       uint32_t space;
-       uint16_t max_channel_idx;
-} __packed;
-
-/*
- * phy db - Receive phy db chunk after calibrations
- */
-struct iwm_calib_res_notif_phy_db {
-       uint16_t type;
-       uint16_t length;
-       uint8_t data[];
-} __packed;
-
-/*
  * get phy db section: returns a pointer to a phy db section specified by
  * type and channel group id.
  */
@@ -2914,12 +2860,6 @@ iwm_start_fw(struct iwm_softc *sc, enum 
 }
 
 int
-iwm_fw_alive(struct iwm_softc *sc, uint32_t sched_base)
-{
-       return iwm_post_alive(sc);
-}
-
-int
 iwm_send_tx_ant_cfg(struct iwm_softc *sc, uint8_t valid_tx_ant)
 {
        struct iwm_tx_ant_cfg_cmd tx_ant_cmd = {
@@ -2965,7 +2905,7 @@ iwm_mvm_load_ucode_wait_alive(struct iwm
                return error;
        }
 
-       return iwm_fw_alive(sc, sc->sched_base);
+       return iwm_post_alive(sc);
 }
 
 /*
@@ -2986,8 +2926,10 @@ iwm_run_init_mvm_ucode(struct iwm_softc 
 
        sc->sc_init_complete = 0;
        if ((error = iwm_mvm_load_ucode_wait_alive(sc,
-           IWM_UCODE_TYPE_INIT)) != 0)
+           IWM_UCODE_TYPE_INIT)) != 0) {
+               printf("%s: failed to load init firmware\n", DEVNAME(sc));
                return error;
+       }
 
        if (justnvm) {
                if ((error = iwm_nvm_init(sc)) != 0) {
@@ -3734,8 +3676,6 @@ iwm_mvm_send_cmd_status(struct iwm_softc
        struct iwm_cmd_response *resp;
        int error, resp_len;
 
-       //lockdep_assert_held(&mvm->mutex);
-
        KASSERT((cmd->flags & IWM_CMD_WANT_SKB) == 0);
        cmd->flags |= IWM_CMD_SYNC | IWM_CMD_WANT_SKB;
 
@@ -4282,30 +4222,6 @@ iwm_mvm_power_log(struct iwm_softc *sc, 
                DPRINTF(("Disable power management\n"));
                return;
        }
-       KASSERT(0);
-
-#if 0
-       DPRINTF(mvm, "Rx timeout = %u usec\n",
-                       le32_to_cpu(cmd->rx_data_timeout));
-       DPRINTF(mvm, "Tx timeout = %u usec\n",
-                       le32_to_cpu(cmd->tx_data_timeout));
-       if (cmd->flags & cpu_to_le16(IWM_POWER_FLAGS_SKIP_OVER_DTIM_MSK))
-               DPRINTF(mvm, "DTIM periods to skip = %u\n",
-                               cmd->skip_dtim_periods);
-       if (cmd->flags & cpu_to_le16(IWM_POWER_FLAGS_LPRX_ENA_MSK))
-               DPRINTF(mvm, "LP RX RSSI threshold = %u\n",
-                               cmd->lprx_rssi_threshold);
-       if (cmd->flags & cpu_to_le16(IWM_POWER_FLAGS_ADVANCE_PM_ENA_MSK)) {
-               DPRINTF(mvm, "uAPSD enabled\n");
-               DPRINTF(mvm, "Rx timeout (uAPSD) = %u usec\n",
-                               le32_to_cpu(cmd->rx_data_timeout_uapsd));
-               DPRINTF(mvm, "Tx timeout (uAPSD) = %u usec\n",
-                               le32_to_cpu(cmd->tx_data_timeout_uapsd));
-               DPRINTF(mvm, "QNDP TID = %d\n", cmd->qndp_tid);
-               DPRINTF(mvm, "ACs flags = 0x%x\n", cmd->uapsd_ac_flags);
-               DPRINTF(mvm, "Max SP = %d\n", cmd->uapsd_max_sp);
-       }
-#endif
 }
 
 void
@@ -4530,13 +4446,7 @@ iwm_mvm_sta_send_to_fw(struct iwm_softc 
 int
 iwm_mvm_add_sta(struct iwm_softc *sc, struct iwm_node *in)
 {
-       int ret;
-
-       ret = iwm_mvm_sta_send_to_fw(sc, in, 0);
-       if (ret)
-               return ret;
-
-       return 0;
+       return iwm_mvm_sta_send_to_fw(sc, in, 0);
 }
 
 int
Index: if_iwmreg.h
===================================================================
RCS file: /cvs/src/sys/dev/pci/if_iwmreg.h,v
retrieving revision 1.10
diff -u -p -r1.10 if_iwmreg.h
--- if_iwmreg.h 7 Feb 2016 12:16:24 -0000       1.10
+++ if_iwmreg.h 17 May 2016 16:43:23 -0000
@@ -521,7 +521,7 @@ enum iwm_dtd_diode_reg {
 };
 
 /**
- * enum iwl_ucode_tlv_flag - ucode API flags
+ * enum iwm_ucode_tlv_flag - ucode API flags
  * @IWM_UCODE_TLV_FLAGS_PAN: This is PAN capable microcode; this previously
  *     was a separate TLV but moved here to save space.
  * @IWM_UCODE_TLV_FLAGS_NEWSCAN: new uCode scan behaviour on hidden SSID,
@@ -1469,7 +1469,14 @@ enum {
        IWM_MVM_CMD_QUEUE = 9,
 };
 
-#define IWM_MVM_CMD_FIFO       7
+enum iwm_mvm_tx_fifo {
+       IWM_MVM_TX_FIFO_BK = 0,
+       IWM_MVM_TX_FIFO_BE,
+       IWM_MVM_TX_FIFO_VI,
+       IWM_MVM_TX_FIFO_VO,
+       IWM_MVM_TX_FIFO_MCAST = 5,
+       IWM_MVM_TX_FIFO_CMD = 7,
+};
 
 #define IWM_MVM_STATION_COUNT  16
 
@@ -1690,6 +1697,45 @@ struct iwm_phy_cfg_cmd {
 #define IWM_PHY_CFG_RX_CHAIN_A (1 << 12)
 #define IWM_PHY_CFG_RX_CHAIN_B (1 << 13)
 #define IWM_PHY_CFG_RX_CHAIN_C (1 << 14)
+
+/*
+ * PHY db
+ */
+
+enum iwm_phy_db_section_type {
+       IWM_PHY_DB_CFG = 1,
+       IWM_PHY_DB_CALIB_NCH,
+       IWM_PHY_DB_UNUSED,
+       IWM_PHY_DB_CALIB_CHG_PAPD,
+       IWM_PHY_DB_CALIB_CHG_TXP,
+       IWM_PHY_DB_MAX
+};
+
+#define IWM_PHY_DB_CMD 0x6c /* TEMP API - The actual is 0x8c */
+
+/*
+ * phy db - configure operational ucode
+ */
+struct iwm_phy_db_cmd {
+       uint16_t type;
+       uint16_t length;
+       uint8_t data[];
+} __packed;
+
+/* for parsing of tx power channel group data that comes from the firmware*/
+struct iwm_phy_db_chg_txp {
+       uint32_t space;
+       uint16_t max_channel_idx;
+} __packed;
+
+/*
+ * phy db - Receive phy db chunk after calibrations
+ */
+struct iwm_calib_res_notif_phy_db {
+       uint16_t type;
+       uint16_t length;
+       uint8_t data[];
+} __packed;
 
 
 /* Target of the IWM_NVM_ACCESS_CMD */

Reply via email to