Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __NET_TC_PED_H
0003 #define __NET_TC_PED_H
0004 
0005 #include <net/act_api.h>
0006 #include <linux/tc_act/tc_pedit.h>
0007 
0008 struct tcf_pedit_key_ex {
0009     enum pedit_header_type htype;
0010     enum pedit_cmd cmd;
0011 };
0012 
0013 struct tcf_pedit {
0014     struct tc_action    common;
0015     unsigned char       tcfp_nkeys;
0016     unsigned char       tcfp_flags;
0017     u32         tcfp_off_max_hint;
0018     struct tc_pedit_key *tcfp_keys;
0019     struct tcf_pedit_key_ex *tcfp_keys_ex;
0020 };
0021 
0022 #define to_pedit(a) ((struct tcf_pedit *)a)
0023 
0024 static inline bool is_tcf_pedit(const struct tc_action *a)
0025 {
0026 #ifdef CONFIG_NET_CLS_ACT
0027     if (a->ops && a->ops->id == TCA_ID_PEDIT)
0028         return true;
0029 #endif
0030     return false;
0031 }
0032 
0033 static inline int tcf_pedit_nkeys(const struct tc_action *a)
0034 {
0035     return to_pedit(a)->tcfp_nkeys;
0036 }
0037 
0038 static inline u32 tcf_pedit_htype(const struct tc_action *a, int index)
0039 {
0040     if (to_pedit(a)->tcfp_keys_ex)
0041         return to_pedit(a)->tcfp_keys_ex[index].htype;
0042 
0043     return TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK;
0044 }
0045 
0046 static inline u32 tcf_pedit_cmd(const struct tc_action *a, int index)
0047 {
0048     if (to_pedit(a)->tcfp_keys_ex)
0049         return to_pedit(a)->tcfp_keys_ex[index].cmd;
0050 
0051     return __PEDIT_CMD_MAX;
0052 }
0053 
0054 static inline u32 tcf_pedit_mask(const struct tc_action *a, int index)
0055 {
0056     return to_pedit(a)->tcfp_keys[index].mask;
0057 }
0058 
0059 static inline u32 tcf_pedit_val(const struct tc_action *a, int index)
0060 {
0061     return to_pedit(a)->tcfp_keys[index].val;
0062 }
0063 
0064 static inline u32 tcf_pedit_offset(const struct tc_action *a, int index)
0065 {
0066     return to_pedit(a)->tcfp_keys[index].off;
0067 }
0068 #endif /* __NET_TC_PED_H */