blob: 6fb6f96c1d1775a5dbd30aaff1afe64ee40df348 [file] [log] [blame]
Guvenc Gulcee8372d92020-12-01 20:20:43 +01001// SPDX-License-Identifier: GPL-2.0
2/*
3 * Shared Memory Communications over RDMA (SMC-R) and RoCE
4 *
5 * Generic netlink support functions to interact with SMC module
6 *
7 * Copyright IBM Corp. 2020
8 *
9 * Author(s): Guvenc Gulce <guvenc@linux.ibm.com>
10 */
11
12#include <linux/module.h>
13#include <linux/list.h>
14#include <linux/ctype.h>
15#include <linux/mutex.h>
16#include <linux/if.h>
17#include <linux/smc.h>
18
19#include "smc_core.h"
Guvenc Gulceaaf95522020-12-01 20:20:48 +010020#include "smc_ism.h"
Guvenc Gulcea3db10e2020-12-01 20:20:49 +010021#include "smc_ib.h"
Guvenc Gulce8c406022021-06-16 16:52:56 +020022#include "smc_stats.h"
Guvenc Gulcee8372d92020-12-01 20:20:43 +010023#include "smc_netlink.h"
24
25#define SMC_CMD_MAX_ATTR 1
26
27/* SMC_GENL generic netlink operation definition */
28static const struct genl_ops smc_gen_nl_ops[] = {
Guvenc Gulce099b9902020-12-01 20:20:44 +010029 {
30 .cmd = SMC_NETLINK_GET_SYS_INFO,
31 /* can be retrieved by unprivileged users */
32 .dumpit = smc_nl_get_sys_info,
33 },
Guvenc Gulcee9b8c842020-12-01 20:20:45 +010034 {
35 .cmd = SMC_NETLINK_GET_LGR_SMCR,
36 /* can be retrieved by unprivileged users */
37 .dumpit = smcr_nl_get_lgr,
38 },
Guvenc Gulce5a7e09d2020-12-01 20:20:46 +010039 {
40 .cmd = SMC_NETLINK_GET_LINK_SMCR,
41 /* can be retrieved by unprivileged users */
42 .dumpit = smcr_nl_get_link,
43 },
Guvenc Gulce8f9dde42020-12-01 20:20:47 +010044 {
45 .cmd = SMC_NETLINK_GET_LGR_SMCD,
46 /* can be retrieved by unprivileged users */
47 .dumpit = smcd_nl_get_lgr,
48 },
Guvenc Gulceaaf95522020-12-01 20:20:48 +010049 {
50 .cmd = SMC_NETLINK_GET_DEV_SMCD,
51 /* can be retrieved by unprivileged users */
52 .dumpit = smcd_nl_get_device,
53 },
Guvenc Gulcea3db10e2020-12-01 20:20:49 +010054 {
55 .cmd = SMC_NETLINK_GET_DEV_SMCR,
56 /* can be retrieved by unprivileged users */
57 .dumpit = smcr_nl_get_device,
58 },
Guvenc Gulce8c406022021-06-16 16:52:56 +020059 {
60 .cmd = SMC_NETLINK_GET_STATS,
61 /* can be retrieved by unprivileged users */
62 .dumpit = smc_nl_get_stats,
63 },
Guvenc Gulcef0dd7bf2021-06-16 16:52:57 +020064 {
65 .cmd = SMC_NETLINK_GET_FBACK_STATS,
66 /* can be retrieved by unprivileged users */
67 .dumpit = smc_nl_get_fback_stats,
68 },
Guvenc Gulcee8372d92020-12-01 20:20:43 +010069};
70
71static const struct nla_policy smc_gen_nl_policy[2] = {
72 [SMC_CMD_MAX_ATTR] = { .type = NLA_REJECT, },
73};
74
75/* SMC_GENL family definition */
76struct genl_family smc_gen_nl_family __ro_after_init = {
77 .hdrsize = 0,
78 .name = SMC_GENL_FAMILY_NAME,
79 .version = SMC_GENL_FAMILY_VERSION,
80 .maxattr = SMC_CMD_MAX_ATTR,
81 .policy = smc_gen_nl_policy,
82 .netnsok = true,
83 .module = THIS_MODULE,
84 .ops = smc_gen_nl_ops,
85 .n_ops = ARRAY_SIZE(smc_gen_nl_ops)
86};
87
88int __init smc_nl_init(void)
89{
90 return genl_register_family(&smc_gen_nl_family);
91}
92
93void smc_nl_exit(void)
94{
95 genl_unregister_family(&smc_gen_nl_family);
96}