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")
Signed-off-by: Rafael Castillo <[email protected]>
---
 drivers/net/ethernet/intel/idpf/idpf_lib.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/idpf/idpf_lib.c 
b/drivers/net/ethernet/intel/idpf/idpf_lib.c
index 523c0e0be884..bfe08f5f74a7 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_lib.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_lib.c
@@ -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;
        }
-- 
2.56.0.611.g1030f0b940-goog

Reply via email to