Skip to content

Commit a9763f3

Browse files
mdrustadJeff Kirsher
authored andcommitted
ixgbe: Update PTP to support X550EM_x devices
The X550EM_x devices handle clocking differently, so update the PTP implementation to accommodate them. This involves significant changes to ixgbe's PTP code to accommodate the new range of behaviors including things like non-power-of-2 clock wrapping. Signed-off-by: Mark Rustad <[email protected]> Tested-by: Darin Miller <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 2f9be16 commit a9763f3

File tree

4 files changed

+578
-197
lines changed

4 files changed

+578
-197
lines changed

drivers/net/ethernet/intel/ixgbe/ixgbe.h

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ struct ixgbe_rx_queue_stats {
224224
u64 csum_err;
225225
};
226226

227+
#define IXGBE_TS_HDR_LEN 8
228+
227229
enum 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);
969978
void ixgbe_ptp_stop(struct ixgbe_adapter *adapter);
970979
void ixgbe_ptp_overflow_check(struct ixgbe_adapter *adapter);
971980
void 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+
9731003
int ixgbe_ptp_set_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr);
9741004
int ixgbe_ptp_get_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr);
9751005
void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter);
9761006
void 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
9791009
void ixgbe_sriov_reinit(struct ixgbe_adapter *adapter);
9801010
#endif

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,15 +1634,16 @@ static void ixgbe_process_skb_fields(struct ixgbe_ring *rx_ring,
16341634
struct sk_buff *skb)
16351635
{
16361636
struct net_device *dev = rx_ring->netdev;
1637+
u32 flags = rx_ring->q_vector->adapter->flags;
16371638

16381639
ixgbe_update_rsc_stats(rx_ring, skb);
16391640

16401641
ixgbe_rx_hash(rx_ring, rx_desc, skb);
16411642

16421643
ixgbe_rx_checksum(rx_ring, rx_desc, skb);
16431644

1644-
if (unlikely(ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_STAT_TS)))
1645-
ixgbe_ptp_rx_hwtstamp(rx_ring->q_vector->adapter, skb);
1645+
if (unlikely(flags & IXGBE_FLAG_RX_HWTSTAMP_ENABLED))
1646+
ixgbe_ptp_rx_hwtstamp(rx_ring, rx_desc, skb);
16461647

16471648
if ((dev->features & NETIF_F_HW_VLAN_CTAG_RX) &&
16481649
ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_VP)) {
@@ -2740,7 +2741,7 @@ static irqreturn_t ixgbe_msix_other(int irq, void *data)
27402741
ixgbe_check_fan_failure(adapter, eicr);
27412742

27422743
if (unlikely(eicr & IXGBE_EICR_TIMESYNC))
2743-
ixgbe_ptp_check_pps_event(adapter, eicr);
2744+
ixgbe_ptp_check_pps_event(adapter);
27442745

27452746
/* re-enable the original interrupt state, no lsc, no queues */
27462747
if (!test_bit(__IXGBE_DOWN, &adapter->state))
@@ -2947,7 +2948,7 @@ static irqreturn_t ixgbe_intr(int irq, void *data)
29472948

29482949
ixgbe_check_fan_failure(adapter, eicr);
29492950
if (unlikely(eicr & IXGBE_EICR_TIMESYNC))
2950-
ixgbe_ptp_check_pps_event(adapter, eicr);
2951+
ixgbe_ptp_check_pps_event(adapter);
29512952

29522953
/* would disable interrupts here but EIAM disabled it */
29532954
napi_schedule_irqoff(&q_vector->napi);

0 commit comments

Comments
 (0)