Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1310630rbb; Mon, 26 Feb 2024 05:42:58 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV3JM1oYLK+UjtQalcM7SJbpQXSoayYhwnu8DodvIBs4tEnnTUZybLzCCLz5qXVc/ZwT2vpWLrtUSw3C/inWRI76X6BQ6D15ylQKgpSFg== X-Google-Smtp-Source: AGHT+IE0qoI/pZf8SQXblLwKnewfFlk44ODCK575Wtfb/lkJOQozKKnOykzGi8M8688tlOldcg9M X-Received: by 2002:a05:6512:3d0e:b0:512:fa7a:813f with SMTP id d14-20020a0565123d0e00b00512fa7a813fmr2933800lfv.10.1708954978297; Mon, 26 Feb 2024 05:42:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708954978; cv=pass; d=google.com; s=arc-20160816; b=gKCItjtnj+1u7v4A8oiIMx1kfvSkOXVTSoj8iR/hQzVPo0qYHnfOevbm1zlifCX3HO YKa9rA+fRpRe/zjC8AFiEifTeLtawym6bk27Afl/ks47jP2OP5Tx1BLsJi4qNgo3hB0u v1U/2usHjc74t1R/LftXVMUfsEvbW8jwF/Iqgeim2vhSLNu0Wsfxi1w/OrtDSpxvuftc RlOMtqWMpMZnIIxC1ud1YGJVhUj8Bt+KDJRhK3IZ5xdQj+tSpQ5mmnDK4l7vlHGkjbGK HI3pQkMw7ULe2YRKXgAzgkXAUxDaJP4CLPIxiNakeoHFwjx9mZv0n/Jnad9f6mDUF3qe qnTA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=Gq+8CqbRK0bNTdHWzW38Hudxf9L3BTTuFVfiz/meMfc=; fh=vtlcgQ30nO0QjQR7y1Wfn7g9c11A+T6SWcSZ6WixcJI=; b=kVpMmYxGQg5uEZSGfIDnnl2l3nVRG7A0bbLUQOLjSwFOykD6Yf1BQcWdffqoqsb0Xl YYfpyS45ZGpv4C5laJK0oy+2n1FU4lVUldC2Y6pldvS6n5JbRngCpuwyHkEx6GjErmZ3 NPD8luSeeI4uSCQjfyBpz8bwqhL9sgkUCisb6V5oMBiA81LC89jT0ij9aVi6h+0/f+EG usTE3YFt/KfIGiSUuC01YZH3nQh9oUNhrGbOmWxed3aAlxux0CL0Yr91qUDOCcaADf8p j4QoWc2dPrrOGnMrdv7wOB/6akp2S3pJNiNCjrdbX04INC2C0K46OyqtYDeYBu6Wsk8i JC5g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="jEKj/su9"; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-81511-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81511-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id z6-20020a509e06000000b005657b632d53si2002283ede.579.2024.02.26.05.42.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 05:42:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81511-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="jEKj/su9"; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-81511-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81511-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id CB9531F28C0F for ; Mon, 26 Feb 2024 13:42:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7880612C814; Mon, 26 Feb 2024 13:40:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="jEKj/su9" Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6344312C53B; Mon, 26 Feb 2024 13:40:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708954828; cv=none; b=LZJgjHb2AFxwi5xxzl1cXHJ+05f2TsX3e8YBNnp/9y5uBtYq5PEh7E67LBBSDtif7W18UeoK870CdVXDLfDdKx6oM8S+cNFGtyA2hz1Cxcei8e/8Bsb7HLe/3Sdpt8l2AB6TnH8TOaFwgY0jQmpGz9Ov22tzpmP9MlOYBeIorAs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708954828; c=relaxed/simple; bh=PYeI0mXSVSX9o+T/dB8fcu+Qtcihzq/j+ecDGARPjf8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Kr3AjM7x7Jth1/DfNrf02ku/umDknR5mNoiXlzLW78mcjpTmIbmAJpnhLirj1kRXdiYzMK/2ymOzGC2zmxFBk7lED3s+CQAuraEBsZUfjBB3rJg5qS2P4YUvCsqCTh2BnIhfL7O4VdmZEHvQKQVJualMjZUsg6whIJFS/hXJAS8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=jEKj/su9; arc=none smtp.client-ip=217.70.183.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 8461640016; Mon, 26 Feb 2024 13:40:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708954824; 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=Gq+8CqbRK0bNTdHWzW38Hudxf9L3BTTuFVfiz/meMfc=; b=jEKj/su9Yb7eOwQ4U1IUIfCOdWeeHrkYEGMTkt1lVLhCZs/SBVzI94doKCgJIj/3WRp2Sk Em6QGvkLE420/RYQ0nK+cwCajxZb7zLSslw6XlgFp5YMLPQSsN1d+bWSMDklbAAoh/gIxn KqFwd6hQFwYtY6x0rbkIS2v0IXOjLnaMknS1eq76IlsOU1HT8bzrPYJBMd8e0H8Kh3Yt03 /i4JJsIUPOby7aCgorrzOmyXMg/m8piro8uhWXxyr0tP8DU9xc1yDvF2rmegiZM29b+FaS nHwnwYFJzhGkr+xWPB/+4oNFMmGKmBbzMwRrYdL9YqurF+bkQju9FRQ3QQLymQ== From: Kory Maincent Date: Mon, 26 Feb 2024 14:40:01 +0100 Subject: [PATCH net-next v9 10/13] net: netdevsim: ptp_mock: Convert to netdev_ptp_clock_register Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240226-feature_ptp_netnext-v9-10-455611549f21@bootlin.com> References: <20240226-feature_ptp_netnext-v9-0-455611549f21@bootlin.com> In-Reply-To: <20240226-feature_ptp_netnext-v9-0-455611549f21@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 , Rahul Rameshbabu , Kory Maincent X-Mailer: b4 0.12.4 X-GND-Sasl: kory.maincent@bootlin.com The hardware registration clock for net device is now using netdev_ptp_clock_register to save the net_device pointer within the PTP clock xarray. netdevsim is registering its ptp through the mock driver. It is the only driver using the mock driver to register a ptp clock. Convert the mock driver to the new API. Reviewed-by: Rahul Rameshbabu Signed-off-by: Kory Maincent --- Shouldn't we move the mock driver in the netdevsim directory as it is only used by netdevsim driver? Changes in v8: - New patch --- drivers/net/netdevsim/netdev.c | 19 +++++++++++-------- drivers/ptp/ptp_mock.c | 4 ++-- include/linux/ptp_mock.h | 4 ++-- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c index 77e8250282a5..7f58645559b5 100644 --- a/drivers/net/netdevsim/netdev.c +++ b/drivers/net/netdevsim/netdev.c @@ -321,16 +321,11 @@ static int nsim_init_netdevsim(struct netdevsim *ns) struct mock_phc *phc; int err; - phc = mock_phc_create(&ns->nsim_bus_dev->dev); - if (IS_ERR(phc)) - return PTR_ERR(phc); - - ns->phc = phc; ns->netdev->netdev_ops = &nsim_netdev_ops; err = nsim_udp_tunnels_info_create(ns->nsim_dev, ns->netdev); if (err) - goto err_phc_destroy; + return err; rtnl_lock(); err = nsim_bpf_init(ns); @@ -344,8 +339,18 @@ static int nsim_init_netdevsim(struct netdevsim *ns) if (err) goto err_ipsec_teardown; rtnl_unlock(); + + phc = mock_phc_create(ns->netdev); + if (IS_ERR(phc)) { + err = PTR_ERR(phc); + goto err_register_netdevice; + } + + ns->phc = phc; return 0; +err_register_netdevice: + unregister_netdevice(ns->netdev); err_ipsec_teardown: nsim_ipsec_teardown(ns); nsim_macsec_teardown(ns); @@ -353,8 +358,6 @@ static int nsim_init_netdevsim(struct netdevsim *ns) err_utn_destroy: rtnl_unlock(); nsim_udp_tunnels_info_destroy(ns->netdev); -err_phc_destroy: - mock_phc_destroy(ns->phc); return err; } diff --git a/drivers/ptp/ptp_mock.c b/drivers/ptp/ptp_mock.c index e7b459c846a2..1dcbe7426746 100644 --- a/drivers/ptp/ptp_mock.c +++ b/drivers/ptp/ptp_mock.c @@ -115,7 +115,7 @@ int mock_phc_index(struct mock_phc *phc) } EXPORT_SYMBOL_GPL(mock_phc_index); -struct mock_phc *mock_phc_create(struct device *dev) +struct mock_phc *mock_phc_create(struct net_device *dev) { struct mock_phc *phc; int err; @@ -147,7 +147,7 @@ struct mock_phc *mock_phc_create(struct device *dev) spin_lock_init(&phc->lock); timecounter_init(&phc->tc, &phc->cc, 0); - phc->clock = ptp_clock_register(&phc->info, dev); + phc->clock = netdev_ptp_clock_register(&phc->info, dev); if (IS_ERR(phc->clock)) { err = PTR_ERR(phc->clock); goto out_free_phc; diff --git a/include/linux/ptp_mock.h b/include/linux/ptp_mock.h index 72eb401034d9..e226011071f8 100644 --- a/include/linux/ptp_mock.h +++ b/include/linux/ptp_mock.h @@ -13,13 +13,13 @@ struct mock_phc; #if IS_ENABLED(CONFIG_PTP_1588_CLOCK_MOCK) -struct mock_phc *mock_phc_create(struct device *dev); +struct mock_phc *mock_phc_create(struct net_device *dev); void mock_phc_destroy(struct mock_phc *phc); int mock_phc_index(struct mock_phc *phc); #else -static inline struct mock_phc *mock_phc_create(struct device *dev) +static inline struct mock_phc *mock_phc_create(struct net_device *dev) { return NULL; } -- 2.25.1