Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7177ecf3 authored by Alexei Avshalom Lazar's avatar Alexei Avshalom Lazar Committed by Lior David
Browse files

wil6210: force EDMG channel through debugfs



Force EDMG (Enhanced Directional Multi-Gigabit) channel through debugfs
for debugging channel bonding feature.

Usage: echo <EDMG_CH> > force_edmg_channel

When force_edmg_channel is set, it will be used in connect and PCP start
commands.

Change-Id: Ia1e12cb8cf730dbb448fae47b40dfa11053567d0
Signed-off-by: default avatarAlexei Avshalom Lazar <ailizaro@codeaurora.org>
Signed-off-by: default avatarMaya Erez <merez@codeaurora.org>
[liord@codeaurora.org: fix merge conflicts, SPDX license]
Signed-off-by: default avatarLior David <liord@codeaurora.org>
parent c4dff16a
Loading
Loading
Loading
Loading
+90 −0
Original line number Diff line number Diff line
@@ -424,6 +424,86 @@ int wil_iftype_nl2wmi(enum nl80211_iftype type)
	return -EOPNOTSUPP;
}

int wil_spec2wmi_ch(u8 spec_ch, u8 *wmi_ch)
{
	switch (spec_ch) {
	case 1:
		*wmi_ch = WMI_CHANNEL_1;
		break;
	case 2:
		*wmi_ch = WMI_CHANNEL_2;
		break;
	case 3:
		*wmi_ch = WMI_CHANNEL_3;
		break;
	case 4:
		*wmi_ch = WMI_CHANNEL_4;
		break;
	case 5:
		*wmi_ch = WMI_CHANNEL_5;
		break;
	case 6:
		*wmi_ch = WMI_CHANNEL_6;
		break;
	case 9:
		*wmi_ch = WMI_CHANNEL_9;
		break;
	case 10:
		*wmi_ch = WMI_CHANNEL_10;
		break;
	case 11:
		*wmi_ch = WMI_CHANNEL_11;
		break;
	case 12:
		*wmi_ch = WMI_CHANNEL_12;
		break;
	default:
		return -EINVAL;
	}

	return 0;
}

int wil_wmi2spec_ch(u8 wmi_ch, u8 *spec_ch)
{
	switch (wmi_ch) {
	case WMI_CHANNEL_1:
		*spec_ch = 1;
		break;
	case WMI_CHANNEL_2:
		*spec_ch = 2;
		break;
	case WMI_CHANNEL_3:
		*spec_ch = 3;
		break;
	case WMI_CHANNEL_4:
		*spec_ch = 4;
		break;
	case WMI_CHANNEL_5:
		*spec_ch = 5;
		break;
	case WMI_CHANNEL_6:
		*spec_ch = 6;
		break;
	case WMI_CHANNEL_9:
		*spec_ch = 9;
		break;
	case WMI_CHANNEL_10:
		*spec_ch = 10;
		break;
	case WMI_CHANNEL_11:
		*spec_ch = 11;
		break;
	case WMI_CHANNEL_12:
		*spec_ch = 12;
		break;
	default:
		return -EINVAL;
	}

	return 0;
}

int wil_cid_fill_sinfo(struct wil6210_vif *vif, int cid,
		       struct station_info *sinfo)
{
@@ -1171,6 +1251,16 @@ static int wil_cfg80211_connect(struct wiphy *wiphy,
	}
	conn.channel = ch - 1;

	if (test_bit(WMI_FW_CAPABILITY_CHANNEL_BONDING, wil->fw_capabilities))
		if (wil->force_edmg_channel) {
			rc = wil_spec2wmi_ch(wil->force_edmg_channel,
					     &conn.edmg_channel);
			if (rc)
				wil_err(wil,
					"wmi channel for channel %d not found",
					wil->force_edmg_channel);
		}

