wavelan.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. #define DEBUG if(1){}else print
  2. #define SEEKEYS 0
  3. // Lucent's Length-Type-Value records to talk to the wavelan.
  4. // most operational parameters are read/set using this.
  5. enum
  6. {
  7. WTyp_Stats = 0xf100,
  8. WTyp_Scan = 0xf101,
  9. WTyp_Link = 0xf200,
  10. WTyp_Ptype = 0xfc00,
  11. WTyp_Mac = 0xfc01,
  12. WTyp_WantName = 0xfc02,
  13. WTyp_Chan = 0xfc03,
  14. WTyp_NetName = 0xfc04,
  15. WTyp_ApDens = 0xfc06,
  16. WTyp_MaxLen = 0xfc07,
  17. WTyp_PM = 0xfc09,
  18. WTyp_PMWait = 0xfc0c,
  19. WTyp_NodeName = 0xfc0e,
  20. WTyp_Crypt = 0xfc20,
  21. WTyp_XClear = 0xfc22,
  22. WTyp_CreateIBSS = 0xfc81,
  23. WTyp_RtsThres = 0xfc83,
  24. WTyp_TxRate = 0xfc84,
  25. WTx1Mbps = 0x0,
  26. WTx2Mbps = 0x1,
  27. WTxAuto = 0x3,
  28. WTyp_Prom = 0xfc85,
  29. WTyp_Keys = 0xfcb0,
  30. WTyp_TxKey = 0xfcb1,
  31. WTyp_StationID = 0xfd20,
  32. WTyp_CurName = 0xfd41,
  33. WTyp_BaseID = 0xfd42, // ID of the currently connected-to base station
  34. WTyp_CurTxRate = 0xfd44, // Current TX rate
  35. WTyp_HasCrypt = 0xfd4f,
  36. WTyp_Tick = 0xfce0,
  37. };
  38. // Controller
  39. enum
  40. {
  41. WDfltIRQ = 3, // default irq
  42. WDfltIOB = 0x180, // default IO base
  43. WIOLen = 0x40, // Hermes IO length
  44. WTmOut = 65536, // Cmd time out
  45. WPTypeManaged = 1,
  46. WPTypeWDS = 2,
  47. WPTypeAdHoc = 3,
  48. WDfltPType = WPTypeManaged,
  49. WDfltApDens = 1,
  50. WDfltRtsThres = 2347, // == disabled
  51. WDfltTxRate = WTxAuto, // 2Mbps
  52. WMaxLen = 2304,
  53. WNameLen = 32,
  54. WNKeys = 4,
  55. WKeyLen = 14,
  56. WMinKeyLen = 5,
  57. WMaxKeyLen = 13,
  58. // Wavelan hermes registers
  59. WR_Cmd = 0x00,
  60. WCmdIni = 0x0000,
  61. WCmdEna = 0x0001,
  62. WCmdDis = 0x0002,
  63. WCmdTx = 0x000b,
  64. WCmdMalloc = 0x000a,
  65. WCmdEnquire = 0x0011,
  66. WCmdMsk = 0x003f,
  67. WCmdAccRd = 0x0021,
  68. WCmdReclaim = 0x0100,
  69. WCmdAccWr = 0x0121,
  70. WCmdBusy = 0x8000,
  71. WR_Parm0 = 0x02,
  72. WR_Parm1 = 0x04,
  73. WR_Parm2 = 0x06,
  74. WR_Sts = 0x08,
  75. WR_InfoId = 0x10,
  76. WR_Sel0 = 0x18,
  77. WR_Sel1 = 0x1a,
  78. WR_Off0 = 0x1c,
  79. WR_Off1 = 0x1e,
  80. WBusyOff = 0x8000,
  81. WErrOff = 0x4000,
  82. WResSts = 0x7f00,
  83. WR_RXId = 0x20,
  84. WR_Alloc = 0x22,
  85. WR_EvSts = 0x30,
  86. WR_IntEna = 0x32,
  87. WCmdEv = 0x0010,
  88. WRXEv = 0x0001,
  89. WTXEv = 0x0002,
  90. WTxErrEv = 0x0004,
  91. WAllocEv = 0x0008,
  92. WInfoEv = 0x0080,
  93. WIDropEv = 0x2000,
  94. WTickEv = 0x8000,
  95. WEvs = WRXEv|WTXEv|WAllocEv|WInfoEv|WIDropEv,
  96. WR_EvAck = 0x34,
  97. WR_Data0 = 0x36,
  98. WR_Data1 = 0x38,
  99. WR_PciCor = 0x26,
  100. WR_PciHcr = 0x2E,
  101. // Frame stuff
  102. WF_Err = 0x0003,
  103. WF_1042 = 0x2000,
  104. WF_Tunnel = 0x4000,
  105. WF_WMP = 0x6000,
  106. WF_Data = 0x0008,
  107. WSnapK1 = 0xaa,
  108. WSnapK2 = 0x00,
  109. WSnapCtlr = 0x03,
  110. WSnap0 = (WSnapK1|(WSnapK1<<8)),
  111. WSnap1 = (WSnapK2|(WSnapCtlr<<8)),
  112. WSnapHdrLen = 6,
  113. WF_802_11_Off = 0x44,
  114. WF_802_3_Off = 0x2e,
  115. };
  116. typedef struct Ctlr Ctlr;
  117. typedef struct Wltv Wltv;
  118. typedef struct WFrame WFrame;
  119. typedef struct Stats Stats;
  120. typedef struct WStats WStats;
  121. typedef struct WScan WScan;
  122. typedef struct WKey WKey;
  123. struct WStats
  124. {
  125. ulong ntxuframes; // unicast frames
  126. ulong ntxmframes; // multicast frames
  127. ulong ntxfrags; // fragments
  128. ulong ntxubytes; // unicast bytes
  129. ulong ntxmbytes; // multicast bytes
  130. ulong ntxdeferred; // deferred transmits
  131. ulong ntxsretries; // single retries
  132. ulong ntxmultiretries; // multiple retries
  133. ulong ntxretrylimit;
  134. ulong ntxdiscards;
  135. ulong nrxuframes; // unicast frames
  136. ulong nrxmframes; // multicast frames
  137. ulong nrxfrags; // fragments
  138. ulong nrxubytes; // unicast bytes
  139. ulong nrxmbytes; // multicast bytes
  140. ulong nrxfcserr;
  141. ulong nrxdropnobuf;
  142. ulong nrxdropnosa;
  143. ulong nrxcantdecrypt;
  144. ulong nrxmsgfrag;
  145. ulong nrxmsgbadfrag;
  146. ulong end;
  147. };
  148. struct WScan
  149. {
  150. ushort chan; /* dss channel */
  151. ushort noise; /* average noise in the air */
  152. ushort signal; /* signal strength */
  153. uchar bssid[Eaddrlen]; /* MAC address of the ap */
  154. ushort interval; /* beacon transmit interval */
  155. ushort capinfo; /* capability bits (0-ess, 1-ibss, 4-privacy [wep]) */
  156. ushort ssid_len; /* ssid length */
  157. char ssid[WNameLen]; /* ssid (ap name) */
  158. };
  159. struct WFrame
  160. {
  161. ushort sts;
  162. ushort rsvd0;
  163. ushort rsvd1;
  164. ushort qinfo;
  165. ushort rsvd2;
  166. ushort rsvd3;
  167. ushort txctl;
  168. ushort framectl;
  169. ushort id;
  170. uchar addr1[Eaddrlen];
  171. uchar addr2[Eaddrlen];
  172. uchar addr3[Eaddrlen];
  173. ushort seqctl;
  174. uchar addr4[Eaddrlen];
  175. ushort dlen;
  176. uchar dstaddr[Eaddrlen];
  177. uchar srcaddr[Eaddrlen];
  178. ushort len;
  179. ushort dat[3];
  180. ushort type;
  181. };
  182. struct WKey
  183. {
  184. ushort len;
  185. char dat[WKeyLen];
  186. };
  187. struct Wltv
  188. {
  189. ushort len;
  190. ushort type;
  191. union
  192. {
  193. struct {
  194. ushort val;
  195. ushort pad;
  196. };
  197. struct {
  198. uchar addr[8];
  199. };
  200. struct {
  201. ushort slen;
  202. char s[WNameLen];
  203. };
  204. struct {
  205. char name[WNameLen];
  206. };
  207. struct {
  208. WKey keys[WNKeys];
  209. };
  210. };
  211. };
  212. // What the driver thinks. Not what the card thinks.
  213. struct Stats
  214. {
  215. ulong nints;
  216. ulong ndoubleint;
  217. ulong nrx;
  218. ulong ntx;
  219. ulong ntxrq;
  220. ulong nrxerr;
  221. ulong ntxerr;
  222. ulong nalloc; // allocation (reclaim) events
  223. ulong ninfo;
  224. ulong nidrop;
  225. ulong nwatchdogs; // transmit time outs, actually
  226. int ticks;
  227. int tickintr;
  228. int signal;
  229. int noise;
  230. };
  231. enum {
  232. Attached = 0x01,
  233. Power = 0x02,
  234. };
  235. struct Ctlr
  236. {
  237. Lock;
  238. int state; // Attached | Power
  239. int slot;
  240. int iob;
  241. int createibss;
  242. int ptype;
  243. int apdensity;
  244. int rtsthres;
  245. int txbusy;
  246. int txrate;
  247. int txdid;
  248. int txmid;
  249. int txtmout;
  250. int maxlen;
  251. int chan;
  252. int pmena;
  253. int pmwait;
  254. Proc *timerproc;
  255. int scanticks;
  256. char netname[WNameLen];
  257. char wantname[WNameLen];
  258. char nodename[WNameLen];
  259. WFrame txf;
  260. uchar txbuf[1536];
  261. int hascrypt; // card has encryption
  262. int crypt; // encryption off/on
  263. int txkey; // transmit key
  264. Wltv keys; // default keys
  265. int xclear; // exclude clear packets off/on
  266. int ctlrno;
  267. ushort *mmb;
  268. /* for PCI-based devices */
  269. Ctlr *next;
  270. int active;
  271. Pcidev *pcidev;
  272. Stats;
  273. WStats;
  274. };
  275. extern char* wavenames[];
  276. void csr_outs(Ctlr*, int, ushort);
  277. ushort csr_ins(Ctlr*, int);
  278. void w_intdis(Ctlr*);
  279. int w_cmd(Ctlr *, ushort, ushort);
  280. void ltv_outs(Ctlr*, int, ushort);
  281. int ltv_ins(Ctlr*, int);
  282. int w_option(Ctlr*, char*, long);
  283. int w_inltv(Ctlr*, Wltv*);
  284. void w_attach(Ether*);
  285. void w_interrupt(Ureg*,void*);
  286. void w_transmit(Ether*);
  287. long w_ifstat(Ether*, void*, long, ulong);
  288. long w_ctl(Ether*, void*, long);
  289. void w_promiscuous(void*, int);
  290. void w_multicast(void*, uchar*, int);
  291. int wavelanreset(Ether*, Ctlr*);