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
 NON_AUTO_SRCS	+= core/elf_loader.c
164
 NON_AUTO_SRCS	+= core/elf_loader.c
165
 NON_AUTO_SRCS	+= drivers/net/prism2.c
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
 # Rules for finalising files.  TGT_MAKEROM_FLAGS is defined as part of
172
 # Rules for finalising files.  TGT_MAKEROM_FLAGS is defined as part of
168
 # the automatic build system and varies by target; it includes the
173
 # the automatic build system and varies by target; it includes the
169
 # "-p 0x1234,0x5678" string to set the PCI IDs.
174
 # "-p 0x1234,0x5678" string to set the PCI IDs.

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

92
 	for (bus = 0; bus < 256; ++bus) {
92
 	for (bus = 0; bus < 256; ++bus) {
93
 		for (dev = 0; dev < 32; ++dev) {
93
 		for (dev = 0; dev < 32; ++dev) {
94
 			devfn = (dev << 3);
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
 						      &vendor);
101
 						      &vendor);
97
 			if (rc)
102
 			if (rc)
98
 				return rc;
103
 				return rc;
100
 			if (vendor != MELLANOX_VENDOR_ID)
105
 			if (vendor != MELLANOX_VENDOR_ID)
101
 				continue;
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
 						      &dev_id);
109
 						      &dev_id);
105
 			if (rc)
110
 			if (rc)
106
 				return rc;
111
 				return rc;
108
 			if (dev_id != TAVOR_BRIDGE_DEVICE_ID)
113
 			if (dev_id != TAVOR_BRIDGE_DEVICE_ID)
109
 				continue;
114
 				continue;
110
 
115
 
111
-			rc = pcibios_read_config_byte(bus, devfn,
116
+			rc = pcibios_read_config_byte(&tmp,
112
 						      PCI_SECONDARY_BUS,
117
 						      PCI_SECONDARY_BUS,
113
 						      &sec_bus);
118
 						      &sec_bus);
114
 			if (rc)
119
 			if (rc)
161
 	tavor_pci_dev.dev.dev = dev;
166
 	tavor_pci_dev.dev.dev = dev;
162
 
167
 
163
 	tprintf("");
168
 	tprintf("");
164
-	if (dev->dev_id == TAVOR_DEVICE_ID) {
169
+	if (dev->device == TAVOR_DEVICE_ID) {
165
 
170
 
166
 		rc = find_mlx_bridge(dev->bus, &br_bus, &br_devfn);
171
 		rc = find_mlx_bridge(dev->bus, &br_bus, &br_devfn);
167
 		if (rc) {
172
 		if (rc) {
175
 		tprintf("bus=%d devfn=0x%x", br_bus, br_devfn);
180
 		tprintf("bus=%d devfn=0x%x", br_bus, br_devfn);
176
 		/* save config space */
181
 		/* save config space */
177
 		for (i = 0; i < 64; ++i) {
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
 						       &tavor_pci_dev.br.
189
 						       &tavor_pci_dev.br.
180
 						       dev_config_space[i]);
190
 						       dev_config_space[i]);
181
 			if (rc) {
191
 			if (rc) {
236
 	int i;
246
 	int i;
237
 	int rc;
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
 		for (i = 0; i < 64; ++i) {
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
 							i << 2,
257
 							i << 2,
244
 							tavor_pci_dev.br.
258
 							tavor_pci_dev.br.
245
 							dev_config_space[i]);
259
 							dev_config_space[i]);

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

174
 			       (~(((unsigned long)align) - 1)));
174
 			       (~(((unsigned long)align) - 1)));
175
 }
175
 }
176
 
176
 
177
+#include <gpxe/umalloc.h>
178
+
177
 static int init_dev_data(void)
179
 static int init_dev_data(void)
