msi-x 机制 --- linux kernel 实现欣赏

先看 MSI Capability Structures. 

 

/*
 *    很简单,使能 MSI
 *    默认情况下,MSI 是禁用的.
 *    这里要使能它.
 */
static inline void pci_msi_set_enable(struct pci_dev *dev, int enable)
{
	u16 control;

    /*
     *    读取消息控制寄存器.
     */
	pci_read_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, &control);
    /*
     *    bit[0] 置 1.  见下图.
     */
	control &= ~PCI_MSI_FLAGS_ENABLE;
	if (enable)
		control |= PCI_MSI_FLAGS_ENABLE;
    /*
     *    写入消息控制寄存器
     */
	pci_write_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, control);
}

MSI-X 有很大的变化

bit[15] : 默认值为0,

static int msix_capability_init(struct pci_dev *dev, struct msix_entry *entries,
				int nvec, struct irq_affinity *affd)
{
        u16 control;

        /*
         *    读取消息控制寄存器.
         *    
         *    1) Table size . bit[10:0]  
         *       即 中断向量的个数.
         *       可见一个Function能支持 2048个MSI-X 中断.
         */
        pci_read_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, &control);
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值