aboutsummaryrefslogtreecommitdiffstats
path: root/include
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 /include
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 'include')
-rw-r--r--include/net/mac80211.h70
1 files changed, 45 insertions, 25 deletions
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index be2a383b4776..24a8ad3f5073 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -280,6 +280,7 @@ struct ieee80211_low_level_stats {
280 * the hardware to use given values (depending on what is supported). */ 280 * the hardware to use given values (depending on what is supported). */
281 281
282struct ieee80211_tx_control { 282struct ieee80211_tx_control {
283 struct ieee80211_vif *vif;
283 int tx_rate; /* Transmit rate, given as the hw specific value for the 284 int tx_rate; /* Transmit rate, given as the hw specific value for the
284 * rate (from struct ieee80211_rate) */ 285 * rate (from struct ieee80211_rate) */
285 int rts_cts_rate; /* Transmit rate for RTS/CTS frame, given as the hw 286 int rts_cts_rate; /* Transmit rate for RTS/CTS frame, given as the hw
@@ -332,7 +333,6 @@ struct ieee80211_tx_control {
332 * packet dropping when probing higher rates, if hw 333 * packet dropping when probing higher rates, if hw
333 * supports multiple retry rates. -1 = not used */ 334 * supports multiple retry rates. -1 = not used */
334 int type; /* internal */ 335 int type; /* internal */
335 int ifindex; /* internal */
336}; 336};
337 337
338 338
@@ -530,13 +530,25 @@ enum ieee80211_if_types {
530}; 530};
531 531
532/** 532/**
533 * struct ieee80211_vif - per-interface data
534 *
535 * Data in this structure is continually present for driver
536 * use during the life of a virtual interface.
537 *
538 * @drv_priv: data area for driver use, will always be aligned to
539 * sizeof(void *).
540 */
541struct ieee80211_vif {
542 /* must be last */
543 u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *))));
544};
545
546/**
533 * struct ieee80211_if_init_conf - initial configuration of an interface 547 * struct ieee80211_if_init_conf - initial configuration of an interface
534 * 548 *
535 * @if_id: internal interface ID. This number has no particular meaning to 549 * @vif: pointer to a driver-use per-interface structure. The pointer
536 * drivers and the only allowed usage is to pass it to 550 * itself is also used for various functions including
537 * ieee80211_beacon_get() and ieee80211_get_buffered_bc() functions. 551 * ieee80211_beacon_get() and ieee80211_get_buffered_bc().
538 * This field is not valid for monitor interfaces
539 * (interfaces of %IEEE80211_IF_TYPE_MNTR type).
540 * @type: one of &enum ieee80211_if_types constants. Determines the type of 552 * @type: one of &enum ieee80211_if_types constants. Determines the type of
541 * added/removed interface. 553 * added/removed interface.
542 * @mac_addr: pointer to MAC address of the interface. This pointer is valid 554 * @mac_addr: pointer to MAC address of the interface. This pointer is valid
@@ -553,8 +565,8 @@ enum ieee80211_if_types {
553 * in pure monitor mode. 565 * in pure monitor mode.
554 */ 566 */
555struct ieee80211_if_init_conf { 567struct ieee80211_if_init_conf {
556 int if_id;
557 enum ieee80211_if_types type; 568 enum ieee80211_if_types type;
569 struct ieee80211_vif *vif;
558 void *mac_addr; 570 void *mac_addr;
559}; 571};
560 572
@@ -757,6 +769,9 @@ enum ieee80211_hw_flags {
757 * @rate_control_algorithm: rate control algorithm for this hardware. 769 * @rate_control_algorithm: rate control algorithm for this hardware.
758 * If unset (NULL), the default algorithm will be used. Must be 770 * If unset (NULL), the default algorithm will be used. Must be
759 * set before calling ieee80211_register_hw(). 771 * set before calling ieee80211_register_hw().
772 *
773 * @vif_data_size: size (in bytes) of the drv_priv data area
774 * within &struct ieee80211_vif.
760 */ 775 */
761struct ieee80211_hw { 776struct ieee80211_hw {
762 struct ieee80211_conf conf; 777 struct ieee80211_conf conf;
@@ -767,6 +782,7 @@ struct ieee80211_hw {
767 u32 flags; 782 u32 flags;
768 unsigned int extra_tx_headroom; 783 unsigned int extra_tx_headroom;
769 int channel_change_time; 784 int channel_change_time;
785 int vif_data_size;
770 u8 queues; 786 u8 queues;
771 s8 max_rssi; 787 s8 max_rssi;
772 s8 max_signal; 788 s8 max_signal;
@@ -1076,7 +1092,8 @@ struct ieee80211_ops {
1076 struct ieee80211_if_init_conf *conf); 1092 struct ieee80211_if_init_conf *conf);
1077 int (*config)(struct ieee80211_hw *hw, struct ieee80211_conf *conf); 1093 int (*config)(struct ieee80211_hw *hw, struct ieee80211_conf *conf);
1078 int (*config_interface)(struct ieee80211_hw *hw, 1094 int (*config_interface)(struct ieee80211_hw *hw,
1079 int if_id, struct ieee80211_if_conf *conf); 1095 struct ieee80211_vif *vif,
1096 struct ieee80211_if_conf *conf);
1080 void (*configure_filter)(struct ieee80211_hw *hw, 1097 void (*configure_filter)(struct ieee80211_hw *hw,
1081 unsigned int changed_flags, 1098 unsigned int changed_flags,
1082 unsigned int *total_flags, 1099 unsigned int *total_flags,
@@ -1094,7 +1111,7 @@ struct ieee80211_ops {
1094 int (*set_frag_threshold)(struct ieee80211_hw *hw, u32 value); 1111 int (*set_frag_threshold)(struct ieee80211_hw *hw, u32 value);
1095 int (*set_retry_limit)(struct ieee80211_hw *hw, 1112 int (*set_retry_limit)(struct ieee80211_hw *hw,
1096 u32 short_retry, u32 long_retr); 1113 u32 short_retry, u32 long_retr);
1097 void (*sta_notify)(struct ieee80211_hw *hw, int if_id, 1114 void (*sta_notify)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1098 enum sta_notify_cmd, const u8 *addr); 1115 enum sta_notify_cmd, const u8 *addr);
1099 void (*erp_ie_changed)(struct ieee80211_hw *hw, u8 changes, 1116 void (*erp_ie_changed)(struct ieee80211_hw *hw, u8 changes,
1100 int cts_protection, int preamble); 1117 int cts_protection, int preamble);
@@ -1309,7 +1326,7 @@ void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
1309/** 1326/**
1310 * ieee80211_beacon_get - beacon generation function 1327 * ieee80211_beacon_get - beacon generation function
1311 * @hw: pointer obtained from ieee80211_alloc_hw(). 1328 * @hw: pointer obtained from ieee80211_alloc_hw().
1312 * @if_id: interface ID from &struct ieee80211_if_init_conf. 1329 * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
1313 * @control: will be filled with information needed to send this beacon. 1330 * @control: will be filled with information needed to send this beacon.
1314 * 1331 *
1315 * If the beacon frames are generated by the host system (i.e., not in 1332 * If the beacon frames are generated by the host system (i.e., not in
@@ -1320,13 +1337,13 @@ void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
1320 * is responsible of freeing it. 1337 * is responsible of freeing it.
1321 */ 1338 */
1322struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, 1339struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
1323 int if_id, 1340 struct ieee80211_vif *vif,
1324 struct ieee80211_tx_control *control); 1341 struct ieee80211_tx_control *control);
1325 1342
1326/** 1343/**
1327 * ieee80211_rts_get - RTS frame generation function 1344 * ieee80211_rts_get - RTS frame generation function
1328 * @hw: pointer obtained from ieee80211_alloc_hw(). 1345 * @hw: pointer obtained from ieee80211_alloc_hw().
1329 * @if_id: interface ID from &struct ieee80211_if_init_conf. 1346 * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
1330 * @frame: pointer to the frame that is going to be protected by the RTS. 1347 * @frame: pointer to the frame that is going to be protected by the RTS.
1331 * @frame_len: the frame length (in octets). 1348 * @frame_len: the frame length (in octets).
1332 * @frame_txctl: &struct ieee80211_tx_control of the frame. 1349 * @frame_txctl: &struct ieee80211_tx_control of the frame.
@@ -1337,7 +1354,7 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
1337 * the next RTS frame from the 802.11 code. The low-level is responsible 1354 * the next RTS frame from the 802.11 code. The low-level is responsible
1338 * for calling this function before and RTS frame is needed. 1355 * for calling this function before and RTS frame is needed.
1339 */ 1356 */
1340void ieee80211_rts_get(struct ieee80211_hw *hw, int if_id, 1357void ieee80211_rts_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1341 const void *frame, size_t frame_len, 1358 const void *frame, size_t frame_len,
1342 const struct ieee80211_tx_control *frame_txctl, 1359 const struct ieee80211_tx_control *frame_txctl,
1343 struct ieee80211_rts *rts); 1360 struct ieee80211_rts *rts);
@@ -1345,7 +1362,7 @@ void ieee80211_rts_get(struct ieee80211_hw *hw, int if_id,
1345/** 1362/**
1346 * ieee80211_rts_duration - Get the duration field for an RTS frame 1363 * ieee80211_rts_duration - Get the duration field for an RTS frame
1347 * @hw: pointer obtained from ieee80211_alloc_hw(). 1364 * @hw: pointer obtained from ieee80211_alloc_hw().
1348 * @if_id: interface ID from &struct ieee80211_if_init_conf. 1365 * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
1349 * @frame_len: the length of the frame that is going to be protected by the RTS. 1366 * @frame_len: the length of the frame that is going to be protected by the RTS.
1350 * @frame_txctl: &struct ieee80211_tx_control of the frame. 1367 * @frame_txctl: &struct ieee80211_tx_control of the frame.
1351 * 1368 *
@@ -1353,14 +1370,14 @@ void ieee80211_rts_get(struct ieee80211_hw *hw, int if_id,
1353 * the duration field, the low-level driver uses this function to receive 1370 * the duration field, the low-level driver uses this function to receive
1354 * the duration field value in little-endian byteorder. 1371 * the duration field value in little-endian byteorder.
1355 */ 1372 */
1356__le16 ieee80211_rts_duration(struct ieee80211_hw *hw, int if_id, 1373__le16 ieee80211_rts_duration(struct ieee80211_hw *hw,
1357 size_t frame_len, 1374 struct ieee80211_vif *vif, size_t frame_len,
1358 const struct ieee80211_tx_control *frame_txctl); 1375 const struct ieee80211_tx_control *frame_txctl);
1359 1376
1360/** 1377/**
1361 * ieee80211_ctstoself_get - CTS-to-self frame generation function 1378 * ieee80211_ctstoself_get - CTS-to-self frame generation function
1362 * @hw: pointer obtained from ieee80211_alloc_hw(). 1379 * @hw: pointer obtained from ieee80211_alloc_hw().
1363 * @if_id: interface ID from &struct ieee80211_if_init_conf. 1380 * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
1364 * @frame: pointer to the frame that is going to be protected by the CTS-to-self. 1381 * @frame: pointer to the frame that is going to be protected by the CTS-to-self.
1365 * @frame_len: the frame length (in octets). 1382 * @frame_len: the frame length (in octets).
1366 * @frame_txctl: &struct ieee80211_tx_control of the frame. 1383 * @frame_txctl: &struct ieee80211_tx_control of the frame.
@@ -1371,7 +1388,8 @@ __le16 ieee80211_rts_duration(struct ieee80211_hw *hw, int if_id,
1371 * the next CTS-to-self frame from the 802.11 code. The low-level is responsible 1388 * the next CTS-to-self frame from the 802.11 code. The low-level is responsible
1372 * for calling this function before and CTS-to-self frame is needed. 1389 * for calling this function before and CTS-to-self frame is needed.
1373 */ 1390 */
1374void ieee80211_ctstoself_get(struct ieee80211_hw *hw, int if_id, 1391void ieee80211_ctstoself_get(struct ieee80211_hw *hw,
1392 struct ieee80211_vif *vif,
1375 const void *frame, size_t frame_len, 1393 const void *frame, size_t frame_len,
1376 const struct ieee80211_tx_control *frame_txctl, 1394 const struct ieee80211_tx_control *frame_txctl,
1377 struct ieee80211_cts *cts); 1395 struct ieee80211_cts *cts);
@@ -1379,7 +1397,7 @@ void ieee80211_ctstoself_get(struct ieee80211_hw *hw, int if_id,
1379/** 1397/**
1380 * ieee80211_ctstoself_duration - Get the duration field for a CTS-to-self frame 1398 * ieee80211_ctstoself_duration - Get the duration field for a CTS-to-self frame
1381 * @hw: pointer obtained from ieee80211_alloc_hw(). 1399 * @hw: pointer obtained from ieee80211_alloc_hw().
1382 * @if_id: interface ID from &struct ieee80211_if_init_conf. 1400 * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
1383 * @frame_len: the length of the frame that is going to be protected by the CTS-to-self. 1401 * @frame_len: the length of the frame that is going to be protected by the CTS-to-self.
1384 * @frame_txctl: &struct ieee80211_tx_control of the frame. 1402 * @frame_txctl: &struct ieee80211_tx_control of the frame.
1385 * 1403 *
@@ -1387,28 +1405,30 @@ void ieee80211_ctstoself_get(struct ieee80211_hw *hw, int if_id,
1387 * the duration field, the low-level driver uses this function to receive 1405 * the duration field, the low-level driver uses this function to receive
1388 * the duration field value in little-endian byteorder. 1406 * the duration field value in little-endian byteorder.
1389 */ 1407 */
1390__le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, int if_id, 1408__le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw,
1409 struct ieee80211_vif *vif,
1391 size_t frame_len, 1410 size_t frame_len,
1392 const struct ieee80211_tx_control *frame_txctl); 1411 const struct ieee80211_tx_control *frame_txctl);
1393 1412
1394/** 1413/**
1395 * ieee80211_generic_frame_duration - Calculate the duration field for a frame 1414 * ieee80211_generic_frame_duration - Calculate the duration field for a frame
1396 * @hw: pointer obtained from ieee80211_alloc_hw(). 1415 * @hw: pointer obtained from ieee80211_alloc_hw().
1397 * @if_id: interface ID from &struct ieee80211_if_init_conf. 1416 * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
1398 * @frame_len: the length of the frame. 1417 * @frame_len: the length of the frame.
1399 * @rate: the rate (in 100kbps) at which the frame is going to be transmitted. 1418 * @rate: the rate (in 100kbps) at which the frame is going to be transmitted.
1400 * 1419 *
1401 * Calculate the duration field of some generic frame, given its 1420 * Calculate the duration field of some generic frame, given its
1402 * length and transmission rate (in 100kbps). 1421 * length and transmission rate (in 100kbps).
1403 */ 1422 */
1404__le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, int if_id, 1423__le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw,
1424 struct ieee80211_vif *vif,
1405 size_t frame_len, 1425 size_t frame_len,
1406 int rate); 1426 int rate);
1407 1427
1408/** 1428/**
1409 * ieee80211_get_buffered_bc - accessing buffered broadcast and multicast frames 1429 * ieee80211_get_buffered_bc - accessing buffered broadcast and multicast frames
1410 * @hw: pointer as obtained from ieee80211_alloc_hw(). 1430 * @hw: pointer as obtained from ieee80211_alloc_hw().
1411 * @if_id: interface ID from &struct ieee80211_if_init_conf. 1431 * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
1412 * @control: will be filled with information needed to send returned frame. 1432 * @control: will be filled with information needed to send returned frame.
1413 * 1433 *
1414 * Function for accessing buffered broadcast and multicast frames. If 1434 * Function for accessing buffered broadcast and multicast frames. If
@@ -1427,7 +1447,7 @@ __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, int if_id,
1427 * use common code for all beacons. 1447 * use common code for all beacons.
1428 */ 1448 */
1429struct sk_buff * 1449struct sk_buff *
1430ieee80211_get_buffered_bc(struct ieee80211_hw *hw, int if_id, 1450ieee80211_get_buffered_bc(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1431 struct ieee80211_tx_control *control); 1451 struct ieee80211_tx_control *control);
1432 1452
1433/** 1453/**
@@ -1517,7 +1537,7 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw);
1517 */ 1537 */
1518void ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw, 1538void ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw,
1519 void (*iterator)(void *data, u8 *mac, 1539 void (*iterator)(void *data, u8 *mac,
1520 int if_id), 1540 struct ieee80211_vif *vif),
1521 void *data); 1541 void *data);
1522 1542
1523#endif /* MAC80211_H */ 1543#endif /* MAC80211_H */