linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] mac80211_hwsim: Clean up
@ 2008-06-13 16:44 Jouni Malinen
  2008-06-13 16:44 ` [PATCH 1/3] mac80211_hwsim: Clean up documentation Jouni Malinen
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jouni Malinen @ 2008-06-13 16:44 UTC (permalink / raw)
  To: John W. Linville; +Cc: Johannes Berg, linux-wireless

This set includes some minor cleanup for mac80211_hwsim based on the
comments from Johannes Berg. The patches apply on top of the
mac80211_hwsim patch I sent on Wednesday.

-- 
Jouni Malinen                                            PGP id EFC895FA

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

* [PATCH 1/3] mac80211_hwsim: Clean up documentation
  2008-06-13 16:44 [PATCH 0/3] mac80211_hwsim: Clean up Jouni Malinen
@ 2008-06-13 16:44 ` Jouni Malinen
  2008-06-13 16:44 ` [PATCH 2/3] mac80211_hwsim: Minor cleanup Jouni Malinen
  2008-06-13 16:44 ` [PATCH 3/3] mac80211_hwsim: Shared TX code for received frames and Beacons Jouni Malinen
  2 siblings, 0 replies; 4+ messages in thread
From: Jouni Malinen @ 2008-06-13 16:44 UTC (permalink / raw)
  To: John W. Linville; +Cc: Johannes Berg, linux-wireless

Clean up the introduction and fix a typo.

Signed-off-by: Jouni Malinen <j@w1.fi>


Index: wireless-testing/Documentation/networking/mac80211_hwsim/README
===================================================================
--- wireless-testing.orig/Documentation/networking/mac80211_hwsim/README
+++ wireless-testing/Documentation/networking/mac80211_hwsim/README
@@ -9,13 +9,12 @@ published by the Free Software Foundatio
 Introduction
 
 mac80211_hwsim is a Linux kernel module that can be used to simulate
-arbitrary number of IEEE 802.11 radios for mac80211 on a single
-device. It can be used to test most of the mac80211 functionality and
-user space tools (e.g., hostapd and wpa_supplicant) in a way that
-matches very closely with the normal case of using real WLAN
-hardware. From the mac80211 view point, mac80211_hwsim is yet another
-hardware driver, i.e., no changes to mac80211 are needed to use this
-testing tool.
+arbitrary number of IEEE 802.11 radios for mac80211. It can be used to
+test most of the mac80211 functionality and user space tools (e.g.,
+hostapd and wpa_supplicant) in a way that matches very closely with
+the normal case of using real WLAN hardware. From the mac80211 view
+point, mac80211_hwsim is yet another hardware driver, i.e., no changes
+to mac80211 are needed to use this testing tool.
 
 The main goal for mac80211_hwsim is to make it easier for developers
 to test their code and work with new features to mac80211, hostapd,
@@ -26,7 +25,7 @@ since all radio operation is simulated, 
 tests regardless of regulatory rules.
 
 mac80211_hwsim kernel module has a parameter 'radios' that can be used
-to select how many radios are simulates (default 2). This allows
+to select how many radios are simulated (default 2). This allows
 configuration of both very simply setups (e.g., just a single access
 point and a station) or large scale tests (multiple access points with
 hundreds of stations).

--

-- 
Jouni Malinen                                            PGP id EFC895FA

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

