]> asedeno.scripts.mit.edu Git - linux.git/blob - drivers/net/ethernet/cavium/liquidio/liquidio_common.h
liquidio CN23XX: code cleanup
[linux.git] / drivers / net / ethernet / cavium / liquidio / liquidio_common.h
1 /**********************************************************************
2 * Author: Cavium, Inc.
3 *
4 * Contact: support@cavium.com
5 *          Please include "LiquidIO" in the subject.
6 *
7 * Copyright (c) 2003-2015 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
17 * details.
18 *
19 * This file may also be available under a different license from Cavium.
20 * Contact Cavium, Inc. for more information
21 **********************************************************************/
22
23 /*!  \file  liquidio_common.h
24  *   \brief Common: Structures and macros used in PCI-NIC package by core and
25  *   host driver.
26  */
27
28 #ifndef __LIQUIDIO_COMMON_H__
29 #define __LIQUIDIO_COMMON_H__
30
31 #include "octeon_config.h"
32
33 #define LIQUIDIO_PACKAGE ""
34 #define LIQUIDIO_BASE_MAJOR_VERSION 1
35 #define LIQUIDIO_BASE_MINOR_VERSION 4
36 #define LIQUIDIO_BASE_MICRO_VERSION 1
37 #define LIQUIDIO_BASE_VERSION   __stringify(LIQUIDIO_BASE_MAJOR_VERSION) "." \
38                                 __stringify(LIQUIDIO_BASE_MINOR_VERSION)
39 #define LIQUIDIO_MICRO_VERSION  "." __stringify(LIQUIDIO_BASE_MICRO_VERSION)
40 #define LIQUIDIO_VERSION        LIQUIDIO_PACKAGE \
41                                 __stringify(LIQUIDIO_BASE_MAJOR_VERSION) "." \
42                                 __stringify(LIQUIDIO_BASE_MINOR_VERSION) \
43                                 "." __stringify(LIQUIDIO_BASE_MICRO_VERSION)
44
45 struct lio_version {
46         u16  major;
47         u16  minor;
48         u16  micro;
49         u16  reserved;
50 };
51
52 #define CONTROL_IQ 0
53 /** Tag types used by Octeon cores in its work. */
54 enum octeon_tag_type {
55         ORDERED_TAG = 0,
56         ATOMIC_TAG = 1,
57         NULL_TAG = 2,
58         NULL_NULL_TAG = 3
59 };
60
61 /* pre-defined host->NIC tag values */
62 #define LIO_CONTROL  (0x11111110)
63 #define LIO_DATA(i)  (0x11111111 + (i))
64
65 /* Opcodes used by host driver/apps to perform operations on the core.
66  * These are used to identify the major subsystem that the operation
67  * is for.
68  */
69 #define OPCODE_CORE 0           /* used for generic core operations */
70 #define OPCODE_NIC  1           /* used for NIC operations */
71 /* Subcodes are used by host driver/apps to identify the sub-operation
72  * for the core. They only need to by unique for a given subsystem.
73  */
74 #define OPCODE_SUBCODE(op, sub)       (((op & 0x0f) << 8) | ((sub) & 0x7f))
75
76 /** OPCODE_CORE subcodes. For future use. */
77
78 /** OPCODE_NIC subcodes */
79
80 /* This subcode is sent by core PCI driver to indicate cores are ready. */
81 #define OPCODE_NIC_CORE_DRV_ACTIVE     0x01
82 #define OPCODE_NIC_NW_DATA             0x02     /* network packet data */
83 #define OPCODE_NIC_CMD                 0x03
84 #define OPCODE_NIC_INFO                0x04
85 #define OPCODE_NIC_PORT_STATS          0x05
86 #define OPCODE_NIC_MDIO45              0x06
87 #define OPCODE_NIC_TIMESTAMP           0x07
88 #define OPCODE_NIC_INTRMOD_CFG         0x08
89 #define OPCODE_NIC_IF_CFG              0x09
90 #define OPCODE_NIC_VF_DRV_NOTICE       0x0A
91 #define VF_DRV_LOADED                  1
92 #define VF_DRV_REMOVED                -1
93 #define VF_DRV_MACADDR_CHANGED         2
94
95 #define CORE_DRV_TEST_SCATTER_OP    0xFFF5
96
97 #define OPCODE_SLOW_PATH(rh)  \
98         (OPCODE_SUBCODE(rh->r.opcode, rh->r.subcode) != \
99                 OPCODE_SUBCODE(OPCODE_NIC, OPCODE_NIC_NW_DATA))
100
101 /* Application codes advertised by the core driver initialization packet. */
102 #define CVM_DRV_APP_START           0x0
103 #define CVM_DRV_NO_APP              0
104 #define CVM_DRV_APP_COUNT           0x2
105 #define CVM_DRV_BASE_APP            (CVM_DRV_APP_START + 0x0)
106 #define CVM_DRV_NIC_APP             (CVM_DRV_APP_START + 0x1)
107 #define CVM_DRV_INVALID_APP         (CVM_DRV_APP_START + 0x2)
108 #define CVM_DRV_APP_END             (CVM_DRV_INVALID_APP - 1)
109
110 /* Macro to increment index.
111  * Index is incremented by count; if the sum exceeds
112  * max, index is wrapped-around to the start.
113  */
114 #define INCR_INDEX(index, count, max)                \
115 do {                                                 \
116         if (((index) + (count)) >= (max))            \
117                 index = ((index) + (count)) - (max); \
118         else                                         \
119                 index += (count);                    \
120 } while (0)
121
122 #define INCR_INDEX_BY1(index, max)      \
123 do {                                    \
124         if ((++(index)) == (max))       \
125                 index = 0;              \
126 } while (0)
127
128 #define DECR_INDEX(index, count, max)                  \
129 do {                                                   \
130         if ((count) > (index))                         \
131                 index = ((max) - ((count - index)));   \
132         else                                           \
133                 index -= count;                        \
134 } while (0)
135
136 #define OCT_BOARD_NAME 32
137 #define OCT_SERIAL_LEN 64
138
139 /* Structure used by core driver to send indication that the Octeon
140  * application is ready.
141  */
142 struct octeon_core_setup {
143         u64 corefreq;
144
145         char boardname[OCT_BOARD_NAME];
146
147         char board_serial_number[OCT_SERIAL_LEN];
148
149         u64 board_rev_major;
150
151         u64 board_rev_minor;
152
153 };
154
155 /*---------------------------  SCATTER GATHER ENTRY  -----------------------*/
156
157 /* The Scatter-Gather List Entry. The scatter or gather component used with
158  * a Octeon input instruction has this format.
159  */
160 struct octeon_sg_entry {
161         /** The first 64 bit gives the size of data in each dptr.*/
162         union {
163                 u16 size[4];
164                 u64 size64;
165         } u;
166
167         /** The 4 dptr pointers for this entry. */
168         u64 ptr[4];
169
170 };
171
172 #define OCT_SG_ENTRY_SIZE    (sizeof(struct octeon_sg_entry))
173
174 /* \brief Add size to gather list
175  * @param sg_entry scatter/gather entry
176  * @param size size to add
177  * @param pos position to add it.
178  */
179 static inline void add_sg_size(struct octeon_sg_entry *sg_entry,
180                                u16 size,
181                                u32 pos)
182 {
183 #ifdef __BIG_ENDIAN_BITFIELD
184         sg_entry->u.size[pos] = size;
185 #else
186         sg_entry->u.size[3 - pos] = size;
187 #endif
188 }
189
190 /*------------------------- End Scatter/Gather ---------------------------*/
191
192 #define   OCTNET_FRM_PTP_HEADER_SIZE  8
193
194 #define   OCTNET_FRM_HEADER_SIZE     22 /* VLAN + Ethernet */
195
196 #define   OCTNET_MIN_FRM_SIZE        64
197
198 #define   OCTNET_MAX_FRM_SIZE        (16000 + OCTNET_FRM_HEADER_SIZE)
199
200 #define   OCTNET_DEFAULT_FRM_SIZE    (1500 + OCTNET_FRM_HEADER_SIZE)
201
202 /** NIC Commands are sent using this Octeon Input Queue */
203 #define   OCTNET_CMD_Q                0
204
205 /* NIC Command types */
206 #define   OCTNET_CMD_CHANGE_MTU       0x1
207 #define   OCTNET_CMD_CHANGE_MACADDR   0x2
208 #define   OCTNET_CMD_CHANGE_DEVFLAGS  0x3
209 #define   OCTNET_CMD_RX_CTL           0x4
210
211 #define   OCTNET_CMD_SET_MULTI_LIST   0x5
212 #define   OCTNET_CMD_CLEAR_STATS      0x6
213
214 /* command for setting the speed, duplex & autoneg */
215 #define   OCTNET_CMD_SET_SETTINGS     0x7
216 #define   OCTNET_CMD_SET_FLOW_CTL     0x8
217
218 #define   OCTNET_CMD_MDIO_READ_WRITE  0x9
219 #define   OCTNET_CMD_GPIO_ACCESS      0xA
220 #define   OCTNET_CMD_LRO_ENABLE       0xB
221 #define   OCTNET_CMD_LRO_DISABLE      0xC
222 #define   OCTNET_CMD_SET_RSS          0xD
223 #define   OCTNET_CMD_WRITE_SA         0xE
224 #define   OCTNET_CMD_DELETE_SA        0xF
225 #define   OCTNET_CMD_UPDATE_SA        0x12
226
227 #define   OCTNET_CMD_TNL_RX_CSUM_CTL 0x10
228 #define   OCTNET_CMD_TNL_TX_CSUM_CTL 0x11
229 #define   OCTNET_CMD_IPSECV2_AH_ESP_CTL 0x13
230 #define   OCTNET_CMD_VERBOSE_ENABLE   0x14
231 #define   OCTNET_CMD_VERBOSE_DISABLE  0x15
232
233 #define   OCTNET_CMD_ENABLE_VLAN_FILTER 0x16
234 #define   OCTNET_CMD_ADD_VLAN_FILTER  0x17
235 #define   OCTNET_CMD_DEL_VLAN_FILTER  0x18
236 #define   OCTNET_CMD_VXLAN_PORT_CONFIG 0x19
237
238 #define   OCTNET_CMD_ID_ACTIVE         0x1a
239
240 #define   OCTNET_CMD_SET_VF_LINKSTATE  0x1c
241 #define   OCTNET_CMD_VXLAN_PORT_ADD    0x0
242 #define   OCTNET_CMD_VXLAN_PORT_DEL    0x1
243 #define   OCTNET_CMD_RXCSUM_ENABLE     0x0
244 #define   OCTNET_CMD_RXCSUM_DISABLE    0x1
245 #define   OCTNET_CMD_TXCSUM_ENABLE     0x0
246 #define   OCTNET_CMD_TXCSUM_DISABLE    0x1
247
248 /* RX(packets coming from wire) Checksum verification flags */
249 /* TCP/UDP csum */
250 #define   CNNIC_L4SUM_VERIFIED             0x1
251 #define   CNNIC_IPSUM_VERIFIED             0x2
252 #define   CNNIC_TUN_CSUM_VERIFIED          0x4
253 #define   CNNIC_CSUM_VERIFIED (CNNIC_IPSUM_VERIFIED | CNNIC_L4SUM_VERIFIED)
254
255 /*LROIPV4 and LROIPV6 Flags*/
256 #define   OCTNIC_LROIPV4    0x1
257 #define   OCTNIC_LROIPV6    0x2
258
259 /* Interface flags communicated between host driver and core app. */
260 enum octnet_ifflags {
261         OCTNET_IFFLAG_PROMISC   = 0x01,
262         OCTNET_IFFLAG_ALLMULTI  = 0x02,
263         OCTNET_IFFLAG_MULTICAST = 0x04,
264         OCTNET_IFFLAG_BROADCAST = 0x08,
265         OCTNET_IFFLAG_UNICAST   = 0x10
266 };
267
268 /*   wqe
269  *  ---------------  0
270  * |  wqe  word0-3 |
271  *  ---------------  32
272  * |    PCI IH     |
273  *  ---------------  40
274  * |     RPTR      |
275  *  ---------------  48
276  * |    PCI IRH    |
277  *  ---------------  56
278  * |  OCT_NET_CMD  |
279  *  ---------------  64
280  * | Addtl 8-BData |
281  * |               |
282  *  ---------------
283  */
284
285 union octnet_cmd {
286         u64 u64;
287
288         struct {
289 #ifdef __BIG_ENDIAN_BITFIELD
290                 u64 cmd:5;
291
292                 u64 more:6; /* How many udd words follow the command */
293
294                 u64 reserved:29;
295
296                 u64 param1:16;
297
298                 u64 param2:8;
299
300 #else
301
302                 u64 param2:8;
303
304                 u64 param1:16;
305
306                 u64 reserved:29;
307
308                 u64 more:6;
309
310                 u64 cmd:5;
311
312 #endif
313         } s;
314
315 };
316
317 #define   OCTNET_CMD_SIZE     (sizeof(union octnet_cmd))
318
319 /*pkiih3 + irh + ossp[0] + ossp[1] + rdp + rptr = 40 bytes */
320 #define LIO_SOFTCMDRESP_IH2       40
321 #define LIO_SOFTCMDRESP_IH3       (40 + 8)
322
323 #define LIO_PCICMD_O2             24
324 #define LIO_PCICMD_O3             (24 + 8)
325
326 /* Instruction Header(DPI) - for OCTEON-III models */
327 struct  octeon_instr_ih3 {
328 #ifdef __BIG_ENDIAN_BITFIELD
329
330         /** Reserved3 */
331         u64     reserved3:1;
332
333         /** Gather indicator 1=gather*/
334         u64     gather:1;
335
336         /** Data length OR no. of entries in gather list */
337         u64     dlengsz:14;
338
339         /** Front Data size */
340         u64     fsz:6;
341
342         /** Reserved2 */
343         u64     reserved2:4;
344
345         /** PKI port kind - PKIND */
346         u64     pkind:6;
347
348         /** Reserved1 */
349         u64     reserved1:32;
350
351 #else
352         /** Reserved1 */
353         u64     reserved1:32;
354
355         /** PKI port kind - PKIND */
356         u64     pkind:6;
357
358         /** Reserved2 */
359         u64     reserved2:4;
360
361         /** Front Data size */
362         u64     fsz:6;
363
364         /** Data length OR no. of entries in gather list */
365         u64     dlengsz:14;
366
367         /** Gather indicator 1=gather*/
368         u64     gather:1;
369
370         /** Reserved3 */
371         u64     reserved3:1;
372
373 #endif
374 };
375
376 /* Optional PKI Instruction Header(PKI IH) - for OCTEON-III models */
377 /** BIG ENDIAN format.   */
378 struct  octeon_instr_pki_ih3 {
379 #ifdef __BIG_ENDIAN_BITFIELD
380
381         /** Wider bit */
382         u64     w:1;
383
384         /** Raw mode indicator 1 = RAW */
385         u64     raw:1;
386
387         /** Use Tag */
388         u64     utag:1;
389
390         /** Use QPG */
391         u64     uqpg:1;
392
393         /** Reserved2 */
394         u64     reserved2:1;
395
396         /** Parse Mode */
397         u64     pm:3;
398
399         /** Skip Length */
400         u64     sl:8;
401
402         /** Use Tag Type */
403         u64     utt:1;
404
405         /** Tag type */
406         u64     tagtype:2;
407
408         /** Reserved1 */
409         u64     reserved1:2;
410
411         /** QPG Value */
412         u64     qpg:11;
413
414         /** Tag Value */
415         u64     tag:32;
416
417 #else
418
419         /** Tag Value */
420         u64     tag:32;
421
422         /** QPG Value */
423         u64     qpg:11;
424
425         /** Reserved1 */
426         u64     reserved1:2;
427
428         /** Tag type */
429         u64     tagtype:2;
430
431         /** Use Tag Type */
432         u64     utt:1;
433
434         /** Skip Length */
435         u64     sl:8;
436
437         /** Parse Mode */
438         u64     pm:3;
439
440         /** Reserved2 */
441         u64     reserved2:1;
442
443         /** Use QPG */
444         u64     uqpg:1;
445
446         /** Use Tag */
447         u64     utag:1;
448
449         /** Raw mode indicator 1 = RAW */
450         u64     raw:1;
451
452         /** Wider bit */
453         u64     w:1;
454 #endif
455
456 };
457
458 /** Instruction Header */
459 struct octeon_instr_ih2 {
460 #ifdef __BIG_ENDIAN_BITFIELD
461         /** Raw mode indicator 1 = RAW */
462         u64 raw:1;
463
464         /** Gather indicator 1=gather*/
465         u64 gather:1;
466
467         /** Data length OR no. of entries in gather list */
468         u64 dlengsz:14;
469
470         /** Front Data size */
471         u64 fsz:6;
472
473         /** Packet Order / Work Unit selection (1 of 8)*/
474         u64 qos:3;
475
476         /** Core group selection (1 of 16) */
477         u64 grp:4;
478
479         /** Short Raw Packet Indicator 1=short raw pkt */
480         u64 rs:1;
481
482         /** Tag type */
483         u64 tagtype:2;
484
485         /** Tag Value */
486         u64 tag:32;
487 #else
488         /** Tag Value */
489         u64 tag:32;
490
491         /** Tag type */
492         u64 tagtype:2;
493
494         /** Short Raw Packet Indicator 1=short raw pkt */
495         u64 rs:1;
496
497         /** Core group selection (1 of 16) */
498         u64 grp:4;
499
500         /** Packet Order / Work Unit selection (1 of 8)*/
501         u64 qos:3;
502
503         /** Front Data size */
504         u64 fsz:6;
505
506         /** Data length OR no. of entries in gather list */
507         u64 dlengsz:14;
508
509         /** Gather indicator 1=gather*/
510         u64 gather:1;
511
512         /** Raw mode indicator 1 = RAW */
513         u64 raw:1;
514 #endif
515 };
516
517 /** Input Request Header */
518 struct octeon_instr_irh {
519 #ifdef __BIG_ENDIAN_BITFIELD
520         u64 opcode:4;
521         u64 rflag:1;
522         u64 subcode:7;
523         u64 vlan:12;
524         u64 priority:3;
525         u64 reserved:5;
526         u64 ossp:32;             /* opcode/subcode specific parameters */
527 #else
528         u64 ossp:32;             /* opcode/subcode specific parameters */
529         u64 reserved:5;
530         u64 priority:3;
531         u64 vlan:12;
532         u64 subcode:7;
533         u64 rflag:1;
534         u64 opcode:4;
535 #endif
536 };
537
538 /** Return Data Parameters */
539 struct octeon_instr_rdp {
540 #ifdef __BIG_ENDIAN_BITFIELD
541         u64 reserved:49;
542         u64 pcie_port:3;
543         u64 rlen:12;
544 #else
545         u64 rlen:12;
546         u64 pcie_port:3;
547         u64 reserved:49;
548 #endif
549 };
550
551 /** Receive Header */
552 union octeon_rh {
553 #ifdef __BIG_ENDIAN_BITFIELD
554         u64 u64;
555         struct {
556                 u64 opcode:4;
557                 u64 subcode:8;
558                 u64 len:3;     /** additional 64-bit words */
559                 u64 reserved:17;
560                 u64 ossp:32;   /** opcode/subcode specific parameters */
561         } r;
562         struct {
563                 u64 opcode:4;
564                 u64 subcode:8;
565                 u64 len:3;     /** additional 64-bit words */
566                 u64 extra:28;
567                 u64 vlan:12;
568                 u64 priority:3;
569                 u64 csum_verified:3;     /** checksum verified. */
570                 u64 has_hwtstamp:1;      /** Has hardware timestamp. 1 = yes. */
571                 u64 encap_on:1;
572                 u64 has_hash:1;          /** Has hash (rth or rss). 1 = yes. */
573         } r_dh;
574         struct {
575                 u64 opcode:4;
576                 u64 subcode:8;
577                 u64 len:3;     /** additional 64-bit words */
578                 u64 reserved:11;
579                 u64 num_gmx_ports:8;
580                 u64 max_nic_ports:10;
581                 u64 app_cap_flags:4;
582                 u64 app_mode:8;
583                 u64 pkind:8;
584         } r_core_drv_init;
585         struct {
586                 u64 opcode:4;
587                 u64 subcode:8;
588                 u64 len:3;       /** additional 64-bit words */
589                 u64 reserved:8;
590                 u64 extra:25;
591                 u64 gmxport:16;
592         } r_nic_info;
593 #else
594         u64 u64;
595         struct {
596                 u64 ossp:32;  /** opcode/subcode specific parameters */
597                 u64 reserved:17;
598                 u64 len:3;    /** additional 64-bit words */
599                 u64 subcode:8;
600                 u64 opcode:4;
601         } r;
602         struct {
603                 u64 has_hash:1;          /** Has hash (rth or rss). 1 = yes. */
604                 u64 encap_on:1;
605                 u64 has_hwtstamp:1;      /** 1 = has hwtstamp */
606                 u64 csum_verified:3;     /** checksum verified. */
607                 u64 priority:3;
608                 u64 vlan:12;
609                 u64 extra:28;
610                 u64 len:3;    /** additional 64-bit words */
611                 u64 subcode:8;
612                 u64 opcode:4;
613         } r_dh;
614         struct {
615                 u64 pkind:8;
616                 u64 app_mode:8;
617                 u64 app_cap_flags:4;
618                 u64 max_nic_ports:10;
619                 u64 num_gmx_ports:8;
620                 u64 reserved:11;
621                 u64 len:3;       /** additional 64-bit words */
622                 u64 subcode:8;
623                 u64 opcode:4;
624         } r_core_drv_init;
625         struct {
626                 u64 gmxport:16;
627                 u64 extra:25;
628                 u64 reserved:8;
629                 u64 len:3;       /** additional 64-bit words */
630                 u64 subcode:8;
631                 u64 opcode:4;
632         } r_nic_info;
633 #endif
634 };
635
636 #define  OCT_RH_SIZE   (sizeof(union  octeon_rh))
637
638 union octnic_packet_params {
639         u32 u32;
640         struct {
641 #ifdef __BIG_ENDIAN_BITFIELD
642                 u32 reserved:24;
643                 u32 ip_csum:1;          /* Perform IP header checksum(s) */
644                 /* Perform Outer transport header checksum */
645                 u32 transport_csum:1;
646                 /* Find tunnel, and perform transport csum. */
647                 u32 tnl_csum:1;
648                 u32 tsflag:1;           /* Timestamp this packet */
649                 u32 ipsec_ops:4;        /* IPsec operation */
650 #else
651                 u32 ipsec_ops:4;
652                 u32 tsflag:1;
653                 u32 tnl_csum:1;
654                 u32 transport_csum:1;
655                 u32 ip_csum:1;
656                 u32 reserved:24;
657 #endif
658         } s;
659 };
660
661 /** Status of a RGMII Link on Octeon as seen by core driver. */
662 union oct_link_status {
663         u64 u64;
664
665         struct {
666 #ifdef __BIG_ENDIAN_BITFIELD
667                 u64 duplex:8;
668                 u64 mtu:16;
669                 u64 speed:16;
670                 u64 link_up:1;
671                 u64 autoneg:1;
672                 u64 if_mode:5;
673                 u64 pause:1;
674                 u64 flashing:1;
675                 u64 reserved:15;
676 #else
677                 u64 reserved:15;
678                 u64 flashing:1;
679                 u64 pause:1;
680                 u64 if_mode:5;
681                 u64 autoneg:1;
682                 u64 link_up:1;
683                 u64 speed:16;
684                 u64 mtu:16;
685                 u64 duplex:8;
686 #endif
687         } s;
688 };
689
690 /** The txpciq info passed to host from the firmware */
691
692 union oct_txpciq {
693         u64 u64;
694
695         struct {
696 #ifdef __BIG_ENDIAN_BITFIELD
697                 u64 q_no:8;
698                 u64 port:8;
699                 u64 pkind:6;
700                 u64 use_qpg:1;
701                 u64 qpg:11;
702                 u64 reserved:30;
703 #else
704                 u64 reserved:30;
705                 u64 qpg:11;
706                 u64 use_qpg:1;
707                 u64 pkind:6;
708                 u64 port:8;
709                 u64 q_no:8;
710 #endif
711         } s;
712 };
713
714 /** The rxpciq info passed to host from the firmware */
715
716 union oct_rxpciq {
717         u64 u64;
718
719         struct {
720 #ifdef __BIG_ENDIAN_BITFIELD
721                 u64 q_no:8;
722                 u64 reserved:56;
723 #else
724                 u64 reserved:56;
725                 u64 q_no:8;
726 #endif
727         } s;
728 };
729
730 /** Information for a OCTEON ethernet interface shared between core & host. */
731 struct oct_link_info {
732         union oct_link_status link;
733         u64 hw_addr;
734
735 #ifdef __BIG_ENDIAN_BITFIELD
736         u64 gmxport:16;
737         u64 macaddr_is_admin_asgnd:1;
738         u64 rsvd:31;
739         u64 num_txpciq:8;
740         u64 num_rxpciq:8;
741 #else
742         u64 num_rxpciq:8;
743         u64 num_txpciq:8;
744         u64 rsvd:31;
745         u64 macaddr_is_admin_asgnd:1;
746         u64 gmxport:16;
747 #endif
748
749         union oct_txpciq txpciq[MAX_IOQS_PER_NICIF];
750         union oct_rxpciq rxpciq[MAX_IOQS_PER_NICIF];
751 };
752
753 #define OCT_LINK_INFO_SIZE   (sizeof(struct oct_link_info))
754
755 struct liquidio_if_cfg_info {
756         u64 iqmask; /** mask for IQs enabled for  the port */
757         u64 oqmask; /** mask for OQs enabled for the port */
758         struct oct_link_info linfo; /** initial link information */
759         char   liquidio_firmware_version[32];
760 };
761
762 /** Stats for each NIC port in RX direction. */
763 struct nic_rx_stats {
764         /* link-level stats */
765         u64 total_rcvd;
766         u64 bytes_rcvd;
767         u64 total_bcst;
768         u64 total_mcst;
769         u64 runts;
770         u64 ctl_rcvd;
771         u64 fifo_err;      /* Accounts for over/under-run of buffers */
772         u64 dmac_drop;
773         u64 fcs_err;
774         u64 jabber_err;
775         u64 l2_err;
776         u64 frame_err;
777
778         /* firmware stats */
779         u64 fw_total_rcvd;
780         u64 fw_total_fwd;
781         u64 fw_err_pko;
782         u64 fw_err_link;
783         u64 fw_err_drop;
784         u64 fw_rx_vxlan;
785         u64 fw_rx_vxlan_err;
786
787         /* LRO */
788         u64 fw_lro_pkts;   /* Number of packets that are LROed      */
789         u64 fw_lro_octs;   /* Number of octets that are LROed       */
790         u64 fw_total_lro;  /* Number of LRO packets formed          */
791         u64 fw_lro_aborts; /* Number of times lRO of packet aborted */
792         u64 fw_lro_aborts_port;
793         u64 fw_lro_aborts_seq;
794         u64 fw_lro_aborts_tsval;
795         u64 fw_lro_aborts_timer;
796         /* intrmod: packet forward rate */
797         u64 fwd_rate;
798 };
799
800 /** Stats for each NIC port in RX direction. */
801 struct nic_tx_stats {
802         /* link-level stats */
803         u64 total_pkts_sent;
804         u64 total_bytes_sent;
805         u64 mcast_pkts_sent;
806         u64 bcast_pkts_sent;
807         u64 ctl_sent;
808         u64 one_collision_sent;   /* Packets sent after one collision*/
809         u64 multi_collision_sent; /* Packets sent after multiple collision*/
810         u64 max_collision_fail;   /* Packets not sent due to max collisions */
811         u64 max_deferral_fail;   /* Packets not sent due to max deferrals */
812         u64 fifo_err;       /* Accounts for over/under-run of buffers */
813         u64 runts;
814         u64 total_collisions; /* Total number of collisions detected */
815
816         /* firmware stats */
817         u64 fw_total_sent;
818         u64 fw_total_fwd;
819         u64 fw_total_fwd_bytes;
820         u64 fw_err_pko;
821         u64 fw_err_link;
822         u64 fw_err_drop;
823         u64 fw_err_tso;
824         u64 fw_tso;             /* number of tso requests */
825         u64 fw_tso_fwd;         /* number of packets segmented in tso */
826         u64 fw_tx_vxlan;
827 };
828
829 struct oct_link_stats {
830         struct nic_rx_stats fromwire;
831         struct nic_tx_stats fromhost;
832
833 };
834
835 #define LIO68XX_LED_CTRL_ADDR     0x3501
836 #define LIO68XX_LED_CTRL_CFGON    0x1f
837 #define LIO68XX_LED_CTRL_CFGOFF   0x100
838 #define LIO68XX_LED_BEACON_ADDR   0x3508
839 #define LIO68XX_LED_BEACON_CFGON  0x47fd
840 #define LIO68XX_LED_BEACON_CFGOFF 0x11fc
841 #define VITESSE_PHY_GPIO_DRIVEON  0x1
842 #define VITESSE_PHY_GPIO_CFG      0x8
843 #define VITESSE_PHY_GPIO_DRIVEOFF 0x4
844 #define VITESSE_PHY_GPIO_HIGH     0x2
845 #define VITESSE_PHY_GPIO_LOW      0x3
846 #define LED_IDENTIFICATION_ON     0x1
847 #define LED_IDENTIFICATION_OFF    0x0
848
849 struct oct_mdio_cmd {
850         u64 op;
851         u64 mdio_addr;
852         u64 value1;
853         u64 value2;
854         u64 value3;
855 };
856
857 #define OCT_LINK_STATS_SIZE   (sizeof(struct oct_link_stats))
858
859 /* intrmod: max. packet rate threshold */
860 #define LIO_INTRMOD_MAXPKT_RATETHR      196608
861 /* intrmod: min. packet rate threshold */
862 #define LIO_INTRMOD_MINPKT_RATETHR      9216
863 /* intrmod: max. packets to trigger interrupt */
864 #define LIO_INTRMOD_RXMAXCNT_TRIGGER    384
865 /* intrmod: min. packets to trigger interrupt */
866 #define LIO_INTRMOD_RXMINCNT_TRIGGER    0
867 /* intrmod: max. time to trigger interrupt */
868 #define LIO_INTRMOD_RXMAXTMR_TRIGGER    128
869 /* 66xx:intrmod: min. time to trigger interrupt
870  * (value of 1 is optimum for TCP_RR)
871  */
872 #define LIO_INTRMOD_RXMINTMR_TRIGGER    1
873
874 /* intrmod: max. packets to trigger interrupt */
875 #define LIO_INTRMOD_TXMAXCNT_TRIGGER    64
876 /* intrmod: min. packets to trigger interrupt */
877 #define LIO_INTRMOD_TXMINCNT_TRIGGER    0
878
879 /* intrmod: poll interval in seconds */
880 #define LIO_INTRMOD_CHECK_INTERVAL  1
881
882 struct oct_intrmod_cfg {
883         u64 rx_enable;
884         u64 tx_enable;
885         u64 check_intrvl;
886         u64 maxpkt_ratethr;
887         u64 minpkt_ratethr;
888         u64 rx_maxcnt_trigger;
889         u64 rx_mincnt_trigger;
890         u64 rx_maxtmr_trigger;
891         u64 rx_mintmr_trigger;
892         u64 tx_mincnt_trigger;
893         u64 tx_maxcnt_trigger;
894         u64 rx_frames;
895         u64 tx_frames;
896         u64 rx_usecs;
897 };
898
899 #define BASE_QUEUE_NOT_REQUESTED 65535
900
901 union oct_nic_if_cfg {
902         u64 u64;
903         struct {
904 #ifdef __BIG_ENDIAN_BITFIELD
905                 u64 base_queue:16;
906                 u64 num_iqueues:16;
907                 u64 num_oqueues:16;
908                 u64 gmx_port_id:8;
909                 u64 vf_id:8;
910 #else
911                 u64 vf_id:8;
912                 u64 gmx_port_id:8;
913                 u64 num_oqueues:16;
914                 u64 num_iqueues:16;
915                 u64 base_queue:16;
916 #endif
917         } s;
918 };
919
920 #endif