From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 992BFA034D for ; Wed, 23 Feb 2022 12:54:13 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8D3B1426DE; Wed, 23 Feb 2022 12:54:13 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id D373A426D8; Wed, 23 Feb 2022 12:54:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645617251; x=1677153251; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gpPWbdkhuH0E7rjGXP1uKMZIeJSJysknNTlRG1SSBDQ=; b=j2Cu+asHBzpwL93xLwt4pFhuebpfk/Jz7dLCkzy0FVs103LAnqxE/oyN MxukVnkdX0cvKR9aCdBEmYQNyMjEfMcsjSjSwUukwVGdsbkSpyaUvJeDX kuF+N8m4h5HBVOpKlEQGRfyGYAgerJ//1EVa3wRA261Xdabb5GojHX3mW 6DR6+H2f+YD07ViCewFVlxtBygpNa5xlUip6ZENEinFBJKt7RXQSq8P2b DO0R62lYRfZxk+/9LgQMI21lpawWelLgGHroKLj080XZgPjH0atHfA1Ed tkrr85QTA3hpEB005MyVVljoVfyp0bCv58T/5i93lXs+LF3g+NmeZ/bAI A==; X-IronPort-AV: E=McAfee;i="6200,9189,10266"; a="249529285" X-IronPort-AV: E=Sophos;i="5.88,390,1635231600"; d="scan'208";a="249529285" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Feb 2022 03:54:09 -0800 X-IronPort-AV: E=Sophos;i="5.88,390,1635231600"; d="scan'208";a="532651267" Received: from unknown (HELO localhost.localdomain) ([10.239.251.3]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Feb 2022 03:54:07 -0800 From: wenxuanx.wu@intel.com To: xiaoyun.li@intel.com, ferruh.yigit@intel.com, dev@dpdk.org Cc: wenxuan wu , stable@dpdk.org Subject: [PATCH v2 1/2] lib/ethdev: add reverse macro to quit testpmd Date: Wed, 23 Feb 2022 19:32:50 +0800 Message-Id: <20220223113251.723692-2-wenxuanx.wu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220223113251.723692-1-wenxuanx.wu@intel.com> References: <20220223113251.723692-1-wenxuanx.wu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org From: wenxuan wu There is a heap-free-after-use bug when quit testpmd with pf and vfs, stop and close ports in reverse order is a more reasonable approach. Cc: stable@dpdk.org Signed-off-by: wenxuan wu --- lib/ethdev/rte_ethdev.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index 2660e4f374..813f72e825 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -2185,7 +2185,8 @@ struct rte_eth_dev_owner { * @return * Next valid port ID owned by owner_id, RTE_MAX_ETHPORTS if there is none. */ -uint64_t rte_eth_find_next_owned_by(uint16_t port_id, +uint64_t +rte_eth_find_next_owned_by(uint16_t port_id, const uint64_t owner_id); /** @@ -2212,6 +2213,14 @@ uint16_t rte_eth_find_next(uint16_t port_id); #define RTE_ETH_FOREACH_DEV(p) \ RTE_ETH_FOREACH_DEV_OWNED_BY(p, RTE_ETH_DEV_NO_OWNER) +/** + * Macro to iterate over all enabled and ownerless ethdev ports in reverse order. + */ +#define RTE_ETH_FOREACH_DEV_REVERSE(p) \ + for (p = rte_eth_dev_count_total() - 1; \ + p < rte_eth_dev_count_total(); \ + p--) + /** * Iterates over ethdev ports of a specified device. * -- 2.25.1