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 825CAA0548; Thu, 8 Sep 2022 10:46:20 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E9A7442B7C; Thu, 8 Sep 2022 10:45:44 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2119.outbound.protection.outlook.com [40.107.237.119]) by mails.dpdk.org (Postfix) with ESMTP id 485BE42B7C for ; Thu, 8 Sep 2022 10:45:42 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DKBIxfXgOS4kG+RQEDFyqzX+Ylmbrns0pkG6e3qC9St/hNn8fFDVSIm4W0yINBuvY+JopeuxLSQM0feE5tLniJYCA1MvQ91uHboNhPf95FFRxjmXc6ZPsrVHPzfF4jl2we8Jac0yYBQ608rgZ2Fmxj9N4IWJ8/JmNDa8M/XSWV26icqqd9aJasNu7tRb3ErGcFiDd1jRuMJkD34RyHxpwwVVSYZeqfAhJZvfFa3+HI5GFzrjqfiqW1GCUA+KE3iogjKlkjiJu61hgTWNRCCrBK0UVztbD7rOQGnKPT8a82qIeY/gtaSxWqMg5sbL6guUubTrnQGmMbNhihzfFB8GQw== 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=bWygOeOgAbCApDX13ejBx8a6rGrmQDA80IBSgNOzrqs=; b=Z5VSRxxhTko2+70C/bu//Qdn7Uw7r0Bc4cos5jy5RkpD/BL+i7JChBk3tp+6/j1Un5oVeS/KuTeqW4UMOPDe4ZZS7V2tsEzplgm+VGd6mWaFiBf9+Y9rL62VehkHd5CitDb3h1gjc5k9Ogjh/o5Dyb8pdwtESq9gt4bWuYnW0xxxWi14wpekcHObYFoigB3+z1VqZh70bTyUbo5LCowemUKVnCUb0zZEtTZdJn2PCPRPBoBRZYCdJ3oHnyUkoITzIkdqh5efovtu6TGspPvE/o98gjTBhFRyB3ljh5c+dxAPUofRwcqvzJBqyIpzpqDuwtV+L3ERBY+1vNWEMpfTWg== 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=bWygOeOgAbCApDX13ejBx8a6rGrmQDA80IBSgNOzrqs=; b=R+KTyZ0mhAjq/MsH2eliyIMs84KcjECiVUfS6sJWhBELnRXKih06JWsptoiTjoGQ9zgpfo/O5IJqGAeF91YNWhO1Ulw+qTwQiFttu+hUIqXeamW3/ca3rseQPPgfIgX4PJnUz/jXyTAzOQ+Au0Vy08/mIP+uadZ4/umvyThmgFc= 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 MW4PR13MB5940.namprd13.prod.outlook.com (2603:10b6:303:1b8::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.3; Thu, 8 Sep 2022 08:45:40 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::402d:6abc:83a8:2431]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::402d:6abc:83a8:2431%6]) with mapi id 15.20.5612.009; Thu, 8 Sep 2022 08:45:40 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v8 07/12] net/nfp: add flower ctrl VNIC related logics Date: Thu, 8 Sep 2022 16:44:57 +0800 Message-Id: <1662626702-17254-8-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1662626702-17254-1-git-send-email-chaoyong.he@corigine.com> References: <1662626702-17254-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI2PR01CA0023.apcprd01.prod.exchangelabs.com (2603:1096:4:192::17) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|MW4PR13MB5940:EE_ X-MS-Office365-Filtering-Correlation-Id: 01d5831e-e8bb-4602-a131-08da9176824f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +P3O2oNz7lhdNRjaO1mmFIznOM2p0Gx1Uzw14EwJS9RQumLcaZZuHSU1SzCYqO0qNNl29LkKFI02j4xWNSkIi4l2qNeSTs3SxltU1dbi8YBHXPf3cPx5KtoPHri+czWPxCC7fqThKbV+b4mya6Vc5imTsmJ8QcgeRyxMTw4mp6g7ehmOztWh3GrY40iFezwl0CHiM2+DbqOkUAeDvj2qBdiiseOMCSM0eJuz17l47IQiAMEVbmZFfIz44x9YL/IKK7qtZZ9xkwV5aTVHiBkMw6eF1+rI9mCxSejvBXeDH7ZtPNW6eKYmgu4vg3pnQTzPu/O/swg0XXlXtNZhWYrK7Gyae+uFve7qddQ63vYj29M4GZAAH8P9hZZlBVsso44zeQGHm5NTWmg2jtfrL265HR/+U/aFfDpGswRxNuaO4LlNjhpmeRe4SGS7WXYmq/cppdU5khJS9iVkXTzO7UgccmEv/ndBQlGbt7mJg6E+9bverYRn84eYf0VCwvlU2wGqXhQQN/fr7AzWfreRwG45HEfUz2PigMLYBkcm5+Q/46/xm3rhWhaPARjhfC60NJyypnTq6Cp94+hejSvKtk4m1sHBdGHwCbG+W3E8Ou+EDJ/r5BDQqsGL7Wm8YuOJNoglGbXpo/f3xzFt7P3LSeumiZMtOVdX/i/E2Nd9H4j0hgCsZUKkogfrnfY1KunjP93n6VBvqbf9+Vfw28jAS2Jlj1HaF8OgYKiNqmUmyi8UwKBk2y/jyxXyulB2YZTNp/t3/X4zB187ad+7X1Gw+h1Cmg== 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)(396003)(366004)(39840400004)(346002)(376002)(136003)(107886003)(44832011)(2616005)(30864003)(41300700001)(6916009)(38350700002)(83380400001)(66574015)(26005)(6512007)(186003)(36756003)(38100700002)(4326008)(2906002)(6506007)(316002)(66946007)(478600001)(86362001)(5660300002)(66476007)(52116002)(6486002)(6666004)(8936002)(8676002)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?cHd5dzg2QVhGMzFGR0dkblAvaTJ6TVp3YUlkUmwzeE5RNU92Wlo5UTlxSG5I?= =?utf-8?B?aGVwakVBVEt1NFhlWEZaSmZpZ1N5cVh2SXFHZDJySmdKS2lYaVRCNTlBelFO?= =?utf-8?B?Y2pVWWVFWHpROExYN1A3MHNpeUVmZURVdWpYUXBTeU13NkN1cnhjVm5aQkVD?= =?utf-8?B?RkpiWnUzVkpDUFo3aTk5VThrTlRFaWo5cEkxaExzR0ppUUlubFM0NE8rbkRF?= =?utf-8?B?c05CRDMyTHdleHJsQ2hjK3Z0alpRRjlGYk9hMHcrbzhOZ3orSGZtcnMzTHBI?= =?utf-8?B?S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haMC9KVk5iVGhUZ0UyS2NvZ3BI?= =?utf-8?B?M3l2STZ1MlhWU1FhbnRGWXBwVGxlK2FwbytZSEx0VnZLNWxZb0lHdTQvck1t?= =?utf-8?B?cmc9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR13MB5940 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 setup/start logic for the ctrl vNIC. This vNIC is used by the PMD and flower firmware as a communication channel between driver and firmware. In the case of OVS it is also used to communicate flow statistics from hardware to the driver. A rte_eth device is not exposed to DPDK for this vNIC as it is strictly used internally by flower logic. Rx and Tx logic will be added later for this vNIC. Because of the add of ctrl vNIC, a new PCItoCPPBar is needed. Modify the related logics. Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- drivers/net/nfp/flower/nfp_flower.c | 264 +++++++++++++++++++++++++++++ drivers/net/nfp/flower/nfp_flower.h | 6 + drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c | 31 ++-- 3 files changed, 289 insertions(+), 12 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index e0c0ab3..4d07416 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -26,6 +26,7 @@ #define DEFAULT_FLBUF_SIZE 9216 #define PF_VNIC_NB_DESC 1024 +#define CTRL_VNIC_NB_DESC 512 static const struct rte_eth_rxconf rx_conf = { .rx_free_thresh = DEFAULT_RX_FREE_THRESH, @@ -205,6 +206,11 @@ .dev_close = nfp_flower_pf_close, }; +static const struct eth_dev_ops nfp_flower_ctrl_vnic_ops = { + .dev_infos_get = nfp_net_infos_get, + .dev_configure = nfp_net_configure, +}; + static void nfp_flower_pf_mp_init(__rte_unused struct rte_mempool *mp, __rte_unused void *opaque_arg, @@ -489,6 +495,176 @@ } static int +nfp_flower_init_ctrl_vnic(struct nfp_net_hw *hw) +{ + uint32_t i; + int ret = 0; + uint16_t n_txq; + uint16_t n_rxq; + uint16_t port_id; + unsigned int numa_node; + struct rte_mempool *mp; + struct nfp_pf_dev *pf_dev; + struct rte_eth_dev *eth_dev; + struct nfp_app_fw_flower *app_fw_flower; + + static const struct rte_eth_conf port_conf = { + .rxmode = { + .mq_mode = RTE_ETH_MQ_RX_NONE, + }, + .txmode = { + .mq_mode = RTE_ETH_MQ_TX_NONE, + }, + }; + + /* Set up some pointers here for ease of use */ + pf_dev = hw->pf_dev; + app_fw_flower = NFP_PRIV_TO_APP_FW_FLOWER(pf_dev->app_fw_priv); + + ret = nfp_flower_init_vnic_common(hw, "ctrl_vnic"); + if (ret != 0) + goto done; + + /* Allocate memory for the eth_dev of the vNIC */ + hw->eth_dev = rte_eth_dev_allocate("nfp_ctrl_vnic"); + if (hw->eth_dev == NULL) { + ret = -ENOMEM; + goto done; + } + + /* Grab the pointer to the newly created rte_eth_dev here */ + eth_dev = hw->eth_dev; + + numa_node = rte_socket_id(); + + /* Fill in some of the eth_dev fields */ + eth_dev->device = &pf_dev->pci_dev->device; + eth_dev->data->dev_private = hw; + + /* Create a mbuf pool for the ctrl vNIC */ + app_fw_flower->ctrl_pktmbuf_pool = rte_pktmbuf_pool_create("ctrl_mbuf_pool", + 4 * CTRL_VNIC_NB_DESC, 64, 0, 9216, numa_node); + if (app_fw_flower->ctrl_pktmbuf_pool == NULL) { + PMD_INIT_LOG(ERR, "create mbuf pool for ctrl vnic failed"); + ret = -ENOMEM; + goto port_release; + } + + mp = app_fw_flower->ctrl_pktmbuf_pool; + + eth_dev->dev_ops = &nfp_flower_ctrl_vnic_ops; + rte_eth_dev_probing_finish(eth_dev); + + /* Configure the ctrl vNIC device */ + n_rxq = hw->max_rx_queues; + n_txq = hw->max_tx_queues; + port_id = hw->eth_dev->data->port_id; + + ret = rte_eth_dev_configure(port_id, n_rxq, n_txq, &port_conf); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Could not configure ctrl vNIC device %d", ret); + goto mempool_cleanup; + } + + /* Set up the Rx queues */ + for (i = 0; i < n_rxq; i++) { + ret = nfp_net_rx_queue_setup(eth_dev, i, CTRL_VNIC_NB_DESC, numa_node, + &rx_conf, mp); + if (ret) { + PMD_INIT_LOG(ERR, "Configure ctrl vNIC Rx queue %d failed", i); + goto rx_queue_cleanup; + } + } + + /* Set up the Tx queues */ + for (i = 0; i < n_txq; i++) { + ret = nfp_net_nfd3_tx_queue_setup(eth_dev, i, CTRL_VNIC_NB_DESC, numa_node, + &tx_conf); + if (ret) { + PMD_INIT_LOG(ERR, "Configure ctrl vNIC Tx queue %d failed", i); + goto tx_queue_cleanup; + } + } + + return 0; + +tx_queue_cleanup: + for (i = 0; i < n_txq; i++) + nfp_net_tx_queue_release(eth_dev, i); +rx_queue_cleanup: + for (i = 0; i < n_rxq; i++) + nfp_net_rx_queue_release(eth_dev, i); +mempool_cleanup: + rte_mempool_free(mp); +port_release: + rte_eth_dev_release_port(hw->eth_dev); +done: + return ret; +} + +static void +nfp_flower_cleanup_ctrl_vnic(struct nfp_net_hw *hw) +{ + uint32_t i; + struct nfp_app_fw_flower *app_fw_flower; + + app_fw_flower = NFP_PRIV_TO_APP_FW_FLOWER(hw->pf_dev->app_fw_priv); + + for (i = 0; i < hw->max_tx_queues; i++) + nfp_net_tx_queue_release(hw->eth_dev, i); + + for (i = 0; i < hw->max_rx_queues; i++) + nfp_net_rx_queue_release(hw->eth_dev, i); + + rte_mempool_free(app_fw_flower->ctrl_pktmbuf_pool); + rte_eth_dev_release_port(hw->eth_dev); +} + +static int +nfp_flower_start_ctrl_vnic(struct nfp_net_hw *hw) +{ + int ret; + uint32_t update; + uint32_t new_ctrl; + struct rte_eth_dev *dev; + + dev = hw->eth_dev; + + /* Disabling queues just in case... */ + nfp_net_disable_queues(dev); + + /* Enabling the required queues in the device */ + nfp_net_enable_queues(dev); + + /* Writing configuration parameters in the device */ + nfp_net_params_setup(hw); + + new_ctrl = NFP_NET_CFG_CTRL_ENABLE; + update = NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING | + NFP_NET_CFG_UPDATE_MSIX; + + rte_wmb(); + + /* If an error when reconfig we avoid to change hw state */ + ret = nfp_net_reconfig(hw, new_ctrl, update); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Failed to reconfig ctrl vnic"); + return -EIO; + } + + hw->ctrl = new_ctrl; + + /* Setup the freelist ring */ + ret = nfp_net_rx_freelist_setup(dev); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Error with flower ctrl vNIC freelist setup"); + return -EIO; + } + + return 0; +} + +static int nfp_flower_pf_vnic_service(void *arg) { int ret; @@ -515,6 +691,32 @@ } static int +nfp_flower_ctrl_vnic_service(void *arg) +{ + int ret; + struct nfp_app_fw_flower *app_fw_flower = arg; + + ret = nfp_flower_init_ctrl_vnic(app_fw_flower->ctrl_hw); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Could not initialize flower ctrl vNIC"); + goto ctrl_vnic_cleanup; + } + + ret = nfp_flower_start_ctrl_vnic(app_fw_flower->ctrl_hw); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Could not start flower ctrl vNIC"); + goto ctrl_vnic_cleanup; + } + + return 0; + +ctrl_vnic_cleanup: + nfp_flower_cleanup_ctrl_vnic(app_fw_flower->ctrl_hw); + + return ret; +} + +static int nfp_flower_enable_pf_vnic_service(struct nfp_app_fw_flower *app_fw_flower) { int ret; @@ -546,12 +748,45 @@ return 0; } +static int +nfp_flower_enable_ctrl_vnic_service(struct nfp_app_fw_flower *app_fw_flower) +{ + int ret; + uint32_t service_id; + struct rte_service_spec ctrl_vnic_service = { + .name = "flower_ctrl_vnic_service", + .callback = nfp_flower_ctrl_vnic_service, + }; + + /* Pass a pointer to the flower app to the service */ + ctrl_vnic_service.callback_userdata = (void *)app_fw_flower; + + /* Register the flower services */ + ret = rte_service_component_register(&ctrl_vnic_service, &service_id); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Could not register flower ctrl vnic service"); + return -EINVAL; + } + + PMD_INIT_LOG(INFO, "Flower ctrl vnic service registered"); + + /* Map them to available service cores*/ + ret = nfp_map_service(service_id); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Could not map flower ctrl vnic service"); + return -EINVAL; + } + + return 0; +} + int nfp_init_app_fw_flower(struct nfp_pf_dev *pf_dev) { int ret; unsigned int numa_node; struct nfp_net_hw *pf_hw; + struct nfp_net_hw *ctrl_hw; struct nfp_app_fw_flower *app_fw_flower; numa_node = rte_socket_id(); @@ -597,6 +832,31 @@ pf_hw->pf_dev = pf_dev; pf_hw->cpp = pf_dev->cpp; + /* The ctrl vNIC struct comes directly after the PF one */ + app_fw_flower->ctrl_hw = pf_hw + 1; + ctrl_hw = app_fw_flower->ctrl_hw; + + /* Map the ctrl vNIC ctrl bar */ + ctrl_hw->ctrl_bar = nfp_rtsym_map(pf_dev->sym_tbl, "_pf0_net_ctrl_bar", + 32768, &ctrl_hw->ctrl_area); + if (ctrl_hw->ctrl_bar == NULL) { + PMD_INIT_LOG(ERR, "Cloud not map the ctrl vNIC ctrl bar"); + ret = -ENODEV; + goto pf_cpp_area_cleanup; + } + + /* Now populate the ctrl vNIC */ + ctrl_hw->pf_dev = pf_dev; + ctrl_hw->cpp = pf_dev->cpp; + + /* Start up flower ctrl vnic service */ + ret = nfp_flower_enable_ctrl_vnic_service(app_fw_flower); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Enable nfp ctrl vnic service failed."); + ret = -EINVAL; + goto ctrl_cpp_area_cleanup; + } + /* Start up flower pf vnic service */ ret = nfp_flower_enable_pf_vnic_service(app_fw_flower); if (ret != 0) @@ -604,6 +864,10 @@ return 0; +ctrl_cpp_area_cleanup: + nfp_cpp_area_free(ctrl_hw->ctrl_area); +pf_cpp_area_cleanup: + nfp_cpp_area_free(pf_dev->ctrl_area); eth_tbl_cleanup: free(app_fw_flower->nfp_eth_table); vnic_cleanup: diff --git a/drivers/net/nfp/flower/nfp_flower.h b/drivers/net/nfp/flower/nfp_flower.h index 981d88d..e18703e 100644 --- a/drivers/net/nfp/flower/nfp_flower.h +++ b/drivers/net/nfp/flower/nfp_flower.h @@ -14,6 +14,12 @@ struct nfp_app_fw_flower { /* Pointer to the PF vNIC */ struct nfp_net_hw *pf_hw; + /* Pointer to a mempool for the ctrlvNIC */ + struct rte_mempool *ctrl_pktmbuf_pool; + + /* Pointer to the ctrl vNIC */ + struct nfp_net_hw *ctrl_hw; + /* the eth table as reported by firmware */ struct nfp_eth_table *nfp_eth_table; }; diff --git a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c index 08bc4e8..22c8bc4 100644 --- a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c +++ b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c @@ -91,7 +91,10 @@ * @refcnt: number of current users * @iomem: mapped IO memory */ +#define NFP_BAR_MIN 1 +#define NFP_BAR_MID 5 #define NFP_BAR_MAX 7 + struct nfp_bar { struct nfp_pcie_user *nfp; uint32_t barcfg; @@ -292,6 +295,7 @@ struct nfp_pcie_user { * BAR0.0: Reserved for General Mapping (for MSI-X access to PCIe SRAM) * * Halving PCItoCPPBars for primary and secondary processes. + * For CoreNIC firmware: * NFP PMD just requires two fixed slots, one for configuration BAR, * and another for accessing the hw queues. Another slot is needed * for setting the link up or down. Secondary processes do not need @@ -301,6 +305,9 @@ struct nfp_pcie_user { * supported. Due to this requirement and future extensions requiring * new slots per process, only one secondary process is supported by * now. + * For Flower firmware: + * NFP PMD need another fixed slots, used as the configureation BAR + * for ctrl vNIC. */ static int nfp_enable_bars(struct nfp_pcie_user *nfp) @@ -309,11 +316,11 @@ struct nfp_pcie_user { int x, start, end; if (rte_eal_process_type() == RTE_PROC_PRIMARY) { - start = 4; - end = 1; + start = NFP_BAR_MID; + end = NFP_BAR_MIN; } else { - start = 7; - end = 4; + start = NFP_BAR_MAX; + end = NFP_BAR_MID; } for (x = start; x > end; x--) { bar = &nfp->bar[x - 1]; @@ -341,11 +348,11 @@ struct nfp_pcie_user { int x, start, end; if (rte_eal_process_type() == RTE_PROC_PRIMARY) { - start = 4; - end = 1; + start = NFP_BAR_MID; + end = NFP_BAR_MIN; } else { - start = 7; - end = 4; + start = NFP_BAR_MAX; + end = NFP_BAR_MID; } for (x = start; x > end; x--) { bar = &nfp->bar[x - 1]; @@ -364,11 +371,11 @@ struct nfp_pcie_user { int x, start, end; if (rte_eal_process_type() == RTE_PROC_PRIMARY) { - start = 4; - end = 1; + start = NFP_BAR_MID; + end = NFP_BAR_MIN; } else { - start = 7; - end = 4; + start = NFP_BAR_MAX; + end = NFP_BAR_MID; } for (x = start; x > end; x--) { -- 1.8.3.1