linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Wagner <wagi@monom.org>
To: linux-wireless@vger.kernel.org
Subject: [RFC] Simulate medium behavior
Date: Wed, 22 Apr 2009 11:21:59 +0200	[thread overview]
Message-ID: <20090422092159.GA24586@toronto053.server4you.de> (raw)

Hi,

I'm still working improving the scan behavior of NM. Yes, I'm
terrible slow.  One thing which would help for this work is to
simulate the wireless medium.

Below is my humble try to get a knob for enabling/disabling 
tx/rx. The variable name 'medium' is not really good, though
I didn't come up with something better.

Writing a 0 to /debug/ieee80211/phy*/hwsim/medium enables rx/tx for
the specific phy. Writing anything but 0 disables rx/tx.  Not a very
good API. It could be made something more realistic like reception
quality is 80% associated some statistical dropping algorithm. Any
thoughts?

Is this the right direction I'm heading to?

thanks,
daniel

---
 drivers/net/wireless/mac80211_hwsim.c |   32 +++++++++++++++++++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index d4fdc8b..6373226 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -291,6 +291,9 @@ struct mac80211_hwsim_data {
 	bool ps_poll_pending;
 	struct dentry *debugfs;
 	struct dentry *debugfs_ps;
+
+	struct dentry *debugfs_medium;
+	unsigned int medium;
 };
 
 
@@ -399,6 +402,11 @@ static bool mac80211_hwsim_tx_frame(struct ieee80211_hw *hw,
 	rx_status.rate_idx = info->control.rates[0].idx;
 	/* TODO: simulate signal strength (and optional packet drop) */
 
+	if (data->medium != 0) {
+		/* drop packet, no ack received */
+		return false;
+	}
+
 	if (data->ps != PS_DISABLED)
 		hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM);
 
@@ -412,7 +420,8 @@ static bool mac80211_hwsim_tx_frame(struct ieee80211_hw *hw,
 
 		if (!data2->started || !data2->radio_enabled ||
 		    !hwsim_ps_rx_ok(data2, skb) ||
-		    data->channel->center_freq != data2->channel->center_freq)
+		    data->channel->center_freq != data2->channel->center_freq ||
+		    data2->medium != 0)
 			continue;
 
 		nskb = skb_copy(skb, GFP_ATOMIC);
@@ -725,6 +734,7 @@ static void mac80211_hwsim_free(void)
 	spin_unlock_bh(&hwsim_radio_lock);
 
 	list_for_each_entry(data, &tmplist, list) {
+		debugfs_remove(data->debugfs_medium);
 		debugfs_remove(data->debugfs_ps);
 		debugfs_remove(data->debugfs);
 		ieee80211_unregister_hw(data->hw);
@@ -876,6 +886,22 @@ static int hwsim_fops_ps_write(void *dat, u64 val)
 DEFINE_SIMPLE_ATTRIBUTE(hwsim_fops_ps, hwsim_fops_ps_read, hwsim_fops_ps_write,
 			"%llu\n");
 
+static int hwsim_fops_medium_read(void *dat, u64 *val)
+{
+	struct mac80211_hwsim_data *data = dat;
+	*val = data->medium;
+	return 0;
+}
+
+static int hwsim_fops_medium_write(void *dat, u64 val)
+{
+	struct mac80211_hwsim_data *data = dat;
+	data->medium = val;
+	return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(hwsim_fops_medium, hwsim_fops_medium_read, hwsim_fops_medium_write,
+			"%llu\n");
 
 static int __init init_mac80211_hwsim(void)
 {
@@ -1106,6 +1132,10 @@ static int __init init_mac80211_hwsim(void)
 						       data->debugfs, data,
 						       &hwsim_fops_ps);
 
+		data->debugfs_medium = debugfs_create_file("medium", 0666,
+							   data->debugfs, data,
+							   &hwsim_fops_medium);
+
 		setup_timer(&data->beacon_timer, mac80211_hwsim_beacon,
 			    (unsigned long) hw);
 
-- 
1.6.0.2.GIT


             reply	other threads:[~2009-04-22  9:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-22  9:21 Daniel Wagner [this message]
2009-04-22  9:38 ` [RFC] Simulate medium behavior Johannes Berg
2009-04-22 11:35   ` Daniel Wagner
2009-05-07 18:41     ` Daniel Wagner
2009-05-07 19:02       ` Johannes Berg
2009-05-07 20:47         ` Daniel Wagner
2009-05-14 18:45         ` Daniel Wagner
2009-05-14 19:12           ` Johannes Berg
2009-05-14 20:50             ` Daniel Wagner
2009-05-14 21: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=20090422092159.GA24586@toronto053.server4you.de \
    --to=wagi@monom.org \
    --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).