mlx5: manage all special flow types at once
authorAdrien Mazarguil <adrien.mazarguil@6wind.com>
Thu, 3 Mar 2016 14:27:36 +0000 (15:27 +0100)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Wed, 16 Mar 2016 17:52:17 +0000 (18:52 +0100)
This commit adds helpers to remove redundant code.

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
drivers/net/mlx5/mlx5.c
drivers/net/mlx5/mlx5.h
drivers/net/mlx5/mlx5_rxmode.c
drivers/net/mlx5/mlx5_trigger.c

index ae2576f..ad69ec2 100644 (file)
@@ -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);
 
index 8442016..43b24fb 100644 (file)
@@ -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 *);
index 9ac7a41..bcf4231 100644 (file)
@@ -267,6 +267,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.
  *
index db7890f..b5ca7d4 100644 (file)
@@ -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);