SlideShare a Scribd company logo
PCIe & SR IOV in virtual 
PCIe & SR‐IOV in virtual
     environment
        海老澤 健太郎
       Twitter: @ebiken
     ebiken.g@gmail.com
PCI コンフィグレーション空間
•   デバイス上のFunction毎に存在するメモリ空間
•   ドライバはここにアクセスすることによりデバイスを操作

•   アクセス方法
    – IO Port:起動時 or Legacy
    – MMIO : Memory Mapped IO
                          d

•   フォーマットは3タイプ
    – Type 0 : non‐bridge function
       ype 0 : o b dge u ct o
         •   一般的なデバイスはこちら(NIC, DISK)
    – Type 1 : PCI‐to PCI Bridge
         •   PCIe Switch で Packet Routing するための情報を含む
    – Type 2 : CardBus Bridge
       yp                  g

•   サイズ・配置
    – PCIe = 4KByte (そのうち PCI 共通=256 Byte)
    – 64 B t : コンフィグレ ション空間ヘッダ部分(PCI共通部)
          Byte コンフィグレーション空間ヘッダ部分(PCI共通部)
    – 192 Byte :デバイス固有の領域(PCI共通部)




                                           2
PCI コンフィグレーション空間:配置
           物理メモリ空間     SDRAM    PCIメモリ空間

           メインメモリ     メインメモリ
  4GB
           システムBIOS

           PCI用MMIO             PCIデバイス
  3GB


           メインメモリ     メインメモリ


  1MB
             予約       シャドウRAM
           VGAビデオ                VGAビデオ
0xa0000
      コンベンショナルメモリ
                      メインメモリ
  0MB    (640KB)

                       3
Type 0
             31 - 24               23 - 16               15 - 8                 7-0

1    00h               Device ID                                   Vendor ID

2    04h                 Status                                    Command

3    08h   Class code              Subclass              Prog IF             Revision ID

4    0Ch      BIST            Header type          Latency Timer           Cache Line Size

5    10h                            Base address #0 (BAR0)

6    14h                            Base address #1 (BAR1)

7    18h                            Base address #2 (BAR2)

8    1Ch                            Base address #3 (BAR3)

9    20h                            Base address #4 (BAR4)

10   24h                            Base address #5 (BAR5)

11   28h                              Cardbus CIS Pointer

12   2Ch             Subsystem ID                         Subsystem Vendor ID

13   30h                          Expansion ROM base address
                                                                             Capabilities
14   34h                           Reserved
                                                                              Pointer
15   38h                                      Reserved

16   3Ch   Max latency
           M l t                  Min Grant
                                  Mi G t            Interrupt PIN
                                                    I t     t               Interrupt Line
                                                                            I t     t Li


                                                                       4
コンフィグレーション空間 … PF on Host
[root@dut 0000:03:00.1]# lspci –x
03:00.0 Ethernet controller: Intel Corporation 82599EB 10 Gigabit TN Network Connection (rev 01)
             Vendor ID = 8086 (Intel)
                  Device ID = 151c (82599EB 10 Gigabit TN Network Connection)                  Header Type = 80
                                                                                               bit 7 : Multi function
                                   Command = 0407                                              bit 6‐0 : non‐bridge function
                                       bit 0 : IO enable
                                       bit 1 : Mem enable             Revision ID = 01 Class code = 02 (Network Controller)
                                                     Status = 0010

        00:     86    80     1c    15       07    04        10   00   01   00    00   02    10   00    80   00
        10:     04    00     20    df       00    00        00   00   c1   ec    00   00    00   00    00   00
        20:     04    80     1f    df       00    00        00   00   00   00    00   00    86   80    2c   a0
        30:     00    00     00    00       40    00        00   00   00   00    00   00    0e   02    00   00
  BAR#01 = 0000 0000 df20 0004 (Mem, 64bit)                                     IRQ PIN = INTB#
                                         BAR#23 = 0000 0000 0000 ecc1 IRQ Line = 0e
                                         (IO, 32bit)
     BAR#45 = 0000 0000 df1f 8004 (M
              0000 0000 df1f 8004 (Mem, 64bit)
                                        64bi )
                                                                 Subsystem Vendor ID = 8086 (Intel)

  PCI IDs = Vendor ID + Device ID                                                   Subsystem ID = a02c (***********)
  http://pciids.sourceforge.net/
     p p                 g
  http://pci‐ids.ucw.cz/read/PC/8086                 !!PCIはリトルエンディアン!!
                                                                  5
コンフィグレーション空間 … VF on Host
[root@dut 0000:03:00.1]# lspci –x
03:10.0 Ethernet controller: Intel Corporation 82599 Ethernet Controller Virtual Function (rev 01)
             Vendor ID = ffff (n/a)
                                /
                   Device ID = ffff (n/a)                                                      Header Type = 80
                                                                                               bit 7 : Single function
                                   Command = 0004                                              bit 6‐0 : non‐bridge function
                                       bit 0 : IO disable
                                       bit 1 : Mem disable            Revision ID = 01 Class code = 02 (Network Controller)
                                                      Status = 0010

        00:     ff    ff     ff    ff       04     00    10   00      01   00    00   02    00   00    00   00
        10:     00    00     00    00       00     00    00   00      00   00    00   00    00   00    00   00
        20:     00    00     00    00       00     00    00   00      00   00    00   00    86   80    2c   a0
        30:     00    00     00    00       70     00    00   00      00   00    00   00    00   00    00   00
  BAR#01 = 0000 0000 0000 0000                                                               IRQ PIN = n/a
                                                      BAR#23 = 0000 0000 0000 0000 IRQ Line = 00

      BAR#45 = 0000 0000 0000 0000
               0000 0000 0000 0000
                                                                                  Subsystem Vendor ID = 8086 (Intel)

  PCI IDs = Vendor ID + Device ID                                                   Subsystem ID = a02c (***********)
  http://pciids.sourceforge.net/
     p p                 g
  http://pci‐ids.ucw.cz/read/PC/8086                 !!PCIはリトルエンディアン!!
                                                                 6
