目录

目录

DPDK常用结构体解析

目录
/**
 * A structure used to configure an Ethernet port.
 * Depending upon the Rx multi-queue mode, extra advanced
 * configuration settings may be needed.
 */

struct rte_eth_conf {

}

配置以太网端口的结构。

/**
 * A structure used to configure the Rx features of an Ethernet port.
 */
struct rte_eth_rxmode {
	/** The multi-queue packet distribution mode to be used, e.g. RSS. */
	enum rte_eth_rx_mq_mode mq_mode;
	uint32_t mtu;  /**< Requested MTU. */
	/**
	 * Per-port Rx offloads to be set using RTE_ETH_RX_OFFLOAD_* flags.
	 * Only offloads set on rx_offload_capa field on rte_eth_dev_info
	 * structure are allowed to be set.
	 */
	uint64_t offloads;
}

配置以太端口的接收特性。

  1. offload 用于配置卸载特性,能将某些网络数据处理任务从主机 CPU 转移到网络接口卡(NIC),从而减少 CPU 的负担,提高数据包的处理效率。DPDK 中使用 RTE_ETH_RX_OFFLOAD_*定义了卸载能力集,不指定时默认不开启任何卸载能力。
  2. mtu 最大传输单元,它定义了网络链路中能够处理的最大数据帧的大小(包括头部信息)。标准的以太网MTU大小通常为1500字节,过大过小的设置都可能影响网络的效率与性能。
  3. mq_mode
/**
 *  A set of values to identify what method is to be used to route
 *  packets to multiple queues.
 */
enum rte_eth_rx_mq_mode {
		/** None of DCB, RSS or VMDq mode */
		RTE_ETH_MQ_RX_NONE = 0,

		/** For Rx side, only RSS is on */
		RTE_ETH_MQ_RX_RSS = RTE_ETH_MQ_RX_RSS_FLAG,

		/** For Rx side,only DCB is on. */
		RTE_ETH_MQ_RX_DCB = RTE_ETH_MQ_RX_DCB_FLAG,

		/** Only VMDq, no RSS nor DCB */
		RTE_ETH_MQ_RX_VMDQ_ONLY = RTE_ETH_MQ_RX_VMDQ_FLAG,
		...
}

标识使用什么方法将数据包路由到多个队列。

  • DCB(Data Center Bridging):
    • 原理:流量控制、优先级控制、带宽分配等功能保证稳定网络性能
    • 场景:数据中心和企业网络,吞吐量和低延迟的环境(如存储和高频交易);适合多种类型的流量管理
  • RSS(Receive Side Scaling):
    • 原理:通过哈希算法将流量分配到不同队列,以实现负载均衡,利用多核心并行处理数据
    • 场景:多核处理器系统,需要提升数据包处理能力的场景
  • VMDq(Virtual Machine Device Queues):
    • 原理:为每个虚拟机分配独立的接收和发送队列,减少虚拟机间的竞争
    • 场景:虚拟化环境,提升虚拟化网络性能和隔离性;如私有云等
/**
 * A structure used to configure the Tx features of an Ethernet port.
 */
struct rte_eth_txmode {
}

配置以太端口的发送特性。