vpp与dpdk的关系

dpdk作为vpp的一个插件,主要用来从网卡收发包。

vpp使用如下命令参数初始化dpdk eal。

EAL init args: -c a -n 1 --in-memory --huge-dir /mnt/hugepages --no-pci --proc-type primary --file-prefix vpp --master-lcore 1

dpdk初始化流程

读取配置

dpdk_config

初始化库

dpdk_lib_init

注册节点

  • 输入节点
dpdk_device_inpu
  • 输出节点

    • 接口tx function的赋值

      VNET_DEVICE_CLASS_TX_FN (dpdk_device_class)
      
    • 接口output node和tx node的初始化

网口操作

/* A class of hardware interface devices. */
/* 一类硬件接口的操作函数集合,这些函数是在硬件设备的驱动上封装的一层 */
typedef struct _vnet_device_class
{/* Index into main vector.类索引 */u32 index;/* Device name (e.g. "FOOBAR 1234a").设备类名字 */char *name;/* Function to call when hardware interface is added/deleted. *//* 添加/删除一个该类设备的实例函数 */vnet_interface_function_t *interface_add_del_function;/* Function to bring device administratively up/down. *//* 设备UP/DOWN操作函数 */vnet_interface_function_t *admin_up_down_function;/* Function to call when sub-interface is added/deleted *//* 以该类型设备为主设备,添加/删除一个子接口的函数 */vnet_subif_add_del_function_t *subif_add_del_function;/* Function to call interface rx mode is changed *//* 接收模式变化函数 */vnet_interface_set_rx_mode_function_t *rx_mode_change_function;/* Function to call interface l2 mode is changed *//* 接口的二层模式变化操作函数 */vnet_interface_set_l2_mode_function_t *set_l2_mode_function;/* Redistribute flag changes/existence of this interface class. */u32 redistribute;/* Transmit function. *//* 发送函数 */vlib_node_function_t *tx_function;/* Transmit function candidate registration with priority *//* 注册的多个候选的发送函数,最终根据优先级选择一个最高的赋值给tx_function */vlib_node_fn_registration_t *tx_fn_registrations;/* Error strings indexed by error code for this node. *//* 发送函数错误原因字符数组 */char **tx_function_error_strings;/* Number of error codes used by this node. *//* tx_function_error_strings数组大小 */u32 tx_function_n_errors;/* Renumber device name [only!] support, a control-plane kludge */int (*name_renumber) (struct vnet_hw_interface_t * hi,u32 new_dev_instance);/* Interface flow offload operations *//* 流量卸载功能操作函数集合 */                      vnet_flow_dev_ops_function_t *flow_ops_function;/* Format device instance as name. */format_function_t *format_device_name;/* Parse function for device name. */unformat_function_t *unformat_device_name;/* Format device verbosely for this class. */format_function_t *format_device;/* Trace buffer format for TX function. */format_function_t *format_tx_trace;/* Format flow offload entry */format_function_t *format_flow;/* Function to clear hardware counters for device. *//* 清除统计函数 */void (*clear_counters) (u32 dev_class_instance);uword (*is_valid_class_for_interface) (struct vnet_main_t * vnm,u32 hw_if_index,u32 hw_class_index);/* Called when hardware class of an interface changes. */void (*hw_class_change) (struct vnet_main_t * vnm,u32 hw_if_index, u32 new_hw_class_index);/* Called to redirect traffic from a specific interface instance *//* 强制重定向一个接口的流量到指定的node */                         void (*rx_redirect_to_node) (struct vnet_main_t * vnm,u32 hw_if_index, u32 node_index);/* Link-list of all device classes set up by constructors created below *//* 形成链表 */struct _vnet_device_class *next_class_registration;/* Function to set mac address. *//* 链路层地址变化函数 */vnet_interface_set_mac_address_function_t *mac_addr_change_function;
} vnet_device_class_t;

vpp中dpdk内存管理

