blob: f2a9597ff53c089cb3aa4a810e6286355c9f194c [file] [log] [blame]
Neil Horman5bc14212011-11-22 05:10:51 +00001/*
2 * netprio_cgroup.h Control Group Priority set
3 *
4 *
5 * Authors: Neil Horman <nhorman@tuxdriver.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free
9 * Software Foundation; either version 2 of the License, or (at your option)
10 * any later version.
11 *
12 */
13
14#ifndef _NETPRIO_CGROUP_H
15#define _NETPRIO_CGROUP_H
Daniel Borkmann86f85152013-12-29 17:27:11 +010016
Neil Horman5bc14212011-11-22 05:10:51 +000017#include <linux/cgroup.h>
18#include <linux/hardirq.h>
19#include <linux/rcupdate.h>
20
Daniel Borkmann86f85152013-12-29 17:27:11 +010021#if IS_ENABLED(CONFIG_CGROUP_NET_PRIO)
Neil Horman5bc14212011-11-22 05:10:51 +000022struct netprio_map {
23 struct rcu_head rcu;
24 u32 priomap_len;
25 u32 priomap[];
26};
27
Joe Perches37830722013-07-31 17:31:39 -070028void sock_update_netprioidx(struct sock *sk);
Neil Horman5bc14212011-11-22 05:10:51 +000029
Neil Horman2b73bc62012-02-10 05:43:38 +000030static inline u32 task_netprioidx(struct task_struct *p)
Neil Horman5bc14212011-11-22 05:10:51 +000031{
Tejun Heo88d642f2012-11-22 07:32:47 -080032 struct cgroup_subsys_state *css;
Neil Horman2b73bc62012-02-10 05:43:38 +000033 u32 idx;
34
35 rcu_read_lock();
Tejun Heo073219e2014-02-08 10:36:58 -050036 css = task_css(p, net_prio_cgrp_id);
Tejun Heo88d642f2012-11-22 07:32:47 -080037 idx = css->cgroup->id;
Neil Horman2b73bc62012-02-10 05:43:38 +000038 rcu_read_unlock();
39 return idx;
40}
Daniel Borkmann86f85152013-12-29 17:27:11 +010041#else /* !CONFIG_CGROUP_NET_PRIO */
Neil Horman2b73bc62012-02-10 05:43:38 +000042static inline u32 task_netprioidx(struct task_struct *p)
43{
44 return 0;
45}
46
Zefan Li6ffd4642013-04-08 20:03:47 +000047#define sock_update_netprioidx(sk)
Daniel Wagner51e4e7f2012-09-12 16:12:03 +020048
Daniel Borkmann86f85152013-12-29 17:27:11 +010049#endif /* CONFIG_CGROUP_NET_PRIO */
Neil Horman5bc14212011-11-22 05:10:51 +000050#endif /* _NET_CLS_CGROUP_H */