Original 0.2.0pre8_plus_fixes_54 tarball
[acx-mac80211.git] / include / acx_func.h
blob7dff0c6106e897f407db664bdd3b35a37fba4832
1 /* include/acx100_helper.h
3 * --------------------------------------------------------------------
5 * Copyright (C) 2003 ACX100 Open Source Project
7 * The contents of this file are subject to the Mozilla Public
8 * License Version 1.1 (the "License"); you may not use this file
9 * except in compliance with the License. You may obtain a copy of
10 * the License at http://www.mozilla.org/MPL/
12 * Software distributed under the License is distributed on an "AS
13 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
14 * implied. See the License for the specific language governing
15 * rights and limitations under the License.
17 * Alternatively, the contents of this file may be used under the
18 * terms of the GNU Public License version 2 (the "GPL"), in which
19 * case the provisions of the GPL are applicable instead of the
20 * above. If you wish to allow the use of your version of this file
21 * only under the terms of the GPL and not to allow others to use
22 * your version of this file under the MPL, indicate your decision
23 * by deleting the provisions above and replace them with the notice
24 * and other provisions required by the GPL. If you do not delete
25 * the provisions above, a recipient may use your version of this
26 * file under either the MPL or the GPL.
28 * --------------------------------------------------------------------
30 * Inquiries regarding the ACX100 Open Source Project can be
31 * made directly to:
33 * acx100-users@lists.sf.net
34 * http://acx100.sf.net
36 * --------------------------------------------------------------------
39 /*============================================================================*
40 * Debug / log functionality *
41 *============================================================================*/
43 /* NOTE: If we still want basic logging of driver info if ACX_DEBUG is not
44 * defined, we should provide an acxlog variant that is never turned off. We
45 * should make a acx_msg(), and rename acxlog() to acx_debug() to make the
46 * difference very clear.
49 #if ACX_DEBUG
51 #define acxlog(chan, args...) \
52 do { \
53 if (debug & (chan)) \
54 printk(KERN_WARNING args); \
55 } while (0)
57 void log_fn_enter(const char *funcname);
58 void log_fn_exit(const char *funcname);
59 void log_fn_exit_v(const char *funcname, int v);
61 #define FN_ENTER \
62 do { \
63 if (unlikely(debug & L_FUNC)) { \
64 log_fn_enter(__func__); \
65 } \
66 } while (0)
68 #define FN_EXIT1(v) \
69 do { \
70 if (unlikely(debug & L_FUNC)) { \
71 log_fn_exit_v(__func__, v); \
72 } \
73 } while (0)
74 #define FN_EXIT0() \
75 do { \
76 if (unlikely(debug & L_FUNC)) { \
77 log_fn_exit(__func__); \
78 } \
79 } while (0)
81 #else
83 #define acxlog(chan, args...)
84 #define FN_ENTER
85 #define FN_EXIT1(v)
86 #define FN_EXIT0()
88 #endif /* ACX_DEBUG */
90 /*============================================================================*
91 * Locking and synchronization functions *
92 *============================================================================*/
94 /* These functions *must* be inline or they will break horribly on SPARC, due
95 * to its weird semantics for save/restore flags. extern inline should prevent
96 * the kernel from linking or module from loading if they are not inlined. */
98 #ifdef BROKEN_LOCKING
99 extern inline int acx_lock(wlandevice_t *priv, unsigned long *flags)
101 local_irq_save(*flags);
102 if (!spin_trylock(&priv->lock)) {
103 printk("ARGH! Lock already taken in %s\n", __func__);
104 local_irq_restore(*flags);
105 return -EFAULT;
106 } else {
107 printk("Lock given out in %s\n", __func__);
109 if (priv->hw_unavailable) {
110 printk(KERN_WARNING
111 "acx_lock() called with hw_unavailable (dev=%p)\n",
112 priv->netdev);
113 spin_unlock_irqrestore(&priv->lock, *flags);
114 return -EBUSY;
116 return OK;
119 extern inline void acx_unlock(wlandevice_t *priv, unsigned long *flags)
121 /* printk(KERN_WARNING "unlock\n"); */
122 spin_unlock_irqrestore(&priv->lock, *flags);
123 /* printk(KERN_WARNING "/unlock\n"); */
126 #else /* BROKEN_LOCKING */
128 extern inline int acx_lock(wlandevice_t *priv, unsigned long *flags)
130 /* do nothing and be quiet */
131 /*@-noeffect@*/
132 (void)*priv;
133 (void)*flags;
134 /*@=noeffect@*/
135 return OK;
138 extern inline void acx_unlock(wlandevice_t *priv, unsigned long *flags)
140 /* do nothing and be quiet */
141 /*@-noeffect@*/
142 (void)*priv;
143 (void)*flags;
144 /*@=noeffect@*/
146 #endif /* BROKEN_LOCKING */
147 static inline void acx_stop_queue(netdevice_t *dev, const char *msg)
149 netif_stop_queue(dev);
150 if (msg)
151 acxlog(L_BUFT, "tx: stop queue %s\n", msg);
154 static inline int acx_queue_stopped(netdevice_t *dev)
156 return netif_queue_stopped(dev);
159 static inline void acx_start_queue(netdevice_t *dev, const char *msg)
161 netif_start_queue(dev);
162 if (msg)
163 acxlog(L_BUFT, "tx: start queue %s\n", msg);
166 static inline void acx_wake_queue(netdevice_t *dev, const char *msg)
168 netif_wake_queue(dev);
169 if (msg)
170 acxlog(L_BUFT, "tx: wake queue %s\n", msg);
173 static inline void acx_carrier_off(netdevice_t *dev, const char *msg)
175 netif_carrier_off(dev);
176 if (msg)
177 acxlog(L_BUFT, "tx: carrier off %s\n", msg);
180 static inline void acx_carrier_on(netdevice_t *dev, const char *msg)
182 netif_carrier_on(dev);
183 if (msg)
184 acxlog(L_BUFT, "tx: carrier on %s\n", msg);
189 void acx_schedule(long timeout);
190 int acx_reset_dev(netdevice_t *dev);
191 void acx_cmd_join_bssid(wlandevice_t *priv, const u8 *bssid);
192 int acx_init_mac(netdevice_t *dev, u16 init);
193 void acx_set_reg_domain(wlandevice_t *priv, unsigned char reg_dom_id);
194 void acx_set_timer(wlandevice_t *priv, u32 time);
195 void acx_update_capabilities(wlandevice_t *priv);
196 u16 acx_read_eeprom_offset(wlandevice_t *priv, u32 addr,
197 u8 *charbuf);
198 u16 acx_read_eeprom_area(wlandevice_t *priv);
199 u16 acx_write_eeprom_offset(wlandevice_t *priv, u32 addr,
200 u32 len, const u8 *charbuf);
201 u16 acx_read_phy_reg(wlandevice_t *priv, u32 reg, u8 *charbuf);
202 u16 acx_write_phy_reg(wlandevice_t *priv, u32 reg, u8 value);
203 void acx_start(wlandevice_t *priv);
204 void acx_reset_mac(wlandevice_t *priv);
205 #ifdef USE_FW_LOADER_26
206 firmware_image_t *acx_read_fw(struct device *dev, const char *file, u32 *size);
207 #else
208 firmware_image_t *acx_read_fw(const char *file, u32 *size);
209 #endif
210 void acx100_set_wepkey(wlandevice_t *priv);
211 void acx111_set_wepkey(wlandevice_t *priv);
212 int acx100_init_wep(wlandevice_t *priv);
213 void acx_initialize_rx_config(wlandevice_t *priv);
214 void acx_update_card_settings(wlandevice_t *priv, int init, int get_all, int set_all);
215 void acx_init_task_scheduler(wlandevice_t *priv);
216 void acx_flush_task_scheduler(void);
217 void acx_schedule_after_interrupt_task(wlandevice_t *priv, unsigned int set_flag);
218 void acx_cmd_start_scan(wlandevice_t *priv);
219 int acx_upload_radio(wlandevice_t *priv);
220 void acx_read_configoption(wlandevice_t *priv);
221 u16 acx_proc_register_entries(const struct net_device *dev);
222 u16 acx_proc_unregister_entries(const struct net_device *dev);
223 void acx_update_dot11_ratevector(wlandevice_t *priv);
225 int acx_recalib_radio(wlandevice_t *priv);
226 int acx111_get_feature_config(wlandevice_t *priv, u32 *feature_options, u32 *data_flow_options);
227 int acx111_set_feature_config(wlandevice_t *priv, u32 feature_options, u32 data_flow_options, unsigned int mode /* 0 == remove, 1 == add, 2 == set */);
228 static inline int acx111_feature_off(wlandevice_t *priv, u32 f, u32 d)
230 return acx111_set_feature_config(priv, f, d, 0);
232 static inline int acx111_feature_on(wlandevice_t *priv, u32 f, u32 d)
234 return acx111_set_feature_config(priv, f, d, 1);
236 static inline int acx111_feature_set(wlandevice_t *priv, u32 f, u32 d)
238 return acx111_set_feature_config(priv, f, d, 2);
243 /* acx100_ioctl.c */
244 int acx_ioctl_old(netdevice_t *dev, struct ifreq *ifr, int cmd);
246 void acx_sta_list_init(wlandevice_t *priv);
247 client_t *acx_sta_list_get(wlandevice_t *priv, const u8 *address);
248 client_t *acx_sta_list_add(wlandevice_t *priv, const u8 *address);
249 client_t *acx_sta_list_get_or_add(wlandevice_t *priv, const u8 *address);
250 void acx_sta_list_del(wlandevice_t *priv, client_t *clt);
252 void acx_set_status(wlandevice_t *priv, u16 status);
253 int acx_rx_ieee802_11_frame(wlandevice_t *priv, rxhostdesc_t *desc);
254 u32 acx_transmit_disassoc(client_t *arg_0, wlandevice_t *priv);
255 void acx_timer(unsigned long a);
256 void acx_complete_dot11_scan(wlandevice_t *priv);
258 #define COUNT_STATE_STR 6
260 static inline const char *acx_get_status_name(u16 status)
262 extern const char * const g_wlan_state_str[COUNT_STATE_STR];
263 return g_wlan_state_str[
264 (status < COUNT_STATE_STR) ?
265 status : COUNT_STATE_STR-1
269 static inline p80211_hdr_t *acx_get_p80211_hdr(wlandevice_t *priv, const rxbuffer_t *rxbuf)
271 if (!(priv->rx_config_1 & RX_CFG1_INCLUDE_PHY_HDR))
272 return (p80211_hdr_t *)&rxbuf->hdr_a3;
274 /* take into account phy header in front of packet */
275 if(CHIPTYPE_ACX111 == priv->chip_type)
276 return (p80211_hdr_t*)((u8*)&rxbuf->hdr_a3 + 8);
278 return (p80211_hdr_t*)((u8*)&rxbuf->hdr_a3 + 4);
283 /*============================================================================*
284 * Function Declarations *
285 *============================================================================*/
287 int acx_ether_to_txdesc(struct wlandevice *priv,
288 struct txdescriptor *txdesc, const struct sk_buff *skb);
289 struct sk_buff *acx_rxdesc_to_ether(struct wlandevice *priv,
290 const struct rxhostdescriptor *rxdesc);
291 void acx_rxdesc_to_txdesc(const struct rxhostdescriptor *rxhostdesc,
292 struct txdescriptor *txdesc);
295 #if (WLAN_HOSTIF!=WLAN_USB) /* must be used for non-USB only */
296 #define INLINE_IO static inline /* undefine for out-of-line */
297 #include <acx_inline.h>
298 #endif /* (WLAN_HOSTIF!=WLAN_USB) */
300 #define ACX_CMD_TIMEOUT_DEFAULT 5000
302 void acx_get_info_state(wlandevice_t *priv);
303 void acx_get_cmd_state(wlandevice_t *priv);
304 void acx_write_cmd_type_or_status(wlandevice_t *priv, u32 val, unsigned int is_status);
305 int acx_issue_cmd(wlandevice_t *priv, unsigned int cmd, /*@null@*/ void *pcmdparam,
306 unsigned int paramlen, u32 timeout);
307 int acx_configure(wlandevice_t *priv, void *pdr, short type);
308 int acx_configure_length(wlandevice_t *priv, void *pdr, short type,
309 short length);
310 int acx_interrogate(wlandevice_t *priv, void *pdr, short type);
311 void acx_power_led(wlandevice_t *priv, u8 enable);
313 void acx_select_io_register_set(wlandevice_t *priv, u16 chip_type);
315 static inline void acx_log_mac_address(int level, const u8 *mac, const char *tail)
317 if (debug & level) {
318 printk(MACSTR"%s", MAC(mac), tail);
324 /* former idma.h */
325 int acx100_create_dma_regions(wlandevice_t *priv);
326 int acx111_create_dma_regions(wlandevice_t *priv);
327 int acx_delete_dma_regions(wlandevice_t *priv);
328 void acx_dma_tx_data(wlandevice_t *wlandev, struct txdescriptor *txdesc);
329 void acx_clean_tx_desc(wlandevice_t *priv);
330 void acx_clean_tx_desc_emergency(wlandevice_t *priv);
331 u8 acx_signal_to_winlevel(u8 rawlevel);
332 void acx_process_rx_desc(wlandevice_t *priv);
333 struct txdescriptor *acx_get_tx_desc(wlandevice_t *priv);