Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2245562lqt; Mon, 22 Apr 2024 05:59:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVmSd6Lu98Iwj+uLy14ZBoEGh9SJFhh/EanuK4HPnzYRcUJPyrWi4XI4nQyYLF2OJOxVj4CnyZholV00O5AyXbrkJBIn/xRXnPCtZm0Iw== X-Google-Smtp-Source: AGHT+IG+8vezax0suZVqV8Tt1BuVVcghniQPbP4EBDCSJQjbXWekBsp7EXw7Bg3cHXXW0YnqUYlF X-Received: by 2002:a17:903:22c1:b0:1e2:61ca:9449 with SMTP id y1-20020a17090322c100b001e261ca9449mr12576069plg.40.1713790778359; Mon, 22 Apr 2024 05:59:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713790778; cv=pass; d=google.com; s=arc-20160816; b=Q3TD6j6FBuAQ2/TnA7li5oM7SaieXidKwJYKogjrSgnF5WAaP4jQ+ZRN7AdFdKf4qT XTHfbvWSu3A9tCJ0MMLW+py1OyvaKMUSyQHuBVBoly/XqOQqNCZgG/NVW5vxPs1ajKZd OUxswNAUy4t0BnxL17h3OPACEfnFiL6xguVtppEaRFOW6Z96E8ARP02L51JWO9GMBRGp NUriP5LyeG1msFv7b0cxcfJB1Tc+TEfhvficakXHGNaUHOiU7pbqvntmqL6AxH+is7Xu yFbBl3faLFgd9Ti4xY925JbVI0xdWSG58Z8NV4E/rzZOZ7kRix/KgMce9txgXfV09hno lihw== 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=EtjDyVeqqMgYUVSHB7nyuZRP2kSxS8c/e1unyRtkL5I=; fh=vtlcgQ30nO0QjQR7y1Wfn7g9c11A+T6SWcSZ6WixcJI=; b=TfhdcR8KQWuxwQ36zICqlFnvvOANotnK4MDohx1Gmcg3KQwPaM5AgSEoId40aHeI1E oY6N05ohMFJBT4mS9Bq8/IZhFDF6yYp7teAGUsYN2WXlKD91s/Os33HQAOWyAiEAq2RY gIYd2JlrKo/IhQtqT1pbOUPPU38DEUREQtjRUxJ074BrVkwoxGwymTpH9oLRMNJ9YEnn WIGwZX1q7DXQ3iy1IbF5XV+oin7XpGdNg+Y5qHAw8tWfVd6rFCXywwasMNcyNDKXfs+m Lt9xC7jUs7/rkDbDfjH5dplaWK+7+MHwiTjHBtDSQIJBYC+xUHz+ByDvsCVDkk6adLkV 5AEw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=h79QtJDL; 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-153384-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153384-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id t12-20020a17090340cc00b001e9668d755dsi3000526pld.39.2024.04.22.05.59.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 05:59:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-153384-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=h79QtJDL; 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-153384-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153384-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 7FB1DB23F90 for ; Mon, 22 Apr 2024 12:53:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 590B6152E11; Mon, 22 Apr 2024 12:50:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="h79QtJDL" Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (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 42B10152198; Mon, 22 Apr 2024 12:50:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713790252; cv=none; b=jLZrQn9c9FKdPLZsxgsLyt+VM7CA/lgaBsJdzIcLhsGZrlktuaGsn7nsKXMzHnUaifkvCUOB+uyznwEGDZsgMfSJey5jaFFiD/JCGVSVFZ8oyYIWJMCQjBub4N/wUmbNUIAPFZhgLd2irsewWNh+H1xsWfwutT4vB6E9ZWSS7gs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713790252; 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=b3YpPXDsjWiMb5UQRSzsDwGe6gOhPCC2BTWSrUMgLjCAITqAPX5pHUod0lghDfcGfjxJ4lRggDcmhJ2/qvhQgA4+wc9B2DPcuaWWTteeACiFq5dJ9hmDYlaIU6IS46En4lgEEvkJitPWOhag9MbMJWLOiYVDifcE9FhHV6UMB+Q= 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=h79QtJDL; arc=none smtp.client-ip=217.70.183.196 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 65D27E000B; Mon, 22 Apr 2024 12:50:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1713790248; 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=h79QtJDLob/AyUf2p8I1De9yjzuaOcTSes1Lj5A9nA9telm1PNO0tGp/jdihCQfy1IttfI GKtc3H3J9ybMjrWkptNdYRLiiLdatKTXQpPXClIvCv9n9/8pHZAYnUWwG4/mDjFpWkPS5q 2wC6xxbS4HKKeiyh8gCmiH8S8CwZhtYR5Rrr9OeNP532xNCG5TGMQbPp5BjsVYSeRo+g0v x7vA2LrKrlbSHTn7ye9UeihxCImHDHIPQjcOTrD5DrXoPoMXzlKumn1OnMSK/lRc/h5bVv KAIz2Ad2yfxyJ6pJYCr9uSDyqhh08GW/usjF/EK00FamU1sKTMbYtbonn9zIXw== From: Kory Maincent Date: Mon, 22 Apr 2024 14:50:25 +0200 Subject: [PATCH net-next v11 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: <20240422-feature_ptp_netnext-v11-10-f14441f2a1d8@bootlin.com> References: <20240422-feature_ptp_netnext-v11-0-f14441f2a1d8@bootlin.com> In-Reply-To: <20240422-feature_ptp_netnext-v11-0-f14441f2a1d8@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; - 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_bpf_init(ns); @@ -506,8 +501,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); @@ -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; } 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