Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp615008rwb; Wed, 7 Dec 2022 02:53:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf6rizk7xvluK6p7ztCGKK29r6R6RQtrwZnfdCv/ahUvWQaBJw6CxeJlP9m7zDYFeqQjWVfx X-Received: by 2002:a17:90a:d157:b0:211:710e:7d03 with SMTP id t23-20020a17090ad15700b00211710e7d03mr91389529pjw.56.1670410427721; Wed, 07 Dec 2022 02:53:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670410427; cv=none; d=google.com; s=arc-20160816; b=cd5gjYVdeELHE9OBX7FE9SXMccmNvucv1QI4F2CVgSlxobeQaYrCYTOkKOG0CwFKmQ +x9qBoFS4+lwSUZHeVKF9xX0EAeRiheKDmEhcigYts3pDQi3gYZtkNjJRF/93cXl9YpD k+ndkoeP0H9HuhD5q6NaJIjSYbjNsS8kOxrkjOA0lOoZwuMiTch911YIv8OJJXQu1LBC Fk/XoF0d8BQKovM1o6ey1/BWEERkwH1iKaLBK/YpyHYNJmjZeOQvHHhy11iztlDgRGpn zrMbE+zfkYgGD7gHeRzMoBRnGvlRwZfP3bANW3mboCUlo0eDU0sJ0LpUM+T7mRSQCCEQ 0iWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/vdOUq/hueGf9q04U2z4nVzVdAzw30oN6SpxZVu/XGc=; b=Az1zajej1P/7Fdv6XvkT4oShkbFwrlbQhAke21WFH9wZ6o3eCYW+I6TuvudhdStbBX yUMizYuld/nqUgUdeKGcWgBGLuxRx8VFZvD0g2ZHjmc/4vTWKBP3sk657ufG4rLWuo0c JxTEcCcil6F8ZEeRufVioc1A30zdXmT+xIwDn4eolu7zZ/9R4K7rV1VQpXtFk8wUHqm9 dTjHJANZhKrmc+JtmdmT2y1eIpNrbLy586GB8uUSTwTbA1sHpRsWjNkOodL01TRr2BED 3kyABh3cRg68PDIslR/CLvHck3hc7ibf4tIFafvcbw5CgV/Zp4L89ntQ/hWuk9jejekw 2Qog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="UD/XNwZF"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lw14-20020a17090b180e00b002187b138f98si1222486pjb.165.2022.12.07.02.53.38; Wed, 07 Dec 2022 02:53:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="UD/XNwZF"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229652AbiLGKi3 (ORCPT + 76 others); Wed, 7 Dec 2022 05:38:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229783AbiLGKiN (ORCPT ); Wed, 7 Dec 2022 05:38:13 -0500 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4BE04667A; Wed, 7 Dec 2022 02:38:12 -0800 (PST) Received: by mail-ed1-x531.google.com with SMTP id i15so16092116edf.2; Wed, 07 Dec 2022 02:38:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=/vdOUq/hueGf9q04U2z4nVzVdAzw30oN6SpxZVu/XGc=; b=UD/XNwZFSHd5Nm0bGWgegEzUA2p7zIX4KEPlAZ5edg96CM5eayxHGUz+0AeXiIHsU5 fB3ybtWHYakn9OQGNON8DUC/yIbxekcNiiBT/Dd9mPGf+jOZvvxwq+X75yy9iXnEzBLO P0GnIr3etA0EddcMY1DMqHff3camCmf1mtih3EPNiilBr8n1HERTjk+mLgblpwlrDAF5 4aMj/EGakQKwuFvQSvmvXzEktO+cOI890Ig7Gv/Ddo2iC120Sfq2H7XGAsQ8ug7ZoGDS nwBipkeoYbDKbVQPR2tlB5oATI5P/2QnKD/uUtoVRC2geNOdbX4HvWNWjjAPgiv7iA9O jIkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/vdOUq/hueGf9q04U2z4nVzVdAzw30oN6SpxZVu/XGc=; b=Ae4c4vIBiq7NtQmH+z4jq4TQAvQVjkqFPGP9uZtBaUOQwrMdo4ay3J+3AlJ6XEkgjC iMXQNHMqD1TC3iePYhe3DKlIOxrp2wTL9HVSSnyLROQr+HwSyPMfKuFx+sanoVPWwvjo GF29yr/Rh6HCyi3c8pKi6RbsJvPmiob/ZQUZwQd9CNb3rHBN/Fe2GFvvjwGrzAcw7qXL 2LNTkhBt+BL7+CEqdGxOMKJIX0g7TgZpEH9CldvRWOHYjfprJap2p5+AfIAvmLNYoGcT MFqh36gwyWGS8Vxl2WPTvAzQTlAZ9ucDtAxX7eFcDo/5yGWvRQzeCHzMZl7SR018S8zD y4Dg== X-Gm-Message-State: ANoB5plY6lMk62ykLFQJLzRpJidQ3PrFJrTylGwXmkTtI9G4pjo41ylu H0FrzEMT8WYZfxJhsgOtvsw= X-Received: by 2002:aa7:db90:0:b0:459:aa70:d4fd with SMTP id u16-20020aa7db90000000b00459aa70d4fdmr78260533edt.162.1670409491255; Wed, 07 Dec 2022 02:38:11 -0800 (PST) Received: from skbuf ([188.26.184.215]) by smtp.gmail.com with ESMTPSA id j17-20020a17090623f100b007c0d0dad9c6sm5431418ejg.108.2022.12.07.02.38.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 02:38:10 -0800 (PST) Date: Wed, 7 Dec 2022 12:38:08 +0200 From: Vladimir Oltean To: Arun.Ramadoss@microchip.com Cc: andrew@lunn.ch, linux-kernel@vger.kernel.org, UNGLinuxDriver@microchip.com, vivien.didelot@gmail.com, linux@armlinux.org.uk, ceggers@arri.de, Tristram.Ha@microchip.com, f.fainelli@gmail.com, kuba@kernel.org, edumazet@google.com, pabeni@redhat.com, richardcochran@gmail.com, netdev@vger.kernel.org, Woojung.Huh@microchip.com, davem@davemloft.net Subject: Re: [Patch net-next v2 07/13] net: dsa: microchip: ptp: add packet reception timestamping Message-ID: <20221207103808.nfkvr2hwv5yud4uc@skbuf> References: <20221206091428.28285-1-arun.ramadoss@microchip.com> <20221206091428.28285-8-arun.ramadoss@microchip.com> <20221206125344.rwheovbxdoad2duv@skbuf> <148ee662f8def0e63b81d9164d2fd7c0f7029cf7.camel@microchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <148ee662f8def0e63b81d9164d2fd7c0f7029cf7.camel@microchip.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 07, 2022 at 06:00:27AM +0000, Arun.Ramadoss@microchip.com wrote: > I looked into the sja1105 and hellcreek rxtstamp() implementation. > Here, SKB is queued in rxtstamp() and ptp_schedule_worker is started. > In the work queue, skb is dequeued and current ptp hardware clock is > read. Using the partial time stamp and phc clock, absolute time stamp > is calculated and posted. > In this KSZ implementation, ptp_schedule_worker is used for maintaining > the ptp software clock which read value from hardware clock every > second for faster access of clock value. > > Based on the above observation, I have doubt on how to implement. Below > are the algorithm. Kindly suggest which one to proceed. > 1. Remove the existing ptp software clock mainpulation using > ptp_schedule_worker. Instead in the ptp_schedule_worker, dequeue the > skb and timestamp the rx packets by directly reading from the ptp > hardware clock. > 2. Keep the existing implementation, add the rxtstamp() where it will > not queue skb instead just process the timestamping with using software > clock and KSZ_SKB_CB()->tstamp. Search more, you'll find felix_rxtstamp() which is closer to (2) and to what you need. There, reading the 64-bit PTP time is done in NET_RX softirq context because the register access is over MMIO. That might change in the future with the introduction of the SPI controlled VSC7512, but for now it is a good example.