New upstream version 17.11-rc3
[deb_dpdk.git] / drivers / net / thunderx / base / nicvf_hw_defs.h
index 2f2b225..e7e092b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *   BSD LICENSE
  *
- *   Copyright (C) Cavium networks Ltd. 2016.
+ *   Copyright (C) Cavium, Inc. 2016.
  *
  *   Redistribution and use in source and binary forms, with or without
  *   modification, are permitted provided that the following conditions
@@ -13,7 +13,7 @@
  *       notice, this list of conditions and the following disclaimer in
  *       the documentation and/or other materials provided with the
  *       distribution.
- *     * Neither the name of Cavium networks nor the names of its
+ *     * Neither the name of Cavium, Inc nor the names of its
  *       contributors may be used to endorse or promote products derived
  *       from this software without specific prior written permission.
  *
@@ -36,6 +36,8 @@
 #include <stdint.h>
 #include <stdbool.h>
 
+#include "nicvf_plat.h"
+
 /* Virtual function register offsets */
 
 #define NIC_VF_CFG                      (0x000020)
 #define NICVF_INTR_MBOX_SHIFT           22
 #define NICVF_INTR_QS_ERR_SHIFT         23
 
+#define NICVF_QS_RQ_DIS_APAD_SHIFT      22
+
 #define NICVF_INTR_CQ_MASK              (0xFF << NICVF_INTR_CQ_SHIFT)
 #define NICVF_INTR_SQ_MASK              (0xFF << NICVF_INTR_SQ_SHIFT)
 #define NICVF_INTR_RBDR_MASK            (0x03 << NICVF_INTR_RBDR_SHIFT)
 #define NICVF_CQE_RX2_RBPTR_WORD        (7)
 
 #define NICVF_STATIC_ASSERT(s) _Static_assert(s, #s)
+#define assert_primary(nic) assert((nic)->sqs_mode == 0)
 
-typedef uint64_t nicvf_phys_addr_t;
-
-#ifndef __BYTE_ORDER__
-#error __BYTE_ORDER__ not defined
-#endif
+typedef uint64_t nicvf_iova_addr_t;
 
 /* vNIC HW Enumerations */
 
