1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 Copyright (C) 2010 Willow Garage <http://www.willowgarage.com>
5 Copyright (C) 2009 Bartlomiej Zolnierkiewicz
13 * Hardware has 255 WCID table entries. First 32 entries are reserved for
14 * shared keys. Since parts of the pairwise key table might be shared with
15 * the beacon frame buffers 6 & 7 we could only use the first 222 entries.
19 #define STA_IDS_SIZE (WCID_END - WCID_START + 2)
31 /* RT2800 driver data structure */
32 struct rt2800_drv_data {
35 s8 rx_calibration_bw20;
36 s8 rx_calibration_bw40;
37 s8 tx_calibration_bw20;
38 s8 tx_calibration_bw40;
44 unsigned int tbtt_tick;
45 unsigned int ampdu_factor_cnt[4];
46 DECLARE_BITMAP(sta_ids, STA_IDS_SIZE);
47 struct ieee80211_sta *wcid_to_sta[STA_IDS_SIZE];
51 u32 (*register_read)(struct rt2x00_dev *rt2x00dev,
52 const unsigned int offset);
53 u32 (*register_read_lock)(struct rt2x00_dev *rt2x00dev,
54 const unsigned int offset);
55 void (*register_write)(struct rt2x00_dev *rt2x00dev,
56 const unsigned int offset, u32 value);
57 void (*register_write_lock)(struct rt2x00_dev *rt2x00dev,
58 const unsigned int offset, u32 value);
60 void (*register_multiread)(struct rt2x00_dev *rt2x00dev,
61 const unsigned int offset,
62 void *value, const u32 length);
63 void (*register_multiwrite)(struct rt2x00_dev *rt2x00dev,
64 const unsigned int offset,
65 const void *value, const u32 length);
67 int (*regbusy_read)(struct rt2x00_dev *rt2x00dev,
68 const unsigned int offset,
69 const struct rt2x00_field32 field, u32 *reg);
71 int (*read_eeprom)(struct rt2x00_dev *rt2x00dev);
72 bool (*hwcrypt_disabled)(struct rt2x00_dev *rt2x00dev);
74 int (*drv_write_firmware)(struct rt2x00_dev *rt2x00dev,
75 const u8 *data, const size_t len);
76 int (*drv_init_registers)(struct rt2x00_dev *rt2x00dev);
77 __le32 *(*drv_get_txwi)(struct queue_entry *entry);
78 unsigned int (*drv_get_dma_done)(struct data_queue *queue);
81 static inline u32 rt2800_register_read(struct rt2x00_dev *rt2x00dev,
82 const unsigned int offset)
84 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
86 return rt2800ops->register_read(rt2x00dev, offset);
89 static inline u32 rt2800_register_read_lock(struct rt2x00_dev *rt2x00dev,
90 const unsigned int offset)
92 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
94 return rt2800ops->register_read_lock(rt2x00dev, offset);
97 static inline void rt2800_register_write(struct rt2x00_dev *rt2x00dev,
98 const unsigned int offset,
101 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
103 rt2800ops->register_write(rt2x00dev, offset, value);
106 static inline void rt2800_register_write_lock(struct rt2x00_dev *rt2x00dev,
107 const unsigned int offset,
110 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
112 rt2800ops->register_write_lock(rt2x00dev, offset, value);
115 static inline void rt2800_register_multiread(struct rt2x00_dev *rt2x00dev,
116 const unsigned int offset,
117 void *value, const u32 length)
119 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
121 rt2800ops->register_multiread(rt2x00dev, offset, value, length);
124 static inline void rt2800_register_multiwrite(struct rt2x00_dev *rt2x00dev,
125 const unsigned int offset,
129 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
131 rt2800ops->register_multiwrite(rt2x00dev, offset, value, length);
134 static inline int rt2800_regbusy_read(struct rt2x00_dev *rt2x00dev,
135 const unsigned int offset,
136 const struct rt2x00_field32 field,
139 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
141 return rt2800ops->regbusy_read(rt2x00dev, offset, field, reg);
144 static inline int rt2800_read_eeprom(struct rt2x00_dev *rt2x00dev)
146 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
148 return rt2800ops->read_eeprom(rt2x00dev);
151 static inline bool rt2800_hwcrypt_disabled(struct rt2x00_dev *rt2x00dev)
153 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
155 return rt2800ops->hwcrypt_disabled(rt2x00dev);
158 static inline int rt2800_drv_write_firmware(struct rt2x00_dev *rt2x00dev,
159 const u8 *data, const size_t len)
161 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
163 return rt2800ops->drv_write_firmware(rt2x00dev, data, len);
166 static inline int rt2800_drv_init_registers(struct rt2x00_dev *rt2x00dev)
168 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
170 return rt2800ops->drv_init_registers(rt2x00dev);
173 static inline __le32 *rt2800_drv_get_txwi(struct queue_entry *entry)
175 const struct rt2800_ops *rt2800ops = entry->queue->rt2x00dev->ops->drv;
177 return rt2800ops->drv_get_txwi(entry);
180 static inline unsigned int rt2800_drv_get_dma_done(struct data_queue *queue)
182 const struct rt2800_ops *rt2800ops = queue->rt2x00dev->ops->drv;
184 return rt2800ops->drv_get_dma_done(queue);
187 void rt2800_mcu_request(struct rt2x00_dev *rt2x00dev,
188 const u8 command, const u8 token,
189 const u8 arg0, const u8 arg1);
191 int rt2800_wait_csr_ready(struct rt2x00_dev *rt2x00dev);
192 int rt2800_wait_wpdma_ready(struct rt2x00_dev *rt2x00dev);
194 int rt2800_check_firmware(struct rt2x00_dev *rt2x00dev,
195 const u8 *data, const size_t len);
196 int rt2800_load_firmware(struct rt2x00_dev *rt2x00dev,
197 const u8 *data, const size_t len);
199 void rt2800_write_tx_data(struct queue_entry *entry,
200 struct txentry_desc *txdesc);
201 void rt2800_process_rxwi(struct queue_entry *entry, struct rxdone_entry_desc *txdesc);
203 void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi,
205 void rt2800_txdone(struct rt2x00_dev *rt2x00dev, unsigned int quota);
206 void rt2800_txdone_nostatus(struct rt2x00_dev *rt2x00dev);
207 bool rt2800_txstatus_timeout(struct rt2x00_dev *rt2x00dev);
208 bool rt2800_txstatus_pending(struct rt2x00_dev *rt2x00dev);
210 void rt2800_watchdog(struct rt2x00_dev *rt2x00dev);
212 void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc);
213 void rt2800_clear_beacon(struct queue_entry *entry);
215 extern const struct rt2x00debug rt2800_rt2x00debug;
217 int rt2800_rfkill_poll(struct rt2x00_dev *rt2x00dev);
218 int rt2800_config_shared_key(struct rt2x00_dev *rt2x00dev,
219 struct rt2x00lib_crypto *crypto,
220 struct ieee80211_key_conf *key);
221 int rt2800_config_pairwise_key(struct rt2x00_dev *rt2x00dev,
222 struct rt2x00lib_crypto *crypto,
223 struct ieee80211_key_conf *key);
224 int rt2800_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
225 struct ieee80211_sta *sta);
226 int rt2800_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
227 struct ieee80211_sta *sta);
228 void rt2800_config_filter(struct rt2x00_dev *rt2x00dev,
229 const unsigned int filter_flags);
230 void rt2800_config_intf(struct rt2x00_dev *rt2x00dev, struct rt2x00_intf *intf,
231 struct rt2x00intf_conf *conf, const unsigned int flags);
232 void rt2800_config_erp(struct rt2x00_dev *rt2x00dev, struct rt2x00lib_erp *erp,
234 void rt2800_config_ant(struct rt2x00_dev *rt2x00dev, struct antenna_setup *ant);
235 void rt2800_config(struct rt2x00_dev *rt2x00dev,
236 struct rt2x00lib_conf *libconf,
237 const unsigned int flags);
238 void rt2800_link_stats(struct rt2x00_dev *rt2x00dev, struct link_qual *qual);
239 void rt2800_reset_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual);
240 void rt2800_link_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual,
242 void rt2800_gain_calibration(struct rt2x00_dev *rt2x00dev);
243 void rt2800_vco_calibration(struct rt2x00_dev *rt2x00dev);
245 int rt2800_enable_radio(struct rt2x00_dev *rt2x00dev);
246 void rt2800_disable_radio(struct rt2x00_dev *rt2x00dev);
248 int rt2800_efuse_detect(struct rt2x00_dev *rt2x00dev);
249 int rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev);
251 int rt2800_probe_hw(struct rt2x00_dev *rt2x00dev);
253 void rt2800_get_key_seq(struct ieee80211_hw *hw,
254 struct ieee80211_key_conf *key,
255 struct ieee80211_key_seq *seq);
256 int rt2800_set_rts_threshold(struct ieee80211_hw *hw, u32 value);
257 int rt2800_conf_tx(struct ieee80211_hw *hw,
258 struct ieee80211_vif *vif,
259 unsigned int link_id, u16 queue_idx,
260 const struct ieee80211_tx_queue_params *params);
261 u64 rt2800_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
262 int rt2800_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
263 struct ieee80211_ampdu_params *params);
264 int rt2800_get_survey(struct ieee80211_hw *hw, int idx,
265 struct survey_info *survey);
266 void rt2800_disable_wpdma(struct rt2x00_dev *rt2x00dev);
268 void rt2800_get_txwi_rxwi_size(struct rt2x00_dev *rt2x00dev,
269 unsigned short *txwi_size,
270 unsigned short *rxwi_size);
271 void rt2800_pre_reset_hw(struct rt2x00_dev *rt2x00dev);
273 #endif /* RT2800LIB_H */