From patchwork Mon Apr 24 08:26:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xing, Beilei" X-Patchwork-Id: 126445 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 29709429D2; Mon, 24 Apr 2023 10:49:46 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 177E7410EC; Mon, 24 Apr 2023 10:49:46 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id 04E75410DE for ; Mon, 24 Apr 2023 10:49:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1682326185; x=1713862185; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KkYb3abEHHqd0pWNW/iUPTucd8/xVfv0IURe2D4Lq9w=; b=SCajUDHFet9AQiyGmzbG7p9ruqhNvcXVAEQqgf5ZKmyF7SY9QFKOuTwg Mo/B7RxnAwfvyo/O4QG06srG/4QUzNXpgRJbKW7GDkL3uKouW/zrL2Q0K sU06lZNvzXYOfnLXeQ1u0g+49aUemr1D9pTI8mqAIlhmRjTCjNZwuNXif uSABbwaeHGsagT+pFcfkE3AOIBvB4CKVD95pOyXYyc9qPuvr1qn8ayBi+ t1BxRxaUFSsbAr8j457h8FLEAd6lJ4DOkUOGF6UTBLEQVThQaOK0sm6Rs ARF6KJwb/NLL2JzH8EpvPHzUO9z3mEBN+ylBq6SL58ZVG62X2kAQy0iHP Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10689"; a="345155905" X-IronPort-AV: E=Sophos;i="5.99,222,1677571200"; d="scan'208";a="345155905" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2023 01:49:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10689"; a="817178022" X-IronPort-AV: E=Sophos;i="5.99,222,1677571200"; d="scan'208";a="817178022" Received: from dpdk-beileix-3.sh.intel.com ([10.67.110.253]) by orsmga004.jf.intel.com with ESMTP; 24 Apr 2023 01:49:42 -0700 From: beilei.xing@intel.com To: jingjing.wu@intel.com Cc: dev@dpdk.org, Beilei Xing Subject: [PATCH] net/idpf: add VF support Date: Mon, 24 Apr 2023 08:26:39 +0000 Message-Id: <20230424082639.14006-1-beilei.xing@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20230404124937.72970-1-beilei.xing@intel.com> References: <20230404124937.72970-1-beilei.xing@intel.com> MIME-Version: 1.0 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 Support VF whose device id is 0x145c. Signed-off-by: Beilei Xing --- v3 change: - move check reset done function and mail box init to common module. v2 change: - Rebase code based on new patchset: https://patches.dpdk.org/project/dpdk/cover/20230404124112.71703-1-beilei.xing@intel.com/ drivers/common/idpf/idpf_common_device.c | 140 ++++++++++++++++------- drivers/common/idpf/idpf_common_device.h | 2 + drivers/net/idpf/idpf_ethdev.c | 2 + 3 files changed, 105 insertions(+), 39 deletions(-) diff --git a/drivers/common/idpf/idpf_common_device.c b/drivers/common/idpf/idpf_common_device.c index c5e7bbf66c..7da4eef82c 100644 --- a/drivers/common/idpf/idpf_common_device.c +++ b/drivers/common/idpf/idpf_common_device.c @@ -16,6 +16,7 @@ idpf_reset_pf(struct idpf_hw *hw) } #define IDPF_RESET_WAIT_CNT 100 + static int idpf_check_pf_reset_done(struct idpf_hw *hw) { @@ -33,48 +34,105 @@ idpf_check_pf_reset_done(struct idpf_hw *hw) return -EBUSY; } -#define CTLQ_NUM 2 static int -idpf_init_mbx(struct idpf_hw *hw) +idpf_check_vf_reset_done(struct idpf_hw *hw) { - 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, - } + uint32_t reg; + int i; + + for (i = 0; i < IDPF_RESET_WAIT_CNT; i++) { + reg = IDPF_READ_REG(hw, VFGEN_RSTAT); + if (reg != 0xFFFFFFFF && (reg & VFGEN_RSTAT_VFR_STATE_M)) + return 0; + rte_delay_ms(1000); + } + + DRV_LOG(ERR, "VF reset timeout"); + return -EBUSY; +} + +#define IDPF_CTLQ_NUM 2 + +struct idpf_ctlq_create_info pf_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, + } + } +}; + +struct idpf_ctlq_create_info vf_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 = VF_ATQH, + .tail = VF_ATQT, + .len = VF_ATQLEN, + .bah = VF_ATQBAH, + .bal = VF_ATQBAL, + .len_mask = VF_ATQLEN_ATQLEN_M, + .len_ena_mask = VF_ATQLEN_ATQENABLE_M, + .head_mask = VF_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 = VF_ARQH, + .tail = VF_ARQT, + .len = VF_ARQLEN, + .bah = VF_ARQBAH, + .bal = VF_ARQBAL, + .len_mask = VF_ARQLEN_ARQLEN_M, + .len_ena_mask = VF_ARQLEN_ARQENABLE_M, + .head_mask = VF_ARQH_ARQH_M, + } + } +}; + +static int +idpf_init_mbx(struct idpf_hw *hw) +{ struct idpf_ctlq_info *ctlq; - int ret; + int ret = 0; - ret = idpf_ctlq_init(hw, CTLQ_NUM, ctlq_info); + if (hw->device_id == IDPF_DEV_ID_PF) + ret = idpf_ctlq_init(hw, IDPF_CTLQ_NUM, pf_ctlq_info); + else if (hw->device_id == IDPF_DEV_ID_SRIOV) + ret = idpf_ctlq_init(hw, IDPF_CTLQ_NUM, vf_ctlq_info); if (ret != 0) return ret; @@ -312,8 +370,12 @@ 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 (hw->device_id == IDPF_DEV_ID_PF) { + idpf_reset_pf(hw); + ret = idpf_check_pf_reset_done(hw); + } else if (hw->device_id == IDPF_DEV_ID_SRIOV) { + ret = idpf_check_vf_reset_done(hw); + } if (ret != 0) { DRV_LOG(ERR, "IDPF is still resetting"); goto err_check_reset; diff --git a/drivers/common/idpf/idpf_common_device.h b/drivers/common/idpf/idpf_common_device.h index c2dc2f16b9..261cf2c8ee 100644 --- a/drivers/common/idpf/idpf_common_device.h +++ b/drivers/common/idpf/idpf_common_device.h @@ -10,6 +10,8 @@ #include #include +#define IDPF_DEV_ID_SRIOV 0x145C + #define IDPF_RSS_KEY_LEN 52 #define IDPF_CTLQ_ID -1 diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c index 899fdf8b29..ec87d88fb0 100644 --- a/drivers/net/idpf/idpf_ethdev.c +++ b/drivers/net/idpf/idpf_ethdev.c @@ -1078,6 +1078,7 @@ idpf_handle_virtchnl_msg(struct idpf_adapter_ext *adapter_ex) switch (mbx_op) { case idpf_mbq_opc_send_msg_to_peer_pf: + case idpf_mbq_opc_send_msg_to_peer_drv: if (vc_op == VIRTCHNL2_OP_EVENT) { if (ctlq_msg.data_len < sizeof(struct virtchnl2_event)) { PMD_DRV_LOG(ERR, "Error event"); @@ -1319,6 +1320,7 @@ idpf_dev_vport_init(struct rte_eth_dev *dev, void *init_params) static const struct rte_pci_id pci_id_idpf_map[] = { { RTE_PCI_DEVICE(IDPF_INTEL_VENDOR_ID, IDPF_DEV_ID_PF) }, + { RTE_PCI_DEVICE(IDPF_INTEL_VENDOR_ID, IDPF_DEV_ID_SRIOV) }, { .vendor_id = 0, /* sentinel */ }, };