FreeBSD/sys/dev/nxge/xgehal/xgehal-device.c
/*
 * __hal_device_handle_link_down_ind
 * @hldev: HAL device handle.
 *
 * Link down indication handler. The function is invoked by HAL when
 * Xframe indicates that the link is down.
 */
hal_device_handle_link_down_ind
@hldev: HAL device handle.

Link down indication handler. The function is invoked by HAL when
Xframe indicates that the link is down.
hal_device_handle_link_down_ind @hldev : HAL device handle . Link down indication handler . The function is invoked by HAL when Xframe indicates that the link is down .
static int
__hal_device_handle_link_down_ind(xge_hal_device_t *hldev)
{
	xge_hal_pci_bar0_t *bar0 = (xge_hal_pci_bar0_t *)(void *)hldev->bar0;
	u64 val64;
	if (hldev->link_state == XGE_HAL_LINK_DOWN) {
#ifdef  XGE_HAL_PROCESS_LINK_INT_IN_ISR
	    if (xge_hal_device_check_id(hldev) == XGE_HAL_CARD_HERC){
	        val64 = xge_os_pio_mem_read64(
	            hldev->pdev, hldev->regh0,
	            &bar0->misc_int_mask);
	        val64 |= XGE_HAL_MISC_INT_REG_LINK_DOWN_INT;
	        val64 &= ~XGE_HAL_MISC_INT_REG_LINK_UP_INT;
	        xge_os_pio_mem_write64(hldev->pdev, hldev->regh0,
	            val64, &bar0->misc_int_mask);
	    }
#endif
	    xge_debug_device(XGE_TRACE,
	        "link down indication while link is down, ignoring..");
	    return 0;
	}
	xge_os_mdelay(1);
	val64 = xge_os_pio_mem_read64(hldev->pdev, hldev->regh0,
	                  &bar0->adapter_control);
	if (val64 & XGE_HAL_ADAPTER_CNTL_EN) {
	    if (__hal_device_register_poll(hldev, &bar0->adapter_status, 0,
	        (XGE_HAL_ADAPTER_STATUS_RMAC_REMOTE_FAULT |
	        XGE_HAL_ADAPTER_STATUS_RMAC_LOCAL_FAULT),
	        XGE_HAL_DEVICE_FAULT_WAIT_MAX_MILLIS) == XGE_HAL_OK) {
	        xge_debug_device(XGE_TRACE,
	            "link is actually up (possible noisy link?), ignoring.");
	        return(0);
	    }
	}
	val64 = xge_os_pio_mem_read64(hldev->pdev, hldev->regh0,
	                &bar0->adapter_control);
	val64 = val64 & (~XGE_HAL_ADAPTER_LED_ON);
	xge_os_pio_mem_write64(hldev->pdev, hldev->regh0, val64,
	               &bar0->adapter_control);
#ifdef  XGE_HAL_PROCESS_LINK_INT_IN_ISR
	if (xge_hal_device_check_id(hldev) == XGE_HAL_CARD_HERC) {
	    val64 = xge_os_pio_mem_read64(hldev->pdev, hldev->regh0,
	                      &bar0->misc_int_mask);
	    val64 |= XGE_HAL_MISC_INT_REG_LINK_DOWN_INT;
	    val64 &= ~XGE_HAL_MISC_INT_REG_LINK_UP_INT;
	    xge_os_pio_mem_write64(hldev->pdev, hldev->regh0, val64,
	                   &bar0->misc_int_mask);
	    xge_debug_device(XGE_TRACE, "calling link down..");
	    hldev->link_state = XGE_HAL_LINK_DOWN;
	    if (g_xge_hal_driver->uld_callbacks.link_down) {
	            g_xge_hal_driver->uld_callbacks.link_down(
	                hldev->upper_layer_info);
	    }
	    return 1;
	}
#endif
	(void) xge_queue_produce_context(hldev->queueh,
	                 XGE_HAL_EVENT_LINK_IS_DOWN,
	                 hldev);
	return 1;
}
static int __hal_device_handle_link_down_ind ( xge_hal_device_t * hldev ) { xge_hal_pci_bar0_t * bar0 = ( xge_hal_pci_bar0_t * ) ( void * ) hldev -> bar0 ; u64 val64 ; if ( hldev -> link_state == XGE_HAL_LINK_DOWN ) { #ifdef XGE_HAL_PROCESS_LINK_INT_IN_ISR if ( xge_hal_device_check_id ( hldev ) == XGE_HAL_CARD_HERC ) { val64 = xge_os_pio_mem_read64 ( hldev -> pdev , hldev -> regh0 , & bar0 -> misc_int_mask ) ; val64 |= XGE_HAL_MISC_INT_REG_LINK_DOWN_INT ; val64 &= ~ XGE_HAL_MISC_INT_REG_LINK_UP_INT ; xge_os_pio_mem_write64 ( hldev -> pdev , hldev -> regh0 , val64 , & bar0 -> misc_int_mask ) ; } #endif xge_debug_device ( XGE_TRACE , " " ) ; return 0 ; } xge_os_mdelay ( 1 ) ; val64 = xge_os_pio_mem_read64 ( hldev -> pdev , hldev -> regh0 , & bar0 -> adapter_control ) ; if ( val64 & XGE_HAL_ADAPTER_CNTL_EN ) { if ( __hal_device_register_poll ( hldev , & bar0 -> adapter_status , 0 , ( XGE_HAL_ADAPTER_STATUS_RMAC_REMOTE_FAULT | XGE_HAL_ADAPTER_STATUS_RMAC_LOCAL_FAULT ) , XGE_HAL_DEVICE_FAULT_WAIT_MAX_MILLIS ) == XGE_HAL_OK ) { xge_debug_device ( XGE_TRACE , " " ) ; return ( 0 ) ; } } val64 = xge_os_pio_mem_read64 ( hldev -> pdev , hldev -> regh0 , & bar0 -> adapter_control ) ; val64 = val64 & ( ~ XGE_HAL_ADAPTER_LED_ON ) ; xge_os_pio_mem_write64 ( hldev -> pdev , hldev -> regh0 , val64 , & bar0 -> adapter_control ) ; #ifdef XGE_HAL_PROCESS_LINK_INT_IN_ISR if ( xge_hal_device_check_id ( hldev ) == XGE_HAL_CARD_HERC ) { val64 = xge_os_pio_mem_read64 ( hldev -> pdev , hldev -> regh0 , & bar0 -> misc_int_mask ) ; val64 |= XGE_HAL_MISC_INT_REG_LINK_DOWN_INT ; val64 &= ~ XGE_HAL_MISC_INT_REG_LINK_UP_INT ; xge_os_pio_mem_write64 ( hldev -> pdev , hldev -> regh0 , val64 , & bar0 -> misc_int_mask ) ; xge_debug_device ( XGE_TRACE , " " ) ; hldev -> link_state = XGE_HAL_LINK_DOWN ; if ( g_xge_hal_driver -> uld_callbacks . link_down ) { g_xge_hal_driver -> uld_callbacks . link_down ( hldev -> upper_layer_info ) ; } return 1 ; } #endif ( void ) xge_queue_produce_context ( hldev -> queueh , XGE_HAL_EVENT_LINK_IS_DOWN , hldev ) ; return 1 ; }
__hal_device_handle_link_down_ind
 @hldev: HAL device handle.
__hal_device_handle_link_down_ind @hldev : HAL device handle .
/*
	 * If the previous link state is not up, return.
	 */ /* try to debounce the link only if the adapter is enabled. */ /* turn off LED */ /*
	     * Mask the Link Down interrupt and unmask the Link up
	     * interrupt
	     */ /* link is down */ /* notify ULD */ /* notify ULD */ /* link is down */