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.h 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837
  1. #ifndef _INTELX_H
  2. #define _INTELX_H
  3. /** @file
  4. *
  5. * Intel 40 Gigabit Ethernet network card driver
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  9. #include <stdint.h>
  10. #include <ipxe/if_ether.h>
  11. struct intelxl_nic;
  12. /** BAR size */
  13. #define INTELXL_BAR_SIZE 0x200000
  14. /** Alignment
  15. *
  16. * No data structure requires greater than 128 byte alignment.
  17. */
  18. #define INTELXL_ALIGN 128
  19. /******************************************************************************
  20. *
  21. * Admin queue
  22. *
  23. ******************************************************************************
  24. */
  25. /** PF Admin Command Queue register block */
  26. #define INTELXL_ADMIN_CMD 0x080000
  27. /** PF Admin Event Queue register block */
  28. #define INTELXL_ADMIN_EVT 0x080080
  29. /** Admin Queue Base Address Low Register (offset) */
  30. #define INTELXL_ADMIN_BAL 0x000
  31. /** Admin Queue Base Address High Register (offset) */
  32. #define INTELXL_ADMIN_BAH 0x100
  33. /** Admin Queue Length Register (offset) */
  34. #define INTELXL_ADMIN_LEN 0x200
  35. #define INTELXL_ADMIN_LEN_LEN(x) ( (x) << 0 ) /**< Queue length */
  36. #define INTELXL_ADMIN_LEN_ENABLE 0x80000000UL /**< Queue enable */
  37. /** Admin Queue Head Register (offset) */
  38. #define INTELXL_ADMIN_HEAD 0x300
  39. /** Admin Queue Tail Register (offset) */
  40. #define INTELXL_ADMIN_TAIL 0x400
  41. /** Admin queue register offsets
  42. *
  43. * The physical and virtual function register maps have no discernible
  44. * relationship.
  45. */
  46. struct intelxl_admin_offsets {
  47. /** Base Address Low Register offset */
  48. unsigned int bal;
  49. /** Base Address High Register offset */
  50. unsigned int bah;
  51. /** Length Register offset */
  52. unsigned int len;
  53. /** Head Register offset */
  54. unsigned int head;
  55. /** Tail Register offset */
  56. unsigned int tail;
  57. };
  58. /** Admin queue data buffer command parameters */
  59. struct intelxl_admin_buffer_params {
  60. /** Reserved */
  61. uint8_t reserved[8];
  62. /** Buffer address high */
  63. uint32_t high;
  64. /** Buffer address low */
  65. uint32_t low;
  66. } __attribute__ (( packed ));
  67. /** Admin queue Get Version command */
  68. #define INTELXL_ADMIN_VERSION 0x0001
  69. /** Admin queue version number */
  70. struct intelxl_admin_version {
  71. /** Major version number */
  72. uint16_t major;
  73. /** Minor version number */
  74. uint16_t minor;
  75. } __attribute__ (( packed ));
  76. /** Admin queue Get Version command parameters */
  77. struct intelxl_admin_version_params {
  78. /** ROM version */
  79. uint32_t rom;
  80. /** Firmware build ID */
  81. uint32_t build;
  82. /** Firmware version */
  83. struct intelxl_admin_version firmware;
  84. /** API version */
  85. struct intelxl_admin_version api;
  86. } __attribute__ (( packed ));
  87. /** Admin queue Driver Version command */
  88. #define INTELXL_ADMIN_DRIVER 0x0002
  89. /** Admin queue Driver Version command parameters */
  90. struct intelxl_admin_driver_params {
  91. /** Driver version */
  92. uint8_t major;
  93. /** Minor version */
  94. uint8_t minor;
  95. /** Build version */
  96. uint8_t build;
  97. /** Sub-build version */
  98. uint8_t sub;
  99. /** Reserved */
  100. uint8_t reserved[4];
  101. /** Data buffer address */
  102. uint64_t address;
  103. } __attribute__ (( packed ));
  104. /** Admin queue Driver Version data buffer */
  105. struct intelxl_admin_driver_buffer {
  106. /** Driver name */
  107. char name[32];
  108. } __attribute__ (( packed ));
  109. /** Admin queue Shutdown command */
  110. #define INTELXL_ADMIN_SHUTDOWN 0x0003
  111. /** Admin queue Shutdown command parameters */
  112. struct intelxl_admin_shutdown_params {
  113. /** Driver unloading */
  114. uint8_t unloading;
  115. /** Reserved */
  116. uint8_t reserved[15];
  117. } __attribute__ (( packed ));
  118. /** Driver is unloading */
  119. #define INTELXL_ADMIN_SHUTDOWN_UNLOADING 0x01
  120. /** Admin queue Get Switch Configuration command */
  121. #define INTELXL_ADMIN_SWITCH 0x0200
  122. /** Switching element configuration */
  123. struct intelxl_admin_switch_config {
  124. /** Switching element type */
  125. uint8_t type;
  126. /** Revision */
  127. uint8_t revision;
  128. /** Switching element ID */
  129. uint16_t seid;
  130. /** Uplink switching element ID */
  131. uint16_t uplink;
  132. /** Downlink switching element ID */
  133. uint16_t downlink;
  134. /** Reserved */
  135. uint8_t reserved_b[3];
  136. /** Connection type */
  137. uint8_t connection;
  138. /** Reserved */
  139. uint8_t reserved_c[2];
  140. /** Element specific information */
  141. uint16_t info;
  142. } __attribute__ (( packed ));
  143. /** Virtual Station Inferface element type */
  144. #define INTELXL_ADMIN_SWITCH_TYPE_VSI 19
  145. /** Admin queue Get Switch Configuration command parameters */
  146. struct intelxl_admin_switch_params {
  147. /** Starting switching element identifier */
  148. uint16_t next;
  149. /** Reserved */
  150. uint8_t reserved[6];
  151. /** Data buffer address */
  152. uint64_t address;
  153. } __attribute__ (( packed ));
  154. /** Admin queue Get Switch Configuration data buffer */
  155. struct intelxl_admin_switch_buffer {
  156. /** Number of switching elements reported */
  157. uint16_t count;
  158. /** Total number of switching elements */
  159. uint16_t total;
  160. /** Reserved */
  161. uint8_t reserved_a[12];
  162. /** Switch configuration */
  163. struct intelxl_admin_switch_config cfg;
  164. } __attribute__ (( packed ));
  165. /** Admin queue Get VSI Parameters command */
  166. #define INTELXL_ADMIN_VSI 0x0212
  167. /** Admin queue Get VSI Parameters command parameters */
  168. struct intelxl_admin_vsi_params {
  169. /** VSI switching element ID */
  170. uint16_t vsi;
  171. /** Reserved */
  172. uint8_t reserved[6];
  173. /** Data buffer address */
  174. uint64_t address;
  175. } __attribute__ (( packed ));
  176. /** Admin queue Get VSI Parameters data buffer */
  177. struct intelxl_admin_vsi_buffer {
  178. /** Reserved */
  179. uint8_t reserved_a[30];
  180. /** Queue numbers */
  181. uint16_t queue[16];
  182. /** Reserved */
  183. uint8_t reserved_b[34];
  184. /** Queue set handles for each traffic class */
  185. uint16_t qset[8];
  186. /** Reserved */
  187. uint8_t reserved_c[16];
  188. } __attribute__ (( packed ));
  189. /** Admin queue Set VSI Promiscuous Modes command */
  190. #define INTELXL_ADMIN_PROMISC 0x0254
  191. /** Admin queue Set VSI Promiscuous Modes command parameters */
  192. struct intelxl_admin_promisc_params {
  193. /** Flags */
  194. uint16_t flags;
  195. /** Valid flags */
  196. uint16_t valid;
  197. /** VSI switching element ID */
  198. uint16_t vsi;
  199. /** Reserved */
  200. uint8_t reserved[10];
  201. } __attribute__ (( packed ));
  202. /** Promiscuous unicast mode */
  203. #define INTELXL_ADMIN_PROMISC_FL_UNICAST 0x0001
  204. /** Promiscuous multicast mode */
  205. #define INTELXL_ADMIN_PROMISC_FL_MULTICAST 0x0002
  206. /** Promiscuous broadcast mode */
  207. #define INTELXL_ADMIN_PROMISC_FL_BROADCAST 0x0004
  208. /** Promiscuous VLAN mode */
  209. #define INTELXL_ADMIN_PROMISC_FL_VLAN 0x0010
  210. /** Admin queue Restart Autonegotiation command */
  211. #define INTELXL_ADMIN_AUTONEG 0x0605
  212. /** Admin queue Restart Autonegotiation command parameters */
  213. struct intelxl_admin_autoneg_params {
  214. /** Flags */
  215. uint8_t flags;
  216. /** Reserved */
  217. uint8_t reserved[15];
  218. } __attribute__ (( packed ));
  219. /** Restart autonegotiation */
  220. #define INTELXL_ADMIN_AUTONEG_FL_RESTART 0x02
  221. /** Enable link */
  222. #define INTELXL_ADMIN_AUTONEG_FL_ENABLE 0x04
  223. /** Admin queue Get Link Status command */
  224. #define INTELXL_ADMIN_LINK 0x0607
  225. /** Admin queue Get Link Status command parameters */
  226. struct intelxl_admin_link_params {
  227. /** Link status notification */
  228. uint8_t notify;
  229. /** Reserved */
  230. uint8_t reserved_a;
  231. /** PHY type */
  232. uint8_t phy;
  233. /** Link speed */
  234. uint8_t speed;
  235. /** Link status */
  236. uint8_t status;
  237. /** Reserved */
  238. uint8_t reserved_b[11];
  239. } __attribute__ (( packed ));
  240. /** Notify driver of link status changes */
  241. #define INTELXL_ADMIN_LINK_NOTIFY 0x03
  242. /** Link is up */
  243. #define INTELXL_ADMIN_LINK_UP 0x01
  244. /** Admin queue Send Message to PF command */
  245. #define INTELXL_ADMIN_SEND_TO_PF 0x0801
  246. /** Admin queue Send Message to VF command */
  247. #define INTELXL_ADMIN_SEND_TO_VF 0x0802
  248. /** Admin queue command parameters */
  249. union intelxl_admin_params {
  250. /** Additional data buffer command parameters */
  251. struct intelxl_admin_buffer_params buffer;
  252. /** Get Version command parameters */
  253. struct intelxl_admin_version_params version;
  254. /** Driver Version command parameters */
  255. struct intelxl_admin_driver_params driver;
  256. /** Shutdown command parameters */
  257. struct intelxl_admin_shutdown_params shutdown;
  258. /** Get Switch Configuration command parameters */
  259. struct intelxl_admin_switch_params sw;
  260. /** Get VSI Parameters command parameters */
  261. struct intelxl_admin_vsi_params vsi;
  262. /** Set VSI Promiscuous Modes command parameters */
  263. struct intelxl_admin_promisc_params promisc;
  264. /** Restart Autonegotiation command parameters */
  265. struct intelxl_admin_autoneg_params autoneg;
  266. /** Get Link Status command parameters */
  267. struct intelxl_admin_link_params link;
  268. } __attribute__ (( packed ));
  269. /** Admin queue data buffer */
  270. union intelxl_admin_buffer {
  271. /** Driver Version data buffer */
  272. struct intelxl_admin_driver_buffer driver;
  273. /** Get Switch Configuration data buffer */
  274. struct intelxl_admin_switch_buffer sw;
  275. /** Get VSI Parameters data buffer */
  276. struct intelxl_admin_vsi_buffer vsi;
  277. /** Alignment padding */
  278. uint8_t pad[INTELXL_ALIGN];
  279. } __attribute__ (( packed ));
  280. /** Admin queue descriptor */
  281. struct intelxl_admin_descriptor {
  282. /** Flags */
  283. uint16_t flags;
  284. /** Opcode */
  285. uint16_t opcode;
  286. /** Data length */
  287. uint16_t len;
  288. /** Return value */
  289. uint16_t ret;
  290. /** Opaque cookie / VF opcode */
  291. union {
  292. /** Cookie */
  293. uint32_t cookie;
  294. /** VF opcode */
  295. uint32_t vopcode;
  296. };
  297. /** VF return value */
  298. int32_t vret;
  299. /** Parameters */
  300. union intelxl_admin_params params;
  301. } __attribute__ (( packed ));
  302. /** Admin descriptor done */
  303. #define INTELXL_ADMIN_FL_DD 0x0001
  304. /** Admin descriptor contains a completion */
  305. #define INTELXL_ADMIN_FL_CMP 0x0002
  306. /** Admin descriptor completed in error */
  307. #define INTELXL_ADMIN_FL_ERR 0x0004
  308. /** Admin descriptor uses data buffer for command parameters */
  309. #define INTELXL_ADMIN_FL_RD 0x0400
  310. /** Admin descriptor uses data buffer */
  311. #define INTELXL_ADMIN_FL_BUF 0x1000
  312. /** Admin queue */
  313. struct intelxl_admin {
  314. /** Descriptors */
  315. struct intelxl_admin_descriptor *desc;
  316. /** Data buffers */
  317. union intelxl_admin_buffer *buf;
  318. /** Queue index */
  319. unsigned int index;
  320. /** Register block base */
  321. unsigned int base;
  322. /** Register offsets */
  323. const struct intelxl_admin_offsets *regs;
  324. };
  325. /**
  326. * Initialise admin queue
  327. *
  328. * @v admin Admin queue
  329. * @v base Register block base
  330. * @v regs Register offsets
  331. */
  332. static inline __attribute__ (( always_inline )) void
  333. intelxl_init_admin ( struct intelxl_admin *admin, unsigned int base,
  334. const struct intelxl_admin_offsets *regs ) {
  335. admin->base = base;
  336. admin->regs = regs;
  337. }
  338. /** Number of admin queue descriptors */
  339. #define INTELXL_ADMIN_NUM_DESC 4
  340. /** Maximum time to wait for an admin request to complete */
  341. #define INTELXL_ADMIN_MAX_WAIT_MS 100
  342. /** Admin queue API major version */
  343. #define INTELXL_ADMIN_API_MAJOR 1
  344. /******************************************************************************
  345. *
  346. * Transmit and receive queue context
  347. *
  348. ******************************************************************************
  349. */
  350. /** CMLAN Context Data Register */
  351. #define INTELXL_PFCM_LANCTXDATA(x) ( 0x10c100 + ( 0x80 * (x) ) )
  352. /** CMLAN Context Control Register */
  353. #define INTELXL_PFCM_LANCTXCTL 0x10c300
  354. #define INTELXL_PFCM_LANCTXCTL_QUEUE_NUM(x) \
  355. ( (x) << 0 ) /**< Queue number */
  356. #define INTELXL_PFCM_LANCTXCTL_SUB_LINE(x) \
  357. ( (x) << 12 ) /**< Sub-line */
  358. #define INTELXL_PFCM_LANCTXCTL_TYPE(x) \
  359. ( (x) << 15 ) /**< Queue type */
  360. #define INTELXL_PFCM_LANCTXCTL_TYPE_RX \
  361. INTELXL_PFCM_LANCTXCTL_TYPE ( 0x0 ) /**< RX queue type */
  362. #define INTELXL_PFCM_LANCTXCTL_TYPE_TX \
  363. INTELXL_PFCM_LANCTXCTL_TYPE ( 0x1 ) /**< TX queue type */
  364. #define INTELXL_PFCM_LANCTXCTL_OP_CODE(x) \
  365. ( (x) << 17 ) /**< Op code */
  366. #define INTELXL_PFCM_LANCTXCTL_OP_CODE_READ \
  367. INTELXL_PFCM_LANCTXCTL_OP_CODE ( 0x0 ) /**< Read context */
  368. #define INTELXL_PFCM_LANCTXCTL_OP_CODE_WRITE \
  369. INTELXL_PFCM_LANCTXCTL_OP_CODE ( 0x1 ) /**< Write context */
  370. /** CMLAN Context Status Register */
  371. #define INTELXL_PFCM_LANCTXSTAT 0x10c380
  372. #define INTELXL_PFCM_LANCTXSTAT_DONE 0x00000001UL /**< Complete */
  373. /** Queue context line */
  374. struct intelxl_context_line {
  375. /** Raw data */
  376. uint32_t raw[4];
  377. } __attribute__ (( packed ));
  378. /** Transmit queue context */
  379. struct intelxl_context_tx {
  380. /** Head pointer */
  381. uint16_t head;
  382. /** Flags */
  383. uint16_t flags;
  384. /** Base address */
  385. uint64_t base;
  386. /** Reserved */
  387. uint8_t reserved_a[8];
  388. /** Queue count */
  389. uint16_t count;
  390. /** Reserved */
  391. uint8_t reserved_b[100];
  392. /** Queue set */
  393. uint16_t qset;
  394. /** Reserved */
  395. uint8_t reserved_c[4];
  396. } __attribute__ (( packed ));
  397. /** New transmit queue context */
  398. #define INTELXL_CTX_TX_FL_NEW 0x4000
  399. /** Transmit queue base address */
  400. #define INTELXL_CTX_TX_BASE( base ) ( (base) >> 7 )
  401. /** Transmit queue count */
  402. #define INTELXL_CTX_TX_COUNT( count ) ( (count) << 1 )
  403. /** Transmit queue set */
  404. #define INTELXL_CTX_TX_QSET( qset) ( (qset) << 4 )
  405. /** Receive queue context */
  406. struct intelxl_context_rx {
  407. /** Head pointer */
  408. uint16_t head;
  409. /** Reserved */
  410. uint8_t reserved_a[2];
  411. /** Base address and queue count */
  412. uint64_t base_count;
  413. /** Data buffer length */
  414. uint16_t len;
  415. /** Flags */
  416. uint8_t flags;
  417. /** Reserved */
  418. uint8_t reserved_b[7];
  419. /** Maximum frame size */
  420. uint16_t mfs;
  421. } __attribute__ (( packed ));
  422. /** Receive queue base address and queue count */
  423. #define INTELXL_CTX_RX_BASE_COUNT( base, count ) \
  424. ( ( (base) >> 7 ) | ( ( ( uint64_t ) (count) ) << 57 ) )
  425. /** Receive queue data buffer length */
  426. #define INTELXL_CTX_RX_LEN( len ) ( (len) >> 1 )
  427. /** Strip CRC from received packets */
  428. #define INTELXL_CTX_RX_FL_CRCSTRIP 0x20
  429. /** Receive queue maximum frame size */
  430. #define INTELXL_CTX_RX_MFS( mfs ) ( (mfs) >> 2 )
  431. /** Maximum time to wait for a context operation to complete */
  432. #define INTELXL_CTX_MAX_WAIT_MS 100
  433. /** Time to wait for a queue to become enabled */
  434. #define INTELXL_QUEUE_ENABLE_DELAY_US 20
  435. /** Time to wait for a transmit queue to become pre-disabled */
  436. #define INTELXL_QUEUE_PRE_DISABLE_DELAY_US 400
  437. /** Maximum time to wait for a queue to become disabled */
  438. #define INTELXL_QUEUE_DISABLE_MAX_WAIT_MS 1000
  439. /******************************************************************************
  440. *
  441. * Transmit and receive descriptors
  442. *
  443. ******************************************************************************
  444. */
  445. /** Global Transmit Queue Head register */
  446. #define INTELXL_QTX_HEAD(x) ( 0x0e4000 + ( 0x4 * (x) ) )
  447. /** Global Transmit Pre Queue Disable register */
  448. #define INTELXL_GLLAN_TXPRE_QDIS(x) ( 0x0e6500 + ( 0x4 * ( (x) / 0x80 ) ) )
  449. #define INTELXL_GLLAN_TXPRE_QDIS_QINDX(x) \
  450. ( (x) << 0 ) /**< Queue index */
  451. #define INTELXL_GLLAN_TXPRE_QDIS_SET_QDIS \
  452. 0x40000000UL /**< Set disable */
  453. #define INTELXL_GLLAN_TXPRE_QDIS_CLEAR_QDIS \
  454. 0x80000000UL /**< Clear disable */
  455. /** Global Transmit Queue register block */
  456. #define INTELXL_QTX(x) ( 0x100000 + ( 0x4 * (x) ) )
  457. /** Global Receive Queue register block */
  458. #define INTELXL_QRX(x) ( 0x120000 + ( 0x4 * (x) ) )
  459. /** Queue Enable Register (offset) */
  460. #define INTELXL_QXX_ENA 0x0000
  461. #define INTELXL_QXX_ENA_REQ 0x00000001UL /**< Enable request */
  462. #define INTELXL_QXX_ENA_STAT 0x00000004UL /**< Enabled status */
  463. /** Queue Control Register (offset) */
  464. #define INTELXL_QXX_CTL 0x4000
  465. #define INTELXL_QXX_CTL_PFVF_Q(x) ( (x) << 0 ) /**< PF/VF queue */
  466. #define INTELXL_QXX_CTL_PFVF_Q_PF \
  467. INTELXL_QXX_CTL_PFVF_Q ( 0x2 ) /**< PF queue */
  468. #define INTELXL_QXX_CTL_PFVF_PF_INDX(x) ( (x) << 2 ) /**< PF index */
  469. /** Queue Tail Pointer Register (offset) */
  470. #define INTELXL_QXX_TAIL 0x8000
  471. /** Transmit data descriptor */
  472. struct intelxl_tx_data_descriptor {
  473. /** Buffer address */
  474. uint64_t address;
  475. /** Flags */
  476. uint32_t flags;
  477. /** Length */
  478. uint32_t len;
  479. } __attribute__ (( packed ));
  480. /** Transmit data descriptor type */
  481. #define INTELXL_TX_DATA_DTYP 0x0
  482. /** Transmit data descriptor end of packet */
  483. #define INTELXL_TX_DATA_EOP 0x10
  484. /** Transmit data descriptor report status */
  485. #define INTELXL_TX_DATA_RS 0x20
  486. /** Transmit data descriptor pretty please
  487. *
  488. * This bit is completely missing from older versions of the XL710
  489. * datasheet. Later versions describe it innocuously as "reserved,
  490. * must be 1". Without this bit, everything will appear to work (up
  491. * to and including the port "transmit good octets" counter), but no
  492. * packet will actually be sent.
  493. */
  494. #define INTELXL_TX_DATA_JFDI 0x40
  495. /** Transmit data descriptor length */
  496. #define INTELXL_TX_DATA_LEN( len ) ( (len) << 2 )
  497. /** Transmit writeback descriptor */
  498. struct intelxl_tx_writeback_descriptor {
  499. /** Reserved */
  500. uint8_t reserved_a[8];
  501. /** Flags */
  502. uint8_t flags;
  503. /** Reserved */
  504. uint8_t reserved_b[7];
  505. } __attribute__ (( packed ));
  506. /** Transmit writeback descriptor complete */
  507. #define INTELXL_TX_WB_FL_DD 0x01
  508. /** Receive data descriptor */
  509. struct intelxl_rx_data_descriptor {
  510. /** Buffer address */
  511. uint64_t address;
  512. /** Flags */
  513. uint32_t flags;
  514. /** Reserved */
  515. uint8_t reserved[4];
  516. } __attribute__ (( packed ));
  517. /** Receive writeback descriptor */
  518. struct intelxl_rx_writeback_descriptor {
  519. /** Reserved */
  520. uint8_t reserved_a[2];
  521. /** VLAN tag */
  522. uint16_t vlan;
  523. /** Reserved */
  524. uint8_t reserved_b[4];
  525. /** Flags */
  526. uint32_t flags;
  527. /** Length */
  528. uint32_t len;
  529. } __attribute__ (( packed ));
  530. /** Receive writeback descriptor complete */
  531. #define INTELXL_RX_WB_FL_DD 0x00000001UL
  532. /** Receive writeback descriptor VLAN tag present */
  533. #define INTELXL_RX_WB_FL_VLAN 0x00000004UL
  534. /** Receive writeback descriptor error */
  535. #define INTELXL_RX_WB_FL_RXE 0x00080000UL
  536. /** Receive writeback descriptor length */
  537. #define INTELXL_RX_WB_LEN(len) ( ( (len) >> 6 ) & 0x3fff )
  538. /** Packet descriptor */
  539. union intelxl_descriptor {
  540. /** Transmit data descriptor */
  541. struct intelxl_tx_data_descriptor tx;
  542. /** Transmit writeback descriptor */
  543. struct intelxl_tx_writeback_descriptor tx_wb;
  544. /** Receive data descriptor */
  545. struct intelxl_rx_data_descriptor rx;
  546. /** Receive writeback descriptor */
  547. struct intelxl_rx_writeback_descriptor rx_wb;
  548. };
  549. /** Descriptor ring */
  550. struct intelxl_ring {
  551. /** Descriptors */
  552. union intelxl_descriptor *desc;
  553. /** Producer index */
  554. unsigned int prod;
  555. /** Consumer index */
  556. unsigned int cons;
  557. /** Register block */
  558. unsigned int reg;
  559. /** Length (in bytes) */
  560. size_t len;
  561. /** Program queue context
  562. *
  563. * @v intelxl Intel device
  564. * @v address Descriptor ring base address
  565. */
  566. int ( * context ) ( struct intelxl_nic *intelxl, physaddr_t address );
  567. };
  568. /**
  569. * Initialise descriptor ring
  570. *
  571. * @v ring Descriptor ring
  572. * @v count Number of descriptors
  573. * @v context Method to program queue context
  574. */
  575. static inline __attribute__ (( always_inline)) void
  576. intelxl_init_ring ( struct intelxl_ring *ring, unsigned int count,
  577. int ( * context ) ( struct intelxl_nic *intelxl,
  578. physaddr_t address ) ) {
  579. ring->len = ( count * sizeof ( ring->desc[0] ) );
  580. ring->context = context;
  581. }
  582. /** Number of transmit descriptors */
  583. #define INTELXL_TX_NUM_DESC 16
  584. /** Transmit descriptor ring maximum fill level */
  585. #define INTELXL_TX_FILL ( INTELXL_TX_NUM_DESC - 1 )
  586. /** Number of receive descriptors
  587. *
  588. * In PXE mode (i.e. able to post single receive descriptors), 8
  589. * descriptors is the only permitted value covering all possible
  590. * numbers of PFs.
  591. */
  592. #define INTELXL_RX_NUM_DESC 8
  593. /** Receive descriptor ring fill level */
  594. #define INTELXL_RX_FILL ( INTELXL_RX_NUM_DESC - 1 )
  595. /******************************************************************************
  596. *
  597. * Top level
  598. *
  599. ******************************************************************************
  600. */
  601. /** PF Interrupt Zero Dynamic Control Register */
  602. #define INTELXL_PFINT_DYN_CTL0 0x038480
  603. #define INTELXL_PFINT_DYN_CTL0_INTENA 0x00000001UL /**< Enable */
  604. #define INTELXL_PFINT_DYN_CTL0_CLEARPBA 0x00000002UL /**< Acknowledge */
  605. #define INTELXL_PFINT_DYN_CTL0_INTENA_MASK 0x80000000UL /**< Ignore enable */
  606. /** PF Interrupt Zero Linked List Register */
  607. #define INTELXL_PFINT_LNKLST0 0x038500
  608. #define INTELXL_PFINT_LNKLST0_FIRSTQ_INDX(x) \
  609. ( (x) << 0 ) /**< Queue index */
  610. #define INTELXL_PFINT_LNKLST0_FIRSTQ_INDX_NONE \
  611. INTELXL_PFINT_LNKLST0_FIRSTQ_INDX ( 0x7ff ) /**< End of list */
  612. #define INTELXL_PFINT_LNKLST0_FIRSTQ_TYPE(x) \
  613. ( (x) << 11 ) /**< Queue type */
  614. #define INTELXL_PFINT_LNKLST0_FIRSTQ_TYPE_RX \
  615. INTELXL_PFINT_LNKLST0_FIRSTQ_TYPE ( 0x0 ) /**< Receive queue */
  616. #define INTELXL_PFINT_LNKLST0_FIRSTQ_TYPE_TX \
  617. INTELXL_PFINT_LNKLST0_FIRSTQ_TYPE ( 0x1 ) /**< Transmit queue */
  618. /** PF Interrupt Zero Cause Enablement Register */
  619. #define INTELXL_PFINT_ICR0_ENA 0x038800
  620. #define INTELXL_PFINT_ICR0_ENA_ADMINQ 0x40000000UL /**< Admin event */
  621. /** Receive Queue Interrupt Cause Control Register */
  622. #define INTELXL_QINT_RQCTL(x) ( 0x03a000 + ( 0x4 * (x) ) )
  623. #define INTELXL_QINT_RQCTL_NEXTQ_INDX(x) ( (x) << 16 ) /**< Queue index */
  624. #define INTELXL_QINT_RQCTL_NEXTQ_INDX_NONE \
  625. INTELXL_QINT_RQCTL_NEXTQ_INDX ( 0x7ff ) /**< End of list */
  626. #define INTELXL_QINT_RQCTL_NEXTQ_TYPE(x) ( (x) << 27 ) /**< Queue type */
  627. #define INTELXL_QINT_RQCTL_NEXTQ_TYPE_RX \
  628. INTELXL_QINT_RQCTL_NEXTQ_TYPE ( 0x0 ) /**< Receive queue */
  629. #define INTELXL_QINT_RQCTL_NEXTQ_TYPE_TX \
  630. INTELXL_QINT_RQCTL_NEXTQ_TYPE ( 0x1 ) /**< Transmit queue */
  631. #define INTELXL_QINT_RQCTL_CAUSE_ENA 0x40000000UL /**< Enable */
  632. /** Transmit Queue Interrupt Cause Control Register */
  633. #define INTELXL_QINT_TQCTL(x) ( 0x03c000 + ( 0x4 * (x) ) )
  634. #define INTELXL_QINT_TQCTL_NEXTQ_INDX(x) ( (x) << 16 ) /**< Queue index */
  635. #define INTELXL_QINT_TQCTL_NEXTQ_INDX_NONE \
  636. INTELXL_QINT_TQCTL_NEXTQ_INDX ( 0x7ff ) /**< End of list */
  637. #define INTELXL_QINT_TQCTL_NEXTQ_TYPE(x) ( (x) << 27 ) /**< Queue type */
  638. #define INTELXL_QINT_TQCTL_NEXTQ_TYPE_RX \
  639. INTELXL_QINT_TQCTL_NEXTQ_TYPE ( 0x0 ) /**< Receive queue */
  640. #define INTELXL_QINT_TQCTL_NEXTQ_TYPE_TX \
  641. INTELXL_QINT_TQCTL_NEXTQ_TYPE ( 0x1 ) /**< Transmit queue */
  642. #define INTELXL_QINT_TQCTL_CAUSE_ENA 0x40000000UL /**< Enable */
  643. /** PF Control Register */
  644. #define INTELXL_PFGEN_CTRL 0x092400
  645. #define INTELXL_PFGEN_CTRL_PFSWR 0x00000001UL /**< Software Reset */
  646. /** Time to delay for device reset, in milliseconds */
  647. #define INTELXL_RESET_DELAY_MS 100
  648. /** PF Queue Allocation Register */
  649. #define INTELXL_PFLAN_QALLOC 0x1c0400
  650. #define INTELXL_PFLAN_QALLOC_FIRSTQ(x) \
  651. ( ( (x) >> 0 ) & 0x7ff ) /**< First queue */
  652. #define INTELXL_PFLAN_QALLOC_LASTQ(x) \
  653. ( ( (x) >> 16 ) & 0x7ff ) /**< Last queue */
  654. /** PF LAN Port Number Register */
  655. #define INTELXL_PFGEN_PORTNUM 0x1c0480
  656. #define INTELXL_PFGEN_PORTNUM_PORT_NUM(x) \
  657. ( ( (x) >> 0 ) & 0x3 ) /**< Port number */
  658. /** Port MAC Address Low Register */
  659. #define INTELXL_PRTGL_SAL 0x1e2120
  660. /** Port MAC Address High Register */
  661. #define INTELXL_PRTGL_SAH 0x1e2140
  662. #define INTELXL_PRTGL_SAH_MFS_GET(x) ( (x) >> 16 ) /**< Max frame size */
  663. #define INTELXL_PRTGL_SAH_MFS_SET(x) ( (x) << 16 ) /**< Max frame size */
  664. /** Receive address */
  665. union intelxl_receive_address {
  666. struct {
  667. uint32_t low;
  668. uint32_t high;
  669. } __attribute__ (( packed )) reg;
  670. uint8_t raw[ETH_ALEN];
  671. };
  672. /** An Intel 40Gigabit network card */
  673. struct intelxl_nic {
  674. /** Registers */
  675. void *regs;
  676. /** Maximum frame size */
  677. size_t mfs;
  678. /** Physical function number */
  679. unsigned int pf;
  680. /** Absolute queue number base */
  681. unsigned int base;
  682. /** Port number */
  683. unsigned int port;
  684. /** Queue number */
  685. unsigned int queue;
  686. /** Virtual Station Interface switching element ID */
  687. unsigned int vsi;
  688. /** Queue set handle */
  689. unsigned int qset;
  690. /** Admin command queue */
  691. struct intelxl_admin command;
  692. /** Admin event queue */
  693. struct intelxl_admin event;
  694. /** Transmit descriptor ring */
  695. struct intelxl_ring tx;
  696. /** Receive descriptor ring */
  697. struct intelxl_ring rx;
  698. /** Receive I/O buffers */
  699. struct io_buffer *rx_iobuf[INTELXL_RX_NUM_DESC];
  700. };
  701. extern void intelxlvf_admin_event ( struct net_device *netdev,
  702. struct intelxl_admin_descriptor *evt,
  703. union intelxl_admin_buffer *buf );
  704. #endif /* _INTELXL_H */