mac80211_hwsim: Clean up
Subsystems (2)
cover mac80211_hwsim: Clean up
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.
Signature · 1 line
Jouni Malinen PGP id EFC895FA
PATCH 1/3 mac80211_hwsim: Clean up documentation
Clean up the introduction and fix a typo.
Signed-off-by Jouni Malinen <[email protected]>
Documentation/networking/mac80211_hwsim/README +7 -8
@@ -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).
--
Signature · 1 line
Jouni Malinen PGP id EFC895FA
PATCH 2/3 mac80211_hwsim: Minor cleanup
In reply to Jouni MalinenRemove unnecessary '__constant_' prefix and use the atomic version of ieee80211_iterate_active_interfaces().
Signed-off-by Jouni Malinen <[email protected]>
drivers/net/wireless/mac80211_hwsim.c +6 -6
@@ -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(stskb_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(unsignif (!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);
--
Signature · 1 line
Jouni Malinen PGP id EFC895FA
PATCH 3/3 mac80211_hwsim: Shared TX code for received frames and Beacons
In reply to Jouni MalinenUse a shared function for transmitting the frames instead of duplicated code in two places.
Signed-off-by Jouni Malinen <[email protected]>
drivers/net/wireless/mac80211_hwsim.c +32 -51
@@ -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 ieeeieee80211_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); }
--
Signature · 1 line
Jouni Malinen PGP id EFC895FA