blob: dec7522b6ce1c80ff186278dc412814d304a12b4 [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Neil Horman5bc14212011-11-22 05:10:51 +00002/*
3 * netprio_cgroup.h Control Group Priority set
4 *
Neil Horman5bc14212011-11-22 05:10:51 +00005 * Authors: Neil Horman <nhorman@tuxdriver.com>
Neil Horman5bc14212011-11-22 05:10:51 +00006 */
7
8#ifndef _NETPRIO_CGROUP_H
9#define _NETPRIO_CGROUP_H
Daniel Borkmann86f85152013-12-29 17:27:11 +010010
Neil Horman5bc14212011-11-22 05:10:51 +000011#include <linux/cgroup.h>
12#include <linux/hardirq.h>
13#include <linux/rcupdate.h>
14
Daniel Borkmann86f85152013-12-29 17:27:11 +010015#if IS_ENABLED(CONFIG_CGROUP_NET_PRIO)
Neil Horman5bc14212011-11-22 05:10:51 +000016struct netprio_map {
17 struct rcu_head rcu;
18 u32 priomap_len;
19 u32 priomap[];
20};
21
Neil Horman2b73bc62012-02-10 05:43:38 +000022static inline u32 task_netprioidx(struct task_struct *p)
Neil Horman5bc14212011-11-22 05:10:51 +000023{
Tejun Heo88d642f2012-11-22 07:32:47 -080024 struct cgroup_subsys_state *css;
Neil Horman2b73bc62012-02-10 05:43:38 +000025 u32 idx;
26
27 rcu_read_lock();
Tejun Heo073219e2014-02-08 10:36:58 -050028 css = task_css(p, net_prio_cgrp_id);
Tejun Heodb53c732019-11-04 15:54:29 -080029 idx = css->id;
Neil Horman2b73bc62012-02-10 05:43:38 +000030 rcu_read_unlock();
31 return idx;
32}
Tejun Heo2a56a1f2015-12-07 17:38:52 -050033
34static inline void sock_update_netprioidx(struct sock_cgroup_data *skcd)
35{
36 if (in_interrupt())
37 return;
38
39 sock_cgroup_set_prioidx(skcd, task_netprioidx(current));
40}
41
Daniel Borkmann86f85152013-12-29 17:27:11 +010042#else /* !CONFIG_CGROUP_NET_PRIO */
Tejun Heo2a56a1f2015-12-07 17:38:52 -050043
Neil Horman2b73bc62012-02-10 05:43:38 +000044static inline u32 task_netprioidx(struct task_struct *p)
45{
46 return 0;
47}
48
Tejun Heo2a56a1f2015-12-07 17:38:52 -050049static inline void sock_update_netprioidx(struct sock_cgroup_data *skcd)
50{
51}
Daniel Wagner51e4e7f2012-09-12 16:12:03 +020052
Daniel Borkmann86f85152013-12-29 17:27:11 +010053#endif /* CONFIG_CGROUP_NET_PRIO */
Neil Horman5bc14212011-11-22 05:10:51 +000054#endif /* _NET_CLS_CGROUP_H */