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

Commit 5d660bdc authored by Dedy Lansky's avatar Dedy Lansky
Browse files

wil6210: add fst_config sysfs



fst_config sysfs is used by userspace to configure FST parameters.
The FST configuration is sent to FW using WMI_FST_CONFIG_CMDID.

Change-Id: I940feb36baa7c0d14de8abcdd54c05f489bdc4de
Signed-off-by: default avatarDedy Lansky <dlansky@codeaurora.org>
parent 1d70e214
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
@@ -317,6 +317,43 @@ fst_link_loss_store(struct device *dev, struct device_attribute *attr,

static DEVICE_ATTR_RW(fst_link_loss);

static ssize_t
fst_config_store(struct device *dev, struct device_attribute *attr,
		 const char *buf, size_t count)
{
	struct wil6210_priv *wil = dev_get_drvdata(dev);
	u8 addr[ETH_ALEN];
	int rc;
	u8 enabled, entry_mcs, exit_mcs, slevel;

	/* <ap_bssid> <enabled> <entry_mcs> <exit_mcs> <sensitivity_level> */
	if (sscanf(buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx %hhu %hhu %hhu %hhu",
		   &addr[0], &addr[1], &addr[2],
		   &addr[3], &addr[4], &addr[5],
		   &enabled, &entry_mcs, &exit_mcs, &slevel) != 10)
		return -EINVAL;

	if (entry_mcs > WIL_MCS_MAX || exit_mcs > WIL_MCS_MAX ||
	    entry_mcs < exit_mcs || slevel > WMI_FST_SWITCH_SENSITIVITY_HIGH)
		return -EINVAL;

	wil_dbg_misc(wil,
		     "fst_config %sabled for [%pM] with entry/exit MCS %d/%d, sensitivity %s\n",
		     enabled ? "en" : "dis", addr, entry_mcs, exit_mcs,
		     (slevel == WMI_FST_SWITCH_SENSITIVITY_LOW) ?
			"LOW" : (slevel == WMI_FST_SWITCH_SENSITIVITY_HIGH) ?
					"HIGH" : "MED");

	rc = wmi_set_fst_config(wil, addr, enabled, entry_mcs, exit_mcs,
				slevel);
	if (!rc)
		rc = count;

	return rc;
}

static DEVICE_ATTR_WO(fst_config);

static ssize_t
vr_profile_show(struct device *dev, struct device_attribute *attr,
		char *buf)
@@ -427,6 +464,7 @@ static struct attribute *wil6210_sysfs_entries[] = {
	&dev_attr_fst_link_loss.attr,
	&dev_attr_snr_thresh.attr,
	&dev_attr_vr_profile.attr,
	&dev_attr_fst_config.attr,
	NULL
};

+2 −0
Original line number Diff line number Diff line
@@ -1575,4 +1575,6 @@ int wmi_reset_spi_slave(struct wil6210_priv *wil);
void wil_clear_fw_log_addr(struct wil6210_priv *wil);
int wmi_set_cqm_rssi_config(struct wil6210_priv *wil,
			    s32 rssi_thold, u32 rssi_hyst);
int wmi_set_fst_config(struct wil6210_priv *wil, const u8 *bssid, u8 enabled,
		       u8 entry_mcs, u8 exit_mcs, u8 slevel);
#endif /* __WIL6210_H__ */
+42 −0
Original line number Diff line number Diff line
@@ -483,6 +483,8 @@ static const char *cmdid2name(u16 cmdid)
		return "WMI_RBUFCAP_CFG_CMD";
	case WMI_TEMP_SENSE_ALL_CMDID:
		return "WMI_TEMP_SENSE_ALL_CMDID";
	case WMI_FST_CONFIG_CMDID:
		return "WMI_FST_CONFIG_CMD";
	case WMI_SET_LINK_MONITOR_CMDID:
		return "WMI_SET_LINK_MONITOR_CMD";
	default:
@@ -637,6 +639,8 @@ static const char *eventid2name(u16 eventid)
		return "WMI_RBUFCAP_CFG_EVENT";
	case WMI_TEMP_SENSE_ALL_DONE_EVENTID:
		return "WMI_TEMP_SENSE_ALL_DONE_EVENTID";
	case WMI_FST_CONFIG_EVENTID:
		return "WMI_FST_CONFIG_EVENT";
	case WMI_SET_LINK_MONITOR_EVENTID:
		return "WMI_SET_LINK_MONITOR_EVENT";
	case WMI_LINK_MONITOR_EVENTID:
@@ -4427,3 +4431,41 @@ int wmi_set_cqm_rssi_config(struct wil6210_priv *wil,

	return 0;
}

int wmi_set_fst_config(struct wil6210_priv *wil, const u8 *bssid, u8 enabled,
		       u8 entry_mcs, u8 exit_mcs, u8 slevel)
{
	struct net_device *ndev = wil->main_ndev;
	struct wil6210_vif *vif = ndev_to_vif(ndev);
	int rc;
	struct wmi_fst_config_cmd cmd = {
		.fst_en = enabled,
		.fst_entry_mcs = entry_mcs,
		.fst_exit_mcs = exit_mcs,
		.sensitivity_level = slevel,
	};
	struct {
		struct wmi_cmd_hdr hdr;
		struct wmi_fst_config_event evt;
	} __packed reply = {
		.evt = {.status = WMI_FW_STATUS_FAILURE},
	};

	ether_addr_copy(cmd.fst_ap_bssid, bssid);

	rc = wmi_call(wil, WMI_FST_CONFIG_CMDID, vif->mid, &cmd,
		      sizeof(cmd), WMI_FST_CONFIG_EVENTID,
		      &reply, sizeof(reply), WIL_WMI_CALL_GENERAL_TO_MS);
	if (rc) {
		wil_err(wil, "WMI_FST_CONFIG_CMDID failed, rc %d\n", rc);
		return rc;
	}

	if (reply.evt.status != WMI_FW_STATUS_SUCCESS) {
		wil_err(wil, "WMI_FST_CONFIG_CMDID failed, status %d\n",
			reply.evt.status);
		return -EINVAL;
	}

	return 0;
}
+27 −0
Original line number Diff line number Diff line
@@ -195,6 +195,7 @@ enum wmi_command_id {
	WMI_RCP_ADDBA_RESP_EDMA_CMDID			= 0x83B,
	WMI_LINK_MAINTAIN_CFG_WRITE_CMDID		= 0x842,
	WMI_LINK_MAINTAIN_CFG_READ_CMDID		= 0x843,
	WMI_FST_CONFIG_CMDID				= 0x844,
	WMI_SET_LINK_MONITOR_CMDID			= 0x845,
	WMI_SET_SECTORS_CMDID				= 0x849,
	WMI_MAINTAIN_PAUSE_CMDID			= 0x850,
@@ -2043,6 +2044,7 @@ enum wmi_event_id {
	WMI_TX_MGMT_PACKET_EVENTID			= 0x1841,
	WMI_LINK_MAINTAIN_CFG_WRITE_DONE_EVENTID	= 0x1842,
	WMI_LINK_MAINTAIN_CFG_READ_DONE_EVENTID		= 0x1843,
	WMI_FST_CONFIG_EVENTID				= 0x1844,
	WMI_SET_LINK_MONITOR_EVENTID			= 0x1845,
	WMI_RF_XPM_READ_RESULT_EVENTID			= 0x1856,
	WMI_RF_XPM_WRITE_RESULT_EVENTID			= 0x1857,
@@ -3333,6 +3335,24 @@ struct wmi_link_maintain_cfg_read_cmd {
	__le32 cid;
} __packed;

/* switch sensitivity levels for WMI_FST_CONFIG_CMDID command */
enum wmi_fst_switch_sensitivity_level {
	WMI_FST_SWITCH_SENSITIVITY_LOW	= 0x00,
	WMI_FST_SWITCH_SENSITIVITY_MED	= 0x01,
	WMI_FST_SWITCH_SENSITIVITY_HIGH	= 0x02,
};

/* WMI_FST_CONFIG_CMDID */
struct wmi_fst_config_cmd {
	u8 fst_en;
	u8 fst_ap_bssid[WMI_MAC_LEN];
	u8 fst_entry_mcs;
	u8 fst_exit_mcs;
	/* wmi_fst_switch_sensitivity_level */
	u8 sensitivity_level;
	u8 reserved[2];
} __packed;

/* WMI_SET_LINK_MONITOR_CMDID */
struct wmi_set_link_monitor_cmd {
	u8 rssi_hyst;
@@ -3341,6 +3361,13 @@ struct wmi_set_link_monitor_cmd {
	s8 rssi_thresholds_list[0];
} __packed;

/* WMI_FST_CONFIG_EVENTID */
struct wmi_fst_config_event {
	/* wmi_fw_status */
	u8 status;
	u8 reserved[3];
} __packed;

/* wmi_link_monitor_event_type */
enum wmi_link_monitor_event_type {
	WMI_LINK_MONITOR_NOTIF_RSSI_THRESHOLD_EVT	= 0x00,