2 * Copyright (c) 2013 Qualcomm Atheros, Inc.
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:
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
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
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.
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.
36 * @defgroup adf_net_public network abstraction API
40 * @ingroup adf_net_public
42 * These APIs abstract the OS networking stack from a driver.
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.
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.
66 #include <adf_os_types.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>
74 * check for a NULL handle
76 #define ADF_NET_NULL __ADF_NET_NULL
79 * @brief this register the driver to the shim, but won't get
80 * any handle until create device is called.
82 * @param[in] drv driver info structure
84 * @return status of operation
86 static inline a_status_t
87 adf_net_register_drv(adf_drv_info_t *drv)
89 return(__adf_net_register_drv(drv));
94 * @brief deregister the driver from the shim
96 * @param[in] name driver name passed in adf_drv_info_t
98 * @see adf_net_register_drv()
101 adf_net_unregister_drv(a_uint8_t *drv_name)
103 __adf_net_unregister_drv(drv_name);
108 * @brief register a real device with the kernel
110 * @param[in] hdl driver handle for this device
111 * @param[in] op per-device switch structure
112 * @param[in] info basic device information
114 * @return opaque device handle
116 static inline adf_net_handle_t
117 adf_net_dev_create(adf_drv_handle_t hdl,
119 adf_net_dev_info_t *info)
121 return (__adf_net_dev_create(hdl, op, info));
125 * @brief register a virtual device with the kernel.
126 * A virtual device is always backed by a real device.
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
133 * @return opaque device handle
135 * @see adf_net_dev_create()
137 static inline adf_net_handle_t
138 adf_net_vdev_create(adf_net_handle_t dev_hdl,
139 adf_drv_handle_t hdl,
141 adf_net_dev_info_t *info)
143 return (__adf_net_vdev_create(dev_hdl, hdl, op, info));
147 * @brief Checks if the interface is running or not
149 * @param[in] hdl opaque device handle
151 * @return true if running, false if not
153 static inline a_bool_t
154 adf_net_is_running(adf_net_handle_t hdl)
156 return (__adf_net_is_running(hdl));
160 * @brief Checks if the interface is up or not
162 * @param[in] hdl opaque device handle
164 * @return true if up, false if not
166 static inline a_bool_t
167 adf_net_is_up(adf_net_handle_t hdl)
169 return (__adf_net_is_up(hdl));
174 * @brief check whether the carrier is available or not
176 * @param[in] hdl opaque device handle
178 * @return a_bool_t true if available, false if not
180 static inline a_bool_t
181 adf_net_carrier_ok(adf_net_handle_t hdl)
183 return(__adf_net_carrier_ok(hdl));
188 * @brief inform the networking stack that the link is down
190 * @param[in] hdl opaque device handle
193 adf_net_carrier_off(adf_net_handle_t hdl)
195 __adf_net_carrier_off(hdl);
200 * @brief inform the networking stack that the link is up
202 * @param[in] hdl opaque device handle
204 * @see adf_net_carrier_off()
207 adf_net_carrier_on(adf_net_handle_t hdl)
209 __adf_net_carrier_on(hdl);
215 * driver will use these to keep the native networking stack abreast of its
216 * resource (descriptor) situation.
220 * @brief inform the networking stack that the device is ready to receive
221 * transmit packets. Typically called during init.
223 * @param[in] hdl opaque device handle
226 adf_net_start_queue(adf_net_handle_t hdl)
228 __adf_net_start_queue(hdl);
232 * @brief inform the networking stack to stop sending transmit packets.
233 * Typically called if the driver runs out of resources for the device.
235 * @param[in] hdl opaque device handle
238 adf_net_stop_queue(adf_net_handle_t hdl)
240 __adf_net_stop_queue(hdl);
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.
249 * @note adf_net_wake_queue() is the counterpart of adf_net_stop_queue()
251 * @param[in] hdl opaque device handle
254 adf_net_wake_queue(adf_net_handle_t hdl)
256 __adf_net_wake_queue(hdl);
261 * @brief Check the state of the queue
263 * @param[in] hdl opaque device handle
265 * @return true if stopped, false if not
267 static inline a_bool_t
268 adf_net_queue_stopped(adf_net_handle_t hdl)
270 return(__adf_net_queue_stopped(hdl));
274 * @brief get interface name
276 * @param[in] hdl opaque device handle
278 * @return name of interface
280 static inline const a_uint8_t *
281 adf_net_ifname(adf_net_handle_t hdl)
283 return (__adf_net_ifname(hdl));
287 * @brief Get OS Handle from OS device object.
289 * @param[in] osdev OS device object
293 static inline adf_os_handle_t
294 adf_net_dev_to_os(adf_os_device_t osdev)
296 return __adf_net_dev_to_os(osdev);
300 * @brief Get OS Handle from OS net handle.
302 * @param[in] osdev OS net handle
306 static inline adf_os_handle_t
307 adf_net_hdl_to_os(adf_net_handle_t hdl)
309 return __adf_net_hdl_to_os(hdl);