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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674
  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. * Refill admin event queue
  574. *
  575. * @v intelxl Intel device
  576. */
  577. static void intelxl_refill_admin ( struct intelxl_nic *intelxl ) {
  578. struct intelxl_admin *admin = &intelxl->event;
  579. const struct intelxl_admin_offsets *regs = admin->regs;
  580. void *admin_regs = ( intelxl->regs + admin->base );
  581. unsigned int tail;
  582. /* Update tail pointer */
  583. tail = ( ( admin->index + INTELXL_ADMIN_NUM_DESC - 1 ) %
  584. INTELXL_ADMIN_NUM_DESC );
  585. wmb();
  586. writel ( tail, admin_regs + regs->tail );
  587. }
  588. /**
  589. * Poll admin event queue
  590. *
  591. * @v netdev Network device
  592. */
  593. static void intelxl_poll_admin ( struct net_device *netdev ) {
  594. struct intelxl_nic *intelxl = netdev->priv;
  595. struct intelxl_admin *admin = &intelxl->event;
  596. struct intelxl_admin_descriptor *evt;
  597. union intelxl_admin_buffer *buf;
  598. /* Check for events */
  599. while ( 1 ) {
  600. /* Get next event descriptor and data buffer */
  601. evt = &admin->desc[ admin->index % INTELXL_ADMIN_NUM_DESC ];
  602. buf = &admin->buf[ admin->index % INTELXL_ADMIN_NUM_DESC ];
  603. /* Stop if descriptor is not yet completed */
  604. if ( ! ( evt->flags & INTELXL_ADMIN_FL_DD ) )
  605. return;
  606. DBGC2 ( intelxl, "INTELXL %p admin event %#x:\n",
  607. intelxl, admin->index );
  608. DBGC2_HDA ( intelxl, virt_to_phys ( evt ), evt,
  609. sizeof ( *evt ) );
  610. if ( evt->flags & cpu_to_le16 ( INTELXL_ADMIN_FL_BUF ) ) {
  611. DBGC2_HDA ( intelxl, virt_to_phys ( buf ), buf,
  612. le16_to_cpu ( evt->len ) );
  613. }
  614. /* Handle event */
  615. switch ( evt->opcode ) {
  616. case cpu_to_le16 ( INTELXL_ADMIN_LINK ):
  617. intelxl_admin_link ( netdev );
  618. break;
  619. default:
  620. DBGC ( intelxl, "INTELXL %p admin event %#x "
  621. "unrecognised opcode %#04x\n", intelxl,
  622. admin->index, le16_to_cpu ( evt->opcode ) );
  623. break;
  624. }
  625. /* Reset descriptor and refill queue */
  626. intelxl_admin_event_init ( intelxl, admin->index );
  627. admin->index++;
  628. intelxl_refill_admin ( intelxl );
  629. }
  630. }
  631. /**
  632. * Open admin queues
  633. *
  634. * @v intelxl Intel device
  635. * @ret rc Return status code
  636. */
  637. static int intelxl_open_admin ( struct intelxl_nic *intelxl ) {
  638. int rc;
  639. /* Allocate admin event queue */
  640. if ( ( rc = intelxl_alloc_admin ( intelxl, &intelxl->event ) ) != 0 )
  641. goto err_alloc_event;
  642. /* Allocate admin command queue */
  643. if ( ( rc = intelxl_alloc_admin ( intelxl, &intelxl->command ) ) != 0 )
  644. goto err_alloc_command;
  645. /* (Re)open admin queues */
  646. intelxl_reopen_admin ( intelxl );
  647. /* Get firmware version */
  648. if ( ( rc = intelxl_admin_version ( intelxl ) ) != 0 )
  649. goto err_version;
  650. /* Report driver version */
  651. if ( ( rc = intelxl_admin_driver ( intelxl ) ) != 0 )
  652. goto err_driver;
  653. return 0;
  654. err_driver:
  655. err_version:
  656. intelxl_disable_admin ( intelxl, &intelxl->command );
  657. intelxl_disable_admin ( intelxl, &intelxl->event );
  658. intelxl_free_admin ( intelxl, &intelxl->command );
  659. err_alloc_command:
  660. intelxl_free_admin ( intelxl, &intelxl->event );
  661. err_alloc_event:
  662. return rc;
  663. }
  664. /**
  665. * Reopen admin queues (after virtual function reset)
  666. *
  667. * @v intelxl Intel device
  668. */
  669. static void intelxl_reopen_admin ( struct intelxl_nic *intelxl ) {
  670. unsigned int i;
  671. /* Enable admin event queue */
  672. intelxl_enable_admin ( intelxl, &intelxl->event );
  673. /* Enable admin command queue */
  674. intelxl_enable_admin ( intelxl, &intelxl->command );
  675. /* Initialise all admin event queue descriptors */
  676. for ( i = 0 ; i < INTELXL_ADMIN_NUM_DESC ; i++ )
  677. intelxl_admin_event_init ( intelxl, i );
  678. /* Post all descriptors to event queue */
  679. intelxl_refill_admin ( intelxl );
  680. }
  681. /**
  682. * Close admin queues
  683. *
  684. * @v intelxl Intel device
  685. */
  686. static void intelxl_close_admin ( struct intelxl_nic *intelxl ) {
  687. /* Shut down admin queues */
  688. intelxl_admin_shutdown ( intelxl );
  689. /* Disable admin queues */
  690. intelxl_disable_admin ( intelxl, &intelxl->command );
  691. intelxl_disable_admin ( intelxl, &intelxl->event );
  692. /* Free admin queues */
  693. intelxl_free_admin ( intelxl, &intelxl->command );
  694. intelxl_free_admin ( intelxl, &intelxl->event );
  695. }
  696. /******************************************************************************
  697. *
  698. * Descriptor rings
  699. *
  700. ******************************************************************************
  701. */
  702. /**
  703. * Dump queue context (for debugging)
  704. *
  705. * @v intelxl Intel device
  706. * @v op Context operation
  707. * @v len Size of context
  708. */
  709. static __attribute__ (( unused )) void
  710. intelxl_context_dump ( struct intelxl_nic *intelxl, uint32_t op, size_t len ) {
  711. struct intelxl_context_line line;
  712. uint32_t pfcm_lanctxctl;
  713. uint32_t pfcm_lanctxstat;
  714. unsigned int queue;
  715. unsigned int index;
  716. unsigned int i;
  717. /* Do nothing unless debug output is enabled */
  718. if ( ! DBG_EXTRA )
  719. return;
  720. /* Dump context */
  721. DBGC2 ( intelxl, "INTELXL %p context %#08x:\n", intelxl, op );
  722. for ( index = 0 ; ( sizeof ( line ) * index ) < len ; index++ ) {
  723. /* Start context operation */
  724. queue = ( intelxl->base + intelxl->queue );
  725. pfcm_lanctxctl =
  726. ( INTELXL_PFCM_LANCTXCTL_QUEUE_NUM ( queue ) |
  727. INTELXL_PFCM_LANCTXCTL_SUB_LINE ( index ) |
  728. INTELXL_PFCM_LANCTXCTL_OP_CODE_READ | op );
  729. writel ( pfcm_lanctxctl,
  730. intelxl->regs + INTELXL_PFCM_LANCTXCTL );
  731. /* Wait for operation to complete */
  732. for ( i = 0 ; i < INTELXL_CTX_MAX_WAIT_MS ; i++ ) {
  733. /* Check if operation is complete */
  734. pfcm_lanctxstat = readl ( intelxl->regs +
  735. INTELXL_PFCM_LANCTXSTAT );
  736. if ( pfcm_lanctxstat & INTELXL_PFCM_LANCTXSTAT_DONE )
  737. break;
  738. /* Delay */
  739. mdelay ( 1 );
  740. }
  741. /* Read context data */
  742. for ( i = 0 ; i < ( sizeof ( line ) /
  743. sizeof ( line.raw[0] ) ) ; i++ ) {
  744. line.raw[i] = readl ( intelxl->regs +
  745. INTELXL_PFCM_LANCTXDATA ( i ) );
  746. }
  747. DBGC2_HDA ( intelxl, ( sizeof ( line ) * index ),
  748. &line, sizeof ( line ) );
  749. }
  750. }
  751. /**
  752. * Program queue context line
  753. *
  754. * @v intelxl Intel device
  755. * @v line Queue context line
  756. * @v index Line number
  757. * @v op Context operation
  758. * @ret rc Return status code
  759. */
  760. static int intelxl_context_line ( struct intelxl_nic *intelxl,
  761. struct intelxl_context_line *line,
  762. unsigned int index, uint32_t op ) {
  763. uint32_t pfcm_lanctxctl;
  764. uint32_t pfcm_lanctxstat;
  765. unsigned int queue;
  766. unsigned int i;
  767. /* Write context data */
  768. for ( i = 0; i < ( sizeof ( *line ) / sizeof ( line->raw[0] ) ); i++ ) {
  769. writel ( le32_to_cpu ( line->raw[i] ),
  770. intelxl->regs + INTELXL_PFCM_LANCTXDATA ( i ) );
  771. }
  772. /* Start context operation */
  773. queue = ( intelxl->base + intelxl->queue );
  774. pfcm_lanctxctl = ( INTELXL_PFCM_LANCTXCTL_QUEUE_NUM ( queue ) |
  775. INTELXL_PFCM_LANCTXCTL_SUB_LINE ( index ) |
  776. INTELXL_PFCM_LANCTXCTL_OP_CODE_WRITE | op );
  777. writel ( pfcm_lanctxctl, intelxl->regs + INTELXL_PFCM_LANCTXCTL );
  778. /* Wait for operation to complete */
  779. for ( i = 0 ; i < INTELXL_CTX_MAX_WAIT_MS ; i++ ) {
  780. /* Check if operation is complete */
  781. pfcm_lanctxstat = readl ( intelxl->regs +
  782. INTELXL_PFCM_LANCTXSTAT );
  783. if ( pfcm_lanctxstat & INTELXL_PFCM_LANCTXSTAT_DONE )
  784. return 0;
  785. /* Delay */
  786. mdelay ( 1 );
  787. }
  788. DBGC ( intelxl, "INTELXL %p timed out waiting for context: %#08x\n",
  789. intelxl, pfcm_lanctxctl );
  790. return -ETIMEDOUT;
  791. }
  792. /**
  793. * Program queue context
  794. *
  795. * @v intelxl Intel device
  796. * @v line Queue context lines
  797. * @v len Size of context
  798. * @v op Context operation
  799. * @ret rc Return status code
  800. */
  801. static int intelxl_context ( struct intelxl_nic *intelxl,
  802. struct intelxl_context_line *line,
  803. size_t len, uint32_t op ) {
  804. unsigned int index;
  805. int rc;
  806. DBGC2 ( intelxl, "INTELXL %p context %#08x len %#zx:\n",
  807. intelxl, op, len );
  808. DBGC2_HDA ( intelxl, 0, line, len );
  809. /* Program one line at a time */
  810. for ( index = 0 ; ( sizeof ( *line ) * index ) < len ; index++ ) {
  811. if ( ( rc = intelxl_context_line ( intelxl, line++, index,
  812. op ) ) != 0 )
  813. return rc;
  814. }
  815. return 0;
  816. }
  817. /**
  818. * Program transmit queue context
  819. *
  820. * @v intelxl Intel device
  821. * @v address Descriptor ring base address
  822. * @ret rc Return status code
  823. */
  824. static int intelxl_context_tx ( struct intelxl_nic *intelxl,
  825. physaddr_t address ) {
  826. union {
  827. struct intelxl_context_tx tx;
  828. struct intelxl_context_line line;
  829. } ctx;
  830. int rc;
  831. /* Initialise context */
  832. memset ( &ctx, 0, sizeof ( ctx ) );
  833. ctx.tx.flags = cpu_to_le16 ( INTELXL_CTX_TX_FL_NEW );
  834. ctx.tx.base = cpu_to_le64 ( INTELXL_CTX_TX_BASE ( address ) );
  835. ctx.tx.count =
  836. cpu_to_le16 ( INTELXL_CTX_TX_COUNT ( INTELXL_TX_NUM_DESC ) );
  837. ctx.tx.qset = INTELXL_CTX_TX_QSET ( intelxl->qset );
  838. /* Program context */
  839. if ( ( rc = intelxl_context ( intelxl, &ctx.line, sizeof ( ctx ),
  840. INTELXL_PFCM_LANCTXCTL_TYPE_TX ) ) != 0 )
  841. return rc;
  842. return 0;
  843. }
  844. /**
  845. * Program receive queue context
  846. *
  847. * @v intelxl Intel device
  848. * @v address Descriptor ring base address
  849. * @ret rc Return status code
  850. */
  851. static int intelxl_context_rx ( struct intelxl_nic *intelxl,
  852. physaddr_t address ) {
  853. union {
  854. struct intelxl_context_rx rx;
  855. struct intelxl_context_line line;
  856. } ctx;
  857. uint64_t base_count;
  858. int rc;
  859. /* Initialise context */
  860. memset ( &ctx, 0, sizeof ( ctx ) );
  861. base_count = INTELXL_CTX_RX_BASE_COUNT ( address, INTELXL_RX_NUM_DESC );
  862. ctx.rx.base_count = cpu_to_le64 ( base_count );
  863. ctx.rx.len = cpu_to_le16 ( INTELXL_CTX_RX_LEN ( intelxl->mfs ) );
  864. ctx.rx.flags = INTELXL_CTX_RX_FL_CRCSTRIP;
  865. ctx.rx.mfs = cpu_to_le16 ( INTELXL_CTX_RX_MFS ( intelxl->mfs ) );
  866. /* Program context */
  867. if ( ( rc = intelxl_context ( intelxl, &ctx.line, sizeof ( ctx ),
  868. INTELXL_PFCM_LANCTXCTL_TYPE_RX ) ) != 0 )
  869. return rc;
  870. return 0;
  871. }
  872. /**
  873. * Enable descriptor ring
  874. *
  875. * @v intelxl Intel device
  876. * @v ring Descriptor ring
  877. * @ret rc Return status code
  878. */
  879. static int intelxl_enable_ring ( struct intelxl_nic *intelxl,
  880. struct intelxl_ring *ring ) {
  881. void *ring_regs = ( intelxl->regs + ring->reg );
  882. uint32_t qxx_ena;
  883. /* Enable ring */
  884. writel ( INTELXL_QXX_ENA_REQ, ( ring_regs + INTELXL_QXX_ENA ) );
  885. udelay ( INTELXL_QUEUE_ENABLE_DELAY_US );
  886. qxx_ena = readl ( ring_regs + INTELXL_QXX_ENA );
  887. if ( ! ( qxx_ena & INTELXL_QXX_ENA_STAT ) ) {
  888. DBGC ( intelxl, "INTELXL %p ring %06x failed to enable: "
  889. "%#08x\n", intelxl, ring->reg, qxx_ena );
  890. return -EIO;
  891. }
  892. return 0;
  893. }
  894. /**
  895. * Disable descriptor ring
  896. *
  897. * @v intelxl Intel device
  898. * @v ring Descriptor ring
  899. * @ret rc Return status code
  900. */
  901. static int intelxl_disable_ring ( struct intelxl_nic *intelxl,
  902. struct intelxl_ring *ring ) {
  903. void *ring_regs = ( intelxl->regs + ring->reg );
  904. uint32_t qxx_ena;
  905. unsigned int i;
  906. /* Disable ring */
  907. writel ( 0, ( ring_regs + INTELXL_QXX_ENA ) );
  908. /* Wait for ring to be disabled */
  909. for ( i = 0 ; i < INTELXL_QUEUE_DISABLE_MAX_WAIT_MS ; i++ ) {
  910. /* Check if ring is disabled */
  911. qxx_ena = readl ( ring_regs + INTELXL_QXX_ENA );
  912. if ( ! ( qxx_ena & INTELXL_QXX_ENA_STAT ) )
  913. return 0;
  914. /* Delay */
  915. mdelay ( 1 );
  916. }
  917. DBGC ( intelxl, "INTELXL %p ring %06x timed out waiting for disable: "
  918. "%#08x\n", intelxl, ring->reg, qxx_ena );
  919. return -ETIMEDOUT;
  920. }
  921. /**
  922. * Create descriptor ring
  923. *
  924. * @v intelxl Intel device
  925. * @v ring Descriptor ring
  926. * @ret rc Return status code
  927. */
  928. static int intelxl_create_ring ( struct intelxl_nic *intelxl,
  929. struct intelxl_ring *ring ) {
  930. void *ring_regs = ( intelxl->regs + ring->reg );
  931. physaddr_t address;
  932. int rc;
  933. /* Allocate descriptor ring */
  934. ring->desc = malloc_dma ( ring->len, INTELXL_ALIGN );
  935. if ( ! ring->desc ) {
  936. rc = -ENOMEM;
  937. goto err_alloc;
  938. }
  939. /* Initialise descriptor ring */
  940. memset ( ring->desc, 0, ring->len );
  941. /* Reset tail pointer */
  942. writel ( 0, ( ring_regs + INTELXL_QXX_TAIL ) );
  943. /* Program queue context */
  944. address = virt_to_bus ( ring->desc );
  945. if ( ( rc = ring->context ( intelxl, address ) ) != 0 )
  946. goto err_context;
  947. /* Enable ring */
  948. if ( ( rc = intelxl_enable_ring ( intelxl, ring ) ) != 0 )
  949. goto err_enable;
  950. /* Reset counters */
  951. ring->prod = 0;
  952. ring->cons = 0;
  953. DBGC ( intelxl, "INTELXL %p ring %06x is at [%08llx,%08llx)\n",
  954. intelxl, ring->reg, ( ( unsigned long long ) address ),
  955. ( ( unsigned long long ) address + ring->len ) );
  956. return 0;
  957. intelxl_disable_ring ( intelxl, ring );
  958. err_enable:
  959. err_context:
  960. free_dma ( ring->desc, ring->len );
  961. err_alloc:
  962. return rc;
  963. }
  964. /**
  965. * Destroy descriptor ring
  966. *
  967. * @v intelxl Intel device
  968. * @v ring Descriptor ring
  969. */
  970. static void intelxl_destroy_ring ( struct intelxl_nic *intelxl,
  971. struct intelxl_ring *ring ) {
  972. int rc;
  973. /* Disable ring */
  974. if ( ( rc = intelxl_disable_ring ( intelxl, ring ) ) != 0 ) {
  975. /* Leak memory; there's nothing else we can do */
  976. return;
  977. }
  978. /* Free descriptor ring */
  979. free_dma ( ring->desc, ring->len );
  980. ring->desc = NULL;
  981. }
  982. /**
  983. * Refill receive descriptor ring
  984. *
  985. * @v intelxl Intel device
  986. */
  987. static void intelxl_refill_rx ( struct intelxl_nic *intelxl ) {
  988. struct intelxl_rx_data_descriptor *rx;
  989. struct io_buffer *iobuf;
  990. unsigned int rx_idx;
  991. unsigned int rx_tail;
  992. physaddr_t address;
  993. unsigned int refilled = 0;
  994. /* Refill ring */
  995. while ( ( intelxl->rx.prod - intelxl->rx.cons ) < INTELXL_RX_FILL ) {
  996. /* Allocate I/O buffer */
  997. iobuf = alloc_iob ( intelxl->mfs );
  998. if ( ! iobuf ) {
  999. /* Wait for next refill */
  1000. break;
  1001. }
  1002. /* Get next receive descriptor */
  1003. rx_idx = ( intelxl->rx.prod++ % INTELXL_RX_NUM_DESC );
  1004. rx = &intelxl->rx.desc[rx_idx].rx;
  1005. /* Populate receive descriptor */
  1006. address = virt_to_bus ( iobuf->data );
  1007. rx->address = cpu_to_le64 ( address );
  1008. rx->flags = 0;
  1009. /* Record I/O buffer */
  1010. assert ( intelxl->rx_iobuf[rx_idx] == NULL );
  1011. intelxl->rx_iobuf[rx_idx] = iobuf;
  1012. DBGC2 ( intelxl, "INTELXL %p RX %d is [%llx,%llx)\n", intelxl,
  1013. rx_idx, ( ( unsigned long long ) address ),
  1014. ( ( unsigned long long ) address + intelxl->mfs ) );
  1015. refilled++;
  1016. }
  1017. /* Push descriptors to card, if applicable */
  1018. if ( refilled ) {
  1019. wmb();
  1020. rx_tail = ( intelxl->rx.prod % INTELXL_RX_NUM_DESC );
  1021. writel ( rx_tail,
  1022. ( intelxl->regs + intelxl->rx.reg + INTELXL_QXX_TAIL));
  1023. }
  1024. }
  1025. /******************************************************************************
  1026. *
  1027. * Network device interface
  1028. *
  1029. ******************************************************************************
  1030. */
  1031. /**
  1032. * Open network device
  1033. *
  1034. * @v netdev Network device
  1035. * @ret rc Return status code
  1036. */
  1037. static int intelxl_open ( struct net_device *netdev ) {
  1038. struct intelxl_nic *intelxl = netdev->priv;
  1039. union intelxl_receive_address mac;
  1040. unsigned int queue;
  1041. uint32_t prtgl_sal;
  1042. uint32_t prtgl_sah;
  1043. int rc;
  1044. /* Calculate maximum frame size */
  1045. intelxl->mfs = ( ( ETH_HLEN + netdev->mtu + 4 /* CRC */ +
  1046. INTELXL_ALIGN - 1 ) & ~( INTELXL_ALIGN - 1 ) );
  1047. /* Program MAC address and maximum frame size */
  1048. memset ( &mac, 0, sizeof ( mac ) );
  1049. memcpy ( mac.raw, netdev->ll_addr, sizeof ( mac.raw ) );
  1050. prtgl_sal = le32_to_cpu ( mac.reg.low );
  1051. prtgl_sah = ( le32_to_cpu ( mac.reg.high ) |
  1052. INTELXL_PRTGL_SAH_MFS_SET ( intelxl->mfs ) );
  1053. writel ( prtgl_sal, intelxl->regs + INTELXL_PRTGL_SAL );
  1054. writel ( prtgl_sah, intelxl->regs + INTELXL_PRTGL_SAH );
  1055. /* Associate transmit queue to PF */
  1056. writel ( ( INTELXL_QXX_CTL_PFVF_Q_PF |
  1057. INTELXL_QXX_CTL_PFVF_PF_INDX ( intelxl->pf ) ),
  1058. ( intelxl->regs + intelxl->tx.reg + INTELXL_QXX_CTL ) );
  1059. /* Clear transmit pre queue disable */
  1060. queue = ( intelxl->base + intelxl->queue );
  1061. writel ( ( INTELXL_GLLAN_TXPRE_QDIS_CLEAR_QDIS |
  1062. INTELXL_GLLAN_TXPRE_QDIS_QINDX ( queue ) ),
  1063. ( intelxl->regs + INTELXL_GLLAN_TXPRE_QDIS ( queue ) ) );
  1064. /* Reset transmit queue head */
  1065. writel ( 0, ( intelxl->regs + INTELXL_QTX_HEAD ( intelxl->queue ) ) );
  1066. /* Create receive descriptor ring */
  1067. if ( ( rc = intelxl_create_ring ( intelxl, &intelxl->rx ) ) != 0 )
  1068. goto err_create_rx;
  1069. /* Create transmit descriptor ring */
  1070. if ( ( rc = intelxl_create_ring ( intelxl, &intelxl->tx ) ) != 0 )
  1071. goto err_create_tx;
  1072. /* Fill receive ring */
  1073. intelxl_refill_rx ( intelxl );
  1074. /* Restart autonegotiation */
  1075. intelxl_admin_autoneg ( intelxl );
  1076. /* Update link state */
  1077. intelxl_admin_link ( netdev );
  1078. return 0;
  1079. writel ( ( INTELXL_GLLAN_TXPRE_QDIS_SET_QDIS |
  1080. INTELXL_GLLAN_TXPRE_QDIS_QINDX ( queue ) ),
  1081. ( intelxl->regs + INTELXL_GLLAN_TXPRE_QDIS ( queue ) ) );
  1082. udelay ( INTELXL_QUEUE_PRE_DISABLE_DELAY_US );
  1083. intelxl_destroy_ring ( intelxl, &intelxl->tx );
  1084. err_create_tx:
  1085. intelxl_destroy_ring ( intelxl, &intelxl->rx );
  1086. err_create_rx:
  1087. return rc;
  1088. }
  1089. /**
  1090. * Close network device
  1091. *
  1092. * @v netdev Network device
  1093. */
  1094. static void intelxl_close ( struct net_device *netdev ) {
  1095. struct intelxl_nic *intelxl = netdev->priv;
  1096. unsigned int queue;
  1097. unsigned int i;
  1098. /* Dump contexts (for debugging) */
  1099. intelxl_context_dump ( intelxl, INTELXL_PFCM_LANCTXCTL_TYPE_TX,
  1100. sizeof ( struct intelxl_context_tx ) );
  1101. intelxl_context_dump ( intelxl, INTELXL_PFCM_LANCTXCTL_TYPE_RX,
  1102. sizeof ( struct intelxl_context_rx ) );
  1103. /* Pre-disable transmit queue */
  1104. queue = ( intelxl->base + intelxl->queue );
  1105. writel ( ( INTELXL_GLLAN_TXPRE_QDIS_SET_QDIS |
  1106. INTELXL_GLLAN_TXPRE_QDIS_QINDX ( queue ) ),
  1107. ( intelxl->regs + INTELXL_GLLAN_TXPRE_QDIS ( queue ) ) );
  1108. udelay ( INTELXL_QUEUE_PRE_DISABLE_DELAY_US );
  1109. /* Destroy transmit descriptor ring */
  1110. intelxl_destroy_ring ( intelxl, &intelxl->tx );
  1111. /* Destroy receive descriptor ring */
  1112. intelxl_destroy_ring ( intelxl, &intelxl->rx );
  1113. /* Discard any unused receive buffers */
  1114. for ( i = 0 ; i < INTELXL_RX_NUM_DESC ; i++ ) {
  1115. if ( intelxl->rx_iobuf[i] )
  1116. free_iob ( intelxl->rx_iobuf[i] );
  1117. intelxl->rx_iobuf[i] = NULL;
  1118. }
  1119. }
  1120. /**
  1121. * Transmit packet
  1122. *
  1123. * @v netdev Network device
  1124. * @v iobuf I/O buffer
  1125. * @ret rc Return status code
  1126. */
  1127. static int intelxl_transmit ( struct net_device *netdev,
  1128. struct io_buffer *iobuf ) {
  1129. struct intelxl_nic *intelxl = netdev->priv;
  1130. struct intelxl_tx_data_descriptor *tx;
  1131. unsigned int tx_idx;
  1132. unsigned int tx_tail;
  1133. physaddr_t address;
  1134. size_t len;
  1135. /* Get next transmit descriptor */
  1136. if ( ( intelxl->tx.prod - intelxl->tx.cons ) >= INTELXL_TX_FILL ) {
  1137. DBGC ( intelxl, "INTELXL %p out of transmit descriptors\n",
  1138. intelxl );
  1139. return -ENOBUFS;
  1140. }
  1141. tx_idx = ( intelxl->tx.prod++ % INTELXL_TX_NUM_DESC );
  1142. tx_tail = ( intelxl->tx.prod % INTELXL_TX_NUM_DESC );
  1143. tx = &intelxl->tx.desc[tx_idx].tx;
  1144. /* Populate transmit descriptor */
  1145. address = virt_to_bus ( iobuf->data );
  1146. len = iob_len ( iobuf );
  1147. tx->address = cpu_to_le64 ( address );
  1148. tx->len = cpu_to_le32 ( INTELXL_TX_DATA_LEN ( len ) );
  1149. tx->flags = cpu_to_le32 ( INTELXL_TX_DATA_DTYP | INTELXL_TX_DATA_EOP |
  1150. INTELXL_TX_DATA_RS | INTELXL_TX_DATA_JFDI );
  1151. wmb();
  1152. /* Notify card that there are packets ready to transmit */
  1153. writel ( tx_tail,
  1154. ( intelxl->regs + intelxl->tx.reg + INTELXL_QXX_TAIL ) );
  1155. DBGC2 ( intelxl, "INTELXL %p TX %d is [%llx,%llx)\n", intelxl, tx_idx,
  1156. ( ( unsigned long long ) address ),
  1157. ( ( unsigned long long ) address + len ) );
  1158. return 0;
  1159. }
  1160. /**
  1161. * Poll for completed packets
  1162. *
  1163. * @v netdev Network device
  1164. */
  1165. static void intelxl_poll_tx ( struct net_device *netdev ) {
  1166. struct intelxl_nic *intelxl = netdev->priv;
  1167. struct intelxl_tx_writeback_descriptor *tx_wb;
  1168. unsigned int tx_idx;
  1169. /* Check for completed packets */
  1170. while ( intelxl->tx.cons != intelxl->tx.prod ) {
  1171. /* Get next transmit descriptor */
  1172. tx_idx = ( intelxl->tx.cons % INTELXL_TX_NUM_DESC );
  1173. tx_wb = &intelxl->tx.desc[tx_idx].tx_wb;
  1174. /* Stop if descriptor is still in use */
  1175. if ( ! ( tx_wb->flags & INTELXL_TX_WB_FL_DD ) )
  1176. return;
  1177. DBGC2 ( intelxl, "INTELXL %p TX %d complete\n",
  1178. intelxl, tx_idx );
  1179. /* Complete TX descriptor */
  1180. netdev_tx_complete_next ( netdev );
  1181. intelxl->tx.cons++;
  1182. }
  1183. }
  1184. /**
  1185. * Poll for received packets
  1186. *
  1187. * @v netdev Network device
  1188. */
  1189. static void intelxl_poll_rx ( struct net_device *netdev ) {
  1190. struct intelxl_nic *intelxl = netdev->priv;
  1191. struct intelxl_rx_writeback_descriptor *rx_wb;
  1192. struct io_buffer *iobuf;
  1193. unsigned int rx_idx;
  1194. unsigned int tag;
  1195. size_t len;
  1196. /* Check for received packets */
  1197. while ( intelxl->rx.cons != intelxl->rx.prod ) {
  1198. /* Get next receive descriptor */
  1199. rx_idx = ( intelxl->rx.cons % INTELXL_RX_NUM_DESC );
  1200. rx_wb = &intelxl->rx.desc[rx_idx].rx_wb;
  1201. /* Stop if descriptor is still in use */
  1202. if ( ! ( rx_wb->flags & cpu_to_le32 ( INTELXL_RX_WB_FL_DD ) ) )
  1203. return;
  1204. /* Populate I/O buffer */
  1205. iobuf = intelxl->rx_iobuf[rx_idx];
  1206. intelxl->rx_iobuf[rx_idx] = NULL;
  1207. len = INTELXL_RX_WB_LEN ( le32_to_cpu ( rx_wb->len ) );
  1208. iob_put ( iobuf, len );
  1209. /* Find VLAN device, if applicable */
  1210. if ( rx_wb->flags & cpu_to_le32 ( INTELXL_RX_WB_FL_VLAN ) ) {
  1211. tag = VLAN_TAG ( le16_to_cpu ( rx_wb->vlan ) );
  1212. } else {
  1213. tag = 0;
  1214. }
  1215. /* Hand off to network stack */
  1216. if ( rx_wb->flags & cpu_to_le32 ( INTELXL_RX_WB_FL_RXE ) ) {
  1217. DBGC ( intelxl, "INTELXL %p RX %d error (length %zd, "
  1218. "flags %08x)\n", intelxl, rx_idx, len,
  1219. le32_to_cpu ( rx_wb->flags ) );
  1220. vlan_netdev_rx_err ( netdev, tag, iobuf, -EIO );
  1221. } else {
  1222. DBGC2 ( intelxl, "INTELXL %p RX %d complete (length "
  1223. "%zd)\n", intelxl, rx_idx, len );
  1224. vlan_netdev_rx ( netdev, tag, iobuf );
  1225. }
  1226. intelxl->rx.cons++;
  1227. }
  1228. }
  1229. /**
  1230. * Poll for completed and received packets
  1231. *
  1232. * @v netdev Network device
  1233. */
  1234. static void intelxl_poll ( struct net_device *netdev ) {
  1235. struct intelxl_nic *intelxl = netdev->priv;
  1236. /* Acknowledge interrupts, if applicable */
  1237. if ( netdev_irq_enabled ( netdev ) ) {
  1238. writel ( ( INTELXL_PFINT_DYN_CTL0_CLEARPBA |
  1239. INTELXL_PFINT_DYN_CTL0_INTENA_MASK ),
  1240. intelxl->regs + INTELXL_PFINT_DYN_CTL0 );
  1241. }
  1242. /* Poll for completed packets */
  1243. intelxl_poll_tx ( netdev );
  1244. /* Poll for received packets */
  1245. intelxl_poll_rx ( netdev );
  1246. /* Poll for admin events */
  1247. intelxl_poll_admin ( netdev );
  1248. /* Refill RX ring */
  1249. intelxl_refill_rx ( intelxl );
  1250. }
  1251. /**
  1252. * Enable or disable interrupts
  1253. *
  1254. * @v netdev Network device
  1255. * @v enable Interrupts should be enabled
  1256. */
  1257. static void intelxl_irq ( struct net_device *netdev, int enable ) {
  1258. struct intelxl_nic *intelxl = netdev->priv;
  1259. if ( enable ) {
  1260. writel ( INTELXL_PFINT_DYN_CTL0_INTENA,
  1261. intelxl->regs + INTELXL_PFINT_DYN_CTL0 );
  1262. } else {
  1263. writel ( 0, intelxl->regs + INTELXL_PFINT_DYN_CTL0 );
  1264. }
  1265. }
  1266. /** Network device operations */
  1267. static struct net_device_operations intelxl_operations = {
  1268. .open = intelxl_open,
  1269. .close = intelxl_close,
  1270. .transmit = intelxl_transmit,
  1271. .poll = intelxl_poll,
  1272. .irq = intelxl_irq,
  1273. };
  1274. /******************************************************************************
  1275. *
  1276. * PCI interface
  1277. *
  1278. ******************************************************************************
  1279. */
  1280. /**
  1281. * Probe PCI device
  1282. *
  1283. * @v pci PCI device
  1284. * @ret rc Return status code
  1285. */
  1286. static int intelxl_probe ( struct pci_device *pci ) {
  1287. struct net_device *netdev;
  1288. struct intelxl_nic *intelxl;
  1289. uint32_t pfgen_portnum;
  1290. uint32_t pflan_qalloc;
  1291. int rc;
  1292. /* Allocate and initialise net device */
  1293. netdev = alloc_etherdev ( sizeof ( *intelxl ) );
  1294. if ( ! netdev ) {
  1295. rc = -ENOMEM;
  1296. goto err_alloc;
  1297. }
  1298. netdev_init ( netdev, &intelxl_operations );
  1299. intelxl = netdev->priv;
  1300. pci_set_drvdata ( pci, netdev );
  1301. netdev->dev = &pci->dev;
  1302. memset ( intelxl, 0, sizeof ( *intelxl ) );
  1303. intelxl->pf = PCI_FUNC ( pci->busdevfn );
  1304. intelxl_init_admin ( &intelxl->command, INTELXL_ADMIN_CMD,
  1305. &intelxl_admin_offsets );
  1306. intelxl_init_admin ( &intelxl->event, INTELXL_ADMIN_EVT,
  1307. &intelxl_admin_offsets );
  1308. intelxl_init_ring ( &intelxl->tx, INTELXL_TX_NUM_DESC,
  1309. intelxl_context_tx );
  1310. intelxl_init_ring ( &intelxl->rx, INTELXL_RX_NUM_DESC,
  1311. intelxl_context_rx );
  1312. /* Fix up PCI device */
  1313. adjust_pci_device ( pci );
  1314. /* Map registers */
  1315. intelxl->regs = ioremap ( pci->membase, INTELXL_BAR_SIZE );
  1316. if ( ! intelxl->regs ) {
  1317. rc = -ENODEV;
  1318. goto err_ioremap;
  1319. }
  1320. /* Reset the NIC */
  1321. if ( ( rc = intelxl_reset ( intelxl ) ) != 0 )
  1322. goto err_reset;
  1323. /* Get port number and base queue number */
  1324. pfgen_portnum = readl ( intelxl->regs + INTELXL_PFGEN_PORTNUM );
  1325. intelxl->port = INTELXL_PFGEN_PORTNUM_PORT_NUM ( pfgen_portnum );
  1326. pflan_qalloc = readl ( intelxl->regs + INTELXL_PFLAN_QALLOC );
  1327. intelxl->base = INTELXL_PFLAN_QALLOC_FIRSTQ ( pflan_qalloc );
  1328. DBGC ( intelxl, "INTELXL %p PF %d using port %d queues [%#04x-%#04x]\n",
  1329. intelxl, intelxl->pf, intelxl->port, intelxl->base,
  1330. INTELXL_PFLAN_QALLOC_LASTQ ( pflan_qalloc ) );
  1331. /* Fetch MAC address and maximum frame size */
  1332. if ( ( rc = intelxl_fetch_mac ( intelxl, netdev ) ) != 0 )
  1333. goto err_fetch_mac;
  1334. /* Open admin queues */
  1335. if ( ( rc = intelxl_open_admin ( intelxl ) ) != 0 )
  1336. goto err_open_admin;
  1337. /* Get switch configuration */
  1338. if ( ( rc = intelxl_admin_switch ( intelxl ) ) != 0 )
  1339. goto err_admin_switch;
  1340. /* Get VSI configuration */
  1341. if ( ( rc = intelxl_admin_vsi ( intelxl ) ) != 0 )
  1342. goto err_admin_vsi;
  1343. /* Configure switch for promiscuous mode */
  1344. if ( ( rc = intelxl_admin_promisc ( intelxl ) ) != 0 )
  1345. goto err_admin_promisc;
  1346. /* Configure queue register addresses */
  1347. intelxl->tx.reg = INTELXL_QTX ( intelxl->queue );
  1348. intelxl->rx.reg = INTELXL_QRX ( intelxl->queue );
  1349. /* Configure interrupt causes */
  1350. writel ( ( INTELXL_QINT_TQCTL_NEXTQ_INDX_NONE |
  1351. INTELXL_QINT_TQCTL_CAUSE_ENA ),
  1352. intelxl->regs + INTELXL_QINT_TQCTL ( intelxl->queue ) );
  1353. writel ( ( INTELXL_QINT_RQCTL_NEXTQ_INDX ( intelxl->queue ) |
  1354. INTELXL_QINT_RQCTL_NEXTQ_TYPE_TX |
  1355. INTELXL_QINT_RQCTL_CAUSE_ENA ),
  1356. intelxl->regs + INTELXL_QINT_RQCTL ( intelxl->queue ) );
  1357. writel ( ( INTELXL_PFINT_LNKLST0_FIRSTQ_INDX ( intelxl->queue ) |
  1358. INTELXL_PFINT_LNKLST0_FIRSTQ_TYPE_RX ),
  1359. intelxl->regs + INTELXL_PFINT_LNKLST0 );
  1360. writel ( INTELXL_PFINT_ICR0_ENA_ADMINQ,
  1361. intelxl->regs + INTELXL_PFINT_ICR0_ENA );
  1362. /* Register network device */
  1363. if ( ( rc = register_netdev ( netdev ) ) != 0 )
  1364. goto err_register_netdev;
  1365. /* Set initial link state */
  1366. intelxl_admin_link ( netdev );
  1367. return 0;
  1368. unregister_netdev ( netdev );
  1369. err_register_netdev:
  1370. err_admin_promisc:
  1371. err_admin_vsi:
  1372. err_admin_switch:
  1373. intelxl_close_admin ( intelxl );
  1374. err_open_admin:
  1375. err_fetch_mac:
  1376. intelxl_reset ( intelxl );
  1377. err_reset:
  1378. iounmap ( intelxl->regs );
  1379. err_ioremap:
  1380. netdev_nullify ( netdev );
  1381. netdev_put ( netdev );
  1382. err_alloc:
  1383. return rc;
  1384. }
  1385. /**
  1386. * Remove PCI device
  1387. *
  1388. * @v pci PCI device
  1389. */
  1390. static void intelxl_remove ( struct pci_device *pci ) {
  1391. struct net_device *netdev = pci_get_drvdata ( pci );
  1392. struct intelxl_nic *intelxl = netdev->priv;
  1393. /* Unregister network device */
  1394. unregister_netdev ( netdev );
  1395. /* Close admin queues */
  1396. intelxl_close_admin ( intelxl );
  1397. /* Reset the NIC */
  1398. intelxl_reset ( intelxl );
  1399. /* Free network device */
  1400. iounmap ( intelxl->regs );
  1401. netdev_nullify ( netdev );
  1402. netdev_put ( netdev );
  1403. }
  1404. /** PCI device IDs */
  1405. static struct pci_device_id intelxl_nics[] = {
  1406. PCI_ROM ( 0x8086, 0x1572, "x710-sfp", "X710 10GbE SFP+", 0 ),
  1407. PCI_ROM ( 0x8086, 0x1574, "xl710-qemu", "Virtual XL710", 0 ),
  1408. PCI_ROM ( 0x8086, 0x1580, "xl710-kx-b", "XL710 40GbE backplane", 0 ),
  1409. PCI_ROM ( 0x8086, 0x1581, "xl710-kx-c", "XL710 10GbE backplane", 0 ),
  1410. PCI_ROM ( 0x8086, 0x1583, "xl710-qda2", "XL710 40GbE QSFP+", 0 ),
  1411. PCI_ROM ( 0x8086, 0x1584, "xl710-qda1", "XL710 40GbE QSFP+", 0 ),
  1412. PCI_ROM ( 0x8086, 0x1585, "x710-qsfp", "X710 10GbE QSFP+", 0 ),
  1413. PCI_ROM ( 0x8086, 0x1586, "x710-10gt", "X710 10GBASE-T", 0 ),
  1414. PCI_ROM ( 0x8086, 0x1587, "x710-kr2", "XL710 20GbE backplane", 0 ),
  1415. PCI_ROM ( 0x8086, 0x1588, "x710-kr2-a", "XL710 20GbE backplane", 0 ),
  1416. PCI_ROM ( 0x8086, 0x1589, "x710-10gt4", "X710 10GBASE-T4", 0 ),
  1417. PCI_ROM ( 0x8086, 0x158a, "xxv710", "XXV710 25GbE backplane", 0 ),
  1418. PCI_ROM ( 0x8086, 0x158b, "xxv710-sfp28", "XXV710 25GbE SFP28", 0 ),
  1419. PCI_ROM ( 0x8086, 0x37ce, "x722-kx", "X722 10GbE backplane", 0 ),
  1420. PCI_ROM ( 0x8086, 0x37cf, "x722-qsfp", "X722 10GbE QSFP+", 0 ),
  1421. PCI_ROM ( 0x8086, 0x37d0, "x722-sfp", "X722 10GbE SFP+", 0 ),
  1422. PCI_ROM ( 0x8086, 0x37d1, "x722-1gt", "X722 1GBASE-T", 0 ),
  1423. PCI_ROM ( 0x8086, 0x37d2, "x722-10gt", "X722 10GBASE-T", 0 ),
  1424. PCI_ROM ( 0x8086, 0x37d3, "x722-sfp-i", "X722 10GbE SFP+", 0 ),
  1425. };
  1426. /** PCI driver */
  1427. struct pci_driver intelxl_driver __pci_driver = {
  1428. .ids = intelxl_nics,
  1429. .id_count = ( sizeof ( intelxl_nics ) / sizeof ( intelxl_nics[0] ) ),
  1430. .probe = intelxl_probe,
  1431. .remove = intelxl_remove,
  1432. };