FreeBSD/sys/dev/nxge/xgehal/xgehal-device.c
/*
 * __hal_device_handle_link_up_ind
 * @hldev: HAL device handle.
 *
 * Link up indication handler. The function is invoked by HAL when
 * Xframe indicates that the link is up for programmable amount of time.
 */
hal_device_handle_link_up_ind
@hldev: HAL device handle.

Link up indication handler. The function is invoked by HAL when
Xframe indicates that the link is up for programmable amount of time.
hal_device_handle_link_up_ind @hldev : HAL device handle . Link up indication handler . The function is invoked by HAL when Xframe indicates that the link is up for programmable amount of time .
static int
__hal_device_handle_link_up_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_UP) {
#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_UP_INT;
	        val64 &= ~XGE_HAL_MISC_INT_REG_LINK_DOWN_INT;
	        xge_os_pio_mem_write64(hldev->pdev, hldev->regh0,
	            val64, &bar0->misc_int_mask);
	    }
#endif
	    xge_debug_device(XGE_TRACE,
	        "link up indication while link is up, ignoring..");
	    return 0;
	}
	val64 = xge_os_pio_mem_read64(hldev->pdev, hldev->regh0,
	                 &bar0->adapter_control);
	val64 |= XGE_HAL_ADAPTER_CNTL_EN;
	val64 = val64 & (~XGE_HAL_ADAPTER_ECC_EN); 
	xge_os_pio_mem_write64(hldev->pdev, hldev->regh0, val64,
	             &bar0->adapter_control);
	val64 = xge_os_pio_mem_read64(hldev->pdev, hldev->regh0,
	                &bar0->adapter_control);
	val64 = val64|(XGE_HAL_ADAPTER_EOI_TX_ON |
	        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->adapter_status);
	        if (val64 & (XGE_HAL_ADAPTER_STATUS_RMAC_REMOTE_FAULT |
	                 XGE_HAL_ADAPTER_STATUS_RMAC_LOCAL_FAULT)) {
	            xge_debug_device(XGE_TRACE, "%s",
	                      "fail to transition link to up...");
	        return 0;
	        }
	        else {
	            val64 = xge_os_pio_mem_read64(hldev->pdev, hldev->regh0,
	                              &bar0->misc_int_mask);
	            val64 |= XGE_HAL_MISC_INT_REG_LINK_UP_INT;
	            val64 &= ~XGE_HAL_MISC_INT_REG_LINK_DOWN_INT;
	            xge_os_pio_mem_write64(hldev->pdev, hldev->regh0, val64,
	                           &bar0->misc_int_mask);
	            xge_debug_device(XGE_TRACE, "calling link up..");
	            hldev->link_state = XGE_HAL_LINK_UP;
	            if (g_xge_hal_driver->uld_callbacks.link_up) {
	                g_xge_hal_driver->uld_callbacks.link_up(
	                        hldev->upper_layer_info);
	            }
	        return 1;
	        }
	    }
#endif
	xge_os_mdelay(1);
	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) {
	    (void) xge_queue_produce_context(hldev->queueh,
	                     XGE_HAL_EVENT_LINK_IS_UP,
	                     hldev);
	    return 1;
	} else {
	    xge_debug_device(XGE_TRACE, "%s",
	              "fail to transition link to up...");
	    return 0;
	}
}
static int __hal_device_handle_link_up_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_UP ) { #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_UP_INT ; val64 &= ~ XGE_HAL_MISC_INT_REG_LINK_DOWN_INT ; xge_os_pio_mem_write64 ( hldev -> pdev , hldev -> regh0 , val64 , & bar0 -> misc_int_mask ) ; } #endif xge_debug_device ( XGE_TRACE , " " ) ; return 0 ; } val64 = xge_os_pio_mem_read64 ( hldev -> pdev , hldev -> regh0 , & bar0 -> adapter_control ) ; val64 |= XGE_HAL_ADAPTER_CNTL_EN ; val64 = val64 & ( ~ XGE_HAL_ADAPTER_ECC_EN ) ; xge_os_pio_mem_write64 ( hldev -> pdev , hldev -> regh0 , val64 , & bar0 -> adapter_control ) ; val64 = xge_os_pio_mem_read64 ( hldev -> pdev , hldev -> regh0 , & bar0 -> adapter_control ) ; val64 = val64 | ( XGE_HAL_ADAPTER_EOI_TX_ON | 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 -> adapter_status ) ; if ( val64 & ( XGE_HAL_ADAPTER_STATUS_RMAC_REMOTE_FAULT | XGE_HAL_ADAPTER_STATUS_RMAC_LOCAL_FAULT ) ) { xge_debug_device ( XGE_TRACE , " " , " " ) ; return 0 ; } else { val64 = xge_os_pio_mem_read64 ( hldev -> pdev , hldev -> regh0 , & bar0 -> misc_int_mask ) ; val64 |= XGE_HAL_MISC_INT_REG_LINK_UP_INT ; val64 &= ~ XGE_HAL_MISC_INT_REG_LINK_DOWN_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_UP ; if ( g_xge_hal_driver -> uld_callbacks . link_up ) { g_xge_hal_driver -> uld_callbacks . link_up ( hldev -> upper_layer_info ) ; } return 1 ; } } #endif xge_os_mdelay ( 1 ) ; 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 ) { ( void ) xge_queue_produce_context ( hldev -> queueh , XGE_HAL_EVENT_LINK_IS_UP , hldev ) ; return 1 ; } else { xge_debug_device ( XGE_TRACE , " " , " " ) ; return 0 ; } }
__hal_device_handle_link_up_ind
 @hldev: HAL device handle.
__hal_device_handle_link_up_ind @hldev : HAL device handle .
/*
	 * If the previous link state is not down, return.
	 */ /* Now re-enable it as due to noise, hardware turned it off */ /* ECC enable */ /* Turn on the Laser */ /*
	             * Mask the Link Up interrupt and unmask the Link Down
	             * interrupt.
	             */ /* notify ULD */ /* notify ULD */ /* link is up after been enabled */