bereg.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. /* $OpenBSD: bereg.h,v 1.4 2008/06/26 05:42:18 ray Exp $ */
  2. /* $NetBSD: bereg.h,v 1.4 2000/07/24 04:28:51 mycroft Exp $ */
  3. /*-
  4. * Copyright (c) 1999 The NetBSD Foundation, Inc.
  5. * All rights reserved.
  6. *
  7. * This code is derived from software contributed to The NetBSD Foundation
  8. * by Paul Kranenburg.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in the
  17. * documentation and/or other materials provided with the distribution.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  21. * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  22. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
  23. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  24. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  25. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  26. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  27. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  28. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  29. * POSSIBILITY OF SUCH DAMAGE.
  30. */
  31. /*
  32. * Copyright (c) 1998 Theo de Raadt and Jason L. Wright.
  33. * All rights reserved.
  34. *
  35. * Redistribution and use in source and binary forms, with or without
  36. * modification, are permitted provided that the following conditions
  37. * are met:
  38. * 1. Redistributions of source code must retain the above copyright
  39. * notice, this list of conditions and the following disclaimer.
  40. * 2. Redistributions in binary form must reproduce the above copyright
  41. * notice, this list of conditions and the following disclaimer in the
  42. * documentation and/or other materials provided with the distribution.
  43. *
  44. * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
  45. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  46. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  47. * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  48. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  49. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  50. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  51. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  52. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  53. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  54. */
  55. /*
  56. * BE Global registers
  57. */
  58. #if 0
  59. struct be_bregs {
  60. u_int32_t xif_cfg; /* XIF config */
  61. u_int32_t _unused[63]; /* reserved */
  62. u_int32_t stat; /* status, clear on read */
  63. u_int32_t imask; /* interrupt mask */
  64. u_int32_t _unused2[64]; /* reserved */
  65. u_int32_t tx_swreset; /* tx software reset */
  66. u_int32_t tx_cfg; /* tx config */
  67. u_int32_t ipkt_gap1; /* inter-packet gap 1 */
  68. u_int32_t ipkt_gap2; /* inter-packet gap 2 */
  69. u_int32_t attempt_limit; /* tx attempt limit */
  70. u_int32_t stime; /* tx slot time */
  71. u_int32_t preamble_len; /* size of tx preamble */
  72. u_int32_t preamble_pattern; /* pattern for tx preamble */
  73. u_int32_t tx_sframe_delim; /* tx delimiter */
  74. u_int32_t jsize; /* jam length */
  75. u_int32_t tx_pkt_max; /* tx max pkt size */
  76. u_int32_t tx_pkt_min; /* tx min pkt size */
  77. u_int32_t peak_attempt; /* count of tx peak attempts */
  78. u_int32_t dt_ctr; /* tx defer timer */
  79. u_int32_t nc_ctr; /* tx normal collision cntr */
  80. u_int32_t fc_ctr; /* tx first-collision cntr */
  81. u_int32_t ex_ctr; /* tx excess-collision cntr */
  82. u_int32_t lt_ctr; /* tx late-collision cntr */
  83. u_int32_t rand_seed; /* tx random number seed */
  84. u_int32_t tx_smachine; /* tx state machine */
  85. u_int32_t _unused3[44]; /* reserved */
  86. u_int32_t rx_swreset; /* rx software reset */
  87. u_int32_t rx_cfg; /* rx config register */
  88. u_int32_t rx_pkt_max; /* rx max pkt size */
  89. u_int32_t rx_pkt_min; /* rx min pkt size */
  90. u_int32_t mac_addr2; /* ethernet address 2 (MSB) */
  91. u_int32_t mac_addr1; /* ethernet address 1 */
  92. u_int32_t mac_addr0; /* ethernet address 0 (LSB) */
  93. u_int32_t fr_ctr; /* rx frame receive cntr */
  94. u_int32_t gle_ctr; /* rx giant-len error cntr */
  95. u_int32_t unale_ctr; /* rx unaligned error cntr */
  96. u_int32_t rcrce_ctr; /* rx CRC error cntr */
  97. u_int32_t rx_smachine; /* rx state machine */
  98. u_int32_t rx_cvalid; /* rx code violation */
  99. u_int32_t _unused4; /* reserved */
  100. u_int32_t htable3; /* hash table 3 */
  101. u_int32_t htable2; /* hash table 2 */
  102. u_int32_t htable1; /* hash table 1 */
  103. u_int32_t htable0; /* hash table 0 */
  104. u_int32_t afilter2; /* address filter 2 */
  105. u_int32_t afilter1; /* address filter 1 */
  106. u_int32_t afilter0; /* address filter 0 */
  107. u_int32_t afilter_mask; /* address filter mask */
  108. };
  109. #endif
  110. /* register indices: */
  111. #define BE_BRI_XIFCFG (0*4)
  112. #define BE_BRI_STAT (64*4)
  113. #define BE_BRI_IMASK (65*4)
  114. #define BE_BRI_TXCFG (131*4)
  115. #define BE_BRI_JSIZE (139*4)
  116. #define BE_BRI_NCCNT (144*4)
  117. #define BE_BRI_FCCNT (145*4)
  118. #define BE_BRI_EXCNT (146*4)
  119. #define BE_BRI_LTCNT (147*4)
  120. #define BE_BRI_RANDSEED (148*4)
  121. #define BE_BRI_RXCFG (195*4)
  122. #define BE_BRI_MACADDR2 (198*4)
  123. #define BE_BRI_MACADDR1 (199*4)
  124. #define BE_BRI_MACADDR0 (200*4)
  125. #define BE_BRI_HASHTAB3 (208*4)
  126. #define BE_BRI_HASHTAB2 (209*4)
  127. #define BE_BRI_HASHTAB1 (210*4)
  128. #define BE_BRI_HASHTAB0 (211*4)
  129. /* be_bregs.xif_cfg: XIF config. */
  130. #define BE_BR_XCFG_ODENABLE 0x00000001 /* output driver enable */
  131. #define BE_BR_XCFG_RESV 0x00000002 /* reserved, write as 1 */
  132. #define BE_BR_XCFG_MLBACK 0x00000004 /* loopback-mode mii enable */
  133. #define BE_BR_XCFG_SMODE 0x00000008 /* enable serial mode */
  134. /* be_bregs.stat: status, clear on read. */
  135. #define BE_BR_STAT_GOTFRAME 0x00000001 /* received a frame */
  136. #define BE_BR_STAT_RCNTEXP 0x00000002 /* rx frame cntr expired */
  137. #define BE_BR_STAT_ACNTEXP 0x00000004 /* align-error cntr expired */
  138. #define BE_BR_STAT_CCNTEXP 0x00000008 /* crc-error cntr expired */
  139. #define BE_BR_STAT_LCNTEXP 0x00000010 /* length-error cntr expired */
  140. #define BE_BR_STAT_RFIFOVF 0x00000020 /* rx fifo overflow */
  141. #define BE_BR_STAT_CVCNTEXP 0x00000040 /* code-violation cntr exprd */
  142. #define BE_BR_STAT_SENTFRAME 0x00000100 /* transmitted a frame */
  143. #define BE_BR_STAT_TFIFO_UND 0x00000200 /* tx fifo underrun */
  144. #define BE_BR_STAT_MAXPKTERR 0x00000400 /* max-packet size error */
  145. #define BE_BR_STAT_NCNTEXP 0x00000800 /* normal-collision cntr exp */
  146. #define BE_BR_STAT_ECNTEXP 0x00001000 /* excess-collision cntr exp */
  147. #define BE_BR_STAT_LCCNTEXP 0x00002000 /* late-collision cntr exp */
  148. #define BE_BR_STAT_FCNTEXP 0x00004000 /* first-collision cntr exp */
  149. #define BE_BR_STAT_DTIMEXP 0x00008000 /* defer-timer expired */
  150. #define BE_BR_STAT_BITS "\020" \
  151. "\01GOTFRAME\02RCNTEXP\03ACNTEXP" \
  152. "\04CCNTEXP\05LCNTEXP\06RFIFOVF" \
  153. "\07CVCNTEXP\011SENTFRAME\012TFIFO_UND" \
  154. "\013MAXPKTERR\014NCNTEXP\015ECNTEXP" \
  155. "\016LCCNTEXP\017FCNTEXP\020DTIMEXP"
  156. /* be_bregs.imask: interrupt mask. */
  157. #define BE_BR_IMASK_GOTFRAME 0x00000001 /* received a frame */
  158. #define BE_BR_IMASK_RCNTEXP 0x00000002 /* rx frame cntr expired */
  159. #define BE_BR_IMASK_ACNTEXP 0x00000004 /* align-error cntr expired */
  160. #define BE_BR_IMASK_CCNTEXP 0x00000008 /* crc-error cntr expired */
  161. #define BE_BR_IMASK_LCNTEXP 0x00000010 /* length-error cntr expired */
  162. #define BE_BR_IMASK_RFIFOVF 0x00000020 /* rx fifo overflow */
  163. #define BE_BR_IMASK_CVCNTEXP 0x00000040 /* code-violation cntr exprd */
  164. #define BE_BR_IMASK_SENTFRAME 0x00000100 /* transmitted a frame */
  165. #define BE_BR_IMASK_TFIFO_UND 0x00000200 /* tx fifo underrun */
  166. #define BE_BR_IMASK_MAXPKTERR 0x00000400 /* max-packet size error */
  167. #define BE_BR_IMASK_NCNTEXP 0x00000800 /* normal-collision cntr exp */
  168. #define BE_BR_IMASK_ECNTEXP 0x00001000 /* excess-collision cntr exp */
  169. #define BE_BR_IMASK_LCCNTEXP 0x00002000 /* late-collision cntr exp */
  170. #define BE_BR_IMASK_FCNTEXP 0x00004000 /* first-collision cntr exp */
  171. #define BE_BR_IMASK_DTIMEXP 0x00008000 /* defer-timer expired */
  172. /* be_bregs.tx_cfg: tx config. */
  173. #define BE_BR_TXCFG_ENABLE 0x00000001 /* enable the transmitter */
  174. #define BE_BR_TXCFG_FIFO 0x00000010 /* default tx fthresh */
  175. #define BE_BR_TXCFG_SMODE 0x00000020 /* enable slow transmit mode */
  176. #define BE_BR_TXCFG_CIGN 0x00000040 /* ignore tx collisions */
  177. #define BE_BR_TXCFG_FCSOFF 0x00000080 /* do not emit fcs */
  178. #define BE_BR_TXCFG_DBACKOFF 0x00000100 /* disable backoff */
  179. #define BE_BR_TXCFG_FULLDPLX 0x00000200 /* enable full-duplex */
  180. /* be_bregs.rx_cfg: rx config. */
  181. #define BE_BR_RXCFG_ENABLE 0x00000001 /* enable the receiver */
  182. #define BE_BR_RXCFG_FIFO 0x0000000e /* default rx fthresh */
  183. #define BE_BR_RXCFG_PSTRIP 0x00000020 /* pad byte strip enable */
  184. #define BE_BR_RXCFG_PMISC 0x00000040 /* enable promiscous mode */
  185. #define BE_BR_RXCFG_DERR 0x00000080 /* disable error checking */
  186. #define BE_BR_RXCFG_DCRCS 0x00000100 /* disable crc stripping */
  187. #define BE_BR_RXCFG_ME 0x00000200 /* receive packets for me */
  188. #define BE_BR_RXCFG_PGRP 0x00000400 /* enable promisc group mode */
  189. #define BE_BR_RXCFG_HENABLE 0x00000800 /* enable hash filter */
  190. #define BE_BR_RXCFG_AENABLE 0x00001000 /* enable address filter */
  191. /*
  192. * BE Channel registers
  193. */
  194. #if 0
  195. struct be_cregs {
  196. u_int32_t ctrl; /* control */
  197. u_int32_t stat; /* status */
  198. u_int32_t rxds; /* rx descriptor ring ptr */
  199. u_int32_t txds; /* tx descriptor ring ptr */
  200. u_int32_t rimask; /* rx interrupt mask */
  201. u_int32_t timask; /* tx interrupt mask */
  202. u_int32_t qmask; /* qec error interrupt mask */
  203. u_int32_t bmask; /* be error interrupt mask */
  204. u_int32_t rxwbufptr; /* local memory rx write ptr */
  205. u_int32_t rxrbufptr; /* local memory rx read ptr */
  206. u_int32_t txwbufptr; /* local memory tx write ptr */
  207. u_int32_t txrbufptr; /* local memory tx read ptr */
  208. u_int32_t ccnt; /* collision counter */
  209. };
  210. #endif
  211. /* register indices: */
  212. #define BE_CRI_CTRL (0*4)
  213. #define BE_CRI_STAT (1*4)
  214. #define BE_CRI_RXDS (2*4)
  215. #define BE_CRI_TXDS (3*4)
  216. #define BE_CRI_RIMASK (4*4)
  217. #define BE_CRI_TIMASK (5*4)
  218. #define BE_CRI_QMASK (6*4)
  219. #define BE_CRI_BMASK (7*4)
  220. #define BE_CRI_RXWBUF (8*4)
  221. #define BE_CRI_RXRBUF (9*4)
  222. #define BE_CRI_TXWBUF (10*4)
  223. #define BE_CRI_TXRBUF (11*4)
  224. #define BE_CRI_CCNT (12*4)
  225. /* be_cregs.ctrl: control. */
  226. #define BE_CR_CTRL_TWAKEUP 0x00000001 /* tx dma wakeup */
  227. /* be_cregs.stat: status. */
  228. #define BE_CR_STAT_BERROR 0x80000000 /* be error */
  229. #define BE_CR_STAT_TXIRQ 0x00200000 /* tx interrupt */
  230. #define BE_CR_STAT_TXDERR 0x00080000 /* tx descriptor is bad */
  231. #define BE_CR_STAT_TXLERR 0x00040000 /* tx late error */
  232. #define BE_CR_STAT_TXPERR 0x00020000 /* tx parity error */
  233. #define BE_CR_STAT_TXSERR 0x00010000 /* tx sbus error ack */
  234. #define BE_CR_STAT_RXIRQ 0x00000020 /* rx interrupt */
  235. #define BE_CR_STAT_RXDROP 0x00000010 /* rx packet dropped */
  236. #define BE_CR_STAT_RXSMALL 0x00000008 /* rx buffer too small */
  237. #define BE_CR_STAT_RXLERR 0x00000004 /* rx late error */
  238. #define BE_CR_STAT_RXPERR 0x00000002 /* rx parity error */
  239. #define BE_CR_STAT_RXSERR 0x00000001 /* rx sbus error ack */
  240. /* be_cregs.qmask: qec error interrupt mask. */
  241. #define BE_CR_QMASK_TXDERR 0x00080000 /* tx descriptor is bad */
  242. #define BE_CR_QMASK_TXLERR 0x00040000 /* tx late error */
  243. #define BE_CR_QMASK_TXPERR 0x00020000 /* tx parity error */
  244. #define BE_CR_QMASK_TXSERR 0x00010000 /* tx sbus error ack */
  245. #define BE_CR_QMASK_RXDROP 0x00000010 /* rx packet dropped */
  246. #define BE_CR_QMASK_RXSMALL 0x00000008 /* rx buffer too small */
  247. #define BE_CR_QMASK_RXLERR 0x00000004 /* rx late error */
  248. #define BE_CR_QMASK_RXPERR 0x00000002 /* rx parity error */
  249. #define BE_CR_QMASK_RXSERR 0x00000001 /* rx sbus error ack */
  250. /*
  251. * BE Transceiver registers
  252. */
  253. #if 0
  254. struct be_tregs {
  255. u_int32_t tcvr_pal; /* transceiver pal */
  256. u_int32_t mgmt_pal; /* management pal */
  257. };
  258. #endif
  259. /* register indices: */
  260. #define BE_TRI_TCVRPAL 0
  261. #define BE_TRI_MGMTPAL 4
  262. /* be_tregs.tcvr_pal: transceiver pal */
  263. #define TCVR_PAL_SERIAL 0x00000001 /* serial mode enable */
  264. #define TCVR_PAL_EXTLBACK 0x00000002 /* external loopback */
  265. #define TCVR_PAL_MSENSE 0x00000004 /* media sense */
  266. #define TCVR_PAL_LTENABLE 0x00000008 /* link test enable */
  267. #define TCVR_PAL_LTSTATUS 0x00000010 /* link test status: p1 only */
  268. #define TCVR_PAL_BITS "\020" \
  269. "\01SERIAL\02EXTLBACK\03MSENSE" \
  270. "\04LTENABLE\05LTSTATUS"
  271. /* be_tregs.mgmt_pal: management pal */
  272. #define MGMT_PAL_DCLOCK 0x00000001 /* data clock strobe */
  273. #define MGMT_PAL_OENAB 0x00000002 /* output enable */
  274. #define MGMT_PAL_MDIO 0x00000004 /* MDIO data/attached */
  275. #define MGMT_PAL_EXT_MDIO MGMT_PAL_MDIO /* external mdio */
  276. #define MGMT_PAL_EXT_MDIO_SHIFT 2 /* position of ext mdio bit */
  277. #define MGMT_PAL_TIMEO 0x00000008 /* tx enable timeout error */
  278. #define MGMT_PAL_INT_MDIO MGMT_PAL_TIMEO /* internal mdio */
  279. #define MGMT_PAL_INT_MDIO_SHIFT 3 /* position of int mdio bit */
  280. #define MGMT_PAL_BITS "\020" \
  281. "\01DLCLOCK\02ENAB\03EXT_MDIO" \
  282. "\04INT_MDIO"
  283. /* Packet buffer size */
  284. #define BE_PKT_BUF_SZ 2048
  285. #define MC_POLY_BE 0x04c11db7UL /* mcast crc, big endian */
  286. #define MC_POLY_LE 0xedb88320UL /* mcast crc, little endian */
  287. /* PHY addresses */
  288. #define BE_PHY_EXTERNAL 0
  289. #define BE_PHY_INTERNAL 1