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