From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 6471CA0093;
	Fri, 22 Apr 2022 15:03:54 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 0A18541611;
	Fri, 22 Apr 2022 15:03:49 +0200 (CEST)
Received: from mga03.intel.com (mga03.intel.com [134.134.136.65])
 by mails.dpdk.org (Postfix) with ESMTP id 54BC7410D5
 for <dev@dpdk.org>; Fri, 22 Apr 2022 15:03:47 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
 d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
 t=1650632627; x=1682168627;
 h=from:to:subject:date:message-id:in-reply-to:references;
 bh=maHLaBc3LDRjSGFBVxk7EoEgpp8qPb9l2SK5G44EUr4=;
 b=KFQYdkdeb2sxFR9A06VzlqcARyTKzBzCn1YTgmG901qfF+WtYyl/rzzm
 WCyvsDFJufLcBcfoD/JcF1Rc6CzLstvtj6rI8ia1XAMKKUW2UdhRIqO+v
 7QY2upjZBqPD/WtVt79OElECuSF8x9sPLAsjJ/3QvlB0D9YE9yUznXBCZ
 8VyqYKqzJW94XYuvZk4v38WdlD9UrQOicg05GOe9tW7Ic+dKsyrWo6L3y
 W+g3weVDRdpRWifCIqdgKRbqUprLYSRrYUqMNnxLwbnHLG9MvpfUaoBuK
 8sHtDSGM8YuXie1Dpdp7fVp8e4ypNMTxRzI+HTFzvxU7wA8iQhoz29kMR w==;
X-IronPort-AV: E=McAfee;i="6400,9594,10324"; a="264445323"
X-IronPort-AV: E=Sophos;i="5.90,281,1643702400"; d="scan'208";a="264445323"
Received: from fmsmga005.fm.intel.com ([10.253.24.32])
 by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 22 Apr 2022 06:03:46 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.90,281,1643702400"; d="scan'208";a="867669164"
Received: from silpixa00400573.ir.intel.com (HELO
 silpixa00400573.ger.corp.intel.com) ([10.237.223.107])
 by fmsmga005.fm.intel.com with ESMTP; 22 Apr 2022 06:03:46 -0700
From: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
To: dev@dpdk.org
Subject: [PATCH V2 3/3] examples/pipeline: improve learner table timers
Date: Fri, 22 Apr 2022 14:03:43 +0100
Message-Id: <20220422130343.44060-3-cristian.dumitrescu@intel.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20220422130343.44060-1-cristian.dumitrescu@intel.com>
References: <20220421155951.31811-1-cristian.dumitrescu@intel.com>
 <20220422130343.44060-1-cristian.dumitrescu@intel.com>
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

Added the rearm counter to the statistics. Updated the learner table
example to the new learner table timer operation.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
 examples/pipeline/cli.c                 |  2 ++
 examples/pipeline/examples/learner.spec | 15 +++++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c
index d52ad6b61e..0334616bd9 100644
--- a/examples/pipeline/cli.c
+++ b/examples/pipeline/cli.c
@@ -2677,12 +2677,14 @@ cmd_pipeline_stats(char **tokens,
 			"\t\tMiss (packets): %" PRIu64 "\n"
 			"\t\tLearn OK (packets): %" PRIu64 "\n"
 			"\t\tLearn error (packets): %" PRIu64 "\n"
+			"\t\tRearm (packets): %" PRIu64 "\n"
 			"\t\tForget (packets): %" PRIu64 "\n",
 			learner_info.name,
 			stats.n_pkts_hit,
 			stats.n_pkts_miss,
 			stats.n_pkts_learn_ok,
 			stats.n_pkts_learn_err,
+			stats.n_pkts_rearm,
 			stats.n_pkts_forget);
 		out_size -= strlen(out);
 		out += strlen(out);
diff --git a/examples/pipeline/examples/learner.spec b/examples/pipeline/examples/learner.spec
index 4ee52da7ac..095325c293 100644
--- a/examples/pipeline/examples/learner.spec
+++ b/examples/pipeline/examples/learner.spec
@@ -48,6 +48,9 @@ struct metadata_t {
 	bit<32> port_in
 	bit<32> port_out
 
+	// Key timeout.
+	bit<32> timeout_id
+
 	// Arguments for the "fwd_action" action.
 	bit<32> fwd_action_arg_port_out
 }
@@ -68,10 +71,14 @@ struct fwd_action_args_t {
 
 action fwd_action args instanceof fwd_action_args_t {
 	mov m.port_out t.port_out
+	rearm
 	return
 }
 
 action learn_action args none {
+	// Pick the key timeout. Timeout ID #1 (i.e. 120 seconds) is selected.
+	mov m.timeout_id 1
+
 	// Read current counter value into m.fwd_action_arg_port_out.
 	regrd m.fwd_action_arg_port_out counter 0
 
@@ -84,7 +91,7 @@ action learn_action args none {
 	// Add the current lookup key to the table with fwd_action as the key action. The action
 	// arguments are read from the packet meta-data (the m.fwd_action_arg_port_out field). These
 	// packet meta-data fields have to be written before the "learn" instruction is invoked.
-	learn fwd_action m.fwd_action_arg_port_out
+	learn fwd_action m.fwd_action_arg_port_out m.timeout_id
 
 	// Send the current packet to the same output port.
 	mov m.port_out m.fwd_action_arg_port_out
@@ -110,7 +117,11 @@ learner fwd_table {
 
 	size 1048576
 
-	timeout 120
+	timeout {
+		60
+		120
+		180
+	}
 }
 
 //
-- 
2.17.1