コンフィグレーション空間 … VF on Guest
[root@dutvm‐sriov ~]# lspci ‐ x
00:03.0 Ethernet controller: Intel Corporation 82559 Ethernet Controller Virtual Function (rev 01)
            Vendor ID = 8086 (Intel)
                   Device ID = 10ed (82559 Ethernet Controller Virtual Function)               Header Type = 80
                                                                                               bit 7 : Single function
                                   Command = 0407                                              bit 6‐0 : non‐bridge function
                                       bit 0 : IO enable
                                       bit 1 : Mem enable             Revision ID = 01 Class code = 02 (Network Controller)
                                                     Status = 0010

        00:     86    80     ed    10       07    04        10   00   01   00    00   02    00   00    00   00
        10:     00    00     02    f2       00    00        00   00   00   00    00   00    00   40    02   f2
        20:     00    00     00    00       00    00        00   00   00   00    00   00    86   80    2c   a0
        30:     00    00     00    00       a0    00        00   00   00   00    00   00    00   00    00   00
  BAR#0 = f202 0000 (Mem, 32bit)                                                                   IRQ PIN = n/a
                                                  BAR#3 = f202 4000 (Mem, 32bit)         IRQ Line = 00
      BAR#45 = 0000 0000 0000 0000
               0000 0000 0000 0000
                                                                                  Subsystem Vendor ID = 8086 (Intel)

  PCI IDs = Vendor ID + Device ID                                                   Subsystem ID = a02c (***********)
  http://pciids.sourceforge.net/
     p p                 g
  http://pci‐ids.ucw.cz/read/PC/8086                 !!PCIはリトルエンディアン!!
                                                                  7
PF on Host
[root@dut ~]# lspci ‐v ‐s 03:00.0
03:00.0 Ethernet controller: Intel Corporation 82599EB 10 Gigabit TN Network Connection (rev 01)
    Subsystem: Intel Corporation Device a02c
       b             l          i       i
    Flags: bus master, fast devsel, latency 0, IRQ 45
    Memory at df200000 (64‐bit, non‐prefetchable) [size=2M]
    I/O ports at ecc0 [size=32]
    Memory at df1f8000 (64‐bit, non‐prefetchable) [size=16K]
    Capabilities: [40] Power Management version 3
    Capabilities: [50] MSI: Enable‐ Count=1/1 Maskable+ 64bit+
    Capabilities: [70] MSI X: Enable Count=64 Masked‐
    Capabilities: [70] MSI‐X: Enable+ Count 64 Masked
    Capabilities: [a0] Express Endpoint, MSI 00
    Capabilities: [e0] Vital Product Data
    Capabilities: [100] Advanced Error Reporting
    Capabilities: [140] Device Serial Number 00‐1b‐21‐ff‐ff‐ce‐51‐c4
    Capabilities: [140] Device Serial Number 00 1b 21 ff ff ce 51 c4
    Capabilities: [150] Alternative Routing‐ID Interpretation (ARI)
    Capabilities: [160] Single Root I/O Virtualization (SR‐IOV)
    Kernel driver in use: ixgbe
    Kernel modules: ixgbe
          l    d l i b




                                                  8
VF on Host / Guest 比較
[root@dut ~]# lspci ‐v ‐s 03:10.0
03:10.0 Ethernet controller: Intel Corporation 82599 Ethernet Controller Virtual Function (rev 01)
    Subsystem: Intel Corporation Device a02c
    Subsystem: Intel Corporation Device a02c
    Flags: bus master, fast devsel, latency 0
    [virtual] Memory at d0000000 (64‐bit, prefetchable) [size=16K]
    [virtual] Memory at d0100000 (64‐bit, prefetchable) [size=16K]
    Capabilities: [70] MSI‐X: Enable+ Count=3 Masked‐
       p          [ ]
    Capabilities: [a0] Express Endpoint, MSI 00
    Capabilities: [100] Advanced Error Reporting
    Capabilities: [150] Alternative Routing‐ID Interpretation (ARI)
    Kernel driver in use: pci‐stub
    Kernel modules: ixgbevf
          l    d l       b f

[root@dutvm‐sriov ~]# lspci ‐v ‐s 00:03.0
00:03.0 Ethernet controller: Intel Corporation 82559 Ethernet Controller Virtual Function (rev 01)
    Subsystem: Intel Corporation Device a02c
    Subsystem: Intel Corporation Device a02c
    Physical Slot: 3
    Flags: bus master, fast devsel, latency 0
    Memory at f2020000 (32‐bit, non‐prefetchable) [size=16K]
    Memory at f2024000 (32‐bit, non‐prefetchable) [size=16K]
            y               (     ,     p          )[         ]
    Capabilities: [a0] Express Endpoint, MSI 00
    Capabilities: [70] MSI‐x: Enable+ Count=3 Masked‐
    Kernel driver in use: ixgbevf
    Kernel modules: ixgbevf



                                                           9
IO v.s. Memory ‐ Mapped IO
•   IO Mapped IO
     –   IO port (IO空間) を利用
     –   IO空間のアドレス=IOポートアドレス、ポート番号
     –   1,2,4 Byte単位でのRead/Write
     –   IO Port専用のニーモニックがある。asm/io.h

•   MMIO : Memory Mapped IO
     – IO Portの代わりにメモリアクセスをハードウェアレベルでのデバイスへのアクセスに置換
     – デバイスに割当られたアドレス範囲にメモリアクセスをすることにより、ドライバからデバイス
       のレジスタRead/Write可能
     – ドライバが動作する「仮想メモリアドレス」と、MMIO確保された「物理メモリアドレス」の違いに
       注意

•              (PCIe Root Bridge <‐> Device) は共通
    PCIe Layer (PCI R
    PCI L                 B id       D i )
     – Config TLP (Transaction Layer Packet) でアクセス

•   共通の抽象的なインタ フェ ス有り
    共通の抽象的なインターフェース有り
     – asm/iomap.h
     – void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max len);




                                               10
IO v.s. Memory ‐ Mapped IO
•   IO Ports, MMIO割当確認方法
    – [root@hwn01 ~]# ls /proc/ | grep ^io
    – iomem
    – ioports
    [root@hwn01 ~]# cat /proc/ioports
    0000‐0cf7 : PCI Bus 0000:00
     0000‐001f : dma1
     0020‐0021 : pic1
     0040‐0043 : timer0
     0050‐0053 : timer1
     0050‐0053 : timer1
     0060‐0060 : keyboard

    [root@hwn01 ~]# cat /proc/iomem
    00000000‐0000ffff : reserved
    00000000 0000ffff            d
    00010000‐0009f7ff : System RAM
    …
     f4000000‐f7ffffff : PCI MMCONFIG 0000 [bus 00‐3f]
      f4000000‐f7ffffff : reserved
       f4000000‐f7ffffff : pnp 00:0a
     fb400000‐fb7fffff : 0000:00:02.0



                                              11
メモ
• MSI, MSI‐X の Configuration 空間パラメーターと、/proc/interrupt
  で見える割り込み番号の関係
   – ???
• PCIe MSI, MSI‐X の処理方法
   – NICからアドレス0xfeeに対しメモリ書き込み(DWORD Mem Write
                                    Mem Write 
     Transaction)
      • アドレスは初期化時 MSI Capability Registerにソフトウェア(BIOS??)がセット
      • 0xfeeはLocal APIC のレジスタへMemory Mapされている
                    APIC のレジスタ Memory
   – LAPICがCPUへ割り込み通知(INTR)
   – CPU ⇒ LAPICへAck(INTA)
   – LAPIC⇒CPU:Vectorを返す
