Skip to contentSkip to conversation

wcn36xx: Add support for FTM WLAN

PATCH Superseded Ramon Fried 2 participants 3 messages Feb 28, 2018 – Mar 11, 2018

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wcn36xx: Add support for FTM WLAN

From: Eyal Ilsar <[email protected]>

Introduced infrastructure for supporting FTM WLAN in user space exposing the netlink channel from the kernel WLAN driver. This included:
1) Registered wcn36xx driver to testmode callback from netlink
2) Added testmode callback implementation to handle incoming FTM commands
3) Added FTM command packet structure
4) Added handling for GET_BUILD_RELEASE_NUMBER (msgid=0x32A2)
5) Added generic handling for all PTT_MSG packets

---
 drivers/net/wireless/ath/wcn36xx/Makefile     |   2 +
 drivers/net/wireless/ath/wcn36xx/hal.h        |  16 +++
 drivers/net/wireless/ath/wcn36xx/main.c       |   3 +
 drivers/net/wireless/ath/wcn36xx/smd.c        |  72 ++++++++++++
 drivers/net/wireless/ath/wcn36xx/smd.h        |   4 +
 drivers/net/wireless/ath/wcn36xx/testmode.c   | 161 ++++++++++++++++++++++++++
 drivers/net/wireless/ath/wcn36xx/testmode.h   |  42 +++++++
 drivers/net/wireless/ath/wcn36xx/testmode_i.h |  41 +++++++
 drivers/net/wireless/ath/wcn36xx/wcn36xx.h    |   2 +
 9 files changed, 343 insertions(+)
 create mode 100644 drivers/net/wireless/ath/wcn36xx/testmode.c
 create mode 100644 drivers/net/wireless/ath/wcn36xx/testmode.h
 create mode 100644 drivers/net/wireless/ath/wcn36xx/testmode_i.h
drivers/net/wireless/ath/wcn36xx/Makefile +2 -0
index 3b09435104eb..582049f65735 100644
@@ -6,3 +6,5 @@ wcn36xx-y +=   main.o \
                smd.o \
                pmc.o \
                debug.o
+
+wcn36xx-$(CONFIG_NL80211_TESTMODE) += testmode.o
drivers/net/wireless/ath/wcn36xx/hal.h +16 -0
index 182963522941..d2df6750e5f6 100644
@@ -2230,6 +2230,22 @@ struct wcn36xx_hal_switch_channel_rsp_msg {
 
 } __packed;
 
