Intel 82599 10GbE
Controllerで遊ぼう
      @syuu1228
おいくらまんえん?


• 1枚5万くらいかな?
Spec
•   PCIe 2.0 x8
•   15.5KB Jumbo frames
•   128 Tx / 128 Rx Queues
•   Rx Queue Assignment
    •   RSS
    •   Flow Director
    •   L2, L3, L4 Filters
    •   SYN Packet Filters
•   Virtualization Support(SR-IOV,VMDq)
•   VLAN, FCoE Support
•   Direct Cache Access
•   etc, etc...
• Disabling RSS on the fly is not allowed, and the 82599 must be reset after RSS is disabled.
 • When RSS is disabled, packets are assigned an RSS output index = zero.

When multiple request queues are enabled in RSS mode, un-decodable packets are assigned an RSS



             Receive Side Scaling
output index = zero. The 32-bit tag (normally a result of the hash function) equals zero.




                  Parsed receive packet




                                                   Redirection Table
                       RSS hash
                                                        128 x 4



                                        7 LS   7
                                        bits
                         32                                                0

                                                         4

                                                                                RSS Disable or (RSS
                    Packet Descriptor
                                                                                 & not decodable)


                                                                  4

                                                             RSS output index


Figure 7.10. RSS Block Diagram
     src-ip, src-port, dst-ip, dst-portからハッシュ値
      を作成、Redirection Tableを参照してキュー
Receive Side Scaling?


• RSSとか初めて聞いた、って人はこのへ
 んを読んできてね♪
 http://bit.ly/rqGJBJ
Queue Assignmentの最適化
 (RFS hardware acceleration)
       CPU0   CPU1     CPU2       CPU3

                      プロセスA      プロセスB



                     プロセス起床      プロセス起床




                     ネットワーク     ネットワーク
                      スタック       スタック




                     割り込みハンドラ   割り込みハンドラ




                       バッファ       バッファ




サーバでは、パケットの宛先プロセスが居る
   CPUへ割り込む方が効率が良い
• Disabling RSS on the fly is not allowed, and the 82599 must be reset after RSS is disabled.
 • When RSS is disabled, packets are assigned an RSS output index = zero.

When multiple request queues are enabled in RSS mode, un-decodable packets are assigned an RSS


      Receive Side Scalingの制限
output index = zero. The 32-bit tag (normally a result of the hash function) equals zero.




                  Parsed receive packet

                                                                            128フローしか
                                                   Redirection Table
                                                                                識別出来ない
                       RSS hash
                                                        128 x 4



                                        7 LS   7
                                        bits
                         32                                                0

                                                         4

                                                                                  RSS Disable or (RSS
                    Packet Descriptor
                                                                                   & not decodable)
                    32bitのハッシュ値のうち
                       4bitしか使ってない                                4

                                                             RSS output index


Figure 7.10. RSS Block Diagram
      フローが多いとハッシュ衝突する為、特定フローを
              特定CPUへキューするのには向いていない
Flow Director
•   32kのハッシュテーブルの先にリンクドリスト

•   2つのFilter mode

    •   Signature Mode:ハッシュ値
        最大32k個

    •   Perfect Match Mode:ヘッダの完全マッチ
        (dst-ip, dst-port, src-ip, src-port, protocol)
        最大8k個
ets by a hash function on the relevant tuples as defined by the FDIR...M registers. Each bucke
nized in a linked list indicated by the hash lookup table. Buckets can have a variable length wh
 st filter in each bucket is indicated as a last. There is no upper limit for a linked list length du


                                          Flow Director
 amming; however, a received packet that matches a filter that exceeds the FDIRCTRL.Max-Len
eported to software (see Section 7.1.2.7.5).




             Logic AND of Rx Packet tuples with
              the Flexible filters Mask registers                              Flow ID Fields in “Perfect Match mode”


                                   ~350                  Hash (Signature)
                                                                               Flow ID Field in “Signature mode”
                                                           15 bit output

                           Hash
                        15 bit output
                                                    Hash-Index = 0     Hash-Index = 1            Hash-Index = N    Hash-Index = N+1

                                   15 bit address    Flow ID fields     Flow ID fields            Flow ID fields     Flow ID fields
                                                      Filter Action      Filter Action     ...     Filter Action      Filter Action   ...
        Addr
         0 Bucket Valid First Filter PTR             Collision flag     Collision flag            Collision flag     Collision flag
                                                    Next Filter PTR    Next Filter PTR           Next Filter PTR    Next Filter PTR
         1     Bucket Valid First Filter PTR
         2     Bucket Valid First Filter PTR
                                                                                    Bucket 0 (linked list 0)
        ...            ...                                                                                            ‘too long’
         M Bucket Valid First Filter PTR            Hash-Index = 0     Hash-Index = 1                                 Linked list
        ...                  ...                     Flow ID fields     Flow ID fields
        32K Bucket Valid First Filter PTR             Filter Action      Filter Action
                                                     Collision flag     Collision flag           Max recommended linked list length
                                                    Next Filter PTR    Next Filter PTR               (FDIRCTRL.Max-Length)

                 Hash Lookup Table                       Bucket M (linked list M)
                     Shares the Rx
              packet buffer memory space                       Flexible Filters table - Shares the Rx packet buffer memory space