• VFのBAR
   – VFのメモリ空間にはBARはない
   – PFのSR IOV C bilit R i t に設定
     PFのSR‐IOV Capability Registerに設定
   – Host の lspci ‐v はそちらを表示



                               12
メモ
• 空の PCI スロットのベ ンダ ID とデバイス ID を
  読み取ろうとしたときは、0xFFFFFFFF というエ
  ラ メッセ ジが返る
  ラー メッセージが返る

• BARは起動時にBIOSが割り当て
 – http://www.mnc.co.jp/intime/user/intimedev.php
   ?PCI%A5%B3%A5%F3%A5%D5%A5%A3%A5%B0%
   A5%EC%A1%BC%A5%B7%A5%E7%A5%F3%A5%EC
   %A5%B8%A5%B9%A5%BF

                       13
割り込み一覧(/proc/interrupts)
[root@hwn01 ~]# cat /proc/interrupts
           CPU0       CPU1       CPU2     CPU3
  0:        144          1          0        0   IO-APIC-edge      timer
  1:          3          0          1        2   IO-APIC-edge      i8042
  4:
  4           0          1          1        0   IO-APIC-edge
                                                          d
  8:         33         58         31       57   IO-APIC-edge      rtc0
  9:          0          0          0        0   IO-APIC-fasteoi   acpi
 16:          0          0          0        0   IO-APIC-fasteoi   ahci, uhci_hcd:usb3, uhci_hcd:usb9
 17:        115          3          1        1   IO-APIC-fasteoi   pata_jmicron, firewire_ohci
 18:       2150       3669        117      284   IO-APIC-fasteoi   ehci_hcd:usb1, uhci_hcd:usb5, uhci_hcd:usb8
 19:      51447       1305      39191     1307   IO-APIC-fasteoi   ata_piix, ata_piix, uhci_hcd:usb7
 21:          0          0          0        0   IO-APIC-fasteoi   uhci_hcd:usb4
 23:          0          0          0        0   IO-APIC-fasteoi   ehci_hcd:usb2, uhci_hcd:usb6
 41:      58395        289       3073      269   PCI-MSI-edge      i915@pci:0000:00:02.0
 42:         47         50         47       52   PCI-MSI-edge      hda_intel
 43:       2710       6576       3336     3655   PCI-MSI-edge      eth0
 44:          0          0          0        1   PCI-MSI-edge      xhci_hcd
 45:          0          0          0        0   PCI-MSI-edge      xhci_hcd
 46:          0          0          0        0   PCI-MSI-edge      xhci_hcd
 47:          0          0          0        0   PCI-MSI-edge      xhci_hcd
 48:          0          0          0        0   PCI-MSI-edge      xhci_hcd
 49:       2985          6        648        5   PCI-MSI-edge      eth1
NMI:         13         34         95       28   Non-maskable interrupts
LOC:     332011     170933     296037   190006   Local timer interrupts
SPU:          0          0          0        0   Spurious interrupts
PMI:         13         34         95       28   Performance monitoring interrupts
IWI:          0          0          0        0   IRQ work interrupts
RES:     452195      37148     103501    14434   Rescheduling interrupts
                                                            g        p
CAL:        812       6027       1044     7911   Function call interrupts
TLB:       1077        644       2068      824   TLB shootdowns
TRM:          0          0          0        0   Thermal event interrupts
THR:          0          0          0        0   Threshold APIC interrupts
MCE:          0          0          0        0   Machine check exceptions
MCP:         29         28         28       28   Machine check polls
ERR:          0
MIS:          0


                                                               14

More Related Content

What's hot

Pythonの理解を試みる 〜バイトコードインタプリタを作成する〜
Pythonの理解を試みる 〜バイトコードインタプリタを作成する〜Pythonの理解を試みる 〜バイトコードインタプリタを作成する〜
Pythonの理解を試みる 〜バイトコードインタプリタを作成する〜
Preferred Networks
 

What's hot (20)

「FPGA 開発入門:FPGA を用いたエッジ AI の高速化手法を学ぶ」
「FPGA 開発入門:FPGA を用いたエッジ AI の高速化手法を学ぶ」「FPGA 開発入門:FPGA を用いたエッジ AI の高速化手法を学ぶ」
「FPGA 開発入門:FPGA を用いたエッジ AI の高速化手法を学ぶ」
 
第9回ACRiウェビナー_セック/岩渕様ご講演資料
第9回ACRiウェビナー_セック/岩渕様ご講演資料第9回ACRiウェビナー_セック/岩渕様ご講演資料
第9回ACRiウェビナー_セック/岩渕様ご講演資料
 
P4によるデータプレーンプログラミングとユースケースのご紹介
P4によるデータプレーンプログラミングとユースケースのご紹介P4によるデータプレーンプログラミングとユースケースのご紹介
P4によるデータプレーンプログラミングとユースケースのご紹介
 
Xbyakの紹介とその周辺
Xbyakの紹介とその周辺Xbyakの紹介とその周辺
Xbyakの紹介とその周辺
 
ZynqMPのブートとパワーマネージメント : (ZynqMP Boot and Power Management)
ZynqMPのブートとパワーマネージメント : (ZynqMP Boot and Power Management)ZynqMPのブートとパワーマネージメント : (ZynqMP Boot and Power Management)
ZynqMPのブートとパワーマネージメント : (ZynqMP Boot and Power Management)
 
Chainer でのプロファイリングをちょっと楽にする話
Chainer でのプロファイリングをちょっと楽にする話Chainer でのプロファイリングをちょっと楽にする話
Chainer でのプロファイリングをちょっと楽にする話
 
2値化CNN on FPGAでGPUとガチンコバトル(公開版)
2値化CNN on FPGAでGPUとガチンコバトル(公開版)2値化CNN on FPGAでGPUとガチンコバトル(公開版)
2値化CNN on FPGAでGPUとガチンコバトル(公開版)
 
いまさら聞けない!CUDA高速化入門
いまさら聞けない!CUDA高速化入門いまさら聞けない!CUDA高速化入門
いまさら聞けない!CUDA高速化入門
 
マルチコアを用いた画像処理
マルチコアを用いた画像処理マルチコアを用いた画像処理
マルチコアを用いた画像処理
 
Zynq mp勉強会資料
Zynq mp勉強会資料Zynq mp勉強会資料
Zynq mp勉強会資料
 
UEFIベアメタルプログラミング
UEFIベアメタルプログラミングUEFIベアメタルプログラミング
UEFIベアメタルプログラミング
 
NVIDIA GPUで作るHeadless X11 Linux
NVIDIA GPUで作るHeadless X11 LinuxNVIDIA GPUで作るHeadless X11 Linux
NVIDIA GPUで作るHeadless X11 Linux
 
4章 Linuxカーネル - 割り込み・例外 3
4章 Linuxカーネル - 割り込み・例外 34章 Linuxカーネル - 割り込み・例外 3
4章 Linuxカーネル - 割り込み・例外 3
 
