ath9k_htc: Update to upstream's commit d19607454d656cb14d8c16dfbf161eebb542e8fe dated...
[linux-libre-firmware.git] / ath9k_htc / target_firmware / magpie_fw_dev / target / inc / adf_net.h
1 /*
2  * Copyright (c) 2013 Qualcomm Atheros, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted (subject to the limitations in the
7  * disclaimer below) provided that the following conditions are met:
8  *
9  *  * Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  *  * Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the
15  *    distribution.
16  *
17  *  * Neither the name of Qualcomm Atheros nor the names of its
18  *    contributors may be used to endorse or promote products derived
19  *    from this software without specific prior written permission.
20  *
21  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
22  * GRANTED BY THIS LICENSE.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
23  * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
24  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
32  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
33  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 /**
36  * @defgroup adf_net_public network abstraction API
37  */
38
39 /**
40  * @ingroup adf_net_public
41  * @file adf_net.h
42  * These APIs abstract the OS networking stack from a driver.
43  */
44
45 /**
46  * @mainpage
47  * @section Introduction
48  * The Atheros Driver Framework provides a mechanism to run the Atheros
49  * WLAN driver on a variety of Operating Systems and Platforms. It achieves
50  * this by abstracting all OS-specific and platform-specific functionality
51  * the driver requires. This ensures the core logic in the driver is OS-
52  * and platform-independent.
53  * @section Modules
54  * The driver framework consists of three main components:
55  * @subsection sec1 Network Stack
56  * This component abstracts the OS network stack. See @ref adf_net_public for details.
57  * @subsection sec2 Network Buffer
58  * This component abstracts the OS network buffer. See @ref adf_nbuf_public for details.
59  * @subsection sec3 OS services
60  * This component abstracts any OS services. See @ref adf_os_public for details.
61  */
62
63 #ifndef _ADF_NET_H
64 #define _ADF_NET_H
65
66 #include <adf_os_types.h>
67 #include <adf_nbuf.h>
68 #include "adf_net_types.h"
69 #include "adf_net_wcmd.h"
70 #include <adf_net_sw.h>
71 #include <adf_net_pvt.h>
72
73 /*
74  * check for a NULL handle
75  * */
76 #define ADF_NET_NULL        __ADF_NET_NULL
77
78 /**
79  * @brief this register the driver to the shim, but won't get
80  *        any handle until create device is called.
81  *
82  * @param[in] drv driver info structure
83  *
84  * @return status of operation
85  */
86 static inline a_status_t
87 adf_net_register_drv(adf_drv_info_t *drv)
88 {
89     return(__adf_net_register_drv(drv));
90 }
91
92
93 /**
94  * @brief deregister the driver from the shim
95  *
96  * @param[in] name driver name passed in adf_drv_info_t
97  *
98  * @see adf_net_register_drv()
99  */
100 static inline void
101 adf_net_unregister_drv(a_uint8_t *drv_name)
102 {
103     __adf_net_unregister_drv(drv_name);
104 }
105
106
107 /**
108  * @brief register a real device with the kernel
109  *
110  * @param[in] hdl driver handle for this device
111  * @param[in] op per-device switch structure
112  * @param[in] info basic device information
113  *
114  * @return opaque device handle
115  */
116 static inline adf_net_handle_t
117 adf_net_dev_create(adf_drv_handle_t   hdl,
118                    adf_dev_sw_t      *op,
119                    adf_net_dev_info_t *info)
120 {
121     return (__adf_net_dev_create(hdl, op, info));
122 }
123
124 /**
125  * @brief register a virtual device with the kernel.
126  * A virtual device is always backed by a real device.
127  *
128  * @param[in] dev_hdl opaque device handle for the real device
129  * @param[in] hdl driver handle for this virtual device
130  * @param[in] op per-virtual-device switch structure
131  * @param[in] info basic virtual device information
132  *
133  * @return opaque device handle
134  *
135  * @see adf_net_dev_create()
136  */
137 static inline adf_net_handle_t
138 adf_net_vdev_create(adf_net_handle_t   dev_hdl,
139                     adf_drv_handle_t   hdl,
140                     adf_vdev_sw_t     *op,
141                     adf_net_dev_info_t *info)
142 {
143     return (__adf_net_vdev_create(dev_hdl, hdl, op, info));
144 }
145
146 /**
147  * @brief Checks if the interface is running or not
148  *
149  * @param[in] hdl opaque device handle
150  *
151  * @return true if running, false if not
152  */
153 static inline a_bool_t
154 adf_net_is_running(adf_net_handle_t hdl)
155 {
156     return (__adf_net_is_running(hdl));
157 }
158
159 /**
160  * @brief Checks if the interface is up or not
161  *
162  * @param[in] hdl opaque device handle
163  *
164  * @return true if up, false if not
165  */
166 static inline a_bool_t
167 adf_net_is_up(adf_net_handle_t hdl)
168 {
169     return (__adf_net_is_up(hdl));
170 }
171
172
173 /**
174  * @brief check whether the carrier is available or not
175  *
176  * @param[in] hdl opaque device handle
177  *
178  * @return a_bool_t true if available, false if not
179  */
180 static inline a_bool_t
181 adf_net_carrier_ok(adf_net_handle_t hdl)
182 {
183     return(__adf_net_carrier_ok(hdl));
184 }
185
186
187 /**
188  * @brief inform the networking stack that the link is down
189  *
190  * @param[in] hdl opaque device handle
191  */
192 static inline void
193 adf_net_carrier_off(adf_net_handle_t hdl)
194 {
195     __adf_net_carrier_off(hdl);
196 }
197
198
199 /**
200  * @brief inform the networking stack that the link is up
201  *
202  * @param[in] hdl opaque device handle
203  *
204  * @see adf_net_carrier_off()
205  */
206 static inline void
207 adf_net_carrier_on(adf_net_handle_t hdl)
208 {
209     __adf_net_carrier_on(hdl);
210 }
211
212
213 /*
214  * Queue mgmt.
215  * driver will use these to keep the native networking stack abreast of its
216  * resource (descriptor) situation.
217  */
218
219 /**
220  * @brief inform the networking stack that the device is ready to receive
221  * transmit packets. Typically called during init.
222  *
223  * @param[in] hdl opaque device handle
224  */
225 static inline void
226 adf_net_start_queue(adf_net_handle_t hdl)
227 {
228     __adf_net_start_queue(hdl);
229 }
230
231 /**
232  * @brief inform the networking stack to stop sending transmit packets.
233  * Typically called if the driver runs out of resources for the device.
234  *
235  * @param[in] hdl opaque device handle
236  */
237 static inline void
238 adf_net_stop_queue(adf_net_handle_t hdl)
239 {
240     __adf_net_stop_queue(hdl);
241 }
242
243
244 /**
245  * @brief inform the native stack to resume sending packets
246  * to transmit.Typically called when the driver has resources
247  * available again for the device.
248  *
249  * @note adf_net_wake_queue() is the counterpart of adf_net_stop_queue()
250  *
251  * @param[in] hdl opaque device handle
252  */
253 static inline void
254 adf_net_wake_queue(adf_net_handle_t hdl)
255 {
256     __adf_net_wake_queue(hdl);
257 }
258
259
260 /**
261  * @brief Check the state of the queue
262  *
263  * @param[in] hdl opaque device handle
264  *
265  * @return true if stopped, false if not
266  */
267 static inline a_bool_t
268 adf_net_queue_stopped(adf_net_handle_t hdl)
269 {
270     return(__adf_net_queue_stopped(hdl));
271 }
272
273 /**
274  * @brief get interface name
275  *
276  * @param[in] hdl opaque device handle
277  *
278  * @return name of interface
279  */
280 static inline const a_uint8_t *
281 adf_net_ifname(adf_net_handle_t  hdl)
282 {
283     return (__adf_net_ifname(hdl));
284 }
285
286 /**
287  * @brief Get OS Handle from OS device object.
288  *
289  * @param[in] osdev OS device object
290  *
291  * @return OS handle
292  */
293 static inline adf_os_handle_t
294 adf_net_dev_to_os(adf_os_device_t osdev)
295 {
296     return __adf_net_dev_to_os(osdev);
297 }
298
299 /**
300  * @brief Get OS Handle from OS net handle.
301  *
302  * @param[in] osdev OS net handle
303  *
304  * @return OS handle
305  */
306 static inline adf_os_handle_t
307 adf_net_hdl_to_os(adf_net_handle_t hdl)
308 {
309     return __adf_net_hdl_to_os(hdl);
310 }
311
312 #endif