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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692
  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_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 = malloc_dma ( ring->len, INTELXL_ALIGN );
  951. if ( ! ring->desc ) {
  952. rc = -ENOMEM;
  953. goto err_alloc;
  954. }
  955. /* Initialise descriptor ring */
  956. memset ( ring->desc, 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 );
  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, 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, ring->len );
  996. ring->desc = 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_idx].rx;
  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_idx].tx;
  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_idx].tx_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_idx].rx_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. intelxl_context_tx );
  1326. intelxl_init_ring ( &intelxl->rx, INTELXL_RX_NUM_DESC,
  1327. intelxl_context_rx );
  1328. /* Fix up PCI device */
  1329. adjust_pci_device ( pci );
  1330. /* Map registers */
  1331. intelxl->regs = ioremap ( pci->membase, INTELXL_BAR_SIZE );
  1332. if ( ! intelxl->regs ) {
  1333. rc = -ENODEV;
  1334. goto err_ioremap;
  1335. }
  1336. /* Reset the NIC */
  1337. if ( ( rc = intelxl_reset ( intelxl ) ) != 0 )
  1338. goto err_reset;
  1339. /* Get port number and base queue number */
  1340. pfgen_portnum = readl ( intelxl->regs + INTELXL_PFGEN_PORTNUM );
  1341. intelxl->port = INTELXL_PFGEN_PORTNUM_PORT_NUM ( pfgen_portnum );
  1342. pflan_qalloc = readl ( intelxl->regs + INTELXL_PFLAN_QALLOC );
  1343. intelxl->base = INTELXL_PFLAN_QALLOC_FIRSTQ ( pflan_qalloc );
  1344. DBGC ( intelxl, "INTELXL %p PF %d using port %d queues [%#04x-%#04x]\n",
  1345. intelxl, intelxl->pf, intelxl->port, intelxl->base,
  1346. INTELXL_PFLAN_QALLOC_LASTQ ( pflan_qalloc ) );
  1347. /* Fetch MAC address and maximum frame size */
  1348. if ( ( rc = intelxl_fetch_mac ( intelxl, netdev ) ) != 0 )
  1349. goto err_fetch_mac;
  1350. /* Open admin queues */
  1351. if ( ( rc = intelxl_open_admin ( intelxl ) ) != 0 )
  1352. goto err_open_admin;
  1353. /* Get switch configuration */
  1354. if ( ( rc = intelxl_admin_switch ( intelxl ) ) != 0 )
  1355. goto err_admin_switch;
  1356. /* Get VSI configuration */
  1357. if ( ( rc = intelxl_admin_vsi ( intelxl ) ) != 0 )
  1358. goto err_admin_vsi;
  1359. /* Configure switch for promiscuous mode */
  1360. if ( ( rc = intelxl_admin_promisc ( intelxl ) ) != 0 )
  1361. goto err_admin_promisc;
  1362. /* Configure queue register addresses */
  1363. intelxl->tx.reg = INTELXL_QTX ( intelxl->queue );
  1364. intelxl->rx.reg = INTELXL_QRX ( intelxl->queue );
  1365. /* Configure interrupt causes */
  1366. writel ( ( INTELXL_QINT_TQCTL_NEXTQ_INDX_NONE |
  1367. INTELXL_QINT_TQCTL_CAUSE_ENA ),
  1368. intelxl->regs + INTELXL_QINT_TQCTL ( intelxl->queue ) );
  1369. writel ( ( INTELXL_QINT_RQCTL_NEXTQ_INDX ( intelxl->queue ) |
  1370. INTELXL_QINT_RQCTL_NEXTQ_TYPE_TX |
  1371. INTELXL_QINT_RQCTL_CAUSE_ENA ),
  1372. intelxl->regs + INTELXL_QINT_RQCTL ( intelxl->queue ) );
  1373. writel ( ( INTELXL_PFINT_LNKLST0_FIRSTQ_INDX ( intelxl->queue ) |
  1374. INTELXL_PFINT_LNKLST0_FIRSTQ_TYPE_RX ),
  1375. intelxl->regs + INTELXL_PFINT_LNKLST0 );
  1376. writel ( INTELXL_PFINT_ICR0_ENA_ADMINQ,
  1377. intelxl->regs + INTELXL_PFINT_ICR0_ENA );
  1378. /* Register network device */
  1379. if ( ( rc = register_netdev ( netdev ) ) != 0 )
  1380. goto err_register_netdev;
  1381. /* Set initial link state */
  1382. intelxl_admin_link ( netdev );
  1383. return 0;
  1384. unregister_netdev ( netdev );
  1385. err_register_netdev:
  1386. err_admin_promisc:
  1387. err_admin_vsi:
  1388. err_admin_switch:
  1389. intelxl_close_admin ( intelxl );
  1390. err_open_admin:
  1391. err_fetch_mac:
  1392. intelxl_reset ( intelxl );
  1393. err_reset:
  1394. iounmap ( intelxl->regs );
  1395. err_ioremap:
  1396. netdev_nullify ( netdev );
  1397. netdev_put ( netdev );
  1398. err_alloc:
  1399. return rc;
  1400. }
  1401. /**
  1402. * Remove PCI device
  1403. *
  1404. * @v pci PCI device
  1405. */
  1406. static void intelxl_remove ( struct pci_device *pci ) {
  1407. struct net_device *netdev = pci_get_drvdata ( pci );
  1408. struct intelxl_nic *intelxl = netdev->priv;
  1409. /* Unregister network device */
  1410. unregister_netdev ( netdev );
  1411. /* Close admin queues */
  1412. intelxl_close_admin ( intelxl );
  1413. /* Reset the NIC */
  1414. intelxl_reset ( intelxl );
  1415. /* Free network device */
  1416. iounmap ( intelxl->regs );
  1417. netdev_nullify ( netdev );
  1418. netdev_put ( netdev );
  1419. }
  1420. /** PCI device IDs */
  1421. static struct pci_device_id intelxl_nics[] = {
  1422. PCI_ROM ( 0x8086, 0x1572, "x710-sfp", "X710 10GbE SFP+", 0 ),
  1423. PCI_ROM ( 0x8086, 0x1574, "xl710-qemu", "Virtual XL710", 0 ),
  1424. PCI_ROM ( 0x8086, 0x1580, "xl710-kx-b", "XL710 40GbE backplane", 0 ),
  1425. PCI_ROM ( 0x8086, 0x1581, "xl710-kx-c", "XL710 10GbE backplane", 0 ),
  1426. PCI_ROM ( 0x8086, 0x1583, "xl710-qda2", "XL710 40GbE QSFP+", 0 ),
  1427. PCI_ROM ( 0x8086, 0x1584, "xl710-qda1", "XL710 40GbE QSFP+", 0 ),
  1428. PCI_ROM ( 0x8086, 0x1585, "x710-qsfp", "X710 10GbE QSFP+", 0 ),
  1429. PCI_ROM ( 0x8086, 0x1586, "x710-10gt", "X710 10GBASE-T", 0 ),
  1430. PCI_ROM ( 0x8086, 0x1587, "x710-kr2", "XL710 20GbE backplane", 0 ),
  1431. PCI_ROM ( 0x8086, 0x1588, "x710-kr2-a", "XL710 20GbE backplane", 0 ),
  1432. PCI_ROM ( 0x8086, 0x1589, "x710-10gt4", "X710 10GBASE-T4", 0 ),
  1433. PCI_ROM ( 0x8086, 0x158a, "xxv710", "XXV710 25GbE backplane", 0 ),
  1434. PCI_ROM ( 0x8086, 0x158b, "xxv710-sfp28", "XXV710 25GbE SFP28", 0 ),
  1435. PCI_ROM ( 0x8086, 0x37ce, "x722-kx", "X722 10GbE backplane", 0 ),
  1436. PCI_ROM ( 0x8086, 0x37cf, "x722-qsfp", "X722 10GbE QSFP+", 0 ),
  1437. PCI_ROM ( 0x8086, 0x37d0, "x722-sfp", "X722 10GbE SFP+", 0 ),
  1438. PCI_ROM ( 0x8086, 0x37d1, "x722-1gt", "X722 1GBASE-T", 0 ),
  1439. PCI_ROM ( 0x8086, 0x37d2, "x722-10gt", "X722 10GBASE-T", 0 ),
  1440. PCI_ROM ( 0x8086, 0x37d3, "x722-sfp-i", "X722 10GbE SFP+", 0 ),
  1441. };
  1442. /** PCI driver */
  1443. struct pci_driver intelxl_driver __pci_driver = {
  1444. .ids = intelxl_nics,
  1445. .id_count = ( sizeof ( intelxl_nics ) / sizeof ( intelxl_nics[0] ) ),
  1446. .probe = intelxl_probe,
  1447. .remove = intelxl_remove,
  1448. };