From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 76B30A0524; Fri, 14 May 2021 11:20:03 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0A17540042; Fri, 14 May 2021 11:20:03 +0200 (CEST) Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by mails.dpdk.org (Postfix) with ESMTP id 2141F40041 for ; Fri, 14 May 2021 11:20:02 +0200 (CEST) Received: by mail-wr1-f44.google.com with SMTP id h4so29366833wrt.12 for ; Fri, 14 May 2021 02:20:02 -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=FF/Eakve+9E5IbC5zTRP6FPkvbzWBIBWGIFtIHulPGk=; b=lHBOL9fOoY3MFYrMVU0aXa03grxDJtrt/J7K34DSwcSanGXxNq4psMkSv8caaNwS/K 8WhJ3LyMTAD7d4zHeuXbFN8xCw/79rft1ooggDqFr1Kpcb65PSUOuc+45yrsOXF641WG boWc+REOUhBhb0uyxs4cZw6vNHtcExILNgCRUNFEtR/AmcDkhU3BYAYoAFhyUZXuTHju sQFYUAauRoejeJqt/joX677aqu4gC2x5qWQV1THqlymck1a9XsXJ7s+GiPJTbXM2MTh1 sVi8Y49WH4yvTJZ9aa6qj7eNTRc8om/TRtCpuCoJvMIlkVjAmP0jI+qxvKSTor7F2yRk VLvg== 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=FF/Eakve+9E5IbC5zTRP6FPkvbzWBIBWGIFtIHulPGk=; b=nK7ReBNv3nCSPT2sh7wOpC487EmbAz9nMefiCGv/5TATf48fzUNbkS10U2P4TqaUhx heImFpkAAaaZXzPXwjXmz5su7oBoJYSH9c3og8DLl9YYTEYuVe9eHNd62UN0sxosFKkG zqYPs3ZEDcZq0wNwxJNNCIoUutuDU+YKTASctKdP1MU/A9ahTyZ9tgbtmQ5BrO/LE9ti BrilWtcAflqGDERcL8SLrPt3Mg9r1xcD1uTAr7ybgibGVJFX8+H+rN6MuJen87nT2pDF 26E590/a7lU2vFTcgZzdDpaC2gc4Dwm7SG6cGYr4gqGsXL3cs3HvhqpTrLDsinsfDe3f 1mTA== X-Gm-Message-State: AOAM533hL/2ZnYu7t23Ij+0lXBgtiltAhT+eQVOmOuJXMpVF/21PFnob Bh7qwzEl805VyIvr9eEl5mAbkbbbSR2HfW1cDmO52GquLWEi9PgXSxCQm2gljVTUca/a0j8oGlE DBEmVbH8Q2wIbDwP10xY+UY93+F8HAgfWPR5NycDea+/7arii9BOvn1eFRLie7Y/c8Ws= X-Google-Smtp-Source: ABdhPJyE4Ep3TyhorREJMBWnrBrKQZn0eOdqo4UiRZTE/b+LYZd8lKMJeUKNZMnmhiGrqFeCXcN6ww== X-Received: by 2002:a5d:488b:: with SMTP id g11mr56217886wrq.317.1620984001387; Fri, 14 May 2021 02:20:01 -0700 (PDT) Received: from localhost.localdomain ([105.30.25.75]) by smtp.gmail.com with ESMTPSA id g66sm4731107wma.11.2021.05.14.02.20.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 May 2021 02:20:01 -0700 (PDT) From: Heinrich Kuhn To: dev@dpdk.org Cc: Heinrich Kuhn , Simon Horman Date: Fri, 14 May 2021 11:19:34 +0200 Message-Id: <20210514091934.64833-1-heinrich.kuhn@netronome.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] net/nfp: fix internal NFP port addressing 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" Depending on the breakout mode of the physical ports the internal NFP port number might differ from the actual physical port number. Prior to this patch the physical port number was used when making configuration changes to the physical ports (enable, admin up etc). After this change the internal port number is now correctly used for configuration changes. Fixes: 5e15e799d ("net/nfp: create separate entity for PF device") Signed-off-by: Heinrich Kuhn Signed-off-by: Simon Horman --- drivers/net/nfp/nfp_net.c | 38 +++++++++++++++++++++++------------ drivers/net/nfp/nfp_net_pmd.h | 3 +++ 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c index 888324cd2..05370767b 100644 --- a/drivers/net/nfp/nfp_net.c +++ b/drivers/net/nfp/nfp_net.c @@ -769,10 +769,10 @@ nfp_net_start(struct rte_eth_dev *dev) if (hw->is_phyport) { if (rte_eal_process_type() == RTE_PROC_PRIMARY) /* Configure the physical port up */ - nfp_eth_set_configured(hw->cpp, hw->idx, 1); + nfp_eth_set_configured(hw->cpp, hw->nfp_idx, 1); else nfp_eth_set_configured(dev->process_private, - hw->idx, 1); + hw->nfp_idx, 1); } hw->ctrl = new_ctrl; @@ -825,10 +825,10 @@ nfp_net_stop(struct rte_eth_dev *dev) if (hw->is_phyport) { if (rte_eal_process_type() == RTE_PROC_PRIMARY) /* Configure the physical port down */ - nfp_eth_set_configured(hw->cpp, hw->idx, 0); + nfp_eth_set_configured(hw->cpp, hw->nfp_idx, 0); else nfp_eth_set_configured(dev->process_private, - hw->idx, 0); + hw->nfp_idx, 0); } return 0; @@ -849,10 +849,10 @@ nfp_net_set_link_up(struct rte_eth_dev *dev) if (rte_eal_process_type() == RTE_PROC_PRIMARY) /* Configure the physical port down */ - return nfp_eth_set_configured(hw->cpp, hw->idx, 1); + return nfp_eth_set_configured(hw->cpp, hw->nfp_idx, 1); else return nfp_eth_set_configured(dev->process_private, - hw->idx, 1); + hw->nfp_idx, 1); } /* Set the link down. */ @@ -870,10 +870,10 @@ nfp_net_set_link_down(struct rte_eth_dev *dev) if (rte_eal_process_type() == RTE_PROC_PRIMARY) /* Configure the physical port down */ - return nfp_eth_set_configured(hw->cpp, hw->idx, 0); + return nfp_eth_set_configured(hw->cpp, hw->nfp_idx, 0); else return nfp_eth_set_configured(dev->process_private, - hw->idx, 0); + hw->nfp_idx, 0); } /* Reset and stop device. The device can not be restarted. */ @@ -2806,15 +2806,15 @@ nfp_net_init(struct rte_eth_dev *eth_dev) return -ENODEV; } - /* This points to the specific port private data */ - PMD_INIT_LOG(DEBUG, "Working with physical port number %d", - port); - /* Use PF array of physical ports to get pointer to * this specific port */ hw = pf_dev->ports[port]; + PMD_INIT_LOG(DEBUG, "Working with physical port number: %d, " + "NFP internal port number: %d", + port, hw->nfp_idx); + } else { hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); } @@ -3493,9 +3493,17 @@ static int nfp_init_phyports(struct nfp_pf_dev *pf_dev) { struct nfp_net_hw *hw; struct rte_eth_dev *eth_dev; + struct nfp_eth_table *nfp_eth_table = NULL; int ret = 0; int i; + nfp_eth_table = nfp_eth_read_ports(pf_dev->cpp); + if (!nfp_eth_table) { + PMD_INIT_LOG(ERR, "Error reading NFP ethernet table"); + ret = -EIO; + goto error; + } + /* Loop through all physical ports on PF */ for (i = 0; i < pf_dev->total_phyports; i++) { const unsigned int numa_node = rte_socket_id(); @@ -3551,6 +3559,7 @@ static int nfp_init_phyports(struct nfp_pf_dev *pf_dev) hw->cpp = pf_dev->cpp; hw->eth_dev = eth_dev; hw->idx = i; + hw->nfp_idx = nfp_eth_table->ports[i].index; hw->is_phyport = true; nfp_net_init: @@ -3569,7 +3578,8 @@ static int nfp_init_phyports(struct nfp_pf_dev *pf_dev) rte_eth_dev_probing_finish(eth_dev); } /* End loop, all ports on this PF */ - return 0; + ret = 0; + goto eth_table_cleanup; port_cleanup: for (i = 0; i < pf_dev->total_phyports; i++) { @@ -3580,6 +3590,8 @@ static int nfp_init_phyports(struct nfp_pf_dev *pf_dev) pf_dev->ports[i] = NULL; } } +eth_table_cleanup: + free(nfp_eth_table); error: return ret; } diff --git a/drivers/net/nfp/nfp_net_pmd.h b/drivers/net/nfp/nfp_net_pmd.h index 922d94001..b1303b13f 100644 --- a/drivers/net/nfp/nfp_net_pmd.h +++ b/drivers/net/nfp/nfp_net_pmd.h @@ -483,7 +483,10 @@ struct nfp_net_hw { struct nfp_cpp_area *msix_area; uint8_t *hw_queues; + /* Sequential physical port number */ uint8_t idx; + /* Internal port number as seen from NFP */ + uint8_t nfp_idx; bool is_phyport; union eth_table_entry *eth_table; -- 2.30.1 (Apple Git-130)