Commit 5042cddf authored by Michael J. Ruhl's avatar Michael J. Ruhl Committed by Doug Ledford

IB/hfi1: Use filedata rather than filepointer

Since almost all functions that use the hfi1_filedata get the pointer
from the file pointer, simplify by only passing the hfi1_filedata pointer.
Reviewed-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Reviewed-by: default avatarIra Weiny <ira.weiny@intel.com>
Signed-off-by: default avatarMichael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent f4cd8765
...@@ -80,16 +80,18 @@ static u64 kvirt_to_phys(void *addr); ...@@ -80,16 +80,18 @@ static u64 kvirt_to_phys(void *addr);
static int assign_ctxt(struct file *fp, struct hfi1_user_info *uinfo); static int assign_ctxt(struct file *fp, struct hfi1_user_info *uinfo);
static int init_subctxts(struct hfi1_ctxtdata *uctxt, static int init_subctxts(struct hfi1_ctxtdata *uctxt,
const struct hfi1_user_info *uinfo); const struct hfi1_user_info *uinfo);
static int user_init(struct file *fp); static int user_init(struct hfi1_filedata *fd);
static int get_ctxt_info(struct file *fp, void __user *ubase, __u32 len); static int get_ctxt_info(struct hfi1_filedata *fd, void __user *ubase,
static int get_base_info(struct file *fp, void __user *ubase, __u32 len); __u32 len);
static int setup_ctxt(struct file *fp); static int get_base_info(struct hfi1_filedata *fd, void __user *ubase,
__u32 len);
static int setup_ctxt(struct hfi1_filedata *fd);
static int setup_subctxt(struct hfi1_ctxtdata *uctxt); static int setup_subctxt(struct hfi1_ctxtdata *uctxt);
static int get_user_context(struct file *fp, struct hfi1_user_info *uinfo, static int get_user_context(struct hfi1_filedata *fd,
int devno); struct hfi1_user_info *uinfo, int devno);
static int find_shared_ctxt(struct file *fp, static int find_shared_ctxt(struct hfi1_filedata *fd,
const struct hfi1_user_info *uinfo); const struct hfi1_user_info *uinfo);
static int allocate_ctxt(struct file *fp, struct hfi1_devdata *dd, static int allocate_ctxt(struct hfi1_filedata *fd, struct hfi1_devdata *dd,
struct hfi1_user_info *uinfo); struct hfi1_user_info *uinfo);
static unsigned int poll_urgent(struct file *fp, struct poll_table_struct *pt); static unsigned int poll_urgent(struct file *fp, struct poll_table_struct *pt);
static unsigned int poll_next(struct file *fp, struct poll_table_struct *pt); static unsigned int poll_next(struct file *fp, struct poll_table_struct *pt);
...@@ -238,17 +240,17 @@ static long hfi1_file_ioctl(struct file *fp, unsigned int cmd, ...@@ -238,17 +240,17 @@ static long hfi1_file_ioctl(struct file *fp, unsigned int cmd,
ret = assign_ctxt(fp, &uinfo); ret = assign_ctxt(fp, &uinfo);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = setup_ctxt(fp); ret = setup_ctxt(fd);
if (ret) if (ret)
return ret; return ret;
ret = user_init(fp); ret = user_init(fd);
break; break;
case HFI1_IOCTL_CTXT_INFO: case HFI1_IOCTL_CTXT_INFO:
ret = get_ctxt_info(fp, (void __user *)(unsigned long)arg, ret = get_ctxt_info(fd, (void __user *)(unsigned long)arg,
sizeof(struct hfi1_ctxt_info)); sizeof(struct hfi1_ctxt_info));
break; break;
case HFI1_IOCTL_USER_INFO: case HFI1_IOCTL_USER_INFO:
ret = get_base_info(fp, (void __user *)(unsigned long)arg, ret = get_base_info(fd, (void __user *)(unsigned long)arg,
sizeof(struct hfi1_base_info)); sizeof(struct hfi1_base_info));
break; break;
case HFI1_IOCTL_CREDIT_UPD: case HFI1_IOCTL_CREDIT_UPD:
...@@ -262,7 +264,7 @@ static long hfi1_file_ioctl(struct file *fp, unsigned int cmd, ...@@ -262,7 +264,7 @@ static long hfi1_file_ioctl(struct file *fp, unsigned int cmd,
sizeof(tinfo))) sizeof(tinfo)))
return -EFAULT; return -EFAULT;
ret = hfi1_user_exp_rcv_setup(fp, &tinfo); ret = hfi1_user_exp_rcv_setup(fd, &tinfo);
if (!ret) { if (!ret) {
/* /*
* Copy the number of tidlist entries we used * Copy the number of tidlist entries we used
...@@ -284,7 +286,7 @@ static long hfi1_file_ioctl(struct file *fp, unsigned int cmd, ...@@ -284,7 +286,7 @@ static long hfi1_file_ioctl(struct file *fp, unsigned int cmd,
sizeof(tinfo))) sizeof(tinfo)))
return -EFAULT; return -EFAULT;
ret = hfi1_user_exp_rcv_clear(fp, &tinfo); ret = hfi1_user_exp_rcv_clear(fd, &tinfo);
if (ret) if (ret)
break; break;
addr = arg + offsetof(struct hfi1_tid_info, tidcnt); addr = arg + offsetof(struct hfi1_tid_info, tidcnt);
...@@ -299,7 +301,7 @@ static long hfi1_file_ioctl(struct file *fp, unsigned int cmd, ...@@ -299,7 +301,7 @@ static long hfi1_file_ioctl(struct file *fp, unsigned int cmd,
sizeof(tinfo))) sizeof(tinfo)))
return -EFAULT; return -EFAULT;
ret = hfi1_user_exp_rcv_invalid(fp, &tinfo); ret = hfi1_user_exp_rcv_invalid(fd, &tinfo);
if (ret) if (ret)
break; break;
addr = arg + offsetof(struct hfi1_tid_info, tidcnt); addr = arg + offsetof(struct hfi1_tid_info, tidcnt);
...@@ -436,7 +438,7 @@ static ssize_t hfi1_write_iter(struct kiocb *kiocb, struct iov_iter *from) ...@@ -436,7 +438,7 @@ static ssize_t hfi1_write_iter(struct kiocb *kiocb, struct iov_iter *from)
unsigned long count = 0; unsigned long count = 0;
ret = hfi1_user_sdma_process_request( ret = hfi1_user_sdma_process_request(
kiocb->ki_filp, (struct iovec *)(from->iov + done), fd, (struct iovec *)(from->iov + done),
dim, &count); dim, &count);
if (ret) { if (ret) {
reqs = ret; reqs = ret;
...@@ -863,7 +865,7 @@ static int assign_ctxt(struct file *fp, struct hfi1_user_info *uinfo) ...@@ -863,7 +865,7 @@ static int assign_ctxt(struct file *fp, struct hfi1_user_info *uinfo)
if (uinfo->subctxt_cnt) { if (uinfo->subctxt_cnt) {
struct hfi1_filedata *fd = fp->private_data; struct hfi1_filedata *fd = fp->private_data;
ret = find_shared_ctxt(fp, uinfo); ret = find_shared_ctxt(fd, uinfo);
if (ret < 0) if (ret < 0)
goto done_unlock; goto done_unlock;
if (ret) { if (ret) {
...@@ -878,7 +880,7 @@ static int assign_ctxt(struct file *fp, struct hfi1_user_info *uinfo) ...@@ -878,7 +880,7 @@ static int assign_ctxt(struct file *fp, struct hfi1_user_info *uinfo)
*/ */
if (!ret) { if (!ret) {
i_minor = iminor(file_inode(fp)) - HFI1_USER_MINOR_BASE; i_minor = iminor(file_inode(fp)) - HFI1_USER_MINOR_BASE;
ret = get_user_context(fp, uinfo, i_minor); ret = get_user_context(fp->private_data, uinfo, i_minor);
} }
done_unlock: done_unlock:
mutex_unlock(&hfi1_mutex); mutex_unlock(&hfi1_mutex);
...@@ -886,8 +888,8 @@ static int assign_ctxt(struct file *fp, struct hfi1_user_info *uinfo) ...@@ -886,8 +888,8 @@ static int assign_ctxt(struct file *fp, struct hfi1_user_info *uinfo)
return ret; return ret;
} }
static int get_user_context(struct file *fp, struct hfi1_user_info *uinfo, static int get_user_context(struct hfi1_filedata *fd,
int devno) struct hfi1_user_info *uinfo, int devno)
{ {
struct hfi1_devdata *dd = NULL; struct hfi1_devdata *dd = NULL;
int devmax, npresent, nup; int devmax, npresent, nup;
...@@ -905,15 +907,14 @@ static int get_user_context(struct file *fp, struct hfi1_user_info *uinfo, ...@@ -905,15 +907,14 @@ static int get_user_context(struct file *fp, struct hfi1_user_info *uinfo,
else if (!dd->freectxts) else if (!dd->freectxts)
return -EBUSY; return -EBUSY;
return allocate_ctxt(fp, dd, uinfo); return allocate_ctxt(fd, dd, uinfo);
} }
static int find_shared_ctxt(struct file *fp, static int find_shared_ctxt(struct hfi1_filedata *fd,
const struct hfi1_user_info *uinfo) const struct hfi1_user_info *uinfo)
{ {
int devmax, ndev, i; int devmax, ndev, i;
int ret = 0; int ret = 0;
struct hfi1_filedata *fd = fp->private_data;
devmax = hfi1_count_units(NULL, NULL); devmax = hfi1_count_units(NULL, NULL);
...@@ -960,10 +961,9 @@ static int find_shared_ctxt(struct file *fp, ...@@ -960,10 +961,9 @@ static int find_shared_ctxt(struct file *fp,
return ret; return ret;
} }
static int allocate_ctxt(struct file *fp, struct hfi1_devdata *dd, static int allocate_ctxt(struct hfi1_filedata *fd, struct hfi1_devdata *dd,
struct hfi1_user_info *uinfo) struct hfi1_user_info *uinfo)
{ {
struct hfi1_filedata *fd = fp->private_data;
struct hfi1_ctxtdata *uctxt; struct hfi1_ctxtdata *uctxt;
unsigned ctxt; unsigned ctxt;
int ret, numa; int ret, numa;
...@@ -1113,10 +1113,9 @@ static int setup_subctxt(struct hfi1_ctxtdata *uctxt) ...@@ -1113,10 +1113,9 @@ static int setup_subctxt(struct hfi1_ctxtdata *uctxt)
return ret; return ret;
} }
static int user_init(struct file *fp) static int user_init(struct hfi1_filedata *fd)
{ {
unsigned int rcvctrl_ops = 0; unsigned int rcvctrl_ops = 0;
struct hfi1_filedata *fd = fp->private_data;
struct hfi1_ctxtdata *uctxt = fd->uctxt; struct hfi1_ctxtdata *uctxt = fd->uctxt;
/* make sure that the context has already been setup */ /* make sure that the context has already been setup */
...@@ -1179,10 +1178,10 @@ static int user_init(struct file *fp) ...@@ -1179,10 +1178,10 @@ static int user_init(struct file *fp)
return 0; return 0;
} }
static int get_ctxt_info(struct file *fp, void __user *ubase, __u32 len) static int get_ctxt_info(struct hfi1_filedata *fd, void __user *ubase,
__u32 len)
{ {
struct hfi1_ctxt_info cinfo; struct hfi1_ctxt_info cinfo;
struct hfi1_filedata *fd = fp->private_data;
struct hfi1_ctxtdata *uctxt = fd->uctxt; struct hfi1_ctxtdata *uctxt = fd->uctxt;
int ret = 0; int ret = 0;
...@@ -1220,9 +1219,8 @@ static int get_ctxt_info(struct file *fp, void __user *ubase, __u32 len) ...@@ -1220,9 +1219,8 @@ static int get_ctxt_info(struct file *fp, void __user *ubase, __u32 len)
return ret; return ret;
} }
static int setup_ctxt(struct file *fp) static int setup_ctxt(struct hfi1_filedata *fd)
{ {
struct hfi1_filedata *fd = fp->private_data;
struct hfi1_ctxtdata *uctxt = fd->uctxt; struct hfi1_ctxtdata *uctxt = fd->uctxt;
struct hfi1_devdata *dd = uctxt->dd; struct hfi1_devdata *dd = uctxt->dd;
int ret = 0; int ret = 0;
...@@ -1257,7 +1255,7 @@ static int setup_ctxt(struct file *fp) ...@@ -1257,7 +1255,7 @@ static int setup_ctxt(struct file *fp)
goto done; goto done;
} }
ret = hfi1_user_sdma_alloc_queues(uctxt, fp); ret = hfi1_user_sdma_alloc_queues(uctxt, fd);
if (ret) if (ret)
goto done; goto done;
/* /*
...@@ -1269,7 +1267,7 @@ static int setup_ctxt(struct file *fp) ...@@ -1269,7 +1267,7 @@ static int setup_ctxt(struct file *fp)
* (due to the above wait_event_interruptible() until the master * (due to the above wait_event_interruptible() until the master
* is setup. * is setup.
*/ */
ret = hfi1_user_exp_rcv_init(fp); ret = hfi1_user_exp_rcv_init(fd);
if (ret) if (ret)
goto done; goto done;
...@@ -1278,10 +1276,10 @@ static int setup_ctxt(struct file *fp) ...@@ -1278,10 +1276,10 @@ static int setup_ctxt(struct file *fp)
return ret; return ret;
} }
static int get_base_info(struct file *fp, void __user *ubase, __u32 len) static int get_base_info(struct hfi1_filedata *fd, void __user *ubase,
__u32 len)
{ {
struct hfi1_base_info binfo; struct hfi1_base_info binfo;
struct hfi1_filedata *fd = fp->private_data;
struct hfi1_ctxtdata *uctxt = fd->uctxt; struct hfi1_ctxtdata *uctxt = fd->uctxt;
struct hfi1_devdata *dd = uctxt->dd; struct hfi1_devdata *dd = uctxt->dd;
ssize_t sz; ssize_t sz;
......
...@@ -87,7 +87,7 @@ static void unlock_exp_tids(struct hfi1_ctxtdata *uctxt, ...@@ -87,7 +87,7 @@ static void unlock_exp_tids(struct hfi1_ctxtdata *uctxt,
struct hfi1_filedata *fd); struct hfi1_filedata *fd);
static u32 find_phys_blocks(struct page **pages, unsigned npages, static u32 find_phys_blocks(struct page **pages, unsigned npages,
struct tid_pageset *list); struct tid_pageset *list);
static int set_rcvarray_entry(struct file *fp, unsigned long vaddr, static int set_rcvarray_entry(struct hfi1_filedata *fd, unsigned long vaddr,
u32 rcventry, struct tid_group *grp, u32 rcventry, struct tid_group *grp,
struct page **pages, unsigned npages); struct page **pages, unsigned npages);
static int tid_rb_insert(void *arg, struct mmu_rb_node *node); static int tid_rb_insert(void *arg, struct mmu_rb_node *node);
...@@ -95,12 +95,11 @@ static void cacheless_tid_rb_remove(struct hfi1_filedata *fdata, ...@@ -95,12 +95,11 @@ static void cacheless_tid_rb_remove(struct hfi1_filedata *fdata,
struct tid_rb_node *tnode); struct tid_rb_node *tnode);
static void tid_rb_remove(void *arg, struct mmu_rb_node *node); static void tid_rb_remove(void *arg, struct mmu_rb_node *node);
static int tid_rb_invalidate(void *arg, struct mmu_rb_node *mnode); static int tid_rb_invalidate(void *arg, struct mmu_rb_node *mnode);
static int program_rcvarray(struct file *fp, unsigned long vaddr, static int program_rcvarray(struct hfi1_filedata *fd, unsigned long vaddr,
struct tid_group *grp, struct tid_group *grp, struct tid_pageset *sets,
struct tid_pageset *sets,
unsigned start, u16 count, struct page **pages, unsigned start, u16 count, struct page **pages,
u32 *tidlist, unsigned *tididx, unsigned *pmapped); u32 *tidlist, unsigned *tididx, unsigned *pmapped);
static int unprogram_rcvarray(struct file *fp, u32 tidinfo, static int unprogram_rcvarray(struct hfi1_filedata *fd, u32 tidinfo,
struct tid_group **grp); struct tid_group **grp);
static void clear_tid_node(struct hfi1_filedata *fd, struct tid_rb_node *node); static void clear_tid_node(struct hfi1_filedata *fd, struct tid_rb_node *node);
...@@ -160,9 +159,8 @@ static inline void tid_group_move(struct tid_group *group, ...@@ -160,9 +159,8 @@ static inline void tid_group_move(struct tid_group *group,
* receive caching. This needs to be done after the context has * receive caching. This needs to be done after the context has
* been configured with the eager/expected RcvEntry counts. * been configured with the eager/expected RcvEntry counts.
*/ */
int hfi1_user_exp_rcv_init(struct file *fp) int hfi1_user_exp_rcv_init(struct hfi1_filedata *fd)
{ {
struct hfi1_filedata *fd = fp->private_data;
struct hfi1_ctxtdata *uctxt = fd->uctxt; struct hfi1_ctxtdata *uctxt = fd->uctxt;
struct hfi1_devdata *dd = uctxt->dd; struct hfi1_devdata *dd = uctxt->dd;
unsigned tidbase; unsigned tidbase;
...@@ -361,10 +359,10 @@ static inline void rcv_array_wc_fill(struct hfi1_devdata *dd, u32 index) ...@@ -361,10 +359,10 @@ static inline void rcv_array_wc_fill(struct hfi1_devdata *dd, u32 index)
* can fit into the group. If the group becomes fully * can fit into the group. If the group becomes fully
* used, move it to tid_full_list. * used, move it to tid_full_list.
*/ */
int hfi1_user_exp_rcv_setup(struct file *fp, struct hfi1_tid_info *tinfo) int hfi1_user_exp_rcv_setup(struct hfi1_filedata *fd,
struct hfi1_tid_info *tinfo)
{ {
int ret = 0, need_group = 0, pinned; int ret = 0, need_group = 0, pinned;
struct hfi1_filedata *fd = fp->private_data;
struct hfi1_ctxtdata *uctxt = fd->uctxt; struct hfi1_ctxtdata *uctxt = fd->uctxt;
struct hfi1_devdata *dd = uctxt->dd; struct hfi1_devdata *dd = uctxt->dd;
unsigned npages, ngroups, pageidx = 0, pageset_count, npagesets, unsigned npages, ngroups, pageidx = 0, pageset_count, npagesets,
...@@ -461,7 +459,7 @@ int hfi1_user_exp_rcv_setup(struct file *fp, struct hfi1_tid_info *tinfo) ...@@ -461,7 +459,7 @@ int hfi1_user_exp_rcv_setup(struct file *fp, struct hfi1_tid_info *tinfo)
struct tid_group *grp = struct tid_group *grp =
tid_group_pop(&uctxt->tid_group_list); tid_group_pop(&uctxt->tid_group_list);
ret = program_rcvarray(fp, vaddr, grp, pagesets, ret = program_rcvarray(fd, vaddr, grp, pagesets,
pageidx, dd->rcv_entries.group_size, pageidx, dd->rcv_entries.group_size,
pages, tidlist, &tididx, &mapped); pages, tidlist, &tididx, &mapped);
/* /*
...@@ -507,7 +505,7 @@ int hfi1_user_exp_rcv_setup(struct file *fp, struct hfi1_tid_info *tinfo) ...@@ -507,7 +505,7 @@ int hfi1_user_exp_rcv_setup(struct file *fp, struct hfi1_tid_info *tinfo)
unsigned use = min_t(unsigned, pageset_count - pageidx, unsigned use = min_t(unsigned, pageset_count - pageidx,
grp->size - grp->used); grp->size - grp->used);
ret = program_rcvarray(fp, vaddr, grp, pagesets, ret = program_rcvarray(fd, vaddr, grp, pagesets,
pageidx, use, pages, tidlist, pageidx, use, pages, tidlist,
&tididx, &mapped); &tididx, &mapped);
if (ret < 0) { if (ret < 0) {
...@@ -557,7 +555,7 @@ int hfi1_user_exp_rcv_setup(struct file *fp, struct hfi1_tid_info *tinfo) ...@@ -557,7 +555,7 @@ int hfi1_user_exp_rcv_setup(struct file *fp, struct hfi1_tid_info *tinfo)
* everything done so far so we don't leak resources. * everything done so far so we don't leak resources.
*/ */
tinfo->tidlist = (unsigned long)&tidlist; tinfo->tidlist = (unsigned long)&tidlist;
hfi1_user_exp_rcv_clear(fp, tinfo); hfi1_user_exp_rcv_clear(fd, tinfo);
tinfo->tidlist = 0; tinfo->tidlist = 0;
ret = -EFAULT; ret = -EFAULT;
goto bail; goto bail;
...@@ -581,10 +579,10 @@ int hfi1_user_exp_rcv_setup(struct file *fp, struct hfi1_tid_info *tinfo) ...@@ -581,10 +579,10 @@ int hfi1_user_exp_rcv_setup(struct file *fp, struct hfi1_tid_info *tinfo)
return ret > 0 ? 0 : ret; return ret > 0 ? 0 : ret;
} }
int hfi1_user_exp_rcv_clear(struct file *fp, struct hfi1_tid_info *tinfo) int hfi1_user_exp_rcv_clear(struct hfi1_filedata *fd,
struct hfi1_tid_info *tinfo)
{ {
int ret = 0; int ret = 0;
struct hfi1_filedata *fd = fp->private_data;
struct hfi1_ctxtdata *uctxt = fd->uctxt; struct hfi1_ctxtdata *uctxt = fd->uctxt;
u32 *tidinfo; u32 *tidinfo;
unsigned tididx; unsigned tididx;
...@@ -599,7 +597,7 @@ int hfi1_user_exp_rcv_clear(struct file *fp, struct hfi1_tid_info *tinfo) ...@@ -599,7 +597,7 @@ int hfi1_user_exp_rcv_clear(struct file *fp, struct hfi1_tid_info *tinfo)
mutex_lock(&uctxt->exp_lock); mutex_lock(&uctxt->exp_lock);
for (tididx = 0; tididx < tinfo->tidcnt; tididx++) { for (tididx = 0; tididx < tinfo->tidcnt; tididx++) {
ret = unprogram_rcvarray(fp, tidinfo[tididx], NULL); ret = unprogram_rcvarray(fd, tidinfo[tididx], NULL);
if (ret) { if (ret) {
hfi1_cdbg(TID, "Failed to unprogram rcv array %d", hfi1_cdbg(TID, "Failed to unprogram rcv array %d",
ret); ret);
...@@ -616,9 +614,9 @@ int hfi1_user_exp_rcv_clear(struct file *fp, struct hfi1_tid_info *tinfo) ...@@ -616,9 +614,9 @@ int hfi1_user_exp_rcv_clear(struct file *fp, struct hfi1_tid_info *tinfo)
return ret; return ret;
} }
int hfi1_user_exp_rcv_invalid(struct file *fp, struct hfi1_tid_info *tinfo) int hfi1_user_exp_rcv_invalid(struct hfi1_filedata *fd,
struct hfi1_tid_info *tinfo)
{ {
struct hfi1_filedata *fd = fp->private_data;
struct hfi1_ctxtdata *uctxt = fd->uctxt; struct hfi1_ctxtdata *uctxt = fd->uctxt;
unsigned long *ev = uctxt->dd->events + unsigned long *ev = uctxt->dd->events +
(((uctxt->ctxt - uctxt->dd->first_dyn_alloc_ctxt) * (((uctxt->ctxt - uctxt->dd->first_dyn_alloc_ctxt) *
...@@ -733,7 +731,7 @@ static u32 find_phys_blocks(struct page **pages, unsigned npages, ...@@ -733,7 +731,7 @@ static u32 find_phys_blocks(struct page **pages, unsigned npages,
/** /**
* program_rcvarray() - program an RcvArray group with receive buffers * program_rcvarray() - program an RcvArray group with receive buffers
* @fp: file pointer * @fd: filedata pointer
* @vaddr: starting user virtual address * @vaddr: starting user virtual address
* @grp: RcvArray group * @grp: RcvArray group
* @sets: array of struct tid_pageset holding information on physically * @sets: array of struct tid_pageset holding information on physically
...@@ -758,13 +756,12 @@ static u32 find_phys_blocks(struct page **pages, unsigned npages, ...@@ -758,13 +756,12 @@ static u32 find_phys_blocks(struct page **pages, unsigned npages,
* -ENOMEM or -EFAULT on error from set_rcvarray_entry(), or * -ENOMEM or -EFAULT on error from set_rcvarray_entry(), or
* number of RcvArray entries programmed. * number of RcvArray entries programmed.
*/ */
static int program_rcvarray(struct file *fp, unsigned long vaddr, static int program_rcvarray(struct hfi1_filedata *fd, unsigned long vaddr,
struct tid_group *grp, struct tid_group *grp,
struct tid_pageset *sets, struct tid_pageset *sets,
unsigned start, u16 count, struct page **pages, unsigned start, u16 count, struct page **pages,
u32 *tidlist, unsigned *tididx, unsigned *pmapped) u32 *tidlist, unsigned *tididx, unsigned *pmapped)
{ {
struct hfi1_filedata *fd = fp->private_data;
struct hfi1_ctxtdata *uctxt = fd->uctxt; struct hfi1_ctxtdata *uctxt = fd->uctxt;
struct hfi1_devdata *dd = uctxt->dd; struct hfi1_devdata *dd = uctxt->dd;
u16 idx; u16 idx;
...@@ -805,7 +802,7 @@ static int program_rcvarray(struct file *fp, unsigned long vaddr, ...@@ -805,7 +802,7 @@ static int program_rcvarray(struct file *fp, unsigned long vaddr,
npages = sets[setidx].count; npages = sets[setidx].count;
pageidx = sets[setidx].idx; pageidx = sets[setidx].idx;
ret = set_rcvarray_entry(fp, vaddr + (pageidx * PAGE_SIZE), ret = set_rcvarray_entry(fd, vaddr + (pageidx * PAGE_SIZE),
rcventry, grp, pages + pageidx, rcventry, grp, pages + pageidx,
npages); npages);
if (ret) if (ret)
...@@ -827,12 +824,11 @@ static int program_rcvarray(struct file *fp, unsigned long vaddr, ...@@ -827,12 +824,11 @@ static int program_rcvarray(struct file *fp, unsigned long vaddr,
return idx; return idx;
} }
static int set_rcvarray_entry(struct file *fp, unsigned long vaddr, static int set_rcvarray_entry(struct hfi1_filedata *fd, unsigned long vaddr,
u32 rcventry, struct tid_group *grp, u32 rcventry, struct tid_group *grp,
struct page **pages, unsigned npages) struct page **pages, unsigned npages)
{ {
int ret; int ret;
struct hfi1_filedata *fd = fp->private_data;
struct hfi1_ctxtdata *uctxt = fd->uctxt; struct hfi1_ctxtdata *uctxt = fd->uctxt;
struct tid_rb_node *node; struct tid_rb_node *node;
struct hfi1_devdata *dd = uctxt->dd; struct hfi1_devdata *dd = uctxt->dd;
...@@ -886,10 +882,9 @@ static int set_rcvarray_entry(struct file *fp, unsigned long vaddr, ...@@ -886,10 +882,9 @@ static int set_rcvarray_entry(struct file *fp, unsigned long vaddr,
return 0; return 0;
} }
static int unprogram_rcvarray(struct file *fp, u32 tidinfo, static int unprogram_rcvarray(struct hfi1_filedata *fd, u32 tidinfo,
struct tid_group **grp) struct tid_group **grp)
{ {
struct hfi1_filedata *fd = fp->private_data;
struct hfi1_ctxtdata *uctxt = fd->uctxt; struct hfi1_ctxtdata *uctxt = fd->uctxt;
struct hfi1_devdata *dd = uctxt->dd; struct hfi1_devdata *dd = uctxt->dd;
struct tid_rb_node *node; struct tid_rb_node *node;
......
...@@ -71,10 +71,13 @@ ...@@ -71,10 +71,13 @@
} while (0) } while (0)
void hfi1_user_exp_rcv_grp_free(struct hfi1_ctxtdata *uctxt); void hfi1_user_exp_rcv_grp_free(struct hfi1_ctxtdata *uctxt);
int hfi1_user_exp_rcv_init(struct file *fp); int hfi1_user_exp_rcv_init(struct hfi1_filedata *fd);
int hfi1_user_exp_rcv_free(struct hfi1_filedata *fd); int hfi1_user_exp_rcv_free(struct hfi1_filedata *fd);
int hfi1_user_exp_rcv_setup(struct file *fp, struct hfi1_tid_info *tinfo); int hfi1_user_exp_rcv_setup(struct hfi1_filedata *fd,
int hfi1_user_exp_rcv_clear(struct file *fp, struct hfi1_tid_info *tinfo); struct hfi1_tid_info *tinfo);
int hfi1_user_exp_rcv_invalid(struct file *fp, struct hfi1_tid_info *tinfo); int hfi1_user_exp_rcv_clear(struct hfi1_filedata *fd,
struct hfi1_tid_info *tinfo);
int hfi1_user_exp_rcv_invalid(struct hfi1_filedata *fd,
struct hfi1_tid_info *tinfo);
#endif /* _HFI1_USER_EXP_RCV_H */ #endif /* _HFI1_USER_EXP_RCV_H */
...@@ -372,9 +372,9 @@ static void sdma_kmem_cache_ctor(void *obj) ...@@ -372,9 +372,9 @@ static void sdma_kmem_cache_ctor(void *obj)
memset(tx, 0, sizeof(*tx)); memset(tx, 0, sizeof(*tx));
} }
int hfi1_user_sdma_alloc_queues(struct hfi1_ctxtdata *uctxt, struct file *fp) int hfi1_user_sdma_alloc_queues(struct hfi1_ctxtdata *uctxt,
struct hfi1_filedata *fd)
{ {
struct hfi1_filedata *fd;
int ret = 0; int ret = 0;
char buf[64]; char buf[64];
struct hfi1_devdata *dd; struct hfi1_devdata *dd;
...@@ -382,13 +382,11 @@ int hfi1_user_sdma_alloc_queues(struct hfi1_ctxtdata *uctxt, struct file *fp) ...@@ -382,13 +382,11 @@ int hfi1_user_sdma_alloc_queues(struct hfi1_ctxtdata *uctxt, struct file *fp)
struct hfi1_user_sdma_pkt_q *pq; struct hfi1_user_sdma_pkt_q *pq;
unsigned long flags; unsigned long flags;
if (!uctxt || !fp) { if (!uctxt || !fd) {
ret = -EBADF; ret = -EBADF;
goto done; goto done;
} }
fd = fp->private_data;
if (!hfi1_sdma_comp_ring_size) { if (!hfi1_sdma_comp_ring_size) {
ret = -EINVAL; ret = -EINVAL;
goto done; goto done;
...@@ -536,11 +534,11 @@ static u8 dlid_to_selector(u16 dlid) ...@@ -536,11 +534,11 @@ static u8 dlid_to_selector(u16 dlid)
return mapping[hash]; return mapping[hash];
} }
int hfi1_user_sdma_process_request(struct file *fp, struct iovec *iovec, int hfi1_user_sdma_process_request(struct hfi1_filedata *fd,
unsigned long dim, unsigned long *count) struct iovec *iovec, unsigned long dim,
unsigned long *count)
{ {
int ret = 0, i; int ret = 0, i;
struct hfi1_filedata *fd = fp->private_data;
struct hfi1_ctxtdata *uctxt = fd->uctxt; struct hfi1_ctxtdata *uctxt = fd->uctxt;
struct hfi1_user_sdma_pkt_q *pq = fd->pq; struct hfi1_user_sdma_pkt_q *pq = fd->pq;
struct hfi1_user_sdma_comp_q *cq = fd->cq; struct hfi1_user_sdma_comp_q *cq = fd->cq;
......
...@@ -80,8 +80,11 @@ struct hfi1_user_sdma_comp_q { ...@@ -80,8 +80,11 @@ struct hfi1_user_sdma_comp_q {
struct hfi1_sdma_comp_entry *comps; struct hfi1_sdma_comp_entry *comps;
}; };
int hfi1_user_sdma_alloc_queues(struct hfi1_ctxtdata *uctxt, struct file *fp); int hfi1_user_sdma_alloc_queues(struct hfi1_ctxtdata *uctxt,
struct hfi1_filedata *fd);
int hfi1_user_sdma_free_queues(struct hfi1_filedata *fd); int hfi1_user_sdma_free_queues(struct hfi1_filedata *fd);
int hfi1_user_sdma_process_request(struct file *fp, struct iovec *iovec, int hfi1_user_sdma_process_request(struct hfi1_filedata *fd,
unsigned long dim, unsigned long *count); struct iovec *iovec, unsigned long dim,
unsigned long *count);
#endif /* _HFI1_USER_SDMA_H */ #endif /* _HFI1_USER_SDMA_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment