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.

intelxl.c 46KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670
  1. /*
  2. * Copyright (C) 2018 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 <stdio.h>
  27. #include <unistd.h>
  28. #include <errno.h>
  29. #include <byteswap.h>
  30. #include <ipxe/netdevice.h>
  31. #include <ipxe/ethernet.h>
  32. #include <ipxe/if_ether.h>
  33. #include <ipxe/vlan.h>
  34. #include <ipxe/iobuf.h>
  35. #include <ipxe/malloc.h>
  36. #include <ipxe/pci.h>
  37. #include <ipxe/version.h>
  38. #include "intelxl.h"
  39. /** @file
  40. *
  41. * Intel 40 Gigabit Ethernet network card driver
  42. *
  43. */
  44. static void intelxl_reopen_admin ( struct intelxl_nic *intelxl );
  45. /******************************************************************************
  46. *
  47. * Device reset
  48. *
  49. ******************************************************************************
  50. */
  51. /**
  52. * Reset hardware
  53. *
  54. * @v intelxl Intel device
  55. * @ret rc Return status code
  56. */
  57. static int intelxl_reset ( struct intelxl_nic *intelxl ) {
  58. uint32_t pfgen_ctrl;
  59. /* Perform a global software reset */
  60. pfgen_ctrl = readl ( intelxl->regs + INTELXL_PFGEN_CTRL );
  61. writel ( ( pfgen_ctrl | INTELXL_PFGEN_CTRL_PFSWR ),
  62. intelxl->regs + INTELXL_PFGEN_CTRL );
  63. mdelay ( INTELXL_RESET_DELAY_MS );
  64. return 0;
  65. }
  66. /******************************************************************************
  67. *
  68. * MAC address
  69. *
  70. ******************************************************************************
  71. */
  72. /**
  73. * Fetch initial MAC address and maximum frame size
  74. *
  75. * @v intelxl Intel device
  76. * @v netdev Network device
  77. * @ret rc Return status code
  78. */
  79. static int intelxl_fetch_mac ( struct intelxl_nic *intelxl,
  80. struct net_device *netdev ) {
  81. union intelxl_receive_address mac;
  82. uint32_t prtgl_sal;
  83. uint32_t prtgl_sah;
  84. size_t mfs;
  85. /* Read NVM-loaded address */
  86. prtgl_sal = readl ( intelxl->regs + INTELXL_PRTGL_SAL );
  87. prtgl_sah = readl ( intelxl->regs + INTELXL_PRTGL_SAH );
  88. mac.reg.low = cpu_to_le32 ( prtgl_sal );
  89. mac.reg.high = cpu_to_le32 ( prtgl_sah );
  90. /* Check that address is valid */
  91. if ( ! is_valid_ether_addr ( mac.raw ) ) {
  92. DBGC ( intelxl, "INTELXL %p has invalid MAC address (%s)\n",
  93. intelxl, eth_ntoa ( mac.raw ) );
  94. return -ENOENT;
  95. }
  96. /* Copy MAC address */
  97. DBGC ( intelxl, "INTELXL %p has autoloaded MAC address %s\n",
  98. intelxl, eth_ntoa ( mac.raw ) );
  99. memcpy ( netdev->hw_addr, mac.raw, ETH_ALEN );
  100. /* Get maximum frame size */
  101. mfs = INTELXL_PRTGL_SAH_MFS_GET ( prtgl_sah );
  102. netdev->max_pkt_len = ( mfs - 4 /* CRC */ );
  103. return 0;
  104. }
  105. /******************************************************************************
  106. *
  107. * Admin queue
  108. *
  109. ******************************************************************************
  110. */
  111. /** Admin queue register offsets */
  112. static const struct intelxl_admin_offsets intelxl_admin_offsets = {
  113. .bal = INTELXL_ADMIN_BAL,
  114. .bah = INTELXL_ADMIN_BAH,
  115. .len = INTELXL_ADMIN_LEN,
  116. .head = INTELXL_ADMIN_HEAD,
  117. .tail = INTELXL_ADMIN_TAIL,
  118. };
  119. /**
  120. * Allocate admin queue
  121. *
  122. * @v intelxl Intel device
  123. * @v admin Admin queue
  124. * @ret rc Return status code
  125. */
  126. static int intelxl_alloc_admin ( struct intelxl_nic *intelxl,
  127. struct intelxl_admin *admin ) {
  128. size_t buf_len = ( sizeof ( admin->buf[0] ) * INTELXL_ADMIN_NUM_DESC );
  129. size_t len = ( sizeof ( admin->desc[0] ) * INTELXL_ADMIN_NUM_DESC );
  130. /* Allocate admin queue */
  131. admin->buf = malloc_dma ( ( buf_len + len ), INTELXL_ALIGN );
  132. if ( ! admin->buf )
  133. return -ENOMEM;
  134. admin->desc = ( ( ( void * ) admin->buf ) + buf_len );
  135. DBGC ( intelxl, "INTELXL %p A%cQ is at [%08llx,%08llx) buf "
  136. "[%08llx,%08llx)\n", intelxl,
  137. ( ( admin == &intelxl->command ) ? 'T' : 'R' ),
  138. ( ( unsigned long long ) virt_to_bus ( admin->desc ) ),
  139. ( ( unsigned long long ) ( virt_to_bus ( admin->desc ) + len ) ),
  140. ( ( unsigned long long ) virt_to_bus ( admin->buf ) ),
  141. ( ( unsigned long long ) ( virt_to_bus ( admin->buf ) +
  142. buf_len ) ) );
  143. return 0;
  144. }
  145. /**
  146. * Enable admin queue
  147. *
  148. * @v intelxl Intel device
  149. * @v admin Admin queue
  150. */
  151. static void intelxl_enable_admin ( struct intelxl_nic *intelxl,
  152. struct intelxl_admin *admin ) {
  153. size_t len = ( sizeof ( admin->desc[0] ) * INTELXL_ADMIN_NUM_DESC );
  154. const struct intelxl_admin_offsets *regs = admin->regs;
  155. void *admin_regs = ( intelxl->regs + admin->base );
  156. physaddr_t address;
  157. /* Initialise admin queue */
  158. memset ( admin->desc, 0, len );
  159. /* Reset head and tail registers */
  160. writel ( 0, admin_regs + regs->head );
  161. writel ( 0, admin_regs + regs->tail );
  162. /* Reset queue index */
  163. admin->index = 0;
  164. /* Program queue address */
  165. address = virt_to_bus ( admin->desc );
  166. writel ( ( address & 0xffffffffUL ), admin_regs + regs->bal );
  167. if ( sizeof ( physaddr_t ) > sizeof ( uint32_t ) ) {
  168. writel ( ( ( ( uint64_t ) address ) >> 32 ),
  169. admin_regs + regs->bah );
  170. } else {
  171. writel ( 0, admin_regs + regs->bah );
  172. }
  173. /* Program queue length and enable queue */
  174. writel ( ( INTELXL_ADMIN_LEN_LEN ( INTELXL_ADMIN_NUM_DESC ) |
  175. INTELXL_ADMIN_LEN_ENABLE ),
  176. admin_regs + regs->len );
  177. }
  178. /**
  179. * Disable admin queue
  180. *
  181. * @v intelxl Intel device
  182. * @v admin Admin queue
  183. */
  184. static void intelxl_disable_admin ( struct intelxl_nic *intelxl,
  185. struct intelxl_admin *admin ) {
  186. const struct intelxl_admin_offsets *regs = admin->regs;
  187. void *admin_regs = ( intelxl->regs + admin->base );
  188. /* Disable queue */
  189. writel ( 0, admin_regs + regs->len );
  190. }
  191. /**
  192. * Free admin queue
  193. *
  194. * @v intelxl Intel device
  195. * @v admin Admin queue
  196. */
  197. static void intelxl_free_admin ( struct intelxl_nic *intelxl __unused,
  198. struct intelxl_admin *admin ) {
  199. size_t buf_len = ( sizeof ( admin->buf[0] ) * INTELXL_ADMIN_NUM_DESC );
  200. size_t len = ( sizeof ( admin->desc[0] ) * INTELXL_ADMIN_NUM_DESC );
  201. /* Free queue */
  202. free_dma ( admin->buf, ( buf_len + len ) );
  203. }
  204. /**
  205. * Get next admin command queue descriptor
  206. *
  207. * @v intelxl Intel device
  208. * @ret cmd Command descriptor
  209. */
  210. static struct intelxl_admin_descriptor *
  211. intelxl_admin_command_descriptor ( struct intelxl_nic *intelxl ) {
  212. struct intelxl_admin *admin = &intelxl->command;
  213. struct intelxl_admin_descriptor *cmd;
  214. /* Get and initialise next descriptor */
  215. cmd = &admin->desc[ admin->index % INTELXL_ADMIN_NUM_DESC ];
  216. memset ( cmd, 0, sizeof ( *cmd ) );
  217. return cmd;
  218. }
  219. /**
  220. * Get next admin command queue data buffer
  221. *
  222. * @v intelxl Intel device
  223. * @ret buf Data buffer
  224. */
  225. static union intelxl_admin_buffer *
  226. intelxl_admin_command_buffer ( struct intelxl_nic *intelxl ) {
  227. struct intelxl_admin *admin = &intelxl->command;
  228. union intelxl_admin_buffer *buf;
  229. /* Get next data buffer */
  230. buf = &admin->buf[ admin->index % INTELXL_ADMIN_NUM_DESC ];
  231. memset ( buf, 0, sizeof ( *buf ) );
  232. return buf;
  233. }
  234. /**
  235. * Initialise admin event queue descriptor
  236. *
  237. * @v intelxl Intel device
  238. * @v index Event queue index
  239. */
  240. static void intelxl_admin_event_init ( struct intelxl_nic *intelxl,
  241. unsigned int index ) {
  242. struct intelxl_admin *admin = &intelxl->event;
  243. struct intelxl_admin_descriptor *evt;
  244. union intelxl_admin_buffer *buf;
  245. uint64_t address;
  246. /* Initialise descriptor */
  247. evt = &admin->desc[ index % INTELXL_ADMIN_NUM_DESC ];
  248. buf = &admin->buf[ index % INTELXL_ADMIN_NUM_DESC ];
  249. address = virt_to_bus ( buf );
  250. evt->flags = cpu_to_le16 ( INTELXL_ADMIN_FL_BUF );
  251. evt->len = cpu_to_le16 ( sizeof ( *buf ) );
  252. evt->params.buffer.high = cpu_to_le32 ( address >> 32 );
  253. evt->params.buffer.low = cpu_to_le32 ( address & 0xffffffffUL );
  254. }
  255. /**
  256. * Issue admin queue command
  257. *
  258. * @v intelxl Intel device
  259. * @ret rc Return status code
  260. */
  261. static int intelxl_admin_command ( struct intelxl_nic *intelxl ) {
  262. struct intelxl_admin *admin = &intelxl->command;
  263. const struct intelxl_admin_offsets *regs = admin->regs;
  264. void *admin_regs = ( intelxl->regs + admin->base );
  265. struct intelxl_admin_descriptor *cmd;
  266. union intelxl_admin_buffer *buf;
  267. uint64_t address;
  268. uint32_t cookie;
  269. unsigned int index;
  270. unsigned int tail;
  271. unsigned int i;
  272. int rc;
  273. /* Get next queue entry */
  274. index = admin->index++;
  275. tail = ( admin->index % INTELXL_ADMIN_NUM_DESC );
  276. cmd = &admin->desc[ index % INTELXL_ADMIN_NUM_DESC ];
  277. buf = &admin->buf[ index % INTELXL_ADMIN_NUM_DESC ];
  278. DBGC2 ( intelxl, "INTELXL %p admin command %#x opcode %#04x:\n",
  279. intelxl, index, le16_to_cpu ( cmd->opcode ) );
  280. /* Sanity checks */
  281. assert ( ! ( cmd->flags & cpu_to_le16 ( INTELXL_ADMIN_FL_DD ) ) );
  282. assert ( ! ( cmd->flags & cpu_to_le16 ( INTELXL_ADMIN_FL_CMP ) ) );
  283. assert ( ! ( cmd->flags & cpu_to_le16 ( INTELXL_ADMIN_FL_ERR ) ) );
  284. assert ( cmd->ret == 0 );
  285. /* Populate data buffer address if applicable */
  286. if ( cmd->flags & cpu_to_le16 ( INTELXL_ADMIN_FL_BUF ) ) {
  287. address = virt_to_bus ( buf );
  288. cmd->params.buffer.high = cpu_to_le32 ( address >> 32 );
  289. cmd->params.buffer.low = cpu_to_le32 ( address & 0xffffffffUL );
  290. }
  291. /* Populate cookie */
  292. cmd->cookie = cpu_to_le32 ( index );
  293. /* Record cookie */
  294. cookie = cmd->cookie;
  295. /* Post command descriptor */
  296. DBGC2_HDA ( intelxl, virt_to_phys ( cmd ), cmd, sizeof ( *cmd ) );
  297. if ( cmd->flags & cpu_to_le16 ( INTELXL_ADMIN_FL_BUF ) ) {
  298. DBGC2_HDA ( intelxl, virt_to_phys ( buf ), buf,
  299. le16_to_cpu ( cmd->len ) );
  300. }
  301. wmb();
  302. writel ( tail, admin_regs + regs->tail );
  303. /* Wait for completion */
  304. for ( i = 0 ; i < INTELXL_ADMIN_MAX_WAIT_MS ; i++ ) {
  305. /* If response is not complete, delay 1ms and retry */
  306. if ( ! ( cmd->flags & INTELXL_ADMIN_FL_DD ) ) {
  307. mdelay ( 1 );
  308. continue;
  309. }
  310. DBGC2 ( intelxl, "INTELXL %p admin command %#x response:\n",
  311. intelxl, index );
  312. DBGC2_HDA ( intelxl, virt_to_phys ( cmd ), cmd,
  313. sizeof ( *cmd ) );
  314. /* Check for cookie mismatch */
  315. if ( cmd->cookie != cookie ) {
  316. DBGC ( intelxl, "INTELXL %p admin command %#x bad "
  317. "cookie %#x\n", intelxl, index,
  318. le32_to_cpu ( cmd->cookie ) );
  319. rc = -EPROTO;
  320. goto err;
  321. }
  322. /* Check for errors */
  323. if ( cmd->ret != 0 ) {
  324. DBGC ( intelxl, "INTELXL %p admin command %#x error "
  325. "%d\n", intelxl, index,
  326. le16_to_cpu ( cmd->ret ) );
  327. rc = -EIO;
  328. goto err;
  329. }
  330. /* Success */
  331. return 0;
  332. }
  333. rc = -ETIMEDOUT;
  334. DBGC ( intelxl, "INTELXL %p timed out waiting for admin command %#x:\n",
  335. intelxl, index );
  336. err:
  337. DBGC_HDA ( intelxl, virt_to_phys ( cmd ), cmd, sizeof ( *cmd ) );
  338. return rc;
  339. }
  340. /**
  341. * Get firmware version
  342. *
  343. * @v intelxl Intel device
  344. * @ret rc Return status code
  345. */
  346. static int intelxl_admin_version ( struct intelxl_nic *intelxl ) {
  347. struct intelxl_admin_descriptor *cmd;
  348. struct intelxl_admin_version_params *version;
  349. unsigned int api;
  350. int rc;
  351. /* Populate descriptor */
  352. cmd = intelxl_admin_command_descriptor ( intelxl );
  353. cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_VERSION );
  354. version = &cmd->params.version;
  355. /* Issue command */
  356. if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
  357. return rc;
  358. api = le16_to_cpu ( version->api.major );
  359. DBGC ( intelxl, "INTELXL %p firmware v%d.%d API v%d.%d\n",
  360. intelxl, le16_to_cpu ( version->firmware.major ),
  361. le16_to_cpu ( version->firmware.minor ),
  362. api, le16_to_cpu ( version->api.minor ) );
  363. /* Check for API compatibility */
  364. if ( api > INTELXL_ADMIN_API_MAJOR ) {
  365. DBGC ( intelxl, "INTELXL %p unsupported API v%d\n",
  366. intelxl, api );
  367. return -ENOTSUP;
  368. }
  369. return 0;
  370. }
  371. /**
  372. * Report driver version
  373. *
  374. * @v intelxl Intel device
  375. * @ret rc Return status code
  376. */
  377. static int intelxl_admin_driver ( struct intelxl_nic *intelxl ) {
  378. struct intelxl_admin_descriptor *cmd;
  379. struct intelxl_admin_driver_params *driver;
  380. union intelxl_admin_buffer *buf;
  381. int rc;
  382. /* Populate descriptor */
  383. cmd = intelxl_admin_command_descriptor ( intelxl );
  384. cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_DRIVER );
  385. cmd->flags = cpu_to_le16 ( INTELXL_ADMIN_FL_RD | INTELXL_ADMIN_FL_BUF );
  386. cmd->len = cpu_to_le16 ( sizeof ( buf->driver ) );
  387. driver = &cmd->params.driver;
  388. driver->major = product_major_version;
  389. driver->minor = product_minor_version;
  390. buf = intelxl_admin_command_buffer ( intelxl );
  391. snprintf ( buf->driver.name, sizeof ( buf->driver.name ), "%s",
  392. ( product_name[0] ? product_name : product_short_name ) );
  393. /* Issue command */
  394. if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
  395. return rc;
  396. return 0;
  397. }
  398. /**
  399. * Shutdown admin queues
  400. *
  401. * @v intelxl Intel device
  402. * @ret rc Return status code
  403. */
  404. static int intelxl_admin_shutdown ( struct intelxl_nic *intelxl ) {
  405. struct intelxl_admin_descriptor *cmd;
  406. struct intelxl_admin_shutdown_params *shutdown;
  407. int rc;
  408. /* Populate descriptor */
  409. cmd = intelxl_admin_command_descriptor ( intelxl );
  410. cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_SHUTDOWN );
  411. shutdown = &cmd->params.shutdown;
  412. shutdown->unloading = INTELXL_ADMIN_SHUTDOWN_UNLOADING;
  413. /* Issue command */
  414. if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
  415. return rc;
  416. return 0;
  417. }
  418. /**
  419. * Get switch configuration
  420. *
  421. * @v intelxl Intel device
  422. * @ret rc Return status code
  423. */
  424. static int intelxl_admin_switch ( struct intelxl_nic *intelxl ) {
  425. struct intelxl_admin_descriptor *cmd;
  426. struct intelxl_admin_switch_params *sw;
  427. union intelxl_admin_buffer *buf;
  428. int rc;
  429. /* Populate descriptor */
  430. cmd = intelxl_admin_command_descriptor ( intelxl );
  431. cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_SWITCH );
  432. cmd->flags = cpu_to_le16 ( INTELXL_ADMIN_FL_BUF );
  433. cmd->len = cpu_to_le16 ( sizeof ( buf->sw ) );
  434. sw = &cmd->params.sw;
  435. buf = intelxl_admin_command_buffer ( intelxl );
  436. /* Get each configuration in turn */
  437. do {
  438. /* Issue command */
  439. if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
  440. return rc;
  441. /* Dump raw configuration */
  442. DBGC2 ( intelxl, "INTELXL %p SEID %#04x:\n",
  443. intelxl, le16_to_cpu ( buf->sw.cfg.seid ) );
  444. DBGC2_HDA ( intelxl, 0, &buf->sw.cfg, sizeof ( buf->sw.cfg ) );
  445. /* Parse response */
  446. if ( buf->sw.cfg.type == INTELXL_ADMIN_SWITCH_TYPE_VSI ) {
  447. intelxl->vsi = le16_to_cpu ( buf->sw.cfg.seid );
  448. DBGC ( intelxl, "INTELXL %p VSI %#04x uplink %#04x "
  449. "downlink %#04x conn %#02x\n", intelxl,
  450. intelxl->vsi, le16_to_cpu ( buf->sw.cfg.uplink ),
  451. le16_to_cpu ( buf->sw.cfg.downlink ),
  452. buf->sw.cfg.connection );
  453. }
  454. } while ( sw->next );
  455. /* Check that we found a VSI */
  456. if ( ! intelxl->vsi ) {
  457. DBGC ( intelxl, "INTELXL %p has no VSI\n", intelxl );
  458. return -ENOENT;
  459. }
  460. return 0;
  461. }
  462. /**
  463. * Get VSI parameters
  464. *
  465. * @v intelxl Intel device
  466. * @ret rc Return status code
  467. */
  468. static int intelxl_admin_vsi ( struct intelxl_nic *intelxl ) {
  469. struct intelxl_admin_descriptor *cmd;
  470. struct intelxl_admin_vsi_params *vsi;
  471. union intelxl_admin_buffer *buf;
  472. int rc;
  473. /* Populate descriptor */
  474. cmd = intelxl_admin_command_descriptor ( intelxl );
  475. cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_VSI );
  476. cmd->flags = cpu_to_le16 ( INTELXL_ADMIN_FL_BUF );
  477. cmd->len = cpu_to_le16 ( sizeof ( buf->vsi ) );
  478. vsi = &cmd->params.vsi;
  479. vsi->vsi = cpu_to_le16 ( intelxl->vsi );
  480. buf = intelxl_admin_command_buffer ( intelxl );
  481. /* Issue command */
  482. if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
  483. return rc;
  484. /* Parse response */
  485. intelxl->queue = le16_to_cpu ( buf->vsi.queue[0] );
  486. intelxl->qset = le16_to_cpu ( buf->vsi.qset[0] );
  487. DBGC ( intelxl, "INTELXL %p VSI %#04x queue %#04x qset %#04x\n",
  488. intelxl, intelxl->vsi, intelxl->queue, intelxl->qset );
  489. return 0;
  490. }
  491. /**
  492. * Set VSI promiscuous modes
  493. *
  494. * @v intelxl Intel device
  495. * @ret rc Return status code
  496. */
  497. static int intelxl_admin_promisc ( struct intelxl_nic *intelxl ) {
  498. struct intelxl_admin_descriptor *cmd;
  499. struct intelxl_admin_promisc_params *promisc;
  500. uint16_t flags;
  501. int rc;
  502. /* Populate descriptor */
  503. cmd = intelxl_admin_command_descriptor ( intelxl );
  504. cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_PROMISC );
  505. flags = ( INTELXL_ADMIN_PROMISC_FL_UNICAST |
  506. INTELXL_ADMIN_PROMISC_FL_MULTICAST |
  507. INTELXL_ADMIN_PROMISC_FL_BROADCAST |
  508. INTELXL_ADMIN_PROMISC_FL_VLAN );
  509. promisc = &cmd->params.promisc;
  510. promisc->flags = cpu_to_le16 ( flags );
  511. promisc->valid = cpu_to_le16 ( flags );
  512. promisc->vsi = cpu_to_le16 ( intelxl->vsi );
  513. /* Issue command */
  514. if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
  515. return rc;
  516. return 0;
  517. }
  518. /**
  519. * Restart autonegotiation
  520. *
  521. * @v intelxl Intel device
  522. * @ret rc Return status code
  523. */
  524. static int intelxl_admin_autoneg ( struct intelxl_nic *intelxl ) {
  525. struct intelxl_admin_descriptor *cmd;
  526. struct intelxl_admin_autoneg_params *autoneg;
  527. int rc;
  528. /* Populate descriptor */
  529. cmd = intelxl_admin_command_descriptor ( intelxl );
  530. cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_AUTONEG );
  531. autoneg = &cmd->params.autoneg;
  532. autoneg->flags = ( INTELXL_ADMIN_AUTONEG_FL_RESTART |
  533. INTELXL_ADMIN_AUTONEG_FL_ENABLE );
  534. /* Issue command */
  535. if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
  536. return rc;
  537. return 0;
  538. }
  539. /**
  540. * Get link status
  541. *
  542. * @v netdev Network device
  543. * @ret rc Return status code
  544. */
  545. static int intelxl_admin_link ( struct net_device *netdev ) {
  546. struct intelxl_nic *intelxl = netdev->priv;
  547. struct intelxl_admin_descriptor *cmd;
  548. struct intelxl_admin_link_params *link;
  549. int rc;
  550. /* Populate descriptor */
  551. cmd = intelxl_admin_command_descriptor ( intelxl );
  552. cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_LINK );
  553. link = &cmd->params.link;
  554. link->notify = INTELXL_ADMIN_LINK_NOTIFY;
  555. /* Issue command */
  556. if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
  557. return rc;
  558. DBGC ( intelxl, "INTELXL %p PHY %#02x speed %#02x status %#02x\n",
  559. intelxl, link->phy, link->speed, link->status );
  560. /* Update network device */
  561. if ( link->status & INTELXL_ADMIN_LINK_UP ) {
  562. netdev_link_up ( netdev );
  563. } else {
  564. netdev_link_down ( netdev );
  565. }
  566. return 0;
  567. }
  568. /**
  569. * Refill admin event queue
  570. *
  571. * @v intelxl Intel device
  572. */
  573. static void intelxl_refill_admin ( struct intelxl_nic *intelxl ) {
  574. struct intelxl_admin *admin = &intelxl->event;
  575. const struct intelxl_admin_offsets *regs = admin->regs;
  576. void *admin_regs = ( intelxl->regs + admin->base );
  577. unsigned int tail;
  578. /* Update tail pointer */
  579. tail = ( ( admin->index + INTELXL_ADMIN_NUM_DESC - 1 ) %
  580. INTELXL_ADMIN_NUM_DESC );
  581. wmb();
  582. writel ( tail, admin_regs + regs->tail );
  583. }
  584. /**
  585. * Poll admin event queue
  586. *
  587. * @v netdev Network device
  588. */
  589. static void intelxl_poll_admin ( struct net_device *netdev ) {
  590. struct intelxl_nic *intelxl = netdev->priv;
  591. struct intelxl_admin *admin = &intelxl->event;
  592. struct intelxl_admin_descriptor *evt;
  593. union intelxl_admin_buffer *buf;
  594. /* Check for events */
  595. while ( 1 ) {
  596. /* Get next event descriptor and data buffer */
  597. evt = &admin->desc[ admin->index % INTELXL_ADMIN_NUM_DESC ];
  598. buf = &admin->buf[ admin->index % INTELXL_ADMIN_NUM_DESC ];
  599. /* Stop if descriptor is not yet completed */
  600. if ( ! ( evt->flags & INTELXL_ADMIN_FL_DD ) )
  601. return;
  602. DBGC2 ( intelxl, "INTELXL %p admin event %#x:\n",
  603. intelxl, admin->index );
  604. DBGC2_HDA ( intelxl, virt_to_phys ( evt ), evt,
  605. sizeof ( *evt ) );
  606. if ( evt->flags & cpu_to_le16 ( INTELXL_ADMIN_FL_BUF ) ) {
  607. DBGC2_HDA ( intelxl, virt_to_phys ( buf ), buf,
  608. le16_to_cpu ( evt->len ) );
  609. }
  610. /* Handle event */
  611. switch ( evt->opcode ) {
  612. case cpu_to_le16 ( INTELXL_ADMIN_LINK ):
  613. intelxl_admin_link ( netdev );
  614. break;
  615. default:
  616. DBGC ( intelxl, "INTELXL %p admin event %#x "
  617. "unrecognised opcode %#04x\n", intelxl,
  618. admin->index, le16_to_cpu ( evt->opcode ) );
  619. break;
  620. }
  621. /* Reset descriptor and refill queue */
  622. intelxl_admin_event_init ( intelxl, admin->index );
  623. admin->index++;
  624. intelxl_refill_admin ( intelxl );
  625. }
  626. }
  627. /**
  628. * Open admin queues
  629. *
  630. * @v intelxl Intel device
  631. * @ret rc Return status code
  632. */
  633. static int intelxl_open_admin ( struct intelxl_nic *intelxl ) {
  634. int rc;
  635. /* Allocate admin event queue */
  636. if ( ( rc = intelxl_alloc_admin ( intelxl, &intelxl->event ) ) != 0 )
  637. goto err_alloc_event;
  638. /* Allocate admin command queue */
  639. if ( ( rc = intelxl_alloc_admin ( intelxl, &intelxl->command ) ) != 0 )
  640. goto err_alloc_command;
  641. /* (Re)open admin queues */
  642. intelxl_reopen_admin ( intelxl );
  643. /* Get firmware version */
  644. if ( ( rc = intelxl_admin_version ( intelxl ) ) != 0 )
  645. goto err_version;
  646. /* Report driver version */
  647. if ( ( rc = intelxl_admin_driver ( intelxl ) ) != 0 )
  648. goto err_driver;
  649. return 0;
  650. err_driver:
  651. err_version:
  652. intelxl_disable_admin ( intelxl, &intelxl->command );
  653. intelxl_disable_admin ( intelxl, &intelxl->event );
  654. intelxl_free_admin ( intelxl, &intelxl->command );
  655. err_alloc_command:
  656. intelxl_free_admin ( intelxl, &intelxl->event );
  657. err_alloc_event:
  658. return rc;
  659. }
  660. /**
  661. * Reopen admin queues (after virtual function reset)
  662. *
  663. * @v intelxl Intel device
  664. */
  665. static void intelxl_reopen_admin ( struct intelxl_nic *intelxl ) {
  666. unsigned int i;
  667. /* Enable admin event queue */
  668. intelxl_enable_admin ( intelxl, &intelxl->event );
  669. /* Enable admin command queue */
  670. intelxl_enable_admin ( intelxl, &intelxl->command );
  671. /* Initialise all admin event queue descriptors */
  672. for ( i = 0 ; i < INTELXL_ADMIN_NUM_DESC ; i++ )
  673. intelxl_admin_event_init ( intelxl, i );
  674. /* Post all descriptors to event queue */
  675. intelxl_refill_admin ( intelxl );
  676. }
  677. /**
  678. * Close admin queues
  679. *
  680. * @v intelxl Intel device
  681. */
  682. static void intelxl_close_admin ( struct intelxl_nic *intelxl ) {
  683. /* Shut down admin queues */
  684. intelxl_admin_shutdown ( intelxl );
  685. /* Disable admin queues */
  686. intelxl_disable_admin ( intelxl, &intelxl->command );
  687. intelxl_disable_admin ( intelxl, &intelxl->event );
  688. /* Free admin queues */
  689. intelxl_free_admin ( intelxl, &intelxl->command );
  690. intelxl_free_admin ( intelxl, &intelxl->event );
  691. }
  692. /******************************************************************************
  693. *
  694. * Descriptor rings
  695. *
  696. ******************************************************************************
  697. */
  698. /**
  699. * Dump queue context (for debugging)
  700. *
  701. * @v intelxl Intel device
  702. * @v op Context operation
  703. * @v len Size of context
  704. */
  705. static __attribute__ (( unused )) void
  706. intelxl_context_dump ( struct intelxl_nic *intelxl, uint32_t op, size_t len ) {
  707. struct intelxl_context_line line;
  708. uint32_t pfcm_lanctxctl;
  709. uint32_t pfcm_lanctxstat;
  710. unsigned int queue;
  711. unsigned int index;
  712. unsigned int i;
  713. /* Do nothing unless debug output is enabled */
  714. if ( ! DBG_EXTRA )
  715. return;
  716. /* Dump context */
  717. DBGC2 ( intelxl, "INTELXL %p context %#08x:\n", intelxl, op );
  718. for ( index = 0 ; ( sizeof ( line ) * index ) < len ; index++ ) {
  719. /* Start context operation */
  720. queue = ( intelxl->base + intelxl->queue );
  721. pfcm_lanctxctl =
  722. ( INTELXL_PFCM_LANCTXCTL_QUEUE_NUM ( queue ) |
  723. INTELXL_PFCM_LANCTXCTL_SUB_LINE ( index ) |
  724. INTELXL_PFCM_LANCTXCTL_OP_CODE_READ | op );
  725. writel ( pfcm_lanctxctl,
  726. intelxl->regs + INTELXL_PFCM_LANCTXCTL );
  727. /* Wait for operation to complete */
  728. for ( i = 0 ; i < INTELXL_CTX_MAX_WAIT_MS ; i++ ) {
  729. /* Check if operation is complete */
  730. pfcm_lanctxstat = readl ( intelxl->regs +
  731. INTELXL_PFCM_LANCTXSTAT );
  732. if ( pfcm_lanctxstat & INTELXL_PFCM_LANCTXSTAT_DONE )
  733. break;
  734. /* Delay */
  735. mdelay ( 1 );
  736. }
  737. /* Read context data */
  738. for ( i = 0 ; i < ( sizeof ( line ) /
  739. sizeof ( line.raw[0] ) ) ; i++ ) {
  740. line.raw[i] = readl ( intelxl->regs +
  741. INTELXL_PFCM_LANCTXDATA ( i ) );
  742. }
  743. DBGC2_HDA ( intelxl, ( sizeof ( line ) * index ),
  744. &line, sizeof ( line ) );
  745. }
  746. }
  747. /**
  748. * Program queue context line
  749. *
  750. * @v intelxl Intel device
  751. * @v line Queue context line
  752. * @v index Line number
  753. * @v op Context operation
  754. * @ret rc Return status code
  755. */
  756. static int intelxl_context_line ( struct intelxl_nic *intelxl,
  757. struct intelxl_context_line *line,
  758. unsigned int index, uint32_t op ) {
  759. uint32_t pfcm_lanctxctl;
  760. uint32_t pfcm_lanctxstat;
  761. unsigned int queue;
  762. unsigned int i;
  763. /* Write context data */
  764. for ( i = 0; i < ( sizeof ( *line ) / sizeof ( line->raw[0] ) ); i++ ) {
  765. writel ( le32_to_cpu ( line->raw[i] ),
  766. intelxl->regs + INTELXL_PFCM_LANCTXDATA ( i ) );
  767. }
  768. /* Start context operation */
  769. queue = ( intelxl->base + intelxl->queue );
  770. pfcm_lanctxctl = ( INTELXL_PFCM_LANCTXCTL_QUEUE_NUM ( queue ) |
  771. INTELXL_PFCM_LANCTXCTL_SUB_LINE ( index ) |
  772. INTELXL_PFCM_LANCTXCTL_OP_CODE_WRITE | op );
  773. writel ( pfcm_lanctxctl, intelxl->regs + INTELXL_PFCM_LANCTXCTL );
  774. /* Wait for operation to complete */
  775. for ( i = 0 ; i < INTELXL_CTX_MAX_WAIT_MS ; i++ ) {
  776. /* Check if operation is complete */
  777. pfcm_lanctxstat = readl ( intelxl->regs +
  778. INTELXL_PFCM_LANCTXSTAT );
  779. if ( pfcm_lanctxstat & INTELXL_PFCM_LANCTXSTAT_DONE )
  780. return 0;
  781. /* Delay */
  782. mdelay ( 1 );
  783. }
  784. DBGC ( intelxl, "INTELXL %p timed out waiting for context: %#08x\n",
  785. intelxl, pfcm_lanctxctl );
  786. return -ETIMEDOUT;
  787. }
  788. /**
  789. * Program queue context
  790. *
  791. * @v intelxl Intel device
  792. * @v line Queue context lines
  793. * @v len Size of context
  794. * @v op Context operation
  795. * @ret rc Return status code
  796. */
  797. static int intelxl_context ( struct intelxl_nic *intelxl,
  798. struct intelxl_context_line *line,
  799. size_t len, uint32_t op ) {
  800. unsigned int index;
  801. int rc;
  802. DBGC2 ( intelxl, "INTELXL %p context %#08x len %#zx:\n",
  803. intelxl, op, len );
  804. DBGC2_HDA ( intelxl, 0, line, len );
  805. /* Program one line at a time */
  806. for ( index = 0 ; ( sizeof ( *line ) * index ) < len ; index++ ) {
  807. if ( ( rc = intelxl_context_line ( intelxl, line++, index,
  808. op ) ) != 0 )
  809. return rc;
  810. }
  811. return 0;
  812. }
  813. /**
  814. * Program transmit queue context
  815. *
  816. * @v intelxl Intel device
  817. * @v address Descriptor ring base address
  818. * @ret rc Return status code
  819. */
  820. static int intelxl_context_tx ( struct intelxl_nic *intelxl,
  821. physaddr_t address ) {
  822. union {
  823. struct intelxl_context_tx tx;
  824. struct intelxl_context_line line;
  825. } ctx;
  826. int rc;
  827. /* Initialise context */
  828. memset ( &ctx, 0, sizeof ( ctx ) );
  829. ctx.tx.flags = cpu_to_le16 ( INTELXL_CTX_TX_FL_NEW );
  830. ctx.tx.base = cpu_to_le64 ( INTELXL_CTX_TX_BASE ( address ) );
  831. ctx.tx.count =
  832. cpu_to_le16 ( INTELXL_CTX_TX_COUNT ( INTELXL_TX_NUM_DESC ) );
  833. ctx.tx.qset = INTELXL_CTX_TX_QSET ( intelxl->qset );
  834. /* Program context */
  835. if ( ( rc = intelxl_context ( intelxl, &ctx.line, sizeof ( ctx ),
  836. INTELXL_PFCM_LANCTXCTL_TYPE_TX ) ) != 0 )
  837. return rc;
  838. return 0;
  839. }
  840. /**
  841. * Program receive queue context
  842. *
  843. * @v intelxl Intel device
  844. * @v address Descriptor ring base address
  845. * @ret rc Return status code
  846. */
  847. static int intelxl_context_rx ( struct intelxl_nic *intelxl,
  848. physaddr_t address ) {
  849. union {
  850. struct intelxl_context_rx rx;
  851. struct intelxl_context_line line;
  852. } ctx;
  853. uint64_t base_count;
  854. int rc;
  855. /* Initialise context */
  856. memset ( &ctx, 0, sizeof ( ctx ) );
  857. base_count = INTELXL_CTX_RX_BASE_COUNT ( address, INTELXL_RX_NUM_DESC );
  858. ctx.rx.base_count = cpu_to_le64 ( base_count );
  859. ctx.rx.len = cpu_to_le16 ( INTELXL_CTX_RX_LEN ( intelxl->mfs ) );
  860. ctx.rx.flags = INTELXL_CTX_RX_FL_CRCSTRIP;
  861. ctx.rx.mfs = cpu_to_le16 ( INTELXL_CTX_RX_MFS ( intelxl->mfs ) );
  862. /* Program context */
  863. if ( ( rc = intelxl_context ( intelxl, &ctx.line, sizeof ( ctx ),
  864. INTELXL_PFCM_LANCTXCTL_TYPE_RX ) ) != 0 )
  865. return rc;
  866. return 0;
  867. }
  868. /**
  869. * Enable descriptor ring
  870. *
  871. * @v intelxl Intel device
  872. * @v ring Descriptor ring
  873. * @ret rc Return status code
  874. */
  875. static int intelxl_enable_ring ( struct intelxl_nic *intelxl,
  876. struct intelxl_ring *ring ) {
  877. void *ring_regs = ( intelxl->regs + ring->reg );
  878. uint32_t qxx_ena;
  879. /* Enable ring */
  880. writel ( INTELXL_QXX_ENA_REQ, ( ring_regs + INTELXL_QXX_ENA ) );
  881. udelay ( INTELXL_QUEUE_ENABLE_DELAY_US );
  882. qxx_ena = readl ( ring_regs + INTELXL_QXX_ENA );
  883. if ( ! ( qxx_ena & INTELXL_QXX_ENA_STAT ) ) {
  884. DBGC ( intelxl, "INTELXL %p ring %06x failed to enable: "
  885. "%#08x\n", intelxl, ring->reg, qxx_ena );
  886. return -EIO;
  887. }
  888. return 0;
  889. }
  890. /**
  891. * Disable descriptor ring
  892. *
  893. * @v intelxl Intel device
  894. * @v ring Descriptor ring
  895. * @ret rc Return status code
  896. */
  897. static int intelxl_disable_ring ( struct intelxl_nic *intelxl,
  898. struct intelxl_ring *ring ) {
  899. void *ring_regs = ( intelxl->regs + ring->reg );
  900. uint32_t qxx_ena;
  901. unsigned int i;
  902. /* Disable ring */
  903. writel ( 0, ( ring_regs + INTELXL_QXX_ENA ) );
  904. /* Wait for ring to be disabled */
  905. for ( i = 0 ; i < INTELXL_QUEUE_DISABLE_MAX_WAIT_MS ; i++ ) {
  906. /* Check if ring is disabled */
  907. qxx_ena = readl ( ring_regs + INTELXL_QXX_ENA );
  908. if ( ! ( qxx_ena & INTELXL_QXX_ENA_STAT ) )
  909. return 0;
  910. /* Delay */
  911. mdelay ( 1 );
  912. }
  913. DBGC ( intelxl, "INTELXL %p ring %06x timed out waiting for disable: "
  914. "%#08x\n", intelxl, ring->reg, qxx_ena );
  915. return -ETIMEDOUT;
  916. }
  917. /**
  918. * Create descriptor ring
  919. *
  920. * @v intelxl Intel device
  921. * @v ring Descriptor ring
  922. * @ret rc Return status code
  923. */
  924. static int intelxl_create_ring ( struct intelxl_nic *intelxl,
  925. struct intelxl_ring *ring ) {
  926. void *ring_regs = ( intelxl->regs + ring->reg );
  927. physaddr_t address;
  928. int rc;
  929. /* Allocate descriptor ring */
  930. ring->desc = malloc_dma ( ring->len, INTELXL_ALIGN );
  931. if ( ! ring->desc ) {
  932. rc = -ENOMEM;
  933. goto err_alloc;
  934. }
  935. /* Initialise descriptor ring */
  936. memset ( ring->desc, 0, ring->len );
  937. /* Reset tail pointer */
  938. writel ( 0, ( ring_regs + INTELXL_QXX_TAIL ) );
  939. /* Program queue context */
  940. address = virt_to_bus ( ring->desc );
  941. if ( ( rc = ring->context ( intelxl, address ) ) != 0 )
  942. goto err_context;
  943. /* Enable ring */
  944. if ( ( rc = intelxl_enable_ring ( intelxl, ring ) ) != 0 )
  945. goto err_enable;
  946. /* Reset counters */
  947. ring->prod = 0;
  948. ring->cons = 0;
  949. DBGC ( intelxl, "INTELXL %p ring %06x is at [%08llx,%08llx)\n",
  950. intelxl, ring->reg, ( ( unsigned long long ) address ),
  951. ( ( unsigned long long ) address + ring->len ) );
  952. return 0;
  953. intelxl_disable_ring ( intelxl, ring );
  954. err_enable:
  955. err_context:
  956. free_dma ( ring->desc, ring->len );
  957. err_alloc:
  958. return rc;
  959. }
  960. /**
  961. * Destroy descriptor ring
  962. *
  963. * @v intelxl Intel device
  964. * @v ring Descriptor ring
  965. */
  966. static void intelxl_destroy_ring ( struct intelxl_nic *intelxl,
  967. struct intelxl_ring *ring ) {
  968. int rc;
  969. /* Disable ring */
  970. if ( ( rc = intelxl_disable_ring ( intelxl, ring ) ) != 0 ) {
  971. /* Leak memory; there's nothing else we can do */
  972. return;
  973. }
  974. /* Free descriptor ring */
  975. free_dma ( ring->desc, ring->len );
  976. ring->desc = NULL;
  977. }
  978. /**
  979. * Refill receive descriptor ring
  980. *
  981. * @v intelxl Intel device
  982. */
  983. static void intelxl_refill_rx ( struct intelxl_nic *intelxl ) {
  984. struct intelxl_rx_data_descriptor *rx;
  985. struct io_buffer *iobuf;
  986. unsigned int rx_idx;
  987. unsigned int rx_tail;
  988. physaddr_t address;
  989. unsigned int refilled = 0;
  990. /* Refill ring */
  991. while ( ( intelxl->rx.prod - intelxl->rx.cons ) < INTELXL_RX_FILL ) {
  992. /* Allocate I/O buffer */
  993. iobuf = alloc_iob ( intelxl->mfs );
  994. if ( ! iobuf ) {
  995. /* Wait for next refill */
  996. break;
  997. }
  998. /* Get next receive descriptor */
  999. rx_idx = ( intelxl->rx.prod++ % INTELXL_RX_NUM_DESC );
  1000. rx = &intelxl->rx.desc[rx_idx].rx;
  1001. /* Populate receive descriptor */
  1002. address = virt_to_bus ( iobuf->data );
  1003. rx->address = cpu_to_le64 ( address );
  1004. rx->flags = 0;
  1005. /* Record I/O buffer */
  1006. assert ( intelxl->rx_iobuf[rx_idx] == NULL );
  1007. intelxl->rx_iobuf[rx_idx] = iobuf;
  1008. DBGC2 ( intelxl, "INTELXL %p RX %d is [%llx,%llx)\n", intelxl,
  1009. rx_idx, ( ( unsigned long long ) address ),
  1010. ( ( unsigned long long ) address + intelxl->mfs ) );
  1011. refilled++;
  1012. }
  1013. /* Push descriptors to card, if applicable */
  1014. if ( refilled ) {
  1015. wmb();
  1016. rx_tail = ( intelxl->rx.prod % INTELXL_RX_NUM_DESC );
  1017. writel ( rx_tail,
  1018. ( intelxl->regs + intelxl->rx.reg + INTELXL_QXX_TAIL));
  1019. }
  1020. }
  1021. /******************************************************************************
  1022. *
  1023. * Network device interface
  1024. *
  1025. ******************************************************************************
  1026. */
  1027. /**
  1028. * Open network device
  1029. *
  1030. * @v netdev Network device
  1031. * @ret rc Return status code
  1032. */
  1033. static int intelxl_open ( struct net_device *netdev ) {
  1034. struct intelxl_nic *intelxl = netdev->priv;
  1035. union intelxl_receive_address mac;
  1036. unsigned int queue;
  1037. uint32_t prtgl_sal;
  1038. uint32_t prtgl_sah;
  1039. int rc;
  1040. /* Calculate maximum frame size */
  1041. intelxl->mfs = ( ( ETH_HLEN + netdev->mtu + 4 /* CRC */ +
  1042. INTELXL_ALIGN - 1 ) & ~( INTELXL_ALIGN - 1 ) );
  1043. /* Program MAC address and maximum frame size */
  1044. memset ( &mac, 0, sizeof ( mac ) );
  1045. memcpy ( mac.raw, netdev->ll_addr, sizeof ( mac.raw ) );
  1046. prtgl_sal = le32_to_cpu ( mac.reg.low );
  1047. prtgl_sah = ( le32_to_cpu ( mac.reg.high ) |
  1048. INTELXL_PRTGL_SAH_MFS_SET ( intelxl->mfs ) );
  1049. writel ( prtgl_sal, intelxl->regs + INTELXL_PRTGL_SAL );
  1050. writel ( prtgl_sah, intelxl->regs + INTELXL_PRTGL_SAH );
  1051. /* Associate transmit queue to PF */
  1052. writel ( ( INTELXL_QXX_CTL_PFVF_Q_PF |
  1053. INTELXL_QXX_CTL_PFVF_PF_INDX ( intelxl->pf ) ),
  1054. ( intelxl->regs + intelxl->tx.reg + INTELXL_QXX_CTL ) );
  1055. /* Clear transmit pre queue disable */
  1056. queue = ( intelxl->base + intelxl->queue );
  1057. writel ( ( INTELXL_GLLAN_TXPRE_QDIS_CLEAR_QDIS |
  1058. INTELXL_GLLAN_TXPRE_QDIS_QINDX ( queue ) ),
  1059. ( intelxl->regs + INTELXL_GLLAN_TXPRE_QDIS ( queue ) ) );
  1060. /* Reset transmit queue head */
  1061. writel ( 0, ( intelxl->regs + INTELXL_QTX_HEAD ( intelxl->queue ) ) );
  1062. /* Create receive descriptor ring */
  1063. if ( ( rc = intelxl_create_ring ( intelxl, &intelxl->rx ) ) != 0 )
  1064. goto err_create_rx;
  1065. /* Create transmit descriptor ring */
  1066. if ( ( rc = intelxl_create_ring ( intelxl, &intelxl->tx ) ) != 0 )
  1067. goto err_create_tx;
  1068. /* Fill receive ring */
  1069. intelxl_refill_rx ( intelxl );
  1070. /* Restart autonegotiation */
  1071. intelxl_admin_autoneg ( intelxl );
  1072. /* Update link state */
  1073. intelxl_admin_link ( netdev );
  1074. return 0;
  1075. writel ( ( INTELXL_GLLAN_TXPRE_QDIS_SET_QDIS |
  1076. INTELXL_GLLAN_TXPRE_QDIS_QINDX ( queue ) ),
  1077. ( intelxl->regs + INTELXL_GLLAN_TXPRE_QDIS ( queue ) ) );
  1078. udelay ( INTELXL_QUEUE_PRE_DISABLE_DELAY_US );
  1079. intelxl_destroy_ring ( intelxl, &intelxl->tx );
  1080. err_create_tx:
  1081. intelxl_destroy_ring ( intelxl, &intelxl->rx );
  1082. err_create_rx:
  1083. return rc;
  1084. }
  1085. /**
  1086. * Close network device
  1087. *
  1088. * @v netdev Network device
  1089. */
  1090. static void intelxl_close ( struct net_device *netdev ) {
  1091. struct intelxl_nic *intelxl = netdev->priv;
  1092. unsigned int queue;
  1093. unsigned int i;
  1094. /* Dump contexts (for debugging) */
  1095. intelxl_context_dump ( intelxl, INTELXL_PFCM_LANCTXCTL_TYPE_TX,
  1096. sizeof ( struct intelxl_context_tx ) );
  1097. intelxl_context_dump ( intelxl, INTELXL_PFCM_LANCTXCTL_TYPE_RX,
  1098. sizeof ( struct intelxl_context_rx ) );
  1099. /* Pre-disable transmit queue */
  1100. queue = ( intelxl->base + intelxl->queue );
  1101. writel ( ( INTELXL_GLLAN_TXPRE_QDIS_SET_QDIS |
  1102. INTELXL_GLLAN_TXPRE_QDIS_QINDX ( queue ) ),
  1103. ( intelxl->regs + INTELXL_GLLAN_TXPRE_QDIS ( queue ) ) );
  1104. udelay ( INTELXL_QUEUE_PRE_DISABLE_DELAY_US );
  1105. /* Destroy transmit descriptor ring */
  1106. intelxl_destroy_ring ( intelxl, &intelxl->tx );
  1107. /* Destroy receive descriptor ring */
  1108. intelxl_destroy_ring ( intelxl, &intelxl->rx );
  1109. /* Discard any unused receive buffers */
  1110. for ( i = 0 ; i < INTELXL_RX_NUM_DESC ; i++ ) {
  1111. if ( intelxl->rx_iobuf[i] )
  1112. free_iob ( intelxl->rx_iobuf[i] );
  1113. intelxl->rx_iobuf[i] = NULL;
  1114. }
  1115. }
  1116. /**
  1117. * Transmit packet
  1118. *
  1119. * @v netdev Network device
  1120. * @v iobuf I/O buffer
  1121. * @ret rc Return status code
  1122. */
  1123. static int intelxl_transmit ( struct net_device *netdev,
  1124. struct io_buffer *iobuf ) {
  1125. struct intelxl_nic *intelxl = netdev->priv;
  1126. struct intelxl_tx_data_descriptor *tx;
  1127. unsigned int tx_idx;
  1128. unsigned int tx_tail;
  1129. physaddr_t address;
  1130. size_t len;
  1131. /* Get next transmit descriptor */
  1132. if ( ( intelxl->tx.prod - intelxl->tx.cons ) >= INTELXL_TX_FILL ) {
  1133. DBGC ( intelxl, "INTELXL %p out of transmit descriptors\n",
  1134. intelxl );
  1135. return -ENOBUFS;
  1136. }
  1137. tx_idx = ( intelxl->tx.prod++ % INTELXL_TX_NUM_DESC );
  1138. tx_tail = ( intelxl->tx.prod % INTELXL_TX_NUM_DESC );
  1139. tx = &intelxl->tx.desc[tx_idx].tx;
  1140. /* Populate transmit descriptor */
  1141. address = virt_to_bus ( iobuf->data );
  1142. len = iob_len ( iobuf );
  1143. tx->address = cpu_to_le64 ( address );
  1144. tx->len = cpu_to_le32 ( INTELXL_TX_DATA_LEN ( len ) );
  1145. tx->flags = cpu_to_le32 ( INTELXL_TX_DATA_DTYP | INTELXL_TX_DATA_EOP |
  1146. INTELXL_TX_DATA_RS | INTELXL_TX_DATA_JFDI );
  1147. wmb();
  1148. /* Notify card that there are packets ready to transmit */
  1149. writel ( tx_tail,
  1150. ( intelxl->regs + intelxl->tx.reg + INTELXL_QXX_TAIL ) );
  1151. DBGC2 ( intelxl, "INTELXL %p TX %d is [%llx,%llx)\n", intelxl, tx_idx,
  1152. ( ( unsigned long long ) address ),
  1153. ( ( unsigned long long ) address + len ) );
  1154. return 0;
  1155. }
  1156. /**
  1157. * Poll for completed packets
  1158. *
  1159. * @v netdev Network device
  1160. */
  1161. static void intelxl_poll_tx ( struct net_device *netdev ) {
  1162. struct intelxl_nic *intelxl = netdev->priv;
  1163. struct intelxl_tx_writeback_descriptor *tx_wb;
  1164. unsigned int tx_idx;
  1165. /* Check for completed packets */
  1166. while ( intelxl->tx.cons != intelxl->tx.prod ) {
  1167. /* Get next transmit descriptor */
  1168. tx_idx = ( intelxl->tx.cons % INTELXL_TX_NUM_DESC );
  1169. tx_wb = &intelxl->tx.desc[tx_idx].tx_wb;
  1170. /* Stop if descriptor is still in use */
  1171. if ( ! ( tx_wb->flags & INTELXL_TX_WB_FL_DD ) )
  1172. return;
  1173. DBGC2 ( intelxl, "INTELXL %p TX %d complete\n",
  1174. intelxl, tx_idx );
  1175. /* Complete TX descriptor */
  1176. netdev_tx_complete_next ( netdev );
  1177. intelxl->tx.cons++;
  1178. }
  1179. }
  1180. /**
  1181. * Poll for received packets
  1182. *
  1183. * @v netdev Network device
  1184. */
  1185. static void intelxl_poll_rx ( struct net_device *netdev ) {
  1186. struct intelxl_nic *intelxl = netdev->priv;
  1187. struct intelxl_rx_writeback_descriptor *rx_wb;
  1188. struct io_buffer *iobuf;
  1189. unsigned int rx_idx;
  1190. unsigned int tag;
  1191. size_t len;
  1192. /* Check for received packets */
  1193. while ( intelxl->rx.cons != intelxl->rx.prod ) {
  1194. /* Get next receive descriptor */
  1195. rx_idx = ( intelxl->rx.cons % INTELXL_RX_NUM_DESC );
  1196. rx_wb = &intelxl->rx.desc[rx_idx].rx_wb;
  1197. /* Stop if descriptor is still in use */
  1198. if ( ! ( rx_wb->flags & cpu_to_le32 ( INTELXL_RX_WB_FL_DD ) ) )
  1199. return;
  1200. /* Populate I/O buffer */
  1201. iobuf = intelxl->rx_iobuf[rx_idx];
  1202. intelxl->rx_iobuf[rx_idx] = NULL;
  1203. len = INTELXL_RX_WB_LEN ( le32_to_cpu ( rx_wb->len ) );
  1204. iob_put ( iobuf, len );
  1205. /* Find VLAN device, if applicable */
  1206. if ( rx_wb->flags & cpu_to_le32 ( INTELXL_RX_WB_FL_VLAN ) ) {
  1207. tag = VLAN_TAG ( le16_to_cpu ( rx_wb->vlan ) );
  1208. } else {
  1209. tag = 0;
  1210. }
  1211. /* Hand off to network stack */
  1212. if ( rx_wb->flags & cpu_to_le32 ( INTELXL_RX_WB_FL_RXE ) ) {
  1213. DBGC ( intelxl, "INTELXL %p RX %d error (length %zd, "
  1214. "flags %08x)\n", intelxl, rx_idx, len,
  1215. le32_to_cpu ( rx_wb->flags ) );
  1216. vlan_netdev_rx_err ( netdev, tag, iobuf, -EIO );
  1217. } else {
  1218. DBGC2 ( intelxl, "INTELXL %p RX %d complete (length "
  1219. "%zd)\n", intelxl, rx_idx, len );
  1220. vlan_netdev_rx ( netdev, tag, iobuf );
  1221. }
  1222. intelxl->rx.cons++;
  1223. }
  1224. }
  1225. /**
  1226. * Poll for completed and received packets
  1227. *
  1228. * @v netdev Network device
  1229. */
  1230. static void intelxl_poll ( struct net_device *netdev ) {
  1231. struct intelxl_nic *intelxl = netdev->priv;
  1232. /* Acknowledge interrupts, if applicable */
  1233. if ( netdev_irq_enabled ( netdev ) ) {
  1234. writel ( ( INTELXL_PFINT_DYN_CTL0_CLEARPBA |
  1235. INTELXL_PFINT_DYN_CTL0_INTENA_MASK ),
  1236. intelxl->regs + INTELXL_PFINT_DYN_CTL0 );
  1237. }
  1238. /* Poll for completed packets */
  1239. intelxl_poll_tx ( netdev );
  1240. /* Poll for received packets */
  1241. intelxl_poll_rx ( netdev );
  1242. /* Poll for admin events */
  1243. intelxl_poll_admin ( netdev );
  1244. /* Refill RX ring */
  1245. intelxl_refill_rx ( intelxl );
  1246. }
  1247. /**
  1248. * Enable or disable interrupts
  1249. *
  1250. * @v netdev Network device
  1251. * @v enable Interrupts should be enabled
  1252. */
  1253. static void intelxl_irq ( struct net_device *netdev, int enable ) {
  1254. struct intelxl_nic *intelxl = netdev->priv;
  1255. if ( enable ) {
  1256. writel ( INTELXL_PFINT_DYN_CTL0_INTENA,
  1257. intelxl->regs + INTELXL_PFINT_DYN_CTL0 );
  1258. } else {
  1259. writel ( 0, intelxl->regs + INTELXL_PFINT_DYN_CTL0 );
  1260. }
  1261. }
  1262. /** Network device operations */
  1263. static struct net_device_operations intelxl_operations = {
  1264. .open = intelxl_open,
  1265. .close = intelxl_close,
  1266. .transmit = intelxl_transmit,
  1267. .poll = intelxl_poll,
  1268. .irq = intelxl_irq,
  1269. };
  1270. /******************************************************************************
  1271. *
  1272. * PCI interface
  1273. *
  1274. ******************************************************************************
  1275. */
  1276. /**
  1277. * Probe PCI device
  1278. *
  1279. * @v pci PCI device
  1280. * @ret rc Return status code
  1281. */
  1282. static int intelxl_probe ( struct pci_device *pci ) {
  1283. struct net_device *netdev;
  1284. struct intelxl_nic *intelxl;
  1285. uint32_t pfgen_portnum;
  1286. uint32_t pflan_qalloc;
  1287. int rc;
  1288. /* Allocate and initialise net device */
  1289. netdev = alloc_etherdev ( sizeof ( *intelxl ) );
  1290. if ( ! netdev ) {
  1291. rc = -ENOMEM;
  1292. goto err_alloc;
  1293. }
  1294. netdev_init ( netdev, &intelxl_operations );
  1295. intelxl = netdev->priv;
  1296. pci_set_drvdata ( pci, netdev );
  1297. netdev->dev = &pci->dev;
  1298. memset ( intelxl, 0, sizeof ( *intelxl ) );
  1299. intelxl->pf = PCI_FUNC ( pci->busdevfn );
  1300. intelxl_init_admin ( &intelxl->command, INTELXL_ADMIN_CMD,
  1301. &intelxl_admin_offsets );
  1302. intelxl_init_admin ( &intelxl->event, INTELXL_ADMIN_EVT,
  1303. &intelxl_admin_offsets );
  1304. intelxl_init_ring ( &intelxl->tx, INTELXL_TX_NUM_DESC,
  1305. intelxl_context_tx );
  1306. intelxl_init_ring ( &intelxl->rx, INTELXL_RX_NUM_DESC,
  1307. intelxl_context_rx );
  1308. /* Fix up PCI device */
  1309. adjust_pci_device ( pci );
  1310. /* Map registers */
  1311. intelxl->regs = ioremap ( pci->membase, INTELXL_BAR_SIZE );
  1312. if ( ! intelxl->regs ) {
  1313. rc = -ENODEV;
  1314. goto err_ioremap;
  1315. }
  1316. /* Reset the NIC */
  1317. if ( ( rc = intelxl_reset ( intelxl ) ) != 0 )
  1318. goto err_reset;
  1319. /* Get port number and base queue number */
  1320. pfgen_portnum = readl ( intelxl->regs + INTELXL_PFGEN_PORTNUM );
  1321. intelxl->port = INTELXL_PFGEN_PORTNUM_PORT_NUM ( pfgen_portnum );
  1322. pflan_qalloc = readl ( intelxl->regs + INTELXL_PFLAN_QALLOC );
  1323. intelxl->base = INTELXL_PFLAN_QALLOC_FIRSTQ ( pflan_qalloc );
  1324. DBGC ( intelxl, "INTELXL %p PF %d using port %d queues [%#04x-%#04x]\n",
  1325. intelxl, intelxl->pf, intelxl->port, intelxl->base,
  1326. INTELXL_PFLAN_QALLOC_LASTQ ( pflan_qalloc ) );
  1327. /* Fetch MAC address and maximum frame size */
  1328. if ( ( rc = intelxl_fetch_mac ( intelxl, netdev ) ) != 0 )
  1329. goto err_fetch_mac;
  1330. /* Open admin queues */
  1331. if ( ( rc = intelxl_open_admin ( intelxl ) ) != 0 )
  1332. goto err_open_admin;
  1333. /* Get switch configuration */
  1334. if ( ( rc = intelxl_admin_switch ( intelxl ) ) != 0 )
  1335. goto err_admin_switch;
  1336. /* Get VSI configuration */
  1337. if ( ( rc = intelxl_admin_vsi ( intelxl ) ) != 0 )
  1338. goto err_admin_vsi;
  1339. /* Configure switch for promiscuous mode */
  1340. if ( ( rc = intelxl_admin_promisc ( intelxl ) ) != 0 )
  1341. goto err_admin_promisc;
  1342. /* Configure queue register addresses */
  1343. intelxl->tx.reg = INTELXL_QTX ( intelxl->queue );
  1344. intelxl->rx.reg = INTELXL_QRX ( intelxl->queue );
  1345. /* Configure interrupt causes */
  1346. writel ( ( INTELXL_QINT_TQCTL_NEXTQ_INDX_NONE |
  1347. INTELXL_QINT_TQCTL_CAUSE_ENA ),
  1348. intelxl->regs + INTELXL_QINT_TQCTL ( intelxl->queue ) );
  1349. writel ( ( INTELXL_QINT_RQCTL_NEXTQ_INDX ( intelxl->queue ) |
  1350. INTELXL_QINT_RQCTL_NEXTQ_TYPE_TX |
  1351. INTELXL_QINT_RQCTL_CAUSE_ENA ),
  1352. intelxl->regs + INTELXL_QINT_RQCTL ( intelxl->queue ) );
  1353. writel ( ( INTELXL_PFINT_LNKLST0_FIRSTQ_INDX ( intelxl->queue ) |
  1354. INTELXL_PFINT_LNKLST0_FIRSTQ_TYPE_RX ),
  1355. intelxl->regs + INTELXL_PFINT_LNKLST0 );
  1356. writel ( INTELXL_PFINT_ICR0_ENA_ADMINQ,
  1357. intelxl->regs + INTELXL_PFINT_ICR0_ENA );
  1358. /* Register network device */
  1359. if ( ( rc = register_netdev ( netdev ) ) != 0 )
  1360. goto err_register_netdev;
  1361. /* Set initial link state */
  1362. intelxl_admin_link ( netdev );
  1363. return 0;
  1364. unregister_netdev ( netdev );
  1365. err_register_netdev:
  1366. err_admin_promisc:
  1367. err_admin_vsi:
  1368. err_admin_switch:
  1369. intelxl_close_admin ( intelxl );
  1370. err_open_admin:
  1371. err_fetch_mac:
  1372. intelxl_reset ( intelxl );
  1373. err_reset:
  1374. iounmap ( intelxl->regs );
  1375. err_ioremap:
  1376. netdev_nullify ( netdev );
  1377. netdev_put ( netdev );
  1378. err_alloc:
  1379. return rc;
  1380. }
  1381. /**
  1382. * Remove PCI device
  1383. *
  1384. * @v pci PCI device
  1385. */
  1386. static void intelxl_remove ( struct pci_device *pci ) {
  1387. struct net_device *netdev = pci_get_drvdata ( pci );
  1388. struct intelxl_nic *intelxl = netdev->priv;
  1389. /* Unregister network device */
  1390. unregister_netdev ( netdev );
  1391. /* Close admin queues */
  1392. intelxl_close_admin ( intelxl );
  1393. /* Reset the NIC */
  1394. intelxl_reset ( intelxl );
  1395. /* Free network device */
  1396. iounmap ( intelxl->regs );
  1397. netdev_nullify ( netdev );
  1398. netdev_put ( netdev );
  1399. }
  1400. /** PCI device IDs */
  1401. static struct pci_device_id intelxl_nics[] = {
  1402. PCI_ROM ( 0x8086, 0x1572, "x710-sfp", "X710 10GbE SFP+", 0 ),
  1403. PCI_ROM ( 0x8086, 0x1574, "xl710-qemu", "Virtual XL710", 0 ),
  1404. PCI_ROM ( 0x8086, 0x1580, "xl710-kx-b", "XL710 40GbE backplane", 0 ),
  1405. PCI_ROM ( 0x8086, 0x1581, "xl710-kx-c", "XL710 10GbE backplane", 0 ),
  1406. PCI_ROM ( 0x8086, 0x1583, "xl710-qda2", "XL710 40GbE QSFP+", 0 ),
  1407. PCI_ROM ( 0x8086, 0x1584, "xl710-qda1", "XL710 40GbE QSFP+", 0 ),
  1408. PCI_ROM ( 0x8086, 0x1585, "x710-qsfp", "X710 10GbE QSFP+", 0 ),
  1409. PCI_ROM ( 0x8086, 0x1586, "x710-10gt", "X710 10GBASE-T", 0 ),
  1410. PCI_ROM ( 0x8086, 0x1587, "x710-kr2", "XL710 20GbE backplane", 0 ),
  1411. PCI_ROM ( 0x8086, 0x1588, "x710-kr2-a", "XL710 20GbE backplane", 0 ),
  1412. PCI_ROM ( 0x8086, 0x1589, "x710-10gt4", "X710 10GBASE-T4", 0 ),
  1413. PCI_ROM ( 0x8086, 0x158a, "xxv710", "XXV710 25GbE backplane", 0 ),
  1414. PCI_ROM ( 0x8086, 0x158b, "xxv710-sfp28", "XXV710 25GbE SFP28", 0 ),
  1415. PCI_ROM ( 0x8086, 0x37ce, "x722-kx", "X722 10GbE backplane", 0 ),
  1416. PCI_ROM ( 0x8086, 0x37cf, "x722-qsfp", "X722 10GbE QSFP+", 0 ),
  1417. PCI_ROM ( 0x8086, 0x37d0, "x722-sfp", "X722 10GbE SFP+", 0 ),
  1418. PCI_ROM ( 0x8086, 0x37d1, "x722-1gt", "X722 1GBASE-T", 0 ),
  1419. PCI_ROM ( 0x8086, 0x37d2, "x722-10gt", "X722 10GBASE-T", 0 ),
  1420. PCI_ROM ( 0x8086, 0x37d3, "x722-sfp-i", "X722 10GbE SFP+", 0 ),
  1421. };
  1422. /** PCI driver */
  1423. struct pci_driver intelxl_driver __pci_driver = {
  1424. .ids = intelxl_nics,
  1425. .id_count = ( sizeof ( intelxl_nics ) / sizeof ( intelxl_nics[0] ) ),
  1426. .probe = intelxl_probe,
  1427. .remove = intelxl_remove,
  1428. };