1 /**************************************************************************
3 Copyright (c) 2007, Chelsio Inc.
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
12 2. Neither the name of the Chelsio Corporation nor the names of its
13 contributors may be used to endorse or promote products derived from
14 this software without specific prior written permission.
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 POSSIBILITY OF SUCH DAMAGE.
28 ***************************************************************************/
30 #include <sys/cdefs.h>
31 __FBSDID("$FreeBSD$");
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/kernel.h>
36 #include <sys/fcntl.h>
37 #include <sys/limits.h>
40 #include <sys/module.h>
41 #include <sys/mutex.h>
43 #include <sys/sockopt.h>
44 #include <sys/sockstate.h>
45 #include <sys/sockbuf.h>
46 #include <sys/socket.h>
47 #include <sys/sysctl.h>
49 #include <sys/syslog.h>
52 #include <net/route.h>
54 #include <netinet/in.h>
55 #include <netinet/in_pcb.h>
56 #include <netinet/in_systm.h>
57 #include <netinet/in_var.h>
59 #include <cxgb_osdep.h>
60 #include <sys/mbufq.h>
62 #include <netinet/tcp.h>
63 #include <netinet/tcp_var.h>
64 #include <netinet/tcp_fsm.h>
65 #include <net/route.h>
68 #include <common/cxgb_firmware_exports.h>
69 #include <common/cxgb_tcb.h>
70 #include <common/cxgb_ctl_defs.h>
71 #include <common/cxgb_t3_cpl.h>
72 #include <cxgb_offload.h>
73 #include <cxgb_include.h>
74 #include <ulp/toecore/cxgb_toedev.h>
75 #include <ulp/tom/cxgb_tom.h>
76 #include <ulp/tom/cxgb_defs.h>
77 #include <ulp/tom/cxgb_t3_ddp.h>
79 /* Avoid clutter in the hw.* space, keep all toe tunables within hw.cxgb */
80 SYSCTL_DECL(_hw_cxgb);
81 SYSCTL_NODE(_hw_cxgb, OID_AUTO, toe, CTLFLAG_RD, 0, "TOE parameters");
83 static struct tom_tunables default_tunable_vals = {
84 .max_host_sndbuf = 32 * 1024,
87 .rx_credit_thres = 15 * 1024,
92 .soft_backlog_limit = 0,
94 .ddp_thres = 14 * 4096,
95 .ddp_copy_limit = 13 * 4096,
98 .zcopy_sosend_enabled = 0,
99 .zcopy_sosend_partial_thres = 40960,
100 .zcopy_sosend_partial_copy = 4096 * 3,
101 .zcopy_sosend_thres = 128 * 1024,
102 .zcopy_sosend_copy = 4096 * 2,
103 .zcopy_sosend_ret_pending_dma = 1,
107 static int activated = 1;
108 TUNABLE_INT("hw.cxgb.toe.activated", &activated);
109 SYSCTL_UINT(_hw_cxgb_toe, OID_AUTO, activated, CTLFLAG_RDTUN, &activated, 0,
110 "enable TOE at init time");
113 TUNABLE_INT("hw.cxgb.toe.ddp", &ddp);
114 SYSCTL_UINT(_hw_cxgb_toe, OID_AUTO, ddp, CTLFLAG_RDTUN, &ddp, 0, "enable DDP");
117 t3_init_tunables(struct tom_data *t)
119 t->conf = default_tunable_vals;
121 /* Adjust tunables */
122 t->conf.activated = activated;
125 /* Now apply device specific fixups. */
126 t->conf.mss = T3C_DATA(t->cdev)->tx_max_chunk;
127 t->conf.max_wrs = T3C_DATA(t->cdev)->max_wrs;
131 t3_sysctl_register(struct adapter *sc, const struct tom_tunables *p)
133 struct sysctl_ctx_list *ctx;
134 struct sysctl_oid_list *children;
136 ctx = device_get_sysctl_ctx(sc->dev);
137 children = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev));