DPDK patches and discussions
 help / color / mirror / Atom feed
From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 3/4] mlx5: add support for HW packet padding
Date: Mon, 22 Feb 2016 19:19:07 +0100	[thread overview]
Message-ID: <1456165148-28416-4-git-send-email-adrien.mazarguil@6wind.com> (raw)
In-Reply-To: <1456165148-28416-1-git-send-email-adrien.mazarguil@6wind.com>

From: Olga Shern <olgas@mellanox.com>

Environment variable MLX5_PMD_ENABLE_PADDING enables HW packet padding
in PCI bus transactions.

When packet size is cache aligned and CRC stripping is enabled, 4 fewer
bytes are written to the PCI bus. Enabling padding makes such packets
aligned again.

In cases where PCI bandwidth is the bottleneck, padding can improve
performance by 10%.

This is disabled by default since this can also decrease performance for
unaligned packet sizes.

Signed-off-by: Olga Shern <olgas@mellanox.com>
---
 doc/guides/nics/mlx5.rst               | 14 ++++++++++++++
 doc/guides/rel_notes/release_16_04.rst |  5 +++++
 drivers/net/mlx5/Makefile              |  5 +++++
 drivers/net/mlx5/mlx5.c                | 19 +++++++++++++++++++
 drivers/net/mlx5/mlx5.h                |  4 ++++
 drivers/net/mlx5/mlx5_rxq.c            | 10 ++++++++++
 6 files changed, 57 insertions(+)

diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst
index df07146..66fe0d9 100644
--- a/doc/guides/nics/mlx5.rst
+++ b/doc/guides/nics/mlx5.rst
@@ -155,6 +155,20 @@ Environment variables
   lower performance when there is no backpressure, it is not enabled by
   default.
 
+- ``MLX5_PMD_ENABLE_PADDING``
+
+  Enables HW packet padding in PCI bus transactions.
+
+  When packet size is cache aligned and CRC stripping is enabled, 4 fewer
+  bytes are written to the PCI bus. Enabling padding makes such packets
+  aligned again.
+
+  In cases where PCI bandwidth is the bottleneck, padding can improve
+  performance by 10%.
+
+  This is disabled by default since this can also decrease performance for
+  unaligned packet sizes.
+
 Run-time configuration
 ~~~~~~~~~~~~~~~~~~~~~~
 
diff --git a/doc/guides/rel_notes/release_16_04.rst b/doc/guides/rel_notes/release_16_04.rst
index 08f7592..a3a30fd 100644
--- a/doc/guides/rel_notes/release_16_04.rst
+++ b/doc/guides/rel_notes/release_16_04.rst
@@ -87,6 +87,11 @@ This section should contain new features added in this release. Sample format:
 
   Implemented TX support in secondary processes (like mlx4).
 
+* **mlx5: Added optional packet padding by HW.**
+
+  Added an option to make PCI bus transactions rounded to multiple of 64
+  bytes for better cache alignment.
+
 
 Resolved Issues
 ---------------
diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile
index 7076ae3..712c0a9 100644
--- a/drivers/net/mlx5/Makefile
+++ b/drivers/net/mlx5/Makefile
@@ -137,6 +137,11 @@ mlx5_autoconf.h: $(RTE_SDK)/scripts/auto-config-h.sh
 		infiniband/verbs.h \
 		enum IBV_EXP_CQ_RX_TCP_PACKET \
 		$(AUTOCONF_OUTPUT)
+	$Q sh -- '$<' '$@' \
+		HAVE_EXP_CREATE_WQ_FLAG_RX_END_PADDING \
+		infiniband/verbs.h \
+		enum IBV_EXP_CREATE_WQ_FLAG_RX_END_PADDING \
+		$(AUTOCONF_OUTPUT)
 
 $(SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD):.c=.o): mlx5_autoconf.h
 
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 998e6f0..8baef28 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -68,6 +68,25 @@
 #include "mlx5_defs.h"
 
 /**
+ * Retrieve integer value from environment variable.
+ *
+ * @param[in] name
+ *   Environment variable name.
+ *
+ * @return
+ *   Integer value, 0 if the variable is not set.
+ */
+int
+mlx5_getenv_int(const char *name)
+{
+	const char *val = getenv(name);
+
+	if (val == NULL)
+		return 0;
+	return atoi(val);
+}
+
+/**
  * DPDK callback to close the device.
  *
  * Destroy all queues and objects, free memory.
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index bad9283..436b70b 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -159,6 +159,10 @@ priv_unlock(struct priv *priv)
 	rte_spinlock_unlock(&priv->lock);
 }
 
+/* mlx5.c */
+
+int mlx5_getenv_int(const char *);
+
 /* mlx5_ethdev.c */
 
 struct priv *mlx5_get_priv(struct rte_eth_dev *dev);
diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index 3d84f41..0efa7a3 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -1258,6 +1258,16 @@ rxq_setup(struct rte_eth_dev *dev, struct rxq *rxq, uint16_t desc,
 				  0),
 #endif /* HAVE_EXP_DEVICE_ATTR_VLAN_OFFLOADS */
 	};
+
+#ifdef HAVE_EXP_CREATE_WQ_FLAG_RX_END_PADDING
+	if (mlx5_getenv_int("MLX5_PMD_ENABLE_PADDING")) {
+		INFO("%p: packet padding is enabled on queue %p",
+		     (void *)dev, (void *)rxq);
+		attr.wq.flags = IBV_EXP_CREATE_WQ_FLAG_RX_END_PADDING;
+		attr.wq.comp_mask |= IBV_EXP_CREATE_WQ_FLAGS;
+	}
+#endif /* HAVE_EXP_CREATE_WQ_FLAG_RX_END_PADDING */
+
 	tmpl.wq = ibv_exp_create_wq(priv->ctx, &attr.wq);
 	if (tmpl.wq == NULL) {
 		ret = (errno ? errno : EINVAL);
-- 
2.1.4

  parent reply	other threads:[~2016-02-22 18:19 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-22 18:19 [dpdk-dev] [PATCH 0/4] Implement missing features in mlx5 Adrien Mazarguil
2016-02-22 18:19 ` [dpdk-dev] [PATCH 1/4] mlx5: add callbacks to support link (up / down) changes Adrien Mazarguil
2016-02-22 18:19 ` [dpdk-dev] [PATCH 2/4] mlx5: allow operation in secondary processes Adrien Mazarguil
2016-02-22 18:19 ` Adrien Mazarguil [this message]
2016-02-22 18:19 ` [dpdk-dev] [PATCH 4/4] mlx5: add VLAN insertion offload Adrien Mazarguil
2016-03-03 14:27 ` [dpdk-dev] [PATCH v2 0/5] Implement missing features in mlx5 Adrien Mazarguil
2016-03-03 14:27   ` [dpdk-dev] [PATCH v2 1/5] mlx5: add callbacks to support link (up / down) changes Adrien Mazarguil
2016-03-03 14:27   ` [dpdk-dev] [PATCH v2 2/5] mlx5: allow operation in secondary processes Adrien Mazarguil
2016-03-03 14:27   ` [dpdk-dev] [PATCH v2 3/5] mlx5: add RX CRC stripping configuration Adrien Mazarguil
2016-03-03 14:27   ` [dpdk-dev] [PATCH v2 4/5] mlx5: add support for HW packet padding Adrien Mazarguil
2016-03-03 14:27   ` [dpdk-dev] [PATCH v2 5/5] mlx5: add VLAN insertion offload Adrien Mazarguil
2016-03-11 15:24     ` Bruce Richardson
2016-03-16 13:45       ` Adrien Mazarguil
2016-03-17 15:38   ` [dpdk-dev] [PATCH v3 0/5] Implement missing features in mlx5 Adrien Mazarguil
2016-03-17 15:38     ` [dpdk-dev] [PATCH v3 1/5] mlx5: add callbacks to support link (up / down) changes Adrien Mazarguil
2016-03-17 15:38     ` [dpdk-dev] [PATCH v3 2/5] mlx5: allow operation in secondary processes Adrien Mazarguil
2016-03-17 15:38     ` [dpdk-dev] [PATCH v3 3/5] mlx5: add RX CRC stripping configuration Adrien Mazarguil
2016-03-17 15:38     ` [dpdk-dev] [PATCH v3 4/5] mlx5: add support for HW packet padding Adrien Mazarguil
2016-03-17 15:38     ` [dpdk-dev] [PATCH v3 5/5] mlx5: add VLAN insertion offload Adrien Mazarguil
2016-03-22 16:35     ` [dpdk-dev] [PATCH v3 0/5] Implement missing features in mlx5 Bruce Richardson

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=1456165148-28416-4-git-send-email-adrien.mazarguil@6wind.com \
    --to=adrien.mazarguil@6wind.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).