aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Bowling <kbowling@FreeBSD.org>2026-08-12 01:29:31 +0000
committerKevin Bowling <kbowling@FreeBSD.org>2026-08-12 20:06:16 +0000
commit2519e19f05e0c3e5925bf81b729b4c28f2ad1af6 (patch)
tree87e35b288b71faa38388f948c3b47d14b756c408
parent9f7633b932954162792e2caef4f6f0cd87e82f43 (diff)
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
-rw-r--r--sys/net/ifdi_if.m10
-rw-r--r--sys/net/iflib.c2
2 files changed, 11 insertions, 1 deletions
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);