#mermaid-svg-Yw0Yn4uJMBfsWsgB .label{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);fill:#333;color:#333}#mermaid-svg-Yw0Yn4uJMBfsWsgB .label text{fill:#333}#mermaid-svg-Yw0Yn4uJMBfsWsgB .node rect,#mermaid-svg-Yw0Yn4uJMBfsWsgB .node circle,#mermaid-svg-Yw0Yn4uJMBfsWsgB .node ellipse,#mermaid-svg-Yw0Yn4uJMBfsWsgB .node polygon,#mermaid-svg-Yw0Yn4uJMBfsWsgB .node path{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-Yw0Yn4uJMBfsWsgB .node .label{text-align:center;fill:#333}#mermaid-svg-Yw0Yn4uJMBfsWsgB .node.clickable{cursor:pointer}#mermaid-svg-Yw0Yn4uJMBfsWsgB .arrowheadPath{fill:#333}#mermaid-svg-Yw0Yn4uJMBfsWsgB .edgePath .path{stroke:#333;stroke-width:1.5px}#mermaid-svg-Yw0Yn4uJMBfsWsgB .flowchart-link{stroke:#333;fill:none}#mermaid-svg-Yw0Yn4uJMBfsWsgB .edgeLabel{background-color:#e8e8e8;text-align:center}#mermaid-svg-Yw0Yn4uJMBfsWsgB .edgeLabel rect{opacity:0.9}#mermaid-svg-Yw0Yn4uJMBfsWsgB .edgeLabel span{color:#333}#mermaid-svg-Yw0Yn4uJMBfsWsgB .cluster rect{fill:#ffffde;stroke:#aa3;stroke-width:1px}#mermaid-svg-Yw0Yn4uJMBfsWsgB .cluster text{fill:#333}#mermaid-svg-Yw0Yn4uJMBfsWsgB div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:12px;background:#ffffde;border:1px solid #aa3;border-radius:2px;pointer-events:none;z-index:100}#mermaid-svg-Yw0Yn4uJMBfsWsgB .actor{stroke:#ccf;fill:#ECECFF}#mermaid-svg-Yw0Yn4uJMBfsWsgB text.actor>tspan{fill:#000;stroke:none}#mermaid-svg-Yw0Yn4uJMBfsWsgB .actor-line{stroke:grey}#mermaid-svg-Yw0Yn4uJMBfsWsgB .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333}#mermaid-svg-Yw0Yn4uJMBfsWsgB .messageLine1{stroke-width:1.5;stroke-dasharray:2, 2;stroke:#333}#mermaid-svg-Yw0Yn4uJMBfsWsgB #arrowhead path{fill:#333;stroke:#333}#mermaid-svg-Yw0Yn4uJMBfsWsgB .sequenceNumber{fill:#fff}#mermaid-svg-Yw0Yn4uJMBfsWsgB #sequencenumber{fill:#333}#mermaid-svg-Yw0Yn4uJMBfsWsgB #crosshead path{fill:#333;stroke:#333}#mermaid-svg-Yw0Yn4uJMBfsWsgB .messageText{fill:#333;stroke:#333}#mermaid-svg-Yw0Yn4uJMBfsWsgB .labelBox{stroke:#ccf;fill:#ECECFF}#mermaid-svg-Yw0Yn4uJMBfsWsgB .labelText,#mermaid-svg-Yw0Yn4uJMBfsWsgB .labelText>tspan{fill:#000;stroke:none}#mermaid-svg-Yw0Yn4uJMBfsWsgB .loopText,#mermaid-svg-Yw0Yn4uJMBfsWsgB .loopText>tspan{fill:#000;stroke:none}#mermaid-svg-Yw0Yn4uJMBfsWsgB .loopLine{stroke-width:2px;stroke-dasharray:2, 2;stroke:#ccf;fill:#ccf}#mermaid-svg-Yw0Yn4uJMBfsWsgB .note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-Yw0Yn4uJMBfsWsgB .noteText,#mermaid-svg-Yw0Yn4uJMBfsWsgB .noteText>tspan{fill:#000;stroke:none}#mermaid-svg-Yw0Yn4uJMBfsWsgB .activation0{fill:#f4f4f4;stroke:#666}#mermaid-svg-Yw0Yn4uJMBfsWsgB .activation1{fill:#f4f4f4;stroke:#666}#mermaid-svg-Yw0Yn4uJMBfsWsgB .activation2{fill:#f4f4f4;stroke:#666}#mermaid-svg-Yw0Yn4uJMBfsWsgB .mermaid-main-font{font-family:"trebuchet ms", verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-Yw0Yn4uJMBfsWsgB .section{stroke:none;opacity:0.2}#mermaid-svg-Yw0Yn4uJMBfsWsgB .section0{fill:rgba(102,102,255,0.49)}#mermaid-svg-Yw0Yn4uJMBfsWsgB .section2{fill:#fff400}#mermaid-svg-Yw0Yn4uJMBfsWsgB .section1,#mermaid-svg-Yw0Yn4uJMBfsWsgB .section3{fill:#fff;opacity:0.2}#mermaid-svg-Yw0Yn4uJMBfsWsgB .sectionTitle0{fill:#333}#mermaid-svg-Yw0Yn4uJMBfsWsgB .sectionTitle1{fill:#333}#mermaid-svg-Yw0Yn4uJMBfsWsgB .sectionTitle2{fill:#333}#mermaid-svg-Yw0Yn4uJMBfsWsgB .sectionTitle3{fill:#333}#mermaid-svg-Yw0Yn4uJMBfsWsgB .sectionTitle{text-anchor:start;font-size:11px;text-height:14px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-Yw0Yn4uJMBfsWsgB .grid .tick{stroke:#d3d3d3;opacity:0.8;shape-rendering:crispEdges}#mermaid-svg-Yw0Yn4uJMBfsWsgB .grid .tick text{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-Yw0Yn4uJMBfsWsgB .grid path{stroke-width:0}#mermaid-svg-Yw0Yn4uJMBfsWsgB .today{fill:none;stroke:red;stroke-width:2px}#mermaid-svg-Yw0Yn4uJMBfsWsgB .task{stroke-width:2}#mermaid-svg-Yw0Yn4uJMBfsWsgB .taskText{text-anchor:middle;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-Yw0Yn4uJMBfsWsgB .taskText:not([font-size]){font-size:11px}#mermaid-svg-Yw0Yn4uJMBfsWsgB .taskTextOutsideRight{fill:#000;text-anchor:start;font-size:11px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-Yw0Yn4uJMBfsWsgB .taskTextOutsideLeft{fill:#000;text-anchor:end;font-size:11px}#mermaid-svg-Yw0Yn4uJMBfsWsgB .task.clickable{cursor:pointer}#mermaid-svg-Yw0Yn4uJMBfsWsgB .taskText.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-Yw0Yn4uJMBfsWsgB .taskTextOutsideLeft.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-Yw0Yn4uJMBfsWsgB .taskTextOutsideRight.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-Yw0Yn4uJMBfsWsgB .taskText0,#mermaid-svg-Yw0Yn4uJMBfsWsgB .taskText1,#mermaid-svg-Yw0Yn4uJMBfsWsgB .taskText2,#mermaid-svg-Yw0Yn4uJMBfsWsgB .taskText3{fill:#fff}#mermaid-svg-Yw0Yn4uJMBfsWsgB .task0,#mermaid-svg-Yw0Yn4uJMBfsWsgB .task1,#mermaid-svg-Yw0Yn4uJMBfsWsgB .task2,#mermaid-svg-Yw0Yn4uJMBfsWsgB .task3{fill:#8a90dd;stroke:#534fbc}#mermaid-svg-Yw0Yn4uJMBfsWsgB .taskTextOutside0,#mermaid-svg-Yw0Yn4uJMBfsWsgB .taskTextOutside2{fill:#000}#mermaid-svg-Yw0Yn4uJMBfsWsgB .taskTextOutside1,#mermaid-svg-Yw0Yn4uJMBfsWsgB .taskTextOutside3{fill:#000}#mermaid-svg-Yw0Yn4uJMBfsWsgB .active0,#mermaid-svg-Yw0Yn4uJMBfsWsgB .active1,#mermaid-svg-Yw0Yn4uJMBfsWsgB .active2,#mermaid-svg-Yw0Yn4uJMBfsWsgB .active3{fill:#bfc7ff;stroke:#534fbc}#mermaid-svg-Yw0Yn4uJMBfsWsgB .activeText0,#mermaid-svg-Yw0Yn4uJMBfsWsgB .activeText1,#mermaid-svg-Yw0Yn4uJMBfsWsgB .activeText2,#mermaid-svg-Yw0Yn4uJMBfsWsgB .activeText3{fill:#000 !important}#mermaid-svg-Yw0Yn4uJMBfsWsgB .done0,#mermaid-svg-Yw0Yn4uJMBfsWsgB .done1,#mermaid-svg-Yw0Yn4uJMBfsWsgB .done2,#mermaid-svg-Yw0Yn4uJMBfsWsgB .done3{stroke:grey;fill:#d3d3d3;stroke-width:2}#mermaid-svg-Yw0Yn4uJMBfsWsgB .doneText0,#mermaid-svg-Yw0Yn4uJMBfsWsgB .doneText1,#mermaid-svg-Yw0Yn4uJMBfsWsgB .doneText2,#mermaid-svg-Yw0Yn4uJMBfsWsgB .doneText3{fill:#000 !important}#mermaid-svg-Yw0Yn4uJMBfsWsgB .crit0,#mermaid-svg-Yw0Yn4uJMBfsWsgB .crit1,#mermaid-svg-Yw0Yn4uJMBfsWsgB .crit2,#mermaid-svg-Yw0Yn4uJMBfsWsgB .crit3{stroke:#f88;fill:red;stroke-width:2}#mermaid-svg-Yw0Yn4uJMBfsWsgB .activeCrit0,#mermaid-svg-Yw0Yn4uJMBfsWsgB .activeCrit1,#mermaid-svg-Yw0Yn4uJMBfsWsgB .activeCrit2,#mermaid-svg-Yw0Yn4uJMBfsWsgB .activeCrit3{stroke:#f88;fill:#bfc7ff;stroke-width:2}#mermaid-svg-Yw0Yn4uJMBfsWsgB .doneCrit0,#mermaid-svg-Yw0Yn4uJMBfsWsgB .doneCrit1,#mermaid-svg-Yw0Yn4uJMBfsWsgB .doneCrit2,#mermaid-svg-Yw0Yn4uJMBfsWsgB .doneCrit3{stroke:#f88;fill:#d3d3d3;stroke-width:2;cursor:pointer;shape-rendering:crispEdges}#mermaid-svg-Yw0Yn4uJMBfsWsgB .milestone{transform:rotate(45deg) scale(0.8, 0.8)}#mermaid-svg-Yw0Yn4uJMBfsWsgB .milestoneText{font-style:italic}#mermaid-svg-Yw0Yn4uJMBfsWsgB .doneCritText0,#mermaid-svg-Yw0Yn4uJMBfsWsgB .doneCritText1,#mermaid-svg-Yw0Yn4uJMBfsWsgB .doneCritText2,#mermaid-svg-Yw0Yn4uJMBfsWsgB .doneCritText3{fill:#000 !important}#mermaid-svg-Yw0Yn4uJMBfsWsgB .activeCritText0,#mermaid-svg-Yw0Yn4uJMBfsWsgB .activeCritText1,#mermaid-svg-Yw0Yn4uJMBfsWsgB .activeCritText2,#mermaid-svg-Yw0Yn4uJMBfsWsgB .activeCritText3{fill:#000 !important}#mermaid-svg-Yw0Yn4uJMBfsWsgB .titleText{text-anchor:middle;font-size:18px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-Yw0Yn4uJMBfsWsgB g.classGroup text{fill:#9370db;stroke:none;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:10px}#mermaid-svg-Yw0Yn4uJMBfsWsgB g.classGroup text .title{font-weight:bolder}#mermaid-svg-Yw0Yn4uJMBfsWsgB g.clickable{cursor:pointer}#mermaid-svg-Yw0Yn4uJMBfsWsgB g.classGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-Yw0Yn4uJMBfsWsgB g.classGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-Yw0Yn4uJMBfsWsgB .classLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5}#mermaid-svg-Yw0Yn4uJMBfsWsgB .classLabel .label{fill:#9370db;font-size:10px}#mermaid-svg-Yw0Yn4uJMBfsWsgB .relation{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-Yw0Yn4uJMBfsWsgB .dashed-line{stroke-dasharray:3}#mermaid-svg-Yw0Yn4uJMBfsWsgB #compositionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-Yw0Yn4uJMBfsWsgB #compositionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-Yw0Yn4uJMBfsWsgB #aggregationStart{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-Yw0Yn4uJMBfsWsgB #aggregationEnd{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-Yw0Yn4uJMBfsWsgB #dependencyStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-Yw0Yn4uJMBfsWsgB #dependencyEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-Yw0Yn4uJMBfsWsgB #extensionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-Yw0Yn4uJMBfsWsgB #extensionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-Yw0Yn4uJMBfsWsgB .commit-id,#mermaid-svg-Yw0Yn4uJMBfsWsgB .commit-msg,#mermaid-svg-Yw0Yn4uJMBfsWsgB .branch-label{fill:lightgrey;color:lightgrey;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-Yw0Yn4uJMBfsWsgB .pieTitleText{text-anchor:middle;font-size:25px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-Yw0Yn4uJMBfsWsgB .slice{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-Yw0Yn4uJMBfsWsgB g.stateGroup text{fill:#9370db;stroke:none;font-size:10px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-Yw0Yn4uJMBfsWsgB g.stateGroup text{fill:#9370db;fill:#333;stroke:none;font-size:10px}#mermaid-svg-Yw0Yn4uJMBfsWsgB g.statediagram-cluster .cluster-label text{fill:#333}#mermaid-svg-Yw0Yn4uJMBfsWsgB g.stateGroup .state-title{font-weight:bolder;fill:#000}#mermaid-svg-Yw0Yn4uJMBfsWsgB g.stateGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-Yw0Yn4uJMBfsWsgB g.stateGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-Yw0Yn4uJMBfsWsgB .transition{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-Yw0Yn4uJMBfsWsgB .stateGroup .composit{fill:white;border-bottom:1px}#mermaid-svg-Yw0Yn4uJMBfsWsgB .stateGroup .alt-composit{fill:#e0e0e0;border-bottom:1px}#mermaid-svg-Yw0Yn4uJMBfsWsgB .state-note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-Yw0Yn4uJMBfsWsgB .state-note text{fill:black;stroke:none;font-size:10px}#mermaid-svg-Yw0Yn4uJMBfsWsgB .stateLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.7}#mermaid-svg-Yw0Yn4uJMBfsWsgB .edgeLabel text{fill:#333}#mermaid-svg-Yw0Yn4uJMBfsWsgB .stateLabel text{fill:#000;font-size:10px;font-weight:bold;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-Yw0Yn4uJMBfsWsgB .node circle.state-start{fill:black;stroke:black}#mermaid-svg-Yw0Yn4uJMBfsWsgB .node circle.state-end{fill:black;stroke:white;stroke-width:1.5}#mermaid-svg-Yw0Yn4uJMBfsWsgB #statediagram-barbEnd{fill:#9370db}#mermaid-svg-Yw0Yn4uJMBfsWsgB .statediagram-cluster rect{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-Yw0Yn4uJMBfsWsgB .statediagram-cluster rect.outer{rx:5px;ry:5px}#mermaid-svg-Yw0Yn4uJMBfsWsgB .statediagram-state .divider{stroke:#9370db}#mermaid-svg-Yw0Yn4uJMBfsWsgB .statediagram-state .title-state{rx:5px;ry:5px}#mermaid-svg-Yw0Yn4uJMBfsWsgB .statediagram-cluster.statediagram-cluster .inner{fill:white}#mermaid-svg-Yw0Yn4uJMBfsWsgB .statediagram-cluster.statediagram-cluster-alt .inner{fill:#e0e0e0}#mermaid-svg-Yw0Yn4uJMBfsWsgB .statediagram-cluster .inner{rx:0;ry:0}#mermaid-svg-Yw0Yn4uJMBfsWsgB .statediagram-state rect.basic{rx:5px;ry:5px}#mermaid-svg-Yw0Yn4uJMBfsWsgB .statediagram-state rect.divider{stroke-dasharray:10,10;fill:#efefef}#mermaid-svg-Yw0Yn4uJMBfsWsgB .note-edge{stroke-dasharray:5}#mermaid-svg-Yw0Yn4uJMBfsWsgB .statediagram-note rect{fill:#fff5ad;stroke:#aa3;stroke-width:1px;rx:0;ry:0}:root{--mermaid-font-family: '"trebuchet ms", verdana, arial';--mermaid-font-family: "Comic Sans MS", "Comic Sans", cursive}#mermaid-svg-Yw0Yn4uJMBfsWsgB .error-icon{fill:#522}#mermaid-svg-Yw0Yn4uJMBfsWsgB .error-text{fill:#522;stroke:#522}#mermaid-svg-Yw0Yn4uJMBfsWsgB .edge-thickness-normal{stroke-width:2px}#mermaid-svg-Yw0Yn4uJMBfsWsgB .edge-thickness-thick{stroke-width:3.5px}#mermaid-svg-Yw0Yn4uJMBfsWsgB .edge-pattern-solid{stroke-dasharray:0}#mermaid-svg-Yw0Yn4uJMBfsWsgB .edge-pattern-dashed{stroke-dasharray:3}#mermaid-svg-Yw0Yn4uJMBfsWsgB .edge-pattern-dotted{stroke-dasharray:2}#mermaid-svg-Yw0Yn4uJMBfsWsgB .marker{fill:#333}#mermaid-svg-Yw0Yn4uJMBfsWsgB .marker.cross{stroke:#333}:root { --mermaid-font-family: "trebuchet ms", verdana, arial;} #mermaid-svg-Yw0Yn4uJMBfsWsgB {color: rgba(0, 0, 0, 0.75);font: ;}

