@@ -2659,18 +2659,8 @@ static int hns3_nic_change_mtu(struct net_device *netdev, int new_mtu)
2659
2659
return ret ;
2660
2660
}
2661
2661
2662
- static bool hns3_get_tx_timeo_queue_info (struct net_device * ndev )
2662
+ static int hns3_get_timeout_queue (struct net_device * ndev )
2663
2663
{
2664
- struct hns3_nic_priv * priv = netdev_priv (ndev );
2665
- struct hnae3_handle * h = hns3_get_handle (ndev );
2666
- struct hns3_enet_ring * tx_ring ;
2667
- struct napi_struct * napi ;
2668
- int timeout_queue = 0 ;
2669
- int hw_head , hw_tail ;
2670
- int fbd_num , fbd_oft ;
2671
- int ebd_num , ebd_oft ;
2672
- int bd_num , bd_err ;
2673
- int ring_en , tc ;
2674
2664
int i ;
2675
2665
2676
2666
/* Find the stopped queue the same way the stack does */
@@ -2690,25 +2680,22 @@ static bool hns3_get_tx_timeo_queue_info(struct net_device *ndev)
2690
2680
dql -> last_obj_cnt , dql -> num_queued ,
2691
2681
dql -> adj_limit , dql -> num_completed );
2692
2682
#endif
2693
- timeout_queue = i ;
2694
2683
netdev_info (ndev , "queue state: 0x%lx, delta msecs: %u\n" ,
2695
2684
q -> state ,
2696
2685
jiffies_to_msecs (jiffies - trans_start ));
2697
2686
break ;
2698
2687
}
2699
2688
}
2700
2689
2701
- if (i == ndev -> num_tx_queues ) {
2702
- netdev_info (ndev ,
2703
- "no netdev TX timeout queue found, timeout count: %llu\n" ,
2704
- priv -> tx_timeout_count );
2705
- return false;
2706
- }
2707
-
2708
- priv -> tx_timeout_count ++ ;
2690
+ return i ;
2691
+ }
2709
2692
2710
- tx_ring = & priv -> ring [timeout_queue ];
2711
- napi = & tx_ring -> tqp_vector -> napi ;
2693
+ static void hns3_dump_queue_stats (struct net_device * ndev ,
2694
+ struct hns3_enet_ring * tx_ring ,
2695
+ int timeout_queue )
2696
+ {
2697
+ struct napi_struct * napi = & tx_ring -> tqp_vector -> napi ;
2698
+ struct hns3_nic_priv * priv = netdev_priv (ndev );
2712
2699
2713
2700
netdev_info (ndev ,
2714
2701
"tx_timeout count: %llu, queue id: %d, SW_NTU: 0x%x, SW_NTC: 0x%x, napi state: %lu\n" ,
@@ -2724,6 +2711,48 @@ static bool hns3_get_tx_timeo_queue_info(struct net_device *ndev)
2724
2711
"seg_pkt_cnt: %llu, tx_more: %llu, restart_queue: %llu, tx_busy: %llu\n" ,
2725
2712
tx_ring -> stats .seg_pkt_cnt , tx_ring -> stats .tx_more ,
2726
2713
tx_ring -> stats .restart_queue , tx_ring -> stats .tx_busy );
2714
+ }
2715
+
2716
+ static void hns3_dump_queue_reg (struct net_device * ndev ,
2717
+ struct hns3_enet_ring * tx_ring )
2718
+ {
2719
+ netdev_info (ndev ,
2720
+ "BD_NUM: 0x%x HW_HEAD: 0x%x, HW_TAIL: 0x%x, BD_ERR: 0x%x, INT: 0x%x\n" ,
2721
+ hns3_tqp_read_reg (tx_ring , HNS3_RING_TX_RING_BD_NUM_REG ),
2722
+ hns3_tqp_read_reg (tx_ring , HNS3_RING_TX_RING_HEAD_REG ),
2723
+ hns3_tqp_read_reg (tx_ring , HNS3_RING_TX_RING_TAIL_REG ),
2724
+ hns3_tqp_read_reg (tx_ring , HNS3_RING_TX_RING_BD_ERR_REG ),
2725
+ readl (tx_ring -> tqp_vector -> mask_addr ));
2726
+ netdev_info (ndev ,
2727
+ "RING_EN: 0x%x, TC: 0x%x, FBD_NUM: 0x%x FBD_OFT: 0x%x, EBD_NUM: 0x%x, EBD_OFT: 0x%x\n" ,
2728
+ hns3_tqp_read_reg (tx_ring , HNS3_RING_EN_REG ),
2729
+ hns3_tqp_read_reg (tx_ring , HNS3_RING_TX_RING_TC_REG ),
2730
+ hns3_tqp_read_reg (tx_ring , HNS3_RING_TX_RING_FBDNUM_REG ),
2731
+ hns3_tqp_read_reg (tx_ring , HNS3_RING_TX_RING_OFFSET_REG ),
2732
+ hns3_tqp_read_reg (tx_ring , HNS3_RING_TX_RING_EBDNUM_REG ),
2733
+ hns3_tqp_read_reg (tx_ring ,
2734
+ HNS3_RING_TX_RING_EBD_OFFSET_REG ));
2735
+ }
2736
+
2737
+ static bool hns3_get_tx_timeo_queue_info (struct net_device * ndev )
2738
+ {
2739
+ struct hns3_nic_priv * priv = netdev_priv (ndev );
2740
+ struct hnae3_handle * h = hns3_get_handle (ndev );
2741
+ struct hns3_enet_ring * tx_ring ;
2742
+ int timeout_queue ;
2743
+
2744
+ timeout_queue = hns3_get_timeout_queue (ndev );
2745
+ if (timeout_queue >= ndev -> num_tx_queues ) {
2746
+ netdev_info (ndev ,
2747
+ "no netdev TX timeout queue found, timeout count: %llu\n" ,
2748
+ priv -> tx_timeout_count );
2749
+ return false;
2750
+ }
2751
+
2752
+ priv -> tx_timeout_count ++ ;
2753
+
2754
+ tx_ring = & priv -> ring [timeout_queue ];
2755
+ hns3_dump_queue_stats (ndev , tx_ring , timeout_queue );
2727
2756
2728
2757
/* When mac received many pause frames continuous, it's unable to send
2729
2758
* packets, which may cause tx timeout
@@ -2736,32 +2765,7 @@ static bool hns3_get_tx_timeo_queue_info(struct net_device *ndev)
2736
2765
mac_stats .tx_pause_cnt , mac_stats .rx_pause_cnt );
2737
2766
}
2738
2767
2739
- hw_head = readl_relaxed (tx_ring -> tqp -> io_base +
2740
- HNS3_RING_TX_RING_HEAD_REG );
2741
- hw_tail = readl_relaxed (tx_ring -> tqp -> io_base +
2742
- HNS3_RING_TX_RING_TAIL_REG );
2743
- fbd_num = readl_relaxed (tx_ring -> tqp -> io_base +
2744
- HNS3_RING_TX_RING_FBDNUM_REG );
2745
- fbd_oft = readl_relaxed (tx_ring -> tqp -> io_base +
2746
- HNS3_RING_TX_RING_OFFSET_REG );
2747
- ebd_num = readl_relaxed (tx_ring -> tqp -> io_base +
2748
- HNS3_RING_TX_RING_EBDNUM_REG );
2749
- ebd_oft = readl_relaxed (tx_ring -> tqp -> io_base +
2750
- HNS3_RING_TX_RING_EBD_OFFSET_REG );
2751
- bd_num = readl_relaxed (tx_ring -> tqp -> io_base +
2752
- HNS3_RING_TX_RING_BD_NUM_REG );
2753
- bd_err = readl_relaxed (tx_ring -> tqp -> io_base +
2754
- HNS3_RING_TX_RING_BD_ERR_REG );
2755
- ring_en = readl_relaxed (tx_ring -> tqp -> io_base + HNS3_RING_EN_REG );
2756
- tc = readl_relaxed (tx_ring -> tqp -> io_base + HNS3_RING_TX_RING_TC_REG );
2757
-
2758
- netdev_info (ndev ,
2759
- "BD_NUM: 0x%x HW_HEAD: 0x%x, HW_TAIL: 0x%x, BD_ERR: 0x%x, INT: 0x%x\n" ,
2760
- bd_num , hw_head , hw_tail , bd_err ,
2761
- readl (tx_ring -> tqp_vector -> mask_addr ));
2762
- netdev_info (ndev ,
2763
- "RING_EN: 0x%x, TC: 0x%x, FBD_NUM: 0x%x FBD_OFT: 0x%x, EBD_NUM: 0x%x, EBD_OFT: 0x%x\n" ,
2764
- ring_en , tc , fbd_num , fbd_oft , ebd_num , ebd_oft );
2768
+ hns3_dump_queue_reg (ndev , tx_ring );
2765
2769
2766
2770
return true;
2767
2771
}
0 commit comments