Linuxでの利用例#1(自動)
          Flow
        Director    Txq
         Filters
                                 NIC



        フィルタ
                   送信処理
         更新

                            ドライバ

                   プロトコル
                   スタック


                   ソケット


                       システムコール

                    proce
                      ss



プロセスコンテキストからのパケット送出時に送信
元CPUとパケットヘッダを用いてフィルタを更新
Linuxでの利用例#2(手動)
•   ethtoolからフィルタをマニュアル追加
    ethtool -K ntuple on
    ethtool -U eth0 flow-type udp4 src-ip 0xa0a0a000
    src-ip-mask 0xFFFFFF00 dst-ip 0 dst-ip-mask 0
    src-port 9 src-port-mask 0 dst-port 9
    ethtool -U eth0 flow-type tcp4 vlan 100 vlan-mask
    0xF000 action 8
•   フィルタの表示
    ethtool -u eth0
FreeBSDでは?
•   利用例1の機能は試験的に実装されている
    が、問題があって性能が出ない為か無効化
    されている

•   利用例2の機能はそもそもethtoolコマンドが
    無い
    代わりのコマンドもioctlインタフェースもな
    い
そうだsysctl増やそう

• こんな風に打ったらフィルタ設定でき
 ればいいんじゃね?
 $ sysctl dev.ix.0.set_fdir_signature="tcpv4
 10.0.0.2:47390 10.0.0.1:22 10"
 $ sysctl dev.ix.0.clear_fdir_signature="tcpv4
 10.0.0.2:47390 10.0.0.1:22"
作ってみた


• Adding Flow Director sysctls to ixgbe(4)
  http://bit.ly/p4eK0u
デベロッパーの皆様の反応
•   ごめん、そもそもIntelのドライバは「OS共通部分」があって、WindowsでもSolarisでも使って
    て、その部分にあまり手を入れられると困るんだよね、基本的にIntelで作ってるコードそのま
    ま使う方針だから

•   Linuxにはethtoolにgenericなインタフェースがあるけど、FreeBSDも同じようにした方が良く
    ね?

•   ifconfigにオプションふやそーぜ!

•   でも、この手の機能はNICによって大きく違うので、一旦適切ではないgenericなインタフェー
    スを定義してしまうと面倒な事になるよ

•   Linuxでは定義する時にちょっとしくって古いインタフェースと新しいインタフェースの2つが
    出来ちゃったよ

•   話しそれるけど、ソケットAPIからCPUがpin出来ればいいんじゃないかなぁ

•   (例1のように)カーネルで透過的に出来るといいよねー

    •    それLinuxだとRFSとXPSで出来るよ!読んでみて!
で、どうすれば。

• ←あんまり議論に参加出来てない
• 次の一手は何をするのが良いんだろ
 う?

