ath10k: add ATH10K_FW_IE_WMI_OP_VERSION
authorKalle Valo <kvalo@qca.qualcomm.com>
Wed, 3 Dec 2014 08:10:08 +0000 (10:10 +0200)
committerKalle Valo <kvalo@qca.qualcomm.com>
Mon, 8 Dec 2014 15:38:35 +0000 (17:38 +0200)
Instead of using feature flags, add new 32 bit variable for managing different
WMI versions. This makes it firmware interface tests a bit less convoluted,
especially when we add one more interface.

Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
drivers/net/wireless/ath/ath10k/core.c
drivers/net/wireless/ath/ath10k/core.h
drivers/net/wireless/ath/ath10k/hw.h

index 6c47c1e2829289f21f48f0ee3e5258c5c59825c8..16f210e0b8334284723d9ef4e50ee2975edb2b94 100644 (file)
@@ -508,7 +508,7 @@ static int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name)
        int ie_id, i, index, bit, ret;
        struct ath10k_fw_ie *hdr;
        const u8 *data;
-       __le32 *timestamp;
+       __le32 *timestamp, *version;
 
        /* first fetch the firmware file (firmware-*.bin) */
        ar->firmware = ath10k_fetch_fw_file(ar, ar->hw_params.fw.dir, name);
@@ -623,6 +623,17 @@ static int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name)
                        ar->otp_len = ie_len;
 
                        break;
+               case ATH10K_FW_IE_WMI_OP_VERSION:
+                       if (ie_len != sizeof(u32))
+                               break;
+
+                       version = (__le32 *)data;
+
+                       ar->wmi.op_version = le32_to_cpup(version);
+
+                       ath10k_dbg(ar, ATH10K_DBG_BOOT, "found fw ie wmi op version %d\n",
+                                  ar->wmi.op_version);
+                       break;
                default:
                        ath10k_warn(ar, "Unknown FW IE: %u\n",
                                    le32_to_cpu(hdr->id));
@@ -871,12 +882,40 @@ static int ath10k_core_init_firmware_features(struct ath10k *ar)
                return -EINVAL;
        }
 
-       if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) {
-               ar->max_num_peers = TARGET_10X_NUM_PEERS;
-               ar->max_num_stations = TARGET_10X_NUM_STATIONS;
-       } else {
+       if (ar->wmi.op_version >= ATH10K_FW_WMI_OP_VERSION_MAX) {
+               ath10k_err(ar, "unsupported WMI OP version (max %d): %d\n",
+                          ATH10K_FW_WMI_OP_VERSION_MAX, ar->wmi.op_version);
+               return -EINVAL;
+       }
+
+       /* Backwards compatibility for firmwares without
+        * ATH10K_FW_IE_WMI_OP_VERSION.
+        */
+       if (ar->wmi.op_version == ATH10K_FW_WMI_OP_VERSION_UNSET) {
+               if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) {
+                       if (test_bit(ATH10K_FW_FEATURE_WMI_10_2, ar->fw_features))
+                               ar->wmi.op_version = ATH10K_FW_WMI_OP_VERSION_10_2;
+                       else
+                               ar->wmi.op_version = ATH10K_FW_WMI_OP_VERSION_10_1;
+               } else {
+                       ar->wmi.op_version = ATH10K_FW_WMI_OP_VERSION_MAIN;
+               }
+       }
+
+       switch (ar->wmi.op_version) {
+       case ATH10K_FW_WMI_OP_VERSION_MAIN:
                ar->max_num_peers = TARGET_NUM_PEERS;
                ar->max_num_stations = TARGET_NUM_STATIONS;
+               break;
+       case ATH10K_FW_WMI_OP_VERSION_10_1:
+       case ATH10K_FW_WMI_OP_VERSION_10_2:
+               ar->max_num_peers = TARGET_10X_NUM_PEERS;
+               ar->max_num_stations = TARGET_10X_NUM_STATIONS;
+               break;
+       case ATH10K_FW_WMI_OP_VERSION_UNSET:
+       case ATH10K_FW_WMI_OP_VERSION_MAX:
+               WARN_ON(1);
+               return -EINVAL;
        }
 
        return 0;
index 44bee8850586e388b80b5675970f9f270be08824..0ae1df65b04871dd1880f66dd6b4e3368c7dc7e2 100644 (file)
@@ -120,6 +120,7 @@ struct ath10k_mem_chunk {
 };
 
 struct ath10k_wmi {
+       enum ath10k_fw_wmi_op_version op_version;
        enum ath10k_htc_ep_id eid;
        struct completion service_ready;
        struct completion unified_ready;
@@ -369,7 +370,7 @@ enum ath10k_fw_features {
        /* wmi_mgmt_rx_hdr contains extra RSSI information */
        ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX = 0,
 
-       /* firmware from 10X branch */
+       /* Firmware from 10X branch. Deprecated, don't use in new code. */
        ATH10K_FW_FEATURE_WMI_10X = 1,
 
        /* firmware support tx frame management over WMI, otherwise it's HTT */
@@ -378,8 +379,9 @@ enum ath10k_fw_features {
        /* Firmware does not support P2P */
        ATH10K_FW_FEATURE_NO_P2P = 3,
 
-       /* Firmware 10.2 feature bit. The ATH10K_FW_FEATURE_WMI_10X feature bit
-        * is required to be set as well.
+       /* Firmware 10.2 feature bit. The ATH10K_FW_FEATURE_WMI_10X feature
+        * bit is required to be set as well. Deprecated, don't use in new
+        * code.
         */
        ATH10K_FW_FEATURE_WMI_10_2 = 4,
 
index dfedfd0e0f344a8b1893de5262de261c5f403e44..5bae90c3db99cc8d6d09b4206cdf821b0f6e60e9 100644 (file)
@@ -58,6 +58,22 @@ enum ath10k_fw_ie_type {
        ATH10K_FW_IE_FEATURES = 2,
        ATH10K_FW_IE_FW_IMAGE = 3,
        ATH10K_FW_IE_OTP_IMAGE = 4,
+
+       /* WMI "operations" interface version, 32 bit value. Supported from
+        * FW API 4 and above.
+        */
+       ATH10K_FW_IE_WMI_OP_VERSION = 5,
+};
+
+enum ath10k_fw_wmi_op_version {
+       ATH10K_FW_WMI_OP_VERSION_UNSET = 0,
+
+       ATH10K_FW_WMI_OP_VERSION_MAIN = 1,
+       ATH10K_FW_WMI_OP_VERSION_10_1 = 2,
+       ATH10K_FW_WMI_OP_VERSION_10_2 = 3,
+
+       /* keep last */
+       ATH10K_FW_WMI_OP_VERSION_MAX,
 };
 
 /* Known pecularities: