Received: by 2002:a05:7208:2202:b0:86:316c:7444 with SMTP id s2csp2376509rbb; Tue, 4 Jun 2024 03:43:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV7n5+MmoBXBBDyYogkGv2holwQUdc1mFKSqK95cj8AVJ7K71HpOuH5bWbVTDeP9jnQJ1g0ArYPAdQ28wSuXW5G8qJH1dgmTsD+Vduuww== X-Google-Smtp-Source: AGHT+IHqyEzQMszlWS7wX1IdgjLsisl2oH+Xmtv/NLvkupkzuKWw/Yq33oIpTmHc/bpRKwP+7FSg X-Received: by 2002:a17:906:3e4d:b0:a69:67e3:57f6 with SMTP id a640c23a62f3a-a6967e35a8emr87421066b.5.1717497788702; Tue, 04 Jun 2024 03:43:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717497788; cv=pass; d=google.com; s=arc-20160816; b=ZP5L1ZiuLEny2I6SvhvFqsNgdXGh3bZ9DHp49JSMV7DyNI6JhlRucSXR3Fe7Iofhig OCfs8S5JRiIDstJKgf+nzuzCFd/Br/FO5/lwCaFHA22yQPtC2HEe7B7pkfNoV1rw0auw BsGp2UtOwwuClPiA1mgSMY/D/6+x3mMVU3BBIYH5HOTKI7M9Pf8RS9bCtbH9dP2xv4nE FILxHtsl/CYaEPlY2IHi6xfi4B7q6Cgmq+XOkAUjBUS3wYNEriobz7qs0gogXKPIjZrt sIbtKbaatnA5Y1T5+v2/pQ8QJ/XsDknbQAkoCLY4MolQsEoXf4HF2f1ogldtgJRwtQDd ZyLw== 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=YXhuPfMb8JiYCutfiZUlVCVpb7e9NN3nMxofwfDJxZk=; fh=vtlcgQ30nO0QjQR7y1Wfn7g9c11A+T6SWcSZ6WixcJI=; b=FrXHG7AF2fwkNozWNwivxeZuLbRPlSd7ZVNdlz0vFW2BmJ9P9sGFKAtKtOk6F6YKVc g1X8GnuKbL5yim9wO+6k4UnIOHjGzqt5gtI7EJRxcGMl9ck2bFGM7hl0eq7B34Q12cFx 1X0RlNuytxhk92A4MWRzKza2bduHOEge1nCXFxJa9UhS0Zyw1T9M8wAtVFTuMyjqeWQp uLDPzcfrlr3hyzdJecu+GIdIlB/UiB4xGNYjTlQLRA2zfDO/Wscp4E2NeagL/ya/0BM9 WXxrWHXwmIv5fB8i8isnyHkqI/ffQI7wVj6OnOsphqt2Iwsw+QEe+Sd5rdbK8ZT34hTF 99dw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ZzaP3Lcm; 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-200442-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200442-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 a640c23a62f3a-a690427c298si198096566b.23.2024.06.04.03.43.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 03:43:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200442-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=ZzaP3Lcm; 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-200442-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200442-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 4D6EA1F20933 for ; Tue, 4 Jun 2024 10:43:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6C58C146A7B; Tue, 4 Jun 2024 10:40:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="ZzaP3Lcm" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 3E8DB146A69; Tue, 4 Jun 2024 10:40:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717497620; cv=none; b=u/4xHczaDzIyELJQg5lkK1KUSwY4ZJnhVudKr+o4JNPIfzO6zZqmmnoAw9xK2ypWNjG30YzQemPyXXOcOrbDLIhiEoz0WKv5fa0OYj2bHZ0/n4RwbkSjQ/PG9FslSw41njG8sP08/cbomxKPZb3tHk6thAKmcxXPrMEXg4hRVRk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717497620; c=relaxed/simple; bh=7yhAM6xH9kCUFSvDoP+AEJuCocl7K81S23eYIiV8v30=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tHqbUCc6PJSzrD7GyPtC75kR2HdPK43Ii+pxl26LU6xihs6fIUYNNHHqrMVxzOiYbhToxCYkKeCKrBjFp5lsd0StCn1xSiduPNJitbhbYQhZvhHTStG8WKo+mxxeTuXdUVLTuTwWeUfH4JE/RxpjRuLdhGqJ8anpFfJ4dXgDu0g= 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=ZzaP3Lcm; arc=none smtp.client-ip=217.70.183.201 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 D7C1E1BF206; Tue, 4 Jun 2024 10:40:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1717497616; 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=YXhuPfMb8JiYCutfiZUlVCVpb7e9NN3nMxofwfDJxZk=; b=ZzaP3Lcmxfjr7gJhZb177k5Y113ChXkBQ6BsTHc5/mDKEwA9VsQceBsETOSlwdVU7bTf6G fw4+IfFJOuc44mavp3dnWonWdLE3+W9kkDA71ZzQUy+EyoB2VpwKVRcO4eBi+JHxgDFsVN s3c2CQswspGboYg1XcnEEHWTszSKK8eKIo2WfUK0KbVVksjLwl8x7uc+mgfHk6jgwYML3N 7WZN8xx3kJ6C2NPwvSkkUkVAyBwfzsHvV6TF7Hi/e5O97j2zpCebsvF5KHOAU63Fq0M7Tg 6mc5nSpgi1WAGWXv2yCaVhkF+2RfXypOQtudao7dwsljQrrz6Ufx5trpZsJovQ== From: Kory Maincent Date: Tue, 04 Jun 2024 12:39:45 +0200 Subject: [PATCH net-next v14 10/14] 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: <20240604-feature_ptp_netnext-v14-10-77b6f6efea40@bootlin.com> References: <20240604-feature_ptp_netnext-v14-0-77b6f6efea40@bootlin.com> In-Reply-To: <20240604-feature_ptp_netnext-v14-0-77b6f6efea40@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 c22897bf5509..51ba5e75740e 100644 --- a/drivers/net/netdevsim/netdev.c +++ b/drivers/net/netdevsim/netdev.c @@ -662,17 +662,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); @@ -690,8 +685,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); @@ -701,8 +706,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.34.1