aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/intel/ixgbe
diff options
context:
space:
mode:
authorJacob Keller <jacob.e.keller@intel.com>2012-12-05 02:24:41 -0500
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2013-01-23 17:32:57 -0500
commit6cb562d6681155190c52ef7603c559c284eef159 (patch)
tree183dd8ccb290d0e7697efabb97b2fec0409c1edb /drivers/net/ethernet/intel/ixgbe
parentf2f33387f999bd914938dc2da4a3408ea14ad878 (diff)
ixgbe: Use watchdog check in favor of BPF for detecting latched timestamp
This patch removes ixgbe_ptp_match, and the corresponding packet filtering from ixgbe driver. This code was previously causing some issues within the hotpath of the driver. However the code also provided a check against possible frozen Rx timestamp due to dropped packets when the Rx ring is full. This patch provides a replacement solution based on the watchdog. To this end, whenever a packet consumes the Rx timestamp it stores the jiffy value in the rx_ring structure. Watchdog updates its own jiffy timer whenever there is no valid timestamp in the registers. If watchdog detects a valid timestamp in the registers, (meaning that no Rx packet has consumed it yet) it will check which time is most recent, the last time in the watchdog, or any time in the rx_rings. If the most recent "event" was more than 5seconds ago, it will flush the Rx timestamp and print a warning message to the syslog. Reported-by: Alexander Duyck <alexander.h.duyck@intel.com> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/ixgbe')
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe.h7
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c5
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c126
3 files changed, 51 insertions, 87 deletions
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
index f94c085a9c0b..2572e1393e22 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
@@ -35,6 +35,7 @@
35#include <linux/cpumask.h> 35#include <linux/cpumask.h>
36#include <linux/aer.h> 36#include <linux/aer.h>
37#include <linux/if_vlan.h> 37#include <linux/if_vlan.h>
38#include <linux/jiffies.h>
38 39
39#include <linux/clocksource.h> 40#include <linux/clocksource.h>
40#include <linux/net_tstamp.h> 41#include <linux/net_tstamp.h>
@@ -231,6 +232,7 @@ struct ixgbe_ring {
231 struct ixgbe_tx_buffer *tx_buffer_info; 232 struct ixgbe_tx_buffer *tx_buffer_info;
232 struct ixgbe_rx_buffer *rx_buffer_info; 233 struct ixgbe_rx_buffer *rx_buffer_info;
233 }; 234 };
235 unsigned long last_rx_timestamp;
234 unsigned long state; 236 unsigned long state;
235 u8 __iomem *tail; 237 u8 __iomem *tail;
236 dma_addr_t dma; /* phys. address of descriptor ring */ 238 dma_addr_t dma; /* phys. address of descriptor ring */
@@ -581,10 +583,10 @@ struct ixgbe_adapter {
581 struct ptp_clock *ptp_clock; 583 struct ptp_clock *ptp_clock;
582 struct ptp_clock_info ptp_caps; 584 struct ptp_clock_info ptp_caps;
583 unsigned long last_overflow_check; 585 unsigned long last_overflow_check;
586 unsigned long last_rx_ptp_check;
584 spinlock_t tmreg_lock; 587 spinlock_t tmreg_lock;
585 struct cyclecounter cc; 588 struct cyclecounter cc;
586 struct timecounter tc; 589 struct timecounter tc;
587 int rx_hwtstamp_filter;
588 u32 base_incval; 590 u32 base_incval;
589 591
590 /* SR-IOV */ 592 /* SR-IOV */
@@ -749,9 +751,10 @@ static inline struct netdev_queue *txring_txq(const struct ixgbe_ring *ring)
749extern void ixgbe_ptp_init(struct ixgbe_adapter *adapter); 751extern void ixgbe_ptp_init(struct ixgbe_adapter *adapter);
750extern void ixgbe_ptp_stop(struct ixgbe_adapter *adapter); 752extern void ixgbe_ptp_stop(struct ixgbe_adapter *adapter);
751extern void ixgbe_ptp_overflow_check(struct ixgbe_adapter *adapter); 753extern void ixgbe_ptp_overflow_check(struct ixgbe_adapter *adapter);
754extern void ixgbe_ptp_rx_hang(struct ixgbe_adapter *adapter);
752extern void ixgbe_ptp_tx_hwtstamp(struct ixgbe_q_vector *q_vector, 755extern void ixgbe_ptp_tx_hwtstamp(struct ixgbe_q_vector *q_vector,
753 struct sk_buff *skb); 756 struct sk_buff *skb);
754extern void ixgbe_ptp_rx_hwtstamp(struct ixgbe_q_vector *q_vector, 757extern void ixgbe_ptp_rx_hwtstamp(struct ixgbe_ring *rx_ring,
755 union ixgbe_adv_rx_desc *rx_desc, 758 union ixgbe_adv_rx_desc *rx_desc,
756 struct sk_buff *skb); 759 struct sk_buff *skb);
757extern int ixgbe_ptp_hwtstamp_ioctl(struct ixgbe_adapter *adapter, 760extern int ixgbe_ptp_hwtstamp_ioctl(struct ixgbe_adapter *adapter,
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index e7109de2204a..ab4328842a66 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -1441,7 +1441,7 @@ static void ixgbe_process_skb_fields(struct ixgbe_ring *rx_ring,
1441 1441
1442 ixgbe_rx_checksum(rx_ring, rx_desc, skb); 1442 ixgbe_rx_checksum(rx_ring, rx_desc, skb);
1443 1443
1444 ixgbe_ptp_rx_hwtstamp(rx_ring->q_vector, rx_desc, skb); 1444 ixgbe_ptp_rx_hwtstamp(rx_ring, rx_desc, skb);
1445 1445
1446 if ((dev->features & NETIF_F_HW_VLAN_RX) && 1446 if ((dev->features & NETIF_F_HW_VLAN_RX) &&
1447 ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_VP)) { 1447 ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_VP)) {
@@ -5534,6 +5534,8 @@ static void ixgbe_watchdog_link_is_up(struct ixgbe_adapter *adapter)
5534 break; 5534 break;
5535 } 5535 }
5536 5536
5537 adapter->last_rx_ptp_check = jiffies;
5538
5537 if (adapter->flags2 & IXGBE_FLAG2_PTP_ENABLED) 5539 if (adapter->flags2 & IXGBE_FLAG2_PTP_ENABLED)
5538 ixgbe_ptp_start_cyclecounter(adapter); 5540 ixgbe_ptp_start_cyclecounter(adapter);
5539 5541
@@ -5887,6 +5889,7 @@ static void ixgbe_service_task(struct work_struct *work)
5887 ixgbe_fdir_reinit_subtask(adapter); 5889 ixgbe_fdir_reinit_subtask(adapter);
5888 ixgbe_check_hang_subtask(adapter); 5890 ixgbe_check_hang_subtask(adapter);
5889 ixgbe_ptp_overflow_check(adapter); 5891 ixgbe_ptp_overflow_check(adapter);
5892 ixgbe_ptp_rx_hang(adapter);
5890 5893
5891 ixgbe_service_event_complete(adapter); 5894 ixgbe_service_event_complete(adapter);
5892} 5895}
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
index 2e54e0ca8d3f..dcc67e2f8db4 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
@@ -101,10 +101,6 @@
101#define NSECS_PER_SEC 1000000000ULL 101#define NSECS_PER_SEC 1000000000ULL
102#endif 102#endif
103 103
104static struct sock_filter ptp_filter[] = {
105 PTP_FILTER
106};
107
108/** 104/**
109 * ixgbe_ptp_setup_sdp 105 * ixgbe_ptp_setup_sdp
110 * @hw: the hardware private structure 106 * @hw: the hardware private structure
@@ -428,64 +424,44 @@ void ixgbe_ptp_overflow_check(struct ixgbe_adapter *adapter)
428} 424}
429 425
430/** 426/**
431 * ixgbe_ptp_match - determine if this skb matches a ptp packet 427 * ixgbe_ptp_rx_hang - detect error case when Rx timestamp registers latched
432 * @skb: pointer to the skb 428 * @adapter: private network adapter structure
433 * @hwtstamp: pointer to the hwtstamp_config to check
434 *
435 * Determine whether the skb should have been timestamped, assuming the
436 * hwtstamp was set via the hwtstamp ioctl. Returns non-zero when the packet
437 * should have a timestamp waiting in the registers, and 0 otherwise.
438 * 429 *
439 * V1 packets have to check the version type to determine whether they are 430 * this watchdog task is scheduled to detect error case where hardware has
440 * correct. However, we can't directly access the data because it might be 431 * dropped an Rx packet that was timestamped when the ring is full. The
441 * fragmented in the SKB, in paged memory. In order to work around this, we 432 * particular error is rare but leaves the device in a state unable to timestamp
442 * use skb_copy_bits which will properly copy the data whether it is in the 433 * any future packets.
443 * paged memory fragments or not. We have to copy the IP header as well as the
444 * message type.
445 */ 434 */
446static int ixgbe_ptp_match(struct sk_buff *skb, int rx_filter) 435void ixgbe_ptp_rx_hang(struct ixgbe_adapter *adapter)
447{ 436{
448 struct iphdr iph; 437 struct ixgbe_hw *hw = &adapter->hw;
449 u8 msgtype; 438 struct ixgbe_ring *rx_ring;
450 unsigned int type, offset; 439 u32 tsyncrxctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
451 440 unsigned long rx_event;
452 if (rx_filter == HWTSTAMP_FILTER_NONE) 441 int n;
453 return 0;
454
455 type = sk_run_filter(skb, ptp_filter);
456
457 if (likely(rx_filter == HWTSTAMP_FILTER_PTP_V2_EVENT))
458 return type & PTP_CLASS_V2;
459 442
460 /* For the remaining cases actually check message type */ 443 /* if we don't have a valid timestamp in the registers, just update the
461 switch (type) { 444 * timeout counter and exit
462 case PTP_CLASS_V1_IPV4: 445 */
463 skb_copy_bits(skb, OFF_IHL, &iph, sizeof(iph)); 446 if (!(tsyncrxctl & IXGBE_TSYNCRXCTL_VALID)) {
464 offset = ETH_HLEN + (iph.ihl << 2) + UDP_HLEN + OFF_PTP_CONTROL; 447 adapter->last_rx_ptp_check = jiffies;
465 break; 448 return;
466 case PTP_CLASS_V1_IPV6:
467 offset = OFF_PTP6 + OFF_PTP_CONTROL;
468 break;
469 default:
470 /* other cases invalid or handled above */
471 return 0;
472 } 449 }
473 450
474 /* Make sure our buffer is long enough */ 451 /* determine the most recent watchdog or rx_timestamp event */
475 if (skb->len < offset) 452 rx_event = adapter->last_rx_ptp_check;
476 return 0; 453 for (n = 0; n < adapter->num_rx_queues; n++) {
454 rx_ring = adapter->rx_ring[n];
455 if (time_after(rx_ring->last_rx_timestamp, rx_event))
456 rx_event = rx_ring->last_rx_timestamp;
457 }
477 458
478 skb_copy_bits(skb, offset, &msgtype, sizeof(msgtype)); 459 /* only need to read the high RXSTMP register to clear the lock */
460 if (time_is_before_jiffies(rx_event + 5*HZ)) {
461 IXGBE_READ_REG(hw, IXGBE_RXSTMPH);
462 adapter->last_rx_ptp_check = jiffies;
479 463
480 switch (rx_filter) { 464 e_warn(drv, "clearing RX Timestamp hang");
481 case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
482 return (msgtype == IXGBE_RXMTRL_V1_SYNC_MSG);
483 break;
484 case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
485 return (msgtype == IXGBE_RXMTRL_V1_DELAY_REQ_MSG);
486 break;
487 default:
488 return 0;
489 } 465 }
490} 466}
491 467
@@ -545,7 +521,7 @@ void ixgbe_ptp_tx_hwtstamp(struct ixgbe_q_vector *q_vector,
545 * value, then store that result into the shhwtstamps structure which 521 * value, then store that result into the shhwtstamps structure which
546 * is passed up the network stack 522 * is passed up the network stack
547 */ 523 */
548void ixgbe_ptp_rx_hwtstamp(struct ixgbe_q_vector *q_vector, 524void ixgbe_ptp_rx_hwtstamp(struct ixgbe_ring *rx_ring,
549 union ixgbe_adv_rx_desc *rx_desc, 525 union ixgbe_adv_rx_desc *rx_desc,
550 struct sk_buff *skb) 526 struct sk_buff *skb)
551{ 527{
@@ -557,43 +533,32 @@ void ixgbe_ptp_rx_hwtstamp(struct ixgbe_q_vector *q_vector,
557 unsigned long flags; 533 unsigned long flags;
558 534
559 /* we cannot process timestamps on a ring without a q_vector */ 535 /* we cannot process timestamps on a ring without a q_vector */
560 if (!q_vector || !q_vector->adapter) 536 if (!rx_ring->q_vector || !rx_ring->q_vector->adapter)
561 return; 537 return;
562 538
563 adapter = q_vector->adapter; 539 adapter = rx_ring->q_vector->adapter;
564 hw = &adapter->hw; 540 hw = &adapter->hw;
565 541
566 if (likely(!ixgbe_ptp_match(skb, adapter->rx_hwtstamp_filter))) 542 if (unlikely(!ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_STAT_TS)))
567 return; 543 return;
568 544
545 /*
546 * Read the tsyncrxctl register afterwards in order to prevent taking an
547 * I/O hit on every packet.
548 */
569 tsyncrxctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL); 549 tsyncrxctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
570
571 /* Check if we have a valid timestamp and make sure the skb should
572 * have been timestamped */
573 if (!(tsyncrxctl & IXGBE_TSYNCRXCTL_VALID)) 550 if (!(tsyncrxctl & IXGBE_TSYNCRXCTL_VALID))
574 return; 551 return;
575 552
576 /* 553 /*
577 * Always read the registers, in order to clear a possible fault 554 * Update the last_rx_timestamp timer in order to enable watchdog check
578 * because of stagnant RX timestamp values for a packet that never 555 * for error case of latched timestamp on a dropped packet.
579 * reached the queue.
580 */ 556 */
557 rx_ring->last_rx_timestamp = jiffies;
558
581 regval |= (u64)IXGBE_READ_REG(hw, IXGBE_RXSTMPL); 559 regval |= (u64)IXGBE_READ_REG(hw, IXGBE_RXSTMPL);
582 regval |= (u64)IXGBE_READ_REG(hw, IXGBE_RXSTMPH) << 32; 560 regval |= (u64)IXGBE_READ_REG(hw, IXGBE_RXSTMPH) << 32;
583 561
584 /*
585 * If the timestamp bit is set in the packet's descriptor, we know the
586 * timestamp belongs to this packet. No other packet can be
587 * timestamped until the registers for timestamping have been read.
588 * Therefor only one packet with this bit can be in the queue at a
589 * time, and the rx timestamp values that were in the registers belong
590 * to this packet.
591 *
592 * If nothing went wrong, then it should have a skb_shared_tx that we
593 * can turn into a skb_shared_hwtstamps.
594 */
595 if (unlikely(!ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_STAT_TS)))
596 return;
597 562
598 spin_lock_irqsave(&adapter->tmreg_lock, flags); 563 spin_lock_irqsave(&adapter->tmreg_lock, flags);
599 ns = timecounter_cyc2time(&adapter->tc, regval); 564 ns = timecounter_cyc2time(&adapter->tc, regval);
@@ -698,9 +663,6 @@ int ixgbe_ptp_hwtstamp_ioctl(struct ixgbe_adapter *adapter,
698 return 0; 663 return 0;
699 } 664 }
700 665
701 /* Store filter value for later use */
702 adapter->rx_hwtstamp_filter = config.rx_filter;
703
704 /* define ethertype filter for timestamping L2 packets */ 666 /* define ethertype filter for timestamping L2 packets */
705 if (is_l2) 667 if (is_l2)
706 IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_1588), 668 IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_1588),
@@ -902,10 +864,6 @@ void ixgbe_ptp_init(struct ixgbe_adapter *adapter)
902 return; 864 return;
903 } 865 }
904 866
905 /* initialize the ptp filter */
906 if (ptp_filter_init(ptp_filter, ARRAY_SIZE(ptp_filter)))
907 e_dev_warn("ptp_filter_init failed\n");
908
909 spin_lock_init(&adapter->tmreg_lock); 867 spin_lock_init(&adapter->tmreg_lock);
910 868
911 adapter->ptp_clock = ptp_clock_register(&adapter->ptp_caps, 869 adapter->ptp_clock = ptp_clock_register(&adapter->ptp_caps,