xref: /freebsd/sys/dev/vmware/vmci/vmci_kernel_api_1.h (revision d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf)
1 /*-
2  * Copyright (c) 2018 VMware, Inc.
3  *
4  * SPDX-License-Identifier: (BSD-2-Clause OR GPL-2.0)
5  */
6 
7 /* Kernel API (v1) exported from the VMCI guest driver. */
8 
9 #ifndef _VMCI_KERNEL_API_1_H_
10 #define _VMCI_KERNEL_API_1_H_
11 
12 #include "vmci_call_defs.h"
13 #include "vmci_defs.h"
14 
15 /* Define version 1. */
16 #undef  VMCI_KERNEL_API_VERSION
17 #define VMCI_KERNEL_API_VERSION_1	1
18 #define VMCI_KERNEL_API_VERSION		VMCI_KERNEL_API_VERSION_1
19 
20 /* VMCI Datagram API. */
21 int	vmci_datagram_create_handle(uint32_t resource_id, uint32_t flags,
22 	    vmci_datagram_recv_cb recv_cb, void *client_data,
23 	    struct vmci_handle *out_handle);
24 int	vmci_datagram_create_handle_priv(uint32_t resource_id, uint32_t flags,
25 	    vmci_privilege_flags priv_flags, vmci_datagram_recv_cb recv_cb,
26 	    void *client_data, struct vmci_handle *out_handle);
27 int	vmci_datagram_destroy_handle(struct vmci_handle handle);
28 int	vmci_datagram_send(struct vmci_datagram *msg);
29 
30 /* VMCI Utility API. */
31 vmci_id vmci_get_context_id(void);
32 
33 /* VMCI Event API. */
34 typedef void (*vmci_event_cb)(vmci_id sub_id, struct vmci_event_data *ed,
35 		    void *client_data);
36 
37 int	vmci_event_subscribe(vmci_event_type event, vmci_event_cb callback,
38 	    void *callback_data, vmci_id *sub_id);
39 int	vmci_event_unsubscribe(vmci_id sub_id);
40 
41 /* VMCI Queue Pair API. */
42 struct vmci_qpair;
43 
44 int	vmci_qpair_alloc(struct vmci_qpair **qpair, struct vmci_handle *handle,
45 	    uint64_t produce_q_size, uint64_t consume_q_size, vmci_id peer,
46 	    uint32_t flags, vmci_privilege_flags priv_flags);
47 int	vmci_qpair_detach(struct vmci_qpair **qpair);
48 int	vmci_qpair_get_produce_indexes(const struct vmci_qpair *qpair,
49 	    uint64_t *producer_tail, uint64_t *consumer_head);
50 int	vmci_qpair_get_consume_indexes(const struct vmci_qpair *qpair,
51 	    uint64_t *consumer_tail, uint64_t *producer_head);
52 int64_t	vmci_qpair_produce_free_space(const struct vmci_qpair *qpair);
53 int64_t	vmci_qpair_produce_buf_ready(const struct vmci_qpair *qpair);
54 int64_t	vmci_qpair_consume_free_space(const struct vmci_qpair *qpair);
55 int64_t	vmci_qpair_consume_buf_ready(const struct vmci_qpair *qpair);
56 ssize_t	vmci_qpair_enqueue(struct vmci_qpair *qpair, const void *buf,
57 	    size_t buf_size, int mode);
58 ssize_t	vmci_qpair_dequeue(struct vmci_qpair *qpair, void *buf,
59 	    size_t buf_size, int mode);
60 ssize_t vmci_qpair_peek(struct vmci_qpair *qpair, void *buf,
61 	    size_t buf_size, int mode);
62 ssize_t	vmci_qpair_enquev(struct vmci_qpair *qpair, void *iov, size_t iov_size,
63 	    int mode);
64 ssize_t	vmci_qpair_dequev(struct vmci_qpair *qpair, void *iov, size_t iov_size,
65 	    int mode);
66 ssize_t	vmci_qpair_peekv(struct vmci_qpair *qpair, void *iov, size_t iov_size,
67 	    int mode);
68 
69 #endif /* !_VMCI_KERNEL_API_1_H_ */
70