Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp4176674pxy; Mon, 26 Apr 2021 21:14:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzg5s0YXf2P7YMDMctzzWFkzvXRx6E9Gdc2gEuL+0KeR7e06JmB+dP5Yy4oj2+/oQMNd4P1 X-Received: by 2002:a63:ff52:: with SMTP id s18mr20040989pgk.163.1619496867385; Mon, 26 Apr 2021 21:14:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619496867; cv=none; d=google.com; s=arc-20160816; b=HZ4YfPzWu5Ruc16EnarC4V7V5ZkTIF8W1K11B8yooK56xapsWM00rT3ynBjPsFVtnI hNCMcwHl/2/IJG6YOGl1exIryCUsw7r7ICgus3RtZginx1J3iQAd8+5LH1Vt85d48C6f 7qFzZ0eWcTzcJR2nvSAw/cZFmgoy4zkr+TC3wS6YBNe6HWPFhJjpSVTnSRCRGDxtZp0Q fqAT7/g/rIoheadzODv2tYOly21j53qxc19jHOH7UMiR3fSLdY/gFiKrAtPMk+cqpBUG k4sELWgDuMj5b4rAIr+DafPKOgUBEWy4kBGpsIc2jmZ/nUIvHNW0SNiNseCdoGDS3OXL 1otg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=CUVq497rj5TCxSeJEZf3Loa3qVqcv1XpF1UoEXEShuo=; b=Vk0GItoNsp79gENcL0/xKSFKd1yRFEDgrbhqanBfMgGEvV/Xt5SoY2aRNrq9/yLRtz zCjoS5hBgD//9I6HWV2fgpxHsVQGhLuY2eoMzLK+GVJ6bqH2GBwypjpgh/yaQpprD6/d MebgyFaWw82YFJ/mlmEWAuw9sdHNJcRTgOucAbLM3aJ7n+UdwbCT8kMWcsEEavUX9cmA ufv9McKpJDLYPJfH6DAknR0x51LriHo1vdXtn81g5Wd+Uau61AWvwy0stO2Zm/8tURyG 7Sy5g0hL11rQP+Q50a1Wlc3lcmYMvN264mLXetq97ELh0rSv/RLF9EfBd1tslI7sEuGR tlHw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b10si20798481pgw.174.2021.04.26.21.14.15; Mon, 26 Apr 2021 21:14:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236339AbhD0EMl (ORCPT + 99 others); Tue, 27 Apr 2021 00:12:41 -0400 Received: from inva020.nxp.com ([92.121.34.13]:46304 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233320AbhD0EMb (ORCPT ); Tue, 27 Apr 2021 00:12:31 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id CD54A1A0971; Tue, 27 Apr 2021 06:11:47 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 7902B1A18C4; Tue, 27 Apr 2021 06:11:41 +0200 (CEST) Received: from localhost.localdomain (mega.ap.freescale.net [10.192.208.232]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id B73744032C; Tue, 27 Apr 2021 06:11:33 +0200 (CEST) From: Yangbo Lu To: netdev@vger.kernel.org Cc: Yangbo Lu , Richard Cochran , Vladimir Oltean , "David S . Miller" , Jakub Kicinski , Jonathan Corbet , Kurt Kanzenbach , Andrew Lunn , Vivien Didelot , Florian Fainelli , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [net-next, v3, 5/7] docs: networking: timestamping: update for DSA switches Date: Tue, 27 Apr 2021 12:22:01 +0800 Message-Id: <20210427042203.26258-6-yangbo.lu@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210427042203.26258-1-yangbo.lu@nxp.com> References: <20210427042203.26258-1-yangbo.lu@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Update timestamping doc for DSA switches to describe current implementation accurately. On TX, the skb cloning is no longer in DSA generic code. Signed-off-by: Yangbo Lu Acked-by: Richard Cochran --- Changes for v2: - Split from tx timestamp optimization big patch. Changes for v3: - None. --- Documentation/networking/timestamping.rst | 63 ++++++++++++++--------- 1 file changed, 39 insertions(+), 24 deletions(-) diff --git a/Documentation/networking/timestamping.rst b/Documentation/networking/timestamping.rst index f682e88fa87e..7db3985359bc 100644 --- a/Documentation/networking/timestamping.rst +++ b/Documentation/networking/timestamping.rst @@ -630,30 +630,45 @@ hardware timestamping on it. This is because the SO_TIMESTAMPING API does not allow the delivery of multiple hardware timestamps for the same packet, so anybody else except for the DSA switch port must be prevented from doing so. -In code, DSA provides for most of the infrastructure for timestamping already, -in generic code: a BPF classifier (``ptp_classify_raw``) is used to identify -PTP event messages (any other packets, including PTP general messages, are not -timestamped), and provides two hooks to drivers: - -- ``.port_txtstamp()``: The driver is passed a clone of the timestampable skb - to be transmitted, before actually transmitting it. Typically, a switch will - have a PTP TX timestamp register (or sometimes a FIFO) where the timestamp - becomes available. There may be an IRQ that is raised upon this timestamp's - availability, or the driver might have to poll after invoking - ``dev_queue_xmit()`` towards the host interface. Either way, in the - ``.port_txtstamp()`` method, the driver only needs to save the clone for - later use (when the timestamp becomes available). Each skb is annotated with - a pointer to its clone, in ``DSA_SKB_CB(skb)->clone``, to ease the driver's - job of keeping track of which clone belongs to which skb. - -- ``.port_rxtstamp()``: The original (and only) timestampable skb is provided - to the driver, for it to annotate it with a timestamp, if that is immediately - available, or defer to later. On reception, timestamps might either be - available in-band (through metadata in the DSA header, or attached in other - ways to the packet), or out-of-band (through another RX timestamping FIFO). - Deferral on RX is typically necessary when retrieving the timestamp needs a - sleepable context. In that case, it is the responsibility of the DSA driver - to call ``netif_rx_ni()`` on the freshly timestamped skb. +In the generic layer, DSA provides the following infrastructure for PTP +timestamping: + +- ``.port_txtstamp()``: a hook called prior to the transmission of + packets with a hardware TX timestamping request from user space. + This is required for two-step timestamping, since the hardware + timestamp becomes available after the actual MAC transmission, so the + driver must be prepared to correlate the timestamp with the original + packet so that it can re-enqueue the packet back into the socket's + error queue. To save the packet for when the timestamp becomes + available, the driver can call ``skb_clone_sk`` , save the clone pointer + in skb->cb and enqueue a tx skb queue. Typically, a switch will have a + PTP TX timestamp register (or sometimes a FIFO) where the timestamp + becomes available. In case of a FIFO, the hardware might store + key-value pairs of PTP sequence ID/message type/domain number and the + actual timestamp. To perform the correlation correctly between the + packets in a queue waiting for timestamping and the actual timestamps, + drivers can use a BPF classifier (``ptp_classify_raw``) to identify + the PTP transport type, and ``ptp_parse_header`` to interpret the PTP + header fields. There may be an IRQ that is raised upon this + timestamp's availability, or the driver might have to poll after + invoking ``dev_queue_xmit()`` towards the host interface. + One-step TX timestamping do not require packet cloning, since there is + no follow-up message required by the PTP protocol (because the + TX timestamp is embedded into the packet by the MAC), and therefore + user space does not expect the packet annotated with the TX timestamp + to be re-enqueued into its socket's error queue. + +- ``.port_rxtstamp()``: On RX, the BPF classifier is run by DSA to + identify PTP event messages (any other packets, including PTP general + messages, are not timestamped). The original (and only) timestampable + skb is provided to the driver, for it to annotate it with a timestamp, + if that is immediately available, or defer to later. On reception, + timestamps might either be available in-band (through metadata in the + DSA header, or attached in other ways to the packet), or out-of-band + (through another RX timestamping FIFO). Deferral on RX is typically + necessary when retrieving the timestamp needs a sleepable context. In + that case, it is the responsibility of the DSA driver to call + ``netif_rx_ni()`` on the freshly timestamped skb. 3.2.2 Ethernet PHYs ^^^^^^^^^^^^^^^^^^^ -- 2.25.1