From patchwork Wed Sep 20 06:22:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simei Su X-Patchwork-Id: 131663 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 470C1425E9; Wed, 20 Sep 2023 08:22:56 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6440840DCD; Wed, 20 Sep 2023 08:22:32 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id 4606440DCE for ; Wed, 20 Sep 2023 08:22:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695190950; x=1726726950; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YIXtmR3F6j533+wnP/110K8+BIFrwlK36OSItmBKQj4=; b=Pab25MP/YQxaBjfc1aOETaYOeQRs51BH8wokSicH6g8qGCZaiu402qVc sbdZeF7nsFIhrNHaU+kCqdFFmiU0phwVt/TzkX4FN5mP2PZ0OYZFeieRL 8BnxRUJpbtOvOHG2TT9XPtkE4vq11p4fBaCGz4S0hGX/6/fCMZFTeSGDd SiDMcfimomHqxmuLJ4LR8hKbIq4G+tW1ocF3OGWMV98xOE/iUiyLFxpXu jmugkCx+smQNzp6vm16yn1s1iPZpo1wkV3F1n7cKTmrO/Bom6dhZrfzgG 1vUw7k/MAP3rmoa0KZ5f5idHStotInA+O18rezobJCFXdkNeMqxDR/fiM w==; X-IronPort-AV: E=McAfee;i="6600,9927,10838"; a="466453258" X-IronPort-AV: E=Sophos;i="6.02,161,1688454000"; d="scan'208";a="466453258" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Sep 2023 23:22:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10838"; a="920154654" X-IronPort-AV: E=Sophos;i="6.02,161,1688454000"; d="scan'208";a="920154654" Received: from dpdk-simei-icelake.sh.intel.com ([10.67.110.167]) by orsmga005.jf.intel.com with ESMTP; 19 Sep 2023 23:22:26 -0700 From: Simei Su To: jingjing.wu@intel.com, beilei.xing@intel.com, qi.z.zhang@intel.com Cc: dev@dpdk.org, wenjun1.wu@intel.com, mingxia.liu@intel.com, wenjing.qiao@intel.com, Simei Su , Shailendra Bhatnagar , Julianx Grajkowski Subject: [PATCH v5 06/11] common/idpf/base: refine structure and necessary check Date: Wed, 20 Sep 2023 14:22:31 +0800 Message-Id: <20230920062236.375308-7-simei.su@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230920062236.375308-1-simei.su@intel.com> References: <20230918021130.192982-1-simei.su@intel.com> <20230920062236.375308-1-simei.su@intel.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org a) Refine queue chunk and vector chunk structures. b) Add non_flex prefix to distinguish the flex array definitions. c) Add some specific fields. d) Refine condition check. Signed-off-by: Shailendra Bhatnagar Signed-off-by: Julianx Grajkowski Signed-off-by: Simei Su Acked-by: Beilei Xing --- .mailmap | 2 + drivers/common/idpf/base/idpf_common.c | 6 ++- drivers/common/idpf/base/virtchnl2.h | 72 +++++++++++++++++--------- 3 files changed, 54 insertions(+), 26 deletions(-) diff --git a/.mailmap b/.mailmap index d8782cd67e..23aed53102 100644 --- a/.mailmap +++ b/.mailmap @@ -1643,3 +1643,5 @@ Jayaprakash Shanmugam Zhenning Xiao Josh Hay Madhu Chittim +Shailendra Bhatnagar +Julianx Grajkowski diff --git a/drivers/common/idpf/base/idpf_common.c b/drivers/common/idpf/base/idpf_common.c index fbf71416fd..9610916aa9 100644 --- a/drivers/common/idpf/base/idpf_common.c +++ b/drivers/common/idpf/base/idpf_common.c @@ -239,8 +239,10 @@ int idpf_clean_arq_element(struct idpf_hw *hw, e->desc.ret_val = msg.status; e->desc.datalen = msg.data_len; if (msg.data_len > 0) { - if (!msg.ctx.indirect.payload) - return -EINVAL; + if (!msg.ctx.indirect.payload || !msg.ctx.indirect.payload->va || + !e->msg_buf) { + return -EFAULT; + } e->buf_len = msg.data_len; msg_data_len = msg.data_len; idpf_memcpy(e->msg_buf, msg.ctx.indirect.payload->va, msg_data_len, diff --git a/drivers/common/idpf/base/virtchnl2.h b/drivers/common/idpf/base/virtchnl2.h index 320430df6f..3900b784d0 100644 --- a/drivers/common/idpf/base/virtchnl2.h +++ b/drivers/common/idpf/base/virtchnl2.h @@ -89,8 +89,8 @@ * VIRTCHNL2_OP_GET_PTYPE_INFO_RAW */ /* opcodes 529, 530, and 531 are reserved */ -#define VIRTCHNL2_OP_CREATE_ADI 532 -#define VIRTCHNL2_OP_DESTROY_ADI 533 +#define VIRTCHNL2_OP_NON_FLEX_CREATE_ADI 532 +#define VIRTCHNL2_OP_NON_FLEX_DESTROY_ADI 533 #define VIRTCHNL2_OP_LOOPBACK 534 #define VIRTCHNL2_OP_ADD_MAC_ADDR 535 #define VIRTCHNL2_OP_DEL_MAC_ADDR 536 @@ -294,6 +294,7 @@ /* These messages are only sent to PF from CP */ #define VIRTCHNL2_EVENT_START_RESET_ADI 2 #define VIRTCHNL2_EVENT_FINISH_RESET_ADI 3 +#define VIRTCHNL2_EVENT_ADI_ACTIVE 4 /* VIRTCHNL2_QUEUE_TYPE * Transmit and Receive queue types are valid in legacy as well as split queue @@ -547,7 +548,8 @@ struct virtchnl2_get_capabilities { u8 max_sg_bufs_per_tx_pkt; u8 reserved1; - __le16 pad1; + /* upper bound of number of ADIs supported */ + __le16 max_adis; /* version of Control Plane that is running */ __le16 oem_cp_ver_major; @@ -1059,14 +1061,34 @@ struct virtchnl2_sriov_vfs_info { VIRTCHNL2_CHECK_STRUCT_LEN(4, virtchnl2_sriov_vfs_info); -/* VIRTCHNL2_OP_CREATE_ADI +/* structure to specify single chunk of queue */ +/* 'chunks' is fixed size(not flexible) and will be deprecated at some point */ +struct virtchnl2_non_flex_queue_reg_chunks { + __le16 num_chunks; + u8 reserved[6]; + struct virtchnl2_queue_reg_chunk chunks[1]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN(40, virtchnl2_non_flex_queue_reg_chunks); + +/* structure to specify single chunk of interrupt vector */ +/* 'vchunks' is fixed size(not flexible) and will be deprecated at some point */ +struct virtchnl2_non_flex_vector_chunks { + __le16 num_vchunks; + u8 reserved[14]; + struct virtchnl2_vector_chunk vchunks[1]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN(48, virtchnl2_non_flex_vector_chunks); + +/* VIRTCHNL2_OP_NON_FLEX_CREATE_ADI * PF sends this message to CP to create ADI by filling in required - * fields of virtchnl2_create_adi structure. - * CP responds with the updated virtchnl2_create_adi structure containing the - * necessary fields followed by chunks which in turn will have an array of + * fields of virtchnl2_non_flex_create_adi structure. + * CP responds with the updated virtchnl2_non_flex_create_adi structure containing + * the necessary fields followed by chunks which in turn will have an array of * num_chunks entries of virtchnl2_queue_chunk structures. */ -struct virtchnl2_create_adi { +struct virtchnl2_non_flex_create_adi { /* PF sends PASID to CP */ __le32 pasid; /* @@ -1076,29 +1098,31 @@ struct virtchnl2_create_adi { __le16 mbx_id; /* PF sends mailbox vector id to CP */ __le16 mbx_vec_id; + /* PF populates this ADI index */ + __le16 adi_index; /* CP populates ADI id */ __le16 adi_id; u8 reserved[64]; - u8 pad[6]; + u8 pad[4]; /* CP populates queue chunks */ - struct virtchnl2_queue_reg_chunks chunks; + struct virtchnl2_non_flex_queue_reg_chunks chunks; /* PF sends vector chunks to CP */ - struct virtchnl2_vector_chunks vchunks; + struct virtchnl2_non_flex_vector_chunks vchunks; }; -VIRTCHNL2_CHECK_STRUCT_LEN(168, virtchnl2_create_adi); +VIRTCHNL2_CHECK_STRUCT_LEN(168, virtchnl2_non_flex_create_adi); /* VIRTCHNL2_OP_DESTROY_ADI * PF sends this message to CP to destroy ADI by filling * in the adi_id in virtchnl2_destropy_adi structure. * CP responds with the status of the requested operation. */ -struct virtchnl2_destroy_adi { +struct virtchnl2_non_flex_destroy_adi { __le16 adi_id; u8 reserved[2]; }; -VIRTCHNL2_CHECK_STRUCT_LEN(4, virtchnl2_destroy_adi); +VIRTCHNL2_CHECK_STRUCT_LEN(4, virtchnl2_non_flex_destroy_adi); /* Based on the descriptor type the PF supports, CP fills ptype_id_10 or * ptype_id_8 for flex and base descriptor respectively. If ptype_id_10 value @@ -1562,10 +1586,10 @@ static inline const char *virtchnl2_op_str(__le32 v_opcode) return "VIRTCHNL2_OP_EVENT"; case VIRTCHNL2_OP_RESET_VF: return "VIRTCHNL2_OP_RESET_VF"; - case VIRTCHNL2_OP_CREATE_ADI: - return "VIRTCHNL2_OP_CREATE_ADI"; - case VIRTCHNL2_OP_DESTROY_ADI: - return "VIRTCHNL2_OP_DESTROY_ADI"; + case VIRTCHNL2_OP_NON_FLEX_CREATE_ADI: + return "VIRTCHNL2_OP_NON_FLEX_CREATE_ADI"; + case VIRTCHNL2_OP_NON_FLEX_DESTROY_ADI: + return "VIRTCHNL2_OP_NON_FLEX_DESTROY_ADI"; case VIRTCHNL2_OP_ADD_QUEUE_GROUPS: return "VIRTCHNL2_OP_ADD_QUEUE_GROUPS"; case VIRTCHNL2_OP_DEL_QUEUE_GROUPS: @@ -1620,11 +1644,11 @@ virtchnl2_vc_validate_vf_msg(__rte_unused struct virtchnl2_version_info *ver, u3 sizeof(struct virtchnl2_queue_reg_chunk); } break; - case VIRTCHNL2_OP_CREATE_ADI: - valid_len = sizeof(struct virtchnl2_create_adi); + case VIRTCHNL2_OP_NON_FLEX_CREATE_ADI: + valid_len = sizeof(struct virtchnl2_non_flex_create_adi); if (msglen >= valid_len) { - struct virtchnl2_create_adi *cadi = - (struct virtchnl2_create_adi *)msg; + struct virtchnl2_non_flex_create_adi *cadi = + (struct virtchnl2_non_flex_create_adi *)msg; if (cadi->chunks.num_chunks == 0) { /* zero chunks is allowed as input */ @@ -1641,8 +1665,8 @@ virtchnl2_vc_validate_vf_msg(__rte_unused struct virtchnl2_version_info *ver, u3 sizeof(struct virtchnl2_vector_chunk); } break; - case VIRTCHNL2_OP_DESTROY_ADI: - valid_len = sizeof(struct virtchnl2_destroy_adi); + case VIRTCHNL2_OP_NON_FLEX_DESTROY_ADI: + valid_len = sizeof(struct virtchnl2_non_flex_destroy_adi); break; case VIRTCHNL2_OP_DESTROY_VPORT: case VIRTCHNL2_OP_ENABLE_VPORT: