xref: /freebsd/sys/compat/linuxkpi/common/include/linux/rhashtable.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1*a30a0d94SBjoern A. Zeeb /*-
2*a30a0d94SBjoern A. Zeeb  * Copyright (c) 2023 Bjoern A. Zeeb
3*a30a0d94SBjoern A. Zeeb  *
4*a30a0d94SBjoern A. Zeeb  * Redistribution and use in source and binary forms, with or without
5*a30a0d94SBjoern A. Zeeb  * modification, are permitted provided that the following conditions
6*a30a0d94SBjoern A. Zeeb  * are met:
7*a30a0d94SBjoern A. Zeeb  * 1. Redistributions of source code must retain the above copyright
8*a30a0d94SBjoern A. Zeeb  *    notice, this list of conditions and the following disclaimer.
9*a30a0d94SBjoern A. Zeeb  * 2. Redistributions in binary form must reproduce the above copyright
10*a30a0d94SBjoern A. Zeeb  *    notice, this list of conditions and the following disclaimer in the
11*a30a0d94SBjoern A. Zeeb  *    documentation and/or other materials provided with the distribution.
12*a30a0d94SBjoern A. Zeeb  *
13*a30a0d94SBjoern A. Zeeb  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14*a30a0d94SBjoern A. Zeeb  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15*a30a0d94SBjoern A. Zeeb  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16*a30a0d94SBjoern A. Zeeb  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17*a30a0d94SBjoern A. Zeeb  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18*a30a0d94SBjoern A. Zeeb  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19*a30a0d94SBjoern A. Zeeb  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20*a30a0d94SBjoern A. Zeeb  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21*a30a0d94SBjoern A. Zeeb  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22*a30a0d94SBjoern A. Zeeb  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23*a30a0d94SBjoern A. Zeeb  * SUCH DAMAGE.
24*a30a0d94SBjoern A. Zeeb  */
25*a30a0d94SBjoern A. Zeeb 
26*a30a0d94SBjoern A. Zeeb #ifndef	_LINUXKPI_LINUX_RHASHTABLE_H
27*a30a0d94SBjoern A. Zeeb #define	_LINUXKPI_LINUX_RHASHTABLE_H
28*a30a0d94SBjoern A. Zeeb 
29*a30a0d94SBjoern A. Zeeb #include <linux/kernel.h>	/* pr_debug */
30*a30a0d94SBjoern A. Zeeb 
31*a30a0d94SBjoern A. Zeeb struct rhash_head {
32*a30a0d94SBjoern A. Zeeb };
33*a30a0d94SBjoern A. Zeeb 
34*a30a0d94SBjoern A. Zeeb struct rhashtable_params {
35*a30a0d94SBjoern A. Zeeb 	uint16_t	head_offset;
36*a30a0d94SBjoern A. Zeeb 	uint16_t	key_len;
37*a30a0d94SBjoern A. Zeeb 	uint16_t	key_offset;
38*a30a0d94SBjoern A. Zeeb 	uint16_t	nelem_hint;
39*a30a0d94SBjoern A. Zeeb 	bool		automatic_shrinking;
40*a30a0d94SBjoern A. Zeeb };
41*a30a0d94SBjoern A. Zeeb 
42*a30a0d94SBjoern A. Zeeb struct rhashtable {
43*a30a0d94SBjoern A. Zeeb };
44*a30a0d94SBjoern A. Zeeb 
45*a30a0d94SBjoern A. Zeeb static inline int
rhashtable_init(struct rhashtable * rht,const struct rhashtable_params * params)46*a30a0d94SBjoern A. Zeeb rhashtable_init(struct rhashtable *rht,
47*a30a0d94SBjoern A. Zeeb     const struct rhashtable_params *params)
48*a30a0d94SBjoern A. Zeeb {
49*a30a0d94SBjoern A. Zeeb 
50*a30a0d94SBjoern A. Zeeb 	pr_debug("%s: TODO\n", __func__);
51*a30a0d94SBjoern A. Zeeb 	return (-1);
52*a30a0d94SBjoern A. Zeeb }
53*a30a0d94SBjoern A. Zeeb 
54*a30a0d94SBjoern A. Zeeb static inline void
rhashtable_destroy(struct rhashtable * rht)55*a30a0d94SBjoern A. Zeeb rhashtable_destroy(struct rhashtable *rht)
56*a30a0d94SBjoern A. Zeeb {
57*a30a0d94SBjoern A. Zeeb 	pr_debug("%s: TODO\n", __func__);
58*a30a0d94SBjoern A. Zeeb }
59*a30a0d94SBjoern A. Zeeb 
60*a30a0d94SBjoern A. Zeeb static inline void *
rhashtable_lookup_fast(struct rhashtable * rht,const void * key,const struct rhashtable_params params)61*a30a0d94SBjoern A. Zeeb rhashtable_lookup_fast(struct rhashtable *rht, const void *key,
62*a30a0d94SBjoern A. Zeeb     const struct rhashtable_params params)
63*a30a0d94SBjoern A. Zeeb {
64*a30a0d94SBjoern A. Zeeb 
65*a30a0d94SBjoern A. Zeeb 	pr_debug("%s: TODO\n", __func__);
66*a30a0d94SBjoern A. Zeeb 	return (NULL);
67*a30a0d94SBjoern A. Zeeb }
68*a30a0d94SBjoern A. Zeeb 
69*a30a0d94SBjoern A. Zeeb static inline void *
rhashtable_lookup_get_insert_fast(struct rhashtable * rht,struct rhash_head * obj,const struct rhashtable_params params)70*a30a0d94SBjoern A. Zeeb rhashtable_lookup_get_insert_fast(struct rhashtable *rht,
71*a30a0d94SBjoern A. Zeeb     struct rhash_head *obj, const struct rhashtable_params params)
72*a30a0d94SBjoern A. Zeeb {
73*a30a0d94SBjoern A. Zeeb 
74*a30a0d94SBjoern A. Zeeb 	pr_debug("%s: TODO\n", __func__);
75*a30a0d94SBjoern A. Zeeb 	return (NULL);
76*a30a0d94SBjoern A. Zeeb }
77*a30a0d94SBjoern A. Zeeb 
78*a30a0d94SBjoern A. Zeeb static inline int
rhashtable_remove_fast(struct rhashtable * rht,struct rhash_head * obj,const struct rhashtable_params params)79*a30a0d94SBjoern A. Zeeb rhashtable_remove_fast(struct rhashtable *rht,
80*a30a0d94SBjoern A. Zeeb     struct rhash_head *obj, const struct rhashtable_params params)
81*a30a0d94SBjoern A. Zeeb {
82*a30a0d94SBjoern A. Zeeb 
83*a30a0d94SBjoern A. Zeeb 	pr_debug("%s: TODO\n", __func__);
84*a30a0d94SBjoern A. Zeeb 	return (-ENOENT);
85*a30a0d94SBjoern A. Zeeb }
86*a30a0d94SBjoern A. Zeeb 
87*a30a0d94SBjoern A. Zeeb #endif	/* _LINUXKPI_LINUX_RHASHTABLE_H */
88