(四)DPDK-PMD

Ethernet controller overview

圖1 

PHY (物理層的模擬信號)  ----> MAC(數字信號) ---->FIFO(buff 先進先出)---->

DMA&Queue mangement  (維護管理多個Queue   DMA描述符環形隊列 把網卡數據搬移到內存or緩存過程)---->

PCIe (主機和網卡的接口 )

SR-IOV引入了兩個新的功能類型:

  • PFs(Physical Functions,物理功能):物理網卡所支持的一項PCI功能,一個PF可以擴展出若干個VF。
  • VFs(Virtual Functions,虛擬功能):支持SR-IOV的物理網卡虛擬出來的實例,以一個獨立網卡的形式呈現,每個VF有獨立的PCI配置區域,並可以與其它VF共享同一個物理資源(共用同一個物理網口

 對於DPDK 都是一個device (portid)

Rx Descriptors

 

Read和Write-Back 都是對網卡來說的 (網卡Read這個Descriptors格式是什麼 ,不是CPU read)

Read 

Write-Back : 網卡發完了 通知host  

Tx Descriptors

 

 

 Ring

 

DMA(Direct Memory Access,直接存儲器訪問)是一種高速的數據傳輸方式,允許在外部設備和存儲器之間直接讀寫數據。數據既不通過CPU,也不需要CPU干預。整個數據傳輸操作在DMA控制器的控制下進行。網卡DMA控制器通過環形隊列與CPU交互。環形隊列的內容部分位於主存中,控制部分通過訪問外設寄存器的方式完成。 

Rx Overview

 

Tx Overview

 

 

DPDK PMD driver

DPDK  Architecture 

UIO Picture

 

UIO: 通過mmap 把地址映射到 用戶空間    用戶空間的pmd 可以像操作內存那樣操作設備 

Mbuf

 

現在增加後擴展到兩個cacheline  

Mempool and mbuf

Create mbuf pool rte_pktmbuf_pool_create” in application initilization

NB_MBUF = nb_ports*nb_rx_queue*nb_rx_desc +

                          nb_ports*nb_tx_queue*nb_tx_desc +

                          nb_ports*nb_lcores*MAX_PKT_BURST

                          nb_lcores*MEMPOOL_CACHE_SIZE

Allocate mbuf rte_rxmbuf_allocin rx_pkt_burst function                                         (收包方向)

Free mbuf “rte_pktmbuf_free_seg”/ “rte_pktmbuf_free” in tx_pkt_burst function  (發包反向)

PMD Logical View

Hardware PMDs通過編程  NIC的寄存器  或 封裝ND Shared code.來實現dpdk以太網設備抽象 

drivers/net/

PS: 綠色爲真實的物理網卡 

Ethernet Device Framework

  

數據結構

Example DPDK Network Application

 

一些概念 

Bursting (突發)

  • Multiple buffers can be allocated, and sometimes freed, at once, removing per-packet overhead(開銷)

Scattered(分散) (針對大包)

  • Multi-segmented rte_mbuf  
  • EOP flag in descriptor indicates if the descriptor is the last one of the packet.

Threshold (閾值) (發了多個包之後 在去寫寄存器)

  • rx_free_thresh: Drives the freeing of RX descriptors
  • tx_rs_thresh : Drives the setting of RS bit on TXDs
  • tx_free_thresh : Start freeing TX buffers if there are less free descriptors than this value

Number of descriptors on queue

   隊列上的描述符數   就是這個Ring有多長(給CPU一個緩存的空間)

Bulk

 

Vector PMD

利用intel寬指令集實現的收發包函數

NIC Features

RX HW offload

rt u mbuf->ol_flags    標誌表示RX卸載狀態

 

Pack type

rte_mbuf->ptype  根據NIC的解析 指明數據包類型。

Example

  •   RTE_PTYPE_L2_ETHER |
  •   RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
  •   RTE_PTYPE_L4_TCP

 

Receive classification filters(接收分類篩選器)

 

MAC VLAN filtering/Internal Switch (mac-vlan過濾/內部交換機)

 

RSS – Receive Side Scaling (接收端縮放)

 Flow director(流量控制器)

Tx HW offload

 

VLAN Insert

Checksum offload

TSO

 

More advanced features

 

Virtrulization

SRIOV

VMDQ

QoS

DCB

Tx Schedule

Mirroring

Tunnel supporting

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章