tc_mpls.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
  2. /* Copyright (C) 2019 Netronome Systems, Inc. */
  3. #ifndef __NET_TC_MPLS_H
  4. #define __NET_TC_MPLS_H
  5. #include <linux/tc_act/tc_mpls.h>
  6. #include <net/act_api.h>
  7. struct tcf_mpls_params {
  8. int tcfm_action;
  9. u32 tcfm_label;
  10. u8 tcfm_tc;
  11. u8 tcfm_ttl;
  12. u8 tcfm_bos;
  13. __be16 tcfm_proto;
  14. struct rcu_head rcu;
  15. };
  16. #define ACT_MPLS_TC_NOT_SET 0xff
  17. #define ACT_MPLS_BOS_NOT_SET 0xff
  18. #define ACT_MPLS_LABEL_NOT_SET 0xffffffff
  19. struct tcf_mpls {
  20. struct tc_action common;
  21. struct tcf_mpls_params __rcu *mpls_p;
  22. };
  23. #define to_mpls(a) ((struct tcf_mpls *)a)
  24. static inline bool is_tcf_mpls(const struct tc_action *a)
  25. {
  26. #ifdef CONFIG_NET_CLS_ACT
  27. if (a->ops && a->ops->id == TCA_ID_MPLS)
  28. return true;
  29. #endif
  30. return false;
  31. }
  32. static inline u32 tcf_mpls_action(const struct tc_action *a)
  33. {
  34. u32 tcfm_action;
  35. rcu_read_lock();
  36. tcfm_action = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_action;
  37. rcu_read_unlock();
  38. return tcfm_action;
  39. }
  40. static inline __be16 tcf_mpls_proto(const struct tc_action *a)
  41. {
  42. __be16 tcfm_proto;
  43. rcu_read_lock();
  44. tcfm_proto = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_proto;
  45. rcu_read_unlock();
  46. return tcfm_proto;
  47. }
  48. static inline u32 tcf_mpls_label(const struct tc_action *a)
  49. {
  50. u32 tcfm_label;
  51. rcu_read_lock();
  52. tcfm_label = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_label;
  53. rcu_read_unlock();
  54. return tcfm_label;
  55. }
  56. static inline u8 tcf_mpls_tc(const struct tc_action *a)
  57. {
  58. u8 tcfm_tc;
  59. rcu_read_lock();
  60. tcfm_tc = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_tc;
  61. rcu_read_unlock();
  62. return tcfm_tc;
  63. }
  64. static inline u8 tcf_mpls_bos(const struct tc_action *a)
  65. {
  66. u8 tcfm_bos;
  67. rcu_read_lock();
  68. tcfm_bos = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_bos;
  69. rcu_read_unlock();
  70. return tcfm_bos;
  71. }
  72. static inline u8 tcf_mpls_ttl(const struct tc_action *a)
  73. {
  74. u8 tcfm_ttl;
  75. rcu_read_lock();
  76. tcfm_ttl = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_ttl;
  77. rcu_read_unlock();
  78. return tcfm_ttl;
  79. }
  80. #endif /* __NET_TC_MPLS_H */