net/mlx5: implement isolated mode from flow API
authorNélio Laranjeiro <nelio.laranjeiro@6wind.com>
Wed, 24 May 2017 13:44:08 +0000 (15:44 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 6 Jul 2017 13:00:56 +0000 (15:00 +0200)
Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
drivers/net/mlx5/mlx5.h
drivers/net/mlx5/mlx5_fdir.c
drivers/net/mlx5/mlx5_flow.c
drivers/net/mlx5/mlx5_mac.c
drivers/net/mlx5/mlx5_rxmode.c
drivers/net/mlx5/mlx5_rxq.c

index 1148dee..aa8a1a0 100644 (file)
@@ -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 *);
index c8d4748..34a7e69 100644 (file)
@@ -1053,6 +1053,7 @@ static const struct rte_flow_ops mlx5_flow_ops = {
        .destroy = mlx5_flow_destroy,
        .flush = mlx5_flow_flush,
        .query = NULL,
+       .isolate = mlx5_flow_isolate,
 };
 
 /**
index b7b7c83..86be929 100644 (file)
@@ -1600,3 +1600,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;
+}
index 79e0c41..8489ea6 100644 (file)
@@ -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) {
index 173e6e8..a67e542 100644 (file)
@@ -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) {
index 2a26839..0e31df3 100644 (file)
@@ -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);