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 898B7427F3; Tue, 21 Mar 2023 08:39:21 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 728E340A7F; Tue, 21 Mar 2023 08:39:21 +0100 (CET) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 8C20C40A7A for ; Tue, 21 Mar 2023 08:39:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679384360; x=1710920360; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cEeZd7Kjonz7C0zgZUDgs57jp6kc37Rmeli51CK0hTE=; b=HRDBkytweeFCt9Ix+VAt3iTDnCNfOpE9amxd7BddqoSdkGqMl7AT8Ii6 CSRtZIT3DGq/I/6HhG2v98SkcsHyX3tSCPFoo1TFY7k0LcwwxhS5EsSXh TZSm6xsSKuGjFPyxpKYuBwcRb5P45mtSden5fZhwqxTOHQLrga0mNrNjK A5eBIC5FIEVU1Yn9dd26kMpM64liRiVKqaKH5zLBCNdyBq5qby6LgGoV5 CRdzjf3YdM25wEEPAKay4UfVNN3g8C/tDqabVoDpdoLcRudF/uZ5pXUjd gyXIkClnharR7dwVuLB5fyt7iFOPIcs+s24FF6WsfOzqulBh402drUOKg A==; X-IronPort-AV: E=McAfee;i="6600,9927,10655"; a="401443732" X-IronPort-AV: E=Sophos;i="5.98,278,1673942400"; d="scan'208";a="401443732" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Mar 2023 00:39:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10655"; a="631464336" X-IronPort-AV: E=Sophos;i="5.98,278,1673942400"; d="scan'208";a="631464336" Received: from dpdk-beileix-3.sh.intel.com ([10.67.110.253]) by orsmga003.jf.intel.com with ESMTP; 21 Mar 2023 00:39:17 -0700 From: beilei.xing@intel.com To: jingjing.wu@intel.com Cc: dev@dpdk.org, Beilei Xing Subject: [PATCH v2] common/idpf: move PF specific functions from common init Date: Tue, 21 Mar 2023 07:07:03 +0000 Message-Id: <20230321070703.80689-1-beilei.xing@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20230321065316.79549-1-beilei.xing@intel.com> References: <20230321065316.79549-1-beilei.xing@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 From: Beilei Xing Move PF reset and PF mailbox initialization functions from idpf_adapter_init function to xxxx_adapter_ext_init function, since they're different between PF and VF support. Signed-off-by: Beilei Xing --- v2 change: - fix typo. drivers/common/idpf/idpf_common_device.c | 72 +++++------------------- drivers/common/idpf/idpf_common_device.h | 13 +++++ drivers/common/idpf/version.map | 5 ++ drivers/net/cpfl/cpfl_ethdev.c | 18 ++++++ drivers/net/idpf/idpf_ethdev.c | 51 +++++++++++++++++ 5 files changed, 100 insertions(+), 59 deletions(-) diff --git a/drivers/common/idpf/idpf_common_device.c b/drivers/common/idpf/idpf_common_device.c index c5e7bbf66c..3b58bdd41e 100644 --- a/drivers/common/idpf/idpf_common_device.c +++ b/drivers/common/idpf/idpf_common_device.c @@ -6,8 +6,8 @@ #include #include -static void -idpf_reset_pf(struct idpf_hw *hw) +void +idpf_hw_pf_reset(struct idpf_hw *hw) { uint32_t reg; @@ -15,9 +15,8 @@ idpf_reset_pf(struct idpf_hw *hw) IDPF_WRITE_REG(hw, PFGEN_CTRL, (reg | PFGEN_CTRL_PFSWR)); } -#define IDPF_RESET_WAIT_CNT 100 -static int -idpf_check_pf_reset_done(struct idpf_hw *hw) +int +idpf_hw_pf_reset_check(struct idpf_hw *hw) { uint32_t reg; int i; @@ -33,48 +32,13 @@ idpf_check_pf_reset_done(struct idpf_hw *hw) return -EBUSY; } -#define CTLQ_NUM 2 -static int -idpf_init_mbx(struct idpf_hw *hw) +int +idpf_hw_mbx_init(struct idpf_hw *hw, struct idpf_ctlq_create_info *ctlq_info) { - struct idpf_ctlq_create_info ctlq_info[CTLQ_NUM] = { - { - .type = IDPF_CTLQ_TYPE_MAILBOX_TX, - .id = IDPF_CTLQ_ID, - .len = IDPF_CTLQ_LEN, - .buf_size = IDPF_DFLT_MBX_BUF_SIZE, - .reg = { - .head = PF_FW_ATQH, - .tail = PF_FW_ATQT, - .len = PF_FW_ATQLEN, - .bah = PF_FW_ATQBAH, - .bal = PF_FW_ATQBAL, - .len_mask = PF_FW_ATQLEN_ATQLEN_M, - .len_ena_mask = PF_FW_ATQLEN_ATQENABLE_M, - .head_mask = PF_FW_ATQH_ATQH_M, - } - }, - { - .type = IDPF_CTLQ_TYPE_MAILBOX_RX, - .id = IDPF_CTLQ_ID, - .len = IDPF_CTLQ_LEN, - .buf_size = IDPF_DFLT_MBX_BUF_SIZE, - .reg = { - .head = PF_FW_ARQH, - .tail = PF_FW_ARQT, - .len = PF_FW_ARQLEN, - .bah = PF_FW_ARQBAH, - .bal = PF_FW_ARQBAL, - .len_mask = PF_FW_ARQLEN_ARQLEN_M, - .len_ena_mask = PF_FW_ARQLEN_ARQENABLE_M, - .head_mask = PF_FW_ARQH_ARQH_M, - } - } - }; struct idpf_ctlq_info *ctlq; int ret; - ret = idpf_ctlq_init(hw, CTLQ_NUM, ctlq_info); + ret = idpf_ctlq_init(hw, IDPF_CTLQ_NUM, ctlq_info); if (ret != 0) return ret; @@ -96,6 +60,12 @@ idpf_init_mbx(struct idpf_hw *hw) return ret; } +void +idpf_hw_mbx_deinit(struct idpf_hw *hw) +{ + idpf_ctlq_deinit(hw); +} + static int idpf_get_pkt_type(struct idpf_adapter *adapter) { @@ -312,19 +282,6 @@ idpf_adapter_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) { @@ -357,8 +314,6 @@ idpf_adapter_init(struct idpf_adapter *adapter) rte_free(adapter->mbx_resp); adapter->mbx_resp = NULL; err_mbx_resp: - idpf_ctlq_deinit(hw); -err_check_reset: return ret; } @@ -367,7 +322,6 @@ idpf_adapter_deinit(struct idpf_adapter *adapter) { struct idpf_hw *hw = &adapter->hw; - idpf_ctlq_deinit(hw); rte_free(adapter->mbx_resp); adapter->mbx_resp = NULL; diff --git a/drivers/common/idpf/idpf_common_device.h b/drivers/common/idpf/idpf_common_device.h index c2dc2f16b9..ac4afd5ab9 100644 --- a/drivers/common/idpf/idpf_common_device.h +++ b/drivers/common/idpf/idpf_common_device.h @@ -10,8 +10,11 @@ #include #include +#define IDPF_RESET_WAIT_CNT 100 + #define IDPF_RSS_KEY_LEN 52 +#define IDPF_CTLQ_NUM 2 #define IDPF_CTLQ_ID -1 #define IDPF_CTLQ_LEN 64 #define IDPF_DFLT_MBX_BUF_SIZE 4096 @@ -142,6 +145,8 @@ struct idpf_cmd_info { uint32_t out_size; /* buffer size for response */ }; +struct idpf_ctlq_create_info ctlq_info[IDPF_CTLQ_NUM]; + /* notify current command done. Only call in case execute * _atomic_set_cmd successfully. */ @@ -180,6 +185,14 @@ atomic_set_cmd(struct idpf_adapter *adapter, uint32_t ops) return !ret; } +__rte_internal +void idpf_hw_pf_reset(struct idpf_hw *hw); +__rte_internal +int idpf_hw_pf_reset_check(struct idpf_hw *hw); +__rte_internal +int idpf_hw_mbx_init(struct idpf_hw *hw, struct idpf_ctlq_create_info *ctlq_info); +__rte_internal +void idpf_hw_mbx_deinit(struct idpf_hw *hw); __rte_internal int idpf_adapter_init(struct idpf_adapter *adapter); __rte_internal diff --git a/drivers/common/idpf/version.map b/drivers/common/idpf/version.map index 70334a1b03..7076759024 100644 --- a/drivers/common/idpf/version.map +++ b/drivers/common/idpf/version.map @@ -15,6 +15,11 @@ INTERNAL { idpf_dp_splitq_xmit_pkts; idpf_dp_splitq_xmit_pkts_avx512; + idpf_hw_mbx_deinit; + idpf_hw_mbx_init; + idpf_hw_pf_reset; + idpf_hw_pf_reset_check; + idpf_qc_rx_thresh_check; idpf_qc_rx_queue_release; idpf_qc_rxq_mbufs_release; diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c index ede730fd50..21505b86f2 100644 --- a/drivers/net/cpfl/cpfl_ethdev.c +++ b/drivers/net/cpfl/cpfl_ethdev.c @@ -1165,6 +1165,8 @@ cpfl_dev_alarm_handler(void *param) rte_eal_alarm_set(CPFL_ALARM_INTERVAL, cpfl_dev_alarm_handler, adapter); } +extern struct idpf_ctlq_create_info ctlq_info[IDPF_CTLQ_NUM]; + static int cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adapter) { @@ -1181,6 +1183,19 @@ 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); + idpf_hw_pf_reset(hw); + ret = idpf_hw_pf_reset_check(hw); + if (ret != 0) { + PMD_INIT_LOG(ERR, "PF is still resetting"); + goto err_reset_check; + } + + ret = idpf_hw_mbx_init(hw, ctlq_info); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Failed to init mailbox"); + goto err_reset_check; + } + ret = idpf_adapter_init(base); if (ret != 0) { PMD_INIT_LOG(ERR, "Failed to init adapter"); @@ -1213,6 +1228,8 @@ cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *a rte_eal_alarm_cancel(cpfl_dev_alarm_handler, adapter); idpf_adapter_deinit(base); err_adapter_init: + idpf_hw_mbx_deinit(hw); +err_reset_check: return ret; } @@ -1323,6 +1340,7 @@ cpfl_adapter_ext_deinit(struct cpfl_adapter_ext *adapter) { rte_eal_alarm_cancel(cpfl_dev_alarm_handler, adapter); idpf_adapter_deinit(&adapter->base); + idpf_hw_mbx_deinit(&adapter->base.hw); rte_free(adapter->vports); adapter->vports = NULL; diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c index e02ec2ec5a..c23623c5fc 100644 --- a/drivers/net/idpf/idpf_ethdev.c +++ b/drivers/net/idpf/idpf_ethdev.c @@ -1128,6 +1128,41 @@ idpf_dev_alarm_handler(void *param) rte_eal_alarm_set(IDPF_ALARM_INTERVAL, idpf_dev_alarm_handler, adapter); } +struct idpf_ctlq_create_info ctlq_info[IDPF_CTLQ_NUM] = { + { + .type = IDPF_CTLQ_TYPE_MAILBOX_TX, + .id = IDPF_CTLQ_ID, + .len = IDPF_CTLQ_LEN, + .buf_size = IDPF_DFLT_MBX_BUF_SIZE, + .reg = { + .head = PF_FW_ATQH, + .tail = PF_FW_ATQT, + .len = PF_FW_ATQLEN, + .bah = PF_FW_ATQBAH, + .bal = PF_FW_ATQBAL, + .len_mask = PF_FW_ATQLEN_ATQLEN_M, + .len_ena_mask = PF_FW_ATQLEN_ATQENABLE_M, + .head_mask = PF_FW_ATQH_ATQH_M, + } + }, + { + .type = IDPF_CTLQ_TYPE_MAILBOX_RX, + .id = IDPF_CTLQ_ID, + .len = IDPF_CTLQ_LEN, + .buf_size = IDPF_DFLT_MBX_BUF_SIZE, + .reg = { + .head = PF_FW_ARQH, + .tail = PF_FW_ARQT, + .len = PF_FW_ARQLEN, + .bah = PF_FW_ARQBAH, + .bal = PF_FW_ARQBAL, + .len_mask = PF_FW_ARQLEN_ARQLEN_M, + .len_ena_mask = PF_FW_ARQLEN_ARQENABLE_M, + .head_mask = PF_FW_ARQH_ARQH_M, + } + } +}; + static int idpf_adapter_ext_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *adapter) { @@ -1144,6 +1179,19 @@ idpf_adapter_ext_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *a strncpy(adapter->name, pci_dev->device.name, PCI_PRI_STR_SIZE); + idpf_hw_pf_reset(hw); + ret = idpf_hw_pf_reset_check(hw); + if (ret != 0) { + PMD_INIT_LOG(ERR, "PF is still resetting"); + goto err_reset_check; + } + + ret = idpf_hw_mbx_init(hw, ctlq_info); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Failed to init mailbox"); + goto err_reset_check; + } + ret = idpf_adapter_init(base); if (ret != 0) { PMD_INIT_LOG(ERR, "Failed to init adapter"); @@ -1175,6 +1223,8 @@ idpf_adapter_ext_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *a rte_eal_alarm_cancel(idpf_dev_alarm_handler, adapter); idpf_adapter_deinit(base); err_adapter_init: + idpf_hw_mbx_deinit(hw); +err_reset_check: return ret; } @@ -1311,6 +1361,7 @@ idpf_adapter_ext_deinit(struct idpf_adapter_ext *adapter) { rte_eal_alarm_cancel(idpf_dev_alarm_handler, adapter); idpf_adapter_deinit(&adapter->base); + idpf_hw_mbx_deinit(&adapter->base.hw); rte_free(adapter->vports); adapter->vports = NULL; -- 2.26.2