tc_vlan.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright (c) 2014 Jiri Pirko <jiri@resnulli.us>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. */
  9. #ifndef __NET_TC_VLAN_H
  10. #define __NET_TC_VLAN_H
  11. #include <net/act_api.h>
  12. #include <linux/tc_act/tc_vlan.h>
  13. struct tcf_vlan_params {
  14. int tcfv_action;
  15. u16 tcfv_push_vid;
  16. __be16 tcfv_push_proto;
  17. u8 tcfv_push_prio;
  18. struct rcu_head rcu;
  19. };
  20. struct tcf_vlan {
  21. struct tc_action common;
  22. struct tcf_vlan_params __rcu *vlan_p;
  23. };
  24. #define to_vlan(a) ((struct tcf_vlan *)a)
  25. static inline bool is_tcf_vlan(const struct tc_action *a)
  26. {
  27. #ifdef CONFIG_NET_CLS_ACT
  28. if (a->ops && a->ops->type == TCA_ACT_VLAN)
  29. return true;
  30. #endif
  31. return false;
  32. }
  33. static inline u32 tcf_vlan_action(const struct tc_action *a)
  34. {
  35. u32 tcfv_action;
  36. rcu_read_lock();
  37. tcfv_action = rcu_dereference(to_vlan(a)->vlan_p)->tcfv_action;
  38. rcu_read_unlock();
  39. return tcfv_action;
  40. }
  41. static inline u16 tcf_vlan_push_vid(const struct tc_action *a)
  42. {
  43. u16 tcfv_push_vid;
  44. rcu_read_lock();
  45. tcfv_push_vid = rcu_dereference(to_vlan(a)->vlan_p)->tcfv_push_vid;
  46. rcu_read_unlock();
  47. return tcfv_push_vid;
  48. }
  49. static inline __be16 tcf_vlan_push_proto(const struct tc_action *a)
  50. {
  51. __be16 tcfv_push_proto;
  52. rcu_read_lock();
  53. tcfv_push_proto = rcu_dereference(to_vlan(a)->vlan_p)->tcfv_push_proto;
  54. rcu_read_unlock();
  55. return tcfv_push_proto;
  56. }
  57. static inline u8 tcf_vlan_push_prio(const struct tc_action *a)
  58. {
  59. u8 tcfv_push_prio;
  60. rcu_read_lock();
  61. tcfv_push_prio = rcu_dereference(to_vlan(a)->vlan_p)->tcfv_push_prio;
  62. rcu_read_unlock();
  63. return tcfv_push_prio;
  64. }
  65. #endif /* __NET_TC_VLAN_H */