Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp1092073lqb; Wed, 17 Apr 2024 22:51:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV3pTu5GjEn8td/nrwTLlTwapAzK0/TKc7CVRpWyy3wYab/xWhbI/RKV8E+LmJemFFdW17GtN7R8g7l8k8++8Fq4/PtFFnx+nBXmy6BdA== X-Google-Smtp-Source: AGHT+IFtKrN2EMVgdWS1DqFpFWGJxEDvU87Hf7S+mR1Te+Q7BS21q3SwebqInshi+QxE+Ej+2MUx X-Received: by 2002:a50:d5c1:0:b0:56e:22dd:f24c with SMTP id g1-20020a50d5c1000000b0056e22ddf24cmr984699edj.21.1713419510123; Wed, 17 Apr 2024 22:51:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713419510; cv=pass; d=google.com; s=arc-20160816; b=IlAar1HYAeHIiOkEaS5Mt8hcOz+7XnDmztn9pNhQxF57ZpqK/O2tYtFIu08VVpIbbU QU+fdsBRlWn4UeooHaBeGNO660n/MuQqKyQLYeMNeROFSWX7nBK+y5cYsX7Np3N6OtRD 1gL6IO37JQgSEOSksAYmb94mgrIK817Q9fCPG1YKeMwF9OZtiSfy0H5uuOFYKfRasrbN cJ2twMDBP86RSzzgg0slLFCDNKD+vz8YfrPuvkdkdSfFUG3AF3Qi+7igkld9+OLFpWWB IUrBianJuBU4nWPrIgGIMswlcalrjzhy2PK13w0q205oU5D9jB/UT8oisKrUZRimifyJ PJUg== 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=mgD2zVbGomE9WC9wXHSFiZJILTvHN5Kfd0Rp4oWQDF8=; fh=qkGlvv8zfKrlkuXE/s3ehZEvZayzU2GMgPL5Kr2e378=; b=wgAT5lSwaqnF3vsZvDTjh2hAW2fKb5Ajs8UisSaH/v5oAXLig0PBvGu30yBd8NBvSF ws2soXwnJGpQGguwTMvcRT/67isqU9GtmoYRBk8eNA38c3vKUYLt0kWYedN4IqACjDR/ Wy7tJT6FuFniKb2uQKTfJH1m4ZelKerfDNTDMIVHyAQGg23OYpWnWp4kJH+BzhvW5jY/ rrgtb2V4EijWy9DmAgzeU7nm67w+N0kiSf42+yuAK7oJPXAgaLsUfj9cI5/b7ySaHHEU /2YdMTjwpRfp7VoJg9Dhjnoew8Xg7Xnd/oF52RY5U9x/EGouxPPosasr6oJzL9c6raGI /05w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=DHyc6I5x; 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-149541-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-149541-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. [147.75.80.249]) by mx.google.com with ESMTPS id u18-20020a509512000000b0056e64f21501si445969eda.530.2024.04.17.22.51.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 22:51:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-149541-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=DHyc6I5x; 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-149541-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-149541-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 D5E421F21838 for ; Thu, 18 Apr 2024 05:51:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 990D05FBAF; Thu, 18 Apr 2024 05:51:38 +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="DHyc6I5x" Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 70D5156454; Thu, 18 Apr 2024 05:51:36 +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=1713419497; cv=none; b=E+zihHhgjz/jS1+47ZP5DcROPdSJx4tqTWyeLj65Hahryb9o6NMiVHVfon2R115ISQsOp8xcjM0XaAeZv8pZZJQUmowajhuIT0w4+oWqZuEs5YW8cK9NX1UVIZwHPdhm80+GTKu/EX5QOXQOOVFvdFFR32nPD1/ue281homDEmk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713419497; c=relaxed/simple; bh=zATJ74G5Sc1DMdnW7cJJ13791upLRtnZmKExsPlmzfk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rRMnaHivZK6d+GfBz8gMjFTOZgLYtMjocXcBozSIhkrbcvBpuRFDSxzP5gF0vL4UJC21MzaYF4/rgrywXBw3W6uHG7Ci//GXuJ597Rp7gYpgwGHa5c190JascXtZIatCnGF1k5Tp7b/hZ/6y7fOvRN0TPcaQB/7nIHmY4qobszw= 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=DHyc6I5x; 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 C97D220FD4D8; Wed, 17 Apr 2024 22:51:35 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com C97D220FD4D8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1713419495; bh=mgD2zVbGomE9WC9wXHSFiZJILTvHN5Kfd0Rp4oWQDF8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=DHyc6I5x+CWragIiq+raj0E0lD/tx6O6G4CHM9jHYNKswHCJG6E2TDzVzJdQhV+wt CPF7CUYy+TeAHFj7pRwqLQnRSkOPrIBKu/8M5uJ/5I/2escB1/GPYwZOs+0AlyjOQT GhUGkTJKYDUnoDIpcKRcy42FYTi0Z810i20H17vs= Date: Wed, 17 Apr 2024 22:51:35 -0700 From: Shradha Gupta To: Zhu Yanjun Cc: 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: <20240418055135.GA13182@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: <56b0a8c1-50f6-41a9-9ea5-ed45ada58892@linux.dev> User-Agent: Mutt/1.5.21 (2010-09-15) 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. > > Zhu Yanjun Thanks for the reference, Zhu. > > > > >Jason