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 <soumyadeep.h...@intel.com>
---
 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

Reply via email to