i82586.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. /*
  2. * Intel 82586 IEEE 802.3 Ethernet LAN Coprocessor.
  3. *
  4. * See:
  5. * Intel Microcommunications 1991
  6. * p1-1 to p1-37
  7. * Intel order No. 231658
  8. * ISBN 1-55512-119-5
  9. *
  10. * Unfortunately, the above chapter mentions neither
  11. * the System Configuration Pointer (SCP) nor the
  12. * Intermediate System Configuration Pointer (ISCP),
  13. * so we probably need to look elsewhere for the
  14. * whole story -- some recommend the "Intel LAN
  15. * Components manual" but I have neither a copy
  16. * nor a full reference. But "elsewhere" may be
  17. * in the same publication...
  18. * The description of a later device, the
  19. * "82596CA High-Performance 32-Bit Local Area Network
  20. * Coprocessor", (ibid. p1-38 to p1-109) does mention
  21. * the SCP and ISCP and also has an i82586 compatibility
  22. * mode. Even more useful is "AP-235 An 82586 Data Link
  23. * Driver" (ibid. p1-337 to p1-417).
  24. */
  25. #define I82586_MEMZ (64 * 1024)
  26. #define I82586_SCP_ADDR (I82586_MEMZ - sizeof(scp_t))
  27. #define ADDR_LEN 6
  28. #define I82586NULL 0xFFFF
  29. #define toff(t,p,f) (unsigned short)((void *)(&((t *)((void *)0 + (p)))->f) - (void *)0)
  30. /*
  31. * System Configuration Pointer (SCP).
  32. */
  33. typedef struct scp_t scp_t;
  34. struct scp_t
  35. {
  36. unsigned short scp_sysbus; /* 82586 bus width: */
  37. #define SCP_SY_16BBUS (0x0 << 0) /* 16 bits */
  38. #define SCP_SY_8BBUS (0x1 << 0) /* 8 bits. */
  39. unsigned short scp_junk[2]; /* Unused */
  40. unsigned short scp_iscpl; /* lower 16 bits of ISCP_ADDR */
  41. unsigned short scp_iscph; /* upper 16 bits of ISCP_ADDR */
  42. };
  43. /*
  44. * Intermediate System Configuration Pointer (ISCP).
  45. */
  46. typedef struct iscp_t iscp_t;
  47. struct iscp_t
  48. {
  49. unsigned short iscp_busy; /* set by CPU before first CA, */
  50. /* cleared by 82586 after read. */
  51. unsigned short iscp_offset; /* offset of SCB */
  52. unsigned short iscp_basel; /* base of SCB */
  53. unsigned short iscp_baseh; /* " */
  54. };
  55. /*
  56. * System Control Block (SCB).
  57. * The 82586 writes its status to scb_status and then
  58. * raises an interrupt to alert the CPU.
  59. * The CPU writes a command to scb_command and
  60. * then issues a Channel Attention (CA) to alert the 82586.
  61. */
  62. typedef struct scb_t scb_t;
  63. struct scb_t
  64. {
  65. unsigned short scb_status; /* Status of 82586 */
  66. #define SCB_ST_INT (0xF << 12) /* Some of: */
  67. #define SCB_ST_CX (0x1 << 15) /* Cmd completed */
  68. #define SCB_ST_FR (0x1 << 14) /* Frame received */
  69. #define SCB_ST_CNA (0x1 << 13) /* Cmd unit not active */
  70. #define SCB_ST_RNR (0x1 << 12) /* Rcv unit not ready */
  71. #define SCB_ST_JUNK0 (0x1 << 11) /* 0 */
  72. #define SCB_ST_CUS (0x7 << 8) /* Cmd unit status */
  73. #define SCB_ST_CUS_IDLE (0 << 8) /* Idle */
  74. #define SCB_ST_CUS_SUSP (1 << 8) /* Suspended */
  75. #define SCB_ST_CUS_ACTV (2 << 8) /* Active */
  76. #define SCB_ST_JUNK1 (0x1 << 7) /* 0 */
  77. #define SCB_ST_RUS (0x7 << 4) /* Rcv unit status */
  78. #define SCB_ST_RUS_IDLE (0 << 4) /* Idle */
  79. #define SCB_ST_RUS_SUSP (1 << 4) /* Suspended */
  80. #define SCB_ST_RUS_NRES (2 << 4) /* No resources */
  81. #define SCB_ST_RUS_RDY (4 << 4) /* Ready */
  82. unsigned short scb_command; /* Next command */
  83. #define SCB_CMD_ACK_CX (0x1 << 15) /* Ack cmd completion */
  84. #define SCB_CMD_ACK_FR (0x1 << 14) /* Ack frame received */
  85. #define SCB_CMD_ACK_CNA (0x1 << 13) /* Ack CU not active */
  86. #define SCB_CMD_ACK_RNR (0x1 << 12) /* Ack RU not ready */
  87. #define SCB_CMD_JUNKX (0x1 << 11) /* Unused */
  88. #define SCB_CMD_CUC (0x7 << 8) /* Command Unit command */
  89. #define SCB_CMD_CUC_NOP (0 << 8) /* Nop */
  90. #define SCB_CMD_CUC_GO (1 << 8) /* Start cbl_offset */
  91. #define SCB_CMD_CUC_RES (2 << 8) /* Resume execution */
  92. #define SCB_CMD_CUC_SUS (3 << 8) /* Suspend " */
  93. #define SCB_CMD_CUC_ABT (4 << 8) /* Abort " */
  94. #define SCB_CMD_RESET (0x1 << 7) /* Reset chip (hardware) */
  95. #define SCB_CMD_RUC (0x7 << 4) /* Receive Unit command */
  96. #define SCB_CMD_RUC_NOP (0 << 4) /* Nop */
  97. #define SCB_CMD_RUC_GO (1 << 4) /* Start rfa_offset */
  98. #define SCB_CMD_RUC_RES (2 << 4) /* Resume reception */
  99. #define SCB_CMD_RUC_SUS (3 << 4) /* Suspend " */
  100. #define SCB_CMD_RUC_ABT (4 << 4) /* Abort " */
  101. unsigned short scb_cbl_offset; /* Offset of first command unit */
  102. /* Action Command */
  103. unsigned short scb_rfa_offset; /* Offset of first Receive */
  104. /* Frame Descriptor in the */
  105. /* Receive Frame Area */
  106. unsigned short scb_crcerrs; /* Properly aligned frames */
  107. /* received with a CRC error */
  108. unsigned short scb_alnerrs; /* Misaligned frames received */
  109. /* with a CRC error */
  110. unsigned short scb_rscerrs; /* Frames lost due to no space */
  111. unsigned short scb_ovrnerrs; /* Frames lost due to slow bus */
  112. };
  113. #define scboff(p,f) toff(scb_t, p, f)
  114. /*
  115. * The eight Action Commands.
  116. */
  117. typedef enum acmd_e acmd_e;
  118. enum acmd_e
  119. {
  120. acmd_nop = 0, /* Do nothing */
  121. acmd_ia_setup = 1, /* Load an (ethernet) address into the */
  122. /* 82586 */
  123. acmd_configure = 2, /* Update the 82586 operating parameters */
  124. acmd_mc_setup = 3, /* Load a list of (ethernet) multicast */
  125. /* addresses into the 82586 */
  126. acmd_transmit = 4, /* Transmit a frame */
  127. acmd_tdr = 5, /* Perform a Time Domain Reflectometer */
  128. /* test on the serial link */
  129. acmd_dump = 6, /* Copy 82586 registers to memory */
  130. acmd_diagnose = 7, /* Run an internal self test */
  131. };
  132. /*
  133. * Generic Action Command header.
  134. */
  135. typedef struct ach_t ach_t;
  136. struct ach_t
  137. {
  138. unsigned short ac_status; /* Command status: */
  139. #define AC_SFLD_C (0x1 << 15) /* Command completed */
  140. #define AC_SFLD_B (0x1 << 14) /* Busy executing */
  141. #define AC_SFLD_OK (0x1 << 13) /* Completed error free */
  142. #define AC_SFLD_A (0x1 << 12) /* Command aborted */
  143. #define AC_SFLD_FAIL (0x1 << 11) /* Selftest failed */
  144. #define AC_SFLD_S10 (0x1 << 10) /* No carrier sense */
  145. /* during transmission */
  146. #define AC_SFLD_S9 (0x1 << 9) /* Tx unsuccessful: */
  147. /* (stopped) lost CTS */
  148. #define AC_SFLD_S8 (0x1 << 8) /* Tx unsuccessful: */
  149. /* (stopped) slow DMA */
  150. #define AC_SFLD_S7 (0x1 << 7) /* Tx deferred: */
  151. /* other link traffic */
  152. #define AC_SFLD_S6 (0x1 << 6) /* Heart Beat: collision */
  153. /* detect after last tx */
  154. #define AC_SFLD_S5 (0x1 << 5) /* Tx stopped: */
  155. /* excessive collisions */
  156. #define AC_SFLD_MAXCOL (0xF << 0) /* Collision count */
  157. unsigned short ac_command; /* Command specifier: */
  158. #define AC_CFLD_EL (0x1 << 15) /* End of command list */
  159. #define AC_CFLD_S (0x1 << 14) /* Suspend on completion */
  160. #define AC_CFLD_I (0x1 << 13) /* Interrupt on completion */
  161. #define AC_CFLD_CMD (0x7 << 0) /* acmd_e */
  162. unsigned short ac_link; /* Next Action Command */
  163. };
  164. #define acoff(p,f) toff(ach_t, p, f)
  165. /*
  166. * The Nop Action Command.
  167. */
  168. typedef struct ac_nop_t ac_nop_t;
  169. struct ac_nop_t
  170. {
  171. ach_t nop_h;
  172. };
  173. /*
  174. * The IA-Setup Action Command.
  175. */
  176. typedef struct ac_ias_t ac_ias_t;
  177. struct ac_ias_t
  178. {
  179. ach_t ias_h;
  180. unsigned char ias_addr[ADDR_LEN]; /* The (ethernet) address */
  181. };
  182. /*
  183. * The Configure Action Command.
  184. */
  185. typedef struct ac_cfg_t ac_cfg_t;
  186. struct ac_cfg_t
  187. {
  188. ach_t cfg_h;
  189. unsigned char cfg_byte_cnt; /* Size foll data: 4-12 */
  190. #define AC_CFG_BYTE_CNT(v) (((v) & 0xF) << 0)
  191. unsigned char cfg_fifolim; /* FIFO threshold */
  192. #define AC_CFG_FIFOLIM(v) (((v) & 0xF) << 0)
  193. unsigned char cfg_byte8;
  194. #define AC_CFG_SAV_BF(v) (((v) & 0x1) << 7) /* Save rxd bad frames */
  195. #define AC_CFG_SRDY(v) (((v) & 0x1) << 6) /* SRDY/ARDY pin means */
  196. /* external sync. */
  197. unsigned char cfg_byte9;
  198. #define AC_CFG_ELPBCK(v) (((v) & 0x1) << 7) /* External loopback */
  199. #define AC_CFG_ILPBCK(v) (((v) & 0x1) << 6) /* Internal loopback */
  200. #define AC_CFG_PRELEN(v) (((v) & 0x3) << 4) /* Preamble length */
  201. #define AC_CFG_PLEN_2 0 /* 2 bytes */
  202. #define AC_CFG_PLEN_4 1 /* 4 bytes */
  203. #define AC_CFG_PLEN_8 2 /* 8 bytes */
  204. #define AC_CFG_PLEN_16 3 /* 16 bytes */
  205. #define AC_CFG_ALOC(v) (((v) & 0x1) << 3) /* Addr/len data is */
  206. /* explicit in buffers */
  207. #define AC_CFG_ADDRLEN(v) (((v) & 0x7) << 0) /* Bytes per address */
  208. unsigned char cfg_byte10;
  209. #define AC_CFG_BOFMET(v) (((v) & 0x1) << 7) /* Use alternate expo. */
  210. /* backoff method */
  211. #define AC_CFG_ACR(v) (((v) & 0x7) << 4) /* Accelerated cont. res. */
  212. #define AC_CFG_LINPRIO(v) (((v) & 0x7) << 0) /* Linear priority */
  213. unsigned char cfg_ifs; /* Interframe spacing */
  214. unsigned char cfg_slotl; /* Slot time (low byte) */
  215. unsigned char cfg_byte13;
  216. #define AC_CFG_RETRYNUM(v) (((v) & 0xF) << 4) /* Max. collision retry */
  217. #define AC_CFG_SLTTMHI(v) (((v) & 0x7) << 0) /* Slot time (high bits) */
  218. unsigned char cfg_byte14;
  219. #define AC_CFG_FLGPAD(v) (((v) & 0x1) << 7) /* Pad with HDLC flags */
  220. #define AC_CFG_BTSTF(v) (((v) & 0x1) << 6) /* Do HDLC bitstuffing */
  221. #define AC_CFG_CRC16(v) (((v) & 0x1) << 5) /* 16 bit CCITT CRC */
  222. #define AC_CFG_NCRC(v) (((v) & 0x1) << 4) /* Insert no CRC */
  223. #define AC_CFG_TNCRS(v) (((v) & 0x1) << 3) /* Tx even if no carrier */
  224. #define AC_CFG_MANCH(v) (((v) & 0x1) << 2) /* Manchester coding */
  225. #define AC_CFG_BCDIS(v) (((v) & 0x1) << 1) /* Disable broadcast */
  226. #define AC_CFG_PRM(v) (((v) & 0x1) << 0) /* Promiscuous mode */
  227. unsigned char cfg_byte15;
  228. #define AC_CFG_ICDS(v) (((v) & 0x1) << 7) /* Internal collision */
  229. /* detect source */
  230. #define AC_CFG_CDTF(v) (((v) & 0x7) << 4) /* Collision detect */
  231. /* filter in bit times */
  232. #define AC_CFG_ICSS(v) (((v) & 0x1) << 3) /* Internal carrier */
  233. /* sense source */
  234. #define AC_CFG_CSTF(v) (((v) & 0x7) << 0) /* Carrier sense */
  235. /* filter in bit times */
  236. unsigned short cfg_min_frm_len;
  237. #define AC_CFG_MNFRM(v) (((v) & 0xFF) << 0) /* Min. bytes/frame (<= 255) */
  238. };
  239. /*
  240. * The MC-Setup Action Command.
  241. */
  242. typedef struct ac_mcs_t ac_mcs_t;
  243. struct ac_mcs_t
  244. {
  245. ach_t mcs_h;
  246. unsigned short mcs_cnt; /* No. of bytes of MC addresses */
  247. #if 0
  248. unsigned char mcs_data[ADDR_LEN]; /* The first MC address .. */
  249. ...
  250. #endif
  251. };
  252. #define I82586_MAX_MULTICAST_ADDRESSES 128 /* Hardware hashed filter */
  253. /*
  254. * The Transmit Action Command.
  255. */
  256. typedef struct ac_tx_t ac_tx_t;
  257. struct ac_tx_t
  258. {
  259. ach_t tx_h;
  260. unsigned short tx_tbd_offset; /* Address of list of buffers. */
  261. #if 0
  262. Linux packets are passed down with the destination MAC address
  263. and length/type field already prepended to the data,
  264. so we do not need to insert it. Consistent with this
  265. we must also set the AC_CFG_ALOC(..) flag during the
  266. ac_cfg_t action command.
  267. unsigned char tx_addr[ADDR_LEN]; /* The frame dest. address */
  268. unsigned short tx_length; /* The frame length */
  269. #endif /* 0 */
  270. };
  271. /*
  272. * The Time Domain Reflectometer Action Command.
  273. */
  274. typedef struct ac_tdr_t ac_tdr_t;
  275. struct ac_tdr_t
  276. {
  277. ach_t tdr_h;
  278. unsigned short tdr_result; /* Result. */
  279. #define AC_TDR_LNK_OK (0x1 << 15) /* No link problem */
  280. #define AC_TDR_XCVR_PRB (0x1 << 14) /* Txcvr cable problem */
  281. #define AC_TDR_ET_OPN (0x1 << 13) /* Open on the link */
  282. #define AC_TDR_ET_SRT (0x1 << 12) /* Short on the link */
  283. #define AC_TDR_TIME (0x7FF << 0) /* Distance to problem */
  284. /* site in transmit */
  285. /* clock cycles */
  286. };
  287. /*
  288. * The Dump Action Command.
  289. */
  290. typedef struct ac_dmp_t ac_dmp_t;
  291. struct ac_dmp_t
  292. {
  293. ach_t dmp_h;
  294. unsigned short dmp_offset; /* Result. */
  295. };
  296. /*
  297. * Size of the result of the dump command.
  298. */
  299. #define DUMPBYTES 170
  300. /*
  301. * The Diagnose Action Command.
  302. */
  303. typedef struct ac_dgn_t ac_dgn_t;
  304. struct ac_dgn_t
  305. {
  306. ach_t dgn_h;
  307. };
  308. /*
  309. * Transmit Buffer Descriptor (TBD).
  310. */
  311. typedef struct tbd_t tbd_t;
  312. struct tbd_t
  313. {
  314. unsigned short tbd_status; /* Written by the CPU */
  315. #define TBD_STATUS_EOF (0x1 << 15) /* This TBD is the */
  316. /* last for this frame */
  317. #define TBD_STATUS_ACNT (0x3FFF << 0) /* Actual count of data */
  318. /* bytes in this buffer */
  319. unsigned short tbd_next_bd_offset; /* Next in list */
  320. unsigned short tbd_bufl; /* Buffer address (low) */
  321. unsigned short tbd_bufh; /* " " (high) */
  322. };
  323. /*
  324. * Receive Buffer Descriptor (RBD).
  325. */
  326. typedef struct rbd_t rbd_t;
  327. struct rbd_t
  328. {
  329. unsigned short rbd_status; /* Written by the 82586 */
  330. #define RBD_STATUS_EOF (0x1 << 15) /* This RBD is the */
  331. /* last for this frame */
  332. #define RBD_STATUS_F (0x1 << 14) /* ACNT field is valid */
  333. #define RBD_STATUS_ACNT (0x3FFF << 0) /* Actual no. of data */
  334. /* bytes in this buffer */
  335. unsigned short rbd_next_rbd_offset; /* Next rbd in list */
  336. unsigned short rbd_bufl; /* Data pointer (low) */
  337. unsigned short rbd_bufh; /* " " (high) */
  338. unsigned short rbd_el_size; /* EL+Data buf. size */
  339. #define RBD_EL (0x1 << 15) /* This BD is the */
  340. /* last in the list */
  341. #define RBD_SIZE (0x3FFF << 0) /* No. of bytes the */
  342. /* buffer can hold */
  343. };
  344. #define rbdoff(p,f) toff(rbd_t, p, f)
  345. /*
  346. * Frame Descriptor (FD).
  347. */
  348. typedef struct fd_t fd_t;
  349. struct fd_t
  350. {
  351. unsigned short fd_status; /* Written by the 82586 */
  352. #define FD_STATUS_C (0x1 << 15) /* Completed storing frame */
  353. #define FD_STATUS_B (0x1 << 14) /* FD was consumed by RU */
  354. #define FD_STATUS_OK (0x1 << 13) /* Frame rxd successfully */
  355. #define FD_STATUS_S11 (0x1 << 11) /* CRC error */
  356. #define FD_STATUS_S10 (0x1 << 10) /* Alignment error */
  357. #define FD_STATUS_S9 (0x1 << 9) /* Ran out of resources */
  358. #define FD_STATUS_S8 (0x1 << 8) /* Rx DMA overrun */
  359. #define FD_STATUS_S7 (0x1 << 7) /* Frame too short */
  360. #define FD_STATUS_S6 (0x1 << 6) /* No EOF flag */
  361. unsigned short fd_command; /* Command */
  362. #define FD_COMMAND_EL (0x1 << 15) /* Last FD in list */
  363. #define FD_COMMAND_S (0x1 << 14) /* Suspend RU after rx */
  364. unsigned short fd_link_offset; /* Next FD */
  365. unsigned short fd_rbd_offset; /* First RBD (data) */
  366. /* Prepared by CPU, */
  367. /* updated by 82586 */
  368. #if 0
  369. I think the rest is unused since we
  370. have set AC_CFG_ALOC(..). However, just
  371. in case, we leave the space.
  372. #endif /* 0 */
  373. unsigned char fd_dest[ADDR_LEN]; /* Destination address */
  374. /* Written by 82586 */
  375. unsigned char fd_src[ADDR_LEN]; /* Source address */
  376. /* Written by 82586 */
  377. unsigned short fd_length; /* Frame length or type */
  378. /* Written by 82586 */
  379. };
  380. #define fdoff(p,f) toff(fd_t, p, f)
  381. /*
  382. * This software may only be used and distributed
  383. * according to the terms of the GNU General Public License.
  384. *
  385. * For more details, see wavelan.c.
  386. */