kernel-5.4: bump to 5.4.102 and refresh patches
[openwrt/openwrt.git] / target / linux / layerscape / patches-5.4 / 701-net-0101-sdk_dpaa-add-the-get_ts_info-interface-for-ethtool.patch
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
5
6 Added the get_ts_info interface for ethtool to check
7 the timestamping capability.
8
9 Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
10 ---
11 .../net/ethernet/freescale/sdk_dpaa/dpaa_ethtool.c | 45 ++++++++++++++++++++++
12 1 file changed, 45 insertions(+)
13
14 --- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_ethtool.c
15 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_ethtool.c
16 @@ -39,6 +39,9 @@
17 #endif
18
19 #include <linux/string.h>
20 +#include <linux/of_platform.h>
21 +#include <linux/net_tstamp.h>
22 +#include <linux/fsl/ptp_qoriq.h>
23
24 #include "dpaa_eth.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);
28 }
29
30 +static int dpaa_get_ts_info(struct net_device *net_dev,
31 + struct ethtool_ts_info *info)
32 +{
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;
39 +
40 + info->phc_index = -1;
41 +
42 + fman_node = of_get_parent(mac_node);
43 + if (fman_node)
44 + ptp_node = of_parse_phandle(fman_node, "ptimer-handle", 0);
45 +
46 + if (ptp_node)
47 + ptp_dev = of_find_device_by_node(ptp_node);
48 +
49 + if (ptp_dev)
50 + ptp = platform_get_drvdata(ptp_dev);
51 +
52 + if (ptp)
53 + info->phc_index = ptp->phc_index;
54 +
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);
63 +#else
64 + info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE |
65 + SOF_TIMESTAMPING_SOFTWARE;
66 +#endif
67 +
68 + return 0;
69 +}
70 +
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,
77 #endif
78 + .get_ts_info = dpaa_get_ts_info,
79 };