1 // SPDX-License-Identifier: GPL-2.0
3 * Shared Memory Communications over RDMA (SMC-R) and RoCE
5 * Generic netlink support functions to interact with SMC module
7 * Copyright IBM Corp. 2020
9 * Author(s): Guvenc Gulce <guvenc@linux.ibm.com>
12 #include <linux/module.h>
13 #include <linux/list.h>
14 #include <linux/ctype.h>
15 #include <linux/mutex.h>
17 #include <linux/smc.h>
22 #include "smc_stats.h"
23 #include "smc_netlink.h"
25 #define SMC_CMD_MAX_ATTR 1
27 /* SMC_GENL generic netlink operation definition */
28 static const struct genl_ops smc_gen_nl_ops[] = {
30 .cmd = SMC_NETLINK_GET_SYS_INFO,
31 /* can be retrieved by unprivileged users */
32 .dumpit = smc_nl_get_sys_info,
35 .cmd = SMC_NETLINK_GET_LGR_SMCR,
36 /* can be retrieved by unprivileged users */
37 .dumpit = smcr_nl_get_lgr,
40 .cmd = SMC_NETLINK_GET_LINK_SMCR,
41 /* can be retrieved by unprivileged users */
42 .dumpit = smcr_nl_get_link,
45 .cmd = SMC_NETLINK_GET_LGR_SMCD,
46 /* can be retrieved by unprivileged users */
47 .dumpit = smcd_nl_get_lgr,
50 .cmd = SMC_NETLINK_GET_DEV_SMCD,
51 /* can be retrieved by unprivileged users */
52 .dumpit = smcd_nl_get_device,
55 .cmd = SMC_NETLINK_GET_DEV_SMCR,
56 /* can be retrieved by unprivileged users */
57 .dumpit = smcr_nl_get_device,
60 .cmd = SMC_NETLINK_GET_STATS,
61 /* can be retrieved by unprivileged users */
62 .dumpit = smc_nl_get_stats,
65 .cmd = SMC_NETLINK_GET_FBACK_STATS,
66 /* can be retrieved by unprivileged users */
67 .dumpit = smc_nl_get_fback_stats,
71 static const struct nla_policy smc_gen_nl_policy[2] = {
72 [SMC_CMD_MAX_ATTR] = { .type = NLA_REJECT, },
75 /* SMC_GENL family definition */
76 struct genl_family smc_gen_nl_family __ro_after_init = {
78 .name = SMC_GENL_FAMILY_NAME,
79 .version = SMC_GENL_FAMILY_VERSION,
80 .maxattr = SMC_CMD_MAX_ATTR,
81 .policy = smc_gen_nl_policy,
83 .module = THIS_MODULE,
84 .ops = smc_gen_nl_ops,
85 .n_ops = ARRAY_SIZE(smc_gen_nl_ops)
88 int __init smc_nl_init(void)
90 return genl_register_family(&smc_gen_nl_family);
93 void smc_nl_exit(void)
95 genl_unregister_family(&smc_gen_nl_family);