欢迎来到 DPDK交流社区 ,有什么问题可以尽管在这里提问,您将会收到社区其他成员的回答;也可以将您的总结写在这里,为社区其他成员提供帮助。 (QQ交流群:127163755)

为什么使用dpdk中thash测试一条链路的hash值,发现返回的rss值不同呢?

0 投票
struct test_thash_v4 v4_tbl[] = {
{IPv4(161, 142, 100, 80), IPv4(66, 9, 149, 187),
        1766, 2794},
{IPv4(66, 9, 149, 187), IPv4(161, 142, 100, 80),
        2794, 1766},
{IPv4(65, 69, 140, 83), IPv4(199, 92, 111, 2),
        4739, 14230},
{IPv4(12, 22, 207, 184), IPv4(24, 19, 198, 95),
        38024, 12898},
{IPv4(209, 142, 163, 6), IPv4(38, 27, 205, 30),
        2217, 48228},
{IPv4(202, 188, 127, 2), IPv4(153, 39, 163, 191),
        1303, 44251},
};

uint8_t default_rss_key[] = {
0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2,
0x41, 0x67, 0x25, 0x3d, 0x43, 0xa3, 0x8f, 0xb0,
0xd0, 0xca, 0x2b, 0xcb, 0xae, 0x7b, 0x30, 0xb4,
0x77, 0xcb, 0x2d, 0xa3, 0x80, 0x30, 0xf2, 0x0c,
0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa,
};

int test_thash(void)
{
        uint32_t i, j;
        union rte_thash_tuple tuple;
        uint32_t rss_l3, rss_l3l4;
        uint8_t rss_key_be[RTE_DIM(default_rss_key)];

        /* Convert RSS key*/
        rte_convert_rss_key((uint32_t *)&default_rss_key,
                (uint32_t *)rss_key_be, RTE_DIM(default_rss_key));

        for (i = 0; i < RTE_DIM(v4_tbl); i++) {
                tuple.v4.src_addr = v4_tbl[i].src_ip;
                tuple.v4.dst_addr = v4_tbl[i].dst_ip;
                tuple.v4.sport = v4_tbl[i].src_port;
                tuple.v4.dport = v4_tbl[i].dst_port;
                /*Calculate hash with original key*/
                rss_l3 = rte_softrss((uint32_t *)&tuple,
                                RTE_THASH_V4_L3_LEN, default_rss_key);
                printf("rss_l3 = %u\t",rss_l3);
                rss_l3l4 = rte_softrss((uint32_t *)&tuple,
                                RTE_THASH_V4_L4_LEN, default_rss_key);
                printf("rss_l3l4 = %u\t",rss_l3l4);

                /*Calculate hash with converted key*/
                rss_l3 = rte_softrss_be((uint32_t *)&tuple,
                                RTE_THASH_V4_L3_LEN, rss_key_be);
                printf("rss_l3 = %u\t",rss_l3);
                rss_l3l4 = rte_softrss_be((uint32_t *)&tuple,
                                RTE_THASH_V4_L4_LEN, rss_key_be);
                printf("rss_l3l4 = %u\n",rss_l3l4);

        }
        return 0;
}                   

 

输出结果为:targ[0]=1834637018
targ[1]=626724546
targ[2]=1097278781
targ[3]=1134792624
targ[4]=3502910411
targ[5]=2927308980
targ[6]=2009804195
targ[7]=2150691340
targ[8]=1782757179
targ[9]=3198943738
rss_l3 = 842960834    rss_l3l4 = 1372373368    rss_l3 = 842960834    rss_l3l4 = 1372373368
rss_l3 = 3125106814    rss_l3l4 = 4259813810    rss_l3 = 3125106814    rss_l3l4 = 4259813810
rss_l3 = 3608684074    rss_l3l4 = 3324424426    rss_l3 = 3608684074    rss_l3l4 = 3324424426
rss_l3 = 3536889310    rss_l3l4 = 1546336586    rss_l3 = 3536889310    rss_l3l4 = 1546336586
rss_l3 = 2191036790    rss_l3l4 = 2949067391    rss_l3 = 2191036790    rss_l3l4 = 2949067391
rss_l3 = 1561856453    rss_l3l4 = 283650210    rss_l3 = 1561856453    rss_l3l4 = 283650210

v4_tbl表中的第一条和第二条是同一条链路的往返,但是程序运行结果rss值分别是:

rss_l3 = 842960834    rss_l3l4 = 1372373368    rss_l3 = 842960834    rss_l3l4 = 1372373368
rss_l3 = 3125106814    rss_l3l4 = 4259813810    rss_l3 = 3125106814    rss_l3l4 = 4259813810

这是为什么呢??请各位大神赐教!
最新提问 9月 20, 2017 分类:经验之谈 | 用户: andyleo0 (120 分)

1个回答

0 投票
应该是与它的算法有关,可能算法不是针对五元组的对称算法吧
最新回答 9月 25, 2017 用户: admin (260 分)
...