33 #include <linux/netdevice.h> 34 #include <linux/wireless.h> 36 #include <rtnet_port.h> 44 #define DRV_NAME "rt2x00" 45 #define DRV_VERSION "0.1" 46 #define DRV_AUTHOR "Daniel Gregorek <dxg@gmx.de>" 55 #ifdef CONFIG_RT2X00_DEBUG 56 extern int rt2x00_debug_level;
57 #define DEBUG_PRINTK(__message...) \ 59 rtdm_printk(__message); \ 62 #define DEBUG_PRINTK(__message...) \ 72 #define PANIC(__message, __args...) \ 73 rtdm_printk(KERN_PANIC DRV_NAME "->%s: Panic - " __message, \ 74 __FUNCTION__, ##__args); 75 #define ERROR(__message, __args...) \ 76 rtdm_printk(KERN_ERR DRV_NAME "->%s: Error - " __message, \ 77 __FUNCTION__, ##__args); 78 #define WARNING(__message, __args...) \ 79 rtdm_printk(KERN_WARNING DRV_NAME "->%s: Warning - " __message, \ 80 __FUNCTION__, ##__args); 81 #define NOTICE(__message, __args...) \ 82 rtdm_printk(KERN_NOTICE DRV_NAME "->%s: Notice - " __message, \ 83 __FUNCTION__, ##__args); 84 #define INFO(__message, __args...) \ 85 rtdm_printk(KERN_INFO DRV_NAME "->%s: Info - " __message, \ 86 __FUNCTION__, ##__args); 87 #define DEBUG(__message, __args...) \ 88 DEBUG_PRINTK(KERN_DEBUG DRV_NAME "->%s: Debug - " __message, \ 89 __FUNCTION__, ##__args); 104 #define DATA_FRAME_SIZE 2432 105 #define MGMT_FRAME_SIZE 256 110 #define XMIT_IFS_SIFS 0x0001 111 #define XMIT_IFS_BACKOFF 0x0002 112 #define XMIT_IFS_NEW_BACKOFF 0x0004 113 #define XMIT_IFS_NONE 0x0008 114 #define XMIT_NEW_SEQUENCE 0x0010 115 #define XMIT_ACK 0x0020 116 #define XMIT_TIMESTAMP 0x0040 117 #define XMIT_RTS 0x0080 118 #define XMIT_OFDM 0x0100 119 #define XMIT_LONG_RETRY 0x0200 120 #define XMIT_MORE_FRAGS 0x0400 121 #define XMIT_SHORT_PREAMBLE 0x0800 122 #define XMIT_START 0x1000 127 #define STATS_TX_RESULT 0x01 128 #define STATS_TX_RETRY_COUNT 0x02 129 #define STATS_RX_CRC 0x10 130 #define STATS_RX_PHYSICAL 0x20 131 #define STATS_RX_QUALITY 0x40 132 #define STATS_RX_DROP 0x80 138 #define TX_SUCCESS_RETRY 1 139 #define TX_FAIL_RETRY 2 140 #define TX_FAIL_INVALID 3 141 #define TX_FAIL_OTHER 4 146 #define CHANNEL_OFDM 0x01 147 #define CHANNEL_UNII_LOW 0x02 148 #define CHANNEL_HIPERLAN2 0x04 149 #define CHANNEL_UNII_HIGH 0x08 151 #define CHANNEL_OFDM_MIN 1 152 #define CHANNEL_OFDM_MAX 14 153 #define CHANNEL_UNII_LOW_MIN 36 154 #define CHANNEL_UNII_LOW_MAX 64 155 #define CHANNEL_HIPERLAN2_MIN 100 156 #define CHANNEL_HIPERLAN2_MAX 140 157 #define CHANNEL_UNII_HIGH_MIN 149 158 #define CHANNEL_UNII_HIGH_MAX 161 163 static struct _rt2x00_capabilities {
171 3, 12, 25, 50, 75, 100,
179 12, 18, 24, 36, 48, 72, 96, 108,
183 struct _rt2x00_config {
185 #define CONFIG_DROP_BCAST 0x0001 186 #define CONFIG_DROP_MCAST 0x0002 187 #define CONFIG_AUTORESP 0x0004 220 #define UPDATE_ALL_CONFIG 0xffff 221 #define UPDATE_BSSID 0x0001 222 #define UPDATE_PACKET_FILTER 0x0002 223 #define UPDATE_CHANNEL 0x0004 224 #define UPDATE_BITRATE 0x0008 225 #define UPDATE_RETRY 0x0010 226 #define UPDATE_TXPOWER 0x0020 227 #define UPDATE_ANTENNA 0x0040 228 #define UPDATE_DURATION 0x0080 229 #define UPDATE_PREAMBLE 0x0100 230 #define UPDATE_AUTORESP 0x0200 231 #define UPDATE_LED_STATUS 0x0400 232 #define UPDATE_BBPSENS 0x0800 236 struct _rt2x00_core {
242 #define DEVICE_ENABLED 0 243 #define DEVICE_AWAKE 1 244 #define DEVICE_RADIO_ON 2 245 #define DEVICE_CONFIG_UPDATE 3 250 struct _rt2x00_dev_handler *handler;
255 struct rtnet_device *rtnet_dev;
260 struct rtwlan_device *rtwlan_dev;
265 struct _rt2x00_config config;
274 struct _rt2x00_dev_handler {
278 struct module *dev_module;
283 int (*dev_probe)(
struct _rt2x00_core *core,
void *priv);
284 int (*dev_remove)(
struct _rt2x00_core *core);
289 int (*dev_radio_on)(
struct _rt2x00_core *core);
290 int (*dev_radio_off)(
struct _rt2x00_core *core);
295 int (*dev_update_config)(
struct _rt2x00_core *core, u16 update_flags);
300 int (*dev_xmit_packet)(
struct _rt2x00_core *core,
struct rtskb *rtskb,
301 u16 rate, u16 xmit_flags);
306 int (*dev_register_access)(
struct _rt2x00_core *core,
int request,
307 u32 address, u32 *value);
311 static inline void *rt2x00_priv(
const struct _rt2x00_core *core)
323 #define IEEE80211_HEADER 24 325 static inline u16 get_duration(
const unsigned int size,
const u8 rate)
327 return ((size * 8 * 2) / rate);
330 static inline u16 get_duration_res(
const unsigned int size,
const u8 rate)
332 return ((size * 8 * 2) % rate);
335 static inline u16 get_preamble(
const struct _rt2x00_config *config)
346 struct _rt2x00_field16 {
351 struct _rt2x00_field32 {
356 #define FIELD16(__offset, __mask) \ 357 ((struct _rt2x00_field16){ (__offset), (__mask) }) 358 #define FIELD32(__offset, __mask) \ 359 ((struct _rt2x00_field32){ (__offset), (__mask) }) 361 static inline void rt2x00_set_field32(u32 *reg,
362 const struct _rt2x00_field32 field,
365 *reg &= cpu_to_le32(~(field.bit_mask));
366 *reg |= cpu_to_le32((value << field.bit_offset) & field.bit_mask);
369 static inline void rt2x00_set_field32_nb(u32 *reg,
370 const struct _rt2x00_field32 field,
373 *reg &= ~(field.bit_mask);
374 *reg |= (value << field.bit_offset) & field.bit_mask;
377 static inline u32 rt2x00_get_field32(
const u32 reg,
378 const struct _rt2x00_field32 field)
380 return (le32_to_cpu(reg) & field.bit_mask) >> field.bit_offset;
383 static inline u32 rt2x00_get_field32_nb(
const u32 reg,
384 const struct _rt2x00_field32 field)
386 return (reg & field.bit_mask) >> field.bit_offset;
389 static inline void rt2x00_set_field16(u16 *reg,
390 const struct _rt2x00_field16 field,
393 *reg &= cpu_to_le16(~(field.bit_mask));
394 *reg |= cpu_to_le16((value << field.bit_offset) & field.bit_mask);
397 static inline void rt2x00_set_field16_nb(u16 *reg,
398 const struct _rt2x00_field16 field,
401 *reg &= ~(field.bit_mask);
402 *reg |= (value << field.bit_offset) & field.bit_mask;
405 static inline u16 rt2x00_get_field16(
const u16 reg,
406 const struct _rt2x00_field16 field)
408 return (le16_to_cpu(reg) & field.bit_mask) >> field.bit_offset;
411 static inline u16 rt2x00_get_field16_nb(
const u16 reg,
412 const struct _rt2x00_field16 field)
414 return (reg & field.bit_mask) >> field.bit_offset;
432 struct _rt2x00_chip {
442 static inline void set_chip(
struct _rt2x00_chip *chipset,
const u16 rt,
445 INFO(
"Chipset detected - rt: %04x, rf: %04x.\n", rt, rf);
448 chipset->rf = rf | (chipset->rt & 0xff00);
451 static inline char rt2x00_rt(
const struct _rt2x00_chip *chipset,
const u16 chip)
453 return (chipset->rt == chip);
456 static inline char rt2x00_rf(
const struct _rt2x00_chip *chipset,
const u16 chip)
458 return (chipset->rf == chip);
461 static inline u16 rt2x00_get_rf(
const struct _rt2x00_chip *chipset)
485 struct _rt2x00_core *core;
520 #define ATIM_ENTRIES 1 521 #define PRIO_ENTRIES 2 522 #define BEACON_ENTRIES 1 527 static inline void rt2x00_init_ring(
struct _rt2x00_core *core,
528 struct _data_ring *ring,
const u8 ring_type,
529 const u16 max_entries,
const u16 entry_size,
534 ring->index_done = 0;
535 ring->ring_type = ring_type;
536 ring->max_entries = max_entries;
537 ring->entry_size = entry_size;
538 ring->desc_size = desc_size;
540 ring->max_entries * (ring->desc_size + ring->entry_size);
543 static inline void rt2x00_deinit_ring(
struct _data_ring *ring)
547 ring->index_done = 0;
549 ring->max_entries = 0;
550 ring->entry_size = 0;
558 static inline void rt2x00_ring_index_inc(
struct _data_ring *ring)
560 ring->index = (++ring->index < ring->max_entries) ? ring->index : 0;
563 static inline void rt2x00_ring_index_done_inc(
struct _data_ring *ring)
566 (++ring->index_done < ring->max_entries) ? ring->index_done : 0;
569 static inline void rt2x00_ring_clear_index(
struct _data_ring *ring)
572 ring->index_done = 0;
575 static inline u8 rt2x00_ring_empty(
struct _data_ring *ring)
577 return ring->index_done == ring->index;
580 static inline u8 rt2x00_ring_free_entries(
struct _data_ring *ring)
582 if (ring->index >= ring->index_done)
583 return ring->max_entries - (ring->index - ring->index_done);
585 return ring->index_done - ring->index;
592 static inline u8 rt2x00_get_plcp(
const u8 rate)
596 0x00, 0x01, 0x02, 0x03,
597 0x0b, 0x0f, 0x0a, 0x0e, 0x09, 0x0d, 0x08, 0x0c,
600 for (; counter < 12; counter++) {
601 if (capabilities.bitrate[counter] == rate)
602 return plcp[counter];
608 #define OFDM_CHANNEL(__channel) \ 609 ((__channel) >= CHANNEL_OFDM_MIN && (__channel) <= CHANNEL_OFDM_MAX) 610 #define UNII_LOW_CHANNEL(__channel) \ 611 ((__channel) >= CHANNEL_UNII_LOW_MIN && \ 612 (__channel) <= CHANNEL_UNII_LOW_MAX) 613 #define HIPERLAN2_CHANNEL(__channel) \ 614 ((__channel) >= CHANNEL_HIPERLAN2_MIN && \ 615 (__channel) <= CHANNEL_HIPERLAN2_MAX) 616 #define UNII_HIGH_CHANNEL(__channel) \ 617 ((__channel) >= CHANNEL_UNII_HIGH_MIN && \ 618 (__channel) <= CHANNEL_UNII_HIGH_MAX) 624 static inline int rt2x00_get_channel_index(
const u8 channel)
626 if (OFDM_CHANNEL(channel))
627 return (channel - 1);
632 if (UNII_LOW_CHANNEL(channel))
633 return ((channel - CHANNEL_UNII_LOW_MIN) / 4);
634 else if (HIPERLAN2_CHANNEL(channel))
635 return ((channel - CHANNEL_HIPERLAN2_MIN) / 4);
636 else if (UNII_HIGH_CHANNEL(channel))
637 return ((channel - CHANNEL_UNII_HIGH_MIN) / 4);
644 extern struct rtnet_device *
645 rt2x00_core_probe(
struct _rt2x00_dev_handler *handler,
void *priv,
647 extern void rt2x00_core_remove(
struct rtnet_device *rtnet_dev);
static int __attribute__((cold))
Test if a mutex structure contains a valid autoinitializer.
Definition: mutex.c:177