DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Lijun Ou <oulijun@huawei.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
	"linuxarm@huawei.com" <linuxarm@huawei.com>
Subject: Re: [dpdk-dev] [PATCH 5/7] net/hns3: fix location of saving ethdev
Date: Fri, 18 Dec 2020 14:11:14 +0000	[thread overview]
Message-ID: <5d570e4d-5acb-f8f6-b58e-58d7a34bff55@intel.com> (raw)
In-Reply-To: <1607846585-2381-6-git-send-email-oulijun@huawei.com>

On 12/13/2020 8:03 AM, Lijun Ou wrote:
> From: "Min Hu (Connor)" <humin29@huawei.com>
> 
> In current version, procedure of saving eth_dev in
> hns3 PMD init will be called more than twice, one
> for primary, the other for secondary. That will cause
> segmentation fault in Multi-process as eth_dev will
> be changed in secondary process, which is different
> from one in primary process.
> This patch saved eth_dev in dev_private only in
> primary process, as dev_private is shared by primary
> process and secondary process.
> 
> Fixes: 8929efbc1c46 ("net/hns3: fix FEC state query")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
> Signed-off-by: Lijun Ou <oulijun@huawei.com>
> ---
>   drivers/net/hns3/hns3_ethdev.c    | 3 +--
>   drivers/net/hns3/hns3_ethdev_vf.c | 1 +
>   2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
> index 7c34e38..f49b779 100644
> --- a/drivers/net/hns3/hns3_ethdev.c
> +++ b/drivers/net/hns3/hns3_ethdev.c
> @@ -6106,8 +6106,6 @@ hns3_dev_init(struct rte_eth_dev *eth_dev)
>   
>   	PMD_INIT_FUNC_TRACE();
>   
> -	hns->eth_dev = eth_dev;
> -
>   	eth_dev->process_private = (struct hns3_process_private *)
>   	    rte_zmalloc_socket("hns3_filter_list",
>   			       sizeof(struct hns3_process_private),
> @@ -6134,6 +6132,7 @@ hns3_dev_init(struct rte_eth_dev *eth_dev)
>   		return 0;
>   	}
>   
> +	hns->eth_dev = eth_dev;
>   	eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
>   

The definition of the problem is correct, but with this update the 
'hns->eth_dev' will be wrong for the secondary process.

The initial problem was access to 'rte_eth_devices' global variable, which is 
wrong. But current approach can cause problem for the secondaries, moving 
'eth_dev' to process private can work but before making things more complex,
I would like to check why it is needed.

The usage is as following:

hns3_query_dev_fec_info(struct hns3_hw *hw)
	struct rte_eth_dev *eth_dev = hns->eth_dev;
	ret = hns3_fec_get(eth_dev, &pf->fec_mode);

hns3_fec_get(struct rte_eth_dev *dev, uint32_t *fec_capa)
	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);


Here since 'hns3_fec_get()' is dev_ops, it needs to get 'eth_dev' as parameter. 
Trying to use it internally forces to know 'eth_dev', but instead it can be 
possible to create an internal function that gets "struct hns3_hw" as parameter 
and it can be called internally without knowing 'eth_dev', and the .dev_ops can 
be wrapper to this,
I mean something like this, what do you think:

hns3_fec_get_internal(struct hns3_hw *hw, uint32_t *fec_capa);

hns3_query_dev_fec_info(struct hns3_hw *hw)
	ret = hns3_fec_get_internal(hw, &pf->fec_mode);

hns3_fec_get(struct rte_eth_dev *dev, uint32_t *fec_capa)
	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
	hns3_fec_get_internal(hw, fec_capa)


There is other patch to switch to 'hns->eth_dev', I wonder can same approach be 
applied to those usages?



  reply	other threads:[~2020-12-18 14:11 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-13  8:02 [dpdk-dev] [PATCH 0/7] some bugfixes for hns3 Lijun Ou
2020-12-13  8:02 ` [dpdk-dev] [PATCH 1/7] net/hns3: fix incorrect interception with filter director Lijun Ou
2020-12-13  8:03 ` [dpdk-dev] [PATCH 2/7] net/hns3: fix xstats statistics with id Lijun Ou
2020-12-17 15:20   ` Ferruh Yigit
2020-12-18  7:06     ` oulijun
2020-12-18 13:34       ` Ferruh Yigit
2020-12-13  8:03 ` [dpdk-dev] [PATCH 3/7] net/hns3: fix abnormal return value in xstats Lijun Ou
2020-12-13  8:03 ` [dpdk-dev] [PATCH 4/7] net/hns3: fix Rx/Tx abnormal errors stats Lijun Ou
2020-12-13  8:03 ` [dpdk-dev] [PATCH 5/7] net/hns3: fix location of saving ethdev Lijun Ou
2020-12-18 14:11   ` Ferruh Yigit [this message]
2020-12-13  8:03 ` [dpdk-dev] [PATCH 6/7] net/hns3: fix directly access with rte device Lijun Ou
2020-12-13  8:03 ` [dpdk-dev] [PATCH 7/7] net/hns3: remove unnecessary memset Lijun Ou
2021-01-06  3:46 ` [dpdk-dev] [PATCH v2 0/6] some bugfixes for hns3 Lijun Ou
2021-01-06  3:46   ` [dpdk-dev] [PATCH v2 1/6] net/hns3: fix incorrect interception with filter director Lijun Ou
2021-01-19 21:27     ` Thomas Monjalon
2021-01-06  3:46   ` [dpdk-dev] [PATCH v2 2/6] net/hns3: fix xstats statistics with id and names Lijun Ou
2021-01-06  3:46   ` [dpdk-dev] [PATCH v2 3/6] net/hns3: fix abnormal return value in xstats Lijun Ou
2021-01-06  3:46   ` [dpdk-dev] [PATCH v2 4/6] net/hns3: fix Rx/Tx abnormal errors stats Lijun Ou
2021-01-06  3:46   ` [dpdk-dev] [PATCH v2 5/6] net/hns3: fix crash with multi-process Lijun Ou
2021-01-06  3:46   ` [dpdk-dev] [PATCH v2 6/6] net/hns3: remove unnecessary memset Lijun Ou
2021-01-14 23:34   ` [dpdk-dev] [PATCH v2 0/6] some bugfixes for hns3 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=5d570e4d-5acb-f8f6-b58e-58d7a34bff55@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=dev@dpdk.org \
    --cc=linuxarm@huawei.com \
    --cc=oulijun@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).