dpdk_config
dpdk_buffer_pool_create
dpdk_pool_create
rte_mempool_create_empty
rte_pktmbuf_pool_init
rte_mempool_get_priv
dpdk_lib_init

dpdk_pool_create与rte_pktmbuf_pool_create的区别:

dpdk mempool

  • mempool基础

Mempool是固定大小的对象分配器。 在DPDK中,它由名称唯一标识,并且使用mempool操作来存储空闲对象。Mempool的组织是通过三个部分实现的:

  • mempool对象节点:mempool的对象挂接在 static struct rte_tailq_elem rte_mempool_tailq 全局队列中,可以通过名字进行唯一标识符;此队列只是mempool的一个对象指示结构,并不是实际的内存区;
  • mempool实际内存区: struct rte_memzone 是实际分配的连续内存空间,存储所创建的mempool对象;
  • ring无锁队列:作为一个无锁环形队列 struct rte_ring ,存储着mempool对象的指针,提供了方便存取使用mempool的空间的办法。

mempool的对象通过与ring无锁队列建立关联方便存取;同时,为了减少多核访问造成的冲突,引入了local_cache对象缓冲区。该local_cache非硬件上的cache,而是为了减少多核访问ring造成的临界区访问,coreX app会优先访问该local_cache上的对象。入队的时候优先入local_cache中,出队的时候优先从local_cache中出队。

  • mempool创建使用

