You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

intel.c 33KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  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. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  24. #include <stdint.h>
  25. #include <string.h>
  26. #include <unistd.h>
  27. #include <errno.h>
  28. #include <byteswap.h>
  29. #include <ipxe/netdevice.h>
  30. #include <ipxe/ethernet.h>
  31. #include <ipxe/if_ether.h>
  32. #include <ipxe/iobuf.h>
  33. #include <ipxe/malloc.h>
  34. #include <ipxe/pci.h>
  35. #include <ipxe/profile.h>
  36. #include "intel.h"
  37. /** @file
  38. *
  39. * Intel 10/100/1000 network card driver
  40. *
  41. */
  42. /** VM transmit profiler */
  43. static struct profiler intel_vm_tx_profiler __profiler =
  44. { .name = "intel.vm_tx" };
  45. /** VM receive refill profiler */
  46. static struct profiler intel_vm_refill_profiler __profiler =
  47. { .name = "intel.vm_refill" };
  48. /** VM poll profiler */
  49. static struct profiler intel_vm_poll_profiler __profiler =
  50. { .name = "intel.vm_poll" };
  51. /******************************************************************************
  52. *
  53. * EEPROM interface
  54. *
  55. ******************************************************************************
  56. */
  57. /**
  58. * Read data from EEPROM
  59. *
  60. * @v nvs NVS device
  61. * @v address Address from which to read
  62. * @v data Data buffer
  63. * @v len Length of data buffer
  64. * @ret rc Return status code
  65. */
  66. static int intel_read_eeprom ( struct nvs_device *nvs, unsigned int address,
  67. void *data, size_t len ) {
  68. struct intel_nic *intel =
  69. container_of ( nvs, struct intel_nic, eeprom );
  70. unsigned int i;
  71. uint32_t value;
  72. uint16_t *data_word = data;
  73. /* Sanity check. We advertise a blocksize of one word, so
  74. * should only ever receive single-word requests.
  75. */
  76. assert ( len == sizeof ( *data_word ) );
  77. /* Initiate read */
  78. writel ( ( INTEL_EERD_START | ( address << intel->eerd_addr_shift ) ),
  79. intel->regs + INTEL_EERD );
  80. /* Wait for read to complete */
  81. for ( i = 0 ; i < INTEL_EEPROM_MAX_WAIT_MS ; i++ ) {
  82. /* If read is not complete, delay 1ms and retry */
  83. value = readl ( intel->regs + INTEL_EERD );
  84. if ( ! ( value & intel->eerd_done ) ) {
  85. mdelay ( 1 );
  86. continue;
  87. }
  88. /* Extract data */
  89. *data_word = cpu_to_le16 ( INTEL_EERD_DATA ( value ) );
  90. return 0;
  91. }
  92. DBGC ( intel, "INTEL %p timed out waiting for EEPROM read\n", intel );
  93. return -ETIMEDOUT;
  94. }
  95. /**
  96. * Write data to EEPROM
  97. *
  98. * @v nvs NVS device
  99. * @v address Address to which to write
  100. * @v data Data buffer
  101. * @v len Length of data buffer
  102. * @ret rc Return status code
  103. */
  104. static int intel_write_eeprom ( struct nvs_device *nvs,
  105. unsigned int address __unused,
  106. const void *data __unused,
  107. size_t len __unused ) {
  108. struct intel_nic *intel =
  109. container_of ( nvs, struct intel_nic, eeprom );
  110. DBGC ( intel, "INTEL %p EEPROM write not supported\n", intel );
  111. return -ENOTSUP;
  112. }
  113. /**
  114. * Initialise EEPROM
  115. *
  116. * @v intel Intel device
  117. * @ret rc Return status code
  118. */
  119. static int intel_init_eeprom ( struct intel_nic *intel ) {
  120. unsigned int i;
  121. uint32_t value;
  122. /* The NIC automatically detects the type of attached EEPROM.
  123. * The EERD register provides access to only a single word at
  124. * a time, so we pretend to have a single-word block size.
  125. *
  126. * The EEPROM size may be larger than the minimum size, but
  127. * this doesn't matter to us since we access only the first
  128. * few words.
  129. */
  130. intel->eeprom.word_len_log2 = INTEL_EEPROM_WORD_LEN_LOG2;
  131. intel->eeprom.size = INTEL_EEPROM_MIN_SIZE_WORDS;
  132. intel->eeprom.block_size = 1;
  133. intel->eeprom.read = intel_read_eeprom;
  134. intel->eeprom.write = intel_write_eeprom;
  135. /* The layout of the EERD register was changed at some point
  136. * to accommodate larger EEPROMs. Read from address zero (for
  137. * which the request layouts are compatible) to determine
  138. * which type of register we have.
  139. */
  140. writel ( INTEL_EERD_START, intel->regs + INTEL_EERD );
  141. for ( i = 0 ; i < INTEL_EEPROM_MAX_WAIT_MS ; i++ ) {
  142. value = readl ( intel->regs + INTEL_EERD );
  143. if ( value & INTEL_EERD_DONE_LARGE ) {
  144. DBGC ( intel, "INTEL %p has large-format EERD\n",
  145. intel );
  146. intel->eerd_done = INTEL_EERD_DONE_LARGE;
  147. intel->eerd_addr_shift = INTEL_EERD_ADDR_SHIFT_LARGE;
  148. return 0;
  149. }
  150. if ( value & INTEL_EERD_DONE_SMALL ) {
  151. DBGC ( intel, "INTEL %p has small-format EERD\n",
  152. intel );
  153. intel->eerd_done = INTEL_EERD_DONE_SMALL;
  154. intel->eerd_addr_shift = INTEL_EERD_ADDR_SHIFT_SMALL;
  155. return 0;
  156. }
  157. mdelay ( 1 );
  158. }
  159. DBGC ( intel, "INTEL %p timed out waiting for initial EEPROM read "
  160. "(value %08x)\n", intel, value );
  161. return -ETIMEDOUT;
  162. }
  163. /******************************************************************************
  164. *
  165. * MAC address
  166. *
  167. ******************************************************************************
  168. */
  169. /**
  170. * Fetch initial MAC address from EEPROM
  171. *
  172. * @v intel Intel device
  173. * @v hw_addr Hardware address to fill in
  174. * @ret rc Return status code
  175. */
  176. static int intel_fetch_mac_eeprom ( struct intel_nic *intel,
  177. uint8_t *hw_addr ) {
  178. int rc;
  179. /* Initialise EEPROM */
  180. if ( ( rc = intel_init_eeprom ( intel ) ) != 0 )
  181. return rc;
  182. /* Read base MAC address from EEPROM */
  183. if ( ( rc = nvs_read ( &intel->eeprom, INTEL_EEPROM_MAC,
  184. hw_addr, ETH_ALEN ) ) != 0 ) {
  185. DBGC ( intel, "INTEL %p could not read EEPROM base MAC "
  186. "address: %s\n", intel, strerror ( rc ) );
  187. return rc;
  188. }
  189. /* Adjust MAC address for multi-port devices */
  190. hw_addr[ETH_ALEN-1] ^= intel->port;
  191. DBGC ( intel, "INTEL %p has EEPROM MAC address %s (port %d)\n",
  192. intel, eth_ntoa ( hw_addr ), intel->port );
  193. return 0;
  194. }
  195. /**
  196. * Fetch initial MAC address
  197. *
  198. * @v intel Intel device
  199. * @v hw_addr Hardware address to fill in
  200. * @ret rc Return status code
  201. */
  202. static int intel_fetch_mac ( struct intel_nic *intel, uint8_t *hw_addr ) {
  203. union intel_receive_address mac;
  204. int rc;
  205. /* Read current address from RAL0/RAH0 */
  206. mac.reg.low = cpu_to_le32 ( readl ( intel->regs + INTEL_RAL0 ) );
  207. mac.reg.high = cpu_to_le32 ( readl ( intel->regs + INTEL_RAH0 ) );
  208. DBGC ( intel, "INTEL %p has autoloaded MAC address %s\n",
  209. intel, eth_ntoa ( mac.raw ) );
  210. /* Use current address if valid */
  211. if ( is_valid_ether_addr ( mac.raw ) ) {
  212. memcpy ( hw_addr, mac.raw, ETH_ALEN );
  213. return 0;
  214. }
  215. /* Otherwise, try to read address from EEPROM */
  216. if ( ( rc = intel_fetch_mac_eeprom ( intel, hw_addr ) ) == 0 )
  217. return 0;
  218. DBGC ( intel, "INTEL %p has no MAC address to use\n", intel );
  219. return -ENOENT;
  220. }
  221. /******************************************************************************
  222. *
  223. * Device reset
  224. *
  225. ******************************************************************************
  226. */
  227. /**
  228. * Reset hardware
  229. *
  230. * @v intel Intel device
  231. * @ret rc Return status code
  232. */
  233. static int intel_reset ( struct intel_nic *intel ) {
  234. uint32_t pbs;
  235. uint32_t pba;
  236. uint32_t ctrl;
  237. uint32_t status;
  238. /* Force RX and TX packet buffer allocation, to work around an
  239. * errata in ICH devices.
  240. */
  241. if ( intel->flags & INTEL_PBS_ERRATA ) {
  242. DBGC ( intel, "INTEL %p WARNING: applying ICH PBS/PBA errata\n",
  243. intel );
  244. pbs = readl ( intel->regs + INTEL_PBS );
  245. pba = readl ( intel->regs + INTEL_PBA );
  246. writel ( 0x08, intel->regs + INTEL_PBA );
  247. writel ( 0x10, intel->regs + INTEL_PBS );
  248. DBGC ( intel, "INTEL %p PBS %#08x->%#08x PBA %#08x->%#08x\n",
  249. intel, pbs, readl ( intel->regs + INTEL_PBS ),
  250. pba, readl ( intel->regs + INTEL_PBA ) );
  251. }
  252. /* Always reset MAC. Required to reset the TX and RX rings. */
  253. ctrl = readl ( intel->regs + INTEL_CTRL );
  254. writel ( ( ctrl | INTEL_CTRL_RST ), intel->regs + INTEL_CTRL );
  255. mdelay ( INTEL_RESET_DELAY_MS );
  256. /* Set a sensible default configuration */
  257. ctrl |= ( INTEL_CTRL_SLU | INTEL_CTRL_ASDE );
  258. ctrl &= ~( INTEL_CTRL_LRST | INTEL_CTRL_FRCSPD | INTEL_CTRL_FRCDPLX );
  259. writel ( ctrl, intel->regs + INTEL_CTRL );
  260. mdelay ( INTEL_RESET_DELAY_MS );
  261. /* On some models (notably ICH), the PHY reset mechanism
  262. * appears to be broken. In particular, the PHY_CTRL register
  263. * will be correctly loaded from NVM but the values will not
  264. * be propagated to the "OEM bits" PHY register. This
  265. * typically has the effect of dropping the link speed to
  266. * 10Mbps.
  267. *
  268. * Work around this problem by skipping the PHY reset if
  269. * either (a) the link is already up, or (b) this particular
  270. * NIC is known to be broken.
  271. */
  272. status = readl ( intel->regs + INTEL_STATUS );
  273. if ( ( intel->flags & INTEL_NO_PHY_RST ) ||
  274. ( status & INTEL_STATUS_LU ) ) {
  275. DBGC ( intel, "INTEL %p %sMAC reset (ctrl %08x)\n", intel,
  276. ( ( intel->flags & INTEL_NO_PHY_RST ) ? "forced " : "" ),
  277. ctrl );
  278. return 0;
  279. }
  280. /* Reset PHY and MAC simultaneously */
  281. writel ( ( ctrl | INTEL_CTRL_RST | INTEL_CTRL_PHY_RST ),
  282. intel->regs + INTEL_CTRL );
  283. mdelay ( INTEL_RESET_DELAY_MS );
  284. /* PHY reset is not self-clearing on all models */
  285. writel ( ctrl, intel->regs + INTEL_CTRL );
  286. mdelay ( INTEL_RESET_DELAY_MS );
  287. DBGC ( intel, "INTEL %p MAC+PHY reset (ctrl %08x)\n", intel, ctrl );
  288. return 0;
  289. }
  290. /******************************************************************************
  291. *
  292. * Link state
  293. *
  294. ******************************************************************************
  295. */
  296. /**
  297. * Check link state
  298. *
  299. * @v netdev Network device
  300. */
  301. static void intel_check_link ( struct net_device *netdev ) {
  302. struct intel_nic *intel = netdev->priv;
  303. uint32_t status;
  304. /* Read link status */
  305. status = readl ( intel->regs + INTEL_STATUS );
  306. DBGC ( intel, "INTEL %p link status is %08x\n", intel, status );
  307. /* Update network device */
  308. if ( status & INTEL_STATUS_LU ) {
  309. netdev_link_up ( netdev );
  310. } else {
  311. netdev_link_down ( netdev );
  312. }
  313. }
  314. /******************************************************************************
  315. *
  316. * Descriptors
  317. *
  318. ******************************************************************************
  319. */
  320. /**
  321. * Populate transmit descriptor
  322. *
  323. * @v tx Transmit descriptor
  324. * @v addr Data buffer address
  325. * @v len Length of data
  326. */
  327. void intel_describe_tx ( struct intel_descriptor *tx, physaddr_t addr,
  328. size_t len ) {
  329. /* Populate transmit descriptor */
  330. tx->address = cpu_to_le64 ( addr );
  331. tx->length = cpu_to_le16 ( len );
  332. tx->flags = 0;
  333. tx->command = ( INTEL_DESC_CMD_RS | INTEL_DESC_CMD_IFCS |
  334. INTEL_DESC_CMD_EOP );
  335. tx->status = 0;
  336. }
  337. /**
  338. * Populate advanced transmit descriptor
  339. *
  340. * @v tx Transmit descriptor
  341. * @v addr Data buffer address
  342. * @v len Length of data
  343. */
  344. void intel_describe_tx_adv ( struct intel_descriptor *tx, physaddr_t addr,
  345. size_t len ) {
  346. /* Populate advanced transmit descriptor */
  347. tx->address = cpu_to_le64 ( addr );
  348. tx->length = cpu_to_le16 ( len );
  349. tx->flags = INTEL_DESC_FL_DTYP_DATA;
  350. tx->command = ( INTEL_DESC_CMD_DEXT | INTEL_DESC_CMD_RS |
  351. INTEL_DESC_CMD_IFCS | INTEL_DESC_CMD_EOP );
  352. tx->status = cpu_to_le32 ( INTEL_DESC_STATUS_PAYLEN ( len ) );
  353. }
  354. /**
  355. * Populate receive descriptor
  356. *
  357. * @v rx Receive descriptor
  358. * @v addr Data buffer address
  359. * @v len Length of data
  360. */
  361. void intel_describe_rx ( struct intel_descriptor *rx, physaddr_t addr,
  362. size_t len __unused ) {
  363. /* Populate transmit descriptor */
  364. rx->address = cpu_to_le64 ( addr );
  365. rx->length = 0;
  366. rx->status = 0;
  367. }
  368. /******************************************************************************
  369. *
  370. * Network device interface
  371. *
  372. ******************************************************************************
  373. */
  374. /**
  375. * Create descriptor ring
  376. *
  377. * @v intel Intel device
  378. * @v ring Descriptor ring
  379. * @ret rc Return status code
  380. */
  381. int intel_create_ring ( struct intel_nic *intel, struct intel_ring *ring ) {
  382. physaddr_t address;
  383. uint32_t dctl;
  384. /* Allocate descriptor ring. Align ring on its own size to
  385. * prevent any possible page-crossing errors due to hardware
  386. * errata.
  387. */
  388. ring->desc = malloc_dma ( ring->len, ring->len );
  389. if ( ! ring->desc )
  390. return -ENOMEM;
  391. /* Initialise descriptor ring */
  392. memset ( ring->desc, 0, ring->len );
  393. /* Program ring address */
  394. address = virt_to_bus ( ring->desc );
  395. writel ( ( address & 0xffffffffUL ),
  396. ( intel->regs + ring->reg + INTEL_xDBAL ) );
  397. if ( sizeof ( physaddr_t ) > sizeof ( uint32_t ) ) {
  398. writel ( ( ( ( uint64_t ) address ) >> 32 ),
  399. ( intel->regs + ring->reg + INTEL_xDBAH ) );
  400. } else {
  401. writel ( 0, intel->regs + ring->reg + INTEL_xDBAH );
  402. }
  403. /* Program ring length */
  404. writel ( ring->len, ( intel->regs + ring->reg + INTEL_xDLEN ) );
  405. /* Reset head and tail pointers */
  406. writel ( 0, ( intel->regs + ring->reg + INTEL_xDH ) );
  407. writel ( 0, ( intel->regs + ring->reg + INTEL_xDT ) );
  408. /* Enable ring */
  409. dctl = readl ( intel->regs + ring->reg + INTEL_xDCTL );
  410. dctl |= INTEL_xDCTL_ENABLE;
  411. writel ( dctl, intel->regs + ring->reg + INTEL_xDCTL );
  412. DBGC ( intel, "INTEL %p ring %05x is at [%08llx,%08llx)\n",
  413. intel, ring->reg, ( ( unsigned long long ) address ),
  414. ( ( unsigned long long ) address + ring->len ) );
  415. return 0;
  416. }
  417. /**
  418. * Destroy descriptor ring
  419. *
  420. * @v intel Intel device
  421. * @v ring Descriptor ring
  422. */
  423. void intel_destroy_ring ( struct intel_nic *intel, struct intel_ring *ring ) {
  424. /* Clear ring length */
  425. writel ( 0, ( intel->regs + ring->reg + INTEL_xDLEN ) );
  426. /* Clear ring address */
  427. writel ( 0, ( intel->regs + ring->reg + INTEL_xDBAL ) );
  428. writel ( 0, ( intel->regs + ring->reg + INTEL_xDBAH ) );
  429. /* Free descriptor ring */
  430. free_dma ( ring->desc, ring->len );
  431. ring->desc = NULL;
  432. ring->prod = 0;
  433. ring->cons = 0;
  434. }
  435. /**
  436. * Refill receive descriptor ring
  437. *
  438. * @v intel Intel device
  439. */
  440. void intel_refill_rx ( struct intel_nic *intel ) {
  441. struct intel_descriptor *rx;
  442. struct io_buffer *iobuf;
  443. unsigned int rx_idx;
  444. unsigned int rx_tail;
  445. physaddr_t address;
  446. unsigned int refilled = 0;
  447. /* Refill ring */
  448. while ( ( intel->rx.prod - intel->rx.cons ) < INTEL_RX_FILL ) {
  449. /* Allocate I/O buffer */
  450. iobuf = alloc_iob ( INTEL_RX_MAX_LEN );
  451. if ( ! iobuf ) {
  452. /* Wait for next refill */
  453. break;
  454. }
  455. /* Get next receive descriptor */
  456. rx_idx = ( intel->rx.prod++ % INTEL_NUM_RX_DESC );
  457. rx = &intel->rx.desc[rx_idx];
  458. /* Populate receive descriptor */
  459. address = virt_to_bus ( iobuf->data );
  460. intel->rx.describe ( rx, address, 0 );
  461. /* Record I/O buffer */
  462. assert ( intel->rx_iobuf[rx_idx] == NULL );
  463. intel->rx_iobuf[rx_idx] = iobuf;
  464. DBGC2 ( intel, "INTEL %p RX %d is [%llx,%llx)\n", intel, rx_idx,
  465. ( ( unsigned long long ) address ),
  466. ( ( unsigned long long ) address + INTEL_RX_MAX_LEN ) );
  467. refilled++;
  468. }
  469. /* Push descriptors to card, if applicable */
  470. if ( refilled ) {
  471. wmb();
  472. rx_tail = ( intel->rx.prod % INTEL_NUM_RX_DESC );
  473. profile_start ( &intel_vm_refill_profiler );
  474. writel ( rx_tail, intel->regs + intel->rx.reg + INTEL_xDT );
  475. profile_stop ( &intel_vm_refill_profiler );
  476. profile_exclude ( &intel_vm_refill_profiler );
  477. }
  478. }
  479. /**
  480. * Discard unused receive I/O buffers
  481. *
  482. * @v intel Intel device
  483. */
  484. void intel_empty_rx ( struct intel_nic *intel ) {
  485. unsigned int i;
  486. for ( i = 0 ; i < INTEL_NUM_RX_DESC ; i++ ) {
  487. if ( intel->rx_iobuf[i] )
  488. free_iob ( intel->rx_iobuf[i] );
  489. intel->rx_iobuf[i] = NULL;
  490. }
  491. }
  492. /**
  493. * Open network device
  494. *
  495. * @v netdev Network device
  496. * @ret rc Return status code
  497. */
  498. static int intel_open ( struct net_device *netdev ) {
  499. struct intel_nic *intel = netdev->priv;
  500. union intel_receive_address mac;
  501. uint32_t tctl;
  502. uint32_t rctl;
  503. int rc;
  504. /* Create transmit descriptor ring */
  505. if ( ( rc = intel_create_ring ( intel, &intel->tx ) ) != 0 )
  506. goto err_create_tx;
  507. /* Create receive descriptor ring */
  508. if ( ( rc = intel_create_ring ( intel, &intel->rx ) ) != 0 )
  509. goto err_create_rx;
  510. /* Program MAC address */
  511. memset ( &mac, 0, sizeof ( mac ) );
  512. memcpy ( mac.raw, netdev->ll_addr, sizeof ( mac.raw ) );
  513. writel ( le32_to_cpu ( mac.reg.low ), intel->regs + INTEL_RAL0 );
  514. writel ( ( le32_to_cpu ( mac.reg.high ) | INTEL_RAH0_AV ),
  515. intel->regs + INTEL_RAH0 );
  516. /* Enable transmitter */
  517. tctl = readl ( intel->regs + INTEL_TCTL );
  518. tctl &= ~( INTEL_TCTL_CT_MASK | INTEL_TCTL_COLD_MASK );
  519. tctl |= ( INTEL_TCTL_EN | INTEL_TCTL_PSP | INTEL_TCTL_CT_DEFAULT |
  520. INTEL_TCTL_COLD_DEFAULT );
  521. writel ( tctl, intel->regs + INTEL_TCTL );
  522. /* Enable receiver */
  523. rctl = readl ( intel->regs + INTEL_RCTL );
  524. rctl &= ~( INTEL_RCTL_BSIZE_BSEX_MASK );
  525. rctl |= ( INTEL_RCTL_EN | INTEL_RCTL_UPE | INTEL_RCTL_MPE |
  526. INTEL_RCTL_BAM | INTEL_RCTL_BSIZE_2048 | INTEL_RCTL_SECRC );
  527. writel ( rctl, intel->regs + INTEL_RCTL );
  528. /* Fill receive ring */
  529. intel_refill_rx ( intel );
  530. /* Update link state */
  531. intel_check_link ( netdev );
  532. /* Apply required errata */
  533. if ( intel->flags & INTEL_VMWARE ) {
  534. DBGC ( intel, "INTEL %p applying VMware errata workaround\n",
  535. intel );
  536. intel->force_icr = INTEL_IRQ_RXT0;
  537. }
  538. return 0;
  539. intel_destroy_ring ( intel, &intel->rx );
  540. err_create_rx:
  541. intel_destroy_ring ( intel, &intel->tx );
  542. err_create_tx:
  543. return rc;
  544. }
  545. /**
  546. * Close network device
  547. *
  548. * @v netdev Network device
  549. */
  550. static void intel_close ( struct net_device *netdev ) {
  551. struct intel_nic *intel = netdev->priv;
  552. /* Disable receiver */
  553. writel ( 0, intel->regs + INTEL_RCTL );
  554. /* Disable transmitter */
  555. writel ( 0, intel->regs + INTEL_TCTL );
  556. /* Destroy receive descriptor ring */
  557. intel_destroy_ring ( intel, &intel->rx );
  558. /* Discard any unused receive buffers */
  559. intel_empty_rx ( intel );
  560. /* Destroy transmit descriptor ring */
  561. intel_destroy_ring ( intel, &intel->tx );
  562. /* Reset the NIC, to flush the transmit and receive FIFOs */
  563. intel_reset ( intel );
  564. }
  565. /**
  566. * Transmit packet
  567. *
  568. * @v netdev Network device
  569. * @v iobuf I/O buffer
  570. * @ret rc Return status code
  571. */
  572. int intel_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) {
  573. struct intel_nic *intel = netdev->priv;
  574. struct intel_descriptor *tx;
  575. unsigned int tx_idx;
  576. unsigned int tx_tail;
  577. physaddr_t address;
  578. size_t len;
  579. /* Get next transmit descriptor */
  580. if ( ( intel->tx.prod - intel->tx.cons ) >= INTEL_TX_FILL ) {
  581. DBGC ( intel, "INTEL %p out of transmit descriptors\n", intel );
  582. return -ENOBUFS;
  583. }
  584. tx_idx = ( intel->tx.prod++ % INTEL_NUM_TX_DESC );
  585. tx_tail = ( intel->tx.prod % INTEL_NUM_TX_DESC );
  586. tx = &intel->tx.desc[tx_idx];
  587. /* Populate transmit descriptor */
  588. address = virt_to_bus ( iobuf->data );
  589. len = iob_len ( iobuf );
  590. intel->tx.describe ( tx, address, len );
  591. wmb();
  592. /* Notify card that there are packets ready to transmit */
  593. profile_start ( &intel_vm_tx_profiler );
  594. writel ( tx_tail, intel->regs + intel->tx.reg + INTEL_xDT );
  595. profile_stop ( &intel_vm_tx_profiler );
  596. profile_exclude ( &intel_vm_tx_profiler );
  597. DBGC2 ( intel, "INTEL %p TX %d is [%llx,%llx)\n", intel, tx_idx,
  598. ( ( unsigned long long ) address ),
  599. ( ( unsigned long long ) address + len ) );
  600. return 0;
  601. }
  602. /**
  603. * Poll for completed packets
  604. *
  605. * @v netdev Network device
  606. */
  607. void intel_poll_tx ( struct net_device *netdev ) {
  608. struct intel_nic *intel = netdev->priv;
  609. struct intel_descriptor *tx;
  610. unsigned int tx_idx;
  611. /* Check for completed packets */
  612. while ( intel->tx.cons != intel->tx.prod ) {
  613. /* Get next transmit descriptor */
  614. tx_idx = ( intel->tx.cons % INTEL_NUM_TX_DESC );
  615. tx = &intel->tx.desc[tx_idx];
  616. /* Stop if descriptor is still in use */
  617. if ( ! ( tx->status & cpu_to_le32 ( INTEL_DESC_STATUS_DD ) ) )
  618. return;
  619. DBGC2 ( intel, "INTEL %p TX %d complete\n", intel, tx_idx );
  620. /* Complete TX descriptor */
  621. netdev_tx_complete_next ( netdev );
  622. intel->tx.cons++;
  623. }
  624. }
  625. /**
  626. * Poll for received packets
  627. *
  628. * @v netdev Network device
  629. */
  630. void intel_poll_rx ( struct net_device *netdev ) {
  631. struct intel_nic *intel = netdev->priv;
  632. struct intel_descriptor *rx;
  633. struct io_buffer *iobuf;
  634. unsigned int rx_idx;
  635. size_t len;
  636. /* Check for received packets */
  637. while ( intel->rx.cons != intel->rx.prod ) {
  638. /* Get next receive descriptor */
  639. rx_idx = ( intel->rx.cons % INTEL_NUM_RX_DESC );
  640. rx = &intel->rx.desc[rx_idx];
  641. /* Stop if descriptor is still in use */
  642. if ( ! ( rx->status & cpu_to_le32 ( INTEL_DESC_STATUS_DD ) ) )
  643. return;
  644. /* Populate I/O buffer */
  645. iobuf = intel->rx_iobuf[rx_idx];
  646. intel->rx_iobuf[rx_idx] = NULL;
  647. len = le16_to_cpu ( rx->length );
  648. iob_put ( iobuf, len );
  649. /* Hand off to network stack */
  650. if ( rx->status & cpu_to_le32 ( INTEL_DESC_STATUS_RXE ) ) {
  651. DBGC ( intel, "INTEL %p RX %d error (length %zd, "
  652. "status %08x)\n", intel, rx_idx, len,
  653. le32_to_cpu ( rx->status ) );
  654. netdev_rx_err ( netdev, iobuf, -EIO );
  655. } else {
  656. DBGC2 ( intel, "INTEL %p RX %d complete (length %zd)\n",
  657. intel, rx_idx, len );
  658. netdev_rx ( netdev, iobuf );
  659. }
  660. intel->rx.cons++;
  661. }
  662. }
  663. /**
  664. * Poll for completed and received packets
  665. *
  666. * @v netdev Network device
  667. */
  668. static void intel_poll ( struct net_device *netdev ) {
  669. struct intel_nic *intel = netdev->priv;
  670. uint32_t icr;
  671. /* Check for and acknowledge interrupts */
  672. profile_start ( &intel_vm_poll_profiler );
  673. icr = readl ( intel->regs + INTEL_ICR );
  674. profile_stop ( &intel_vm_poll_profiler );
  675. profile_exclude ( &intel_vm_poll_profiler );
  676. icr |= intel->force_icr;
  677. if ( ! icr )
  678. return;
  679. /* Poll for TX completions, if applicable */
  680. if ( icr & INTEL_IRQ_TXDW )
  681. intel_poll_tx ( netdev );
  682. /* Poll for RX completions, if applicable */
  683. if ( icr & ( INTEL_IRQ_RXT0 | INTEL_IRQ_RXO ) )
  684. intel_poll_rx ( netdev );
  685. /* Report receive overruns */
  686. if ( icr & INTEL_IRQ_RXO )
  687. netdev_rx_err ( netdev, NULL, -ENOBUFS );
  688. /* Check link state, if applicable */
  689. if ( icr & INTEL_IRQ_LSC )
  690. intel_check_link ( netdev );
  691. /* Check for unexpected interrupts */
  692. if ( icr & ~( INTEL_IRQ_TXDW | INTEL_IRQ_TXQE | INTEL_IRQ_LSC |
  693. INTEL_IRQ_RXDMT0 | INTEL_IRQ_RXT0 | INTEL_IRQ_RXO ) ) {
  694. DBGC ( intel, "INTEL %p unexpected ICR %08x\n", intel, icr );
  695. /* Report as a TX error */
  696. netdev_tx_err ( netdev, NULL, -ENOTSUP );
  697. }
  698. /* Refill RX ring */
  699. intel_refill_rx ( intel );
  700. }
  701. /**
  702. * Enable or disable interrupts
  703. *
  704. * @v netdev Network device
  705. * @v enable Interrupts should be enabled
  706. */
  707. static void intel_irq ( struct net_device *netdev, int enable ) {
  708. struct intel_nic *intel = netdev->priv;
  709. uint32_t mask;
  710. mask = ( INTEL_IRQ_TXDW | INTEL_IRQ_LSC | INTEL_IRQ_RXT0 );
  711. if ( enable ) {
  712. writel ( mask, intel->regs + INTEL_IMS );
  713. } else {
  714. writel ( mask, intel->regs + INTEL_IMC );
  715. }
  716. }
  717. /** Intel network device operations */
  718. static struct net_device_operations intel_operations = {
  719. .open = intel_open,
  720. .close = intel_close,
  721. .transmit = intel_transmit,
  722. .poll = intel_poll,
  723. .irq = intel_irq,
  724. };
  725. /******************************************************************************
  726. *
  727. * PCI interface
  728. *
  729. ******************************************************************************
  730. */
  731. /**
  732. * Probe PCI device
  733. *
  734. * @v pci PCI device
  735. * @ret rc Return status code
  736. */
  737. static int intel_probe ( struct pci_device *pci ) {
  738. struct net_device *netdev;
  739. struct intel_nic *intel;
  740. int rc;
  741. /* Allocate and initialise net device */
  742. netdev = alloc_etherdev ( sizeof ( *intel ) );
  743. if ( ! netdev ) {
  744. rc = -ENOMEM;
  745. goto err_alloc;
  746. }
  747. netdev_init ( netdev, &intel_operations );
  748. intel = netdev->priv;
  749. pci_set_drvdata ( pci, netdev );
  750. netdev->dev = &pci->dev;
  751. memset ( intel, 0, sizeof ( *intel ) );
  752. intel->port = PCI_FUNC ( pci->busdevfn );
  753. intel->flags = pci->id->driver_data;
  754. intel_init_ring ( &intel->tx, INTEL_NUM_TX_DESC, INTEL_TD,
  755. intel_describe_tx );
  756. intel_init_ring ( &intel->rx, INTEL_NUM_RX_DESC, INTEL_RD,
  757. intel_describe_rx );
  758. /* Fix up PCI device */
  759. adjust_pci_device ( pci );
  760. /* Map registers */
  761. intel->regs = ioremap ( pci->membase, INTEL_BAR_SIZE );
  762. if ( ! intel->regs ) {
  763. rc = -ENODEV;
  764. goto err_ioremap;
  765. }
  766. /* Reset the NIC */
  767. if ( ( rc = intel_reset ( intel ) ) != 0 )
  768. goto err_reset;
  769. /* Fetch MAC address */
  770. if ( ( rc = intel_fetch_mac ( intel, netdev->hw_addr ) ) != 0 )
  771. goto err_fetch_mac;
  772. /* Register network device */
  773. if ( ( rc = register_netdev ( netdev ) ) != 0 )
  774. goto err_register_netdev;
  775. /* Set initial link state */
  776. intel_check_link ( netdev );
  777. return 0;
  778. unregister_netdev ( netdev );
  779. err_register_netdev:
  780. err_fetch_mac:
  781. intel_reset ( intel );
  782. err_reset:
  783. iounmap ( intel->regs );
  784. err_ioremap:
  785. netdev_nullify ( netdev );
  786. netdev_put ( netdev );
  787. err_alloc:
  788. return rc;
  789. }
  790. /**
  791. * Remove PCI device
  792. *
  793. * @v pci PCI device
  794. */
  795. static void intel_remove ( struct pci_device *pci ) {
  796. struct net_device *netdev = pci_get_drvdata ( pci );
  797. struct intel_nic *intel = netdev->priv;
  798. /* Unregister network device */
  799. unregister_netdev ( netdev );
  800. /* Reset the NIC */
  801. intel_reset ( intel );
  802. /* Free network device */
  803. iounmap ( intel->regs );
  804. netdev_nullify ( netdev );
  805. netdev_put ( netdev );
  806. }
  807. /** Intel PCI device IDs */
  808. static struct pci_device_id intel_nics[] = {
  809. PCI_ROM ( 0x8086, 0x0438, "dh8900cc", "DH8900CC", 0 ),
  810. PCI_ROM ( 0x8086, 0x043a, "dh8900cc-f", "DH8900CC Fiber", 0 ),
  811. PCI_ROM ( 0x8086, 0x043c, "dh8900cc-b", "DH8900CC Backplane", 0 ),
  812. PCI_ROM ( 0x8086, 0x0440, "dh8900cc-s", "DH8900CC SFP", 0 ),
  813. PCI_ROM ( 0x8086, 0x1000, "82542-f", "82542 (Fiber)", 0 ),
  814. PCI_ROM ( 0x8086, 0x1001, "82543gc-f", "82543GC (Fiber)", 0 ),
  815. PCI_ROM ( 0x8086, 0x1004, "82543gc", "82543GC (Copper)", 0 ),
  816. PCI_ROM ( 0x8086, 0x1008, "82544ei", "82544EI (Copper)", 0 ),
  817. PCI_ROM ( 0x8086, 0x1009, "82544ei-f", "82544EI (Fiber)", 0 ),
  818. PCI_ROM ( 0x8086, 0x100c, "82544gc", "82544GC (Copper)", 0 ),
  819. PCI_ROM ( 0x8086, 0x100d, "82544gc-l", "82544GC (LOM)", 0 ),
  820. PCI_ROM ( 0x8086, 0x100e, "82540em", "82540EM", 0 ),
  821. PCI_ROM ( 0x8086, 0x100f, "82545em", "82545EM (Copper)", INTEL_VMWARE ),
  822. PCI_ROM ( 0x8086, 0x1010, "82546eb", "82546EB (Copper)", 0 ),
  823. PCI_ROM ( 0x8086, 0x1011, "82545em-f", "82545EM (Fiber)", 0 ),
  824. PCI_ROM ( 0x8086, 0x1012, "82546eb-f", "82546EB (Fiber)", 0 ),
  825. PCI_ROM ( 0x8086, 0x1013, "82541ei", "82541EI", 0 ),
  826. PCI_ROM ( 0x8086, 0x1014, "82541er", "82541ER", 0 ),
  827. PCI_ROM ( 0x8086, 0x1015, "82540em-l", "82540EM (LOM)", 0 ),
  828. PCI_ROM ( 0x8086, 0x1016, "82540ep-m", "82540EP (Mobile)", 0 ),
  829. PCI_ROM ( 0x8086, 0x1017, "82540ep", "82540EP", 0 ),
  830. PCI_ROM ( 0x8086, 0x1018, "82541ei", "82541EI", 0 ),
  831. PCI_ROM ( 0x8086, 0x1019, "82547ei", "82547EI", 0 ),
  832. PCI_ROM ( 0x8086, 0x101a, "82547ei-m", "82547EI (Mobile)", 0 ),
  833. PCI_ROM ( 0x8086, 0x101d, "82546eb", "82546EB", 0 ),
  834. PCI_ROM ( 0x8086, 0x101e, "82540ep-m", "82540EP (Mobile)", 0 ),
  835. PCI_ROM ( 0x8086, 0x1026, "82545gm", "82545GM", 0 ),
  836. PCI_ROM ( 0x8086, 0x1027, "82545gm-1", "82545GM", 0 ),
  837. PCI_ROM ( 0x8086, 0x1028, "82545gm-2", "82545GM", 0 ),
  838. PCI_ROM ( 0x8086, 0x1049, "82566mm", "82566MM", INTEL_PBS_ERRATA ),
  839. PCI_ROM ( 0x8086, 0x104a, "82566dm", "82566DM", INTEL_PBS_ERRATA ),
  840. PCI_ROM ( 0x8086, 0x104b, "82566dc", "82566DC", INTEL_PBS_ERRATA ),
  841. PCI_ROM ( 0x8086, 0x104c, "82562v", "82562V", INTEL_PBS_ERRATA ),
  842. PCI_ROM ( 0x8086, 0x104d, "82566mc", "82566MC", INTEL_PBS_ERRATA ),
  843. PCI_ROM ( 0x8086, 0x105e, "82571eb", "82571EB", 0 ),
  844. PCI_ROM ( 0x8086, 0x105f, "82571eb-1", "82571EB", 0 ),
  845. PCI_ROM ( 0x8086, 0x1060, "82571eb-2", "82571EB", 0 ),
  846. PCI_ROM ( 0x8086, 0x1075, "82547gi", "82547GI", 0 ),
  847. PCI_ROM ( 0x8086, 0x1076, "82541gi", "82541GI", 0 ),
  848. PCI_ROM ( 0x8086, 0x1077, "82541gi-1", "82541GI", 0 ),
  849. PCI_ROM ( 0x8086, 0x1078, "82541er", "82541ER", 0 ),
  850. PCI_ROM ( 0x8086, 0x1079, "82546gb", "82546GB", 0 ),
  851. PCI_ROM ( 0x8086, 0x107a, "82546gb-1", "82546GB", 0 ),
  852. PCI_ROM ( 0x8086, 0x107b, "82546gb-2", "82546GB", 0 ),
  853. PCI_ROM ( 0x8086, 0x107c, "82541pi", "82541PI", 0 ),
  854. PCI_ROM ( 0x8086, 0x107d, "82572ei", "82572EI (Copper)", 0 ),
  855. PCI_ROM ( 0x8086, 0x107e, "82572ei-f", "82572EI (Fiber)", 0 ),
  856. PCI_ROM ( 0x8086, 0x107f, "82572ei", "82572EI", 0 ),
  857. PCI_ROM ( 0x8086, 0x108a, "82546gb-3", "82546GB", 0 ),
  858. PCI_ROM ( 0x8086, 0x108b, "82573v", "82573V (Copper)", 0 ),
  859. PCI_ROM ( 0x8086, 0x108c, "82573e", "82573E (Copper)", 0 ),
  860. PCI_ROM ( 0x8086, 0x1096, "80003es2lan", "80003ES2LAN (Copper)", 0 ),
  861. PCI_ROM ( 0x8086, 0x1098, "80003es2lan-s", "80003ES2LAN (Serdes)", 0 ),
  862. PCI_ROM ( 0x8086, 0x1099, "82546gb-4", "82546GB (Copper)", 0 ),
  863. PCI_ROM ( 0x8086, 0x109a, "82573l", "82573L", 0 ),
  864. PCI_ROM ( 0x8086, 0x10a4, "82571eb", "82571EB", 0 ),
  865. PCI_ROM ( 0x8086, 0x10a5, "82571eb", "82571EB (Fiber)", 0 ),
  866. PCI_ROM ( 0x8086, 0x10a7, "82575eb", "82575EB", 0 ),
  867. PCI_ROM ( 0x8086, 0x10a9, "82575eb", "82575EB Backplane", 0 ),
  868. PCI_ROM ( 0x8086, 0x10b5, "82546gb", "82546GB (Copper)", 0 ),
  869. PCI_ROM ( 0x8086, 0x10b9, "82572ei", "82572EI (Copper)", 0 ),
  870. PCI_ROM ( 0x8086, 0x10ba, "80003es2lan", "80003ES2LAN (Copper)", 0 ),
  871. PCI_ROM ( 0x8086, 0x10bb, "80003es2lan", "80003ES2LAN (Serdes)", 0 ),
  872. PCI_ROM ( 0x8086, 0x10bc, "82571eb", "82571EB (Copper)", 0 ),
  873. PCI_ROM ( 0x8086, 0x10bd, "82566dm-2", "82566DM-2", 0 ),
  874. PCI_ROM ( 0x8086, 0x10bf, "82567lf", "82567LF", 0 ),
  875. PCI_ROM ( 0x8086, 0x10c0, "82562v-2", "82562V-2", 0 ),
  876. PCI_ROM ( 0x8086, 0x10c2, "82562g-2", "82562G-2", 0 ),
  877. PCI_ROM ( 0x8086, 0x10c3, "82562gt-2", "82562GT-2", 0 ),
  878. PCI_ROM ( 0x8086, 0x10c4, "82562gt", "82562GT", INTEL_PBS_ERRATA ),
  879. PCI_ROM ( 0x8086, 0x10c5, "82562g", "82562G", INTEL_PBS_ERRATA ),
  880. PCI_ROM ( 0x8086, 0x10c9, "82576", "82576", 0 ),
  881. PCI_ROM ( 0x8086, 0x10cb, "82567v", "82567V", 0 ),
  882. PCI_ROM ( 0x8086, 0x10cc, "82567lm-2", "82567LM-2", 0 ),
  883. PCI_ROM ( 0x8086, 0x10cd, "82567lf-2", "82567LF-2", 0 ),
  884. PCI_ROM ( 0x8086, 0x10ce, "82567v-2", "82567V-2", 0 ),
  885. PCI_ROM ( 0x8086, 0x10d3, "82574l", "82574L", 0 ),
  886. PCI_ROM ( 0x8086, 0x10d5, "82571pt", "82571PT PT Quad", 0 ),
  887. PCI_ROM ( 0x8086, 0x10d6, "82575gb", "82575GB", 0 ),
  888. PCI_ROM ( 0x8086, 0x10d9, "82571eb-d", "82571EB Dual Mezzanine", 0 ),
  889. PCI_ROM ( 0x8086, 0x10da, "82571eb-q", "82571EB Quad Mezzanine", 0 ),
  890. PCI_ROM ( 0x8086, 0x10de, "82567lm-3", "82567LM-3", 0 ),
  891. PCI_ROM ( 0x8086, 0x10df, "82567lf-3", "82567LF-3", 0 ),
  892. PCI_ROM ( 0x8086, 0x10e5, "82567lm-4", "82567LM-4", 0 ),
  893. PCI_ROM ( 0x8086, 0x10e6, "82576", "82576", 0 ),
  894. PCI_ROM ( 0x8086, 0x10e7, "82576-2", "82576", 0 ),
  895. PCI_ROM ( 0x8086, 0x10e8, "82576-3", "82576", 0 ),
  896. PCI_ROM ( 0x8086, 0x10ea, "82577lm", "82577LM", 0 ),
  897. PCI_ROM ( 0x8086, 0x10eb, "82577lc", "82577LC", 0 ),
  898. PCI_ROM ( 0x8086, 0x10ef, "82578dm", "82578DM", 0 ),
  899. PCI_ROM ( 0x8086, 0x10f0, "82578dc", "82578DC", 0 ),
  900. PCI_ROM ( 0x8086, 0x10f5, "82567lm", "82567LM", 0 ),
  901. PCI_ROM ( 0x8086, 0x10f6, "82574l", "82574L", 0 ),
  902. PCI_ROM ( 0x8086, 0x1501, "82567v-3", "82567V-3", INTEL_PBS_ERRATA ),
  903. PCI_ROM ( 0x8086, 0x1502, "82579lm", "82579LM", INTEL_NO_PHY_RST ),
  904. PCI_ROM ( 0x8086, 0x1503, "82579v", "82579V", 0 ),
  905. PCI_ROM ( 0x8086, 0x150a, "82576ns", "82576NS", 0 ),
  906. PCI_ROM ( 0x8086, 0x150c, "82583v", "82583V", 0 ),
  907. PCI_ROM ( 0x8086, 0x150d, "82576-4", "82576 Backplane", 0 ),
  908. PCI_ROM ( 0x8086, 0x150e, "82580", "82580", 0 ),
  909. PCI_ROM ( 0x8086, 0x150f, "82580-f", "82580 Fiber", 0 ),
  910. PCI_ROM ( 0x8086, 0x1510, "82580-b", "82580 Backplane", 0 ),
  911. PCI_ROM ( 0x8086, 0x1511, "82580-s", "82580 SFP", 0 ),
  912. PCI_ROM ( 0x8086, 0x1516, "82580-2", "82580", 0 ),
  913. PCI_ROM ( 0x8086, 0x1518, "82576ns", "82576NS SerDes", 0 ),
  914. PCI_ROM ( 0x8086, 0x1521, "i350", "I350", 0 ),
  915. PCI_ROM ( 0x8086, 0x1522, "i350-f", "I350 Fiber", 0 ),
  916. PCI_ROM ( 0x8086, 0x1523, "i350-b", "I350 Backplane", 0 ),
  917. PCI_ROM ( 0x8086, 0x1524, "i350-2", "I350", 0 ),
  918. PCI_ROM ( 0x8086, 0x1525, "82567v-4", "82567V-4", 0 ),
  919. PCI_ROM ( 0x8086, 0x1526, "82576-5", "82576", 0 ),
  920. PCI_ROM ( 0x8086, 0x1527, "82580-f2", "82580 Fiber", 0 ),
  921. PCI_ROM ( 0x8086, 0x1533, "i210", "I210", 0 ),
  922. PCI_ROM ( 0x8086, 0x1539, "i211", "I211", 0 ),
  923. PCI_ROM ( 0x8086, 0x153a, "i217lm", "I217-LM", INTEL_NO_PHY_RST ),
  924. PCI_ROM ( 0x8086, 0x153b, "i217v", "I217-V", 0 ),
  925. PCI_ROM ( 0x8086, 0x1559, "i218v", "I218-V", 0),
  926. PCI_ROM ( 0x8086, 0x155a, "i218lm", "I218-LM", 0),
  927. PCI_ROM ( 0x8086, 0x156f, "i219lm", "I219-LM", 0 ),
  928. PCI_ROM ( 0x8086, 0x1570, "i219v", "I219-V", 0 ),
  929. PCI_ROM ( 0x8086, 0x157b, "i210-2", "I210", 0 ),
  930. PCI_ROM ( 0x8086, 0x15a0, "i218lm-2", "I218-LM", INTEL_NO_PHY_RST ),
  931. PCI_ROM ( 0x8086, 0x15a1, "i218v-2", "I218-V", 0 ),
  932. PCI_ROM ( 0x8086, 0x15a2, "i218lm-3", "I218-LM", INTEL_NO_PHY_RST ),
  933. PCI_ROM ( 0x8086, 0x15a3, "i218v-3", "I218-V", INTEL_NO_PHY_RST ),
  934. PCI_ROM ( 0x8086, 0x15b7, "i219lm-2", "I219-LM (2)", INTEL_NO_PHY_RST ),
  935. PCI_ROM ( 0x8086, 0x15b8, "i219v-2", "I219-V (2)", 0 ),
  936. PCI_ROM ( 0x8086, 0x294c, "82566dc-2", "82566DC-2", 0 ),
  937. PCI_ROM ( 0x8086, 0x2e6e, "cemedia", "CE Media Processor", 0 ),
  938. };
  939. /** Intel PCI driver */
  940. struct pci_driver intel_driver __pci_driver = {
  941. .ids = intel_nics,
  942. .id_count = ( sizeof ( intel_nics ) / sizeof ( intel_nics[0] ) ),
  943. .probe = intel_probe,
  944. .remove = intel_remove,
  945. };