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 A8D624375B; Fri, 22 Dec 2023 09:29:08 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3755C4025D; Fri, 22 Dec 2023 09:29:08 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by mails.dpdk.org (Postfix) with ESMTP id 69EFA4003C for ; Fri, 22 Dec 2023 09:29:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1703233746; x=1734769746; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=aULL0CE37F+4n8+4OeMuaX6jAYOX3z7kk5b0pp723Ew=; b=LLG7sWAze17EFcH48U9IZ+tkqXW6Fyf7LTNFQXLYC80/6PXj/DAL0bM9 nVZJlOBiRbzLLBwzBeUrQ9UAzmsmjpjSeCoZ4sNuHrU0/k+/MLWisGxai vuhs7Hav0HPgZhecSgKy9rtkckJNqorW2Fbc+yjIkvgOFg/Dts972hbsi 7+iCUUbzGcdNTB0zZZ3xXfpvgQZbU9/a6p0+Xkhi3TwWnPlP2Boa/3JSG XZqNz0fEs1mEnCbuvQe16VwcJp+ksPZnhe9N9tbbOU0HpitsM+Ll4I7ml PjRpKjOcyIkQ+wlFqS14+npzMcohI6HMLHCmyYCsK2TRUbBQ4i5MYEUuy Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10931"; a="14774548" X-IronPort-AV: E=Sophos;i="6.04,294,1695711600"; d="scan'208";a="14774548" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Dec 2023 00:28:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10931"; a="900359301" X-IronPort-AV: E=Sophos;i="6.04,294,1695711600"; d="scan'208";a="900359301" Received: from dpdk-beileix-icelake.sh.intel.com ([10.67.116.155]) by orsmga004.jf.intel.com with ESMTP; 22 Dec 2023 00:28:48 -0800 From: beilei.xing@intel.com To: jingjing.wu@intel.com Cc: dev@dpdk.org, Beilei Xing Subject: [PATCH] common/idpf: refine get packet type Date: Fri, 22 Dec 2023 16:51:28 +0000 Message-Id: <20231222165128.2899806-1-beilei.xing@intel.com> X-Mailer: git-send-email 2.34.1 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 From: Beilei Xing Since the response of virtual channel virtchnl2_get_ptype_info is changed on IMC side, driver needs to be updated when requiring the virtual channel. Signed-off-by: Beilei Xing --- drivers/common/idpf/idpf_common_device.c | 64 ++++++++++++++-------- drivers/common/idpf/idpf_common_device.h | 9 +++ drivers/common/idpf/idpf_common_virtchnl.c | 28 ++++------ drivers/common/idpf/idpf_common_virtchnl.h | 4 +- 4 files changed, 63 insertions(+), 42 deletions(-) diff --git a/drivers/common/idpf/idpf_common_device.c b/drivers/common/idpf/idpf_common_device.c index cc4207a46e..1380cc462c 100644 --- a/drivers/common/idpf/idpf_common_device.c +++ b/drivers/common/idpf/idpf_common_device.c @@ -157,49 +157,65 @@ idpf_init_mbx(struct idpf_hw *hw) static int idpf_get_pkt_type(struct idpf_adapter *adapter) { - struct virtchnl2_get_ptype_info *ptype_info; + struct virtchnl2_get_ptype_info *req_ptype_info; + struct virtchnl2_get_ptype_info *recv_ptype_info; + uint16_t recv_num_ptypes = 0; uint16_t ptype_offset, i, j; - uint16_t ptype_recvd = 0; + uint16_t start_ptype_id = 0; int ret; - ret = idpf_vc_ptype_info_query(adapter); - if (ret != 0) { - DRV_LOG(ERR, "Fail to query packet type information"); - return ret; + req_ptype_info = rte_zmalloc("req_ptype_info", IDPF_DFLT_MBX_BUF_SIZE, 0); + if (req_ptype_info == NULL) + return -ENOMEM; + + recv_ptype_info = rte_zmalloc("recv_ptype_info", IDPF_DFLT_MBX_BUF_SIZE, 0); + if (recv_ptype_info == NULL) { + ret = -ENOMEM; + goto free_req_ptype_info; } - ptype_info = rte_zmalloc("ptype_info", IDPF_DFLT_MBX_BUF_SIZE, 0); - if (ptype_info == NULL) - return -ENOMEM; + while (start_ptype_id < IDPF_MAX_PKT_TYPE) { + memset(req_ptype_info, 0, sizeof(*req_ptype_info)); + memset(recv_ptype_info, 0, sizeof(*recv_ptype_info)); + + if ((start_ptype_id + IDPF_RX_MAX_PTYPES_PER_BUF) > IDPF_MAX_PKT_TYPE) + req_ptype_info->num_ptypes = + rte_cpu_to_le_16(IDPF_MAX_PKT_TYPE - start_ptype_id); + else + req_ptype_info->num_ptypes = rte_cpu_to_le_16(IDPF_RX_MAX_PTYPES_PER_BUF); + req_ptype_info->start_ptype_id = start_ptype_id; - while (ptype_recvd < IDPF_MAX_PKT_TYPE) { - ret = idpf_vc_one_msg_read(adapter, VIRTCHNL2_OP_GET_PTYPE_INFO, - IDPF_DFLT_MBX_BUF_SIZE, (uint8_t *)ptype_info); + ret = idpf_vc_ptype_info_query(adapter, req_ptype_info, recv_ptype_info); if (ret != 0) { - DRV_LOG(ERR, "Fail to get packet type information"); - goto free_ptype_info; + DRV_LOG(ERR, "Fail to query packet type information"); + goto free_recv_ptype_info; } - ptype_recvd += ptype_info->num_ptypes; + recv_num_ptypes += rte_cpu_to_le_16(recv_ptype_info->num_ptypes); + if (recv_num_ptypes > IDPF_MAX_PKT_TYPE) { + ret = -EINVAL; + goto free_recv_ptype_info; + } + + start_ptype_id = rte_cpu_to_le_16(req_ptype_info->start_ptype_id) + + rte_cpu_to_le_16(req_ptype_info->num_ptypes); + ptype_offset = sizeof(struct virtchnl2_get_ptype_info) - sizeof(struct virtchnl2_ptype); - for (i = 0; i < rte_cpu_to_le_16(ptype_info->num_ptypes); i++) { + for (i = 0; i < rte_cpu_to_le_16(recv_ptype_info->num_ptypes); i++) { bool is_inner = false, is_ip = false; struct virtchnl2_ptype *ptype; uint32_t proto_hdr = 0; ptype = (struct virtchnl2_ptype *) - ((uint8_t *)ptype_info + ptype_offset); + ((uint8_t *)recv_ptype_info + ptype_offset); ptype_offset += IDPF_GET_PTYPE_SIZE(ptype); if (ptype_offset > IDPF_DFLT_MBX_BUF_SIZE) { ret = -EINVAL; - goto free_ptype_info; + goto free_recv_ptype_info; } - if (rte_cpu_to_le_16(ptype->ptype_id_10) == 0xFFFF) - goto free_ptype_info; - for (j = 0; j < ptype->proto_id_count; j++) { switch (rte_cpu_to_le_16(ptype->proto_id[j])) { case VIRTCHNL2_PROTO_HDR_GRE: @@ -358,8 +374,10 @@ idpf_get_pkt_type(struct idpf_adapter *adapter) } } -free_ptype_info: - rte_free(ptype_info); +free_recv_ptype_info: + rte_free(recv_ptype_info); +free_req_ptype_info: + rte_free(req_ptype_info); clear_cmd(adapter); return ret; } diff --git a/drivers/common/idpf/idpf_common_device.h b/drivers/common/idpf/idpf_common_device.h index f767ea7cec..2b94f0331a 100644 --- a/drivers/common/idpf/idpf_common_device.h +++ b/drivers/common/idpf/idpf_common_device.h @@ -31,6 +31,15 @@ #define IDPF_DFLT_INTERVAL 16 +#define IDPF_RX_MAX_PTYPE_PROTO_IDS 32 +#define IDPF_RX_MAX_PTYPE_SZ (sizeof(struct virtchnl2_ptype) + \ + (sizeof(uint16_t) * \ + (IDPF_RX_MAX_PTYPE_PROTO_IDS - 1))) +#define IDPF_RX_PTYPE_HDR_SZ (sizeof(struct virtchnl2_get_ptype_info) - \ + sizeof(struct virtchnl2_ptype)) +#define IDPF_RX_MAX_PTYPES_PER_BUF \ + ((IDPF_DFLT_MBX_BUF_SIZE - IDPF_RX_PTYPE_HDR_SZ)/ \ + IDPF_RX_MAX_PTYPE_SZ) #define IDPF_GET_PTYPE_SIZE(p) \ (sizeof(struct virtchnl2_ptype) + \ (((p)->proto_id_count ? ((p)->proto_id_count - 1) : 0) * sizeof((p)->proto_id[0]))) diff --git a/drivers/common/idpf/idpf_common_virtchnl.c b/drivers/common/idpf/idpf_common_virtchnl.c index 6455f640da..c46ed50eb5 100644 --- a/drivers/common/idpf/idpf_common_virtchnl.c +++ b/drivers/common/idpf/idpf_common_virtchnl.c @@ -202,15 +202,11 @@ idpf_vc_cmd_execute(struct idpf_adapter *adapter, struct idpf_cmd_info *args) switch (args->ops) { case VIRTCHNL_OP_VERSION: case VIRTCHNL2_OP_GET_CAPS: + case VIRTCHNL2_OP_GET_PTYPE_INFO: /* for init virtchnl ops, need to poll the response */ err = idpf_vc_one_msg_read(adapter, args->ops, args->out_size, args->out_buffer); clear_cmd(adapter); break; - case VIRTCHNL2_OP_GET_PTYPE_INFO: - /* for multuple response message, - * do not handle the response here. - */ - break; default: /* For other virtchnl ops in running time, * wait for the cmd done flag. @@ -909,28 +905,24 @@ idpf_vc_vport_ena_dis(struct idpf_vport *vport, bool enable) } int -idpf_vc_ptype_info_query(struct idpf_adapter *adapter) +idpf_vc_ptype_info_query(struct idpf_adapter *adapter, + struct virtchnl2_get_ptype_info *req_ptype_info, + struct virtchnl2_get_ptype_info *recv_ptype_info) { - struct virtchnl2_get_ptype_info *ptype_info; struct idpf_cmd_info args; - int len, err; - - len = sizeof(struct virtchnl2_get_ptype_info); - ptype_info = rte_zmalloc("ptype_info", len, 0); - if (ptype_info == NULL) - return -ENOMEM; + int err; - ptype_info->start_ptype_id = 0; - ptype_info->num_ptypes = IDPF_MAX_PKT_TYPE; args.ops = VIRTCHNL2_OP_GET_PTYPE_INFO; - args.in_args = (uint8_t *)ptype_info; - args.in_args_size = len; + args.in_args = (uint8_t *)req_ptype_info; + args.in_args_size = sizeof(struct virtchnl2_get_ptype_info); + args.out_buffer = adapter->mbx_resp; + args.out_size = IDPF_DFLT_MBX_BUF_SIZE; err = idpf_vc_cmd_execute(adapter, &args); if (err != 0) DRV_LOG(ERR, "Failed to execute command of VIRTCHNL2_OP_GET_PTYPE_INFO"); - rte_free(ptype_info); + rte_memcpy(recv_ptype_info, args.out_buffer, IDPF_DFLT_MBX_BUF_SIZE); return err; } diff --git a/drivers/common/idpf/idpf_common_virtchnl.h b/drivers/common/idpf/idpf_common_virtchnl.h index 9ff5c38c26..73446ded86 100644 --- a/drivers/common/idpf/idpf_common_virtchnl.h +++ b/drivers/common/idpf/idpf_common_virtchnl.h @@ -41,7 +41,9 @@ int idpf_vc_vectors_alloc(struct idpf_vport *vport, uint16_t num_vectors); __rte_internal int idpf_vc_vectors_dealloc(struct idpf_vport *vport); __rte_internal -int idpf_vc_ptype_info_query(struct idpf_adapter *adapter); +int idpf_vc_ptype_info_query(struct idpf_adapter *adapter, + struct virtchnl2_get_ptype_info *req_ptype_info, + struct virtchnl2_get_ptype_info *recv_ptype_info); __rte_internal int idpf_vc_one_msg_read(struct idpf_adapter *adapter, uint32_t ops, uint16_t buf_len, uint8_t *buf); -- 2.34.1