ZTS: Fix io_uring support check
[zfs.git] / include / sys / abd_impl.h
blob40546d4af137a94cc59681f8583bda15dc4fc140
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or https://opensource.org/licenses/CDDL-1.0.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright (c) 2014 by Chunwei Chen. All rights reserved.
23 * Copyright (c) 2016, 2019 by Delphix. All rights reserved.
26 #ifndef _ABD_IMPL_H
27 #define _ABD_IMPL_H
29 #include <sys/abd.h>
30 #include <sys/wmsum.h>
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
36 typedef enum abd_stats_op {
37 ABDSTAT_INCR, /* Increase abdstat values */
38 ABDSTAT_DECR /* Decrease abdstat values */
39 } abd_stats_op_t;
41 struct scatterlist; /* forward declaration */
43 struct abd_iter {
44 /* public interface */
45 void *iter_mapaddr; /* addr corresponding to iter_pos */
46 size_t iter_mapsize; /* length of data valid at mapaddr */
48 /* private */
49 abd_t *iter_abd; /* ABD being iterated through */
50 size_t iter_pos;
51 size_t iter_offset; /* offset in current sg/abd_buf, */
52 /* abd_offset included */
53 struct scatterlist *iter_sg; /* current sg */
56 extern abd_t *abd_zero_scatter;
58 abd_t *abd_gang_get_offset(abd_t *, size_t *);
59 abd_t *abd_alloc_struct(size_t);
60 void abd_free_struct(abd_t *);
63 * OS specific functions
66 abd_t *abd_alloc_struct_impl(size_t);
67 abd_t *abd_get_offset_scatter(abd_t *, abd_t *, size_t, size_t);
68 void abd_free_struct_impl(abd_t *);
69 void abd_alloc_chunks(abd_t *, size_t);
70 void abd_free_chunks(abd_t *);
71 void abd_update_scatter_stats(abd_t *, abd_stats_op_t);
72 void abd_update_linear_stats(abd_t *, abd_stats_op_t);
73 void abd_verify_scatter(abd_t *);
74 void abd_free_linear_page(abd_t *);
75 /* OS specific abd_iter functions */
76 void abd_iter_init(struct abd_iter *, abd_t *);
77 boolean_t abd_iter_at_end(struct abd_iter *);
78 void abd_iter_advance(struct abd_iter *, size_t);
79 void abd_iter_map(struct abd_iter *);
80 void abd_iter_unmap(struct abd_iter *);
83 * Helper macros
85 #define ABDSTAT_INCR(stat, val) \
86 wmsum_add(&abd_sums.stat, (val))
87 #define ABDSTAT_BUMP(stat) ABDSTAT_INCR(stat, 1)
88 #define ABDSTAT_BUMPDOWN(stat) ABDSTAT_INCR(stat, -1)
90 #define ABD_SCATTER(abd) (abd->abd_u.abd_scatter)
91 #define ABD_LINEAR_BUF(abd) (abd->abd_u.abd_linear.abd_buf)
92 #define ABD_GANG(abd) (abd->abd_u.abd_gang)
94 #if defined(_KERNEL)
95 #if defined(__FreeBSD__)
96 #define abd_enter_critical(flags) critical_enter()
97 #define abd_exit_critical(flags) critical_exit()
98 #else
99 #define abd_enter_critical(flags) local_irq_save(flags)
100 #define abd_exit_critical(flags) local_irq_restore(flags)
101 #endif
102 #else /* !_KERNEL */
103 #define abd_enter_critical(flags) ((void)0)
104 #define abd_exit_critical(flags) ((void)0)
105 #endif
107 #ifdef __cplusplus
109 #endif
111 #endif /* _ABD_IMPL_H */