DPDK RSS 基础

1 rss 的作用

rss 是网卡提供的分流机制。用来将报表分流到不同的收包队列,以提高收包性能。

引用 Intel 82599 10 GbE Controller Datasheet 其中的 Section 7.1.2.8.1, RSS Hash Function 一节。

  1. The receive packet is parsed into the header fields used by the hash operation (such as IP addresses, TCP port, etc.)
  2. A hash calculation is performed.
    The 82599 supports a single hash function, as defined by MSFT RSS.
    The 82599 therefore does not indicate to the device driver which hash function is used.
    The 32-bit result is fed into the packet receive descriptor.
  3. The seven LSBs of the hash result are used as an index into a 128-entry redirection table.
    Each entry provides a 4-bit RSS output index.

When RSS is enabled, the 82599 provides software with the following information as:

  1. Required by Microsoft (MSFT) RSS
  2. Provided for device driver assist:
  • * A Dword result of the MSFT RSS hash function, to be used by the stack for flow classification, is written into the receive packet descriptor (required by MSFT RSS).
  • * A 4-bit RSS Type field conveys the hash function used for the specific packet (required by MSFT RSS).

Enabling rules:

  • RSS is enabled in the MRQC register.
  • RSS enabling cannot be done dynamically while it must be preceded by a software reset.
  • RSS status field in the descriptor write-back is enabled when the RXCSUM.PCSD bit is set (fragment checksum is disabled).
    RSS is therefore mutually exclusive with UDP fragmentation checksum offload.
  • Support for RSS is not provided when legacy receive descriptor format is used.

Disabling rules:

  • 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 output index = zero.
The 32-bit tag (normally a result of the hash function) equals zero.

注意:

  • 没有开启 rss:
    • 则所有报文只会从一个硬件队列来收包。
  • 开启 rss 后:
    • rss 会解释报文的 l3 层信息:ip 地址。甚至 l4 层信息:tcp/udp 端口。
      • 报文会经过 hash function 计算出一个 uint32_t 的 rss hash。填充到 struct rte_mbuf 的 hash.rss字段中。
      • rss hash 的 低7位 会映射到 4位长 的 RSS output index
    • 无法解释的 报文,rss hashRSS output index 设置为 0。

在这里插入图片描述

2 DPDK rss 的 配置

21 用于 DPDK rss 的 配置 的数据结构

struct rte_eth_rss_conf 用于配置网卡的 rss。

struct rte_eth_rss_conf {
   
	uint8_t *rss_key;    /**< If not NULL, 40-byte hash key. */
	uint8_t rss_key_len; /**< hash key length in bytes. */
	uint64_t rss_hf;     /**< Hash functions to apply - see below. */
};
字段 描述
rss_key rss_key 数组。如果 为 NULL,留给网卡设置 rss_key。
rss_key_len rss_key 数组的字节数。
rss_hf 需要对报文的分析的元组类型。常用的组合有 l3: ETH_RSS_IP, l3+l4: ETH_RSS_IP | ETH_RSS_UDP | ETH_RSS_TCP

2.2 常见 rss 的配置

static struct rte_eth_conf eth_conf = {
   
	.rxmode = {
   
		.mq_mode = ETH_MQ_RX_RSS		/* 使用 RSS 分流 */
	},
	.rx_adv_conf = {
   
		.rss_conf = {
   
			.rss_key = NULL,	/* 留给 网卡设置 rss_key */
			.rss_key_len = 0, 	/* rss_key 数组的字节数 */
			.rss_hf = ETH_RSS_IP 	/* 通过 l3 tuple 计算 rss hash */
					| ETH_RSS_UDP 	/* + 通过 UDP tuple 计算 rss hash */
					| ETH_RSS_TCP	/* + 通过 TCP tuple 计算 rss hash */
		},
	/* ... */
	}
/* ... */
};

问题:

  • 将 rss_key 字段设置为 NULL, 留给 网卡设置 rss key。不是一个好主意。
  • 因为不同的驱动,rss key 有可能设置为对称,也有可能设置为非对称的。所以不同驱动网卡的分流效果,将无法预测。

比如网卡82599ES 使用的是 ixgbe 的驱动。
在 ixgbe_rss_configure() 中,会使用 对称的 rss key 作为默认值。

ixgbe 的驱动 用于 rss 配置的代码:

/* filepath:
 *   dpdk/drivers/net/ixgbe/ixgbe_rxtx.c
 */

/* ixgbe 的驱动 使用了 对称的 rss key 作为默认值。 */
static uint8_t rss_intel_key[40] = {
   
	0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 
    0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 
    0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 
    0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 
    0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A,
};

static void
ixgbe_rss_configure(struct rte_eth_dev *dev)
{<
  • 3
    点赞
  • 31
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值