Skip to content

Commit a3ebb03

Browse files
imitsyanko-qtnKalle Valo
authored andcommitted
qtnfmac: use MAJOR.MINOR format for firmware protocol
Use MAJOR.MINOR format for QLink firmware protocol. MAJOR part is incremented when backward compatibility is broken. Normally this part should not be incremented unless there is a good reason for that. MINOR part is incremented each time when new features are added to qlink.h, e.g. new TLVs, events, commands. These changes should not break backward compatibility. For instance, older firmware versions may not be able to parse new flags or send new types of events, but this does not impact normal system operations. As part of initialization sequence, driver requests protocol version from firmware and refuses to start in case there is a mismatch in MAJOR part of the version. Signed-off-by: Igor Mitsyanko <igor.mitsyanko.os@quantenna.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
1 parent 346bdd8 commit a3ebb03

4 files changed

Lines changed: 86 additions & 33 deletions

File tree

‎drivers/net/wireless/quantenna/qtnfmac/commands.c‎

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,6 @@ qtnf_cmd_resp_proc_hw_info(struct qtnf_bus *bus,
900900
hwinfo->num_mac = resp->num_mac;
901901
hwinfo->mac_bitmap = resp->mac_bitmap;
902902
hwinfo->fw_ver = le32_to_cpu(resp->fw_ver);
903-
hwinfo->ql_proto_ver = le16_to_cpu(resp->ql_proto_ver);
904903
hwinfo->total_tx_chain = resp->total_tx_chain;
905904
hwinfo->total_rx_chain = resp->total_rx_chain;
906905
hwinfo->hw_capab = le32_to_cpu(resp->hw_capab);
@@ -954,25 +953,29 @@ qtnf_cmd_resp_proc_hw_info(struct qtnf_bus *bus,
954953
tlv = (struct qlink_tlv_hdr *)(tlv->val + tlv_value_len);
955954
}
956955

957-
pr_info("fw_version=%d, MACs map %#x, chains Tx=%u Rx=%u, capab=0x%x\n",
958-
hwinfo->fw_ver, hwinfo->mac_bitmap,
959-
hwinfo->total_tx_chain, hwinfo->total_rx_chain,
960-
hwinfo->hw_capab);
961-
962-
pr_info("\nBuild name: %s" \
963-
"\nBuild revision: %s" \
964-
"\nBuild type: %s" \
965-
"\nBuild label: %s" \
966-
"\nBuild timestamp: %lu" \
967-
"\nPlatform ID: %lu" \
968-
"\nHardware ID: %s" \
969-
"\nCalibration version: %s" \
970-
"\nU-Boot version: %s" \
971-
"\nHardware version: 0x%08x\n",
956+
pr_info("\nBuild name: %s\n"
957+
"Build revision: %s\n"
958+
"Build type: %s\n"
959+
"Build label: %s\n"
960+
"Build timestamp: %lu\n"
961+
"Platform ID: %lu\n"
962+
"Hardware ID: %s\n"
963+
"Calibration version: %s\n"
964+
"U-Boot version: %s\n"
965+
"Hardware version: 0x%08x\n"
966+
"Qlink ver: %u.%u\n"
967+
"MACs map: %#x\n"
968+
"Chains Rx-Tx: %ux%u\n"
969+
"FW version: 0x%x\n",
972970
bld_name, bld_rev, bld_type, bld_label,
973971
(unsigned long)bld_tmstamp,
974972
(unsigned long)plat_id,
975-
hw_id, calibration_ver, uboot_ver, hw_ver);
973+
hw_id, calibration_ver, uboot_ver, hw_ver,
974+
QLINK_VER_MAJOR(bus->hw_info.ql_proto_ver),
975+
QLINK_VER_MINOR(bus->hw_info.ql_proto_ver),
976+
hwinfo->mac_bitmap,
977+
hwinfo->total_rx_chain, hwinfo->total_tx_chain,
978+
hwinfo->fw_ver);
976979

977980
strlcpy(hwinfo->fw_version, bld_label, sizeof(hwinfo->fw_version));
978981
hwinfo->hw_version = hw_ver;
@@ -1866,23 +1869,35 @@ int qtnf_cmd_send_update_phy_params(struct qtnf_wmac *mac, u32 changed)
18661869

18671870
int qtnf_cmd_send_init_fw(struct qtnf_bus *bus)
18681871
{
1872+
struct sk_buff *resp_skb = NULL;
1873+
struct qlink_resp_init_fw *resp;
1874+
struct qlink_cmd_init_fw *cmd;
18691875
struct sk_buff *cmd_skb;
1870-
int ret = 0;
1876+
size_t info_len = 0;
1877+
int ret;
18711878

18721879
cmd_skb = qtnf_cmd_alloc_new_cmdskb(QLINK_MACID_RSVD, QLINK_VIFID_RSVD,
18731880
QLINK_CMD_FW_INIT,
1874-
sizeof(struct qlink_cmd));
1881+
sizeof(*cmd));
18751882
if (!cmd_skb)
18761883
return -ENOMEM;
18771884

1885+
cmd = (struct qlink_cmd_init_fw *)cmd_skb->data;
1886+
cmd->qlink_proto_ver = cpu_to_le32(QLINK_PROTO_VER);
1887+
18781888
qtnf_bus_lock(bus);
1879-
ret = qtnf_cmd_send(bus, cmd_skb);
1889+
ret = qtnf_cmd_send_with_reply(bus, cmd_skb, &resp_skb,
1890+
sizeof(*resp), &info_len);
1891+
qtnf_bus_unlock(bus);
1892+
18801893
if (ret)
18811894
goto out;
18821895

1883-
out:
1884-
qtnf_bus_unlock(bus);
1896+
resp = (struct qlink_resp_init_fw *)resp_skb->data;
1897+
bus->hw_info.ql_proto_ver = le32_to_cpu(resp->qlink_proto_ver);
18851898

1899+
out:
1900+
consume_skb(resp_skb);
18861901
return ret;
18871902
}
18881903

