Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1028439ybl; Wed, 11 Dec 2019 11:16:32 -0800 (PST) X-Google-Smtp-Source: APXvYqzwPVTCRtpZ/0YWBciV529bYfigmSMUBeR8hC/DRPurPDfEuMTgY0prgqsajUi17tx8LKQx X-Received: by 2002:a9d:6a5a:: with SMTP id h26mr3628512otn.103.1576091792752; Wed, 11 Dec 2019 11:16:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576091792; cv=none; d=google.com; s=arc-20160816; b=GMDup2S3GMbBMc39X1L6xmeRJhmLEGt/zbGNSQIExpleVd30XbXoFVynQ2zUFu2RHE J5TzI8ZfaYsoOWqiP40vVNfx782YgkQvnxFEYiSqzdTQDeShF6rzavDSnN393lXZqs/V LgpCmFDUZklHGJksoMUwodIbQrcHTwC7wh1LcAtVjHgtQOCFfZ9vuMsk/IfG7uhi9tjJ 83kx1BUIrstkuZ0PdKFUSO+4AAVVzzr2cpJI5blUT/Hvm4hc1K0SRaIgThf66+ITDoAR YyZyQ1jNnVxOPDkMbYPXAF4qMYnTqlXmfcTVrpau3U5qJtakisKBufnWDzEFwoUL9xgr Ey3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=nJ/VWCmz71EpQ9QVZBA9BDeegL7NdVe7RbPuPTBMFb8=; b=Sf6En5DFyrPfVwHM0I2Mpsov67m0gVUTU2dGen3b83vhUqe1Ld/mgYTqeDH+4Ral7T SWB+KIu2M2lbainIe3pWLrkTctVbPCdsy1Zyx/xq4XjlLutk5D1xQhbZRwCdIWuPOVhf fUeE0BGUYxVUrbIMB4/8STLcDRGvj4vri+vz0/+sf7mlNv81+YN6LIBdfMwFLINMfMFx ZVTiqkKDAuLQTbG88zI7DIWazncUjmWweGUqtkLMbV/dJw000+AV645MJC1atvp9DVb8 ibb8w2ZtsgrNgq1b2DCh4sGJ3ZzBMUlY8nVrDT3uQz4HKBsiybg7X8uGZ7VVsNzkdm8L OFaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=KMPbSM+R; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f4si1639061oto.169.2019.12.11.11.16.20; Wed, 11 Dec 2019 11:16:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=KMPbSM+R; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727334AbfLKTPu (ORCPT + 99 others); Wed, 11 Dec 2019 14:15:50 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:33525 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726987AbfLKTPs (ORCPT ); Wed, 11 Dec 2019 14:15:48 -0500 Received: by mail-lj1-f193.google.com with SMTP id 21so25393561ljr.0 for ; Wed, 11 Dec 2019 11:15:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=nJ/VWCmz71EpQ9QVZBA9BDeegL7NdVe7RbPuPTBMFb8=; b=KMPbSM+RTtQCtsZ+EOpry4KaHB4ciwutPzLElQIdeyKoETduWovwHScxT/XWI5rNvN eF7bdWi8ukAekR9UiOtDWXBw+13AjJXss6wLWJLlITQIca6enXWhk8Z9oTuHvmDNRSCZ MsSWmKHNJWGd5UqvLi20oamFGsHjUHwyXlblsKLoF5HalIwl56Hi+mQKOVjD0LNXmhkR LsGXS8DG8BAWJL2QtnArulm2UUhTH5R11Qb2aAJrxtHAxtXhjAJDHSKyMML/DK9fMQKc 2qydHgUs66emUt7dHu1mgTHJSPh0qYK3nRjdUzOT2vpEOahACJXIG8fjtKsLq3WFmJ16 PN+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=nJ/VWCmz71EpQ9QVZBA9BDeegL7NdVe7RbPuPTBMFb8=; b=J/msvLM6T6FsJTMUmoZPCzfx0kc76W8hsUgFKcRL/b/mEcbmQxK7aNNzIZwH4z+XQs EKJqIR9V38Cdwatbp0+8iMVEJKdIBnyO0bInK/vqZTejrCDpXJd1Sb4L3lGFwTGleKNt HM3UHSQATzvEzRFFhNPp0td5/bHffpY+4eA7hT0GCL8wQnRY898QwQR5Cd1qEgiGZoLH u3MbDQaN098vxR2WpnPLqOXonVT63Pc4K3YZ2SoxVJaS+hmDZ1R5oYhjlwwqlBEzEUaH PPzGHPbXENowI57dYOwZioVWZxnSzICIF5xxPZvR+YWGqweyJrupnCWIRTmkrLLxqUx4 2/bA== X-Gm-Message-State: APjAAAVlDW5ex34X9/v5kwRorAkSJIlrGfSfJxFjRy/zBJi8BYuU1SlZ 7SjTtSSZKFgBTF3Z3L5/Yx+oV9BS7Vc= X-Received: by 2002:a2e:8613:: with SMTP id a19mr3268726lji.210.1576091745719; Wed, 11 Dec 2019 11:15:45 -0800 (PST) Received: from cakuba.netronome.com ([66.60.152.14]) by smtp.gmail.com with ESMTPSA id 138sm1689304lfa.76.2019.12.11.11.15.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2019 11:15:45 -0800 (PST) Date: Wed, 11 Dec 2019 11:15:37 -0800 From: Jakub Kicinski To: Yuval Avnery Cc: Jiri Pirko , "davem@davemloft.net" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH net-next] netdevsim: Add max_vfs to bus_dev Message-ID: <20191211111537.416bf078@cakuba.netronome.com> In-Reply-To: References: <1576033133-18845-1-git-send-email-yuvalav@mellanox.com> <20191211095854.6cd860f1@cakuba.netronome.com> Organization: Netronome Systems, Ltd. MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 11 Dec 2019 18:19:56 +0000, Yuval Avnery wrote: > > On Wed, 11 Dec 2019 04:58:53 +0200, Yuval Avnery wrote: > > > Currently there is no limit to the number of VFs netdevsim can enable. > > > In a real systems this value exist and used by driver. > > > Fore example, Some features might need to consider this value when > > > allocating memory. > > > > Thanks for the patch! > > > > Can you shed a little bit more light on where it pops up? Just for my curiosity? > > Yes, like we described in the subdev threads. > User should be able to configure some attributes before the VF was enabled. > So all those (persistent) VF attributes should be available for query and configuration > before VF was enabled. > The driver can allocate an array according to max_vfs to hold all that data, > like we do here in" vfconfigs". I was after more practical reasoning, are you writing some tests for subdev stuff that will depend on this change? :) > > > Signed-off-by: Yuval Avnery > > > Acked-by: Jiri Pirko > > > > > > diff --git a/drivers/net/netdevsim/bus.c b/drivers/net/netdevsim/bus.c > > > index 6aeed0c600f8..f1a0171080cb 100644 > > > --- a/drivers/net/netdevsim/bus.c > > > +++ b/drivers/net/netdevsim/bus.c > > > @@ -26,9 +26,9 @@ static struct nsim_bus_dev *to_nsim_bus_dev(struct > > > device *dev) static int nsim_bus_dev_vfs_enable(struct nsim_bus_dev > > *nsim_bus_dev, > > > unsigned int num_vfs) > > > { > > > - nsim_bus_dev->vfconfigs = kcalloc(num_vfs, > > > - sizeof(struct nsim_vf_config), > > > - GFP_KERNEL); > > > > You're changing the semantics of the enable/disable as well now. > > The old values used to be wiped when SR-IOV is disabled, now they will be > > retained across disable/enable pair. > > > > I think it'd be better if that wasn't the case. Users may expect a system to be > > in the same state after they enable SR-IOV, regardless if someone else used > > SR-IOV since last reboot. > > Right, > But some values should retain across enable/disable, for example MAC address which is persistent. > So maybe we need to retain some values, while resetting others on disable? > Would that work? Mmm. That is a good question. For all practical purposes SR-IOV used to be local to the host that enables it until Smart/middle box NICs emerged. Perhaps the best way forward would be to reset the config that was set via legacy APIs and keep only the MACs provisioned via persistent devlink API? So for now we'd memset, and once devlink API lands reset selectively? > > Could you add a memset(,0,) here? > > > > > + if (nsim_bus_dev->max_vfs < num_vfs) > > > + return -ENOMEM; > > > + > > > if (!nsim_bus_dev->vfconfigs) > > > return -ENOMEM; > > > > This check seems useless now, no? We will always have vfconfigs