1 // SPDX-License-Identifier: GPL-2.0
3 * Shared Memory Communications over RDMA (SMC-R) and RoCE
5 * smc_sysctl.c: sysctl interface to SMC subsystem.
7 * Copyright (c) 2022, Alibaba Inc.
9 * Author: Tony Lu <tonylu@linux.alibaba.com>
13 #include <linux/init.h>
14 #include <linux/sysctl.h>
15 #include <net/net_namespace.h>
20 #include "smc_sysctl.h"
22 static struct ctl_table smc_table[] = {
24 .procname = "autocorking_size",
25 .data = &init_net.smc.sysctl_autocorking_size,
26 .maxlen = sizeof(unsigned int),
28 .proc_handler = proc_douintvec,
31 .procname = "smcr_buf_type",
32 .data = &init_net.smc.sysctl_smcr_buf_type,
33 .maxlen = sizeof(unsigned int),
35 .proc_handler = proc_douintvec_minmax,
36 .extra1 = SYSCTL_ZERO,
40 .procname = "smcr_testlink_time",
41 .data = &init_net.smc.sysctl_smcr_testlink_time,
42 .maxlen = sizeof(int),
44 .proc_handler = proc_dointvec_jiffies,
49 int __net_init smc_sysctl_net_init(struct net *net)
51 struct ctl_table *table;
54 if (!net_eq(net, &init_net)) {
57 table = kmemdup(table, sizeof(smc_table), GFP_KERNEL);
61 for (i = 0; i < ARRAY_SIZE(smc_table) - 1; i++)
62 table[i].data += (void *)net - (void *)&init_net;
65 net->smc.smc_hdr = register_net_sysctl(net, "net/smc", table);
66 if (!net->smc.smc_hdr)
69 net->smc.sysctl_autocorking_size = SMC_AUTOCORKING_DEFAULT_SIZE;
70 net->smc.sysctl_smcr_buf_type = SMCR_PHYS_CONT_BUFS;
71 net->smc.sysctl_smcr_testlink_time = SMC_LLC_TESTLINK_DEFAULT_TIME;
76 if (!net_eq(net, &init_net))
82 void __net_exit smc_sysctl_net_exit(struct net *net)
84 struct ctl_table *table;
86 table = net->smc.smc_hdr->ctl_table_arg;
87 unregister_net_sysctl_table(net->smc.smc_hdr);
88 if (!net_eq(net, &init_net))