get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 136300,
    "url": "http://patches.dpdk.org/api/patches/136300/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20240202030415.739638-2-chaoyong.he@corigine.com/",
    "project": {
        "id": 1,
        "url": "http://patches.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": "<20240202030415.739638-2-chaoyong.he@corigine.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20240202030415.739638-2-chaoyong.he@corigine.com",
    "date": "2024-02-02T03:04:13",
    "name": "[v2,1/3] net/nfp: add synchronize module",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "a484e6e869c5e318dc33d11ed814cd9979d493ba",
    "submitter": {
        "id": 2554,
        "url": "http://patches.dpdk.org/api/people/2554/?format=api",
        "name": "Chaoyong He",
        "email": "chaoyong.he@corigine.com"
    },
    "delegate": {
        "id": 319,
        "url": "http://patches.dpdk.org/api/users/319/?format=api",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@amd.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20240202030415.739638-2-chaoyong.he@corigine.com/mbox/",
    "series": [
        {
            "id": 30978,
            "url": "http://patches.dpdk.org/api/series/30978/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=30978",
            "date": "2024-02-02T03:04:12",
            "name": "enhance NFP service framework",
            "version": 2,
            "mbox": "http://patches.dpdk.org/series/30978/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/136300/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/136300/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 11DA243A49;\n\tFri,  2 Feb 2024 04:04:55 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 5372E42D28;\n\tFri,  2 Feb 2024 04:04:49 +0100 (CET)",
            "from NAM10-MW2-obe.outbound.protection.outlook.com\n (mail-mw2nam10on2094.outbound.protection.outlook.com [40.107.94.94])\n by mails.dpdk.org (Postfix) with ESMTP id AC3E440268\n for <dev@dpdk.org>; Fri,  2 Feb 2024 04:04:47 +0100 (CET)",
            "from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5)\n by SN7PR13MB6177.namprd13.prod.outlook.com (2603:10b6:806:2e3::15)\n with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.30; Fri, 2 Feb\n 2024 03:04:45 +0000",
            "from SJ0PR13MB5545.namprd13.prod.outlook.com\n ([fe80::8e02:f738:570a:f8aa]) by SJ0PR13MB5545.namprd13.prod.outlook.com\n ([fe80::8e02:f738:570a:f8aa%7]) with mapi id 15.20.7249.024; Fri, 2 Feb 2024\n 03:04:45 +0000"
        ],
        "ARC-Seal": "i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;\n b=TG2vQgftARknsy0L2DNuCscRHx68nNtqr+ZOzbNJdw1GRZvUb1Ly6E3uQ+AUQ+7BD3YcuThp9CjG4Vlmu0AK4MrTah22zQcCi40PpYpaPMbE1pVIbc8m5Qs3q7S9f8Sf1Fzg2VnlsbCOjnlOr+eo7v32ECU6osD56TVE9N2/5HkbYBJLnxP0OB9z6lCE6SzHr5K0xscizQeCGAO4y+Dpa3XN6zX13r8WDxlrAjErkPqKYK5UD4gSurdVs1i5mlUk5dTDHrFT8a3IzGplfO2EaGd6K06OJlx0/HW4d+EmSw8WYHWMnZitnFcT8wgqMG8QLrJUm7xvVT11OEoF5qE3YQ==",
        "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=EDdidAtLEGr6J7F9yLfLTZ8UHNmJvBfxSXmNem/GJfk=;\n b=NufAKxM7lqbkp7HANFAEEym/WacMt/wqzGzD+1E6Era5vi3YpjXAL8OtxY/92TsI4Z8pan0DrW0dM8jAVCNeEzks0LNNR/ExpowU2v6n+MwtbylzIrrafAbdgw8Ga9GAMKM6rT7iXcmS1oQ29LIJ+4fwxZsxywdygRnhctwSzCVIUiBIYLpQ4GFL6pmxAySM3l9tYxA1pAhCpXd3qmi/yxVIABSuD/AxtmpLcvJ7N9RhJRoqNXP3DeD/d0PXez4/LHiEUUqREeST6BHhFkQbPei9mVZCaWQVhroRj9+HUJzQ+AJz/wJyXJFzHrTHK/ws2MpPHrIAKGeEAJgfSNU93w==",
        "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=EDdidAtLEGr6J7F9yLfLTZ8UHNmJvBfxSXmNem/GJfk=;\n b=GE4PQSpyLs4i3lL5SidpadiCH3Gc7//Mv24Xr9XtmXH9W1Eje0T3usQKMCcM5QDfA6Xqk+sKMCI1bJZkFmTWSjlpclxErhOuqZjxQMfqHPBKhs3mNfRHA41ZWtS8MnDQ4zaDFZq9AaQ5o7+oxOe77f0z6PH2e0J1To2wAtdykbU=",
        "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": "oss-drivers@corigine.com, Long Wu <long.wu@corigine.com>,\n Chaoyong He <chaoyong.he@corigine.com>,\n Peng Zhang <peng.zhang@corigine.com>",
        "Subject": "[PATCH v2 1/3] net/nfp: add synchronize module",
        "Date": "Fri,  2 Feb 2024 11:04:13 +0800",
        "Message-Id": "<20240202030415.739638-2-chaoyong.he@corigine.com>",
        "X-Mailer": "git-send-email 2.39.1",
        "In-Reply-To": "<20240202030415.739638-1-chaoyong.he@corigine.com>",
        "References": "<20240124092541.2011874-1-chaoyong.he@corigine.com>\n <20240202030415.739638-1-chaoyong.he@corigine.com>",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-ClientProxiedBy": "BYAPR05CA0004.namprd05.prod.outlook.com\n (2603:10b6:a03:c0::17) 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_|SN7PR13MB6177:EE_",
        "X-MS-Office365-Filtering-Correlation-Id": "59109f1b-f34a-4c25-17b0-08dc239bb5af",
        "X-MS-Exchange-SenderADCheck": "1",
        "X-MS-Exchange-AntiSpam-Relay": "0",
        "X-Microsoft-Antispam": "BCL:0;",
        "X-Microsoft-Antispam-Message-Info": "\n AT/Y5NU1wTNcrAggBH9SbPP5uMKzUq1SYaDoKv8AL2g2d85wRofsNQkHkynxEPmIZ+KrQwe4hSs5eszAr5lPp7BZ0WjJfUkH0nIYDEcFHN0OeavhLg0K1a5pyZAi9PrGWkBHcFUUGj6ufEV3XyCf3G5jJR6t6aYXxzFpAqSCPCMKap7zmqGxPQzFQ1nx+bLLdydiINdCg+icnCiC0/gYppjFpbLt4/5kB6KyqONm8fmCYcbzgUfXMgIQXb4/d8SMtudAX9WDIRhhvp2xyz/lemgxkKD9TcaNGGpRJXtcR8UZsZQZvWPXZt3VyPbVimfJg6pTqFUMPtNN7ASL7AMRRsuJxLzUXtHADH/GuzGMLY7cm74zxnNBZ9YshfsJjFr4wFrsTv8So53Z97FPW2+frXQ2EO+q+mXp8nxxJcn/DbDNbeuTbWWPRiLMbzTB177787/szReXA99faMa1W0DhWUm+F6m+VJb4jDaHtLiXYoN/oTxMWO8Jker+ffSIDsgbBpdxeZgiHpOpzxFhn17poBIHyXrFwUnxjtUEntidHbTPp8ci/9LidAfkaDY9dmtKBn93yF/XYsl1RHNNVk01nKItLUE19XcBaW+/do/V4PxWv84UZNrwqm8raV1NkVpo",
        "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)(366004)(136003)(376002)(396003)(39840400004)(346002)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(41300700001)(1076003)(107886003)(26005)(2616005)(6916009)(38350700005)(316002)(36756003)(478600001)(6512007)(6486002)(83380400001)(52116002)(6506007)(6666004)(38100700002)(86362001)(2906002)(5660300002)(30864003)(66946007)(54906003)(66476007)(66556008)(8936002)(44832011)(8676002)(4326008);\n DIR:OUT; SFP:1102;",
        "X-MS-Exchange-AntiSpam-MessageData-ChunkCount": "1",
        "X-MS-Exchange-AntiSpam-MessageData-0": "\n ssT5kUUZZOA7DfuvcYumF1KfX9nf9DnQ2T32FclX+FgdB9PvmhTo2karT1w5DzGknUGmOJCMA9yiLeWzcvN5NyIOxWM3vsL75i9jQgjb9aie4CiIEXXK9ctSAmz/GmDit8uGFRp94xwsx4AyPDhGq+TcFfNntMJC0RBZ/7NvjsmRZYcWgoki5sF+HXseveHRhCLoV6qmdTSwIqjJbr2/H4kH8KWfjbry9ynrQW+ly80Gdq08x6Xi9gGKNrwXg8rWS/A1vwPOFlRhQw/IrPibkzsn7ErvyHhbhZe0wI5G5zxwc7VSlxuQHce6iAFT7ka3FMSd08R3eVWhSzVjvDMngUUBsbniMP+PvMwEEjlyDRt2Zr2prmghs50+O2m1UYFCpig/npPAYYQSbkzbNemTPqoXvYUJGeNc1SlAKvAF10+OSGtoDSuorPAD+OS7/9wmnjkdzpjakKc3NCJyQQtElLIKeGnQYWcl8hpogdkLc61ZXwFH5KGb4nEudCU7X8uO6He6Sp7WlKkL0NZ02fa62jGYWZXIZVK/ioat2n2Q92Q9wc5l52nBL7rAVMUoF03+ChPDzFc1UV9Q8Ma+2aR8NumAM3wlNvLygDTT1NlHSlnCXpE5eL1A1VV18gMSFJaqrmiIvAFASd4A1EbsBn7Rix7lYZpNMgTHaA2tUx5HZQ5yYhhDurNav3wZ9AMKFYU7l0esBezAcXVc8dPC+ev5gFzzAXqgT2V+aeMHGmprW48f6yGyQJgSH2+5YdmrfYNKFg13HFdtpEtSujLmWkuRqGqjHz7oggPaiA/qX2g3PsvLEaXp9hKy/5fZrsceVO97d1AD0+yrrwziac8ZywZqTOfjR+MR7eySNlMF7lXhvxsX7NGoZE2G/FXlxmozcuaPs2uVISNkOHXVL4ptohfOEcTqf/KqnxW2EOMMD0AKID22Zh1PcOuHhAfPh5PTZLXn0W5SmiiD02CSUMHHRN9t6n4YPacvi2/G2kzhoT/ZiW170gOKRHqbWSjt5Tf6/y4VFYwmZYQG1LQA0JmA6c6r8cx0RQcXD+kFjsyQ5Ud5Ebbrcu+32RU3rKBBRB2UlFsGnghfqdkWhlDgqOMY8qQTkWyMQ8oobwkRas2+YTuVzTXreckJ1/Wab6Sv0eeugAFrCZkfqjAel2t4vAm6t0ZfxE0GlK0MMI0SY09yIrnWWVOShnPUke+5Zgn+nIoUouiM2WCd8CIDLRwC40U3FdUHpis1rCMBBoKYdaz/lfaZbk8cyzp9ndDKGBe99vAWDc9uBoDomAIwaKv+ZjYngH1LJuKK/7vc57/WVBZZ/FV0x0jvj7qKXNaLdE8/iwaeCcTGd7DfsGN6hvgc8Sz0doK87oKDL8wn+aHbJ4RkTkd9/o8cFktXjkn9cex61OGNxgigFJLdwXzCIqK7eOXQ56hiA7Bek5XB2K/U4FgowgYTjPFRijYW79llfgl4h/8XdgDgltuiHhV5s1pQZi1nRb5Jt0s/yfE+tOKT/QnlOe3gi9b2ZcEkO5ZnV8SwIX7ffwKOXtU30EVVJrbUw9tFTUU2rkKDACopJPAr1kr7sZ9S3Adeb3HonEDG+VWZT1eUrKMEjdUFHIb5VF4HzY4s1AUx0g==",
        "X-OriginatorOrg": "corigine.com",
        "X-MS-Exchange-CrossTenant-Network-Message-Id": "\n 59109f1b-f34a-4c25-17b0-08dc239bb5af",
        "X-MS-Exchange-CrossTenant-AuthSource": "SJ0PR13MB5545.namprd13.prod.outlook.com",
        "X-MS-Exchange-CrossTenant-AuthAs": "Internal",
        "X-MS-Exchange-CrossTenant-OriginalArrivalTime": "02 Feb 2024 03:04:45.7444 (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 8bwwP5mK6wlldgVMh6yc9RWBwaudZCvObq7XULiJDXloh/Yysmm8uqkDm0eTPJld7wgjgjRXulJc6asM0ugbY4dzrFENhyY0LGEpeC54EeU=",
        "X-MS-Exchange-Transport-CrossTenantHeadersStamped": "SN7PR13MB6177",
        "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": "From: Long Wu <long.wu@corigine.com>\n\nPMD has some information that needs synchronized:\n1. Between devices in one process.\n2. Between multiple processes for one device, before creating\n\"rte_eth_device\".\n3. Between multiple processes for one device, after creating\n\"rte_eth_device\".\n\nThe final one is already support by framework\n(eth_dev->data->dev_private), and this patch aims to support\nthe first two cases by adding a synchronize module.\n\nSigned-off-by: Long Wu <long.wu@corigine.com>\nReviewed-by: Chaoyong He <chaoyong.he@corigine.com>\nReviewed-by: Peng Zhang <peng.zhang@corigine.com>\n---\n drivers/net/nfp/meson.build        |   1 +\n drivers/net/nfp/nfp_ethdev.c       |  31 ++-\n drivers/net/nfp/nfp_net_common.h   |   4 +\n drivers/net/nfp/nfpcore/nfp_sync.c | 382 +++++++++++++++++++++++++++++\n drivers/net/nfp/nfpcore/nfp_sync.h |  29 +++\n 5 files changed, 444 insertions(+), 3 deletions(-)\n create mode 100644 drivers/net/nfp/nfpcore/nfp_sync.c\n create mode 100644 drivers/net/nfp/nfpcore/nfp_sync.h",
    "diff": "diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build\nindex 46be6f60cd..c625355d7a 100644\n--- a/drivers/net/nfp/meson.build\n+++ b/drivers/net/nfp/meson.build\n@@ -26,6 +26,7 @@ sources = files(\n         'nfpcore/nfp_nsp_eth.c',\n         'nfpcore/nfp_resource.c',\n         'nfpcore/nfp_rtsym.c',\n+        'nfpcore/nfp_sync.c',\n         'nfpcore/nfp_target.c',\n         'nfpcore/nfp6000_pcie.c',\n         'nfp_cpp_bridge.c',\ndiff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c\nindex 07cd32881c..3ece806487 100644\n--- a/drivers/net/nfp/nfp_ethdev.c\n+++ b/drivers/net/nfp/nfp_ethdev.c\n@@ -19,6 +19,7 @@\n #include \"nfpcore/nfp_nsp.h\"\n #include \"nfpcore/nfp6000_pcie.h\"\n #include \"nfpcore/nfp_resource.h\"\n+#include \"nfpcore/nfp_sync.h\"\n \n #include \"nfp_cpp_bridge.h\"\n #include \"nfp_ipsec.h\"\n@@ -551,6 +552,7 @@ nfp_pf_uninit(struct nfp_pf_dev *pf_dev)\n \tfree(pf_dev->nfp_eth_table);\n \tfree(pf_dev->hwinfo);\n \tnfp_cpp_free(pf_dev->cpp);\n+\tnfp_sync_free(pf_dev->sync);\n \trte_free(pf_dev);\n }\n \n@@ -559,6 +561,7 @@ nfp_pf_secondary_uninit(struct nfp_pf_dev *pf_dev)\n {\n \tfree(pf_dev->sym_tbl);\n \tnfp_cpp_free(pf_dev->cpp);\n+\tnfp_sync_free(pf_dev->sync);\n \trte_free(pf_dev);\n \n \treturn 0;\n@@ -1612,6 +1615,7 @@ nfp_net_speed_capa_get(struct nfp_pf_dev *pf_dev,\n static int\n nfp_pf_init(struct rte_pci_device *pci_dev)\n {\n+\tvoid *sync;\n \tuint32_t i;\n \tuint32_t id;\n \tint ret = 0;\n@@ -1652,6 +1656,13 @@ nfp_pf_init(struct rte_pci_device *pci_dev)\n \t\treturn -ENOMEM;\n \t}\n \n+\tsync = nfp_sync_alloc();\n+\tif (sync == NULL) {\n+\t\tPMD_INIT_LOG(ERR, \"Failed to alloc sync zone.\");\n+\t\tret = -ENOMEM;\n+\t\tgoto pf_cleanup;\n+\t}\n+\n \t/*\n \t * When device bound to UIO, the device could be used, by mistake,\n \t * by two DPDK apps, and the UIO driver does not avoid it. This\n@@ -1667,7 +1678,7 @@ nfp_pf_init(struct rte_pci_device *pci_dev)\n \tif (cpp == NULL) {\n \t\tPMD_INIT_LOG(ERR, \"A CPP handle can not be obtained\");\n \t\tret = -EIO;\n-\t\tgoto pf_cleanup;\n+\t\tgoto sync_free;\n \t}\n \n \thwinfo = nfp_hwinfo_read(cpp);\n@@ -1734,6 +1745,7 @@ nfp_pf_init(struct rte_pci_device *pci_dev)\n \tpf_dev->sym_tbl = sym_tbl;\n \tpf_dev->pci_dev = pci_dev;\n \tpf_dev->nfp_eth_table = nfp_eth_table;\n+\tpf_dev->sync = sync;\n \n \t/* Get the speed capability */\n \tfor (i = 0; i < nfp_eth_table->count; i++) {\n@@ -1815,6 +1827,8 @@ nfp_pf_init(struct rte_pci_device *pci_dev)\n \tfree(hwinfo);\n cpp_cleanup:\n \tnfp_cpp_free(cpp);\n+sync_free:\n+\tnfp_sync_free(sync);\n pf_cleanup:\n \trte_free(pf_dev);\n \n@@ -1878,6 +1892,7 @@ nfp_secondary_init_app_fw_nic(struct nfp_pf_dev *pf_dev)\n static int\n nfp_pf_secondary_init(struct rte_pci_device *pci_dev)\n {\n+\tvoid *sync;\n \tint ret = 0;\n \tstruct nfp_cpp *cpp;\n \tuint8_t function_id;\n@@ -1910,6 +1925,13 @@ nfp_pf_secondary_init(struct rte_pci_device *pci_dev)\n \t\treturn -ENOMEM;\n \t}\n \n+\tsync = nfp_sync_alloc();\n+\tif (sync == NULL) {\n+\t\tPMD_INIT_LOG(ERR, \"Failed to alloc sync zone.\");\n+\t\tret = -ENOMEM;\n+\t\tgoto pf_cleanup;\n+\t}\n+\n \t/*\n \t * When device bound to UIO, the device could be used, by mistake,\n \t * by two DPDK apps, and the UIO driver does not avoid it. This\n@@ -1925,7 +1947,7 @@ nfp_pf_secondary_init(struct rte_pci_device *pci_dev)\n \tif (cpp == NULL) {\n \t\tPMD_INIT_LOG(ERR, \"A CPP handle can not be obtained\");\n \t\tret = -EIO;\n-\t\tgoto pf_cleanup;\n+\t\tgoto sync_free;\n \t}\n \n \t/*\n@@ -1936,7 +1958,7 @@ nfp_pf_secondary_init(struct rte_pci_device *pci_dev)\n \tif (sym_tbl == NULL) {\n \t\tPMD_INIT_LOG(ERR, \"Something is wrong with the firmware symbol table\");\n \t\tret = -EIO;\n-\t\tgoto pf_cleanup;\n+\t\tgoto sync_free;\n \t}\n \n \t/* Read the app ID of the firmware loaded */\n@@ -1954,6 +1976,7 @@ nfp_pf_secondary_init(struct rte_pci_device *pci_dev)\n \tpf_dev->cpp = cpp;\n \tpf_dev->sym_tbl = sym_tbl;\n \tpf_dev->pci_dev = pci_dev;\n+\tpf_dev->sync = sync;\n \n \t/* Call app specific init code now */\n \tswitch (app_fw_id) {\n@@ -1983,6 +2006,8 @@ nfp_pf_secondary_init(struct rte_pci_device *pci_dev)\n \n sym_tbl_cleanup:\n \tfree(sym_tbl);\n+sync_free:\n+\tnfp_sync_free(sync);\n pf_cleanup:\n \trte_free(pf_dev);\n \ndiff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h\nindex 5648ad32d8..3a441f49f6 100644\n--- a/drivers/net/nfp/nfp_net_common.h\n+++ b/drivers/net/nfp/nfp_net_common.h\n@@ -12,6 +12,7 @@\n #include <nfp_dev.h>\n #include <rte_spinlock.h>\n \n+#include \"nfpcore/nfp_sync.h\"\n #include \"nfp_net_ctrl.h\"\n \n /* Interrupt definitions */\n@@ -109,6 +110,9 @@ struct nfp_pf_dev {\n \n \t/** Supported speeds bitmap */\n \tuint32_t speed_capa;\n+\n+\t/** Synchronized info */\n+\tstruct nfp_sync *sync;\n };\n \n #define NFP_NET_FLOW_LIMIT    1024\ndiff --git a/drivers/net/nfp/nfpcore/nfp_sync.c b/drivers/net/nfp/nfpcore/nfp_sync.c\nnew file mode 100644\nindex 0000000000..8bc38d6585\n--- /dev/null\n+++ b/drivers/net/nfp/nfpcore/nfp_sync.c\n@@ -0,0 +1,382 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright (c) 2024 Corigine, Inc.\n+ * All rights reserved.\n+ */\n+\n+#include \"nfp_sync.h\"\n+\n+#include <rte_dev.h>\n+#include <rte_malloc.h>\n+#include <rte_memzone.h>\n+#include <rte_spinlock.h>\n+\n+#include \"nfp_logs.h\"\n+\n+#define NFP_SYNC_ELEMENT_MAX    8\n+#define NFP_SYNC_PCI_MAX        32\n+\n+struct nfp_sync_element {\n+\tuint16_t count;\n+\t/** Element ID, use ASCII - SYN<> */\n+\tuint32_t magic;\n+\tvoid *handle;\n+};\n+\n+struct nfp_sync_common {\n+\tchar pci_name[PCI_PRI_STR_SIZE + 1];\n+\tuint16_t avail;\n+\tstruct nfp_sync_element element[NFP_SYNC_ELEMENT_MAX];\n+};\n+\n+struct nfp_sync {\n+\trte_spinlock_t spinlock;\n+\n+\tuint16_t alloc_count;\n+\n+\tstruct nfp_sync_common process;\n+\n+\tstruct nfp_sync_common pci[NFP_SYNC_PCI_MAX];\n+\n+\tconst struct rte_memzone *mz;\n+};\n+\n+struct nfp_sync *\n+nfp_sync_alloc(void)\n+{\n+\tuint16_t i;\n+\tstruct nfp_sync *sync;\n+\tconst struct rte_memzone *mz;\n+\n+\tmz = rte_memzone_lookup(\"nfp_sync\");\n+\tif (mz != NULL) {\n+\t\tsync = mz->addr;\n+\t\tsync->alloc_count++;\n+\n+\t\treturn sync;\n+\t}\n+\n+\tmz = rte_memzone_reserve(\"nfp_sync\",  sizeof(*sync), SOCKET_ID_ANY,\n+\t\t\tRTE_MEMZONE_SIZE_HINT_ONLY);\n+\tif (mz == NULL)\n+\t\treturn NULL;\n+\n+\tsync = mz->addr;\n+\n+\tmemset(sync, 0, sizeof(*sync));\n+\n+\trte_spinlock_init(&sync->spinlock);\n+\tsync->alloc_count = 1;\n+\tsync->mz = mz;\n+\n+\tfor (i = 0; i < NFP_SYNC_PCI_MAX; i++)\n+\t\tsync->pci[i].avail = NFP_SYNC_ELEMENT_MAX;\n+\n+\tsync->process.avail = NFP_SYNC_ELEMENT_MAX;\n+\n+\treturn sync;\n+}\n+\n+void\n+nfp_sync_free(struct nfp_sync *sync)\n+{\n+\tuint16_t i;\n+\n+\trte_spinlock_lock(&sync->spinlock);\n+\n+\tsync->alloc_count--;\n+\tif (sync->alloc_count != 0) {\n+\t\trte_spinlock_unlock(&sync->spinlock);\n+\t\treturn;\n+\t}\n+\n+\tif (sync->process.avail != NFP_SYNC_ELEMENT_MAX)\n+\t\tPMD_DRV_LOG(ERR, \"Sync process handle residue\");\n+\n+\tfor (i = 0; i < NFP_SYNC_PCI_MAX; i++) {\n+\t\tif (sync->pci[i].avail != NFP_SYNC_ELEMENT_MAX)\n+\t\t\tPMD_DRV_LOG(ERR, \"Sync %s pci handle residue\",\n+\t\t\t\t\tsync->pci[i].pci_name);\n+\t}\n+\n+\trte_spinlock_unlock(&sync->spinlock);\n+\n+\trte_memzone_free(sync->mz);\n+}\n+\n+static void *\n+nfp_sync_element_alloc(struct nfp_sync_element *element,\n+\t\tuint32_t magic,\n+\t\tuint32_t size)\n+{\n+\tvoid *handle;\n+\n+\thandle = rte_zmalloc(NULL, size, 0);\n+\tif (handle == NULL)\n+\t\treturn NULL;\n+\n+\telement->handle = handle;\n+\telement->count = 1;\n+\telement->magic = magic;\n+\n+\treturn handle;\n+}\n+\n+static void\n+nfp_sync_element_free(struct nfp_sync_element *element,\n+\t\tvoid *handle)\n+{\n+\telement->count--;\n+\tif (element->count != 0)\n+\t\treturn;\n+\n+\trte_free(handle);\n+\telement->handle = NULL;\n+\telement->magic = 0;\n+}\n+\n+static void *\n+nfp_sync_common_handle_alloc(struct nfp_sync_common *common,\n+\t\tuint32_t magic,\n+\t\tuint32_t size)\n+{\n+\tuint16_t i;\n+\tvoid *handle = NULL;\n+\tuint16_t avail_slot = NFP_SYNC_ELEMENT_MAX;\n+\n+\tfor (i = 0; i < NFP_SYNC_ELEMENT_MAX; i++) {\n+\t\tif (common->element[i].magic != magic)\n+\t\t\tcontinue;\n+\n+\t\tcommon->element[i].count++;\n+\n+\t\treturn common->element[i].handle;\n+\t}\n+\n+\tif (common->avail == 0)\n+\t\treturn NULL;\n+\n+\tfor (i = 0; i < NFP_SYNC_ELEMENT_MAX; i++) {\n+\t\tif (common->element[i].magic == 0) {\n+\t\t\tavail_slot = i;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\thandle = nfp_sync_element_alloc(&common->element[avail_slot], magic, size);\n+\tif (handle == NULL)\n+\t\treturn NULL;\n+\n+\tcommon->avail--;\n+\n+\treturn handle;\n+}\n+\n+static void\n+nfp_sync_common_handle_free(struct nfp_sync_common *common,\n+\t\tvoid *handle)\n+{\n+\tuint16_t i;\n+\n+\tif (common->avail == NFP_SYNC_ELEMENT_MAX)\n+\t\treturn;\n+\n+\tfor (i = 0; i < NFP_SYNC_ELEMENT_MAX; i++) {\n+\t\tif (common->element[i].handle == handle)\n+\t\t\tbreak;\n+\t}\n+\n+\tif (i == NFP_SYNC_ELEMENT_MAX)\n+\t\treturn;\n+\n+\tnfp_sync_element_free(&common->element[i], handle);\n+\n+\tif (common->element[i].count == 0)\n+\t\tcommon->avail++;\n+}\n+\n+static void *\n+nfp_sync_process_inner_handle_alloc(struct nfp_sync *sync,\n+\t\tuint32_t magic,\n+\t\tuint32_t size)\n+{\n+\tvoid *handle = NULL;\n+\n+\trte_spinlock_lock(&sync->spinlock);\n+\n+\thandle = nfp_sync_common_handle_alloc(&sync->process, magic, size);\n+\tif (handle == NULL)\n+\t\tPMD_DRV_LOG(ERR, \"Process handle alloc failed\");\n+\n+\trte_spinlock_unlock(&sync->spinlock);\n+\n+\treturn handle;\n+}\n+\n+static void\n+nfp_sync_process_inner_handle_free(struct nfp_sync *sync,\n+\t\tvoid *handle)\n+{\n+\trte_spinlock_lock(&sync->spinlock);\n+\n+\tnfp_sync_common_handle_free(&sync->process, handle);\n+\n+\trte_spinlock_unlock(&sync->spinlock);\n+}\n+\n+static uint16_t\n+nfp_sync_process_handle_count_get(struct nfp_sync *sync,\n+\t\tvoid *handle)\n+{\n+\tuint16_t i;\n+\tuint16_t count = 0;\n+\n+\trte_spinlock_lock(&sync->spinlock);\n+\n+\tfor (i = 0; i < NFP_SYNC_ELEMENT_MAX; i++) {\n+\t\tif (sync->process.element[i].handle == handle) {\n+\t\t\tcount = sync->process.element[i].count;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\trte_spinlock_unlock(&sync->spinlock);\n+\n+\treturn count;\n+}\n+\n+static void *\n+nfp_sync_pci_inner_handle_alloc(struct nfp_sync *sync,\n+\t\tconst char *pci_name,\n+\t\tuint32_t magic,\n+\t\tuint32_t size)\n+{\n+\tuint16_t i;\n+\tvoid *handle = NULL;\n+\tuint16_t pci_avail_id = NFP_SYNC_PCI_MAX;\n+\n+\trte_spinlock_lock(&sync->spinlock);\n+\n+\tfor (i = 0; i < NFP_SYNC_PCI_MAX; i++) {\n+\t\tif (strcmp(pci_name, sync->pci[i].pci_name) == 0) {\n+\t\t\tpci_avail_id = i;\n+\t\t\tgoto common_alloc;\n+\t\t}\n+\t}\n+\n+\tfor (i = 0; i < NFP_SYNC_PCI_MAX; i++) {\n+\t\tif (strlen(sync->pci[i].pci_name) == 0) {\n+\t\t\tpci_avail_id = i;\n+\t\t\tstrcpy(sync->pci[pci_avail_id].pci_name, pci_name);\n+\t\t\tgoto common_alloc;\n+\t\t}\n+\t}\n+\n+\trte_spinlock_unlock(&sync->spinlock);\n+\n+\treturn NULL;\n+\n+common_alloc:\n+\thandle = nfp_sync_common_handle_alloc(&sync->pci[pci_avail_id],\n+\t\t\tmagic, size);\n+\tif (handle == NULL)\n+\t\tPMD_DRV_LOG(ERR, \"PCI handle alloc failed\");\n+\n+\trte_spinlock_unlock(&sync->spinlock);\n+\n+\treturn handle;\n+}\n+\n+static void\n+nfp_sync_pci_inner_handle_free(struct nfp_sync *sync,\n+\t\tconst char *pci_name,\n+\t\tvoid *handle)\n+{\n+\tuint16_t i;\n+\tchar *name_tmp;\n+\n+\trte_spinlock_lock(&sync->spinlock);\n+\n+\tfor (i = 0; i < NFP_SYNC_PCI_MAX; i++) {\n+\t\tname_tmp = sync->pci[i].pci_name;\n+\t\tif (strlen(name_tmp) != 0 && strcmp(pci_name, name_tmp) == 0) {\n+\t\t\tnfp_sync_common_handle_free(&sync->pci[i], handle);\n+\t\t\tif (sync->pci[i].avail == NFP_SYNC_ELEMENT_MAX)\n+\t\t\t\tname_tmp[0] = 0;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\trte_spinlock_unlock(&sync->spinlock);\n+}\n+\n+static uint16_t\n+nfp_sync_pci_handle_count_get(struct nfp_sync *sync,\n+\t\tconst char *pci_name,\n+\t\tvoid *handle)\n+{\n+\tuint16_t i;\n+\tuint16_t count = 0;\n+\tstruct nfp_sync_common *pci_common;\n+\n+\trte_spinlock_lock(&sync->spinlock);\n+\n+\tfor (i = 0; i < NFP_SYNC_PCI_MAX; i++) {\n+\t\tif (strcmp(sync->pci[i].pci_name, pci_name) == 0)\n+\t\t\tbreak;\n+\t}\n+\n+\tif (i == NFP_SYNC_PCI_MAX) {\n+\t\trte_spinlock_unlock(&sync->spinlock);\n+\t\treturn 0;\n+\t}\n+\n+\tpci_common = &sync->pci[i];\n+\n+\tfor (i = 0; i < NFP_SYNC_ELEMENT_MAX; i++) {\n+\t\tif (pci_common->element[i].handle == handle) {\n+\t\t\tcount = pci_common->element[i].count;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\trte_spinlock_unlock(&sync->spinlock);\n+\n+\treturn count;\n+}\n+\n+void *\n+nfp_sync_handle_alloc(struct nfp_sync *sync,\n+\t\tstruct rte_pci_device *pci_dev,\n+\t\tuint32_t magic,\n+\t\tuint32_t size)\n+{\n+\tif (pci_dev == NULL)\n+\t\treturn nfp_sync_process_inner_handle_alloc(sync, magic, size);\n+\n+\treturn nfp_sync_pci_inner_handle_alloc(sync, pci_dev->device.name,\n+\t\t\tmagic, size);\n+}\n+\n+void\n+nfp_sync_handle_free(struct nfp_sync *sync,\n+\t\tstruct rte_pci_device *pci_dev,\n+\t\tvoid *handle)\n+{\n+\tif (pci_dev == NULL) {\n+\t\tnfp_sync_process_inner_handle_free(sync, handle);\n+\t\treturn;\n+\t}\n+\n+\tnfp_sync_pci_inner_handle_free(sync, pci_dev->device.name, handle);\n+}\n+\n+uint16_t\n+nfp_sync_handle_count_get(struct nfp_sync *sync,\n+\t\tstruct rte_pci_device *pci_dev,\n+\t\tvoid *handle)\n+{\n+\tif (pci_dev == NULL)\n+\t\treturn nfp_sync_process_handle_count_get(sync, handle);\n+\n+\treturn nfp_sync_pci_handle_count_get(sync, pci_dev->device.name, handle);\n+}\ndiff --git a/drivers/net/nfp/nfpcore/nfp_sync.h b/drivers/net/nfp/nfpcore/nfp_sync.h\nnew file mode 100644\nindex 0000000000..82f01e2652\n--- /dev/null\n+++ b/drivers/net/nfp/nfpcore/nfp_sync.h\n@@ -0,0 +1,29 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright (c) 2024 Corigine, Inc.\n+ * All rights reserved.\n+ */\n+\n+#ifndef __NFP_SYNC_H__\n+#define __NFP_SYNC_H__\n+\n+#include <stdint.h>\n+\n+#include <bus_pci_driver.h>\n+\n+struct nfp_sync;\n+\n+struct nfp_sync *nfp_sync_alloc(void);\n+void nfp_sync_free(struct nfp_sync *sync);\n+\n+void *nfp_sync_handle_alloc(struct nfp_sync *sync,\n+\t\tstruct rte_pci_device *pci_dev,\n+\t\tuint32_t magic,\n+\t\tuint32_t size);\n+void nfp_sync_handle_free(struct nfp_sync *sync,\n+\t\tstruct rte_pci_device *pci_dev,\n+\t\tvoid *handle);\n+uint16_t nfp_sync_handle_count_get(struct nfp_sync *sync,\n+\t\tstruct rte_pci_device *pci_dev,\n+\t\tvoid *handle);\n+\n+#endif /* __NFP_SYNC_H__ */\n",
    "prefixes": [
        "v2",
        "1/3"
    ]
}