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>
18 #include "smc_sysctl.h"
20 static struct ctl_table smc_table[] = {
22 .procname = "autocorking_size",
23 .data = &init_net.smc.sysctl_autocorking_size,
24 .maxlen = sizeof(unsigned int),
26 .proc_handler = proc_douintvec,
31 int __net_init smc_sysctl_net_init(struct net *net)
33 struct ctl_table *table;
36 if (!net_eq(net, &init_net)) {
39 table = kmemdup(table, sizeof(smc_table), GFP_KERNEL);
43 for (i = 0; i < ARRAY_SIZE(smc_table) - 1; i++)
44 table[i].data += (void *)net - (void *)&init_net;
47 net->smc.smc_hdr = register_net_sysctl(net, "net/smc", table);
48 if (!net->smc.smc_hdr)
51 net->smc.sysctl_autocorking_size = SMC_AUTOCORKING_DEFAULT_SIZE;
56 if (!net_eq(net, &init_net))
62 void __net_exit smc_sysctl_net_exit(struct net *net)
64 struct ctl_table *table;
66 table = net->smc.smc_hdr->ctl_table_arg;
67 unregister_net_sysctl_table(net->smc.smc_hdr);
68 if (!net_eq(net, &init_net))