From patchwork Wed Jan 26 04:40:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 12724584 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 6D73BC2BA4C for ; Wed, 26 Jan 2022 04:40:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233238AbiAZEkp (ORCPT ); Tue, 25 Jan 2022 23:40:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231732AbiAZEkj (ORCPT ); Tue, 25 Jan 2022 23:40:39 -0500 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFD5EC061744 for ; Tue, 25 Jan 2022 20:40:39 -0800 (PST) Received: by mail-pl1-x635.google.com with SMTP id u11so21341751plh.13 for ; Tue, 25 Jan 2022 20:40:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=455jHzpZKl+i99QBAMM/nIa+UODXenNPvKvUf3S1ZoA=; b=QqdY3UdV66zX/5R0GpMBiT2ySITYNL+ZY/NOM6y5Vd53cdQYZ486VEoHJAdYIR9p11 WAybCx6F3OySJ6nA1p/yW/5xpSpGlcNWFxQMKl9c17MNbR25s7HDdXVPDOxvMWhka14l 6wBFkyvSorPYfuLDgCwPV/Tq/vAsCjR+JGma8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=455jHzpZKl+i99QBAMM/nIa+UODXenNPvKvUf3S1ZoA=; b=73IR/c4KwDFZ9rphRUb3v37YsicsEEZEfpEcpf0cWI8X/nzKo8pQG3+dIL/Di4+AIk DttLo79JA/umqhyWguCdaQTnTVk9RAtYpSI4A/WO8Xir0gHkfJFGgINiEOPjX/l0dp9u 3TWZnoEnVKmSKOVXafRZMVj3S41RIhS/87s/PABy/9l/7LVcMtK75TPmYmyNaSl0zwhO pMuembyHSXVJ+dR2DlxN9rXOr3Sb+5tDGKnwjcgySsgDFNTw/vztAgumgJFIjDcJQBOB jmzzCtxcIZv5nWhSpLeU5BXg0+Y+3moHRYmyN1ktzIv1iihsBAWV0IAe04fEjAmlIAY+ 9ZmQ== X-Gm-Message-State: AOAM530hRXAwpTbyfOJWzXjMXmvmyxaTxevtkQy52gfBFeBxk3L+fInp 8qAASTN+N+L7jAY86ABBdY2Sng== X-Google-Smtp-Source: ABdhPJxcme0n0VkCVTMosb9vQMtoneqP0tbpT7CsRsETfO3WxjssrczBUXPq2eKA8uFuOlPOqlwN1Q== X-Received: by 2002:a17:90a:14a4:: with SMTP id k33mr6907376pja.21.1643172038987; Tue, 25 Jan 2022 20:40:38 -0800 (PST) Received: from localhost.swdvt.lab.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id s12sm559957pfk.65.2022.01.25.20.40.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Jan 2022 20:40:38 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, kuba@kernel.org, gospo@broadcom.com, pavan.chebbi@broadcom.com, Richard Cochran Subject: [PATCH net-next 5/5] bnxt_en: Handle async event when the PHC is updated in RTC mode Date: Tue, 25 Jan 2022 23:40:13 -0500 Message-Id: <1643172013-31729-6-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1643172013-31729-1-git-send-email-michael.chan@broadcom.com> References: <1643172013-31729-1-git-send-email-michael.chan@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Pavan Chebbi In Multi-host environment, when the PHC is updated by one host, an async message from firmware will be sent to other hosts. Re-initialize the timecounter when the driver receives this async message. Cc: Richard Cochran Reviewed-by: Somnath Kotur Signed-off-by: Pavan Chebbi Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 514798a4f15b..c313221348c5 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -233,6 +233,7 @@ static const u16 bnxt_async_events_arr[] = { ASYNC_EVENT_CMPL_EVENT_ID_ECHO_REQUEST, ASYNC_EVENT_CMPL_EVENT_ID_PPS_TIMESTAMP, ASYNC_EVENT_CMPL_EVENT_ID_ERROR_REPORT, + ASYNC_EVENT_CMPL_EVENT_ID_PHC_UPDATE, }; static struct workqueue_struct *bnxt_pf_wq; @@ -2079,6 +2080,16 @@ static void bnxt_event_error_report(struct bnxt *bp, u32 data1, u32 data2) (BNXT_EVENT_RING_TYPE(data2) == \ ASYNC_EVENT_CMPL_RING_MONITOR_MSG_EVENT_DATA2_DISABLE_RING_TYPE_RX) +#define BNXT_EVENT_PHC_EVENT_TYPE(data1) \ + (((data1) & ASYNC_EVENT_CMPL_PHC_UPDATE_EVENT_DATA1_FLAGS_MASK) >>\ + ASYNC_EVENT_CMPL_PHC_UPDATE_EVENT_DATA1_FLAGS_SFT) + +#define BNXT_EVENT_PHC_RTC_UPDATE(data1) \ + (((data1) & ASYNC_EVENT_CMPL_PHC_UPDATE_EVENT_DATA1_PHC_TIME_MSB_MASK) >>\ + ASYNC_EVENT_CMPL_PHC_UPDATE_EVENT_DATA1_PHC_TIME_MSB_SFT) + +#define BNXT_PHC_BITS 48 + static int bnxt_async_event_process(struct bnxt *bp, struct hwrm_async_event_cmpl *cmpl) { @@ -2258,6 +2269,24 @@ static int bnxt_async_event_process(struct bnxt *bp, bnxt_event_error_report(bp, data1, data2); goto async_event_process_exit; } + case ASYNC_EVENT_CMPL_EVENT_ID_PHC_UPDATE: { + switch (BNXT_EVENT_PHC_EVENT_TYPE(data1)) { + case ASYNC_EVENT_CMPL_PHC_UPDATE_EVENT_DATA1_FLAGS_PHC_RTC_UPDATE: + if (bp->fw_cap & BNXT_FW_CAP_PTP_RTC) { + struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; + u64 ns; + + spin_lock_bh(&ptp->ptp_lock); + bnxt_ptp_update_current_time(bp); + ns = (((u64)BNXT_EVENT_PHC_RTC_UPDATE(data1) << + BNXT_PHC_BITS) | ptp->current_time); + bnxt_ptp_rtc_timecounter_init(ptp, ns); + spin_unlock_bh(&ptp->ptp_lock); + } + break; + } + goto async_event_process_exit; + } case ASYNC_EVENT_CMPL_EVENT_ID_DEFERRED_RESPONSE: { u16 seq_id = le32_to_cpu(cmpl->event_data2) & 0xffff;