Wed May 30 08:35:27 2018 UTC ()
 Clear que->disabled_count in {ixgbe,ixv}_init_locked(). Without this,
interrupt mask state and EIMS may mismatch and if_init doesn't recover
from TX/RX stall problem.

 This change itself doesn't fix PR#53294.


(msaitoh)
diff -r1.156 -r1.157 src/sys/dev/pci/ixgbe/ixgbe.c
diff -r1.101 -r1.102 src/sys/dev/pci/ixgbe/ixv.c

cvs diff -r1.156 -r1.157 src/sys/dev/pci/ixgbe/ixgbe.c (expand / switch to unified diff)

--- src/sys/dev/pci/ixgbe/ixgbe.c 2018/05/25 04:40:27 1.156
+++ src/sys/dev/pci/ixgbe/ixgbe.c 2018/05/30 08:35:26 1.157
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ixgbe.c,v 1.156 2018/05/25 04:40:27 ozaki-r Exp $ */ 1/* $NetBSD: ixgbe.c,v 1.157 2018/05/30 08:35:26 msaitoh Exp $ */
2 2
3/****************************************************************************** 3/******************************************************************************
4 4
5 Copyright (c) 2001-2017, Intel Corporation 5 Copyright (c) 2001-2017, Intel Corporation
6 All rights reserved. 6 All rights reserved.
7 7
8 Redistribution and use in source and binary forms, with or without 8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met: 9 modification, are permitted provided that the following conditions are met:
10 10
11 1. Redistributions of source code must retain the above copyright notice, 11 1. Redistributions of source code must retain the above copyright notice,
12 this list of conditions and the following disclaimer. 12 this list of conditions and the following disclaimer.
13 13
14 2. Redistributions in binary form must reproduce the above copyright 14 2. Redistributions in binary form must reproduce the above copyright
@@ -3784,41 +3784,44 @@ ixgbe_set_if_hwassist(struct adapter *ad @@ -3784,41 +3784,44 @@ ixgbe_set_if_hwassist(struct adapter *ad
3784 * Used in two ways: It is used by the stack as an init 3784 * Used in two ways: It is used by the stack as an init
3785 * entry point in network interface structure. It is also 3785 * entry point in network interface structure. It is also
3786 * used by the driver as a hw/sw initialization routine to 3786 * used by the driver as a hw/sw initialization routine to
3787 * get to a consistent state. 3787 * get to a consistent state.
3788 * 3788 *
3789 * return 0 on success, positive on failure 3789 * return 0 on success, positive on failure
3790 ************************************************************************/ 3790 ************************************************************************/
3791static void 3791static void
3792ixgbe_init_locked(struct adapter *adapter) 3792ixgbe_init_locked(struct adapter *adapter)
3793{ 3793{
3794 struct ifnet *ifp = adapter->ifp; 3794 struct ifnet *ifp = adapter->ifp;
3795 device_t dev = adapter->dev; 3795 device_t dev = adapter->dev;
3796 struct ixgbe_hw *hw = &adapter->hw; 3796 struct ixgbe_hw *hw = &adapter->hw;
 3797 struct ix_queue *que;
3797 struct tx_ring *txr; 3798 struct tx_ring *txr;
3798 struct rx_ring *rxr; 3799 struct rx_ring *rxr;
3799 u32 txdctl, mhadd; 3800 u32 txdctl, mhadd;
3800 u32 rxdctl, rxctrl; 3801 u32 rxdctl, rxctrl;
3801 u32 ctrl_ext; 3802 u32 ctrl_ext;
3802 int i, j, err; 3803 int i, j, err;
3803 3804
3804 /* XXX check IFF_UP and IFF_RUNNING, power-saving state! */ 3805 /* XXX check IFF_UP and IFF_RUNNING, power-saving state! */
3805 3806
3806 KASSERT(mutex_owned(&adapter->core_mtx)); 3807 KASSERT(mutex_owned(&adapter->core_mtx));
3807 INIT_DEBUGOUT("ixgbe_init_locked: begin"); 3808 INIT_DEBUGOUT("ixgbe_init_locked: begin");
3808 3809
3809 hw->adapter_stopped = FALSE; 3810 hw->adapter_stopped = FALSE;
3810 ixgbe_stop_adapter(hw); 3811 ixgbe_stop_adapter(hw);
3811 callout_stop(&adapter->timer); 3812 callout_stop(&adapter->timer);
 3813 for (i = 0, que = adapter->queues; i < adapter->num_queues; i++, que++)
 3814 que->disabled_count = 0;
3812 3815
3813 /* XXX I moved this here from the SIOCSIFMTU case in ixgbe_ioctl(). */ 3816 /* XXX I moved this here from the SIOCSIFMTU case in ixgbe_ioctl(). */
3814 adapter->max_frame_size = 3817 adapter->max_frame_size =
3815 ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN; 3818 ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
3816 3819
3817 /* Queue indices may change with IOV mode */ 3820 /* Queue indices may change with IOV mode */
3818 ixgbe_align_all_queue_indices(adapter); 3821 ixgbe_align_all_queue_indices(adapter);
3819 3822
3820 /* reprogram the RAR[0] in case user changed it. */ 3823 /* reprogram the RAR[0] in case user changed it. */
3821 ixgbe_set_rar(hw, 0, hw->mac.addr, adapter->pool, IXGBE_RAH_AV); 3824 ixgbe_set_rar(hw, 0, hw->mac.addr, adapter->pool, IXGBE_RAH_AV);
3822 3825
3823 /* Get the latest mac address, User can use a LAA */ 3826 /* Get the latest mac address, User can use a LAA */
3824 memcpy(hw->mac.addr, CLLADDR(ifp->if_sadl), 3827 memcpy(hw->mac.addr, CLLADDR(ifp->if_sadl),

cvs diff -r1.101 -r1.102 src/sys/dev/pci/ixgbe/ixv.c (expand / switch to unified diff)

--- src/sys/dev/pci/ixgbe/ixv.c 2018/05/25 04:40:27 1.101
+++ src/sys/dev/pci/ixgbe/ixv.c 2018/05/30 08:35:26 1.102
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/*$NetBSD: ixv.c,v 1.101 2018/05/25 04:40:27 ozaki-r Exp $*/ 1/*$NetBSD: ixv.c,v 1.102 2018/05/30 08:35:26 msaitoh Exp $*/
2 2
3/****************************************************************************** 3/******************************************************************************
4 4
5 Copyright (c) 2001-2017, Intel Corporation 5 Copyright (c) 2001-2017, Intel Corporation
6 All rights reserved. 6 All rights reserved.
7 7
8 Redistribution and use in source and binary forms, with or without 8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met: 9 modification, are permitted provided that the following conditions are met:
10 10
11 1. Redistributions of source code must retain the above copyright notice, 11 1. Redistributions of source code must retain the above copyright notice,
12 this list of conditions and the following disclaimer. 12 this list of conditions and the following disclaimer.
13 13
14 2. Redistributions in binary form must reproduce the above copyright 14 2. Redistributions in binary form must reproduce the above copyright
@@ -709,36 +709,38 @@ ixv_detach(device_t dev, int flags) @@ -709,36 +709,38 @@ ixv_detach(device_t dev, int flags)
709 * Used in two ways: It is used by the stack as an init entry 709 * Used in two ways: It is used by the stack as an init entry
710 * point in network interface structure. It is also used 710 * point in network interface structure. It is also used
711 * by the driver as a hw/sw initialization routine to get 711 * by the driver as a hw/sw initialization routine to get
712 * to a consistent state. 712 * to a consistent state.
713 * 713 *
714 * return 0 on success, positive on failure 714 * return 0 on success, positive on failure
715 ************************************************************************/ 715 ************************************************************************/
716static void 716static void
717ixv_init_locked(struct adapter *adapter) 717ixv_init_locked(struct adapter *adapter)
718{ 718{
719 struct ifnet *ifp = adapter->ifp; 719 struct ifnet *ifp = adapter->ifp;
720 device_t dev = adapter->dev; 720 device_t dev = adapter->dev;
721 struct ixgbe_hw *hw = &adapter->hw; 721 struct ixgbe_hw *hw = &adapter->hw;
722 struct ix_queue *que = adapter->queues; 722 struct ix_queue *que;
723 int error = 0; 723 int error = 0;
724 uint32_t mask; 724 uint32_t mask;
725 int i; 725 int i;
726 726
727 INIT_DEBUGOUT("ixv_init_locked: begin"); 727 INIT_DEBUGOUT("ixv_init_locked: begin");
728 KASSERT(mutex_owned(&adapter->core_mtx)); 728 KASSERT(mutex_owned(&adapter->core_mtx));
729 hw->adapter_stopped = FALSE; 729 hw->adapter_stopped = FALSE;
730 hw->mac.ops.stop_adapter(hw); 730 hw->mac.ops.stop_adapter(hw);
731 callout_stop(&adapter->timer); 731 callout_stop(&adapter->timer);
 732 for (i = 0, que = adapter->queues; i < adapter->num_queues; i++, que++)
 733 que->disabled_count = 0;
732 734
733 /* reprogram the RAR[0] in case user changed it. */ 735 /* reprogram the RAR[0] in case user changed it. */
734 hw->mac.ops.set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV); 736 hw->mac.ops.set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
735 737
736 /* Get the latest mac address, User can use a LAA */ 738 /* Get the latest mac address, User can use a LAA */
737 memcpy(hw->mac.addr, CLLADDR(ifp->if_sadl), 739 memcpy(hw->mac.addr, CLLADDR(ifp->if_sadl),
738 IXGBE_ETH_LENGTH_OF_ADDRESS); 740 IXGBE_ETH_LENGTH_OF_ADDRESS);
739 hw->mac.ops.set_rar(hw, 0, hw->mac.addr, 0, 1); 741 hw->mac.ops.set_rar(hw, 0, hw->mac.addr, 0, 1);
740 742
741 /* Prepare transmit descriptors and buffers */ 743 /* Prepare transmit descriptors and buffers */
742 if (ixgbe_setup_transmit_structures(adapter)) { 744 if (ixgbe_setup_transmit_structures(adapter)) {
743 aprint_error_dev(dev, "Could not setup transmit structures\n"); 745 aprint_error_dev(dev, "Could not setup transmit structures\n");
744 ixv_stop(adapter); 746 ixv_stop(adapter);
@@ -788,27 +790,27 @@ ixv_init_locked(struct adapter *adapter) @@ -788,27 +790,27 @@ ixv_init_locked(struct adapter *adapter)
788 ifp->if_hwassist |= CSUM_SCTP; 790 ifp->if_hwassist |= CSUM_SCTP;
789#endif 791#endif
790 } 792 }
791#endif 793#endif
792  794
793 /* Set up VLAN offload and filter */ 795 /* Set up VLAN offload and filter */
794 ixv_setup_vlan_support(adapter); 796 ixv_setup_vlan_support(adapter);
795 797
796 /* Set up MSI-X routing */ 798 /* Set up MSI-X routing */
797 ixv_configure_ivars(adapter); 799 ixv_configure_ivars(adapter);
798 800
799 /* Set up auto-mask */ 801 /* Set up auto-mask */
800 mask = (1 << adapter->vector); 802 mask = (1 << adapter->vector);
801 for (i = 0; i < adapter->num_queues; i++, que++) 803 for (i = 0, que = adapter->queues; i < adapter->num_queues; i++, que++)
802 mask |= (1 << que->msix); 804 mask |= (1 << que->msix);
803 IXGBE_WRITE_REG(hw, IXGBE_VTEIAM, mask); 805 IXGBE_WRITE_REG(hw, IXGBE_VTEIAM, mask);
804 806
805 /* Set moderation on the Link interrupt */ 807 /* Set moderation on the Link interrupt */
806 ixv_eitr_write(adapter, adapter->vector, IXGBE_LINK_ITR); 808 ixv_eitr_write(adapter, adapter->vector, IXGBE_LINK_ITR);
807 809
808 /* Stats init */ 810 /* Stats init */
809 ixv_init_stats(adapter); 811 ixv_init_stats(adapter);
810 812
811 /* Config/Enable Link */ 813 /* Config/Enable Link */
812 hw->mac.get_link_status = TRUE; 814 hw->mac.get_link_status = TRUE;
813 hw->mac.ops.check_link(hw, &adapter->link_speed, &adapter->link_up, 815 hw->mac.ops.check_link(hw, &adapter->link_speed, &adapter->link_up,
814 FALSE); 816 FALSE);