From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 6A378C6C8 for ; Fri, 29 Jan 2016 16:35:55 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP; 29 Jan 2016 07:35:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,364,1449561600"; d="scan'208";a="901010080" Received: from gklab-246-018.igk.intel.com (HELO stargo) ([10.217.246.18]) by orsmga002.jf.intel.com with SMTP; 29 Jan 2016 07:35:52 -0800 Received: by stargo (sSMTP sendmail emulation); Fri, 29 Jan 2016 16:32:20 +0100 From: Marcin Kerlin To: dev@dpdk.org Date: Fri, 29 Jan 2016 16:31:37 +0100 Message-Id: <1454081497-13015-1-git-send-email-marcinx.kerlin@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1453824934-10650-1-git-send-email-marcinx.kerlin@intel.com> References: <1453824934-10650-1-git-send-email-marcinx.kerlin@intel.com> Subject: [dpdk-dev] [PATCH v2 1/1] jobstats: added function abort for job X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jan 2016 15:35:55 -0000 This patch adds new function rte_jobstats_abort. It marks *job* as finished and time of this work will be add to management time instead of execution time. This function should be used instead of rte_jobstats_finish if condition occurs, condition is defined by the application for example when receiving n>0 packets. v2: * removed redundant field Signed-off-by: Marcin Kerlin --- lib/librte_jobstats/rte_jobstats.c | 20 ++++++++++++++++++++ lib/librte_jobstats/rte_jobstats.h | 14 ++++++++++++++ lib/librte_jobstats/rte_jobstats_version.map | 7 +++++++ 3 files changed, 41 insertions(+) diff --git a/lib/librte_jobstats/rte_jobstats.c b/lib/librte_jobstats/rte_jobstats.c index 2eaac0c..2b42050 100644 --- a/lib/librte_jobstats/rte_jobstats.c +++ b/lib/librte_jobstats/rte_jobstats.c @@ -170,6 +170,26 @@ rte_jobstats_start(struct rte_jobstats_context *ctx, struct rte_jobstats *job) } int +rte_jobstats_abort(struct rte_jobstats *job) +{ + struct rte_jobstats_context *ctx; + uint64_t now, exec_time; + + /* Some sanity check. */ + if (unlikely(job == NULL || job->context == NULL)) + return -EINVAL; + + ctx = job->context; + now = get_time(); + exec_time = now - ctx->state_time; + ADD_TIME_MIN_MAX(ctx, management, exec_time); + ctx->state_time = now; + job->context = NULL; + + return 0; +} + +int rte_jobstats_finish(struct rte_jobstats *job, int64_t job_value) { struct rte_jobstats_context *ctx; diff --git a/lib/librte_jobstats/rte_jobstats.h b/lib/librte_jobstats/rte_jobstats.h index de6a89a..c2b285f 100644 --- a/lib/librte_jobstats/rte_jobstats.h +++ b/lib/librte_jobstats/rte_jobstats.h @@ -237,6 +237,20 @@ int rte_jobstats_start(struct rte_jobstats_context *ctx, struct rte_jobstats *job); /** + * Mark that *job* finished its execution, but time of this work will be skipped + * and added to management time. + * + * @param job + * Job object. + * + * @return + * 0 on success + * -EINVAL if job is NULL or job was not started (it have no context). + */ +int +rte_jobstats_abort(struct rte_jobstats *job); + +/** * Mark that *job* finished its execution. Context in which it was executing * will receive stat update. After this function call *job* object is ready to * be executed in other context. diff --git a/lib/librte_jobstats/rte_jobstats_version.map b/lib/librte_jobstats/rte_jobstats_version.map index cb01bfd..e3b21ca 100644 --- a/lib/librte_jobstats/rte_jobstats_version.map +++ b/lib/librte_jobstats/rte_jobstats_version.map @@ -17,3 +17,10 @@ DPDK_2.0 { local: *; }; + +DPDK_2.3 { + global: + + rte_jobstats_abort; + +} DPDK_2.0; -- 1.9.1