Skip to content

Commit

Permalink
app/testpmd: fix RSS key for flow API RSS rule
Browse files Browse the repository at this point in the history
When a flow API RSS rule is issued in testpmd, device RSS key is changed
unexpectedly, device RSS key is changed to the testpmd default RSS key.

Consider the following usage with testpmd:
1. first, startup testpmd:
 testpmd> show port 0 rss-hash key
 RSS functions: all ipv4-frag ipv4-other ipv6-frag ipv6-other ip
 RSS key: 6D5A56DA255B0EC24167253D43A38FB0D0CA2BCBAE7B30B477CB2DA38030F
          20C6A42B73BBEAC01FA
2. create a rss rule
 testpmd> flow create 0 ingress pattern eth / ipv4 / udp / end \
          actions rss types ipv4-udp end queues end / end

3. show rss-hash key
 testpmd> show port 0 rss-hash key
 RSS functions: all ipv4-udp udp
 RSS key: 74657374706D6427732064656661756C74205253532068617368206B65792
          C206F76657272696465

This is because testpmd always sends a key with the RSS rule,
if user provides a key as part of the rule that key is used, if user
doesn't provide a key, testpmd default key is sent to the PMDs, which is
causing device programmed RSS key to be changed.

There was a previous attempt to fix the same issue [1], but it has been
reverted back [2] because of the crash when 'key_len' is provided
without 'key'.

This patch follows the same approach with the initial fix [1] but also
addresses the crash.

After change, testpmd RSS key is 'NULL' by default, if user provides a
key as part of rule it is used, if not no key is sent to the PMDs at all

[1]
Commit a4391f8 ("app/testpmd: set default RSS key as null")

[2]
Commit f3698c3 ("app/testpmd: revert setting default RSS")

Fixes: d0ad864 ("app/testpmd: fix RSS flow action configuration")
Cc: stable@dpdk.org

Signed-off-by: Lijun Ou <oulijun@huawei.com>
Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
  • Loading branch information
oulijun authored and Ferruh Yigit committed Nov 3, 2020
1 parent b8c3c62 commit 1848b11
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
19 changes: 2 additions & 17 deletions app/test-pmd/cmdline_flow.c
Expand Up @@ -4850,30 +4850,15 @@ parse_vc_action_rss(struct context *ctx, const struct token *token,
.func = RTE_ETH_HASH_FUNCTION_DEFAULT,
.level = 0,
.types = rss_hf,
.key_len = sizeof(action_rss_data->key),
.key_len = 0,
.queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
.key = action_rss_data->key,
.key = NULL,
.queue = action_rss_data->queue,
},
.key = "testpmd's default RSS hash key, "
"override it for better balancing",
.queue = { 0 },
};
for (i = 0; i < action_rss_data->conf.queue_num; ++i)
action_rss_data->queue[i] = i;
if (!port_id_is_invalid(ctx->port, DISABLED_WARN) &&
ctx->port != (portid_t)RTE_PORT_ALL) {
struct rte_eth_dev_info info;
int ret2;

ret2 = rte_eth_dev_info_get(ctx->port, &info);
if (ret2 != 0)
return ret2;

action_rss_data->conf.key_len =
RTE_MIN(sizeof(action_rss_data->key),
info.hash_key_size);
}
action->conf = &action_rss_data->conf;
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/librte_ethdev/rte_flow.c
Expand Up @@ -577,7 +577,7 @@ rte_flow_conv_action_conf(void *buf, const size_t size,
}),
size > sizeof(*dst.rss) ? sizeof(*dst.rss) : size);
off = sizeof(*dst.rss);
if (src.rss->key_len) {
if (src.rss->key_len && src.rss->key) {
off = RTE_ALIGN_CEIL(off, sizeof(*dst.rss->key));
tmp = sizeof(*src.rss->key) * src.rss->key_len;
if (size >= off + tmp)
Expand Down

0 comments on commit 1848b11

Please sign in to comment.