init from v2.6.32.60
[mach-moxart.git] / drivers / net / wireless / rt2x00 / rt2x00.h
blob6d7a9a79db363531e72f66ff010ac53b01860078
1 /*
2 Copyright (C) 2004 - 2009 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/skbuff.h>
31 #include <linux/workqueue.h>
32 #include <linux/firmware.h>
33 #include <linux/leds.h>
34 #include <linux/mutex.h>
35 #include <linux/etherdevice.h>
36 #include <linux/input-polldev.h>
38 #include <net/mac80211.h>
40 #include "rt2x00debug.h"
41 #include "rt2x00leds.h"
42 #include "rt2x00reg.h"
43 #include "rt2x00queue.h"
46 * Module information.
48 #define DRV_VERSION "2.3.0"
49 #define DRV_PROJECT "http://rt2x00.serialmonkey.com"
52 * Debug definitions.
53 * Debug output has to be enabled during compile time.
55 #define DEBUG_PRINTK_MSG(__dev, __kernlvl, __lvl, __msg, __args...) \
56 printk(__kernlvl "%s -> %s: %s - " __msg, \
57 wiphy_name((__dev)->hw->wiphy), __func__, __lvl, ##__args)
59 #define DEBUG_PRINTK_PROBE(__kernlvl, __lvl, __msg, __args...) \
60 printk(__kernlvl "%s -> %s: %s - " __msg, \
61 KBUILD_MODNAME, __func__, __lvl, ##__args)
63 #ifdef CONFIG_RT2X00_DEBUG
64 #define DEBUG_PRINTK(__dev, __kernlvl, __lvl, __msg, __args...) \
65 DEBUG_PRINTK_MSG(__dev, __kernlvl, __lvl, __msg, ##__args);
66 #else
67 #define DEBUG_PRINTK(__dev, __kernlvl, __lvl, __msg, __args...) \
68 do { } while (0)
69 #endif /* CONFIG_RT2X00_DEBUG */
72 * Various debug levels.
73 * The debug levels PANIC and ERROR both indicate serious problems,
74 * for this reason they should never be ignored.
75 * The special ERROR_PROBE message is for messages that are generated
76 * when the rt2x00_dev is not yet initialized.
78 #define PANIC(__dev, __msg, __args...) \
79 DEBUG_PRINTK_MSG(__dev, KERN_CRIT, "Panic", __msg, ##__args)
80 #define ERROR(__dev, __msg, __args...) \
81 DEBUG_PRINTK_MSG(__dev, KERN_ERR, "Error", __msg, ##__args)
82 #define ERROR_PROBE(__msg, __args...) \
83 DEBUG_PRINTK_PROBE(KERN_ERR, "Error", __msg, ##__args)
84 #define WARNING(__dev, __msg, __args...) \
85 DEBUG_PRINTK(__dev, KERN_WARNING, "Warning", __msg, ##__args)
86 #define NOTICE(__dev, __msg, __args...) \
87 DEBUG_PRINTK(__dev, KERN_NOTICE, "Notice", __msg, ##__args)
88 #define INFO(__dev, __msg, __args...) \
89 DEBUG_PRINTK(__dev, KERN_INFO, "Info", __msg, ##__args)
90 #define DEBUG(__dev, __msg, __args...) \
91 DEBUG_PRINTK(__dev, KERN_DEBUG, "Debug", __msg, ##__args)
92 #define EEPROM(__dev, __msg, __args...) \
93 DEBUG_PRINTK(__dev, KERN_DEBUG, "EEPROM recovery", __msg, ##__args)
96 * Duration calculations
97 * The rate variable passed is: 100kbs.
98 * To convert from bytes to bits we multiply size with 8,
99 * then the size is multiplied with 10 to make the
100 * real rate -> rate argument correction.
102 #define GET_DURATION(__size, __rate) (((__size) * 8 * 10) / (__rate))
103 #define GET_DURATION_RES(__size, __rate)(((__size) * 8 * 10) % (__rate))
106 * Determine the alignment requirement,
107 * to make sure the 802.11 payload is padded to a 4-byte boundrary
108 * we must determine the address of the payload and calculate the
109 * amount of bytes needed to move the data.
111 #define ALIGN_SIZE(__skb, __header) \
112 ( ((unsigned long)((__skb)->data + (__header))) & 3 )
115 * Constants for extra TX headroom for alignment purposes.
117 #define RT2X00_ALIGN_SIZE 4 /* Only whole frame needs alignment */
118 #define RT2X00_L2PAD_SIZE 8 /* Both header & payload need alignment */
121 * Standard timing and size defines.
122 * These values should follow the ieee80211 specifications.
124 #define ACK_SIZE 14
125 #define IEEE80211_HEADER 24
126 #define PLCP 48
127 #define BEACON 100
128 #define PREAMBLE 144
129 #define SHORT_PREAMBLE 72
130 #define SLOT_TIME 20
131 #define SHORT_SLOT_TIME 9
132 #define SIFS 10
133 #define PIFS ( SIFS + SLOT_TIME )
134 #define SHORT_PIFS ( SIFS + SHORT_SLOT_TIME )
135 #define DIFS ( PIFS + SLOT_TIME )
136 #define SHORT_DIFS ( SHORT_PIFS + SHORT_SLOT_TIME )
137 #define EIFS ( SIFS + DIFS + \
138 GET_DURATION(IEEE80211_HEADER + ACK_SIZE, 10) )
139 #define SHORT_EIFS ( SIFS + SHORT_DIFS + \
140 GET_DURATION(IEEE80211_HEADER + ACK_SIZE, 10) )
143 * Structure for average calculation
144 * The avg field contains the actual average value,
145 * but avg_weight is internally used during calculations
146 * to prevent rounding errors.
148 struct avg_val {
149 int avg;
150 int avg_weight;
154 * Chipset identification
155 * The chipset on the device is composed of a RT and RF chip.
156 * The chipset combination is important for determining device capabilities.
158 struct rt2x00_chip {
159 u16 rt;
160 #define RT2460 0x0101
161 #define RT2560 0x0201
162 #define RT2570 0x1201
163 #define RT2561s 0x0301 /* Turbo */
164 #define RT2561 0x0302
165 #define RT2661 0x0401
166 #define RT2571 0x1300
167 #define RT2870 0x1600
169 u16 rf;
170 u32 rev;
174 * RF register values that belong to a particular channel.
176 struct rf_channel {
177 int channel;
178 u32 rf1;
179 u32 rf2;
180 u32 rf3;
181 u32 rf4;
185 * Channel information structure
187 struct channel_info {
188 unsigned int flags;
189 #define GEOGRAPHY_ALLOWED 0x00000001
191 short tx_power1;
192 short tx_power2;
196 * Antenna setup values.
198 struct antenna_setup {
199 enum antenna rx;
200 enum antenna tx;
204 * Quality statistics about the currently active link.
206 struct link_qual {
208 * Statistics required for Link tuning by driver
209 * The rssi value is provided by rt2x00lib during the
210 * link_tuner() callback function.
211 * The false_cca field is filled during the link_stats()
212 * callback function and could be used during the
213 * link_tuner() callback function.
215 int rssi;
216 int false_cca;
219 * VGC levels
220 * Hardware driver will tune the VGC level during each call
221 * to the link_tuner() callback function. This vgc_level is
222 * is determined based on the link quality statistics like
223 * average RSSI and the false CCA count.
225 * In some cases the drivers need to differentiate between
226 * the currently "desired" VGC level and the level configured
227 * in the hardware. The latter is important to reduce the
228 * number of BBP register reads to reduce register access
229 * overhead. For this reason we store both values here.
231 u8 vgc_level;
232 u8 vgc_level_reg;
235 * Statistics required for Signal quality calculation.
236 * These fields might be changed during the link_stats()
237 * callback function.
239 int rx_success;
240 int rx_failed;
241 int tx_success;
242 int tx_failed;
246 * Antenna settings about the currently active link.
248 struct link_ant {
250 * Antenna flags
252 unsigned int flags;
253 #define ANTENNA_RX_DIVERSITY 0x00000001
254 #define ANTENNA_TX_DIVERSITY 0x00000002
255 #define ANTENNA_MODE_SAMPLE 0x00000004
258 * Currently active TX/RX antenna setup.
259 * When software diversity is used, this will indicate
260 * which antenna is actually used at this time.
262 struct antenna_setup active;
265 * RSSI history information for the antenna.
266 * Used to determine when to switch antenna
267 * when using software diversity.
269 int rssi_history;
272 * Current RSSI average of the currently active antenna.
273 * Similar to the avg_rssi in the link_qual structure
274 * this value is updated by using the walking average.
276 struct avg_val rssi_ant;
280 * To optimize the quality of the link we need to store
281 * the quality of received frames and periodically
282 * optimize the link.
284 struct link {
286 * Link tuner counter
287 * The number of times the link has been tuned
288 * since the radio has been switched on.
290 u32 count;
293 * Quality measurement values.
295 struct link_qual qual;
298 * TX/RX antenna setup.
300 struct link_ant ant;
303 * Currently active average RSSI value
305 struct avg_val avg_rssi;
308 * Currently precalculated percentages of successful
309 * TX and RX frames.
311 int rx_percentage;
312 int tx_percentage;
315 * Work structure for scheduling periodic link tuning.
317 struct delayed_work work;
321 * Interface structure
322 * Per interface configuration details, this structure
323 * is allocated as the private data for ieee80211_vif.
325 struct rt2x00_intf {
327 * All fields within the rt2x00_intf structure
328 * must be protected with a spinlock.
330 spinlock_t lock;
333 * MAC of the device.
335 u8 mac[ETH_ALEN];
338 * BBSID of the AP to associate with.
340 u8 bssid[ETH_ALEN];
343 * beacon->skb must be protected with the mutex.
345 struct mutex beacon_skb_mutex;
348 * Entry in the beacon queue which belongs to
349 * this interface. Each interface has its own
350 * dedicated beacon entry.
352 struct queue_entry *beacon;
355 * Actions that needed rescheduling.
357 unsigned int delayed_flags;
358 #define DELAYED_UPDATE_BEACON 0x00000001
361 * Software sequence counter, this is only required
362 * for hardware which doesn't support hardware
363 * sequence counting.
365 spinlock_t seqlock;
366 u16 seqno;
369 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
371 return (struct rt2x00_intf *)vif->drv_priv;
375 * struct hw_mode_spec: Hardware specifications structure
377 * Details about the supported modes, rates and channels
378 * of a particular chipset. This is used by rt2x00lib
379 * to build the ieee80211_hw_mode array for mac80211.
381 * @supported_bands: Bitmask contained the supported bands (2.4GHz, 5.2GHz).
382 * @supported_rates: Rate types which are supported (CCK, OFDM).
383 * @num_channels: Number of supported channels. This is used as array size
384 * for @tx_power_a, @tx_power_bg and @channels.
385 * @channels: Device/chipset specific channel values (See &struct rf_channel).
386 * @channels_info: Additional information for channels (See &struct channel_info).
387 * @ht: Driver HT Capabilities (See &ieee80211_sta_ht_cap).
389 struct hw_mode_spec {
390 unsigned int supported_bands;
391 #define SUPPORT_BAND_2GHZ 0x00000001
392 #define SUPPORT_BAND_5GHZ 0x00000002
394 unsigned int supported_rates;
395 #define SUPPORT_RATE_CCK 0x00000001
396 #define SUPPORT_RATE_OFDM 0x00000002
398 unsigned int num_channels;
399 const struct rf_channel *channels;
400 const struct channel_info *channels_info;
402 struct ieee80211_sta_ht_cap ht;
406 * Configuration structure wrapper around the
407 * mac80211 configuration structure.
408 * When mac80211 configures the driver, rt2x00lib
409 * can precalculate values which are equal for all
410 * rt2x00 drivers. Those values can be stored in here.
412 struct rt2x00lib_conf {
413 struct ieee80211_conf *conf;
415 struct rf_channel rf;
416 struct channel_info channel;
420 * Configuration structure for erp settings.
422 struct rt2x00lib_erp {
423 int short_preamble;
424 int cts_protection;
426 u32 basic_rates;
428 int slot_time;
430 short sifs;
431 short pifs;
432 short difs;
433 short eifs;
435 u16 beacon_int;
439 * Configuration structure for hardware encryption.
441 struct rt2x00lib_crypto {
442 enum cipher cipher;
444 enum set_key_cmd cmd;
445 const u8 *address;
447 u32 bssidx;
448 u32 aid;
450 u8 key[16];
451 u8 tx_mic[8];
452 u8 rx_mic[8];
456 * Configuration structure wrapper around the
457 * rt2x00 interface configuration handler.
459 struct rt2x00intf_conf {
461 * Interface type
463 enum nl80211_iftype type;
466 * TSF sync value, this is dependant on the operation type.
468 enum tsf_sync sync;
471 * The MAC and BSSID addressess are simple array of bytes,
472 * these arrays are little endian, so when sending the addressess
473 * to the drivers, copy the it into a endian-signed variable.
475 * Note that all devices (except rt2500usb) have 32 bits
476 * register word sizes. This means that whatever variable we
477 * pass _must_ be a multiple of 32 bits. Otherwise the device
478 * might not accept what we are sending to it.
479 * This will also make it easier for the driver to write
480 * the data to the device.
482 __le32 mac[2];
483 __le32 bssid[2];
487 * rt2x00lib callback functions.
489 struct rt2x00lib_ops {
491 * Interrupt handlers.
493 irq_handler_t irq_handler;
496 * Device init handlers.
498 int (*probe_hw) (struct rt2x00_dev *rt2x00dev);
499 char *(*get_firmware_name) (struct rt2x00_dev *rt2x00dev);
500 int (*check_firmware) (struct rt2x00_dev *rt2x00dev,
501 const u8 *data, const size_t len);
502 int (*load_firmware) (struct rt2x00_dev *rt2x00dev,
503 const u8 *data, const size_t len);
506 * Device initialization/deinitialization handlers.
508 int (*initialize) (struct rt2x00_dev *rt2x00dev);
509 void (*uninitialize) (struct rt2x00_dev *rt2x00dev);
512 * queue initialization handlers
514 bool (*get_entry_state) (struct queue_entry *entry);
515 void (*clear_entry) (struct queue_entry *entry);
518 * Radio control handlers.
520 int (*set_device_state) (struct rt2x00_dev *rt2x00dev,
521 enum dev_state state);
522 int (*rfkill_poll) (struct rt2x00_dev *rt2x00dev);
523 void (*link_stats) (struct rt2x00_dev *rt2x00dev,
524 struct link_qual *qual);
525 void (*reset_tuner) (struct rt2x00_dev *rt2x00dev,
526 struct link_qual *qual);
527 void (*link_tuner) (struct rt2x00_dev *rt2x00dev,
528 struct link_qual *qual, const u32 count);
531 * TX control handlers
533 void (*write_tx_desc) (struct rt2x00_dev *rt2x00dev,
534 struct sk_buff *skb,
535 struct txentry_desc *txdesc);
536 int (*write_tx_data) (struct queue_entry *entry);
537 void (*write_beacon) (struct queue_entry *entry);
538 int (*get_tx_data_len) (struct queue_entry *entry);
539 void (*kick_tx_queue) (struct rt2x00_dev *rt2x00dev,
540 const enum data_queue_qid queue);
541 void (*kill_tx_queue) (struct rt2x00_dev *rt2x00dev,
542 const enum data_queue_qid queue);
545 * RX control handlers
547 void (*fill_rxdone) (struct queue_entry *entry,
548 struct rxdone_entry_desc *rxdesc);
551 * Configuration handlers.
553 int (*config_shared_key) (struct rt2x00_dev *rt2x00dev,
554 struct rt2x00lib_crypto *crypto,
555 struct ieee80211_key_conf *key);
556 int (*config_pairwise_key) (struct rt2x00_dev *rt2x00dev,
557 struct rt2x00lib_crypto *crypto,
558 struct ieee80211_key_conf *key);
559 void (*config_filter) (struct rt2x00_dev *rt2x00dev,
560 const unsigned int filter_flags);
561 void (*config_intf) (struct rt2x00_dev *rt2x00dev,
562 struct rt2x00_intf *intf,
563 struct rt2x00intf_conf *conf,
564 const unsigned int flags);
565 #define CONFIG_UPDATE_TYPE ( 1 << 1 )
566 #define CONFIG_UPDATE_MAC ( 1 << 2 )
567 #define CONFIG_UPDATE_BSSID ( 1 << 3 )
569 void (*config_erp) (struct rt2x00_dev *rt2x00dev,
570 struct rt2x00lib_erp *erp);
571 void (*config_ant) (struct rt2x00_dev *rt2x00dev,
572 struct antenna_setup *ant);
573 void (*config) (struct rt2x00_dev *rt2x00dev,
574 struct rt2x00lib_conf *libconf,
575 const unsigned int changed_flags);
579 * rt2x00 driver callback operation structure.
581 struct rt2x00_ops {
582 const char *name;
583 const unsigned int max_sta_intf;
584 const unsigned int max_ap_intf;
585 const unsigned int eeprom_size;
586 const unsigned int rf_size;
587 const unsigned int tx_queues;
588 const unsigned int extra_tx_headroom;
589 const struct data_queue_desc *rx;
590 const struct data_queue_desc *tx;
591 const struct data_queue_desc *bcn;
592 const struct data_queue_desc *atim;
593 const struct rt2x00lib_ops *lib;
594 const struct ieee80211_ops *hw;
595 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
596 const struct rt2x00debug *debugfs;
597 #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
601 * rt2x00 device flags
603 enum rt2x00_flags {
605 * Device state flags
607 DEVICE_STATE_PRESENT,
608 DEVICE_STATE_REGISTERED_HW,
609 DEVICE_STATE_INITIALIZED,
610 DEVICE_STATE_STARTED,
611 DEVICE_STATE_ENABLED_RADIO,
614 * Driver requirements
616 DRIVER_REQUIRE_FIRMWARE,
617 DRIVER_REQUIRE_BEACON_GUARD,
618 DRIVER_REQUIRE_ATIM_QUEUE,
619 DRIVER_REQUIRE_DMA,
620 DRIVER_REQUIRE_COPY_IV,
621 DRIVER_REQUIRE_L2PAD,
624 * Driver features
626 CONFIG_SUPPORT_HW_BUTTON,
627 CONFIG_SUPPORT_HW_CRYPTO,
628 DRIVER_SUPPORT_CONTROL_FILTERS,
629 DRIVER_SUPPORT_CONTROL_FILTER_PSPOLL,
632 * Driver configuration
634 CONFIG_FRAME_TYPE,
635 CONFIG_RF_SEQUENCE,
636 CONFIG_EXTERNAL_LNA_A,
637 CONFIG_EXTERNAL_LNA_BG,
638 CONFIG_DOUBLE_ANTENNA,
639 CONFIG_DISABLE_LINK_TUNING,
640 CONFIG_CHANNEL_HT40,
644 * rt2x00 device structure.
646 struct rt2x00_dev {
648 * Device structure.
649 * The structure stored in here depends on the
650 * system bus (PCI or USB).
651 * When accessing this variable, the rt2x00dev_{pci,usb}
652 * macros should be used for correct typecasting.
654 struct device *dev;
657 * Callback functions.
659 const struct rt2x00_ops *ops;
662 * IEEE80211 control structure.
664 struct ieee80211_hw *hw;
665 struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS];
666 enum ieee80211_band curr_band;
669 * If enabled, the debugfs interface structures
670 * required for deregistration of debugfs.
672 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
673 struct rt2x00debug_intf *debugfs_intf;
674 #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
677 * LED structure for changing the LED status
678 * by mac8011 or the kernel.
680 #ifdef CONFIG_RT2X00_LIB_LEDS
681 struct rt2x00_led led_radio;
682 struct rt2x00_led led_assoc;
683 struct rt2x00_led led_qual;
684 u16 led_mcu_reg;
685 #endif /* CONFIG_RT2X00_LIB_LEDS */
688 * Device flags.
689 * In these flags the current status and some
690 * of the device capabilities are stored.
692 unsigned long flags;
695 * Device information, Bus IRQ and name (PCI, SoC)
697 int irq;
698 const char *name;
701 * Chipset identification.
703 struct rt2x00_chip chip;
706 * hw capability specifications.
708 struct hw_mode_spec spec;
711 * This is the default TX/RX antenna setup as indicated
712 * by the device's EEPROM.
714 struct antenna_setup default_ant;
717 * Register pointers
718 * csr.base: CSR base register address. (PCI)
719 * csr.cache: CSR cache for usb_control_msg. (USB)
721 union csr {
722 void __iomem *base;
723 void *cache;
724 } csr;
727 * Mutex to protect register accesses.
728 * For PCI and USB devices it protects against concurrent indirect
729 * register access (BBP, RF, MCU) since accessing those
730 * registers require multiple calls to the CSR registers.
731 * For USB devices it also protects the csr_cache since that
732 * field is used for normal CSR access and it cannot support
733 * multiple callers simultaneously.
735 struct mutex csr_mutex;
738 * Current packet filter configuration for the device.
739 * This contains all currently active FIF_* flags send
740 * to us by mac80211 during configure_filter().
742 unsigned int packet_filter;
745 * Interface details:
746 * - Open ap interface count.
747 * - Open sta interface count.
748 * - Association count.
750 unsigned int intf_ap_count;
751 unsigned int intf_sta_count;
752 unsigned int intf_associated;
755 * Link quality
757 struct link link;
760 * EEPROM data.
762 __le16 *eeprom;
765 * Active RF register values.
766 * These are stored here so we don't need
767 * to read the rf registers and can directly
768 * use this value instead.
769 * This field should be accessed by using
770 * rt2x00_rf_read() and rt2x00_rf_write().
772 u32 *rf;
775 * LNA gain
777 short lna_gain;
780 * Current TX power value.
782 u16 tx_power;
785 * Current retry values.
787 u8 short_retry;
788 u8 long_retry;
791 * Rssi <-> Dbm offset
793 u8 rssi_offset;
796 * Frequency offset (for rt61pci & rt73usb).
798 u8 freq_offset;
801 * Calibration information (for rt2800usb & rt2800pci).
802 * [0] -> BW20
803 * [1] -> BW40
805 u8 calibration[2];
808 * Beacon interval.
810 u16 beacon_int;
813 * Low level statistics which will have
814 * to be kept up to date while device is running.
816 struct ieee80211_low_level_stats low_level_stats;
819 * RX configuration information.
821 struct ieee80211_rx_status rx_status;
824 * Scheduled work.
825 * NOTE: intf_work will use ieee80211_iterate_active_interfaces()
826 * which means it cannot be placed on the hw->workqueue
827 * due to RTNL locking requirements.
829 struct work_struct intf_work;
832 * Data queue arrays for RX, TX and Beacon.
833 * The Beacon array also contains the Atim queue
834 * if that is supported by the device.
836 unsigned int data_queues;
837 struct data_queue *rx;
838 struct data_queue *tx;
839 struct data_queue *bcn;
842 * Firmware image.
844 const struct firmware *fw;
848 * Generic RF access.
849 * The RF is being accessed by word index.
851 static inline void rt2x00_rf_read(struct rt2x00_dev *rt2x00dev,
852 const unsigned int word, u32 *data)
854 BUG_ON(word < 1 || word > rt2x00dev->ops->rf_size / sizeof(u32));
855 *data = rt2x00dev->rf[word - 1];
858 static inline void rt2x00_rf_write(struct rt2x00_dev *rt2x00dev,
859 const unsigned int word, u32 data)
861 BUG_ON(word < 1 || word > rt2x00dev->ops->rf_size / sizeof(u32));
862 rt2x00dev->rf[word - 1] = data;
866 * Generic EEPROM access.
867 * The EEPROM is being accessed by word index.
869 static inline void *rt2x00_eeprom_addr(struct rt2x00_dev *rt2x00dev,
870 const unsigned int word)
872 return (void *)&rt2x00dev->eeprom[word];
875 static inline void rt2x00_eeprom_read(struct rt2x00_dev *rt2x00dev,
876 const unsigned int word, u16 *data)
878 *data = le16_to_cpu(rt2x00dev->eeprom[word]);
881 static inline void rt2x00_eeprom_write(struct rt2x00_dev *rt2x00dev,
882 const unsigned int word, u16 data)
884 rt2x00dev->eeprom[word] = cpu_to_le16(data);
888 * Chipset handlers
890 static inline void rt2x00_set_chip(struct rt2x00_dev *rt2x00dev,
891 const u16 rt, const u16 rf, const u32 rev)
893 INFO(rt2x00dev,
894 "Chipset detected - rt: %04x, rf: %04x, rev: %08x.\n",
895 rt, rf, rev);
897 rt2x00dev->chip.rt = rt;
898 rt2x00dev->chip.rf = rf;
899 rt2x00dev->chip.rev = rev;
902 static inline void rt2x00_set_chip_rt(struct rt2x00_dev *rt2x00dev,
903 const u16 rt)
905 rt2x00dev->chip.rt = rt;
908 static inline void rt2x00_set_chip_rf(struct rt2x00_dev *rt2x00dev,
909 const u16 rf, const u32 rev)
911 rt2x00_set_chip(rt2x00dev, rt2x00dev->chip.rt, rf, rev);
914 static inline char rt2x00_rt(const struct rt2x00_chip *chipset, const u16 chip)
916 return (chipset->rt == chip);
919 static inline char rt2x00_rf(const struct rt2x00_chip *chipset, const u16 chip)
921 return (chipset->rf == chip);
924 static inline u32 rt2x00_rev(const struct rt2x00_chip *chipset)
926 return chipset->rev;
929 static inline bool rt2x00_check_rev(const struct rt2x00_chip *chipset,
930 const u32 mask, const u32 rev)
932 return ((chipset->rev & mask) == rev);
936 * rt2x00queue_map_txskb - Map a skb into DMA for TX purposes.
937 * @rt2x00dev: Pointer to &struct rt2x00_dev.
938 * @skb: The skb to map.
940 void rt2x00queue_map_txskb(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb);
943 * rt2x00queue_get_queue - Convert queue index to queue pointer
944 * @rt2x00dev: Pointer to &struct rt2x00_dev.
945 * @queue: rt2x00 queue index (see &enum data_queue_qid).
947 struct data_queue *rt2x00queue_get_queue(struct rt2x00_dev *rt2x00dev,
948 const enum data_queue_qid queue);
951 * rt2x00queue_get_entry - Get queue entry where the given index points to.
952 * @queue: Pointer to &struct data_queue from where we obtain the entry.
953 * @index: Index identifier for obtaining the correct index.
955 struct queue_entry *rt2x00queue_get_entry(struct data_queue *queue,
956 enum queue_index index);
959 * Interrupt context handlers.
961 void rt2x00lib_beacondone(struct rt2x00_dev *rt2x00dev);
962 void rt2x00lib_txdone(struct queue_entry *entry,
963 struct txdone_entry_desc *txdesc);
964 void rt2x00lib_rxdone(struct rt2x00_dev *rt2x00dev,
965 struct queue_entry *entry);
968 * mac80211 handlers.
970 int rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb);
971 int rt2x00mac_start(struct ieee80211_hw *hw);
972 void rt2x00mac_stop(struct ieee80211_hw *hw);
973 int rt2x00mac_add_interface(struct ieee80211_hw *hw,
974 struct ieee80211_if_init_conf *conf);
975 void rt2x00mac_remove_interface(struct ieee80211_hw *hw,
976 struct ieee80211_if_init_conf *conf);
977 int rt2x00mac_config(struct ieee80211_hw *hw, u32 changed);
978 void rt2x00mac_configure_filter(struct ieee80211_hw *hw,
979 unsigned int changed_flags,
980 unsigned int *total_flags,
981 u64 multicast);
982 int rt2x00mac_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
983 bool set);
984 #ifdef CONFIG_RT2X00_LIB_CRYPTO
985 int rt2x00mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
986 struct ieee80211_vif *vif, struct ieee80211_sta *sta,
987 struct ieee80211_key_conf *key);
988 #else
989 #define rt2x00mac_set_key NULL
990 #endif /* CONFIG_RT2X00_LIB_CRYPTO */
991 int rt2x00mac_get_stats(struct ieee80211_hw *hw,
992 struct ieee80211_low_level_stats *stats);
993 int rt2x00mac_get_tx_stats(struct ieee80211_hw *hw,
994 struct ieee80211_tx_queue_stats *stats);
995 void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw,
996 struct ieee80211_vif *vif,
997 struct ieee80211_bss_conf *bss_conf,
998 u32 changes);
999 int rt2x00mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
1000 const struct ieee80211_tx_queue_params *params);
1001 void rt2x00mac_rfkill_poll(struct ieee80211_hw *hw);
1004 * Driver allocation handlers.
1006 int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev);
1007 void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev);
1008 #ifdef CONFIG_PM
1009 int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev, pm_message_t state);
1010 int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev);
1011 #endif /* CONFIG_PM */
1013 #endif /* RT2X00_H */