igc: Add basic support for Timestamping/PTP
Subsystems (2)
v3 cover igc: Add basic support for Timestamping/PTP
Hi,
Changes from v2:
- Rebased against Jeff's next-queue tree.
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 v3 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)
@@ -432,6 +439,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 */
@@ -515,6 +536,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
@@ -218,6 +218,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 */
@@ -240,6 +241,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 */
@@ -355,6 +357,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
@@ -102,6 +102,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); }
@@ -4277,6 +4280,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,
@@ -4288,6 +4309,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 */
@@ -4588,6 +4610,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;
@@ -4629,6 +4654,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
@@ -209,6 +209,30 @@#define IGC_LENERRS 0x04138/* Length Errors Count */ #define IGC_HRMPC 0x0A018/* Header Redirection Missed Packet Count */ +/* 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
kbuild test robot
build botRe: [Intel-wired-lan] [next-queue PATCH v3 1/5] igc: Add basic skeleton for PTP
Thank you for the patch! Perhaps something to improve:
Hi Vinicius,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on jkirsher-next-queue/dev-queue]
[also build test WARNING on v5.4 v5.4-rc8 v5.4-rc7 next-20191202 v5.4 next-20191203] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Vinicius-Costa-Gomes/igc-Add-basic-skeleton-for-PTP/20191203-072231 base: https://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue.git dev-queue reproduce: # apt-get install sparse # sparse version: v0.6.1-91-g817270f-dirty make ARCH=x86_64 allmodconfig make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag
sparse warnings: (new ones prefixed by >>)
drivers/net/ethernet/intel/igc/igc_ptp.c:143:6: sparse: sparse: symbol 'igc_ptp_tx_hang' was not declared. Should it be static?
>> drivers/net/ethernet/intel/igc/igc_ptp.c:173:6: sparse: sparse: symbol 'igc_ptp_tx_work' was not declared. Should it be static? >> drivers/net/ethernet/intel/igc/igc_ptp.c:277:6: sparse: sparse: symbol 'igc_ptp_suspend' was not declared. Should it be static?
Please review and possibly fold the followup patch.
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation
kbuild test robot
build bot[RFC PATCH] igc: igc_ptp_tx_work() can be static
In reply to Vinicius Costa GomesFixes: 253d7866c579 ("igc: Add basic skeleton for PTP")
--- igc_ptp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/igc/igc_ptp.c +2 -2
@@ -170,7 +170,7 @@ void igc_ptp_tx_hang(struct igc_adapter *adapter) } } -void igc_ptp_tx_work (struct work_struct *work) +static void igc_ptp_tx_work (struct work_struct *work) { }
@@ -274,7 +274,7 @@ void igc_ptp_init(struct igc_adapter *adapter)* This function stops the overflow check work and PTP Tx timestamp work, and * will prepare the device for OS suspend. */ -void igc_ptp_suspend (struct igc_adapter *adapter) +static void igc_ptp_suspend (struct igc_adapter *adapter) {if (!(adapter->ptp_flags &IGC_PTP_ENABLED ))return ;
Brown
PATCH v3 1/5 igc: Add basic skeleton for PTP
In reply to Vinicius Costa GomesQuoted 11 lines
From: Intel-wired-lan <[email protected]> On Behalf Of Vinicius Costa Gomes
Sent: Monday, December 2, 2019 3:20 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next-queue PATCH v3 1/5] igc: Add basic skeleton for PTPThis allows the creation of the
/dev/ptpXdevice for i225, and reading and writing the time.Signed-off-by Vinicius Costa Gomes <[email protected]>
Quoted 10 lines
--- 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
PATCH v3 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.
@@ -539,6 +553,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
@@ -314,12 +314,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
@@ -356,6 +365,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. */
@@ -367,6 +377,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
@@ -1299,6 +1299,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);
@@ -1418,6 +1422,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
@@ -222,6 +222,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
kbuild test robot
build botRe: [Intel-wired-lan] [next-queue PATCH v3 2/5] igc: Add support for RX timestamping
Thank you for the patch! Perhaps something to improve:
Hi Vinicius,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on jkirsher-next-queue/dev-queue]
[also build test WARNING on next-20191202 next-20191204]
[cannot apply to v5.4 v5.4-rc8 v5.4-rc7 v5.4]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Vinicius-Costa-Gomes/igc-Add-basic-skeleton-for-PTP/20191203-072231 base: https://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue.git dev-queue reproduce: # apt-get install sparse # sparse version: v0.6.1-91-g817270f-dirty make ARCH=x86_64 allmodconfig make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag
sparse warnings: (new ones prefixed by >>)
>> drivers/net/ethernet/intel/igc/igc_ptp.c:397:17: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected unsigned int val @@ got restricted __be1unsigned int val @@ >> drivers/net/ethernet/intel/igc/igc_ptp.c:397:17: sparse: expected unsigned int val >> drivers/net/ethernet/intel/igc/igc_ptp.c:397:17: sparse: got restricted __be16 [usertype]
drivers/net/ethernet/intel/igc/igc_ptp.c:415:6: sparse: sparse: symbol 'igc_ptp_tx_hang' was not declared. Should it be static? drivers/net/ethernet/intel/igc/igc_ptp.c:445:6: sparse: sparse: symbol 'igc_ptp_tx_work' was not declared. Should it be static? drivers/net/ethernet/intel/igc/igc_ptp.c:549:6: sparse: sparse: symbol 'igc_ptp_suspend' was not declared. Should it be static?
vim +397 drivers/net/ethernet/intel/igc/igc_ptp.c
281
282 /**
283 * igc_ptp_set_timestamp_mode - setup hardware for timestamping
284 * @adapter: networking device structure
285 * @config: hwtstamp configuration
286 *
287 * Incoming time stamping has to be configured via the hardware
288 * filters. Not all combinations are supported, in particular event
289 * type has to be specified. Matching the kind of event packet is
290 * not supported, with the exception of "all V2 events regardless of
291 * level 2 or 4".
292 *
293 */
294 static int igc_ptp_set_timestamp_mode(struct igc_adapter *adapter,
295 struct hwtstamp_config *config)
296 {
297 struct igc_hw *hw = &adapter->hw;
298 u32 tsync_rx_ctl = IGC_TSYNCRXCTL_ENABLED;
299 u32 tsync_rx_cfg = 0;
300 bool is_l4 = false;
301 bool is_l2 = false;
302 u32 regval;
303
304 /* reserved for future extensions */
305 if (config->flags)
306 return -EINVAL;
307
308 switch (config->rx_filter) {
309 case HWTSTAMP_FILTER_NONE:
310 tsync_rx_ctl = 0;
311 break;
312 case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
313 tsync_rx_ctl |= IGC_TSYNCRXCTL_TYPE_L4_V1;
314 tsync_rx_cfg = IGC_TSYNCRXCFG_PTP_V1_SYNC_MESSAGE;
315 is_l4 = true;
316 break;
317 case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
318 tsync_rx_ctl |= IGC_TSYNCRXCTL_TYPE_L4_V1;
319 tsync_rx_cfg = IGC_TSYNCRXCFG_PTP_V1_DELAY_REQ_MESSAGE;
320 is_l4 = true;
321 break;
322 case HWTSTAMP_FILTER_PTP_V2_EVENT:
323 case HWTSTAMP_FILTER_PTP_V2_L2_EVENT:
324 case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
325 case HWTSTAMP_FILTER_PTP_V2_SYNC:
326 case HWTSTAMP_FILTER_PTP_V2_L2_SYNC:
327 case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
328 case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
329 case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ:
330 case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
331 tsync_rx_ctl |= IGC_TSYNCRXCTL_TYPE_EVENT_V2;
332 config->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
333 is_l2 = true;
334 is_l4 = true;
335 break;
336 case HWTSTAMP_FILTER_PTP_V1_L4_EVENT:
337 case HWTSTAMP_FILTER_NTP_ALL:
338 case HWTSTAMP_FILTER_ALL:
339 tsync_rx_ctl |= IGC_TSYNCRXCTL_TYPE_ALL;
340 config->rx_filter = HWTSTAMP_FILTER_ALL;
341 break;
342 /* fall through */
343 default:
344 config->rx_filter = HWTSTAMP_FILTER_NONE;
345 return -ERANGE;
346 }
347
348 /* Per-packet timestamping only works if all packets are
349 * timestamped, so enable timestamping in all packets as long
350 * as one rx filter was configured.
351 */
352 if (tsync_rx_ctl) {
353 tsync_rx_ctl = IGC_TSYNCRXCTL_ENABLED;
354 tsync_rx_ctl |= IGC_TSYNCRXCTL_TYPE_ALL;
355 config->rx_filter = HWTSTAMP_FILTER_ALL;
356 is_l2 = true;
357 is_l4 = true;
358
359 if (hw->mac.type == igc_i225) {
360 regval = rd32(IGC_RXPBS);
361 regval |= IGC_RXPBS_CFG_TS_EN;
362 wr32(IGC_RXPBS, regval);
363
364 /* FIXME: For now, only support retrieving RX
365 * timestamps from timer 0
366 */
367 igc_ptp_enable_tstamp_all_rxqueues(adapter, 0);
368 }
369 }
370
371 /* enable/disable RX */
372 regval = rd32(IGC_TSYNCRXCTL);
373 regval &= ~(IGC_TSYNCRXCTL_ENABLED | IGC_TSYNCRXCTL_TYPE_MASK);
374 regval |= tsync_rx_ctl;
375 wr32(IGC_TSYNCRXCTL, regval);
376
377 /* define which PTP packets are time stamped */
378 wr32(IGC_TSYNCRXCFG, tsync_rx_cfg);
379
380 /* define ethertype filter for timestamped packets */
381 if (is_l2)
382 wr32(IGC_ETQF(3),
383 (IGC_ETQF_FILTER_ENABLE | /* enable filter */
384 IGC_ETQF_1588 | /* enable timestamping */
385 ETH_P_1588)); /* 1588 eth protocol type */
386 else
387 wr32(IGC_ETQF(3), 0);
388
389 /* L4 Queue Filter[3]: filter by destination port and protocol */
390 if (is_l4) {
391 u32 ftqf = (IPPROTO_UDP /* UDP */
392 | IGC_FTQF_VF_BP /* VF not compared */
393 | IGC_FTQF_1588_TIME_STAMP /* Enable Timestamp */
394 | IGC_FTQF_MASK); /* mask all inputs */
395 ftqf &= ~IGC_FTQF_MASK_PROTO_BP; /* enable protocol check */
396
> 397 wr32(IGC_IMIR(3), htons(PTP_EV_PORT)); 398 wr32(IGC_IMIREXT(3),
399 (IGC_IMIREXT_SIZE_BP | IGC_IMIREXT_CTRL_BP));
400 wr32(IGC_FTQF(3), ftqf);
401 } else {
402 wr32(IGC_FTQF(3), IGC_FTQF_MASK);
403 }
404 wrfl();
405
406 /* clear TX/RX time stamp registers, just to be sure */
407 regval = rd32(IGC_TXSTMPL);
408 regval = rd32(IGC_TXSTMPH);
409 regval = rd32(IGC_RXSTMPL);
410 regval = rd32(IGC_RXSTMPH);
411
412 return 0;
413 }
414
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation
Brown
PATCH v3 2/5 igc: Add support for RX timestamping
In reply to Vinicius Costa GomesQuoted 16 lines
From: Intel-wired-lan <[email protected]> On Behalf Of Vinicius Costa Gomes
Sent: Monday, December 2, 2019 3:20 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next-queue PATCH v3 2/5] igc: Add support for RX timestampingThis 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.
Quoted 8 lines
Signed-off-by Vinicius Costa Gomes <[email protected]>--- 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(+)
PATCH v3 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
@@ -558,6 +558,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
@@ -401,10 +401,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
Brown
PATCH v3 3/5 igc: Add support for TX timestamping
Quoted 14 lines
From: Intel-wired-lan <[email protected]> On Behalf Of Vinicius Costa Gomes
Sent: Monday, December 2, 2019 3:20 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next-queue PATCH v3 3/5] igc: Add support for TX timestampingThis 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.
Quoted 8 lines
Signed-off-by Vinicius Costa Gomes <[email protected]>--- 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(+)
PATCH v3 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
Brown
PATCH v3 4/5 igc: Add support for ethtool GET_TS_INFO command
Quoted 7 lines
From: Intel-wired-lan <[email protected]> On Behalf Of Vinicius Costa Gomes
Sent: Monday, December 2, 2019 3:20 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next-queue PATCH v3 4/5] igc: Add support for ethtoolGET_TS_INFOcommand
Quoted 9 lines
This command allows igc to report what types of timestamping are supported. ptp4l uses this to detect if the hardware supports timestamping.
Signed-off-by Vinicius Costa Gomes <[email protected]>--- drivers/net/ethernet/intel/igc/igc_ethtool.c | 34 ++++++++++++++++++++ 1 file changed, 34 insertions(+)
PATCH v3 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
@@ -395,6 +395,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
@@ -418,6 +419,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
Brown
PATCH v3 5/5 igc: Use Start of Packet signal from PHY for timestamping
Quoted 7 lines
From: Intel-wired-lan <[email protected]> On Behalf Of Vinicius Costa Gomes
Sent: Monday, December 2, 2019 3:20 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next-queue PATCH v3 5/5] igc: Use Start of Packet signal from PHY for timestamping
Quoted 9 lines
For better accuracy, i225 is able to do timestamping using the Start of Packet signal from the PHY.
Signed-off-by Vinicius Costa Gomes <[email protected]>--- 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(-)