Christopher Ferris | 2abfa9e | 2021-11-01 16:26:06 -0700 | [diff] [blame] | 1 | /**************************************************************************** |
| 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 Ferris | 8666d04 | 2023-09-06 14:55:31 -0700 | [diff] [blame] | 21 | #include <linux/stddef.h> |
| 22 | #include <linux/types.h> |
Christopher Ferris | 2abfa9e | 2021-11-01 16:26:06 -0700 | [diff] [blame] | 23 | #define IOPRIO_CLASS_SHIFT 13 |
Christopher Ferris | 8666d04 | 2023-09-06 14:55:31 -0700 | [diff] [blame] | 24 | #define IOPRIO_NR_CLASSES 8 |
| 25 | #define IOPRIO_CLASS_MASK (IOPRIO_NR_CLASSES - 1) |
Christopher Ferris | 2abfa9e | 2021-11-01 16:26:06 -0700 | [diff] [blame] | 26 | #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 Ferris | 2abfa9e | 2021-11-01 16:26:06 -0700 | [diff] [blame] | 29 | enum { |
Christopher Ferris | 8666d04 | 2023-09-06 14:55:31 -0700 | [diff] [blame] | 30 | 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 Ferris | 2abfa9e | 2021-11-01 16:26:06 -0700 | [diff] [blame] | 35 | }; |
Christopher Ferris | 8666d04 | 2023-09-06 14:55:31 -0700 | [diff] [blame] | 36 | #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 Ferris | 2abfa9e | 2021-11-01 16:26:06 -0700 | [diff] [blame] | 40 | #define IOPRIO_BE_NR IOPRIO_NR_LEVELS |
| 41 | enum { |
| 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 Ferris | 8666d04 | 2023-09-06 14:55:31 -0700 | [diff] [blame] | 48 | #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) |
| 53 | enum { |
| 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 Hughes | b10c99d | 2023-10-12 23:57:49 +0000 | [diff] [blame^] | 64 | static __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 Ferris | 2abfa9e | 2021-11-01 16:26:06 -0700 | [diff] [blame] | 70 | #endif |