#define pr_fmt(fmt) …
#include <linux/module.h>
#include <linux/init.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/fs.h>
#include <linux/cdev.h>
#include <linux/dma-mapping.h>
#include <linux/poll.h>
#include <linux/mutex.h>
#include <linux/kref.h>
#include <linux/compat.h>
#include <linux/sched.h>
#include <linux/semaphore.h>
#include <linux/slab.h>
#include <linux/nospec.h>
#include <linux/uaccess.h>
#include <rdma/ib_mad.h>
#include <rdma/ib_user_mad.h>
#include <rdma/rdma_netlink.h>
#include "core_priv.h"
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
#define MAX_UMAD_RECV_LIST_SIZE …
enum { … };
struct ib_umad_port { … };
struct ib_umad_device { … };
struct ib_umad_file { … };
struct ib_umad_packet { … };
struct ib_rmpp_mad_hdr { … } __packed;
#define CREATE_TRACE_POINTS
#include <trace/events/ib_umad.h>
static const dev_t base_umad_dev = …;
static const dev_t base_issm_dev = …;
static dev_t dynamic_umad_dev;
static dev_t dynamic_issm_dev;
static DEFINE_IDA(umad_ida);
static int ib_umad_add_one(struct ib_device *device);
static void ib_umad_remove_one(struct ib_device *device, void *client_data);
static void ib_umad_dev_free(struct kref *kref)
{ … }
static void ib_umad_dev_get(struct ib_umad_device *dev)
{ … }
static void ib_umad_dev_put(struct ib_umad_device *dev)
{ … }
static int hdr_size(struct ib_umad_file *file)
{ … }
static struct ib_mad_agent *__get_agent(struct ib_umad_file *file, int id)
{ … }
static int queue_packet(struct ib_umad_file *file, struct ib_mad_agent *agent,
struct ib_umad_packet *packet, bool is_recv_mad)
{ … }
static void dequeue_send(struct ib_umad_file *file,
struct ib_umad_packet *packet)
{ … }
static void send_handler(struct ib_mad_agent *agent,
struct ib_mad_send_wc *send_wc)
{ … }
static void recv_handler(struct ib_mad_agent *agent,
struct ib_mad_send_buf *send_buf,
struct ib_mad_recv_wc *mad_recv_wc)
{ … }
static ssize_t copy_recv_mad(struct ib_umad_file *file, char __user *buf,
struct ib_umad_packet *packet, size_t count)
{ … }
static ssize_t copy_send_mad(struct ib_umad_file *file, char __user *buf,
struct ib_umad_packet *packet, size_t count)
{ … }
static ssize_t ib_umad_read(struct file *filp, char __user *buf,
size_t count, loff_t *pos)
{ … }
static int copy_rmpp_mad(struct ib_mad_send_buf *msg, const char __user *buf)
{ … }
static int same_destination(struct ib_user_mad_hdr *hdr1,
struct ib_user_mad_hdr *hdr2)
{ … }
static int is_duplicate(struct ib_umad_file *file,
struct ib_umad_packet *packet)
{ … }
static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
size_t count, loff_t *pos)
{ … }
static __poll_t ib_umad_poll(struct file *filp, struct poll_table_struct *wait)
{ … }
static int ib_umad_reg_agent(struct ib_umad_file *file, void __user *arg,
int compat_method_mask)
{ … }
static int ib_umad_reg_agent2(struct ib_umad_file *file, void __user *arg)
{ … }
static int ib_umad_unreg_agent(struct ib_umad_file *file, u32 __user *arg)
{ … }
static long ib_umad_enable_pkey(struct ib_umad_file *file)
{ … }
static long ib_umad_ioctl(struct file *filp, unsigned int cmd,
unsigned long arg)
{ … }
#ifdef CONFIG_COMPAT
static long ib_umad_compat_ioctl(struct file *filp, unsigned int cmd,
unsigned long arg)
{ … }
#endif
static int ib_umad_open(struct inode *inode, struct file *filp)
{ … }
static int ib_umad_close(struct inode *inode, struct file *filp)
{ … }
static const struct file_operations umad_fops = …;
static int ib_umad_sm_open(struct inode *inode, struct file *filp)
{ … }
static int ib_umad_sm_close(struct inode *inode, struct file *filp)
{ … }
static const struct file_operations umad_sm_fops = …;
static struct ib_umad_port *get_port(struct ib_device *ibdev,
struct ib_umad_device *umad_dev,
u32 port)
{ … }
static int ib_umad_get_nl_info(struct ib_device *ibdev, void *client_data,
struct ib_client_nl_info *res)
{ … }
static struct ib_client umad_client = …;
MODULE_ALIAS_RDMA_CLIENT(…) …;
static int ib_issm_get_nl_info(struct ib_device *ibdev, void *client_data,
struct ib_client_nl_info *res)
{ … }
static struct ib_client issm_client = …;
MODULE_ALIAS_RDMA_CLIENT(…) …;
static ssize_t ibdev_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RO(ibdev);
static ssize_t port_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RO(port);
static struct attribute *umad_class_dev_attrs[] = …;
ATTRIBUTE_GROUPS(…);
static char *umad_devnode(const struct device *dev, umode_t *mode)
{ … }
static ssize_t abi_version_show(const struct class *class,
const struct class_attribute *attr, char *buf)
{ … }
static CLASS_ATTR_RO(abi_version);
static struct attribute *umad_class_attrs[] = …;
ATTRIBUTE_GROUPS(…);
static struct class umad_class = …;
static void ib_umad_release_port(struct device *device)
{ … }
static void ib_umad_init_port_dev(struct device *dev,
struct ib_umad_port *port,
const struct ib_device *device)
{ … }
static int ib_umad_init_port(struct ib_device *device, int port_num,
struct ib_umad_device *umad_dev,
struct ib_umad_port *port)
{ … }
static void ib_umad_kill_port(struct ib_umad_port *port)
{ … }
static int ib_umad_add_one(struct ib_device *device)
{ … }
static void ib_umad_remove_one(struct ib_device *device, void *client_data)
{ … }
static int __init ib_umad_init(void)
{ … }
static void __exit ib_umad_cleanup(void)
{ … }
module_init(…) …;
module_exit(ib_umad_cleanup);