4 * @brief Device driver implementation declarations for the
5 * Intel Pro/1000 Gigabit Ethernet card(s).
7 * Parts of this code is based on the DragonflyBSD (FreeBSD)
8 * implementation, and the fxp driver for Minix 3.
10 * @see http://svn.freebsd.org/viewvc/base/head/sys/dev/e1000/
13 * @author Niek Linnenbank <nieklinnenbank@gmail.com>
14 * @date September 2009
21 #include <minix/drivers.h>
24 #include <net/gen/ether.h>
25 #include <net/gen/eth_io.h>
26 #include <machine/pci.h>
35 /** Number of receive descriptors per card. */
36 #define E1000_RXDESC_NR 256
38 /** Number of transmit descriptors per card. */
39 #define E1000_TXDESC_NR 256
41 /** Number of I/O vectors to use. */
42 #define E1000_IOVEC_NR 16
44 /** Size of each I/O buffer per descriptor. */
45 #define E1000_IOBUF_SIZE 2048
47 /** Debug verbosity. */
48 #define E1000_VERBOSE 1
50 /** MAC address override variable. */
51 #define E1000_ENVVAR "E1000ETH"
62 /** Card has been detected on the PCI bus. */
63 #define E1000_DETECTED (1 << 0)
65 /** Card is enabled. */
66 #define E1000_ENABLED (1 << 1)
68 /** Client has requested to receive packets. */
69 #define E1000_READING (1 << 2)
71 /** Client has requested to write packets. */
72 #define E1000_WRITING (1 << 3)
74 /** Received some packets on the card. */
75 #define E1000_RECEIVED (1 << 4)
77 /** Transmitted some packets on the card. */
78 #define E1000_TRANSMIT (1 << 5)
90 * @brief Print a debug message.
91 * @param level Debug verbosity level.
92 * @param args Arguments to printf().
94 #define E1000_DEBUG(level, args) \
95 if ((level) <= E1000_VERBOSE) \
101 * Read a byte from flash memory.
102 * @param e e1000_t pointer.
103 * @param reg Register offset.
105 #define E1000_READ_FLASH_REG(e,reg) \
106 *(u32_t *) (((e)->flash) + (reg))
109 * Read a 16-bit word from flash memory.
110 * @param e e1000_t pointer.
111 * @param reg Register offset.
113 #define E1000_READ_FLASH_REG16(e,reg) \
114 *(u16_t *) (((e)->flash) + (reg))
117 * Write a 16-bit word to flash memory.
118 * @param e e1000_t pointer.
119 * @param reg Register offset.
120 * @param value New value.
122 #define E1000_WRITE_FLASH_REG(e,reg,value) \
123 *((u32_t *) (((e)->flash) + (reg))) = (value)
126 * Write a 16-bit word to flash memory.
127 * @param e e1000_t pointer.
128 * @param reg Register offset.
129 * @param value New value.
131 #define E1000_WRITE_FLASH_REG16(e,reg,value) \
132 *((u16_t *) (((e)->flash) + (reg))) = (value)
139 * @brief Describes the state of an Intel Pro/1000 card.
143 char name
[8]; /**< String containing the device name. */
144 int status
; /**< Describes the card's current state. */
145 int irq
; /**< Interrupt Request Vector. */
146 int irq_hook
; /**< Interrupt Request Vector Hook. */
147 int revision
; /**< Hardware Revision Number. */
148 u8_t
*regs
; /**< Memory mapped hardware registers. */
149 u8_t
*flash
; /**< Optional flash memory. */
150 u32_t flash_base_addr
; /**< Flash base address. */
151 ether_addr_t address
; /**< Ethernet MAC address. */
152 u16_t (*eeprom_read
)(void *, int reg
); /**< Function to read
154 int eeprom_done_bit
; /**< Offset of the EERD.DONE bit. */
155 int eeprom_addr_off
; /**< Offset of the EERD.ADDR field. */
157 e1000_rx_desc_t
*rx_desc
; /**< Receive Descriptor table. */
158 phys_bytes rx_desc_p
; /**< Physical Receive Descriptor Address. */
159 int rx_desc_count
; /**< Number of Receive Descriptors. */
160 char *rx_buffer
; /**< Receive buffer returned by malloc(). */
161 int rx_buffer_size
; /**< Size of the receive buffer. */
163 e1000_tx_desc_t
*tx_desc
; /**< Transmit Descriptor table. */
164 phys_bytes tx_desc_p
; /**< Physical Transmit Descriptor Address. */
165 int tx_desc_count
; /**< Number of Transmit Descriptors. */
166 char *tx_buffer
; /**< Transmit buffer returned by malloc(). */
167 int tx_buffer_size
; /**< Size of the transmit buffer. */
169 int client
; /**< Process ID being served by e1000. */
170 message rx_message
; /**< Read message received from client. */
171 message tx_message
; /**< Write message received from client. */
172 size_t rx_size
; /**< Size of one packet received. */
176 #endif /* __E1000_H */