iPXE
eepro100.c
Go to the documentation of this file.
1/*
2 * eepro100.c -- This is a driver for Intel Fast Ethernet Controllers
3 * (ifec).
4 *
5 * Originally written for Etherboot by:
6 *
7 * Copyright (C) AW Computer Systems.
8 * written by R.E.Wolff -- R.E.Wolff@BitWizard.nl
9 *
10 * AW Computer Systems is contributing to the free software community
11 * by paying for this driver and then putting the result under GPL.
12 *
13 * If you need a Linux device driver, please contact BitWizard for a
14 * quote.
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License as
18 * published by the Free Software Foundation; either version 2, or (at
19 * your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful, but
22 * WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
29 * 02110-1301, USA.
30 *
31 *
32 * date version by what
33 * Written: May 29 1997 V0.10 REW Initial revision.
34 * changes: May 31 1997 V0.90 REW Works!
35 * Jun 1 1997 V0.91 REW Cleanup
36 * Jun 2 1997 V0.92 REW Add some code documentation
37 * Jul 25 1997 V1.00 REW Tested by AW to work in a PROM
38 * Cleanup for publication
39 * Dez 11 2004 V1.10 Kiszka Add RX ring buffer support
40 * Jun 2008 v2.0 mdeck Updated to iPXE. Changed much.
41 *
42 * Cleanups and fixes by Thomas Miletich<thomas.miletich@gmail.com>
43 *
44 * This is the etherboot intel etherexpress Pro/100B driver.
45 *
46 * It was written from scratch, with Donald Beckers eepro100.c kernel
47 * driver as a guideline. Mostly the 82557 related definitions and the
48 * lower level routines have been cut-and-pasted into this source.
49 *
50 * The driver was finished before Intel got the NDA out of the closet.
51 *
52 * Datasheet is now published and available from
53 * ftp://download.intel.com/design/network/manuals/8255X_OpenSDM.pdf
54 * - Michael Brown
55 * */
56
57FILE_LICENCE ( GPL2_OR_LATER );
58
59/*
60 * General Theory of Operation
61 *
62 * Initialization
63 *
64 * ifec_pci_probe() is called by iPXE during initialization. Typical NIC
65 * initialization is performed. EEPROM data is read.
66 *
67 * Network Boot
68 *
69 * ifec_net_open() is called by iPXE before attempting to network boot from the
70 * card. Here, the Command Unit & Receive Unit are initialized. The tx & rx
71 * rings are setup. The MAC address is programmed and the card is configured.
72 *
73 * Transmit
74 *
75 * ifec_net_transmit() enqueues a packet in the tx ring - active::tcbs[] The tx
76 * ring is composed of TCBs linked to each other into a ring. A tx request
77 * fills out the next available TCB with a pointer to the packet data.
78 * The last enqueued tx is always at active::tcb_head. Thus, a tx request fills
79 * out the TCB following tcb_head.
80 * active::tcb_tail points to the TCB we're awaiting completion of.
81 * ifec_tx_process() checks tcb_tail, and once complete,
82 * blindly increments tcb_tail to the next ring TCB.
83 *
84 * Receive
85 *
86 * priv::rfds[] is an array of Receive Frame Descriptors. The RFDs are linked
87 * together to form a ring.
88 * ifec_net_poll() calls ifec_rx_process(), which checks the next RFD for
89 * data. If we received a packet, we allocate a new io_buffer and copy the
90 * packet data into it. If alloc_iob() fails, we don't touch the RFD and try
91 * again on the next poll.
92 */
93
94/*
95 * Debugging levels:
96 * - DBG() is for any errors, i.e. failed alloc_iob(), malloc_phys(),
97 * TX overflow, corrupted packets, ...
98 * - DBG2() is for successful events, like packet received,
99 * packet transmitted, and other general notifications.
100 * - DBGP() prints the name of each called function on entry
101 */
102
103#include <stdint.h>
104#include <string.h>
105#include <byteswap.h>
106#include <errno.h>
107#include <stdio.h>
108#include <unistd.h>
109#include <ipxe/ethernet.h>
110#include <ipxe/if_ether.h>
111#include <ipxe/iobuf.h>
112#include <ipxe/malloc.h>
113#include <ipxe/pci.h>
114#include <ipxe/spi_bit.h>
115#include <ipxe/timer.h>
116#include <ipxe/nvs.h>
117#include <ipxe/threewire.h>
118#include <ipxe/netdevice.h>
119#include "eepro100.h"
120
121/****************************** Global data **********************************/
122
123/*
124 * This is the default configuration command data. The values were copied from
125 * the Linux kernel initialization for the eepro100.
126 */
127static struct ifec_cfg ifec_cfg = {
128 .status = 0,
129 .command = CmdConfigure | CmdSuspend,
130 .link = 0, /* Filled in later */
131 .byte = { 22, /* How many bytes in this array */
132 ( TX_FIFO << 4 ) | RX_FIFO, /* Rx & Tx FIFO limits */
133 0, 0, /* Adaptive Interframe Spacing */
134 RX_DMA_COUNT, /* Rx DMA max byte count */
135 TX_DMA_COUNT + 0x80, /* Tx DMA max byte count */
136 0x32, /* Many bits. */
137 0x03, /* Discard short receive & Underrun retries */
138 1, /* 1=Use MII 0=Use AUI */
139 0,
140 0x2E, /* NSAI, Preamble length, & Loopback*/
141 0, /* Linear priority */
142 0x60, /* L PRI MODE & Interframe spacing */
143 0, 0xf2,
144 0x48, /* Promiscuous, Broadcast disable, CRS & CDT */
145 0, 0x40,
146 0xf2, /* Stripping, Padding, Receive CRC Transfer */
147 0x80, /* 0x40=Force full-duplex, 0x80=Allowfull-duplex*/
148 0x3f, /* Multiple IA */
149 0x0D } /* Multicast all */
150};
151
153 .open = ifec_net_open,
154 .close = ifec_net_close,
155 .transmit = ifec_net_transmit,
156 .poll = ifec_net_poll,
157 .irq = ifec_net_irq
158};
159
160/******************* iPXE PCI Device Driver API functions ********************/
161
162/*
163 * Initialize the PCI device.
164 *
165 * @v pci The device's associated pci_device structure.
166 * @v id The PCI device + vendor id.
167 * @ret rc Returns zero if successfully initialized.
168 *
169 * This function is called very early on, while iPXE is initializing.
170 * This is a iPXE PCI Device Driver API function.
171 */
172static int ifec_pci_probe ( struct pci_device *pci )
173{
174 struct net_device *netdev;
175 struct ifec_private *priv;
176 int rc;
177
178 DBGP ( "ifec_pci_probe: " );
179
180 if ( pci->ioaddr == 0 )
181 return -EINVAL;
182
183 netdev = alloc_etherdev ( sizeof(*priv) );
184 if ( !netdev )
185 return -ENOMEM;
186
188 priv = netdev->priv;
189
190 pci_set_drvdata ( pci, netdev );
191 netdev->dev = &pci->dev;
192
193 /* enable bus master, etc */
194 adjust_pci_device( pci );
195
196 DBGP ( "pci " );
197
198 memset ( priv, 0, sizeof(*priv) );
199 priv->ioaddr = pci->ioaddr;
200
201 ifec_reset ( netdev );
202 DBGP ( "reset " );
203
205
206 /* read MAC address */
207 nvs_read ( &priv->eeprom.nvs, EEPROM_ADDR_MAC_0, netdev->hw_addr,
208 ETH_ALEN );
209 /* read mdio_register */
211 &priv->mdio_register, 2 );
212
213 if ( ( rc = register_netdev ( netdev ) ) != 0 )
214 goto error;
215
217
218 DBGP ( "ints\n" );
219
220 return 0;
221
222error:
223 ifec_reset ( netdev );
225 netdev_put ( netdev );
226
227 return rc;
228}
229
230/*
231 * Remove a device from the PCI device list.
232 *
233 * @v pci PCI device to remove.
234 *
235 * This is a PCI Device Driver API function.
236 */
237static void ifec_pci_remove ( struct pci_device *pci )
238{
239 struct net_device *netdev = pci_get_drvdata ( pci );
240
241 DBGP ( "ifec_pci_remove\n" );
242
244 ifec_reset ( netdev );
246 netdev_put ( netdev );
247}
248
249/****************** iPXE Network Device Driver API functions *****************/
250
251/*
252 * Close a network device.
253 *
254 * @v netdev Device to close.
255 *
256 * This is a iPXE Network Device Driver API function.
257 */
258static void ifec_net_close ( struct net_device *netdev )
259{
260 struct ifec_private *priv = netdev->priv;
261 unsigned long ioaddr = priv->ioaddr;
262 unsigned short intr_status;
263
264 DBGP ( "ifec_net_close\n" );
265
266 /* disable interrupts */
267 ifec_net_irq ( netdev, 0 );
268
269 /* Ack & clear ints */
270 intr_status = inw ( ioaddr + SCBStatus );
271 outw ( intr_status, ioaddr + SCBStatus );
272 inw ( ioaddr + SCBStatus );
273
274 ifec_reset ( netdev );
275
276 /* Free any resources */
277 ifec_free ( netdev );
278}
279
280/* Interrupts to be masked */
281#define INTERRUPT_MASK ( SCBMaskEarlyRx | SCBMaskFlowCtl )
282
283/*
284 * Enable or disable IRQ masking.
285 *
286 * @v netdev Device to control.
287 * @v enable Zero to mask off IRQ, non-zero to enable IRQ.
288 *
289 * This is a iPXE Network Driver API function.
290 */
291static void ifec_net_irq ( struct net_device *netdev, int enable )
292{
293 struct ifec_private *priv = netdev->priv;
294 unsigned long ioaddr = priv->ioaddr;
295
296 DBGP ( "ifec_net_irq\n" );
297
298 outw ( enable ? INTERRUPT_MASK : SCBMaskAll, ioaddr + SCBCmd );
299}
300
301/*
302 * Opens a network device.
303 *
304 * @v netdev Device to be opened.
305 * @ret rc Non-zero if failed to open.
306 *
307 * This enables tx and rx on the device.
308 * This is a iPXE Network Device Driver API function.
309 */
310static int ifec_net_open ( struct net_device *netdev )
311{
312 struct ifec_private *priv = netdev->priv;
313 struct ifec_ias *ias = NULL;
314 struct ifec_cfg *cfg = NULL;
315 int i, options;
316 int rc = -ENOMEM;
317
318 DBGP ( "ifec_net_open: " );
319
320 /* Ensure interrupts are disabled. */
321 ifec_net_irq ( netdev, 0 );
322
323 /* Initialize Command Unit and Receive Unit base addresses. */
327
328 /* Initialize both rings */
329 if ( ( rc = ifec_rx_setup ( netdev ) ) != 0 )
330 goto error;
331 if ( ( rc = ifec_tx_setup ( netdev ) ) != 0 )
332 goto error;
333
334 /* Initialize MDIO */
335 options = 0x00; /* 0x40 = 10mbps half duplex, 0x00 = Autosense */
337
338 /* Prepare MAC address w/ Individual Address Setup (ias) command.*/
339 ias = malloc_phys ( sizeof ( *ias ), CB_ALIGN );
340 if ( !ias ) {
341 rc = -ENOMEM;
342 goto error;
343 }
344 ias->command = CmdIASetup;
345 ias->status = 0;
346 memcpy ( ias->ia, netdev->ll_addr, ETH_ALEN );
347
348 /* Prepare operating parameters w/ a configure command. */
349 cfg = malloc_phys ( sizeof ( *cfg ), CB_ALIGN );
350 if ( !cfg ) {
351 rc = -ENOMEM;
352 goto error;
353 }
354 memcpy ( cfg, &ifec_cfg, sizeof ( *cfg ) );
355 cfg->link = virt_to_bus ( priv->tcbs );
356 cfg->byte[19] = ( options & 0x10 ) ? 0xC0 : 0x80;
357 ias->link = virt_to_bus ( cfg );
358
359 /* Issue the ias and configure commands. */
362 priv->configured = 1;
363
364 /* Wait up to 10 ms for configuration to initiate */
365 for ( i = 10; i && !cfg->status; i-- )
366 mdelay ( 1 );
367 if ( ! cfg->status ) {
368 DBG ( "Failed to initiate!\n" );
369 goto error;
370 }
371 free_phys ( ias, sizeof ( *ias ) );
372 free_phys ( cfg, sizeof ( *cfg ) );
373 DBG2 ( "cfg " );
374
375 /* Enable rx by sending ring address to card */
376 if ( priv->rfds[0] != NULL ) {
377 ifec_scb_cmd ( netdev, virt_to_bus( priv->rfds[0] ), RUStart );
379 }
380 DBG2 ( "rx_start\n" );
381
382 return 0;
383
384error:
385 free_phys ( cfg, sizeof ( *cfg ) );
386 free_phys ( ias, sizeof ( *ias ) );
387 ifec_free ( netdev );
388 ifec_reset ( netdev );
389 return rc;
390}
391
392/*
393 * This function allows a driver to process events during operation.
394 *
395 * @v netdev Device being polled.
396 *
397 * This is called periodically by iPXE to let the driver check the status of
398 * transmitted packets and to allow the driver to check for received packets.
399 * This is a iPXE Network Device Driver API function.
400 */
401static void ifec_net_poll ( struct net_device *netdev )
402{
403 struct ifec_private *priv = netdev->priv;
404 unsigned short intr_status;
405
406 DBGP ( "ifec_net_poll\n" );
407
408 /* acknowledge interrupts ASAP */
409 intr_status = inw ( priv->ioaddr + SCBStatus );
410 outw ( intr_status, priv->ioaddr + SCBStatus );
411 inw ( priv->ioaddr + SCBStatus );
412
413 DBG2 ( "poll - status: 0x%04X\n", intr_status );
414
415 /* anything to do here? */
416 if ( ( intr_status & ( ~INTERRUPT_MASK ) ) == 0 )
417 return;
418
419 /* process received and transmitted packets */
422
423 ifec_check_ru_status ( netdev, intr_status );
424
425 return;
426}
427
428/*
429 * This transmits a packet.
430 *
431 * @v netdev Device to transmit from.
432 * @v iobuf Data to transmit.
433 * @ret rc Non-zero if failed to transmit.
434 *
435 * This is a iPXE Network Driver API function.
436 */
438 struct io_buffer *iobuf )
439{
440 struct ifec_private *priv = netdev->priv;
441 struct ifec_tcb *tcb = priv->tcb_head->next;
442 unsigned long ioaddr = priv->ioaddr;
443
444 DBGP ( "ifec_net_transmit\n" );
445
446 /* Wait for TCB to become available. */
447 if ( tcb->status || tcb->iob ) {
448 DBG ( "TX overflow\n" );
449 return -ENOBUFS;
450 }
451
452 DBG2 ( "transmitting packet (%zd bytes). status = %hX, cmd=%hX\n",
453 iob_len ( iobuf ), tcb->status, inw ( ioaddr + SCBCmd ) );
454
456 tcb->count = 0x01208000;
457 tcb->tbd_addr0 = virt_to_bus ( iobuf->data );
458 tcb->tbd_size0 = 0x3FFF & iob_len ( iobuf );
459 tcb->iob = iobuf;
460
462
463 /* Append to end of ring. */
464 priv->tcb_head = tcb;
465
466 return 0;
467}
468
469/*************************** Local support functions *************************/
470
471/* Define what each GPIO Pin does */
478
479/*
480 * Read a single bit from the GPIO pins used for SPI.
481 * should be called by SPI bitbash functions only
482 *
483 * @v basher Bitbash device
484 * @v bit_id Line to be read
485 */
486static int ifec_spi_read_bit ( struct bit_basher *basher,
487 unsigned int bit_id )
488{
489 struct ifec_private *priv =
490 container_of ( basher, struct ifec_private, spi.basher );
491 unsigned long ee_addr = priv->ioaddr + CSREeprom;
492 unsigned int ret = 0;
493 uint16_t mask;
494
495 DBGP ( "ifec_spi_read_bit\n" );
496
497 mask = ifec_ee_bits[bit_id];
498 ret = inw (ee_addr);
499
500 return ( ret & mask ) ? 1 : 0;
501}
502
503/*
504 * Write a single bit to the GPIO pins used for SPI.
505 * should be called by SPI bitbash functions only
506 *
507 * @v basher Bitbash device
508 * @v bit_id Line to write to
509 * @v data Value to write
510 */
511static void ifec_spi_write_bit ( struct bit_basher *basher,
512 unsigned int bit_id,
513 unsigned long data )
514{
515 struct ifec_private *priv =
516 container_of ( basher, struct ifec_private, spi.basher );
517 unsigned long ee_addr = priv->ioaddr + CSREeprom;
518 short val;
519 uint16_t mask = ifec_ee_bits[bit_id];
520
521 DBGP ( "ifec_spi_write_bit\n" );
522
523 val = inw ( ee_addr );
524 val &= ~mask;
525 val |= data & mask;
526
527 outw ( val, ee_addr );
528}
529
530/* set function pointer to SPI read- and write-bit functions */
532 .read = ifec_spi_read_bit,
533 .write = ifec_spi_write_bit,
534};
535
536/*
537 * Initialize the eeprom stuff
538 *
539 * @v netdev Network device
540 */
541static void ifec_init_eeprom ( struct net_device *netdev )
542{
543 struct ifec_private *priv = netdev->priv;
544
545 DBGP ( "ifec_init_eeprom\n" );
546
547 priv->spi.basher.op = &ifec_basher_ops;
548 priv->spi.bus.mode = SPI_MODE_THREEWIRE;
549 init_spi_bit_basher ( &priv->spi );
550
551 priv->eeprom.bus = &priv->spi.bus;
552
553 /* init as 93c46(93c14 compatible) first, to set the command len,
554 * block size and word len. Needs to be set for address len detection.
555 */
556 init_at93c46 ( &priv->eeprom, 16 );
557
558 /* detect address length, */
560
561 /* address len == 8 means 93c66 instead of 93c46 */
562 if ( priv->eeprom.address_len == 8 )
563 init_at93c66 ( &priv->eeprom, 16 );
564}
565
566/*
567 * Support function: ifec_mdio_read
568 *
569 * This probably reads a register in the "physical media interface chip".
570 * -- REW
571 */
572static int ifec_mdio_read ( struct net_device *netdev, int phy_id,
573 int location )
574{
575 struct ifec_private *priv = netdev->priv;
576 unsigned long ioaddr = priv->ioaddr;
577 int val;
578 int boguscnt = 64*4; /* <64 usec. to complete, typ 27 ticks */
579
580 DBGP ( "ifec_mdio_read\n" );
581
582 outl ( 0x08000000 | ( location << 16 ) | ( phy_id << 21 ),
583 ioaddr + CSRCtrlMDI );
584 do {
585 udelay ( 16 );
586
587 val = inl ( ioaddr + CSRCtrlMDI );
588
589 if ( --boguscnt < 0 ) {
590 DBG ( " ifec_mdio_read() time out with val = %X.\n",
591 val );
592 break;
593 }
594 } while (! ( val & 0x10000000 ) );
595 return val & 0xffff;
596}
597
598/*
599 * Initializes MDIO.
600 *
601 * @v netdev Network device
602 * @v options MDIO options
603 */
604static void ifec_mdio_setup ( struct net_device *netdev, int options )
605{
606 struct ifec_private *priv = netdev->priv;
607 unsigned short mdio_register = priv->mdio_register;
608
609 DBGP ( "ifec_mdio_setup\n" );
610
611 if ( ( (mdio_register>>8) & 0x3f ) == DP83840
612 || ( (mdio_register>>8) & 0x3f ) == DP83840A ) {
613 int mdi_reg23 = ifec_mdio_read ( netdev, mdio_register
614 & 0x1f, 23 ) | 0x0422;
615 if (CONGENB)
616 mdi_reg23 |= 0x0100;
617 DBG2 ( "DP83840 specific setup, setting register 23 to "
618 "%hX.\n", mdi_reg23 );
619 ifec_mdio_write ( netdev, mdio_register & 0x1f, 23, mdi_reg23 );
620 }
621 DBG2 ( "dp83840 " );
622 if ( options != 0 ) {
624 ( (options & 0x20) ? 0x2000 : 0 ) |
625 ( (options & 0x10) ? 0x0100 : 0 ) );
626 DBG2 ( "set mdio_register. " );
627 }
628}
629
630/*
631 * Support function: ifec_mdio_write
632 *
633 * This probably writes to the "physical media interface chip".
634 * -- REW
635 */
636static int ifec_mdio_write ( struct net_device *netdev,
637 int phy_id, int location, int value )
638{
639 struct ifec_private *priv = netdev->priv;
640 unsigned long ioaddr = priv->ioaddr;
641 int val;
642 int boguscnt = 64*4; /* <64 usec. to complete, typ 27 ticks */
643
644 DBGP ( "ifec_mdio_write\n" );
645
646 outl ( 0x04000000 | ( location << 16 ) | ( phy_id << 21 ) | value,
647 ioaddr + CSRCtrlMDI );
648 do {
649 udelay ( 16 );
650
651 val = inl ( ioaddr + CSRCtrlMDI );
652 if ( --boguscnt < 0 ) {
653 DBG ( " ifec_mdio_write() time out with val = %X.\n",
654 val );
655 break;
656 }
657 } while (! ( val & 0x10000000 ) );
658 return val & 0xffff;
659}
660
661/*
662 * Resets the hardware.
663 *
664 * @v netdev Network device
665 */
666static void ifec_reset ( struct net_device *netdev )
667{
668 struct ifec_private *priv = netdev->priv;
669 unsigned long ioaddr = priv->ioaddr;
670
671 DBGP ( "ifec_reset\n" );
672
673 /* do partial reset first */
675 inw ( ioaddr + SCBStatus );
676 udelay ( 20 );
677
678 /* full reset */
680 inw ( ioaddr + SCBStatus );
681 udelay ( 20 );
682
683 /* disable interrupts again */
684 ifec_net_irq ( netdev, 0 );
685}
686
687/*
688 * free()s the tx/rx rings.
689 *
690 * @v netdev Network device
691 */
692static void ifec_free ( struct net_device *netdev )
693{
694 struct ifec_private *priv = netdev->priv;
695 int i;
696
697 DBGP ( "ifec_free\n" );
698
699 /* free all allocated receive io_buffers */
700 for ( i = 0; i < RFD_COUNT; i++ ) {
701 free_iob ( priv->rx_iobs[i] );
702 priv->rx_iobs[i] = NULL;
703 priv->rfds[i] = NULL;
704 }
705
706 /* free TX ring buffer */
707 free_phys ( priv->tcbs, TX_RING_BYTES );
708
709 priv->tcbs = NULL;
710}
711
712/*
713 * Initializes an RFD.
714 *
715 * @v rfd RFD struct to initialize
716 * @v command Command word
717 * @v link Link value
718 */
719static void ifec_rfd_init ( struct ifec_rfd *rfd, s16 command, u32 link )
720{
721 DBGP ( "ifec_rfd_init\n" );
722
723 rfd->status = 0;
724 rfd->command = command;
725 rfd->rx_buf_addr = 0xFFFFFFFF;
726 rfd->count = 0;
727 rfd->size = RFD_PACKET_LEN;
728 rfd->link = link;
729}
730
731/*
732 * Send address of new RFD to card
733 *
734 * @v netdev Network device
735 */
736static void ifec_reprime_ru ( struct net_device *netdev )
737{
738 struct ifec_private *priv = netdev->priv;
739 int cur_rx = priv->cur_rx;
740
741 DBGP ( "ifec_reprime_ru\n" );
742
743 if ( priv->rfds[cur_rx] != NULL ) {
745 RUStart );
747 }
748}
749
750/*
751 * Check if reprime of RU needed
752 *
753 * @v netdev Network device
754 */
756 unsigned short intr_status )
757{
758 struct ifec_private *priv = netdev->priv;
759
760 DBGP ( "ifec_check_ru_status\n" );
761
762 /*
763 * The chip may have suspended reception for various reasons.
764 * Check for that, and re-prime it should this be the case.
765 */
766 switch ( ( intr_status >> 2 ) & 0xf ) {
767 case 0: /* Idle */
768 case 4: /* Ready */
769 break;
770 case 1: /* Suspended */
771 case 2: /* No resources (RFDs) */
772 case 9: /* Suspended with no more RBDs */
773 case 10: /* No resources due to no RBDs */
774 case 12: /* Ready with no RBDs */
775 DBG ( "ifec_net_poll: RU reprimed.\n" );
777 break;
778 default:
779 /* reserved values */
780 DBG ( "ifec_net_poll: RU state anomaly: %i\n",
781 ( inw ( priv->ioaddr + SCBStatus ) >> 2 ) & 0xf );
782 break;
783 }
784}
785
786#define RFD_STATUS ( RFD_OK | RFDRxCol | RFDRxErr | RFDShort | \
787 RFDDMAOverrun | RFDNoBufs | RFDCRCError )
788/*
789 * Looks for received packets in the rx ring, reports success or error to
790 * the core accordingly. Starts reallocation of rx ring.
791 *
792 * @v netdev Network device
793 */
794static void ifec_rx_process ( struct net_device *netdev )
795{
796 struct ifec_private *priv = netdev->priv;
797 int cur_rx = priv->cur_rx;
798 struct io_buffer *iob = priv->rx_iobs[cur_rx];
799 struct ifec_rfd *rfd = priv->rfds[cur_rx];
800 unsigned int rx_len;
801 s16 status;
802
803 DBGP ( "ifec_rx_process\n" );
804
805 /* Process any received packets */
806 while ( iob && rfd && ( status = rfd->status ) ) {
807 rx_len = rfd->count & RFDMaskCount;
808
809 DBG2 ( "Got a packet: Len = %d, cur_rx = %d.\n", rx_len,
810 cur_rx );
811 DBGIO_HD ( (void*)rfd->packet, 0x30 );
812
813 if ( ( status & ( RFD_STATUS & ~RFDShort ) ) != RFD_OK ) {
814 DBG ( "Corrupted packet received. "
815 "Status = %#08hx\n", status );
816 netdev_rx_err ( netdev, iob, -EINVAL );
817 } else {
818 /* Hand off the packet to the network subsystem */
819 iob_put ( iob, rx_len );
820 DBG2 ( "Received packet: %p, len: %d\n", iob, rx_len );
821 netdev_rx ( netdev, iob );
822 }
823
824 /* make sure we don't reuse this RFD */
825 priv->rx_iobs[cur_rx] = NULL;
826 priv->rfds[cur_rx] = NULL;
827
828 /* Next RFD */
829 priv->cur_rx = ( cur_rx + 1 ) % RFD_COUNT;
830 cur_rx = priv->cur_rx;
831 iob = priv->rx_iobs[cur_rx];
832 rfd = priv->rfds[cur_rx];
833 }
834
836}
837
838/*
839 * Allocates io_buffer, set pointers in ifec_private structure accordingly,
840 * reserves space for RFD header in io_buffer.
841 *
842 * @v netdev Network device
843 * @v cur Descriptor number to work on
844 * @v cmd Value to set cmd field in RFD to
845 * @v link Pointer to ned RFD
846 * @ret rc 0 on success, negative on failure
847 */
848static int ifec_get_rx_desc ( struct net_device *netdev, int cur, int cmd,
849 int link )
850{
851 struct ifec_private *priv = netdev->priv;
852 struct ifec_rfd *rfd = priv->rfds[cur];
853
854 DBGP ( "ifec_get_rx_desc\n" );
855
856 priv->rx_iobs[cur] = alloc_iob ( sizeof ( *rfd ) );
857 if ( ! priv->rx_iobs[cur] ) {
858 DBG ( "alloc_iob failed. desc. nr: %d\n", cur );
859 priv->rfds[cur] = NULL;
860 return -ENOMEM;
861 }
862
863 /* Initialize new tail. */
864 priv->rfds[cur] = priv->rx_iobs[cur]->data;
865 ifec_rfd_init ( priv->rfds[cur], cmd, link );
866 iob_reserve ( priv->rx_iobs[cur], RFD_HEADER_LEN );
867
868 return 0;
869}
870
871/*
872 * Allocate new descriptor entries and initialize them if needed
873 *
874 * @v netdev Network device
875 */
876static void ifec_refill_rx_ring ( struct net_device *netdev )
877{
878 struct ifec_private *priv = netdev->priv;
879 int i, cur_rx;
880 unsigned short intr_status;
881
882 DBGP ( "ifec_refill_rx_ring\n" );
883
884 for ( i = 0; i < RFD_COUNT; i++ ) {
885 cur_rx = ( priv->cur_rx + i ) % RFD_COUNT;
886 /* only refill if empty */
887 if ( priv->rfds[cur_rx] != NULL ||
888 priv->rx_iobs[cur_rx] != NULL )
889 continue;
890
891 DBG2 ( "refilling RFD %d\n", cur_rx );
892
894 CmdSuspend | CmdEndOfList, 0 ) == 0 ) {
895 if ( i > 0 ) {
896 int prev_rx = ( ( ( cur_rx + RFD_COUNT ) - 1 )
897 % RFD_COUNT );
898 struct ifec_rfd *rfd = priv->rfds[prev_rx];
899
900 rfd->command = 0;
901 rfd->link = virt_to_bus ( priv->rfds[cur_rx] );
902 }
903 }
904 }
905
906 intr_status = inw ( priv->ioaddr + SCBStatus );
907 ifec_check_ru_status ( netdev, intr_status );
908}
909
910/*
911 * Initial allocation & initialization of the rx ring.
912 *
913 * @v netdev Device of rx ring.
914 * @ret rc Non-zero if error occurred
915 */
916static int ifec_rx_setup ( struct net_device *netdev )
917{
918 struct ifec_private *priv = netdev->priv;
919 int i;
920
921 DBGP ( "ifec_rx_setup\n" );
922
923 priv->cur_rx = 0;
924
925 /* init values for ifec_refill_rx_ring() */
926 for ( i = 0; i < RFD_COUNT; i++ ) {
927 priv->rfds[i] = NULL;
928 priv->rx_iobs[i] = NULL;
929 }
931
932 return 0;
933}
934
935/*
936 * Initiates a SCB command.
937 *
938 * @v netdev Network device
939 * @v ptr General pointer value for command.
940 * @v cmd Command to issue.
941 * @ret rc Non-zero if command not issued.
942 */
943static int ifec_scb_cmd ( struct net_device *netdev, u32 ptr, u8 cmd )
944{
945 struct ifec_private *priv = netdev->priv;
946 unsigned long ioaddr = priv->ioaddr;
947 int rc;
948
949 DBGP ( "ifec_scb_cmd\n" );
950
951 rc = ifec_scb_cmd_wait ( netdev ); /* Wait until ready */
952 if ( !rc ) {
953 outl ( ptr, ioaddr + SCBPointer );
954 outb ( cmd, ioaddr + SCBCmd ); /* Issue command */
955 }
956 return rc;
957}
958
959/*
960 * Wait for command unit to accept a command.
961 *
962 * @v cmd_ioaddr I/O address of command register.
963 * @ret rc Non-zero if command timed out.
964 */
965static int ifec_scb_cmd_wait ( struct net_device *netdev )
966{
967 struct ifec_private *priv = netdev->priv;
968 unsigned long cmd_ioaddr = priv->ioaddr + SCBCmd;
969 int rc, wait = CU_CMD_TIMEOUT;
970
971 DBGP ( "ifec_scb_cmd_wait\n" );
972
973 for ( ; wait && ( rc = inb ( cmd_ioaddr ) ); wait-- )
974 udelay ( 1 );
975
976 if ( !wait )
977 DBG ( "ifec_scb_cmd_wait timeout!\n" );
978 return rc;
979}
980
981/*
982 * Check status of transmitted packets & perform tx completions.
983 *
984 * @v netdev Network device.
985 */
986static void ifec_tx_process ( struct net_device *netdev )
987{
988 struct ifec_private *priv = netdev->priv;
989 struct ifec_tcb *tcb = priv->tcb_tail;
990 s16 status;
991
992 DBGP ( "ifec_tx_process\n" );
993
994 /* Check status of transmitted packets */
995 while ( ( status = tcb->status ) && tcb->iob ) {
996 if ( status & TCB_U ) {
997 /* report error to iPXE */
998 DBG ( "ifec_tx_process : tx error!\n " );
1000 } else {
1001 /* report successful transmit */
1002 netdev_tx_complete ( netdev, tcb->iob );
1003 }
1004 DBG2 ( "tx completion\n" );
1005
1006 tcb->iob = NULL;
1007 tcb->status = 0;
1008
1009 priv->tcb_tail = tcb->next; /* Next TCB */
1010 tcb = tcb->next;
1011 }
1012}
1013
1014/*
1015 * Allocates & initialize tx resources.
1016 *
1017 * @v netdev Network device.
1018 * @ret rc Non-zero if error occurred.
1019 */
1020static int ifec_tx_setup ( struct net_device *netdev )
1021{
1022 struct ifec_private *priv = netdev->priv;
1023 struct ifec_tcb *tcb;
1024 int i;
1025
1026 DBGP ( "ifec_tx_setup\n" );
1027
1028 /* allocate tx ring */
1030 if ( !priv->tcbs ) {
1031 DBG ( "TX-ring allocation failed\n" );
1032 return -ENOMEM;
1033 }
1034
1035 tcb = priv->tcb_tail = priv->tcbs;
1036 priv->tx_curr = priv->tx_tail = 0;
1037 priv->tx_cnt = 0;
1038
1039 for ( i = 0; i < TCB_COUNT; i++, tcb++ ) {
1040 tcb->status = 0;
1041 tcb->count = 0x01208000;
1042 tcb->iob = NULL;
1043 tcb->tbda_addr = virt_to_bus ( &tcb->tbd_addr0 );
1044 tcb->link = virt_to_bus ( tcb + 1 );
1045 tcb->next = tcb + 1;
1046 }
1047 /* We point tcb_head at the last TCB, so the first ifec_net_transmit()
1048 * will use the first (head->next) TCB to transmit. */
1049 priv->tcb_head = --tcb;
1050 tcb->link = virt_to_bus ( priv->tcbs );
1051 tcb->next = priv->tcbs;
1052
1053 return 0;
1054}
1055
1056/*
1057 * Wake up the Command Unit and issue a Resume/Start.
1058 *
1059 * @v netdev Network device containing Command Unit
1060 *
1061 * The time between clearing the S bit and issuing Resume must be as short as
1062 * possible to prevent a race condition. As noted in linux eepro100.c :
1063 * Note: Watch out for the potential race condition here: imagine
1064 * erasing the previous suspend
1065 * the chip processes the previous command
1066 * the chip processes the final command, and suspends
1067 * doing the CU_RESUME
1068 * the chip processes the next-yet-valid post-final-command.
1069 * So blindly sending a CU_RESUME is only safe if we do it immediately after
1070 * erasing the previous CmdSuspend, without the possibility of an intervening
1071 * delay.
1072 */
1074{
1075 struct ifec_private *priv = netdev->priv;
1076 unsigned long ioaddr = priv->ioaddr;
1077 struct ifec_tcb *tcb = priv->tcb_head->next;
1078
1079 DBGP ( "ifec_tx_wake\n" );
1080
1081 /* For the special case of the first transmit, we issue a START. The
1082 * card won't RESUME after the configure command. */
1083 if ( priv->configured ) {
1084 priv->configured = 0;
1085 ifec_scb_cmd ( netdev, virt_to_bus ( tcb ), CUStart );
1087 return;
1088 }
1089
1090 /* Resume if suspended. */
1091 switch ( ( inw ( ioaddr + SCBStatus ) >> 6 ) & 0x3 ) {
1092 case 0: /* Idle - We should not reach this state. */
1093 DBG2 ( "ifec_tx_wake: tx idle!\n" );
1094 ifec_scb_cmd ( netdev, virt_to_bus ( tcb ), CUStart );
1096 return;
1097 case 1: /* Suspended */
1098 DBG2 ( "s" );
1099 break;
1100 default: /* Active */
1101 DBG2 ( "a" );
1102 }
1104 outl ( 0, ioaddr + SCBPointer );
1105 priv->tcb_head->command &= ~CmdSuspend;
1106 /* Immediately issue Resume command */
1107 outb ( CUResume, ioaddr + SCBCmd );
1109}
1110
1111/*********************************************************************/
1112
1113static struct pci_device_id ifec_nics[] = {
1114PCI_ROM(0x8086, 0x1029, "id1029", "Intel EtherExpressPro100 ID1029", 0),
1115PCI_ROM(0x8086, 0x1030, "id1030", "Intel EtherExpressPro100 ID1030", 0),
1116PCI_ROM(0x8086, 0x1031, "82801cam", "Intel 82801CAM (ICH3) Chipset Ethernet Controller", 0),
1117PCI_ROM(0x8086, 0x1032, "eepro100-1032", "Intel PRO/100 VE Network Connection", 0),
1118PCI_ROM(0x8086, 0x1033, "eepro100-1033", "Intel PRO/100 VM Network Connection", 0),
1119PCI_ROM(0x8086, 0x1034, "eepro100-1034", "Intel PRO/100 VM Network Connection", 0),
1120PCI_ROM(0x8086, 0x1035, "eepro100-1035", "Intel 82801CAM (ICH3) Chipset Ethernet Controller", 0),
1121PCI_ROM(0x8086, 0x1036, "eepro100-1036", "Intel 82801CAM (ICH3) Chipset Ethernet Controller", 0),
1122PCI_ROM(0x8086, 0x1037, "eepro100-1037", "Intel 82801CAM (ICH3) Chipset Ethernet Controller", 0),
1123PCI_ROM(0x8086, 0x1038, "id1038", "Intel PRO/100 VM Network Connection", 0),
1124PCI_ROM(0x8086, 0x1039, "82562et", "Intel PRO100 VE 82562ET", 0),
1125PCI_ROM(0x8086, 0x103a, "id103a", "Intel Corporation 82559 InBusiness 10/100", 0),
1126PCI_ROM(0x8086, 0x103b, "82562etb", "Intel PRO100 VE 82562ETB", 0),
1127PCI_ROM(0x8086, 0x103c, "eepro100-103c", "Intel PRO/100 VM Network Connection", 0),
1128PCI_ROM(0x8086, 0x103d, "eepro100-103d", "Intel PRO/100 VE Network Connection", 0),
1129PCI_ROM(0x8086, 0x103e, "eepro100-103e", "Intel PRO/100 VM Network Connection", 0),
1130PCI_ROM(0x8086, 0x1050, "82562ez", "Intel 82562EZ Network Connection", 0),
1131PCI_ROM(0x8086, 0x1051, "prove", "Intel PRO/100 VE Network Connection", 0),
1132PCI_ROM(0x8086, 0x1059, "82551qm", "Intel PRO/100 M Mobile Connection", 0),
1133PCI_ROM(0x8086, 0x1065, "82562-3", "Intel 82562 based Fast Ethernet Connection", 0),
1134PCI_ROM(0x8086, 0x1092, "82562-3", "Intel Pro/100 VE Network", 0),
1135PCI_ROM(0x8086, 0x10fe, "82552", "Intel 82552 10/100 Network Connection", 0),
1136PCI_ROM(0x8086, 0x1209, "82559er", "Intel EtherExpressPro100 82559ER", 0),
1137PCI_ROM(0x8086, 0x1227, "82865", "Intel 82865 EtherExpress PRO/100A", 0),
1138PCI_ROM(0x8086, 0x1228, "82556", "Intel 82556 EtherExpress PRO/100 Smart", 0),
1139PCI_ROM(0x8086, 0x1229, "eepro100", "Intel EtherExpressPro100", 0),
1140PCI_ROM(0x8086, 0x2449, "82562em", "Intel EtherExpressPro100 82562EM", 0),
1141PCI_ROM(0x8086, 0x2459, "82562-1", "Intel 82562 based Fast Ethernet Connection", 0),
1142PCI_ROM(0x8086, 0x245d, "82562-2", "Intel 82562 based Fast Ethernet Connection", 0),
1143PCI_ROM(0x8086, 0x27dc, "eepro100-27dc", "Intel 82801G (ICH7) Chipset Ethernet Controller", 0),
1144PCI_ROM(0x8086, 0x5200, "eepro100-5200", "Intel EtherExpress PRO/100 Intelligent Server", 0),
1145PCI_ROM(0x8086, 0x5201, "eepro100-5201", "Intel EtherExpress PRO/100 Intelligent Server", 0),
1146};
1147
1148/* Cards with device ids 0x1030 to 0x103F, 0x2449, 0x2459 or 0x245D might need
1149 * a workaround for hardware bug on 10 mbit half duplex (see linux driver eepro100.c)
1150 * 2003/03/17 gbaum */
1151
1152struct pci_driver ifec_driver __pci_driver = {
1153 .ids = ifec_nics,
1154 .id_count = ( sizeof (ifec_nics) / sizeof (ifec_nics[0]) ),
1157};
1158
1159/*
1160 * Local variables:
1161 * c-basic-offset: 8
1162 * c-indent-level: 8
1163 * tab-width: 8
1164 * End:
1165 */
static int options
Definition 3c515.c:286
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
struct golan_eqe_cmd cmd
Definition CIB_PRM.h:1
u32 link
Link to next descriptor.
Definition ar9003_mac.h:1
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
pseudo_bit_t value[0x00020]
Definition arbel.h:2
struct arbelprm_completion_with_error error
Definition arbel.h:1
unsigned short uint16_t
Definition stdint.h:11
static unsigned long ioaddr
Definition davicom.c:129
#define EE_DATA_READ
Definition davicom.c:80
#define EE_DATA_WRITE
Definition davicom.c:77
#define EE_SHIFT_CLK
Definition davicom.c:75
#define EE_ENB
Definition davicom.c:81
#define RFD_STATUS
Definition eepro100.c:786
static int ifec_net_open(struct net_device *netdev)
Definition eepro100.c:310
static void ifec_reset(struct net_device *netdev)
Definition eepro100.c:666
static void ifec_free(struct net_device *netdev)
Definition eepro100.c:692
static struct pci_device_id ifec_nics[]
Definition eepro100.c:1113
static void ifec_reprime_ru(struct net_device *netdev)
Definition eepro100.c:736
static struct bit_basher_operations ifec_basher_ops
Definition eepro100.c:531
static void ifec_mdio_setup(struct net_device *netdev, int options)
Definition eepro100.c:604
static void ifec_spi_write_bit(struct bit_basher *basher, unsigned int bit_id, unsigned long data)
Definition eepro100.c:511
static int ifec_scb_cmd_wait(struct net_device *netdev)
Definition eepro100.c:965
static void ifec_net_close(struct net_device *netdev)
Definition eepro100.c:258
static void ifec_rx_process(struct net_device *netdev)
Definition eepro100.c:794
static void ifec_rfd_init(struct ifec_rfd *rfd, s16 command, u32 link)
Definition eepro100.c:719
static int ifec_net_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Definition eepro100.c:437
void ifec_tx_wake(struct net_device *netdev)
Definition eepro100.c:1073
static void ifec_init_eeprom(struct net_device *netdev)
Definition eepro100.c:541
static struct net_device_operations ifec_operations
Definition eepro100.c:152
static void ifec_refill_rx_ring(struct net_device *netdev)
Definition eepro100.c:876
static int ifec_pci_probe(struct pci_device *pci)
Definition eepro100.c:172
static int ifec_spi_read_bit(struct bit_basher *basher, unsigned int bit_id)
Definition eepro100.c:486
static int ifec_scb_cmd(struct net_device *netdev, u32 ptr, u8 cmd)
Definition eepro100.c:943
static void ifec_net_irq(struct net_device *netdev, int enable)
Definition eepro100.c:291
static int ifec_rx_setup(struct net_device *netdev)
Definition eepro100.c:916
static void ifec_tx_process(struct net_device *netdev)
Definition eepro100.c:986
static const uint16_t ifec_ee_bits[]
Definition eepro100.c:472
static int ifec_get_rx_desc(struct net_device *netdev, int cur, int cmd, int link)
Definition eepro100.c:848
static int ifec_tx_setup(struct net_device *netdev)
Definition eepro100.c:1020
static int ifec_mdio_write(struct net_device *netdev, int phy_id, int location, int value)
Definition eepro100.c:636
static void ifec_pci_remove(struct pci_device *pci)
Definition eepro100.c:237
static void ifec_check_ru_status(struct net_device *netdev, unsigned short intr_status)
Definition eepro100.c:755
static void ifec_net_poll(struct net_device *netdev)
Definition eepro100.c:401
static int ifec_mdio_read(struct net_device *netdev, int phy_id, int location)
Definition eepro100.c:572
#define INTERRUPT_MASK
Definition eepro100.c:281
#define RX_FIFO
Definition eepro100.h:9
@ CUResume
Definition eepro100.h:43
@ CUCmdBase
Definition eepro100.h:44
@ CUStatsAddr
Definition eepro100.h:43
@ RUAddrLoad
Definition eepro100.h:46
@ RUStart
Definition eepro100.h:45
@ SCBMaskAll
Definition eepro100.h:41
@ CUStart
Definition eepro100.h:43
#define CB_ALIGN
Definition eepro100.h:18
#define TX_RING_BYTES
Definition eepro100.h:23
#define CONGENB
Definition eepro100.h:7
@ TCB_U
Definition eepro100.h:64
@ RFDShort
Definition eepro100.h:71
@ RFD_OK
Definition eepro100.h:73
@ RFDMaskCount
Definition eepro100.h:77
@ CmdIASetup
Definition eepro100.h:55
@ CmdTxFlex
Definition eepro100.h:60
@ CmdTx
Definition eepro100.h:56
@ CmdConfigure
Definition eepro100.h:55
@ CmdSuspend
Definition eepro100.h:60
@ CmdEndOfList
Definition eepro100.h:59
@ DP83840
Definition eepro100.h:82
@ DP83840A
Definition eepro100.h:83
#define TCB_COUNT
Definition eepro100.h:21
#define RFD_COUNT
Definition eepro100.h:20
#define RX_DMA_COUNT
Definition eepro100.h:11
#define TX_FIFO
Definition eepro100.h:8
#define EEPROM_ADDR_MDIO_REGISTER
Definition eepro100.h:27
#define CU_CMD_TIMEOUT
Definition eepro100.h:12
#define TX_DMA_COUNT
Definition eepro100.h:10
#define RFD_PACKET_LEN
Definition eepro100.h:15
#define EEPROM_ADDR_MAC_0
Definition eepro100.h:26
#define RFD_HEADER_LEN
Definition eepro100.h:17
@ PortReset
Definition eepro100.h:50
@ PortPartialReset
Definition eepro100.h:50
@ CSRPort
Definition eepro100.h:32
@ CSREeprom
Definition eepro100.h:32
@ SCBStatus
Definition eepro100.h:31
@ SCBCmd
Definition eepro100.h:31
@ SCBPointer
Definition eepro100.h:31
@ CSRCtrlMDI
Definition eepro100.h:33
uint8_t data[48]
Additional event data.
Definition ena.h:11
uint8_t status
Status.
Definition ena.h:5
static unsigned int cur_rx
Definition epic100.c:84
Error codes.
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition ethernet.c:265
Ethernet protocol.
static struct net_device * netdev
Definition gdbudp.c:53
#define DBGP(...)
Definition compiler.h:532
#define DBG2(...)
Definition compiler.h:515
#define DBGIO_HD(...)
Definition compiler.h:551
#define DBG(...)
Print a debugging message.
Definition compiler.h:498
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define EINVAL
Invalid argument.
Definition errno.h:429
#define ENOMEM
Not enough space.
Definition errno.h:535
#define ENOBUFS
No buffer space available.
Definition errno.h:499
#define ETH_ALEN
Definition if_ether.h:9
#define u8
Definition igbvf_osdep.h:40
#define inw(io_addr)
Definition io.h:292
#define outb(data, io_addr)
Definition io.h:310
#define outw(data, io_addr)
Definition io.h:320
#define inl(io_addr)
Definition io.h:301
#define outl(data, io_addr)
Definition io.h:330
#define inb(io_addr)
Definition io.h:283
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition io.h:184
iPXE timers
void __asmcall int val
Definition setjmp.h:12
int16_t s16
Definition stdint.h:21
String functions.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void * memset(void *dest, int character, size_t len) __nonnull
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition iobuf.c:153
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition iobuf.c:131
I/O buffers.
#define iob_put(iobuf, len)
Definition iobuf.h:125
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition iobuf.h:160
#define iob_reserve(iobuf, len)
Definition iobuf.h:72
void * malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
Definition malloc.c:707
void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition malloc.c:723
Dynamic memory allocation.
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition netdevice.c:549
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition netdevice.c:942
void netdev_tx_complete_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Complete network transmission.
Definition netdevice.c:471
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition netdevice.c:587
int register_netdev(struct net_device *netdev)
Register network device.
Definition netdevice.c:760
Network device management.
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition netdevice.h:789
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition netdevice.h:519
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition netdevice.h:532
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition netdevice.h:576
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
Definition netdevice.h:767
int nvs_read(struct nvs_device *nvs, unsigned int address, void *data, size_t len)
Read from non-volatile storage device.
Definition nvs.c:76
Non-volatile storage.
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition pci.c:241
PCI bus.
#define __pci_driver
Declare a PCI driver.
Definition pci.h:278
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Definition pci.h:366
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition pci.h:308
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition pci.h:376
@ cfg
Definition sis900.h:23
#define SPI_MODE_THREEWIRE
Threewire-compatible mode.
Definition spi.h:200
void init_spi_bit_basher(struct spi_bit_basher *spibit)
Initialise SPI bit-bashing interface.
Definition spi_bit.c:236
SPI bit-bashing interface.
@ SPI_BIT_MOSI
Master Out Slave In.
Definition spi_bit.h:38
@ SPI_BIT_MISO
Master In Slave Out.
Definition spi_bit.h:40
@ SPI_BIT_SCLK
Serial clock.
Definition spi_bit.h:36
#define SPI_BIT_SS(slave)
Determine bit index for a particular slave.
Definition spi_bit.h:51
#define container_of(ptr, type, field)
Get containing structure.
Definition stddef.h:36
Bit-bashing operations.
Definition bitbash.h:16
A bit-bashing interface.
Definition bitbash.h:56
A command-line command.
Definition command.h:10
u8 ia[6]
Definition eepro100.h:135
u16 command
Definition eepro100.h:133
volatile s16 status
Definition eepro100.h:132
u32 link
Definition eepro100.h:134
unsigned short mdio_register
Definition eepro100.h:148
struct spi_bit_basher spi
Definition eepro100.h:166
char packet[RFD_PACKET_LEN]
Definition eepro100.h:128
u32 rx_buf_addr
Definition eepro100.h:125
s16 command
Definition eepro100.h:123
u32 link
Definition eepro100.h:124
volatile s16 status
Definition eepro100.h:122
u16 count
Definition eepro100.h:126
u16 size
Definition eepro100.h:127
u32 tbda_addr
Definition eepro100.h:110
struct ifec_tcb * next
Definition eepro100.h:118
volatile s16 status
Definition eepro100.h:107
u32 link
Definition eepro100.h:109
struct io_buffer * iob
Definition eepro100.h:117
s32 count
Definition eepro100.h:111
s32 tbd_size0
Definition eepro100.h:115
u16 command
Definition eepro100.h:108
u32 tbd_addr0
Definition eepro100.h:114
A persistent I/O buffer.
Definition iobuf.h:38
void * data
Start of data.
Definition iobuf.h:53
Network device operations.
Definition netdevice.h:214
A network device.
Definition netdevice.h:353
A PCI device ID list entry.
Definition pci.h:175
A PCI device.
Definition pci.h:211
unsigned long ioaddr
I/O address.
Definition pci.h:226
struct device dev
Generic device.
Definition pci.h:213
A PCI driver.
Definition pci.h:252
int(* probe)(struct pci_device *pci)
Probe device.
Definition pci.h:265
struct bit_basher basher
Bit-bashing interface.
Definition spi_bit.h:21
int threewire_detect_address_len(struct spi_device *device)
Autodetect device address length.
Definition threewire.c:120
Three-wire serial interface.
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition timer.c:79
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition timer.c:61
static struct tlan_private * priv
Definition tlan.c:225
#define u32
Definition vga.h:21
static struct xen_remove_from_physmap * remove
Definition xenmem.h:40