git: 87b97830f7e6 - stable/14 - iflib: Allow conditional LED device support

From: Kevin Bowling <kbowling_at_FreeBSD.org>
Date: Wed, 26 Aug 2026 01:07:13 UTC
The branch stable/14 has been updated by kbowling:

URL: https://cgit.FreeBSD.org/src/commit/?id=87b97830f7e65685448827bc87ee82d769eecb20

commit 87b97830f7e65685448827bc87ee82d769eecb20
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2026-08-12 01:29:31 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-08-26 01:06:54 +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.
    
    (cherry picked from commit 2519e19f05e0c3e5925bf81b729b4c28f2ad1af6)
---
 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 d52bf66bd110..a4cede67f16d 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)
 	{
@@ -341,6 +347,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 ed6ce3de70de..9c8fb396e3e1 100644
--- a/sys/net/iflib.c
+++ b/sys/net/iflib.c
@@ -5432,7 +5432,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);