Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp322356lqd; Wed, 24 Apr 2024 03:34:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV7QAcrkd1d5RThmNAKLapHzOYe15JARqtsix2Yl8ApYWXS5HzfSFDyG/hKuzn2O2Vly4v2VtlRHn4voGHe1rCSJ+rSAs84A/fC5xTQXA== X-Google-Smtp-Source: AGHT+IHhdQ91HIir15Bt57qfhfcqVARVIzixTXek5VazC27ec1R5rdMcdTZuYoDx5G+1MH6eIbEC X-Received: by 2002:a50:9e8d:0:b0:572:1c21:1937 with SMTP id a13-20020a509e8d000000b005721c211937mr5830799edf.11.1713954861407; Wed, 24 Apr 2024 03:34:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713954861; cv=pass; d=google.com; s=arc-20160816; b=f3U4bbDQKROrpMjNUe6zIRRwUsVaJG8+XA8J7xS9n7tGPqX7bbOfAulyZv3yH9XLqf P/MBaGUtWUNfu8HCQHnXkMugdr+4Igvh4P4hKAzynY52fES73bnergEuOITahdS3LTGE 6FJLwEj82DvtEx2KeoJmj0Mna9VCkUOARfMIFLl/K43a7zPWe/F206ZNGBC7ygwCNzTa sk3byZyJlOp9V/qlBgIDnGbMel45RsE6X7dP/aF/tVis0uCfpnqN3xXe5Fmn1bwtnJod VGQCSqBGl8WSkvqSu7WgNs7uhCWGAdbueKAYq69kuLSuaedWuqiUkTqrmMlzswElupix cefA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :dkim-filter; bh=fmV2dEL2yO9DxzlpnlosDU08cXJN2Bc3pZpwWQ9nU5k=; fh=9F/zgAfNvLnDgRbLMUtbyBgsbRvrFwmtG/oTUj9XYVQ=; b=hTcOBqlFgqqWgqxt20V0Q6Qiz0ELB3NXDPbDm370L3vXEZOYkaZK8VIMIXwlimGkNL fNhd+pRnBJplJU+v/6hOMjwEtBIg75SDtnjMESlOI1EUsrVFKo5PdwF5bVE1stHqJaNP 80grN2C0GfV9IJUV7zVDDlFzq/ShyoQLreQilT9m+xcQgj1aXyZy5skexNpA7PleFFR7 /U5W2REEwfBwdRB/CIfq+O2xR3WIEW4WqqT4zOE20XHTxYiKro0oyGZghXsjeHzBfQpo px7ueRM/YrPk6Bpx/PgpT0+8SPUjcL+W5GbC0ItSs+S1OKVBfzzaYij7c2vwcGpSy0CK XJ1g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=GlM+J1m4; 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-156731-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156731-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 r6-20020a50d686000000b0056df9749489si7927842edi.651.2024.04.24.03.34.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 03:34:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-156731-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=GlM+J1m4; 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-156731-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156731-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 27C161F230B8 for ; Wed, 24 Apr 2024 10:34:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0A375159584; Wed, 24 Apr 2024 10:34:12 +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="GlM+J1m4" Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0DA8B142621; Wed, 24 Apr 2024 10:34:09 +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=1713954851; cv=none; b=molL5rueBkWpLEYqSQKMnAJ91PQN2pTfhaWTtp+bWja3NmxcUZb8ag1domkcKxO/vBh42ELktoNox2EDJE7XvEmrGlO2130uCWkCsucTYXBfNB/QW2RIPVTBN8MRiK9gGju+MVlJLCd7KRBWM8mbIec4+EqCaG0JfLTQMHoX7pg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713954851; c=relaxed/simple; bh=pBpwupSigKleZZTb+2kGSlklScf7AqbywhAP8CWXs1E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=j5wAvqrxyTTwS3iye9QyekWxGvHzVEbsBzg1XvvGWajqBYiYfDuwuO233aOrn5ngXUW4phzgOmEOqt5YK7KRW1M+zv4V03O+2kKk6+R3BfyWUaCPlPFS9O81LePq6JMhyqmMRWbECkVLCxoddvfFq1giuCuMrlgRxbJ8JIzg5U0= 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=GlM+J1m4; 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 B3906208591D; Wed, 24 Apr 2024 03:34:09 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com B3906208591D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1713954849; bh=fmV2dEL2yO9DxzlpnlosDU08cXJN2Bc3pZpwWQ9nU5k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GlM+J1m4MN+NBqgAk6ui0SjVDAU87Ui6H78VbQ6O0ZFDGJ8hSHxYlZ28HX9DaNVlA i/rPA9pTXl7J4XLOTElJUGZU6fvsYMB28q1FxnkgJRWe0EKkquBlCZD+6tZjAviJsC qhzt/CtHlrb6osxvWM//xRbF9c71mqb4irSDoKk8= From: Shradha Gupta To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Bjorn Helgaas , Jonathan Corbet , Randy Dunlap , Johannes Berg , Breno Leitao , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Long Li , Souradeep Chakrabarti , Konstantin Taranov , Yury Norov , linux-hyperv@vger.kernel.org Cc: Shradha Gupta , shradhagupta@microsoft.com Subject: [PATCH net-next v2 2/2] net: mana: Add new device attributes for mana Date: Wed, 24 Apr 2024 03:34:08 -0700 Message-Id: <1713954848-30299-1-git-send-email-shradhagupta@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1713954774-29953-1-git-send-email-shradhagupta@linux.microsoft.com> References: <1713954774-29953-1-git-send-email-shradhagupta@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Add new device attributes to read num_ports and max_num_msix setting for MANA device. Signed-off-by: Shradha Gupta --- Changes in v2 * Used the suggested method(v1 dicsussion) to implement sysfs device parameters for MANA device * Implemented attributes max_mtu and min_mtu generically for all device drivers --- .../net/ethernet/microsoft/mana/gdma_main.c | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/net/ethernet/microsoft/mana/gdma_main.c b/drivers/net/ethernet/microsoft/mana/gdma_main.c index 1332db9a08eb..e35f984e34ce 100644 --- a/drivers/net/ethernet/microsoft/mana/gdma_main.c +++ b/drivers/net/ethernet/microsoft/mana/gdma_main.c @@ -1471,6 +1471,37 @@ static bool mana_is_pf(unsigned short dev_id) return dev_id == MANA_PF_DEVICE_ID; } +static ssize_t num_ports_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; + + return sysfs_emit(buf, "%d\n", ac->num_ports); +} + +static DEVICE_ATTR_RO(num_ports); + +static ssize_t max_num_msix_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); + + return sysfs_emit(buf, "%d\n", gc->max_num_msix); +} + +static DEVICE_ATTR_RO(max_num_msix); + +static struct attribute *mana_gd_device_attrs[] = { + &dev_attr_num_ports.attr, + &dev_attr_max_num_msix.attr, + NULL, +}; + +ATTRIBUTE_GROUPS(mana_gd_device); + static int mana_gd_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { struct gdma_context *gc; @@ -1613,6 +1644,7 @@ static const struct pci_device_id mana_id_table[] = { }; static struct pci_driver mana_driver = { + .dev_groups = mana_gd_device_groups, .name = "mana", .id_table = mana_id_table, .probe = mana_gd_probe, -- 2.34.1