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 2DCD05A88 for ; Thu, 9 Jul 2015 15:30:24 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP; 09 Jul 2015 06:30:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,440,1432623600"; d="scan'208";a="759074451" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga002.fm.intel.com with ESMTP; 09 Jul 2015 06:30:22 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id t69DULJa010597; Thu, 9 Jul 2015 14:30:21 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id t69DUL0m014020; Thu, 9 Jul 2015 14:30:21 +0100 Received: (from jmcnam2x@localhost) by sivswdev02.ir.intel.com with id t69DULJA014016; Thu, 9 Jul 2015 14:30:21 +0100 From: John McNamara To: dev@dpdk.org Date: Thu, 9 Jul 2015 14:30:14 +0100 Message-Id: <1436448620-13972-2-git-send-email-john.mcnamara@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1436448620-13972-1-git-send-email-john.mcnamara@intel.com> References: <1436448620-13972-1-git-send-email-john.mcnamara@intel.com> Subject: [dpdk-dev] [PATCH v4 1/7] ethdev: add support for ieee1588 timestamping 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, 09 Jul 2015 13:30:25 -0000 Add ethdev API to enable and read IEEE1588/802.1AS PTP timestamps from devices that support it. The following functions are added: rte_eth_timesync_enable() rte_eth_timesync_disable() rte_eth_timesync_read_rx_timestamp() rte_eth_timesync_read_tx_timestamp() Signed-off-by: John McNamara --- lib/librte_ether/rte_ethdev.c | 70 +++++++++++++++++++++++++- lib/librte_ether/rte_ethdev.h | 90 +++++++++++++++++++++++++++++++++- lib/librte_ether/rte_ether_version.map | 4 ++ 3 files changed, 162 insertions(+), 2 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 44d41b8..9ba0e24 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -1,7 +1,7 @@ /*- * BSD LICENSE * - * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. + * Copyright(c) 2010-2015 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -3304,3 +3304,71 @@ rte_eth_dev_set_mc_addr_list(uint8_t port_id, FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_mc_addr_list, -ENOTSUP); return dev->dev_ops->set_mc_addr_list(dev, mc_addr_set, nb_mc_addr); } + +int +rte_eth_timesync_enable(uint8_t port_id) +{ + struct rte_eth_dev *dev; + + if (!rte_eth_dev_is_valid_port(port_id)) { + PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); + return -ENODEV; + } + + dev = &rte_eth_devices[port_id]; + + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->timesync_enable, -ENOTSUP); + return (*dev->dev_ops->timesync_enable)(dev); +} + +int +rte_eth_timesync_disable(uint8_t port_id) +{ + struct rte_eth_dev *dev; + + if (!rte_eth_dev_is_valid_port(port_id)) { + PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); + return -ENODEV; + } + + dev = &rte_eth_devices[port_id]; + + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->timesync_disable, -ENOTSUP); + return (*dev->dev_ops->timesync_disable)(dev); +} + +int +rte_eth_timesync_read_rx_timestamp(uint8_t port_id, struct timespec *timestamp, + uint32_t flags) +{ + struct rte_eth_dev *dev; + + if (!rte_eth_dev_is_valid_port(port_id)) { + PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); + return -ENODEV; + } + + dev = &rte_eth_devices[port_id]; + + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->timesync_read_rx_timestamp, + -ENOTSUP); + return (*dev->dev_ops->timesync_read_rx_timestamp)(dev, timestamp, + flags); +} + +int +rte_eth_timesync_read_tx_timestamp(uint8_t port_id, struct timespec *timestamp) +{ + struct rte_eth_dev *dev; + + if (!rte_eth_dev_is_valid_port(port_id)) { + PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); + return -ENODEV; + } + + dev = &rte_eth_devices[port_id]; + + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->timesync_read_tx_timestamp, + -ENOTSUP); + return (*dev->dev_ops->timesync_read_tx_timestamp)(dev, timestamp); +} diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 438d59a..79bde89 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1,7 +1,7 @@ /*- * BSD LICENSE * - * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. + * Copyright(c) 2010-2015 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1240,6 +1240,21 @@ typedef int (*eth_set_mc_addr_list_t)(struct rte_eth_dev *dev, uint32_t nb_mc_addr); /**< @internal set the list of multicast addresses on an Ethernet device */ +typedef int (*eth_timesync_enable_t)(struct rte_eth_dev *dev); +/**< @internal Function used to enable IEEE1588/802.1AS timestamping. */ + +typedef int (*eth_timesync_disable_t)(struct rte_eth_dev *dev); +/**< @internal Function used to disable IEEE1588/802.1AS timestamping. */ + +typedef int (*eth_timesync_read_rx_timestamp_t)(struct rte_eth_dev *dev, + struct timespec *timestamp, + uint32_t flags); +/**< @internal Function used to read an RX IEEE1588/802.1AS timestamp. */ + +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. */ + #ifdef RTE_NIC_BYPASS enum { @@ -1398,6 +1413,15 @@ struct eth_dev_ops { rss_hash_conf_get_t rss_hash_conf_get; eth_filter_ctrl_t filter_ctrl; /**< common filter control*/ eth_set_mc_addr_list_t set_mc_addr_list; /**< set list of mcast addrs */ + + /** Turn IEEE1588/802.1AS timestamping on. */ + eth_timesync_enable_t timesync_enable; + /** Turn IEEE1588/802.1AS timestamping off. */ + eth_timesync_disable_t timesync_disable; + /** Read the IEEE1588/802.1AS RX timestamp. */ + 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; }; /** @@ -3647,4 +3671,68 @@ int rte_eth_dev_set_mc_addr_list(uint8_t port_id, struct ether_addr *mc_addr_set, uint32_t nb_mc_addr); + +/** + * Enable IEEE1588/802.1AS timestamping for an Ethernet device. + * + * @param port_id + * The port identifier of the Ethernet device. + * + * @return + * - 0: Success. + * - -ENODEV: The port ID is invalid. + * - -ENOTSUP: The function is not supported by the Ethernet driver. + */ +extern int rte_eth_timesync_enable(uint8_t port_id); + +/** + * Disable IEEE1588/802.1AS timestamping for an Ethernet device. + * + * @param port_id + * The port identifier of the Ethernet device. + * + * @return + * - 0: Success. + * - -ENODEV: The port ID is invalid. + * - -ENOTSUP: The function is not supported by the Ethernet driver. + */ +extern int rte_eth_timesync_disable(uint8_t port_id); + +/** + * Read an IEEE1588/802.1AS RX timestamp from an Ethernet device. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param timestamp + * Pointer to the timestamp struct. + * @param flags + * Device specific flags. Used to pass the RX timesync register index to + * i40e. Unused in igb/ixgbe, pass 0 instead. + * + * @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_read_rx_timestamp(uint8_t port_id, + struct timespec *timestamp, + uint32_t flags); + +/** + * Read an IEEE1588/802.1AS TX timestamp from an Ethernet device. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param timestamp + * Pointer to the timestamp 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_read_tx_timestamp(uint8_t port_id, + struct timespec *timestamp); #endif /* _RTE_ETHDEV_H_ */ diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map index e3c8fa1..39baf11 100644 --- a/lib/librte_ether/rte_ether_version.map +++ b/lib/librte_ether/rte_ether_version.map @@ -110,5 +110,9 @@ DPDK_2.1 { global: rte_eth_dev_set_mc_addr_list; + rte_eth_timesync_disable; + rte_eth_timesync_enable; + rte_eth_timesync_read_rx_timestamp; + rte_eth_timesync_read_tx_timestamp; } DPDK_2.0; -- 1.8.1.4