DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v1] net/i40e: fix virtual channel confiliction issue
@ 2020-09-20 15:28 Yuying Zhang
  2020-10-19  2:20 ` [dpdk-dev] [PATCH v2] " Yuying Zhang
  0 siblings, 1 reply; 6+ messages in thread
From: Yuying Zhang @ 2020-09-20 15:28 UTC (permalink / raw)
  To: dev, qi.z.zhang, beilei.xing; +Cc: Yuying Zhang, stable

i40evf_execute_vf_cmd() uses _atomic_set_cmd() to execute virtual
channel commands safely in multi-process mode. However, it returns -1
when one process is pending. Add a spinlock to wait for the virtual
channel will handle this issue in concurrent scenarios.

Fixes: 4861cde46116 ("i40e: new poll mode driver")
Cc: stable@dpdk.org

Signed-off-by: Yuying Zhang <yuying.zhang@intel.com>
---
 drivers/net/i40e/i40e_ethdev.h    | 1 +
 drivers/net/i40e/i40e_ethdev_vf.c | 8 +++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index 19f821829..514c0988b 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -1199,6 +1199,7 @@ struct i40e_vf {
 	uint16_t max_pkt_len; /* Maximum packet length */
 	bool promisc_unicast_enabled;
 	bool promisc_multicast_enabled;
+	rte_spinlock_t cmd_send_lock;
 
 	uint32_t version_major; /* Major version number */
 	uint32_t version_minor; /* Minor version number */
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 69cab8e73..7fdc58649 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -326,8 +326,11 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args)
 	enum i40evf_aq_result ret;
 	int err, i = 0;
 
-	if (_atomic_set_cmd(vf, args->ops))
+	rte_spinlock_lock(&vf->cmd_send_lock);
+	if (_atomic_set_cmd(vf, args->ops)) {
+		rte_spinlock_unlock(&vf->cmd_send_lock);
 		return -1;
+	}
 
 	info.msg = args->out_buffer;
 	info.buf_len = args->out_size;
@@ -339,6 +342,7 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args)
 	if (err) {
 		PMD_DRV_LOG(ERR, "fail to send cmd %d", args->ops);
 		_clear_cmd(vf);
+		rte_spinlock_unlock(&vf->cmd_send_lock);
 		return err;
 	}
 
@@ -406,6 +410,7 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args)
 		break;
 	}
 
+	rte_spinlock_unlock(&vf->cmd_send_lock);
 	return err | vf->cmd_retval;
 }
 
@@ -1249,6 +1254,7 @@ i40evf_init_vf(struct rte_eth_dev *dev)
 
 	vf->adapter = I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 	vf->dev_data = dev->data;
+	rte_spinlock_init(&vf->cmd_send_lock);
 	err = i40e_set_mac_type(hw);
 	if (err) {
 		PMD_INIT_LOG(ERR, "set_mac_type failed: %d", err);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [dpdk-dev] [PATCH v2] net/i40e: fix virtual channel confiliction issue
  2020-09-20 15:28 [dpdk-dev] [PATCH v1] net/i40e: fix virtual channel confiliction issue Yuying Zhang
@ 2020-10-19  2:20 ` Yuying Zhang
  2020-10-22  8:54   ` Zhang, Qi Z
  2020-10-23 10:41   ` Ferruh Yigit
  0 siblings, 2 replies; 6+ messages in thread
From: Yuying Zhang @ 2020-10-19  2:20 UTC (permalink / raw)
  To: dev, qi.z.zhang, beilei.xing; +Cc: Yuying Zhang, stable

i40evf_execute_vf_cmd() uses _atomic_set_cmd() to execute virtual
channel commands safely in multi-process mode and multi-thread mode.
However, it returns -1 when one process or thread is pending. Add
rte_spinlock_trylock() to handle this issue in concurrent scenarios.

Fixes: 4861cde46116 ("i40e: new poll mode driver")
Cc: stable@dpdk.org

