Skip to contentSkip to conversation

idpf: check vport state instead of link_up in hwtstamp get/set

PATCH New Rafael Castillo 1 participant 1 message Nov 16

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 idpf: check vport state instead of link_up in hwtstamp get/set

vport->link_up is cleared on vport stop and only restored asynchronously when the Control Plane delivers VIRTCHNL2_EVENT_LINK_CHANGE, causing SIOCSHWTSTAMP and SIOCGHWTSTAMP to fail with -EPERM right after open or soft reset or while physical link is down. Check test_bit(IDPF_VPORT_UP, np->state) instead so hardware timestamping can be queried and configured whenever the vport is administratively up.

Fixes 1a49cf814fe1 ("idpf: add Tx timestamp flows")
---
 drivers/net/ethernet/intel/idpf/idpf_lib.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_lib.c +4 -2
index 523c0e0be884..bfe08f5f74a7 100644
@@ -2598,13 +2598,14 @@ static int idpf_hwtstamp_set(struct net_device *netdev,
 			     struct kernel_hwtstamp_config *config,
 			     struct netlink_ext_ack *extack)
 {
+	struct idpf_netdev_priv *np = netdev_priv(netdev);
 	struct idpf_vport *vport;
 	int err;
 
 	idpf_vport_ctrl_lock(netdev);
 	vport = idpf_netdev_to_vport(netdev);
 
-	if (!vport->link_up) {
+	if (!test_bit(IDPF_VPORT_UP, np->state)) {
 		idpf_vport_ctrl_unlock(netdev);
 		return -EPERM;
 	}
@@ -2625,12 +2626,13 @@ static int idpf_hwtstamp_set(struct net_device *netdev,
 static int idpf_hwtstamp_get(struct net_device *netdev,
 			     struct kernel_hwtstamp_config *config)
 {
+	struct idpf_netdev_priv *np = netdev_priv(netdev);
 	struct idpf_vport *vport;
 
 	idpf_vport_ctrl_lock(netdev);
 	vport = idpf_netdev_to_vport(netdev);
 
-	if (!vport->link_up) {
+	if (!test_bit(IDPF_VPORT_UP, np->state)) {
 		idpf_vport_ctrl_unlock(netdev);
 		return -EPERM;
 	}
Signature · 1 line
2.56.0.611.g1030f0b940-goog