linux/net/smc/smc_netlink.c
<<
>>
Prefs
   1// 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"
  20#include "smc_ism.h"
  21#include "smc_ib.h"
  22#include "smc_stats.h"
  23#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[] = {
  29        {
  30                .cmd = SMC_NETLINK_GET_SYS_INFO,
  31                /* can be retrieved by unprivileged users */
  32                .dumpit = smc_nl_get_sys_info,
  33        },
  34        {
  35                .cmd = SMC_NETLINK_GET_LGR_SMCR,
  36                /* can be retrieved by unprivileged users */
  37                .dumpit = smcr_nl_get_lgr,
  38        },
  39        {
  40                .cmd = SMC_NETLINK_GET_LINK_SMCR,
  41                /* can be retrieved by unprivileged users */
  42                .dumpit = smcr_nl_get_link,
  43        },
  44        {
  45                .cmd = SMC_NETLINK_GET_LGR_SMCD,
  46                /* can be retrieved by unprivileged users */
  47                .dumpit = smcd_nl_get_lgr,
  48        },
  49        {
  50                .cmd = SMC_NETLINK_GET_DEV_SMCD,
  51                /* can be retrieved by unprivileged users */
  52                .dumpit = smcd_nl_get_device,
  53        },
  54        {
  55                .cmd = SMC_NETLINK_GET_DEV_SMCR,
  56                /* can be retrieved by unprivileged users */
  57                .dumpit = smcr_nl_get_device,
  58        },
  59        {
  60                .cmd = SMC_NETLINK_GET_STATS,
  61                /* can be retrieved by unprivileged users */
  62                .dumpit = smc_nl_get_stats,
  63        },
  64        {
  65                .cmd = SMC_NETLINK_GET_FBACK_STATS,
  66                /* can be retrieved by unprivileged users */
  67                .dumpit = smc_nl_get_fback_stats,
  68        },
  69};
  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}
  97