xref: /linux/include/net/tc_act/tc_skbedit.h (revision eddd2cf195d6fb5e4bbc91a0fe4be55110f559ab)
1ca9b0e27SAlexander Duyck /*
2ca9b0e27SAlexander Duyck  * Copyright (c) 2008, Intel Corporation.
3ca9b0e27SAlexander Duyck  *
4ca9b0e27SAlexander Duyck  * This program is free software; you can redistribute it and/or modify it
5ca9b0e27SAlexander Duyck  * under the terms and conditions of the GNU General Public License,
6ca9b0e27SAlexander Duyck  * version 2, as published by the Free Software Foundation.
7ca9b0e27SAlexander Duyck  *
8ca9b0e27SAlexander Duyck  * This program is distributed in the hope it will be useful, but WITHOUT
9ca9b0e27SAlexander Duyck  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10ca9b0e27SAlexander Duyck  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
11ca9b0e27SAlexander Duyck  * more details.
12ca9b0e27SAlexander Duyck  *
13ca9b0e27SAlexander Duyck  * You should have received a copy of the GNU General Public License along with
14a6227e26SJeff Kirsher  * this program; if not, see <http://www.gnu.org/licenses/>.
15ca9b0e27SAlexander Duyck  *
16ca9b0e27SAlexander Duyck  * Author: Alexander Duyck <alexander.h.duyck@intel.com>
17ca9b0e27SAlexander Duyck  */
18ca9b0e27SAlexander Duyck 
19ca9b0e27SAlexander Duyck #ifndef __NET_TC_SKBEDIT_H
20ca9b0e27SAlexander Duyck #define __NET_TC_SKBEDIT_H
21ca9b0e27SAlexander Duyck 
22ca9b0e27SAlexander Duyck #include <net/act_api.h>
23519afb18SAmir Vadai #include <linux/tc_act/tc_skbedit.h>
24ca9b0e27SAlexander Duyck 
25c749cddaSDavide Caratti struct tcf_skbedit_params {
26ca9b0e27SAlexander Duyck 	u32 flags;
27ca9b0e27SAlexander Duyck 	u32 priority;
281c55d62eSjamal 	u32 mark;
294fe77d82SAntonio Quartulli 	u32 mask;
30ca9b0e27SAlexander Duyck 	u16 queue_mapping;
31ff202ee1SJamal Hadi Salim 	u16 ptype;
32c749cddaSDavide Caratti 	struct rcu_head rcu;
33c749cddaSDavide Caratti };
34c749cddaSDavide Caratti 
35c749cddaSDavide Caratti struct tcf_skbedit {
36c749cddaSDavide Caratti 	struct tc_action common;
37c749cddaSDavide Caratti 	struct tcf_skbedit_params __rcu *params;
38ca9b0e27SAlexander Duyck };
39a85a970aSWANG Cong #define to_skbedit(a) ((struct tcf_skbedit *)a)
40ca9b0e27SAlexander Duyck 
41519afb18SAmir Vadai /* Return true iff action is mark */
42519afb18SAmir Vadai static inline bool is_tcf_skbedit_mark(const struct tc_action *a)
43519afb18SAmir Vadai {
44519afb18SAmir Vadai #ifdef CONFIG_NET_CLS_ACT
45c749cddaSDavide Caratti 	u32 flags;
46c749cddaSDavide Caratti 
47*eddd2cf1SEli Cohen 	if (a->ops && a->ops->id == TCA_ID_SKBEDIT) {
48c749cddaSDavide Caratti 		rcu_read_lock();
49c749cddaSDavide Caratti 		flags = rcu_dereference(to_skbedit(a)->params)->flags;
50c749cddaSDavide Caratti 		rcu_read_unlock();
51c749cddaSDavide Caratti 		return flags == SKBEDIT_F_MARK;
52c749cddaSDavide Caratti 	}
53519afb18SAmir Vadai #endif
54519afb18SAmir Vadai 	return false;
55519afb18SAmir Vadai }
56519afb18SAmir Vadai 
57519afb18SAmir Vadai static inline u32 tcf_skbedit_mark(const struct tc_action *a)
58519afb18SAmir Vadai {
59c749cddaSDavide Caratti 	u32 mark;
60c749cddaSDavide Caratti 
61c749cddaSDavide Caratti 	rcu_read_lock();
62c749cddaSDavide Caratti 	mark = rcu_dereference(to_skbedit(a)->params)->mark;
63c749cddaSDavide Caratti 	rcu_read_unlock();
64c749cddaSDavide Caratti 
65c749cddaSDavide Caratti 	return mark;
66519afb18SAmir Vadai }
67519afb18SAmir Vadai 
68ca9b0e27SAlexander Duyck #endif /* __NET_TC_SKBEDIT_H */
69