Signed-off-by: Yuying Zhang <yuying.zhang@intel.com>
---
 drivers/net/i40e/i40e_ethdev.h    |  1 +
 drivers/net/i40e/i40e_ethdev_vf.c | 16 +++++++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index 1466998aa..508a940dc 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -1209,6 +1209,7 @@ struct i40e_vf {
 	bool promisc_unicast_enabled;
 	bool promisc_multicast_enabled;
 
+	rte_spinlock_t cmd_send_lock;
 	uint32_t version_major; /* Major version number */
 	uint32_t version_minor; /* Minor version number */
 	uint16_t promisc_flags; /* Promiscuous setting */
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 4d6510d1f..282db4721 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -314,7 +314,7 @@ _atomic_set_cmd(struct i40e_vf *vf, enum virtchnl_ops ops)
 #define ASQ_DELAY_MS  10
 
 static int
-i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args)
+_i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args)
 {
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
@@ -405,6 +405,19 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args)
 	return err | vf->cmd_retval;
 }
 
+static int
+i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args)
+{
+	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+	int err;
+
+	while (!rte_spinlock_trylock(&vf->cmd_send_lock))
+		rte_delay_us_sleep(50);
+	err = _i40evf_execute_vf_cmd(dev, args);
+	rte_spinlock_unlock(&vf->cmd_send_lock);
+	return err;
+}
+
 /*
  * Check API version with sync wait until version read or fail from admin queue
  */
@@ -1246,6 +1259,7 @@ i40evf_init_vf(struct rte_eth_dev *dev)
 
 	vf->adapter = I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 	vf->dev_data = dev->data;
+	rte_spinlock_init(&vf->cmd_send_lock);
 	err = i40e_set_mac_type(hw);
 	if (err) {
 		PMD_INIT_LOG(ERR, "set_mac_type failed: %d", err);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/i40e: fix virtual channel confiliction issue
  2020-10-19  2:20 ` [dpdk-dev] [PATCH v2] " Yuying Zhang
@ 2020-10-22  8:54   ` Zhang, Qi Z
  2020-10-23 10:41   ` Ferruh Yigit
  1 sibling, 0 replies; 6+ messages in thread
From: Zhang, Qi Z @ 2020-10-22  8:54 UTC (permalink / raw)
  To: Zhang, Yuying, dev, Xing, Beilei; +Cc: stable



> -----Original Message-----
> From: Zhang, Yuying <yuying.zhang@intel.com>
> Sent: Monday, October 19, 2020 10:20 AM
> To: dev@dpdk.org; Zhang, Qi Z <qi.z.zhang@intel.com>; Xing, Beilei
> <beilei.xing@intel.com>
> Cc: Zhang, Yuying <yuying.zhang@intel.com>; stable@dpdk.org
> Subject: [PATCH v2] net/i40e: fix virtual channel confiliction issue
> 
> i40evf_execute_vf_cmd() uses _atomic_set_cmd() to execute virtual channel
> commands safely in multi-process mode and multi-thread mode.
> However, it returns -1 when one process or thread is pending. Add
> rte_spinlock_trylock() to handle this issue in concurrent scenarios.
> 
> Fixes: 4861cde46116 ("i40e: new poll mode driver")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Yuying Zhang <yuying.zhang@intel.com>

Acked-by: Qi Zhang <qi.z.zhang@intel.com>

Applied to dpdk-next-net-intel.

Thanks
Qi

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/i40e: fix virtual channel confiliction issue
  2020-10-19  2:20 ` [dpdk-dev] [PATCH v2] " Yuying Zhang
  2020-10-22  8:54   ` Zhang, Qi Z
@ 2020-10-23 10:41   ` Ferruh Yigit
  2020-10-30  5:32     ` Zhang, Yuying
  1 sibling, 1 reply; 6+ messages in thread
From: Ferruh Yigit @ 2020-10-23 10:41 UTC (permalink / raw)
  To: Yuying Zhang, dev, qi.z.zhang, beilei.xing; +Cc: stable

On 10/19/2020 3:20 AM, Yuying Zhang wrote:
> i40evf_execute_vf_cmd() uses _atomic_set_cmd() to execute virtual
> channel commands safely in multi-process mode and multi-thread mode.
> However, it returns -1 when one process or thread is pending. Add
> rte_spinlock_trylock() to handle this issue in concurrent scenarios.
> 

Should '_atomic_set_cmd()' removed, since spinlock it added?

> Fixes: 4861cde46116 ("i40e: new poll mode driver")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Yuying Zhang <yuying.zhang@intel.com>

<...>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/i40e: fix virtual channel confiliction issue
  2020-10-23 10:41   ` Ferruh Yigit
@ 2020-10-30  5:32     ` Zhang, Yuying
  2020-10-30  8:30       ` Ferruh Yigit
  0 siblings, 1 reply; 6+ messages in thread
From: Zhang, Yuying @ 2020-10-30  5:32 UTC (permalink / raw)
  To: Yigit, Ferruh, dev, Zhang, Qi Z, Xing, Beilei; +Cc: stable



> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@intel.com>
> Sent: Friday, October 23, 2020 6:42 PM
> To: Zhang, Yuying <yuying.zhang@intel.com>; dev@dpdk.org; Zhang, Qi Z
> <qi.z.zhang@intel.com>; Xing, Beilei <beilei.xing@intel.com>
> Cc: stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v2] net/i40e: fix virtual channel confiliction issue
> 
> On 10/19/2020 3:20 AM, Yuying Zhang wrote:
> > i40evf_execute_vf_cmd() uses _atomic_set_cmd() to execute virtual
> > channel commands safely in multi-process mode and multi-thread mode.
> > However, it returns -1 when one process or thread is pending. Add
> > rte_spinlock_trylock() to handle this issue in concurrent scenarios.
> >
> 
> Should '_atomic_set_cmd()' removed, since spinlock it added?
> 
> > Fixes: 4861cde46116 ("i40e: new poll mode driver")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Yuying Zhang <yuying.zhang@intel.com>
> 
> <...>
'_atomic_set_cmd()' is also used for sync with i40evf_handle_aq_msg to handle the request <-> response.
It is not just used for multi-task. I prefer to keep the atomic.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/i40e: fix virtual channel confiliction issue
  2020-10-30  5:32     ` Zhang, Yuying
@ 2020-10-30  8:30       ` Ferruh Yigit
  0 siblings, 0 replies; 6+ messages in thread
