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 35903A0547; Fri, 9 Apr 2021 16:40:42 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0F031141058; Fri, 9 Apr 2021 16:40:42 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id C359B4014D for ; Fri, 9 Apr 2021 16:40:40 +0200 (CEST) IronPort-SDR: zlOJ6zbOrBoWtev+ce36k1ZJrte1NPE+CgBtv6vchE60XzJnCdHzCUm4avXmQRyF5MAAZUb1ya WKO7tahFRXzQ== X-IronPort-AV: E=McAfee;i="6000,8403,9949"; a="173253511" X-IronPort-AV: E=Sophos;i="5.82,209,1613462400"; d="scan'208";a="173253511" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2021 07:40:22 -0700 IronPort-SDR: ouN6YGIc4oNmbQkpS/iG4BoYFWWAxbWKK6hsHkvHTr9t3OEwuA/tEnkmIfr9FA08WvVWCZ5It0 qfmbI5udCmEg== X-IronPort-AV: E=Sophos;i="5.82,209,1613462400"; d="scan'208";a="422753534" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.213.203.45]) ([10.213.203.45]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2021 07:40:21 -0700 To: Jiawen Wu , dev@dpdk.org References: <20210406093048.2923172-1-jiawenwu@trustnetic.com> <20210406093048.2923172-4-jiawenwu@trustnetic.com> From: Ferruh Yigit X-User: ferruhy Message-ID: Date: Fri, 9 Apr 2021 15:40:19 +0100 MIME-Version: 1.0 In-Reply-To: <20210406093048.2923172-4-jiawenwu@trustnetic.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH v4 3/6] net/ngbe: support probe and remove 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" On 4/6/2021 10:30 AM, Jiawen Wu wrote: > Add basic PCIe ethdev probe and remove. > > Signed-off-by: Jiawen Wu <...> > --- a/drivers/net/ngbe/ngbe_ethdev.c > +++ b/drivers/net/ngbe/ngbe_ethdev.c > @@ -1,10 +1,12 @@ > - /* SPDX-License-Identifier: BSD-3-Clause > - * Copyright(c) 2018-2020 > - */ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2018-2020 > + */ Can you please fix this where it is introduced at first place? <...> > +static int > +eth_ngbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, > + struct rte_pci_device *pci_dev) > +{ > + struct rte_eth_dev *pf_ethdev; > + struct rte_eth_devargs eth_da; > + int retval; > + > + if (pci_dev->device.devargs) { > + retval = rte_eth_devargs_parse(pci_dev->device.devargs->args, > + ð_da); > + if (retval) > + return retval; > + } else { > + memset(ð_da, 0, sizeof(eth_da)); > + } > + > + retval = rte_eth_dev_create(&pci_dev->device, pci_dev->device.name, > + sizeof(struct ngbe_adapter), > + eth_dev_pci_specific_init, pci_dev, > + eth_ngbe_dev_init, NULL); > + > + if (retval || eth_da.nb_representor_ports < 1) > + return retval; no need to check the 'nb_representor_ports' here, the driver does not support the port anyway, it can return immediately. Similarly 'rte_eth_devargs_parse()' call above can be removed, for same reason. When port representor support added to driver, following check also may be added since new representator types are added recently. if (eth_da.type != RTE_ETH_REPRESENTOR_VF) return -ENOTSUP; > + > + pf_ethdev = rte_eth_dev_allocated(pci_dev->device.name); > + if (pf_ethdev == NULL) > + return -ENODEV; > + Also above part can be removed completely, pf_ethdev is get to use in the existance of the port representor, no need to get it now. > + return 0; > +} > + > +static int eth_ngbe_pci_remove(struct rte_pci_device *pci_dev) > +{ > + struct rte_eth_dev *ethdev; > + > + ethdev = rte_eth_dev_allocated(pci_dev->device.name); > + if (!ethdev) > + return -ENODEV; This is not an error case, you can return success (0) here. Same applies to txgbe too.