From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) (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 46C9A40800C; Thu, 9 Jul 2026 10:09:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=211.75.126.72 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783591746; cv=none; b=HUbu6qEJ8RIExgzocvORCJyr++VtqIMiTkWUJD7uCtE3XKIK76xBzHcFfoh3gm5AOgEkypYWEaonB6tsP46G+dmR0wHCWQIT1U3OOQ2H+uyAAyh3nBqUIa8IWxID82+7alFZoqx9RuBlf4nTThnvsEHU6m97JtmMJsB935JzmvQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783591746; c=relaxed/simple; bh=aLVJ65lHO1HLVS5zuPPKCLMQNKCWuDDrTCE/7TgBgns=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=K642nlHxZBYnP2iz1HcvVCwxII7m6s1im6MkpiOnzu6jEQoYqnF/LT39TBUJvBTSRwoYY/HT100GTwe2Wyi/+iM3lfaKVMSbEXZLfCagEpS8zAOYZYvts+YIN59N4Qs+41yh4MXWy9tiowUQlogwaOOw8ZMO66pnF7GbSQSQzro= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=realsil.com.cn; spf=pass smtp.mailfrom=realsil.com.cn; dkim=pass (2048-bit key) header.d=realsil.com.cn header.i=@realsil.com.cn header.b=dXfJgs0h; arc=none smtp.client-ip=211.75.126.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=realsil.com.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=realsil.com.cn Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=realsil.com.cn header.i=@realsil.com.cn header.b="dXfJgs0h" X-SpamFilter-By: ArmorX SpamTrap 5.80 with qID 669A2nGqA2982778, This message is accepted by code: ctloc85258 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=realsil.com.cn; s=dkim; t=1783591369; bh=zrTu82WAenAcirI3SMhiBMdq9KesCAU/lLNMpK8hMHU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding:Content-Type; b=dXfJgs0hwLpD1M3oe5EqmT8BnizjGCB3PomrNk0Qw466/b+76enPrFKkPp9ZfsAGt YO4YyFo8U1hzAcBhPb179tCtEzl1xU9tj9m84dqF4TE2Feh89TFUKgg2OQRLBYrgPa +MKdqNq1b/4c5t9uZOdxgPGxTK2GlTiZ3kUrls7DW6N6P0GTIIZGZQuxIfC6pRXYVj eje7EokHvC8dZnSAixloPftHWhPJF3mL1/BaLGbkE8/PCKax4Hjgm3+Y1GA08h5+Vr sYuazceTH5wrixVUxaPj7RkZqbgPF1AfDBk9vSafFF+k8hATrKbk75l82J8Edd8yOs U5OM58fz2dZcg== Received: from RS-EX-MBS2.realsil.com.cn ([172.29.17.102]) by rtits2.realtek.com.tw (8.15.2/3.29/5.94) with ESMTPS id 669A2nGqA2982778 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 9 Jul 2026 18:02:49 +0800 Received: from RS-EX-MBS2.realsil.com.cn (172.29.17.102) by RS-EX-MBS2.realsil.com.cn (172.29.17.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Thu, 9 Jul 2026 18:02:49 +0800 Received: from 172.29.37.154 (172.29.37.152) by RS-EX-MBS2.realsil.com.cn (172.29.17.102) with Microsoft SMTP Server id 15.2.2562.17 via Frontend Transport; Thu, 9 Jul 2026 18:02:49 +0800 From: javen To: , , , , , , , , CC: , , , , , , Javen Xu , Andrew Lunn Subject: [PATCH net-next v6 1/7] r8169: add speed in private struct Date: Thu, 9 Jul 2026 18:02:30 +0800 Message-ID: <20260709100237.541-2-javen_xu@realsil.com.cn> X-Mailer: git-send-email 2.50.1.windows.1 In-Reply-To: <20260709100237.541-1-javen_xu@realsil.com.cn> References: <20260709100237.541-1-javen_xu@realsil.com.cn> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain From: Javen Xu This patch adds speed in private struct in order to decouple from phydev in the following patch supporting for phylink. Reviewed-by: Andrew Lunn Signed-off-by: Javen Xu --- Changes in v2: - repalce current_speed with speed Changes in v3: - update tp->speed in rtl8169_set_link_ksettings() Changes in v4: - no changes Changes in v5: - no changes Changes in v6: - no changes --- drivers/net/ethernet/realtek/r8169_main.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index ec4fc21fa21f..c60710f9bd21 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -750,6 +750,7 @@ struct rtl8169_private { u32 irq_mask; int irq; struct clk *clk; + int speed; struct { DECLARE_BITMAP(flags, RTL_FLAG_MAX); @@ -1673,16 +1674,14 @@ static void rtl8169_irq_mask_and_ack(struct rtl8169_private *tp) rtl_pci_commit(tp); } -static void rtl_link_chg_patch(struct rtl8169_private *tp) +static void rtl_link_chg_patch(struct rtl8169_private *tp, int speed) { - struct phy_device *phydev = tp->phydev; - if (tp->mac_version == RTL_GIGA_MAC_VER_34 || tp->mac_version == RTL_GIGA_MAC_VER_38) { - if (phydev->speed == SPEED_1000) { + if (speed == SPEED_1000) { rtl_eri_write(tp, 0x1bc, ERIAR_MASK_1111, 0x00000011); rtl_eri_write(tp, 0x1dc, ERIAR_MASK_1111, 0x00000005); - } else if (phydev->speed == SPEED_100) { + } else if (speed == SPEED_100) { rtl_eri_write(tp, 0x1bc, ERIAR_MASK_1111, 0x0000001f); rtl_eri_write(tp, 0x1dc, ERIAR_MASK_1111, 0x00000005); } else { @@ -1692,7 +1691,7 @@ static void rtl_link_chg_patch(struct rtl8169_private *tp) rtl_reset_packet_filter(tp); } else if (tp->mac_version == RTL_GIGA_MAC_VER_35 || tp->mac_version == RTL_GIGA_MAC_VER_36) { - if (phydev->speed == SPEED_1000) { + if (speed == SPEED_1000) { rtl_eri_write(tp, 0x1bc, ERIAR_MASK_1111, 0x00000011); rtl_eri_write(tp, 0x1dc, ERIAR_MASK_1111, 0x00000005); } else { @@ -1700,7 +1699,7 @@ static void rtl_link_chg_patch(struct rtl8169_private *tp) rtl_eri_write(tp, 0x1dc, ERIAR_MASK_1111, 0x0000003f); } } else if (tp->mac_version == RTL_GIGA_MAC_VER_37) { - if (phydev->speed == SPEED_10) { + if (speed == SPEED_10) { rtl_eri_write(tp, 0x1d0, ERIAR_MASK_0011, 0x4d02); rtl_eri_write(tp, 0x1dc, ERIAR_MASK_0011, 0x0060a); } else { @@ -2074,11 +2073,11 @@ rtl_coalesce_info(struct rtl8169_private *tp) ci = rtl_coalesce_info_8168_8136; /* if speed is unknown assume highest one */ - if (tp->phydev->speed == SPEED_UNKNOWN) + if (tp->speed == SPEED_UNKNOWN) return ci; for (; ci->speed; ci++) { - if (tp->phydev->speed == ci->speed) + if (tp->speed == ci->speed) return ci; } @@ -2236,7 +2235,7 @@ static void rtl_set_eee_txidle_timer(struct rtl8169_private *tp) static unsigned int r8169_get_tx_lpi_timer_us(struct rtl8169_private *tp) { - unsigned int speed = tp->phydev->speed; + unsigned int speed = tp->speed; unsigned int timer = tp->tx_lpi_timer; if (!timer || speed == SPEED_UNKNOWN) @@ -4968,8 +4967,9 @@ static void r8169_phylink_handler(struct net_device *ndev) struct rtl8169_private *tp = netdev_priv(ndev); struct device *d = tp_to_dev(tp); + tp->speed = tp->phydev->speed; if (netif_carrier_ok(ndev)) { - rtl_link_chg_patch(tp); + rtl_link_chg_patch(tp, tp->speed); rtl_enable_tx_lpi(tp, tp->phydev->enable_tx_lpi); pm_request_resume(d); } else { @@ -5667,6 +5667,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ext_xid_str, xid); tp->mac_version = chip->mac_version; tp->fw_name = chip->fw_name; + tp->speed = SPEED_UNKNOWN; /* Disable ASPM L1 as that cause random device stop working * problems as well as full system hangs for some PCIe devices users. -- 2.43.0