From: Ferruh Yigit @ 2020-10-30  8:30 UTC (permalink / raw)
  To: Zhang, Yuying, dev, Zhang, Qi Z, Xing, Beilei; +Cc: stable

On 10/30/2020 5:32 AM, Zhang, Yuying wrote:
> 
> 
>> -----Original Message-----
>> From: Ferruh Yigit <ferruh.yigit@intel.com>
>> Sent: Friday, October 23, 2020 6:42 PM
>> To: Zhang, Yuying <yuying.zhang@intel.com>; dev@dpdk.org; Zhang, Qi Z
>> <qi.z.zhang@intel.com>; Xing, Beilei <beilei.xing@intel.com>
>> Cc: stable@dpdk.org
>> Subject: Re: [dpdk-dev] [PATCH v2] net/i40e: fix virtual channel confiliction issue
>>
>> On 10/19/2020 3:20 AM, Yuying Zhang wrote:
>>> i40evf_execute_vf_cmd() uses _atomic_set_cmd() to execute virtual
>>> channel commands safely in multi-process mode and multi-thread mode.
>>> However, it returns -1 when one process or thread is pending. Add
>>> rte_spinlock_trylock() to handle this issue in concurrent scenarios.
>>>
>>
>> Should '_atomic_set_cmd()' removed, since spinlock it added?
>>
>>> Fixes: 4861cde46116 ("i40e: new poll mode driver")
>>> Cc: stable@dpdk.org
>>>
>>> Signed-off-by: Yuying Zhang <yuying.zhang@intel.com>
>>
>> <...>
> '_atomic_set_cmd()' is also used for sync with i40evf_handle_aq_msg to handle the request <-> response.
> It is not just used for multi-task. I prefer to keep the atomic.
> 

OK

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-10-30  8:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-20 15:28 [dpdk-dev] [PATCH v1] net/i40e: fix virtual channel confiliction issue Yuying Zhang
2020-10-19  2:20 ` [dpdk-dev] [PATCH v2] " Yuying Zhang
2020-10-22  8:54   ` Zhang, Qi Z
2020-10-23 10:41   ` Ferruh Yigit
2020-10-30  5:32     ` Zhang, Yuying
2020-10-30  8:30       ` Ferruh Yigit

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).