@@ -556,7 +557,7 @@ enum nic_stat_vnic_tx_e {
 typedef union {
        uint64_t u64;
        struct {
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#if NICVF_BYTE_ORDER == NICVF_BIG_ENDIAN
                uint64_t cqe_type:4;
                uint64_t stdn_fault:1;
                uint64_t rsvd0:1;
@@ -601,7 +602,7 @@ typedef union {
 typedef union {
        uint64_t u64;
        struct {
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#if NICVF_BYTE_ORDER == NICVF_BIG_ENDIAN
                uint64_t pkt_len:16;
                uint64_t l2_ptr:8;
                uint64_t l3_ptr:8;
@@ -626,7 +627,7 @@ typedef union {
 typedef union {
        uint64_t u64;
        struct {
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#if NICVF_BYTE_ORDER == NICVF_BIG_ENDIAN
                uint64_t rss_tag:32;
                uint64_t vlan_tci:16;
                uint64_t vlan_ptr:8;
@@ -643,7 +644,7 @@ typedef union {
 typedef union {
        uint64_t u64;
        struct {
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#if NICVF_BYTE_ORDER == NICVF_BIG_ENDIAN
                uint16_t rb3_sz;
                uint16_t rb2_sz;
                uint16_t rb1_sz;
@@ -660,7 +661,7 @@ typedef union {
 typedef union {
        uint64_t u64;
        struct {
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#if NICVF_BYTE_ORDER == NICVF_BIG_ENDIAN
                uint16_t rb7_sz;
                uint16_t rb6_sz;
                uint16_t rb5_sz;
@@ -677,7 +678,7 @@ typedef union {
 typedef union {
        uint64_t u64;
        struct {
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#if NICVF_BYTE_ORDER == NICVF_BIG_ENDIAN
                uint16_t rb11_sz;
                uint16_t rb10_sz;
                uint16_t rb9_sz;
@@ -694,7 +695,7 @@ typedef union {
 typedef union {
        uint64_t u64;
        struct {
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#if NICVF_BYTE_ORDER == NICVF_BIG_ENDIAN
                uint64_t vlan_found:1;
                uint64_t vlan_stripped:1;
                uint64_t vlan2_found:1;
@@ -739,7 +740,7 @@ struct cqe_rx_t {
 };
 
 struct cqe_rx_tcp_err_t {
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#if NICVF_BYTE_ORDER == NICVF_BIG_ENDIAN
        uint64_t   cqe_type:4; /* W0 */
        uint64_t   rsvd0:60;
 
@@ -761,7 +762,7 @@ struct cqe_rx_tcp_err_t {
 };
 
 struct cqe_rx_tcp_t {
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#if NICVF_BYTE_ORDER == NICVF_BIG_ENDIAN
        uint64_t   cqe_type:4; /* W0 */
        uint64_t   rsvd0:52;
        uint64_t   cq_tcp_status:8;
@@ -783,7 +784,7 @@ struct cqe_rx_tcp_t {
 };
 
 struct cqe_send_t {
-#if defined(__BIG_ENDIAN_BITFIELD)
+#if NICVF_BYTE_ORDER == NICVF_BIG_ENDIAN
        uint64_t   cqe_type:4; /* W0 */
        uint64_t   rsvd0:4;
        uint64_t   sqe_ptr:16;
@@ -795,7 +796,7 @@ struct cqe_send_t {
        uint64_t   send_status:8;
 
        uint64_t   ptp_timestamp:64; /* W1 */
-#elif defined(__LITTLE_ENDIAN_BITFIELD)
+#elif NICVF_BYTE_ORDER == NICVF_LITTLE_ENDIAN
        uint64_t   send_status:8;
        uint64_t   rsvd3:8;
        uint64_t   sq_idx:3;
@@ -811,7 +812,7 @@ struct cqe_send_t {
 };
 
 struct cq_entry_type_t {
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#if NICVF_BYTE_ORDER == NICVF_BIG_ENDIAN
        uint64_t cqe_type:4;
        uint64_t __pad:60;
 #else
@@ -832,14 +833,14 @@ union cq_entry_t {
 NICVF_STATIC_ASSERT(sizeof(union cq_entry_t) == 512);
 
 struct rbdr_entry_t {
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#if NICVF_BYTE_ORDER == NICVF_BIG_ENDIAN
        union {
                struct {
                        uint64_t   rsvd0:15;
                        uint64_t   buf_addr:42;
                        uint64_t   cache_align:7;
                };
-               nicvf_phys_addr_t full_addr;
+               nicvf_iova_addr_t full_addr;
        };
 #else
        union {
@@ -848,7 +849,7 @@ struct rbdr_entry_t {
                        uint64_t   buf_addr:42;
                        uint64_t   rsvd0:15;
                };
-               nicvf_phys_addr_t full_addr;
+               nicvf_iova_addr_t full_addr;
        };
 #endif
 };
@@ -857,7 +858,7 @@ NICVF_STATIC_ASSERT(sizeof(struct rbdr_entry_t) == sizeof(uint64_t));
 
 /* TCP reassembly context */
 struct rbe_tcp_cnxt_t {
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#if NICVF_BYTE_ORDER == NICVF_BIG_ENDIAN
        uint64_t   tcp_pkt_cnt:12;
        uint64_t   rsvd1:4;
        uint64_t   align_hdr_bytes:4;
@@ -896,7 +897,7 @@ struct rx_hdr_t {
 };
 
 struct sq_crc_subdesc {
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#if NICVF_BYTE_ORDER == NICVF_BIG_ENDIAN
        uint64_t    rsvd1:32;
        uint64_t    crc_ival:32;
        uint64_t    subdesc_type:4;
@@ -918,7 +919,7 @@ struct sq_crc_subdesc {
 };
 
 struct sq_gather_subdesc {
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#if NICVF_BYTE_ORDER == NICVF_BIG_ENDIAN
        uint64_t    subdesc_type:4; /* W0 */
        uint64_t    ld_type:2;
        uint64_t    rsvd0:42;
@@ -939,7 +940,7 @@ struct sq_gather_subdesc {
 
 /* SQ immediate subdescriptor */
 struct sq_imm_subdesc {
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#if NICVF_BYTE_ORDER == NICVF_BIG_ENDIAN
        uint64_t    subdesc_type:4; /* W0 */
        uint64_t    rsvd0:46;
        uint64_t    len:14;
@@ -955,7 +956,7 @@ struct sq_imm_subdesc {
 };
 
 struct sq_mem_subdesc {
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#if NICVF_BYTE_ORDER == NICVF_BIG_ENDIAN
        uint64_t    subdesc_type:4; /* W0 */
        uint64_t    mem_alg:4;
        uint64_t    mem_dsz:2;
@@ -979,7 +980,7 @@ struct sq_mem_subdesc {
 };
 
 struct sq_hdr_subdesc {
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#if NICVF_BYTE_ORDER == NICVF_BIG_ENDIAN
        uint64_t    subdesc_type:4;
        uint64_t    tso:1;
        uint64_t    post_cqe:1; /* Post CQE on no error also */
@@ -1042,7 +1043,7 @@ NICVF_STATIC_ASSERT(sizeof(union sq_entry_t) == 16);
 
 /* Queue config register formats */
 struct rq_cfg { union { struct {
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#if NICVF_BYTE_ORDER == NICVF_BIG_ENDIAN
        uint64_t reserved_2_63:62;
        uint64_t ena:1;
        uint64_t reserved_0:1;
@@ -1056,7 +1057,7 @@ struct rq_cfg { union { struct {
 }; };
 
 struct cq_cfg { union { struct {
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#if NICVF_BYTE_ORDER == NICVF_BIG_ENDIAN
        uint64_t reserved_43_63:21;
        uint64_t ena:1;
        uint64_t reset:1;
@@ -1082,8 +1083,9 @@ struct cq_cfg { union { struct {
 }; };
 
 struct sq_cfg { union { struct {
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
-       uint64_t reserved_20_63:44;
+#if NICVF_BYTE_ORDER == NICVF_BIG_ENDIAN
+       uint64_t reserved_32_63:32;
+       uint64_t cq_limit:8;
        uint64_t ena:1;
        uint64_t reserved_18_18:1;
        uint64_t reset:1;
@@ -1101,14 +1103,15 @@ struct sq_cfg { union { struct {
        uint64_t reset:1;
        uint64_t reserved_18_18:1;
        uint64_t ena:1;
-       uint64_t reserved_20_63:44;
+       uint64_t cq_limit:8;
+       uint64_t reserved_32_63:32;
 #endif
        };
        uint64_t value;
 }; };
 
 struct rbdr_cfg { union { struct {
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#if NICVF_BYTE_ORDER == NICVF_BIG_ENDIAN
        uint64_t reserved_45_63:19;
        uint64_t ena:1;
        uint64_t reset:1;
@@ -1136,7 +1139,7 @@ struct rbdr_cfg { union { struct {
 }; };
 
 struct pf_qs_cfg { union { struct {
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#if NICVF_BYTE_ORDER == NICVF_BIG_ENDIAN
        uint64_t reserved_32_63:32;
        uint64_t ena:1;
        uint64_t reserved_27_30:4;
@@ -1166,7 +1169,7 @@ struct pf_qs_cfg { union { struct {
 }; };
 
 struct pf_rq_cfg { union { struct {
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#if NICVF_BYTE_ORDER == NICVF_BIG_ENDIAN
        uint64_t reserved1:1;
        uint64_t reserved0:34;
        uint64_t strip_pre_l2:1;
@@ -1194,7 +1197,7 @@ struct pf_rq_cfg { union { struct {
 }; };
 
 struct pf_rq_drop_cfg { union { struct {
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#if NICVF_BYTE_ORDER == NICVF_BIG_ENDIAN
        uint64_t rbdr_red:1;
        uint64_t cq_red:1;
        uint64_t reserved3:14;