From patchwork Wed Jun 9 12:15:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Kuhn X-Patchwork-Id: 94057 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6E40FA0C46; Wed, 9 Jun 2021 14:16:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DF97E40E3C; Wed, 9 Jun 2021 14:16:04 +0200 (CEST) Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by mails.dpdk.org (Postfix) with ESMTP id 058184003C for ; Wed, 9 Jun 2021 14:16:03 +0200 (CEST) Received: by mail-wr1-f42.google.com with SMTP id e11so15045106wrg.3 for ; Wed, 09 Jun 2021 05:16:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=eruG17gS2DII9W7CKNRO9tijK2Vjfbs6fDNDDmLXJPE=; b=KdTNna9nQC2WqZoq3j2y+Td10e07Z5IjjfMn+EDPL2hawpyu1QFBKn0RVnpDiqYkD3 wqfV4369O4r1n/0BXr0t9iuAHFa9pCMcR70g46tpy6C0sMl/vt7bpr8CCLikQWXNzdaJ yVTLauntJLZQVWfIYzQOIndrbQpTHcqXYgwuIAKcSyF2/F1jxjzwXQ+R6nQwrNTRVicQ HO8jK9y45ZIrD5W3p8u91qqwOMh7/ofEiKbbvnxDJR0aVE9Fu/k5dOe9UTCy2imInHsu xoJALbLek/hjKMfVU5f6AombLU8FOS7TRLnHxIj3KqvjYnRO5LtYBDNBHtw/b5699IUw 3IeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=eruG17gS2DII9W7CKNRO9tijK2Vjfbs6fDNDDmLXJPE=; b=XBX0zskXYPk2KlBNc33TCHGeXLbybfL6HUlpA/TW/GG7QzAhUGlc8ZzBzvONqJhGFw XY8+5gNQm10TrMcsdjVNB4DmIvyB/668/SFvKbpk1OwqU4NqDOBuwXEoEW8W0ursylA5 vDUH9rEasquE7vYejzfMYu8xUra2BZj+HNggpD0tajjuMcDATAMf1eLPtTxKpX85+gBo 8jKxuh1eq/JwoOEbWiogcu60lfGEI3YCvVqrsIMWj44YGX46yzpy9EZOmafnROjOx/3r q5V4b1bXIDljK2ih/bLE8KsCWChEBXvxYMSKNvk7/MWSzWON3Dz7tPPvLa2zT9mDz6Vy m78g== X-Gm-Message-State: AOAM531s//HhoQzOuhYMHEh1Uy725JeTfAyzkbSU6Eoj729OSwsqgDfs sQRjWBPm4Zn5BWHva5zgirLqeUHR8CuIA0+eYp5drJ6rMLSa1f7bAar9zpPwouKHKEO1LR/c/tR beum89SeZMhEbDOP3G5Tg3bgGUhKppTzyteGaEPpkd+NKTNliQtocRbrM6t1gj9yK X-Google-Smtp-Source: ABdhPJwKZF8hFGbZeUvGhYM2WVDxUbsbCLhAOf8ywO94AjYU2kI/RIfMLa+FooRyQZ/jDKA/EwxIdA== X-Received: by 2002:a5d:5902:: with SMTP id v2mr27404132wrd.272.1623240963513; Wed, 09 Jun 2021 05:16:03 -0700 (PDT) Received: from localhost.localdomain ([105.30.25.75]) by smtp.gmail.com with ESMTPSA id 32sm26669090wrs.5.2021.06.09.05.16.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jun 2021 05:16:03 -0700 (PDT) From: Heinrich Kuhn To: dev@dpdk.org Cc: Heinrich Kuhn , Simon Horman Date: Wed, 9 Jun 2021 14:15:31 +0200 Message-Id: <20210609121532.69998-1-heinrich.kuhn@netronome.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 1/2] net/nfp: improve PF probing logic X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" When using rte_eth_dev_pci_generic_probe() during probing a rte_eth_dev will be created with the name field corresponding to the PCI address of the device. NFP4000/6000 devices only have a single PF (but potentially multiple physical ports). This means that in a simple two port example the rte_eth_devices[] array will be populated with two devices: 0000:02:00.0 and 0000:02:00.0_port1. This is inconsistent and not ideal. It will also cause issues when a secondary process tries to attach to these ports. This patch removes the use of rte_eth_dev_pci_generic_probe() and allocates eth_dev's for each physical port during PF initialization, giving them more consistent names. Fixes: 5e15e799d697 ("net/nfp: create separate entity for PF device") Signed-off-by: Heinrich Kuhn Signed-off-by: Simon Horman --- drivers/net/nfp/nfp_net.c | 31 ++++++++----------------------- drivers/net/nfp/nfp_net_pmd.h | 3 --- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c index 2ee88fbfc7..d94c8dc727 100644 --- a/drivers/net/nfp/nfp_net.c +++ b/drivers/net/nfp/nfp_net.c @@ -58,7 +58,7 @@ static int nfp_net_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu); static int nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info); static int nfp_net_init(struct rte_eth_dev *eth_dev); -static int nfp_pf_init(struct rte_eth_dev *eth_dev); +static int nfp_pf_init(struct rte_pci_device *pci_dev); static int nfp_pci_uninit(struct rte_eth_dev *eth_dev); static int nfp_init_phyports(struct nfp_pf_dev *pf_dev); static int nfp_net_link_update(struct rte_eth_dev *dev, int wait_to_complete); @@ -3530,20 +3530,14 @@ static int nfp_init_phyports(struct nfp_pf_dev *pf_dev) goto nfp_net_init; } - /* First port has already been initialized */ - if (i == 0) { - eth_dev = pf_dev->eth_dev; - goto skip_dev_alloc; - } - - /* Allocate a eth_dev for remaining ports */ + /* Allocate a eth_dev for this phyport */ eth_dev = rte_eth_dev_allocate(port_name); if (!eth_dev) { ret = -ENODEV; goto port_cleanup; } - /* Allocate memory for remaining ports */ + /* Allocate memory for this phyport */ eth_dev->data->dev_private = rte_zmalloc_socket(port_name, sizeof(struct nfp_net_hw), RTE_CACHE_LINE_SIZE, numa_node); @@ -3553,7 +3547,6 @@ static int nfp_init_phyports(struct nfp_pf_dev *pf_dev) goto port_cleanup; } -skip_dev_alloc: hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); /* Add this device to the PF's array of physical ports */ @@ -3600,24 +3593,20 @@ static int nfp_init_phyports(struct nfp_pf_dev *pf_dev) return ret; } -static int nfp_pf_init(struct rte_eth_dev *eth_dev) +static int nfp_pf_init(struct rte_pci_device *pci_dev) { - struct rte_pci_device *pci_dev; - struct nfp_net_hw *hw = NULL; struct nfp_pf_dev *pf_dev = NULL; struct nfp_cpp *cpp; struct nfp_hwinfo *hwinfo; struct nfp_rtsym_table *sym_tbl; struct nfp_eth_table *nfp_eth_table = NULL; struct rte_service_spec service; + uint32_t *nfp_cpp_service_id = NULL; char name[RTE_ETH_NAME_MAX_LEN]; int total_ports; int ret = -ENODEV; int err; - pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); - hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev); - if (!pci_dev) return ret; @@ -3685,7 +3674,7 @@ static int nfp_pf_init(struct rte_eth_dev *eth_dev) goto sym_tbl_cleanup; } /* Allocate memory for the PF "device" */ - snprintf(name, sizeof(name), "nfp_pf%d", eth_dev->data->port_id); + snprintf(name, sizeof(name), "nfp_pf%d", 0); pf_dev = rte_zmalloc(name, sizeof(*pf_dev), 0); if (!pf_dev) { ret = -ENOMEM; @@ -3703,9 +3692,6 @@ static int nfp_pf_init(struct rte_eth_dev *eth_dev) pf_dev->pci_dev = pci_dev; - /* The first eth_dev is part of the PF struct */ - pf_dev->eth_dev = eth_dev; - /* Map the symbol table */ pf_dev->ctrl_bar = nfp_rtsym_map(pf_dev->sym_tbl, "_pf0_net_bar0", pf_dev->total_phyports * 32768, @@ -3754,7 +3740,7 @@ static int nfp_pf_init(struct rte_eth_dev *eth_dev) service.callback_userdata = (void *)cpp; if (rte_service_component_register(&service, - &hw->nfp_cpp_service_id)) + nfp_cpp_service_id)) RTE_LOG(ERR, PMD, "NFP CPP bridge service register() failed"); else RTE_LOG(DEBUG, PMD, "NFP CPP bridge service registered"); @@ -3780,8 +3766,7 @@ static int nfp_pf_init(struct rte_eth_dev *eth_dev) static int nfp_pf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, struct rte_pci_device *dev) { - return rte_eth_dev_pci_generic_probe(dev, - sizeof(struct nfp_net_hw), nfp_pf_init); + return nfp_pf_init(dev); } static const struct rte_pci_id pci_id_nfp_pf_net_map[] = { diff --git a/drivers/net/nfp/nfp_net_pmd.h b/drivers/net/nfp/nfp_net_pmd.h index b1303b13f5..212f9ef162 100644 --- a/drivers/net/nfp/nfp_net_pmd.h +++ b/drivers/net/nfp/nfp_net_pmd.h @@ -389,9 +389,6 @@ struct nfp_pf_dev { /* Backpointer to associated pci device */ struct rte_pci_device *pci_dev; - /* First physical port's eth device */ - struct rte_eth_dev *eth_dev; - /* Array of physical ports belonging to this PF */ struct nfp_net_hw *ports[NFP_MAX_PHYPORTS];