From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1AE69A0C43; Tue, 28 Sep 2021 18:47:10 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 06640410E5; Tue, 28 Sep 2021 18:47:10 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id 32B38410E4 for ; Tue, 28 Sep 2021 18:47:08 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10121"; a="310300858" X-IronPort-AV: E=Sophos;i="5.85,329,1624345200"; d="scan'208";a="310300858" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2021 09:38:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,329,1624345200"; d="scan'208";a="554137734" Received: from txandevlnx322.an.intel.com ([10.123.117.44]) by FMSMGA003.fm.intel.com with ESMTP; 28 Sep 2021 09:38:51 -0700 From: Ganapati Kundapura To: jerinjacobk@gmail.com, dev@dpdk.org Cc: jay.jayatheerthan@intel.com, Jerin Jacob Date: Tue, 28 Sep 2021 11:38:48 -0500 Message-Id: <20210928163848.1511459-1-ganapati.kundapura@intel.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20210916091532.1848770-1-ganapati.kundapura@intel.com> References: <20210916091532.1848770-1-ganapati.kundapura@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3] eventdev: add Rx timestamp in mbuf using mbuf dynamic field X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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 support to register timestamp dynamic field in mbuf. Update the timestamp in mbuf for each packet before enqueuing to event device if the timestamp is not already set. Adding the timestamp in Rx adapter avoids additional latency due to the event device. Acked-by: Jerin Jacob Signed-off-by: Ganapati Kundapura --- Depends-on: patch-97549(make Rx-adapter enqueue buffer as circular buffer) v3: * updated timestamp variables to static * corrected wrong headline case: rx --> Rx * corrected headline too long git log issue v2: * Removed rte_ prefix from the internal function v1: * Add support to register timestamp dynamic field in mbuf --- diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c index f2dc695..e7595b2 100644 --- a/lib/eventdev/rte_event_eth_rx_adapter.c +++ b/lib/eventdev/rte_event_eth_rx_adapter.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "rte_eventdev.h" #include "eventdev_pmd.h" @@ -240,6 +241,17 @@ struct eth_rx_queue_info { static struct rte_event_eth_rx_adapter **event_eth_rx_adapter; +/* Enable dynamic timestamp field in mbuf */ +static uint64_t event_eth_rx_timestamp_dynflag; +static int event_eth_rx_timestamp_dynfield_offset = -1; + +static inline rte_mbuf_timestamp_t * +rxa_timestamp_dynfield(struct rte_mbuf *mbuf) +{ + return RTE_MBUF_DYNFIELD(mbuf, + event_eth_rx_timestamp_dynfield_offset, rte_mbuf_timestamp_t *); +} + static inline int rxa_validate_id(uint8_t id) { @@ -890,8 +902,18 @@ rxa_buffer_mbufs(struct rte_event_eth_rx_adapter *rx_adapter, int do_rss; uint16_t nb_cb; uint16_t dropped; + uint64_t ts, ts_mask; if (!eth_rx_queue_info->ena_vector) { + ts = m->ol_flags & event_eth_rx_timestamp_dynflag ? + 0 : rte_get_tsc_cycles(); + + /* 0xffff ffff ffff ffff if PKT_RX_TIMESTAMP is set, + * otherwise 0 + */ + ts_mask = (uint64_t)(!(m->ol_flags & + event_eth_rx_timestamp_dynflag)) - 1ULL; + /* 0xffff ffff if PKT_RX_RSS_HASH is set, otherwise 0 */ rss_mask = ~(((m->ol_flags & PKT_RX_RSS_HASH) != 0) - 1); do_rss = !rss_mask && !eth_rx_queue_info->flow_id_mask; @@ -899,6 +921,9 @@ rxa_buffer_mbufs(struct rte_event_eth_rx_adapter *rx_adapter, struct rte_event *ev; m = mbufs[i]; + *rxa_timestamp_dynfield(m) = ts | + (*rxa_timestamp_dynfield(m) & ts_mask); + ev = &buf->events[new_tail]; rss = do_rss ? rxa_do_softrss(m, rx_adapter->rss_key_be) @@ -2238,6 +2263,14 @@ rte_event_eth_rx_adapter_create_ext(uint8_t id, uint8_t dev_id, event_eth_rx_adapter[id] = rx_adapter; if (conf_cb == rxa_default_conf_cb) rx_adapter->default_cb_arg = 1; + + if (rte_mbuf_dyn_rx_timestamp_register( + &event_eth_rx_timestamp_dynfield_offset, + &event_eth_rx_timestamp_dynflag) != 0) { + RTE_EDEV_LOG_ERR("Error registering timestamp field in mbuf\n"); + return -rte_errno; + } + rte_eventdev_trace_eth_rx_adapter_create(id, dev_id, conf_cb, conf_arg); return 0; -- 2.6.4