* [PATCH 2/3] mac80211_hwsim: Minor cleanup
  2008-06-13 16:44 [PATCH 0/3] mac80211_hwsim: Clean up Jouni Malinen
  2008-06-13 16:44 ` [PATCH 1/3] mac80211_hwsim: Clean up documentation Jouni Malinen
@ 2008-06-13 16:44 ` Jouni Malinen
  2008-06-13 16:44 ` [PATCH 3/3] mac80211_hwsim: Shared TX code for received frames and Beacons Jouni Malinen
  2 siblings, 0 replies; 4+ messages in thread
From: Jouni Malinen @ 2008-06-13 16:44 UTC (permalink / raw)
  To: John W. Linville; +Cc: Johannes Berg, linux-wireless

Remove unnecessary '__constant_' prefix and use the atomic version of
ieee80211_iterate_active_interfaces().

Signed-off-by: Jouni Malinen <j@w1.fi>


Index: wireless-testing/drivers/net/wireless/mac80211_hwsim.c
===================================================================
--- wireless-testing.orig/drivers/net/wireless/mac80211_hwsim.c
+++ wireless-testing/drivers/net/wireless/mac80211_hwsim.c
@@ -121,10 +121,9 @@ static void mac80211_hwsim_monitor_rx(st
 	hdr->hdr.it_version = PKTHDR_RADIOTAP_VERSION;
 	hdr->hdr.it_pad = 0;
 	hdr->hdr.it_len = cpu_to_le16(sizeof(*hdr));
-	hdr->hdr.it_present = __constant_cpu_to_le32(
-	     (1 << IEEE80211_RADIOTAP_FLAGS) |
-	     (1 << IEEE80211_RADIOTAP_RATE) |
-	     (1 << IEEE80211_RADIOTAP_CHANNEL));
+	hdr->hdr.it_present = cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) |
+					  (1 << IEEE80211_RADIOTAP_RATE) |
+					  (1 << IEEE80211_RADIOTAP_CHANNEL));
 	hdr->rt_flags = 0;
 	hdr->rt_rate = txrate->bitrate / 5;
 	hdr->rt_channel = data->channel->center_freq;
@@ -139,7 +138,7 @@ static void mac80211_hwsim_monitor_rx(st
 	skb_set_mac_header(skb, 0);
 	skb->ip_summed = CHECKSUM_UNNECESSARY;
 	skb->pkt_type = PACKET_OTHERHOST;
-	skb->protocol = __constant_htons(ETH_P_802_2);
+	skb->protocol = htons(ETH_P_802_2);
 	memset(skb->cb, 0, sizeof(skb->cb));
 	netif_rx(skb);
 }
@@ -309,7 +308,8 @@ static void mac80211_hwsim_beacon(unsign
 	if (!data->started || !data->radio_enabled)
 		return;
 
-	ieee80211_iterate_active_interfaces(hw, mac80211_hwsim_beacon_tx, hw);
+	ieee80211_iterate_active_interfaces_atomic(
+		hw, mac80211_hwsim_beacon_tx, hw);
 
 	data->beacon_timer.expires = jiffies + data->beacon_int;
 	add_timer(&data->beacon_timer);

--

-- 
Jouni Malinen                                            PGP id EFC895FA

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

* [PATCH 3/3] mac80211_hwsim: Shared TX code for received frames and Beacons
  2008-06-13 16:44 [PATCH 0/3] mac80211_hwsim: Clean up Jouni Malinen
  2008-06-13 16:44 ` [PATCH 1/3] mac80211_hwsim: Clean up documentation Jouni Malinen
  2008-06-13 16:44 ` [PATCH 2/3] mac80211_hwsim: Minor cleanup Jouni Malinen
@ 2008-06-13 16:44 ` Jouni Malinen
  2 siblings, 0 replies; 4+ messages in thread
From: Jouni Malinen @ 2008-06-13 16:44 UTC (permalink / raw)
  To: John W. Linville; +Cc: Johannes Berg, linux-wireless

Use a shared function for transmitting the frames instead of
duplicated code in two places.

Signed-off-by: Jouni Malinen <j@w1.fi>


Index: wireless-testing/drivers/net/wireless/mac80211_hwsim.c
===================================================================
--- wireless-testing.orig/drivers/net/wireless/mac80211_hwsim.c
+++ wireless-testing/drivers/net/wireless/mac80211_hwsim.c
@@ -144,31 +144,14 @@ static void mac80211_hwsim_monitor_rx(st
 }
 
 
