rt2x00: Replace DRV_NAME with KBUILD_MODNAME
[linux-2.6/verdex.git] / drivers / net / wireless / rt2x00 / rt2x00.h
blobb2283cebfab9258ede7388709e6f4d6eda22f0a0
1 /*
2 Copyright (C) 2004 - 2007 rt2x00 SourceForge Project
3 <http://rt2x00.serialmonkey.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the
17 Free Software Foundation, Inc.,
18 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 Module: rt2x00
23 Abstract: rt2x00 global information.
26 #ifndef RT2X00_H
27 #define RT2X00_H
29 #include <linux/bitops.h>
30 #include <linux/prefetch.h>
31 #include <linux/skbuff.h>
32 #include <linux/workqueue.h>
33 #include <linux/firmware.h>
34 #include <linux/mutex.h>
36 #include <net/mac80211.h>
38 #include "rt2x00debug.h"
39 #include "rt2x00reg.h"
40 #include "rt2x00ring.h"
43 * Module information.
45 #define DRV_VERSION "2.0.12"
46 #define DRV_PROJECT "http://rt2x00.serialmonkey.com"
49 * Debug definitions.
50 * Debug output has to be enabled during compile time.
52 #define DEBUG_PRINTK_MSG(__dev, __kernlvl, __lvl, __msg, __args...) \
53 printk(__kernlvl "%s -> %s: %s - " __msg, \
54 wiphy_name((__dev)->hw->wiphy), __FUNCTION__, __lvl, ##__args)
56 #define DEBUG_PRINTK_PROBE(__kernlvl, __lvl, __msg, __args...) \
57 printk(__kernlvl "%s -> %s: %s - " __msg, \
58 KBUILD_MODNAME, __FUNCTION__, __lvl, ##__args)
60 #ifdef CONFIG_RT2X00_DEBUG
61 #define DEBUG_PRINTK(__dev, __kernlvl, __lvl, __msg, __args...) \
62 DEBUG_PRINTK_MSG(__dev, __kernlvl, __lvl, __msg, ##__args);
63 #else
64 #define DEBUG_PRINTK(__dev, __kernlvl, __lvl, __msg, __args...) \
65 do { } while (0)
66 #endif /* CONFIG_RT2X00_DEBUG */
69 * Various debug levels.
70 * The debug levels PANIC and ERROR both indicate serious problems,
71 * for this reason they should never be ignored.
72 * The special ERROR_PROBE message is for messages that are generated
73 * when the rt2x00_dev is not yet initialized.
75 #define PANIC(__dev, __msg, __args...) \
76 DEBUG_PRINTK_MSG(__dev, KERN_CRIT, "Panic", __msg, ##__args)
77 #define ERROR(__dev, __msg, __args...) \
78 DEBUG_PRINTK_MSG(__dev, KERN_ERR, "Error", __msg, ##__args)
79 #define ERROR_PROBE(__msg, __args...) \
80 DEBUG_PRINTK_PROBE(KERN_ERR, "Error", __msg, ##__args)
81 #define WARNING(__dev, __msg, __args...) \
82 DEBUG_PRINTK(__dev, KERN_WARNING, "Warning", __msg, ##__args)
83 #define NOTICE(__dev, __msg, __args...) \
84 DEBUG_PRINTK(__dev, KERN_NOTICE, "Notice", __msg, ##__args)
85 #define INFO(__dev, __msg, __args...) \
86 DEBUG_PRINTK(__dev, KERN_INFO, "Info", __msg, ##__args)
87 #define DEBUG(__dev, __msg, __args...) \
88 DEBUG_PRINTK(__dev, KERN_DEBUG, "Debug", __msg, ##__args)
89 #define EEPROM(__dev, __msg, __args...) \
90 DEBUG_PRINTK(__dev, KERN_DEBUG, "EEPROM recovery", __msg, ##__args)
93 * Ring sizes.
94 * Ralink PCI devices demand the Frame size to be a multiple of 128 bytes.
95 * DATA_FRAME_SIZE is used for TX, RX, ATIM and PRIO rings.
96 * MGMT_FRAME_SIZE is used for the BEACON ring.
98 #define DATA_FRAME_SIZE 2432
99 #define MGMT_FRAME_SIZE 256
102 * Number of entries in a packet ring.
103 * PCI devices only need 1 Beacon entry,
104 * but USB devices require a second because they
105 * have to send a Guardian byte first.
107 #define RX_ENTRIES 12
108 #define TX_ENTRIES 12
109 #define ATIM_ENTRIES 1
110 #define BEACON_ENTRIES 2
113 * Standard timing and size defines.
114 * These values should follow the ieee80211 specifications.
116 #define ACK_SIZE 14
117 #define IEEE80211_HEADER 24
118 #define PLCP 48
119 #define BEACON 100
120 #define PREAMBLE 144
121 #define SHORT_PREAMBLE 72
122 #define SLOT_TIME 20
123 #define SHORT_SLOT_TIME 9
124 #define SIFS 10
125 #define PIFS ( SIFS + SLOT_TIME )
126 #define SHORT_PIFS ( SIFS + SHORT_SLOT_TIME )
127 #define DIFS ( PIFS + SLOT_TIME )
128 #define SHORT_DIFS ( SHORT_PIFS + SHORT_SLOT_TIME )
129 #define EIFS ( SIFS + (8 * (IEEE80211_HEADER + ACK_SIZE)) )
132 * IEEE802.11 header defines
134 static inline int is_rts_frame(u16 fc)
136 return (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) &&
137 ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_RTS));
140 static inline int is_cts_frame(u16 fc)
142 return (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) &&
143 ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_CTS));
146 static inline int is_probe_resp(u16 fc)
148 return (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) &&
149 ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PROBE_RESP));
153 * Chipset identification
154 * The chipset on the device is composed of a RT and RF chip.
155 * The chipset combination is important for determining device capabilities.
157 struct rt2x00_chip {
158 u16 rt;
159 #define RT2460 0x0101
160 #define RT2560 0x0201
161 #define RT2570 0x1201
162 #define RT2561s 0x0301 /* Turbo */
163 #define RT2561 0x0302
164 #define RT2661 0x0401
165 #define RT2571 0x1300
167 u16 rf;
168 u32 rev;
172 * RF register values that belong to a particular channel.
174 struct rf_channel {
175 int channel;
176 u32 rf1;
177 u32 rf2;
178 u32 rf3;
179 u32 rf4;
183 * Antenna setup values.
185 struct antenna_setup {
186 enum antenna rx;
187 enum antenna tx;
191 * Quality statistics about the currently active link.
193 struct link_qual {
195 * Statistics required for Link tuning.
196 * For the average RSSI value we use the "Walking average" approach.
197 * When adding RSSI to the average value the following calculation
198 * is needed:
200 * avg_rssi = ((avg_rssi * 7) + rssi) / 8;
202 * The advantage of this approach is that we only need 1 variable
203 * to store the average in (No need for a count and a total).
204 * But more importantly, normal average values will over time
205 * move less and less towards newly added values this results
206 * that with link tuning, the device can have a very good RSSI
207 * for a few minutes but when the device is moved away from the AP
208 * the average will not decrease fast enough to compensate.
209 * The walking average compensates this and will move towards
210 * the new values correctly allowing a effective link tuning.
212 int avg_rssi;
213 int false_cca;
216 * Statistics required for Signal quality calculation.
217 * For calculating the Signal quality we have to determine
218 * the total number of success and failed RX and TX frames.
219 * After that we also use the average RSSI value to help
220 * determining the signal quality.
221 * For the calculation we will use the following algorithm:
223 * rssi_percentage = (avg_rssi * 100) / rssi_offset
224 * rx_percentage = (rx_success * 100) / rx_total
225 * tx_percentage = (tx_success * 100) / tx_total
226 * avg_signal = ((WEIGHT_RSSI * avg_rssi) +
227 * (WEIGHT_TX * tx_percentage) +
228 * (WEIGHT_RX * rx_percentage)) / 100
230 * This value should then be checked to not be greated then 100.
232 int rx_percentage;
233 int rx_success;
234 int rx_failed;
235 int tx_percentage;
236 int tx_success;
237 int tx_failed;
238 #define WEIGHT_RSSI 20
239 #define WEIGHT_RX 40
240 #define WEIGHT_TX 40
244 * Antenna settings about the currently active link.
246 struct link_ant {
248 * Antenna flags
250 unsigned int flags;
251 #define ANTENNA_RX_DIVERSITY 0x00000001
252 #define ANTENNA_TX_DIVERSITY 0x00000002
253 #define ANTENNA_MODE_SAMPLE 0x00000004
256 * Currently active TX/RX antenna setup.
257 * When software diversity is used, this will indicate
258 * which antenna is actually used at this time.
260 struct antenna_setup active;
263 * RSSI information for the different antenna's.
264 * These statistics are used to determine when
265 * to switch antenna when using software diversity.
267 * rssi[0] -> Antenna A RSSI
268 * rssi[1] -> Antenna B RSSI
270 int rssi_history[2];
273 * Current RSSI average of the currently active antenna.
274 * Similar to the avg_rssi in the link_qual structure
275 * this value is updated by using the walking average.
277 int rssi_ant;
281 * To optimize the quality of the link we need to store
282 * the quality of received frames and periodically
283 * optimize the link.
285 struct link {
287 * Link tuner counter
288 * The number of times the link has been tuned
289 * since the radio has been switched on.
291 u32 count;
294 * Quality measurement values.
296 struct link_qual qual;
299 * TX/RX antenna setup.
301 struct link_ant ant;
304 * Active VGC level
306 int vgc_level;
309 * Work structure for scheduling periodic link tuning.
311 struct delayed_work work;
315 * Small helper macro to work with moving/walking averages.
317 #define MOVING_AVERAGE(__avg, __val, __samples) \
318 ( (((__avg) * ((__samples) - 1)) + (__val)) / (__samples) )
321 * When we lack RSSI information return something less then -80 to
322 * tell the driver to tune the device to maximum sensitivity.
324 #define DEFAULT_RSSI ( -128 )
327 * Link quality access functions.
329 static inline int rt2x00_get_link_rssi(struct link *link)
331 if (link->qual.avg_rssi && link->qual.rx_success)
332 return link->qual.avg_rssi;
333 return DEFAULT_RSSI;
336 static inline int rt2x00_get_link_ant_rssi(struct link *link)
338 if (link->ant.rssi_ant && link->qual.rx_success)
339 return link->ant.rssi_ant;
340 return DEFAULT_RSSI;
343 static inline int rt2x00_get_link_ant_rssi_history(struct link *link,
344 enum antenna ant)
346 if (link->ant.rssi_history[ant - ANTENNA_A])
347 return link->ant.rssi_history[ant - ANTENNA_A];
348 return DEFAULT_RSSI;
351 static inline int rt2x00_update_ant_rssi(struct link *link, int rssi)
353 int old_rssi = link->ant.rssi_history[link->ant.active.rx - ANTENNA_A];
354 link->ant.rssi_history[link->ant.active.rx - ANTENNA_A] = rssi;
355 return old_rssi;
359 * Interface structure
360 * Configuration details about the current interface.
362 struct interface {
364 * Interface identification. The value is assigned
365 * to us by the 80211 stack, and is used to request
366 * new beacons.
368 int id;
371 * Current working type (IEEE80211_IF_TYPE_*).
372 * When set to INVALID_INTERFACE, no interface is configured.
374 int type;
375 #define INVALID_INTERFACE IEEE80211_IF_TYPE_INVALID
378 * MAC of the device.
380 u8 mac[ETH_ALEN];
383 * BBSID of the AP to associate with.
385 u8 bssid[ETH_ALEN];
388 * Store the packet filter mode for the current interface.
390 unsigned int filter;
393 static inline int is_interface_present(struct interface *intf)
395 return !!intf->id;
398 static inline int is_interface_type(struct interface *intf, int type)
400 return intf->type == type;
404 * Details about the supported modes, rates and channels
405 * of a particular chipset. This is used by rt2x00lib
406 * to build the ieee80211_hw_mode array for mac80211.
408 struct hw_mode_spec {
410 * Number of modes, rates and channels.
412 int num_modes;
413 int num_rates;
414 int num_channels;
417 * txpower values.
419 const u8 *tx_power_a;
420 const u8 *tx_power_bg;
421 u8 tx_power_default;
424 * Device/chipset specific value.
426 const struct rf_channel *channels;
430 * Configuration structure wrapper around the
431 * mac80211 configuration structure.
432 * When mac80211 configures the driver, rt2x00lib
433 * can precalculate values which are equal for all
434 * rt2x00 drivers. Those values can be stored in here.
436 struct rt2x00lib_conf {
437 struct ieee80211_conf *conf;
438 struct rf_channel rf;
440 struct antenna_setup ant;
442 int phymode;
444 int basic_rates;
445 int slot_time;
447 short sifs;
448 short pifs;
449 short difs;
450 short eifs;
454 * rt2x00lib callback functions.
456 struct rt2x00lib_ops {
458 * Interrupt handlers.
460 irq_handler_t irq_handler;
463 * Device init handlers.
465 int (*probe_hw) (struct rt2x00_dev *rt2x00dev);
466 char *(*get_firmware_name) (struct rt2x00_dev *rt2x00dev);
467 int (*load_firmware) (struct rt2x00_dev *rt2x00dev, void *data,
468 const size_t len);
471 * Device initialization/deinitialization handlers.
473 int (*initialize) (struct rt2x00_dev *rt2x00dev);
474 void (*uninitialize) (struct rt2x00_dev *rt2x00dev);
477 * Radio control handlers.
479 int (*set_device_state) (struct rt2x00_dev *rt2x00dev,
480 enum dev_state state);
481 int (*rfkill_poll) (struct rt2x00_dev *rt2x00dev);
482 void (*link_stats) (struct rt2x00_dev *rt2x00dev,
483 struct link_qual *qual);
484 void (*reset_tuner) (struct rt2x00_dev *rt2x00dev);
485 void (*link_tuner) (struct rt2x00_dev *rt2x00dev);
488 * TX control handlers
490 void (*write_tx_desc) (struct rt2x00_dev *rt2x00dev,
491 __le32 *txd,
492 struct txdata_entry_desc *desc,
493 struct ieee80211_hdr *ieee80211hdr,
494 unsigned int length,
495 struct ieee80211_tx_control *control);
496 int (*write_tx_data) (struct rt2x00_dev *rt2x00dev,
497 struct data_ring *ring, struct sk_buff *skb,
498 struct ieee80211_tx_control *control);
499 int (*get_tx_data_len) (struct rt2x00_dev *rt2x00dev,
500 struct sk_buff *skb);
501 void (*kick_tx_queue) (struct rt2x00_dev *rt2x00dev,
502 unsigned int queue);
505 * RX control handlers
507 void (*fill_rxdone) (struct data_entry *entry,
508 struct rxdata_entry_desc *desc);
511 * Configuration handlers.
513 void (*config_mac_addr) (struct rt2x00_dev *rt2x00dev, __le32 *mac);
514 void (*config_bssid) (struct rt2x00_dev *rt2x00dev, __le32 *bssid);
515 void (*config_type) (struct rt2x00_dev *rt2x00dev, const int type,
516 const int tsf_sync);
517 void (*config_preamble) (struct rt2x00_dev *rt2x00dev,
518 const int short_preamble,
519 const int ack_timeout,
520 const int ack_consume_time);
521 void (*config) (struct rt2x00_dev *rt2x00dev, const unsigned int flags,
522 struct rt2x00lib_conf *libconf);
523 #define CONFIG_UPDATE_PHYMODE ( 1 << 1 )
524 #define CONFIG_UPDATE_CHANNEL ( 1 << 2 )
525 #define CONFIG_UPDATE_TXPOWER ( 1 << 3 )
526 #define CONFIG_UPDATE_ANTENNA ( 1 << 4 )
527 #define CONFIG_UPDATE_SLOT_TIME ( 1 << 5 )
528 #define CONFIG_UPDATE_BEACON_INT ( 1 << 6 )
529 #define CONFIG_UPDATE_ALL 0xffff
533 * rt2x00 driver callback operation structure.
535 struct rt2x00_ops {
536 const char *name;
537 const unsigned int rxd_size;
538 const unsigned int txd_size;
539 const unsigned int eeprom_size;
540 const unsigned int rf_size;
541 const struct rt2x00lib_ops *lib;
542 const struct ieee80211_ops *hw;
543 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
544 const struct rt2x00debug *debugfs;
545 #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
549 * rt2x00 device flags
551 enum rt2x00_flags {
553 * Device state flags
555 DEVICE_PRESENT,
556 DEVICE_REGISTERED_HW,
557 DEVICE_INITIALIZED,
558 DEVICE_STARTED,
559 DEVICE_STARTED_SUSPEND,
560 DEVICE_ENABLED_RADIO,
561 DEVICE_DISABLED_RADIO_HW,
564 * Driver features
566 DRIVER_REQUIRE_FIRMWARE,
567 DRIVER_REQUIRE_BEACON_RING,
570 * Driver configuration
572 CONFIG_SUPPORT_HW_BUTTON,
573 CONFIG_FRAME_TYPE,
574 CONFIG_RF_SEQUENCE,
575 CONFIG_EXTERNAL_LNA_A,
576 CONFIG_EXTERNAL_LNA_BG,
577 CONFIG_DOUBLE_ANTENNA,
578 CONFIG_DISABLE_LINK_TUNING,
579 CONFIG_SHORT_PREAMBLE,
583 * rt2x00 device structure.
585 struct rt2x00_dev {
587 * Device structure.
588 * The structure stored in here depends on the
589 * system bus (PCI or USB).
590 * When accessing this variable, the rt2x00dev_{pci,usb}
591 * macro's should be used for correct typecasting.
593 void *dev;
594 #define rt2x00dev_pci(__dev) ( (struct pci_dev*)(__dev)->dev )
595 #define rt2x00dev_usb(__dev) ( (struct usb_interface*)(__dev)->dev )
598 * Callback functions.
600 const struct rt2x00_ops *ops;
603 * IEEE80211 control structure.
605 struct ieee80211_hw *hw;
606 struct ieee80211_hw_mode *hwmodes;
607 unsigned int curr_hwmode;
608 #define HWMODE_B 0
609 #define HWMODE_G 1
610 #define HWMODE_A 2
613 * rfkill structure for RF state switching support.
614 * This will only be compiled in when required.
616 #ifdef CONFIG_RT2X00_LIB_RFKILL
617 struct rfkill *rfkill;
618 struct input_polled_dev *poll_dev;
619 #endif /* CONFIG_RT2X00_LIB_RFKILL */
622 * If enabled, the debugfs interface structures
623 * required for deregistration of debugfs.
625 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
626 const struct rt2x00debug_intf *debugfs_intf;
627 #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
630 * Device flags.
631 * In these flags the current status and some
632 * of the device capabilities are stored.
634 unsigned long flags;
637 * Chipset identification.
639 struct rt2x00_chip chip;
642 * hw capability specifications.
644 struct hw_mode_spec spec;
647 * This is the default TX/RX antenna setup as indicated
648 * by the device's EEPROM. When mac80211 sets its
649 * antenna value to 0 we should be using these values.
651 struct antenna_setup default_ant;
654 * Register pointers
655 * csr_addr: Base register address. (PCI)
656 * csr_cache: CSR cache for usb_control_msg. (USB)
658 void __iomem *csr_addr;
659 void *csr_cache;
662 * Mutex to protect register accesses on USB devices.
663 * There are 2 reasons this is needed, one is to ensure
664 * use of the csr_cache (for USB devices) by one thread
665 * isn't corrupted by another thread trying to access it.
666 * The other is that access to BBP and RF registers
667 * require multiple BUS transactions and if another thread
668 * attempted to access one of those registers at the same
669 * time one of the writes could silently fail.
671 struct mutex usb_cache_mutex;
674 * Interface configuration.
676 struct interface interface;
679 * Link quality
681 struct link link;
684 * EEPROM data.
686 __le16 *eeprom;
689 * Active RF register values.
690 * These are stored here so we don't need
691 * to read the rf registers and can directly
692 * use this value instead.
693 * This field should be accessed by using
694 * rt2x00_rf_read() and rt2x00_rf_write().
696 u32 *rf;
699 * USB Max frame size (for rt2500usb & rt73usb).
701 u16 usb_maxpacket;
704 * Current TX power value.
706 u16 tx_power;
709 * LED register (for rt61pci & rt73usb).
711 u16 led_reg;
714 * Led mode (LED_MODE_*)
716 u8 led_mode;
719 * Rssi <-> Dbm offset
721 u8 rssi_offset;
724 * Frequency offset (for rt61pci & rt73usb).
726 u8 freq_offset;
729 * Low level statistics which will have
730 * to be kept up to date while device is running.
732 struct ieee80211_low_level_stats low_level_stats;
735 * RX configuration information.
737 struct ieee80211_rx_status rx_status;
740 * Scheduled work.
742 struct work_struct beacon_work;
743 struct work_struct filter_work;
744 struct work_struct config_work;
747 * Data ring arrays for RX, TX and Beacon.
748 * The Beacon array also contains the Atim ring
749 * if that is supported by the device.
751 int data_rings;
752 struct data_ring *rx;
753 struct data_ring *tx;
754 struct data_ring *bcn;
757 * Firmware image.
759 const struct firmware *fw;
763 * For-each loop for the ring array.
764 * All rings have been allocated as a single array,
765 * this means we can create a very simply loop macro
766 * that is capable of looping through all rings.
767 * ring_end(), txring_end() and ring_loop() are helper macro's which
768 * should not be used directly. Instead the following should be used:
769 * ring_for_each() - Loops through all rings (RX, TX, Beacon & Atim)
770 * txring_for_each() - Loops through TX data rings (TX only)
771 * txringall_for_each() - Loops through all TX rings (TX, Beacon & Atim)
773 #define ring_end(__dev) \
774 &(__dev)->rx[(__dev)->data_rings]
776 #define txring_end(__dev) \
777 &(__dev)->tx[(__dev)->hw->queues]
779 #define ring_loop(__entry, __start, __end) \
780 for ((__entry) = (__start); \
781 prefetch(&(__entry)[1]), (__entry) != (__end); \
782 (__entry) = &(__entry)[1])
784 #define ring_for_each(__dev, __entry) \
785 ring_loop(__entry, (__dev)->rx, ring_end(__dev))
787 #define txring_for_each(__dev, __entry) \
788 ring_loop(__entry, (__dev)->tx, txring_end(__dev))
790 #define txringall_for_each(__dev, __entry) \
791 ring_loop(__entry, (__dev)->tx, ring_end(__dev))
794 * Generic RF access.
795 * The RF is being accessed by word index.
797 static inline void rt2x00_rf_read(struct rt2x00_dev *rt2x00dev,
798 const unsigned int word, u32 *data)
800 *data = rt2x00dev->rf[word];
803 static inline void rt2x00_rf_write(struct rt2x00_dev *rt2x00dev,
804 const unsigned int word, u32 data)
806 rt2x00dev->rf[word] = data;
810 * Generic EEPROM access.
811 * The EEPROM is being accessed by word index.
813 static inline void *rt2x00_eeprom_addr(struct rt2x00_dev *rt2x00dev,
814 const unsigned int word)
816 return (void *)&rt2x00dev->eeprom[word];
819 static inline void rt2x00_eeprom_read(struct rt2x00_dev *rt2x00dev,
820 const unsigned int word, u16 *data)
822 *data = le16_to_cpu(rt2x00dev->eeprom[word]);
825 static inline void rt2x00_eeprom_write(struct rt2x00_dev *rt2x00dev,
826 const unsigned int word, u16 data)
828 rt2x00dev->eeprom[word] = cpu_to_le16(data);
832 * Chipset handlers
834 static inline void rt2x00_set_chip(struct rt2x00_dev *rt2x00dev,
835 const u16 rt, const u16 rf, const u32 rev)
837 INFO(rt2x00dev,
838 "Chipset detected - rt: %04x, rf: %04x, rev: %08x.\n",
839 rt, rf, rev);
841 rt2x00dev->chip.rt = rt;
842 rt2x00dev->chip.rf = rf;
843 rt2x00dev->chip.rev = rev;
846 static inline char rt2x00_rt(const struct rt2x00_chip *chipset, const u16 chip)
848 return (chipset->rt == chip);
851 static inline char rt2x00_rf(const struct rt2x00_chip *chipset, const u16 chip)
853 return (chipset->rf == chip);
856 static inline u16 rt2x00_rev(const struct rt2x00_chip *chipset)
858 return chipset->rev;
861 static inline u16 rt2x00_check_rev(const struct rt2x00_chip *chipset,
862 const u32 rev)
864 return (((chipset->rev & 0xffff0) == rev) &&
865 !!(chipset->rev & 0x0000f));
869 * Duration calculations
870 * The rate variable passed is: 100kbs.
871 * To convert from bytes to bits we multiply size with 8,
872 * then the size is multiplied with 10 to make the
873 * real rate -> rate argument correction.
875 static inline u16 get_duration(const unsigned int size, const u8 rate)
877 return ((size * 8 * 10) / rate);
880 static inline u16 get_duration_res(const unsigned int size, const u8 rate)
882 return ((size * 8 * 10) % rate);
886 * Library functions.
888 struct data_ring *rt2x00lib_get_ring(struct rt2x00_dev *rt2x00dev,
889 const unsigned int queue);
892 * Interrupt context handlers.
894 void rt2x00lib_beacondone(struct rt2x00_dev *rt2x00dev);
895 void rt2x00lib_txdone(struct data_entry *entry,
896 const int status, const int retry);
897 void rt2x00lib_rxdone(struct data_entry *entry, struct sk_buff *skb,
898 struct rxdata_entry_desc *desc);
901 * TX descriptor initializer
903 void rt2x00lib_write_tx_desc(struct rt2x00_dev *rt2x00dev,
904 __le32 *txd,
905 struct ieee80211_hdr *ieee80211hdr,
906 unsigned int length,
907 struct ieee80211_tx_control *control);
910 * mac80211 handlers.
912 int rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb,
913 struct ieee80211_tx_control *control);
914 int rt2x00mac_start(struct ieee80211_hw *hw);
915 void rt2x00mac_stop(struct ieee80211_hw *hw);
916 int rt2x00mac_add_interface(struct ieee80211_hw *hw,
917 struct ieee80211_if_init_conf *conf);
918 void rt2x00mac_remove_interface(struct ieee80211_hw *hw,
919 struct ieee80211_if_init_conf *conf);
920 int rt2x00mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf);
921 int rt2x00mac_config_interface(struct ieee80211_hw *hw, int if_id,
922 struct ieee80211_if_conf *conf);
923 int rt2x00mac_get_stats(struct ieee80211_hw *hw,
924 struct ieee80211_low_level_stats *stats);
925 int rt2x00mac_get_tx_stats(struct ieee80211_hw *hw,
926 struct ieee80211_tx_queue_stats *stats);
927 void rt2x00mac_erp_ie_changed(struct ieee80211_hw *hw, u8 changes,
928 int cts_protection, int preamble);
929 int rt2x00mac_conf_tx(struct ieee80211_hw *hw, int queue,
930 const struct ieee80211_tx_queue_params *params);
933 * Driver allocation handlers.
935 int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev);
936 void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev);
937 #ifdef CONFIG_PM
938 int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev, pm_message_t state);
939 int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev);
940 #endif /* CONFIG_PM */
942 #endif /* RT2X00_H */