162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef __NET_TC_GACT_H 362306a36Sopenharmony_ci#define __NET_TC_GACT_H 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci#include <net/act_api.h> 662306a36Sopenharmony_ci#include <linux/tc_act/tc_gact.h> 762306a36Sopenharmony_ci 862306a36Sopenharmony_cistruct tcf_gact { 962306a36Sopenharmony_ci struct tc_action common; 1062306a36Sopenharmony_ci#ifdef CONFIG_GACT_PROB 1162306a36Sopenharmony_ci u16 tcfg_ptype; 1262306a36Sopenharmony_ci u16 tcfg_pval; 1362306a36Sopenharmony_ci int tcfg_paction; 1462306a36Sopenharmony_ci atomic_t packets; 1562306a36Sopenharmony_ci#endif 1662306a36Sopenharmony_ci}; 1762306a36Sopenharmony_ci#define to_gact(a) ((struct tcf_gact *)a) 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_cistatic inline bool __is_tcf_gact_act(const struct tc_action *a, int act, 2062306a36Sopenharmony_ci bool is_ext) 2162306a36Sopenharmony_ci{ 2262306a36Sopenharmony_ci#ifdef CONFIG_NET_CLS_ACT 2362306a36Sopenharmony_ci struct tcf_gact *gact; 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci if (a->ops && a->ops->id != TCA_ID_GACT) 2662306a36Sopenharmony_ci return false; 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci gact = to_gact(a); 2962306a36Sopenharmony_ci if ((!is_ext && gact->tcf_action == act) || 3062306a36Sopenharmony_ci (is_ext && TC_ACT_EXT_CMP(gact->tcf_action, act))) 3162306a36Sopenharmony_ci return true; 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci#endif 3462306a36Sopenharmony_ci return false; 3562306a36Sopenharmony_ci} 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_cistatic inline bool is_tcf_gact_ok(const struct tc_action *a) 3862306a36Sopenharmony_ci{ 3962306a36Sopenharmony_ci return __is_tcf_gact_act(a, TC_ACT_OK, false); 4062306a36Sopenharmony_ci} 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_cistatic inline bool is_tcf_gact_shot(const struct tc_action *a) 4362306a36Sopenharmony_ci{ 4462306a36Sopenharmony_ci return __is_tcf_gact_act(a, TC_ACT_SHOT, false); 4562306a36Sopenharmony_ci} 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_cistatic inline bool is_tcf_gact_trap(const struct tc_action *a) 4862306a36Sopenharmony_ci{ 4962306a36Sopenharmony_ci return __is_tcf_gact_act(a, TC_ACT_TRAP, false); 5062306a36Sopenharmony_ci} 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_cistatic inline bool is_tcf_gact_goto_chain(const struct tc_action *a) 5362306a36Sopenharmony_ci{ 5462306a36Sopenharmony_ci return __is_tcf_gact_act(a, TC_ACT_GOTO_CHAIN, true); 5562306a36Sopenharmony_ci} 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_cistatic inline u32 tcf_gact_goto_chain_index(const struct tc_action *a) 5862306a36Sopenharmony_ci{ 5962306a36Sopenharmony_ci return READ_ONCE(a->tcfa_action) & TC_ACT_EXT_VAL_MASK; 6062306a36Sopenharmony_ci} 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_cistatic inline bool is_tcf_gact_continue(const struct tc_action *a) 6362306a36Sopenharmony_ci{ 6462306a36Sopenharmony_ci return __is_tcf_gact_act(a, TC_ACT_UNSPEC, false); 6562306a36Sopenharmony_ci} 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_cistatic inline bool is_tcf_gact_reclassify(const struct tc_action *a) 6862306a36Sopenharmony_ci{ 6962306a36Sopenharmony_ci return __is_tcf_gact_act(a, TC_ACT_RECLASSIFY, false); 7062306a36Sopenharmony_ci} 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_cistatic inline bool is_tcf_gact_pipe(const struct tc_action *a) 7362306a36Sopenharmony_ci{ 7462306a36Sopenharmony_ci return __is_tcf_gact_act(a, TC_ACT_PIPE, false); 7562306a36Sopenharmony_ci} 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_ci#endif /* __NET_TC_GACT_H */ 78