From patchwork Wed Oct 30 13:54:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kory Maincent X-Patchwork-Id: 13856575 X-Patchwork-Delegate: kuba@kernel.org Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (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 9C65F1E8856; Wed, 30 Oct 2024 13:55:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.197 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730296515; cv=none; b=oGgWklkN7oSGRusF+xfGeeJ/QW8+JXTSi5ZbvKF97jtbmXGAAxQsQ3IC/5rT8/TLpmVnhM5nJRgaR/k6TSekrV5yi8A6Ek7X4Ltp0SB8+9A9Lgi6DN8DexbL0dNUsgBzEYwn+OaqB29MUzGRE9AWRbKEx7XHQoUazxnADr520JU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730296515; c=relaxed/simple; bh=AiJJTj4Ei6Pu4fYDdoi5BN0+nk+u3cB660WzYT17JKc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iJjsL69YIZ3JaNdGjvgwVzl8wt+3HCq9fYHER4bslnVIqW5M27VkdFr0va8vJ8x/t5dTALuo9LBmLtw881W/fGSkV3YCdLrUJaPtSZ86MvYCnuiak1M2tsjxDiU/eKm5j0YjzPYqOwi4NChNoDqDM/q1uGS71953EdQGqRw3Mtg= 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=Icf+MFA/; arc=none smtp.client-ip=217.70.183.197 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Icf+MFA/" Received: by mail.gandi.net (Postfix) with ESMTPSA id 60B431C000E; Wed, 30 Oct 2024 13:55:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1730296511; 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=Fq4eTw5gjPKZ2qkeh1v5b1UUeAkITT/C7oYWuEbLAbk=; b=Icf+MFA/vGYFYyHj8H3lxAchvi+bXit6n+J0RLjiNQP9ubfcw2s0vLdZbVOBBvDEBbez0D CmRgvD9cWbCKzf0lf6KxcM4K4doduwsY9TlrN+U8u8LNgqbHkyZH9/Q+OEZ/qMa5YAnR3B lneTHOVq2VtkrS/3j77CRyTsWBnWEO9QFSSSnO+o15boqDWDbdcdqucuuS4oUEEatLqJ2r c6w91Xo920oERJjc2O+UKbsJGNT+Kf8LesByDy9HvOQuLUeERU+TWiWTNDndTdtDUXBbfd qSLjw9jlXcONDPRGS9MwTSxKEUt1+vnP3HH2dP90MIsYa7WxW27gBjQPuQNCBw== From: Kory Maincent Date: Wed, 30 Oct 2024 14:54:47 +0100 Subject: [PATCH net-next v19 05/10] net: netdevsim: ptp_mock: Convert to netdev_ptp_clock_register Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241030-feature_ptp_netnext-v19-5-94f8aadc9d5c@bootlin.com> References: <20241030-feature_ptp_netnext-v19-0-94f8aadc9d5c@bootlin.com> In-Reply-To: <20241030-feature_ptp_netnext-v19-0-94f8aadc9d5c@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 , donald.hunter@gmail.com, danieller@nvidia.com, ecree.xilinx@gmail.com, Andrew Lunn Cc: Thomas Petazzoni , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-doc@vger.kernel.org, Maxime Chevallier , Rahul Rameshbabu , Willem de Bruijn , Shannon Nelson , Alexandra Winter , Kory Maincent , Jacob Keller X-Mailer: b4 0.14.1 X-GND-Sasl: kory.maincent@bootlin.com X-Patchwork-Delegate: kuba@kernel.org 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 Reviewed-by: Jacob Keller Signed-off-by: Kory Maincent --- 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 cad85bb0cf54..dd9f4acafcd5 100644 --- a/drivers/net/netdevsim/netdev.c +++ b/drivers/net/netdevsim/netdev.c @@ -702,17 +702,12 @@ 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; ns->netdev->stat_ops = &nsim_stat_ops; err = nsim_udp_tunnels_info_create(ns->nsim_dev, ns->netdev); if (err) - goto err_phc_destroy; + return err; rtnl_lock(); err = nsim_queue_init(ns); @@ -730,8 +725,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); @@ -741,8 +746,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; }