From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 71FD4A053D; Mon, 27 Jul 2020 17:26:42 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 097E22C6E; Mon, 27 Jul 2020 17:26:41 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 54F461023 for ; Mon, 27 Jul 2020 17:26:39 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from viacheslavo@mellanox.com) with SMTP; 27 Jul 2020 18:26:37 +0300 Received: from pegasus12.mtr.labs.mlnx (pegasus12.mtr.labs.mlnx [10.210.17.40]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 06RFQbLb022756; Mon, 27 Jul 2020 18:26:37 +0300 Received: from pegasus12.mtr.labs.mlnx (localhost [127.0.0.1]) by pegasus12.mtr.labs.mlnx (8.14.7/8.14.7) with ESMTP id 06RFQbVO011384; Mon, 27 Jul 2020 15:26:37 GMT Received: (from viacheslavo@localhost) by pegasus12.mtr.labs.mlnx (8.14.7/8.14.7/Submit) id 06RFQaiW011383; Mon, 27 Jul 2020 15:26:36 GMT X-Authentication-Warning: pegasus12.mtr.labs.mlnx: viacheslavo set sender to viacheslavo@mellanox.com using -f From: Viacheslav Ovsiienko To: dev@dpdk.org Cc: matan@mellanox.com, rasland@mellanox.com, thomas@monjalon.net, ferruh.yigit@intel.com Date: Mon, 27 Jul 2020 15:26:35 +0000 Message-Id: <1595863595-11344-1-git-send-email-viacheslavo@mellanox.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH] app/testpmd: fix txonly mode timestamp intitialization 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" The testpmd application forwards data in multiple threads. In the txonly mode the Tx timestamps must be initialized on per thread basis to provide phase shift for the packet burst being sent. This per thread initialization was performed on zero value of the variable in thread local storage and happened only once after testpmd forwarding start. Executing "start" and "stop" commands did not cause thread local variables zeroing and wrong timestamp values were used. Fixes: 4940344dab1d ("app/testpmd: add Tx scheduling command") Signed-off-by: Viacheslav Ovsiienko --- app/test-pmd/txonly.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c index 97f4a45..415431d 100644 --- a/app/test-pmd/txonly.c +++ b/app/test-pmd/txonly.c @@ -55,9 +55,13 @@ static struct rte_udp_hdr pkt_udp_hdr; /**< UDP header of tx packets. */ RTE_DEFINE_PER_LCORE(uint64_t, timestamp_qskew); /**< Timestamp offset per queue */ +RTE_DEFINE_PER_LCORE(uint32_t, timestamp_idone); /**< Timestamp init done. */ + static uint64_t timestamp_mask; /**< Timestamp dynamic flag mask */ static int32_t timestamp_off; /**< Timestamp dynamic field offset */ static bool timestamp_enable; /**< Timestamp enable */ +static volatile uint32_t timestamp_init_req; + /**< Timestamp initialization request. */ static uint64_t timestamp_initial[RTE_MAX_ETHPORTS]; static void @@ -229,7 +233,8 @@ rte_be64_t ts; } timestamp_mark; - if (unlikely(!skew)) { + if (unlikely(timestamp_init_req != + RTE_PER_LCORE(timestamp_idone))) { struct rte_eth_dev *dev = &rte_eth_devices[fs->tx_port]; unsigned int txqs_n = dev->data->nb_tx_queues; uint64_t phase = tx_pkt_times_inter * fs->tx_queue / @@ -241,6 +246,7 @@ skew = timestamp_initial[fs->tx_port] + tx_pkt_times_inter + phase; RTE_PER_LCORE(timestamp_qskew) = skew; + RTE_PER_LCORE(timestamp_idone) = timestamp_init_req; } timestamp_mark.pkt_idx = rte_cpu_to_be_16(idx); timestamp_mark.queue_idx = rte_cpu_to_be_16(fs->tx_queue); @@ -426,6 +432,9 @@ timestamp_mask && timestamp_off >= 0 && !rte_eth_read_clock(pi, ×tamp_initial[pi]); + if (timestamp_enable) + timestamp_init_req++; + rte_wmb(); } struct fwd_engine tx_only_engine = { -- 1.8.3.1