ibmlana.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. #ifndef _IBM_LANA_INCLUDE_
  2. #define _IBM_LANA_INCLUDE_
  3. #ifdef _IBM_LANA_DRIVER_
  4. /* maximum packet size */
  5. #define PKTSIZE 1524
  6. /* number of transmit buffers */
  7. #define TXBUFCNT 4
  8. /* Adapter ID's */
  9. #define IBM_LANA_ID 0xffe0
  10. /* media enumeration - defined in a way that it fits onto the LAN/A's
  11. POS registers... */
  12. typedef enum {
  13. Media_10BaseT, Media_10Base5,
  14. Media_Unknown, Media_10Base2, Media_Count
  15. } ibmlana_medium;
  16. /* private structure */
  17. typedef struct {
  18. unsigned int slot; /* MCA-Slot-# */
  19. int realirq; /* memorizes actual IRQ, even when
  20. currently not allocated */
  21. ibmlana_medium medium; /* physical cannector */
  22. u32 tdastart, txbufstart, /* addresses */
  23. rrastart, rxbufstart, rdastart, rxbufcnt, txusedcnt;
  24. int nextrxdescr, /* next rx descriptor to be used */
  25. lastrxdescr, /* last free rx descriptor */
  26. nexttxdescr, /* last tx descriptor to be used */
  27. currtxdescr, /* tx descriptor currently tx'ed */
  28. txused[TXBUFCNT]; /* busy flags */
  29. void __iomem *base;
  30. spinlock_t lock;
  31. } ibmlana_priv;
  32. /* this card uses quite a lot of I/O ports...luckily the MCA bus decodes
  33. a full 64K I/O range... */
  34. #define IBM_LANA_IORANGE 0xa0
  35. /* Command Register: */
  36. #define SONIC_CMDREG 0x00
  37. #define CMDREG_HTX 0x0001 /* halt transmission */
  38. #define CMDREG_TXP 0x0002 /* start transmission */
  39. #define CMDREG_RXDIS 0x0004 /* disable receiver */
  40. #define CMDREG_RXEN 0x0008 /* enable receiver */
  41. #define CMDREG_STP 0x0010 /* stop timer */
  42. #define CMDREG_ST 0x0020 /* start timer */
  43. #define CMDREG_RST 0x0080 /* software reset */
  44. #define CMDREG_RRRA 0x0100 /* force SONIC to read first RRA */
  45. #define CMDREG_LCAM 0x0200 /* force SONIC to read CAM descrs */
  46. /* Data Configuration Register */
  47. #define SONIC_DCREG 0x02
  48. #define DCREG_EXBUS 0x8000 /* Extended Bus Mode */
  49. #define DCREG_LBR 0x2000 /* Latched Bus Retry */
  50. #define DCREG_PO1 0x1000 /* Programmable Outputs */
  51. #define DCREG_PO0 0x0800
  52. #define DCREG_SBUS 0x0400 /* Synchronous Bus Mode */
  53. #define DCREG_USR1 0x0200 /* User Definable Pins */
  54. #define DCREG_USR0 0x0100
  55. #define DCREG_WC0 0x0000 /* 0..3 Wait States */
  56. #define DCREG_WC1 0x0040
  57. #define DCREG_WC2 0x0080
  58. #define DCREG_WC3 0x00c0
  59. #define DCREG_DW16 0x0000 /* 16 bit Bus Mode */
  60. #define DCREG_DW32 0x0020 /* 32 bit Bus Mode */
  61. #define DCREG_BMS 0x0010 /* Block Mode Select */
  62. #define DCREG_RFT4 0x0000 /* 4/8/16/24 bytes RX Threshold */
  63. #define DCREG_RFT8 0x0004
  64. #define DCREG_RFT16 0x0008
  65. #define DCREG_RFT24 0x000c
  66. #define DCREG_TFT8 0x0000 /* 8/16/24/28 bytes TX Threshold */
  67. #define DCREG_TFT16 0x0001
  68. #define DCREG_TFT24 0x0002
  69. #define DCREG_TFT28 0x0003
  70. /* Receive Control Register */
  71. #define SONIC_RCREG 0x04
  72. #define RCREG_ERR 0x8000 /* accept damaged and collided pkts */
  73. #define RCREG_RNT 0x4000 /* accept packets that are < 64 */
  74. #define RCREG_BRD 0x2000 /* accept broadcasts */
  75. #define RCREG_PRO 0x1000 /* promiscuous mode */
  76. #define RCREG_AMC 0x0800 /* accept all multicasts */
  77. #define RCREG_LB_NONE 0x0000 /* no loopback */
  78. #define RCREG_LB_MAC 0x0200 /* MAC loopback */
  79. #define RCREG_LB_ENDEC 0x0400 /* ENDEC loopback */
  80. #define RCREG_LB_XVR 0x0600 /* Transceiver loopback */
  81. #define RCREG_MC 0x0100 /* Multicast received */
  82. #define RCREG_BC 0x0080 /* Broadcast received */
  83. #define RCREG_LPKT 0x0040 /* last packet in RBA */
  84. #define RCREG_CRS 0x0020 /* carrier sense present */
  85. #define RCREG_COL 0x0010 /* recv'd packet with collision */
  86. #define RCREG_CRCR 0x0008 /* recv'd packet with CRC error */
  87. #define RCREG_FAER 0x0004 /* recv'd packet with inv. framing */
  88. #define RCREG_LBK 0x0002 /* recv'd loopback packet */
  89. #define RCREG_PRX 0x0001 /* recv'd packet is OK */
  90. /* Transmit Control Register */
  91. #define SONIC_TCREG 0x06
  92. #define TCREG_PINT 0x8000 /* generate interrupt after TDA read */
  93. #define TCREG_POWC 0x4000 /* timer start out of window detect */
  94. #define TCREG_CRCI 0x2000 /* inhibit CRC generation */
  95. #define TCREG_EXDIS 0x1000 /* disable excessive deferral timer */
  96. #define TCREG_EXD 0x0400 /* excessive deferral occurred */
  97. #define TCREG_DEF 0x0200 /* single deferral occurred */
  98. #define TCREG_NCRS 0x0100 /* no carrier detected */
  99. #define TCREG_CRSL 0x0080 /* carrier lost */
  100. #define TCREG_EXC 0x0040 /* excessive collisions occurred */
  101. #define TCREG_OWC 0x0020 /* out of window collision occurred */
  102. #define TCREG_PMB 0x0008 /* packet monitored bad */
  103. #define TCREG_FU 0x0004 /* FIFO underrun */
  104. #define TCREG_BCM 0x0002 /* byte count mismatch of fragments */
  105. #define TCREG_PTX 0x0001 /* packet transmitted OK */
  106. /* Interrupt Mask Register */
  107. #define SONIC_IMREG 0x08
  108. #define IMREG_BREN 0x4000 /* interrupt when bus retry occurred */
  109. #define IMREG_HBLEN 0x2000 /* interrupt when heartbeat lost */
  110. #define IMREG_LCDEN 0x1000 /* interrupt when CAM loaded */
  111. #define IMREG_PINTEN 0x0800 /* interrupt when PINT in TDA set */
  112. #define IMREG_PRXEN 0x0400 /* interrupt when packet received */
  113. #define IMREG_PTXEN 0x0200 /* interrupt when packet was sent */
  114. #define IMREG_TXEREN 0x0100 /* interrupt when send failed */
  115. #define IMREG_TCEN 0x0080 /* interrupt when timer completed */
  116. #define IMREG_RDEEN 0x0040 /* interrupt when RDA exhausted */
  117. #define IMREG_RBEEN 0x0020 /* interrupt when RBA exhausted */
  118. #define IMREG_RBAEEN 0x0010 /* interrupt when RBA too short */
  119. #define IMREG_CRCEN 0x0008 /* interrupt when CRC counter rolls */
  120. #define IMREG_FAEEN 0x0004 /* interrupt when FAE counter rolls */
  121. #define IMREG_MPEN 0x0002 /* interrupt when MP counter rolls */
  122. #define IMREG_RFOEN 0x0001 /* interrupt when Rx FIFO overflows */
  123. /* Interrupt Status Register */
  124. #define SONIC_ISREG 0x0a
  125. #define ISREG_BR 0x4000 /* bus retry occurred */
  126. #define ISREG_HBL 0x2000 /* heartbeat lost */
  127. #define ISREG_LCD 0x1000 /* CAM loaded */
  128. #define ISREG_PINT 0x0800 /* PINT in TDA set */
  129. #define ISREG_PKTRX 0x0400 /* packet received */
  130. #define ISREG_TXDN 0x0200 /* packet was sent */
  131. #define ISREG_TXER 0x0100 /* send failed */
  132. #define ISREG_TC 0x0080 /* timer completed */
  133. #define ISREG_RDE 0x0040 /* RDA exhausted */
  134. #define ISREG_RBE 0x0020 /* RBA exhausted */
  135. #define ISREG_RBAE 0x0010 /* RBA too short for received frame */
  136. #define ISREG_CRC 0x0008 /* CRC counter rolls over */
  137. #define ISREG_FAE 0x0004 /* FAE counter rolls over */
  138. #define ISREG_MP 0x0002 /* MP counter rolls over */
  139. #define ISREG_RFO 0x0001 /* Rx FIFO overflows */
  140. #define SONIC_UTDA 0x0c /* current transmit descr address */
  141. #define SONIC_CTDA 0x0e
  142. #define SONIC_URDA 0x1a /* current receive descr address */
  143. #define SONIC_CRDA 0x1c
  144. #define SONIC_CRBA0 0x1e /* current receive buffer address */
  145. #define SONIC_CRBA1 0x20
  146. #define SONIC_RBWC0 0x22 /* word count in receive buffer */
  147. #define SONIC_RBWC1 0x24
  148. #define SONIC_EOBC 0x26 /* minimum space to be free in RBA */
  149. #define SONIC_URRA 0x28 /* upper address of CDA & Recv Area */
  150. #define SONIC_RSA 0x2a /* start of receive resource area */
  151. #define SONIC_REA 0x2c /* end of receive resource area */
  152. #define SONIC_RRP 0x2e /* resource read pointer */
  153. #define SONIC_RWP 0x30 /* resource write pointer */
  154. #define SONIC_CAMEPTR 0x42 /* CAM entry pointer */
  155. #define SONIC_CAMADDR2 0x44 /* CAM address ports */
  156. #define SONIC_CAMADDR1 0x46
  157. #define SONIC_CAMADDR0 0x48
  158. #define SONIC_CAMPTR 0x4c /* lower address of CDA */
  159. #define SONIC_CAMCNT 0x4e /* # of CAM descriptors to load */
  160. /* Data Configuration Register 2 */
  161. #define SONIC_DCREG2 0x7e
  162. #define DCREG2_EXPO3 0x8000 /* extended programmable outputs */
  163. #define DCREG2_EXPO2 0x4000
  164. #define DCREG2_EXPO1 0x2000
  165. #define DCREG2_EXPO0 0x1000
  166. #define DCREG2_HD 0x0800 /* heartbeat disable */
  167. #define DCREG2_JD 0x0200 /* jabber timer disable */
  168. #define DCREG2_AUTO 0x0100 /* enable AUI/TP auto selection */
  169. #define DCREG2_XWRAP 0x0040 /* TP transceiver loopback */
  170. #define DCREG2_PH 0x0010 /* HOLD request timing */
  171. #define DCREG2_PCM 0x0004 /* packet compress when matched */
  172. #define DCREG2_PCNM 0x0002 /* packet compress when not matched */
  173. #define DCREG2_RJCM 0x0001 /* inverse packet match via CAM */
  174. /* Board Control Register: Enable RAM, Interrupts... */
  175. #define BCMREG 0x80
  176. #define BCMREG_RAMEN 0x80 /* switch over to RAM */
  177. #define BCMREG_IPEND 0x40 /* interrupt pending ? */
  178. #define BCMREG_RESET 0x08 /* reset board */
  179. #define BCMREG_16BIT 0x04 /* adapter in 16-bit slot */
  180. #define BCMREG_RAMWIN 0x02 /* enable RAM window */
  181. #define BCMREG_IEN 0x01 /* interrupt enable */
  182. /* MAC Address PROM */
  183. #define MACADDRPROM 0x92
  184. /* structure of a CAM entry */
  185. typedef struct {
  186. u32 index; /* pointer into CAM area */
  187. u32 addr0; /* address part (bits 0..15 used) */
  188. u32 addr1;
  189. u32 addr2;
  190. } camentry_t;
  191. /* structure of a receive resource */
  192. typedef struct {
  193. u32 startlo; /* start address (bits 0..15 used) */
  194. u32 starthi;
  195. u32 cntlo; /* size in 16-bit quantities */
  196. u32 cnthi;
  197. } rra_t;
  198. /* structure of a receive descriptor */
  199. typedef struct {
  200. u32 status; /* packet status */
  201. u32 length; /* length in bytes */
  202. u32 startlo; /* start address */
  203. u32 starthi;
  204. u32 seqno; /* frame sequence */
  205. u32 link; /* pointer to next descriptor */
  206. /* bit 0 = EOL */
  207. u32 inuse; /* !=0 --> free for SONIC to write */
  208. } rda_t;
  209. /* structure of a transmit descriptor */
  210. typedef struct {
  211. u32 status; /* transmit status */
  212. u32 config; /* value for TCR */
  213. u32 length; /* total length */
  214. u32 fragcount; /* number of fragments */
  215. u32 startlo; /* start address of fragment */
  216. u32 starthi;
  217. u32 fraglength; /* length of this fragment */
  218. /* more address/length triplets may */
  219. /* follow here */
  220. u32 link; /* pointer to next descriptor */
  221. /* bit 0 = EOL */
  222. } tda_t;
  223. #endif /* _IBM_LANA_DRIVER_ */
  224. #endif /* _IBM_LANA_INCLUDE_ */