Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B35FC61DA4 for ; Wed, 15 Mar 2023 05:12:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231132AbjCOFM3 (ORCPT ); Wed, 15 Mar 2023 01:12:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229732AbjCOFM0 (ORCPT ); Wed, 15 Mar 2023 01:12:26 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A322F5D277 for ; Tue, 14 Mar 2023 22:11:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678857098; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jTWqQfH2jSclsQKQPaFec1o38miRjxcnCEr069EGPqA=; b=gqqczEI7+zn92ScN9OjLUpf6kLwQz9BgvYWq+7/2xvtTAxXe1qQxsCG549fPUnoXRLh9IT NfC4UBoIRr8tJgqn6qh4E5//quEu4KfxmqmnD+6PUHxZzmNuhe7V+Vyy7ZakLfjEsSZ5K5 3aJdDtOzsx0kg/Y6L/LHWWeSyHwCQJM= Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-294-o_q_anBkPkGUVZLLVVn9iQ-1; Wed, 15 Mar 2023 01:11:37 -0400 X-MC-Unique: o_q_anBkPkGUVZLLVVn9iQ-1 Received: by mail-pj1-f72.google.com with SMTP id q24-20020a17090a2e1800b00237c37964d4so398749pjd.8 for ; Tue, 14 Mar 2023 22:11:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678857096; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jTWqQfH2jSclsQKQPaFec1o38miRjxcnCEr069EGPqA=; b=EFuSWbapzjzGMXyTRDDdNkssHnDZJXE4sxtr+I0EzEltCrfpboLT6HWh7se+1xPSv+ ew+PzAmbvJ4cvbMIDgX5VanWUn4BehWVJSOhyDoIbNrkXgmq9kxC+uK85+VkzC9mHVu/ 5aR4MCDOEeBYUDwTzzZiediCmPhA2ak+ix7qe/7smX3zdHrvbcpaBX6e8UodnmkvM8xI 7Li9NETQ0OrP7dEIHzcTKEvASFvU0S51lG5ucscfppc4QHviyfOc4QPY18gAhOqzxfov VWAhO53mZMBMlX3CxXtHaLd3vl2CDDePIDswsh3+sQrNwWuA52/iRtUr+xSDv5mfELXy MvTA== X-Gm-Message-State: AO0yUKU0qm/fTVCT+rSiNo5WnbWSyz+a0BfU2vzTPddRKafJnde+0e5e kgNOtNUNn62QswHyoAxkMBFdcc6Xm2r2jIc2LCS2kDD1Hc7b7iwKzGwOCPRcGJOtEb503fDGcK0 +6bdJbojVeyixXjWUO+mKfiGh X-Received: by 2002:a17:903:1389:b0:19a:e96a:58b3 with SMTP id jx9-20020a170903138900b0019ae96a58b3mr1289218plb.22.1678857096177; Tue, 14 Mar 2023 22:11:36 -0700 (PDT) X-Google-Smtp-Source: AK7set9vzLgqqDLumGkAJ6rLHtB3EUu7fIcjX4yeWCXfnK660iCK8xgSOLHGp33SXUSs5VD1la/41Q== X-Received: by 2002:a17:903:1389:b0:19a:e96a:58b3 with SMTP id jx9-20020a170903138900b0019ae96a58b3mr1289203plb.22.1678857095826; Tue, 14 Mar 2023 22:11:35 -0700 (PDT) Received: from [10.72.12.84] ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id g3-20020a170902740300b0019a8530c063sm2580750pll.102.2023.03.14.22.11.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Mar 2023 22:11:35 -0700 (PDT) Message-ID: <071329fe-7215-235c-06b7-f17bf69d872b@redhat.com> Date: Wed, 15 Mar 2023 13:11:23 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH net-next v2 01/14] sfc: add function personality support for EF100 devices Content-Language: en-US To: Gautam Dawar , linux-net-drivers@amd.com, Edward Cree , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, eperezma@redhat.com, harpreet.anand@amd.com, tanuj.kamde@amd.com, koushik.dutta@amd.com References: <20230307113621.64153-1-gautam.dawar@amd.com> <20230307113621.64153-2-gautam.dawar@amd.com> From: Jason Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2023/3/13 19:50, Martin Habets 写道: > On Fri, Mar 10, 2023 at 01:04:14PM +0800, Jason Wang wrote: >> On Tue, Mar 7, 2023 at 7:36 PM Gautam Dawar wrote: >>> A function personality defines the location and semantics of >>> registers in the BAR. EF100 NICs allow different personalities >>> of a PCIe function and changing it at run-time. A total of three >>> function personalities are defined as of now: EF100, vDPA and >>> None with EF100 being the default. >>> For now, vDPA net devices can be created on a EF100 virtual >>> function and the VF personality will be changed to vDPA in the >>> process. >>> >>> Co-developed-by: Martin Habets >>> Signed-off-by: Martin Habets >>> Signed-off-by: Gautam Dawar >>> --- >>> drivers/net/ethernet/sfc/ef100.c | 6 +- >>> drivers/net/ethernet/sfc/ef100_nic.c | 98 +++++++++++++++++++++++++++- >>> drivers/net/ethernet/sfc/ef100_nic.h | 11 ++++ >>> 3 files changed, 111 insertions(+), 4 deletions(-) >>> >>> diff --git a/drivers/net/ethernet/sfc/ef100.c b/drivers/net/ethernet/sfc/ef100.c >>> index 71aab3d0480f..c1c69783db7b 100644 >>> --- a/drivers/net/ethernet/sfc/ef100.c >>> +++ b/drivers/net/ethernet/sfc/ef100.c >>> @@ -429,8 +429,7 @@ static void ef100_pci_remove(struct pci_dev *pci_dev) >>> if (!efx) >>> return; >>> >>> - probe_data = container_of(efx, struct efx_probe_data, efx); >>> - ef100_remove_netdev(probe_data); >>> + efx_ef100_set_bar_config(efx, EF100_BAR_CONFIG_NONE); >>> #ifdef CONFIG_SFC_SRIOV >>> efx_fini_struct_tc(efx); >>> #endif >>> @@ -443,6 +442,7 @@ static void ef100_pci_remove(struct pci_dev *pci_dev) >>> pci_disable_pcie_error_reporting(pci_dev); >>> >>> pci_set_drvdata(pci_dev, NULL); >>> + probe_data = container_of(efx, struct efx_probe_data, efx); >>> efx_fini_struct(efx); >>> kfree(probe_data); >>> }; >>> @@ -508,7 +508,7 @@ static int ef100_pci_probe(struct pci_dev *pci_dev, >>> goto fail; >>> >>> efx->state = STATE_PROBED; >>> - rc = ef100_probe_netdev(probe_data); >>> + rc = efx_ef100_set_bar_config(efx, EF100_BAR_CONFIG_EF100); >>> if (rc) >>> goto fail; >>> >>> diff --git a/drivers/net/ethernet/sfc/ef100_nic.c b/drivers/net/ethernet/sfc/ef100_nic.c >>> index 4dc643b0d2db..8cbe5e0f4bdf 100644 >>> --- a/drivers/net/ethernet/sfc/ef100_nic.c >>> +++ b/drivers/net/ethernet/sfc/ef100_nic.c >>> @@ -772,6 +772,99 @@ static int efx_ef100_get_base_mport(struct efx_nic *efx) >>> return 0; >>> } >>> >>> +/* BAR configuration. >>> + * To change BAR configuration, tear down the current configuration (which >>> + * leaves the hardware in the PROBED state), and then initialise the new >>> + * BAR state. >>> + */ >>> +struct ef100_bar_config_ops { >>> + int (*init)(struct efx_probe_data *probe_data); >>> + void (*fini)(struct efx_probe_data *probe_data); >>> +}; >>> + >>> +static const struct ef100_bar_config_ops bar_config_ops[] = { >>> + [EF100_BAR_CONFIG_EF100] = { >>> + .init = ef100_probe_netdev, >>> + .fini = ef100_remove_netdev >>> + }, >>> +#ifdef CONFIG_SFC_VDPA >>> + [EF100_BAR_CONFIG_VDPA] = { >>> + .init = NULL, >>> + .fini = NULL >>> + }, >>> +#endif >>> + [EF100_BAR_CONFIG_NONE] = { >>> + .init = NULL, >>> + .fini = NULL >>> + }, >>> +}; >> This looks more like a mini bus implementation. I wonder if we can >> reuse an auxiliary bus here which is more user friendly for management >> tools. > When we were in the design phase of vDPA for EF100 it was still called > virtbus, and the virtbus discussion was in full swing at that time. > We could not afford to add risk to the project by depending on it, as > it might not have been merged at all. Right. > If we were doing the same design now I would definitely consider using > the auxiliary bus. > > Martin But it's not late to do the change now. Auxiliary bus has been used by a lot of devices (even with vDPA device). The change looks not too complicated. This looks more scalable and convenient for management layer. Thanks