Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3845959imm; Mon, 25 Jun 2018 05:41:17 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJqmXXwXoK1WhkusIl29KmDfasosHv2qP/deST3bCPbrX6gj3B9Il7OhFYIDy90PyM5pQoJ X-Received: by 2002:a17:902:7896:: with SMTP id q22-v6mr12005640pll.243.1529930477556; Mon, 25 Jun 2018 05:41:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529930477; cv=none; d=google.com; s=arc-20160816; b=MvJqinxlyx/8j60nNUxRSI1BzWdWKWRP0NXkmtPVc/K2X5aTk6ZNjWQscAiWOJW9cS Y9hpeErRKVzKzvMZkSc2dNaZHLMUy6lrN+7uShTNC5lj8yVn4b0KG4LAyqcyi2ubdWXh GuRgx+Ao0Dhh8kLJWi/wOW/Nr5x+NkssvBtTu1KSPKHu4r61t594RjrSW960gn13T6oM vg7VR0KSn64y85rWKu1xWaJ+RAiglVqTWSZaxG5K3YnMatvOSGA0zPsKE6mLdFeNovLO FntW/4n+xsKNE22MD9YWvPmkrJoroLh+4Yo6J2fmOJeG6/a2dzzmKamat18W/iyZwEmU seAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=RQ573CrNWHmqnPRu+nb0qMnsjzMudKRYFV+yyvenP6k=; b=PqVcTCm7y0tfepS5mCiN9wYyTclghlQiR31UrTKyg9DFDb7MY1EEKpV7dQfP9HEhKM Jt7bM64X+YSLOXGcjVJu5peBy0wc1um3BvLO9TKuKwMs+5NGpEdJ8mNMzu9lO1rDs44J IAsp+/lm++vA2Pw00t0CYoRoXovpgLNEfbJqxZ7nvh5Z5LBg6u1Y/9Mwkf3+8N9JNgqn WMxXArzf6TxRc2UNBUL6DElwsWkCOLF4GQMTDj94Dbr/56YNj+S7IWC1t63cy16mA5oU O9r06WE69DdY6EztpFE0RAi8KzTcvVhidCijbWbwRgv5z3XC1jCGPQ8jFl98zlUROTMC tFhA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y124-v6si11960163pgy.228.2018.06.25.05.41.03; Mon, 25 Jun 2018 05:41:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752617AbeFYMkD (ORCPT + 99 others); Mon, 25 Jun 2018 08:40:03 -0400 Received: from inva020.nxp.com ([92.121.34.13]:38408 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933402AbeFYMjk (ORCPT ); Mon, 25 Jun 2018 08:39:40 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 07C871A00CE; Mon, 25 Jun 2018 14:39:39 +0200 (CEST) Received: from smtp.na-rdc02.nxp.com (inv1260.us-phx01.nxp.com [134.27.49.11]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id BF1DE1A00CA; Mon, 25 Jun 2018 14:39:38 +0200 (CEST) Received: from az84smr01.freescale.net (az84smr01.freescale.net [10.64.34.197]) by inv1260.na-rdc02.nxp.com (Postfix) with ESMTP id 33F4640A70; Mon, 25 Jun 2018 05:39:38 -0700 (MST) Received: from titan.ap.freescale.net ([10.192.208.233]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id w5PCd34V025070; Mon, 25 Jun 2018 05:39:35 -0700 From: Yangbo Lu To: netdev@vger.kernel.org, madalin.bucur@nxp.com, Richard Cochran , Rob Herring , Shawn Guo , "David S . Miller" Cc: devicetree@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Yangbo Lu Subject: [v4, 10/10] dpaa_eth: add the get_ts_info interface for ethtool Date: Mon, 25 Jun 2018 20:37:16 +0800 Message-Id: <20180625123716.28993-11-yangbo.lu@nxp.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180625123716.28993-1-yangbo.lu@nxp.com> References: <20180625123716.28993-1-yangbo.lu@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Added the get_ts_info interface for ethtool to check the timestamping capability. Signed-off-by: Yangbo Lu Acked-by: Richard Cochran Acked-by: Madalin Bucur --- Changes for v2: - Removed ifdef for hw timestamp. Changes for v3: - None. Changes for v4: - Added ACKs. --- drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c | 39 ++++++++++++++++++++ 1 files changed, 39 insertions(+), 0 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c b/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c index 2f933b6..3184c8f 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c @@ -32,6 +32,9 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include +#include +#include +#include #include "dpaa_eth.h" #include "mac.h" @@ -515,6 +518,41 @@ static int dpaa_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd) return ret; } +static int dpaa_get_ts_info(struct net_device *net_dev, + struct ethtool_ts_info *info) +{ + struct device *dev = net_dev->dev.parent; + struct device_node *mac_node = dev->of_node; + struct device_node *fman_node = NULL, *ptp_node = NULL; + struct platform_device *ptp_dev = NULL; + struct qoriq_ptp *ptp = NULL; + + info->phc_index = -1; + + fman_node = of_get_parent(mac_node); + if (fman_node) + ptp_node = of_parse_phandle(fman_node, "ptimer-handle", 0); + + if (ptp_node) + ptp_dev = of_find_device_by_node(ptp_node); + + if (ptp_dev) + ptp = platform_get_drvdata(ptp_dev); + + if (ptp) + info->phc_index = ptp->phc_index; + + info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE | + SOF_TIMESTAMPING_RX_HARDWARE | + SOF_TIMESTAMPING_RAW_HARDWARE; + info->tx_types = (1 << HWTSTAMP_TX_OFF) | + (1 << HWTSTAMP_TX_ON); + info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) | + (1 << HWTSTAMP_FILTER_ALL); + + return 0; +} + const struct ethtool_ops dpaa_ethtool_ops = { .get_drvinfo = dpaa_get_drvinfo, .get_msglevel = dpaa_get_msglevel, @@ -530,4 +568,5 @@ static int dpaa_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd) .set_link_ksettings = dpaa_set_link_ksettings, .get_rxnfc = dpaa_get_rxnfc, .set_rxnfc = dpaa_set_rxnfc, + .get_ts_info = dpaa_get_ts_info, }; -- 1.7.1