1 From 0ade532080c8cc777cd2af78b11040a353b89880 Mon Sep 17 00:00:00 2001
2 From: Yangbo Lu <yangbo.lu@nxp.com>
3 Date: Thu, 1 Nov 2018 10:34:52 +0800
4 Subject: [PATCH] sdk_dpaa: add the get_ts_info interface for ethtool
6 Added the get_ts_info interface for ethtool to check
7 the timestamping capability.
9 Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
11 .../net/ethernet/freescale/sdk_dpaa/dpaa_ethtool.c | 45 ++++++++++++++++++++++
12 1 file changed, 45 insertions(+)
14 --- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_ethtool.c
15 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_ethtool.c
19 #include <linux/string.h>
20 +#include <linux/of_platform.h>
21 +#include <linux/net_tstamp.h>
22 +#include <linux/fsl/ptp_qoriq.h>
25 #include "mac.h" /* struct mac_device */
26 @@ -519,6 +522,47 @@ static void dpa_get_strings(struct net_d
27 memcpy(strings, dpa_stats_global, size);
30 +static int dpaa_get_ts_info(struct net_device *net_dev,
31 + struct ethtool_ts_info *info)
33 + struct dpa_priv_s *priv = netdev_priv(net_dev);
34 + struct device *dev = priv->mac_dev->dev;
35 + struct device_node *mac_node = dev->of_node;
36 + struct device_node *fman_node = NULL, *ptp_node = NULL;
37 + struct platform_device *ptp_dev = NULL;
38 + struct qoriq_ptp *ptp = NULL;
40 + info->phc_index = -1;
42 + fman_node = of_get_parent(mac_node);
44 + ptp_node = of_parse_phandle(fman_node, "ptimer-handle", 0);
47 + ptp_dev = of_find_device_by_node(ptp_node);
50 + ptp = platform_get_drvdata(ptp_dev);
53 + info->phc_index = ptp->phc_index;
55 +#ifdef CONFIG_FSL_DPAA_TS
56 + info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE |
57 + SOF_TIMESTAMPING_RX_HARDWARE |
58 + SOF_TIMESTAMPING_RAW_HARDWARE;
59 + info->tx_types = (1 << HWTSTAMP_TX_OFF) |
60 + (1 << HWTSTAMP_TX_ON);
61 + info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
62 + (1 << HWTSTAMP_FILTER_ALL);
64 + info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE |
65 + SOF_TIMESTAMPING_SOFTWARE;
71 const struct ethtool_ops dpa_ethtool_ops = {
72 .get_link_ksettings = dpa_get_ksettings,
73 .set_link_ksettings = dpa_set_ksettings,
74 @@ -539,4 +583,5 @@ const struct ethtool_ops dpa_ethtool_ops
75 .get_wol = dpa_get_wol,
76 .set_wol = dpa_set_wol,
78 + .get_ts_info = dpaa_get_ts_info,