git: 2519e19f05e0 - main - iflib: Allow conditional LED device support

Kevin Bowling <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a7cd27a.3415e.d6d1410__16431.4523850166$1786565266$gmane$org@gitrepo.freebsd.org>
The branch main has been updated by kbowling:

URL: https://cgit.FreeBSD.org/src/commit/?id=2519e19f05e0c3e5925bf81b729b4c28f2ad1af6

commit 2519e19f05e0c3e5925bf81b729b4c28f2ad1af6
Author:     Kevin Bowling <[email protected]>
AuthorDate: 2026-08-12 01:29:31 +0000
Commit:     Kevin Bowling <[email protected]>
CommitDate: 2026-08-12 20:06:16 +0000

    iflib: Allow conditional LED device support
    
    A driver class may implement LED control even though the capability is
    not available on every device or firmware version it supports.  Add an
    optional capability method and consult it before creating the led(4)
    device.  Default to supported so existing providers are unchanged.
    
    This will be used by bnxt which blends PF and VF in the same driver.
    
    MFC after:      2 weeks
---
 sys/net/ifdi_if.m | 10 ++++++++++
 sys/net/iflib.c   |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/sys/net/ifdi_if.m b/sys/net/ifdi_if.m
index cb24ba36ee60..e9db929e1900 100644
--- a/sys/net/ifdi_if.m
+++ b/sys/net/ifdi_if.m
@@ -71,6 +71,12 @@ CODE {
 	{
 	}
 
+	static bool
+	null_led_supported(if_ctx_t _ctx __unused)
+	{
+		return (true);
+	}
+
 	static void
 	null_vlan_register_op(if_ctx_t _ctx __unused, uint16_t vtag __unused)
 	{
@@ -347,6 +353,10 @@ METHOD void led_func {
 	int _onoff;
 } DEFAULT null_led_func;
 
+METHOD bool led_supported {
+	if_ctx_t _ctx;
+} DEFAULT null_led_supported;
+
 METHOD void vlan_register {
 	if_ctx_t _ctx;
 	uint16_t _vtag;
diff --git a/sys/net/iflib.c b/sys/net/iflib.c
index ef2f96c268e5..abc56f159547 100644
--- a/sys/net/iflib.c
+++ b/sys/net/iflib.c
@@ -5440,7 +5440,7 @@ iflib_device_register(device_t dev, void *sc, if_shared_ctx_t sctx, if_ctx_t *ct
 	kobj_desc = &ifdi_led_func_desc;
 	kobj_method = kobj_lookup_method(((kobj_t)ctx)->ops->cls, NULL,
 	    kobj_desc);
-	if (kobj_method != &kobj_desc->deflt)
+	if (kobj_method != &kobj_desc->deflt && IFDI_LED_SUPPORTED(ctx))
 		iflib_led_create(ctx);
 
 	return (0);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.