2019-05-28 10:10:04 -07:00
/* SPDX-License-Identifier: GPL-2.0-only */
2008-09-12 16:30:20 -07:00
/*
* Copyright ( c ) 2008 , Intel Corporation .
*
* Author : Alexander Duyck < alexander . h . duyck @ intel . com >
*/
# ifndef __NET_TC_SKBEDIT_H
# define __NET_TC_SKBEDIT_H
# include <net/act_api.h>
2016-03-08 12:42:32 +02:00
# include <linux/tc_act/tc_skbedit.h>
2008-09-12 16:30:20 -07:00
2018-07-11 16:04:50 +02:00
struct tcf_skbedit_params {
u32 flags ;
u32 priority ;
u32 mark ;
u32 mask ;
u16 queue_mapping ;
u16 ptype ;
struct rcu_head rcu ;
} ;
2008-09-12 16:30:20 -07:00
struct tcf_skbedit {
2018-07-11 16:04:50 +02:00
struct tc_action common ;
struct tcf_skbedit_params __rcu * params ;
2008-09-12 16:30:20 -07:00
} ;
2016-07-25 16:09:41 -07:00
# define to_skbedit(a) ((struct tcf_skbedit *)a)
2008-09-12 16:30:20 -07:00
2020-03-19 15:47:20 +02:00
/* Return true iff action is the one identified by FLAG. */
static inline bool is_tcf_skbedit_with_flag ( const struct tc_action * a , u32 flag )
2016-03-08 12:42:32 +02:00
{
# ifdef CONFIG_NET_CLS_ACT
2018-07-11 16:04:50 +02:00
u32 flags ;
2019-02-10 14:25:00 +02:00
if ( a - > ops & & a - > ops - > id = = TCA_ID_SKBEDIT ) {
2018-07-11 16:04:50 +02:00
rcu_read_lock ( ) ;
flags = rcu_dereference ( to_skbedit ( a ) - > params ) - > flags ;
rcu_read_unlock ( ) ;
2020-03-19 15:47:20 +02:00
return flags = = flag ;
2018-07-11 16:04:50 +02:00
}
2016-03-08 12:42:32 +02:00
# endif
return false ;
}
2020-03-19 15:47:20 +02:00
/* Return true iff action is mark */
static inline bool is_tcf_skbedit_mark ( const struct tc_action * a )
{
return is_tcf_skbedit_with_flag ( a , SKBEDIT_F_MARK ) ;
}
2016-03-08 12:42:32 +02:00
static inline u32 tcf_skbedit_mark ( const struct tc_action * a )
{
2018-07-11 16:04:50 +02:00
u32 mark ;
rcu_read_lock ( ) ;
mark = rcu_dereference ( to_skbedit ( a ) - > params ) - > mark ;
rcu_read_unlock ( ) ;
return mark ;
2016-03-08 12:42:32 +02:00
}
2019-08-04 16:09:03 +01:00
/* Return true iff action is ptype */
static inline bool is_tcf_skbedit_ptype ( const struct tc_action * a )
{
2020-03-19 15:47:20 +02:00
return is_tcf_skbedit_with_flag ( a , SKBEDIT_F_PTYPE ) ;
2019-08-04 16:09:03 +01:00
}
static inline u32 tcf_skbedit_ptype ( const struct tc_action * a )
{
u16 ptype ;
rcu_read_lock ( ) ;
ptype = rcu_dereference ( to_skbedit ( a ) - > params ) - > ptype ;
rcu_read_unlock ( ) ;
return ptype ;
}
2020-03-19 15:47:21 +02:00
/* Return true iff action is priority */
static inline bool is_tcf_skbedit_priority ( const struct tc_action * a )
{
return is_tcf_skbedit_with_flag ( a , SKBEDIT_F_PRIORITY ) ;
}
static inline u32 tcf_skbedit_priority ( const struct tc_action * a )
{
u32 priority ;
rcu_read_lock ( ) ;
priority = rcu_dereference ( to_skbedit ( a ) - > params ) - > priority ;
rcu_read_unlock ( ) ;
return priority ;
}
2008-09-12 16:30:20 -07:00
# endif /* __NET_TC_SKBEDIT_H */