From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by dpdk.org (Postfix) with ESMTP id D2EAD1B738 for ; Wed, 7 Feb 2018 17:47:24 +0100 (CET) Received: by mail-wm0-f68.google.com with SMTP id g1so4361749wmg.2 for ; Wed, 07 Feb 2018 08:47:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hzNHF3nTqNind+Bviv7MGyGshHEWGlztDPs2uW4zBLs=; b=LrYCzUlSX2ikDL509TLMYRdR9TDOLZJ3a1zQW82sCLgBWq1ncYWWWBmcMl3E29svnB NOzBRzDjip9MRGfefloY1w81n07xVNFuTSIAZsAPAGBMrbjHMPvjRsNis8T76UGQSxqN TSgVKUBuKluaFIsxx5K/FTIvLdeqF2q73xXo4pFqSI+9PZ2iJKCoHobY9G2x/Dy0sBJY uyRbtIL9IG2zoxIi/BLm7kk9dxY44Rrw7/IRwRvbyCzarwPK3O/s5untijDnqw3n9NXm 07LbywZVoUjQnbanmUivhRqk4E8CrfOo6KgC60ULC6WpP8Rrh/f9getiJRoSBEwnsxjr RE3A== 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; bh=hzNHF3nTqNind+Bviv7MGyGshHEWGlztDPs2uW4zBLs=; b=uav/EaVr2Choa0OGRVmKauGCWFa5Vl26zGTGky50huUrknEw/BqHgE9LM+zUzW/aA7 lHLIUa3amhO6JRJzDwXE44kDyOa6kfjqZB/0D5cFqRiv7GKi7j2c9T4OLhjEWGNQ8n1T a/kY6BPgDgWNAC2cUsMwVBpaO0M26CpdzPCKnV7f3MDp3T3BInWRjTAibVTIOo8as2vH wK9aCuS0UAEtTYC3XZEZRLegaLf18OB9uSpO0ijbtLFju5LXBsyKUmCcj5tCDTuXqu5K LWZVhYoV4rMVAxbDUg73mX+d5/OfvlzQCXJrYGiJqOlpohU1WyMMMZLTh6A3qROaIuqk a8rA== X-Gm-Message-State: APf1xPCpzRo41Fhq8cyO+o35I7Q31tmezJGGm8QUTmZC2YEXv/wgBvsf Hx2ouNCTtAIAM8efztUXFT6h2vrH X-Google-Smtp-Source: AH8x224HBIzPA8gUdO0RHwR0ymbz0i2009u+/tm4SGkWUJyRtfvvnw834ttVTkvY5lavBd0iuqckhw== X-Received: by 10.28.12.75 with SMTP id 72mr4827379wmm.97.1518022043494; Wed, 07 Feb 2018 08:47:23 -0800 (PST) Received: from localhost ([2a00:23c5:bef3:400:9531:588b:44ae:bec4]) by smtp.gmail.com with ESMTPSA id g205sm1735173wme.43.2018.02.07.08.47.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 07 Feb 2018 08:47:22 -0800 (PST) From: luca.boccassi@gmail.com To: Hyong Youb Kim Cc: John Daley , dpdk stable Date: Wed, 7 Feb 2018 16:46:36 +0000 Message-Id: <20180207164705.29052-5-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180207164705.29052-1-luca.boccassi@gmail.com> References: <20180126131332.15346-62-luca.boccassi@gmail.com> <20180207164705.29052-1-luca.boccassi@gmail.com> Subject: [dpdk-stable] patch 'net/enic: fix crash due to static max number of queues' has been queued to LTS release 16.11.5 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Feb 2018 16:47:24 -0000 Hi, FYI, your patch has been queued to LTS release 16.11.5 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/09/18. So please shout if anyone has objections. Thanks. Luca Boccassi --- >>From 669981bf6861e1da3d120ac720a8e430267d1cbd Mon Sep 17 00:00:00 2001 From: Hyong Youb Kim Date: Mon, 22 Jan 2018 17:05:28 -0800 Subject: [PATCH] net/enic: fix crash due to static max number of queues [ upstream commit 6c45c330589d334c4f7b729e61ae30a6acfcc119 ] ENIC_CQ_MAX, ENIC_WQ_MAX and others are arbitrary values that prevent the app from using more queues when they are available on hardware. Remove them and dynamically allocate vnic_cq and such arrays to accommodate all available hardware queues. As a side effect of removing ENIC_CQ_MAX, this commit fixes a segfault that would happen when the app requests more than 16 CQs, because enic_set_vnic_res() does not consider ENIC_CQ_MAX. For example, the following command causes a crash. testpmd -- --rxq=16 --txq=16 Fixes: ce93d3c36db0 ("net/enic: fix resource check failures when bonding devices") Signed-off-by: Hyong Youb Kim Reviewed-by: John Daley --- drivers/net/enic/enic.h | 26 +++++++++---------------- drivers/net/enic/enic_ethdev.c | 18 ++---------------- drivers/net/enic/enic_main.c | 43 ++++++++++++++++++++++++++++++++---------- 3 files changed, 44 insertions(+), 43 deletions(-) diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h index a3d2a0fb5..46f20b2d6 100644 --- a/drivers/net/enic/enic.h +++ b/drivers/net/enic/enic.h @@ -53,14 +53,6 @@ #define DRV_DESCRIPTION "Cisco VIC Ethernet NIC Poll-mode Driver" #define DRV_COPYRIGHT "Copyright 2008-2015 Cisco Systems, Inc" -#define ENIC_WQ_MAX 8 -/* With Rx scatter support, we use two RQs on VIC per RQ used by app. Both - * RQs use the same CQ. - */ -#define ENIC_RQ_MAX 16 -#define ENIC_CQ_MAX (ENIC_WQ_MAX + (ENIC_RQ_MAX / 2)) -#define ENIC_INTR_MAX (ENIC_CQ_MAX + 2) - #define VLAN_ETH_HLEN 18 #define ENICPMD_SETTING(enic, f) ((enic->config.flags & VENETF_##f) ? 1 : 0) @@ -139,17 +131,17 @@ struct enic { unsigned int flags; unsigned int priv_flags; - /* work queue */ - struct vnic_wq wq[ENIC_WQ_MAX]; - unsigned int wq_count; + /* work queue (len = conf_wq_count) */ + struct vnic_wq *wq; + unsigned int wq_count; /* equals eth_dev nb_tx_queues */ - /* receive queue */ - struct vnic_rq rq[ENIC_RQ_MAX]; - unsigned int rq_count; + /* receive queue (len = conf_rq_count) */ + struct vnic_rq *rq; + unsigned int rq_count; /* equals eth_dev nb_rx_queues */ - /* completion queue */ - struct vnic_cq cq[ENIC_CQ_MAX]; - unsigned int cq_count; + /* completion queue (len = conf_cq_count) */ + struct vnic_cq *cq; + unsigned int cq_count; /* equals rq_count + wq_count */ /* interrupt resource */ struct vnic_intr intr; diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c index 2b154ec24..17479d4d3 100644 --- a/drivers/net/enic/enic_ethdev.c +++ b/drivers/net/enic/enic_ethdev.c @@ -184,13 +184,7 @@ static int enicpmd_dev_tx_queue_setup(struct rte_eth_dev *eth_dev, struct enic *enic = pmd_priv(eth_dev); ENICPMD_FUNC_TRACE(); - if (queue_idx >= ENIC_WQ_MAX) { - dev_err(enic, - "Max number of TX queues exceeded. Max is %d\n", - ENIC_WQ_MAX); - return -EINVAL; - } - + RTE_ASSERT(queue_idx < enic->conf_wq_count); eth_dev->data->tx_queues[queue_idx] = (void *)&enic->wq[queue_idx]; ret = enic_alloc_wq(enic, queue_idx, socket_id, nb_desc); @@ -302,16 +296,8 @@ static int enicpmd_dev_rx_queue_setup(struct rte_eth_dev *eth_dev, struct enic *enic = pmd_priv(eth_dev); ENICPMD_FUNC_TRACE(); - /* With Rx scatter support, two RQs are now used on VIC per RQ used - * by the application. - */ - if (queue_idx * 2 >= ENIC_RQ_MAX) { - dev_err(enic, - "Max number of RX queues exceeded. Max is %d. This PMD uses 2 RQs on VIC per RQ used by DPDK.\n", - ENIC_RQ_MAX); - return -EINVAL; - } + RTE_ASSERT(enic_rte_rq_idx_to_sop_idx(queue_idx) < enic->conf_rq_count); eth_dev->data->rx_queues[queue_idx] = (void *)&enic->rq[enic_rte_rq_idx_to_sop_idx(queue_idx)]; diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c index b25eff4f1..63d0c50d6 100644 --- a/drivers/net/enic/enic_main.c +++ b/drivers/net/enic/enic_main.c @@ -1080,6 +1080,9 @@ static void enic_dev_deinit(struct enic *enic) vnic_dev_notify_unset(enic->vdev); rte_free(eth_dev->data->mac_addrs); + rte_free(enic->cq); + rte_free(enic->rq); + rte_free(enic->wq); } @@ -1087,27 +1090,28 @@ int enic_set_vnic_res(struct enic *enic) { struct rte_eth_dev *eth_dev = enic->rte_dev; int rc = 0; + unsigned int required_rq, required_wq, required_cq; - /* With Rx scatter support, two RQs are now used per RQ used by - * the application. - */ - if (enic->conf_rq_count < eth_dev->data->nb_rx_queues) { + /* Always use two vNIC RQs per eth_dev RQ, regardless of Rx scatter. */ + required_rq = eth_dev->data->nb_rx_queues * 2; + required_wq = eth_dev->data->nb_tx_queues; + required_cq = eth_dev->data->nb_rx_queues + eth_dev->data->nb_tx_queues; + + if (enic->conf_rq_count < required_rq) { dev_err(dev, "Not enough Receive queues. Requested:%u which uses %d RQs on VIC, Configured:%u\n", eth_dev->data->nb_rx_queues, - eth_dev->data->nb_rx_queues * 2, enic->conf_rq_count); + required_rq, enic->conf_rq_count); rc = -EINVAL; } - if (enic->conf_wq_count < eth_dev->data->nb_tx_queues) { + if (enic->conf_wq_count < required_wq) { dev_err(dev, "Not enough Transmit queues. Requested:%u, Configured:%u\n", eth_dev->data->nb_tx_queues, enic->conf_wq_count); rc = -EINVAL; } - if (enic->conf_cq_count < (eth_dev->data->nb_rx_queues + - eth_dev->data->nb_tx_queues)) { + if (enic->conf_cq_count < required_cq) { dev_err(dev, "Not enough Completion queues. Required:%u, Configured:%u\n", - (eth_dev->data->nb_rx_queues + - eth_dev->data->nb_tx_queues), enic->conf_cq_count); + required_cq, enic->conf_cq_count); rc = -EINVAL; } @@ -1309,6 +1313,25 @@ static int enic_dev_init(struct enic *enic) dev_err(enic, "See the ENIC PMD guide for more information.\n"); return -EINVAL; } + /* Queue counts may be zeros. rte_zmalloc returns NULL in that case. */ + enic->cq = rte_zmalloc("enic_vnic_cq", sizeof(struct vnic_cq) * + enic->conf_cq_count, 8); + enic->rq = rte_zmalloc("enic_vnic_rq", sizeof(struct vnic_rq) * + enic->conf_rq_count, 8); + enic->wq = rte_zmalloc("enic_vnic_wq", sizeof(struct vnic_wq) * + enic->conf_wq_count, 8); + if (enic->conf_cq_count > 0 && enic->cq == NULL) { + dev_err(enic, "failed to allocate vnic_cq, aborting.\n"); + return -1; + } + if (enic->conf_rq_count > 0 && enic->rq == NULL) { + dev_err(enic, "failed to allocate vnic_rq, aborting.\n"); + return -1; + } + if (enic->conf_wq_count > 0 && enic->wq == NULL) { + dev_err(enic, "failed to allocate vnic_wq, aborting.\n"); + return -1; + } /* Get the supported filters */ enic_fdir_info(enic); -- 2.14.2