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 59C8FA00C4; Fri, 5 Aug 2022 12:53:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1049540C35; Fri, 5 Aug 2022 12:53:29 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 7BE5D400D5 for ; Fri, 5 Aug 2022 12:53:27 +0200 (CEST) Received: from [192.168.1.39] (unknown [188.170.75.116]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id DE573A5 for ; Fri, 5 Aug 2022 13:53:26 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru DE573A5 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1659696807; bh=cUDGuSChRNqETLSBfc3iBH+dLjDziYUFoKHGnzg63AY=; h=Date:Subject:To:References:From:In-Reply-To:From; b=r+qwWwH41tBWXIWXnd5FpWZhzrnldgJkYHcLTTtxoweIG8vEHMzU256CRFL1GsY2Q ogVCEHSUNaN8awIw5H/1FHvmXLDvoCANFavCc9SeB2dcu5813G4zOqKwHVZNSkyKzo edNDjBrH8TWVcDA4/myC+kBa19H06w6Umt9b5Ayc= Message-ID: <565a977c-3b60-d57d-ff25-d301ebc1b80c@oktetlabs.ru> Date: Fri, 5 Aug 2022 13:53:26 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v5 03/12] net/nfp: move app specific init logic to own function Content-Language: en-US To: dev@dpdk.org References: <1659681155-16525-1-git-send-email-chaoyong.he@corigine.com> <1659681155-16525-4-git-send-email-chaoyong.he@corigine.com> From: Andrew Rybchenko In-Reply-To: <1659681155-16525-4-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 On 8/5/22 09:32, Chaoyong He wrote: > The NFP card can load different firmware applications. > This commit move the init logic of corenic app of the > secondary process into its own function. > > Signed-off-by: Chaoyong He > Reviewed-by: Niklas Söderlund > --- > drivers/net/nfp/nfp_ethdev.c | 93 +++++++++++++++++++++++++++++--------------- > 1 file changed, 62 insertions(+), 31 deletions(-) > > diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c > index 2c5607c..90dd01e 100644 > --- a/drivers/net/nfp/nfp_ethdev.c > +++ b/drivers/net/nfp/nfp_ethdev.c > @@ -936,7 +936,7 @@ > break; > default: > PMD_INIT_LOG(ERR, "nfp_net: no device ID matching"); > - err = -ENODEV; > + ret = -ENODEV; It looks unrelated to the patch and looks as a bug in previous code/patches which deserves separate fix. > goto pf_cleanup; > } > > @@ -991,6 +991,50 @@ > return ret; > } > > +static int > +nfp_secondary_init_app_nic(struct rte_pci_device *pci_dev, > + struct nfp_rtsym_table *sym_tbl, > + struct nfp_cpp *cpp) > +{ > + int i; > + int err = 0; > + int ret = 0; > + int total_vnics; > + struct nfp_net_hw *hw; > + > + /* Read the number of vNIC's created for the PF */ > + total_vnics = nfp_rtsym_read_le(sym_tbl, "nfd_cfg_pf0_num_ports", &err); > + if (err || total_vnics <= 0 || total_vnics > 8) { Compare err vs 0 explicitly > + PMD_INIT_LOG(ERR, "nfd_cfg_pf0_num_ports symbol with wrong value"); > + return -ENODEV; > + } > + > + for (i = 0; i < total_vnics; i++) { > + struct rte_eth_dev *eth_dev; > + char port_name[RTE_ETH_NAME_MAX_LEN]; > + snprintf(port_name, sizeof(port_name), "%s_port%d", > + pci_dev->device.name, i); > + > + PMD_DRV_LOG(DEBUG, "Secondary attaching to port %s", port_name); > + eth_dev = rte_eth_dev_attach_secondary(port_name); > + if (eth_dev == NULL) { > + RTE_LOG(ERR, EAL, > + "secondary process attach failed, ethdev doesn't exist"); > + ret = -ENODEV; > + break; > + } > + > + eth_dev->process_private = cpp; > + hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); > + if (nfp_net_ethdev_ops_mount(hw, eth_dev)) > + return -EINVAL; > + > + rte_eth_dev_probing_finish(eth_dev); > + } > + > + return ret; > +} > + > /* > * When attaching to the NFP4000/6000 PF on a secondary process there > * is no need to initialise the PF again. Only minimal work is required > @@ -999,12 +1043,10 @@ > static int > nfp_pf_secondary_init(struct rte_pci_device *pci_dev) > { > - int i; > int err = 0; > int ret = 0; > - int total_ports; > + enum nfp_app_id app_id; > struct nfp_cpp *cpp; > - struct nfp_net_hw *hw; > struct nfp_rtsym_table *sym_tbl; > > if (pci_dev == NULL) > @@ -1038,37 +1080,26 @@ > return -EIO; > } > > - total_ports = nfp_rtsym_read_le(sym_tbl, "nfd_cfg_pf0_num_ports", &err); > - if (err || total_ports <= 0 || total_ports > 8) { > - PMD_INIT_LOG(ERR, "nfd_cfg_pf0_num_ports symbol with wrong value"); > - ret = -ENODEV; > + /* Read the app ID of the firmware loaded */ > + app_id = nfp_rtsym_read_le(sym_tbl, "_pf0_net_app_id", &err); > + if (err) { Compare vs 0 > + PMD_INIT_LOG(ERR, "Couldn't read app_id from fw"); > goto sym_tbl_cleanup; > } > > - for (i = 0; i < total_ports; i++) { > - struct rte_eth_dev *eth_dev; > - char port_name[RTE_ETH_NAME_MAX_LEN]; > - > - snprintf(port_name, sizeof(port_name), "%s_port%d", > - pci_dev->device.name, i); > - > - PMD_DRV_LOG(DEBUG, "Secondary attaching to port %s", port_name); > - eth_dev = rte_eth_dev_attach_secondary(port_name); > - if (eth_dev == NULL) { > - RTE_LOG(ERR, EAL, > - "secondary process attach failed, ethdev doesn't exist"); > - ret = -ENODEV; > - break; > + switch (app_id) { > + case NFP_APP_CORE_NIC: > + PMD_INIT_LOG(INFO, "Initializing coreNIC"); > + ret = nfp_secondary_init_app_nic(pci_dev, sym_tbl, cpp); > + if (ret) { Compare vs 0 > + PMD_INIT_LOG(ERR, "Could not initialize coreNIC!"); > + goto sym_tbl_cleanup; > } > - > - hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); > - > - if (nfp_net_ethdev_ops_mount(hw, eth_dev)) > - return -EINVAL; > - > - eth_dev->process_private = cpp; > - > - rte_eth_dev_probing_finish(eth_dev); > + break; > + default: > + PMD_INIT_LOG(ERR, "Unsupported Firmware loaded"); > + ret = -EINVAL; > + goto sym_tbl_cleanup; > } > > if (ret)