summaryrefslogtreecommitdiffstats
path: root/src/drivers
diff options
context:
space:
mode:
authorMichael Brown2007-08-18 19:04:18 +0200
committerMichael Brown2007-08-18 19:04:18 +0200
commitb42c5905cb59f6ca4893afa4935eb0365079cae9 (patch)
tree0c83569b1ace173652fb06f7cec359ffaa4fb02e /src/drivers
parentStarted fixing up compilation warnings. (diff)
downloadipxe-b42c5905cb59f6ca4893afa4935eb0365079cae9.tar.gz
ipxe-b42c5905cb59f6ca4893afa4935eb0365079cae9.tar.xz
ipxe-b42c5905cb59f6ca4893afa4935eb0365079cae9.zip
Very quick and very dirty hack to get the Mellanox code building
inside gPXE.
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/net/mlx_ipoib/ib_mt23108.c30
-rw-r--r--src/drivers/net/mlx_ipoib/ib_mt25218.c12
-rw-r--r--src/drivers/net/mlx_ipoib/mt23108.c33
-rw-r--r--src/drivers/net/mlx_ipoib/mt23108_imp.c4
-rw-r--r--src/drivers/net/mlx_ipoib/mt25218.c33
-rw-r--r--src/drivers/net/mlx_ipoib/mt25218_imp.c4
6 files changed, 71 insertions, 45 deletions
diff --git a/src/drivers/net/mlx_ipoib/ib_mt23108.c b/src/drivers/net/mlx_ipoib/ib_mt23108.c
index 881f59331..d9261b9cd 100644
--- a/src/drivers/net/mlx_ipoib/ib_mt23108.c
+++ b/src/drivers/net/mlx_ipoib/ib_mt23108.c
@@ -92,7 +92,12 @@ static int find_mlx_bridge(__u8 hca_bus, __u8 * br_bus_p, __u8 * br_devfn_p)
for (bus = 0; bus < 256; ++bus) {
for (dev = 0; dev < 32; ++dev) {
devfn = (dev << 3);
- rc = pcibios_read_config_word(bus, devfn, PCI_VENDOR_ID,
+
+ struct pci_device tmp;
+ tmp.bus = bus;
+ tmp.devfn = devfn;
+
+ rc = pcibios_read_config_word(&tmp, PCI_VENDOR_ID,
&vendor);
if (rc)
return rc;
@@ -100,7 +105,7 @@ static int find_mlx_bridge(__u8 hca_bus, __u8 * br_bus_p, __u8 * br_devfn_p)
if (vendor != MELLANOX_VENDOR_ID)
continue;
- rc = pcibios_read_config_word(bus, devfn, PCI_DEVICE_ID,
+ rc = pcibios_read_config_word(&tmp, PCI_DEVICE_ID,
&dev_id);
if (rc)
return rc;
@@ -108,7 +113,7 @@ static int find_mlx_bridge(__u8 hca_bus, __u8 * br_bus_p, __u8 * br_devfn_p)
if (dev_id != TAVOR_BRIDGE_DEVICE_ID)
continue;
- rc = pcibios_read_config_byte(bus, devfn,
+ rc = pcibios_read_config_byte(&tmp,
PCI_SECONDARY_BUS,
&sec_bus);
if (rc)
@@ -161,7 +166,7 @@ static int ib_device_init(struct pci_device *dev)
tavor_pci_dev.dev.dev = dev;
tprintf("");
- if (dev->dev_id == TAVOR_DEVICE_ID) {
+ if (dev->device == TAVOR_DEVICE_ID) {
rc = find_mlx_bridge(dev->bus, &br_bus, &br_devfn);
if (rc) {
@@ -175,7 +180,12 @@ static int ib_device_init(struct pci_device *dev)
tprintf("bus=%d devfn=0x%x", br_bus, br_devfn);
/* save config space */
for (i = 0; i < 64; ++i) {
- rc = pcibios_read_config_dword(br_bus, br_devfn, i << 2,
+
+ struct pci_device tmp;
+ tmp.bus = br_bus;
+ tmp.devfn = br_devfn;
+
+ rc = pcibios_read_config_dword(&tmp, i << 2,
&tavor_pci_dev.br.
dev_config_space[i]);
if (rc) {
@@ -236,10 +246,14 @@ static int restore_config(void)
int i;
int rc;
- if (tavor_pci_dev.dev.dev->dev_id == TAVOR_DEVICE_ID) {
+ if (tavor_pci_dev.dev.dev->device == TAVOR_DEVICE_ID) {
for (i = 0; i < 64; ++i) {
- rc = pcibios_write_config_dword(tavor_pci_dev.br.bus,
- tavor_pci_dev.br.devfn,
+
+ struct pci_device tmp;
+ tmp.bus = tavor_pci_dev.br.bus;
+ tmp.devfn = tavor_pci_dev.br.devfn;
+
+ rc = pcibios_write_config_dword(&tmp,
i << 2,
tavor_pci_dev.br.
dev_config_space[i]);
diff --git a/src/drivers/net/mlx_ipoib/ib_mt25218.c b/src/drivers/net/mlx_ipoib/ib_mt25218.c
index 1e9ac6377..8f3873e6e 100644
--- a/src/drivers/net/mlx_ipoib/ib_mt25218.c
+++ b/src/drivers/net/mlx_ipoib/ib_mt25218.c
@@ -174,6 +174,8 @@ static inline unsigned long lalign(unsigned long buf, unsigned long align)
(~(((unsigned long)align) - 1)));
}
+#include <gpxe/umalloc.h>
+
static int init_dev_data(void)
{
unsigned long tmp;
@@ -191,9 +193,13 @@ static int init_dev_data(void)
tprintf("outprm: va=%p, pa=0x%lx", dev_buffers_p->outprm_buf,
virt_to_bus(dev_buffers_p->outprm_buf));
- phys_mem.base =
- (virt_to_phys(_text) - reserve_size) & (~(reserve_size - 1));
-
+ userptr_t lotsofmem = umalloc ( reserve_size * 2 );
+ if ( ! lotsofmem ) {
+ printf ( "Could not allocate large memblock\n" );
+ return -1;
+ }
+ phys_mem.base = ( ( user_to_phys ( lotsofmem, 0 ) + reserve_size ) &
+ ~( reserve_size - 1 ) );
phys_mem.offset = 0;
return 0;
diff --git a/src/drivers/net/mlx_ipoib/mt23108.c b/src/drivers/net/mlx_ipoib/mt23108.c
index bd9a92f06..37947a8c8 100644
--- a/src/drivers/net/mlx_ipoib/mt23108.c
+++ b/src/drivers/net/mlx_ipoib/mt23108.c
@@ -148,7 +148,7 @@ static void tavor_transmit(struct nic *nic, const char *dest, /* Destination */
/**************************************************************************
DISABLE - Turn off ethernet interface
***************************************************************************/
-static void tavor_disable(struct dev *dev)
+static void tavor_disable(struct nic *nic)
{
/* put the card in its initial state */
/* This function serves 3 purposes.
@@ -160,18 +160,24 @@ static void tavor_disable(struct dev *dev)
* This allows etherboot to reinitialize the interface
* if something is something goes wrong.
*/
- if (dev || 1) { // ????
+ if (nic || 1) { // ????
disable_imp();
}
}
+static struct nic_operations tavor_operations = {
+ .connect = dummy_connect,
+ .poll = tavor_poll,
+ .transmit = tavor_transmit,
+ .irq = tavor_irq,
+};
+
/**************************************************************************
PROBE - Look for an adapter, this routine's visible to the outside
***************************************************************************/
-static int tavor_probe(struct dev *dev, struct pci_device *pci)
+static int tavor_probe(struct nic *nic, struct pci_device *pci)
{
- struct nic *nic = (struct nic *)dev;
int rc;
unsigned char user_request;
@@ -215,10 +221,7 @@ static int tavor_probe(struct dev *dev, struct pci_device *pci)
nic->ioaddr = pci->ioaddr & ~3;
nic->irqno = pci->irq;
/* point to NIC specific routines */
- dev->disable = tavor_disable;
- nic->poll = tavor_poll;
- nic->transmit = tavor_transmit;
- nic->irq = tavor_irq;
+ nic->nic_op = &tavor_operations;
return 1;
}
@@ -226,16 +229,12 @@ static int tavor_probe(struct dev *dev, struct pci_device *pci)
return 0;
}
-static struct pci_id tavor_nics[] = {
+static struct pci_device_id tavor_nics[] = {
PCI_ROM(0x15b3, 0x5a44, "MT23108", "MT23108 HCA driver"),
PCI_ROM(0x15b3, 0x6278, "MT25208", "MT25208 HCA driver"),
};
-static struct pci_driver tavor_driver __pci_driver = {
- .type = NIC_DRIVER,
- .name = "MT23108/MT25208",
- .probe = tavor_probe,
- .ids = tavor_nics,
- .id_count = sizeof(tavor_nics) / sizeof(tavor_nics[0]),
- .class = 0,
-};
+PCI_DRIVER ( tavor_driver, tavor_nics, PCI_NO_CLASS );
+
+DRIVER ( "MT23108/MT25208", nic_driver, pci_driver, tavor_driver,
+ tavor_probe, tavor_disable );
diff --git a/src/drivers/net/mlx_ipoib/mt23108_imp.c b/src/drivers/net/mlx_ipoib/mt23108_imp.c
index b1e855b19..d2bdf46bb 100644
--- a/src/drivers/net/mlx_ipoib/mt23108_imp.c
+++ b/src/drivers/net/mlx_ipoib/mt23108_imp.c
@@ -91,10 +91,12 @@ static int transmit_imp(const char *dest, /* Destination */
rc = ipoib_send_packet(dest, type, packet, size);
if (rc) {
printf("*** ERROR IN SEND FLOW ***\n");
+#if 0
printf("restarting Etherboot\n");
sleep(1);
longjmp(restart_etherboot, -1);
/* we should not be here ... */
+#endif
return -1;
}
@@ -222,9 +224,11 @@ static int poll_imp(struct nic *nic, int retrieve, unsigned int *size_p)
fatal_handling:
printf("restarting Etherboot\n");
+#if 0
sleep(1);
longjmp(restart_etherboot, -1);
/* we should not be here ... */
+#endif
return -1;
}
diff --git a/src/drivers/net/mlx_ipoib/mt25218.c b/src/drivers/net/mlx_ipoib/mt25218.c
index 25ae6c6b7..3273ebf65 100644
--- a/src/drivers/net/mlx_ipoib/mt25218.c
+++ b/src/drivers/net/mlx_ipoib/mt25218.c
@@ -148,7 +148,7 @@ static void mt25218_transmit(struct nic *nic, const char *dest, /* Destination *
/**************************************************************************
DISABLE - Turn off ethernet interface
***************************************************************************/
-static void mt25218_disable(struct dev *dev)
+static void mt25218_disable(struct nic *nic)
{
/* put the card in its initial state */
/* This function serves 3 purposes.
@@ -160,18 +160,24 @@ static void mt25218_disable(struct dev *dev)
* This allows etherboot to reinitialize the interface
* if something is something goes wrong.
*/
- if (dev || 1) { // ????
+ if (nic || 1) { // ????
disable_imp();
}
}
+static struct nic_operations mt25218_operations = {
+ .connect = dummy_connect,
+ .poll = mt25218_poll,
+ .transmit = mt25218_transmit,
+ .irq = mt25218_irq,
+};
+
/**************************************************************************
PROBE - Look for an adapter, this routine's visible to the outside
***************************************************************************/
-static int mt25218_probe(struct dev *dev, struct pci_device *pci)
+static int mt25218_probe(struct nic *nic, struct pci_device *pci)
{
- struct nic *nic = (struct nic *)dev;
int rc;
unsigned char user_request;
@@ -215,10 +221,7 @@ static int mt25218_probe(struct dev *dev, struct pci_device *pci)
nic->ioaddr = pci->ioaddr & ~3;
nic->irqno = pci->irq;
/* point to NIC specific routines */
- dev->disable = mt25218_disable;
- nic->poll = mt25218_poll;
- nic->transmit = mt25218_transmit;
- nic->irq = mt25218_irq;
+ nic->nic_op = &mt25218_operations;
return 1;
}
@@ -226,16 +229,12 @@ static int mt25218_probe(struct dev *dev, struct pci_device *pci)
return 0;
}
-static struct pci_id mt25218_nics[] = {
+static struct pci_device_id mt25218_nics[] = {
PCI_ROM(0x15b3, 0x6282, "MT25218", "MT25218 HCA driver"),
PCI_ROM(0x15b3, 0x6274, "MT25204", "MT25204 HCA driver"),
};
-static struct pci_driver mt25218_driver __pci_driver = {
- .type = NIC_DRIVER,
- .name = "MT25218",
- .probe = mt25218_probe,
- .ids = mt25218_nics,
- .id_count = sizeof(mt25218_nics) / sizeof(mt25218_nics[0]),
- .class = 0,
-};
+PCI_DRIVER ( mt25218_driver, mt25218_nics, PCI_NO_CLASS );
+
+DRIVER ( "MT25218", nic_driver, pci_driver, mt25218_driver,
+ mt25218_probe, mt25218_disable );
diff --git a/src/drivers/net/mlx_ipoib/mt25218_imp.c b/src/drivers/net/mlx_ipoib/mt25218_imp.c
index 9ab57f675..301f31df7 100644
--- a/src/drivers/net/mlx_ipoib/mt25218_imp.c
+++ b/src/drivers/net/mlx_ipoib/mt25218_imp.c
@@ -91,10 +91,12 @@ static int transmit_imp(const char *dest, /* Destination */
rc = ipoib_send_packet(dest, type, packet, size);
if (rc) {
printf("*** ERROR IN SEND FLOW ***\n");
+#if 0
printf("restarting Etherboot\n");
sleep(1);
longjmp(restart_etherboot, -1);
/* we should not be here ... */
+#endif
return -1;
}
@@ -221,10 +223,12 @@ static int poll_imp(struct nic *nic, int retrieve, unsigned int *size_p)
return 0;
fatal_handling:
+#if 0
printf("restarting Etherboot\n");
sleep(1);
longjmp(restart_etherboot, -1);
/* we should not be here ... */
+#endif
return -1;
}