From patchwork Thu Mar 29 18:31:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jasvinder Singh X-Patchwork-Id: 36692 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C36944C70; Thu, 29 Mar 2018 20:32:51 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 601A84CB3 for ; Thu, 29 Mar 2018 20:32:20 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Mar 2018 11:32:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,378,1517904000"; d="scan'208";a="216058866" Received: from silpixa00381635.ir.intel.com (HELO silpixa00381635.ger.corp.intel.com) ([10.237.222.149]) by fmsmga005.fm.intel.com with ESMTP; 29 Mar 2018 11:32:19 -0700 From: Jasvinder Singh To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com Date: Thu, 29 Mar 2018 19:31:28 +0100 Message-Id: <20180329183208.103844-10-jasvinder.singh@intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20180329183208.103844-1-jasvinder.singh@intel.com> References: <20180316175906.159198-2-jasvinder.singh@intel.com> <20180329183208.103844-1-jasvinder.singh@intel.com> Subject: [dpdk-dev] [PATCH v4 09/49] pipeline: add timestamp action X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add implementation of timestamp action. Signed-off-by: Cristian Dumitrescu --- lib/librte_pipeline/rte_pipeline_version.map | 1 + lib/librte_pipeline/rte_table_action.c | 79 +++++++++++++++++++++++++++- lib/librte_pipeline/rte_table_action.h | 31 +++++++++++ 3 files changed, 110 insertions(+), 1 deletion(-) diff --git a/lib/librte_pipeline/rte_pipeline_version.map b/lib/librte_pipeline/rte_pipeline_version.map index 8241efc..4e948b8 100644 --- a/lib/librte_pipeline/rte_pipeline_version.map +++ b/lib/librte_pipeline/rte_pipeline_version.map @@ -62,6 +62,7 @@ EXPERIMENTAL { rte_table_action_profile_freeze; rte_table_action_table_params_get; rte_table_action_stats_read; + rte_table_action_time_read; rte_table_action_ttl_read; } DPDK_16.04; diff --git a/lib/librte_pipeline/rte_table_action.c b/lib/librte_pipeline/rte_table_action.c index 8bcc4eb..1a32c71 100644 --- a/lib/librte_pipeline/rte_table_action.c +++ b/lib/librte_pipeline/rte_table_action.c @@ -1149,6 +1149,28 @@ pkt_work_stats(struct stats_data *data, } /** + * RTE_TABLE_ACTION_TIME + */ +struct time_data { + uint64_t time; +} __attribute__((__packed__)); + +static int +time_apply(struct time_data *data, + struct rte_table_action_time_params *p) +{ + data->time = p->time; + return 0; +} + +static __rte_always_inline void +pkt_work_time(struct time_data *data, + uint64_t time) +{ + data->time = time; +} + +/** * Action profile */ static int @@ -1162,6 +1184,7 @@ action_valid(enum rte_table_action_type action) case RTE_TABLE_ACTION_NAT: case RTE_TABLE_ACTION_TTL: case RTE_TABLE_ACTION_STATS: + case RTE_TABLE_ACTION_TIME: return 1; default: return 0; @@ -1276,6 +1299,9 @@ action_data_size(enum rte_table_action_type action, case RTE_TABLE_ACTION_STATS: return sizeof(struct stats_data); + case RTE_TABLE_ACTION_TIME: + return sizeof(struct time_data); + default: return 0; } @@ -1512,6 +1538,10 @@ rte_table_action_apply(struct rte_table_action *action, return stats_apply(action_data, action_params); + case RTE_TABLE_ACTION_TIME: + return time_apply(action_data, + action_params); + default: return -EINVAL; } @@ -1741,6 +1771,29 @@ rte_table_action_stats_read(struct rte_table_action *action, return 0; } +int +rte_table_action_time_read(struct rte_table_action *action, + void *data, + uint64_t *timestamp) +{ + struct time_data *time_data; + + /* Check input arguments */ + if ((action == NULL) || + ((action->cfg.action_mask & + (1LLU << RTE_TABLE_ACTION_TIME)) == 0) || + (data == NULL) || + (timestamp == NULL)) + return -EINVAL; + + time_data = action_data_get(data, action, RTE_TABLE_ACTION_TIME); + + /* Read */ + *timestamp = time_data->time; + + return 0; +} + static __rte_always_inline uint64_t pkt_work(struct rte_mbuf *mbuf, struct rte_pipeline_table_entry *table_entry, @@ -1831,6 +1884,13 @@ pkt_work(struct rte_mbuf *mbuf, pkt_work_stats(data, total_length); } + if (cfg->action_mask & (1LLU << RTE_TABLE_ACTION_TIME)) { + void *data = + action_data_get(table_entry, action, RTE_TABLE_ACTION_TIME); + + pkt_work_time(data, time); + } + return drop_mask; } @@ -2076,6 +2136,22 @@ pkt4_work(struct rte_mbuf **mbufs, pkt_work_stats(data3, total_length3); } + if (cfg->action_mask & (1LLU << RTE_TABLE_ACTION_TIME)) { + void *data0 = + action_data_get(table_entry0, action, RTE_TABLE_ACTION_TIME); + void *data1 = + action_data_get(table_entry1, action, RTE_TABLE_ACTION_TIME); + void *data2 = + action_data_get(table_entry2, action, RTE_TABLE_ACTION_TIME); + void *data3 = + action_data_get(table_entry3, action, RTE_TABLE_ACTION_TIME); + + pkt_work_time(data0, time); + pkt_work_time(data1, time); + pkt_work_time(data2, time); + pkt_work_time(data3, time); + } + return drop_mask0 | (drop_mask1 << 1) | (drop_mask2 << 2) | @@ -2093,7 +2169,8 @@ ah(struct rte_pipeline *p, uint64_t pkts_drop_mask = 0; uint64_t time = 0; - if (cfg->action_mask & (1LLU << RTE_TABLE_ACTION_MTR)) + if (cfg->action_mask & ((1LLU << RTE_TABLE_ACTION_MTR) | + (1LLU << RTE_TABLE_ACTION_TIME))) time = rte_rdtsc(); if ((pkts_mask & (pkts_mask + 1)) == 0) { diff --git a/lib/librte_pipeline/rte_table_action.h b/lib/librte_pipeline/rte_table_action.h index 53b9866..e9b30ab 100644 --- a/lib/librte_pipeline/rte_table_action.h +++ b/lib/librte_pipeline/rte_table_action.h @@ -86,6 +86,9 @@ enum rte_table_action_type { /** Statistics. */ RTE_TABLE_ACTION_STATS, + + /** Timestamp. */ + RTE_TABLE_ACTION_TIME, }; /** Common action configuration (per table action profile). */ @@ -542,6 +545,15 @@ struct rte_table_action_stats_counters { }; /** + * RTE_TABLE_ACTION_TIME + */ +/** Timestamp action parameters (per table rule). */ +struct rte_table_action_time_params { + /** Initial timestamp value. Typically set to current time. */ + uint64_t time; +}; + +/** * Table action profile. */ struct rte_table_action_profile; @@ -815,6 +827,25 @@ rte_table_action_stats_read(struct rte_table_action *action, struct rte_table_action_stats_counters *stats, int clear); +/** + * Table action timestamp read. + * + * @param[in] action + * Handle to table action object (needs to be valid). + * @param[in] data + * Data byte array (typically table rule data) with timestamp action + * previously applied on it. + * @param[inout] timestamp + * Pre-allocated memory where the timestamp read from *data* is saved (has to + * be non-NULL). + * @return + * Zero on success, non-zero error code otherwise. + */ +int __rte_experimental +rte_table_action_time_read(struct rte_table_action *action, + void *data, + uint64_t *timestamp); + #ifdef __cplusplus } #endif