Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1190875rdb; Fri, 16 Feb 2024 07:56:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXaW46JB3mjgy1EtOc4lhnv+833xbFxw8bn89TgY0yhaziSF4TZX4HR5+U0FBz/UkDoOGTeU6T4VE8H2KiR17Lp7P8ULGL1hK8q4QIwAA== X-Google-Smtp-Source: AGHT+IHz9gq2Rkq2T5uqsZSi6yLjDQeQYa/HP5/udFD/rVAwM8DDv6CLy4tCAczfaRMsV+vl1bli X-Received: by 2002:a05:6a20:4387:b0:19e:4ab2:c362 with SMTP id i7-20020a056a20438700b0019e4ab2c362mr8448990pzl.14.1708098971156; Fri, 16 Feb 2024 07:56:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708098971; cv=pass; d=google.com; s=arc-20160816; b=Pzm9B2+/PE2FjBLcHmaEfwcjJ93kNDC2lkuY7OHMHiJ6QtKHrRZQbg+BGXqzGYt9jh Wlgg4TW/Gs1D1aD0AvbxVs8lObAVWG+C36meGk4YrZ/p8HXVZDaAqswh5Oqq8zVkvAqu KXWQF16zRG6zgQW/c/9ZiMMSfTN2aXXJG/3FLJHLje+NRa2yQFlPpOlCbhGm1jpCpKL5 JMys7SYyZy6wt5Y7DJg1oNS/RssVhE0B6wxmMYcOilmYPHy3WSw+J3nLaFmZSuSfttze XhXDO2/dJyvuZFpBAb/rBvOztOOEjJ1V6br/yTaxjKh/xgQRT9wePi5Zzfz77RTf4eqM D20w== 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=4ybkeqbNzvHWp95Jf30SwLVuY/Le8DIafmSMZ2+PWjs=; fh=vtlcgQ30nO0QjQR7y1Wfn7g9c11A+T6SWcSZ6WixcJI=; b=dU6F6Zu4mKn15deaa3jbebgqm2iyCfLBZ/nL89os70b7ZjC90Tj7UokpMGzF2KIYTV OX18wZ1rcvj8GaqGDmDRUNGq6uhjNeOqK6Bg32GOy5JNdKQ6tQViF3i+Jg4XolPF3VIS zYG6UjFH/l6GG/XX5Z7wUXFQL7D3U+3YBcgoH9S2bEnzyksE2bWoy4iu+Y4ZP4+iYa5N Ph6tTZTyr7LueVJywPdlS5/ZM/rRMwQWXZo/dvu4bcTBvAwbGFaxvH9jvXcdVPBi8L+J I6sqRAXYBOF4AfdhQix3ldsB+U1fhttpfSGtph50U90jhtrGq4ig8B/9Gw1Gw+hQE4U0 RrKA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=PhoLSlMt; 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-68919-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68919-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 ct16-20020a056a000f9000b006e09456ba83si113691pfb.71.2024.02.16.07.56.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 07:56:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68919-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=PhoLSlMt; 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-68919-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68919-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 7B7832815F9 for ; Fri, 16 Feb 2024 15:56:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7B0F71350C7; Fri, 16 Feb 2024 15:53:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="PhoLSlMt" Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (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 D005A131E2F; Fri, 16 Feb 2024 15:53:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708098792; cv=none; b=m0WqY4VKEC2verebOIUnI5Io2NWD3aVwzhtyQ2heW9+ueTAuY0dwuTYcXMt3ir2B2p0p9qQjTBxGP287eQ+ZCeM24ItBsvS0RE660PPtULOc63FZcsxxIOXvE8z53x93kuSg+ib8c0SmjUO4Eb7p+yhxpbEzUKb/PVRlGn7F/Oc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708098792; c=relaxed/simple; bh=ofguNo6Qw8u4BIZ10jVG4IP+SAipIpHr2SfAps5s9LY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MNpHQBP+tbs9163mVu7q+/gDo56BZjnhjiIh8B3NujJxGRtDsug5iqQbzJd9Zo2ECjow1p4VlPo65kbFGFQgVxT+JGlBe0kyEi6S7wG2VMLVHskmgd5mhOUI5kIhvu1EkJgy3d7XqalxualstC8e+KX+2e5V5G3wJnivCUvR4Kw= 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=PhoLSlMt; arc=none smtp.client-ip=217.70.183.193 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 16CD724000A; Fri, 16 Feb 2024 15:53:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708098788; 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=4ybkeqbNzvHWp95Jf30SwLVuY/Le8DIafmSMZ2+PWjs=; b=PhoLSlMthm/EXYwqoHTv3Bne5dbFJhznoy/b6fYCgNMjy+SLvwPXIGnFc0sLbeFfcxJ0s2 2ZYIuylV2ci/aT2/orhwgzV8h3viS/ZRfAxseRd6dsFCLbA/NbTziHaxe3+zx6MYKQ0mop I5fNw1mu4pOCTvUIt7BhQVwzWOG2bW4yLig3RPFtX9bBLppPSo+78NHkDSCCHbMMVVwYp+ lb7cifYLjbl1RgCxzytKoJluiGbLAOzUB53EtDpqdSbvRmdVnnN1G8U5PaXGD0Q7L2AtwD idKaewdhVsziWtJHzah8WzMH+iNgrvD39BXilsx8g4v/uIdFVsFvls/SUG09eg== From: Kory Maincent Date: Fri, 16 Feb 2024 16:52:28 +0100 Subject: [PATCH RFC net-next v8 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: <20240216-feature_ptp_netnext-v8-10-510f42f444fb@bootlin.com> References: <20240216-feature_ptp_netnext-v8-0-510f42f444fb@bootlin.com> In-Reply-To: <20240216-feature_ptp_netnext-v8-0-510f42f444fb@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.12.4 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. Signed-off-by: Kory Maincent --- Shouldn't we move the mock driver in the netdevsim directory as it is only used by netdevsim driver? 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 77e8250282a5..7f58645559b5 100644 --- a/drivers/net/netdevsim/netdev.c +++ b/drivers/net/netdevsim/netdev.c @@ -321,16 +321,11 @@ 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; 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); @@ -344,8 +339,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); @@ -353,8 +358,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.25.1