#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/cdev.h>
#include <linux/ioctl.h>
#include <linux/uaccess.h>
#include <linux/list.h>
#include <linux/fs.h>
#include <linux/err.h>
#include <linux/net.h>
#include <linux/poll.h>
#include <linux/spinlock.h>
#include <linux/sched.h>
#include <linux/kfifo.h>
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/mman.h>
#include <linux/dma-mapping.h>
#ifdef CONFIG_RAPIDIO_DMA_ENGINE
#include <linux/dmaengine.h>
#endif
#include <linux/rio.h>
#include <linux/rio_ids.h>
#include <linux/rio_drv.h>
#include <linux/rio_mport_cdev.h>
#include "../rio.h"
#define DRV_NAME …
#define DRV_PREFIX …
#define DEV_NAME …
#define DRV_VERSION …
enum { … };
#ifdef DEBUG
#define rmcd_debug(level, fmt, arg...) …
#else
#define rmcd_debug …
#endif
#define rmcd_warn(fmt, arg...) …
#define rmcd_error(fmt, arg...) …
MODULE_AUTHOR(…) …;
MODULE_AUTHOR(…) …;
MODULE_AUTHOR(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
MODULE_VERSION(…);
static int dma_timeout = …;
module_param(dma_timeout, int, S_IRUGO);
MODULE_PARM_DESC(…) …;
#ifdef DEBUG
static u32 dbg_level = …;
module_param(dbg_level, uint, S_IWUSR | S_IWGRP | S_IRUGO);
MODULE_PARM_DESC(…) …;
#endif
struct mport_dma_buf { … };
enum rio_mport_map_dir { … };
struct rio_mport_mapping { … };
struct rio_mport_dma_map { … };
#define MPORT_MAX_DMA_BUFS …
#define MPORT_EVENT_DEPTH …
struct mport_dev { … };
struct mport_cdev_priv { … };
struct rio_mport_pw_filter { … };
struct rio_mport_db_filter { … };
static LIST_HEAD(mport_devs);
static DEFINE_MUTEX(mport_devs_lock);
#if (0)
static DECLARE_WAIT_QUEUE_HEAD(mport_cdev_wait);
#endif
static const struct class dev_class = …;
static dev_t dev_number;
static void mport_release_mapping(struct kref *ref);
static int rio_mport_maint_rd(struct mport_cdev_priv *priv, void __user *arg,
int local)
{ … }
static int rio_mport_maint_wr(struct mport_cdev_priv *priv, void __user *arg,
int local)
{ … }
static int
rio_mport_create_outbound_mapping(struct mport_dev *md, struct file *filp,
u16 rioid, u64 raddr, u32 size,
dma_addr_t *paddr)
{ … }
static int
rio_mport_get_outbound_mapping(struct mport_dev *md, struct file *filp,
u16 rioid, u64 raddr, u32 size,
dma_addr_t *paddr)
{ … }
static int rio_mport_obw_map(struct file *filp, void __user *arg)
{ … }
static int rio_mport_obw_free(struct file *filp, void __user *arg)
{ … }
static int maint_hdid_set(struct mport_cdev_priv *priv, void __user *arg)
{ … }
static int maint_comptag_set(struct mport_cdev_priv *priv, void __user *arg)
{ … }
#ifdef CONFIG_RAPIDIO_DMA_ENGINE
struct mport_dma_req { … };
static void mport_release_def_dma(struct kref *dma_ref)
{ … }
static void mport_release_dma(struct kref *dma_ref)
{ … }
static void dma_req_free(struct kref *ref)
{ … }
static void dma_xfer_callback(void *param)
{ … }
static struct dma_async_tx_descriptor
*prep_dma_xfer(struct dma_chan *chan, struct rio_transfer_io *transfer,
struct sg_table *sgt, int nents, enum dma_transfer_direction dir,
enum dma_ctrl_flags flags)
{ … }
static int get_dma_channel(struct mport_cdev_priv *priv)
{ … }
static void put_dma_channel(struct mport_cdev_priv *priv)
{ … }
static int do_dma_request(struct mport_dma_req *req,
struct rio_transfer_io *xfer,
enum rio_transfer_sync sync, int nents)
{ … }
static int
rio_dma_transfer(struct file *filp, u32 transfer_mode,
enum rio_transfer_sync sync, enum dma_data_direction dir,
struct rio_transfer_io *xfer)
{ … }
static int rio_mport_transfer_ioctl(struct file *filp, void __user *arg)
{ … }
static int rio_mport_wait_for_async_dma(struct file *filp, void __user *arg)
{ … }
static int rio_mport_create_dma_mapping(struct mport_dev *md, struct file *filp,
u64 size, struct rio_mport_mapping **mapping)
{ … }
static int rio_mport_alloc_dma(struct file *filp, void __user *arg)
{ … }
static int rio_mport_free_dma(struct file *filp, void __user *arg)
{ … }
#else
static int rio_mport_transfer_ioctl(struct file *filp, void *arg)
{
return -ENODEV;
}
static int rio_mport_wait_for_async_dma(struct file *filp, void __user *arg)
{
return -ENODEV;
}
static int rio_mport_alloc_dma(struct file *filp, void __user *arg)
{
return -ENODEV;
}
static int rio_mport_free_dma(struct file *filp, void __user *arg)
{
return -ENODEV;
}
#endif
static int
rio_mport_create_inbound_mapping(struct mport_dev *md, struct file *filp,
u64 raddr, u64 size,
struct rio_mport_mapping **mapping)
{ … }
static int
rio_mport_get_inbound_mapping(struct mport_dev *md, struct file *filp,
u64 raddr, u64 size,
struct rio_mport_mapping **mapping)
{ … }
static int rio_mport_map_inbound(struct file *filp, void __user *arg)
{ … }
static int rio_mport_inbound_free(struct file *filp, void __user *arg)
{ … }
static int maint_port_idx_get(struct mport_cdev_priv *priv, void __user *arg)
{ … }
static int rio_mport_add_event(struct mport_cdev_priv *priv,
struct rio_event *event)
{ … }
static void rio_mport_doorbell_handler(struct rio_mport *mport, void *dev_id,
u16 src, u16 dst, u16 info)
{ … }
static int rio_mport_add_db_filter(struct mport_cdev_priv *priv,
void __user *arg)
{ … }
static void rio_mport_delete_db_filter(struct rio_mport_db_filter *db_filter)
{ … }
static int rio_mport_remove_db_filter(struct mport_cdev_priv *priv,
void __user *arg)
{ … }
static int rio_mport_match_pw(union rio_pw_msg *msg,
struct rio_pw_filter *filter)
{ … }
static int rio_mport_pw_handler(struct rio_mport *mport, void *context,
union rio_pw_msg *msg, int step)
{ … }
static int rio_mport_add_pw_filter(struct mport_cdev_priv *priv,
void __user *arg)
{ … }
static void rio_mport_delete_pw_filter(struct rio_mport_pw_filter *pw_filter)
{ … }
static int rio_mport_match_pw_filter(struct rio_pw_filter *a,
struct rio_pw_filter *b)
{ … }
static int rio_mport_remove_pw_filter(struct mport_cdev_priv *priv,
void __user *arg)
{ … }
static void rio_release_dev(struct device *dev)
{ … }
static void rio_release_net(struct device *dev)
{ … }
static int rio_mport_add_riodev(struct mport_cdev_priv *priv,
void __user *arg)
{ … }
static int rio_mport_del_riodev(struct mport_cdev_priv *priv, void __user *arg)
{ … }
static int mport_cdev_open(struct inode *inode, struct file *filp)
{ … }
static int mport_cdev_fasync(int fd, struct file *filp, int mode)
{ … }
#ifdef CONFIG_RAPIDIO_DMA_ENGINE
static void mport_cdev_release_dma(struct file *filp)
{ … }
#else
#define mport_cdev_release_dma …
#endif
static int mport_cdev_release(struct inode *inode, struct file *filp)
{ … }
static long mport_cdev_ioctl(struct file *filp,
unsigned int cmd, unsigned long arg)
{ … }
static void mport_release_mapping(struct kref *ref)
{ … }
static void mport_mm_open(struct vm_area_struct *vma)
{ … }
static void mport_mm_close(struct vm_area_struct *vma)
{ … }
static const struct vm_operations_struct vm_ops = …;
static int mport_cdev_mmap(struct file *filp, struct vm_area_struct *vma)
{ … }
static __poll_t mport_cdev_poll(struct file *filp, poll_table *wait)
{ … }
static ssize_t mport_read(struct file *filp, char __user *buf, size_t count,
loff_t *ppos)
{ … }
static ssize_t mport_write(struct file *filp, const char __user *buf,
size_t count, loff_t *ppos)
{ … }
static const struct file_operations mport_fops = …;
static void mport_device_release(struct device *dev)
{ … }
static struct mport_dev *mport_cdev_add(struct rio_mport *mport)
{ … }
static void mport_cdev_terminate_dma(struct mport_dev *md)
{ … }
static int mport_cdev_kill_fasync(struct mport_dev *md)
{ … }
static void mport_cdev_remove(struct mport_dev *md)
{ … }
static int mport_add_mport(struct device *dev)
{ … }
static void mport_remove_mport(struct device *dev)
{ … }
static struct class_interface rio_mport_interface __refdata = …;
static int __init mport_init(void)
{ … }
static void __exit mport_exit(void)
{ … }
module_init(…) …;
module_exit(mport_exit);