From patchwork Tue Jul 10 16:04:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrien Mazarguil X-Patchwork-Id: 42731 X-Patchwork-Delegate: shahafs@mellanox.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 3DB961B439; Tue, 10 Jul 2018 18:05:07 +0200 (CEST) Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by dpdk.org (Postfix) with ESMTP id 268B31B1D3 for ; Tue, 10 Jul 2018 18:05:03 +0200 (CEST) Received: by mail-wm0-f67.google.com with SMTP id v25-v6so25240046wmc.0 for ; Tue, 10 Jul 2018 09:05:03 -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=9hrYhb06M81OLEec/FAJOkvBG9oAKlUR/iA+Ybmj35w=; b=qW+ESj4d5L3L9vy0tFB0kv2j0FCQLIcKfd7DwW+ylvESvqMfNo/NFzsUBu+7KNPYp9 CwzUxMtCxzmlfnatDecbcNiqxL5e9xZtmpsUXloXhWDWZa1cMdIscAzyg5FE/yHtYoSs YHA6ZGNcA3sKfGPnWz6acdmcAl+7CH7PbcLqE/PYh/7NTBZ0JfM36RuTsbGN4slRjwfr iwRKH0Hba7Q+vYPRlp60xP09MYJiCLC/ku84kSdqUPal1GstDLaXKRXICVy9850CUHyK dqj+vXBSuThaBlfQ8UCdVPYPwv0i5wWUNRsl8nenp0UTfPq0HQaAPLSA1a7xmjXfnTYl VPSA== 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=9hrYhb06M81OLEec/FAJOkvBG9oAKlUR/iA+Ybmj35w=; b=Jyw47h7NjyAdbbrzsUQJzgYFuYVGnFIFaCjNz0ZNSnxhpmljGuHefkQXGcnHPFR6bI 6TAVO7C6odv/teJyEPFjjQPnjrAH4xpXTEh33JZw1T1OIpKYC+fIgDc0c4ziKZOFo+kr 2tWxlGogGUuKgf/hVPqfXV/KN3Z+szAplJAdi9jefhULAu1ovD5/Wr0MZNq7xrZxs6Hh luWghu5sjptTC4Q272OaTjRLd/oUU6vG1v1Bjj+b8J+uOKNfe3UsZyoHyainQ6jHgS9k GfPOZnN20Jw66Oaiu5vzmJk29rzP92Pwbh3pJKTPIW5ZkRXoA4mDorT1M6TReQQULh/F AGpg== X-Gm-Message-State: APt69E3hNgRdTkZv4tknMIZMHa8TiM1yC/1wQ5jM5/83shRCrdU1SSJG t6NPqxpIRcjSS9PmzkjrWtxZMg== X-Google-Smtp-Source: AAOMgpf6TdcDE/dBGNmIxHg2Tkz3k79K3Ut+Uyb9BRfgZdz7Cn5gaH4our1qZKM7MDhKY2J8g3yQgA== X-Received: by 2002:a1c:b801:: with SMTP id i1-v6mr14599425wmf.30.1531238702816; Tue, 10 Jul 2018 09:05:02 -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 125-v6sm35478652wmw.9.2018.07.10.09.05.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Jul 2018 09:05:01 -0700 (PDT) Date: Tue, 10 Jul 2018 18:04:46 +0200 From: Adrien Mazarguil To: Shahaf Shuler Cc: dev@dpdk.org, Xueming Li Message-ID: <20180710155743.14448-4-adrien.mazarguil@6wind.com> References: <20180705083934.5535-1-adrien.mazarguil@6wind.com> <20180710155743.14448-1-adrien.mazarguil@6wind.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180710155743.14448-1-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.11.0 Subject: [dpdk-dev] [PATCH v5 03/10] net/mlx5: drop useless support for several Verbs ports 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" Unlike mlx4 from which this capability was inherited, mlx5 devices expose exactly one Verbs port per PCI bus address. Each physical port gets assigned its own bus address with a single Verbs port. While harmless, this code requires an extra loop that would get in the way of subsequent refactoring. No functional impact. Signed-off-by: Adrien Mazarguil Cc: Shahaf Shuler Cc: Xueming Li --- v3 changes: This patch was not present in prior revisions. As discussed [1], it was added after finally deciding to remove this support. [1] https://mails.dpdk.org/archives/dev/2018-June/105661.html --- drivers/net/mlx5/mlx5.c | 96 +++++++++++++------------------------ drivers/net/mlx5/mlx5.h | 1 - drivers/net/mlx5/mlx5_ethdev.c | 2 +- drivers/net/mlx5/mlx5_txq.c | 2 +- 4 files changed, 34 insertions(+), 67 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 4e7f29f5b..717d8b268 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -652,11 +652,13 @@ static int mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, struct rte_pci_device *pci_dev) { - struct ibv_device **list = NULL; - struct ibv_device *ibv_dev; + struct ibv_device **list; struct ibv_context *ctx = NULL; struct ibv_device_attr_ex attr; + struct ibv_pd *pd = NULL; struct mlx5dv_context dv_attr = { .comp_mask = 0 }; + struct rte_eth_dev *eth_dev = NULL; + struct priv *priv = NULL; int err = 0; unsigned int vf = 0; unsigned int mps; @@ -719,6 +721,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, err = rte_errno; break; } + mlx5_glue->free_device_list(list); if (ctx == NULL) { switch (err) { case 0: @@ -733,7 +736,6 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, } goto error; } - ibv_dev = list[i]; DRV_LOG(DEBUG, "device opened"); #ifdef HAVE_IBV_MLX5_MOD_SWP dv_attr.comp_mask |= MLX5DV_CONTEXT_MASK_SWP; @@ -827,15 +829,9 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, DEBUG("ibv_query_device_ex() failed"); goto error; } - DRV_LOG(INFO, "%u port(s) detected", attr.orig_attr.phys_port_cnt); - for (i = 0; i < attr.orig_attr.phys_port_cnt; i++) { + { char name[RTE_ETH_NAME_MAX_LEN]; - int len; - uint32_t port = i + 1; /* ports are indexed from one */ struct ibv_port_attr port_attr; - struct ibv_pd *pd = NULL; - struct priv *priv = NULL; - struct rte_eth_dev *eth_dev = NULL; struct ether_addr mac; struct mlx5_dev_config config = { .cqe_comp = cqe_comp, @@ -859,11 +855,9 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, }, }; - len = snprintf(name, sizeof(name), PCI_PRI_FMT, + snprintf(name, sizeof(name), PCI_PRI_FMT, pci_dev->addr.domain, pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function); - if (attr.orig_attr.phys_port_cnt > 1) - snprintf(name + len, sizeof(name), " port %u", i); if (rte_eal_process_type() == RTE_PROC_SECONDARY) { eth_dev = rte_eth_dev_attach_secondary(name); if (eth_dev == NULL) { @@ -901,31 +895,22 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, eth_dev->tx_pkt_burst = mlx5_select_tx_function(eth_dev); rte_eth_dev_probing_finish(eth_dev); - continue; - } - DRV_LOG(DEBUG, "using port %u", port); - if (!ctx) - ctx = mlx5_glue->open_device(ibv_dev); - if (ctx == NULL) { - err = ENODEV; - goto port_error; + claim_zero(mlx5_glue->close_device(ctx)); + return 0; } /* Check port status. */ - err = mlx5_glue->query_port(ctx, port, &port_attr); + err = mlx5_glue->query_port(ctx, 1, &port_attr); if (err) { DRV_LOG(ERR, "port query failed: %s", strerror(err)); - goto port_error; + goto error; } if (port_attr.link_layer != IBV_LINK_LAYER_ETHERNET) { - DRV_LOG(ERR, - "port %d is not configured in Ethernet mode", - port); + DRV_LOG(ERR, "port is not configured in Ethernet mode"); err = EINVAL; - goto port_error; + goto error; } if (port_attr.state != IBV_PORT_ACTIVE) - DRV_LOG(DEBUG, "port %d is not active: \"%s\" (%d)", - port, + DRV_LOG(DEBUG, "port is not active: \"%s\" (%d)", mlx5_glue->port_state_str(port_attr.state), port_attr.state); /* Allocate protection domain. */ @@ -933,7 +918,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, if (pd == NULL) { DRV_LOG(ERR, "PD allocation failure"); err = ENOMEM; - goto port_error; + goto error; } /* from rte_ethdev.c */ priv = rte_zmalloc("ethdev private structure", @@ -942,13 +927,12 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, if (priv == NULL) { DRV_LOG(ERR, "priv allocation failure"); err = ENOMEM; - goto port_error; + goto error; } priv->ctx = ctx; strncpy(priv->ibdev_path, priv->ctx->device->ibdev_path, sizeof(priv->ibdev_path)); priv->device_attr = attr; - priv->port = port; priv->pd = pd; priv->mtu = ETHER_MTU; err = mlx5_args(&config, pci_dev->device.devargs); @@ -956,7 +940,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, err = rte_errno; DRV_LOG(ERR, "failed to process device arguments: %s", strerror(rte_errno)); - goto port_error; + goto error; } config.hw_csum = !!(attr.device_cap_flags_ex & IBV_DEVICE_RAW_IP_CSUM); @@ -1006,7 +990,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, "multi-packet send not supported on this device" " (" MLX5_TXQ_MPW_EN ")"); err = ENOTSUP; - goto port_error; + goto error; } DRV_LOG(INFO, "%s MPS is %s", config.mps == MLX5_MPW_ENHANCED ? "enhanced " : "", @@ -1038,7 +1022,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, if (eth_dev == NULL) { DRV_LOG(ERR, "can not allocate rte ethdev"); err = ENOMEM; - goto port_error; + goto error; } eth_dev->data->dev_private = priv; priv->dev_data = eth_dev->data; @@ -1049,7 +1033,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, err = mlx5_uar_init_primary(eth_dev); if (err) { err = rte_errno; - goto port_error; + goto error; } /* Configure the first MAC address by default. */ if (mlx5_get_mac(eth_dev, &mac.addr_bytes)) { @@ -1058,7 +1042,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, " loaded? (errno: %s)", eth_dev->data->port_id, strerror(rte_errno)); err = ENODEV; - goto port_error; + goto error; } DRV_LOG(INFO, "port %u MAC address is %02x:%02x:%02x:%02x:%02x:%02x", @@ -1082,7 +1066,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, err = mlx5_get_mtu(eth_dev, &priv->mtu); if (err) { err = rte_errno; - goto port_error; + goto error; } DRV_LOG(DEBUG, "port %u MTU is %u", eth_dev->data->port_id, priv->mtu); @@ -1131,7 +1115,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, DRV_LOG(ERR, "port %u drop queue allocation failed: %s", eth_dev->data->port_id, strerror(rte_errno)); err = rte_errno; - goto port_error; + goto error; } /* Supported Verbs flow priority number detection. */ if (verb_priorities == 0) @@ -1140,7 +1124,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, DRV_LOG(ERR, "port %u wrong Verbs flow priorities: %u", eth_dev->data->port_id, verb_priorities); err = ENOTSUP; - goto port_error; + goto error; } priv->config.max_verbs_prio = verb_priorities; /* @@ -1154,7 +1138,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, eth_dev->device->numa_node); if (err) { err = rte_errno; - goto port_error; + goto error; } /* Add device to memory callback list. */ rte_rwlock_write_lock(&mlx5_shared_data->mem_event_rwlock); @@ -1162,33 +1146,17 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, priv, mem_event_cb); rte_rwlock_write_unlock(&mlx5_shared_data->mem_event_rwlock); rte_eth_dev_probing_finish(eth_dev); - /* - * Each eth_dev instance is assigned its own Verbs context, - * since this one is consumed, let the next iteration open - * another. - */ - ctx = NULL; - continue; -port_error: - if (priv) - rte_free(priv); - if (pd) - claim_zero(mlx5_glue->dealloc_pd(pd)); - if (eth_dev && rte_eal_process_type() == RTE_PROC_PRIMARY) - rte_eth_dev_release_port(eth_dev); - break; + return 0; } - /* - * XXX if something went wrong in the loop above, there is a resource - * leak (ctx, pd, priv, dpdk ethdev) but we can do nothing about it as - * long as the dpdk does not provide a way to deallocate a ethdev and a - * way to enumerate the registered ethdevs to free the previous ones. - */ error: + if (priv) + rte_free(priv); + if (pd) + claim_zero(mlx5_glue->dealloc_pd(pd)); + if (eth_dev) + rte_eth_dev_release_port(eth_dev); if (ctx) claim_zero(mlx5_glue->close_device(ctx)); - if (list) - mlx5_glue->free_device_list(list); if (err) { rte_errno = err; return -rte_errno; diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 997b04a33..f55ff4a21 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -159,7 +159,6 @@ struct priv { unsigned int vlan_filter_n; /* Number of configured VLAN filters. */ /* Device properties. */ uint16_t mtu; /* Configured MTU. */ - uint8_t port; /* Physical port number. */ unsigned int isolated:1; /* Whether isolated mode is enabled. */ /* RX/TX queues. */ unsigned int rxqs_n; /* RX queues array size. */ diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c index ebe5cb6e3..819f5baad 100644 --- a/drivers/net/mlx5/mlx5_ethdev.c +++ b/drivers/net/mlx5/mlx5_ethdev.c @@ -166,7 +166,7 @@ mlx5_get_ifname(const struct rte_eth_dev *dev, char (*ifname)[IF_NAMESIZE]) if (dev_port == dev_port_prev) goto try_dev_id; dev_port_prev = dev_port; - if (dev_port == (priv->port - 1u)) + if (dev_port == 0) strlcpy(match, name, sizeof(match)); } closedir(dir); diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c index 669b91319..5057561ae 100644 --- a/drivers/net/mlx5/mlx5_txq.c +++ b/drivers/net/mlx5/mlx5_txq.c @@ -434,7 +434,7 @@ mlx5_txq_ibv_new(struct rte_eth_dev *dev, uint16_t idx) /* Move the QP to this state. */ .qp_state = IBV_QPS_INIT, /* Primary port number. */ - .port_num = priv->port + .port_num = 1, }; ret = mlx5_glue->modify_qp(tmpl.qp, &attr.mod, (IBV_QP_STATE | IBV_QP_PORT));