DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/4] ethdev: add support for ieee1588 timestamping
@ 2015-06-05 15:19 John McNamara
  2015-06-05 15:19 ` [dpdk-dev] [PATCH 1/4] " John McNamara
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: John McNamara @ 2015-06-05 15:19 UTC (permalink / raw)
  To: dev

This patchset adds ethdev API to enable and read IEEE1588 PTP timestamps from
devices 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()

The "ieee1588" forwarding mode in testpmd is also refactored to demonstrate
the new API and to clean up the code.

Adds support for igb and ixgbe. Support for i40e will follow in V2.

I would be interested in getting feedback from maintainers of non-Intel pmds
on whether this interface is sufficient to initialise, read from, and stop,
IEEE1588 functionality on other devices.


John McNamara (4):
  ethdev: add support for ieee1588 timestamping
  e1000: add support for ieee1588 timestamping
  ixgbe: add support for ieee1588 timestamping
  app/testpmd: refactor ieee1588 forwarding

 app/test-pmd/ieee1588fwd.c             | 443 +--------------------------------
 drivers/net/e1000/igb_ethdev.c         | 118 +++++++++
 drivers/net/ixgbe/ixgbe_ethdev.c       | 118 +++++++++
 lib/librte_ether/rte_ethdev.c          |  70 +++++-
 lib/librte_ether/rte_ethdev.h          |  88 ++++++-
 lib/librte_ether/rte_ether_version.map |   4 +
 6 files changed, 409 insertions(+), 432 deletions(-)

-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dpdk-dev] [PATCH 1/4] ethdev: add support for ieee1588 timestamping
  2015-06-05 15:19 [dpdk-dev] [PATCH 0/4] ethdev: add support for ieee1588 timestamping John McNamara
@ 2015-06-05 15:19 ` John McNamara
  2015-06-05 15:19 ` [dpdk-dev] [PATCH 2/4] e1000: " John McNamara
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: John McNamara @ 2015-06-05 15:19 UTC (permalink / raw)
  To: dev

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dpdk-dev] [PATCH 2/4] e1000: add support for ieee1588 timestamping
  2015-06-05 15:19 [dpdk-dev] [PATCH 0/4] ethdev: add support for ieee1588 timestamping John McNamara
  2015-06-05 15:19 ` [dpdk-dev] [PATCH 1/4] " John McNamara