‎drivers/net/wireless/quantenna/qtnfmac/core.c‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -756,20 +756,22 @@ int qtnf_core_attach(struct qtnf_bus *bus)
756756
goto error;
757757
}
758758

759+
if (QLINK_VER_MAJOR(bus->hw_info.ql_proto_ver) !=
760+
QLINK_PROTO_VER_MAJOR) {
761+
pr_err("qlink driver vs FW version mismatch: %u vs %u\n",
762+
QLINK_PROTO_VER_MAJOR,
763+
QLINK_VER_MAJOR(bus->hw_info.ql_proto_ver));
764+
ret = -EPROTONOSUPPORT;
765+
goto error;
766+
}
767+
759768
bus->fw_state = QTNF_FW_STATE_ACTIVE;
760769
ret = qtnf_cmd_get_hw_info(bus);
761770
if (ret) {
762771
pr_err("failed to get HW info: %d\n", ret);
763772
goto error;
764773
}
765774

766-
if (bus->hw_info.ql_proto_ver != QLINK_PROTO_VER) {
767-
pr_err("qlink version mismatch %u != %u\n",
768-
QLINK_PROTO_VER, bus->hw_info.ql_proto_ver);
769-
ret = -EPROTONOSUPPORT;
770-
goto error;
771-
}
772-
773775
if ((bus->hw_info.hw_capab & QLINK_HW_CAPAB_HW_BRIDGE) &&
774776
bus->bus_ops->data_tx_use_meta_set)
775777
bus->bus_ops->data_tx_use_meta_set(bus, true);

‎drivers/net/wireless/quantenna/qtnfmac/core.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ struct qtnf_wmac {
117117
};
118118

