2 /**************************************************************************
4 Copyright (c) 2007, Chelsio Inc.
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
10 1. Redistributions of source code must retain the above copyright notice,
11 this list of conditions and the following disclaimer.
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.
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.
32 ***************************************************************************/
35 #include <sys/protosw.h>
36 #include <netinet/toedev.h>
38 #define LISTEN_INFO_HASH_SIZE 32
41 struct listen_info *next; /* Link to next entry */
42 struct socket *so; /* The listening socket */
43 unsigned int stid; /* The server TID */
48 * TOM tunable parameters. They can be manipulated through sysctl(2) or /proc.
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
75 TAILQ_ENTRY(tom_data) entry;
81 struct cxgb_client *client;
82 struct tom_tunables conf;
83 struct tom_sysctl_table *sysctl;
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.
90 struct listen_info *listen_hash_tab[LISTEN_INFO_HASH_SIZE];
91 struct mtx listen_lock;
93 struct mbuf_head deferq;
94 struct task deferq_task;
96 struct socket **tid_release_list;
97 struct mtx tid_release_lock;
98 struct task tid_release_task;
100 volatile int tx_dma_pending;
102 unsigned int ddp_llimit;
103 unsigned int ddp_ulimit;
105 unsigned int rx_page_size;
109 struct mtx ppod_map_lock;
111 struct adap_ports *ports;
112 struct taskqueue *tq;
118 struct tom_data *tom_data;
120 LIST_HEAD(, toepcb) synq_head;
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)
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)
140 void t3_init_tunables(struct tom_data *t);
142 void t3_sysctl_register(struct adapter *sc, const struct tom_tunables *p);
144 static __inline struct mbuf *
145 m_gethdr_nofail(int len)
149 m = m_gethdr(M_NOWAIT, MT_DATA);
151 panic("implement lowmem cache\n");
154 KASSERT(len < MHLEN, ("requested header size too large for mbuf"));
155 m->m_pkthdr.len = m->m_len = len;