-static int mac80211_hwsim_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
+static int mac80211_hwsim_tx_frame(struct ieee80211_hw *hw,
+				   struct sk_buff *skb)
 {
 	struct mac80211_hwsim_data *data = hw->priv;
-	struct ieee80211_rx_status rx_status;
 	int i, ack = 0;
-	struct ieee80211_hdr *hdr;
+	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
 	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
-	struct ieee80211_tx_info *txi;
-
-	mac80211_hwsim_monitor_rx(hw, skb);
-
-	if (skb->len < 10) {
-		/* Should not happen; just a sanity check for addr1 use */
-		dev_kfree_skb(skb);
-		return NETDEV_TX_OK;
-	}
-
-	if (!data->radio_enabled) {
-		printk(KERN_DEBUG "%s: dropped TX frame since radio "
-		       "disabled\n", wiphy_name(hw->wiphy));
-		dev_kfree_skb(skb);
-		return NETDEV_TX_OK;
-	}
-
-	hdr = (struct ieee80211_hdr *) skb->data;
+	struct ieee80211_rx_status rx_status;
 
 	memset(&rx_status, 0, sizeof(rx_status));
 	/* TODO: set mactime */
@@ -199,6 +182,33 @@ static int mac80211_hwsim_tx(struct ieee
 		ieee80211_rx_irqsafe(hwsim_radios[i], nskb, &rx_status);
 	}
 
+	return ack;
+}
+
+
+static int mac80211_hwsim_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
+{
+	struct mac80211_hwsim_data *data = hw->priv;
+	int ack;
+	struct ieee80211_tx_info *txi;
+
+	mac80211_hwsim_monitor_rx(hw, skb);
+
+	if (skb->len < 10) {
+		/* Should not happen; just a sanity check for addr1 use */
+		dev_kfree_skb(skb);
+		return NETDEV_TX_OK;
+	}
+
+	if (!data->radio_enabled) {
+		printk(KERN_DEBUG "%s: dropped TX frame since radio "
+		       "disabled\n", wiphy_name(hw->wiphy));
+		dev_kfree_skb(skb);
+		return NETDEV_TX_OK;
+	}
+
+	ack = mac80211_hwsim_tx_frame(hw, skb);
+
 	txi = IEEE80211_SKB_CB(skb);
 	memset(&txi->status, 0, sizeof(txi->status));
 	if (!(txi->flags & IEEE80211_TX_CTL_NO_ACK)) {
@@ -254,10 +264,7 @@ static void mac80211_hwsim_beacon_tx(voi
 				     struct ieee80211_vif *vif)
 {
 	struct ieee80211_hw *hw = arg;
-	struct mac80211_hwsim_data *data = hw->priv;
 	struct sk_buff *skb;
-	struct ieee80211_rx_status rx_status;
-	int i;
 	struct ieee80211_tx_info *info;
 
 	if (vif->type != IEEE80211_IF_TYPE_AP)
@@ -269,33 +276,7 @@ static void mac80211_hwsim_beacon_tx(voi
 	info = IEEE80211_SKB_CB(skb);
 
 	mac80211_hwsim_monitor_rx(hw, skb);
-
-	memset(&rx_status, 0, sizeof(rx_status));
-	/* TODO: set mactime */
-	rx_status.freq = data->channel->center_freq;
-	rx_status.band = data->channel->band;
-	rx_status.rate_idx = info->tx_rate_idx;
-	/* TODO: simulate signal strength (and optional packet drop) */
-
-	/* Copy skb to all enabled radios that are on the current frequency */
-	for (i = 0; i < hwsim_radio_count; i++) {
-		struct mac80211_hwsim_data *data2;
-		struct sk_buff *nskb;
-
-		if (hwsim_radios[i] == NULL || hwsim_radios[i] == hw)
-			continue;
-		data2 = hwsim_radios[i]->priv;
-		if (!data2->started || !data2->radio_enabled ||
-		    data->channel->center_freq != data2->channel->center_freq)
-			continue;
-
-		nskb = skb_copy(skb, GFP_ATOMIC);
-		if (nskb == NULL)
-			continue;
-
-		ieee80211_rx_irqsafe(hwsim_radios[i], nskb, &rx_status);
-	}
-
+	mac80211_hwsim_tx_frame(hw, skb);
 	dev_kfree_skb(skb);
 }
 

--

-- 
Jouni Malinen                                            PGP id EFC895FA

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

end of thread, other threads:[~2008-06-13 16:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-13 16:44 [PATCH 0/3] mac80211_hwsim: Clean up Jouni Malinen
2008-06-13 16:44 ` [PATCH 1/3] mac80211_hwsim: Clean up documentation Jouni Malinen
2008-06-13 16:44 ` [PATCH 2/3] mac80211_hwsim: Minor cleanup Jouni Malinen
2008-06-13 16:44 ` [PATCH 3/3] mac80211_hwsim: Shared TX code for received frames and Beacons Jouni Malinen

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