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

Commit fb4ff828 authored by Dedy Lansky's avatar Dedy Lansky Committed by Alexei Avshalom Lazar
Browse files

wil6210: add sysfs for setting connect SNR threshold



snr_thresh sysfs can be used to set omni and direct SNR threshold for
connection.

Change-Id: I091a6b61a1a4cb98e0e8c0f70b2fff4d22486e61
Signed-off-by: default avatarDedy Lansky <dlansky@codeaurora.org>
CRs-Fixed: 2143032
Signed-off-by: default avatarAlexei Avshalom Lazar <ailizaro@codeaurora.org>
parent 9101b7a7
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1088,6 +1088,10 @@ int wil_reset(struct wil6210_priv *wil, bool load_fw)

		wil_collect_fw_info(wil);

		if (wil->snr_thresh.enabled)
			wmi_set_snr_thresh(wil, wil->snr_thresh.omni,
					   wil->snr_thresh.direct);

		if (wil->platform_ops.notify) {
			rc = wil->platform_ops.notify(wil->platform_handle,
						      WIL_PLATFORM_EVT_FW_RDY);
+39 −0
Original line number Diff line number Diff line
@@ -268,10 +268,49 @@ static DEVICE_ATTR(fst_link_loss, 0644,
		   wil_fst_link_loss_sysfs_show,
		   wil_fst_link_loss_sysfs_store);

static ssize_t
wil_snr_thresh_sysfs_show(struct device *dev, struct device_attribute *attr,
			  char *buf)
{
	struct wil6210_priv *wil = dev_get_drvdata(dev);
	ssize_t len = 0;

	if (wil->snr_thresh.enabled)
		len = snprintf(buf, PAGE_SIZE, "omni=%d, direct=%d\n",
			       wil->snr_thresh.omni, wil->snr_thresh.direct);

	return len;
}

static ssize_t
wil_snr_thresh_sysfs_store(struct device *dev,
			   struct device_attribute *attr,
			   const char *buf, size_t count)
{
	struct wil6210_priv *wil = dev_get_drvdata(dev);
	int rc;
	short omni, direct;

	/* to disable snr threshold, set both omni and direct to 0 */
	if (sscanf(buf, "%hd %hd", &omni, &direct) != 2)
		return -EINVAL;

	rc = wmi_set_snr_thresh(wil, omni, direct);
	if (!rc)
		rc = count;

	return rc;
}

static DEVICE_ATTR(snr_thresh, 0644,
		   wil_snr_thresh_sysfs_show,
		   wil_snr_thresh_sysfs_store);

static struct attribute *wil6210_sysfs_entries[] = {
	&dev_attr_ftm_txrx_offset.attr,
	&dev_attr_thermal_throttling.attr,
	&dev_attr_fst_link_loss.attr,
	&dev_attr_snr_thresh.attr,
	NULL
};

+7 −0
Original line number Diff line number Diff line
@@ -739,6 +739,11 @@ struct wil6210_priv {
	struct wil_ftm_priv ftm;
	bool tt_data_set;
	struct wmi_tt_data tt_data;
	struct {
		bool enabled;
		short omni;
		short direct;
	} snr_thresh;

#ifdef CONFIG_PM
#ifdef CONFIG_PM_SLEEP
@@ -1050,4 +1055,6 @@ int wmi_link_maintain_cfg_write(struct wil6210_priv *wil,
				const u8 *addr,
				bool fst_link_loss);

int wmi_set_snr_thresh(struct wil6210_priv *wil, short omni, short direct);

#endif /* __WIL6210_H__ */
+29 −0
Original line number Diff line number Diff line
@@ -2150,3 +2150,32 @@ bool wil_is_wmi_idle(struct wil6210_priv *wil)
	spin_unlock_irqrestore(&wil->wmi_ev_lock, flags);
	return rc;
}

int wmi_set_snr_thresh(struct wil6210_priv *wil, short omni, short direct)
{
	int rc;
	struct wmi_set_connect_snr_thr_cmd cmd = {
		.enable = true,
		.omni_snr_thr = cpu_to_le16(omni),
		.direct_snr_thr = cpu_to_le16(direct),
	};

	if (!test_bit(WMI_FW_CAPABILITY_CONNECT_SNR_THR, wil->fw_capabilities))
		return -ENOTSUPP;

	if (omni == 0 && direct == 0)
		cmd.enable = false;

	wil_dbg_wmi(wil, "%s snr thresh omni=%d, direct=%d (1/4 dB units)\n",
		    cmd.enable ? "enable" : "disable", omni, direct);

	rc = wmi_send(wil, WMI_SET_CONNECT_SNR_THR_CMDID, &cmd, sizeof(cmd));
	if (rc)
		return rc;

	wil->snr_thresh.enabled = cmd.enable;
	wil->snr_thresh.omni = omni;
	wil->snr_thresh.direct = direct;

	return 0;
}
+1 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ enum wmi_fw_capability {
	WMI_FW_CAPABILITY_RSSI_REPORTING		= 12,
	WMI_FW_CAPABILITY_SET_SILENT_RSSI_TABLE		= 13,
	WMI_FW_CAPABILITY_LO_POWER_CALIB_FROM_OTP	= 14,
	WMI_FW_CAPABILITY_CONNECT_SNR_THR		= 16,
	WMI_FW_CAPABILITY_MAX,
};