+struct wcn36xx_hal_process_ptt_msg_req_msg {
+	struct wcn36xx_hal_msg_header header;
+
+	/* Actual FTM Command body */
+	u8 ptt_msg[0];
+} __packed;
+
+struct wcn36xx_hal_process_ptt_msg_rsp_msg {
+	struct wcn36xx_hal_msg_header header;
+
+	/* FTM Command response status */
+	u32   ptt_msg_resp_status;
+	/* Actual FTM Command body */
+	u8 ptt_msg[0];
+} __packed;
+
 struct update_edca_params_req_msg {
 	struct wcn36xx_hal_msg_header header;
 
drivers/net/wireless/ath/wcn36xx/main.c +3 -0
index 8c2654075eb8..6b73da6f7fde 100644
@@ -26,6 +26,7 @@
 #include <linux/soc/qcom/smem_state.h>
 #include <linux/soc/qcom/wcnss_ctrl.h>
 #include "wcn36xx.h"
+#include "testmode.h"
 
 unsigned int wcn36xx_dbg_mask;
 module_param_named(debug_mask, wcn36xx_dbg_mask, uint, 0644);
@@ -1119,6 +1120,8 @@ static const struct ieee80211_ops wcn36xx_ops = {
 	.sta_add		= wcn36xx_sta_add,
 	.sta_remove		= wcn36xx_sta_remove,
 	.ampdu_action		= wcn36xx_ampdu_action,
+
+	CFG80211_TESTMODE_CMD(wcn36xx_tm_cmd)
 };
 
 static int wcn36xx_init_ieee80211(struct wcn36xx *wcn)
drivers/net/wireless/ath/wcn36xx/smd.c +72 -0

108 lines not on this page · raw message

drivers/net/wireless/ath/wcn36xx/smd.h +4 -0
index 8076edf40ac8..6d83cc99dc25 100644
@@ -86,6 +86,10 @@ int wcn36xx_smd_send_beacon(struct wcn36xx *wcn, struct ieee80211_vif *vif,
 			    u16 p2p_off);
 int wcn36xx_smd_switch_channel(struct wcn36xx *wcn,
 			       struct ieee80211_vif *vif, int ch);
+int wcn36xx_smd_process_ptt_msg(struct wcn36xx *wcn,
+			    struct ieee80211_vif *vif,
+				void *ptt_msg, size_t len,
+				void **ptt_rsp_msg);
 int wcn36xx_smd_update_proberesp_tmpl(struct wcn36xx *wcn,
 				      struct ieee80211_vif *vif,
 				      struct sk_buff *skb);
drivers/net/wireless/ath/wcn36xx/testmode.c new file +161 -0

161 lines not on this page · raw message

drivers/net/wireless/ath/wcn36xx/testmode.h new file +42 -0

42 lines not on this page · raw message

drivers/net/wireless/ath/wcn36xx/testmode_i.h new file +41 -0

41 lines not on this page · raw message

drivers/net/wireless/ath/wcn36xx/wcn36xx.h +2 -0
index 81017e6703b4..6a6c49835a13 100644
@@ -56,6 +56,8 @@ enum wcn36xx_debug_mask {
 	WCN36XX_DBG_BEACON_DUMP	= 0x00001000,
 	WCN36XX_DBG_PMC		= 0x00002000,
 	WCN36XX_DBG_PMC_DUMP	= 0x00004000,
+	WCN36XX_DBG_TESTMODE		= 0x00008000,
+	WCN36XX_DBG_TESTMODE_DUMP	= 0x00010000,
 	WCN36XX_DBG_ANY		= 0xffffffff,
 };
 
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#1 lore raw
Quoted 4 lines · Ramon Fried

From: Eyal Ilsar <[email protected]>

Introduced infrastructure for supporting FTM WLAN in user space exposing the netlink channel from the kernel WLAN driver.

What's FTM WLAN? Don't assume that people know all the acronyms.

This included:

Quoted 5 lines

1) Registered wcn36xx driver to testmode callback from netlink
2) Added testmode callback implementation to handle incoming FTM commands
3) Added FTM command packet structure
4) Added handling for GET_BUILD_RELEASE_NUMBER (msgid=0x32A2)
5) Added generic handling for all PTT_MSG packets

I don't remember the english grammar terminology, but in the commit log use the form "register", "add" instead of "registered", "added".

