18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright (c) 2006 Oracle.  All rights reserved.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * This software is available to you under a choice of one of two
58c2ecf20Sopenharmony_ci * licenses.  You may choose to be licensed under the terms of the GNU
68c2ecf20Sopenharmony_ci * General Public License (GPL) Version 2, available from the file
78c2ecf20Sopenharmony_ci * COPYING in the main directory of this source tree, or the
88c2ecf20Sopenharmony_ci * OpenIB.org BSD license below:
98c2ecf20Sopenharmony_ci *
108c2ecf20Sopenharmony_ci *     Redistribution and use in source and binary forms, with or
118c2ecf20Sopenharmony_ci *     without modification, are permitted provided that the following
128c2ecf20Sopenharmony_ci *     conditions are met:
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci *      - Redistributions of source code must retain the above
158c2ecf20Sopenharmony_ci *        copyright notice, this list of conditions and the following
168c2ecf20Sopenharmony_ci *        disclaimer.
178c2ecf20Sopenharmony_ci *
188c2ecf20Sopenharmony_ci *      - Redistributions in binary form must reproduce the above
198c2ecf20Sopenharmony_ci *        copyright notice, this list of conditions and the following
208c2ecf20Sopenharmony_ci *        disclaimer in the documentation and/or other materials
218c2ecf20Sopenharmony_ci *        provided with the distribution.
228c2ecf20Sopenharmony_ci *
238c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
248c2ecf20Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
258c2ecf20Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
268c2ecf20Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
278c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
288c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
298c2ecf20Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
308c2ecf20Sopenharmony_ci * SOFTWARE.
318c2ecf20Sopenharmony_ci *
328c2ecf20Sopenharmony_ci */
338c2ecf20Sopenharmony_ci#include <linux/kernel.h>
348c2ecf20Sopenharmony_ci#include <linux/sysctl.h>
358c2ecf20Sopenharmony_ci#include <linux/proc_fs.h>
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci#include "ib.h"
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_cistatic struct ctl_table_header *rds_ib_sysctl_hdr;
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ciunsigned long rds_ib_sysctl_max_send_wr = RDS_IB_DEFAULT_SEND_WR;
428c2ecf20Sopenharmony_ciunsigned long rds_ib_sysctl_max_recv_wr = RDS_IB_DEFAULT_RECV_WR;
438c2ecf20Sopenharmony_ciunsigned long rds_ib_sysctl_max_recv_allocation = (128 * 1024 * 1024) / RDS_FRAG_SIZE;
448c2ecf20Sopenharmony_cistatic unsigned long rds_ib_sysctl_max_wr_min = 1;
458c2ecf20Sopenharmony_ci/* hardware will fail CQ creation long before this */
468c2ecf20Sopenharmony_cistatic unsigned long rds_ib_sysctl_max_wr_max = (u32)~0;
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ciunsigned long rds_ib_sysctl_max_unsig_wrs = 16;
498c2ecf20Sopenharmony_cistatic unsigned long rds_ib_sysctl_max_unsig_wr_min = 1;
508c2ecf20Sopenharmony_cistatic unsigned long rds_ib_sysctl_max_unsig_wr_max = 64;
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci/*
538c2ecf20Sopenharmony_ci * This sysctl does nothing.
548c2ecf20Sopenharmony_ci *
558c2ecf20Sopenharmony_ci * Backwards compatibility with RDS 3.0 wire protocol
568c2ecf20Sopenharmony_ci * disables initial FC credit exchange.
578c2ecf20Sopenharmony_ci * If it's ever possible to drop 3.0 support,
588c2ecf20Sopenharmony_ci * setting this to 1 and moving init/refill of send/recv
598c2ecf20Sopenharmony_ci * rings from ib_cm_connect_complete() back into ib_setup_qp()
608c2ecf20Sopenharmony_ci * will cause credits to be added before protocol negotiation.
618c2ecf20Sopenharmony_ci */
628c2ecf20Sopenharmony_ciunsigned int rds_ib_sysctl_flow_control = 0;
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_cistatic struct ctl_table rds_ib_sysctl_table[] = {
658c2ecf20Sopenharmony_ci	{
668c2ecf20Sopenharmony_ci		.procname       = "max_send_wr",
678c2ecf20Sopenharmony_ci		.data		= &rds_ib_sysctl_max_send_wr,
688c2ecf20Sopenharmony_ci		.maxlen         = sizeof(unsigned long),
698c2ecf20Sopenharmony_ci		.mode           = 0644,
708c2ecf20Sopenharmony_ci		.proc_handler   = proc_doulongvec_minmax,
718c2ecf20Sopenharmony_ci		.extra1		= &rds_ib_sysctl_max_wr_min,
728c2ecf20Sopenharmony_ci		.extra2		= &rds_ib_sysctl_max_wr_max,
738c2ecf20Sopenharmony_ci	},
748c2ecf20Sopenharmony_ci	{
758c2ecf20Sopenharmony_ci		.procname       = "max_recv_wr",
768c2ecf20Sopenharmony_ci		.data		= &rds_ib_sysctl_max_recv_wr,
778c2ecf20Sopenharmony_ci		.maxlen         = sizeof(unsigned long),
788c2ecf20Sopenharmony_ci		.mode           = 0644,
798c2ecf20Sopenharmony_ci		.proc_handler   = proc_doulongvec_minmax,
808c2ecf20Sopenharmony_ci		.extra1		= &rds_ib_sysctl_max_wr_min,
818c2ecf20Sopenharmony_ci		.extra2		= &rds_ib_sysctl_max_wr_max,
828c2ecf20Sopenharmony_ci	},
838c2ecf20Sopenharmony_ci	{
848c2ecf20Sopenharmony_ci		.procname       = "max_unsignaled_wr",
858c2ecf20Sopenharmony_ci		.data		= &rds_ib_sysctl_max_unsig_wrs,
868c2ecf20Sopenharmony_ci		.maxlen         = sizeof(unsigned long),
878c2ecf20Sopenharmony_ci		.mode           = 0644,
888c2ecf20Sopenharmony_ci		.proc_handler   = proc_doulongvec_minmax,
898c2ecf20Sopenharmony_ci		.extra1		= &rds_ib_sysctl_max_unsig_wr_min,
908c2ecf20Sopenharmony_ci		.extra2		= &rds_ib_sysctl_max_unsig_wr_max,
918c2ecf20Sopenharmony_ci	},
928c2ecf20Sopenharmony_ci	{
938c2ecf20Sopenharmony_ci		.procname       = "max_recv_allocation",
948c2ecf20Sopenharmony_ci		.data		= &rds_ib_sysctl_max_recv_allocation,
958c2ecf20Sopenharmony_ci		.maxlen         = sizeof(unsigned long),
968c2ecf20Sopenharmony_ci		.mode           = 0644,
978c2ecf20Sopenharmony_ci		.proc_handler   = proc_doulongvec_minmax,
988c2ecf20Sopenharmony_ci	},
998c2ecf20Sopenharmony_ci	{
1008c2ecf20Sopenharmony_ci		.procname	= "flow_control",
1018c2ecf20Sopenharmony_ci		.data		= &rds_ib_sysctl_flow_control,
1028c2ecf20Sopenharmony_ci		.maxlen		= sizeof(rds_ib_sysctl_flow_control),
1038c2ecf20Sopenharmony_ci		.mode		= 0644,
1048c2ecf20Sopenharmony_ci		.proc_handler	= proc_dointvec,
1058c2ecf20Sopenharmony_ci	},
1068c2ecf20Sopenharmony_ci	{ }
1078c2ecf20Sopenharmony_ci};
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_civoid rds_ib_sysctl_exit(void)
1108c2ecf20Sopenharmony_ci{
1118c2ecf20Sopenharmony_ci	if (rds_ib_sysctl_hdr)
1128c2ecf20Sopenharmony_ci		unregister_net_sysctl_table(rds_ib_sysctl_hdr);
1138c2ecf20Sopenharmony_ci}
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ciint rds_ib_sysctl_init(void)
1168c2ecf20Sopenharmony_ci{
1178c2ecf20Sopenharmony_ci	rds_ib_sysctl_hdr = register_net_sysctl(&init_net, "net/rds/ib", rds_ib_sysctl_table);
1188c2ecf20Sopenharmony_ci	if (!rds_ib_sysctl_hdr)
1198c2ecf20Sopenharmony_ci		return -ENOMEM;
1208c2ecf20Sopenharmony_ci	return 0;
1218c2ecf20Sopenharmony_ci}
122