wlandrv.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. /****************************************************************************
  2. * This file is part of the WLAN-Ethernut device driver.
  3. *
  4. * Copyright (c) 2004 by Michael Fischer. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. 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 distribution.
  15. * 3. Neither the name of the author nor the names of its contributors may
  16. * be used to endorse or promote products derived from this software
  17. * without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
  23. * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. ****************************************************************************
  33. * Portions Copyright:
  34. *
  35. * Copyright (c) 2001 Atsushi Onoe
  36. * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
  37. * Copyright (c) 2002 M Warner Losh <imp@freebsd.org>. All rights reserved.
  38. * Copyright (c) 1997, 1998, 1999
  39. * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
  40. *
  41. * Redistribution and use in source and binary forms, with or without
  42. * modification, are permitted provided that the following conditions
  43. * are met:
  44. * 1. Redistributions of source code must retain the above copyright
  45. * notice, this list of conditions and the following disclaimer.
  46. * 2. Redistributions in binary form must reproduce the above copyright
  47. * notice, this list of conditions and the following disclaimer in the
  48. * documentation and/or other materials provided with the distribution.
  49. * 3. Neither the name of the author nor the names of any co-contributors
  50. * may be used to endorse or promote products derived from this software
  51. * without specific prior written permission.
  52. *
  53. * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
  54. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  55. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  56. * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
  57. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  58. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  59. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  60. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  61. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  62. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  63. * THE POSSIBILITY OF SUCH DAMAGE.
  64. *
  65. ****************************************************************************
  66. * History:
  67. *
  68. * 28.02.04 mifi First Version
  69. * This file is a mix of several FreeBSD header files.
  70. * I have put all the files together, because it was
  71. * difficult to use the original files. I have try this
  72. * but I must comment out to much to get it to work.
  73. * The other "define" file is wlandef.h,
  74. * here you will the rest of it.
  75. * 03.03.04 mifi Move debug switch to wlancfg.h
  76. ****************************************************************************/
  77. #ifndef __WLANDRV_H__
  78. #define __WLANDRV_H__
  79. #include <compiler.h>
  80. #include <dev/wlantypes.h>
  81. #include <dev/wlan.h>
  82. #include <dev/wlandef.h>
  83. /*-------------------------------------------------------------------------*/
  84. /* global defines and types */
  85. /*-------------------------------------------------------------------------*/
  86. /*
  87. * Resetport definition
  88. */
  89. #define RESET_EN_PORT DDRD
  90. #define RESET_PORT PORTD
  91. #define RESET_BIT 0x20
  92. /***************************************************************************/
  93. /* if_wivar.h */
  94. /***************************************************************************/
  95. /*
  96. * Driver Flags
  97. */
  98. #define WI_FLAGS_ATTACHED 0x0001
  99. #define WI_FLAGS_INITIALIZED 0x0002
  100. #define WI_FLAGS_OUTRANGE 0x0004
  101. #define WI_FLAGS_HAS_MOR 0x0010
  102. #define WI_FLAGS_HAS_ROAMING 0x0020
  103. #define WI_FLAGS_HAS_DIVERSITY 0x0040
  104. #define WI_FLAGS_HAS_SYSSCALE 0x0080
  105. #define WI_FLAGS_BUG_AUTOINC 0x0100
  106. #define WI_FLAGS_HAS_FRAGTHR 0x0200
  107. #define WI_FLAGS_HAS_DBMADJUST 0x0400
  108. /*
  109. * TX Buffer count
  110. */
  111. #define WI_NTXBUF 3
  112. /***************************************************************************/
  113. /* ieee80211.h */
  114. /***************************************************************************/
  115. #define IEEE80211_ADDR_LEN 6
  116. #define IEEE80211_NWID_LEN 32
  117. #define IEEE80211_WEP_KEYLEN 5 /* 40bit */
  118. #define IEEE80211_WEP_IVLEN 3 /* 24bit */
  119. #define IEEE80211_WEP_KIDLEN 1 /* 1 octet */
  120. #define IEEE80211_WEP_CRCLEN 4 /* CRC-32 */
  121. #define IEEE80211_WEP_NKID 4 /* number of key ids */
  122. #define IEEE80211_CRC_LEN 4
  123. /***************************************************************************/
  124. /* ieee80211_var.h */
  125. /***************************************************************************/
  126. /*
  127. * ic_flags
  128. */
  129. #define IEEE80211_F_ASCAN 0x00000001 /* STATUS: active scan */
  130. #define IEEE80211_F_SIBSS 0x00000002 /* STATUS: start IBSS */
  131. #define IEEE80211_F_WEPON 0x00000100 /* CONF: WEP enabled */
  132. #define IEEE80211_F_IBSSON 0x00000200 /* CONF: IBSS creation enable */
  133. #define IEEE80211_F_PMGTON 0x00000400 /* CONF: Power mgmt enable */
  134. #define IEEE80211_F_DESBSSID 0x00000800 /* CONF: des_bssid is set */
  135. #define IEEE80211_F_SCANAP 0x00001000 /* CONF: Scanning AP */
  136. #define IEEE80211_F_ROAMING 0x00002000 /* CONF: roaming enabled */
  137. #define IEEE80211_F_SWRETRY 0x00004000 /* CONF: sw tx retry enabled */
  138. #define IEEE80211_F_TXPMGT 0x00018000 /* STATUS: tx power */
  139. #define IEEE80211_F_TXPOW_OFF 0x00000000 /* TX Power: radio disabled */
  140. #define IEEE80211_F_TXPOW_FIXED 0x00008000 /* TX Power: fixed rate */
  141. #define IEEE80211_F_TXPOW_AUTO 0x00010000 /* TX Power: undefined */
  142. #define IEEE80211_F_SHSLOT 0x00020000 /* CONF: short slot time */
  143. #define IEEE80211_F_SHPREAMBLE 0x00040000 /* CONF: short preamble */
  144. /*
  145. * ic_caps
  146. */
  147. #define IEEE80211_C_WEP 0x0001 /* CAPABILITY: WEP available */
  148. #define IEEE80211_C_IBSS 0x0002 /* CAPABILITY: IBSS available */
  149. #define IEEE80211_C_PMGT 0x0004 /* CAPABILITY: Power mgmt */
  150. #define IEEE80211_C_HOSTAP 0x0008 /* CAPABILITY: HOSTAP avail */
  151. #define IEEE80211_C_AHDEMO 0x0010 /* CAPABILITY: Old Adhoc Demo */
  152. #define IEEE80211_C_SWRETRY 0x0020 /* CAPABILITY: sw tx retry */
  153. #define IEEE80211_C_TXPMGT 0x0040 /* CAPABILITY: tx power mgmt */
  154. #define IEEE80211_C_SHSLOT 0x0080 /* CAPABILITY: short slottime */
  155. #define IEEE80211_C_SHPREAMBLE 0x0100 /* CAPABILITY: short preamble */
  156. #define IEEE80211_C_MONITOR 0x0200 /* CAPABILITY: monitor mode */
  157. #define IEEE80211_C_RCVMGT 0x0400 /* CAPABILITY: rcv mgt frames */
  158. enum ieee80211_opmode {
  159. IEEE80211_M_STA = 1, /* infrastructure station */
  160. IEEE80211_M_IBSS = 0, /* IBSS (adhoc) station */
  161. IEEE80211_M_AHDEMO = 3, /* Old lucent compatible adhoc demo */
  162. IEEE80211_M_HOSTAP = 6, /* Software Access Point */
  163. IEEE80211_M_MONITOR = 8 /* Monitor mode */
  164. };
  165. /***************************************************************************/
  166. /* ieee80211_prot.h */
  167. /***************************************************************************/
  168. /*
  169. * 802.11 protocol implementation definitions.
  170. */
  171. enum ieee80211_state {
  172. IEEE80211_S_INIT = 0, /* default state */
  173. IEEE80211_S_SCAN = 1, /* scanning */
  174. IEEE80211_S_AUTH = 2, /* try to authenticate */
  175. IEEE80211_S_ASSOC = 3, /* try to assoc */
  176. IEEE80211_S_RUN = 4, /* associated */
  177. };
  178. #define IEEE80211_S_MAX (IEEE80211_S_RUN+1)
  179. /***************************************************************************/
  180. /* ieee80211_crypto.h */
  181. /***************************************************************************/
  182. /*
  183. * 802.11 protocol crypto-related definitions.
  184. */
  185. #define IEEE80211_KEYBUF_SIZE 16
  186. struct ieee80211_wepkey {
  187. int wk_len;
  188. u_int8_t wk_key[IEEE80211_KEYBUF_SIZE];
  189. };
  190. /***************************************************************************/
  191. /* ieee80211_node.h */
  192. /***************************************************************************/
  193. struct ieee80211_rateset {
  194. u_int8_t rs_nrates;
  195. u_int8_t rs_rates[IEEE80211_RATE_MAXSIZE];
  196. };
  197. /***************************************************************************/
  198. /* ieee80211_var.h */
  199. /***************************************************************************/
  200. struct ieee80211com {
  201. u_int8_t ic_myaddr[IEEE80211_ADDR_LEN];
  202. struct ieee80211_rateset ic_sup_rates[IEEE80211_MODE_MAX];
  203. u_int16_t ChannelList;
  204. u_int32_t ic_flags; /* state flags */
  205. u_int32_t ic_caps; /* capabilities */
  206. enum ieee80211_opmode ic_opmode; /* operation mode */
  207. enum ieee80211_state ic_state; /* 802.11 state */
  208. u_int16_t ic_ibss_chan;
  209. int ic_fixed_rate; /* index to ic_sup_rates[] */
  210. int ic_des_esslen;
  211. u_int8_t ic_des_essid[IEEE80211_NWID_LEN];
  212. struct ieee80211_wepkey ic_nw_keys[IEEE80211_WEP_NKID];
  213. int ic_wep_txkey; /* default tx key index */
  214. };
  215. /***************************************************************************/
  216. /* if_wivar.h */
  217. /***************************************************************************/
  218. struct wi_softc {
  219. /*
  220. * This is our Interrupt stuff
  221. */
  222. int InterruptInitDone;
  223. HANDLE volatile InterruptEvent;
  224. u_int16_t EventStatus;
  225. /*
  226. * Now here comes the FreeBSD stuff...
  227. */
  228. struct ieee80211com sc_ic;
  229. int PromiscuousMode;
  230. int wi_gone;
  231. int sc_enabled;
  232. int sc_reset;
  233. int sc_firmware_type;
  234. u_int32_t sc_pri_firmware_ver; /* Primary firmware */
  235. u_int32_t sc_sta_firmware_ver; /* Station firmware */
  236. int wi_cmd_count;
  237. int sc_flags;
  238. int sc_bap_id;
  239. int sc_bap_off;
  240. u_int16_t sc_portnum;
  241. /*
  242. * RSSI interpretation
  243. */
  244. u_int16_t sc_min_rssi; /* clamp sc_min_rssi < RSSI */
  245. u_int16_t sc_max_rssi; /* clamp RSSI < sc_max_rssi */
  246. u_int16_t sc_dbm_offset; /* dBm ~ RSSI - sc_dbm_offset */
  247. u_int16_t sc_max_datalen;
  248. u_int16_t sc_system_scale;
  249. u_int16_t sc_cnfauthmode;
  250. u_int16_t sc_roaming_mode;
  251. u_int16_t sc_microwave_oven;
  252. u_int16_t sc_authtype;
  253. int sc_buflen; /* TX buffer size */
  254. int sc_ntxbuf;
  255. struct {
  256. int d_fid;
  257. int d_len;
  258. } sc_txd[WI_NTXBUF]; /* TX buffers */
  259. int sc_txnext; /* index of next TX */
  260. int sc_txcur; /* index of current TX */
  261. int sc_tx_timer;
  262. int sc_scan_timer;
  263. u_int16_t sc_ibss_port;
  264. };
  265. typedef struct wi_softc WI_SOFTC;
  266. /*-------------------------------------------------------------------------*/
  267. /* global macros */
  268. /*-------------------------------------------------------------------------*/
  269. #define device_t NUTDEVICE*
  270. #define device_get_softc(_a) (struct wi_softc*)_a->dev_dcb
  271. /*-------------------------------------------------------------------------*/
  272. /* Prototypes */
  273. /*-------------------------------------------------------------------------*/
  274. int wlandrv_ProbeDevice (void);
  275. int wlandrv_Attach (device_t dev);
  276. void wlandrv_Init (device_t dev);
  277. int wlandrv_PutPacket (NUTDEVICE * dev, NETBUF * nb);
  278. int wlandrv_IOCTL (NUTDEVICE * dev, int req, void *conf);
  279. #endif /* !__WLANDRV_H__ */