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 69C5741C49; Tue, 14 Feb 2023 13:36:45 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1E57C42D8F; Tue, 14 Feb 2023 13:36:34 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 5D8F842D47 for ; Tue, 14 Feb 2023 13:36:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676378191; x=1707914191; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FNxjFy2NdWvI1WPLaWdtCBaFt+SQN+IovRYeguHQv7U=; b=TeunEv9SzDvqloZ0yCcLyEiK2KZhUnsTr2CyG53U2xK+KJOz7tjbNUnP KfFnLMd7114Ir14oDid/amOdy3yBNgYR8nVMsSK2SWqhBBJQhETAa55d1 7wUL/53NK13VjpTYywXWWkZ2LVRziU4ArtYl0Akfwtcr9RPIh/DKwrusn F0JTVHzsp9r/HfOGLzHrctc7V0nrpGtoLg1SMGH1kEjgXRlY+uAqTcbj4 f6fkAs5nKBOyiRoMRnEnY2kSq0wK1zwGz/JzyOUJXZJniZGYBoa76Lb8g Gl/pyXS8NGgMvuG/GWg1vhOPuH/JJEkJUbsJChLBFp8UxNJiHdrzTCqGY g==; X-IronPort-AV: E=McAfee;i="6500,9779,10620"; a="314793182" X-IronPort-AV: E=Sophos;i="5.97,296,1669104000"; d="scan'208";a="314793182" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2023 04:36:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10620"; a="699528519" X-IronPort-AV: E=Sophos;i="5.97,296,1669104000"; d="scan'208";a="699528519" Received: from dpdk-mingxial-01.sh.intel.com ([10.67.119.167]) by orsmga008.jf.intel.com with ESMTP; 14 Feb 2023 04:36:28 -0800 From: Mingxia Liu To: dev@dpdk.org, beilei.xing@intel.com, yuying.zhang@intel.com Cc: Mingxia Liu , Xiao Wang , Junfeng Guo Subject: [PATCH v2 2/5] net/cpfl: update device initialization for hairpin queue Date: Tue, 14 Feb 2023 11:38:49 +0000 Message-Id: <20230214113852.3341607-3-mingxia.liu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230214113852.3341607-1-mingxia.liu@intel.com> References: <20230118130659.976873-1-mingxia.liu@intel.com> <20230214113852.3341607-1-mingxia.liu@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 This patch update device initialization for hairpin queue. Signed-off-by: Beilei Xing Signed-off-by: Xiao Wang Signed-off-by: Junfeng Guo Signed-off-by: Mingxia Liu --- drivers/common/idpf/idpf_common_device.c | 51 ++++++++++++++++ drivers/common/idpf/idpf_common_device.h | 2 + drivers/common/idpf/idpf_common_virtchnl.c | 28 +++++++++ drivers/common/idpf/idpf_common_virtchnl.h | 3 + drivers/common/idpf/version.map | 2 + drivers/net/cpfl/cpfl_ethdev.c | 68 +++++++++++++++++++++- 6 files changed, 153 insertions(+), 1 deletion(-) diff --git a/drivers/common/idpf/idpf_common_device.c b/drivers/common/idpf/idpf_common_device.c index 5475a3e52c..2d968884c6 100644 --- a/drivers/common/idpf/idpf_common_device.c +++ b/drivers/common/idpf/idpf_common_device.c @@ -362,6 +362,57 @@ idpf_adapter_init(struct idpf_adapter *adapter) return ret; } +int +idpf_adapter_common_init(struct idpf_adapter *adapter) +{ + struct idpf_hw *hw = &adapter->hw; + int ret; + + idpf_reset_pf(hw); + ret = idpf_check_pf_reset_done(hw); + if (ret != 0) { + DRV_LOG(ERR, "IDPF is still resetting"); + goto err_check_reset; + } + + ret = idpf_init_mbx(hw); + if (ret != 0) { + DRV_LOG(ERR, "Failed to init mailbox"); + goto err_check_reset; + } + + adapter->mbx_resp = rte_zmalloc("idpf_adapter_mbx_resp", + IDPF_DFLT_MBX_BUF_SIZE, 0); + if (adapter->mbx_resp == NULL) { + DRV_LOG(ERR, "Failed to allocate idpf_adapter_mbx_resp memory"); + ret = -ENOMEM; + goto err_mbx_resp; + } + + ret = idpf_vc_api_version_check(adapter); + if (ret != 0) { + DRV_LOG(ERR, "Failed to check api version"); + goto err_check_api; + } + + ret = idpf_get_pkt_type(adapter); + if (ret != 0) { + DRV_LOG(ERR, "Failed to set ptype table"); + goto err_check_api; + } + + return 0; + +err_check_api: + rte_free(adapter->mbx_resp); + adapter->mbx_resp = NULL; +err_mbx_resp: + idpf_ctlq_deinit(hw); +err_check_reset: + return ret; +} + + int idpf_adapter_deinit(struct idpf_adapter *adapter) { diff --git a/drivers/common/idpf/idpf_common_device.h b/drivers/common/idpf/idpf_common_device.h index 364a60221a..185c88fcd2 100644 --- a/drivers/common/idpf/idpf_common_device.h +++ b/drivers/common/idpf/idpf_common_device.h @@ -183,6 +183,8 @@ atomic_set_cmd(struct idpf_adapter *adapter, uint32_t ops) __rte_internal int idpf_adapter_init(struct idpf_adapter *adapter); __rte_internal +int idpf_adapter_common_init(struct idpf_adapter *adapter); +__rte_internal int idpf_adapter_deinit(struct idpf_adapter *adapter); __rte_internal int idpf_vport_init(struct idpf_vport *vport, diff --git a/drivers/common/idpf/idpf_common_virtchnl.c b/drivers/common/idpf/idpf_common_virtchnl.c index 99d9efbb7c..7fa0074293 100644 --- a/drivers/common/idpf/idpf_common_virtchnl.c +++ b/drivers/common/idpf/idpf_common_virtchnl.c @@ -338,6 +338,34 @@ idpf_vc_caps_get(struct idpf_adapter *adapter) return 0; } +int idpf_vc_caps_get_by_info(struct idpf_adapter *adapter, + struct virtchnl2_get_capabilities *caps_info) +{ + struct virtchnl2_get_capabilities caps_msg; + struct idpf_cmd_info args; + int err; + + memset(&caps_msg, 0, sizeof(struct virtchnl2_get_capabilities)); + rte_memcpy(&caps_msg, caps_info, sizeof(caps_msg)); + + args.ops = VIRTCHNL2_OP_GET_CAPS; + args.in_args = (uint8_t *)&caps_msg; + args.in_args_size = sizeof(caps_msg); + 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_CAPS"); + return err; + } + + rte_memcpy(&adapter->caps, args.out_buffer, sizeof(caps_msg)); + + return 0; +} + int idpf_vc_vport_create(struct idpf_vport *vport, struct virtchnl2_create_vport *create_vport_info) diff --git a/drivers/common/idpf/idpf_common_virtchnl.h b/drivers/common/idpf/idpf_common_virtchnl.h index d479d93c8e..6f46bef673 100644 --- a/drivers/common/idpf/idpf_common_virtchnl.h +++ b/drivers/common/idpf/idpf_common_virtchnl.h @@ -64,4 +64,7 @@ int idpf_vc_ctlq_recv(struct idpf_ctlq_info *cq, u16 *num_q_msg, __rte_internal int idpf_vc_ctlq_post_rx_buffs(struct idpf_hw *hw, struct idpf_ctlq_info *cq, u16 *buff_count, struct idpf_dma_mem **buffs); +__rte_internal +int idpf_vc_caps_get_by_info(struct idpf_adapter *adapter, + struct virtchnl2_get_capabilities *caps_info); #endif /* _IDPF_COMMON_VIRTCHNL_H_ */ diff --git a/drivers/common/idpf/version.map b/drivers/common/idpf/version.map index 70334a1b03..c021669fd2 100644 --- a/drivers/common/idpf/version.map +++ b/drivers/common/idpf/version.map @@ -2,6 +2,7 @@ INTERNAL { global: idpf_adapter_deinit; + idpf_adapter_common_init; idpf_adapter_init; idpf_dp_prep_pkts; @@ -37,6 +38,7 @@ INTERNAL { idpf_vc_api_version_check; idpf_vc_caps_get; + idpf_vc_caps_get_by_info; idpf_vc_cmd_execute; idpf_vc_ctlq_post_rx_buffs; idpf_vc_ctlq_recv; diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c index f799707ea7..acc6180ca4 100644 --- a/drivers/net/cpfl/cpfl_ethdev.c +++ b/drivers/net/cpfl/cpfl_ethdev.c @@ -1154,6 +1154,72 @@ cpfl_dev_alarm_handler(void *param) rte_eal_alarm_set(CPFL_ALARM_INTERVAL, cpfl_dev_alarm_handler, adapter); } +static int +cpfl_get_caps(struct idpf_adapter *adapter) +{ + struct virtchnl2_get_capabilities caps_msg = {0}; + + caps_msg.csum_caps = + VIRTCHNL2_CAP_TX_CSUM_L3_IPV4 | + VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_TCP | + VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_UDP | + VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_SCTP | + VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_TCP | + VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_UDP | + VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_SCTP | + VIRTCHNL2_CAP_TX_CSUM_GENERIC | + VIRTCHNL2_CAP_RX_CSUM_L3_IPV4 | + VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_TCP | + VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_UDP | + VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_SCTP | + VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_TCP | + VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_UDP | + VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_SCTP | + VIRTCHNL2_CAP_RX_CSUM_GENERIC; + + caps_msg.rss_caps = + VIRTCHNL2_CAP_RSS_IPV4_TCP | + VIRTCHNL2_CAP_RSS_IPV4_UDP | + VIRTCHNL2_CAP_RSS_IPV4_SCTP | + VIRTCHNL2_CAP_RSS_IPV4_OTHER | + VIRTCHNL2_CAP_RSS_IPV6_TCP | + VIRTCHNL2_CAP_RSS_IPV6_UDP | + VIRTCHNL2_CAP_RSS_IPV6_SCTP | + VIRTCHNL2_CAP_RSS_IPV6_OTHER | + VIRTCHNL2_CAP_RSS_IPV4_AH | + VIRTCHNL2_CAP_RSS_IPV4_ESP | + VIRTCHNL2_CAP_RSS_IPV4_AH_ESP | + VIRTCHNL2_CAP_RSS_IPV6_AH | + VIRTCHNL2_CAP_RSS_IPV6_ESP | + VIRTCHNL2_CAP_RSS_IPV6_AH_ESP; + + caps_msg.other_caps = VIRTCHNL2_CAP_WB_ON_ITR | + VIRTCHNL2_CAP_PTP | + VIRTCHNL2_CAP_RX_FLEX_DESC; + + return idpf_vc_caps_get_by_info(adapter, &caps_msg); +} + +static int +cpfl_adapter_init(struct idpf_adapter *adapter) +{ + int ret = 0; + + ret = idpf_adapter_common_init(adapter); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Failed to init idpf common adapter"); + return ret; + } + + ret = cpfl_get_caps(adapter); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Failed to get capabilities"); + return ret; + } + + return ret; +} + static int cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adapter) { @@ -1170,7 +1236,7 @@ cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *a strncpy(adapter->name, pci_dev->device.name, PCI_PRI_STR_SIZE); - ret = idpf_adapter_init(base); + ret = cpfl_adapter_init(base); if (ret != 0) { PMD_INIT_LOG(ERR, "Failed to init adapter"); goto err_adapter_init; -- 2.25.1