Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1837319lqp; Mon, 15 Apr 2024 21:27:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXzrz18v99UDduuVoCZOrrp4pOgRpbNUA3GMhFAQ8SmwR3NL595olMeMG/qWnMMSKEKMJwYjnqlF7Ut9/TXgbg6CBVCAYDpREr81/q7EA== X-Google-Smtp-Source: AGHT+IFheyeqiD9ar+CbyjVXXsfZ35KTTbUA4ngN5wUHA9ZmVQ/yAqhHKl2S1lF0ARXypxA4Ww2T X-Received: by 2002:ac8:5f13:0:b0:436:57d6:d1db with SMTP id x19-20020ac85f13000000b0043657d6d1dbmr2639755qta.9.1713241640516; Mon, 15 Apr 2024 21:27:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713241640; cv=pass; d=google.com; s=arc-20160816; b=Zc661faDnni1PFSDMItLofxW2cAIAlKPBwdh2OIpvV/4ioATIJouq53XRsfLJAeva0 mEbxR6ZYdnEpMr2fu173VJWBY0c9vlWXNi1GjhuW+sGfxwoM7Ee7nWyikMc5Pz19M4k7 j5SNxLB9t3SJnKIr9v5TIjKB6uPysn1N5wHWEZvDfMTd7xQdG5DqUrWcpgqt2x7vdpTF h1QycR/w1R8Xb86iwd2OYBWODZ8KCNOHwgNZbrahcqZQ6NsZG/evbvOkMitPnknQ7jR7 zmcMI7PaKZH1SiKg8ilrEh2kMIM+ZkeoM1sDSZurZPy1AwtYZ9a6DDVo41Ca9hOiWZ+5 kbsQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :date:dkim-signature:message-id; bh=xtudUHObd5FAkvIMzOg0MTxFzzCYwBlwkkCYwlAcIHs=; fh=CG5TxkP3nJ11H/uPEKaky0avELaM2xMP8gywkeO0+o8=; b=hcMaieQVJ9/hNmmXjaXwB2u0y+1J+dRj1NUHa5aa9weB2IyC1GCnc+WrP8KlcABJdc a+3O0NN6aOVRgPTJURmQlWopaMJx/hcnCZs974fr/0zLEcocFtaVLpGyyuGrq1VLcsRh yU3T2h8lFVGtKeRVbVr23IJapRF0Pmc9Es01LGtKGAIGLPPj3Vp/uHRQGnsxR2TmMpEs T+Pmjfj0XuKQHw3EFJx5m0DL7zsFQZu2/3h0OZjo2dGpit+Oo9emO7WAZpwcOHi9g9FU zbugB5EYeTq4/UL3Oqvq0Z2x822YVhr5LRWtXPjgq0Z4az4J4mmsCkp7tTjKmqHUrCw5 VE+Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=D2i5KAqD; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-146224-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146224-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id k18-20020ac85fd2000000b00436ae10b569si7760800qta.161.2024.04.15.21.27.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 21:27:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146224-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=D2i5KAqD; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-146224-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146224-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 2C2661C20ECB for ; Tue, 16 Apr 2024 04:27:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3422C2E40E; Tue, 16 Apr 2024 04:27:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="D2i5KAqD" Received: from out-186.mta0.migadu.com (out-186.mta0.migadu.com [91.218.175.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F20521101 for ; Tue, 16 Apr 2024 04:27:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.186 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713241632; cv=none; b=qcD+sArVwBs6Xbfdw7w8HMIASzI43dTnYAMXXwYKijTKP0G9I8U3Wh82rYmQpJcQyNR3jWIaQ74aWp0VraWhXEoDPEegd/OvTdvcmdm6oNdufGC9sV6F5Trp/jD0++1welmpX9+ik+PhcxvoLPFuTNnQSp0jsZOJVKKfLR9T/Bc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713241632; c=relaxed/simple; bh=0xecUiT5IqPzvTJOIQC5hqXruSFac8zxlq/vQvqSXgs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=VcQT2dF18RzlfK7hXBNA00gwMqRBh1rGSI9L3M/OFETRphBd61t4MYPzYPhhJ0nuwE/NQlOu8JigiICO6F6qW5jXwC2JrM/HZ9x64p1CgyN7ZuiE+NN0VmBM6PPVpU+JS/aq32QT46aBAhvuNoALLgp5YhDpDm81+iXYP18uuYU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=D2i5KAqD; arc=none smtp.client-ip=91.218.175.186 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Message-ID: <56b0a8c1-50f6-41a9-9ea5-ed45ada58892@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1713241628; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xtudUHObd5FAkvIMzOg0MTxFzzCYwBlwkkCYwlAcIHs=; b=D2i5KAqDKs8klSfndz0c2S1gYNEJbLXTY+VzV7COIzkHA1uL+rCg9e9Q4G3y+kNAbDbXRT eVd6uS6SXRNA5bvuftrLsOmHwavWXM4GUcFIeKETdUPT2R6W6ADCqvbOni2GhHgBli2KBJ ka/Pxqb6H0cImaD/fyvxs+Dsej9rAP4= Date: Tue, 16 Apr 2024 06:27:04 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH net-next] net: mana: Add new device attributes for mana To: Jason Gunthorpe , Shradha Gupta 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 References: <1713174589-29243-1-git-send-email-shradhagupta@linux.microsoft.com> <20240415161305.GO223006@ziepe.ca> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Zhu Yanjun In-Reply-To: <20240415161305.GO223006@ziepe.ca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT 在 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. Zhu Yanjun > > Jason