From nobody Thu Mar 07 19:27:16 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 4TrK7T01K7z5DfWd; Thu, 7 Mar 2024 19:27:17 +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 4TrK7S4tw4z4b47; Thu, 7 Mar 2024 19:27:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709839636; 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=LO0zTDEY+St5eINhvpl31JG7Gt9Bsq2j+InNr8vBozo=; b=XUhUFYwkdAceN2X3WT2vO1VpO6r2VGnbCIbxsX7jmMwjVnUHgLDRh/Nn6FxXn5WCg9OCxV 7ymHZDj9DxWidgnTp/5mDpVUhFsgjer0gQK9VeL6uh/WxOdhHLlDn6X890NquWNF4Z+t6I PZF6u2d9qNFvRqveTN9OMO2fP5LHj3KFwsiKCC4fn7raGKTVcu/mQSNii2pNSNT+0ckiFT xUZ63r+6W1a6jhIRlQX1lZMyME6rC+MH6Akm14cR6JYzF+rLqDPY0E0i1XXIdn1knl9sNW hoEXSSVCjmKthuKtwnNBPW8pLYQA6yD0mwdQathTgKLK0tiI1VPp4D+UIdGPGg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1709839636; a=rsa-sha256; cv=none; b=w78qCaADUX2Xsy32ZbaV0qXOf1KCaqWKs6nd4zb9NdoJqyXA3qBIu56Q1R3la5VDqBWGyp rw5pqDwD3tjkuEgXAy9rnCmZLyAXGvCoifup0UYcCYq2nEQ8jU6zI/Ax4z7OpFbXxoT36H IsE8UHVcz/1FIX1SL8ELYXK/kzDKZf8kh+pJJOyMn2D3J7tbCpyYvfXWDw/2FQ9y01PlwQ BF4MZf0zn1kek26nDOpABz229vwkeum6diwfGfg+6z4waT0wkUBW7mnysN/UxBaCdAbcih 0dT0Kq1tB/3yjVipFGMtRMj3nugbC6/XPN10zUrOGSIh45o4EvoYwA+S+kF56w== 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=1709839636; 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=LO0zTDEY+St5eINhvpl31JG7Gt9Bsq2j+InNr8vBozo=; b=IYyHKUqvM0w0aZfvL2LQ/BR45dfCzrAVXZ5hI1bVwh/dvOL1N5TPBauypRRIjpgEs3TxiE Wa8puZ7nGEGjVSyOhkWQtmRR5ee3UaJttoRZOGck58DLJpanPzn9MCYNlUtJKc3KMwsIaa k9J+9U2kvbD+EG7QRoLKECvnm8ZiG5j/BfT0BhwEvVX2effl1YrFyWZA7yK801DUXIOEPg 2G2/FGRFze0szQpMHowH4QMiwg2qGKC4oCCKuNIZ0e0W9nZVobVKHqHJ6WHpm07fOUeYGN kQP8hukucWoosKux+FHxXkVYwFLjKf+C+vQ3prw1UlhCfNVE3A+tgyVOTKXDhQ== 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 4TrK7S4L0RznNh; Thu, 7 Mar 2024 19:27:16 +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 427JRGCN064408; Thu, 7 Mar 2024 19:27:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 427JRGFS064405; Thu, 7 Mar 2024 19:27:16 GMT (envelope-from git) Date: Thu, 7 Mar 2024 19:27:16 GMT Message-Id: <202403071927.427JRGFS064405@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Sumit Saxena Subject: git: 3320f0f69f06 - main - 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ssaxena X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3320f0f69f06df5c36daa8ff71e0c07908ff0f1a Auto-Submitted: auto-generated The branch main has been updated by ssaxena: URL: https://cgit.FreeBSD.org/src/commit/?id=3320f0f69f06df5c36daa8ff71e0c07908ff0f1a commit 3320f0f69f06df5c36daa8ff71e0c07908ff0f1a Author: Sumit Saxena AuthorDate: 2024-03-06 13:21:21 +0000 Commit: Sumit Saxena CommitDate: 2024-03-07 19:16:39 +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 --- 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 e4a14aa954f5..f82d32c3ff5b 100644 --- a/sys/dev/bnxt/if_bnxt.c +++ b/sys/dev/bnxt/if_bnxt.c @@ -224,6 +224,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 @@ -287,6 +289,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), @@ -1807,6 +1810,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) @@ -1969,6 +1999,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; @@ -2874,6 +2905,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 */ @@ -2890,6 +2948,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;