drivers/net/wireless/ath/wcn36xx/hal.h struct wcn36xx_hal_switch_channel_rsp_msg { · line 2244

Quoted 5 lines
drivers/net/wireless/ath/wcn36xx/hal.h +5 -0
+struct wcn36xx_hal_process_ptt_msg_rsp_msg {
+	struct wcn36xx_hal_msg_header header;
+
+	/* FTM Command response status */
+	u32   ptt_msg_resp_status;

Unnecessary whitespace after u32.

Quoted 10 lines
drivers/net/wireless/ath/wcn36xx/smd.c +10 -0
+static int wcn36xx_smd_process_ptt_msg_rsp(void *buf, size_t len,
+			void **p_ptt_rsp_msg)
+{
+	struct wcn36xx_hal_process_ptt_msg_rsp_msg *rsp;
+	int ret = 0;
+
+	ret = wcn36xx_smd_rsp_status_check(buf, len);
+	if (ret)
+		return ret;
+	rsp = (struct wcn36xx_hal_process_ptt_msg_rsp_msg *)buf;

drivers/net/wireless/ath/wcn36xx/smd.c int wcn36xx_smd_switch_channel(struct wcn36xx *wcn, · line 778

Quoted 10 lines
drivers/net/wireless/ath/wcn36xx/smd.c +10 -0
+	wcn36xx_dbg(WCN36XX_DBG_HAL, "process ptt msg responded with length %d\n",
+			rsp->header.len);
+	wcn36xx_dbg_dump(WCN36XX_DBG_HAL_DUMP, "HAL_PTT_MSG_RSP:", rsp->ptt_msg,
+			rsp->header.len - sizeof(rsp->ptt_msg_resp_status));
+	if (rsp->header.len > 0) {
+		*p_ptt_rsp_msg = kmalloc(rsp->header.len, GFP_ATOMIC);
+		memcpy(*p_ptt_rsp_msg, rsp->ptt_msg, rsp->header.len);
+	}
+	return ret;
+}

Adding few empty lines to the function would make it more readable.

drivers/net/wireless/ath/wcn36xx/smd.c int wcn36xx_smd_rsp_process(struct rpmsg_device *rpdev, · line 2403

Quoted 6 lines
drivers/net/wireless/ath/wcn36xx/smd.c +1 -0
@@ -2330,6 +2399,7 @@ int wcn36xx_smd_rsp_process(struct rpmsg_device *rpdev,
 	struct ieee80211_hw *hw = priv;
 	struct wcn36xx *wcn = hw->priv;
 	struct wcn36xx_hal_ind_msg *msg_ind;
+
 	wcn36xx_dbg_dump(WCN36XX_DBG_SMD_DUMP, "SMD <<< ", buf, len);

Unrelated change.

Quoted 24 lines
drivers/net/wireless/ath/wcn36xx/testmode.c new file +24 -0
+int wcn36xx_tm_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+		  void *data, int len)
+{
+	struct wcn36xx *wcn = hw->priv;
+	struct nlattr *tb[WCN36XX_TM_ATTR_MAX + 1];
+	int ret = 0;
+	unsigned short attr;
+
+	wcn36xx_dbg_dump(WCN36XX_DBG_TESTMODE_DUMP, "Data:", data, len);
+	ret = nla_parse(tb, WCN36XX_TM_ATTR_MAX, data, len,
+			wcn36xx_tm_policy, NULL);
+	if (ret)
+		return ret;
+
+	if (!tb[WCN36XX_TM_ATTR_CMD])
+		return -EINVAL;
+
+	attr = nla_get_u16(tb[WCN36XX_TM_ATTR_CMD]);
+
+	switch (attr) {
+	case WCN36XX_TM_CMD_START:
+	case WCN36XX_TM_CMD_STOP:
+		// N/A to this driver as it does not need to switch state
+		break;

[...]

drivers/net/wireless/ath/wcn36xx/testmode_i.h line 35

Quoted 8 lines
drivers/net/wireless/ath/wcn36xx/testmode_i.h new file +8 -0
+enum wcn36xx_tm_cmd {
+	/* For backwards compatibility
+	 */
+	WCN36XX_TM_CMD_START = 1,
+
+	/* For backwards compatibility
+	 */
+	WCN36XX_TM_CMD_STOP = 2,

This looks odd. If wcn36xx does not need START and STOP commands why add those in the first place?

Signature · 1 line
Kalle Valo
#2 lore raw
Quoted 7 lines · Kalle Valo
Quoted 4 lines · Ramon Fried

From: Eyal Ilsar <[email protected]>

Introduced infrastructure for supporting FTM WLAN in user space exposing the netlink channel from the kernel WLAN driver.

What's FTM WLAN? Don't assume that people know all the acronyms.

FTM is factory test mode if I recall correctly, but you're right. I elaborate more in the commit message.

Quoted 9 lines

This included:

Quoted 5 lines

1) Registered wcn36xx driver to testmode callback from netlink
2) Added testmode callback implementation to handle incoming FTM commands
3) Added FTM command packet structure
4) Added handling for GET_BUILD_RELEASE_NUMBER (msgid=0x32A2)
5) Added generic handling for all PTT_MSG packets

I don't remember the english grammar terminology, but in the commit log use the form "register", "add" instead of "registered", "added".

OK. Will fix.

Quoted 6 lines

drivers/net/wireless/ath/wcn36xx/hal.h struct wcn36xx_hal_switch_channel_rsp_msg { · line 2244

Quoted 5 lines
drivers/net/wireless/ath/wcn36xx/hal.h +5 -0
+struct wcn36xx_hal_process_ptt_msg_rsp_msg {
+	struct wcn36xx_hal_msg_header header;
+
+	/* FTM Command response status */
+	u32   ptt_msg_resp_status;

Unnecessary whitespace after u32.

Thanks.

Quoted 13 lines
Quoted 13 lines
drivers/net/wireless/ath/wcn36xx/smd.c +13 -0
+static int wcn36xx_smd_process_ptt_msg_rsp(void *buf, size_t len,
+			void **p_ptt_rsp_msg)
+{
+	struct wcn36xx_hal_process_ptt_msg_rsp_msg *rsp;
+	int ret = 0;
+
+	ret = wcn36xx_smd_rsp_status_check(buf, len);
+	if (ret)
+		return ret;
+	rsp = (struct wcn36xx_hal_process_ptt_msg_rsp_msg *)buf;
+	wcn36xx_dbg(WCN36XX_DBG_HAL, "process ptt msg responded with length %d\n",
+			rsp->header.len);
+	wcn36xx_dbg_dump(WCN36XX_DBG_HAL_DUMP, "HAL_PTT_MSG_RSP:", rsp->ptt_msg,
Quoted 8 lines

drivers/net/wireless/ath/wcn36xx/smd.c int wcn36xx_smd_switch_channel(struct wcn36xx *wcn, · line 778

Quoted 7 lines
drivers/net/wireless/ath/wcn36xx/smd.c +7 -0
+			rsp->header.len - sizeof(rsp->ptt_msg_resp_status));
+	if (rsp->header.len > 0) {
+		*p_ptt_rsp_msg = kmalloc(rsp->header.len, GFP_ATOMIC);
+		memcpy(*p_ptt_rsp_msg, rsp->ptt_msg, rsp->header.len);
+	}
+	return ret;
+}

Adding few empty lines to the function would make it more readable.

Ok, I will add.

Quoted 7 lines

drivers/net/wireless/ath/wcn36xx/smd.c int wcn36xx_smd_rsp_process(struct rpmsg_device *rpdev, · line 2403

Quoted 6 lines
drivers/net/wireless/ath/wcn36xx/smd.c +1 -0
@@ -2330,6 +2399,7 @@ int wcn36xx_smd_rsp_process(struct rpmsg_device *rpdev,
 	struct ieee80211_hw *hw = priv;
 	struct wcn36xx *wcn = hw->priv;
 	struct wcn36xx_hal_ind_msg *msg_ind;
+
 	wcn36xx_dbg_dump(WCN36XX_DBG_SMD_DUMP, "SMD <<< ", buf, len);

Unrelated change.

Nice catch. thanks.

Quoted 26 lines
Quoted 24 lines
drivers/net/wireless/ath/wcn36xx/testmode.c new file +24 -0
+int wcn36xx_tm_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+		  void *data, int len)
+{
+	struct wcn36xx *wcn = hw->priv;
+	struct nlattr *tb[WCN36XX_TM_ATTR_MAX + 1];
+	int ret = 0;
+	unsigned short attr;
+
+	wcn36xx_dbg_dump(WCN36XX_DBG_TESTMODE_DUMP, "Data:", data, len);
+	ret = nla_parse(tb, WCN36XX_TM_ATTR_MAX, data, len,
+			wcn36xx_tm_policy, NULL);
+	if (ret)
+		return ret;
+
+	if (!tb[WCN36XX_TM_ATTR_CMD])
+		return -EINVAL;
+
+	attr = nla_get_u16(tb[WCN36XX_TM_ATTR_CMD]);
+
+	switch (attr) {
+	case WCN36XX_TM_CMD_START:
+	case WCN36XX_TM_CMD_STOP:
+		// N/A to this driver as it does not need to switch state
+		break;

[...]

Quoted 10 lines

drivers/net/wireless/ath/wcn36xx/testmode_i.h line 35

Quoted 8 lines
drivers/net/wireless/ath/wcn36xx/testmode_i.h new file +8 -0
+enum wcn36xx_tm_cmd {
+	/* For backwards compatibility
+	 */
+	WCN36XX_TM_CMD_START = 1,
+
+	/* For backwards compatibility
+	 */
+	WCN36XX_TM_CMD_STOP = 2,

This looks odd. If wcn36xx does not need START and STOP commands why add those in the first place?

AFAIK the user-space app sends these commands, but I will check again. in WCN36xx unlike ATH10k it's not needed to do any transition or replace the firmware to go in test mode, but I assume that if this command arrives we should return success.

Quoted 1 line