	ether_addr_copy(conn.bssid, bss->bssid);
	ether_addr_copy(conn.dst_mac, bss->bssid);

+6 −16
Original line number Diff line number Diff line
// SPDX-License-Identifier: ISC
/*
 * Copyright (c) 2012-2017 Qualcomm Atheros, Inc.
 * Copyright (c) 2018, The Linux Foundation. All rights reserved.
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
 */

#include <linux/module.h>
@@ -954,7 +943,7 @@ static ssize_t wil_read_pmccfg(struct file *file, char __user *user_buf,
	" - \"alloc <num descriptors> <descriptor_size>\" to allocate pmc\n"
	" - \"free\" to free memory allocated for pmc\n";

	sprintf(text, "Last command status: %d\n\n%s",
	snprintf(text, sizeof(text), "Last command status: %d\n\n%s",
		 wil_pmc_last_cmd_status(wil),
		 help);

@@ -2526,6 +2515,7 @@ static const struct dbg_off dbg_wil_off[] = {
	WIL_FIELD(tx_status_ring_order, 0644,	doff_u32),
	WIL_FIELD(rx_buff_id_count, 0644,	doff_u32),
	WIL_FIELD(amsdu_en, 0644,	doff_u8),
	WIL_FIELD(force_edmg_channel, 0644,	doff_u8),
	{},
};

+4 −0
Original line number Diff line number Diff line
@@ -969,6 +969,7 @@ struct wil6210_priv {
	u8 wakeup_trigger;
	struct wil_suspend_stats suspend_stats;
	struct wil_debugfs_data dbg_data;
	u8 force_edmg_channel;
	bool tx_latency; /* collect TX latency measurements */
	size_t tx_latency_res; /* bin resolution in usec */

@@ -1391,6 +1392,9 @@ int wmi_mgmt_tx(struct wil6210_vif *vif, const u8 *buf, size_t len);
int wmi_mgmt_tx_ext(struct wil6210_vif *vif, const u8 *buf, size_t len,
		    u8 channel, u16 duration_ms);

int wil_wmi2spec_ch(u8 wmi_ch, u8 *spec_ch);
int wil_spec2wmi_ch(u8 spec_ch, u8 *wmi_ch);

int reverse_memcmp(const void *cs, const void *ct, size_t count);

/* WMI for enhanced DMA */
+21 −2
Original line number Diff line number Diff line
@@ -918,6 +918,7 @@ static void wmi_evt_connect(struct wil6210_vif *vif, int id, void *d, int len)
	struct wireless_dev *wdev = vif_to_wdev(vif);
	struct wmi_connect_event *evt = d;
	int ch; /* channel number */
	u8 spec_ch = 0; /* spec channel number */
	struct station_info *sinfo;
	u8 *assoc_req_ie, *assoc_resp_ie;
	size_t assoc_req_ielen, assoc_resp_ielen;
@@ -945,8 +946,16 @@ static void wmi_evt_connect(struct wil6210_vif *vif, int id, void *d, int len)
	}

	ch = evt->channel + 1;
	if (evt->edmg_channel &&
	    test_bit(WMI_FW_CAPABILITY_CHANNEL_BONDING, wil->fw_capabilities))
		wil_wmi2spec_ch(evt->edmg_channel, &spec_ch);
	if (spec_ch)
		wil_info(wil, "Connect %pM EDMG channel [%d] primary channel [%d] cid %d aid %d\n",
			 evt->bssid, spec_ch, ch, evt->cid, evt->aid);
	else
		wil_info(wil, "Connect %pM channel [%d] cid %d aid %d\n",
			 evt->bssid, ch, evt->cid, evt->aid);

	wil_hex_dump_wmi("connect AI : ", DUMP_PREFIX_OFFSET, 16, 1,
			 evt->assoc_info, len - sizeof(*evt), true);

@@ -1825,6 +1834,16 @@ int wmi_pcp_start(struct wil6210_vif *vif,
		.evt = {.status = WMI_FW_STATUS_FAILURE},
	};

	if (test_bit(WMI_FW_CAPABILITY_CHANNEL_BONDING, wil->fw_capabilities))
		if (wil->force_edmg_channel) {
			rc = wil_spec2wmi_ch(wil->force_edmg_channel,
					     &cmd.edmg_channel);
			if (rc)
				wil_err(wil,
					"wmi channel for channel %d not found",
					wil->force_edmg_channel);
		}

	if (!vif->privacy)
		cmd.disable_sec = 1;

+24 −2
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@ enum wmi_fw_capability {
	WMI_FW_CAPABILITY_LO_POWER_CALIB_FROM_OTP	= 14,
	WMI_FW_CAPABILITY_PNO				= 15,
	WMI_FW_CAPABILITY_CONNECT_SNR_THR		= 16,
	WMI_FW_CAPABILITY_CHANNEL_BONDING		= 17,
	WMI_FW_CAPABILITY_REF_CLOCK_CONTROL		= 18,
	WMI_FW_CAPABILITY_AP_SME_OFFLOAD_NONE		= 19,
	WMI_FW_CAPABILITY_MULTI_VIFS			= 20,
@@ -344,6 +345,19 @@ enum wmi_connect_ctrl_flag_bits {

#define WMI_MAX_SSID_LEN	(32)

enum wmi_channel {
	WMI_CHANNEL_1	= 0x00,
	WMI_CHANNEL_2	= 0x01,
	WMI_CHANNEL_3	= 0x02,
	WMI_CHANNEL_4	= 0x03,
	WMI_CHANNEL_5	= 0x04,
	WMI_CHANNEL_6	= 0x05,
	WMI_CHANNEL_9	= 0x06,
	WMI_CHANNEL_10	= 0x07,
	WMI_CHANNEL_11	= 0x08,
	WMI_CHANNEL_12	= 0x09,
};

/* WMI_CONNECT_CMDID */
struct wmi_connect_cmd {
	u8 network_type;
@@ -355,8 +369,12 @@ struct wmi_connect_cmd {
	u8 group_crypto_len;
	u8 ssid_len;
	u8 ssid[WMI_MAX_SSID_LEN];
	/* enum wmi_channel WMI_CHANNEL_1..WMI_CHANNEL_6; for EDMG this is
	 * the primary channel number
	 */
	u8 channel;
	u8 reserved0;
	/* enum wmi_channel WMI_CHANNEL_9..WMI_CHANNEL_12 */
	u8 edmg_channel;
	u8 bssid[WMI_MAC_LEN];
	__le32 ctrl_flags;
	u8 dst_mac[WMI_MAC_LEN];
@@ -2272,8 +2290,12 @@ struct wmi_notify_req_done_event {

/* WMI_CONNECT_EVENTID */
struct wmi_connect_event {
	/* enum wmi_channel WMI_CHANNEL_1..WMI_CHANNEL_6; for EDMG this is
	 * the primary channel number
	 */
	u8 channel;
	u8 reserved0;
	/* enum wmi_channel WMI_CHANNEL_9..WMI_CHANNEL_12 */
	u8 edmg_channel;
	u8 bssid[WMI_MAC_LEN];
	__le16 listen_interval;
	__le16 beacon_interval;