netprio_cgroup.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #ifndef _NETPRIO_CGROUP_H
  14. #define _NETPRIO_CGROUP_H
  15. #include <linux/module.h>
  16. #include <linux/cgroup.h>
  17. #include <linux/hardirq.h>
  18. #include <linux/rcupdate.h>
  19. struct cgroup_netprio_state
  20. {
  21. struct cgroup_subsys_state css;
  22. u32 prioidx;
  23. };
  24. struct netprio_map {
  25. struct rcu_head rcu;
  26. u32 priomap_len;
  27. u32 priomap[];
  28. };
  29. #ifdef CONFIG_CGROUPS
  30. #ifndef CONFIG_NETPRIO_CGROUP
  31. extern int net_prio_subsys_id;
  32. #endif
  33. extern void sock_update_netprioidx(struct sock *sk);
  34. static inline struct cgroup_netprio_state
  35. *task_netprio_state(struct task_struct *p)
  36. {
  37. #if IS_ENABLED(CONFIG_NETPRIO_CGROUP)
  38. return container_of(task_subsys_state(p, net_prio_subsys_id),
  39. struct cgroup_netprio_state, css);
  40. #else
  41. return NULL;
  42. #endif
  43. }
  44. #else
  45. #define sock_update_netprioidx(sk)
  46. #define skb_update_prio(skb)
  47. static inline struct cgroup_netprio_state
  48. *task_netprio_state(struct task_struct *p)
  49. {
  50. return NULL;
  51. }
  52. #endif
  53. #endif /* _NET_CLS_CGROUP_H */