Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp1095463lqb; Wed, 17 Apr 2024 23:01:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVjXSZSqgHjL0WxkMhHPydDgxzKgxDIknR/ydZekts0d6Rwev5f1NgoGe/fuI6XU4V8EnhzeHhatBMJJTjCaFZLrTNCm8UBwavFXz3ynQ== X-Google-Smtp-Source: AGHT+IETxglrWeQcjhHAqImO9QSALqKsvw2uCxrKBczS6ZTXbi1bAYV8rO4x3OeL3g2Bfvs7unmM X-Received: by 2002:a17:902:ba87:b0:1e8:674b:d10f with SMTP id k7-20020a170902ba8700b001e8674bd10fmr1805482pls.41.1713420081887; Wed, 17 Apr 2024 23:01:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713420081; cv=pass; d=google.com; s=arc-20160816; b=d8SIh8+of7KQH2SlH+MRPiw3MhrpcItvYuLG11mv/ILEKOfT44Ytup+6w+qnTublRI PWGWTh7ljrkyzycoJbrMPIMgLvQi17qSBHMjE+LwcQSBujIqUE8PFQKXFCjUa/dfw2/m n5WmHQW6FhqYm+jb2r9ilRK0aKF3dpsDCIzQonf+3L/6h0OFrKp0tJgSBMjPlvnDirOT CmstsHWXW4h2AUHig7yIIU33/BKhMMHRa2267xRTRxEZIVRfefz+AfSi2ZTkYLgxMpM9 avwxntZVOAjAzrAKxmDa/FQ8NZ32ci2jU2/x/nfmlKK5/iWyxbeLoLITDMjEvp91zVjU 9rkA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature:dkim-filter; bh=YKgl5iX1KfOMktLT9SvYfyg3kkZRGtrAtWjdU53tHMU=; fh=M+bGFYbA+Med+qVbXZ5LQZQQLWhQZjH8JuWWOTwZbPQ=; b=wbdjPy3fyiJkx3WWzcEL0AHJVb55ND4Wb8CF9IoSUYYP3Qmt0RxaszHduPygPykghz sjks65vchaYWyMvICfNo+vNR6266VEGatR3+T7n0KFAL84LEOfzvN7yWfnhhLgJfEmch itBwyANI2fZhyqfAEDmpeyORJKFS+s5la0YJXznOEv+QZbcLvuzu9qBJ4nT7MJ1HBy2d IuMYKTe6eRXK9W9X5k77ROoxBETOuo79SEHO1LCDuky1nEoYk4vMXLGwake1fmV+umiz 61ernFeb6LzJnXxt4JqQJ599eIyV/snEpMR2kNxVQwAqO1v+Iurwq4wDcfWx/JbHIz9u O+WQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=J+FfVYQX; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-149548-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-149548-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id l9-20020a170903244900b001e49ad76d62si820054pls.108.2024.04.17.23.01.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 23:01:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-149548-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=J+FfVYQX; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-149548-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-149548-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7AFCF282B08 for ; Thu, 18 Apr 2024 06:01:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1BF886A340; Thu, 18 Apr 2024 06:01:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="J+FfVYQX" Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F1CB08C11; Thu, 18 Apr 2024 06:01:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713420071; cv=none; b=Vln4CsLuECryTTXj+lCMb+6uKZx6RCE2BuU5mcFB7KtJHb9bcXPiBAvqPTIAZkuGSFnObZrY2HUAMD0ghI2FPbWp8cC5KtV1+11hYaJpiQqXgTTQWvABsAggOp2yw6oRL5KC9KBeww+EyQiXfYA34hhK4dYr+FHJkH7hlj+tj2Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713420071; c=relaxed/simple; bh=wnxrM0SyZ5InG/utr8nH+FRU5SD2JuTpuZTi5wktvRI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jMKL4NpWXqY8UW0oPdxYlT2d8xAxELShh+BhOos8O/aKUOJbU53wc7sLR4WGZa4BXC1ooXspnrS2wRJaDGMugXQt5i5IxYVZzRLMSLQYrQ782VkFC3P7aslnaohZ+Phgrjhovp8TlM+mcRGtciReJkUHmsIrATm8oRp2yqYQXEs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=J+FfVYQX; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Received: by linux.microsoft.com (Postfix, from userid 1134) id B365320FD4DC; Wed, 17 Apr 2024 23:01:08 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com B365320FD4DC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1713420068; bh=YKgl5iX1KfOMktLT9SvYfyg3kkZRGtrAtWjdU53tHMU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=J+FfVYQXqbM55TRugVunoZ8T8LxT+WPKcNjCZOoBaciWIWzP8nYHIjxevlR1GBCYz lVspw0/oQFz7knVEGFm0ZB5Vbyig47AuQVuKemfJXJpyFtqRbIXO+01XPz/LleBmrB pBicAD3JrmjO1130q7R3YCJozlKKNIbbeZSaRevU= Date: Wed, 17 Apr 2024 23:01:08 -0700 From: Shradha Gupta To: Andrew Lunn Cc: Zhu Yanjun , Jason Gunthorpe , linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Ajay Sharma , Leon Romanovsky , Thomas Gleixner , Sebastian Andrzej Siewior , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Long Li , Michael Kelley , Shradha Gupta , Yury Norov , Konstantin Taranov , Souradeep Chakrabarti Subject: Re: [PATCH net-next] net: mana: Add new device attributes for mana Message-ID: <20240418060108.GB13182@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1713174589-29243-1-git-send-email-shradhagupta@linux.microsoft.com> <20240415161305.GO223006@ziepe.ca> <56b0a8c1-50f6-41a9-9ea5-ed45ada58892@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) On Tue, Apr 16, 2024 at 08:09:35PM +0200, Andrew Lunn wrote: > On Tue, Apr 16, 2024 at 06:27:04AM +0200, Zhu Yanjun wrote: > > ??? 2024/4/15 18:13, Jason Gunthorpe ??????: > > > On Mon, Apr 15, 2024 at 02:49:49AM -0700, Shradha Gupta wrote: > > > > Add new device attributes to view multiport, msix, and adapter MTU > > > > setting for MANA device. > > > > > > > > Signed-off-by: Shradha Gupta > > > > --- > > > > .../net/ethernet/microsoft/mana/gdma_main.c | 74 +++++++++++++++++++ > > > > include/net/mana/gdma.h | 9 +++ > > > > 2 files changed, 83 insertions(+) > > > > > > > > diff --git a/drivers/net/ethernet/microsoft/mana/gdma_main.c b/drivers/net/ethernet/microsoft/mana/gdma_main.c > > > > index 1332db9a08eb..6674a02cff06 100644 > > > > --- a/drivers/net/ethernet/microsoft/mana/gdma_main.c > > > > +++ b/drivers/net/ethernet/microsoft/mana/gdma_main.c > > > > @@ -1471,6 +1471,65 @@ static bool mana_is_pf(unsigned short dev_id) > > > > return dev_id == MANA_PF_DEVICE_ID; > > > > } > > > > +static ssize_t mana_attr_show(struct device *dev, > > > > + struct device_attribute *attr, char *buf) > > > > +{ > > > > + struct pci_dev *pdev = to_pci_dev(dev); > > > > + struct gdma_context *gc = pci_get_drvdata(pdev); > > > > + struct mana_context *ac = gc->mana.driver_data; > > > > + > > > > + if (strcmp(attr->attr.name, "mport") == 0) > > > > + return snprintf(buf, PAGE_SIZE, "%d\n", ac->num_ports); > > > > + else if (strcmp(attr->attr.name, "adapter_mtu") == 0) > > > > + return snprintf(buf, PAGE_SIZE, "%d\n", gc->adapter_mtu); > > > > + else if (strcmp(attr->attr.name, "msix") == 0) > > > > + return snprintf(buf, PAGE_SIZE, "%d\n", gc->max_num_msix); > > > > + else > > > > + return -EINVAL; > > > > + > > > > > > That is not how sysfs should be implemented at all, please find a > > > good example to copy from. Every attribute should use its own function > > > with the macros to link it into an attributes group and sysfs_emit > > > should be used for printing > > > > Not sure if this file drivers/infiniband/hw/usnic/usnic_ib_sysfs.c is a good > > example or not. > > The first question should be, what are these values used for? You can > then decide on debugfs or sysfs. debugfs is easier to use, and you > avoid any ABI, which will make long term support easier. Hi Andrew, We want to eventually use these attributes to make the device settings configurable and also improve debuggability for MANA devices. I feel having these attributes in sysfs would make more sense as we plan to extend the attribute list and also make them settable. Regards, Shradha. > > Andrew