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 43131440F2; Tue, 28 May 2024 10:18:20 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D24BC40DCD; Tue, 28 May 2024 10:17:35 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by mails.dpdk.org (Postfix) with ESMTP id 512D740DDD for ; Tue, 28 May 2024 10:17:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716884254; x=1748420254; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4laPUOcEdiBBlNDcLsS32tlpxTrHHHVLrZmCyzH0ano=; b=aPyMphizhkJuSapafQJn+rcwkIMnACCYFNuY2ESJIB4tdKgEBHm6ysBn Src7szH8IEkmxgYEQvtNmXC9p+zWjY/4l1nyz5S0RWqRm7MUr3YDE+whq xCYZGVx+pNWAkAkhD4XB7HAGUXTtoeFPb2fw6lPjzCTnnBw6aKr4f+Frp y1gLwC5QAY8H6xgV09uDPafNhbToOgUbd258kRHbDONp41UrxS8OdLBgA bkf0fkfK0E9f80W1jGg5esf42WyuX17Ja5Fl29olc+1u4poYGIPBexz6o 6ydLsIiK4Lml1bqORJSE3pR6pBRt4liMxDnY90ElL0AvaMdTTX9dKNm4j g==; X-CSE-ConnectionGUID: tv9hdTpcS3uDpdCisissrg== X-CSE-MsgGUID: nUY/FCESRcmeAHryXBE35Q== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="35728418" X-IronPort-AV: E=Sophos;i="6.08,194,1712646000"; d="scan'208";a="35728418" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 01:17:33 -0700 X-CSE-ConnectionGUID: JNK/sWnWRoKSfkD/o55xPg== X-CSE-MsgGUID: YofPOpWMTqOz7zatnYKh1A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,194,1712646000"; d="scan'208";a="34976603" Received: from unknown (HELO npf-hyd-clx-03..) ([10.145.170.182]) by fmviesa008.fm.intel.com with ESMTP; 28 May 2024 01:17:32 -0700 From: Soumyadeep Hore To: jingjing.wu@intel.com Cc: dev@dpdk.org Subject: [PATCH 18/25] common/idpf: removing redundant functionality of virtchnl2 Date: Tue, 28 May 2024 07:35:58 +0000 Message-ID: <20240528073559.867121-9-soumyadeep.hore@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240528073559.867121-1-soumyadeep.hore@intel.com> References: <20240528073559.867121-1-soumyadeep.hore@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 The function virtchnl2_vc_validate_vf_msg() currently has implementation based on Linux 6.5 kernel and is redundant for dpdk. In future if required new implementation will be added. Signed-off-by: Soumyadeep Hore --- drivers/common/idpf/base/virtchnl2.h | 326 --------------------------- 1 file changed, 326 deletions(-) diff --git a/drivers/common/idpf/base/virtchnl2.h b/drivers/common/idpf/base/virtchnl2.h index aadb2aafff..90232e82a8 100644 --- a/drivers/common/idpf/base/virtchnl2.h +++ b/drivers/common/idpf/base/virtchnl2.h @@ -2083,331 +2083,5 @@ static inline const char *virtchnl2_op_str(__le32 v_opcode) * * Validate msg format against struct for each opcode. */ -static inline int -virtchnl2_vc_validate_vf_msg(struct virtchnl2_version_info *ver, u32 v_opcode, - u8 *msg, __le16 msglen) -{ - bool err_msg_format = false; -#ifdef FLEX_ARRAY_SUPPORT - bool is_flex_array = true; -#else - bool is_flex_array = false; -#endif /* !FLEX_ARRAY_SUPPORT */ - __le32 valid_len = 0; - __le32 num_chunks; - __le32 num_qgrps; - - /* It is possible that the FLEX_ARRAY_SUPPORT flag is not defined - * by all the users of virtchnl2 header file. Let's take an example - * where the driver doesn't support flex array and CP does. In this - * case, the size of the VIRTCHNL2_OP_CREATE_VPORT message sent from - * the driver would be 192 bytes because of the 1-sized array in the - * virtchnl2_create_vport structure whereas the message size expected - * by the CP would be 160 bytes (as the driver doesn't send any chunk - * information on create vport). This means, both 160 and 192 byte - * message length are valid. The math for the message size check of the - * opcodes consider the said scenarios for the flex array supported - * structures. - */ - /* Validate message length */ - switch (v_opcode) { - case VIRTCHNL2_OP_VERSION: - valid_len = sizeof(struct virtchnl2_version_info); - break; - case VIRTCHNL2_OP_GET_CAPS: - valid_len = sizeof(struct virtchnl2_get_capabilities); - break; - case VIRTCHNL2_OP_CREATE_VPORT: - num_chunks = ((struct virtchnl2_create_vport *)msg)->chunks.num_chunks; - valid_len = struct_size_t(struct virtchnl2_create_vport, - chunks.chunks, num_chunks); - - if (!is_flex_array) - /* Remove the additional chunk included in the - * struct_size_t calculation in case of no flex array - * support, due to the 1-sized array. - */ - valid_len -= sizeof(struct virtchnl2_queue_reg_chunk); - - /* Zero chunks is allowed as input */ - if (!num_chunks && msglen > valid_len) - valid_len += sizeof(struct virtchnl2_queue_reg_chunk); - - break; - case VIRTCHNL2_OP_NON_FLEX_CREATE_ADI: - valid_len = sizeof(struct virtchnl2_non_flex_create_adi); - if (msglen >= valid_len) { - 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 */ - break; - } - - if (cadi->vchunks.num_vchunks == 0) { - err_msg_format = true; - break; - } - valid_len += (cadi->chunks.num_chunks - 1) * - sizeof(struct virtchnl2_queue_reg_chunk); - valid_len += (cadi->vchunks.num_vchunks - 1) * - sizeof(struct virtchnl2_vector_chunk); - } - break; - 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: - case VIRTCHNL2_OP_DISABLE_VPORT: - valid_len = sizeof(struct virtchnl2_vport); - break; - case VIRTCHNL2_OP_CONFIG_TX_QUEUES: - num_chunks = ((struct virtchnl2_config_tx_queues *)msg)->num_qinfo; - if (!num_chunks) { - err_msg_format = true; - break; - } - - valid_len = struct_size_t(struct virtchnl2_config_tx_queues, - qinfo, num_chunks); - if (!is_flex_array) - valid_len -= sizeof(struct virtchnl2_txq_info); - - break; - case VIRTCHNL2_OP_CONFIG_RX_QUEUES: - num_chunks = ((struct virtchnl2_config_rx_queues *)msg)->num_qinfo; - if (!num_chunks) { - err_msg_format = true; - break; - } - - valid_len = struct_size_t(struct virtchnl2_config_rx_queues, - qinfo, num_chunks); - if (!is_flex_array) - valid_len -= sizeof(struct virtchnl2_rxq_info); - - break; - case VIRTCHNL2_OP_ADD_QUEUES: - num_chunks = ((struct virtchnl2_add_queues *)msg)->chunks.num_chunks; - valid_len = struct_size_t(struct virtchnl2_add_queues, - chunks.chunks, num_chunks); - if (!is_flex_array) - valid_len -= sizeof(struct virtchnl2_queue_reg_chunk); - - /* Zero chunks is allowed as input */ - if (!num_chunks && msglen > valid_len) - valid_len += sizeof(struct virtchnl2_queue_reg_chunk); - - break; - case VIRTCHNL2_OP_ENABLE_QUEUES: - case VIRTCHNL2_OP_DISABLE_QUEUES: - case VIRTCHNL2_OP_DEL_QUEUES: - num_chunks = ((struct virtchnl2_del_ena_dis_queues *)msg)->chunks.num_chunks; - if (!num_chunks || - num_chunks > VIRTCHNL2_OP_DEL_ENABLE_DISABLE_QUEUES_MAX) { - err_msg_format = true; - break; - } - - valid_len = struct_size_t(struct virtchnl2_del_ena_dis_queues, - chunks.chunks, num_chunks); - if (!is_flex_array) - valid_len -= sizeof(struct virtchnl2_queue_chunk); - - break; - case VIRTCHNL2_OP_ADD_QUEUE_GROUPS: - num_qgrps = ((struct virtchnl2_add_queue_groups *)msg)->num_queue_groups; - if (!num_qgrps) { - err_msg_format = true; - break; - } - - /* valid_len is also used as an offset to find the array of - * virtchnl2_queue_group_info structures - */ - valid_len = sizeof(struct virtchnl2_add_queue_groups); - if (!is_flex_array) - valid_len -= sizeof(struct virtchnl2_queue_group_info); - - while (num_qgrps--) { - struct virtchnl2_queue_group_info *qgrp_info; - - qgrp_info = (struct virtchnl2_queue_group_info *) - ((u8 *)msg + valid_len); - num_chunks = qgrp_info->chunks.num_chunks; - - valid_len += struct_size_t(struct virtchnl2_queue_group_info, - chunks.chunks, num_chunks); - if (!is_flex_array) - valid_len -= sizeof(struct virtchnl2_queue_reg_chunk); - } - - break; - case VIRTCHNL2_OP_DEL_QUEUE_GROUPS: - num_qgrps = ((struct virtchnl2_delete_queue_groups *)msg)->num_queue_groups; - if (!num_qgrps) { - err_msg_format = true; - break; - } - - valid_len = struct_size_t(struct virtchnl2_delete_queue_groups, - qg_ids, num_qgrps); - if (!is_flex_array) - valid_len -= sizeof(struct virtchnl2_queue_group_id); - - break; - case VIRTCHNL2_OP_MAP_QUEUE_VECTOR: - case VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR: - num_chunks = ((struct virtchnl2_queue_vector_maps *)msg)->num_qv_maps; - if (!num_chunks || - num_chunks > VIRTCHNL2_OP_MAP_UNMAP_QUEUE_VECTOR_MAX) { - err_msg_format = true; - break; - } - - valid_len = struct_size_t(struct virtchnl2_queue_vector_maps, - qv_maps, num_chunks); - if (!is_flex_array) - valid_len -= sizeof(struct virtchnl2_queue_vector); - - break; - case VIRTCHNL2_OP_ALLOC_VECTORS: - num_chunks = ((struct virtchnl2_alloc_vectors *)msg)->vchunks.num_vchunks; - valid_len = struct_size_t(struct virtchnl2_alloc_vectors, - vchunks.vchunks, num_chunks); - if (!is_flex_array) - valid_len -= sizeof(struct virtchnl2_vector_chunk); - - /* Zero chunks is allowed as input */ - if (!num_chunks && msglen > valid_len) - valid_len += sizeof(struct virtchnl2_vector_chunk); - - break; - case VIRTCHNL2_OP_DEALLOC_VECTORS: - num_chunks = ((struct virtchnl2_vector_chunks *)msg)->num_vchunks; - if (!num_chunks) { - err_msg_format = true; - break; - } - - valid_len = struct_size_t(struct virtchnl2_vector_chunks, - vchunks, num_chunks); - if (!is_flex_array) - valid_len -= sizeof(struct virtchnl2_vector_chunk); - - break; - case VIRTCHNL2_OP_GET_RSS_KEY: - case VIRTCHNL2_OP_SET_RSS_KEY: - num_chunks = ((struct virtchnl2_rss_key *)msg)->key_len; - valid_len = struct_size_t(struct virtchnl2_rss_key, - key, num_chunks); - if (!is_flex_array) - valid_len -= sizeof(u8); - - /* Zero entries is allowed as input */ - if (!num_chunks && msglen > valid_len) - valid_len += sizeof(u8); - - break; - case VIRTCHNL2_OP_GET_RSS_LUT: - case VIRTCHNL2_OP_SET_RSS_LUT: - num_chunks = ((struct virtchnl2_rss_lut *)msg)->lut_entries; - valid_len = struct_size_t(struct virtchnl2_rss_lut, - lut, num_chunks); - if (!is_flex_array) - valid_len -= sizeof(__le32); - - /* Zero entries is allowed as input */ - if (!num_chunks && msglen > valid_len) - valid_len += sizeof(__le32); - - break; - case VIRTCHNL2_OP_GET_RSS_HASH: - case VIRTCHNL2_OP_SET_RSS_HASH: - valid_len = sizeof(struct virtchnl2_rss_hash); - break; - case VIRTCHNL2_OP_SET_SRIOV_VFS: - valid_len = sizeof(struct virtchnl2_sriov_vfs_info); - break; - case VIRTCHNL2_OP_GET_PTYPE_INFO: - valid_len = sizeof(struct virtchnl2_get_ptype_info); - break; - case VIRTCHNL2_OP_GET_STATS: - valid_len = sizeof(struct virtchnl2_vport_stats); - break; - case VIRTCHNL2_OP_GET_PORT_STATS: - valid_len = sizeof(struct virtchnl2_port_stats); - break; - case VIRTCHNL2_OP_RESET_VF: - break; -#ifdef VIRTCHNL2_EDT_SUPPORT - case VIRTCHNL2_OP_GET_EDT_CAPS: - valid_len = sizeof(struct virtchnl2_edt_caps); - break; -#endif /* VIRTCHNL2_EDT_SUPPORT */ -#ifdef NOT_FOR_UPSTREAM - case VIRTCHNL2_OP_GET_OEM_CAPS: - valid_len = sizeof(struct virtchnl2_oem_caps); - break; -#endif /* NOT_FOR_UPSTREAM */ -#ifdef VIRTCHNL2_IWARP - case VIRTCHNL2_OP_RDMA: - /* These messages are opaque to us and will be validated in - * the RDMA client code. We just need to check for nonzero - * length. The firmware will enforce max length restrictions. - */ - if (msglen) - valid_len = msglen; - else - err_msg_format = true; - break; - case VIRTCHNL2_OP_RELEASE_RDMA_IRQ_MAP: - break; - case VIRTCHNL2_OP_CONFIG_RDMA_IRQ_MAP: - num_chunks = ((struct virtchnl2_rdma_qvlist_info *)msg)->num_vectors; - if (!num_chunks || - num_chunks > VIRTCHNL2_OP_CONFIG_RDMA_IRQ_MAP_MAX) { - err_msg_format = true; - break; - } - - valid_len = struct_size_t(struct virtchnl2_rdma_qvlist_info, - qv_info, num_chunks); - if (!is_flex_array) - valid_len -= sizeof(struct virtchnl2_rdma_qv_info); - - break; -#endif /* VIRTCHNL2_IWARP */ - case VIRTCHNL2_OP_GET_PTP_CAPS: - valid_len = sizeof(struct virtchnl2_get_ptp_caps); - break; - case VIRTCHNL2_OP_GET_PTP_TX_TSTAMP_LATCHES: - valid_len = sizeof(struct virtchnl2_ptp_tx_tstamp_latches); - num_chunks = ((struct virtchnl2_ptp_tx_tstamp_latches *)msg)->num_latches; - if (!num_chunks) { - err_msg_format = true; - break; - } - - valid_len = struct_size_t(struct virtchnl2_ptp_tx_tstamp_latches, - tstamp_latches, num_chunks); - if (!is_flex_array) - valid_len -= sizeof(struct virtchnl2_ptp_tx_tstamp_latch); - - break; - /* These are always errors coming from the VF */ - case VIRTCHNL2_OP_EVENT: - case VIRTCHNL2_OP_UNKNOWN: - default: - return VIRTCHNL2_STATUS_ERR_ESRCH; - } - /* Few more checks */ - if (err_msg_format || valid_len != msglen) - return VIRTCHNL2_STATUS_ERR_EINVAL; - - return 0; -} #endif /* _VIRTCHNL_2_H_ */ -- 2.43.0