Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Kernel/userspace transport abstraction for Hyper-V util driver.
0004  *
0005  * Copyright (C) 2015, Vitaly Kuznetsov <vkuznets@redhat.com>
0006  */
0007 
0008 #ifndef _HV_UTILS_TRANSPORT_H
0009 #define _HV_UTILS_TRANSPORT_H
0010 
0011 #include <linux/connector.h>
0012 #include <linux/miscdevice.h>
0013 
0014 enum hvutil_transport_mode {
0015     HVUTIL_TRANSPORT_INIT = 0,
0016     HVUTIL_TRANSPORT_NETLINK,
0017     HVUTIL_TRANSPORT_CHARDEV,
0018     HVUTIL_TRANSPORT_DESTROY,
0019 };
0020 
0021 struct hvutil_transport {
0022     int mode;                           /* hvutil_transport_mode */
0023     struct file_operations fops;        /* file operations */
0024     struct miscdevice mdev;             /* misc device */
0025     struct cb_id cn_id;                 /* CN_*_IDX/CN_*_VAL */
0026     struct list_head list;              /* hvt_list */
0027     int (*on_msg)(void *, int);         /* callback on new user message */
0028     void (*on_reset)(void);             /* callback when userspace drops */
0029     void (*on_read)(void);              /* callback on message read */
0030     u8 *outmsg;                         /* message to the userspace */
0031     int outmsg_len;                     /* its length */
0032     wait_queue_head_t outmsg_q;         /* poll/read wait queue */
0033     struct mutex lock;                  /* protects struct members */
0034     struct completion release;          /* synchronize with fd release */
0035 };
0036 
0037 struct hvutil_transport *hvutil_transport_init(const char *name,
0038                            u32 cn_idx, u32 cn_val,
0039                            int (*on_msg)(void *, int),
0040                            void (*on_reset)(void));
0041 int hvutil_transport_send(struct hvutil_transport *hvt, void *msg, int len,
0042               void (*on_read_cb)(void));
0043 void hvutil_transport_destroy(struct hvutil_transport *hvt);
0044 
0045 #endif /* _HV_UTILS_TRANSPORT_H */