aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2x00.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2x00.h')
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h133
1 files changed, 54 insertions, 79 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index 86e4624a63ea..7b67f9666c3b 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -27,7 +27,6 @@
27#define RT2X00_H 27#define RT2X00_H
28 28
29#include <linux/bitops.h> 29#include <linux/bitops.h>
30#include <linux/prefetch.h>
31#include <linux/skbuff.h> 30#include <linux/skbuff.h>
32#include <linux/workqueue.h> 31#include <linux/workqueue.h>
33#include <linux/firmware.h> 32#include <linux/firmware.h>
@@ -38,7 +37,7 @@
38 37
39#include "rt2x00debug.h" 38#include "rt2x00debug.h"
40#include "rt2x00reg.h" 39#include "rt2x00reg.h"
41#include "rt2x00ring.h" 40#include "rt2x00queue.h"
42 41
43/* 42/*
44 * Module information. 43 * Module information.
@@ -91,26 +90,6 @@
91 DEBUG_PRINTK(__dev, KERN_DEBUG, "EEPROM recovery", __msg, ##__args) 90 DEBUG_PRINTK(__dev, KERN_DEBUG, "EEPROM recovery", __msg, ##__args)
92 91
93/* 92/*
94 * Ring sizes.
95 * Ralink PCI devices demand the Frame size to be a multiple of 128 bytes.
96 * DATA_FRAME_SIZE is used for TX, RX, ATIM and PRIO rings.
97 * MGMT_FRAME_SIZE is used for the BEACON ring.
98 */
99#define DATA_FRAME_SIZE 2432
100#define MGMT_FRAME_SIZE 256
101
102/*
103 * Number of entries in a packet ring.
104 * PCI devices only need 1 Beacon entry,
105 * but USB devices require a second because they
106 * have to send a Guardian byte first.
107 */
108#define RX_ENTRIES 12
109#define TX_ENTRIES 12
110#define ATIM_ENTRIES 1
111#define BEACON_ENTRIES 2
112
113/*
114 * Standard timing and size defines. 93 * Standard timing and size defines.
115 * These values should follow the ieee80211 specifications. 94 * These values should follow the ieee80211 specifications.
116 */ 95 */
@@ -474,12 +453,12 @@ struct rt2x00lib_ops {
474 void (*uninitialize) (struct rt2x00_dev *rt2x00dev); 453 void (*uninitialize) (struct rt2x00_dev *rt2x00dev);
475 454
476 /* 455 /*
477 * Ring initialization handlers 456 * queue initialization handlers
478 */ 457 */
479 void (*init_rxentry) (struct rt2x00_dev *rt2x00dev, 458 void (*init_rxentry) (struct rt2x00_dev *rt2x00dev,
480 struct data_entry *entry); 459 struct queue_entry *entry);
481 void (*init_txentry) (struct rt2x00_dev *rt2x00dev, 460 void (*init_txentry) (struct rt2x00_dev *rt2x00dev,
482 struct data_entry *entry); 461 struct queue_entry *entry);
483 462
484 /* 463 /*
485 * Radio control handlers. 464 * Radio control handlers.
@@ -497,10 +476,10 @@ struct rt2x00lib_ops {
497 */ 476 */
498 void (*write_tx_desc) (struct rt2x00_dev *rt2x00dev, 477 void (*write_tx_desc) (struct rt2x00_dev *rt2x00dev,
499 struct sk_buff *skb, 478 struct sk_buff *skb,
500 struct txdata_entry_desc *desc, 479 struct txentry_desc *txdesc,
501 struct ieee80211_tx_control *control); 480 struct ieee80211_tx_control *control);
502 int (*write_tx_data) (struct rt2x00_dev *rt2x00dev, 481 int (*write_tx_data) (struct rt2x00_dev *rt2x00dev,
503 struct data_ring *ring, struct sk_buff *skb, 482 struct data_queue *queue, struct sk_buff *skb,
504 struct ieee80211_tx_control *control); 483 struct ieee80211_tx_control *control);
505 int (*get_tx_data_len) (struct rt2x00_dev *rt2x00dev, 484 int (*get_tx_data_len) (struct rt2x00_dev *rt2x00dev,
506 struct sk_buff *skb); 485 struct sk_buff *skb);
@@ -510,8 +489,8 @@ struct rt2x00lib_ops {
510 /* 489 /*
511 * RX control handlers 490 * RX control handlers
512 */ 491 */
513 void (*fill_rxdone) (struct data_entry *entry, 492 void (*fill_rxdone) (struct queue_entry *entry,
514 struct rxdata_entry_desc *desc); 493 struct rxdone_entry_desc *rxdesc);
515 494
516 /* 495 /*
517 * Configuration handlers. 496 * Configuration handlers.
@@ -540,10 +519,12 @@ struct rt2x00lib_ops {
540 */ 519 */
541struct rt2x00_ops { 520struct rt2x00_ops {
542 const char *name; 521 const char *name;
543 const unsigned int rxd_size;
544 const unsigned int txd_size;
545 const unsigned int eeprom_size; 522 const unsigned int eeprom_size;
546 const unsigned int rf_size; 523 const unsigned int rf_size;
524 const struct data_queue_desc *rx;
525 const struct data_queue_desc *tx;
526 const struct data_queue_desc *bcn;
527 const struct data_queue_desc *atim;
547 const struct rt2x00lib_ops *lib; 528 const struct rt2x00lib_ops *lib;
548 const struct ieee80211_ops *hw; 529 const struct ieee80211_ops *hw;
549#ifdef CONFIG_RT2X00_LIB_DEBUGFS 530#ifdef CONFIG_RT2X00_LIB_DEBUGFS
@@ -570,7 +551,8 @@ enum rt2x00_flags {
570 * Driver features 551 * Driver features
571 */ 552 */
572 DRIVER_REQUIRE_FIRMWARE, 553 DRIVER_REQUIRE_FIRMWARE,
573 DRIVER_REQUIRE_BEACON_RING, 554 DRIVER_REQUIRE_BEACON_GUARD,
555 DRIVER_REQUIRE_ATIM_QUEUE,
574 556
575 /* 557 /*
576 * Driver configuration 558 * Driver configuration
@@ -597,8 +579,10 @@ struct rt2x00_dev {
597 * macro's should be used for correct typecasting. 579 * macro's should be used for correct typecasting.
598 */ 580 */
599 void *dev; 581 void *dev;
600#define rt2x00dev_pci(__dev) ( (struct pci_dev*)(__dev)->dev ) 582#define rt2x00dev_pci(__dev) ( (struct pci_dev *)(__dev)->dev )
601#define rt2x00dev_usb(__dev) ( (struct usb_interface*)(__dev)->dev ) 583#define rt2x00dev_usb(__dev) ( (struct usb_interface *)(__dev)->dev )
584#define rt2x00dev_usb_dev(__dev)\
585 ( (struct usb_device *)interface_to_usbdev(rt2x00dev_usb(__dev)) )
602 586
603 /* 587 /*
604 * Callback functions. 588 * Callback functions.
@@ -757,14 +741,14 @@ struct rt2x00_dev {
757 struct work_struct config_work; 741 struct work_struct config_work;
758 742
759 /* 743 /*
760 * Data ring arrays for RX, TX and Beacon. 744 * Data queue arrays for RX, TX and Beacon.
761 * The Beacon array also contains the Atim ring 745 * The Beacon array also contains the Atim queue
762 * if that is supported by the device. 746 * if that is supported by the device.
763 */ 747 */
764 int data_rings; 748 int data_queues;
765 struct data_ring *rx; 749 struct data_queue *rx;
766 struct data_ring *tx; 750 struct data_queue *tx;
767 struct data_ring *bcn; 751 struct data_queue *bcn;
768 752
769 /* 753 /*
770 * Firmware image. 754 * Firmware image.
@@ -773,37 +757,6 @@ struct rt2x00_dev {
773}; 757};
774 758
775/* 759/*
776 * For-each loop for the ring array.
777 * All rings have been allocated as a single array,
778 * this means we can create a very simply loop macro
779 * that is capable of looping through all rings.
780 * ring_end(), txring_end() and ring_loop() are helper macro's which
781 * should not be used directly. Instead the following should be used:
782 * ring_for_each() - Loops through all rings (RX, TX, Beacon & Atim)
783 * txring_for_each() - Loops through TX data rings (TX only)
784 * txringall_for_each() - Loops through all TX rings (TX, Beacon & Atim)
785 */
786#define ring_end(__dev) \
787 &(__dev)->rx[(__dev)->data_rings]
788
789#define txring_end(__dev) \
790 &(__dev)->tx[(__dev)->hw->queues]
791
792#define ring_loop(__entry, __start, __end) \
793 for ((__entry) = (__start); \
794 prefetch(&(__entry)[1]), (__entry) != (__end); \
795 (__entry) = &(__entry)[1])
796
797#define ring_for_each(__dev, __entry) \
798 ring_loop(__entry, (__dev)->rx, ring_end(__dev))
799
800#define txring_for_each(__dev, __entry) \
801 ring_loop(__entry, (__dev)->tx, txring_end(__dev))
802
803#define txringall_for_each(__dev, __entry) \
804 ring_loop(__entry, (__dev)->tx, ring_end(__dev))
805
806/*
807 * Generic RF access. 760 * Generic RF access.
808 * The RF is being accessed by word index. 761 * The RF is being accessed by word index.
809 */ 762 */
@@ -895,20 +848,42 @@ static inline u16 get_duration_res(const unsigned int size, const u8 rate)
895 return ((size * 8 * 10) % rate); 848 return ((size * 8 * 10) % rate);
896} 849}
897 850
898/* 851/**
899 * Library functions. 852 * rt2x00queue_get_queue - Convert mac80211 queue index to rt2x00 queue
853 * @rt2x00dev: Pointer to &struct rt2x00_dev.
854 * @queue: mac80211 queue index (see &enum ieee80211_tx_queue).
900 */ 855 */
901struct data_ring *rt2x00lib_get_ring(struct rt2x00_dev *rt2x00dev, 856struct data_queue *rt2x00queue_get_queue(struct rt2x00_dev *rt2x00dev,
902 const unsigned int queue); 857 const enum ieee80211_tx_queue queue);
858
859/**
860 * rt2x00queue_get_entry - Get queue entry where the given index points to.
861 * @rt2x00dev: Pointer to &struct rt2x00_dev.
862 * @index: Index identifier for obtaining the correct index.
863 */
864struct queue_entry *rt2x00queue_get_entry(struct data_queue *queue,
865 enum queue_index index);
866
867/**
868 * rt2x00queue_index_inc - Index incrementation function
869 * @queue: Queue (&struct data_queue) to perform the action on.
870 * @action: Index type (&enum queue_index) to perform the action on.
871 *
872 * This function will increase the requested index on the queue,
873 * it will grab the appropriate locks and handle queue overflow events by
874 * resetting the index to the start of the queue.
875 */
876void rt2x00queue_index_inc(struct data_queue *queue, enum queue_index index);
877
903 878
904/* 879/*
905 * Interrupt context handlers. 880 * Interrupt context handlers.
906 */ 881 */
907void rt2x00lib_beacondone(struct rt2x00_dev *rt2x00dev); 882void rt2x00lib_beacondone(struct rt2x00_dev *rt2x00dev);
908void rt2x00lib_txdone(struct data_entry *entry, 883void rt2x00lib_txdone(struct queue_entry *entry,
909 const int status, const int retry); 884 struct txdone_entry_desc *txdesc);
910void rt2x00lib_rxdone(struct data_entry *entry, struct sk_buff *skb, 885void rt2x00lib_rxdone(struct queue_entry *entry,
911 struct rxdata_entry_desc *desc); 886 struct rxdone_entry_desc *rxdesc);
912 887
913/* 888/*
914 * TX descriptor initializer 889 * TX descriptor initializer