/efe/src/efe.h

https://bitbucket.org/0xffea/driver-gate · C++ Header · 458 lines · 350 code · 61 blank · 47 comment · 0 complexity · 25194e03e38de7725189f62460f93a88 MD5 · raw file

  1. /*
  2. * Copyright (c) 2010 Steven Stallion. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are
  6. * met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above
  11. * copyright notice, this list of conditions and the following
  12. * disclaimer in the documentation and/or other materials provided
  13. * with the distribution.
  14. * 3. Neither the name of the copyright owner nor the names of any
  15. * contributors may be used to endorse or promote products derived
  16. * from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
  19. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  21. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  22. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  23. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  24. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  25. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  26. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  27. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #ifndef _EFE_H
  31. #define _EFE_H
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. #define VENDOR_ID 0x10B8
  36. #define DEVICE_ID 0x0005
  37. #define RESET_DELAY 1
  38. #define RESET_TEST_CYCLES 16
  39. #define STOP_DELAY 10
  40. #define STOP_DELAY_CYCLES 160
  41. #define MII_DELAY 1
  42. #define MII_DELAY_CYCLES 16
  43. #define EEPROM_DELAY 3
  44. #define EEPROM_WORDSZ 16
  45. #define AT93C46_ADDRLEN 6
  46. #define AT93C56_ADDRLEN 8
  47. #define FLAG_RUNNING (1UL << 0)
  48. #define FLAG_SUSPENDED (1UL << 1)
  49. #define MCHASHL 64
  50. #define MCHASHSZ 16
  51. #define BURSTLEN 0x3F
  52. #define RXDESCL 128
  53. #define TXDESCL 128
  54. #define BUFSZ 1536
  55. /*
  56. * Control/Status registers.
  57. */
  58. #define CSR_COMMAND 0x00 /* Control Register */
  59. #define CSR_INTSTAT 0x04 /* Interrupt Status Register */
  60. #define CSR_INTMASK 0x08 /* Interrupt Mask Register */
  61. #define CSR_GENCTL 0x0C /* General Control Register */
  62. #define CSR_NVCTL 0x10 /* Non-volatile Control Register */
  63. #define CSR_EECTL 0x14 /* EEPROM Control Register */
  64. #define CSR_PBLCNT 0x18 /* Programmable Burst Length Counter */
  65. #define CSR_TEST 0x1C /* Test Register */
  66. #define CSR_CRCCNT 0x20 /* CRC Error Counter */
  67. #define CSR_ALICNT 0x24 /* Frame Alignment Error Counter */
  68. #define CSR_MPCNT 0x28 /* Missed Packet Counter */
  69. #define CSR_RXFIFO 0x2C /* Receive FIFO Contents */
  70. #define CSR_MMCTL 0x30 /* MII Control Register */
  71. #define CSR_MMDATA 0x34 /* MII Interface Register */
  72. #define CSR_MMCFG 0x38 /* MII Configuration Register */
  73. #define CSR_IPG 0x3C /* Interpacket Gap Register */
  74. #define CSR_LAN0 0x40 /* LAN Address Register 0 */
  75. #define CSR_LAN1 0x44 /* LAN Address Register 1 */
  76. #define CSR_LAN2 0x48 /* LAN Address Register 2 */
  77. #define CSR_IDCHK 0x4C /* Board ID/Checksum Register */
  78. #define CSR_MC0 0x50 /* Multicast Address Register 0 */
  79. #define CSR_MC1 0x54 /* Multicast Address Register 1 */
  80. #define CSR_MC2 0x58 /* Multicast Address Register 2 */
  81. #define CSR_MC3 0x5C /* Multicast Address Register 3 */
  82. #define CSR_RXCON 0x60 /* Receive Control Register */
  83. #define CSR_RXSTAT 0x64 /* Receive Status Register */
  84. #define CSR_RXCNT 0x68 /* Receive Byte Count */
  85. #define CSR_RXTEST 0x6C /* Receive Test */
  86. #define CSR_TXCON 0x70 /* Transmit Control Register */
  87. #define CSR_TXSTAT 0x74 /* Transmit Status Register */
  88. #define CSR_TDPAR 0x78 /* Transmit Packet Address */
  89. #define CSR_TXTEST 0x7C /* Transmit Test */
  90. #define CSR_PRFDAR 0x80 /* PCI Receive First Descriptor Address */
  91. #define CSR_PRCDAR 0x84 /* PCI Receive Current Descriptor Address */
  92. #define CSR_PRHDAR 0x88 /* PCI Receive Host Data Address */
  93. #define CSR_PRFLAR 0x8C /* PCI Receive Fragment List Address */
  94. #define CSR_PRDLGTH 0x90 /* PCI Receive DMA Length/Control */
  95. #define CSR_PRFCNT 0x94 /* PCI Receive Fragment Count */
  96. #define CSR_PRLCAR 0x98 /* PCI Receive RAM Current Address */
  97. #define CSR_PRLPAR 0x9C /* PCI Receive RAM Packet Address */
  98. #define CSR_PREFAR 0xA0 /* PCI Receive End of Frame Address */
  99. #define CSR_PRSTAT 0xA4 /* PCI Receive DMA Status Register */
  100. #define CSR_PRBUF 0xA8 /* Receive RAM Buffer */
  101. #define CSR_RDNCAR 0xAC /* Receive MTU Current Address */
  102. #define CSR_PRCPTHR 0xB0 /* PCI Receive Copy Threshold Register */
  103. #define CSR_ROMDATA 0xB4 /* ROMDATA */
  104. #define CSR_PREEMPR 0xBC /* Preemptive Interrupt */
  105. #define CSR_PTFDAR 0xC0 /* PCI Transmit First Descriptor Address */
  106. #define CSR_PTCDAR 0xC4 /* PCI Transmit Current Descriptor Address */
  107. #define CSR_PTHDAR 0xC8 /* PCI Transmit Host Data Address */
  108. #define CSR_PTFLAR 0xCC /* PCI Transmit Fragment List Address */
  109. #define CSR_PTDLGTH 0xD0 /* PCI Transmit DMA Length/Control */
  110. #define CSR_PTFCNT 0xD4 /* PCI Transmit Fragment Count */
  111. #define CSR_PTLCAR 0xD8 /* PCI Transmit RAM Current Address */
  112. #define CSR_ETXTHR 0xDC /* PCI Early Transmit Threshold Register */
  113. #define CSR_PTETXC 0xE0 /* PCI Early Transmit Count */
  114. #define CSR_PTSTAT 0xE4 /* PCI Transmit DMA Status */
  115. #define CSR_PTBUF 0xE8 /* Transmit RAM Buffer */
  116. #define CSR_PTFDAR2 0xEC /* PCI Transmit 2 First Descriptor Address */
  117. #define CSR_FEVTR 0xF0 /* CardBus (UNUSED) */
  118. #define CSR_FEVTRMSKR 0xF4 /* CardBus (UNUSED) */
  119. #define CSR_FPRSTSTR 0xF8 /* CardBus (UNUSED) */
  120. #define CSR_FFRCEVTR 0xFF /* CardBus (UNUSED) */
  121. /*
  122. * Register fields.
  123. */
  124. #define COMMAND_STOP_RX (1UL << 0) /* Stop Receiver */
  125. #define COMMAND_START_RX (1UL << 1) /* Start Receiver */
  126. #define COMMAND_TXQUEUED (1UL << 2) /* Queue TX Descriptor */
  127. #define COMMAND_RXQUEUED (1UL << 3) /* Queue RX Descriptor */
  128. #define COMMAND_NEXTFRAME (1UL << 4) /* Release RX Frame */
  129. #define COMMAND_STOP_TDMA (1UL << 5) /* Stop TX DMA */
  130. #define COMMAND_STOP_RDMA (1UL << 6) /* Stop RX DMA */
  131. #define COMMAND_TXUGO (1UL << 7) /* Restart Transmission */
  132. #define INTSTAT_RCC (1UL << 0) /* Receive Copy Complete */
  133. #define INTSTAT_HCC (1UL << 1) /* Header Copy Complete */
  134. #define INTSTAT_RQE (1UL << 2) /* Receive Queue Empty */
  135. #define INTSTAT_OVW (1UL << 3) /* Receive Overflow */
  136. #define INTSTAT_RXE (1UL << 4) /* Receive Error */
  137. #define INTSTAT_TXC (1UL << 5) /* Transmit Complete */
  138. #define INTSTAT_TCC (1UL << 6) /* Transmit Chain Complete */
  139. #define INTSTAT_TQE (1UL << 7) /* Transmit Queue Empty */
  140. #define INTSTAT_TXU (1UL << 8) /* Transmit Underrun */
  141. #define INTSTAT_CNT (1UL << 9) /* Counter Overflow */
  142. #define INTSTAT_PREI (1UL << 10) /* Preemptive Interrupt */
  143. #define INTSTAT_RCT (1UL << 11) /* Receive Copy Threshold */
  144. #define INTSTAT_FATAL (1UL << 12) /* Fatal Error */
  145. #define INTSTAT_PME (1UL << 14) /* Power Management Event */
  146. #define INTSTAT_GP2 (1UL << 15) /* GPIO Event */
  147. #define INTSTAT_ACTV (1UL << 16) /* Interrupt Active */
  148. #define INTSTAT_RXIDLE (1UL << 17) /* Receive Idle */
  149. #define INTSTAT_TXIDLE (1UL << 18) /* Transmit Idle */
  150. #define INTSTAT_RCIP (1UL << 19) /* Receive Copy in Progress */
  151. #define INTSTAT_TCIP (1UL << 20) /* Transmit Copy in Progress */
  152. #define INTSTAT_RBE (1UL << 21) /* Receive Buffers Empty */
  153. #define INTSTAT_RCTS (1UL << 22) /* Receive Copy Threshold Status */
  154. #define INTSTAT_RSV (1UL << 23) /* Receive Status Valid */
  155. #define INTSTAT_DPE (1UL << 24) /* PCI Data Parity Error */
  156. #define INTSTAT_APE (1UL << 25) /* PCI Address Parity Error */
  157. #define INTSTAT_PMA (1UL << 26) /* PCI Master Abort */
  158. #define INTSTAT_PTA (1UL << 27) /* PCI Target Abort */
  159. #define INTMASK_RCC (1UL << 0) /* Receive Copy Complete */
  160. #define INTMASK_HCC (1UL << 1) /* Header Copy Complete */
  161. #define INTMASK_RQE (1UL << 2) /* Receive Queue Empty */
  162. #define INTMASK_OVW (1UL << 3) /* Receive Overflow */
  163. #define INTMASK_RXE (1UL << 4) /* Receive Error */
  164. #define INTMASK_TXC (1UL << 5) /* Transmit Complete */
  165. #define INTMASK_TCC (1UL << 6) /* Transmit Chain Complete */
  166. #define INTMASK_TQE (1UL << 7) /* Transmit Queue Empty */
  167. #define INTMASK_TXU (1UL << 8) /* Transmit Underrun */
  168. #define INTMASK_CNT (1UL << 9) /* Counter Overflow */
  169. #define INTMASK_PREI (1UL << 10) /* Preemptive Interrupt */
  170. #define INTMASK_RCT (1UL << 11) /* Receive Copy Threshold */
  171. #define INTMASK_FATAL (1UL << 12) /* Fatal Error */
  172. #define INTMASK_PME (1UL << 14) /* Power Management Event */
  173. #define INTMASK_GP2 (1UL << 15) /* GPIO Event */
  174. #define GENCTL_RESET (1UL << 0) /* Soft Reset */
  175. #define GENCTL_INT (1UL << 1) /* Interrupt Enable */
  176. #define GENCTL_SWINT (1UL << 2) /* Software Interrupt */
  177. #define GENCTL_PWRDWN (1UL << 3) /* Power Down */
  178. #define GENCTL_ONECOPY (1UL << 4) /* One Copy per Receive Frame */
  179. #define GENCTL_BE (1UL << 5) /* Big Endian */
  180. #define GENCTL_RDP (1UL << 6) /* Receive DMA Priority */
  181. #define GENCTL_TDP (1UL << 7) /* Transmit DMA Priority */
  182. #define GENCTL_RFT_32 (0UL << 8) /* Receive FIFO Threshold (1/4) */
  183. #define GENCTL_RFT_64 (1UL << 8) /* Receive FIFO Threshold (1/2) */
  184. #define GENCTL_RFT_96 (2UL << 8) /* Receive FIFO Threshold (3/4) */
  185. #define GENCTL_RFT_128 (3UL << 8) /* Receive FIFO Threshold (FULL) */
  186. #define GENCTL_MRM (1UL << 10) /* Memory Read Multiple */
  187. #define GENCTL_MRL (1UL << 11) /* Memory Read Line */
  188. #define GENCTL_SOFT0 (1UL << 12) /* Software Bit 0 */
  189. #define GENCTL_SOFT1 (1UL << 13) /* Software Bit 1 */
  190. #define GENCTL_RSTPHY (1UL << 14) /* PHY Reset */
  191. #define GENCTL_SCLK (1UL << 16) /* System Clock */
  192. #define GENCTL_RD (1UL << 17) /* Reset Disable */
  193. #define GENCTL_MPE (1UL << 18) /* Magic Packet Enable */
  194. #define GENCTL_PME (1UL << 19) /* PME Interrupt Enable */
  195. #define GENCTL_PS_00 (0UL << 20) /* Power State "00" */
  196. #define GENCTL_PS_01 (1UL << 20) /* Power State "01" */
  197. #define GENCTL_PS_10 (2UL << 20) /* Power State "10" */
  198. #define GENCTL_PS_11 (3UL << 20) /* Power State "11" */
  199. #define GENCTL_OPLE (1UL << 22) /* On Power Loss Enable */
  200. #define NVCTL_EMM (1UL << 0) /* Enable Memory Map */
  201. #define NVCTL_CRS (1UL << 1) /* Clock Run Supported */
  202. #define NVCTL_GPOE1 (1UL << 2) /* General Purpose Output Enable 1 */
  203. #define NVCTL_GPOE2 (1UL << 3) /* General Purpose Output Enable 2 */
  204. #define NVCTL_GPIO1 (1UL << 4) /* General Purpose I/O 1 */
  205. #define NVCTL_GPIO2 (1UL << 5) /* General Purpose I/O 2 */
  206. #define NVCTL_CB_MODE (1UL << 6) /* CardBus (UNUSED) */
  207. #define NVCTL_IPG_DLY 7 /* Inter-packet Gap Timer Delay */
  208. #define EECTL_ENABLE (1UL << 0) /* EEPROM Enable */
  209. #define EECTL_EECS (1UL << 1) /* EEPROM Chip Select */
  210. #define EECTL_EESK (1UL << 2) /* EEPROM Clock */
  211. #define EECTL_EEDI (1UL << 3) /* EEPROM Data Input */
  212. #define EECTL_EEDO (1UL << 4) /* EEPROM Data Output */
  213. #define EECTL_EERDY (1UL << 5) /* EEPROM Ready */
  214. #define EECTL_SIZE (1UL << 6) /* EEPROM Size */
  215. #define TEST_CLOCK (1UL << 3) /* Clock Test */
  216. #define MMCTL_READ (1UL << 0) /* MII Read */
  217. #define MMCTL_WRITE (1UL << 1) /* MII Write */
  218. #define MMCTL_RESPONDER (1UL << 3) /* MII Responder */
  219. #define MMCTL_PHYREG 4 /* PHY Address */
  220. #define MMCTL_PHYADDR 9 /* PHY Register Address */
  221. #define MMCFG_SME (1UL << 0) /* Serial Mode Enable */
  222. #define MMCFG_EN694 (1UL << 1) /* EN694 Pin */
  223. #define MMCFG_694LNK (1UL << 2) /* 694LNK Pin */
  224. #define MMCFG_PHY (1UL << 3) /* PHY Present */
  225. #define MMCFG_SMI (1UL << 4) /* Enable Serial Management */
  226. #define MMCFG_ALTCS (1UL << 5) /* Alternate Clock Source */
  227. #define MMCFG_ALTDATA (1UL << 6) /* Alternate Data */
  228. #define MMCFG_STXC (1UL << 14) /* Select TX Clock */
  229. #define MMCFG_SNTXC (1UL << 15) /* Set No TX Clock */
  230. #define RXCON_SEP (1UL << 0) /* Save Errored Packets */
  231. #define RXCON_RRF (1UL << 1) /* Receive Runt Frames */
  232. #define RXCON_RBF (1UL << 2) /* Receive Broadcast Frames */
  233. #define RXCON_RMF (1UL << 3) /* Receive Multicast Frames */
  234. #define RXCON_RIIA (1UL << 4) /* Receive Inverse Addresses */
  235. #define RXCON_PROMISC (1UL << 5) /* Promiscuous Mode */
  236. #define RXCON_MONITOR (1UL << 6) /* Monitor Mode */
  237. #define RXCON_ERE (1UL << 7) /* Early Receive Enable */
  238. #define RXCON_EB_INT (0UL << 8) /* External Buffer (Inernal) */
  239. #define RXCON_EB_16K (1UL << 8) /* External Buffer (16K) */
  240. #define RXCON_EB_32K (2UL << 8) /* External Buffer (32K) */
  241. #define RXCON_EB_128K (3UL << 8) /* External Buffer (128K) */
  242. #define RXSTAT_PRI (1UL << 0) /* Packet Received Intact */
  243. #define RXSTAT_FAE (1UL << 1) /* Frame Alignment Error */
  244. #define RXSTAT_CRC (1UL << 2) /* CRC Error */
  245. #define RXSTAT_MP (1UL << 3) /* Missed Packet */
  246. #define RXSTAT_MAR (1UL << 4) /* Multicast Address Recognized */
  247. #define RXSTAT_BAR (1UL << 5) /* Broadcast Address Recognized */
  248. #define RXSTAT_RD (1UL << 6) /* Receiver Disabled */
  249. #define RXSTAT_NSV (1UL << 12) /* Network Status Valid */
  250. #define RXSTAT_FLE (1UL << 13) /* Fragment List Error */
  251. #define RXSTAT_HC (1UL << 14) /* Header Copied */
  252. #define RXSTAT_OWNER (1UL << 15) /* Descriptor Ownership Bit */
  253. #define RXCTL_FRAGLIST (1UL << 0) /* Fragment List */
  254. #define RXCTL_LFFORM (1UL << 1) /* Fragment List Format */
  255. #define RXCTL_HEADER (1UL << 2) /* Header Copy */
  256. #define TXCON_ETE (1UL << 0) /* Early Transmit Enable */
  257. #define TXCON_LB_0 (0UL << 1) /* Normal Operation */
  258. #define TXCON_LB_1 (1UL << 1) /* Internal Loopback */
  259. #define TXCON_LB_2 (2UL << 1) /* External Loopback */
  260. #define TXCON_LB_3 (3UL << 1) /* Full Duplex Mode */
  261. #define TXCON_SLOT 3 /* Slot Time */
  262. #define TXSTAT_PTX (1UL << 0) /* Packet Transmitted */
  263. #define TXSTAT_ND (1UL << 1) /* Non-deferred Transmission */
  264. #define TXSTAT_COLL (1UL << 2) /* Transmitted w/Collisions */
  265. #define TXSTAT_CSL (1UL << 3) /* Carrier Sense Lost */
  266. #define TXSTAT_UFLO (1UL << 4) /* TX Underrun */
  267. #define TXSTAT_CDH (1UL << 5) /* Collision Detect Heartbeat */
  268. #define TXSTAT_OWC (1UL << 6) /* Out of Window Collision */
  269. #define TXSTAT_DEFER (1UL << 7) /* IGP Deferring */
  270. #define TXSTAT_CCNT 8 /* Collision Count */
  271. #define TXSTAT_CCNTMASK 0x1F /* Collision Count Mask */
  272. #define TXSTAT_EXCOLL (1UL << 12) /* Excessive Collisions */
  273. #define TXSTAT_OWNER (1UL << 15) /* Descriptor Ownership Bit */
  274. #define TXCTL_FRAGLIST (1UL << 0) /* Fragment List */
  275. #define TXCTL_LFFORM (1UL << 1) /* Fragment List Format */
  276. #define TXCTL_IAF (1UL << 2) /* Interrupt After Frame */
  277. #define TXCTL_NOCRC (1UL << 3) /* Disable CRC Generation */
  278. #define TXCTL_LASTDESCR (1UL << 4) /* Last Transmit Descriptor */
  279. /*
  280. * Register access.
  281. */
  282. #define GETCSR(efep, reg) \
  283. ddi_get32((efep)->efe_regs_acch, \
  284. (uint32_t *)((efep)->efe_regs + (reg)))
  285. #define PUTCSR(efep, reg, val) \
  286. ddi_put32((efep)->efe_regs_acch, \
  287. (uint32_t *)((efep)->efe_regs + (reg)), (val))
  288. #define CLRBIT(efep, reg, bit) \
  289. PUTCSR(efep, reg, (GETCSR(efep, reg) & ~(bit)))
  290. #define SETBIT(efep, reg, bit) \
  291. PUTCSR(efep, reg, (GETCSR(efep, reg) | (bit)))
  292. /*
  293. * DMA access.
  294. */
  295. #define DESCSZ(x) (sizeof (efe_desc_t) * (x))
  296. #define BUFPSZ(x) (sizeof (efe_buf_t *) * (x))
  297. #define DESCADDR(rp, x) ((rp)->r_dmac.dmac_address + DESCSZ(x))
  298. #define DESCLEN(rp) ((rp)->r_len)
  299. #define BUFADDR(bp) ((bp)->b_dmac.dmac_address)
  300. #define BUFLEN(bp) ((bp)->b_len)
  301. #define NEXTDESC(rp, x) (((x) + 1) % (rp)->r_len)
  302. #define NEXTDESCADDR(rp, x) DESCADDR(rp, NEXTDESC(rp, x))
  303. #define GETDESC(rp, x) (&(rp)->r_descp[(x)])
  304. #define GETDESC16(rp, addr) \
  305. ddi_get16((rp)->r_acch, (addr))
  306. #define PUTDESC16(rp, addr, val) \
  307. ddi_put16((rp)->r_acch, (addr), (val))
  308. #define GETDESC32(rp, addr) \
  309. ddi_get32((rp)->r_acch, (addr))
  310. #define PUTDESC32(rp, addr, val) \
  311. ddi_put32((rp)->r_acch, (addr), (val))
  312. #define SYNCDESC(rp, x, type) \
  313. (void) ddi_dma_sync((rp)->r_dmah, DESCSZ(x), \
  314. sizeof (efe_desc_t), (type))
  315. #define GETBUF(rp, x) ((rp)->r_bufpp[(x)])
  316. #define SYNCBUF(bp, type) \
  317. (void) ddi_dma_sync((bp)->b_dmah, 0, (bp)->b_len, (type))
  318. /*
  319. * Soft state.
  320. */
  321. typedef struct {
  322. uint16_t d_status;
  323. uint16_t d_len;
  324. uint32_t d_bufaddr;
  325. uint16_t d_buflen;
  326. uint16_t d_control;
  327. uint32_t d_next;
  328. } efe_desc_t;
  329. typedef struct {
  330. ddi_dma_handle_t b_dmah;
  331. ddi_acc_handle_t b_acch;
  332. ddi_dma_cookie_t b_dmac;
  333. size_t b_len;
  334. caddr_t b_kaddr;
  335. } efe_buf_t;
  336. typedef struct {
  337. ddi_dma_handle_t r_dmah;
  338. ddi_acc_handle_t r_acch;
  339. ddi_dma_cookie_t r_dmac;
  340. size_t r_len;
  341. efe_desc_t *r_descp;
  342. efe_buf_t **r_bufpp;
  343. } efe_ring_t;
  344. typedef struct {
  345. dev_info_t *efe_dip;
  346. mii_handle_t efe_miih;
  347. mac_handle_t efe_mh;
  348. uint32_t *efe_regs;
  349. ddi_acc_handle_t efe_regs_acch;
  350. ddi_intr_handle_t efe_intrh;
  351. kmutex_t efe_intrlock;
  352. kmutex_t efe_txlock;
  353. int efe_flags;
  354. boolean_t efe_promisc;
  355. uint8_t efe_macaddr[ETHERADDRL];
  356. uint_t efe_mccount[MCHASHL];
  357. uint16_t efe_mchash[MCHASHL / MCHASHSZ];
  358. efe_ring_t *efe_rx_ring;
  359. uint_t efe_rx_desc;
  360. efe_ring_t *efe_tx_ring;
  361. uint_t efe_tx_desc;
  362. uint_t efe_tx_sent;
  363. /*
  364. * Driver statistics.
  365. */
  366. uint64_t efe_multircv;
  367. uint64_t efe_brdcstrcv;
  368. uint64_t efe_multixmt;
  369. uint64_t efe_brdcstxmt;
  370. uint64_t efe_norcvbuf;
  371. uint64_t efe_ierrors;
  372. uint64_t efe_noxmtbuf;
  373. uint64_t efe_oerrors;
  374. uint64_t efe_collisions;
  375. uint64_t efe_rbytes;
  376. uint64_t efe_ipackets;
  377. uint64_t efe_obytes;
  378. uint64_t efe_opackets;
  379. uint64_t efe_uflo;
  380. uint64_t efe_oflo;
  381. uint64_t efe_align_errors;
  382. uint64_t efe_fcs_errors;
  383. uint64_t efe_first_collisions;
  384. uint64_t efe_tx_late_collisions;
  385. uint64_t efe_defer_xmts;
  386. uint64_t efe_ex_collisions;
  387. uint64_t efe_macxmt_errors;
  388. uint64_t efe_carrier_errors;
  389. uint64_t efe_toolong_errors;
  390. uint64_t efe_macrcv_errors;
  391. uint64_t efe_runt_errors;
  392. uint64_t efe_jabber_errors;
  393. } efe_t;
  394. #ifdef __cplusplus
  395. }
  396. #endif
  397. #endif /* _EFE_H */