Signed-off-by: Nelio Laranjeiro <nelio.laranje...@6wind.com>
Acked-by: Adrien Mazarguil <adrien.mazarg...@6wind.com>
Acked-by: Shahaf Shuler <shah...@mellanox.com>
---
Depends on:

http://dpdk.org/ml/archives/dev/2017-April/064327.html
http://dpdk.org/dev/patchwork/patch/23741/
---
 drivers/net/mlx5/mlx5.h        |  2 ++
 drivers/net/mlx5/mlx5_fdir.c   |  1 +
 drivers/net/mlx5/mlx5_flow.c   | 27 +++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_mac.c    |  2 ++
 drivers/net/mlx5/mlx5_rxmode.c |  2 ++
 drivers/net/mlx5/mlx5_rxq.c    |  2 ++
 6 files changed, 36 insertions(+)

diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 67fd742..20f46c9 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -129,6 +129,7 @@ struct priv {
        unsigned int pending_alarm:1; /* An alarm is pending. */
        unsigned int tso:1; /* Whether TSO is supported. */
        unsigned int tunnel_en:1;
+       unsigned int isolated:1; /* Whether isolated mode is enabled. */
        /* Whether Tx offloads for tunneled packets are supported. */
        unsigned int max_tso_payload_sz; /* Maximum TCP payload for TSO. */
        unsigned int txq_inline; /* Maximum packet size for inlining. */
@@ -311,6 +312,7 @@ struct rte_flow *mlx5_flow_create(struct rte_eth_dev *,
 int mlx5_flow_destroy(struct rte_eth_dev *, struct rte_flow *,
                      struct rte_flow_error *);
 int mlx5_flow_flush(struct rte_eth_dev *, struct rte_flow_error *);
+int mlx5_flow_isolate(struct rte_eth_dev *, int, struct rte_flow_error *);
 int priv_flow_start(struct priv *);
 void priv_flow_stop(struct priv *);
 int priv_flow_rxq_in_use(struct priv *, struct rxq *);
diff --git a/drivers/net/mlx5/mlx5_fdir.c b/drivers/net/mlx5/mlx5_fdir.c
index f80c58b..4b21e5a 100644
--- a/drivers/net/mlx5/mlx5_fdir.c
+++ b/drivers/net/mlx5/mlx5_fdir.c
@@ -1050,6 +1050,7 @@ static const struct rte_flow_ops mlx5_flow_ops = {
        .destroy = mlx5_flow_destroy,
        .flush = mlx5_flow_flush,
        .query = NULL,
+       .isolate = mlx5_flow_isolate,
 };
 
 /**
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index adcbe3f..5660f3c 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -1584,3 +1584,30 @@ priv_flow_rxq_in_use(struct priv *priv, struct rxq *rxq)
        }
        return 0;
 }
+
+/**
+ * Isolated mode.
+ *
+ * @see rte_flow_isolate()
+ * @see rte_flow_ops
+ */
+int
+mlx5_flow_isolate(struct rte_eth_dev *dev,
+                 int enable,
+                 struct rte_flow_error *error)
+{
+       struct priv *priv = dev->data->dev_private;
+
+       priv_lock(priv);
+       if (priv->started) {
+               rte_flow_error_set(error, EBUSY,
+                                  RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+                                  NULL,
+                                  "port must be stopped first");
+               priv_unlock(priv);
+               return -rte_errno;
+       }
+       priv->isolated = !!enable;
+       priv_unlock(priv);
+       return 0;
+}
diff --git a/drivers/net/mlx5/mlx5_mac.c b/drivers/net/mlx5/mlx5_mac.c
index 79e0c41..8489ea6 100644
--- a/drivers/net/mlx5/mlx5_mac.c
+++ b/drivers/net/mlx5/mlx5_mac.c
@@ -443,6 +443,8 @@ priv_mac_addrs_enable(struct priv *priv)
        unsigned int i;
        int ret;
 
+       if (priv->isolated)
+               return 0;
        if (!priv_allow_flow_type(priv, HASH_RXQ_FLOW_TYPE_MAC))
                return 0;
        for (i = 0; (i != priv->hash_rxqs_n); ++i) {
diff --git a/drivers/net/mlx5/mlx5_rxmode.c b/drivers/net/mlx5/mlx5_rxmode.c
index 173e6e8..a67e542 100644
--- a/drivers/net/mlx5/mlx5_rxmode.c
+++ b/drivers/net/mlx5/mlx5_rxmode.c
@@ -347,6 +347,8 @@ priv_special_flow_enable_all(struct priv *priv)
 {
        enum hash_rxq_flow_type flow_type;
 
+       if (priv->isolated)
+               return 0;
        for (flow_type = HASH_RXQ_FLOW_TYPE_PROMISC;
                        flow_type != HASH_RXQ_FLOW_TYPE_MAC;
                        ++flow_type) {
diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index 2a26839..0e31df3 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -363,6 +363,8 @@ priv_create_hash_rxqs(struct priv *priv)
        assert(priv->hash_rxqs_n == 0);
        assert(priv->pd != NULL);
        assert(priv->ctx != NULL);
+       if (priv->isolated)
+               return 0;
        if (priv->rxqs_n == 0)
                return EINVAL;
        assert(priv->rxqs != NULL);
-- 
2.1.4

Reply via email to