b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | /* |
| 3 | * Copyright (c) 2014 Jiri Pirko <jiri@resnulli.us> |
| 4 | */ |
| 5 | |
| 6 | #ifndef __NET_TC_VLAN_H |
| 7 | #define __NET_TC_VLAN_H |
| 8 | |
| 9 | #include <net/act_api.h> |
| 10 | #include <linux/tc_act/tc_vlan.h> |
| 11 | |
| 12 | struct tcf_vlan_params { |
| 13 | int tcfv_action; |
| 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 | |
| 21 | struct tcf_vlan { |
| 22 | struct tc_action common; |
| 23 | struct tcf_vlan_params __rcu *vlan_p; |
| 24 | }; |
| 25 | #define to_vlan(a) ((struct tcf_vlan *)a) |
| 26 | |
| 27 | static inline bool is_tcf_vlan(const struct tc_action *a) |
| 28 | { |
| 29 | #ifdef CONFIG_NET_CLS_ACT |
| 30 | if (a->ops && a->ops->id == TCA_ID_VLAN) |
| 31 | return true; |
| 32 | #endif |
| 33 | return false; |
| 34 | } |
| 35 | |
| 36 | static inline u32 tcf_vlan_action(const struct tc_action *a) |
| 37 | { |
| 38 | u32 tcfv_action; |
| 39 | |
| 40 | rcu_read_lock(); |
| 41 | tcfv_action = rcu_dereference(to_vlan(a)->vlan_p)->tcfv_action; |
| 42 | rcu_read_unlock(); |
| 43 | |
| 44 | return tcfv_action; |
| 45 | } |
| 46 | |
| 47 | static inline u16 tcf_vlan_push_vid(const struct tc_action *a) |
| 48 | { |
| 49 | u16 tcfv_push_vid; |
| 50 | |
| 51 | rcu_read_lock(); |
| 52 | tcfv_push_vid = rcu_dereference(to_vlan(a)->vlan_p)->tcfv_push_vid; |
| 53 | rcu_read_unlock(); |
| 54 | |
| 55 | return tcfv_push_vid; |
| 56 | } |
| 57 | |
| 58 | static inline __be16 tcf_vlan_push_proto(const struct tc_action *a) |
| 59 | { |
| 60 | __be16 tcfv_push_proto; |
| 61 | |
| 62 | rcu_read_lock(); |
| 63 | tcfv_push_proto = rcu_dereference(to_vlan(a)->vlan_p)->tcfv_push_proto; |
| 64 | rcu_read_unlock(); |
| 65 | |
| 66 | return tcfv_push_proto; |
| 67 | } |
| 68 | |
| 69 | static inline u8 tcf_vlan_push_prio(const struct tc_action *a) |
| 70 | { |
| 71 | u8 tcfv_push_prio; |
| 72 | |
| 73 | rcu_read_lock(); |
| 74 | tcfv_push_prio = rcu_dereference(to_vlan(a)->vlan_p)->tcfv_push_prio; |
| 75 | rcu_read_unlock(); |
| 76 | |
| 77 | return tcfv_push_prio; |
| 78 | } |
| 79 | #endif /* __NET_TC_VLAN_H */ |