@ 2015-06-05 15:19 ` 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
  3 siblings, 0 replies; 5+ messages in thread
From: John McNamara @ 2015-06-05 15:19 UTC (permalink / raw)
  To: dev

Add e1000/igb support for new ethdev APIs to enable and read
IEEE1588 PTP timestamps.

Signed-off-by: John McNamara <john.mcnamara@intel.com>
---
 drivers/net/e1000/igb_ethdev.c | 118 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 118 insertions(+)

diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index e4b370d..f4e5527 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -74,6 +74,12 @@
 #define IGB_8_BIT_WIDTH  CHAR_BIT
 #define IGB_8_BIT_MASK   UINT8_MAX
 
+/* IEEE1588 additional values. */
+#define E1000_ETQF_FILTER_1588 3
+#define E1000_TIMINCA_INCVALUE   16000000
+#define E1000_TIMINCA_INIT       ((0x02 << E1000_TIMINCA_16NS_SHIFT) \
+				  | E1000_TIMINCA_INCVALUE)
+
 static int  eth_igb_configure(struct rte_eth_dev *dev);
 static int  eth_igb_start(struct rte_eth_dev *dev);
 static void eth_igb_stop(struct rte_eth_dev *dev);
@@ -194,6 +200,13 @@ static int eth_igb_filter_ctrl(struct rte_eth_dev *dev,
 		     enum rte_filter_op filter_op,
 		     void *arg);
 
+static int igb_ieee1588_enable(struct rte_eth_dev *dev);
+static int igb_ieee1588_disable(struct rte_eth_dev *dev);
+static int igb_ieee1588_read_rx_timestamp(struct rte_eth_dev *dev,
+					  struct timespec *timestamp);
+static int igb_ieee1588_read_tx_timestamp(struct rte_eth_dev *dev,
+					  struct timespec *timestamp);
+
 /*
  * Define VF Stats MACRO for Non "cleared on read" register
  */
@@ -269,6 +282,10 @@ static const struct eth_dev_ops eth_igb_ops = {
 	.rss_hash_update      = eth_igb_rss_hash_update,
 	.rss_hash_conf_get    = eth_igb_rss_hash_conf_get,
 	.filter_ctrl          = eth_igb_filter_ctrl,
+	.ieee1588_enable            = igb_ieee1588_enable,
+	.ieee1588_disable           = igb_ieee1588_disable,
+	.ieee1588_read_rx_timestamp = igb_ieee1588_read_rx_timestamp,
+	.ieee1588_read_tx_timestamp = igb_ieee1588_read_tx_timestamp,
 };
 
 /*
@@ -3642,6 +3659,107 @@ eth_igb_filter_ctrl(struct rte_eth_dev *dev,
 	return ret;
 }
 
+static int
+igb_ieee1588_enable(struct rte_eth_dev *dev)
+{
+	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	uint32_t tsync_ctl;
+
+	/* Start incrementing the System Time registers used to timestamp PTP
+	 * packets.
+	 */
+	E1000_WRITE_REG(hw, E1000_TIMINCA, E1000_TIMINCA_INIT);
+
+	/* Enable L2 filtering of IEEE1588 Ethernet frame types. */
+	E1000_WRITE_REG(hw, E1000_ETQF(E1000_ETQF_FILTER_1588),
+			(ETHER_TYPE_1588 |
+			 E1000_ETQF_FILTER_ENABLE |
+			 E1000_ETQF_1588));
+
+	/* Enable timestamping of received PTP packets. */
+	tsync_ctl = E1000_READ_REG(hw, E1000_TSYNCRXCTL);
+	tsync_ctl |= E1000_TSYNCRXCTL_ENABLED;
+
+	E1000_WRITE_REG(hw, E1000_TSYNCRXCTL, tsync_ctl);
+
+	/* Enable Timestamping of transmitted PTP packets. */
+	tsync_ctl = E1000_READ_REG(hw, E1000_TSYNCTXCTL);
+	tsync_ctl |= E1000_TSYNCTXCTL_ENABLED;
+
+	E1000_WRITE_REG(hw, E1000_TSYNCTXCTL, tsync_ctl);
+
+	return 0;
+}
+
+static int
+igb_ieee1588_disable(struct rte_eth_dev *dev)
+{
+	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	uint32_t tsync_ctl;
+
+	/* Disable Timestamping of transmitted PTP packets. */
+	tsync_ctl = E1000_READ_REG(hw, E1000_TSYNCTXCTL);
+	tsync_ctl &= ~E1000_TSYNCTXCTL_ENABLED;
+
+	E1000_WRITE_REG(hw, E1000_TSYNCTXCTL, tsync_ctl);
+
+	/* Disable timestamping of received PTP packets. */
+	tsync_ctl = E1000_READ_REG(hw, E1000_TSYNCRXCTL);
+	tsync_ctl &= ~E1000_TSYNCRXCTL_ENABLED;
+
+	E1000_WRITE_REG(hw, E1000_TSYNCRXCTL, tsync_ctl);
+
+	/* Disable L2 filtering of IEEE1588 Ethernet frame types. */
+	E1000_WRITE_REG(hw, E1000_ETQF(E1000_ETQF_FILTER_1588), 0);
+
+	/* Stop incrementating the System Time registers. */
+	E1000_WRITE_REG(hw, E1000_TIMINCA, 0);
+
+	return 0;
+}
+
+static int
+igb_ieee1588_read_rx_timestamp(struct rte_eth_dev *dev,
+			       struct timespec *timestamp)
+{
+	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	uint32_t tsync_rxctl;
+	uint32_t rx_stmpl;
+	uint32_t rx_stmph;
+
+	tsync_rxctl = E1000_READ_REG(hw, E1000_TSYNCRXCTL);
+	if ((tsync_rxctl & 0x01) == 0)
+		return -EINVAL;
+
+	rx_stmpl = E1000_READ_REG(hw, E1000_RXSTMPL);
+	rx_stmph = E1000_READ_REG(hw, E1000_RXSTMPH);
+	timestamp->tv_sec = (uint64_t)(((uint64_t)rx_stmph << 32) | rx_stmpl);
+	timestamp->tv_nsec = 0;
+
+	return  0;
+}
+
+static int
+igb_ieee1588_read_tx_timestamp(struct rte_eth_dev *dev,
+			       struct timespec *timestamp)
+{
+	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	uint32_t tsync_txctl;
+	uint32_t tx_stmpl;
+	uint32_t tx_stmph;
+
+	tsync_txctl = E1000_READ_REG(hw, E1000_TSYNCTXCTL);
+	if ((tsync_txctl & 0x01) == 0)
+		return -EINVAL;
+
+	tx_stmpl = E1000_READ_REG(hw, E1000_TXSTMPL);
+	tx_stmph = E1000_READ_REG(hw, E1000_TXSTMPH);
+	timestamp->tv_sec = (uint64_t)(((uint64_t)tx_stmph << 32) | tx_stmpl);
+	timestamp->tv_nsec = 0;
+
+	return  0;
+}
+
 static struct rte_driver pmd_igb_drv = {
 	.type = PMD_PDEV,
 	.init = rte_igb_pmd_init,
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dpdk-dev] [PATCH 3/4] ixgbe: add support for ieee1588 timestamping
  2015-06-05 15:19 [dpdk-dev] [PATCH 0/4] ethdev: add support for ieee1588 timestamping John McNamara
  2015-06-05 15:19 ` [dpdk-dev] [PATCH 1/4] " John McNamara
  2015-06-05 15:19 ` [dpdk-dev] [PATCH 2/4] e1000: " John McNamara
@ 2015-06-05 15:19 ` John McNamara
  2015-06-05 15:19 ` [dpdk-dev] [PATCH 4/4] app/testpmd: refactor ieee1588 forwarding John McNamara
  3 siblings, 0 replies; 5+ messages in thread
From: John McNamara @ 2015-06-05 15:19 UTC (permalink / raw)
  To: dev

Add ixgbe support for new ethdev APIs to enable and read IEEE1588
PTP timestamps.

Signed-off-by: John McNamara <john.mcnamara@intel.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 118 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 118 insertions(+)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 0d9f9b2..dc72011 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -116,6 +116,12 @@
 
 #define IXGBE_QUEUE_STAT_COUNTERS (sizeof(hw_stats->qprc) / sizeof(hw_stats->qprc[0]))
 
+/* IEEE1588 additional values. */
+#define IXGBE_TIMINCA_16NS_SHIFT 24
+#define IXGBE_TIMINCA_INCVALUE   16000000
+#define IXGBE_TIMINCA_INIT       ((0x02 << IXGBE_TIMINCA_16NS_SHIFT) \
+				  | IXGBE_TIMINCA_INCVALUE)
+
 static int eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev);
 static int  ixgbe_dev_configure(struct rte_eth_dev *dev);
 static int  ixgbe_dev_start(struct rte_eth_dev *dev);
@@ -257,6 +263,13 @@ static int ixgbe_dev_filter_ctrl(struct rte_eth_dev *dev,
 		     void *arg);
 static int ixgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);
 
+static int ixgbe_ieee1588_enable(struct rte_eth_dev *dev);
+static int ixgbe_ieee1588_disable(struct rte_eth_dev *dev);
+static int ixgbe_ieee1588_read_rx_timestamp(struct rte_eth_dev *dev,
+					    struct timespec *timestamp);
+static int ixgbe_ieee1588_read_tx_timestamp(struct rte_eth_dev *dev,
+					    struct timespec *timestamp);
+
 /*
  * Define VF Stats MACRO for Non "cleared on read" register
  */
@@ -381,6 +394,10 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
 	.rss_hash_update      = ixgbe_dev_rss_hash_update,
 	.rss_hash_conf_get    = ixgbe_dev_rss_hash_conf_get,
 	.filter_ctrl          = ixgbe_dev_filter_ctrl,
+	.ieee1588_enable            = ixgbe_ieee1588_enable,
+	.ieee1588_disable           = ixgbe_ieee1588_disable,
+	.ieee1588_read_rx_timestamp = ixgbe_ieee1588_read_rx_timestamp,
+	.ieee1588_read_tx_timestamp = ixgbe_ieee1588_read_tx_timestamp,
 };
 
 /*
@@ -4439,6 +4456,107 @@ ixgbe_dev_filter_ctrl(struct rte_eth_dev *dev,
 	return ret;
 }
 
+static int
+ixgbe_ieee1588_enable(struct rte_eth_dev *dev)
+{
+	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	uint32_t tsync_ctl;
+
+	/* Start incrementing the System Time registers used to timestamp PTP
+	 * packets.
+	 */
+	IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, IXGBE_TIMINCA_INIT);
+
+	/* Enable L2 filtering of IEEE1588 Ethernet frame types. */
+	IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_1588),
+			(ETHER_TYPE_1588 |
+			 IXGBE_ETQF_FILTER_EN |
+			 IXGBE_ETQF_1588));
+
+	/* Enable timestamping of received PTP packets. */
+	tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
+	tsync_ctl |= IXGBE_TSYNCRXCTL_ENABLED;
+
+	IXGBE_WRITE_REG(hw, IXGBE_TSYNCRXCTL, tsync_ctl);
+
+	/* Enable Timestamping of transmitted PTP packets. */
+	tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
+	tsync_ctl |= IXGBE_TSYNCTXCTL_ENABLED;
+
+	IXGBE_WRITE_REG(hw, IXGBE_TSYNCTXCTL, tsync_ctl);
+
+	return 0;
+}
+
+static int
+ixgbe_ieee1588_disable(struct rte_eth_dev *dev)
+{
+	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	uint32_t tsync_ctl;
+
+	/* Disable Timestamping of transmitted PTP packets. */
+	tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
+	tsync_ctl &= ~IXGBE_TSYNCTXCTL_ENABLED;
+
+	IXGBE_WRITE_REG(hw, IXGBE_TSYNCTXCTL, tsync_ctl);
+
+	/* Disable timestamping of received PTP packets. */
+	tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
+	tsync_ctl &= ~IXGBE_TSYNCRXCTL_ENABLED;
+
+	IXGBE_WRITE_REG(hw, IXGBE_TSYNCRXCTL, tsync_ctl);
+
+	/* Disable L2 filtering of IEEE1588 Ethernet frame types. */
+	IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_1588), 0);
+
+	/* Stop incrementating the System Time registers. */
+	IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, 0);
+
+	return 0;
+}
+
+static int
+ixgbe_ieee1588_read_rx_timestamp(struct rte_eth_dev *dev,
+				 struct timespec *timestamp)
+{
+	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	uint32_t tsync_rxctl;
+	uint32_t rx_stmpl;
+	uint32_t rx_stmph;
+
+	tsync_rxctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
+	if ((tsync_rxctl & 0x01) == 0)
+		return -EINVAL;
+
+	rx_stmpl = IXGBE_READ_REG(hw, IXGBE_RXSTMPL);
+	rx_stmph = IXGBE_READ_REG(hw, IXGBE_RXSTMPH);
+	timestamp->tv_sec = (uint64_t)(((uint64_t)rx_stmph << 32) | rx_stmpl);
+	timestamp->tv_nsec = 0;
+
+	return  0;
+}
+
+static int
+ixgbe_ieee1588_read_tx_timestamp(struct rte_eth_dev *dev,
+				 struct timespec *timestamp)
+{
+	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	uint32_t tsync_txctl;
+	uint32_t tx_stmpl;
+	uint32_t tx_stmph;
+
+	tsync_txctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
+	if ((tsync_txctl & 0x01) == 0)
+		return -EINVAL;
+
+	tx_stmpl = IXGBE_READ_REG(hw, IXGBE_TXSTMPL);
+	tx_stmph = IXGBE_READ_REG(hw, IXGBE_TXSTMPH);
+	timestamp->tv_sec = (uint64_t)(((uint64_t)tx_stmph << 32) | tx_stmpl);
+	timestamp->tv_nsec = 0;
+
+	return  0;
+}
+
 static struct rte_driver rte_ixgbe_driver = {
 	.type = PMD_PDEV,
 	.init = rte_ixgbe_pmd_init,
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dpdk-dev] [PATCH 4/4] app/testpmd: refactor ieee1588 forwarding
  2015-06-05 15:19 [dpdk-dev] [PATCH 0/4] ethdev: add support for ieee1588 timestamping John McNamara
                   ` (2 preceding siblings ...)
  2015-06-05 15:19 ` [dpdk-dev] [PATCH 3/4] ixgbe: " John McNamara
@ 2015-06-05 15:19 ` John McNamara
  3 siblings, 0 replies; 5+ messages in thread
