@@ -224,6 +224,8 @@ struct ixgbe_rx_queue_stats {
224224 u64 csum_err ;
225225};
226226
227+ #define IXGBE_TS_HDR_LEN 8
228+
227229enum ixgbe_ring_state_t {
228230 __IXGBE_TX_FDIR_INIT_DONE ,
229231 __IXGBE_TX_XPS_INIT_DONE ,
@@ -282,6 +284,8 @@ struct ixgbe_ring {
282284 u16 next_to_use ;
283285 u16 next_to_clean ;
284286
287+ unsigned long last_rx_timestamp ;
288+
285289 union {
286290 u16 next_to_alloc ;
287291 struct {
@@ -640,6 +644,8 @@ struct ixgbe_adapter {
640644#define IXGBE_FLAG_SRIOV_CAPABLE (u32)(1 << 22)
641645#define IXGBE_FLAG_SRIOV_ENABLED (u32)(1 << 23)
642646#define IXGBE_FLAG_VXLAN_OFFLOAD_CAPABLE BIT(24)
647+ #define IXGBE_FLAG_RX_HWTSTAMP_ENABLED BIT(25)
648+ #define IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER BIT(26)
643649
644650 u32 flags2 ;
645651#define IXGBE_FLAG2_RSC_CAPABLE (u32)(1 << 0)
@@ -756,9 +762,12 @@ struct ixgbe_adapter {
756762 unsigned long last_rx_ptp_check ;
757763 unsigned long last_rx_timestamp ;
758764 spinlock_t tmreg_lock ;
759- struct cyclecounter cc ;
760- struct timecounter tc ;
765+ struct cyclecounter hw_cc ;
766+ struct timecounter hw_tc ;
761767 u32 base_incval ;
768+ u32 tx_hwtstamp_timeouts ;
769+ u32 rx_hwtstamp_cleared ;
770+ void (* ptp_setup_sdp )(struct ixgbe_adapter * );
762771
763772 /* SR-IOV */
764773 DECLARE_BITMAP (active_vfs , IXGBE_MAX_VF_FUNCTIONS );
@@ -969,12 +978,33 @@ void ixgbe_ptp_suspend(struct ixgbe_adapter *adapter);
969978void ixgbe_ptp_stop (struct ixgbe_adapter * adapter );
970979void ixgbe_ptp_overflow_check (struct ixgbe_adapter * adapter );
971980void ixgbe_ptp_rx_hang (struct ixgbe_adapter * adapter );
972- void ixgbe_ptp_rx_hwtstamp (struct ixgbe_adapter * adapter , struct sk_buff * skb );
981+ void ixgbe_ptp_rx_pktstamp (struct ixgbe_q_vector * , struct sk_buff * );
982+ void ixgbe_ptp_rx_rgtstamp (struct ixgbe_q_vector * , struct sk_buff * skb );
983+ static inline void ixgbe_ptp_rx_hwtstamp (struct ixgbe_ring * rx_ring ,
984+ union ixgbe_adv_rx_desc * rx_desc ,
985+ struct sk_buff * skb )
986+ {
987+ if (unlikely (ixgbe_test_staterr (rx_desc , IXGBE_RXD_STAT_TSIP ))) {
988+ ixgbe_ptp_rx_pktstamp (rx_ring -> q_vector , skb );
989+ return ;
990+ }
991+
992+ if (unlikely (!ixgbe_test_staterr (rx_desc , IXGBE_RXDADV_STAT_TS )))
993+ return ;
994+
995+ ixgbe_ptp_rx_rgtstamp (rx_ring -> q_vector , skb );
996+
997+ /* Update the last_rx_timestamp timer in order to enable watchdog check
998+ * for error case of latched timestamp on a dropped packet.
999+ */
1000+ rx_ring -> last_rx_timestamp = jiffies ;
1001+ }
1002+
9731003int ixgbe_ptp_set_ts_config (struct ixgbe_adapter * adapter , struct ifreq * ifr );
9741004int ixgbe_ptp_get_ts_config (struct ixgbe_adapter * adapter , struct ifreq * ifr );
9751005void ixgbe_ptp_start_cyclecounter (struct ixgbe_adapter * adapter );
9761006void ixgbe_ptp_reset (struct ixgbe_adapter * adapter );
977- void ixgbe_ptp_check_pps_event (struct ixgbe_adapter * adapter , u32 eicr );
1007+ void ixgbe_ptp_check_pps_event (struct ixgbe_adapter * adapter );
9781008#ifdef CONFIG_PCI_IOV
9791009void ixgbe_sriov_reinit (struct ixgbe_adapter * adapter );
9801010#endif
0 commit comments