igc: Add basic support for Timestamping/PTP
Subsystems (2)
v2 cover igc: Add basic support for Timestamping/PTP
Hi,
Changes from v1:
- Fixed wrong value for IGC_SRRCTL_TIMESTAMP;
- Added support for retrieving timestamps from PHY (patch 5/5);
Original cover letter (lightly edited):
This adds basic support for Timestamping and enables ptp4l/phc2sys to work using i225.
To get ptp4l/phc2sys to work we need 2 basic feature sets:
(1) reading/adjusting the PHC clock;
(2) enabling/retrieving HW timestamps;
Patch 1/5 adds support for (1), patch 2/5 and 3/5 adds support for (2) and patch 4/5 implements the ethtool ioctl that ptp4l uses to check what timestamping methods are supported.
As most of the functionality is similar to i210, this code uses that as a base. To keep this short, only the features necessary to make time synchronization using linuxptp are added.
The most important differences from i210 is that there's now support for multiple PTP domains, with multiple timestamping registers.
Still aiming to keep this series short, only support for one PTP domain is added, and also only one of the timestamping registers is used.
Missing from this series is also support configuring/using the programmable pins.
Cheers,
--
Vinicius
Vinicius Costa Gomes (5):
igc: Add basic skeleton for PTP
igc: Add support for RX timestamping
igc: Add support for TX timestamping
igc: Add support for ethtool GET_TS_INFO command
igc: Use Start of Packet signal from PHY for timestamping
drivers/net/ethernet/intel/igc/Makefile | 2 +- drivers/net/ethernet/intel/igc/igc.h | 45 ++ drivers/net/ethernet/intel/igc/igc_defines.h | 66 ++ drivers/net/ethernet/intel/igc/igc_ethtool.c | 34 + drivers/net/ethernet/intel/igc/igc_main.c | 86 +++ drivers/net/ethernet/intel/igc/igc_ptp.c | 716 +++++++++++++++++++ drivers/net/ethernet/intel/igc/igc_regs.h | 27 + 7 files changed, 975 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/intel/igc/igc_ptp.c
Signature · 1 line
2.24.0
PATCH v2 1/5 igc: Add basic skeleton for PTP
This allows the creation of the /dev/ptpX device for i225, and reading and writing the time.
--- drivers/net/ethernet/intel/igc/Makefile | 2 +- drivers/net/ethernet/intel/igc/igc.h | 26 ++ drivers/net/ethernet/intel/igc/igc_defines.h | 12 + drivers/net/ethernet/intel/igc/igc_main.c | 27 ++ drivers/net/ethernet/intel/igc/igc_ptp.c | 349 +++++++++++++++++++ drivers/net/ethernet/intel/igc/igc_regs.h | 24 ++ 6 files changed, 439 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/intel/igc/igc_ptp.c
drivers/net/ethernet/intel/igc/Makefile +1 -1
@@ -8,4 +8,4 @@ obj-$(CONFIG_IGC) += igc.o igc-objs := igc_main.o igc_mac.o igc_i225.o igc_base.o igc_nvm.o igc_phy.o \ -igc_ethtool.o +igc_ethtool.o igc_ptp.o
drivers/net/ethernet/intel/igc/igc.h +26 -0
@@ -10,6 +10,9 @@#include <linux/vmalloc.h> #include <linux/ethtool.h> #include <linux/sctp.h> +#include <linux/ptp_clock_kernel.h> +#include <linux/timecounter.h> +#include <linux/net_tstamp.h> #include "igc_hw.h"
@@ -45,11 +48,15 @@ extern char igc_driver_version[];#define IGC_REGS_LEN 740#define IGC_RETA_SIZE 128 +/* flags controlling PTP/1588 function */ +#define IGC_PTP_ENABLED BIT(0) +/* Interrupt defines */ #define IGC_START_ITR 648/* ~6000 ints/sec */ #define IGC_FLAG_HAS_MSI BIT(0)#define IGC_FLAG_QUEUE_PAIRS BIT(3)#define IGC_FLAG_DMAC BIT(4) +#define IGC_FLAG_PTP BIT(8)#define IGC_FLAG_NEED_LINK_UPDATE BIT(9)#define IGC_FLAG_MEDIA_RESET BIT(10)#define IGC_FLAG_MAS_ENABLE BIT(12)
@@ -430,6 +437,20 @@ struct igc_adapter {unsigned long link_check_timeout;struct igc_info ei; + +struct ptp_clock *ptp_clock; +struct ptp_clock_info ptp_caps; +struct work_struct ptp_tx_work; +struct sk_buff *ptp_tx_skb; +struct hwtstamp_config tstamp_config; +unsigned long ptp_tx_start; +unsigned long last_rx_ptp_check; +unsigned long last_rx_timestamp; +unsigned int ptp_flags; +/* System time value lock */ +spinlock_t tmreg_lock; +struct cyclecounter cc; +struct timecounter tc; };/* igc_desc_unused - calculate if we have unused descriptors */
@@ -513,6 +534,11 @@ int igc_add_filter(struct igc_adapter *adapter,int igc_erase_filter (struct igc_adapter *adapter,struct igc_nfc_filter *input); +void igc_ptp_init (struct igc_adapter *adapter); +void igc_ptp_reset (struct igc_adapter *adapter); +void igc_ptp_stop (struct igc_adapter *adapter); +int igc_ptp_set_ts_config (struct net_device *netdev,struct ifreq *ifr); +int igc_ptp_get_ts_config (struct net_device *netdev,struct ifreq *ifr);#define igc_rx_pg_size (_ring) (PAGE_SIZE << igc_rx_pg_order(_ring))#define IGC_TXD_DCMD (IGC_ADVTXD_DCMD_EOP | IGC_ADVTXD_DCMD_RS)
drivers/net/ethernet/intel/igc/igc_defines.h +12 -0
@@ -187,6 +187,7 @@#define IGC_ICR_RXDMT0 BIT(4)/* Rx desc min. threshold (0) */ #define IGC_ICR_RXO BIT(6)/* Rx overrun */ #define IGC_ICR_RXT0 BIT(7)/* Rx timer intr (ring 0) */ +#define IGC_ICR_TS BIT(19)/* Time Sync Interrupt */ #define IGC_ICR_DRSTA BIT(30)/* Device Reset Asserted */ /* If this bit asserted, the driver should claim the interrupt */
@@ -209,6 +210,7 @@#define IGC_IMS_DRSTA IGC_ICR_DRSTA/* Device Reset Asserted */ #define IGC_IMS_RXT0 IGC_ICR_RXT0/* Rx timer intr */ #define IGC_IMS_RXDMT0 IGC_ICR_RXDMT0/* Rx desc min. threshold */ +#define IGC_IMS_TS IGC_ICR_TS/* Time Sync Interrupt */ #define IGC_QVECTOR_MASK 0x7FFC/* Q-vector mask */ #define IGC_ITR_VAL_MASK 0x04/* ITR value mask */
@@ -324,6 +326,16 @@#define I225_RXPBSIZE_DEFAULT 0x000000A2/* RXPBSIZE default */ #define I225_TXPBSIZE_DEFAULT 0x04000014/* TXPBSIZE default */ +/* Time Sync Interrupt Causes */ +#define IGC_TSICR_SYS_WRAP BIT(0)/* SYSTIM Wrap around. */ +#define IGC_TSICR_TXTS BIT(1)/* Transmit Timestamp. */ +#define IGC_TSICR_TT0 BIT(3)/* Target Time 0 Trigger. */ +#define IGC_TSICR_TT1 BIT(4)/* Target Time 1 Trigger. */ +#define IGC_TSICR_AUTT0 BIT(5)/* Auxiliary Timestamp 0 Taken. */ +#define IGC_TSICR_AUTT1 BIT(6)/* Auxiliary Timestamp 1 Taken. */ + +#define IGC_TSICR_INTERRUPTS IGC_TSICR_TXTS +/* Receive Checksum Control */ #define IGC_RXCSUM_CRCOFL 0x00000800/* CRC32 offload enable */ #define IGC_RXCSUM_PCSD 0x00002000/* packet checksum disabled */
drivers/net/ethernet/intel/igc/igc_main.c +27 -0
@@ -110,6 +110,9 @@ void igc_reset(struct igc_adapter *adapter)if (!netif_running (adapter->netdev))igc_power_down_link (adapter); +/* Re-enable PTP, where applicable. */ +igc_ptp_reset (adapter); +igc_get_phy_info (hw); }
@@ -4199,6 +4202,24 @@ static int igc_close(struct net_device *netdev)return 0 ; } +/** +* igc_ioctl - Access the hwtstamp interface +* @netdev: network interface device structure +* @ifreq: interface request data +* @cmd: ioctl command +**/ +static int igc_ioctl (struct net_device *netdev,struct ifreq *ifr,int cmd) +{ +switch (cmd) { +case SIOCGHWTSTAMP : +return igc_ptp_get_ts_config (netdev, ifr); +case SIOCSHWTSTAMP : +return igc_ptp_set_ts_config (netdev, ifr); +default : +return -EOPNOTSUPP ; + } +} +static const struct net_device_ops igc_netdev_ops = { .ndo_open = igc_open, .ndo_stop = igc_close,
@@ -4210,6 +4231,7 @@ static const struct net_device_ops igc_netdev_ops = { .ndo_fix_features = igc_fix_features, .ndo_set_features = igc_set_features, .ndo_features_check = igc_features_check, + .ndo_do_ioctl = igc_ioctl, };/* PCIe configuration access */
@@ -4512,6 +4534,9 @@ static int igc_probe(struct pci_dev *pdev,/* carrier off reporting is important to ethtool even BEFORE open */ netif_carrier_off (netdev); +/* do hw tstamp init after resetting */ +igc_ptp_init (adapter); +/* Check if Media Autosense is enabled */ adapter->ei = *ei;
@@ -4554,6 +4579,8 @@ static void igc_remove(struct pci_dev *pdev)struct net_device *netdev =pci_get_drvdata (pdev);struct igc_adapter *adapter =netdev_priv (netdev); +igc_ptp_stop (adapter); +set_bit (__IGC_DOWN, &adapter->state);del_timer_sync (&adapter->watchdog_timer);
drivers/net/ethernet/intel/igc/igc_ptp.c new file +349 -0
349 lines not on this page · raw message
drivers/net/ethernet/intel/igc/igc_regs.h +24 -0
@@ -211,6 +211,30 @@#define IGC_I225_PHPM 0x00E14/* Phy Power Management */ +/* Time sync registers */ +#define IGC_TSICR 0x0B66C/* Time Sync Interrupt Cause */ +#define IGC_TSIM 0x0B674/* Time Sync Interrupt Mask Register */ +#define IGC_TSAUXC 0x0B640/* Timesync Auxiliary Control register */ +#define IGC_TSYNCRXCTL 0x0B620/* Rx Time Sync Control register - RW */ +#define IGC_TSYNCTXCTL 0x0B614/* Tx Time Sync Control register - RW */ +#define IGC_TSYNCRXCFG 0x05F50/* Time Sync Rx Configuration - RW */ +#define IGC_TSSDP 0x0003C/* Time Sync SDP Configuration Register - RW */ + +#define IGC_IMIR (_i) (0x05A80 + ((_i) * 4))/* Immediate Interrupt */ +#define IGC_IMIREXT (_i) (0x05AA0 + ((_i) * 4))/* Immediate INTR Ext*/ + +#define IGC_FTQF (_n) (0x059E0 + (4 * (_n)))/* 5-tuple Queue Fltr */ +/* System Time Registers */ +#define IGC_SYSTIML 0x0B600/* System time register Low - RO */ +#define IGC_SYSTIMH 0x0B604/* System time register High - RO */ +#define IGC_SYSTIMR 0x0B6F8/* System time register Residue */ +#define IGC_TIMINCA 0x0B608/* Increment attributes register - RW */ + +#define IGC_RXSTMPL 0x0B624/* Rx timestamp Low - RO */ +#define IGC_RXSTMPH 0x0B628/* Rx timestamp High - RO */ +#define IGC_TXSTMPL 0x0B618/* Tx timestamp value Low - RO */ +#define IGC_TXSTMPH 0x0B61C/* Tx timestamp value High - RO */ +/* Management registers */ #define IGC_MANC 0x05820/* Management Control - RW */
Signature · 1 line
2.24.0
PATCH v2 2/5 igc: Add support for RX timestamping
In reply to Vinicius Costa GomesThis adds support for timestamping received packets.
It is based on the i210, as many features of i225 work the same way. The main difference from i210 is that i225 has support for choosing the timer register to use when timestamping packets. Right now, we only support using timer 0. The other difference is that i225 stores two timestamps in the receive descriptor, right now, we only retrieve one.
--- drivers/net/ethernet/intel/igc/igc.h | 17 ++ drivers/net/ethernet/intel/igc/igc_defines.h | 38 +++ drivers/net/ethernet/intel/igc/igc_main.c | 10 + drivers/net/ethernet/intel/igc/igc_ptp.c | 272 +++++++++++++++++++ drivers/net/ethernet/intel/igc/igc_regs.h | 3 + 5 files changed, 340 insertions(+)
drivers/net/ethernet/intel/igc/igc.h +17 -0
@@ -107,6 +107,20 @@ extern char igc_driver_version[];#define AUTO_ALL_MODES 0#define IGC_RX_HDR_LEN IGC_RXBUFFER_256 +/* Transmit and receive latency (for PTP timestamps) */ +/* FIXME: These values were estimated using the ones that i210 has as +* basis, they seem to provide good numbers with ptp4l/phc2sys, but we +* need to confirm them. +*/ +#define IGC_I225_TX_LATENCY_10 9542 +#define IGC_I225_TX_LATENCY_100 1024 +#define IGC_I225_TX_LATENCY_1000 178 +#define IGC_I225_TX_LATENCY_2500 64 +#define IGC_I225_RX_LATENCY_10 20662 +#define IGC_I225_RX_LATENCY_100 2213 +#define IGC_I225_RX_LATENCY_1000 448 +#define IGC_I225_RX_LATENCY_2500 160 +/* RX and TX descriptor control thresholds. * PTHRESH - MAC will consider prefetch if it has fewer than this number of * descriptors available in its onboard memory.
@@ -537,6 +551,9 @@ int igc_erase_filter(struct igc_adapter *adapter,void igc_ptp_init (struct igc_adapter *adapter);void igc_ptp_reset (struct igc_adapter *adapter);void igc_ptp_stop (struct igc_adapter *adapter); +void igc_ptp_rx_rgtstamp (struct igc_q_vector *q_vector,struct sk_buff *skb); +void igc_ptp_rx_pktstamp (struct igc_q_vector *q_vector,void *va, +struct sk_buff *skb);int igc_ptp_set_ts_config (struct net_device *netdev,struct ifreq *ifr);int igc_ptp_get_ts_config (struct net_device *netdev,struct ifreq *ifr);#define igc_rx_pg_size (_ring) (PAGE_SIZE << igc_rx_pg_order(_ring))
drivers/net/ethernet/intel/igc/igc_defines.h +38 -0
@@ -283,12 +283,21 @@#define IGC_RCTL_RDMTS_HALF 0x00000000/* Rx desc min thresh size */ #define IGC_RCTL_BAM 0x00008000/* broadcast enable */ +/* Split Replication Receive Control */ +#define IGC_SRRCTL_TIMESTAMP 0x40000000 +#define IGC_SRRCTL_TIMER1SEL (timer) (((timer) & 0x3) << 14) +#define IGC_SRRCTL_TIMER0SEL (timer) (((timer) & 0x3) << 17) +/* Receive Descriptor bit definitions */ #define IGC_RXD_STAT_EOP 0x02/* End of Packet */ #define IGC_RXD_STAT_IXSM 0x04/* Ignore checksum */ #define IGC_RXD_STAT_UDPCS 0x10/* UDP xsum calculated */ #define IGC_RXD_STAT_TCPCS 0x20/* TCP xsum calculated */ +/* Advanced Receive Descriptor bit definitions */ +#define IGC_RXDADV_STAT_TSIP 0x08000/* timestamp in packet */ +#define IGC_RXDADV_STAT_TS 0x10000/* Pkt was time stamped */ +#define IGC_RXDEXT_STATERR_CE 0x01000000#define IGC_RXDEXT_STATERR_SE 0x02000000#define IGC_RXDEXT_STATERR_SEQ 0x04000000
@@ -325,6 +334,7 @@#define I225_RXPBSIZE_DEFAULT 0x000000A2/* RXPBSIZE default */ #define I225_TXPBSIZE_DEFAULT 0x04000014/* TXPBSIZE default */ +#define IGC_RXPBS_CFG_TS_EN 0x80000000/* Timestamp in Rx buffer */ /* Time Sync Interrupt Causes */ #define IGC_TSICR_SYS_WRAP BIT(0)/* SYSTIM Wrap around. */
@@ -336,6 +346,34 @@#define IGC_TSICR_INTERRUPTS IGC_TSICR_TXTS +/* PTP Queue Filter */ +#define IGC_ETQF_1588 BIT(30) + +#define IGC_FTQF_VF_BP 0x00008000 +#define IGC_FTQF_1588_TIME_STAMP 0x08000000 +#define IGC_FTQF_MASK 0xF0000000 +#define IGC_FTQF_MASK_PROTO_BP 0x10000000 + +/* Time Sync Receive Control bit definitions */ +#define IGC_TSYNCRXCTL_VALID 0x00000001/* Rx timestamp valid */ +#define IGC_TSYNCRXCTL_TYPE_MASK 0x0000000E/* Rx type mask */ +#define IGC_TSYNCRXCTL_TYPE_L2_V2 0x00 +#define IGC_TSYNCRXCTL_TYPE_L4_V1 0x02 +#define IGC_TSYNCRXCTL_TYPE_L2_L4_V2 0x04 +#define IGC_TSYNCRXCTL_TYPE_ALL 0x08 +#define IGC_TSYNCRXCTL_TYPE_EVENT_V2 0x0A +#define IGC_TSYNCRXCTL_ENABLED 0x00000010/* enable Rx timestamping */ +#define IGC_TSYNCRXCTL_SYSCFI 0x00000020/* Sys clock frequency */ + +/* Time Sync Receive Configuration */ +#define IGC_TSYNCRXCFG_PTP_V1_CTRLT_MASK 0x000000FF +#define IGC_TSYNCRXCFG_PTP_V1_SYNC_MESSAGE 0x00 +#define IGC_TSYNCRXCFG_PTP_V1_DELAY_REQ_MESSAGE 0x01 + +/* Immediate Interrupt Receive Extended */ +#define IGC_IMIREXT_CTRL_BP 0x00080000/* Bypass check of ctrl bits */ +#define IGC_IMIREXT_SIZE_BP 0x00001000/* Packet size bypass */ +/* Receive Checksum Control */ #define IGC_RXCSUM_CRCOFL 0x00000800/* CRC32 offload enable */ #define IGC_RXCSUM_PCSD 0x00002000/* packet checksum disabled */
drivers/net/ethernet/intel/igc/igc_main.c +10 -0
@@ -1272,6 +1272,10 @@ static void igc_process_skb_fields(struct igc_ring *rx_ring,igc_rx_checksum (rx_ring, rx_desc, skb); +if (igc_test_staterr (rx_desc,IGC_RXDADV_STAT_TS ) && + !igc_test_staterr (rx_desc,IGC_RXDADV_STAT_TSIP )) +igc_ptp_rx_rgtstamp (rx_ring->q_vector, skb); +skb_record_rx_queue (skb, rx_ring->queue_index); skb->protocol =eth_type_trans (skb, rx_ring->netdev);
@@ -1391,6 +1395,12 @@ static struct sk_buff *igc_construct_skb(struct igc_ring *rx_ring,if (unlikely (!skb))return NULL ; +if (unlikely (igc_test_staterr (rx_desc,IGC_RXDADV_STAT_TSIP ))) { +igc_ptp_rx_pktstamp (rx_ring->q_vector, va, skb); + va +=IGC_TS_HDR_LEN ; + size -=IGC_TS_HDR_LEN ; + } +/* Determine available headroom for copy */ headlen = size;if (headlen >IGC_RX_HDR_LEN )
drivers/net/ethernet/intel/igc/igc_ptp.c +272 -0
281 lines not on this page · raw message
drivers/net/ethernet/intel/igc/igc_regs.h +3 -0
@@ -224,6 +224,9 @@#define IGC_IMIREXT (_i) (0x05AA0 + ((_i) * 4))/* Immediate INTR Ext*/ #define IGC_FTQF (_n) (0x059E0 + (4 * (_n)))/* 5-tuple Queue Fltr */ + +#define IGC_RXPBS 0x02404/* Rx Packet Buffer Size - RW */ +/* System Time Registers */ #define IGC_SYSTIML 0x0B600/* System time register Low - RO */ #define IGC_SYSTIMH 0x0B604/* System time register High - RO */
Signature · 1 line
2.24.0
PATCH v2 3/5 igc: Add support for TX timestamping
In reply to Vinicius Costa GomesThis adds support for timestamping packets being transmitted.
Based on the code from i210. The basic differences is that i225 has 4 registers to store the transmit timestamps (i210 has one). Right now, we only support retrieving from one register, support for using the other registers will be added later.
--- drivers/net/ethernet/intel/igc/igc.h | 2 + drivers/net/ethernet/intel/igc/igc_defines.h | 14 +++ drivers/net/ethernet/intel/igc/igc_main.c | 49 +++++++++++ drivers/net/ethernet/intel/igc/igc_ptp.c | 92 ++++++++++++++++++++ 4 files changed, 157 insertions(+)
drivers/net/ethernet/intel/igc/igc.h +2 -0
@@ -556,6 +556,8 @@ void igc_ptp_rx_pktstamp(struct igc_q_vector *q_vector, void *va, struct sk_buff *skb);int igc_ptp_set_ts_config (struct net_device *netdev,struct ifreq *ifr);int igc_ptp_get_ts_config (struct net_device *netdev,struct ifreq *ifr); +void igc_ptp_tx_hang (struct igc_adapter *adapter); +#define igc_rx_pg_size (_ring) (PAGE_SIZE << igc_rx_pg_order(_ring))#define IGC_TXD_DCMD (IGC_ADVTXD_DCMD_EOP | IGC_ADVTXD_DCMD_RS)
drivers/net/ethernet/intel/igc/igc_defines.h +14 -0
@@ -370,10 +370,24 @@#define IGC_TSYNCRXCFG_PTP_V1_SYNC_MESSAGE 0x00#define IGC_TSYNCRXCFG_PTP_V1_DELAY_REQ_MESSAGE 0x01 +/* Immediate Interrupt Receive */ +#define IGC_IMIR_CLEAR_MASK 0xF001FFFF/* IMIR Reg Clear Mask */ +#define IGC_IMIR_PORT_BYPASS 0x20000/* IMIR Port Bypass Bit */ +#define IGC_IMIR_PRIORITY_SHIFT 29/* IMIR Priority Shift */ +#define IGC_IMIREXT_CLEAR_MASK 0x7FFFF/* IMIREXT Reg Clear Mask */ +/* Immediate Interrupt Receive Extended */ #define IGC_IMIREXT_CTRL_BP 0x00080000/* Bypass check of ctrl bits */ #define IGC_IMIREXT_SIZE_BP 0x00001000/* Packet size bypass */ +/* Time Sync Transmit Control bit definitions */ +#define IGC_TSYNCTXCTL_VALID 0x00000001/* Tx timestamp valid */ +#define IGC_TSYNCTXCTL_ENABLED 0x00000010/* enable Tx timestamping */ +#define IGC_TSYNCTXCTL_MAX_ALLOWED_DLY_MASK 0x0000F000/* max delay */ +#define IGC_TSYNCTXCTL_SYNC_COMP_ERR 0x20000000/* sync err */ +#define IGC_TSYNCTXCTL_SYNC_COMP 0x40000000/* sync complete */ +#define IGC_TSYNCTXCTL_START_SYNC 0x80000000/* initiate sync */ +/* Receive Checksum Control */ #define IGC_RXCSUM_CRCOFL 0x00000800/* CRC32 offload enable */ #define IGC_RXCSUM_PCSD 0x00002000/* packet checksum disabled */
drivers/net/ethernet/intel/igc/igc_main.c +49 -0
85 lines not on this page · raw message
drivers/net/ethernet/intel/igc/igc_ptp.c +92 -0
124 lines not on this page · raw message
Signature · 1 line
2.24.0
PATCH v2 4/5 igc: Add support for ethtool GET_TS_INFO command
In reply to Vinicius Costa GomesThis command allows igc to report what types of timestamping are supported. ptp4l uses this to detect if the hardware supports timestamping.
--- drivers/net/ethernet/intel/igc/igc_ethtool.c | 34 ++++++++++++++++++++ 1 file changed, 34 insertions(+)
drivers/net/ethernet/intel/igc/igc_ethtool.c +34 -0
@@ -1600,6 +1600,39 @@ static int igc_set_channels(struct net_device *netdev,return 0 ; } +static int igc_get_ts_info (struct net_device *dev, +struct ethtool_ts_info *info) +{ +struct igc_adapter *adapter =netdev_priv (dev); + +if (adapter->ptp_clock) + info->phc_index =ptp_clock_index (adapter->ptp_clock); +else + info->phc_index =-1 ; + +switch (adapter->hw.mac.type) { +case igc_i225: + info->so_timestamping = +SOF_TIMESTAMPING_TX_SOFTWARE | +SOF_TIMESTAMPING_RX_SOFTWARE | +SOF_TIMESTAMPING_SOFTWARE | +SOF_TIMESTAMPING_TX_HARDWARE | +SOF_TIMESTAMPING_RX_HARDWARE | +SOF_TIMESTAMPING_RAW_HARDWARE ; + + info->tx_types = +BIT (HWTSTAMP_TX_OFF ) | +BIT (HWTSTAMP_TX_ON ); + + info->rx_filters =BIT (HWTSTAMP_FILTER_NONE ); + info->rx_filters |=BIT (HWTSTAMP_FILTER_ALL ); + +return 0 ; +default : +return -EOPNOTSUPP ; + } +} +static u32 igc_get_priv_flags (struct net_device *netdev) {struct igc_adapter *adapter =netdev_priv (netdev);
@@ -1847,6 +1880,7 @@ static const struct ethtool_ops igc_ethtool_ops = { .get_rxfh_indir_size = igc_get_rxfh_indir_size, .get_rxfh = igc_get_rxfh, .set_rxfh = igc_set_rxfh, + .get_ts_info = igc_get_ts_info, .get_channels = igc_get_channels, .set_channels = igc_set_channels, .get_priv_flags = igc_get_priv_flags,
Signature · 1 line
2.24.0
PATCH v2 5/5 igc: Use Start of Packet signal from PHY for timestamping
In reply to Vinicius Costa GomesFor better accuracy, i225 is able to do timestamping using the Start of Packet signal from the PHY.
--- drivers/net/ethernet/intel/igc/igc_defines.h | 2 ++ drivers/net/ethernet/intel/igc/igc_ptp.c | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/igc/igc_defines.h +2 -0
@@ -364,6 +364,7 @@#define IGC_TSYNCRXCTL_TYPE_EVENT_V2 0x0A#define IGC_TSYNCRXCTL_ENABLED 0x00000010/* enable Rx timestamping */ #define IGC_TSYNCRXCTL_SYSCFI 0x00000020/* Sys clock frequency */ +#define IGC_TSYNCRXCTL_RXSYNSIG 0x00000400/* Sample RX tstamp in PHY sop */ /* Time Sync Receive Configuration */ #define IGC_TSYNCRXCFG_PTP_V1_CTRLT_MASK 0x000000FF
@@ -387,6 +388,7 @@#define IGC_TSYNCTXCTL_SYNC_COMP_ERR 0x20000000/* sync err */ #define IGC_TSYNCTXCTL_SYNC_COMP 0x40000000/* sync complete */ #define IGC_TSYNCTXCTL_START_SYNC 0x80000000/* initiate sync */ +#define IGC_TSYNCTXCTL_TXSYNSIG 0x00000020/* Sample TX tstamp in PHY sop */ /* Receive Checksum Control */ #define IGC_RXCSUM_CRCOFL 0x00000800/* CRC32 offload enable */
drivers/net/ethernet/intel/igc/igc_ptp.c +4 -1
@@ -368,6 +368,7 @@ static int igc_ptp_set_timestamp_mode(struct igc_adapter *adapter,if (tsync_rx_ctl) { tsync_rx_ctl =IGC_TSYNCRXCTL_ENABLED ; tsync_rx_ctl |=IGC_TSYNCRXCTL_TYPE_ALL ; + tsync_rx_ctl |=IGC_TSYNCRXCTL_RXSYNSIG ; config->rx_filter =HWTSTAMP_FILTER_ALL ; is_l2 = true; is_l4 = true;
@@ -384,8 +385,10 @@ static int igc_ptp_set_timestamp_mode(struct igc_adapter *adapter, } } -if (tsync_tx_ctl) +if (tsync_tx_ctl) { tsync_tx_ctl =IGC_TSYNCTXCTL_ENABLED ; + tsync_tx_ctl |=IGC_TSYNCTXCTL_TXSYNSIG ; + }/* enable/disable TX */ regval =rd32 (IGC_TSYNCTXCTL );
Signature · 1 line
2.24.0