Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __NET_TC_GACT_H
0003 #define __NET_TC_GACT_H
0004 
0005 #include <net/act_api.h>
0006 #include <linux/tc_act/tc_gact.h>
0007 
0008 struct tcf_gact {
0009     struct tc_action    common;
0010 #ifdef CONFIG_GACT_PROB
0011     u16         tcfg_ptype;
0012     u16         tcfg_pval;
0013     int         tcfg_paction;
0014     atomic_t        packets;
0015 #endif
0016 };
0017 #define to_gact(a) ((struct tcf_gact *)a)
0018 
0019 static inline bool __is_tcf_gact_act(const struct tc_action *a, int act,
0020                      bool is_ext)
0021 {
0022 #ifdef CONFIG_NET_CLS_ACT
0023     struct tcf_gact *gact;
0024 
0025     if (a->ops && a->ops->id != TCA_ID_GACT)
0026         return false;
0027 
0028     gact = to_gact(a);
0029     if ((!is_ext && gact->tcf_action == act) ||
0030         (is_ext && TC_ACT_EXT_CMP(gact->tcf_action, act)))
0031         return true;
0032 
0033 #endif
0034     return false;
0035 }
0036 
0037 static inline bool is_tcf_gact_ok(const struct tc_action *a)
0038 {
0039     return __is_tcf_gact_act(a, TC_ACT_OK, false);
0040 }
0041 
0042 static inline bool is_tcf_gact_shot(const struct tc_action *a)
0043 {
0044     return __is_tcf_gact_act(a, TC_ACT_SHOT, false);
0045 }
0046 
0047 static inline bool is_tcf_gact_trap(const struct tc_action *a)
0048 {
0049     return __is_tcf_gact_act(a, TC_ACT_TRAP, false);
0050 }
0051 
0052 static inline bool is_tcf_gact_goto_chain(const struct tc_action *a)
0053 {
0054     return __is_tcf_gact_act(a, TC_ACT_GOTO_CHAIN, true);
0055 }
0056 
0057 static inline u32 tcf_gact_goto_chain_index(const struct tc_action *a)
0058 {
0059     return READ_ONCE(a->tcfa_action) & TC_ACT_EXT_VAL_MASK;
0060 }
0061 
0062 static inline bool is_tcf_gact_continue(const struct tc_action *a)
0063 {
0064     return __is_tcf_gact_act(a, TC_ACT_UNSPEC, false);
0065 }
0066 
0067 static inline bool is_tcf_gact_reclassify(const struct tc_action *a)
0068 {
0069     return __is_tcf_gact_act(a, TC_ACT_RECLASSIFY, false);
0070 }
0071 
0072 static inline bool is_tcf_gact_pipe(const struct tc_action *a)
0073 {
0074     return __is_tcf_gact_act(a, TC_ACT_PIPE, false);
0075 }
0076 
0077 #endif /* __NET_TC_GACT_H */