On Tue, Oct 27, 2020 at 11:23:20PM +0000, Ophir Munk wrote: > From: Tal Shnaiderman <tal...@nvidia.com> > > 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 <tal...@nvidia.com> > Signed-off-by: Ophir Munk <ophi...@nvidia.com> > --- > 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