Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1924171imm; Thu, 7 Jun 2018 02:30:10 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL/nnquFIFPPJmqNXa3q1/T2SMg9nIjpvV0JhkAtjMUjBz/J5CjSf1C94JXMvndwsYDBTCT X-Received: by 2002:a17:902:1007:: with SMTP id b7-v6mr1221699pla.88.1528363810215; Thu, 07 Jun 2018 02:30:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528363810; cv=none; d=google.com; s=arc-20160816; b=HhaXcJPbPl20TCDst2G72mXmNkfbQKFOsbuqw5PoN8QtcXWEGiIVh2TAEDgwA3A90z SmN5INMQeCN81rSP0hFbebIlzMYk/ULBYo6cXA+so4AN6Lg7pyBQJIRzMOID6JTDEn0L TcNLMPJzr5/emqZez2Jxij0auon1KKXzqKXVH6PvDGyut76dW4gyMDVAP3ChDvpW2P0a Vl+lyeYoh0JUgjG/bjo5YAIyEm4X9DvYATdAMLhEWTZKgzjMrmgO87OIf6lON4AEEAop k/JsRShTAJC50ONioI30SpeD37S3gQfVh+xH+AOE/LvfisnzBJRc1X5nmMsqkH6QUVnS u4ZQ== 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=lrX6xnXA8/3+6MfjNwZViVcywlSD+z9KeEUYQ2Ym1S4=; b=aqIjVo1G8/R+E2gfeEH2HIkD++cU/u0Q7ZaHCGzewI6gdBy2GU7Bw/oeUKm9Ptl4/F CGM+anwUjv2pFU2xTz9Ah2oatsB3Fw4Tpux2SzbHzT0tl/HeIZfCqp/RQGqTCh/AEm9i T3VpO2bi7sz4E7mACjzkSleBxSwwwdf6PRJiUZXItQDAudIaEMokcDsMmOsix4aQaK0d VX1IhTSPC/Cw3hrWIJGAY21tZUmByrSRkKH82PVeoyJazFCFm+mIsq52RzcIp/Iw8Zu0 GaXvEqPuxmqfOUXSytbTDtXM0pNxXcr8xFYMWnQbvpyOMDbxZ+t2bFEos6r3V6jD/tTU LuRQ== 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 i8-v6si15827516pgf.649.2018.06.07.02.29.55; Thu, 07 Jun 2018 02:30:10 -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 S1753606AbeFGJXh (ORCPT + 99 others); Thu, 7 Jun 2018 05:23:37 -0400 Received: from inva020.nxp.com ([92.121.34.13]:46378 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932920AbeFGJW4 (ORCPT ); Thu, 7 Jun 2018 05:22:56 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 687DA1A008B; Thu, 7 Jun 2018 11:22:54 +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 27EE31A0312; Thu, 7 Jun 2018 11:22:54 +0200 (CEST) Received: from az84smr01.freescale.net (az84smr01.freescale.net [10.64.34.197]) by inv1260.na-rdc02.nxp.com (Postfix) with ESMTP id 8E69240A56; Thu, 7 Jun 2018 02:22:53 -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 w579MJ4q020959; Thu, 7 Jun 2018 02:22:51 -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: [v3, 10/10] dpaa_eth: add the get_ts_info interface for ethtool Date: Thu, 7 Jun 2018 17:20:50 +0800 Message-Id: <20180607092050.46128-11-yangbo.lu@nxp.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180607092050.46128-1-yangbo.lu@nxp.com> References: <20180607092050.46128-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 --- Changes for v2: - Removed ifdef for hw timestamp. Changes for v3: - None. --- 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