From: Victor Goldenshtein <victorg@ti.com>
To: <hostap@lists.shmoo.com>
Cc: <linux-wireless@vger.kernel.org>, <kgiori@qca.qualcomm.com>,
<mcgrof@frijolero.org>, <zefir.kurtisi@neratec.com>,
<adrian.chadd@gmail.com>, <j@w1.fi>, <johannes@sipsolutions.net>,
<coelho@ti.com>, <assaf@ti.com>, <yoni.divinsky@ti.com>,
<igalc@ti.com>, <adrian@freebsd.org>, <nbd@nbd.name>,
<simon.wunderlich@s2003.tu-chemnitz.de>
Subject: [PATCH v3 6/7] nl80211: add channel switch command/event
Date: Wed, 8 Aug 2012 14:55:37 +0300 [thread overview]
Message-ID: <1344426938-1883-7-git-send-email-victorg@ti.com> (raw)
In-Reply-To: <1344426938-1883-1-git-send-email-victorg@ti.com>
Implement AP channel switch command and handle
channel switch complete event.
Signed-hostap: Boris Presman <boris.presman@ti.com>
Signed-hostap: Victor Goldenshtein <victorg@ti.com>
---
src/drivers/driver_nl80211.c | 65 +++++++++++++++++++++++++++++++++++++++--
1 files changed, 61 insertions(+), 4 deletions(-)
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index fadd4cb..c2780a4 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -1197,7 +1197,8 @@ static void mlme_event_disconnect(struct wpa_driver_nl80211_data *drv,
static void mlme_event_ch_switch(struct wpa_driver_nl80211_data *drv,
- struct nlattr *freq, struct nlattr *type)
+ struct nlattr *freq, struct nlattr *type,
+ enum wpa_event_type event)
{
union wpa_event_data data;
int ht_enabled = 1;
@@ -1226,7 +1227,7 @@ static void mlme_event_ch_switch(struct wpa_driver_nl80211_data *drv,
data.ch_switch.ht_enabled = ht_enabled;
data.ch_switch.ch_offset = chan_offset;
- wpa_supplicant_event(drv->ctx, EVENT_CH_SWITCH, &data);
+ wpa_supplicant_event(drv->ctx, event, &data);
}
@@ -2151,8 +2152,18 @@ static void do_process_drv_event(struct wpa_driver_nl80211_data *drv,
tb[NL80211_ATTR_RESP_IE]);
break;
case NL80211_CMD_CH_SWITCH_NOTIFY:
- mlme_event_ch_switch(drv, tb[NL80211_ATTR_WIPHY_FREQ],
- tb[NL80211_ATTR_WIPHY_CHANNEL_TYPE]);
+ /*
+ * TODO: as soon as GO will support DFS, AP
+ * and GO channel switches should be united.
+ */
+ if (drv->nlmode == NL80211_IFTYPE_AP)
+ mlme_event_ch_switch(drv, tb[NL80211_ATTR_WIPHY_FREQ],
+ tb[NL80211_ATTR_WIPHY_CHANNEL_TYPE],
+ EVENT_AP_CH_SWITCH_COMPLETE);
+ else
+ mlme_event_ch_switch(drv, tb[NL80211_ATTR_WIPHY_FREQ],
+ tb[NL80211_ATTR_WIPHY_CHANNEL_TYPE],
+ EVENT_CH_SWITCH);
break;
case NL80211_CMD_DISCONNECT:
mlme_event_disconnect(drv, tb[NL80211_ATTR_REASON_CODE],
@@ -8876,6 +8887,51 @@ nla_put_failure:
}
+static int nl80211_ap_channel_switch(void *priv,
+ struct hostapd_channel_switch *params)
+{
+ struct i802_bss *bss = priv;
+ struct wpa_driver_nl80211_data *drv = bss->drv;
+ struct nl_msg *msg;
+ int ret;
+
+ wpa_printf(MSG_DEBUG, "nl80211: Channel switch, "
+ "ch_switch_count = %d, tx_block = %d, "
+ "freq = %d, post_switch_block_tx = %d.",
+ params->ch_switch_count, params->tx_block,
+ params->freq, params->post_switch_block_tx);
+
+ msg = nlmsg_alloc();
+ if (!msg)
+ return -1;
+
+ nl80211_cmd(bss->drv, msg, 0, NL80211_CMD_AP_CH_SWITCH);
+
+ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->ifindex);
+ NLA_PUT_U32(msg, NL80211_ATTR_CH_SWITCH_COUNT, params->ch_switch_count);
+ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, params->freq);
+
+ /* only HT20 is supported at this point */
+ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, NL80211_CHAN_HT20);
+
+ if (params->tx_block)
+ NLA_PUT_FLAG(msg, NL80211_ATTR_CH_SWITCH_BLOCK_TX);
+
+ if (params->post_switch_block_tx)
+ NLA_PUT_FLAG(msg, NL80211_ATTR_CH_SWITCH_POST_BLOCK_TX);
+
+ ret = send_and_recv_msgs(drv, msg, NULL, NULL);
+ if (ret == 0) {
+ bss->freq = params->freq;
+ return 0;
+ }
+ wpa_printf(MSG_DEBUG, "nl80211: Failed to channel switch: "
+ "%d (%s)", ret, strerror(-ret));
+nla_put_failure:
+ return -1;
+}
+
+
#ifdef CONFIG_TDLS
static int nl80211_send_tdls_mgmt(void *priv, const u8 *dst, u8 action_code,
@@ -9171,6 +9227,7 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = {
.poll_client = nl80211_poll_client,
.set_p2p_powersave = nl80211_set_p2p_powersave,
.enable_tx = nl80211_enable_dfs_tx,
+ .hapd_channel_switch = nl80211_ap_channel_switch,
#ifdef CONFIG_TDLS
.send_tdls_mgmt = nl80211_send_tdls_mgmt,
.tdls_oper = nl80211_tdls_oper,
--
1.7.5.4
next prev parent reply other threads:[~2012-08-08 12:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-08 11:55 [PATCH v3 0/7] hostap: add DFS master ability Victor Goldenshtein
2012-08-08 11:55 ` [PATCH v3 1/7] hostapd: implement dfs drv ops functions Victor Goldenshtein
2012-08-08 11:55 ` [PATCH v3 2/7] hostapd: add channel switch ability Victor Goldenshtein
2012-08-08 11:55 ` [PATCH v3 3/7] hostapd: add dfs events Victor Goldenshtein
2012-08-08 11:55 ` [PATCH v3 4/7] hostapd: add dfs support into interface init flow Victor Goldenshtein
2012-08-08 11:55 ` [PATCH v3 5/7] nl80211: add support to enable TX on oper-channel Victor Goldenshtein
2012-08-08 11:55 ` Victor Goldenshtein [this message]
2012-08-08 11:55 ` [PATCH v3 7/7] nl80211: add start radar detection command/event Victor Goldenshtein
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1344426938-1883-7-git-send-email-victorg@ti.com \
--to=victorg@ti.com \
--cc=adrian.chadd@gmail.com \
--cc=adrian@freebsd.org \
--cc=assaf@ti.com \
--cc=coelho@ti.com \
--cc=hostap@lists.shmoo.com \
--cc=igalc@ti.com \
--cc=j@w1.fi \
--cc=johannes@sipsolutions.net \
--cc=kgiori@qca.qualcomm.com \
--cc=linux-wireless@vger.kernel.org \
--cc=mcgrof@frijolero.org \
--cc=nbd@nbd.name \
--cc=simon.wunderlich@s2003.tu-chemnitz.de \
--cc=yoni.divinsky@ti.com \
--cc=zefir.kurtisi@neratec.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).