liquidio_common.h 23 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039
  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_BASE_MAJOR_VERSION 1
  26. #define LIQUIDIO_BASE_MINOR_VERSION 7
  27. #define LIQUIDIO_BASE_MICRO_VERSION 2
  28. #define LIQUIDIO_BASE_VERSION __stringify(LIQUIDIO_BASE_MAJOR_VERSION) "." \
  29. __stringify(LIQUIDIO_BASE_MINOR_VERSION)
  30. struct lio_version {
  31. u16 major;
  32. u16 minor;
  33. u16 micro;
  34. u16 reserved;
  35. };
  36. #define CONTROL_IQ 0
  37. /** Tag types used by Octeon cores in its work. */
  38. enum octeon_tag_type {
  39. ORDERED_TAG = 0,
  40. ATOMIC_TAG = 1,
  41. NULL_TAG = 2,
  42. NULL_NULL_TAG = 3
  43. };
  44. /* pre-defined host->NIC tag values */
  45. #define LIO_CONTROL (0x11111110)
  46. #define LIO_DATA(i) (0x11111111 + (i))
  47. /* Opcodes used by host driver/apps to perform operations on the core.
  48. * These are used to identify the major subsystem that the operation
  49. * is for.
  50. */
  51. #define OPCODE_CORE 0 /* used for generic core operations */
  52. #define OPCODE_NIC 1 /* used for NIC operations */
  53. /* Subcodes are used by host driver/apps to identify the sub-operation
  54. * for the core. They only need to by unique for a given subsystem.
  55. */
  56. #define OPCODE_SUBCODE(op, sub) ((((op) & 0x0f) << 8) | ((sub) & 0x7f))
  57. /** OPCODE_CORE subcodes. For future use. */
  58. /** OPCODE_NIC subcodes */
  59. /* This subcode is sent by core PCI driver to indicate cores are ready. */
  60. #define OPCODE_NIC_CORE_DRV_ACTIVE 0x01
  61. #define OPCODE_NIC_NW_DATA 0x02 /* network packet data */
  62. #define OPCODE_NIC_CMD 0x03
  63. #define OPCODE_NIC_INFO 0x04
  64. #define OPCODE_NIC_PORT_STATS 0x05
  65. #define OPCODE_NIC_MDIO45 0x06
  66. #define OPCODE_NIC_TIMESTAMP 0x07
  67. #define OPCODE_NIC_INTRMOD_CFG 0x08
  68. #define OPCODE_NIC_IF_CFG 0x09
  69. #define OPCODE_NIC_VF_DRV_NOTICE 0x0A
  70. #define OPCODE_NIC_INTRMOD_PARAMS 0x0B
  71. #define OPCODE_NIC_QCOUNT_UPDATE 0x12
  72. #define OPCODE_NIC_SET_TRUSTED_VF 0x13
  73. #define OPCODE_NIC_SYNC_OCTEON_TIME 0x14
  74. #define VF_DRV_LOADED 1
  75. #define VF_DRV_REMOVED -1
  76. #define VF_DRV_MACADDR_CHANGED 2
  77. #define OPCODE_NIC_VF_REP_PKT 0x15
  78. #define OPCODE_NIC_VF_REP_CMD 0x16
  79. #define OPCODE_NIC_UBOOT_CTL 0x17
  80. #define CORE_DRV_TEST_SCATTER_OP 0xFFF5
  81. /* Application codes advertised by the core driver initialization packet. */
  82. #define CVM_DRV_APP_START 0x0
  83. #define CVM_DRV_NO_APP 0
  84. #define CVM_DRV_APP_COUNT 0x2
  85. #define CVM_DRV_BASE_APP (CVM_DRV_APP_START + 0x0)
  86. #define CVM_DRV_NIC_APP (CVM_DRV_APP_START + 0x1)
  87. #define CVM_DRV_INVALID_APP (CVM_DRV_APP_START + 0x2)
  88. #define CVM_DRV_APP_END (CVM_DRV_INVALID_APP - 1)
  89. #define BYTES_PER_DHLEN_UNIT 8
  90. #define MAX_REG_CNT 2000000U
  91. #define INTRNAMSIZ 32
  92. #define IRQ_NAME_OFF(i) ((i) * INTRNAMSIZ)
  93. #define MAX_IOQ_INTERRUPTS_PER_PF (64 * 2)
  94. #define MAX_IOQ_INTERRUPTS_PER_VF (8 * 2)
  95. #define SCR2_BIT_FW_LOADED 63
  96. /* App specific capabilities from firmware to pf driver */
  97. #define LIQUIDIO_TIME_SYNC_CAP 0x1
  98. #define LIQUIDIO_SWITCHDEV_CAP 0x2
  99. #define LIQUIDIO_SPOOFCHK_CAP 0x4
  100. /* error status return from firmware */
  101. #define OCTEON_REQUEST_NO_PERMISSION 0xc
  102. static inline u32 incr_index(u32 index, u32 count, u32 max)
  103. {
  104. if ((index + count) >= max)
  105. index = index + count - max;
  106. else
  107. index += count;
  108. return index;
  109. }
  110. #define OCT_BOARD_NAME 32
  111. #define OCT_SERIAL_LEN 64
  112. /* Structure used by core driver to send indication that the Octeon
  113. * application is ready.
  114. */
  115. struct octeon_core_setup {
  116. u64 corefreq;
  117. char boardname[OCT_BOARD_NAME];
  118. char board_serial_number[OCT_SERIAL_LEN];
  119. u64 board_rev_major;
  120. u64 board_rev_minor;
  121. };
  122. /*--------------------------- SCATTER GATHER ENTRY -----------------------*/
  123. /* The Scatter-Gather List Entry. The scatter or gather component used with
  124. * a Octeon input instruction has this format.
  125. */
  126. struct octeon_sg_entry {
  127. /** The first 64 bit gives the size of data in each dptr.*/
  128. union {
  129. u16 size[4];
  130. u64 size64;
  131. } u;
  132. /** The 4 dptr pointers for this entry. */
  133. u64 ptr[4];
  134. };
  135. #define OCT_SG_ENTRY_SIZE (sizeof(struct octeon_sg_entry))
  136. /* \brief Add size to gather list
  137. * @param sg_entry scatter/gather entry
  138. * @param size size to add
  139. * @param pos position to add it.
  140. */
  141. static inline void add_sg_size(struct octeon_sg_entry *sg_entry,
  142. u16 size,
  143. u32 pos)
  144. {
  145. #ifdef __BIG_ENDIAN_BITFIELD
  146. sg_entry->u.size[pos] = size;
  147. #else
  148. sg_entry->u.size[3 - pos] = size;
  149. #endif
  150. }
  151. /*------------------------- End Scatter/Gather ---------------------------*/
  152. #define OCTNET_FRM_LENGTH_SIZE 8
  153. #define OCTNET_FRM_PTP_HEADER_SIZE 8
  154. #define OCTNET_FRM_HEADER_SIZE 22 /* VLAN + Ethernet */
  155. #define OCTNET_MIN_FRM_SIZE 64
  156. #define OCTNET_MAX_FRM_SIZE (16000 + OCTNET_FRM_HEADER_SIZE)
  157. #define OCTNET_DEFAULT_MTU (1500)
  158. #define OCTNET_DEFAULT_FRM_SIZE (OCTNET_DEFAULT_MTU + OCTNET_FRM_HEADER_SIZE)
  159. /** NIC Commands are sent using this Octeon Input Queue */
  160. #define OCTNET_CMD_Q 0
  161. /* NIC Command types */
  162. #define OCTNET_CMD_CHANGE_MTU 0x1
  163. #define OCTNET_CMD_CHANGE_MACADDR 0x2
  164. #define OCTNET_CMD_CHANGE_DEVFLAGS 0x3
  165. #define OCTNET_CMD_RX_CTL 0x4
  166. #define OCTNET_CMD_SET_MULTI_LIST 0x5
  167. #define OCTNET_CMD_CLEAR_STATS 0x6
  168. /* command for setting the speed, duplex & autoneg */
  169. #define OCTNET_CMD_SET_SETTINGS 0x7
  170. #define OCTNET_CMD_SET_FLOW_CTL 0x8
  171. #define OCTNET_CMD_MDIO_READ_WRITE 0x9
  172. #define OCTNET_CMD_GPIO_ACCESS 0xA
  173. #define OCTNET_CMD_LRO_ENABLE 0xB
  174. #define OCTNET_CMD_LRO_DISABLE 0xC
  175. #define OCTNET_CMD_SET_RSS 0xD
  176. #define OCTNET_CMD_WRITE_SA 0xE
  177. #define OCTNET_CMD_DELETE_SA 0xF
  178. #define OCTNET_CMD_UPDATE_SA 0x12
  179. #define OCTNET_CMD_TNL_RX_CSUM_CTL 0x10
  180. #define OCTNET_CMD_TNL_TX_CSUM_CTL 0x11
  181. #define OCTNET_CMD_IPSECV2_AH_ESP_CTL 0x13
  182. #define OCTNET_CMD_VERBOSE_ENABLE 0x14
  183. #define OCTNET_CMD_VERBOSE_DISABLE 0x15
  184. #define OCTNET_CMD_VLAN_FILTER_CTL 0x16
  185. #define OCTNET_CMD_ADD_VLAN_FILTER 0x17
  186. #define OCTNET_CMD_DEL_VLAN_FILTER 0x18
  187. #define OCTNET_CMD_VXLAN_PORT_CONFIG 0x19
  188. #define OCTNET_CMD_ID_ACTIVE 0x1a
  189. #define OCTNET_CMD_SET_UC_LIST 0x1b
  190. #define OCTNET_CMD_SET_VF_LINKSTATE 0x1c
  191. #define OCTNET_CMD_QUEUE_COUNT_CTL 0x1f
  192. #define OCTNET_CMD_GROUP1 1
  193. #define OCTNET_CMD_SET_VF_SPOOFCHK 0x1
  194. #define OCTNET_GROUP1_LAST_CMD OCTNET_CMD_SET_VF_SPOOFCHK
  195. #define OCTNET_CMD_VXLAN_PORT_ADD 0x0
  196. #define OCTNET_CMD_VXLAN_PORT_DEL 0x1
  197. #define OCTNET_CMD_RXCSUM_ENABLE 0x0
  198. #define OCTNET_CMD_RXCSUM_DISABLE 0x1
  199. #define OCTNET_CMD_TXCSUM_ENABLE 0x0
  200. #define OCTNET_CMD_TXCSUM_DISABLE 0x1
  201. #define OCTNET_CMD_VLAN_FILTER_ENABLE 0x1
  202. #define OCTNET_CMD_VLAN_FILTER_DISABLE 0x0
  203. #define OCTNET_CMD_FAIL 0x1
  204. #define SEAPI_CMD_FEC_SET 0x0
  205. #define SEAPI_CMD_FEC_SET_DISABLE 0x0
  206. #define SEAPI_CMD_FEC_SET_RS 0x1
  207. #define SEAPI_CMD_FEC_GET 0x1
  208. #define SEAPI_CMD_SPEED_SET 0x2
  209. #define SEAPI_CMD_SPEED_GET 0x3
  210. #define OPCODE_NIC_VF_PORT_STATS 0x22
  211. #define LIO_CMD_WAIT_TM 100
  212. /* RX(packets coming from wire) Checksum verification flags */
  213. /* TCP/UDP csum */
  214. #define CNNIC_L4SUM_VERIFIED 0x1
  215. #define CNNIC_IPSUM_VERIFIED 0x2
  216. #define CNNIC_TUN_CSUM_VERIFIED 0x4
  217. #define CNNIC_CSUM_VERIFIED (CNNIC_IPSUM_VERIFIED | CNNIC_L4SUM_VERIFIED)
  218. /*LROIPV4 and LROIPV6 Flags*/
  219. #define OCTNIC_LROIPV4 0x1
  220. #define OCTNIC_LROIPV6 0x2
  221. /* Interface flags communicated between host driver and core app. */
  222. enum octnet_ifflags {
  223. OCTNET_IFFLAG_PROMISC = 0x01,
  224. OCTNET_IFFLAG_ALLMULTI = 0x02,
  225. OCTNET_IFFLAG_MULTICAST = 0x04,
  226. OCTNET_IFFLAG_BROADCAST = 0x08,
  227. OCTNET_IFFLAG_UNICAST = 0x10
  228. };
  229. /* wqe
  230. * --------------- 0
  231. * | wqe word0-3 |
  232. * --------------- 32
  233. * | PCI IH |
  234. * --------------- 40
  235. * | RPTR |
  236. * --------------- 48
  237. * | PCI IRH |
  238. * --------------- 56
  239. * | OCT_NET_CMD |
  240. * --------------- 64
  241. * | Addtl 8-BData |
  242. * | |
  243. * ---------------
  244. */
  245. union octnet_cmd {
  246. u64 u64;
  247. struct {
  248. #ifdef __BIG_ENDIAN_BITFIELD
  249. u64 cmd:5;
  250. u64 more:6; /* How many udd words follow the command */
  251. u64 cmdgroup:8;
  252. u64 reserved:21;
  253. u64 param1:16;
  254. u64 param2:8;
  255. #else
  256. u64 param2:8;
  257. u64 param1:16;
  258. u64 reserved:21;
  259. u64 cmdgroup:8;
  260. u64 more:6;
  261. u64 cmd:5;
  262. #endif
  263. } s;
  264. };
  265. #define OCTNET_CMD_SIZE (sizeof(union octnet_cmd))
  266. /*pkiih3 + irh + ossp[0] + ossp[1] + rdp + rptr = 40 bytes */
  267. #define LIO_SOFTCMDRESP_IH2 40
  268. #define LIO_SOFTCMDRESP_IH3 (40 + 8)
  269. #define LIO_PCICMD_O2 24
  270. #define LIO_PCICMD_O3 (24 + 8)
  271. /* Instruction Header(DPI) - for OCTEON-III models */
  272. struct octeon_instr_ih3 {
  273. #ifdef __BIG_ENDIAN_BITFIELD
  274. /** Reserved3 */
  275. u64 reserved3:1;
  276. /** Gather indicator 1=gather*/
  277. u64 gather:1;
  278. /** Data length OR no. of entries in gather list */
  279. u64 dlengsz:14;
  280. /** Front Data size */
  281. u64 fsz:6;
  282. /** Reserved2 */
  283. u64 reserved2:4;
  284. /** PKI port kind - PKIND */
  285. u64 pkind:6;
  286. /** Reserved1 */
  287. u64 reserved1:32;
  288. #else
  289. /** Reserved1 */
  290. u64 reserved1:32;
  291. /** PKI port kind - PKIND */
  292. u64 pkind:6;
  293. /** Reserved2 */
  294. u64 reserved2:4;
  295. /** Front Data size */
  296. u64 fsz:6;
  297. /** Data length OR no. of entries in gather list */
  298. u64 dlengsz:14;
  299. /** Gather indicator 1=gather*/
  300. u64 gather:1;
  301. /** Reserved3 */
  302. u64 reserved3:1;
  303. #endif
  304. };
  305. /* Optional PKI Instruction Header(PKI IH) - for OCTEON-III models */
  306. /** BIG ENDIAN format. */
  307. struct octeon_instr_pki_ih3 {
  308. #ifdef __BIG_ENDIAN_BITFIELD
  309. /** Wider bit */
  310. u64 w:1;
  311. /** Raw mode indicator 1 = RAW */
  312. u64 raw:1;
  313. /** Use Tag */
  314. u64 utag:1;
  315. /** Use QPG */
  316. u64 uqpg:1;
  317. /** Reserved2 */
  318. u64 reserved2:1;
  319. /** Parse Mode */
  320. u64 pm:3;
  321. /** Skip Length */
  322. u64 sl:8;
  323. /** Use Tag Type */
  324. u64 utt:1;
  325. /** Tag type */
  326. u64 tagtype:2;
  327. /** Reserved1 */
  328. u64 reserved1:2;
  329. /** QPG Value */
  330. u64 qpg:11;
  331. /** Tag Value */
  332. u64 tag:32;
  333. #else
  334. /** Tag Value */
  335. u64 tag:32;
  336. /** QPG Value */
  337. u64 qpg:11;
  338. /** Reserved1 */
  339. u64 reserved1:2;
  340. /** Tag type */
  341. u64 tagtype:2;
  342. /** Use Tag Type */
  343. u64 utt:1;
  344. /** Skip Length */
  345. u64 sl:8;
  346. /** Parse Mode */
  347. u64 pm:3;
  348. /** Reserved2 */
  349. u64 reserved2:1;
  350. /** Use QPG */
  351. u64 uqpg:1;
  352. /** Use Tag */
  353. u64 utag:1;
  354. /** Raw mode indicator 1 = RAW */
  355. u64 raw:1;
  356. /** Wider bit */
  357. u64 w:1;
  358. #endif
  359. };
  360. /** Instruction Header */
  361. struct octeon_instr_ih2 {
  362. #ifdef __BIG_ENDIAN_BITFIELD
  363. /** Raw mode indicator 1 = RAW */
  364. u64 raw:1;
  365. /** Gather indicator 1=gather*/
  366. u64 gather:1;
  367. /** Data length OR no. of entries in gather list */
  368. u64 dlengsz:14;
  369. /** Front Data size */
  370. u64 fsz:6;
  371. /** Packet Order / Work Unit selection (1 of 8)*/
  372. u64 qos:3;
  373. /** Core group selection (1 of 16) */
  374. u64 grp:4;
  375. /** Short Raw Packet Indicator 1=short raw pkt */
  376. u64 rs:1;
  377. /** Tag type */
  378. u64 tagtype:2;
  379. /** Tag Value */
  380. u64 tag:32;
  381. #else
  382. /** Tag Value */
  383. u64 tag:32;
  384. /** Tag type */
  385. u64 tagtype:2;
  386. /** Short Raw Packet Indicator 1=short raw pkt */
  387. u64 rs:1;
  388. /** Core group selection (1 of 16) */
  389. u64 grp:4;
  390. /** Packet Order / Work Unit selection (1 of 8)*/
  391. u64 qos:3;
  392. /** Front Data size */
  393. u64 fsz:6;
  394. /** Data length OR no. of entries in gather list */
  395. u64 dlengsz:14;
  396. /** Gather indicator 1=gather*/
  397. u64 gather:1;
  398. /** Raw mode indicator 1 = RAW */
  399. u64 raw:1;
  400. #endif
  401. };
  402. /** Input Request Header */
  403. struct octeon_instr_irh {
  404. #ifdef __BIG_ENDIAN_BITFIELD
  405. u64 opcode:4;
  406. u64 rflag:1;
  407. u64 subcode:7;
  408. u64 vlan:12;
  409. u64 priority:3;
  410. u64 reserved:5;
  411. u64 ossp:32; /* opcode/subcode specific parameters */
  412. #else
  413. u64 ossp:32; /* opcode/subcode specific parameters */
  414. u64 reserved:5;
  415. u64 priority:3;
  416. u64 vlan:12;
  417. u64 subcode:7;
  418. u64 rflag:1;
  419. u64 opcode:4;
  420. #endif
  421. };
  422. /** Return Data Parameters */
  423. struct octeon_instr_rdp {
  424. #ifdef __BIG_ENDIAN_BITFIELD
  425. u64 reserved:49;
  426. u64 pcie_port:3;
  427. u64 rlen:12;
  428. #else
  429. u64 rlen:12;
  430. u64 pcie_port:3;
  431. u64 reserved:49;
  432. #endif
  433. };
  434. /** Receive Header */
  435. union octeon_rh {
  436. #ifdef __BIG_ENDIAN_BITFIELD
  437. u64 u64;
  438. struct {
  439. u64 opcode:4;
  440. u64 subcode:8;
  441. u64 len:3; /** additional 64-bit words */
  442. u64 reserved:17;
  443. u64 ossp:32; /** opcode/subcode specific parameters */
  444. } r;
  445. struct {
  446. u64 opcode:4;
  447. u64 subcode:8;
  448. u64 len:3; /** additional 64-bit words */
  449. u64 extra:28;
  450. u64 vlan:12;
  451. u64 priority:3;
  452. u64 csum_verified:3; /** checksum verified. */
  453. u64 has_hwtstamp:1; /** Has hardware timestamp. 1 = yes. */
  454. u64 encap_on:1;
  455. u64 has_hash:1; /** Has hash (rth or rss). 1 = yes. */
  456. } r_dh;
  457. struct {
  458. u64 opcode:4;
  459. u64 subcode:8;
  460. u64 len:3; /** additional 64-bit words */
  461. u64 reserved:11;
  462. u64 num_gmx_ports:8;
  463. u64 max_nic_ports:10;
  464. u64 app_cap_flags:4;
  465. u64 app_mode:8;
  466. u64 pkind:8;
  467. } r_core_drv_init;
  468. struct {
  469. u64 opcode:4;
  470. u64 subcode:8;
  471. u64 len:3; /** additional 64-bit words */
  472. u64 reserved:8;
  473. u64 extra:25;
  474. u64 gmxport:16;
  475. } r_nic_info;
  476. #else
  477. u64 u64;
  478. struct {
  479. u64 ossp:32; /** opcode/subcode specific parameters */
  480. u64 reserved:17;
  481. u64 len:3; /** additional 64-bit words */
  482. u64 subcode:8;
  483. u64 opcode:4;
  484. } r;
  485. struct {
  486. u64 has_hash:1; /** Has hash (rth or rss). 1 = yes. */
  487. u64 encap_on:1;
  488. u64 has_hwtstamp:1; /** 1 = has hwtstamp */
  489. u64 csum_verified:3; /** checksum verified. */
  490. u64 priority:3;
  491. u64 vlan:12;
  492. u64 extra:28;
  493. u64 len:3; /** additional 64-bit words */
  494. u64 subcode:8;
  495. u64 opcode:4;
  496. } r_dh;
  497. struct {
  498. u64 pkind:8;
  499. u64 app_mode:8;
  500. u64 app_cap_flags:4;
  501. u64 max_nic_ports:10;
  502. u64 num_gmx_ports:8;
  503. u64 reserved:11;
  504. u64 len:3; /** additional 64-bit words */
  505. u64 subcode:8;
  506. u64 opcode:4;
  507. } r_core_drv_init;
  508. struct {
  509. u64 gmxport:16;
  510. u64 extra:25;
  511. u64 reserved:8;
  512. u64 len:3; /** additional 64-bit words */
  513. u64 subcode:8;
  514. u64 opcode:4;
  515. } r_nic_info;
  516. #endif
  517. };
  518. #define OCT_RH_SIZE (sizeof(union octeon_rh))
  519. union octnic_packet_params {
  520. u32 u32;
  521. struct {
  522. #ifdef __BIG_ENDIAN_BITFIELD
  523. u32 reserved:24;
  524. u32 ip_csum:1; /* Perform IP header checksum(s) */
  525. /* Perform Outer transport header checksum */
  526. u32 transport_csum:1;
  527. /* Find tunnel, and perform transport csum. */
  528. u32 tnl_csum:1;
  529. u32 tsflag:1; /* Timestamp this packet */
  530. u32 ipsec_ops:4; /* IPsec operation */
  531. #else
  532. u32 ipsec_ops:4;
  533. u32 tsflag:1;
  534. u32 tnl_csum:1;
  535. u32 transport_csum:1;
  536. u32 ip_csum:1;
  537. u32 reserved:24;
  538. #endif
  539. } s;
  540. };
  541. /** Status of a RGMII Link on Octeon as seen by core driver. */
  542. union oct_link_status {
  543. u64 u64;
  544. struct {
  545. #ifdef __BIG_ENDIAN_BITFIELD
  546. u64 duplex:8;
  547. u64 mtu:16;
  548. u64 speed:16;
  549. u64 link_up:1;
  550. u64 autoneg:1;
  551. u64 if_mode:5;
  552. u64 pause:1;
  553. u64 flashing:1;
  554. u64 phy_type:5;
  555. u64 reserved:10;
  556. #else
  557. u64 reserved:10;
  558. u64 phy_type:5;
  559. u64 flashing:1;
  560. u64 pause:1;
  561. u64 if_mode:5;
  562. u64 autoneg:1;
  563. u64 link_up:1;
  564. u64 speed:16;
  565. u64 mtu:16;
  566. u64 duplex:8;
  567. #endif
  568. } s;
  569. };
  570. enum lio_phy_type {
  571. LIO_PHY_PORT_TP = 0x0,
  572. LIO_PHY_PORT_FIBRE = 0x1,
  573. LIO_PHY_PORT_UNKNOWN,
  574. };
  575. /** The txpciq info passed to host from the firmware */
  576. union oct_txpciq {
  577. u64 u64;
  578. struct {
  579. #ifdef __BIG_ENDIAN_BITFIELD
  580. u64 q_no:8;
  581. u64 port:8;
  582. u64 pkind:6;
  583. u64 use_qpg:1;
  584. u64 qpg:11;
  585. u64 reserved0:10;
  586. u64 ctrl_qpg:11;
  587. u64 reserved:9;
  588. #else
  589. u64 reserved:9;
  590. u64 ctrl_qpg:11;
  591. u64 reserved0:10;
  592. u64 qpg:11;
  593. u64 use_qpg:1;
  594. u64 pkind:6;
  595. u64 port:8;
  596. u64 q_no:8;
  597. #endif
  598. } s;
  599. };
  600. /** The rxpciq info passed to host from the firmware */
  601. union oct_rxpciq {
  602. u64 u64;
  603. struct {
  604. #ifdef __BIG_ENDIAN_BITFIELD
  605. u64 q_no:8;
  606. u64 reserved:56;
  607. #else
  608. u64 reserved:56;
  609. u64 q_no:8;
  610. #endif
  611. } s;
  612. };
  613. /** Information for a OCTEON ethernet interface shared between core & host. */
  614. struct oct_link_info {
  615. union oct_link_status link;
  616. u64 hw_addr;
  617. #ifdef __BIG_ENDIAN_BITFIELD
  618. u64 gmxport:16;
  619. u64 macaddr_is_admin_asgnd:1;
  620. u64 rsvd:13;
  621. u64 macaddr_spoofchk:1;
  622. u64 rsvd1:17;
  623. u64 num_txpciq:8;
  624. u64 num_rxpciq:8;
  625. #else
  626. u64 num_rxpciq:8;
  627. u64 num_txpciq:8;
  628. u64 rsvd1:17;
  629. u64 macaddr_spoofchk:1;
  630. u64 rsvd:13;
  631. u64 macaddr_is_admin_asgnd:1;
  632. u64 gmxport:16;
  633. #endif
  634. union oct_txpciq txpciq[MAX_IOQS_PER_NICIF];
  635. union oct_rxpciq rxpciq[MAX_IOQS_PER_NICIF];
  636. };
  637. #define OCT_LINK_INFO_SIZE (sizeof(struct oct_link_info))
  638. struct liquidio_if_cfg_info {
  639. u64 iqmask; /** mask for IQs enabled for the port */
  640. u64 oqmask; /** mask for OQs enabled for the port */
  641. struct oct_link_info linfo; /** initial link information */
  642. char liquidio_firmware_version[32];
  643. };
  644. /** Stats for each NIC port in RX direction. */
  645. struct nic_rx_stats {
  646. /* link-level stats */
  647. u64 total_rcvd; /* Received packets */
  648. u64 bytes_rcvd; /* Octets of received packets */
  649. u64 total_bcst; /* Number of non-dropped L2 broadcast packets */
  650. u64 total_mcst; /* Number of non-dropped L2 multicast packets */
  651. u64 runts; /* Packets shorter than allowed */
  652. u64 ctl_rcvd; /* Received PAUSE packets */
  653. u64 fifo_err; /* Packets dropped due to RX FIFO full */
  654. u64 dmac_drop; /* Packets dropped by the DMAC filter */
  655. u64 fcs_err; /* Sum of fragment, overrun, and FCS errors */
  656. u64 jabber_err; /* Packets larger than allowed */
  657. u64 l2_err; /* Sum of DMA, parity, PCAM access, no memory,
  658. * buffer overflow, malformed L2 header or
  659. * length, oversize errors
  660. **/
  661. u64 frame_err; /* Sum of IPv4 and L4 checksum errors */
  662. u64 red_drops; /* Packets dropped by RED due to buffer
  663. * exhaustion
  664. **/
  665. /* firmware stats */
  666. u64 fw_total_rcvd;
  667. u64 fw_total_fwd;
  668. u64 fw_total_fwd_bytes;
  669. u64 fw_total_mcast;
  670. u64 fw_total_bcast;
  671. u64 fw_err_pko;
  672. u64 fw_err_link;
  673. u64 fw_err_drop;
  674. u64 fw_rx_vxlan;
  675. u64 fw_rx_vxlan_err;
  676. /* LRO */
  677. u64 fw_lro_pkts; /* Number of packets that are LROed */
  678. u64 fw_lro_octs; /* Number of octets that are LROed */
  679. u64 fw_total_lro; /* Number of LRO packets formed */
  680. u64 fw_lro_aborts; /* Number of times LRO of packet aborted */
  681. u64 fw_lro_aborts_port;
  682. u64 fw_lro_aborts_seq;
  683. u64 fw_lro_aborts_tsval;
  684. u64 fw_lro_aborts_timer; /* Timer setting error */
  685. /* intrmod: packet forward rate */
  686. u64 fwd_rate;
  687. };
  688. /** Stats for each NIC port in RX direction. */
  689. struct nic_tx_stats {
  690. /* link-level stats */
  691. u64 total_pkts_sent; /* Total frames sent on the interface */
  692. u64 total_bytes_sent; /* Total octets sent on the interface */
  693. u64 mcast_pkts_sent; /* Packets sent to the multicast DMAC */
  694. u64 bcast_pkts_sent; /* Packets sent to a broadcast DMAC */
  695. u64 ctl_sent; /* Control/PAUSE packets sent */
  696. u64 one_collision_sent; /* Packets sent that experienced a
  697. * single collision before successful
  698. * transmission
  699. **/
  700. u64 multi_collision_sent; /* Packets sent that experienced
  701. * multiple collisions before successful
  702. * transmission
  703. **/
  704. u64 max_collision_fail; /* Packets dropped due to excessive
  705. * collisions
  706. **/
  707. u64 max_deferral_fail; /* Packets not sent due to max
  708. * deferrals
  709. **/
  710. u64 fifo_err; /* Packets sent that experienced a
  711. * transmit underflow and were
  712. * truncated
  713. **/
  714. u64 runts; /* Packets sent with an octet count
  715. * lessthan 64
  716. **/
  717. u64 total_collisions; /* Packets dropped due to excessive
  718. * collisions
  719. **/
  720. /* firmware stats */
  721. u64 fw_total_sent;
  722. u64 fw_total_fwd;
  723. u64 fw_total_fwd_bytes;
  724. u64 fw_total_mcast_sent;
  725. u64 fw_total_bcast_sent;
  726. u64 fw_err_pko;
  727. u64 fw_err_link;
  728. u64 fw_err_drop;
  729. u64 fw_err_tso;
  730. u64 fw_tso; /* number of tso requests */
  731. u64 fw_tso_fwd; /* number of packets segmented in tso */
  732. u64 fw_tx_vxlan;
  733. u64 fw_err_pki;
  734. };
  735. struct oct_link_stats {
  736. struct nic_rx_stats fromwire;
  737. struct nic_tx_stats fromhost;
  738. };
  739. static inline int opcode_slow_path(union octeon_rh *rh)
  740. {
  741. u16 subcode1, subcode2;
  742. subcode1 = OPCODE_SUBCODE((rh)->r.opcode, (rh)->r.subcode);
  743. subcode2 = OPCODE_SUBCODE(OPCODE_NIC, OPCODE_NIC_NW_DATA);
  744. return (subcode2 != subcode1);
  745. }
  746. #define LIO68XX_LED_CTRL_ADDR 0x3501
  747. #define LIO68XX_LED_CTRL_CFGON 0x1f
  748. #define LIO68XX_LED_CTRL_CFGOFF 0x100
  749. #define LIO68XX_LED_BEACON_ADDR 0x3508
  750. #define LIO68XX_LED_BEACON_CFGON 0x47fd
  751. #define LIO68XX_LED_BEACON_CFGOFF 0x11fc
  752. #define VITESSE_PHY_GPIO_DRIVEON 0x1
  753. #define VITESSE_PHY_GPIO_CFG 0x8
  754. #define VITESSE_PHY_GPIO_DRIVEOFF 0x4
  755. #define VITESSE_PHY_GPIO_HIGH 0x2
  756. #define VITESSE_PHY_GPIO_LOW 0x3
  757. #define LED_IDENTIFICATION_ON 0x1
  758. #define LED_IDENTIFICATION_OFF 0x0
  759. #define LIO23XX_COPPERHEAD_LED_GPIO 0x2
  760. struct oct_mdio_cmd {
  761. u64 op;
  762. u64 mdio_addr;
  763. u64 value1;
  764. u64 value2;
  765. u64 value3;
  766. };
  767. #define OCT_LINK_STATS_SIZE (sizeof(struct oct_link_stats))
  768. struct oct_intrmod_cfg {
  769. u64 rx_enable;
  770. u64 tx_enable;
  771. u64 check_intrvl;
  772. u64 maxpkt_ratethr;
  773. u64 minpkt_ratethr;
  774. u64 rx_maxcnt_trigger;
  775. u64 rx_mincnt_trigger;
  776. u64 rx_maxtmr_trigger;
  777. u64 rx_mintmr_trigger;
  778. u64 tx_mincnt_trigger;
  779. u64 tx_maxcnt_trigger;
  780. u64 rx_frames;
  781. u64 tx_frames;
  782. u64 rx_usecs;
  783. };
  784. #define BASE_QUEUE_NOT_REQUESTED 65535
  785. union oct_nic_if_cfg {
  786. u64 u64;
  787. struct {
  788. #ifdef __BIG_ENDIAN_BITFIELD
  789. u64 base_queue:16;
  790. u64 num_iqueues:16;
  791. u64 num_oqueues:16;
  792. u64 gmx_port_id:8;
  793. u64 vf_id:8;
  794. #else
  795. u64 vf_id:8;
  796. u64 gmx_port_id:8;
  797. u64 num_oqueues:16;
  798. u64 num_iqueues:16;
  799. u64 base_queue:16;
  800. #endif
  801. } s;
  802. };
  803. struct lio_trusted_vf {
  804. uint64_t active: 1;
  805. uint64_t id : 8;
  806. uint64_t reserved: 55;
  807. };
  808. struct lio_time {
  809. s64 sec; /* seconds */
  810. s64 nsec; /* nanoseconds */
  811. };
  812. struct lio_vf_rep_stats {
  813. u64 tx_packets;
  814. u64 tx_bytes;
  815. u64 tx_dropped;
  816. u64 rx_packets;
  817. u64 rx_bytes;
  818. u64 rx_dropped;
  819. };
  820. enum lio_vf_rep_req_type {
  821. LIO_VF_REP_REQ_NONE,
  822. LIO_VF_REP_REQ_STATE,
  823. LIO_VF_REP_REQ_MTU,
  824. LIO_VF_REP_REQ_STATS,
  825. LIO_VF_REP_REQ_DEVNAME
  826. };
  827. enum {
  828. LIO_VF_REP_STATE_DOWN,
  829. LIO_VF_REP_STATE_UP
  830. };
  831. #define LIO_IF_NAME_SIZE 16
  832. struct lio_vf_rep_req {
  833. u8 req_type;
  834. u8 ifidx;
  835. u8 rsvd[6];
  836. union {
  837. struct lio_vf_rep_name {
  838. char name[LIO_IF_NAME_SIZE];
  839. } rep_name;
  840. struct lio_vf_rep_mtu {
  841. u32 mtu;
  842. u32 rsvd;
  843. } rep_mtu;
  844. struct lio_vf_rep_state {
  845. u8 state;
  846. u8 rsvd[7];
  847. } rep_state;
  848. };
  849. };
  850. struct lio_vf_rep_resp {
  851. u64 rh;
  852. u8 status;
  853. u8 rsvd[7];
  854. };
  855. #endif