All of lore.kernel.org
 help / color / mirror / Atom feed
From: Raslan Darawsheh <rasland@mellanox.com>
To: dev@dpdk.org
Cc: yskoh@mellanox.com
Subject: [PATCH v3 3/3] net/mlx5: add Rx HW timestamp
Date: Thu, 28 Sep 2017 19:48:23 +0300	[thread overview]
Message-ID: <1506617303-32509-3-git-send-email-rasland@mellanox.com> (raw)
In-Reply-To: <1506617303-32509-1-git-send-email-rasland@mellanox.com>

Expose Rx HW timestamp to packet mbufs.

Signed-off-by :Raslan Darawsheh <rasland@mellanox.com>
Acked-by: Yongseok Koh <yskoh@mellanox.com>
---
 drivers/net/mlx5/mlx5_ethdev.c       |  3 ++-
 drivers/net/mlx5/mlx5_rxq.c          |  6 +++++-
 drivers/net/mlx5/mlx5_rxtx.c         |  5 +++++
 drivers/net/mlx5/mlx5_rxtx.h         |  3 ++-
 drivers/net/mlx5/mlx5_rxtx_vec_sse.c | 13 ++++++++++++-
 5 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index 6f17a95..f5fc7d6 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -674,7 +674,8 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
 		  DEV_RX_OFFLOAD_UDP_CKSUM |
 		  DEV_RX_OFFLOAD_TCP_CKSUM) :
 		 0) |
-		(priv->hw_vlan_strip ? DEV_RX_OFFLOAD_VLAN_STRIP : 0);
+		(priv->hw_vlan_strip ? DEV_RX_OFFLOAD_VLAN_STRIP : 0) |
+		DEV_RX_OFFLOAD_TIMESTAMP;
 	if (!priv->mps)
 		info->tx_offload_capa = DEV_TX_OFFLOAD_VLAN_INSERT;
 	if (priv->hw_csum)
diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index 22448c9..77e980b 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -930,6 +930,8 @@ rxq_ctrl_setup(struct rte_eth_dev *dev, struct rxq_ctrl *rxq_ctrl,
 	if (priv->hw_csum_l2tun)
 		tmpl.rxq.csum_l2tun =
 			!!dev->data->dev_conf.rxmode.hw_ip_checksum;
+	tmpl.rxq.hw_timestamp =
+			!!dev->data->dev_conf.rxmode.hw_timestamp;
 	/* Use the entire RX mempool as the memory region. */
 	tmpl.mr = mlx5_mp2mr(priv->pd, mp);
 	if (tmpl.mr == NULL) {
@@ -951,7 +953,7 @@ rxq_ctrl_setup(struct rte_eth_dev *dev, struct rxq_ctrl *rxq_ctrl,
 	attr.cq = (struct ibv_cq_init_attr_ex){
 		.comp_mask = 0,
 	};
-	if (priv->cqe_comp) {
+	if (priv->cqe_comp && !tmpl.rxq.hw_timestamp) {
 		attr.cq.comp_mask |= IBV_CQ_INIT_ATTR_MASK_FLAGS;
 		attr.cq.flags |= MLX5DV_CQ_INIT_ATTR_MASK_COMPRESSED_CQE;
 		/*
@@ -960,6 +962,8 @@ rxq_ctrl_setup(struct rte_eth_dev *dev, struct rxq_ctrl *rxq_ctrl,
 		 */
 		if (rxq_check_vec_support(&tmpl.rxq) < 0)
 			cqe_n = (desc * 2) - 1; /* Double the number of CQEs. */
+	} else if (priv->cqe_comp && tmpl.rxq.hw_timestamp) {
+		DEBUG("Rx CQE compression is disabled for HW timestamp");
 	}
 	tmpl.cq = ibv_create_cq(priv->ctx, cqe_n, NULL, tmpl.channel, 0);
 	if (tmpl.cq == NULL) {
diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
index 4808348..3476122 100644
--- a/drivers/net/mlx5/mlx5_rxtx.c
+++ b/drivers/net/mlx5/mlx5_rxtx.c
@@ -1870,6 +1870,11 @@ mlx5_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
 				pkt->vlan_tci =
 					rte_be_to_cpu_16(cqe->vlan_info);
 			}
+			if (rxq->hw_timestamp) {
+				pkt->timestamp =
+					rte_be_to_cpu_64(cqe->timestamp);
+				pkt->ol_flags |= PKT_RX_TIMESTAMP;
+			}
 			if (rxq->crc_present)
 				len -= ETHER_CRC_LEN;
 			PKT_LEN(pkt) = len;
diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h
index e352a1e..2d7b960 100644
--- a/drivers/net/mlx5/mlx5_rxtx.h
+++ b/drivers/net/mlx5/mlx5_rxtx.h
@@ -101,6 +101,7 @@ struct rxq_zip {
 struct rxq {
 	unsigned int csum:1; /* Enable checksum offloading. */
 	unsigned int csum_l2tun:1; /* Same for L2 tunnels. */
+	unsigned int hw_timestamp:1; /* Enable HW timestamp. */
 	unsigned int vlan_strip:1; /* Enable VLAN stripping. */
 	unsigned int crc_present:1; /* CRC must be subtracted. */
 	unsigned int sges_n:2; /* Log 2 of SGEs (max buffers per packet). */
@@ -110,7 +111,7 @@ struct rxq {
 	unsigned int rss_hash:1; /* RSS hash result is enabled. */
 	unsigned int mark:1; /* Marked flow available on the queue. */
 	unsigned int pending_err:1; /* CQE error needs to be handled. */
-	unsigned int :7; /* Remaining bits. */
+	unsigned int :6; /* Remaining bits. */
 	volatile uint32_t *rq_db;
 	volatile uint32_t *cq_db;
 	uint16_t rq_ci;
diff --git a/drivers/net/mlx5/mlx5_rxtx_vec_sse.c b/drivers/net/mlx5/mlx5_rxtx_vec_sse.c
index a7ef17e..ad97cd7 100644
--- a/drivers/net/mlx5/mlx5_rxtx_vec_sse.c
+++ b/drivers/net/mlx5/mlx5_rxtx_vec_sse.c
@@ -744,7 +744,8 @@ rxq_cq_to_ptype_oflags_v(struct rxq *rxq, __m128i cqes[4], __m128i op_err,
 {
 	__m128i pinfo0, pinfo1;
 	__m128i pinfo, ptype;
-	__m128i ol_flags = _mm_set1_epi32(rxq->rss_hash * PKT_RX_RSS_HASH);
+	__m128i ol_flags = _mm_set1_epi32(rxq->rss_hash * PKT_RX_RSS_HASH |
+					  rxq->hw_timestamp * PKT_RX_TIMESTAMP);
 	__m128i cv_flags;
 	const __m128i zero = _mm_setzero_si128();
 	const __m128i ptype_mask =
@@ -1206,6 +1207,16 @@ rxq_burst_v(struct rxq *rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
 		rxq->pending_err |= !!_mm_cvtsi128_si64(opcode);
 		/* D.5 fill in mbuf - rearm_data and packet_type. */
 		rxq_cq_to_ptype_oflags_v(rxq, cqes, opcode, &pkts[pos]);
+		if (rxq->hw_timestamp) {
+			pkts[pos]->timestamp =
+				rte_be_to_cpu_64(cq[pos].timestamp);
+			pkts[pos + 1]->timestamp =
+				rte_be_to_cpu_64(cq[pos + p1].timestamp);
+			pkts[pos + 2]->timestamp =
+				rte_be_to_cpu_64(cq[pos + p2].timestamp);
+			pkts[pos + 3]->timestamp =
+				rte_be_to_cpu_64(cq[pos + p3].timestamp);
+		}
 #ifdef MLX5_PMD_SOFT_COUNTERS
 		/* Add up received bytes count. */
 		byte_cnt = _mm_shuffle_epi8(op_own, len_shuf_mask);
-- 
2.7.4

  parent reply	other threads:[~2017-09-28 16:48 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-22 13:46 [PATCH 1/3] ethdev: expose Rx hardware timestamp Raslan Darawsheh
2017-08-22 13:46 ` [PATCH 2/3] app/testpmd: add Rx timestamp in testpmd Raslan Darawsheh
2017-08-22 13:46 ` [PATCH 3/3] net/mlx5: add hardware timestamp Raslan Darawsheh
2017-08-23 15:02   ` Nélio Laranjeiro
2017-08-24  7:46   ` [PATCH v2 1/3] ethdev: expose Rx " Raslan Darawsheh
2017-08-24  7:46     ` [PATCH v2 2/3] app/testpmd: add Rx timestamp in testpmd Raslan Darawsheh
2017-08-24 13:49       ` Nélio Laranjeiro
2017-08-24  7:46     ` [PATCH v2 3/3] net/mlx5: add hardware timestamp Raslan Darawsheh
2017-08-24 14:01       ` Nélio Laranjeiro
2017-08-24 13:47     ` [PATCH v2 1/3] ethdev: expose Rx " Nélio Laranjeiro
2017-09-28 16:48     ` [PATCH v3 1/3] ethdev: add Rx HW timestamp capability Raslan Darawsheh
2017-09-28 16:48       ` [PATCH v3 2/3] app/testpmd: add Rx HW timestamp Raslan Darawsheh
2017-09-28 16:48       ` Raslan Darawsheh [this message]
2017-09-29  7:25       ` [PATCH v3 1/3] ethdev: add Rx HW timestamp capability Andrew Rybchenko
2017-10-01  6:44         ` Shahaf Shuler
2017-10-02 14:50       ` [PATCH " Raslan Darawsheh
2017-10-02 14:50         ` [PATCH 2/3] app/testpmd: add Rx HW timestamp Raslan Darawsheh
2017-10-02 14:50         ` [PATCH 3/3] net/mlx5: " Raslan Darawsheh
2017-10-02 18:48         ` [PATCH 1/3] ethdev: add Rx HW timestamp capability Ferruh Yigit
2017-10-03  0:39           ` Yongseok Koh
2017-10-03  6:33       ` [PATCH v5 " Raslan Darawsheh
2017-10-03  6:33         ` [PATCH v5 2/3] app/testpmd: add Rx HW timestamp Raslan Darawsheh
2017-10-03  6:33         ` [PATCH v5 3/3] net/mlx5: " Raslan Darawsheh
2017-10-03  6:40         ` [PATCH v5 1/3] ethdev: add Rx HW timestamp capability Andrew Rybchenko
2017-10-03  6:53           ` Yongseok Koh
2017-10-03  7:24             ` Andrew Rybchenko
2017-10-03 11:00       ` [PATCH v6 " Raslan Darawsheh
2017-10-03 11:00         ` [PATCH v6 2/3] app/testpmd: add Rx HW timestamp Raslan Darawsheh
2017-10-05 23:11           ` Yongseok Koh
2017-10-03 11:00         ` [PATCH v6 3/3] net/mlx5: " Raslan Darawsheh
2017-10-05 23:23           ` Yongseok Koh
2017-10-08  8:24           ` [PATCH v7 1/3] ethdev: add Rx HW timestamp capability Raslan Darawsheh
2017-10-08  8:24             ` [PATCH v7 2/3] app/testpmd: add Rx HW timestamp Raslan Darawsheh
2017-10-08  8:24             ` [PATCH v7 3/3] net/mlx5: " Raslan Darawsheh
2017-10-09 19:17               ` Ferruh Yigit
2017-10-10  7:45           ` [PATCH v8 1/3] ethdev: add Rx HW timestamp capability Raslan Darawsheh
2017-10-10  7:45             ` [PATCH v8 2/3] app/testpmd: add Rx HW timestamp Raslan Darawsheh
2017-10-10  7:45             ` [PATCH v8 3/3] net/mlx5: " Raslan Darawsheh
2017-10-10 13:33             ` [PATCH v8 1/3] ethdev: add Rx HW timestamp capability Yongseok Koh
2017-10-10 14:37           ` [PATCH v9 " Raslan Darawsheh
2017-10-10 14:37             ` [PATCH v9 2/3] app/testpmd: add Rx HW timestamp Raslan Darawsheh
2017-10-10 14:37             ` [PATCH v9 3/3] net/mlx5: " Raslan Darawsheh
2017-10-10 14:40               ` Yongseok Koh
2017-10-11  1:14             ` [PATCH v9 1/3] ethdev: add Rx HW timestamp capability Ferruh Yigit
2017-10-11  1:22               ` Yongseok Koh
2017-10-11  1:30                 ` Ferruh Yigit
2017-10-04  5:57         ` [PATCH v6 " Shahaf Shuler
2017-10-06  0:54         ` Ferruh Yigit
2017-10-02 14:01     ` [PATCH " Raslan Darawsheh
2017-10-02 14:01       ` [PATCH 2/3] app/testpmd: add Rx HW timestamp Raslan Darawsheh
2017-10-02 14:01       ` [PATCH 3/3] net/mlx5: " Raslan Darawsheh

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=1506617303-32509-3-git-send-email-rasland@mellanox.com \
    --to=rasland@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=yskoh@mellanox.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.