DPDK patches and discussions
 help / color / mirror / Atom feed
From: John McNamara <john.mcnamara@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v2 1/7] ethdev: add support for ieee1588 timestamping
Date: Mon, 29 Jun 2015 14:42:18 +0100	[thread overview]
Message-ID: <1435585344-26652-2-git-send-email-john.mcnamara@intel.com> (raw)
In-Reply-To: <1435585344-26652-1-git-send-email-john.mcnamara@intel.com>

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 <john.mcnamara@intel.com>
---
 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 02cd07f..dae390a 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
@@ -3644,3 +3644,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 f1219ac..6d382ee 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
@@ -1233,6 +1233,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 {
@@ -1391,6 +1406,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;
 };
 
 /**
@@ -3641,4 +3665,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 012a82e..7e55f23 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -98,6 +98,10 @@ DPDK_2.0 {
 	rte_eth_stats;
 	rte_eth_stats_get;
 	rte_eth_stats_reset;
+	rte_eth_timesync_disable;
+	rte_eth_timesync_enable;
+	rte_eth_timesync_read_rx_timestamp;
+	rte_eth_timesync_read_tx_timestamp;
 	rte_eth_tx_burst;
 	rte_eth_tx_queue_setup;
 	rte_eth_xstats_get;
-- 
1.8.1.4

  reply	other threads:[~2015-06-29 13:42 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-29 13:42 [dpdk-dev] [PATCH v2 0/7] " John McNamara
2015-06-29 13:42 ` John McNamara [this message]
2015-07-02 10:17   ` [dpdk-dev] [PATCH v2 1/7] " Thomas Monjalon
2015-07-02 15:14     ` Mcnamara, John
2015-06-29 13:42 ` [dpdk-dev] [PATCH v2 2/7] e1000: " John McNamara
2015-06-29 13:42 ` [dpdk-dev] [PATCH v2 3/7] ixgbe: " John McNamara
2015-06-29 13:42 ` [dpdk-dev] [PATCH v2 4/7] i40e: " John McNamara
2015-06-29 13:42 ` [dpdk-dev] [PATCH v2 5/7] app/testpmd: refactor ieee1588 forwarding John McNamara
2015-06-29 13:42 ` [dpdk-dev] [PATCH v2 6/7] doc: document ieee1588 forwarding mode John McNamara
2015-06-29 13:42 ` [dpdk-dev] [PATCH v2 7/7] abi: announce mbuf addition for ieee1588 in DPDK 2.2 John McNamara
2015-07-02  1:24 ` [dpdk-dev] [PATCH v2 0/7] ethdev: add support for ieee1588 timestamping Lu, Wenzhuo
2015-07-02 15:16 ` [dpdk-dev] [PATCH v3 " John McNamara
2015-07-02 15:16   ` [dpdk-dev] [PATCH v3 1/7] " John McNamara
2015-07-02 15:16   ` [dpdk-dev] [PATCH v3 2/7] e1000: " John McNamara
2015-07-02 15:16   ` [dpdk-dev] [PATCH v3 3/7] ixgbe: " John McNamara
2015-07-02 15:16   ` [dpdk-dev] [PATCH v3 4/7] i40e: " John McNamara
2015-07-02 15:16   ` [dpdk-dev] [PATCH v3 5/7] app/testpmd: refactor ieee1588 forwarding John McNamara
2015-07-02 15:16   ` [dpdk-dev] [PATCH v3 6/7] doc: document ieee1588 forwarding mode John McNamara
2015-07-02 15:16   ` [dpdk-dev] [PATCH v3 7/7] abi: announce mbuf addition for ieee1588 in DPDK 2.2 John McNamara
2015-07-06 13:16     ` Thomas Monjalon
2015-07-08 13:10       ` Bruce Richardson
2015-07-09 15:51         ` Thomas Monjalon
2015-07-09 16:01           ` Bruce Richardson
2015-07-03  8:22   ` [dpdk-dev] [PATCH v3 0/7] ethdev: add support for ieee1588 timestamping Lu, Wenzhuo
2015-07-08  1:59   ` Fu, JingguoX

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1435585344-26652-2-git-send-email-john.mcnamara@intel.com \
    --to=john.mcnamara@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).