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;
|
2022-04-16 00:40:46 +08:00
|
|
|
u16 mapping_mod;
|
2018-07-11 16:04:50 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2022-10-21 00:58:39 -07:00
|
|
|
static inline u16 tcf_skbedit_rx_queue_mapping(const struct tc_action *a)
|
|
|
|
{
|
|
|
|
u16 rx_queue;
|
|
|
|
|
|
|
|
rcu_read_lock();
|
|
|
|
rx_queue = rcu_dereference(to_skbedit(a)->params)->queue_mapping;
|
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
|
|
return rx_queue;
|
|
|
|
}
|
|
|
|
|
2022-04-07 10:35:28 +03:00
|
|
|
/* Return true iff action is queue_mapping */
|
|
|
|
static inline bool is_tcf_skbedit_queue_mapping(const struct tc_action *a)
|
|
|
|
{
|
|
|
|
return is_tcf_skbedit_with_flag(a, SKBEDIT_F_QUEUE_MAPPING);
|
|
|
|
}
|
|
|
|
|
2022-10-21 00:58:39 -07:00
|
|
|
/* Return true if action is on ingress traffic */
|
|
|
|
static inline bool is_tcf_skbedit_ingress(u32 flags)
|
|
|
|
{
|
|
|
|
return flags & TCA_ACT_FLAGS_AT_INGRESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool is_tcf_skbedit_tx_queue_mapping(const struct tc_action *a)
|
|
|
|
{
|
|
|
|
return is_tcf_skbedit_queue_mapping(a) &&
|
|
|
|
!is_tcf_skbedit_ingress(a->tcfa_flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool is_tcf_skbedit_rx_queue_mapping(const struct tc_action *a)
|
|
|
|
{
|
|
|
|
return is_tcf_skbedit_queue_mapping(a) &&
|
|
|
|
is_tcf_skbedit_ingress(a->tcfa_flags);
|
|
|
|
}
|
|
|
|
|
2022-04-07 10:35:28 +03:00
|
|
|
/* Return true iff action is inheritdsfield */
|
|
|
|
static inline bool is_tcf_skbedit_inheritdsfield(const struct tc_action *a)
|
|
|
|
{
|
|
|
|
return is_tcf_skbedit_with_flag(a, SKBEDIT_F_INHERITDSFIELD);
|
|
|
|
}
|
|
|
|
|
2008-09-12 16:30:20 -07:00
|
|
|
#endif /* __NET_TC_SKBEDIT_H */
|