Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp516614lqb; Wed, 29 May 2024 02:44:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW75DCDiLo95Ut2DbcpHpZKCfWsr/nywCdeigiPoXxM42U8a+sQ1SoT1O5mZ3ffG1KkvFyUKpNuYJRLXV3mgR4t33wIzomn5w6KvGjLsA== X-Google-Smtp-Source: AGHT+IF71i1jOosgNtHsy89N3vGODKfIQevt0TmNmcXsZxvo699rWsVHTWcl34KAb/iLlT2cBtEn X-Received: by 2002:a17:902:eccf:b0:1f4:7bf1:71de with SMTP id d9443c01a7336-1f47bf174c2mr108289345ad.12.1716975892330; Wed, 29 May 2024 02:44:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716975892; cv=pass; d=google.com; s=arc-20160816; b=ZVaGoXZB4aUknXgNCu1vmYhebb8WDg0bOoxnvHnYk/Y9Rp74LU/9XgqzqKka6BFNM1 pNPXngUfrxU/++AHDnBofNNW+GtrJCDGbJnEXMe239bH1q6jxw5TVXrsY4u4U1ehQyXk hKjIJaOclcKwqvkkF0HWadHstIgXirOy8lBb3as9gCRb26fBNPcfqTr8h8oA+QnvYgSI 8cDQgILiHEAt6b2EhwKqb/ZnO4p6DL1BHs3fOToHMRGn6BPKDpW7133rqvDDQGKqdG59 NvFH/VO+T0VWvNcVWs/frWbenDu5ve+TqYRfyuJZWiBvO5p3Ysq2udH2KsJFRTROL2GY /rww== 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=W4wMPmLNMvNsgE0AmrW6kbMDblm/mxFM5jloI5e5mtY4BH6n3AXGizoUC1Mhn6Fddi mCw3Y9wEpB6jsn8xofvYFyVxxQDtJSNLBhZh/2AmSZmvealqInw8+4eQnr04hc8Tisah 7/yp8D9yC3NY9sQ6/dRC3Ai3obz07iBHlagZMbWMhDgBlIBr99g/QF0g797Vxu24FBBp cdZI15KXJM+giEzIrJIIob2GWqXQ4SPEtdEz71/42f77m6uMxHjph2iqCk03ZnnGtkBA GEkGkEGQv5aAIEaseX4a8iZltTCcxPuXb1dHQjPKpuC+Q4UpZwtoi1e4VhRl1Ufd2WWh Jj8Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=j6UhuSsL; 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-193869-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193869-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f44ca213adsi95732385ad.646.2024.05.29.02.44.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 02:44:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193869-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=j6UhuSsL; 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-193869-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193869-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id EBE9E28B5E2 for ; Wed, 29 May 2024 09:44:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CEFB717F39F; Wed, 29 May 2024 09:41:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="j6UhuSsL" Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (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 8999817B4F9; Wed, 29 May 2024 09:41:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716975713; cv=none; b=nnsO55dFs1SGZE+lQrHMq/MKBIONZqAu2wobZFI1eXsERWbrecdoD+scjcq4lIgrio8vb4DfYpyhdwN50BzKa6fFt+BK7sQEO082ahvBKzQLC3T7zQscHhFwn2y7QM1fjs5MUK4nSOsmo/sFpYjUUvVVUN0W/nR3SYmBmjDLEeo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716975713; c=relaxed/simple; bh=7yhAM6xH9kCUFSvDoP+AEJuCocl7K81S23eYIiV8v30=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jhkLmyv7n4/10h/I+rKCTZqYfHOAXTuXQvzUnQPJJvL9DdGTyB7R6ZecNyOpE7vwpaJdhdmcoEeDp2Xirewb2eu+/AgXbnrcQgeEaAfzBgy4iaU5H0awWL++wF6sQwYBlvpt+7dg+kGzJ3HM4eWbDH1ly/N5PaPNDIQsz8v/BEE= 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=j6UhuSsL; arc=none smtp.client-ip=217.70.183.195 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 84E196000F; Wed, 29 May 2024 09:41:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1716975709; 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=j6UhuSsLr4zqQaxvbXfIh3/ve0KrV7HIpaH28X8hP51oZzMCb9Qt/LD1ZZjZv0F65lJbpe kPS50lEYoNE2ApP9xWOPOHUOvVWy5Di82bcycQ+VNXaknvm2UBs1TLO5e3zk3Kms/O5OLC Mptk4nANXWbtqAY4czcCM7oGxS9LhuUPJfE02hPKdcP9pNr/UCBlhY9G7HO1HsX9Ylj8Lr ZrIDgAq3Omzz1SaJi4U7FFmiACzgf1A3R1EGZlA2AxFFLIEN2biOfzeiGOSD87NCS38j9R HR5AmdSK2OkIBTb2Yj3rx9viTB9uWVi8Mp/lAEWBwsUu+U+9DDbofhkt2ZaLRA== From: Kory Maincent Date: Wed, 29 May 2024 11:39:42 +0200 Subject: [PATCH net-next v13 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: <20240529-feature_ptp_netnext-v13-10-6eda4d40fa4f@bootlin.com> References: <20240529-feature_ptp_netnext-v13-0-6eda4d40fa4f@bootlin.com> In-Reply-To: <20240529-feature_ptp_netnext-v13-0-6eda4d40fa4f@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