Dpdk Learning Notes



  • Dpdk Learning Notes

    Main libs

    ethdev

    dpdk doc:ethdev

    Description

    • setup an Ethernet device(启动网卡设备)
    • get its MAC address, the speed and the status of its physical link(获取MAC地址、速度和物理链接的状态)
    • receive and transmit packets(收发包)

    Functions

    rte_eth_tx_burst
    • Send a burst of output packets on a transmit queue of an Ethernet device.(把需要发送的包放到网卡的发送队列里)
    
    static uint16_t rte_eth_tx_burst(	
    uint16_t 	port_id,               //网卡port
    uint16_t 	queue_id,              //packet放到哪个transmit queue
    struct rte_mbuf ** 	tx_pkts,       //要发送包的rmbuf地址
    uint16_t 	nb_pkts                //最大发送包的数量
    )	
    
    rte_eth_rx_burst
    • Retrieve a burst of input packets from a receive queue of an Ethernet device. (从receive queue取包)
    static uint16_t rte_eth_rx_burst(
    uint16_t 	port_id,              //网卡port
    uint16_t 	queue_id,             //从哪个receive queue取包
    struct rte_mbuf ** 	rx_pkts,      //足够大的rmbuf存放取回来的包
    const uint16_t 	nb_pkts           //最大取包个数
    )		
    
    • return:The number of packets actually retrieved.(实际收到包数量)
    rte_eth_dev_configure
    • Configure an Ethernet device. This function must be invoked first before any other function in the Ethernet API. This function can also be re-invoked when a device is in the stopped state.(配置网络设备,其他用到ethernet的设备必须先config)
    
    int rte_eth_dev_configure(	
    uint16_t 	port_id,                            //网卡port  
    uint16_t 	nb_rx_queue,                        //rx queue数量
    uint16_t 	nb_tx_queue,                        //tx queue数量
    const struct rte_eth_conf *  eth_conf           //设置信息
    )	
    
    • return:
      • =0: Success, device configured.(成功)
      • <0: Error code returned by the driver configuration function.(失败)
    rte_eth_dev_count
    • Get the total number of Ethernet devices that have been successfully initialized by the matching Ethernet driver during the PCI probing phase and that are available for applications to use. (获取成功初始化的ethernet设备)
    uint16_t rte_eth_dev_count(void)	
    
    • return:The total number of usable Ethernet devices.(可用ethernet设备总数)

    mempool

    dpdk doc: mempool

    ring

    dpdk doc: ring

    mbuf

    dpdk doc: mbuf

    Description

    • provides the ability to create and destroy buffers that may be used by the RTE application to store message buffers.(RTE buffer 管理)
    • message buffers are stored in a mempool
    • provides an API to allocate/free packet mbufs, which are used to carry network packets.(buffer管理并接受来自网络的包)

    Functions

    rte_pktmbuf_pool_create
    • creates and initializes a packet mbuf pool(创建并初始化)
    • wrapper to rte_mempool functions(封装了mempool功能)
    Background Knowledge
    • Physical socket: It is the actual spot on which processor is fixed on the motherboard.(CPU 个数-2)

    • Physical core: It is the division of the actual processor on a hardware level.(物理核心个数-22*2)

    • Logical processor: It is the division of a physical core by using hyper-thread or other techniques.(虚拟核心技术-未开启)

    
    struct rte_mempool* rte_pktmbuf_pool_create	(	
    const char * 	name,                 //pool 名字
    unsigned 	n,                        //pool中元素个数
    unsigned 	cache_size,               //pre-core 的object cash
    uint16_t 	priv_size,                //RTE_MBUF_PRIV_ALIGN
    uint16_t 	data_room_size,           //data buffer的大小
    int 	socket_id                     //绑定的socket id(哪个cpu)
    )	
    
    • return:
      • The pointer to the new allocated mempool, on success.(成功返回指针)
      • NULL on error with rte_errno set appropriately. (失败返回错误信息)

    Example Analyses

    l2fwd

    dpdk doc:l2fwd



  • 咋全是英文


  • 项目组组长

    会好好研读哒


  • 核心层

    DPDK太深奥了


 

Copyright © 2018 bbs.dian.org.cn All rights reserved.

与 Dian 的连接断开,我们正在尝试重连,请耐心等待