From patchwork Wed Jun 24 13:23:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Baum X-Patchwork-Id: 72137 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A387CA0350; Wed, 24 Jun 2020 15:25:11 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 33C541D93A; Wed, 24 Jun 2020 15:25:11 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id E98C31D933 for ; Wed, 24 Jun 2020 15:25:09 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from matan@mellanox.com) with SMTP; 24 Jun 2020 16:25:09 +0300 Received: from pegasus07.mtr.labs.mlnx (pegasus07.mtr.labs.mlnx [10.210.16.112]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 05ODO97k025703; Wed, 24 Jun 2020 16:24:09 +0300 From: Michael Baum To: dev@dpdk.org Cc: matan@mellanox.com, viacheslavo@mellanox.com Date: Wed, 24 Jun 2020 13:23:57 +0000 Message-Id: <1593005037-4228-1-git-send-email-michaelba@mellanox.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH] net/mlx5: use direct API to find port by device 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Using RTE_ETH_FOREACH_DEV_OF loop is not necessary when the driver wants to find only the first match. Use rte_eth_find_next_of to find it. Signed-off-by: Michael Baum Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5_mr.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c index adbe07c..3b781b6 100644 --- a/drivers/net/mlx5/mlx5_mr.c +++ b/drivers/net/mlx5/mlx5_mr.c @@ -313,9 +313,10 @@ struct mr_update_mp_data { { uint16_t port_id; - RTE_ETH_FOREACH_DEV_OF(port_id, &pdev->device) - return &rte_eth_devices[port_id]; - return NULL; + port_id = rte_eth_find_next_of(0, &pdev->device); + if (port_id == RTE_MAX_ETHPORTS) + return NULL; + return &rte_eth_devices[port_id]; } /**