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 02AFBA00C4; Sun, 24 Apr 2022 09:16:08 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B8B78427FB; Sun, 24 Apr 2022 09:15:53 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id AC448427F1 for ; Sun, 24 Apr 2022 09:15:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650784551; x=1682320551; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=hMf5X1gH+U2KQo+Qqn2lsikHSKQlgJLRoRp/XdiGNFU=; b=bjCi9D4Fy8O8TrRNaz+OwPUZKd9SO6v4s+CTiz4dxQgfh6WSIBzzFwl1 L+iSjqox/yyt3FeJKa18XYYQk50xIlm/pHcwdn4ZwEbQsDNWoB55hFj1B EkfUXkZ5vaflQSPOKewwGLY87gGvGGuQqVvMqe53dd5dWnULAtKEfG8J3 Ykg/kFiENWGLJSv8Ukw9cB48FLNcFLUqwcEkYcZ6YOwxzqrnDFVHVE8Nk 9vk6s5CF0IW+CqjwIHQORszylWOCWOiTudUE++DbGJ8c/i2pPTapoN8pk D0CCGJkrlqcEaKDiovwJ6gHp4w9JA89YOuFVfq0nsk6Q0BqAPEAOiGpGm g==; X-IronPort-AV: E=McAfee;i="6400,9594,10326"; a="263855990" X-IronPort-AV: E=Sophos;i="5.90,286,1643702400"; d="scan'208";a="263855990" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2022 00:15:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,286,1643702400"; d="scan'208";a="594773453" Received: from unknown (HELO npg-dpdk-simeisu-cvl-119d218.sh.intel.com) ([10.67.119.218]) by orsmga001.jf.intel.com with ESMTP; 24 Apr 2022 00:15:49 -0700 From: Simei Su To: qi.z.zhang@intel.com, qiming.yang@intel.com Cc: dev@dpdk.org, wenjun1.wu@intel.com, Simei Su Subject: [PATCH v2 3/3] net/iavf: improve performance of Rx timestamp offload Date: Sun, 24 Apr 2022 15:08:45 +0800 Message-Id: <20220424070845.87096-4-simei.su@intel.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20220424070845.87096-1-simei.su@intel.com> References: <20220408021307.272746-1-simei.su@intel.com> <20220424070845.87096-1-simei.su@intel.com> 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 In this patch, We use CPU ticks instead of HW register to determine whether low 32 bits timestamp has turned over. It can avoid requesting register value frequently and improve receiving performance. Signed-off-by: Wenjun Wu --- drivers/net/iavf/iavf.h | 1 + drivers/net/iavf/iavf_ethdev.c | 9 ++++++++ drivers/net/iavf/iavf_rxtx.c | 51 +++++++++++++++++++++++++++--------------- drivers/net/iavf/iavf_rxtx.h | 1 - 4 files changed, 43 insertions(+), 19 deletions(-) diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h index 3255c93..dd83567 100644 --- a/drivers/net/iavf/iavf.h +++ b/drivers/net/iavf/iavf.h @@ -315,6 +315,7 @@ struct iavf_adapter { uint16_t fdir_ref_cnt; struct iavf_devargs devargs; uint64_t phc_time; + uint64_t hw_time_update; }; /* IAVF_DEV_PRIVATE_TO */ diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c index 89e4240..d1a2b53 100644 --- a/drivers/net/iavf/iavf_ethdev.c +++ b/drivers/net/iavf/iavf_ethdev.c @@ -1019,6 +1019,15 @@ iavf_dev_start(struct rte_eth_dev *dev) goto err_mac; } + if (dev->data->dev_conf.rxmode.offloads & + RTE_ETH_RX_OFFLOAD_TIMESTAMP) { + if (iavf_get_phc_time(adapter)) { + PMD_DRV_LOG(ERR, "get physical time failed"); + goto err_mac; + } + adapter->hw_time_update = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000); + } + return 0; err_mac: diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c index 2d3bafd..bb67a9a 100644 --- a/drivers/net/iavf/iavf_rxtx.c +++ b/drivers/net/iavf/iavf_rxtx.c @@ -1425,8 +1425,14 @@ iavf_recv_pkts_flex_rxd(void *rx_queue, struct iavf_adapter *ad = rxq->vsi->adapter; uint64_t ts_ns; - if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) - rxq->hw_register_set = 1; + if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) { + uint64_t sw_cur_time = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000); + if (sw_cur_time - ad->hw_time_update > 4) { + if (iavf_get_phc_time(ad)) + PMD_DRV_LOG(ERR, "get physical time failed"); + ad->hw_time_update = sw_cur_time; + } + } nb_rx = 0; nb_hold = 0; @@ -1498,13 +1504,12 @@ iavf_recv_pkts_flex_rxd(void *rx_queue, pkt_flags = iavf_flex_rxd_error_to_pkt_flags(rx_stat_err0); if (iavf_timestamp_dynflag > 0) { - if (rxq->hw_register_set) - iavf_get_phc_time(ad); - - rxq->hw_register_set = 0; ts_ns = iavf_tstamp_convert_32b_64b(ad->phc_time, rte_le_to_cpu_32(rxd.wb.flex_ts.ts_high)); + ad->phc_time = ts_ns; + ad->hw_time_update = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000); + *RTE_MBUF_DYNFIELD(rxm, iavf_timestamp_dynfield_offset, rte_mbuf_timestamp_t *) = ts_ns; @@ -1546,8 +1551,14 @@ iavf_recv_scattered_pkts_flex_rxd(void *rx_queue, struct rte_mbuf **rx_pkts, volatile union iavf_rx_flex_desc *rxdp; const uint32_t *ptype_tbl = rxq->vsi->adapter->ptype_tbl; - if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) - rxq->hw_register_set = 1; + if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) { + uint64_t sw_cur_time = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000); + if (sw_cur_time - ad->hw_time_update > 4) { + if (iavf_get_phc_time(ad)) + PMD_DRV_LOG(ERR, "get physical time failed"); + ad->hw_time_update = sw_cur_time; + } + } while (nb_rx < nb_pkts) { rxdp = (volatile union iavf_rx_flex_desc *)&rx_ring[rx_id]; @@ -1662,13 +1673,12 @@ iavf_recv_scattered_pkts_flex_rxd(void *rx_queue, struct rte_mbuf **rx_pkts, pkt_flags = iavf_flex_rxd_error_to_pkt_flags(rx_stat_err0); if (iavf_timestamp_dynflag > 0) { - if (rxq->hw_register_set) - iavf_get_phc_time(ad); - - rxq->hw_register_set = 0; ts_ns = iavf_tstamp_convert_32b_64b(ad->phc_time, rte_le_to_cpu_32(rxd.wb.flex_ts.ts_high)); + ad->phc_time = ts_ns; + ad->hw_time_update = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000); + *RTE_MBUF_DYNFIELD(first_seg, iavf_timestamp_dynfield_offset, rte_mbuf_timestamp_t *) = ts_ns; @@ -1882,8 +1892,14 @@ iavf_rx_scan_hw_ring_flex_rxd(struct iavf_rx_queue *rxq, if (!(stat_err0 & (1 << IAVF_RX_FLEX_DESC_STATUS0_DD_S))) return 0; - if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) - rxq->hw_register_set = 1; + if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) { + uint64_t sw_cur_time = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000); + if (sw_cur_time - ad->hw_time_update > 4) { + if (iavf_get_phc_time(ad)) + PMD_DRV_LOG(ERR, "get physical time failed"); + ad->hw_time_update = sw_cur_time; + } + } /* Scan LOOK_AHEAD descriptors at a time to determine which * descriptors reference packets that are ready to be received. @@ -1942,13 +1958,12 @@ iavf_rx_scan_hw_ring_flex_rxd(struct iavf_rx_queue *rxq, pkt_flags = iavf_flex_rxd_error_to_pkt_flags(stat_err0); if (iavf_timestamp_dynflag > 0) { - if (rxq->hw_register_set) - iavf_get_phc_time(ad); - - rxq->hw_register_set = 0; ts_ns = iavf_tstamp_convert_32b_64b(ad->phc_time, rte_le_to_cpu_32(rxdp[j].wb.flex_ts.ts_high)); + ad->phc_time = ts_ns; + ad->hw_time_update = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000); + *RTE_MBUF_DYNFIELD(mb, iavf_timestamp_dynfield_offset, rte_mbuf_timestamp_t *) = ts_ns; diff --git a/drivers/net/iavf/iavf_rxtx.h b/drivers/net/iavf/iavf_rxtx.h index 37453c4..642b9a7 100644 --- a/drivers/net/iavf/iavf_rxtx.h +++ b/drivers/net/iavf/iavf_rxtx.h @@ -222,7 +222,6 @@ struct iavf_rx_queue { /* flexible descriptor metadata extraction offload flag */ struct iavf_rx_queue_stats stats; uint64_t offloads; - uint32_t hw_register_set; }; struct iavf_tx_entry { -- 2.9.5