#include <linux/poll.h>
#include <linux/cdev.h>
#include <linux/vmalloc.h>
#include <linux/io.h>
#include <linux/sched/mm.h>
#include <linux/bitmap.h>
#include <rdma/ib.h>
#include "hfi.h"
#include "pio.h"
#include "device.h"
#include "common.h"
#include "trace.h"
#include "mmu_rb.h"
#include "user_sdma.h"
#include "user_exp_rcv.h"
#include "aspm.h"
#undef pr_fmt
#define pr_fmt(fmt) …
#define SEND_CTXT_HALT_TIMEOUT …
static int hfi1_file_open(struct inode *inode, struct file *fp);
static int hfi1_file_close(struct inode *inode, struct file *fp);
static ssize_t hfi1_write_iter(struct kiocb *kiocb, struct iov_iter *from);
static __poll_t hfi1_poll(struct file *fp, struct poll_table_struct *pt);
static int hfi1_file_mmap(struct file *fp, struct vm_area_struct *vma);
static u64 kvirt_to_phys(void *addr);
static int assign_ctxt(struct hfi1_filedata *fd, unsigned long arg, u32 len);
static void init_subctxts(struct hfi1_ctxtdata *uctxt,
const struct hfi1_user_info *uinfo);
static int init_user_ctxt(struct hfi1_filedata *fd,
struct hfi1_ctxtdata *uctxt);
static void user_init(struct hfi1_ctxtdata *uctxt);
static int get_ctxt_info(struct hfi1_filedata *fd, unsigned long arg, u32 len);
static int get_base_info(struct hfi1_filedata *fd, unsigned long arg, u32 len);
static int user_exp_rcv_setup(struct hfi1_filedata *fd, unsigned long arg,
u32 len);
static int user_exp_rcv_clear(struct hfi1_filedata *fd, unsigned long arg,
u32 len);
static int user_exp_rcv_invalid(struct hfi1_filedata *fd, unsigned long arg,
u32 len);
static int setup_base_ctxt(struct hfi1_filedata *fd,
struct hfi1_ctxtdata *uctxt);
static int setup_subctxt(struct hfi1_ctxtdata *uctxt);
static int find_sub_ctxt(struct hfi1_filedata *fd,
const struct hfi1_user_info *uinfo);
static int allocate_ctxt(struct hfi1_filedata *fd, struct hfi1_devdata *dd,
struct hfi1_user_info *uinfo,
struct hfi1_ctxtdata **cd);
static void deallocate_ctxt(struct hfi1_ctxtdata *uctxt);
static __poll_t poll_urgent(struct file *fp, struct poll_table_struct *pt);
static __poll_t poll_next(struct file *fp, struct poll_table_struct *pt);
static int user_event_ack(struct hfi1_ctxtdata *uctxt, u16 subctxt,
unsigned long arg);
static int set_ctxt_pkey(struct hfi1_ctxtdata *uctxt, unsigned long arg);
static int ctxt_reset(struct hfi1_ctxtdata *uctxt);
static int manage_rcvq(struct hfi1_ctxtdata *uctxt, u16 subctxt,
unsigned long arg);
static vm_fault_t vma_fault(struct vm_fault *vmf);
static long hfi1_file_ioctl(struct file *fp, unsigned int cmd,
unsigned long arg);
static const struct file_operations hfi1_file_ops = …;
static const struct vm_operations_struct vm_ops = …;
enum mmap_types { … };
#define HFI1_MMAP_OFFSET_MASK …
#define HFI1_MMAP_OFFSET_SHIFT …
#define HFI1_MMAP_SUBCTXT_MASK …
#define HFI1_MMAP_SUBCTXT_SHIFT …
#define HFI1_MMAP_CTXT_MASK …
#define HFI1_MMAP_CTXT_SHIFT …
#define HFI1_MMAP_TYPE_MASK …
#define HFI1_MMAP_TYPE_SHIFT …
#define HFI1_MMAP_MAGIC_MASK …
#define HFI1_MMAP_MAGIC_SHIFT …
#define HFI1_MMAP_MAGIC …
#define HFI1_MMAP_TOKEN_SET(field, val) …
#define HFI1_MMAP_TOKEN_GET(field, token) …
#define HFI1_MMAP_TOKEN(type, ctxt, subctxt, addr) …
#define dbg(fmt, ...) …
static inline int is_valid_mmap(u64 token)
{ … }
static int hfi1_file_open(struct inode *inode, struct file *fp)
{ … }
static long hfi1_file_ioctl(struct file *fp, unsigned int cmd,
unsigned long arg)
{ … }
static ssize_t hfi1_write_iter(struct kiocb *kiocb, struct iov_iter *from)
{ … }
static inline void mmap_cdbg(u16 ctxt, u8 subctxt, u8 type, u8 mapio, u8 vmf,
u64 memaddr, void *memvirt, dma_addr_t memdma,
ssize_t memlen, struct vm_area_struct *vma)
{ … }
static int hfi1_file_mmap(struct file *fp, struct vm_area_struct *vma)
{ … }
static vm_fault_t vma_fault(struct vm_fault *vmf)
{ … }
static __poll_t hfi1_poll(struct file *fp, struct poll_table_struct *pt)
{ … }
static int hfi1_file_close(struct inode *inode, struct file *fp)
{ … }
static u64 kvirt_to_phys(void *addr)
{ … }
static int complete_subctxt(struct hfi1_filedata *fd)
{ … }
static int assign_ctxt(struct hfi1_filedata *fd, unsigned long arg, u32 len)
{ … }
static int match_ctxt(struct hfi1_filedata *fd,
const struct hfi1_user_info *uinfo,
struct hfi1_ctxtdata *uctxt)
{ … }
static int find_sub_ctxt(struct hfi1_filedata *fd,
const struct hfi1_user_info *uinfo)
{ … }
static int allocate_ctxt(struct hfi1_filedata *fd, struct hfi1_devdata *dd,
struct hfi1_user_info *uinfo,
struct hfi1_ctxtdata **rcd)
{ … }
static void deallocate_ctxt(struct hfi1_ctxtdata *uctxt)
{ … }
static void init_subctxts(struct hfi1_ctxtdata *uctxt,
const struct hfi1_user_info *uinfo)
{ … }
static int setup_subctxt(struct hfi1_ctxtdata *uctxt)
{ … }
static void user_init(struct hfi1_ctxtdata *uctxt)
{ … }
static int get_ctxt_info(struct hfi1_filedata *fd, unsigned long arg, u32 len)
{ … }
static int init_user_ctxt(struct hfi1_filedata *fd,
struct hfi1_ctxtdata *uctxt)
{ … }
static int setup_base_ctxt(struct hfi1_filedata *fd,
struct hfi1_ctxtdata *uctxt)
{ … }
static int get_base_info(struct hfi1_filedata *fd, unsigned long arg, u32 len)
{ … }
static int user_exp_rcv_setup(struct hfi1_filedata *fd, unsigned long arg,
u32 len)
{ … }
static int user_exp_rcv_clear(struct hfi1_filedata *fd, unsigned long arg,
u32 len)
{ … }
static int user_exp_rcv_invalid(struct hfi1_filedata *fd, unsigned long arg,
u32 len)
{ … }
static __poll_t poll_urgent(struct file *fp,
struct poll_table_struct *pt)
{ … }
static __poll_t poll_next(struct file *fp,
struct poll_table_struct *pt)
{ … }
int hfi1_set_uevent_bits(struct hfi1_pportdata *ppd, const int evtbit)
{ … }
static int manage_rcvq(struct hfi1_ctxtdata *uctxt, u16 subctxt,
unsigned long arg)
{ … }
static int user_event_ack(struct hfi1_ctxtdata *uctxt, u16 subctxt,
unsigned long arg)
{ … }
static int set_ctxt_pkey(struct hfi1_ctxtdata *uctxt, unsigned long arg)
{ … }
static int ctxt_reset(struct hfi1_ctxtdata *uctxt)
{ … }
static void user_remove(struct hfi1_devdata *dd)
{ … }
static int user_add(struct hfi1_devdata *dd)
{ … }
int hfi1_device_create(struct hfi1_devdata *dd)
{ … }
void hfi1_device_remove(struct hfi1_devdata *dd)
{ … }