2019-05-29 23:57:36 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2013-01-08 23:54:39 +00:00
|
|
|
/*
|
|
|
|
* VMware VMCI Driver
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 VMware, Inc. All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _VMCI_HANDLE_ARRAY_H_
|
|
|
|
#define _VMCI_HANDLE_ARRAY_H_
|
|
|
|
|
|
|
|
#include <linux/vmw_vmci_defs.h>
|
2019-05-24 15:13:10 +00:00
|
|
|
#include <linux/limits.h>
|
2013-01-08 23:54:39 +00:00
|
|
|
#include <linux/types.h>
|
|
|
|
|
|
|
|
struct vmci_handle_arr {
|
2019-05-24 15:13:10 +00:00
|
|
|
u32 capacity;
|
|
|
|
u32 max_capacity;
|
|
|
|
u32 size;
|
|
|
|
u32 pad;
|
2013-01-08 23:54:39 +00:00
|
|
|
struct vmci_handle entries[];
|
|
|
|
};
|
|
|
|
|
2019-05-24 15:13:10 +00:00
|
|
|
#define VMCI_HANDLE_ARRAY_HEADER_SIZE \
|
|
|
|
offsetof(struct vmci_handle_arr, entries)
|
|
|
|
/* Select a default capacity that results in a 64 byte sized array */
|
|
|
|
#define VMCI_HANDLE_ARRAY_DEFAULT_CAPACITY 6
|
|
|
|
/* Make sure that the max array size can be expressed by a u32 */
|
|
|
|
#define VMCI_HANDLE_ARRAY_MAX_CAPACITY \
|
|
|
|
((U32_MAX - VMCI_HANDLE_ARRAY_HEADER_SIZE - 1) / \
|
|
|
|
sizeof(struct vmci_handle))
|
|
|
|
|
|
|
|
struct vmci_handle_arr *vmci_handle_arr_create(u32 capacity, u32 max_capacity);
|
2013-01-08 23:54:39 +00:00
|
|
|
void vmci_handle_arr_destroy(struct vmci_handle_arr *array);
|
2019-05-24 15:13:10 +00:00
|
|
|
int vmci_handle_arr_append_entry(struct vmci_handle_arr **array_ptr,
|
|
|
|
struct vmci_handle handle);
|
2013-01-08 23:54:39 +00:00
|
|
|
struct vmci_handle vmci_handle_arr_remove_entry(struct vmci_handle_arr *array,
|
|
|
|
struct vmci_handle
|
|
|
|
entry_handle);
|
|
|
|
struct vmci_handle vmci_handle_arr_remove_tail(struct vmci_handle_arr *array);
|
|
|
|
struct vmci_handle
|
2019-05-24 15:13:10 +00:00
|
|
|
vmci_handle_arr_get_entry(const struct vmci_handle_arr *array, u32 index);
|
2013-01-08 23:54:39 +00:00
|
|
|
bool vmci_handle_arr_has_entry(const struct vmci_handle_arr *array,
|
|
|
|
struct vmci_handle entry_handle);
|
|
|
|
struct vmci_handle *vmci_handle_arr_get_handles(struct vmci_handle_arr *array);
|
|
|
|
|
2019-05-24 15:13:10 +00:00
|
|
|
static inline u32 vmci_handle_arr_get_size(
|
2013-01-08 23:54:39 +00:00
|
|
|
const struct vmci_handle_arr *array)
|
|
|
|
{
|
|
|
|
return array->size;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* _VMCI_HANDLE_ARRAY_H_ */
|