tc_vlan.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright (c) 2014 Jiri Pirko <jiri@resnulli.us>
  4. */
  5. #ifndef __NET_TC_VLAN_H
  6. #define __NET_TC_VLAN_H
  7. #include <net/act_api.h>
  8. #include <linux/tc_act/tc_vlan.h>
  9. struct tcf_vlan_params {
  10. int action;
  11. int tcfv_action;
  12. unsigned char tcfv_push_dst[ETH_ALEN];
  13. unsigned char tcfv_push_src[ETH_ALEN];
  14. u16 tcfv_push_vid;
  15. __be16 tcfv_push_proto;
  16. u8 tcfv_push_prio;
  17. bool tcfv_push_prio_exists;
  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 u32 tcf_vlan_action(const struct tc_action *a)
  26. {
  27. u32 tcfv_action;
  28. rcu_read_lock();
  29. tcfv_action = rcu_dereference(to_vlan(a)->vlan_p)->tcfv_action;
  30. rcu_read_unlock();
  31. return tcfv_action;
  32. }
  33. static inline u16 tcf_vlan_push_vid(const struct tc_action *a)
  34. {
  35. u16 tcfv_push_vid;
  36. rcu_read_lock();
  37. tcfv_push_vid = rcu_dereference(to_vlan(a)->vlan_p)->tcfv_push_vid;
  38. rcu_read_unlock();
  39. return tcfv_push_vid;
  40. }
  41. static inline __be16 tcf_vlan_push_proto(const struct tc_action *a)
  42. {
  43. __be16 tcfv_push_proto;
  44. rcu_read_lock();
  45. tcfv_push_proto = rcu_dereference(to_vlan(a)->vlan_p)->tcfv_push_proto;
  46. rcu_read_unlock();
  47. return tcfv_push_proto;
  48. }
  49. static inline u8 tcf_vlan_push_prio(const struct tc_action *a)
  50. {
  51. u8 tcfv_push_prio;
  52. rcu_read_lock();
  53. tcfv_push_prio = rcu_dereference(to_vlan(a)->vlan_p)->tcfv_push_prio;
  54. rcu_read_unlock();
  55. return tcfv_push_prio;
  56. }
  57. static inline void tcf_vlan_push_eth(unsigned char *src, unsigned char *dest,
  58. const struct tc_action *a)
  59. {
  60. rcu_read_lock();
  61. memcpy(dest, rcu_dereference(to_vlan(a)->vlan_p)->tcfv_push_dst, ETH_ALEN);
  62. memcpy(src, rcu_dereference(to_vlan(a)->vlan_p)->tcfv_push_src, ETH_ALEN);
  63. rcu_read_unlock();
  64. }
  65. #endif /* __NET_TC_VLAN_H */