diff options
author | Jouni Malinen <j@w1.fi> | 2008-06-13 12:44:48 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-06-14 12:18:12 -0400 |
commit | e36cfdc9b17fa64245ee6206287e5120e59bbfca (patch) | |
tree | daef7afbb47f228a2c5db6c253e5b6db67de252b | |
parent | f248f10515dc7279120adf2d3eabcac9561fb1b4 (diff) |
mac80211_hwsim: Shared TX code for received frames and Beacons
Use a shared function for transmitting the frames instead of
duplicated code in two places.
Signed-off-by: Jouni Malinen <j@w1.fi>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | drivers/net/wireless/mac80211_hwsim.c | 83 |
1 files changed, 32 insertions, 51 deletions
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 7a8494e4ca51..8da352ae6825 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c | |||
@@ -144,31 +144,14 @@ static void mac80211_hwsim_monitor_rx(struct ieee80211_hw *hw, | |||
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
147 | static int mac80211_hwsim_tx(struct ieee80211_hw *hw, struct sk_buff *skb) | 147 | static int mac80211_hwsim_tx_frame(struct ieee80211_hw *hw, |
148 | struct sk_buff *skb) | ||
148 | { | 149 | { |
149 | struct mac80211_hwsim_data *data = hw->priv; | 150 | struct mac80211_hwsim_data *data = hw->priv; |
150 | struct ieee80211_rx_status rx_status; | ||
151 | int i, ack = 0; | 151 | int i, ack = 0; |
152 | struct ieee80211_hdr *hdr; | 152 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; |
153 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 153 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
154 | struct ieee80211_tx_info *txi; | 154 | struct ieee80211_rx_status rx_status; |
155 | |||
156 | mac80211_hwsim_monitor_rx(hw, skb); | ||
157 | |||
158 | if (skb->len < 10) { | ||
159 | /* Should not happen; just a sanity check for addr1 use */ | ||
160 | dev_kfree_skb(skb); | ||
161 | return NETDEV_TX_OK; | ||
162 | } | ||
163 | |||
164 | if (!data->radio_enabled) { | ||
165 | printk(KERN_DEBUG "%s: dropped TX frame since radio " | ||
166 | "disabled\n", wiphy_name(hw->wiphy)); | ||
167 | dev_kfree_skb(skb); | ||
168 | return NETDEV_TX_OK; | ||
169 | } | ||
170 | |||
171 | hdr = (struct ieee80211_hdr *) skb->data; | ||
172 | 155 | ||
173 | memset(&rx_status, 0, sizeof(rx_status)); | 156 | memset(&rx_status, 0, sizeof(rx_status)); |
174 | /* TODO: set mactime */ | 157 | /* TODO: set mactime */ |
@@ -199,6 +182,33 @@ static int mac80211_hwsim_tx(struct ieee80211_hw *hw, struct sk_buff *skb) | |||
199 | ieee80211_rx_irqsafe(hwsim_radios[i], nskb, &rx_status); | 182 | ieee80211_rx_irqsafe(hwsim_radios[i], nskb, &rx_status); |
200 | } | 183 | } |
201 | 184 | ||
185 | return ack; | ||
186 | } | ||
187 | |||
188 | |||
189 | static int mac80211_hwsim_tx(struct ieee80211_hw *hw, struct sk_buff *skb) | ||
190 | { | ||
191 | struct mac80211_hwsim_data *data = hw->priv; | ||
192 | int ack; | ||
193 | struct ieee80211_tx_info *txi; | ||
194 | |||
195 | mac80211_hwsim_monitor_rx(hw, skb); | ||
196 | |||
197 | if (skb->len < 10) { | ||
198 | /* Should not happen; just a sanity check for addr1 use */ | ||
199 | dev_kfree_skb(skb); | ||
200 | return NETDEV_TX_OK; | ||
201 | } | ||
202 | |||
203 | if (!data->radio_enabled) { | ||
204 | printk(KERN_DEBUG "%s: dropped TX frame since radio " | ||
205 | "disabled\n", wiphy_name(hw->wiphy)); | ||
206 | dev_kfree_skb(skb); | ||
207 | return NETDEV_TX_OK; | ||
208 | } | ||
209 | |||
210 | ack = mac80211_hwsim_tx_frame(hw, skb); | ||
211 | |||
202 | txi = IEEE80211_SKB_CB(skb); | 212 | txi = IEEE80211_SKB_CB(skb); |
203 | memset(&txi->status, 0, sizeof(txi->status)); | 213 | memset(&txi->status, 0, sizeof(txi->status)); |
204 | if (!(txi->flags & IEEE80211_TX_CTL_NO_ACK)) { | 214 | if (!(txi->flags & IEEE80211_TX_CTL_NO_ACK)) { |
@@ -254,10 +264,7 @@ static void mac80211_hwsim_beacon_tx(void *arg, u8 *mac, | |||
254 | struct ieee80211_vif *vif) | 264 | struct ieee80211_vif *vif) |
255 | { | 265 | { |
256 | struct ieee80211_hw *hw = arg; | 266 | struct ieee80211_hw *hw = arg; |
257 | struct mac80211_hwsim_data *data = hw->priv; | ||
258 | struct sk_buff *skb; | 267 | struct sk_buff *skb; |
259 | struct ieee80211_rx_status rx_status; | ||
260 | int i; | ||
261 | struct ieee80211_tx_info *info; | 268 | struct ieee80211_tx_info *info; |
262 | 269 | ||
263 | if (vif->type != IEEE80211_IF_TYPE_AP) | 270 | if (vif->type != IEEE80211_IF_TYPE_AP) |
@@ -269,33 +276,7 @@ static void mac80211_hwsim_beacon_tx(void *arg, u8 *mac, | |||
269 | info = IEEE80211_SKB_CB(skb); | 276 | info = IEEE80211_SKB_CB(skb); |
270 | 277 | ||
271 | mac80211_hwsim_monitor_rx(hw, skb); | 278 | mac80211_hwsim_monitor_rx(hw, skb); |
272 | 279 | mac80211_hwsim_tx_frame(hw, skb); | |
273 | memset(&rx_status, 0, sizeof(rx_status)); | ||
274 | /* TODO: set mactime */ | ||
275 | rx_status.freq = data->channel->center_freq; | ||
276 | rx_status.band = data->channel->band; | ||
277 | rx_status.rate_idx = info->tx_rate_idx; | ||
278 | /* TODO: simulate signal strength (and optional packet drop) */ | ||
279 | |||
280 | /* Copy skb to all enabled radios that are on the current frequency */ | ||
281 | for (i = 0; i < hwsim_radio_count; i++) { | ||
282 | struct mac80211_hwsim_data *data2; | ||
283 | struct sk_buff *nskb; | ||
284 | |||
285 | if (hwsim_radios[i] == NULL || hwsim_radios[i] == hw) | ||
286 | continue; | ||
287 | data2 = hwsim_radios[i]->priv; | ||
288 | if (!data2->started || !data2->radio_enabled || | ||
289 | data->channel->center_freq != data2->channel->center_freq) | ||
290 | continue; | ||
291 | |||
292 | nskb = skb_copy(skb, GFP_ATOMIC); | ||
293 | if (nskb == NULL) | ||
294 | continue; | ||
295 | |||
296 | ieee80211_rx_irqsafe(hwsim_radios[i], nskb, &rx_status); | ||
297 | } | ||
298 | |||
299 | dev_kfree_skb(skb); | 280 | dev_kfree_skb(skb); |
300 | } | 281 | } |
301 | 282 | ||