iPXE
exanic.h
Go to the documentation of this file.
1#ifndef _EXANIC_H
2#define _EXANIC_H
3
4/** @file
5 *
6 * Exablaze ExaNIC driver
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11
12#include <stdint.h>
13#include <ipxe/pci.h>
14#include <ipxe/ethernet.h>
15#include <ipxe/retry.h>
16#include <ipxe/i2c.h>
17#include <ipxe/bitbash.h>
18
19/** Maximum number of ports */
20#define EXANIC_MAX_PORTS 8
21
22/** Register BAR */
23#define EXANIC_REGS_BAR PCI_BASE_ADDRESS_0
24
25/** Transmit region BAR */
26#define EXANIC_TX_BAR PCI_BASE_ADDRESS_2
27
28/** Alignment for DMA regions */
29#define EXANIC_ALIGN 0x1000
30
31/** Flag for 32-bit DMA addresses */
32#define EXANIC_DMA_32_BIT 0x00000001UL
33
34/** Register set length */
35#define EXANIC_REGS_LEN 0x2000
36
37/** Transmit feedback region length */
38#define EXANIC_TXF_LEN 0x1000
39
40/** Transmit feedback slot
41 *
42 * This is a policy decision.
43 */
44#define EXANIC_TXF_SLOT( index ) ( 0x40 * (index) )
45
46/** Receive region length */
47#define EXANIC_RX_LEN 0x200000
48
49/** Transmit feedback base address register */
50#define EXANIC_TXF_BASE 0x0014
51
52/** Capabilities register */
53#define EXANIC_CAPS 0x0038
54#define EXANIC_CAPS_100M 0x01000000UL /**< 100Mbps supported */
55#define EXANIC_CAPS_1G 0x02000000UL /**< 1Gbps supported */
56#define EXANIC_CAPS_10G 0x04000000UL /**< 10Gbps supported */
57#define EXANIC_CAPS_40G 0x08000000UL /**< 40Gbps supported */
58#define EXANIC_CAPS_100G 0x10000000UL /**< 100Gbps supported */
59#define EXANIC_CAPS_SPEED_MASK 0x1f000000UL /**< Supported speeds mask */
60
61/** I2C GPIO register */
62#define EXANIC_I2C 0x012c
63
64/** Power control register */
65#define EXANIC_POWER 0x0138
66#define EXANIC_POWER_ON 0x000000f0UL /**< Power on PHYs */
67
68/** Port register offset */
69#define EXANIC_PORT_REGS( index ) ( 0x0200 + ( 0x40 * (index) ) )
70
71/** Port enable register */
72#define EXANIC_PORT_ENABLE 0x0000
73#define EXANIC_PORT_ENABLE_ENABLED 0x00000001UL /**< Port is enabled */
74
75/** Port speed register */
76#define EXANIC_PORT_SPEED 0x0004
77
78/** Port status register */
79#define EXANIC_PORT_STATUS 0x0008
80#define EXANIC_PORT_STATUS_LINK 0x00000008UL /**< Link is up */
81#define EXANIC_PORT_STATUS_ABSENT 0x80000000UL /**< Port is not present */
82
83/** Port MAC address (second half) register */
84#define EXANIC_PORT_MAC 0x000c
85
86/** Port flags register */
87#define EXANIC_PORT_FLAGS 0x0010
88#define EXANIC_PORT_FLAGS_PROMISC 0x00000001UL /**< Promiscuous mode */
89
90/** Port receive chunk base address register */
91#define EXANIC_PORT_RX_BASE 0x0014
92
93/** Port transmit command register */
94#define EXANIC_PORT_TX_COMMAND 0x0020
95
96/** Port transmit region offset register */
97#define EXANIC_PORT_TX_OFFSET 0x0024
98
99/** Port transmit region length register */
100#define EXANIC_PORT_TX_LEN 0x0028
101
102/** Port MAC address (first half) register */
103#define EXANIC_PORT_OUI 0x0030
104
105/** Port interrupt configuration register */
106#define EXANIC_PORT_IRQ 0x0034
107
108/** An ExaNIC transmit chunk descriptor */
110 /** Feedback ID */
112 /** Feedback slot */
114 /** Payload length (including padding */
116 /** Payload type */
118 /** Flags */
120} __attribute__ (( packed ));
121
122/** An ExaNIC transmit chunk */
124 /** Descriptor */
126 /** Padding */
128 /** Payload data */
130} __attribute__ (( packed ));
131
132/** Raw Ethernet frame type */
133#define EXANIC_TYPE_RAW 0x01
134
135/** An ExaNIC receive chunk descriptor */
137 /** Timestamp */
139 /** Status (valid only on final chunk) */
141 /** Length (zero except on the final chunk) */
143 /** Filter number */
145 /** Generation */
147} __attribute__ (( packed ));
148
149/** An ExaNIC receive chunk */
151 /** Payload data */
153 /** Descriptor */
155} __attribute__ (( packed ));
156
157/** Receive status error mask */
158#define EXANIC_STATUS_ERROR_MASK 0x0f
159
160/** Number of receive chunks */
161#define EXANIC_RX_COUNT ( EXANIC_RX_LEN / sizeof ( struct exanic_rx_chunk ) )
162
163/** An ExaNIC I2C bus configuration */
165 /** GPIO bit for pulling SCL low */
167 /** GPIO bit for pulling SDA low */
169 /** GPIO bit for reading SDA */
171};
172
173/** EEPROM address */
174#define EXANIC_EEPROM_ADDRESS 0x50
175
176/** An ExaNIC port */
178 /** Network device */
180 /** Port registers */
181 void *regs;
182
183 /** Transmit region offset */
184 size_t tx_offset;
185 /** Transmit region */
186 void *tx;
187 /** Number of transmit descriptors */
189 /** Transmit producer counter */
191 /** Transmit consumer counter */
193 /** Transmit feedback slot */
195 /** Transmit feedback region */
197
198 /** Receive region */
200 /** Receive consumer counter */
201 unsigned int rx_cons;
202 /** Receive I/O buffer (if any) */
204 /** Receive status */
205 int rx_rc;
206
207 /** Port status */
209 /** Default link speed (as raw register value) */
211 /** Speed capability bitmask */
213 /** Current attempted link speed (as a capability bit index) */
214 unsigned int speed;
215 /** Port status check timer */
217};
218
219/** An ExaNIC */
220struct exanic {
221 /** Registers */
222 void *regs;
223 /** Transmit region */
224 void *tx;
225 /** Transmit feedback region */
226 void *txf;
227
228 /** I2C bus configuration */
230 /** I2C bit-bashing interface */
232 /** I2C serial EEPROM */
234
235 /** Capabilities */
237 /** Base MAC address */
239
240 /** Ports */
242};
243
244/** Maximum used length of transmit region
245 *
246 * This is a policy decision to avoid overflowing the 16-bit transmit
247 * producer and consumer counters.
248 */
249#define EXANIC_MAX_TX_LEN ( 256 * sizeof ( struct exanic_tx_chunk ) )
250
251/** Maximum length of received packet
252 *
253 * This is a policy decision.
254 */
255#define EXANIC_MAX_RX_LEN ( ETH_FRAME_LEN + 4 /* VLAN */ + 4 /* CRC */ )
256
257/** Interval between link state checks
258 *
259 * This is a policy decision.
260 */
261#define EXANIC_LINK_INTERVAL ( 1 * TICKS_PER_SEC )
262
263#endif /* _EXANIC_H */
unsigned short uint16_t
Definition stdint.h:11
unsigned int uint32_t
Definition stdint.h:12
unsigned char uint8_t
Definition stdint.h:10
Bit-bashing interfaces.
Ethernet protocol.
#define EXANIC_MAX_PORTS
Maximum number of ports.
Definition exanic.h:20
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
I2C interface.
#define ETH_ALEN
Definition if_ether.h:9
#define __attribute__(x)
Definition compiler.h:10
PCI bus.
Retry timers.
An ExaNIC I2C bus configuration.
Definition exanic.h:164
uint8_t getsda
GPIO bit for reading SDA.
Definition exanic.h:170
uint8_t setscl
GPIO bit for pulling SCL low.
Definition exanic.h:166
uint8_t setsda
GPIO bit for pulling SDA low.
Definition exanic.h:168
An ExaNIC port.
Definition exanic.h:177
struct net_device * netdev
Network device.
Definition exanic.h:179
uint16_t tx_count
Number of transmit descriptors.
Definition exanic.h:188
void * tx
Transmit region.
Definition exanic.h:186
uint32_t status
Port status.
Definition exanic.h:208
uint16_t * txf
Transmit feedback region.
Definition exanic.h:196
struct retry_timer timer
Port status check timer.
Definition exanic.h:216
uint16_t tx_cons
Transmit consumer counter.
Definition exanic.h:192
int rx_rc
Receive status.
Definition exanic.h:205
uint32_t speeds
Speed capability bitmask.
Definition exanic.h:212
void * regs
Port registers.
Definition exanic.h:181
struct io_buffer * rx_iobuf
Receive I/O buffer (if any)
Definition exanic.h:203
size_t tx_offset
Transmit region offset.
Definition exanic.h:184
uint16_t txf_slot
Transmit feedback slot.
Definition exanic.h:194
unsigned int rx_cons
Receive consumer counter.
Definition exanic.h:201
uint32_t default_speed
Default link speed (as raw register value)
Definition exanic.h:210
struct exanic_rx_chunk * rx
Receive region.
Definition exanic.h:199
uint16_t tx_prod
Transmit producer counter.
Definition exanic.h:190
unsigned int speed
Current attempted link speed (as a capability bit index)
Definition exanic.h:214
An ExaNIC receive chunk.
Definition exanic.h:150
uint8_t data[120]
Payload data.
Definition exanic.h:152
struct exanic_rx_descriptor desc
Descriptor.
Definition exanic.h:154
An ExaNIC receive chunk descriptor.
Definition exanic.h:136
uint8_t generation
Generation.
Definition exanic.h:146
uint8_t filter
Filter number.
Definition exanic.h:144
uint32_t timestamp
Timestamp.
Definition exanic.h:138
uint8_t len
Length (zero except on the final chunk)
Definition exanic.h:142
uint8_t status
Status (valid only on final chunk)
Definition exanic.h:140
An ExaNIC transmit chunk.
Definition exanic.h:123
uint8_t pad[2]
Padding.
Definition exanic.h:127
struct exanic_tx_descriptor desc
Descriptor.
Definition exanic.h:125
uint8_t data[2038]
Payload data.
Definition exanic.h:129
An ExaNIC transmit chunk descriptor.
Definition exanic.h:109
uint8_t type
Payload type.
Definition exanic.h:117
uint16_t txf_slot
Feedback slot.
Definition exanic.h:113
uint16_t txf_id
Feedback ID.
Definition exanic.h:111
uint16_t len
Payload length (including padding.
Definition exanic.h:115
uint8_t flags
Flags.
Definition exanic.h:119
An ExaNIC.
Definition exanic.h:220
struct exanic_port * port[EXANIC_MAX_PORTS]
Ports.
Definition exanic.h:241
void * regs
Registers.
Definition exanic.h:222
void * txf
Transmit feedback region.
Definition exanic.h:226
uint8_t mac[ETH_ALEN]
Base MAC address.
Definition exanic.h:238
struct exanic_i2c_config i2cfg
I2C bus configuration.
Definition exanic.h:229
uint32_t caps
Capabilities.
Definition exanic.h:236
struct i2c_device eeprom
I2C serial EEPROM.
Definition exanic.h:233
void * tx
Transmit region.
Definition exanic.h:224
struct i2c_bit_basher basher
I2C bit-bashing interface.
Definition exanic.h:231
A bit-bashing I2C interface.
Definition i2c.h:91
An I2C device.
Definition i2c.h:20
A persistent I/O buffer.
Definition iobuf.h:38
A network device.
Definition netdevice.h:353
A retry timer.
Definition retry.h:22