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 36KB

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