#include <linux/module.h>
#include <linux/pid.h>
#include <linux/pid_namespace.h>
#include <linux/mutex.h>
#include <net/netlink.h>
#include <rdma/rdma_cm.h>
#include <rdma/rdma_netlink.h>
#include "core_priv.h"
#include "cma_priv.h"
#include "restrack.h"
#include "uverbs.h"
static bool privileged_qkey;
res_fill_func_t;
static const struct nla_policy nldev_policy[RDMA_NLDEV_ATTR_MAX] = …;
static int put_driver_name_print_type(struct sk_buff *msg, const char *name,
enum rdma_nldev_print_type print_type)
{ … }
static int _rdma_nl_put_driver_u32(struct sk_buff *msg, const char *name,
enum rdma_nldev_print_type print_type,
u32 value)
{ … }
static int _rdma_nl_put_driver_u64(struct sk_buff *msg, const char *name,
enum rdma_nldev_print_type print_type,
u64 value)
{ … }
int rdma_nl_put_driver_string(struct sk_buff *msg, const char *name,
const char *str)
{ … }
EXPORT_SYMBOL(…);
int rdma_nl_put_driver_u32(struct sk_buff *msg, const char *name, u32 value)
{ … }
EXPORT_SYMBOL(…);
int rdma_nl_put_driver_u32_hex(struct sk_buff *msg, const char *name,
u32 value)
{ … }
EXPORT_SYMBOL(…);
int rdma_nl_put_driver_u64(struct sk_buff *msg, const char *name, u64 value)
{ … }
EXPORT_SYMBOL(…);
int rdma_nl_put_driver_u64_hex(struct sk_buff *msg, const char *name, u64 value)
{ … }
EXPORT_SYMBOL(…);
bool rdma_nl_get_privileged_qkey(void)
{ … }
EXPORT_SYMBOL(…);
static int fill_nldev_handle(struct sk_buff *msg, struct ib_device *device)
{ … }
static int fill_dev_info(struct sk_buff *msg, struct ib_device *device)
{ … }
static int fill_port_info(struct sk_buff *msg,
struct ib_device *device, u32 port,
const struct net *net)
{ … }
static int fill_res_info_entry(struct sk_buff *msg,
const char *name, u64 curr)
{ … }
static int fill_res_info(struct sk_buff *msg, struct ib_device *device,
bool show_details)
{ … }
static int fill_res_name_pid(struct sk_buff *msg,
struct rdma_restrack_entry *res)
{ … }
static int fill_res_qp_entry_query(struct sk_buff *msg,
struct rdma_restrack_entry *res,
struct ib_device *dev,
struct ib_qp *qp)
{ … }
static int fill_res_qp_entry(struct sk_buff *msg, bool has_cap_net_admin,
struct rdma_restrack_entry *res, uint32_t port)
{ … }
static int fill_res_qp_raw_entry(struct sk_buff *msg, bool has_cap_net_admin,
struct rdma_restrack_entry *res, uint32_t port)
{ … }
static int fill_res_cm_id_entry(struct sk_buff *msg, bool has_cap_net_admin,
struct rdma_restrack_entry *res, uint32_t port)
{ … }
static int fill_res_cq_entry(struct sk_buff *msg, bool has_cap_net_admin,
struct rdma_restrack_entry *res, uint32_t port)
{ … }
static int fill_res_cq_raw_entry(struct sk_buff *msg, bool has_cap_net_admin,
struct rdma_restrack_entry *res, uint32_t port)
{ … }
static int fill_res_mr_entry(struct sk_buff *msg, bool has_cap_net_admin,
struct rdma_restrack_entry *res, uint32_t port)
{ … }
static int fill_res_mr_raw_entry(struct sk_buff *msg, bool has_cap_net_admin,
struct rdma_restrack_entry *res, uint32_t port)
{ … }
static int fill_res_pd_entry(struct sk_buff *msg, bool has_cap_net_admin,
struct rdma_restrack_entry *res, uint32_t port)
{ … }
static int fill_res_ctx_entry(struct sk_buff *msg, bool has_cap_net_admin,
struct rdma_restrack_entry *res, uint32_t port)
{ … }
static int fill_res_range_qp_entry(struct sk_buff *msg, uint32_t min_range,
uint32_t max_range)
{ … }
static int fill_res_srq_qps(struct sk_buff *msg, struct ib_srq *srq)
{ … }
static int fill_res_srq_entry(struct sk_buff *msg, bool has_cap_net_admin,
struct rdma_restrack_entry *res, uint32_t port)
{ … }
static int fill_res_srq_raw_entry(struct sk_buff *msg, bool has_cap_net_admin,
struct rdma_restrack_entry *res, uint32_t port)
{ … }
static int fill_stat_counter_mode(struct sk_buff *msg,
struct rdma_counter *counter)
{ … }
static int fill_stat_counter_qp_entry(struct sk_buff *msg, u32 qpn)
{ … }
static int fill_stat_counter_qps(struct sk_buff *msg,
struct rdma_counter *counter)
{ … }
int rdma_nl_stat_hwcounter_entry(struct sk_buff *msg, const char *name,
u64 value)
{ … }
EXPORT_SYMBOL(…);
static int fill_stat_mr_entry(struct sk_buff *msg, bool has_cap_net_admin,
struct rdma_restrack_entry *res, uint32_t port)
{ … }
static int fill_stat_counter_hwcounters(struct sk_buff *msg,
struct rdma_counter *counter)
{ … }
static int fill_res_counter_entry(struct sk_buff *msg, bool has_cap_net_admin,
struct rdma_restrack_entry *res,
uint32_t port)
{ … }
static int nldev_get_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
struct netlink_ext_ack *extack)
{ … }
static int nldev_set_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
struct netlink_ext_ack *extack)
{ … }
static int _nldev_get_dumpit(struct ib_device *device,
struct sk_buff *skb,
struct netlink_callback *cb,
unsigned int idx)
{ … }
static int nldev_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
{ … }
static int nldev_port_get_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
struct netlink_ext_ack *extack)
{ … }
static int nldev_port_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb)
{ … }
static int nldev_res_get_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
struct netlink_ext_ack *extack)
{ … }
static int _nldev_res_get_dumpit(struct ib_device *device,
struct sk_buff *skb,
struct netlink_callback *cb,
unsigned int idx)
{ … }
static int nldev_res_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb)
{ … }
struct nldev_fill_res_entry { … };
enum nldev_res_flags { … };
static const struct nldev_fill_res_entry fill_entries[RDMA_RESTRACK_MAX] = …;
static int res_get_common_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
struct netlink_ext_ack *extack,
enum rdma_restrack_type res_type,
res_fill_func_t fill_func)
{ … }
static int res_get_common_dumpit(struct sk_buff *skb,
struct netlink_callback *cb,
enum rdma_restrack_type res_type,
res_fill_func_t fill_func)
{ … }
#define RES_GET_FUNCS(name, type) …
RES_GET_FUNCS(qp, RDMA_RESTRACK_QP);
RES_GET_FUNCS(qp_raw, RDMA_RESTRACK_QP);
RES_GET_FUNCS(cm_id, RDMA_RESTRACK_CM_ID);
RES_GET_FUNCS(cq, RDMA_RESTRACK_CQ);
RES_GET_FUNCS(cq_raw, RDMA_RESTRACK_CQ);
RES_GET_FUNCS(pd, RDMA_RESTRACK_PD);
RES_GET_FUNCS(mr, RDMA_RESTRACK_MR);
RES_GET_FUNCS(mr_raw, RDMA_RESTRACK_MR);
RES_GET_FUNCS(counter, RDMA_RESTRACK_COUNTER);
RES_GET_FUNCS(ctx, RDMA_RESTRACK_CTX);
RES_GET_FUNCS(srq, RDMA_RESTRACK_SRQ);
RES_GET_FUNCS(srq_raw, RDMA_RESTRACK_SRQ);
static LIST_HEAD(link_ops);
static DECLARE_RWSEM(link_ops_rwsem);
static const struct rdma_link_ops *link_ops_get(const char *type)
{ … }
void rdma_link_register(struct rdma_link_ops *ops)
{ … }
EXPORT_SYMBOL(…);
void rdma_link_unregister(struct rdma_link_ops *ops)
{ … }
EXPORT_SYMBOL(…);
static int nldev_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
struct netlink_ext_ack *extack)
{ … }
static int nldev_dellink(struct sk_buff *skb, struct nlmsghdr *nlh,
struct netlink_ext_ack *extack)
{ … }
static int nldev_get_chardev(struct sk_buff *skb, struct nlmsghdr *nlh,
struct netlink_ext_ack *extack)
{ … }
static int nldev_sys_get_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
struct netlink_ext_ack *extack)
{ … }
static int nldev_set_sys_set_netns_doit(struct nlattr *tb[])
{ … }
static int nldev_set_sys_set_pqkey_doit(struct nlattr *tb[])
{ … }
static int nldev_set_sys_set_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
struct netlink_ext_ack *extack)
{ … }
static int nldev_stat_set_mode_doit(struct sk_buff *msg,
struct netlink_ext_ack *extack,
struct nlattr *tb[],
struct ib_device *device, u32 port)
{ … }
static int nldev_stat_set_counter_dynamic_doit(struct nlattr *tb[],
struct ib_device *device,
u32 port)
{ … }
static int nldev_stat_set_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
struct netlink_ext_ack *extack)
{ … }
static int nldev_stat_del_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
struct netlink_ext_ack *extack)
{ … }
static int stat_get_doit_default_counter(struct sk_buff *skb,
struct nlmsghdr *nlh,
struct netlink_ext_ack *extack,
struct nlattr *tb[])
{ … }
static int stat_get_doit_qp(struct sk_buff *skb, struct nlmsghdr *nlh,
struct netlink_ext_ack *extack, struct nlattr *tb[])
{ … }
static int nldev_stat_get_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
struct netlink_ext_ack *extack)
{ … }
static int nldev_stat_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb)
{ … }
static int nldev_stat_get_counter_status_doit(struct sk_buff *skb,
struct nlmsghdr *nlh,
struct netlink_ext_ack *extack)
{ … }
static int nldev_newdev(struct sk_buff *skb, struct nlmsghdr *nlh,
struct netlink_ext_ack *extack)
{ … }
static int nldev_deldev(struct sk_buff *skb, struct nlmsghdr *nlh,
struct netlink_ext_ack *extack)
{ … }
static const struct rdma_nl_cbs nldev_cb_table[RDMA_NLDEV_NUM_OPS] = …;
void __init nldev_init(void)
{ … }
void nldev_exit(void)
{ … }
MODULE_ALIAS_RDMA_NETLINK(…);