From patchwork Tue Aug 1 16:53:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrien Mazarguil X-Patchwork-Id: 27314 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 278EE9B75; Tue, 1 Aug 2017 18:54:58 +0200 (CEST) Received: from mail-wm0-f47.google.com (mail-wm0-f47.google.com [74.125.82.47]) by dpdk.org (Postfix) with ESMTP id E47539183 for ; Tue, 1 Aug 2017 18:54:53 +0200 (CEST) Received: by mail-wm0-f47.google.com with SMTP id k20so24262456wmg.0 for ; Tue, 01 Aug 2017 09:54:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=jQqmQNiT4w3n/FEbTQ9g6naF7sDAl3iH6ekHyBfC+F8=; b=HEQJngOuCESiPhbN7lDJX9tlSpisUjBSQA9Fy+ZIb8dUbTNxNHhVtVJ7S5RlvU5JUd sz4Wx3mJIVcDHUStSt1OW7zhdkSulouab+wpTQx5TIAjvaeoErkKIJHUYtBiT0z2Jkhm ps4LHWBvsiSJZs+vgPXQ3oyecehKNO/IJ/FRqxlXijB2affmqVPeuYfzSTTJQKtzSUc+ 80x15y/u0sE/dZ2udIuApVJ4rfXkaxhOFWacqjX4gIwxndEbUkgHUxN2K3ORiPHeX9ps J/oVqSRKXzi0wJcuNDbbJDntKyIdeQ6SlMENxmBSu10Q9ip37FAl2wi2uuKk4KIZTiah 7D2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=jQqmQNiT4w3n/FEbTQ9g6naF7sDAl3iH6ekHyBfC+F8=; b=F8V25PbgpdNG5Gq2dbmAiv4OYiUL/7m77HRzfNeMWysGF+v8bbcJYwrw30LSxbS/AJ L4R4fg2EPSqta4PnsDVbfbL66+OMidUQX70Auf83cUx6TyRi/ih9OkO6uhN3cBb6x5KO EWhzLjNElgi6lDzXps51x9M83PbAneUCR9jvHt4d7tEvHevk17PQmwVTXrv7R3VhlCaE 2dZ30WF9aDI0iC15dvf2QPtMe19o/NmccESD1l7g013pEz6Og3lpn8uKNdYFphP1xzmx KUqIA23fkm/7pL6GyGihljXZ1S+72wkVCAC1dq2yAVj5DAKznveQQSLqbBgzWkpTDkds ul8A== X-Gm-Message-State: AIVw111f7zPjcr1OeooUM4CNzXZjLulJ7NwOtpwkGzzRNRoFvgmZqEp6 FkbUscrQlTk2yG/GQRE= X-Received: by 10.28.20.67 with SMTP id 64mr1961937wmu.60.1501606492359; Tue, 01 Aug 2017 09:54:52 -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 w64sm1535935wmw.1.2017.08.01.09.54.51 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 01 Aug 2017 09:54:51 -0700 (PDT) From: Adrien Mazarguil To: dev@dpdk.org Date: Tue, 1 Aug 2017 18:53:49 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v1 02/48] net/mlx4: remove limitation on number of instances 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" The seemingly artificial limitation on the maximum number of instances for this PMD is an historical leftover that predates its first public release. It was used as a workaround to support multiple physical ports on a PCI device exposing a single bus address when mlx4 was implemented directly as an Ethernet device driver instead of a PCI driver spawning Ethernet devices. Getting rid of it simplifies device initialization. Signed-off-by: Adrien Mazarguil --- drivers/net/mlx4/mlx4.c | 57 +++----------------------------------------- 1 file changed, 3 insertions(+), 54 deletions(-) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index b5a7607..0ae78e0 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -5444,40 +5444,6 @@ priv_get_mac(struct priv *priv, uint8_t (*mac)[ETHER_ADDR_LEN]) return 0; } -/* Support up to 32 adapters. */ -static struct { - struct rte_pci_addr pci_addr; /* associated PCI address */ - uint32_t ports; /* physical ports bitfield. */ -} mlx4_dev[32]; - -/** - * Get device index in mlx4_dev[] from PCI bus address. - * - * @param[in] pci_addr - * PCI bus address to look for. - * - * @return - * mlx4_dev[] index on success, -1 on failure. - */ -static int -mlx4_dev_idx(struct rte_pci_addr *pci_addr) -{ - unsigned int i; - int ret = -1; - - assert(pci_addr != NULL); - for (i = 0; (i != elemof(mlx4_dev)); ++i) { - if ((mlx4_dev[i].pci_addr.domain == pci_addr->domain) && - (mlx4_dev[i].pci_addr.bus == pci_addr->bus) && - (mlx4_dev[i].pci_addr.devid == pci_addr->devid) && - (mlx4_dev[i].pci_addr.function == pci_addr->function)) - return i; - if ((mlx4_dev[i].ports == 0) && (ret == -1)) - ret = i; - } - return ret; -} - /** * Retrieve integer value from environment variable. * @@ -6060,21 +6026,11 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) .active_ports = 0, }; unsigned int vf; - int idx; int i; (void)pci_drv; assert(pci_drv == &mlx4_driver); - /* Get mlx4_dev[] index. */ - idx = mlx4_dev_idx(&pci_dev->addr); - if (idx == -1) { - ERROR("this driver cannot support any more adapters"); - return -ENOMEM; - } - DEBUG("using driver device index %d", idx); - /* Save PCI address. */ - mlx4_dev[idx].pci_addr = pci_dev->addr; list = ibv_get_device_list(&i); if (list == NULL) { assert(errno); @@ -6141,7 +6097,6 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) } for (i = 0; i < device_attr.phys_port_cnt; i++) { uint32_t port = i + 1; /* ports are indexed from one */ - uint32_t test = (1 << i); struct ibv_context *ctx = NULL; struct ibv_port_attr port_attr; struct ibv_pd *pd = NULL; @@ -6162,7 +6117,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) #endif /* RSS_SUPPORT */ #endif /* HAVE_EXP_QUERY_DEVICE */ - DEBUG("using port %u (%08" PRIx32 ")", port, test); + DEBUG("using port %u", port); ctx = ibv_open_device(ibv_dev); if (ctx == NULL) { @@ -6198,8 +6153,6 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) goto port_error; } - mlx4_dev[idx].ports |= test; - /* from rte_ethdev.c */ priv = rte_zmalloc("ethdev private structure", sizeof(*priv), @@ -6405,6 +6358,8 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) rte_eth_dev_release_port(eth_dev); break; } + if (i == device_attr.phys_port_cnt) + return 0; /* * XXX if something went wrong in the loop above, there is a resource @@ -6413,12 +6368,6 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) * way to enumerate the registered ethdevs to free the previous ones. */ - /* no port found, complain */ - if (!mlx4_dev[idx].ports) { - err = ENODEV; - goto error; - } - error: if (attr_ctx) claim_zero(ibv_close_device(attr_ctx));