From 51d5f8ec953c80a87fb1da83ff3cb03d1d32ef2b Mon Sep 17 00:00:00 2001 From: =?utf8?q?N=C3=A9lio=20Laranjeiro?= Date: Wed, 24 May 2017 15:44:08 +0200 Subject: [PATCH] net/mlx5: implement isolated mode from flow API Signed-off-by: Nelio Laranjeiro Acked-by: Adrien Mazarguil Acked-by: Shahaf Shuler --- 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 1148dee36b..aa8a1a0ed1 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 c8d47489f5..34a7e69f1b 100644 --- a/drivers/net/mlx5/mlx5_fdir.c +++ b/drivers/net/mlx5/mlx5_fdir.c @@ -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, }; /** diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index b7b7c8356c..86be9291c9 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -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; +} diff --git a/drivers/net/mlx5/mlx5_mac.c b/drivers/net/mlx5/mlx5_mac.c index 79e0c41063..8489ea6783 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 173e6e842b..a67e542675 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 2a2683985a..0e31df318e 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.20.1