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 4A9A142F41 for ; Tue, 25 Jul 2023 08:52:15 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2DFA840A7F; Tue, 25 Jul 2023 08:52:15 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2126.outbound.protection.outlook.com [40.107.237.126]) by mails.dpdk.org (Postfix) with ESMTP id AA37540697 for ; Tue, 25 Jul 2023 08:52:13 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bi2YDKHWYiVCuQUQ89hPrrpA6zT4v1loWSs53WWu3CnegDjCMI/ELqix6uf+1huhKJKQXQSv96JrzFCJYIoBXs4TfbtlIGH/5H/HUX8jwhMGLgSkf8q334V+4z3x4LKKDtTDuDBf0Gr5ow+6rvvHugPpaTaufb7OOUOIeH1zHG6wYrSF80X4fC0wdN6ma3llIf2JExPXm0qJPm9/g+l9JPq/RLscl7FRVfKZFxtH5CpwRemMCSojLo508xILToY4UYtgYqTVi72n/nqh2g8/NkPq1WaJ1uNqbfSLvYBcakWkafogyMAMS8zaGKmfY8mIjTj8HPLdO24BftfDN8bc/A== 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=4KNrk3r5fJfUbf6/BccXa0ipGM0MrUW/qL+VYme2iY0=; b=kJIHvXklVZuSHf1u1Ervx2YSXqdFUm0pcOSVATC4EpS2YLJHt9ifNTAD96N2a0a8k/DWSKCxqe83qEeApvVRukU3Il9dGSg/W/Gn2mLiGRkWPp0kuPSe+9LNpR2gOEyT46rYwgPgFvRsqhhL99VcdvGW8xJxTHAMH3iPZaUnQKhCjqwXTquYidkeFdfYMxwOPZ1UH+1QQEY8D2WnDq2J70wRcBVsjzaWntNVhBl+YbIZYkmp+0xOVssPl19L0YRjOiJptlN6yTGvimSYj1ilqFoSR4ZcOzKcRr9ZC4A5+SvYOes9dnxPiPSEoYev/EakwXXF9+5tjDRegVpjjA+zeg== 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=4KNrk3r5fJfUbf6/BccXa0ipGM0MrUW/qL+VYme2iY0=; b=UpNoIBic6j1ACQzoDHfkvjU+h+f7GR/sk6GO1Rr/pdqoIvcezNQVmUYNN8UJm91z4z83yjZfv4mVpUWnhDTJeOYfIFBJLCEp8uE45tuX+QOJ89d74mIVZZMH9i55ghCFUPl1AeHQQ0S/R0bSl3S2tSqEABqNplr53zQjlbC0WVA= 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 DM6PR13MB3723.namprd13.prod.outlook.com (2603:10b6:5:246::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Tue, 25 Jul 2023 06:52:10 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::cb32:34c9:7242:7748]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::cb32:34c9:7242:7748%4]) with mapi id 15.20.6609.031; Tue, 25 Jul 2023 06:52:10 +0000 From: Chaoyong He To: stable@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH 21.11] net/nfp: fix offloading flows Date: Tue, 25 Jul 2023 14:51:42 +0800 Message-Id: <20230725065143.425037-1-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2PR02CA0125.apcprd02.prod.outlook.com (2603:1096:4:188::13) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|DM6PR13MB3723:EE_ X-MS-Office365-Filtering-Correlation-Id: 42325f55-aa4c-408a-9d72-08db8cdbab02 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DQhG13ZTTbQd32PIw2WzNoouUf1S1aPdC5yF1BJuO27u/IFGqIpKAfsicjjO18mNb++r9zAONt8M/FepGCvw7gmQrke2qNyAEzpl/u/Rw6DFr1IzBE6RYwAM+hTR7lUivjtHFJcF9mVTf91pUl/g1GnJXRuXtWNqFxXAS7XFyANF8kZ+xnTP2iuL15mqdmPs3V23KAFNH7+kfWD5VDCGqBJ0ynATOfCSUfViQjJ5irlvQMcxwLdS9daGQERLAPqrH55h/n087BYCD9R8UusVzNo4HN7GFRVLVK2Q0e2rrTNvg+5WdKMTKA7MOgjAH6iOIrLcXHT6e6I2THgRNU16yNFJJEFS+Er944/vA6JRZIPtNhhn4Gk7tWNeMgUFaGBZtiuASiW2gHR2JZgW/0CL8qS5dIq+d9OuhoPxNFZShnqaiNjgC0LeF7SgoSZg9DY6LQEYW4TTAifd25/zJIwL5Q4sQROYv0HOBrVEhIdD8LJo9su+JOlSc2rOXxdKBmDkghtUna7/t7+tz288I2YvN3l1ylm1vNMjrCD7BqjlAr1DUbwep0v9hGsfYV8wLyeYlRP4KgMIMC00rkseGVM8Yz+gbkatxpyVT/9yhYnW9AoNcFYPseJ/XSiJmMB+QjOnukd4K89/EOzcbZj4LsAQ5eb115er+Q8zfv6kNAO4ckQ= 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:(13230028)(4636009)(396003)(366004)(136003)(376002)(39840400004)(346002)(451199021)(52116002)(6666004)(6486002)(6512007)(478600001)(1076003)(2616005)(186003)(107886003)(36756003)(6506007)(26005)(44832011)(2906002)(41300700001)(66946007)(6916009)(8936002)(4326008)(5660300002)(38350700002)(316002)(8676002)(66556008)(66476007)(38100700002)(86362001)(83380400001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?udwKCPvuNxdp28+P17aL51cfodw75psmzsF8ANA0MS4KwLz/Cxgyg/BWWt+l?= =?us-ascii?Q?7Fhu40OPhNVIG5V3VtXewZps1HkaJySC0M8EgT1qX/woyskQWyO1USDWLVl+?= =?us-ascii?Q?Sy7w7cwm8NpNaAPTY2EEzOgDX/fS6zmfTDXQyp4PoykgP2zh5SvZOXp1QSyP?= =?us-ascii?Q?28jW6zYA/WkMBkBbuvwsDPTHkZAT58Ei7F3S2Z83TmeEFY/zdYOznAHFg1m5?= =?us-ascii?Q?k2uIG6KQ9BxezJVP/hS8ZY9wGuzs0JoRTYP7UTSpuNMGfVYxYDJVb2gbht22?= =?us-ascii?Q?zOTi4iMKMPHsYqeugEbYmTPZkpqJPWDGaJ/AEFa8V/5pKbQSJpxugVfJn4n3?= =?us-ascii?Q?oKK5mPiE+XweSOI4jkEpe/+soeEp3mwbKrtPgxMZb7GMdu7U00dNUEZXMVZH?= =?us-ascii?Q?ANKrlTO+hs3Z1BdkgIa4vvkFco7ln5SdVj/k5g9zkSyR4/85y3ILPxgAh5ht?= =?us-ascii?Q?4aj2Ti7i0qPUN3cyfVudFnm6WngcmTyq4JWVznZgti3N431F0GvETPy0k1S4?= =?us-ascii?Q?xPYjUW2je2Q1kWqHECcPJa57LNgrX0CZpIfJw3n5Xf9KFc79535YkPH7LJ/4?= =?us-ascii?Q?WP9LyoY2lpka5gS/SuF66H/Xa1JZjgUy58/8fUyzcG1YWFADrlOwemmOUS4x?= =?us-ascii?Q?7d8KfQ4owzBJzY3tBo/PpeME06PjViEI69ChB+Un6IHCGyPWoSLf5Yw6p7h6?= =?us-ascii?Q?0j7ozmRdFX54YWAKn6e3G9kI+61WJtHMFBdUwB/1i6djBtWwD1bi8FUcEI/Q?= =?us-ascii?Q?boXwG465InfV5vSpi/8lMboQjWLIx0/YtdABSmWNtFtvU3ucrvoDtN/6L8vy?= =?us-ascii?Q?62a+wwk4yd2gPPrc26cBMzd4wV+HeJTY+Cd9VdYn4xSA65OgeUMmSmvoHa83?= =?us-ascii?Q?snl1pOd7maEDzjbQe60cUwrSVGcIx1zH5VnFnqwBIRHsk6blXtrPn7tiO27l?= =?us-ascii?Q?tLnVSMPRmtFYILu7IgamwUADY3N3YO6hWKSs3NzGexfSJwnqOPmHmo0s+jqA?= =?us-ascii?Q?nILcFlNMvjAfNYAb06pE1y61OmtIwyt5j5yjrQYFMkIMWPE6Gvp4Uwi1nRme?= =?us-ascii?Q?Py5wf56ZFOrFeQBJfhEIUPBvO7p3FJfzgsR8ycP1NAOgcc/u20uPTK5TyHpD?= =?us-ascii?Q?b/CWo+Npw8ohdMERdspNlNLAH9QAtCeP6SDom6tv2xOh0+ne/EMH2CrjZCrx?= =?us-ascii?Q?co8Bh4ON2mkqB95jEQETL71qCM+NSKwpEjrN2XSFgydVkjSY82Xs1ocPnFrj?= =?us-ascii?Q?Un1HTpNA7Zd/WG6DBLcEwDO/1zY3JB5pUgxBW/d4KxmSGknM0UEptLmNnXZJ?= =?us-ascii?Q?fHdsIXeb0VIOsjEfscnR++fu3toBD/TdSzqpp3Mza6YKYVqPfkkxx3Hi6mM9?= =?us-ascii?Q?Iw2ThA72Mu16E8WQIpk65JQo4ZtkFW9dAxm+ceWHI7RSo2zjw2SRF/vgJITZ?= =?us-ascii?Q?XuwP/LkYL8e6AxV065I7VhASdECRvEs/l8cJjQM55l3GxSUJbo/1+lTPl+0T?= =?us-ascii?Q?1wyBrQEcii81Gor2obwQhWGMBp93NWEFt+wE3/ZWsjaFtfSHQkVLUb7fj6Zl?= =?us-ascii?Q?FspaRl5BZUDAX3qTM6/1YFF/NNYCrrJkr3iXT6GCDA88rsikudGfhOE2pde/?= =?us-ascii?Q?lw=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 42325f55-aa4c-408a-9d72-08db8cdbab02 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2023 06:52:10.1017 (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: L9bTnGKSeDLokfiTTWEQhatTanrWw7aLoxY3J2ANW50i35KgIt79HyOjuLIYjBDZbbZSwFpYdZ9epcszlAcCyKfYUrso4xMtJhb1PLMlUro= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR13MB3723 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org [ upstream commit 925c27ec8de92efe69f4cb56e3fc0e413354c739 ] The symbol '_abi_flower_extra_features' is in IMEM for NFP4000, but in EMU_CACHE for NFP3800 because which does not have IMEM. The original logic can't read symbol from EMU_CACHE, so the probe process will fail when we try to offload flows use NFP3800. Modify the related data structure and logics to support read symbol from EMU_CACHE. Fixes: c7e9729da6b5 ("net/nfp: support CPP") Cc: stable@dpdk.org Signed-off-by: Chaoyong He --- drivers/net/nfp/nfp_ethdev.c | 4 +- drivers/net/nfp/nfpcore/nfp_cpp.h | 7 +- drivers/net/nfp/nfpcore/nfp_cppcore.c | 52 +++++++++--- drivers/net/nfp/nfpcore/nfp_rtsym.c | 117 ++++++++++++++++++++++++-- 4 files changed, 158 insertions(+), 22 deletions(-) diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 748bacff07..37593fd216 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -800,6 +800,7 @@ static int nfp_pf_init(struct rte_pci_device *pci_dev) { struct nfp_pf_dev *pf_dev = NULL; struct nfp_cpp *cpp; + uint32_t cpp_id; struct nfp_hwinfo *hwinfo; struct nfp_rtsym_table *sym_tbl; struct nfp_eth_table *nfp_eth_table = NULL; @@ -904,7 +905,8 @@ static int nfp_pf_init(struct rte_pci_device *pci_dev) PMD_INIT_LOG(DEBUG, "ctrl bar: %p", pf_dev->ctrl_bar); /* configure access to tx/rx vNIC BARs */ - pf_dev->hw_queues = nfp_cpp_map_area(pf_dev->cpp, 0, 0, + cpp_id = NFP_CPP_ISLAND_ID(0, NFP_CPP_ACTION_RW, 0, 0); + pf_dev->hw_queues = nfp_cpp_map_area(pf_dev->cpp, cpp_id, NFP_PCIE_QUEUE(0), NFP_QCP_QUEUE_AREA_SZ, &pf_dev->hwqueues_area); diff --git a/drivers/net/nfp/nfpcore/nfp_cpp.h b/drivers/net/nfp/nfpcore/nfp_cpp.h index 720d3989e6..61d36047e1 100644 --- a/drivers/net/nfp/nfpcore/nfp_cpp.h +++ b/drivers/net/nfp/nfpcore/nfp_cpp.h @@ -34,6 +34,9 @@ struct nfp_cpp { */ uint32_t imb_cat_table[16]; + /* MU access type bit offset */ + uint32_t mu_locality_lsb; + int driver_lock_needed; }; @@ -363,7 +366,7 @@ struct nfp_cpp_area *nfp_cpp_area_alloc_acquire(struct nfp_cpp *cpp, */ void nfp_cpp_area_release_free(struct nfp_cpp_area *area); -uint8_t *nfp_cpp_map_area(struct nfp_cpp *cpp, int domain, int target, +uint8_t *nfp_cpp_map_area(struct nfp_cpp *cpp, uint32_t cpp_id, uint64_t addr, unsigned long size, struct nfp_cpp_area **area); /* @@ -778,4 +781,6 @@ int nfp_cpp_mutex_unlock(struct nfp_cpp_mutex *mutex); */ int nfp_cpp_mutex_trylock(struct nfp_cpp_mutex *mutex); +uint32_t nfp_cpp_mu_locality_lsb(struct nfp_cpp *cpp); + #endif /* !__NFP_CPP_H__ */ diff --git a/drivers/net/nfp/nfpcore/nfp_cppcore.c b/drivers/net/nfp/nfpcore/nfp_cppcore.c index 37799af558..13d979633d 100644 --- a/drivers/net/nfp/nfpcore/nfp_cppcore.c +++ b/drivers/net/nfp/nfpcore/nfp_cppcore.c @@ -118,6 +118,36 @@ nfp_cpp_area_name(struct nfp_cpp_area *cpp_area) return cpp_area->name; } +#define NFP_IMB_TGTADDRESSMODECFG_MODE_of(_x) (((_x) >> 13) & 0x7) +#define NFP_IMB_TGTADDRESSMODECFG_ADDRMODE RTE_BIT32(12) + +static int +nfp_cpp_set_mu_locality_lsb(struct nfp_cpp *cpp) +{ + int ret; + int mode; + int addr40; + uint32_t imbcppat; + + imbcppat = cpp->imb_cat_table[NFP_CPP_TARGET_MU]; + mode = NFP_IMB_TGTADDRESSMODECFG_MODE_of(imbcppat); + addr40 = imbcppat & NFP_IMB_TGTADDRESSMODECFG_ADDRMODE; + + ret = nfp_cppat_mu_locality_lsb(mode, addr40); + if (ret < 0) + return ret; + + cpp->mu_locality_lsb = ret; + + return 0; +} + +uint32_t +nfp_cpp_mu_locality_lsb(struct nfp_cpp *cpp) +{ + return cpp->mu_locality_lsb; +} + /* * nfp_cpp_area_alloc - allocate a new CPP area * @cpp: CPP handle @@ -142,10 +172,6 @@ nfp_cpp_area_alloc_with_name(struct nfp_cpp *cpp, uint32_t dest, if (!cpp) return NULL; - /* CPP bus uses only a 40-bit address */ - if ((address + size) > (1ULL << 40)) - return NFP_ERRPTR(EFAULT); - /* Remap from cpp_island to cpp_target */ err = nfp_target_cpp(dest, tmp64, &dest, &tmp64, cpp->imb_cat_table); if (err < 0) @@ -588,6 +614,12 @@ nfp_cpp_alloc(struct rte_pci_device *dev, int driver_lock_needed) } } + err = nfp_cpp_set_mu_locality_lsb(cpp); + if (err < 0) { + free(cpp); + return NULL; + } + return cpp; } @@ -819,8 +851,7 @@ __nfp_cpp_model_autodetect(struct nfp_cpp *cpp, uint32_t *model) /* * nfp_cpp_map_area() - Helper function to map an area * @cpp: NFP CPP handler - * @domain: CPP domain - * @target: CPP target + * @cpp_id: CPP ID * @addr: CPP address * @size: Size of the area * @area: Area handle (output) @@ -831,16 +862,13 @@ __nfp_cpp_model_autodetect(struct nfp_cpp *cpp, uint32_t *model) * Return: Pointer to memory mapped area or ERR_PTR */ uint8_t * -nfp_cpp_map_area(struct nfp_cpp *cpp, int domain, int target, uint64_t addr, +nfp_cpp_map_area(struct nfp_cpp *cpp, uint32_t cpp_id, uint64_t addr, unsigned long size, struct nfp_cpp_area **area) { uint8_t *res; - uint32_t dest; - - dest = NFP_CPP_ISLAND_ID(target, NFP_CPP_ACTION_RW, 0, domain); - *area = nfp_cpp_area_alloc_acquire(cpp, dest, addr, size); - if (!*area) + *area = nfp_cpp_area_alloc_acquire(cpp, cpp_id, addr, size); + if (*area == NULL) goto err_eio; res = nfp_cpp_area_iomem(*area); diff --git a/drivers/net/nfp/nfpcore/nfp_rtsym.c b/drivers/net/nfp/nfpcore/nfp_rtsym.c index 2feca2ed81..2c6c639367 100644 --- a/drivers/net/nfp/nfpcore/nfp_rtsym.c +++ b/drivers/net/nfp/nfpcore/nfp_rtsym.c @@ -232,6 +232,102 @@ nfp_rtsym_lookup(struct nfp_rtsym_table *rtbl, const char *name) return NULL; } +static uint64_t +nfp_rtsym_size(const struct nfp_rtsym *sym) +{ + switch (sym->type) { + case NFP_RTSYM_TYPE_NONE: + return 0; + case NFP_RTSYM_TYPE_OBJECT: /* Fall through */ + case NFP_RTSYM_TYPE_FUNCTION: + return sym->size; + case NFP_RTSYM_TYPE_ABS: + return sizeof(uint64_t); + default: + return 0; + } +} + +static int +nfp_rtsym_to_dest(struct nfp_cpp *cpp, + const struct nfp_rtsym *sym, + uint8_t action, + uint8_t token, + uint64_t offset, + uint32_t *cpp_id, + uint64_t *addr) +{ + if (sym->type != NFP_RTSYM_TYPE_OBJECT) + return -EINVAL; + + *addr = sym->addr + offset; + + if (sym->target >= 0) { + *cpp_id = NFP_CPP_ISLAND_ID(sym->target, action, token, sym->domain); + } else if (sym->target == NFP_RTSYM_TARGET_EMU_CACHE) { + int locality_off = nfp_cpp_mu_locality_lsb(cpp); + + *addr &= ~(NFP_MU_ADDR_ACCESS_TYPE_MASK << locality_off); + *addr |= NFP_MU_ADDR_ACCESS_TYPE_DIRECT << locality_off; + + *cpp_id = NFP_CPP_ISLAND_ID(NFP_CPP_TARGET_MU, action, token, + sym->domain); + } else { + return -EINVAL; + } + + return 0; +} + +static int +nfp_rtsym_readl(struct nfp_cpp *cpp, + const struct nfp_rtsym *sym, + uint8_t action, + uint8_t token, + uint64_t offset, + uint32_t *value) +{ + int ret; + uint64_t addr; + uint32_t cpp_id; + + if (offset + 4 > nfp_rtsym_size(sym)) + return -ENXIO; + + ret = nfp_rtsym_to_dest(cpp, sym, action, token, offset, &cpp_id, &addr); + if (ret != 0) + return ret; + + return nfp_cpp_readl(cpp, cpp_id, addr, value); +} + +static int +nfp_rtsym_readq(struct nfp_cpp *cpp, + const struct nfp_rtsym *sym, + uint8_t action, + uint8_t token, + uint64_t offset, + uint64_t *value) +{ + int ret; + uint64_t addr; + uint32_t cpp_id; + + if (offset + 8 > nfp_rtsym_size(sym)) + return -ENXIO; + + if (sym->type == NFP_RTSYM_TYPE_ABS) { + *value = sym->addr; + return 0; + } + + ret = nfp_rtsym_to_dest(cpp, sym, action, token, offset, &cpp_id, &addr); + if (ret != 0) + return ret; + + return nfp_cpp_readq(cpp, cpp_id, addr, value); +} + /* * nfp_rtsym_read_le() - Read a simple unsigned scalar value from symbol * @rtbl: NFP RTsym table @@ -248,7 +344,7 @@ uint64_t nfp_rtsym_read_le(struct nfp_rtsym_table *rtbl, const char *name, int *error) { const struct nfp_rtsym *sym; - uint32_t val32, id; + uint32_t val32; uint64_t val; int err; @@ -258,19 +354,17 @@ nfp_rtsym_read_le(struct nfp_rtsym_table *rtbl, const char *name, int *error) goto exit; } - id = NFP_CPP_ISLAND_ID(sym->target, NFP_CPP_ACTION_RW, 0, sym->domain); - #ifdef DEBUG printf("Reading symbol %s with size %" PRIu64 " at %" PRIx64 "\n", name, sym->size, sym->addr); #endif switch (sym->size) { case 4: - err = nfp_cpp_readl(rtbl->cpp, id, sym->addr, &val32); + err = nfp_rtsym_readl(rtbl->cpp, sym, NFP_CPP_ACTION_RW, 0, 0, &val32); val = val32; break; case 8: - err = nfp_cpp_readq(rtbl->cpp, id, sym->addr, &val); + err = nfp_rtsym_readq(rtbl->cpp, sym, NFP_CPP_ACTION_RW, 0, 0, &val); break; default: printf("rtsym '%s' unsupported size: %" PRId64 "\n", @@ -295,8 +389,11 @@ uint8_t * nfp_rtsym_map(struct nfp_rtsym_table *rtbl, const char *name, unsigned int min_size, struct nfp_cpp_area **area) { - const struct nfp_rtsym *sym; + int ret; uint8_t *mem; + uint64_t addr; + uint32_t cpp_id; + const struct nfp_rtsym *sym; #ifdef DEBUG printf("mapping symbol %s\n", name); @@ -307,14 +404,18 @@ nfp_rtsym_map(struct nfp_rtsym_table *rtbl, const char *name, return NULL; } + ret = nfp_rtsym_to_dest(rtbl->cpp, sym, NFP_CPP_ACTION_RW, 0, 0, + &cpp_id, &addr); + if (ret != 0) + return NULL; + if (sym->size < min_size) { printf("Symbol %s too small (%" PRIu64 " < %u)\n", name, sym->size, min_size); return NULL; } - mem = nfp_cpp_map_area(rtbl->cpp, sym->domain, sym->target, sym->addr, - sym->size, area); + mem = nfp_cpp_map_area(rtbl->cpp, cpp_id, addr, sym->size, area); if (!mem) { printf("Failed to map symbol %s\n", name); return NULL; -- 2.39.1