From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by dpdk.org (Postfix) with ESMTP id 3C1B91BF75 for ; Wed, 4 Jul 2018 19:28:07 +0200 (CEST) Received: by mail-wm0-f68.google.com with SMTP id v3-v6so3404591wmh.0 for ; Wed, 04 Jul 2018 10:28:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=F6UKdF8chVk02b+gy5+r5VSdXFrrdqIlPgEhvkrtS4E=; b=WL1I6HKr9JFpi5Iuvqt9HRwBaYIHl0zQAmpu6+ig+NugWOqP97R9+U7nKdUgqAeOPp VTOqXjbYbGNWYIK3cSs8Ds4Kv/qbMkwfBLUC6MYttCDQxtYPRFfaPeUZJ6HBJ8u7O3Ag 1iWBtM79l87qV7qlS4hOYL2jOTCj+9ti2fO4XgMRYrwrqhTZ6UHqMr5IkYJk3lzt+Wfq ehdoZ/9AbIbmn9ZqJkX/0OH/HkaBHMGrF1LgFD+ChNidWSUhPJW+VGipYobDOhGgEJBS jEOWQnBFUrFmeYXfLZoC7iXbl+HPGvoSrZsDGnGyG6W5DFlVOm///vi5Sx4lmZorUQbx tohg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=F6UKdF8chVk02b+gy5+r5VSdXFrrdqIlPgEhvkrtS4E=; b=mwHGKPUSK1kRnmER+hEeoZeqSQDChsOeVGw7IotcHEGYtJq3mZWstGTxNuFALxkITa uF3pI4k2rl1ltgZa8WUC2q2Poan9f1ze2w88GNvEPCndczNmXpOm1f/1gVY1Tcm68oBJ uolRy2lZ3uGv2yh+QLmhx9ZVjxp+4x48iMbQepj/oeJnJPrWCFKEXxFZJ4BWACaRVtkN SF5NfU37dq+V5rTfPO0Yz0je8qSFE/DiaEIpl/1mKu5TFSNli3xUOHCO2Vcbjr/kaV9Q ckLTfiYhDrg2vx6EyQRqC9DLNctOpreeCdTuV9XvJWOj98tf+xgcPzYQQucmW/QlFsQ3 50lg== X-Gm-Message-State: APt69E0M9YwQqWy+xOKw89Ho/rVbSGWTPbAprmqTmryZbbic8dAT2r8n 9376jyFw3bi63W54eO6f5xqWfQ== X-Google-Smtp-Source: AAOMgpehrbDCeTCp4mrWaU+ucNv83Tm8LeHvxc/AJUTnpnG3AIVSPaFNHIahSoySsYj2lJzmObo5nQ== X-Received: by 2002:a1c:7501:: with SMTP id o1-v6mr2221648wmc.133.1530725286988; Wed, 04 Jul 2018 10:28:06 -0700 (PDT) Received: from 6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id r10-v6sm6549505wrm.66.2018.07.04.10.28.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Jul 2018 10:28:06 -0700 (PDT) Date: Wed, 4 Jul 2018 19:27:50 +0200 From: Adrien Mazarguil To: Shahaf Shuler Cc: dev@dpdk.org Message-ID: <20180704172322.22571-10-adrien.mazarguil@6wind.com> References: <20180614083047.10812-1-adrien.mazarguil@6wind.com> <20180704172322.22571-1-adrien.mazarguil@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180704172322.22571-1-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.11.0 Subject: [dpdk-dev] [PATCH v3 09/10] net/mlx5: add parameter for port representors 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: , X-List-Received-Date: Wed, 04 Jul 2018 17:28:07 -0000 Prior to this patch, all port representors detected on a given device were probed and Ethernet devices instantiated for each of them. This patch adds support for the standard "representor" parameter, which implies that port representors are not probed by default anymore, except for the list provided through device arguments. (Patch based on prior work from Yuanhan Liu) Signed-off-by: Adrien Mazarguil Reviewed-by: Xueming Li -- v3 changes: - Adapted representor detection to the reworked mlx5_dev_spawn(). v2 changes: - Added error message for when rte_eth_devargs_parse() fails. --- doc/guides/nics/mlx5.rst | 12 ++++++++ doc/guides/prog_guide/poll_mode_drv.rst | 2 ++ drivers/net/mlx5/mlx5.c | 41 ++++++++++++++++++++++++++-- 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index 7dd9c1c5e..0d0d21727 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -392,6 +392,18 @@ Run-time configuration Disabled by default. +- ``representor`` parameter [list] + + This parameter can be used to instantiate DPDK Ethernet devices from + existing port (or VF) representors configured on the device. + + It is a standard parameter whose format is described in + :ref:`ethernet_device_standard_device_arguments`. + + For instance, to probe port representors 0 through 2:: + + representor=[0-2] + Firmware configuration ~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/guides/prog_guide/poll_mode_drv.rst b/doc/guides/prog_guide/poll_mode_drv.rst index af82352a0..58d49ba0f 100644 --- a/doc/guides/prog_guide/poll_mode_drv.rst +++ b/doc/guides/prog_guide/poll_mode_drv.rst @@ -365,6 +365,8 @@ Ethernet Device API The Ethernet device API exported by the Ethernet PMDs is described in the *DPDK API Reference*. +.. _ethernet_device_standard_device_arguments: + Ethernet Device Standard Device Arguments ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 05dd3bbe7..7e757274a 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -92,6 +92,9 @@ /* Activate Netlink support in VF mode. */ #define MLX5_VF_NL_EN "vf_nl_en" +/* Select port representors to instantiate. */ +#define MLX5_REPRESENTOR "representor" + #ifndef HAVE_IBV_MLX5_MOD_MPW #define MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED (1 << 2) #define MLX5DV_CONTEXT_FLAGS_ENHANCED_MPW (1 << 3) @@ -426,6 +429,9 @@ mlx5_args_check(const char *key, const char *val, void *opaque) struct mlx5_dev_config *config = opaque; unsigned long tmp; + /* No-op, port representors are processed in mlx5_dev_spawn(). */ + if (!strcmp(MLX5_REPRESENTOR, key)) + return 0; errno = 0; tmp = strtoul(val, NULL, 0); if (errno) { @@ -498,6 +504,7 @@ mlx5_args(struct mlx5_dev_config *config, struct rte_devargs *devargs) MLX5_RX_VEC_EN, MLX5_L3_VXLAN_EN, MLX5_VF_NL_EN, + MLX5_REPRESENTOR, NULL, }; struct rte_kvargs *kvlist; @@ -655,7 +662,9 @@ mlx5_uar_init_secondary(struct rte_eth_dev *dev) * * @return * A valid Ethernet device object on success, NULL otherwise and rte_errno - * is set. + * is set. The following error is defined: + * + * EBUSY: device is not supposed to be spawned. */ static struct rte_eth_dev * mlx5_dev_spawn(struct rte_device *dpdk_dev, @@ -707,6 +716,26 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, int own_domain_id = 0; unsigned int i; + /* Determine if this port representor is supposed to be spawned. */ + if (switch_info->representor && dpdk_dev->devargs) { + struct rte_eth_devargs eth_da; + + err = rte_eth_devargs_parse(dpdk_dev->devargs->args, ð_da); + if (err) { + rte_errno = -err; + DRV_LOG(ERR, "failed to process device arguments: %s", + strerror(rte_errno)); + return NULL; + } + for (i = 0; i < eth_da.nb_representor_ports; ++i) + if (eth_da.representor_ports[i] == + (uint16_t)switch_info->port_name) + break; + if (i == eth_da.nb_representor_ports) { + rte_errno = EBUSY; + return NULL; + } + } /* Prepare shared data between primary and secondary process. */ mlx5_prepare_shared_data(); errno = 0; @@ -1318,8 +1347,12 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, list[i].eth_dev = mlx5_dev_spawn (&pci_dev->device, list[i].ibv_dev, vf, &list[i].info); - if (!list[i].eth_dev) - break; + if (!list[i].eth_dev) { + if (rte_errno != EBUSY) + break; + /* Device is disabled, ignore it. */ + continue; + } restore = list[i].eth_dev->data->dev_flags; rte_eth_copy_pci_info(list[i].eth_dev, pci_dev); /* Restore non-PCI flags cleared by the above call. */ @@ -1345,6 +1378,8 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, ret = -rte_errno; /* Roll back. */ while (i--) { + if (!list[i].eth_dev) + continue; mlx5_dev_close(list[i].eth_dev); if (rte_eal_process_type() == RTE_PROC_PRIMARY) rte_free(list[i].eth_dev->data->dev_private); -- 2.11.0