linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 099/306] mac80211-hwsim: notify user-space about channel change.
@ 2017-02-24  0:28 greearb
  2017-02-24  0:28 ` [PATCH 100/306] mac80211-hwsim: remove dmesg spam about get-survey greearb
                   ` (6 more replies)
  0 siblings, 7 replies; 26+ messages in thread
From: greearb @ 2017-02-24  0:28 UTC (permalink / raw)
  To: linux-wireless; +Cc: Ben Greear

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>
---
 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 d3bad57..af53317 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -1005,6 +1005,52 @@ static int hwsim_unicast_netgroup(struct mac80211_hwsim_data *data,
 	return res;
 }
 
+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(data->wmediumd);
+
+	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)
@@ -1622,6 +1668,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 39f2246..73646b1 100644
--- a/drivers/net/wireless/mac80211_hwsim.h
+++ b/drivers/net/wireless/mac80211_hwsim.h
@@ -71,6 +71,11 @@ enum hwsim_tx_control_flags {
  * @HWSIM_CMD_DEL_RADIO: destroy a radio, reply is multicasted
  * @HWSIM_CMD_GET_RADIO: fetch information about existing radios, uses:
  *	%HWSIM_ATTR_RADIO_ID
+ * @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 {
@@ -81,6 +86,7 @@ enum {
 	HWSIM_CMD_NEW_RADIO,
 	HWSIM_CMD_DEL_RADIO,
 	HWSIM_CMD_GET_RADIO,
+	HWSIM_CMD_NOTIFY,
 	__HWSIM_CMD_MAX,
 };
 #define HWSIM_CMD_MAX (_HWSIM_CMD_MAX - 1)
-- 
2.4.11

^ permalink raw reply related	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2017-03-02 14:40 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-24  0:28 [PATCH 099/306] mac80211-hwsim: notify user-space about channel change greearb
2017-02-24  0:28 ` [PATCH 100/306] mac80211-hwsim: remove dmesg spam about get-survey greearb
2017-02-24  6:36   ` Johannes Berg
2017-02-24  0:28 ` [PATCH 101/306] mac80211-hwsim: Pass rate-ctrl flags and tx-power to user-space greearb
2017-02-24  6:37   ` Johannes Berg
2017-02-24  0:28 ` [PATCH 102/306] mac80211-hwsim: enable better rx-status when using netlink greearb
2017-02-24  6:38   ` Johannes Berg
2017-02-24  0:28 ` [PATCH 160/306] mac80211-hwsim: add rate-limited debugging for rx-netlink greearb
2017-02-24  6:39   ` Johannes Berg
2017-02-24 15:27     ` Ben Greear
2017-02-27 14:33       ` Johannes Berg
2017-02-24  0:28 ` [PATCH 161/306] mac80211-hwsim: Improve logging greearb
2017-02-24  6:42   ` Johannes Berg
2017-02-24 15:26     ` Ben Greear
2017-02-24  0:28 ` [PATCH 162/306] mac80211-hwsim: add length checks before allocating skb greearb
2017-02-24  6:43   ` Johannes Berg
2017-02-24  8:45   ` Andrew Zaborowski
2017-02-24 15:19     ` Ben Greear
2017-02-24  6:36 ` [PATCH 099/306] mac80211-hwsim: notify user-space about channel change Johannes Berg
2017-02-24 15:39   ` Ben Greear
2017-02-27 14:34     ` Johannes Berg
2017-02-27 20:48   ` Ben Greear
2017-03-02  8:38     ` Johannes Berg
2017-03-02 14:26       ` Ben Greear
2017-02-27 21:00   ` Ben Greear
2017-03-02  8:39     ` Johannes Berg

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).