xref: /illumos-gate/usr/src/uts/common/io/bnx/570x/common/include/toe_ctx.h (revision 55fea89dcaa64928bed4327112404dcb3e07b79f)
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 #ifndef _TOE_CTX_H
16 #define _TOE_CTX_H
17 
18 #include "tcp_ctx.h"
19 
20 
21 
22 /////////////////////////////////////////////////////////////////////
23 // TOE TX section
24 /////////////////////////////////////////////////////////////////////
25 typedef struct {
26     u32_t rto_intvl;     // current unbounded rto interval (in ticks)
27     u32_t unused;
28     u32_t tcp_last_rcv_win_seq;
29     u8_t  tx_in_coalesce;
30     u8_t  tx_ind_silly_win;
31     u8_t  tx_large_bd;
32     u8_t  tx_comp_defer;
33     u16_t max_rt_tick;               // maximum total retransmit timeout (in ticks)
34     u16_t total_rt_tick;             // total retransmit timeout  (in ticks)
35     u32_t tcp_sack_start;             // keep track of rx SACK
36     u8_t  tx_comp_prod;
37     u8_t  tx_comp_cons;
38     u8_t  persist_probe_cnt;
39     u8_t  in_generic;
40     u32_t tx_comp_step;
41     u32_t reply_ts;
42         #define TOE_RTT_SAMPLED                   (1<<0)
43     u32_t tcp_save_cwin;
44     u32_t unused2;
45     u32_t host_win_update;
46 } toe_l4_tx_ctx_b_t;
47 
48 typedef struct {
49     u32_t rto_intvl;     // current unbounded rto interval (in ticks)
50     u32_t unused;
51     u32_t tcp_last_rcv_win_seq;
52     u8_t  tx_comp_defer;
53     u8_t  tx_large_bd;
54     u8_t  tx_ind_silly_win;
55     u8_t  tx_in_coalesce;
56     u16_t total_rt_tick;             // total retransmit timeout  (in ticks)
57     u16_t max_rt_tick;               // maximum total retransmit timeout (in ticks)
58     u32_t tcp_sack_start;             // keep track of rx SACK
59     u8_t  in_generic;
60     u8_t  persist_probe_cnt;
61     u8_t  tx_comp_cons;
62     u8_t  tx_comp_prod;
63     u32_t tx_comp_step;
64     u32_t reply_ts;
65         #define TOE_RTT_SAMPLED                   (1<<0)
66     u32_t tcp_save_cwin;
67     u32_t unused2;
68     u32_t host_win_update;
69 } toe_l4_tx_ctx_l_t;
70 
71 #if defined(LITTLE_ENDIAN)
72     typedef toe_l4_tx_ctx_l_t  toe_l4_tx_ctx_t;
73 #elif defined(BIG_ENDIAN)
74     typedef toe_l4_tx_ctx_b_t  toe_l4_tx_ctx_t;
75 #endif
76 
77     typedef struct {
78     tcp_tx_ctx_t        tcp;
79     toe_l4_tx_ctx_t     toe;
80 } toe_tx_ctx_t;
81 
82 /////////////////////////////////////////////////////////////////////
83 // TOE CMN section
84 /////////////////////////////////////////////////////////////////////
85 typedef struct {
86     u32_t   tcp_disconnect_seq;           // last snd seq # before disconnecting
87     u32_t   last_fin_seq;                  // last rx seq # in FIN packet
88     u8_t    tcp_retx_defer;
89     u8_t    tcp_flow_state;
90         #define TOE_FLOW_STATE_NORMAL_INIT           (0<<0)
91         #define TOE_FLOW_STATE_NORMAL_RUNNING        (1<<0)
92         #define TOE_FLOW_STATE_LIMIT_TX_ACTIVE       (2<<0)
93         #define TOE_FLOW_STATE_IN_LOSS_RECOVERY      (3<<0)
94         #define TOE_FLOW_STATE_FAST_RETX_INIT1       (4<<0)
95         #define TOE_FLOW_STATE_FAST_RETX_INIT2       (5<<0)
96         #define TOE_FLOW_STATE_FAST_RETX_RELOAD      (6<<0)
97         #define TOE_FLOW_STATE_FAST_RETX_ACTIVE1     (7<<0)
98         #define TOE_FLOW_STATE_FAST_RETX_ACTIVE2     (8<<0)
99         #define TOE_FLOW_STATE_FAST_RECOVERY_INIT1   (9<<0)
100         #define TOE_FLOW_STATE_FAST_RECOVERY_INIT2   (10<<0)
101         #define TOE_FLOW_STATE_FAST_RECOVERY_ACTIVE  (11<<0)
102         #define TOE_FLOW_STATE_FAST_RECOVERY_EXIT    (12<<0)
103     u8_t    tcp_partial_ack_cnt;
104     u8_t    timer1_mode;        // timer1 is overloaded for retx, persist, sws prevention and FIN_WAIT2 timer
105     u32_t   tcp_snd_recover;
106     u16_t   gen_buff_accum;
107     u8_t    ooo_fin_upload_state;
108         #define OOO_FIN_UPLOAD_IDLE                   (0<<0)
109         #define OOO_FIN_UPLOAD_DEFER                  (1<<0)
110         #define OOO_FIN_UPLOAD_NOW                    (2<<0)
111         #define OOO_FIN_UPLOAD_DONE                   (3<<0)
112         #define OOO_FIN_UPLOAD_DEFER_PENDING          (4<<0)
113         #define OOO_FIN_UPLOAD_UNKNOWN                (5<<0)
114     u8_t    reload_comp_status;
115         #define RELOAD_COMP_IDLE                      (0<<0)
116         #define RELOAD_COMP_HOST_PENDING              (1<<0)
117         #define RELOAD_COMP_ONCHIP_PENDING            (2<<0)
118     u32_t   ooo_fin_seq;
119 } toe_l4_cmn_ctx_b_t;
120 
121 typedef struct {
122     u32_t   tcp_disconnect_seq;           // last snd seq # before disconnecting
123     u32_t   last_fin_seq;                  // last rx seq # in FIN packet
124     u8_t    timer1_mode;        // timer1 is overloaded for retx, persist, sws prevention and FIN_WAIT2 timer
125         #define TIMER1_RETX_MODE        (0)
126         #define TIMER1_PERSIST_MODE     (1)
127         #define TIMER1_SWS_PREVENT_MODE (2)
128         #define TIMER1_FIN_WAIT2_MODE   (3)
129     u8_t    tcp_partial_ack_cnt;
130     u8_t    tcp_flow_state;
131         #define TOE_FLOW_STATE_NORMAL_INIT            (0<<0)
132         #define TOE_FLOW_STATE_NORMAL_RUNNING         (1<<0)
133         #define TOE_FLOW_STATE_LIMIT_TX_ACTIVE        (2<<0)
134         #define TOE_FLOW_STATE_IN_LOSS_RECOVERY       (3<<0)
135         #define TOE_FLOW_STATE_FAST_RETX_INIT1        (4<<0)
136         #define TOE_FLOW_STATE_FAST_RETX_INIT2        (5<<0)
137         #define TOE_FLOW_STATE_FAST_RETX_RELOAD       (6<<0)
138         #define TOE_FLOW_STATE_FAST_RETX_ACTIVE1      (7<<0)
139         #define TOE_FLOW_STATE_FAST_RETX_ACTIVE2      (8<<0)
140         #define TOE_FLOW_STATE_FAST_RECOVERY_INIT1    (9<<0)
141         #define TOE_FLOW_STATE_FAST_RECOVERY_INIT2    (10<<0)
142         #define TOE_FLOW_STATE_FAST_RECOVERY_ACTIVE   (11<<0)
143         #define TOE_FLOW_STATE_FAST_RECOVERY_EXIT     (12<<0)
144     u8_t    tcp_retx_defer;
145     u32_t   tcp_snd_recover;
146     u8_t    reload_comp_status;
147         #define RELOAD_COMP_IDLE                      (0<<0)
148         #define RELOAD_COMP_HOST_PENDING              (1<<0)
149         #define RELOAD_COMP_ONCHIP_PENDING            (2<<0)
150     u8_t    ooo_fin_upload_state;
151     u16_t   gen_buff_accum;
152     u32_t   ooo_fin_seq;
153 } toe_l4_cmn_ctx_l_t;
154 
155 #if defined(LITTLE_ENDIAN)
156     typedef toe_l4_cmn_ctx_l_t  toe_l4_cmn_ctx_t;
157 #elif defined(BIG_ENDIAN)
158     typedef toe_l4_cmn_ctx_b_t  toe_l4_cmn_ctx_t;
159 #endif
160 
161 typedef struct {
162     tcp_cmn_ctx_t        tcp;
163     toe_l4_cmn_ctx_t     toe;
164 } toe_cmn_ctx_t;
165 
166 /////////////////////////////////////////////////////////////////////
167 // TOE RX section
168 /////////////////////////////////////////////////////////////////////
169 typedef struct {
170     u32_t ccell_hist_bseq;
171     u32_t ccell_hist_bhaddr_hi;
172     u32_t ccell_hist_bhaddr_lo;
173     u16_t ccell_hist_bidx;
174     u16_t ccell_hist_bd_nbytes;
175 } toe_ccell_hist_b_t;
176 
177 typedef struct {
178     u32_t ccell_hist_bseq;
179     u32_t ccell_hist_bhaddr_hi;
180     u32_t ccell_hist_bhaddr_lo;
181     u16_t ccell_hist_bd_nbytes;
182     u16_t ccell_hist_bidx;
183 } toe_ccell_hist_l_t;
184 
185 #if defined(LITTLE_ENDIAN)
186     typedef toe_ccell_hist_l_t  toe_ccell_hist_t;
187 #elif defined(BIG_ENDIAN)
188     typedef toe_ccell_hist_b_t  toe_ccell_hist_t;
189 #endif
190 
191 #define MAX_CCELL_HIST_ENTRY    9
192 
193 typedef struct {
194     u8_t  l4_bd_chain_v2p_proc1flags;
195     u8_t  l4_bd_chain_host_gen_count;
196     u16_t l4_bd_chain_host_bdidx;
197     u32_t l4_bd_chain_host_bseq;
198     u32_t l4_bd_chain_nx_bdhaddr_hi;
199     u32_t l4_bd_chain_nx_bdhaddr_lo;
200     u32_t l4_bd_chain_nx_seq;
201     u8_t  l4_bd_chain_v2p_flags;
202     u8_t  l4_bd_chain_v2p_gen_count;
203     u16_t l4_bd_chain_nx_bdidx;
204     u16_t l4_bd_chain_gen_used;
205     u16_t l4_bd_chain_nx_boff;
206     u32_t l4_bd_chain_cmpl_seq;
207     u32_t l4_bd_chain_cmpl_bdhaddr_hi;
208     u32_t l4_bd_chain_cmpl_bdhaddr_lo;
209     u16_t l4_bd_chain_gen_size;
210     u16_t l4_bd_chain_cmpl_bdidx;
211     u32_t l4_bd_chain_io_seq;
212     u32_t l4_bd_chain_hole_seq;
213     u32_t l4_bd_chain_end_seq;
214     u32_t l4_bd_chain_bseq_lead;
215     u32_t l4_bd_chain_push_seq;
216     u32_t l4_bd_chain_gen_start_seq;
217     u32_t l4_bd_chain_gen_seq;
218     u32_t l4_bd_chain_gen_bfr_hi;
219     u32_t l4_bd_chain_gen_bfr_lo;
220     u32_t l4_bd_chain_hole2_seq;      // to keep track of 2nd holes
221     u32_t l4_bd_chain_end2_seq;
222     u8_t  ccell_hist_prod_idx;
223     u8_t  ccell_hist_cons_idx;
224     u8_t  ccell_hist_num_entry;
225     u8_t  unused;
226     toe_ccell_hist_t ccell_hist_tbl[MAX_CCELL_HIST_ENTRY];
227 } toe_l4_rx_ctx_b_t;
228 
229 typedef struct {
230     u16_t l4_bd_chain_host_bdidx;
231     u8_t  l4_bd_chain_host_gen_count;
232     u8_t  l4_bd_chain_v2p_proc1flags;
233     u32_t l4_bd_chain_host_bseq;
234     u32_t l4_bd_chain_nx_bdhaddr_hi;
235     u32_t l4_bd_chain_nx_bdhaddr_lo;
236     u32_t l4_bd_chain_nx_seq;
237     u16_t l4_bd_chain_nx_bdidx;
238     u8_t  l4_bd_chain_v2p_gen_count;
239     u8_t  l4_bd_chain_v2p_flags;
240     u16_t l4_bd_chain_nx_boff;
241     u16_t l4_bd_chain_gen_used;
242     u32_t l4_bd_chain_cmpl_seq;
243     u32_t l4_bd_chain_cmpl_bdhaddr_hi;
244     u32_t l4_bd_chain_cmpl_bdhaddr_lo;
245     u16_t l4_bd_chain_cmpl_bdidx;
246     u16_t l4_bd_chain_gen_size;
247     u32_t l4_bd_chain_io_seq;
248     u32_t l4_bd_chain_hole_seq;
249     u32_t l4_bd_chain_end_seq;
250     u32_t l4_bd_chain_bseq_lead;
251     u32_t l4_bd_chain_push_seq;
252     u32_t l4_bd_chain_gen_start_seq;
253     u32_t l4_bd_chain_gen_seq;
254     u32_t l4_bd_chain_gen_bfr_hi;
255     u32_t l4_bd_chain_gen_bfr_lo;
256     u32_t l4_bd_chain_hole2_seq;      // to keep track of 2nd holes
257     u32_t l4_bd_chain_end2_seq;
258     toe_ccell_hist_t ccell_hist_tbl[MAX_CCELL_HIST_ENTRY];
259     u8_t  unused;
260     u8_t  ccell_hist_num_entry;
261     u8_t  ccell_hist_cons_idx;
262     u8_t  ccell_hist_prod_idx;
263 } toe_l4_rx_ctx_l_t;
264 
265 #if defined(LITTLE_ENDIAN)
266     typedef toe_l4_rx_ctx_l_t  toe_l4_rx_ctx_t;
267 #elif defined(BIG_ENDIAN)
268     typedef toe_l4_rx_ctx_b_t  toe_l4_rx_ctx_t;
269 #endif
270 
271 typedef struct {
272     tcp_rx_ctx_t        tcp;
273     toe_l4_rx_ctx_t     toe;
274 } toe_rx_ctx_t;
275 
276 /* container structure for entire L4 ctx, it is mainly used by VBD debugging tools */
277 typedef struct {
278     toe_tx_ctx_t            toe_tx;
279     u8_t                    unused_0[128 - sizeof(toe_tx_ctx_t)];
280     toe_cmn_ctx_t           toe_cmn;   /* ctx_cmn is full */
281 //    u8_t                    unused_0[128 - sizeof(toe_cmn_ctx_t)];
282     toe_rx_ctx_t            toe_rx;
283     u8_t                    unused_1[256 - sizeof(toe_rx_ctx_t)];
284     u8_t                    reserved[64];
285     tcp_context_cmd_cell_te_t  toe_cmd_cell;
286 } toe_ctx_t;
287 
288 
289 
290 // Calling the following macro will actually get optimized during compile
291 // time. Its sole purpose is to ensure the context variable locations are
292 // not moved by accident
293 #define TEST_TOE_CTX(){                           \
294 if (0){                                           \
295  1/((sizeof(toe_ctx_t) == 0x268) &&               \
296     (OFFSETOF(toe_ctx_t, toe_cmn) == 128) &&      \
297     (OFFSETOF(toe_ctx_t, toe_rx)  == 128+128) &&  \
298     (OFFSETOF(toe_ctx_t, toe_cmd_cell)  == 128+128+256+64));}}
299 
300 
301 /*
302  *  l4_bd_chain_context_b definition
303  */
304 typedef struct l4_bd_chain_context_b
305 {
306     u8_t l4bdctx_v2p_proc1flags;
307         #define L4BDCTX_V2P_PROC1FLAGS_BD_CHN_FLUSH         (1<<0)
308         #define L4BDCTX_V2P_PROC1FLAGS_BD_FORCE_PUSH        (1<<1)
309 
310     u8_t l4bdctx_host_gen_count;
311     u16_t l4bdctx_host_bdidx;
312     u32_t l4bdctx_host_bseq;
313     u32_t l4bdctx_nx_bdhaddr_hi;
314     u32_t l4bdctx_nx_bdhaddr_lo;
315     u32_t l4bdctx_nx_seq;
316     u8_t l4bdctx_v2p_flags;
317     u8_t l4bdctx_v2p_gen_count;
318     u16_t l4bdctx_nx_bdidx;
319     u16_t l4bdctx_gen_used;
320     u16_t l4bdctx_nx_boff;
321     u32_t l4bdctx_cmpl_seq;
322     u32_t l4bdctx_cmpl_bdhaddr_hi;
323     u32_t l4bdctx_cmpl_bdhaddr_lo;
324     u16_t l4bdctx_gen_size;
325     u16_t l4bdctx_cmpl_bdidx;
326     u32_t l4bdctx_io_seq;
327     u32_t l4bdctx_hole_seq;
328     u32_t l4bdctx_end_seq;
329     u32_t l4bdctx_bseq_lead;
330     u32_t l4bdctx_push_seq;
331     u32_t l4bdctx_gen_start_seq;
332     u32_t l4bdctx_gen_seq;
333     u32_t l4bdctx_gen_bfr_hi;
334     u32_t l4bdctx_gen_bfr_lo;
335 } l4_bd_chain_context_b_t;
336 
337 
338 /*
339  *  l4_bd_chain_context_l definition
340  */
341 typedef struct l4_bd_chain_context_l
342 {
343     u16_t l4bdctx_host_bdidx;
344     u8_t l4bdctx_host_gen_count;
345     u8_t l4bdctx_v2p_proc1flags;
346         #define L4BDCTX_V2P_PROC1FLAGS_BD_CHN_FLUSH         (1<<0)
347         #define L4BDCTX_V2P_PROC1FLAGS_BD_FORCE_PUSH        (1<<1)
348 
349     u32_t l4bdctx_host_bseq;
350     u32_t l4bdctx_nx_bdhaddr_hi;
351     u32_t l4bdctx_nx_bdhaddr_lo;
352     u32_t l4bdctx_nx_seq;
353     u16_t l4bdctx_nx_bdidx;
354     u8_t l4bdctx_v2p_gen_count;
355     u8_t l4bdctx_v2p_flags;
356     u16_t l4bdctx_nx_boff;
357     u16_t l4bdctx_gen_used;
358     u32_t l4bdctx_cmpl_seq;
359     u32_t l4bdctx_cmpl_bdhaddr_hi;
360     u32_t l4bdctx_cmpl_bdhaddr_lo;
361     u16_t l4bdctx_cmpl_bdidx;
362     u16_t l4bdctx_gen_size;
363     u32_t l4bdctx_io_seq;
364     u32_t l4bdctx_hole_seq;
365     u32_t l4bdctx_end_seq;
366     u32_t l4bdctx_bseq_lead;
367     u32_t l4bdctx_push_seq;
368     u32_t l4bdctx_gen_start_seq;
369     u32_t l4bdctx_gen_seq;
370     u32_t l4bdctx_gen_bfr_hi;
371     u32_t l4bdctx_gen_bfr_lo;
372 } l4_bd_chain_context_l_t;
373 
374 
375 /*
376  * l4_bd_chain_context select
377  */
378 #if defined(LITTLE_ENDIAN)
379     typedef l4_bd_chain_context_l_t l4_bd_chain_context_t;
380 #elif defined(BIG_ENDIAN)
381     typedef l4_bd_chain_context_b_t l4_bd_chain_context_t;
382 #endif
383 
384 /*
385  *  l4_context_b definition
386  */
387 typedef struct l4_context_b
388 {
389     u8_t l4ctx_ctx_type;
390         #define L4CTX_TYPE_TYPE                             (0xf<<4)
391         #define L4CTX_TYPE_TYPE_EMPTY                       (0<<4)
392         #define L4CTX_TYPE_TYPE_L2                          (1<<4)
393         #define L4CTX_TYPE_TYPE_TCP                         (2<<4)
394         #define L4CTX_TYPE_TYPE_L5                          (3<<4)
395         #define L4CTX_TYPE_TYPE_L2_BD_CHN                   (4<<4)
396         #define L4CTX_TYPE_TYPE_ISCSI                       (5<<4)
397 
398     u8_t l4ctx_size;
399     u8_t l4ctx_bd_pre_read;
400     u8_t l4ctx_gen_bd_cid;
401     u8_t l4ctx_gen_bd_max;
402     u8_t l4ctx_oubits;
403         #define L4CTX_OUBITS_ACTIVATE                       (1<<0)
404         #define L4CTX_OUBITS_CP_UPLOAD                      (1<<1)
405         #define L4CTX_OUBITS_RXP_UPLOAD                     (1<<2)
406         #define L4CTX_OUBITS_TXP_UPLOAD                     (1<<3)
407         #define L4CTX_OUBITS_COM_RX_UPLOAD                  (1<<4)
408         #define L4CTX_OUBITS_COM_TX_UPLOAD                  (1<<5)
409         #define L4CTX_OUBITS_CP_UPLOAD_COMP                 (1<<6)
410 
411     u8_t    l4ctx_force_ack_pending;
412     u8_t    l4ctx_challenge_ack_state;         // refer to tcpm-tcpsecure-09 requirement
413         #define CHALLENGE_ACK_NOT_SENT          0            // Challenge Ack not sent
414         #define CHALLENGE_ACK_SENT_KA_DISABLED  1            // Challenge ACK is sent while KA was disabled
415         #define CHALLENGE_ACK_SENT_KA_ENABLED   2            // Challenge ACK is sent while KA was enabled
416     u16_t   l4ctx_tcp_pgid;
417     u8_t    unused;
418     u8_t    l4ctx_tcp_retx_defer;
419     u32_t l4ctx_tcp_timer1;
420         #define L4CTX_TCP_TIMER1_DISABLE                    (1UL<<0)
421         #define L4CTX_TCP_TIMER1_VALUE                      (0x7fffffffL<<1)
422 
423     u16_t l4ctx_tcp_timer2;
424         #define L4CTX_TCP_TIMER2_DISABLE                    (1<<0)
425         #define L4CTX_TCP_TIMER2_VALUE                      (0x7fff<<1)
426 
427     u16_t l4ctx_tcp_timer3;
428         #define L4CTX_TCP_TIMER3_DISABLE                    (1<<0)
429         #define L4CTX_TCP_TIMER3_VALUE                      (0x7fff<<1)
430 
431     u16_t l4ctx_tcp_timer4;
432         #define L4CTX_TCP_TIMER4_DISABLE                    (1<<0)
433         #define L4CTX_TCP_TIMER4_VALUE                      (0x7fff<<1)
434 
435     u16_t l4ctx_tcp_timer5;
436         #define L4CTX_TCP_TIMER5_DISABLE                    (1<<0)
437         #define L4CTX_TCP_TIMER5_VALUE                      (0x7fff<<1)
438 
439     u32_t l4ctx_tcp_snd_wl1;
440     u32_t l4ctx_tcp_snd_wl2;
441     u8_t l4ctx_tcp_ttl;
442     u8_t l4ctx_tcp_tos;
443     u8_t l4ctx_tcp_dack;
444     u8_t l4ctx_tcp_modes;
445         #define L4CTX_TCP_MODES_RST_INDICATED_PENDING       (1<<0)
446         #define L4CTX_TCP_MODES_DISC_BD                     (1<<1)
447         #define L4CTX_TCP_MODES_UPLOAD_INITED               (1<<2)
448         #define L4CTX_TCP_MODES_RMT_DISC                    (1<<3)
449         #define L4CTX_TCP_MODES_PG_INVALIDATED              (1<<4)
450         #define L4CTX_TCP_MODES_ABORT_PENDING               (1<<5)
451         #define L4CTX_TCP_MODES_DISC_PENDING                (1<<6)
452         #define L4CTX_TCP_MODES_STOP_TX                     (1<<7)
453 
454     u32_t l4ctx_tcp_max_adv_win;
455     u32_t l4ctx_rto_intvl;         // current unbounded retransmission timeout (RTO)
456     u32_t l4ctx_tcp_ip_src;
457     u32_t l4ctx_tcp_ip_dst;
458     u8_t l4ctx_tcp_iphdr_nbytes;
459     u8_t l4ctx_tcp_snd_seg_scale;
460     u8_t l4ctx_tcp_rcv_seg_scale;
461     u8_t l4ctx_tcp_tcp_hlen;
462     u16_t l4ctx_tcp_src_port;
463     u16_t l4ctx_tcp_dst_port;
464     u16_t l4ctx_tcp_mss;
465     u8_t l4ctx_tcp_flags;
466         #define L4CTX_TCP_FLAGS_NO_DELAY_ACK                (1<<0)
467         #define L4CTX_TCP_FLAGS_KEEP_ALIVE                  (1<<1)
468         #define L4CTX_TCP_FLAGS_NAGLE                       (1<<2)
469         #define L4CTX_TCP_FLAGS_TIME_STAMP                  (1<<3)
470         #define L4CTX_TCP_FLAGS_SACK                        (1<<4)
471         #define L4CTX_TCP_FLAGS_SEG_SCALING                 (1<<5)
472         #define L4CTX_TCP_FLAGS_OPTION2                     (1<<6)
473 
474     u8_t l4ctx_tcp_state;
475         #define L4CTX_TCP_STATE_VALUE                       (0xff<<0)
476         #define L4CTX_TCP_STATE_VALUE_UNDEFINED             (0<<0)
477         #define L4CTX_TCP_STATE_VALUE_LISTEN                (2<<0)
478         #define L4CTX_TCP_STATE_VALUE_SYN_SENT              (4<<0)
479         #define L4CTX_TCP_STATE_VALUE_SYN_RECV              (6<<0)
480         #define L4CTX_TCP_STATE_VALUE_CLOSE_WAIT            (8<<0)
481         #define L4CTX_TCP_STATE_VALUE_ESTABLISHED           (10<<0)
482         #define L4CTX_TCP_STATE_VALUE_FIN_WAIT1             (12<<0)
483         #define L4CTX_TCP_STATE_VALUE_FIN_WAIT2             (14<<0)
484         #define L4CTX_TCP_STATE_VALUE_TIME_WAIT             (16<<0)
485         #define L4CTX_TCP_STATE_VALUE_CLOSED                (18<<0)
486         #define L4CTX_TCP_STATE_VALUE_LAST_ACK              (20<<0)
487         #define L4CTX_TCP_STATE_VALUE_CLOSING               (22<<0)
488         #define L4CTX_TCP_STATE_VALUE_ABORT_CONNECTION      (24<<0)
489 
490     u32_t l4ctx_tcp_rcv_next;
491     u32_t l4ctx_last_ack_sent;
492     u32_t l4ctx_tcp_rcv_win_seq;
493     u32_t l4ctx_tcp_snd_una;
494     u32_t l4ctx_tcp_snd_next;
495     u32_t l4ctx_tcp_snd_max;
496     u32_t l4ctx_tcp_snd_win;
497     u32_t l4ctx_tcp_snd_cwin;
498     u32_t l4ctx_tcp_tstamp;
499     u32_t l4ctx_tcp_ssthresh;
500     u16_t l4ctx_tcp_sm_rtt;
501     u16_t l4ctx_tcp_sm_delta;
502     u32_t l4ctx_tcp_max_snd_win;
503     u32_t l4ctx_tcp_tsch_snd_next;
504     u32_t l4ctx_tcp_slot_size;
505         #define L4CTX_TCP_SLOT_SIZE_SLOT_SIZE               (0xffffffL<<0)
506         #define L4CTX_TCP_SLOT_SIZE_CMD_MAX                 (0x7fL<<24)
507         #define L4CTX_TCP_SLOT_SIZE_STOP                    (1UL<<31)
508 
509     u8_t l4ctx_tcp_cp_cmd;
510     u8_t l4ctx_tcp_tsch_cmd;
511     u8_t l4ctx_tcp_cons_retx_num;
512     u8_t l4ctx_tcp_tsch_xnum;
513         #define L4CTX_TCP_TSCH_XNUM_VAL                     (0x7f<<0)
514         #define L4CTX_TCP_TSCH_XNUM_L4                      (1<<7)
515 
516     u8_t l4ctx_tcp_num_dupack;
517     u8_t l4ctx_tcp_tx_protocol_flags;
518         #define L4CTX_TCP_TX_PROTOCOL_FLAGS_TIMER_DELAY_ACK  (1<<0)
519         #define L4CTX_TCP_TX_PROTOCOL_FLAGS_UPLOAD          (1<<1)
520         #define L4CTX_TCP_TX_PROTOCOL_FLAGS_FORCE_ACK       (1<<2)
521         #define L4CTX_TCP_TX_PROTOCOL_FLAGS_LAST_ACK        (1<<3)
522         #define L4CTX_TCP_TX_PROTOCOL_FLAGS_LAST_RST        (1<<4)
523         /* TOE stack overload bit 4 to signal TXP to sends out pure ack
524          * TOE stack should never use last RST bit
525          */
526         #define L4CTX_TCP_TX_PROTOCOL_FLAGS_PURE_ACK        L4CTX_TCP_TX_PROTOCOL_FLAGS_LAST_RST
527         #define L4CTX_TCP_TX_PROTOCOL_FLAGS_FORCE_RST       (1<<5)
528         #define L4CTX_TCP_TX_PROTOCOL_FLAGS_FORCE_ACK_MINUS (1<<6)
529         #define L4CTX_TCP_TX_PROTOCOL_FLAGS_SKIP_KA         (1<<7)
530 
531     u8_t l4ctx_tcp_prod_retx_num;
532     u8_t l4ctx_tcp_tsch_cons_retx_num;
533     u8_t l4ctx_tcp_comp_cons_retx_num;
534     u8_t l4ctx_tcp_num_retx;
535     u8_t l4ctx_tcp_upload_reason;
536         #define L4CTX_TCP_UPLOAD_REASON_KEEP_ALIVE          (1<<0)
537         #define L4CTX_TCP_UPLOAD_REASON_FIN                 (1<<1)
538         #define L4CTX_TCP_UPLOAD_REASON_URG                 (1<<2)
539         #define L4CTX_TCP_UPLOAD_REASON_FRAGMENT            (1<<3)
540         #define L4CTX_TCP_UPLOAD_REASON_IP_OPTION           (1<<4)
541         #define L4CTX_TCP_UPLOAD_REASON_RST                 (1<<5)
542         #define L4CTX_TCP_UPLOAD_REASON_SYN                 (1<<6)
543         #define L4CTX_TCP_UPLOAD_REASON_TIMEOUT             (1<<7)
544 
545     u8_t l4ctx_tcp_txp_cmd;
546     u32_t l4ctx_tcp_offload_seq;
547     tcp_context_cmd_cell_te_t l4ctx_cmd[1];
548     u8_t l4ctx_l4_bd_chain_v2p_proc1flags;
549         #define L4CTX_L4_BD_CHAIN_V2P_PROC1FLAGS_BD_CHN_FLUSH             (1<<0)
550         #define L4CTX_L4_BD_CHAIN_V2P_PROC1FLAGS_BD_CHN_FORCE_PUSH        (1<<1)
551 
552     u8_t l4ctx_l4_bd_chain_host_gen_count;
553     u16_t l4ctx_l4_bd_chain_host_bdidx;
554     u32_t l4ctx_l4_bd_chain_host_bseq;
555     u32_t l4ctx_l4_bd_chain_nx_bdhaddr_hi;
556     u32_t l4ctx_l4_bd_chain_nx_bdhaddr_lo;
557     u32_t l4ctx_l4_bd_chain_nx_seq;
558     u8_t l4ctx_l4_bd_chain_v2p_flags;
559         #define L4CTX_L4_BD_CHAIN_V2P_FLAGS_GEN_BD_IN_USE   (1<<1)
560         #define L4CTX_L4_BD_CHAIN_V2P_FLAGS_HOLE_MODE       (1<<2)
561         #define L4CTX_L4_BD_CHAIN_V2P_FLAGS_INDICATED       (1<<3)
562         #define L4CTX_L4_BD_CHAIN_V2P_FLAGS_PUSH_ARMED      (1<<4)
563         #define L4CTX_L4_BD_CHAIN_V2P_FLAGS_PUSH_PENDING    (1<<5)
564         #define L4CTX_L4_BD_CHAIN_V2P_FLAGS_2ND_HOLE_MODE   (1<<6)
565         #define L4CTX_L4_BD_CHAIN_V2P_FLAGS_NEW_ISLAND      (1<<7)  // 0 : 1st (inside) island is newer
566                                                                     // 1 : 2nd (outside) island is newer
567     u8_t l4ctx_l4_bd_chain_v2p_gen_count;
568     u16_t l4ctx_l4_bd_chain_nx_bdidx;
569     u16_t l4ctx_l4_bd_chain_gen_used;
570     u16_t l4ctx_l4_bd_chain_nx_boff;
571     u32_t l4ctx_l4_bd_chain_cmpl_seq;
572     u32_t l4ctx_l4_bd_chain_cmpl_bdhaddr_hi;
573     u32_t l4ctx_l4_bd_chain_cmpl_bdhaddr_lo;
574     u16_t l4ctx_l4_bd_chain_gen_size;
575     u16_t l4ctx_l4_bd_chain_cmpl_bdidx;
576     u32_t l4ctx_l4_bd_chain_io_seq;
577     u32_t l4ctx_l4_bd_chain_hole_seq;
578     u32_t l4ctx_l4_bd_chain_end_seq;
579     u32_t l4ctx_l4_bd_chain_bseq_lead;
580     u32_t l4ctx_l4_bd_chain_push_seq;
581     u32_t l4ctx_l4_bd_chain_gen_start_seq;
582     u32_t l4ctx_l4_bd_chain_gen_seq;
583     u32_t l4ctx_l4_bd_chain_gen_bfr_hi;
584     u32_t l4ctx_l4_bd_chain_gen_bfr_lo;
585     u32_t l4ctx_tx_comp_step;
586     u16_t l4ctx_max_rt_tick;               // maximum total retransmit timeout (in ticks)
587     u16_t l4ctx_total_rt_tick;             // total retransmit timeout  (in ticks)
588     u32_t l4ctx_ooo_fin_seq;
589     u32_t l4ctx_unused;
590     u32_t l4ctx_tcp_last_rcv_win_seq;
591     u32_t l4ctx_tcp_save_cwin;
592     u8_t  l4ctx_tcp_flow_state;
593         #define  TOE_FLOW_STATE_NORMAL_INIT           (0<<0)
594         #define  TOE_FLOW_STATE_NORMAL_RUNNING        (1<<0)
595         #define  TOE_FLOW_STATE_LIMIT_TX_ACTIVE       (2<<0)
596         #define  TOE_FLOW_STATE_IN_LOSS_RECOVERY      (3<<0)
597         #define  TOE_FLOW_STATE_FAST_RETX_INIT1       (4<<0)
598         #define  TOE_FLOW_STATE_FAST_RETX_INIT2       (5<<0)
599         #define  TOE_FLOW_STATE_FAST_RETX_RELOAD      (6<<0)
600         #define  TOE_FLOW_STATE_FAST_RETX_ACTIVE1     (7<<0)
601         #define  TOE_FLOW_STATE_FAST_RETX_ACTIVE2     (8<<0)
602         #define  TOE_FLOW_STATE_FAST_RECOVERY_INIT1   (9<<0)
603         #define  TOE_FLOW_STATE_FAST_RECOVERY_INIT2   (10<<0)
604         #define  TOE_FLOW_STATE_FAST_RECOVERY_ACTIVE  (11<<0)
605         #define  TOE_FLOW_STATE_FAST_RECOVERY_EXIT    (12<<0)
606         #define  TCP_FLOW_NORMAL(x)         ((x) <= TOE_FLOW_STATE_NORMAL_RUNNING)
607         #define  TCP_FLOW_LIMIT_TX(x)       ((x) == TOE_FLOW_STATE_LIMIT_TX_ACTIVE )
608         #define  TCP_FLOW_LOSS_RECOVERY(x)  ((x) == TOE_FLOW_STATE_LOSS_RECOVERY )
609         #define  TCP_FLOW_FAST_RETX(x)      ((x) >= TOE_FLOW_STATE_FAST_RETX_INIT1  \
610                                           && (x) <= TOE_FLOW_STATE_FAST_RECOVERY_ACTIVE)
611         #define  TCP_FLOW_FAST_RECOVERY(x)  ((x) >= TOE_FLOW_STATE_FAST_RECOVERY_INIT1)
612     u8_t  l4ctx_tcp_partial_ack_cnt;
613     u8_t  l4ctx_timer1_mode;        // timer1 is overloaded for retx, persist, sws prevention and FIN_WAIT2 timer
614         #define TIMER1_RETX_MODE                      (0)
615         #define TIMER1_PERSIST_MODE                   (1)
616         #define TIMER1_SWS_PREVENT_MODE               (2)
617         #define TIMER1_FIN_WAIT2_MODE                 (3)
618     u8_t  l4ctx_ooo_fin_upload_state;
619         #define OOO_FIN_UPLOAD_IDLE                   (0<<0)
620         #define OOO_FIN_UPLOAD_DEFER                  (1<<0)
621         #define OOO_FIN_UPLOAD_NOW                    (2<<0)
622         #define OOO_FIN_UPLOAD_DONE                   (3<<0)
623         #define OOO_FIN_UPLOAD_DEFER_PENDING          (4<<0)
624         #define OOO_FIN_UPLOAD_UNKNOWN                (5<<0)
625     u32_t l4ctx_last_fin_seq;              // last rx seq # in FIN packet
626     u8_t  l4ctx_persist_probe_cnt;
627     u8_t  l4ctx_reload_comp_status;
628         #define RELOAD_COMP_IDLE                      (0<<0)
629         #define RELOAD_COMP_HOST_PENDING              (1<<0)
630         #define RELOAD_COMP_ONCHIP_PENDING            (2<<0)
631     u8_t  l4ctx_tx_flags;
632         #define L4CTX_TX_FLAGS_IN_COALESCE            (1<<1)
633         #define L4CTX_TX_FLAGS_IND_SILLY_WIN          (1<<2)
634         #define L4CTX_TX_FLAGS_LARGE_BD               (1<<3)
635     u8_t  l4ctx_ka_probe_cnt;
636 
637     u32_t l4ctx_tcp_disconnect_seq;          // last snd seq # before disconnecting
638     u32_t l4ctx_tcp_snd_recover;
639     u32_t l4ctx_reply_ts;
640         #define TOE_RTT_SAMPLED                       (1<<0)
641     u16_t l4ctx_ka_timeout_tick;
642     u16_t l4ctx_ka_interval_tick;
643 
644     u8_t  l4ctx_tx_comp_prod;
645     u8_t  l4ctx_tx_comp_cons;
646     u8_t  l4ctx_ka_max_probe_cnt;
647     u8_t  l4ctx_in_generic;
648 
649     u32_t l4ctx_host_win_update;
650     u16_t l4ctx_cam_index;
651     u16_t l4ctx_gen_buff_accum;
652 } l4_context_b_t;
653 
654 
655 
656 
657 /*
658  *  l4_context_l definition
659  */
660 typedef struct l4_context_l
661 {
662     u8_t l4ctx_gen_bd_cid;
663     u8_t l4ctx_bd_pre_read;
664     u8_t l4ctx_size;
665     u8_t l4ctx_ctx_type;
666         #define L4CTX_TYPE_TYPE                             (0xf<<4)
667         #define L4CTX_TYPE_TYPE_EMPTY                       (0<<4)
668         #define L4CTX_TYPE_TYPE_L2                          (1<<4)
669         #define L4CTX_TYPE_TYPE_TCP                         (2<<4)
670         #define L4CTX_TYPE_TYPE_L5                          (3<<4)
671         #define L4CTX_TYPE_TYPE_L2_BD_CHN                   (4<<4)
672         #define L4CTX_TYPE_TYPE_ISCSI                       (5<<4)
673 
674     u8_t    l4ctx_challenge_ack_state;         // refer to tcpm-tcpsecure-09 requirement
675     u8_t    l4ctx_force_ack_pending;
676     u8_t l4ctx_oubits;
677         #define L4CTX_OUBITS_ACTIVATE                       (1<<0)
678         #define L4CTX_OUBITS_CP_UPLOAD                      (1<<1)
679         #define L4CTX_OUBITS_RXP_UPLOAD                     (1<<2)
680         #define L4CTX_OUBITS_TXP_UPLOAD                     (1<<3)
681         #define L4CTX_OUBITS_COM_RX_UPLOAD                  (1<<4)
682         #define L4CTX_OUBITS_COM_TX_UPLOAD                  (1<<5)
683         #define L4CTX_OUBITS_CP_UPLOAD_COMP                 (1<<6)
684 
685     u8_t l4ctx_gen_bd_max;
686     u8_t l4ctx_tcp_retx_defer;
687     u8_t unused;
688     u16_t l4ctx_tcp_pgid;
689     u32_t l4ctx_tcp_timer1;
690         #define L4CTX_TCP_TIMER1_DISABLE                    (1UL<<0)
691         #define L4CTX_TCP_TIMER1_VALUE                      (0x7fffffffL<<1)
692 
693     u16_t l4ctx_tcp_timer3;
694         #define L4CTX_TCP_TIMER3_DISABLE                    (1<<0)
695         #define L4CTX_TCP_TIMER3_VALUE                      (0x7fff<<1)
696 
697     u16_t l4ctx_tcp_timer2;
698         #define L4CTX_TCP_TIMER2_DISABLE                    (1<<0)
699         #define L4CTX_TCP_TIMER2_VALUE                      (0x7fff<<1)
700 
701     u16_t l4ctx_tcp_timer5;
702         #define L4CTX_TCP_TIMER5_DISABLE                    (1<<0)
703         #define L4CTX_TCP_TIMER5_VALUE                      (0x7fff<<1)
704 
705     u16_t l4ctx_tcp_timer4;
706         #define L4CTX_TCP_TIMER4_DISABLE                    (1<<0)
707         #define L4CTX_TCP_TIMER4_VALUE                      (0x7fff<<1)
708 
709     u32_t l4ctx_tcp_snd_wl1;
710     u32_t l4ctx_tcp_snd_wl2;
711     u8_t l4ctx_tcp_modes;
712         #define L4CTX_TCP_MODES_RST_INDICATED               (1<<0)
713         #define L4CTX_TCP_MODES_DISC_BD                     (1<<1)
714         #define L4CTX_TCP_MODES_UPLOAD_INITED               (1<<2)
715         #define L4CTX_TCP_MODES_RMT_DISC                    (1<<3)
716         #define L4CTX_TCP_MODES_PG_INVALIDATED              (1<<4)
717         #define L4CTX_TCP_MODES_ABORT_PENDING               (1<<5)
718         #define L4CTX_TCP_MODES_DISC_PENDING                (1<<6)
719         #define L4CTX_TCP_MODES_SS                          (1<<7)
720 
721     u8_t l4ctx_tcp_dack;
722     u8_t l4ctx_tcp_tos;
723     u8_t l4ctx_tcp_ttl;
724     u32_t l4ctx_tcp_max_adv_win;
725     u32_t l4ctx_tcp_rto_intvl;     // current  unbounded retransmission timeout (RTO)
726     u32_t l4ctx_tcp_ip_src;
727     u32_t l4ctx_tcp_ip_dst;
728     u8_t l4ctx_tcp_tcp_hlen;
729     u8_t l4ctx_tcp_rcv_seg_scale;
730     u8_t l4ctx_tcp_snd_seg_scale;
731     u8_t l4ctx_tcp_iphdr_nbytes;
732     u16_t l4ctx_tcp_dst_port;
733     u16_t l4ctx_tcp_src_port;
734     u8_t l4ctx_tcp_state;
735         #define L4CTX_TCP_STATE_VALUE                       (0xff<<0)
736         #define L4CTX_TCP_STATE_VALUE_UNDEFINED             (0<<0)
737         #define L4CTX_TCP_STATE_VALUE_LISTEN                (2<<0)
738         #define L4CTX_TCP_STATE_VALUE_SYN_SENT              (4<<0)
739         #define L4CTX_TCP_STATE_VALUE_SYN_RECV              (6<<0)
740         #define L4CTX_TCP_STATE_VALUE_CLOSE_WAIT            (8<<0)
741         #define L4CTX_TCP_STATE_VALUE_ESTABLISHED           (10<<0)
742         #define L4CTX_TCP_STATE_VALUE_FIN_WAIT1             (12<<0)
743         #define L4CTX_TCP_STATE_VALUE_FIN_WAIT2             (14<<0)
744         #define L4CTX_TCP_STATE_VALUE_TIME_WAIT             (16<<0)
745         #define L4CTX_TCP_STATE_VALUE_CLOSED                (18<<0)
746         #define L4CTX_TCP_STATE_VALUE_LAST_ACK              (20<<0)
747         #define L4CTX_TCP_STATE_VALUE_CLOSING               (22<<0)
748         #define L4CTX_TCP_STATE_VALUE_ABORT_CONNECTION      (24<<0)
749 
750     u8_t l4ctx_tcp_flags;
751         #define L4CTX_TCP_FLAGS_NO_DELAY_ACK                (1<<0)
752         #define L4CTX_TCP_FLAGS_KEEP_ALIVE                  (1<<1)
753         #define L4CTX_TCP_FLAGS_NAGLE                       (1<<2)
754         #define L4CTX_TCP_FLAGS_TIME_STAMP                  (1<<3)
755         #define L4CTX_TCP_FLAGS_SACK                        (1<<4)
756         #define L4CTX_TCP_FLAGS_SEG_SCALING                 (1<<5)
757         #define L4CTX_TCP_FLAGS_OPTION2                     (1<<6)
758         #define L4CTX_TCP_FLAGS_SEND_SYN                    (1<<7)
759 
760     u16_t l4ctx_tcp_mss;
761     u32_t l4ctx_tcp_rcv_next;
762     u32_t l4ctx_last_ack_sent;
763     u32_t l4ctx_tcp_rcv_win_seq;
764     u32_t l4ctx_tcp_snd_una;
765     u32_t l4ctx_tcp_snd_next;
766     u32_t l4ctx_tcp_snd_max;
767     u32_t l4ctx_tcp_snd_win;
768     u32_t l4ctx_tcp_snd_cwin;
769     u32_t l4ctx_tcp_tstamp;
770     u32_t l4ctx_tcp_ssthresh;
771     u16_t l4ctx_tcp_sm_delta;
772     u16_t l4ctx_tcp_sm_rtt;
773     u32_t l4ctx_tcp_max_snd_win;
774     u32_t l4ctx_tcp_tsch_snd_next;
775     u32_t l4ctx_tcp_slot_size;
776         #define L4CTX_TCP_SLOT_SIZE_SLOT_SIZE               (0xffffffL<<0)
777         #define L4CTX_TCP_SLOT_SIZE_CMD_MAX                 (0x7fL<<24)
778         #define L4CTX_TCP_SLOT_SIZE_STOP                    (1UL<<31)
779 
780     u8_t l4ctx_tcp_tsch_xnum;
781         #define L4CTX_TCP_TSCH_XNUM_VAL                     (0x7f<<0)
782         #define L4CTX_TCP_TSCH_XNUM_L4                      (1<<7)
783 
784     u8_t l4ctx_tcp_cons_retx_num;
785     u8_t l4ctx_tcp_tsch_cmd;
786     u8_t l4ctx_tcp_cp_cmd;
787     u8_t l4ctx_tcp_tsch_cons_retx_num;
788     u8_t l4ctx_tcp_prod_retx_num;
789     u8_t l4ctx_tcp_tx_protocol_flags;
790     u8_t l4ctx_tcp_num_dupack;
791     u8_t l4ctx_tcp_txp_cmd;
792     u8_t l4ctx_tcp_upload_reason;
793         #define L4CTX_TCP_UPLOAD_REASON_KEEP_ALIVE          (1<<0)
794         #define L4CTX_TCP_UPLOAD_REASON_FIN                 (1<<1)
795         #define L4CTX_TCP_UPLOAD_REASON_URG                 (1<<2)
796         #define L4CTX_TCP_UPLOAD_REASON_FRAGMENT            (1<<3)
797         #define L4CTX_TCP_UPLOAD_REASON_IP_OPTION           (1<<4)
798         #define L4CTX_TCP_UPLOAD_REASON_RST                 (1<<5)
799         #define L4CTX_TCP_UPLOAD_REASON_SYN                 (1<<6)
800         #define L4CTX_TCP_UPLOAD_REASON_TIMEOUT             (1<<7)
801 
802     u8_t l4ctx_tcp_num_retx;
803     u8_t l4ctx_tcp_comp_cons_retx_num;
804     u32_t l4ctx_tcp_offload_seq;
805     tcp_context_cmd_cell_te_t l4ctx_cmd[1];
806     u16_t l4ctx_l4_bd_chain_host_bdidx;
807     u8_t l4ctx_l4_bd_chain_host_gen_count;
808     u8_t l4ctx_l4_bd_chain_v2p_proc1flags;
809         #define L4CTX_L4_BD_CHAIN_V2P_PROC1FLAGS_BD_CHN_FLUSH             (1<<0)
810         #define L4CTX_L4_BD_CHAIN_V2P_PROC1FLAGS_BD_CHN_FORCE_PUSH        (1<<1)
811     u32_t l4ctx_l4_bd_chain_host_bseq;
812     u32_t l4ctx_l4_bd_chain_nx_bdhaddr_hi;
813     u32_t l4ctx_l4_bd_chain_nx_bdhaddr_lo;
814     u32_t l4ctx_l4_bd_chain_nx_seq;
815     u16_t l4ctx_l4_bd_chain_nx_bdidx;
816     u8_t l4ctx_l4_bd_chain_v2p_gen_count;
817     u8_t l4ctx_l4_bd_chain_v2p_flags;
818     u16_t l4ctx_l4_bd_chain_nx_boff;
819     u16_t l4ctx_l4_bd_chain_gen_used;
820     u32_t l4ctx_l4_bd_chain_cmpl_seq;
821     u32_t l4ctx_l4_bd_chain_cmpl_bdhaddr_hi;
822     u32_t l4ctx_l4_bd_chain_cmpl_bdhaddr_lo;
823     u16_t l4ctx_l4_bd_chain_cmpl_bdidx;
824     u16_t l4ctx_l4_bd_chain_gen_size;
825     u32_t l4ctx_l4_bd_chain_io_seq;
826     u32_t l4ctx_l4_bd_chain_hole_seq;
827     u32_t l4ctx_l4_bd_chain_end_seq;
828     u32_t l4ctx_l4_bd_chain_bseq_lead;
829     u32_t l4ctx_l4_bd_chain_push_seq;
830     u32_t l4ctx_l4_bd_chain_gen_start_seq;
831     u32_t l4ctx_l4_bd_chain_gen_seq;
832     u32_t l4ctx_l4_bd_chain_gen_bfr_hi;
833     u32_t l4ctx_l4_bd_chain_gen_bfr_lo;
834     u32_t l4ctx_tx_comp_step;
835     u16_t l4ctx_total_rt_tick;             // total retransmit timeout  (in ticks)
836     u16_t l4ctx_max_rt_tick;               // maximum total retransmit timeout (in ticks)
837     u32_t l4ctx_ooo_fin_seq;
838     u32_t l4ctx_unused;
839     u32_t l4ctx_tcp_last_rcv_win_seq;
840     u32_t l4ctx_tcp_save_cwin;
841     u8_t  l4ctx_ooo_fin_upload_state;
842     u8_t  l4ctx_timer1_mode;        // timer1 is overloaded for retx, persist, sws prevention and FIN_WAIT2 timer
843     u8_t  l4ctx_tcp_partial_ack_cnt;
844     u8_t  l4ctx_tcp_flow_state;
845         #define  TOE_FLOW_STATE_NORMAL_INIT           (0<<0)
846         #define  TOE_FLOW_STATE_NORMAL_RUNNING        (1<<0)
847         #define  TOE_FLOW_STATE_LIMIT_TX_ACTIVE       (2<<0)
848         #define  TOE_FLOW_STATE_IN_LOSS_RECOVERY      (3<<0)
849         #define  TOE_FLOW_STATE_FAST_RETX_INIT1       (4<<0)
850         #define  TOE_FLOW_STATE_FAST_RETX_INIT2       (5<<0)
851         #define  TOE_FLOW_STATE_FAST_RETX_RELOAD      (6<<0)
852         #define  TOE_FLOW_STATE_FAST_RETX_ACTIVE1     (7<<0)
853         #define  TOE_FLOW_STATE_FAST_RETX_ACTIVE2     (8<<0)
854         #define  TOE_FLOW_STATE_FAST_RECOVERY_INIT1   (9<<0)
855         #define  TOE_FLOW_STATE_FAST_RECOVERY_INIT2   (10<<0)
856         #define  TOE_FLOW_STATE_FAST_RECOVERY_ACTIVE  (11<<0)
857         #define  TOE_FLOW_STATE_FAST_RECOVERY_EXIT    (12<<0)
858     u32_t l4ctx_last_fin_seq;              // last rx seq # in FIN packet
859     u8_t  l4ctx_ka_probe_cnt;
860     u8_t  l4ctx_tx_flags;
861         #define L4CTX_TX_FLAGS_IN_COALESCE            (1<<1)
862         #define L4CTX_TX_FLAGS_IND_SILLY_WIN          (1<<2)
863     u8_t  l4ctx_reload_comp_status;
864         #define RELOAD_COMP_IDLE                      (0<<0)
865         #define RELOAD_COMP_HOST_PENDING              (1<<0)
866         #define RELOAD_COMP_ONCHIP_PENDING            (2<<0)
867     u8_t  l4ctx_persist_probe_cnt;
868     u32_t l4ctx_tcp_disconnect_seq;          // last snd seq # before disconnecting
869     u32_t l4ctx_tcp_snd_recover;
870     u32_t l4ctx_reply_ts;
871         #define TOE_RTT_SAMPLED                       (1<<0)
872     u16_t l4ctx_ka_interval;
873     u16_t l4ctx_ka_timeout;
874     u8_t  l4ctx_in_generic;
875     u8_t  l4ctx_ka_max_probe_cnt;
876     u8_t  l4ctx_tx_comp_con;
877     u8_t  l4ctx_tx_comp_prod;
878     u32_t l4ctx_host_win_update;
879     u16_t l4ctx_gen_buff_accum;
880     u16_t l4ctx_cam_index;
881 } l4_context_l_t;
882 
883 
884 
885 
886 
887 /*
888  * l4_context select
889  */
890 #if defined(LITTLE_ENDIAN)
891     typedef l4_context_l_t l4_context_t;
892 #elif defined(BIG_ENDIAN)
893     typedef l4_context_b_t l4_context_t;
894 #endif
895 
896 
897 #endif /* _TOE_CTX_H */
898 
899