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/7] mlx5: manage all special flow types at once
Date: Mon, 22 Feb 2016 19:18:39 +0100	[thread overview]
Message-ID: <1456165123-28365-4-git-send-email-adrien.mazarguil@6wind.com> (raw)
In-Reply-To: <1456165123-28365-1-git-send-email-adrien.mazarguil@6wind.com>

This commit adds helpers to remove redundant code.

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
 drivers/net/mlx5/mlx5.c         |  5 +----
 drivers/net/mlx5/mlx5.h         |  2 ++
 drivers/net/mlx5/mlx5_rxmode.c  | 40 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_trigger.c | 10 ++--------
 4 files changed, 45 insertions(+), 12 deletions(-)

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index ae2576f..ad69ec2 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -88,10 +88,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)
 	      ((priv->ctx != NULL) ? priv->ctx->device->name : ""));
 	/* In case mlx5_dev_stop() has not been called. */
 	priv_dev_interrupt_handler_uninstall(priv, dev);
-	priv_special_flow_disable(priv, HASH_RXQ_FLOW_TYPE_ALLMULTI);
-	priv_special_flow_disable(priv, HASH_RXQ_FLOW_TYPE_PROMISC);
-	priv_special_flow_disable(priv, HASH_RXQ_FLOW_TYPE_BROADCAST);
-	priv_special_flow_disable(priv, HASH_RXQ_FLOW_TYPE_IPV6MULTI);
+	priv_special_flow_disable_all(priv);
 	priv_mac_addrs_disable(priv);
 	priv_destroy_hash_rxqs(priv);
 
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 8442016..43b24fb 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -199,6 +199,8 @@ int mlx5_dev_rss_reta_update(struct rte_eth_dev *,
 
 int priv_special_flow_enable(struct priv *, enum hash_rxq_flow_type);
 void priv_special_flow_disable(struct priv *, enum hash_rxq_flow_type);
+int priv_special_flow_enable_all(struct priv *);
+void priv_special_flow_disable_all(struct priv *);
 void mlx5_promiscuous_enable(struct rte_eth_dev *);
 void mlx5_promiscuous_disable(struct rte_eth_dev *);
 void mlx5_allmulticast_enable(struct rte_eth_dev *);
diff --git a/drivers/net/mlx5/mlx5_rxmode.c b/drivers/net/mlx5/mlx5_rxmode.c
index 9ac7a41..bcf4231 100644
--- a/drivers/net/mlx5/mlx5_rxmode.c
+++ b/drivers/net/mlx5/mlx5_rxmode.c
@@ -268,6 +268,46 @@ priv_special_flow_disable(struct priv *priv, enum hash_rxq_flow_type flow_type)
 }
 
 /**
+ * Enable all special flows in all hash RX queues.
+ *
+ * @param priv
+ *   Private structure.
+ */
+int
+priv_special_flow_enable_all(struct priv *priv)
+{
+	enum hash_rxq_flow_type flow_type;
+
+	for (flow_type = 0; flow_type != HASH_RXQ_FLOW_TYPE_MAC; ++flow_type) {
+		int ret;
+
+		ret = priv_special_flow_enable(priv, flow_type);
+		if (!ret)
+			continue;
+		/* Failure, rollback. */
+		while (flow_type)
+			priv_special_flow_disable(priv, --flow_type);
+		return ret;
+	}
+	return 0;
+}
+
+/**
+ * Disable all special flows in all hash RX queues.
+ *
+ * @param priv
+ *   Private structure.
+ */
+void
+priv_special_flow_disable_all(struct priv *priv)
+{
+	enum hash_rxq_flow_type flow_type;
+
+	for (flow_type = 0; flow_type != HASH_RXQ_FLOW_TYPE_MAC; ++flow_type)
+		priv_special_flow_disable(priv, flow_type);
+}
+
+/**
  * DPDK callback to enable promiscuous mode.
  *
  * @param dev
diff --git a/drivers/net/mlx5/mlx5_trigger.c b/drivers/net/mlx5/mlx5_trigger.c
index db7890f..b5ca7d4 100644
--- a/drivers/net/mlx5/mlx5_trigger.c
+++ b/drivers/net/mlx5/mlx5_trigger.c
@@ -80,10 +80,7 @@ mlx5_dev_start(struct rte_eth_dev *dev)
 		      " %s",
 		      (void *)priv, strerror(err));
 		/* Rollback. */
