From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 36ABBA00BE for ; Wed, 20 Apr 2022 13:03:10 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 130B8406A2; Wed, 20 Apr 2022 13:03:10 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id A081F40687; Wed, 20 Apr 2022 13:03:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650452588; x=1681988588; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=XxJYE4v9JXkw8NzWNvLh1trXqblLOYqwKOm5HAViCvM=; b=ir8qZXf36wGxZeYQMnslE7ZlY/QbUxYXOm+mlQO3koVd1kILPEHujwOc nHr40aaFpFSUt3otbQbIVfC1YZmt43/bzhJUpu0x7Rz6752zId4TFPJFK Cm7e17XebueH0yIFJVzcfc6CwM6udlQqZl4UlxyrK7qezJ3XJPBcAxOTW HbW0UZnSfARJVKNOX3zsKxrx6veOomJU/myMMmZFMlBzL3WChBK+fBVnI haaXjUycYsUTFAKo23OAK+G58uBos1OxbTbpB5KL0bvjFvO1g34vxuLFo VARw3/yLpbNYKyWcHfv7i7rrh4VsxLxga5TOfiVKpR0Nini9flfs8tRWJ Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10322"; a="262856811" X-IronPort-AV: E=Sophos;i="5.90,275,1643702400"; d="scan'208";a="262856811" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2022 04:03:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,275,1643702400"; d="scan'208";a="529705278" Received: from silpixa00400884.ir.intel.com ([10.243.22.82]) by orsmga006.jf.intel.com with ESMTP; 20 Apr 2022 04:03:04 -0700 From: Radu Nicolau To: Jingjing Wu , Beilei Xing Cc: dev@dpdk.org, daniel.m.buckley@intel.com, qi.z.zhang@intel.com, Radu Nicolau , stable@dpdk.org Subject: [PATCH] net/iavf: fix device initialization Date: Wed, 20 Apr 2022 12:03:01 +0100 Message-Id: <20220420110301.2913603-1-radu.nicolau@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org When the inline crypto feature VF capability flag is set also check if the feature is enabled, otherwise the initialization will fail even when the inline crypto is not required. Fixes: 6bc987ecb860 ("net/iavf: support IPsec inline crypto") Cc: stable@dpdk.org Signed-off-by: Radu Nicolau --- drivers/net/iavf/iavf_ipsec_crypto.c | 69 ++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 3 deletions(-) diff --git a/drivers/net/iavf/iavf_ipsec_crypto.c b/drivers/net/iavf/iavf_ipsec_crypto.c index b1949cee91..72ce39a052 100644 --- a/drivers/net/iavf/iavf_ipsec_crypto.c +++ b/drivers/net/iavf/iavf_ipsec_crypto.c @@ -1563,17 +1563,80 @@ iavf_security_ctx_destroy(struct iavf_adapter *adapter) return 0; } +static int +iavf_ipsec_crypto_status_get(struct iavf_adapter *adapter, + struct virtchnl_ipsec_status *status) +{ + /* Perform pf-vf comms */ + struct inline_ipsec_msg *request = NULL, *response = NULL; + size_t request_len, response_len; + int rc; + + request_len = sizeof(struct inline_ipsec_msg); + + request = rte_malloc("iavf-device-status-request", request_len, 0); + if (request == NULL) { + rc = -ENOMEM; + goto update_cleanup; + } + + response_len = sizeof(struct inline_ipsec_msg) + + sizeof(struct virtchnl_ipsec_cap); + response = rte_malloc("iavf-device-status-response", + response_len, 0); + if (response == NULL) { + rc = -ENOMEM; + goto update_cleanup; + } + + /* set msg header params */ + request->ipsec_opcode = INLINE_IPSEC_OP_GET_STATUS; + request->req_id = (uint16_t)0xDEADBEEF; + + /* send virtual channel request to add SA to hardware database */ + rc = iavf_ipsec_crypto_request(adapter, + (uint8_t *)request, request_len, + (uint8_t *)response, response_len); + if (rc) + goto update_cleanup; + + /* verify response id */ + if (response->ipsec_opcode != request->ipsec_opcode || + response->req_id != request->req_id){ + rc = -EFAULT; + goto update_cleanup; + } + memcpy(status, response->ipsec_data.ipsec_status, sizeof(*status)); + +update_cleanup: + rte_free(response); + rte_free(request); + + return rc; +} + + int iavf_ipsec_crypto_supported(struct iavf_adapter *adapter) { struct virtchnl_vf_resource *resources = adapter->vf.vf_res; + int crypto_supported = false; /** Capability check for IPsec Crypto */ if (resources && (resources->vf_cap_flags & - VIRTCHNL_VF_OFFLOAD_INLINE_IPSEC_CRYPTO)) - return true; + VIRTCHNL_VF_OFFLOAD_INLINE_IPSEC_CRYPTO)) { + struct virtchnl_ipsec_status status; + int rc = iavf_ipsec_crypto_status_get(adapter, &status); + if (rc == 0 && status.status == INLINE_IPSEC_STATUS_AVAILABLE) + crypto_supported = true; + } - return false; + /* Clear the VF flag to return faster next call */ + if (resources && !crypto_supported) + resources->vf_cap_flags &= + ~(VIRTCHNL_VF_OFFLOAD_INLINE_IPSEC_CRYPTO); + + return crypto_supported; } #define IAVF_IPSEC_INSET_ESP (\ -- 2.25.1