Skip to contentSkip to conversation

net: dsa: motorcomm: Add devlink info and resources

PATCH New David Yang 1 participant 1 message Nov 19

Subsystems (6)
lore
Share & tools
lore

David Yang

author maintainer
#0 lore raw

PATCH v6 1/1 net: dsa: motorcomm: Add devlink info and resources

Expose the ASIC model via devlink info (ASIC_ID), and register devlink resources for ACLs and meters. Document the devlink support.

---
v6:
- add devlink document
v5: https://lore.kernel.org/r/[email protected]
- minor stylistic fixes
v4: https://lore.kernel.org/r/[email protected]
- remove FDB-related changes
v3: https://lore.kernel.org/r/[email protected]
- remove the buggy sub-resources
v2: https://lore.kernel.org/r/[email protected]
- fix issues reported by sashiko

 Documentation/networking/devlink/index.rst  |   1 +
 Documentation/networking/devlink/yt921x.rst |  37 +++++++
 MAINTAINERS                                 |   1 +
 drivers/net/dsa/motorcomm/Makefile          |   1 +
 drivers/net/dsa/motorcomm/chip.c            |   8 ++
 drivers/net/dsa/motorcomm/devlink.c         | 107 ++++++++++++++++++++
 drivers/net/dsa/motorcomm/devlink.h         |  18 ++++
 7 files changed, 173 insertions(+)
 create mode 100644 Documentation/networking/devlink/yt921x.rst
 create mode 100644 drivers/net/dsa/motorcomm/devlink.c
 create mode 100644 drivers/net/dsa/motorcomm/devlink.h
Documentation/networking/devlink/index.rst +1 -0
index 03f49389a755..be0d59cbaa3c 100644
@@ -104,4 +104,5 @@ parameters, info versions, and other features it supports.
    sfc
    stmmac
    ti-cpsw-switch
+   yt921x
    zl3073x
Documentation/networking/devlink/yt921x.rst new file +37 -0
new file mode 100644
index 000000000000..7ccb75a30029
@@ -0,0 +1,37 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+=======================
+yt921x devlink support
+=======================
+
+This document describes the devlink features implemented by the ``yt921x``
+device driver.
+
+Info versions
+=============
+
+The ``yt921x`` driver reports the following devlink info versions.
+
+.. list-table:: devlink info versions implemented
+
+   * - Name
+     - Description
+   * - ``asic.id``
+     - ASIC model name as reported by the driver.
+
+Resources
+=========
+
+The ``yt921x`` driver exposes the following devlink resources to monitor
+hardware occupancy.
+
+.. list-table:: Driver-specific resources implemented
+   :widths: 5 95
+
+   * - Name
+     - Description
+   * - ``ACL``
+     - TCAM entries available for ACL rules, 384 entries in total, organized
+       as 48 blocks of 8 entries.
+   * - ``meters``
+     - Meters available for ACL rules to police matching flows, 64 in total.
MAINTAINERS +1 -0
index 40bb77cbc6b0..8ef92c9ff65f 100644
@@ -18974,6 +18974,7 @@ M:	David Yang <[email protected]>
 L:	[email protected]
 S:	Maintained
 F:	Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml
+F:	Documentation/networking/devlink/yt921x.rst
 F:	drivers/net/dsa/motorcomm/
 F:	net/dsa/tag_yt921x.c
 
drivers/net/dsa/motorcomm/Makefile +1 -0
index 9eaa59f699e8..0b31d815ce43 100644
@@ -2,6 +2,7 @@
 obj-$(CONFIG_NET_DSA_YT921X) += yt921x.o
 yt921x-objs := chip.o
 yt921x-$(CONFIG_NET_DSA_YT921X_LEDS) += leds.o
+yt921x-objs += devlink.o
 yt921x-objs += mdio_bus.o
 yt921x-objs += mib.o
 yt921x-objs += pcs-921x.o
drivers/net/dsa/motorcomm/chip.c +8 -0
index 35e70b322608..dca5bc593848 100644
@@ -26,6 +26,7 @@
 #include <net/ieee8021q.h>
 
 #include "chip.h"
+#include "devlink.h"
 #include "leds.h"
 #include "mdio_bus.h"
 #include "mib.h"
@@ -2149,6 +2150,8 @@ static void yt921x_dsa_teardown(struct dsa_switch *ds)
 
 	yt921x_leds_remove(priv);
 #endif
+
+	dsa_devlink_resources_unregister(ds);
 }
 
 static int yt921x_chip_detect(struct yt921x_priv *priv)
@@ -2483,6 +2486,10 @@ static int yt921x_dsa_setup(struct dsa_switch *ds)
 	if (res)
 		return res;
 
+	res = yt921x_devlink_setup(priv);
+	if (res)
+		return res;
+
 #if IS_ENABLED(CONFIG_NET_DSA_YT921X_LEDS)
 	res = yt921x_leds_setup(priv);
 	if (res)
@@ -2571,6 +2578,7 @@ static const struct dsa_switch_ops yt921x_dsa_switch_ops = {
 	.port_add_dscp_prio	= yt921x_dsa_port_add_dscp_prio,
 #endif
 	/* chip */
+	.devlink_info_get	= yt921x_dsa_devlink_info_get,
 	.teardown		= yt921x_dsa_teardown,
 	.setup			= yt921x_dsa_setup,
 };
drivers/net/dsa/motorcomm/devlink.c new file +107 -0

107 lines not on this page · raw message

drivers/net/dsa/motorcomm/devlink.h new file +18 -0
new file mode 100644
index 000000000000..184b9f05742e
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (c) 2026 David Yang
+ */
+
+#ifndef _YT_DEVLINK_H
+#define _YT_DEVLINK_H
+
+#include <net/dsa.h>
+
+struct yt921x_priv;
+
+int
+yt921x_dsa_devlink_info_get(struct dsa_switch *ds, struct devlink_info_req *req,
+			    struct netlink_ext_ack *extack);
+int yt921x_devlink_setup(struct yt921x_priv *priv);
+
+#endif
Signature · 1 line
2.53.0