blob: 1fbedd02d88f522f392f92940e2ea789b3af58f3 [file] [log] [blame]
Christopher Ferris2abfa9e2021-11-01 16:26:06 -07001/****************************************************************************
2 ****************************************************************************
3 ***
4 *** This header was automatically generated from a Linux kernel header
5 *** of the same name, to make information necessary for userspace to
6 *** call into the kernel available to libc. It contains only constants,
7 *** structures, and macros generated from the original header, and thus,
8 *** contains no copyrightable information.
9 ***
10 *** To edit the content of this header, modify the corresponding
11 *** source file (e.g. under external/kernel-headers/original/) then
12 *** run bionic/libc/kernel/tools/update_all.py
13 ***
14 *** Any manual change here will be lost the next time this script will
15 *** be run. You've been warned!
16 ***
17 ****************************************************************************
18 ****************************************************************************/
19#ifndef _UAPI_LINUX_IOPRIO_H
20#define _UAPI_LINUX_IOPRIO_H
Christopher Ferris8666d042023-09-06 14:55:31 -070021#include <linux/stddef.h>
22#include <linux/types.h>
Christopher Ferris2abfa9e2021-11-01 16:26:06 -070023#define IOPRIO_CLASS_SHIFT 13
Christopher Ferris8666d042023-09-06 14:55:31 -070024#define IOPRIO_NR_CLASSES 8
25#define IOPRIO_CLASS_MASK (IOPRIO_NR_CLASSES - 1)
Christopher Ferris2abfa9e2021-11-01 16:26:06 -070026#define IOPRIO_PRIO_MASK ((1UL << IOPRIO_CLASS_SHIFT) - 1)
27#define IOPRIO_PRIO_CLASS(ioprio) (((ioprio) >> IOPRIO_CLASS_SHIFT) & IOPRIO_CLASS_MASK)
28#define IOPRIO_PRIO_DATA(ioprio) ((ioprio) & IOPRIO_PRIO_MASK)
Christopher Ferris2abfa9e2021-11-01 16:26:06 -070029enum {
Christopher Ferris8666d042023-09-06 14:55:31 -070030 IOPRIO_CLASS_NONE = 0,
31 IOPRIO_CLASS_RT = 1,
32 IOPRIO_CLASS_BE = 2,
33 IOPRIO_CLASS_IDLE = 3,
34 IOPRIO_CLASS_INVALID = 7,
Christopher Ferris2abfa9e2021-11-01 16:26:06 -070035};
Christopher Ferris8666d042023-09-06 14:55:31 -070036#define IOPRIO_LEVEL_NR_BITS 3
37#define IOPRIO_NR_LEVELS (1 << IOPRIO_LEVEL_NR_BITS)
38#define IOPRIO_LEVEL_MASK (IOPRIO_NR_LEVELS - 1)
39#define IOPRIO_PRIO_LEVEL(ioprio) ((ioprio) & IOPRIO_LEVEL_MASK)
Christopher Ferris2abfa9e2021-11-01 16:26:06 -070040#define IOPRIO_BE_NR IOPRIO_NR_LEVELS
41enum {
42 IOPRIO_WHO_PROCESS = 1,
43 IOPRIO_WHO_PGRP,
44 IOPRIO_WHO_USER,
45};
46#define IOPRIO_NORM 4
47#define IOPRIO_BE_NORM IOPRIO_NORM
Christopher Ferris8666d042023-09-06 14:55:31 -070048#define IOPRIO_HINT_SHIFT IOPRIO_LEVEL_NR_BITS
49#define IOPRIO_HINT_NR_BITS 10
50#define IOPRIO_NR_HINTS (1 << IOPRIO_HINT_NR_BITS)
51#define IOPRIO_HINT_MASK (IOPRIO_NR_HINTS - 1)
52#define IOPRIO_PRIO_HINT(ioprio) (((ioprio) >> IOPRIO_HINT_SHIFT) & IOPRIO_HINT_MASK)
53enum {
54 IOPRIO_HINT_NONE = 0,
55 IOPRIO_HINT_DEV_DURATION_LIMIT_1 = 1,
56 IOPRIO_HINT_DEV_DURATION_LIMIT_2 = 2,
57 IOPRIO_HINT_DEV_DURATION_LIMIT_3 = 3,
58 IOPRIO_HINT_DEV_DURATION_LIMIT_4 = 4,
59 IOPRIO_HINT_DEV_DURATION_LIMIT_5 = 5,
60 IOPRIO_HINT_DEV_DURATION_LIMIT_6 = 6,
61 IOPRIO_HINT_DEV_DURATION_LIMIT_7 = 7,
62};
63#define IOPRIO_BAD_VALUE(val,max) ((val) < 0 || (val) >= (max))
Elliott Hughesb10c99d2023-10-12 23:57:49 +000064static __always_inline __u16 ioprio_value(int __linux_class, int level, int hint) {
65 if(IOPRIO_BAD_VALUE(__linux_class, IOPRIO_NR_CLASSES) || IOPRIO_BAD_VALUE(level, IOPRIO_NR_LEVELS) || IOPRIO_BAD_VALUE(hint, IOPRIO_NR_HINTS)) return IOPRIO_CLASS_INVALID << IOPRIO_CLASS_SHIFT;
66 return(__linux_class << IOPRIO_CLASS_SHIFT) | (hint << IOPRIO_HINT_SHIFT) | level;
67}
68#define IOPRIO_PRIO_VALUE(class,level) ioprio_value(__linux_class, level, IOPRIO_HINT_NONE)
69#define IOPRIO_PRIO_VALUE_HINT(class,level,hint) ioprio_value(__linux_class, level, hint)
Christopher Ferris2abfa9e2021-11-01 16:26:06 -070070#endif