Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1555906lqp; Mon, 15 Apr 2024 09:40:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWlHyaawdXIabZBgNc+paHP01l61UwIGLcn59oVm2SFlcqOZLoex/zdOZ87bweEL7x+fzbnCpnwK9CHZje3vxUZQgoMHK7MuJQU4NWlmQ== X-Google-Smtp-Source: AGHT+IEOHx9TV1rR5p7ku5ZrDGHqJMEuE4bVTGKVm8f4TVan2MG9YcVnfz/Ogen5EzabdKXBs0E4 X-Received: by 2002:aca:d15:0:b0:3c7:51f:156c with SMTP id 21-20020aca0d15000000b003c7051f156cmr6602371oin.29.1713199211640; Mon, 15 Apr 2024 09:40:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713199211; cv=pass; d=google.com; s=arc-20160816; b=axYTRIvyCICo3/MeYRnZy0BpPQoHRdVHEupHxpVa5WKuGwBF3JYki8lJuvcm+55dka 6KGiHAwxN7s+WdSdta9Xq97g3a/jchMlUUSuPoEcl1fkkSe8vJgK/fA1hX9A1GQXUDlo yRi4uIC0+iSa9g7QOqmJi8gOZYJfX7x32BQPY0e8sive4RhLDxanCrqPWDyIIPE8bfJB atmLVTeVT0jByTpXt2rRvEvFSQylpPim6M81oCSAlzbIcMcMU5oiLVmPYDuOooAtzAEC LuYuv3a/ogfJPf6oJab4cUbgP1CLZBj2zezTPZMaBO0SJUIGvDWlLEI4UYhzI0MRZfgW BDLw== 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=LhdsE6efodYH8GQvxcpPZhNnPBH3tY5kGI4QxFJUD7A=; fh=99PPjs8AifWl2MCDZPakkUB9+wHZWlzC+/LmGIHlSjk=; b=1Gen8v0XdFDxX/trSjU8ltTKXkfjeDmzHUibxs07aKoAhQLqPGyjLZUF0i5wZzS02u +t3u+Bondu0/oR+VbKEJGSDA/xyjYTIPKRv4I2xwzWpyS2TEp8qAdB1y/fUmNOBW1Sb9 YdRrq9Rna7KRg6E4foxc9eaKDS2//VizBsttyqNce2IkwMa+w6ZVIGYq8jrIovs1MAFp 7/6mqCEk+NqeVsmj0VXKAC/xbJnQQrb/b2xLNH3JI2kImXdsYf32s5mk4l45CLTF46y6 JfF/wQ2z0tANHaH+3W2LQUugsYkkV2V7DLYB580nM+FhVtsTGxf1V78bW8o+dFbq/JCZ RyLw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=IGdTDLf6; 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-145576-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145576-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 ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o8-20020a05622a044800b00432cfc75456si10248644qtx.585.2024.04.15.09.40.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 09:40:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-145576-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.microsoft.com header.s=default header.b=IGdTDLf6; 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-145576-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145576-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 3F30B1C21B6E for ; Mon, 15 Apr 2024 16:40:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 106C9839E5; Mon, 15 Apr 2024 16:38:42 +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="IGdTDLf6" Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 76D0182485; Mon, 15 Apr 2024 16:38:39 +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=1713199121; cv=none; b=J3bxOEvG5/v+oVB8S5upB+VxY0VsruVlVGfNNldSCcv85oE5sgKDtXqfCCzNswKuoJmRpSqTEj5s1uERvrjRtOBmG67rIwqcV+jEmkRwPs6BA/l2XFIWBcSM3Mkv7+7SOauzcv0og1OLHeCVhPN2C5ICocEr85UAiUIXH1fjseA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713199121; c=relaxed/simple; bh=Iu3sKE+YRCqwKdiAB3om3hv5zVJb0LpbWJ23pVnz8Cg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nrBHxxGrvGPl277AJG5SuJlgmm99YKP0yUAifKdIUJ8RmLE4z8yYARfzl1NjspbH+tr1PVgEXckSL1Pyty8Wh+8HyilUuq2SpIwMpejQBu3ofwghyfHNoMzcDWAl4921cgswsY4LOtDu4AB9bOkJa7CENYRDCGIZ3olUDLaxShk= 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=IGdTDLf6; 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 1127) id CFF9E20FC5F5; Mon, 15 Apr 2024 09:38:32 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com CFF9E20FC5F5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1713199112; bh=LhdsE6efodYH8GQvxcpPZhNnPBH3tY5kGI4QxFJUD7A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IGdTDLf6NwimYdoARfgYLzKymBbs2nS+TCIfTqZBb1p/2QYvV1Jy2p9AcHrIVGbyx wWNZ/6STv4qrFKgJ8h9jsk3naDFVR9zZ+6BOndDZ0reksraiMZRhJMSdbWw5C5xs+i 1qVsQkuqaNM6aI3DB4RwYnFb9zlWr/lKUQLRGxbg= Date: Mon, 15 Apr 2024 09:38:32 -0700 From: Saurabh Singh Sengar To: 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 Subject: Re: [PATCH net-next] net: mana: Add new device attributes for mana Message-ID: <20240415163832.GA28558@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1713174589-29243-1-git-send-email-shradhagupta@linux.microsoft.com> 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: <1713174589-29243-1-git-send-email-shradhagupta@linux.microsoft.com> User-Agent: Mutt/1.5.21 (2010-09-15) 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; > +} > + > +static int mana_gd_setup_sysfs(struct pci_dev *pdev) > +{ > + struct gdma_context *gc = pci_get_drvdata(pdev); > + int retval = 0; > + > + gc->mana_attributes.mana_mport_attr.attr.name = "mport"; > + gc->mana_attributes.mana_mport_attr.attr.mode = 0444; > + gc->mana_attributes.mana_mport_attr.show = mana_attr_show; > + sysfs_attr_init(&gc->mana_attributes.mana_mport_attr); > + retval = device_create_file(&pdev->dev, > + &gc->mana_attributes.mana_mport_attr); if you can use .dev_groups, sysfs creation and removal will be lot more simplified for the driver. - Saurabh