diff mbox series

[net-next,v2,2/2] net: mana: Add new device attributes for mana

Message ID 1713954848-30299-1-git-send-email-shradhagupta@linux.microsoft.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series Add sysfs attributes for MANA | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 11 of 11 maintainers
netdev/build_clang success Errors and warnings before: 937 this patch: 937
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 937 this patch: 937
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 44 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-04-24--15-00 (tests: 995)

Commit Message

Shradha Gupta April 24, 2024, 10:34 a.m. UTC
Add new device attributes to read num_ports and max_num_msix setting for
MANA device.

Signed-off-by: Shradha Gupta <shradhagupta@linux.microsoft.com>
---
 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 mbox series

Patch

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,