]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - sys/dev/cxgb/ulp/tom/cxgb_tom.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_tom.h
1
2 /**************************************************************************
3
4 Copyright (c) 2007, Chelsio Inc.
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 are met:
9
10  1. Redistributions of source code must retain the above copyright notice,
11     this list of conditions and the following disclaimer.
12
13  2. Neither the name of the Chelsio Corporation nor the names of its
14     contributors may be used to endorse or promote products derived from
15     this software without specific prior written permission.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 POSSIBILITY OF SUCH DAMAGE.
28
29
30 $FreeBSD$
31
32 ***************************************************************************/
33 #ifndef CXGB_TOM_H_
34 #define CXGB_TOM_H_
35 #include <sys/protosw.h>
36 #include <netinet/toedev.h>
37
38 #define LISTEN_INFO_HASH_SIZE 32 
39
40 struct listen_info {
41         struct listen_info *next;  /* Link to next entry */
42         struct socket *so;         /* The listening socket */
43         unsigned int stid;         /* The server TID */
44 };
45
46
47 /*
48  * TOM tunable parameters.  They can be manipulated through sysctl(2) or /proc.
49  */
50 struct tom_tunables {
51         int max_host_sndbuf;    // max host RAM consumed by a sndbuf
52         int tx_hold_thres;      // push/pull threshold for non-full TX sk_buffs
53         int max_wrs;            // max # of outstanding WRs per connection
54         int rx_credit_thres;    // min # of RX credits needed for RX_DATA_ACK
55         int cong_alg;           // Congestion control algorithm
56         int mss;                // max TX_DATA WR payload size
57         int delack;             // delayed ACK control
58         int max_conn;           // maximum number of offloaded connections
59         int soft_backlog_limit; // whether the listen backlog limit is soft
60         int ddp;                // whether to put new connections in DDP mode
61         int ddp_thres;          // min recvmsg size before activating DDP
62         int ddp_copy_limit;     // capacity of kernel DDP buffer
63         int ddp_push_wait;      // whether blocking DDP waits for PSH flag
64         int ddp_rcvcoalesce;    // whether receive coalescing is enabled
65         int zcopy_sosend_enabled; // < is never zcopied
66         int zcopy_sosend_partial_thres; // < is never zcopied
67         int zcopy_sosend_partial_copy; // bytes copied in partial zcopy
68         int zcopy_sosend_thres;// >= are mostly zcopied
69         int zcopy_sosend_copy; // bytes coped in zcopied
70         int zcopy_sosend_ret_pending_dma;// pot. return while pending DMA
71         int activated;          // TOE engine activation state
72 };
73
74 struct tom_data {
75         TAILQ_ENTRY(tom_data) entry;
76                               
77         struct t3cdev *cdev;
78         struct pci_dev *pdev;
79         struct toedev tdev;
80
81         struct cxgb_client *client;
82         struct tom_tunables conf;
83         struct tom_sysctl_table *sysctl;
84
85         /*
86          * The next three locks listen_lock, deferq.lock, and tid_release_lock
87          * are used rarely so we let them potentially share a cacheline.
88          */
89
90         struct listen_info *listen_hash_tab[LISTEN_INFO_HASH_SIZE];
91         struct mtx listen_lock;
92
93         struct mbuf_head deferq;
94         struct task deferq_task;
95
96         struct socket **tid_release_list;
97         struct mtx tid_release_lock;
98         struct task tid_release_task;
99
100         volatile int tx_dma_pending;
101         
102         unsigned int ddp_llimit;
103         unsigned int ddp_ulimit;
104
105         unsigned int rx_page_size;
106
107         u8 *ppod_map;
108         unsigned int nppods;
109         struct mtx ppod_map_lock;
110         
111         struct adap_ports *ports;
112         struct taskqueue *tq;
113 };
114
115
116 struct listen_ctx {
117         struct socket *lso;
118         struct tom_data *tom_data;
119         int ulp_mode;
120         LIST_HEAD(, toepcb) synq_head;
121         
122 };
123
124 #define TOM_DATA(dev) (*(struct tom_data **)&(dev)->tod_l4opt)
125 #define T3C_DEV(sk) ((TOM_DATA(TOE_DEV(sk)))->cdev)
126 #define TOEP_T3C_DEV(toep) (TOM_DATA(toep->tp_toedev)->cdev)
127 #define TOM_TUNABLE(dev, param) (TOM_DATA(dev)->conf.param)
128
129 #define TP_DATASENT             (1 << 0)
130 #define TP_TX_WAIT_IDLE         (1 << 1)
131 #define TP_FIN_SENT             (1 << 2)
132 #define TP_ABORT_RPL_PENDING    (1 << 3)
133 #define TP_ABORT_SHUTDOWN       (1 << 4)
134 #define TP_ABORT_RPL_RCVD       (1 << 5)
135 #define TP_ABORT_REQ_RCVD       (1 << 6)
136 #define TP_CLOSE_CON_REQUESTED  (1 << 7)
137 #define TP_SYN_RCVD             (1 << 8)
138 #define TP_ESTABLISHED          (1 << 9)
139
140 void t3_init_tunables(struct tom_data *t);
141
142 void t3_sysctl_register(struct adapter *sc, const struct tom_tunables *p);
143
144 static __inline struct mbuf *
145 m_gethdr_nofail(int len)
146 {
147         struct mbuf *m;
148         
149         m = m_gethdr(M_NOWAIT, MT_DATA);
150         if (m == NULL) {
151                 panic("implement lowmem cache\n");
152         }
153         
154         KASSERT(len < MHLEN, ("requested header size too large for mbuf"));     
155         m->m_pkthdr.len = m->m_len = len;
156         return (m);
157 }
158
159
160 #endif