From patchwork Fri Oct 30 09:43:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mrzyglod X-Patchwork-Id: 8339 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 3D5388E6C; Fri, 30 Oct 2015 10:45:20 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 061F88E6A for ; Fri, 30 Oct 2015 10:45:18 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP; 30 Oct 2015 02:45:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,217,1444719600"; d="scan'208";a="838722414" Received: from unknown ([10.217.248.15]) by orsmga002.jf.intel.com with SMTP; 30 Oct 2015 02:45:16 -0700 Received: by (sSMTP sendmail emulation); Fri, 30 Oct 2015 10:44:33 +0100 From: Daniel Mrzyglod To: dev@dpdk.org Date: Fri, 30 Oct 2015 10:43:19 +0100 Message-Id: <1446198204-9852-2-git-send-email-danielx.t.mrzyglod@intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1446198204-9852-1-git-send-email-danielx.t.mrzyglod@intel.com> References: <1443799208-9408-1-git-send-email-danielx.t.mrzyglod@intel.com> <1446198204-9852-1-git-send-email-danielx.t.mrzyglod@intel.com> Subject: [dpdk-dev] [PATCH v2 1/6] ethdev: add additional ieee1588 support functions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add additional functions to support the existing IEEE1588 functionality. * rte_eth_timesync_settime(), function to set the device clock time. * rte_eth_timesync_gettime, function to get the device clock time. * rte_eth_timesync_adjust, function to adjust the device clock time. Signed-off-by: Daniel Mrzyglod --- doc/guides/rel_notes/release_2_2.rst | 3 ++ lib/librte_ether/rte_ethdev.c | 36 +++++++++++++++++++ lib/librte_ether/rte_ethdev.h | 64 ++++++++++++++++++++++++++++++++++ lib/librte_ether/rte_ether_version.map | 9 +++++ 4 files changed, 112 insertions(+) diff --git a/doc/guides/rel_notes/release_2_2.rst b/doc/guides/rel_notes/release_2_2.rst index 89e4d58..b83ef7f 100644 --- a/doc/guides/rel_notes/release_2_2.rst +++ b/doc/guides/rel_notes/release_2_2.rst @@ -123,6 +123,9 @@ API Changes * The devargs union field virtual is renamed to virt for C++ compatibility. +* Add new functions in ethdev to support IEEE1588: rte_eth_timesync_time_adjust() + rte_eth_timesync_time_get(), rte_eth_timesync_time_set() + ABI Changes ----------- diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index f593f6e..d7d2714 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -3284,6 +3284,42 @@ rte_eth_timesync_read_tx_timestamp(uint8_t port_id, struct timespec *timestamp) } int +rte_eth_timesync_time_adjust(uint8_t port_id, int64_t delta) +{ + struct rte_eth_dev *dev; + + VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + dev = &rte_eth_devices[port_id]; + + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->timesync_time_adjust, -ENOTSUP); + return (*dev->dev_ops->timesync_time_adjust)(dev, delta); +} + +int +rte_eth_timesync_time_get(uint8_t port_id, struct timespec *timestamp) +{ + struct rte_eth_dev *dev; + + VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + dev = &rte_eth_devices[port_id]; + + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->timesync_time_get, -ENOTSUP); + return (*dev->dev_ops->timesync_time_get)(dev, timestamp); +} + +int +rte_eth_timesync_time_set(uint8_t port_id, struct timespec *timestamp) +{ + struct rte_eth_dev *dev; + + VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + dev = &rte_eth_devices[port_id]; + + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->timesync_time_set, -ENOTSUP); + return (*dev->dev_ops->timesync_time_set)(dev, timestamp); +} + +int rte_eth_dev_get_reg_length(uint8_t port_id) { struct rte_eth_dev *dev; diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 8a8c82b..c639064 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1129,6 +1129,17 @@ typedef int (*eth_timesync_read_tx_timestamp_t)(struct rte_eth_dev *dev, struct timespec *timestamp); /**< @internal Function used to read a TX IEEE1588/802.1AS timestamp. */ +typedef int (*eth_timesync_time_adjust)(struct rte_eth_dev *dev, int64_t); +/**< @internal Function used to adjust device clock */ + +typedef int (*eth_timesync_time_get)(struct rte_eth_dev *dev, + struct timespec *timestamp); +/**< @internal Function used to get time from device clock. */ + +typedef int (*eth_timesync_time_set)(struct rte_eth_dev *dev, + struct timespec *timestamp); +/**< @internal Function used to get time from device clock */ + typedef int (*eth_get_reg_length_t)(struct rte_eth_dev *dev); /**< @internal Retrieve device register count */ @@ -1312,6 +1323,12 @@ struct eth_dev_ops { eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp; /** Read the IEEE1588/802.1AS TX timestamp. */ eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp; + /** Adjust the device clock */ + eth_timesync_time_adjust timesync_time_adjust; + /** Get the device clock timespec */ + eth_timesync_time_get timesync_time_get; + /** Set the device clock timespec */ + eth_timesync_time_set timesync_time_set; }; /** @@ -3598,6 +3615,53 @@ extern int rte_eth_timesync_read_rx_timestamp(uint8_t port_id, extern int rte_eth_timesync_read_tx_timestamp(uint8_t port_id, struct timespec *timestamp); +/** + * Adjust the timesync clock on an Ethernet device.. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param delta + * The adjustment in nanoseconds + * + * @return + * - 0: Success. + * - -ENODEV: The port ID is invalid. + * - -ENOTSUP: The function is not supported by the Ethernet driver. + */ +extern int rte_eth_timesync_time_adjust(uint8_t port_id, int64_t delta); + +/** + * Read the time from the timesync clock on an Ethernet device. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param time + * Pointer to the timespec struct. + * + * @return + * - 0: Success. + */ +extern int rte_eth_timesync_time_get(uint8_t port_id, + struct timespec *time); + + +/** + * Set the time of the timesync clock on an Ethernet device. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param time + * Pointer to the timespec struct. + * + * @return + * - 0: Success. + * - -EINVAL: No timestamp is available. + * - -ENODEV: The port ID is invalid. + * - -ENOTSUP: The function is not supported by the Ethernet driver. + */ +extern int rte_eth_timesync_time_set(uint8_t port_id, + struct timespec *time); + #ifdef __cplusplus } #endif diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map index 8345a6c..78b46c1 100644 --- a/lib/librte_ether/rte_ether_version.map +++ b/lib/librte_ether/rte_ether_version.map @@ -127,3 +127,12 @@ DPDK_2.1 { rte_eth_timesync_read_tx_timestamp; } DPDK_2.0; + +DPDK_2.2 { + global: + + rte_eth_timesync_time_adjust; + rte_eth_timesync_time_get; + rte_eth_timesync_time_set; + +} DPDK_2.1;