All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] net/mlx4: fix Rx after updating number of queues
@ 2017-10-31 10:31 Adrien Mazarguil
  2017-10-31 10:31 ` [PATCH 2/2] net/mlx4: fix queue index check on flow rules Adrien Mazarguil
  0 siblings, 1 reply; 2+ messages in thread
From: Adrien Mazarguil @ 2017-10-31 10:31 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: dev

When not in isolated mode, internal flow rules are automatically maintained
by the PMD to receive traffic according to global device settings (MAC,
VLAN, promiscuous mode and so on).

Since RSS support was added to the mix, it must also check whether Rx queue
configuration has changed when refreshing flow rules to prevent the
following from happening:

- With a smaller number of Rx queues, traffic is implicitly dropped since
  the existing RSS context cannot be re-applied.
- With a larger number of Rx queues, traffic remains balanced within the
  original (smaller) set of queues.

One workaround before this commit was to temporarily enter/leave isolated
mode to make it regenerate internal flow rules.

Fixes: 7d8675956f57 ("net/mlx4: add RSS support outside flow API")

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
 drivers/net/mlx4/mlx4_flow.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
index 7a6097f..86bac1b 100644
--- a/drivers/net/mlx4/mlx4_flow.c
+++ b/drivers/net/mlx4/mlx4_flow.c
@@ -1342,6 +1342,7 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error)
 			assert(flow->ibv_attr->type == IBV_FLOW_ATTR_NORMAL);
 			assert(flow->ibv_attr->num_of_specs == 1);
 			assert(eth->type == IBV_FLOW_SPEC_ETH);
+			assert(flow->rss);
 			if (rule_vlan &&
 			    (eth->val.vlan_tag != *rule_vlan ||
 			     eth->mask.vlan_tag != RTE_BE16(0x0fff)))
@@ -1354,8 +1355,13 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error)
 				    eth->val.src_mac[j] != UINT8_C(0x00) ||
 				    eth->mask.src_mac[j] != UINT8_C(0x00))
 					break;
-			if (j == sizeof(mac->addr_bytes))
-				break;
+			if (j != sizeof(mac->addr_bytes))
+				continue;
+			if (flow->rss->queues != queues ||
+			    memcmp(flow->rss->queue_id, rss_conf->queue,
+				   queues * sizeof(flow->rss->queue_id[0])))
+				continue;
+			break;
 		}
 		if (!flow || !flow->internal) {
 			/* Not found, create a new flow rule. */
@@ -1389,6 +1395,13 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error)
 					break;
 			}
 		}
+		if (flow && flow->internal) {
+			assert(flow->rss);
+			if (flow->rss->queues != queues ||
+			    memcmp(flow->rss->queue_id, rss_conf->queue,
+				   queues * sizeof(flow->rss->queue_id[0])))
+				flow = NULL;
+		}
 		if (!flow || !flow->internal) {
 			/* Not found, create a new flow rule. */
 			if (priv->dev->data->promiscuous) {
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] net/mlx4: fix queue index check on flow rules
  2017-10-31 10:31 [PATCH 1/2] net/mlx4: fix Rx after updating number of queues Adrien Mazarguil
@ 2017-10-31 10:31 ` Adrien Mazarguil
  0 siblings, 0 replies; 2+ messages in thread
From: Adrien Mazarguil @ 2017-10-31 10:31 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: dev

Users are not prevented from creating flow rules targeting nonexistent
queues, which silently makes such rules drop-like.

While it can be thought as a feature, reporting an error instead is
actually far more useful in order to catch common mistakes.

Fixes: 078b8b452e6b ("net/mlx4: add RSS flow rule action support")

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
 drivers/net/mlx4/mlx4_flow.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
index 86bac1b..8b87b29 100644
--- a/drivers/net/mlx4/mlx4_flow.c
+++ b/drivers/net/mlx4/mlx4_flow.c
@@ -734,6 +734,11 @@ mlx4_flow_prepare(struct priv *priv,
 			if (flow->rss)
 				break;
 			queue = action->conf;
+			if (queue->index >= priv->dev->data->nb_rx_queues) {
+				msg = "queue target index beyond number of"
+					" configured Rx queues";
+				goto exit_action_not_supported;
+			}
 			flow->rss = mlx4_rss_get
 				(priv, 0, mlx4_rss_hash_key_default, 1,
 				 &queue->index);
@@ -760,6 +765,15 @@ mlx4_flow_prepare(struct priv *priv,
 						   ETH_RSS_NONFRAG_IPV6_TCP),
 				};
 			/* Sanity checks. */
+			for (i = 0; i < rss->num; ++i)
+				if (rss->queue[i] >=
+				    priv->dev->data->nb_rx_queues)
+					break;
+			if (i != rss->num) {
+				msg = "queue index target beyond number of"
+					" configured Rx queues";
+				goto exit_action_not_supported;
+			}
 			if (!rte_is_power_of_2(rss->num)) {
 				msg = "for RSS, mlx4 requires the number of"
 					" queues to be a power of two";
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-10-31 10:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-31 10:31 [PATCH 1/2] net/mlx4: fix Rx after updating number of queues Adrien Mazarguil
2017-10-31 10:31 ` [PATCH 2/2] net/mlx4: fix queue index check on flow rules Adrien Mazarguil

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.