]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - sys/dev/cxgb/ulp/tom/cxgb_toepcb.h
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / sys / dev / cxgb / ulp / tom / cxgb_toepcb.h
1 /*-
2  * Copyright (c) 2007-2008, Chelsio Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  *    this list of conditions and the following disclaimer.
10  *
11  * 2. Neither the name of the Chelsio Corporation nor the names of its
12  *    contributors may be used to endorse or promote products derived from
13  *    this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  *
27  * $FreeBSD$
28  */
29 #ifndef CXGB_TOEPCB_H_
30 #define CXGB_TOEPCB_H_
31 #include <sys/bus.h>
32 #include <sys/condvar.h>
33 #include <sys/mbufq.h>
34
35 struct toepcb {
36         struct toedev           *tp_toedev;
37         struct l2t_entry        *tp_l2t;
38         unsigned int            tp_tid;
39         int                     tp_wr_max;
40         int                     tp_wr_avail;
41         int                     tp_wr_unacked;
42         int                     tp_delack_mode;
43         int                     tp_mtu_idx;
44         int                     tp_ulp_mode;
45         int                     tp_qset_idx;
46         int                     tp_mss_clamp;
47         int                     tp_qset;
48         int                     tp_flags;
49         int                     tp_enqueued_bytes;
50         int                     tp_page_count;
51         int                     tp_state;
52
53         tcp_seq                 tp_iss;
54         tcp_seq                 tp_delack_seq;
55         tcp_seq                 tp_rcv_wup;
56         tcp_seq                 tp_copied_seq;
57         uint64_t                tp_write_seq;
58
59         volatile int            tp_refcount;
60         vm_page_t               *tp_pages;
61         
62         struct tcpcb            *tp_tp;
63         struct mbuf             *tp_m_last;
64         bus_dma_tag_t           tp_tx_dmat;
65         bus_dma_tag_t           tp_rx_dmat;
66         bus_dmamap_t            tp_dmamap;
67
68         LIST_ENTRY(toepcb)      synq_entry;
69         struct mbuf_head        wr_list;
70         struct mbuf_head        out_of_order_queue;
71         struct ddp_state        tp_ddp_state;
72         struct cv               tp_cv;
73                            
74 };
75
76 static inline void
77 reset_wr_list(struct toepcb *toep)
78 {
79
80         mbufq_init(&toep->wr_list);
81 }
82
83 static inline void
84 purge_wr_queue(struct toepcb *toep)
85 {
86         struct mbuf *m;
87         
88         while ((m = mbufq_dequeue(&toep->wr_list)) != NULL) 
89                 m_freem(m);
90 }
91
92 static inline void
93 enqueue_wr(struct toepcb *toep, struct mbuf *m)
94 {
95
96         mbufq_tail(&toep->wr_list, m);
97 }
98
99 static inline struct mbuf *
100 peek_wr(const struct toepcb *toep)
101 {
102
103         return (mbufq_peek(&toep->wr_list));
104 }
105
106 static inline struct mbuf *
107 dequeue_wr(struct toepcb *toep)
108 {
109
110         return (mbufq_dequeue(&toep->wr_list));
111 }
112
113 #define wr_queue_walk(toep, m) \
114         for (m = peek_wr(toep); m; m = m->m_nextpkt)
115
116
117
118 #endif
119