linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zhu Yanjun <yanjun.zhu@linux.dev>
To: Jason Gunthorpe <jgg@ziepe.ca>,
	Shradha Gupta <shradhagupta@linux.microsoft.com>
Cc: linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org,
	linux-rdma@vger.kernel.org, netdev@vger.kernel.org,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Ajay Sharma <sharmaajay@microsoft.com>,
	Leon Romanovsky <leon@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	"K. Y. Srinivasan" <kys@microsoft.com>,
	Haiyang Zhang <haiyangz@microsoft.com>,
	Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>,
	Long Li <longli@microsoft.com>,
	Michael Kelley <mikelley@microsoft.com>,
	Shradha Gupta <shradhagupta@microsoft.com>,
	Yury Norov <yury.norov@gmail.com>,
	Konstantin Taranov <kotaranov@microsoft.com>,
	Souradeep Chakrabarti <schakrabarti@linux.microsoft.com>
Subject: Re: [PATCH net-next] net: mana: Add new device attributes for mana
Date: Tue, 16 Apr 2024 06:27:04 +0200	[thread overview]
Message-ID: <56b0a8c1-50f6-41a9-9ea5-ed45ada58892@linux.dev> (raw)
In-Reply-To: <20240415161305.GO223006@ziepe.ca>

在 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 <shradhagupta@linux.microsoft.com>
>> ---
>>   .../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.

Zhu Yanjun

> 
> Jason


  parent reply	other threads:[~2024-04-16  4:27 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-15  9:49 [PATCH net-next] net: mana: Add new device attributes for mana Shradha Gupta
2024-04-15 16:13 ` Jason Gunthorpe
2024-04-16  4:25   ` Shradha Gupta
2024-04-16  4:27   ` Zhu Yanjun [this message]
2024-04-16 18:09     ` Andrew Lunn
2024-04-18  6:01       ` Shradha Gupta
2024-04-18 17:50         ` Jason Gunthorpe
2024-04-18 18:42           ` Andrew Lunn
2024-04-19 16:59             ` Shradha Gupta
2024-04-19 18:51               ` Andrew Lunn
2024-04-22 10:08                 ` Shradha Gupta
2024-04-18  5:51     ` Shradha Gupta
2024-04-15 16:38 ` Saurabh Singh Sengar
2024-04-16  4:26   ` Shradha Gupta
2024-04-18 21:29 ` Haiyang Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56b0a8c1-50f6-41a9-9ea5-ed45ada58892@linux.dev \
    --to=yanjun.zhu@linux.dev \
    --cc=bigeasy@linutronix.de \
    --cc=decui@microsoft.com \
    --cc=edumazet@google.com \
    --cc=haiyangz@microsoft.com \
    --cc=jgg@ziepe.ca \
    --cc=kotaranov@microsoft.com \
    --cc=kuba@kernel.org \
    --cc=kys@microsoft.com \
    --cc=leon@kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=longli@microsoft.com \
    --cc=mikelley@microsoft.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=schakrabarti@linux.microsoft.com \
    --cc=sharmaajay@microsoft.com \
    --cc=shradhagupta@linux.microsoft.com \
    --cc=shradhagupta@microsoft.com \
    --cc=tglx@linutronix.de \
    --cc=wei.liu@kernel.org \
    --cc=yury.norov@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).