blob: 5aa01f427d4aa01bf106a37e82d9fb3a681a6643 [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
219
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700220/* RX(packets coming from wire) Checksum verification flags */
221/* TCP/UDP csum */
222#define CNNIC_L4SUM_VERIFIED 0x1
223#define CNNIC_IPSUM_VERIFIED 0x2
224#define CNNIC_TUN_CSUM_VERIFIED 0x4
225#define CNNIC_CSUM_VERIFIED (CNNIC_IPSUM_VERIFIED | CNNIC_L4SUM_VERIFIED)
226
227/*LROIPV4 and LROIPV6 Flags*/
228#define OCTNIC_LROIPV4 0x1
229#define OCTNIC_LROIPV6 0x2
230
231/* Interface flags communicated between host driver and core app. */
232enum octnet_ifflags {
233 OCTNET_IFFLAG_PROMISC = 0x01,
234 OCTNET_IFFLAG_ALLMULTI = 0x02,
235 OCTNET_IFFLAG_MULTICAST = 0x04,
236 OCTNET_IFFLAG_BROADCAST = 0x08,
237 OCTNET_IFFLAG_UNICAST = 0x10
238};
239
240/* wqe
241 * --------------- 0
242 * | wqe word0-3 |
243 * --------------- 32
244 * | PCI IH |
245 * --------------- 40
246 * | RPTR |
247 * --------------- 48
248 * | PCI IRH |
249 * --------------- 56
250 * | OCT_NET_CMD |
251 * --------------- 64
252 * | Addtl 8-BData |
253 * | |
254 * ---------------
255 */
256
257union octnet_cmd {
258 u64 u64;
259
260 struct {
261#ifdef __BIG_ENDIAN_BITFIELD
262 u64 cmd:5;
263
264 u64 more:6; /* How many udd words follow the command */
265
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700266 u64 reserved:29;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700267
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700268 u64 param1:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700269
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700270 u64 param2:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700271
272#else
273
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700274 u64 param2:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700275
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700276 u64 param1:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700277
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700278 u64 reserved:29;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700279
280 u64 more:6;
281
282 u64 cmd:5;
283
284#endif
285 } s;
286
287};
288
289#define OCTNET_CMD_SIZE (sizeof(union octnet_cmd))
290
Raghu Vatsavayi6a885b62016-06-14 16:54:51 -0700291/* Instruction Header (DPI - CN23xx) - for OCTEON-III models */
292struct octeon_instr_ih3 {
293#ifdef __BIG_ENDIAN_BITFIELD
294
295 /** Reserved3 */
296 u64 reserved3:1;
297
298 /** Gather indicator 1=gather*/
299 u64 gather:1;
300
301 /** Data length OR no. of entries in gather list */
302 u64 dlengsz:14;
303
304 /** Front Data size */
305 u64 fsz:6;
306
307 /** Reserved2 */
308 u64 reserved2:4;
309
310 /** PKI port kind - PKIND */
311 u64 pkind:6;
312
313 /** Reserved1 */
314 u64 reserved1:32;
315
316#else
317 /** Reserved1 */
318 u64 reserved1:32;
319
320 /** PKI port kind - PKIND */
321 u64 pkind:6;
322
323 /** Reserved2 */
324 u64 reserved2:4;
325
326 /** Front Data size */
327 u64 fsz:6;
328
329 /** Data length OR no. of entries in gather list */
330 u64 dlengsz:14;
331
332 /** Gather indicator 1=gather*/
333 u64 gather:1;
334
335 /** Reserved3 */
336 u64 reserved3:1;
337
338#endif
339};
340
341/* Optional PKI Instruction Header(PKI IH) - for OCTEON CN23XX models */
342/** BIG ENDIAN format. */
343struct octeon_instr_pki_ih3 {
344#ifdef __BIG_ENDIAN_BITFIELD
345
346 /** Wider bit */
347 u64 w:1;
348
349 /** Raw mode indicator 1 = RAW */
350 u64 raw:1;
351
352 /** Use Tag */
353 u64 utag:1;
354
355 /** Use QPG */
356 u64 uqpg:1;
357
358 /** Reserved2 */
359 u64 reserved2:1;
360
361 /** Parse Mode */
362 u64 pm:3;
363
364 /** Skip Length */
365 u64 sl:8;
366
367 /** Use Tag Type */
368 u64 utt:1;
369
370 /** Tag type */
371 u64 tagtype:2;
372
373 /** Reserved1 */
374 u64 reserved1:2;
375
376 /** QPG Value */
377 u64 qpg:11;
378
379 /** Tag Value */
380 u64 tag:32;
381
382#else
383
384 /** Tag Value */
385 u64 tag:32;
386
387 /** QPG Value */
388 u64 qpg:11;
389
390 /** Reserved1 */
391 u64 reserved1:2;
392
393 /** Tag type */
394 u64 tagtype:2;
395
396 /** Use Tag Type */
397 u64 utt:1;
398
399 /** Skip Length */
400 u64 sl:8;
401
402 /** Parse Mode */
403 u64 pm:3;
404
405 /** Reserved2 */
406 u64 reserved2:1;
407
408 /** Use QPG */
409 u64 uqpg:1;
410
411 /** Use Tag */
412 u64 utag:1;
413
414 /** Raw mode indicator 1 = RAW */
415 u64 raw:1;
416
417 /** Wider bit */
418 u64 w:1;
419#endif
420
421};
422
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700423/** Instruction Header */
Raghu Vatsavayi6a885b62016-06-14 16:54:51 -0700424struct octeon_instr_ih2 {
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700425#ifdef __BIG_ENDIAN_BITFIELD
426 /** Raw mode indicator 1 = RAW */
427 u64 raw:1;
428
429 /** Gather indicator 1=gather*/
430 u64 gather:1;
431
432 /** Data length OR no. of entries in gather list */
433 u64 dlengsz:14;
434
435 /** Front Data size */
436 u64 fsz:6;
437
438 /** Packet Order / Work Unit selection (1 of 8)*/
439 u64 qos:3;
440
441 /** Core group selection (1 of 16) */
442 u64 grp:4;
443
444 /** Short Raw Packet Indicator 1=short raw pkt */
445 u64 rs:1;
446
447 /** Tag type */
448 u64 tagtype:2;
449
450 /** Tag Value */
451 u64 tag:32;
452#else
453 /** Tag Value */
454 u64 tag:32;
455
456 /** Tag type */
457 u64 tagtype:2;
458
459 /** Short Raw Packet Indicator 1=short raw pkt */
460 u64 rs:1;
461
462 /** Core group selection (1 of 16) */
463 u64 grp:4;
464
465 /** Packet Order / Work Unit selection (1 of 8)*/
466 u64 qos:3;
467
468 /** Front Data size */
469 u64 fsz:6;
470
471 /** Data length OR no. of entries in gather list */
472 u64 dlengsz:14;
473
474 /** Gather indicator 1=gather*/
475 u64 gather:1;
476
477 /** Raw mode indicator 1 = RAW */
478 u64 raw:1;
479#endif
480};
481
482/** Input Request Header */
483struct octeon_instr_irh {
484#ifdef __BIG_ENDIAN_BITFIELD
485 u64 opcode:4;
486 u64 rflag:1;
487 u64 subcode:7;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700488 u64 vlan:12;
489 u64 priority:3;
490 u64 reserved:5;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700491 u64 ossp:32; /* opcode/subcode specific parameters */
492#else
493 u64 ossp:32; /* opcode/subcode specific parameters */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700494 u64 reserved:5;
495 u64 priority:3;
496 u64 vlan:12;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700497 u64 subcode:7;
498 u64 rflag:1;
499 u64 opcode:4;
500#endif
501};
502
503/** Return Data Parameters */
504struct octeon_instr_rdp {
505#ifdef __BIG_ENDIAN_BITFIELD
506 u64 reserved:49;
507 u64 pcie_port:3;
508 u64 rlen:12;
509#else
510 u64 rlen:12;
511 u64 pcie_port:3;
512 u64 reserved:49;
513#endif
514};
515
516/** Receive Header */
517union octeon_rh {
518#ifdef __BIG_ENDIAN_BITFIELD
519 u64 u64;
520 struct {
521 u64 opcode:4;
522 u64 subcode:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700523 u64 len:3; /** additional 64-bit words */
524 u64 reserved:17;
525 u64 ossp:32; /** opcode/subcode specific parameters */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700526 } r;
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 extra:28;
532 u64 vlan:12;
533 u64 priority:3;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700534 u64 csum_verified:3; /** checksum verified. */
535 u64 has_hwtstamp:1; /** Has hardware timestamp. 1 = yes. */
536 } r_dh;
537 struct {
538 u64 opcode:4;
539 u64 subcode:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700540 u64 len:3; /** additional 64-bit words */
541 u64 reserved:11;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700542 u64 num_gmx_ports:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700543 u64 max_nic_ports:10;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700544 u64 app_cap_flags:4;
545 u64 app_mode:16;
546 } r_core_drv_init;
547 struct {
548 u64 opcode:4;
549 u64 subcode:8;
550 u64 len:3; /** additional 64-bit words */
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700551 u64 reserved:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700552 u64 extra:25;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700553 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700554 } r_nic_info;
555#else
556 u64 u64;
557 struct {
558 u64 ossp:32; /** opcode/subcode specific parameters */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700559 u64 reserved:17;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700560 u64 len:3; /** additional 64-bit words */
561 u64 subcode:8;
562 u64 opcode:4;
563 } r;
564 struct {
565 u64 has_hwtstamp:1; /** 1 = has hwtstamp */
566 u64 csum_verified:3; /** checksum verified. */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700567 u64 priority:3;
568 u64 vlan:12;
569 u64 extra:28;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700570 u64 len:3; /** additional 64-bit words */
571 u64 subcode:8;
572 u64 opcode:4;
573 } r_dh;
574 struct {
575 u64 app_mode:16;
576 u64 app_cap_flags:4;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700577 u64 max_nic_ports:10;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700578 u64 num_gmx_ports:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700579 u64 reserved:11;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700580 u64 len:3; /** additional 64-bit words */
581 u64 subcode:8;
582 u64 opcode:4;
583 } r_core_drv_init;
584 struct {
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700585 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700586 u64 extra:25;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700587 u64 reserved:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700588 u64 len:3; /** additional 64-bit words */
589 u64 subcode:8;
590 u64 opcode:4;
591 } r_nic_info;
592#endif
593};
594
595#define OCT_RH_SIZE (sizeof(union octeon_rh))
596
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700597union octnic_packet_params {
598 u32 u32;
599 struct {
600#ifdef __BIG_ENDIAN_BITFIELD
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700601 u32 reserved:24;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700602 u32 ip_csum:1; /* Perform IP header checksum(s) */
603 /* Perform Outer transport header checksum */
604 u32 transport_csum:1;
605 /* Find tunnel, and perform transport csum. */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700606 u32 tnl_csum:1;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700607 u32 tsflag:1; /* Timestamp this packet */
608 u32 ipsec_ops:4; /* IPsec operation */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700609#else
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700610 u32 ipsec_ops:4;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700611 u32 tsflag:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700612 u32 tnl_csum:1;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700613 u32 transport_csum:1;
614 u32 ip_csum:1;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700615 u32 reserved:24;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700616#endif
617 } s;
618};
619
620/** Status of a RGMII Link on Octeon as seen by core driver. */
621union oct_link_status {
622 u64 u64;
623
624 struct {
625#ifdef __BIG_ENDIAN_BITFIELD
626 u64 duplex:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700627 u64 mtu:16;
628 u64 speed:16;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700629 u64 link_up:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700630 u64 autoneg:1;
Raghu Vatsavayi9eb60842016-06-21 22:53:12 -0700631 u64 if_mode:5;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700632 u64 pause:1;
Raghu Vatsavayi9eb60842016-06-21 22:53:12 -0700633 u64 reserved:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700634#else
Raghu Vatsavayi9eb60842016-06-21 22:53:12 -0700635 u64 reserved:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700636 u64 pause:1;
Raghu Vatsavayi9eb60842016-06-21 22:53:12 -0700637 u64 if_mode:5;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700638 u64 autoneg:1;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700639 u64 link_up:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700640 u64 speed:16;
641 u64 mtu:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700642 u64 duplex:8;
643#endif
644 } s;
645};
646
Raghu Vatsavayi26236fa2016-06-14 16:54:44 -0700647/** The txpciq info passed to host from the firmware */
648
649union oct_txpciq {
650 u64 u64;
651
652 struct {
653#ifdef __BIG_ENDIAN_BITFIELD
654 u64 q_no:8;
655 u64 port:8;
656 u64 pkind:6;
657 u64 use_qpg:1;
658 u64 qpg:11;
659 u64 reserved:30;
660#else
661 u64 reserved:30;
662 u64 qpg:11;
663 u64 use_qpg:1;
664 u64 pkind:6;
665 u64 port:8;
666 u64 q_no:8;
667#endif
668 } s;
669};
670
671/** The rxpciq info passed to host from the firmware */
672
673union oct_rxpciq {
674 u64 u64;
675
676 struct {
677#ifdef __BIG_ENDIAN_BITFIELD
678 u64 q_no:8;
679 u64 reserved:56;
680#else
681 u64 reserved:56;
682 u64 q_no:8;
683#endif
684 } s;
685};
686
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700687/** Information for a OCTEON ethernet interface shared between core & host. */
688struct oct_link_info {
689 union oct_link_status link;
690 u64 hw_addr;
691
692#ifdef __BIG_ENDIAN_BITFIELD
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700693 u64 gmxport:16;
694 u64 rsvd:32;
695 u64 num_txpciq:8;
696 u64 num_rxpciq:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700697#else
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700698 u64 num_rxpciq:8;
699 u64 num_txpciq:8;
700 u64 rsvd:32;
701 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700702#endif
703
Raghu Vatsavayi26236fa2016-06-14 16:54:44 -0700704 union oct_txpciq txpciq[MAX_IOQS_PER_NICIF];
705 union oct_rxpciq rxpciq[MAX_IOQS_PER_NICIF];
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700706};
707
708#define OCT_LINK_INFO_SIZE (sizeof(struct oct_link_info))
709
710struct liquidio_if_cfg_info {
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700711 u64 iqmask; /** mask for IQs enabled for the port */
712 u64 oqmask; /** mask for OQs enabled for the port */
713 struct oct_link_info linfo; /** initial link information */
Raghu Vatsavayid3d7e6c2016-06-21 22:53:07 -0700714 char liquidio_firmware_version[32];
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700715};
716
717/** Stats for each NIC port in RX direction. */
718struct nic_rx_stats {
719 /* link-level stats */
720 u64 total_rcvd;
721 u64 bytes_rcvd;
722 u64 total_bcst;
723 u64 total_mcst;
724 u64 runts;
725 u64 ctl_rcvd;
726 u64 fifo_err; /* Accounts for over/under-run of buffers */
727 u64 dmac_drop;
728 u64 fcs_err;
729 u64 jabber_err;
730 u64 l2_err;
731 u64 frame_err;
732
733 /* firmware stats */
734 u64 fw_total_rcvd;
735 u64 fw_total_fwd;
736 u64 fw_err_pko;
737 u64 fw_err_link;
738 u64 fw_err_drop;
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700739
740 /* LRO */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700741 u64 fw_lro_pkts; /* Number of packets that are LROed */
742 u64 fw_lro_octs; /* Number of octets that are LROed */
743 u64 fw_total_lro; /* Number of LRO packets formed */
744 u64 fw_lro_aborts; /* Number of times lRO of packet aborted */
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700745 u64 fw_lro_aborts_port;
746 u64 fw_lro_aborts_seq;
747 u64 fw_lro_aborts_tsval;
748 u64 fw_lro_aborts_timer;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700749 /* intrmod: packet forward rate */
750 u64 fwd_rate;
751};
752
753/** Stats for each NIC port in RX direction. */
754struct nic_tx_stats {
755 /* link-level stats */
756 u64 total_pkts_sent;
757 u64 total_bytes_sent;
758 u64 mcast_pkts_sent;
759 u64 bcast_pkts_sent;
760 u64 ctl_sent;
761 u64 one_collision_sent; /* Packets sent after one collision*/
762 u64 multi_collision_sent; /* Packets sent after multiple collision*/
763 u64 max_collision_fail; /* Packets not sent due to max collisions */
764 u64 max_deferral_fail; /* Packets not sent due to max deferrals */
765 u64 fifo_err; /* Accounts for over/under-run of buffers */
766 u64 runts;
767 u64 total_collisions; /* Total number of collisions detected */
768
769 /* firmware stats */
770 u64 fw_total_sent;
771 u64 fw_total_fwd;
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700772 u64 fw_total_fwd_bytes;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700773 u64 fw_err_pko;
774 u64 fw_err_link;
775 u64 fw_err_drop;
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700776 u64 fw_err_tso;
777 u64 fw_tso; /* number of tso requests */
778 u64 fw_tso_fwd; /* number of packets segmented in tso */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700779};
780
781struct oct_link_stats {
782 struct nic_rx_stats fromwire;
783 struct nic_tx_stats fromhost;
784
785};
786
787#define LIO68XX_LED_CTRL_ADDR 0x3501
788#define LIO68XX_LED_CTRL_CFGON 0x1f
789#define LIO68XX_LED_CTRL_CFGOFF 0x100
790#define LIO68XX_LED_BEACON_ADDR 0x3508
791#define LIO68XX_LED_BEACON_CFGON 0x47fd
792#define LIO68XX_LED_BEACON_CFGOFF 0x11fc
793#define VITESSE_PHY_GPIO_DRIVEON 0x1
794#define VITESSE_PHY_GPIO_CFG 0x8
795#define VITESSE_PHY_GPIO_DRIVEOFF 0x4
796#define VITESSE_PHY_GPIO_HIGH 0x2
797#define VITESSE_PHY_GPIO_LOW 0x3
798
799struct oct_mdio_cmd {
800 u64 op;
801 u64 mdio_addr;
802 u64 value1;
803 u64 value2;
804 u64 value3;
805};
806
807#define OCT_LINK_STATS_SIZE (sizeof(struct oct_link_stats))
808
Raghu Vatsavayi78e6a9b2016-06-21 22:53:10 -0700809/* intrmod: max. packet rate threshold */
810#define LIO_INTRMOD_MAXPKT_RATETHR 196608
811/* intrmod: min. packet rate threshold */
812#define LIO_INTRMOD_MINPKT_RATETHR 9216
813/* intrmod: max. packets to trigger interrupt */
814#define LIO_INTRMOD_RXMAXCNT_TRIGGER 384
815/* intrmod: min. packets to trigger interrupt */
816#define LIO_INTRMOD_RXMINCNT_TRIGGER 1
817/* intrmod: max. time to trigger interrupt */
818#define LIO_INTRMOD_RXMAXTMR_TRIGGER 128
819/* 66xx:intrmod: min. time to trigger interrupt
820 * (value of 1 is optimum for TCP_RR)
821 */
822#define LIO_INTRMOD_RXMINTMR_TRIGGER 1
823
824/* intrmod: max. packets to trigger interrupt */
825#define LIO_INTRMOD_TXMAXCNT_TRIGGER 64
826/* intrmod: min. packets to trigger interrupt */
827#define LIO_INTRMOD_TXMINCNT_TRIGGER 0
828
829/* intrmod: poll interval in seconds */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700830#define LIO_INTRMOD_CHECK_INTERVAL 1
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700831
832struct oct_intrmod_cfg {
Raghu Vatsavayi78e6a9b2016-06-21 22:53:10 -0700833 u64 rx_enable;
834 u64 tx_enable;
835 u64 check_intrvl;
836 u64 maxpkt_ratethr;
837 u64 minpkt_ratethr;
838 u64 rx_maxcnt_trigger;
839 u64 rx_mincnt_trigger;
840 u64 rx_maxtmr_trigger;
841 u64 rx_mintmr_trigger;
842 u64 tx_mincnt_trigger;
843 u64 tx_maxcnt_trigger;
844 u64 rx_frames;
845 u64 tx_frames;
846 u64 rx_usecs;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700847};
848
849#define BASE_QUEUE_NOT_REQUESTED 65535
850
851union oct_nic_if_cfg {
852 u64 u64;
853 struct {
854#ifdef __BIG_ENDIAN_BITFIELD
855 u64 base_queue:16;
856 u64 num_iqueues:16;
857 u64 num_oqueues:16;
858 u64 gmx_port_id:8;
859 u64 reserved:8;
860#else
861 u64 reserved:8;
862 u64 gmx_port_id:8;
863 u64 num_oqueues:16;
864 u64 num_iqueues:16;
865 u64 base_queue:16;
866#endif
867 } s;
868};
869
870#endif