ゼロからはじめるKVM超入門
ゼロからはじめるKVM超入門ゼロからはじめるKVM超入門
ゼロからはじめるKVM超入門
 
CUDAのアセンブリ言語基礎のまとめ PTXとSASSの概説
CUDAのアセンブリ言語基礎のまとめ PTXとSASSの概説CUDAのアセンブリ言語基礎のまとめ PTXとSASSの概説
CUDAのアセンブリ言語基礎のまとめ PTXとSASSの概説
 
ACRiウェビナー:小野様ご講演資料
ACRiウェビナー:小野様ご講演資料ACRiウェビナー:小野様ご講演資料
ACRiウェビナー:小野様ご講演資料
 
Gpu vs fpga
Gpu vs fpgaGpu vs fpga
Gpu vs fpga
 
Pythonの理解を試みる 〜バイトコードインタプリタを作成する〜
Pythonの理解を試みる 〜バイトコードインタプリタを作成する〜Pythonの理解を試みる 〜バイトコードインタプリタを作成する〜
Pythonの理解を試みる 〜バイトコードインタプリタを作成する〜
 
コンテナネットワーキング(CNI)最前線
コンテナネットワーキング(CNI)最前線コンテナネットワーキング(CNI)最前線
コンテナネットワーキング(CNI)最前線
 
Vivado hls勉強会1(基礎編)
Vivado hls勉強会1(基礎編)Vivado hls勉強会1(基礎編)
Vivado hls勉強会1(基礎編)
 

Viewers also liked

Message Signaled Interrupts
Message Signaled InterruptsMessage Signaled Interrupts
Message Signaled Interrupts
Anshuman Biswal
 
仮想化環境におけるパケットフォワーディング
仮想化環境におけるパケットフォワーディング仮想化環境におけるパケットフォワーディング
仮想化環境におけるパケットフォワーディング
Takuya ASADA
 

Viewers also liked (19)

Slideshare - PCIe
Slideshare - PCIeSlideshare - PCIe
Slideshare - PCIe
 
20120309 cloud mix-public クラウドごった煮
20120309 cloud mix-public クラウドごった煮 20120309 cloud mix-public クラウドごった煮
20120309 cloud mix-public クラウドごった煮
 
Introduction to Ostinato , network packet crafting and generator.
Introduction to Ostinato, network packet crafting and generator.Introduction to Ostinato, network packet crafting and generator.
Introduction to Ostinato , network packet crafting and generator.
 
OpenVZ - Linux Containers:第2回 コンテナ型仮想化の情報交換会@東京
OpenVZ - Linux Containers:第2回 コンテナ型仮想化の情報交換会@東京OpenVZ - Linux Containers:第2回 コンテナ型仮想化の情報交換会@東京
OpenVZ - Linux Containers:第2回 コンテナ型仮想化の情報交換会@東京
 
Vyatta and Virtualization 仮想環境でのVyatta
Vyatta and Virtualization 仮想環境でのVyattaVyatta and Virtualization 仮想環境でのVyatta
Vyatta and Virtualization 仮想環境でのVyatta
 
Vyatta @ Open Cloud Campus - 20110630
Vyatta @ Open Cloud Campus - 20110630Vyatta @ Open Cloud Campus - 20110630
Vyatta @ Open Cloud Campus - 20110630
 
OpenStack with SR-IOV
OpenStack with SR-IOVOpenStack with SR-IOV
OpenStack with SR-IOV
 
SR-IOV benchmark
SR-IOV benchmarkSR-IOV benchmark
SR-IOV benchmark
 
Message Signaled Interrupts
Message Signaled InterruptsMessage Signaled Interrupts
Message Signaled Interrupts
 
OVN 設定サンプル | OVN config example 2015/12/27
OVN 設定サンプル | OVN config example 2015/12/27OVN 設定サンプル | OVN config example 2015/12/27
OVN 設定サンプル | OVN config example 2015/12/27
 
SR-IOV Introduce
SR-IOV IntroduceSR-IOV Introduce
SR-IOV Introduce
 
plotnetcfg入門 | Introduction to plotnetcfg
plotnetcfg入門 | Introduction to plotnetcfgplotnetcfg入門 | Introduction to plotnetcfg
plotnetcfg入門 | Introduction to plotnetcfg
 
夏合宿
夏合宿夏合宿
夏合宿
 
FPGAで作るOpenFlow Switch (FPGAエクストリーム・コンピューティング 第6回) FPGAX#6
FPGAで作るOpenFlow Switch (FPGAエクストリーム・コンピューティング 第6回) FPGAX#6FPGAで作るOpenFlow Switch (FPGAエクストリーム・コンピューティング 第6回) FPGAX#6
FPGAで作るOpenFlow Switch (FPGAエクストリーム・コンピューティング 第6回) FPGAX#6
 
ネットワークAPI のあれこれ (ENOG37)
ネットワークAPI のあれこれ (ENOG37)ネットワークAPI のあれこれ (ENOG37)
ネットワークAPI のあれこれ (ENOG37)
 
