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

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