get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 90657,
    "url": "http://patches.dpdk.org/api/patches/90657/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20210406114131.25874-45-ndabilpuram@marvell.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": "<20210406114131.25874-45-ndabilpuram@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210406114131.25874-45-ndabilpuram@marvell.com",
    "date": "2021-04-06T11:41:23",
    "name": "[v4,44/52] common/cnxk: add npc init and fini support",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "8eae0d22003ce71e9b5069f28f563760b93b5bd0",
    "submitter": {
        "id": 1202,
        "url": "http://patches.dpdk.org/api/people/1202/?format=api",
        "name": "Nithin Dabilpuram",
        "email": "ndabilpuram@marvell.com"
    },
    "delegate": {
        "id": 310,
        "url": "http://patches.dpdk.org/api/users/310/?format=api",
        "username": "jerin",
        "first_name": "Jerin",
        "last_name": "Jacob",
        "email": "jerinj@marvell.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20210406114131.25874-45-ndabilpuram@marvell.com/mbox/",
    "series": [
        {
            "id": 16128,
            "url": "http://patches.dpdk.org/api/series/16128/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=16128",
            "date": "2021-04-06T11:40:39",
            "name": "Add Marvell CNXK common driver",
            "version": 4,
            "mbox": "http://patches.dpdk.org/series/16128/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/90657/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/90657/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 465F5A0546;\n\tTue,  6 Apr 2021 13:48:33 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 722181410AE;\n\tTue,  6 Apr 2021 13:43:57 +0200 (CEST)",
            "from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com\n [67.231.148.174])\n by mails.dpdk.org (Postfix) with ESMTP id 1B7B71410A0\n for <dev@dpdk.org>; Tue,  6 Apr 2021 13:43:54 +0200 (CEST)",
            "from pps.filterd (m0045849.ppops.net [127.0.0.1])\n by mx0a-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id\n 136Bdwfr008324 for <dev@dpdk.org>; Tue, 6 Apr 2021 04:43:54 -0700",
            "from dc5-exch02.marvell.com ([199.233.59.182])\n by mx0a-0016f401.pphosted.com with ESMTP id 37r72p2dv0-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT)\n for <dev@dpdk.org>; Tue, 06 Apr 2021 04:43:54 -0700",
            "from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com\n (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.2;\n Tue, 6 Apr 2021 04:43:52 -0700",
            "from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com\n (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend\n Transport; Tue, 6 Apr 2021 04:43:52 -0700",
            "from hyd1588t430.marvell.com (unknown [10.29.52.204])\n by maili.marvell.com (Postfix) with ESMTP id 466883F7040;\n Tue,  6 Apr 2021 04:43:50 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;\n h=from : to : cc :\n subject : date : message-id : in-reply-to : references : mime-version :\n content-type; s=pfpt0220; bh=gE+UJ6PzI8/o5THvs8nXDm8UptQ45E7vCExd28C5UXc=;\n b=D+LuOY3kLak3+YJk9YMM4xc54Rp3gwJGiYWIfg5Ts4lH4voGy9DiS/K8XIaaCfE+Qpt7\n sJOzAV/1y6we+zGbdWcbs1Rdby5D5IlAfoYitcNVZxe75GxvrjgVt2x4JIWZpsWdsg7c\n aqjQ4B8D3nU/WJ9CDdMkNdw9gD9Z74YMEBSKY1QoddREWnrfPJPJ4e85Lhk8IAtFsYVt\n q+kyS4SIFKZgq/ccoK0ekGGkelgxPyO3LRZH7aCVmVhLRoKfYwi6NRbAdos6+7q51n2t\n NfxQrIW6bzj1ro2GckM6YzwzfK4WDBY23LAQtqJWusxgpZTXSuedCsYY1WPxUp+6k/eh 5A==",
        "From": "Nithin Dabilpuram <ndabilpuram@marvell.com>",
        "To": "<dev@dpdk.org>",
        "CC": "<jerinj@marvell.com>, <skori@marvell.com>, <skoteshwar@marvell.com>,\n <pbhagavatula@marvell.com>, <kirankumark@marvell.com>,\n <psatheesh@marvell.com>, <asekhar@marvell.com>",
        "Date": "Tue, 6 Apr 2021 17:11:23 +0530",
        "Message-ID": "<20210406114131.25874-45-ndabilpuram@marvell.com>",
        "X-Mailer": "git-send-email 2.8.4",
        "In-Reply-To": "<20210406114131.25874-1-ndabilpuram@marvell.com>",
        "References": "<20210305133918.8005-1-ndabilpuram@marvell.com>\n <20210406114131.25874-1-ndabilpuram@marvell.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain",
        "X-Proofpoint-GUID": "faZdLWo8ARgw5P_khlx5cG_BL0JlrXss",
        "X-Proofpoint-ORIG-GUID": "faZdLWo8ARgw5P_khlx5cG_BL0JlrXss",
        "X-Proofpoint-Virus-Version": "vendor=fsecure engine=2.50.10434:6.0.369, 18.0.761\n definitions=2021-04-06_02:2021-04-01,\n 2021-04-06 signatures=0",
        "Subject": "[dpdk-dev] [PATCH v4 44/52] common/cnxk: add npc init and fini\n support",
        "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",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "From: Kiran Kumar K <kirankumark@marvell.com>\n\nAdding support initialize and fini the npc. Further, adding APIs to\ncreate and destroy the npc rules.\n\nSigned-off-by: Kiran Kumar K <kirankumark@marvell.com>\n---\n drivers/common/cnxk/meson.build |   1 +\n drivers/common/cnxk/roc_npc.c   | 713 ++++++++++++++++++++++++++++++++++++++++\n drivers/common/cnxk/roc_npc.h   |  40 +++\n drivers/common/cnxk/version.map |  16 +\n 4 files changed, 770 insertions(+)\n create mode 100644 drivers/common/cnxk/roc_npc.c",
    "diff": "diff --git a/drivers/common/cnxk/meson.build b/drivers/common/cnxk/meson.build\nindex 9dd4c23..f12e344 100644\n--- a/drivers/common/cnxk/meson.build\n+++ b/drivers/common/cnxk/meson.build\n@@ -34,6 +34,7 @@ sources = files('roc_dev.c',\n \t\t'roc_npa.c',\n \t\t'roc_npa_debug.c',\n \t\t'roc_npa_irq.c',\n+\t\t'roc_npc.c',\n \t\t'roc_npc_mcam.c',\n \t\t'roc_npc_parse.c',\n \t\t'roc_npc_utils.c',\ndiff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c\nnew file mode 100644\nindex 0000000..c1ac3c7\n--- /dev/null\n+++ b/drivers/common/cnxk/roc_npc.c\n@@ -0,0 +1,713 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(C) 2021 Marvell.\n+ */\n+\n+#include \"roc_api.h\"\n+#include \"roc_priv.h\"\n+\n+int\n+roc_npc_mcam_free_counter(struct roc_npc *roc_npc, uint16_t ctr_id)\n+{\n+\tstruct npc *npc = roc_npc_to_npc_priv(roc_npc);\n+\n+\treturn npc_mcam_free_counter(npc, ctr_id);\n+}\n+\n+int\n+roc_npc_mcam_read_counter(struct roc_npc *roc_npc, uint32_t ctr_id,\n+\t\t\t  uint64_t *count)\n+{\n+\tstruct npc *npc = roc_npc_to_npc_priv(roc_npc);\n+\n+\treturn npc_mcam_read_counter(npc, ctr_id, count);\n+}\n+\n+int\n+roc_npc_mcam_clear_counter(struct roc_npc *roc_npc, uint32_t ctr_id)\n+{\n+\tstruct npc *npc = roc_npc_to_npc_priv(roc_npc);\n+\n+\treturn npc_mcam_clear_counter(npc, ctr_id);\n+}\n+\n+int\n+roc_npc_mcam_free_entry(struct roc_npc *roc_npc, uint32_t entry)\n+{\n+\tstruct npc *npc = roc_npc_to_npc_priv(roc_npc);\n+\n+\treturn npc_mcam_free_entry(npc, entry);\n+}\n+\n+int\n+roc_npc_mcam_free_all_resources(struct roc_npc *roc_npc)\n+{\n+\tstruct npc *npc = roc_npc_to_npc_priv(roc_npc);\n+\n+\treturn npc_flow_free_all_resources(npc);\n+}\n+\n+int\n+roc_npc_mcam_alloc_entries(struct roc_npc *roc_npc, int ref_entry,\n+\t\t\t   int *alloc_entry, int req_count, int priority,\n+\t\t\t   int *resp_count)\n+{\n+\tstruct npc *npc = roc_npc_to_npc_priv(roc_npc);\n+\n+\treturn npc_mcam_alloc_entries(npc, ref_entry, alloc_entry, req_count,\n+\t\t\t\t      priority, resp_count);\n+}\n+\n+int\n+roc_npc_mcam_alloc_entry(struct roc_npc *roc_npc, struct roc_npc_flow *mcam,\n+\t\t\t struct roc_npc_flow *ref_mcam, int prio,\n+\t\t\t int *resp_count)\n+{\n+\tstruct npc *npc = roc_npc_to_npc_priv(roc_npc);\n+\n+\treturn npc_mcam_alloc_entry(npc, mcam, ref_mcam, prio, resp_count);\n+}\n+\n+int\n+roc_npc_mcam_ena_dis_entry(struct roc_npc *roc_npc, struct roc_npc_flow *mcam,\n+\t\t\t   bool enable)\n+{\n+\tstruct npc *npc = roc_npc_to_npc_priv(roc_npc);\n+\n+\treturn npc_mcam_ena_dis_entry(npc, mcam, enable);\n+}\n+\n+int\n+roc_npc_mcam_write_entry(struct roc_npc *roc_npc, struct roc_npc_flow *mcam)\n+{\n+\tstruct npc *npc = roc_npc_to_npc_priv(roc_npc);\n+\n+\treturn npc_mcam_write_entry(npc, mcam);\n+}\n+\n+int\n+roc_npc_get_low_priority_mcam(struct roc_npc *roc_npc)\n+{\n+\tstruct npc *npc = roc_npc_to_npc_priv(roc_npc);\n+\n+\tif (roc_model_is_cn10k())\n+\t\treturn (npc->mcam_entries - NPC_MCAME_RESVD_10XX - 1);\n+\telse\n+\t\treturn (npc->mcam_entries - NPC_MCAME_RESVD_9XXX - 1);\n+}\n+\n+static int\n+npc_mcam_tot_entries(void)\n+{\n+\t/* FIXME: change to reading in AF from NPC_AF_CONST1/2\n+\t * MCAM_BANK_DEPTH(_EXT) * MCAM_BANKS\n+\t */\n+\tif (roc_model_is_cn10k())\n+\t\treturn 16 * 1024; /* MCAM_BANKS = 4, BANK_DEPTH_EXT = 4096 */\n+\telse\n+\t\treturn 4 * 1024; /* MCAM_BANKS = 4, BANK_DEPTH_EXT = 1024 */\n+}\n+\n+const char *\n+roc_npc_profile_name_get(struct roc_npc *roc_npc)\n+{\n+\tstruct npc *npc = roc_npc_to_npc_priv(roc_npc);\n+\n+\treturn (char *)npc->profile_name;\n+}\n+\n+int\n+roc_npc_init(struct roc_npc *roc_npc)\n+{\n+\tuint8_t *mem = NULL, *nix_mem = NULL, *npc_mem = NULL;\n+\tstruct nix *nix = roc_nix_to_nix_priv(roc_npc->roc_nix);\n+\tstruct npc *npc = roc_npc_to_npc_priv(roc_npc);\n+\tuint32_t bmap_sz;\n+\tint rc = 0, idx;\n+\tsize_t sz;\n+\n+\tPLT_STATIC_ASSERT(sizeof(struct npc) <= ROC_NPC_MEM_SZ);\n+\n+\tmemset(npc, 0, sizeof(*npc));\n+\tnpc->mbox = (&nix->dev)->mbox;\n+\troc_npc->channel = nix->rx_chan_base;\n+\troc_npc->pf_func = (&nix->dev)->pf_func;\n+\tnpc->channel = roc_npc->channel;\n+\tnpc->pf_func = roc_npc->pf_func;\n+\tnpc->flow_max_priority = roc_npc->flow_max_priority;\n+\tnpc->switch_header_type = roc_npc->switch_header_type;\n+\tnpc->flow_prealloc_size = roc_npc->flow_prealloc_size;\n+\n+\tif (npc->mbox == NULL)\n+\t\treturn NPC_ERR_PARAM;\n+\n+\trc = npc_mcam_fetch_kex_cfg(npc);\n+\tif (rc)\n+\t\tgoto done;\n+\n+\troc_npc->kex_capability = npc_get_kex_capability(npc);\n+\troc_npc->rx_parse_nibble = npc->keyx_supp_nmask[NPC_MCAM_RX];\n+\n+\tnpc->mark_actions = 0;\n+\n+\tnpc->mcam_entries = npc_mcam_tot_entries() >> npc->keyw[NPC_MCAM_RX];\n+\n+\t/* Free, free_rev, live and live_rev entries */\n+\tbmap_sz = plt_bitmap_get_memory_footprint(npc->mcam_entries);\n+\tmem = plt_zmalloc(4 * bmap_sz * npc->flow_max_priority, 0);\n+\tif (mem == NULL) {\n+\t\tplt_err(\"Bmap alloc failed\");\n+\t\trc = NPC_ERR_NO_MEM;\n+\t\treturn rc;\n+\t}\n+\n+\tsz = npc->flow_max_priority * sizeof(struct npc_mcam_ents_info);\n+\tnpc->flow_entry_info = plt_zmalloc(sz, 0);\n+\tif (npc->flow_entry_info == NULL) {\n+\t\tplt_err(\"flow_entry_info alloc failed\");\n+\t\trc = NPC_ERR_NO_MEM;\n+\t\tgoto done;\n+\t}\n+\n+\tsz = npc->flow_max_priority * sizeof(struct plt_bitmap *);\n+\tnpc->free_entries = plt_zmalloc(sz, 0);\n+\tif (npc->free_entries == NULL) {\n+\t\tplt_err(\"free_entries alloc failed\");\n+\t\trc = NPC_ERR_NO_MEM;\n+\t\tgoto done;\n+\t}\n+\n+\tsz = npc->flow_max_priority * sizeof(struct plt_bitmap *);\n+\tnpc->free_entries_rev = plt_zmalloc(sz, 0);\n+\tif (npc->free_entries_rev == NULL) {\n+\t\tplt_err(\"free_entries_rev alloc failed\");\n+\t\trc = NPC_ERR_NO_MEM;\n+\t\tgoto done;\n+\t}\n+\n+\tsz = npc->flow_max_priority * sizeof(struct plt_bitmap *);\n+\tnpc->live_entries = plt_zmalloc(sz, 0);\n+\tif (npc->live_entries == NULL) {\n+\t\tplt_err(\"live_entries alloc failed\");\n+\t\trc = NPC_ERR_NO_MEM;\n+\t\tgoto done;\n+\t}\n+\n+\tsz = npc->flow_max_priority * sizeof(struct plt_bitmap *);\n+\tnpc->live_entries_rev = plt_zmalloc(sz, 0);\n+\tif (npc->live_entries_rev == NULL) {\n+\t\tplt_err(\"live_entries_rev alloc failed\");\n+\t\trc = NPC_ERR_NO_MEM;\n+\t\tgoto done;\n+\t}\n+\n+\tsz = npc->flow_max_priority * sizeof(struct npc_flow_list);\n+\tnpc->flow_list = plt_zmalloc(sz, 0);\n+\tif (npc->flow_list == NULL) {\n+\t\tplt_err(\"flow_list alloc failed\");\n+\t\trc = NPC_ERR_NO_MEM;\n+\t\tgoto done;\n+\t}\n+\n+\tnpc_mem = mem;\n+\tfor (idx = 0; idx < npc->flow_max_priority; idx++) {\n+\t\tTAILQ_INIT(&npc->flow_list[idx]);\n+\n+\t\tnpc->free_entries[idx] =\n+\t\t\tplt_bitmap_init(npc->mcam_entries, mem, bmap_sz);\n+\t\tmem += bmap_sz;\n+\n+\t\tnpc->free_entries_rev[idx] =\n+\t\t\tplt_bitmap_init(npc->mcam_entries, mem, bmap_sz);\n+\t\tmem += bmap_sz;\n+\n+\t\tnpc->live_entries[idx] =\n+\t\t\tplt_bitmap_init(npc->mcam_entries, mem, bmap_sz);\n+\t\tmem += bmap_sz;\n+\n+\t\tnpc->live_entries_rev[idx] =\n+\t\t\tplt_bitmap_init(npc->mcam_entries, mem, bmap_sz);\n+\t\tmem += bmap_sz;\n+\n+\t\tnpc->flow_entry_info[idx].free_ent = 0;\n+\t\tnpc->flow_entry_info[idx].live_ent = 0;\n+\t\tnpc->flow_entry_info[idx].max_id = 0;\n+\t\tnpc->flow_entry_info[idx].min_id = ~(0);\n+\t}\n+\n+\tnpc->rss_grps = NPC_RSS_GRPS;\n+\n+\tbmap_sz = plt_bitmap_get_memory_footprint(npc->rss_grps);\n+\tnix_mem = plt_zmalloc(bmap_sz, 0);\n+\tif (nix_mem == NULL) {\n+\t\tplt_err(\"Bmap alloc failed\");\n+\t\trc = NPC_ERR_NO_MEM;\n+\t\tgoto done;\n+\t}\n+\n+\tnpc->rss_grp_entries = plt_bitmap_init(npc->rss_grps, nix_mem, bmap_sz);\n+\n+\tif (!npc->rss_grp_entries) {\n+\t\tplt_err(\"bitmap init failed\");\n+\t\trc = NPC_ERR_NO_MEM;\n+\t\tgoto done;\n+\t}\n+\n+\t/* Group 0 will be used for RSS,\n+\t * 1 -7 will be used for npc_flow RSS action\n+\t */\n+\tplt_bitmap_set(npc->rss_grp_entries, 0);\n+\n+\treturn rc;\n+\n+done:\n+\tif (npc->flow_list)\n+\t\tplt_free(npc->flow_list);\n+\tif (npc->live_entries_rev)\n+\t\tplt_free(npc->live_entries_rev);\n+\tif (npc->live_entries)\n+\t\tplt_free(npc->live_entries);\n+\tif (npc->free_entries_rev)\n+\t\tplt_free(npc->free_entries_rev);\n+\tif (npc->free_entries)\n+\t\tplt_free(npc->free_entries);\n+\tif (npc->flow_entry_info)\n+\t\tplt_free(npc->flow_entry_info);\n+\tif (npc_mem)\n+\t\tplt_free(npc_mem);\n+\treturn rc;\n+}\n+\n+int\n+roc_npc_fini(struct roc_npc *roc_npc)\n+{\n+\tstruct npc *npc = roc_npc_to_npc_priv(roc_npc);\n+\tint rc;\n+\n+\trc = npc_flow_free_all_resources(npc);\n+\tif (rc) {\n+\t\tplt_err(\"Error when deleting NPC MCAM entries, counters\");\n+\t\treturn rc;\n+\t}\n+\n+\tif (npc->flow_list) {\n+\t\tplt_free(npc->flow_list);\n+\t\tnpc->flow_list = NULL;\n+\t}\n+\n+\tif (npc->live_entries_rev) {\n+\t\tplt_free(npc->live_entries_rev);\n+\t\tnpc->live_entries_rev = NULL;\n+\t}\n+\n+\tif (npc->live_entries) {\n+\t\tplt_free(npc->live_entries);\n+\t\tnpc->live_entries = NULL;\n+\t}\n+\n+\tif (npc->free_entries_rev) {\n+\t\tplt_free(npc->free_entries_rev);\n+\t\tnpc->free_entries_rev = NULL;\n+\t}\n+\n+\tif (npc->free_entries) {\n+\t\tplt_free(npc->free_entries);\n+\t\tnpc->free_entries = NULL;\n+\t}\n+\n+\tif (npc->flow_entry_info) {\n+\t\tplt_free(npc->flow_entry_info);\n+\t\tnpc->flow_entry_info = NULL;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int\n+npc_parse_actions(struct npc *npc, const struct roc_npc_attr *attr,\n+\t\t  const struct roc_npc_action actions[],\n+\t\t  struct roc_npc_flow *flow)\n+{\n+\tconst struct roc_npc_action_mark *act_mark;\n+\tconst struct roc_npc_action_queue *act_q;\n+\tconst struct roc_npc_action_vf *vf_act;\n+\tint sel_act, req_act = 0;\n+\tuint16_t pf_func, vf_id;\n+\tint errcode = 0;\n+\tint mark = 0;\n+\tint rq = 0;\n+\n+\t/* Initialize actions */\n+\tflow->ctr_id = NPC_COUNTER_NONE;\n+\tpf_func = npc->pf_func;\n+\n+\tfor (; actions->type != ROC_NPC_ACTION_TYPE_END; actions++) {\n+\t\tswitch (actions->type) {\n+\t\tcase ROC_NPC_ACTION_TYPE_VOID:\n+\t\t\tbreak;\n+\t\tcase ROC_NPC_ACTION_TYPE_MARK:\n+\t\t\tact_mark = (const struct roc_npc_action_mark *)\n+\t\t\t\t\t   actions->conf;\n+\t\t\tif (act_mark->id > (NPC_FLOW_FLAG_VAL - 2)) {\n+\t\t\t\tplt_err(\"mark value must be < 0xfffe\");\n+\t\t\t\tgoto err_exit;\n+\t\t\t}\n+\t\t\tmark = act_mark->id + 1;\n+\t\t\treq_act |= ROC_NPC_ACTION_TYPE_MARK;\n+\t\t\tnpc->mark_actions += 1;\n+\t\t\tbreak;\n+\n+\t\tcase ROC_NPC_ACTION_TYPE_FLAG:\n+\t\t\tmark = NPC_FLOW_FLAG_VAL;\n+\t\t\treq_act |= ROC_NPC_ACTION_TYPE_FLAG;\n+\t\t\tnpc->mark_actions += 1;\n+\t\t\tbreak;\n+\n+\t\tcase ROC_NPC_ACTION_TYPE_COUNT:\n+\t\t\t/* Indicates, need a counter */\n+\t\t\tflow->ctr_id = 1;\n+\t\t\treq_act |= ROC_NPC_ACTION_TYPE_COUNT;\n+\t\t\tbreak;\n+\n+\t\tcase ROC_NPC_ACTION_TYPE_DROP:\n+\t\t\treq_act |= ROC_NPC_ACTION_TYPE_DROP;\n+\t\t\tbreak;\n+\n+\t\tcase ROC_NPC_ACTION_TYPE_PF:\n+\t\t\treq_act |= ROC_NPC_ACTION_TYPE_PF;\n+\t\t\tpf_func &= (0xfc00);\n+\t\t\tbreak;\n+\n+\t\tcase ROC_NPC_ACTION_TYPE_VF:\n+\t\t\tvf_act =\n+\t\t\t\t(const struct roc_npc_action_vf *)actions->conf;\n+\t\t\treq_act |= ROC_NPC_ACTION_TYPE_VF;\n+\t\t\tvf_id = vf_act->id & RVU_PFVF_FUNC_MASK;\n+\t\t\tpf_func &= (0xfc00);\n+\t\t\tpf_func = (pf_func | (vf_id + 1));\n+\t\t\tbreak;\n+\n+\t\tcase ROC_NPC_ACTION_TYPE_QUEUE:\n+\t\t\tact_q = (const struct roc_npc_action_queue *)\n+\t\t\t\t\tactions->conf;\n+\t\t\trq = act_q->index;\n+\t\t\treq_act |= ROC_NPC_ACTION_TYPE_QUEUE;\n+\t\t\tbreak;\n+\n+\t\tcase ROC_NPC_ACTION_TYPE_RSS:\n+\t\t\treq_act |= ROC_NPC_ACTION_TYPE_RSS;\n+\t\t\tbreak;\n+\n+\t\tcase ROC_NPC_ACTION_TYPE_SEC:\n+\t\t\t/* Assumes user has already configured security\n+\t\t\t * session for this flow. Associated conf is\n+\t\t\t * opaque. When security is implemented,\n+\t\t\t * we need to verify that for specified security\n+\t\t\t * session:\n+\t\t\t *  action_type ==\n+\t\t\t *    NPC_SECURITY_ACTION_TYPE_INLINE_PROTOCOL &&\n+\t\t\t *  session_protocol ==\n+\t\t\t *    NPC_SECURITY_PROTOCOL_IPSEC\n+\t\t\t *\n+\t\t\t * RSS is not supported with inline ipsec. Get the\n+\t\t\t * rq from associated conf, or make\n+\t\t\t * ROC_NPC_ACTION_TYPE_QUEUE compulsory with this\n+\t\t\t * action.\n+\t\t\t * Currently, rq = 0 is assumed.\n+\t\t\t */\n+\t\t\treq_act |= ROC_NPC_ACTION_TYPE_SEC;\n+\t\t\trq = 0;\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\terrcode = NPC_ERR_ACTION_NOTSUP;\n+\t\t\tgoto err_exit;\n+\t\t}\n+\t}\n+\n+\t/* Check if actions specified are compatible */\n+\tif (attr->egress) {\n+\t\t/* Only DROP/COUNT is supported */\n+\t\tif (!(req_act & ROC_NPC_ACTION_TYPE_DROP)) {\n+\t\t\terrcode = NPC_ERR_ACTION_NOTSUP;\n+\t\t\tgoto err_exit;\n+\t\t} else if (req_act & ~(ROC_NPC_ACTION_TYPE_DROP |\n+\t\t\t\t       ROC_NPC_ACTION_TYPE_COUNT)) {\n+\t\t\terrcode = NPC_ERR_ACTION_NOTSUP;\n+\t\t\tgoto err_exit;\n+\t\t}\n+\t\tflow->npc_action = NIX_TX_ACTIONOP_DROP;\n+\t\tgoto set_pf_func;\n+\t}\n+\n+\t/* We have already verified the attr, this is ingress.\n+\t * - Exactly one terminating action is supported\n+\t * - Exactly one of MARK or FLAG is supported\n+\t * - If terminating action is DROP, only count is valid.\n+\t */\n+\tsel_act = req_act & NPC_ACTION_TERM;\n+\tif ((sel_act & (sel_act - 1)) != 0) {\n+\t\terrcode = NPC_ERR_ACTION_NOTSUP;\n+\t\tgoto err_exit;\n+\t}\n+\n+\tif (req_act & ROC_NPC_ACTION_TYPE_DROP) {\n+\t\tsel_act = req_act & ~ROC_NPC_ACTION_TYPE_COUNT;\n+\t\tif ((sel_act & (sel_act - 1)) != 0) {\n+\t\t\terrcode = NPC_ERR_ACTION_NOTSUP;\n+\t\t\tgoto err_exit;\n+\t\t}\n+\t}\n+\n+\tif ((req_act & (ROC_NPC_ACTION_TYPE_FLAG | ROC_NPC_ACTION_TYPE_MARK)) ==\n+\t    (ROC_NPC_ACTION_TYPE_FLAG | ROC_NPC_ACTION_TYPE_MARK)) {\n+\t\terrcode = NPC_ERR_ACTION_NOTSUP;\n+\t\tgoto err_exit;\n+\t}\n+\n+\t/* Set NIX_RX_ACTIONOP */\n+\tif (req_act & (ROC_NPC_ACTION_TYPE_PF | ROC_NPC_ACTION_TYPE_VF)) {\n+\t\tflow->npc_action = NIX_RX_ACTIONOP_UCAST;\n+\t\tif (req_act & ROC_NPC_ACTION_TYPE_QUEUE)\n+\t\t\tflow->npc_action |= (uint64_t)rq << 20;\n+\t} else if (req_act & ROC_NPC_ACTION_TYPE_DROP) {\n+\t\tflow->npc_action = NIX_RX_ACTIONOP_DROP;\n+\t} else if (req_act & ROC_NPC_ACTION_TYPE_QUEUE) {\n+\t\tflow->npc_action = NIX_RX_ACTIONOP_UCAST;\n+\t\tflow->npc_action |= (uint64_t)rq << 20;\n+\t} else if (req_act & ROC_NPC_ACTION_TYPE_RSS) {\n+\t\tflow->npc_action = NIX_RX_ACTIONOP_UCAST;\n+\t} else if (req_act & ROC_NPC_ACTION_TYPE_SEC) {\n+\t\tflow->npc_action = NIX_RX_ACTIONOP_UCAST_IPSEC;\n+\t\tflow->npc_action |= (uint64_t)rq << 20;\n+\t} else if (req_act &\n+\t\t   (ROC_NPC_ACTION_TYPE_FLAG | ROC_NPC_ACTION_TYPE_MARK)) {\n+\t\tflow->npc_action = NIX_RX_ACTIONOP_UCAST;\n+\t} else if (req_act & ROC_NPC_ACTION_TYPE_COUNT) {\n+\t\t/* Keep ROC_NPC_ACTION_TYPE_COUNT_ACT always at the end\n+\t\t * This is default action, when user specify only\n+\t\t * COUNT ACTION\n+\t\t */\n+\t\tflow->npc_action = NIX_RX_ACTIONOP_UCAST;\n+\t} else {\n+\t\t/* Should never reach here */\n+\t\terrcode = NPC_ERR_ACTION_NOTSUP;\n+\t\tgoto err_exit;\n+\t}\n+\n+\tif (mark)\n+\t\tflow->npc_action |= (uint64_t)mark << 40;\n+\n+set_pf_func:\n+\t/* Ideally AF must ensure that correct pf_func is set */\n+\tflow->npc_action |= (uint64_t)pf_func << 4;\n+\n+\treturn 0;\n+\n+err_exit:\n+\treturn errcode;\n+}\n+\n+typedef int (*npc_parse_stage_func_t)(struct npc_parse_state *pst);\n+\n+static int\n+npc_parse_pattern(struct npc *npc, const struct roc_npc_item_info pattern[],\n+\t\t  struct roc_npc_flow *flow, struct npc_parse_state *pst)\n+{\n+\tnpc_parse_stage_func_t parse_stage_funcs[] = {\n+\t\tnpc_parse_meta_items, npc_parse_cpt_hdr, npc_parse_higig2_hdr,\n+\t\tnpc_parse_la,\t      npc_parse_lb,\t npc_parse_lc,\n+\t\tnpc_parse_ld,\t      npc_parse_le,\t npc_parse_lf,\n+\t\tnpc_parse_lg,\t      npc_parse_lh,\n+\t};\n+\tuint8_t layer = 0;\n+\tint key_offset;\n+\tint rc;\n+\n+\tif (pattern == NULL)\n+\t\treturn NPC_ERR_PARAM;\n+\n+\tmemset(pst, 0, sizeof(*pst));\n+\tpst->npc = npc;\n+\tpst->flow = flow;\n+\n+\t/* Use integral byte offset */\n+\tkey_offset = pst->npc->keyx_len[flow->nix_intf];\n+\tkey_offset = (key_offset + 7) / 8;\n+\n+\t/* Location where LDATA would begin */\n+\tpst->mcam_data = (uint8_t *)flow->mcam_data;\n+\tpst->mcam_mask = (uint8_t *)flow->mcam_mask;\n+\n+\twhile (pattern->type != ROC_NPC_ITEM_TYPE_END &&\n+\t       layer < PLT_DIM(parse_stage_funcs)) {\n+\t\t/* Skip place-holders */\n+\t\tpattern = npc_parse_skip_void_and_any_items(pattern);\n+\n+\t\tpst->pattern = pattern;\n+\t\trc = parse_stage_funcs[layer](pst);\n+\t\tif (rc != 0)\n+\t\t\treturn rc;\n+\n+\t\tlayer++;\n+\n+\t\t/*\n+\t\t * Parse stage function sets pst->pattern to\n+\t\t * 1 past the last item it consumed.\n+\t\t */\n+\t\tpattern = pst->pattern;\n+\n+\t\tif (pst->terminate)\n+\t\t\tbreak;\n+\t}\n+\n+\t/* Skip trailing place-holders */\n+\tpattern = npc_parse_skip_void_and_any_items(pattern);\n+\n+\t/* Are there more items than what we can handle? */\n+\tif (pattern->type != ROC_NPC_ITEM_TYPE_END)\n+\t\treturn NPC_ERR_PATTERN_NOTSUP;\n+\n+\treturn 0;\n+}\n+\n+static int\n+npc_parse_attr(struct npc *npc, const struct roc_npc_attr *attr,\n+\t       struct roc_npc_flow *flow)\n+{\n+\tif (attr == NULL)\n+\t\treturn NPC_ERR_PARAM;\n+\telse if (attr->priority >= npc->flow_max_priority)\n+\t\treturn NPC_ERR_PARAM;\n+\telse if ((!attr->egress && !attr->ingress) ||\n+\t\t (attr->egress && attr->ingress))\n+\t\treturn NPC_ERR_PARAM;\n+\n+\tif (attr->ingress)\n+\t\tflow->nix_intf = ROC_NPC_INTF_RX;\n+\telse\n+\t\tflow->nix_intf = ROC_NPC_INTF_TX;\n+\n+\tflow->priority = attr->priority;\n+\treturn 0;\n+}\n+\n+static int\n+npc_parse_rule(struct npc *npc, const struct roc_npc_attr *attr,\n+\t       const struct roc_npc_item_info pattern[],\n+\t       const struct roc_npc_action actions[], struct roc_npc_flow *flow,\n+\t       struct npc_parse_state *pst)\n+{\n+\tint err;\n+\n+\t/* Check attr */\n+\terr = npc_parse_attr(npc, attr, flow);\n+\tif (err)\n+\t\treturn err;\n+\n+\t/* Check pattern */\n+\terr = npc_parse_pattern(npc, pattern, flow, pst);\n+\tif (err)\n+\t\treturn err;\n+\n+\t/* Check action */\n+\terr = npc_parse_actions(npc, attr, actions, flow);\n+\tif (err)\n+\t\treturn err;\n+\treturn 0;\n+}\n+\n+int\n+roc_npc_flow_parse(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,\n+\t\t   const struct roc_npc_item_info pattern[],\n+\t\t   const struct roc_npc_action actions[],\n+\t\t   struct roc_npc_flow *flow)\n+{\n+\tstruct npc *npc = roc_npc_to_npc_priv(roc_npc);\n+\tstruct npc_parse_state parse_state = {0};\n+\tint rc;\n+\n+\trc = npc_parse_rule(npc, attr, pattern, actions, flow, &parse_state);\n+\tif (rc)\n+\t\treturn rc;\n+\n+\tparse_state.is_vf = !roc_nix_is_pf(roc_npc->roc_nix);\n+\n+\treturn npc_program_mcam(npc, &parse_state, 0);\n+}\n+\n+struct roc_npc_flow *\n+roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,\n+\t\t    const struct roc_npc_item_info pattern[],\n+\t\t    const struct roc_npc_action actions[], int *errcode)\n+{\n+\tstruct npc *npc = roc_npc_to_npc_priv(roc_npc);\n+\tstruct roc_npc_flow *flow, *flow_iter;\n+\tstruct npc_parse_state parse_state;\n+\tstruct npc_flow_list *list;\n+\tint rc;\n+\n+\tflow = plt_zmalloc(sizeof(*flow), 0);\n+\tif (flow == NULL) {\n+\t\t*errcode = NPC_ERR_NO_MEM;\n+\t\treturn NULL;\n+\t}\n+\tmemset(flow, 0, sizeof(*flow));\n+\n+\trc = npc_parse_rule(npc, attr, pattern, actions, flow, &parse_state);\n+\tif (rc != 0) {\n+\t\t*errcode = rc;\n+\t\tgoto err_exit;\n+\t}\n+\n+\tparse_state.is_vf = !roc_nix_is_pf(roc_npc->roc_nix);\n+\n+\trc = npc_program_mcam(npc, &parse_state, 1);\n+\tif (rc != 0) {\n+\t\t*errcode = rc;\n+\t\tgoto err_exit;\n+\t}\n+\n+\tlist = &npc->flow_list[flow->priority];\n+\t/* List in ascending order of mcam entries */\n+\tTAILQ_FOREACH(flow_iter, list, next) {\n+\t\tif (flow_iter->mcam_id > flow->mcam_id) {\n+\t\t\tTAILQ_INSERT_BEFORE(flow_iter, flow, next);\n+\t\t\treturn flow;\n+\t\t}\n+\t}\n+\n+\tTAILQ_INSERT_TAIL(list, flow, next);\n+\treturn flow;\n+\n+err_exit:\n+\tplt_free(flow);\n+\treturn NULL;\n+}\n+\n+int\n+roc_npc_flow_destroy(struct roc_npc *roc_npc, struct roc_npc_flow *flow)\n+{\n+\tstruct npc *npc = roc_npc_to_npc_priv(roc_npc);\n+\tstruct plt_bitmap *bmap;\n+\tuint16_t match_id;\n+\tint rc;\n+\n+\tmatch_id = (flow->npc_action >> NPC_RX_ACT_MATCH_OFFSET) &\n+\t\t   NPC_RX_ACT_MATCH_MASK;\n+\n+\tif (match_id && match_id < NPC_ACTION_FLAG_DEFAULT) {\n+\t\tif (npc->mark_actions == 0)\n+\t\t\treturn NPC_ERR_PARAM;\n+\t}\n+\n+\trc = npc_mcam_free_entry(npc, flow->mcam_id);\n+\tif (rc != 0)\n+\t\treturn rc;\n+\n+\tTAILQ_REMOVE(&npc->flow_list[flow->priority], flow, next);\n+\n+\tbmap = npc->live_entries[flow->priority];\n+\tplt_bitmap_clear(bmap, flow->mcam_id);\n+\n+\tplt_free(flow);\n+\treturn 0;\n+}\ndiff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h\nindex c841240..996739e 100644\n--- a/drivers/common/cnxk/roc_npc.h\n+++ b/drivers/common/cnxk/roc_npc.h\n@@ -126,4 +126,44 @@ struct roc_npc {\n \tuint8_t reserved[ROC_NPC_MEM_SZ];\n } __plt_cache_aligned;\n \n+int __roc_api roc_npc_init(struct roc_npc *roc_npc);\n+int __roc_api roc_npc_fini(struct roc_npc *roc_npc);\n+const char *__roc_api roc_npc_profile_name_get(struct roc_npc *roc_npc);\n+\n+struct roc_npc_flow *__roc_api\n+roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,\n+\t\t    const struct roc_npc_item_info pattern[],\n+\t\t    const struct roc_npc_action actions[], int *errcode);\n+int __roc_api roc_npc_flow_destroy(struct roc_npc *roc_npc,\n+\t\t\t\t   struct roc_npc_flow *flow);\n+int __roc_api roc_npc_mcam_free_entry(struct roc_npc *roc_npc, uint32_t entry);\n+int __roc_api roc_npc_mcam_alloc_entry(struct roc_npc *roc_npc,\n+\t\t\t\t       struct roc_npc_flow *mcam,\n+\t\t\t\t       struct roc_npc_flow *ref_mcam, int prio,\n+\t\t\t\t       int *resp_count);\n+int __roc_api roc_npc_mcam_alloc_entries(struct roc_npc *roc_npc, int ref_entry,\n+\t\t\t\t\t int *alloc_entry, int req_count,\n+\t\t\t\t\t int priority, int *resp_count);\n+int __roc_api roc_npc_mcam_ena_dis_entry(struct roc_npc *roc_npc,\n+\t\t\t\t\t struct roc_npc_flow *mcam,\n+\t\t\t\t\t bool enable);\n+int __roc_api roc_npc_mcam_write_entry(struct roc_npc *roc_npc,\n+\t\t\t\t       struct roc_npc_flow *mcam);\n+int __roc_api roc_npc_flow_parse(struct roc_npc *roc_npc,\n+\t\t\t\t const struct roc_npc_attr *attr,\n+\t\t\t\t const struct roc_npc_item_info pattern[],\n+\t\t\t\t const struct roc_npc_action actions[],\n+\t\t\t\t struct roc_npc_flow *flow);\n+int __roc_api roc_npc_get_low_priority_mcam(struct roc_npc *roc_npc);\n+\n+int __roc_api roc_npc_mcam_free_counter(struct roc_npc *roc_npc,\n+\t\t\t\t\tuint16_t ctr_id);\n+\n+int __roc_api roc_npc_mcam_read_counter(struct roc_npc *roc_npc,\n+\t\t\t\t\tuint32_t ctr_id, uint64_t *count);\n+int __roc_api roc_npc_mcam_clear_counter(struct roc_npc *roc_npc,\n+\t\t\t\t\t uint32_t ctr_id);\n+\n+int __roc_api roc_npc_mcam_free_all_resources(struct roc_npc *roc_npc);\n+\n #endif /* _ROC_NPC_H_ */\ndiff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map\nindex f961a23..ed82b56 100644\n--- a/drivers/common/cnxk/version.map\n+++ b/drivers/common/cnxk/version.map\n@@ -154,6 +154,22 @@ INTERNAL {\n \troc_npa_pool_destroy;\n \troc_npa_pool_op_pc_reset;\n \troc_npa_pool_range_update_check;\n+\troc_npc_fini;\n+\troc_npc_flow_create;\n+\troc_npc_flow_destroy;\n+\troc_npc_flow_parse;\n+\troc_npc_get_low_priority_mcam;\n+\troc_npc_init;\n+\troc_npc_mcam_alloc_entries;\n+\troc_npc_mcam_alloc_entry;\n+\troc_npc_mcam_clear_counter;\n+\troc_npc_mcam_ena_dis_entry;\n+\troc_npc_mcam_free_all_resources;\n+\troc_npc_mcam_free_counter;\n+\troc_npc_mcam_free_entry;\n+\troc_npc_mcam_write_entry;\n+\troc_npc_mcam_read_counter;\n+\troc_npc_profile_name_get;\n \troc_plt_init;\n \troc_plt_init_cb_register;\n \n",
    "prefixes": [
        "v4",
        "44/52"
    ]
}