From patchwork Tue Jan 17 18:15:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vacek X-Patchwork-Id: 13104995 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAB79C54E76 for ; Tue, 17 Jan 2023 18:53:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232850AbjAQSwq (ORCPT ); Tue, 17 Jan 2023 13:52:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235095AbjAQSui (ORCPT ); Tue, 17 Jan 2023 13:50:38 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D0BE4DCE6 for ; Tue, 17 Jan 2023 10:15:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673979344; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=hoHrYOZi5AepvexSScpofKM1v72zsm9+pebsH147dPw=; b=Oxm62b27s2ebInlCCBVDbfewUCqt/zRfsCX+ExGRacD+7skBlWKhzNiKbvlqGQMo/GJbJv eeOe88RyXxXQ/NiBRh0xVb34Lpn6zfFZRehBJ8vxGCOZsd1zECkhmm6mwHTNk4Ln995cfV ubGNImnzCp7Ll/aBXDRBbq7dKe29QWI= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-498-E6arC8fUMxqGHhfEb1Ibsg-1; Tue, 17 Jan 2023 13:15:40 -0500 X-MC-Unique: E6arC8fUMxqGHhfEb1Ibsg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 267BC3C0F42F; Tue, 17 Jan 2023 18:15:40 +0000 (UTC) Received: from metal.redhat.com (ovpn-192-69.brq.redhat.com [10.40.192.69]) by smtp.corp.redhat.com (Postfix) with ESMTP id A90931415108; Tue, 17 Jan 2023 18:15:37 +0000 (UTC) From: Daniel Vacek To: Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran Cc: Daniel Vacek , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ice/ptp: fix the PTP worker retrying indefinitely if the link went down Date: Tue, 17 Jan 2023 19:15:32 +0100 Message-Id: <20230117181533.2350335-1-neelx@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org When the link goes down the ice_ptp_tx_tstamp_work() may loop forever trying to process the packets. In this case it makes sense to just drop them. Signed-off-by: Daniel Vacek --- drivers/net/ethernet/intel/ice/ice_ptp.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c index d63161d73eb16..c313177ba6676 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -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,6 +696,8 @@ static bool ice_ptp_tx_tstamp(struct ice_ptp_tx *tx) if (err) return false; + link_up = hw->port_info->phy.link_info.link_info & ICE_AQ_LINK_UP; + for_each_set_bit(idx, tx->in_use, tx->len) { struct skb_shared_hwtstamps shhwtstamps = {}; u8 phy_idx = idx + tx->offset; @@ -702,6 +705,12 @@ static bool ice_ptp_tx_tstamp(struct ice_ptp_tx *tx) bool drop_ts = false; struct sk_buff *skb; + /* Drop packets if the link went down */ + if (!link_up) { + drop_ts = true; + goto skip_ts_read; + } + /* Drop packets which have waited for more than 2 seconds */ if (time_is_before_jiffies(tx->tstamps[idx].start + 2 * HZ)) { drop_ts = true;