From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasesh Mody Subject: [PATCH v4 22/62] net/qede/base: check active VF queues before stopping Date: Mon, 27 Mar 2017 23:51:52 -0700 Message-ID: <1490683952-24919-23-git-send-email-rasesh.mody@cavium.com> References: <798af029-9a26-9065-350b-48781c1d3c55@intel.com> Mime-Version: 1.0 Content-Type: text/plain Cc: Rasesh Mody To: , Return-path: Received: from mx0b-0016ce01.pphosted.com (mx0a-0016ce01.pphosted.com [67.231.148.157]) by dpdk.org (Postfix) with ESMTP id 24F5769D4 for ; Tue, 28 Mar 2017 08:54:51 +0200 (CEST) In-Reply-To: <798af029-9a26-9065-350b-48781c1d3c55@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Make sure VF queue are closed before stopping vport. Signed-off-by: Rasesh Mody --- drivers/net/qede/base/ecore_sriov.c | 37 ++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/net/qede/base/ecore_sriov.c b/drivers/net/qede/base/ecore_sriov.c index 365be25..73c4015 100644 --- a/drivers/net/qede/base/ecore_sriov.c +++ b/drivers/net/qede/base/ecore_sriov.c @@ -232,6 +232,30 @@ static bool ecore_iov_validate_sb(struct ecore_hwfn *p_hwfn, return false; } +static bool ecore_iov_validate_active_rxq(struct ecore_hwfn *p_hwfn, + struct ecore_vf_info *p_vf) +{ + u8 i; + + for (i = 0; i < p_vf->num_rxqs; i++) + if (p_vf->vf_queues[i].rxq_active) + return true; + + return false; +} + +static bool ecore_iov_validate_active_txq(struct ecore_hwfn *p_hwfn, + struct ecore_vf_info *p_vf) +{ + u8 i; + + for (i = 0; i < p_vf->num_rxqs; i++) + if (p_vf->vf_queues[i].txq_active) + return true; + + return false; +} + /* TODO - this is linux crc32; Need a way to ifdef it out for linux */ u32 ecore_crc32(u32 crc, u8 *ptr, u32 length) { @@ -1365,8 +1389,10 @@ static void ecore_iov_vf_cleanup(struct ecore_hwfn *p_hwfn, p_vf->num_active_rxqs = 0; - for (i = 0; i < ECORE_MAX_VF_CHAINS_PER_PF; i++) + for (i = 0; i < ECORE_MAX_VF_CHAINS_PER_PF; i++) { p_vf->vf_queues[i].rxq_active = 0; + p_vf->vf_queues[i].txq_active = 0; + } OSAL_MEMSET(&p_vf->shadow_config, 0, sizeof(p_vf->shadow_config)); OSAL_MEMSET(&p_vf->acquire, 0, sizeof(p_vf->acquire)); @@ -1943,6 +1969,15 @@ static void ecore_iov_vf_mbx_stop_vport(struct ecore_hwfn *p_hwfn, vf->vport_instance--; vf->spoof_chk = false; + if ((ecore_iov_validate_active_rxq(p_hwfn, vf)) || + (ecore_iov_validate_active_txq(p_hwfn, vf))) { + vf->b_malicious = true; + DP_NOTICE(p_hwfn, false, + "VF [%02x] - considered malicious;" + " Unable to stop RX/TX queuess\n", + vf->abs_vf_id); + } + rc = ecore_sp_vport_stop(p_hwfn, vf->opaque_fid, vf->vport_id); if (rc != ECORE_SUCCESS) { DP_ERR(p_hwfn, -- 1.7.10.3