DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Zhang, Qi Z" <qi.z.zhang@intel.com>
To: Mike Pattrick <mkp@redhat.com>, "dev@dpdk.org" <dev@dpdk.org>
Cc: "thomas@monjalon.net" <thomas@monjalon.net>,
	"david.marchand@redhat.com" <david.marchand@redhat.com>,
	"Zhou, YidingX" <yidingx.zhou@intel.com>,
	"ktraynor@redhat.com" <ktraynor@redhat.com>,
	"stable@dpdk.org" <stable@dpdk.org>
Subject: RE: [PATCH v2] net/iavf: add lock for vf commands
Date: Mon, 26 Dec 2022 06:01:31 +0000	[thread overview]
Message-ID: <DM4PR11MB599427B845286E5DCD3B35A1D7EC9@DM4PR11MB5994.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20221220155414.266309-1-mkp@redhat.com>



> -----Original Message-----
> From: Mike Pattrick <mkp@redhat.com>
> Sent: Tuesday, December 20, 2022 11:54 PM
> To: dev@dpdk.org
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; thomas@monjalon.net;
> david.marchand@redhat.com; Zhou, YidingX <yidingx.zhou@intel.com>;
> ktraynor@redhat.com; Mike Pattrick <mkp@redhat.com>; stable@dpdk.org
> Subject: [PATCH v2] net/iavf: add lock for vf commands
> 
> iavf admin queue commands aren't thread-safe. Bugs surrounding this issue
> can manifest in a variety of ways but frequently pend_cmd is over written.
> Simultaneously executing commands can result in a misconfigured device or
> DPDK sleeping in a thread for 2 second.
> 
> Despite this limitation, vf commands may be executed from both
> iavf_dev_alarm_handler() in a control thread and the applications main
> thread. This is trivial to simulate in the testpmd application by creating a
> bond of vf's in active backup mode, and then turning the bond off and then
> on again repeatedly.
> 
> Previously [1] was proposed as a potential solution, but this commit did not
> resolve all potential issues concerning the admin queue and has been
> reverted from the stable branch. I propose adding locks until a more
> complete solution is available.
> 
> [1] commit cb5c1b91f76f ("net/iavf: add thread for event callbacks")
> 
> Fixes: 48de41ca11f0 ("net/avf: enable link status update")
> Fixes: 84108425054a ("net/iavf: support asynchronous virtual channel
> message")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Mike Pattrick <mkp@redhat.com>
> 
> ---
> 
> v2:
>  - Added locks around some iavf_execute_vf_cmd calls which were missed  in
> v1
>  - Changed description to indicate that [1] was only reverted out of the  stable
> branch.
> ---
>  drivers/net/iavf/iavf.h       |  1 +
>  drivers/net/iavf/iavf_vchnl.c | 90 +++++++++++++++++++++++++++++++++++
>  2 files changed, 91 insertions(+)
> 
> diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h index
> 1edebab8dc..aa18650ffa 100644
> --- a/drivers/net/iavf/iavf.h
> +++ b/drivers/net/iavf/iavf.h
> @@ -262,6 +262,7 @@ struct iavf_info {
>  	struct iavf_qv_map *qv_map; /* queue vector mapping */
>  	struct iavf_flow_list flow_list;
>  	rte_spinlock_t flow_ops_lock;
> +	rte_spinlock_t aq_lock;
>  	struct iavf_parser_list rss_parser_list;
>  	struct iavf_parser_list dist_parser_list;
>  	struct iavf_parser_list ipsec_crypto_parser_list; diff --git
> a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c index
> f92daf97f2..edb74edcac 100644
> --- a/drivers/net/iavf/iavf_vchnl.c
> +++ b/drivers/net/iavf/iavf_vchnl.c
> @@ -554,7 +554,9 @@ iavf_enable_vlan_strip(struct iavf_adapter *adapter)
>  	args.in_args_size = 0;
>  	args.out_buffer = vf->aq_resp;
>  	args.out_size = IAVF_AQ_BUF_SZ;
> +	rte_spinlock_lock(&vf->aq_lock);
>  	ret = iavf_execute_vf_cmd(adapter, &args, 0);
> +	rte_spinlock_unlock(&vf->aq_lock);
>  	if (ret)
>  		PMD_DRV_LOG(ERR, "Failed to execute command of"
>  			    " OP_ENABLE_VLAN_STRIPPING");
> @@ -575,7 +577,9 @@ iavf_disable_vlan_strip(struct iavf_adapter *adapter)
>  	args.in_args_size = 0;
>  	args.out_buffer = vf->aq_resp;
>  	args.out_size = IAVF_AQ_BUF_SZ;
> +	rte_spinlock_lock(&vf->aq_lock);
>  	ret = iavf_execute_vf_cmd(adapter, &args, 0);
> +	rte_spinlock_unlock(&vf->aq_lock);
>  	if (ret)
>  		PMD_DRV_LOG(ERR, "Failed to execute command of"
>  			    " OP_DISABLE_VLAN_STRIPPING");
> @@ -604,7 +608,9 @@ iavf_check_api_version(struct iavf_adapter *adapter)
>  	args.out_buffer = vf->aq_resp;
>  	args.out_size = IAVF_AQ_BUF_SZ;
> 
> +	rte_spinlock_lock(&vf->aq_lock);
>  	err = iavf_execute_vf_cmd(adapter, &args, 0);
> +	rte_spinlock_unlock(&vf->aq_lock);

Instead of wrapping lock and unlock every place, can we add a new wrap function e.g.: iavf_execute_vf_cmd_safe? 



  reply	other threads:[~2022-12-26  6:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-19 23:23 [PATCH] " Mike Pattrick
2022-12-20 15:02 ` David Marchand
2022-12-20 15:54   ` [PATCH v2] " Mike Pattrick
2022-12-26  6:01     ` Zhang, Qi Z [this message]
2022-12-28 22:28     ` [PATCH v3] " Mike Pattrick
2022-12-28 23:00     ` [PATCH v4] " Mike Pattrick
2023-01-13 13:35       ` David Marchand
2023-01-17  1:20       ` Zhang, Qi Z

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=DM4PR11MB599427B845286E5DCD3B35A1D7EC9@DM4PR11MB5994.namprd11.prod.outlook.com \
    --to=qi.z.zhang@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=ktraynor@redhat.com \
    --cc=mkp@redhat.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    --cc=yidingx.zhou@intel.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).