Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

intel.c 34KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143
  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. uint32_t orig_ctrl;
  239. uint32_t orig_status;
  240. /* Record initial control and status register values */
  241. orig_ctrl = ctrl = readl ( intel->regs + INTEL_CTRL );
  242. orig_status = readl ( intel->regs + INTEL_STATUS );
  243. /* Force RX and TX packet buffer allocation, to work around an
  244. * errata in ICH devices.
  245. */
  246. if ( intel->flags & INTEL_PBS_ERRATA ) {
  247. DBGC ( intel, "INTEL %p WARNING: applying ICH PBS/PBA errata\n",
  248. intel );
  249. pbs = readl ( intel->regs + INTEL_PBS );
  250. pba = readl ( intel->regs + INTEL_PBA );
  251. writel ( 0x08, intel->regs + INTEL_PBA );
  252. writel ( 0x10, intel->regs + INTEL_PBS );
  253. DBGC ( intel, "INTEL %p PBS %#08x->%#08x PBA %#08x->%#08x\n",
  254. intel, pbs, readl ( intel->regs + INTEL_PBS ),
  255. pba, readl ( intel->regs + INTEL_PBA ) );
  256. }
  257. /* Always reset MAC. Required to reset the TX and RX rings. */
  258. writel ( ( ctrl | INTEL_CTRL_RST ), intel->regs + INTEL_CTRL );
  259. mdelay ( INTEL_RESET_DELAY_MS );
  260. /* Set a sensible default configuration */
  261. ctrl |= ( INTEL_CTRL_SLU | INTEL_CTRL_ASDE );
  262. ctrl &= ~( INTEL_CTRL_LRST | INTEL_CTRL_FRCSPD | INTEL_CTRL_FRCDPLX );
  263. writel ( ctrl, intel->regs + INTEL_CTRL );
  264. mdelay ( INTEL_RESET_DELAY_MS );
  265. /* On some models (notably ICH), the PHY reset mechanism
  266. * appears to be broken. In particular, the PHY_CTRL register
  267. * will be correctly loaded from NVM but the values will not
  268. * be propagated to the "OEM bits" PHY register. This
  269. * typically has the effect of dropping the link speed to
  270. * 10Mbps.
  271. *
  272. * Work around this problem by skipping the PHY reset if
  273. * either (a) the link is already up, or (b) this particular
  274. * NIC is known to be broken.
  275. */
  276. status = readl ( intel->regs + INTEL_STATUS );
  277. if ( ( intel->flags & INTEL_NO_PHY_RST ) ||
  278. ( status & INTEL_STATUS_LU ) ) {
  279. DBGC ( intel, "INTEL %p %sMAC reset (%08x/%08x was "
  280. "%08x/%08x)\n", intel,
  281. ( ( intel->flags & INTEL_NO_PHY_RST ) ? "forced " : "" ),
  282. ctrl, status, orig_ctrl, orig_status );
  283. return 0;
  284. }
  285. /* Reset PHY and MAC simultaneously */
  286. writel ( ( ctrl | INTEL_CTRL_RST | INTEL_CTRL_PHY_RST ),
  287. intel->regs + INTEL_CTRL );
  288. mdelay ( INTEL_RESET_DELAY_MS );
  289. /* PHY reset is not self-clearing on all models */
  290. writel ( ctrl, intel->regs + INTEL_CTRL );
  291. mdelay ( INTEL_RESET_DELAY_MS );
  292. status = readl ( intel->regs + INTEL_STATUS );
  293. DBGC ( intel, "INTEL %p MAC+PHY reset (%08x/%08x was %08x/%08x)\n",
  294. intel, ctrl, status, orig_ctrl, orig_status );
  295. return 0;
  296. }
  297. /******************************************************************************
  298. *
  299. * Link state
  300. *
  301. ******************************************************************************
  302. */
  303. /**
  304. * Check link state
  305. *
  306. * @v netdev Network device
  307. */
  308. static void intel_check_link ( struct net_device *netdev ) {
  309. struct intel_nic *intel = netdev->priv;
  310. uint32_t status;
  311. /* Read link status */
  312. status = readl ( intel->regs + INTEL_STATUS );
  313. DBGC ( intel, "INTEL %p link status is %08x\n", intel, status );
  314. /* Update network device */
  315. if ( status & INTEL_STATUS_LU ) {
  316. netdev_link_up ( netdev );
  317. } else {
  318. netdev_link_down ( netdev );
  319. }
  320. }
  321. /******************************************************************************
  322. *
  323. * Descriptors
  324. *
  325. ******************************************************************************
  326. */
  327. /**
  328. * Populate transmit descriptor
  329. *
  330. * @v tx Transmit descriptor
  331. * @v addr Data buffer address
  332. * @v len Length of data
  333. */
  334. void intel_describe_tx ( struct intel_descriptor *tx, physaddr_t addr,
  335. size_t len ) {
  336. /* Populate transmit descriptor */
  337. tx->address = cpu_to_le64 ( addr );
  338. tx->length = cpu_to_le16 ( len );
  339. tx->flags = 0;
  340. tx->command = ( INTEL_DESC_CMD_RS | INTEL_DESC_CMD_IFCS |
  341. INTEL_DESC_CMD_EOP );
  342. tx->status = 0;
  343. }
  344. /**
  345. * Populate advanced transmit descriptor
  346. *
  347. * @v tx Transmit descriptor
  348. * @v addr Data buffer address
  349. * @v len Length of data
  350. */
  351. void intel_describe_tx_adv ( struct intel_descriptor *tx, physaddr_t addr,
  352. size_t len ) {
  353. /* Populate advanced transmit descriptor */
  354. tx->address = cpu_to_le64 ( addr );
  355. tx->length = cpu_to_le16 ( len );
  356. tx->flags = INTEL_DESC_FL_DTYP_DATA;
  357. tx->command = ( INTEL_DESC_CMD_DEXT | INTEL_DESC_CMD_RS |
  358. INTEL_DESC_CMD_IFCS | INTEL_DESC_CMD_EOP );
  359. tx->status = cpu_to_le32 ( INTEL_DESC_STATUS_PAYLEN ( len ) );
  360. }
  361. /**
  362. * Populate receive descriptor
  363. *
  364. * @v rx Receive descriptor
  365. * @v addr Data buffer address
  366. * @v len Length of data
  367. */
  368. void intel_describe_rx ( struct intel_descriptor *rx, physaddr_t addr,
  369. size_t len __unused ) {
  370. /* Populate transmit descriptor */
  371. rx->address = cpu_to_le64 ( addr );
  372. rx->length = 0;
  373. rx->status = 0;
  374. }
  375. /******************************************************************************
  376. *
  377. * Network device interface
  378. *
  379. ******************************************************************************
  380. */
  381. /**
  382. * Disable descriptor ring
  383. *
  384. * @v intel Intel device
  385. * @v reg Register block
  386. * @ret rc Return status code
  387. */
  388. static int intel_disable_ring ( struct intel_nic *intel, unsigned int reg ) {
  389. uint32_t dctl;
  390. unsigned int i;
  391. /* Disable ring */
  392. writel ( 0, ( intel->regs + reg + INTEL_xDCTL ) );
  393. /* Wait for disable to complete */
  394. for ( i = 0 ; i < INTEL_DISABLE_MAX_WAIT_MS ; i++ ) {
  395. /* Check if ring is disabled */
  396. dctl = readl ( intel->regs + reg + INTEL_xDCTL );
  397. if ( ! ( dctl & INTEL_xDCTL_ENABLE ) )
  398. return 0;
  399. /* Delay */
  400. mdelay ( 1 );
  401. }
  402. DBGC ( intel, "INTEL %p ring %05x timed out waiting for disable "
  403. "(dctl %08x)\n", intel, reg, dctl );
  404. return -ETIMEDOUT;
  405. }
  406. /**
  407. * Reset descriptor ring
  408. *
  409. * @v intel Intel device
  410. * @v reg Register block
  411. * @ret rc Return status code
  412. */
  413. void intel_reset_ring ( struct intel_nic *intel, unsigned int reg ) {
  414. /* Disable ring. Ignore errors and continue to reset the ring anyway */
  415. intel_disable_ring ( intel, reg );
  416. /* Clear ring length */
  417. writel ( 0, ( intel->regs + reg + INTEL_xDLEN ) );
  418. /* Clear ring address */
  419. writel ( 0, ( intel->regs + reg + INTEL_xDBAH ) );
  420. writel ( 0, ( intel->regs + reg + INTEL_xDBAL ) );
  421. /* Reset head and tail pointers */
  422. writel ( 0, ( intel->regs + reg + INTEL_xDH ) );
  423. writel ( 0, ( intel->regs + reg + INTEL_xDT ) );
  424. }
  425. /**
  426. * Create descriptor ring
  427. *
  428. * @v intel Intel device
  429. * @v ring Descriptor ring
  430. * @ret rc Return status code
  431. */
  432. int intel_create_ring ( struct intel_nic *intel, struct intel_ring *ring ) {
  433. physaddr_t address;
  434. uint32_t dctl;
  435. /* Allocate descriptor ring. Align ring on its own size to
  436. * prevent any possible page-crossing errors due to hardware
  437. * errata.
  438. */
  439. ring->desc = malloc_dma ( ring->len, ring->len );
  440. if ( ! ring->desc )
  441. return -ENOMEM;
  442. /* Initialise descriptor ring */
  443. memset ( ring->desc, 0, ring->len );
  444. /* Program ring address */
  445. address = virt_to_bus ( ring->desc );
  446. writel ( ( address & 0xffffffffUL ),
  447. ( intel->regs + ring->reg + INTEL_xDBAL ) );
  448. if ( sizeof ( physaddr_t ) > sizeof ( uint32_t ) ) {
  449. writel ( ( ( ( uint64_t ) address ) >> 32 ),
  450. ( intel->regs + ring->reg + INTEL_xDBAH ) );
  451. } else {
  452. writel ( 0, intel->regs + ring->reg + INTEL_xDBAH );
  453. }
  454. /* Program ring length */
  455. writel ( ring->len, ( intel->regs + ring->reg + INTEL_xDLEN ) );
  456. /* Reset head and tail pointers */
  457. writel ( 0, ( intel->regs + ring->reg + INTEL_xDH ) );
  458. writel ( 0, ( intel->regs + ring->reg + INTEL_xDT ) );
  459. /* Enable ring */
  460. dctl = readl ( intel->regs + ring->reg + INTEL_xDCTL );
  461. dctl |= INTEL_xDCTL_ENABLE;
  462. writel ( dctl, intel->regs + ring->reg + INTEL_xDCTL );
  463. DBGC ( intel, "INTEL %p ring %05x is at [%08llx,%08llx)\n",
  464. intel, ring->reg, ( ( unsigned long long ) address ),
  465. ( ( unsigned long long ) address + ring->len ) );
  466. return 0;
  467. }
  468. /**
  469. * Destroy descriptor ring
  470. *
  471. * @v intel Intel device
  472. * @v ring Descriptor ring
  473. */
  474. void intel_destroy_ring ( struct intel_nic *intel, struct intel_ring *ring ) {
  475. /* Reset ring */
  476. intel_reset_ring ( intel, ring->reg );
  477. /* Free descriptor ring */
  478. free_dma ( ring->desc, ring->len );
  479. ring->desc = NULL;
  480. ring->prod = 0;
  481. ring->cons = 0;
  482. }
  483. /**
  484. * Refill receive descriptor ring
  485. *
  486. * @v intel Intel device
  487. */
  488. void intel_refill_rx ( struct intel_nic *intel ) {
  489. struct intel_descriptor *rx;
  490. struct io_buffer *iobuf;
  491. unsigned int rx_idx;
  492. unsigned int rx_tail;
  493. physaddr_t address;
  494. unsigned int refilled = 0;
  495. /* Refill ring */
  496. while ( ( intel->rx.prod - intel->rx.cons ) < INTEL_RX_FILL ) {
  497. /* Allocate I/O buffer */
  498. iobuf = alloc_iob ( INTEL_RX_MAX_LEN );
  499. if ( ! iobuf ) {
  500. /* Wait for next refill */
  501. break;
  502. }
  503. /* Get next receive descriptor */
  504. rx_idx = ( intel->rx.prod++ % INTEL_NUM_RX_DESC );
  505. rx = &intel->rx.desc[rx_idx];
  506. /* Populate receive descriptor */
  507. address = virt_to_bus ( iobuf->data );
  508. intel->rx.describe ( rx, address, 0 );
  509. /* Record I/O buffer */
  510. assert ( intel->rx_iobuf[rx_idx] == NULL );
  511. intel->rx_iobuf[rx_idx] = iobuf;
  512. DBGC2 ( intel, "INTEL %p RX %d is [%llx,%llx)\n", intel, rx_idx,
  513. ( ( unsigned long long ) address ),
  514. ( ( unsigned long long ) address + INTEL_RX_MAX_LEN ) );
  515. refilled++;
  516. }
  517. /* Push descriptors to card, if applicable */
  518. if ( refilled ) {
  519. wmb();
  520. rx_tail = ( intel->rx.prod % INTEL_NUM_RX_DESC );
  521. profile_start ( &intel_vm_refill_profiler );
  522. writel ( rx_tail, intel->regs + intel->rx.reg + INTEL_xDT );
  523. profile_stop ( &intel_vm_refill_profiler );
  524. profile_exclude ( &intel_vm_refill_profiler );
  525. }
  526. }
  527. /**
  528. * Discard unused receive I/O buffers
  529. *
  530. * @v intel Intel device
  531. */
  532. void intel_empty_rx ( struct intel_nic *intel ) {
  533. unsigned int i;
  534. for ( i = 0 ; i < INTEL_NUM_RX_DESC ; i++ ) {
  535. if ( intel->rx_iobuf[i] )
  536. free_iob ( intel->rx_iobuf[i] );
  537. intel->rx_iobuf[i] = NULL;
  538. }
  539. }
  540. /**
  541. * Open network device
  542. *
  543. * @v netdev Network device
  544. * @ret rc Return status code
  545. */
  546. static int intel_open ( struct net_device *netdev ) {
  547. struct intel_nic *intel = netdev->priv;
  548. union intel_receive_address mac;
  549. uint32_t tctl;
  550. uint32_t rctl;
  551. int rc;
  552. /* Create transmit descriptor ring */
  553. if ( ( rc = intel_create_ring ( intel, &intel->tx ) ) != 0 )
  554. goto err_create_tx;
  555. /* Create receive descriptor ring */
  556. if ( ( rc = intel_create_ring ( intel, &intel->rx ) ) != 0 )
  557. goto err_create_rx;
  558. /* Program MAC address */
  559. memset ( &mac, 0, sizeof ( mac ) );
  560. memcpy ( mac.raw, netdev->ll_addr, sizeof ( mac.raw ) );
  561. writel ( le32_to_cpu ( mac.reg.low ), intel->regs + INTEL_RAL0 );
  562. writel ( ( le32_to_cpu ( mac.reg.high ) | INTEL_RAH0_AV ),
  563. intel->regs + INTEL_RAH0 );
  564. /* Enable transmitter */
  565. tctl = readl ( intel->regs + INTEL_TCTL );
  566. tctl &= ~( INTEL_TCTL_CT_MASK | INTEL_TCTL_COLD_MASK );
  567. tctl |= ( INTEL_TCTL_EN | INTEL_TCTL_PSP | INTEL_TCTL_CT_DEFAULT |
  568. INTEL_TCTL_COLD_DEFAULT );
  569. writel ( tctl, intel->regs + INTEL_TCTL );
  570. /* Enable receiver */
  571. rctl = readl ( intel->regs + INTEL_RCTL );
  572. rctl &= ~( INTEL_RCTL_BSIZE_BSEX_MASK );
  573. rctl |= ( INTEL_RCTL_EN | INTEL_RCTL_UPE | INTEL_RCTL_MPE |
  574. INTEL_RCTL_BAM | INTEL_RCTL_BSIZE_2048 | INTEL_RCTL_SECRC );
  575. writel ( rctl, intel->regs + INTEL_RCTL );
  576. /* Fill receive ring */
  577. intel_refill_rx ( intel );
  578. /* Update link state */
  579. intel_check_link ( netdev );
  580. /* Apply required errata */
  581. if ( intel->flags & INTEL_VMWARE ) {
  582. DBGC ( intel, "INTEL %p applying VMware errata workaround\n",
  583. intel );
  584. intel->force_icr = INTEL_IRQ_RXT0;
  585. }
  586. return 0;
  587. intel_destroy_ring ( intel, &intel->rx );
  588. err_create_rx:
  589. intel_destroy_ring ( intel, &intel->tx );
  590. err_create_tx:
  591. return rc;
  592. }
  593. /**
  594. * Close network device
  595. *
  596. * @v netdev Network device
  597. */
  598. static void intel_close ( struct net_device *netdev ) {
  599. struct intel_nic *intel = netdev->priv;
  600. /* Disable receiver */
  601. writel ( 0, intel->regs + INTEL_RCTL );
  602. /* Disable transmitter */
  603. writel ( 0, intel->regs + INTEL_TCTL );
  604. /* Destroy receive descriptor ring */
  605. intel_destroy_ring ( intel, &intel->rx );
  606. /* Discard any unused receive buffers */
  607. intel_empty_rx ( intel );
  608. /* Destroy transmit descriptor ring */
  609. intel_destroy_ring ( intel, &intel->tx );
  610. /* Reset the NIC, to flush the transmit and receive FIFOs */
  611. intel_reset ( intel );
  612. }
  613. /**
  614. * Transmit packet
  615. *
  616. * @v netdev Network device
  617. * @v iobuf I/O buffer
  618. * @ret rc Return status code
  619. */
  620. int intel_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) {
  621. struct intel_nic *intel = netdev->priv;
  622. struct intel_descriptor *tx;
  623. unsigned int tx_idx;
  624. unsigned int tx_tail;
  625. physaddr_t address;
  626. size_t len;
  627. /* Get next transmit descriptor */
  628. if ( ( intel->tx.prod - intel->tx.cons ) >= INTEL_TX_FILL ) {
  629. DBGC ( intel, "INTEL %p out of transmit descriptors\n", intel );
  630. return -ENOBUFS;
  631. }
  632. tx_idx = ( intel->tx.prod++ % INTEL_NUM_TX_DESC );
  633. tx_tail = ( intel->tx.prod % INTEL_NUM_TX_DESC );
  634. tx = &intel->tx.desc[tx_idx];
  635. /* Populate transmit descriptor */
  636. address = virt_to_bus ( iobuf->data );
  637. len = iob_len ( iobuf );
  638. intel->tx.describe ( tx, address, len );
  639. wmb();
  640. /* Notify card that there are packets ready to transmit */
  641. profile_start ( &intel_vm_tx_profiler );
  642. writel ( tx_tail, intel->regs + intel->tx.reg + INTEL_xDT );
  643. profile_stop ( &intel_vm_tx_profiler );
  644. profile_exclude ( &intel_vm_tx_profiler );
  645. DBGC2 ( intel, "INTEL %p TX %d is [%llx,%llx)\n", intel, tx_idx,
  646. ( ( unsigned long long ) address ),
  647. ( ( unsigned long long ) address + len ) );
  648. return 0;
  649. }
  650. /**
  651. * Poll for completed packets
  652. *
  653. * @v netdev Network device
  654. */
  655. void intel_poll_tx ( struct net_device *netdev ) {
  656. struct intel_nic *intel = netdev->priv;
  657. struct intel_descriptor *tx;
  658. unsigned int tx_idx;
  659. /* Check for completed packets */
  660. while ( intel->tx.cons != intel->tx.prod ) {
  661. /* Get next transmit descriptor */
  662. tx_idx = ( intel->tx.cons % INTEL_NUM_TX_DESC );
  663. tx = &intel->tx.desc[tx_idx];
  664. /* Stop if descriptor is still in use */
  665. if ( ! ( tx->status & cpu_to_le32 ( INTEL_DESC_STATUS_DD ) ) )
  666. return;
  667. DBGC2 ( intel, "INTEL %p TX %d complete\n", intel, tx_idx );
  668. /* Complete TX descriptor */
  669. netdev_tx_complete_next ( netdev );
  670. intel->tx.cons++;
  671. }
  672. }
  673. /**
  674. * Poll for received packets
  675. *
  676. * @v netdev Network device
  677. */
  678. void intel_poll_rx ( struct net_device *netdev ) {
  679. struct intel_nic *intel = netdev->priv;
  680. struct intel_descriptor *rx;
  681. struct io_buffer *iobuf;
  682. unsigned int rx_idx;
  683. size_t len;
  684. /* Check for received packets */
  685. while ( intel->rx.cons != intel->rx.prod ) {
  686. /* Get next receive descriptor */
  687. rx_idx = ( intel->rx.cons % INTEL_NUM_RX_DESC );
  688. rx = &intel->rx.desc[rx_idx];
  689. /* Stop if descriptor is still in use */
  690. if ( ! ( rx->status & cpu_to_le32 ( INTEL_DESC_STATUS_DD ) ) )
  691. return;
  692. /* Populate I/O buffer */
  693. iobuf = intel->rx_iobuf[rx_idx];
  694. intel->rx_iobuf[rx_idx] = NULL;
  695. len = le16_to_cpu ( rx->length );
  696. iob_put ( iobuf, len );
  697. /* Hand off to network stack */
  698. if ( rx->status & cpu_to_le32 ( INTEL_DESC_STATUS_RXE ) ) {
  699. DBGC ( intel, "INTEL %p RX %d error (length %zd, "
  700. "status %08x)\n", intel, rx_idx, len,
  701. le32_to_cpu ( rx->status ) );
  702. netdev_rx_err ( netdev, iobuf, -EIO );
  703. } else {
  704. DBGC2 ( intel, "INTEL %p RX %d complete (length %zd)\n",
  705. intel, rx_idx, len );
  706. netdev_rx ( netdev, iobuf );
  707. }
  708. intel->rx.cons++;
  709. }
  710. }
  711. /**
  712. * Poll for completed and received packets
  713. *
  714. * @v netdev Network device
  715. */
  716. static void intel_poll ( struct net_device *netdev ) {
  717. struct intel_nic *intel = netdev->priv;
  718. uint32_t icr;
  719. /* Check for and acknowledge interrupts */
  720. profile_start ( &intel_vm_poll_profiler );
  721. icr = readl ( intel->regs + INTEL_ICR );
  722. profile_stop ( &intel_vm_poll_profiler );
  723. profile_exclude ( &intel_vm_poll_profiler );
  724. icr |= intel->force_icr;
  725. if ( ! icr )
  726. return;
  727. /* Poll for TX completions, if applicable */
  728. if ( icr & INTEL_IRQ_TXDW )
  729. intel_poll_tx ( netdev );
  730. /* Poll for RX completions, if applicable */
  731. if ( icr & ( INTEL_IRQ_RXT0 | INTEL_IRQ_RXO ) )
  732. intel_poll_rx ( netdev );
  733. /* Report receive overruns */
  734. if ( icr & INTEL_IRQ_RXO )
  735. netdev_rx_err ( netdev, NULL, -ENOBUFS );
  736. /* Check link state, if applicable */
  737. if ( icr & INTEL_IRQ_LSC )
  738. intel_check_link ( netdev );
  739. /* Check for unexpected interrupts */
  740. if ( icr & ~( INTEL_IRQ_TXDW | INTEL_IRQ_TXQE | INTEL_IRQ_LSC |
  741. INTEL_IRQ_RXDMT0 | INTEL_IRQ_RXT0 | INTEL_IRQ_RXO ) ) {
  742. DBGC ( intel, "INTEL %p unexpected ICR %08x\n", intel, icr );
  743. /* Report as a TX error */
  744. netdev_tx_err ( netdev, NULL, -ENOTSUP );
  745. }
  746. /* Refill RX ring */
  747. intel_refill_rx ( intel );
  748. }
  749. /**
  750. * Enable or disable interrupts
  751. *
  752. * @v netdev Network device
  753. * @v enable Interrupts should be enabled
  754. */
  755. static void intel_irq ( struct net_device *netdev, int enable ) {
  756. struct intel_nic *intel = netdev->priv;
  757. uint32_t mask;
  758. mask = ( INTEL_IRQ_TXDW | INTEL_IRQ_LSC | INTEL_IRQ_RXT0 );
  759. if ( enable ) {
  760. writel ( mask, intel->regs + INTEL_IMS );
  761. } else {
  762. writel ( mask, intel->regs + INTEL_IMC );
  763. }
  764. }
  765. /** Intel network device operations */
  766. static struct net_device_operations intel_operations = {
  767. .open = intel_open,
  768. .close = intel_close,
  769. .transmit = intel_transmit,
  770. .poll = intel_poll,
  771. .irq = intel_irq,
  772. };
  773. /******************************************************************************
  774. *
  775. * PCI interface
  776. *
  777. ******************************************************************************
  778. */
  779. /**
  780. * Probe PCI device
  781. *
  782. * @v pci PCI device
  783. * @ret rc Return status code
  784. */
  785. static int intel_probe ( struct pci_device *pci ) {
  786. struct net_device *netdev;
  787. struct intel_nic *intel;
  788. int rc;
  789. /* Allocate and initialise net device */
  790. netdev = alloc_etherdev ( sizeof ( *intel ) );
  791. if ( ! netdev ) {
  792. rc = -ENOMEM;
  793. goto err_alloc;
  794. }
  795. netdev_init ( netdev, &intel_operations );
  796. intel = netdev->priv;
  797. pci_set_drvdata ( pci, netdev );
  798. netdev->dev = &pci->dev;
  799. memset ( intel, 0, sizeof ( *intel ) );
  800. intel->port = PCI_FUNC ( pci->busdevfn );
  801. intel->flags = pci->id->driver_data;
  802. intel_init_ring ( &intel->tx, INTEL_NUM_TX_DESC, INTEL_TD,
  803. intel_describe_tx );
  804. intel_init_ring ( &intel->rx, INTEL_NUM_RX_DESC, INTEL_RD,
  805. intel_describe_rx );
  806. /* Fix up PCI device */
  807. adjust_pci_device ( pci );
  808. /* Map registers */
  809. intel->regs = ioremap ( pci->membase, INTEL_BAR_SIZE );
  810. if ( ! intel->regs ) {
  811. rc = -ENODEV;
  812. goto err_ioremap;
  813. }
  814. /* Reset the NIC */
  815. if ( ( rc = intel_reset ( intel ) ) != 0 )
  816. goto err_reset;
  817. /* Fetch MAC address */
  818. if ( ( rc = intel_fetch_mac ( intel, netdev->hw_addr ) ) != 0 )
  819. goto err_fetch_mac;
  820. /* Register network device */
  821. if ( ( rc = register_netdev ( netdev ) ) != 0 )
  822. goto err_register_netdev;
  823. /* Set initial link state */
  824. intel_check_link ( netdev );
  825. return 0;
  826. unregister_netdev ( netdev );
  827. err_register_netdev:
  828. err_fetch_mac:
  829. intel_reset ( intel );
  830. err_reset:
  831. iounmap ( intel->regs );
  832. err_ioremap:
  833. netdev_nullify ( netdev );
  834. netdev_put ( netdev );
  835. err_alloc:
  836. return rc;
  837. }
  838. /**
  839. * Remove PCI device
  840. *
  841. * @v pci PCI device
  842. */
  843. static void intel_remove ( struct pci_device *pci ) {
  844. struct net_device *netdev = pci_get_drvdata ( pci );
  845. struct intel_nic *intel = netdev->priv;
  846. /* Unregister network device */
  847. unregister_netdev ( netdev );
  848. /* Reset the NIC */
  849. intel_reset ( intel );
  850. /* Free network device */
  851. iounmap ( intel->regs );
  852. netdev_nullify ( netdev );
  853. netdev_put ( netdev );
  854. }
  855. /** Intel PCI device IDs */
  856. static struct pci_device_id intel_nics[] = {
  857. PCI_ROM ( 0x8086, 0x0438, "dh8900cc", "DH8900CC", 0 ),
  858. PCI_ROM ( 0x8086, 0x043a, "dh8900cc-f", "DH8900CC Fiber", 0 ),
  859. PCI_ROM ( 0x8086, 0x043c, "dh8900cc-b", "DH8900CC Backplane", 0 ),
  860. PCI_ROM ( 0x8086, 0x0440, "dh8900cc-s", "DH8900CC SFP", 0 ),
  861. PCI_ROM ( 0x8086, 0x1000, "82542-f", "82542 (Fiber)", 0 ),
  862. PCI_ROM ( 0x8086, 0x1001, "82543gc-f", "82543GC (Fiber)", 0 ),
  863. PCI_ROM ( 0x8086, 0x1004, "82543gc", "82543GC (Copper)", 0 ),
  864. PCI_ROM ( 0x8086, 0x1008, "82544ei", "82544EI (Copper)", 0 ),
  865. PCI_ROM ( 0x8086, 0x1009, "82544ei-f", "82544EI (Fiber)", 0 ),
  866. PCI_ROM ( 0x8086, 0x100c, "82544gc", "82544GC (Copper)", 0 ),
  867. PCI_ROM ( 0x8086, 0x100d, "82544gc-l", "82544GC (LOM)", 0 ),
  868. PCI_ROM ( 0x8086, 0x100e, "82540em", "82540EM", 0 ),
  869. PCI_ROM ( 0x8086, 0x100f, "82545em", "82545EM (Copper)", INTEL_VMWARE ),
  870. PCI_ROM ( 0x8086, 0x1010, "82546eb", "82546EB (Copper)", 0 ),
  871. PCI_ROM ( 0x8086, 0x1011, "82545em-f", "82545EM (Fiber)", 0 ),
  872. PCI_ROM ( 0x8086, 0x1012, "82546eb-f", "82546EB (Fiber)", 0 ),
  873. PCI_ROM ( 0x8086, 0x1013, "82541ei", "82541EI", 0 ),
  874. PCI_ROM ( 0x8086, 0x1014, "82541er", "82541ER", 0 ),
  875. PCI_ROM ( 0x8086, 0x1015, "82540em-l", "82540EM (LOM)", 0 ),
  876. PCI_ROM ( 0x8086, 0x1016, "82540ep-m", "82540EP (Mobile)", 0 ),
  877. PCI_ROM ( 0x8086, 0x1017, "82540ep", "82540EP", 0 ),
  878. PCI_ROM ( 0x8086, 0x1018, "82541ei", "82541EI", 0 ),
  879. PCI_ROM ( 0x8086, 0x1019, "82547ei", "82547EI", 0 ),
  880. PCI_ROM ( 0x8086, 0x101a, "82547ei-m", "82547EI (Mobile)", 0 ),
  881. PCI_ROM ( 0x8086, 0x101d, "82546eb", "82546EB", 0 ),
  882. PCI_ROM ( 0x8086, 0x101e, "82540ep-m", "82540EP (Mobile)", 0 ),
  883. PCI_ROM ( 0x8086, 0x1026, "82545gm", "82545GM", 0 ),
  884. PCI_ROM ( 0x8086, 0x1027, "82545gm-1", "82545GM", 0 ),
  885. PCI_ROM ( 0x8086, 0x1028, "82545gm-2", "82545GM", 0 ),
  886. PCI_ROM ( 0x8086, 0x1049, "82566mm", "82566MM", INTEL_PBS_ERRATA ),
  887. PCI_ROM ( 0x8086, 0x104a, "82566dm", "82566DM", INTEL_PBS_ERRATA ),
  888. PCI_ROM ( 0x8086, 0x104b, "82566dc", "82566DC", INTEL_PBS_ERRATA ),
  889. PCI_ROM ( 0x8086, 0x104c, "82562v", "82562V", INTEL_PBS_ERRATA ),
  890. PCI_ROM ( 0x8086, 0x104d, "82566mc", "82566MC", INTEL_PBS_ERRATA ),
  891. PCI_ROM ( 0x8086, 0x105e, "82571eb", "82571EB", 0 ),
  892. PCI_ROM ( 0x8086, 0x105f, "82571eb-1", "82571EB", 0 ),
  893. PCI_ROM ( 0x8086, 0x1060, "82571eb-2", "82571EB", 0 ),
  894. PCI_ROM ( 0x8086, 0x1075, "82547gi", "82547GI", 0 ),
  895. PCI_ROM ( 0x8086, 0x1076, "82541gi", "82541GI", 0 ),
  896. PCI_ROM ( 0x8086, 0x1077, "82541gi-1", "82541GI", 0 ),
  897. PCI_ROM ( 0x8086, 0x1078, "82541er", "82541ER", 0 ),
  898. PCI_ROM ( 0x8086, 0x1079, "82546gb", "82546GB", 0 ),
  899. PCI_ROM ( 0x8086, 0x107a, "82546gb-1", "82546GB", 0 ),
  900. PCI_ROM ( 0x8086, 0x107b, "82546gb-2", "82546GB", 0 ),
  901. PCI_ROM ( 0x8086, 0x107c, "82541pi", "82541PI", 0 ),
  902. PCI_ROM ( 0x8086, 0x107d, "82572ei", "82572EI (Copper)", 0 ),
  903. PCI_ROM ( 0x8086, 0x107e, "82572ei-f", "82572EI (Fiber)", 0 ),
  904. PCI_ROM ( 0x8086, 0x107f, "82572ei", "82572EI", 0 ),
  905. PCI_ROM ( 0x8086, 0x108a, "82546gb-3", "82546GB", 0 ),
  906. PCI_ROM ( 0x8086, 0x108b, "82573v", "82573V (Copper)", 0 ),
  907. PCI_ROM ( 0x8086, 0x108c, "82573e", "82573E (Copper)", 0 ),
  908. PCI_ROM ( 0x8086, 0x1096, "80003es2lan", "80003ES2LAN (Copper)", 0 ),
  909. PCI_ROM ( 0x8086, 0x1098, "80003es2lan-s", "80003ES2LAN (Serdes)", 0 ),
  910. PCI_ROM ( 0x8086, 0x1099, "82546gb-4", "82546GB (Copper)", 0 ),
  911. PCI_ROM ( 0x8086, 0x109a, "82573l", "82573L", 0 ),
  912. PCI_ROM ( 0x8086, 0x10a4, "82571eb", "82571EB", 0 ),
  913. PCI_ROM ( 0x8086, 0x10a5, "82571eb", "82571EB (Fiber)", 0 ),
  914. PCI_ROM ( 0x8086, 0x10a7, "82575eb", "82575EB", 0 ),
  915. PCI_ROM ( 0x8086, 0x10a9, "82575eb", "82575EB Backplane", 0 ),
  916. PCI_ROM ( 0x8086, 0x10b5, "82546gb", "82546GB (Copper)", 0 ),
  917. PCI_ROM ( 0x8086, 0x10b9, "82572ei", "82572EI (Copper)", 0 ),
  918. PCI_ROM ( 0x8086, 0x10ba, "80003es2lan", "80003ES2LAN (Copper)", 0 ),
  919. PCI_ROM ( 0x8086, 0x10bb, "80003es2lan", "80003ES2LAN (Serdes)", 0 ),
  920. PCI_ROM ( 0x8086, 0x10bc, "82571eb", "82571EB (Copper)", 0 ),
  921. PCI_ROM ( 0x8086, 0x10bd, "82566dm-2", "82566DM-2", 0 ),
  922. PCI_ROM ( 0x8086, 0x10bf, "82567lf", "82567LF", 0 ),
  923. PCI_ROM ( 0x8086, 0x10c0, "82562v-2", "82562V-2", 0 ),
  924. PCI_ROM ( 0x8086, 0x10c2, "82562g-2", "82562G-2", 0 ),
  925. PCI_ROM ( 0x8086, 0x10c3, "82562gt-2", "82562GT-2", 0 ),
  926. PCI_ROM ( 0x8086, 0x10c4, "82562gt", "82562GT", INTEL_PBS_ERRATA ),
  927. PCI_ROM ( 0x8086, 0x10c5, "82562g", "82562G", INTEL_PBS_ERRATA ),
  928. PCI_ROM ( 0x8086, 0x10c9, "82576", "82576", 0 ),
  929. PCI_ROM ( 0x8086, 0x10cb, "82567v", "82567V", 0 ),
  930. PCI_ROM ( 0x8086, 0x10cc, "82567lm-2", "82567LM-2", 0 ),
  931. PCI_ROM ( 0x8086, 0x10cd, "82567lf-2", "82567LF-2", 0 ),
  932. PCI_ROM ( 0x8086, 0x10ce, "82567v-2", "82567V-2", 0 ),
  933. PCI_ROM ( 0x8086, 0x10d3, "82574l", "82574L", 0 ),
  934. PCI_ROM ( 0x8086, 0x10d5, "82571pt", "82571PT PT Quad", 0 ),
  935. PCI_ROM ( 0x8086, 0x10d6, "82575gb", "82575GB", 0 ),
  936. PCI_ROM ( 0x8086, 0x10d9, "82571eb-d", "82571EB Dual Mezzanine", 0 ),
  937. PCI_ROM ( 0x8086, 0x10da, "82571eb-q", "82571EB Quad Mezzanine", 0 ),
  938. PCI_ROM ( 0x8086, 0x10de, "82567lm-3", "82567LM-3", 0 ),
  939. PCI_ROM ( 0x8086, 0x10df, "82567lf-3", "82567LF-3", 0 ),
  940. PCI_ROM ( 0x8086, 0x10e5, "82567lm-4", "82567LM-4", 0 ),
  941. PCI_ROM ( 0x8086, 0x10e6, "82576", "82576", 0 ),
  942. PCI_ROM ( 0x8086, 0x10e7, "82576-2", "82576", 0 ),
  943. PCI_ROM ( 0x8086, 0x10e8, "82576-3", "82576", 0 ),
  944. PCI_ROM ( 0x8086, 0x10ea, "82577lm", "82577LM", 0 ),
  945. PCI_ROM ( 0x8086, 0x10eb, "82577lc", "82577LC", 0 ),
  946. PCI_ROM ( 0x8086, 0x10ef, "82578dm", "82578DM", 0 ),
  947. PCI_ROM ( 0x8086, 0x10f0, "82578dc", "82578DC", 0 ),
  948. PCI_ROM ( 0x8086, 0x10f5, "82567lm", "82567LM", 0 ),
  949. PCI_ROM ( 0x8086, 0x10f6, "82574l", "82574L", 0 ),
  950. PCI_ROM ( 0x8086, 0x1501, "82567v-3", "82567V-3", INTEL_PBS_ERRATA ),
  951. PCI_ROM ( 0x8086, 0x1502, "82579lm", "82579LM", INTEL_NO_PHY_RST ),
  952. PCI_ROM ( 0x8086, 0x1503, "82579v", "82579V", 0 ),
  953. PCI_ROM ( 0x8086, 0x150a, "82576ns", "82576NS", 0 ),
  954. PCI_ROM ( 0x8086, 0x150c, "82583v", "82583V", 0 ),
  955. PCI_ROM ( 0x8086, 0x150d, "82576-4", "82576 Backplane", 0 ),
  956. PCI_ROM ( 0x8086, 0x150e, "82580", "82580", 0 ),
  957. PCI_ROM ( 0x8086, 0x150f, "82580-f", "82580 Fiber", 0 ),
  958. PCI_ROM ( 0x8086, 0x1510, "82580-b", "82580 Backplane", 0 ),
  959. PCI_ROM ( 0x8086, 0x1511, "82580-s", "82580 SFP", 0 ),
  960. PCI_ROM ( 0x8086, 0x1516, "82580-2", "82580", 0 ),
  961. PCI_ROM ( 0x8086, 0x1518, "82576ns", "82576NS SerDes", 0 ),
  962. PCI_ROM ( 0x8086, 0x1521, "i350", "I350", 0 ),
  963. PCI_ROM ( 0x8086, 0x1522, "i350-f", "I350 Fiber", 0 ),
  964. PCI_ROM ( 0x8086, 0x1523, "i350-b", "I350 Backplane", 0 ),
  965. PCI_ROM ( 0x8086, 0x1524, "i350-2", "I350", 0 ),
  966. PCI_ROM ( 0x8086, 0x1525, "82567v-4", "82567V-4", 0 ),
  967. PCI_ROM ( 0x8086, 0x1526, "82576-5", "82576", 0 ),
  968. PCI_ROM ( 0x8086, 0x1527, "82580-f2", "82580 Fiber", 0 ),
  969. PCI_ROM ( 0x8086, 0x1533, "i210", "I210", 0 ),
  970. PCI_ROM ( 0x8086, 0x1539, "i211", "I211", 0 ),
  971. PCI_ROM ( 0x8086, 0x153a, "i217lm", "I217-LM", INTEL_NO_PHY_RST ),
  972. PCI_ROM ( 0x8086, 0x153b, "i217v", "I217-V", 0 ),
  973. PCI_ROM ( 0x8086, 0x1559, "i218v", "I218-V", 0),
  974. PCI_ROM ( 0x8086, 0x155a, "i218lm", "I218-LM", 0),
  975. PCI_ROM ( 0x8086, 0x156f, "i219lm", "I219-LM", 0 ),
  976. PCI_ROM ( 0x8086, 0x1570, "i219v", "I219-V", 0 ),
  977. PCI_ROM ( 0x8086, 0x157b, "i210-2", "I210", 0 ),
  978. PCI_ROM ( 0x8086, 0x15a0, "i218lm-2", "I218-LM", INTEL_NO_PHY_RST ),
  979. PCI_ROM ( 0x8086, 0x15a1, "i218v-2", "I218-V", 0 ),
  980. PCI_ROM ( 0x8086, 0x15a2, "i218lm-3", "I218-LM", INTEL_NO_PHY_RST ),
  981. PCI_ROM ( 0x8086, 0x15a3, "i218v-3", "I218-V", INTEL_NO_PHY_RST ),
  982. PCI_ROM ( 0x8086, 0x15b7, "i219lm-2", "I219-LM (2)", INTEL_NO_PHY_RST ),
  983. PCI_ROM ( 0x8086, 0x15b8, "i219v-2", "I219-V (2)", 0 ),
  984. PCI_ROM ( 0x8086, 0x294c, "82566dc-2", "82566DC-2", 0 ),
  985. PCI_ROM ( 0x8086, 0x2e6e, "cemedia", "CE Media Processor", 0 ),
  986. };
  987. /** Intel PCI driver */
  988. struct pci_driver intel_driver __pci_driver = {
  989. .ids = intel_nics,
  990. .id_count = ( sizeof ( intel_nics ) / sizeof ( intel_nics[0] ) ),
  991. .probe = intel_probe,
  992. .remove = intel_remove,
  993. };