Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1836913lqp; Mon, 15 Apr 2024 21:25:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX38h4/p+BOy2dWzPjH+TrVD5t5pNOq+VjhU19rr/2mtFldqOm6LvuEGVTpmlaomMFr5zpoBTjrd4Xo9yJMUd50tAAxeiMxss//Mec2Pw== X-Google-Smtp-Source: AGHT+IGJNBJivoqtFXVXRsOa55F8YkYCQtd+XDs9M2VxHUJpYvqDu4m/JAjBFveQWDmFJuyPzL/M X-Received: by 2002:adf:ed41:0:b0:343:78d9:ebad with SMTP id u1-20020adfed41000000b0034378d9ebadmr9165665wro.27.1713241539968; Mon, 15 Apr 2024 21:25:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713241539; cv=pass; d=google.com; s=arc-20160816; b=MrllXF49TyKP6WZr1nOVSdRiQZpznZTmsKwHzBUQ5YuKWn11PYH3g4BdRWDXVGy97j +GAMH+gjVB92g2/Y8qnJi52oWtb1jUfF2bJuImj/DPm71RfEwD3D0sAup6FHlZJzph5F M92RJ+/N5pVNccgaMohkWBQN2j2fe9KehZVFbPqQQ0LpR0NvHSWATDAgg5LzrInr+R63 FNI7I2X85sMqFE0u96Egftvmeh+cGwrcU0Z6dVYnvxDphB7ojJCjJV2t3rqkwOlmi9rG Eh3Pfe55Wo/5VmEAghuSbKA2l5N48jIaRIhMglEiCdRRr0m0lnwDP4yYjQcsjvhAQ3Br k2GQ== 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=ogpyOHNHkyZwnpq6dIwauvYSTq02i3af+QgdMRMGFrI=; fh=QzkXNsXxwztCd4rW8xHffVb5/+uqFYSfrMCrSp/aJAc=; b=Q2BXfBPr62xgrYmmIVgG0VvZNY2JtDrNnH/JY2/tMA337Lnegsj5ahwQQ0B9nYW5Ff odDwoKQDL7B+iYfNvzQvHJ8zvw7XhE11vn9zo9svo87y+724iFu4hInx1S+gqsaYNh9g wcQu+nDZH9B/qlLwLDeS+wasoH9pjFWMkONy8LcSG+mCF1nLlH6iCe/vytEkjJjaqtCg LfYkb7SaqhxhezQXoHBihrckvBuC9J0VDzUnhl37XVwQZ1iBSGA28xZwluioRSXDJO9l kzgPK99d22wJ4N7FLe/vbH50vvs20r4LFqQgtuwqLOIa6/DMdCnGGtF0kr+r8e0IeSV0 d71Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=CeQrwFtP; 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-146222-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146222-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 am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id fx25-20020a170906b75900b00a51f236f748si5203255ejb.1042.2024.04.15.21.25.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 21:25:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146222-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=CeQrwFtP; 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-146222-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146222-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 am.mirrors.kernel.org (Postfix) with ESMTPS id A894A1F23FB2 for ; Tue, 16 Apr 2024 04:25:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 769A32E40E; Tue, 16 Apr 2024 04:25:28 +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="CeQrwFtP" Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5F85420B0E; Tue, 16 Apr 2024 04:25:26 +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=1713241527; cv=none; b=qNZg5bWQHbfY17J46v+xsm9JNG/zGGu0mIOMASVC6YtG3jCMntyS8JRC8y4U17ks3R1YtePYBflRbDIomn503i+ZMqo7CiPGBtp/y7E69e5aLmZQ/GgdGZ5L2gZzNvwGfcE+tet6Gr3gvo2kLEes6LkP8XbIwZEh9O7wPx2HaJw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713241527; c=relaxed/simple; bh=dLKuEx3zS6xD3HOWu8wyg2W7hIiC28htgpdfpLYs9IY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tHYkNltP1gtrld+krOe3SFaaImyUEGz0/toID4j7aQYZuo4pWUf0awjXA0lnhIvD2swmRTx8MX9650DlrKHXp5DSRV5LQQhNkXY3Cniyufsed0SCRZt572XHhfDNWtHRZvFJuU6mue0XtXaVUKr3mK3n8uTzZNlVczcA6G0G/O0= 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=CeQrwFtP; 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 EEDDF20FD43F; Mon, 15 Apr 2024 21:25:25 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com EEDDF20FD43F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1713241525; bh=ogpyOHNHkyZwnpq6dIwauvYSTq02i3af+QgdMRMGFrI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CeQrwFtPIrMI1svwcbTGL4cUAUqpYv6uEHp4pP1EqCIynzeYP8zAmTG/WSVDJNYcb Xb+xMLdqR5YXhG8tIHZPO1CWnPIjJcztbqZmM9lJfukqwDfjbSEpl6GUEMt8U1+eUQ SYbflB8VYkyYF8PXVSwTr2TEDlYR5o7uMljDc4d4= Date: Mon, 15 Apr 2024 21:25:25 -0700 From: Shradha Gupta To: Jason Gunthorpe Cc: 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: <20240416042525.GA23796@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1713174589-29243-1-git-send-email-shradhagupta@linux.microsoft.com> <20240415161305.GO223006@ziepe.ca> 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: <20240415161305.GO223006@ziepe.ca> User-Agent: Mutt/1.5.21 (2010-09-15) On Mon, Apr 15, 2024 at 01:13:05PM -0300, Jason Gunthorpe wrote: > 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 > > Jason Thanks Jason, I will make the appropriate changes in the next version. Regards, Shradha.