其他分享
首页 > 其他分享> > e1000_irq_enable pk enable_irq

e1000_irq_enable pk enable_irq

作者:互联网

函数:enable_irq( ):

函数enable_irq( )在实现过程中调用了函数__enable_irq( ),根据中断所处的深度和状态的不同,会有不同的执行结果,一般用于改变中断的状态,使中断处于唤醒状态,触发中断处理函数的执行及减少中断所处的深度,即改变字段depth的值。

static int __init enable_disable_irq_init(void)
{
    int result=0;
    printk("into enable_disable_irq_init\n");
    /*申请一个新的中断,中断号对应的是11,中断处理函数是myhandler( ),中断类型是IRQF_
        DISABLED,中断设备名是A_NEW_Device,设备编号是NULL(即不对应真实的设备)*/
    result=request_irq(irq, irq_handler, IRQF_DISABLED, "A_New_Device", NULL);
    disable_irq(irq); //调用disable_irq( )函数,使中断的深度增加1
    enable_irq(irq); //调用enable_irq( )函数,使中断的深度减少1,同时触发中断处理函数执行
    printk("the result of the request_irq is: %d\n", result);    //输出中断申请的结果
    printk("out enable_disable_irq_init\n");
    return 0;
}

 

 

static void e1000_netpoll(struct net_device *netdev)
{
    struct e1000_adapter *adapter = netdev_priv(netdev);

    if (disable_hardirq(adapter->pdev->irq))
        e1000_intr(adapter->pdev->irq, netdev);
    enable_irq(adapter->pdev->irq);
}

 

e1000_irq_enable

int e1000_open(struct net_device *netdev)
{
    struct e1000_adapter *adapter = netdev_priv(netdev);
    struct e1000_hw *hw = &adapter->hw;
    int err;

    /* disallow open during test */
    if (test_bit(__E1000_TESTING, &adapter->flags))
        return -EBUSY;

    netif_carrier_off(netdev);

    /* allocate transmit descriptors */
    err = e1000_setup_all_tx_resources(adapter);
    if (err)
        goto err_setup_tx;

    /* allocate receive descriptors */
    err = e1000_setup_all_rx_resources(adapter);
    if (err)
        goto err_setup_rx;

    e1000_power_up_phy(adapter);

    adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
    if ((hw->mng_cookie.status &
              E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) {
        e1000_update_mng_vlan(adapter);
    }

    /* before we allocate an interrupt, we must be ready to handle it.
     * Setting DEBUG_SHIRQ in the kernel makes it fire an interrupt
     * as soon as we call pci_request_irq, so we have to setup our
     * clean_rx handler before we do so.
     */
    e1000_configure(adapter);

    err = e1000_request_irq(adapter);
    if (err)
        goto err_req_irq;

    /* From here on the code is the same as e1000_up() */
    clear_bit(__E1000_DOWN, &adapter->flags);

    napi_enable(&adapter->napi);

    e1000_irq_enable(adapter);

    netif_start_queue(netdev);

    /* fire a link status change interrupt to start the watchdog */
    ew32(ICS, E1000_ICS_LSC);

    return E1000_SUCCESS;

err_req_irq:
    e1000_power_down_phy(adapter);
    e1000_free_all_rx_resources(adapter);
err_setup_rx:
    e1000_free_all_tx_resources(adapter);
err_setup_tx:
    e1000_reset(adapter);

    return err;
}

 

/**
 * e1000_irq_enable - Enable default interrupt generation settings
 * @adapter: board private structure
 **/
static void e1000_irq_enable(struct e1000_adapter *adapter)
{
    struct e1000_hw *hw = &adapter->hw;

    ew32(IMS, IMS_ENABLE_MASK);
    E1000_WRITE_FLUSH();
}

 

标签:enable,err,netdev,irq,adapter,pk,e1000
来源: https://www.cnblogs.com/dream397/p/16121270.html