From patchwork Wed Jun 12 23:17:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13695647 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0157513210F for ; Wed, 12 Jun 2024 23:18:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718234282; cv=none; b=SivWJWM+WjlviLqXT07xrHjD7O2m8FW0NnNnare1lQn7AL+Gt1gHu1LgZsjN+oyJ7WmgLRicY4DIgHsIf++iOSZX6mP4jBmWhKwPY9oj0TIEzt9qEESXgT1/a/Q0FpYhroOJPmF7tRhxPHa+yUPN9WNwvH8ZDsF7/5Qi2vqmDu0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718234282; c=relaxed/simple; bh=PBlEoUgbj+wVo3PfpWLYRq8Sze+UxZjzGAik1yqNSys=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=MRb0cRsIraPkNccmMZYuza+qAQHR4lENH9k33FMlhl8htXAdLselAsQjFPjeEXV3OF617J7mAzemNfFfy4sgkSiWrq9LXp5saBnFyqQNypmcvU4YgaGEKw6h+1VUKhG1AgeB51iweFzkkbnz+P+Kvcrsejfv3+Z8S1OJos6Y5CI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=WdelUN2R; arc=none smtp.client-ip=209.85.210.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="WdelUN2R" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-70421e78edcso326152b3a.3 for ; Wed, 12 Jun 2024 16:18:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1718234280; x=1718839080; darn=vger.kernel.org; h=mime-version:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=nZDrRcHHjDFFf70JVqwvoZOLdTMU3sSZTvxA88qB9ig=; b=WdelUN2RXDhzm9Jw8wHSUl6+cSCDQqD1KPgoUTPWmhBOU2f2qMu8XprqDRFGrRZ41L ayegwgolA2Xqdowx9L4PkA9vKELLrhZVGF9AjHJtdd5k7gUcEMORfbszAQ4Xsm23uxyW G8aCsX3lESJsYnoYhYSjB5lwd+OmJUON6KLvI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718234280; x=1718839080; h=mime-version:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=nZDrRcHHjDFFf70JVqwvoZOLdTMU3sSZTvxA88qB9ig=; b=gPqNqM3YR11lpgrPyYi3sycCd1FxG1QrXuNRJHoBid6nUgM0UWGVNS8jwG1BkE16Y6 C+cX4mg6ndz6jddhgpBAEBYgWpe+jPjZtMkIzB7YAFUdO5+p2oP3D2wzMdiZPuordSsC GZHuDybas7mceCDz9FGV+MXG3BS7hZ7eiT8jSPfFlJU3QYXJxycCe7f9u2YbFUbPj2I9 o/KfdnnufTnibi/FWzCBr7A+cMFnb7h4FMRBELuKymPzbgZGkM68ADqf0l4JoDE+8NSh lqAEgkXMRyuuCED0hO5hNdLJ7HoGKcZgF+1Xhi1O/uXjcRAhbsH8hInISPdcYQEtTU1C kwnw== X-Gm-Message-State: AOJu0YwPbR+gyAkaYIRh2uVGjXCxzG95mGOzRqP/oFDWylpSHvDsDK3g H18iWq8ziJjvSdYFDFavHEMNE08ZvcLtkFmrGUbOd6yHZNXzI+d3/o9AxPnj1Q== X-Google-Smtp-Source: AGHT+IEgQ++4Okwq32UtHwEJ+xixTWLbKBLz9x6RKLDjFJ9gwDZQsNK8SQqNTTRVgjaj97vGtiD6xw== X-Received: by 2002:a05:6a00:1704:b0:705:9abf:a41d with SMTP id d2e1a72fcca58-705bce0a2cbmr4076452b3a.10.1718234279806; Wed, 12 Jun 2024 16:17:59 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705ccb917f2sm94795b3a.189.2024.06.12.16.17.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Jun 2024 16:17:59 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew.gospodarek@broadcom.com, horms@kernel.org, przemyslaw.kitszel@intel.com, Somnath Kotur , Pavan Chebbi Subject: [PATCH net v3] bnxt_en: Cap the size of HWRM_PORT_PHY_QCFG forwarded response Date: Wed, 12 Jun 2024 16:17:36 -0700 Message-ID: <20240612231736.57823-1-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Firmware interface 1.10.2.118 has increased the size of HWRM_PORT_PHY_QCFG response beyond the maximum size that can be forwarded. When the VF's link state is not the default auto state, the PF will need to forward the response back to the VF to indicate the forced state. This regression may cause the VF to fail to initialize. Fix it by capping the HWRM_PORT_PHY_QCFG response to the maximum 96 bytes. The SPEEDS2_SUPPORTED flag needs to be cleared because the new speeds2 fields are beyond the legacy structure. Also modify bnxt_hwrm_fwd_resp() to print a warning if the message size exceeds 96 bytes to make this failure more obvious. Fixes: 84a911db8305 ("bnxt_en: Update firmware interface to 1.10.2.118") Reviewed-by: Somnath Kotur Reviewed-by: Pavan Chebbi Signed-off-by: Michael Chan --- v3: Add comment that the last byte of the compat struct is different from the original struct. Use {} to zero the struct instead of {0}. v2: Remove Bug and ChangeID from ChangeLog Add comment to explain the clearing of the SPEEDS2_SUPPORTED flag drivers/net/ethernet/broadcom/bnxt/bnxt.h | 51 +++++++++++++++++++ .../net/ethernet/broadcom/bnxt/bnxt_sriov.c | 12 ++++- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 656ab81c0272..bbc7edccd5a4 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1434,6 +1434,57 @@ struct bnxt_l2_filter { atomic_t refcnt; }; +/* Compat version of hwrm_port_phy_qcfg_output capped at 96 bytes. The + * first 95 bytes are identical to hwrm_port_phy_qcfg_output in bnxt_hsi.h. + * The last valid byte in the compat version is different. + */ +struct hwrm_port_phy_qcfg_output_compat { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + u8 link; + u8 active_fec_signal_mode; + __le16 link_speed; + u8 duplex_cfg; + u8 pause; + __le16 support_speeds; + __le16 force_link_speed; + u8 auto_mode; + u8 auto_pause; + __le16 auto_link_speed; + __le16 auto_link_speed_mask; + u8 wirespeed; + u8 lpbk; + u8 force_pause; + u8 module_status; + __le32 preemphasis; + u8 phy_maj; + u8 phy_min; + u8 phy_bld; + u8 phy_type; + u8 media_type; + u8 xcvr_pkg_type; + u8 eee_config_phy_addr; + u8 parallel_detect; + __le16 link_partner_adv_speeds; + u8 link_partner_adv_auto_mode; + u8 link_partner_adv_pause; + __le16 adv_eee_link_speed_mask; + __le16 link_partner_adv_eee_link_speed_mask; + __le32 xcvr_identifier_type_tx_lpi_timer; + __le16 fec_cfg; + u8 duplex_state; + u8 option_flags; + char phy_vendor_name[16]; + char phy_vendor_partnumber[16]; + __le16 support_pam4_speeds; + __le16 force_pam4_link_speed; + __le16 auto_pam4_link_speed_mask; + u8 link_partner_pam4_adv_speeds; + u8 valid; +}; + struct bnxt_link_info { u8 phy_type; u8 media_type; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c index 175192ebaa77..22898d3d088b 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c @@ -950,8 +950,11 @@ static int bnxt_hwrm_fwd_resp(struct bnxt *bp, struct bnxt_vf_info *vf, struct hwrm_fwd_resp_input *req; int rc; - if (BNXT_FWD_RESP_SIZE_ERR(msg_size)) + if (BNXT_FWD_RESP_SIZE_ERR(msg_size)) { + netdev_warn_once(bp->dev, "HWRM fwd response too big (%d bytes)\n", + msg_size); return -EINVAL; + } rc = hwrm_req_init(bp, req, HWRM_FWD_RESP); if (!rc) { @@ -1085,7 +1088,7 @@ static int bnxt_vf_set_link(struct bnxt *bp, struct bnxt_vf_info *vf) rc = bnxt_hwrm_exec_fwd_resp( bp, vf, sizeof(struct hwrm_port_phy_qcfg_input)); } else { - struct hwrm_port_phy_qcfg_output phy_qcfg_resp = {0}; + struct hwrm_port_phy_qcfg_output_compat phy_qcfg_resp = {}; struct hwrm_port_phy_qcfg_input *phy_qcfg_req; phy_qcfg_req = @@ -1096,6 +1099,11 @@ static int bnxt_vf_set_link(struct bnxt *bp, struct bnxt_vf_info *vf) mutex_unlock(&bp->link_lock); phy_qcfg_resp.resp_len = cpu_to_le16(sizeof(phy_qcfg_resp)); phy_qcfg_resp.seq_id = phy_qcfg_req->seq_id; + /* New SPEEDS2 fields are beyond the legacy structure, so + * clear the SPEEDS2_SUPPORTED flag. + */ + phy_qcfg_resp.option_flags &= + ~PORT_PHY_QCAPS_RESP_FLAGS2_SPEEDS2_SUPPORTED; phy_qcfg_resp.valid = 1; if (vf->flags & BNXT_VF_LINK_UP) {