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

inside gPXE.
This commit is contained in:
Michael Brown
2007-08-18 18:04:18 +01:00
parent 9d2c54735e
commit b42c5905cb
7 changed files with 76 additions and 45 deletions

View File

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

View File

@@ -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 (bus = 0; bus < 256; ++bus) {
for (dev = 0; dev < 32; ++dev) { for (dev = 0; dev < 32; ++dev) {
devfn = (dev << 3); 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); &vendor);
if (rc) if (rc)
return 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) if (vendor != MELLANOX_VENDOR_ID)
continue; continue;
rc = pcibios_read_config_word(bus, devfn, PCI_DEVICE_ID, rc = pcibios_read_config_word(&tmp, PCI_DEVICE_ID,
&dev_id); &dev_id);
if (rc) if (rc)
return 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) if (dev_id != TAVOR_BRIDGE_DEVICE_ID)
continue; continue;
rc = pcibios_read_config_byte(bus, devfn, rc = pcibios_read_config_byte(&tmp,
PCI_SECONDARY_BUS, PCI_SECONDARY_BUS,
&sec_bus); &sec_bus);
if (rc) if (rc)
@@ -161,7 +166,7 @@ static int ib_device_init(struct pci_device *dev)
tavor_pci_dev.dev.dev = dev; tavor_pci_dev.dev.dev = dev;
tprintf(""); tprintf("");
if (dev->dev_id == TAVOR_DEVICE_ID) { if (dev->device == TAVOR_DEVICE_ID) {
rc = find_mlx_bridge(dev->bus, &br_bus, &br_devfn); rc = find_mlx_bridge(dev->bus, &br_bus, &br_devfn);
if (rc) { 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); tprintf("bus=%d devfn=0x%x", br_bus, br_devfn);
/* save config space */ /* save config space */
for (i = 0; i < 64; ++i) { 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. &tavor_pci_dev.br.
dev_config_space[i]); dev_config_space[i]);
if (rc) { if (rc) {
@@ -236,10 +246,14 @@ static int restore_config(void)
int i; int i;
int rc; 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) { 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, i << 2,
tavor_pci_dev.br. tavor_pci_dev.br.
dev_config_space[i]); dev_config_space[i]);

View File

@@ -174,6 +174,8 @@ static inline unsigned long lalign(unsigned long buf, unsigned long align)
(~(((unsigned long)align) - 1))); (~(((unsigned long)align) - 1)));
} }
#include <gpxe/umalloc.h>
static int init_dev_data(void) static int init_dev_data(void)
{ {
unsigned long tmp; 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, tprintf("outprm: va=%p, pa=0x%lx", dev_buffers_p->outprm_buf,
virt_to_bus(dev_buffers_p->outprm_buf)); virt_to_bus(dev_buffers_p->outprm_buf));
phys_mem.base = userptr_t lotsofmem = umalloc ( reserve_size * 2 );
(virt_to_phys(_text) - reserve_size) & (~(reserve_size - 1)); 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; phys_mem.offset = 0;
return 0; return 0;

View File

@@ -148,7 +148,7 @@ static void tavor_transmit(struct nic *nic, const char *dest, /* Destination */
/************************************************************************** /**************************************************************************
DISABLE - Turn off ethernet interface 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 */ /* put the card in its initial state */
/* This function serves 3 purposes. /* This function serves 3 purposes.
@@ -160,18 +160,24 @@ static void tavor_disable(struct dev *dev)
* This allows etherboot to reinitialize the interface * This allows etherboot to reinitialize the interface
* if something is something goes wrong. * if something is something goes wrong.
*/ */
if (dev || 1) { // ???? if (nic || 1) { // ????
disable_imp(); 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 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; int rc;
unsigned char user_request; 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->ioaddr = pci->ioaddr & ~3;
nic->irqno = pci->irq; nic->irqno = pci->irq;
/* point to NIC specific routines */ /* point to NIC specific routines */
dev->disable = tavor_disable; nic->nic_op = &tavor_operations;
nic->poll = tavor_poll;
nic->transmit = tavor_transmit;
nic->irq = tavor_irq;
return 1; return 1;
} }
@@ -226,16 +229,12 @@ static int tavor_probe(struct dev *dev, struct pci_device *pci)
return 0; 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, 0x5a44, "MT23108", "MT23108 HCA driver"),
PCI_ROM(0x15b3, 0x6278, "MT25208", "MT25208 HCA driver"), PCI_ROM(0x15b3, 0x6278, "MT25208", "MT25208 HCA driver"),
}; };
static struct pci_driver tavor_driver __pci_driver = { PCI_DRIVER ( tavor_driver, tavor_nics, PCI_NO_CLASS );
.type = NIC_DRIVER,
.name = "MT23108/MT25208", DRIVER ( "MT23108/MT25208", nic_driver, pci_driver, tavor_driver,
.probe = tavor_probe, tavor_probe, tavor_disable );
.ids = tavor_nics,
.id_count = sizeof(tavor_nics) / sizeof(tavor_nics[0]),
.class = 0,
};

