From nobody Thu Aug 27 05:17:25 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4hVqXB6cQFz6qS6Z for ; Thu, 27 Aug 2026 05:17:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hVqXB5mg0z3kXq for ; Thu, 27 Aug 2026 05:17:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1787807850; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=VD5vqNKDBFe/+jwpyzKOkuTose1xGsINGjdMajOPaO8=; b=LeOhrcSBioUuqH8XqUJYWlVGCsX2OxLUuMqblZQJwpY5pjltWCzLwrtiHs0cZiDYMFCWbv Q5qQuP6Kta+RO+al+lkOB70h0iLtzuoao69udSnrBVsutCVRHejW8QS575LE1p73lLnVVb BooFWrDpMHuIif1vSalk5VMoBlgI+Wkwoig91LMnJt2YTf2BtzHsUIvBYHYaJ6vb44YvPG JKGsAsuzBo6O80qUguGp5uGYDinpgDrelI8f83S0rbcKQCgAWLJK0mglknkzbaCWdc4ljA ghQuE8SPPItbbUNfqq8k6c51zTSaVk5AiRXlvasgpfvSZignxcIhnsG7+FEUSw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1787807850; a=rsa-sha256; cv=none; b=Qz6KRDBo4TlO/JRyitw/CKfpFAht0A0Kp83xunYlobag5+4qsOmdxTfZPuyEGhmKT4rGCq 4VaJ5yzTntTvJDi+MXZBrLBWwoUGWk0I4phcJ+JwoaDw8D6dg012YfIq/V5I5GnmatoYzP X+Rmiy9QrkeGaulEA/m8laYRwEVakFxkviCU+P+lkgOAq3jpZt6m+MvHfF4R//H66KPVdD iEC4lW+MnYA4fjJuy3NjMQwnzjEuIaTfhJNy06L6NGL0BWcj4mXMdCiYoB9piby2QtUHh3 UBUaFcNKZE6W94Eg4M0tfmc+wltWI1BrEEspefa8n8NQdpSaMYZ7m5XGl+6hLg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1787807850; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=VD5vqNKDBFe/+jwpyzKOkuTose1xGsINGjdMajOPaO8=; b=u7iuzX4Lp3c/yYMlPgF+5iYB0hKWOzL4omJJK32wDMAyyy4Ke+1poj/nMahIvAR0gPlv/s hZY0MWWygOAh+jXLBLkObk/lYgkOUkrwqO0SiIxBy2BnoI4HJRuDOttHfPct+vqJqsvc5S vFcp0Xup8HU2GTZUyfEJ5dbgJyxsuKxpaXaXmjGoikTy7jDNNXS19T9JmWZX2kBI2KqABG 3FUJarMLVMQIm44n72J7gdL1rOhA1e7botnCS0FNq78U4me8X9H0VN0gwl6bgsfqRRpuTJ 7nbQ3ZIJAcKdXTt5xka0sP7IqNzrm94jUjkXVMUlABdc1KFzBo+52di4/OsTmQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hVqXB4Zsbz18dB for ; Thu, 27 Aug 2026 05:17:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 42426 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 27 Aug 2026 05:17:25 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: b057c92506f8 - stable/15 - bnxt: Add led(4) identification support List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: b057c92506f8600bd0d703eae4337ce81bfbeea9 Auto-Submitted: auto-generated Date: Thu, 27 Aug 2026 05:17:25 +0000 Message-Id: <6a8fc865.42426.6d18eace@gitrepo.freebsd.org> The branch stable/15 has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=b057c92506f8600bd0d703eae4337ce81bfbeea9 commit b057c92506f8600bd0d703eae4337ce81bfbeea9 Author: Kevin Bowling AuthorDate: 2026-08-12 01:29:31 +0000 Commit: Kevin Bowling CommitDate: 2026-08-27 05:16:56 +0000 bnxt: Add led(4) identification support Query the firmware for the LEDs on each physical port and expose /dev/led/bnxt* only when alternate blinking is supported. Configure every LED in the advertised group for identification and restore its default firmware state before a function reset. This follows the DPDK and Linux bnxt HWRM identification paths. Reviewed against: DPDK, Linux Reviewed by: Sumit Saxena Sponsored by: BBOX.io (cherry picked from commit 98b5640786f874949e441bee7c4ad5740cd6a649) --- share/man/man4/bnxt.4 | 7 ++- sys/dev/bnxt/bnxt_en/bnxt.h | 15 ++++++ sys/dev/bnxt/bnxt_en/bnxt_hwrm.c | 105 +++++++++++++++++++++++++++++++++++++++ sys/dev/bnxt/bnxt_en/bnxt_hwrm.h | 2 + sys/dev/bnxt/bnxt_en/if_bnxt.c | 41 +++++++++++++++ 5 files changed, 169 insertions(+), 1 deletion(-) diff --git a/share/man/man4/bnxt.4 b/share/man/man4/bnxt.4 index 5e3ee27426d5..cedab9b83d00 100644 --- a/share/man/man4/bnxt.4 +++ b/share/man/man4/bnxt.4 @@ -23,7 +23,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF .\" THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd December 10, 2025 +.Dd August 11, 2026 .Dt BNXT 4 .Os .Sh NAME @@ -52,6 +52,11 @@ BCM574XX, BCM575XX, and BCM576XX Ethernet controllers. .Pp For more information on configuring this device, see .Xr ifconfig 8 . +.Pp +On physical functions whose firmware reports identification LED support, +the LEDs for each port are controlled through its +.Pa /dev/led/bnxt* +device node. .Sh HARDWARE The .Nm diff --git a/sys/dev/bnxt/bnxt_en/bnxt.h b/sys/dev/bnxt/bnxt_en/bnxt.h index 64482a656e9d..6b4db469e7aa 100644 --- a/sys/dev/bnxt/bnxt_en/bnxt.h +++ b/sys/dev/bnxt/bnxt_en/bnxt.h @@ -458,6 +458,18 @@ struct bnxt_link_info { uint8_t active_lanes; }; +#define BNXT_MAX_LED 4 + +/* Layout of one LED capability record returned by HWRM_PORT_LED_QCAPS. */ +struct bnxt_led_info { + uint8_t led_id; + uint8_t led_type; + uint8_t led_group_id; + uint8_t unused; + uint16_t led_state_caps; + uint16_t led_color_caps; +}; + enum bnxt_phy_type { BNXT_MEDIA_CR = 0, BNXT_MEDIA_LR, @@ -1063,6 +1075,9 @@ struct bnxt_softc { struct bnxt_bar_info hwrm_bar; struct bnxt_bar_info doorbell_bar; struct bnxt_link_info link_info; + struct bnxt_led_info leds[BNXT_MAX_LED]; + uint8_t num_leds; + bool led_active; #define BNXT_FLAG_VF 0x0001 #define BNXT_FLAG_NPAR 0x0002 #define BNXT_FLAG_WOL_CAP 0x0004 diff --git a/sys/dev/bnxt/bnxt_en/bnxt_hwrm.c b/sys/dev/bnxt/bnxt_en/bnxt_hwrm.c index 2a79b418fe62..11b6bd949e72 100644 --- a/sys/dev/bnxt/bnxt_en/bnxt_hwrm.c +++ b/sys/dev/bnxt/bnxt_en/bnxt_hwrm.c @@ -73,6 +73,31 @@ static void bnxt_hwrm_set_eee(struct bnxt_softc *softc, BNXT_TX_STATS_PRI_ENTRY(counter, 6), \ BNXT_TX_STATS_PRI_ENTRY(counter, 7) +#define BNXT_LED_DFLT_ENA \ + (HWRM_PORT_LED_CFG_INPUT_ENABLES_LED0_ID | \ + HWRM_PORT_LED_CFG_INPUT_ENABLES_LED0_STATE | \ + HWRM_PORT_LED_CFG_INPUT_ENABLES_LED0_BLINK_ON | \ + HWRM_PORT_LED_CFG_INPUT_ENABLES_LED0_BLINK_OFF | \ + HWRM_PORT_LED_CFG_INPUT_ENABLES_LED0_GROUP_ID) +#define BNXT_LED_DFLT_ENA_SHIFT 6 +#define BNXT_LED_DFLT_ENABLES(_i) \ + (BNXT_LED_DFLT_ENA << (BNXT_LED_DFLT_ENA_SHIFT * (_i))) +#define BNXT_LED_ALT_BLINK_CAP \ + HWRM_PORT_LED_QCAPS_OUTPUT_LED0_STATE_CAPS_BLINK_ALT_SUPPORTED + +struct bnxt_led_cfg { + uint8_t led_id; + uint8_t led_state; + uint8_t led_color; + uint8_t unused; + uint16_t led_blink_on; + uint16_t led_blink_off; + uint8_t led_group_id; + uint8_t reserved; +}; + +CTASSERT(sizeof(struct bnxt_led_info) == 8); +CTASSERT(sizeof(struct bnxt_led_cfg) == 10); long bnxt_rx_bytes_pri_arr_base_off[] = {BNXT_RX_STATS_PRI_ENTRIES(rx_bytes)}; long bnxt_rx_pkts_pri_arr_base_off[] = {BNXT_RX_STATS_PRI_ENTRIES(rx_packets)}; @@ -1258,6 +1283,86 @@ fail: return rc; } +int +bnxt_hwrm_port_led_qcaps(struct bnxt_softc *softc) +{ + struct hwrm_port_led_qcaps_output *resp; + struct hwrm_port_led_qcaps_input req = {0}; + struct bnxt_led_info *led; + uint16_t caps; + int i, rc; + + softc->num_leds = 0; + if (BNXT_VF(softc) || softc->hwrm_spec_code < 0x10601) + return (0); + + resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; + bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_PORT_LED_QCAPS); + req.port_id = htole16(softc->pf.port_id); + + BNXT_HWRM_LOCK(softc); + rc = _hwrm_send_message(softc, &req, sizeof(req)); + if (rc != 0) + goto out; + + /* HWRM describes up to four LED records in both response and request. */ + if (resp->num_leds == 0 || resp->num_leds > BNXT_MAX_LED) + goto out; + memcpy(softc->leds, &resp->led0_id, + sizeof(softc->leds[0]) * resp->num_leds); + softc->num_leds = resp->num_leds; + for (i = 0; i < softc->num_leds; i++) { + led = &softc->leds[i]; + caps = le16toh(led->led_state_caps); + if (led->led_group_id == 0 || + (caps & BNXT_LED_ALT_BLINK_CAP) == 0) { + softc->num_leds = 0; + break; + } + } +out: + BNXT_HWRM_UNLOCK(softc); + return (rc); +} + +int +bnxt_hwrm_port_led_cfg(struct bnxt_softc *softc, bool led_on) +{ + struct hwrm_port_led_cfg_input req = {0}; + struct bnxt_led_cfg *led_cfg; + uint32_t enables; + uint16_t duration; + uint8_t led_state; + int i; + + if (BNXT_VF(softc) || softc->num_leds == 0) + return (EOPNOTSUPP); + + bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_PORT_LED_CFG); + req.port_id = htole16(softc->pf.port_id); + req.num_leds = softc->num_leds; + led_state = HWRM_PORT_LED_CFG_INPUT_LED0_STATE_DEFAULT; + duration = 0; + if (led_on) { + led_state = HWRM_PORT_LED_CFG_INPUT_LED0_STATE_BLINKALT; + duration = htole16(500); + } + + enables = 0; + led_cfg = (struct bnxt_led_cfg *)(void *)&req.led0_id; + for (i = 0; i < softc->num_leds; i++, led_cfg++) { + enables |= BNXT_LED_DFLT_ENABLES(i); + led_cfg->led_id = softc->leds[i].led_id; + led_cfg->led_state = led_state; + led_cfg->led_blink_on = duration; + led_cfg->led_blink_off = duration; + led_cfg->led_group_id = softc->leds[i].led_group_id; + } + req.enables = htole32(enables); + + return (hwrm_send_message(softc, &req, sizeof(req))); +} + int bnxt_hwrm_func_qcfg(struct bnxt_softc *softc) { diff --git a/sys/dev/bnxt/bnxt_en/bnxt_hwrm.h b/sys/dev/bnxt/bnxt_en/bnxt_hwrm.h index 126cad977c82..edc5f3579dd9 100644 --- a/sys/dev/bnxt/bnxt_en/bnxt_hwrm.h +++ b/sys/dev/bnxt/bnxt_en/bnxt_hwrm.h @@ -69,6 +69,8 @@ int bnxt_hwrm_stat_ctx_alloc(struct bnxt_softc *softc, struct bnxt_cp_ring *cpr, int bnxt_hwrm_stat_ctx_free(struct bnxt_softc *softc, struct bnxt_cp_ring *cpr); int bnxt_hwrm_port_qstats(struct bnxt_softc *softc); int bnxt_hwrm_port_qstats_ext(struct bnxt_softc *softc); +int bnxt_hwrm_port_led_qcaps(struct bnxt_softc *softc); +int bnxt_hwrm_port_led_cfg(struct bnxt_softc *softc, bool led_on); int bnxt_hwrm_ring_grp_alloc(struct bnxt_softc *softc, struct bnxt_grp_info *grp); int bnxt_hwrm_ring_grp_free(struct bnxt_softc *softc, struct bnxt_grp_info *gr); diff --git a/sys/dev/bnxt/bnxt_en/if_bnxt.c b/sys/dev/bnxt/bnxt_en/if_bnxt.c index 79047490455b..556d63e4015f 100644 --- a/sys/dev/bnxt/bnxt_en/if_bnxt.c +++ b/sys/dev/bnxt/bnxt_en/if_bnxt.c @@ -200,6 +200,9 @@ static int bnxt_detach(if_ctx_t ctx); static void bnxt_init(if_ctx_t ctx); static int bnxt_init_hw(if_ctx_t ctx); static void bnxt_stop(if_ctx_t ctx); +static void bnxt_if_led_func(if_ctx_t ctx, int onoff); +static bool bnxt_if_led_supported(if_ctx_t ctx); +static void bnxt_led_restore(struct bnxt_softc *softc); static void bnxt_multi_set(if_ctx_t ctx); static int bnxt_mtu_set(if_ctx_t ctx, uint32_t mtu); static void bnxt_media_status(if_ctx_t ctx, struct ifmediareq * ifmr); @@ -319,6 +322,8 @@ static device_method_t bnxt_iflib_methods[] = { DEVMETHOD(ifdi_init, bnxt_init), DEVMETHOD(ifdi_stop, bnxt_stop), + DEVMETHOD(ifdi_led_func, bnxt_if_led_func), + DEVMETHOD(ifdi_led_supported, bnxt_if_led_supported), DEVMETHOD(ifdi_multi_set, bnxt_multi_set), DEVMETHOD(ifdi_mtu_set, bnxt_mtu_set), DEVMETHOD(ifdi_media_status, bnxt_media_status), @@ -2048,11 +2053,14 @@ static int bnxt_open(struct bnxt_softc *bp) rc = bnxt_hwrm_func_qcaps(bp); if (rc) return rc; + (void)bnxt_hwrm_port_led_qcaps(bp); /* Register the driver with the FW */ rc = bnxt_drv_rgtr(bp); if (rc) return rc; + /* Retry a restore which could not complete before firmware reset. */ + bnxt_led_restore(bp); if (bp->hwrm_spec_code >= 0x10803) { rc = bnxt_alloc_ctx_mem(bp); if (rc) { @@ -2498,6 +2506,7 @@ bnxt_attach_pre(if_ctx_t ctx) rc = bnxt_hwrm_func_qcaps(softc); if (rc) goto failed; + (void)bnxt_hwrm_port_led_qcaps(softc); /* * Register the driver with the FW @@ -2896,6 +2905,7 @@ fail: static void bnxt_func_reset(struct bnxt_softc *softc) { + bnxt_led_restore(softc); if (!BNXT_CHIP_P5_PLUS(softc)) { bnxt_hwrm_func_reset(softc); @@ -3234,6 +3244,37 @@ bnxt_stop(if_ctx_t ctx) return; } +static void +bnxt_if_led_func(if_ctx_t ctx, int onoff) +{ + struct bnxt_softc *softc = iflib_get_softc(ctx); + bool active; + + active = onoff != 0; + if (active == softc->led_active) + return; + if (bnxt_hwrm_port_led_cfg(softc, active) == 0) + softc->led_active = active; +} + +static void +bnxt_led_restore(struct bnxt_softc *softc) +{ + + if (!softc->led_active) + return; + if (bnxt_hwrm_port_led_cfg(softc, false) == 0) + softc->led_active = false; +} + +static bool +bnxt_if_led_supported(if_ctx_t ctx) +{ + struct bnxt_softc *softc = iflib_get_softc(ctx); + + return (softc->num_leds != 0); +} + static u_int bnxt_copy_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt) {