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

Commit 17011da0 authored by Igor Mitsyanko's avatar Igor Mitsyanko Committed by Kalle Valo
Browse files

qtnfmac: configure and start AP interface with a single command



Current logic artificially divides "start AP" procedure into three
stages:
- generic interface configuration (security, channel etc)
- IE's processing
- enable AP mode on interface

This separation would not allow to do a proper device configuration as
first stage needs to use information from IEs that are processed on
a second stage. Which means first and second stages have to be meged.
In that case there is no point anymore to keep third stage either, so
merge all three into a single command.

This new command carries all the same info as contained in
"struct cfg80211_ap_settings".

Signed-off-by: default avatarIgor Mitsyanko <igor.mitsyanko.os@quantenna.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 4d1f0fab
Loading
Loading
Loading
Loading
+1 −16
Original line number Diff line number Diff line
@@ -271,26 +271,11 @@ static int qtnf_start_ap(struct wiphy *wiphy, struct net_device *dev,
	struct qtnf_vif *vif = qtnf_netdev_get_priv(dev);
	int ret;

	ret = qtnf_cmd_send_config_ap(vif, settings);
	if (ret) {
		pr_err("VIF%u.%u: failed to push config to FW\n",
		       vif->mac->macid, vif->vifid);
		goto out;
	}

	ret = qtnf_mgmt_set_appie(vif, &settings->beacon);
	if (ret) {
		pr_err("VIF%u.%u: failed to add IEs to beacon\n",
		       vif->mac->macid, vif->vifid);
		goto out;
	}

	ret = qtnf_cmd_send_start_ap(vif);
	ret = qtnf_cmd_send_start_ap(vif, settings);
	if (ret)
		pr_err("VIF%u.%u: failed to start AP\n", vif->mac->macid,
		       vif->vifid);

out:
	return ret;
}

+42 −30
Original line number Diff line number Diff line
@@ -162,56 +162,51 @@ static void qtnf_cmd_tlv_ie_set_add(struct sk_buff *cmd_skb, u8 frame_type,
		memcpy(tlv->ie_data, buf, len);
}

int qtnf_cmd_send_start_ap(struct qtnf_vif *vif)
static bool qtnf_cmd_start_ap_can_fit(const struct qtnf_vif *vif,
				      const struct cfg80211_ap_settings *s)
{
	struct sk_buff *cmd_skb;
	u16 res_code = QLINK_CMD_RESULT_OK;
	int ret;

	cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid,
					    QLINK_CMD_START_AP,
					    sizeof(struct qlink_cmd));
	if (unlikely(!cmd_skb))
		return -ENOMEM;

	qtnf_bus_lock(vif->mac->bus);
	unsigned int len = sizeof(struct qlink_cmd_start_ap);

	ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code);
	len += s->ssid_len;
	len += s->beacon.head_len;
	len += s->beacon.tail_len;
	len += s->beacon.beacon_ies_len;
	len += s->beacon.proberesp_ies_len;
	len += s->beacon.assocresp_ies_len;
	len += s->beacon.probe_resp_len;

	if (unlikely(ret))
		goto out;
	if (cfg80211_chandef_valid(&s->chandef))
		len += sizeof(struct qlink_tlv_chandef);

	if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
		pr_err("VIF%u.%u: CMD failed: %u\n", vif->mac->macid,
		       vif->vifid, res_code);
		ret = -EFAULT;
		goto out;
	if (len > (sizeof(struct qlink_cmd) + QTNF_MAX_CMD_BUF_SIZE)) {
		pr_err("VIF%u.%u: can not fit AP settings: %u\n",
		       vif->mac->macid, vif->vifid, len);
		return false;
	}

	netif_carrier_on(vif->netdev);

out:
	qtnf_bus_unlock(vif->mac->bus);
	return ret;
	return true;
}