-		priv_special_flow_disable(priv, HASH_RXQ_FLOW_TYPE_IPV6MULTI);
-		priv_special_flow_disable(priv, HASH_RXQ_FLOW_TYPE_BROADCAST);
-		priv_special_flow_disable(priv, HASH_RXQ_FLOW_TYPE_ALLMULTI);
-		priv_special_flow_disable(priv, HASH_RXQ_FLOW_TYPE_PROMISC);
+		priv_special_flow_disable_all(priv);
 		priv_mac_addrs_disable(priv);
 		priv_destroy_hash_rxqs(priv);
 	}
@@ -113,10 +110,7 @@ mlx5_dev_stop(struct rte_eth_dev *dev)
 		return;
 	}
 	DEBUG("%p: cleaning up and destroying hash RX queues", (void *)dev);
-	priv_special_flow_disable(priv, HASH_RXQ_FLOW_TYPE_IPV6MULTI);
-	priv_special_flow_disable(priv, HASH_RXQ_FLOW_TYPE_BROADCAST);
-	priv_special_flow_disable(priv, HASH_RXQ_FLOW_TYPE_ALLMULTI);
-	priv_special_flow_disable(priv, HASH_RXQ_FLOW_TYPE_PROMISC);
+	priv_special_flow_disable_all(priv);
 	priv_mac_addrs_disable(priv);
 	priv_destroy_hash_rxqs(priv);
 	priv_fdir_disable(priv);
-- 
2.1.4

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

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-22 18:18 [dpdk-dev] [PATCH 0/7] Assorted fixes for mlx4 and mlx5 Adrien Mazarguil
2016-02-22 18:18 ` [dpdk-dev] [PATCH 1/7] mlx5: fix possible crash during initialization Adrien Mazarguil
2016-02-22 18:18 ` [dpdk-dev] [PATCH 2/7] mlx5: check if port is configured as Ethernet device Adrien Mazarguil
2016-02-22 18:18 ` Adrien Mazarguil [this message]
2016-02-22 18:18 ` [dpdk-dev] [PATCH 4/7] mlx5: remove redundant debugging message Adrien Mazarguil
2016-02-22 18:18 ` [dpdk-dev] [PATCH 5/7] mlx5: apply VLAN filtering to broadcast and IPv6 multicast flows Adrien Mazarguil
2016-02-22 18:18 ` [dpdk-dev] [PATCH 6/7] mlx5: fix RX checksum offload in non L3/L4 packets Adrien Mazarguil
2016-02-22 18:18 ` [dpdk-dev] [PATCH 7/7] mlx4: make sure that number of RX queues is a power of 2 Adrien Mazarguil
2016-03-03 14:27 ` [dpdk-dev] [PATCH v2 0/7] Assorted fixes for mlx4 and mlx5 Adrien Mazarguil
2016-03-03 14:27   ` [dpdk-dev] [PATCH v2 1/7] mlx5: fix possible crash during initialization Adrien Mazarguil
2016-03-03 14:27   ` [dpdk-dev] [PATCH v2 2/7] mlx5: check if port is configured as Ethernet device Adrien Mazarguil
2016-03-03 14:27   ` [dpdk-dev] [PATCH v2 3/7] mlx5: manage all special flow types at once Adrien Mazarguil
2016-03-03 14:27   ` [dpdk-dev] [PATCH v2 4/7] mlx5: remove redundant debugging message Adrien Mazarguil
2016-03-03 14:27   ` [dpdk-dev] [PATCH v2 5/7] mlx5: apply VLAN filtering to broadcast and IPv6 multicast flows Adrien Mazarguil
2016-03-03 14:27   ` [dpdk-dev] [PATCH v2 6/7] mlx5: fix RX checksum offload in non L3/L4 packets Adrien Mazarguil
2016-03-03 14:27   ` [dpdk-dev] [PATCH v2 7/7] mlx4: make sure that number of RX queues is a power of 2 Adrien Mazarguil
2016-03-10 22:15   ` [dpdk-dev] [PATCH v2 0/7] Assorted fixes for mlx4 and 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=1456165123-28365-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).