From patchwork Wed Sep 25 07:53:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 59700 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6FD4E343C; Wed, 25 Sep 2019 09:54:00 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 531D52E83 for ; Wed, 25 Sep 2019 09:53:55 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from viacheslavo@mellanox.com) with ESMTPS (AES256-SHA encrypted); 25 Sep 2019 10:53:53 +0300 Received: from pegasus12.mtr.labs.mlnx (pegasus12.mtr.labs.mlnx [10.210.17.40]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x8P7rr7a030210; Wed, 25 Sep 2019 10:53:53 +0300 Received: from pegasus12.mtr.labs.mlnx (localhost [127.0.0.1]) by pegasus12.mtr.labs.mlnx (8.14.7/8.14.7) with ESMTP id x8P7rrFv006858; Wed, 25 Sep 2019 07:53:53 GMT Received: (from viacheslavo@localhost) by pegasus12.mtr.labs.mlnx (8.14.7/8.14.7/Submit) id x8P7rrN4006857; Wed, 25 Sep 2019 07:53:53 GMT X-Authentication-Warning: pegasus12.mtr.labs.mlnx: viacheslavo set sender to viacheslavo@mellanox.com using -f From: Viacheslav Ovsiienko To: dev@dpdk.org Cc: matan@mellanox.com, rasland@mellanox.com Date: Wed, 25 Sep 2019 07:53:26 +0000 Message-Id: <1569398015-6027-4-git-send-email-viacheslavo@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1569398015-6027-1-git-send-email-viacheslavo@mellanox.com> References: <1569398015-6027-1-git-send-email-viacheslavo@mellanox.com> Subject: [dpdk-dev] [PATCH 03/12] net/mlx5: allocate device list explicitly 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" At device probing the device list to spawn was allocated as dynamic size local variable. It was no possible to have one unified exit point from routine due to compiler warnings. This patch allocates the spawn device list directly with rte_zmalloc() and it is possible to goto to unified exit label from anywhere of the routine. Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index dd8159c..701da7e 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -2154,6 +2154,7 @@ struct mlx5_dev_spawn_data { * Actually this is the number of iterations to spawn. */ unsigned int ns = 0; + struct mlx5_dev_spawn_data *list = NULL; struct mlx5_dev_config dev_config; int ret; @@ -2176,8 +2177,8 @@ struct mlx5_dev_spawn_data { * matching ones, gathering into the list. */ struct ibv_device *ibv_match[ret + 1]; - int nl_route = -1; - int nl_rdma = -1; + int nl_route = mlx5_nl_init(NETLINK_ROUTE); + int nl_rdma = mlx5_nl_init(NETLINK_RDMA); unsigned int i; while (ret-- > 0) { @@ -2199,7 +2200,6 @@ struct mlx5_dev_spawn_data { ibv_match[nd] = NULL; if (!nd) { /* No device matches, just complain and bail out. */ - mlx5_glue->free_device_list(ibv_list); DRV_LOG(WARNING, "no Verbs device matches PCI device " PCI_PRI_FMT "," " are kernel drivers loaded?", @@ -2207,10 +2207,8 @@ struct mlx5_dev_spawn_data { pci_dev->addr.devid, pci_dev->addr.function); rte_errno = ENOENT; ret = -rte_errno; - return ret; + goto exit; } - nl_route = mlx5_nl_init(NETLINK_ROUTE); - nl_rdma = mlx5_nl_init(NETLINK_RDMA); if (nd == 1) { /* * Found single matching device may have multiple ports. @@ -2227,8 +2225,16 @@ struct mlx5_dev_spawn_data { * Now we can determine the maximal * amount of devices to be spawned. */ - struct mlx5_dev_spawn_data list[np ? np : nd]; - + list = rte_zmalloc("device spawn data", + sizeof(struct mlx5_dev_spawn_data) * + (np ? np : nd), + RTE_CACHE_LINE_SIZE); + if (!list) { + DRV_LOG(ERR, "spawn data array allocation failure"); + rte_errno = ENOMEM; + ret = -rte_errno; + goto exit; + } if (np > 1) { /* * Single IB device with multiple ports found, @@ -2477,12 +2483,15 @@ struct mlx5_dev_spawn_data { /* * Do the routine cleanup: * - close opened Netlink sockets + * - free allocated spawn data array * - free the Infiniband device list */ if (nl_rdma >= 0) close(nl_rdma); if (nl_route >= 0) close(nl_route); + if (list) + rte_free(list); assert(ibv_list); mlx5_glue->free_device_list(ibv_list); return ret;