aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/util.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2007-12-18 19:31:26 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:09:36 -0500
commit32bfd35d4b63bd63de4bb0d791ef049c3c868726 (patch)
treec1c213a35a00bcbe71a2ecc6521e19dec66cf6eb /net/mac80211/util.c
parentf653211197f3841f383fa9757ef8ce182c6cf627 (diff)
mac80211: dont use interface indices in drivers
This patch gets rid of the if_id stuff where possible in favour of a new per-virtual-interface structure "struct ieee80211_vif". This structure is located at the end of the per-interface structure and contains a variable length driver-use data area. This has two advantages: * removes the need to look up interfaces by if_id, this is better for working with network namespaces and performance * allows drivers to store and retrieve per-interface data without having to allocate own lists/hash tables Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/util.c')
-rw-r--r--net/mac80211/util.c45
1 files changed, 15 insertions, 30 deletions
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index adb85dd5098d..15503ca3e945 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -302,44 +302,34 @@ int ieee80211_frame_duration(struct ieee80211_local *local, size_t len,
302} 302}
303 303
304/* Exported duration function for driver use */ 304/* Exported duration function for driver use */
305__le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, int if_id, 305__le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw,
306 struct ieee80211_vif *vif,
306 size_t frame_len, int rate) 307 size_t frame_len, int rate)
307{ 308{
308 struct ieee80211_local *local = hw_to_local(hw); 309 struct ieee80211_local *local = hw_to_local(hw);
309 struct net_device *bdev = dev_get_by_index(&init_net, if_id); 310 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
310 struct ieee80211_sub_if_data *sdata;
311 u16 dur; 311 u16 dur;
312 int erp; 312 int erp;
313 313
314 if (unlikely(!bdev))
315 return 0;
316
317 sdata = IEEE80211_DEV_TO_SUB_IF(bdev);
318 erp = ieee80211_is_erp_rate(hw->conf.phymode, rate); 314 erp = ieee80211_is_erp_rate(hw->conf.phymode, rate);
319 dur = ieee80211_frame_duration(local, frame_len, rate, 315 dur = ieee80211_frame_duration(local, frame_len, rate,
320 erp, sdata->flags & IEEE80211_SDATA_SHORT_PREAMBLE); 316 erp, sdata->flags & IEEE80211_SDATA_SHORT_PREAMBLE);
321 317
322 dev_put(bdev);
323 return cpu_to_le16(dur); 318 return cpu_to_le16(dur);
324} 319}
325EXPORT_SYMBOL(ieee80211_generic_frame_duration); 320EXPORT_SYMBOL(ieee80211_generic_frame_duration);
326 321
327__le16 ieee80211_rts_duration(struct ieee80211_hw *hw, int if_id, 322__le16 ieee80211_rts_duration(struct ieee80211_hw *hw,
328 size_t frame_len, 323 struct ieee80211_vif *vif, size_t frame_len,
329 const struct ieee80211_tx_control *frame_txctl) 324 const struct ieee80211_tx_control *frame_txctl)
330{ 325{
331 struct ieee80211_local *local = hw_to_local(hw); 326 struct ieee80211_local *local = hw_to_local(hw);
332 struct ieee80211_rate *rate; 327 struct ieee80211_rate *rate;
333 struct net_device *bdev = dev_get_by_index(&init_net, if_id); 328 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
334 struct ieee80211_sub_if_data *sdata;
335 int short_preamble; 329 int short_preamble;
336 int erp; 330 int erp;
337 u16 dur; 331 u16 dur;
338 332
339 if (unlikely(!bdev))
340 return 0;
341
342 sdata = IEEE80211_DEV_TO_SUB_IF(bdev);
343 short_preamble = sdata->flags & IEEE80211_SDATA_SHORT_PREAMBLE; 333 short_preamble = sdata->flags & IEEE80211_SDATA_SHORT_PREAMBLE;
344 334
345 rate = frame_txctl->rts_rate; 335 rate = frame_txctl->rts_rate;
@@ -355,27 +345,22 @@ __le16 ieee80211_rts_duration(struct ieee80211_hw *hw, int if_id,
355 dur += ieee80211_frame_duration(local, 10, rate->rate, 345 dur += ieee80211_frame_duration(local, 10, rate->rate,
356 erp, short_preamble); 346 erp, short_preamble);
357 347
358 dev_put(bdev);
359 return cpu_to_le16(dur); 348 return cpu_to_le16(dur);
360} 349}
361EXPORT_SYMBOL(ieee80211_rts_duration); 350EXPORT_SYMBOL(ieee80211_rts_duration);
362 351
363__le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, int if_id, 352__le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw,
353 struct ieee80211_vif *vif,
364 size_t frame_len, 354 size_t frame_len,
365 const struct ieee80211_tx_control *frame_txctl) 355 const struct ieee80211_tx_control *frame_txctl)
366{ 356{
367 struct ieee80211_local *local = hw_to_local(hw); 357 struct ieee80211_local *local = hw_to_local(hw);
368 struct ieee80211_rate *rate; 358 struct ieee80211_rate *rate;
369 struct net_device *bdev = dev_get_by_index(&init_net, if_id); 359 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
370 struct ieee80211_sub_if_data *sdata;
371 int short_preamble; 360 int short_preamble;
372 int erp; 361 int erp;
373 u16 dur; 362 u16 dur;
374 363
375 if (unlikely(!bdev))
376 return 0;
377
378 sdata = IEEE80211_DEV_TO_SUB_IF(bdev);
379 short_preamble = sdata->flags & IEEE80211_SDATA_SHORT_PREAMBLE; 364 short_preamble = sdata->flags & IEEE80211_SDATA_SHORT_PREAMBLE;
380 365
381 rate = frame_txctl->rts_rate; 366 rate = frame_txctl->rts_rate;
@@ -390,7 +375,6 @@ __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, int if_id,
390 erp, short_preamble); 375 erp, short_preamble);
391 } 376 }
392 377
393 dev_put(bdev);
394 return cpu_to_le16(dur); 378 return cpu_to_le16(dur);
395} 379}
396EXPORT_SYMBOL(ieee80211_ctstoself_duration); 380EXPORT_SYMBOL(ieee80211_ctstoself_duration);
@@ -475,10 +459,11 @@ void ieee80211_wake_queues(struct ieee80211_hw *hw)
475} 459}
476EXPORT_SYMBOL(ieee80211_wake_queues); 460EXPORT_SYMBOL(ieee80211_wake_queues);
477 461
478void ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw, 462void ieee80211_iterate_active_interfaces(
479 void (*iterator)(void *data, u8 *mac, 463 struct ieee80211_hw *hw,
480 int if_id), 464 void (*iterator)(void *data, u8 *mac,
481 void *data) 465 struct ieee80211_vif *vif),
466 void *data)
482{ 467{
483 struct ieee80211_local *local = hw_to_local(hw); 468 struct ieee80211_local *local = hw_to_local(hw);
484 struct ieee80211_sub_if_data *sdata; 469 struct ieee80211_sub_if_data *sdata;
@@ -501,7 +486,7 @@ void ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw,
501 continue; 486 continue;
502 if (netif_running(sdata->dev)) 487 if (netif_running(sdata->dev))
503 iterator(data, sdata->dev->dev_addr, 488 iterator(data, sdata->dev->dev_addr,
504 sdata->dev->ifindex); 489 &sdata->vif);
505 } 490 }
506 491
507 rcu_read_unlock(); 492 rcu_read_unlock();