Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1545427lqp; Mon, 15 Apr 2024 09:22:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVYB3DRULA8Z4nDtUf5bya6LycF7+PRwb+ZNtYewDtVCNSRxQp/60k5Q0M/Rs2ebH2VuZbH5+n8Adwdk7XpVTHLYXSJVgD2Y8vhb3MlAg== X-Google-Smtp-Source: AGHT+IEf7CmjkRY0oo/DaQuzw5JXtmvX5wExMrwp4IR/VQ/t2U/1v6ZSGEDoo6PcrX9I1AzATTAD X-Received: by 2002:a17:902:a3cc:b0:1e5:caba:7fbd with SMTP id q12-20020a170902a3cc00b001e5caba7fbdmr10217729plb.44.1713198159669; Mon, 15 Apr 2024 09:22:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713198159; cv=pass; d=google.com; s=arc-20160816; b=yGWkNrvKfTVI5h2TwzeaU1EieGIMrXkCRxpAma8OwcEJHu5I1U4lr1jE1dYaGwBFN6 qLV/1AG3SYyreIZz6zrxDX3N1138S7whn53hBAa98obJql5IDFCWfI5FZiv8FxWeGd52 YpqEIY+8LKelyXZi0fZUfpzfGgu8cWQys1g8zwaoTBFndyx6Nd8GntrFIDSn/5rC8Whg +6EgozS2hKF1133pMkzcotPuM/Ix9wit1lE6pSBRmWcRt9LSr9ccOpdaGKvb1flj/w6Y 46Ia59pwnIw7WTTB9oSTdpj+veUxhsvAzZ7mrQvm/jPPKBnpy8YXiOL5NuyE0AD9ZE3G F66w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=on+iLChflz05Dr/oXUYjGxNpjkJObC3efkHZq3cR0H4=; fh=99PPjs8AifWl2MCDZPakkUB9+wHZWlzC+/LmGIHlSjk=; b=EUWBLNeJyvvfacAIKkrWWxF0zz3GYMIVX+1BgRWQn5D1cxaFosrMLkCczp+KyOu7gZ UDMCEnSwZC0eg6hNceHAwxZQXyERzmjKRMnWuofV2TK11PgnOEo/IO/KQM01CZ6Io0js +7m6Dmq6cP3eSEh7hrK/Wv7H/4fAo0SgGLbcIAaVbtMoDDaidFOqx9kGDRRLbxejDKXG cPO4pG+kdS9TTnyqHMuXqb2aCVbgdmEnN45MVRh3K3J/aJELaQvxo4UEUVTXG4wGFvco YHaEEwqwddAUFdJ+keMn+C71cvP0Kxe/pOg/Ee9pVj5KE1kkea9SVE/OhWbQn+8MJWwS HnpQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=ZjKwUMqo; arc=pass (i=1 spf=pass spfdomain=ziepe.ca dkim=pass dkdomain=ziepe.ca); spf=pass (google.com: domain of linux-kernel+bounces-145522-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145522-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id y11-20020a17090322cb00b001e4638cbd46si8055362plg.420.2024.04.15.09.22.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 09:22:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-145522-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=ZjKwUMqo; arc=pass (i=1 spf=pass spfdomain=ziepe.ca dkim=pass dkdomain=ziepe.ca); spf=pass (google.com: domain of linux-kernel+bounces-145522-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145522-linux.lists.archive=gmail.com@vger.kernel.org" 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 58B56B23EF2 for ; Mon, 15 Apr 2024 16:14:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 92EEC84A48; Mon, 15 Apr 2024 16:13:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="ZjKwUMqo" Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F00207F7FA for ; Mon, 15 Apr 2024 16:13:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713197590; cv=none; b=H9N/ORYRGUXD6gtNu/0eoLWYVCySl3JA1cVqUIiDM0cxlE2jmhJXC/WhYHDy7PKOG1u4mYuz4IePFx8Oeqq0Jxb1t+kvq/McFiECSxvForE+FkRo0Ewmqr7UHo7FbTu6akIgH9NesryCf7qZWJHZvmi6cVRv0XRE2egdgin1VMY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713197590; c=relaxed/simple; bh=3txhU/uOLpNTBRjbxQmBVPq2bA1GUBYvBxcrijzixx8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ThMvX1X9pKswLA0t1Qnr9/H2NCj0bbOHQTh5mqa53awKemmn3nPUuTlkwFAnRfAiXtfG+MHd3QLhdU/eZnrzQ1WfNrBGasOhGUekP2ljHMKG1MlaRJEYdRNHL7qsy8YWhxoW+hd+L23poyguGD7xoweCoJ8wDuuvD9whRwxSa5g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=ZjKwUMqo; arc=none smtp.client-ip=209.85.160.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Received: by mail-qt1-f179.google.com with SMTP id d75a77b69052e-434d0f63c31so14577451cf.1 for ; Mon, 15 Apr 2024 09:13:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1713197587; x=1713802387; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=on+iLChflz05Dr/oXUYjGxNpjkJObC3efkHZq3cR0H4=; b=ZjKwUMqoA90oBHmVpe7Xx0DHnZ1fQROR9vxQKYtPJg84Ecb9bm/HjbOlMAZMyhSg1/ MvUIapL9MB4IEm0uNhhwEo8pAXK77x+AM/RgVUPPRd3BvKHYY05lt1zZoo2d1csm7h/b 9algl+2CpVYyPX9XM/b4q6MDtBCso6jMDLyMIyzZxlmJMROzJr29Myw9hqfk1xzk7PHb Xku0zjkwFejkxprHeybOYuJDd8MEheW6/OAtkn9c2sMjJba+qQStYO71cdRx++2nct2s twrfNNyyMCAuqb4dKNhLnd9PIXvXEpKiML+V8pt79S5Qls5XnxilPVE2N/jQGrbt1uzm 70bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713197587; x=1713802387; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=on+iLChflz05Dr/oXUYjGxNpjkJObC3efkHZq3cR0H4=; b=S+jvE5Ob6BrIdW+zM6aHA7DbQ7+9BkkHNzbS5uDdEwjR9AHO7PflSQKkXqFnGxByh2 5ZuvTPUC02DYMLsx/gv91Fnq8R3tsge1NhZOW2metMxuINdPWMGinolfmAo7xeH5KN83 qBOFNoB5w2Nf5NuSOD6eWcjFf4ZTtW6MWEcJ6eyPRD9pVPVoXPn5e8xVYXl0CRkWPzo9 wF50B0U5xW2u2bAElSTGD+4pFVoHTRW3Q5Fq9k7wU2pwCBj2KgK1LFIjd9ubSOIvfSQj 8XOWdHecL/tzrBaFMx4tF+cV6z120PrRxk5FyfJLwcXRJyTsP2GyaPFro87Pu2n7Zp/X +SIg== X-Gm-Message-State: AOJu0YwV5zeOUUXO77ldKMMnePdO0sgWjj27hKcmzzE1+Juz850UlqFq vjkm9O7LN+CTS9cz3lgTuXJB+gDUA+YmRKsvs9G+pOi/Bn/qtDBOLBRzXJKjhjM= X-Received: by 2002:ac8:5747:0:b0:434:9253:da0c with SMTP id 7-20020ac85747000000b004349253da0cmr12619578qtx.7.1713197586903; Mon, 15 Apr 2024 09:13:06 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-68-80-239.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.80.239]) by smtp.gmail.com with ESMTPSA id fp17-20020a05622a509100b004343d021503sm6144270qtb.67.2024.04.15.09.13.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 09:13:06 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1rwOx7-006Br7-Sv; Mon, 15 Apr 2024 13:13:05 -0300 Date: Mon, 15 Apr 2024 13:13:05 -0300 From: Jason Gunthorpe 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: <20240415161305.GO223006@ziepe.ca> 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> 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