From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id AE955A04E7; Wed, 11 Nov 2020 01:02:18 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7A1772B93; Wed, 11 Nov 2020 01:02:16 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by dpdk.org (Postfix) with ESMTP id 6AF60F90 for ; Wed, 11 Nov 2020 01:02:15 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1059) id 9722620C27FA; Tue, 10 Nov 2020 16:02:13 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 9722620C27FA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1605052933; bh=Nmu9RoTw6aw6m7nL6UW9PkBnf8tWEuja2yuNdvxZicQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=oquTFbuAtePujyGZgZLyq2QPcy9rW2g0HRATAZj/TRlWxMhD8pgqKDgdgWxvoNqAv fT64V885RjW8yqCySlNSq2sGKy+aFc0ZoCzSVGfO0d0Ws0gsd9HrpfWg/xjwJKUlY/ LWpHSnoawz1jIWJ802A4yxUrgkw6pUGKlBvFvsxw= Date: Tue, 10 Nov 2020 16:02:13 -0800 From: Narcisa Ana Maria Vasile To: Ophir Munk Cc: dev@dpdk.org, Raslan Darawsheh , Matan Azrad , Tal Shnaiderman , Thomas Monjalon , Harini Ramakrishnan Message-ID: <20201111000213.GB9449@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <20201027232335.31427-1-ophirmu@nvidia.com> <20201027232335.31427-58-ophirmu@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201027232335.31427-58-ophirmu@nvidia.com> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [dpdk-dev] [PATCH v1 57/72] net/mlx5/windows: initial probing implementation 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" On Tue, Oct 27, 2020 at 11:23:20PM +0000, Ophir Munk wrote: > From: Tal Shnaiderman > > This commit implements mlx5_os_pci_probe API under Windows. It does all > required initializations then it gets the PCI device list using glue API > get_device_list(). Next, all non MLX5 matched devices are filtered out. > The supported NIC types are: CONNECTX4VF, CONNECTX4LXVF, CONNECTX5VF, > CONNECTX5EXVF, CONNECTX5BFVF, CONNECTX6VF, MELLANOX_CONNECTX6DXVF. Each > device in the list is assigned with default configuration parameters, > most of them are 0. The default dv_flow_en parameter value is 1 (which > means Windows match and action flows are based on DV code). Next for > each PCI device call mlx5_dev_spawn() to create an eth device (struct > rte_ethdev). The implementation of device spawn is in the follow up > commit. Finally, the device list is free. > > Signed-off-by: Tal Shnaiderman > Signed-off-by: Ophir Munk > --- > drivers/net/mlx5/windows/mlx5_os.c | 278 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 278 insertions(+) > > +static int > +mlx5_init_shared_data(void) > +{ > + const struct rte_memzone *mz; > + int ret = 0; > + > + rte_spinlock_lock(&mlx5_shared_data_lock); > + if (mlx5_shared_data == NULL) { Maybe: Invert the check to reduce indentation. You can also move it before taking the lock: if (mlx5_shared_data) { return 0; } > + if (rte_eal_process_type() == RTE_PROC_PRIMARY) { > + /* Allocate shared memory. */ > + mz = rte_memzone_reserve(MZ_MLX5_PMD_SHARED_DATA, > + sizeof(*mlx5_shared_data), > + SOCKET_ID_ANY, 0); > + if (mz == NULL) { > + DRV_LOG(ERR, > + "Cannot allocate mlx5 shared data"); > + ret = -rte_errno; > + goto error; > + } > + mlx5_shared_data = mz->addr; > + memset(mlx5_shared_data, 0, sizeof(*mlx5_shared_data)); > + rte_spinlock_init(&mlx5_shared_data->lock); > + } else { > + /* Lookup allocated shared memory. */ > + mz = rte_memzone_lookup(MZ_MLX5_PMD_SHARED_DATA); > + if (mz == NULL) { > + DRV_LOG(ERR, > + "Cannot attach mlx5 shared data"); > + ret = -rte_errno; > + goto error; > + } > + mlx5_shared_data = mz->addr; > + memset(&mlx5_local_data, 0, sizeof(mlx5_local_data)); > + } > + } > +error: > + rte_spinlock_unlock(&mlx5_shared_data_lock); > + return ret; > +} > + dev_config.dv_flow_en = 1; > + dev_config.decap_en = 0; > + dev_config.log_hp_size = MLX5_ARG_UNSET; > + list[ns].eth_dev = mlx5_dev_spawn(&pci_dev->device, > + &list[ns], > + &dev_config); > + if (!list[ns].eth_dev) mlx5_dev_spawn() updates rte_errno, we should ret to rte_errno before exiting here. > + goto exit; > + restore = list[ns].eth_dev->data->dev_flags; > + rte_eth_copy_pci_info(list[ns].eth_dev, pci_dev); > + /* Restore non-PCI flags cleared by the above call. */ > + list[ns].eth_dev->data->dev_flags |= restore; > + rte_eth_dev_probing_finish(list[ns].eth_dev); > + ret = 0; > 2.8.4