Blame SOURCES/0003-tc-implement-support-for-action-flags.patch

0ac2f3
From a3d12445422afa12a67a7cd121b7add89f6c7d67 Mon Sep 17 00:00:00 2001
0ac2f3
From: Andrea Claudi <aclaudi@redhat.com>
0ac2f3
Date: Thu, 16 Apr 2020 12:41:49 +0200
0ac2f3
Subject: [PATCH] tc: implement support for action flags
0ac2f3
0ac2f3
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1770671
0ac2f3
Upstream Status: iproute2.git commit fb2e033add073
0ac2f3
0ac2f3
commit fb2e033add073893dea71bb483353790fe8c5354
0ac2f3
Author: Vlad Buslov <vladbu@mellanox.com>
0ac2f3
Date:   Wed Oct 30 16:20:40 2019 +0200
0ac2f3
0ac2f3
    tc: implement support for action flags
0ac2f3
0ac2f3
    Implement setting and printing of action flags with single available flag
0ac2f3
    value "no_percpu" that translates to kernel UAPI TCA_ACT_FLAGS value
0ac2f3
    TCA_ACT_FLAGS_NO_PERCPU_STATS. Update man page with information regarding
0ac2f3
    usage of action flags.
0ac2f3
0ac2f3
    Example usage:
0ac2f3
0ac2f3
     # tc actions add action gact drop no_percpu
0ac2f3
     # sudo tc actions list action gact
0ac2f3
     total acts 1
0ac2f3
0ac2f3
            action order 0: gact action drop
0ac2f3
             random type none pass val 0
0ac2f3
             index 1 ref 1 bind 0
0ac2f3
            no_percpu
0ac2f3
0ac2f3
    Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
0ac2f3
    Signed-off-by: David Ahern <dsahern@gmail.com>
0ac2f3
---
0ac2f3
 man/man8/tc-actions.8 | 14 ++++++++++++++
0ac2f3
 tc/m_action.c         | 19 +++++++++++++++++++
0ac2f3
 2 files changed, 33 insertions(+)
0ac2f3
0ac2f3
diff --git a/man/man8/tc-actions.8 b/man/man8/tc-actions.8
0ac2f3
index f46166e3f6859..bee59f7247fae 100644
0ac2f3
--- a/man/man8/tc-actions.8
0ac2f3
+++ b/man/man8/tc-actions.8
0ac2f3
@@ -47,6 +47,8 @@ actions \- independently defined actions in tc
0ac2f3
 ] [
0ac2f3
 .I COOKIESPEC
0ac2f3
 ] [
0ac2f3
+.I FLAGS
0ac2f3
+] [
0ac2f3
 .I CONTROL
0ac2f3
 ]
0ac2f3
 
0ac2f3
@@ -71,6 +73,10 @@ ACTNAME
0ac2f3
 :=
0ac2f3
 .BI cookie " COOKIE"
0ac2f3
 
0ac2f3
+.I FLAGS
0ac2f3
+:=
0ac2f3
+.I no_percpu
0ac2f3
+
0ac2f3
 .I ACTDETAIL
0ac2f3
 :=
0ac2f3
 .I ACTNAME ACTPARAMS
0ac2f3
@@ -186,6 +192,14 @@ As such, it can be used as a correlating value for maintaining user state.
0ac2f3
 The value to be stored is completely arbitrary and does not require a specific
0ac2f3
 format. It is stored inside the action structure itself.
0ac2f3
 
0ac2f3
+.TP
0ac2f3
+.I FLAGS
0ac2f3
+Action-specific flags. Currently, the only supported flag is
0ac2f3
+.I no_percpu
0ac2f3
+which indicates that action is expected to have minimal software data-path
0ac2f3
+traffic and doesn't need to allocate stat counters with percpu allocator.
0ac2f3
+This option is intended to be used by hardware-offloaded actions.
0ac2f3
+
0ac2f3
 .TP
0ac2f3
 .BI since " MSTIME"
0ac2f3
 When dumping large number of actions, a millisecond time-filter can be
0ac2f3
diff --git a/tc/m_action.c b/tc/m_action.c
0ac2f3
index bdc62720879c1..c46aeaafa8ebf 100644
0ac2f3
--- a/tc/m_action.c
0ac2f3
+++ b/tc/m_action.c
0ac2f3
@@ -249,6 +249,16 @@ done0:
0ac2f3
 				addattr_l(n, MAX_MSG, TCA_ACT_COOKIE,
0ac2f3
 					  &act_ck, act_ck_len);
0ac2f3
 
0ac2f3
+			if (*argv && strcmp(*argv, "no_percpu") == 0) {
0ac2f3
+				struct nla_bitfield32 flags =
0ac2f3
+					{ TCA_ACT_FLAGS_NO_PERCPU_STATS,
0ac2f3
+					  TCA_ACT_FLAGS_NO_PERCPU_STATS };
0ac2f3
+
0ac2f3
+				addattr_l(n, MAX_MSG, TCA_ACT_FLAGS, &flags,
0ac2f3
+					  sizeof(struct nla_bitfield32));
0ac2f3
+				NEXT_ARG_FWD();
0ac2f3
+			}
0ac2f3
+
0ac2f3
 			addattr_nest_end(n, tail);
0ac2f3
 			ok++;
0ac2f3
 		}
0ac2f3
@@ -317,6 +327,15 @@ static int tc_print_one_action(FILE *f, struct rtattr *arg)
0ac2f3
 					   strsz, b1, sizeof(b1)));
0ac2f3
 		print_string(PRINT_FP, NULL, "%s", _SL_);
0ac2f3
 	}
0ac2f3
+	if (tb[TCA_ACT_FLAGS]) {
0ac2f3
+		struct nla_bitfield32 *flags = RTA_DATA(tb[TCA_ACT_FLAGS]);
0ac2f3
+
0ac2f3
+		if (flags->selector & TCA_ACT_FLAGS_NO_PERCPU_STATS)
0ac2f3
+			print_bool(PRINT_ANY, "no_percpu", "\tno_percpu",
0ac2f3
+				   flags->value &
0ac2f3
+				   TCA_ACT_FLAGS_NO_PERCPU_STATS);
0ac2f3
+		print_string(PRINT_FP, NULL, "%s", _SL_);
0ac2f3
+	}
0ac2f3
 
0ac2f3
 	return 0;
0ac2f3
 }
0ac2f3
-- 
0ac2f3
2.25.4
0ac2f3