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 EF4C9A0543; Fri, 12 Aug 2022 12:23:39 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 46C6642C29; Fri, 12 Aug 2022 12:22:59 +0200 (CEST) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2122.outbound.protection.outlook.com [40.107.100.122]) by mails.dpdk.org (Postfix) with ESMTP id 944CD42C39 for ; Fri, 12 Aug 2022 12:22:57 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ljMY/v9RDvZrmR7mNkkGm603hC4qkDcxB+2cayKGl+LiYSyvaILcVi3T1YBrwZp6MryCGSSXUpJSOXasH5xBkp3VBIzO7riX7dUeYAhe/PrOdiEq6vlZ7sSjYBJn7ANATW3wVIdIShdYuiGZKk/3a4h0Jidf399F/YLjp1b2zWwi7ZIH6mPMQJgcFhYMDve8tMtmaxmTSKLgSnPhxp0/7OmJ0LuDP5dPnbmoKwwegnpgRSo2DHrUyNo5kfOR1+r+p9DV2LeKD4PIrf/tUC/cZR7heLIypEryGHJEruGLD4sVHPLgB/utqL9ks0yYLaOgIN5N7z+NHu6hPQMpmpJf4Q== 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=iS7FH7IM/twmdZscXH5OCALELjQFdKhrzx1DB+8IhO4=; b=mjWtSAkQq589oZmSnMzUOB3IiPNdcPzxgkqlSc0uWrOU7Gk6ObrzDRZI7S1UPFxEHLvRgYMgRGYoEldyu80oNM/8yXBYItkOibmfJgxg6jW0lw2z/J6lKAx7UOU+/+LepvB+mfRC9WoyQka+l/z96sARbl2IVORpqbs8BeL0bL+bXryzbHyHoQK67u8w7gN1rSMfMJWmb3ckaiT5UOe9AVDwmdPqGYXi8dzlIFkY1n7iRJSnW15/G7lCntKrPBsGLKLXnAH+e41jL8S6VSthOxz97FlSPD63oGpDe7P1qZg71PUoNRXICYrpO7U++4NlJ2MNKgmsebjh1Et0u2SBAA== 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=iS7FH7IM/twmdZscXH5OCALELjQFdKhrzx1DB+8IhO4=; b=jdsSULjsOk/m2/A4U7Qn4n31ShA+ge7MbLLz4BvJo/jq6drLxp878VxDCHc4zGJ/1kQFYY2+wOjZXNkgbuUUrBtfSIpnS2GsCNKadj0wt9VkYCqMf+zLciK/grpG9d7/rqjbfqn7h1qsJHxznNXgLoK7f/E/KvlXgFUAWUz6NTA= 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 MN2PR13MB2624.namprd13.prod.outlook.com (2603:10b6:208:ed::10) 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 10:22:55 +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 10:22:55 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v7 07/12] net/nfp: add flower ctrl VNIC related logics Date: Fri, 12 Aug 2022 18:22:25 +0800 Message-Id: <1660299750-10668-8-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1660299750-10668-1-git-send-email-chaoyong.he@corigine.com> References: <1660299750-10668-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: BYAPR01CA0019.prod.exchangelabs.com (2603:10b6:a02:80::32) 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: 7de2086b-ae13-4819-30b6-08da7c4c9f2d X-MS-TrafficTypeDiagnostic: MN2PR13MB2624:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QTOTzRq5LRSEli2KlZaWDo+Hf/7Tk5TMIdxaVp6I1gfy6/Eye/FXlmkC7qJUwzcxk8xD4vGvJ3gN/Su1ruI6TWGlfWU56UJnv0aReodKVy58giDdYttDwxagMyTLPNPjOOOJ9k0b6n1CJf55/cI+MhfouKPWNzbkrL911elSa2NEMoeAk8lswDboit/UM+AJ9va99BZpCr7b5iBy2lLFjUvi50hTFLjpiAjbGAHDRvEAxVd0L5bg0PFj4uqMCovS1jFSYZiiugva0jrjzQHfqe8I3dV4IQypuugius8V5XQT4Ge0NrB5Hnyk0V+5BoobvuvUKokAu0ONF/3D+2P8SB1+cl0RW79rzrwBf38rfQVsxJ+8gyqbGbVheHgchg7k0F+vH6sYMYhwkep79RqOZ7J3z1Yvvri2r3D2YdmV5ioPV7nQXaJbrXJkTinaOKEjhNOuwZqLzohXpPsTngg/rmNH2Y7UlLIJvSPTD2/HkyEan/yo2RnyLgpoXtS+ETrE9nRuPvrFNJHwVYq1CENi1kqEK4RS9qGfdJEnN+1bkT4wOwxOjtjoWz9qhKinj9r2ghioc1tSM1NWdA+yy+KWR2b9sp7WoPQZkqxrbY6B+TyNruIyaxXnAicsVLK6GaBqJZhEVnk2PArHJ7GtgRMcc1R7BevgtZRI7cxKMPh74BXddTisHUZwdaRgPIZ/K22ncyd+IMXzG3huRN/Wv4+mpl1RC7QR1N6bR6jy0Cd6MImItdFaGEk8furfdSa806iKc4GizPT7171FkyDKnpcXQLKRJlJoL14XSMA845g2ALY= 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)(366004)(396003)(346002)(39840400004)(376002)(136003)(52116002)(41300700001)(6916009)(316002)(26005)(478600001)(6486002)(6512007)(186003)(6666004)(36756003)(83380400001)(5660300002)(66574015)(2616005)(107886003)(6506007)(66476007)(8676002)(4326008)(66556008)(66946007)(30864003)(44832011)(86362001)(2906002)(8936002)(38100700002)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?dFlsSGk1OVBRUSt0TE5ZSnVMOXhMOWowaVV2MVNGQ05NZXJtUzBKYlBRYTR3?= =?utf-8?B?bDl4a04vNlZnRWdIWGZERW5xdUY1UWdldmhLZWdtVkllQi80TEhYN1AyZTc4?= =?utf-8?B?MHpWL0NMUTNjR0s1akEyZDVHQ0k5Q2E2Z1JhYXRYcEErZ1FTYzV3aDdTTXJV?= =?utf-8?B?eElSQ0xXSm4xRUJ5WDhtbi9BRkI2YXVSNWVBY2NqRSt6ODRad2Y5dUNUSEYw?= =?utf-8?B?YlZhajdwYWErUHpCVmZiYkd4a1hKbk1nL3hCQnFabytaZEhiWmFLTlBxZnVr?= =?utf-8?B?b3FYQW1Qd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mNPMEpadFBTdWtIUE9IcGtl?= =?utf-8?B?NkFPQTBNOEJFQkdmT0h4Y0lYaHl3d0pUcWhJTyszbCt5Rzk0eVpZTW9OOHZm?= =?utf-8?B?Y2c9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7de2086b-ae13-4819-30b6-08da7c4c9f2d X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2022 10:22:55.6869 (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: 4FimD0padr32xxywHjcgeaD2yLTYQo/85rlg4HEYVTH22MuacfgOEkgKJ+JdLv9sl6wkKYNkk+z5rjBiql0lqxYUA6e0D5HUXQaI6MbpEXs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR13MB2624 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 | 217 ++++++++++++++++++++++++++++- drivers/net/nfp/flower/nfp_flower.h | 6 + drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c | 31 +++-- 3 files changed, 239 insertions(+), 15 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index 43d4667..c9a4d50 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -27,6 +27,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, @@ -206,6 +207,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 struct rte_service_spec flower_services[NFP_FLOWER_SERVICE_MAX] = { }; @@ -504,6 +510,132 @@ return ret; } +static void +nfp_flower_cleanup_ctrl_vnic(struct nfp_net_hw *hw) +{ + uint32_t i; + struct nfp_app_flower *app_flower; + + app_flower = nfp_app_flower_priv_get(hw->pf_dev); + + 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_flower->ctrl_pktmbuf_pool); + rte_eth_dev_release_port(hw->eth_dev); +} + +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_flower *app_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_flower = nfp_app_flower_priv_get(pf_dev); + + 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_flower->ctrl_pktmbuf_pool = rte_pktmbuf_pool_create("ctrl_mbuf_pool", + 4 * CTRL_VNIC_NB_DESC, 64, 0, 9216, numa_node); + if (app_flower->ctrl_pktmbuf_pool == NULL) { + PMD_INIT_LOG(ERR, "create mbuf pool for ctrl vnic failed"); + ret = -ENOMEM; + goto port_release; + } + + mp = app_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 int nfp_flower_start_pf_vnic(struct nfp_net_hw *hw) { @@ -522,12 +654,57 @@ return 0; } +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; +} + 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_net_hw *ctrl_hw; struct nfp_app_flower *app_flower; numa_node = rte_socket_id(); @@ -573,30 +750,64 @@ pf_hw->pf_dev = pf_dev; pf_hw->cpp = pf_dev->cpp; + /* The ctrl vNIC struct comes directly after the PF one */ + app_flower->ctrl_hw = pf_hw + 1; + ctrl_hw = app_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; + ret = nfp_flower_init_pf_vnic(app_flower->pf_hw); if (ret != 0) { PMD_INIT_LOG(ERR, "Could not initialize flower PF vNIC"); - goto pf_cpp_area_cleanup; + goto ctrl_cpp_area_cleanup; + } + + ret = nfp_flower_init_ctrl_vnic(app_flower->ctrl_hw); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Could not initialize flower ctrl vNIC"); + goto pf_vnic_cleanup; } /* Start the PF vNIC */ ret = nfp_flower_start_pf_vnic(app_flower->pf_hw); if (ret != 0) { PMD_INIT_LOG(ERR, "Could not start flower PF vNIC"); - goto pf_vnic_cleanup; + goto ctrl_vnic_cleanup; + } + + /* Start the ctrl vNIC */ + ret = nfp_flower_start_ctrl_vnic(app_flower->ctrl_hw); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Could not start flower ctrl vNIC"); + goto ctrl_vnic_cleanup; } /* Start up flower services */ ret = nfp_flower_enable_services(app_flower); if (ret != 0) { ret = -ESRCH; - goto pf_vnic_cleanup; + goto ctrl_vnic_cleanup; } return 0; +ctrl_vnic_cleanup: + nfp_flower_cleanup_ctrl_vnic(app_flower->ctrl_hw); pf_vnic_cleanup: nfp_flower_cleanup_pf_vnic(app_flower->pf_hw); +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: diff --git a/drivers/net/nfp/flower/nfp_flower.h b/drivers/net/nfp/flower/nfp_flower.h index f6fd4eb..f11ef6d 100644 --- a/drivers/net/nfp/flower/nfp_flower.h +++ b/drivers/net/nfp/flower/nfp_flower.h @@ -21,6 +21,12 @@ struct nfp_app_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