DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 1/2] net/mlx5: fix flow queues array allocation
@ 2017-04-11 15:21 Nelio Laranjeiro
  2017-04-11 15:21 ` [dpdk-dev] [PATCH 2/2] net/mlx5: panic when destroying a queue in use Nelio Laranjeiro
  2017-04-12 15:02 ` [dpdk-dev] [PATCH 1/2] net/mlx5: fix flow queues array allocation Ferruh Yigit
  0 siblings, 2 replies; 7+ messages in thread
From: Nelio Laranjeiro @ 2017-04-11 15:21 UTC (permalink / raw)
  To: dev; +Cc: Adrien Mazarguil

Flow queues array offset is not properly computed causing all sorts of
issues.  Address it by making the rte_flow structure less complex.

Fixes: 360663e1df46 ("net/mlx5: prepare support for RSS action rule")

Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
 drivers/net/mlx5/mlx5_flow.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 3691e95..c735c43 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -98,11 +98,11 @@ struct rte_flow {
 	struct ibv_exp_flow *ibv_flow; /**< Verbs flow. */
 	struct ibv_exp_wq *wq; /**< Verbs work queue. */
 	struct ibv_cq *cq; /**< Verbs completion queue. */
-	struct rxq *(*rxqs)[]; /**< Pointer to the queues array. */
 	uint16_t rxqs_n; /**< Number of queues in this flow, 0 if drop queue. */
 	uint32_t mark:1; /**< Set if the flow is marked. */
 	uint32_t drop:1; /**< Drop queue. */
 	uint64_t hash_fields; /**< Fields that participate in the hash. */
+	struct rxq *rxqs[]; /**< Pointer to the queues array. */
 };
 
 /** Static initializer for items. */
@@ -1038,24 +1038,20 @@ priv_flow_create_action_queue(struct priv *priv,
 	assert(priv->pd);
 	assert(priv->ctx);
 	assert(!action->drop);
-	rte_flow = rte_calloc(__func__, 1,
-			      sizeof(*rte_flow) + sizeof(struct rxq *) *
-			      action->queues_n, 0);
+	rte_flow = rte_calloc(__func__, 1, sizeof(*rte_flow) +
+			      sizeof(*rte_flow->rxqs) * action->queues_n, 0);
 	if (!rte_flow) {
 		rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE,
 				   NULL, "cannot allocate flow memory");
 		return NULL;
 	}
-	rte_flow->rxqs = (struct rxq *(*)[])((uintptr_t)rte_flow +
-					     sizeof(struct rxq *) *
-					     action->queues_n);
 	for (i = 0; i < action->queues_n; ++i) {
 		struct rxq_ctrl *rxq;
 
 		rxq = container_of((*priv->rxqs)[action->queues[i]],
 				   struct rxq_ctrl, rxq);
 		wqs[i] = rxq->wq;
-		(*rte_flow->rxqs)[i] = &rxq->rxq;
+		rte_flow->rxqs[i] = &rxq->rxq;
 		++rte_flow->rxqs_n;
 		rxq->rxq.mark |= action->mark;
 	}
@@ -1265,7 +1261,7 @@ priv_flow_destroy(struct priv *priv,
 		 * present in any other marked flow (RSS or not).
 		 */
 		for (queue_n = 0; queue_n < flow->rxqs_n; ++queue_n) {
-			rxq = (*flow->rxqs)[queue_n];
+			rxq = flow->rxqs[queue_n];
 			for (tmp = LIST_FIRST(&priv->flows);
 			     tmp;
 			     tmp = LIST_NEXT(tmp, next)) {
@@ -1278,7 +1274,7 @@ priv_flow_destroy(struct priv *priv,
 				     ++tqueue_n) {
 					struct rxq *trxq;
 
-					trxq = (*tmp->rxqs)[tqueue_n];
+					trxq = tmp->rxqs[tqueue_n];
 					if (rxq == trxq)
 						++mark_n;
 				}
@@ -1489,7 +1485,7 @@ priv_flow_stop(struct priv *priv)
 			unsigned int n;
 
 			for (n = 0; n < flow->rxqs_n; ++n)
-				(*flow->rxqs)[n]->mark = 0;
+				flow->rxqs[n]->mark = 0;
 		}
 		DEBUG("Flow %p removed", (void *)flow);
 	}
@@ -1534,7 +1530,7 @@ priv_flow_start(struct priv *priv)
 			unsigned int n;
 
 			for (n = 0; n < flow->rxqs_n; ++n)
-				(*flow->rxqs)[n]->mark = 1;
+				flow->rxqs[n]->mark = 1;
 		}
 	}
 	return 0;
-- 
2.1.4

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

end of thread, other threads:[~2017-04-13 11:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-11 15:21 [dpdk-dev] [PATCH 1/2] net/mlx5: fix flow queues array allocation Nelio Laranjeiro
2017-04-11 15:21 ` [dpdk-dev] [PATCH 2/2] net/mlx5: panic when destroying a queue in use Nelio Laranjeiro
2017-04-12 16:48   ` Ferruh Yigit
2017-04-12 17:04     ` Adrien Mazarguil
2017-04-12 15:02 ` [dpdk-dev] [PATCH 1/2] net/mlx5: fix flow queues array allocation Ferruh Yigit
2017-04-12 16:51   ` Ferruh Yigit
2017-04-13 11:00     ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).