liquidio_common.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909
  1. /**********************************************************************
  2. * Author: Cavium, Inc.
  3. *
  4. * Contact: support@cavium.com
  5. * Please include "LiquidIO" in the subject.
  6. *
  7. * Copyright (c) 2003-2016 Cavium, Inc.
  8. *
  9. * This file is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License, Version 2, as
  11. * published by the Free Software Foundation.
  12. *
  13. * This file is distributed in the hope that it will be useful, but
  14. * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
  15. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
  16. * NONINFRINGEMENT. See the GNU General Public License for more details.
  17. ***********************************************************************/
  18. /*! \file liquidio_common.h
  19. * \brief Common: Structures and macros used in PCI-NIC package by core and
  20. * host driver.
  21. */
  22. #ifndef __LIQUIDIO_COMMON_H__
  23. #define __LIQUIDIO_COMMON_H__
  24. #include "octeon_config.h"
  25. #define LIQUIDIO_PACKAGE ""
  26. #define LIQUIDIO_BASE_MAJOR_VERSION 1
  27. #define LIQUIDIO_BASE_MINOR_VERSION 4
  28. #define LIQUIDIO_BASE_MICRO_VERSION 1
  29. #define LIQUIDIO_BASE_VERSION __stringify(LIQUIDIO_BASE_MAJOR_VERSION) "." \
  30. __stringify(LIQUIDIO_BASE_MINOR_VERSION)
  31. #define LIQUIDIO_MICRO_VERSION "." __stringify(LIQUIDIO_BASE_MICRO_VERSION)
  32. #define LIQUIDIO_VERSION LIQUIDIO_PACKAGE \
  33. __stringify(LIQUIDIO_BASE_MAJOR_VERSION) "." \
  34. __stringify(LIQUIDIO_BASE_MINOR_VERSION) \
  35. "." __stringify(LIQUIDIO_BASE_MICRO_VERSION)
  36. struct lio_version {
  37. u16 major;
  38. u16 minor;
  39. u16 micro;
  40. u16 reserved;
  41. };
  42. #define CONTROL_IQ 0
  43. /** Tag types used by Octeon cores in its work. */
  44. enum octeon_tag_type {
  45. ORDERED_TAG = 0,
  46. ATOMIC_TAG = 1,
  47. NULL_TAG = 2,
  48. NULL_NULL_TAG = 3
  49. };
  50. /* pre-defined host->NIC tag values */
  51. #define LIO_CONTROL (0x11111110)
  52. #define LIO_DATA(i) (0x11111111 + (i))
  53. /* Opcodes used by host driver/apps to perform operations on the core.
  54. * These are used to identify the major subsystem that the operation
  55. * is for.
  56. */
  57. #define OPCODE_CORE 0 /* used for generic core operations */
  58. #define OPCODE_NIC 1 /* used for NIC operations */
  59. /* Subcodes are used by host driver/apps to identify the sub-operation
  60. * for the core. They only need to by unique for a given subsystem.
  61. */
  62. #define OPCODE_SUBCODE(op, sub) ((((op) & 0x0f) << 8) | ((sub) & 0x7f))
  63. /** OPCODE_CORE subcodes. For future use. */
  64. /** OPCODE_NIC subcodes */
  65. /* This subcode is sent by core PCI driver to indicate cores are ready. */
  66. #define OPCODE_NIC_CORE_DRV_ACTIVE 0x01
  67. #define OPCODE_NIC_NW_DATA 0x02 /* network packet data */
  68. #define OPCODE_NIC_CMD 0x03
  69. #define OPCODE_NIC_INFO 0x04
  70. #define OPCODE_NIC_PORT_STATS 0x05
  71. #define OPCODE_NIC_MDIO45 0x06
  72. #define OPCODE_NIC_TIMESTAMP 0x07
  73. #define OPCODE_NIC_INTRMOD_CFG 0x08
  74. #define OPCODE_NIC_IF_CFG 0x09
  75. #define OPCODE_NIC_VF_DRV_NOTICE 0x0A
  76. #define VF_DRV_LOADED 1
  77. #define VF_DRV_REMOVED -1
  78. #define VF_DRV_MACADDR_CHANGED 2
  79. #define CORE_DRV_TEST_SCATTER_OP 0xFFF5
  80. /* Application codes advertised by the core driver initialization packet. */
  81. #define CVM_DRV_APP_START 0x0
  82. #define CVM_DRV_NO_APP 0
  83. #define CVM_DRV_APP_COUNT 0x2
  84. #define CVM_DRV_BASE_APP (CVM_DRV_APP_START + 0x0)
  85. #define CVM_DRV_NIC_APP (CVM_DRV_APP_START + 0x1)
  86. #define CVM_DRV_INVALID_APP (CVM_DRV_APP_START + 0x2)
  87. #define CVM_DRV_APP_END (CVM_DRV_INVALID_APP - 1)
  88. #define BYTES_PER_DHLEN_UNIT 8
  89. #define MAX_REG_CNT 2000000U
  90. static inline u32 incr_index(u32 index, u32 count, u32 max)
  91. {
  92. if ((index + count) >= max)
  93. index = index + count - max;
  94. else
  95. index += count;
  96. return index;
  97. }
  98. #define OCT_BOARD_NAME 32
  99. #define OCT_SERIAL_LEN 64
  100. /* Structure used by core driver to send indication that the Octeon
  101. * application is ready.
  102. */
  103. struct octeon_core_setup {
  104. u64 corefreq;
  105. char boardname[OCT_BOARD_NAME];
  106. char board_serial_number[OCT_SERIAL_LEN];
  107. u64 board_rev_major;
  108. u64 board_rev_minor;
  109. };
  110. /*--------------------------- SCATTER GATHER ENTRY -----------------------*/
  111. /* The Scatter-Gather List Entry. The scatter or gather component used with
  112. * a Octeon input instruction has this format.
  113. */
  114. struct octeon_sg_entry {
  115. /** The first 64 bit gives the size of data in each dptr.*/
  116. union {
  117. u16 size[4];
  118. u64 size64;
  119. } u;
  120. /** The 4 dptr pointers for this entry. */
  121. u64 ptr[4];
  122. };
  123. #define OCT_SG_ENTRY_SIZE (sizeof(struct octeon_sg_entry))
  124. /* \brief Add size to gather list
  125. * @param sg_entry scatter/gather entry
  126. * @param size size to add
  127. * @param pos position to add it.
  128. */
  129. static inline void add_sg_size(struct octeon_sg_entry *sg_entry,
  130. u16 size,
  131. u32 pos)
  132. {
  133. #ifdef __BIG_ENDIAN_BITFIELD
  134. sg_entry->u.size[pos] = size;
  135. #else
  136. sg_entry->u.size[3 - pos] = size;
  137. #endif
  138. }
  139. /*------------------------- End Scatter/Gather ---------------------------*/
  140. #define OCTNET_FRM_PTP_HEADER_SIZE 8
  141. #define OCTNET_FRM_HEADER_SIZE 22 /* VLAN + Ethernet */
  142. #define OCTNET_MIN_FRM_SIZE 64
  143. #define OCTNET_MAX_FRM_SIZE (16000 + OCTNET_FRM_HEADER_SIZE)
  144. #define OCTNET_DEFAULT_FRM_SIZE (1500 + OCTNET_FRM_HEADER_SIZE)
  145. /** NIC Commands are sent using this Octeon Input Queue */
  146. #define OCTNET_CMD_Q 0
  147. /* NIC Command types */
  148. #define OCTNET_CMD_CHANGE_MTU 0x1
  149. #define OCTNET_CMD_CHANGE_MACADDR 0x2
  150. #define OCTNET_CMD_CHANGE_DEVFLAGS 0x3
  151. #define OCTNET_CMD_RX_CTL 0x4
  152. #define OCTNET_CMD_SET_MULTI_LIST 0x5
  153. #define OCTNET_CMD_CLEAR_STATS 0x6
  154. /* command for setting the speed, duplex & autoneg */
  155. #define OCTNET_CMD_SET_SETTINGS 0x7
  156. #define OCTNET_CMD_SET_FLOW_CTL 0x8
  157. #define OCTNET_CMD_MDIO_READ_WRITE 0x9
  158. #define OCTNET_CMD_GPIO_ACCESS 0xA
  159. #define OCTNET_CMD_LRO_ENABLE 0xB
  160. #define OCTNET_CMD_LRO_DISABLE 0xC
  161. #define OCTNET_CMD_SET_RSS 0xD
  162. #define OCTNET_CMD_WRITE_SA 0xE
  163. #define OCTNET_CMD_DELETE_SA 0xF
  164. #define OCTNET_CMD_UPDATE_SA 0x12
  165. #define OCTNET_CMD_TNL_RX_CSUM_CTL 0x10
  166. #define OCTNET_CMD_TNL_TX_CSUM_CTL 0x11
  167. #define OCTNET_CMD_IPSECV2_AH_ESP_CTL 0x13
  168. #define OCTNET_CMD_VERBOSE_ENABLE 0x14
  169. #define OCTNET_CMD_VERBOSE_DISABLE 0x15
  170. #define OCTNET_CMD_ENABLE_VLAN_FILTER 0x16
  171. #define OCTNET_CMD_ADD_VLAN_FILTER 0x17
  172. #define OCTNET_CMD_DEL_VLAN_FILTER 0x18
  173. #define OCTNET_CMD_VXLAN_PORT_CONFIG 0x19
  174. #define OCTNET_CMD_ID_ACTIVE 0x1a
  175. #define OCTNET_CMD_SET_UC_LIST 0x1b
  176. #define OCTNET_CMD_SET_VF_LINKSTATE 0x1c
  177. #define OCTNET_CMD_VXLAN_PORT_ADD 0x0
  178. #define OCTNET_CMD_VXLAN_PORT_DEL 0x1
  179. #define OCTNET_CMD_RXCSUM_ENABLE 0x0
  180. #define OCTNET_CMD_RXCSUM_DISABLE 0x1
  181. #define OCTNET_CMD_TXCSUM_ENABLE 0x0
  182. #define OCTNET_CMD_TXCSUM_DISABLE 0x1
  183. /* RX(packets coming from wire) Checksum verification flags */
  184. /* TCP/UDP csum */
  185. #define CNNIC_L4SUM_VERIFIED 0x1
  186. #define CNNIC_IPSUM_VERIFIED 0x2
  187. #define CNNIC_TUN_CSUM_VERIFIED 0x4
  188. #define CNNIC_CSUM_VERIFIED (CNNIC_IPSUM_VERIFIED | CNNIC_L4SUM_VERIFIED)
  189. /*LROIPV4 and LROIPV6 Flags*/
  190. #define OCTNIC_LROIPV4 0x1
  191. #define OCTNIC_LROIPV6 0x2
  192. /* Interface flags communicated between host driver and core app. */
  193. enum octnet_ifflags {
  194. OCTNET_IFFLAG_PROMISC = 0x01,
  195. OCTNET_IFFLAG_ALLMULTI = 0x02,
  196. OCTNET_IFFLAG_MULTICAST = 0x04,
  197. OCTNET_IFFLAG_BROADCAST = 0x08,
  198. OCTNET_IFFLAG_UNICAST = 0x10
  199. };
  200. /* wqe
  201. * --------------- 0
  202. * | wqe word0-3 |
  203. * --------------- 32
  204. * | PCI IH |
  205. * --------------- 40
  206. * | RPTR |
  207. * --------------- 48
  208. * | PCI IRH |
  209. * --------------- 56
  210. * | OCT_NET_CMD |
  211. * --------------- 64
  212. * | Addtl 8-BData |
  213. * | |
  214. * ---------------
  215. */
  216. union octnet_cmd {
  217. u64 u64;
  218. struct {
  219. #ifdef __BIG_ENDIAN_BITFIELD
  220. u64 cmd:5;
  221. u64 more:6; /* How many udd words follow the command */
  222. u64 reserved:29;
  223. u64 param1:16;
  224. u64 param2:8;
  225. #else
  226. u64 param2:8;
  227. u64 param1:16;
  228. u64 reserved:29;
  229. u64 more:6;
  230. u64 cmd:5;
  231. #endif
  232. } s;
  233. };
  234. #define OCTNET_CMD_SIZE (sizeof(union octnet_cmd))
  235. /*pkiih3 + irh + ossp[0] + ossp[1] + rdp + rptr = 40 bytes */
  236. #define LIO_SOFTCMDRESP_IH2 40
  237. #define LIO_SOFTCMDRESP_IH3 (40 + 8)
  238. #define LIO_PCICMD_O2 24
  239. #define LIO_PCICMD_O3 (24 + 8)
  240. /* Instruction Header(DPI) - for OCTEON-III models */
  241. struct octeon_instr_ih3 {
  242. #ifdef __BIG_ENDIAN_BITFIELD
  243. /** Reserved3 */
  244. u64 reserved3:1;
  245. /** Gather indicator 1=gather*/
  246. u64 gather:1;
  247. /** Data length OR no. of entries in gather list */
  248. u64 dlengsz:14;
  249. /** Front Data size */
  250. u64 fsz:6;
  251. /** Reserved2 */
  252. u64 reserved2:4;
  253. /** PKI port kind - PKIND */
  254. u64 pkind:6;
  255. /** Reserved1 */
  256. u64 reserved1:32;
  257. #else
  258. /** Reserved1 */
  259. u64 reserved1:32;
  260. /** PKI port kind - PKIND */
  261. u64 pkind:6;
  262. /** Reserved2 */
  263. u64 reserved2:4;
  264. /** Front Data size */
  265. u64 fsz:6;
  266. /** Data length OR no. of entries in gather list */
  267. u64 dlengsz:14;
  268. /** Gather indicator 1=gather*/
  269. u64 gather:1;
  270. /** Reserved3 */
  271. u64 reserved3:1;
  272. #endif
  273. };
  274. /* Optional PKI Instruction Header(PKI IH) - for OCTEON-III models */
  275. /** BIG ENDIAN format. */
  276. struct octeon_instr_pki_ih3 {
  277. #ifdef __BIG_ENDIAN_BITFIELD
  278. /** Wider bit */
  279. u64 w:1;
  280. /** Raw mode indicator 1 = RAW */
  281. u64 raw:1;
  282. /** Use Tag */
  283. u64 utag:1;
  284. /** Use QPG */
  285. u64 uqpg:1;
  286. /** Reserved2 */
  287. u64 reserved2:1;
  288. /** Parse Mode */
  289. u64 pm:3;
  290. /** Skip Length */
  291. u64 sl:8;
  292. /** Use Tag Type */
  293. u64 utt:1;
  294. /** Tag type */
  295. u64 tagtype:2;
  296. /** Reserved1 */
  297. u64 reserved1:2;
  298. /** QPG Value */
  299. u64 qpg:11;
  300. /** Tag Value */
  301. u64 tag:32;
  302. #else
  303. /** Tag Value */
  304. u64 tag:32;
  305. /** QPG Value */
  306. u64 qpg:11;
  307. /** Reserved1 */
  308. u64 reserved1:2;
  309. /** Tag type */
  310. u64 tagtype:2;
  311. /** Use Tag Type */
  312. u64 utt:1;
  313. /** Skip Length */
  314. u64 sl:8;
  315. /** Parse Mode */
  316. u64 pm:3;
  317. /** Reserved2 */
  318. u64 reserved2:1;
  319. /** Use QPG */
  320. u64 uqpg:1;
  321. /** Use Tag */
  322. u64 utag:1;
  323. /** Raw mode indicator 1 = RAW */
  324. u64 raw:1;
  325. /** Wider bit */
  326. u64 w:1;
  327. #endif
  328. };
  329. /** Instruction Header */
  330. struct octeon_instr_ih2 {
  331. #ifdef __BIG_ENDIAN_BITFIELD
  332. /** Raw mode indicator 1 = RAW */
  333. u64 raw:1;
  334. /** Gather indicator 1=gather*/
  335. u64 gather:1;
  336. /** Data length OR no. of entries in gather list */
  337. u64 dlengsz:14;
  338. /** Front Data size */
  339. u64 fsz:6;
  340. /** Packet Order / Work Unit selection (1 of 8)*/
  341. u64 qos:3;
  342. /** Core group selection (1 of 16) */
  343. u64 grp:4;
  344. /** Short Raw Packet Indicator 1=short raw pkt */
  345. u64 rs:1;
  346. /** Tag type */
  347. u64 tagtype:2;
  348. /** Tag Value */
  349. u64 tag:32;
  350. #else
  351. /** Tag Value */
  352. u64 tag:32;
  353. /** Tag type */
  354. u64 tagtype:2;
  355. /** Short Raw Packet Indicator 1=short raw pkt */
  356. u64 rs:1;
  357. /** Core group selection (1 of 16) */
  358. u64 grp:4;
  359. /** Packet Order / Work Unit selection (1 of 8)*/
  360. u64 qos:3;
  361. /** Front Data size */
  362. u64 fsz:6;
  363. /** Data length OR no. of entries in gather list */
  364. u64 dlengsz:14;
  365. /** Gather indicator 1=gather*/
  366. u64 gather:1;
  367. /** Raw mode indicator 1 = RAW */
  368. u64 raw:1;
  369. #endif
  370. };
  371. /** Input Request Header */
  372. struct octeon_instr_irh {
  373. #ifdef __BIG_ENDIAN_BITFIELD
  374. u64 opcode:4;
  375. u64 rflag:1;
  376. u64 subcode:7;
  377. u64 vlan:12;
  378. u64 priority:3;
  379. u64 reserved:5;
  380. u64 ossp:32; /* opcode/subcode specific parameters */
  381. #else
  382. u64 ossp:32; /* opcode/subcode specific parameters */
  383. u64 reserved:5;
  384. u64 priority:3;
  385. u64 vlan:12;
  386. u64 subcode:7;
  387. u64 rflag:1;
  388. u64 opcode:4;
  389. #endif
  390. };
  391. /** Return Data Parameters */
  392. struct octeon_instr_rdp {
  393. #ifdef __BIG_ENDIAN_BITFIELD
  394. u64 reserved:49;
  395. u64 pcie_port:3;
  396. u64 rlen:12;
  397. #else
  398. u64 rlen:12;
  399. u64 pcie_port:3;
  400. u64 reserved:49;
  401. #endif
  402. };
  403. /** Receive Header */
  404. union octeon_rh {
  405. #ifdef __BIG_ENDIAN_BITFIELD
  406. u64 u64;
  407. struct {
  408. u64 opcode:4;
  409. u64 subcode:8;
  410. u64 len:3; /** additional 64-bit words */
  411. u64 reserved:17;
  412. u64 ossp:32; /** opcode/subcode specific parameters */
  413. } r;
  414. struct {
  415. u64 opcode:4;
  416. u64 subcode:8;
  417. u64 len:3; /** additional 64-bit words */
  418. u64 extra:28;
  419. u64 vlan:12;
  420. u64 priority:3;
  421. u64 csum_verified:3; /** checksum verified. */
  422. u64 has_hwtstamp:1; /** Has hardware timestamp. 1 = yes. */
  423. u64 encap_on:1;
  424. u64 has_hash:1; /** Has hash (rth or rss). 1 = yes. */
  425. } r_dh;
  426. struct {
  427. u64 opcode:4;
  428. u64 subcode:8;
  429. u64 len:3; /** additional 64-bit words */
  430. u64 reserved:11;
  431. u64 num_gmx_ports:8;
  432. u64 max_nic_ports:10;
  433. u64 app_cap_flags:4;
  434. u64 app_mode:8;
  435. u64 pkind:8;
  436. } r_core_drv_init;
  437. struct {
  438. u64 opcode:4;
  439. u64 subcode:8;
  440. u64 len:3; /** additional 64-bit words */
  441. u64 reserved:8;
  442. u64 extra:25;
  443. u64 gmxport:16;
  444. } r_nic_info;
  445. #else
  446. u64 u64;
  447. struct {
  448. u64 ossp:32; /** opcode/subcode specific parameters */
  449. u64 reserved:17;
  450. u64 len:3; /** additional 64-bit words */
  451. u64 subcode:8;
  452. u64 opcode:4;
  453. } r;
  454. struct {
  455. u64 has_hash:1; /** Has hash (rth or rss). 1 = yes. */
  456. u64 encap_on:1;
  457. u64 has_hwtstamp:1; /** 1 = has hwtstamp */
  458. u64 csum_verified:3; /** checksum verified. */
  459. u64 priority:3;
  460. u64 vlan:12;
  461. u64 extra:28;
  462. u64 len:3; /** additional 64-bit words */
  463. u64 subcode:8;
  464. u64 opcode:4;
  465. } r_dh;
  466. struct {
  467. u64 pkind:8;
  468. u64 app_mode:8;
  469. u64 app_cap_flags:4;
  470. u64 max_nic_ports:10;
  471. u64 num_gmx_ports:8;
  472. u64 reserved:11;
  473. u64 len:3; /** additional 64-bit words */
  474. u64 subcode:8;
  475. u64 opcode:4;
  476. } r_core_drv_init;
  477. struct {
  478. u64 gmxport:16;
  479. u64 extra:25;
  480. u64 reserved:8;
  481. u64 len:3; /** additional 64-bit words */
  482. u64 subcode:8;
  483. u64 opcode:4;
  484. } r_nic_info;
  485. #endif
  486. };
  487. #define OCT_RH_SIZE (sizeof(union octeon_rh))
  488. union octnic_packet_params {
  489. u32 u32;
  490. struct {
  491. #ifdef __BIG_ENDIAN_BITFIELD
  492. u32 reserved:24;
  493. u32 ip_csum:1; /* Perform IP header checksum(s) */
  494. /* Perform Outer transport header checksum */
  495. u32 transport_csum:1;
  496. /* Find tunnel, and perform transport csum. */
  497. u32 tnl_csum:1;
  498. u32 tsflag:1; /* Timestamp this packet */
  499. u32 ipsec_ops:4; /* IPsec operation */
  500. #else
  501. u32 ipsec_ops:4;
  502. u32 tsflag:1;
  503. u32 tnl_csum:1;
  504. u32 transport_csum:1;
  505. u32 ip_csum:1;
  506. u32 reserved:24;
  507. #endif
  508. } s;
  509. };
  510. /** Status of a RGMII Link on Octeon as seen by core driver. */
  511. union oct_link_status {
  512. u64 u64;
  513. struct {
  514. #ifdef __BIG_ENDIAN_BITFIELD
  515. u64 duplex:8;
  516. u64 mtu:16;
  517. u64 speed:16;
  518. u64 link_up:1;
  519. u64 autoneg:1;
  520. u64 if_mode:5;
  521. u64 pause:1;
  522. u64 flashing:1;
  523. u64 reserved:15;
  524. #else
  525. u64 reserved:15;
  526. u64 flashing:1;
  527. u64 pause:1;
  528. u64 if_mode:5;
  529. u64 autoneg:1;
  530. u64 link_up:1;
  531. u64 speed:16;
  532. u64 mtu:16;
  533. u64 duplex:8;
  534. #endif
  535. } s;
  536. };
  537. /** The txpciq info passed to host from the firmware */
  538. union oct_txpciq {
  539. u64 u64;
  540. struct {
  541. #ifdef __BIG_ENDIAN_BITFIELD
  542. u64 q_no:8;
  543. u64 port:8;
  544. u64 pkind:6;
  545. u64 use_qpg:1;
  546. u64 qpg:11;
  547. u64 reserved:30;
  548. #else
  549. u64 reserved:30;
  550. u64 qpg:11;
  551. u64 use_qpg:1;
  552. u64 pkind:6;
  553. u64 port:8;
  554. u64 q_no:8;
  555. #endif
  556. } s;
  557. };
  558. /** The rxpciq info passed to host from the firmware */
  559. union oct_rxpciq {
  560. u64 u64;
  561. struct {
  562. #ifdef __BIG_ENDIAN_BITFIELD
  563. u64 q_no:8;
  564. u64 reserved:56;
  565. #else
  566. u64 reserved:56;
  567. u64 q_no:8;
  568. #endif
  569. } s;
  570. };
  571. /** Information for a OCTEON ethernet interface shared between core & host. */
  572. struct oct_link_info {
  573. union oct_link_status link;
  574. u64 hw_addr;
  575. #ifdef __BIG_ENDIAN_BITFIELD
  576. u64 gmxport:16;
  577. u64 macaddr_is_admin_asgnd:1;
  578. u64 rsvd:31;
  579. u64 num_txpciq:8;
  580. u64 num_rxpciq:8;
  581. #else
  582. u64 num_rxpciq:8;
  583. u64 num_txpciq:8;
  584. u64 rsvd:31;
  585. u64 macaddr_is_admin_asgnd:1;
  586. u64 gmxport:16;
  587. #endif
  588. union oct_txpciq txpciq[MAX_IOQS_PER_NICIF];
  589. union oct_rxpciq rxpciq[MAX_IOQS_PER_NICIF];
  590. };
  591. #define OCT_LINK_INFO_SIZE (sizeof(struct oct_link_info))
  592. struct liquidio_if_cfg_info {
  593. u64 iqmask; /** mask for IQs enabled for the port */
  594. u64 oqmask; /** mask for OQs enabled for the port */
  595. struct oct_link_info linfo; /** initial link information */
  596. char liquidio_firmware_version[32];
  597. };
  598. /** Stats for each NIC port in RX direction. */
  599. struct nic_rx_stats {
  600. /* link-level stats */
  601. u64 total_rcvd;
  602. u64 bytes_rcvd;
  603. u64 total_bcst;
  604. u64 total_mcst;
  605. u64 runts;
  606. u64 ctl_rcvd;
  607. u64 fifo_err; /* Accounts for over/under-run of buffers */
  608. u64 dmac_drop;
  609. u64 fcs_err;
  610. u64 jabber_err;
  611. u64 l2_err;
  612. u64 frame_err;
  613. /* firmware stats */
  614. u64 fw_total_rcvd;
  615. u64 fw_total_fwd;
  616. u64 fw_err_pko;
  617. u64 fw_err_link;
  618. u64 fw_err_drop;
  619. u64 fw_rx_vxlan;
  620. u64 fw_rx_vxlan_err;
  621. /* LRO */
  622. u64 fw_lro_pkts; /* Number of packets that are LROed */
  623. u64 fw_lro_octs; /* Number of octets that are LROed */
  624. u64 fw_total_lro; /* Number of LRO packets formed */
  625. u64 fw_lro_aborts; /* Number of times lRO of packet aborted */
  626. u64 fw_lro_aborts_port;
  627. u64 fw_lro_aborts_seq;
  628. u64 fw_lro_aborts_tsval;
  629. u64 fw_lro_aborts_timer;
  630. /* intrmod: packet forward rate */
  631. u64 fwd_rate;
  632. };
  633. /** Stats for each NIC port in RX direction. */
  634. struct nic_tx_stats {
  635. /* link-level stats */
  636. u64 total_pkts_sent;
  637. u64 total_bytes_sent;
  638. u64 mcast_pkts_sent;
  639. u64 bcast_pkts_sent;
  640. u64 ctl_sent;
  641. u64 one_collision_sent; /* Packets sent after one collision*/
  642. u64 multi_collision_sent; /* Packets sent after multiple collision*/
  643. u64 max_collision_fail; /* Packets not sent due to max collisions */
  644. u64 max_deferral_fail; /* Packets not sent due to max deferrals */
  645. u64 fifo_err; /* Accounts for over/under-run of buffers */
  646. u64 runts;
  647. u64 total_collisions; /* Total number of collisions detected */
  648. /* firmware stats */
  649. u64 fw_total_sent;
  650. u64 fw_total_fwd;
  651. u64 fw_total_fwd_bytes;
  652. u64 fw_err_pko;
  653. u64 fw_err_link;
  654. u64 fw_err_drop;
  655. u64 fw_err_tso;
  656. u64 fw_tso; /* number of tso requests */
  657. u64 fw_tso_fwd; /* number of packets segmented in tso */
  658. u64 fw_tx_vxlan;
  659. };
  660. struct oct_link_stats {
  661. struct nic_rx_stats fromwire;
  662. struct nic_tx_stats fromhost;
  663. };
  664. static inline int opcode_slow_path(union octeon_rh *rh)
  665. {
  666. u16 subcode1, subcode2;
  667. subcode1 = OPCODE_SUBCODE((rh)->r.opcode, (rh)->r.subcode);
  668. subcode2 = OPCODE_SUBCODE(OPCODE_NIC, OPCODE_NIC_NW_DATA);
  669. return (subcode2 != subcode1);
  670. }
  671. #define LIO68XX_LED_CTRL_ADDR 0x3501
  672. #define LIO68XX_LED_CTRL_CFGON 0x1f
  673. #define LIO68XX_LED_CTRL_CFGOFF 0x100
  674. #define LIO68XX_LED_BEACON_ADDR 0x3508
  675. #define LIO68XX_LED_BEACON_CFGON 0x47fd
  676. #define LIO68XX_LED_BEACON_CFGOFF 0x11fc
  677. #define VITESSE_PHY_GPIO_DRIVEON 0x1
  678. #define VITESSE_PHY_GPIO_CFG 0x8
  679. #define VITESSE_PHY_GPIO_DRIVEOFF 0x4
  680. #define VITESSE_PHY_GPIO_HIGH 0x2
  681. #define VITESSE_PHY_GPIO_LOW 0x3
  682. #define LED_IDENTIFICATION_ON 0x1
  683. #define LED_IDENTIFICATION_OFF 0x0
  684. struct oct_mdio_cmd {
  685. u64 op;
  686. u64 mdio_addr;
  687. u64 value1;
  688. u64 value2;
  689. u64 value3;
  690. };
  691. #define OCT_LINK_STATS_SIZE (sizeof(struct oct_link_stats))
  692. /* intrmod: max. packet rate threshold */
  693. #define LIO_INTRMOD_MAXPKT_RATETHR 196608
  694. /* intrmod: min. packet rate threshold */
  695. #define LIO_INTRMOD_MINPKT_RATETHR 9216
  696. /* intrmod: max. packets to trigger interrupt */
  697. #define LIO_INTRMOD_RXMAXCNT_TRIGGER 384
  698. /* intrmod: min. packets to trigger interrupt */
  699. #define LIO_INTRMOD_RXMINCNT_TRIGGER 0
  700. /* intrmod: max. time to trigger interrupt */
  701. #define LIO_INTRMOD_RXMAXTMR_TRIGGER 128
  702. /* 66xx:intrmod: min. time to trigger interrupt
  703. * (value of 1 is optimum for TCP_RR)
  704. */
  705. #define LIO_INTRMOD_RXMINTMR_TRIGGER 1
  706. /* intrmod: max. packets to trigger interrupt */
  707. #define LIO_INTRMOD_TXMAXCNT_TRIGGER 64
  708. /* intrmod: min. packets to trigger interrupt */
  709. #define LIO_INTRMOD_TXMINCNT_TRIGGER 0
  710. /* intrmod: poll interval in seconds */
  711. #define LIO_INTRMOD_CHECK_INTERVAL 1
  712. struct oct_intrmod_cfg {
  713. u64 rx_enable;
  714. u64 tx_enable;
  715. u64 check_intrvl;
  716. u64 maxpkt_ratethr;
  717. u64 minpkt_ratethr;
  718. u64 rx_maxcnt_trigger;
  719. u64 rx_mincnt_trigger;
  720. u64 rx_maxtmr_trigger;
  721. u64 rx_mintmr_trigger;
  722. u64 tx_mincnt_trigger;
  723. u64 tx_maxcnt_trigger;
  724. u64 rx_frames;
  725. u64 tx_frames;
  726. u64 rx_usecs;
  727. };
  728. #define BASE_QUEUE_NOT_REQUESTED 65535
  729. union oct_nic_if_cfg {
  730. u64 u64;
  731. struct {
  732. #ifdef __BIG_ENDIAN_BITFIELD
  733. u64 base_queue:16;
  734. u64 num_iqueues:16;
  735. u64 num_oqueues:16;
  736. u64 gmx_port_id:8;
  737. u64 vf_id:8;
  738. #else
  739. u64 vf_id:8;
  740. u64 gmx_port_id:8;
  741. u64 num_oqueues:16;
  742. u64 num_iqueues:16;
  743. u64 base_queue:16;
  744. #endif
  745. } s;
  746. };
  747. #endif