blob: 5552f6737423068248d70d9e8463d03b6a93db15 [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 Vatsavayi5b823512016-09-01 11:16:07 -0700313/*pkiih3 + irh + ossp[0] + ossp[1] + rdp + rptr = 40 bytes */
314#define LIO_SOFTCMDRESP_IH2 40
315#define LIO_SOFTCMDRESP_IH3 (40 + 8)
316
317#define LIO_PCICMD_O2 24
318#define LIO_PCICMD_O3 (24 + 8)
319
Raghu Vatsavayia2c64b62016-07-03 13:56:55 -0700320/* Instruction Header(DPI) - for OCTEON-III models */
Raghu Vatsavayi6a885b62016-06-14 16:54:51 -0700321struct octeon_instr_ih3 {
322#ifdef __BIG_ENDIAN_BITFIELD
323
324 /** Reserved3 */
325 u64 reserved3:1;
326
327 /** Gather indicator 1=gather*/
328 u64 gather:1;
329
330 /** Data length OR no. of entries in gather list */
331 u64 dlengsz:14;
332
333 /** Front Data size */
334 u64 fsz:6;
335
336 /** Reserved2 */
337 u64 reserved2:4;
338
339 /** PKI port kind - PKIND */
340 u64 pkind:6;
341
342 /** Reserved1 */
343 u64 reserved1:32;
344
345#else
346 /** Reserved1 */
347 u64 reserved1:32;
348
349 /** PKI port kind - PKIND */
350 u64 pkind:6;
351
352 /** Reserved2 */
353 u64 reserved2:4;
354
355 /** Front Data size */
356 u64 fsz:6;
357
358 /** Data length OR no. of entries in gather list */
359 u64 dlengsz:14;
360
361 /** Gather indicator 1=gather*/
362 u64 gather:1;
363
364 /** Reserved3 */
365 u64 reserved3:1;
366
367#endif
368};
369
Raghu Vatsavayia2c64b62016-07-03 13:56:55 -0700370/* Optional PKI Instruction Header(PKI IH) - for OCTEON-III models */
Raghu Vatsavayi6a885b62016-06-14 16:54:51 -0700371/** BIG ENDIAN format. */
372struct octeon_instr_pki_ih3 {
373#ifdef __BIG_ENDIAN_BITFIELD
374
375 /** Wider bit */
376 u64 w:1;
377
378 /** Raw mode indicator 1 = RAW */
379 u64 raw:1;
380
381 /** Use Tag */
382 u64 utag:1;
383
384 /** Use QPG */
385 u64 uqpg:1;
386
387 /** Reserved2 */
388 u64 reserved2:1;
389
390 /** Parse Mode */
391 u64 pm:3;
392
393 /** Skip Length */
394 u64 sl:8;
395
396 /** Use Tag Type */
397 u64 utt:1;
398
399 /** Tag type */
400 u64 tagtype:2;
401
402 /** Reserved1 */
403 u64 reserved1:2;
404
405 /** QPG Value */
406 u64 qpg:11;
407
408 /** Tag Value */
409 u64 tag:32;
410
411#else
412
413 /** Tag Value */
414 u64 tag:32;
415
416 /** QPG Value */
417 u64 qpg:11;
418
419 /** Reserved1 */
420 u64 reserved1:2;
421
422 /** Tag type */
423 u64 tagtype:2;
424
425 /** Use Tag Type */
426 u64 utt:1;
427
428 /** Skip Length */
429 u64 sl:8;
430
431 /** Parse Mode */
432 u64 pm:3;
433
434 /** Reserved2 */
435 u64 reserved2:1;
436
437 /** Use QPG */
438 u64 uqpg:1;
439
440 /** Use Tag */
441 u64 utag:1;
442
443 /** Raw mode indicator 1 = RAW */
444 u64 raw:1;
445
446 /** Wider bit */
447 u64 w:1;
448#endif
449
450};
451
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700452/** Instruction Header */
Raghu Vatsavayi6a885b62016-06-14 16:54:51 -0700453struct octeon_instr_ih2 {
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700454#ifdef __BIG_ENDIAN_BITFIELD
455 /** Raw mode indicator 1 = RAW */
456 u64 raw:1;
457
458 /** Gather indicator 1=gather*/
459 u64 gather:1;
460
461 /** Data length OR no. of entries in gather list */
462 u64 dlengsz:14;
463
464 /** Front Data size */
465 u64 fsz:6;
466
467 /** Packet Order / Work Unit selection (1 of 8)*/
468 u64 qos:3;
469
470 /** Core group selection (1 of 16) */
471 u64 grp:4;
472
473 /** Short Raw Packet Indicator 1=short raw pkt */
474 u64 rs:1;
475
476 /** Tag type */
477 u64 tagtype:2;
478
479 /** Tag Value */
480 u64 tag:32;
481#else
482 /** Tag Value */
483 u64 tag:32;
484
485 /** Tag type */
486 u64 tagtype:2;
487
488 /** Short Raw Packet Indicator 1=short raw pkt */
489 u64 rs:1;
490
491 /** Core group selection (1 of 16) */
492 u64 grp:4;
493
494 /** Packet Order / Work Unit selection (1 of 8)*/
495 u64 qos:3;
496
497 /** Front Data size */
498 u64 fsz:6;
499
500 /** Data length OR no. of entries in gather list */
501 u64 dlengsz:14;
502
503 /** Gather indicator 1=gather*/
504 u64 gather:1;
505
506 /** Raw mode indicator 1 = RAW */
507 u64 raw:1;
508#endif
509};
510
511/** Input Request Header */
512struct octeon_instr_irh {
513#ifdef __BIG_ENDIAN_BITFIELD
514 u64 opcode:4;
515 u64 rflag:1;
516 u64 subcode:7;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700517 u64 vlan:12;
518 u64 priority:3;
519 u64 reserved:5;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700520 u64 ossp:32; /* opcode/subcode specific parameters */
521#else
522 u64 ossp:32; /* opcode/subcode specific parameters */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700523 u64 reserved:5;
524 u64 priority:3;
525 u64 vlan:12;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700526 u64 subcode:7;
527 u64 rflag:1;
528 u64 opcode:4;
529#endif
530};
531
532/** Return Data Parameters */
533struct octeon_instr_rdp {
534#ifdef __BIG_ENDIAN_BITFIELD
535 u64 reserved:49;
536 u64 pcie_port:3;
537 u64 rlen:12;
538#else
539 u64 rlen:12;
540 u64 pcie_port:3;
541 u64 reserved:49;
542#endif
543};
544
545/** Receive Header */
546union octeon_rh {
547#ifdef __BIG_ENDIAN_BITFIELD
548 u64 u64;
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 reserved:17;
554 u64 ossp:32; /** opcode/subcode specific parameters */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700555 } r;
556 struct {
557 u64 opcode:4;
558 u64 subcode:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700559 u64 len:3; /** additional 64-bit words */
560 u64 extra:28;
561 u64 vlan:12;
562 u64 priority:3;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700563 u64 csum_verified:3; /** checksum verified. */
564 u64 has_hwtstamp:1; /** Has hardware timestamp. 1 = yes. */
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700565 u64 encap_on:1;
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700566 u64 has_hash:1; /** Has hash (rth or rss). 1 = yes. */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700567 } r_dh;
568 struct {
569 u64 opcode:4;
570 u64 subcode:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700571 u64 len:3; /** additional 64-bit words */
572 u64 reserved:11;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700573 u64 num_gmx_ports:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700574 u64 max_nic_ports:10;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700575 u64 app_cap_flags:4;
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700576 u64 app_mode:8;
577 u64 pkind:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700578 } r_core_drv_init;
579 struct {
580 u64 opcode:4;
581 u64 subcode:8;
582 u64 len:3; /** additional 64-bit words */
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700583 u64 reserved:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700584 u64 extra:25;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700585 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700586 } r_nic_info;
587#else
588 u64 u64;
589 struct {
590 u64 ossp:32; /** opcode/subcode specific parameters */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700591 u64 reserved:17;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700592 u64 len:3; /** additional 64-bit words */
593 u64 subcode:8;
594 u64 opcode:4;
595 } r;
596 struct {
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700597 u64 has_hash:1; /** Has hash (rth or rss). 1 = yes. */
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700598 u64 encap_on:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700599 u64 has_hwtstamp:1; /** 1 = has hwtstamp */
600 u64 csum_verified:3; /** checksum verified. */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700601 u64 priority:3;
602 u64 vlan:12;
603 u64 extra:28;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700604 u64 len:3; /** additional 64-bit words */
605 u64 subcode:8;
606 u64 opcode:4;
607 } r_dh;
608 struct {
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700609 u64 pkind:8;
610 u64 app_mode:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700611 u64 app_cap_flags:4;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700612 u64 max_nic_ports:10;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700613 u64 num_gmx_ports:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700614 u64 reserved:11;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700615 u64 len:3; /** additional 64-bit words */
616 u64 subcode:8;
617 u64 opcode:4;
618 } r_core_drv_init;
619 struct {
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700620 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700621 u64 extra:25;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700622 u64 reserved:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700623 u64 len:3; /** additional 64-bit words */
624 u64 subcode:8;
625 u64 opcode:4;
626 } r_nic_info;
627#endif
628};
629
630#define OCT_RH_SIZE (sizeof(union octeon_rh))
631
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700632union octnic_packet_params {
633 u32 u32;
634 struct {
635#ifdef __BIG_ENDIAN_BITFIELD
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700636 u32 reserved:24;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700637 u32 ip_csum:1; /* Perform IP header checksum(s) */
638 /* Perform Outer transport header checksum */
639 u32 transport_csum:1;
640 /* Find tunnel, and perform transport csum. */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700641 u32 tnl_csum:1;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700642 u32 tsflag:1; /* Timestamp this packet */
643 u32 ipsec_ops:4; /* IPsec operation */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700644#else
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700645 u32 ipsec_ops:4;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700646 u32 tsflag:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700647 u32 tnl_csum:1;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700648 u32 transport_csum:1;
649 u32 ip_csum:1;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700650 u32 reserved:24;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700651#endif
652 } s;
653};
654
655/** Status of a RGMII Link on Octeon as seen by core driver. */
656union oct_link_status {
657 u64 u64;
658
659 struct {
660#ifdef __BIG_ENDIAN_BITFIELD
661 u64 duplex:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700662 u64 mtu:16;
663 u64 speed:16;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700664 u64 link_up:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700665 u64 autoneg:1;
Raghu Vatsavayi9eb60842016-06-21 22:53:12 -0700666 u64 if_mode:5;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700667 u64 pause:1;
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700668 u64 flashing:1;
669 u64 reserved:15;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700670#else
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700671 u64 reserved:15;
672 u64 flashing:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700673 u64 pause:1;
Raghu Vatsavayi9eb60842016-06-21 22:53:12 -0700674 u64 if_mode:5;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700675 u64 autoneg:1;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700676 u64 link_up:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700677 u64 speed:16;
678 u64 mtu:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700679 u64 duplex:8;
680#endif
681 } s;
682};
683
Raghu Vatsavayi26236fa2016-06-14 16:54:44 -0700684/** The txpciq info passed to host from the firmware */
685
686union oct_txpciq {
687 u64 u64;
688
689 struct {
690#ifdef __BIG_ENDIAN_BITFIELD
691 u64 q_no:8;
692 u64 port:8;
693 u64 pkind:6;
694 u64 use_qpg:1;
695 u64 qpg:11;
696 u64 reserved:30;
697#else
698 u64 reserved:30;
699 u64 qpg:11;
700 u64 use_qpg:1;
701 u64 pkind:6;
702 u64 port:8;
703 u64 q_no:8;
704#endif
705 } s;
706};
707
708/** The rxpciq info passed to host from the firmware */
709
710union oct_rxpciq {
711 u64 u64;
712
713 struct {
714#ifdef __BIG_ENDIAN_BITFIELD
715 u64 q_no:8;
716 u64 reserved:56;
717#else
718 u64 reserved:56;
719 u64 q_no:8;
720#endif
721 } s;
722};
723
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700724/** Information for a OCTEON ethernet interface shared between core & host. */
725struct oct_link_info {
726 union oct_link_status link;
727 u64 hw_addr;
728
729#ifdef __BIG_ENDIAN_BITFIELD
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700730 u64 gmxport:16;
731 u64 rsvd:32;
732 u64 num_txpciq:8;
733 u64 num_rxpciq:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700734#else
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700735 u64 num_rxpciq:8;
736 u64 num_txpciq:8;
737 u64 rsvd:32;
738 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700739#endif
740
Raghu Vatsavayi26236fa2016-06-14 16:54:44 -0700741 union oct_txpciq txpciq[MAX_IOQS_PER_NICIF];
742 union oct_rxpciq rxpciq[MAX_IOQS_PER_NICIF];
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700743};
744
745#define OCT_LINK_INFO_SIZE (sizeof(struct oct_link_info))
746
747struct liquidio_if_cfg_info {
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700748 u64 iqmask; /** mask for IQs enabled for the port */
749 u64 oqmask; /** mask for OQs enabled for the port */
750 struct oct_link_info linfo; /** initial link information */
Raghu Vatsavayid3d7e6c2016-06-21 22:53:07 -0700751 char liquidio_firmware_version[32];
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700752};
753
754/** Stats for each NIC port in RX direction. */
755struct nic_rx_stats {
756 /* link-level stats */
757 u64 total_rcvd;
758 u64 bytes_rcvd;
759 u64 total_bcst;
760 u64 total_mcst;
761 u64 runts;
762 u64 ctl_rcvd;
763 u64 fifo_err; /* Accounts for over/under-run of buffers */
764 u64 dmac_drop;
765 u64 fcs_err;
766 u64 jabber_err;
767 u64 l2_err;
768 u64 frame_err;
769
770 /* firmware stats */
771 u64 fw_total_rcvd;
772 u64 fw_total_fwd;
773 u64 fw_err_pko;
774 u64 fw_err_link;
775 u64 fw_err_drop;
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700776 u64 fw_rx_vxlan;
777 u64 fw_rx_vxlan_err;
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700778
779 /* LRO */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700780 u64 fw_lro_pkts; /* Number of packets that are LROed */
781 u64 fw_lro_octs; /* Number of octets that are LROed */
782 u64 fw_total_lro; /* Number of LRO packets formed */
783 u64 fw_lro_aborts; /* Number of times lRO of packet aborted */
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700784 u64 fw_lro_aborts_port;
785 u64 fw_lro_aborts_seq;
786 u64 fw_lro_aborts_tsval;
787 u64 fw_lro_aborts_timer;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700788 /* intrmod: packet forward rate */
789 u64 fwd_rate;
790};
791
792/** Stats for each NIC port in RX direction. */
793struct nic_tx_stats {
794 /* link-level stats */
795 u64 total_pkts_sent;
796 u64 total_bytes_sent;
797 u64 mcast_pkts_sent;
798 u64 bcast_pkts_sent;
799 u64 ctl_sent;
800 u64 one_collision_sent; /* Packets sent after one collision*/
801 u64 multi_collision_sent; /* Packets sent after multiple collision*/
802 u64 max_collision_fail; /* Packets not sent due to max collisions */
803 u64 max_deferral_fail; /* Packets not sent due to max deferrals */
804 u64 fifo_err; /* Accounts for over/under-run of buffers */
805 u64 runts;
806 u64 total_collisions; /* Total number of collisions detected */
807
808 /* firmware stats */
809 u64 fw_total_sent;
810 u64 fw_total_fwd;
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700811 u64 fw_total_fwd_bytes;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700812 u64 fw_err_pko;
813 u64 fw_err_link;
814 u64 fw_err_drop;
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700815 u64 fw_err_tso;
816 u64 fw_tso; /* number of tso requests */
817 u64 fw_tso_fwd; /* number of packets segmented in tso */
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700818 u64 fw_tx_vxlan;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700819};
820
821struct oct_link_stats {
822 struct nic_rx_stats fromwire;
823 struct nic_tx_stats fromhost;
824
825};
826
827#define LIO68XX_LED_CTRL_ADDR 0x3501
828#define LIO68XX_LED_CTRL_CFGON 0x1f
829#define LIO68XX_LED_CTRL_CFGOFF 0x100
830#define LIO68XX_LED_BEACON_ADDR 0x3508
831#define LIO68XX_LED_BEACON_CFGON 0x47fd
832#define LIO68XX_LED_BEACON_CFGOFF 0x11fc
833#define VITESSE_PHY_GPIO_DRIVEON 0x1
834#define VITESSE_PHY_GPIO_CFG 0x8
835#define VITESSE_PHY_GPIO_DRIVEOFF 0x4
836#define VITESSE_PHY_GPIO_HIGH 0x2
837#define VITESSE_PHY_GPIO_LOW 0x3
838
839struct oct_mdio_cmd {
840 u64 op;
841 u64 mdio_addr;
842 u64 value1;
843 u64 value2;
844 u64 value3;
845};
846
847#define OCT_LINK_STATS_SIZE (sizeof(struct oct_link_stats))
848
Raghu Vatsavayi78e6a9b2016-06-21 22:53:10 -0700849/* intrmod: max. packet rate threshold */
850#define LIO_INTRMOD_MAXPKT_RATETHR 196608
851/* intrmod: min. packet rate threshold */
852#define LIO_INTRMOD_MINPKT_RATETHR 9216
853/* intrmod: max. packets to trigger interrupt */
854#define LIO_INTRMOD_RXMAXCNT_TRIGGER 384
855/* intrmod: min. packets to trigger interrupt */
Raghu Vatsavayicd8b1eb2016-08-31 11:03:22 -0700856#define LIO_INTRMOD_RXMINCNT_TRIGGER 0
Raghu Vatsavayi78e6a9b2016-06-21 22:53:10 -0700857/* intrmod: max. time to trigger interrupt */
858#define LIO_INTRMOD_RXMAXTMR_TRIGGER 128
859/* 66xx:intrmod: min. time to trigger interrupt
860 * (value of 1 is optimum for TCP_RR)
861 */
862#define LIO_INTRMOD_RXMINTMR_TRIGGER 1
863
864/* intrmod: max. packets to trigger interrupt */
865#define LIO_INTRMOD_TXMAXCNT_TRIGGER 64
866/* intrmod: min. packets to trigger interrupt */
867#define LIO_INTRMOD_TXMINCNT_TRIGGER 0
868
869/* intrmod: poll interval in seconds */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700870#define LIO_INTRMOD_CHECK_INTERVAL 1
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700871
872struct oct_intrmod_cfg {
Raghu Vatsavayi78e6a9b2016-06-21 22:53:10 -0700873 u64 rx_enable;
874 u64 tx_enable;
875 u64 check_intrvl;
876 u64 maxpkt_ratethr;
877 u64 minpkt_ratethr;
878 u64 rx_maxcnt_trigger;
879 u64 rx_mincnt_trigger;
880 u64 rx_maxtmr_trigger;
881 u64 rx_mintmr_trigger;
882 u64 tx_mincnt_trigger;
883 u64 tx_maxcnt_trigger;
884 u64 rx_frames;
885 u64 tx_frames;
886 u64 rx_usecs;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700887};
888
889#define BASE_QUEUE_NOT_REQUESTED 65535
890
891union oct_nic_if_cfg {
892 u64 u64;
893 struct {
894#ifdef __BIG_ENDIAN_BITFIELD
895 u64 base_queue:16;
896 u64 num_iqueues:16;
897 u64 num_oqueues:16;
898 u64 gmx_port_id:8;
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700899 u64 vf_id:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700900#else
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700901 u64 vf_id:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700902 u64 gmx_port_id:8;
903 u64 num_oqueues:16;
904 u64 num_iqueues:16;
905 u64 base_queue:16;
906#endif
907 } s;
908};
909
910#endif