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

Commit 3a9333b3 authored by Dedy Lansky's avatar Dedy Lansky Committed by Maya Erez
Browse files

wil6210: move WMI functionality out of wil_cfg80211_mgmt_tx



Rearrange the code by having new function wmi_mgmt_tx() to take care
of the WMI part of wil_cfg80211_mgmt_tx().

Change-Id: Ia045999cdc9153c3403abda3ee023173cea70dad
Signed-off-by: default avatarDedy Lansky <dlansky@codeaurora.org>
Signed-off-by: default avatarMaya Erez <merez@codeaurora.org>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
Git-commit: 1c21cc5fc4df4997eddc6e0b5c5bad225c3f1ecc
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git
[merez@codeaurora.org: trivial conflict fixes]
parent 3440f98c
Loading
Loading
Loading
Loading
+4 −35
Original line number Diff line number Diff line
@@ -1158,17 +1158,11 @@ int wil_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
			 u64 *cookie)
{
	const u8 *buf = params->buf;
	size_t len = params->len, total;
	size_t len = params->len;
	struct wil6210_priv *wil = wiphy_to_wil(wiphy);
	struct wil6210_vif *vif = wdev_to_vif(wil, wdev);
	int rc;
	bool tx_status = false;
	struct ieee80211_mgmt *mgmt_frame = (void *)buf;
	struct wmi_sw_tx_req_cmd *cmd;
	struct {
		struct wmi_cmd_hdr wmi;
		struct wmi_sw_tx_complete_event evt;
	} __packed evt;
	bool tx_status;

	/* Note, currently we do not support the "wait" parameter, user-space
	 * must call remain_on_channel before mgmt_tx or listen on a channel
@@ -1177,34 +1171,9 @@ int wil_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
	 * different from currently "listened" channel and fail if it is.
	 */

	wil_dbg_misc(wil, "mgmt_tx mid %d\n", vif->mid);
	wil_hex_dump_misc("mgmt tx frame ", DUMP_PREFIX_OFFSET, 16, 1, buf,
			  len, true);

	if (len < sizeof(struct ieee80211_hdr_3addr))
		return -EINVAL;

	total = sizeof(*cmd) + len;
	if (total < len)
		return -EINVAL;

	cmd = kmalloc(total, GFP_KERNEL);
	if (!cmd) {
		rc = -ENOMEM;
		goto out;
	}

	memcpy(cmd->dst_mac, mgmt_frame->da, WMI_MAC_LEN);
	cmd->len = cpu_to_le16(len);
	memcpy(cmd->payload, buf, len);

	rc = wmi_call(wil, WMI_SW_TX_REQ_CMDID, vif->mid, cmd, total,
		      WMI_SW_TX_COMPLETE_EVENTID, &evt, sizeof(evt), 2000);
	if (rc == 0)
		tx_status = !evt.evt.status;
	rc = wmi_mgmt_tx(vif, buf, len);
	tx_status = (rc == 0);

	kfree(cmd);
 out:
	cfg80211_mgmt_tx_status(wdev, cookie ? *cookie : 0, buf, len,
				tx_status, GFP_KERNEL);
	return rc;
+1 −0
Original line number Diff line number Diff line
@@ -1362,6 +1362,7 @@ int wmi_set_snr_thresh(struct wil6210_priv *wil, short omni, short direct);
int wmi_start_sched_scan(struct wil6210_priv *wil,
			 struct cfg80211_sched_scan_request *request);
int wmi_stop_sched_scan(struct wil6210_priv *wil);
int wmi_mgmt_tx(struct wil6210_vif *vif, const u8 *buf, size_t len);

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

+47 −0
Original line number Diff line number Diff line
@@ -3095,6 +3095,53 @@ int wmi_stop_sched_scan(struct wil6210_priv *wil)
	return 0;
}

int wmi_mgmt_tx(struct wil6210_vif *vif, const u8 *buf, size_t len)
{
	size_t total;
	struct wil6210_priv *wil = vif_to_wil(vif);
	struct ieee80211_mgmt *mgmt_frame = (void *)buf;
	struct wmi_sw_tx_req_cmd *cmd;
	struct {
		struct wmi_cmd_hdr wmi;
		struct wmi_sw_tx_complete_event evt;
	} __packed evt = {
		.evt = {.status = WMI_FW_STATUS_FAILURE},
	};
	int rc;

	wil_dbg_misc(wil, "mgmt_tx mid %d\n", vif->mid);
	wil_hex_dump_misc("mgmt tx frame ", DUMP_PREFIX_OFFSET, 16, 1, buf,
			  len, true);

	if (len < sizeof(struct ieee80211_hdr_3addr))
		return -EINVAL;

	total = sizeof(*cmd) + len;
	if (total < len) {
		wil_err(wil, "mgmt_tx invalid len %zu\n", len);
		return -EINVAL;
	}

	cmd = kmalloc(total, GFP_KERNEL);
	if (!cmd)
		return -ENOMEM;

	memcpy(cmd->dst_mac, mgmt_frame->da, WMI_MAC_LEN);
	cmd->len = cpu_to_le16(len);
	memcpy(cmd->payload, buf, len);

	rc = wmi_call(wil, WMI_SW_TX_REQ_CMDID, vif->mid, cmd, total,
		      WMI_SW_TX_COMPLETE_EVENTID, &evt, sizeof(evt), 2000);
	if (!rc && evt.evt.status != WMI_FW_STATUS_SUCCESS) {
		wil_err(wil, "mgmt_tx failed with status %d\n", evt.evt.status);
		rc = -EINVAL;
	}

	kfree(cmd);

	return rc;
}

int wil_wmi_tx_sring_cfg(struct wil6210_priv *wil, int ring_id)
{
	int rc;