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 4FF3243267; Thu, 2 Nov 2023 03:24:20 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 76DDF42E67; Thu, 2 Nov 2023 03:23:54 +0100 (CET) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2122.outbound.protection.outlook.com [40.107.96.122]) by mails.dpdk.org (Postfix) with ESMTP id 8558042E66 for ; Thu, 2 Nov 2023 03:23:52 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Moynh1lKBZ1qoN3qQ2SRLEc42ceBXwzd5W2t4CEIEXifaSp69nsUltOiTidYUZ7cixpiV0Ub7RMkkYydbMOVb7GcoIxLS0+dUxEHeax/btS22eO+giVZzlM2yjOM2hzPeyrQw/GMyeyuejG6KouH8rkwTJkORO/73WV43L8+sGxKQCnActaAbcQa4hCV5xg/X7evjJf44ee8IlJuD/kY6gKqMmldbq9bcVqucL9KbUCOuQLnOGbpuUndt0zFOkQYPRKTOjxibvzENutM7wvkB4cGoEL5Yl11nLbZDOnZuiUqT8iCCL5CyJBOc3Jj0VzAaG4FIKqe8o8Grbc4ASHi8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=W50/nAcoJBmAfjnKNsffU7oMusWQsbdZHAgyINcNIvU=; b=BPlRfxMC4agbIWgXGpbEVzbZyADx3c97Fs7B0IGhz77NcmnU4sCG2rowJNkJE1zDJN8VTO65d+2JMVEiUpxRCyYI8ltmK9LlCyeISaNn1wvQp1eLjX996zW/0Pa+D11hUf/yWpyx9gVx+1c/HyV00Xvp/YqBHs+sEFcWE5JZvz0MBpF8IqmzxVHcvXXJrVI5o2f5yb8OlCxY9FCwf/wuFbXTHdGSbKq8ftaMuih0O3QD9KzIfpg1U1+9Zxmr+3lsZA0sDOGZKrKdgX8VaAlv7/XbOGO2PqJQYmgb2tdP4goBzw9M2XlnRXZnIXRBxttFQoBvLzmyLrUasaBQXI3Htw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W50/nAcoJBmAfjnKNsffU7oMusWQsbdZHAgyINcNIvU=; b=Pt6zu5Qq3CBgBOOOaymtDuxgad4H3JHNhpH0VPpZFmitfs/7PYs4W16+ft8chftePaZZpZVUw1GsvGxkztg5CuEKz6eU5yf4sorteJ5z7RSJUCpYjwdJ9p0OyRST/86PGSdHNap5tGRU7cGygOK3aqr1BwgZ89Rdadz7uFq2sQU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by BY5PR13MB4455.namprd13.prod.outlook.com (2603:10b6:a03:1d4::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.19; Thu, 2 Nov 2023 02:23:51 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::45b3:d83c:cff2:4a1b]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::45b3:d83c:cff2:4a1b%6]) with mapi id 15.20.6933.027; Thu, 2 Nov 2023 02:23:51 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Peng Zhang , Chaoyong He , Long Wu Subject: [PATCH 04/11] net/nfp: add flag to indicate multiple PFs support Date: Thu, 2 Nov 2023 10:23:14 +0800 Message-Id: <20231102022321.2254224-5-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231102022321.2254224-1-chaoyong.he@corigine.com> References: <20231102022321.2254224-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: BY5PR20CA0030.namprd20.prod.outlook.com (2603:10b6:a03:1f4::43) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|BY5PR13MB4455:EE_ X-MS-Office365-Filtering-Correlation-Id: 0c30f154-41e3-466f-6230-08dbdb4ac095 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bt8IJp50JMraowWdRAczzf6q5kVHsxsh0TY4JHRkwaf4rgf28MCA1ncv44Mtdqbo2MSIbfh09E7PgXJFqG6umgJ2DQn5PpfrqHOI/awSBLf5CBK3jvWl/8bdAhD+2bQ+RqFfEBH85AApGWyN40PNkK5PYl0bbN6oHXFQXc6FO21uq/C3iPAeZHkKtVi8uo2HL0pLVmjAeujygdclxJdRB8zJGVptCDgzF86Ue0OyQbDLcp/U0m8vNf4a7aE8rUOOI+Q10mM+sx0Qv7XKi44PXVTo1or8zThxSzw/WylrPgvdO7aAXN+6W2eWmaT9mugdEsuQH/ojjgr7hKPnD7eZp2UxI0vwQgMJqiwWHkOA4pbW7NqTBu/Av7OP0Y+Y80JrLTSym3W19eiiKXN9Rom/Q2dJJJOBzZNWFcW/NVWSiM3pfWJnZxGu8LERBJc+pCmVPF1VV6VcsN9VFfCqqAcEAc7L5iJ4EPVDt+abNdaK0yU37EwJj2Iqr8p+sR3lhSVtglPDQpXajJ5lUU6rLNGvdUXlyapkZ8gzU0h+43xkn0XnqZggDv/iaB5/G9MonKt5bSU5hCWC41SMN80irQejzQM0kCAsq7nlu/ND/Re8/KieQYV9bwSFtXcCkEN6F0PfjgQqOCF/iRXIKK7kyd2sBdDydM99RjJ9rhkiolVMilk= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(346002)(396003)(136003)(39830400003)(376002)(366004)(230922051799003)(451199024)(1800799009)(64100799003)(186009)(2906002)(8936002)(4326008)(8676002)(44832011)(6666004)(41300700001)(6486002)(478600001)(66556008)(316002)(66476007)(6916009)(54906003)(5660300002)(66946007)(6506007)(52116002)(107886003)(1076003)(26005)(2616005)(83380400001)(38350700005)(6512007)(36756003)(86362001)(38100700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?I9+uDjcWw/s503kh7kTbhvJI6X7c3k3E2bt7qdHZdQW0A0renGpVHwHUT4tf?= =?us-ascii?Q?RmUEbu6PtgDp+Vh5EJyMlLK8pLmStr06BFCxy3J1hKwtWR+jQ/wCiQ8oiwyB?= =?us-ascii?Q?PZUrY8I/H/Mf3q9O/LpYNQe4rj+Vj7XyFvCCK9cbJ6AOkKGXKekfKlbhfayd?= =?us-ascii?Q?CzOlBZiE+1MJzLjtaTx7UXbEdRuwFtfspz1g2vMXnxFRnm+nW5svrZsCBiak?= =?us-ascii?Q?j1i8mjhiGxpE6NcNuSqV5mpW+dLzb9JCAydT7CD4ykdmRz1rhginyKN/us31?= =?us-ascii?Q?bUHXrphhG4wWqL9mDu5wjVv/Vcd/yDKMt1JXXPMDu4j3wGVUc+mQbNhsM45M?= =?us-ascii?Q?2rILzd8BAM3q2Pa56dN/SVon147C3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ii?Q?fgngj/RnWnN1LbYnzaAcfwuWjF4mCjZ2KItP2N39cUkfYJQoYxfquIhmP8eV?= =?us-ascii?Q?uVuALOvq+Mq/itRSZ1ywO/XE2kSBGFb8NHNb8Lv3lmUccv7+304DePzgLtig?= =?us-ascii?Q?J441r3LoCnHuDQ8BOtsSrq7onkQOClPdEJe46VOfpDIEl6MsghLF7TWG4nBd?= =?us-ascii?Q?LrVKs07F+8r7WeCBc0kIoY8xteHlh/gMjikVn9V6zZFW5mAsCafTVPLIQj5M?= =?us-ascii?Q?WuLkEipOAgNwhu365YpYxXIcq78N0WFQbEeZ938qIF0Mt4BWGKMbrwZX3SJm?= =?us-ascii?Q?oPwk0KJ26f/lS2J9Yiy+3AxYZOKItFnLw/nq7YQC9tn+jV4W66WIRd1pCPYb?= =?us-ascii?Q?iQ=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0c30f154-41e3-466f-6230-08dbdb4ac095 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Nov 2023 02:23:51.0937 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: No2Gvb7SYXu9TkagOc5K1mSddmTAQzy+JKpJ4dO/6xGXcyb35pjp7CiQrZBSk9EWPUhAoaiZAlXMO+5Elr8JYeUunFCY0b6gkNkoRkvjJRE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR13MB4455 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: Peng Zhang Support for multiple PFs have been added to the NFP3800 firmware. This can be detected by reading the NSP major version, which was bumped to 1 when support was added. Add a flag and detecting method to record if the current device is cabable to support multiple PFs. This will be used in later patches to initialize and make use of this new feature. Noteworthy about the detection method from NSP version information, the NSP minor version was not touched when increasing the major version. This makes the first NSP version to support multiple PFs version 1.8, while the latest version without this supports remains 0.8. Signed-off-by: Peng Zhang Reviewed-by: Chaoyong He Reviewed-by: Long Wu --- drivers/net/nfp/nfp_ethdev.c | 49 +++++++++++++++++++++++-------- drivers/net/nfp/nfp_net_common.h | 8 +++++ drivers/net/nfp/nfpcore/nfp_nsp.c | 14 +++++++-- 3 files changed, 56 insertions(+), 15 deletions(-) diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index aa2b59af32..7022ef435f 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -479,7 +479,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev) rte_eth_copy_pci_info(eth_dev, pci_dev); - if (port == 0) { + if (port == 0 || pf_dev->multi_pf.enabled) { uint32_t min_size; hw->ctrl_bar = pf_dev->ctrl_bar; @@ -712,6 +712,26 @@ nfp_fw_setup(struct rte_pci_device *dev, return err; } +static inline bool +nfp_check_multi_pf_from_nsp(struct rte_pci_device *pci_dev, + struct nfp_cpp *cpp) +{ + bool flag; + struct nfp_nsp *nsp; + + nsp = nfp_nsp_open(cpp); + if (nsp == NULL) { + PMD_DRV_LOG(ERR, "NFP error when obtaining NSP handle"); + return false; + } + + flag = (nfp_nsp_get_abi_ver_major(nsp) > 0) && + (pci_dev->id.device_id == PCI_DEVICE_ID_NFP3800_PF_NIC); + + nfp_nsp_close(nsp); + return flag; +} + static int nfp_init_app_fw_nic(struct nfp_pf_dev *pf_dev, const struct nfp_dev_info *dev_info) @@ -874,6 +894,14 @@ nfp_pf_init(struct rte_pci_device *pci_dev) return -ENODEV; } + /* Allocate memory for the PF "device" */ + snprintf(name, sizeof(name), "nfp_pf%d", 0); + pf_dev = rte_zmalloc(name, sizeof(*pf_dev), 0); + if (pf_dev == NULL) { + PMD_INIT_LOG(ERR, "Can't allocate memory for the PF device"); + return -ENOMEM; + } + /* * When device bound to UIO, the device could be used, by mistake, * by two DPDK apps, and the UIO driver does not avoid it. This @@ -888,7 +916,8 @@ nfp_pf_init(struct rte_pci_device *pci_dev) if (cpp == NULL) { PMD_INIT_LOG(ERR, "A CPP handle can not be obtained"); - return -EIO; + ret = -EIO; + goto pf_cleanup; } hwinfo = nfp_hwinfo_read(cpp); @@ -906,6 +935,8 @@ nfp_pf_init(struct rte_pci_device *pci_dev) goto hwinfo_cleanup; } + pf_dev->multi_pf.enabled = nfp_check_multi_pf_from_nsp(pci_dev, cpp); + /* Force the physical port down to clear the possible DMA error */ for (i = 0; i < nfp_eth_table->count; i++) nfp_eth_set_configured(cpp, nfp_eth_table->ports[i].index, 0); @@ -932,14 +963,6 @@ nfp_pf_init(struct rte_pci_device *pci_dev) goto sym_tbl_cleanup; } - /* Allocate memory for the PF "device" */ - snprintf(name, sizeof(name), "nfp_pf%d", 0); - pf_dev = rte_zmalloc(name, sizeof(*pf_dev), 0); - if (pf_dev == NULL) { - ret = -ENOMEM; - goto sym_tbl_cleanup; - } - /* Populate the newly created PF device */ pf_dev->app_fw_id = app_fw_id; pf_dev->cpp = cpp; @@ -957,7 +980,7 @@ nfp_pf_init(struct rte_pci_device *pci_dev) if (pf_dev->qc_bar == NULL) { PMD_INIT_LOG(ERR, "nfp_rtsym_map fails for net.qc"); ret = -EIO; - goto pf_cleanup; + goto sym_tbl_cleanup; } PMD_INIT_LOG(DEBUG, "qc_bar address: %p", pf_dev->qc_bar); @@ -998,8 +1021,6 @@ nfp_pf_init(struct rte_pci_device *pci_dev) hwqueues_cleanup: nfp_cpp_area_free(pf_dev->qc_area); -pf_cleanup: - rte_free(pf_dev); sym_tbl_cleanup: free(sym_tbl); eth_table_cleanup: @@ -1008,6 +1029,8 @@ nfp_pf_init(struct rte_pci_device *pci_dev) free(hwinfo); cpp_cleanup: nfp_cpp_free(cpp); +pf_cleanup: + rte_free(pf_dev); return ret; } diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h index b9df2fe563..bd0ed077c5 100644 --- a/drivers/net/nfp/nfp_net_common.h +++ b/drivers/net/nfp/nfp_net_common.h @@ -54,6 +54,11 @@ struct nfp_net_tlv_caps { uint32_t mbox_cmsg_types; /**< Cmsgs which can be passed through the mailbox */ }; +struct nfp_multi_pf { + /** Support multiple PF */ + bool enabled; +}; + struct nfp_pf_dev { /** Backpointer to associated pci device */ struct rte_pci_device *pci_dev; @@ -79,6 +84,9 @@ struct nfp_pf_dev { /** Service id of cpp bridge service */ uint32_t cpp_bridge_id; + + /** Multiple PF configuration */ + struct nfp_multi_pf multi_pf; }; struct nfp_app_fw_nic { diff --git a/drivers/net/nfp/nfpcore/nfp_nsp.c b/drivers/net/nfp/nfpcore/nfp_nsp.c index a680b972b8..9f88b822f3 100644 --- a/drivers/net/nfp/nfpcore/nfp_nsp.c +++ b/drivers/net/nfp/nfpcore/nfp_nsp.c @@ -40,7 +40,17 @@ #define NSP_DFLT_BUFFER_SIZE_MB GENMASK_ULL(7, 0) #define NSP_MAGIC 0xab10 -#define NSP_MAJOR 0 + +/* + * ABI major version is bumped separately without resetting minor + * version when the change in NSP is not compatible to old driver. + */ +#define NSP_MAJOR 1 + +/* + * ABI minor version is bumped when new feature is introduced + * while old driver can still work without this new feature. + */ #define NSP_MINOR 8 #define NSP_CODE_MAJOR GENMASK_ULL(15, 12) @@ -203,7 +213,7 @@ nfp_nsp_check(struct nfp_nsp *state) state->ver.major = FIELD_GET(NSP_STATUS_MAJOR, reg); state->ver.minor = FIELD_GET(NSP_STATUS_MINOR, reg); - if (state->ver.major != NSP_MAJOR || state->ver.minor < NSP_MINOR) { + if (state->ver.major > NSP_MAJOR || state->ver.minor < NSP_MINOR) { PMD_DRV_LOG(ERR, "Unsupported ABI %hu.%hu", state->ver.major, state->ver.minor); return -EINVAL; -- 2.39.1