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
54 enum AR5523_flags {
55 AR5523_HW_UP,
56 AR5523_USB_DISCONNECTED,
57 AR5523_CONNECTED
58 };
59
60 struct 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
74 struct ar5523_tx_data {
75 struct list_head list;
76 struct ar5523 *ar;
77 struct urb *urb;
78 };
79
80 struct ar5523_rx_data {
81 struct list_head list;
82 struct ar5523 *ar;
83 struct urb *urb;
84 struct sk_buff *skb;
85 };
86
87 struct ar5523 {
88 struct usb_device *dev;
89 struct ieee80211_hw *hw;
90
91 unsigned long flags;
92 struct mutex mutex;
93 struct workqueue_struct *wq;
94
95 struct ar5523_tx_cmd tx_cmd;
96
97 struct delayed_work stat_work;
98
99 struct timer_list tx_wd_timer;
100 struct work_struct tx_wd_work;
101 struct work_struct tx_work;
102 struct list_head tx_queue_pending;
103 struct list_head tx_queue_submitted;
104 spinlock_t tx_data_list_lock;
105 wait_queue_head_t tx_flush_waitq;
106
107
108 atomic_t tx_nr_total;
109
110
111 atomic_t tx_nr_pending;
112
113 void *rx_cmd_buf;
114 struct urb *rx_cmd_urb;
115
116 struct ar5523_rx_data rx_data[AR5523_RX_DATA_COUNT];
117 spinlock_t rx_data_list_lock;
118 struct list_head rx_data_free;
119 struct list_head rx_data_used;
120 atomic_t rx_data_free_cnt;
121
122 struct work_struct rx_refill_work;
123
124 unsigned int rxbufsz;
125 u8 serial[16];
126
127 struct ieee80211_channel channels[14];
128 struct ieee80211_rate rates[12];
129 struct ieee80211_supported_band band;
130 struct ieee80211_vif *vif;
131 };
132
133
134 #define AR5523_CMD_FLAG_READ (1 << 1)
135 #define AR5523_CMD_FLAG_MAGIC (1 << 2)
136
137 #define ar5523_dbg(ar, format, arg...) \
138 dev_dbg(&(ar)->dev->dev, format, ## arg)
139
140
141
142
143
144 #define ar5523_err(ar, format, arg...) \
145 do { \
146 if (!test_bit(AR5523_USB_DISCONNECTED, &ar->flags)) { \
147 dev_err(&(ar)->dev->dev, format, ## arg); \
148 } \
149 } while (0)
150 #define ar5523_info(ar, format, arg...) \
151 dev_info(&(ar)->dev->dev, format, ## arg)