18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * VMware VMCI Driver
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2012 VMware, Inc. All rights reserved.
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef _VMCI_RESOURCE_H_
98c2ecf20Sopenharmony_ci#define _VMCI_RESOURCE_H_
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include <linux/vmw_vmci_defs.h>
128c2ecf20Sopenharmony_ci#include <linux/types.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#include "vmci_context.h"
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_cienum vmci_resource_type {
188c2ecf20Sopenharmony_ci	VMCI_RESOURCE_TYPE_ANY,
198c2ecf20Sopenharmony_ci	VMCI_RESOURCE_TYPE_API,
208c2ecf20Sopenharmony_ci	VMCI_RESOURCE_TYPE_GROUP,
218c2ecf20Sopenharmony_ci	VMCI_RESOURCE_TYPE_DATAGRAM,
228c2ecf20Sopenharmony_ci	VMCI_RESOURCE_TYPE_DOORBELL,
238c2ecf20Sopenharmony_ci	VMCI_RESOURCE_TYPE_QPAIR_GUEST,
248c2ecf20Sopenharmony_ci	VMCI_RESOURCE_TYPE_QPAIR_HOST
258c2ecf20Sopenharmony_ci};
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_cistruct vmci_resource {
288c2ecf20Sopenharmony_ci	struct vmci_handle handle;
298c2ecf20Sopenharmony_ci	enum vmci_resource_type type;
308c2ecf20Sopenharmony_ci	struct hlist_node node;
318c2ecf20Sopenharmony_ci	struct kref kref;
328c2ecf20Sopenharmony_ci	struct completion done;
338c2ecf20Sopenharmony_ci};
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ciint vmci_resource_add(struct vmci_resource *resource,
378c2ecf20Sopenharmony_ci		      enum vmci_resource_type resource_type,
388c2ecf20Sopenharmony_ci		      struct vmci_handle handle);
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_civoid vmci_resource_remove(struct vmci_resource *resource);
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_cistruct vmci_resource *
438c2ecf20Sopenharmony_civmci_resource_by_handle(struct vmci_handle resource_handle,
448c2ecf20Sopenharmony_ci			enum vmci_resource_type resource_type);
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_cistruct vmci_resource *vmci_resource_get(struct vmci_resource *resource);
478c2ecf20Sopenharmony_ciint vmci_resource_put(struct vmci_resource *resource);
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_cistruct vmci_handle vmci_resource_handle(struct vmci_resource *resource);
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci#endif /* _VMCI_RESOURCE_H_ */
52