From: John McNamara @ 2015-06-05 15:19 UTC (permalink / raw)
  To: dev

Refactor the ieee1588_fwd mode in testpmd to use the new ethdev
APIs to enable and read IEEE1588 PTP timestamps.

Signed-off-by: John McNamara <john.mcnamara@intel.com>
---
 app/test-pmd/ieee1588fwd.c | 443 ++-------------------------------------------
 1 file changed, 13 insertions(+), 430 deletions(-)

diff --git a/app/test-pmd/ieee1588fwd.c b/app/test-pmd/ieee1588fwd.c
index 84237c1..b5c4f5a 100644
--- a/app/test-pmd/ieee1588fwd.c
+++ b/app/test-pmd/ieee1588fwd.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
@@ -31,39 +31,9 @@
  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <stdint.h>
-#include <unistd.h>
-#include <inttypes.h>
 
-#include <sys/queue.h>
-#include <sys/stat.h>
-
-#include <rte_common.h>
-#include <rte_byteorder.h>
-#include <rte_log.h>
-#include <rte_debug.h>
 #include <rte_cycles.h>
-#include <rte_memory.h>
-#include <rte_memzone.h>
-#include <rte_launch.h>
-#include <rte_eal.h>
-#include <rte_per_lcore.h>
-#include <rte_lcore.h>
-#include <rte_atomic.h>
-#include <rte_branch_prediction.h>
-#include <rte_ring.h>
-#include <rte_memory.h>
-#include <rte_mempool.h>
-#include <rte_mbuf.h>
-#include <rte_interrupts.h>
-#include <rte_pci.h>
-#include <rte_ether.h>
 #include <rte_ethdev.h>
