From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.11 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795212056; b=eX7H7h7v3IhWa6A2pK/Wm60zSiKGBty0Zz9n5K0PA/erjYaNUXzPWjX82VfbV1kQOdC1 0BAVET0s5sEF1N3c+rdYV7+uDinwf08MS1VqTKKyG1MCHulFl8SrK+1abFqWnGBKDP1eE RWEBNDrePlDs3rFJFRSLbJdLOieC6hSod4Okv00UQFiNm3Rg9Sdnvn6MfV63SNF3DYqBI 1g0F1UvNGZnxPDOuNcMMu8uPDl50/e95UfqM9AAUnMgTWBsBgW21dfG61pNaJ8lWTuP6E x49ZiyYYpEweEWzk6ffVxu9U4CpHDfjLpJlJvc9ay7ewm87UKSS2aj+ck3KdU4ihYzw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795212056; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=Uvq4uKGHzSQ3buzUB1HJ/Thk9Bfbl0KP8JSvhHAXY7g=; b=PRsZxgQkkUB6XhQlDzOQfDH/fnnMerfcAAYwh6KsoRE1aCUOfoH1zKVOcYyf5NGvLUNu +Ky6UKt/Vzh4IpUO2LjnJLaRQjkOMQt80PIU57cAAFcpYk4Ar6YrIqa7BtdLaghuetPui G0RyjAfqubmkt9FZXMyIw7QTRQh1YC8wmpHfnORD8Jdg608AEX4BjHQD3ftt/usBZyOCg 2XUkurj1ku9l3m6++XblhvnwHT5MYf5jWJmw+BK5ZsmIqn+d21wr/k4mayZSEzOG8HEOI mOmOIeK2YRMjQZGNmR/Q6tbwQ9Z71ASKIt9OWecYQMpJmoDcHaEfHwsC6kc0U5jRjew== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=DuOi8gJn; arc=none smtp.remote-ip=198.175.65.11 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4BD260A2600 for ; Fri, 20 Nov 2026 22:00:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B4BD260A2600 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=DuOi8gJn DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1795212050; x=1826748050; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xU3qRvXwmJviQ3d/raL80mVMxXG5DB3mEuXWEZhVQiE=; b=DuOi8gJnvYztMNG9ChTJ8byjA+qZmPPoKQDGHodBBMxP74SXFbhOD3/C lsQYjAutj+BXzjT9PkelY9KqvYGCJLf9ZH0fUQK+Q/Sd5WISp5TVA4PRY qiaKkmQ0qM85z8+AAMZV3lHTxixDynQ68qUMIu/ghB+s1xo0g/FaysJGL scMJv9Vdu8LOgnVLBi14Xn3NIM4UnnlYQkmH4TiVaFz1pmTDvQt9c+QbE 4hDRSxg4GGMKUkrz9x+9z1rleXeJyzQXZydfi/hneOl2e+nv1/KIi3rQl 27YaSE5ZEBdL8xPnUpvdyT8e+8E9e8CsNr79e5DZODhE1S6A2JOAWOuis w==; X-CSE-ConnectionGUID: XWYKDjRAR8asyeiT+dcygg== X-CSE-MsgGUID: cKLNnMqHRkONa9rbuCkZzw== X-IronPort-AV: E=McAfee;i="6800,10657,11972"; a="3995048" X-IronPort-AV: E=Sophos;i="6.27,223,1787036400"; d="scan'208";a="3995048" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2026 14:00:37 -0800 X-CSE-ConnectionGUID: f8buBfcoQgOCaTEcDbglwA== X-CSE-MsgGUID: N1A90iK/QBqkwr1NxX68bw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,223,1787036400"; d="scan'208";a="10775824" Received: from anguy11-upstream.jf.intel.com ([10.166.9.133]) by fmviesa004.fm.intel.com with ESMTP; 20 Nov 2026 14:00:35 -0800 From: Tony Nguyen To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@kernel.org, andrew+netdev@lunn.ch, netdev@vger.kernel.org Cc: Tomasz Lichwala , anthony.l.nguyen@intel.com, ripatel@wii.dev, xiaolinkui@kylinos.cn, xiaolinkui@126.com, runyu.xiao@seu.edu.cn, horms@kernel.org, Marcin Szycik , Przemek Kitszel , Rafal Romanowski Subject: [PATCH net 3/4] ixgbevf: fix link speed reporting for Hyper-V E610 VFs Date: Fri, 20 Nov 2026 14:00:19 -0800 Message-ID: <20261120220022.3133664-4-anthony.l.nguyen@intel.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20261120220022.3133664-1-anthony.l.nguyen@intel.com> References: <20261120220022.3133664-1-anthony.l.nguyen@intel.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Tomasz Lichwala When an E610 VF is running under Hyper-V, the VFLINKS register does not carry valid link speed. The existing code reads speed from VFLINKS, which does not reflect the actual negotiated speed. This results in ethtool reporting a stale or incorrect link speed. The Hyper-V synthetic NIC exposes the actual link status through emulated PCI config space at offset 0x209 in VFLINKS register format. Read and decode link status from there when checking link on E610 VFs. To avoid generating unnecessary VMBus transactions on every watchdog cycle, read the PCI config register on demand when ethtool or sysfs queries link speed, rather than polling it periodically. The cached value is used by the watchdog and link state notifications as before. Guard the PCI config space read with IS_ENABLED(CONFIG_PCI_MMCONFIG), since accessing offsets above 256 requires MMCONFIG support. Fixes: 4c44b450c69b ("ixgbevf: Add support for Intel(R) E610 device") Reviewed-by: Marcin Szycik Signed-off-by: Tomasz Lichwala Reviewed-by: Przemek Kitszel Tested-by: Rafal Romanowski Signed-off-by: Tony Nguyen --- drivers/net/ethernet/intel/ixgbevf/ethtool.c | 12 ++++ drivers/net/ethernet/intel/ixgbevf/vf.c | 68 +++++++++++++++++--- 2 files changed, 72 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbevf/ethtool.c b/drivers/net/ethernet/intel/ixgbevf/ethtool.c index 537a60d5276f..5d0fb4f4d9a3 100644 --- a/drivers/net/ethernet/intel/ixgbevf/ethtool.c +++ b/drivers/net/ethernet/intel/ixgbevf/ethtool.c @@ -83,6 +83,18 @@ static int ixgbevf_get_link_ksettings(struct net_device *netdev, struct ethtool_link_ksettings *cmd) { struct ixgbevf_adapter *adapter = netdev_priv(netdev); + struct ixgbe_hw *hw = &adapter->hw; + + /* Hyper-V E610 VFs: read current link speed from PCI config space + * on every link speed query. + */ + if (adapter->pdev->subsystem_device == IXGBE_SUBDEV_ID_E610_VF_HV) { + spin_lock_bh(&adapter->mbx_lock); + hw->mac.get_link_status = true; + hw->mac.ops.check_link(hw, &adapter->link_speed, + &adapter->link_up, false); + spin_unlock_bh(&adapter->mbx_lock); + } ethtool_link_ksettings_zero_link_mode(cmd, supported); ethtool_link_ksettings_add_link_mode(cmd, supported, 10000baseT_Full); diff --git a/drivers/net/ethernet/intel/ixgbevf/vf.c b/drivers/net/ethernet/intel/ixgbevf/vf.c index f6df86d124b9..a84b62641e9b 100644 --- a/drivers/net/ethernet/intel/ixgbevf/vf.c +++ b/drivers/net/ethernet/intel/ixgbevf/vf.c @@ -1,14 +1,17 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright(c) 1999 - 2024 Intel Corporation. */ +#include + #include "vf.h" #include "ixgbevf.h" -/* On Hyper-V, to reset, we need to read from this offset - * from the PCI config space. This is the mechanism used on - * Hyper-V to support PF/VF communication. +/* On Hyper-V the PF/VF communication is through emulated PCI config + * space. The reset and link status are exposed at the offsets below. */ -#define IXGBE_HV_RESET_OFFSET 0x201 +#define IXGBE_HV_RESET_OFFSET 0x201 +#define IXGBE_HV_LINK_STATUS_OFFSET 0x209 +#define IXGBE_HV_LINK_STATUS_SIZE 4 static inline s32 ixgbevf_write_msg_read_ack(struct ixgbe_hw *hw, u32 *msg, u32 *retmsg, u16 size) @@ -901,6 +904,40 @@ static s32 ixgbevf_check_mac_link_vf(struct ixgbe_hw *hw, return ret_val; } +/** + * ixgbevf_hv_read_links_e610 - read link status from PCI config space + * @hw: pointer to hardware structure + * @links_reg: pointer to store read value + * + * On Hyper-V E610 VFs the VFLINKS register does not carry valid link speed. + * Instead, link status is exposed through emulated PCI config space at offset + * 0x209 in VFLINKS register format. + * + * Return: 0 on success, negative error code on failure. + */ +static s32 ixgbevf_hv_read_links_e610(struct ixgbe_hw *hw, u32 *links_reg) +{ + struct ixgbevf_adapter *adapter = hw->back; + u8 data[IXGBE_HV_LINK_STATUS_SIZE]; + + if (!IS_ENABLED(CONFIG_PCI_MMCONFIG)) { + dev_err_once(&adapter->pdev->dev, + "cannot read link status, PCI_MMCONFIG is required for Hyper-V\n"); + return -EOPNOTSUPP; + } + + for (int i = 0; i < IXGBE_HV_LINK_STATUS_SIZE; i++) { + int ret = pci_read_config_byte(adapter->pdev, + IXGBE_HV_LINK_STATUS_OFFSET + i, + &data[i]); + if (ret) + return pcibios_err_to_errno(ret); + } + + *links_reg = get_unaligned_le32(data); + return 0; +} + /** * ixgbevf_hv_check_mac_link_vf - check link * @hw: pointer to private hardware struct @@ -909,6 +946,7 @@ static s32 ixgbevf_check_mac_link_vf(struct ixgbe_hw *hw, * @autoneg_wait_to_complete: unused * * Hyper-V variant; there is no mailbox communication. + * For E610 VFs, link status is read from emulated PCI config space. */ static s32 ixgbevf_hv_check_mac_link_vf(struct ixgbe_hw *hw, ixgbe_link_speed *speed, @@ -926,8 +964,16 @@ static s32 ixgbevf_hv_check_mac_link_vf(struct ixgbe_hw *hw, if (!mac->get_link_status) goto out; - /* if link status is down no point in checking to see if pf is up */ - links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS); + if (mac->type == ixgbe_mac_e610_vf) { + if (ixgbevf_hv_read_links_e610(hw, &links_reg)) { + *link_up = false; + *speed = IXGBE_LINK_SPEED_UNKNOWN; + return 0; + } + } else { + links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS); + } + if (!(links_reg & IXGBE_LINKS_UP)) goto out; @@ -941,8 +987,11 @@ static s32 ixgbevf_hv_check_mac_link_vf(struct ixgbe_hw *hw, udelay(100); links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS); - if (!(links_reg & IXGBE_LINKS_UP)) - goto out; + if (!(links_reg & IXGBE_LINKS_UP)) { + *link_up = false; + *speed = IXGBE_LINK_SPEED_UNKNOWN; + return 0; + } } } @@ -956,6 +1005,9 @@ static s32 ixgbevf_hv_check_mac_link_vf(struct ixgbe_hw *hw, case IXGBE_LINKS_SPEED_100_82599: *speed = IXGBE_LINK_SPEED_100_FULL; break; + default: + *speed = IXGBE_LINK_SPEED_UNKNOWN; + break; } /* if we passed all the tests above then the link is up and we no -- 2.47.1