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 70FDF45D27; Mon, 25 Nov 2024 12:34:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 45A7240698; Mon, 25 Nov 2024 12:34:03 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) by mails.dpdk.org (Postfix) with ESMTP id A5239402C9 for ; Mon, 25 Nov 2024 12:34:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1732534442; x=1764070442; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=GrjrMQd5+K99QWuQdaOnXcL2LTqUPakK8A0CZNu8nX8=; b=hzeLkK55hh7+17q1NUZy+jbgYyhfqfCdKDblc6Z8FrV+TTKoNIFXtaiA 1XSrrSJl73SuWUyqlbWUMIzVG6o/s2tfGkHP36j8ZofWoJQEcaG0IB2Jc urqRpZQG3M0H+xYHdzrm32xlwUYQlx/vXPzeq6bvFyGG6ao9UMepYJ4uv NX4hTZkdj1sC/k9Rgyy2zd2t/Z0jwHxpnKL9Dw8xuD6f3KpPcy+bHb+Ix wdTcjye1s3Xjny+UbDaSZGE5YlmKFVroUk90wejwjsNQ6T9pRIDhMrMB1 MFPdrSTdpThll8llFADBOVW9hrQ3eQckOmIkyf9iZR7kQtEYuOiEqsIYE g==; X-CSE-ConnectionGUID: ODr/6C0mS56LM5RWybq9Zw== X-CSE-MsgGUID: qFR72iiyTc2cXR9ogPHPFQ== X-IronPort-AV: E=McAfee;i="6700,10204,11266"; a="44015581" X-IronPort-AV: E=Sophos;i="6.12,182,1728975600"; d="scan'208";a="44015581" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2024 03:33:30 -0800 X-CSE-ConnectionGUID: rHOpfawzRZaMADy14IVbrA== X-CSE-MsgGUID: zgmLd4zOSBWBy9uBhP7GbA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,182,1728975600"; d="scan'208";a="90867926" Received: from silpixa00401119.ir.intel.com ([10.55.129.167]) by fmviesa006.fm.intel.com with ESMTP; 25 Nov 2024 03:33:28 -0800 From: Anatoly Burakov To: dev@dpdk.org, Vladimir Medvedkin Subject: [PATCH v2 1/3] net/ixgbe: initialize PTP to system time Date: Mon, 25 Nov 2024 11:33:24 +0000 Message-ID: <672ea483818966221e348a09531a9975e2b83b38.1732534388.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <38eca384ecd00e1601532dd10e20ef45aedf8434.1732288709.git.anatoly.burakov@intel.com> References: <38eca384ecd00e1601532dd10e20ef45aedf8434.1732288709.git.anatoly.burakov@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Currently, ixgbe driver initializes PTP timestamp to 0. This is different from what kernel driver does (which initializes it to system time). Align the DPDK driver to kernel driver by setting PTP timestamp to system time when enabling PTP. Note that ixgbe driver always uses zero-based timestamps for PTP, so we would only ever update the internal timecounter and not the actual NIC registers. Implementation note: in order to get access to clock_gettime on MinGW, we have to use rte_os_shim.h header, which provides a wrapper around that function. However, what it *also* provides is wrapper macros around various other OS-related functions such as read(). Due to one of the mailbox ops in base code being called "read", MinGW will misinterpret a call into that op as an attempt to call read() the OS function, and produce a compile error. This is being worked around by using parentheses around access to the read op. Signed-off-by: Anatoly Burakov --- drivers/net/ixgbe/ixgbe_ethdev.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index d02d1e43a3..277fdbc9f2 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -35,6 +35,7 @@ #ifdef RTE_LIB_SECURITY #include #endif +#include #include "ixgbe_logs.h" #include "base/ixgbe_api.h" @@ -4168,7 +4169,12 @@ ixgbevf_check_link(struct ixgbe_hw *hw, ixgbe_link_speed *speed, /* if the read failed it could just be a mailbox collision, best wait * until we are called again and don't report an error */ - if (mbx->ops[0].read(hw, &in_msg, 1, 0)) + + /* + * on MinGW, the read op call is interpreted as call into read() macro, + * so avoid calling it directly. + */ + if ((mbx->ops[0].read)(hw, &in_msg, 1, 0)) goto out; if (!(in_msg & IXGBE_VT_MSGTYPE_CTS)) { @@ -6924,6 +6930,12 @@ ixgbe_timesync_enable(struct rte_eth_dev *dev) struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); uint32_t tsync_ctl; uint32_t tsauxc; + struct timespec ts; + + memset(&ts, 0, sizeof(struct timespec)); + + /* get current system time */ + clock_gettime(CLOCK_REALTIME, &ts); /* Stop the timesync system time. */ IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, 0x0); @@ -6956,6 +6968,9 @@ ixgbe_timesync_enable(struct rte_eth_dev *dev) IXGBE_WRITE_FLUSH(hw); + /* ixgbe uses zero-based timestamping so only adjust timecounter */ + ixgbe_timesync_write_time(dev, &ts); + return 0; } -- 2.43.5