From nobody Thu Aug 27 05:18:39 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 4hVqYX1dJ4z6qSCh for ; Thu, 27 Aug 2026 05:18:40 +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 4hVqYX120lz3l1X for ; Thu, 27 Aug 2026 05:18:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1787807920; 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=RIzUm4gZQz0pmB6alpewMAtcnyWZiCrtRDPKD3TXNtE=; b=eUR+MkrUcQCL1Jt+4daGVIrRtf7MTaaRYOK+bHuIOlhxc8MRYVwt59ZRxoIitJ1rCaX1S3 FRKxKiWtG6jEpbOrDA/BBWl9RkEUm6O8t2xP7AF4vs4z8CGFZcAmM/Ur0xW/fuYhoFSq6V c2tdFy9TU5wUaj3+EJGGxSSN8fpj0mRrL8zXH1rr/OADM+A/FuNqFvFe+Ispyc4ONwDqG3 C47F4aQDGAS8K6unxaLHeuAaGAnhqgzbSykuhiD8OwNtdEvHR/bD/w/+lpxRxSYRkLQxgf UE8c1zBvBEqrthiGwVnTNt8zl8z6C/4yy5K43UWTAVaIBnT5RmdDOwZDz1174A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1787807920; a=rsa-sha256; cv=none; b=igmh3Xi4TsAfUCTgKKknBvuI6J5x9uRJLrG/JtrGYM4vRVLE8FAxV78aes1W8OOjknHdd9 kTSHDGW3TZ1CJxChJLH9ihUISJUVzwBlGgAbte8dSFm51CJiVZvK/GXiJYsMgU/RB/gT8O 15U+fMZpHGc6jWl+nuVvNCM5GMfonsoq6fGXVlo+av57Ca7NnAjBiZQZvZ1ZLA+noJVaWi elKdFDhO7Ubnkx3ahOMn6G9u4LIooV5Ghow9z/6WE03Zp5PRCePDNIvKXWK6kqCKqqOAHd 0aFYPazj1cXbrRRH+JfA+YWkmy+ustHj0uZN3/HkG0/RG61TyMAyooGQSyh72g== 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=1787807920; 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=RIzUm4gZQz0pmB6alpewMAtcnyWZiCrtRDPKD3TXNtE=; b=waxT3/ppWNOEb6oYh6VsodvH6yK4dhPI1q8bp1uR+NtN/ufzpUkqu338tRtfV6BisJZ9Zk TvVkIJ7KDulrQS38/SEz5xgf0yFSNIyPALzibrVbDWrTmU1kyaBM97ycrixNS736y2GANY 9devOO2vNXKwyBf3hLSAS7QuUiLo5yxykbUVElQC7ExHOYSQ6Gu5HyNNaGKxpyEHTSRHBK 2ihPnSwsjyb0CEuJi3Y/LRvhP8tZ2lchrR4SixpUM8MpEvekjfQIDsub0SU5kGytuY7qoS RM9aHaFBd4hQK/xtm/DtMh56GKtF064SKshQ//rlBiWpKsenTZA/mUVrfbQsGg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hVqYW6bsWz18T8 for ; Thu, 27 Aug 2026 05:18:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 41ba0 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 27 Aug 2026 05:18:39 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 072f131a9012 - stable/14 - 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/14 X-Git-Reftype: branch X-Git-Commit: 072f131a90125a228359917d02669b6b563d366b Auto-Submitted: auto-generated Date: Thu, 27 Aug 2026 05:18:39 +0000 Message-Id: <6a8fc8af.41ba0.34036b4e@gitrepo.freebsd.org> The branch stable/14 has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=072f131a90125a228359917d02669b6b563d366b commit 072f131a90125a228359917d02669b6b563d366b Author: Kevin Bowling AuthorDate: 2026-08-12 01:29:31 +0000 Commit: Kevin Bowling CommitDate: 2026-08-27 05:18:13 +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 f07c66fd4dda..c7f970e54f08 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 August 18, 2020 +.Dd August 11, 2026 .Dt BNXT 4 .Os .Sh NAME @@ -52,6 +52,11 @@ and BCM57402/4/6 Ethernet controller chips. .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 0ba7b5723b91..e0a0224fa07c 100644 --- a/sys/dev/bnxt/bnxt_en/bnxt.h +++ b/sys/dev/bnxt/bnxt_en/bnxt.h @@ -457,6 +457,18 @@ struct bnxt_link_info { struct hwrm_port_phy_qcfg_output phy_qcfg_resp; }; +#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, @@ -1062,6 +1074,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 9e7f4614d9f9..0b3b21b2f5cc 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)}; @@ -1255,6 +1280,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 54d79ea39459..d8096ec14d9a 100644 --- a/sys/dev/bnxt/bnxt_en/if_bnxt.c +++ b/sys/dev/bnxt/bnxt_en/if_bnxt.c @@ -201,6 +201,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); @@ -320,6 +323,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), @@ -2044,11 +2049,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) { @@ -2494,6 +2502,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 @@ -2885,6 +2894,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); @@ -3223,6 +3233,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) {