Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (c) 2008, Intel Corporation.
0004  *
0005  * Author: Alexander Duyck <alexander.h.duyck@intel.com>
0006  */
0007 
0008 #ifndef __NET_TC_SKBEDIT_H
0009 #define __NET_TC_SKBEDIT_H
0010 
0011 #include <net/act_api.h>
0012 #include <linux/tc_act/tc_skbedit.h>
0013 
0014 struct tcf_skbedit_params {
0015     u32 flags;
0016     u32 priority;
0017     u32 mark;
0018     u32 mask;
0019     u16 queue_mapping;
0020     u16 mapping_mod;
0021     u16 ptype;
0022     struct rcu_head rcu;
0023 };
0024 
0025 struct tcf_skbedit {
0026     struct tc_action common;
0027     struct tcf_skbedit_params __rcu *params;
0028 };
0029 #define to_skbedit(a) ((struct tcf_skbedit *)a)
0030 
0031 /* Return true iff action is the one identified by FLAG. */
0032 static inline bool is_tcf_skbedit_with_flag(const struct tc_action *a, u32 flag)
0033 {
0034 #ifdef CONFIG_NET_CLS_ACT
0035     u32 flags;
0036 
0037     if (a->ops && a->ops->id == TCA_ID_SKBEDIT) {
0038         rcu_read_lock();
0039         flags = rcu_dereference(to_skbedit(a)->params)->flags;
0040         rcu_read_unlock();
0041         return flags == flag;
0042     }
0043 #endif
0044     return false;
0045 }
0046 
0047 /* Return true iff action is mark */
0048 static inline bool is_tcf_skbedit_mark(const struct tc_action *a)
0049 {
0050     return is_tcf_skbedit_with_flag(a, SKBEDIT_F_MARK);
0051 }
0052 
0053 static inline u32 tcf_skbedit_mark(const struct tc_action *a)
0054 {
0055     u32 mark;
0056 
0057     rcu_read_lock();
0058     mark = rcu_dereference(to_skbedit(a)->params)->mark;
0059     rcu_read_unlock();
0060 
0061     return mark;
0062 }
0063 
0064 /* Return true iff action is ptype */
0065 static inline bool is_tcf_skbedit_ptype(const struct tc_action *a)
0066 {
0067     return is_tcf_skbedit_with_flag(a, SKBEDIT_F_PTYPE);
0068 }
0069 
0070 static inline u32 tcf_skbedit_ptype(const struct tc_action *a)
0071 {
0072     u16 ptype;
0073 
0074     rcu_read_lock();
0075     ptype = rcu_dereference(to_skbedit(a)->params)->ptype;
0076     rcu_read_unlock();
0077 
0078     return ptype;
0079 }
0080 
0081 /* Return true iff action is priority */
0082 static inline bool is_tcf_skbedit_priority(const struct tc_action *a)
0083 {
0084     return is_tcf_skbedit_with_flag(a, SKBEDIT_F_PRIORITY);
0085 }
0086 
0087 static inline u32 tcf_skbedit_priority(const struct tc_action *a)
0088 {
0089     u32 priority;
0090 
0091     rcu_read_lock();
0092     priority = rcu_dereference(to_skbedit(a)->params)->priority;
0093     rcu_read_unlock();
0094 
0095     return priority;
0096 }
0097 
0098 /* Return true iff action is queue_mapping */
0099 static inline bool is_tcf_skbedit_queue_mapping(const struct tc_action *a)
0100 {
0101     return is_tcf_skbedit_with_flag(a, SKBEDIT_F_QUEUE_MAPPING);
0102 }
0103 
0104 /* Return true iff action is inheritdsfield */
0105 static inline bool is_tcf_skbedit_inheritdsfield(const struct tc_action *a)
0106 {
0107     return is_tcf_skbedit_with_flag(a, SKBEDIT_F_INHERITDSFIELD);
0108 }
0109 
0110 #endif /* __NET_TC_SKBEDIT_H */