先注意一下 rte_mempool_create 的参数中的两个 mp_init 和 obj_init ,前者负责初始化mempool中配置的私有参数,如在数据包中加入的我们自己的私有结构;后者负责初始化每个mempool对象。我们然后按照mempool的3个关键部分展开说明。

  • mempool头结构的创建

    mempool头结构包含3个部分: struct rte_mempool , struct rte_mempool_cache 和mempool private。创建是在 rte_mempool_create_empty() 中完成的,先进行了对齐的检查,然后从mempool队列中取出头节点,我们创建的mempool结构填充好,就挂接在这个节点上。接下来做一些检查工作和创建flag的设置.rte_mempool_calc_obj_size() 计算了每个obj的大小,这个obj又是由三个部分组成的,header_size、elt_size、trailer_size,即头,数据区,尾。在没有开启RTE_LIBRTE_MEMPOOL_DEBUG调试时,没有尾部分;头部分的结构为: struct rte_mempool_objhdr ,通过这个头部,mempool中的obj都是链接到队列中的,所以,提供了遍历obj的方式(尽管很少这么用)。函数返回最后计算对齐后的obj的大小,为后面分配空间提供依据。

  • mempool实际空间的创建

这部分的创建是在函数 rte_mempool_populate_default(struct rte_mempool *mp) 中完成的。

