netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net-next 1/2] i40e: Do not check VF state in i40e_ndo_get_vf_config
@ 2019-06-05 19:45 Jeff Kirsher
  2019-06-05 19:45 ` [net-next 2/2] i40e: Check and set the PF driver state first in i40e_ndo_set_vf_mac Jeff Kirsher
  2019-06-05 23:53 ` [net-next 1/2] i40e: Do not check VF state in i40e_ndo_get_vf_config David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Jeff Kirsher @ 2019-06-05 19:45 UTC (permalink / raw)
  To: davem; +Cc: Lihong Yang, netdev, nhorman, sassmann, Andrew Bowers, Jeff Kirsher

From: Lihong Yang <lihong.yang@intel.com>

The VF configuration returned in i40e_ndo_get_vf_config is
already stored by the PF. There is no dependency on any
specific state of the VF to return the configuration.
Drop the check against I40E_VF_STATE_INIT since it is not
needed.

Signed-off-by: Lihong Yang <lihong.yang@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index 479bc60c8f71..f14367834318 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -4302,10 +4302,8 @@ int i40e_ndo_get_vf_config(struct net_device *netdev,
 	vf = &pf->vf[vf_id];
 	/* first vsi is always the LAN vsi */
 	vsi = pf->vsi[vf->lan_vsi_idx];
-	if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states)) {
-		dev_err(&pf->pdev->dev, "VF %d still in reset. Try again.\n",
-			vf_id);
-		ret = -EAGAIN;
+	if (!vsi) {
+		ret = -ENOENT;
 		goto error_param;
 	}
 
-- 
2.21.0


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

* [net-next 2/2] i40e: Check and set the PF driver state first in i40e_ndo_set_vf_mac
  2019-06-05 19:45 [net-next 1/2] i40e: Do not check VF state in i40e_ndo_get_vf_config Jeff Kirsher
@ 2019-06-05 19:45 ` Jeff Kirsher
  2019-06-05 23:53   ` David Miller
  2019-06-05 23:53 ` [net-next 1/2] i40e: Do not check VF state in i40e_ndo_get_vf_config David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Jeff Kirsher @ 2019-06-05 19:45 UTC (permalink / raw)
  To: davem; +Cc: Lihong Yang, netdev, nhorman, sassmann, Jeff Kirsher

From: Lihong Yang <lihong.yang@intel.com>

The PF driver state flag __I40E_VIRTCHNL_OP_PENDING needs to be
checked and set at the beginning of i40e_ndo_set_vf_mac. Otherwise,
if there are error conditions before it, the flag will be cleared
unexpectedly by this function to cause potential race conditions.
Hence move the check to the top of this function.

Signed-off-by: Lihong Yang <lihong.yang@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index f14367834318..09a7fd4d24e8 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -3943,6 +3943,11 @@ int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)
 	int bkt;
 	u8 i;
 
+	if (test_and_set_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state)) {
+		dev_warn(&pf->pdev->dev, "Unable to configure VFs, other operation is pending.\n");
+		return -EAGAIN;
+	}
+
 	/* validate the request */
 	ret = i40e_validate_vf(pf, vf_id);
 	if (ret)
@@ -3967,11 +3972,6 @@ int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)
 		goto error_param;
 	}
 
-	if (test_and_set_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state)) {
-		dev_warn(&pf->pdev->dev, "Unable to configure VFs, other operation is pending.\n");
-		return -EAGAIN;
-	}
-
 	if (is_multicast_ether_addr(mac)) {
 		dev_err(&pf->pdev->dev,
 			"Invalid Ethernet address %pM for VF %d\n", mac, vf_id);
-- 
2.21.0


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

* Re: [net-next 1/2] i40e: Do not check VF state in i40e_ndo_get_vf_config
  2019-06-05 19:45 [net-next 1/2] i40e: Do not check VF state in i40e_ndo_get_vf_config Jeff Kirsher
  2019-06-05 19:45 ` [net-next 2/2] i40e: Check and set the PF driver state first in i40e_ndo_set_vf_mac Jeff Kirsher
@ 2019-06-05 23:53 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2019-06-05 23:53 UTC (permalink / raw)
  To: jeffrey.t.kirsher; +Cc: lihong.yang, netdev, nhorman, sassmann, andrewx.bowers

From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Date: Wed,  5 Jun 2019 12:45:15 -0700

> From: Lihong Yang <lihong.yang@intel.com>
> 
> The VF configuration returned in i40e_ndo_get_vf_config is
> already stored by the PF. There is no dependency on any
> specific state of the VF to return the configuration.
> Drop the check against I40E_VF_STATE_INIT since it is not
> needed.
> 
> Signed-off-by: Lihong Yang <lihong.yang@intel.com>
> Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>

Applied.

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

* Re: [net-next 2/2] i40e: Check and set the PF driver state first in i40e_ndo_set_vf_mac
  2019-06-05 19:45 ` [net-next 2/2] i40e: Check and set the PF driver state first in i40e_ndo_set_vf_mac Jeff Kirsher
@ 2019-06-05 23:53   ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-06-05 23:53 UTC (permalink / raw)
  To: jeffrey.t.kirsher; +Cc: lihong.yang, netdev, nhorman, sassmann

From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Date: Wed,  5 Jun 2019 12:45:16 -0700

> From: Lihong Yang <lihong.yang@intel.com>
> 
> The PF driver state flag __I40E_VIRTCHNL_OP_PENDING needs to be
> checked and set at the beginning of i40e_ndo_set_vf_mac. Otherwise,
> if there are error conditions before it, the flag will be cleared
> unexpectedly by this function to cause potential race conditions.
> Hence move the check to the top of this function.
> 
> Signed-off-by: Lihong Yang <lihong.yang@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>

Applied.

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

end of thread, other threads:[~2019-06-05 23:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-05 19:45 [net-next 1/2] i40e: Do not check VF state in i40e_ndo_get_vf_config Jeff Kirsher
2019-06-05 19:45 ` [net-next 2/2] i40e: Check and set the PF driver state first in i40e_ndo_set_vf_mac Jeff Kirsher
2019-06-05 23:53   ` David Miller
2019-06-05 23:53 ` [net-next 1/2] i40e: Do not check VF state in i40e_ndo_get_vf_config David Miller

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