DPDK 之 Symmetric Receive-side Scaling

DPDK 之 Symmetric Receive-side Scaling

上篇介绍到RSS HASH默认RK是一个非对称KEY,也就是同一条数据流收、发这两个方向的数据包的RSS HASH值是不同的。在IDS/DPI等流量分析应用场景中,同一条流数据由非对称HASH计算将分流到不同的CPU,这样极大的增加了应用负担,降低了处理能力。为了解决这个问题,有人提出了修改(RSSRK),将其改为重复的16个bits,来获取对称的结果。具体详情可查阅Scalable TCP Session Monitoring with Symmetric Receive-side Scaling此篇论文,这里不再详述。

对称RK为以下320 bits数据,将其写入网卡RSSRK寄存器(82599)即可:

0x6d5a 0x6d5a 0x6d5a 0x6d5a
0x6d5a 0x6d5a 0x6d5a 0x6d5a
0x6d5a 0x6d5a 0x6d5a 0x6d5a
0x6d5a 0x6d5a 0x6d5a 0x6d5a
0x6d5a 0x6d5a 0x6d5a 0x6d5a

DPDK 可通过 API rte_eth_dev_rss_hash_update 动态修改当前网卡 RSS HASH KEY, 具体可参考testpmdport_rss_hash_key_updatecmd_config_rss_parsed 详细实现:

void
port_rss_hash_key_update(portid_t port_id, char rss_type[], uint8_t *hash_key,
             uint hash_key_len)
{
    struct rte_eth_rss_conf rss_conf;
    int diag;
    unsigned int i;

    rss_conf.rss_key = NULL;
    rss_conf.rss_key_len = hash_key_len;
    rss_conf.rss_hf = 0;
    for (i = 0; i < RTE_DIM(rss_type_table); i++) {
        if (!strcmp(rss_type_table[i].str, rss_type))
            rss_conf.rss_hf = rss_type_table[i].rss_type;
    }
    diag = rte_eth_dev_rss_hash_conf_get(port_id, &rss_conf);
    if (diag == 0) {
        rss_conf.rss_key = hash_key;
        diag = rte_eth_dev_rss_hash_update(port_id, &rss_conf);
    }
    if (diag == 0)
        return;

    switch (diag) {
    case -ENODEV:
        printf("port index %d invalid\n", port_id);
        break;
    case -ENOTSUP:
        printf("operation not supported by device\n");
        break;
    default:
        printf("operation failed - diag=%d\n", diag);
        break;
    }
}

Reference

Scalable TCP Session Monitoring with Symmetric Receive-side Scaling

Symmetric RSS (Receive-Side scaling)

ntop - Hardware-based Symmetric Flow Balancing in DNA

你可能感兴趣的:(DPDK)