From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f175.google.com (mail-wr0-f175.google.com [209.85.128.175]) by dpdk.org (Postfix) with ESMTP id AB8A6532E for ; Tue, 11 Apr 2017 17:22:15 +0200 (CEST) Received: by mail-wr0-f175.google.com with SMTP id o21so243835wrb.2 for ; Tue, 11 Apr 2017 08:22:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=9wHl7LYV/tA9PPuihJfT7SsPCfFiUHyl2AD0EyVANrY=; b=BTJgDYDxqZQsy2IE+hOnqur+55XrJaMD3AI20AsfWvvfUGV+iVu+8FsXehiNbOm8Fd SfqYFmNeG10HUL9JKxy00WjnHVyjB1coid53a6gRRRnJMkx2TO5tv1JLZwadTCUdNzvq 99Ai+TFbpFhzVsdQWpkP9p1ZT756DY/eu7M3WYidG3sAl5qY1e4XQrQszEmwC//RH9iE mwR06CJsvZ37eNurLhfojyl9gibIG2/xoTZ/OUfFGHj9s2OlgGX1TOIHrGi4vZcBun3I ls2KaNHPOj5hivsUeBk0ZI5YwRlpkvoN7YF87egnPtW+CGUMQGrwDR1+Akl01LN8aG67 uVNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=9wHl7LYV/tA9PPuihJfT7SsPCfFiUHyl2AD0EyVANrY=; b=EXza4mK075L3kqTXZC2u1RnNkEnvbn3vlEhFIduz4/rev/gKoyKBJjdB28uUC3V2CG H4a5ae5BscyeCcGDbzCehJ2HucKt2wMNJewBNNhOv2Ywf0CYR8eNRWdM8G3f45sajLwe iGxEQpmNj/BHpG1mLvzZZ6Lh+2AmMSf1av++dBwbdI+Q9Vzslq5cD34TeB3osGnhF0oS xa/3o1SMQU7trZI1N5xbIhhGHhZz5cBgEvUMWlZk2zsLYjkdlxB/voPB6Xdx5LV7rkbQ 5UAerOEaDoJ76ZXrMAlrFeVGuuGGZt+1AUidJjnphgrF2WZhD+UeRFJitmPQC/b0xH6q cfJw== X-Gm-Message-State: AN3rC/48rTBpbJISYeRLyp6LfllGyeLkjkNmvijACQrH3rUIiH+xmrV4vC5agQQk4X1Fc4GQ X-Received: by 10.223.151.150 with SMTP id s22mr23962224wrb.123.1491924135255; Tue, 11 Apr 2017 08:22:15 -0700 (PDT) Received: from ping.vm.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id u145sm2887215wmu.1.2017.04.11.08.22.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 11 Apr 2017 08:22:14 -0700 (PDT) From: Nelio Laranjeiro To: dev@dpdk.org Cc: Adrien Mazarguil Date: Tue, 11 Apr 2017 17:21:52 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH 2/2] net/mlx5: panic when destroying a queue in use X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Apr 2017 15:22:15 -0000 Since the queue release API does not allow failures (return value is void) and the flow API does not allow a queue to be released as long as a flow rule depends on it, the only rational decision to avoid undefined behavior is to panic in this situation. Signed-off-by: Nelio Laranjeiro Acked-by: Adrien Mazarguil --- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow.c | 31 +++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_rxq.c | 4 ++++ 3 files changed, 36 insertions(+) diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index e8bf361..71e19ec 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -313,5 +313,6 @@ int mlx5_flow_destroy(struct rte_eth_dev *, struct rte_flow *, int mlx5_flow_flush(struct rte_eth_dev *, 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 *); #endif /* RTE_PMD_MLX5_H_ */ diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index c735c43..8d62f85 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -1535,3 +1535,34 @@ priv_flow_start(struct priv *priv) } return 0; } + +/** + * Verify if the Rx queue is used in a flow. + * + * @param priv + * Pointer to private structure. + * @param rxq + * Pointer to the queue to search. + * + * @return + * Nonzero if the queue is used by a flow. + */ +int +priv_flow_rxq_in_use(struct priv *priv, struct rxq *rxq) +{ + struct rte_flow *flow; + + for (flow = LIST_FIRST(&priv->flows); + flow; + flow = LIST_NEXT(flow, next)) { + unsigned int n; + + if (flow->drop) + continue; + for (n = 0; n < flow->rxqs_n; ++n) { + if (flow->rxqs[n] == rxq) + return 1; + } + } + return 0; +} diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index 5566482..8b78233 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -59,6 +59,7 @@ #include #include #include +#include #ifdef PEDANTIC #pragma GCC diagnostic error "-Wpedantic" #endif @@ -1248,6 +1249,9 @@ mlx5_rx_queue_release(void *dpdk_rxq) rxq_ctrl = container_of(rxq, struct rxq_ctrl, rxq); priv = rxq_ctrl->priv; priv_lock(priv); + if (priv_flow_rxq_in_use(priv, rxq)) + rte_panic("Rx queue %p is still used by a flow and cannot be" + " removed\n", (void *)rxq_ctrl); for (i = 0; (i != priv->rxqs_n); ++i) if ((*priv->rxqs)[i] == rxq) { DEBUG("%p: removing RX queue %p from list", -- 2.1.4