• vfio_enable_intx


    /* enable legacy (INTx) interrupts */
    static int
    vfio_enable_intx(const struct rte_intr_handle *intr_handle) {
            struct vfio_irq_set *irq_set;
            char irq_set_buf[IRQ_SET_BUF_LEN];
            int len, ret;
            int *fd_ptr;
    
            len = sizeof(irq_set_buf);
    
            /* enable INTx */
            irq_set = (struct vfio_irq_set *) irq_set_buf;
            irq_set->argsz = len;
            irq_set->count = 1;
            irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER;
            irq_set->index = VFIO_PCI_INTX_IRQ_INDEX;
            irq_set->start = 0;
            fd_ptr = (int *) &irq_set->data;
            *fd_ptr = intr_handle->fd;
    
            ret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);
    
            if (ret) {
                    RTE_LOG(ERR, EAL, "Error enabling INTx interrupts for fd %d
    ",
                                                    intr_handle->fd);
                    return -1;
            }
    
            /* unmask INTx after enabling */
            memset(irq_set, 0, len);
            len = sizeof(struct vfio_irq_set);
            irq_set->argsz = len;
            irq_set->count = 1;
            irq_set->flags = VFIO_IRQ_SET_DATA_NONE | VFIO_IRQ_SET_ACTION_UNMASK;
            irq_set->index = VFIO_PCI_INTX_IRQ_INDEX;
            irq_set->start = 0;
    
            ret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);
    
            if (ret) {
                    RTE_LOG(ERR, EAL, "Error unmasking INTx interrupts for fd %d
    ",
                                                    intr_handle->fd);
                    return -1;
            }
            return 0;
    }
    
    /* disable legacy (INTx) interrupts */
    static int
    vfio_disable_intx(const struct rte_intr_handle *intr_handle) {
            struct vfio_irq_set *irq_set;
            char irq_set_buf[IRQ_SET_BUF_LEN];
            int len, ret;
    
            len = sizeof(struct vfio_irq_set);
    
            /* mask interrupts before disabling */
            irq_set = (struct vfio_irq_set *) irq_set_buf;
            irq_set->argsz = len;
            irq_set->count = 1;
            irq_set->flags = VFIO_IRQ_SET_DATA_NONE | VFIO_IRQ_SET_ACTION_MASK;
            irq_set->index = VFIO_PCI_INTX_IRQ_INDEX;
            irq_set->start = 0;
    
            ret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);
    
            if (ret) {
                    RTE_LOG(ERR, EAL, "Error masking INTx interrupts for fd %d
    ",
                                                    intr_handle->fd);
                    return -1;
            }
    
            /* disable INTx*/
            memset(irq_set, 0, len);
            irq_set->argsz = len;
            irq_set->count = 0;
            irq_set->flags = VFIO_IRQ_SET_DATA_NONE | VFIO_IRQ_SET_ACTION_TRIGGER;
            irq_set->index = VFIO_PCI_INTX_IRQ_INDEX;
            irq_set->start = 0;
    
            ret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);
    
            if (ret) {
                    RTE_LOG(ERR, EAL,
                            "Error disabling INTx interrupts for fd %d
    ", intr_handle->fd);
                    return -1;
            }
            return 0;
    }
  • 相关阅读:
    Citrix的一个安装问题(The Configuration file(s) for this site could not be read )
    MDOP(1) : AppV 命令行刷新
    BPC (9) SAP BI & BPC 安装 : 一个外行眼里的千奇百怪 (4)
    BPC (12) 服务账号密码重置(1)
    BPC (10) 二种平台的安装
    BPC (9) SAP BI & BPC 安装 : 一个外行眼里的千奇百怪 (3)
    BPC (11) – NW BPC 7.04 三个Bug
    一本30多年前的桥牌书
    使用XCode联机调试你的iOS应用
    $_SERVER 数据的一系列数据
  • 原文地址:https://www.cnblogs.com/dream397/p/13567449.html
Copyright © 2020-2023  润新知