首先计算为这些元素需要分配多大的空间, rte_mempool_ops_calc_mem_size()

接着 rte_memzone_reserve_aligned() 分配空间。把元素添加到mempool,实际上就是把申请的空间分给每个元素。

  • ring的创建

转自DPDK-----内存管理之mempool

reference

  1. https://blog.csdn.net/the_dog_tail_grass/article/details/113603311
  2. https://blog.csdn.net/u010827484/article/details/103377792
  3. https://segmentfault.com/a/1190000019400426
  4. https://www.cnblogs.com/rex-2018-cloud/p/10039065.html

vpp与dpdk的关系相关推荐

  1. FD.io/VPP — QoS — DPDK Hqos

    目录 文章目录 目录 基于 DPDK QoS 套件实现的 Hqos 1.CONF 配置 Hqos 2.CLI 配置 Hqos 基于 DPDK QoS 套件实现的 Hqos Hqos 的处理流程如上图所 ...

  2. FD.io VPP对 DPDK的详细配置:绑定网卡,启动VPP

    目录 Prerequisites Using DPDK interfaces Configuring Vagrant and start the VM Checking the host-only n ...

  3. dBm和Vpp以及Vpeak的关系

    很多时候我们要根据输入功率来推算输出电压摆幅,因此里记录一下计算方式. 输入信号为15dBm时,计算其输出电压摆幅: 15dBm比0dBm大15dB,电压量的15dB相当于10^(15/2/10)=5 ...

  4. FD.io VPP:探究分段场景下vlib_buf在收发包的处理(dpdk_plugin.so)、rte_mbuf与vlib_buf 关系

    Table of Contents rte_mbuf.vlib_buf 关系及内存分布 使用dpdk-收包接口函数 使用dpdk 发包接口函数 总结 参考阅读 在使用vpp老版本copy报文的时候,经 ...

  5. 基于DPDK+VPP实现高性能防火墙

    0. 数据平面和用户态协议栈 传统基于linux netfilter实现防火墙,虽然方便,但是性能很差.于是pfring/netmap/dpdk等机制,都要bypass掉内核协议栈. 多年来,各大操作 ...

  6. CentOS7 搭建基于DPDK的FD.io VPP环境-1

    目录 Prerequisites Installation, Compilation and Configuration Prerequisites 1. Install CentOS 7.7 2. ...

  7. How-to: Build VPP FD.IO with Mellanox DPDK PMD on top CentOS 7.7 with inbox drivers.

    目录 References Prerequisites Installation, Compilation and Configuration This short document will gui ...

  8. DPDK和VPP地址池

    如下VPP命令,默认创建名称为vpp pool 0的地址池,其中包括256032个vlib_buffer_t内存结构. vpp# show dpdk buffer name="vpp poo ...

  9. FD.io VPP:用户文档:VPP RPM包的构建与离线安装

    VPP RPM包的构建与离线安装 RToax 2020年9月 要开始使用VPP进行开发,您需要获取所需的VPP源代码,然后构建软件包. 1. 设置代理 如果你的服务器本地可以连接互联网,则跳过设置代理 ...

