4 * Copyright (C) 2012 VMware, Inc. All rights reserved.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation version 2 and no later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 #ifndef __VMW_VMCI_API_H__
17 #define __VMW_VMCI_API_H__
19 #include <linux/uidgid.h>
20 #include <linux/vmw_vmci_defs.h>
22 #undef VMCI_KERNEL_API_VERSION
23 #define VMCI_KERNEL_API_VERSION_1 1
24 #define VMCI_KERNEL_API_VERSION_2 2
25 #define VMCI_KERNEL_API_VERSION VMCI_KERNEL_API_VERSION_2
27 typedef void (vmci_device_shutdown_fn
) (void *device_registration
,
30 int vmci_datagram_create_handle(u32 resource_id
, u32 flags
,
31 vmci_datagram_recv_cb recv_cb
,
33 struct vmci_handle
*out_handle
);
34 int vmci_datagram_create_handle_priv(u32 resource_id
, u32 flags
, u32 priv_flags
,
35 vmci_datagram_recv_cb recv_cb
,
37 struct vmci_handle
*out_handle
);
38 int vmci_datagram_destroy_handle(struct vmci_handle handle
);
39 int vmci_datagram_send(struct vmci_datagram
*msg
);
40 int vmci_doorbell_create(struct vmci_handle
*handle
, u32 flags
,
42 vmci_callback notify_cb
, void *client_data
);
43 int vmci_doorbell_destroy(struct vmci_handle handle
);
44 int vmci_doorbell_notify(struct vmci_handle handle
, u32 priv_flags
);
45 u32
vmci_get_context_id(void);
46 bool vmci_is_context_owner(u32 context_id
, kuid_t uid
);
48 int vmci_event_subscribe(u32 event
,
49 vmci_event_cb callback
, void *callback_data
,
51 int vmci_event_unsubscribe(u32 subid
);
52 u32
vmci_context_get_priv_flags(u32 context_id
);
53 int vmci_qpair_alloc(struct vmci_qp
**qpair
,
54 struct vmci_handle
*handle
,
57 u32 peer
, u32 flags
, u32 priv_flags
);
58 int vmci_qpair_detach(struct vmci_qp
**qpair
);
59 int vmci_qpair_get_produce_indexes(const struct vmci_qp
*qpair
,
62 int vmci_qpair_get_consume_indexes(const struct vmci_qp
*qpair
,
65 s64
vmci_qpair_produce_free_space(const struct vmci_qp
*qpair
);
66 s64
vmci_qpair_produce_buf_ready(const struct vmci_qp
*qpair
);
67 s64
vmci_qpair_consume_free_space(const struct vmci_qp
*qpair
);
68 s64
vmci_qpair_consume_buf_ready(const struct vmci_qp
*qpair
);
69 ssize_t
vmci_qpair_enqueue(struct vmci_qp
*qpair
,
70 const void *buf
, size_t buf_size
, int mode
);
71 ssize_t
vmci_qpair_dequeue(struct vmci_qp
*qpair
,
72 void *buf
, size_t buf_size
, int mode
);
73 ssize_t
vmci_qpair_peek(struct vmci_qp
*qpair
, void *buf
, size_t buf_size
,
75 ssize_t
vmci_qpair_enquev(struct vmci_qp
*qpair
,
76 void *iov
, size_t iov_size
, int mode
);
77 ssize_t
vmci_qpair_dequev(struct vmci_qp
*qpair
,
78 void *iov
, size_t iov_size
, int mode
);
79 ssize_t
vmci_qpair_peekv(struct vmci_qp
*qpair
, void *iov
, size_t iov_size
,
82 #endif /* !__VMW_VMCI_API_H__ */