From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4819C2D0C3 for ; Sat, 21 Dec 2019 19:36:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A3167206B7 for ; Sat, 21 Dec 2019 19:36:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WlaS7byV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727173AbfLUTgo (ORCPT ); Sat, 21 Dec 2019 14:36:44 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:41973 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726107AbfLUTgn (ORCPT ); Sat, 21 Dec 2019 14:36:43 -0500 Received: by mail-pl1-f196.google.com with SMTP id bd4so5534123plb.8; Sat, 21 Dec 2019 11:36:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+LgVazWFqvVcdctdDKHy4vuxqcL6YZfeaQzb1I4YFjU=; b=WlaS7byVzvG1Wlro8BIzXOv1kC2r2PnuHfrhpNThLLwCGXpy61kSKxnQOxyFVp8h1d C1dQKYsu211z+iYkO2RX6o80c+81ulcRfU/wY42cMKCsSg/IHusFRPs4vDadpZpcR9aS /H1081xabVqu+XznpOakrTEZ3JjKmi/xbQ321gehTsgU8keXVeFkkKGZRYAfHrEpUyyh 958epaOMAGT3Cub3jvWPOEMV/F0axi7HuWdjuy5rUCQz9Swh9Qopn/kcRqZRAzX8CcRi ZnaMJapYky8EVm6jXQSJdBXx8R74AoGgQJmlCZhQYATniYkVvKsGYuLTxdlJbWyjvl9H SinQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+LgVazWFqvVcdctdDKHy4vuxqcL6YZfeaQzb1I4YFjU=; b=byo7kbg8TyyHhiAweFXZAiKnAH3v6XOzlwjeYZidttIArXydyfbx2X0rm8ILJ93L8q h+/+PMjeyvA+YJIJe+M03tx9l/Be2NRHsDbwUL4OJaLsPxLEvq0vwo9fuZK5I1wW8UhM 31eM1/GChKrqsKvyWPKH/vpsEAMIaiE7bZppSuuy2aXpIM3z49u897r+K/i+nQrOsu4k LqW3KQDpiCCFUdw88WCQ30o+0l1jm3doj1+NSMjBqJLqBt6Gb/6FjsFUX94mHYJElaLN kE5OgR/BoLTT4Ps47pkWLquUAXAwhFIcmyFa3fvQ0MMA8dN2CzUjup/ivlGb9Y9Q7521 5IIg== X-Gm-Message-State: APjAAAVqymZ6e6vLaiR9Ed60qZ22uxi7g7Zk3wIp2ZVc+nV7Ojbp0N0M 7xiIK/ikTZNfIiXJW19E2CNpTETP X-Google-Smtp-Source: APXvYqy+Ex51csdgdISZG+G9ikjtP1SCgW4Ef9+vFCZjpcaXFapDQKz8n7OPURMrV56bc+tGgLhfRQ== X-Received: by 2002:a17:902:7042:: with SMTP id h2mr2814272plt.271.1576957002655; Sat, 21 Dec 2019 11:36:42 -0800 (PST) Received: from localhost.localdomain (c-73-241-114-122.hsd1.ca.comcast.net. [73.241.114.122]) by smtp.gmail.com with ESMTPSA id y197sm18512603pfc.79.2019.12.21.11.36.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Dec 2019 11:36:42 -0800 (PST) From: Richard Cochran To: netdev@vger.kernel.org Cc: David Miller , devicetree@vger.kernel.org, Andrew Lunn , Florian Fainelli , Heiner Kallweit , Jacob Keller , Jakub Kicinski , Mark Rutland , Miroslav Lichvar , Murali Karicheri , Rob Herring , Willem de Bruijn , Wingman Kwok Subject: [PATCH V8 net-next 01/12] net: phy: Introduce helper functions for time stamping support. Date: Sat, 21 Dec 2019 11:36:27 -0800 Message-Id: <5d7df80cc0dfce0204124f7dc4283c7126f24c33.1576956342.git.richardcochran@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Some parts of the networking stack and at least one driver test fields within the 'struct phy_device' in order to query time stamping capabilities and to invoke time stamping methods. This patch adds a functional interface around the time stamping fields. This will allow insulating the callers from future changes to the details of the time stamping implemenation. Signed-off-by: Richard Cochran Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli --- include/linux/phy.h | 60 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/include/linux/phy.h b/include/linux/phy.h index 5032d453ac66..fc51aacb03a7 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -936,6 +936,66 @@ static inline bool phy_polling_mode(struct phy_device *phydev) return phydev->irq == PHY_POLL; } +/** + * phy_has_hwtstamp - Tests whether a PHY time stamp configuration. + * @phydev: the phy_device struct + */ +static inline bool phy_has_hwtstamp(struct phy_device *phydev) +{ + return phydev && phydev->drv && phydev->drv->hwtstamp; +} + +/** + * phy_has_rxtstamp - Tests whether a PHY supports receive time stamping. + * @phydev: the phy_device struct + */ +static inline bool phy_has_rxtstamp(struct phy_device *phydev) +{ + return phydev && phydev->drv && phydev->drv->rxtstamp; +} + +/** + * phy_has_tsinfo - Tests whether a PHY reports time stamping and/or + * PTP hardware clock capabilities. + * @phydev: the phy_device struct + */ +static inline bool phy_has_tsinfo(struct phy_device *phydev) +{ + return phydev && phydev->drv && phydev->drv->ts_info; +} + +/** + * phy_has_txtstamp - Tests whether a PHY supports transmit time stamping. + * @phydev: the phy_device struct + */ +static inline bool phy_has_txtstamp(struct phy_device *phydev) +{ + return phydev && phydev->drv && phydev->drv->txtstamp; +} + +static inline int phy_hwtstamp(struct phy_device *phydev, struct ifreq *ifr) +{ + return phydev->drv->hwtstamp(phydev, ifr); +} + +static inline bool phy_rxtstamp(struct phy_device *phydev, struct sk_buff *skb, + int type) +{ + return phydev->drv->rxtstamp(phydev, skb, type); +} + +static inline int phy_ts_info(struct phy_device *phydev, + struct ethtool_ts_info *tsinfo) +{ + return phydev->drv->ts_info(phydev, tsinfo); +} + +static inline void phy_txtstamp(struct phy_device *phydev, struct sk_buff *skb, + int type) +{ + phydev->drv->txtstamp(phydev, skb, type); +} + /** * phy_is_internal - Convenience function for testing if a PHY is internal * @phydev: the phy_device struct -- 2.20.1