blob: f308ee49a7546aef25ebb6681a324a120f3d679f [file] [log] [blame]
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -07001/**********************************************************************
Raghu Vatsavayi50579d32016-11-14 15:54:46 -08002 * Author: Cavium, Inc.
3 *
4 * Contact: support@cavium.com
5 * Please include "LiquidIO" in the subject.
6 *
7 * Copyright (c) 2003-2016 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 details.
17 ***********************************************************************/
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -070018/*! \file liquidio_common.h
19 * \brief Common: Structures and macros used in PCI-NIC package by core and
20 * host driver.
21 */
22
23#ifndef __LIQUIDIO_COMMON_H__
24#define __LIQUIDIO_COMMON_H__
25
26#include "octeon_config.h"
27
Raghu Vatsavayid3d7e6c2016-06-21 22:53:07 -070028#define LIQUIDIO_PACKAGE ""
Raghu Vatsavayi83101ce2016-08-31 11:03:21 -070029#define LIQUIDIO_BASE_MAJOR_VERSION 1
30#define LIQUIDIO_BASE_MINOR_VERSION 4
31#define LIQUIDIO_BASE_MICRO_VERSION 1
32#define LIQUIDIO_BASE_VERSION __stringify(LIQUIDIO_BASE_MAJOR_VERSION) "." \
33 __stringify(LIQUIDIO_BASE_MINOR_VERSION)
34#define LIQUIDIO_MICRO_VERSION "." __stringify(LIQUIDIO_BASE_MICRO_VERSION)
35#define LIQUIDIO_VERSION LIQUIDIO_PACKAGE \
36 __stringify(LIQUIDIO_BASE_MAJOR_VERSION) "." \
37 __stringify(LIQUIDIO_BASE_MINOR_VERSION) \
38 "." __stringify(LIQUIDIO_BASE_MICRO_VERSION)
39
40struct lio_version {
41 u16 major;
42 u16 minor;
43 u16 micro;
44 u16 reserved;
45};
Raghu Vatsavayia2c64b62016-07-03 13:56:55 -070046
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -070047#define CONTROL_IQ 0
48/** Tag types used by Octeon cores in its work. */
49enum octeon_tag_type {
50 ORDERED_TAG = 0,
51 ATOMIC_TAG = 1,
52 NULL_TAG = 2,
53 NULL_NULL_TAG = 3
54};
55
56/* pre-defined host->NIC tag values */
57#define LIO_CONTROL (0x11111110)
58#define LIO_DATA(i) (0x11111111 + (i))
59
60/* Opcodes used by host driver/apps to perform operations on the core.
61 * These are used to identify the major subsystem that the operation
62 * is for.
63 */
64#define OPCODE_CORE 0 /* used for generic core operations */
65#define OPCODE_NIC 1 /* used for NIC operations */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -070066/* Subcodes are used by host driver/apps to identify the sub-operation
67 * for the core. They only need to by unique for a given subsystem.
68 */
Raghu Vatsavayi97a25322016-11-14 15:54:47 -080069#define OPCODE_SUBCODE(op, sub) ((((op) & 0x0f) << 8) | ((sub) & 0x7f))
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -070070
71/** OPCODE_CORE subcodes. For future use. */
72
73/** OPCODE_NIC subcodes */
74
75/* This subcode is sent by core PCI driver to indicate cores are ready. */
76#define OPCODE_NIC_CORE_DRV_ACTIVE 0x01
77#define OPCODE_NIC_NW_DATA 0x02 /* network packet data */
78#define OPCODE_NIC_CMD 0x03
79#define OPCODE_NIC_INFO 0x04
80#define OPCODE_NIC_PORT_STATS 0x05
81#define OPCODE_NIC_MDIO45 0x06
82#define OPCODE_NIC_TIMESTAMP 0x07
83#define OPCODE_NIC_INTRMOD_CFG 0x08
84#define OPCODE_NIC_IF_CFG 0x09
Raghu Vatsavayi86dea552016-11-14 15:54:43 -080085#define OPCODE_NIC_VF_DRV_NOTICE 0x0A
86#define VF_DRV_LOADED 1
87#define VF_DRV_REMOVED -1
88#define VF_DRV_MACADDR_CHANGED 2
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -070089
90#define CORE_DRV_TEST_SCATTER_OP 0xFFF5
91
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -070092/* Application codes advertised by the core driver initialization packet. */
93#define CVM_DRV_APP_START 0x0
94#define CVM_DRV_NO_APP 0
95#define CVM_DRV_APP_COUNT 0x2
96#define CVM_DRV_BASE_APP (CVM_DRV_APP_START + 0x0)
97#define CVM_DRV_NIC_APP (CVM_DRV_APP_START + 0x1)
98#define CVM_DRV_INVALID_APP (CVM_DRV_APP_START + 0x2)
99#define CVM_DRV_APP_END (CVM_DRV_INVALID_APP - 1)
100
Raghu Vatsavayi97a25322016-11-14 15:54:47 -0800101static inline u32 incr_index(u32 index, u32 count, u32 max)
102{
103 if ((index + count) >= max)
104 index = index + count - max;
105 else
106 index += count;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700107
Raghu Vatsavayi97a25322016-11-14 15:54:47 -0800108 return index;
109}
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700110
111#define OCT_BOARD_NAME 32
112#define OCT_SERIAL_LEN 64
113
114/* Structure used by core driver to send indication that the Octeon
115 * application is ready.
116 */
117struct octeon_core_setup {
118 u64 corefreq;
119
120 char boardname[OCT_BOARD_NAME];
121
122 char board_serial_number[OCT_SERIAL_LEN];
123
124 u64 board_rev_major;
125
126 u64 board_rev_minor;
127
128};
129
130/*--------------------------- SCATTER GATHER ENTRY -----------------------*/
131
132/* The Scatter-Gather List Entry. The scatter or gather component used with
133 * a Octeon input instruction has this format.
134 */
135struct octeon_sg_entry {
136 /** The first 64 bit gives the size of data in each dptr.*/
137 union {
138 u16 size[4];
139 u64 size64;
140 } u;
141
142 /** The 4 dptr pointers for this entry. */
143 u64 ptr[4];
144
145};
146
147#define OCT_SG_ENTRY_SIZE (sizeof(struct octeon_sg_entry))
148
149/* \brief Add size to gather list
150 * @param sg_entry scatter/gather entry
151 * @param size size to add
152 * @param pos position to add it.
153 */
154static inline void add_sg_size(struct octeon_sg_entry *sg_entry,
155 u16 size,
156 u32 pos)
157{
158#ifdef __BIG_ENDIAN_BITFIELD
159 sg_entry->u.size[pos] = size;
160#else
161 sg_entry->u.size[3 - pos] = size;
162#endif
163}
164
165/*------------------------- End Scatter/Gather ---------------------------*/
166
167#define OCTNET_FRM_PTP_HEADER_SIZE 8
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700168
Raghu Vatsavayia5b37882016-06-14 16:54:48 -0700169#define OCTNET_FRM_HEADER_SIZE 22 /* VLAN + Ethernet */
170
171#define OCTNET_MIN_FRM_SIZE 64
172
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700173#define OCTNET_MAX_FRM_SIZE (16000 + OCTNET_FRM_HEADER_SIZE)
174
175#define OCTNET_DEFAULT_FRM_SIZE (1500 + OCTNET_FRM_HEADER_SIZE)
176
177/** NIC Commands are sent using this Octeon Input Queue */
178#define OCTNET_CMD_Q 0
179
180/* NIC Command types */
181#define OCTNET_CMD_CHANGE_MTU 0x1
182#define OCTNET_CMD_CHANGE_MACADDR 0x2
183#define OCTNET_CMD_CHANGE_DEVFLAGS 0x3
184#define OCTNET_CMD_RX_CTL 0x4
185
186#define OCTNET_CMD_SET_MULTI_LIST 0x5
187#define OCTNET_CMD_CLEAR_STATS 0x6
188
189/* command for setting the speed, duplex & autoneg */
190#define OCTNET_CMD_SET_SETTINGS 0x7
191#define OCTNET_CMD_SET_FLOW_CTL 0x8
192
193#define OCTNET_CMD_MDIO_READ_WRITE 0x9
194#define OCTNET_CMD_GPIO_ACCESS 0xA
195#define OCTNET_CMD_LRO_ENABLE 0xB
196#define OCTNET_CMD_LRO_DISABLE 0xC
197#define OCTNET_CMD_SET_RSS 0xD
198#define OCTNET_CMD_WRITE_SA 0xE
199#define OCTNET_CMD_DELETE_SA 0xF
200#define OCTNET_CMD_UPDATE_SA 0x12
201
202#define OCTNET_CMD_TNL_RX_CSUM_CTL 0x10
203#define OCTNET_CMD_TNL_TX_CSUM_CTL 0x11
204#define OCTNET_CMD_IPSECV2_AH_ESP_CTL 0x13
205#define OCTNET_CMD_VERBOSE_ENABLE 0x14
206#define OCTNET_CMD_VERBOSE_DISABLE 0x15
207
Raghu Vatsavayi63245f22016-06-21 22:53:05 -0700208#define OCTNET_CMD_ENABLE_VLAN_FILTER 0x16
209#define OCTNET_CMD_ADD_VLAN_FILTER 0x17
210#define OCTNET_CMD_DEL_VLAN_FILTER 0x18
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700211#define OCTNET_CMD_VXLAN_PORT_CONFIG 0x19
Raghu Vatsavayidc3abcb2016-09-01 11:16:08 -0700212
213#define OCTNET_CMD_ID_ACTIVE 0x1a
214
Raghu Vatsavayi86dea552016-11-14 15:54:43 -0800215#define OCTNET_CMD_SET_VF_LINKSTATE 0x1c
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700216#define OCTNET_CMD_VXLAN_PORT_ADD 0x0
217#define OCTNET_CMD_VXLAN_PORT_DEL 0x1
218#define OCTNET_CMD_RXCSUM_ENABLE 0x0
219#define OCTNET_CMD_RXCSUM_DISABLE 0x1
220#define OCTNET_CMD_TXCSUM_ENABLE 0x0
221#define OCTNET_CMD_TXCSUM_DISABLE 0x1
Raghu Vatsavayi63245f22016-06-21 22:53:05 -0700222
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700223/* RX(packets coming from wire) Checksum verification flags */
224/* TCP/UDP csum */
225#define CNNIC_L4SUM_VERIFIED 0x1
226#define CNNIC_IPSUM_VERIFIED 0x2
227#define CNNIC_TUN_CSUM_VERIFIED 0x4
228#define CNNIC_CSUM_VERIFIED (CNNIC_IPSUM_VERIFIED | CNNIC_L4SUM_VERIFIED)
229
230/*LROIPV4 and LROIPV6 Flags*/
231#define OCTNIC_LROIPV4 0x1
232#define OCTNIC_LROIPV6 0x2
233
234/* Interface flags communicated between host driver and core app. */
235enum octnet_ifflags {
236 OCTNET_IFFLAG_PROMISC = 0x01,
237 OCTNET_IFFLAG_ALLMULTI = 0x02,
238 OCTNET_IFFLAG_MULTICAST = 0x04,
239 OCTNET_IFFLAG_BROADCAST = 0x08,
240 OCTNET_IFFLAG_UNICAST = 0x10
241};
242
243/* wqe
244 * --------------- 0
245 * | wqe word0-3 |
246 * --------------- 32
247 * | PCI IH |
248 * --------------- 40
249 * | RPTR |
250 * --------------- 48
251 * | PCI IRH |
252 * --------------- 56
253 * | OCT_NET_CMD |
254 * --------------- 64
255 * | Addtl 8-BData |
256 * | |
257 * ---------------
258 */
259
260union octnet_cmd {
261 u64 u64;
262
263 struct {
264#ifdef __BIG_ENDIAN_BITFIELD
265 u64 cmd:5;
266
267 u64 more:6; /* How many udd words follow the command */
268
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700269 u64 reserved:29;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700270
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700271 u64 param1:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700272
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700273 u64 param2:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700274
275#else
276
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700277 u64 param2:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700278
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700279 u64 param1:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700280
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700281 u64 reserved:29;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700282
283 u64 more:6;
284
285 u64 cmd:5;
286
287#endif
288 } s;
289
290};
291
292#define OCTNET_CMD_SIZE (sizeof(union octnet_cmd))
293
Raghu Vatsavayi5b823512016-09-01 11:16:07 -0700294/*pkiih3 + irh + ossp[0] + ossp[1] + rdp + rptr = 40 bytes */
295#define LIO_SOFTCMDRESP_IH2 40
296#define LIO_SOFTCMDRESP_IH3 (40 + 8)
297
298#define LIO_PCICMD_O2 24
299#define LIO_PCICMD_O3 (24 + 8)
300
Raghu Vatsavayia2c64b62016-07-03 13:56:55 -0700301/* Instruction Header(DPI) - for OCTEON-III models */
Raghu Vatsavayi6a885b62016-06-14 16:54:51 -0700302struct octeon_instr_ih3 {
303#ifdef __BIG_ENDIAN_BITFIELD
304
305 /** Reserved3 */
306 u64 reserved3:1;
307
308 /** Gather indicator 1=gather*/
309 u64 gather:1;
310
311 /** Data length OR no. of entries in gather list */
312 u64 dlengsz:14;
313
314 /** Front Data size */
315 u64 fsz:6;
316
317 /** Reserved2 */
318 u64 reserved2:4;
319
320 /** PKI port kind - PKIND */
321 u64 pkind:6;
322
323 /** Reserved1 */
324 u64 reserved1:32;
325
326#else
327 /** Reserved1 */
328 u64 reserved1:32;
329
330 /** PKI port kind - PKIND */
331 u64 pkind:6;
332
333 /** Reserved2 */
334 u64 reserved2:4;
335
336 /** Front Data size */
337 u64 fsz:6;
338
339 /** Data length OR no. of entries in gather list */
340 u64 dlengsz:14;
341
342 /** Gather indicator 1=gather*/
343 u64 gather:1;
344
345 /** Reserved3 */
346 u64 reserved3:1;
347
348#endif
349};
350
Raghu Vatsavayia2c64b62016-07-03 13:56:55 -0700351/* Optional PKI Instruction Header(PKI IH) - for OCTEON-III models */
Raghu Vatsavayi6a885b62016-06-14 16:54:51 -0700352/** BIG ENDIAN format. */
353struct octeon_instr_pki_ih3 {
354#ifdef __BIG_ENDIAN_BITFIELD
355
356 /** Wider bit */
357 u64 w:1;
358
359 /** Raw mode indicator 1 = RAW */
360 u64 raw:1;
361
362 /** Use Tag */
363 u64 utag:1;
364
365 /** Use QPG */
366 u64 uqpg:1;
367
368 /** Reserved2 */
369 u64 reserved2:1;
370
371 /** Parse Mode */
372 u64 pm:3;
373
374 /** Skip Length */
375 u64 sl:8;
376
377 /** Use Tag Type */
378 u64 utt:1;
379
380 /** Tag type */
381 u64 tagtype:2;
382
383 /** Reserved1 */
384 u64 reserved1:2;
385
386 /** QPG Value */
387 u64 qpg:11;
388
389 /** Tag Value */
390 u64 tag:32;
391
392#else
393
394 /** Tag Value */
395 u64 tag:32;
396
397 /** QPG Value */
398 u64 qpg:11;
399
400 /** Reserved1 */
401 u64 reserved1:2;
402
403 /** Tag type */
404 u64 tagtype:2;
405
406 /** Use Tag Type */
407 u64 utt:1;
408
409 /** Skip Length */
410 u64 sl:8;
411
412 /** Parse Mode */
413 u64 pm:3;
414
415 /** Reserved2 */
416 u64 reserved2:1;
417
418 /** Use QPG */
419 u64 uqpg:1;
420
421 /** Use Tag */
422 u64 utag:1;
423
424 /** Raw mode indicator 1 = RAW */
425 u64 raw:1;
426
427 /** Wider bit */
428 u64 w:1;
429#endif
430
431};
432
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700433/** Instruction Header */
Raghu Vatsavayi6a885b62016-06-14 16:54:51 -0700434struct octeon_instr_ih2 {
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700435#ifdef __BIG_ENDIAN_BITFIELD
436 /** Raw mode indicator 1 = RAW */
437 u64 raw:1;
438
439 /** Gather indicator 1=gather*/
440 u64 gather:1;
441
442 /** Data length OR no. of entries in gather list */
443 u64 dlengsz:14;
444
445 /** Front Data size */
446 u64 fsz:6;
447
448 /** Packet Order / Work Unit selection (1 of 8)*/
449 u64 qos:3;
450
451 /** Core group selection (1 of 16) */
452 u64 grp:4;
453
454 /** Short Raw Packet Indicator 1=short raw pkt */
455 u64 rs:1;
456
457 /** Tag type */
458 u64 tagtype:2;
459
460 /** Tag Value */
461 u64 tag:32;
462#else
463 /** Tag Value */
464 u64 tag:32;
465
466 /** Tag type */
467 u64 tagtype:2;
468
469 /** Short Raw Packet Indicator 1=short raw pkt */
470 u64 rs:1;
471
472 /** Core group selection (1 of 16) */
473 u64 grp:4;
474
475 /** Packet Order / Work Unit selection (1 of 8)*/
476 u64 qos:3;
477
478 /** Front Data size */
479 u64 fsz:6;
480
481 /** Data length OR no. of entries in gather list */
482 u64 dlengsz:14;
483
484 /** Gather indicator 1=gather*/
485 u64 gather:1;
486
487 /** Raw mode indicator 1 = RAW */
488 u64 raw:1;
489#endif
490};
491
492/** Input Request Header */
493struct octeon_instr_irh {
494#ifdef __BIG_ENDIAN_BITFIELD
495 u64 opcode:4;
496 u64 rflag:1;
497 u64 subcode:7;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700498 u64 vlan:12;
499 u64 priority:3;
500 u64 reserved:5;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700501 u64 ossp:32; /* opcode/subcode specific parameters */
502#else
503 u64 ossp:32; /* opcode/subcode specific parameters */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700504 u64 reserved:5;
505 u64 priority:3;
506 u64 vlan:12;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700507 u64 subcode:7;
508 u64 rflag:1;
509 u64 opcode:4;
510#endif
511};
512
513/** Return Data Parameters */
514struct octeon_instr_rdp {
515#ifdef __BIG_ENDIAN_BITFIELD
516 u64 reserved:49;
517 u64 pcie_port:3;
518 u64 rlen:12;
519#else
520 u64 rlen:12;
521 u64 pcie_port:3;
522 u64 reserved:49;
523#endif
524};
525
526/** Receive Header */
527union octeon_rh {
528#ifdef __BIG_ENDIAN_BITFIELD
529 u64 u64;
530 struct {
531 u64 opcode:4;
532 u64 subcode:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700533 u64 len:3; /** additional 64-bit words */
534 u64 reserved:17;
535 u64 ossp:32; /** opcode/subcode specific parameters */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700536 } r;
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 extra:28;
542 u64 vlan:12;
543 u64 priority:3;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700544 u64 csum_verified:3; /** checksum verified. */
545 u64 has_hwtstamp:1; /** Has hardware timestamp. 1 = yes. */
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700546 u64 encap_on:1;
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700547 u64 has_hash:1; /** Has hash (rth or rss). 1 = yes. */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700548 } r_dh;
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:11;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700554 u64 num_gmx_ports:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700555 u64 max_nic_ports:10;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700556 u64 app_cap_flags:4;
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700557 u64 app_mode:8;
558 u64 pkind:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700559 } r_core_drv_init;
560 struct {
561 u64 opcode:4;
562 u64 subcode:8;
563 u64 len:3; /** additional 64-bit words */
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700564 u64 reserved:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700565 u64 extra:25;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700566 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700567 } r_nic_info;
568#else
569 u64 u64;
570 struct {
571 u64 ossp:32; /** opcode/subcode specific parameters */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700572 u64 reserved:17;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700573 u64 len:3; /** additional 64-bit words */
574 u64 subcode:8;
575 u64 opcode:4;
576 } r;
577 struct {
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700578 u64 has_hash:1; /** Has hash (rth or rss). 1 = yes. */
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700579 u64 encap_on:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700580 u64 has_hwtstamp:1; /** 1 = has hwtstamp */
581 u64 csum_verified:3; /** checksum verified. */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700582 u64 priority:3;
583 u64 vlan:12;
584 u64 extra:28;
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_dh;
589 struct {
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700590 u64 pkind:8;
591 u64 app_mode:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700592 u64 app_cap_flags:4;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700593 u64 max_nic_ports:10;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700594 u64 num_gmx_ports:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700595 u64 reserved:11;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700596 u64 len:3; /** additional 64-bit words */
597 u64 subcode:8;
598 u64 opcode:4;
599 } r_core_drv_init;
600 struct {
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700601 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700602 u64 extra:25;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700603 u64 reserved:8;
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_nic_info;
608#endif
609};
610
611#define OCT_RH_SIZE (sizeof(union octeon_rh))
612
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700613union octnic_packet_params {
614 u32 u32;
615 struct {
616#ifdef __BIG_ENDIAN_BITFIELD
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700617 u32 reserved:24;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700618 u32 ip_csum:1; /* Perform IP header checksum(s) */
619 /* Perform Outer transport header checksum */
620 u32 transport_csum:1;
621 /* Find tunnel, and perform transport csum. */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700622 u32 tnl_csum:1;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700623 u32 tsflag:1; /* Timestamp this packet */
624 u32 ipsec_ops:4; /* IPsec operation */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700625#else
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700626 u32 ipsec_ops:4;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700627 u32 tsflag:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700628 u32 tnl_csum:1;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700629 u32 transport_csum:1;
630 u32 ip_csum:1;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700631 u32 reserved:24;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700632#endif
633 } s;
634};
635
636/** Status of a RGMII Link on Octeon as seen by core driver. */
637union oct_link_status {
638 u64 u64;
639
640 struct {
641#ifdef __BIG_ENDIAN_BITFIELD
642 u64 duplex:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700643 u64 mtu:16;
644 u64 speed:16;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700645 u64 link_up:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700646 u64 autoneg:1;
Raghu Vatsavayi9eb60842016-06-21 22:53:12 -0700647 u64 if_mode:5;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700648 u64 pause:1;
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700649 u64 flashing:1;
650 u64 reserved:15;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700651#else
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700652 u64 reserved:15;
653 u64 flashing:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700654 u64 pause:1;
Raghu Vatsavayi9eb60842016-06-21 22:53:12 -0700655 u64 if_mode:5;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700656 u64 autoneg:1;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700657 u64 link_up:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700658 u64 speed:16;
659 u64 mtu:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700660 u64 duplex:8;
661#endif
662 } s;
663};
664
Raghu Vatsavayi26236fa2016-06-14 16:54:44 -0700665/** The txpciq info passed to host from the firmware */
666
667union oct_txpciq {
668 u64 u64;
669
670 struct {
671#ifdef __BIG_ENDIAN_BITFIELD
672 u64 q_no:8;
673 u64 port:8;
674 u64 pkind:6;
675 u64 use_qpg:1;
676 u64 qpg:11;
677 u64 reserved:30;
678#else
679 u64 reserved:30;
680 u64 qpg:11;
681 u64 use_qpg:1;
682 u64 pkind:6;
683 u64 port:8;
684 u64 q_no:8;
685#endif
686 } s;
687};
688
689/** The rxpciq info passed to host from the firmware */
690
691union oct_rxpciq {
692 u64 u64;
693
694 struct {
695#ifdef __BIG_ENDIAN_BITFIELD
696 u64 q_no:8;
697 u64 reserved:56;
698#else
699 u64 reserved:56;
700 u64 q_no:8;
701#endif
702 } s;
703};
704
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700705/** Information for a OCTEON ethernet interface shared between core & host. */
706struct oct_link_info {
707 union oct_link_status link;
708 u64 hw_addr;
709
710#ifdef __BIG_ENDIAN_BITFIELD
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700711 u64 gmxport:16;
Raghu Vatsavayi8c978d02016-11-14 15:54:41 -0800712 u64 macaddr_is_admin_asgnd:1;
713 u64 rsvd:31;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700714 u64 num_txpciq:8;
715 u64 num_rxpciq:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700716#else
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700717 u64 num_rxpciq:8;
718 u64 num_txpciq:8;
Raghu Vatsavayi8c978d02016-11-14 15:54:41 -0800719 u64 rsvd:31;
720 u64 macaddr_is_admin_asgnd:1;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700721 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700722#endif
723
Raghu Vatsavayi26236fa2016-06-14 16:54:44 -0700724 union oct_txpciq txpciq[MAX_IOQS_PER_NICIF];
725 union oct_rxpciq rxpciq[MAX_IOQS_PER_NICIF];
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700726};
727
728#define OCT_LINK_INFO_SIZE (sizeof(struct oct_link_info))
729
730struct liquidio_if_cfg_info {
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700731 u64 iqmask; /** mask for IQs enabled for the port */
732 u64 oqmask; /** mask for OQs enabled for the port */
733 struct oct_link_info linfo; /** initial link information */
Raghu Vatsavayid3d7e6c2016-06-21 22:53:07 -0700734 char liquidio_firmware_version[32];
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700735};
736
737/** Stats for each NIC port in RX direction. */
738struct nic_rx_stats {
739 /* link-level stats */
740 u64 total_rcvd;
741 u64 bytes_rcvd;
742 u64 total_bcst;
743 u64 total_mcst;
744 u64 runts;
745 u64 ctl_rcvd;
746 u64 fifo_err; /* Accounts for over/under-run of buffers */
747 u64 dmac_drop;
748 u64 fcs_err;
749 u64 jabber_err;
750 u64 l2_err;
751 u64 frame_err;
752
753 /* firmware stats */
754 u64 fw_total_rcvd;
755 u64 fw_total_fwd;
756 u64 fw_err_pko;
757 u64 fw_err_link;
758 u64 fw_err_drop;
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700759 u64 fw_rx_vxlan;
760 u64 fw_rx_vxlan_err;
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700761
762 /* LRO */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700763 u64 fw_lro_pkts; /* Number of packets that are LROed */
764 u64 fw_lro_octs; /* Number of octets that are LROed */
765 u64 fw_total_lro; /* Number of LRO packets formed */
766 u64 fw_lro_aborts; /* Number of times lRO of packet aborted */
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700767 u64 fw_lro_aborts_port;
768 u64 fw_lro_aborts_seq;
769 u64 fw_lro_aborts_tsval;
770 u64 fw_lro_aborts_timer;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700771 /* intrmod: packet forward rate */
772 u64 fwd_rate;
773};
774
775/** Stats for each NIC port in RX direction. */
776struct nic_tx_stats {
777 /* link-level stats */
778 u64 total_pkts_sent;
779 u64 total_bytes_sent;
780 u64 mcast_pkts_sent;
781 u64 bcast_pkts_sent;
782 u64 ctl_sent;
783 u64 one_collision_sent; /* Packets sent after one collision*/
784 u64 multi_collision_sent; /* Packets sent after multiple collision*/
785 u64 max_collision_fail; /* Packets not sent due to max collisions */
786 u64 max_deferral_fail; /* Packets not sent due to max deferrals */
787 u64 fifo_err; /* Accounts for over/under-run of buffers */
788 u64 runts;
789 u64 total_collisions; /* Total number of collisions detected */
790
791 /* firmware stats */
792 u64 fw_total_sent;
793 u64 fw_total_fwd;
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700794 u64 fw_total_fwd_bytes;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700795 u64 fw_err_pko;
796 u64 fw_err_link;
797 u64 fw_err_drop;
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700798 u64 fw_err_tso;
799 u64 fw_tso; /* number of tso requests */
800 u64 fw_tso_fwd; /* number of packets segmented in tso */
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700801 u64 fw_tx_vxlan;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700802};
803
804struct oct_link_stats {
805 struct nic_rx_stats fromwire;
806 struct nic_tx_stats fromhost;
807
808};
809
Raghu Vatsavayi97a25322016-11-14 15:54:47 -0800810static inline int opcode_slow_path(union octeon_rh *rh)
811{
812 u16 subcode1, subcode2;
813
814 subcode1 = OPCODE_SUBCODE((rh)->r.opcode, (rh)->r.subcode);
815 subcode2 = OPCODE_SUBCODE(OPCODE_NIC, OPCODE_NIC_NW_DATA);
816
817 return (subcode2 != subcode1);
818}
819
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700820#define LIO68XX_LED_CTRL_ADDR 0x3501
821#define LIO68XX_LED_CTRL_CFGON 0x1f
822#define LIO68XX_LED_CTRL_CFGOFF 0x100
823#define LIO68XX_LED_BEACON_ADDR 0x3508
824#define LIO68XX_LED_BEACON_CFGON 0x47fd
825#define LIO68XX_LED_BEACON_CFGOFF 0x11fc
826#define VITESSE_PHY_GPIO_DRIVEON 0x1
827#define VITESSE_PHY_GPIO_CFG 0x8
828#define VITESSE_PHY_GPIO_DRIVEOFF 0x4
829#define VITESSE_PHY_GPIO_HIGH 0x2
830#define VITESSE_PHY_GPIO_LOW 0x3
Raghu Vatsavayidc3abcb2016-09-01 11:16:08 -0700831#define LED_IDENTIFICATION_ON 0x1
832#define LED_IDENTIFICATION_OFF 0x0
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700833
834struct oct_mdio_cmd {
835 u64 op;
836 u64 mdio_addr;
837 u64 value1;
838 u64 value2;
839 u64 value3;
840};
841
842#define OCT_LINK_STATS_SIZE (sizeof(struct oct_link_stats))
843
Raghu Vatsavayi78e6a9b2016-06-21 22:53:10 -0700844/* intrmod: max. packet rate threshold */
845#define LIO_INTRMOD_MAXPKT_RATETHR 196608
846/* intrmod: min. packet rate threshold */
847#define LIO_INTRMOD_MINPKT_RATETHR 9216
848/* intrmod: max. packets to trigger interrupt */
849#define LIO_INTRMOD_RXMAXCNT_TRIGGER 384
850/* intrmod: min. packets to trigger interrupt */
Raghu Vatsavayicd8b1eb2016-08-31 11:03:22 -0700851#define LIO_INTRMOD_RXMINCNT_TRIGGER 0
Raghu Vatsavayi78e6a9b2016-06-21 22:53:10 -0700852/* intrmod: max. time to trigger interrupt */
853#define LIO_INTRMOD_RXMAXTMR_TRIGGER 128
854/* 66xx:intrmod: min. time to trigger interrupt
855 * (value of 1 is optimum for TCP_RR)
856 */
857#define LIO_INTRMOD_RXMINTMR_TRIGGER 1
858
859/* intrmod: max. packets to trigger interrupt */
860#define LIO_INTRMOD_TXMAXCNT_TRIGGER 64
861/* intrmod: min. packets to trigger interrupt */
862#define LIO_INTRMOD_TXMINCNT_TRIGGER 0
863
864/* intrmod: poll interval in seconds */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700865#define LIO_INTRMOD_CHECK_INTERVAL 1
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700866
867struct oct_intrmod_cfg {
Raghu Vatsavayi78e6a9b2016-06-21 22:53:10 -0700868 u64 rx_enable;
869 u64 tx_enable;
870 u64 check_intrvl;
871 u64 maxpkt_ratethr;
872 u64 minpkt_ratethr;
873 u64 rx_maxcnt_trigger;
874 u64 rx_mincnt_trigger;
875 u64 rx_maxtmr_trigger;
876 u64 rx_mintmr_trigger;
877 u64 tx_mincnt_trigger;
878 u64 tx_maxcnt_trigger;
879 u64 rx_frames;
880 u64 tx_frames;
881 u64 rx_usecs;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700882};
883
884#define BASE_QUEUE_NOT_REQUESTED 65535
885
886union oct_nic_if_cfg {
887 u64 u64;
888 struct {
889#ifdef __BIG_ENDIAN_BITFIELD
890 u64 base_queue:16;
891 u64 num_iqueues:16;
892 u64 num_oqueues:16;
893 u64 gmx_port_id:8;
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700894 u64 vf_id:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700895#else
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700896 u64 vf_id:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700897 u64 gmx_port_id:8;
898 u64 num_oqueues:16;
899 u64 num_iqueues:16;
900 u64 base_queue:16;
901#endif
902 } s;
903};
904
905#endif