824 #include <linux/miscdevice.h> 871 down_read(¤t->mm->mmap_sem);
873 up_read(¤t->mm->mmap_sem);
881 p->ddi_max_buffer_size =
883 p->ddi_max_buffer_segment_size =
885 p->ddi_max_buffer_segments =
911 int n =
p->dbr_bvec.ov_vec.v_nr;
916 if (
p->dbr_buffer_id == 0)
927 sz =
n *
sizeof *
buf;
928 if (copy_from_user(
buf, (
void __user *)
p->dbr_bvec.ov_buf, sz)) {
933 if (copy_from_user(
count,
934 (
void __user *)
p->dbr_bvec.ov_vec.v_count, sz)) {
946 down_read(¤t->mm->mmap_sem);
948 up_read(¤t->mm->mmap_sem);
961 p->dbr_bvec.ov_buf =
buf;
962 p->dbr_bvec.ov_vec.v_count =
count;
964 p->dbr_bvec.ov_buf =
NULL;
965 p->dbr_bvec.ov_vec.v_count =
NULL;
1020 drv_bufs_tlist_del(kb);
1042 if (!virt_addr_valid(kb))
1062 if (!virt_addr_valid(ktm) || !virt_addr_valid(kb))
1072 rc =
op(ktm, cb, kb);
1089 if (!virt_addr_valid(ktm) || !virt_addr_valid(kb))
1110 if (!virt_addr_valid(ktm))
1164 for (
i = 0, sz = 1; nidstrs[
i] !=
NULL; ++
i)
1165 sz += strlen(nidstrs[
i]) + 1;
1166 if (sz >
p->dng_size) {
1176 for (
i = 0, sz = 0; nidstrs[
i] !=
NULL; ++
i) {
1177 strcpy(&
buf[sz], nidstrs[
i]);
1178 sz += strlen(nidstrs[
i]) + 1;
1181 if (copy_to_user((
void __user *)
p->dng_buf,
buf, sz))
1203 unsigned long utmp = (
unsigned long)
p->dts_ctm;
1214 down_read(¤t->mm->mmap_sem);
1216 up_read(¤t->mm->mmap_sem);
1269 drv_bevs_tlist_del(kbev);
1271 drv_bevs_tlink_fini(kbev);
1275 drv_tms_tlist_del(ktm);
1297 if (!virt_addr_valid(ktm))
1320 if (!virt_addr_valid(ktm))
1330 drv_bevs_tlink_init(kbe);
1332 down_read(¤t->mm->mmap_sem);
1334 up_read(¤t->mm->mmap_sem);
1356 drv_bevs_tlink_fini(kbe);
1373 unsigned int cmd,
unsigned long arg)
1388 unsigned sz = _IOC_SIZE(cmd);
1401 if (_IOC_DIR(cmd) & _IOC_WRITE) {
1402 if (copy_from_user(&
p, (
void __user *) arg, sz)) {
1471 if (
rc >= 0 && (_IOC_DIR(cmd) & _IOC_READ)) {
1472 if (copy_to_user((
void __user *) arg, &
p, sz))
1478 !M0_IN(
rc, (-ETIMEDOUT, -ERESTARTSYS))))
1480 if (
rc == -ERESTARTSYS)
1500 if (!(
file->f_flags & O_RDWR))
1510 file->private_data = kd;
1534 bool cleanup =
false;
1576 spin_lock(&ktm->ktm_bevq_lock);
1577 while (kb->kb_ktm == ktm) {
1578 spin_unlock(&ktm->ktm_bevq_lock);
1579 wait_event(ktm->ktm_wq, kb->kb_ktm ==
NULL);
1580 spin_lock(&ktm->ktm_bevq_lock);
1582 spin_unlock(&ktm->ktm_bevq_lock);
1614 .owner = THIS_MODULE,
1627 .minor = MISC_DYNAMIC_MINOR,
1648 printk(
"Motr %s registered with minor %d\n",
1658 printk(
"Motr %s deregistered\n",
nlx_dev.name);
static void nlx_kcore_core_domain_unmap(struct nlx_kcore_domain *kd)
struct nlx_core_kmem_loc kd_cd_loc
static void nlx_kcore_kcore_dom_fini(struct nlx_kcore_domain *kd)
static struct m0_addb2_philter p
static int nlx_dev_ioctl_nidstr_encode(struct m0_lnet_dev_nid_encdec_params *p)
static struct nlx_core_transfer_mc * nlx_kcore_core_tm_map(struct nlx_kcore_transfer_mc *ktm)
M0_INTERNAL void m0_mutex_unlock(struct m0_mutex *mutex)
M0_INTERNAL int nlx_dev_init(void)
struct nlx_core_bev_link cbe_tm_link
#define M0_LNET_BUF_ACTIVE_SEND
int(* nlx_kcore_queue_op_t)(struct nlx_kcore_transfer_mc *ktm, struct nlx_core_buffer *cb, struct nlx_kcore_buffer *kb)
nlx_kcore_queue_op_t ko_buf_passive_recv
static int nlx_dev_buf_deregister(struct nlx_kcore_domain *kd, struct nlx_kcore_buffer *kb)
M0_INTERNAL m0_bcount_t nlx_core_get_max_buffer_segment_size(struct nlx_core_domain *lcdom)
nlx_kcore_queue_op_t ko_buf_msg_send
#define WRITABLE_USER_PAGE_GET(uaddr, pg)
#define M0_LOG(level,...)
static int nlx_kcore_kcore_dom_init(struct nlx_kcore_domain *kd)
static bool nlx_kcore_tm_invariant(const struct nlx_kcore_transfer_mc *kctm)
static bool nlx_core_buffer_invariant(const struct nlx_core_buffer *lcb)
#define M0_LNET_BUF_MSG_SEND
#define NLX_PAGE_OFFSET(addr)
#define M0_LNET_BUF_REGISTER
static int nlx_dev_ioctl_dom_init(struct nlx_kcore_domain *kd, struct m0_lnet_dev_dom_init_params *p)
static struct file_operations nlx_dev_file_ops
static struct nlx_core_domain * nlx_kcore_core_domain_map(struct nlx_kcore_domain *kd)
#define M0_LNET_NIDSTR_ENCODE
#define NLX_ALLOC_PTR(ptr)
void(* ko_dom_fini)(struct nlx_kcore_domain *kd, struct nlx_core_domain *cd)
static int nlx_dev_ioctl_buf_del(const struct nlx_kcore_domain *kd, const struct m0_lnet_dev_buf_queue_params *p)
static int nlx_dev_ioctl_buf_deregister(struct nlx_kcore_domain *kd, struct m0_lnet_dev_buf_deregister_params *p)
M0_INTERNAL void m0_mutex_lock(struct m0_mutex *mutex)
static int nlx_kcore_buffer_uva_to_kiov(struct nlx_kcore_buffer *kb, const struct m0_bufvec *bvec)
static struct nlx_core_buffer * nlx_kcore_core_buffer_map(struct nlx_kcore_buffer *kb)
static int nlx_dev_ioctl_buf_event_wait(const struct nlx_kcore_domain *kd, const struct m0_lnet_dev_buf_event_wait_params *p)
int(* ko_buf_register)(struct nlx_kcore_domain *kd, nlx_core_opaque_ptr_t buffer_id, struct nlx_core_buffer *cb, struct nlx_kcore_buffer *kb)
void(* ko_tm_stop)(struct nlx_core_transfer_mc *ctm, struct nlx_kcore_transfer_mc *ktm)
#define NLX_ALLOC_ARR(ptr, nr)
nlx_kcore_queue_op_t ko_buf_msg_recv
int(* ko_buf_event_wait)(struct nlx_core_transfer_mc *ctm, struct nlx_kcore_transfer_mc *ktm, m0_time_t timeout)
static int nlx_kcore_nidstr_decode(const char *nidstr, uint64_t *nid)
static int nlx_kcore_nidstr_encode(uint64_t nid, char nidstr[M0_NET_LNET_NIDSTR_SIZE])
#define M0_LNET_BUF_PASSIVE_SEND
static int nlx_dev_ioctl_tm_start(struct nlx_kcore_domain *kd, struct m0_lnet_dev_tm_start_params *p)
#define M0_LNET_BUF_DEREGISTER
int(* ko_tm_start)(struct nlx_kcore_domain *kd, struct nlx_core_transfer_mc *ctm, struct nlx_kcore_transfer_mc *ktm)
#define M0_ERR_INFO(rc, fmt,...)
static int nlx_dev_ioctl_tm_stop(struct nlx_kcore_domain *kd, struct m0_lnet_dev_tm_stop_params *p)
return M0_ERR(-EOPNOTSUPP)
struct nlx_core_kmem_loc cbl_p_self_loc
M0_INTERNAL void nlx_dev_fini(void)
static int nlx_dev_ioctl_buf_register(struct nlx_kcore_domain *kd, struct m0_lnet_dev_buf_register_params *p)
M0_INTERNAL int nlx_dev_close(struct inode *inode, struct file *file)
static struct miscdevice nlx_dev
void(* ko_buf_deregister)(struct nlx_core_buffer *cb, struct nlx_kcore_buffer *kb)
nlx_kcore_queue_op_t ko_buf_passive_send
#define M0_LNET_NIDSTR_DECODE
#define NLX_ALLOC(ptr, len)
static int nlx_dev_ioctl_nidstr_decode(struct m0_lnet_dev_nid_encdec_params *p)
M0_INTERNAL m0_bcount_t nlx_core_get_max_buffer_size(struct nlx_core_domain *lcdom)
static void nlx_kcore_core_bev_unmap(struct nlx_kcore_buffer_event *kbe)
M0_INTERNAL int32_t nlx_core_get_max_buffer_segments(struct nlx_core_domain *lcdom)
nlx_kcore_queue_op_t ko_buf_active_send
static void nlx_core_kmem_loc_set(struct nlx_core_kmem_loc *loc, struct page *pg, uint32_t off)
static void bev_link_bless(struct nlx_core_bev_link *ql, struct page *pg)
M0_INTERNAL void nlx_core_nidstrs_put(struct nlx_core_domain *lcdom, char ***nidary)
struct m0_mutex kd_drv_mutex
static void nlx_kcore_core_tm_unmap(struct nlx_kcore_transfer_mc *ktm)
static bool nlx_dev_registered
#define M0_LNET_BUF_EVENT_WAIT
struct nlx_kcore_ops * kd_drv_ops
#define M0_LNET_BUF_PASSIVE_RECV
int(* ko_buf_del)(struct nlx_kcore_transfer_mc *ktm, struct nlx_kcore_buffer *kb)
#define M0_LNET_IOC_MAX_NR
static int nlx_dev_open(struct inode *inode, struct file *file)
struct nlx_core_kmem_loc kb_cb_loc
static int nlx_dev_tm_cleanup(struct nlx_kcore_domain *kd, struct nlx_kcore_transfer_mc *ktm)
#define M0_LNET_NIDSTRS_GET
static long nlx_dev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
#define WRITABLE_USER_PAGE_PUT(pg)
static bool nlx_core_tm_invariant(const struct nlx_core_transfer_mc *lctm)
#define m0_tlist_for(descr, head, obj)
#define M0_LNET_BEV_BLESS
static int nlx_dev_ioctl_buf_queue_op(const struct m0_lnet_dev_buf_queue_params *p, nlx_kcore_queue_op_t op)
static void nlx_dev_buf_pages_unpin(const struct nlx_kcore_buffer *kb)
#define M0_LNET_IOC_MAGIC
struct nlx_core_kmem_loc kbe_bev_loc
static struct nlx_core_buffer_event * nlx_kcore_core_bev_map(struct nlx_kcore_buffer_event *kbe)
static bool nlx_core_kmem_loc_is_empty(const struct nlx_core_kmem_loc *loc)
#define M0_LNET_IOC_MIN_NR
#define M0_LNET_BUF_MSG_RECV
struct m0_tl ktm_drv_bevs
int(* ko_dom_init)(struct nlx_kcore_domain *kd, struct nlx_core_domain *cd)
struct nlx_core_kmem_loc ktm_ctm_loc
M0_BASSERT(sizeof(struct nlx_xo_domain)< PAGE_SIZE)
#define m0_tl_for(name, head, obj)
static bool nlx_kcore_buffer_invariant(const struct nlx_kcore_buffer *kcb)
nlx_kcore_queue_op_t ko_buf_active_recv
static void nlx_kcore_core_buffer_unmap(struct nlx_kcore_buffer *kb)
#define M0_LNET_BUF_ACTIVE_RECV
static int nlx_dev_ioctl_nidstrs_get(struct nlx_kcore_domain *kd, struct m0_lnet_dev_nidstrs_get_params *p)
nlx_core_opaque_ptr_t cb_buffer_id
M0_INTERNAL int nlx_core_nidstrs_get(struct nlx_core_domain *lcdom, char ***nidary)
static bool nlx_kcore_domain_invariant(const struct nlx_kcore_domain *kd)
static int nlx_kcore_LNetMDUnlink(struct nlx_kcore_transfer_mc *kctm, struct nlx_kcore_buffer *kcb)
static int nlx_dev_ioctl_bev_bless(struct nlx_kcore_domain *kd, struct m0_lnet_dev_bev_bless_params *p)