178
 {
180
 {
179
 	unsigned long tmp;
181
 	unsigned long tmp;
191
 	tprintf("outprm: va=%p, pa=0x%lx", dev_buffers_p->outprm_buf,
193
 	tprintf("outprm: va=%p, pa=0x%lx", dev_buffers_p->outprm_buf,
192
 		virt_to_bus(dev_buffers_p->outprm_buf));
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
 	phys_mem.offset = 0;
203
 	phys_mem.offset = 0;
198
 
204
 
199
 	return 0;
205
 	return 0;

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

148
 /**************************************************************************
148
 /**************************************************************************
149
 DISABLE - Turn off ethernet interface
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
 	/* put the card in its initial state */
153
 	/* put the card in its initial state */
154
 	/* This function serves 3 purposes.
154
 	/* This function serves 3 purposes.
160
 	 * This allows etherboot to reinitialize the interface
160
 	 * This allows etherboot to reinitialize the interface
161
 	 *  if something is something goes wrong.
161
 	 *  if something is something goes wrong.
162
 	 */
162
 	 */
163
-	if (dev || 1) {		// ????
163
+	if (nic || 1) {		// ????
164
 		disable_imp();
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
 PROBE - Look for an adapter, this routine's visible to the outside
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
 	int rc;
181
 	int rc;
176
 	unsigned char user_request;
182
 	unsigned char user_request;
177
 
183
 
215
 		nic->ioaddr = pci->ioaddr & ~3;
221
 		nic->ioaddr = pci->ioaddr & ~3;
216
 		nic->irqno = pci->irq;
222
 		nic->irqno = pci->irq;
217
 		/* point to NIC specific routines */
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
 		return 1;
226
 		return 1;
224
 	}
227
 	}
226
 	return 0;
229
 	return 0;
227
 }
230
 }
228
 
231
 
229
-static struct pci_id tavor_nics[] = {
232
+static struct pci_device_id tavor_nics[] = {
230
 	PCI_ROM(0x15b3, 0x5a44, "MT23108", "MT23108 HCA driver"),
233
 	PCI_ROM(0x15b3, 0x5a44, "MT23108", "MT23108 HCA driver"),
231
 	PCI_ROM(0x15b3, 0x6278, "MT25208", "MT25208 HCA driver"),
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
 	rc = ipoib_send_packet(dest, type, packet, size);
91
 	rc = ipoib_send_packet(dest, type, packet, size);
92
 	if (rc) {
92
 	if (rc) {
93
 		printf("*** ERROR IN SEND FLOW ***\n");
93
 		printf("*** ERROR IN SEND FLOW ***\n");
94
+#if 0
94
 		printf("restarting Etherboot\n");
95
 		printf("restarting Etherboot\n");
95
 		sleep(1);
96
 		sleep(1);
96
 		longjmp(restart_etherboot, -1);
97
 		longjmp(restart_etherboot, -1);
97
 		/* we should not be here ... */
98
 		/* we should not be here ... */
99
+#endif
98
 		return -1; 
100
 		return -1; 
99
 	}
101
 	}
100
 
102
 
222
 
224
 
223
 fatal_handling:
225
 fatal_handling:
224
 	printf("restarting Etherboot\n");
226
 	printf("restarting Etherboot\n");
227
+#if 0
225
 	sleep(1);
228
 	sleep(1);
226
 	longjmp(restart_etherboot, -1);
229
 	longjmp(restart_etherboot, -1);
227
 	/* we should not be here ... */
230
 	/* we should not be here ... */
231
+#endif
228
 	return -1; 
232
 	return -1; 
229
 	
233
 	
230
 }
234
 }

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

148
 /**************************************************************************
148
 /**************************************************************************
149
 DISABLE - Turn off ethernet interface
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
 	/* put the card in its initial state */
153
 	/* put the card in its initial state */
154
 	/* This function serves 3 purposes.
154
 	/* This function serves 3 purposes.
160
 	 * This allows etherboot to reinitialize the interface
160
 	 * This allows etherboot to reinitialize the interface
161
 	 *  if something is something goes wrong.
161
 	 *  if something is something goes wrong.
162
 	 */
162
 	 */
163
-	if (dev || 1) {		// ????
163
+	if (nic || 1) {		// ????
164
 		disable_imp();
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
 PROBE - Look for an adapter, this routine's visible to the outside
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
 	int rc;
181
 	int rc;
176
 	unsigned char user_request;
182
 	unsigned char user_request;
177
 
183
 
215
 		nic->ioaddr = pci->ioaddr & ~3;
221
 		nic->ioaddr = pci->ioaddr & ~3;
216
 		nic->irqno = pci->irq;
222
 		nic->irqno = pci->irq;
217
 		/* point to NIC specific routines */
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
 		return 1;
226
 		return 1;
224
 	}
227
 	}
226
 	return 0;
229
 	return 0;
227
 }
230
 }
228
 
231
 
229
-static struct pci_id mt25218_nics[] = {
232
+static struct pci_device_id mt25218_nics[] = {
230
 	PCI_ROM(0x15b3, 0x6282, "MT25218", "MT25218 HCA driver"),
233
 	PCI_ROM(0x15b3, 0x6282, "MT25218", "MT25218 HCA driver"),
231
 	PCI_ROM(0x15b3, 0x6274, "MT25204", "MT25204 HCA driver"),
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
 	rc = ipoib_send_packet(dest, type, packet, size);
91
 	rc = ipoib_send_packet(dest, type, packet, size);
92
 	if (rc) {
92
 	if (rc) {
93
 		printf("*** ERROR IN SEND FLOW ***\n");
93
 		printf("*** ERROR IN SEND FLOW ***\n");
94
+#if 0
94
 		printf("restarting Etherboot\n");
95
 		printf("restarting Etherboot\n");
95
 		sleep(1);
96
 		sleep(1);
96
 		longjmp(restart_etherboot, -1);
97
 		longjmp(restart_etherboot, -1);
97
 		/* we should not be here ... */
98
 		/* we should not be here ... */
99
+#endif
98
 		return -1; 
100
 		return -1; 
99
 	}
101
 	}
100
 
102
 
221
 	return 0;
223
 	return 0;
222
 
224
 
223
 fatal_handling:
225
 fatal_handling:
226
+#if 0
224
 	printf("restarting Etherboot\n");
227
 	printf("restarting Etherboot\n");
225
 	sleep(1);
228
 	sleep(1);
226
 	longjmp(restart_etherboot, -1);
229
 	longjmp(restart_etherboot, -1);
227
 	/* we should not be here ... */
230
 	/* we should not be here ... */
231
+#endif
228
 	return -1; 
232
 	return -1; 
229
 	
233
 	
230
 }
234
 }

Loading…
Cancel
Save