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 2558042600; Tue, 19 Sep 2023 11:58:09 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D40C6427E4; Tue, 19 Sep 2023 11:56:11 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2113.outbound.protection.outlook.com [40.107.243.113]) by mails.dpdk.org (Postfix) with ESMTP id 4B45B41104 for ; Tue, 19 Sep 2023 11:56:10 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rp+Lqb06j3shevX6/ZbUlV+ypONdxKq3YRVkUVM52j3A63TM2g0iWQ8m3j7XcBd3yVfRqCZh74J+wJDa+i/xIubNtSOPkJWup2zX99GfW7NU0AYBWcMmnERa+dt06RVhVMb9OplIcUzm8Ih8Yd+MIk1vAY+Uug+h0qFU+YF5zO8e5sd/4Qsb89ECcxkmAzh1syX0NG+suj4w/8k06M/AXJ5BCMmgOmQfaLspI0kZTqbbH2JwSenh7DtOywSJ1/vpDc1rABjsRPGkfUCK5bgr2hZNxbYMoNWlnaLNhIIXwG1YdMgH/L+YSmtfnPfjboiIINyMbqCenCRBrSHNDAhMWQ== 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=z1W8RGbvRphu6ol/4bDEOO2oovSXr9ZXDjLoLcMR5qs=; b=d5MO5vv2bYbf1+ONVBlsbV2BI3mtoV8F3pzatybcx3PKo0H7XlM7KZXlz2TXRemXgQdCwN4XSnN4CPspKEXBXRuGRrW2hydQggmyWX9bwjjj9ziD4ZPL6EqeCRzeemj6EQzkWSe4qzLYwStt+txibO4/nbQf+ydHIhSViNVRHXm03b49uT95D7StOlN9aYLrRi9cj9WRc4XU+4jkCV1hnDdPy8+gcSMZ/cOKgG4xCXj41K7HwcEJz+blkZgE8wu2+1raljNK4fzmMQ8DyGZgiSy3An7PV9WFFb1W+Xn2+Sh3kcz19U9p4j7GrB7cLa4lM4ub8sxHVpuKYZpVJGCB1g== 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=z1W8RGbvRphu6ol/4bDEOO2oovSXr9ZXDjLoLcMR5qs=; b=ieCTwiI8lthUUbhF0oWQuQTK4vvNHNn49hti2iuGcDtwy1g3BuCw3JgfjtRlqqURlhZFkMsocE9fF/OjVP7cq5xnZQYmQFRuk82JIq5648riXsQo2khn2Q84mBomLgiNLY7AVDonpsZcWlqeMljYFciA69TH8Xwo09JsTLpVhGU= 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 MW5PR13MB5877.namprd13.prod.outlook.com (2603:10b6:303:1c7::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.28; Tue, 19 Sep 2023 09:55:58 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::7a1c:2887:348a:84bd]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::7a1c:2887:348a:84bd%6]) with mapi id 15.20.6792.026; Tue, 19 Sep 2023 09:55:58 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Chaoyong He Subject: [PATCH v5 24/26] net/nfp: refact the PCIe module Date: Tue, 19 Sep 2023 17:54:38 +0800 Message-Id: <20230919095440.45445-25-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230919095440.45445-1-chaoyong.he@corigine.com> References: <20230918024612.1600536-1-chaoyong.he@corigine.com> <20230919095440.45445-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: BY5PR04CA0014.namprd04.prod.outlook.com (2603:10b6:a03:1d0::24) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|MW5PR13MB5877:EE_ X-MS-Office365-Filtering-Correlation-Id: 50535de3-8e29-46e3-d2e3-08dbb8f69f8e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GMycC13Y5jf2w4YnG4bIwDG1UqOODuMixiyhY65RPI0y5C2EqNEJYYIX9gTmmwRkznTdEhH8YYOHvBnVL+VpOrw8xdqiKbYHRYuWLRzYqq3HzdOeOy3WBooloO4ehThe/7mU4jJBynKlzjWm3sNUrXez5DUSWXoP3JH1cVOuKO7fI/ITlL1QLnZnQJh3+pzpoLYYou+Fo/7CaDTwP/zZoxeKDYysxtyYf/+84923AGJ0Q3KHEdZFd1k8eHngwCr+hfNCMxSdZ+NSKp0rTA64swCHTe5FBFTNF3yBii2y6HIZwI4lr8MhHY+P9+kGDa+uY9s3Q4r9oMpfV7uJ4lLMZmoFiUuDBRxBFceiFtdCFea/lJkpkx7HN/csUBCKUxy+HEpQHXudplWqesPqamZnOZV0bWafzh3+/3ZJjGG13IzJ76Q8tT9crbGV+h5mjCaXlI176tFEDG+Ui0IEt/cXmkaS4vQo/wblPoTCUmkfxsov0aBCZeyN/fPXfvUXkfGubTZ9ATpdV0KPL7uaZ2Ugfz9/SZUnaoh9qZrBe6mkboWEx1ILZZ0VFNAvlq7KIZG8Lsz4X4Vsun3tBWhYDxgvq7gInaeZxSwtSx6YJNOId5JyQ+55XIbaVQ4yUfEza2bCsivhyAHFevrGFJnq45bVJN2Am5/Ssa34W3wNQBumZa4= 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)(136003)(396003)(39840400004)(366004)(376002)(186009)(451199024)(1800799009)(6506007)(6486002)(6666004)(52116002)(86362001)(36756003)(38350700002)(38100700002)(2616005)(1076003)(107886003)(26005)(2906002)(6512007)(478600001)(83380400001)(8676002)(5660300002)(4326008)(41300700001)(8936002)(44832011)(66946007)(66556008)(66476007)(6916009)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?7P2OqXfDcBaFJ7vXnHLMdz99BS1IKseLGpQCbTJQDh3PhnthIjkEtCoqAORu?= =?us-ascii?Q?khPFY5wSHtJ0qazPxUeR8WAcetDrIFw50Cw9YDVm05AhV0kvjldWDgtktz4H?= =?us-ascii?Q?Mw5lMgRK895P+BK22ac4xCDIzOuH5OMp1Ae0cR9LbF5zNvAwY54DFqPqt0y/?= =?us-ascii?Q?ibiykUUlJt5sej3+Kx9K4Zx2zoMwUWgNL7wxD+0BegFfxVy1Voeopgi3QoRS?= =?us-ascii?Q?sVg1hjEI+LhoBaHOOZKQb6lZOX+6mp/4G0NncpmlUYHayi8Ggrlvuv8pmiH+?= =?us-ascii?Q?X1zilZ9L44B4xSJRAADFxIIZtuvLgkytPK6785PrE6K/j1vZdprURsO/0Lzp?= =?us-ascii?Q?7rlc7vZ6xM04LfFgnwIda1lBVWrdjhIJ7jYEoriHdg+6HOB+AQlCUr422pwc?= =?us-ascii?Q?QJrs7YRH0xgTXCPwVMwG0vR+P4x4ozBaToIqMqHpUzJS0lKqpSlo80O6wv03?= =?us-ascii?Q?8ER0Wj8PHnJSPZOCPfgJYrRO9Moxm7DfWsXr1mk2aJJyZkYKqFGxZDA7CzHA?= =?us-ascii?Q?NOAiVVIyYVDXepGl627Qt4LKidNsB24u6CMyqcbht8OyTZAR/ZoPdlHxrm35?= =?us-ascii?Q?JeBnfbMJYnjL9JGsLMqljU36a3jNwhfYe4HOoWfL3bZHkc/u404dHaAxWAk9?= =?us-ascii?Q?N8RReru5O2xSlTAMBu8l0SvFZnq3AMKFrfP4SAnTgPDTdMZ2hL4efZQj63r/?= =?us-ascii?Q?0Zgbs5epdvfmxitGeSQzH6IBbAsUeH6nYT5Td9Hv6ZXr7AHKEcGDXu9kJk66?= =?us-ascii?Q?HNL71OK53vPuWuk9Y3ZOrEIqicMi0OlirebDs4HpPjcIPryeFCbk7JdfnXiK?= =?us-ascii?Q?/7AL8JYEGAeIOAmofLCBgsa61eBjqrzpMTJ+1p9kuCk/2gWkJMSA3e8awsRB?= =?us-ascii?Q?X/IL4Rpjpp2M6tvALQXRRh8R6xjaEx328mgCIW4s0B6raqH3jE/Ok5PJCJ5U?= =?us-ascii?Q?BPfwg4vmbVZooZrblaxjVKjHim9py0s+wr90RUW65ZLGSfI6JbikSrJ4lvtB?= =?us-ascii?Q?S3ujrGqIcksSzxJgZV7De16Fp17hakTsT3rCyr4a/xxPBlQy0Z7G+RRPrGWh?= =?us-ascii?Q?T/Kg9QQTjR9W9y0MF+iupilAFYjrgoRYKTlt4vGP1Hfz4w1vh+Ykl9K4AzwD?= =?us-ascii?Q?QfHDkC4kkYeEEr4/pzm5iRlRsoyWSoYO+giIxQGDFhSh6reC0L6sS5TDtrpP?= =?us-ascii?Q?/66x27X4yRj8ByPqzwETBAdbTJJxntCWf1nIaQlh+z4/qEUO0xge5D5ZmNJv?= =?us-ascii?Q?2uYhZucZG4tZH4cjZ19NwBVMay9W7QOuVFY7C1s5sldojlAuuRHMgi3WCFic?= =?us-ascii?Q?xh/LrDoa0vSqw1aad3r1YH1GQdQEQmbawmPBWen4IrMQ39XGa76cWC5WVIEJ?= =?us-ascii?Q?M46MZ4UgT8/9znSE/ik7aMT2npd5egA46/9XLkwWrC+j4rtLgI18ArYoes4M?= =?us-ascii?Q?uPiaWh4RduSW1Xv47QLpbo8Q9sYmoROR5w/X5Y8OAIa36D8v7ufdImEmnBRS?= =?us-ascii?Q?TUsxiQCjl7mLu0yCyFSkph9PFxAFfmpXGTy6F80FQ154kMKYhdIQez2Avv9G?= =?us-ascii?Q?ao1NtLA4xW2dPcx69dvLOXFwg/VHn+1nwW6KrUjoirBzJ4jV7qoyCAquNWS1?= =?us-ascii?Q?jQ=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 50535de3-8e29-46e3-d2e3-08dbb8f69f8e X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2023 09:55:58.4185 (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: km/VjDXRPA8C/q80wUTQHt/qkLdysoXRJ4Xct3SNVn5BuZnAjhnZYnneW9hJpYb1IbCIGLn0Antpotv134MDV1XTorJJ6axaDHGGTKgu8ps= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR13MB5877 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 Sync the logic from kernel driver and remove the unneeded header file include statements. Signed-off-by: Chaoyong He --- drivers/net/nfp/nfpcore/nfp6000_pcie.c | 211 +++++++++++++++++-------- drivers/net/nfp/nfpcore/nfp_cpp.h | 9 ++ 2 files changed, 150 insertions(+), 70 deletions(-) diff --git a/drivers/net/nfp/nfpcore/nfp6000_pcie.c b/drivers/net/nfp/nfpcore/nfp6000_pcie.c index 45645e04f8..4f453f19a9 100644 --- a/drivers/net/nfp/nfpcore/nfp6000_pcie.c +++ b/drivers/net/nfp/nfpcore/nfp6000_pcie.c @@ -16,23 +16,8 @@ #include "nfp6000_pcie.h" -#include -#include -#include #include -#include -#include #include -#include -#include -#include -#include - -#include -#include -#include - -#include #include "nfp_cpp.h" #include "nfp_logs.h" @@ -43,8 +28,11 @@ #define NFP_PCIE_BAR(_pf) (0x30000 + ((_pf) & 7) * 0xc0) #define NFP_PCIE_BAR_PCIE2CPP_ACTION_BASEADDRESS(_x) (((_x) & 0x1f) << 16) +#define NFP_PCIE_BAR_PCIE2CPP_ACTION_BASEADDRESS_OF(_x) (((_x) >> 16) & 0x1f) #define NFP_PCIE_BAR_PCIE2CPP_BASEADDRESS(_x) (((_x) & 0xffff) << 0) +#define NFP_PCIE_BAR_PCIE2CPP_BASEADDRESS_OF(_x) (((_x) >> 0) & 0xffff) #define NFP_PCIE_BAR_PCIE2CPP_LENGTHSELECT(_x) (((_x) & 0x3) << 27) +#define NFP_PCIE_BAR_PCIE2CPP_LENGTHSELECT_OF(_x) (((_x) >> 27) & 0x3) #define NFP_PCIE_BAR_PCIE2CPP_LENGTHSELECT_32BIT 0 #define NFP_PCIE_BAR_PCIE2CPP_LENGTHSELECT_64BIT 1 #define NFP_PCIE_BAR_PCIE2CPP_LENGTHSELECT_0BYTE 3 @@ -55,7 +43,9 @@ #define NFP_PCIE_BAR_PCIE2CPP_MAPTYPE_TARGET 2 #define NFP_PCIE_BAR_PCIE2CPP_MAPTYPE_GENERAL 3 #define NFP_PCIE_BAR_PCIE2CPP_TARGET_BASEADDRESS(_x) (((_x) & 0xf) << 23) +#define NFP_PCIE_BAR_PCIE2CPP_TARGET_BASEADDRESS_OF(_x) (((_x) >> 23) & 0xf) #define NFP_PCIE_BAR_PCIE2CPP_TOKEN_BASEADDRESS(_x) (((_x) & 0x3) << 21) +#define NFP_PCIE_BAR_PCIE2CPP_TOKEN_BASEADDRESS_OF(_x) (((_x) >> 21) & 0x3) /* * Minimal size of the PCIe cfg memory we depend on being mapped, @@ -132,7 +122,7 @@ nfp_compute_bar(const struct nfp_bar *bar, uint32_t newcfg; uint32_t bitsize; - if (target >= 16) + if (target >= NFP_CPP_NUM_TARGETS) return -EINVAL; switch (width) { @@ -182,10 +172,6 @@ nfp_compute_bar(const struct nfp_bar *bar, offset &= mask; bitsize = 40 - 21; } - - if (bar->bitsize < bitsize) - return -EINVAL; - newcfg |= offset >> bitsize; if (bar_base != NULL) @@ -434,7 +420,7 @@ nfp6000_area_acquire(struct nfp_cpp_area *area) /* Must have been too big. Sub-allocate. */ if (priv->bar->iomem == NULL) - return (-ENOMEM); + return -ENOMEM; priv->iomem = priv->bar->iomem + priv->bar_offset; @@ -464,9 +450,9 @@ nfp6000_area_read(struct nfp_cpp_area *area, uint32_t offset, size_t length) { + int ret; size_t n; int width; - bool is_64; uint32_t *wrptr32 = address; uint64_t *wrptr64 = address; struct nfp6000_area_priv *priv; @@ -484,47 +470,54 @@ nfp6000_area_read(struct nfp_cpp_area *area, if (width <= 0) return -EINVAL; + /* MU reads via a PCIe2CPP BAR support 32bit (and other) lengths */ + if (priv->target == (NFP_CPP_TARGET_MU & NFP_CPP_TARGET_ID_MASK) && + priv->action == NFP_CPP_ACTION_RW && + (offset % sizeof(uint64_t) == 4 || + length % sizeof(uint64_t) == 4)) + width = TARGET_WIDTH_32; + /* Unaligned? Translate to an explicit access */ if (((priv->offset + offset) & (width - 1)) != 0) { PMD_DRV_LOG(ERR, "aread_read unaligned!!!"); return -EINVAL; } - is_64 = width == TARGET_WIDTH_64; - - /* MU reads via a PCIe2CPP BAR supports 32bit (and other) lengths */ - if (priv->target == (NFP_CPP_TARGET_ID_MASK & NFP_CPP_TARGET_MU) && - priv->action == NFP_CPP_ACTION_RW) { - is_64 = false; - } + if (priv->bar == NULL) + return -EFAULT; - if (is_64) { - if (offset % sizeof(uint64_t) != 0 || - length % sizeof(uint64_t) != 0) - return -EINVAL; - } else { + switch (width) { + case TARGET_WIDTH_32: if (offset % sizeof(uint32_t) != 0 || length % sizeof(uint32_t) != 0) return -EINVAL; - } - if (priv->bar == NULL) - return -EFAULT; + for (n = 0; n < length; n += sizeof(uint32_t)) { + *wrptr32 = *rdptr32; + wrptr32++; + rdptr32++; + } + + ret = n; + break; + case TARGET_WIDTH_64: + if (offset % sizeof(uint64_t) != 0 || + length % sizeof(uint64_t) != 0) + return -EINVAL; - if (is_64) for (n = 0; n < length; n += sizeof(uint64_t)) { *wrptr64 = *rdptr64; wrptr64++; rdptr64++; } - else - for (n = 0; n < length; n += sizeof(uint32_t)) { - *wrptr32 = *rdptr32; - wrptr32++; - rdptr32++; - } - return n; + ret = n; + break; + default: + return -EINVAL; + } + + return ret; } static int @@ -533,9 +526,9 @@ nfp6000_area_write(struct nfp_cpp_area *area, uint32_t offset, size_t length) { + int ret; size_t n; int width; - bool is_64; uint32_t *wrptr32; uint64_t *wrptr64; struct nfp6000_area_priv *priv; @@ -553,47 +546,53 @@ nfp6000_area_write(struct nfp_cpp_area *area, if (width <= 0) return -EINVAL; + /* MU reads via a PCIe2CPP BAR support 32bit (and other) lengths */ + if (priv->target == (NFP_CPP_TARGET_MU & NFP_CPP_TARGET_ID_MASK) && + priv->action == NFP_CPP_ACTION_RW && + (offset % sizeof(uint64_t) == 4 || + length % sizeof(uint64_t) == 4)) + width = TARGET_WIDTH_32; + /* Unaligned? Translate to an explicit access */ if (((priv->offset + offset) & (width - 1)) != 0) return -EINVAL; - is_64 = width == TARGET_WIDTH_64; - - /* MU writes via a PCIe2CPP BAR supports 32bit (and other) lengths */ - if (priv->target == (NFP_CPP_TARGET_ID_MASK & NFP_CPP_TARGET_MU) && - priv->action == NFP_CPP_ACTION_RW) - is_64 = false; + if (priv->bar == NULL) + return -EFAULT; - if (is_64) { - if (offset % sizeof(uint64_t) != 0 || - length % sizeof(uint64_t) != 0) - return -EINVAL; - } else { + switch (width) { + case TARGET_WIDTH_32: if (offset % sizeof(uint32_t) != 0 || length % sizeof(uint32_t) != 0) return -EINVAL; - } - if (priv->bar == NULL) - return -EFAULT; + for (n = 0; n < length; n += sizeof(uint32_t)) { + *wrptr32 = *rdptr32; + wrptr32++; + rdptr32++; + } + + ret = n; + break; + case TARGET_WIDTH_64: + if (offset % sizeof(uint64_t) != 0 || + length % sizeof(uint64_t) != 0) + return -EINVAL; - if (is_64) for (n = 0; n < length; n += sizeof(uint64_t)) { *wrptr64 = *rdptr64; wrptr64++; rdptr64++; } - else - for (n = 0; n < length; n += sizeof(uint32_t)) { - *wrptr32 = *rdptr32; - wrptr32++; - rdptr32++; - } - return n; -} + ret = n; + break; + default: + return -EINVAL; + } -#define PCI_DEVICES "/sys/bus/pci/devices" + return ret; +} static int nfp_acquire_process_lock(struct nfp_pcie_user *desc) @@ -706,6 +705,74 @@ nfp6000_set_serial(struct rte_pci_device *dev, return 0; } +static int +nfp6000_get_dsn(struct rte_pci_device *pci_dev, + uint64_t *dsn) +{ + off_t pos; + size_t len; + uint64_t tmp = 0; + + pos = rte_pci_find_ext_capability(pci_dev, RTE_PCI_EXT_CAP_ID_DSN); + if (pos <= 0) { + PMD_DRV_LOG(ERR, "PCI_EXT_CAP_ID_DSN not found"); + return -ENODEV; + } + + pos += 4; + len = sizeof(tmp); + + if (rte_pci_read_config(pci_dev, &tmp, len, pos) < 0) { + PMD_DRV_LOG(ERR, "nfp get device serial number failed"); + return -ENOENT; + } + + *dsn = tmp; + + return 0; +} + +static int +nfp6000_get_interface(struct rte_pci_device *dev, + uint16_t *interface) +{ + int ret; + uint64_t dsn = 0; + + ret = nfp6000_get_dsn(dev, &dsn); + if (ret != 0) + return ret; + + *interface = dsn & 0xffff; + + return 0; +} + +static int +nfp6000_get_serial(struct rte_pci_device *dev, + uint8_t *serial, + size_t length) +{ + int ret; + uint64_t dsn = 0; + + if (length < NFP_SERIAL_LEN) + return -ENOMEM; + + ret = nfp6000_get_dsn(dev, &dsn); + if (ret != 0) + return ret; + + serial[0] = (dsn >> 56) & 0xff; + serial[1] = (dsn >> 48) & 0xff; + serial[2] = (dsn >> 40) & 0xff; + serial[3] = (dsn >> 32) & 0xff; + serial[4] = (dsn >> 24) & 0xff; + serial[5] = (dsn >> 16) & 0xff; + + return 0; +} + static int nfp6000_set_barsz(struct rte_pci_device *dev, struct nfp_pcie_user *desc) @@ -789,6 +856,10 @@ static const struct nfp_cpp_operations nfp6000_pcie_ops = { .free = nfp6000_free, .area_priv_size = sizeof(struct nfp6000_area_priv), + + .get_interface = nfp6000_get_interface, + .get_serial = nfp6000_get_serial, + .area_init = nfp6000_area_init, .area_acquire = nfp6000_area_acquire, .area_release = nfp6000_area_release, diff --git a/drivers/net/nfp/nfpcore/nfp_cpp.h b/drivers/net/nfp/nfpcore/nfp_cpp.h index 34ed50ceca..0f36ba0b50 100644 --- a/drivers/net/nfp/nfpcore/nfp_cpp.h +++ b/drivers/net/nfp/nfpcore/nfp_cpp.h @@ -16,6 +16,8 @@ struct nfp_cpp_area; #define NFP_SERIAL_LEN 6 +#define NFP_CPP_NUM_TARGETS 16 + /* * NFP CPP operations structure */ @@ -33,6 +35,13 @@ struct nfp_cpp_operations { */ void (*free)(struct nfp_cpp *cpp); + int (*get_interface)(struct rte_pci_device *dev, + uint16_t *interface); + + int (*get_serial)(struct rte_pci_device *dev, + uint8_t *serial, + size_t length); + /* * Initialize a new NFP CPP area * NOTE: This is _not_ serialized -- 2.39.1