Intel 82599 10GbE Controllerで遊ぼう

  • 1.
  • 2.
  • 6.
    Spec • PCIe 2.0 x8 • 15.5KB Jumbo frames • 128 Tx / 128 Rx Queues • Rx Queue Assignment • RSS • Flow Director • L2, L3, L4 Filters • SYN Packet Filters • Virtualization Support(SR-IOV,VMDq) • VLAN, FCoE Support • Direct Cache Access • etc, etc...
  • 7.
    • Disabling RSSon the fly is not allowed, and the 82599 must be reset after RSS is disabled. • When RSS is disabled, packets are assigned an RSS output index = zero. When multiple request queues are enabled in RSS mode, un-decodable packets are assigned an RSS Receive Side Scaling output index = zero. The 32-bit tag (normally a result of the hash function) equals zero. Parsed receive packet Redirection Table RSS hash 128 x 4 7 LS 7 bits 32 0 4 RSS Disable or (RSS Packet Descriptor & not decodable) 4 RSS output index Figure 7.10. RSS Block Diagram src-ip, src-port, dst-ip, dst-portからハッシュ値 を作成、Redirection Tableを参照してキュー
  • 8.
    Receive Side Scaling? •RSSとか初めて聞いた、って人はこのへ んを読んできてね♪ http://bit.ly/rqGJBJ
  • 9.
    Queue Assignmentの最適化 (RFShardware acceleration) CPU0 CPU1 CPU2 CPU3 プロセスA プロセスB プロセス起床 プロセス起床 ネットワーク ネットワーク スタック スタック 割り込みハンドラ 割り込みハンドラ バッファ バッファ サーバでは、パケットの宛先プロセスが居る CPUへ割り込む方が効率が良い
  • 10.
    • Disabling RSSon the fly is not allowed, and the 82599 must be reset after RSS is disabled. • When RSS is disabled, packets are assigned an RSS output index = zero. When multiple request queues are enabled in RSS mode, un-decodable packets are assigned an RSS Receive Side Scalingの制限 output index = zero. The 32-bit tag (normally a result of the hash function) equals zero. Parsed receive packet 128フローしか Redirection Table 識別出来ない RSS hash 128 x 4 7 LS 7 bits 32 0 4 RSS Disable or (RSS Packet Descriptor & not decodable) 32bitのハッシュ値のうち 4bitしか使ってない 4 RSS output index Figure 7.10. RSS Block Diagram フローが多いとハッシュ衝突する為、特定フローを 特定CPUへキューするのには向いていない
  • 11.
    Flow Director • 32kのハッシュテーブルの先にリンクドリスト • 2つのFilter mode • Signature Mode:ハッシュ値 最大32k個 • Perfect Match Mode:ヘッダの完全マッチ (dst-ip, dst-port, src-ip, src-port, protocol) 最大8k個
  • 12.
    ets by ahash function on the relevant tuples as defined by the FDIR...M registers. Each bucke nized in a linked list indicated by the hash lookup table. Buckets can have a variable length wh st filter in each bucket is indicated as a last. There is no upper limit for a linked list length du Flow Director amming; however, a received packet that matches a filter that exceeds the FDIRCTRL.Max-Len eported to software (see Section 7.1.2.7.5). Logic AND of Rx Packet tuples with the Flexible filters Mask registers Flow ID Fields in “Perfect Match mode” ~350 Hash (Signature) Flow ID Field in “Signature mode” 15 bit output Hash 15 bit output Hash-Index = 0 Hash-Index = 1 Hash-Index = N Hash-Index = N+1 15 bit address Flow ID fields Flow ID fields Flow ID fields Flow ID fields Filter Action Filter Action ... Filter Action Filter Action ... Addr 0 Bucket Valid First Filter PTR Collision flag Collision flag Collision flag Collision flag Next Filter PTR Next Filter PTR Next Filter PTR Next Filter PTR 1 Bucket Valid First Filter PTR 2 Bucket Valid First Filter PTR Bucket 0 (linked list 0) ... ... ‘too long’ M Bucket Valid First Filter PTR Hash-Index = 0 Hash-Index = 1 Linked list ... ... Flow ID fields Flow ID fields 32K Bucket Valid First Filter PTR Filter Action Filter Action Collision flag Collision flag Max recommended linked list length Next Filter PTR Next Filter PTR (FDIRCTRL.Max-Length) Hash Lookup Table Bucket M (linked list M) Shares the Rx packet buffer memory space Flexible Filters table - Shares the Rx packet buffer memory space
  • 13.
    Linuxでの利用例#1(自動) Flow Director Txq Filters NIC フィルタ 送信処理 更新 ドライバ プロトコル スタック ソケット システムコール proce ss プロセスコンテキストからのパケット送出時に送信 元CPUとパケットヘッダを用いてフィルタを更新
  • 14.
    Linuxでの利用例#2(手動) • ethtoolからフィルタをマニュアル追加 ethtool -K ntuple on ethtool -U eth0 flow-type udp4 src-ip 0xa0a0a000 src-ip-mask 0xFFFFFF00 dst-ip 0 dst-ip-mask 0 src-port 9 src-port-mask 0 dst-port 9 ethtool -U eth0 flow-type tcp4 vlan 100 vlan-mask 0xF000 action 8 • フィルタの表示 ethtool -u eth0
  • 15.
    FreeBSDでは? • 利用例1の機能は試験的に実装されている が、問題があって性能が出ない為か無効化 されている • 利用例2の機能はそもそもethtoolコマンドが 無い 代わりのコマンドもioctlインタフェースもな い
  • 16.
    そうだsysctl増やそう • こんな風に打ったらフィルタ設定でき ればいいんじゃね? $ sysctl dev.ix.0.set_fdir_signature="tcpv4 10.0.0.2:47390 10.0.0.1:22 10" $ sysctl dev.ix.0.clear_fdir_signature="tcpv4 10.0.0.2:47390 10.0.0.1:22"
  • 17.
    作ってみた • Adding FlowDirector sysctls to ixgbe(4) http://bit.ly/p4eK0u
  • 18.
    デベロッパーの皆様の反応 • ごめん、そもそもIntelのドライバは「OS共通部分」があって、WindowsでもSolarisでも使って て、その部分にあまり手を入れられると困るんだよね、基本的にIntelで作ってるコードそのま ま使う方針だから • Linuxにはethtoolにgenericなインタフェースがあるけど、FreeBSDも同じようにした方が良く ね? • ifconfigにオプションふやそーぜ! • でも、この手の機能はNICによって大きく違うので、一旦適切ではないgenericなインタフェー スを定義してしまうと面倒な事になるよ • Linuxでは定義する時にちょっとしくって古いインタフェースと新しいインタフェースの2つが 出来ちゃったよ • 話しそれるけど、ソケットAPIからCPUがpin出来ればいいんじゃないかなぁ • (例1のように)カーネルで透過的に出来るといいよねー • それLinuxだとRFSとXPSで出来るよ!読んでみて!
  • 19.