119119
struct qtnf_hw_info {
120-
u16 ql_proto_ver;
120+
u32 ql_proto_ver;
121121
u8 num_mac;
122122
u8 mac_bitmap;
123123
u32 fw_ver;

‎drivers/net/wireless/quantenna/qtnfmac/qlink.h‎

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,18 @@
66

77
#include <linux/ieee80211.h>
88

9-
#define QLINK_PROTO_VER 16
9+
#define QLINK_PROTO_VER_MAJOR_M 0xFFFF
10+
#define QLINK_PROTO_VER_MAJOR_S 16
11+
#define QLINK_PROTO_VER_MINOR_M 0xFFFF
12+
#define QLINK_VER_MINOR(_ver) ((_ver) & QLINK_PROTO_VER_MINOR_M)
13+
#define QLINK_VER_MAJOR(_ver) \
14+
(((_ver) >> QLINK_PROTO_VER_MAJOR_S) & QLINK_PROTO_VER_MAJOR_M)
15+
#define QLINK_VER(_maj, _min) (((_maj) << QLINK_PROTO_VER_MAJOR_S) | (_min))
16+
17+
#define QLINK_PROTO_VER_MAJOR 18
18+
#define QLINK_PROTO_VER_MINOR 0
19+
#define QLINK_PROTO_VER \
20+
QLINK_VER(QLINK_PROTO_VER_MAJOR, QLINK_PROTO_VER_MINOR)
1021

1122
#define QLINK_MACID_RSVD 0xFF
1223
#define QLINK_VIFID_RSVD 0xFF
@@ -326,6 +337,23 @@ struct qlink_cmd {
326337
u8 vifid;
327338
} __packed;
328339

340+
/**
341+
* struct qlink_cmd_init_fw - data for QLINK_CMD_FW_INIT
342+
*
343+
* Initialize firmware based on specified host configuration. This is the first
344+
* command sent to wifi card and it's fixed part should never be changed, any
345+
* additions must be done by appending TLVs.
346+
* If wifi card can not operate with a specified parameters it will return
347+
* error.
348+
*
349+
* @qlink_proto_ver: QLINK protocol version used by host driver.
350+
*/
351+
struct qlink_cmd_init_fw {
352+
struct qlink_cmd chdr;
353+
__le32 qlink_proto_ver;
354+
u8 var_info[0];
355+
} __packed;
356+
329357
/**
330358
* struct qlink_cmd_manage_intf - interface management command
331359
*
@@ -895,6 +923,16 @@ struct qlink_resp {
895923
u8 vifid;
896924
} __packed;
897925

926+
/**
927+
* struct qlink_resp_init_fw - response for QLINK_CMD_FW_INIT
928+
*
929+
* @qlink_proto_ver: QLINK protocol version used by wifi card firmware.
930+
*/
931+
struct qlink_resp_init_fw {
932+
struct qlink_resp rhdr;
933+
__le32 qlink_proto_ver;
934+
} __packed;
935+
898936
/**
899937
* enum qlink_dfs_regions - regulatory DFS regions
900938
*
@@ -953,7 +991,6 @@ struct qlink_resp_get_mac_info {
953991
*
954992
* @fw_ver: wireless hardware firmware version.
955993
* @hw_capab: Bitmap of capabilities supported by firmware.
956-
* @ql_proto_ver: Version of QLINK protocol used by firmware.
957994
* @num_mac: Number of separate physical radio devices provided by hardware.
958995
* @mac_bitmap: Bitmap of MAC IDs that are active and can be used in firmware.
959996
* @total_tx_chains: total number of transmit chains used by device.
@@ -967,7 +1004,6 @@ struct qlink_resp_get_hw_info {
9671004
__le32 bld_tmstamp;
9681005
__le32 plat_id;
9691006
__le32 hw_ver;
970-
__le16 ql_proto_ver;
9711007
u8 num_mac;
9721008
u8 mac_bitmap;
9731009
u8 total_tx_chain;

0 commit comments

Comments
 (0)