blob: d03f5296f33e8135f44496bfc69a27c3eec94c48 [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
Prasad Kanneganti50c0add2017-03-28 12:14:06 -070030#define LIQUIDIO_BASE_MINOR_VERSION 5
Raghu Vatsavayi83101ce2016-08-31 11:03:21 -070031#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
Prasad Kanneganti50c0add2017-03-28 12:14:06 -070086#define OPCODE_NIC_INTRMOD_PARAMS 0x0B
Raghu Vatsavayi86dea552016-11-14 15:54:43 -080087#define VF_DRV_LOADED 1
88#define VF_DRV_REMOVED -1
89#define VF_DRV_MACADDR_CHANGED 2
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -070090
91#define CORE_DRV_TEST_SCATTER_OP 0xFFF5
92
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -070093/* Application codes advertised by the core driver initialization packet. */
94#define CVM_DRV_APP_START 0x0
95#define CVM_DRV_NO_APP 0
96#define CVM_DRV_APP_COUNT 0x2
97#define CVM_DRV_BASE_APP (CVM_DRV_APP_START + 0x0)
98#define CVM_DRV_NIC_APP (CVM_DRV_APP_START + 0x1)
99#define CVM_DRV_INVALID_APP (CVM_DRV_APP_START + 0x2)
100#define CVM_DRV_APP_END (CVM_DRV_INVALID_APP - 1)
101
Prasad Kannegantide28c992017-01-09 14:42:40 -0800102#define BYTES_PER_DHLEN_UNIT 8
Satanand Burlacdb478e2017-01-31 13:04:42 -0800103#define MAX_REG_CNT 2000000U
Rick Farrington0c88a762017-03-13 12:58:04 -0700104#define INTRNAMSIZ 32
105#define IRQ_NAME_OFF(i) ((i) * INTRNAMSIZ)
106#define MAX_IOQ_INTERRUPTS_PER_PF (64 * 2)
107#define MAX_IOQ_INTERRUPTS_PER_VF (8 * 2)
108
Prasad Kannegantide28c992017-01-09 14:42:40 -0800109
Raghu Vatsavayi97a25322016-11-14 15:54:47 -0800110static inline u32 incr_index(u32 index, u32 count, u32 max)
111{
112 if ((index + count) >= max)
113 index = index + count - max;
114 else
115 index += count;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700116
Raghu Vatsavayi97a25322016-11-14 15:54:47 -0800117 return index;
118}
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700119
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 */
Felix Manlunas7cc61db2017-03-23 13:26:28 -0700190#define OCTNET_CMD_RESET_PF 0x0
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700191#define OCTNET_CMD_CHANGE_MTU 0x1
192#define OCTNET_CMD_CHANGE_MACADDR 0x2
193#define OCTNET_CMD_CHANGE_DEVFLAGS 0x3
194#define OCTNET_CMD_RX_CTL 0x4
195
196#define OCTNET_CMD_SET_MULTI_LIST 0x5
197#define OCTNET_CMD_CLEAR_STATS 0x6
198
199/* command for setting the speed, duplex & autoneg */
200#define OCTNET_CMD_SET_SETTINGS 0x7
201#define OCTNET_CMD_SET_FLOW_CTL 0x8
202
203#define OCTNET_CMD_MDIO_READ_WRITE 0x9
204#define OCTNET_CMD_GPIO_ACCESS 0xA
205#define OCTNET_CMD_LRO_ENABLE 0xB
206#define OCTNET_CMD_LRO_DISABLE 0xC
207#define OCTNET_CMD_SET_RSS 0xD
208#define OCTNET_CMD_WRITE_SA 0xE
209#define OCTNET_CMD_DELETE_SA 0xF
210#define OCTNET_CMD_UPDATE_SA 0x12
211
212#define OCTNET_CMD_TNL_RX_CSUM_CTL 0x10
213#define OCTNET_CMD_TNL_TX_CSUM_CTL 0x11
214#define OCTNET_CMD_IPSECV2_AH_ESP_CTL 0x13
215#define OCTNET_CMD_VERBOSE_ENABLE 0x14
216#define OCTNET_CMD_VERBOSE_DISABLE 0x15
217
Prasad Kanneganti836d57e2017-06-18 12:41:34 -0700218#define OCTNET_CMD_VLAN_FILTER_CTL 0x16
Raghu Vatsavayi63245f22016-06-21 22:53:05 -0700219#define OCTNET_CMD_ADD_VLAN_FILTER 0x17
220#define OCTNET_CMD_DEL_VLAN_FILTER 0x18
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700221#define OCTNET_CMD_VXLAN_PORT_CONFIG 0x19
Raghu Vatsavayidc3abcb2016-09-01 11:16:08 -0700222
223#define OCTNET_CMD_ID_ACTIVE 0x1a
224
Raghu Vatsavayi50f7f942016-12-07 08:54:33 -0800225#define OCTNET_CMD_SET_UC_LIST 0x1b
Raghu Vatsavayi86dea552016-11-14 15:54:43 -0800226#define OCTNET_CMD_SET_VF_LINKSTATE 0x1c
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700227#define OCTNET_CMD_VXLAN_PORT_ADD 0x0
228#define OCTNET_CMD_VXLAN_PORT_DEL 0x1
229#define OCTNET_CMD_RXCSUM_ENABLE 0x0
230#define OCTNET_CMD_RXCSUM_DISABLE 0x1
231#define OCTNET_CMD_TXCSUM_ENABLE 0x0
232#define OCTNET_CMD_TXCSUM_DISABLE 0x1
Prasad Kanneganti836d57e2017-06-18 12:41:34 -0700233#define OCTNET_CMD_VLAN_FILTER_ENABLE 0x1
234#define OCTNET_CMD_VLAN_FILTER_DISABLE 0x0
Raghu Vatsavayi63245f22016-06-21 22:53:05 -0700235
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700236/* RX(packets coming from wire) Checksum verification flags */
237/* TCP/UDP csum */
238#define CNNIC_L4SUM_VERIFIED 0x1
239#define CNNIC_IPSUM_VERIFIED 0x2
240#define CNNIC_TUN_CSUM_VERIFIED 0x4
241#define CNNIC_CSUM_VERIFIED (CNNIC_IPSUM_VERIFIED | CNNIC_L4SUM_VERIFIED)
242
243/*LROIPV4 and LROIPV6 Flags*/
244#define OCTNIC_LROIPV4 0x1
245#define OCTNIC_LROIPV6 0x2
246
247/* Interface flags communicated between host driver and core app. */
248enum octnet_ifflags {
249 OCTNET_IFFLAG_PROMISC = 0x01,
250 OCTNET_IFFLAG_ALLMULTI = 0x02,
251 OCTNET_IFFLAG_MULTICAST = 0x04,
252 OCTNET_IFFLAG_BROADCAST = 0x08,
253 OCTNET_IFFLAG_UNICAST = 0x10
254};
255
256/* wqe
257 * --------------- 0
258 * | wqe word0-3 |
259 * --------------- 32
260 * | PCI IH |
261 * --------------- 40
262 * | RPTR |
263 * --------------- 48
264 * | PCI IRH |
265 * --------------- 56
266 * | OCT_NET_CMD |
267 * --------------- 64
268 * | Addtl 8-BData |
269 * | |
270 * ---------------
271 */
272
273union octnet_cmd {
274 u64 u64;
275
276 struct {
277#ifdef __BIG_ENDIAN_BITFIELD
278 u64 cmd:5;
279
280 u64 more:6; /* How many udd words follow the command */
281
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700282 u64 reserved:29;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700283
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700284 u64 param1:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700285
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700286 u64 param2:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700287
288#else
289
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700290 u64 param2:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700291
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700292 u64 param1:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700293
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700294 u64 reserved:29;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700295
296 u64 more:6;
297
298 u64 cmd:5;
299
300#endif
301 } s;
302
303};
304
305#define OCTNET_CMD_SIZE (sizeof(union octnet_cmd))
306
Raghu Vatsavayi5b823512016-09-01 11:16:07 -0700307/*pkiih3 + irh + ossp[0] + ossp[1] + rdp + rptr = 40 bytes */
308#define LIO_SOFTCMDRESP_IH2 40
309#define LIO_SOFTCMDRESP_IH3 (40 + 8)
310
311#define LIO_PCICMD_O2 24
312#define LIO_PCICMD_O3 (24 + 8)
313
Raghu Vatsavayia2c64b62016-07-03 13:56:55 -0700314/* Instruction Header(DPI) - for OCTEON-III models */
Raghu Vatsavayi6a885b62016-06-14 16:54:51 -0700315struct octeon_instr_ih3 {
316#ifdef __BIG_ENDIAN_BITFIELD
317
318 /** Reserved3 */
319 u64 reserved3:1;
320
321 /** Gather indicator 1=gather*/
322 u64 gather:1;
323
324 /** Data length OR no. of entries in gather list */
325 u64 dlengsz:14;
326
327 /** Front Data size */
328 u64 fsz:6;
329
330 /** Reserved2 */
331 u64 reserved2:4;
332
333 /** PKI port kind - PKIND */
334 u64 pkind:6;
335
336 /** Reserved1 */
337 u64 reserved1:32;
338
339#else
340 /** Reserved1 */
341 u64 reserved1:32;
342
343 /** PKI port kind - PKIND */
344 u64 pkind:6;
345
346 /** Reserved2 */
347 u64 reserved2:4;
348
349 /** Front Data size */
350 u64 fsz:6;
351
352 /** Data length OR no. of entries in gather list */
353 u64 dlengsz:14;
354
355 /** Gather indicator 1=gather*/
356 u64 gather:1;
357
358 /** Reserved3 */
359 u64 reserved3:1;
360
361#endif
362};
363
Raghu Vatsavayia2c64b62016-07-03 13:56:55 -0700364/* Optional PKI Instruction Header(PKI IH) - for OCTEON-III models */
Raghu Vatsavayi6a885b62016-06-14 16:54:51 -0700365/** BIG ENDIAN format. */
366struct octeon_instr_pki_ih3 {
367#ifdef __BIG_ENDIAN_BITFIELD
368
369 /** Wider bit */
370 u64 w:1;
371
372 /** Raw mode indicator 1 = RAW */
373 u64 raw:1;
374
375 /** Use Tag */
376 u64 utag:1;
377
378 /** Use QPG */
379 u64 uqpg:1;
380
381 /** Reserved2 */
382 u64 reserved2:1;
383
384 /** Parse Mode */
385 u64 pm:3;
386
387 /** Skip Length */
388 u64 sl:8;
389
390 /** Use Tag Type */
391 u64 utt:1;
392
393 /** Tag type */
394 u64 tagtype:2;
395
396 /** Reserved1 */
397 u64 reserved1:2;
398
399 /** QPG Value */
400 u64 qpg:11;
401
402 /** Tag Value */
403 u64 tag:32;
404
405#else
406
407 /** Tag Value */
408 u64 tag:32;
409
410 /** QPG Value */
411 u64 qpg:11;
412
413 /** Reserved1 */
414 u64 reserved1:2;
415
416 /** Tag type */
417 u64 tagtype:2;
418
419 /** Use Tag Type */
420 u64 utt:1;
421
422 /** Skip Length */
423 u64 sl:8;
424
425 /** Parse Mode */
426 u64 pm:3;
427
428 /** Reserved2 */
429 u64 reserved2:1;
430
431 /** Use QPG */
432 u64 uqpg:1;
433
434 /** Use Tag */
435 u64 utag:1;
436
437 /** Raw mode indicator 1 = RAW */
438 u64 raw:1;
439
440 /** Wider bit */
441 u64 w:1;
442#endif
443
444};
445
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700446/** Instruction Header */
Raghu Vatsavayi6a885b62016-06-14 16:54:51 -0700447struct octeon_instr_ih2 {
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700448#ifdef __BIG_ENDIAN_BITFIELD
449 /** Raw mode indicator 1 = RAW */
450 u64 raw:1;
451
452 /** Gather indicator 1=gather*/
453 u64 gather:1;
454
455 /** Data length OR no. of entries in gather list */
456 u64 dlengsz:14;
457
458 /** Front Data size */
459 u64 fsz:6;
460
461 /** Packet Order / Work Unit selection (1 of 8)*/
462 u64 qos:3;
463
464 /** Core group selection (1 of 16) */
465 u64 grp:4;
466
467 /** Short Raw Packet Indicator 1=short raw pkt */
468 u64 rs:1;
469
470 /** Tag type */
471 u64 tagtype:2;
472
473 /** Tag Value */
474 u64 tag:32;
475#else
476 /** Tag Value */
477 u64 tag:32;
478
479 /** Tag type */
480 u64 tagtype:2;
481
482 /** Short Raw Packet Indicator 1=short raw pkt */
483 u64 rs:1;
484
485 /** Core group selection (1 of 16) */
486 u64 grp:4;
487
488 /** Packet Order / Work Unit selection (1 of 8)*/
489 u64 qos:3;
490
491 /** Front Data size */
492 u64 fsz:6;
493
494 /** Data length OR no. of entries in gather list */
495 u64 dlengsz:14;
496
497 /** Gather indicator 1=gather*/
498 u64 gather:1;
499
500 /** Raw mode indicator 1 = RAW */
501 u64 raw:1;
502#endif
503};
504
505/** Input Request Header */
506struct octeon_instr_irh {
507#ifdef __BIG_ENDIAN_BITFIELD
508 u64 opcode:4;
509 u64 rflag:1;
510 u64 subcode:7;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700511 u64 vlan:12;
512 u64 priority:3;
513 u64 reserved:5;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700514 u64 ossp:32; /* opcode/subcode specific parameters */
515#else
516 u64 ossp:32; /* opcode/subcode specific parameters */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700517 u64 reserved:5;
518 u64 priority:3;
519 u64 vlan:12;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700520 u64 subcode:7;
521 u64 rflag:1;
522 u64 opcode:4;
523#endif
524};
525
526/** Return Data Parameters */
527struct octeon_instr_rdp {
528#ifdef __BIG_ENDIAN_BITFIELD
529 u64 reserved:49;
530 u64 pcie_port:3;
531 u64 rlen:12;
532#else
533 u64 rlen:12;
534 u64 pcie_port:3;
535 u64 reserved:49;
536#endif
537};
538
539/** Receive Header */
540union octeon_rh {
541#ifdef __BIG_ENDIAN_BITFIELD
542 u64 u64;
543 struct {
544 u64 opcode:4;
545 u64 subcode:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700546 u64 len:3; /** additional 64-bit words */
547 u64 reserved:17;
548 u64 ossp:32; /** opcode/subcode specific parameters */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700549 } r;
550 struct {
551 u64 opcode:4;
552 u64 subcode:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700553 u64 len:3; /** additional 64-bit words */
554 u64 extra:28;
555 u64 vlan:12;
556 u64 priority:3;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700557 u64 csum_verified:3; /** checksum verified. */
558 u64 has_hwtstamp:1; /** Has hardware timestamp. 1 = yes. */
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700559 u64 encap_on:1;
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700560 u64 has_hash:1; /** Has hash (rth or rss). 1 = yes. */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700561 } r_dh;
562 struct {
563 u64 opcode:4;
564 u64 subcode:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700565 u64 len:3; /** additional 64-bit words */
566 u64 reserved:11;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700567 u64 num_gmx_ports:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700568 u64 max_nic_ports:10;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700569 u64 app_cap_flags:4;
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700570 u64 app_mode:8;
571 u64 pkind:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700572 } r_core_drv_init;
573 struct {
574 u64 opcode:4;
575 u64 subcode:8;
576 u64 len:3; /** additional 64-bit words */
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700577 u64 reserved:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700578 u64 extra:25;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700579 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700580 } r_nic_info;
581#else
582 u64 u64;
583 struct {
584 u64 ossp:32; /** opcode/subcode specific parameters */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700585 u64 reserved:17;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700586 u64 len:3; /** additional 64-bit words */
587 u64 subcode:8;
588 u64 opcode:4;
589 } r;
590 struct {
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700591 u64 has_hash:1; /** Has hash (rth or rss). 1 = yes. */
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700592 u64 encap_on:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700593 u64 has_hwtstamp:1; /** 1 = has hwtstamp */
594 u64 csum_verified:3; /** checksum verified. */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700595 u64 priority:3;
596 u64 vlan:12;
597 u64 extra:28;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700598 u64 len:3; /** additional 64-bit words */
599 u64 subcode:8;
600 u64 opcode:4;
601 } r_dh;
602 struct {
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700603 u64 pkind:8;
604 u64 app_mode:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700605 u64 app_cap_flags:4;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700606 u64 max_nic_ports:10;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700607 u64 num_gmx_ports:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700608 u64 reserved:11;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700609 u64 len:3; /** additional 64-bit words */
610 u64 subcode:8;
611 u64 opcode:4;
612 } r_core_drv_init;
613 struct {
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700614 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700615 u64 extra:25;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700616 u64 reserved:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700617 u64 len:3; /** additional 64-bit words */
618 u64 subcode:8;
619 u64 opcode:4;
620 } r_nic_info;
621#endif
622};
623
624#define OCT_RH_SIZE (sizeof(union octeon_rh))
625
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700626union octnic_packet_params {
627 u32 u32;
628 struct {
629#ifdef __BIG_ENDIAN_BITFIELD
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700630 u32 reserved:24;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700631 u32 ip_csum:1; /* Perform IP header checksum(s) */
632 /* Perform Outer transport header checksum */
633 u32 transport_csum:1;
634 /* Find tunnel, and perform transport csum. */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700635 u32 tnl_csum:1;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700636 u32 tsflag:1; /* Timestamp this packet */
637 u32 ipsec_ops:4; /* IPsec operation */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700638#else
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700639 u32 ipsec_ops:4;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700640 u32 tsflag:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700641 u32 tnl_csum:1;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700642 u32 transport_csum:1;
643 u32 ip_csum:1;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700644 u32 reserved:24;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700645#endif
646 } s;
647};
648
649/** Status of a RGMII Link on Octeon as seen by core driver. */
650union oct_link_status {
651 u64 u64;
652
653 struct {
654#ifdef __BIG_ENDIAN_BITFIELD
655 u64 duplex:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700656 u64 mtu:16;
657 u64 speed:16;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700658 u64 link_up:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700659 u64 autoneg:1;
Raghu Vatsavayi9eb60842016-06-21 22:53:12 -0700660 u64 if_mode:5;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700661 u64 pause:1;
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700662 u64 flashing:1;
663 u64 reserved:15;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700664#else
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700665 u64 reserved:15;
666 u64 flashing:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700667 u64 pause:1;
Raghu Vatsavayi9eb60842016-06-21 22:53:12 -0700668 u64 if_mode:5;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700669 u64 autoneg:1;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700670 u64 link_up:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700671 u64 speed:16;
672 u64 mtu:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700673 u64 duplex:8;
674#endif
675 } s;
676};
677
Raghu Vatsavayi26236fa2016-06-14 16:54:44 -0700678/** The txpciq info passed to host from the firmware */
679
680union oct_txpciq {
681 u64 u64;
682
683 struct {
684#ifdef __BIG_ENDIAN_BITFIELD
685 u64 q_no:8;
686 u64 port:8;
687 u64 pkind:6;
688 u64 use_qpg:1;
689 u64 qpg:11;
690 u64 reserved:30;
691#else
692 u64 reserved:30;
693 u64 qpg:11;
694 u64 use_qpg:1;
695 u64 pkind:6;
696 u64 port:8;
697 u64 q_no:8;
698#endif
699 } s;
700};
701
702/** The rxpciq info passed to host from the firmware */
703
704union oct_rxpciq {
705 u64 u64;
706
707 struct {
708#ifdef __BIG_ENDIAN_BITFIELD
709 u64 q_no:8;
710 u64 reserved:56;
711#else
712 u64 reserved:56;
713 u64 q_no:8;
714#endif
715 } s;
716};
717
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700718/** Information for a OCTEON ethernet interface shared between core & host. */
719struct oct_link_info {
720 union oct_link_status link;
721 u64 hw_addr;
722
723#ifdef __BIG_ENDIAN_BITFIELD
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700724 u64 gmxport:16;
Raghu Vatsavayi8c978d02016-11-14 15:54:41 -0800725 u64 macaddr_is_admin_asgnd:1;
726 u64 rsvd:31;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700727 u64 num_txpciq:8;
728 u64 num_rxpciq:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700729#else
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700730 u64 num_rxpciq:8;
731 u64 num_txpciq:8;
Raghu Vatsavayi8c978d02016-11-14 15:54:41 -0800732 u64 rsvd:31;
733 u64 macaddr_is_admin_asgnd:1;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700734 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700735#endif
736
Raghu Vatsavayi26236fa2016-06-14 16:54:44 -0700737 union oct_txpciq txpciq[MAX_IOQS_PER_NICIF];
738 union oct_rxpciq rxpciq[MAX_IOQS_PER_NICIF];
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700739};
740
741#define OCT_LINK_INFO_SIZE (sizeof(struct oct_link_info))
742
743struct liquidio_if_cfg_info {
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700744 u64 iqmask; /** mask for IQs enabled for the port */
745 u64 oqmask; /** mask for OQs enabled for the port */
746 struct oct_link_info linfo; /** initial link information */
Raghu Vatsavayid3d7e6c2016-06-21 22:53:07 -0700747 char liquidio_firmware_version[32];
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700748};
749
750/** Stats for each NIC port in RX direction. */
751struct nic_rx_stats {
752 /* link-level stats */
753 u64 total_rcvd;
754 u64 bytes_rcvd;
755 u64 total_bcst;
756 u64 total_mcst;
757 u64 runts;
758 u64 ctl_rcvd;
759 u64 fifo_err; /* Accounts for over/under-run of buffers */
760 u64 dmac_drop;
761 u64 fcs_err;
762 u64 jabber_err;
763 u64 l2_err;
764 u64 frame_err;
765
766 /* firmware stats */
767 u64 fw_total_rcvd;
768 u64 fw_total_fwd;
769 u64 fw_err_pko;
770 u64 fw_err_link;
771 u64 fw_err_drop;
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700772 u64 fw_rx_vxlan;
773 u64 fw_rx_vxlan_err;
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700774
775 /* LRO */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700776 u64 fw_lro_pkts; /* Number of packets that are LROed */
777 u64 fw_lro_octs; /* Number of octets that are LROed */
778 u64 fw_total_lro; /* Number of LRO packets formed */
779 u64 fw_lro_aborts; /* Number of times lRO of packet aborted */
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700780 u64 fw_lro_aborts_port;
781 u64 fw_lro_aborts_seq;
782 u64 fw_lro_aborts_tsval;
783 u64 fw_lro_aborts_timer;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700784 /* intrmod: packet forward rate */
785 u64 fwd_rate;
786};
787
788/** Stats for each NIC port in RX direction. */
789struct nic_tx_stats {
790 /* link-level stats */
791 u64 total_pkts_sent;
792 u64 total_bytes_sent;
793 u64 mcast_pkts_sent;
794 u64 bcast_pkts_sent;
795 u64 ctl_sent;
796 u64 one_collision_sent; /* Packets sent after one collision*/
797 u64 multi_collision_sent; /* Packets sent after multiple collision*/
798 u64 max_collision_fail; /* Packets not sent due to max collisions */
799 u64 max_deferral_fail; /* Packets not sent due to max deferrals */
800 u64 fifo_err; /* Accounts for over/under-run of buffers */
801 u64 runts;
802 u64 total_collisions; /* Total number of collisions detected */
803
804 /* firmware stats */
805 u64 fw_total_sent;
806 u64 fw_total_fwd;
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700807 u64 fw_total_fwd_bytes;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700808 u64 fw_err_pko;
809 u64 fw_err_link;
810 u64 fw_err_drop;
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700811 u64 fw_err_tso;
812 u64 fw_tso; /* number of tso requests */
813 u64 fw_tso_fwd; /* number of packets segmented in tso */
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700814 u64 fw_tx_vxlan;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700815};
816
817struct oct_link_stats {
818 struct nic_rx_stats fromwire;
819 struct nic_tx_stats fromhost;
820
821};
822
Raghu Vatsavayi97a25322016-11-14 15:54:47 -0800823static inline int opcode_slow_path(union octeon_rh *rh)
824{
825 u16 subcode1, subcode2;
826
827 subcode1 = OPCODE_SUBCODE((rh)->r.opcode, (rh)->r.subcode);
828 subcode2 = OPCODE_SUBCODE(OPCODE_NIC, OPCODE_NIC_NW_DATA);
829
830 return (subcode2 != subcode1);
831}
832
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700833#define LIO68XX_LED_CTRL_ADDR 0x3501
834#define LIO68XX_LED_CTRL_CFGON 0x1f
835#define LIO68XX_LED_CTRL_CFGOFF 0x100
836#define LIO68XX_LED_BEACON_ADDR 0x3508
837#define LIO68XX_LED_BEACON_CFGON 0x47fd
838#define LIO68XX_LED_BEACON_CFGOFF 0x11fc
839#define VITESSE_PHY_GPIO_DRIVEON 0x1
840#define VITESSE_PHY_GPIO_CFG 0x8
841#define VITESSE_PHY_GPIO_DRIVEOFF 0x4
842#define VITESSE_PHY_GPIO_HIGH 0x2
843#define VITESSE_PHY_GPIO_LOW 0x3
Raghu Vatsavayidc3abcb2016-09-01 11:16:08 -0700844#define LED_IDENTIFICATION_ON 0x1
845#define LED_IDENTIFICATION_OFF 0x0
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700846
847struct oct_mdio_cmd {
848 u64 op;
849 u64 mdio_addr;
850 u64 value1;
851 u64 value2;
852 u64 value3;
853};
854
855#define OCT_LINK_STATS_SIZE (sizeof(struct oct_link_stats))
856
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700857struct oct_intrmod_cfg {
Raghu Vatsavayi78e6a9b2016-06-21 22:53:10 -0700858 u64 rx_enable;
859 u64 tx_enable;
860 u64 check_intrvl;
861 u64 maxpkt_ratethr;
862 u64 minpkt_ratethr;
863 u64 rx_maxcnt_trigger;
864 u64 rx_mincnt_trigger;
865 u64 rx_maxtmr_trigger;
866 u64 rx_mintmr_trigger;
867 u64 tx_mincnt_trigger;
868 u64 tx_maxcnt_trigger;
869 u64 rx_frames;
870 u64 tx_frames;
871 u64 rx_usecs;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700872};
873
874#define BASE_QUEUE_NOT_REQUESTED 65535
875
876union oct_nic_if_cfg {
877 u64 u64;
878 struct {
879#ifdef __BIG_ENDIAN_BITFIELD
880 u64 base_queue:16;
881 u64 num_iqueues:16;
882 u64 num_oqueues:16;
883 u64 gmx_port_id:8;
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700884 u64 vf_id:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700885#else
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700886 u64 vf_id:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700887 u64 gmx_port_id:8;
888 u64 num_oqueues:16;
889 u64 num_iqueues:16;
890 u64 base_queue:16;
891#endif
892 } s;
893};
894
895#endif