From: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
To: dev@dpdk.org
Cc: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Subject: [dpdk-dev] [PATCH 1/2] net/mlx5: fix flow queues array allocation
Date: Tue, 11 Apr 2017 17:21:51 +0200 [thread overview]
Message-ID: <bb9435f1c3712b34993bdc1d4b29241dffeac4a0.1491924075.git.nelio.laranjeiro@6wind.com> (raw)
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
next reply other threads:[~2017-04-11 15:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-11 15:21 Nelio Laranjeiro [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bb9435f1c3712b34993bdc1d4b29241dffeac4a0.1491924075.git.nelio.laranjeiro@6wind.com \
--to=nelio.laranjeiro@6wind.com \
--cc=adrien.mazarguil@6wind.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).