get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/131552/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 131552,
    "url": "http://patchwork.dpdk.org/api/patches/131552/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20230918024612.1600536-19-chaoyong.he@corigine.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20230918024612.1600536-19-chaoyong.he@corigine.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230918024612.1600536-19-chaoyong.he@corigine.com",
    "date": "2023-09-18T02:46:04",
    "name": "[v4,18/26] net/nfp: refact the nsp module",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "e46981672bbdd8987bd3eae19c2c30a3286cce81",
    "submitter": {
        "id": 2554,
        "url": "http://patchwork.dpdk.org/api/people/2554/?format=api",
        "name": "Chaoyong He",
        "email": "chaoyong.he@corigine.com"
    },
    "delegate": {
        "id": 319,
        "url": "http://patchwork.dpdk.org/api/users/319/?format=api",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@amd.com"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20230918024612.1600536-19-chaoyong.he@corigine.com/mbox/",
    "series": [
        {
            "id": 29531,
            "url": "http://patchwork.dpdk.org/api/series/29531/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=29531",
            "date": "2023-09-18T02:45:46",
            "name": "refact the nfpcore module",
            "version": 4,
            "mbox": "http://patchwork.dpdk.org/series/29531/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/131552/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/131552/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 2E34C425C9;\n\tMon, 18 Sep 2023 04:49:37 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 0E382427E6;\n\tMon, 18 Sep 2023 04:47:49 +0200 (CEST)",
            "from NAM12-MW2-obe.outbound.protection.outlook.com\n (mail-mw2nam12on2130.outbound.protection.outlook.com [40.107.244.130])\n by mails.dpdk.org (Postfix) with ESMTP id BD23941151\n for <dev@dpdk.org>; Mon, 18 Sep 2023 04:47:44 +0200 (CEST)",
            "from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5)\n by PH7PR13MB6435.namprd13.prod.outlook.com (2603:10b6:510:2ea::9)\n with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26; Mon, 18 Sep\n 2023 02:47:42 +0000",
            "from SJ0PR13MB5545.namprd13.prod.outlook.com\n ([fe80::7a1c:2887:348a:84bd]) by SJ0PR13MB5545.namprd13.prod.outlook.com\n ([fe80::7a1c:2887:348a:84bd%6]) with mapi id 15.20.6792.026; Mon, 18 Sep 2023\n 02:47:42 +0000"
        ],
        "ARC-Seal": "i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;\n b=mCtrg/qMMOPV7PEoy6WlukvJ6cbocmYNgelxsLTX5w2Llgvs4QQLPcJkGaz8LHOVZhQ3O4UPp7sQBM40s+YAyb1P7Z5OUfWig+tgZhJWKzeV6p+CY38/ON8NY+MNOpCk0GxU3mkhBYK/jVZ3KiXemdVwiNMPDDidBOWBiv7+m4Zze57bn+EKABRQXr7sutlfkcLuBHMmQvrsRf8aad5/IKivIxeBjcRHI9lNorfNekBpR+7MKiHFutvgT4WJVEGdKwNRxXwlSp5ocoqWARZ2SpwUW7/v3Bm7mpzk8zs5mrQWWQ7vtv4/20cwuO9ZdrLaKiorSph6JKVlpXHfsvcOEw==",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;\n s=arcselector9901;\n 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;\n bh=XwuB+/ZcSFenE1ezj9T79WAgZ8s+szB6iUQxlLJrhf4=;\n b=mPdniAJdGXDmBCRVu7mmZ5x0CyVJgQfy3XHJympWynz+A4glU7kvin/7ueiyo7EoYpxTpI70tiCoQoJw56jfwWvzpoIuYVvypdT8HEUzkxls9DNsay3abvZf0ZXtM3P6mYWU2SSGpZGy2+Ua42F1VGB5DhUA0YLuJogKZ7qyver6d7TOe+fEzwWdv4GrH/qto2IlKhwZZ2s2v/VC5MiUhUHQGoLXkBGSkNHWiTrJzt/7J31TE0FFbzbeZGR3qiVnSI7JM1hXupFfj5kOc50BFJ2YUnf3QiIBo/K+J9qBARSBL/ZMGp1pzFlF8nTNl5gGpnErzg8Mj7AFIPbuOcORxA==",
        "ARC-Authentication-Results": "i=1; mx.microsoft.com 1; spf=pass\n smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com;\n dkim=pass header.d=corigine.com; arc=none",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n bh=XwuB+/ZcSFenE1ezj9T79WAgZ8s+szB6iUQxlLJrhf4=;\n b=l+4t2C34dYAI4kCnyesPT+f25xsFCyCQ3kvkU4kPVW9QuKfbMi9cXjOtTyE3IIrx2mRes3LQ8lk1IkGa1DsiBgdfYV/n7c4+dF92GL3bXccz8TmduvSKZdXUsgiGZCAGWqxRYNNiSqfmG1SUeOwpfQK1aL8FrasVOdikn+38+F4=",
        "Authentication-Results": "dkim=none (message not signed)\n header.d=none;dmarc=none action=none header.from=corigine.com;",
        "From": "Chaoyong He <chaoyong.he@corigine.com>",
        "To": "dev@dpdk.org",
        "Cc": "Chaoyong He <chaoyong.he@corigine.com>,\n =?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@corigine.com>",
        "Subject": "[PATCH v4 18/26] net/nfp: refact the nsp module",
        "Date": "Mon, 18 Sep 2023 10:46:04 +0800",
        "Message-Id": "<20230918024612.1600536-19-chaoyong.he@corigine.com>",
        "X-Mailer": "git-send-email 2.39.1",
        "In-Reply-To": "<20230918024612.1600536-1-chaoyong.he@corigine.com>",
        "References": "<20230915091551.1459606-1-chaoyong.he@corigine.com>\n <20230918024612.1600536-1-chaoyong.he@corigine.com>",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "X-ClientProxiedBy": "SE2P216CA0016.KORP216.PROD.OUTLOOK.COM\n (2603:1096:101:114::20) To SJ0PR13MB5545.namprd13.prod.outlook.com\n (2603:10b6:a03:424::5)",
        "MIME-Version": "1.0",
        "X-MS-PublicTrafficType": "Email",
        "X-MS-TrafficTypeDiagnostic": "SJ0PR13MB5545:EE_|PH7PR13MB6435:EE_",
        "X-MS-Office365-Filtering-Correlation-Id": "186be7fd-73e0-42e1-eddc-08dbb7f1a143",
        "X-MS-Exchange-SenderADCheck": "1",
        "X-MS-Exchange-AntiSpam-Relay": "0",
        "X-Microsoft-Antispam": "BCL:0;",
        "X-Microsoft-Antispam-Message-Info": "\n Uy+bA9a6bXJajkcGmGiQtOAOZDDcVpa8P7K/DrR5ZWNIFTId5zr17EGN0xzBeIxfNANo3cp1ylzmC1VoT6Zl3HEyaYUF7WWgzEdY9LaqOOgZU/FCNt1w5yelCRII/T0a+6O3wpe7ga0xRe4gQ7tDJkYaMTowJDERp5GpKFZmbIwm39c+nP2/7p5qbunYUWcqUNlecSgQcJSqypwcPwdW7SQ+M7WKuzHSNkY71aH9iA/Oz44cSMf4mk1LT6SgJlKhMpghEaVO+rn+TJ+7dcd++77RgXpTsive3YuNNvCQT7jcWmK35pZ8jDQYTTOREh6ROa204xp2tN4sjQ+/+7jYcOmPx3jjZWvdjhFFw9ZGLTi2xhHwh+L6MY00N9Ekb4QMyJ+3o/ABuEhaithUlpquONHpzT4R+8gJCszdCoyziWoQc0mcYzc4W5DPv3eJyxNY9zSAgLMtDWEUBJByJzaS1sltwUB7PjfYatsh+OzFuL6anOGtF+nFQtlwwSQqzdboVmfWu4Z/cM9dK04Jwa8UzxTguzLrluv5Tw3lDNo31+r7fyJR1E/qrMiDeHiyx8stfo38tK4a/k6mAKjFRPmiKs7fhMdlsrAgrUowLcFaDWknBYVTIziQ/CgRFyNcKY+QmpWJ84n2PYa+kTpugRWIv+9JamrSFVj8WGEJauPYV5w=",
        "X-Forefront-Antispam-Report": "CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;\n IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE;\n SFS:(13230031)(39830400003)(136003)(346002)(366004)(376002)(396003)(1800799009)(451199024)(186009)(54906003)(66476007)(66946007)(66574015)(41300700001)(6916009)(316002)(8676002)(4326008)(8936002)(52116002)(6506007)(6486002)(6512007)(478600001)(6666004)(83380400001)(26005)(1076003)(2616005)(107886003)(86362001)(2906002)(30864003)(44832011)(38100700002)(38350700002)(5660300002)(36756003)(66556008);\n DIR:OUT; SFP:1102;",
        "X-MS-Exchange-AntiSpam-MessageData-ChunkCount": "1",
        "X-MS-Exchange-AntiSpam-MessageData-0": "=?utf-8?q?hy2Y2jusumO89g8ss2H6H0ycaFjx?=\n\t=?utf-8?q?phvLX2eYixITyHMhwIX7NOib0G8jzt5hV7II+lDa7DZFDNnmrVIvpb6hwHsrnPSoF?=\n\t=?utf-8?q?N+VpB37/u7oJzYhw2pERIDktg/LPn1O07rI52VRZSJGGdP9/7/tmfKzUSSyJEj2Ld?=\n\t=?utf-8?q?q0gy9X20FptmPJN6nJneJwvOHQGfKpCdKJBopQ6jU0HqzVJoFEnJU98HR/oMQtUbD?=\n\t=?utf-8?q?+q0d0fADNKBca0gkrOwx3JpQQ0yCub23g5zZVukkJsf3G9Ut0HRuVXwmKIrRSD9dh?=\n\t=?utf-8?q?TmIbrTjg3IVLMuClV4JdLbo5HAij8+OhiVdgXrcm6Xn5b891K9vUYLuGCaecryCgm?=\n\t=?utf-8?q?H9hBBhJNyUaUCKmCCD8/sSxV6g4KKKec145RHoFnmEgFcRusCzi9yUVgGbN1IH0/Z?=\n\t=?utf-8?q?B0+0zhzpoaLlaus/5f4vcVmAFSz2K1Ewfkux0ITbg3o5Wv4/LTUq5u1dukSsE1F0x?=\n\t=?utf-8?q?Of5+PJQmmbkO5qZ957kZzEGp1P1exwg/jYLXN9qUXBZZ67dbelw8JlrctXqhjhIwI?=\n\t=?utf-8?q?3z9HJ7Medn5XM4avL1WzcnboUNwwincu1yC+eWcgOMDpewyfUvTm3rxDzc6STOx5/?=\n\t=?utf-8?q?gzJY2nGK3uvcX3+Xq+slpvoMAGrR8qBkG3ZIBgqmevOi4pNwt/GV7O383TSAb3Zx8?=\n\t=?utf-8?q?1FFNxXQ0BbwPk+55kHlnnc09lQe3V409Svlz4NcYlvVIcv3S1AiL9i0Wiqz+BqZNz?=\n\t=?utf-8?q?PUqyKNHw8bxtqtd5Jlz4hjPGAVCnp0a3tGHM/yS7DBokKfnT4j1F8jO4E/JbQP5x4?=\n\t=?utf-8?q?WW7/1b4RYwIW13Fn22te9JiUwqxKnArLeLw+RaaVqC1Ef57jEaaaWX0wIrU3l5MX2?=\n\t=?utf-8?q?koWIM/6He70zITgUE5DBk8ymnPjDK8IYAoCM2ZNtbbmzMGKs1J4kzmuSVTjFsK4Gk?=\n\t=?utf-8?q?Un8HAPbK6b+5cIsFKKhXq3t/Z4hYjZ1AhcWUW72dtRkqJIkx7f0RfDrdATbfvJ+IJ?=\n\t=?utf-8?q?PODSuN+pcRJDRclVOLjvcR3cyedpHcWyn0qjez13NLIXQQcHXc0oBhl2zFa6wtbdU?=\n\t=?utf-8?q?C7pLs2cycvKLDFJcbvJdaW4vba7HGW7qO2FHPNHTajo3eyMwiuvOJsN4spRrEQii7?=\n\t=?utf-8?q?+PJjxL59vFjgb6PJEQ9K3PcOWZGdruy7L1nxXBed1uLyk+GD5kOLGHuDQWhjeX0GZ?=\n\t=?utf-8?q?ePmLfjVjjO4hcpSqpb6GOdrucZY9DgzVc9S0QzPvggJNnmq014BlYkUAAMUdv5YK+?=\n\t=?utf-8?q?bmMc8ZMt+NBtueYb5/WWmyqdlVYl8dJK092FH1636OopWAsOWy9yATW1BRu7sw0RV?=\n\t=?utf-8?q?npmSb+cDYYnuUiQvvnOC9XspRV0e0A8BXeMXMCCyb6xbZzY8shU/RYidjkOurUs4p?=\n\t=?utf-8?q?isFhiX/0lcqL9KYFCYEZgkGm4iD/UAfkRRf5GX4CbBs6dZUjlB2vaqpik3070+f59?=\n\t=?utf-8?q?HArdOY54sR6xP5+vXouX5hvJdeuen4Nmak35www7xjMiIm1ZGeyZXR2p+od1UvWHv?=\n\t=?utf-8?q?h6eKXVPKAYrPv/Vs2Nywi3zhXPnpc0ljvwdd3oW58+dGzohZE67LBz5OD7yrFNo7d?=\n\t=?utf-8?q?nw2I7ZlMnuweau4csxN+ZseaEq0sp8dBBQ=3D=3D?=",
        "X-OriginatorOrg": "corigine.com",
        "X-MS-Exchange-CrossTenant-Network-Message-Id": "\n 186be7fd-73e0-42e1-eddc-08dbb7f1a143",
        "X-MS-Exchange-CrossTenant-AuthSource": "SJ0PR13MB5545.namprd13.prod.outlook.com",
        "X-MS-Exchange-CrossTenant-AuthAs": "Internal",
        "X-MS-Exchange-CrossTenant-OriginalArrivalTime": "18 Sep 2023 02:47:42.6758 (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": "\n 5Z85FttisK5bKRk/KtVyzmTcMszlksIFLmu6J3pIcAzA3qwhqohmuKWhl/LePsj7JDNzrv1rYTZfrvpBYx7Sc95LJWSEQtdfEB/j0J6wClA=",
        "X-MS-Exchange-Transport-CrossTenantHeadersStamped": "PH7PR13MB6435",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "Move the definition of data structure into the implement file.\nAlso sync the logic from kernel driver and remove the unneeded header\nfile include statements.\n\nSigned-off-by: Chaoyong He <chaoyong.he@corigine.com>\nReviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>\n---\n drivers/net/nfp/nfp_ethdev.c           |   2 +-\n drivers/net/nfp/nfpcore/nfp_nsp.c      | 390 +++++++++++++++++++------\n drivers/net/nfp/nfpcore/nfp_nsp.h      | 140 ++++-----\n drivers/net/nfp/nfpcore/nfp_nsp_cmds.c |   4 -\n drivers/net/nfp/nfpcore/nfp_nsp_eth.c  |  79 ++---\n 5 files changed, 398 insertions(+), 217 deletions(-)",
    "diff": "diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c\nindex e3ff3d8087..efb47c5d56 100644\n--- a/drivers/net/nfp/nfp_ethdev.c\n+++ b/drivers/net/nfp/nfp_ethdev.c\n@@ -661,7 +661,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev)\n static int\n nfp_fw_upload(struct rte_pci_device *dev, struct nfp_nsp *nsp, char *card)\n {\n-\tstruct nfp_cpp *cpp = nsp->cpp;\n+\tstruct nfp_cpp *cpp = nfp_nsp_cpp(nsp);\n \tvoid *fw_buf;\n \tchar fw_name[125];\n \tchar serial[40];\ndiff --git a/drivers/net/nfp/nfpcore/nfp_nsp.c b/drivers/net/nfp/nfpcore/nfp_nsp.c\nindex 0f67148907..e9b3fc3945 100644\n--- a/drivers/net/nfp/nfpcore/nfp_nsp.c\n+++ b/drivers/net/nfp/nfpcore/nfp_nsp.c\n@@ -3,20 +3,127 @@\n  * All rights reserved.\n  */\n \n-#define NFP_SUBSYS \"nfp_nsp\"\n-\n-#include <stdio.h>\n-#include <time.h>\n+#include \"nfp_nsp.h\"\n \n #include <rte_common.h>\n \n-#include \"nfp_cpp.h\"\n #include \"nfp_logs.h\"\n-#include \"nfp_nsp.h\"\n #include \"nfp_platform.h\"\n #include \"nfp_resource.h\"\n \n-int\n+/* Offsets relative to the CSR base */\n+#define NSP_STATUS              0x00\n+#define   NSP_STATUS_MAGIC      GENMASK_ULL(63, 48)\n+#define   NSP_STATUS_MAJOR      GENMASK_ULL(47, 44)\n+#define   NSP_STATUS_MINOR      GENMASK_ULL(43, 32)\n+#define   NSP_STATUS_CODE       GENMASK_ULL(31, 16)\n+#define   NSP_STATUS_RESULT     GENMASK_ULL(15, 8)\n+#define   NSP_STATUS_BUSY       RTE_BIT64(0)\n+\n+#define NSP_COMMAND             0x08\n+#define   NSP_COMMAND_OPTION    GENMASK_ULL(63, 32)\n+#define   NSP_COMMAND_CODE      GENMASK_ULL(31, 16)\n+#define   NSP_COMMAND_DMA_BUF   RTE_BIT64(1)\n+#define   NSP_COMMAND_START     RTE_BIT64(0)\n+\n+/* CPP address to retrieve the data from */\n+#define NSP_BUFFER              0x10\n+#define   NSP_BUFFER_CPP        GENMASK_ULL(63, 40)\n+#define   NSP_BUFFER_ADDRESS    GENMASK_ULL(39, 0)\n+\n+#define NSP_DFLT_BUFFER         0x18\n+#define   NSP_DFLT_BUFFER_CPP          GENMASK_ULL(63, 40)\n+#define   NSP_DFLT_BUFFER_ADDRESS      GENMASK_ULL(39, 0)\n+\n+#define NSP_DFLT_BUFFER_CONFIG  0x20\n+#define   NSP_DFLT_BUFFER_SIZE_4KB     GENMASK_ULL(15, 8)\n+#define   NSP_DFLT_BUFFER_SIZE_MB      GENMASK_ULL(7, 0)\n+\n+#define NSP_MAGIC               0xab10\n+#define NSP_MAJOR               0\n+#define NSP_MINOR               8\n+\n+#define NSP_CODE_MAJOR          GENMASK_ULL(15, 12)\n+#define NSP_CODE_MINOR          GENMASK_ULL(11, 0)\n+\n+#define NFP_FW_LOAD_RET_MAJOR   GENMASK_ULL(15, 8)\n+#define NFP_FW_LOAD_RET_MINOR   GENMASK_ULL(23, 16)\n+\n+enum nfp_nsp_cmd {\n+\tSPCODE_NOOP             = 0, /* No operation */\n+\tSPCODE_SOFT_RESET       = 1, /* Soft reset the NFP */\n+\tSPCODE_FW_DEFAULT       = 2, /* Load default (UNDI) FW */\n+\tSPCODE_PHY_INIT         = 3, /* Initialize the PHY */\n+\tSPCODE_MAC_INIT         = 4, /* Initialize the MAC */\n+\tSPCODE_PHY_RXADAPT      = 5, /* Re-run PHY RX Adaptation */\n+\tSPCODE_FW_LOAD          = 6, /* Load fw from buffer, len in option */\n+\tSPCODE_ETH_RESCAN       = 7, /* Rescan ETHs, write ETH_TABLE to buf */\n+\tSPCODE_ETH_CONTROL      = 8, /* Update media config from buffer */\n+\tSPCODE_NSP_WRITE_FLASH  = 11, /* Load and flash image from buffer */\n+\tSPCODE_NSP_SENSORS      = 12, /* Read NSP sensor(s) */\n+\tSPCODE_NSP_IDENTIFY     = 13, /* Read NSP version */\n+\tSPCODE_FW_STORED        = 16, /* If no FW loaded, load flash app FW */\n+\tSPCODE_HWINFO_LOOKUP    = 17, /* Lookup HWinfo with overwrites etc. */\n+\tSPCODE_HWINFO_SET       = 18, /* Set HWinfo entry */\n+\tSPCODE_FW_LOADED        = 19, /* Is application firmware loaded */\n+\tSPCODE_VERSIONS         = 21, /* Report FW versions */\n+\tSPCODE_READ_SFF_EEPROM  = 22, /* Read module EEPROM */\n+\tSPCODE_READ_MEDIA       = 23, /* Get the supported/advertised media for a port */\n+};\n+\n+static const struct {\n+\tuint32_t code;\n+\tconst char *msg;\n+} nsp_errors[] = {\n+\t{ 6010, \"could not map to phy for port\" },\n+\t{ 6011, \"not an allowed rate/lanes for port\" },\n+\t{ 6012, \"not an allowed rate/lanes for port\" },\n+\t{ 6013, \"high/low error, change other port first\" },\n+\t{ 6014, \"config not found in flash\" },\n+};\n+\n+struct nfp_nsp {\n+\tstruct nfp_cpp *cpp;\n+\tstruct nfp_resource *res;\n+\tstruct {\n+\t\tuint16_t major;\n+\t\tuint16_t minor;\n+\t} ver;\n+\n+\t/** Eth table config state */\n+\tbool modified;\n+\tuint32_t idx;\n+\tvoid *entries;\n+};\n+\n+/* NFP command argument structure */\n+struct nfp_nsp_command_arg {\n+\tuint16_t code;         /**< NFP SP Command Code */\n+\tbool dma;              /**< @buf points to a host buffer, not NSP buffer */\n+\tbool error_quiet;      /**< Don't print command error/warning */\n+\tuint32_t timeout_sec;  /**< Timeout value to wait for completion in seconds */\n+\tuint32_t option;       /**< NSP Command Argument */\n+\tuint64_t buf;          /**< NSP Buffer Address */\n+\t/** Callback for interpreting option if error occurred */\n+\tvoid (*error_cb)(struct nfp_nsp *state, uint32_t ret_val);\n+};\n+\n+/* NFP command with buffer argument structure */\n+struct nfp_nsp_command_buf_arg {\n+\tstruct nfp_nsp_command_arg arg;  /**< NFP command argument structure */\n+\tconst void *in_buf;              /**< Buffer with data for input */\n+\tvoid *out_buf;                   /**< Buffer for output data */\n+\tuint32_t in_size;                /**< Size of @in_buf */\n+\tuint32_t out_size;               /**< Size of @out_buf */\n+};\n+\n+struct nfp_cpp *\n+nfp_nsp_cpp(struct nfp_nsp *state)\n+{\n+\treturn state->cpp;\n+}\n+\n+bool\n nfp_nsp_config_modified(struct nfp_nsp *state)\n {\n \treturn state->modified;\n@@ -24,7 +131,7 @@ nfp_nsp_config_modified(struct nfp_nsp *state)\n \n void\n nfp_nsp_config_set_modified(struct nfp_nsp *state,\n-\t\tint modified)\n+\t\tbool modified)\n {\n \tstate->modified = modified;\n }\n@@ -66,7 +173,7 @@ nfp_nsp_print_extended_error(uint32_t ret_val)\n \t\treturn;\n \n \tfor (i = 0; i < RTE_DIM(nsp_errors); i++)\n-\t\tif (ret_val == (uint32_t)nsp_errors[i].code)\n+\t\tif (ret_val == nsp_errors[i].code)\n \t\t\tPMD_DRV_LOG(ERR, \"err msg: %s\", nsp_errors[i].msg);\n }\n \n@@ -222,11 +329,8 @@ nfp_nsp_wait_reg(struct nfp_cpp *cpp,\n  *   - -ETIMEDOUT if the NSP took longer than @timeout_sec seconds to complete\n  */\n static int\n-nfp_nsp_command(struct nfp_nsp *state,\n-\t\tuint16_t code,\n-\t\tuint32_t option,\n-\t\tuint32_t buff_cpp,\n-\t\tuint64_t buff_addr)\n+nfp_nsp_command_real(struct nfp_nsp *state,\n+\t\tconst struct nfp_nsp_command_arg *arg)\n {\n \tint err;\n \tuint64_t reg;\n@@ -250,22 +354,14 @@ nfp_nsp_command(struct nfp_nsp *state,\n \t\treturn err;\n \t}\n \n-\tif (!FIELD_FIT(NSP_BUFFER_CPP, buff_cpp >> 8) ||\n-\t\t\t!FIELD_FIT(NSP_BUFFER_ADDRESS, buff_addr)) {\n-\t\tPMD_DRV_LOG(ERR, \"Host buffer out of reach %08x %\" PRIx64,\n-\t\t\t\tbuff_cpp, buff_addr);\n-\t\treturn -EINVAL;\n-\t}\n-\n-\terr = nfp_cpp_writeq(cpp, nsp_cpp, nsp_buffer,\n-\t\t\tFIELD_PREP(NSP_BUFFER_CPP, buff_cpp >> 8) |\n-\t\t\tFIELD_PREP(NSP_BUFFER_ADDRESS, buff_addr));\n+\terr = nfp_cpp_writeq(cpp, nsp_cpp, nsp_buffer, arg->buf);\n \tif (err < 0)\n \t\treturn err;\n \n \terr = nfp_cpp_writeq(cpp, nsp_cpp, nsp_command,\n-\t\t\tFIELD_PREP(NSP_COMMAND_OPTION, option) |\n-\t\t\tFIELD_PREP(NSP_COMMAND_CODE, code) |\n+\t\t\tFIELD_PREP(NSP_COMMAND_OPTION, arg->option) |\n+\t\t\tFIELD_PREP(NSP_COMMAND_CODE, arg->code) |\n+\t\t\tFIELD_PREP(NSP_COMMAND_DMA_BUF, arg->dma) |\n \t\t\tFIELD_PREP(NSP_COMMAND_START, 1));\n \tif (err < 0)\n \t\treturn err;\n@@ -275,7 +371,7 @@ nfp_nsp_command(struct nfp_nsp *state,\n \t\t\tNSP_COMMAND_START, 0);\n \tif (err != 0) {\n \t\tPMD_DRV_LOG(ERR, \"Error %d waiting for code %#04x to start\",\n-\t\t\t\terr, code);\n+\t\t\t\terr, arg->code);\n \t\treturn err;\n \t}\n \n@@ -284,7 +380,7 @@ nfp_nsp_command(struct nfp_nsp *state,\n \t\t\tNSP_STATUS_BUSY, 0);\n \tif (err != 0) {\n \t\tPMD_DRV_LOG(ERR, \"Error %d waiting for code %#04x to complete\",\n-\t\t\t\terr, code);\n+\t\t\t\terr, arg->code);\n \t\treturn err;\n \t}\n \n@@ -296,84 +392,85 @@ nfp_nsp_command(struct nfp_nsp *state,\n \n \terr = FIELD_GET(NSP_STATUS_RESULT, reg);\n \tif (err != 0) {\n-\t\tPMD_DRV_LOG(ERR, \"Result (error) code set: %d (%d) command: %d\",\n-\t\t\t\t-err, (int)ret_val, code);\n-\t\tnfp_nsp_print_extended_error(ret_val);\n+\t\tif (!arg->error_quiet)\n+\t\t\tPMD_DRV_LOG(WARNING, \"Result (error) code set: %d (%d) command: %d\",\n+\t\t\t\t\t-err, (int)ret_val, arg->code);\n+\n+\t\tif (arg->error_cb != 0)\n+\t\t\targ->error_cb(state, ret_val);\n+\t\telse\n+\t\t\tnfp_nsp_print_extended_error(ret_val);\n+\n \t\treturn -err;\n \t}\n \n \treturn ret_val;\n }\n \n-#define SZ_1M 0x00100000\n+static int\n+nfp_nsp_command(struct nfp_nsp *state,\n+\t\tuint16_t code)\n+{\n+\tconst struct nfp_nsp_command_arg arg = {\n+\t\t.code = code,\n+\t};\n+\n+\treturn nfp_nsp_command_real(state, &arg);\n+}\n \n static int\n-nfp_nsp_command_buf(struct nfp_nsp *nsp,\n-\t\tuint16_t code, uint32_t option,\n-\t\tconst void *in_buf,\n-\t\tunsigned int in_size,\n-\t\tvoid *out_buf,\n-\t\tunsigned int out_size)\n+nfp_nsp_command_buf_def(struct nfp_nsp *nsp,\n+\t\tstruct nfp_nsp_command_buf_arg *arg)\n {\n \tint err;\n \tint ret;\n \tuint64_t reg;\n-\tsize_t max_size;\n \tuint32_t cpp_id;\n \tuint64_t cpp_buf;\n \tstruct nfp_cpp *cpp = nsp->cpp;\n \n-\tif (nsp->ver.minor < 13) {\n-\t\tPMD_DRV_LOG(ERR, \"NSP: Code 0x%04x with buffer not supported ABI %hu.%hu)\",\n-\t\t\t\tcode, nsp->ver.major, nsp->ver.minor);\n-\t\treturn -EOPNOTSUPP;\n-\t}\n-\n-\terr = nfp_cpp_readq(cpp, nfp_resource_cpp_id(nsp->res),\n-\t\t\tnfp_resource_address(nsp->res) + NSP_DFLT_BUFFER_CONFIG,\n-\t\t\t&reg);\n-\tif (err < 0)\n-\t\treturn err;\n-\n-\tmax_size = RTE_MAX(in_size, out_size);\n-\tif (FIELD_GET(NSP_DFLT_BUFFER_SIZE_MB, reg) * SZ_1M < max_size) {\n-\t\tPMD_DRV_LOG(ERR, \"NSP: default buffer too small for command 0x%04x (%llu < %zu)\",\n-\t\t\t\tcode, FIELD_GET(NSP_DFLT_BUFFER_SIZE_MB, reg) * SZ_1M, max_size);\n-\t\treturn -EINVAL;\n-\t}\n-\n \terr = nfp_cpp_readq(cpp, nfp_resource_cpp_id(nsp->res),\n \t\t\tnfp_resource_address(nsp->res) + NSP_DFLT_BUFFER,\n \t\t\t&reg);\n \tif (err < 0)\n \t\treturn err;\n \n-\tcpp_id = FIELD_GET(NSP_BUFFER_CPP, reg) << 8;\n-\tcpp_buf = FIELD_GET(NSP_BUFFER_ADDRESS, reg);\n+\tcpp_id = FIELD_GET(NSP_DFLT_BUFFER_CPP, reg) << 8;\n+\tcpp_buf = FIELD_GET(NSP_DFLT_BUFFER_ADDRESS, reg);\n \n-\tif (in_buf != NULL && in_size > 0) {\n-\t\terr = nfp_cpp_write(cpp, cpp_id, cpp_buf, in_buf, in_size);\n+\tif (arg->in_buf != NULL && arg->in_size > 0) {\n+\t\terr = nfp_cpp_write(cpp, cpp_id, cpp_buf,\n+\t\t\t\targ->in_buf, arg->in_size);\n \t\tif (err < 0)\n \t\t\treturn err;\n \t}\n \n \t/* Zero out remaining part of the buffer */\n-\tif (out_buf != NULL && out_size > 0 && out_size > in_size) {\n-\t\tmemset(out_buf, 0, out_size - in_size);\n-\t\terr = nfp_cpp_write(cpp, cpp_id, cpp_buf + in_size, out_buf,\n-\t\t\t\tout_size - in_size);\n+\tif (arg->out_buf != NULL && arg->out_size > arg->in_size) {\n+\t\terr = nfp_cpp_write(cpp, cpp_id, cpp_buf + arg->in_size,\n+\t\t\t\targ->out_buf, arg->out_size - arg->in_size);\n \t\tif (err < 0)\n \t\t\treturn err;\n \t}\n \n-\tret = nfp_nsp_command(nsp, code, option, cpp_id, cpp_buf);\n+\tif (!FIELD_FIT(NSP_BUFFER_CPP, cpp_id >> 8) ||\n+\t\t\t!FIELD_FIT(NSP_BUFFER_ADDRESS, cpp_buf)) {\n+\t\tPMD_DRV_LOG(ERR, \"Buffer out of reach %#08x %#016lx\",\n+\t\t\t\tcpp_id, cpp_buf);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\targ->arg.buf = FIELD_PREP(NSP_BUFFER_CPP, cpp_id >> 8) |\n+\t\t\tFIELD_PREP(NSP_BUFFER_ADDRESS, cpp_buf);\n+\tret = nfp_nsp_command_real(nsp, &arg->arg);\n \tif (ret < 0) {\n \t\tPMD_DRV_LOG(ERR, \"NSP command failed\");\n \t\treturn ret;\n \t}\n \n-\tif (out_buf != NULL && out_size > 0) {\n-\t\terr = nfp_cpp_read(cpp, cpp_id, cpp_buf, out_buf, out_size);\n+\tif (arg->out_buf != NULL && arg->out_size > 0) {\n+\t\terr = nfp_cpp_read(cpp, cpp_id, cpp_buf,\n+\t\t\t\targ->out_buf, arg->out_size);\n \t\tif (err < 0)\n \t\t\treturn err;\n \t}\n@@ -381,6 +478,43 @@ nfp_nsp_command_buf(struct nfp_nsp *nsp,\n \treturn ret;\n }\n \n+#define SZ_1M 0x00100000\n+#define SZ_4K 0x00001000\n+\n+static int\n+nfp_nsp_command_buf(struct nfp_nsp *nsp,\n+\t\tstruct nfp_nsp_command_buf_arg *arg)\n+{\n+\tint err;\n+\tuint64_t reg;\n+\tuint32_t size;\n+\tuint32_t max_size;\n+\tstruct nfp_cpp *cpp = nsp->cpp;\n+\n+\tif (nsp->ver.minor < 13) {\n+\t\tPMD_DRV_LOG(ERR, \"NSP: Code %#04x with buffer not supported ABI %hu.%hu)\",\n+\t\t\t\targ->arg.code, nsp->ver.major, nsp->ver.minor);\n+\t\treturn -EOPNOTSUPP;\n+\t}\n+\n+\terr = nfp_cpp_readq(cpp, nfp_resource_cpp_id(nsp->res),\n+\t\t\tnfp_resource_address(nsp->res) + NSP_DFLT_BUFFER_CONFIG,\n+\t\t\t&reg);\n+\tif (err < 0)\n+\t\treturn err;\n+\n+\tmax_size = RTE_MAX(arg->in_size, arg->out_size);\n+\tsize = FIELD_GET(NSP_DFLT_BUFFER_SIZE_MB, reg) * SZ_1M +\n+\t\t\tFIELD_GET(NSP_DFLT_BUFFER_SIZE_4KB, reg) * SZ_4K;\n+\tif (size < max_size) {\n+\t\tPMD_DRV_LOG(ERR, \"NSP: default buffer too small for command %#04x (%u < %u)\",\n+\t\t\t\targ->arg.code, size, max_size);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn nfp_nsp_command_buf_def(nsp, arg);\n+}\n+\n int\n nfp_nsp_wait(struct nfp_nsp *state)\n {\n@@ -392,7 +526,7 @@ nfp_nsp_wait(struct nfp_nsp *state)\n \twait.tv_nsec = 25000000;    /* 25ms */\n \n \tfor (;;) {\n-\t\terr = nfp_nsp_command(state, SPCODE_NOOP, 0, 0, 0);\n+\t\terr = nfp_nsp_command(state, SPCODE_NOOP);\n \t\tif (err != -EAGAIN)\n \t\t\tbreak;\n \n@@ -413,13 +547,57 @@ nfp_nsp_wait(struct nfp_nsp *state)\n int\n nfp_nsp_device_soft_reset(struct nfp_nsp *state)\n {\n-\treturn nfp_nsp_command(state, SPCODE_SOFT_RESET, 0, 0, 0);\n+\treturn nfp_nsp_command(state, SPCODE_SOFT_RESET);\n }\n \n int\n nfp_nsp_mac_reinit(struct nfp_nsp *state)\n {\n-\treturn nfp_nsp_command(state, SPCODE_MAC_INIT, 0, 0, 0);\n+\treturn nfp_nsp_command(state, SPCODE_MAC_INIT);\n+}\n+\n+static void\n+nfp_nsp_load_fw_extended_msg(struct nfp_nsp *state,\n+\t\tuint32_t ret_val)\n+{\n+\tuint32_t minor;\n+\tuint32_t major;\n+\tstatic const char * const major_msg[] = {\n+\t\t/* 0 */ \"Firmware from driver loaded\",\n+\t\t/* 1 */ \"Firmware from flash loaded\",\n+\t\t/* 2 */ \"Firmware loading failure\",\n+\t};\n+\tstatic const char * const minor_msg[] = {\n+\t\t/*  0 */ \"\",\n+\t\t/*  1 */ \"no named partition on flash\",\n+\t\t/*  2 */ \"error reading from flash\",\n+\t\t/*  3 */ \"can not deflate\",\n+\t\t/*  4 */ \"not a trusted file\",\n+\t\t/*  5 */ \"can not parse FW file\",\n+\t\t/*  6 */ \"MIP not found in FW file\",\n+\t\t/*  7 */ \"null firmware name in MIP\",\n+\t\t/*  8 */ \"FW version none\",\n+\t\t/*  9 */ \"FW build number none\",\n+\t\t/* 10 */ \"no FW selection policy HWInfo key found\",\n+\t\t/* 11 */ \"static FW selection policy\",\n+\t\t/* 12 */ \"FW version has precedence\",\n+\t\t/* 13 */ \"different FW application load requested\",\n+\t\t/* 14 */ \"development build\",\n+\t};\n+\n+\tmajor = FIELD_GET(NFP_FW_LOAD_RET_MAJOR, ret_val);\n+\tminor = FIELD_GET(NFP_FW_LOAD_RET_MINOR, ret_val);\n+\n+\tif (!nfp_nsp_has_stored_fw_load(state))\n+\t\treturn;\n+\n+\tif (major >= RTE_DIM(major_msg))\n+\t\tPMD_DRV_LOG(INFO, \"FW loading status: %x\", ret_val);\n+\telse if (minor >= RTE_DIM(minor_msg))\n+\t\tPMD_DRV_LOG(INFO, \"%s, reason code: %d\", major_msg[major], minor);\n+\telse\n+\t\tPMD_DRV_LOG(INFO, \"%s%c %s\", major_msg[major],\n+\t\t\t\tminor != 0 ? ',' : '.', minor_msg[minor]);\n }\n \n int\n@@ -427,8 +605,24 @@ nfp_nsp_load_fw(struct nfp_nsp *state,\n \t\tvoid *buf,\n \t\tsize_t size)\n {\n-\treturn nfp_nsp_command_buf(state, SPCODE_FW_LOAD, size, buf, size,\n-\t\t\tNULL, 0);\n+\tint ret;\n+\tstruct nfp_nsp_command_buf_arg load_fw = {\n+\t\t{\n+\t\t\t.code     = SPCODE_FW_LOAD,\n+\t\t\t.option   = size,\n+\t\t\t.error_cb = nfp_nsp_load_fw_extended_msg,\n+\t\t},\n+\t\t.in_buf  = buf,\n+\t\t.in_size = size,\n+\t};\n+\n+\tret = nfp_nsp_command_buf(state, &load_fw);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n+\tnfp_nsp_load_fw_extended_msg(state, ret);\n+\n+\treturn 0;\n }\n \n int\n@@ -436,8 +630,16 @@ nfp_nsp_read_eth_table(struct nfp_nsp *state,\n \t\tvoid *buf,\n \t\tsize_t size)\n {\n-\treturn nfp_nsp_command_buf(state, SPCODE_ETH_RESCAN, size, NULL, 0,\n-\t\t\tbuf, size);\n+\tstruct nfp_nsp_command_buf_arg eth_rescan = {\n+\t\t{\n+\t\t\t.code   = SPCODE_ETH_RESCAN,\n+\t\t\t.option = size,\n+\t\t},\n+\t\t.out_buf  = buf,\n+\t\t.out_size = size,\n+\t};\n+\n+\treturn nfp_nsp_command_buf(state, &eth_rescan);\n }\n \n int\n@@ -445,8 +647,16 @@ nfp_nsp_write_eth_table(struct nfp_nsp *state,\n \t\tconst void *buf,\n \t\tsize_t size)\n {\n-\treturn nfp_nsp_command_buf(state, SPCODE_ETH_CONTROL, size, buf, size,\n-\t\t\tNULL, 0);\n+\tstruct nfp_nsp_command_buf_arg eth_ctrl = {\n+\t\t{\n+\t\t\t.code   = SPCODE_ETH_CONTROL,\n+\t\t\t.option = size,\n+\t\t},\n+\t\t.in_buf  = buf,\n+\t\t.in_size = size,\n+\t};\n+\n+\treturn nfp_nsp_command_buf(state, &eth_ctrl);\n }\n \n int\n@@ -454,8 +664,16 @@ nfp_nsp_read_identify(struct nfp_nsp *state,\n \t\tvoid *buf,\n \t\tsize_t size)\n {\n-\treturn nfp_nsp_command_buf(state, SPCODE_NSP_IDENTIFY, size, NULL, 0,\n-\t\t\tbuf, size);\n+\tstruct nfp_nsp_command_buf_arg identify = {\n+\t\t{\n+\t\t\t.code   = SPCODE_NSP_IDENTIFY,\n+\t\t\t.option = size,\n+\t\t},\n+\t\t.out_buf  = buf,\n+\t\t.out_size = size,\n+\t};\n+\n+\treturn nfp_nsp_command_buf(state, &identify);\n }\n \n int\n@@ -464,6 +682,14 @@ nfp_nsp_read_sensors(struct nfp_nsp *state,\n \t\tvoid *buf,\n \t\tsize_t size)\n {\n-\treturn nfp_nsp_command_buf(state, SPCODE_NSP_SENSORS, sensor_mask, NULL,\n-\t\t\t0, buf, size);\n+\tstruct nfp_nsp_command_buf_arg sensors = {\n+\t\t{\n+\t\t\t.code   = SPCODE_NSP_SENSORS,\n+\t\t\t.option = sensor_mask,\n+\t\t},\n+\t\t.out_buf  = buf,\n+\t\t.out_size = size,\n+\t};\n+\n+\treturn nfp_nsp_command_buf(state, &sensors);\n }\ndiff --git a/drivers/net/nfp/nfpcore/nfp_nsp.h b/drivers/net/nfp/nfpcore/nfp_nsp.h\nindex 14986a9130..fe52dffeb7 100644\n--- a/drivers/net/nfp/nfpcore/nfp_nsp.h\n+++ b/drivers/net/nfp/nfpcore/nfp_nsp.h\n@@ -7,78 +7,8 @@\n #define __NSP_NSP_H__\n \n #include \"nfp_cpp.h\"\n-#include \"nfp_nsp.h\"\n-\n-/* Offsets relative to the CSR base */\n-#define NSP_STATUS              0x00\n-#define   NSP_STATUS_MAGIC      GENMASK_ULL(63, 48)\n-#define   NSP_STATUS_MAJOR      GENMASK_ULL(47, 44)\n-#define   NSP_STATUS_MINOR      GENMASK_ULL(43, 32)\n-#define   NSP_STATUS_CODE       GENMASK_ULL(31, 16)\n-#define   NSP_STATUS_RESULT     GENMASK_ULL(15, 8)\n-#define   NSP_STATUS_BUSY       RTE_BIT64(0)\n-\n-#define NSP_COMMAND             0x08\n-#define   NSP_COMMAND_OPTION    GENMASK_ULL(63, 32)\n-#define   NSP_COMMAND_CODE      GENMASK_ULL(31, 16)\n-#define   NSP_COMMAND_START     RTE_BIT64(0)\n-\n-/* CPP address to retrieve the data from */\n-#define NSP_BUFFER              0x10\n-#define   NSP_BUFFER_CPP        GENMASK_ULL(63, 40)\n-#define   NSP_BUFFER_PCIE       GENMASK_ULL(39, 38)\n-#define   NSP_BUFFER_ADDRESS    GENMASK_ULL(37, 0)\n-\n-#define NSP_DFLT_BUFFER         0x18\n-\n-#define NSP_DFLT_BUFFER_CONFIG 0x20\n-#define   NSP_DFLT_BUFFER_SIZE_MB    GENMASK_ULL(7, 0)\n-\n-#define NSP_MAGIC               0xab10\n-#define NSP_MAJOR               0\n-#define NSP_MINOR               8\n-\n-#define NSP_CODE_MAJOR          GENMASK(15, 12)\n-#define NSP_CODE_MINOR          GENMASK(11, 0)\n-\n-enum nfp_nsp_cmd {\n-\tSPCODE_NOOP             = 0, /* No operation */\n-\tSPCODE_SOFT_RESET       = 1, /* Soft reset the NFP */\n-\tSPCODE_FW_DEFAULT       = 2, /* Load default (UNDI) FW */\n-\tSPCODE_PHY_INIT         = 3, /* Initialize the PHY */\n-\tSPCODE_MAC_INIT         = 4, /* Initialize the MAC */\n-\tSPCODE_PHY_RXADAPT      = 5, /* Re-run PHY RX Adaptation */\n-\tSPCODE_FW_LOAD          = 6, /* Load fw from buffer, len in option */\n-\tSPCODE_ETH_RESCAN       = 7, /* Rescan ETHs, write ETH_TABLE to buf */\n-\tSPCODE_ETH_CONTROL      = 8, /* Update media config from buffer */\n-\tSPCODE_NSP_SENSORS      = 12, /* Read NSP sensor(s) */\n-\tSPCODE_NSP_IDENTIFY     = 13, /* Read NSP version */\n-};\n-\n-static const struct {\n-\tint code;\n-\tconst char *msg;\n-} nsp_errors[] = {\n-\t{ 6010, \"could not map to phy for port\" },\n-\t{ 6011, \"not an allowed rate/lanes for port\" },\n-\t{ 6012, \"not an allowed rate/lanes for port\" },\n-\t{ 6013, \"high/low error, change other port first\" },\n-\t{ 6014, \"config not found in flash\" },\n-};\n \n-struct nfp_nsp {\n-\tstruct nfp_cpp *cpp;\n-\tstruct nfp_resource *res;\n-\tstruct {\n-\t\tuint16_t major;\n-\t\tuint16_t minor;\n-\t} ver;\n-\n-\t/* Eth table config state */\n-\tint modified;\n-\tunsigned int idx;\n-\tvoid *entries;\n-};\n+struct nfp_nsp;\n \n struct nfp_nsp *nfp_nsp_open(struct nfp_cpp *cpp);\n void nfp_nsp_close(struct nfp_nsp *state);\n@@ -92,18 +22,61 @@ int nfp_nsp_read_identify(struct nfp_nsp *state, void *buf, size_t size);\n int nfp_nsp_read_sensors(struct nfp_nsp *state, uint32_t sensor_mask,\n \t\tvoid *buf, size_t size);\n \n-static inline int\n+static inline bool\n nfp_nsp_has_mac_reinit(struct nfp_nsp *state)\n {\n \treturn nfp_nsp_get_abi_ver_minor(state) > 20;\n }\n \n+static inline bool\n+nfp_nsp_has_stored_fw_load(struct nfp_nsp *state)\n+{\n+\treturn nfp_nsp_get_abi_ver_minor(state) > 23;\n+}\n+\n+static inline bool\n+nfp_nsp_has_hwinfo_lookup(struct nfp_nsp *state)\n+{\n+\treturn nfp_nsp_get_abi_ver_minor(state) > 24;\n+}\n+\n+static inline bool\n+nfp_nsp_has_hwinfo_set(struct nfp_nsp *state)\n+{\n+\treturn nfp_nsp_get_abi_ver_minor(state) > 25;\n+}\n+\n+static inline bool\n+nfp_nsp_has_fw_loaded(struct nfp_nsp *state)\n+{\n+\treturn nfp_nsp_get_abi_ver_minor(state) > 25;\n+}\n+\n+static inline bool\n+nfp_nsp_has_versions(struct nfp_nsp *state)\n+{\n+\treturn nfp_nsp_get_abi_ver_minor(state) > 27;\n+}\n+\n+static inline bool\n+nfp_nsp_has_read_module_eeprom(struct nfp_nsp *state)\n+{\n+\treturn nfp_nsp_get_abi_ver_minor(state) > 28;\n+}\n+\n+static inline bool\n+nfp_nsp_has_read_media(struct nfp_nsp *state)\n+{\n+\treturn nfp_nsp_get_abi_ver_minor(state) > 33;\n+}\n+\n enum nfp_eth_interface {\n \tNFP_INTERFACE_NONE      = 0,\n \tNFP_INTERFACE_SFP       = 1,\n \tNFP_INTERFACE_SFPP      = 10,\n \tNFP_INTERFACE_SFP28     = 28,\n \tNFP_INTERFACE_QSFP      = 40,\n+\tNFP_INTERFACE_RJ45      = 45,\n \tNFP_INTERFACE_CXP       = 100,\n \tNFP_INTERFACE_QSFP28    = 112,\n };\n@@ -151,6 +124,7 @@ struct nfp_eth_table {\n \t\tenum nfp_eth_media media; /**< Media type of the @interface */\n \n \t\tenum nfp_eth_fec fec;     /**< Forward Error Correction mode */\n+\t\tenum nfp_eth_fec act_fec; /**< Active Forward Error Correction mode */\n \t\tenum nfp_eth_aneg aneg;   /**< Auto negotiation mode */\n \n \t\tstruct rte_ether_addr mac_addr;  /**< Interface MAC address */\n@@ -159,17 +133,18 @@ struct nfp_eth_table {\n \t\t/** Id of interface within port (for split ports) */\n \t\tuint8_t label_subport;\n \n-\t\tint enabled;     /**< Enable port */\n-\t\tint tx_enabled;  /**< Enable TX */\n-\t\tint rx_enabled;  /**< Enable RX */\n+\t\tbool enabled;     /**< Enable port */\n+\t\tbool tx_enabled;  /**< Enable TX */\n+\t\tbool rx_enabled;  /**< Enable RX */\n+\t\tbool supp_aneg;   /**< Support auto negotiation */\n \n-\t\tint override_changed;  /**< Media reconfig pending */\n+\t\tbool override_changed;  /**< Media reconfig pending */\n \n \t\tuint8_t port_type;    /**< One of %PORT_* */\n \t\t/** Sum of lanes of all subports of this port */\n \t\tuint32_t port_lanes;\n \n-\t\tint is_split;   /**< Split port */\n+\t\tbool is_split;   /**< Split port */\n \n \t\tuint32_t fec_modes_supported;  /**< Bitmap of FEC modes supported */\n \t} ports[]; /**< Table of ports */\n@@ -177,8 +152,8 @@ struct nfp_eth_table {\n \n struct nfp_eth_table *nfp_eth_read_ports(struct nfp_cpp *cpp);\n \n-int nfp_eth_set_mod_enable(struct nfp_cpp *cpp, uint32_t idx, int enable);\n-int nfp_eth_set_configured(struct nfp_cpp *cpp, uint32_t idx, int configed);\n+int nfp_eth_set_mod_enable(struct nfp_cpp *cpp, uint32_t idx, bool enable);\n+int nfp_eth_set_configured(struct nfp_cpp *cpp, uint32_t idx, bool configured);\n int nfp_eth_set_fec(struct nfp_cpp *cpp, uint32_t idx, enum nfp_eth_fec mode);\n \n int nfp_nsp_read_eth_table(struct nfp_nsp *state, void *buf, size_t size);\n@@ -187,12 +162,13 @@ int nfp_nsp_write_eth_table(struct nfp_nsp *state, const void *buf,\n void nfp_nsp_config_set_state(struct nfp_nsp *state, void *entries,\n \t\tuint32_t idx);\n void nfp_nsp_config_clear_state(struct nfp_nsp *state);\n-void nfp_nsp_config_set_modified(struct nfp_nsp *state, int modified);\n+void nfp_nsp_config_set_modified(struct nfp_nsp *state, bool modified);\n void *nfp_nsp_config_entries(struct nfp_nsp *state);\n-int nfp_nsp_config_modified(struct nfp_nsp *state);\n+struct nfp_cpp *nfp_nsp_cpp(struct nfp_nsp *state);\n+bool nfp_nsp_config_modified(struct nfp_nsp *state);\n uint32_t nfp_nsp_config_idx(struct nfp_nsp *state);\n \n-static inline int\n+static inline bool\n nfp_eth_can_support_fec(struct nfp_eth_table_port *eth_port)\n {\n \treturn eth_port->fec_modes_supported != 0;\ndiff --git a/drivers/net/nfp/nfpcore/nfp_nsp_cmds.c b/drivers/net/nfp/nfpcore/nfp_nsp_cmds.c\nindex f656f200f4..46fa5467de 100644\n--- a/drivers/net/nfp/nfpcore/nfp_nsp_cmds.c\n+++ b/drivers/net/nfp/nfpcore/nfp_nsp_cmds.c\n@@ -3,12 +3,8 @@\n  * All rights reserved.\n  */\n \n-#include <stdio.h>\n-#include <rte_byteorder.h>\n-#include \"nfp_cpp.h\"\n #include \"nfp_logs.h\"\n #include \"nfp_nsp.h\"\n-#include \"nfp_nffw.h\"\n \n struct nsp_identify {\n \tuint8_t version[40];\ndiff --git a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c\nindex eb30d8e779..cc472907ca 100644\n--- a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c\n+++ b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c\n@@ -3,10 +3,6 @@\n  * All rights reserved.\n  */\n \n-#include <stdio.h>\n-#include <rte_common.h>\n-#include <rte_byteorder.h>\n-#include \"nfp_cpp.h\"\n #include \"nfp_logs.h\"\n #include \"nfp_nsp.h\"\n #include \"nfp_platform.h\"\n@@ -21,6 +17,7 @@\n #define NSP_ETH_PORT_PHYLABEL           GENMASK_ULL(59, 54)\n #define NSP_ETH_PORT_FEC_SUPP_BASER     RTE_BIT64(60)\n #define NSP_ETH_PORT_FEC_SUPP_RS        RTE_BIT64(61)\n+#define NSP_ETH_PORT_SUPP_ANEG          RTE_BIT64(63)\n \n #define NSP_ETH_PORT_LANES_MASK         rte_cpu_to_le_64(NSP_ETH_PORT_LANES)\n \n@@ -34,6 +31,7 @@\n #define NSP_ETH_STATE_OVRD_CHNG         RTE_BIT64(22)\n #define NSP_ETH_STATE_ANEG              GENMASK_ULL(25, 23)\n #define NSP_ETH_STATE_FEC               GENMASK_ULL(27, 26)\n+#define NSP_ETH_STATE_ACT_FEC           GENMASK_ULL(29, 28)\n \n #define NSP_ETH_CTRL_CONFIGURED         RTE_BIT64(0)\n #define NSP_ETH_CTRL_ENABLED            RTE_BIT64(1)\n@@ -54,26 +52,12 @@\n #define PORT_NONE               0xef\n #define PORT_OTHER              0xff\n \n-#define SPEED_10                10\n-#define SPEED_100               100\n-#define SPEED_1000              1000\n-#define SPEED_2500              2500\n-#define SPEED_5000              5000\n-#define SPEED_10000             10000\n-#define SPEED_14000             14000\n-#define SPEED_20000             20000\n-#define SPEED_25000             25000\n-#define SPEED_40000             40000\n-#define SPEED_50000             50000\n-#define SPEED_56000             56000\n-#define SPEED_100000            100000\n-\n enum nfp_eth_raw {\n \tNSP_ETH_RAW_PORT = 0,\n \tNSP_ETH_RAW_STATE,\n \tNSP_ETH_RAW_MAC,\n \tNSP_ETH_RAW_CONTROL,\n-\tNSP_ETH_NUM_RAW\n+\tNSP_ETH_NUM_RAW,\n };\n \n enum nfp_eth_rate {\n@@ -100,12 +84,12 @@ static const struct {\n \tenum nfp_eth_rate rate;\n \tuint32_t speed;\n } nsp_eth_rate_tbl[] = {\n-\t{ RATE_INVALID, 0, },\n-\t{ RATE_10M,     SPEED_10, },\n-\t{ RATE_100M,    SPEED_100, },\n-\t{ RATE_1G,      SPEED_1000, },\n-\t{ RATE_10G,     SPEED_10000, },\n-\t{ RATE_25G,     SPEED_25000, },\n+\t{ RATE_INVALID, RTE_ETH_SPEED_NUM_NONE, },\n+\t{ RATE_10M,     RTE_ETH_SPEED_NUM_10M, },\n+\t{ RATE_100M,    RTE_ETH_SPEED_NUM_100M, },\n+\t{ RATE_1G,      RTE_ETH_SPEED_NUM_1G, },\n+\t{ RATE_10G,     RTE_ETH_SPEED_NUM_10G, },\n+\t{ RATE_25G,     RTE_ETH_SPEED_NUM_25G, },\n };\n \n static uint32_t\n@@ -193,7 +177,14 @@ nfp_eth_port_translate(struct nfp_nsp *nsp,\n \tif (dst->fec_modes_supported != 0)\n \t\tdst->fec_modes_supported |= NFP_FEC_AUTO | NFP_FEC_DISABLED;\n \n-\tdst->fec = 1 << FIELD_GET(NSP_ETH_STATE_FEC, state);\n+\tdst->fec = FIELD_GET(NSP_ETH_STATE_FEC, state);\n+\tdst->act_fec = dst->fec;\n+\n+\tif (nfp_nsp_get_abi_ver_minor(nsp) < 33)\n+\t\treturn;\n+\n+\tdst->act_fec = FIELD_GET(NSP_ETH_STATE_ACT_FEC, state);\n+\tdst->supp_aneg = FIELD_GET(NSP_ETH_PORT_SUPP_ANEG, port);\n }\n \n static void\n@@ -222,7 +213,7 @@ nfp_eth_calc_port_geometry(struct nfp_eth_table *table)\n \t\t\t\t\t\ttable->ports[i].label_port,\n \t\t\t\t\t\ttable->ports[i].label_subport);\n \n-\t\t\ttable->ports[i].is_split = 1;\n+\t\t\ttable->ports[i].is_split = true;\n \t\t}\n \t}\n }\n@@ -233,6 +224,9 @@ nfp_eth_calc_port_type(struct nfp_eth_table_port *entry)\n \tif (entry->interface == NFP_INTERFACE_NONE) {\n \t\tentry->port_type = PORT_NONE;\n \t\treturn;\n+\t} else if (entry->interface == NFP_INTERFACE_RJ45) {\n+\t\tentry->port_type = PORT_TP;\n+\t\treturn;\n \t}\n \n \tif (entry->media == NFP_MEDIA_FIBRE)\n@@ -251,7 +245,6 @@ nfp_eth_read_ports_real(struct nfp_nsp *nsp)\n \tuint32_t table_sz;\n \tstruct nfp_eth_table *table;\n \tunion eth_table_entry *entries;\n-\tconst struct rte_ether_addr *mac;\n \n \tentries = malloc(NSP_ETH_TABLE_SIZE);\n \tif (entries == NULL)\n@@ -264,16 +257,9 @@ nfp_eth_read_ports_real(struct nfp_nsp *nsp)\n \t\tgoto err;\n \t}\n \n-\t/*\n-\t * The NFP3800 NIC support 8 ports, but only 2 ports are valid,\n-\t * the rest 6 ports mac are all 0, ensure we don't use these port\n-\t */\n-\tfor (i = 0; i < NSP_ETH_MAX_COUNT; i++) {\n-\t\tmac = (const struct rte_ether_addr *)entries[i].mac_addr;\n-\t\tif ((entries[i].port & NSP_ETH_PORT_LANES_MASK) != 0 &&\n-\t\t\t\t!rte_is_zero_ether_addr(mac))\n+\tfor (i = 0; i < NSP_ETH_MAX_COUNT; i++)\n+\t\tif ((entries[i].port & NSP_ETH_PORT_LANES_MASK) != 0)\n \t\t\tcnt++;\n-\t}\n \n \t/*\n \t * Some versions of flash will give us 0 instead of port count. For\n@@ -294,11 +280,8 @@ nfp_eth_read_ports_real(struct nfp_nsp *nsp)\n \tmemset(table, 0, table_sz);\n \ttable->count = cnt;\n \tfor (i = 0, j = 0; i < NSP_ETH_MAX_COUNT; i++) {\n-\t\tmac = (const struct rte_ether_addr *)entries[i].mac_addr;\n-\t\tif ((entries[i].port & NSP_ETH_PORT_LANES_MASK) != 0 &&\n-\t\t\t\t!rte_is_zero_ether_addr(mac))\n-\t\t\tnfp_eth_port_translate(nsp, &entries[i], i,\n-\t\t\t\t\t&table->ports[j++]);\n+\t\tif ((entries[i].port & NSP_ETH_PORT_LANES_MASK) != 0)\n+\t\t\tnfp_eth_port_translate(nsp, &entries[i], i, &table->ports[j++]);\n \t}\n \n \tnfp_eth_calc_port_geometry(table);\n@@ -440,7 +423,7 @@ nfp_eth_config_commit_end(struct nfp_nsp *nsp)\n int\n nfp_eth_set_mod_enable(struct nfp_cpp *cpp,\n \t\tuint32_t idx,\n-\t\tint enable)\n+\t\tbool enable)\n {\n \tuint64_t reg;\n \tstruct nfp_nsp *nsp;\n@@ -448,7 +431,7 @@ nfp_eth_set_mod_enable(struct nfp_cpp *cpp,\n \n \tnsp = nfp_eth_config_start(cpp, idx);\n \tif (nsp == NULL)\n-\t\treturn -1;\n+\t\treturn -EIO;\n \n \tentries = nfp_nsp_config_entries(nsp);\n \n@@ -460,7 +443,7 @@ nfp_eth_set_mod_enable(struct nfp_cpp *cpp,\n \t\treg |= FIELD_PREP(NSP_ETH_CTRL_ENABLED, enable);\n \t\tentries[idx].control = rte_cpu_to_le_64(reg);\n \n-\t\tnfp_nsp_config_set_modified(nsp, 1);\n+\t\tnfp_nsp_config_set_modified(nsp, true);\n \t}\n \n \treturn nfp_eth_config_commit_end(nsp);\n@@ -484,7 +467,7 @@ nfp_eth_set_mod_enable(struct nfp_cpp *cpp,\n int\n nfp_eth_set_configured(struct nfp_cpp *cpp,\n \t\tuint32_t idx,\n-\t\tint configured)\n+\t\tbool configured)\n {\n \tuint64_t reg;\n \tstruct nfp_nsp *nsp;\n@@ -513,7 +496,7 @@ nfp_eth_set_configured(struct nfp_cpp *cpp,\n \t\treg |= FIELD_PREP(NSP_ETH_CTRL_CONFIGURED, configured);\n \t\tentries[idx].control = rte_cpu_to_le_64(reg);\n \n-\t\tnfp_nsp_config_set_modified(nsp, 1);\n+\t\tnfp_nsp_config_set_modified(nsp, true);\n \t}\n \n \treturn nfp_eth_config_commit_end(nsp);\n@@ -551,7 +534,7 @@ nfp_eth_set_bit_config(struct nfp_nsp *nsp,\n \n \tentries[idx].control |= rte_cpu_to_le_64(ctrl_bit);\n \n-\tnfp_nsp_config_set_modified(nsp, 1);\n+\tnfp_nsp_config_set_modified(nsp, true);\n \n \treturn 0;\n }\n",
    "prefixes": [
        "v4",
        "18/26"
    ]
}