0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include <linux/module.h>
0013 #include <linux/list.h>
0014 #include <linux/ctype.h>
0015 #include <linux/mutex.h>
0016 #include <linux/if.h>
0017 #include <linux/smc.h>
0018
0019 #include "smc_core.h"
0020 #include "smc_ism.h"
0021 #include "smc_ib.h"
0022 #include "smc_clc.h"
0023 #include "smc_stats.h"
0024 #include "smc_netlink.h"
0025
0026 const struct nla_policy
0027 smc_gen_ueid_policy[SMC_NLA_EID_TABLE_MAX + 1] = {
0028 [SMC_NLA_EID_TABLE_UNSPEC] = { .type = NLA_UNSPEC },
0029 [SMC_NLA_EID_TABLE_ENTRY] = { .type = NLA_STRING,
0030 .len = SMC_MAX_EID_LEN,
0031 },
0032 };
0033
0034 #define SMC_CMD_MAX_ATTR 1
0035
0036 static const struct genl_ops smc_gen_nl_ops[] = {
0037 {
0038 .cmd = SMC_NETLINK_GET_SYS_INFO,
0039
0040 .dumpit = smc_nl_get_sys_info,
0041 },
0042 {
0043 .cmd = SMC_NETLINK_GET_LGR_SMCR,
0044
0045 .dumpit = smcr_nl_get_lgr,
0046 },
0047 {
0048 .cmd = SMC_NETLINK_GET_LINK_SMCR,
0049
0050 .dumpit = smcr_nl_get_link,
0051 },
0052 {
0053 .cmd = SMC_NETLINK_GET_LGR_SMCD,
0054
0055 .dumpit = smcd_nl_get_lgr,
0056 },
0057 {
0058 .cmd = SMC_NETLINK_GET_DEV_SMCD,
0059
0060 .dumpit = smcd_nl_get_device,
0061 },
0062 {
0063 .cmd = SMC_NETLINK_GET_DEV_SMCR,
0064
0065 .dumpit = smcr_nl_get_device,
0066 },
0067 {
0068 .cmd = SMC_NETLINK_GET_STATS,
0069
0070 .dumpit = smc_nl_get_stats,
0071 },
0072 {
0073 .cmd = SMC_NETLINK_GET_FBACK_STATS,
0074
0075 .dumpit = smc_nl_get_fback_stats,
0076 },
0077 {
0078 .cmd = SMC_NETLINK_DUMP_UEID,
0079
0080 .dumpit = smc_nl_dump_ueid,
0081 },
0082 {
0083 .cmd = SMC_NETLINK_ADD_UEID,
0084 .flags = GENL_ADMIN_PERM,
0085 .doit = smc_nl_add_ueid,
0086 .policy = smc_gen_ueid_policy,
0087 },
0088 {
0089 .cmd = SMC_NETLINK_REMOVE_UEID,
0090 .flags = GENL_ADMIN_PERM,
0091 .doit = smc_nl_remove_ueid,
0092 .policy = smc_gen_ueid_policy,
0093 },
0094 {
0095 .cmd = SMC_NETLINK_FLUSH_UEID,
0096 .flags = GENL_ADMIN_PERM,
0097 .doit = smc_nl_flush_ueid,
0098 },
0099 {
0100 .cmd = SMC_NETLINK_DUMP_SEID,
0101
0102 .dumpit = smc_nl_dump_seid,
0103 },
0104 {
0105 .cmd = SMC_NETLINK_ENABLE_SEID,
0106 .flags = GENL_ADMIN_PERM,
0107 .doit = smc_nl_enable_seid,
0108 },
0109 {
0110 .cmd = SMC_NETLINK_DISABLE_SEID,
0111 .flags = GENL_ADMIN_PERM,
0112 .doit = smc_nl_disable_seid,
0113 },
0114 {
0115 .cmd = SMC_NETLINK_DUMP_HS_LIMITATION,
0116
0117 .dumpit = smc_nl_dump_hs_limitation,
0118 },
0119 {
0120 .cmd = SMC_NETLINK_ENABLE_HS_LIMITATION,
0121 .flags = GENL_ADMIN_PERM,
0122 .doit = smc_nl_enable_hs_limitation,
0123 },
0124 {
0125 .cmd = SMC_NETLINK_DISABLE_HS_LIMITATION,
0126 .flags = GENL_ADMIN_PERM,
0127 .doit = smc_nl_disable_hs_limitation,
0128 },
0129 };
0130
0131 static const struct nla_policy smc_gen_nl_policy[2] = {
0132 [SMC_CMD_MAX_ATTR] = { .type = NLA_REJECT, },
0133 };
0134
0135
0136 struct genl_family smc_gen_nl_family __ro_after_init = {
0137 .hdrsize = 0,
0138 .name = SMC_GENL_FAMILY_NAME,
0139 .version = SMC_GENL_FAMILY_VERSION,
0140 .maxattr = SMC_CMD_MAX_ATTR,
0141 .policy = smc_gen_nl_policy,
0142 .netnsok = true,
0143 .module = THIS_MODULE,
0144 .ops = smc_gen_nl_ops,
0145 .n_ops = ARRAY_SIZE(smc_gen_nl_ops)
0146 };
0147
0148 int __init smc_nl_init(void)
0149 {
0150 return genl_register_family(&smc_gen_nl_family);
0151 }
0152
0153 void smc_nl_exit(void)
0154 {
0155 genl_unregister_family(&smc_gen_nl_family);
0156 }