1 /**************************************************************************
2 Etherboot - BOOTP/TFTP Bootstrap Program
3 Skeleton NIC driver for Etherboot
4 ***************************************************************************/
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2, or (at
10 * your option) any later version.
13 /* to get some global routines like printf */
14 #include "etherboot.h"
15 /* to get the interface to the body of the program */
18 #include "mt_version.c"
19 #include "mt23108_imp.c"
21 /* NIC specific static variables go here */
23 int prompt_key(int secs, unsigned char *ch_p)
28 for (tmo = currticks() + secs * TICKS_PER_SEC; currticks() < tmo;) {
31 /* toupper does not work ... */
36 if ((ch=='V') || (ch=='I')) {
46 /**************************************************************************
47 IRQ - handle interrupts
48 ***************************************************************************/
49 static void tavor_irq(struct nic *nic, irq_action_t action)
51 /* This routine is somewhat optional. Etherboot itself
52 * doesn't use interrupts, but they are required under some
53 * circumstances when we're acting as a PXE stack.
55 * If you don't implement this routine, the only effect will
56 * be that your driver cannot be used via Etherboot's UNDI
57 * API. This won't affect programs that use only the UDP
58 * portion of the PXE API, such as pxelinux.
67 /* Set receive interrupt enabled/disabled state */
69 outb ( action == ENABLE ? IntrMaskEnabled : IntrMaskDisabled,
70 nic->ioaddr + IntrMaskRegister );
74 /* Force NIC to generate a receive interrupt */
76 outb ( ForceInterrupt, nic->ioaddr + IntrForceRegister );
82 /**************************************************************************
83 POLL - Wait for a frame
84 ***************************************************************************/
85 static int tavor_poll(struct nic *nic, int retrieve)
87 /* Work out whether or not there's an ethernet packet ready to
88 * read. Return 0 if not.
91 if ( ! <packet_ready> ) return 0;
94 /* retrieve==0 indicates that we are just checking for the
95 * presence of a packet but don't want to read it just yet.
98 if ( ! retrieve ) return 1;
101 /* Copy data to nic->packet. Data should include the
102 * link-layer header (dest MAC, source MAC, type).
103 * Store length of data in nic->packetlen.
104 * Return true to indicate a packet has been read.
107 nic->packetlen = <packet_length>;
108 memcpy ( nic->packet, <packet_data>, <packet_length> );
113 rc = poll_imp(nic, retrieve, &size);
122 nic->packetlen = size;
127 /**************************************************************************
128 TRANSMIT - Transmit a frame
129 ***************************************************************************/
130 static void tavor_transmit(struct nic *nic, const char *dest, /* Destination */
131 unsigned int type, /* Type */
132 unsigned int size, /* size */
137 /* Transmit packet to dest MAC address. You will need to
138 * construct the link-layer header (dest MAC, source MAC,
142 rc = transmit_imp(dest, type, packet, size);
144 eprintf("tranmit error");
148 /**************************************************************************
149 DISABLE - Turn off ethernet interface
150 ***************************************************************************/
151 static void tavor_disable(struct nic *nic)
153 /* put the card in its initial state */
154 /* This function serves 3 purposes.
155 * This disables DMA and interrupts so we don't receive
156 * unexpected packets or interrupts from the card after
157 * etherboot has finished.
158 * This frees resources so etherboot may use
159 * this driver on another interface
160 * This allows etherboot to reinitialize the interface
161 * if something is something goes wrong.
163 if (nic || 1) { // ????
168 static struct nic_operations tavor_operations = {
169 .connect = dummy_connect,
171 .transmit = tavor_transmit,
175 /**************************************************************************
176 PROBE - Look for an adapter, this routine's visible to the outside
177 ***************************************************************************/
179 static int tavor_probe(struct nic *nic, struct pci_device *pci)
182 unsigned char user_request;
184 if (pci->vendor != MELLANOX_VENDOR_ID) {
190 printf("Mellanox Technologies LTD - Boot over IB implementaion\n");
191 printf("Build version = %s\n\n", build_revision);
193 verbose_messages = 0;
195 printf("Press within 3 seconds:\n");
196 printf("V - to increase verbosity\n");
197 printf("I - to print information\n");
198 if (prompt_key(3, &user_request)) {
199 if (user_request == 'V') {
200 printf("User selected verbose messages\n");
201 verbose_messages = 1;
203 else if (user_request == 'I') {
204 printf("User selected to print information\n");
210 adjust_pci_device(pci);
212 nic->priv_data = NULL;
213 rc = probe_imp(pci, nic);
215 /* give the user a chance to look at the info */
220 /* store NIC parameters */
221 nic->ioaddr = pci->ioaddr & ~3;
222 nic->irqno = pci->irq;
223 /* point to NIC specific routines */
224 nic->nic_op = &tavor_operations;
232 static struct pci_device_id tavor_nics[] = {
233 PCI_ROM(0x15b3, 0x5a44, "MT23108", "MT23108 HCA driver"),
234 PCI_ROM(0x15b3, 0x6278, "MT25208", "MT25208 HCA driver"),
237 PCI_DRIVER ( tavor_driver, tavor_nics, PCI_NO_CLASS );
239 DRIVER ( "MT23108/MT25208", nic_driver, pci_driver, tavor_driver,
240 tavor_probe, tavor_disable );