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 33E9BA0543; Fri, 12 Aug 2022 11:23:04 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A56F342C1E; Fri, 12 Aug 2022 11:22:46 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2137.outbound.protection.outlook.com [40.107.223.137]) by mails.dpdk.org (Postfix) with ESMTP id 2125442B96 for ; Fri, 12 Aug 2022 11:22:45 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N9MY3btpS10Wt5E2HT3+4sLkiD94ViSYyw3iJ4+g4udu2RB28Ow28gf5ocUSpdV8Pz/MzU+tPninnmwfYz47FJ4VOLVyi7Nq0Hfxxb9ZO8m9VCcO7svjP3cfIeWqZvZSty9/BDONHbjw3xGxjOnQlYdlh7QUHKcvoy617p+ZvbQEpIc+R/BaUsTOonrfakM5JItmEexDd2UMM3f50law+PlOIAAZxB5IVTe3vsC1k9B7lyH0ectJoWr+sSRUpdzeaoQMITO/5JBMvfcgENoY1kSmrLm+V/bomCrxoKetoROIb5c7k1aB+Kh9CIBeE7Ax5ayWqe6YtF4Y8THMHFFwFw== 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=6vg9mBL25Fxi8w90rGRWrhrhpiNEWbERyL6qj9qS6uQ=; b=V9vtRcUPyQ4JF7RB0jPo8ew0Qgu/baoW6K9xTwOdYYrRoWweHcUWtKQcoEHMqefCWdwN2AhxFaaIKbqVKNk0T76sF/uBcnUA8vTMsqQz8GPGKB2jZoLDFQKSvd3d9HdON+QsKX3TrCyeal5mu5vW8r6l3EDzDcyPYkm0piMuBfVraqF/YBh6yFp5dWB5YngORBjjzPrTXhPQqaBcaSjFcfNMw5YotiAOu4K53R3SopV2urGYIJtAD5DN3prl7V98Qfzc4XbPapiP9C7Tuj6pQgzemDkxUwU0geGBaNrXaPZ/TgtxLux4fMARIZDmcJkTE29FbGVCQaOGkGbc01eYrA== 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=6vg9mBL25Fxi8w90rGRWrhrhpiNEWbERyL6qj9qS6uQ=; b=WCO9D5cHTb9+L6bUnZoXlH4hO2QIpxjaOZrdcDV0mQb8bDJw9fgqUQbA9lspMiX0YIdX7u4xfbVk4B9eseETJcae1xxvPb/KJ1u7ek8CVEkNZDWFW23CPR5ZKSk9VPd9m+FwOLgIYTAHd2iJEqlum9G+WDMuT+mkp+liX48iCqM= 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 PH0PR13MB5284.namprd13.prod.outlook.com (2603:10b6:510:f5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.9; Fri, 12 Aug 2022 09:22:43 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::402d:6abc:83a8:2431]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::402d:6abc:83a8:2431%5]) with mapi id 15.20.5525.009; Fri, 12 Aug 2022 09:22:43 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He , Heinrich Kuhn Subject: [PATCH v6 04/12] net/nfp: add initial flower firmware support Date: Fri, 12 Aug 2022 17:22:05 +0800 Message-Id: <1660296133-35266-5-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1660296133-35266-1-git-send-email-chaoyong.he@corigine.com> References: <1660296133-35266-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI2PR01CA0046.apcprd01.prod.exchangelabs.com (2603:1096:4:193::18) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1799cc34-94f3-48d4-3d86-08da7c44362d X-MS-TrafficTypeDiagnostic: PH0PR13MB5284:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Us0EXsgg/pesErogk9SJd6VZBUdN8aQnYi+7/mQW/6i6JL8fRXxLuxLjX6JXFg6In7fBxDhm4aS7lY+0MlNX9LTxcl0VvqMIoCjnMD11tpUKLONo7ohRJ5gOfDffzJ9rGsFBGnkMqtuSmQX5aRBCq520Mcj3uJ+cB+sRjymDU9RvAuWfJQJEhEmY2cIlmQSkkxUrDBPL+HojcMOC6eorPAMdt5Pikejm6iSC67Q8N/gwiWTLB9q3M5ca/53GlxJ6TTs6YbsejxnCYAZ3kN6wVS3dDBUXb/xcSYa/7zPXjgF5sUnVt3rIvq7DTvVKCB4F1kmkRpnyh4sb18RyFXqzld018UcA0GJHK2Tmiji9Wy8fkvSnGwbUb8Ccpf8QYz+dknVouyMhwJaf9GP/QFFQeVUqa7wRTfd5vNpPu737Ufch+9DHRev4f1svjR6tYLjk6hpCTL7Sr1gUvbYO/4ZPMpCMZZEd3xcTT2y8FZwV3weo+6kTLBEXQgVoGiPu1mgd1vMv4KvYIu2isby9sAOFzFf9BfyGugO/5EcLQOHmDI04KyQtdgcVG3vDQEaxMbWdGpy+pwWURLJ0YMIdLGX3OhxsUKTuIArodYYzjBryFIZlAjkNXFh0dF9oiA4cdH2Ceb2XfQQXpoo3YyMjdXa2g3aIhuZlD2gNTT418G28VBZ4JTqLjIfSsctLdULYKMre4wHi6l1DUJBPGRnlF8+wXFWKEIlOInfZnKcv+QvRCHZYmiH2YHTWB9n1JLnxemwKIFbu2DFkK8mOE9aJpe0/qa28ZPlzdi5iIdQFKE6DvHomNgCzHHOspJbxI1xo9oYLIHFaZtqldyHTigYOiJcF97B++nRPCW9+pa0gcaHlmNc= 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:(13230016)(4636009)(346002)(376002)(39850400004)(136003)(396003)(366004)(86362001)(36756003)(6666004)(41300700001)(30864003)(44832011)(38100700002)(38350700002)(83380400001)(186003)(6506007)(66574015)(6916009)(26005)(107886003)(6512007)(2616005)(5660300002)(8936002)(478600001)(52116002)(2906002)(6486002)(8676002)(316002)(54906003)(66476007)(4326008)(66946007)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?T2phbmlQT3VpZEIxMjRCYWRINkJ3T2xDVVZ1MnpsNWFhaVZyNUxTNGtzVjBh?= =?utf-8?B?VDZUZXIvUDErZzF1MFJWdXlyQm5rNlY2aHpsSmlBaWZEcHFTenlZQmg5bktI?= =?utf-8?B?SWJlVU1ON3ptVWlRMVphQTZOR0RscGpWcDZPU0xqUXlsVmhsaVprbnJEZlBN?= =?utf-8?B?VlhSY2pqY0pWRWRGWjVyN2F2YmFLancxWUlaalBxUjhqNE1TSFFzYyt5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dkhlSGxoQTdhLzBvdjFJ?= =?utf-8?B?cjlWUVZ5VzVEcS9obWpvMzZyNlhaTWhjNGpmb1RueTdVMjFqNjZFdHhCUHBZ?= =?utf-8?B?ZEI3RE1DL1dKYVM3Znp3aGs5bTFzbjV1U09UVHErNG5pd3BWSDhqRURxemRN?= =?utf-8?B?SGc9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1799cc34-94f3-48d4-3d86-08da7c44362d X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2022 09:22:43.5525 (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: coYxiP7Af7scTuz1hRWQ0nw16gXOsa33N7+NRn4QfwcVKMkkg0JFvZ5wOksB4EuUHakqOHbYvRjSHRkjr7Gn6Ltel/y3/ypSjg215+nrAx4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5284 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 Adds the basic probing infrastructure to support the flower firmware. This firmware is geared towards offloading OVS and can generally be found in /lib/firmware/netronome/flower. It is also used by the NFP kernel driver when OVS offload with TC is desired. Adds the basic infrastructure needed by the flower firmware to operate. The firmware requires threads to service both the PF vNIC and the ctrl vNIC. The PF is responsible for handling any fallback traffic and the ctrl vNIC is used to communicate OVS flows and flow statistics to and from the smartNIC. rte_services are used to facilitate this logic. Adds the cpp service, used for some user tools. Signed-off-by: Chaoyong He Signed-off-by: Heinrich Kuhn Reviewed-by: Niklas Söderlund --- drivers/net/nfp/flower/nfp_flower.c | 102 ++++++++++++++++++++++++++++++++++++ drivers/net/nfp/flower/nfp_flower.h | 22 ++++++++ drivers/net/nfp/meson.build | 1 + drivers/net/nfp/nfp_common.h | 1 + drivers/net/nfp/nfp_cpp_bridge.c | 88 ++++++++++++++++++++++++++----- drivers/net/nfp/nfp_cpp_bridge.h | 6 ++- drivers/net/nfp/nfp_ethdev.c | 40 ++++++++++++-- 7 files changed, 241 insertions(+), 19 deletions(-) create mode 100644 drivers/net/nfp/flower/nfp_flower.c create mode 100644 drivers/net/nfp/flower/nfp_flower.h diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c new file mode 100644 index 0000000..1e12f49 --- /dev/null +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -0,0 +1,102 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2022 Corigine, Inc. + * All rights reserved. + */ + +#include +#include +#include +#include +#include +#include + +#include "../nfp_common.h" +#include "../nfp_logs.h" +#include "../nfp_ctrl.h" +#include "../nfp_cpp_bridge.h" +#include "nfp_flower.h" + +static struct rte_service_spec flower_services[NFP_FLOWER_SERVICE_MAX] = { +}; + +static int +nfp_flower_enable_services(struct nfp_app_flower *app_flower) +{ + int i; + int ret = 0; + + for (i = 0; i < NFP_FLOWER_SERVICE_MAX; i++) { + /* Pass a pointer to the flower app to the service */ + flower_services[i].callback_userdata = (void *)app_flower; + + /* Register the flower services */ + ret = rte_service_component_register(&flower_services[i], + &app_flower->flower_services_ids[i]); + if (ret != 0) { + PMD_INIT_LOG(WARNING, + "Could not register Flower PF vNIC service"); + break; + } + + PMD_INIT_LOG(INFO, "Flower PF vNIC service registered"); + + /* Map them to available service cores*/ + ret = nfp_map_service(app_flower->flower_services_ids[i]); + if (ret != 0) + break; + } + + return ret; +} + +int +nfp_init_app_flower(struct nfp_pf_dev *pf_dev) +{ + int ret; + unsigned int numa_node; + struct nfp_net_hw *pf_hw; + struct nfp_app_flower *app_flower; + + numa_node = rte_socket_id(); + + /* Allocate memory for the Flower app */ + app_flower = rte_zmalloc_socket("nfp_app_flower", sizeof(*app_flower), + RTE_CACHE_LINE_SIZE, numa_node); + if (app_flower == NULL) { + ret = -ENOMEM; + goto done; + } + + pf_dev->app_priv = app_flower; + + /* Allocate memory for the PF AND ctrl vNIC here (hence the * 2) */ + pf_hw = rte_zmalloc_socket("nfp_pf_vnic", 2 * sizeof(struct nfp_net_adapter), + RTE_CACHE_LINE_SIZE, numa_node); + if (pf_hw == NULL) { + ret = -ENOMEM; + goto app_cleanup; + } + + /* Start up flower services */ + ret = nfp_flower_enable_services(app_flower); + if (ret != 0) { + ret = -ESRCH; + goto vnic_cleanup; + } + + return 0; + +vnic_cleanup: + rte_free(pf_hw); +app_cleanup: + rte_free(app_flower); +done: + return ret; +} + +int +nfp_secondary_init_app_flower(__rte_unused struct nfp_cpp *cpp) +{ + PMD_INIT_LOG(ERR, "Flower firmware not supported"); + return -ENOTSUP; +} diff --git a/drivers/net/nfp/flower/nfp_flower.h b/drivers/net/nfp/flower/nfp_flower.h new file mode 100644 index 0000000..4a9b302 --- /dev/null +++ b/drivers/net/nfp/flower/nfp_flower.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2022 Corigine, Inc. + * All rights reserved. + */ + +#ifndef _NFP_FLOWER_H_ +#define _NFP_FLOWER_H_ + +enum nfp_flower_service { + NFP_FLOWER_SERVICE_MAX +}; + +/* The flower application's private structure */ +struct nfp_app_flower { + /* List of rte_service ID's for the flower app */ + uint32_t flower_services_ids[NFP_FLOWER_SERVICE_MAX]; +}; + +int nfp_init_app_flower(struct nfp_pf_dev *pf_dev); +int nfp_secondary_init_app_flower(struct nfp_cpp *cpp); + +#endif /* _NFP_FLOWER_H_ */ diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build index 810f02a..7ae3115 100644 --- a/drivers/net/nfp/meson.build +++ b/drivers/net/nfp/meson.build @@ -6,6 +6,7 @@ if not is_linux or not dpdk_conf.get('RTE_ARCH_64') reason = 'only supported on 64-bit Linux' endif sources = files( + 'flower/nfp_flower.c', 'nfpcore/nfp_cpp_pcie_ops.c', 'nfpcore/nfp_nsp.c', 'nfpcore/nfp_cppcore.c', diff --git a/drivers/net/nfp/nfp_common.h b/drivers/net/nfp/nfp_common.h index b99971b..8d721bd 100644 --- a/drivers/net/nfp/nfp_common.h +++ b/drivers/net/nfp/nfp_common.h @@ -114,6 +114,7 @@ /* Firmware application ID's */ enum nfp_app_id { NFP_APP_CORE_NIC = 0x1, + NFP_APP_FLOWER_NIC = 0x3, }; /* nfp_qcp_ptr - Read or Write Pointer of a queue */ diff --git a/drivers/net/nfp/nfp_cpp_bridge.c b/drivers/net/nfp/nfp_cpp_bridge.c index 0922ea9..ac14029 100644 --- a/drivers/net/nfp/nfp_cpp_bridge.c +++ b/drivers/net/nfp/nfp_cpp_bridge.c @@ -28,22 +28,86 @@ static int nfp_cpp_bridge_serve_write(int sockfd, struct nfp_cpp *cpp); static int nfp_cpp_bridge_serve_read(int sockfd, struct nfp_cpp *cpp); static int nfp_cpp_bridge_serve_ioctl(int sockfd, struct nfp_cpp *cpp); +static int nfp_cpp_bridge_service_func(void *args); -void nfp_register_cpp_service(struct nfp_cpp *cpp) +static struct rte_service_spec cpp_service = { + .name = "nfp_cpp_service", + .callback = nfp_cpp_bridge_service_func, +}; + +int +nfp_map_service(uint32_t service_id) { - uint32_t *cpp_service_id = NULL; - struct rte_service_spec service; + int32_t ret; + uint32_t slcore = 0; + int32_t slcore_count; + uint8_t service_count; + const char *service_name; + uint32_t slcore_array[RTE_MAX_LCORE]; + uint8_t min_service_count = UINT8_MAX; + + slcore_count = rte_service_lcore_list(slcore_array, RTE_MAX_LCORE); + if (slcore_count <= 0) { + PMD_INIT_LOG(DEBUG, "No service cores found"); + return -ENOENT; + } + + /* + * Find a service core with the least number of services already + * registered to it + */ + while (slcore_count--) { + service_count = rte_service_lcore_count_services(slcore_array[slcore_count]); + if (service_count < min_service_count) { + slcore = slcore_array[slcore_count]; + min_service_count = service_count; + } + } - memset(&service, 0, sizeof(struct rte_service_spec)); - snprintf(service.name, sizeof(service.name), "nfp_cpp_service"); - service.callback = nfp_cpp_bridge_service_func; - service.callback_userdata = (void *)cpp; + service_name = rte_service_get_name(service_id); + PMD_INIT_LOG(INFO, "Mapping service %s to core %u", service_name, slcore); + ret = rte_service_map_lcore_set(service_id, slcore, 1); + if (ret != 0) { + PMD_INIT_LOG(DEBUG, "Could not map flower service"); + return -ENOENT; + } - if (rte_service_component_register(&service, - cpp_service_id)) - RTE_LOG(WARNING, PMD, "NFP CPP bridge service register() failed"); + rte_service_runstate_set(service_id, 1); + rte_service_component_runstate_set(service_id, 1); + rte_service_lcore_start(slcore); + if (rte_service_may_be_active(slcore)) + RTE_LOG(INFO, PMD, "The service %s is running", service_name); else - RTE_LOG(DEBUG, PMD, "NFP CPP bridge service registered"); + RTE_LOG(INFO, PMD, "The service %s is not running", service_name); + + return 0; +} + +int nfp_enable_cpp_service(struct nfp_cpp *cpp, enum nfp_app_id app_id) +{ + int ret = 0; + uint32_t id = 0; + + cpp_service.callback_userdata = (void *)cpp; + + /* Register the cpp service */ + ret = rte_service_component_register(&cpp_service, &id); + if (ret != 0) { + PMD_INIT_LOG(WARNING, "Could not register nfp cpp service"); + return -EINVAL; + } + + PMD_INIT_LOG(INFO, "NFP cpp service registered"); + + /* Map it to available service core*/ + ret = nfp_map_service(id); + if (ret != 0) { + PMD_INIT_LOG(DEBUG, "Could not map nfp cpp service"); + if (app_id == NFP_APP_FLOWER_NIC) + return -EINVAL; + } + + return 0; } /* @@ -307,7 +371,7 @@ void nfp_register_cpp_service(struct nfp_cpp *cpp) * unaware of the CPP bridge performing the NFP kernel char driver for CPP * accesses. */ -int32_t +static int nfp_cpp_bridge_service_func(void *args) { struct sockaddr address; diff --git a/drivers/net/nfp/nfp_cpp_bridge.h b/drivers/net/nfp/nfp_cpp_bridge.h index aea5fdc..dde50d7 100644 --- a/drivers/net/nfp/nfp_cpp_bridge.h +++ b/drivers/net/nfp/nfp_cpp_bridge.h @@ -16,6 +16,8 @@ #ifndef _NFP_CPP_BRIDGE_H_ #define _NFP_CPP_BRIDGE_H_ +#include "nfp_common.h" + #define NFP_CPP_MEMIO_BOUNDARY (1 << 20) #define NFP_BRIDGE_OP_READ 20 #define NFP_BRIDGE_OP_WRITE 30 @@ -24,8 +26,8 @@ #define NFP_IOCTL 'n' #define NFP_IOCTL_CPP_IDENTIFICATION _IOW(NFP_IOCTL, 0x8f, uint32_t) -void nfp_register_cpp_service(struct nfp_cpp *cpp); -int32_t nfp_cpp_bridge_service_func(void *args); +int nfp_map_service(uint32_t service_id); +int nfp_enable_cpp_service(struct nfp_cpp *cpp, enum nfp_app_id app_id); #endif /* _NFP_CPP_BRIDGE_H_ */ /* diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index ec4f408..8dad575 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -38,6 +38,8 @@ #include "nfp_ctrl.h" #include "nfp_cpp_bridge.h" +#include "flower/nfp_flower.h" + static int nfp_net_pf_read_mac(struct nfp_app_nic *app_nic, int port) { @@ -837,7 +839,8 @@ } static int -nfp_pf_init(struct rte_pci_device *pci_dev) +nfp_pf_init(struct rte_pci_device *pci_dev, + struct rte_pci_driver *pci_drv) { int ret; int err = 0; @@ -964,6 +967,16 @@ goto hwqueues_cleanup; } break; + case NFP_APP_FLOWER_NIC: + PMD_INIT_LOG(INFO, "Initializing Flower"); + pci_dev->device.driver = &pci_drv->driver; + ret = nfp_init_app_flower(pf_dev); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Could not initialize Flower!"); + pci_dev->device.driver = NULL; + goto hwqueues_cleanup; + } + break; default: PMD_INIT_LOG(ERR, "Unsupported Firmware loaded"); ret = -EINVAL; @@ -971,7 +984,12 @@ } /* register the CPP bridge service here for primary use */ - nfp_register_cpp_service(pf_dev->cpp); + ret = nfp_enable_cpp_service(pf_dev->cpp, pf_dev->app_id); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Enable cpp service failed."); + ret = -EINVAL; + goto hwqueues_cleanup; + } return 0; @@ -1095,6 +1113,14 @@ goto sym_tbl_cleanup; } break; + case NFP_APP_FLOWER_NIC: + PMD_INIT_LOG(INFO, "Initializing Flower"); + ret = nfp_secondary_init_app_flower(cpp); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Could not initialize Flower!"); + goto sym_tbl_cleanup; + } + break; default: PMD_INIT_LOG(ERR, "Unsupported Firmware loaded"); ret = -EINVAL; @@ -1105,7 +1131,11 @@ goto sym_tbl_cleanup; /* Register the CPP bridge service for the secondary too */ - nfp_register_cpp_service(cpp); + ret = nfp_enable_cpp_service(cpp, app_id); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Enable cpp service failed."); + ret = -EINVAL; + } sym_tbl_cleanup: free(sym_tbl); @@ -1114,11 +1144,11 @@ } static int -nfp_pf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, +nfp_pf_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *dev) { if (rte_eal_process_type() == RTE_PROC_PRIMARY) - return nfp_pf_init(dev); + return nfp_pf_init(dev, pci_drv); else return nfp_pf_secondary_init(dev); } -- 1.8.3.1