Browse Source

Very quick and very dirty hack to get the Mellanox code building

inside gPXE.
tags/v0.9.3
Michael Brown 17 years ago
parent
commit
b42c5905cb

+ 5
- 0
src/Makefile View File

@@ -164,6 +164,11 @@ SRCDIRS		+= usr
164 164
 NON_AUTO_SRCS	+= core/elf_loader.c
165 165
 NON_AUTO_SRCS	+= drivers/net/prism2.c
166 166
 
167
+SRCS		+= drivers/net/mlx_ipoib/mt25218.c
168
+SRCS		+= drivers/net/mlx_ipoib/mt23108.c
169
+CFLAGS_mt25218	= -Wno-error
170
+CFLAGS_mt23108	= -Wno-error
171
+
167 172
 # Rules for finalising files.  TGT_MAKEROM_FLAGS is defined as part of
168 173
 # the automatic build system and varies by target; it includes the
169 174
 # "-p 0x1234,0x5678" string to set the PCI IDs.

+ 22
- 8
src/drivers/net/mlx_ipoib/ib_mt23108.c View File

@@ -92,7 +92,12 @@ static int find_mlx_bridge(__u8 hca_bus, __u8 * br_bus_p, __u8 * br_devfn_p)
92 92
 	for (bus = 0; bus < 256; ++bus) {
93 93
 		for (dev = 0; dev < 32; ++dev) {
94 94
 			devfn = (dev << 3);
95
-			rc = pcibios_read_config_word(bus, devfn, PCI_VENDOR_ID,
95
+
96
+			struct pci_device tmp;
97
+			tmp.bus = bus;
98
+			tmp.devfn = devfn;
99
+
100
+			rc = pcibios_read_config_word(&tmp, PCI_VENDOR_ID,
96 101
 						      &vendor);
97 102
 			if (rc)
98 103
 				return rc;
@@ -100,7 +105,7 @@ static int find_mlx_bridge(__u8 hca_bus, __u8 * br_bus_p, __u8 * br_devfn_p)
100 105
 			if (vendor != MELLANOX_VENDOR_ID)
101 106
 				continue;
102 107
 
103
-			rc = pcibios_read_config_word(bus, devfn, PCI_DEVICE_ID,
108
+			rc = pcibios_read_config_word(&tmp, PCI_DEVICE_ID,
104 109
 						      &dev_id);
105 110
 			if (rc)
106 111
 				return rc;
@@ -108,7 +113,7 @@ static int find_mlx_bridge(__u8 hca_bus, __u8 * br_bus_p, __u8 * br_devfn_p)
108 113
 			if (dev_id != TAVOR_BRIDGE_DEVICE_ID)
109 114
 				continue;
110 115
 
111
-			rc = pcibios_read_config_byte(bus, devfn,
116
+			rc = pcibios_read_config_byte(&tmp,
112 117
 						      PCI_SECONDARY_BUS,
113 118
 						      &sec_bus);
114 119
 			if (rc)
@@ -161,7 +166,7 @@ static int ib_device_init(struct pci_device *dev)
161 166
 	tavor_pci_dev.dev.dev = dev;
162 167
 
163 168
 	tprintf("");
164
-	if (dev->dev_id == TAVOR_DEVICE_ID) {
169
+	if (dev->device == TAVOR_DEVICE_ID) {
165 170
 
166 171
 		rc = find_mlx_bridge(dev->bus, &br_bus, &br_devfn);
167 172
 		if (rc) {
@@ -175,7 +180,12 @@ static int ib_device_init(struct pci_device *dev)
175 180
 		tprintf("bus=%d devfn=0x%x", br_bus, br_devfn);
176 181
 		/* save config space */
177 182
 		for (i = 0; i < 64; ++i) {
178
-			rc = pcibios_read_config_dword(br_bus, br_devfn, i << 2,
183
+
184
+			struct pci_device tmp;
185
+			tmp.bus = br_bus;
186
+			tmp.devfn = br_devfn;
187
+
188
+			rc = pcibios_read_config_dword(&tmp, i << 2,
179 189
 						       &tavor_pci_dev.br.
180 190
 						       dev_config_space[i]);
181 191
 			if (rc) {
@@ -236,10 +246,14 @@ static int restore_config(void)
236 246
 	int i;
237 247
 	int rc;
238 248
 
239
-	if (tavor_pci_dev.dev.dev->dev_id == TAVOR_DEVICE_ID) {
249
+	if (tavor_pci_dev.dev.dev->device == TAVOR_DEVICE_ID) {
240 250
 		for (i = 0; i < 64; ++i) {
241
-			rc = pcibios_write_config_dword(tavor_pci_dev.br.bus,
242
-							tavor_pci_dev.br.devfn,
251
+
252
+			struct pci_device tmp;
253
+			tmp.bus = tavor_pci_dev.br.bus;
254
+			tmp.devfn = tavor_pci_dev.br.devfn;
255
+
256
+			rc = pcibios_write_config_dword(&tmp,
243 257
 							i << 2,
244 258
 							tavor_pci_dev.br.
245 259
 							dev_config_space[i]);

+ 9
- 3
src/drivers/net/mlx_ipoib/ib_mt25218.c View File

@@ -174,6 +174,8 @@ static inline unsigned long lalign(unsigned long buf, unsigned long align)
174 174
 			       (~(((unsigned long)align) - 1)));
175 175
 }
176 176
 
177
+#include <gpxe/umalloc.h>
178
+
177 179
 static int init_dev_data(void)
178 180
 {
179 181
 	unsigned long tmp;
@@ -191,9 +193,13 @@ static int init_dev_data(void)
191 193
 	tprintf("outprm: va=%p, pa=0x%lx", dev_buffers_p->outprm_buf,
192 194
 		virt_to_bus(dev_buffers_p->outprm_buf));
193 195
 
194
-	phys_mem.base =
195
-	    (virt_to_phys(_text) - reserve_size) & (~(reserve_size - 1));
196
-
196
+	userptr_t lotsofmem = umalloc ( reserve_size * 2 );
197
+	if ( ! lotsofmem ) {
198
+		printf ( "Could not allocate large memblock\n" );
199
+		return -1;
200
+	}
201
+	phys_mem.base = ( ( user_to_phys ( lotsofmem, 0 ) + reserve_size ) &
202
+			  ~( reserve_size - 1 ) );
197 203
 	phys_mem.offset = 0;
198 204
 
199 205
 	return 0;

+ 16
- 17
src/drivers/net/mlx_ipoib/mt23108.c View File

@@ -148,7 +148,7 @@ static void tavor_transmit(struct nic *nic, const char *dest,	/* Destination */
148 148
 /**************************************************************************
149 149
 DISABLE - Turn off ethernet interface
150 150
 ***************************************************************************/
151
-static void tavor_disable(struct dev *dev)
151
+static void tavor_disable(struct nic *nic)
152 152
 {
153 153
 	/* put the card in its initial state */
154 154
 	/* This function serves 3 purposes.
@@ -160,18 +160,24 @@ static void tavor_disable(struct dev *dev)
160 160
 	 * This allows etherboot to reinitialize the interface
161 161
 	 *  if something is something goes wrong.
162 162
 	 */
163
-	if (dev || 1) {		// ????
163
+	if (nic || 1) {		// ????
164 164
 		disable_imp();
165 165
 	}
166 166
 }
167 167
 
168
+static struct nic_operations tavor_operations = {
169
+	.connect	= dummy_connect,
170
+	.poll		= tavor_poll,
171
+	.transmit	= tavor_transmit,
172
+	.irq		= tavor_irq,
173
+};
174
+
168 175
 /**************************************************************************
169 176
 PROBE - Look for an adapter, this routine's visible to the outside
170 177
 ***************************************************************************/
171 178
 
172
-static int tavor_probe(struct dev *dev, struct pci_device *pci)
179
+static int tavor_probe(struct nic *nic, struct pci_device *pci)
173 180
 {
174
-	struct nic *nic = (struct nic *)dev;
175 181
 	int rc;
176 182
 	unsigned char user_request;
177 183
 
@@ -215,10 +221,7 @@ static int tavor_probe(struct dev *dev, struct pci_device *pci)
215 221
 		nic->ioaddr = pci->ioaddr & ~3;
216 222
 		nic->irqno = pci->irq;
217 223
 		/* point to NIC specific routines */
218
-		dev->disable = tavor_disable;
219
-		nic->poll = tavor_poll;
220
-		nic->transmit = tavor_transmit;
221
-		nic->irq = tavor_irq;
224
+		nic->nic_op = &tavor_operations;
222 225
 
223 226
 		return 1;
224 227
 	}
@@ -226,16 +229,12 @@ static int tavor_probe(struct dev *dev, struct pci_device *pci)
226 229
 	return 0;
227 230
 }
228 231
 
229
-static struct pci_id tavor_nics[] = {
232
+static struct pci_device_id tavor_nics[] = {
230 233
 	PCI_ROM(0x15b3, 0x5a44, "MT23108", "MT23108 HCA driver"),
231 234
 	PCI_ROM(0x15b3, 0x6278, "MT25208", "MT25208 HCA driver"),
232 235
 };
233 236
 
234
-static struct pci_driver tavor_driver __pci_driver = {
235
-	.type = NIC_DRIVER,
236
-	.name = "MT23108/MT25208",
237
-	.probe = tavor_probe,
238
-	.ids = tavor_nics,
239
-	.id_count = sizeof(tavor_nics) / sizeof(tavor_nics[0]),
240
-	.class = 0,
241
-};
237
+PCI_DRIVER ( tavor_driver, tavor_nics, PCI_NO_CLASS );
238
+
239
+DRIVER ( "MT23108/MT25208", nic_driver, pci_driver, tavor_driver,
240
+	 tavor_probe, tavor_disable );

+ 4
- 0
src/drivers/net/mlx_ipoib/mt23108_imp.c View File

@@ -91,10 +91,12 @@ static int transmit_imp(const char *dest,	/* Destination */
91 91
 	rc = ipoib_send_packet(dest, type, packet, size);
92 92
 	if (rc) {
93 93
 		printf("*** ERROR IN SEND FLOW ***\n");
94
+#if 0
94 95
 		printf("restarting Etherboot\n");
95 96
 		sleep(1);
96 97
 		longjmp(restart_etherboot, -1);
97 98
 		/* we should not be here ... */
99
+#endif
98 100
 		return -1; 
99 101
 	}
100 102
 
@@ -222,9 +224,11 @@ static int poll_imp(struct nic *nic, int retrieve, unsigned int *size_p)
222 224
 
223 225
 fatal_handling:
224 226
 	printf("restarting Etherboot\n");
227
+#if 0
225 228
 	sleep(1);
226 229
 	longjmp(restart_etherboot, -1);
227 230
 	/* we should not be here ... */
231
+#endif
228 232
 	return -1; 
229 233
 	
230 234
 }

+ 16
- 17
src/drivers/net/mlx_ipoib/mt25218.c View File

@@ -148,7 +148,7 @@ static void mt25218_transmit(struct nic *nic, const char *dest,	/* Destination *
148 148
 /**************************************************************************
149 149
 DISABLE - Turn off ethernet interface
150 150
 ***************************************************************************/
151
-static void mt25218_disable(struct dev *dev)
151
+static void mt25218_disable(struct nic *nic)
152 152
 {
153 153
 	/* put the card in its initial state */
154 154
 	/* This function serves 3 purposes.
@@ -160,18 +160,24 @@ static void mt25218_disable(struct dev *dev)
160 160
 	 * This allows etherboot to reinitialize the interface
161 161
 	 *  if something is something goes wrong.
162 162
 	 */
163
-	if (dev || 1) {		// ????
163
+	if (nic || 1) {		// ????
164 164
 		disable_imp();
165 165
 	}
166 166
 }
167 167
 
168
+static struct nic_operations mt25218_operations = {
169
+	.connect	= dummy_connect,
170
+	.poll		= mt25218_poll,
171
+	.transmit	= mt25218_transmit,
172
+	.irq		= mt25218_irq,
173
+};
174
+
168 175
 /**************************************************************************
169 176
 PROBE - Look for an adapter, this routine's visible to the outside
170 177
 ***************************************************************************/
171 178
 
172
-static int mt25218_probe(struct dev *dev, struct pci_device *pci)
179
+static int mt25218_probe(struct nic *nic, struct pci_device *pci)
173 180
 {
174
-	struct nic *nic = (struct nic *)dev;
175 181
 	int rc;
176 182
 	unsigned char user_request;
177 183
 
@@ -215,10 +221,7 @@ static int mt25218_probe(struct dev *dev, struct pci_device *pci)
215 221
 		nic->ioaddr = pci->ioaddr & ~3;
216 222
 		nic->irqno = pci->irq;
217 223
 		/* point to NIC specific routines */
218
-		dev->disable = mt25218_disable;
219
-		nic->poll = mt25218_poll;
220
-		nic->transmit = mt25218_transmit;
221
-		nic->irq = mt25218_irq;
224
+		nic->nic_op = &mt25218_operations;
222 225
 
223 226
 		return 1;
224 227
 	}
@@ -226,16 +229,12 @@ static int mt25218_probe(struct dev *dev, struct pci_device *pci)
226 229
 	return 0;
227 230
 }
228 231
 
229
-static struct pci_id mt25218_nics[] = {
232
+static struct pci_device_id mt25218_nics[] = {
230 233
 	PCI_ROM(0x15b3, 0x6282, "MT25218", "MT25218 HCA driver"),
231 234
 	PCI_ROM(0x15b3, 0x6274, "MT25204", "MT25204 HCA driver"),
232 235
 };
233 236
 
234
-static struct pci_driver mt25218_driver __pci_driver = {
235
-	.type = NIC_DRIVER,
236
-	.name = "MT25218",
237
-	.probe = mt25218_probe,
238
-	.ids = mt25218_nics,
239
-	.id_count = sizeof(mt25218_nics) / sizeof(mt25218_nics[0]),
240
-	.class = 0,
241
-};
237
+PCI_DRIVER ( mt25218_driver, mt25218_nics, PCI_NO_CLASS );
238
+
239
+DRIVER ( "MT25218", nic_driver, pci_driver, mt25218_driver,
240
+	 mt25218_probe, mt25218_disable );

+ 4
- 0
src/drivers/net/mlx_ipoib/mt25218_imp.c View File

@@ -91,10 +91,12 @@ static int transmit_imp(const char *dest,	/* Destination */
91 91
 	rc = ipoib_send_packet(dest, type, packet, size);
92 92
 	if (rc) {
93 93
 		printf("*** ERROR IN SEND FLOW ***\n");
94
+#if 0
94 95
 		printf("restarting Etherboot\n");
95 96
 		sleep(1);
96 97
 		longjmp(restart_etherboot, -1);
97 98
 		/* we should not be here ... */
99
+#endif
98 100
 		return -1; 
99 101
 	}
100 102
 
@@ -221,10 +223,12 @@ static int poll_imp(struct nic *nic, int retrieve, unsigned int *size_p)
221 223
 	return 0;
222 224
 
223 225
 fatal_handling:
226
+#if 0
224 227
 	printf("restarting Etherboot\n");
225 228
 	sleep(1);
226 229
 	longjmp(restart_etherboot, -1);
227 230
 	/* we should not be here ... */
231
+#endif
228 232
 	return -1; 
229 233
 	
230 234
 }

Loading…
Cancel
Save