blob: 1c4c9c462b8fb50013dcbc819b31d9846160ad6a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/*-
* Copyright (c) 2018 VMware, Inc.
*
* SPDX-License-Identifier: (BSD-2-Clause OR GPL-2.0)
*
* $FreeBSD$
*/
/* Hash table for use in the APIs. */
#ifndef _VMCI_HASHTABLE_H_
#define _VMCI_HASHTABLE_H_
#include "vmci_defs.h"
#include "vmci_kernel_if.h"
struct vmci_hash_entry {
struct vmci_handle handle;
int ref_count;
struct vmci_hash_entry *next;
};
struct vmci_hashtable {
struct vmci_hash_entry **entries;
/* Number of buckets in above array. */
int size;
vmci_lock lock;
};
struct vmci_hashtable *vmci_hashtable_create(int size);
void vmci_hashtable_destroy(struct vmci_hashtable *table);
void vmci_hashtable_init_entry(struct vmci_hash_entry *entry,
struct vmci_handle handle);
int vmci_hashtable_add_entry(struct vmci_hashtable *table,
struct vmci_hash_entry *entry);
int vmci_hashtable_remove_entry(struct vmci_hashtable *table,
struct vmci_hash_entry *entry);
struct vmci_hash_entry *vmci_hashtable_get_entry(struct vmci_hashtable *table,
struct vmci_handle handle);
void vmci_hashtable_hold_entry(struct vmci_hashtable *table,
struct vmci_hash_entry *entry);
int vmci_hashtable_release_entry(struct vmci_hashtable *table,
struct vmci_hash_entry *entry);
bool vmci_hashtable_entry_exists(struct vmci_hashtable *table,
struct vmci_handle handle);
void vmci_hashtable_sync(struct vmci_hashtable *table);
#endif /* !_VMCI_HASHTABLE_H_ */
|