Received: by 2002:a05:6a10:8395:0:0:0:0 with SMTP id n21csp339704pxh; Tue, 9 Nov 2021 11:33:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJxN4Wj1URsdn9lQBtSnAqHYOlrJI8wQ9ErIxntpqASz6RkRSJinr2GERXJIYb/OaVMA0Ok4 X-Received: by 2002:a05:6602:148b:: with SMTP id a11mr7136397iow.85.1636486404828; Tue, 09 Nov 2021 11:33:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636486404; cv=none; d=google.com; s=arc-20160816; b=Sif8FIXIksgqOLffMBSf6NdCEWblipgb+jMVjG1USlMxYiSua4qKjQ2jkfyCOXYfvb 0OV15TfjOcmNDyAooQrX6pHj+AsXV5i7+pOFDKtLzrdhM3zV9ys2Pm/BQyyZeA8o7O0t mHsybnonx1S79xZdQS6nV1pSrPULz+7cG8ObksiCaQE5autlgtaFPkDpTjFD6r5A9qjp nQz6HKzcHhjyiVJNevm0dDmZAEmrPE73/4RAFqQ7FJrFo89ziZCf6w73B0O2iHVpiIrg Kmatd/SKXG3IrHO0aJe9w+3iRdAV7EY0zGkfLFB/abXsxUO/D82o6AFQyGSJ/14bwImw sk4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:dkim-signature:dkim-signature:from; bh=bw5qBgd0vmub1Pz0L0QBZ2Rcgqf+q4qF+intuloVUEs=; b=AtranmJ5xpimtPKoi++yq4A6HPi5ySJ0OUOvFpmnr412eFH+dgnyyEVcnGY59456yW c/oCoGbhBtWgako8CAMgd1i1kLHSMM8q74PUU1JqJVUrOWQsxHKiZGP3Zi7AedLeDnaf zNcAnh7gE04vXpAlRTvFShUSSV83Z5+IYqw6fyohhX3tivXlA6RF3m2nVldNZcRKxx32 jJ+yqv76JfHYZPhgow5BNinr9nEeQ+dSYYxDltBpG6/27aSa1qRIzaWTrBYg4miFsKJ7 71K5SeL4TnkFOsfJP90TOVah+7vIRFtsQY6a/APrMqiA+JNOzvSg9ajORADBEo7jKOET 2STQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="U0/DZg8u"; dkim=neutral (no key) header.i=@linutronix.de; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t20si46488600iov.32.2021.11.09.11.33.07; Tue, 09 Nov 2021 11:33:24 -0800 (PST) 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; dkim=pass header.i=@linutronix.de header.s=2020 header.b="U0/DZg8u"; dkim=neutral (no key) header.i=@linutronix.de; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245022AbhKIJxe (ORCPT + 99 others); Tue, 9 Nov 2021 04:53:34 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:34922 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244979AbhKIJx2 (ORCPT ); Tue, 9 Nov 2021 04:53:28 -0500 From: Martin Kaistra DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1636451441; 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=bw5qBgd0vmub1Pz0L0QBZ2Rcgqf+q4qF+intuloVUEs=; b=U0/DZg8u2uFgnNZAOm6vLTWVYKLNlbXJAZTjMTCEM8Ra8jpt/AdJzmFbG7+M8bjTCNQ89S 7xK8hP52Y3n7DdIWETXT9CNM9RJkUDs+W04HrwKP3u2zkWxA/9S1lfTDw7qlszFxT2XM5x zWhn+bJo9D41AZMrfCGPMb616Ca2VaGRZoCC4+s8T9ZlaDm6U4ZhNUYNiF2fKJDuGmPWzs yCpN2I5G1ZbuJgt0CK6ju+83uXjT3ciuGdmweLTR3abOM0QeWqupA1S3lT4Llth2v4RRZQ J6icNiduVJ1iFcW3Id4ErJNif7y49ac9fOxbfl3FLM1ZG1RQVHLJyIgNLV4gZg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1636451441; 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=bw5qBgd0vmub1Pz0L0QBZ2Rcgqf+q4qF+intuloVUEs=; b=Zrisn8IlnnH4WW5dCXEKUchUYFA8khY9U1ug+WU0fP0LFOkGKexrVUMMlVZE4DX4uN4Zv0 TyXJVO2g0W8068Cg== To: Florian Fainelli , Andrew Lunn , Vivien Didelot Cc: martin.kaistra@linutronix.de, Richard Cochran , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , John Stultz , Thomas Gleixner , Stephen Boyd , Russell King , Marc Kleine-Budde , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v2 0/7] Add PTP support for BCM53128 switch Date: Tue, 9 Nov 2021 10:50:02 +0100 Message-Id: <20211109095013.27829-1-martin.kaistra@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, this series adds PTP support to the b53 DSA driver for the BCM53128 switch using the BroadSync HD feature. As there seems to be only one filter (either by Ethertype or DA) for timestamping incoming packets, only L2 is supported. To be able to use the timecounter infrastructure with a counter that wraps around at a non-power of two point, patch 2 adds support for such a custom point. Alternatively I could fix up the delta every time a wrap-around occurs in the driver itself, but this way it can also be useful for other hardware. v1 -> v2: fix compiling each patch with W=1 C=1 fix compiling when NET_DSA or B53 = m return error on request for too broad filters use aux_work for overflow check fix signature of b53_port_txtstamp() for !CONFIG_B53_PTP rework broadsync hd register definitions add and use register definitions for multiport control remove setting default value for B53_BROADSYNC_TIMEBASE_ADJ simplify initialisation of dev->ptp_clock_info fix pskb_may_pull() for different tag lengths add unlikely() to check for status frames add pointer to b53_port_hwtstamp from dp->priv to simplify access from tag_brcm.c Ideally, for the B53=m case, I would have liked to include the PTP support in the b53_module itself, however I couldn't find a way to do that without renaming either the common source file or the module, which I didn't want to do. Instead, b53_ptp will be allowed as a loadable module, but only if b53_common is also a module, otherwise it will be built-in. This is v2, the previous version can be found here: https://lore.kernel.org/netdev/20211104133204.19757-1-martin.kaistra@linutronix.de/ Thanks, Martin Kurt Kanzenbach (1): net: dsa: b53: Add BroadSync HD register definitions Martin Kaistra (6): net: dsa: b53: Move struct b53_device to include/linux/dsa/b53.h timecounter: allow for non-power of two overflow net: dsa: b53: Add PHC clock support net: dsa: b53: Add logic for RX timestamping net: dsa: b53: Add logic for TX timestamping net: dsa: b53: Expose PTP timestamping ioctls to userspace drivers/net/dsa/b53/Kconfig | 8 + drivers/net/dsa/b53/Makefile | 4 + drivers/net/dsa/b53/b53_common.c | 21 ++ drivers/net/dsa/b53/b53_priv.h | 90 +------- drivers/net/dsa/b53/b53_ptp.c | 366 +++++++++++++++++++++++++++++++ drivers/net/dsa/b53/b53_ptp.h | 67 ++++++ drivers/net/dsa/b53/b53_regs.h | 71 ++++++ include/linux/dsa/b53.h | 144 ++++++++++++ include/linux/timecounter.h | 3 + kernel/time/timecounter.c | 3 + net/dsa/tag_brcm.c | 81 ++++++- 11 files changed, 760 insertions(+), 98 deletions(-) create mode 100644 drivers/net/dsa/b53/b53_ptp.c create mode 100644 drivers/net/dsa/b53/b53_ptp.h create mode 100644 include/linux/dsa/b53.h -- 2.20.1