DPDK patches and discussions
 help / color / mirror / Atom feed
From: Liming Sun <lsun@ezchip.com>
To: <dev@dpdk.org>
Subject: [dpdk-dev] [PATCH v4 2/2] driver/net/mpipe: some code optimization
Date: Tue, 9 Feb 2016 23:04:30 -0500	[thread overview]
Message-ID: <1455077070-6666-2-git-send-email-lsun@ezchip.com> (raw)
In-Reply-To: <1455077070-6666-1-git-send-email-lsun@ezchip.com>

This commit includes two small code optimization.
1. use __insn_fetchadd4() instead of rte_atomic32_xxx() in
   mpipe_dp_enter/mpipe_dp_exit to avoid the nnecessary memory
   fence.
2. replace the calling of rte_pktmbuf_reset() in mpipe_recv_mbuf()
   with specific code to avoid some duplicated initializations.

Signed-off-by: Liming Sun <lsun@ezchip.com>
Acked-by: Zhigang Lu <zlu@ezchip.com>
---
 drivers/net/mpipe/mpipe_tilegx.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/net/mpipe/mpipe_tilegx.c b/drivers/net/mpipe/mpipe_tilegx.c
index 5845511..8d006fa 100644
--- a/drivers/net/mpipe/mpipe_tilegx.c
+++ b/drivers/net/mpipe/mpipe_tilegx.c
@@ -451,13 +451,13 @@ static inline void
 mpipe_dp_enter(struct mpipe_dev_priv *priv)
 {
 	__insn_mtspr(SPR_DSTREAM_PF, 0);
-	rte_atomic32_inc(&priv->dp_count);
+	__insn_fetchadd4(&priv->dp_count, 1);
 }
 
 static inline void
 mpipe_dp_exit(struct mpipe_dev_priv *priv)
 {
-	rte_atomic32_dec(&priv->dp_count);
+	__insn_fetchadd4(&priv->dp_count, -1);
 }
 
 static inline void
@@ -484,12 +484,20 @@ mpipe_recv_mbuf(struct mpipe_dev_priv *priv, gxio_mpipe_idesc_t *idesc,
 	uint16_t size = gxio_mpipe_idesc_get_xfer_size(idesc);
 	struct rte_mbuf *mbuf = RTE_PTR_SUB(va, priv->rx_offset);
 
-	rte_pktmbuf_reset(mbuf);
 	mbuf->data_off = (uintptr_t)va - (uintptr_t)mbuf->buf_addr;
-	mbuf->port     = in_port;
-	mbuf->data_len = size;
+	mbuf->nb_segs = 1;
+	mbuf->port = in_port;
+	mbuf->ol_flags = 0;
+	if (gxio_mpipe_idesc_get_ethertype(idesc) == ETHER_TYPE_IPv4)
+		mbuf->packet_type = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L2_ETHER;
+	else if (gxio_mpipe_idesc_get_ethertype(idesc) == ETHER_TYPE_IPv6)
+		mbuf->packet_type = RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L2_ETHER;
+	else
+		mbuf->packet_type = RTE_PTYPE_UNKNOWN;
 	mbuf->pkt_len  = size;
+	mbuf->data_len = size;
 	mbuf->hash.rss = gxio_mpipe_idesc_get_flow_hash(idesc);
+	mbuf->next = NULL;
 
 	PMD_DEBUG_RX("%s: RX mbuf %p, buffer %p, buf_addr %p, size %d\n",
 		     mpipe_name(priv), mbuf, va, mbuf->buf_addr, size);
-- 
1.8.3.1

  reply	other threads:[~2016-02-10  4:04 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-22 19:49 [dpdk-dev] [PATCH 0/2] Some enhancement of the tilegx mpipe driver Liming Sun
2015-12-22 19:49 ` [dpdk-dev] [PATCH 1/2] driver/net/mpipe: add rte_vect.h and enable CONFIG_RTE_LIBRTE_LPM Liming Sun
2016-01-08  7:41   ` Tony Lu
2015-12-22 19:49 ` [dpdk-dev] [PATCH 2/2] driver/net/mpipe: fix the crash/hung issue when testpmd quits Liming Sun
2016-01-08  7:49   ` Tony Lu
2016-01-08 14:39   ` [dpdk-dev] [PATCH v2 1/2] driver/net/mpipe: add rte_vect.h and enable CONFIG_RTE_LIBRTE_LPM Liming Sun
2016-01-08 14:39     ` [dpdk-dev] [PATCH v2 2/2] driver/net/mpipe: fix the crash/hung issue when testpmd quits Liming Sun
2016-02-09 15:59       ` Bruce Richardson
2016-02-10 14:50         ` Liming Sun
2016-02-10  5:15       ` [dpdk-dev] [PATCH v3] " Liming Sun
2016-02-26 17:35         ` Bruce Richardson
2016-02-09 15:55     ` [dpdk-dev] [PATCH v2 1/2] driver/net/mpipe: add rte_vect.h and enable CONFIG_RTE_LIBRTE_LPM Bruce Richardson
2016-02-09 18:40       ` Liming Sun
2016-02-10 14:52       ` Liming Sun
2016-02-10  3:46     ` [dpdk-dev] [PATCH v3 1/2] eal/tile: " Liming Sun
2016-02-10  3:47       ` [dpdk-dev] [PATCH v3 2/2] driver/net/mpipe: some code optimization Liming Sun
2016-02-10  4:04     ` [dpdk-dev] [PATCH v4 1/2] eal/tile: add rte_vect.h and enable CONFIG_RTE_LIBRTE_LPM Liming Sun
2016-02-10  4:04       ` Liming Sun [this message]
2016-03-08 19:59       ` Thomas Monjalon
2016-03-17 14:04         ` Thomas Monjalon

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=1455077070-6666-2-git-send-email-lsun@ezchip.com \
    --to=lsun@ezchip.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).