Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3652133ybt; Tue, 23 Jun 2020 07:37:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRvFNUYZnH1GUX7S83m5BelzV7wLX+ZPigpvhiiR3XZUlDRGaOsLfMFGCiVRixZ+IBeOi0 X-Received: by 2002:a05:6402:b13:: with SMTP id bm19mr22814444edb.82.1592923052785; Tue, 23 Jun 2020 07:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592923052; cv=none; d=google.com; s=arc-20160816; b=Rbb0zHOLZMhNUItvArcb+GLzAoMB5hoJFwfWgmYaAq2eTyQ3NFj+UQHV89lnUxorji mlzuDhOX+JSEyKi54I8j7YUsRbjZ66BMvKHrYgt6g/yuu/O9upVB6RCmj075gNh9gr30 Fcr7kB2lBPWCOke3k6kvQYxDXhBT6GiU97xSYweUeyPGDYcPNSq3yMtz5PPy3FZy7Mos TsVd0VpHM+jn+dYGo+Fg606iHch42DU2fozdVRU1QnQNF77GTIteExydKPShbj1y49NM AEd7cdfO1fDk6tLxO/BvEx+PaWTtdwcgBE/1ewFYSLcHP24A3Q8tZpnqiUmzOHiWaQRm IbNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=sCEMGji9lOlQZH7X/A/LPaMvLEWc8wmSeVcelWfV05c=; b=oPOS2Atqa0vgBhlbJ/UH2skXbqX1ofJ/SD92kihb666bOsEZsFaDKsvPGKtf3ae3ki euZsuZq1IR2ZZhDkh0AWXSpo+F/jaSXK+8QfNqPo23kipEIQj94ehYgf+AMSupEoCzee 6ts+iOAzLgMwaXzBMktvoHRV7e/6ztnOk8kcySKZmRO9viaDX4OK9fBystXgPzuT0pj1 flQYMXyVpYN7ZQ0AEn5NXIfXCM5SJ1YD1lU0b2mFoEtXCtLlXBU2orVRFcg+wV382Eyi Ik8nx+qNXlM9lbEtwp5UlED5ffoE/TkjZKNL60FXK0W+WHAsSKEBfzloPzN1qdc1aXcf +eeA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c4si1403904edq.372.2020.06.23.07.37.09; Tue, 23 Jun 2020 07:37:32 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732800AbgFWOfI (ORCPT + 99 others); Tue, 23 Jun 2020 10:35:08 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:20753 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732738AbgFWOfH (ORCPT ); Tue, 23 Jun 2020 10:35:07 -0400 X-Originating-IP: 90.76.143.236 Received: from localhost (lfbn-tou-1-1075-236.w90-76.abo.wanadoo.fr [90.76.143.236]) (Authenticated sender: antoine.tenart@bootlin.com) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 9B539240015; Tue, 23 Jun 2020 14:35:02 +0000 (UTC) From: Antoine Tenart To: davem@davemloft.net, andrew@lunn.ch, f.fainelli@gmail.com, hkallweit1@gmail.com, richardcochran@gmail.com, alexandre.belloni@bootlin.com, UNGLinuxDriver@microchip.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, allan.nielsen@microchip.com, foss@0leil.net, antoine.tenart@bootlin.com Subject: [PATCH net-next v4 0/8] net: phy: mscc: PHC and timestamping support Date: Tue, 23 Jun 2020 16:30:06 +0200 Message-Id: <20200623143014.47864-1-antoine.tenart@bootlin.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, This series aims at adding support for PHC and timestamping operations in the MSCC PHY driver, for the VSC858x and VSC8575. Those PHYs are capable of timestamping in 1-step and 2-step for both L2 and L4 traffic. As of this series, only IPv4 support was implemented when using L4 mode. This is because of an hardware limitation which prevents us for supporting both IPv4 and IPv6 at the same time. Implementing support for IPv6 should be quite easy (I do have the modifications needed for the hardware configuration) but I did not see a way to retrieve this information in hwtstamp(). What would you suggest? Those PHYs are distributed in hardware packages containing multiple times the PHY. The VSC8584 for example is composed of 4 PHYs. With hardware packages, parts of the logic is usually common and one of the PHY has to be used for some parts of the initialization. Following this logic, the 1588 blocks of those PHYs are shared between two PHYs and accessing the registers has to be done using the "base" PHY of the group. This is handled thanks to helpers in the PTP code (and locks). We also need the MDIO bus lock while performing a single read or write to the 1588 registers as the read/write are composed of multiple MDIO transactions (and we don't want other threads updating the page). To get and set the PHC time, a GPIO has to be used and changes are only retrieved or committed when on a rising edge. The same GPIO is shared by all PHYs, so the granularity of the lock protecting it has to be different from the ones protecting the 1588 registers (the VSC8584 PHY has 2 1588 blocks, and a single load/save pin). Patch 1 extends the recently added helpers to share information between PHYs of the same hardware package; to allow having part of the probe to be shared (in addition to the already supported init part). This will be used when adding support for PHC/TS to initialize locks. Patches 2 and 3 are mostly cosmetic. Patch 4 takes into account the 1588 block in the MACsec initialization, to allow having both the MACsec and 1588 blocks initialized on a running system. Patches 5 and 6 add support for PHC and timestamping operations in the MSCC driver. An initialization of the 1588 block (plus all the registers definition; and helpers) is added first; and then comes a patch to implement the PHC and timestamping API. Patches 7 and 8 add the required hardware description for device trees, to be able to use the load/save GPIO pin on the PCB120 board. To use this on a PCB120 board, two other series are needed and have already been sent upstream (one is merged). There are no dependency between all those series. Thanks! Antoine Since v3: - Fixed a SKB leak. - Removed ts_lock from the init, as TS and PHC operations aren't registered at this time. - Refectored the ts_base_addr/phy intialization. - Cleaned up the ingr/egr latencies definitons. - Fixed a comment about locking and the shared GPIO. - A few cosmetic fixes. Since v2: - Removed explicit inlines from .c files. - Fixed three warnings. Since v1: - Removed checks in rxtstamp/txtstamp as skb cannot be NULL here. - Reworked get_ptp_header_rx/get_ptp_header. - Reworked the locking logic between the PHC and timestamping operations. - Fixed a compilation issue on x86 reported by Jakub. Antoine Tenart (5): net: phy: add support for a common probe between shared PHYs net: phy: mscc: fix copyright and author information in MACsec net: phy: mscc: take into account the 1588 block in MACsec init net: phy: mscc: timestamping and PHC support dt-bindings: net: phy: vsc8531: document the load/save GPIO Quentin Schulz (3): net: phy: mscc: remove the TR CLK disable magic value net: phy: mscc: 1588 block initialization MIPS: dts: ocelot: describe the load/save GPIO .../bindings/net/mscc-phy-vsc8531.txt | 3 + arch/mips/boot/dts/mscc/ocelot_pcb120.dts | 12 +- drivers/net/phy/mscc/Makefile | 4 + drivers/net/phy/mscc/mscc.h | 63 + drivers/net/phy/mscc/mscc_fc_buffer.h | 2 +- drivers/net/phy/mscc/mscc_mac.h | 2 +- drivers/net/phy/mscc/mscc_macsec.c | 10 +- drivers/net/phy/mscc/mscc_macsec.h | 2 +- drivers/net/phy/mscc/mscc_main.c | 61 +- drivers/net/phy/mscc/mscc_ptp.c | 1592 +++++++++++++++++ drivers/net/phy/mscc/mscc_ptp.h | 477 +++++ include/linux/phy.h | 18 +- 12 files changed, 2225 insertions(+), 21 deletions(-) create mode 100644 drivers/net/phy/mscc/mscc_ptp.c create mode 100644 drivers/net/phy/mscc/mscc_ptp.h -- 2.26.2