blob: 11df55a5b2462c4e3c26c39208ad5c943c6fcb27 [file] [log] [blame]
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -07001/**********************************************************************
2* Author: Cavium, Inc.
3*
4* Contact: support@cavium.com
5* Please include "LiquidIO" in the subject.
6*
7* Copyright (c) 2003-2015 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
17* details.
18*
19* This file may also be available under a different license from Cavium.
20* Contact Cavium, Inc. for more information
21**********************************************************************/
22
23/*! \file liquidio_common.h
24 * \brief Common: Structures and macros used in PCI-NIC package by core and
25 * host driver.
26 */
27
28#ifndef __LIQUIDIO_COMMON_H__
29#define __LIQUIDIO_COMMON_H__
30
31#include "octeon_config.h"
32
Raghu Vatsavayid3d7e6c2016-06-21 22:53:07 -070033#define LIQUIDIO_PACKAGE ""
Raghu Vatsavayi83101ce2016-08-31 11:03:21 -070034#define LIQUIDIO_BASE_MAJOR_VERSION 1
35#define LIQUIDIO_BASE_MINOR_VERSION 4
36#define LIQUIDIO_BASE_MICRO_VERSION 1
37#define LIQUIDIO_BASE_VERSION __stringify(LIQUIDIO_BASE_MAJOR_VERSION) "." \
38 __stringify(LIQUIDIO_BASE_MINOR_VERSION)
39#define LIQUIDIO_MICRO_VERSION "." __stringify(LIQUIDIO_BASE_MICRO_VERSION)
40#define LIQUIDIO_VERSION LIQUIDIO_PACKAGE \
41 __stringify(LIQUIDIO_BASE_MAJOR_VERSION) "." \
42 __stringify(LIQUIDIO_BASE_MINOR_VERSION) \
43 "." __stringify(LIQUIDIO_BASE_MICRO_VERSION)
44
45struct lio_version {
46 u16 major;
47 u16 minor;
48 u16 micro;
49 u16 reserved;
50};
Raghu Vatsavayia2c64b62016-07-03 13:56:55 -070051
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -070052#define CONTROL_IQ 0
53/** Tag types used by Octeon cores in its work. */
54enum octeon_tag_type {
55 ORDERED_TAG = 0,
56 ATOMIC_TAG = 1,
57 NULL_TAG = 2,
58 NULL_NULL_TAG = 3
59};
60
61/* pre-defined host->NIC tag values */
62#define LIO_CONTROL (0x11111110)
63#define LIO_DATA(i) (0x11111111 + (i))
64
65/* Opcodes used by host driver/apps to perform operations on the core.
66 * These are used to identify the major subsystem that the operation
67 * is for.
68 */
69#define OPCODE_CORE 0 /* used for generic core operations */
70#define OPCODE_NIC 1 /* used for NIC operations */
71#define OPCODE_LAST OPCODE_NIC
72
73/* Subcodes are used by host driver/apps to identify the sub-operation
74 * for the core. They only need to by unique for a given subsystem.
75 */
76#define OPCODE_SUBCODE(op, sub) (((op & 0x0f) << 8) | ((sub) & 0x7f))
77
78/** OPCODE_CORE subcodes. For future use. */
79
80/** OPCODE_NIC subcodes */
81
82/* This subcode is sent by core PCI driver to indicate cores are ready. */
83#define OPCODE_NIC_CORE_DRV_ACTIVE 0x01
84#define OPCODE_NIC_NW_DATA 0x02 /* network packet data */
85#define OPCODE_NIC_CMD 0x03
86#define OPCODE_NIC_INFO 0x04
87#define OPCODE_NIC_PORT_STATS 0x05
88#define OPCODE_NIC_MDIO45 0x06
89#define OPCODE_NIC_TIMESTAMP 0x07
90#define OPCODE_NIC_INTRMOD_CFG 0x08
91#define OPCODE_NIC_IF_CFG 0x09
92
93#define CORE_DRV_TEST_SCATTER_OP 0xFFF5
94
95#define OPCODE_SLOW_PATH(rh) \
96 (OPCODE_SUBCODE(rh->r.opcode, rh->r.subcode) != \
97 OPCODE_SUBCODE(OPCODE_NIC, OPCODE_NIC_NW_DATA))
98
99/* Application codes advertised by the core driver initialization packet. */
100#define CVM_DRV_APP_START 0x0
101#define CVM_DRV_NO_APP 0
102#define CVM_DRV_APP_COUNT 0x2
103#define CVM_DRV_BASE_APP (CVM_DRV_APP_START + 0x0)
104#define CVM_DRV_NIC_APP (CVM_DRV_APP_START + 0x1)
105#define CVM_DRV_INVALID_APP (CVM_DRV_APP_START + 0x2)
106#define CVM_DRV_APP_END (CVM_DRV_INVALID_APP - 1)
107
108/* Macro to increment index.
109 * Index is incremented by count; if the sum exceeds
110 * max, index is wrapped-around to the start.
111 */
112#define INCR_INDEX(index, count, max) \
113do { \
114 if (((index) + (count)) >= (max)) \
115 index = ((index) + (count)) - (max); \
116 else \
117 index += (count); \
118} while (0)
119
120#define INCR_INDEX_BY1(index, max) \
121do { \
122 if ((++(index)) == (max)) \
123 index = 0; \
124} while (0)
125
126#define DECR_INDEX(index, count, max) \
127do { \
128 if ((count) > (index)) \
129 index = ((max) - ((count - index))); \
130 else \
131 index -= count; \
132} while (0)
133
134#define OCT_BOARD_NAME 32
135#define OCT_SERIAL_LEN 64
136
137/* Structure used by core driver to send indication that the Octeon
138 * application is ready.
139 */
140struct octeon_core_setup {
141 u64 corefreq;
142
143 char boardname[OCT_BOARD_NAME];
144
145 char board_serial_number[OCT_SERIAL_LEN];
146
147 u64 board_rev_major;
148
149 u64 board_rev_minor;
150
151};
152
153/*--------------------------- SCATTER GATHER ENTRY -----------------------*/
154
155/* The Scatter-Gather List Entry. The scatter or gather component used with
156 * a Octeon input instruction has this format.
157 */
158struct octeon_sg_entry {
159 /** The first 64 bit gives the size of data in each dptr.*/
160 union {
161 u16 size[4];
162 u64 size64;
163 } u;
164
165 /** The 4 dptr pointers for this entry. */
166 u64 ptr[4];
167
168};
169
170#define OCT_SG_ENTRY_SIZE (sizeof(struct octeon_sg_entry))
171
172/* \brief Add size to gather list
173 * @param sg_entry scatter/gather entry
174 * @param size size to add
175 * @param pos position to add it.
176 */
177static inline void add_sg_size(struct octeon_sg_entry *sg_entry,
178 u16 size,
179 u32 pos)
180{
181#ifdef __BIG_ENDIAN_BITFIELD
182 sg_entry->u.size[pos] = size;
183#else
184 sg_entry->u.size[3 - pos] = size;
185#endif
186}
187
188/*------------------------- End Scatter/Gather ---------------------------*/
189
190#define OCTNET_FRM_PTP_HEADER_SIZE 8
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700191
Raghu Vatsavayia5b37882016-06-14 16:54:48 -0700192#define OCTNET_FRM_HEADER_SIZE 22 /* VLAN + Ethernet */
193
194#define OCTNET_MIN_FRM_SIZE 64
195
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700196#define OCTNET_MAX_FRM_SIZE (16000 + OCTNET_FRM_HEADER_SIZE)
197
198#define OCTNET_DEFAULT_FRM_SIZE (1500 + OCTNET_FRM_HEADER_SIZE)
199
200/** NIC Commands are sent using this Octeon Input Queue */
201#define OCTNET_CMD_Q 0
202
203/* NIC Command types */
204#define OCTNET_CMD_CHANGE_MTU 0x1
205#define OCTNET_CMD_CHANGE_MACADDR 0x2
206#define OCTNET_CMD_CHANGE_DEVFLAGS 0x3
207#define OCTNET_CMD_RX_CTL 0x4
208
209#define OCTNET_CMD_SET_MULTI_LIST 0x5
210#define OCTNET_CMD_CLEAR_STATS 0x6
211
212/* command for setting the speed, duplex & autoneg */
213#define OCTNET_CMD_SET_SETTINGS 0x7
214#define OCTNET_CMD_SET_FLOW_CTL 0x8
215
216#define OCTNET_CMD_MDIO_READ_WRITE 0x9
217#define OCTNET_CMD_GPIO_ACCESS 0xA
218#define OCTNET_CMD_LRO_ENABLE 0xB
219#define OCTNET_CMD_LRO_DISABLE 0xC
220#define OCTNET_CMD_SET_RSS 0xD
221#define OCTNET_CMD_WRITE_SA 0xE
222#define OCTNET_CMD_DELETE_SA 0xF
223#define OCTNET_CMD_UPDATE_SA 0x12
224
225#define OCTNET_CMD_TNL_RX_CSUM_CTL 0x10
226#define OCTNET_CMD_TNL_TX_CSUM_CTL 0x11
227#define OCTNET_CMD_IPSECV2_AH_ESP_CTL 0x13
228#define OCTNET_CMD_VERBOSE_ENABLE 0x14
229#define OCTNET_CMD_VERBOSE_DISABLE 0x15
230
Raghu Vatsavayi63245f22016-06-21 22:53:05 -0700231#define OCTNET_CMD_ENABLE_VLAN_FILTER 0x16
232#define OCTNET_CMD_ADD_VLAN_FILTER 0x17
233#define OCTNET_CMD_DEL_VLAN_FILTER 0x18
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700234#define OCTNET_CMD_VXLAN_PORT_CONFIG 0x19
235#define OCTNET_CMD_VXLAN_PORT_ADD 0x0
236#define OCTNET_CMD_VXLAN_PORT_DEL 0x1
237#define OCTNET_CMD_RXCSUM_ENABLE 0x0
238#define OCTNET_CMD_RXCSUM_DISABLE 0x1
239#define OCTNET_CMD_TXCSUM_ENABLE 0x0
240#define OCTNET_CMD_TXCSUM_DISABLE 0x1
Raghu Vatsavayi63245f22016-06-21 22:53:05 -0700241
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700242/* RX(packets coming from wire) Checksum verification flags */
243/* TCP/UDP csum */
244#define CNNIC_L4SUM_VERIFIED 0x1
245#define CNNIC_IPSUM_VERIFIED 0x2
246#define CNNIC_TUN_CSUM_VERIFIED 0x4
247#define CNNIC_CSUM_VERIFIED (CNNIC_IPSUM_VERIFIED | CNNIC_L4SUM_VERIFIED)
248
249/*LROIPV4 and LROIPV6 Flags*/
250#define OCTNIC_LROIPV4 0x1
251#define OCTNIC_LROIPV6 0x2
252
253/* Interface flags communicated between host driver and core app. */
254enum octnet_ifflags {
255 OCTNET_IFFLAG_PROMISC = 0x01,
256 OCTNET_IFFLAG_ALLMULTI = 0x02,
257 OCTNET_IFFLAG_MULTICAST = 0x04,
258 OCTNET_IFFLAG_BROADCAST = 0x08,
259 OCTNET_IFFLAG_UNICAST = 0x10
260};
261
262/* wqe
263 * --------------- 0
264 * | wqe word0-3 |
265 * --------------- 32
266 * | PCI IH |
267 * --------------- 40
268 * | RPTR |
269 * --------------- 48
270 * | PCI IRH |
271 * --------------- 56
272 * | OCT_NET_CMD |
273 * --------------- 64
274 * | Addtl 8-BData |
275 * | |
276 * ---------------
277 */
278
279union octnet_cmd {
280 u64 u64;
281
282 struct {
283#ifdef __BIG_ENDIAN_BITFIELD
284 u64 cmd:5;
285
286 u64 more:6; /* How many udd words follow the command */
287
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700288 u64 reserved:29;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700289
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700290 u64 param1:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700291
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700292 u64 param2:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700293
294#else
295
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700296 u64 param2:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700297
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700298 u64 param1:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700299
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700300 u64 reserved:29;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700301
302 u64 more:6;
303
304 u64 cmd:5;
305
306#endif
307 } s;
308
309};
310
311#define OCTNET_CMD_SIZE (sizeof(union octnet_cmd))
312
Raghu Vatsavayia2c64b62016-07-03 13:56:55 -0700313/* Instruction Header(DPI) - for OCTEON-III models */
Raghu Vatsavayi6a885b62016-06-14 16:54:51 -0700314struct octeon_instr_ih3 {
315#ifdef __BIG_ENDIAN_BITFIELD
316
317 /** Reserved3 */
318 u64 reserved3:1;
319
320 /** Gather indicator 1=gather*/
321 u64 gather:1;
322
323 /** Data length OR no. of entries in gather list */
324 u64 dlengsz:14;
325
326 /** Front Data size */
327 u64 fsz:6;
328
329 /** Reserved2 */
330 u64 reserved2:4;
331
332 /** PKI port kind - PKIND */
333 u64 pkind:6;
334
335 /** Reserved1 */
336 u64 reserved1:32;
337
338#else
339 /** Reserved1 */
340 u64 reserved1:32;
341
342 /** PKI port kind - PKIND */
343 u64 pkind:6;
344
345 /** Reserved2 */
346 u64 reserved2:4;
347
348 /** Front Data size */
349 u64 fsz:6;
350
351 /** Data length OR no. of entries in gather list */
352 u64 dlengsz:14;
353
354 /** Gather indicator 1=gather*/
355 u64 gather:1;
356
357 /** Reserved3 */
358 u64 reserved3:1;
359
360#endif
361};
362
Raghu Vatsavayia2c64b62016-07-03 13:56:55 -0700363/* Optional PKI Instruction Header(PKI IH) - for OCTEON-III models */
Raghu Vatsavayi6a885b62016-06-14 16:54:51 -0700364/** BIG ENDIAN format. */
365struct octeon_instr_pki_ih3 {
366#ifdef __BIG_ENDIAN_BITFIELD
367
368 /** Wider bit */
369 u64 w:1;
370
371 /** Raw mode indicator 1 = RAW */
372 u64 raw:1;
373
374 /** Use Tag */
375 u64 utag:1;
376
377 /** Use QPG */
378 u64 uqpg:1;
379
380 /** Reserved2 */
381 u64 reserved2:1;
382
383 /** Parse Mode */
384 u64 pm:3;
385
386 /** Skip Length */
387 u64 sl:8;
388
389 /** Use Tag Type */
390 u64 utt:1;
391
392 /** Tag type */
393 u64 tagtype:2;
394
395 /** Reserved1 */
396 u64 reserved1:2;
397
398 /** QPG Value */
399 u64 qpg:11;
400
401 /** Tag Value */
402 u64 tag:32;
403
404#else
405
406 /** Tag Value */
407 u64 tag:32;
408
409 /** QPG Value */
410 u64 qpg:11;
411
412 /** Reserved1 */
413 u64 reserved1:2;
414
415 /** Tag type */
416 u64 tagtype:2;
417
418 /** Use Tag Type */
419 u64 utt:1;
420
421 /** Skip Length */
422 u64 sl:8;
423
424 /** Parse Mode */
425 u64 pm:3;
426
427 /** Reserved2 */
428 u64 reserved2:1;
429
430 /** Use QPG */
431 u64 uqpg:1;
432
433 /** Use Tag */
434 u64 utag:1;
435
436 /** Raw mode indicator 1 = RAW */
437 u64 raw:1;
438
439 /** Wider bit */
440 u64 w:1;
441#endif
442
443};
444
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700445/** Instruction Header */
Raghu Vatsavayi6a885b62016-06-14 16:54:51 -0700446struct octeon_instr_ih2 {
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700447#ifdef __BIG_ENDIAN_BITFIELD
448 /** Raw mode indicator 1 = RAW */
449 u64 raw:1;
450
451 /** Gather indicator 1=gather*/
452 u64 gather:1;
453
454 /** Data length OR no. of entries in gather list */
455 u64 dlengsz:14;
456
457 /** Front Data size */
458 u64 fsz:6;
459
460 /** Packet Order / Work Unit selection (1 of 8)*/
461 u64 qos:3;
462
463 /** Core group selection (1 of 16) */
464 u64 grp:4;
465
466 /** Short Raw Packet Indicator 1=short raw pkt */
467 u64 rs:1;
468
469 /** Tag type */
470 u64 tagtype:2;
471
472 /** Tag Value */
473 u64 tag:32;
474#else
475 /** Tag Value */
476 u64 tag:32;
477
478 /** Tag type */
479 u64 tagtype:2;
480
481 /** Short Raw Packet Indicator 1=short raw pkt */
482 u64 rs:1;
483
484 /** Core group selection (1 of 16) */
485 u64 grp:4;
486
487 /** Packet Order / Work Unit selection (1 of 8)*/
488 u64 qos:3;
489
490 /** Front Data size */
491 u64 fsz:6;
492
493 /** Data length OR no. of entries in gather list */
494 u64 dlengsz:14;
495
496 /** Gather indicator 1=gather*/
497 u64 gather:1;
498
499 /** Raw mode indicator 1 = RAW */
500 u64 raw:1;
501#endif
502};
503
504/** Input Request Header */
505struct octeon_instr_irh {
506#ifdef __BIG_ENDIAN_BITFIELD
507 u64 opcode:4;
508 u64 rflag:1;
509 u64 subcode:7;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700510 u64 vlan:12;
511 u64 priority:3;
512 u64 reserved:5;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700513 u64 ossp:32; /* opcode/subcode specific parameters */
514#else
515 u64 ossp:32; /* opcode/subcode specific parameters */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700516 u64 reserved:5;
517 u64 priority:3;
518 u64 vlan:12;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700519 u64 subcode:7;
520 u64 rflag:1;
521 u64 opcode:4;
522#endif
523};
524
525/** Return Data Parameters */
526struct octeon_instr_rdp {
527#ifdef __BIG_ENDIAN_BITFIELD
528 u64 reserved:49;
529 u64 pcie_port:3;
530 u64 rlen:12;
531#else
532 u64 rlen:12;
533 u64 pcie_port:3;
534 u64 reserved:49;
535#endif
536};
537
538/** Receive Header */
539union octeon_rh {
540#ifdef __BIG_ENDIAN_BITFIELD
541 u64 u64;
542 struct {
543 u64 opcode:4;
544 u64 subcode:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700545 u64 len:3; /** additional 64-bit words */
546 u64 reserved:17;
547 u64 ossp:32; /** opcode/subcode specific parameters */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700548 } r;
549 struct {
550 u64 opcode:4;
551 u64 subcode:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700552 u64 len:3; /** additional 64-bit words */
553 u64 extra:28;
554 u64 vlan:12;
555 u64 priority:3;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700556 u64 csum_verified:3; /** checksum verified. */
557 u64 has_hwtstamp:1; /** Has hardware timestamp. 1 = yes. */
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700558 u64 encap_on:1;
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700559 u64 has_hash:1; /** Has hash (rth or rss). 1 = yes. */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700560 } r_dh;
561 struct {
562 u64 opcode:4;
563 u64 subcode:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700564 u64 len:3; /** additional 64-bit words */
565 u64 reserved:11;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700566 u64 num_gmx_ports:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700567 u64 max_nic_ports:10;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700568 u64 app_cap_flags:4;
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700569 u64 app_mode:8;
570 u64 pkind:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700571 } r_core_drv_init;
572 struct {
573 u64 opcode:4;
574 u64 subcode:8;
575 u64 len:3; /** additional 64-bit words */
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700576 u64 reserved:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700577 u64 extra:25;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700578 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700579 } r_nic_info;
580#else
581 u64 u64;
582 struct {
583 u64 ossp:32; /** opcode/subcode specific parameters */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700584 u64 reserved:17;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700585 u64 len:3; /** additional 64-bit words */
586 u64 subcode:8;
587 u64 opcode:4;
588 } r;
589 struct {
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700590 u64 has_hash:1; /** Has hash (rth or rss). 1 = yes. */
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700591 u64 encap_on:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700592 u64 has_hwtstamp:1; /** 1 = has hwtstamp */
593 u64 csum_verified:3; /** checksum verified. */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700594 u64 priority:3;
595 u64 vlan:12;
596 u64 extra:28;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700597 u64 len:3; /** additional 64-bit words */
598 u64 subcode:8;
599 u64 opcode:4;
600 } r_dh;
601 struct {
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700602 u64 pkind:8;
603 u64 app_mode:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700604 u64 app_cap_flags:4;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700605 u64 max_nic_ports:10;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700606 u64 num_gmx_ports:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700607 u64 reserved:11;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700608 u64 len:3; /** additional 64-bit words */
609 u64 subcode:8;
610 u64 opcode:4;
611 } r_core_drv_init;
612 struct {
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700613 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700614 u64 extra:25;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700615 u64 reserved:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700616 u64 len:3; /** additional 64-bit words */
617 u64 subcode:8;
618 u64 opcode:4;
619 } r_nic_info;
620#endif
621};
622
623#define OCT_RH_SIZE (sizeof(union octeon_rh))
624
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700625union octnic_packet_params {
626 u32 u32;
627 struct {
628#ifdef __BIG_ENDIAN_BITFIELD
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700629 u32 reserved:24;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700630 u32 ip_csum:1; /* Perform IP header checksum(s) */
631 /* Perform Outer transport header checksum */
632 u32 transport_csum:1;
633 /* Find tunnel, and perform transport csum. */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700634 u32 tnl_csum:1;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700635 u32 tsflag:1; /* Timestamp this packet */
636 u32 ipsec_ops:4; /* IPsec operation */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700637#else
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700638 u32 ipsec_ops:4;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700639 u32 tsflag:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700640 u32 tnl_csum:1;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700641 u32 transport_csum:1;
642 u32 ip_csum:1;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700643 u32 reserved:24;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700644#endif
645 } s;
646};
647
648/** Status of a RGMII Link on Octeon as seen by core driver. */
649union oct_link_status {
650 u64 u64;
651
652 struct {
653#ifdef __BIG_ENDIAN_BITFIELD
654 u64 duplex:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700655 u64 mtu:16;
656 u64 speed:16;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700657 u64 link_up:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700658 u64 autoneg:1;
Raghu Vatsavayi9eb60842016-06-21 22:53:12 -0700659 u64 if_mode:5;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700660 u64 pause:1;
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700661 u64 flashing:1;
662 u64 reserved:15;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700663#else
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700664 u64 reserved:15;
665 u64 flashing:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700666 u64 pause:1;
Raghu Vatsavayi9eb60842016-06-21 22:53:12 -0700667 u64 if_mode:5;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700668 u64 autoneg:1;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700669 u64 link_up:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700670 u64 speed:16;
671 u64 mtu:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700672 u64 duplex:8;
673#endif
674 } s;
675};
676
Raghu Vatsavayi26236fa2016-06-14 16:54:44 -0700677/** The txpciq info passed to host from the firmware */
678
679union oct_txpciq {
680 u64 u64;
681
682 struct {
683#ifdef __BIG_ENDIAN_BITFIELD
684 u64 q_no:8;
685 u64 port:8;
686 u64 pkind:6;
687 u64 use_qpg:1;
688 u64 qpg:11;
689 u64 reserved:30;
690#else
691 u64 reserved:30;
692 u64 qpg:11;
693 u64 use_qpg:1;
694 u64 pkind:6;
695 u64 port:8;
696 u64 q_no:8;
697#endif
698 } s;
699};
700
701/** The rxpciq info passed to host from the firmware */
702
703union oct_rxpciq {
704 u64 u64;
705
706 struct {
707#ifdef __BIG_ENDIAN_BITFIELD
708 u64 q_no:8;
709 u64 reserved:56;
710#else
711 u64 reserved:56;
712 u64 q_no:8;
713#endif
714 } s;
715};
716
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700717/** Information for a OCTEON ethernet interface shared between core & host. */
718struct oct_link_info {
719 union oct_link_status link;
720 u64 hw_addr;
721
722#ifdef __BIG_ENDIAN_BITFIELD
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700723 u64 gmxport:16;
724 u64 rsvd:32;
725 u64 num_txpciq:8;
726 u64 num_rxpciq:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700727#else
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700728 u64 num_rxpciq:8;
729 u64 num_txpciq:8;
730 u64 rsvd:32;
731 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700732#endif
733
Raghu Vatsavayi26236fa2016-06-14 16:54:44 -0700734 union oct_txpciq txpciq[MAX_IOQS_PER_NICIF];
735 union oct_rxpciq rxpciq[MAX_IOQS_PER_NICIF];
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700736};
737
738#define OCT_LINK_INFO_SIZE (sizeof(struct oct_link_info))
739
740struct liquidio_if_cfg_info {
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700741 u64 iqmask; /** mask for IQs enabled for the port */
742 u64 oqmask; /** mask for OQs enabled for the port */
743 struct oct_link_info linfo; /** initial link information */
Raghu Vatsavayid3d7e6c2016-06-21 22:53:07 -0700744 char liquidio_firmware_version[32];
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700745};
746
747/** Stats for each NIC port in RX direction. */
748struct nic_rx_stats {
749 /* link-level stats */
750 u64 total_rcvd;
751 u64 bytes_rcvd;
752 u64 total_bcst;
753 u64 total_mcst;
754 u64 runts;
755 u64 ctl_rcvd;
756 u64 fifo_err; /* Accounts for over/under-run of buffers */
757 u64 dmac_drop;
758 u64 fcs_err;
759 u64 jabber_err;
760 u64 l2_err;
761 u64 frame_err;
762
763 /* firmware stats */
764 u64 fw_total_rcvd;
765 u64 fw_total_fwd;
766 u64 fw_err_pko;
767 u64 fw_err_link;
768 u64 fw_err_drop;
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700769 u64 fw_rx_vxlan;
770 u64 fw_rx_vxlan_err;
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700771
772 /* LRO */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700773 u64 fw_lro_pkts; /* Number of packets that are LROed */
774 u64 fw_lro_octs; /* Number of octets that are LROed */
775 u64 fw_total_lro; /* Number of LRO packets formed */
776 u64 fw_lro_aborts; /* Number of times lRO of packet aborted */
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700777 u64 fw_lro_aborts_port;
778 u64 fw_lro_aborts_seq;
779 u64 fw_lro_aborts_tsval;
780 u64 fw_lro_aborts_timer;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700781 /* intrmod: packet forward rate */
782 u64 fwd_rate;
783};
784
785/** Stats for each NIC port in RX direction. */
786struct nic_tx_stats {
787 /* link-level stats */
788 u64 total_pkts_sent;
789 u64 total_bytes_sent;
790 u64 mcast_pkts_sent;
791 u64 bcast_pkts_sent;
792 u64 ctl_sent;
793 u64 one_collision_sent; /* Packets sent after one collision*/
794 u64 multi_collision_sent; /* Packets sent after multiple collision*/
795 u64 max_collision_fail; /* Packets not sent due to max collisions */
796 u64 max_deferral_fail; /* Packets not sent due to max deferrals */
797 u64 fifo_err; /* Accounts for over/under-run of buffers */
798 u64 runts;
799 u64 total_collisions; /* Total number of collisions detected */
800
801 /* firmware stats */
802 u64 fw_total_sent;
803 u64 fw_total_fwd;
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700804 u64 fw_total_fwd_bytes;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700805 u64 fw_err_pko;
806 u64 fw_err_link;
807 u64 fw_err_drop;
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700808 u64 fw_err_tso;
809 u64 fw_tso; /* number of tso requests */
810 u64 fw_tso_fwd; /* number of packets segmented in tso */
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700811 u64 fw_tx_vxlan;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700812};
813
814struct oct_link_stats {
815 struct nic_rx_stats fromwire;
816 struct nic_tx_stats fromhost;
817
818};
819
820#define LIO68XX_LED_CTRL_ADDR 0x3501
821#define LIO68XX_LED_CTRL_CFGON 0x1f
822#define LIO68XX_LED_CTRL_CFGOFF 0x100
823#define LIO68XX_LED_BEACON_ADDR 0x3508
824#define LIO68XX_LED_BEACON_CFGON 0x47fd
825#define LIO68XX_LED_BEACON_CFGOFF 0x11fc
826#define VITESSE_PHY_GPIO_DRIVEON 0x1
827#define VITESSE_PHY_GPIO_CFG 0x8
828#define VITESSE_PHY_GPIO_DRIVEOFF 0x4
829#define VITESSE_PHY_GPIO_HIGH 0x2
830#define VITESSE_PHY_GPIO_LOW 0x3
831
832struct oct_mdio_cmd {
833 u64 op;
834 u64 mdio_addr;
835 u64 value1;
836 u64 value2;
837 u64 value3;
838};
839
840#define OCT_LINK_STATS_SIZE (sizeof(struct oct_link_stats))
841
Raghu Vatsavayi78e6a9b2016-06-21 22:53:10 -0700842/* intrmod: max. packet rate threshold */
843#define LIO_INTRMOD_MAXPKT_RATETHR 196608
844/* intrmod: min. packet rate threshold */
845#define LIO_INTRMOD_MINPKT_RATETHR 9216
846/* intrmod: max. packets to trigger interrupt */
847#define LIO_INTRMOD_RXMAXCNT_TRIGGER 384
848/* intrmod: min. packets to trigger interrupt */
849#define LIO_INTRMOD_RXMINCNT_TRIGGER 1
850/* intrmod: max. time to trigger interrupt */
851#define LIO_INTRMOD_RXMAXTMR_TRIGGER 128
852/* 66xx:intrmod: min. time to trigger interrupt
853 * (value of 1 is optimum for TCP_RR)
854 */
855#define LIO_INTRMOD_RXMINTMR_TRIGGER 1
856
857/* intrmod: max. packets to trigger interrupt */
858#define LIO_INTRMOD_TXMAXCNT_TRIGGER 64
859/* intrmod: min. packets to trigger interrupt */
860#define LIO_INTRMOD_TXMINCNT_TRIGGER 0
861
862/* intrmod: poll interval in seconds */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700863#define LIO_INTRMOD_CHECK_INTERVAL 1
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700864
865struct oct_intrmod_cfg {
Raghu Vatsavayi78e6a9b2016-06-21 22:53:10 -0700866 u64 rx_enable;
867 u64 tx_enable;
868 u64 check_intrvl;
869 u64 maxpkt_ratethr;
870 u64 minpkt_ratethr;
871 u64 rx_maxcnt_trigger;
872 u64 rx_mincnt_trigger;
873 u64 rx_maxtmr_trigger;
874 u64 rx_mintmr_trigger;
875 u64 tx_mincnt_trigger;
876 u64 tx_maxcnt_trigger;
877 u64 rx_frames;
878 u64 tx_frames;
879 u64 rx_usecs;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700880};
881
882#define BASE_QUEUE_NOT_REQUESTED 65535
883
884union oct_nic_if_cfg {
885 u64 u64;
886 struct {
887#ifdef __BIG_ENDIAN_BITFIELD
888 u64 base_queue:16;
889 u64 num_iqueues:16;
890 u64 num_oqueues:16;
891 u64 gmx_port_id:8;
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700892 u64 vf_id:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700893#else
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700894 u64 vf_id:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700895 u64 gmx_port_id:8;
896 u64 num_oqueues:16;
897 u64 num_iqueues:16;
898 u64 base_queue:16;
899#endif
900 } s;
901};
902
903#endif