1/* 2 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 3 * 4 * Copyright (c) 2011, 2012, Intel Corporation. 5 * 6 * Author: Eric Barton <eric@bartonsoftware.com> 7 * 8 * Portals is free software; you can redistribute it and/or 9 * modify it under the terms of version 2 of the GNU General Public 10 * License as published by the Free Software Foundation. 11 * 12 * Portals is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with Portals; if not, write to the Free Software 19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 */ 21 22#include "socklnd.h" 23 24static int sock_timeout = 50; 25module_param(sock_timeout, int, 0644); 26MODULE_PARM_DESC(sock_timeout, "dead socket timeout (seconds)"); 27 28static int credits = 256; 29module_param(credits, int, 0444); 30MODULE_PARM_DESC(credits, "# concurrent sends"); 31 32static int peer_credits = 8; 33module_param(peer_credits, int, 0444); 34MODULE_PARM_DESC(peer_credits, "# concurrent sends to 1 peer"); 35 36static int peer_buffer_credits; 37module_param(peer_buffer_credits, int, 0444); 38MODULE_PARM_DESC(peer_buffer_credits, "# per-peer router buffer credits"); 39 40static int peer_timeout = 180; 41module_param(peer_timeout, int, 0444); 42MODULE_PARM_DESC(peer_timeout, "Seconds without aliveness news to declare peer dead (<=0 to disable)"); 43 44/* Number of daemons in each thread pool which is percpt, 45 * we will estimate reasonable value based on CPUs if it's not set. */ 46static unsigned int nscheds; 47module_param(nscheds, int, 0444); 48MODULE_PARM_DESC(nscheds, "# scheduler daemons in each pool while starting"); 49 50static int nconnds = 4; 51module_param(nconnds, int, 0444); 52MODULE_PARM_DESC(nconnds, "# connection daemons while starting"); 53 54static int nconnds_max = 64; 55module_param(nconnds_max, int, 0444); 56MODULE_PARM_DESC(nconnds_max, "max # connection daemons"); 57 58static int min_reconnectms = 1000; 59module_param(min_reconnectms, int, 0644); 60MODULE_PARM_DESC(min_reconnectms, "min connection retry interval (mS)"); 61 62static int max_reconnectms = 60000; 63module_param(max_reconnectms, int, 0644); 64MODULE_PARM_DESC(max_reconnectms, "max connection retry interval (mS)"); 65 66# define DEFAULT_EAGER_ACK 0 67static int eager_ack = DEFAULT_EAGER_ACK; 68module_param(eager_ack, int, 0644); 69MODULE_PARM_DESC(eager_ack, "send tcp ack packets eagerly"); 70 71static int typed_conns = 1; 72module_param(typed_conns, int, 0444); 73MODULE_PARM_DESC(typed_conns, "use different sockets for bulk"); 74 75static int min_bulk = (1<<10); 76module_param(min_bulk, int, 0644); 77MODULE_PARM_DESC(min_bulk, "smallest 'large' message"); 78 79# define DEFAULT_BUFFER_SIZE 0 80static int tx_buffer_size = DEFAULT_BUFFER_SIZE; 81module_param(tx_buffer_size, int, 0644); 82MODULE_PARM_DESC(tx_buffer_size, "socket tx buffer size (0 for system default)"); 83 84static int rx_buffer_size = DEFAULT_BUFFER_SIZE; 85module_param(rx_buffer_size, int, 0644); 86MODULE_PARM_DESC(rx_buffer_size, "socket rx buffer size (0 for system default)"); 87 88static int nagle; 89module_param(nagle, int, 0644); 90MODULE_PARM_DESC(nagle, "enable NAGLE?"); 91 92static int round_robin = 1; 93module_param(round_robin, int, 0644); 94MODULE_PARM_DESC(round_robin, "Round robin for multiple interfaces"); 95 96static int keepalive = 30; 97module_param(keepalive, int, 0644); 98MODULE_PARM_DESC(keepalive, "# seconds before send keepalive"); 99 100static int keepalive_idle = 30; 101module_param(keepalive_idle, int, 0644); 102MODULE_PARM_DESC(keepalive_idle, "# idle seconds before probe"); 103 104#define DEFAULT_KEEPALIVE_COUNT 5 105static int keepalive_count = DEFAULT_KEEPALIVE_COUNT; 106module_param(keepalive_count, int, 0644); 107MODULE_PARM_DESC(keepalive_count, "# missed probes == dead"); 108 109static int keepalive_intvl = 5; 110module_param(keepalive_intvl, int, 0644); 111MODULE_PARM_DESC(keepalive_intvl, "seconds between probes"); 112 113static int enable_csum; 114module_param(enable_csum, int, 0644); 115MODULE_PARM_DESC(enable_csum, "enable check sum"); 116 117static int inject_csum_error; 118module_param(inject_csum_error, int, 0644); 119MODULE_PARM_DESC(inject_csum_error, "set non-zero to inject a checksum error"); 120 121static int nonblk_zcack = 1; 122module_param(nonblk_zcack, int, 0644); 123MODULE_PARM_DESC(nonblk_zcack, "always send ZC-ACK on non-blocking connection"); 124 125static unsigned int zc_min_payload = (16 << 10); 126module_param(zc_min_payload, int, 0644); 127MODULE_PARM_DESC(zc_min_payload, "minimum payload size to zero copy"); 128 129static unsigned int zc_recv; 130module_param(zc_recv, int, 0644); 131MODULE_PARM_DESC(zc_recv, "enable ZC recv for Chelsio driver"); 132 133static unsigned int zc_recv_min_nfrags = 16; 134module_param(zc_recv_min_nfrags, int, 0644); 135MODULE_PARM_DESC(zc_recv_min_nfrags, "minimum # of fragments to enable ZC recv"); 136 137 138#if SOCKNAL_VERSION_DEBUG 139static int protocol = 3; 140module_param(protocol, int, 0644); 141MODULE_PARM_DESC(protocol, "protocol version"); 142#endif 143 144ksock_tunables_t ksocknal_tunables; 145 146int ksocknal_tunables_init(void) 147{ 148 149 /* initialize ksocknal_tunables structure */ 150 ksocknal_tunables.ksnd_timeout = &sock_timeout; 151 ksocknal_tunables.ksnd_nscheds = &nscheds; 152 ksocknal_tunables.ksnd_nconnds = &nconnds; 153 ksocknal_tunables.ksnd_nconnds_max = &nconnds_max; 154 ksocknal_tunables.ksnd_min_reconnectms = &min_reconnectms; 155 ksocknal_tunables.ksnd_max_reconnectms = &max_reconnectms; 156 ksocknal_tunables.ksnd_eager_ack = &eager_ack; 157 ksocknal_tunables.ksnd_typed_conns = &typed_conns; 158 ksocknal_tunables.ksnd_min_bulk = &min_bulk; 159 ksocknal_tunables.ksnd_tx_buffer_size = &tx_buffer_size; 160 ksocknal_tunables.ksnd_rx_buffer_size = &rx_buffer_size; 161 ksocknal_tunables.ksnd_nagle = &nagle; 162 ksocknal_tunables.ksnd_round_robin = &round_robin; 163 ksocknal_tunables.ksnd_keepalive = &keepalive; 164 ksocknal_tunables.ksnd_keepalive_idle = &keepalive_idle; 165 ksocknal_tunables.ksnd_keepalive_count = &keepalive_count; 166 ksocknal_tunables.ksnd_keepalive_intvl = &keepalive_intvl; 167 ksocknal_tunables.ksnd_credits = &credits; 168 ksocknal_tunables.ksnd_peertxcredits = &peer_credits; 169 ksocknal_tunables.ksnd_peerrtrcredits = &peer_buffer_credits; 170 ksocknal_tunables.ksnd_peertimeout = &peer_timeout; 171 ksocknal_tunables.ksnd_enable_csum = &enable_csum; 172 ksocknal_tunables.ksnd_inject_csum_error = &inject_csum_error; 173 ksocknal_tunables.ksnd_nonblk_zcack = &nonblk_zcack; 174 ksocknal_tunables.ksnd_zc_min_payload = &zc_min_payload; 175 ksocknal_tunables.ksnd_zc_recv = &zc_recv; 176 ksocknal_tunables.ksnd_zc_recv_min_nfrags = &zc_recv_min_nfrags; 177 178 179 180#if SOCKNAL_VERSION_DEBUG 181 ksocknal_tunables.ksnd_protocol = &protocol; 182#endif 183 184 if (*ksocknal_tunables.ksnd_zc_min_payload < (2 << 10)) 185 *ksocknal_tunables.ksnd_zc_min_payload = (2 << 10); 186 187 return 0; 188}; 189