From 0d2186743d62a568b26d9d56a96e03eaf3f91522 Mon Sep 17 00:00:00 2001 From: Adrien Mazarguil Date: Thu, 3 Mar 2016 15:27:36 +0100 Subject: [PATCH] mlx5: manage all special flow types at once This commit adds helpers to remove redundant code. Signed-off-by: Adrien Mazarguil --- 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 ae2576f655..ad69ec2b85 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 84420162f3..43b24fb6e6 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 9ac7a4113f..bcf4231464 100644 --- a/drivers/net/mlx5/mlx5_rxmode.c +++ b/drivers/net/mlx5/mlx5_rxmode.c @@ -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. * diff --git a/drivers/net/mlx5/mlx5_trigger.c b/drivers/net/mlx5/mlx5_trigger.c index db7890f2d3..b5ca7d4668 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.20.1