blob: 2b6a8424b4ffe326934bb693087ed9985803fa03 [file] [log] [blame]
Elliott Hughes180edef2023-11-02 00:08:05 +00001/*
2 * This file is auto-generated. Modifications will be lost.
3 *
4 * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
5 * for more information.
6 */
Christopher Ferris2abfa9e2021-11-01 16:26:06 -07007#ifndef _UAPI_LINUX_IOPRIO_H
8#define _UAPI_LINUX_IOPRIO_H
Christopher Ferris8666d042023-09-06 14:55:31 -07009#include <linux/stddef.h>
10#include <linux/types.h>
Christopher Ferris2abfa9e2021-11-01 16:26:06 -070011#define IOPRIO_CLASS_SHIFT 13
Christopher Ferris8666d042023-09-06 14:55:31 -070012#define IOPRIO_NR_CLASSES 8
13#define IOPRIO_CLASS_MASK (IOPRIO_NR_CLASSES - 1)
Christopher Ferris2abfa9e2021-11-01 16:26:06 -070014#define IOPRIO_PRIO_MASK ((1UL << IOPRIO_CLASS_SHIFT) - 1)
15#define IOPRIO_PRIO_CLASS(ioprio) (((ioprio) >> IOPRIO_CLASS_SHIFT) & IOPRIO_CLASS_MASK)
16#define IOPRIO_PRIO_DATA(ioprio) ((ioprio) & IOPRIO_PRIO_MASK)
Christopher Ferris2abfa9e2021-11-01 16:26:06 -070017enum {
Christopher Ferris8666d042023-09-06 14:55:31 -070018 IOPRIO_CLASS_NONE = 0,
19 IOPRIO_CLASS_RT = 1,
20 IOPRIO_CLASS_BE = 2,
21 IOPRIO_CLASS_IDLE = 3,
22 IOPRIO_CLASS_INVALID = 7,
Christopher Ferris2abfa9e2021-11-01 16:26:06 -070023};
Christopher Ferris8666d042023-09-06 14:55:31 -070024#define IOPRIO_LEVEL_NR_BITS 3
25#define IOPRIO_NR_LEVELS (1 << IOPRIO_LEVEL_NR_BITS)
26#define IOPRIO_LEVEL_MASK (IOPRIO_NR_LEVELS - 1)
27#define IOPRIO_PRIO_LEVEL(ioprio) ((ioprio) & IOPRIO_LEVEL_MASK)
Christopher Ferris2abfa9e2021-11-01 16:26:06 -070028#define IOPRIO_BE_NR IOPRIO_NR_LEVELS
29enum {
30 IOPRIO_WHO_PROCESS = 1,
31 IOPRIO_WHO_PGRP,
32 IOPRIO_WHO_USER,
33};
34#define IOPRIO_NORM 4
35#define IOPRIO_BE_NORM IOPRIO_NORM
Christopher Ferris8666d042023-09-06 14:55:31 -070036#define IOPRIO_HINT_SHIFT IOPRIO_LEVEL_NR_BITS
37#define IOPRIO_HINT_NR_BITS 10
38#define IOPRIO_NR_HINTS (1 << IOPRIO_HINT_NR_BITS)
39#define IOPRIO_HINT_MASK (IOPRIO_NR_HINTS - 1)
40#define IOPRIO_PRIO_HINT(ioprio) (((ioprio) >> IOPRIO_HINT_SHIFT) & IOPRIO_HINT_MASK)
41enum {
42 IOPRIO_HINT_NONE = 0,
43 IOPRIO_HINT_DEV_DURATION_LIMIT_1 = 1,
44 IOPRIO_HINT_DEV_DURATION_LIMIT_2 = 2,
45 IOPRIO_HINT_DEV_DURATION_LIMIT_3 = 3,
46 IOPRIO_HINT_DEV_DURATION_LIMIT_4 = 4,
47 IOPRIO_HINT_DEV_DURATION_LIMIT_5 = 5,
48 IOPRIO_HINT_DEV_DURATION_LIMIT_6 = 6,
49 IOPRIO_HINT_DEV_DURATION_LIMIT_7 = 7,
50};
51#define IOPRIO_BAD_VALUE(val,max) ((val) < 0 || (val) >= (max))
Christopher Ferris67d1e5e2023-10-31 13:36:37 -070052static __always_inline __u16 ioprio_value(int prioclass, int priolevel, int priohint) {
53 if(IOPRIO_BAD_VALUE(prioclass, IOPRIO_NR_CLASSES) || IOPRIO_BAD_VALUE(priolevel, IOPRIO_NR_LEVELS) || IOPRIO_BAD_VALUE(priohint, IOPRIO_NR_HINTS)) return IOPRIO_CLASS_INVALID << IOPRIO_CLASS_SHIFT;
54 return(prioclass << IOPRIO_CLASS_SHIFT) | (priohint << IOPRIO_HINT_SHIFT) | priolevel;
Elliott Hughesb10c99d2023-10-12 23:57:49 +000055}
Christopher Ferris67d1e5e2023-10-31 13:36:37 -070056#define IOPRIO_PRIO_VALUE(prioclass,priolevel) ioprio_value(prioclass, priolevel, IOPRIO_HINT_NONE)
57#define IOPRIO_PRIO_VALUE_HINT(prioclass,priolevel,priohint) ioprio_value(prioclass, priolevel, priohint)
Christopher Ferris2abfa9e2021-11-01 16:26:06 -070058#endif