最新文章

  1. *103.编译的过程
  2. Spring Data JPA教程:获取所需的依赖关系
  3. 计算机应用 winxp,2017年职称计算机考试模块WindowsXP试题
  4. Java多线程系列(二):线程的五大状态,以及线程之间的通信与协作
  5. python递归查找值返回_python – 从树递归中返回值列表
  6. 20171016课程随笔
  7. 嘉楠勘智 K210 RISC-V 64位双核处理器开发板(荔枝丹)
  8. C# 获取UTC 转换时间戳为C#时间
  9. LMAX Disruptor——一个高性能、低延迟且简单的框架
  10. typora高级设置字体_设计黑金风格高级感logo
  11. OpenCV下载驿站(解决github下载问题,解决OpenCV官网下载较慢)
  12. 发现的IplImage转QImage的好用的方式
  13. 手把手教您:iOS 6.1~6.12 完美越狱教程
  14. 360随身wifi3代linux驱动下载,360随身wifi3驱动
  15. 只会用ping测试网络通不通?高级网工还会这么用
  16. C++ - PAT- L1-030. 一帮一(天梯赛决赛题目)
  17. 搜狗输入法如何输入直角引号(「『』」 )
  18. 人生路上对我影响最大的老师
  19. 后端开发、C++开发面经分类整理
  20. ant java /jre,关于java:Ant:找不到类:javac1.8

热门文章

  1. 全球名校课程作业分享系列(9)--斯坦福CS231n之RNN与计算机看图说话
  2. svn 撤销已经add的文件
  3. 【学习笔记】NOIP爆零赛8
  4. 获取员工其当前的薪水比其manager当前薪水还高的相关信息--2-5
  5. 【论文分享】Sequence Directed Hybrid Fuzzing
  6. C++ VARIANT数据类型操作详解
  7. HCIP-DATACOM H12-831(101-120)
  8. 计算机的输入输出设备
  9. oracle常用分析函数与聚合函数的用法
  10. SVN客户端安装和使用