wimax.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. /*
  2. * Linux WiMax
  3. * API for user space
  4. *
  5. *
  6. * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * * Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * * Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in
  16. * the documentation and/or other materials provided with the
  17. * distribution.
  18. * * Neither the name of Intel Corporation nor the names of its
  19. * contributors may be used to endorse or promote products derived
  20. * from this software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  25. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  26. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  27. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  28. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  29. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  30. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  32. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. *
  34. *
  35. * Intel Corporation <linux-wimax@intel.com>
  36. * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
  37. * - Initial implementation
  38. *
  39. *
  40. * This file declares the user/kernel protocol that is spoken over
  41. * Generic Netlink, as well as any type declaration that is to be used
  42. * by kernel and user space.
  43. *
  44. * It is intended for user space to clone it verbatim to use it as a
  45. * primary reference for definitions.
  46. *
  47. * Stuff intended for kernel usage as well as full protocol and stack
  48. * documentation is rooted in include/net/wimax.h.
  49. */
  50. #ifndef __LINUX__WIMAX_H__
  51. #define __LINUX__WIMAX_H__
  52. #include <linux/types.h>
  53. enum {
  54. /**
  55. * Version of the interface (unsigned decimal, MMm, max 25.5)
  56. * M - Major: change if removing or modifying an existing call.
  57. * m - minor: change when adding a new call
  58. */
  59. WIMAX_GNL_VERSION = 01,
  60. /* Generic NetLink attributes */
  61. WIMAX_GNL_ATTR_INVALID = 0x00,
  62. WIMAX_GNL_ATTR_MAX = 10,
  63. };
  64. /*
  65. * Generic NetLink operations
  66. *
  67. * Most of these map to an API call; _OP_ stands for operation, _RP_
  68. * for reply and _RE_ for report (aka: signal).
  69. */
  70. enum {
  71. WIMAX_GNL_OP_MSG_FROM_USER, /* User to kernel message */
  72. WIMAX_GNL_OP_MSG_TO_USER, /* Kernel to user message */
  73. WIMAX_GNL_OP_RFKILL, /* Run wimax_rfkill() */
  74. WIMAX_GNL_OP_RESET, /* Run wimax_rfkill() */
  75. WIMAX_GNL_RE_STATE_CHANGE, /* Report: status change */
  76. WIMAX_GNL_OP_STATE_GET, /* Request for current state */
  77. };
  78. /* Message from user / to user */
  79. enum {
  80. WIMAX_GNL_MSG_IFIDX = 1,
  81. WIMAX_GNL_MSG_PIPE_NAME,
  82. WIMAX_GNL_MSG_DATA,
  83. };
  84. /*
  85. * wimax_rfkill()
  86. *
  87. * The state of the radio (ON/OFF) is mapped to the rfkill subsystem's
  88. * switch state (DISABLED/ENABLED).
  89. */
  90. enum wimax_rf_state {
  91. WIMAX_RF_OFF = 0, /* Radio is off, rfkill on/enabled */
  92. WIMAX_RF_ON = 1, /* Radio is on, rfkill off/disabled */
  93. WIMAX_RF_QUERY = 2,
  94. };
  95. /* Attributes */
  96. enum {
  97. WIMAX_GNL_RFKILL_IFIDX = 1,
  98. WIMAX_GNL_RFKILL_STATE,
  99. };
  100. /* Attributes for wimax_reset() */
  101. enum {
  102. WIMAX_GNL_RESET_IFIDX = 1,
  103. };
  104. /* Attributes for wimax_state_get() */
  105. enum {
  106. WIMAX_GNL_STGET_IFIDX = 1,
  107. };
  108. /*
  109. * Attributes for the Report State Change
  110. *
  111. * For now we just have the old and new states; new attributes might
  112. * be added later on.
  113. */
  114. enum {
  115. WIMAX_GNL_STCH_IFIDX = 1,
  116. WIMAX_GNL_STCH_STATE_OLD,
  117. WIMAX_GNL_STCH_STATE_NEW,
  118. };
  119. /**
  120. * enum wimax_st - The different states of a WiMAX device
  121. * @__WIMAX_ST_NULL: The device structure has been allocated and zeroed,
  122. * but still wimax_dev_add() hasn't been called. There is no state.
  123. *
  124. * @WIMAX_ST_DOWN: The device has been registered with the WiMAX and
  125. * networking stacks, but it is not initialized (normally that is
  126. * done with 'ifconfig DEV up' [or equivalent], which can upload
  127. * firmware and enable communications with the device).
  128. * In this state, the device is powered down and using as less
  129. * power as possible.
  130. * This state is the default after a call to wimax_dev_add(). It
  131. * is ok to have drivers move directly to %WIMAX_ST_UNINITIALIZED
  132. * or %WIMAX_ST_RADIO_OFF in _probe() after the call to
  133. * wimax_dev_add().
  134. * It is recommended that the driver leaves this state when
  135. * calling 'ifconfig DEV up' and enters it back on 'ifconfig DEV
  136. * down'.
  137. *
  138. * @__WIMAX_ST_QUIESCING: The device is being torn down, so no API
  139. * operations are allowed to proceed except the ones needed to
  140. * complete the device clean up process.
  141. *
  142. * @WIMAX_ST_UNINITIALIZED: [optional] Communication with the device
  143. * is setup, but the device still requires some configuration
  144. * before being operational.
  145. * Some WiMAX API calls might work.
  146. *
  147. * @WIMAX_ST_RADIO_OFF: The device is fully up; radio is off (wether
  148. * by hardware or software switches).
  149. * It is recommended to always leave the device in this state
  150. * after initialization.
  151. *
  152. * @WIMAX_ST_READY: The device is fully up and radio is on.
  153. *
  154. * @WIMAX_ST_SCANNING: [optional] The device has been instructed to
  155. * scan. In this state, the device cannot be actively connected to
  156. * a network.
  157. *
  158. * @WIMAX_ST_CONNECTING: The device is connecting to a network. This
  159. * state exists because in some devices, the connect process can
  160. * include a number of negotiations between user space, kernel
  161. * space and the device. User space needs to know what the device
  162. * is doing. If the connect sequence in a device is atomic and
  163. * fast, the device can transition directly to CONNECTED
  164. *
  165. * @WIMAX_ST_CONNECTED: The device is connected to a network.
  166. *
  167. * @__WIMAX_ST_INVALID: This is an invalid state used to mark the
  168. * maximum numeric value of states.
  169. *
  170. * Description:
  171. *
  172. * Transitions from one state to another one are atomic and can only
  173. * be caused in kernel space with wimax_state_change(). To read the
  174. * state, use wimax_state_get().
  175. *
  176. * States starting with __ are internal and shall not be used or
  177. * referred to by drivers or userspace. They look ugly, but that's the
  178. * point -- if any use is made non-internal to the stack, it is easier
  179. * to catch on review.
  180. *
  181. * All API operations [with well defined exceptions] will take the
  182. * device mutex before starting and then check the state. If the state
  183. * is %__WIMAX_ST_NULL, %WIMAX_ST_DOWN, %WIMAX_ST_UNINITIALIZED or
  184. * %__WIMAX_ST_QUIESCING, it will drop the lock and quit with
  185. * -%EINVAL, -%ENOMEDIUM, -%ENOTCONN or -%ESHUTDOWN.
  186. *
  187. * The order of the definitions is important, so we can do numerical
  188. * comparisons (eg: < %WIMAX_ST_RADIO_OFF means the device is not ready
  189. * to operate).
  190. */
  191. /*
  192. * The allowed state transitions are described in the table below
  193. * (states in rows can go to states in columns where there is an X):
  194. *
  195. * UNINI RADIO READY SCAN CONNEC CONNEC
  196. * NULL DOWN QUIESCING TIALIZED OFF NING TING TED
  197. * NULL - x
  198. * DOWN - x x x
  199. * QUIESCING x -
  200. * UNINITIALIZED x - x
  201. * RADIO_OFF x - x
  202. * READY x x - x x x
  203. * SCANNING x x x - x x
  204. * CONNECTING x x x x - x
  205. * CONNECTED x x x -
  206. *
  207. * This table not available in kernel-doc because the formatting messes it up.
  208. */
  209. enum wimax_st {
  210. __WIMAX_ST_NULL = 0,
  211. WIMAX_ST_DOWN,
  212. __WIMAX_ST_QUIESCING,
  213. WIMAX_ST_UNINITIALIZED,
  214. WIMAX_ST_RADIO_OFF,
  215. WIMAX_ST_READY,
  216. WIMAX_ST_SCANNING,
  217. WIMAX_ST_CONNECTING,
  218. WIMAX_ST_CONNECTED,
  219. __WIMAX_ST_INVALID /* Always keep last */
  220. };
  221. #endif /* #ifndef __LINUX__WIMAX_H__ */