patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Dongdong Liu <liudongdong3@huawei.com>
To: <dev@dpdk.org>, <ferruh.yigit@amd.com>, <thomas@monjalon.net>,
	<andrew.rybchenko@oktetlabs.ru>, <lihuisong@huawei.com>
Cc: <stable@dpdk.org>, <yisen.zhuang@huawei.com>
Subject: Re: [PATCH V2 09/10] net/hns3: fix bad memory structure conversion
Date: Tue, 31 Jan 2023 17:34:15 +0800	[thread overview]
Message-ID: <5e1bc8d5-84ac-95ab-8d1b-6589dc5b5c82@huawei.com> (raw)
In-Reply-To: <20230130093129.18529-10-liudongdong3@huawei.com>



On 2023/1/30 17:31, Dongdong Liu wrote:
> From: Huisong Li <lihuisong@huawei.com>
>
> When the type in 'struct rte_flow_action' is RTE_FLOW_ACTION_TYPE_RSS, the
> 'conf' pointer references the 'struct rte_flow_action_rss' instead of the
> 'struct hns3_rss_conf' in driver. But driver uses 'struct hns3_rss_conf' to
> convert this 'conf' pointer to get RSS action configuration.
>
> In addition, RSS filter configuration is directly cloned to RSS filter node
> instead of coping it after successfully setting to hardware.
>
> Fixes: c37ca66f2b27 ("net/hns3: support RSS")
> Cc: stable@dpdk.org
>
> Signed-off-by: Huisong Li <lihuisong@huawei.com>
> Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
> ---
>  drivers/net/hns3/hns3_flow.c | 57 +++++++++++++-----------------------
>  1 file changed, 20 insertions(+), 37 deletions(-)
>
> diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
> index fbc38dd3d4..307aba75a7 100644
> --- a/drivers/net/hns3/hns3_flow.c
> +++ b/drivers/net/hns3/hns3_flow.c
> @@ -95,8 +95,8 @@ static const struct rte_flow_action *
>  hns3_find_rss_general_action(const struct rte_flow_item pattern[],
>  			     const struct rte_flow_action actions[])
>  {
> +	const struct rte_flow_action_rss *rss_act;
>  	const struct rte_flow_action *act = NULL;
> -	const struct hns3_rss_conf *rss;
>  	bool have_eth = false;
>
>  	for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) {
> @@ -115,8 +115,8 @@ hns3_find_rss_general_action(const struct rte_flow_item pattern[],
>  		}
>  	}
>
> -	rss = act->conf;
> -	if (have_eth && rss->conf.queue_num) {
> +	rss_act = act->conf;
> +	if (have_eth && rss_act->queue_num) {
>  		/*
>  		 * Pattern have ETH and action's queue_num > 0, indicate this is
>  		 * queue region configuration.
> @@ -1296,30 +1296,6 @@ hns3_action_rss_same(const struct rte_flow_action_rss *comp,
>  			sizeof(*with->queue) * with->queue_num));
>  }
>
> -static int
> -hns3_rss_conf_copy(struct hns3_rss_conf *out,
> -		   const struct rte_flow_action_rss *in)
> -{
> -	if (in->key_len > RTE_DIM(out->key) ||
> -	    in->queue_num > RTE_DIM(out->queue))
> -		return -EINVAL;
> -	if (in->key == NULL && in->key_len)
> -		return -EINVAL;
> -	out->conf = (struct rte_flow_action_rss) {
> -		.func = in->func,
> -		.level = in->level,
> -		.types = in->types,
> -		.key_len = in->key_len,
> -		.queue_num = in->queue_num,
> -	};
> -	out->conf.queue = memcpy(out->queue, in->queue,
> -				sizeof(*in->queue) * in->queue_num);
> -	if (in->key)
> -		out->conf.key = memcpy(out->key, in->key, in->key_len);
> -
> -	return 0;
> -}
> -
>  static bool
>  hns3_rss_input_tuple_supported(struct hns3_hw *hw,
>  			       const struct rte_flow_action_rss *rss)
> @@ -1733,9 +1709,10 @@ hns3_flow_create_rss_rule(struct rte_eth_dev *dev,
>  			  struct rte_flow *flow)
>  {
>  	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> +	const struct rte_flow_action_rss *rss_act;
>  	struct hns3_rss_conf_ele *rss_filter_ptr;
>  	struct hns3_rss_conf_ele *filter_ptr;
> -	const struct hns3_rss_conf *rss_conf;
> +	struct hns3_rss_conf *new_conf;
>  	int ret;
>
>  	rss_filter_ptr = rte_zmalloc("hns3 rss filter",
> @@ -1745,19 +1722,25 @@ hns3_flow_create_rss_rule(struct rte_eth_dev *dev,
>  		return -ENOMEM;
>  	}
>
> -	/*
> -	 * After all the preceding tasks are successfully configured, configure
> -	 * rules to the hardware to simplify the rollback of rules in the
> -	 * hardware.
> -	 */
> -	rss_conf = (const struct hns3_rss_conf *)act->conf;
> -	ret = hns3_flow_parse_rss(dev, rss_conf, true);
> +	rss_act = (const struct rte_flow_action_rss *)act->conf;
> +	new_conf = &rss_filter_ptr->filter_info;
> +	memcpy(&new_conf->conf, rss_act, sizeof(*rss_act));
> +	if (rss_act->queue_num > 0) {
> +		memcpy(new_conf->queue, rss_act->queue,
> +		       rss_act->queue_num * sizeof(new_conf->queue[0]));
> +		new_conf->conf.queue = new_conf->queue;
> +	}
> +	if (rss_act->key_len > 0) {

When do the below test, Segmentation fault occurred.
testpmd> flow create 0 ingress pattern end actions rss key_len 40 / end
Segmentation fault (core dumped)

It should make sure new_conf->key is not NULL before doing memcpy.
Will fix this in V3.

Thanks,
Dongdong
> +		memcpy(new_conf->key, rss_act->key,
> +		       rss_act->key_len * sizeof(new_conf->key[0]));
> +		new_conf->conf.key = new_conf->key;
> +	}
> +
> +	ret = hns3_flow_parse_rss(dev, new_conf, true);
>  	if (ret != 0) {
>  		rte_free(rss_filter_ptr);
>  		return ret;
>  	}
> -
> -	hns3_rss_conf_copy(&rss_filter_ptr->filter_info, &rss_conf->conf);
>  	rss_filter_ptr->filter_info.valid = true;
>
>  	/*
>

  reply	other threads:[~2023-01-31  9:34 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-29 10:51 [PATCH 00/10] net/hns3: some bugfixes for rss Dongdong Liu
2023-01-29 10:51 ` [PATCH 01/10] net/hns3: fix error log about indirection table size Dongdong Liu
2023-01-29 10:51 ` [PATCH 02/10] net/hns3: extract common API to query device Dongdong Liu
2023-01-29 10:51 ` [PATCH 03/10] net/hns3: refactor set RSS hash algorithm and key interface Dongdong Liu
2023-01-29 10:51 ` [PATCH 04/10] net/hns3: fix fixed RSS key size to be more compatibility Dongdong Liu
2023-01-29 10:51 ` [PATCH 05/10] net/hns3: fix misclearing RSS configuration Dongdong Liu
2023-01-29 10:51 ` [PATCH 06/10] net/hns3: using RSS filter list to check duplicated rule Dongdong Liu
2023-01-29 10:51 ` [PATCH 07/10] net/hns3: remove useless code when destroy valid RSS rule Dongdong Liu
2023-01-29 10:51 ` [PATCH 08/10] net/hns3: fix useless warning when flush or destroy rule Dongdong Liu
2023-01-29 10:51 ` [PATCH 09/10] net/hns3: fix bad memory structure conversion Dongdong Liu
2023-01-29 10:51 ` [PATCH 10/10] net/hns3: fix incorrect check for duplicate RSS rule Dongdong Liu
2023-01-30  9:31 ` [PATCH V2 00/10] net/hns3: some bugfixes for rss Dongdong Liu
2023-01-30  9:31   ` [PATCH V2 01/10] net/hns3: fix error log about indirection table size Dongdong Liu
2023-01-30  9:31   ` [PATCH V2 02/10] net/hns3: extract common API to query device Dongdong Liu
2023-01-30  9:31   ` [PATCH V2 03/10] net/hns3: refactor set RSS hash algorithm and key interface Dongdong Liu
2023-01-30  9:31   ` [PATCH V2 04/10] net/hns3: fix fixed RSS key size to be more compatibility Dongdong Liu
2023-01-30  9:31   ` [PATCH V2 05/10] net/hns3: fix misclearing RSS configuration Dongdong Liu
2023-01-30  9:31   ` [PATCH V2 06/10] net/hns3: using RSS filter list to check duplicated rule Dongdong Liu
2023-01-30  9:31   ` [PATCH V2 07/10] net/hns3: remove useless code when destroy valid RSS rule Dongdong Liu
2023-01-30  9:31   ` [PATCH V2 08/10] net/hns3: fix useless warning when flush or destroy rule Dongdong Liu
2023-01-30  9:31   ` [PATCH V2 09/10] net/hns3: fix bad memory structure conversion Dongdong Liu
2023-01-31  9:34     ` Dongdong Liu [this message]
2023-01-30  9:31   ` [PATCH V2 10/10] net/hns3: fix incorrect check for duplicate RSS rule Dongdong Liu
2023-01-31 13:02 ` [PATCH V3 00/10] net/hns3: some bugfixes for rss Dongdong Liu
2023-01-31 13:02   ` [PATCH V3 01/10] net/hns3: fix error log about indirection table size Dongdong Liu
2023-01-31 13:02   ` [PATCH V3 02/10] net/hns3: extract common API to query device Dongdong Liu
2023-01-31 13:02   ` [PATCH V3 03/10] net/hns3: refactor set RSS hash algorithm and key interface Dongdong Liu
2023-01-31 13:02   ` [PATCH V3 04/10] net/hns3: fix fixed RSS key size to be more compatibility Dongdong Liu
2023-01-31 13:02   ` [PATCH V3 05/10] net/hns3: fix misclearing RSS configuration Dongdong Liu
2023-01-31 13:02   ` [PATCH V3 06/10] net/hns3: using RSS filter list to check duplicated rule Dongdong Liu
2023-01-31 13:02   ` [PATCH V3 07/10] net/hns3: remove useless code when destroy valid RSS rule Dongdong Liu
2023-01-31 13:02   ` [PATCH V3 08/10] net/hns3: fix useless warning when flush or destroy rule Dongdong Liu
2023-01-31 13:02   ` [PATCH V3 09/10] net/hns3: fix bad memory structure conversion Dongdong Liu
2023-01-31 13:03   ` [PATCH V3 10/10] net/hns3: fix incorrect check for duplicate RSS rule Dongdong Liu
2023-02-08 17:46   ` [PATCH V3 00/10] net/hns3: some bugfixes for rss Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5e1bc8d5-84ac-95ab-8d1b-6589dc5b5c82@huawei.com \
    --to=liudongdong3@huawei.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=lihuisong@huawei.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    --cc=yisen.zhuang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).