blob: 63df3a2a8ce54aa184d8a7806f62d9e9cf121050 [file] [log] [blame]
George Zhang20259842013-01-08 15:55:59 -08001/*
2 * VMware VMCI Driver
3 *
4 * Copyright (C) 2012 VMware, Inc. All rights reserved.
5 *
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.
9 *
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
13 * for more details.
14 */
15
16#ifndef __VMW_VMCI_API_H__
17#define __VMW_VMCI_API_H__
18
19#include <linux/uidgid.h>
20#include <linux/vmw_vmci_defs.h>
21
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
26
Al Virod838df22014-11-24 19:32:50 -050027struct msghdr;
George Zhang20259842013-01-08 15:55:59 -080028typedef void (vmci_device_shutdown_fn) (void *device_registration,
29 void *user_data);
30
31int vmci_datagram_create_handle(u32 resource_id, u32 flags,
32 vmci_datagram_recv_cb recv_cb,
33 void *client_data,
34 struct vmci_handle *out_handle);
35int vmci_datagram_create_handle_priv(u32 resource_id, u32 flags, u32 priv_flags,
36 vmci_datagram_recv_cb recv_cb,
37 void *client_data,
38 struct vmci_handle *out_handle);
39int vmci_datagram_destroy_handle(struct vmci_handle handle);
40int vmci_datagram_send(struct vmci_datagram *msg);
41int vmci_doorbell_create(struct vmci_handle *handle, u32 flags,
42 u32 priv_flags,
43 vmci_callback notify_cb, void *client_data);
44int vmci_doorbell_destroy(struct vmci_handle handle);
45int vmci_doorbell_notify(struct vmci_handle handle, u32 priv_flags);
46u32 vmci_get_context_id(void);
47bool vmci_is_context_owner(u32 context_id, kuid_t uid);
48
49int vmci_event_subscribe(u32 event,
50 vmci_event_cb callback, void *callback_data,
51 u32 *subid);
52int vmci_event_unsubscribe(u32 subid);
53u32 vmci_context_get_priv_flags(u32 context_id);
54int vmci_qpair_alloc(struct vmci_qp **qpair,
55 struct vmci_handle *handle,
56 u64 produce_qsize,
57 u64 consume_qsize,
58 u32 peer, u32 flags, u32 priv_flags);
59int vmci_qpair_detach(struct vmci_qp **qpair);
60int vmci_qpair_get_produce_indexes(const struct vmci_qp *qpair,
61 u64 *producer_tail,
62 u64 *consumer_head);
63int vmci_qpair_get_consume_indexes(const struct vmci_qp *qpair,
64 u64 *consumer_tail,
65 u64 *producer_head);
66s64 vmci_qpair_produce_free_space(const struct vmci_qp *qpair);
67s64 vmci_qpair_produce_buf_ready(const struct vmci_qp *qpair);
68s64 vmci_qpair_consume_free_space(const struct vmci_qp *qpair);
69s64 vmci_qpair_consume_buf_ready(const struct vmci_qp *qpair);
70ssize_t vmci_qpair_enqueue(struct vmci_qp *qpair,
71 const void *buf, size_t buf_size, int mode);
72ssize_t vmci_qpair_dequeue(struct vmci_qp *qpair,
73 void *buf, size_t buf_size, int mode);
74ssize_t vmci_qpair_peek(struct vmci_qp *qpair, void *buf, size_t buf_size,
75 int mode);
76ssize_t vmci_qpair_enquev(struct vmci_qp *qpair,
Al Viro4c946d92014-11-27 19:52:04 -050077 struct msghdr *msg, size_t iov_size, int mode);
George Zhang20259842013-01-08 15:55:59 -080078ssize_t vmci_qpair_dequev(struct vmci_qp *qpair,
Al Virod838df22014-11-24 19:32:50 -050079 struct msghdr *msg, size_t iov_size, int mode);
80ssize_t vmci_qpair_peekv(struct vmci_qp *qpair, struct msghdr *msg, size_t iov_size,
George Zhang20259842013-01-08 15:55:59 -080081 int mode);
82
83#endif /* !__VMW_VMCI_API_H__ */