FreeBSD/sys/dev/e1000/if_em.c
/*
** em_flush_desc_rings - remove all descriptors from the descriptor rings
**
** In i219, the descriptor rings must be emptied before resetting the HW
** or before changing the device state to D3 during runtime (runtime PM).
**
** Failure to do this will cause the HW to enter a unit hang state which can
** only be released by PCI reset on the device
**
*/
remove all descriptors from the descriptor rings
In i219, the descriptor rings must be emptied before resetting the HW
or before changing the device state to D3 during runtime (runtime PM).

Failure to do this will cause the HW to enter a unit hang state which can
only be released by PCI reset on the device
remove all descriptors from the descriptor rings In i219 the descriptor rings must be emptied before resetting the HW or before changing the device state to D3 during runtime ( runtime PM ) . Failure to do this will cause the HW to enter a unit hang state which can only be released by PCI reset on the device
static void
em_flush_desc_rings(struct adapter *adapter)
{
	struct e1000_hw	*hw = &adapter->hw;
	device_t	dev = adapter->dev;
	u16		hang_state;
	u32		fext_nvm11, tdlen;
	fext_nvm11 = E1000_READ_REG(hw, E1000_FEXTNVM11);
	fext_nvm11 |= E1000_FEXTNVM11_DISABLE_MULR_FIX;
	E1000_WRITE_REG(hw, E1000_FEXTNVM11, fext_nvm11);
	tdlen = E1000_READ_REG(hw, E1000_TDLEN(0));
	hang_state = pci_read_config(dev, PCICFG_DESC_RING_STATUS, 2);
	if (!(hang_state & FLUSH_DESC_REQUIRED) || !tdlen)
		return;
	em_flush_tx_ring(adapter);
	hang_state = pci_read_config(dev, PCICFG_DESC_RING_STATUS, 2);
	if (hang_state & FLUSH_DESC_REQUIRED)
		em_flush_rx_ring(adapter);
}
static void em_flush_desc_rings ( struct adapter * adapter ) { struct e1000_hw * hw = & adapter -> hw ; device_t dev = adapter -> dev ; u16 hang_state ; u32 fext_nvm11 , tdlen ; fext_nvm11 = E1000_READ_REG ( hw , E1000_FEXTNVM11 ) ; fext_nvm11 |= E1000_FEXTNVM11_DISABLE_MULR_FIX ; E1000_WRITE_REG ( hw , E1000_FEXTNVM11 , fext_nvm11 ) ; tdlen = E1000_READ_REG ( hw , E1000_TDLEN ( 0 ) ) ; hang_state = pci_read_config ( dev , PCICFG_DESC_RING_STATUS , 2 ) ; if ( ! ( hang_state & FLUSH_DESC_REQUIRED ) || ! tdlen ) return ; em_flush_tx_ring ( adapter ) ; hang_state = pci_read_config ( dev , PCICFG_DESC_RING_STATUS , 2 ) ; if ( hang_state & FLUSH_DESC_REQUIRED ) em_flush_rx_ring ( adapter ) ; }
em_flush_desc_rings - remove all descriptors from the descriptor rings
In i219, the descriptor rings must be emptied before resetting the HW
or before changing the device state to D3 during runtime (runtime PM).
em_flush_desc_rings - remove all descriptors from the descriptor rings In i219 the descriptor rings must be emptied before resetting the HW or before changing the device state to D3 during runtime ( runtime PM ) .
/* First, disable MULR fix in FEXTNVM11 */ /* do nothing if we're not in faulty state, or if the queue is empty */ /* recheck, maybe the fault is caused by the rx ring */