1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#define AR5523_FLAG_PRE_FIRMWARE (1 << 0)
22#define AR5523_FLAG_ABG (1 << 1)
23
24#define AR5523_FIRMWARE_FILE "ar5523.bin"
25
26#define AR5523_CMD_TX_PIPE 0x01
27#define AR5523_DATA_TX_PIPE 0x02
28#define AR5523_CMD_RX_PIPE 0x81
29#define AR5523_DATA_RX_PIPE 0x82
30
31#define ar5523_cmd_tx_pipe(dev) \
32 usb_sndbulkpipe((dev), AR5523_CMD_TX_PIPE)
33#define ar5523_data_tx_pipe(dev) \
34 usb_sndbulkpipe((dev), AR5523_DATA_TX_PIPE)
35#define ar5523_cmd_rx_pipe(dev) \
36 usb_rcvbulkpipe((dev), AR5523_CMD_RX_PIPE)
37#define ar5523_data_rx_pipe(dev) \
38 usb_rcvbulkpipe((dev), AR5523_DATA_RX_PIPE)
39
40#define AR5523_DATA_TIMEOUT 10000
41#define AR5523_CMD_TIMEOUT 1000
42
43#define AR5523_TX_DATA_COUNT 8
44#define AR5523_TX_DATA_RESTART_COUNT 2
45#define AR5523_RX_DATA_COUNT 16
46#define AR5523_RX_DATA_REFILL_COUNT 8
47
48#define AR5523_CMD_ID 1
49#define AR5523_DATA_ID 2
50
51#define AR5523_TX_WD_TIMEOUT (HZ * 2)
52#define AR5523_FLUSH_TIMEOUT (HZ * 3)
53
54enum AR5523_flags {
55 AR5523_HW_UP,
56 AR5523_USB_DISCONNECTED,
57 AR5523_CONNECTED
58};
59
60struct ar5523_tx_cmd {
61 struct ar5523 *ar;
62 struct urb *urb_tx;
63 void *buf_tx;
64 void *odata;
65 int olen;
66 int flags;
67 int res;
68 struct completion done;
69};
70
71
72
73
74struct ar5523_tx_data {
75 struct list_head list;
76 struct ar5523 *ar;
77 struct sk_buff *skb;
78 struct urb *urb;
79};
80
81struct ar5523_rx_data {
82 struct list_head list;
83 struct ar5523 *ar;
84 struct urb *urb;
85 struct sk_buff *skb;
86};
87
88struct ar5523 {
89 struct usb_device *dev;
90 struct ieee80211_hw *hw;
91
92 unsigned long flags;
93 struct mutex mutex;
94 struct workqueue_struct *wq;
95
96 struct ar5523_tx_cmd tx_cmd;
97
98 struct delayed_work stat_work;
99
100 struct timer_list tx_wd_timer;
101 struct work_struct tx_wd_work;
102 struct work_struct tx_work;
103 struct list_head tx_queue_pending;
104 struct list_head tx_queue_submitted;
105 spinlock_t tx_data_list_lock;
106 wait_queue_head_t tx_flush_waitq;
107
108
109 atomic_t tx_nr_total;
110
111
112 atomic_t tx_nr_pending;
113
114 void *rx_cmd_buf;
115 struct urb *rx_cmd_urb;
116
117 struct ar5523_rx_data rx_data[AR5523_RX_DATA_COUNT];
118 spinlock_t rx_data_list_lock;
119 struct list_head rx_data_free;
120 struct list_head rx_data_used;
121 atomic_t rx_data_free_cnt;
122
123 struct work_struct rx_refill_work;
124
125 unsigned int rxbufsz;
126 u8 serial[16];
127
128 struct ieee80211_channel channels[14];
129 struct ieee80211_rate rates[12];
130 struct ieee80211_supported_band band;
131 struct ieee80211_vif *vif;
132};
133
134
135#define AR5523_CMD_FLAG_READ (1 << 1)
136#define AR5523_CMD_FLAG_MAGIC (1 << 2)
137
138#define ar5523_dbg(ar, format, arg...) \
139 dev_dbg(&(ar)->dev->dev, format, ## arg)
140
141
142
143
144
145#define ar5523_err(ar, format, arg...) \
146do { \
147 if (!test_bit(AR5523_USB_DISCONNECTED, &ar->flags)) { \
148 dev_err(&(ar)->dev->dev, format, ## arg); \
149 } \
150} while (0)
151#define ar5523_info(ar, format, arg...) \
152 dev_info(&(ar)->dev->dev, format, ## arg)
153