-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net/smc: add sysctl interface for SMC
This patch add sysctl interface to support container environment for SMC as we talk in the mail list. Link: https://lore.kernel.org/netdev/20220224020253.GF5443@linux.alibaba.com Co-developed-by: Tony Lu <tonylu@linux.alibaba.com> Signed-off-by: Tony Lu <tonylu@linux.alibaba.com> Signed-off-by: Dust Li <dust.li@linux.alibaba.com> Signed-off-by: David S. Miller <davem@davemloft.net>
- Loading branch information
Dust Li
authored and
David S. Miller
committed
Mar 1, 2022
1 parent
1e385c0
commit 462791b
Showing
5 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* | ||
* Shared Memory Communications over RDMA (SMC-R) and RoCE | ||
* | ||
* smc_sysctl.c: sysctl interface to SMC subsystem. | ||
* | ||
* Copyright (c) 2022, Alibaba Inc. | ||
* | ||
* Author: Tony Lu <tonylu@linux.alibaba.com> | ||
* | ||
*/ | ||
|
||
#include <linux/init.h> | ||
#include <linux/sysctl.h> | ||
#include <net/net_namespace.h> | ||
|
||
#include "smc_sysctl.h" | ||
|
||
static struct ctl_table smc_table[] = { | ||
{ } | ||
}; | ||
|
||
static __net_init int smc_sysctl_init_net(struct net *net) | ||
{ | ||
struct ctl_table *table; | ||
|
||
table = smc_table; | ||
if (!net_eq(net, &init_net)) { | ||
int i; | ||
|
||
table = kmemdup(table, sizeof(smc_table), GFP_KERNEL); | ||
if (!table) | ||
goto err_alloc; | ||
|
||
for (i = 0; i < ARRAY_SIZE(smc_table) - 1; i++) | ||
table[i].data += (void *)net - (void *)&init_net; | ||
} | ||
|
||
net->smc.smc_hdr = register_net_sysctl(net, "net/smc", table); | ||
if (!net->smc.smc_hdr) | ||
goto err_reg; | ||
|
||
return 0; | ||
|
||
err_reg: | ||
if (!net_eq(net, &init_net)) | ||
kfree(table); | ||
err_alloc: | ||
return -ENOMEM; | ||
} | ||
|
||
static __net_exit void smc_sysctl_exit_net(struct net *net) | ||
{ | ||
unregister_net_sysctl_table(net->smc.smc_hdr); | ||
} | ||
|
||
static struct pernet_operations smc_sysctl_ops __net_initdata = { | ||
.init = smc_sysctl_init_net, | ||
.exit = smc_sysctl_exit_net, | ||
}; | ||
|
||
int __init smc_sysctl_init(void) | ||
{ | ||
return register_pernet_subsys(&smc_sysctl_ops); | ||
} | ||
|
||
void smc_sysctl_exit(void) | ||
{ | ||
unregister_pernet_subsys(&smc_sysctl_ops); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
/* | ||
* Shared Memory Communications over RDMA (SMC-R) and RoCE | ||
* | ||
* smc_sysctl.c: sysctl interface to SMC subsystem. | ||
* | ||
* Copyright (c) 2022, Alibaba Inc. | ||
* | ||
* Author: Tony Lu <tonylu@linux.alibaba.com> | ||
* | ||
*/ | ||
|
||
#ifndef _SMC_SYSCTL_H | ||
#define _SMC_SYSCTL_H | ||
|
||
#ifdef CONFIG_SYSCTL | ||
|
||
int smc_sysctl_init(void); | ||
void smc_sysctl_exit(void); | ||
|
||
#else | ||
|
||
int smc_sysctl_init(void) | ||
{ | ||
return 0; | ||
} | ||
|
||
void smc_sysctl_exit(void) { } | ||
|
||
#endif /* CONFIG_SYSCTL */ | ||
|
||
#endif /* _SMC_SYSCTL_H */ |