Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1626042imm; Wed, 6 Jun 2018 20:26:33 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKYkFC6frkXT8CBbkPHLhxUcYfb8w8cbihhFze8g64wtlGF4rjOAjlF8YAdcoBqzDlYPDys X-Received: by 2002:a63:65c4:: with SMTP id z187-v6mr154108pgb.180.1528341993805; Wed, 06 Jun 2018 20:26:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528341993; cv=none; d=google.com; s=arc-20160816; b=i5Rmu1JouBORzbGuJRDd58wFQTbtaf5dB2PE1t+Xv9TVdxGDi2SW+8fS/Ww0IS0P7W kOp+688LAyDQ4/CoB6YC0whrUgonUqjHL042G3u3UeqAy82bBUZELOQH51ZB7czIwcu5 qVX8FUI0WjL5tsYLtUoplnGX7ya4xh8KGqjkRaMGmm+5WOL9bXrQhFjY6HuFixbUbpe9 W95IlPvv8dAMbyMrLDsTRm7pCsHiDQhN29IoZV0xJRkHcTUXsZ6zXhLa1vV2LFshnuIB /gWRCQSerhTl32htbb7WmPvtFK3Xosd7iXvWAQe35FnO4dzVsMHt1dtkqfjKbb6YGjVs T70g== 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=k3ZKTcvG2lRpZfLzZ1kplB6lNawgI0NCb5Zo2/MOAlU=; b=yJwVhiVEBiOW/P5xQrpuhx6CvHhNsdeVvtm/YjSLaIZQXqcpJoH0xpD9djStEjlMw0 OPxVLxOI/kEurTAAmq4j1hbid/C+lUmlVu8msyEkBspZZj1LnIkLx7dyTy33QCU2B5W1 SiPQhxfOv0SgYT78FOnJ0Yv2h5sEute8N62loVMOrDZ/ZbyMUwdK8z7PuB8CQhX9B8f0 55xA85ZbXS7F5p4q/7Ew28+frCFvfCFFFAciqq8YT7H6LiBMp66T6JnkNcqMkRjB3c4Y TXVgVVrNU4H4jfEYeSYuaCexkirgtrcC9NT4ZG0Kr2/RpfVNcRR3Qr7HqQIzmDg1bPtP VFSA== 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 s4-v6si21499347pgq.454.2018.06.06.20.26.19; Wed, 06 Jun 2018 20:26:33 -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 S933688AbeFGDZJ (ORCPT + 99 others); Wed, 6 Jun 2018 23:25:09 -0400 Received: from inva021.nxp.com ([92.121.34.21]:34137 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932746AbeFGDZE (ORCPT ); Wed, 6 Jun 2018 23:25:04 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id E49C32001F9; Thu, 7 Jun 2018 05:25:02 +0200 (CEST) Received: from smtp.na-rdc02.nxp.com (inv1260.us-phx01.nxp.com [134.27.49.11]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id B0B98200206; Thu, 7 Jun 2018 05:25:02 +0200 (CEST) Received: from az84smr01.freescale.net (az84smr01.freescale.net [10.64.34.197]) by inv1260.na-rdc02.nxp.com (Postfix) with ESMTP id 2679640A70; Wed, 6 Jun 2018 20:25:02 -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 w573OSwX023286; Wed, 6 Jun 2018 20:24:59 -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: [v2, 10/10] dpaa_eth: add the get_ts_info interface for ethtool Date: Thu, 7 Jun 2018 11:22:56 +0800 Message-Id: <20180607032256.39802-11-yangbo.lu@nxp.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180607032256.39802-1-yangbo.lu@nxp.com> References: <20180607032256.39802-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. --- 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