Browse Source

[etherfabric] Merge changes from vendor tree

Also clean up minor errors in the use of debug macros.
tags/v0.9.6
Michael Brown 15 years ago
parent
commit
58dd6e04c5
2 changed files with 3775 additions and 2764 deletions
  1. 3574
    2764
      src/drivers/net/etherfabric.c
  2. 201
    0
      src/drivers/net/etherfabric_nic.h

+ 3574
- 2764
src/drivers/net/etherfabric.c
File diff suppressed because it is too large
View File


+ 201
- 0
src/drivers/net/etherfabric_nic.h View File

@@ -0,0 +1,201 @@
1
+/**************************************************************************
2
+ *
3
+ * Etherboot driver for Level 5 Etherfabric network cards
4
+ *
5
+ * Written by Michael Brown <mbrown@fensystems.co.uk>
6
+ *
7
+ * Copyright Fen Systems Ltd. 2005
8
+ * Copyright Level 5 Networks Inc. 2005
9
+ *
10
+ * This software may be used and distributed according to the terms of
11
+ * the GNU General Public License (GPL), incorporated herein by
12
+ * reference.  Drivers based on or derived from this code fall under
13
+ * the GPL and must retain the authorship, copyright and license
14
+ * notice.
15
+ *
16
+ **************************************************************************
17
+ */
18
+#ifndef EFAB_NIC_H
19
+#define  EFAB_NIC_H
20
+#include <gpxe/bitbash.h>
21
+#include <gpxe/i2c.h>
22
+#include <gpxe/spi.h>
23
+#include <gpxe/nvo.h>
24
+#include <gpxe/if_ether.h>
25
+/**************************************************************************
26
+ *
27
+ * Constants and macros
28
+ *
29
+ **************************************************************************
30
+ */
31
+/* Board IDs. Early boards have no board_type, (e.g. EF1002 and 401/403)
32
+ * But newer boards are getting bigger...
33
+ */
34
+typedef enum {
35
+	EFAB_BOARD_INVALID = 0, /* Early boards do not have board rev. info. */
36
+	EFAB_BOARD_SFE4001 = 1,
37
+	EFAB_BOARD_SFE4002 = 2,
38
+	EFAB_BOARD_SFE4003 = 3,
39
+	/* Insert new types before here */
40
+	EFAB_BOARD_MAX
41
+} efab_board_type;
42
+
43
+/* PHY types. */
44
+typedef enum {
45
+	PHY_TYPE_AUTO = 0, /* on development board detect between CX4 & alaska */
46
+	PHY_TYPE_CX4_RTMR = 1,
47
+	PHY_TYPE_1GIG_ALASKA = 2,
48
+	PHY_TYPE_10XPRESS = 3,
49
+	PHY_TYPE_XFP = 4,
50
+	PHY_TYPE_CX4 = 5,
51
+	PHY_TYPE_PM8358 = 6,
52
+} phy_type_t;
53
+
54
+/**************************************************************************
55
+ *
56
+ * Hardware data structures and sizing
57
+ *
58
+ **************************************************************************
59
+ */
60
+
61
+#define dma_addr_t unsigned long
62
+typedef efab_qword_t falcon_rx_desc_t;
63
+typedef efab_qword_t falcon_tx_desc_t;
64
+typedef efab_qword_t falcon_event_t;
65
+
66
+#define EFAB_BUF_ALIGN		4096
67
+#define EFAB_RXD_SIZE		512
68
+#define EFAB_TXD_SIZE		512
69
+#define EFAB_EVQ_SIZE		512
70
+
71
+#define EFAB_NUM_RX_DESC        16
72
+#define EFAB_RX_BUF_SIZE	1600
73
+
74
+/**************************************************************************
75
+ *
76
+ * Data structures
77
+ *
78
+ **************************************************************************
79
+ */
80
+
81
+struct efab_nic;
82
+
83
+/* A buffer table allocation backing a tx dma, rx dma or eventq */
84
+struct efab_special_buffer {
85
+	dma_addr_t dma_addr;
86
+	int id;
87
+};
88
+
89
+/* A TX queue */
90
+struct efab_tx_queue {
91
+	/* The hardware ring */
92
+	falcon_tx_desc_t *ring;
93
+
94
+	/* The software ring storing io_buffers. */
95
+	struct io_buffer *buf[EFAB_TXD_SIZE];
96
+
97
+	/* The buffer table reservation pushed to hardware */
98
+	struct efab_special_buffer entry;
99
+
100
+	/* Software descriptor write ptr */
101
+	unsigned int write_ptr;
102
+
103
+	/* Hardware descriptor read ptr */
104
+	unsigned int read_ptr;
105
+};
106
+
107
+/* An RX queue */
108
+struct efab_rx_queue {
109
+	/* The hardware ring */
110
+	falcon_rx_desc_t *ring;
111
+
112
+	/* The software ring storing io_buffers */
113
+	struct io_buffer *buf[EFAB_NUM_RX_DESC];
114
+
115
+	/* The buffer table reservation pushed to hardware */
116
+	struct efab_special_buffer entry;
117
+
118
+	/* Descriptor write ptr, into both the hardware and software rings */
119
+	unsigned int write_ptr;
120
+
121
+	/* Hardware completion ptr */
122
+	unsigned int read_ptr;
123
+};
124
+
125
+/* An event queue */
126
+struct efab_ev_queue {
127
+	/* The hardware ring to push to hardware.
128
+	 * Must be the first entry in the structure */
129
+	falcon_event_t *ring;
130
+
131
+	/* The buffer table reservation pushed to hardware */
132
+	struct efab_special_buffer entry;
133
+
134
+	/* Pointers into the ring */
135
+	unsigned int read_ptr;
136
+};
137
+
138
+struct efab_mac_operations {
139
+	int ( * init ) ( struct efab_nic *efab );
140
+};
141
+
142
+struct efab_phy_operations {
143
+	int ( * init ) ( struct efab_nic *efab );
144
+	unsigned int mmds;
145
+};
146
+
147
+struct efab_board_operations {
148
+	int ( * init ) ( struct efab_nic *efab );
149
+	void ( * fini ) ( struct efab_nic *efab );
150
+};
151
+
152
+struct efab_nic {
153
+	struct net_device *netdev;
154
+	int pci_revision;
155
+	int is_asic;
156
+
157
+	/* I2C bit-bashed interface */
158
+	struct i2c_bit_basher i2c_bb;
159
+
160
+	/** SPI bus and devices, and the user visible NVO area */
161
+	struct spi_bus spi_bus;
162
+	struct spi_device spi_flash;
163
+	struct spi_device spi_eeprom;
164
+	struct spi_device *spi;
165
+	struct nvo_block nvo;
166
+
167
+	/** Board, MAC, and PHY operations tables */
168
+	struct efab_board_operations *board_op;
169
+	struct efab_mac_operations *mac_op;
170
+	struct efab_phy_operations *phy_op;
171
+
172
+	/* PHY and board types */
173
+	int phy_addr;
174
+	int phy_type;
175
+	int phy_10g;
176
+	int board_type;
177
+
178
+	/** Memory and IO base */
179
+	void *membase;
180
+	unsigned int iobase;
181
+
182
+	/* Buffer table allocation head */
183
+	int buffer_head;
184
+
185
+	/* Queues */
186
+	struct efab_rx_queue rx_queue;
187
+	struct efab_tx_queue tx_queue;
188
+	struct efab_ev_queue ev_queue;
189
+
190
+	/** MAC address */
191
+	uint8_t mac_addr[ETH_ALEN];
192
+	/** GMII link options */
193
+	unsigned int link_options;
194
+	/** Link status */
195
+	int link_up;
196
+
197
+	/** INT_REG_KER */
198
+	efab_oword_t int_ker __attribute__ (( aligned ( 16 ) ));
199
+};
200
+#endif /* EFAB_NIC_H */
201
+

Loading…
Cancel
Save