ネットワーク機器のAPIあれこれ入門 (NetOpsCoding#2)
ネットワーク機器のAPIあれこれ入門(NetOpsCoding#2)ネットワーク機器のAPIあれこれ入門(NetOpsCoding#2)
ネットワーク機器のAPIあれこれ入門 (NetOpsCoding#2)
 
仮想化環境におけるパケットフォワーディング
仮想化環境におけるパケットフォワーディング仮想化環境におけるパケットフォワーディング
仮想化環境におけるパケットフォワーディング
 
Interrupts on xv6
Interrupts on xv6Interrupts on xv6
Interrupts on xv6
 
"OPEN NETWORKING" に向けた Management / Data Plane の動向
"OPEN NETWORKING" に向けた Management / Data Plane の動向"OPEN NETWORKING" に向けた Management / Data Plane の動向
"OPEN NETWORKING" に向けた Management / Data Plane の動向
 

Similar to 20111015 勉強会 (PCIe / SR-IOV)

About FeliCa Lite(日本語)
About FeliCa Lite(日本語)About FeliCa Lite(日本語)
About FeliCa Lite(日本語)
Hirokuma Ueno
 
/proc/irq/&lt;irq>/smp_affinity
/proc/irq/&lt;irq>/smp_affinity/proc/irq/&lt;irq>/smp_affinity
/proc/irq/&lt;irq>/smp_affinity
Takuya ASADA
 
Exploring the x64
Exploring the x64Exploring the x64
Exploring the x64
FFRI, Inc.
 
Dalvik仮想マシンのアーキテクチャ 改訂版
Dalvik仮想マシンのアーキテクチャ 改訂版Dalvik仮想マシンのアーキテクチャ 改訂版
Dalvik仮想マシンのアーキテクチャ 改訂版
Takuya Matsunaga
 

Similar to 20111015 勉強会 (PCIe / SR-IOV) (20)

Bluetooth通信の 仕組みと活用法紹介
Bluetooth通信の仕組みと活用法紹介Bluetooth通信の仕組みと活用法紹介
Bluetooth通信の 仕組みと活用法紹介
 
Windowsのパケットモニタ作成
Windowsのパケットモニタ作成Windowsのパケットモニタ作成
Windowsのパケットモニタ作成
 
あるブートローダの話
あるブートローダの話あるブートローダの話
あるブートローダの話
 
20120519_qpstudy 2012.05 いやらしい@hasegawのI/O入門
20120519_qpstudy 2012.05 いやらしい@hasegawのI/O入門20120519_qpstudy 2012.05 いやらしい@hasegawのI/O入門
20120519_qpstudy 2012.05 いやらしい@hasegawのI/O入門
 
Extreme Assembler Tanka - eagle0wl
Extreme Assembler Tanka - eagle0wlExtreme Assembler Tanka - eagle0wl
Extreme Assembler Tanka - eagle0wl
 
About FeliCa Lite(日本語)
About FeliCa Lite(日本語)About FeliCa Lite(日本語)
About FeliCa Lite(日本語)
 
Trema day 1
Trema day 1Trema day 1
Trema day 1
 
/proc/irq/&lt;irq>/smp_affinity
/proc/irq/&lt;irq>/smp_affinity/proc/irq/&lt;irq>/smp_affinity
/proc/irq/&lt;irq>/smp_affinity
 
ASAMAP 開発秘話
ASAMAP 開発秘話ASAMAP 開発秘話
ASAMAP 開発秘話
 
Exploring the x64
Exploring the x64Exploring the x64
Exploring the x64
 
Kiso sekkei 01rev03
Kiso sekkei 01rev03Kiso sekkei 01rev03
Kiso sekkei 01rev03
 
UVLOの等価回路モデル作成方法
UVLOの等価回路モデル作成方法UVLOの等価回路モデル作成方法
UVLOの等価回路モデル作成方法
 
4章 Linuxカーネル - 割り込み・例外 2
4章 Linuxカーネル - 割り込み・例外 24章 Linuxカーネル - 割り込み・例外 2
4章 Linuxカーネル - 割り込み・例外 2
 
第1回【CCNA】ネットワーク基礎講座‗なにわTECH道171208
第1回【CCNA】ネットワーク基礎講座‗なにわTECH道171208第1回【CCNA】ネットワーク基礎講座‗なにわTECH道171208
第1回【CCNA】ネットワーク基礎講座‗なにわTECH道171208
 
Dalvik仮想マシンのアーキテクチャ 改訂版
Dalvik仮想マシンのアーキテクチャ 改訂版Dalvik仮想マシンのアーキテクチャ 改訂版
Dalvik仮想マシンのアーキテクチャ 改訂版
 
Reconf 201901
Reconf 201901Reconf 201901
Reconf 201901
 
BitVisor Summit 7「8. ベアメタルクラウドにおけるハードウェア保護に関する研究 & Advent Calendar について」
BitVisor Summit 7「8. ベアメタルクラウドにおけるハードウェア保護に関する研究 & Advent Calendar について」BitVisor Summit 7「8. ベアメタルクラウドにおけるハードウェア保護に関する研究 & Advent Calendar について」
BitVisor Summit 7「8. ベアメタルクラウドにおけるハードウェア保護に関する研究 & Advent Calendar について」
 
JTAGを使ってみよう
JTAGを使ってみようJTAGを使ってみよう
JTAGを使ってみよう
 
[TL06] 日本の第一人者が C# の現状と今後を徹底解説! 「この素晴らしい C# に祝福を!」
[TL06] 日本の第一人者が C# の現状と今後を徹底解説! 「この素晴らしい C# に祝福を!」[TL06] 日本の第一人者が C# の現状と今後を徹底解説! 「この素晴らしい C# に祝福を!」
[TL06] 日本の第一人者が C# の現状と今後を徹底解説! 「この素晴らしい C# に祝福を!」
 
Polyphony の行く末(2018/3/3)
Polyphony の行く末(2018/3/3)Polyphony の行く末(2018/3/3)
Polyphony の行く末(2018/3/3)
 

More from Kentaro Ebisawa

More from Kentaro Ebisawa (20)

P4 Updates (2020) (Japanese)
P4 Updates (2020) (Japanese)P4 Updates (2020) (Japanese)
P4 Updates (2020) (Japanese)
 
Barefoot Faster™ 日本語紹介
Barefoot Faster™ 日本語紹介Barefoot Faster™ 日本語紹介
Barefoot Faster™ 日本語紹介
 
IETF106 Hackathon 報告 & P4 based Switch の課題と未来
IETF106 Hackathon 報告 & P4 based Switch の課題と未来IETF106 Hackathon 報告 & P4 based Switch の課題と未来
IETF106 Hackathon 報告 & P4 based Switch の課題と未来
 
MPLS Japan 2019 : Data & Control Plane を繋ぐ API
MPLS Japan 2019 : Data & Control Plane を繋ぐ APIMPLS Japan 2019 : Data & Control Plane を繋ぐ API
MPLS Japan 2019 : Data & Control Plane を繋ぐ API
 
Yang Tools Quick Memo
Yang Tools Quick MemoYang Tools Quick Memo
Yang Tools Quick Memo
 
In Network Computing Prototype Using P4 at KSC/KREONET 2019
In Network Computing Prototype Using P4 at KSC/KREONET 2019In Network Computing Prototype Using P4 at KSC/KREONET 2019
In Network Computing Prototype Using P4 at KSC/KREONET 2019
 
Comparison of SRv6 Extensions uSID, SRv6+, C-SRH
Comparison of SRv6 Extensions uSID, SRv6+, C-SRHComparison of SRv6 Extensions uSID, SRv6+, C-SRH
Comparison of SRv6 Extensions uSID, SRv6+, C-SRH
 
Interop2019 Toyota Netcope P4
Interop2019 Toyota Netcope P4Interop2019 Toyota Netcope P4
Interop2019 Toyota Netcope P4
 
IETF 104 Hackathon VPP Prototyping Stateless SRv6/GTP-U Translation
IETF 104 Hackathon VPP Prototyping Stateless SRv6/GTP-U TranslationIETF 104 Hackathon VPP Prototyping Stateless SRv6/GTP-U Translation
IETF 104 Hackathon VPP Prototyping Stateless SRv6/GTP-U Translation
 
p4srv6 (P4-16) design document rev1.0
p4srv6 (P4-16) design document rev1.0p4srv6 (P4-16) design document rev1.0
p4srv6 (P4-16) design document rev1.0
 
SRv6 Mobile User Plane : Initial POC and Implementation
SRv6 Mobile User Plane : Initial POC and ImplementationSRv6 Mobile User Plane : Initial POC and Implementation
SRv6 Mobile User Plane : Initial POC and Implementation
 
JANOG43 Forefront of SRv6, Open Source Implementations
JANOG43 Forefront of SRv6, Open Source ImplementationsJANOG43 Forefront of SRv6, Open Source Implementations
JANOG43 Forefront of SRv6, Open Source Implementations
 
Using GTP on Linux with libgtpnl
Using GTP on Linux with libgtpnlUsing GTP on Linux with libgtpnl
Using GTP on Linux with libgtpnl
 
GTPing, How To
GTPing, How ToGTPing, How To
GTPing, How To
 
"SRv6の現状と展望" ENOG53@上越
"SRv6の現状と展望" ENOG53@上越"SRv6の現状と展望" ENOG53@上越
"SRv6の現状と展望" ENOG53@上越
 
SRv6 Mobile User Plane P4 proto-type
SRv6 Mobile User Plane P4 proto-typeSRv6 Mobile User Plane P4 proto-type
SRv6 Mobile User Plane P4 proto-type
 
Zebra SRv6 CLI on Linux Dataplane (ENOG#49)
Zebra SRv6 CLI on Linux Dataplane (ENOG#49)Zebra SRv6 CLI on Linux Dataplane (ENOG#49)
Zebra SRv6 CLI on Linux Dataplane (ENOG#49)
 
Zebra 2.0 in Hybrid Cloud Era
Zebra 2.0 in Hybrid Cloud EraZebra 2.0 in Hybrid Cloud Era
Zebra 2.0 in Hybrid Cloud Era
 
p4alu: Arithmetic Logic Unit in P4
p4alu: Arithmetic Logic Unit in P4p4alu: Arithmetic Logic Unit in P4
p4alu: Arithmetic Logic Unit in P4
 
zebra & openconfigd Introduction
zebra & openconfigd Introductionzebra & openconfigd Introduction
zebra & openconfigd Introduction
 

Recently uploaded

2024年5月25日Serverless Meetup大阪 アプリケーションをどこで動かすべきなのか.pptx
2024年5月25日Serverless Meetup大阪 アプリケーションをどこで動かすべきなのか.pptx2024年5月25日Serverless Meetup大阪 アプリケーションをどこで動かすべきなのか.pptx
2024年5月25日Serverless Meetup大阪 アプリケーションをどこで動かすべきなのか.pptx
ssuserbefd24
 

Recently uploaded (11)

2024年5月25日Serverless Meetup大阪 アプリケーションをどこで動かすべきなのか.pptx
2024年5月25日Serverless Meetup大阪 アプリケーションをどこで動かすべきなのか.pptx2024年5月25日Serverless Meetup大阪 アプリケーションをどこで動かすべきなのか.pptx
2024年5月25日Serverless Meetup大阪 アプリケーションをどこで動かすべきなのか.pptx
 
論文紹介: Exploiting semantic segmentation to boost reinforcement learning in vid...
論文紹介: Exploiting semantic segmentation to boost reinforcement learning in vid...論文紹介: Exploiting semantic segmentation to boost reinforcement learning in vid...
論文紹介: Exploiting semantic segmentation to boost reinforcement learning in vid...
 
LoRaWAN 4チャンネル電流センサー・コンバーター CS01-LB 日本語マニュアル
LoRaWAN 4チャンネル電流センサー・コンバーター CS01-LB 日本語マニュアルLoRaWAN 4チャンネル電流センサー・コンバーター CS01-LB 日本語マニュアル
LoRaWAN 4チャンネル電流センサー・コンバーター CS01-LB 日本語マニュアル
 
2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx
2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx
2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx
 
YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)
YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)
YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)
 
20240523_IoTLT_vol111_kitazaki_v1___.pdf
20240523_IoTLT_vol111_kitazaki_v1___.pdf20240523_IoTLT_vol111_kitazaki_v1___.pdf
20240523_IoTLT_vol111_kitazaki_v1___.pdf
 
5/22 第23回 Customer系エンジニア座談会のスライド 公開用 西口瑛一
5/22 第23回 Customer系エンジニア座談会のスライド 公開用 西口瑛一5/22 第23回 Customer系エンジニア座談会のスライド 公開用 西口瑛一
5/22 第23回 Customer系エンジニア座談会のスライド 公開用 西口瑛一
 
論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes
論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes
論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes
 
Amazon Cognitoで実装するパスキー (Security-JAWS【第33回】 勉強会)
Amazon Cognitoで実装するパスキー (Security-JAWS【第33回】 勉強会)Amazon Cognitoで実装するパスキー (Security-JAWS【第33回】 勉強会)
Amazon Cognitoで実装するパスキー (Security-JAWS【第33回】 勉強会)
 
MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。
MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。
MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。
 
【AI論文解説】Consistency ModelとRectified Flow
【AI論文解説】Consistency ModelとRectified Flow【AI論文解説】Consistency ModelとRectified Flow
【AI論文解説】Consistency ModelとRectified Flow
 

20111015 勉強会 (PCIe / SR-IOV)

  • 1. PCIe & SR IOV in virtual  PCIe & SR‐IOV in virtual environment 海老澤 健太郎 Twitter: @ebiken ebiken.g@gmail.com
  • 2. PCI コンフィグレーション空間 • デバイス上のFunction毎に存在するメモリ空間 • ドライバはここにアクセスすることによりデバイスを操作 • アクセス方法 – IO Port:起動時 or Legacy – MMIO : Memory Mapped IO d • フォーマットは3タイプ – Type 0 : non‐bridge function ype 0 : o b dge u ct o • 一般的なデバイスはこちら(NIC, DISK) – Type 1 : PCI‐to PCI Bridge • PCIe Switch で Packet Routing するための情報を含む – Type 2 : CardBus Bridge yp g • サイズ・配置 – PCIe = 4KByte (そのうち PCI 共通=256 Byte) – 64 B t : コンフィグレ ション空間ヘッダ部分(PCI共通部) Byte コンフィグレーション空間ヘッダ部分(PCI共通部) – 192 Byte :デバイス固有の領域(PCI共通部) 2
  • 3. PCI コンフィグレーション空間:配置 物理メモリ空間 SDRAM PCIメモリ空間 メインメモリ メインメモリ 4GB システムBIOS PCI用MMIO PCIデバイス 3GB メインメモリ メインメモリ 1MB 予約 シャドウRAM VGAビデオ VGAビデオ 0xa0000 コンベンショナルメモリ メインメモリ 0MB (640KB) 3
  • 4. Type 0 31 - 24 23 - 16 15 - 8 7-0 1 00h Device ID Vendor ID 2 04h Status Command 3 08h Class code Subclass Prog IF Revision ID 4 0Ch BIST Header type Latency Timer Cache Line Size 5 10h Base address #0 (BAR0) 6 14h Base address #1 (BAR1) 7 18h Base address #2 (BAR2) 8 1Ch Base address #3 (BAR3) 9 20h Base address #4 (BAR4) 10 24h Base address #5 (BAR5) 11 28h Cardbus CIS Pointer 12 2Ch Subsystem ID Subsystem Vendor ID 13 30h Expansion ROM base address Capabilities 14 34h Reserved Pointer 15 38h Reserved 16 3Ch Max latency M l t Min Grant Mi G t Interrupt PIN I t t Interrupt Line I t t Li 4
  • 5. コンフィグレーション空間 … PF on Host [root@dut 0000:03:00.1]# lspci –x 03:00.0 Ethernet controller: Intel Corporation 82599EB 10 Gigabit TN Network Connection (rev 01) Vendor ID = 8086 (Intel) Device ID = 151c (82599EB 10 Gigabit TN Network Connection) Header Type = 80 bit 7 : Multi function Command = 0407 bit 6‐0 : non‐bridge function bit 0 : IO enable bit 1 : Mem enable Revision ID = 01 Class code = 02 (Network Controller) Status = 0010 00: 86 80 1c 15 07 04 10 00 01 00 00 02 10 00 80 00 10: 04 00 20 df 00 00 00 00 c1 ec 00 00 00 00 00 00 20: 04 80 1f df 00 00 00 00 00 00 00 00 86 80 2c a0 30: 00 00 00 00 40 00 00 00 00 00 00 00 0e 02 00 00 BAR#01 = 0000 0000 df20 0004 (Mem, 64bit)  IRQ PIN = INTB# BAR#23 = 0000 0000 0000 ecc1 IRQ Line = 0e (IO, 32bit) BAR#45 = 0000 0000 df1f 8004 (M 0000 0000 df1f 8004 (Mem, 64bit) 64bi ) Subsystem Vendor ID = 8086 (Intel) PCI IDs = Vendor ID + Device ID Subsystem ID = a02c (***********) http://pciids.sourceforge.net/ p p g http://pci‐ids.ucw.cz/read/PC/8086 !!PCIはリトルエンディアン!! 5
  • 6. コンフィグレーション空間 … VF on Host [root@dut 0000:03:00.1]# lspci –x 03:10.0 Ethernet controller: Intel Corporation 82599 Ethernet Controller Virtual Function (rev 01) Vendor ID = ffff (n/a) / Device ID = ffff (n/a) Header Type = 80 bit 7 : Single function Command = 0004 bit 6‐0 : non‐bridge function bit 0 : IO disable bit 1 : Mem disable Revision ID = 01 Class code = 02 (Network Controller) Status = 0010 00: ff ff ff ff 04 00 10 00 01 00 00 02 00 00 00 00 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 20: 00 00 00 00 00 00 00 00 00 00 00 00 86 80 2c a0 30: 00 00 00 00 70 00 00 00 00 00 00 00 00 00 00 00 BAR#01 = 0000 0000 0000 0000 IRQ PIN = n/a BAR#23 = 0000 0000 0000 0000 IRQ Line = 00 BAR#45 = 0000 0000 0000 0000 0000 0000 0000 0000 Subsystem Vendor ID = 8086 (Intel) PCI IDs = Vendor ID + Device ID Subsystem ID = a02c (***********) http://pciids.sourceforge.net/ p p g http://pci‐ids.ucw.cz/read/PC/8086 !!PCIはリトルエンディアン!! 6
  • 7. コンフィグレーション空間 … VF on Guest [root@dutvm‐sriov ~]# lspci ‐ x 00:03.0 Ethernet controller: Intel Corporation 82559 Ethernet Controller Virtual Function (rev 01) Vendor ID = 8086 (Intel) Device ID = 10ed (82559 Ethernet Controller Virtual Function) Header Type = 80 bit 7 : Single function Command = 0407  bit 6‐0 : non‐bridge function bit 0 : IO enable bit 1 : Mem enable Revision ID = 01 Class code = 02 (Network Controller) Status = 0010 00: 86 80 ed 10 07 04 10 00 01 00 00 02 00 00 00 00 10: 00 00 02 f2 00 00 00 00 00 00 00 00 00 40 02 f2 20: 00 00 00 00 00 00 00 00 00 00 00 00 86 80 2c a0 30: 00 00 00 00 a0 00 00 00 00 00 00 00 00 00 00 00 BAR#0 = f202 0000 (Mem, 32bit) IRQ PIN = n/a BAR#3 = f202 4000 (Mem, 32bit) IRQ Line = 00 BAR#45 = 0000 0000 0000 0000 0000 0000 0000 0000 Subsystem Vendor ID = 8086 (Intel) PCI IDs = Vendor ID + Device ID Subsystem ID = a02c (***********) http://pciids.sourceforge.net/ p p g http://pci‐ids.ucw.cz/read/PC/8086 !!PCIはリトルエンディアン!! 7
  • 8. PF on Host [root@dut ~]# lspci ‐v ‐s 03:00.0 03:00.0 Ethernet controller: Intel Corporation 82599EB 10 Gigabit TN Network Connection (rev 01) Subsystem: Intel Corporation Device a02c b l i i Flags: bus master, fast devsel, latency 0, IRQ 45 Memory at df200000 (64‐bit, non‐prefetchable) [size=2M] I/O ports at ecc0 [size=32] Memory at df1f8000 (64‐bit, non‐prefetchable) [size=16K] Capabilities: [40] Power Management version 3 Capabilities: [50] MSI: Enable‐ Count=1/1 Maskable+ 64bit+ Capabilities: [70] MSI X: Enable Count=64 Masked‐ Capabilities: [70] MSI‐X: Enable+ Count 64 Masked Capabilities: [a0] Express Endpoint, MSI 00 Capabilities: [e0] Vital Product Data Capabilities: [100] Advanced Error Reporting Capabilities: [140] Device Serial Number 00‐1b‐21‐ff‐ff‐ce‐51‐c4 Capabilities: [140] Device Serial Number 00 1b 21 ff ff ce 51 c4 Capabilities: [150] Alternative Routing‐ID Interpretation (ARI) Capabilities: [160] Single Root I/O Virtualization (SR‐IOV) Kernel driver in use: ixgbe Kernel modules: ixgbe l d l i b 8
  • 9. VF on Host / Guest 比較 [root@dut ~]# lspci ‐v ‐s 03:10.0 03:10.0 Ethernet controller: Intel Corporation 82599 Ethernet Controller Virtual Function (rev 01) Subsystem: Intel Corporation Device a02c Subsystem: Intel Corporation Device a02c Flags: bus master, fast devsel, latency 0 [virtual] Memory at d0000000 (64‐bit, prefetchable) [size=16K] [virtual] Memory at d0100000 (64‐bit, prefetchable) [size=16K] Capabilities: [70] MSI‐X: Enable+ Count=3 Masked‐ p [ ] Capabilities: [a0] Express Endpoint, MSI 00 Capabilities: [100] Advanced Error Reporting Capabilities: [150] Alternative Routing‐ID Interpretation (ARI) Kernel driver in use: pci‐stub Kernel modules: ixgbevf l d l b f [root@dutvm‐sriov ~]# lspci ‐v ‐s 00:03.0 00:03.0 Ethernet controller: Intel Corporation 82559 Ethernet Controller Virtual Function (rev 01) Subsystem: Intel Corporation Device a02c Subsystem: Intel Corporation Device a02c Physical Slot: 3 Flags: bus master, fast devsel, latency 0 Memory at f2020000 (32‐bit, non‐prefetchable) [size=16K] Memory at f2024000 (32‐bit, non‐prefetchable) [size=16K] y ( , p )[ ] Capabilities: [a0] Express Endpoint, MSI 00 Capabilities: [70] MSI‐x: Enable+ Count=3 Masked‐ Kernel driver in use: ixgbevf Kernel modules: ixgbevf 9
  • 10. IO v.s. Memory ‐ Mapped IO • IO Mapped IO – IO port (IO空間) を利用 – IO空間のアドレス=IOポートアドレス、ポート番号 – 1,2,4 Byte単位でのRead/Write – IO Port専用のニーモニックがある。asm/io.h • MMIO : Memory Mapped IO – IO Portの代わりにメモリアクセスをハードウェアレベルでのデバイスへのアクセスに置換 – デバイスに割当られたアドレス範囲にメモリアクセスをすることにより、ドライバからデバイス のレジスタRead/Write可能 – ドライバが動作する「仮想メモリアドレス」と、MMIO確保された「物理メモリアドレス」の違いに 注意 • (PCIe Root Bridge <‐> Device) は共通 PCIe Layer (PCI R PCI L B id D i ) – Config TLP (Transaction Layer Packet) でアクセス • 共通の抽象的なインタ フェ ス有り 共通の抽象的なインターフェース有り – asm/iomap.h – void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max len); 10
  • 11. IO v.s. Memory ‐ Mapped IO • IO Ports, MMIO割当確認方法 – [root@hwn01 ~]# ls /proc/ | grep ^io – iomem – ioports [root@hwn01 ~]# cat /proc/ioports 0000‐0cf7 : PCI Bus 0000:00 0000‐001f : dma1 0020‐0021 : pic1 0040‐0043 : timer0 0050‐0053 : timer1 0050‐0053 : timer1 0060‐0060 : keyboard [root@hwn01 ~]# cat /proc/iomem 00000000‐0000ffff : reserved 00000000 0000ffff d 00010000‐0009f7ff : System RAM … f4000000‐f7ffffff : PCI MMCONFIG 0000 [bus 00‐3f] f4000000‐f7ffffff : reserved f4000000‐f7ffffff : pnp 00:0a fb400000‐fb7fffff : 0000:00:02.0 11
  • 12. メモ • MSI, MSI‐X の Configuration 空間パラメーターと、/proc/interrupt で見える割り込み番号の関係 – ??? • PCIe MSI, MSI‐X の処理方法 – NICからアドレス0xfeeに対しメモリ書き込み(DWORD Mem Write Mem Write  Transaction) • アドレスは初期化時 MSI Capability Registerにソフトウェア(BIOS??)がセット • 0xfeeはLocal APIC のレジスタへMemory Mapされている APIC のレジスタ Memory – LAPICがCPUへ割り込み通知(INTR) – CPU ⇒ LAPICへAck(INTA) – LAPIC⇒CPU:Vectorを返す • VFのBAR – VFのメモリ空間にはBARはない – PFのSR IOV C bilit R i t に設定 PFのSR‐IOV Capability Registerに設定 – Host の lspci ‐v はそちらを表示 12
  • 13. メモ • 空の PCI スロットのベ ンダ ID とデバイス ID を 読み取ろうとしたときは、0xFFFFFFFF というエ ラ メッセ ジが返る ラー メッセージが返る • BARは起動時にBIOSが割り当て – http://www.mnc.co.jp/intime/user/intimedev.php ?PCI%A5%B3%A5%F3%A5%D5%A5%A3%A5%B0% A5%EC%A1%BC%A5%B7%A5%E7%A5%F3%A5%EC %A5%B8%A5%B9%A5%BF 13
  • 14. 割り込み一覧(/proc/interrupts) [root@hwn01 ~]# cat /proc/interrupts CPU0 CPU1 CPU2 CPU3 0: 144 1 0 0 IO-APIC-edge timer 1: 3 0 1 2 IO-APIC-edge i8042 4: 4 0 1 1 0 IO-APIC-edge d 8: 33 58 31 57 IO-APIC-edge rtc0 9: 0 0 0 0 IO-APIC-fasteoi acpi 16: 0 0 0 0 IO-APIC-fasteoi ahci, uhci_hcd:usb3, uhci_hcd:usb9 17: 115 3 1 1 IO-APIC-fasteoi pata_jmicron, firewire_ohci 18: 2150 3669 117 284 IO-APIC-fasteoi ehci_hcd:usb1, uhci_hcd:usb5, uhci_hcd:usb8 19: 51447 1305 39191 1307 IO-APIC-fasteoi ata_piix, ata_piix, uhci_hcd:usb7 21: 0 0 0 0 IO-APIC-fasteoi uhci_hcd:usb4 23: 0 0 0 0 IO-APIC-fasteoi ehci_hcd:usb2, uhci_hcd:usb6 41: 58395 289 3073 269 PCI-MSI-edge i915@pci:0000:00:02.0 42: 47 50 47 52 PCI-MSI-edge hda_intel 43: 2710 6576 3336 3655 PCI-MSI-edge eth0 44: 0 0 0 1 PCI-MSI-edge xhci_hcd 45: 0 0 0 0 PCI-MSI-edge xhci_hcd 46: 0 0 0 0 PCI-MSI-edge xhci_hcd 47: 0 0 0 0 PCI-MSI-edge xhci_hcd 48: 0 0 0 0 PCI-MSI-edge xhci_hcd 49: 2985 6 648 5 PCI-MSI-edge eth1 NMI: 13 34 95 28 Non-maskable interrupts LOC: 332011 170933 296037 190006 Local timer interrupts SPU: 0 0 0 0 Spurious interrupts PMI: 13 34 95 28 Performance monitoring interrupts IWI: 0 0 0 0 IRQ work interrupts RES: 452195 37148 103501 14434 Rescheduling interrupts g p CAL: 812 6027 1044 7911 Function call interrupts TLB: 1077 644 2068 824 TLB shootdowns TRM: 0 0 0 0 Thermal event interrupts THR: 0 0 0 0 Threshold APIC interrupts MCE: 0 0 0 0 Machine check exceptions MCP: 29 28 28 28 Machine check polls ERR: 0 MIS: 0 14