blob: 4a07c0ac9fab66dbc0bf913af9231407c408ff76 [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
Rick Farrington0c88a762017-03-13 12:58:04 -0700103#define INTRNAMSIZ 32
104#define IRQ_NAME_OFF(i) ((i) * INTRNAMSIZ)
105#define MAX_IOQ_INTERRUPTS_PER_PF (64 * 2)
106#define MAX_IOQ_INTERRUPTS_PER_VF (8 * 2)
107
Prasad Kannegantide28c992017-01-09 14:42:40 -0800108
Raghu Vatsavayi97a25322016-11-14 15:54:47 -0800109static inline u32 incr_index(u32 index, u32 count, u32 max)
110{
111 if ((index + count) >= max)
112 index = index + count - max;
113 else
114 index += count;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700115
Raghu Vatsavayi97a25322016-11-14 15:54:47 -0800116 return index;
117}
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700118
119#define OCT_BOARD_NAME 32
120#define OCT_SERIAL_LEN 64
121
122/* Structure used by core driver to send indication that the Octeon
123 * application is ready.
124 */
125struct octeon_core_setup {
126 u64 corefreq;
127
128 char boardname[OCT_BOARD_NAME];
129
130 char board_serial_number[OCT_SERIAL_LEN];
131
132 u64 board_rev_major;
133
134 u64 board_rev_minor;
135
136};
137
138/*--------------------------- SCATTER GATHER ENTRY -----------------------*/
139
140/* The Scatter-Gather List Entry. The scatter or gather component used with
141 * a Octeon input instruction has this format.
142 */
143struct octeon_sg_entry {
144 /** The first 64 bit gives the size of data in each dptr.*/
145 union {
146 u16 size[4];
147 u64 size64;
148 } u;
149
150 /** The 4 dptr pointers for this entry. */
151 u64 ptr[4];
152
153};
154
155#define OCT_SG_ENTRY_SIZE (sizeof(struct octeon_sg_entry))
156
157/* \brief Add size to gather list
158 * @param sg_entry scatter/gather entry
159 * @param size size to add
160 * @param pos position to add it.
161 */
162static inline void add_sg_size(struct octeon_sg_entry *sg_entry,
163 u16 size,
164 u32 pos)
165{
166#ifdef __BIG_ENDIAN_BITFIELD
167 sg_entry->u.size[pos] = size;
168#else
169 sg_entry->u.size[3 - pos] = size;
170#endif
171}
172
173/*------------------------- End Scatter/Gather ---------------------------*/
174
175#define OCTNET_FRM_PTP_HEADER_SIZE 8
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700176
Raghu Vatsavayia5b37882016-06-14 16:54:48 -0700177#define OCTNET_FRM_HEADER_SIZE 22 /* VLAN + Ethernet */
178
179#define OCTNET_MIN_FRM_SIZE 64
180
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700181#define OCTNET_MAX_FRM_SIZE (16000 + OCTNET_FRM_HEADER_SIZE)
182
183#define OCTNET_DEFAULT_FRM_SIZE (1500 + OCTNET_FRM_HEADER_SIZE)
184
185/** NIC Commands are sent using this Octeon Input Queue */
186#define OCTNET_CMD_Q 0
187
188/* NIC Command types */
189#define OCTNET_CMD_CHANGE_MTU 0x1
190#define OCTNET_CMD_CHANGE_MACADDR 0x2
191#define OCTNET_CMD_CHANGE_DEVFLAGS 0x3
192#define OCTNET_CMD_RX_CTL 0x4
193
194#define OCTNET_CMD_SET_MULTI_LIST 0x5
195#define OCTNET_CMD_CLEAR_STATS 0x6
196
197/* command for setting the speed, duplex & autoneg */
198#define OCTNET_CMD_SET_SETTINGS 0x7
199#define OCTNET_CMD_SET_FLOW_CTL 0x8
200
201#define OCTNET_CMD_MDIO_READ_WRITE 0x9
202#define OCTNET_CMD_GPIO_ACCESS 0xA
203#define OCTNET_CMD_LRO_ENABLE 0xB
204#define OCTNET_CMD_LRO_DISABLE 0xC
205#define OCTNET_CMD_SET_RSS 0xD
206#define OCTNET_CMD_WRITE_SA 0xE
207#define OCTNET_CMD_DELETE_SA 0xF
208#define OCTNET_CMD_UPDATE_SA 0x12
209
210#define OCTNET_CMD_TNL_RX_CSUM_CTL 0x10
211#define OCTNET_CMD_TNL_TX_CSUM_CTL 0x11
212#define OCTNET_CMD_IPSECV2_AH_ESP_CTL 0x13
213#define OCTNET_CMD_VERBOSE_ENABLE 0x14
214#define OCTNET_CMD_VERBOSE_DISABLE 0x15
215
Raghu Vatsavayi63245f22016-06-21 22:53:05 -0700216#define OCTNET_CMD_ENABLE_VLAN_FILTER 0x16
217#define OCTNET_CMD_ADD_VLAN_FILTER 0x17
218#define OCTNET_CMD_DEL_VLAN_FILTER 0x18
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700219#define OCTNET_CMD_VXLAN_PORT_CONFIG 0x19
Raghu Vatsavayidc3abcb2016-09-01 11:16:08 -0700220
221#define OCTNET_CMD_ID_ACTIVE 0x1a
222
Raghu Vatsavayi50f7f942016-12-07 08:54:33 -0800223#define OCTNET_CMD_SET_UC_LIST 0x1b
Raghu Vatsavayi86dea552016-11-14 15:54:43 -0800224#define OCTNET_CMD_SET_VF_LINKSTATE 0x1c
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700225#define OCTNET_CMD_VXLAN_PORT_ADD 0x0
226#define OCTNET_CMD_VXLAN_PORT_DEL 0x1
227#define OCTNET_CMD_RXCSUM_ENABLE 0x0
228#define OCTNET_CMD_RXCSUM_DISABLE 0x1
229#define OCTNET_CMD_TXCSUM_ENABLE 0x0
230#define OCTNET_CMD_TXCSUM_DISABLE 0x1
Raghu Vatsavayi63245f22016-06-21 22:53:05 -0700231
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700232/* RX(packets coming from wire) Checksum verification flags */
233/* TCP/UDP csum */
234#define CNNIC_L4SUM_VERIFIED 0x1
235#define CNNIC_IPSUM_VERIFIED 0x2
236#define CNNIC_TUN_CSUM_VERIFIED 0x4
237#define CNNIC_CSUM_VERIFIED (CNNIC_IPSUM_VERIFIED | CNNIC_L4SUM_VERIFIED)
238
239/*LROIPV4 and LROIPV6 Flags*/
240#define OCTNIC_LROIPV4 0x1
241#define OCTNIC_LROIPV6 0x2
242
243/* Interface flags communicated between host driver and core app. */
244enum octnet_ifflags {
245 OCTNET_IFFLAG_PROMISC = 0x01,
246 OCTNET_IFFLAG_ALLMULTI = 0x02,
247 OCTNET_IFFLAG_MULTICAST = 0x04,
248 OCTNET_IFFLAG_BROADCAST = 0x08,
249 OCTNET_IFFLAG_UNICAST = 0x10
250};
251
252/* wqe
253 * --------------- 0
254 * | wqe word0-3 |
255 * --------------- 32
256 * | PCI IH |
257 * --------------- 40
258 * | RPTR |
259 * --------------- 48
260 * | PCI IRH |
261 * --------------- 56
262 * | OCT_NET_CMD |
263 * --------------- 64
264 * | Addtl 8-BData |
265 * | |
266 * ---------------
267 */
268
269union octnet_cmd {
270 u64 u64;
271
272 struct {
273#ifdef __BIG_ENDIAN_BITFIELD
274 u64 cmd:5;
275
276 u64 more:6; /* How many udd words follow the command */
277
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700278 u64 reserved:29;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700279
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700280 u64 param1:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700281
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700282 u64 param2:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700283
284#else
285
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700286 u64 param2:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700287
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700288 u64 param1:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700289
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700290 u64 reserved:29;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700291
292 u64 more:6;
293
294 u64 cmd:5;
295
296#endif
297 } s;
298
299};
300
301#define OCTNET_CMD_SIZE (sizeof(union octnet_cmd))
302
Raghu Vatsavayi5b823512016-09-01 11:16:07 -0700303/*pkiih3 + irh + ossp[0] + ossp[1] + rdp + rptr = 40 bytes */
304#define LIO_SOFTCMDRESP_IH2 40
305#define LIO_SOFTCMDRESP_IH3 (40 + 8)
306
307#define LIO_PCICMD_O2 24
308#define LIO_PCICMD_O3 (24 + 8)
309
Raghu Vatsavayia2c64b62016-07-03 13:56:55 -0700310/* Instruction Header(DPI) - for OCTEON-III models */
Raghu Vatsavayi6a885b62016-06-14 16:54:51 -0700311struct octeon_instr_ih3 {
312#ifdef __BIG_ENDIAN_BITFIELD
313
314 /** Reserved3 */
315 u64 reserved3:1;
316
317 /** Gather indicator 1=gather*/
318 u64 gather:1;
319
320 /** Data length OR no. of entries in gather list */
321 u64 dlengsz:14;
322
323 /** Front Data size */
324 u64 fsz:6;
325
326 /** Reserved2 */
327 u64 reserved2:4;
328
329 /** PKI port kind - PKIND */
330 u64 pkind:6;
331
332 /** Reserved1 */
333 u64 reserved1:32;
334
335#else
336 /** Reserved1 */
337 u64 reserved1:32;
338
339 /** PKI port kind - PKIND */
340 u64 pkind:6;
341
342 /** Reserved2 */
343 u64 reserved2:4;
344
345 /** Front Data size */
346 u64 fsz:6;
347
348 /** Data length OR no. of entries in gather list */
349 u64 dlengsz:14;
350
351 /** Gather indicator 1=gather*/
352 u64 gather:1;
353
354 /** Reserved3 */
355 u64 reserved3:1;
356
357#endif
358};
359
Raghu Vatsavayia2c64b62016-07-03 13:56:55 -0700360/* Optional PKI Instruction Header(PKI IH) - for OCTEON-III models */
Raghu Vatsavayi6a885b62016-06-14 16:54:51 -0700361/** BIG ENDIAN format. */
362struct octeon_instr_pki_ih3 {
363#ifdef __BIG_ENDIAN_BITFIELD
364
365 /** Wider bit */
366 u64 w:1;
367
368 /** Raw mode indicator 1 = RAW */
369 u64 raw:1;
370
371 /** Use Tag */
372 u64 utag:1;
373
374 /** Use QPG */
375 u64 uqpg:1;
376
377 /** Reserved2 */
378 u64 reserved2:1;
379
380 /** Parse Mode */
381 u64 pm:3;
382
383 /** Skip Length */
384 u64 sl:8;
385
386 /** Use Tag Type */
387 u64 utt:1;
388
389 /** Tag type */
390 u64 tagtype:2;
391
392 /** Reserved1 */
393 u64 reserved1:2;
394
395 /** QPG Value */
396 u64 qpg:11;
397
398 /** Tag Value */
399 u64 tag:32;
400
401#else
402
403 /** Tag Value */
404 u64 tag:32;
405
406 /** QPG Value */
407 u64 qpg:11;
408
409 /** Reserved1 */
410 u64 reserved1:2;
411
412 /** Tag type */
413 u64 tagtype:2;
414
415 /** Use Tag Type */
416 u64 utt:1;
417
418 /** Skip Length */
419 u64 sl:8;
420
421 /** Parse Mode */
422 u64 pm:3;
423
424 /** Reserved2 */
425 u64 reserved2:1;
426
427 /** Use QPG */
428 u64 uqpg:1;
429
430 /** Use Tag */
431 u64 utag:1;
432
433 /** Raw mode indicator 1 = RAW */
434 u64 raw:1;
435
436 /** Wider bit */
437 u64 w:1;
438#endif
439
440};
441
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700442/** Instruction Header */
Raghu Vatsavayi6a885b62016-06-14 16:54:51 -0700443struct octeon_instr_ih2 {
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700444#ifdef __BIG_ENDIAN_BITFIELD
445 /** Raw mode indicator 1 = RAW */
446 u64 raw:1;
447
448 /** Gather indicator 1=gather*/
449 u64 gather:1;
450
451 /** Data length OR no. of entries in gather list */
452 u64 dlengsz:14;
453
454 /** Front Data size */
455 u64 fsz:6;
456
457 /** Packet Order / Work Unit selection (1 of 8)*/
458 u64 qos:3;
459
460 /** Core group selection (1 of 16) */
461 u64 grp:4;
462
463 /** Short Raw Packet Indicator 1=short raw pkt */
464 u64 rs:1;
465
466 /** Tag type */
467 u64 tagtype:2;
468
469 /** Tag Value */
470 u64 tag:32;
471#else
472 /** Tag Value */
473 u64 tag:32;
474
475 /** Tag type */
476 u64 tagtype:2;
477
478 /** Short Raw Packet Indicator 1=short raw pkt */
479 u64 rs:1;
480
481 /** Core group selection (1 of 16) */
482 u64 grp:4;
483
484 /** Packet Order / Work Unit selection (1 of 8)*/
485 u64 qos:3;
486
487 /** Front Data size */
488 u64 fsz:6;
489
490 /** Data length OR no. of entries in gather list */
491 u64 dlengsz:14;
492
493 /** Gather indicator 1=gather*/
494 u64 gather:1;
495
496 /** Raw mode indicator 1 = RAW */
497 u64 raw:1;
498#endif
499};
500
501/** Input Request Header */
502struct octeon_instr_irh {
503#ifdef __BIG_ENDIAN_BITFIELD
504 u64 opcode:4;
505 u64 rflag:1;
506 u64 subcode:7;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700507 u64 vlan:12;
508 u64 priority:3;
509 u64 reserved:5;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700510 u64 ossp:32; /* opcode/subcode specific parameters */
511#else
512 u64 ossp:32; /* opcode/subcode specific parameters */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700513 u64 reserved:5;
514 u64 priority:3;
515 u64 vlan:12;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700516 u64 subcode:7;
517 u64 rflag:1;
518 u64 opcode:4;
519#endif
520};
521
522/** Return Data Parameters */
523struct octeon_instr_rdp {
524#ifdef __BIG_ENDIAN_BITFIELD
525 u64 reserved:49;
526 u64 pcie_port:3;
527 u64 rlen:12;
528#else
529 u64 rlen:12;
530 u64 pcie_port:3;
531 u64 reserved:49;
532#endif
533};
534
535/** Receive Header */
536union octeon_rh {
537#ifdef __BIG_ENDIAN_BITFIELD
538 u64 u64;
539 struct {
540 u64 opcode:4;
541 u64 subcode:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700542 u64 len:3; /** additional 64-bit words */
543 u64 reserved:17;
544 u64 ossp:32; /** opcode/subcode specific parameters */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700545 } r;
546 struct {
547 u64 opcode:4;
548 u64 subcode:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700549 u64 len:3; /** additional 64-bit words */
550 u64 extra:28;
551 u64 vlan:12;
552 u64 priority:3;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700553 u64 csum_verified:3; /** checksum verified. */
554 u64 has_hwtstamp:1; /** Has hardware timestamp. 1 = yes. */
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700555 u64 encap_on:1;
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700556 u64 has_hash:1; /** Has hash (rth or rss). 1 = yes. */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700557 } r_dh;
558 struct {
559 u64 opcode:4;
560 u64 subcode:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700561 u64 len:3; /** additional 64-bit words */
562 u64 reserved:11;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700563 u64 num_gmx_ports:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700564 u64 max_nic_ports:10;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700565 u64 app_cap_flags:4;
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700566 u64 app_mode:8;
567 u64 pkind:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700568 } r_core_drv_init;
569 struct {
570 u64 opcode:4;
571 u64 subcode:8;
572 u64 len:3; /** additional 64-bit words */
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700573 u64 reserved:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700574 u64 extra:25;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700575 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700576 } r_nic_info;
577#else
578 u64 u64;
579 struct {
580 u64 ossp:32; /** opcode/subcode specific parameters */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700581 u64 reserved:17;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700582 u64 len:3; /** additional 64-bit words */
583 u64 subcode:8;
584 u64 opcode:4;
585 } r;
586 struct {
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700587 u64 has_hash:1; /** Has hash (rth or rss). 1 = yes. */
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700588 u64 encap_on:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700589 u64 has_hwtstamp:1; /** 1 = has hwtstamp */
590 u64 csum_verified:3; /** checksum verified. */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700591 u64 priority:3;
592 u64 vlan:12;
593 u64 extra:28;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700594 u64 len:3; /** additional 64-bit words */
595 u64 subcode:8;
596 u64 opcode:4;
597 } r_dh;
598 struct {
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700599 u64 pkind:8;
600 u64 app_mode:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700601 u64 app_cap_flags:4;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700602 u64 max_nic_ports:10;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700603 u64 num_gmx_ports:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700604 u64 reserved:11;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700605 u64 len:3; /** additional 64-bit words */
606 u64 subcode:8;
607 u64 opcode:4;
608 } r_core_drv_init;
609 struct {
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700610 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700611 u64 extra:25;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700612 u64 reserved:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700613 u64 len:3; /** additional 64-bit words */
614 u64 subcode:8;
615 u64 opcode:4;
616 } r_nic_info;
617#endif
618};
619
620#define OCT_RH_SIZE (sizeof(union octeon_rh))
621
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700622union octnic_packet_params {
623 u32 u32;
624 struct {
625#ifdef __BIG_ENDIAN_BITFIELD
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700626 u32 reserved:24;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700627 u32 ip_csum:1; /* Perform IP header checksum(s) */
628 /* Perform Outer transport header checksum */
629 u32 transport_csum:1;
630 /* Find tunnel, and perform transport csum. */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700631 u32 tnl_csum:1;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700632 u32 tsflag:1; /* Timestamp this packet */
633 u32 ipsec_ops:4; /* IPsec operation */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700634#else
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700635 u32 ipsec_ops:4;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700636 u32 tsflag:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700637 u32 tnl_csum:1;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700638 u32 transport_csum:1;
639 u32 ip_csum:1;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700640 u32 reserved:24;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700641#endif
642 } s;
643};
644
645/** Status of a RGMII Link on Octeon as seen by core driver. */
646union oct_link_status {
647 u64 u64;
648
649 struct {
650#ifdef __BIG_ENDIAN_BITFIELD
651 u64 duplex:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700652 u64 mtu:16;
653 u64 speed:16;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700654 u64 link_up:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700655 u64 autoneg:1;
Raghu Vatsavayi9eb60842016-06-21 22:53:12 -0700656 u64 if_mode:5;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700657 u64 pause:1;
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700658 u64 flashing:1;
659 u64 reserved:15;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700660#else
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700661 u64 reserved:15;
662 u64 flashing:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700663 u64 pause:1;
Raghu Vatsavayi9eb60842016-06-21 22:53:12 -0700664 u64 if_mode:5;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700665 u64 autoneg:1;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700666 u64 link_up:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700667 u64 speed:16;
668 u64 mtu:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700669 u64 duplex:8;
670#endif
671 } s;
672};
673
Raghu Vatsavayi26236fa2016-06-14 16:54:44 -0700674/** The txpciq info passed to host from the firmware */
675
676union oct_txpciq {
677 u64 u64;
678
679 struct {
680#ifdef __BIG_ENDIAN_BITFIELD
681 u64 q_no:8;
682 u64 port:8;
683 u64 pkind:6;
684 u64 use_qpg:1;
685 u64 qpg:11;
686 u64 reserved:30;
687#else
688 u64 reserved:30;
689 u64 qpg:11;
690 u64 use_qpg:1;
691 u64 pkind:6;
692 u64 port:8;
693 u64 q_no:8;
694#endif
695 } s;
696};
697
698/** The rxpciq info passed to host from the firmware */
699
700union oct_rxpciq {
701 u64 u64;
702
703 struct {
704#ifdef __BIG_ENDIAN_BITFIELD
705 u64 q_no:8;
706 u64 reserved:56;
707#else
708 u64 reserved:56;
709 u64 q_no:8;
710#endif
711 } s;
712};
713
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700714/** Information for a OCTEON ethernet interface shared between core & host. */
715struct oct_link_info {
716 union oct_link_status link;
717 u64 hw_addr;
718
719#ifdef __BIG_ENDIAN_BITFIELD
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700720 u64 gmxport:16;
Raghu Vatsavayi8c978d02016-11-14 15:54:41 -0800721 u64 macaddr_is_admin_asgnd:1;
722 u64 rsvd:31;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700723 u64 num_txpciq:8;
724 u64 num_rxpciq:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700725#else
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700726 u64 num_rxpciq:8;
727 u64 num_txpciq:8;
Raghu Vatsavayi8c978d02016-11-14 15:54:41 -0800728 u64 rsvd:31;
729 u64 macaddr_is_admin_asgnd:1;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700730 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700731#endif
732
Raghu Vatsavayi26236fa2016-06-14 16:54:44 -0700733 union oct_txpciq txpciq[MAX_IOQS_PER_NICIF];
734 union oct_rxpciq rxpciq[MAX_IOQS_PER_NICIF];
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700735};
736
737#define OCT_LINK_INFO_SIZE (sizeof(struct oct_link_info))
738
739struct liquidio_if_cfg_info {
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700740 u64 iqmask; /** mask for IQs enabled for the port */
741 u64 oqmask; /** mask for OQs enabled for the port */
742 struct oct_link_info linfo; /** initial link information */
Raghu Vatsavayid3d7e6c2016-06-21 22:53:07 -0700743 char liquidio_firmware_version[32];
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700744};
745
746/** Stats for each NIC port in RX direction. */
747struct nic_rx_stats {
748 /* link-level stats */
749 u64 total_rcvd;
750 u64 bytes_rcvd;
751 u64 total_bcst;
752 u64 total_mcst;
753 u64 runts;
754 u64 ctl_rcvd;
755 u64 fifo_err; /* Accounts for over/under-run of buffers */
756 u64 dmac_drop;
757 u64 fcs_err;
758 u64 jabber_err;
759 u64 l2_err;
760 u64 frame_err;
761
762 /* firmware stats */
763 u64 fw_total_rcvd;
764 u64 fw_total_fwd;
765 u64 fw_err_pko;
766 u64 fw_err_link;
767 u64 fw_err_drop;
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700768 u64 fw_rx_vxlan;
769 u64 fw_rx_vxlan_err;
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700770
771 /* LRO */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700772 u64 fw_lro_pkts; /* Number of packets that are LROed */
773 u64 fw_lro_octs; /* Number of octets that are LROed */
774 u64 fw_total_lro; /* Number of LRO packets formed */
775 u64 fw_lro_aborts; /* Number of times lRO of packet aborted */
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700776 u64 fw_lro_aborts_port;
777 u64 fw_lro_aborts_seq;
778 u64 fw_lro_aborts_tsval;
779 u64 fw_lro_aborts_timer;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700780 /* intrmod: packet forward rate */
781 u64 fwd_rate;
782};
783
784/** Stats for each NIC port in RX direction. */
785struct nic_tx_stats {
786 /* link-level stats */
787 u64 total_pkts_sent;
788 u64 total_bytes_sent;
789 u64 mcast_pkts_sent;
790 u64 bcast_pkts_sent;
791 u64 ctl_sent;
792 u64 one_collision_sent; /* Packets sent after one collision*/
793 u64 multi_collision_sent; /* Packets sent after multiple collision*/
794 u64 max_collision_fail; /* Packets not sent due to max collisions */
795 u64 max_deferral_fail; /* Packets not sent due to max deferrals */
796 u64 fifo_err; /* Accounts for over/under-run of buffers */
797 u64 runts;
798 u64 total_collisions; /* Total number of collisions detected */
799
800 /* firmware stats */
801 u64 fw_total_sent;
802 u64 fw_total_fwd;
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700803 u64 fw_total_fwd_bytes;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700804 u64 fw_err_pko;
805 u64 fw_err_link;
806 u64 fw_err_drop;
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700807 u64 fw_err_tso;
808 u64 fw_tso; /* number of tso requests */
809 u64 fw_tso_fwd; /* number of packets segmented in tso */
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700810 u64 fw_tx_vxlan;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700811};
812
813struct oct_link_stats {
814 struct nic_rx_stats fromwire;
815 struct nic_tx_stats fromhost;
816
817};
818
Raghu Vatsavayi97a25322016-11-14 15:54:47 -0800819static inline int opcode_slow_path(union octeon_rh *rh)
820{
821 u16 subcode1, subcode2;
822
823 subcode1 = OPCODE_SUBCODE((rh)->r.opcode, (rh)->r.subcode);
824 subcode2 = OPCODE_SUBCODE(OPCODE_NIC, OPCODE_NIC_NW_DATA);
825
826 return (subcode2 != subcode1);
827}
828
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700829#define LIO68XX_LED_CTRL_ADDR 0x3501
830#define LIO68XX_LED_CTRL_CFGON 0x1f
831#define LIO68XX_LED_CTRL_CFGOFF 0x100
832#define LIO68XX_LED_BEACON_ADDR 0x3508
833#define LIO68XX_LED_BEACON_CFGON 0x47fd
834#define LIO68XX_LED_BEACON_CFGOFF 0x11fc
835#define VITESSE_PHY_GPIO_DRIVEON 0x1
836#define VITESSE_PHY_GPIO_CFG 0x8
837#define VITESSE_PHY_GPIO_DRIVEOFF 0x4
838#define VITESSE_PHY_GPIO_HIGH 0x2
839#define VITESSE_PHY_GPIO_LOW 0x3
Raghu Vatsavayidc3abcb2016-09-01 11:16:08 -0700840#define LED_IDENTIFICATION_ON 0x1
841#define LED_IDENTIFICATION_OFF 0x0
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700842
843struct oct_mdio_cmd {
844 u64 op;
845 u64 mdio_addr;
846 u64 value1;
847 u64 value2;
848 u64 value3;
849};
850
851#define OCT_LINK_STATS_SIZE (sizeof(struct oct_link_stats))
852
Raghu Vatsavayi78e6a9b2016-06-21 22:53:10 -0700853/* intrmod: max. packet rate threshold */
854#define LIO_INTRMOD_MAXPKT_RATETHR 196608
855/* intrmod: min. packet rate threshold */
856#define LIO_INTRMOD_MINPKT_RATETHR 9216
857/* intrmod: max. packets to trigger interrupt */
858#define LIO_INTRMOD_RXMAXCNT_TRIGGER 384
859/* intrmod: min. packets to trigger interrupt */
Raghu Vatsavayicd8b1eb2016-08-31 11:03:22 -0700860#define LIO_INTRMOD_RXMINCNT_TRIGGER 0
Raghu Vatsavayi78e6a9b2016-06-21 22:53:10 -0700861/* intrmod: max. time to trigger interrupt */
862#define LIO_INTRMOD_RXMAXTMR_TRIGGER 128
863/* 66xx:intrmod: min. time to trigger interrupt
864 * (value of 1 is optimum for TCP_RR)
865 */
866#define LIO_INTRMOD_RXMINTMR_TRIGGER 1
867
868/* intrmod: max. packets to trigger interrupt */
869#define LIO_INTRMOD_TXMAXCNT_TRIGGER 64
870/* intrmod: min. packets to trigger interrupt */
871#define LIO_INTRMOD_TXMINCNT_TRIGGER 0
872
873/* intrmod: poll interval in seconds */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700874#define LIO_INTRMOD_CHECK_INTERVAL 1
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700875
876struct oct_intrmod_cfg {
Raghu Vatsavayi78e6a9b2016-06-21 22:53:10 -0700877 u64 rx_enable;
878 u64 tx_enable;
879 u64 check_intrvl;
880 u64 maxpkt_ratethr;
881 u64 minpkt_ratethr;
882 u64 rx_maxcnt_trigger;
883 u64 rx_mincnt_trigger;
884 u64 rx_maxtmr_trigger;
885 u64 rx_mintmr_trigger;
886 u64 tx_mincnt_trigger;
887 u64 tx_maxcnt_trigger;
888 u64 rx_frames;
889 u64 tx_frames;
890 u64 rx_usecs;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700891};
892
893#define BASE_QUEUE_NOT_REQUESTED 65535
894
895union oct_nic_if_cfg {
896 u64 u64;
897 struct {
898#ifdef __BIG_ENDIAN_BITFIELD
899 u64 base_queue:16;
900 u64 num_iqueues:16;
901 u64 num_oqueues:16;
902 u64 gmx_port_id:8;
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700903 u64 vf_id:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700904#else
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700905 u64 vf_id:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700906 u64 gmx_port_id:8;
907 u64 num_oqueues:16;
908 u64 num_iqueues:16;
909 u64 base_queue:16;
910#endif
911 } s;
912};
913
914#endif