iPXE
intel.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301, USA.
18  *
19  * You can also choose to distribute this program under the terms of
20  * the Unmodified Binary Distribution Licence (as given in the file
21  * COPYING.UBDL), provided that you have satisfied its requirements.
22  */
23 
24 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25 FILE_SECBOOT ( PERMITTED );
26 
27 #include <stdint.h>
28 #include <string.h>
29 #include <unistd.h>
30 #include <errno.h>
31 #include <byteswap.h>
32 #include <ipxe/netdevice.h>
33 #include <ipxe/ethernet.h>
34 #include <ipxe/if_ether.h>
35 #include <ipxe/iobuf.h>
36 #include <ipxe/dma.h>
37 #include <ipxe/pci.h>
38 #include <ipxe/profile.h>
39 #include "intel.h"
40 
41 /** @file
42  *
43  * Intel 10/100/1000 network card driver
44  *
45  */
46 
47 /** VM transmit profiler */
48 static struct profiler intel_vm_tx_profiler __profiler =
49  { .name = "intel.vm_tx" };
50 
51 /** VM receive refill profiler */
52 static struct profiler intel_vm_refill_profiler __profiler =
53  { .name = "intel.vm_refill" };
54 
55 /** VM poll profiler */
56 static struct profiler intel_vm_poll_profiler __profiler =
57  { .name = "intel.vm_poll" };
58 
59 /******************************************************************************
60  *
61  * EEPROM interface
62  *
63  ******************************************************************************
64  */
65 
66 /**
67  * Read data from EEPROM
68  *
69  * @v nvs NVS device
70  * @v address Address from which to read
71  * @v data Data buffer
72  * @v len Length of data buffer
73  * @ret rc Return status code
74  */
75 static int intel_read_eeprom ( struct nvs_device *nvs, unsigned int address,
76  void *data, size_t len ) {
77  struct intel_nic *intel =
78  container_of ( nvs, struct intel_nic, eeprom );
79  unsigned int i;
81  uint16_t *data_word = data;
82 
83  /* Sanity check. We advertise a blocksize of one word, so
84  * should only ever receive single-word requests.
85  */
86  assert ( len == sizeof ( *data_word ) );
87 
88  /* Initiate read */
89  writel ( ( INTEL_EERD_START | ( address << intel->eerd_addr_shift ) ),
90  intel->regs + INTEL_EERD );
91 
92  /* Wait for read to complete */
93  for ( i = 0 ; i < INTEL_EEPROM_MAX_WAIT_MS ; i++ ) {
94 
95  /* If read is not complete, delay 1ms and retry */
96  value = readl ( intel->regs + INTEL_EERD );
97  if ( ! ( value & intel->eerd_done ) ) {
98  mdelay ( 1 );
99  continue;
100  }
101 
102  /* Extract data */
103  *data_word = cpu_to_le16 ( INTEL_EERD_DATA ( value ) );
104  return 0;
105  }
106 
107  DBGC ( intel, "INTEL %p timed out waiting for EEPROM read\n", intel );
108  return -ETIMEDOUT;
109 }
110 
111 /**
112  * Write data to EEPROM
113  *
114  * @v nvs NVS device
115  * @v address Address to which to write
116  * @v data Data buffer
117  * @v len Length of data buffer
118  * @ret rc Return status code
119  */
120 static int intel_write_eeprom ( struct nvs_device *nvs,
121  unsigned int address __unused,
122  const void *data __unused,
123  size_t len __unused ) {
124  struct intel_nic *intel =
125  container_of ( nvs, struct intel_nic, eeprom );
126 
127  DBGC ( intel, "INTEL %p EEPROM write not supported\n", intel );
128  return -ENOTSUP;
129 }
130 
131 /**
132  * Initialise EEPROM
133  *
134  * @v intel Intel device
135  * @ret rc Return status code
136  */
137 static int intel_init_eeprom ( struct intel_nic *intel ) {
138  unsigned int i;
139  uint32_t value;
140 
141  /* The NIC automatically detects the type of attached EEPROM.
142  * The EERD register provides access to only a single word at
143  * a time, so we pretend to have a single-word block size.
144  *
145  * The EEPROM size may be larger than the minimum size, but
146  * this doesn't matter to us since we access only the first
147  * few words.
148  */
151  intel->eeprom.block_size = 1;
152  intel->eeprom.read = intel_read_eeprom;
154 
155  /* The layout of the EERD register was changed at some point
156  * to accommodate larger EEPROMs. Read from address zero (for
157  * which the request layouts are compatible) to determine
158  * which type of register we have.
159  */
160  writel ( INTEL_EERD_START, intel->regs + INTEL_EERD );
161  for ( i = 0 ; i < INTEL_EEPROM_MAX_WAIT_MS ; i++ ) {
162  value = readl ( intel->regs + INTEL_EERD );
163  if ( value & INTEL_EERD_DONE_LARGE ) {
164  DBGC ( intel, "INTEL %p has large-format EERD\n",
165  intel );
168  return 0;
169  }
170  if ( value & INTEL_EERD_DONE_SMALL ) {
171  DBGC ( intel, "INTEL %p has small-format EERD\n",
172  intel );
175  return 0;
176  }
177  mdelay ( 1 );
178  }
179 
180  DBGC ( intel, "INTEL %p timed out waiting for initial EEPROM read "
181  "(value %08x)\n", intel, value );
182  return -ETIMEDOUT;
183 }
184 
185 /******************************************************************************
186  *
187  * MAC address
188  *
189  ******************************************************************************
190  */
191 
192 /**
193  * Fetch initial MAC address from EEPROM
194  *
195  * @v intel Intel device
196  * @v hw_addr Hardware address to fill in
197  * @ret rc Return status code
198  */
199 static int intel_fetch_mac_eeprom ( struct intel_nic *intel,
200  uint8_t *hw_addr ) {
201  int rc;
202 
203  /* Initialise EEPROM */
204  if ( ( rc = intel_init_eeprom ( intel ) ) != 0 )
205  return rc;
206 
207  /* Read base MAC address from EEPROM */
208  if ( ( rc = nvs_read ( &intel->eeprom, INTEL_EEPROM_MAC,
209  hw_addr, ETH_ALEN ) ) != 0 ) {
210  DBGC ( intel, "INTEL %p could not read EEPROM base MAC "
211  "address: %s\n", intel, strerror ( rc ) );
212  return rc;
213  }
214 
215  /* Adjust MAC address for multi-port devices */
216  hw_addr[ETH_ALEN-1] ^= intel->port;
217 
218  DBGC ( intel, "INTEL %p has EEPROM MAC address %s (port %d)\n",
219  intel, eth_ntoa ( hw_addr ), intel->port );
220  return 0;
221 }
222 
223 /**
224  * Fetch initial MAC address
225  *
226  * @v intel Intel device
227  * @v hw_addr Hardware address to fill in
228  * @ret rc Return status code
229  */
230 static int intel_fetch_mac ( struct intel_nic *intel, uint8_t *hw_addr ) {
232  int rc;
233 
234  /* Read current address from RAL0/RAH0 */
235  mac.reg.low = cpu_to_le32 ( readl ( intel->regs + INTEL_RAL0 ) );
236  mac.reg.high = cpu_to_le32 ( readl ( intel->regs + INTEL_RAH0 ) );
237  DBGC ( intel, "INTEL %p has autoloaded MAC address %s\n",
238  intel, eth_ntoa ( mac.raw ) );
239 
240  /* Use current address if valid */
241  if ( is_valid_ether_addr ( mac.raw ) ) {
242  memcpy ( hw_addr, mac.raw, ETH_ALEN );
243  return 0;
244  }
245 
246  /* Otherwise, try to read address from EEPROM */
247  if ( ( rc = intel_fetch_mac_eeprom ( intel, hw_addr ) ) == 0 )
248  return 0;
249 
250  DBGC ( intel, "INTEL %p has no MAC address to use\n", intel );
251  return -ENOENT;
252 }
253 
254 /******************************************************************************
255  *
256  * Device reset
257  *
258  ******************************************************************************
259  */
260 
261 /**
262  * Reset hardware
263  *
264  * @v intel Intel device
265  * @ret rc Return status code
266  */
267 static int intel_reset ( struct intel_nic *intel ) {
268  uint32_t pbs;
269  uint32_t pba;
270  uint32_t ctrl;
272  uint32_t orig_ctrl;
273  uint32_t orig_status;
274 
275  /* Record initial control and status register values */
276  orig_ctrl = ctrl = readl ( intel->regs + INTEL_CTRL );
277  orig_status = readl ( intel->regs + INTEL_STATUS );
278 
279  /* Force RX and TX packet buffer allocation, to work around an
280  * errata in ICH devices.
281  */
282  if ( intel->flags & INTEL_PBS_ERRATA ) {
283  DBGC ( intel, "INTEL %p WARNING: applying ICH PBS/PBA errata\n",
284  intel );
285  pbs = readl ( intel->regs + INTEL_PBS );
286  pba = readl ( intel->regs + INTEL_PBA );
287  writel ( 0x08, intel->regs + INTEL_PBA );
288  writel ( 0x10, intel->regs + INTEL_PBS );
289  DBGC ( intel, "INTEL %p PBS %#08x->%#08x PBA %#08x->%#08x\n",
290  intel, pbs, readl ( intel->regs + INTEL_PBS ),
291  pba, readl ( intel->regs + INTEL_PBA ) );
292  }
293 
294  /* The Intel I210's packet buffer size registers reset only on
295  * power up. If an operating system changes these but then
296  * the computer recieves a reset signal without losing power,
297  * the registers will stay the same (but be incompatible with
298  * other register defaults), thus making the device unable to
299  * pass traffic.
300  */
301  if ( intel->flags & INTEL_PBSIZE_RST ) {
302  writel ( INTEL_RXPBS_I210, intel->regs + INTEL_RXPBS );
303  writel ( INTEL_TXPBS_I210, intel->regs + INTEL_TXPBS );
304  }
305 
306  /* Always reset MAC. Required to reset the TX and RX rings. */
307  writel ( ( ctrl | INTEL_CTRL_RST ), intel->regs + INTEL_CTRL );
309 
310  /* Set a sensible default configuration */
311  if ( ! ( intel->flags & INTEL_NO_ASDE ) )
313  ctrl |= INTEL_CTRL_SLU;
315  writel ( ctrl, intel->regs + INTEL_CTRL );
317 
318  /* On some models (notably ICH), the PHY reset mechanism
319  * appears to be broken. In particular, the PHY_CTRL register
320  * will be correctly loaded from NVM but the values will not
321  * be propagated to the "OEM bits" PHY register. This
322  * typically has the effect of dropping the link speed to
323  * 10Mbps.
324  *
325  * Work around this problem by skipping the PHY reset if
326  * either (a) the link is already up, or (b) this particular
327  * NIC is known to be broken.
328  */
329  status = readl ( intel->regs + INTEL_STATUS );
330  if ( ( intel->flags & INTEL_NO_PHY_RST ) ||
331  ( status & INTEL_STATUS_LU ) ) {
332  DBGC ( intel, "INTEL %p %sMAC reset (%08x/%08x was "
333  "%08x/%08x)\n", intel,
334  ( ( intel->flags & INTEL_NO_PHY_RST ) ? "forced " : "" ),
335  ctrl, status, orig_ctrl, orig_status );
336  return 0;
337  }
338 
339  /* Reset PHY and MAC simultaneously */
341  intel->regs + INTEL_CTRL );
343 
344  /* PHY reset is not self-clearing on all models */
345  writel ( ctrl, intel->regs + INTEL_CTRL );
347  status = readl ( intel->regs + INTEL_STATUS );
348 
349  DBGC ( intel, "INTEL %p MAC+PHY reset (%08x/%08x was %08x/%08x)\n",
350  intel, ctrl, status, orig_ctrl, orig_status );
351  return 0;
352 }
353 
354 /******************************************************************************
355  *
356  * Link state
357  *
358  ******************************************************************************
359  */
360 
361 /**
362  * Check link state
363  *
364  * @v netdev Network device
365  */
366 static void intel_check_link ( struct net_device *netdev ) {
367  struct intel_nic *intel = netdev->priv;
369 
370  /* Read link status */
371  status = readl ( intel->regs + INTEL_STATUS );
372  DBGC ( intel, "INTEL %p link status is %08x\n", intel, status );
373 
374  /* Update network device */
375  if ( status & INTEL_STATUS_LU ) {
377  } else {
379  }
380 }
381 
382 /******************************************************************************
383  *
384  * Descriptors
385  *
386  ******************************************************************************
387  */
388 
389 /**
390  * Populate transmit descriptor
391  *
392  * @v tx Transmit descriptor
393  * @v addr Data buffer address
394  * @v len Length of data
395  */
397  size_t len ) {
398 
399  /* Populate transmit descriptor */
400  tx->address = cpu_to_le64 ( addr );
401  tx->length = cpu_to_le16 ( len );
402  tx->flags = 0;
403  tx->command = ( INTEL_DESC_CMD_RS | INTEL_DESC_CMD_IFCS |
405  tx->status = 0;
406 }
407 
408 /**
409  * Populate advanced transmit descriptor
410  *
411  * @v tx Transmit descriptor
412  * @v addr Data buffer address
413  * @v len Length of data
414  */
416  size_t len ) {
417 
418  /* Populate advanced transmit descriptor */
419  tx->address = cpu_to_le64 ( addr );
420  tx->length = cpu_to_le16 ( len );
421  tx->flags = INTEL_DESC_FL_DTYP_DATA;
422  tx->command = ( INTEL_DESC_CMD_DEXT | INTEL_DESC_CMD_RS |
424  tx->status = cpu_to_le32 ( INTEL_DESC_STATUS_PAYLEN ( len ) );
425 }
426 
427 /**
428  * Populate receive descriptor
429  *
430  * @v rx Receive descriptor
431  * @v addr Data buffer address
432  * @v len Length of data
433  */
435  size_t len __unused ) {
436 
437  /* Populate transmit descriptor */
438  rx->address = cpu_to_le64 ( addr );
439  rx->length = 0;
440  rx->status = 0;
441 }
442 
443 /******************************************************************************
444  *
445  * Network device interface
446  *
447  ******************************************************************************
448  */
449 
450 /**
451  * Disable descriptor ring
452  *
453  * @v intel Intel device
454  * @v reg Register block
455  * @ret rc Return status code
456  */
457 static int intel_disable_ring ( struct intel_nic *intel, unsigned int reg ) {
458  uint32_t dctl;
459  unsigned int i;
460 
461  /* Disable ring */
462  writel ( 0, ( intel->regs + reg + INTEL_xDCTL ) );
463 
464  /* Wait for disable to complete */
465  for ( i = 0 ; i < INTEL_DISABLE_MAX_WAIT_MS ; i++ ) {
466 
467  /* Check if ring is disabled */
468  dctl = readl ( intel->regs + reg + INTEL_xDCTL );
469  if ( ! ( dctl & INTEL_xDCTL_ENABLE ) )
470  return 0;
471 
472  /* Delay */
473  mdelay ( 1 );
474  }
475 
476  DBGC ( intel, "INTEL %p ring %05x timed out waiting for disable "
477  "(dctl %08x)\n", intel, reg, dctl );
478  return -ETIMEDOUT;
479 }
480 
481 /**
482  * Reset descriptor ring
483  *
484  * @v intel Intel device
485  * @v reg Register block
486  * @ret rc Return status code
487  */
488 void intel_reset_ring ( struct intel_nic *intel, unsigned int reg ) {
489 
490  /* Disable ring. Ignore errors and continue to reset the ring anyway */
491  intel_disable_ring ( intel, reg );
492 
493  /* Clear ring length */
494  writel ( 0, ( intel->regs + reg + INTEL_xDLEN ) );
495 
496  /* Clear ring address */
497  writel ( 0, ( intel->regs + reg + INTEL_xDBAH ) );
498  writel ( 0, ( intel->regs + reg + INTEL_xDBAL ) );
499 
500  /* Reset head and tail pointers */
501  writel ( 0, ( intel->regs + reg + INTEL_xDH ) );
502  writel ( 0, ( intel->regs + reg + INTEL_xDT ) );
503 }
504 
505 /**
506  * Create descriptor ring
507  *
508  * @v intel Intel device
509  * @v ring Descriptor ring
510  * @ret rc Return status code
511  */
512 int intel_create_ring ( struct intel_nic *intel, struct intel_ring *ring ) {
514  uint32_t dctl;
515 
516  /* Allocate descriptor ring. Align ring on its own size to
517  * prevent any possible page-crossing errors due to hardware
518  * errata.
519  */
520  ring->desc = dma_alloc ( intel->dma, &ring->map, ring->len,
521  ring->len );
522  if ( ! ring->desc )
523  return -ENOMEM;
524 
525  /* Initialise descriptor ring */
526  memset ( ring->desc, 0, ring->len );
527 
528  /* Program ring address */
529  address = dma ( &ring->map, ring->desc );
530  writel ( ( address & 0xffffffffUL ),
531  ( intel->regs + ring->reg + INTEL_xDBAL ) );
532  if ( sizeof ( physaddr_t ) > sizeof ( uint32_t ) ) {
533  writel ( ( ( ( uint64_t ) address ) >> 32 ),
534  ( intel->regs + ring->reg + INTEL_xDBAH ) );
535  } else {
536  writel ( 0, intel->regs + ring->reg + INTEL_xDBAH );
537  }
538 
539  /* Program ring length */
540  writel ( ring->len, ( intel->regs + ring->reg + INTEL_xDLEN ) );
541 
542  /* Reset head and tail pointers */
543  writel ( 0, ( intel->regs + ring->reg + INTEL_xDH ) );
544  writel ( 0, ( intel->regs + ring->reg + INTEL_xDT ) );
545 
546  /* Enable ring */
547  dctl = readl ( intel->regs + ring->reg + INTEL_xDCTL );
548  dctl |= INTEL_xDCTL_ENABLE;
549  writel ( dctl, intel->regs + ring->reg + INTEL_xDCTL );
550 
551  DBGC ( intel, "INTEL %p ring %05x is at [%08lx,%08lx)\n",
552  intel, ring->reg, virt_to_phys ( ring->desc ),
553  ( virt_to_phys ( ring->desc ) + ring->len ) );
554 
555  return 0;
556 }
557 
558 /**
559  * Destroy descriptor ring
560  *
561  * @v intel Intel device
562  * @v ring Descriptor ring
563  */
564 void intel_destroy_ring ( struct intel_nic *intel, struct intel_ring *ring ) {
565 
566  /* Reset ring */
567  intel_reset_ring ( intel, ring->reg );
568 
569  /* Free descriptor ring */
570  dma_free ( &ring->map, ring->desc, ring->len );
571  ring->desc = NULL;
572  ring->prod = 0;
573  ring->cons = 0;
574 }
575 
576 /**
577  * Refill receive descriptor ring
578  *
579  * @v intel Intel device
580  */
581 void intel_refill_rx ( struct intel_nic *intel ) {
582  struct intel_descriptor *rx;
583  struct io_buffer *iobuf;
584  unsigned int rx_idx;
585  unsigned int rx_tail;
586  unsigned int refilled = 0;
587 
588  /* Refill ring */
589  while ( ( intel->rx.prod - intel->rx.cons ) < INTEL_RX_FILL ) {
590 
591  /* Allocate I/O buffer */
592  iobuf = alloc_rx_iob ( INTEL_RX_MAX_LEN, intel->dma );
593  if ( ! iobuf ) {
594  /* Wait for next refill */
595  break;
596  }
597 
598  /* Get next receive descriptor */
599  rx_idx = ( intel->rx.prod++ % INTEL_NUM_RX_DESC );
600  rx = &intel->rx.desc[rx_idx];
601 
602  /* Populate receive descriptor */
603  intel->rx.describe ( rx, iob_dma ( iobuf ), 0 );
604 
605  /* Record I/O buffer */
606  assert ( intel->rx_iobuf[rx_idx] == NULL );
607  intel->rx_iobuf[rx_idx] = iobuf;
608 
609  DBGC2 ( intel, "INTEL %p RX %d is [%lx,%lx)\n",
610  intel, rx_idx, virt_to_phys ( iobuf->data ),
611  ( virt_to_phys ( iobuf->data ) + INTEL_RX_MAX_LEN ) );
612  refilled++;
613  }
614 
615  /* Push descriptors to card, if applicable */
616  if ( refilled ) {
617  wmb();
618  rx_tail = ( intel->rx.prod % INTEL_NUM_RX_DESC );
619  profile_start ( &intel_vm_refill_profiler );
620  writel ( rx_tail, intel->regs + intel->rx.reg + INTEL_xDT );
621  profile_stop ( &intel_vm_refill_profiler );
622  profile_exclude ( &intel_vm_refill_profiler );
623  }
624 }
625 
626 /**
627  * Discard unused receive I/O buffers
628  *
629  * @v intel Intel device
630  */
631 void intel_empty_rx ( struct intel_nic *intel ) {
632  unsigned int i;
633 
634  /* Discard unused receive buffers */
635  for ( i = 0 ; i < INTEL_NUM_RX_DESC ; i++ ) {
636  if ( intel->rx_iobuf[i] )
637  free_rx_iob ( intel->rx_iobuf[i] );
638  intel->rx_iobuf[i] = NULL;
639  }
640 }
641 
642 /**
643  * Open network device
644  *
645  * @v netdev Network device
646  * @ret rc Return status code
647  */
648 static int intel_open ( struct net_device *netdev ) {
649  struct intel_nic *intel = netdev->priv;
651  uint32_t fextnvm11;
652  uint32_t tctl;
653  uint32_t rctl;
654  int rc;
655 
656  /* Set undocumented bit in FEXTNVM11 to work around an errata
657  * in i219 devices that will otherwise cause a complete
658  * datapath hang at the next device reset.
659  */
660  if ( intel->flags & INTEL_RST_HANG ) {
661  DBGC ( intel, "INTEL %p WARNING: applying reset hang "
662  "workaround\n", intel );
663  fextnvm11 = readl ( intel->regs + INTEL_FEXTNVM11 );
664  fextnvm11 |= INTEL_FEXTNVM11_WTF;
665  writel ( fextnvm11, intel->regs + INTEL_FEXTNVM11 );
666  }
667 
668  /* Create transmit descriptor ring */
669  if ( ( rc = intel_create_ring ( intel, &intel->tx ) ) != 0 )
670  goto err_create_tx;
671 
672  /* Create receive descriptor ring */
673  if ( ( rc = intel_create_ring ( intel, &intel->rx ) ) != 0 )
674  goto err_create_rx;
675 
676  /* Program MAC address */
677  memset ( &mac, 0, sizeof ( mac ) );
678  memcpy ( mac.raw, netdev->ll_addr, sizeof ( mac.raw ) );
679  writel ( le32_to_cpu ( mac.reg.low ), intel->regs + INTEL_RAL0 );
680  writel ( ( le32_to_cpu ( mac.reg.high ) | INTEL_RAH0_AV ),
681  intel->regs + INTEL_RAH0 );
682 
683  /* Enable transmitter */
684  tctl = readl ( intel->regs + INTEL_TCTL );
688  writel ( tctl, intel->regs + INTEL_TCTL );
689 
690  /* Enable receiver */
691  rctl = readl ( intel->regs + INTEL_RCTL );
692  rctl &= ~( INTEL_RCTL_BSIZE_BSEX_MASK );
695  writel ( rctl, intel->regs + INTEL_RCTL );
696 
697  /* Fill receive ring */
698  intel_refill_rx ( intel );
699 
700  /* Update link state */
702 
703  /* Apply required errata */
704  if ( intel->flags & INTEL_VMWARE ) {
705  DBGC ( intel, "INTEL %p applying VMware errata workaround\n",
706  intel );
707  intel->force_icr = INTEL_IRQ_RXT0;
708  }
709 
710  return 0;
711 
712  intel_destroy_ring ( intel, &intel->rx );
713  err_create_rx:
714  intel_destroy_ring ( intel, &intel->tx );
715  err_create_tx:
716  return rc;
717 }
718 
719 /**
720  * Close network device
721  *
722  * @v netdev Network device
723  */
724 static void intel_close ( struct net_device *netdev ) {
725  struct intel_nic *intel = netdev->priv;
726 
727  /* Disable receiver */
728  writel ( 0, intel->regs + INTEL_RCTL );
729 
730  /* Disable transmitter */
731  writel ( 0, intel->regs + INTEL_TCTL );
732 
733  /* Destroy receive descriptor ring */
734  intel_destroy_ring ( intel, &intel->rx );
735 
736  /* Discard any unused receive buffers */
737  intel_empty_rx ( intel );
738 
739  /* Destroy transmit descriptor ring */
740  intel_destroy_ring ( intel, &intel->tx );
741 
742  /* Reset the NIC, to flush the transmit and receive FIFOs */
743  intel_reset ( intel );
744 }
745 
746 /**
747  * Transmit packet
748  *
749  * @v netdev Network device
750  * @v iobuf I/O buffer
751  * @ret rc Return status code
752  */
753 int intel_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) {
754  struct intel_nic *intel = netdev->priv;
755  struct intel_descriptor *tx;
756  unsigned int tx_idx;
757  unsigned int tx_tail;
758  size_t len;
759 
760  /* Get next transmit descriptor */
761  if ( ( intel->tx.prod - intel->tx.cons ) >= INTEL_TX_FILL ) {
762  DBGC ( intel, "INTEL %p out of transmit descriptors\n", intel );
763  return -ENOBUFS;
764  }
765  tx_idx = ( intel->tx.prod++ % INTEL_NUM_TX_DESC );
766  tx_tail = ( intel->tx.prod % INTEL_NUM_TX_DESC );
767  tx = &intel->tx.desc[tx_idx];
768 
769  /* Populate transmit descriptor */
770  len = iob_len ( iobuf );
771  intel->tx.describe ( tx, iob_dma ( iobuf ), len );
772  wmb();
773 
774  /* Notify card that there are packets ready to transmit */
775  profile_start ( &intel_vm_tx_profiler );
776  writel ( tx_tail, intel->regs + intel->tx.reg + INTEL_xDT );
777  profile_stop ( &intel_vm_tx_profiler );
778  profile_exclude ( &intel_vm_tx_profiler );
779 
780  DBGC2 ( intel, "INTEL %p TX %d is [%lx,%lx)\n",
781  intel, tx_idx, virt_to_phys ( iobuf->data ),
782  ( virt_to_phys ( iobuf->data ) + len ) );
783 
784  return 0;
785 }
786 
787 /**
788  * Poll for completed packets
789  *
790  * @v netdev Network device
791  */
792 void intel_poll_tx ( struct net_device *netdev ) {
793  struct intel_nic *intel = netdev->priv;
794  struct intel_descriptor *tx;
795  unsigned int tx_idx;
796 
797  /* Check for completed packets */
798  while ( intel->tx.cons != intel->tx.prod ) {
799 
800  /* Get next transmit descriptor */
801  tx_idx = ( intel->tx.cons % INTEL_NUM_TX_DESC );
802  tx = &intel->tx.desc[tx_idx];
803 
804  /* Stop if descriptor is still in use */
805  if ( ! ( tx->status & cpu_to_le32 ( INTEL_DESC_STATUS_DD ) ) )
806  return;
807 
808  DBGC2 ( intel, "INTEL %p TX %d complete\n", intel, tx_idx );
809 
810  /* Complete TX descriptor */
812  intel->tx.cons++;
813  }
814 }
815 
816 /**
817  * Poll for received packets
818  *
819  * @v netdev Network device
820  */
821 void intel_poll_rx ( struct net_device *netdev ) {
822  struct intel_nic *intel = netdev->priv;
823  struct intel_descriptor *rx;
824  struct io_buffer *iobuf;
825  unsigned int rx_idx;
826  size_t len;
827 
828  /* Check for received packets */
829  while ( intel->rx.cons != intel->rx.prod ) {
830 
831  /* Get next receive descriptor */
832  rx_idx = ( intel->rx.cons % INTEL_NUM_RX_DESC );
833  rx = &intel->rx.desc[rx_idx];
834 
835  /* Stop if descriptor is still in use */
836  if ( ! ( rx->status & cpu_to_le32 ( INTEL_DESC_STATUS_DD ) ) )
837  return;
838 
839  /* Populate I/O buffer */
840  iobuf = intel->rx_iobuf[rx_idx];
841  intel->rx_iobuf[rx_idx] = NULL;
842  len = le16_to_cpu ( rx->length );
843  iob_put ( iobuf, len );
844 
845  /* Hand off to network stack */
846  if ( rx->status & cpu_to_le32 ( INTEL_DESC_STATUS_RXE ) ) {
847  DBGC ( intel, "INTEL %p RX %d error (length %zd, "
848  "status %08x)\n", intel, rx_idx, len,
849  le32_to_cpu ( rx->status ) );
850  netdev_rx_err ( netdev, iobuf, -EIO );
851  } else {
852  DBGC2 ( intel, "INTEL %p RX %d complete (length %zd)\n",
853  intel, rx_idx, len );
854  netdev_rx ( netdev, iobuf );
855  }
856  intel->rx.cons++;
857  }
858 }
859 
860 /**
861  * Poll for completed and received packets
862  *
863  * @v netdev Network device
864  */
865 static void intel_poll ( struct net_device *netdev ) {
866  struct intel_nic *intel = netdev->priv;
867  uint32_t icr;
868 
869  /* Check for and acknowledge interrupts */
870  profile_start ( &intel_vm_poll_profiler );
871  icr = readl ( intel->regs + INTEL_ICR );
872  profile_stop ( &intel_vm_poll_profiler );
873  profile_exclude ( &intel_vm_poll_profiler );
874  icr |= intel->force_icr;
875  if ( ! icr )
876  return;
877 
878  /* Poll for TX completions, if applicable */
879  if ( icr & INTEL_IRQ_TXDW )
880  intel_poll_tx ( netdev );
881 
882  /* Poll for RX completions, if applicable */
883  if ( icr & ( INTEL_IRQ_RXT0 | INTEL_IRQ_RXO ) )
884  intel_poll_rx ( netdev );
885 
886  /* Report receive overruns */
887  if ( icr & INTEL_IRQ_RXO )
889 
890  /* Check link state, if applicable */
891  if ( icr & INTEL_IRQ_LSC )
893 
894  /* Check for unexpected interrupts */
895  if ( icr & ~( INTEL_IRQ_TXDW | INTEL_IRQ_TXQE | INTEL_IRQ_LSC |
897  DBGC ( intel, "INTEL %p unexpected ICR %08x\n", intel, icr );
898  /* Report as a TX error */
900  }
901 
902  /* Refill RX ring */
903  intel_refill_rx ( intel );
904 }
905 
906 /**
907  * Enable or disable interrupts
908  *
909  * @v netdev Network device
910  * @v enable Interrupts should be enabled
911  */
912 static void intel_irq ( struct net_device *netdev, int enable ) {
913  struct intel_nic *intel = netdev->priv;
914  uint32_t mask;
915 
917  if ( enable ) {
918  writel ( mask, intel->regs + INTEL_IMS );
919  } else {
920  writel ( mask, intel->regs + INTEL_IMC );
921  }
922 }
923 
924 /** Intel network device operations */
926  .open = intel_open,
927  .close = intel_close,
928  .transmit = intel_transmit,
929  .poll = intel_poll,
930  .irq = intel_irq,
931 };
932 
933 /******************************************************************************
934  *
935  * PCI interface
936  *
937  ******************************************************************************
938  */
939 
940 /**
941  * Probe PCI device
942  *
943  * @v pci PCI device
944  * @ret rc Return status code
945  */
946 static int intel_probe ( struct pci_device *pci ) {
947  struct net_device *netdev;
948  struct intel_nic *intel;
949  int rc;
950 
951  /* Allocate and initialise net device */
952  netdev = alloc_etherdev ( sizeof ( *intel ) );
953  if ( ! netdev ) {
954  rc = -ENOMEM;
955  goto err_alloc;
956  }
958  intel = netdev->priv;
959  pci_set_drvdata ( pci, netdev );
960  netdev->dev = &pci->dev;
961  memset ( intel, 0, sizeof ( *intel ) );
962  intel->port = PCI_FUNC ( pci->busdevfn );
963  intel->flags = pci->id->driver_data;
968 
969  /* Fix up PCI device */
970  adjust_pci_device ( pci );
971 
972  /* Map registers */
973  intel->regs = pci_ioremap ( pci, pci->membase, INTEL_BAR_SIZE );
974  if ( ! intel->regs ) {
975  rc = -ENODEV;
976  goto err_ioremap;
977  }
978 
979  /* Configure DMA */
980  intel->dma = &pci->dma;
981  dma_set_mask_64bit ( intel->dma );
982  netdev->dma = intel->dma;
983 
984  /* Reset the NIC */
985  if ( ( rc = intel_reset ( intel ) ) != 0 )
986  goto err_reset;
987 
988  /* Fetch MAC address */
989  if ( ( rc = intel_fetch_mac ( intel, netdev->hw_addr ) ) != 0 )
990  goto err_fetch_mac;
991 
992  /* Register network device */
993  if ( ( rc = register_netdev ( netdev ) ) != 0 )
994  goto err_register_netdev;
995 
996  /* Set initial link state */
998 
999  return 0;
1000 
1002  err_register_netdev:
1003  err_fetch_mac:
1004  intel_reset ( intel );
1005  err_reset:
1006  iounmap ( intel->regs );
1007  err_ioremap:
1008  netdev_nullify ( netdev );
1009  netdev_put ( netdev );
1010  err_alloc:
1011  return rc;
1012 }
1013 
1014 /**
1015  * Remove PCI device
1016  *
1017  * @v pci PCI device
1018  */
1019 static void intel_remove ( struct pci_device *pci ) {
1020  struct net_device *netdev = pci_get_drvdata ( pci );
1021  struct intel_nic *intel = netdev->priv;
1022 
1023  /* Unregister network device */
1025 
1026  /* Reset the NIC */
1027  intel_reset ( intel );
1028 
1029  /* Free network device */
1030  iounmap ( intel->regs );
1031  netdev_nullify ( netdev );
1032  netdev_put ( netdev );
1033 }
1034 
1035 /** Intel PCI device IDs */
1036 static struct pci_device_id intel_nics[] = {
1037  PCI_ROM ( 0x8086, 0x0438, "dh8900cc", "DH8900CC", 0 ),
1038  PCI_ROM ( 0x8086, 0x043a, "dh8900cc-f", "DH8900CC Fiber", 0 ),
1039  PCI_ROM ( 0x8086, 0x043c, "dh8900cc-b", "DH8900CC Backplane", 0 ),
1040  PCI_ROM ( 0x8086, 0x0440, "dh8900cc-s", "DH8900CC SFP", 0 ),
1041  PCI_ROM ( 0x8086, 0x0d4c, "i219lm-11", "I219-LM (11)", INTEL_I219 ),
1042  PCI_ROM ( 0x8086, 0x0d4d, "i219v-11", "I219-V (11)", INTEL_I219 ),
1043  PCI_ROM ( 0x8086, 0x0d4e, "i219lm-10", "I219-LM (10)", INTEL_I219 ),
1044  PCI_ROM ( 0x8086, 0x0d4f, "i219v-10", "I219-V (10)", INTEL_I219 ),
1045  PCI_ROM ( 0x8086, 0x0d53, "i219lm-12", "I219-LM (12)", INTEL_I219 ),
1046  PCI_ROM ( 0x8086, 0x0d55, "i219v-12", "I219-V (12)", INTEL_I219 ),
1047  PCI_ROM ( 0x8086, 0x0d9f, "i225it", "I225-IT", INTEL_PBSIZE_RST ),
1048  PCI_ROM ( 0x8086, 0x0dc5, "i219lm-23", "I219-LM (23)", INTEL_I219 ),
1049  PCI_ROM ( 0x8086, 0x1000, "82542-f", "82542 (Fiber)", 0 ),
1050  PCI_ROM ( 0x8086, 0x1001, "82543gc-f", "82543GC (Fiber)", 0 ),
1051  PCI_ROM ( 0x8086, 0x1004, "82543gc", "82543GC (Copper)", 0 ),
1052  PCI_ROM ( 0x8086, 0x1008, "82544ei", "82544EI (Copper)", 0 ),
1053  PCI_ROM ( 0x8086, 0x1009, "82544ei-f", "82544EI (Fiber)", 0 ),
1054  PCI_ROM ( 0x8086, 0x100c, "82544gc", "82544GC (Copper)", 0 ),
1055  PCI_ROM ( 0x8086, 0x100d, "82544gc-l", "82544GC (LOM)", 0 ),
1056  PCI_ROM ( 0x8086, 0x100e, "82540em", "82540EM", 0 ),
1057  PCI_ROM ( 0x8086, 0x100f, "82545em", "82545EM (Copper)", INTEL_VMWARE ),
1058  PCI_ROM ( 0x8086, 0x1010, "82546eb", "82546EB (Copper)", 0 ),
1059  PCI_ROM ( 0x8086, 0x1011, "82545em-f", "82545EM (Fiber)", 0 ),
1060  PCI_ROM ( 0x8086, 0x1012, "82546eb-f", "82546EB (Fiber)", 0 ),
1061  PCI_ROM ( 0x8086, 0x1013, "82541ei", "82541EI", 0 ),
1062  PCI_ROM ( 0x8086, 0x1014, "82541er", "82541ER", 0 ),
1063  PCI_ROM ( 0x8086, 0x1015, "82540em-l", "82540EM (LOM)", 0 ),
1064  PCI_ROM ( 0x8086, 0x1016, "82540ep-m", "82540EP (Mobile)", 0 ),
1065  PCI_ROM ( 0x8086, 0x1017, "82540ep", "82540EP", 0 ),
1066  PCI_ROM ( 0x8086, 0x1018, "82541ei", "82541EI", 0 ),
1067  PCI_ROM ( 0x8086, 0x1019, "82547ei", "82547EI", 0 ),
1068  PCI_ROM ( 0x8086, 0x101a, "82547ei-m", "82547EI (Mobile)", 0 ),
1069  PCI_ROM ( 0x8086, 0x101d, "82546eb", "82546EB", 0 ),
1070  PCI_ROM ( 0x8086, 0x101e, "82540ep-m", "82540EP (Mobile)", 0 ),
1071  PCI_ROM ( 0x8086, 0x1026, "82545gm", "82545GM", 0 ),
1072  PCI_ROM ( 0x8086, 0x1027, "82545gm-1", "82545GM", 0 ),
1073  PCI_ROM ( 0x8086, 0x1028, "82545gm-2", "82545GM", 0 ),
1074  PCI_ROM ( 0x8086, 0x1049, "82566mm", "82566MM", INTEL_PBS_ERRATA ),
1075  PCI_ROM ( 0x8086, 0x104a, "82566dm", "82566DM", INTEL_PBS_ERRATA ),
1076  PCI_ROM ( 0x8086, 0x104b, "82566dc", "82566DC", INTEL_PBS_ERRATA ),
1077  PCI_ROM ( 0x8086, 0x104c, "82562v", "82562V", INTEL_PBS_ERRATA ),
1078  PCI_ROM ( 0x8086, 0x104d, "82566mc", "82566MC", INTEL_PBS_ERRATA ),
1079  PCI_ROM ( 0x8086, 0x105e, "82571eb", "82571EB", 0 ),
1080  PCI_ROM ( 0x8086, 0x105f, "82571eb-1", "82571EB", 0 ),
1081  PCI_ROM ( 0x8086, 0x1060, "82571eb-2", "82571EB", 0 ),
1082  PCI_ROM ( 0x8086, 0x1075, "82547gi", "82547GI", 0 ),
1083  PCI_ROM ( 0x8086, 0x1076, "82541gi", "82541GI", 0 ),
1084  PCI_ROM ( 0x8086, 0x1077, "82541gi-1", "82541GI", 0 ),
1085  PCI_ROM ( 0x8086, 0x1078, "82541er", "82541ER", 0 ),
1086  PCI_ROM ( 0x8086, 0x1079, "82546gb", "82546GB", 0 ),
1087  PCI_ROM ( 0x8086, 0x107a, "82546gb-1", "82546GB", 0 ),
1088  PCI_ROM ( 0x8086, 0x107b, "82546gb-2", "82546GB", 0 ),
1089  PCI_ROM ( 0x8086, 0x107c, "82541pi", "82541PI", 0 ),
1090  PCI_ROM ( 0x8086, 0x107d, "82572ei", "82572EI (Copper)", 0 ),
1091  PCI_ROM ( 0x8086, 0x107e, "82572ei-f", "82572EI (Fiber)", 0 ),
1092  PCI_ROM ( 0x8086, 0x107f, "82572ei", "82572EI", 0 ),
1093  PCI_ROM ( 0x8086, 0x108a, "82546gb-3", "82546GB", 0 ),
1094  PCI_ROM ( 0x8086, 0x108b, "82573v", "82573V (Copper)", 0 ),
1095  PCI_ROM ( 0x8086, 0x108c, "82573e", "82573E (Copper)", 0 ),
1096  PCI_ROM ( 0x8086, 0x1096, "80003es2lan", "80003ES2LAN (Copper)", 0 ),
1097  PCI_ROM ( 0x8086, 0x1098, "80003es2lan-s", "80003ES2LAN (Serdes)", 0 ),
1098  PCI_ROM ( 0x8086, 0x1099, "82546gb-4", "82546GB (Copper)", 0 ),
1099  PCI_ROM ( 0x8086, 0x109a, "82573l", "82573L", 0 ),
1100  PCI_ROM ( 0x8086, 0x10a4, "82571eb", "82571EB", 0 ),
1101  PCI_ROM ( 0x8086, 0x10a5, "82571eb", "82571EB (Fiber)", 0 ),
1102  PCI_ROM ( 0x8086, 0x10a7, "82575eb", "82575EB", 0 ),
1103  PCI_ROM ( 0x8086, 0x10a9, "82575eb", "82575EB Backplane", 0 ),
1104  PCI_ROM ( 0x8086, 0x10b5, "82546gb", "82546GB (Copper)", 0 ),
1105  PCI_ROM ( 0x8086, 0x10b9, "82572ei", "82572EI (Copper)", 0 ),
1106  PCI_ROM ( 0x8086, 0x10ba, "80003es2lan", "80003ES2LAN (Copper)", 0 ),
1107  PCI_ROM ( 0x8086, 0x10bb, "80003es2lan", "80003ES2LAN (Serdes)", 0 ),
1108  PCI_ROM ( 0x8086, 0x10bc, "82571eb", "82571EB (Copper)", 0 ),
1109  PCI_ROM ( 0x8086, 0x10bd, "82566dm-2", "82566DM-2", 0 ),
1110  PCI_ROM ( 0x8086, 0x10bf, "82567lf", "82567LF", 0 ),
1111  PCI_ROM ( 0x8086, 0x10c0, "82562v-2", "82562V-2", 0 ),
1112  PCI_ROM ( 0x8086, 0x10c2, "82562g-2", "82562G-2", 0 ),
1113  PCI_ROM ( 0x8086, 0x10c3, "82562gt-2", "82562GT-2", 0 ),
1114  PCI_ROM ( 0x8086, 0x10c4, "82562gt", "82562GT", INTEL_PBS_ERRATA ),
1115  PCI_ROM ( 0x8086, 0x10c5, "82562g", "82562G", INTEL_PBS_ERRATA ),
1116  PCI_ROM ( 0x8086, 0x10c9, "82576", "82576", 0 ),
1117  PCI_ROM ( 0x8086, 0x10cb, "82567v", "82567V", 0 ),
1118  PCI_ROM ( 0x8086, 0x10cc, "82567lm-2", "82567LM-2", 0 ),
1119  PCI_ROM ( 0x8086, 0x10cd, "82567lf-2", "82567LF-2", 0 ),
1120  PCI_ROM ( 0x8086, 0x10ce, "82567v-2", "82567V-2", 0 ),
1121  PCI_ROM ( 0x8086, 0x10d3, "82574l", "82574L", 0 ),
1122  PCI_ROM ( 0x8086, 0x10d5, "82571pt", "82571PT PT Quad", 0 ),
1123  PCI_ROM ( 0x8086, 0x10d6, "82575gb", "82575GB", 0 ),
1124  PCI_ROM ( 0x8086, 0x10d9, "82571eb-d", "82571EB Dual Mezzanine", 0 ),
1125  PCI_ROM ( 0x8086, 0x10da, "82571eb-q", "82571EB Quad Mezzanine", 0 ),
1126  PCI_ROM ( 0x8086, 0x10de, "82567lm-3", "82567LM-3", 0 ),
1127  PCI_ROM ( 0x8086, 0x10df, "82567lf-3", "82567LF-3", 0 ),
1128  PCI_ROM ( 0x8086, 0x10e5, "82567lm-4", "82567LM-4", 0 ),
1129  PCI_ROM ( 0x8086, 0x10e6, "82576", "82576", 0 ),
1130  PCI_ROM ( 0x8086, 0x10e7, "82576-2", "82576", 0 ),
1131  PCI_ROM ( 0x8086, 0x10e8, "82576-3", "82576", 0 ),
1132  PCI_ROM ( 0x8086, 0x10ea, "82577lm", "82577LM", 0 ),
1133  PCI_ROM ( 0x8086, 0x10eb, "82577lc", "82577LC", 0 ),
1134  PCI_ROM ( 0x8086, 0x10ef, "82578dm", "82578DM", 0 ),
1135  PCI_ROM ( 0x8086, 0x10f0, "82578dc", "82578DC", 0 ),
1136  PCI_ROM ( 0x8086, 0x10f5, "82567lm", "82567LM", 0 ),
1137  PCI_ROM ( 0x8086, 0x10f6, "82574l", "82574L", 0 ),
1138  PCI_ROM ( 0x8086, 0x125b, "i226lm", "I226-LM", INTEL_PBSIZE_RST ),
1139  PCI_ROM ( 0x8086, 0x125c, "i226v", "I226-V", INTEL_PBSIZE_RST ),
1140  PCI_ROM ( 0x8086, 0x125d, "i226it", "I226-IT", INTEL_PBSIZE_RST ),
1141  PCI_ROM ( 0x8086, 0x1501, "82567v-3", "82567V-3", INTEL_PBS_ERRATA ),
1142  PCI_ROM ( 0x8086, 0x1502, "82579lm", "82579LM", INTEL_NO_PHY_RST ),
1143  PCI_ROM ( 0x8086, 0x1503, "82579v", "82579V", 0 ),
1144  PCI_ROM ( 0x8086, 0x150a, "82576ns", "82576NS", 0 ),
1145  PCI_ROM ( 0x8086, 0x150c, "82583v", "82583V", 0 ),
1146  PCI_ROM ( 0x8086, 0x150d, "82576-4", "82576 Backplane", 0 ),
1147  PCI_ROM ( 0x8086, 0x150e, "82580", "82580", 0 ),
1148  PCI_ROM ( 0x8086, 0x150f, "82580-f", "82580 Fiber", 0 ),
1149  PCI_ROM ( 0x8086, 0x1510, "82580-b", "82580 Backplane", 0 ),
1150  PCI_ROM ( 0x8086, 0x1511, "82580-s", "82580 SFP", 0 ),
1151  PCI_ROM ( 0x8086, 0x1516, "82580-2", "82580", 0 ),
1152  PCI_ROM ( 0x8086, 0x1518, "82576ns", "82576NS SerDes", 0 ),
1153  PCI_ROM ( 0x8086, 0x1521, "i350", "I350", 0 ),
1154  PCI_ROM ( 0x8086, 0x1522, "i350-f", "I350 Fiber", 0 ),
1155  PCI_ROM ( 0x8086, 0x1523, "i350-b", "I350 Backplane", INTEL_NO_ASDE ),
1156  PCI_ROM ( 0x8086, 0x1524, "i350-2", "I350", 0 ),
1157  PCI_ROM ( 0x8086, 0x1525, "82567v-4", "82567V-4", 0 ),
1158  PCI_ROM ( 0x8086, 0x1526, "82576-5", "82576", 0 ),
1159  PCI_ROM ( 0x8086, 0x1527, "82580-f2", "82580 Fiber", 0 ),
1160  PCI_ROM ( 0x8086, 0x1533, "i210", "I210", INTEL_PBSIZE_RST ),
1161  PCI_ROM ( 0x8086, 0x1539, "i211", "I211", 0 ),
1162  PCI_ROM ( 0x8086, 0x153a, "i217lm", "I217-LM", INTEL_NO_PHY_RST ),
1163  PCI_ROM ( 0x8086, 0x153b, "i217v", "I217-V", 0 ),
1164  PCI_ROM ( 0x8086, 0x1559, "i218v", "I218-V", INTEL_NO_PHY_RST ),
1165  PCI_ROM ( 0x8086, 0x155a, "i218lm", "I218-LM", INTEL_NO_PHY_RST ),
1166  PCI_ROM ( 0x8086, 0x156f, "i219lm", "I219-LM", INTEL_I219 ),
1167  PCI_ROM ( 0x8086, 0x1570, "i219v", "I219-V", INTEL_I219 ),
1168  PCI_ROM ( 0x8086, 0x157b, "i210-2", "I210", INTEL_PBSIZE_RST ),
1169  PCI_ROM ( 0x8086, 0x15a0, "i218lm-2", "I218-LM", INTEL_NO_PHY_RST ),
1170  PCI_ROM ( 0x8086, 0x15a1, "i218v-2", "I218-V", 0 ),
1171  PCI_ROM ( 0x8086, 0x15a2, "i218lm-3", "I218-LM", INTEL_NO_PHY_RST ),
1172  PCI_ROM ( 0x8086, 0x15a3, "i218v-3", "I218-V", INTEL_NO_PHY_RST ),
1173  PCI_ROM ( 0x8086, 0x15b7, "i219lm-2", "I219-LM (2)", INTEL_I219 ),
1174  PCI_ROM ( 0x8086, 0x15b8, "i219v-2", "I219-V (2)", INTEL_I219 ),
1175  PCI_ROM ( 0x8086, 0x15b9, "i219lm-3", "I219-LM (3)", INTEL_I219 ),
1176  PCI_ROM ( 0x8086, 0x15bb, "i219lm-7", "I219-LM (7)", INTEL_I219 ),
1177  PCI_ROM ( 0x8086, 0x15bc, "i219v-7", "I219-V (7)", INTEL_I219 ),
1178  PCI_ROM ( 0x8086, 0x15bd, "i219lm-6", "I219-LM (6)", INTEL_I219 ),
1179  PCI_ROM ( 0x8086, 0x15be, "i219v-6", "I219-V (6)", INTEL_I219 ),
1180  PCI_ROM ( 0x8086, 0x15d6, "i219v-5", "I219-V (5)", INTEL_I219 ),
1181  PCI_ROM ( 0x8086, 0x15d7, "i219lm-4", "I219-LM (4)", INTEL_I219 ),
1182  PCI_ROM ( 0x8086, 0x15d8, "i219v-4", "I219-V (4)", INTEL_I219 ),
1183  PCI_ROM ( 0x8086, 0x15df, "i219lm-8", "I219-LM (8)", INTEL_I219 ),
1184  PCI_ROM ( 0x8086, 0x15e0, "i219v-8", "I219-V (8)", INTEL_I219 ),
1185  PCI_ROM ( 0x8086, 0x15e1, "i219lm-9", "I219-LM (9)", INTEL_I219 ),
1186  PCI_ROM ( 0x8086, 0x15e2, "i219v-9", "I219-V (9)", INTEL_I219 ),
1187  PCI_ROM ( 0x8086, 0x15e3, "i219lm-5", "I219-LM (5)", INTEL_I219 ),
1188  PCI_ROM ( 0x8086, 0x15f2, "i225lm", "I225-LM", INTEL_PBSIZE_RST ),
1189  PCI_ROM ( 0x8086, 0x15f3, "i225v", "I225-V", INTEL_PBSIZE_RST ),
1190  PCI_ROM ( 0x8086, 0x15f4, "i219lm-15", "I219-LM (15)", INTEL_I219 ),
1191  PCI_ROM ( 0x8086, 0x15f5, "i219v-15", "I219-V (15)", INTEL_I219 ),
1192  PCI_ROM ( 0x8086, 0x15f9, "i219lm-14", "I219-LM (14)", INTEL_I219 ),
1193  PCI_ROM ( 0x8086, 0x15fa, "i219v-14", "I219-V (14)", INTEL_I219 ),
1194  PCI_ROM ( 0x8086, 0x15fb, "i219lm-13", "I219-LM (13)", INTEL_I219 ),
1195  PCI_ROM ( 0x8086, 0x15fc, "i219v-13", "I219-V (13)", INTEL_I219 ),
1196  PCI_ROM ( 0x8086, 0x1a1c, "i219lm-17", "I219-LM (17)", INTEL_I219 ),
1197  PCI_ROM ( 0x8086, 0x1a1d, "i219v-17", "I219-V (17)", INTEL_I219 ),
1198  PCI_ROM ( 0x8086, 0x1a1e, "i219lm-16", "I219-LM (16)", INTEL_I219 ),
1199  PCI_ROM ( 0x8086, 0x1a1f, "i219v-16", "I219-V (16)", INTEL_I219 ),
1200  PCI_ROM ( 0x8086, 0x1f41, "i354", "I354", INTEL_NO_ASDE ),
1201  PCI_ROM ( 0x8086, 0x294c, "82566dc-2", "82566DC-2", 0 ),
1202  PCI_ROM ( 0x8086, 0x2e6e, "cemedia", "CE Media Processor", 0 ),
1203  PCI_ROM ( 0x8086, 0x5502, "i225lmvp", "I225-LMvP", INTEL_PBSIZE_RST ),
1204  PCI_ROM ( 0x8086, 0x57a0, "i219lm-24", "I219-LM (24)", INTEL_I219 ),
1205  PCI_ROM ( 0x8086, 0x57a1, "i219v-24", "I219-V (24)", INTEL_I219 ),
1206 };
1207 
1208 /** Intel PCI driver */
1209 struct pci_driver intel_driver __pci_driver = {
1210  .ids = intel_nics,
1211  .id_count = ( sizeof ( intel_nics ) / sizeof ( intel_nics[0] ) ),
1212  .probe = intel_probe,
1213  .remove = intel_remove,
1214 };
unsigned int force_icr
Forced interrupts.
Definition: intel.h:300
void * regs
Registers.
Definition: intel.h:292
#define PCI_FUNC(busdevfn)
Definition: pci.h:286
PHY reset is broken.
Definition: intel.h:327
int(* write)(struct nvs_device *nvs, unsigned int address, const void *data, size_t len)
Write data to device.
Definition: nvs.h:60
unsigned long membase
Memory base.
Definition: pci.h:220
#define INTEL_RCTL_BSIZE_2048
Definition: intel.h:122
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
unsigned short uint16_t
Definition: stdint.h:11
wmb()
unsigned int word_len_log2
Word length.
Definition: nvs.h:23
#define INTEL_ICR
Interrupt Cause Read Register.
Definition: intel.h:99
#define INTEL_DESC_STATUS_DD
Descriptor done.
Definition: intel.h:52
#define iob_put(iobuf, len)
Definition: iobuf.h:125
struct dma_device dma
DMA device.
Definition: pci.h:215
#define INTEL_NUM_RX_DESC
Number of receive descriptors.
Definition: intel.h:155
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition: netdevice.c:587
#define INTEL_IRQ_RXDMT0
Receive queue low.
Definition: intel.h:103
#define INTEL_PBA
Packet Buffer Allocation.
Definition: intel.h:138
#define INTEL_EERD
EEPROM Read Register.
Definition: intel.h:78
void intel_poll_rx(struct net_device *netdev)
Poll for received packets.
Definition: intel.c:821
A PCI driver.
Definition: pci.h:252
void intel_reset_ring(struct intel_nic *intel, unsigned int reg)
Reset descriptor ring.
Definition: intel.c:488
#define INTEL_DESC_STATUS_PAYLEN(len)
Payload length.
Definition: intel.h:58
static unsigned int unsigned int reg
Definition: myson.h:162
static int intel_fetch_mac_eeprom(struct intel_nic *intel, uint8_t *hw_addr)
Fetch initial MAC address from EEPROM.
Definition: intel.c:199
ASDE is broken.
Definition: intel.h:329
static struct profiler intel_vm_tx_profiler __profiler
VM transmit profiler.
Definition: intel.c:48
#define INTEL_IRQ_RXT0
Receive timer.
Definition: intel.h:105
#define le32_to_cpu(value)
Definition: byteswap.h:114
int(* open)(struct net_device *netdev)
Open network device.
Definition: netdevice.h:223
void netdev_tx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard transmitted packet.
Definition: netdevice.c:441
#define INTEL_EERD_DONE_SMALL
Read done (small EERD)
Definition: intel.h:80
Error codes.
static int intel_fetch_mac(struct intel_nic *intel, uint8_t *hw_addr)
Fetch initial MAC address.
Definition: intel.c:230
VMware missing interrupt workaround required.
Definition: intel.h:325
struct dma_mapping map
Descriptor ring DMA mapping.
Definition: intel.h:227
#define INTEL_xDCTL
Receive/Transmit Descriptor Control (offset)
Definition: intel.h:196
static int intel_open(struct net_device *netdev)
Open network device.
Definition: intel.c:648
#define INTEL_RD
Receive Descriptor register block.
Definition: intel.h:148
unsigned long driver_data
Arbitrary driver data.
Definition: pci.h:183
static void netdev_tx_complete_next(struct net_device *netdev)
Complete network transmission.
Definition: netdevice.h:779
I/O buffers.
A non-volatile storage device.
Definition: nvs.h:16
#define INTEL_NUM_TX_DESC
Number of transmit descriptors.
Definition: intel.h:175
struct pci_device_id * ids
PCI ID table.
Definition: pci.h:254
void intel_poll_tx(struct net_device *netdev)
Poll for completed packets.
Definition: intel.c:792
uint64_t address
Base address.
Definition: ena.h:24
static void intel_irq(struct net_device *netdev, int enable)
Enable or disable interrupts.
Definition: intel.c:912
#define INTEL_RCTL_BSIZE_BSEX_MASK
Definition: intel.h:123
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
struct intel_ring rx
Receive descriptor ring.
Definition: intel.h:315
#define INTEL_TCTL_EN
Transmit enable.
Definition: intel.h:128
#define DBGC(...)
Definition: compiler.h:505
#define INTEL_xDT
Receive/Transmit Descriptor Tail (offset)
Definition: intel.h:193
int intel_create_ring(struct intel_nic *intel, struct intel_ring *ring)
Create descriptor ring.
Definition: intel.c:512
void intel_empty_rx(struct intel_nic *intel)
Discard unused receive I/O buffers.
Definition: intel.c:631
#define ENOENT
No such file or directory.
Definition: errno.h:515
size_t len
Length (in bytes)
Definition: intel.h:236
unsigned long long uint64_t
Definition: stdint.h:13
static __always_inline void dma_set_mask_64bit(struct dma_device *dma)
Set 64-bit addressable space mask.
Definition: dma.h:467
void intel_describe_tx(struct intel_descriptor *tx, physaddr_t addr, size_t len)
Populate transmit descriptor.
Definition: intel.c:396
struct dma_device * dma
DMA device.
Definition: netdevice.h:367
#define INTEL_TXPBS
Transmit packet buffer size.
Definition: intel.h:164
#define INTEL_PBS
Packet Buffer Size.
Definition: intel.h:141
#define cpu_to_le64(value)
Definition: byteswap.h:109
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition: netdevice.c:231
PBS/PBA errata workaround required.
Definition: intel.h:323
DMA mappings.
#define INTEL_IRQ_TXDW
Transmit descriptor done.
Definition: intel.h:100
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
A data structure for storing profiling information.
Definition: profile.h:27
An Intel descriptor ring.
Definition: intel.h:223
#define INTEL_BAR_SIZE
Intel BAR size.
Definition: intel.h:19
static void profile_stop(struct profiler *profiler)
Stop profiling.
Definition: profile.h:174
#define INTEL_DESC_FL_DTYP_DATA
Definition: intel.h:37
#define INTEL_RCTL_SECRC
Strip CRC.
Definition: intel.h:124
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition: pci.c:241
static void intel_init_ring(struct intel_ring *ring, unsigned int count, unsigned int reg, void(*describe)(struct intel_descriptor *desc, physaddr_t addr, size_t len))
Initialise descriptor ring.
Definition: intel.h:257
unsigned int cons
Consumer index.
Definition: intel.h:231
#define INTEL_xDLEN
Receive/Transmit Descriptor Length (offset)
Definition: intel.h:187
struct device dev
Generic device.
Definition: pci.h:213
unsigned int reg
Register block.
Definition: intel.h:234
#define ENOTSUP
Operation not supported.
Definition: errno.h:590
void intel_refill_rx(struct intel_nic *intel)
Refill receive descriptor ring.
Definition: intel.c:581
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
eeprom
Definition: 3c90x.h:232
static void intel_check_link(struct net_device *netdev)
Check link state.
Definition: intel.c:366
unsigned int port
Port number (for multi-port devices)
Definition: intel.h:296
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition: netdevice.h:519
#define INTEL_CTRL_FRCDPLX
Force duplex.
Definition: intel.h:66
#define INTEL_TX_FILL
Transmit descriptor ring maximum fill level.
Definition: intel.h:178
#define INTEL_xDH
Receive/Transmit Descriptor Head (offset)
Definition: intel.h:190
void dma_free(struct dma_mapping *map, void *addr, size_t len)
Unmap and free DMA-coherent buffer.
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Definition: pci.h:366
#define INTEL_TCTL_CT_MASK
Definition: intel.h:132
#define ENOMEM
Not enough space.
Definition: errno.h:535
#define INTEL_xDBAL
Receive/Transmit Descriptor Base Address Low (offset)
Definition: intel.h:181
FILE_SECBOOT(PERMITTED)
void * memcpy(void *dest, const void *src, size_t len) __nonnull
const char * name
Name.
Definition: profile.h:29
#define INTEL_FEXTNVM11
Future Extended NVM register 11.
Definition: intel.h:210
unsigned int block_size
Data block size (in words)
Definition: nvs.h:37
#define INTEL_EEPROM_MAC
Offset of MAC address within EEPROM.
Definition: intel.h:96
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:576
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:36
Ethernet protocol.
static int intel_reset(struct intel_nic *intel)
Reset hardware.
Definition: intel.c:267
#define INTEL_CTRL_ASDE
Auto-speed detection.
Definition: intel.h:63
void * priv
Driver private data.
Definition: netdevice.h:432
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
void intel_describe_rx(struct intel_descriptor *rx, physaddr_t addr, size_t len __unused)
Populate receive descriptor.
Definition: intel.c:434
#define INTEL_FEXTNVM11_WTF
Don't ask.
Definition: intel.h:211
#define __unused
Declare a variable or data structure as unused.
Definition: compiler.h:573
#define INTEL_EERD_DATA(value)
Read data.
Definition: intel.h:84
Intel 10/100/1000 network card driver.
PBSIZE registers must be explicitly reset.
Definition: intel.h:333
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition: netdevice.h:789
ring len
Length.
Definition: dwmac.h:231
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
#define INTEL_CTRL_LRST
Link reset.
Definition: intel.h:62
uint32_t eerd_done
EEPROM done flag.
Definition: intel.h:305
#define INTEL_EEPROM_WORD_LEN_LOG2
EEPROM word length.
Definition: intel.h:90
static struct net_device * netdev
Definition: gdbudp.c:52
static __always_inline physaddr_t iob_dma(struct io_buffer *iobuf)
Get I/O buffer DMA address.
Definition: iobuf.h:268
struct io_buffer * rx_iobuf[INTEL_NUM_RX_DESC]
Receive I/O buffers.
Definition: intel.h:317
#define INTEL_EERD_ADDR_SHIFT_SMALL
Address shift (small)
Definition: intel.h:82
#define INTEL_IMS
Interrupt Mask Set/Read Register.
Definition: intel.h:108
static void profile_start(struct profiler *profiler)
Start profiling.
Definition: profile.h:161
Profiling.
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:942
#define INTEL_DESC_CMD_IFCS
Insert frame checksum (CRC)
Definition: intel.h:46
int(* read)(struct nvs_device *nvs, unsigned int address, void *data, size_t len)
Read data from device.
Definition: nvs.h:48
#define cpu_to_le32(value)
Definition: byteswap.h:108
#define INTEL_CTRL_RST
Device reset.
Definition: intel.h:67
static int intel_probe(struct pci_device *pci)
Probe PCI device.
Definition: intel.c:946
static struct net_device_operations intel_operations
Intel network device operations.
Definition: intel.c:925
static void intel_poll(struct net_device *netdev)
Poll for completed and received packets.
Definition: intel.c:865
static struct pci_device_id intel_nics[]
Intel PCI device IDs.
Definition: intel.c:1036
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
#define INTEL_I219
The i219 has a seriously broken reset mechanism.
Definition: intel.h:337
#define INTEL_STATUS_LU
Link up.
Definition: intel.h:75
struct io_buffer * alloc_rx_iob(size_t len, struct dma_device *dma)
Allocate and map I/O buffer for receive DMA.
Definition: iobuf.c:188
PCI bus.
A PCI device.
Definition: pci.h:211
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:760
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:160
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:176
uint32_t addr
Buffer address.
Definition: dwmac.h:20
A network device.
Definition: netdevice.h:353
#define ENODEV
No such device.
Definition: errno.h:510
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:532
unsigned char uint8_t
Definition: stdint.h:10
static int intel_write_eeprom(struct nvs_device *nvs, unsigned int address __unused, const void *data __unused, size_t len __unused)
Write data to EEPROM.
Definition: intel.c:120
#define INTEL_RX_MAX_LEN
Receive buffer length.
Definition: intel.h:161
#define INTEL_EEPROM_MAX_WAIT_MS
Maximum time to wait for EEPROM read, in milliseconds.
Definition: intel.h:87
#define ETH_ALEN
Definition: if_ether.h:9
#define INTEL_TCTL_CT_DEFAULT
Definition: intel.h:131
A PCI device ID list entry.
Definition: pci.h:175
#define INTEL_DISABLE_MAX_WAIT_MS
Maximum time to wait for queue disable, in milliseconds.
Definition: intel.h:200
struct pci_driver intel_driver __pci_driver
Intel PCI driver.
Definition: intel.c:1209
#define le16_to_cpu(value)
Definition: byteswap.h:113
#define INTEL_RCTL_BAM
Broadcast accept mode.
Definition: intel.h:118
unsigned int uint32_t
Definition: stdint.h:12
void * dma_alloc(struct dma_device *dma, struct dma_mapping *map, size_t len, size_t align)
Allocate and map DMA-coherent buffer.
static int is_valid_ether_addr(const void *addr)
Check if Ethernet address is valid.
Definition: ethernet.h:78
void(* describe)(struct intel_descriptor *desc, physaddr_t addr, size_t len)
Populate descriptor.
Definition: intel.h:244
static struct xen_remove_from_physmap * remove
Definition: xenmem.h:39
static void intel_remove(struct pci_device *pci)
Remove PCI device.
Definition: intel.c:1019
uint8_t status
Status.
Definition: ena.h:16
Network device operations.
Definition: netdevice.h:214
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition: netdevice.c:549
struct device * dev
Underlying hardware device.
Definition: netdevice.h:365
Network device management.
#define INTEL_CTRL
Device Control Register.
Definition: intel.h:61
unsigned long physaddr_t
Definition: stdint.h:20
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition: pci.h:376
struct dma_device * dma
DMA device.
Definition: intel.h:294
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:79
#define INTEL_RCTL_UPE
Unicast promiscuous mode.
Definition: intel.h:116
#define INTEL_RCTL
Receive Control Register.
Definition: intel.h:114
uint32_t busdevfn
Segment, bus, device, and function (bus:dev.fn) number.
Definition: pci.h:238
A packet descriptor.
Definition: intel.h:22
#define INTEL_TCTL
Transmit Control Register.
Definition: intel.h:127
#define INTEL_TXPBS_I210
I210 power-up default.
Definition: intel.h:165
void free_rx_iob(struct io_buffer *iobuf)
Unmap and free I/O buffer for receive DMA.
Definition: iobuf.c:215
#define ENOBUFS
No buffer space available.
Definition: errno.h:499
static int intel_disable_ring(struct intel_nic *intel, unsigned int reg)
Disable descriptor ring.
Definition: intel.c:457
#define DBGC2(...)
Definition: compiler.h:522
#define INTEL_CTRL_PHY_RST
PHY reset.
Definition: intel.h:68
int(* probe)(struct pci_device *pci)
Probe device.
Definition: pci.h:265
#define INTEL_EERD_DONE_LARGE
Read done (large EERD)
Definition: intel.h:81
int intel_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
Definition: intel.c:753
void * data
Start of data.
Definition: iobuf.h:53
#define INTEL_EERD_ADDR_SHIFT_LARGE
Address shift (large)
Definition: intel.h:83
unsigned int prod
Producer index.
Definition: intel.h:229
void intel_destroy_ring(struct intel_nic *intel, struct intel_ring *ring)
Destroy descriptor ring.
Definition: intel.c:564
#define INTEL_RESET_DELAY_MS
Time to delay for device reset, in milliseconds.
Definition: intel.h:71
#define EIO
Input/output error.
Definition: errno.h:434
#define INTEL_DESC_CMD_DEXT
Descriptor extension.
Definition: intel.h:40
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition: ethernet.c:265
u8 rx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets from the AP.
Definition: wpa.h:234
struct pci_device_id * id
Driver device ID.
Definition: pci.h:248
#define INTEL_CTRL_SLU
Set link up.
Definition: intel.h:64
void intel_describe_tx_adv(struct intel_descriptor *tx, physaddr_t addr, size_t len)
Populate advanced transmit descriptor.
Definition: intel.c:415
#define INTEL_DESC_CMD_EOP
End of packet.
Definition: intel.h:49
uint8_t ctrl
Ring control.
Definition: dwmac.h:18
#define cpu_to_le16(value)
Definition: byteswap.h:107
An Intel network card.
Definition: intel.h:290
void iounmap(volatile const void *io_addr)
Unmap I/O address.
#define INTEL_RXPBS_I210
I210 power-up default.
Definition: intel.h:145
uint8_t data[48]
Additional event data.
Definition: ena.h:22
#define INTEL_RX_FILL
Receive descriptor ring fill level.
Definition: intel.h:158
#define INTEL_xDCTL_ENABLE
Queue enable.
Definition: intel.h:197
struct intel_descriptor * desc
Descriptors.
Definition: intel.h:225
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
static int intel_read_eeprom(struct nvs_device *nvs, unsigned int address, void *data, size_t len)
Read data from EEPROM.
Definition: intel.c:75
#define INTEL_TCTL_PSP
Pad short packets.
Definition: intel.h:129
static int intel_init_eeprom(struct intel_nic *intel)
Initialise EEPROM.
Definition: intel.c:137
#define INTEL_STATUS
Device Status Register.
Definition: intel.h:74
#define INTEL_EERD_START
Start read.
Definition: intel.h:79
struct intel_ring tx
Transmit descriptor ring.
Definition: intel.h:313
Receive address.
Definition: intel.h:214
Reset may cause a complete device hang.
Definition: intel.h:331
#define INTEL_RCTL_EN
Receive enable.
Definition: intel.h:115
#define INTEL_RAH0_AV
Address valid.
Definition: intel.h:207
#define INTEL_IRQ_TXQE
Transmit queue empty.
Definition: intel.h:101
unsigned int eerd_addr_shift
EEPROM address shift.
Definition: intel.h:307
#define INTEL_DESC_STATUS_RXE
Receive error.
Definition: intel.h:55
#define INTEL_RAL0
Receive Address Low.
Definition: intel.h:203
#define INTEL_IRQ_LSC
Link status change.
Definition: intel.h:102
#define INTEL_EEPROM_MIN_SIZE_WORDS
Minimum EEPROM size, in words.
Definition: intel.h:93
#define INTEL_RAH0
Receive Address High.
Definition: intel.h:206
static void profile_exclude(struct profiler *profiler)
Exclude time from other ongoing profiling results.
Definition: profile.h:187
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:388
#define INTEL_TCTL_COLD_MASK
Definition: intel.h:135
#define INTEL_DESC_CMD_RS
Report status.
Definition: intel.h:43
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
#define INTEL_TCTL_COLD_DEFAULT
Definition: intel.h:134
unsigned int flags
Flags.
Definition: intel.h:298
static void intel_close(struct net_device *netdev)
Close network device.
Definition: intel.c:724
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:382
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322
struct nvs_device eeprom
EEPROM.
Definition: intel.h:303
#define INTEL_xDBAH
Receive/Transmit Descriptor Base Address High (offset)
Definition: intel.h:184
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:670
String functions.
#define INTEL_IMC
Interrupt Mask Clear Register.
Definition: intel.h:111
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition: pci.h:308
#define INTEL_RCTL_MPE
Multicast promiscuous.
Definition: intel.h:117
unsigned int size
Device size (in words)
Definition: nvs.h:25
#define INTEL_IRQ_RXO
Receive overrun.
Definition: intel.h:104
#define INTEL_TD
Transmit Descriptor register block.
Definition: intel.h:168
physaddr_t dma(struct dma_mapping *map, void *addr)
Get DMA address from virtual address.
#define INTEL_CTRL_FRCSPD
Force speed.
Definition: intel.h:65
u8 tx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets to the AP.
Definition: wpa.h:237
void * memset(void *dest, int character, size_t len) __nonnull
A persistent I/O buffer.
Definition: iobuf.h:38
#define INTEL_RXPBS
Receive packet buffer size.
Definition: intel.h:144