From nobody Mon Jun 03 19:24:57 2024 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 4VtNwB2GDYz5Js30; Mon, 03 Jun 2024 19:24:58 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VtNw96BKbz4VWQ; Mon, 3 Jun 2024 19:24:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717442697; 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=w/yPAK0jMzz62O/xFTPwFtPAD97xplCyK96l2fOxG2s=; b=DDPAWtWiJPfWKGRuyfhNguhqc2GRgc544lJkJLxKd8shiYzIpaa3p2f/B/uv8+TpE6KrA3 O4tpagh+K0O1WoADRcmwHNkDK+MOEVX3pZqKHyfk30R7DMzlG46mv3Kpeq3jtwXIrarXq6 E26HGBsE1UO2USb/SgCWOVJcL16q5PB0Y7w9E1OjyG7FaecjSQpmd3KhO/ySWwBKP3ARjF BM3W+RTjE5st3HIOHauu025PbG0i0zPA0iJhjJnj3mq0bPA7vTJ7GjfdDrTq9jSNyh/u5y Yzo1MFl61/szd8e4e7ypAbMGUmLrQQ/S1PL4O/je0OQACQWb2HKX8x/iRv0S6w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1717442697; a=rsa-sha256; cv=none; b=q07AnbT1QPB03SqUxTxNQzN7i5wcf9QOYrEPMKVcavmLPsXDXWzNMjFF/qrbTmPCx0igAs o6SzwrDw+dRtqBBVb6fs+/t09MZZLEvG+ZkhVvRw2U3iMotn1e2l/DhKzXeCOy0Y/PAvGZ iZTXgI62x2VmOsVzpOdl6d5oXdhb8uOo1V8Y726y2mHI4J/sLhPqQjf/PrYlu3O39TT6rW oZ6u3w179eIKjO6whKxv2sf1nOcs+7dWZrYQ4stDDyrLjmEEW2WhfDnW7lnYz4CVx91qUC c6GdnBBqF4x7FxFTo8Z/XQbd7kegb7vDzZ7yTQZC2fjsiuEQ3tlla4Po9iukMw== 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=1717442697; 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=w/yPAK0jMzz62O/xFTPwFtPAD97xplCyK96l2fOxG2s=; b=qrgcoT6lGDHVWpPkE1ZdvMLoKi9/P7oGyRe6hwVZl8f/II/6BoeWUFsilrsSnDlV4bANwX Y6FMshd5xndtvZsll677enIcgx/tbfjc9ZhxXTCfwnS3kNPngn1H6kvoVi2OKxvmOg5/p5 PWrRMMGEAe5oG1CKH5VNsBDkMsH3MFN2twQMN8vR+p4H3j5fujrMh5NEe6EBloo618ODRs 3Q3AqF2iWVrD9ZjpfGWb4K5MYr4akNydyLocS3WOVKAZhmxlcxfcdy2spGQDpaSYeJzWEc wMhyR7CobC2NYg8K0B9PYlYbnjyT/wI0ZD6V/ijHJc8wayzYm6rdRNvwGEUhGw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VtNw95n6Dzn1h; Mon, 3 Jun 2024 19:24:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 453JOvLa067734; Mon, 3 Jun 2024 19:24:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 453JOv3e067731; Mon, 3 Jun 2024 19:24:57 GMT (envelope-from git) Date: Mon, 3 Jun 2024 19:24:57 GMT Message-Id: <202406031924.453JOv3e067731@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: 43d9017a2fcd - stable/14 - if_bnxt: Pluggable Module Display 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 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 43d9017a2fcdb62682af401a142d2731df2e10a0 Auto-Submitted: auto-generated The branch stable/14 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=43d9017a2fcdb62682af401a142d2731df2e10a0 commit 43d9017a2fcdb62682af401a142d2731df2e10a0 Author: Sumit Saxena AuthorDate: 2024-03-06 13:21:21 +0000 Commit: Warner Losh CommitDate: 2024-06-03 19:23:13 +0000 if_bnxt: Pluggable Module Display Support This update enables the display of pluggable module information to users via the ifconfig utility. Reviewed by: imp Approved by: imp Differential revision: https://reviews.freebsd.org/D42958 (cherry picked from commit 3320f0f69f06df5c36daa8ff71e0c07908ff0f1a) --- sys/dev/bnxt/bnxt.h | 8 +++++++ sys/dev/bnxt/bnxt_hwrm.c | 40 ++++++++++++++++++++++++++++++++ sys/dev/bnxt/if_bnxt.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+) diff --git a/sys/dev/bnxt/bnxt.h b/sys/dev/bnxt/bnxt.h index a5c607dbe247..4397e0478a0c 100644 --- a/sys/dev/bnxt/bnxt.h +++ b/sys/dev/bnxt/bnxt.h @@ -319,6 +319,8 @@ struct bnxt_link_info { #define BNXT_AUTONEG_FLOW_CTRL 2 uint8_t req_duplex; uint16_t req_link_speed; + uint8_t module_status; + struct hwrm_port_phy_qcfg_output phy_qcfg_resp; }; enum bnxt_cp_type { @@ -802,9 +804,15 @@ struct bnxt_filter_info { uint64_t l2_filter_id_hint; }; +#define I2C_DEV_ADDR_A0 0xa0 +#define BNXT_MAX_PHY_I2C_RESP_SIZE 64 + /* Function declarations */ void bnxt_report_link(struct bnxt_softc *softc); bool bnxt_check_hwrm_version(struct bnxt_softc *softc); struct bnxt_softc *bnxt_find_dev(uint32_t domain, uint32_t bus, uint32_t dev_fn, char *name); +int bnxt_read_sfp_module_eeprom_info(struct bnxt_softc *bp, uint16_t i2c_addr, + uint16_t page_number, uint8_t bank, bool bank_sel_en, uint16_t start_addr, + uint16_t data_length, uint8_t *buf); #endif /* _BNXT_H */ diff --git a/sys/dev/bnxt/bnxt_hwrm.c b/sys/dev/bnxt/bnxt_hwrm.c index 38e6c0db670f..97574c768235 100644 --- a/sys/dev/bnxt/bnxt_hwrm.c +++ b/sys/dev/bnxt/bnxt_hwrm.c @@ -2184,6 +2184,44 @@ bnxt_hwrm_fw_set_time(struct bnxt_softc *softc, uint16_t year, uint8_t month, return hwrm_send_message(softc, &req, sizeof(req)); } +int bnxt_read_sfp_module_eeprom_info(struct bnxt_softc *softc, uint16_t i2c_addr, + uint16_t page_number, uint8_t bank,bool bank_sel_en, uint16_t start_addr, + uint16_t data_length, uint8_t *buf) +{ + struct hwrm_port_phy_i2c_read_output *output = + (void *)softc->hwrm_cmd_resp.idi_vaddr; + struct hwrm_port_phy_i2c_read_input req = {0}; + int rc = 0, byte_offset = 0; + + BNXT_HWRM_LOCK(softc); + bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_PORT_PHY_I2C_READ); + + req.i2c_slave_addr = i2c_addr; + req.page_number = htole16(page_number); + req.port_id = htole16(softc->pf.port_id); + do { + uint16_t xfer_size; + + xfer_size = min_t(uint16_t, data_length, BNXT_MAX_PHY_I2C_RESP_SIZE); + data_length -= xfer_size; + req.page_offset = htole16(start_addr + byte_offset); + req.data_length = xfer_size; + req.bank_number = bank; + req.enables = htole32((start_addr + byte_offset ? + HWRM_PORT_PHY_I2C_READ_INPUT_ENABLES_PAGE_OFFSET : 0) | + (bank_sel_en ? + HWRM_PORT_PHY_I2C_READ_INPUT_ENABLES_BANK_NUMBER : 0)); + rc = hwrm_send_message(softc, &req, sizeof(req)); + if (!rc) + memcpy(buf + byte_offset, output->data, xfer_size); + byte_offset += xfer_size; + } while (!rc && data_length > 0); + + BNXT_HWRM_UNLOCK(softc); + + return rc; +} + int bnxt_hwrm_port_phy_qcfg(struct bnxt_softc *softc) { @@ -2200,6 +2238,7 @@ bnxt_hwrm_port_phy_qcfg(struct bnxt_softc *softc) if (rc) goto exit; + memcpy(&link_info->phy_qcfg_resp, resp, sizeof(*resp)); link_info->phy_link_status = resp->link; link_info->duplex = resp->duplex_cfg; link_info->auto_mode = resp->auto_mode; @@ -2264,6 +2303,7 @@ bnxt_hwrm_port_phy_qcfg(struct bnxt_softc *softc) link_info->transceiver = resp->xcvr_pkg_type; link_info->phy_addr = resp->eee_config_phy_addr & HWRM_PORT_PHY_QCFG_OUTPUT_PHY_ADDR_MASK; + link_info->module_status = resp->module_status; exit: BNXT_HWRM_UNLOCK(softc); diff --git a/sys/dev/bnxt/if_bnxt.c b/sys/dev/bnxt/if_bnxt.c index 0de1ffe78db1..4bd9af19d660 100644 --- a/sys/dev/bnxt/if_bnxt.c +++ b/sys/dev/bnxt/if_bnxt.c @@ -225,6 +225,8 @@ static uint64_t bnxt_get_baudrate(struct bnxt_link_info *link); static void bnxt_get_wol_settings(struct bnxt_softc *softc); static int bnxt_wol_config(if_ctx_t ctx); static bool bnxt_if_needs_restart(if_ctx_t, enum iflib_restart_event); +static int bnxt_i2c_req(if_ctx_t ctx, struct ifi2creq *i2c); +static void bnxt_get_port_module_status(struct bnxt_softc *softc); /* * Device Interface Declaration @@ -288,6 +290,7 @@ static device_method_t bnxt_iflib_methods[] = { DEVMETHOD(ifdi_suspend, bnxt_suspend), DEVMETHOD(ifdi_shutdown, bnxt_shutdown), DEVMETHOD(ifdi_resume, bnxt_resume), + DEVMETHOD(ifdi_i2c_req, bnxt_i2c_req), DEVMETHOD(ifdi_needs_restart, bnxt_if_needs_restart), @@ -1808,6 +1811,33 @@ bnxt_rss_grp_tbl_init(struct bnxt_softc *softc) } } +static void bnxt_get_port_module_status(struct bnxt_softc *softc) +{ + struct bnxt_link_info *link_info = &softc->link_info; + struct hwrm_port_phy_qcfg_output *resp = &link_info->phy_qcfg_resp; + uint8_t module_status; + + if (bnxt_update_link(softc, false)) + return; + + module_status = link_info->module_status; + switch (module_status) { + case HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_DISABLETX: + case HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_PWRDOWN: + case HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_WARNINGMSG: + device_printf(softc->dev, "Unqualified SFP+ module detected on port %d\n", + softc->pf.port_id); + if (softc->hwrm_spec_code >= 0x10201) { + device_printf(softc->dev, "Module part number %s\n", + resp->phy_vendor_partnumber); + } + if (module_status == HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_DISABLETX) + device_printf(softc->dev, "TX is disabled\n"); + if (module_status == HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_PWRDOWN) + device_printf(softc->dev, "SFP+ module is shutdown\n"); + } +} + /* Device configuration */ static void bnxt_init(if_ctx_t ctx) @@ -1970,6 +2000,7 @@ skip_def_cp_ring: } bnxt_do_enable_intr(&softc->def_cp_ring); + bnxt_get_port_module_status(softc); bnxt_media_status(softc->ctx, &ifmr); bnxt_hwrm_cfa_l2_set_rx_mask(softc, &softc->vnic_info); return; @@ -2875,6 +2906,33 @@ exit: return rc; } +static int +bnxt_i2c_req(if_ctx_t ctx, struct ifi2creq *i2c) +{ + struct bnxt_softc *softc = iflib_get_softc(ctx); + uint8_t *data = i2c->data; + int rc; + + /* No point in going further if phy status indicates + * module is not inserted or if it is powered down or + * if it is of type 10GBase-T + */ + if (softc->link_info.module_status > + HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_WARNINGMSG) + return -EOPNOTSUPP; + + /* This feature is not supported in older firmware versions */ + if (!BNXT_CHIP_P5(softc) || + (softc->hwrm_spec_code < 0x10202)) + return -EOPNOTSUPP; + + + rc = bnxt_read_sfp_module_eeprom_info(softc, I2C_DEV_ADDR_A0, 0, 0, 0, + i2c->offset, i2c->len, data); + + return rc; +} + /* * Support functions */ @@ -2891,6 +2949,7 @@ bnxt_probe_phy(struct bnxt_softc *softc) return (rc); } + bnxt_get_port_module_status(softc); /*initialize the ethool setting copy with NVM settings */ if (link_info->auto_mode != HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_MODE_NONE) link_info->autoneg |= BNXT_AUTONEG_SPEED;