162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef __NET_TC_IFE_H 362306a36Sopenharmony_ci#define __NET_TC_IFE_H 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci#include <net/act_api.h> 662306a36Sopenharmony_ci#include <linux/etherdevice.h> 762306a36Sopenharmony_ci#include <linux/rtnetlink.h> 862306a36Sopenharmony_ci 962306a36Sopenharmony_cistruct module; 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_cistruct tcf_ife_params { 1262306a36Sopenharmony_ci u8 eth_dst[ETH_ALEN]; 1362306a36Sopenharmony_ci u8 eth_src[ETH_ALEN]; 1462306a36Sopenharmony_ci u16 eth_type; 1562306a36Sopenharmony_ci u16 flags; 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci struct rcu_head rcu; 1862306a36Sopenharmony_ci}; 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_cistruct tcf_ife_info { 2162306a36Sopenharmony_ci struct tc_action common; 2262306a36Sopenharmony_ci struct tcf_ife_params __rcu *params; 2362306a36Sopenharmony_ci /* list of metaids allowed */ 2462306a36Sopenharmony_ci struct list_head metalist; 2562306a36Sopenharmony_ci}; 2662306a36Sopenharmony_ci#define to_ife(a) ((struct tcf_ife_info *)a) 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_cistruct tcf_meta_info { 2962306a36Sopenharmony_ci const struct tcf_meta_ops *ops; 3062306a36Sopenharmony_ci void *metaval; 3162306a36Sopenharmony_ci u16 metaid; 3262306a36Sopenharmony_ci struct list_head metalist; 3362306a36Sopenharmony_ci}; 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_cistruct tcf_meta_ops { 3662306a36Sopenharmony_ci u16 metaid; /*Maintainer provided ID */ 3762306a36Sopenharmony_ci u16 metatype; /*netlink attribute type (look at net/netlink.h) */ 3862306a36Sopenharmony_ci const char *name; 3962306a36Sopenharmony_ci const char *synopsis; 4062306a36Sopenharmony_ci struct list_head list; 4162306a36Sopenharmony_ci int (*check_presence)(struct sk_buff *, struct tcf_meta_info *); 4262306a36Sopenharmony_ci int (*encode)(struct sk_buff *, void *, struct tcf_meta_info *); 4362306a36Sopenharmony_ci int (*decode)(struct sk_buff *, void *, u16 len); 4462306a36Sopenharmony_ci int (*get)(struct sk_buff *skb, struct tcf_meta_info *mi); 4562306a36Sopenharmony_ci int (*alloc)(struct tcf_meta_info *, void *, gfp_t); 4662306a36Sopenharmony_ci void (*release)(struct tcf_meta_info *); 4762306a36Sopenharmony_ci int (*validate)(void *val, int len); 4862306a36Sopenharmony_ci struct module *owner; 4962306a36Sopenharmony_ci}; 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ci#define MODULE_ALIAS_IFE_META(metan) MODULE_ALIAS("ife-meta-" metan) 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_ciint ife_get_meta_u32(struct sk_buff *skb, struct tcf_meta_info *mi); 5462306a36Sopenharmony_ciint ife_get_meta_u16(struct sk_buff *skb, struct tcf_meta_info *mi); 5562306a36Sopenharmony_ciint ife_alloc_meta_u32(struct tcf_meta_info *mi, void *metaval, gfp_t gfp); 5662306a36Sopenharmony_ciint ife_alloc_meta_u16(struct tcf_meta_info *mi, void *metaval, gfp_t gfp); 5762306a36Sopenharmony_ciint ife_check_meta_u32(u32 metaval, struct tcf_meta_info *mi); 5862306a36Sopenharmony_ciint ife_check_meta_u16(u16 metaval, struct tcf_meta_info *mi); 5962306a36Sopenharmony_ciint ife_encode_meta_u32(u32 metaval, void *skbdata, struct tcf_meta_info *mi); 6062306a36Sopenharmony_ciint ife_validate_meta_u32(void *val, int len); 6162306a36Sopenharmony_ciint ife_validate_meta_u16(void *val, int len); 6262306a36Sopenharmony_ciint ife_encode_meta_u16(u16 metaval, void *skbdata, struct tcf_meta_info *mi); 6362306a36Sopenharmony_civoid ife_release_meta_gen(struct tcf_meta_info *mi); 6462306a36Sopenharmony_ciint register_ife_op(struct tcf_meta_ops *mops); 6562306a36Sopenharmony_ciint unregister_ife_op(struct tcf_meta_ops *mops); 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci#endif /* __NET_TC_IFE_H */ 68