From: John McNamara <john.mcnamara@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 1/4] ethdev: add support for ieee1588 timestamping
Date: Fri, 5 Jun 2015 16:19:04 +0100 [thread overview]
Message-ID: <1433517547-19537-2-git-send-email-john.mcnamara@intel.com> (raw)
In-Reply-To: <1433517547-19537-1-git-send-email-john.mcnamara@intel.com>
Add ethdev API to enable and read IEEE1588 PTP timestamps from
nics that support it. The following functions are added:
rte_eth_ieee1588_enable()
rte_eth_ieee1588_disable()
rte_eth_ieee1588_read_rx_timestamp()
rte_eth_ieee1588_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 | 88 +++++++++++++++++++++++++++++++++-
lib/librte_ether/rte_ether_version.map | 4 ++
3 files changed, 160 insertions(+), 2 deletions(-)
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 5a94654..f85a1cd 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
@@ -3627,3 +3627,71 @@ rte_eth_remove_tx_callback(uint8_t port_id, uint16_t queue_id,
/* Callback wasn't found. */
return -EINVAL;
}
+
+int
+rte_eth_ieee1588_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->ieee1588_enable, -ENOTSUP);
+ return (*dev->dev_ops->ieee1588_enable)(dev);
+}
+
+int
+rte_eth_ieee1588_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->ieee1588_disable, -ENOTSUP);
+ return (*dev->dev_ops->ieee1588_disable)(dev);
+}
+
+int
+rte_eth_ieee1588_read_rx_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->ieee1588_read_rx_timestamp,
+ -ENOTSUP);
+ return (*dev->dev_ops->ieee1588_read_rx_timestamp)(dev, timestamp);
+}
+
+
+int
+rte_eth_ieee1588_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->ieee1588_read_tx_timestamp,
+ -ENOTSUP);
+ return (*dev->dev_ops->ieee1588_read_tx_timestamp)(dev, timestamp);
+}
+
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 16dbe00..abe9b1c 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
@@ -1220,6 +1220,7 @@ typedef int (*eth_mirror_rule_reset_t)(struct rte_eth_dev *dev,
uint8_t rule_id);
/**< @internal Remove a traffic mirroring rule on an Ethernet device */
+
typedef int (*eth_udp_tunnel_add_t)(struct rte_eth_dev *dev,
struct rte_eth_udp_tunnel *tunnel_udp);
/**< @internal Add tunneling UDP info */
@@ -1228,6 +1229,20 @@ typedef int (*eth_udp_tunnel_del_t)(struct rte_eth_dev *dev,
struct rte_eth_udp_tunnel *tunnel_udp);
/**< @internal Delete tunneling UDP info */
+typedef int (*eth_ieee1588_enable_t)(struct rte_eth_dev *dev);
+/**< @internal Function used to enable IEEE1588 PTP timestamping. */
+
+typedef int (*eth_ieee1588_disable_t)(struct rte_eth_dev *dev);
+/**< @internal Function used to disable IEEE1588 PTP timestamping. */
+
+typedef int (*eth_ieee1588_read_rx_timestamp_t)(struct rte_eth_dev *dev,
+ struct timespec *timestamp);
+/**< @internal Function used to read an RX IEEE1588 PTP timestamp. */
+
+typedef int (*eth_ieee1588_read_tx_timestamp_t)(struct rte_eth_dev *dev,
+ struct timespec *timestamp);
+/**< @internal Function used to read a TX IEEE1588 PTP timestamp. */
+
#ifdef RTE_NIC_BYPASS
@@ -1386,6 +1401,16 @@ struct eth_dev_ops {
/** Get current RSS hash configuration. */
rss_hash_conf_get_t rss_hash_conf_get;
eth_filter_ctrl_t filter_ctrl; /**< common filter control*/
+
+ /** Turn IEEE1588 timestamping on. */
+ eth_ieee1588_enable_t ieee1588_enable;
+ /** Turn IEEE1588 timestamping off. */
+ eth_ieee1588_disable_t ieee1588_disable;
+ /** Read the IEEE1588 RX timestamp. */
+ eth_ieee1588_read_rx_timestamp_t ieee1588_read_rx_timestamp;
+ /** Read the IEEE1588 TX timestamp. */
+ eth_ieee1588_read_tx_timestamp_t ieee1588_read_tx_timestamp;
+
};
/**
@@ -3611,6 +3636,67 @@ int rte_eth_remove_rx_callback(uint8_t port_id, uint16_t queue_id,
int rte_eth_remove_tx_callback(uint8_t port_id, uint16_t queue_id,
struct rte_eth_rxtx_callback *user_cb);
+/**
+ * Enable IEEE1588 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_ieee1588_enable(uint8_t port_id);
+
+/**
+ * Disable IEEE1588 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_ieee1588_disable(uint8_t port_id);
+
+/**
+ * Read an IEEE1588 RX 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_ieee1588_read_rx_timestamp(uint8_t port_id,
+ struct timespec *timestamp);
+
+/**
+ * Read an IEEE1588 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_ieee1588_read_tx_timestamp(uint8_t port_id,
+ struct timespec *timestamp);
+
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
index a2d25a6..9a0fe20 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -76,6 +76,10 @@ DPDK_2.0 {
rte_eth_dev_wd_timeout_store;
rte_eth_devices;
rte_eth_driver_register;
+ rte_eth_ieee1588_disable;
+ rte_eth_ieee1588_enable;
+ rte_eth_ieee1588_read_rx_timestamp;
+ rte_eth_ieee1588_read_tx_timestamp;
rte_eth_led_off;
rte_eth_led_on;
rte_eth_link;
--
1.8.1.4
next prev parent reply other threads:[~2015-06-05 15:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-05 15:19 [dpdk-dev] [PATCH 0/4] " John McNamara
2015-06-05 15:19 ` John McNamara [this message]
2015-06-05 15:19 ` [dpdk-dev] [PATCH 2/4] e1000: " John McNamara
2015-06-05 15:19 ` [dpdk-dev] [PATCH 3/4] ixgbe: " John McNamara
2015-06-05 15:19 ` [dpdk-dev] [PATCH 4/4] app/testpmd: refactor ieee1588 forwarding John McNamara
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=1433517547-19537-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).