blob: c6e3d57e3837b7988198d9d9e80a0b49ffd37bc6 [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_BASE_VERSION "1.4"
34#define LIQUIDIO_MICRO_VERSION ".1"
35#define LIQUIDIO_PACKAGE ""
36#define LIQUIDIO_VERSION "1.4.1"
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -070037#define CONTROL_IQ 0
38/** Tag types used by Octeon cores in its work. */
39enum octeon_tag_type {
40 ORDERED_TAG = 0,
41 ATOMIC_TAG = 1,
42 NULL_TAG = 2,
43 NULL_NULL_TAG = 3
44};
45
46/* pre-defined host->NIC tag values */
47#define LIO_CONTROL (0x11111110)
48#define LIO_DATA(i) (0x11111111 + (i))
49
50/* Opcodes used by host driver/apps to perform operations on the core.
51 * These are used to identify the major subsystem that the operation
52 * is for.
53 */
54#define OPCODE_CORE 0 /* used for generic core operations */
55#define OPCODE_NIC 1 /* used for NIC operations */
56#define OPCODE_LAST OPCODE_NIC
57
58/* Subcodes are used by host driver/apps to identify the sub-operation
59 * for the core. They only need to by unique for a given subsystem.
60 */
61#define OPCODE_SUBCODE(op, sub) (((op & 0x0f) << 8) | ((sub) & 0x7f))
62
63/** OPCODE_CORE subcodes. For future use. */
64
65/** OPCODE_NIC subcodes */
66
67/* This subcode is sent by core PCI driver to indicate cores are ready. */
68#define OPCODE_NIC_CORE_DRV_ACTIVE 0x01
69#define OPCODE_NIC_NW_DATA 0x02 /* network packet data */
70#define OPCODE_NIC_CMD 0x03
71#define OPCODE_NIC_INFO 0x04
72#define OPCODE_NIC_PORT_STATS 0x05
73#define OPCODE_NIC_MDIO45 0x06
74#define OPCODE_NIC_TIMESTAMP 0x07
75#define OPCODE_NIC_INTRMOD_CFG 0x08
76#define OPCODE_NIC_IF_CFG 0x09
77
78#define CORE_DRV_TEST_SCATTER_OP 0xFFF5
79
80#define OPCODE_SLOW_PATH(rh) \
81 (OPCODE_SUBCODE(rh->r.opcode, rh->r.subcode) != \
82 OPCODE_SUBCODE(OPCODE_NIC, OPCODE_NIC_NW_DATA))
83
84/* Application codes advertised by the core driver initialization packet. */
85#define CVM_DRV_APP_START 0x0
86#define CVM_DRV_NO_APP 0
87#define CVM_DRV_APP_COUNT 0x2
88#define CVM_DRV_BASE_APP (CVM_DRV_APP_START + 0x0)
89#define CVM_DRV_NIC_APP (CVM_DRV_APP_START + 0x1)
90#define CVM_DRV_INVALID_APP (CVM_DRV_APP_START + 0x2)
91#define CVM_DRV_APP_END (CVM_DRV_INVALID_APP - 1)
92
93/* Macro to increment index.
94 * Index is incremented by count; if the sum exceeds
95 * max, index is wrapped-around to the start.
96 */
97#define INCR_INDEX(index, count, max) \
98do { \
99 if (((index) + (count)) >= (max)) \
100 index = ((index) + (count)) - (max); \
101 else \
102 index += (count); \
103} while (0)
104
105#define INCR_INDEX_BY1(index, max) \
106do { \
107 if ((++(index)) == (max)) \
108 index = 0; \
109} while (0)
110
111#define DECR_INDEX(index, count, max) \
112do { \
113 if ((count) > (index)) \
114 index = ((max) - ((count - index))); \
115 else \
116 index -= count; \
117} while (0)
118
119#define OCT_BOARD_NAME 32
120#define OCT_SERIAL_LEN 64
121
122/* Structure used by core driver to send indication that the Octeon
123 * application is ready.
124 */
125struct octeon_core_setup {
126 u64 corefreq;
127
128 char boardname[OCT_BOARD_NAME];
129
130 char board_serial_number[OCT_SERIAL_LEN];
131
132 u64 board_rev_major;
133
134 u64 board_rev_minor;
135
136};
137
138/*--------------------------- SCATTER GATHER ENTRY -----------------------*/
139
140/* The Scatter-Gather List Entry. The scatter or gather component used with
141 * a Octeon input instruction has this format.
142 */
143struct octeon_sg_entry {
144 /** The first 64 bit gives the size of data in each dptr.*/
145 union {
146 u16 size[4];
147 u64 size64;
148 } u;
149
150 /** The 4 dptr pointers for this entry. */
151 u64 ptr[4];
152
153};
154
155#define OCT_SG_ENTRY_SIZE (sizeof(struct octeon_sg_entry))
156
157/* \brief Add size to gather list
158 * @param sg_entry scatter/gather entry
159 * @param size size to add
160 * @param pos position to add it.
161 */
162static inline void add_sg_size(struct octeon_sg_entry *sg_entry,
163 u16 size,
164 u32 pos)
165{
166#ifdef __BIG_ENDIAN_BITFIELD
167 sg_entry->u.size[pos] = size;
168#else
169 sg_entry->u.size[3 - pos] = size;
170#endif
171}
172
173/*------------------------- End Scatter/Gather ---------------------------*/
174
175#define OCTNET_FRM_PTP_HEADER_SIZE 8
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700176
Raghu Vatsavayia5b37882016-06-14 16:54:48 -0700177#define OCTNET_FRM_HEADER_SIZE 22 /* VLAN + Ethernet */
178
179#define OCTNET_MIN_FRM_SIZE 64
180
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700181#define OCTNET_MAX_FRM_SIZE (16000 + OCTNET_FRM_HEADER_SIZE)
182
183#define OCTNET_DEFAULT_FRM_SIZE (1500 + OCTNET_FRM_HEADER_SIZE)
184
185/** NIC Commands are sent using this Octeon Input Queue */
186#define OCTNET_CMD_Q 0
187
188/* NIC Command types */
189#define OCTNET_CMD_CHANGE_MTU 0x1
190#define OCTNET_CMD_CHANGE_MACADDR 0x2
191#define OCTNET_CMD_CHANGE_DEVFLAGS 0x3
192#define OCTNET_CMD_RX_CTL 0x4
193
194#define OCTNET_CMD_SET_MULTI_LIST 0x5
195#define OCTNET_CMD_CLEAR_STATS 0x6
196
197/* command for setting the speed, duplex & autoneg */
198#define OCTNET_CMD_SET_SETTINGS 0x7
199#define OCTNET_CMD_SET_FLOW_CTL 0x8
200
201#define OCTNET_CMD_MDIO_READ_WRITE 0x9
202#define OCTNET_CMD_GPIO_ACCESS 0xA
203#define OCTNET_CMD_LRO_ENABLE 0xB
204#define OCTNET_CMD_LRO_DISABLE 0xC
205#define OCTNET_CMD_SET_RSS 0xD
206#define OCTNET_CMD_WRITE_SA 0xE
207#define OCTNET_CMD_DELETE_SA 0xF
208#define OCTNET_CMD_UPDATE_SA 0x12
209
210#define OCTNET_CMD_TNL_RX_CSUM_CTL 0x10
211#define OCTNET_CMD_TNL_TX_CSUM_CTL 0x11
212#define OCTNET_CMD_IPSECV2_AH_ESP_CTL 0x13
213#define OCTNET_CMD_VERBOSE_ENABLE 0x14
214#define OCTNET_CMD_VERBOSE_DISABLE 0x15
215
Raghu Vatsavayi63245f22016-06-21 22:53:05 -0700216#define OCTNET_CMD_ENABLE_VLAN_FILTER 0x16
217#define OCTNET_CMD_ADD_VLAN_FILTER 0x17
218#define OCTNET_CMD_DEL_VLAN_FILTER 0x18
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700219#define OCTNET_CMD_VXLAN_PORT_CONFIG 0x19
220#define OCTNET_CMD_VXLAN_PORT_ADD 0x0
221#define OCTNET_CMD_VXLAN_PORT_DEL 0x1
222#define OCTNET_CMD_RXCSUM_ENABLE 0x0
223#define OCTNET_CMD_RXCSUM_DISABLE 0x1
224#define OCTNET_CMD_TXCSUM_ENABLE 0x0
225#define OCTNET_CMD_TXCSUM_DISABLE 0x1
Raghu Vatsavayi63245f22016-06-21 22:53:05 -0700226
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700227/* RX(packets coming from wire) Checksum verification flags */
228/* TCP/UDP csum */
229#define CNNIC_L4SUM_VERIFIED 0x1
230#define CNNIC_IPSUM_VERIFIED 0x2
231#define CNNIC_TUN_CSUM_VERIFIED 0x4
232#define CNNIC_CSUM_VERIFIED (CNNIC_IPSUM_VERIFIED | CNNIC_L4SUM_VERIFIED)
233
234/*LROIPV4 and LROIPV6 Flags*/
235#define OCTNIC_LROIPV4 0x1
236#define OCTNIC_LROIPV6 0x2
237
238/* Interface flags communicated between host driver and core app. */
239enum octnet_ifflags {
240 OCTNET_IFFLAG_PROMISC = 0x01,
241 OCTNET_IFFLAG_ALLMULTI = 0x02,
242 OCTNET_IFFLAG_MULTICAST = 0x04,
243 OCTNET_IFFLAG_BROADCAST = 0x08,
244 OCTNET_IFFLAG_UNICAST = 0x10
245};
246
247/* wqe
248 * --------------- 0
249 * | wqe word0-3 |
250 * --------------- 32
251 * | PCI IH |
252 * --------------- 40
253 * | RPTR |
254 * --------------- 48
255 * | PCI IRH |
256 * --------------- 56
257 * | OCT_NET_CMD |
258 * --------------- 64
259 * | Addtl 8-BData |
260 * | |
261 * ---------------
262 */
263
264union octnet_cmd {
265 u64 u64;
266
267 struct {
268#ifdef __BIG_ENDIAN_BITFIELD
269 u64 cmd:5;
270
271 u64 more:6; /* How many udd words follow the command */
272
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700273 u64 reserved:29;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700274
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700275 u64 param1:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700276
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700277 u64 param2:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700278
279#else
280
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700281 u64 param2:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700282
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700283 u64 param1:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700284
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700285 u64 reserved:29;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700286
287 u64 more:6;
288
289 u64 cmd:5;
290
291#endif
292 } s;
293
294};
295
296#define OCTNET_CMD_SIZE (sizeof(union octnet_cmd))
297
Raghu Vatsavayi6a885b62016-06-14 16:54:51 -0700298/* Instruction Header (DPI - CN23xx) - for OCTEON-III models */
299struct octeon_instr_ih3 {
300#ifdef __BIG_ENDIAN_BITFIELD
301
302 /** Reserved3 */
303 u64 reserved3:1;
304
305 /** Gather indicator 1=gather*/
306 u64 gather:1;
307
308 /** Data length OR no. of entries in gather list */
309 u64 dlengsz:14;
310
311 /** Front Data size */
312 u64 fsz:6;
313
314 /** Reserved2 */
315 u64 reserved2:4;
316
317 /** PKI port kind - PKIND */
318 u64 pkind:6;
319
320 /** Reserved1 */
321 u64 reserved1:32;
322
323#else
324 /** Reserved1 */
325 u64 reserved1:32;
326
327 /** PKI port kind - PKIND */
328 u64 pkind:6;
329
330 /** Reserved2 */
331 u64 reserved2:4;
332
333 /** Front Data size */
334 u64 fsz:6;
335
336 /** Data length OR no. of entries in gather list */
337 u64 dlengsz:14;
338
339 /** Gather indicator 1=gather*/
340 u64 gather:1;
341
342 /** Reserved3 */
343 u64 reserved3:1;
344
345#endif
346};
347
348/* Optional PKI Instruction Header(PKI IH) - for OCTEON CN23XX models */
349/** BIG ENDIAN format. */
350struct octeon_instr_pki_ih3 {
351#ifdef __BIG_ENDIAN_BITFIELD
352
353 /** Wider bit */
354 u64 w:1;
355
356 /** Raw mode indicator 1 = RAW */
357 u64 raw:1;
358
359 /** Use Tag */
360 u64 utag:1;
361
362 /** Use QPG */
363 u64 uqpg:1;
364
365 /** Reserved2 */
366 u64 reserved2:1;
367
368 /** Parse Mode */
369 u64 pm:3;
370
371 /** Skip Length */
372 u64 sl:8;
373
374 /** Use Tag Type */
375 u64 utt:1;
376
377 /** Tag type */
378 u64 tagtype:2;
379
380 /** Reserved1 */
381 u64 reserved1:2;
382
383 /** QPG Value */
384 u64 qpg:11;
385
386 /** Tag Value */
387 u64 tag:32;
388
389#else
390
391 /** Tag Value */
392 u64 tag:32;
393
394 /** QPG Value */
395 u64 qpg:11;
396
397 /** Reserved1 */
398 u64 reserved1:2;
399
400 /** Tag type */
401 u64 tagtype:2;
402
403 /** Use Tag Type */
404 u64 utt:1;
405
406 /** Skip Length */
407 u64 sl:8;
408
409 /** Parse Mode */
410 u64 pm:3;
411
412 /** Reserved2 */
413 u64 reserved2:1;
414
415 /** Use QPG */
416 u64 uqpg:1;
417
418 /** Use Tag */
419 u64 utag:1;
420
421 /** Raw mode indicator 1 = RAW */
422 u64 raw:1;
423
424 /** Wider bit */
425 u64 w:1;
426#endif
427
428};
429
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700430/** Instruction Header */
Raghu Vatsavayi6a885b62016-06-14 16:54:51 -0700431struct octeon_instr_ih2 {
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700432#ifdef __BIG_ENDIAN_BITFIELD
433 /** Raw mode indicator 1 = RAW */
434 u64 raw:1;
435
436 /** Gather indicator 1=gather*/
437 u64 gather:1;
438
439 /** Data length OR no. of entries in gather list */
440 u64 dlengsz:14;
441
442 /** Front Data size */
443 u64 fsz:6;
444
445 /** Packet Order / Work Unit selection (1 of 8)*/
446 u64 qos:3;
447
448 /** Core group selection (1 of 16) */
449 u64 grp:4;
450
451 /** Short Raw Packet Indicator 1=short raw pkt */
452 u64 rs:1;
453
454 /** Tag type */
455 u64 tagtype:2;
456
457 /** Tag Value */
458 u64 tag:32;
459#else
460 /** Tag Value */
461 u64 tag:32;
462
463 /** Tag type */
464 u64 tagtype:2;
465
466 /** Short Raw Packet Indicator 1=short raw pkt */
467 u64 rs:1;
468
469 /** Core group selection (1 of 16) */
470 u64 grp:4;
471
472 /** Packet Order / Work Unit selection (1 of 8)*/
473 u64 qos:3;
474
475 /** Front Data size */
476 u64 fsz:6;
477
478 /** Data length OR no. of entries in gather list */
479 u64 dlengsz:14;
480
481 /** Gather indicator 1=gather*/
482 u64 gather:1;
483
484 /** Raw mode indicator 1 = RAW */
485 u64 raw:1;
486#endif
487};
488
489/** Input Request Header */
490struct octeon_instr_irh {
491#ifdef __BIG_ENDIAN_BITFIELD
492 u64 opcode:4;
493 u64 rflag:1;
494 u64 subcode:7;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700495 u64 vlan:12;
496 u64 priority:3;
497 u64 reserved:5;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700498 u64 ossp:32; /* opcode/subcode specific parameters */
499#else
500 u64 ossp:32; /* opcode/subcode specific parameters */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700501 u64 reserved:5;
502 u64 priority:3;
503 u64 vlan:12;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700504 u64 subcode:7;
505 u64 rflag:1;
506 u64 opcode:4;
507#endif
508};
509
510/** Return Data Parameters */
511struct octeon_instr_rdp {
512#ifdef __BIG_ENDIAN_BITFIELD
513 u64 reserved:49;
514 u64 pcie_port:3;
515 u64 rlen:12;
516#else
517 u64 rlen:12;
518 u64 pcie_port:3;
519 u64 reserved:49;
520#endif
521};
522
523/** Receive Header */
524union octeon_rh {
525#ifdef __BIG_ENDIAN_BITFIELD
526 u64 u64;
527 struct {
528 u64 opcode:4;
529 u64 subcode:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700530 u64 len:3; /** additional 64-bit words */
531 u64 reserved:17;
532 u64 ossp:32; /** opcode/subcode specific parameters */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700533 } r;
534 struct {
535 u64 opcode:4;
536 u64 subcode:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700537 u64 len:3; /** additional 64-bit words */
538 u64 extra:28;
539 u64 vlan:12;
540 u64 priority:3;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700541 u64 csum_verified:3; /** checksum verified. */
542 u64 has_hwtstamp:1; /** Has hardware timestamp. 1 = yes. */
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700543 u64 encap_on:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700544 } r_dh;
545 struct {
546 u64 opcode:4;
547 u64 subcode:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700548 u64 len:3; /** additional 64-bit words */
549 u64 reserved:11;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700550 u64 num_gmx_ports:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700551 u64 max_nic_ports:10;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700552 u64 app_cap_flags:4;
553 u64 app_mode:16;
554 } r_core_drv_init;
555 struct {
556 u64 opcode:4;
557 u64 subcode:8;
558 u64 len:3; /** additional 64-bit words */
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700559 u64 reserved:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700560 u64 extra:25;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700561 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700562 } r_nic_info;
563#else
564 u64 u64;
565 struct {
566 u64 ossp:32; /** opcode/subcode specific parameters */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700567 u64 reserved:17;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700568 u64 len:3; /** additional 64-bit words */
569 u64 subcode:8;
570 u64 opcode:4;
571 } r;
572 struct {
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700573 u64 encap_on:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700574 u64 has_hwtstamp:1; /** 1 = has hwtstamp */
575 u64 csum_verified:3; /** checksum verified. */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700576 u64 priority:3;
577 u64 vlan:12;
578 u64 extra:28;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700579 u64 len:3; /** additional 64-bit words */
580 u64 subcode:8;
581 u64 opcode:4;
582 } r_dh;
583 struct {
584 u64 app_mode:16;
585 u64 app_cap_flags:4;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700586 u64 max_nic_ports:10;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700587 u64 num_gmx_ports:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700588 u64 reserved:11;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700589 u64 len:3; /** additional 64-bit words */
590 u64 subcode:8;
591 u64 opcode:4;
592 } r_core_drv_init;
593 struct {
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700594 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700595 u64 extra:25;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700596 u64 reserved:8;
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_nic_info;
601#endif
602};
603
604#define OCT_RH_SIZE (sizeof(union octeon_rh))
605
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700606union octnic_packet_params {
607 u32 u32;
608 struct {
609#ifdef __BIG_ENDIAN_BITFIELD
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700610 u32 reserved:24;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700611 u32 ip_csum:1; /* Perform IP header checksum(s) */
612 /* Perform Outer transport header checksum */
613 u32 transport_csum:1;
614 /* Find tunnel, and perform transport csum. */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700615 u32 tnl_csum:1;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700616 u32 tsflag:1; /* Timestamp this packet */
617 u32 ipsec_ops:4; /* IPsec operation */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700618#else
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700619 u32 ipsec_ops:4;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700620 u32 tsflag:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700621 u32 tnl_csum:1;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700622 u32 transport_csum:1;
623 u32 ip_csum:1;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700624 u32 reserved:24;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700625#endif
626 } s;
627};
628
629/** Status of a RGMII Link on Octeon as seen by core driver. */
630union oct_link_status {
631 u64 u64;
632
633 struct {
634#ifdef __BIG_ENDIAN_BITFIELD
635 u64 duplex:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700636 u64 mtu:16;
637 u64 speed:16;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700638 u64 link_up:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700639 u64 autoneg:1;
Raghu Vatsavayi9eb60842016-06-21 22:53:12 -0700640 u64 if_mode:5;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700641 u64 pause:1;
Raghu Vatsavayi9eb60842016-06-21 22:53:12 -0700642 u64 reserved:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700643#else
Raghu Vatsavayi9eb60842016-06-21 22:53:12 -0700644 u64 reserved:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700645 u64 pause:1;
Raghu Vatsavayi9eb60842016-06-21 22:53:12 -0700646 u64 if_mode:5;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700647 u64 autoneg:1;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700648 u64 link_up:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700649 u64 speed:16;
650 u64 mtu:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700651 u64 duplex:8;
652#endif
653 } s;
654};
655
Raghu Vatsavayi26236fa2016-06-14 16:54:44 -0700656/** The txpciq info passed to host from the firmware */
657
658union oct_txpciq {
659 u64 u64;
660
661 struct {
662#ifdef __BIG_ENDIAN_BITFIELD
663 u64 q_no:8;
664 u64 port:8;
665 u64 pkind:6;
666 u64 use_qpg:1;
667 u64 qpg:11;
668 u64 reserved:30;
669#else
670 u64 reserved:30;
671 u64 qpg:11;
672 u64 use_qpg:1;
673 u64 pkind:6;
674 u64 port:8;
675 u64 q_no:8;
676#endif
677 } s;
678};
679
680/** The rxpciq info passed to host from the firmware */
681
682union oct_rxpciq {
683 u64 u64;
684
685 struct {
686#ifdef __BIG_ENDIAN_BITFIELD
687 u64 q_no:8;
688 u64 reserved:56;
689#else
690 u64 reserved:56;
691 u64 q_no:8;
692#endif
693 } s;
694};
695
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700696/** Information for a OCTEON ethernet interface shared between core & host. */
697struct oct_link_info {
698 union oct_link_status link;
699 u64 hw_addr;
700
701#ifdef __BIG_ENDIAN_BITFIELD
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700702 u64 gmxport:16;
703 u64 rsvd:32;
704 u64 num_txpciq:8;
705 u64 num_rxpciq:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700706#else
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700707 u64 num_rxpciq:8;
708 u64 num_txpciq:8;
709 u64 rsvd:32;
710 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700711#endif
712
Raghu Vatsavayi26236fa2016-06-14 16:54:44 -0700713 union oct_txpciq txpciq[MAX_IOQS_PER_NICIF];
714 union oct_rxpciq rxpciq[MAX_IOQS_PER_NICIF];
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700715};
716
717#define OCT_LINK_INFO_SIZE (sizeof(struct oct_link_info))
718
719struct liquidio_if_cfg_info {
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700720 u64 iqmask; /** mask for IQs enabled for the port */
721 u64 oqmask; /** mask for OQs enabled for the port */
722 struct oct_link_info linfo; /** initial link information */
Raghu Vatsavayid3d7e6c2016-06-21 22:53:07 -0700723 char liquidio_firmware_version[32];
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700724};
725
726/** Stats for each NIC port in RX direction. */
727struct nic_rx_stats {
728 /* link-level stats */
729 u64 total_rcvd;
730 u64 bytes_rcvd;
731 u64 total_bcst;
732 u64 total_mcst;
733 u64 runts;
734 u64 ctl_rcvd;
735 u64 fifo_err; /* Accounts for over/under-run of buffers */
736 u64 dmac_drop;
737 u64 fcs_err;
738 u64 jabber_err;
739 u64 l2_err;
740 u64 frame_err;
741
742 /* firmware stats */
743 u64 fw_total_rcvd;
744 u64 fw_total_fwd;
745 u64 fw_err_pko;
746 u64 fw_err_link;
747 u64 fw_err_drop;
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700748 u64 fw_rx_vxlan;
749 u64 fw_rx_vxlan_err;
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700750
751 /* LRO */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700752 u64 fw_lro_pkts; /* Number of packets that are LROed */
753 u64 fw_lro_octs; /* Number of octets that are LROed */
754 u64 fw_total_lro; /* Number of LRO packets formed */
755 u64 fw_lro_aborts; /* Number of times lRO of packet aborted */
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700756 u64 fw_lro_aborts_port;
757 u64 fw_lro_aborts_seq;
758 u64 fw_lro_aborts_tsval;
759 u64 fw_lro_aborts_timer;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700760 /* intrmod: packet forward rate */
761 u64 fwd_rate;
762};
763
764/** Stats for each NIC port in RX direction. */
765struct nic_tx_stats {
766 /* link-level stats */
767 u64 total_pkts_sent;
768 u64 total_bytes_sent;
769 u64 mcast_pkts_sent;
770 u64 bcast_pkts_sent;
771 u64 ctl_sent;
772 u64 one_collision_sent; /* Packets sent after one collision*/
773 u64 multi_collision_sent; /* Packets sent after multiple collision*/
774 u64 max_collision_fail; /* Packets not sent due to max collisions */
775 u64 max_deferral_fail; /* Packets not sent due to max deferrals */
776 u64 fifo_err; /* Accounts for over/under-run of buffers */
777 u64 runts;
778 u64 total_collisions; /* Total number of collisions detected */
779
780 /* firmware stats */
781 u64 fw_total_sent;
782 u64 fw_total_fwd;
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700783 u64 fw_total_fwd_bytes;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700784 u64 fw_err_pko;
785 u64 fw_err_link;
786 u64 fw_err_drop;
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700787 u64 fw_err_tso;
788 u64 fw_tso; /* number of tso requests */
789 u64 fw_tso_fwd; /* number of packets segmented in tso */
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700790 u64 fw_tx_vxlan;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700791};
792
793struct oct_link_stats {
794 struct nic_rx_stats fromwire;
795 struct nic_tx_stats fromhost;
796
797};
798
799#define LIO68XX_LED_CTRL_ADDR 0x3501
800#define LIO68XX_LED_CTRL_CFGON 0x1f
801#define LIO68XX_LED_CTRL_CFGOFF 0x100
802#define LIO68XX_LED_BEACON_ADDR 0x3508
803#define LIO68XX_LED_BEACON_CFGON 0x47fd
804#define LIO68XX_LED_BEACON_CFGOFF 0x11fc
805#define VITESSE_PHY_GPIO_DRIVEON 0x1
806#define VITESSE_PHY_GPIO_CFG 0x8
807#define VITESSE_PHY_GPIO_DRIVEOFF 0x4
808#define VITESSE_PHY_GPIO_HIGH 0x2
809#define VITESSE_PHY_GPIO_LOW 0x3
810
811struct oct_mdio_cmd {
812 u64 op;
813 u64 mdio_addr;
814 u64 value1;
815 u64 value2;
816 u64 value3;
817};
818
819#define OCT_LINK_STATS_SIZE (sizeof(struct oct_link_stats))
820
Raghu Vatsavayi78e6a9b2016-06-21 22:53:10 -0700821/* intrmod: max. packet rate threshold */
822#define LIO_INTRMOD_MAXPKT_RATETHR 196608
823/* intrmod: min. packet rate threshold */
824#define LIO_INTRMOD_MINPKT_RATETHR 9216
825/* intrmod: max. packets to trigger interrupt */
826#define LIO_INTRMOD_RXMAXCNT_TRIGGER 384
827/* intrmod: min. packets to trigger interrupt */
828#define LIO_INTRMOD_RXMINCNT_TRIGGER 1
829/* intrmod: max. time to trigger interrupt */
830#define LIO_INTRMOD_RXMAXTMR_TRIGGER 128
831/* 66xx:intrmod: min. time to trigger interrupt
832 * (value of 1 is optimum for TCP_RR)
833 */
834#define LIO_INTRMOD_RXMINTMR_TRIGGER 1
835
836/* intrmod: max. packets to trigger interrupt */
837#define LIO_INTRMOD_TXMAXCNT_TRIGGER 64
838/* intrmod: min. packets to trigger interrupt */
839#define LIO_INTRMOD_TXMINCNT_TRIGGER 0
840
841/* intrmod: poll interval in seconds */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700842#define LIO_INTRMOD_CHECK_INTERVAL 1
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700843
844struct oct_intrmod_cfg {
Raghu Vatsavayi78e6a9b2016-06-21 22:53:10 -0700845 u64 rx_enable;
846 u64 tx_enable;
847 u64 check_intrvl;
848 u64 maxpkt_ratethr;
849 u64 minpkt_ratethr;
850 u64 rx_maxcnt_trigger;
851 u64 rx_mincnt_trigger;
852 u64 rx_maxtmr_trigger;
853 u64 rx_mintmr_trigger;
854 u64 tx_mincnt_trigger;
855 u64 tx_maxcnt_trigger;
856 u64 rx_frames;
857 u64 tx_frames;
858 u64 rx_usecs;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700859};
860
861#define BASE_QUEUE_NOT_REQUESTED 65535
862
863union oct_nic_if_cfg {
864 u64 u64;
865 struct {
866#ifdef __BIG_ENDIAN_BITFIELD
867 u64 base_queue:16;
868 u64 num_iqueues:16;
869 u64 num_oqueues:16;
870 u64 gmx_port_id:8;
871 u64 reserved:8;
872#else
873 u64 reserved:8;
874 u64 gmx_port_id:8;
875 u64 num_oqueues:16;
876 u64 num_iqueues:16;
877 u64 base_queue:16;
878#endif
879 } s;
880};
881
882#endif