break;
}
- return (error);
+ return error;
}
moduledata_t contigmem_mod = {
if (contigmem_num_buffers > RTE_CONTIGMEM_MAX_NUM_BUFS) {
printf("%d buffers requested is greater than %d allowed\n",
contigmem_num_buffers, RTE_CONTIGMEM_MAX_NUM_BUFS);
- return (EINVAL);
+ return EINVAL;
}
if (contigmem_buffer_size < PAGE_SIZE ||
(contigmem_buffer_size & (contigmem_buffer_size - 1)) != 0) {
printf("buffer size 0x%lx is not greater than PAGE_SIZE and "
"power of two\n", contigmem_buffer_size);
- return (EINVAL);
+ return EINVAL;
}
for (i = 0; i < contigmem_num_buffers; i++) {
if (contigmem_buffers[i] == NULL) {
printf("contigmalloc failed for buffer %d\n", i);
- return (ENOMEM);
+ return ENOMEM;
}
printf("%2u: virt=%p phys=%p\n", i, contigmem_buffers[i],
contigmem_cdev = make_dev_credf(0, &contigmem_ops, 0, NULL, UID_ROOT,
GID_WHEEL, 0600, "contigmem");
- return (0);
+ return 0;
}
static int
contigfree(contigmem_buffers[i], contigmem_buffer_size,
M_CONTIGMEM);
- return (0);
+ return 0;
}
static int
int index = (int)(uintptr_t)arg1;
physaddr = (uint64_t)vtophys(contigmem_buffers[index]);
- return (sysctl_handle_64(oidp, &physaddr, 0, req));
+ return sysctl_handle_64(oidp, &physaddr, 0, req);
}
static int
contigmem_open(struct cdev *cdev, int fflags, int devtype,
struct thread *td)
{
- return (0);
+ return 0;
}
static int
{
*paddr = offset;
- return (0);
+ return 0;
}
static int
contigmem_mmap_single(struct cdev *cdev, vm_ooffset_t *offset, vm_size_t size,
struct vm_object **obj, int nprot)
{
+ uint64_t buffer_index;
+
/*
* The buffer index is encoded in the offset. Divide the offset by
* PAGE_SIZE to get the index of the buffer requested by the user
* app.
*/
- if ((*offset/PAGE_SIZE) >= contigmem_num_buffers)
- return (EINVAL);
+ buffer_index = *offset / PAGE_SIZE;
+ if (buffer_index >= contigmem_num_buffers)
+ return EINVAL;
- *offset = (vm_ooffset_t)vtophys(contigmem_buffers[*offset/PAGE_SIZE]);
+ memset(contigmem_buffers[buffer_index], 0, contigmem_buffer_size);
+ *offset = (vm_ooffset_t)vtophys(contigmem_buffers[buffer_index]);
*obj = vm_pager_allocate(OBJT_DEVICE, cdev, size, nprot, *offset,
curthread->td_ucred);
- return (0);
+ return 0;
}