blob: c86421f29a966163fa68982d1552ec63b56ffa0a [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
33#define LIQUIDIO_VERSION "1.1.9"
34#define LIQUIDIO_MAJOR_VERSION 1
35#define LIQUIDIO_MINOR_VERSION 1
36#define LIQUIDIO_MICRO_VERSION 9
37
38#define CONTROL_IQ 0
39/** Tag types used by Octeon cores in its work. */
40enum octeon_tag_type {
41 ORDERED_TAG = 0,
42 ATOMIC_TAG = 1,
43 NULL_TAG = 2,
44 NULL_NULL_TAG = 3
45};
46
47/* pre-defined host->NIC tag values */
48#define LIO_CONTROL (0x11111110)
49#define LIO_DATA(i) (0x11111111 + (i))
50
51/* Opcodes used by host driver/apps to perform operations on the core.
52 * These are used to identify the major subsystem that the operation
53 * is for.
54 */
55#define OPCODE_CORE 0 /* used for generic core operations */
56#define OPCODE_NIC 1 /* used for NIC operations */
57#define OPCODE_LAST OPCODE_NIC
58
59/* Subcodes are used by host driver/apps to identify the sub-operation
60 * for the core. They only need to by unique for a given subsystem.
61 */
62#define OPCODE_SUBCODE(op, sub) (((op & 0x0f) << 8) | ((sub) & 0x7f))
63
64/** OPCODE_CORE subcodes. For future use. */
65
66/** OPCODE_NIC subcodes */
67
68/* This subcode is sent by core PCI driver to indicate cores are ready. */
69#define OPCODE_NIC_CORE_DRV_ACTIVE 0x01
70#define OPCODE_NIC_NW_DATA 0x02 /* network packet data */
71#define OPCODE_NIC_CMD 0x03
72#define OPCODE_NIC_INFO 0x04
73#define OPCODE_NIC_PORT_STATS 0x05
74#define OPCODE_NIC_MDIO45 0x06
75#define OPCODE_NIC_TIMESTAMP 0x07
76#define OPCODE_NIC_INTRMOD_CFG 0x08
77#define OPCODE_NIC_IF_CFG 0x09
78
79#define CORE_DRV_TEST_SCATTER_OP 0xFFF5
80
81#define OPCODE_SLOW_PATH(rh) \
82 (OPCODE_SUBCODE(rh->r.opcode, rh->r.subcode) != \
83 OPCODE_SUBCODE(OPCODE_NIC, OPCODE_NIC_NW_DATA))
84
85/* Application codes advertised by the core driver initialization packet. */
86#define CVM_DRV_APP_START 0x0
87#define CVM_DRV_NO_APP 0
88#define CVM_DRV_APP_COUNT 0x2
89#define CVM_DRV_BASE_APP (CVM_DRV_APP_START + 0x0)
90#define CVM_DRV_NIC_APP (CVM_DRV_APP_START + 0x1)
91#define CVM_DRV_INVALID_APP (CVM_DRV_APP_START + 0x2)
92#define CVM_DRV_APP_END (CVM_DRV_INVALID_APP - 1)
93
94/* Macro to increment index.
95 * Index is incremented by count; if the sum exceeds
96 * max, index is wrapped-around to the start.
97 */
98#define INCR_INDEX(index, count, max) \
99do { \
100 if (((index) + (count)) >= (max)) \
101 index = ((index) + (count)) - (max); \
102 else \
103 index += (count); \
104} while (0)
105
106#define INCR_INDEX_BY1(index, max) \
107do { \
108 if ((++(index)) == (max)) \
109 index = 0; \
110} while (0)
111
112#define DECR_INDEX(index, count, max) \
113do { \
114 if ((count) > (index)) \
115 index = ((max) - ((count - index))); \
116 else \
117 index -= count; \
118} while (0)
119
120#define OCT_BOARD_NAME 32
121#define OCT_SERIAL_LEN 64
122
123/* Structure used by core driver to send indication that the Octeon
124 * application is ready.
125 */
126struct octeon_core_setup {
127 u64 corefreq;
128
129 char boardname[OCT_BOARD_NAME];
130
131 char board_serial_number[OCT_SERIAL_LEN];
132
133 u64 board_rev_major;
134
135 u64 board_rev_minor;
136
137};
138
139/*--------------------------- SCATTER GATHER ENTRY -----------------------*/
140
141/* The Scatter-Gather List Entry. The scatter or gather component used with
142 * a Octeon input instruction has this format.
143 */
144struct octeon_sg_entry {
145 /** The first 64 bit gives the size of data in each dptr.*/
146 union {
147 u16 size[4];
148 u64 size64;
149 } u;
150
151 /** The 4 dptr pointers for this entry. */
152 u64 ptr[4];
153
154};
155
156#define OCT_SG_ENTRY_SIZE (sizeof(struct octeon_sg_entry))
157
158/* \brief Add size to gather list
159 * @param sg_entry scatter/gather entry
160 * @param size size to add
161 * @param pos position to add it.
162 */
163static inline void add_sg_size(struct octeon_sg_entry *sg_entry,
164 u16 size,
165 u32 pos)
166{
167#ifdef __BIG_ENDIAN_BITFIELD
168 sg_entry->u.size[pos] = size;
169#else
170 sg_entry->u.size[3 - pos] = size;
171#endif
172}
173
174/*------------------------- End Scatter/Gather ---------------------------*/
175
176#define OCTNET_FRM_PTP_HEADER_SIZE 8
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700177
Raghu Vatsavayia5b37882016-06-14 16:54:48 -0700178#define OCTNET_FRM_HEADER_SIZE 22 /* VLAN + Ethernet */
179
180#define OCTNET_MIN_FRM_SIZE 64
181
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700182#define OCTNET_MAX_FRM_SIZE (16000 + OCTNET_FRM_HEADER_SIZE)
183
184#define OCTNET_DEFAULT_FRM_SIZE (1500 + OCTNET_FRM_HEADER_SIZE)
185
186/** NIC Commands are sent using this Octeon Input Queue */
187#define OCTNET_CMD_Q 0
188
189/* NIC Command types */
190#define OCTNET_CMD_CHANGE_MTU 0x1
191#define OCTNET_CMD_CHANGE_MACADDR 0x2
192#define OCTNET_CMD_CHANGE_DEVFLAGS 0x3
193#define OCTNET_CMD_RX_CTL 0x4
194
195#define OCTNET_CMD_SET_MULTI_LIST 0x5
196#define OCTNET_CMD_CLEAR_STATS 0x6
197
198/* command for setting the speed, duplex & autoneg */
199#define OCTNET_CMD_SET_SETTINGS 0x7
200#define OCTNET_CMD_SET_FLOW_CTL 0x8
201
202#define OCTNET_CMD_MDIO_READ_WRITE 0x9
203#define OCTNET_CMD_GPIO_ACCESS 0xA
204#define OCTNET_CMD_LRO_ENABLE 0xB
205#define OCTNET_CMD_LRO_DISABLE 0xC
206#define OCTNET_CMD_SET_RSS 0xD
207#define OCTNET_CMD_WRITE_SA 0xE
208#define OCTNET_CMD_DELETE_SA 0xF
209#define OCTNET_CMD_UPDATE_SA 0x12
210
211#define OCTNET_CMD_TNL_RX_CSUM_CTL 0x10
212#define OCTNET_CMD_TNL_TX_CSUM_CTL 0x11
213#define OCTNET_CMD_IPSECV2_AH_ESP_CTL 0x13
214#define OCTNET_CMD_VERBOSE_ENABLE 0x14
215#define OCTNET_CMD_VERBOSE_DISABLE 0x15
216
217/* RX(packets coming from wire) Checksum verification flags */
218/* TCP/UDP csum */
219#define CNNIC_L4SUM_VERIFIED 0x1
220#define CNNIC_IPSUM_VERIFIED 0x2
221#define CNNIC_TUN_CSUM_VERIFIED 0x4
222#define CNNIC_CSUM_VERIFIED (CNNIC_IPSUM_VERIFIED | CNNIC_L4SUM_VERIFIED)
223
224/*LROIPV4 and LROIPV6 Flags*/
225#define OCTNIC_LROIPV4 0x1
226#define OCTNIC_LROIPV6 0x2
227
228/* Interface flags communicated between host driver and core app. */
229enum octnet_ifflags {
230 OCTNET_IFFLAG_PROMISC = 0x01,
231 OCTNET_IFFLAG_ALLMULTI = 0x02,
232 OCTNET_IFFLAG_MULTICAST = 0x04,
233 OCTNET_IFFLAG_BROADCAST = 0x08,
234 OCTNET_IFFLAG_UNICAST = 0x10
235};
236
237/* wqe
238 * --------------- 0
239 * | wqe word0-3 |
240 * --------------- 32
241 * | PCI IH |
242 * --------------- 40
243 * | RPTR |
244 * --------------- 48
245 * | PCI IRH |
246 * --------------- 56
247 * | OCT_NET_CMD |
248 * --------------- 64
249 * | Addtl 8-BData |
250 * | |
251 * ---------------
252 */
253
254union octnet_cmd {
255 u64 u64;
256
257 struct {
258#ifdef __BIG_ENDIAN_BITFIELD
259 u64 cmd:5;
260
261 u64 more:6; /* How many udd words follow the command */
262
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700263 u64 reserved:29;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700264
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700265 u64 param1:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700266
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700267 u64 param2:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700268
269#else
270
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700271 u64 param2:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700272
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700273 u64 param1:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700274
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700275 u64 reserved:29;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700276
277 u64 more:6;
278
279 u64 cmd:5;
280
281#endif
282 } s;
283
284};
285
286#define OCTNET_CMD_SIZE (sizeof(union octnet_cmd))
287
Raghu Vatsavayi6a885b62016-06-14 16:54:51 -0700288/* Instruction Header (DPI - CN23xx) - for OCTEON-III models */
289struct octeon_instr_ih3 {
290#ifdef __BIG_ENDIAN_BITFIELD
291
292 /** Reserved3 */
293 u64 reserved3:1;
294
295 /** Gather indicator 1=gather*/
296 u64 gather:1;
297
298 /** Data length OR no. of entries in gather list */
299 u64 dlengsz:14;
300
301 /** Front Data size */
302 u64 fsz:6;
303
304 /** Reserved2 */
305 u64 reserved2:4;
306
307 /** PKI port kind - PKIND */
308 u64 pkind:6;
309
310 /** Reserved1 */
311 u64 reserved1:32;
312
313#else
314 /** Reserved1 */
315 u64 reserved1:32;
316
317 /** PKI port kind - PKIND */
318 u64 pkind:6;
319
320 /** Reserved2 */
321 u64 reserved2:4;
322
323 /** Front Data size */
324 u64 fsz:6;
325
326 /** Data length OR no. of entries in gather list */
327 u64 dlengsz:14;
328
329 /** Gather indicator 1=gather*/
330 u64 gather:1;
331
332 /** Reserved3 */
333 u64 reserved3:1;
334
335#endif
336};
337
338/* Optional PKI Instruction Header(PKI IH) - for OCTEON CN23XX models */
339/** BIG ENDIAN format. */
340struct octeon_instr_pki_ih3 {
341#ifdef __BIG_ENDIAN_BITFIELD
342
343 /** Wider bit */
344 u64 w:1;
345
346 /** Raw mode indicator 1 = RAW */
347 u64 raw:1;
348
349 /** Use Tag */
350 u64 utag:1;
351
352 /** Use QPG */
353 u64 uqpg:1;
354
355 /** Reserved2 */
356 u64 reserved2:1;
357
358 /** Parse Mode */
359 u64 pm:3;
360
361 /** Skip Length */
362 u64 sl:8;
363
364 /** Use Tag Type */
365 u64 utt:1;
366
367 /** Tag type */
368 u64 tagtype:2;
369
370 /** Reserved1 */
371 u64 reserved1:2;
372
373 /** QPG Value */
374 u64 qpg:11;
375
376 /** Tag Value */
377 u64 tag:32;
378
379#else
380
381 /** Tag Value */
382 u64 tag:32;
383
384 /** QPG Value */
385 u64 qpg:11;
386
387 /** Reserved1 */
388 u64 reserved1:2;
389
390 /** Tag type */
391 u64 tagtype:2;
392
393 /** Use Tag Type */
394 u64 utt:1;
395
396 /** Skip Length */
397 u64 sl:8;
398
399 /** Parse Mode */
400 u64 pm:3;
401
402 /** Reserved2 */
403 u64 reserved2:1;
404
405 /** Use QPG */
406 u64 uqpg:1;
407
408 /** Use Tag */
409 u64 utag:1;
410
411 /** Raw mode indicator 1 = RAW */
412 u64 raw:1;
413
414 /** Wider bit */
415 u64 w:1;
416#endif
417
418};
419
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700420/** Instruction Header */
Raghu Vatsavayi6a885b62016-06-14 16:54:51 -0700421struct octeon_instr_ih2 {
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700422#ifdef __BIG_ENDIAN_BITFIELD
423 /** Raw mode indicator 1 = RAW */
424 u64 raw:1;
425
426 /** Gather indicator 1=gather*/
427 u64 gather:1;
428
429 /** Data length OR no. of entries in gather list */
430 u64 dlengsz:14;
431
432 /** Front Data size */
433 u64 fsz:6;
434
435 /** Packet Order / Work Unit selection (1 of 8)*/
436 u64 qos:3;
437
438 /** Core group selection (1 of 16) */
439 u64 grp:4;
440
441 /** Short Raw Packet Indicator 1=short raw pkt */
442 u64 rs:1;
443
444 /** Tag type */
445 u64 tagtype:2;
446
447 /** Tag Value */
448 u64 tag:32;
449#else
450 /** Tag Value */
451 u64 tag:32;
452
453 /** Tag type */
454 u64 tagtype:2;
455
456 /** Short Raw Packet Indicator 1=short raw pkt */
457 u64 rs:1;
458
459 /** Core group selection (1 of 16) */
460 u64 grp:4;
461
462 /** Packet Order / Work Unit selection (1 of 8)*/
463 u64 qos:3;
464
465 /** Front Data size */
466 u64 fsz:6;
467
468 /** Data length OR no. of entries in gather list */
469 u64 dlengsz:14;
470
471 /** Gather indicator 1=gather*/
472 u64 gather:1;
473
474 /** Raw mode indicator 1 = RAW */
475 u64 raw:1;
476#endif
477};
478
479/** Input Request Header */
480struct octeon_instr_irh {
481#ifdef __BIG_ENDIAN_BITFIELD
482 u64 opcode:4;
483 u64 rflag:1;
484 u64 subcode:7;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700485 u64 vlan:12;
486 u64 priority:3;
487 u64 reserved:5;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700488 u64 ossp:32; /* opcode/subcode specific parameters */
489#else
490 u64 ossp:32; /* opcode/subcode specific parameters */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700491 u64 reserved:5;
492 u64 priority:3;
493 u64 vlan:12;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700494 u64 subcode:7;
495 u64 rflag:1;
496 u64 opcode:4;
497#endif
498};
499
500/** Return Data Parameters */
501struct octeon_instr_rdp {
502#ifdef __BIG_ENDIAN_BITFIELD
503 u64 reserved:49;
504 u64 pcie_port:3;
505 u64 rlen:12;
506#else
507 u64 rlen:12;
508 u64 pcie_port:3;
509 u64 reserved:49;
510#endif
511};
512
513/** Receive Header */
514union octeon_rh {
515#ifdef __BIG_ENDIAN_BITFIELD
516 u64 u64;
517 struct {
518 u64 opcode:4;
519 u64 subcode:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700520 u64 len:3; /** additional 64-bit words */
521 u64 reserved:17;
522 u64 ossp:32; /** opcode/subcode specific parameters */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700523 } r;
524 struct {
525 u64 opcode:4;
526 u64 subcode:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700527 u64 len:3; /** additional 64-bit words */
528 u64 extra:28;
529 u64 vlan:12;
530 u64 priority:3;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700531 u64 csum_verified:3; /** checksum verified. */
532 u64 has_hwtstamp:1; /** Has hardware timestamp. 1 = yes. */
533 } r_dh;
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 reserved:11;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700539 u64 num_gmx_ports:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700540 u64 max_nic_ports:10;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700541 u64 app_cap_flags:4;
542 u64 app_mode:16;
543 } r_core_drv_init;
544 struct {
545 u64 opcode:4;
546 u64 subcode:8;
547 u64 len:3; /** additional 64-bit words */
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700548 u64 reserved:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700549 u64 extra:25;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700550 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700551 } r_nic_info;
552#else
553 u64 u64;
554 struct {
555 u64 ossp:32; /** opcode/subcode specific parameters */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700556 u64 reserved:17;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700557 u64 len:3; /** additional 64-bit words */
558 u64 subcode:8;
559 u64 opcode:4;
560 } r;
561 struct {
562 u64 has_hwtstamp:1; /** 1 = has hwtstamp */
563 u64 csum_verified:3; /** checksum verified. */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700564 u64 priority:3;
565 u64 vlan:12;
566 u64 extra:28;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700567 u64 len:3; /** additional 64-bit words */
568 u64 subcode:8;
569 u64 opcode:4;
570 } r_dh;
571 struct {
572 u64 app_mode:16;
573 u64 app_cap_flags:4;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700574 u64 max_nic_ports:10;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700575 u64 num_gmx_ports:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700576 u64 reserved:11;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700577 u64 len:3; /** additional 64-bit words */
578 u64 subcode:8;
579 u64 opcode:4;
580 } r_core_drv_init;
581 struct {
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700582 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700583 u64 extra:25;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700584 u64 reserved:8;
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_nic_info;
589#endif
590};
591
592#define OCT_RH_SIZE (sizeof(union octeon_rh))
593
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700594union octnic_packet_params {
595 u32 u32;
596 struct {
597#ifdef __BIG_ENDIAN_BITFIELD
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700598 u32 reserved:24;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700599 u32 ip_csum:1; /* Perform IP header checksum(s) */
600 /* Perform Outer transport header checksum */
601 u32 transport_csum:1;
602 /* Find tunnel, and perform transport csum. */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700603 u32 tnl_csum:1;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700604 u32 tsflag:1; /* Timestamp this packet */
605 u32 ipsec_ops:4; /* IPsec operation */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700606#else
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700607 u32 ipsec_ops:4;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700608 u32 tsflag:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700609 u32 tnl_csum:1;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700610 u32 transport_csum:1;
611 u32 ip_csum:1;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700612 u32 reserved:24;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700613#endif
614 } s;
615};
616
617/** Status of a RGMII Link on Octeon as seen by core driver. */
618union oct_link_status {
619 u64 u64;
620
621 struct {
622#ifdef __BIG_ENDIAN_BITFIELD
623 u64 duplex:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700624 u64 mtu:16;
625 u64 speed:16;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700626 u64 link_up:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700627 u64 autoneg:1;
628 u64 interface:4;
629 u64 pause:1;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700630 u64 reserved:17;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700631#else
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700632 u64 reserved:17;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700633 u64 pause:1;
634 u64 interface:4;
635 u64 autoneg:1;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700636 u64 link_up:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700637 u64 speed:16;
638 u64 mtu:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700639 u64 duplex:8;
640#endif
641 } s;
642};
643
Raghu Vatsavayi26236fa2016-06-14 16:54:44 -0700644/** The txpciq info passed to host from the firmware */
645
646union oct_txpciq {
647 u64 u64;
648
649 struct {
650#ifdef __BIG_ENDIAN_BITFIELD
651 u64 q_no:8;
652 u64 port:8;
653 u64 pkind:6;
654 u64 use_qpg:1;
655 u64 qpg:11;
656 u64 reserved:30;
657#else
658 u64 reserved:30;
659 u64 qpg:11;
660 u64 use_qpg:1;
661 u64 pkind:6;
662 u64 port:8;
663 u64 q_no:8;
664#endif
665 } s;
666};
667
668/** The rxpciq info passed to host from the firmware */
669
670union oct_rxpciq {
671 u64 u64;
672
673 struct {
674#ifdef __BIG_ENDIAN_BITFIELD
675 u64 q_no:8;
676 u64 reserved:56;
677#else
678 u64 reserved:56;
679 u64 q_no:8;
680#endif
681 } s;
682};
683
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700684/** Information for a OCTEON ethernet interface shared between core & host. */
685struct oct_link_info {
686 union oct_link_status link;
687 u64 hw_addr;
688
689#ifdef __BIG_ENDIAN_BITFIELD
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700690 u64 gmxport:16;
691 u64 rsvd:32;
692 u64 num_txpciq:8;
693 u64 num_rxpciq:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700694#else
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700695 u64 num_rxpciq:8;
696 u64 num_txpciq:8;
697 u64 rsvd:32;
698 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700699#endif
700
Raghu Vatsavayi26236fa2016-06-14 16:54:44 -0700701 union oct_txpciq txpciq[MAX_IOQS_PER_NICIF];
702 union oct_rxpciq rxpciq[MAX_IOQS_PER_NICIF];
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700703};
704
705#define OCT_LINK_INFO_SIZE (sizeof(struct oct_link_info))
706
707struct liquidio_if_cfg_info {
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700708 u64 iqmask; /** mask for IQs enabled for the port */
709 u64 oqmask; /** mask for OQs enabled for the port */
710 struct oct_link_info linfo; /** initial link information */
711};
712
713/** Stats for each NIC port in RX direction. */
714struct nic_rx_stats {
715 /* link-level stats */
716 u64 total_rcvd;
717 u64 bytes_rcvd;
718 u64 total_bcst;
719 u64 total_mcst;
720 u64 runts;
721 u64 ctl_rcvd;
722 u64 fifo_err; /* Accounts for over/under-run of buffers */
723 u64 dmac_drop;
724 u64 fcs_err;
725 u64 jabber_err;
726 u64 l2_err;
727 u64 frame_err;
728
729 /* firmware stats */
730 u64 fw_total_rcvd;
731 u64 fw_total_fwd;
732 u64 fw_err_pko;
733 u64 fw_err_link;
734 u64 fw_err_drop;
735 u64 fw_lro_pkts; /* Number of packets that are LROed */
736 u64 fw_lro_octs; /* Number of octets that are LROed */
737 u64 fw_total_lro; /* Number of LRO packets formed */
738 u64 fw_lro_aborts; /* Number of times lRO of packet aborted */
739 /* intrmod: packet forward rate */
740 u64 fwd_rate;
741};
742
743/** Stats for each NIC port in RX direction. */
744struct nic_tx_stats {
745 /* link-level stats */
746 u64 total_pkts_sent;
747 u64 total_bytes_sent;
748 u64 mcast_pkts_sent;
749 u64 bcast_pkts_sent;
750 u64 ctl_sent;
751 u64 one_collision_sent; /* Packets sent after one collision*/
752 u64 multi_collision_sent; /* Packets sent after multiple collision*/
753 u64 max_collision_fail; /* Packets not sent due to max collisions */
754 u64 max_deferral_fail; /* Packets not sent due to max deferrals */
755 u64 fifo_err; /* Accounts for over/under-run of buffers */
756 u64 runts;
757 u64 total_collisions; /* Total number of collisions detected */
758
759 /* firmware stats */
760 u64 fw_total_sent;
761 u64 fw_total_fwd;
762 u64 fw_err_pko;
763 u64 fw_err_link;
764 u64 fw_err_drop;
765};
766
767struct oct_link_stats {
768 struct nic_rx_stats fromwire;
769 struct nic_tx_stats fromhost;
770
771};
772
773#define LIO68XX_LED_CTRL_ADDR 0x3501
774#define LIO68XX_LED_CTRL_CFGON 0x1f
775#define LIO68XX_LED_CTRL_CFGOFF 0x100
776#define LIO68XX_LED_BEACON_ADDR 0x3508
777#define LIO68XX_LED_BEACON_CFGON 0x47fd
778#define LIO68XX_LED_BEACON_CFGOFF 0x11fc
779#define VITESSE_PHY_GPIO_DRIVEON 0x1
780#define VITESSE_PHY_GPIO_CFG 0x8
781#define VITESSE_PHY_GPIO_DRIVEOFF 0x4
782#define VITESSE_PHY_GPIO_HIGH 0x2
783#define VITESSE_PHY_GPIO_LOW 0x3
784
785struct oct_mdio_cmd {
786 u64 op;
787 u64 mdio_addr;
788 u64 value1;
789 u64 value2;
790 u64 value3;
791};
792
793#define OCT_LINK_STATS_SIZE (sizeof(struct oct_link_stats))
794
795#define LIO_INTRMOD_CHECK_INTERVAL 1
796#define LIO_INTRMOD_MAXPKT_RATETHR 196608 /* max pkt rate threshold */
797#define LIO_INTRMOD_MINPKT_RATETHR 9216 /* min pkt rate threshold */
798#define LIO_INTRMOD_MAXCNT_TRIGGER 384 /* max pkts to trigger interrupt */
799#define LIO_INTRMOD_MINCNT_TRIGGER 1 /* min pkts to trigger interrupt */
800#define LIO_INTRMOD_MAXTMR_TRIGGER 128 /* max time to trigger interrupt */
801#define LIO_INTRMOD_MINTMR_TRIGGER 32 /* min time to trigger interrupt */
802
803struct oct_intrmod_cfg {
804 u64 intrmod_enable;
805 u64 intrmod_check_intrvl;
806 u64 intrmod_maxpkt_ratethr;
807 u64 intrmod_minpkt_ratethr;
808 u64 intrmod_maxcnt_trigger;
809 u64 intrmod_maxtmr_trigger;
810 u64 intrmod_mincnt_trigger;
811 u64 intrmod_mintmr_trigger;
812};
813
814#define BASE_QUEUE_NOT_REQUESTED 65535
815
816union oct_nic_if_cfg {
817 u64 u64;
818 struct {
819#ifdef __BIG_ENDIAN_BITFIELD
820 u64 base_queue:16;
821 u64 num_iqueues:16;
822 u64 num_oqueues:16;
823 u64 gmx_port_id:8;
824 u64 reserved:8;
825#else
826 u64 reserved:8;
827 u64 gmx_port_id:8;
828 u64 num_oqueues:16;
829 u64 num_iqueues:16;
830 u64 base_queue:16;
831#endif
832 } s;
833};
834
835#endif