diff options
Diffstat (limited to 'net/mac80211/util.c')
-rw-r--r-- | net/mac80211/util.c | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/net/mac80211/util.c b/net/mac80211/util.c index c45658309472..091ac0d634a5 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c | |||
@@ -314,31 +314,46 @@ int ieee80211_frame_duration(struct ieee80211_local *local, size_t len, | |||
314 | } | 314 | } |
315 | 315 | ||
316 | /* Exported duration function for driver use */ | 316 | /* Exported duration function for driver use */ |
317 | __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, | 317 | __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, int if_id, |
318 | size_t frame_len, int rate) | 318 | size_t frame_len, int rate) |
319 | { | 319 | { |
320 | struct ieee80211_local *local = hw_to_local(hw); | 320 | struct ieee80211_local *local = hw_to_local(hw); |
321 | struct net_device *bdev = dev_get_by_index(if_id); | ||
322 | struct ieee80211_sub_if_data *sdata; | ||
321 | u16 dur; | 323 | u16 dur; |
322 | int erp; | 324 | int erp; |
323 | 325 | ||
326 | if (unlikely(!bdev)) | ||
327 | return 0; | ||
328 | |||
329 | sdata = IEEE80211_DEV_TO_SUB_IF(bdev); | ||
324 | erp = ieee80211_is_erp_rate(hw->conf.phymode, rate); | 330 | erp = ieee80211_is_erp_rate(hw->conf.phymode, rate); |
325 | dur = ieee80211_frame_duration(local, frame_len, rate, | 331 | dur = ieee80211_frame_duration(local, frame_len, rate, |
326 | erp, local->short_preamble); | 332 | erp, sdata->short_preamble); |
327 | 333 | ||
334 | dev_put(bdev); | ||
328 | return cpu_to_le16(dur); | 335 | return cpu_to_le16(dur); |
329 | } | 336 | } |
330 | EXPORT_SYMBOL(ieee80211_generic_frame_duration); | 337 | EXPORT_SYMBOL(ieee80211_generic_frame_duration); |
331 | 338 | ||
332 | __le16 ieee80211_rts_duration(struct ieee80211_hw *hw, | 339 | __le16 ieee80211_rts_duration(struct ieee80211_hw *hw, int if_id, |
333 | size_t frame_len, | 340 | size_t frame_len, |
334 | const struct ieee80211_tx_control *frame_txctl) | 341 | const struct ieee80211_tx_control *frame_txctl) |
335 | { | 342 | { |
336 | struct ieee80211_local *local = hw_to_local(hw); | 343 | struct ieee80211_local *local = hw_to_local(hw); |
337 | struct ieee80211_rate *rate; | 344 | struct ieee80211_rate *rate; |
338 | int short_preamble = local->short_preamble; | 345 | struct net_device *bdev = dev_get_by_index(if_id); |
346 | struct ieee80211_sub_if_data *sdata; | ||
347 | int short_preamble; | ||
339 | int erp; | 348 | int erp; |
340 | u16 dur; | 349 | u16 dur; |
341 | 350 | ||
351 | if (unlikely(!bdev)) | ||
352 | return 0; | ||
353 | |||
354 | sdata = IEEE80211_DEV_TO_SUB_IF(bdev); | ||
355 | short_preamble = sdata->short_preamble; | ||
356 | |||
342 | rate = frame_txctl->rts_rate; | 357 | rate = frame_txctl->rts_rate; |
343 | erp = !!(rate->flags & IEEE80211_RATE_ERP); | 358 | erp = !!(rate->flags & IEEE80211_RATE_ERP); |
344 | 359 | ||
@@ -352,20 +367,29 @@ __le16 ieee80211_rts_duration(struct ieee80211_hw *hw, | |||
352 | dur += ieee80211_frame_duration(local, 10, rate->rate, | 367 | dur += ieee80211_frame_duration(local, 10, rate->rate, |
353 | erp, short_preamble); | 368 | erp, short_preamble); |
354 | 369 | ||
370 | dev_put(bdev); | ||
355 | return cpu_to_le16(dur); | 371 | return cpu_to_le16(dur); |
356 | } | 372 | } |
357 | EXPORT_SYMBOL(ieee80211_rts_duration); | 373 | EXPORT_SYMBOL(ieee80211_rts_duration); |
358 | 374 | ||
359 | __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, | 375 | __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, int if_id, |
360 | size_t frame_len, | 376 | size_t frame_len, |
361 | const struct ieee80211_tx_control *frame_txctl) | 377 | const struct ieee80211_tx_control *frame_txctl) |
362 | { | 378 | { |
363 | struct ieee80211_local *local = hw_to_local(hw); | 379 | struct ieee80211_local *local = hw_to_local(hw); |
364 | struct ieee80211_rate *rate; | 380 | struct ieee80211_rate *rate; |
365 | int short_preamble = local->short_preamble; | 381 | struct net_device *bdev = dev_get_by_index(if_id); |
382 | struct ieee80211_sub_if_data *sdata; | ||
383 | int short_preamble; | ||
366 | int erp; | 384 | int erp; |
367 | u16 dur; | 385 | u16 dur; |
368 | 386 | ||
387 | if (unlikely(!bdev)) | ||
388 | return 0; | ||
389 | |||
390 | sdata = IEEE80211_DEV_TO_SUB_IF(bdev); | ||
391 | short_preamble = sdata->short_preamble; | ||
392 | |||
369 | rate = frame_txctl->rts_rate; | 393 | rate = frame_txctl->rts_rate; |
370 | erp = !!(rate->flags & IEEE80211_RATE_ERP); | 394 | erp = !!(rate->flags & IEEE80211_RATE_ERP); |
371 | 395 | ||
@@ -378,6 +402,7 @@ __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, | |||
378 | erp, short_preamble); | 402 | erp, short_preamble); |
379 | } | 403 | } |
380 | 404 | ||
405 | dev_put(bdev); | ||
381 | return cpu_to_le16(dur); | 406 | return cpu_to_le16(dur); |
382 | } | 407 | } |
383 | EXPORT_SYMBOL(ieee80211_ctstoself_duration); | 408 | EXPORT_SYMBOL(ieee80211_ctstoself_duration); |