liquidio_common.h 23 KB

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