From: greearb@candelatech.com
To: johannes@sipsolutions.net
Cc: linux-wireless@vger.kernel.org, Ben Greear <greearb@candelatech.com>
Subject: [RFC] mac80211_hwsim: notify user-space about channel change.
Date: Tue, 17 Feb 2015 15:59:48 -0800 [thread overview]
Message-ID: <1424217588-29558-1-git-send-email-greearb@candelatech.com> (raw)
From: Ben Greear <greearb@candelatech.com>
The goal is to allow the user-space application to properly
filter packets before sending them down to the kernel. This
should more closely mimic what a real piece of hardware would
do.
Signed-off-by: Ben Greear <greearb@candelatech.com>
---
This is against 3.17.8 (plus some hacks and back-ports).
I think this will work for my own needs, but I am curious if others
have suggestions for improvement.
drivers/net/wireless/mac80211_hwsim.c | 48 +++++++++++++++++++++++++++++++++++
drivers/net/wireless/mac80211_hwsim.h | 6 +++++
2 files changed, 54 insertions(+)
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index a3aaf37..3a45a45 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -851,6 +851,52 @@ static bool hwsim_ps_rx_ok(struct mac80211_hwsim_data *data,
return true;
}
+static void mac80211_hwsim_check_nl_notify(struct mac80211_hwsim_data *data)
+{
+ struct sk_buff *skb;
+ u32 center_freq = 0;
+ u32 _portid;
+ void *msg_head;
+
+ /* wmediumd mode check */
+ _portid = ACCESS_ONCE(wmediumd_portid);
+
+ if (!_portid)
+ return;
+
+ skb = genlmsg_new(GENLMSG_DEFAULT_SIZE, GFP_ATOMIC);
+ if (skb == NULL)
+ goto err_print;
+
+ msg_head = genlmsg_put(skb, 0, 0, &hwsim_genl_family, 0,
+ HWSIM_CMD_NOTIFY);
+ if (msg_head == NULL) {
+ printk(KERN_DEBUG "mac80211_hwsim: problem with msg_head, notify\n");
+ goto nla_put_failure;
+ }
+
+ if (nla_put(skb, HWSIM_ATTR_ADDR_TRANSMITTER,
+ ETH_ALEN, data->addresses[1].addr))
+ goto nla_put_failure;
+
+ if (data->channel)
+ center_freq = data->channel->center_freq;
+
+ if (nla_put_u32(skb, HWSIM_ATTR_FREQ, center_freq))
+ goto nla_put_failure;
+
+ genlmsg_end(skb, msg_head);
+ if (genlmsg_unicast(&init_net, skb, _portid))
+ goto err_print;
+
+ return;
+
+nla_put_failure:
+ nlmsg_free(skb);
+err_print:
+ printk(KERN_DEBUG "mac80211_hwsim: error occurred in %s\n", __func__);
+}
+
static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw,
struct sk_buff *my_skb,
int dst_portid)
@@ -1399,6 +1445,8 @@ static int mac80211_hwsim_config(struct ieee80211_hw *hw, u32 changed)
HRTIMER_MODE_REL);
}
+ mac80211_hwsim_check_nl_notify(data);
+
return 0;
}
diff --git a/drivers/net/wireless/mac80211_hwsim.h b/drivers/net/wireless/mac80211_hwsim.h
index 85da35a..8f2306a 100644
--- a/drivers/net/wireless/mac80211_hwsim.h
+++ b/drivers/net/wireless/mac80211_hwsim.h
@@ -68,6 +68,11 @@ enum hwsim_tx_control_flags {
* @HWSIM_CMD_CREATE_RADIO: create a new radio with the given parameters,
* returns the radio ID (>= 0) or negative on errors
* @HWSIM_CMD_DESTROY_RADIO: destroy a radio
+ * @HWSIM_CMD_NOTIFY: notify user-space about driver changes. This is
+ * designed to help the user-space app better emulate radio hardware.
+ * This command uses:
+ * %HWSIM_ATTR_FREQ # Notify current operating center frequency.
+ * %HWSIM_ATTR_ADDR_TRANSMITTER # ID which radio we are notifying about.
* @__HWSIM_CMD_MAX: enum limit
*/
enum {
@@ -77,6 +82,7 @@ enum {
HWSIM_CMD_TX_INFO_FRAME,
HWSIM_CMD_CREATE_RADIO,
HWSIM_CMD_DESTROY_RADIO,
+ HWSIM_CMD_NOTIFY,
__HWSIM_CMD_MAX,
};
#define HWSIM_CMD_MAX (_HWSIM_CMD_MAX - 1)
--
1.7.11.7
next reply other threads:[~2015-02-17 23:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-17 23:59 greearb [this message]
2015-02-23 11:49 ` [RFC] mac80211_hwsim: notify user-space about channel change Johannes Berg
2015-02-23 17:43 ` Ben Greear
2015-02-24 10:11 ` Johannes Berg
2015-02-24 14:36 ` Ben Greear
2015-02-24 14:40 ` Johannes Berg
2015-03-11 21:05 ` Ben Greear
2015-03-31 14:27 ` Johannes Berg
2015-03-31 15:56 ` Ben Greear
2015-04-14 8:13 ` Johannes Berg
2015-04-14 14:56 ` Ben Greear
2015-04-14 15:06 ` Johannes Berg
2015-04-14 15:55 ` Ben Greear
2015-04-15 9:33 ` Johannes Berg
2015-04-15 15:06 ` Ben Greear
2015-04-17 11:25 ` Johannes Berg
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=1424217588-29558-1-git-send-email-greearb@candelatech.com \
--to=greearb@candelatech.com \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
/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).