Imported Upstream version 16.04
[deb_dpdk.git] / drivers / net / cxgbe / base / t4_hw.h
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2014-2015 Chelsio Communications.
5  *   All rights reserved.
6  *
7  *   Redistribution and use in source and binary forms, with or without
8  *   modification, are permitted provided that the following conditions
9  *   are met:
10  *
11  *     * Redistributions of source code must retain the above copyright
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright
14  *       notice, this list of conditions and the following disclaimer in
15  *       the documentation and/or other materials provided with the
16  *       distribution.
17  *     * Neither the name of Chelsio Communications nor the names of its
18  *       contributors may be used to endorse or promote products derived
19  *       from this software without specific prior written permission.
20  *
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 #ifndef __T4_HW_H
35 #define __T4_HW_H
36
37 enum {
38         NCHAN           = 4,     /* # of HW channels */
39         NMTUS           = 16,    /* size of MTU table */
40         NCCTRL_WIN      = 32,    /* # of congestion control windows */
41         MBOX_LEN        = 64,    /* mailbox size in bytes */
42         UDBS_SEG_SIZE   = 128,   /* segment size for BAR2 user doorbells */
43 };
44
45 enum {
46         CIMLA_SIZE     = 2048,  /* # of 32-bit words in CIM LA */
47 };
48
49 enum {
50         SF_SEC_SIZE = 64 * 1024,      /* serial flash sector size */
51 };
52
53 enum {
54         SGE_NTIMERS = 6,          /* # of interrupt holdoff timer values */
55         SGE_NCOUNTERS = 4,        /* # of interrupt packet counter values */
56 };
57
58 /* PCI-e memory window access */
59 enum pcie_memwin {
60         MEMWIN_NIC      = 0,
61 };
62
63 enum {
64         SGE_MAX_WR_LEN = 512,     /* max WR size in bytes */
65         SGE_EQ_IDXSIZE = 64,      /* egress queue pidx/cidx unit size */
66         /* max no. of desc allowed in WR */
67         SGE_MAX_WR_NDESC = SGE_MAX_WR_LEN / SGE_EQ_IDXSIZE,
68 };
69
70 struct sge_qstat {                /* data written to SGE queue status entries */
71         __be32 qid;
72         __be16 cidx;
73         __be16 pidx;
74 };
75
76 /*
77  * Structure for last 128 bits of response descriptors
78  */
79 struct rsp_ctrl {
80         __be32 hdrbuflen_pidx;
81         __be32 pldbuflen_qid;
82         union {
83                 u8 type_gen;
84                 __be64 last_flit;
85         } u;
86 };
87
88 #define S_RSPD_NEWBUF    31
89 #define V_RSPD_NEWBUF(x) ((x) << S_RSPD_NEWBUF)
90 #define F_RSPD_NEWBUF    V_RSPD_NEWBUF(1U)
91
92 #define S_RSPD_LEN    0
93 #define M_RSPD_LEN    0x7fffffff
94 #define V_RSPD_LEN(x) ((x) << S_RSPD_LEN)
95 #define G_RSPD_LEN(x) (((x) >> S_RSPD_LEN) & M_RSPD_LEN)
96
97 #define S_RSPD_GEN    7
98 #define V_RSPD_GEN(x) ((x) << S_RSPD_GEN)
99 #define F_RSPD_GEN    V_RSPD_GEN(1U)
100
101 #define S_RSPD_TYPE    4
102 #define M_RSPD_TYPE    0x3
103 #define V_RSPD_TYPE(x) ((x) << S_RSPD_TYPE)
104 #define G_RSPD_TYPE(x) (((x) >> S_RSPD_TYPE) & M_RSPD_TYPE)
105
106 /* Rx queue interrupt deferral field: timer index */
107 #define S_QINTR_CNT_EN    0
108 #define V_QINTR_CNT_EN(x) ((x) << S_QINTR_CNT_EN)
109 #define F_QINTR_CNT_EN    V_QINTR_CNT_EN(1U)
110
111 #define S_QINTR_TIMER_IDX    1
112 #define M_QINTR_TIMER_IDX    0x7
113 #define V_QINTR_TIMER_IDX(x) ((x) << S_QINTR_TIMER_IDX)
114 #define G_QINTR_TIMER_IDX(x) (((x) >> S_QINTR_TIMER_IDX) & M_QINTR_TIMER_IDX)
115
116 /*
117  * Flash layout.
118  */
119 #define FLASH_START(start)      ((start) * SF_SEC_SIZE)
120 #define FLASH_MAX_SIZE(nsecs)   ((nsecs) * SF_SEC_SIZE)
121
122 enum {
123         /*
124          * Location of firmware image in FLASH.
125          */
126         FLASH_FW_START_SEC = 8,
127         FLASH_FW_NSECS = 16,
128         FLASH_FW_START = FLASH_START(FLASH_FW_START_SEC),
129         FLASH_FW_MAX_SIZE = FLASH_MAX_SIZE(FLASH_FW_NSECS),
130
131         /*
132          * Location of Firmware Configuration File in FLASH.
133          */
134         FLASH_CFG_START_SEC = 31,
135         FLASH_CFG_NSECS = 1,
136         FLASH_CFG_START = FLASH_START(FLASH_CFG_START_SEC),
137         FLASH_CFG_MAX_SIZE = FLASH_MAX_SIZE(FLASH_CFG_NSECS),
138
139         /*
140          * We don't support FLASH devices which can't support the full
141          * standard set of sections which we need for normal operations.
142          */
143         FLASH_MIN_SIZE = FLASH_CFG_START + FLASH_CFG_MAX_SIZE,
144 };
145
146 #undef FLASH_START
147 #undef FLASH_MAX_SIZE
148
149 #endif /* __T4_HW_H */