Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp154445lqg; Wed, 10 Apr 2024 20:18:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUmZZ3mpqYdGKnXX9B6RsVfVJqBIrubjJYD9ftbdUdwgZBXDfhxsq740yn9JMFPPifiB4ByRj4Rjh/K3njGc/WSAKtRGvIEDhzJksrtqg== X-Google-Smtp-Source: AGHT+IFD4aHVuhdleJTsgJZhccbTM+bNnARlQ42vDlnjS+SEg7azHubdMblvSKmXSGBsy7GIj6H/ X-Received: by 2002:a17:90a:7281:b0:2a0:78f4:2dc5 with SMTP id e1-20020a17090a728100b002a078f42dc5mr1817832pjg.22.1712805516967; Wed, 10 Apr 2024 20:18:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712805516; cv=pass; d=google.com; s=arc-20160816; b=N6C6ORutMFADiOt0AzfNDVUW0pWy9aEa0x2Jp0OO4/emK3SfccQ+x0eHq7g6Xh7aFf Z48vN/zkiLDY87zBB5i/NE4UcxfnF2b/bKNVpbEcNInLbO/L4/MMzGZgm8DqR6D4bzKY vz2a2I1xk5r+fjsbHgMkbbcFzbmHjMfFWVz/LLT0Q3/GC/FKRuQKbiOT2u8oYK0UKA3g TsWAET8uaFBIdUYyBJA0ZlLWNsDVPm4NOd/YXf/GI13zrZPcC66JPHhqkl1RLwiRbmiR RwIiy5deUSgpHx/GMihc6Hu+E0gTYnCtowAsJZ+uOIffA82rtTd4VhhUDpiAY4B7I20l m4wQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:subject:references:in-reply-to :message-id:cc:to:from:date:dkim-signature; bh=g85EQHmsQg7ae69eB1wDElQi/dut+TsAUohIEriB58E=; fh=kUSOSPGA3OSrL/weFdxAaluHQfpEEtKoMy4lsZnpUuQ=; b=Y4WRdjCnHx811D3uE2OJGyioqj4vr3lQ+ZqttH4W2QkO7y+yncx1fE5KfcwOZGzkD0 Uk/oJWiX9FLkcJ1Cfbjg3lJjwUYhaWBa0s7Z4SEQuInaYPssmIxZQvCNXnDvxiFqvqFV /dgeBg548b5marxfc0o+4N3EshCpsFka50Fmt0dcLJ6UfVKDQ3/u+2sQkotkZvNlwPUT XeH6IPXYUv1fFB8G0N2iZkhHZVaMbaLuAOCpDIvZvlqt11aZYiMHLaG3II3Mq37HbrVW Ud9xn3YFEnTUTACSl7oqER0c4U1XvHls5GHpPkPtV57xQwQXHzGXBQyoI50Pf5jVeE// JqBw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="c/9uXAvF"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-139699-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139699-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 a10-20020a17090a8c0a00b002a46b80507asi2663180pjo.165.2024.04.10.20.18.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 20:18:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139699-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=@gmail.com header.s=20230601 header.b="c/9uXAvF"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-139699-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139699-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 2A104287C9B for ; Thu, 11 Apr 2024 03:18:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 183BB13BAD2; Thu, 11 Apr 2024 03:18:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="c/9uXAvF" Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8087A23BF; Thu, 11 Apr 2024 03:18:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712805503; cv=none; b=BhZCf+B3Ymls6g9cAIU0j5+KAIv8TcTQiDf5Uveu6Oc1FDMmZnlifUoOftKwMnmmqgg/6pl/d1euYSHs6J4AJTx2tBM3dVSg6oHRO0YDyMO8NIQwePWH9e5DW+ric5W8+RHnlT23eHpZ4OopF9wHyK8P4jFkAbrrrX8bLBc0RtQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712805503; c=relaxed/simple; bh=+7xkEcW33wSX8+FnWZmFFTo2qPCMzT+q4+dusj3+wc0=; h=Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject: Mime-Version:Content-Type; b=reLim9ryfIoRiMTz2vcgQ5Ut4Xylggn/uuAoVklUqQWjZ9sNdOxaeVnva0BUJ/U3Fiz3PMNcM33mCrGmgsaNe/7kAR3p/g+QnRJcuke8GeZ00cw+PzhbO7Phq3feNQvkFRgYuQBRNSYR1y8OaXJxjXi5lPWWZwgCyyW6l/0Dc04= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=c/9uXAvF; arc=none smtp.client-ip=209.85.222.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qk1-f170.google.com with SMTP id af79cd13be357-78ebc7e1586so47731585a.1; Wed, 10 Apr 2024 20:18:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712805500; x=1713410300; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=g85EQHmsQg7ae69eB1wDElQi/dut+TsAUohIEriB58E=; b=c/9uXAvFW9Dy1FDd/2zLbfj/ksA77OIDf+jLBFv48yBI4Fko/zf4tCg9VbDPh2njM0 D7G/PoaZh4QwYMqiqQtNV50JTHtyMnzKlklQziV/wLBAw9k+BsYW0sLwgK4DSq08Y13T 7jXFzHjR7zXLDqYhrzTW33+hLkszDZtVvGGGxc4MD7GLGdLyLXbAOTqjEh/wugoJBa3e d10MrsJljm3264pu6xMoQf+SFjrhjnkuphp2d7u50pMAocuCsWdDTCEk8csnxjRfvVYl Vi3O1mSgWDDY6oxxQqp8/vOXgKrTS4exMYEII2+altWq1UOHyPTo3nETE1YODOKKOvRI 6kKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712805500; x=1713410300; h=content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=g85EQHmsQg7ae69eB1wDElQi/dut+TsAUohIEriB58E=; b=g3BkUdRxLuUiaOlYqNsSXAuBxoFl/ha3msk8P46txZm3Yx/hDWVEvfaMvhaKuSMn+g K5FSFM/1W3QVSDH2b6mx0WVZQR48uzbRCASUQEcdGlFBQIxnrerCUJboXIoGVM9zjSad 045vI92FPnvqE9G8Jo7RxGHKhTj0i0wGbJ2UyVbSVWOaw5KS10bwd2DUxknWBmiipd9a rh7aaz2Z3AywUeUaoZ2YNinl9PMdHriW8w+36r87K1yjhpyZMaWa2r4+6qUW2vfxJmF4 lCUs+ajkzbxHXGoeHMBJKufRbhhIDAGQdXy7rY+1LrN9lPnNOimWAwyY9Yyeo5bRHyZj nvqQ== X-Forwarded-Encrypted: i=1; AJvYcCVjt6W4ycQz6pxngWDy7KsaPrLgzNtuudaPrMMM9TqKxvtagfqhnsFMAokEDkWa+J1Oantw+IZwZ2+Q6MuclXFlVcDQYQtuYLtX1uMBltk+7bPrU2qtwTcOXqErtVusUcfCxRsVFLZFShL4t+amFOOyNJS7LCl1Y9/U6FSDKy2X X-Gm-Message-State: AOJu0Yz1v+9ziryATpSlMweYLhGFYhm/tJx+NwBH4HcD5qX3swXFImhF H6wwIyzA5d6JRgwP4jMAb15HGuaKjmQ6kJDpNkBfWLKJRAhjd3CR X-Received: by 2002:ae9:e301:0:b0:78d:781c:d9f8 with SMTP id v1-20020ae9e301000000b0078d781cd9f8mr2562445qkf.25.1712805500334; Wed, 10 Apr 2024 20:18:20 -0700 (PDT) Received: from localhost (73.84.86.34.bc.googleusercontent.com. [34.86.84.73]) by smtp.gmail.com with ESMTPSA id a14-20020a05620a124e00b0078d631f35c2sm437869qkl.24.2024.04.10.20.18.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 20:18:20 -0700 (PDT) Date: Wed, 10 Apr 2024 23:18:19 -0400 From: Willem de Bruijn To: Willem de Bruijn , Kory Maincent , 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 Message-ID: <6617567bd4da7_2dcc3c294c5@willemb.c.googlers.com.notmuch> In-Reply-To: <66175265992c8_2d6bc6294d8@willemb.c.googlers.com.notmuch> References: <20240409-feature_ptp_netnext-v10-0-0fa2ea5c89a9@bootlin.com> <20240409-feature_ptp_netnext-v10-8-0fa2ea5c89a9@bootlin.com> <66175265992c8_2d6bc6294d8@willemb.c.googlers.com.notmuch> Subject: Re: [PATCH net-next v10 08/13] ptp: Add phc source and helpers to register specific PTP clock or get information 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 Willem de Bruijn wrote: > Kory Maincent wrote: > > Prepare for future hardware timestamp selection by adding source and > > corresponding pointers to ptp_clock structure. Additionally, introduce > > helpers for registering specific phydev or netdev PTP clocks, retrieving > > PTP clock information such as hwtstamp source or phydev/netdev pointers, > > and obtaining the ptp_clock structure from the phc index. > > > > Signed-off-by: Kory Maincent > > --- > > > > Change in v8: > > - New patch. > > > > Change in v10: > > - Add get and put function to avoid unregistering a ptp clock object used. > > - Fix kdoc issues. > > --- > > drivers/ptp/ptp_clock.c | 114 +++++++++++++++++++++++++++++++++++++++ > > drivers/ptp/ptp_private.h | 5 ++ > > include/linux/ptp_clock_kernel.h | 104 +++++++++++++++++++++++++++++++++++ > > 3 files changed, 223 insertions(+) > > > > diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c > > index c56cd0f63909..f962f460ec9d 100644 > > --- a/drivers/ptp/ptp_clock.c > > +++ b/drivers/ptp/ptp_clock.c > > @@ -512,6 +512,120 @@ void ptp_cancel_worker_sync(struct ptp_clock *ptp) > > } > > EXPORT_SYMBOL(ptp_cancel_worker_sync); > > > > +struct ptp_clock *netdev_ptp_clock_register(struct ptp_clock_info *info, > > + struct net_device *dev) > > +{ > > + struct ptp_clock *ptp; > > + > > + ptp = ptp_clock_register(info, &dev->dev); > > + if (IS_ERR(ptp)) > > + return ptp; > > + > > + ptp->phc_source = HWTSTAMP_SOURCE_NETDEV; > > + ptp->netdev = dev; > > + > > + return ptp; > > +} > > +EXPORT_SYMBOL(netdev_ptp_clock_register); > > + > > +struct ptp_clock *phydev_ptp_clock_register(struct ptp_clock_info *info, > > + struct phy_device *phydev) > > +{ > > + struct ptp_clock *ptp; > > + > > + ptp = ptp_clock_register(info, &phydev->mdio.dev); > > + if (IS_ERR(ptp)) > > + return ptp; > > + > > + ptp->phc_source = HWTSTAMP_SOURCE_PHYLIB; > > + ptp->phydev = phydev; > > + > > + return ptp; > > +} > > +EXPORT_SYMBOL(phydev_ptp_clock_register); > > + > > +bool ptp_clock_from_phylib(struct ptp_clock *ptp) > > +{ > > + return ptp->phc_source == HWTSTAMP_SOURCE_PHYLIB; > > +} > > +EXPORT_SYMBOL(ptp_clock_from_phylib); > > + > > +bool ptp_clock_from_netdev(struct ptp_clock *ptp) > > +{ > > + return ptp->phc_source == HWTSTAMP_SOURCE_NETDEV; > > +} > > +EXPORT_SYMBOL(ptp_clock_from_netdev); > > + > > +struct net_device *ptp_clock_netdev(struct ptp_clock *ptp) > > +{ > > + if (ptp->phc_source != HWTSTAMP_SOURCE_NETDEV) > > + return NULL; > > + > > + return ptp->netdev; > > +} > > +EXPORT_SYMBOL(ptp_clock_netdev); > > + > > +struct phy_device *ptp_clock_phydev(struct ptp_clock *ptp) > > +{ > > + if (ptp->phc_source != HWTSTAMP_SOURCE_PHYLIB) > > + return NULL; > > + > > + return ptp->phydev; > > +} > > +EXPORT_SYMBOL(ptp_clock_phydev); > > IMHO these four helpers just add a layer of indirection without much > benefit. Actually, ignore this. This is not important enough to revise when we're alredy at v10. That also goes for the other points. > Do we ever expect more than two sources? Else, the phc_source could be > embedded as the least significant bit of the pointer in the union. In > that case we would need helpers to return the pointer without that LSB. > But space in struct ptp_clock is probably not so valuable that we need > to play such games. > > > +/** > > + * netdev_ptp_clock_register() - register a PTP hardware clock driver for > > + * a net device > > + * > > + * @info: Structure describing the new clock. > > + * @dev: Pointer of the net device > > + */ > > + > > +extern struct ptp_clock * > > +netdev_ptp_clock_register(struct ptp_clock_info *info, > > + struct net_device *dev); > > No need for explicit extern?