Documentation/PCI/pci-iov-howto.txt
Chinese translated version of Documentation/PCI/pci-iov-howto.txt
If you have any comment or update to the content, please contact the
original document maintainer directly. However, if you have a problem
communicating in English you can also ask the Chinese maintainer for
help. Contact the Chinese maintainer if this translation is outdated
or if there is a problem with the translation.
Chinese maintainer: 徐红 1534342777@qq.com
---------------------------------------------------------------------
Documentation/PCI/pci-iov-howto.txt的中文翻译
如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
译存在问题,请联系中文版维护者。
中文版维护者: 徐红 1534342777@qq.com
中文版翻译者: 徐红 1534342777@qq.com
以下为正文
---------------------------------------------------------------------
pci-iov-howto
串行总线的I/O虚拟化
--------------------
PCI Express I/O Virtualization Howto
Copyright (C) 2009 Intel Corporation
Yu Zhao <yu.zhao@intel.com>
Update: November 2012
-- sysfs-based SRIOV enable-/disable-ment
Donald Dutile <ddutile@redhat.com>
串行总线的I/O虚拟化
版权(C) 2009英特尔公司
于赵 < yu.zhao@intel.com >
更新: 2012年11月
——基于系统文件的SRIOV启用/禁用行为
唐纳德 Dutile < ddutile@redhat.com >
1. Overview
1.1 What is SR-IOV
Single Root I/O Virtualization (SR-IOV) is a PCI Express Extended
capability which makes one physical device appear as multiple virtual
devices. The physical device is referred to as Physical Function (PF)
while the virtual devices are referred to as Virtual Functions (VF).
Allocation of the VF can be dynamically controlled by the PF via
registers encapsulated in the capability. By default, this feature is
not enabled and the PF behaves as traditional PCIe device. Once it's
turned on, each VF's PCI configuration space can be accessed by its own
Bus, Device and Function Number (Routing ID). And each VF also has PCI
Memory Space, which is used to map its register set. VF device driver
operates on the register set so it can be functional and appear as a
real existing PCI device.
1.概述
1.1什么是单根I/O虚拟化
单根虚拟化(SR-IOV)是串行总线使物理设备呈现为多个虚拟设备的扩展能力。
物理设备被成为物理函数(PF),虚拟设备被称为虚函数(VF)。虚函数的分
配可以被物理函数通过寄存器封装能力动态控制。默认情况下,这个特性是
不启用的,物理函数表现的和传统的PCIe设备一样。一旦它被开启,每个虚函
数的PCI配置空间就能被它的总线、设备及功能号(路由ID)访问。每个虚函数也
有PCI内存空间,用来映射它的寄存器组。虚函数驱动在寄存器组上操作,这样
它就能像真实存在的PCI设备一样发挥功能了。
2. User Guide
2.1 How can I enable SR-IOV capability
Multiple methods are available for SR-IOV enablement.
In the first method, the device driver (PF driver) will control the
enabling and disabling of the capability via API provided by SR-IOV core.
If the hardware has SR-IOV capability, loading its PF driver would
enable it and all VFs associated with the PF. Some PF drivers require
a module parameter to be set to determine the number of VFs to enable.
In the second method, a write to the sysfs file sriov_numvfs will
enable and disable the VFs associated with a PCIe PF. This method
enables per-PF, VF enable/disable values versus the first method,
which applies to all PFs of the same device. Additionally, the
PCI SRIOV core support ensures that enable/disable operations are
valid to reduce duplication in multiple drivers for the same
checks, e.g., check numvfs == 0 if enabling VFs, ensure
numvfs <= totalvfs.
The second method is the recommended method for new/future VF devices.
2.用户指南
2.1如何启用SR-IOV能力
很多方法都可以启用单根I/O虚拟行为。第一种方法,设备驱动(PF驱动)可
以通过SR-IOV核心提供的API控制这种能力的启用和禁用。如果硬件拥有
SR-IOV能力,下载它的PF驱动就能启用,所有的VF都与PF相关。有些PF驱动
需要设置模块参数来确定VF被启用的数量。第二种方法,对系统文件
sriov_numvfs的写入将会启用或禁用与PCIe PF相关的虚拟设备。这种方法启
用每一个PF,VF启用/禁用值与第一种方法相比,这种适用于相同设备的所
有PF。此外,PCI单根虚拟化核心支持确保启用/禁用操作有效减少相同检查
的多个驱动程序的重复。例如:check numvfs == 0 if enabling VFs, ensure
numvfs <= totalvfs.
第二种方法是为未来新型虚拟设备推荐的方法。
2.2 How can I use the Virtual Functions
The VF is treated as hot-plugged PCI devices in the kernel, so they
should be able to work in the same way as real PCI devices. The VF
requires device driver that is same as a normal PCI device's.
2.2如何使用虚函数
VF在内核中被视为热插入PCI设备,因此,它们应该能像真正的PCI设备一样
工作。VF需要和正常PCI设备一样的设备驱动。
3. Developer Guide
3.1 SR-IOV API
To enable SR-IOV capability:
(a) For the first method, in the driver:
int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn);
'nr_virtfn' is number of VFs to be enabled.
(b) For the second method, from sysfs:
echo 'nr_virtfn' > \
/sys/bus/pci/devices/<DOMAIN:BUS:DEVICE.FUNCTION>/sriov_numvfs
To disable SR-IOV capability:
(a) For the first method, in the driver:
void pci_disable_sriov(struct pci_dev *dev);
(b) For the second method, from sysfs:
echo 0 > \
/sys/bus/pci/devices/<DOMAIN:BUS:DEVICE.FUNCTION>/sriov_numvfs
To notify SR-IOV core of Virtual Function Migration:
(a) In the driver:
irqreturn_t pci_sriov_migration(struct pci_dev *dev);
3.开发者指南
3.1单根I/O虚拟化应用程序编程接口
启用SR-IOV能力
(a)对于第一种方法,在驱动器中:
int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn);
'nr_virtfn' 表示被启用的VF的数量.
(b)对于第二种方法,来源于系统文件:
echo 0 > \
/sys/bus/pci/devices/<DOMAIN:BUS:DEVICE.FUNCTION>/sriov_numvfs
禁用SR-IOV能力
(a)对于第一种方法,在驱动器中:void pci_disable_sriov(struct pci_dev *dev);
(b)对于第二种方法,来源于系统文件:
echo 0 > \
/sys/bus/pci/devices/<DOMAIN:BUS:DEVICE.FUNCTION>/sriov_numvfs
通知SR-IOV核心虚函数迁移:
(a)在驱动器中:
irqreturn_t pci_sriov_migration(struct pci_dev *dev);
3.2 Usage example
Following piece of code illustrates the usage of the SR-IOV API.
3.2用例
下面的代码片段说明了SR-IOV API的使用。
static int dev_probe(struct pci_dev *dev, const struct pci_device_id *id)
{
pci_enable_sriov(dev, NR_VIRTFN);
...
return 0;
}
static void dev_remove(struct pci_dev *dev)
{
pci_disable_sriov(dev);
...
}
static int dev_suspend(struct pci_dev *dev, pm_message_t state)
{
...
return 0;
}
static int dev_resume(struct pci_dev *dev)
{
...
return 0;
}
static void dev_shutdown(struct pci_dev *dev)
{
...
}
static int dev_sriov_configure(struct pci_dev *dev, int numvfs)
{
if (numvfs > 0) {
...
pci_enable_sriov(dev, numvfs);
...
return numvfs;
}
if (numvfs == 0) {
....
pci_disable_sriov(dev);
...
return 0;
}
}
static struct pci_driver dev_driver = {
.name =
"SR-IOV Physical Function driver",
.id_table =
dev_id_table,
.probe =
dev_probe,
.remove =
dev_remove,
.suspend =
dev_suspend,
.resume =
dev_resume,
.shutdown =
dev_shutdown,
.sriov_configure = dev_sriov_configure,
};
Documentation/PCI/pci-iov-howto.txt的更多相关文章
- dts是如何来描述iommu与PCI(e)之间的关系?
1. 在一颗树的根下每个PCI(e)设备被它的请求id(AKA RID)独一无二的标识,一个请求ID由三部分组成,总线号,设备号和功能号,如: Bits [15:8] 是总线号 Bits [7:3]是 ...
- [虚拟化/云][全栈demo] 为qemu增加一个PCI的watchdog外设(二)
这篇文章的理解,需要一些专业知识了. 我们可以创建模拟自己的外设吗? 我们已经知道什么是qemu了,我们可以通过qmeu的提供的外设,DIY一个计算机了. 但是我们可能还不满足,我们可以自己制造一个外 ...
- Linux内核(13) - 子系统的初始化之以PCI子系统为例
由Kconfig这张地图的分布来看,PCI这块儿的代码应该分布在两个地方,drivers/pci和arch/i386/pci,两岸三地都属于一个中国,不管是drivers/pci那儿的,还是arch/ ...
- linux系统从pci.ids文件获取硬件设备详细厂商信息
机器采样: [root@ht24 hwdata]# cat /etc/redhat-release ; uname -r CentOS Linux release 7.9.2009 (Core) 3. ...
- linux PCI设备初始化过程
linux PCI设备初始化过程 start_kernel->rest_init 这个函数会启动一个核心线程0, 核心线程然后调用init -> do_basic_setup. 然后我们开 ...
- 《Linux Device Drivers》第十二章 PCI司机——note
一个简短的引论 它给这一章总线架构的高级概述 集中访问讨论Peripheral Component Interconnect(PCI,外围组件互连)外设内核函数 PCI公交车是最好的支持的内核总线 本 ...
- Linux PCI网卡驱动的详细分析
学习应该是一个先把问题简单化,在把问题复杂化的过程.一开始就着手处理复杂的问题,难免让人有心惊胆颤,捉襟见肘的感觉.读Linux网卡驱动也是一 样.那长长的源码夹杂着那些我们陌生的变量和符号,望而生畏 ...
- [虚拟化/云][全栈demo] 为qemu增加一个PCI的watchdog外设(六)
目的: 1. 为我们自己的watchdog写一个驱动 步骤: 通过之前的介绍,我们很容易猜想到写我们基于PCI的watchdog驱动,可以分2个步骤. 1. 探测加载PCI设备 这部分代码跟我们的设备 ...
- 第I篇PCI体系结构概述
PCI总线作为处理器系统的局部总线,主要目的是为了连接外部设备,而不是作为处理器的系统总线连接Cache和主存储器.但是PCI总线.系统总线和处理器体系结构之间依然存在着紧密的联系. PCI总线作为系 ...
- PCI、PCI-x,PCI-E兼容以及他们之间的区别详细图解
一.PCI PCI接口分为32bit和64bit两种,32bit就是一般台式机使用的普通的pci接口(图一.图三),64bit接口比32bit接口长一些一般只出现在服务器上(图四.图五).32bit和 ...
随机推荐
- BZOJ4255 : Keep Fit!
首先旋转坐标系,把每个点可以接收的范围转化成一个正方形. 然后建立k-d tree,并记录下每个点在k-d tree上的位置. 对询问使用莫队算法,修改$O(\log n)$,查询期望$O(\log ...
- bzoj 3285 离散对数解指数方程
/************************************************************** Problem: 3285 User: idy002 Language: ...
- 【学习笔记】python的代码块(吐槽)
曾经我以为python是像pascal那样begin开始end结束, 直到今天…… 我才知道python是用缩进作为代码段标识的…… >>> def test(n): ... if ...
- Django-Filter源码解析一
Django Filter源码解析 最近在看Django-FIlter项目的源码,学习一下别人的开发思想: 整体介绍 首先,我从其中一个测试用例作为入口,开始了debug之路,一点一点的断点,分析它的 ...
- FireDAC 下的 Sqlite [7] - 备份、优化、事务(Transaction)
用 TFDSQLiteBackup 控件, 两三行代码即可完成 Sqlite 数据库的备份. procedure TForm1.Button1Click(Sender: TObject); begin ...
- Ubuntu 16.04实现SSH无密码登录/免密登录/自动登录(ssh-keygen/ssh-copy-id)
ssh-keygen:产生公钥与私钥(在~/.ssh) ssh-copy-id:将本机的公钥复制到远程机器的authorized_keys文件中(在~/.ssh),ssh-copy-id也能让你有到远 ...
- Redis使用小结
Redis官方没有windows版本的,对于Windows环境的redis,有如下两个方案 微软的移植版本,但只支持到3.2 下载地址 win10及以上的版本直接通过win10的liunx子系统执行 ...
- Ubuntu下配置用msmtp发送gmail邮件
从https://gist.github.com/JosefJezek/6194563上找到的一个配置脚本,下载后添加可执行权限,然后运行即可. 下面是脚本setup-msmtp-for-gmail. ...
- Task Parallel Library01,基本用法
我们知道,每个应用程序就是一个进程,一个进程有多个线程.Task Parallel Library为我们的异步编程.多线程编程提供了强有力的支持,它允许一个主线程运行的同时,另外的一些线程或Task也 ...
- Odoo进销存(采购、销售、仓库)入门教程 - 上
转载地址:http://blog.csdn.net/wangnan537/article/details/46434373 运行环境: Ubuntu14.04+Odoo8.0 作者:苏州-微尘 0. ...