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