xref: /aosp_15_r20/external/ltp/include/lapi/ioprio.h (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Copyright (c) 2019 Linus Walleij <[email protected]>
4  */
5 
6 #ifndef LAPI_IOPRIO_H__
7 #define LAPI_IOPRIO_H__
8 
9 #include "config.h"
10 
11 #ifdef HAVE_LINUX_IOPRIO_H
12 # include <linux/ioprio.h>
13 #else
14 
15 enum {
16 	IOPRIO_CLASS_NONE = 0,
17 	IOPRIO_CLASS_RT,
18 	IOPRIO_CLASS_BE,
19 	IOPRIO_CLASS_IDLE,
20 };
21 
22 enum {
23 	IOPRIO_WHO_PROCESS = 1,
24 	IOPRIO_WHO_PGRP,
25 	IOPRIO_WHO_USER,
26 };
27 
28 # define IOPRIO_CLASS_SHIFT	(13)
29 # define IOPRIO_PRIO_MASK	((1UL << IOPRIO_CLASS_SHIFT) - 1)
30 
31 # define IOPRIO_PRIO_CLASS(data)	((data) >> IOPRIO_CLASS_SHIFT)
32 # define IOPRIO_PRIO_VALUE(class, data)	(((class) << IOPRIO_CLASS_SHIFT) | data)
33 
34 #endif
35 
36 /* The RT and BE I/O priority classes have 8 priority levels 0..7 */
37 #ifdef IOPRIO_NR_LEVELS
38 # define IOPRIO_PRIO_NUM		IOPRIO_NR_LEVELS
39 #else
40 # define IOPRIO_PRIO_NUM		8
41 #endif
42 
43 #ifndef IOPRIO_PRIO_LEVEL
44 # define IOPRIO_PRIO_LEVEL(data)	((data) & IOPRIO_PRIO_MASK)
45 #endif
46 
47 #endif /* LAPI_IOPRIO_H__ */
48