From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 63CE091CC for ; Thu, 12 Nov 2015 13:55:49 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP; 12 Nov 2015 04:55:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,281,1444719600"; d="scan'208";a="835527410" Received: from sie-lab-214-214.ir.intel.com (HELO sie-lab-214-174.ir.intel.com) ([10.237.214.214]) by fmsmga001.fm.intel.com with ESMTP; 12 Nov 2015 04:55:48 -0800 From: Pablo de Lara To: dev@dpdk.org Date: Thu, 12 Nov 2015 12:55:31 +0000 Message-Id: <1447332938-201120-2-git-send-email-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1447332938-201120-1-git-send-email-pablo.de.lara.guarch@intel.com> References: <1446732366-10044-1-git-send-email-danielx.t.mrzyglod@intel.com> <1447332938-201120-1-git-send-email-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH v6 1/8] 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: , X-List-Received-Date: Thu, 12 Nov 2015 12:55:49 -0000 From: Daniel Mrzyglod Add additional functions to support the existing IEEE1588 functionality. * rte_eth_timesync_write_time(): set the device clock time. * rte_eth_timesync_read_time(): get the device clock time. * rte_eth_timesync_adjust_time(): adjust the device clock time. Signed-off-by: Daniel Mrzyglod Signed-off-by: Pablo de Lara Reviewed-by: John McNamara --- doc/guides/rel_notes/release_2_2.rst | 4 ++ lib/librte_ether/rte_ethdev.c | 36 +++++++++++++++++ lib/librte_ether/rte_ethdev.h | 71 ++++++++++++++++++++++++++++++++++ lib/librte_ether/rte_ether_version.map | 3 ++ 4 files changed, 114 insertions(+) diff --git a/doc/guides/rel_notes/release_2_2.rst b/doc/guides/rel_notes/release_2_2.rst index 59dda59..2ef6c29 100644 --- a/doc/guides/rel_notes/release_2_2.rst +++ b/doc/guides/rel_notes/release_2_2.rst @@ -94,6 +94,10 @@ New Features * **Added port hotplug support to xenvirt.** +* **Added API in in ethdev to support IEEE1588.** + + Added functions to read and write and adjust system time in the NIC. + Resolved Issues --------------- diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index e0e1dca..daca6fa 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -3193,6 +3193,42 @@ rte_eth_timesync_read_tx_timestamp(uint8_t port_id, struct timespec *timestamp) } int +rte_eth_timesync_adjust_time(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_adjust_time, -ENOTSUP); + return (*dev->dev_ops->timesync_adjust_time)(dev, delta); +} + +int +rte_eth_timesync_read_time(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_read_time, -ENOTSUP); + return (*dev->dev_ops->timesync_read_time)(dev, timestamp); +} + +int +rte_eth_timesync_write_time(uint8_t port_id, const 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_write_time, -ENOTSUP); + return (*dev->dev_ops->timesync_write_time)(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 48a540d..b7be4b8 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1206,6 +1206,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_adjust_time)(struct rte_eth_dev *dev, int64_t); +/**< @internal Function used to adjust the device clock */ + +typedef int (*eth_timesync_read_time)(struct rte_eth_dev *dev, + struct timespec *timestamp); +/**< @internal Function used to get time from the device clock. */ + +typedef int (*eth_timesync_write_time)(struct rte_eth_dev *dev, + const struct timespec *timestamp); +/**< @internal Function used to get time from the device clock */ + typedef int (*eth_get_reg_length_t)(struct rte_eth_dev *dev); /**< @internal Retrieve device register count */ @@ -1400,6 +1411,12 @@ struct eth_dev_ops { /** Get DCB information */ eth_get_dcb_info get_dcb_info; + /** Adjust the device clock.*/ + eth_timesync_adjust_time timesync_adjust_time; + /** Get the device clock time. */ + eth_timesync_read_time timesync_read_time; + /** Set the device clock time. */ + eth_timesync_write_time timesync_write_time; }; /** @@ -3755,6 +3772,60 @@ extern int rte_eth_timesync_read_tx_timestamp(uint8_t port_id, struct timespec *timestamp); /** + * Adjust the timesync clock on an Ethernet device. + * + * This is usually used in conjunction with other Ethdev timesync functions to + * synchronize the device time using the IEEE1588/802.1AS protocol. + * + * @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_adjust_time(uint8_t port_id, int64_t delta); + +/** + * Read the time from the timesync clock on an Ethernet device. + * + * This is usually used in conjunction with other Ethdev timesync functions to + * synchronize the device time using the IEEE1588/802.1AS protocol. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param time + * Pointer to the timespec struct that holds the time. + * + * @return + * - 0: Success. + */ +extern int rte_eth_timesync_read_time(uint8_t port_id, struct timespec *time); + +/** + * Set the time of the timesync clock on an Ethernet device. + * + * This is usually used in conjunction with other Ethdev timesync functions to + * synchronize the device time using the IEEE1588/802.1AS protocol. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param time + * Pointer to the timespec struct that holds the time. + * + * @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_write_time(uint8_t port_id, + const struct timespec *time); + +/** * Copy pci device info to the Ethernet device data. * * @param eth_dev diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map index 9149aa7..57ad1ef 100644 --- a/lib/librte_ether/rte_ether_version.map +++ b/lib/librte_ether/rte_ether_version.map @@ -135,5 +135,8 @@ DPDK_2.2 { rte_eth_dev_get_dcb_info; rte_eth_rx_queue_info_get; rte_eth_tx_queue_info_get; + rte_eth_timesync_adjust_time; + rte_eth_timesync_read_time; + rte_eth_timesync_write_time; } DPDK_2.1; -- 1.8.1.4