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

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
...@@ -271,26 +271,11 @@ static int qtnf_start_ap(struct wiphy *wiphy, struct net_device *dev, ...@@ -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); struct qtnf_vif *vif = qtnf_netdev_get_priv(dev);
int ret; int ret;
ret = qtnf_cmd_send_config_ap(vif, settings); ret = qtnf_cmd_send_start_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);
if (ret) if (ret)
pr_err("VIF%u.%u: failed to start AP\n", vif->mac->macid, pr_err("VIF%u.%u: failed to start AP\n", vif->mac->macid,
vif->vifid); vif->vifid);
out:
return ret; return ret;
} }
......
...@@ -162,56 +162,51 @@ static void qtnf_cmd_tlv_ie_set_add(struct sk_buff *cmd_skb, u8 frame_type, ...@@ -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); 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; unsigned int len = sizeof(struct qlink_cmd_start_ap);
u16 res_code = QLINK_CMD_RESULT_OK;
int ret;
cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, len += s->ssid_len;
QLINK_CMD_START_AP, len += s->beacon.head_len;
sizeof(struct qlink_cmd)); len += s->beacon.tail_len;
if (unlikely(!cmd_skb)) len += s->beacon.beacon_ies_len;
return -ENOMEM; len += s->beacon.proberesp_ies_len;
len += s->beacon.assocresp_ies_len;
len += s->beacon.probe_resp_len;
qtnf_bus_lock(vif->mac->bus); if (cfg80211_chandef_valid(&s->chandef))
len += sizeof(struct qlink_tlv_chandef);
ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code);
if (unlikely(ret)) if (len > (sizeof(struct qlink_cmd) + QTNF_MAX_CMD_BUF_SIZE)) {
goto out; pr_err("VIF%u.%u: can not fit AP settings: %u\n",
vif->mac->macid, vif->vifid, len);
if (unlikely(res_code != QLINK_CMD_RESULT_OK)) { return false;
pr_err("VIF%u.%u: CMD failed: %u\n", vif->mac->macid,
vif->vifid, res_code);
ret = -EFAULT;
goto out;
} }
netif_carrier_on(vif->netdev); return true;
out:
qtnf_bus_unlock(vif->mac->bus);
return ret;
} }
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) const struct cfg80211_ap_settings *s)
{ {
struct sk_buff *cmd_skb; struct sk_buff *cmd_skb;
struct qlink_cmd_config_ap *cmd; struct qlink_cmd_start_ap *cmd;
struct qlink_auth_encr *aen; struct qlink_auth_encr *aen;
u16 res_code = QLINK_CMD_RESULT_OK; u16 res_code = QLINK_CMD_RESULT_OK;
int ret; int ret;
int i; 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, cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid,
QLINK_CMD_CONFIG_AP, QLINK_CMD_START_AP,
sizeof(*cmd)); sizeof(*cmd));
if (unlikely(!cmd_skb)) if (unlikely(!cmd_skb))
return -ENOMEM; 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->dtim_period = s->dtim_period;
cmd->beacon_interval = cpu_to_le16(s->beacon_interval); cmd->beacon_interval = cpu_to_le16(s->beacon_interval);
cmd->hidden_ssid = qlink_hidden_ssid_nl2q(s->hidden_ssid); cmd->hidden_ssid = qlink_hidden_ssid_nl2q(s->hidden_ssid);
...@@ -256,6 +251,21 @@ int qtnf_cmd_send_config_ap(struct qtnf_vif *vif, ...@@ -256,6 +251,21 @@ int qtnf_cmd_send_config_ap(struct qtnf_vif *vif,
qlink_chandef_cfg2q(&s->chandef, &chtlv->chan); 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); qtnf_bus_lock(vif->mac->bus);
ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); 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, ...@@ -270,6 +280,8 @@ int qtnf_cmd_send_config_ap(struct qtnf_vif *vif,
goto out; goto out;
} }
netif_carrier_on(vif->netdev);
out: out:
qtnf_bus_unlock(vif->mac->bus); qtnf_bus_unlock(vif->mac->bus);
return ret; return ret;
......
...@@ -33,9 +33,8 @@ int qtnf_cmd_send_del_intf(struct qtnf_vif *vif); ...@@ -33,9 +33,8 @@ int qtnf_cmd_send_del_intf(struct qtnf_vif *vif);
int qtnf_cmd_band_info_get(struct qtnf_wmac *mac, int qtnf_cmd_band_info_get(struct qtnf_wmac *mac,
struct ieee80211_supported_band *band); struct ieee80211_supported_band *band);
int qtnf_cmd_send_regulatory_config(struct qtnf_wmac *mac, const char *alpha2); 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); 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_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_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, int qtnf_cmd_send_mgmt_frame(struct qtnf_vif *vif, u32 cookie, u16 flags,
......
...@@ -192,7 +192,6 @@ enum qlink_cmd_type { ...@@ -192,7 +192,6 @@ enum qlink_cmd_type {
QLINK_CMD_BAND_INFO_GET = 0x001A, QLINK_CMD_BAND_INFO_GET = 0x001A,
QLINK_CMD_CHAN_SWITCH = 0x001B, QLINK_CMD_CHAN_SWITCH = 0x001B,
QLINK_CMD_CHAN_GET = 0x001C, QLINK_CMD_CHAN_GET = 0x001C,
QLINK_CMD_CONFIG_AP = 0x0020,
QLINK_CMD_START_AP = 0x0021, QLINK_CMD_START_AP = 0x0021,
QLINK_CMD_STOP_AP = 0x0022, QLINK_CMD_STOP_AP = 0x0022,
QLINK_CMD_GET_STA_INFO = 0x0030, QLINK_CMD_GET_STA_INFO = 0x0030,
...@@ -542,7 +541,7 @@ enum qlink_hidden_ssid { ...@@ -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 * @beacon_interval: beacon interval
* @inactivity_timeout: station's inactivity period in seconds * @inactivity_timeout: station's inactivity period in seconds
...@@ -554,7 +553,7 @@ enum qlink_hidden_ssid { ...@@ -554,7 +553,7 @@ enum qlink_hidden_ssid {
* @aen: encryption info * @aen: encryption info
* @info: variable configurations * @info: variable configurations
*/ */
struct qlink_cmd_config_ap { struct qlink_cmd_start_ap {
struct qlink_cmd chdr; struct qlink_cmd chdr;
__le16 beacon_interval; __le16 beacon_interval;
__le16 inactivity_timeout; __le16 inactivity_timeout;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment