From nobody Thu Dec 18 18:03:49 2025 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (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 EE787175571; Tue, 30 Apr 2024 15:50:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714492254; cv=none; b=MN/OiRqs1c5SlRekFwqA6GN7zfUxZZCJdk+YZ0qZBc/Y1xTSOgFDDejWqqDpTTRx2WscTIwjUvjESFSQQg3w2aFC8VJ/xd3d76h2oLRqH2+caY1BvAKipTcARS2xd3UoMo+EJ454THMehsQI54OSjgtw/zkFW/YVh0MXoPkmxZY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714492254; c=relaxed/simple; bh=MR4T+aVryHDlCdLIA+7+MzjoHtX5UbAViJjBqaEXzNI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tqOAh/NWtCDDizgTg8CGaoZwZ1dFgopp8nKvyocckvpHHaROZj6VfVlkeeuEgJmjaQjzZGE5gf2eILdNGKpJBRn+zBsIYy2omwizFx3DL8KuzjZbnMOzfmNS+p+RQrvAPIvvqGtgTDp3qXr73UlbsN+uRpzJq3oerUv+MmpzYjQ= 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=ElhFqnSP; arc=none smtp.client-ip=217.70.183.200 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="ElhFqnSP" Received: by mail.gandi.net (Postfix) with ESMTPSA id D4F7520016; Tue, 30 Apr 2024 15:50:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1714492239; 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=EtjDyVeqqMgYUVSHB7nyuZRP2kSxS8c/e1unyRtkL5I=; b=ElhFqnSPGOxirfUFhmp8R2K6zVMRcIlW7z0lkVPipo6NHYFqJrlJOrKs6Zciz2XzHcKDTY a9X5/vzDV/Hbnk+aQqj8QiHGko3GFjvlbaAHs6Usf0i3MRRz8GZtqXRY6OXmhhlMEJVBei JKdirDIoNp+XiGdQVqj/AyWgWVwpP5PCUZXQjcK5hb2+xXkOfs9x6pKRjWqySTAkHvbIkt BbeIhCxWADpn0x6eTBR6JQ6RuHbi1d+dAnr5nXPaHpkSRxL8EwvD6LL96vnTtx3IN0cjg4 GtQYcXLd2kI73yOlDHLcOPBsAr8I6DmyGn766H1ybHhr/ct1HXSU5ab8sEnrfQ== From: Kory Maincent Date: Tue, 30 Apr 2024 17:49:53 +0200 Subject: [PATCH net-next v12 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: quoted-printable Message-Id: <20240430-feature_ptp_netnext-v12-10-2c5f24b6a914@bootlin.com> References: <20240430-feature_ptp_netnext-v12-0-2c5f24b6a914@bootlin.com> In-Reply-To: <20240430-feature_ptp_netnext-v12-0-2c5f24b6a914@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.13.0 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 --- 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 d127856f8f36..c53d2163022e 100644 --- a/drivers/net/netdevsim/netdev.c +++ b/drivers/net/netdevsim/netdev.c @@ -482,17 +482,12 @@ static int nsim_init_netdevsim(struct netdevsim *ns) struct mock_phc *phc; int err; =20 - phc =3D mock_phc_create(&ns->nsim_bus_dev->dev); - if (IS_ERR(phc)) - return PTR_ERR(phc); - - ns->phc =3D phc; ns->netdev->netdev_ops =3D &nsim_netdev_ops; ns->netdev->stat_ops =3D &nsim_stat_ops; =20 err =3D nsim_udp_tunnels_info_create(ns->nsim_dev, ns->netdev); if (err) - goto err_phc_destroy; + return err; =20 rtnl_lock(); err =3D nsim_bpf_init(ns); @@ -506,8 +501,18 @@ static int nsim_init_netdevsim(struct netdevsim *ns) if (err) goto err_ipsec_teardown; rtnl_unlock(); + + phc =3D mock_phc_create(ns->netdev); + if (IS_ERR(phc)) { + err =3D PTR_ERR(phc); + goto err_register_netdevice; + } + + ns->phc =3D phc; return 0; =20 +err_register_netdevice: + unregister_netdevice(ns->netdev); err_ipsec_teardown: nsim_ipsec_teardown(ns); nsim_macsec_teardown(ns); @@ -515,8 +520,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; } =20 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); =20 -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); =20 - phc->clock =3D ptp_clock_register(&phc->info, dev); + phc->clock =3D netdev_ptp_clock_register(&phc->info, dev); if (IS_ERR(phc->clock)) { err =3D 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; =20 #if IS_ENABLED(CONFIG_PTP_1588_CLOCK_MOCK) =20 -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); =20 #else =20 -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; } --=20 2.34.1