ice/ptp: fix the PTP worker retrying indefinitely if the link went down
authorDaniel Vacek <neelx@redhat.com>
Thu, 19 Jan 2023 20:23:16 +0000 (21:23 +0100)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Tue, 14 Feb 2023 21:08:02 +0000 (13:08 -0800)
When the link goes down the ice_ptp_tx_tstamp() may loop re-trying to
process the packets till the 2 seconds timeout finally drops them.
In such a case it makes sense to just drop them right away.

Signed-off-by: Daniel Vacek <neelx@redhat.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Gurucharan G <gurucharanx.g@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/ice/ice_ptp.c

index 651dc385ff5d801e9a654bc9fcd84fe79ae345b1..ac6f06f9a2ed06149a1180db22d8a5c42d21dd29 100644 (file)
@@ -680,6 +680,7 @@ static bool ice_ptp_tx_tstamp(struct ice_ptp_tx *tx)
        struct ice_pf *pf;
        struct ice_hw *hw;
        u64 tstamp_ready;
+       bool link_up;
        int err;
        u8 idx;
 
@@ -695,11 +696,14 @@ static bool ice_ptp_tx_tstamp(struct ice_ptp_tx *tx)
        if (err)
                return false;
 
+       /* Drop packets if the link went down */
+       link_up = ptp_port->link_up;
+
        for_each_set_bit(idx, tx->in_use, tx->len) {
                struct skb_shared_hwtstamps shhwtstamps = {};
                u8 phy_idx = idx + tx->offset;
                u64 raw_tstamp = 0, tstamp;
-               bool drop_ts = false;
+               bool drop_ts = !link_up;
                struct sk_buff *skb;
 
                /* Drop packets which have waited for more than 2 seconds */
@@ -728,7 +732,7 @@ static bool ice_ptp_tx_tstamp(struct ice_ptp_tx *tx)
                ice_trace(tx_tstamp_fw_req, tx->tstamps[idx].skb, idx);
 
                err = ice_read_phy_tstamp(hw, tx->block, phy_idx, &raw_tstamp);
-               if (err)
+               if (err && !drop_ts)
                        continue;
 
                ice_trace(tx_tstamp_fw_done, tx->tstamps[idx].skb, idx);