-#include <rte_string_fns.h>
 
 #include "testpmd.h"
 
@@ -77,6 +47,7 @@ struct ptpv2_msg {
 	uint8_t version; /**< must be 0x02 */
 	uint8_t unused[34];
 };
+
 #define PTP_SYNC_MESSAGE                0x0
 #define PTP_DELAY_REQ_MESSAGE           0x1
 #define PTP_PATH_DELAY_REQ_MESSAGE      0x2
@@ -108,393 +79,18 @@ struct ptpv2_msg {
  * is greater than the previous one.
  */
 
-/*
- * 1GbE 82576 Kawela registers used for IEEE1588 hardware support
- */
-#define IGBE_82576_ETQF(n) (0x05CB0 + (4 * (n)))
-#define IGBE_82576_ETQF_FILTER_ENABLE  (1 << 26)
-#define IGBE_82576_ETQF_1588_TIMESTAMP (1 << 30)
-
-#define IGBE_82576_TSYNCRXCTL  0x0B620
-#define IGBE_82576_TSYNCRXCTL_RXTS_ENABLE (1 << 4)
-
-#define IGBE_82576_RXSTMPL     0x0B624
-#define IGBE_82576_RXSTMPH     0x0B628
-#define IGBE_82576_RXSATRL     0x0B62C
-#define IGBE_82576_RXSATRH     0x0B630
-#define IGBE_82576_TSYNCTXCTL  0x0B614
-#define IGBE_82576_TSYNCTXCTL_TXTS_ENABLE (1 << 4)
-
-#define IGBE_82576_TXSTMPL     0x0B618
-#define IGBE_82576_TXSTMPH     0x0B61C
-#define IGBE_82576_SYSTIML     0x0B600
-#define IGBE_82576_SYSTIMH     0x0B604
-#define IGBE_82576_TIMINCA     0x0B608
-#define IGBE_82576_TIMADJL     0x0B60C
-#define IGBE_82576_TIMADJH     0x0B610
-#define IGBE_82576_TSAUXC      0x0B640
-#define IGBE_82576_TRGTTIML0   0x0B644
-#define IGBE_82576_TRGTTIMH0   0x0B648
-#define IGBE_82576_TRGTTIML1   0x0B64C
-#define IGBE_82576_TRGTTIMH1   0x0B650
-#define IGBE_82576_AUXSTMPL0   0x0B65C
-#define IGBE_82576_AUXSTMPH0   0x0B660
-#define IGBE_82576_AUXSTMPL1   0x0B664
-#define IGBE_82576_AUXSTMPH1   0x0B668
-#define IGBE_82576_TSYNCRXCFG  0x05F50
-#define IGBE_82576_TSSDP       0x0003C
-
-/*
- * 10GbE 82599 Niantic registers used for IEEE1588 hardware support
- */
-#define IXGBE_82599_ETQF(n) (0x05128 + (4 * (n)))
-#define IXGBE_82599_ETQF_FILTER_ENABLE  (1 << 31)
-#define IXGBE_82599_ETQF_1588_TIMESTAMP (1 << 30)
-
-#define IXGBE_82599_TSYNCRXCTL 0x05188
-#define IXGBE_82599_TSYNCRXCTL_RXTS_ENABLE (1 << 4)
-
-#define IXGBE_82599_RXSTMPL    0x051E8
-#define IXGBE_82599_RXSTMPH    0x051A4
-#define IXGBE_82599_RXSATRL    0x051A0
-#define IXGBE_82599_RXSATRH    0x051A8
-#define IXGBE_82599_RXMTRL     0x05120
-#define IXGBE_82599_TSYNCTXCTL 0x08C00
-#define IXGBE_82599_TSYNCTXCTL_TXTS_ENABLE (1 << 4)
-
-#define IXGBE_82599_TXSTMPL    0x08C04
-#define IXGBE_82599_TXSTMPH    0x08C08
-#define IXGBE_82599_SYSTIML    0x08C0C
-#define IXGBE_82599_SYSTIMH    0x08C10
-#define IXGBE_82599_TIMINCA    0x08C14
-#define IXGBE_82599_TIMADJL    0x08C18
-#define IXGBE_82599_TIMADJH    0x08C1C
-#define IXGBE_82599_TSAUXC     0x08C20
-#define IXGBE_82599_TRGTTIML0  0x08C24
-#define IXGBE_82599_TRGTTIMH0  0x08C28
-#define IXGBE_82599_TRGTTIML1  0x08C2C
-#define IXGBE_82599_TRGTTIMH1  0x08C30
-#define IXGBE_82599_AUXSTMPL0  0x08C3C
-#define IXGBE_82599_AUXSTMPH0  0x08C40
-#define IXGBE_82599_AUXSTMPL1  0x08C44
-#define IXGBE_82599_AUXSTMPH1  0x08C48
-
-/**
- * Mandatory ETQF register for IEEE1588 packets filter.
- */
-#define ETQF_FILTER_1588_REG 3
-
-/**
- * Recommended value for increment and period of
- * the Increment Attribute Register.
- */
-#define IEEE1588_TIMINCA_INIT ((0x02 << 24) | 0x00F42400)
-
-/**
- * Data structure with pointers to port-specific functions.
- */
-typedef void (*ieee1588_start_t)(portid_t pi); /**< Start IEEE1588 feature. */
-typedef void (*ieee1588_stop_t)(portid_t pi);  /**< Stop IEEE1588 feature.  */
-typedef int  (*tmst_read_t)(portid_t pi, uint64_t *tmst); /**< Read TMST regs */
-
-struct port_ieee1588_ops {
-	ieee1588_start_t ieee1588_start;
-	ieee1588_stop_t  ieee1588_stop;
-	tmst_read_t      rx_tmst_read;
-	tmst_read_t      tx_tmst_read;
-};
-
-/**
- * 1GbE 82576 IEEE1588 operations.
- */
-static void
-igbe_82576_ieee1588_start(portid_t pi)
-{
-	uint32_t tsync_ctl;
-
-	/*
-	 * Start incrementation of the System Time registers used to
-	 * timestamp PTP packets.
-	 */
-	port_id_pci_reg_write(pi, IGBE_82576_TIMINCA, IEEE1588_TIMINCA_INIT);
-	port_id_pci_reg_write(pi, IGBE_82576_TSAUXC, 0);
-
-	/*
-	 * Enable L2 filtering of IEEE1588 Ethernet frame types.
-	 */
-	port_id_pci_reg_write(pi, IGBE_82576_ETQF(ETQF_FILTER_1588_REG),
-			      (ETHER_TYPE_1588 |
-			       IGBE_82576_ETQF_FILTER_ENABLE |
-			       IGBE_82576_ETQF_1588_TIMESTAMP));
-
-	/*
-	 * Enable timestamping of received PTP packets.
-	 */
-	tsync_ctl = port_id_pci_reg_read(pi, IGBE_82576_TSYNCRXCTL);
-	tsync_ctl |= IGBE_82576_TSYNCRXCTL_RXTS_ENABLE;
-	port_id_pci_reg_write(pi, IGBE_82576_TSYNCRXCTL, tsync_ctl);
-
-	/*
-	 * Enable Timestamping of transmitted PTP packets.
-	 */
-	tsync_ctl = port_id_pci_reg_read(pi, IGBE_82576_TSYNCTXCTL);
-	tsync_ctl |= IGBE_82576_TSYNCTXCTL_TXTS_ENABLE;
-	port_id_pci_reg_write(pi, IGBE_82576_TSYNCTXCTL, tsync_ctl);
-}
-
-static void
-igbe_82576_ieee1588_stop(portid_t pi)
-{
-	uint32_t tsync_ctl;
-
-	/*
-	 * Disable Timestamping of transmitted PTP packets.
-	 */
-	tsync_ctl = port_id_pci_reg_read(pi, IGBE_82576_TSYNCTXCTL);
-	tsync_ctl &= ~IGBE_82576_TSYNCTXCTL_TXTS_ENABLE;
-	port_id_pci_reg_write(pi, IGBE_82576_TSYNCTXCTL, tsync_ctl);
-
-	/*
-	 * Disable timestamping of received PTP packets.
-	 */
-	tsync_ctl = port_id_pci_reg_read(pi, IGBE_82576_TSYNCRXCTL);
-	tsync_ctl &= ~IGBE_82576_TSYNCRXCTL_RXTS_ENABLE;
-	port_id_pci_reg_write(pi, IGBE_82576_TSYNCRXCTL, tsync_ctl);
-
-	/*
-	 * Disable L2 filtering of IEEE1588 Ethernet types.
-	 */
-	port_id_pci_reg_write(pi, IGBE_82576_ETQF(ETQF_FILTER_1588_REG), 0);
-
-	/*
-	 * Stop incrementation of the System Time registers.
-	 */
-	port_id_pci_reg_write(pi, IGBE_82576_TIMINCA, 0);
-}
-
-/**
- * Return the 64-bit value contained in the RX IEEE1588 timestamp registers
- * of a 1GbE 82576 port.
- *
- * @param pi
- *   The port identifier.
- *
- * @param tmst
- *   The address of a 64-bit variable to return the value of the RX timestamp.
- *
- * @return
- *  -1: the RXSTMPL and RXSTMPH registers of the port are not valid.
- *   0: the variable pointed to by the "tmst" parameter contains the value
- *      of the RXSTMPL and RXSTMPH registers of the port.
- */
-static int
-igbe_82576_rx_timestamp_read(portid_t pi, uint64_t *tmst)
-{
-	uint32_t tsync_rxctl;
-	uint32_t rx_stmpl;
-	uint32_t rx_stmph;
-
-	tsync_rxctl = port_id_pci_reg_read(pi, IGBE_82576_TSYNCRXCTL);
-	if ((tsync_rxctl & 0x01) == 0)
-		return (-1);
-
-	rx_stmpl = port_id_pci_reg_read(pi, IGBE_82576_RXSTMPL);
-	rx_stmph = port_id_pci_reg_read(pi, IGBE_82576_RXSTMPH);
-	*tmst = (uint64_t)(((uint64_t) rx_stmph << 32) | rx_stmpl);
-	return (0);
-}
-
-/**
- * Return the 64-bit value contained in the TX IEEE1588 timestamp registers
- * of a 1GbE 82576 port.
- *
- * @param pi
- *   The port identifier.
- *
- * @param tmst
- *   The address of a 64-bit variable to return the value of the TX timestamp.
- *
- * @return
- *  -1: the TXSTMPL and TXSTMPH registers of the port are not valid.
- *   0: the variable pointed to by the "tmst" parameter contains the value
- *      of the TXSTMPL and TXSTMPH registers of the port.
- */
-static int
-igbe_82576_tx_timestamp_read(portid_t pi, uint64_t *tmst)
-{
-	uint32_t tsync_txctl;
-	uint32_t tx_stmpl;
-	uint32_t tx_stmph;
-
-	tsync_txctl = port_id_pci_reg_read(pi, IGBE_82576_TSYNCTXCTL);
-	if ((tsync_txctl & 0x01) == 0)
-		return (-1);
-
-	tx_stmpl = port_id_pci_reg_read(pi, IGBE_82576_TXSTMPL);
-	tx_stmph = port_id_pci_reg_read(pi, IGBE_82576_TXSTMPH);
-	*tmst = (uint64_t)(((uint64_t) tx_stmph << 32) | tx_stmpl);
-	return (0);
-}
-
-static struct port_ieee1588_ops igbe_82576_ieee1588_ops = {
-	.ieee1588_start = igbe_82576_ieee1588_start,
-	.ieee1588_stop  = igbe_82576_ieee1588_stop,
-	.rx_tmst_read   = igbe_82576_rx_timestamp_read,
-	.tx_tmst_read   = igbe_82576_tx_timestamp_read,
-};
-
-/**
- * 10GbE 82599 IEEE1588 operations.
- */
-static void
-ixgbe_82599_ieee1588_start(portid_t pi)
-{
-	uint32_t tsync_ctl;
-
-	/*
-	 * Start incrementation of the System Time registers used to
-	 * timestamp PTP packets.
-	 */
-	port_id_pci_reg_write(pi, IXGBE_82599_TIMINCA, IEEE1588_TIMINCA_INIT);
-
-	/*
-	 * Enable L2 filtering of IEEE1588 Ethernet frame types.
-	 */
-	port_id_pci_reg_write(pi, IXGBE_82599_ETQF(ETQF_FILTER_1588_REG),
-			      (ETHER_TYPE_1588 |
-			       IXGBE_82599_ETQF_FILTER_ENABLE |
-			       IXGBE_82599_ETQF_1588_TIMESTAMP));
-
-	/*
-	 * Enable timestamping of received PTP packets.
-	 */
-	tsync_ctl = port_id_pci_reg_read(pi, IXGBE_82599_TSYNCRXCTL);
-	tsync_ctl |= IXGBE_82599_TSYNCRXCTL_RXTS_ENABLE;
-	port_id_pci_reg_write(pi, IXGBE_82599_TSYNCRXCTL, tsync_ctl);
-
-	/*
-	 * Enable Timestamping of transmitted PTP packets.
-	 */
-	tsync_ctl = port_id_pci_reg_read(pi, IXGBE_82599_TSYNCTXCTL);
-	tsync_ctl |= IXGBE_82599_TSYNCTXCTL_TXTS_ENABLE;
-	port_id_pci_reg_write(pi, IXGBE_82599_TSYNCTXCTL, tsync_ctl);
-}
-
-static void
-ixgbe_82599_ieee1588_stop(portid_t pi)
-{
-	uint32_t tsync_ctl;
-
-	/*
-	 * Disable Timestamping of transmitted PTP packets.
-	 */
-	tsync_ctl = port_id_pci_reg_read(pi, IXGBE_82599_TSYNCTXCTL);
-	tsync_ctl &= ~IXGBE_82599_TSYNCTXCTL_TXTS_ENABLE;
-	port_id_pci_reg_write(pi, IXGBE_82599_TSYNCTXCTL, tsync_ctl);
-
-	/*
-	 * Disable timestamping of received PTP packets.
-	 */
-	tsync_ctl = port_id_pci_reg_read(pi, IXGBE_82599_TSYNCRXCTL);
-	tsync_ctl &= ~IXGBE_82599_TSYNCRXCTL_RXTS_ENABLE;
-	port_id_pci_reg_write(pi, IXGBE_82599_TSYNCRXCTL, tsync_ctl);
-
-	/*
-	 * Disable L2 filtering of IEEE1588 Ethernet frame types.
-	 */
-	port_id_pci_reg_write(pi, IXGBE_82599_ETQF(ETQF_FILTER_1588_REG), 0);
-
-	/*
-	 * Stop incrementation of the System Time registers.
-	 */
-	port_id_pci_reg_write(pi, IXGBE_82599_TIMINCA, 0);
-}
-
-/**
- * Return the 64-bit value contained in the RX IEEE1588 timestamp registers
- * of a 10GbE 82599 port.
- *
- * @param pi
- *   The port identifier.
- *
- * @param tmst
- *   The address of a 64-bit variable to return the value of the TX timestamp.
- *
- * @return
- *  -1: the RX timestamp registers of the port are not valid.
- *   0: the variable pointed to by the "tmst" parameter contains the value
- *      of the RXSTMPL and RXSTMPH registers of the port.
- */
-static int
-ixgbe_82599_rx_timestamp_read(portid_t pi, uint64_t *tmst)
-{
-	uint32_t tsync_rxctl;
-	uint32_t rx_stmpl;
-	uint32_t rx_stmph;
-
-	tsync_rxctl = port_id_pci_reg_read(pi, IXGBE_82599_TSYNCRXCTL);
-	if ((tsync_rxctl & 0x01) == 0)
-		return (-1);
-
-	rx_stmpl = port_id_pci_reg_read(pi, IXGBE_82599_RXSTMPL);
-	rx_stmph = port_id_pci_reg_read(pi, IXGBE_82599_RXSTMPH);
-	*tmst = (uint64_t)(((uint64_t) rx_stmph << 32) | rx_stmpl);
-	return (0);
-}
-
-/**
- * Return the 64-bit value contained in the TX IEEE1588 timestamp registers
- * of a 10GbE 82599 port.
- *
- * @param pi
- *   The port identifier.
- *
- * @param tmst
- *   The address of a 64-bit variable to return the value of the TX timestamp.
- *
- * @return
- *  -1: the TXSTMPL and TXSTMPH registers of the port are not valid.
- *   0: the variable pointed to by the "tmst" parameter contains the value
- *      of the TXSTMPL and TXSTMPH registers of the port.
- */
-static int
-ixgbe_82599_tx_timestamp_read(portid_t pi, uint64_t *tmst)
-{
-	uint32_t tsync_txctl;
-	uint32_t tx_stmpl;
-	uint32_t tx_stmph;
-
-	tsync_txctl = port_id_pci_reg_read(pi, IXGBE_82599_TSYNCTXCTL);
-	if ((tsync_txctl & 0x01) == 0)
-		return (-1);
-
-	tx_stmpl = port_id_pci_reg_read(pi, IXGBE_82599_TXSTMPL);
-	tx_stmph = port_id_pci_reg_read(pi, IXGBE_82599_TXSTMPH);
-	*tmst = (uint64_t)(((uint64_t) tx_stmph << 32) | tx_stmpl);
-	return (0);
-}
-
-static struct port_ieee1588_ops ixgbe_82599_ieee1588_ops = {
-	.ieee1588_start = ixgbe_82599_ieee1588_start,
-	.ieee1588_stop  = ixgbe_82599_ieee1588_stop,
-	.rx_tmst_read   = ixgbe_82599_rx_timestamp_read,
-	.tx_tmst_read   = ixgbe_82599_tx_timestamp_read,
-};
-
 static void
 port_ieee1588_rx_timestamp_check(portid_t pi)
 {
-	struct port_ieee1588_ops *ieee_ops;
-	uint64_t rx_tmst;
+	struct timespec timestamp = {0, 0};
 
-	ieee_ops = (struct port_ieee1588_ops *)ports[pi].fwd_ctx;
-	if (ieee_ops->rx_tmst_read(pi, &rx_tmst) < 0) {
-		printf("Port %u: RX timestamp registers not valid\n",
+	if (rte_eth_ieee1588_read_rx_timestamp(pi, &timestamp) < 0) {
+		printf("Port %u RX timestamp registers not valid\n",
 		       (unsigned) pi);
 		return;
 	}
 	printf("Port %u RX timestamp value 0x%"PRIu64"\n",
-	       (unsigned) pi, rx_tmst);
+	       (unsigned) pi, timestamp.tv_sec);
 }
 
 #define MAX_TX_TMST_WAIT_MICROSECS 1000 /**< 1 milli-second */
@@ -502,26 +98,23 @@ port_ieee1588_rx_timestamp_check(portid_t pi)
 static void
 port_ieee1588_tx_timestamp_check(portid_t pi)
 {
-	struct port_ieee1588_ops *ieee_ops;
-	uint64_t tx_tmst;
-	unsigned wait_us;
+	struct timespec timestamp = {0, 0};
+	unsigned wait_us = 0;
 
-	ieee_ops = (struct port_ieee1588_ops *)ports[pi].fwd_ctx;
-	wait_us = 0;
-	while ((ieee_ops->tx_tmst_read(pi, &tx_tmst) < 0) &&
+	while ((rte_eth_ieee1588_read_tx_timestamp(pi, &timestamp) < 0) &&
 	       (wait_us < MAX_TX_TMST_WAIT_MICROSECS)) {
 		rte_delay_us(1);
 		wait_us++;
 	}
 	if (wait_us >= MAX_TX_TMST_WAIT_MICROSECS) {
-		printf("Port %u: TX timestamp registers not valid after"
+		printf("Port %u TX timestamp registers not valid after"
 		       "%u micro-seconds\n",
 		       (unsigned) pi, (unsigned) MAX_TX_TMST_WAIT_MICROSECS);
 		return;
 	}
 	printf("Port %u TX timestamp value 0x%"PRIu64" validated after "
 	       "%u micro-second%s\n",
-	       (unsigned) pi, tx_tmst, wait_us,
+	       (unsigned) pi, timestamp.tv_sec, wait_us,
 	       (wait_us == 1) ? "" : "s");
 }
 
@@ -627,23 +220,13 @@ ieee1588_packet_fwd(struct fwd_stream *fs)
 static void
 port_ieee1588_fwd_begin(portid_t pi)
 {
-	struct port_ieee1588_ops *ieee_ops;
-
-	if (strcmp(ports[pi].dev_info.driver_name, "rte_igb_pmd") == 0)
-		ieee_ops = &igbe_82576_ieee1588_ops;
-	else
-		ieee_ops = &ixgbe_82599_ieee1588_ops;
-	ports[pi].fwd_ctx = ieee_ops;
-	(ieee_ops->ieee1588_start)(pi);
+	rte_eth_ieee1588_enable(pi);
 }
 
 static void
 port_ieee1588_fwd_end(portid_t pi)
 {
-	struct port_ieee1588_ops *ieee_ops;
-
-	ieee_ops = (struct port_ieee1588_ops *)ports[pi].fwd_ctx;
-	(ieee_ops->ieee1588_stop)(pi);
+	rte_eth_ieee1588_disable(pi);
 }
 
 struct fwd_engine ieee1588_fwd_engine = {
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-06-05 15:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-05 15:19 [dpdk-dev] [PATCH 0/4] ethdev: add support for ieee1588 timestamping John McNamara
2015-06-05 15:19 ` [dpdk-dev] [PATCH 1/4] " John McNamara
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

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).