linux/drivers/infiniband/core/user_mad.c

/*
 * Copyright (c) 2004 Topspin Communications.  All rights reserved.
 * Copyright (c) 2005 Voltaire, Inc. All rights reserved.
 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
 * Copyright (c) 2008 Cisco. All rights reserved.
 *
 * This software is available to you under a choice of one of two
 * licenses.  You may choose to be licensed under the terms of the GNU
 * General Public License (GPL) Version 2, available from the file
 * COPYING in the main directory of this source tree, or the
 * OpenIB.org BSD license below:
 *
 *     Redistribution and use in source and binary forms, with or
 *     without modification, are permitted provided that the following
 *     conditions are met:
 *
 *      - Redistributions of source code must retain the above
 *        copyright notice, this list of conditions and the following
 *        disclaimer.
 *
 *      - Redistributions in binary form must reproduce the above
 *        copyright notice, this list of conditions and the following
 *        disclaimer in the documentation and/or other materials
 *        provided with the distribution.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

#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 {};

/*
 * Our lifetime rules for these structs are the following:
 * device special file is opened, we take a reference on the
 * ib_umad_port's struct ib_umad_device. We drop these
 * references in the corresponding close().
 *
 * In addition to references coming from open character devices, there
 * is one more reference to each ib_umad_device representing the
 * module's reference taken when allocating the ib_umad_device in
 * ib_umad_add_one().
 *
 * When destroying an ib_umad_device, we drop the module's reference.
 */

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)
{}

/* caller must hold file->mutex */
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

/*
 * ib_umad_open() does not need the BKL:
 *
 *  - the ib_umad_port structures are properly reference counted, and
 *    everything else is purely local to the file being created, so
 *    races against other open calls are not a problem;
 *  - the ioctl method does not affect any global state outside of the
 *    file structure being operated on;
 */
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);