From patchwork Thu Oct 19 14:29:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?K=C3=B6ry_Maincent?= X-Patchwork-Id: 155603 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp425359vqb; Thu, 19 Oct 2023 07:31:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHHz3P+9PWMiXIpLrkG3fUazy3fmAwnjI+8WLFtcYPoq7aCsZKxzEuShitaN/8Kodpt6NZW X-Received: by 2002:a05:6359:5c1f:b0:134:fdfc:4319 with SMTP id pu31-20020a0563595c1f00b00134fdfc4319mr2030113rwb.20.1697725887122; Thu, 19 Oct 2023 07:31:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697725887; cv=none; d=google.com; s=arc-20160816; b=POFJy8aL0oZrlgtImhaa24lgE0ph7qXDOyIqbtVQ1rsk+CQra/uvFWw3VIOC9osqBL 4qQFa1F4wSGaNXJb0eq3NRMykqzI1fjuepgukbwjn5XNNASMzghx1XxeED40oeMdByHE KZaK5f1meoIqUIfIWcihxZeLSlM9Ou+cm5i7hbs3yftZuPyfKqvN7/Ly69PjLZe9ugLC vcEKgfvU3lgb2nYBgONZbN9sUOtgB0XPP6NuA5r0n72OehwP+m9ejIVTA0/UukgGNLwj CiP8cODxQ7ug5DsNWHKIIuVvqe5jAyIn8ITghWIW/7a4tmG2wzAWpWDxlHwOMpvng9Mi oDnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=abOHoGLIRoNtFY2Rd+BwksfAfNxY0pNAK7aj3cvo/fg=; fh=IL4Om7kRbYP5ILTMWk7kzVj5RVF0+t2ztL6E2Yzsl4U=; b=TGsAJy4C3CWgdkOqe0kUQdXQckc7LdZ7cKW5SVumoOXJGIfLBwv/kHQPaP+IKI8lp7 G6527uPt3CwPUL/WBkEDKStdmVPgVh5Xl5okQeT8+ArS02GP+Oe2jrNHUKtcR6/JRMhG bMjIMA24WFkb7HTO1nqJ7FdHTnlv597vEwc1PcLJWPVv0XUACLu51fbVi0pK4WUIH9f5 puNBjvtZ70Ze+HGzceUVynAvCWxBTo1q7AGBMF9u47jWk5QrE+gybzLFOgF7lvWacW9l YHeWcDlAZzXBRXecyAUk+CExmy3q1HzJOLiTv5paBuYFJNDFiVTWb2ZTLbxaEliUzt2D iEWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=mr0sNbDk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id f8-20020a056a00238800b006be199ee091si6764827pfc.295.2023.10.19.07.31.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 07:31:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=mr0sNbDk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 6A42F8135686; Thu, 19 Oct 2023 07:31:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346117AbjJSO3t (ORCPT + 25 others); Thu, 19 Oct 2023 10:29:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346085AbjJSO3q (ORCPT ); Thu, 19 Oct 2023 10:29:46 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::223]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E070BB0; Thu, 19 Oct 2023 07:29:42 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 1F6486000E; Thu, 19 Oct 2023 14:29:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697725781; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=abOHoGLIRoNtFY2Rd+BwksfAfNxY0pNAK7aj3cvo/fg=; b=mr0sNbDkqmMHmHIkgR8b1omM5idl6ckYKpNOAzNQ6XbWu71bWGstPuou6KexuEQiqkxNn3 BtJXgvoUlk2pdz2/hMA8mKBkQRSiY5rs7k5Z91JI0NrcdnEtnhZkmp3GMiWPcKBqmgjn0p M/n3a3ydnJuqDcpaGavSi2LEUs8dJXJDFTn3xy9d9JDgOiKf0d7bikDC+rU3E7VBVfXsRl QsvyR/kCTtiJGYkeVh4ZGOFbFiIZashV10PKQ5QNR6cBcqlo/AjjRP3wcF8oRJsPTmnwx6 w6LTXiOdIwho1V+96HQhQK7fUgBOVVT3OfzdKk3Dg4fS1/T9JmX6O9yv0bOYQQ== From: Kory Maincent Date: Thu, 19 Oct 2023 16:29:16 +0200 Subject: [PATCH net-next v6 01/16] net: Convert PHYs hwtstamp callback to use kernel_hwtstamp_config MIME-Version: 1.0 Message-Id: <20231019-feature_ptp_netnext-v6-1-71affc27b0e5@bootlin.com> References: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> In-Reply-To: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> To: Florian Fainelli , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Radu Pirea , Jay Vosburgh , Andy Gospodarek , Nicolas Ferre , Claudiu Beznea , Willem de Bruijn , Jonathan Corbet , Horatiu Vultur , UNGLinuxDriver@microchip.com, Simon Horman , Vladimir Oltean Cc: Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Maxime Chevallier , Kory Maincent X-Mailer: b4 0.12.3 X-GND-Sasl: kory.maincent@bootlin.com X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 19 Oct 2023 07:31:09 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780194620019708989 X-GMAIL-MSGID: 1780194620019708989 The PHYs hwtstamp callback are still getting the timestamp config from ifreq and using copy_from/to_user. Get rid of these functions by using timestamp configuration in parameter. This also allow to move on to kernel_hwtstamp_config and be similar to net devices using the new ndo_hwstamp_get/set. This adds the possibility to manipulate the timestamp configuration from the kernel which was not possible with the copy_from/to_user. Signed-off-by: Kory Maincent Reviewed-by: Florian Fainelli --- Change in v6: - Fix nxp_c45_hwtstamp config variable missing --- drivers/net/phy/bcm-phy-ptp.c | 15 ++++++--------- drivers/net/phy/dp83640.c | 24 +++++++++++------------- drivers/net/phy/micrel.c | 38 +++++++++++++++++--------------------- drivers/net/phy/mscc/mscc_ptp.c | 18 ++++++++---------- drivers/net/phy/nxp-c45-tja11xx.c | 17 +++++++---------- drivers/net/phy/phy.c | 21 +++++++++++++++++++-- drivers/ptp/ptp_ines.c | 16 +++++++--------- include/linux/mii_timestamper.h | 4 +++- include/linux/phy.h | 6 ++++-- 9 files changed, 82 insertions(+), 77 deletions(-) diff --git a/drivers/net/phy/bcm-phy-ptp.c b/drivers/net/phy/bcm-phy-ptp.c index ef00d6163061..0beae8f81ffa 100644 --- a/drivers/net/phy/bcm-phy-ptp.c +++ b/drivers/net/phy/bcm-phy-ptp.c @@ -782,16 +782,13 @@ static void bcm_ptp_txtstamp(struct mii_timestamper *mii_ts, } static int bcm_ptp_hwtstamp(struct mii_timestamper *mii_ts, - struct ifreq *ifr) + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack) { struct bcm_ptp_private *priv = mii2priv(mii_ts); - struct hwtstamp_config cfg; u16 mode, ctrl; - if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) - return -EFAULT; - - switch (cfg.rx_filter) { + switch (cfg->rx_filter) { case HWTSTAMP_FILTER_NONE: priv->hwts_rx = false; break; @@ -804,14 +801,14 @@ static int bcm_ptp_hwtstamp(struct mii_timestamper *mii_ts, case HWTSTAMP_FILTER_PTP_V2_EVENT: case HWTSTAMP_FILTER_PTP_V2_SYNC: case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: - cfg.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; + cfg->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; priv->hwts_rx = true; break; default: return -ERANGE; } - priv->tx_type = cfg.tx_type; + priv->tx_type = cfg->tx_type; ctrl = priv->hwts_rx ? SLICE_RX_EN : 0; ctrl |= priv->tx_type != HWTSTAMP_TX_OFF ? SLICE_TX_EN : 0; @@ -840,7 +837,7 @@ static int bcm_ptp_hwtstamp(struct mii_timestamper *mii_ts, /* purge existing data */ skb_queue_purge(&priv->tx_queue); - return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0; + return 0; } static int bcm_ptp_ts_info(struct mii_timestamper *mii_ts, diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c index 2657be7cc049..5c42c47dc564 100644 --- a/drivers/net/phy/dp83640.c +++ b/drivers/net/phy/dp83640.c @@ -1207,22 +1207,20 @@ static irqreturn_t dp83640_handle_interrupt(struct phy_device *phydev) return IRQ_HANDLED; } -static int dp83640_hwtstamp(struct mii_timestamper *mii_ts, struct ifreq *ifr) +static int dp83640_hwtstamp(struct mii_timestamper *mii_ts, + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack) { struct dp83640_private *dp83640 = container_of(mii_ts, struct dp83640_private, mii_ts); - struct hwtstamp_config cfg; u16 txcfg0, rxcfg0; - if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) - return -EFAULT; - - if (cfg.tx_type < 0 || cfg.tx_type > HWTSTAMP_TX_ONESTEP_SYNC) + if (cfg->tx_type < 0 || cfg->tx_type > HWTSTAMP_TX_ONESTEP_SYNC) return -ERANGE; - dp83640->hwts_tx_en = cfg.tx_type; + dp83640->hwts_tx_en = cfg->tx_type; - switch (cfg.rx_filter) { + switch (cfg->rx_filter) { case HWTSTAMP_FILTER_NONE: dp83640->hwts_rx_en = 0; dp83640->layer = 0; @@ -1234,7 +1232,7 @@ static int dp83640_hwtstamp(struct mii_timestamper *mii_ts, struct ifreq *ifr) dp83640->hwts_rx_en = 1; dp83640->layer = PTP_CLASS_L4; dp83640->version = PTP_CLASS_V1; - cfg.rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_EVENT; + cfg->rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_EVENT; break; case HWTSTAMP_FILTER_PTP_V2_L4_EVENT: case HWTSTAMP_FILTER_PTP_V2_L4_SYNC: @@ -1242,7 +1240,7 @@ static int dp83640_hwtstamp(struct mii_timestamper *mii_ts, struct ifreq *ifr) dp83640->hwts_rx_en = 1; dp83640->layer = PTP_CLASS_L4; dp83640->version = PTP_CLASS_V2; - cfg.rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_EVENT; + cfg->rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_EVENT; break; case HWTSTAMP_FILTER_PTP_V2_L2_EVENT: case HWTSTAMP_FILTER_PTP_V2_L2_SYNC: @@ -1250,7 +1248,7 @@ static int dp83640_hwtstamp(struct mii_timestamper *mii_ts, struct ifreq *ifr) dp83640->hwts_rx_en = 1; dp83640->layer = PTP_CLASS_L2; dp83640->version = PTP_CLASS_V2; - cfg.rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT; + cfg->rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT; break; case HWTSTAMP_FILTER_PTP_V2_EVENT: case HWTSTAMP_FILTER_PTP_V2_SYNC: @@ -1258,7 +1256,7 @@ static int dp83640_hwtstamp(struct mii_timestamper *mii_ts, struct ifreq *ifr) dp83640->hwts_rx_en = 1; dp83640->layer = PTP_CLASS_L4 | PTP_CLASS_L2; dp83640->version = PTP_CLASS_V2; - cfg.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; + cfg->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; break; default: return -ERANGE; @@ -1292,7 +1290,7 @@ static int dp83640_hwtstamp(struct mii_timestamper *mii_ts, struct ifreq *ifr) mutex_unlock(&dp83640->clock->extreg_lock); - return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0; + return 0; } static void rx_timestamp_work(struct work_struct *work) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 927d3d54658e..43d072b53839 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -2373,24 +2373,22 @@ static void lan8814_flush_fifo(struct phy_device *phydev, bool egress) lanphy_read_page_reg(phydev, 5, PTP_TSU_INT_STS); } -static int lan8814_hwtstamp(struct mii_timestamper *mii_ts, struct ifreq *ifr) +static int lan8814_hwtstamp(struct mii_timestamper *mii_ts, + struct kernel_hwtstamp_config *config, + struct netlink_ext_ack *extack) { struct kszphy_ptp_priv *ptp_priv = container_of(mii_ts, struct kszphy_ptp_priv, mii_ts); struct phy_device *phydev = ptp_priv->phydev; struct lan8814_shared_priv *shared = phydev->shared->priv; struct lan8814_ptp_rx_ts *rx_ts, *tmp; - struct hwtstamp_config config; int txcfg = 0, rxcfg = 0; int pkt_ts_enable; - if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) - return -EFAULT; + ptp_priv->hwts_tx_type = config->tx_type; + ptp_priv->rx_filter = config->rx_filter; - ptp_priv->hwts_tx_type = config.tx_type; - ptp_priv->rx_filter = config.rx_filter; - - switch (config.rx_filter) { + switch (config->rx_filter) { case HWTSTAMP_FILTER_NONE: ptp_priv->layer = 0; ptp_priv->version = 0; @@ -2436,13 +2434,13 @@ static int lan8814_hwtstamp(struct mii_timestamper *mii_ts, struct ifreq *ifr) lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_TX_MOD, PTP_TX_MOD_TX_PTP_SYNC_TS_INSERT_); - if (config.rx_filter != HWTSTAMP_FILTER_NONE) + if (config->rx_filter != HWTSTAMP_FILTER_NONE) lan8814_config_ts_intr(ptp_priv->phydev, true); else lan8814_config_ts_intr(ptp_priv->phydev, false); mutex_lock(&shared->shared_lock); - if (config.rx_filter != HWTSTAMP_FILTER_NONE) + if (config->rx_filter != HWTSTAMP_FILTER_NONE) shared->ref++; else shared->ref--; @@ -2466,7 +2464,7 @@ static int lan8814_hwtstamp(struct mii_timestamper *mii_ts, struct ifreq *ifr) lan8814_flush_fifo(ptp_priv->phydev, false); lan8814_flush_fifo(ptp_priv->phydev, true); - return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? -EFAULT : 0; + return 0; } static void lan8814_txtstamp(struct mii_timestamper *mii_ts, @@ -3681,21 +3679,19 @@ static void lan8841_ptp_enable_processing(struct kszphy_ptp_priv *ptp_priv, #define LAN8841_PTP_TX_TIMESTAMP_EN 443 #define LAN8841_PTP_TX_MOD 445 -static int lan8841_hwtstamp(struct mii_timestamper *mii_ts, struct ifreq *ifr) +static int lan8841_hwtstamp(struct mii_timestamper *mii_ts, + struct kernel_hwtstamp_config *config, + struct netlink_ext_ack *extack) { struct kszphy_ptp_priv *ptp_priv = container_of(mii_ts, struct kszphy_ptp_priv, mii_ts); struct phy_device *phydev = ptp_priv->phydev; - struct hwtstamp_config config; int txcfg = 0, rxcfg = 0; int pkt_ts_enable; - if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) - return -EFAULT; + ptp_priv->hwts_tx_type = config->tx_type; + ptp_priv->rx_filter = config->rx_filter; - ptp_priv->hwts_tx_type = config.tx_type; - ptp_priv->rx_filter = config.rx_filter; - - switch (config.rx_filter) { + switch (config->rx_filter) { case HWTSTAMP_FILTER_NONE: ptp_priv->layer = 0; ptp_priv->version = 0; @@ -3749,13 +3745,13 @@ static int lan8841_hwtstamp(struct mii_timestamper *mii_ts, struct ifreq *ifr) /* Now enable/disable the timestamping */ lan8841_ptp_enable_processing(ptp_priv, - config.rx_filter != HWTSTAMP_FILTER_NONE); + config->rx_filter != HWTSTAMP_FILTER_NONE); skb_queue_purge(&ptp_priv->tx_queue); lan8841_ptp_flush_fifo(ptp_priv); - return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? -EFAULT : 0; + return 0; } static bool lan8841_rxtstamp(struct mii_timestamper *mii_ts, diff --git a/drivers/net/phy/mscc/mscc_ptp.c b/drivers/net/phy/mscc/mscc_ptp.c index cf728bfd83e2..eb0b032cb613 100644 --- a/drivers/net/phy/mscc/mscc_ptp.c +++ b/drivers/net/phy/mscc/mscc_ptp.c @@ -1045,19 +1045,17 @@ static void vsc85xx_ts_reset_fifo(struct phy_device *phydev) val); } -static int vsc85xx_hwtstamp(struct mii_timestamper *mii_ts, struct ifreq *ifr) +static int vsc85xx_hwtstamp(struct mii_timestamper *mii_ts, + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack) { struct vsc8531_private *vsc8531 = container_of(mii_ts, struct vsc8531_private, mii_ts); struct phy_device *phydev = vsc8531->ptp->phydev; - struct hwtstamp_config cfg; bool one_step = false; u32 val; - if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) - return -EFAULT; - - switch (cfg.tx_type) { + switch (cfg->tx_type) { case HWTSTAMP_TX_ONESTEP_SYNC: one_step = true; break; @@ -1069,9 +1067,9 @@ static int vsc85xx_hwtstamp(struct mii_timestamper *mii_ts, struct ifreq *ifr) return -ERANGE; } - vsc8531->ptp->tx_type = cfg.tx_type; + vsc8531->ptp->tx_type = cfg->tx_type; - switch (cfg.rx_filter) { + switch (cfg->rx_filter) { case HWTSTAMP_FILTER_NONE: break; case HWTSTAMP_FILTER_PTP_V2_L4_EVENT: @@ -1084,7 +1082,7 @@ static int vsc85xx_hwtstamp(struct mii_timestamper *mii_ts, struct ifreq *ifr) return -ERANGE; } - vsc8531->ptp->rx_filter = cfg.rx_filter; + vsc8531->ptp->rx_filter = cfg->rx_filter; mutex_lock(&vsc8531->ts_lock); @@ -1132,7 +1130,7 @@ static int vsc85xx_hwtstamp(struct mii_timestamper *mii_ts, struct ifreq *ifr) vsc8531->ptp->configured = 1; mutex_unlock(&vsc8531->ts_lock); - return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0; + return 0; } static int vsc85xx_ts_info(struct mii_timestamper *mii_ts, diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c index 7ab080ff02df..780ad353cf55 100644 --- a/drivers/net/phy/nxp-c45-tja11xx.c +++ b/drivers/net/phy/nxp-c45-tja11xx.c @@ -1022,24 +1022,21 @@ static bool nxp_c45_rxtstamp(struct mii_timestamper *mii_ts, } static int nxp_c45_hwtstamp(struct mii_timestamper *mii_ts, - struct ifreq *ifreq) + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack) { struct nxp_c45_phy *priv = container_of(mii_ts, struct nxp_c45_phy, mii_ts); struct phy_device *phydev = priv->phydev; const struct nxp_c45_phy_data *data; - struct hwtstamp_config cfg; - if (copy_from_user(&cfg, ifreq->ifr_data, sizeof(cfg))) - return -EFAULT; - - if (cfg.tx_type < 0 || cfg.tx_type > HWTSTAMP_TX_ON) + if (cfg->tx_type < 0 || cfg->tx_type > HWTSTAMP_TX_ON) return -ERANGE; data = nxp_c45_get_data(phydev); - priv->hwts_tx = cfg.tx_type; + priv->hwts_tx = cfg->tx_type; - switch (cfg.rx_filter) { + switch (cfg->rx_filter) { case HWTSTAMP_FILTER_NONE: priv->hwts_rx = 0; break; @@ -1047,7 +1044,7 @@ static int nxp_c45_hwtstamp(struct mii_timestamper *mii_ts, case HWTSTAMP_FILTER_PTP_V2_L2_SYNC: case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ: priv->hwts_rx = 1; - cfg.rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT; + cfg->rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT; break; default: return -ERANGE; @@ -1074,7 +1071,7 @@ static int nxp_c45_hwtstamp(struct mii_timestamper *mii_ts, nxp_c45_clear_reg_field(phydev, &data->regmap->irq_egr_ts_en); nxp_c45_no_ptp_irq: - return copy_to_user(ifreq->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0; + return 0; } static int nxp_c45_ts_info(struct mii_timestamper *mii_ts, diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index a5fa077650e8..d058316666ba 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -325,9 +325,13 @@ EXPORT_SYMBOL(phy_ethtool_ksettings_get); int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd) { struct mii_ioctl_data *mii_data = if_mii(ifr); + struct kernel_hwtstamp_config kernel_cfg; + struct netlink_ext_ack extack = {}; u16 val = mii_data->val_in; bool change_autoneg = false; + struct hwtstamp_config cfg; int prtad, devad; + int ret; switch (cmd) { case SIOCGMIIPHY: @@ -411,8 +415,21 @@ int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd) return 0; case SIOCSHWTSTAMP: - if (phydev->mii_ts && phydev->mii_ts->hwtstamp) - return phydev->mii_ts->hwtstamp(phydev->mii_ts, ifr); + if (phydev->mii_ts && phydev->mii_ts->hwtstamp) { + if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) + return -EFAULT; + + hwtstamp_config_to_kernel(&kernel_cfg, &cfg); + ret = phydev->mii_ts->hwtstamp(phydev->mii_ts, &kernel_cfg, &extack); + if (ret) + return ret; + + hwtstamp_config_from_kernel(&cfg, &kernel_cfg); + if (copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg))) + return -EFAULT; + + return 0; + } fallthrough; default: diff --git a/drivers/ptp/ptp_ines.c b/drivers/ptp/ptp_ines.c index ed215b458183..1d2940a78455 100644 --- a/drivers/ptp/ptp_ines.c +++ b/drivers/ptp/ptp_ines.c @@ -328,17 +328,15 @@ static u64 ines_find_txts(struct ines_port *port, struct sk_buff *skb) return ns; } -static int ines_hwtstamp(struct mii_timestamper *mii_ts, struct ifreq *ifr) +static int ines_hwtstamp(struct mii_timestamper *mii_ts, + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack) { struct ines_port *port = container_of(mii_ts, struct ines_port, mii_ts); u32 cm_one_step = 0, port_conf, ts_stat_rx, ts_stat_tx; - struct hwtstamp_config cfg; unsigned long flags; - if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) - return -EFAULT; - - switch (cfg.tx_type) { + switch (cfg->tx_type) { case HWTSTAMP_TX_OFF: ts_stat_tx = 0; break; @@ -353,7 +351,7 @@ static int ines_hwtstamp(struct mii_timestamper *mii_ts, struct ifreq *ifr) return -ERANGE; } - switch (cfg.rx_filter) { + switch (cfg->rx_filter) { case HWTSTAMP_FILTER_NONE: ts_stat_rx = 0; break; @@ -372,7 +370,7 @@ static int ines_hwtstamp(struct mii_timestamper *mii_ts, struct ifreq *ifr) case HWTSTAMP_FILTER_PTP_V2_SYNC: case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: ts_stat_rx = TS_ENABLE; - cfg.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; + cfg->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; break; default: return -ERANGE; @@ -393,7 +391,7 @@ static int ines_hwtstamp(struct mii_timestamper *mii_ts, struct ifreq *ifr) spin_unlock_irqrestore(&port->lock, flags); - return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0; + return 0; } static void ines_link_state(struct mii_timestamper *mii_ts, diff --git a/include/linux/mii_timestamper.h b/include/linux/mii_timestamper.h index fa940bbaf8ae..26b04f73f214 100644 --- a/include/linux/mii_timestamper.h +++ b/include/linux/mii_timestamper.h @@ -9,6 +9,7 @@ #include #include #include +#include struct phy_device; @@ -51,7 +52,8 @@ struct mii_timestamper { struct sk_buff *skb, int type); int (*hwtstamp)(struct mii_timestamper *mii_ts, - struct ifreq *ifreq); + struct kernel_hwtstamp_config *kernel_config, + struct netlink_ext_ack *extack); void (*link_state)(struct mii_timestamper *mii_ts, struct phy_device *phydev); diff --git a/include/linux/phy.h b/include/linux/phy.h index 3cc52826f18e..e5f1f41e399c 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1560,9 +1560,11 @@ static inline bool phy_has_txtstamp(struct phy_device *phydev) return phydev && phydev->mii_ts && phydev->mii_ts->txtstamp; } -static inline int phy_hwtstamp(struct phy_device *phydev, struct ifreq *ifr) +static inline int phy_hwtstamp(struct phy_device *phydev, + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack) { - return phydev->mii_ts->hwtstamp(phydev->mii_ts, ifr); + return phydev->mii_ts->hwtstamp(phydev->mii_ts, cfg, extack); } static inline bool phy_rxtstamp(struct phy_device *phydev, struct sk_buff *skb, From patchwork Thu Oct 19 14:29:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?K=C3=B6ry_Maincent?= X-Patchwork-Id: 155595 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp424291vqb; Thu, 19 Oct 2023 07:29:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEWnvkS44PB2AUJmSv9X3oGymgOdr9XdiLGd8ARRVUxTGOBnC1QsQXyed+t8iQeHfsY1JAZ X-Received: by 2002:a05:6a20:144b:b0:16b:c20d:f979 with SMTP id a11-20020a056a20144b00b0016bc20df979mr2380170pzi.13.1697725798342; Thu, 19 Oct 2023 07:29:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697725798; cv=none; d=google.com; s=arc-20160816; b=UxnYeEgVxOERg9tpSZ845nMwNe6WIyYYvBcAx7Xa7zQe6N1YbAHIHOWmPaJe6Y4aIE aGCZeEyuuqKvpM7LZRn7x7FHd8dNdbUw5WSS0F2PpktdSOaY6OkUAapuOlEvOPzdNATb 9KrLhfJvxe2Ak4nU6eZKI7a1fPmeK0nUwSyjHo0gZGtKjY9H+b1HnV+QpTGwaVyiOXqj vNzVVNvi6HiKikU319WvAk3dQ/0WsE6+w+XWHnmEiiU6+NhDqq4JkGfU+qZoB8C1UMYi KIGDUOgzfoimzEpjLbatl4chJUOSztBbtltKwjevJiJMimcGLkRJD2OkldJ2xdekYHCS i18Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=iLcv2U5/tJBWHcDOVIYyQDAJQb5WKSZvw4UjIoMJnco=; fh=IL4Om7kRbYP5ILTMWk7kzVj5RVF0+t2ztL6E2Yzsl4U=; b=DtNWWmw81zkwZjX1mhnENhuoQ/6VTLnOFaba39evJ1GEQCFgzqnF3l+vFHu5ff++hv P2csjedOZTjbjGOCj+Le8ufTl6lK1oC6J9v7qIVj2ORXkbDoiQKgsGtdHh9kJdsNtQ95 GpCBhjwBmEtdFKRAQOH9jUXDjHMrTEX6dQshkMGL3dAWe856DqOwilmhhomA9eof/5aS J1ePwdA4UGmdfhSgPorGOtpbGGyUMClHQwygbF1X2pMA+MPHvGCvpNy8ESwwjC9xydWW a42nOwRj5cFVevJGTU1Z/tnqqkA5/mTBfa7BUS+q8TPAOIL+inFJxB/bGmw4JwQhGn06 +9gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="Ij3j/CTi"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id l2-20020a656802000000b0059cdf90b9b2si4312626pgt.685.2023.10.19.07.29.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 07:29:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="Ij3j/CTi"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 67C0F8305900; Thu, 19 Oct 2023 07:29:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346104AbjJSO3r (ORCPT + 25 others); Thu, 19 Oct 2023 10:29:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345641AbjJSO3q (ORCPT ); Thu, 19 Oct 2023 10:29:46 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A3AA119; Thu, 19 Oct 2023 07:29:43 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 7527A60004; Thu, 19 Oct 2023 14:29:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697725782; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iLcv2U5/tJBWHcDOVIYyQDAJQb5WKSZvw4UjIoMJnco=; b=Ij3j/CTi+ULBqRLsOa3XYt71BVUJlYUwYm01CUtgNBboUfUX4Jc+GiMLIqYoQzklhsFR47 daVnAx59wx+o4YsMICB6sSTMwp94gkGEwzvxUI5nkgNgF4GloaI56kg8nJxfZop5a4hudu o915NnGDC1iMHXLMBlfAVVI66T0hNGzLkaM1l+8hANBkEL6/OQowSHwyjqTAk1jDxRrSvX EHqIrNIuVvklbCioJ2BBRwSzwEel7Tsh8fR3yMxSN512QPaw7ndMFMhvUCX8ybtn3AvBwr 5t6ZHHW5N5fR9oW2Sceop8lKr3fF+ld+u3VqOIjwwzaNYzAjH9MWHySWm7QEbg== From: Kory Maincent Date: Thu, 19 Oct 2023 16:29:17 +0200 Subject: [PATCH net-next v6 02/16] net: phy: Remove the call to phy_mii_ioctl in phy_hwstamp_get/set MIME-Version: 1.0 Message-Id: <20231019-feature_ptp_netnext-v6-2-71affc27b0e5@bootlin.com> References: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> In-Reply-To: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> To: Florian Fainelli , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Radu Pirea , Jay Vosburgh , Andy Gospodarek , Nicolas Ferre , Claudiu Beznea , Willem de Bruijn , Jonathan Corbet , Horatiu Vultur , UNGLinuxDriver@microchip.com, Simon Horman , Vladimir Oltean Cc: Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Maxime Chevallier , Kory Maincent X-Mailer: b4 0.12.3 X-GND-Sasl: kory.maincent@bootlin.com X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 19 Oct 2023 07:29:54 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780194526439956172 X-GMAIL-MSGID: 1780194526439956172 __phy_hwtstamp_set function were calling the phy_mii_ioctl function which will then use the ifreq pointer to call the hwtstamp callback. Now that ifreq has been removed from the hwstamp callback parameters it seems more logical to not go through the phy_mii_ioctl function and pass directly kernel_hwtstamp_config parameter to the hwtstamp callback. Lets do the same for __phy_hwtstamp_get function and return directly EOPNOTSUPP as SIOCGHWTSTAMP is not supported for now for the PHYs. Signed-off-by: Kory Maincent Reviewed-by: Florian Fainelli --- drivers/net/phy/phy.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index d058316666ba..3376e58e2b88 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -486,7 +486,7 @@ int __phy_hwtstamp_get(struct phy_device *phydev, if (!phydev) return -ENODEV; - return phy_mii_ioctl(phydev, config->ifr, SIOCGHWTSTAMP); + return -EOPNOTSUPP; } /** @@ -503,7 +503,10 @@ int __phy_hwtstamp_set(struct phy_device *phydev, if (!phydev) return -ENODEV; - return phy_mii_ioctl(phydev, config->ifr, SIOCSHWTSTAMP); + if (phydev->mii_ts && phydev->mii_ts->hwtstamp) + return phydev->mii_ts->hwtstamp(phydev->mii_ts, config, extack); + + return -EOPNOTSUPP; } /** From patchwork Thu Oct 19 14:29:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?K=C3=B6ry_Maincent?= X-Patchwork-Id: 155597 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp425050vqb; Thu, 19 Oct 2023 07:31:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEfp05SfFco9KMsW0xbyMPiP3Io2k89bii3vAms25lRJ3j8gIESrVTAByqopIefLZo3qD22 X-Received: by 2002:a05:6870:1311:b0:1e9:97eb:15a with SMTP id 17-20020a056870131100b001e997eb015amr2615352oab.36.1697725864014; Thu, 19 Oct 2023 07:31:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697725863; cv=none; d=google.com; s=arc-20160816; b=IsbeTo7x2VbTANbqDc8Ssk4NJLsrk4FLk7vCQb3m1a2hlW/eFeI+isBp2z4DrGw4we ZvjWA0jJ7t1a5/K86SMVYO49nNMF73ki4bmTdz7ASsL7vJt1p05dSH5nJlInF083PfuA 4R/8xm/5cWHhSa73CD5vXlw1ej7c2r5Mk0hZEeQdBkXUpWoRxjqrawRIRW00L9L1ZYCY JZV0qEHDEAUIDfJISqPO2R1W1rrNAwM1V9vfRSNYvncMmQSSXa87Q+Gji7H7D8drjBWh feLWxdQDF7dc7JddI9lAagVtbENOokmsCrM3qNNVvEzY5U41Oaee/r9gBvVX3PooLbZ1 SqBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=hNrKy8uw5SHl33VoHbsSV7X+NyIhoa5MW6cneL8IdTE=; fh=oy3X2PWLw23jHPkfJpWDCk03+UzuARh4FsrJgw5D9Kg=; b=uftsV3Q8q/DmdbYKp6+ht6bDjMyn7Zst2Mr1EYa869C1T4Y146ps4GhJvb2e3OWy07 vglt5QQlS37DLDTmTgvXQVMljw851PIXg6VwkTqVD2nq/BK2jAbhgEcMxsBtoJhCo+cd CCpGzkUoDzgGjEZ24xft7H0Q3OAs+SvEoyCIebFTNCpyM/8nkJquUwvZstfUMN+ZK21z uvu5uI78FISUX29xXCem9GHvhHP6e4wEMTlOEmhmU1PoukAUEtl7UCZm12ocq7T6MK6H fFHhzJB7DH3yvm3OFM026kxIiDHJz9Z51CZugpDj35YJ+XxSmXRP5LHJRfZdYL2hdvJY D2+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=jUwABvaw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id a21-20020a656415000000b005b503f56f03si4595942pgv.827.2023.10.19.07.31.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 07:31:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=jUwABvaw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 8EF2E807E89B; Thu, 19 Oct 2023 07:30:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346129AbjJSO35 (ORCPT + 25 others); Thu, 19 Oct 2023 10:29:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346107AbjJSO3s (ORCPT ); Thu, 19 Oct 2023 10:29:48 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6221F12A; Thu, 19 Oct 2023 07:29:45 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id C8FEB60012; Thu, 19 Oct 2023 14:29:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697725784; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hNrKy8uw5SHl33VoHbsSV7X+NyIhoa5MW6cneL8IdTE=; b=jUwABvawl63KScnssbujvwJ8Kf7B7ctUdyuldxNvTAQmtPFor8mxs0xhLYDpkkc/XKMxkp EJkWmjmCYxZRZhH2cJ4Pjd8m1Xj95JIrHMtsltLoIjDiQdzcEVpmp1po3CN4ICqDHy8Ao5 EmTrkXBVkggYgMFqgVN4Agkl3Uvq9qCVlXKN+o1Nv6oZRovZzvqnWOjfD/jsnb4B+LksZ2 Y4Afhj6ro0e2Sr9kDLwjMiPTDtINrRfiL39cPt+wEO0gnPNXzM6dMo/GTO+aKYnbq0sO8b dF4yN/w8EIjLkE3Nnlb0s657f07f05i5TL60q4jPi5RC1n3SK0mfE7kIm9vk7g== From: =?utf-8?q?K=C3=B6ry_Maincent?= Date: Thu, 19 Oct 2023 16:29:18 +0200 Subject: [PATCH net-next v6 03/16] net: ethtool: Refactor identical get_ts_info implementations. MIME-Version: 1.0 Message-Id: <20231019-feature_ptp_netnext-v6-3-71affc27b0e5@bootlin.com> References: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> In-Reply-To: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> To: Florian Fainelli , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Radu Pirea , Jay Vosburgh , Andy Gospodarek , Nicolas Ferre , Claudiu Beznea , Willem de Bruijn , Jonathan Corbet , Horatiu Vultur , UNGLinuxDriver@microchip.com, Simon Horman , Vladimir Oltean Cc: Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Maxime Chevallier , Kory Maincent , Jay Vosburgh X-Mailer: b4 0.12.3 X-GND-Sasl: kory.maincent@bootlin.com X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 19 Oct 2023 07:30:10 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780194595668304981 X-GMAIL-MSGID: 1780194595668304981 From: Richard Cochran The vlan, macvlan and the bonding drivers call their "real" device driver in order to report the time stamping capabilities. Provide a core ethtool helper function to avoid copy/paste in the stack. Signed-off-by: Richard Cochran Signed-off-by: Kory Maincent Reviewed-by: Florian Fainelli Reviewed-by: Jay Vosburgh --- Change in v5: - Fixe typo. Change in v6: - Removed unused variable spotted by kernel test robot. --- drivers/net/bonding/bond_main.c | 29 ++--------------------------- drivers/net/macvlan.c | 14 +------------- include/linux/ethtool.h | 8 ++++++++ net/8021q/vlan_dev.c | 15 +-------------- net/ethtool/common.c | 6 ++++++ 5 files changed, 18 insertions(+), 54 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index ed7212e61c54..fe25fa59fd08 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -5749,10 +5749,8 @@ static int bond_ethtool_get_ts_info(struct net_device *bond_dev, { struct bonding *bond = netdev_priv(bond_dev); struct ethtool_ts_info ts_info; - const struct ethtool_ops *ops; struct net_device *real_dev; bool sw_tx_support = false; - struct phy_device *phydev; struct list_head *iter; struct slave *slave; int ret = 0; @@ -5763,29 +5761,12 @@ static int bond_ethtool_get_ts_info(struct net_device *bond_dev, rcu_read_unlock(); if (real_dev) { - ops = real_dev->ethtool_ops; - phydev = real_dev->phydev; - - if (phy_has_tsinfo(phydev)) { - ret = phy_ts_info(phydev, info); - goto out; - } else if (ops->get_ts_info) { - ret = ops->get_ts_info(real_dev, info); - goto out; - } + ret = ethtool_get_ts_info_by_layer(real_dev, info); } else { /* Check if all slaves support software tx timestamping */ rcu_read_lock(); bond_for_each_slave_rcu(bond, slave, iter) { - ret = -1; - ops = slave->dev->ethtool_ops; - phydev = slave->dev->phydev; - - if (phy_has_tsinfo(phydev)) - ret = phy_ts_info(phydev, &ts_info); - else if (ops->get_ts_info) - ret = ops->get_ts_info(slave->dev, &ts_info); - + ret = ethtool_get_ts_info_by_layer(slave->dev, &ts_info); if (!ret && (ts_info.so_timestamping & SOF_TIMESTAMPING_TX_SOFTWARE)) { sw_tx_support = true; continue; @@ -5797,15 +5778,9 @@ static int bond_ethtool_get_ts_info(struct net_device *bond_dev, rcu_read_unlock(); } - ret = 0; - info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE | - SOF_TIMESTAMPING_SOFTWARE; if (sw_tx_support) info->so_timestamping |= SOF_TIMESTAMPING_TX_SOFTWARE; - info->phc_index = -1; - -out: dev_put(real_dev); return ret; } diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 02bd201bc7e5..759406fbaea8 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -1086,20 +1086,8 @@ static int macvlan_ethtool_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info) { struct net_device *real_dev = macvlan_dev_real_dev(dev); - const struct ethtool_ops *ops = real_dev->ethtool_ops; - struct phy_device *phydev = real_dev->phydev; - if (phy_has_tsinfo(phydev)) { - return phy_ts_info(phydev, info); - } else if (ops->get_ts_info) { - return ops->get_ts_info(real_dev, info); - } else { - info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE | - SOF_TIMESTAMPING_SOFTWARE; - info->phc_index = -1; - } - - return 0; + return ethtool_get_ts_info_by_layer(real_dev, info); } static netdev_features_t macvlan_fix_features(struct net_device *dev, diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 62b61527bcc4..1159daac776e 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -1043,6 +1043,14 @@ static inline int ethtool_mm_frag_size_min_to_add(u32 val_min, u32 *val_add, return -EINVAL; } +/** + * ethtool_get_ts_info_by_layer - Obtains time stamping capabilities from the MAC or PHY layer. + * @dev: pointer to net_device structure + * @info: buffer to hold the result + * Returns zero on success, non-zero otherwise. + */ +int ethtool_get_ts_info_by_layer(struct net_device *dev, struct ethtool_ts_info *info); + /** * ethtool_sprintf - Write formatted string to ethtool string data * @data: Pointer to start of string to update diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index 2a7f1b15714a..407b2335f091 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c @@ -702,20 +702,7 @@ static int vlan_ethtool_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info) { const struct vlan_dev_priv *vlan = vlan_dev_priv(dev); - const struct ethtool_ops *ops = vlan->real_dev->ethtool_ops; - struct phy_device *phydev = vlan->real_dev->phydev; - - if (phy_has_tsinfo(phydev)) { - return phy_ts_info(phydev, info); - } else if (ops->get_ts_info) { - return ops->get_ts_info(vlan->real_dev, info); - } else { - info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE | - SOF_TIMESTAMPING_SOFTWARE; - info->phc_index = -1; - } - - return 0; + return ethtool_get_ts_info_by_layer(vlan->real_dev, info); } static void vlan_dev_get_stats64(struct net_device *dev, diff --git a/net/ethtool/common.c b/net/ethtool/common.c index f5598c5f50de..e2315e24d695 100644 --- a/net/ethtool/common.c +++ b/net/ethtool/common.c @@ -661,6 +661,12 @@ int ethtool_get_phc_vclocks(struct net_device *dev, int **vclock_index) } EXPORT_SYMBOL(ethtool_get_phc_vclocks); +int ethtool_get_ts_info_by_layer(struct net_device *dev, struct ethtool_ts_info *info) +{ + return __ethtool_get_ts_info(dev, info); +} +EXPORT_SYMBOL(ethtool_get_ts_info_by_layer); + const struct ethtool_phy_ops *ethtool_phy_ops; void ethtool_set_ethtool_phy_ops(const struct ethtool_phy_ops *ops) From patchwork Thu Oct 19 14:29:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?K=C3=B6ry_Maincent?= X-Patchwork-Id: 155606 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp425414vqb; Thu, 19 Oct 2023 07:31:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHLknCrARX2brh0HRRTtBbSdSIhUGfGLtoDJx97ksYs6b1j3fHqGMfxKOTaIZYQOxL0yFbI X-Received: by 2002:a05:6a21:3d85:b0:16b:c22c:f99c with SMTP id bj5-20020a056a213d8500b0016bc22cf99cmr2445075pzc.32.1697725890450; Thu, 19 Oct 2023 07:31:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697725890; cv=none; d=google.com; s=arc-20160816; b=GjgFS2aHdFdoJwhVsG6Vm2v5TMdRDuom7CIwZTfjIkpZ7QWTXGDpkvAkEs0u6jvjKF eUDisxXfQ9TIjQ97oCEgtQLEHhYRCp7gRyRA6j/3BaZfywIV10hjqb5u2gmP4ibsLDAY xpyJcCLWYXh1SchxK7xP4Sl5hDhrRoQDIvJxwmW85240VVOh0hsOgwcrWzF/Zwl02b8O 0GmlNCmECHJdfWEb5qmlwIdkhg0dpmM5EsF0p0Z23CzVUR9BJgkVbnR5GaeBdAwvGMNY IXtYTjY5ETzNbAB9NfdSNJW672CNBDggVkpd02DQ8pAvgnPN3NwC8r8S58z2ywW8wbfY BsBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=Zf35sOHFYIOY2HOVCtwWkmKHY/uNOiLiCC6UQaPPXNc=; fh=IL4Om7kRbYP5ILTMWk7kzVj5RVF0+t2ztL6E2Yzsl4U=; b=cQ5kF1i+2tXMZ8+C8oafj+vnLgcGjko+HQ2vysjSyEXf+i2QcB4+jlPVgJjsSLbRYu W7SB1v3c155p/rj49CQlWcsrMPtUFLaCzCoPIopKILoCOvjlRiYGDQQ9JteOjMb8Aodc b2/krN6xZ+bWlM14WkEqse2YywFoRNeIKdGA4qENq/Vn9PPHLFZKijJdIvLLhaVneeLl Kb6dmrkfsKC1acOXDY/Wyo/c9RxCaHlIyZkucm+w2tFDBedFTt3/ZRSKmwG6LrupKG6/ K8v7ECrkYzaaGyLG9dARiGgzesvcGS07peRxeDl5S001LR/0oXAyFYPc8ZSDSJuCC2cc 1Bgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=NN9ZUsMh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id bz8-20020a056a02060800b005638179cecasi3218388pgb.833.2023.10.19.07.31.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 07:31:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=NN9ZUsMh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 7A33E818F49E; Thu, 19 Oct 2023 07:31:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346126AbjJSOaE (ORCPT + 25 others); Thu, 19 Oct 2023 10:30:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346113AbjJSO3t (ORCPT ); Thu, 19 Oct 2023 10:29:49 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B29F49F; Thu, 19 Oct 2023 07:29:46 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 33ACC60002; Thu, 19 Oct 2023 14:29:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697725785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Zf35sOHFYIOY2HOVCtwWkmKHY/uNOiLiCC6UQaPPXNc=; b=NN9ZUsMhqwvhlll2cXv00HcKHpxLUS0bcgoPJAngyez7SxQf4K/tq1gTWEOtc9V1Rf13YU KoPBk752D+hRkJavXO5msKH6qujk70K97TGQtCAe7ptckTEYHg1RpJTbK9cgZJMrtn13Qh zuymY8vBl6ZwunHJemmiiYWTs3g+m+Ck5fQ/QYxuQfoY3u7R1SGiEGfUkSuLUJP5hY0Xs3 P26ehYf7Jd6nAUm7G+LsfFKyRaegcxes4Cwq8isLKk0OAV+7p/PxMy4I+Zdf+p+kFGzzxR z+2rt/qE0iGBnaXdj0Ju65o2EclAuehtm1ONKRwR/hD0dtjGPmJC/IhUtB4J7g== From: Kory Maincent Date: Thu, 19 Oct 2023 16:29:19 +0200 Subject: [PATCH net-next v6 04/16] net: macb: Convert to ndo_hwtstamp_get() and ndo_hwtstamp_set() MIME-Version: 1.0 Message-Id: <20231019-feature_ptp_netnext-v6-4-71affc27b0e5@bootlin.com> References: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> In-Reply-To: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> To: Florian Fainelli , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Radu Pirea , Jay Vosburgh , Andy Gospodarek , Nicolas Ferre , Claudiu Beznea , Willem de Bruijn , Jonathan Corbet , Horatiu Vultur , UNGLinuxDriver@microchip.com, Simon Horman , Vladimir Oltean Cc: Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Maxime Chevallier , Kory Maincent X-Mailer: b4 0.12.3 X-GND-Sasl: kory.maincent@bootlin.com X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 19 Oct 2023 07:31:18 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780194623338200515 X-GMAIL-MSGID: 1780194623338200515 The hardware timestamping through ndo_eth_ioctl() is going away. Convert the macb driver to the new API before that can be removed. Signed-off-by: Kory Maincent Reviewed-by: Florian Fainelli --- drivers/net/ethernet/cadence/macb.h | 15 ++++++++---- drivers/net/ethernet/cadence/macb_main.c | 42 +++++++++++++++++++++++++------- drivers/net/ethernet/cadence/macb_ptp.c | 28 ++++++++------------- 3 files changed, 53 insertions(+), 32 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h index 78c972bb1d96..aa5700ac9c00 100644 --- a/drivers/net/ethernet/cadence/macb.h +++ b/drivers/net/ethernet/cadence/macb.h @@ -1165,9 +1165,10 @@ struct macb_ptp_info { int (*get_ts_info)(struct net_device *dev, struct ethtool_ts_info *info); int (*get_hwtst)(struct net_device *netdev, - struct ifreq *ifr); + struct kernel_hwtstamp_config *tstamp_config); int (*set_hwtst)(struct net_device *netdev, - struct ifreq *ifr, int cmd); + struct kernel_hwtstamp_config *tstamp_config, + struct netlink_ext_ack *extack); }; struct macb_pm_data { @@ -1314,7 +1315,7 @@ struct macb { struct ptp_clock *ptp_clock; struct ptp_clock_info ptp_clock_info; struct tsu_incr tsu_incr; - struct hwtstamp_config tstamp_config; + struct kernel_hwtstamp_config tstamp_config; /* RX queue filer rule set*/ struct ethtool_rx_fs_list rx_fs_list; @@ -1363,8 +1364,12 @@ static inline void gem_ptp_do_rxstamp(struct macb *bp, struct sk_buff *skb, stru gem_ptp_rxstamp(bp, skb, desc); } -int gem_get_hwtst(struct net_device *dev, struct ifreq *rq); -int gem_set_hwtst(struct net_device *dev, struct ifreq *ifr, int cmd); + +int gem_get_hwtst(struct net_device *dev, + struct kernel_hwtstamp_config *tstamp_config); +int gem_set_hwtst(struct net_device *dev, + struct kernel_hwtstamp_config *tstamp_config, + struct netlink_ext_ack *extack); #else static inline void gem_ptp_init(struct net_device *ndev) { } static inline void gem_ptp_remove(struct net_device *ndev) { } diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index cebae0f418f2..898debfd4db3 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -3773,18 +3773,38 @@ static int macb_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) if (!netif_running(dev)) return -EINVAL; - if (bp->ptp_info) { - switch (cmd) { - case SIOCSHWTSTAMP: - return bp->ptp_info->set_hwtst(dev, rq, cmd); - case SIOCGHWTSTAMP: - return bp->ptp_info->get_hwtst(dev, rq); - } - } - return phylink_mii_ioctl(bp->phylink, rq, cmd); } +static int macb_hwtstamp_get(struct net_device *dev, + struct kernel_hwtstamp_config *cfg) +{ + struct macb *bp = netdev_priv(dev); + + if (!netif_running(dev)) + return -EINVAL; + + if (!bp->ptp_info) + return -EOPNOTSUPP; + + return bp->ptp_info->get_hwtst(dev, cfg); +} + +static int macb_hwtstamp_set(struct net_device *dev, + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack) +{ + struct macb *bp = netdev_priv(dev); + + if (!netif_running(dev)) + return -EINVAL; + + if (!bp->ptp_info) + return -EOPNOTSUPP; + + return bp->ptp_info->set_hwtst(dev, cfg, extack); +} + static inline void macb_set_txcsum_feature(struct macb *bp, netdev_features_t features) { @@ -3884,6 +3904,8 @@ static const struct net_device_ops macb_netdev_ops = { #endif .ndo_set_features = macb_set_features, .ndo_features_check = macb_features_check, + .ndo_hwtstamp_set = macb_hwtstamp_set, + .ndo_hwtstamp_get = macb_hwtstamp_get, }; /* Configure peripheral capabilities according to device tree @@ -4539,6 +4561,8 @@ static const struct net_device_ops at91ether_netdev_ops = { #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = at91ether_poll_controller, #endif + .ndo_hwtstamp_set = macb_hwtstamp_set, + .ndo_hwtstamp_get = macb_hwtstamp_get, }; static int at91ether_clk_init(struct platform_device *pdev, struct clk **pclk, diff --git a/drivers/net/ethernet/cadence/macb_ptp.c b/drivers/net/ethernet/cadence/macb_ptp.c index 51d26fa190d7..a63bf29c4fa8 100644 --- a/drivers/net/ethernet/cadence/macb_ptp.c +++ b/drivers/net/ethernet/cadence/macb_ptp.c @@ -374,19 +374,16 @@ static int gem_ptp_set_ts_mode(struct macb *bp, return 0; } -int gem_get_hwtst(struct net_device *dev, struct ifreq *rq) +int gem_get_hwtst(struct net_device *dev, + struct kernel_hwtstamp_config *tstamp_config) { - struct hwtstamp_config *tstamp_config; struct macb *bp = netdev_priv(dev); - tstamp_config = &bp->tstamp_config; + *tstamp_config = bp->tstamp_config; if ((bp->hw_dma_cap & HW_DMA_CAP_PTP) == 0) return -EOPNOTSUPP; - if (copy_to_user(rq->ifr_data, tstamp_config, sizeof(*tstamp_config))) - return -EFAULT; - else - return 0; + return 0; } static void gem_ptp_set_one_step_sync(struct macb *bp, u8 enable) @@ -401,22 +398,18 @@ static void gem_ptp_set_one_step_sync(struct macb *bp, u8 enable) macb_writel(bp, NCR, reg_val & ~MACB_BIT(OSSMODE)); } -int gem_set_hwtst(struct net_device *dev, struct ifreq *ifr, int cmd) +int gem_set_hwtst(struct net_device *dev, + struct kernel_hwtstamp_config *tstamp_config, + struct netlink_ext_ack *extack) { enum macb_bd_control tx_bd_control = TSTAMP_DISABLED; enum macb_bd_control rx_bd_control = TSTAMP_DISABLED; - struct hwtstamp_config *tstamp_config; struct macb *bp = netdev_priv(dev); u32 regval; - tstamp_config = &bp->tstamp_config; if ((bp->hw_dma_cap & HW_DMA_CAP_PTP) == 0) return -EOPNOTSUPP; - if (copy_from_user(tstamp_config, ifr->ifr_data, - sizeof(*tstamp_config))) - return -EFAULT; - switch (tstamp_config->tx_type) { case HWTSTAMP_TX_OFF: break; @@ -463,12 +456,11 @@ int gem_set_hwtst(struct net_device *dev, struct ifreq *ifr, int cmd) return -ERANGE; } + bp->tstamp_config = *tstamp_config; + if (gem_ptp_set_ts_mode(bp, tx_bd_control, rx_bd_control) != 0) return -ERANGE; - if (copy_to_user(ifr->ifr_data, tstamp_config, sizeof(*tstamp_config))) - return -EFAULT; - else - return 0; + return 0; } From patchwork Thu Oct 19 14:29:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?K=C3=B6ry_Maincent?= X-Patchwork-Id: 155600 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp425270vqb; Thu, 19 Oct 2023 07:31:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHlo76rjHp0rD+/dYflE+10r8PnJtmpWpUG+vZARAYnqAe49P7f7iYnt9ptT2pk9bzEGnnW X-Received: by 2002:a05:6a20:144b:b0:17b:d39c:1d6 with SMTP id a11-20020a056a20144b00b0017bd39c01d6mr384197pzi.30.1697725880216; Thu, 19 Oct 2023 07:31:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697725880; cv=none; d=google.com; s=arc-20160816; b=M8MZ+s8ThsbaX4U3JAh/mx6CL3xVGSH/cya2QLt00ET6r6a6ARObS7oqcXoPD4Yzg2 ScyiHx3cPuwo428dS4p5IwQRxSZwbCZnqCOQGTxxP6CTY+QPyTWLjvcxj8RWbnewM+yd /I2QA14CcQeJ5Z74cEynP+Ov68cIFRFBUQyl5yo8X165SfEcRNfedXkDkzdX8lTFTsF7 zUl5CedkspojuoX+V8zcQbUe+ZH6hU/0TGG/jRTx3fVZRYxx7syxy7FMywhSl2yA9RuU LrMcaJFAE/0cG3m8kvG1873MH2xioTPRkNw92J9aYYfefvymwK7oOnlxRWDwTgsj0EZJ WG7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=xcMHe82tB7onpVbG/YH4HQ63t03Vfz3gc/mKWRc+CAI=; fh=IL4Om7kRbYP5ILTMWk7kzVj5RVF0+t2ztL6E2Yzsl4U=; b=Z9nBe89Mw3RwcODYkXJ9FTB/ftLHBoRVe1Ea6mAaqNhCLBg2TgJ6IOHmb2xmSUblF4 OFssTmT0AjLQ1LeKuWkv7YUB0d63tl8PF61NS654kEF3x3q76fLYAur6L4oGBozNSyXx FgOmivHmv1cOKsUk74GYtstaTeqP7AQU9i00sZdtnkzG1IN7wVh6+Gb5eTGRNZqV9Loc W5augHxVZWIblpMY8ttZSv3NvvuJyJ8lIyw0E9uwUtOnT1A9qTRp4P+tWa8ng3iK9gR1 89Y3A3d3wM8m1RHdfxKvXm74Xbp86mWpH4l4S07bv9j+2WAKaj+i1hbNFn5aUa4o3/nz HS3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Mj1rEvY+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id 23-20020a17090a01d700b00262e3c1c1efsi2243070pjd.79.2023.10.19.07.31.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 07:31:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Mj1rEvY+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 7116C8090E9C; Thu, 19 Oct 2023 07:30:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346142AbjJSOaA (ORCPT + 25 others); Thu, 19 Oct 2023 10:30:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346123AbjJSO3u (ORCPT ); Thu, 19 Oct 2023 10:29:50 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::223]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B3C9132; Thu, 19 Oct 2023 07:29:48 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 8E27D6000D; Thu, 19 Oct 2023 14:29:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697725786; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xcMHe82tB7onpVbG/YH4HQ63t03Vfz3gc/mKWRc+CAI=; b=Mj1rEvY+y6c97LeiJ2aCQ/W/aC/HeGclbsg4EspJoHEgpIAACq3Mpda53p7I5wxKZlAs9w bsxUvzzRDGtF6oHQizZbLhJMLOfoDYPIzJvoK8CPGaxp8BHpFP5EdBOBLbwH65wifScv4I /KxcRpt6WZyZz4nNjVsaEMIO1YrokxrqCJDrzwYbOBICJ+oQ7CQxFFxjjJ1iQUls7SlZrD X0RDIZGlZRrExdzSNQVCKTVkKu7KEax37JM9Y1b05/Fb8Y2h68Tg85d+rkEYUC2frb+bjz eXobGMMLRBucwNfweVvuBMOn+OrtWrUHvX8mSdtHxFW7unEKJrRqWE4ga4MS+g== From: Kory Maincent Date: Thu, 19 Oct 2023 16:29:20 +0200 Subject: [PATCH net-next v6 05/16] net: Make dev_set_hwtstamp_phylib accessible MIME-Version: 1.0 Message-Id: <20231019-feature_ptp_netnext-v6-5-71affc27b0e5@bootlin.com> References: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> In-Reply-To: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> To: Florian Fainelli , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Radu Pirea , Jay Vosburgh , Andy Gospodarek , Nicolas Ferre , Claudiu Beznea , Willem de Bruijn , Jonathan Corbet , Horatiu Vultur , UNGLinuxDriver@microchip.com, Simon Horman , Vladimir Oltean Cc: Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Maxime Chevallier , Kory Maincent X-Mailer: b4 0.12.3 X-GND-Sasl: kory.maincent@bootlin.com X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 19 Oct 2023 07:30:21 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780194612505961723 X-GMAIL-MSGID: 1780194612505961723 Make the dev_set_hwtstamp_phylib function accessible in prevision to use it from ethtool to reset the tstamp current configuration. Signed-off-by: Kory Maincent Reviewed-by: Florian Fainelli --- Change in v6: - Add missing EXPORT_SYMBOL_GPL call. --- include/linux/netdevice.h | 3 +++ net/core/dev_ioctl.c | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index e070a4540fba..b9d0411836db 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -3922,6 +3922,9 @@ int generic_hwtstamp_get_lower(struct net_device *dev, int generic_hwtstamp_set_lower(struct net_device *dev, struct kernel_hwtstamp_config *kernel_cfg, struct netlink_ext_ack *extack); +int dev_set_hwtstamp_phylib(struct net_device *dev, + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack); int dev_ethtool(struct net *net, struct ifreq *ifr, void __user *userdata); unsigned int dev_get_flags(const struct net_device *); int __dev_change_flags(struct net_device *dev, unsigned int flags, diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c index b46aedc36939..cb60b0b9c31d 100644 --- a/net/core/dev_ioctl.c +++ b/net/core/dev_ioctl.c @@ -322,9 +322,9 @@ static int dev_get_hwtstamp(struct net_device *dev, struct ifreq *ifr) * frames and not forward them), it must set IFF_SEE_ALL_HWTSTAMP_REQUESTS in * dev->priv_flags. */ -static int dev_set_hwtstamp_phylib(struct net_device *dev, - struct kernel_hwtstamp_config *cfg, - struct netlink_ext_ack *extack) +int dev_set_hwtstamp_phylib(struct net_device *dev, + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack) { const struct net_device_ops *ops = dev->netdev_ops; bool phy_ts = phy_has_hwtstamp(dev->phydev); @@ -363,6 +363,7 @@ static int dev_set_hwtstamp_phylib(struct net_device *dev, return 0; } +EXPORT_SYMBOL_GPL(dev_set_hwtstamp_phylib); static int dev_set_hwtstamp(struct net_device *dev, struct ifreq *ifr) { From patchwork Thu Oct 19 14:29:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?K=C3=B6ry_Maincent?= X-Patchwork-Id: 155599 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp425166vqb; Thu, 19 Oct 2023 07:31:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFSonPziBzqpdct1jsFEhJGicUF8DEwwlOZhKNxRs8yUI0drh3vmJgrx9Btgm3xf/eDEWUB X-Received: by 2002:a17:90a:7f02:b0:27d:36df:8472 with SMTP id k2-20020a17090a7f0200b0027d36df8472mr2116750pjl.27.1697725871833; Thu, 19 Oct 2023 07:31:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697725871; cv=none; d=google.com; s=arc-20160816; b=pnn2cTogkK4vlPeI76g3mTteY5P9hZmsEdL/J0+ujAV2QuF0lO33z2musyPZfZHNkK fcbam1SyD9cx3D9qy487+DGLAgDylO7WgyNv55viTrBT6aNTkYR4YOBuaOQyOjyofC+c 8JIiIr97RpKqA6APFIiElEyOwdV2Tpkb26zdhN/wYet2IiNbQv4kWE6oYSrvSSfcOdj3 y/U4hEVLLXAbxfYG4fnWyl87kcaIY1C6TfMMxRCEEq2ao+t1GVMCOcGom82KnFcmqrL8 Rkp80w0tYRRySAAVz0oiue/eBwWReTkD87kX8C6ks0xgDU0ZOEGsueqCVcMm38fPHrqQ Orlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=xURoacXcM4pBrKyqRvjgBEjVThCkCkRaNKdoTaIAdxk=; fh=IL4Om7kRbYP5ILTMWk7kzVj5RVF0+t2ztL6E2Yzsl4U=; b=RRM1VA93+KEsSIkWXbVR8DHRYsHMLg6bRE69ePvXHAwIvMoqAdrppFf2ttNUyn/Q2x miztH7EqFjv22kG0mqRfYRDQB1ZGMnR6xOoIijL6XawqwhyvLB0ptSPcS1RGylfXg5Hc SPsSi9RPxWQI3hPoYRljrm2O0CihvRGUc4K/yq1Pp0ta8mch0Yd+yXNaB/tHvYKqIorG ooXXAiz9NQ7b2hAlxso1eXcDXts4WgszwDIuuOXK+f9mhsjVe+Dvogbk6jpho4b4DgDU RrXWqBLeKjh8t44Z2L/iLw7abr84mj+cJhHhQWvxOUlVxLc5ClOB2A+cCehR4YJ45qn0 juWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=k8QZBFky; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id oo11-20020a17090b1c8b00b0027cff4f35cbsi2445362pjb.73.2023.10.19.07.31.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 07:31:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=k8QZBFky; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 215F6828C490; Thu, 19 Oct 2023 07:30:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346155AbjJSOaN (ORCPT + 25 others); Thu, 19 Oct 2023 10:30:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346085AbjJSO3w (ORCPT ); Thu, 19 Oct 2023 10:29:52 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::223]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E5F1B0; Thu, 19 Oct 2023 07:29:49 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id E52E960013; Thu, 19 Oct 2023 14:29:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697725788; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xURoacXcM4pBrKyqRvjgBEjVThCkCkRaNKdoTaIAdxk=; b=k8QZBFky9wJnXKs1a2UpjYNtGxE+b27BFWRhmJB6qytTIOPL6okxgbCC+t7jhHBfkeQqI2 E5ZpHOyAUPA5X9PqgxMQNwIaEAg1PVS8pvY44gMuJE2REY9NG1uud0powJF6bB1qqoqdVp dCqiziXMSwlg4/9C1AoqKmE2vtCn05wZAV0whey8Z0epn+xNvXTqOoMmIrNhR6G1dFyP0r 3E9TtgokJECVnk0+6Hl8nl31ljpWW4OzqYTaMYdJtxILIoh4dUBoCnfe8XDrJ9m896qSqb p5fhAT/bnUDxIToikyLTX9Y7nBbpbkZ1QmMoT1wUBCvuQqcW30TkvCVB7Pavcw== From: Kory Maincent Date: Thu, 19 Oct 2023 16:29:21 +0200 Subject: [PATCH net-next v6 06/16] net: phy: micrel: fix ts_info value in case of no phc MIME-Version: 1.0 Message-Id: <20231019-feature_ptp_netnext-v6-6-71affc27b0e5@bootlin.com> References: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> In-Reply-To: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> To: Florian Fainelli , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Radu Pirea , Jay Vosburgh , Andy Gospodarek , Nicolas Ferre , Claudiu Beznea , Willem de Bruijn , Jonathan Corbet , Horatiu Vultur , UNGLinuxDriver@microchip.com, Simon Horman , Vladimir Oltean Cc: Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Maxime Chevallier , Kory Maincent X-Mailer: b4 0.12.3 X-GND-Sasl: kory.maincent@bootlin.com X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 19 Oct 2023 07:30:57 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780194603493642247 X-GMAIL-MSGID: 1780194603493642247 In case of no phc we should not return SOFTWARE TIMESTAMPING flags as we do not know whether the netdev supports of timestamping. Remove it from the lan8841_ts_info and simply return 0. Signed-off-by: Kory Maincent --- This patch is not tested but it seems consistent to me. Changes in v6: - Update the commit message. --- drivers/net/phy/micrel.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 43d072b53839..4c115e55ffc0 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -3607,12 +3607,8 @@ static int lan8841_ts_info(struct mii_timestamper *mii_ts, info->phc_index = ptp_priv->ptp_clock ? ptp_clock_index(ptp_priv->ptp_clock) : -1; - if (info->phc_index == -1) { - info->so_timestamping |= SOF_TIMESTAMPING_TX_SOFTWARE | - SOF_TIMESTAMPING_RX_SOFTWARE | - SOF_TIMESTAMPING_SOFTWARE; + if (info->phc_index == -1) return 0; - } info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE | SOF_TIMESTAMPING_RX_HARDWARE | From patchwork Thu Oct 19 14:29:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?K=C3=B6ry_Maincent?= X-Patchwork-Id: 155607 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp425462vqb; Thu, 19 Oct 2023 07:31:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFCjrM7IeupFUBiiQjlfXs4rxktii7WcWFWbMZUa+qt6Ezz+5wMPfvGnkdOMSbTwT2kPpCl X-Received: by 2002:a17:903:2308:b0:1bb:b74c:88f6 with SMTP id d8-20020a170903230800b001bbb74c88f6mr2848843plh.16.1697725896008; Thu, 19 Oct 2023 07:31:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697725895; cv=none; d=google.com; s=arc-20160816; b=gIfg+tXcKtFOjqWsxeM4swyuho+/PUMmW75K/XjioAxu+qRhTwldVU9mYb8xqs/mFi rwh3djYO+EcmsjIYx1NYddTxXsOk27wlL3ufHnB0hpoBfcaNdvbfRCkuE2dqO8jfL+T6 CpQBhjtytJcxZS+pfrmhT/9ZkR1dcsiKfScZZvKQTxqXHJQMjqKPA3L3kM074vD028ni gmSJ3Ct0YpgW28bY7ki/TCpaKOZaaw3aHocAN3tHWQvaV4JyFlOe6hYSkL+F5cjXH9nH Yswh4/m6vWqqpRpuzYMIg7xf4kQoLbveOaSWh6fxL4XbYXYElkajNKEZ86WaUolhWzY5 8lzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=10SiBN/4Fj+hMV2c6j8AN3pqV9PZiveL87TjssWFLBw=; fh=IL4Om7kRbYP5ILTMWk7kzVj5RVF0+t2ztL6E2Yzsl4U=; b=xEnRENCYJj8pc9s3RAVEBmnkzG8/4AnqvELUS+I9RtUqB9J25Qp5TnSytDD2foP/AM rMPSfiJ4Qvqybh2pPJDZTwBq5JPnuGER2Cup+MjzuV9Ym5eizhX+bbBTc5FjDCWESWRU xFkcKXWjd1RJf2oEZOXi1dJN0oXXAIAErQGxKCNIfxIHtecFyu6UHu+JeKtgQLBi/G0e X8J60c4Yvr1mIOYCKtMoOa/O9MU/9a2EaD9BH40ESEPIJ+feu3PywMZ6FbTphbFUKFG6 zYGwfJQwKSFhRc8pZ6a2nu3bl3jZZjlFeQ6It5pi0Ju46yr2llKLwvKZXlUUcEDf6p9A pP1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=gSiwOFza; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id i16-20020a17090332d000b001c0c86a541asi2418865plr.375.2023.10.19.07.31.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 07:31:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=gSiwOFza; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 38FA28061B74; Thu, 19 Oct 2023 07:30:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346169AbjJSOaH (ORCPT + 25 others); Thu, 19 Oct 2023 10:30:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346127AbjJSO3z (ORCPT ); Thu, 19 Oct 2023 10:29:55 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::223]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5E4913A; Thu, 19 Oct 2023 07:29:50 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 4241C6001E; Thu, 19 Oct 2023 14:29:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697725789; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=10SiBN/4Fj+hMV2c6j8AN3pqV9PZiveL87TjssWFLBw=; b=gSiwOFzap7y0QDq9iIecJSd5Fjz/bJ4Ru8KF5DeoJwC/X9FNV5UtG7SL1MYEUWf2aX/jzA 0UkF7GyG/yXxTYmqT4NhakfwQTB1GhVjzzJdJ2rcXseek6WV0G6PxuReaDDRYIkmNg+fiL ccUBatSZlEuEBRGgpnTxvVgRU94WbfuEBvnwSVnYiv0AGVEYGGpiheiJ0Lv2w6lL1Pdpst bjfJAIPT+nsrL9in9TB/H/CuMAm2lyz0G9cWPXYIwI35wQsdmC2nt3WZXvHwgkZ92DUm82 G8iNmM4AJxjYAoWHvk1Ta73SEnaL8SOlQyF2F8jW3O0EOqgVEeeqg/yD7VnISQ== From: Kory Maincent Date: Thu, 19 Oct 2023 16:29:22 +0200 Subject: [PATCH net-next v6 07/16] net_tstamp: Add TIMESTAMPING SOFTWARE and HARDWARE mask MIME-Version: 1.0 Message-Id: <20231019-feature_ptp_netnext-v6-7-71affc27b0e5@bootlin.com> References: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> In-Reply-To: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> To: Florian Fainelli , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Radu Pirea , Jay Vosburgh , Andy Gospodarek , Nicolas Ferre , Claudiu Beznea , Willem de Bruijn , Jonathan Corbet , Horatiu Vultur , UNGLinuxDriver@microchip.com, Simon Horman , Vladimir Oltean Cc: Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Maxime Chevallier , Kory Maincent X-Mailer: b4 0.12.3 X-GND-Sasl: kory.maincent@bootlin.com X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,URIBL_BLOCKED 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 19 Oct 2023 07:30:21 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780194629238521999 X-GMAIL-MSGID: 1780194629238521999 Timestamping software or hardware flags are often used as a group, therefore adding these masks will easier future use. I did not use SOF_TIMESTAMPING_SYS_HARDWARE flag as it is deprecated and not use at all. Signed-off-by: Kory Maincent --- include/uapi/linux/net_tstamp.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/uapi/linux/net_tstamp.h b/include/uapi/linux/net_tstamp.h index a2c66b3d7f0f..df8091998c8d 100644 --- a/include/uapi/linux/net_tstamp.h +++ b/include/uapi/linux/net_tstamp.h @@ -48,6 +48,14 @@ enum { SOF_TIMESTAMPING_TX_SCHED | \ SOF_TIMESTAMPING_TX_ACK) +#define SOF_TIMESTAMPING_SOFTWARE_MASK (SOF_TIMESTAMPING_RX_SOFTWARE | \ + SOF_TIMESTAMPING_TX_SOFTWARE | \ + SOF_TIMESTAMPING_SOFTWARE) + +#define SOF_TIMESTAMPING_HARDWARE_MASK (SOF_TIMESTAMPING_RX_HARDWARE | \ + SOF_TIMESTAMPING_TX_HARDWARE | \ + SOF_TIMESTAMPING_RAW_HARDWARE) + /** * struct so_timestamping - SO_TIMESTAMPING parameter * From patchwork Thu Oct 19 14:29:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?K=C3=B6ry_Maincent?= X-Patchwork-Id: 155608 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp425468vqb; Thu, 19 Oct 2023 07:31:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGJxQaHNR7aEnUE1TPdRemsEBZFlPwwupN/BR7Yr+zXRcR/Vk1TSnRabRblURZKjCLMshqy X-Received: by 2002:a17:90b:90c:b0:27d:237b:558b with SMTP id bo12-20020a17090b090c00b0027d237b558bmr2261068pjb.5.1697725896128; Thu, 19 Oct 2023 07:31:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697725896; cv=none; d=google.com; s=arc-20160816; b=xU+XcYtyxk4xKMW4BVG82iscVQMqw5mfPq+MoC9dsvpg8jvnQJtb6UTt5aH50x5nAF R+7jKswimmtk6YG2mHSsPd3dptT0eB8/lmt0kc04bRehEq9jx/LZbHKiWMoccHGek6T7 EDOSHxkL9dcEZPqhXJ/2l5R9gLuOie+p1/xgXIOFYrAZ4ekCerMjW17l8TxVS3/7Znu7 p3ze/84eDo6TrkZU40aDncOVgtnMRdyCxVCyVLI7IqqEDMjJFJ9KMmYyrgt/SFW2p/wG TVFAWMBySED37tEkKZPkP4ORSUYSYXKzvcxzlBp5xEI0d/czRX/Nrv7pJIOt7kV4TpL8 HaOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=invxvvsNyaslfuOag5qFd3lmUeCZ/b8fEn5ZKD3SNsQ=; fh=IL4Om7kRbYP5ILTMWk7kzVj5RVF0+t2ztL6E2Yzsl4U=; b=qC7kgYH9ZBgJYVZNs+N7YQ3axPxbB69civwUdYIBlqeyZr6uRMsunFZ6XsxwrTBNkc lY8Xcs+ynDeTkApEf2EsVGhtyyMTu/aG3RsK1bu+/CzrG5wunaWl5TjjaW+ZxFkHZ2+p ERn6PpEqnfnz8nQmZ4534onrS0qEyD9en8bGjgdvR0lk7nBFtOgX3shLQbbtzxvSesBT MtVT1ym5q4FoBtotjVM8xgeXWIaK7YpRI9yiVRcXftMB9i2+e4cT5sNB7ISQWGsN3dbo BOHzfDIzVhT9rMhlnQR3j8yhP4nULn1r9WzFX80DsWG1Fyr3UaW5lIZb0L5iEkLNlAXv B7Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=jO3J2Ka4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id c6-20020a17090ad90600b002568a675b65si2285266pjv.141.2023.10.19.07.31.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 07:31:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=jO3J2Ka4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 40C3D8097892; Thu, 19 Oct 2023 07:30:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346151AbjJSOaR (ORCPT + 25 others); Thu, 19 Oct 2023 10:30:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346140AbjJSO34 (ORCPT ); Thu, 19 Oct 2023 10:29:56 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::223]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44A43181; Thu, 19 Oct 2023 07:29:52 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 9C53760005; Thu, 19 Oct 2023 14:29:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697725790; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=invxvvsNyaslfuOag5qFd3lmUeCZ/b8fEn5ZKD3SNsQ=; b=jO3J2Ka4XF10T0+NOLw84LSwvILNZNBjDL3f2yR5bi/gwhoVsZU4pY2Vn9exOTP3GuQ5dp k34SJ1O24Gn8izKa75kiBJ3P5b3zDwlQ8HLcNZq0G6sfgqNKxOTziDIBoeN0OsgAAG4alA Yv8G44DxedX/3fylWJJZqyROt0CKWPhQGoPaKoPp+jNc6IkmseSNCIu21vjQbQi5Z+Dl3v rgBWMNqnKJJobTLbExlKoWDqLSFulEZiiteExorWHq7yxcXbfvPCyI39iytKIaBYUD0I4F sPclCslI7n21o6EbG9FyhMmSI1/mmsSk4mKWLeX/pkylc6QPj9ktghlbyxu82w== From: Kory Maincent Date: Thu, 19 Oct 2023 16:29:23 +0200 Subject: [PATCH net-next v6 08/16] net: ethtool: Add a command to expose current time stamping layer MIME-Version: 1.0 Message-Id: <20231019-feature_ptp_netnext-v6-8-71affc27b0e5@bootlin.com> References: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> In-Reply-To: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> To: Florian Fainelli , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Radu Pirea , Jay Vosburgh , Andy Gospodarek , Nicolas Ferre , Claudiu Beznea , Willem de Bruijn , Jonathan Corbet , Horatiu Vultur , UNGLinuxDriver@microchip.com, Simon Horman , Vladimir Oltean Cc: Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Maxime Chevallier , Kory Maincent X-Mailer: b4 0.12.3 X-GND-Sasl: kory.maincent@bootlin.com X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,URIBL_BLOCKED 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 19 Oct 2023 07:30:30 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780194629268760718 X-GMAIL-MSGID: 1780194629268760718 Time stamping on network packets may happen either in the MAC or in the PHY, but not both. In preparation for making the choice selectable, expose both the current layers via ethtool. In accordance with the kernel implementation as it stands, the current layer will always read as "phy" when a PHY time stamping device is present. Future patches will allow changing the current layer administratively. Signed-off-by: Kory Maincent --- Changes in v2: - Move the introduction of selected_timestamping_layer variable in next patch. Changes in v3: - Move on to ethtool instead of syfs Changes in v4: - Move on to netlink ethtool instead of ioctl. I am not familiar with netlink so there might be some code that does not follow the good code practice. Changes in v5: - Rename timestamping layers. - Set a default value of ts_layer in __ethtool_get_ts_info function. - Separate TS_GET and TS_LIST_GET ethtool command in two separate patches. - Update documentation. Changes in v6: - Moved back to a timestamping_layer simple enum. - Moved back to MAC/PHY_TIMESTAMING namings. - Add SOFTWARE timestamping description. --- Documentation/networking/ethtool-netlink.rst | 23 ++++++++ include/uapi/linux/ethtool_netlink.h | 14 +++++ include/uapi/linux/net_tstamp.h | 10 ++++ net/ethtool/Makefile | 2 +- net/ethtool/common.h | 1 + net/ethtool/netlink.c | 10 ++++ net/ethtool/netlink.h | 2 + net/ethtool/ts.c | 88 ++++++++++++++++++++++++++++ 8 files changed, 149 insertions(+), 1 deletion(-) diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/networking/ethtool-netlink.rst index 2540c70952ff..644b3b764044 100644 --- a/Documentation/networking/ethtool-netlink.rst +++ b/Documentation/networking/ethtool-netlink.rst @@ -225,6 +225,7 @@ Userspace to kernel: ``ETHTOOL_MSG_RSS_GET`` get RSS settings ``ETHTOOL_MSG_MM_GET`` get MAC merge layer state ``ETHTOOL_MSG_MM_SET`` set MAC merge layer parameters + ``ETHTOOL_MSG_TS_GET`` get current timestamping ===================================== ================================= Kernel to userspace: @@ -268,6 +269,7 @@ Kernel to userspace: ``ETHTOOL_MSG_PSE_GET_REPLY`` PSE parameters ``ETHTOOL_MSG_RSS_GET_REPLY`` RSS settings ``ETHTOOL_MSG_MM_GET_REPLY`` MAC merge layer status + ``ETHTOOL_MSG_TS_GET_REPLY`` current timestamping ======================================== ================================= ``GET`` requests are sent by userspace applications to retrieve device @@ -1994,6 +1996,26 @@ The attributes are propagated to the driver through the following structure: .. kernel-doc:: include/linux/ethtool.h :identifiers: ethtool_mm_cfg +TS_GET +====== + +Gets current timestamping. + +Request contents: + + ================================= ====== ==================== + ``ETHTOOL_A_TS_HEADER`` nested request header + ================================= ====== ==================== + +Kernel response contents: + + ======================= ====== ============================== + ``ETHTOOL_A_TS_HEADER`` nested reply header + ``ETHTOOL_A_TS_LAYER`` u32 current timestamping + ======================= ====== ============================== + +This command get the current timestamp layer. + Request translation =================== @@ -2100,4 +2122,5 @@ are netlink only. n/a ``ETHTOOL_MSG_PLCA_GET_STATUS`` n/a ``ETHTOOL_MSG_MM_GET`` n/a ``ETHTOOL_MSG_MM_SET`` + n/a ``ETHTOOL_MSG_TS_GET`` =================================== ===================================== diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h index 73e2c10dc2cc..cb51136328cf 100644 --- a/include/uapi/linux/ethtool_netlink.h +++ b/include/uapi/linux/ethtool_netlink.h @@ -57,6 +57,7 @@ enum { ETHTOOL_MSG_PLCA_GET_STATUS, ETHTOOL_MSG_MM_GET, ETHTOOL_MSG_MM_SET, + ETHTOOL_MSG_TS_GET, /* add new constants above here */ __ETHTOOL_MSG_USER_CNT, @@ -109,6 +110,7 @@ enum { ETHTOOL_MSG_PLCA_NTF, ETHTOOL_MSG_MM_GET_REPLY, ETHTOOL_MSG_MM_NTF, + ETHTOOL_MSG_TS_GET_REPLY, /* add new constants above here */ __ETHTOOL_MSG_KERNEL_CNT, @@ -975,6 +977,18 @@ enum { ETHTOOL_A_MM_MAX = (__ETHTOOL_A_MM_CNT - 1) }; +/* TS LAYER */ + +enum { + ETHTOOL_A_TS_UNSPEC, + ETHTOOL_A_TS_HEADER, /* nest - _A_HEADER_* */ + ETHTOOL_A_TS_LAYER, /* u32 */ + + /* add new constants above here */ + __ETHTOOL_A_TS_CNT, + ETHTOOL_A_TS_MAX = (__ETHTOOL_A_TS_CNT - 1) +}; + /* generic netlink info */ #define ETHTOOL_GENL_NAME "ethtool" #define ETHTOOL_GENL_VERSION 1 diff --git a/include/uapi/linux/net_tstamp.h b/include/uapi/linux/net_tstamp.h index df8091998c8d..4551fb3d7720 100644 --- a/include/uapi/linux/net_tstamp.h +++ b/include/uapi/linux/net_tstamp.h @@ -13,6 +13,16 @@ #include #include /* for SO_TIMESTAMPING */ +/* Layer of the TIMESTAMPING provider */ +enum timestamping_layer { + NO_TIMESTAMPING, + SOFTWARE_TIMESTAMPING, + MAC_TIMESTAMPING, + PHY_TIMESTAMPING, + + __TIMESTAMPING_COUNT, +}; + /* SO_TIMESTAMPING flags */ enum { SOF_TIMESTAMPING_TX_HARDWARE = (1<<0), diff --git a/net/ethtool/Makefile b/net/ethtool/Makefile index 504f954a1b28..4ea64c080639 100644 --- a/net/ethtool/Makefile +++ b/net/ethtool/Makefile @@ -8,4 +8,4 @@ ethtool_nl-y := netlink.o bitset.o strset.o linkinfo.o linkmodes.o rss.o \ linkstate.o debug.o wol.o features.o privflags.o rings.o \ channels.o coalesce.o pause.o eee.o tsinfo.o cabletest.o \ tunnels.o fec.o eeprom.o stats.o phc_vclocks.o mm.o \ - module.o pse-pd.o plca.o mm.o + module.o pse-pd.o plca.o mm.o ts.o diff --git a/net/ethtool/common.h b/net/ethtool/common.h index 28b8aaaf9bcb..a264b635f7d3 100644 --- a/net/ethtool/common.h +++ b/net/ethtool/common.h @@ -35,6 +35,7 @@ extern const char wol_mode_names[][ETH_GSTRING_LEN]; extern const char sof_timestamping_names[][ETH_GSTRING_LEN]; extern const char ts_tx_type_names[][ETH_GSTRING_LEN]; extern const char ts_rx_filter_names[][ETH_GSTRING_LEN]; +extern const char ts_layer_names[][ETH_GSTRING_LEN]; extern const char udp_tunnel_type_names[][ETH_GSTRING_LEN]; int __ethtool_get_link(struct net_device *dev); diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c index 3bbd5afb7b31..561c0931d055 100644 --- a/net/ethtool/netlink.c +++ b/net/ethtool/netlink.c @@ -306,6 +306,7 @@ ethnl_default_requests[__ETHTOOL_MSG_USER_CNT] = { [ETHTOOL_MSG_PLCA_GET_STATUS] = ðnl_plca_status_request_ops, [ETHTOOL_MSG_MM_GET] = ðnl_mm_request_ops, [ETHTOOL_MSG_MM_SET] = ðnl_mm_request_ops, + [ETHTOOL_MSG_TS_GET] = ðnl_ts_request_ops, }; static struct ethnl_dump_ctx *ethnl_dump_context(struct netlink_callback *cb) @@ -1128,6 +1129,15 @@ static const struct genl_ops ethtool_genl_ops[] = { .policy = ethnl_mm_set_policy, .maxattr = ARRAY_SIZE(ethnl_mm_set_policy) - 1, }, + { + .cmd = ETHTOOL_MSG_TS_GET, + .doit = ethnl_default_doit, + .start = ethnl_default_start, + .dumpit = ethnl_default_dumpit, + .done = ethnl_default_done, + .policy = ethnl_ts_get_policy, + .maxattr = ARRAY_SIZE(ethnl_ts_get_policy) - 1, + }, }; static const struct genl_multicast_group ethtool_nl_mcgrps[] = { diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h index 9a333a8d04c1..1e6085198acc 100644 --- a/net/ethtool/netlink.h +++ b/net/ethtool/netlink.h @@ -395,6 +395,7 @@ extern const struct ethnl_request_ops ethnl_rss_request_ops; extern const struct ethnl_request_ops ethnl_plca_cfg_request_ops; extern const struct ethnl_request_ops ethnl_plca_status_request_ops; extern const struct ethnl_request_ops ethnl_mm_request_ops; +extern const struct ethnl_request_ops ethnl_ts_request_ops; extern const struct nla_policy ethnl_header_policy[ETHTOOL_A_HEADER_FLAGS + 1]; extern const struct nla_policy ethnl_header_policy_stats[ETHTOOL_A_HEADER_FLAGS + 1]; @@ -441,6 +442,7 @@ extern const struct nla_policy ethnl_plca_set_cfg_policy[ETHTOOL_A_PLCA_MAX + 1] extern const struct nla_policy ethnl_plca_get_status_policy[ETHTOOL_A_PLCA_HEADER + 1]; extern const struct nla_policy ethnl_mm_get_policy[ETHTOOL_A_MM_HEADER + 1]; extern const struct nla_policy ethnl_mm_set_policy[ETHTOOL_A_MM_MAX + 1]; +extern const struct nla_policy ethnl_ts_get_policy[ETHTOOL_A_TS_HEADER + 1]; int ethnl_set_features(struct sk_buff *skb, struct genl_info *info); int ethnl_act_cable_test(struct sk_buff *skb, struct genl_info *info); diff --git a/net/ethtool/ts.c b/net/ethtool/ts.c new file mode 100644 index 000000000000..066cb06f4d0b --- /dev/null +++ b/net/ethtool/ts.c @@ -0,0 +1,88 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include + +#include "netlink.h" +#include "common.h" +#include "bitset.h" + +struct ts_req_info { + struct ethnl_req_info base; +}; + +struct ts_reply_data { + struct ethnl_reply_data base; + enum timestamping_layer ts_layer; +}; + +#define TS_REPDATA(__reply_base) \ + container_of(__reply_base, struct ts_reply_data, base) + +/* TS_GET */ +const struct nla_policy ethnl_ts_get_policy[] = { + [ETHTOOL_A_TS_HEADER] = + NLA_POLICY_NESTED(ethnl_header_policy), +}; + +static int ts_prepare_data(const struct ethnl_req_info *req_base, + struct ethnl_reply_data *reply_base, + const struct genl_info *info) +{ + struct ts_reply_data *data = TS_REPDATA(reply_base); + struct net_device *dev = reply_base->dev; + const struct ethtool_ops *ops = dev->ethtool_ops; + int ret; + + ret = ethnl_ops_begin(dev); + if (ret < 0) + return ret; + + if (phy_has_tsinfo(dev->phydev)) { + data->ts_layer = PHY_TIMESTAMPING; + } else if (ops->get_ts_info) { + struct ethtool_ts_info ts_info = {0}; + + ops->get_ts_info(dev, &ts_info); + if (ts_info.so_timestamping & + SOF_TIMESTAMPING_HARDWARE_MASK) + data->ts_layer = MAC_TIMESTAMPING; + + if (ts_info.so_timestamping & + SOF_TIMESTAMPING_SOFTWARE_MASK) + data->ts_layer = SOFTWARE_TIMESTAMPING; + } else { + data->ts_layer = NO_TIMESTAMPING; + } + + ethnl_ops_complete(dev); + + return ret; +} + +static int ts_reply_size(const struct ethnl_req_info *req_base, + const struct ethnl_reply_data *reply_base) +{ + return nla_total_size(sizeof(u32)); +} + +static int ts_fill_reply(struct sk_buff *skb, + const struct ethnl_req_info *req_base, + const struct ethnl_reply_data *reply_base) +{ + struct ts_reply_data *data = TS_REPDATA(reply_base); + + return nla_put_u32(skb, ETHTOOL_A_TS_LAYER, data->ts_layer); +} + +const struct ethnl_request_ops ethnl_ts_request_ops = { + .request_cmd = ETHTOOL_MSG_TS_GET, + .reply_cmd = ETHTOOL_MSG_TS_GET_REPLY, + .hdr_attr = ETHTOOL_A_TS_HEADER, + .req_info_size = sizeof(struct ts_req_info), + .reply_data_size = sizeof(struct ts_reply_data), + + .prepare_data = ts_prepare_data, + .reply_size = ts_reply_size, + .fill_reply = ts_fill_reply, +}; From patchwork Thu Oct 19 14:29:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?K=C3=B6ry_Maincent?= X-Patchwork-Id: 155598 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp425122vqb; Thu, 19 Oct 2023 07:31:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH8VxzZF9/0zYBY6LOcYC4SbBiXO8o+Rm6y06l6IjD1j9F7AmUNCFBAt0Snxlr3eFX9Qg3S X-Received: by 2002:a17:90a:cb98:b0:27d:2763:a13a with SMTP id a24-20020a17090acb9800b0027d2763a13amr2065006pju.48.1697725868520; Thu, 19 Oct 2023 07:31:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697725868; cv=none; d=google.com; s=arc-20160816; b=t4irkinkKh1DClXLgkszYrwohuaT+XgSH4pT9pEkMd4l/BaFz/fVx+0w5YmZ/SMYq8 XplEi1SFQucGkMaTRBKcmZF19z3yMymY5i9Hle1saQKvs7aaYAWywwX8jEeGNGx/sexK MfNSSiD0YW20ezstufLptbZRLmCF2+FEYHcFcQCjzlE6ZfRilbJJ3RqNOJdSE63vmwtf emBpRhp2HGthHIbhwjWeebilNOYlw0+eDxisDrRKaHOGOGVs7xpSlfzDjQKuZMmehUKx ehMi8h93mM+CQaVlYv0NOLiEf86o9isbQ1zyrxbZuVjOk1fBG3j7JjsD8fvy8L8I7Svh J7vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=sa/BMAPjdibMp7a6uAHIuRY7wsT4sAFdEpwtOTUVtjo=; fh=IL4Om7kRbYP5ILTMWk7kzVj5RVF0+t2ztL6E2Yzsl4U=; b=vVJfae+zGL+i7RTsr3bnxZdMHRSTnP/JPaXinSecgJr8j8v8ILJn3rezaHWG3gAhba C+yWXyZziBGfyZ88AU0F5gVXKA2qjw/PVnff0OGGukYp7uLvzbQpheuv8c9jQkCA9pxr zdqUETKB3R6XiFJrC/6Gt7GBDBKK6MXZc/WzRWEE/FaHLxTbHxbg0XE2/eE+ZyS+J6wi OOfNbA+UcPm5ZYOjS70m25toS/bYiv2CqP0X2k79mLnta10rI4OdMmmRoU+PXNXfqsEb RUSn75y/T9mI625of9k/F6GYpboUL+gy4xT+dB9hqJOaOcFYZDFolw+YxFrsosOGkcWr NAGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=MrW0+v9R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id bu23-20020a632957000000b005655e87c8aasi4476199pgb.192.2023.10.19.07.31.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 07:31:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=MrW0+v9R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 763768088A55; Thu, 19 Oct 2023 07:30:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346027AbjJSOaV (ORCPT + 25 others); Thu, 19 Oct 2023 10:30:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346121AbjJSO34 (ORCPT ); Thu, 19 Oct 2023 10:29:56 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A3AD18B; Thu, 19 Oct 2023 07:29:53 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id F03E660004; Thu, 19 Oct 2023 14:29:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697725792; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sa/BMAPjdibMp7a6uAHIuRY7wsT4sAFdEpwtOTUVtjo=; b=MrW0+v9R9WtBjTYkzv16CJrNc9tDAoKkbOUU+KGqO8W+Yk4rna+ZJMqgMSNt1CYcnCdP8l /aGUjxP3dSpbjlaOLyRcbuaqY8YByCgC29BTV4firAUaCZFOyc98lTjJoKi3D1ijFFsRNr tkzuPWl97cO/SzYOUtraE72E2SSRHR258buBUC42zbPuOo8CQE3w6/FrgjfdyhmYQfNa22 RtbXlw25FRuhkVrQq9ynBDmiJzipq2X89YOOU3pvTcqIIBzNFjKhXIhDj7SuduOaj30MvJ ykPveZuiJjbZ5o+L5VcJuCAf1W6s73h80d9FiZNtD0xhYqxbUSzEm4QpOCi2wQ== From: Kory Maincent Date: Thu, 19 Oct 2023 16:29:24 +0200 Subject: [PATCH net-next v6 09/16] netlink: specs: Introduce new netlink command to get current timestamp MIME-Version: 1.0 Message-Id: <20231019-feature_ptp_netnext-v6-9-71affc27b0e5@bootlin.com> References: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> In-Reply-To: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> To: Florian Fainelli , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Radu Pirea , Jay Vosburgh , Andy Gospodarek , Nicolas Ferre , Claudiu Beznea , Willem de Bruijn , Jonathan Corbet , Horatiu Vultur , UNGLinuxDriver@microchip.com, Simon Horman , Vladimir Oltean Cc: Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Maxime Chevallier , Kory Maincent X-Mailer: b4 0.12.3 X-GND-Sasl: kory.maincent@bootlin.com X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 19 Oct 2023 07:30:36 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780194600054713724 X-GMAIL-MSGID: 1780194600054713724 Add a new commands allowing to get the current time stamping on a netdevice's link. Example usage : ./ynl/cli.py --spec netlink/specs/ethtool.yaml --no-schema --do ts-get \ --json '{"header":{"dev-name":"eth0"}}' {'header': {'dev-index': 3, 'dev-name': 'eth0'}, 'ts-layer': 1} Signed-off-by: Kory Maincent --- Documentation/netlink/specs/ethtool.yaml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Documentation/netlink/specs/ethtool.yaml b/Documentation/netlink/specs/ethtool.yaml index 837b565577ca..49ee028e97ca 100644 --- a/Documentation/netlink/specs/ethtool.yaml +++ b/Documentation/netlink/specs/ethtool.yaml @@ -942,6 +942,16 @@ attribute-sets: - name: burst-tmr type: u32 + - + name: ts + attributes: + - + name: header + type: nest + nested-attributes: header + - + name: ts-layer + type: u32 operations: enum-model: directional @@ -1692,3 +1702,17 @@ operations: name: mm-ntf doc: Notification for change in MAC Merge configuration. notify: mm-get + - + name: ts-get + doc: Get current timestamp + + attribute-set: ts + + do: + request: + attributes: + - header + reply: + attributes: &ts + - header + - ts-layer From patchwork Thu Oct 19 14:29:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?K=C3=B6ry_Maincent?= X-Patchwork-Id: 155596 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp424803vqb; Thu, 19 Oct 2023 07:30:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFedAUS2X04QxHSvKbNXmmxNwfoNf52XtYGXn+kG79T67S/vinsIOJShQSPHx5NH0xT3qIn X-Received: by 2002:a05:6a20:da83:b0:163:2dc7:d077 with SMTP id iy3-20020a056a20da8300b001632dc7d077mr2743996pzb.55.1697725845069; Thu, 19 Oct 2023 07:30:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697725845; cv=none; d=google.com; s=arc-20160816; b=gFHg08/aDZ8fBG/zB+mUgcJfd6ylsyFtmo1YU0GpA+Z56jsOHFlIXEG/E4Sf02QBiw iH/4XC3U1e/El1nCKv0171KNs8LKJMtX2lFpwy4H9VddlyW8V/t4cV1vtCkyjyZSpm/C LSqf9B2lrbWuQzsRs4oaMKxm4JfGrGa2EmmPM3lMyjPkOPhobEJXsKAx7IgOpWvZZSnH g2Ibxnoc5IRsVnHJwwgl0H2N1y7i9H9ZM7i+mwGYW0BHmVJe+g6lf4qkg9trAKZqRJJ5 BuNwXgrszmsq+dkZ+k5g3alvQ/KRWVcxoPJzbzmjUUMQ57FCCjQ1tLvN/IXzJTRhCruo wN9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=fXT31FTOUqcM10CroXu4aVSiZjypnHDgcymgM7kbFM4=; fh=IL4Om7kRbYP5ILTMWk7kzVj5RVF0+t2ztL6E2Yzsl4U=; b=cTw7PVgWYCyjQR69Ji2xxw1s4JX/gOPPd5UC/hBfiI/vf3JJMK2VqBvk0aosHCShrl 3Wi3U/YADOMcp0ss0jYx98++ZxYijqAoLDSWrrvfK86u51GlqVf5Bvgy7e0i0okkSE6R +Z/8Odq5Pu20tw60JkiC5pLjGxqmEHLpBNfbe2c0lrXWMTvPfg8aybPYEiPJIKx5XjMO i1EDMSzI12kaNXD7cggST25SHtHlgAdEZq8UVozhn4mhyK35btc1aZjtg9Plx4LHYgzC Racu7rkH1O9zp+/WdVLFBuQRt3QyL3NxvAlEWg43ytwTgZCc52+8h+7wTR3ZmhDgPF89 f4TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=GQzsE9LO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id h12-20020a170902f54c00b001bf1a9dbcc9si2351389plf.549.2023.10.19.07.30.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 07:30:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=GQzsE9LO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 04D49832A050; Thu, 19 Oct 2023 07:30:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346145AbjJSOaZ (ORCPT + 25 others); Thu, 19 Oct 2023 10:30:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346147AbjJSO36 (ORCPT ); Thu, 19 Oct 2023 10:29:58 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1162B9F; Thu, 19 Oct 2023 07:29:54 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 63E7B60018; Thu, 19 Oct 2023 14:29:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697725793; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fXT31FTOUqcM10CroXu4aVSiZjypnHDgcymgM7kbFM4=; b=GQzsE9LOAc9yVRpDqtAFmDec2M9+tXyibFHt0cWDb30GNdr00SkgLY/Skzs9sfT4c1khrE 8TtdaP0mei35t5kpLZMbd3xQMl055QorpSeKIpCLzPpPp8ZIy+7oHHsuFQ21zeYkbusKlz qbuOn72KwD0lTDyHPizK9eGyKMcKFn8JnDsqYHQHzU8Q+5w7etliK//Khe9ibGdQPBT0IG d4wvJZU3Mw2OW1aX1VwsbP9OUGSOcivIH5spgQ14+G/RbbQljResE0RW7QISlZhydO/Q/v BWVT89RAiwhCLMKYfgy0866S5GTLy/T4bLKHqxDFhLC9dY/p+GGRZs9G7wx8bw== From: Kory Maincent Date: Thu, 19 Oct 2023 16:29:25 +0200 Subject: [PATCH net-next v6 10/16] net: ethtool: Add a command to list available time stamping layers MIME-Version: 1.0 Message-Id: <20231019-feature_ptp_netnext-v6-10-71affc27b0e5@bootlin.com> References: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> In-Reply-To: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> To: Florian Fainelli , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Radu Pirea , Jay Vosburgh , Andy Gospodarek , Nicolas Ferre , Claudiu Beznea , Willem de Bruijn , Jonathan Corbet , Horatiu Vultur , UNGLinuxDriver@microchip.com, Simon Horman , Vladimir Oltean Cc: Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Maxime Chevallier , Kory Maincent X-Mailer: b4 0.12.3 X-GND-Sasl: kory.maincent@bootlin.com X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 19 Oct 2023 07:30:41 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780194575921115641 X-GMAIL-MSGID: 1780194575921115641 Introduce a new netlink message that lists all available time stamping layers on a given interface. Signed-off-by: Kory Maincent --- Changes in v6: - Fix Documentation typos. - Follow timestamping layer naming update. --- Documentation/networking/ethtool-netlink.rst | 23 +++++++++ include/uapi/linux/ethtool_netlink.h | 14 ++++++ net/ethtool/netlink.c | 10 ++++ net/ethtool/netlink.h | 1 + net/ethtool/ts.c | 73 ++++++++++++++++++++++++++++ 5 files changed, 121 insertions(+) diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/networking/ethtool-netlink.rst index 644b3b764044..b8d00676ed82 100644 --- a/Documentation/networking/ethtool-netlink.rst +++ b/Documentation/networking/ethtool-netlink.rst @@ -226,6 +226,7 @@ Userspace to kernel: ``ETHTOOL_MSG_MM_GET`` get MAC merge layer state ``ETHTOOL_MSG_MM_SET`` set MAC merge layer parameters ``ETHTOOL_MSG_TS_GET`` get current timestamping + ``ETHTOOL_MSG_TS_LIST_GET`` list available timestampings ===================================== ================================= Kernel to userspace: @@ -270,6 +271,7 @@ Kernel to userspace: ``ETHTOOL_MSG_RSS_GET_REPLY`` RSS settings ``ETHTOOL_MSG_MM_GET_REPLY`` MAC merge layer status ``ETHTOOL_MSG_TS_GET_REPLY`` current timestamping + ``ETHTOOL_MSG_TS_LIST_GET_REPLY`` available timestampings ======================================== ================================= ``GET`` requests are sent by userspace applications to retrieve device @@ -2016,6 +2018,26 @@ Kernel response contents: This command get the current timestamp layer. +TS_LIST_GET +=========== + +Get the list of available timestampings. + +Request contents: + + ================================= ====== ==================== + ``ETHTOOL_A_TS_HEADER`` nested request header + ================================= ====== ==================== + +Kernel response contents: + + =========================== ====== ============================== + ``ETHTOOL_A_TS_HEADER`` nested reply header + ``ETHTOOL_A_TS_LIST_LAYER`` binary available timestampings + =========================== ====== ============================== + +This command lists all the possible timestamp layer available. + Request translation =================== @@ -2123,4 +2145,5 @@ are netlink only. n/a ``ETHTOOL_MSG_MM_GET`` n/a ``ETHTOOL_MSG_MM_SET`` n/a ``ETHTOOL_MSG_TS_GET`` + n/a ``ETHTOOL_MSG_TS_LIST_GET`` =================================== ===================================== diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h index cb51136328cf..62b885d44d06 100644 --- a/include/uapi/linux/ethtool_netlink.h +++ b/include/uapi/linux/ethtool_netlink.h @@ -58,6 +58,7 @@ enum { ETHTOOL_MSG_MM_GET, ETHTOOL_MSG_MM_SET, ETHTOOL_MSG_TS_GET, + ETHTOOL_MSG_TS_LIST_GET, /* add new constants above here */ __ETHTOOL_MSG_USER_CNT, @@ -111,6 +112,7 @@ enum { ETHTOOL_MSG_MM_GET_REPLY, ETHTOOL_MSG_MM_NTF, ETHTOOL_MSG_TS_GET_REPLY, + ETHTOOL_MSG_TS_LIST_GET_REPLY, /* add new constants above here */ __ETHTOOL_MSG_KERNEL_CNT, @@ -989,6 +991,18 @@ enum { ETHTOOL_A_TS_MAX = (__ETHTOOL_A_TS_CNT - 1) }; +/* TS LIST LAYER */ + +enum { + ETHTOOL_A_TS_LIST_UNSPEC, + ETHTOOL_A_TS_LIST_HEADER, /* nest - _A_HEADER_* */ + ETHTOOL_A_TS_LIST_LAYER, /* array, u32 */ + + /* add new constants above here */ + __ETHTOOL_A_TS_LIST_CNT, + ETHTOOL_A_TS_LIST_MAX = (__ETHTOOL_A_TS_LIST_CNT - 1) +}; + /* generic netlink info */ #define ETHTOOL_GENL_NAME "ethtool" #define ETHTOOL_GENL_VERSION 1 diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c index 561c0931d055..842c9db1531f 100644 --- a/net/ethtool/netlink.c +++ b/net/ethtool/netlink.c @@ -307,6 +307,7 @@ ethnl_default_requests[__ETHTOOL_MSG_USER_CNT] = { [ETHTOOL_MSG_MM_GET] = ðnl_mm_request_ops, [ETHTOOL_MSG_MM_SET] = ðnl_mm_request_ops, [ETHTOOL_MSG_TS_GET] = ðnl_ts_request_ops, + [ETHTOOL_MSG_TS_LIST_GET] = ðnl_ts_list_request_ops, }; static struct ethnl_dump_ctx *ethnl_dump_context(struct netlink_callback *cb) @@ -1138,6 +1139,15 @@ static const struct genl_ops ethtool_genl_ops[] = { .policy = ethnl_ts_get_policy, .maxattr = ARRAY_SIZE(ethnl_ts_get_policy) - 1, }, + { + .cmd = ETHTOOL_MSG_TS_LIST_GET, + .doit = ethnl_default_doit, + .start = ethnl_default_start, + .dumpit = ethnl_default_dumpit, + .done = ethnl_default_done, + .policy = ethnl_ts_get_policy, + .maxattr = ARRAY_SIZE(ethnl_ts_get_policy) - 1, + }, }; static const struct genl_multicast_group ethtool_nl_mcgrps[] = { diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h index 1e6085198acc..ea8c312db3af 100644 --- a/net/ethtool/netlink.h +++ b/net/ethtool/netlink.h @@ -396,6 +396,7 @@ extern const struct ethnl_request_ops ethnl_plca_cfg_request_ops; extern const struct ethnl_request_ops ethnl_plca_status_request_ops; extern const struct ethnl_request_ops ethnl_mm_request_ops; extern const struct ethnl_request_ops ethnl_ts_request_ops; +extern const struct ethnl_request_ops ethnl_ts_list_request_ops; extern const struct nla_policy ethnl_header_policy[ETHTOOL_A_HEADER_FLAGS + 1]; extern const struct nla_policy ethnl_header_policy_stats[ETHTOOL_A_HEADER_FLAGS + 1]; diff --git a/net/ethtool/ts.c b/net/ethtool/ts.c index 066cb06f4d0b..f2dd65a2e69c 100644 --- a/net/ethtool/ts.c +++ b/net/ethtool/ts.c @@ -86,3 +86,76 @@ const struct ethnl_request_ops ethnl_ts_request_ops = { .reply_size = ts_reply_size, .fill_reply = ts_fill_reply, }; + +/* TS_LIST_GET */ +struct ts_list_reply_data { + struct ethnl_reply_data base; + enum timestamping_layer ts_layer[__TIMESTAMPING_COUNT]; + u8 num_ts; +}; + +#define TS_LIST_REPDATA(__reply_base) \ + container_of(__reply_base, struct ts_list_reply_data, base) + +static int ts_list_prepare_data(const struct ethnl_req_info *req_base, + struct ethnl_reply_data *reply_base, + const struct genl_info *info) +{ + struct ts_list_reply_data *data = TS_LIST_REPDATA(reply_base); + struct net_device *dev = reply_base->dev; + const struct ethtool_ops *ops = dev->ethtool_ops; + int ret, i = 0; + + ret = ethnl_ops_begin(dev); + if (ret < 0) + return ret; + + if (phy_has_tsinfo(dev->phydev)) + data->ts_layer[i++] = PHY_TIMESTAMPING; + if (ops->get_ts_info) { + struct ethtool_ts_info ts_info = {0}; + + ops->get_ts_info(dev, &ts_info); + if (ts_info.so_timestamping & + SOF_TIMESTAMPING_HARDWARE_MASK) + data->ts_layer[i++] = MAC_TIMESTAMPING; + + if (ts_info.so_timestamping & + SOF_TIMESTAMPING_SOFTWARE_MASK) + data->ts_layer[i++] = SOFTWARE_TIMESTAMPING; + } + + data->num_ts = i; + ethnl_ops_complete(dev); + + return ret; +} + +static int ts_list_reply_size(const struct ethnl_req_info *req_base, + const struct ethnl_reply_data *reply_base) +{ + struct ts_list_reply_data *data = TS_LIST_REPDATA(reply_base); + + return nla_total_size(sizeof(u32)) * data->num_ts; +} + +static int ts_list_fill_reply(struct sk_buff *skb, + const struct ethnl_req_info *req_base, + const struct ethnl_reply_data *reply_base) +{ + struct ts_list_reply_data *data = TS_LIST_REPDATA(reply_base); + + return nla_put(skb, ETHTOOL_A_TS_LIST_LAYER, sizeof(u32) * data->num_ts, data->ts_layer); +} + +const struct ethnl_request_ops ethnl_ts_list_request_ops = { + .request_cmd = ETHTOOL_MSG_TS_LIST_GET, + .reply_cmd = ETHTOOL_MSG_TS_LIST_GET_REPLY, + .hdr_attr = ETHTOOL_A_TS_HEADER, + .req_info_size = sizeof(struct ts_req_info), + .reply_data_size = sizeof(struct ts_list_reply_data), + + .prepare_data = ts_list_prepare_data, + .reply_size = ts_list_reply_size, + .fill_reply = ts_list_fill_reply, +}; From patchwork Thu Oct 19 14:29:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?K=C3=B6ry_Maincent?= X-Patchwork-Id: 155605 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp425369vqb; Thu, 19 Oct 2023 07:31:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFkkUtwn3lFIrA7Zxwt/fIj00tzJ3lrH/vA/P5foNauUpJsJRc50cKxqdcD7d65nIOhzggb X-Received: by 2002:aa7:88d0:0:b0:6b1:bf32:4fc3 with SMTP id k16-20020aa788d0000000b006b1bf324fc3mr2182326pff.19.1697725887835; Thu, 19 Oct 2023 07:31:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697725887; cv=none; d=google.com; s=arc-20160816; b=s1bvdH8tnXBh4m2KFczj3GPwp2+S32YQ2vB5RdKJnOZIlKv6IITckFIJyNo4vAMcYD 16EmLcCxdYTOjEPiyP1A89WMS8BbHa+gdq/LXIpVg7kVR2ZehdVQow62ZuNWJj9Ux5K4 OpxuTuIbkRoDPhEGY6GxD9Y+V5m2nn2neN3aTlDmw0yCVg/qumb644ebhk5Siv0npnvP GO+yAjhAMOySX14xj0qYhfE4J4WuC0wVKVmRGFCFWjf/OiBqAWNKo0W0dNrjDV8kizsk NKmtJ4osDx5rT7Bs34nKJmwwQanKe1Ou+VjqSQP6RVtnrDw4EMuyVaV2pVRsccXrfbH4 cdgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=ctQqRyF0VKpba4qDoD9bfkE+XzRdvDu4EZKoEFJZ5Y8=; fh=IL4Om7kRbYP5ILTMWk7kzVj5RVF0+t2ztL6E2Yzsl4U=; b=Xfe3UMLSKKFfmsTxVxZztQLh0+ZKcZ0pSGADynfX4r0vA+P8jWPiyM6UC9if57UPjy WmxeRXCPQciOU7qMnEhZFC2bK0PWV5QpYPkeRjsVOMAc443JdANpp9cGVKlRD6Gd9Qea zc/CDm/xGGgWF9WZvN5F2dngpweKHjjGf7Q9Ip5eacno+PNGvUumezYHqJ/jUVfQUBjN DhGAsOCHO2nc/6oeo4k9wu7JuD6mRuisPEINkrRERjCv2+aSOEjpHDJsxb7/qa6CXuSc J7dTJvMK7srv4ZDaUCF2GhWBFEcJGLDm8ZKf+R0J59uPw9yybmwJJIrY5obJirzXf8E4 L//g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ZwkAqxoo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id s29-20020a63925d000000b00574035fd472si4543776pgn.31.2023.10.19.07.31.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 07:31:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ZwkAqxoo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 6E0B7813552D; Thu, 19 Oct 2023 07:31:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346180AbjJSOa1 (ORCPT + 25 others); Thu, 19 Oct 2023 10:30:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346128AbjJSO37 (ORCPT ); Thu, 19 Oct 2023 10:29:59 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::223]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FF8A182; Thu, 19 Oct 2023 07:29:56 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id D976260007; Thu, 19 Oct 2023 14:29:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697725795; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ctQqRyF0VKpba4qDoD9bfkE+XzRdvDu4EZKoEFJZ5Y8=; b=ZwkAqxooU+fvld0S9DTZQdLs/SHO4YlQHDJ17vJfZE9XulwB7WkLfItcN6kO174entp4hr reDx7Pur2OHObXNdshmTQ4j9ZzhNcFes9XPLG2L6y9PpTJdVvlPPMQAWwLsOPqQuByG618 jCquTcIUWMrts0Jp0ei1Rad0B1OaV+83XV2NPg/py19RXqpnDmn1Nj2s9AYEQBLAxIafd+ hcUl+IcEPy2qaE3XNxtOH5FIeLTq+/NHfz/6NU6nWGKQgJ4IdqD3FtRcb66Q1rA13OsIaj EnXDMe27K9wolTH5J2L7Tujpj07ZNQiosGSRouwN/b8Ok4AsTzjA2OLXCNVfFA== From: Kory Maincent Date: Thu, 19 Oct 2023 16:29:26 +0200 Subject: [PATCH net-next v6 11/16] netlink: specs: Introduce new netlink command to list available time stamping layers MIME-Version: 1.0 Message-Id: <20231019-feature_ptp_netnext-v6-11-71affc27b0e5@bootlin.com> References: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> In-Reply-To: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> To: Florian Fainelli , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Radu Pirea , Jay Vosburgh , Andy Gospodarek , Nicolas Ferre , Claudiu Beznea , Willem de Bruijn , Jonathan Corbet , Horatiu Vultur , UNGLinuxDriver@microchip.com, Simon Horman , Vladimir Oltean Cc: Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Maxime Chevallier , Kory Maincent X-Mailer: b4 0.12.3 X-GND-Sasl: kory.maincent@bootlin.com X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 19 Oct 2023 07:31:05 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780194620083996410 X-GMAIL-MSGID: 1780194620083996410 Add a new commands allowing to list available time stamping layers on a netdevice's link. Example usage : ./ynl/cli.py --spec netlink/specs/ethtool.yaml --no-schema \ --do ts-list-get \ --json '{"header":{"dev-name":"eth0"}}' {'header': {'dev-index': 3, 'dev-name': 'eth0'}, 'ts-list-layer': b'\x01\x00\x00\x00\x05\x00\x00\x00'} Signed-off-by: Kory Maincent --- Documentation/netlink/specs/ethtool.yaml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Documentation/netlink/specs/ethtool.yaml b/Documentation/netlink/specs/ethtool.yaml index 49ee028e97ca..81ed8e5f2f55 100644 --- a/Documentation/netlink/specs/ethtool.yaml +++ b/Documentation/netlink/specs/ethtool.yaml @@ -952,6 +952,16 @@ attribute-sets: - name: ts-layer type: u32 + - + name: ts-list + attributes: + - + name: header + type: nest + nested-attributes: header + - + name: ts-list-layer + type: binary operations: enum-model: directional @@ -1716,3 +1726,17 @@ operations: attributes: &ts - header - ts-layer + - + name: ts-list-get + doc: Get list of timestamp devices available on an interface + + attribute-set: ts-list + + do: + request: + attributes: + - header + reply: + attributes: + - header + - ts-list-layer From patchwork Thu Oct 19 14:29:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?K=C3=B6ry_Maincent?= X-Patchwork-Id: 155602 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp425305vqb; Thu, 19 Oct 2023 07:31:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE93Lwl3uCNiKwc2c8nGrrExhgMTzOy6eQdefoe2LO5FVq/mJVm1clsun4hwV6XkLsEqaaV X-Received: by 2002:a17:90a:be0d:b0:27d:4247:d52d with SMTP id a13-20020a17090abe0d00b0027d4247d52dmr2039469pjs.48.1697725881827; Thu, 19 Oct 2023 07:31:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697725881; cv=none; d=google.com; s=arc-20160816; b=C25ZqDayg1fX9rnsE2IRm44nZNBKJurMCYHvjKlqa34X6mGnN/6svW80JGHJtjWA0G S3WifphknsNTwMkdtwj7byrdMk0LNJKQERuKkJe8FHF0zqkObPXab7PJNg58YnNoe2tK Eh2xYCV5K91TElMTXkWqjCJ98N0msci4u0uZcXnL1q6UeLA0GKOhJYjSDhydoumb+ejR hMfn2EKKOylc7mh3oQ/o4KxVdwKnWZpIZly+4UFcGsKYBIisPY1UAEKHwp52LOmA+nlA lEiaqSnRE+Mj8RZ1IqtIl2l5mm2OnW7z1QQJa/vVeGrMTedQBlkoaemKk7o0GGgPMU4V c3uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=UxRIH04gHYFpivoTq2QvwMiiy7tjZUo+mRSPNYqTLJ8=; fh=IL4Om7kRbYP5ILTMWk7kzVj5RVF0+t2ztL6E2Yzsl4U=; b=ExzryIO7CGA0MFJzktGsVVieaBHUAEBFArPfqLN4Bhx0Tryi6OIlqPPq2rx3wXrlS9 1tMcqi2p7pxYUKNQET04SGrTFtAtTdpvn8RHBlaSajpIuLwgNDJZtEArSE4z97Dy42+h IAxPCDoWlyWPj2NEJFI3MRwdLIi99xr5tBhU/0G+5xDP/Mnlq4B5J5O+LtpxQ+R5fxDx 1+fxiJDQoVbNWOqVJ3Bd5FXD8lbNcp5dHQ79lW0XjSrCl1XsXIVXAO6M+i6rCwGCFrmV oqIls6T2WewcG/An/XD1ByDy/x+Z6mVyvmy/GW0EdaLYKzSRXP4VVzOTKE6u7jbPgveI t5Hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=hFcr6wWa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id h4-20020a17090aa88400b002774985e8b7si2333577pjq.168.2023.10.19.07.31.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 07:31:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=hFcr6wWa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 82A6F8315848; Thu, 19 Oct 2023 07:31:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346247AbjJSOaa (ORCPT + 25 others); Thu, 19 Oct 2023 10:30:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346143AbjJSOaB (ORCPT ); Thu, 19 Oct 2023 10:30:01 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::223]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F33A0185; Thu, 19 Oct 2023 07:29:57 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 4AC2B60005; Thu, 19 Oct 2023 14:29:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697725796; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UxRIH04gHYFpivoTq2QvwMiiy7tjZUo+mRSPNYqTLJ8=; b=hFcr6wWa8kngQUjQfgfOV49ytC3LN0hfvlBi9cOpNH9VR84D9XpSi97NTdiiJ69ibLf0H8 FA1cgilfUlf27UMnZa4cMkML3vLppYbDqFH5dhN6IzZ0EA2OuBCb1J9cVHoHimeYACWslA eGlgn4A6QqcDjOMJ+c4R4m+TnrMnq8Z+mVNqjkHY/beHrnqiLpJUmLX1iyRiW35fpG3qEJ BsZT6izoonm/YPHKnU2mU612/mhMtfmTzpYP9pOKj5EQlJQtbkxSa5wOfyAdp4gn6VkIpl UwEp+0LzkfHki3NHKmy4tkHOdIfIE3Dbob6E0lOKkPFrfdO+K3I9tXWyl7/znA== From: Kory Maincent Date: Thu, 19 Oct 2023 16:29:27 +0200 Subject: [PATCH net-next v6 12/16] net: Replace hwtstamp_source by timestamping layer MIME-Version: 1.0 Message-Id: <20231019-feature_ptp_netnext-v6-12-71affc27b0e5@bootlin.com> References: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> In-Reply-To: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> To: Florian Fainelli , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Radu Pirea , Jay Vosburgh , Andy Gospodarek , Nicolas Ferre , Claudiu Beznea , Willem de Bruijn , Jonathan Corbet , Horatiu Vultur , UNGLinuxDriver@microchip.com, Simon Horman , Vladimir Oltean Cc: Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Maxime Chevallier , Kory Maincent X-Mailer: b4 0.12.3 X-GND-Sasl: kory.maincent@bootlin.com X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 19 Oct 2023 07:31:18 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780194613975238864 X-GMAIL-MSGID: 1780194613975238864 Replace hwtstamp_source which is only used by the kernel_hwtstamp_config structure by the more widely use timestamp_layer structure. This is done to prepare the support of selectable timestamping source. Signed-off-by: Kory Maincent --- Change in v6: - Follow timestamping layer naming update. --- drivers/net/ethernet/microchip/lan966x/lan966x_main.c | 6 +++--- include/linux/net_tstamp.h | 11 +++-------- net/core/dev_ioctl.c | 2 +- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c index 8e4101628fbd..b219259600e7 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c @@ -470,15 +470,15 @@ static int lan966x_port_hwtstamp_set(struct net_device *dev, struct lan966x_port *port = netdev_priv(dev); int err; - if (cfg->source != HWTSTAMP_SOURCE_NETDEV && - cfg->source != HWTSTAMP_SOURCE_PHYLIB) + if (cfg->source != MAC_TIMESTAMPING && + cfg->source != PHY_TIMESTAMPING) return -EOPNOTSUPP; err = lan966x_ptp_setup_traps(port, cfg); if (err) return err; - if (cfg->source == HWTSTAMP_SOURCE_NETDEV) { + if (cfg->source == MAC_TIMESTAMPING) { if (!port->lan966x->ptp) return -EOPNOTSUPP; diff --git a/include/linux/net_tstamp.h b/include/linux/net_tstamp.h index eb01c37e71e0..bb289c2ad376 100644 --- a/include/linux/net_tstamp.h +++ b/include/linux/net_tstamp.h @@ -5,11 +5,6 @@ #include -enum hwtstamp_source { - HWTSTAMP_SOURCE_NETDEV, - HWTSTAMP_SOURCE_PHYLIB, -}; - /** * struct kernel_hwtstamp_config - Kernel copy of struct hwtstamp_config * @@ -20,8 +15,8 @@ enum hwtstamp_source { * a legacy implementation of a lower driver * @copied_to_user: request was passed to a legacy implementation which already * copied the ioctl request back to user space - * @source: indication whether timestamps should come from the netdev or from - * an attached phylib PHY + * @source: indication whether timestamps should come from software, the netdev + * or from an attached phylib PHY * * Prefer using this structure for in-kernel processing of hardware * timestamping configuration, over the inextensible struct hwtstamp_config @@ -33,7 +28,7 @@ struct kernel_hwtstamp_config { int rx_filter; struct ifreq *ifr; bool copied_to_user; - enum hwtstamp_source source; + enum timestamping_layer source; }; static inline void hwtstamp_config_to_kernel(struct kernel_hwtstamp_config *kernel_cfg, diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c index cb60b0b9c31d..57d9f25f16b8 100644 --- a/net/core/dev_ioctl.c +++ b/net/core/dev_ioctl.c @@ -332,7 +332,7 @@ int dev_set_hwtstamp_phylib(struct net_device *dev, bool changed = false; int err; - cfg->source = phy_ts ? HWTSTAMP_SOURCE_PHYLIB : HWTSTAMP_SOURCE_NETDEV; + cfg->source = phy_ts ? PHY_TIMESTAMPING : NET_TIMESTAMPING; if (phy_ts && (dev->priv_flags & IFF_SEE_ALL_HWTSTAMP_REQUESTS)) { err = ops->ndo_hwtstamp_get(dev, &old_cfg); From patchwork Thu Oct 19 14:29:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?K=C3=B6ry_Maincent?= X-Patchwork-Id: 155601 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp425269vqb; Thu, 19 Oct 2023 07:31:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHQRTWTVdMugIQG2tB9diUpCjphaxsjkeBe733DVdlvydGrTCbaEmuK66EvQ76ZdUQ1qGym X-Received: by 2002:a05:6a00:2187:b0:68f:b5a3:5ec6 with SMTP id h7-20020a056a00218700b0068fb5a35ec6mr3020415pfi.0.1697725880246; Thu, 19 Oct 2023 07:31:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697725880; cv=none; d=google.com; s=arc-20160816; b=eNHGqRA+VU8esguSXPjHOWG/GHCL7291yZvTxUGGmUvIihf+dOuvQ5fcYhNdXxYm+f +50ZHi4eIXFh2Y2AVQdV1l2u78mEuCFI0i2FxwF4b5tFEOKqKzOnIBSoHUC5nhxbK7sz ER6M2uGO3WfIMxyoQ3Biby+17CDF1PLdhBAIlJThh3CRyjnlnts7jGn5opxQm4Wfnz/E L7udO9fXPIM1owIbVemM3AAsy5dW7Kb8k4DTOK6Ykf9s9Bco84W5o+BPbHPswMjoXfSc BC8vX2cF6HuZrAE/NdAAInncmXa1ZZ7zjP6UrVvSTI3gpM+mgDzWMpn0E6ENUqjP+76d flPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=kjWsRSxVM0toh/u9OgWl7BiuleIhEV3f9dm/Izsaanw=; fh=IL4Om7kRbYP5ILTMWk7kzVj5RVF0+t2ztL6E2Yzsl4U=; b=hq1YY1oeczt+AMTT9+NKDgU6Ljeg20/xoeq2JO5WRfVJ8PQUfrmjeEg5rZsg3WMJZE 1fFFKPktHoKkUDPIZgXass2PlrJWzr2CogPUbrIenhH0iNNc2F0wsD4ILaFpOmp9o6BD nAfV0ViD+LWBtP8vD9SQGXeAfrk2uWdfveOxsk3AdY418oXAuGGF7J1htTpXrvViHfae 8EQH+fkUX7N884PuyrYahvLevN0FuoQ+hTkv2kk8DpeEF9xhfVyRxoNfdeUkV9u/Wl+n gd9GYa2aO3K+yPTeJa57uHhJw0gdl7g6p+qn3URhSu9W5vTwMwKJcRgpUmiwprPWe8uv +wxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=nFt6JDPk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id x27-20020aa78f1b000000b006b28fa70b48si6133006pfr.354.2023.10.19.07.31.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 07:31:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=nFt6JDPk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 6737A802507B; Thu, 19 Oct 2023 07:31:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346294AbjJSOat (ORCPT + 25 others); Thu, 19 Oct 2023 10:30:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346173AbjJSOaK (ORCPT ); Thu, 19 Oct 2023 10:30:10 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 573F0191; Thu, 19 Oct 2023 07:29:59 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id B191060002; Thu, 19 Oct 2023 14:29:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697725798; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kjWsRSxVM0toh/u9OgWl7BiuleIhEV3f9dm/Izsaanw=; b=nFt6JDPkcg6LXOb736iPKx87HcRtphO3Br+QltgoIpG/KZvXQvI5I/eiQ0r51zc6+M6ZRU a36dlOecct3ifAIFsQWpi2iLD+QBPpHOjCLS0T9NNyEgYS+CH7wKMnIopVJ0tdzuD1m5qM nFcofXiC3d3gpxN81/1xtz37u8CgWRc1bxTiMG3AtnGZLha64tgE1T38S9ONVwuKBai56s m4WsZp1Itao7ss52bkppcQOfq+fgoEIdg2p/ea1Xs3MgCaeqyUpcEmibtfWEiI0Ay9B/u9 c8geXiENNZUPqqs+75FuwGmoHem7IgC7pAhsTMKlRjZufDRu9OmrxETF0xWSjw== From: Kory Maincent Date: Thu, 19 Oct 2023 16:29:28 +0200 Subject: [PATCH net-next v6 13/16] net: Change the API of PHY default timestamp to MAC MIME-Version: 1.0 Message-Id: <20231019-feature_ptp_netnext-v6-13-71affc27b0e5@bootlin.com> References: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> In-Reply-To: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> To: Florian Fainelli , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Radu Pirea , Jay Vosburgh , Andy Gospodarek , Nicolas Ferre , Claudiu Beznea , Willem de Bruijn , Jonathan Corbet , Horatiu Vultur , UNGLinuxDriver@microchip.com, Simon Horman , Vladimir Oltean Cc: Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Maxime Chevallier , Kory Maincent X-Mailer: b4 0.12.3 X-GND-Sasl: kory.maincent@bootlin.com X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 19 Oct 2023 07:31:17 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780194612415056194 X-GMAIL-MSGID: 1780194612415056194 Change the API to select MAC default time stamping instead of the PHY. Indeed the PHY is closer to the wire therefore theoretically it has less delay than the MAC timestamping but the reality is different. Due to lower time stamping clock frequency, latency in the MDIO bus and no PHC hardware synchronization between different PHY, the PHY PTP is often less precise than the MAC. The exception is for PHY designed specially for PTP case but these devices are not very widespread. For not breaking the compatibility I introduce a default_timestamp flag in phy_device that is set by the phy driver to know we are using the old API behavior. The phy_set_timestamp function is called at each call of phy_attach_direct. In case of MAC driver using phylink this function is called when the interface is turned up. Then if the interface goes down and up again the last choice of timestamp will be overwritten by the default choice. A solution could be to cache the timestamp status but it can bring other issues. In case of SFP, if we change the module, it doesn't make sense to blindly re-set the timestamp back to PHY, if the new module has a PHY with mediocre timestamping capabilities. Signed-off-by: Kory Maincent --- Changes in v5: - Extract the API change in this patch. - Rename whitelist to allowlist. - Set NETDEV_TIMESTAMPING in register_netdevice function. - Add software timestamping case description in ts_info. Change in v6: - Replace the allowlist phy with a default_timestamp flag to know which phy is using old API behavior. - Fix dereferenced of a possible null pointer. - Follow timestamping layer naming update. - Update timestamp default set between MAC and software. - Update ts_info returned in case of software timestamping. --- drivers/net/phy/bcm-phy-ptp.c | 3 +++ drivers/net/phy/dp83640.c | 3 +++ drivers/net/phy/micrel.c | 6 ++++++ drivers/net/phy/mscc/mscc_ptp.c | 2 ++ drivers/net/phy/nxp-c45-tja11xx.c | 3 +++ drivers/net/phy/phy_device.c | 37 +++++++++++++++++++++++++++++++++++++ include/linux/netdevice.h | 5 +++++ include/linux/phy.h | 4 ++++ net/core/dev.c | 3 +++ net/core/dev_ioctl.c | 36 ++++++++++++++++++++++-------------- net/core/timestamping.c | 10 ++++++++++ net/ethtool/common.c | 19 +++++++++++++++++-- 12 files changed, 115 insertions(+), 16 deletions(-) diff --git a/drivers/net/phy/bcm-phy-ptp.c b/drivers/net/phy/bcm-phy-ptp.c index 0beae8f81ffa..92ffc542a823 100644 --- a/drivers/net/phy/bcm-phy-ptp.c +++ b/drivers/net/phy/bcm-phy-ptp.c @@ -931,6 +931,9 @@ struct bcm_ptp_private *bcm_ptp_probe(struct phy_device *phydev) return ERR_CAST(clock); priv->ptp_clock = clock; + /* Timestamp selected by default to keep legacy API */ + phydev->default_timestamp = true; + priv->phydev = phydev; bcm_ptp_init(priv); diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c index 5c42c47dc564..64fd1a109c0f 100644 --- a/drivers/net/phy/dp83640.c +++ b/drivers/net/phy/dp83640.c @@ -1450,6 +1450,9 @@ static int dp83640_probe(struct phy_device *phydev) phydev->mii_ts = &dp83640->mii_ts; phydev->priv = dp83640; + /* Timestamp selected by default to keep legacy API */ + phydev->default_timestamp = true; + spin_lock_init(&dp83640->rx_lock); skb_queue_head_init(&dp83640->rx_queue); skb_queue_head_init(&dp83640->tx_queue); diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 4c115e55ffc0..e50174587899 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -3136,6 +3136,9 @@ static void lan8814_ptp_init(struct phy_device *phydev) ptp_priv->mii_ts.ts_info = lan8814_ts_info; phydev->mii_ts = &ptp_priv->mii_ts; + + /* Timestamp selected by default to keep legacy API */ + phydev->default_timestamp = true; } static int lan8814_ptp_probe_once(struct phy_device *phydev) @@ -4564,6 +4567,9 @@ static int lan8841_probe(struct phy_device *phydev) phydev->mii_ts = &ptp_priv->mii_ts; + /* Timestamp selected by default to keep legacy API */ + phydev->default_timestamp = true; + return 0; } diff --git a/drivers/net/phy/mscc/mscc_ptp.c b/drivers/net/phy/mscc/mscc_ptp.c index eb0b032cb613..fd174eb06d4a 100644 --- a/drivers/net/phy/mscc/mscc_ptp.c +++ b/drivers/net/phy/mscc/mscc_ptp.c @@ -1570,6 +1570,8 @@ int vsc8584_ptp_probe(struct phy_device *phydev) return PTR_ERR(vsc8531->load_save); } + /* Timestamp selected by default to keep legacy API */ + phydev->default_timestamp = true; vsc8531->ptp->phydev = phydev; return 0; diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c index 780ad353cf55..0515c7b979db 100644 --- a/drivers/net/phy/nxp-c45-tja11xx.c +++ b/drivers/net/phy/nxp-c45-tja11xx.c @@ -1658,6 +1658,9 @@ static int nxp_c45_probe(struct phy_device *phydev) priv->mii_ts.ts_info = nxp_c45_ts_info; phydev->mii_ts = &priv->mii_ts; ret = nxp_c45_init_ptp_clock(priv); + + /* Timestamp selected by default to keep legacy API */ + phydev->default_timestamp = true; } else { phydev_dbg(phydev, "PTP support not enabled even if the phy supports it"); } diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 2ce74593d6e4..8c4794631daa 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -1411,6 +1411,26 @@ int phy_sfp_probe(struct phy_device *phydev, } EXPORT_SYMBOL(phy_sfp_probe); +/** + * phy_set_timestamp - set the default selected timestamping device + * @dev: Pointer to net_device + * @phydev: Pointer to phy_device + * + * This is used to set default timestamping device taking into account + * the new API choice, which is selecting the timestamping from MAC by + * default if the phydev does not have default_timestamp flag enabled. + */ +static void phy_set_timestamp(struct net_device *dev, struct phy_device *phydev) +{ + const struct ethtool_ops *ops = dev->ethtool_ops; + + if (!phy_has_tsinfo(phydev)) + return; + + if (!ops->get_ts_info || phydev->default_timestamp) + dev->ts_layer = PHY_TIMESTAMPING; +} + /** * phy_attach_direct - attach a network device to a given PHY device pointer * @dev: network device to attach @@ -1484,6 +1504,7 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, phydev->phy_link_change = phy_link_change; if (dev) { + phy_set_timestamp(dev, phydev); phydev->attached_dev = dev; dev->phydev = phydev; @@ -1812,6 +1833,22 @@ void phy_detach(struct phy_device *phydev) phy_suspend(phydev); if (dev) { + const struct ethtool_ops *ops = dev->ethtool_ops; + struct ethtool_ts_info ts_info = {0}; + + if (ops->get_ts_info) { + ops->get_ts_info(dev, &ts_info); + if ((ts_info.so_timestamping & + SOF_TIMESTAMPING_HARDWARE_MASK) == + SOF_TIMESTAMPING_HARDWARE_MASK) + dev->ts_layer = MAC_TIMESTAMPING; + else if ((ts_info.so_timestamping & + SOF_TIMESTAMPING_SOFTWARE_MASK) == + SOF_TIMESTAMPING_SOFTWARE_MASK) + dev->ts_layer = SOFTWARE_TIMESTAMPING; + } else { + dev->ts_layer = NO_TIMESTAMPING; + } phydev->attached_dev->phydev = NULL; phydev->attached_dev = NULL; } diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index b9d0411836db..52f57008a2dd 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -2054,6 +2055,8 @@ enum netdev_ml_priv_type { * * @dpll_pin: Pointer to the SyncE source pin of a DPLL subsystem, * where the clock is recovered. + * @ts_layer: Tracks which network device + * performs packet time stamping. * * FIXME: cleanup struct net_device such that network protocol info * moves out. @@ -2415,6 +2418,8 @@ struct net_device { #if IS_ENABLED(CONFIG_DPLL) struct dpll_pin *dpll_pin; #endif + + enum timestamping_layer ts_layer; }; #define to_net_dev(d) container_of(d, struct net_device, dev) diff --git a/include/linux/phy.h b/include/linux/phy.h index e5f1f41e399c..317def2a7843 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -604,6 +604,8 @@ struct macsec_ops; * handling shall be postponed until PHY has resumed * @irq_rerun: Flag indicating interrupts occurred while PHY was suspended, * requiring a rerun of the interrupt handler after resume + * @default_timestamp: Flag indicating whether we are using the phy + * timestamp as the default one * @interface: enum phy_interface_t value * @skb: Netlink message for cable diagnostics * @nest: Netlink nest used for cable diagnostics @@ -667,6 +669,8 @@ struct phy_device { unsigned irq_suspended:1; unsigned irq_rerun:1; + unsigned default_timestamp:1; + int rate_matching; enum phy_state state; diff --git a/net/core/dev.c b/net/core/dev.c index 606a366cc209..cef613e31ba7 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -10204,6 +10204,9 @@ int register_netdevice(struct net_device *dev) dev->rtnl_link_state == RTNL_LINK_INITIALIZED) rtmsg_ifinfo(RTM_NEWLINK, dev, ~0U, GFP_KERNEL, 0, NULL); + if (dev->ethtool_ops->get_ts_info) + dev->ts_layer = MAC_TIMESTAMPING; + out: return ret; diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c index 57d9f25f16b8..8d510344c885 100644 --- a/net/core/dev_ioctl.c +++ b/net/core/dev_ioctl.c @@ -259,9 +259,7 @@ static int dev_eth_ioctl(struct net_device *dev, * @dev: Network device * @cfg: Timestamping configuration structure * - * Helper for enforcing a common policy that phylib timestamping, if available, - * should take precedence in front of hardware timestamping provided by the - * netdev. + * Helper for calling the selected hardware provider timestamping. * * Note: phy_mii_ioctl() only handles SIOCSHWTSTAMP (not SIOCGHWTSTAMP), and * there only exists a phydev->mii_ts->hwtstamp() method. So this will return @@ -271,10 +269,14 @@ static int dev_eth_ioctl(struct net_device *dev, static int dev_get_hwtstamp_phylib(struct net_device *dev, struct kernel_hwtstamp_config *cfg) { - if (phy_has_hwtstamp(dev->phydev)) + enum timestamping_layer ts_layer = dev->ts_layer; + + if (ts_layer == PHY_TIMESTAMPING) return phy_hwtstamp_get(dev->phydev, cfg); + else if (ts_layer == MAC_TIMESTAMPING) + return dev->netdev_ops->ndo_hwtstamp_get(dev, cfg); - return dev->netdev_ops->ndo_hwtstamp_get(dev, cfg); + return -EOPNOTSUPP; } static int dev_get_hwtstamp(struct net_device *dev, struct ifreq *ifr) @@ -315,9 +317,8 @@ static int dev_get_hwtstamp(struct net_device *dev, struct ifreq *ifr) * @cfg: Timestamping configuration structure * @extack: Netlink extended ack message structure, for error reporting * - * Helper for enforcing a common policy that phylib timestamping, if available, - * should take precedence in front of hardware timestamping provided by the - * netdev. If the netdev driver needs to perform specific actions even for PHY + * Helper for calling the selected hardware provider timestamping. + * If the netdev driver needs to perform specific actions even for PHY * timestamping to work properly (a switch port must trap the timestamped * frames and not forward them), it must set IFF_SEE_ALL_HWTSTAMP_REQUESTS in * dev->priv_flags. @@ -327,20 +328,26 @@ int dev_set_hwtstamp_phylib(struct net_device *dev, struct netlink_ext_ack *extack) { const struct net_device_ops *ops = dev->netdev_ops; - bool phy_ts = phy_has_hwtstamp(dev->phydev); + enum timestamping_layer ts_layer = dev->ts_layer; struct kernel_hwtstamp_config old_cfg = {}; bool changed = false; int err; - cfg->source = phy_ts ? PHY_TIMESTAMPING : NET_TIMESTAMPING; + cfg->source = ts_layer; + + if (ts_layer != PHY_TIMESTAMPING && + ts_layer != MAC_TIMESTAMPING) + return -EOPNOTSUPP; - if (phy_ts && (dev->priv_flags & IFF_SEE_ALL_HWTSTAMP_REQUESTS)) { + if (ts_layer == PHY_TIMESTAMPING && + dev->priv_flags & IFF_SEE_ALL_HWTSTAMP_REQUESTS) { err = ops->ndo_hwtstamp_get(dev, &old_cfg); if (err) return err; } - if (!phy_ts || (dev->priv_flags & IFF_SEE_ALL_HWTSTAMP_REQUESTS)) { + if (ts_layer == MAC_TIMESTAMPING || + dev->priv_flags & IFF_SEE_ALL_HWTSTAMP_REQUESTS) { err = ops->ndo_hwtstamp_set(dev, cfg, extack); if (err) { if (extack->_msg) @@ -349,10 +356,11 @@ int dev_set_hwtstamp_phylib(struct net_device *dev, } } - if (phy_ts && (dev->priv_flags & IFF_SEE_ALL_HWTSTAMP_REQUESTS)) + if (ts_layer == PHY_TIMESTAMPING && + dev->priv_flags & IFF_SEE_ALL_HWTSTAMP_REQUESTS) changed = kernel_hwtstamp_config_changed(&old_cfg, cfg); - if (phy_ts) { + if (ts_layer == PHY_TIMESTAMPING) { err = phy_hwtstamp_set(dev->phydev, cfg, extack); if (err) { if (changed) diff --git a/net/core/timestamping.c b/net/core/timestamping.c index 04840697fe79..5cf51a523fb3 100644 --- a/net/core/timestamping.c +++ b/net/core/timestamping.c @@ -21,6 +21,7 @@ static unsigned int classify(const struct sk_buff *skb) void skb_clone_tx_timestamp(struct sk_buff *skb) { + enum timestamping_layer ts_layer; struct mii_timestamper *mii_ts; struct sk_buff *clone; unsigned int type; @@ -28,6 +29,10 @@ void skb_clone_tx_timestamp(struct sk_buff *skb) if (!skb->sk) return; + ts_layer = skb->dev->ts_layer; + if (ts_layer != PHY_TIMESTAMPING) + return; + type = classify(skb); if (type == PTP_CLASS_NONE) return; @@ -44,12 +49,17 @@ EXPORT_SYMBOL_GPL(skb_clone_tx_timestamp); bool skb_defer_rx_timestamp(struct sk_buff *skb) { + enum timestamping_layer ts_layer; struct mii_timestamper *mii_ts; unsigned int type; if (!skb->dev || !skb->dev->phydev || !skb->dev->phydev->mii_ts) return false; + ts_layer = skb->dev->ts_layer; + if (ts_layer != PHY_TIMESTAMPING) + return false; + if (skb_headroom(skb) < ETH_HLEN) return false; diff --git a/net/ethtool/common.c b/net/ethtool/common.c index e2315e24d695..d7ae49879b47 100644 --- a/net/ethtool/common.c +++ b/net/ethtool/common.c @@ -633,13 +633,28 @@ int __ethtool_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info) { const struct ethtool_ops *ops = dev->ethtool_ops; struct phy_device *phydev = dev->phydev; + enum timestamping_layer ts_layer; + int ret; memset(info, 0, sizeof(*info)); info->cmd = ETHTOOL_GET_TS_INFO; - if (phy_has_tsinfo(phydev)) + ts_layer = dev->ts_layer; + if (ts_layer == SOFTWARE_TIMESTAMPING) { + ret = ops->get_ts_info(dev, info); + if (ret) + return ret; + info->so_timestamping &= ~SOF_TIMESTAMPING_HARDWARE_MASK; + info->phc_index = -1; + info->rx_filters = 0; + info->tx_types = 0; + return 0; + } + + if (ts_layer == PHY_TIMESTAMPING) return phy_ts_info(phydev, info); - if (ops->get_ts_info) + + if (ts_layer == MAC_TIMESTAMPING) return ops->get_ts_info(dev, info); info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE | From patchwork Thu Oct 19 14:29:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?K=C3=B6ry_Maincent?= X-Patchwork-Id: 155609 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp425500vqb; Thu, 19 Oct 2023 07:31:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGm0LGRStYTSrl7l+JlP1fV3JRPpESjFHw4qE6xfA0cRPtnX3vX5ymowzlSfZgOLHaSY4g7 X-Received: by 2002:a05:6a20:12cc:b0:15a:6733:24e2 with SMTP id v12-20020a056a2012cc00b0015a673324e2mr3261292pzg.25.1697725899453; Thu, 19 Oct 2023 07:31:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697725899; cv=none; d=google.com; s=arc-20160816; b=ffD39LJPzL9Xnh79/qvVUtEGxbTPeHbRipgZytI475QuTAjyXF6hNOTUTz+CdCMvLn mOw1iFrrK1xeWZ4WsSG6FMaROm3VeyZOaEPZxU9bie+ktPOkLP5KLh+h6hgMdrUXqIsy Qi3CFDTwJM3yXB5fAMwzIil+V1UHRWyQSGwPWw5BR4ZKVCP8qYVfR9VrFA6SdLRQ3Xng cTAdHpNa635exiLFKZfh2yHFjtDqjq7rSG/zSN3WCpKxM3KAoSAQeopC+TWQkIJconbI X3p1lzuYSqm3D1ChO9rjvV6bAvdOPkiK7gRPOHjpbF/nh3FSrt3tiqirBu2vknSHOJM4 aOxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=hnH2ZHMI5dsTwImD1KGet0qz4ilreT1GWjYY2D79LCc=; fh=IL4Om7kRbYP5ILTMWk7kzVj5RVF0+t2ztL6E2Yzsl4U=; b=LAcSLILbwsUpyD5FLy1Oyqj7+3qbGd35aFT1ihpP3Uo4TmCtkn/aoWU3fU3Ep1ar7W 6Yx2N1QtbJ/On7jr1JYHldGB2pzZA2fn4TmC6UaaLiXibHAbtJXgNZDFrT9SHASLro33 W5Q+vyrsmTIz/zNBbdfg/R3UEox/HHuDP4lDfge2FQ8zwOBHnO06orAHtOApVlCHKRGB M1NefzpQ+3CkUEYUCIMU+vQc3u/ftQVZvMjM+9S3LcqfZPtZDKzNrGQYlTan3qmRzUkP WTEOvZZzlBHYw5lr6yZCbqglDaoMt9tgVTJeyAJ8fZ19cuEqkznbMeB4SQopI4iiFkZX KnEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Q0XLRxn5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id i135-20020a636d8d000000b0059b71fb1472si4666773pgc.39.2023.10.19.07.31.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 07:31:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Q0XLRxn5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 65A19809ABE2; Thu, 19 Oct 2023 07:30:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346253AbjJSOad (ORCPT + 25 others); Thu, 19 Oct 2023 10:30:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346172AbjJSOaK (ORCPT ); Thu, 19 Oct 2023 10:30:10 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DF9319A; Thu, 19 Oct 2023 07:30:00 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 22E5D6000D; Thu, 19 Oct 2023 14:29:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697725799; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hnH2ZHMI5dsTwImD1KGet0qz4ilreT1GWjYY2D79LCc=; b=Q0XLRxn5P1pSD+4wfSUlxew1r+I7e730puAeo26hfCy/eBQK+fZQI4ptJMzDzSa/MDL5cD 7YpeAjxYif56fPF5oy6T9rPsus852M5f8sV3mrK3Zjwo/AA5p8/7Km3l/U28FhZyIFaszz IUt1jrgTZb8y65BoBozwv00QNlDxEm5G2mKGN8/pOXw17LMDG36lZmY/8F8X2S5i7fTnO7 UFMhkxopFfBWCEuz3EUjrOLsQLmDLKSsuDRlyg7rW8c7tOfOeX2yEbqpFVGAV4hBELhUQp E2FXX1T2a9qqu2FNDXr7PPNuXyDiSbL0LZKUk8FcwYjVg5YrPZEM8jMKVAZqCg== From: Kory Maincent Date: Thu, 19 Oct 2023 16:29:29 +0200 Subject: [PATCH net-next v6 14/16] net: ethtool: ts: Update GET_TS to reply the current selected timestamp MIME-Version: 1.0 Message-Id: <20231019-feature_ptp_netnext-v6-14-71affc27b0e5@bootlin.com> References: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> In-Reply-To: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> To: Florian Fainelli , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Radu Pirea , Jay Vosburgh , Andy Gospodarek , Nicolas Ferre , Claudiu Beznea , Willem de Bruijn , Jonathan Corbet , Horatiu Vultur , UNGLinuxDriver@microchip.com, Simon Horman , Vladimir Oltean Cc: Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Maxime Chevallier , Kory Maincent X-Mailer: b4 0.12.3 X-GND-Sasl: kory.maincent@bootlin.com X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 19 Oct 2023 07:30:43 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780194632868460510 X-GMAIL-MSGID: 1780194632868460510 As the default selected timestamp API change we have to change also the timestamp return by ethtool. This patch return now the current selected timestamp. Signed-off-by: Kory Maincent --- net/ethtool/ts.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/net/ethtool/ts.c b/net/ethtool/ts.c index f2dd65a2e69c..bd219512b8de 100644 --- a/net/ethtool/ts.c +++ b/net/ethtool/ts.c @@ -31,29 +31,13 @@ static int ts_prepare_data(const struct ethnl_req_info *req_base, { struct ts_reply_data *data = TS_REPDATA(reply_base); struct net_device *dev = reply_base->dev; - const struct ethtool_ops *ops = dev->ethtool_ops; int ret; ret = ethnl_ops_begin(dev); if (ret < 0) return ret; - if (phy_has_tsinfo(dev->phydev)) { - data->ts_layer = PHY_TIMESTAMPING; - } else if (ops->get_ts_info) { - struct ethtool_ts_info ts_info = {0}; - - ops->get_ts_info(dev, &ts_info); - if (ts_info.so_timestamping & - SOF_TIMESTAMPING_HARDWARE_MASK) - data->ts_layer = MAC_TIMESTAMPING; - - if (ts_info.so_timestamping & - SOF_TIMESTAMPING_SOFTWARE_MASK) - data->ts_layer = SOFTWARE_TIMESTAMPING; - } else { - data->ts_layer = NO_TIMESTAMPING; - } + data->ts_layer = dev->ts_layer; ethnl_ops_complete(dev); From patchwork Thu Oct 19 14:29:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?K=C3=B6ry_Maincent?= X-Patchwork-Id: 155610 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp425563vqb; Thu, 19 Oct 2023 07:31:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHbo2Rj0RVeK1aNduFMHTm1n2yhPtYHV/VLIoQNkPqIFB/GdQqKtwIFIQtr75BRzNMbo60I X-Received: by 2002:a17:903:704:b0:1c9:db23:704c with SMTP id kk4-20020a170903070400b001c9db23704cmr2333630plb.27.1697725904193; Thu, 19 Oct 2023 07:31:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697725904; cv=none; d=google.com; s=arc-20160816; b=MvzEETXnE+7z0+ivrrfI+5JZaOuhENtcfmyQfseDjybfSwK/BL3ThXvkS6WDfdenzo apwCipMUVZVT0qjYJipeKmAfOOyEskHZaD1mqEsQ9SMRSbSrcTYy05rfpzRaAy37vt8w uIObWtjmEZNkgwoq411jp46X1Bkibq3LRckHJ8EjoCNEyAYFBrD4YR6EPf/aF0+doygC MXq0xsFS6GqXpV98NL4PVzTmTRVA5XjgTgi6O7nc6+GXbaY49TOTLKCyVlqYziVoKGfg 7bOVhtlNDn4FbotW9jLODZE2nmpIds2/wvObFJA8mfhtjiFqZXnFx41p5KkX0PahoumK Yuqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=UL3dPQ+WlkR8wmYXFv5cwsj7UFhnBxJy6YYHytPVUdQ=; fh=IL4Om7kRbYP5ILTMWk7kzVj5RVF0+t2ztL6E2Yzsl4U=; b=NhvHmat9i4eiHXcsAU5aIU5NovXhSJih3JSZ2BoJ3KSdLqC+fAlesCSnjsUznMT+Pr 1yjct9LmQqS1Hz3QA2xCmRUt3pDSpOkeFvNn1WIk6l/BQs2RWsNHmLXiIh2CrTRl8hlh xqqAnc7HRAkCVAY5jwEkx3tuvG9qsQSXT6Ne7xLe6XNysUcuFfh+iSI0NeeYlU+pYlEG O/1bmaM2kd99rp8LzadIgU9jewdIFMbCaSVdmwvHwh+ExrKmCrckgRHwKpoI7YmnN9iC YTCLZkX6m32LBctb+/CNOD0JoJkMwJatvtUwE/MjF3Hna4oHU0Rr3Z69IwZKdwBpZ869 yQJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Or8Z4ZzP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id 4-20020a170902ee4400b001bc5a4f56fcsi2140216plo.554.2023.10.19.07.31.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 07:31:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Or8Z4ZzP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id B8AAD804E44F; Thu, 19 Oct 2023 07:30:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346111AbjJSOag (ORCPT + 25 others); Thu, 19 Oct 2023 10:30:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346191AbjJSOaL (ORCPT ); Thu, 19 Oct 2023 10:30:11 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::223]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 911821A8; Thu, 19 Oct 2023 07:30:02 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 77A9C60004; Thu, 19 Oct 2023 14:29:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697725800; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UL3dPQ+WlkR8wmYXFv5cwsj7UFhnBxJy6YYHytPVUdQ=; b=Or8Z4ZzP+fceE8fXpWT9SuV8UMDkCUptCmK4tvvxWoWEFMPE7uIVTIY575vXDb2wTkgO+c /P/zFgSI0A/4M2Nq2VSxxjitAt7ar2J3WWTKwFbIvMEB4/DCb9t3d6HYwccNCptIWqdFRK MlMxMeLQ6k6spyTv35vGoHvwIGQdnKKYLmgnb6nwh2LJZQHEM9WyyqetpxvqHfgFZSWxLt 8jwRnqc9EzqlREvXqbyarO4nh5medBUPomVwpQI/el0djGsdIphnL+mvqYzx2qaOqwxqMk pdwX1RF79hAp0AroBKR5nZhEDvthONnuYQOLk8TslpQcATjz8yZMc7e3WcexKA== From: Kory Maincent Date: Thu, 19 Oct 2023 16:29:30 +0200 Subject: [PATCH net-next v6 15/16] net ethtool: net: Let the active time stamping layer be selectable MIME-Version: 1.0 Message-Id: <20231019-feature_ptp_netnext-v6-15-71affc27b0e5@bootlin.com> References: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> In-Reply-To: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> To: Florian Fainelli , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Radu Pirea , Jay Vosburgh , Andy Gospodarek , Nicolas Ferre , Claudiu Beznea , Willem de Bruijn , Jonathan Corbet , Horatiu Vultur , UNGLinuxDriver@microchip.com, Simon Horman , Vladimir Oltean Cc: Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Maxime Chevallier , Kory Maincent X-Mailer: b4 0.12.3 X-GND-Sasl: kory.maincent@bootlin.com X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,URIBL_BLOCKED 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 19 Oct 2023 07:30:52 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780194637907886914 X-GMAIL-MSGID: 1780194637907886914 Now that the current timestamp is saved in a variable lets add the ETHTOOL_MSG_TS_SET ethtool netlink socket to make it selectable. Signed-off-by: Kory Maincent --- Changes in v2: - Move selected_timestamping_layer introduction in this patch. - Replace strmcmp by sysfs_streq. - Use the PHY timestamp only if available. Changes in v3: - Add a devicetree binding to select the preferred timestamp - Replace the way to select timestamp through ethtool instead of sysfs You can test it with the ethtool source on branch feature_ptp of: https://github.com/kmaincent/ethtool Changes in v4: - Change the API to select MAC default time stamping instead of the PHY. - Add a whitelist to no break the old timestamp PHY default preferences for current PHY. - Replace the ethtool ioctl by netlink. - Add a netdev notifier to allow network device to create trap on PTP packets. Not tested as it need to change the lan966x driver that implement packet traps. I will do after the hwtstamp management change to NDOs. Changes in v5: - Remove the netdev notifier added in v4. - Extract the default timestamp API change in another patch. Changes in v6: - Update the error message. - Put ndo_hwtstamp_set check first as it is most likely what most drivers currently do not support. - Follow timestamping layer naming update. - Update the timestamp layer check. - Update timestamp set between MAC and software. --- Documentation/networking/ethtool-netlink.rst | 17 +++++ include/uapi/linux/ethtool_netlink.h | 1 + net/ethtool/netlink.c | 8 +++ net/ethtool/netlink.h | 1 + net/ethtool/ts.c | 99 ++++++++++++++++++++++++++++ 5 files changed, 126 insertions(+) diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/networking/ethtool-netlink.rst index b8d00676ed82..530c1775e5f4 100644 --- a/Documentation/networking/ethtool-netlink.rst +++ b/Documentation/networking/ethtool-netlink.rst @@ -227,6 +227,7 @@ Userspace to kernel: ``ETHTOOL_MSG_MM_SET`` set MAC merge layer parameters ``ETHTOOL_MSG_TS_GET`` get current timestamping ``ETHTOOL_MSG_TS_LIST_GET`` list available timestampings + ``ETHTOOL_MSG_TS_SET`` set current timestamping ===================================== ================================= Kernel to userspace: @@ -2038,6 +2039,21 @@ Kernel response contents: This command lists all the possible timestamp layer available. +TS_SET +====== + +Modify the selected timestamping. + +Request contents: + + ======================= ====== =================== + ``ETHTOOL_A_TS_HEADER`` nested reply header + ``ETHTOOL_A_TS_LAYER`` u32 timestamping + ======================= ====== =================== + +This command set the timestamping with one that should be listed by the +TSLIST_GET command. + Request translation =================== @@ -2146,4 +2162,5 @@ are netlink only. n/a ``ETHTOOL_MSG_MM_SET`` n/a ``ETHTOOL_MSG_TS_GET`` n/a ``ETHTOOL_MSG_TS_LIST_GET`` + n/a ``ETHTOOL_MSG_TS_SET`` =================================== ===================================== diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h index 62b885d44d06..df6c4fcc62c1 100644 --- a/include/uapi/linux/ethtool_netlink.h +++ b/include/uapi/linux/ethtool_netlink.h @@ -59,6 +59,7 @@ enum { ETHTOOL_MSG_MM_SET, ETHTOOL_MSG_TS_GET, ETHTOOL_MSG_TS_LIST_GET, + ETHTOOL_MSG_TS_SET, /* add new constants above here */ __ETHTOOL_MSG_USER_CNT, diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c index 842c9db1531f..8322bf71f80d 100644 --- a/net/ethtool/netlink.c +++ b/net/ethtool/netlink.c @@ -308,6 +308,7 @@ ethnl_default_requests[__ETHTOOL_MSG_USER_CNT] = { [ETHTOOL_MSG_MM_SET] = ðnl_mm_request_ops, [ETHTOOL_MSG_TS_GET] = ðnl_ts_request_ops, [ETHTOOL_MSG_TS_LIST_GET] = ðnl_ts_list_request_ops, + [ETHTOOL_MSG_TS_SET] = ðnl_ts_request_ops, }; static struct ethnl_dump_ctx *ethnl_dump_context(struct netlink_callback *cb) @@ -1148,6 +1149,13 @@ static const struct genl_ops ethtool_genl_ops[] = { .policy = ethnl_ts_get_policy, .maxattr = ARRAY_SIZE(ethnl_ts_get_policy) - 1, }, + { + .cmd = ETHTOOL_MSG_TS_SET, + .flags = GENL_UNS_ADMIN_PERM, + .doit = ethnl_default_set_doit, + .policy = ethnl_ts_set_policy, + .maxattr = ARRAY_SIZE(ethnl_ts_set_policy) - 1, + }, }; static const struct genl_multicast_group ethtool_nl_mcgrps[] = { diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h index ea8c312db3af..8fedf234b824 100644 --- a/net/ethtool/netlink.h +++ b/net/ethtool/netlink.h @@ -444,6 +444,7 @@ extern const struct nla_policy ethnl_plca_get_status_policy[ETHTOOL_A_PLCA_HEADE extern const struct nla_policy ethnl_mm_get_policy[ETHTOOL_A_MM_HEADER + 1]; extern const struct nla_policy ethnl_mm_set_policy[ETHTOOL_A_MM_MAX + 1]; extern const struct nla_policy ethnl_ts_get_policy[ETHTOOL_A_TS_HEADER + 1]; +extern const struct nla_policy ethnl_ts_set_policy[ETHTOOL_A_TS_MAX + 1]; int ethnl_set_features(struct sk_buff *skb, struct genl_info *info); int ethnl_act_cable_test(struct sk_buff *skb, struct genl_info *info); diff --git a/net/ethtool/ts.c b/net/ethtool/ts.c index bd219512b8de..357265e74e08 100644 --- a/net/ethtool/ts.c +++ b/net/ethtool/ts.c @@ -59,6 +59,102 @@ static int ts_fill_reply(struct sk_buff *skb, return nla_put_u32(skb, ETHTOOL_A_TS_LAYER, data->ts_layer); } +/* TS_SET */ +const struct nla_policy ethnl_ts_set_policy[] = { + [ETHTOOL_A_TS_HEADER] = NLA_POLICY_NESTED(ethnl_header_policy), + [ETHTOOL_A_TS_LAYER] = NLA_POLICY_RANGE(NLA_U32, 0, + __TIMESTAMPING_COUNT - 1) +}; + +static int ethnl_set_ts_validate(struct ethnl_req_info *req_info, + struct genl_info *info) +{ + struct nlattr **tb = info->attrs; + const struct net_device_ops *ops = req_info->dev->netdev_ops; + + if (!ops->ndo_hwtstamp_set) + return -EOPNOTSUPP; + + if (!tb[ETHTOOL_A_TS_LAYER]) + return 0; + + return 1; +} + +static int ethnl_set_ts(struct ethnl_req_info *req_info, struct genl_info *info) +{ + struct net_device *dev = req_info->dev; + const struct ethtool_ops *ops = dev->ethtool_ops; + struct kernel_hwtstamp_config config = {0}; + struct nlattr **tb = info->attrs; + enum timestamping_layer ts_layer; + bool mod = false; + int ret; + + ts_layer = dev->ts_layer; + ethnl_update_u32(&ts_layer, tb[ETHTOOL_A_TS_LAYER], &mod); + + if (!mod) + return 0; + + if (ts_layer == SOFTWARE_TIMESTAMPING) { + struct ethtool_ts_info ts_info = {0}; + + if (!ops->get_ts_info) { + NL_SET_ERR_MSG_ATTR(info->extack, + tb[ETHTOOL_A_TS_LAYER], + "this net device cannot support timestamping"); + return -EINVAL; + } + + ops->get_ts_info(dev, &ts_info); + if ((ts_info.so_timestamping & + SOF_TIMESTAMPING_SOFTWARE_MASK) != + SOF_TIMESTAMPING_SOFTWARE_MASK) { + NL_SET_ERR_MSG_ATTR(info->extack, + tb[ETHTOOL_A_TS_LAYER], + "this net device cannot support software timestamping"); + return -EINVAL; + } + } else if (ts_layer == MAC_TIMESTAMPING) { + struct ethtool_ts_info ts_info = {0}; + + if (!ops->get_ts_info) { + NL_SET_ERR_MSG_ATTR(info->extack, + tb[ETHTOOL_A_TS_LAYER], + "this net device cannot support timestamping"); + return -EINVAL; + } + + ops->get_ts_info(dev, &ts_info); + if ((ts_info.so_timestamping & + SOF_TIMESTAMPING_HARDWARE_MASK) != + SOF_TIMESTAMPING_HARDWARE_MASK) { + NL_SET_ERR_MSG_ATTR(info->extack, + tb[ETHTOOL_A_TS_LAYER], + "this net device cannot support hardware timestamping"); + return -EINVAL; + } + } else if (ts_layer == PHY_TIMESTAMPING && !phy_has_tsinfo(dev->phydev)) { + NL_SET_ERR_MSG_ATTR(info->extack, tb[ETHTOOL_A_TS_LAYER], + "this phy device cannot support timestamping"); + return -EINVAL; + } + + /* Disable time stamping in the current layer. */ + if (netif_device_present(dev) && + (dev->ts_layer == PHY_TIMESTAMPING || + dev->ts_layer == MAC_TIMESTAMPING)) { + ret = dev_set_hwtstamp_phylib(dev, &config, info->extack); + if (ret < 0) + return ret; + } + + dev->ts_layer = ts_layer; + + return 1; +} + const struct ethnl_request_ops ethnl_ts_request_ops = { .request_cmd = ETHTOOL_MSG_TS_GET, .reply_cmd = ETHTOOL_MSG_TS_GET_REPLY, @@ -69,6 +165,9 @@ const struct ethnl_request_ops ethnl_ts_request_ops = { .prepare_data = ts_prepare_data, .reply_size = ts_reply_size, .fill_reply = ts_fill_reply, + + .set_validate = ethnl_set_ts_validate, + .set = ethnl_set_ts, }; /* TS_LIST_GET */ From patchwork Thu Oct 19 14:29:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?K=C3=B6ry_Maincent?= X-Patchwork-Id: 155604 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp425372vqb; Thu, 19 Oct 2023 07:31:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG31LzGjFBcdULL1130f1ygRIlvQ0TLn+Jy9wSaTahDZ+6geg7HkNqj+VF5BHJU9FVzMaSD X-Received: by 2002:a17:903:2ac8:b0:1c9:faef:5765 with SMTP id lw8-20020a1709032ac800b001c9faef5765mr2171235plb.5.1697725887866; Thu, 19 Oct 2023 07:31:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697725887; cv=none; d=google.com; s=arc-20160816; b=y+9z2DswTxCMbVV0IoEk8FNBVs2qtH/CPGR+YFa/Dwoab3OoPOm8XyCZAwIUamV7fi Z7yfrE4MP7+ZkAmVHxiX21W09c7idmLxkgRkD/Y2RYddOvcPWewrJN9DiWtXBgS9nna5 OGVUDdbn916+vLItdbWDdPl68xAmF0CZhlLIhYsu9g1KR9Isn6skk7WlCoZO/0wTgQGs IW90R1+poMfmgOu/h5+jkdMKEoey7LD0E44ohh5pHZG8xTUflOllWj0lEdbky0UTPLq6 nhEgC/+5ZGITaKs8vm8Bdr/xcV9NkYo51FZy6mOY5HL+RKN6jCOvHUtTVt+Y9+fXNoLD +uxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=fOSgXCQ1eufYILoSDYjDEVxI1OePejpExOW8kSLC0lg=; fh=IL4Om7kRbYP5ILTMWk7kzVj5RVF0+t2ztL6E2Yzsl4U=; b=CzK7Od5LWFapSo4zCdu72VthQqn1i4TL05bpjQRKSgU/71XzHvGDL0y5GWhkMcJIuz Ap+naJ23GdBFaKheGJt5y91I+1CmbCwDSLbCPZhQ3YZDH4zGqbqKbBH+1L4P4cYEznO+ 7cg9yGzoNKcRpLmGdNUlA5XjOMU2jevq5AtlW4yv8qaH+FNY1WOHMrxLqTlArnmTTQQ7 vTbbXxWDPOchZJYcikBVwjOzjAjEgQS8uohPIr5SXamV5Cn1JnIPPXGmlZD5b8HZKx6u i/zHNEoVkJtX12RMQSjHE8WQy/fX5Abc9NOo/jDFur9qb6W8E0PphMvvvl8xujxGieMd kbAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=HsNMiuIF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id v10-20020a1709028d8a00b001c5d09c7b0dsi2187715plo.458.2023.10.19.07.31.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 07:31:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=HsNMiuIF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 49314819972D; Thu, 19 Oct 2023 07:31:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346154AbjJSOal (ORCPT + 25 others); Thu, 19 Oct 2023 10:30:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346194AbjJSOaL (ORCPT ); Thu, 19 Oct 2023 10:30:11 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::223]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0382185; Thu, 19 Oct 2023 07:30:03 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id CF47F60003; Thu, 19 Oct 2023 14:30:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697725802; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fOSgXCQ1eufYILoSDYjDEVxI1OePejpExOW8kSLC0lg=; b=HsNMiuIF66nEyXtvLt2d1ySlhaEeqleKXPD9NqDxbwIC8gJjEzX0MtMhSdr2d2zm7ARPvq Wbt2aXrSRgE0rmdDISRcQ2SkPhHgNFBtIKzZYy3idYqaxMmfi3BZXFcp+guK4XeP+Hldf5 mmmmnoS4uf7dwZaUVbLX7X6KOPqoiL1ZkmdY8HlsSC0Tbns/as5V59w//5jTHRPUNqelXQ nlgrabhhsJkvfJSKqWVkX1voPOpRH/NlDK0u9ut2BhmRDlZFxxD34cmsvsSIJYYJeNxjZD fuunUkAFbSPoVkva6E+0DiGD6abP7yd1rIxNGRunCeNvgxwgOSUp2ZnT4Tegdw== From: Kory Maincent Date: Thu, 19 Oct 2023 16:29:31 +0200 Subject: [PATCH net-next v6 16/16] netlink: specs: Introduce time stamping set command MIME-Version: 1.0 Message-Id: <20231019-feature_ptp_netnext-v6-16-71affc27b0e5@bootlin.com> References: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> In-Reply-To: <20231019-feature_ptp_netnext-v6-0-71affc27b0e5@bootlin.com> To: Florian Fainelli , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Radu Pirea , Jay Vosburgh , Andy Gospodarek , Nicolas Ferre , Claudiu Beznea , Willem de Bruijn , Jonathan Corbet , Horatiu Vultur , UNGLinuxDriver@microchip.com, Simon Horman , Vladimir Oltean Cc: Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Maxime Chevallier , Kory Maincent X-Mailer: b4 0.12.3 X-GND-Sasl: kory.maincent@bootlin.com X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 19 Oct 2023 07:31:25 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780194620201372091 X-GMAIL-MSGID: 1780194620201372091 Add a new commands allowing to set the time stamping. Example usage : ./ynl/cli.py --spec netlink/specs/ethtool.yaml --no-schema \ --do ts-list-get \ --json '{"header":{"dev-name":"eth0"}}' {'header': {'dev-index': 3, 'dev-name': 'eth0'}, 'ts-list-layer': b'\x02\x00\x00\x00\x01\x00\x00\x00\x05\x00\x00\x00'} ./ynl/cli.py --spec netlink/specs/ethtool.yaml --no-schema --do ts-set \ --json '{"header":{"dev-name":"eth0"}, "ts-layer":5}' none ./ynl/cli.py --spec netlink/specs/ethtool.yaml --no-schema --do ts-get \ --json '{"header":{"dev-name":"eth0"}}' {'header': {'dev-index': 3, 'dev-name': 'eth0'}, 'ts-layer': 5} Signed-off-by: Kory Maincent --- Documentation/netlink/specs/ethtool.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/netlink/specs/ethtool.yaml b/Documentation/netlink/specs/ethtool.yaml index 81ed8e5f2f55..cfee4bf32128 100644 --- a/Documentation/netlink/specs/ethtool.yaml +++ b/Documentation/netlink/specs/ethtool.yaml @@ -1740,3 +1740,12 @@ operations: attributes: - header - ts-list-layer + - + name: ts-set + doc: Set the timestamp device + + attribute-set: ts + + do: + request: + attributes: *ts