get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 93569,
    "url": "http://patches.dpdk.org/api/patches/93569/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20210530085929.29695-21-venkatkumar.duvvuru@broadcom.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": "<20210530085929.29695-21-venkatkumar.duvvuru@broadcom.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210530085929.29695-21-venkatkumar.duvvuru@broadcom.com",
    "date": "2021-05-30T08:58:51",
    "name": "[20/58] net/bnxt: add WC TCAM hi/lo move support",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "2617b9476f658e297273f5c15ceed194a1a4d19a",
    "submitter": {
        "id": 1635,
        "url": "http://patches.dpdk.org/api/people/1635/?format=api",
        "name": "Venkat Duvvuru",
        "email": "venkatkumar.duvvuru@broadcom.com"
    },
    "delegate": {
        "id": 1766,
        "url": "http://patches.dpdk.org/api/users/1766/?format=api",
        "username": "ajitkhaparde",
        "first_name": "Ajit",
        "last_name": "Khaparde",
        "email": "ajit.khaparde@broadcom.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20210530085929.29695-21-venkatkumar.duvvuru@broadcom.com/mbox/",
    "series": [
        {
            "id": 17161,
            "url": "http://patches.dpdk.org/api/series/17161/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=17161",
            "date": "2021-05-30T08:58:31",
            "name": "enhancements to host based flow table management",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/17161/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/93569/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/93569/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 558DFA0524;\n\tSun, 30 May 2021 11:03:33 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 202704116F;\n\tSun, 30 May 2021 11:01:05 +0200 (CEST)",
            "from relay.smtp-ext.broadcom.com (relay.smtp-ext.broadcom.com\n [192.19.11.229]) by mails.dpdk.org (Postfix) with ESMTP id 332F441158\n for <dev@dpdk.org>; Sun, 30 May 2021 11:01:01 +0200 (CEST)",
            "from S60.dhcp.broadcom.net (unknown [10.123.66.170])\n (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n (No client certificate requested)\n by relay.smtp-ext.broadcom.com (Postfix) with ESMTPS id 926AE7DC0;\n Sun, 30 May 2021 02:00:59 -0700 (PDT)"
        ],
        "DKIM-Filter": "OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 926AE7DC0",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com;\n s=dkimrelay; t=1622365260;\n bh=FEo+JbhHDy4XlIacvctl+HORwXxGACXENao6p8l7nCQ=;\n h=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n b=B3m4liOON8Bim3eo7xUm3pNMIyDNzLkahcd/lCr6j3NqO82LfqDtWJ46S36xGSdeO\n ioceOntN6gRufXNczyKJV1VSRY53SoSFJpiS2C9bgNM3tS7tJzVZCCIC1qhhVXXPyP\n Ksdys5Z4RREjNNFB2RSngaJDpGH1YSCvwBFYCbps=",
        "From": "Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>",
        "To": "dev@dpdk.org",
        "Cc": "Farah Smith <farah.smith@broadcom.com>,\n Randy Schacher <stuart.schacher@broadcom.com>,\n Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>",
        "Date": "Sun, 30 May 2021 14:28:51 +0530",
        "Message-Id": "<20210530085929.29695-21-venkatkumar.duvvuru@broadcom.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20210530085929.29695-1-venkatkumar.duvvuru@broadcom.com>",
        "References": "<20210530085929.29695-1-venkatkumar.duvvuru@broadcom.com>",
        "Subject": "[dpdk-dev] [PATCH 20/58] net/bnxt: add WC TCAM hi/lo move 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: Farah Smith <farah.smith@broadcom.com>\n\n- Add new API to move wc tcam regions from the hi pool\n  to the low pool.\n- Enable shared tcam get/set functions on Thor.\n\nSigned-off-by: Farah Smith <farah.smith@broadcom.com>\nSigned-off-by: Randy Schacher <stuart.schacher@broadcom.com>\nSigned-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>\nReviewed-by: Randy Schacher <stuart.schacher@broadcom.com>\n---\n drivers/net/bnxt/tf_core/tf_core.c        |  53 +++\n drivers/net/bnxt/tf_core/tf_core.h        |  39 ++\n drivers/net/bnxt/tf_core/tf_device.h      |  18 +\n drivers/net/bnxt/tf_core/tf_device_p4.c   |   1 +\n drivers/net/bnxt/tf_core/tf_device_p58.c  |   5 +-\n drivers/net/bnxt/tf_core/tf_session.c     |  41 ++\n drivers/net/bnxt/tf_core/tf_session.h     |  48 +++\n drivers/net/bnxt/tf_core/tf_tcam.c        |   2 +-\n drivers/net/bnxt/tf_core/tf_tcam_shared.c | 468 ++++++++++++++++++++--\n drivers/net/bnxt/tf_core/tf_tcam_shared.h |  35 ++\n 10 files changed, 673 insertions(+), 37 deletions(-)",
    "diff": "diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c\nindex de2a93646f..73dbee2940 100644\n--- a/drivers/net/bnxt/tf_core/tf_core.c\n+++ b/drivers/net/bnxt/tf_core/tf_core.c\n@@ -917,6 +917,59 @@ tf_free_tcam_entry(struct tf *tfp,\n \treturn 0;\n }\n \n+#ifdef TF_TCAM_SHARED\n+int\n+tf_move_tcam_shared_entries(struct tf *tfp,\n+\t\t\t    struct tf_move_tcam_shared_entries_parms *parms)\n+{\n+\tint rc;\n+\tstruct tf_session *tfs;\n+\tstruct tf_dev_info *dev;\n+\n+\tTF_CHECK_PARMS2(tfp, parms);\n+\n+\t/* Retrieve the session information */\n+\trc = tf_session_get_session(tfp, &tfs);\n+\tif (rc) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"%s: Failed to lookup session, rc:%s\\n\",\n+\t\t\t    tf_dir_2_str(parms->dir),\n+\t\t\t    strerror(-rc));\n+\t\treturn rc;\n+\t}\n+\n+\t/* Retrieve the device information */\n+\trc = tf_session_get_device(tfs, &dev);\n+\tif (rc) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"%s: Failed to lookup device, rc:%s\\n\",\n+\t\t\t    tf_dir_2_str(parms->dir),\n+\t\t\t    strerror(-rc));\n+\t\treturn rc;\n+\t}\n+\n+\tif (dev->ops->tf_dev_move_tcam == NULL) {\n+\t\trc = -EOPNOTSUPP;\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"%s: Operation not supported, rc:%s\\n\",\n+\t\t\t    tf_dir_2_str(parms->dir),\n+\t\t\t    strerror(-rc));\n+\t\treturn rc;\n+\t}\n+\n+\trc = dev->ops->tf_dev_move_tcam(tfp, parms);\n+\tif (rc) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"%s: TCAM shared entries move failed, rc:%s\\n\",\n+\t\t\t    tf_dir_2_str(parms->dir),\n+\t\t\t    strerror(-rc));\n+\t\treturn rc;\n+\t}\n+\n+\treturn 0;\n+}\n+#endif /* TF_TCAM_SHARED */\n+\n int\n tf_alloc_tbl_entry(struct tf *tfp,\n \t\t   struct tf_alloc_tbl_entry_parms *parms)\ndiff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h\nindex 39a498122b..95cde2e8eb 100644\n--- a/drivers/net/bnxt/tf_core/tf_core.h\n+++ b/drivers/net/bnxt/tf_core/tf_core.h\n@@ -1242,6 +1242,10 @@ int tf_free_tbl_scope(struct tf *tfp,\n  * @ref tf_get_tcam_entry\n  *\n  * @ref tf_free_tcam_entry\n+ *\n+#ifdef TF_TCAM_SHARED\n+ * @ref tf_move_tcam_shared_entries\n+#endif\n  */\n \n /**\n@@ -1543,6 +1547,41 @@ struct tf_free_tcam_entry_parms {\n int tf_free_tcam_entry(struct tf *tfp,\n \t\t       struct tf_free_tcam_entry_parms *parms);\n \n+#ifdef TF_TCAM_SHARED\n+/**\n+ * tf_move_tcam_shared_entries parameter definition\n+ */\n+struct tf_move_tcam_shared_entries_parms {\n+\t/**\n+\t * [in] receive or transmit direction\n+\t */\n+\tenum tf_dir dir;\n+\t/**\n+\t * [in] TCAM table type\n+\t */\n+\tenum tf_tcam_tbl_type tcam_tbl_type;\n+};\n+\n+/**\n+ * Move TCAM entries\n+ *\n+ * This API only affects the following TCAM pools within a shared session:\n+ *\n+ * TF_TCAM_TBL_TYPE_WC_TCAM_HIGH\n+ * TF_TCAM_TBL_TYPE_WC_TCAM_LOW\n+ *\n+ * When called, all allocated entries from the high pool will be moved to\n+ * the low pool.  Then the allocated entries in the high pool will be\n+ * cleared and freed.\n+ *\n+ * This API is not supported on a non-shared session.\n+ *\n+ * Returns success or failure code.\n+ */\n+int tf_move_tcam_shared_entries(struct tf *tfp,\n+\t\t\t\tstruct tf_move_tcam_shared_entries_parms *parms);\n+\n+#endif /* TF_TCAM_SHARED */\n /**\n  * @page table Table Access\n  *\ndiff --git a/drivers/net/bnxt/tf_core/tf_device.h b/drivers/net/bnxt/tf_core/tf_device.h\nindex ea4dcfb8e2..48ab17d56b 100644\n--- a/drivers/net/bnxt/tf_core/tf_device.h\n+++ b/drivers/net/bnxt/tf_core/tf_device.h\n@@ -563,6 +563,24 @@ struct tf_dev_ops {\n \tint (*tf_dev_get_tcam)(struct tf *tfp,\n \t\t\t       struct tf_tcam_get_parms *parms);\n \n+#ifdef TF_TCAM_SHARED\n+\t/**\n+\t * Move TCAM shared entries\n+\t *\n+\t * [in] tfp\n+\t *   Pointer to TF handle\n+\t *\n+\t * [in] parms\n+\t *   Pointer to parameters\n+\t *\n+\t *    returns:\n+\t *    0       - Success\n+\t *    -EINVAL - Error\n+\t */\n+\tint (*tf_dev_move_tcam)(struct tf *tfp,\n+\t\t\t\tstruct tf_move_tcam_shared_entries_parms *parms);\n+#endif /* TF_TCAM_SHARED */\n+\n \t/**\n \t * Retrieves the tcam resource info.\n \t *\ndiff --git a/drivers/net/bnxt/tf_core/tf_device_p4.c b/drivers/net/bnxt/tf_core/tf_device_p4.c\nindex fccbccc2d8..c870f45ff0 100644\n--- a/drivers/net/bnxt/tf_core/tf_device_p4.c\n+++ b/drivers/net/bnxt/tf_core/tf_device_p4.c\n@@ -275,6 +275,7 @@ const struct tf_dev_ops tf_dev_ops_p4 = {\n \t.tf_dev_free_tcam = tf_tcam_shared_free,\n \t.tf_dev_set_tcam = tf_tcam_shared_set,\n \t.tf_dev_get_tcam = tf_tcam_shared_get,\n+\t.tf_dev_move_tcam = tf_tcam_shared_move_p4,\n #else /* !TF_TCAM_SHARED */\n \t.tf_dev_alloc_tcam = tf_tcam_alloc,\n \t.tf_dev_free_tcam = tf_tcam_free,\ndiff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c\nindex b25c5acf94..14b9d28b13 100644\n--- a/drivers/net/bnxt/tf_core/tf_device_p58.c\n+++ b/drivers/net/bnxt/tf_core/tf_device_p58.c\n@@ -295,8 +295,9 @@ const struct tf_dev_ops tf_dev_ops_p58 = {\n #ifdef TF_TCAM_SHARED\n \t.tf_dev_alloc_tcam = tf_tcam_shared_alloc,\n \t.tf_dev_free_tcam = tf_tcam_shared_free,\n-\t.tf_dev_set_tcam = tf_tcam_set,\n-\t.tf_dev_get_tcam = tf_tcam_get,\n+\t.tf_dev_set_tcam = tf_tcam_shared_set,\n+\t.tf_dev_get_tcam = tf_tcam_shared_get,\n+\t.tf_dev_move_tcam = tf_tcam_shared_move_p58,\n #else /* !TF_TCAM_SHARED */\n \t.tf_dev_alloc_tcam = tf_tcam_alloc,\n \t.tf_dev_free_tcam = tf_tcam_free,\ndiff --git a/drivers/net/bnxt/tf_core/tf_session.c b/drivers/net/bnxt/tf_core/tf_session.c\nindex e6ab518121..70844edb50 100644\n--- a/drivers/net/bnxt/tf_core/tf_session.c\n+++ b/drivers/net/bnxt/tf_core/tf_session.c\n@@ -945,3 +945,44 @@ tf_session_set_db(struct tf *tfp,\n \n \treturn rc;\n }\n+\n+#ifdef TF_TCAM_SHARED\n+\n+int\n+tf_session_get_tcam_shared_db(struct tf *tfp,\n+\t\t\t      void **tcam_shared_db_handle)\n+{\n+\tstruct tf_session *tfs = NULL;\n+\tint rc = 0;\n+\n+\t*tcam_shared_db_handle = NULL;\n+\n+\tif (tfp == NULL)\n+\t\treturn (-EINVAL);\n+\n+\trc = tf_session_get_session_internal(tfp, &tfs);\n+\tif (rc)\n+\t\treturn rc;\n+\n+\t*tcam_shared_db_handle = tfs->tcam_shared_db_handle;\n+\treturn rc;\n+}\n+\n+int\n+tf_session_set_tcam_shared_db(struct tf *tfp,\n+\t\t\t void *tcam_shared_db_handle)\n+{\n+\tstruct tf_session *tfs = NULL;\n+\tint rc = 0;\n+\n+\tif (tfp == NULL)\n+\t\treturn (-EINVAL);\n+\n+\trc = tf_session_get_session_internal(tfp, &tfs);\n+\tif (rc)\n+\t\treturn rc;\n+\n+\ttfs->tcam_shared_db_handle = tcam_shared_db_handle;\n+\treturn rc;\n+}\n+#endif /* TF_TCAM_SHARED */\ndiff --git a/drivers/net/bnxt/tf_core/tf_session.h b/drivers/net/bnxt/tf_core/tf_session.h\nindex 034a2213a4..c2875f9fa1 100644\n--- a/drivers/net/bnxt/tf_core/tf_session.h\n+++ b/drivers/net/bnxt/tf_core/tf_session.h\n@@ -159,6 +159,13 @@ struct tf_session {\n \t * EM allocator for session\n \t */\n \tvoid *em_pool[TF_DIR_MAX];\n+\n+#ifdef TF_TCAM_SHARED\n+\t/**\n+\t * tcam db reference for the session\n+\t */\n+\tvoid *tcam_shared_db_handle;\n+#endif /* TF_TCAM_SHARED */\n };\n \n /**\n@@ -255,6 +262,22 @@ struct tf_session_close_session_parms {\n  * @ref tf_session_get_fw_session_id\n  *\n  * @ref tf_session_get_session_id\n+ *\n+ * @ref tf_session_is_shared_session_creator\n+ *\n+ * @ref tf_session_get_db\n+ *\n+ * @ref tf_session_set_db\n+ *\n+ * @ref tf_session_get_bp\n+ *\n+ * @ref tf_session_is_shared_session\n+ *\n+ * #define TF_SHARED\n+ * @ref tf_session_get_tcam_shared_db\n+ *\n+ * @ref tf_session_set_tcam_shared_db\n+ * #endif\n  */\n \n /**\n@@ -566,4 +589,29 @@ tf_session_get_bp(struct tf *tfp)\n {\n \treturn tfp->bp;\n }\n+\n+/**\n+ * Set the pointer to the tcam shared database\n+ *\n+ * [in] session, pointer to the session\n+ *\n+ * Returns:\n+ *   - the pointer to the parent bnxt struct\n+ */\n+int\n+tf_session_set_tcam_shared_db(struct tf *tfp,\n+\t\t\t      void *tcam_shared_db_handle);\n+\n+/**\n+ * Get the pointer to the tcam shared database\n+ *\n+ * [in] session, pointer to the session\n+ *\n+ * Returns:\n+ *   - the pointer to the parent bnxt struct\n+ */\n+int\n+tf_session_get_tcam_shared_db(struct tf *tfp,\n+\t\t\t      void **tcam_shared_db_handle);\n+\n #endif /* _TF_SESSION_H_ */\ndiff --git a/drivers/net/bnxt/tf_core/tf_tcam.c b/drivers/net/bnxt/tf_core/tf_tcam.c\nindex 7878f8727a..d7e12e00ef 100644\n--- a/drivers/net/bnxt/tf_core/tf_tcam.c\n+++ b/drivers/net/bnxt/tf_core/tf_tcam.c\n@@ -299,7 +299,7 @@ tf_tcam_alloc(struct tf *tfp,\n \trc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);\n \tif (rc) {\n \t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"Failed to get em_ext_db from session, rc:%s\\n\",\n+\t\t\t    \"Failed to get tcam_db from session, rc:%s\\n\",\n \t\t\t    strerror(-rc));\n \t\treturn rc;\n \t}\ndiff --git a/drivers/net/bnxt/tf_core/tf_tcam_shared.c b/drivers/net/bnxt/tf_core/tf_tcam_shared.c\nindex 17d7fee7a8..0e8cb78f8d 100644\n--- a/drivers/net/bnxt/tf_core/tf_tcam_shared.c\n+++ b/drivers/net/bnxt/tf_core/tf_tcam_shared.c\n@@ -53,10 +53,34 @@ struct tf_tcam_shared_wc_pool {\n \tstruct bitalloc *pool;\n };\n \n+struct tf_tcam_shared_wc_pools {\n+\tstruct tf_tcam_shared_wc_pool db[TF_DIR_MAX][TF_TCAM_SHARED_WC_POOL_MAX];\n+};\n+\n /** The WC TCAM shared pool declarations\n- * TODO: add tcam_shared_wc_db\n  */\n-struct tf_tcam_shared_wc_pool tcam_shared_wc[TF_DIR_MAX][TF_TCAM_SHARED_WC_POOL_MAX];\n+/* struct tf_tcam_shared_wc_pool tcam_shared_wc[TF_DIR_MAX][TF_TCAM_SHARED_WC_POOL_MAX]; */\n+\n+static int\n+tf_tcam_shared_create_db(struct tf_tcam_shared_wc_pools **db)\n+{\n+\tstruct tfp_calloc_parms cparms;\n+\tint rc = 0;\n+\n+\tcparms.nitems = 1;\n+\tcparms.alignment = 0;\n+\tcparms.size = sizeof(struct tf_tcam_shared_wc_pools);\n+\trc = tfp_calloc(&cparms);\n+\tif (rc) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"TCAM shared db allocation failed (%s)\\n\",\n+\t\t\t    strerror(-rc));\n+\t\treturn rc;\n+\t}\n+\t*db = cparms.mem_va;\n+\n+\treturn rc;\n+}\n \n /** Create a WC TCAM shared pool\n  */\n@@ -64,7 +88,8 @@ static int\n tf_tcam_shared_create_wc_pool(int dir,\n \t\t\t      enum tf_tcam_shared_wc_pool_id id,\n \t\t\t      int start,\n-\t\t\t      int stride)\n+\t\t\t      int stride,\n+\t\t\t      struct tf_tcam_shared_wc_pools *tcam_shared_wc)\n {\n \tint rc = 0;\n \tbool free = true;\n@@ -84,9 +109,9 @@ tf_tcam_shared_create_wc_pool(int dir,\n \t\t\t    strerror(-rc));\n \t\treturn rc;\n \t}\n-\ttcam_shared_wc[dir][id].pool = (struct bitalloc *)cparms.mem_va;\n+\ttcam_shared_wc->db[dir][id].pool = (struct bitalloc *)cparms.mem_va;\n \n-\trc = ba_init(tcam_shared_wc[dir][id].pool,\n+\trc = ba_init(tcam_shared_wc->db[dir][id].pool,\n \t\t     stride,\n \t\t     free);\n \n@@ -97,21 +122,27 @@ tf_tcam_shared_create_wc_pool(int dir,\n \t\treturn rc;\n \t}\n \n-\ttcam_shared_wc[dir][id].info.start = start;\n-\ttcam_shared_wc[dir][id].info.stride = stride;\n+\ttcam_shared_wc->db[dir][id].info.start = start;\n+\ttcam_shared_wc->db[dir][id].info.stride = stride;\n+\n \treturn rc;\n }\n /** Free a WC TCAM shared pool\n  */\n-static void\n+static int\n tf_tcam_shared_free_wc_pool(int dir,\n-\t\t\t    enum tf_tcam_shared_wc_pool_id id)\n+\t\t\t    enum tf_tcam_shared_wc_pool_id id,\n+\t\t\t    struct tf_tcam_shared_wc_pools *tcam_shared_wc)\n {\n-\ttcam_shared_wc[dir][id].info.start = 0;\n-\ttcam_shared_wc[dir][id].info.stride = 0;\n+\tint rc = 0;\n+\tTF_CHECK_PARMS1(tcam_shared_wc);\n+\n+\ttcam_shared_wc->db[dir][id].info.start = 0;\n+\ttcam_shared_wc->db[dir][id].info.stride = 0;\n \n-\tif (tcam_shared_wc[dir][id].pool)\n-\t\ttfp_free((void *)tcam_shared_wc[dir][id].pool);\n+\tif (tcam_shared_wc->db[dir][id].pool)\n+\t\ttfp_free((void *)tcam_shared_wc->db[dir][id].pool);\n+\treturn rc;\n }\n \n /** Get the number of WC TCAM slices allocated during 1 allocation/free\n@@ -137,7 +168,7 @@ tf_tcam_shared_get_slices(struct tf *tfp,\n }\n \n static bool\n-tf_tcam_shared_db_valid(struct tf *tfp,\n+tf_tcam_db_valid(struct tf *tfp,\n \t\t\tenum tf_dir dir)\n {\n \tstruct tcam_rm_db *tcam_db;\n@@ -226,6 +257,7 @@ tf_tcam_shared_bind(struct tf *tfp,\n \tuint16_t start, stride;\n \tuint16_t num_slices;\n \tuint16_t hcapi_type;\n+\tstruct tf_tcam_shared_wc_pools *tcam_shared_wc = NULL;\n \n \tTF_CHECK_PARMS2(tfp, parms);\n \n@@ -256,11 +288,14 @@ tf_tcam_shared_bind(struct tf *tfp,\n \t\tif (rc)\n \t\t\treturn rc;\n \n+\t\ttf_tcam_shared_create_db(&tcam_shared_wc);\n+\n+\n \t\t/* If there are WC TCAM entries, create 2 pools each with 1/2\n \t\t * the total number of entries\n \t\t */\n \t\tfor (dir = 0; dir < TF_DIR_MAX; dir++) {\n-\t\t\tif (!tf_tcam_shared_db_valid(tfp, dir))\n+\t\t\tif (!tf_tcam_db_valid(tfp, dir))\n \t\t\t\tcontinue;\n \n \t\t\trc = tf_tcam_shared_get_rm_info(tfp,\n@@ -278,15 +313,19 @@ tf_tcam_shared_bind(struct tf *tfp,\n \t\t\tstride = info.entry.stride / 2;\n \n \t\t\ttf_tcam_shared_create_wc_pool(dir,\n-\t\t\t\t\t\tTF_TCAM_SHARED_WC_POOL_HI,\n-\t\t\t\t\t\tstart,\n-\t\t\t\t\t\tstride);\n+\t\t\t\t\t\t      TF_TCAM_SHARED_WC_POOL_HI,\n+\t\t\t\t\t\t      start,\n+\t\t\t\t\t\t      stride,\n+\t\t\t\t\t\t      tcam_shared_wc);\n \n \t\t\tstart += stride;\n \t\t\ttf_tcam_shared_create_wc_pool(dir,\n-\t\t\t\t\t\tTF_TCAM_SHARED_WC_POOL_LO,\n-\t\t\t\t\t\tstart,\n-\t\t\t\t\t\tstride);\n+\t\t\t\t\t\t      TF_TCAM_SHARED_WC_POOL_LO,\n+\t\t\t\t\t\t      start,\n+\t\t\t\t\t\t      stride,\n+\t\t\t\t\t\t      tcam_shared_wc);\n+\n+\t\t\ttf_session_set_tcam_shared_db(tfp, (void *)tcam_shared_wc);\n \t\t}\n \t}\n done:\n@@ -300,6 +339,8 @@ tf_tcam_shared_unbind(struct tf *tfp)\n {\n \tint rc, dir;\n \tstruct tf_session *tfs;\n+\tvoid *tcam_shared_db_ptr = NULL;\n+\tstruct tf_tcam_shared_wc_pools *tcam_shared_wc;\n \n \tTF_CHECK_PARMS1(tfp);\n \n@@ -315,6 +356,15 @@ tf_tcam_shared_unbind(struct tf *tfp)\n \tif (rc)\n \t\treturn rc;\n \n+\trc = tf_session_get_tcam_shared_db(tfp, (void *)&tcam_shared_db_ptr);\n+\tif (rc) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"Failed to get tcam_shared_db from session, rc:%s\\n\",\n+\t\t\t    strerror(-rc));\n+\t\treturn rc;\n+\t}\n+\ttcam_shared_wc = (struct tf_tcam_shared_wc_pools *)tcam_shared_db_ptr;\n+\n \t/* If we are the shared session\n \t */\n \tif (tf_session_is_shared_session(tfs)) {\n@@ -322,9 +372,11 @@ tf_tcam_shared_unbind(struct tf *tfp)\n \t\t */\n \t\tfor (dir = 0; dir < TF_DIR_MAX; dir++) {\n \t\t\ttf_tcam_shared_free_wc_pool(dir,\n-\t\t\t\t\t\t    TF_TCAM_SHARED_WC_POOL_HI);\n+\t\t\t\t\t\t    TF_TCAM_SHARED_WC_POOL_HI,\n+\t\t\t\t\t\t    tcam_shared_wc);\n \t\t\ttf_tcam_shared_free_wc_pool(dir,\n-\t\t\t\t\t\t    TF_TCAM_SHARED_WC_POOL_LO);\n+\t\t\t\t\t\t    TF_TCAM_SHARED_WC_POOL_LO,\n+\t\t\t\t\t\t    tcam_shared_wc);\n \t\t}\n \t}\n \treturn 0;\n@@ -343,6 +395,8 @@ tf_tcam_shared_alloc(struct tf *tfp,\n \tstruct bitalloc *pool;\n \tenum tf_tcam_shared_wc_pool_id id;\n \tuint16_t num_slices;\n+\tstruct tf_tcam_shared_wc_pools *tcam_shared_wc;\n+\tvoid *tcam_shared_db_ptr = NULL;\n \n \tTF_CHECK_PARMS2(tfp, parms);\n \n@@ -364,13 +418,22 @@ tf_tcam_shared_alloc(struct tf *tfp,\n \t\treturn rc;\n \t}\n \n-\tif (!tf_tcam_shared_db_valid(tfp, parms->dir)) {\n+\tif (!tf_tcam_db_valid(tfp, parms->dir)) {\n \t\tTFP_DRV_LOG(ERR,\n \t\t\t    \"%s: tcam shared pool doesn't exist\\n\",\n \t\t\t    tf_dir_2_str(parms->dir));\n \t\treturn -ENOMEM;\n \t}\n \n+\trc = tf_session_get_tcam_shared_db(tfp, (void *)&tcam_shared_db_ptr);\n+\tif (rc) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"Failed to get tcam_shared_db from session, rc:%s\\n\",\n+\t\t\t    strerror(-rc));\n+\t\treturn rc;\n+\t}\n+\ttcam_shared_wc = (struct tf_tcam_shared_wc_pools *)tcam_shared_db_ptr;\n+\n \tif (parms->type == TF_TCAM_TBL_TYPE_WC_TCAM_HIGH)\n \t\tid = TF_TCAM_SHARED_WC_POOL_HI;\n \telse\n@@ -385,7 +448,7 @@ tf_tcam_shared_alloc(struct tf *tfp,\n \tif (rc)\n \t\treturn rc;\n \n-\tpool = tcam_shared_wc[parms->dir][id].pool;\n+\tpool = tcam_shared_wc->db[parms->dir][id].pool;\n \n \tfor (i = 0; i < num_slices; i++) {\n \t\t/*\n@@ -427,6 +490,8 @@ tf_tcam_shared_free(struct tf *tfp,\n \tuint16_t num_slices;\n \tuint16_t hcapi_type;\n \tstruct tf_rm_alloc_info info;\n+\tvoid *tcam_shared_db_ptr = NULL;\n+\tstruct tf_tcam_shared_wc_pools *tcam_shared_wc;\n \n \tTF_CHECK_PARMS2(tfp, parms);\n \n@@ -448,13 +513,23 @@ tf_tcam_shared_free(struct tf *tfp,\n \t\treturn rc;\n \t}\n \n-\tif (!tf_tcam_shared_db_valid(tfp, parms->dir)) {\n+\tif (!tf_tcam_db_valid(tfp, parms->dir)) {\n \t\tTFP_DRV_LOG(ERR,\n \t\t\t    \"%s: tcam shared pool doesn't exist\\n\",\n \t\t\t    tf_dir_2_str(parms->dir));\n \t\treturn -ENOMEM;\n \t}\n \n+\trc = tf_session_get_tcam_shared_db(tfp, (void *)&tcam_shared_db_ptr);\n+\tif (rc) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"Failed to get tcam_shared_db from session, rc:%s\\n\",\n+\t\t\t    strerror(-rc));\n+\t\treturn rc;\n+\t}\n+\ttcam_shared_wc = (struct tf_tcam_shared_wc_pools *)tcam_shared_db_ptr;\n+\n+\n \tif (parms->type == TF_TCAM_TBL_TYPE_WC_TCAM_HIGH)\n \t\tid = TF_TCAM_SHARED_WC_POOL_HI;\n \telse\n@@ -480,8 +555,8 @@ tf_tcam_shared_free(struct tf *tfp,\n \t\treturn rc;\n \t}\n \n-\tpool = tcam_shared_wc[parms->dir][id].pool;\n-\tstart = tcam_shared_wc[parms->dir][id].info.start;\n+\tpool = tcam_shared_wc->db[parms->dir][id].pool;\n+\tstart = tcam_shared_wc->db[parms->dir][id].info.start;\n \n \tif (parms->idx % num_slices) {\n \t\tTFP_DRV_LOG(ERR,\n@@ -548,6 +623,9 @@ tf_tcam_shared_set(struct tf *tfp __rte_unused,\n \tenum tf_tcam_shared_wc_pool_id id;\n \tuint16_t hcapi_type;\n \tstruct tf_rm_alloc_info info;\n+\tstruct tf_tcam_shared_wc_pools *tcam_shared_wc;\n+\tvoid *tcam_shared_db_ptr = NULL;\n+\n \n \tTF_CHECK_PARMS2(tfp, parms);\n \n@@ -568,7 +646,7 @@ tf_tcam_shared_set(struct tf *tfp __rte_unused,\n \t\treturn rc;\n \t}\n \n-\tif (!tf_tcam_shared_db_valid(tfp, parms->dir)) {\n+\tif (!tf_tcam_db_valid(tfp, parms->dir)) {\n \t\tTFP_DRV_LOG(ERR,\n \t\t\t    \"%s: tcam shared pool doesn't exist\\n\",\n \t\t\t    tf_dir_2_str(parms->dir));\n@@ -585,8 +663,17 @@ tf_tcam_shared_set(struct tf *tfp __rte_unused,\n \telse\n \t\tid = TF_TCAM_SHARED_WC_POOL_LO;\n \n-\tpool = tcam_shared_wc[parms->dir][id].pool;\n-\tstart = tcam_shared_wc[parms->dir][id].info.start;\n+\trc = tf_session_get_tcam_shared_db(tfp, (void *)&tcam_shared_db_ptr);\n+\tif (rc) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"Failed to get tcam_shared_db from session, rc:%s\\n\",\n+\t\t\t    strerror(-rc));\n+\t\treturn rc;\n+\t}\n+\ttcam_shared_wc = (struct tf_tcam_shared_wc_pools *)tcam_shared_db_ptr;\n+\n+\tpool = tcam_shared_wc->db[parms->dir][id].pool;\n+\tstart = tcam_shared_wc->db[parms->dir][id].info.start;\n \n \tlog_idx = parms->idx;\n \tphy_idx = parms->idx + start;\n@@ -656,6 +743,8 @@ tf_tcam_shared_get(struct tf *tfp __rte_unused,\n \tenum tf_tcam_shared_wc_pool_id id;\n \tuint16_t hcapi_type;\n \tstruct tf_rm_alloc_info info;\n+\tstruct tf_tcam_shared_wc_pools *tcam_shared_wc;\n+\tvoid *tcam_shared_db_ptr = NULL;\n \n \tTF_CHECK_PARMS2(tfp, parms);\n \n@@ -676,7 +765,7 @@ tf_tcam_shared_get(struct tf *tfp __rte_unused,\n \t\treturn rc;\n \t}\n \n-\tif (!tf_tcam_shared_db_valid(tfp, parms->dir)) {\n+\tif (!tf_tcam_db_valid(tfp, parms->dir)) {\n \t\tTFP_DRV_LOG(ERR,\n \t\t\t    \"%s: tcam shared pool doesn't exist\\n\",\n \t\t\t    tf_dir_2_str(parms->dir));\n@@ -692,8 +781,18 @@ tf_tcam_shared_get(struct tf *tfp __rte_unused,\n \telse\n \t\tid = TF_TCAM_SHARED_WC_POOL_LO;\n \n-\tpool = tcam_shared_wc[parms->dir][id].pool;\n-\tstart = tcam_shared_wc[parms->dir][id].info.start;\n+\n+\trc = tf_session_get_tcam_shared_db(tfp, (void *)&tcam_shared_db_ptr);\n+\tif (rc) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"Failed to get tcam_shared_db from session, rc:%s\\n\",\n+\t\t\t    strerror(-rc));\n+\t\treturn rc;\n+\t}\n+\ttcam_shared_wc = (struct tf_tcam_shared_wc_pools *)tcam_shared_db_ptr;\n+\n+\tpool = tcam_shared_wc->db[parms->dir][id].pool;\n+\tstart = tcam_shared_wc->db[parms->dir][id].info.start;\n \n \trc = tf_tcam_shared_get_slices(tfp, dev, &num_slices);\n \tif (rc)\n@@ -742,3 +841,304 @@ tf_tcam_shared_get(struct tf *tfp __rte_unused,\n \t}\n \treturn 0;\n }\n+\n+/* Temporary builder defines pulled in here and renamed\n+ */\n+#define TF_TMP_MAX_FIELD_BITLEN 512\n+\n+union tf_tmp_field_obj {\n+\tuint8_t bytes[(TF_TMP_MAX_FIELD_BITLEN + 7) / 8];\n+};\n+\n+#define TF_TMP_MAX_KEY_BITLEN 768\n+#define TF_TMP_MAX_KEY_WORDLEN ((TF_TMP_MAX_KEY_BITLEN + 63) / 64)\n+\n+union tf_tmp_key {\n+\tuint32_t words[(TF_TMP_MAX_KEY_BITLEN + 31) / 32];\n+\tuint8_t bytes[(TF_TMP_MAX_KEY_BITLEN + 7) / 8];\n+};\n+\n+/** Move a WC TCAM entry from the high offset to the same low offset\n+ */\n+static int\n+tf_tcam_shared_move_entry(struct tf *tfp,\n+\t\t\t  struct tf_dev_info *dev,\n+\t\t\t  uint16_t hcapi_type,\n+\t\t\t  enum tf_dir dir,\n+\t\t\t  int sphy_idx,\n+\t\t\t  int dphy_idx,\n+\t\t\t  int key_sz_bytes,\n+\t\t\t  int remap_sz_bytes,\n+\t\t\t  uint16_t num_slices)\n+{\n+\tint rc = 0;\n+\tstruct tf_tcam_get_parms gparms;\n+\tstruct tf_tcam_set_parms sparms;\n+\tstruct tf_tcam_free_parms fparms;\n+\tunion tf_tmp_key tcam_key_obj;\n+\tunion tf_tmp_key tcam_key_msk_obj;\n+\tunion tf_tmp_field_obj tcam_remap_obj;\n+\n+\tmemset(&tcam_key_obj, 0, sizeof(tcam_key_obj));\n+\tmemset(&tcam_key_msk_obj, 0, sizeof(tcam_key_msk_obj));\n+\tmemset(&tcam_remap_obj, 0, sizeof(tcam_remap_obj));\n+\tmemset(&gparms, 0, sizeof(gparms));\n+\n+\tif (num_slices > 1) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"Only single slice supported\");\n+\t\treturn -EOPNOTSUPP;\n+\t}\n+\n+\tgparms.hcapi_type = hcapi_type;\n+\tgparms.dir = dir;\n+\tgparms.type = TF_TCAM_TBL_TYPE_WC_TCAM;\n+\tgparms.idx = sphy_idx;\n+\tgparms.key = (uint8_t *)&tcam_key_obj;\n+\tgparms.key_size = key_sz_bytes;\n+\tgparms.mask = (uint8_t *)&tcam_key_msk_obj;\n+\tgparms.result = (uint8_t *)&tcam_remap_obj;\n+\tgparms.result_size = remap_sz_bytes;\n+\n+\trc = tf_msg_tcam_entry_get(tfp, dev, &gparms);\n+\tif (rc) {\n+\t\t/* Log error */\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"%s: WC_TCAM_HIGH: phyid(%d) get failed, rc:%s\",\n+\t\t\t    tf_dir_2_str(dir),\n+\t\t\t    gparms.idx,\n+\t\t\t    strerror(-rc));\n+\t\treturn rc;\n+\t}\n+\n+\t/* Override HI/LO type with parent WC TCAM type */\n+\tsparms.hcapi_type = hcapi_type;\n+\tsparms.dir = dir;\n+\tsparms.type = TF_TCAM_TBL_TYPE_WC_TCAM;\n+\tsparms.idx = dphy_idx;\n+\tsparms.key = gparms.key;\n+\tsparms.mask = gparms.mask;\n+\tsparms.key_size = gparms.key_size;\n+\tsparms.result = gparms.result;\n+\tsparms.result_size = gparms.result_size;\n+\n+\trc = tf_msg_tcam_entry_set(tfp, dev, &sparms);\n+\tif (rc) {\n+\t\t/* Log error */\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"%s: WC_TCAM_LOW phyid(%d) set failed, rc:%s\",\n+\t\t\t    tf_dir_2_str(dir),\n+\t\t\t    sparms.idx,\n+\t\t\t    strerror(-rc));\n+\t\treturn rc;\n+\t}\n+\n+\t/* Override HI/LO type with parent WC TCAM type */\n+\tfparms.dir = dir;\n+\tfparms.type = TF_TCAM_TBL_TYPE_WC_TCAM;\n+\tfparms.hcapi_type = hcapi_type;\n+\tfparms.idx = sphy_idx;\n+\n+\trc = tf_msg_tcam_entry_free(tfp, dev, &fparms);\n+\tif (rc) {\n+\t\t/* Log error */\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"%s: %s: phyid(%d) free failed, rc:%s\\n\",\n+\t\t\t    tf_dir_2_str(dir),\n+\t\t\t    tf_tcam_tbl_2_str(fparms.type),\n+\t\t\t    sphy_idx,\n+\t\t\t    strerror(-rc));\n+\t\treturn rc;\n+\t}\n+\treturn rc;\n+}\n+\n+/** Move all shared WC TCAM entries from the high pool into the low pool\n+ *  and clear out the high pool entries.\n+ */\n+static\n+int tf_tcam_shared_move(struct tf *tfp,\n+\t\t\tstruct tf_move_tcam_shared_entries_parms *parms,\n+\t\t\tint key_sz_bytes,\n+\t\t\tint remap_sz_bytes)\n+{\n+\tint rc;\n+\tstruct tf_session *tfs;\n+\tstruct tf_dev_info *dev;\n+\tint log_idx;\n+\tuint16_t num_slices;\n+\tstruct bitalloc *hi_pool, *lo_pool;\n+\tuint16_t hi_start, lo_start;\n+\tenum tf_tcam_shared_wc_pool_id hi_id, lo_id;\n+\tuint16_t hcapi_type;\n+\tstruct tf_rm_alloc_info info;\n+\tint hi_cnt, i, j;\n+\tstruct tf_tcam_shared_wc_pools *tcam_shared_wc;\n+\tvoid *tcam_shared_db_ptr = NULL;\n+\n+\tTF_CHECK_PARMS2(tfp, parms);\n+\n+\t/* Retrieve the session information */\n+\trc = tf_session_get_session_internal(tfp, &tfs);\n+\tif (rc)\n+\t\treturn rc;\n+\n+\t/* If we aren't the shared session or one of our\n+\t * special types\n+\t */\n+\tif (!tf_session_is_shared_session(tfs) ||\n+\t    (parms->tcam_tbl_type != TF_TCAM_TBL_TYPE_WC_TCAM_HIGH &&\n+\t     parms->tcam_tbl_type != TF_TCAM_TBL_TYPE_WC_TCAM_LOW)) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"%s: Session must be shared with HI/LO type\\n\",\n+\t\t\t    tf_dir_2_str(parms->dir));\n+\t\treturn -EOPNOTSUPP;\n+\t}\n+\n+\tif (!tf_tcam_db_valid(tfp, parms->dir)) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"%s: tcam shared pool doesn't exist\\n\",\n+\t\t\t    tf_dir_2_str(parms->dir));\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\t/* Retrieve the device information */\n+\trc = tf_session_get_device(tfs, &dev);\n+\tif (rc) {\n+\t\t/* TODO print amazing error */\n+\t\treturn rc;\n+\t}\n+\trc = tf_tcam_shared_get_slices(tfp, dev, &num_slices);\n+\tif (rc)\n+\t\treturn rc;\n+\n+\trc = tf_tcam_shared_get_rm_info(tfp,\n+\t\t\t\t\tparms->dir,\n+\t\t\t\t\t&hcapi_type,\n+\t\t\t\t\t&info);\n+\tif (rc) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"%s: TCAM rm info get failed\\n\",\n+\t\t\t    tf_dir_2_str(parms->dir));\n+\t\treturn rc;\n+\t}\n+\n+\trc = tf_session_get_tcam_shared_db(tfp, (void *)&tcam_shared_db_ptr);\n+\tif (rc) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"Failed to get tcam_shared_db from session, rc:%s\\n\",\n+\t\t\t    strerror(-rc));\n+\t\treturn rc;\n+\t}\n+\ttcam_shared_wc = (struct tf_tcam_shared_wc_pools *)tcam_shared_db_ptr;\n+\n+\thi_id = TF_TCAM_SHARED_WC_POOL_HI;\n+\thi_pool = tcam_shared_wc->db[parms->dir][hi_id].pool;\n+\thi_start = tcam_shared_wc->db[parms->dir][hi_id].info.start;\n+\n+\tlo_id = TF_TCAM_SHARED_WC_POOL_LO;\n+\tlo_pool = tcam_shared_wc->db[parms->dir][lo_id].pool;\n+\tlo_start = tcam_shared_wc->db[parms->dir][lo_id].info.start;\n+\n+\tif (hi_pool == NULL || lo_pool == NULL)\n+\t\treturn -ENOMEM;\n+\n+\t/* Get the total count of in use entries in the high pool\n+\t */\n+\thi_cnt = ba_inuse_count(hi_pool);\n+\n+\t/* Copy each valid entry to the same low pool logical offset\n+\t */\n+\tfor (i = 0; i < hi_cnt; i++) {\n+\t\t/* Go through all the slices\n+\t\t */\n+\t\tfor (j = 0; j < num_slices; j++) {\n+\t\t\t/* Find next free starting from where we left off\n+\t\t\t */\n+\t\t\tlog_idx = ba_find_next_inuse(hi_pool, i);\n+\n+\t\t\tif (log_idx < 0) {\n+\t\t\t\tTFP_DRV_LOG(ERR,\n+\t\t\t\t\t    \"Expected a found %s entry %d\\n\",\n+\t\t\t\t\t    tf_pool_2_str(hi_id),\n+\t\t\t\t\t    i);\n+\t\t\t\tgoto done;\n+\t\t\t}\n+\t\t\t/* The user should have never allocated from the low\n+\t\t\t * pool because the move only happens when switching\n+\t\t\t * from the high to the low pool\n+\t\t\t */\n+\t\t\tif (ba_alloc_index(lo_pool, log_idx) < 0) {\n+\t\t\t\tTFP_DRV_LOG(ERR,\n+\t\t\t\t\t    \"Cannot allocate %s index %d\\n\",\n+\t\t\t\t\t    tf_pool_2_str(lo_id),\n+\t\t\t\t\t    i);\n+\t\t\t\tgoto done;\n+\t\t\t}\n+\n+\t\t\tif (j == 0) {\n+\t\t\t\trc = tf_tcam_shared_move_entry(tfp, dev,\n+\t\t\t\t\t\t\t       hcapi_type,\n+\t\t\t\t\t\t\t       parms->dir,\n+\t\t\t\t\t\t\t       hi_start + log_idx,\n+\t\t\t\t\t\t\t       lo_start + log_idx,\n+\t\t\t\t\t\t\t       key_sz_bytes,\n+\t\t\t\t\t\t\t       remap_sz_bytes,\n+\t\t\t\t\t\t\t       num_slices);\n+\t\t\t\tif (rc) {\n+\t\t\t\t\tTFP_DRV_LOG(ERR,\n+\t\t\t\t\t\t    \"Cannot allocate %s index %d\\n\",\n+\t\t\t\t\t\t    tf_pool_2_str(hi_id),\n+\t\t\t\t\t\t    i);\n+\t\t\t\t\tgoto done;\n+\t\t\t\t}\n+\t\t\t\tba_free(hi_pool, log_idx);\n+\t\t\t\tTFP_DRV_LOG(DEBUG,\n+\t\t\t\t\t    \"%s: TCAM shared move pool(%s) phyid(%d)\\n\",\n+\t\t\t\t\t    tf_dir_2_str(parms->dir),\n+\t\t\t\t\t    tf_pool_2_str(hi_id),\n+\t\t\t\t\t    hi_start + log_idx);\n+\t\t\t\tTFP_DRV_LOG(DEBUG,\n+\t\t\t\t\t    \"to pool(%s) phyid(%d)\\n\",\n+\t\t\t\t\t    tf_pool_2_str(lo_id),\n+\t\t\t\t\t    lo_start + log_idx);\n+\t\t\t}\n+\t\t}\n+\t}\n+done:\n+\treturn rc;\n+}\n+\n+/* Normally, device specific code wouldn't reside here, it belongs\n+ * in a separate device specific function in tf_device_pxx.c.\n+ * But this code is placed here as it is not a long term solution\n+ * and we would like to have this code centrally located for easy\n+ * removal\n+ */\n+#define TF_TCAM_SHARED_KEY_SLICE_SZ_BYTES_P4 12\n+#define TF_TCAM_SHARED_REMAP_SZ_BYTES_P4 4\n+\n+int tf_tcam_shared_move_p4(struct tf *tfp,\n+\t\t\t   struct tf_move_tcam_shared_entries_parms *parms)\n+{\n+\tint rc = 0;\n+\trc = tf_tcam_shared_move(tfp,\n+\t\t\t\t parms,\n+\t\t\t\t TF_TCAM_SHARED_KEY_SLICE_SZ_BYTES_P4,\n+\t\t\t\t TF_TCAM_SHARED_REMAP_SZ_BYTES_P4);\n+\treturn rc;\n+}\n+\n+#define TF_TCAM_SHARED_KEY_SLICE_SZ_BYTES_P58 24\n+#define TF_TCAM_SHARED_REMAP_SZ_BYTES_P58 8\n+\n+int tf_tcam_shared_move_p58(struct tf *tfp,\n+\t\t\t    struct tf_move_tcam_shared_entries_parms *parms)\n+{\n+\tint rc = 0;\n+\trc = tf_tcam_shared_move(tfp,\n+\t\t\t\t parms,\n+\t\t\t\t TF_TCAM_SHARED_KEY_SLICE_SZ_BYTES_P58,\n+\t\t\t\t TF_TCAM_SHARED_REMAP_SZ_BYTES_P58);\n+\treturn rc;\n+}\ndiff --git a/drivers/net/bnxt/tf_core/tf_tcam_shared.h b/drivers/net/bnxt/tf_core/tf_tcam_shared.h\nindex fad6e23b4c..5588125470 100644\n--- a/drivers/net/bnxt/tf_core/tf_tcam_shared.h\n+++ b/drivers/net/bnxt/tf_core/tf_tcam_shared.h\n@@ -124,4 +124,39 @@ int tf_tcam_shared_set(struct tf *tfp,\n int tf_tcam_shared_get(struct tf *tfp,\n \t\t       struct tf_tcam_get_parms *parms);\n \n+\n+/**\n+ * Moves entries from the WC_TCAM_HI to the WC_TCAM_LO shared pools\n+ * for the P4 device.\n+ *\n+ * [in] tfp\n+ *   Pointer to the truflow handle\n+ *\n+ * [in] parms\n+ *   Pointer to parameters\n+ *\n+ * Returns\n+ *   - (0) if successful.\n+ *   - (-EINVAL) on failure.\n+ */\n+int tf_tcam_shared_move_p4(struct tf *tfp,\n+\t\t\t   struct tf_move_tcam_shared_entries_parms *parms);\n+\n+/**\n+ * Moves entries from the WC_TCAM_HI to the WC_TCAM_LO shared pools\n+ * for the P58 device.\n+ *\n+ * [in] tfp\n+ *   Pointer to the truflow handle\n+ *\n+ * [in] parms\n+ *   Pointer to parameters\n+ *\n+ * Returns\n+ *   - (0) if successful.\n+ *   - (-EINVAL) on failure.\n+ */\n+int tf_tcam_shared_move_p58(struct tf *tfp,\n+\t\t\t    struct tf_move_tcam_shared_entries_parms *parms);\n+\n #endif /* _TF_TCAM_SHARED_H */\n",
    "prefixes": [
        "20/58"
    ]
}