Skip to content

Commit 4151473

Browse files
yangbolu1991davem330
authored andcommitted
enetc: add get_ts_info interface for ethtool
This patch is to add get_ts_info interface for ethtool to support getting timestamping capability. Signed-off-by: Yangbo Lu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d398231 commit 4151473

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

drivers/net/ethernet/freescale/enetc/enetc.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ struct enetc_msg_cmd_set_primary_mac {
209209

210210
#define ENETC_CBDR_TIMEOUT 1000 /* usecs */
211211

212+
/* PTP driver exports */
213+
extern int enetc_phc_index;
214+
212215
/* SI common */
213216
int enetc_pci_probe(struct pci_dev *pdev, const char *name, int sizeof_priv);
214217
void enetc_pci_remove(struct pci_dev *pdev);

drivers/net/ethernet/freescale/enetc/enetc_ethtool.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,35 @@ static void enetc_get_ringparam(struct net_device *ndev,
555555
}
556556
}
557557

558+
static int enetc_get_ts_info(struct net_device *ndev,
559+
struct ethtool_ts_info *info)
560+
{
561+
int *phc_idx;
562+
563+
phc_idx = symbol_get(enetc_phc_index);
564+
if (phc_idx) {
565+
info->phc_index = *phc_idx;
566+
symbol_put(enetc_phc_index);
567+
} else {
568+
info->phc_index = -1;
569+
}
570+
571+
#ifdef CONFIG_FSL_ENETC_HW_TIMESTAMPING
572+
info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE |
573+
SOF_TIMESTAMPING_RX_HARDWARE |
574+
SOF_TIMESTAMPING_RAW_HARDWARE;
575+
576+
info->tx_types = (1 << HWTSTAMP_TX_OFF) |
577+
(1 << HWTSTAMP_TX_ON);
578+
info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
579+
(1 << HWTSTAMP_FILTER_ALL);
580+
#else
581+
info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE |
582+
SOF_TIMESTAMPING_SOFTWARE;
583+
#endif
584+
return 0;
585+
}
586+
558587
static const struct ethtool_ops enetc_pf_ethtool_ops = {
559588
.get_regs_len = enetc_get_reglen,
560589
.get_regs = enetc_get_regs,
@@ -571,6 +600,7 @@ static const struct ethtool_ops enetc_pf_ethtool_ops = {
571600
.get_link_ksettings = phy_ethtool_get_link_ksettings,
572601
.set_link_ksettings = phy_ethtool_set_link_ksettings,
573602
.get_link = ethtool_op_get_link,
603+
.get_ts_info = enetc_get_ts_info,
574604
};
575605

576606
static const struct ethtool_ops enetc_vf_ethtool_ops = {
@@ -586,6 +616,7 @@ static const struct ethtool_ops enetc_vf_ethtool_ops = {
586616
.set_rxfh = enetc_set_rxfh,
587617
.get_ringparam = enetc_get_ringparam,
588618
.get_link = ethtool_op_get_link,
619+
.get_ts_info = enetc_get_ts_info,
589620
};
590621

591622
void enetc_set_ethtool_ops(struct net_device *ndev)

drivers/net/ethernet/freescale/enetc/enetc_ptp.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
#include "enetc.h"
99

10+
int enetc_phc_index = -1;
11+
EXPORT_SYMBOL(enetc_phc_index);
12+
1013
static struct ptp_clock_info enetc_ptp_caps = {
1114
.owner = THIS_MODULE,
1215
.name = "ENETC PTP clock",
@@ -96,6 +99,7 @@ static int enetc_ptp_probe(struct pci_dev *pdev,
9699
if (err)
97100
goto err_no_clock;
98101

102+
enetc_phc_index = ptp_qoriq->phc_index;
99103
pci_set_drvdata(pdev, ptp_qoriq);
100104

101105
return 0;
@@ -119,6 +123,7 @@ static void enetc_ptp_remove(struct pci_dev *pdev)
119123
{
120124
struct ptp_qoriq *ptp_qoriq = pci_get_drvdata(pdev);
121125

126+
enetc_phc_index = -1;
122127
ptp_qoriq_free(ptp_qoriq);
123128
kfree(ptp_qoriq);
124129

0 commit comments

Comments
 (0)