int qtnf_cmd_send_config_ap(struct qtnf_vif *vif,
int qtnf_cmd_send_start_ap(struct qtnf_vif *vif,
			   const struct cfg80211_ap_settings *s)
{
	struct sk_buff *cmd_skb;
	struct qlink_cmd_config_ap *cmd;
	struct qlink_cmd_start_ap *cmd;
	struct qlink_auth_encr *aen;
	u16 res_code = QLINK_CMD_RESULT_OK;
	int ret;
	int i;

	if (!qtnf_cmd_start_ap_can_fit(vif, s))
		return -E2BIG;

	cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid,
					    QLINK_CMD_CONFIG_AP,
					    QLINK_CMD_START_AP,
					    sizeof(*cmd));
	if (unlikely(!cmd_skb))
		return -ENOMEM;

	cmd = (struct qlink_cmd_config_ap *)cmd_skb->data;
	cmd = (struct qlink_cmd_start_ap *)cmd_skb->data;
	cmd->dtim_period = s->dtim_period;
	cmd->beacon_interval = cpu_to_le16(s->beacon_interval);
	cmd->hidden_ssid = qlink_hidden_ssid_nl2q(s->hidden_ssid);
@@ -256,6 +251,21 @@ int qtnf_cmd_send_config_ap(struct qtnf_vif *vif,
		qlink_chandef_cfg2q(&s->chandef, &chtlv->chan);
	}

	qtnf_cmd_tlv_ie_set_add(cmd_skb, QLINK_IE_SET_BEACON_HEAD,
				s->beacon.head, s->beacon.head_len);
	qtnf_cmd_tlv_ie_set_add(cmd_skb, QLINK_IE_SET_BEACON_TAIL,
				s->beacon.tail, s->beacon.tail_len);
	qtnf_cmd_tlv_ie_set_add(cmd_skb, QLINK_IE_SET_BEACON_IES,
				s->beacon.beacon_ies, s->beacon.beacon_ies_len);
	qtnf_cmd_tlv_ie_set_add(cmd_skb, QLINK_IE_SET_PROBE_RESP,
				s->beacon.probe_resp, s->beacon.probe_resp_len);
	qtnf_cmd_tlv_ie_set_add(cmd_skb, QLINK_IE_SET_PROBE_RESP_IES,
				s->beacon.proberesp_ies,
				s->beacon.proberesp_ies_len);
	qtnf_cmd_tlv_ie_set_add(cmd_skb, QLINK_IE_SET_ASSOC_RESP,
				s->beacon.assocresp_ies,
				s->beacon.assocresp_ies_len);

	qtnf_bus_lock(vif->mac->bus);

	ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code);
@@ -270,6 +280,8 @@ int qtnf_cmd_send_config_ap(struct qtnf_vif *vif,
		goto out;
	}

	netif_carrier_on(vif->netdev);

out:
	qtnf_bus_unlock(vif->mac->bus);
	return ret;
+2 −3
Original line number Diff line number Diff line
@@ -33,9 +33,8 @@ int qtnf_cmd_send_del_intf(struct qtnf_vif *vif);
int qtnf_cmd_band_info_get(struct qtnf_wmac *mac,
			   struct ieee80211_supported_band *band);
int qtnf_cmd_send_regulatory_config(struct qtnf_wmac *mac, const char *alpha2);
int qtnf_cmd_send_config_ap(struct qtnf_vif *vif,
int qtnf_cmd_send_start_ap(struct qtnf_vif *vif,
			   const struct cfg80211_ap_settings *s);
int qtnf_cmd_send_start_ap(struct qtnf_vif *vif);
int qtnf_cmd_send_stop_ap(struct qtnf_vif *vif);
int qtnf_cmd_send_register_mgmt(struct qtnf_vif *vif, u16 frame_type, bool reg);
int qtnf_cmd_send_mgmt_frame(struct qtnf_vif *vif, u32 cookie, u16 flags,
+2 −3
Original line number Diff line number Diff line
@@ -192,7 +192,6 @@ enum qlink_cmd_type {
	QLINK_CMD_BAND_INFO_GET		= 0x001A,
	QLINK_CMD_CHAN_SWITCH		= 0x001B,
	QLINK_CMD_CHAN_GET		= 0x001C,
	QLINK_CMD_CONFIG_AP		= 0x0020,
	QLINK_CMD_START_AP		= 0x0021,
	QLINK_CMD_STOP_AP		= 0x0022,
	QLINK_CMD_GET_STA_INFO		= 0x0030,
@@ -542,7 +541,7 @@ enum qlink_hidden_ssid {
};

/**
 * struct qlink_cmd_config_ap - data for QLINK_CMD_CONFIG_AP command
 * struct qlink_cmd_start_ap - data for QLINK_CMD_START_AP command
 *
 * @beacon_interval: beacon interval
 * @inactivity_timeout: station's inactivity period in seconds
@@ -554,7 +553,7 @@ enum qlink_hidden_ssid {
 * @aen: encryption info
 * @info: variable configurations
 */
struct qlink_cmd_config_ap {
struct qlink_cmd_start_ap {
	struct qlink_cmd chdr;
	__le16 beacon_interval;
	__le16 inactivity_timeout;