From nobody Thu Apr 2 15:36:24 2026 Received: from mail-oo1-f98.google.com (mail-oo1-f98.google.com [209.85.161.98]) (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 D00933BED35 for ; Fri, 27 Mar 2026 20:15:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.98 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774642503; cv=none; b=smDW+e+NZKIV76mHQIDc8XERPg7qdk3NMDlTkxpkcET726zxvWOgkvIytsoOwhfW2N98WQt8fmxj67hPgaJmeYWPS86Oa2LyL89+F1LM/yyMuM6dLD8Op305NoOU2ApCshCyjI5EST1ly3qp9NGJPFEdgLOlfWxATMOgoegauPQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774642503; c=relaxed/simple; bh=82tDLYlRCFC3hucyMD7nomnm2kmivYBGq+C4YtlHKQ4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fSn58l0fOiDSo4B4j6UJ2+37ogbWASfjmvQksyjjqQvsP90tyU30QJCmKZc7+UjlIHEoz5AbG9WunwunYsZfs3g0x/2iE7tm5q4VhPVZx3+6bu21UgzrGckEEbSdWKnOce6rFavYovi5QHaQZXHK4Jx5VwMN9EO31YYAovzDWhU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject 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=FzaWMYac; arc=none smtp.client-ip=209.85.161.98 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject 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="FzaWMYac" Received: by mail-oo1-f98.google.com with SMTP id 006d021491bc7-67bac077116so1252408eaf.1 for ; Fri, 27 Mar 2026 13:15:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774642500; x=1775247300; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZjQ2eTe6U8E1f5bQ/2sJCU+psvAOj+STAWH7HfsJQow=; b=Crar8rCmFDdVws7QSFSdMf3orwSZdsP7yyloHHErlwjVrvJmrR+pExaIAYJw1ZFMls 20xX3/abT2V81mRr3pguI3pWppMgu84OI1kkAiwhRV6yjtxgR6JIdBlWWLecwCBX/Ib1 URPxcXBAW7FcfTIj9butjFyUS90YCnspjGOUOkuiQmmgMZqYJDolRDJdN4VoPT/+u6DF cmthYLexqKO0AM+NvmjwTT6z5pgmg9ZcVETGg85u1UN0zf8CEcoV8DW8mtzyxutrmtnb wYlB5hmld9t++OTAG95LmlPG6a1uVh+FXMuJ33wQxMpYp+yQbIPn/k9ARSNr+nGIIxCm W9Gw== X-Forwarded-Encrypted: i=1; AJvYcCU5ZUrOx5ky33D5zHXZJBKAD/uULVl6Znzr7AgyQuQudIZHWzwf0tcLYnq0j3k2dXsaHQ5NpincsaIiGLI=@vger.kernel.org X-Gm-Message-State: AOJu0YxC5gWWnAE+dEfZleZQB5i7og2AhReH+3qGSv9obvX/PUa5F+uP uc8MCV8uZZH20rguDPDbzjKak1sPyUlDbJbzxOBQTNVKb9SKaY7OybfItX0Bk+ypFlnSwFhFUAc gB4O0CdSXbzcWbwfhgttb+9qesobFEDZg7fG00JCGtbpP5MKBnb6JsMohuTqiSRHRXDhAmCzRbY yQzxs6Pxi08Iu/5EdshA5uWrbc7hECPIOdx+W94SaGaMgaLR25Cl0NdDgnKc1IqzcvCikrgiF/6 qnHOgbbffBRQtH2WdWkYsvLQ3/U X-Gm-Gg: ATEYQzwKb4qrU87zKIySRntUmseETVfdxvw/mSKcy1P852Xru8TO0n9oe5hGrK7s188 905og35a7xC8JjbMKRgzmiTb0DJszIa07Ymy3L1XeslZXuDbCjvVoJZoZQGiONEeJw6dN8faZlT 9y4CNS5uMvTctXtCzmUxNX8QZU8q4lVgjL7wrTQFeRVeZSK6Dt7v/RkApkh59rMSuJXDh3wxevS y9AARcoIAOuviGlVINnepif/T2ayieGNuITFhKRDPOj7vFWp3dDh8gnMbKqRzKqm/ozk5Ydn40b v2zj4W7rQUYPAw0nOa/1NZqQenvnkbZzOE6NL849JBUAVfe0DmUG2tMFnLQlhrADMrLgBcpDhHm tFnjmlXVs1bh8OPOeuS47ittRiTLu756oJrDlcMbsE3QlevrsTMvcUVC76jyMCKI1iqhn4WaP1f NwaQqLtEhpt7w= X-Received: by 2002:a05:6820:1ca1:b0:67d:f645:559 with SMTP id 006d021491bc7-67e187470a3mr2228541eaf.53.1774642500529; Fri, 27 Mar 2026 13:15:00 -0700 (PDT) Received: from smtp-us-east1-p01-i01-si01.dlp.protect.broadcom.com ([144.49.247.127]) by smtp-relay.gmail.com with ESMTPS id 006d021491bc7-67e22d6bcf9sm37507eaf.0.2026.03.27.13.15.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Mar 2026 13:15:00 -0700 (PDT) X-Relaying-Domain: broadcom.com X-CFilter-Loop: Reflected Received: by mail-yw1-f197.google.com with SMTP id 00721157ae682-798656130b0so56160807b3.1 for ; Fri, 27 Mar 2026 13:15:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1774642499; x=1775247299; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZjQ2eTe6U8E1f5bQ/2sJCU+psvAOj+STAWH7HfsJQow=; b=FzaWMYac+vSm4sZBcxRfz1JUJ6SU4+eMxZtW7dabTY7clRo8PIfABd6QejuolVCadd YDhbudrvy/mXaY+oxrO9QVhHUT9O6M9Mph9w+PeTZin/Q5jLf+6nrs4e+KVotOTTLnOw rsUVXpy/r9GAbli1a4rLjU8RGViGd4P6q8noU= X-Forwarded-Encrypted: i=1; AJvYcCVVk+A34MnQ5+1QDcXWi4qk7m0aiHUehDakhsC5CpDcAWj8qMh0X2EEb+YusIe1/bk4d7MPcWjxxWtJNZA=@vger.kernel.org X-Received: by 2002:a05:690c:e092:b0:79b:d56a:a7c2 with SMTP id 00721157ae682-79bde06b035mr41167067b3.48.1774642499578; Fri, 27 Mar 2026 13:14:59 -0700 (PDT) X-Received: by 2002:a05:690c:e092:b0:79b:d56a:a7c2 with SMTP id 00721157ae682-79bde06b035mr41166627b3.48.1774642499129; Fri, 27 Mar 2026 13:14:59 -0700 (PDT) Received: from localhost.localdomain ([192.19.203.250]) by smtp.gmail.com with ESMTPSA id 00721157ae682-79cb9a8f324sm119057b3.28.2026.03.27.13.14.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Mar 2026 13:14:58 -0700 (PDT) From: Bhargava Marreddy To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, michael.chan@broadcom.com, pavan.chebbi@broadcom.com, vsrama-krishna.nemani@broadcom.com, vikas.gupta@broadcom.com, Bhargava Marreddy Subject: [PATCH net-next v10 04/10] bng_en: implement ethtool pauseparam operations Date: Sat, 28 Mar 2026 01:43:37 +0530 Message-ID: <20260327201343.16146-5-bhargava.marreddy@broadcom.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260327201343.16146-1-bhargava.marreddy@broadcom.com> References: <20260327201343.16146-1-bhargava.marreddy@broadcom.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-DetectorID-Processed: b00c1d49-9d2e-4205-b15f-d015386d3d5e Content-Type: text/plain; charset="utf-8" Implement .get_pauseparam and .set_pauseparam to support flow control configuration. This allows reporting and setting of autoneg, RX pause, and TX pause states. Signed-off-by: Bhargava Marreddy Reviewed-by: Vikas Gupta --- .../net/ethernet/broadcom/bnge/bnge_ethtool.c | 63 +++++++++++++++++++ .../ethernet/broadcom/bnge/bnge_hwrm_lib.c | 6 +- .../net/ethernet/broadcom/bnge/bnge_link.c | 45 +++++++++---- 3 files changed, 100 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c b/drivers/ne= t/ethernet/broadcom/bnge/bnge_ethtool.c index 6bb74a84ea03..424bf2d6721c 100644 --- a/drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c @@ -46,6 +46,67 @@ static void bnge_get_drvinfo(struct net_device *dev, strscpy(info->bus_info, pci_name(bd->pdev), sizeof(info->bus_info)); } =20 +static void bnge_get_pauseparam(struct net_device *dev, + struct ethtool_pauseparam *epause) +{ + struct bnge_net *bn =3D netdev_priv(dev); + struct bnge_dev *bd =3D bn->bd; + + if (bd->phy_flags & BNGE_PHY_FL_NO_PAUSE) { + epause->autoneg =3D 0; + epause->rx_pause =3D 0; + epause->tx_pause =3D 0; + return; + } + + epause->autoneg =3D !!(bn->eth_link_info.autoneg & + BNGE_AUTONEG_FLOW_CTRL); + epause->rx_pause =3D !!(bn->eth_link_info.req_flow_ctrl & + BNGE_LINK_PAUSE_RX); + epause->tx_pause =3D !!(bn->eth_link_info.req_flow_ctrl & + BNGE_LINK_PAUSE_TX); +} + +static int bnge_set_pauseparam(struct net_device *dev, + struct ethtool_pauseparam *epause) +{ + struct bnge_ethtool_link_info old_elink_info, *elink_info; + struct bnge_net *bn =3D netdev_priv(dev); + struct bnge_dev *bd =3D bn->bd; + int rc =3D 0; + + if (!BNGE_PHY_CFG_ABLE(bd) || (bd->phy_flags & BNGE_PHY_FL_NO_PAUSE)) + return -EOPNOTSUPP; + + elink_info =3D &bn->eth_link_info; + old_elink_info =3D *elink_info; + + if (epause->autoneg) { + if (!(elink_info->autoneg & BNGE_AUTONEG_SPEED)) + return -EINVAL; + + elink_info->autoneg |=3D BNGE_AUTONEG_FLOW_CTRL; + } else { + if (elink_info->autoneg & BNGE_AUTONEG_FLOW_CTRL) + elink_info->force_link_chng =3D true; + elink_info->autoneg &=3D ~BNGE_AUTONEG_FLOW_CTRL; + } + + elink_info->req_flow_ctrl =3D 0; + if (epause->rx_pause) + elink_info->req_flow_ctrl |=3D BNGE_LINK_PAUSE_RX; + if (epause->tx_pause) + elink_info->req_flow_ctrl |=3D BNGE_LINK_PAUSE_TX; + + if (netif_running(dev)) { + rc =3D bnge_hwrm_set_pause(bn); + if (rc) + *elink_info =3D old_elink_info; + } + + return rc; +} + static const struct ethtool_ops bnge_ethtool_ops =3D { .cap_link_lanes_supported =3D 1, .get_link_ksettings =3D bnge_get_link_ksettings, @@ -53,6 +114,8 @@ static const struct ethtool_ops bnge_ethtool_ops =3D { .get_drvinfo =3D bnge_get_drvinfo, .get_link =3D bnge_get_link, .nway_reset =3D bnge_nway_reset, + .get_pauseparam =3D bnge_get_pauseparam, + .set_pauseparam =3D bnge_set_pauseparam, }; =20 void bnge_set_ethtool_ops(struct net_device *dev) diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.c b/drivers/n= et/ethernet/broadcom/bnge/bnge_hwrm_lib.c index 1cc62883d3c7..42fa08103df5 100644 --- a/drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.c +++ b/drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.c @@ -1054,7 +1054,11 @@ int bnge_hwrm_set_link_setting(struct bnge_net *bn, = bool set_pause) =20 bnge_hwrm_set_link_common(bn, req); =20 - return bnge_hwrm_req_send(bd, req); + rc =3D bnge_hwrm_req_send(bd, req); + if (!rc) + bn->eth_link_info.force_link_chng =3D false; + + return rc; } =20 int bnge_update_link(struct bnge_net *bn, bool chng_link_state) diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_link.c b/drivers/net/e= thernet/broadcom/bnge/bnge_link.c index af2f4466a199..aef06c13f335 100644 --- a/drivers/net/ethernet/broadcom/bnge/bnge_link.c +++ b/drivers/net/ethernet/broadcom/bnge/bnge_link.c @@ -302,6 +302,8 @@ int bnge_update_phy_setting(struct bnge_net *bn) struct bnge_dev *bd =3D bn->bd; bool update_pause =3D false; bool update_link =3D false; + bool hw_pause_autoneg; + bool pause_autoneg; int rc; =20 link_info =3D &bd->link_info; @@ -313,24 +315,41 @@ int bnge_update_phy_setting(struct bnge_net *bn) return rc; } =20 - if ((elink_info->autoneg & BNGE_AUTONEG_FLOW_CTRL) && - (link_info->auto_pause_setting & BNGE_LINK_PAUSE_BOTH) !=3D - elink_info->req_flow_ctrl) + pause_autoneg =3D !!(elink_info->autoneg & BNGE_AUTONEG_FLOW_CTRL); + hw_pause_autoneg =3D !!(link_info->auto_pause_setting & + PORT_PHY_CFG_REQ_AUTO_PAUSE_AUTONEG_PAUSE); + + /* Check if pause autonegotiation state has changed */ + if (pause_autoneg !=3D hw_pause_autoneg) { update_pause =3D true; - if (!(elink_info->autoneg & BNGE_AUTONEG_FLOW_CTRL) && - link_info->force_pause_setting !=3D elink_info->req_flow_ctrl) + } else if (pause_autoneg) { + /* If pause autoneg is enabled, check if the + * requested RX/TX bits changed + */ + if ((link_info->auto_pause_setting & BNGE_LINK_PAUSE_BOTH) !=3D + elink_info->req_flow_ctrl) + update_pause =3D true; + } else { + /* If pause autoneg is disabled, check if the + * forced RX/TX bits changed + */ + if (link_info->force_pause_setting !=3D elink_info->req_flow_ctrl) + update_pause =3D true; + } + + /* Force update if link change is requested */ + if (elink_info->force_link_chng) update_pause =3D true; + + /* Check if link speed or duplex settings have changed */ if (!(elink_info->autoneg & BNGE_AUTONEG_SPEED)) { - if (BNGE_AUTO_MODE(link_info->auto_mode)) - update_link =3D true; - if (bnge_force_speed_updated(bn)) - update_link =3D true; - if (elink_info->req_duplex !=3D link_info->duplex_setting) + if (BNGE_AUTO_MODE(link_info->auto_mode) || + bnge_force_speed_updated(bn) || + elink_info->req_duplex !=3D link_info->duplex_setting) update_link =3D true; } else { - if (link_info->auto_mode =3D=3D BNGE_LINK_AUTO_NONE) - update_link =3D true; - if (bnge_auto_speed_updated(bn)) + if (link_info->auto_mode =3D=3D BNGE_LINK_AUTO_NONE || + bnge_auto_speed_updated(bn)) update_link =3D true; } =20 --=20 2.47.3