1/*
2 * Copyright 2014-2017 Cavium, Inc.
3 * The contents of this file are subject to the terms of the Common Development
4 * and Distribution License, v.1,  (the "License").
5 *
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the License at available
9 * at http://opensource.org/licenses/CDDL-1.0
10 *
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 */
14
15
16#ifndef _COM_HSI_H
17#define _COM_HSI_H
18
19// Offset of xxx_hsi in 32 bit words from beginning of scratchpad
20#define COM_HSI_OFFSET 0x4
21
22typedef struct _com_hsi_t {
23    fw_version_t version;
24    u32_t fw_doorbell;
25        #define KCQ_READY        (1<<0)
26        #define KCQ1_READY       (1<<1)
27        #define KCQ2_READY       (1<<2)
28        #define KCQ3_READY       (1<<3)
29    u32_t dups;
30    u32_t dacks;
31    u32_t pushs;
32    u32_t compbits;
33    u32_t num_comq;
34    u32_t num_comtq;
35    u32_t num_comxq;
36    u32_t unused_num_fail_reloads;
37    u32_t rx_place;
38    u32_t rtxs;          //  max_retx_cnt : maximum number of tcp retries
39    u32_t min_rto_tick;  //  min_rto (in ticks of retx timer)
40    u32_t max_rto_tick;  //  max_rto (in ticks of retx timer)
41    u32_t max_caf;       // max allowed ack frequency
42    u32_t false_ooo_fin_cnt;
43    u32_t l2_forward_to_mcp;
44    u32_t l2_drop_mcpq_busy;
45    u32_t drtxs;        // doubt reacheability tx count threshold (rfc 2923)
46                        // drtxs - maximum number of times that the offload target should
47                        // retransmit a segment before indicating to the host stack that
48                        // the reachability of a neighbor is in doubt.
49    u32_t abort_ooo_fin_cnt;
50    u32_t total_ooo_fin_cnt;
51    u32_t caus;
52    u32_t dtic;
53    u32_t defer_ooo_fin_cnt;
54    u32_t l4_drop_cnt;  // number of l4 packets dropped by RV2P
55    u32_t cozr;
56    u32_t com_l2_no_buffer;
57    u32_t com_cu_host_bseq;
58    u32_t tnda;
59    u32_t tcnas;
60    u32_t tccas;
61    u32_t caf;          // ack frequency
62    u32_t cmpl_dbg_cnt;
63    u32_t hcwa_kwq_cons_idx;
64    u32_t hcwa_last_kwq_cons_idx;
65    u32_t eaiv;
66    u32_t reload_aft_fin_cnt;           // Number of reload after FIN
67    u32_t enable_fast_iscsi_response;
68    u32_t tsch_restart;
69    u64_t volatile idle_count;
70    u32_t iscsi_rtxs;                   // Number of retransmissions in iSCSI
71    u32_t iscsi_cq_size;                // Number of elements in queue. Its k lsb bits must be 0. bit 0 - arm bit - means CQ is armed
72    u32_t iscsi_cq_cqes_per_page;       // Number of CQEs per page
73    u32_t iscsi_cq_num_pages;           // Number of pages of CQ ( = entries in page table)
74    u32_t iscsi_cq_cqes_per_page_log2;  // Log2 of the Number of CQEs per page
75    u32_t iscsi_data_dig_err;           // Indication on Error="1" / Warning="0" of data digest
76    u32_t iscsi_tcp_config;             // Configuration register - Enable/Disable of DA/KA mechanisms
77    u32_t iscsi_teton_l4_cmd_offset;    // Teton Only: offset of L4 ccell command array
78    u32_t iscsi_teton_l5_offset;        // Teton Only: offset of L5 section
79    u32_t iscsi_teton_l5_cmd_offset;    // Teton Only: offset of L5 ccell command array
80    u32_t iscsi_task_offset;            // offset of the task array
81    u32_t iscsi_r2tq_offset;            // offset of R2TQ section
82    u32_t iscsi_max_num_of_tasks;       // maximal number of pending tasks
83    u32_t iscsi_max_num_of_ccells;      // maximal number of ccells
84    u32_t com_cu_buf_size;
85    u32_t com_l2_iscsi_no_buffer;
86    u32_t com_unicast_no_buffer;
87    u32_t com_mcast_no_buffer;
88    u32_t com_bcast_no_buffer;
89    u32_t l2_drop_pkt_cnt;  // keep tracks of packet drop requested by RXP (e.g. not enough bytes in BD to place the pkt)
90    u32_t com_cu_free_cnt;
91    u32_t cu_rate_limiter_enable;
92}com_hsi_t;
93
94// This macro can be used for little or big endian 32-bit system
95#define COM_HSI_OFFSETOFF(m)  (OFFSETOF(com_hsi_t,m) + 0x10)
96#define COM_HSI_SIZEOF(m)     (sizeof (((com_hsi_t *)0)->m))
97
98// Calling the following macro will actually get optimized during compile
99// time. Its sole purpose is to ensure HSI variables cannot be modified/moved
100// unnoticed   scratch[10240] 0x120000 (RW/Reset: undefined)
101#define TEST_COM_HSI(){                                                    \
102if (0){                                                                    \
103 1/(COM_HSI_OFFSETOFF(version)                       == (COM_HSI_OFFSET * sizeof(u32_t) + 0x000) &&  \
104    COM_HSI_OFFSETOFF(fw_doorbell)                   == (COM_HSI_OFFSET * sizeof(u32_t) + 0x010) &&  \
105    COM_HSI_OFFSETOFF(dups)                          == (COM_HSI_OFFSET * sizeof(u32_t) + 0x014) &&  \
106    COM_HSI_OFFSETOFF(dacks)                         == (COM_HSI_OFFSET * sizeof(u32_t) + 0x018) &&  \
107    COM_HSI_OFFSETOFF(pushs)                         == (COM_HSI_OFFSET * sizeof(u32_t) + 0x01c) &&  \
108    COM_HSI_OFFSETOFF(compbits)                      == (COM_HSI_OFFSET * sizeof(u32_t) + 0x020) &&  \
109    COM_HSI_OFFSETOFF(num_comq)                      == (COM_HSI_OFFSET * sizeof(u32_t) + 0x024) &&  \
110    COM_HSI_OFFSETOFF(num_comtq)                     == (COM_HSI_OFFSET * sizeof(u32_t) + 0x028) &&  \
111    COM_HSI_OFFSETOFF(num_comxq)                     == (COM_HSI_OFFSET * sizeof(u32_t) + 0x02c) &&  \
112    COM_HSI_OFFSETOFF(unused_num_fail_reloads)       == (COM_HSI_OFFSET * sizeof(u32_t) + 0x030) &&  \
113    COM_HSI_OFFSETOFF(rx_place)                      == (COM_HSI_OFFSET * sizeof(u32_t) + 0x034) &&  \
114    COM_HSI_OFFSETOFF(rtxs)                          == (COM_HSI_OFFSET * sizeof(u32_t) + 0x038) &&  \
115    COM_HSI_OFFSETOFF(min_rto_tick)                  == (COM_HSI_OFFSET * sizeof(u32_t) + 0x03c) &&  \
116    COM_HSI_OFFSETOFF(max_rto_tick)                  == (COM_HSI_OFFSET * sizeof(u32_t) + 0x040) &&  \
117    COM_HSI_OFFSETOFF(max_caf)                       == (COM_HSI_OFFSET * sizeof(u32_t) + 0x044) &&  \
118    COM_HSI_OFFSETOFF(false_ooo_fin_cnt)             == (COM_HSI_OFFSET * sizeof(u32_t) + 0x048) &&  \
119    COM_HSI_OFFSETOFF(l2_forward_to_mcp)             == (COM_HSI_OFFSET * sizeof(u32_t) + 0x04c) &&  \
120    COM_HSI_OFFSETOFF(l2_drop_mcpq_busy)             == (COM_HSI_OFFSET * sizeof(u32_t) + 0x050) &&  \
121    COM_HSI_OFFSETOFF(drtxs)                         == (COM_HSI_OFFSET * sizeof(u32_t) + 0x054) &&  \
122    COM_HSI_OFFSETOFF(abort_ooo_fin_cnt)             == (COM_HSI_OFFSET * sizeof(u32_t) + 0x058) &&  \
123    COM_HSI_OFFSETOFF(total_ooo_fin_cnt)             == (COM_HSI_OFFSET * sizeof(u32_t) + 0x05c) &&  \
124    COM_HSI_OFFSETOFF(caus)                          == (COM_HSI_OFFSET * sizeof(u32_t) + 0x060) &&  \
125    COM_HSI_OFFSETOFF(dtic)                          == (COM_HSI_OFFSET * sizeof(u32_t) + 0x064) &&  \
126    COM_HSI_OFFSETOFF(defer_ooo_fin_cnt)             == (COM_HSI_OFFSET * sizeof(u32_t) + 0x068) &&  \
127    COM_HSI_OFFSETOFF(l4_drop_cnt)                   == (COM_HSI_OFFSET * sizeof(u32_t) + 0x06c) &&  \
128    COM_HSI_OFFSETOFF(cozr)                          == (COM_HSI_OFFSET * sizeof(u32_t) + 0x070) &&  \
129    COM_HSI_OFFSETOFF(com_l2_no_buffer)              == (COM_HSI_OFFSET * sizeof(u32_t) + 0x074) &&  \
130    COM_HSI_OFFSETOFF(com_cu_host_bseq)              == (COM_HSI_OFFSET * sizeof(u32_t) + 0x078) &&  \
131    COM_HSI_OFFSETOFF(tnda)                          == (COM_HSI_OFFSET * sizeof(u32_t) + 0x07c) &&  \
132    COM_HSI_OFFSETOFF(tcnas)                         == (COM_HSI_OFFSET * sizeof(u32_t) + 0x080) &&  \
133    COM_HSI_OFFSETOFF(tccas)                         == (COM_HSI_OFFSET * sizeof(u32_t) + 0x084) &&  \
134    COM_HSI_OFFSETOFF(caf)                           == (COM_HSI_OFFSET * sizeof(u32_t) + 0x088) &&  \
135    COM_HSI_OFFSETOFF(cmpl_dbg_cnt)                  == (COM_HSI_OFFSET * sizeof(u32_t) + 0x08c) &&  \
136    COM_HSI_OFFSETOFF(hcwa_kwq_cons_idx)             == (COM_HSI_OFFSET * sizeof(u32_t) + 0x090) &&  \
137    COM_HSI_OFFSETOFF(hcwa_last_kwq_cons_idx)        == (COM_HSI_OFFSET * sizeof(u32_t) + 0x094) &&  \
138    COM_HSI_OFFSETOFF(eaiv)                          == (COM_HSI_OFFSET * sizeof(u32_t) + 0x098) &&  \
139    COM_HSI_OFFSETOFF(reload_aft_fin_cnt)            == (COM_HSI_OFFSET * sizeof(u32_t) + 0x09c) &&  \
140    COM_HSI_OFFSETOFF(enable_fast_iscsi_response)    == (COM_HSI_OFFSET * sizeof(u32_t) + 0x0a0) &&  \
141    COM_HSI_OFFSETOFF(tsch_restart)                  == (COM_HSI_OFFSET * sizeof(u32_t) + 0x0a4) &&  \
142    COM_HSI_OFFSETOFF(idle_count)                    == (COM_HSI_OFFSET * sizeof(u32_t) + 0x0a8) &&  \
143    COM_HSI_OFFSETOFF(iscsi_rtxs)                    == (COM_HSI_OFFSET * sizeof(u32_t) + 0x0b0) &&  \
144    COM_HSI_OFFSETOFF(iscsi_cq_size)                 == (COM_HSI_OFFSET * sizeof(u32_t) + 0x0b4) &&  \
145    COM_HSI_OFFSETOFF(iscsi_cq_cqes_per_page)        == (COM_HSI_OFFSET * sizeof(u32_t) + 0x0b8) &&  \
146    COM_HSI_OFFSETOFF(iscsi_cq_num_pages)            == (COM_HSI_OFFSET * sizeof(u32_t) + 0x0bc) &&  \
147    COM_HSI_OFFSETOFF(iscsi_cq_cqes_per_page_log2)   == (COM_HSI_OFFSET * sizeof(u32_t) + 0x0c0) &&  \
148    COM_HSI_OFFSETOFF(iscsi_data_dig_err)            == (COM_HSI_OFFSET * sizeof(u32_t) + 0x0c4) &&  \
149    COM_HSI_OFFSETOFF(iscsi_tcp_config)              == (COM_HSI_OFFSET * sizeof(u32_t) + 0x0c8) &&  \
150    COM_HSI_OFFSETOFF(iscsi_teton_l4_cmd_offset)     == (COM_HSI_OFFSET * sizeof(u32_t) + 0x0cc) &&  \
151    COM_HSI_OFFSETOFF(iscsi_teton_l5_offset)         == (COM_HSI_OFFSET * sizeof(u32_t) + 0x0d0) &&  \
152    COM_HSI_OFFSETOFF(iscsi_teton_l5_cmd_offset)     == (COM_HSI_OFFSET * sizeof(u32_t) + 0x0d4) &&  \
153    COM_HSI_OFFSETOFF(iscsi_task_offset)             == (COM_HSI_OFFSET * sizeof(u32_t) + 0x0d8) &&  \
154    COM_HSI_OFFSETOFF(iscsi_r2tq_offset)             == (COM_HSI_OFFSET * sizeof(u32_t) + 0x0dc) &&  \
155    COM_HSI_OFFSETOFF(iscsi_max_num_of_tasks)        == (COM_HSI_OFFSET * sizeof(u32_t) + 0x0e0) &&  \
156    COM_HSI_OFFSETOFF(iscsi_max_num_of_ccells)       == (COM_HSI_OFFSET * sizeof(u32_t) + 0x0e4) &&  \
157    COM_HSI_OFFSETOFF(com_cu_buf_size)               == (COM_HSI_OFFSET * sizeof(u32_t) + 0x0e8) &&  \
158    COM_HSI_OFFSETOFF(com_l2_iscsi_no_buffer)        == (COM_HSI_OFFSET * sizeof(u32_t) + 0x0ec) &&  \
159    COM_HSI_OFFSETOFF(com_unicast_no_buffer)         == (COM_HSI_OFFSET * sizeof(u32_t) + 0x0f0) &&  \
160    COM_HSI_OFFSETOFF(com_mcast_no_buffer)           == (COM_HSI_OFFSET * sizeof(u32_t) + 0x0f4) &&  \
161    COM_HSI_OFFSETOFF(com_bcast_no_buffer)           == (COM_HSI_OFFSET * sizeof(u32_t) + 0x0f8) &&  \
162    COM_HSI_OFFSETOFF(l2_drop_pkt_cnt)               == (COM_HSI_OFFSET * sizeof(u32_t) + 0x0fc) &&  \
163    COM_HSI_OFFSETOFF(com_cu_free_cnt)               == (COM_HSI_OFFSET * sizeof(u32_t) + 0x100) &&  \
164    COM_HSI_OFFSETOFF(cu_rate_limiter_enable)        == (COM_HSI_OFFSET * sizeof(u32_t) + 0x104) &&  \
165    COM_HSI_OFFSETOFF(cu_rate_limiter_enable)+COM_HSI_SIZEOF(cu_rate_limiter_enable) == (COM_HSI_OFFSET * sizeof(u32_t) + sizeof(com_hsi_t)));}}
166
167#endif
168
169