1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483 |
- #ifndef RT2X00_H
- #define RT2X00_H
- #include <linux/bitops.h>
- #include <linux/interrupt.h>
- #include <linux/skbuff.h>
- #include <linux/workqueue.h>
- #include <linux/firmware.h>
- #include <linux/leds.h>
- #include <linux/mutex.h>
- #include <linux/etherdevice.h>
- #include <linux/input-polldev.h>
- #include <linux/kfifo.h>
- #include <linux/hrtimer.h>
- #include <linux/average.h>
- #include <linux/usb.h>
- #include <net/mac80211.h>
- #include "rt2x00debug.h"
- #include "rt2x00dump.h"
- #include "rt2x00leds.h"
- #include "rt2x00reg.h"
- #include "rt2x00queue.h"
- #define DRV_VERSION "2.3.0"
- #define DRV_PROJECT "http://rt2x00.serialmonkey.com"
- #ifdef CONFIG_RT2X00_DEBUG
- #define DEBUG
- #endif /* CONFIG_RT2X00_DEBUG */
- #define rt2x00_probe_err(fmt, ...) \
- printk(KERN_ERR KBUILD_MODNAME ": %s: Error - " fmt, \
- __func__, ##__VA_ARGS__)
- #define rt2x00_err(dev, fmt, ...) \
- wiphy_err((dev)->hw->wiphy, "%s: Error - " fmt, \
- __func__, ##__VA_ARGS__)
- #define rt2x00_warn(dev, fmt, ...) \
- wiphy_warn((dev)->hw->wiphy, "%s: Warning - " fmt, \
- __func__, ##__VA_ARGS__)
- #define rt2x00_info(dev, fmt, ...) \
- wiphy_info((dev)->hw->wiphy, "%s: Info - " fmt, \
- __func__, ##__VA_ARGS__)
- #define rt2x00_dbg(dev, fmt, ...) \
- wiphy_dbg((dev)->hw->wiphy, "%s: Debug - " fmt, \
- __func__, ##__VA_ARGS__)
- #define rt2x00_eeprom_dbg(dev, fmt, ...) \
- wiphy_dbg((dev)->hw->wiphy, "%s: EEPROM recovery - " fmt, \
- __func__, ##__VA_ARGS__)
- #define GET_DURATION(__size, __rate) (((__size) * 8 * 10) / (__rate))
- #define GET_DURATION_RES(__size, __rate)(((__size) * 8 * 10) % (__rate))
- #define L2PAD_SIZE(__hdrlen) (-(__hdrlen) & 3)
- #define ALIGN_SIZE(__skb, __header) \
- (((unsigned long)((__skb)->data + (__header))) & 3)
- #define RT2X00_ALIGN_SIZE 4 /* Only whole frame needs alignment */
- #define RT2X00_L2PAD_SIZE 8 /* Both header & payload need alignment */
- #define ACK_SIZE 14
- #define IEEE80211_HEADER 24
- #define PLCP 48
- #define BEACON 100
- #define PREAMBLE 144
- #define SHORT_PREAMBLE 72
- #define SLOT_TIME 20
- #define SHORT_SLOT_TIME 9
- #define SIFS 10
- #define PIFS (SIFS + SLOT_TIME)
- #define SHORT_PIFS (SIFS + SHORT_SLOT_TIME)
- #define DIFS (PIFS + SLOT_TIME)
- #define SHORT_DIFS (SHORT_PIFS + SHORT_SLOT_TIME)
- #define EIFS (SIFS + DIFS + \
- GET_DURATION(IEEE80211_HEADER + ACK_SIZE, 10))
- #define SHORT_EIFS (SIFS + SHORT_DIFS + \
- GET_DURATION(IEEE80211_HEADER + ACK_SIZE, 10))
- enum rt2x00_chip_intf {
- RT2X00_CHIP_INTF_PCI,
- RT2X00_CHIP_INTF_PCIE,
- RT2X00_CHIP_INTF_USB,
- RT2X00_CHIP_INTF_SOC,
- };
- struct rt2x00_chip {
- u16 rt;
- #define RT2460 0x2460
- #define RT2560 0x2560
- #define RT2570 0x2570
- #define RT2661 0x2661
- #define RT2573 0x2573
- #define RT2860 0x2860 /* 2.4GHz */
- #define RT2872 0x2872 /* WSOC */
- #define RT2883 0x2883 /* WSOC */
- #define RT3070 0x3070
- #define RT3071 0x3071
- #define RT3090 0x3090 /* 2.4GHz PCIe */
- #define RT3290 0x3290
- #define RT3352 0x3352 /* WSOC */
- #define RT3390 0x3390
- #define RT3572 0x3572
- #define RT3593 0x3593
- #define RT3883 0x3883 /* WSOC */
- #define RT5390 0x5390 /* 2.4GHz */
- #define RT5392 0x5392 /* 2.4GHz */
- #define RT5592 0x5592
- u16 rf;
- u16 rev;
- enum rt2x00_chip_intf intf;
- };
- struct rf_channel {
- int channel;
- u32 rf1;
- u32 rf2;
- u32 rf3;
- u32 rf4;
- };
- struct channel_info {
- unsigned int flags;
- #define GEOGRAPHY_ALLOWED 0x00000001
- short max_power;
- short default_power1;
- short default_power2;
- short default_power3;
- };
- struct antenna_setup {
- enum antenna rx;
- enum antenna tx;
- u8 rx_chain_num;
- u8 tx_chain_num;
- };
- struct link_qual {
-
- int rssi;
- int false_cca;
-
- u8 vgc_level;
- u8 vgc_level_reg;
-
- int rx_success;
- int rx_failed;
- int tx_success;
- int tx_failed;
- };
- DECLARE_EWMA(rssi, 1024, 8)
- struct link_ant {
-
- unsigned int flags;
- #define ANTENNA_RX_DIVERSITY 0x00000001
- #define ANTENNA_TX_DIVERSITY 0x00000002
- #define ANTENNA_MODE_SAMPLE 0x00000004
-
- struct antenna_setup active;
-
- int rssi_history;
-
- struct ewma_rssi rssi_ant;
- };
- struct link {
-
- u32 count;
-
- struct link_qual qual;
-
- struct link_ant ant;
-
- struct ewma_rssi avg_rssi;
-
- struct delayed_work work;
-
- struct delayed_work watchdog_work;
-
- struct delayed_work agc_work;
-
- struct delayed_work vco_work;
- };
- enum rt2x00_delayed_flags {
- DELAYED_UPDATE_BEACON,
- };
- struct rt2x00_intf {
-
- struct mutex beacon_skb_mutex;
-
- struct queue_entry *beacon;
- bool enable_beacon;
-
- unsigned long delayed_flags;
-
- atomic_t seqno;
- };
- static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
- {
- return (struct rt2x00_intf *)vif->drv_priv;
- }
- struct hw_mode_spec {
- unsigned int supported_bands;
- #define SUPPORT_BAND_2GHZ 0x00000001
- #define SUPPORT_BAND_5GHZ 0x00000002
- unsigned int supported_rates;
- #define SUPPORT_RATE_CCK 0x00000001
- #define SUPPORT_RATE_OFDM 0x00000002
- unsigned int num_channels;
- const struct rf_channel *channels;
- const struct channel_info *channels_info;
- struct ieee80211_sta_ht_cap ht;
- };
- struct rt2x00lib_conf {
- struct ieee80211_conf *conf;
- struct rf_channel rf;
- struct channel_info channel;
- };
- struct rt2x00lib_erp {
- int short_preamble;
- int cts_protection;
- u32 basic_rates;
- int slot_time;
- short sifs;
- short pifs;
- short difs;
- short eifs;
- u16 beacon_int;
- u16 ht_opmode;
- };
- struct rt2x00lib_crypto {
- enum cipher cipher;
- enum set_key_cmd cmd;
- const u8 *address;
- u32 bssidx;
- u8 key[16];
- u8 tx_mic[8];
- u8 rx_mic[8];
- int wcid;
- };
- struct rt2x00intf_conf {
-
- enum nl80211_iftype type;
-
- enum tsf_sync sync;
-
- __le32 mac[2];
- __le32 bssid[2];
- };
- struct rt2x00_sta {
- int wcid;
- };
- static inline struct rt2x00_sta* sta_to_rt2x00_sta(struct ieee80211_sta *sta)
- {
- return (struct rt2x00_sta *)sta->drv_priv;
- }
- struct rt2x00lib_ops {
-
- irq_handler_t irq_handler;
-
- void (*txstatus_tasklet) (unsigned long data);
- void (*pretbtt_tasklet) (unsigned long data);
- void (*tbtt_tasklet) (unsigned long data);
- void (*rxdone_tasklet) (unsigned long data);
- void (*autowake_tasklet) (unsigned long data);
-
- int (*probe_hw) (struct rt2x00_dev *rt2x00dev);
- char *(*get_firmware_name) (struct rt2x00_dev *rt2x00dev);
- int (*check_firmware) (struct rt2x00_dev *rt2x00dev,
- const u8 *data, const size_t len);
- int (*load_firmware) (struct rt2x00_dev *rt2x00dev,
- const u8 *data, const size_t len);
-
- int (*initialize) (struct rt2x00_dev *rt2x00dev);
- void (*uninitialize) (struct rt2x00_dev *rt2x00dev);
-
- bool (*get_entry_state) (struct queue_entry *entry);
- void (*clear_entry) (struct queue_entry *entry);
-
- int (*set_device_state) (struct rt2x00_dev *rt2x00dev,
- enum dev_state state);
- int (*rfkill_poll) (struct rt2x00_dev *rt2x00dev);
- void (*link_stats) (struct rt2x00_dev *rt2x00dev,
- struct link_qual *qual);
- void (*reset_tuner) (struct rt2x00_dev *rt2x00dev,
- struct link_qual *qual);
- void (*link_tuner) (struct rt2x00_dev *rt2x00dev,
- struct link_qual *qual, const u32 count);
- void (*gain_calibration) (struct rt2x00_dev *rt2x00dev);
- void (*vco_calibration) (struct rt2x00_dev *rt2x00dev);
-
- void (*watchdog) (struct rt2x00_dev *rt2x00dev);
- void (*start_queue) (struct data_queue *queue);
- void (*kick_queue) (struct data_queue *queue);
- void (*stop_queue) (struct data_queue *queue);
- void (*flush_queue) (struct data_queue *queue, bool drop);
- void (*tx_dma_done) (struct queue_entry *entry);
-
- void (*write_tx_desc) (struct queue_entry *entry,
- struct txentry_desc *txdesc);
- void (*write_tx_data) (struct queue_entry *entry,
- struct txentry_desc *txdesc);
- void (*write_beacon) (struct queue_entry *entry,
- struct txentry_desc *txdesc);
- void (*clear_beacon) (struct queue_entry *entry);
- int (*get_tx_data_len) (struct queue_entry *entry);
-
- void (*fill_rxdone) (struct queue_entry *entry,
- struct rxdone_entry_desc *rxdesc);
-
- int (*config_shared_key) (struct rt2x00_dev *rt2x00dev,
- struct rt2x00lib_crypto *crypto,
- struct ieee80211_key_conf *key);
- int (*config_pairwise_key) (struct rt2x00_dev *rt2x00dev,
- struct rt2x00lib_crypto *crypto,
- struct ieee80211_key_conf *key);
- void (*config_filter) (struct rt2x00_dev *rt2x00dev,
- const unsigned int filter_flags);
- void (*config_intf) (struct rt2x00_dev *rt2x00dev,
- struct rt2x00_intf *intf,
- struct rt2x00intf_conf *conf,
- const unsigned int flags);
- #define CONFIG_UPDATE_TYPE ( 1 << 1 )
- #define CONFIG_UPDATE_MAC ( 1 << 2 )
- #define CONFIG_UPDATE_BSSID ( 1 << 3 )
- void (*config_erp) (struct rt2x00_dev *rt2x00dev,
- struct rt2x00lib_erp *erp,
- u32 changed);
- void (*config_ant) (struct rt2x00_dev *rt2x00dev,
- struct antenna_setup *ant);
- void (*config) (struct rt2x00_dev *rt2x00dev,
- struct rt2x00lib_conf *libconf,
- const unsigned int changed_flags);
- int (*sta_add) (struct rt2x00_dev *rt2x00dev,
- struct ieee80211_vif *vif,
- struct ieee80211_sta *sta);
- int (*sta_remove) (struct rt2x00_dev *rt2x00dev,
- int wcid);
- };
- struct rt2x00_ops {
- const char *name;
- const unsigned int drv_data_size;
- const unsigned int max_ap_intf;
- const unsigned int eeprom_size;
- const unsigned int rf_size;
- const unsigned int tx_queues;
- void (*queue_init)(struct data_queue *queue);
- const struct rt2x00lib_ops *lib;
- const void *drv;
- const struct ieee80211_ops *hw;
- #ifdef CONFIG_RT2X00_LIB_DEBUGFS
- const struct rt2x00debug *debugfs;
- #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
- };
- enum rt2x00_state_flags {
-
- DEVICE_STATE_PRESENT,
- DEVICE_STATE_REGISTERED_HW,
- DEVICE_STATE_INITIALIZED,
- DEVICE_STATE_STARTED,
- DEVICE_STATE_ENABLED_RADIO,
- DEVICE_STATE_SCANNING,
-
- CONFIG_CHANNEL_HT40,
- CONFIG_POWERSAVING,
- CONFIG_HT_DISABLED,
- CONFIG_QOS_DISABLED,
- CONFIG_MONITORING,
-
- TX_STATUS_READING,
- };
- enum rt2x00_capability_flags {
-
- REQUIRE_FIRMWARE,
- REQUIRE_BEACON_GUARD,
- REQUIRE_ATIM_QUEUE,
- REQUIRE_DMA,
- REQUIRE_COPY_IV,
- REQUIRE_L2PAD,
- REQUIRE_TXSTATUS_FIFO,
- REQUIRE_TASKLET_CONTEXT,
- REQUIRE_SW_SEQNO,
- REQUIRE_HT_TX_DESC,
- REQUIRE_PS_AUTOWAKE,
- REQUIRE_DELAYED_RFKILL,
-
- CAPABILITY_HW_BUTTON,
- CAPABILITY_HW_CRYPTO,
- CAPABILITY_POWER_LIMIT,
- CAPABILITY_CONTROL_FILTERS,
- CAPABILITY_CONTROL_FILTER_PSPOLL,
- CAPABILITY_PRE_TBTT_INTERRUPT,
- CAPABILITY_LINK_TUNING,
- CAPABILITY_FRAME_TYPE,
- CAPABILITY_RF_SEQUENCE,
- CAPABILITY_EXTERNAL_LNA_A,
- CAPABILITY_EXTERNAL_LNA_BG,
- CAPABILITY_DOUBLE_ANTENNA,
- CAPABILITY_BT_COEXIST,
- CAPABILITY_VCO_RECALIBRATION,
- };
- enum {
- IF_COMB_AP = 0,
- NUM_IF_COMB,
- };
- struct rt2x00_dev {
-
- struct device *dev;
-
- const struct rt2x00_ops *ops;
-
- void *drv_data;
-
- struct ieee80211_hw *hw;
- struct ieee80211_supported_band bands[NUM_NL80211_BANDS];
- enum nl80211_band curr_band;
- int curr_freq;
-
- #ifdef CONFIG_RT2X00_LIB_DEBUGFS
- struct rt2x00debug_intf *debugfs_intf;
- #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
-
- #ifdef CONFIG_RT2X00_LIB_LEDS
- struct rt2x00_led led_radio;
- struct rt2x00_led led_assoc;
- struct rt2x00_led led_qual;
- u16 led_mcu_reg;
- #endif /* CONFIG_RT2X00_LIB_LEDS */
-
- unsigned long flags;
-
- unsigned long cap_flags;
-
- int irq;
- const char *name;
-
- struct rt2x00_chip chip;
-
- struct hw_mode_spec spec;
-
- struct antenna_setup default_ant;
-
- union csr {
- void __iomem *base;
- void *cache;
- } csr;
-
- struct mutex csr_mutex;
-
- unsigned int packet_filter;
-
- unsigned int intf_ap_count;
- unsigned int intf_sta_count;
- unsigned int intf_associated;
- unsigned int intf_beaconing;
-
- struct ieee80211_iface_limit if_limits_ap;
- struct ieee80211_iface_combination if_combinations[NUM_IF_COMB];
-
- struct link link;
-
- __le16 *eeprom;
-
- u32 *rf;
-
- short lna_gain;
-
- u16 tx_power;
-
- u8 short_retry;
- u8 long_retry;
-
- u8 rssi_offset;
-
- u8 freq_offset;
-
- u16 aid;
-
- u16 beacon_int;
-
- unsigned long last_beacon;
-
- struct ieee80211_low_level_stats low_level_stats;
-
- struct workqueue_struct *workqueue;
-
- struct work_struct intf_work;
-
- struct work_struct rxdone_work;
- struct work_struct txdone_work;
-
- struct delayed_work autowakeup_work;
- struct work_struct sleep_work;
-
- unsigned int data_queues;
- struct data_queue *rx;
- struct data_queue *tx;
- struct data_queue *bcn;
- struct data_queue *atim;
-
- const struct firmware *fw;
-
- DECLARE_KFIFO_PTR(txstatus_fifo, u32);
-
- struct hrtimer txstatus_timer;
-
- struct tasklet_struct txstatus_tasklet;
- struct tasklet_struct pretbtt_tasklet;
- struct tasklet_struct tbtt_tasklet;
- struct tasklet_struct rxdone_tasklet;
- struct tasklet_struct autowake_tasklet;
-
- int rf_channel;
-
- spinlock_t irqmask_lock;
-
- struct list_head bar_list;
- spinlock_t bar_list_lock;
-
- unsigned int extra_tx_headroom;
- struct usb_anchor *anchor;
- };
- struct rt2x00_bar_list_entry {
- struct list_head list;
- struct rcu_head head;
- struct queue_entry *entry;
- int block_acked;
-
- __u8 ra[6];
- __u8 ta[6];
- __le16 control;
- __le16 start_seq_num;
- };
- #define REGISTER_BUSY_COUNT 100
- #define REGISTER_USB_BUSY_COUNT 20
- #define REGISTER_BUSY_DELAY 100
- static inline void rt2x00_rf_read(struct rt2x00_dev *rt2x00dev,
- const unsigned int word, u32 *data)
- {
- BUG_ON(word < 1 || word > rt2x00dev->ops->rf_size / sizeof(u32));
- *data = rt2x00dev->rf[word - 1];
- }
- static inline void rt2x00_rf_write(struct rt2x00_dev *rt2x00dev,
- const unsigned int word, u32 data)
- {
- BUG_ON(word < 1 || word > rt2x00dev->ops->rf_size / sizeof(u32));
- rt2x00dev->rf[word - 1] = data;
- }
- static inline void *rt2x00_eeprom_addr(struct rt2x00_dev *rt2x00dev,
- const unsigned int word)
- {
- return (void *)&rt2x00dev->eeprom[word];
- }
- static inline void rt2x00_eeprom_read(struct rt2x00_dev *rt2x00dev,
- const unsigned int word, u16 *data)
- {
- *data = le16_to_cpu(rt2x00dev->eeprom[word]);
- }
- static inline void rt2x00_eeprom_write(struct rt2x00_dev *rt2x00dev,
- const unsigned int word, u16 data)
- {
- rt2x00dev->eeprom[word] = cpu_to_le16(data);
- }
- static inline u8 rt2x00_eeprom_byte(struct rt2x00_dev *rt2x00dev,
- const unsigned int byte)
- {
- return *(((u8 *)rt2x00dev->eeprom) + byte);
- }
- static inline void rt2x00_set_chip(struct rt2x00_dev *rt2x00dev,
- const u16 rt, const u16 rf, const u16 rev)
- {
- rt2x00dev->chip.rt = rt;
- rt2x00dev->chip.rf = rf;
- rt2x00dev->chip.rev = rev;
- rt2x00_info(rt2x00dev, "Chipset detected - rt: %04x, rf: %04x, rev: %04x\n",
- rt2x00dev->chip.rt, rt2x00dev->chip.rf,
- rt2x00dev->chip.rev);
- }
- static inline void rt2x00_set_rt(struct rt2x00_dev *rt2x00dev,
- const u16 rt, const u16 rev)
- {
- rt2x00dev->chip.rt = rt;
- rt2x00dev->chip.rev = rev;
- rt2x00_info(rt2x00dev, "RT chipset %04x, rev %04x detected\n",
- rt2x00dev->chip.rt, rt2x00dev->chip.rev);
- }
- static inline void rt2x00_set_rf(struct rt2x00_dev *rt2x00dev, const u16 rf)
- {
- rt2x00dev->chip.rf = rf;
- rt2x00_info(rt2x00dev, "RF chipset %04x detected\n",
- rt2x00dev->chip.rf);
- }
- static inline bool rt2x00_rt(struct rt2x00_dev *rt2x00dev, const u16 rt)
- {
- return (rt2x00dev->chip.rt == rt);
- }
- static inline bool rt2x00_rf(struct rt2x00_dev *rt2x00dev, const u16 rf)
- {
- return (rt2x00dev->chip.rf == rf);
- }
- static inline u16 rt2x00_rev(struct rt2x00_dev *rt2x00dev)
- {
- return rt2x00dev->chip.rev;
- }
- static inline bool rt2x00_rt_rev(struct rt2x00_dev *rt2x00dev,
- const u16 rt, const u16 rev)
- {
- return (rt2x00_rt(rt2x00dev, rt) && rt2x00_rev(rt2x00dev) == rev);
- }
- static inline bool rt2x00_rt_rev_lt(struct rt2x00_dev *rt2x00dev,
- const u16 rt, const u16 rev)
- {
- return (rt2x00_rt(rt2x00dev, rt) && rt2x00_rev(rt2x00dev) < rev);
- }
- static inline bool rt2x00_rt_rev_gte(struct rt2x00_dev *rt2x00dev,
- const u16 rt, const u16 rev)
- {
- return (rt2x00_rt(rt2x00dev, rt) && rt2x00_rev(rt2x00dev) >= rev);
- }
- static inline void rt2x00_set_chip_intf(struct rt2x00_dev *rt2x00dev,
- enum rt2x00_chip_intf intf)
- {
- rt2x00dev->chip.intf = intf;
- }
- static inline bool rt2x00_intf(struct rt2x00_dev *rt2x00dev,
- enum rt2x00_chip_intf intf)
- {
- return (rt2x00dev->chip.intf == intf);
- }
- static inline bool rt2x00_is_pci(struct rt2x00_dev *rt2x00dev)
- {
- return rt2x00_intf(rt2x00dev, RT2X00_CHIP_INTF_PCI) ||
- rt2x00_intf(rt2x00dev, RT2X00_CHIP_INTF_PCIE);
- }
- static inline bool rt2x00_is_pcie(struct rt2x00_dev *rt2x00dev)
- {
- return rt2x00_intf(rt2x00dev, RT2X00_CHIP_INTF_PCIE);
- }
- static inline bool rt2x00_is_usb(struct rt2x00_dev *rt2x00dev)
- {
- return rt2x00_intf(rt2x00dev, RT2X00_CHIP_INTF_USB);
- }
- static inline bool rt2x00_is_soc(struct rt2x00_dev *rt2x00dev)
- {
- return rt2x00_intf(rt2x00dev, RT2X00_CHIP_INTF_SOC);
- }
- static inline bool
- rt2x00_has_cap_flag(struct rt2x00_dev *rt2x00dev,
- enum rt2x00_capability_flags cap_flag)
- {
- return test_bit(cap_flag, &rt2x00dev->cap_flags);
- }
- static inline bool
- rt2x00_has_cap_hw_crypto(struct rt2x00_dev *rt2x00dev)
- {
- return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_HW_CRYPTO);
- }
- static inline bool
- rt2x00_has_cap_power_limit(struct rt2x00_dev *rt2x00dev)
- {
- return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_POWER_LIMIT);
- }
- static inline bool
- rt2x00_has_cap_control_filters(struct rt2x00_dev *rt2x00dev)
- {
- return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_CONTROL_FILTERS);
- }
- static inline bool
- rt2x00_has_cap_control_filter_pspoll(struct rt2x00_dev *rt2x00dev)
- {
- return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_CONTROL_FILTER_PSPOLL);
- }
- static inline bool
- rt2x00_has_cap_pre_tbtt_interrupt(struct rt2x00_dev *rt2x00dev)
- {
- return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_PRE_TBTT_INTERRUPT);
- }
- static inline bool
- rt2x00_has_cap_link_tuning(struct rt2x00_dev *rt2x00dev)
- {
- return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_LINK_TUNING);
- }
- static inline bool
- rt2x00_has_cap_frame_type(struct rt2x00_dev *rt2x00dev)
- {
- return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_FRAME_TYPE);
- }
- static inline bool
- rt2x00_has_cap_rf_sequence(struct rt2x00_dev *rt2x00dev)
- {
- return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_RF_SEQUENCE);
- }
- static inline bool
- rt2x00_has_cap_external_lna_a(struct rt2x00_dev *rt2x00dev)
- {
- return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_EXTERNAL_LNA_A);
- }
- static inline bool
- rt2x00_has_cap_external_lna_bg(struct rt2x00_dev *rt2x00dev)
- {
- return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_EXTERNAL_LNA_BG);
- }
- static inline bool
- rt2x00_has_cap_double_antenna(struct rt2x00_dev *rt2x00dev)
- {
- return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_DOUBLE_ANTENNA);
- }
- static inline bool
- rt2x00_has_cap_bt_coexist(struct rt2x00_dev *rt2x00dev)
- {
- return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_BT_COEXIST);
- }
- static inline bool
- rt2x00_has_cap_vco_recalibration(struct rt2x00_dev *rt2x00dev)
- {
- return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_VCO_RECALIBRATION);
- }
- int rt2x00queue_map_txskb(struct queue_entry *entry);
- void rt2x00queue_unmap_skb(struct queue_entry *entry);
- static inline struct data_queue *
- rt2x00queue_get_tx_queue(struct rt2x00_dev *rt2x00dev,
- const enum data_queue_qid queue)
- {
- if (queue < rt2x00dev->ops->tx_queues && rt2x00dev->tx)
- return &rt2x00dev->tx[queue];
- if (queue == QID_ATIM)
- return rt2x00dev->atim;
- return NULL;
- }
- struct queue_entry *rt2x00queue_get_entry(struct data_queue *queue,
- enum queue_index index);
- void rt2x00queue_pause_queue(struct data_queue *queue);
- void rt2x00queue_unpause_queue(struct data_queue *queue);
- void rt2x00queue_start_queue(struct data_queue *queue);
- void rt2x00queue_stop_queue(struct data_queue *queue);
- void rt2x00queue_flush_queue(struct data_queue *queue, bool drop);
- void rt2x00queue_start_queues(struct rt2x00_dev *rt2x00dev);
- void rt2x00queue_stop_queues(struct rt2x00_dev *rt2x00dev);
- void rt2x00queue_flush_queues(struct rt2x00_dev *rt2x00dev, bool drop);
- #ifdef CONFIG_RT2X00_LIB_DEBUGFS
- void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev,
- enum rt2x00_dump_type type, struct sk_buff *skb);
- #else
- static inline void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev,
- enum rt2x00_dump_type type,
- struct sk_buff *skb)
- {
- }
- #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
- u32 rt2x00lib_get_bssidx(struct rt2x00_dev *rt2x00dev,
- struct ieee80211_vif *vif);
- void rt2x00lib_beacondone(struct rt2x00_dev *rt2x00dev);
- void rt2x00lib_pretbtt(struct rt2x00_dev *rt2x00dev);
- void rt2x00lib_dmastart(struct queue_entry *entry);
- void rt2x00lib_dmadone(struct queue_entry *entry);
- void rt2x00lib_txdone(struct queue_entry *entry,
- struct txdone_entry_desc *txdesc);
- void rt2x00lib_txdone_noinfo(struct queue_entry *entry, u32 status);
- void rt2x00lib_rxdone(struct queue_entry *entry, gfp_t gfp);
- void rt2x00mac_tx(struct ieee80211_hw *hw,
- struct ieee80211_tx_control *control,
- struct sk_buff *skb);
- int rt2x00mac_start(struct ieee80211_hw *hw);
- void rt2x00mac_stop(struct ieee80211_hw *hw);
- int rt2x00mac_add_interface(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif);
- void rt2x00mac_remove_interface(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif);
- int rt2x00mac_config(struct ieee80211_hw *hw, u32 changed);
- void rt2x00mac_configure_filter(struct ieee80211_hw *hw,
- unsigned int changed_flags,
- unsigned int *total_flags,
- u64 multicast);
- int rt2x00mac_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
- bool set);
- #ifdef CONFIG_RT2X00_LIB_CRYPTO
- int rt2x00mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
- struct ieee80211_vif *vif, struct ieee80211_sta *sta,
- struct ieee80211_key_conf *key);
- #else
- #define rt2x00mac_set_key NULL
- #endif /* CONFIG_RT2X00_LIB_CRYPTO */
- int rt2x00mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
- struct ieee80211_sta *sta);
- int rt2x00mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
- struct ieee80211_sta *sta);
- void rt2x00mac_sw_scan_start(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif,
- const u8 *mac_addr);
- void rt2x00mac_sw_scan_complete(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif);
- int rt2x00mac_get_stats(struct ieee80211_hw *hw,
- struct ieee80211_low_level_stats *stats);
- void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif,
- struct ieee80211_bss_conf *bss_conf,
- u32 changes);
- int rt2x00mac_conf_tx(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif, u16 queue,
- const struct ieee80211_tx_queue_params *params);
- void rt2x00mac_rfkill_poll(struct ieee80211_hw *hw);
- void rt2x00mac_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
- u32 queues, bool drop);
- int rt2x00mac_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant);
- int rt2x00mac_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant);
- void rt2x00mac_get_ringparam(struct ieee80211_hw *hw,
- u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max);
- bool rt2x00mac_tx_frames_pending(struct ieee80211_hw *hw);
- int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev);
- void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev);
- #ifdef CONFIG_PM
- int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev, pm_message_t state);
- int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev);
- #endif /* CONFIG_PM */
- #endif /* RT2X00_H */
|