wavelan.h 5.6 KB

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