blob: 294c6f3c6b48254044c610c78625c9c3c86e9b1f [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
Prasad Kannegantide28c992017-01-09 14:42:40 -0800101#define BYTES_PER_DHLEN_UNIT 8
Satanand Burlacdb478e2017-01-31 13:04:42 -0800102#define MAX_REG_CNT 2000000U
Prasad Kannegantide28c992017-01-09 14:42:40 -0800103
Raghu Vatsavayi97a25322016-11-14 15:54:47 -0800104static inline u32 incr_index(u32 index, u32 count, u32 max)
105{
106 if ((index + count) >= max)
107 index = index + count - max;
108 else
109 index += count;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700110
Raghu Vatsavayi97a25322016-11-14 15:54:47 -0800111 return index;
112}
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700113
114#define OCT_BOARD_NAME 32
115#define OCT_SERIAL_LEN 64
116
117/* Structure used by core driver to send indication that the Octeon
118 * application is ready.
119 */
120struct octeon_core_setup {
121 u64 corefreq;
122
123 char boardname[OCT_BOARD_NAME];
124
125 char board_serial_number[OCT_SERIAL_LEN];
126
127 u64 board_rev_major;
128
129 u64 board_rev_minor;
130
131};
132
133/*--------------------------- SCATTER GATHER ENTRY -----------------------*/
134
135/* The Scatter-Gather List Entry. The scatter or gather component used with
136 * a Octeon input instruction has this format.
137 */
138struct octeon_sg_entry {
139 /** The first 64 bit gives the size of data in each dptr.*/
140 union {
141 u16 size[4];
142 u64 size64;
143 } u;
144
145 /** The 4 dptr pointers for this entry. */
146 u64 ptr[4];
147
148};
149
150#define OCT_SG_ENTRY_SIZE (sizeof(struct octeon_sg_entry))
151
152/* \brief Add size to gather list
153 * @param sg_entry scatter/gather entry
154 * @param size size to add
155 * @param pos position to add it.
156 */
157static inline void add_sg_size(struct octeon_sg_entry *sg_entry,
158 u16 size,
159 u32 pos)
160{
161#ifdef __BIG_ENDIAN_BITFIELD
162 sg_entry->u.size[pos] = size;
163#else
164 sg_entry->u.size[3 - pos] = size;
165#endif
166}
167
168/*------------------------- End Scatter/Gather ---------------------------*/
169
170#define OCTNET_FRM_PTP_HEADER_SIZE 8
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700171
Raghu Vatsavayia5b37882016-06-14 16:54:48 -0700172#define OCTNET_FRM_HEADER_SIZE 22 /* VLAN + Ethernet */
173
174#define OCTNET_MIN_FRM_SIZE 64
175
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700176#define OCTNET_MAX_FRM_SIZE (16000 + OCTNET_FRM_HEADER_SIZE)
177
178#define OCTNET_DEFAULT_FRM_SIZE (1500 + OCTNET_FRM_HEADER_SIZE)
179
180/** NIC Commands are sent using this Octeon Input Queue */
181#define OCTNET_CMD_Q 0
182
183/* NIC Command types */
184#define OCTNET_CMD_CHANGE_MTU 0x1
185#define OCTNET_CMD_CHANGE_MACADDR 0x2
186#define OCTNET_CMD_CHANGE_DEVFLAGS 0x3
187#define OCTNET_CMD_RX_CTL 0x4
188
189#define OCTNET_CMD_SET_MULTI_LIST 0x5
190#define OCTNET_CMD_CLEAR_STATS 0x6
191
192/* command for setting the speed, duplex & autoneg */
193#define OCTNET_CMD_SET_SETTINGS 0x7
194#define OCTNET_CMD_SET_FLOW_CTL 0x8
195
196#define OCTNET_CMD_MDIO_READ_WRITE 0x9
197#define OCTNET_CMD_GPIO_ACCESS 0xA
198#define OCTNET_CMD_LRO_ENABLE 0xB
199#define OCTNET_CMD_LRO_DISABLE 0xC
200#define OCTNET_CMD_SET_RSS 0xD
201#define OCTNET_CMD_WRITE_SA 0xE
202#define OCTNET_CMD_DELETE_SA 0xF
203#define OCTNET_CMD_UPDATE_SA 0x12
204
205#define OCTNET_CMD_TNL_RX_CSUM_CTL 0x10
206#define OCTNET_CMD_TNL_TX_CSUM_CTL 0x11
207#define OCTNET_CMD_IPSECV2_AH_ESP_CTL 0x13
208#define OCTNET_CMD_VERBOSE_ENABLE 0x14
209#define OCTNET_CMD_VERBOSE_DISABLE 0x15
210
Raghu Vatsavayi63245f22016-06-21 22:53:05 -0700211#define OCTNET_CMD_ENABLE_VLAN_FILTER 0x16
212#define OCTNET_CMD_ADD_VLAN_FILTER 0x17
213#define OCTNET_CMD_DEL_VLAN_FILTER 0x18
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700214#define OCTNET_CMD_VXLAN_PORT_CONFIG 0x19
Raghu Vatsavayidc3abcb2016-09-01 11:16:08 -0700215
216#define OCTNET_CMD_ID_ACTIVE 0x1a
217
Raghu Vatsavayi50f7f942016-12-07 08:54:33 -0800218#define OCTNET_CMD_SET_UC_LIST 0x1b
Raghu Vatsavayi86dea552016-11-14 15:54:43 -0800219#define OCTNET_CMD_SET_VF_LINKSTATE 0x1c
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700220#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 Vatsavayi5b823512016-09-01 11:16:07 -0700298/*pkiih3 + irh + ossp[0] + ossp[1] + rdp + rptr = 40 bytes */
299#define LIO_SOFTCMDRESP_IH2 40
300#define LIO_SOFTCMDRESP_IH3 (40 + 8)
301
302#define LIO_PCICMD_O2 24
303#define LIO_PCICMD_O3 (24 + 8)
304
Raghu Vatsavayia2c64b62016-07-03 13:56:55 -0700305/* Instruction Header(DPI) - for OCTEON-III models */
Raghu Vatsavayi6a885b62016-06-14 16:54:51 -0700306struct octeon_instr_ih3 {
307#ifdef __BIG_ENDIAN_BITFIELD
308
309 /** Reserved3 */
310 u64 reserved3:1;
311
312 /** Gather indicator 1=gather*/
313 u64 gather:1;
314
315 /** Data length OR no. of entries in gather list */
316 u64 dlengsz:14;
317
318 /** Front Data size */
319 u64 fsz:6;
320
321 /** Reserved2 */
322 u64 reserved2:4;
323
324 /** PKI port kind - PKIND */
325 u64 pkind:6;
326
327 /** Reserved1 */
328 u64 reserved1:32;
329
330#else
331 /** Reserved1 */
332 u64 reserved1:32;
333
334 /** PKI port kind - PKIND */
335 u64 pkind:6;
336
337 /** Reserved2 */
338 u64 reserved2:4;
339
340 /** Front Data size */
341 u64 fsz:6;
342
343 /** Data length OR no. of entries in gather list */
344 u64 dlengsz:14;
345
346 /** Gather indicator 1=gather*/
347 u64 gather:1;
348
349 /** Reserved3 */
350 u64 reserved3:1;
351
352#endif
353};
354
Raghu Vatsavayia2c64b62016-07-03 13:56:55 -0700355/* Optional PKI Instruction Header(PKI IH) - for OCTEON-III models */
Raghu Vatsavayi6a885b62016-06-14 16:54:51 -0700356/** BIG ENDIAN format. */
357struct octeon_instr_pki_ih3 {
358#ifdef __BIG_ENDIAN_BITFIELD
359
360 /** Wider bit */
361 u64 w:1;
362
363 /** Raw mode indicator 1 = RAW */
364 u64 raw:1;
365
366 /** Use Tag */
367 u64 utag:1;
368
369 /** Use QPG */
370 u64 uqpg:1;
371
372 /** Reserved2 */
373 u64 reserved2:1;
374
375 /** Parse Mode */
376 u64 pm:3;
377
378 /** Skip Length */
379 u64 sl:8;
380
381 /** Use Tag Type */
382 u64 utt:1;
383
384 /** Tag type */
385 u64 tagtype:2;
386
387 /** Reserved1 */
388 u64 reserved1:2;
389
390 /** QPG Value */
391 u64 qpg:11;
392
393 /** Tag Value */
394 u64 tag:32;
395
396#else
397
398 /** Tag Value */
399 u64 tag:32;
400
401 /** QPG Value */
402 u64 qpg:11;
403
404 /** Reserved1 */
405 u64 reserved1:2;
406
407 /** Tag type */
408 u64 tagtype:2;
409
410 /** Use Tag Type */
411 u64 utt:1;
412
413 /** Skip Length */
414 u64 sl:8;
415
416 /** Parse Mode */
417 u64 pm:3;
418
419 /** Reserved2 */
420 u64 reserved2:1;
421
422 /** Use QPG */
423 u64 uqpg:1;
424
425 /** Use Tag */
426 u64 utag:1;
427
428 /** Raw mode indicator 1 = RAW */
429 u64 raw:1;
430
431 /** Wider bit */
432 u64 w:1;
433#endif
434
435};
436
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700437/** Instruction Header */
Raghu Vatsavayi6a885b62016-06-14 16:54:51 -0700438struct octeon_instr_ih2 {
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700439#ifdef __BIG_ENDIAN_BITFIELD
440 /** Raw mode indicator 1 = RAW */
441 u64 raw:1;
442
443 /** Gather indicator 1=gather*/
444 u64 gather:1;
445
446 /** Data length OR no. of entries in gather list */
447 u64 dlengsz:14;
448
449 /** Front Data size */
450 u64 fsz:6;
451
452 /** Packet Order / Work Unit selection (1 of 8)*/
453 u64 qos:3;
454
455 /** Core group selection (1 of 16) */
456 u64 grp:4;
457
458 /** Short Raw Packet Indicator 1=short raw pkt */
459 u64 rs:1;
460
461 /** Tag type */
462 u64 tagtype:2;
463
464 /** Tag Value */
465 u64 tag:32;
466#else
467 /** Tag Value */
468 u64 tag:32;
469
470 /** Tag type */
471 u64 tagtype:2;
472
473 /** Short Raw Packet Indicator 1=short raw pkt */
474 u64 rs:1;
475
476 /** Core group selection (1 of 16) */
477 u64 grp:4;
478
479 /** Packet Order / Work Unit selection (1 of 8)*/
480 u64 qos:3;
481
482 /** Front Data size */
483 u64 fsz:6;
484
485 /** Data length OR no. of entries in gather list */
486 u64 dlengsz:14;
487
488 /** Gather indicator 1=gather*/
489 u64 gather:1;
490
491 /** Raw mode indicator 1 = RAW */
492 u64 raw:1;
493#endif
494};
495
496/** Input Request Header */
497struct octeon_instr_irh {
498#ifdef __BIG_ENDIAN_BITFIELD
499 u64 opcode:4;
500 u64 rflag:1;
501 u64 subcode:7;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700502 u64 vlan:12;
503 u64 priority:3;
504 u64 reserved:5;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700505 u64 ossp:32; /* opcode/subcode specific parameters */
506#else
507 u64 ossp:32; /* opcode/subcode specific parameters */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700508 u64 reserved:5;
509 u64 priority:3;
510 u64 vlan:12;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700511 u64 subcode:7;
512 u64 rflag:1;
513 u64 opcode:4;
514#endif
515};
516
517/** Return Data Parameters */
518struct octeon_instr_rdp {
519#ifdef __BIG_ENDIAN_BITFIELD
520 u64 reserved:49;
521 u64 pcie_port:3;
522 u64 rlen:12;
523#else
524 u64 rlen:12;
525 u64 pcie_port:3;
526 u64 reserved:49;
527#endif
528};
529
530/** Receive Header */
531union octeon_rh {
532#ifdef __BIG_ENDIAN_BITFIELD
533 u64 u64;
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:17;
539 u64 ossp:32; /** opcode/subcode specific parameters */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700540 } r;
541 struct {
542 u64 opcode:4;
543 u64 subcode:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700544 u64 len:3; /** additional 64-bit words */
545 u64 extra:28;
546 u64 vlan:12;
547 u64 priority:3;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700548 u64 csum_verified:3; /** checksum verified. */
549 u64 has_hwtstamp:1; /** Has hardware timestamp. 1 = yes. */
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700550 u64 encap_on:1;
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700551 u64 has_hash:1; /** Has hash (rth or rss). 1 = yes. */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700552 } r_dh;
553 struct {
554 u64 opcode:4;
555 u64 subcode:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700556 u64 len:3; /** additional 64-bit words */
557 u64 reserved:11;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700558 u64 num_gmx_ports:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700559 u64 max_nic_ports:10;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700560 u64 app_cap_flags:4;
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700561 u64 app_mode:8;
562 u64 pkind:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700563 } r_core_drv_init;
564 struct {
565 u64 opcode:4;
566 u64 subcode:8;
567 u64 len:3; /** additional 64-bit words */
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700568 u64 reserved:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700569 u64 extra:25;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700570 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700571 } r_nic_info;
572#else
573 u64 u64;
574 struct {
575 u64 ossp:32; /** opcode/subcode specific parameters */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700576 u64 reserved:17;
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;
581 struct {
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700582 u64 has_hash:1; /** Has hash (rth or rss). 1 = yes. */
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700583 u64 encap_on:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700584 u64 has_hwtstamp:1; /** 1 = has hwtstamp */
585 u64 csum_verified:3; /** checksum verified. */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700586 u64 priority:3;
587 u64 vlan:12;
588 u64 extra:28;
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_dh;
593 struct {
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700594 u64 pkind:8;
595 u64 app_mode:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700596 u64 app_cap_flags:4;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700597 u64 max_nic_ports:10;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700598 u64 num_gmx_ports:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700599 u64 reserved:11;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700600 u64 len:3; /** additional 64-bit words */
601 u64 subcode:8;
602 u64 opcode:4;
603 } r_core_drv_init;
604 struct {
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700605 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700606 u64 extra:25;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700607 u64 reserved:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700608 u64 len:3; /** additional 64-bit words */
609 u64 subcode:8;
610 u64 opcode:4;
611 } r_nic_info;
612#endif
613};
614
615#define OCT_RH_SIZE (sizeof(union octeon_rh))
616
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700617union octnic_packet_params {
618 u32 u32;
619 struct {
620#ifdef __BIG_ENDIAN_BITFIELD
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700621 u32 reserved:24;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700622 u32 ip_csum:1; /* Perform IP header checksum(s) */
623 /* Perform Outer transport header checksum */
624 u32 transport_csum:1;
625 /* Find tunnel, and perform transport csum. */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700626 u32 tnl_csum:1;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700627 u32 tsflag:1; /* Timestamp this packet */
628 u32 ipsec_ops:4; /* IPsec operation */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700629#else
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700630 u32 ipsec_ops:4;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700631 u32 tsflag:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700632 u32 tnl_csum:1;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700633 u32 transport_csum:1;
634 u32 ip_csum:1;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700635 u32 reserved:24;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700636#endif
637 } s;
638};
639
640/** Status of a RGMII Link on Octeon as seen by core driver. */
641union oct_link_status {
642 u64 u64;
643
644 struct {
645#ifdef __BIG_ENDIAN_BITFIELD
646 u64 duplex:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700647 u64 mtu:16;
648 u64 speed:16;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700649 u64 link_up:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700650 u64 autoneg:1;
Raghu Vatsavayi9eb60842016-06-21 22:53:12 -0700651 u64 if_mode:5;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700652 u64 pause:1;
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700653 u64 flashing:1;
654 u64 reserved:15;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700655#else
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700656 u64 reserved:15;
657 u64 flashing:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700658 u64 pause:1;
Raghu Vatsavayi9eb60842016-06-21 22:53:12 -0700659 u64 if_mode:5;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700660 u64 autoneg:1;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700661 u64 link_up:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700662 u64 speed:16;
663 u64 mtu:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700664 u64 duplex:8;
665#endif
666 } s;
667};
668
Raghu Vatsavayi26236fa2016-06-14 16:54:44 -0700669/** The txpciq info passed to host from the firmware */
670
671union oct_txpciq {
672 u64 u64;
673
674 struct {
675#ifdef __BIG_ENDIAN_BITFIELD
676 u64 q_no:8;
677 u64 port:8;
678 u64 pkind:6;
679 u64 use_qpg:1;
680 u64 qpg:11;
681 u64 reserved:30;
682#else
683 u64 reserved:30;
684 u64 qpg:11;
685 u64 use_qpg:1;
686 u64 pkind:6;
687 u64 port:8;
688 u64 q_no:8;
689#endif
690 } s;
691};
692
693/** The rxpciq info passed to host from the firmware */
694
695union oct_rxpciq {
696 u64 u64;
697
698 struct {
699#ifdef __BIG_ENDIAN_BITFIELD
700 u64 q_no:8;
701 u64 reserved:56;
702#else
703 u64 reserved:56;
704 u64 q_no:8;
705#endif
706 } s;
707};
708
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700709/** Information for a OCTEON ethernet interface shared between core & host. */
710struct oct_link_info {
711 union oct_link_status link;
712 u64 hw_addr;
713
714#ifdef __BIG_ENDIAN_BITFIELD
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700715 u64 gmxport:16;
Raghu Vatsavayi8c978d02016-11-14 15:54:41 -0800716 u64 macaddr_is_admin_asgnd:1;
717 u64 rsvd:31;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700718 u64 num_txpciq:8;
719 u64 num_rxpciq:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700720#else
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700721 u64 num_rxpciq:8;
722 u64 num_txpciq:8;
Raghu Vatsavayi8c978d02016-11-14 15:54:41 -0800723 u64 rsvd:31;
724 u64 macaddr_is_admin_asgnd:1;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700725 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700726#endif
727
Raghu Vatsavayi26236fa2016-06-14 16:54:44 -0700728 union oct_txpciq txpciq[MAX_IOQS_PER_NICIF];
729 union oct_rxpciq rxpciq[MAX_IOQS_PER_NICIF];
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700730};
731
732#define OCT_LINK_INFO_SIZE (sizeof(struct oct_link_info))
733
734struct liquidio_if_cfg_info {
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700735 u64 iqmask; /** mask for IQs enabled for the port */
736 u64 oqmask; /** mask for OQs enabled for the port */
737 struct oct_link_info linfo; /** initial link information */
Raghu Vatsavayid3d7e6c2016-06-21 22:53:07 -0700738 char liquidio_firmware_version[32];
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700739};
740
741/** Stats for each NIC port in RX direction. */
742struct nic_rx_stats {
743 /* link-level stats */
744 u64 total_rcvd;
745 u64 bytes_rcvd;
746 u64 total_bcst;
747 u64 total_mcst;
748 u64 runts;
749 u64 ctl_rcvd;
750 u64 fifo_err; /* Accounts for over/under-run of buffers */
751 u64 dmac_drop;
752 u64 fcs_err;
753 u64 jabber_err;
754 u64 l2_err;
755 u64 frame_err;
756
757 /* firmware stats */
758 u64 fw_total_rcvd;
759 u64 fw_total_fwd;
760 u64 fw_err_pko;
761 u64 fw_err_link;
762 u64 fw_err_drop;
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700763 u64 fw_rx_vxlan;
764 u64 fw_rx_vxlan_err;
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700765
766 /* LRO */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700767 u64 fw_lro_pkts; /* Number of packets that are LROed */
768 u64 fw_lro_octs; /* Number of octets that are LROed */
769 u64 fw_total_lro; /* Number of LRO packets formed */
770 u64 fw_lro_aborts; /* Number of times lRO of packet aborted */
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700771 u64 fw_lro_aborts_port;
772 u64 fw_lro_aborts_seq;
773 u64 fw_lro_aborts_tsval;
774 u64 fw_lro_aborts_timer;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700775 /* intrmod: packet forward rate */
776 u64 fwd_rate;
777};
778
779/** Stats for each NIC port in RX direction. */
780struct nic_tx_stats {
781 /* link-level stats */
782 u64 total_pkts_sent;
783 u64 total_bytes_sent;
784 u64 mcast_pkts_sent;
785 u64 bcast_pkts_sent;
786 u64 ctl_sent;
787 u64 one_collision_sent; /* Packets sent after one collision*/
788 u64 multi_collision_sent; /* Packets sent after multiple collision*/
789 u64 max_collision_fail; /* Packets not sent due to max collisions */
790 u64 max_deferral_fail; /* Packets not sent due to max deferrals */
791 u64 fifo_err; /* Accounts for over/under-run of buffers */
792 u64 runts;
793 u64 total_collisions; /* Total number of collisions detected */
794
795 /* firmware stats */
796 u64 fw_total_sent;
797 u64 fw_total_fwd;
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700798 u64 fw_total_fwd_bytes;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700799 u64 fw_err_pko;
800 u64 fw_err_link;
801 u64 fw_err_drop;
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700802 u64 fw_err_tso;
803 u64 fw_tso; /* number of tso requests */
804 u64 fw_tso_fwd; /* number of packets segmented in tso */
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700805 u64 fw_tx_vxlan;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700806};
807
808struct oct_link_stats {
809 struct nic_rx_stats fromwire;
810 struct nic_tx_stats fromhost;
811
812};
813
Raghu Vatsavayi97a25322016-11-14 15:54:47 -0800814static inline int opcode_slow_path(union octeon_rh *rh)
815{
816 u16 subcode1, subcode2;
817
818 subcode1 = OPCODE_SUBCODE((rh)->r.opcode, (rh)->r.subcode);
819 subcode2 = OPCODE_SUBCODE(OPCODE_NIC, OPCODE_NIC_NW_DATA);
820
821 return (subcode2 != subcode1);
822}
823
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700824#define LIO68XX_LED_CTRL_ADDR 0x3501
825#define LIO68XX_LED_CTRL_CFGON 0x1f
826#define LIO68XX_LED_CTRL_CFGOFF 0x100
827#define LIO68XX_LED_BEACON_ADDR 0x3508
828#define LIO68XX_LED_BEACON_CFGON 0x47fd
829#define LIO68XX_LED_BEACON_CFGOFF 0x11fc
830#define VITESSE_PHY_GPIO_DRIVEON 0x1
831#define VITESSE_PHY_GPIO_CFG 0x8
832#define VITESSE_PHY_GPIO_DRIVEOFF 0x4
833#define VITESSE_PHY_GPIO_HIGH 0x2
834#define VITESSE_PHY_GPIO_LOW 0x3
Raghu Vatsavayidc3abcb2016-09-01 11:16:08 -0700835#define LED_IDENTIFICATION_ON 0x1
836#define LED_IDENTIFICATION_OFF 0x0
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700837
838struct oct_mdio_cmd {
839 u64 op;
840 u64 mdio_addr;
841 u64 value1;
842 u64 value2;
843 u64 value3;
844};
845
846#define OCT_LINK_STATS_SIZE (sizeof(struct oct_link_stats))
847
Raghu Vatsavayi78e6a9b2016-06-21 22:53:10 -0700848/* intrmod: max. packet rate threshold */
849#define LIO_INTRMOD_MAXPKT_RATETHR 196608
850/* intrmod: min. packet rate threshold */
851#define LIO_INTRMOD_MINPKT_RATETHR 9216
852/* intrmod: max. packets to trigger interrupt */
853#define LIO_INTRMOD_RXMAXCNT_TRIGGER 384
854/* intrmod: min. packets to trigger interrupt */
Raghu Vatsavayicd8b1eb2016-08-31 11:03:22 -0700855#define LIO_INTRMOD_RXMINCNT_TRIGGER 0
Raghu Vatsavayi78e6a9b2016-06-21 22:53:10 -0700856/* intrmod: max. time to trigger interrupt */
857#define LIO_INTRMOD_RXMAXTMR_TRIGGER 128
858/* 66xx:intrmod: min. time to trigger interrupt
859 * (value of 1 is optimum for TCP_RR)
860 */
861#define LIO_INTRMOD_RXMINTMR_TRIGGER 1
862
863/* intrmod: max. packets to trigger interrupt */
864#define LIO_INTRMOD_TXMAXCNT_TRIGGER 64
865/* intrmod: min. packets to trigger interrupt */
866#define LIO_INTRMOD_TXMINCNT_TRIGGER 0
867
868/* intrmod: poll interval in seconds */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700869#define LIO_INTRMOD_CHECK_INTERVAL 1
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700870
871struct oct_intrmod_cfg {
Raghu Vatsavayi78e6a9b2016-06-21 22:53:10 -0700872 u64 rx_enable;
873 u64 tx_enable;
874 u64 check_intrvl;
875 u64 maxpkt_ratethr;
876 u64 minpkt_ratethr;
877 u64 rx_maxcnt_trigger;
878 u64 rx_mincnt_trigger;
879 u64 rx_maxtmr_trigger;
880 u64 rx_mintmr_trigger;
881 u64 tx_mincnt_trigger;
882 u64 tx_maxcnt_trigger;
883 u64 rx_frames;
884 u64 tx_frames;
885 u64 rx_usecs;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700886};
887
888#define BASE_QUEUE_NOT_REQUESTED 65535
889
890union oct_nic_if_cfg {
891 u64 u64;
892 struct {
893#ifdef __BIG_ENDIAN_BITFIELD
894 u64 base_queue:16;
895 u64 num_iqueues:16;
896 u64 num_oqueues:16;
897 u64 gmx_port_id:8;
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700898 u64 vf_id:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700899#else
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700900 u64 vf_id:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700901 u64 gmx_port_id:8;
902 u64 num_oqueues:16;
903 u64 num_iqueues:16;
904 u64 base_queue:16;
905#endif
906 } s;
907};
908
909#endif