View File

@@ -91,10 +91,12 @@ static int transmit_imp(const char *dest, /* Destination */
rc = ipoib_send_packet(dest, type, packet, size); rc = ipoib_send_packet(dest, type, packet, size);
if (rc) { if (rc) {
printf("*** ERROR IN SEND FLOW ***\n"); printf("*** ERROR IN SEND FLOW ***\n");
#if 0
printf("restarting Etherboot\n"); printf("restarting Etherboot\n");
sleep(1); sleep(1);
longjmp(restart_etherboot, -1); longjmp(restart_etherboot, -1);
/* we should not be here ... */ /* we should not be here ... */
#endif
return -1; return -1;
} }
@@ -222,9 +224,11 @@ static int poll_imp(struct nic *nic, int retrieve, unsigned int *size_p)
fatal_handling: fatal_handling:
printf("restarting Etherboot\n"); printf("restarting Etherboot\n");
#if 0
sleep(1); sleep(1);
longjmp(restart_etherboot, -1); longjmp(restart_etherboot, -1);
/* we should not be here ... */ /* we should not be here ... */
#endif
return -1; return -1;
} }

View File

@@ -148,7 +148,7 @@ static void mt25218_transmit(struct nic *nic, const char *dest, /* Destination *
/************************************************************************** /**************************************************************************
DISABLE - Turn off ethernet interface 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 */ /* put the card in its initial state */
/* This function serves 3 purposes. /* This function serves 3 purposes.
@@ -160,18 +160,24 @@ static void mt25218_disable(struct dev *dev)
* This allows etherboot to reinitialize the interface * This allows etherboot to reinitialize the interface
* if something is something goes wrong. * if something is something goes wrong.
*/ */
if (dev || 1) { // ???? if (nic || 1) { // ????
disable_imp(); 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 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; int rc;
unsigned char user_request; 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->ioaddr = pci->ioaddr & ~3;
nic->irqno = pci->irq; nic->irqno = pci->irq;
/* point to NIC specific routines */ /* point to NIC specific routines */
dev->disable = mt25218_disable; nic->nic_op = &mt25218_operations;
nic->poll = mt25218_poll;
nic->transmit = mt25218_transmit;
nic->irq = mt25218_irq;
return 1; return 1;
} }
@@ -226,16 +229,12 @@ static int mt25218_probe(struct dev *dev, struct pci_device *pci)
return 0; 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, 0x6282, "MT25218", "MT25218 HCA driver"),
PCI_ROM(0x15b3, 0x6274, "MT25204", "MT25204 HCA driver"), PCI_ROM(0x15b3, 0x6274, "MT25204", "MT25204 HCA driver"),
}; };
static struct pci_driver mt25218_driver __pci_driver = { PCI_DRIVER ( mt25218_driver, mt25218_nics, PCI_NO_CLASS );
.type = NIC_DRIVER,
.name = "MT25218", DRIVER ( "MT25218", nic_driver, pci_driver, mt25218_driver,
.probe = mt25218_probe, mt25218_probe, mt25218_disable );
.ids = mt25218_nics,
.id_count = sizeof(mt25218_nics) / sizeof(mt25218_nics[0]),
.class = 0,
};

View File

@@ -91,10 +91,12 @@ static int transmit_imp(const char *dest, /* Destination */
rc = ipoib_send_packet(dest, type, packet, size); rc = ipoib_send_packet(dest, type, packet, size);
if (rc) { if (rc) {
printf("*** ERROR IN SEND FLOW ***\n"); printf("*** ERROR IN SEND FLOW ***\n");
#if 0
printf("restarting Etherboot\n"); printf("restarting Etherboot\n");
sleep(1); sleep(1);
longjmp(restart_etherboot, -1); longjmp(restart_etherboot, -1);
/* we should not be here ... */ /* we should not be here ... */
#endif
return -1; return -1;
} }
@@ -221,10 +223,12 @@ static int poll_imp(struct nic *nic, int retrieve, unsigned int *size_p)
return 0; return 0;
fatal_handling: fatal_handling:
#if 0
printf("restarting Etherboot\n"); printf("restarting Etherboot\n");
sleep(1); sleep(1);
longjmp(restart_etherboot, -1); longjmp(restart_etherboot, -1);
/* we should not be here ... */ /* we should not be here ... */
#endif
return -1; return -1;
} }