blob: bc0af8af1a0ca975e3ceb23a9f976afcddb51c1b [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
102
Raghu Vatsavayi97a25322016-11-14 15:54:47 -0800103static inline u32 incr_index(u32 index, u32 count, u32 max)
104{
105 if ((index + count) >= max)
106 index = index + count - max;
107 else
108 index += count;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700109
Raghu Vatsavayi97a25322016-11-14 15:54:47 -0800110 return index;
111}
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700112
113#define OCT_BOARD_NAME 32
114#define OCT_SERIAL_LEN 64
115
116/* Structure used by core driver to send indication that the Octeon
117 * application is ready.
118 */
119struct octeon_core_setup {
120 u64 corefreq;
121
122 char boardname[OCT_BOARD_NAME];
123
124 char board_serial_number[OCT_SERIAL_LEN];
125
126 u64 board_rev_major;
127
128 u64 board_rev_minor;
129
130};
131
132/*--------------------------- SCATTER GATHER ENTRY -----------------------*/
133
134/* The Scatter-Gather List Entry. The scatter or gather component used with
135 * a Octeon input instruction has this format.
136 */
137struct octeon_sg_entry {
138 /** The first 64 bit gives the size of data in each dptr.*/
139 union {
140 u16 size[4];
141 u64 size64;
142 } u;
143
144 /** The 4 dptr pointers for this entry. */
145 u64 ptr[4];
146
147};
148
149#define OCT_SG_ENTRY_SIZE (sizeof(struct octeon_sg_entry))
150
151/* \brief Add size to gather list
152 * @param sg_entry scatter/gather entry
153 * @param size size to add
154 * @param pos position to add it.
155 */
156static inline void add_sg_size(struct octeon_sg_entry *sg_entry,
157 u16 size,
158 u32 pos)
159{
160#ifdef __BIG_ENDIAN_BITFIELD
161 sg_entry->u.size[pos] = size;
162#else
163 sg_entry->u.size[3 - pos] = size;
164#endif
165}
166
167/*------------------------- End Scatter/Gather ---------------------------*/
168
169#define OCTNET_FRM_PTP_HEADER_SIZE 8
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700170
Raghu Vatsavayia5b37882016-06-14 16:54:48 -0700171#define OCTNET_FRM_HEADER_SIZE 22 /* VLAN + Ethernet */
172
173#define OCTNET_MIN_FRM_SIZE 64
174
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700175#define OCTNET_MAX_FRM_SIZE (16000 + OCTNET_FRM_HEADER_SIZE)
176
177#define OCTNET_DEFAULT_FRM_SIZE (1500 + OCTNET_FRM_HEADER_SIZE)
178
179/** NIC Commands are sent using this Octeon Input Queue */
180#define OCTNET_CMD_Q 0
181
182/* NIC Command types */
183#define OCTNET_CMD_CHANGE_MTU 0x1
184#define OCTNET_CMD_CHANGE_MACADDR 0x2
185#define OCTNET_CMD_CHANGE_DEVFLAGS 0x3
186#define OCTNET_CMD_RX_CTL 0x4
187
188#define OCTNET_CMD_SET_MULTI_LIST 0x5
189#define OCTNET_CMD_CLEAR_STATS 0x6
190
191/* command for setting the speed, duplex & autoneg */
192#define OCTNET_CMD_SET_SETTINGS 0x7
193#define OCTNET_CMD_SET_FLOW_CTL 0x8
194
195#define OCTNET_CMD_MDIO_READ_WRITE 0x9
196#define OCTNET_CMD_GPIO_ACCESS 0xA
197#define OCTNET_CMD_LRO_ENABLE 0xB
198#define OCTNET_CMD_LRO_DISABLE 0xC
199#define OCTNET_CMD_SET_RSS 0xD
200#define OCTNET_CMD_WRITE_SA 0xE
201#define OCTNET_CMD_DELETE_SA 0xF
202#define OCTNET_CMD_UPDATE_SA 0x12
203
204#define OCTNET_CMD_TNL_RX_CSUM_CTL 0x10
205#define OCTNET_CMD_TNL_TX_CSUM_CTL 0x11
206#define OCTNET_CMD_IPSECV2_AH_ESP_CTL 0x13
207#define OCTNET_CMD_VERBOSE_ENABLE 0x14
208#define OCTNET_CMD_VERBOSE_DISABLE 0x15
209
Raghu Vatsavayi63245f22016-06-21 22:53:05 -0700210#define OCTNET_CMD_ENABLE_VLAN_FILTER 0x16
211#define OCTNET_CMD_ADD_VLAN_FILTER 0x17
212#define OCTNET_CMD_DEL_VLAN_FILTER 0x18
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700213#define OCTNET_CMD_VXLAN_PORT_CONFIG 0x19
Raghu Vatsavayidc3abcb2016-09-01 11:16:08 -0700214
215#define OCTNET_CMD_ID_ACTIVE 0x1a
216
Raghu Vatsavayi50f7f942016-12-07 08:54:33 -0800217#define OCTNET_CMD_SET_UC_LIST 0x1b
Raghu Vatsavayi86dea552016-11-14 15:54:43 -0800218#define OCTNET_CMD_SET_VF_LINKSTATE 0x1c
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700219#define OCTNET_CMD_VXLAN_PORT_ADD 0x0
220#define OCTNET_CMD_VXLAN_PORT_DEL 0x1
221#define OCTNET_CMD_RXCSUM_ENABLE 0x0
222#define OCTNET_CMD_RXCSUM_DISABLE 0x1
223#define OCTNET_CMD_TXCSUM_ENABLE 0x0
224#define OCTNET_CMD_TXCSUM_DISABLE 0x1
Raghu Vatsavayi63245f22016-06-21 22:53:05 -0700225
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700226/* RX(packets coming from wire) Checksum verification flags */
227/* TCP/UDP csum */
228#define CNNIC_L4SUM_VERIFIED 0x1
229#define CNNIC_IPSUM_VERIFIED 0x2
230#define CNNIC_TUN_CSUM_VERIFIED 0x4
231#define CNNIC_CSUM_VERIFIED (CNNIC_IPSUM_VERIFIED | CNNIC_L4SUM_VERIFIED)
232
233/*LROIPV4 and LROIPV6 Flags*/
234#define OCTNIC_LROIPV4 0x1
235#define OCTNIC_LROIPV6 0x2
236
237/* Interface flags communicated between host driver and core app. */
238enum octnet_ifflags {
239 OCTNET_IFFLAG_PROMISC = 0x01,
240 OCTNET_IFFLAG_ALLMULTI = 0x02,
241 OCTNET_IFFLAG_MULTICAST = 0x04,
242 OCTNET_IFFLAG_BROADCAST = 0x08,
243 OCTNET_IFFLAG_UNICAST = 0x10
244};
245
246/* wqe
247 * --------------- 0
248 * | wqe word0-3 |
249 * --------------- 32
250 * | PCI IH |
251 * --------------- 40
252 * | RPTR |
253 * --------------- 48
254 * | PCI IRH |
255 * --------------- 56
256 * | OCT_NET_CMD |
257 * --------------- 64
258 * | Addtl 8-BData |
259 * | |
260 * ---------------
261 */
262
263union octnet_cmd {
264 u64 u64;
265
266 struct {
267#ifdef __BIG_ENDIAN_BITFIELD
268 u64 cmd:5;
269
270 u64 more:6; /* How many udd words follow the command */
271
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700272 u64 reserved:29;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700273
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700274 u64 param1:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700275
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700276 u64 param2:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700277
278#else
279
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700280 u64 param2:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700281
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700282 u64 param1:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700283
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700284 u64 reserved:29;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700285
286 u64 more:6;
287
288 u64 cmd:5;
289
290#endif
291 } s;
292
293};
294
295#define OCTNET_CMD_SIZE (sizeof(union octnet_cmd))
296
Raghu Vatsavayi5b823512016-09-01 11:16:07 -0700297/*pkiih3 + irh + ossp[0] + ossp[1] + rdp + rptr = 40 bytes */
298#define LIO_SOFTCMDRESP_IH2 40
299#define LIO_SOFTCMDRESP_IH3 (40 + 8)
300
301#define LIO_PCICMD_O2 24
302#define LIO_PCICMD_O3 (24 + 8)
303
Raghu Vatsavayia2c64b62016-07-03 13:56:55 -0700304/* Instruction Header(DPI) - for OCTEON-III models */
Raghu Vatsavayi6a885b62016-06-14 16:54:51 -0700305struct octeon_instr_ih3 {
306#ifdef __BIG_ENDIAN_BITFIELD
307
308 /** Reserved3 */
309 u64 reserved3:1;
310
311 /** Gather indicator 1=gather*/
312 u64 gather:1;
313
314 /** Data length OR no. of entries in gather list */
315 u64 dlengsz:14;
316
317 /** Front Data size */
318 u64 fsz:6;
319
320 /** Reserved2 */
321 u64 reserved2:4;
322
323 /** PKI port kind - PKIND */
324 u64 pkind:6;
325
326 /** Reserved1 */
327 u64 reserved1:32;
328
329#else
330 /** Reserved1 */
331 u64 reserved1:32;
332
333 /** PKI port kind - PKIND */
334 u64 pkind:6;
335
336 /** Reserved2 */
337 u64 reserved2:4;
338
339 /** Front Data size */
340 u64 fsz:6;
341
342 /** Data length OR no. of entries in gather list */
343 u64 dlengsz:14;
344
345 /** Gather indicator 1=gather*/
346 u64 gather:1;
347
348 /** Reserved3 */
349 u64 reserved3:1;
350
351#endif
352};
353
Raghu Vatsavayia2c64b62016-07-03 13:56:55 -0700354/* Optional PKI Instruction Header(PKI IH) - for OCTEON-III models */
Raghu Vatsavayi6a885b62016-06-14 16:54:51 -0700355/** BIG ENDIAN format. */
356struct octeon_instr_pki_ih3 {
357#ifdef __BIG_ENDIAN_BITFIELD
358
359 /** Wider bit */
360 u64 w:1;
361
362 /** Raw mode indicator 1 = RAW */
363 u64 raw:1;
364
365 /** Use Tag */
366 u64 utag:1;
367
368 /** Use QPG */
369 u64 uqpg:1;
370
371 /** Reserved2 */
372 u64 reserved2:1;
373
374 /** Parse Mode */
375 u64 pm:3;
376
377 /** Skip Length */
378 u64 sl:8;
379
380 /** Use Tag Type */
381 u64 utt:1;
382
383 /** Tag type */
384 u64 tagtype:2;
385
386 /** Reserved1 */
387 u64 reserved1:2;
388
389 /** QPG Value */
390 u64 qpg:11;
391
392 /** Tag Value */
393 u64 tag:32;
394
395#else
396
397 /** Tag Value */
398 u64 tag:32;
399
400 /** QPG Value */
401 u64 qpg:11;
402
403 /** Reserved1 */
404 u64 reserved1:2;
405
406 /** Tag type */
407 u64 tagtype:2;
408
409 /** Use Tag Type */
410 u64 utt:1;
411
412 /** Skip Length */
413 u64 sl:8;
414
415 /** Parse Mode */
416 u64 pm:3;
417
418 /** Reserved2 */
419 u64 reserved2:1;
420
421 /** Use QPG */
422 u64 uqpg:1;
423
424 /** Use Tag */
425 u64 utag:1;
426
427 /** Raw mode indicator 1 = RAW */
428 u64 raw:1;
429
430 /** Wider bit */
431 u64 w:1;
432#endif
433
434};
435
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700436/** Instruction Header */
Raghu Vatsavayi6a885b62016-06-14 16:54:51 -0700437struct octeon_instr_ih2 {
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700438#ifdef __BIG_ENDIAN_BITFIELD
439 /** Raw mode indicator 1 = RAW */
440 u64 raw:1;
441
442 /** Gather indicator 1=gather*/
443 u64 gather:1;
444
445 /** Data length OR no. of entries in gather list */
446 u64 dlengsz:14;
447
448 /** Front Data size */
449 u64 fsz:6;
450
451 /** Packet Order / Work Unit selection (1 of 8)*/
452 u64 qos:3;
453
454 /** Core group selection (1 of 16) */
455 u64 grp:4;
456
457 /** Short Raw Packet Indicator 1=short raw pkt */
458 u64 rs:1;
459
460 /** Tag type */
461 u64 tagtype:2;
462
463 /** Tag Value */
464 u64 tag:32;
465#else
466 /** Tag Value */
467 u64 tag:32;
468
469 /** Tag type */
470 u64 tagtype:2;
471
472 /** Short Raw Packet Indicator 1=short raw pkt */
473 u64 rs:1;
474
475 /** Core group selection (1 of 16) */
476 u64 grp:4;
477
478 /** Packet Order / Work Unit selection (1 of 8)*/
479 u64 qos:3;
480
481 /** Front Data size */
482 u64 fsz:6;
483
484 /** Data length OR no. of entries in gather list */
485 u64 dlengsz:14;
486
487 /** Gather indicator 1=gather*/
488 u64 gather:1;
489
490 /** Raw mode indicator 1 = RAW */
491 u64 raw:1;
492#endif
493};
494
495/** Input Request Header */
496struct octeon_instr_irh {
497#ifdef __BIG_ENDIAN_BITFIELD
498 u64 opcode:4;
499 u64 rflag:1;
500 u64 subcode:7;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700501 u64 vlan:12;
502 u64 priority:3;
503 u64 reserved:5;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700504 u64 ossp:32; /* opcode/subcode specific parameters */
505#else
506 u64 ossp:32; /* opcode/subcode specific parameters */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700507 u64 reserved:5;
508 u64 priority:3;
509 u64 vlan:12;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700510 u64 subcode:7;
511 u64 rflag:1;
512 u64 opcode:4;
513#endif
514};
515
516/** Return Data Parameters */
517struct octeon_instr_rdp {
518#ifdef __BIG_ENDIAN_BITFIELD
519 u64 reserved:49;
520 u64 pcie_port:3;
521 u64 rlen:12;
522#else
523 u64 rlen:12;
524 u64 pcie_port:3;
525 u64 reserved:49;
526#endif
527};
528
529/** Receive Header */
530union octeon_rh {
531#ifdef __BIG_ENDIAN_BITFIELD
532 u64 u64;
533 struct {
534 u64 opcode:4;
535 u64 subcode:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700536 u64 len:3; /** additional 64-bit words */
537 u64 reserved:17;
538 u64 ossp:32; /** opcode/subcode specific parameters */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700539 } r;
540 struct {
541 u64 opcode:4;
542 u64 subcode:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700543 u64 len:3; /** additional 64-bit words */
544 u64 extra:28;
545 u64 vlan:12;
546 u64 priority:3;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700547 u64 csum_verified:3; /** checksum verified. */
548 u64 has_hwtstamp:1; /** Has hardware timestamp. 1 = yes. */
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700549 u64 encap_on:1;
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700550 u64 has_hash:1; /** Has hash (rth or rss). 1 = yes. */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700551 } r_dh;
552 struct {
553 u64 opcode:4;
554 u64 subcode:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700555 u64 len:3; /** additional 64-bit words */
556 u64 reserved:11;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700557 u64 num_gmx_ports:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700558 u64 max_nic_ports:10;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700559 u64 app_cap_flags:4;
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700560 u64 app_mode:8;
561 u64 pkind:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700562 } r_core_drv_init;
563 struct {
564 u64 opcode:4;
565 u64 subcode:8;
566 u64 len:3; /** additional 64-bit words */
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700567 u64 reserved:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700568 u64 extra:25;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700569 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700570 } r_nic_info;
571#else
572 u64 u64;
573 struct {
574 u64 ossp:32; /** opcode/subcode specific parameters */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700575 u64 reserved:17;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700576 u64 len:3; /** additional 64-bit words */
577 u64 subcode:8;
578 u64 opcode:4;
579 } r;
580 struct {
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700581 u64 has_hash:1; /** Has hash (rth or rss). 1 = yes. */
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700582 u64 encap_on:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700583 u64 has_hwtstamp:1; /** 1 = has hwtstamp */
584 u64 csum_verified:3; /** checksum verified. */
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700585 u64 priority:3;
586 u64 vlan:12;
587 u64 extra:28;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700588 u64 len:3; /** additional 64-bit words */
589 u64 subcode:8;
590 u64 opcode:4;
591 } r_dh;
592 struct {
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700593 u64 pkind:8;
594 u64 app_mode:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700595 u64 app_cap_flags:4;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700596 u64 max_nic_ports:10;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700597 u64 num_gmx_ports:8;
Raghu Vatsavayi0da0b772016-06-21 22:53:04 -0700598 u64 reserved:11;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700599 u64 len:3; /** additional 64-bit words */
600 u64 subcode:8;
601 u64 opcode:4;
602 } r_core_drv_init;
603 struct {
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700604 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700605 u64 extra:25;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700606 u64 reserved:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700607 u64 len:3; /** additional 64-bit words */
608 u64 subcode:8;
609 u64 opcode:4;
610 } r_nic_info;
611#endif
612};
613
614#define OCT_RH_SIZE (sizeof(union octeon_rh))
615
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700616union octnic_packet_params {
617 u32 u32;
618 struct {
619#ifdef __BIG_ENDIAN_BITFIELD
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700620 u32 reserved:24;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700621 u32 ip_csum:1; /* Perform IP header checksum(s) */
622 /* Perform Outer transport header checksum */
623 u32 transport_csum:1;
624 /* Find tunnel, and perform transport csum. */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700625 u32 tnl_csum:1;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700626 u32 tsflag:1; /* Timestamp this packet */
627 u32 ipsec_ops:4; /* IPsec operation */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700628#else
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700629 u32 ipsec_ops:4;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700630 u32 tsflag:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700631 u32 tnl_csum:1;
Raghu Vatsavayi7275ebf2016-06-14 16:54:49 -0700632 u32 transport_csum:1;
633 u32 ip_csum:1;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700634 u32 reserved:24;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700635#endif
636 } s;
637};
638
639/** Status of a RGMII Link on Octeon as seen by core driver. */
640union oct_link_status {
641 u64 u64;
642
643 struct {
644#ifdef __BIG_ENDIAN_BITFIELD
645 u64 duplex:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700646 u64 mtu:16;
647 u64 speed:16;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700648 u64 link_up:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700649 u64 autoneg:1;
Raghu Vatsavayi9eb60842016-06-21 22:53:12 -0700650 u64 if_mode:5;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700651 u64 pause:1;
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700652 u64 flashing:1;
653 u64 reserved:15;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700654#else
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700655 u64 reserved:15;
656 u64 flashing:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700657 u64 pause:1;
Raghu Vatsavayi9eb60842016-06-21 22:53:12 -0700658 u64 if_mode:5;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700659 u64 autoneg:1;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700660 u64 link_up:1;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700661 u64 speed:16;
662 u64 mtu:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700663 u64 duplex:8;
664#endif
665 } s;
666};
667
Raghu Vatsavayi26236fa2016-06-14 16:54:44 -0700668/** The txpciq info passed to host from the firmware */
669
670union oct_txpciq {
671 u64 u64;
672
673 struct {
674#ifdef __BIG_ENDIAN_BITFIELD
675 u64 q_no:8;
676 u64 port:8;
677 u64 pkind:6;
678 u64 use_qpg:1;
679 u64 qpg:11;
680 u64 reserved:30;
681#else
682 u64 reserved:30;
683 u64 qpg:11;
684 u64 use_qpg:1;
685 u64 pkind:6;
686 u64 port:8;
687 u64 q_no:8;
688#endif
689 } s;
690};
691
692/** The rxpciq info passed to host from the firmware */
693
694union oct_rxpciq {
695 u64 u64;
696
697 struct {
698#ifdef __BIG_ENDIAN_BITFIELD
699 u64 q_no:8;
700 u64 reserved:56;
701#else
702 u64 reserved:56;
703 u64 q_no:8;
704#endif
705 } s;
706};
707
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700708/** Information for a OCTEON ethernet interface shared between core & host. */
709struct oct_link_info {
710 union oct_link_status link;
711 u64 hw_addr;
712
713#ifdef __BIG_ENDIAN_BITFIELD
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700714 u64 gmxport:16;
Raghu Vatsavayi8c978d02016-11-14 15:54:41 -0800715 u64 macaddr_is_admin_asgnd:1;
716 u64 rsvd:31;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700717 u64 num_txpciq:8;
718 u64 num_rxpciq:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700719#else
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700720 u64 num_rxpciq:8;
721 u64 num_txpciq:8;
Raghu Vatsavayi8c978d02016-11-14 15:54:41 -0800722 u64 rsvd:31;
723 u64 macaddr_is_admin_asgnd:1;
Raghu Vatsavayi0cece6c2016-06-14 16:54:50 -0700724 u64 gmxport:16;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700725#endif
726
Raghu Vatsavayi26236fa2016-06-14 16:54:44 -0700727 union oct_txpciq txpciq[MAX_IOQS_PER_NICIF];
728 union oct_rxpciq rxpciq[MAX_IOQS_PER_NICIF];
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700729};
730
731#define OCT_LINK_INFO_SIZE (sizeof(struct oct_link_info))
732
733struct liquidio_if_cfg_info {
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700734 u64 iqmask; /** mask for IQs enabled for the port */
735 u64 oqmask; /** mask for OQs enabled for the port */
736 struct oct_link_info linfo; /** initial link information */
Raghu Vatsavayid3d7e6c2016-06-21 22:53:07 -0700737 char liquidio_firmware_version[32];
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700738};
739
740/** Stats for each NIC port in RX direction. */
741struct nic_rx_stats {
742 /* link-level stats */
743 u64 total_rcvd;
744 u64 bytes_rcvd;
745 u64 total_bcst;
746 u64 total_mcst;
747 u64 runts;
748 u64 ctl_rcvd;
749 u64 fifo_err; /* Accounts for over/under-run of buffers */
750 u64 dmac_drop;
751 u64 fcs_err;
752 u64 jabber_err;
753 u64 l2_err;
754 u64 frame_err;
755
756 /* firmware stats */
757 u64 fw_total_rcvd;
758 u64 fw_total_fwd;
759 u64 fw_err_pko;
760 u64 fw_err_link;
761 u64 fw_err_drop;
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700762 u64 fw_rx_vxlan;
763 u64 fw_rx_vxlan_err;
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700764
765 /* LRO */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700766 u64 fw_lro_pkts; /* Number of packets that are LROed */
767 u64 fw_lro_octs; /* Number of octets that are LROed */
768 u64 fw_total_lro; /* Number of LRO packets formed */
769 u64 fw_lro_aborts; /* Number of times lRO of packet aborted */
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700770 u64 fw_lro_aborts_port;
771 u64 fw_lro_aborts_seq;
772 u64 fw_lro_aborts_tsval;
773 u64 fw_lro_aborts_timer;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700774 /* intrmod: packet forward rate */
775 u64 fwd_rate;
776};
777
778/** Stats for each NIC port in RX direction. */
779struct nic_tx_stats {
780 /* link-level stats */
781 u64 total_pkts_sent;
782 u64 total_bytes_sent;
783 u64 mcast_pkts_sent;
784 u64 bcast_pkts_sent;
785 u64 ctl_sent;
786 u64 one_collision_sent; /* Packets sent after one collision*/
787 u64 multi_collision_sent; /* Packets sent after multiple collision*/
788 u64 max_collision_fail; /* Packets not sent due to max collisions */
789 u64 max_deferral_fail; /* Packets not sent due to max deferrals */
790 u64 fifo_err; /* Accounts for over/under-run of buffers */
791 u64 runts;
792 u64 total_collisions; /* Total number of collisions detected */
793
794 /* firmware stats */
795 u64 fw_total_sent;
796 u64 fw_total_fwd;
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700797 u64 fw_total_fwd_bytes;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700798 u64 fw_err_pko;
799 u64 fw_err_link;
800 u64 fw_err_drop;
Raghu Vatsavayi1f164712016-06-21 22:53:11 -0700801 u64 fw_err_tso;
802 u64 fw_tso; /* number of tso requests */
803 u64 fw_tso_fwd; /* number of packets segmented in tso */
Raghu Vatsavayi01fb2372016-07-03 13:56:47 -0700804 u64 fw_tx_vxlan;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700805};
806
807struct oct_link_stats {
808 struct nic_rx_stats fromwire;
809 struct nic_tx_stats fromhost;
810
811};
812
Raghu Vatsavayi97a25322016-11-14 15:54:47 -0800813static inline int opcode_slow_path(union octeon_rh *rh)
814{
815 u16 subcode1, subcode2;
816
817 subcode1 = OPCODE_SUBCODE((rh)->r.opcode, (rh)->r.subcode);
818 subcode2 = OPCODE_SUBCODE(OPCODE_NIC, OPCODE_NIC_NW_DATA);
819
820 return (subcode2 != subcode1);
821}
822
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700823#define LIO68XX_LED_CTRL_ADDR 0x3501
824#define LIO68XX_LED_CTRL_CFGON 0x1f
825#define LIO68XX_LED_CTRL_CFGOFF 0x100
826#define LIO68XX_LED_BEACON_ADDR 0x3508
827#define LIO68XX_LED_BEACON_CFGON 0x47fd
828#define LIO68XX_LED_BEACON_CFGOFF 0x11fc
829#define VITESSE_PHY_GPIO_DRIVEON 0x1
830#define VITESSE_PHY_GPIO_CFG 0x8
831#define VITESSE_PHY_GPIO_DRIVEOFF 0x4
832#define VITESSE_PHY_GPIO_HIGH 0x2
833#define VITESSE_PHY_GPIO_LOW 0x3
Raghu Vatsavayidc3abcb2016-09-01 11:16:08 -0700834#define LED_IDENTIFICATION_ON 0x1
835#define LED_IDENTIFICATION_OFF 0x0
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700836
837struct oct_mdio_cmd {
838 u64 op;
839 u64 mdio_addr;
840 u64 value1;
841 u64 value2;
842 u64 value3;
843};
844
845#define OCT_LINK_STATS_SIZE (sizeof(struct oct_link_stats))
846
Raghu Vatsavayi78e6a9b2016-06-21 22:53:10 -0700847/* intrmod: max. packet rate threshold */
848#define LIO_INTRMOD_MAXPKT_RATETHR 196608
849/* intrmod: min. packet rate threshold */
850#define LIO_INTRMOD_MINPKT_RATETHR 9216
851/* intrmod: max. packets to trigger interrupt */
852#define LIO_INTRMOD_RXMAXCNT_TRIGGER 384
853/* intrmod: min. packets to trigger interrupt */
Raghu Vatsavayicd8b1eb2016-08-31 11:03:22 -0700854#define LIO_INTRMOD_RXMINCNT_TRIGGER 0
Raghu Vatsavayi78e6a9b2016-06-21 22:53:10 -0700855/* intrmod: max. time to trigger interrupt */
856#define LIO_INTRMOD_RXMAXTMR_TRIGGER 128
857/* 66xx:intrmod: min. time to trigger interrupt
858 * (value of 1 is optimum for TCP_RR)
859 */
860#define LIO_INTRMOD_RXMINTMR_TRIGGER 1
861
862/* intrmod: max. packets to trigger interrupt */
863#define LIO_INTRMOD_TXMAXCNT_TRIGGER 64
864/* intrmod: min. packets to trigger interrupt */
865#define LIO_INTRMOD_TXMINCNT_TRIGGER 0
866
867/* intrmod: poll interval in seconds */
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700868#define LIO_INTRMOD_CHECK_INTERVAL 1
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700869
870struct oct_intrmod_cfg {
Raghu Vatsavayi78e6a9b2016-06-21 22:53:10 -0700871 u64 rx_enable;
872 u64 tx_enable;
873 u64 check_intrvl;
874 u64 maxpkt_ratethr;
875 u64 minpkt_ratethr;
876 u64 rx_maxcnt_trigger;
877 u64 rx_mincnt_trigger;
878 u64 rx_maxtmr_trigger;
879 u64 rx_mintmr_trigger;
880 u64 tx_mincnt_trigger;
881 u64 tx_maxcnt_trigger;
882 u64 rx_frames;
883 u64 tx_frames;
884 u64 rx_usecs;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700885};
886
887#define BASE_QUEUE_NOT_REQUESTED 65535
888
889union oct_nic_if_cfg {
890 u64 u64;
891 struct {
892#ifdef __BIG_ENDIAN_BITFIELD
893 u64 base_queue:16;
894 u64 num_iqueues:16;
895 u64 num_oqueues:16;
896 u64 gmx_port_id:8;
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700897 u64 vf_id:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700898#else
Raghu Vatsavayi9fbc48f2016-07-03 13:56:56 -0700899 u64 vf_id:8;
Raghu Vatsavayif21fb3e2015-06-09 18:15:23 -0700900 u64 gmx_port_id:8;
901 u64 num_oqueues:16;
902 u64 num_iqueues:16;
903 u64 base_queue:16;
904#endif
905 } s;
906};
907
908#endif