adf_net.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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. * @ingroup adf_net_public
  40. * @file adf_net.h
  41. * These APIs abstract the OS networking stack from a driver.
  42. */
  43. /**
  44. * @mainpage
  45. * @section Introduction
  46. * The Atheros Driver Framework provides a mechanism to run the Atheros
  47. * WLAN driver on a variety of Operating Systems and Platforms. It achieves
  48. * this by abstracting all OS-specific and platform-specific functionality
  49. * the driver requires. This ensures the core logic in the driver is OS-
  50. * and platform-independent.
  51. * @section Modules
  52. * The driver framework consists of three main components:
  53. * @subsection sec1 Network Stack
  54. * This component abstracts the OS network stack. See @ref adf_net_public for details.
  55. * @subsection sec2 Network Buffer
  56. * This component abstracts the OS network buffer. See @ref adf_nbuf_public for details.
  57. * @subsection sec3 OS services
  58. * This component abstracts any OS services. See @ref adf_os_public for details.
  59. */
  60. #ifndef _ADF_NET_H
  61. #define _ADF_NET_H
  62. #include <adf_os_types.h>
  63. #include <adf_nbuf.h>
  64. #include "adf_net_types.h"
  65. #include "adf_net_wcmd.h"
  66. #include <adf_net_sw.h>
  67. #include <adf_net_pvt.h>
  68. /*
  69. * check for a NULL handle
  70. * */
  71. #define ADF_NET_NULL __ADF_NET_NULL
  72. /**
  73. * @brief this register the driver to the shim, but won't get
  74. * any handle until create device is called.
  75. *
  76. * @param[in] drv driver info structure
  77. *
  78. * @return status of operation
  79. */
  80. static inline a_status_t
  81. adf_net_register_drv(adf_drv_info_t *drv)
  82. {
  83. return(__adf_net_register_drv(drv));
  84. }
  85. /**
  86. * @brief deregister the driver from the shim
  87. *
  88. * @param[in] name driver name passed in adf_drv_info_t
  89. *
  90. * @see adf_net_register_drv()
  91. */
  92. static inline void
  93. adf_net_unregister_drv(a_uint8_t *drv_name)
  94. {
  95. __adf_net_unregister_drv(drv_name);
  96. }
  97. /**
  98. * @brief register a real device with the kernel
  99. *
  100. * @param[in] hdl driver handle for this device
  101. * @param[in] op per-device switch structure
  102. * @param[in] info basic device information
  103. *
  104. * @return opaque device handle
  105. */
  106. static inline adf_net_handle_t
  107. adf_net_dev_create(adf_drv_handle_t hdl,
  108. adf_dev_sw_t *op,
  109. adf_net_dev_info_t *info)
  110. {
  111. return (__adf_net_dev_create(hdl, op, info));
  112. }
  113. /**
  114. * @brief register a virtual device with the kernel.
  115. * A virtual device is always backed by a real device.
  116. *
  117. * @param[in] dev_hdl opaque device handle for the real device
  118. * @param[in] hdl driver handle for this virtual device
  119. * @param[in] op per-virtual-device switch structure
  120. * @param[in] info basic virtual device information
  121. *
  122. * @return opaque device handle
  123. *
  124. * @see adf_net_dev_create()
  125. */
  126. static inline adf_net_handle_t
  127. adf_net_vdev_create(adf_net_handle_t dev_hdl,
  128. adf_drv_handle_t hdl,
  129. adf_vdev_sw_t *op,
  130. adf_net_dev_info_t *info)
  131. {
  132. return (__adf_net_vdev_create(dev_hdl, hdl, op, info));
  133. }
  134. /**
  135. * @brief Checks if the interface is running or not
  136. *
  137. * @param[in] hdl opaque device handle
  138. *
  139. * @return true if running, false if not
  140. */
  141. static inline a_bool_t
  142. adf_net_is_running(adf_net_handle_t hdl)
  143. {
  144. return (__adf_net_is_running(hdl));
  145. }
  146. /**
  147. * @brief Checks if the interface is up or not
  148. *
  149. * @param[in] hdl opaque device handle
  150. *
  151. * @return true if up, false if not
  152. */
  153. static inline a_bool_t
  154. adf_net_is_up(adf_net_handle_t hdl)
  155. {
  156. return (__adf_net_is_up(hdl));
  157. }
  158. /**
  159. * @brief check whether the carrier is available or not
  160. *
  161. * @param[in] hdl opaque device handle
  162. *
  163. * @return a_bool_t true if available, false if not
  164. */
  165. static inline a_bool_t
  166. adf_net_carrier_ok(adf_net_handle_t hdl)
  167. {
  168. return(__adf_net_carrier_ok(hdl));
  169. }
  170. /**
  171. * @brief inform the networking stack that the link is down
  172. *
  173. * @param[in] hdl opaque device handle
  174. */
  175. static inline void
  176. adf_net_carrier_off(adf_net_handle_t hdl)
  177. {
  178. __adf_net_carrier_off(hdl);
  179. }
  180. /**
  181. * @brief inform the networking stack that the link is up
  182. *
  183. * @param[in] hdl opaque device handle
  184. *
  185. * @see adf_net_carrier_off()
  186. */
  187. static inline void
  188. adf_net_carrier_on(adf_net_handle_t hdl)
  189. {
  190. __adf_net_carrier_on(hdl);
  191. }
  192. /*
  193. * Queue mgmt.
  194. * driver will use these to keep the native networking stack abreast of its
  195. * resource (descriptor) situation.
  196. */
  197. /**
  198. * @brief inform the networking stack that the device is ready to receive
  199. * transmit packets. Typically called during init.
  200. *
  201. * @param[in] hdl opaque device handle
  202. */
  203. static inline void
  204. adf_net_start_queue(adf_net_handle_t hdl)
  205. {
  206. __adf_net_start_queue(hdl);
  207. }
  208. /**
  209. * @brief inform the networking stack to stop sending transmit packets.
  210. * Typically called if the driver runs out of resources for the device.
  211. *
  212. * @param[in] hdl opaque device handle
  213. */
  214. static inline void
  215. adf_net_stop_queue(adf_net_handle_t hdl)
  216. {
  217. __adf_net_stop_queue(hdl);
  218. }
  219. /**
  220. * @brief inform the native stack to resume sending packets
  221. * to transmit.Typically called when the driver has resources
  222. * available again for the device.
  223. *
  224. * @note adf_net_wake_queue() is the counterpart of adf_net_stop_queue()
  225. *
  226. * @param[in] hdl opaque device handle
  227. */
  228. static inline void
  229. adf_net_wake_queue(adf_net_handle_t hdl)
  230. {
  231. __adf_net_wake_queue(hdl);
  232. }
  233. /**
  234. * @brief Check the state of the queue
  235. *
  236. * @param[in] hdl opaque device handle
  237. *
  238. * @return true if stopped, false if not
  239. */
  240. static inline a_bool_t
  241. adf_net_queue_stopped(adf_net_handle_t hdl)
  242. {
  243. return(__adf_net_queue_stopped(hdl));
  244. }
  245. /**
  246. * @brief get interface name
  247. *
  248. * @param[in] hdl opaque device handle
  249. *
  250. * @return name of interface
  251. */
  252. static inline const a_uint8_t *
  253. adf_net_ifname(adf_net_handle_t hdl)
  254. {
  255. return (__adf_net_ifname(hdl));
  256. }
  257. /**
  258. * @brief Get OS Handle from OS device object.
  259. *
  260. * @param[in] osdev OS device object
  261. *
  262. * @return OS handle
  263. */
  264. static inline adf_os_handle_t
  265. adf_net_dev_to_os(adf_os_device_t osdev)
  266. {
  267. return __adf_net_dev_to_os(osdev);
  268. }
  269. /**
  270. * @brief Get OS Handle from OS net handle.
  271. *
  272. * @param[in] osdev OS net handle
  273. *
  274. * @return OS handle
  275. */
  276. static inline adf_os_handle_t
  277. adf_net_hdl_to_os(adf_net_handle_t hdl)
  278. {
  279. return __adf_net_hdl_to_os(hdl);
  280. }
  281. #endif