Neil Horman | 5bc1421 | 2011-11-22 05:10:51 +0000 | [diff] [blame] | 1 | /* |
| 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 Borkmann | 86f8515 | 2013-12-29 17:27:11 +0100 | [diff] [blame] | 16 | |
Neil Horman | 5bc1421 | 2011-11-22 05:10:51 +0000 | [diff] [blame] | 17 | #include <linux/cgroup.h> |
| 18 | #include <linux/hardirq.h> |
| 19 | #include <linux/rcupdate.h> |
| 20 | |
Daniel Borkmann | 86f8515 | 2013-12-29 17:27:11 +0100 | [diff] [blame] | 21 | #if IS_ENABLED(CONFIG_CGROUP_NET_PRIO) |
Neil Horman | 5bc1421 | 2011-11-22 05:10:51 +0000 | [diff] [blame] | 22 | struct netprio_map { |
| 23 | struct rcu_head rcu; |
| 24 | u32 priomap_len; |
| 25 | u32 priomap[]; |
| 26 | }; |
| 27 | |
Joe Perches | 3783072 | 2013-07-31 17:31:39 -0700 | [diff] [blame] | 28 | void sock_update_netprioidx(struct sock *sk); |
Neil Horman | 5bc1421 | 2011-11-22 05:10:51 +0000 | [diff] [blame] | 29 | |
Neil Horman | 2b73bc6 | 2012-02-10 05:43:38 +0000 | [diff] [blame] | 30 | static inline u32 task_netprioidx(struct task_struct *p) |
Neil Horman | 5bc1421 | 2011-11-22 05:10:51 +0000 | [diff] [blame] | 31 | { |
Tejun Heo | 88d642f | 2012-11-22 07:32:47 -0800 | [diff] [blame] | 32 | struct cgroup_subsys_state *css; |
Neil Horman | 2b73bc6 | 2012-02-10 05:43:38 +0000 | [diff] [blame] | 33 | u32 idx; |
| 34 | |
| 35 | rcu_read_lock(); |
Tejun Heo | 073219e | 2014-02-08 10:36:58 -0500 | [diff] [blame] | 36 | css = task_css(p, net_prio_cgrp_id); |
Tejun Heo | 88d642f | 2012-11-22 07:32:47 -0800 | [diff] [blame] | 37 | idx = css->cgroup->id; |
Neil Horman | 2b73bc6 | 2012-02-10 05:43:38 +0000 | [diff] [blame] | 38 | rcu_read_unlock(); |
| 39 | return idx; |
| 40 | } |
Daniel Borkmann | 86f8515 | 2013-12-29 17:27:11 +0100 | [diff] [blame] | 41 | #else /* !CONFIG_CGROUP_NET_PRIO */ |
Neil Horman | 2b73bc6 | 2012-02-10 05:43:38 +0000 | [diff] [blame] | 42 | static inline u32 task_netprioidx(struct task_struct *p) |
| 43 | { |
| 44 | return 0; |
| 45 | } |
| 46 | |
Zefan Li | 6ffd464 | 2013-04-08 20:03:47 +0000 | [diff] [blame] | 47 | #define sock_update_netprioidx(sk) |
Daniel Wagner | 51e4e7f | 2012-09-12 16:12:03 +0200 | [diff] [blame] | 48 | |
Daniel Borkmann | 86f8515 | 2013-12-29 17:27:11 +0100 | [diff] [blame] | 49 | #endif /* CONFIG_CGROUP_NET_PRIO */ |
Neil Horman | 5bc1421 | 2011-11-22 05:10:51 +0000 | [diff] [blame] | 50 | #endif /* _NET_CLS_CGROUP_H */ |