get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 73069,
    "url": "https://patches.dpdk.org/api/patches/73069/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20200703210210.40568-19-ajit.khaparde@broadcom.com/",
    "project": {
        "id": 1,
        "url": "https://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": "<20200703210210.40568-19-ajit.khaparde@broadcom.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200703210210.40568-19-ajit.khaparde@broadcom.com",
    "date": "2020-07-03T21:01:37",
    "name": "[v5,18/51] net/bnxt: multiple device implementation",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "f5db7a2d8f21dc757e0b6250f36610a7d42217f1",
    "submitter": {
        "id": 501,
        "url": "https://patches.dpdk.org/api/people/501/?format=api",
        "name": "Ajit Khaparde",
        "email": "ajit.khaparde@broadcom.com"
    },
    "delegate": {
        "id": 1766,
        "url": "https://patches.dpdk.org/api/users/1766/?format=api",
        "username": "ajitkhaparde",
        "first_name": "Ajit",
        "last_name": "Khaparde",
        "email": "ajit.khaparde@broadcom.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20200703210210.40568-19-ajit.khaparde@broadcom.com/mbox/",
    "series": [
        {
            "id": 10785,
            "url": "https://patches.dpdk.org/api/series/10785/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=10785",
            "date": "2020-07-03T21:01:19",
            "name": "net/bnxt: add features for host-based flow management",
            "version": 5,
            "mbox": "https://patches.dpdk.org/series/10785/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/73069/comments/",
    "check": "fail",
    "checks": "https://patches.dpdk.org/api/patches/73069/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 dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id E88F9A0524;\n\tFri,  3 Jul 2020 23:08:42 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 67AE91DD24;\n\tFri,  3 Jul 2020 23:05:38 +0200 (CEST)",
            "from rnd-relay.smtp.broadcom.com (rnd-relay.smtp.broadcom.com\n [192.19.229.170]) by dpdk.org (Postfix) with ESMTP id 4A1B31DC46\n for <dev@dpdk.org>; Fri,  3 Jul 2020 23:05:04 +0200 (CEST)",
            "from mail-irv-17.broadcom.com (mail-irv-17.lvn.broadcom.net\n [10.75.242.48])\n by rnd-relay.smtp.broadcom.com (Postfix) with ESMTP id 4343D30C067;\n Fri,  3 Jul 2020 14:05:03 -0700 (PDT)",
            "from localhost.localdomain (unknown [10.230.185.215])\n by mail-irv-17.broadcom.com (Postfix) with ESMTP id F16A3140069;\n Fri,  3 Jul 2020 14:05:00 -0700 (PDT)"
        ],
        "DKIM-Filter": "OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com 4343D30C067",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com;\n s=dkimrelay; t=1593810303;\n bh=92vTNiPOq5LWdSp8NOROsEbZudiR5dDSzhbE418CzWI=;\n h=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n b=nEc3O52hoNuiePqbv2Po3GkYj5JLZSXaM84TatvXavV1PYrxsuQaVWfM+xe6pFl9G\n O+VrMmtihtkXdncTdQEnylRgtbYAa9klR/nAUPtFJuFy6SIgc6xZD1ixxCHCV/j35q\n ZS/9+ai8nfk0056a4d9qE0Cj6fggv7fEXCzj6axg=",
        "From": "Ajit Khaparde <ajit.khaparde@broadcom.com>",
        "To": "dev@dpdk.org",
        "Cc": "Michael Wildt <michael.wildt@broadcom.com>,\n Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>,\n Randy Schacher <stuart.schacher@broadcom.com>",
        "Date": "Fri,  3 Jul 2020 14:01:37 -0700",
        "Message-Id": "<20200703210210.40568-19-ajit.khaparde@broadcom.com>",
        "X-Mailer": "git-send-email 2.21.1 (Apple Git-122.3)",
        "In-Reply-To": "<20200703210210.40568-1-ajit.khaparde@broadcom.com>",
        "References": "<1f5421dc-0453-6dc8-09c2-ddfff6eb4888@intel.com>\n <20200703210210.40568-1-ajit.khaparde@broadcom.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH v5 18/51] net/bnxt: multiple device implementation",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "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: Michael Wildt <michael.wildt@broadcom.com>\n\nImplement the Identifier, Table Type and the Resource Manager\nmodules.\nIntegrate Resource Manager with HCAPI.\nUpdate open/close session.\nMove to direct msgs for qcaps and resv messages.\n\nSigned-off-by: Michael Wildt <michael.wildt@broadcom.com>\nSigned-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>\nReviewed-by: Randy Schacher <stuart.schacher@broadcom.com>\nReviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>\n---\n drivers/net/bnxt/tf_core/tf_core.c       | 751 ++++++++---------------\n drivers/net/bnxt/tf_core/tf_core.h       |  97 ++-\n drivers/net/bnxt/tf_core/tf_device.c     |  10 +-\n drivers/net/bnxt/tf_core/tf_device.h     |   1 +\n drivers/net/bnxt/tf_core/tf_device_p4.c  |  26 +-\n drivers/net/bnxt/tf_core/tf_identifier.c |  29 +-\n drivers/net/bnxt/tf_core/tf_identifier.h |   4 +-\n drivers/net/bnxt/tf_core/tf_msg.c        |  45 +-\n drivers/net/bnxt/tf_core/tf_msg.h        |   1 +\n drivers/net/bnxt/tf_core/tf_rm_new.c     | 225 +++++--\n drivers/net/bnxt/tf_core/tf_rm_new.h     |  11 +-\n drivers/net/bnxt/tf_core/tf_session.c    |  28 +-\n drivers/net/bnxt/tf_core/tf_session.h    |   2 +-\n drivers/net/bnxt/tf_core/tf_tbl.c        | 611 +-----------------\n drivers/net/bnxt/tf_core/tf_tbl_type.c   | 252 +++++++-\n drivers/net/bnxt/tf_core/tf_tbl_type.h   |   2 +-\n drivers/net/bnxt/tf_core/tf_tcam.c       |  12 +-\n drivers/net/bnxt/tf_core/tf_util.h       |  45 +-\n drivers/net/bnxt/tf_core/tfp.c           |   4 +-\n 19 files changed, 880 insertions(+), 1276 deletions(-)",
    "diff": "diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c\nindex 29522c66e..3e23d0513 100644\n--- a/drivers/net/bnxt/tf_core/tf_core.c\n+++ b/drivers/net/bnxt/tf_core/tf_core.c\n@@ -19,284 +19,15 @@\n #include \"tf_common.h\"\n #include \"hwrm_tf.h\"\n \n-/**\n- * Create EM Tbl pool of memory indexes.\n- *\n- * [in] session\n- *   Pointer to session\n- * [in] dir\n- *   direction\n- * [in] num_entries\n- *   number of entries to write\n- *\n- * Return:\n- *  0       - Success, entry allocated - no search support\n- *  -ENOMEM -EINVAL -EOPNOTSUPP\n- *          - Failure, entry not allocated, out of resources\n- */\n-static int\n-tf_create_em_pool(struct tf_session *session,\n-\t\t  enum tf_dir dir,\n-\t\t  uint32_t num_entries)\n-{\n-\tstruct tfp_calloc_parms parms;\n-\tuint32_t i, j;\n-\tint rc = 0;\n-\tstruct stack *pool = &session->em_pool[dir];\n-\n-\tparms.nitems = num_entries;\n-\tparms.size = sizeof(uint32_t);\n-\tparms.alignment = 0;\n-\n-\tif (tfp_calloc(&parms) != 0) {\n-\t\tTFP_DRV_LOG(ERR, \"EM pool allocation failure %s\\n\",\n-\t\t\t    strerror(-ENOMEM));\n-\t\treturn -ENOMEM;\n-\t}\n-\n-\t/* Create empty stack\n-\t */\n-\trc = stack_init(num_entries, (uint32_t *)parms.mem_va, pool);\n-\n-\tif (rc != 0) {\n-\t\tTFP_DRV_LOG(ERR, \"EM pool stack init failure %s\\n\",\n-\t\t\t    strerror(-rc));\n-\t\tgoto cleanup;\n-\t}\n-\n-\t/* Fill pool with indexes\n-\t */\n-\tj = num_entries - 1;\n-\n-\tfor (i = 0; i < num_entries; i++) {\n-\t\trc = stack_push(pool, j);\n-\t\tif (rc != 0) {\n-\t\t\tTFP_DRV_LOG(ERR, \"EM pool stack push failure %s\\n\",\n-\t\t\t\t    strerror(-rc));\n-\t\t\tgoto cleanup;\n-\t\t}\n-\t\tj--;\n-\t}\n-\n-\tif (!stack_is_full(pool)) {\n-\t\trc = -EINVAL;\n-\t\tTFP_DRV_LOG(ERR, \"EM pool stack failure %s\\n\",\n-\t\t\t    strerror(-rc));\n-\t\tgoto cleanup;\n-\t}\n-\n-\treturn 0;\n-cleanup:\n-\ttfp_free((void *)parms.mem_va);\n-\treturn rc;\n-}\n-\n-/**\n- * Create EM Tbl pool of memory indexes.\n- *\n- * [in] session\n- *   Pointer to session\n- * [in] dir\n- *   direction\n- *\n- * Return:\n- */\n-static void\n-tf_free_em_pool(struct tf_session *session,\n-\t\tenum tf_dir dir)\n-{\n-\tstruct stack *pool = &session->em_pool[dir];\n-\tuint32_t *ptr;\n-\n-\tptr = stack_items(pool);\n-\n-\ttfp_free(ptr);\n-}\n-\n int\n-tf_open_session(struct tf                    *tfp,\n+tf_open_session(struct tf *tfp,\n \t\tstruct tf_open_session_parms *parms)\n-{\n-\tint rc;\n-\tstruct tf_session *session;\n-\tstruct tfp_calloc_parms alloc_parms;\n-\tunsigned int domain, bus, slot, device;\n-\tuint8_t fw_session_id;\n-\tint dir;\n-\n-\tTF_CHECK_PARMS(tfp, parms);\n-\n-\t/* Filter out any non-supported device types on the Core\n-\t * side. It is assumed that the Firmware will be supported if\n-\t * firmware open session succeeds.\n-\t */\n-\tif (parms->device_type != TF_DEVICE_TYPE_WH) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"Unsupported device type %d\\n\",\n-\t\t\t    parms->device_type);\n-\t\treturn -ENOTSUP;\n-\t}\n-\n-\t/* Build the beginning of session_id */\n-\trc = sscanf(parms->ctrl_chan_name,\n-\t\t    \"%x:%x:%x.%d\",\n-\t\t    &domain,\n-\t\t    &bus,\n-\t\t    &slot,\n-\t\t    &device);\n-\tif (rc != 4) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"Failed to scan device ctrl_chan_name\\n\");\n-\t\treturn -EINVAL;\n-\t}\n-\n-\t/* open FW session and get a new session_id */\n-\trc = tf_msg_session_open(tfp,\n-\t\t\t\t parms->ctrl_chan_name,\n-\t\t\t\t &fw_session_id);\n-\tif (rc) {\n-\t\t/* Log error */\n-\t\tif (rc == -EEXIST)\n-\t\t\tTFP_DRV_LOG(ERR,\n-\t\t\t\t    \"Session is already open, rc:%s\\n\",\n-\t\t\t\t    strerror(-rc));\n-\t\telse\n-\t\t\tTFP_DRV_LOG(ERR,\n-\t\t\t\t    \"Open message send failed, rc:%s\\n\",\n-\t\t\t\t    strerror(-rc));\n-\n-\t\tparms->session_id.id = TF_FW_SESSION_ID_INVALID;\n-\t\treturn rc;\n-\t}\n-\n-\t/* Allocate session */\n-\talloc_parms.nitems = 1;\n-\talloc_parms.size = sizeof(struct tf_session_info);\n-\talloc_parms.alignment = 0;\n-\trc = tfp_calloc(&alloc_parms);\n-\tif (rc) {\n-\t\t/* Log error */\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"Failed to allocate session info, rc:%s\\n\",\n-\t\t\t    strerror(-rc));\n-\t\tgoto cleanup;\n-\t}\n-\n-\ttfp->session = (struct tf_session_info *)alloc_parms.mem_va;\n-\n-\t/* Allocate core data for the session */\n-\talloc_parms.nitems = 1;\n-\talloc_parms.size = sizeof(struct tf_session);\n-\talloc_parms.alignment = 0;\n-\trc = tfp_calloc(&alloc_parms);\n-\tif (rc) {\n-\t\t/* Log error */\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"Failed to allocate session data, rc:%s\\n\",\n-\t\t\t    strerror(-rc));\n-\t\tgoto cleanup;\n-\t}\n-\n-\ttfp->session->core_data = alloc_parms.mem_va;\n-\n-\tsession = (struct tf_session *)tfp->session->core_data;\n-\ttfp_memcpy(session->ctrl_chan_name,\n-\t\t   parms->ctrl_chan_name,\n-\t\t   TF_SESSION_NAME_MAX);\n-\n-\t/* Initialize Session */\n-\tsession->dev = NULL;\n-\ttf_rm_init(tfp);\n-\n-\t/* Construct the Session ID */\n-\tsession->session_id.internal.domain = domain;\n-\tsession->session_id.internal.bus = bus;\n-\tsession->session_id.internal.device = device;\n-\tsession->session_id.internal.fw_session_id = fw_session_id;\n-\n-\t/* Query for Session Config\n-\t */\n-\trc = tf_msg_session_qcfg(tfp);\n-\tif (rc) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"Query config message send failed, rc:%s\\n\",\n-\t\t\t    strerror(-rc));\n-\t\tgoto cleanup_close;\n-\t}\n-\n-\t/* Shadow DB configuration */\n-\tif (parms->shadow_copy) {\n-\t\t/* Ignore shadow_copy setting */\n-\t\tsession->shadow_copy = 0;/* parms->shadow_copy; */\n-#if (TF_SHADOW == 1)\n-\t\trc = tf_rm_shadow_db_init(tfs);\n-\t\tif (rc)\n-\t\t\tTFP_DRV_LOG(ERR,\n-\t\t\t\t    \"Shadow DB Initialization failed\\n, rc:%s\",\n-\t\t\t\t    strerror(-rc));\n-\t\t/* Add additional processing */\n-#endif /* TF_SHADOW */\n-\t}\n-\n-\t/* Adjust the Session with what firmware allowed us to get */\n-\trc = tf_rm_allocate_validate(tfp);\n-\tif (rc) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"Rm allocate validate failed, rc:%s\\n\",\n-\t\t\t    strerror(-rc));\n-\t\tgoto cleanup_close;\n-\t}\n-\n-\t/* Initialize EM pool */\n-\tfor (dir = 0; dir < TF_DIR_MAX; dir++) {\n-\t\trc = tf_create_em_pool(session,\n-\t\t\t\t       (enum tf_dir)dir,\n-\t\t\t\t       TF_SESSION_EM_POOL_SIZE);\n-\t\tif (rc) {\n-\t\t\tTFP_DRV_LOG(ERR,\n-\t\t\t\t    \"EM Pool initialization failed\\n\");\n-\t\t\tgoto cleanup_close;\n-\t\t}\n-\t}\n-\n-\tsession->ref_count++;\n-\n-\t/* Return session ID */\n-\tparms->session_id = session->session_id;\n-\n-\tTFP_DRV_LOG(INFO,\n-\t\t    \"Session created, session_id:%d\\n\",\n-\t\t    parms->session_id.id);\n-\n-\tTFP_DRV_LOG(INFO,\n-\t\t    \"domain:%d, bus:%d, device:%d, fw_session_id:%d\\n\",\n-\t\t    parms->session_id.internal.domain,\n-\t\t    parms->session_id.internal.bus,\n-\t\t    parms->session_id.internal.device,\n-\t\t    parms->session_id.internal.fw_session_id);\n-\n-\treturn 0;\n-\n- cleanup:\n-\ttfp_free(tfp->session->core_data);\n-\ttfp_free(tfp->session);\n-\ttfp->session = NULL;\n-\treturn rc;\n-\n- cleanup_close:\n-\ttf_close_session(tfp);\n-\treturn -EINVAL;\n-}\n-\n-int\n-tf_open_session_new(struct tf *tfp,\n-\t\t    struct tf_open_session_parms *parms)\n {\n \tint rc;\n \tunsigned int domain, bus, slot, device;\n \tstruct tf_session_open_session_parms oparms;\n \n-\tTF_CHECK_PARMS(tfp, parms);\n+\tTF_CHECK_PARMS2(tfp, parms);\n \n \t/* Filter out any non-supported device types on the Core\n \t * side. It is assumed that the Firmware will be supported if\n@@ -347,33 +78,8 @@ tf_open_session_new(struct tf *tfp,\n }\n \n int\n-tf_attach_session(struct tf *tfp __rte_unused,\n-\t\t  struct tf_attach_session_parms *parms __rte_unused)\n-{\n-#if (TF_SHARED == 1)\n-\tint rc;\n-\n-\tTF_CHECK_PARMS_SESSION(tfp, parms);\n-\n-\t/* - Open the shared memory for the attach_chan_name\n-\t * - Point to the shared session for this Device instance\n-\t * - Check that session is valid\n-\t * - Attach to the firmware so it can record there is more\n-\t *   than one client of the session.\n-\t */\n-\n-\tif (tfp->session->session_id.id != TF_SESSION_ID_INVALID) {\n-\t\trc = tf_msg_session_attach(tfp,\n-\t\t\t\t\t   parms->ctrl_chan_name,\n-\t\t\t\t\t   parms->session_id);\n-\t}\n-#endif /* TF_SHARED */\n-\treturn -1;\n-}\n-\n-int\n-tf_attach_session_new(struct tf *tfp,\n-\t\t      struct tf_attach_session_parms *parms)\n+tf_attach_session(struct tf *tfp,\n+\t\t  struct tf_attach_session_parms *parms)\n {\n \tint rc;\n \tunsigned int domain, bus, slot, device;\n@@ -436,65 +142,6 @@ tf_attach_session_new(struct tf *tfp,\n \n int\n tf_close_session(struct tf *tfp)\n-{\n-\tint rc;\n-\tint rc_close = 0;\n-\tstruct tf_session *tfs;\n-\tunion tf_session_id session_id;\n-\tint dir;\n-\n-\tTF_CHECK_TFP_SESSION(tfp);\n-\n-\ttfs = (struct tf_session *)(tfp->session->core_data);\n-\n-\t/* Cleanup if we're last user of the session */\n-\tif (tfs->ref_count == 1) {\n-\t\t/* Cleanup any outstanding resources */\n-\t\trc_close = tf_rm_close(tfp);\n-\t}\n-\n-\tif (tfs->session_id.id != TF_SESSION_ID_INVALID) {\n-\t\trc = tf_msg_session_close(tfp);\n-\t\tif (rc) {\n-\t\t\t/* Log error */\n-\t\t\tTFP_DRV_LOG(ERR,\n-\t\t\t\t    \"Message send failed, rc:%s\\n\",\n-\t\t\t\t    strerror(-rc));\n-\t\t}\n-\n-\t\t/* Update the ref_count */\n-\t\ttfs->ref_count--;\n-\t}\n-\n-\tsession_id = tfs->session_id;\n-\n-\t/* Final cleanup as we're last user of the session */\n-\tif (tfs->ref_count == 0) {\n-\t\t/* Free EM pool */\n-\t\tfor (dir = 0; dir < TF_DIR_MAX; dir++)\n-\t\t\ttf_free_em_pool(tfs, (enum tf_dir)dir);\n-\n-\t\ttfp_free(tfp->session->core_data);\n-\t\ttfp_free(tfp->session);\n-\t\ttfp->session = NULL;\n-\t}\n-\n-\tTFP_DRV_LOG(INFO,\n-\t\t    \"Session closed, session_id:%d\\n\",\n-\t\t    session_id.id);\n-\n-\tTFP_DRV_LOG(INFO,\n-\t\t    \"domain:%d, bus:%d, device:%d, fw_session_id:%d\\n\",\n-\t\t    session_id.internal.domain,\n-\t\t    session_id.internal.bus,\n-\t\t    session_id.internal.device,\n-\t\t    session_id.internal.fw_session_id);\n-\n-\treturn rc_close;\n-}\n-\n-int\n-tf_close_session_new(struct tf *tfp)\n {\n \tint rc;\n \tstruct tf_session_close_session_parms cparms = { 0 };\n@@ -620,76 +267,9 @@ int tf_delete_em_entry(struct tf *tfp,\n \treturn rc;\n }\n \n-int tf_alloc_identifier(struct tf *tfp,\n-\t\t\tstruct tf_alloc_identifier_parms *parms)\n-{\n-\tstruct bitalloc *session_pool;\n-\tstruct tf_session *tfs;\n-\tint id;\n-\tint rc;\n-\n-\tTF_CHECK_PARMS_SESSION(tfp, parms);\n-\n-\ttfs = (struct tf_session *)(tfp->session->core_data);\n-\n-\tswitch (parms->ident_type) {\n-\tcase TF_IDENT_TYPE_L2_CTXT:\n-\t\tTF_RM_GET_POOLS(tfs, parms->dir, &session_pool,\n-\t\t\t\tTF_L2_CTXT_REMAP_POOL_NAME,\n-\t\t\t\trc);\n-\t\tbreak;\n-\tcase TF_IDENT_TYPE_PROF_FUNC:\n-\t\tTF_RM_GET_POOLS(tfs, parms->dir, &session_pool,\n-\t\t\t\tTF_PROF_FUNC_POOL_NAME,\n-\t\t\t\trc);\n-\t\tbreak;\n-\tcase TF_IDENT_TYPE_EM_PROF:\n-\t\tTF_RM_GET_POOLS(tfs, parms->dir, &session_pool,\n-\t\t\t\tTF_EM_PROF_ID_POOL_NAME,\n-\t\t\t\trc);\n-\t\tbreak;\n-\tcase TF_IDENT_TYPE_WC_PROF:\n-\t\tTF_RM_GET_POOLS(tfs, parms->dir, &session_pool,\n-\t\t\t\tTF_WC_TCAM_PROF_ID_POOL_NAME,\n-\t\t\t\trc);\n-\t\tbreak;\n-\tcase TF_IDENT_TYPE_L2_FUNC:\n-\t\tTFP_DRV_LOG(ERR, \"%s: unsupported %s\\n\",\n-\t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t    tf_ident_2_str(parms->ident_type));\n-\t\trc = -EOPNOTSUPP;\n-\t\tbreak;\n-\tdefault:\n-\t\tTFP_DRV_LOG(ERR, \"%s: %s\\n\",\n-\t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t    tf_ident_2_str(parms->ident_type));\n-\t\trc = -EOPNOTSUPP;\n-\t\tbreak;\n-\t}\n-\n-\tif (rc) {\n-\t\tTFP_DRV_LOG(ERR, \"%s: identifier pool %s failure, rc:%s\\n\",\n-\t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t    tf_ident_2_str(parms->ident_type),\n-\t\t\t    strerror(-rc));\n-\t\treturn rc;\n-\t}\n-\n-\tid = ba_alloc(session_pool);\n-\n-\tif (id == BA_FAIL) {\n-\t\tTFP_DRV_LOG(ERR, \"%s: %s: No resource available\\n\",\n-\t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t    tf_ident_2_str(parms->ident_type));\n-\t\treturn -ENOMEM;\n-\t}\n-\tparms->id = id;\n-\treturn 0;\n-}\n-\n int\n-tf_alloc_identifier_new(struct tf *tfp,\n-\t\t\tstruct tf_alloc_identifier_parms *parms)\n+tf_alloc_identifier(struct tf *tfp,\n+\t\t    struct tf_alloc_identifier_parms *parms)\n {\n \tint rc;\n \tstruct tf_session *tfs;\n@@ -732,7 +312,7 @@ tf_alloc_identifier_new(struct tf *tfp,\n \t}\n \n \taparms.dir = parms->dir;\n-\taparms.ident_type = parms->ident_type;\n+\taparms.type = parms->ident_type;\n \taparms.id = &id;\n \trc = dev->ops->tf_dev_alloc_ident(tfp, &aparms);\n \tif (rc) {\n@@ -748,79 +328,9 @@ tf_alloc_identifier_new(struct tf *tfp,\n \treturn 0;\n }\n \n-int tf_free_identifier(struct tf *tfp,\n-\t\t       struct tf_free_identifier_parms *parms)\n-{\n-\tstruct bitalloc *session_pool;\n-\tint rc;\n-\tint ba_rc;\n-\tstruct tf_session *tfs;\n-\n-\tTF_CHECK_PARMS_SESSION(tfp, parms);\n-\n-\ttfs = (struct tf_session *)(tfp->session->core_data);\n-\n-\tswitch (parms->ident_type) {\n-\tcase TF_IDENT_TYPE_L2_CTXT:\n-\t\tTF_RM_GET_POOLS(tfs, parms->dir, &session_pool,\n-\t\t\t\tTF_L2_CTXT_REMAP_POOL_NAME,\n-\t\t\t\trc);\n-\t\tbreak;\n-\tcase TF_IDENT_TYPE_PROF_FUNC:\n-\t\tTF_RM_GET_POOLS(tfs, parms->dir, &session_pool,\n-\t\t\t\tTF_PROF_FUNC_POOL_NAME,\n-\t\t\t\trc);\n-\t\tbreak;\n-\tcase TF_IDENT_TYPE_EM_PROF:\n-\t\tTF_RM_GET_POOLS(tfs, parms->dir, &session_pool,\n-\t\t\t\tTF_EM_PROF_ID_POOL_NAME,\n-\t\t\t\trc);\n-\t\tbreak;\n-\tcase TF_IDENT_TYPE_WC_PROF:\n-\t\tTF_RM_GET_POOLS(tfs, parms->dir, &session_pool,\n-\t\t\t\tTF_WC_TCAM_PROF_ID_POOL_NAME,\n-\t\t\t\trc);\n-\t\tbreak;\n-\tcase TF_IDENT_TYPE_L2_FUNC:\n-\t\tTFP_DRV_LOG(ERR, \"%s: unsupported %s\\n\",\n-\t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t    tf_ident_2_str(parms->ident_type));\n-\t\trc = -EOPNOTSUPP;\n-\t\tbreak;\n-\tdefault:\n-\t\tTFP_DRV_LOG(ERR, \"%s: invalid %s\\n\",\n-\t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t    tf_ident_2_str(parms->ident_type));\n-\t\trc = -EOPNOTSUPP;\n-\t\tbreak;\n-\t}\n-\tif (rc) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s: %s Identifier pool access failed, rc:%s\\n\",\n-\t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t    tf_ident_2_str(parms->ident_type),\n-\t\t\t    strerror(-rc));\n-\t\treturn rc;\n-\t}\n-\n-\tba_rc = ba_inuse(session_pool, (int)parms->id);\n-\n-\tif (ba_rc == BA_FAIL || ba_rc == BA_ENTRY_FREE) {\n-\t\tTFP_DRV_LOG(ERR, \"%s: %s: Entry %d already free\",\n-\t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t    tf_ident_2_str(parms->ident_type),\n-\t\t\t    parms->id);\n-\t\treturn -EINVAL;\n-\t}\n-\n-\tba_free(session_pool, (int)parms->id);\n-\n-\treturn 0;\n-}\n-\n int\n-tf_free_identifier_new(struct tf *tfp,\n-\t\t       struct tf_free_identifier_parms *parms)\n+tf_free_identifier(struct tf *tfp,\n+\t\t   struct tf_free_identifier_parms *parms)\n {\n \tint rc;\n \tstruct tf_session *tfs;\n@@ -862,12 +372,12 @@ tf_free_identifier_new(struct tf *tfp,\n \t}\n \n \tfparms.dir = parms->dir;\n-\tfparms.ident_type = parms->ident_type;\n+\tfparms.type = parms->ident_type;\n \tfparms.id = parms->id;\n \trc = dev->ops->tf_dev_free_ident(tfp, &fparms);\n \tif (rc) {\n \t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s: Identifier allocation failed, rc:%s\\n\",\n+\t\t\t    \"%s: Identifier free 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@@ -1057,3 +567,242 @@ tf_free_tcam_entry(struct tf *tfp,\n \n \treturn 0;\n }\n+\n+int\n+tf_alloc_tbl_entry(struct tf *tfp,\n+\t\t   struct tf_alloc_tbl_entry_parms *parms)\n+{\n+\tint rc;\n+\tstruct tf_session *tfs;\n+\tstruct tf_dev_info *dev;\n+\tstruct tf_tbl_alloc_parms aparms;\n+\tuint32_t idx;\n+\n+\tTF_CHECK_PARMS2(tfp, parms);\n+\n+\t/* Can't do static initialization due to UT enum check */\n+\tmemset(&aparms, 0, sizeof(struct tf_tbl_alloc_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_alloc_tbl == 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 -EOPNOTSUPP;\n+\t}\n+\n+\taparms.dir = parms->dir;\n+\taparms.type = parms->type;\n+\taparms.idx = &idx;\n+\trc = dev->ops->tf_dev_alloc_tbl(tfp, &aparms);\n+\tif (rc) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"%s: Table allocation 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+\tparms->idx = idx;\n+\n+\treturn 0;\n+}\n+\n+int\n+tf_free_tbl_entry(struct tf *tfp,\n+\t\t  struct tf_free_tbl_entry_parms *parms)\n+{\n+\tint rc;\n+\tstruct tf_session *tfs;\n+\tstruct tf_dev_info *dev;\n+\tstruct tf_tbl_free_parms fparms;\n+\n+\tTF_CHECK_PARMS2(tfp, parms);\n+\n+\t/* Can't do static initialization due to UT enum check */\n+\tmemset(&fparms, 0, sizeof(struct tf_tbl_free_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_free_tbl == 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 -EOPNOTSUPP;\n+\t}\n+\n+\tfparms.dir = parms->dir;\n+\tfparms.type = parms->type;\n+\tfparms.idx = parms->idx;\n+\trc = dev->ops->tf_dev_free_tbl(tfp, &fparms);\n+\tif (rc) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"%s: Table free 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+\n+int\n+tf_set_tbl_entry(struct tf *tfp,\n+\t\t struct tf_set_tbl_entry_parms *parms)\n+{\n+\tint rc = 0;\n+\tstruct tf_session *tfs;\n+\tstruct tf_dev_info *dev;\n+\tstruct tf_tbl_set_parms sparms;\n+\n+\tTF_CHECK_PARMS3(tfp, parms, parms->data);\n+\n+\t/* Can't do static initialization due to UT enum check */\n+\tmemset(&sparms, 0, sizeof(struct tf_tbl_set_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_set_tbl == 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 -EOPNOTSUPP;\n+\t}\n+\n+\tsparms.dir = parms->dir;\n+\tsparms.type = parms->type;\n+\tsparms.data = parms->data;\n+\tsparms.data_sz_in_bytes = parms->data_sz_in_bytes;\n+\tsparms.idx = parms->idx;\n+\trc = dev->ops->tf_dev_set_tbl(tfp, &sparms);\n+\tif (rc) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"%s: Table set 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 rc;\n+}\n+\n+int\n+tf_get_tbl_entry(struct tf *tfp,\n+\t\t struct tf_get_tbl_entry_parms *parms)\n+{\n+\tint rc = 0;\n+\tstruct tf_session *tfs;\n+\tstruct tf_dev_info *dev;\n+\tstruct tf_tbl_get_parms gparms;\n+\n+\tTF_CHECK_PARMS3(tfp, parms, parms->data);\n+\n+\t/* Can't do static initialization due to UT enum check */\n+\tmemset(&gparms, 0, sizeof(struct tf_tbl_get_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_get_tbl == 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 -EOPNOTSUPP;\n+\t}\n+\n+\tgparms.dir = parms->dir;\n+\tgparms.type = parms->type;\n+\tgparms.data = parms->data;\n+\tgparms.data_sz_in_bytes = parms->data_sz_in_bytes;\n+\tgparms.idx = parms->idx;\n+\trc = dev->ops->tf_dev_get_tbl(tfp, &gparms);\n+\tif (rc) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"%s: Table get 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 rc;\n+}\ndiff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h\nindex bb456bba7..a7a7bd38a 100644\n--- a/drivers/net/bnxt/tf_core/tf_core.h\n+++ b/drivers/net/bnxt/tf_core/tf_core.h\n@@ -384,34 +384,87 @@ struct tf {\n \tstruct tf_session_info *session;\n };\n \n+/**\n+ * Identifier resource definition\n+ */\n+struct tf_identifier_resources {\n+\t/**\n+\t * Array of TF Identifiers where each entry is expected to be\n+\t * set to the requested resource number of that specific type.\n+\t * The index used is tf_identifier_type.\n+\t */\n+\tuint16_t cnt[TF_IDENT_TYPE_MAX];\n+};\n+\n+/**\n+ * Table type resource definition\n+ */\n+struct tf_tbl_resources {\n+\t/**\n+\t * Array of TF Table types where each entry is expected to be\n+\t * set to the requeste resource number of that specific\n+\t * type. The index used is tf_tbl_type.\n+\t */\n+\tuint16_t cnt[TF_TBL_TYPE_MAX];\n+};\n+\n+/**\n+ * TCAM type resource definition\n+ */\n+struct tf_tcam_resources {\n+\t/**\n+\t * Array of TF TCAM types where each entry is expected to be\n+\t * set to the requested resource number of that specific\n+\t * type. The index used is tf_tcam_tbl_type.\n+\t */\n+\tuint16_t cnt[TF_TCAM_TBL_TYPE_MAX];\n+};\n+\n+/**\n+ * EM type resource definition\n+ */\n+struct tf_em_resources {\n+\t/**\n+\t * Array of TF EM table types where each entry is expected to\n+\t * be set to the requested resource number of that specific\n+\t * type. The index used is tf_em_tbl_type.\n+\t */\n+\tuint16_t cnt[TF_EM_TBL_TYPE_MAX];\n+};\n+\n /**\n  * tf_session_resources parameter definition.\n  */\n struct tf_session_resources {\n-\t/** [in] Requested Identifier Resources\n+\t/**\n+\t * [in] Requested Identifier Resources\n \t *\n-\t * The number of identifier resources requested for the session.\n-\t * The index used is tf_identifier_type.\n+\t * Number of identifier resources requested for the\n+\t * session.\n \t */\n-\tuint16_t identifier_cnt[TF_IDENT_TYPE_MAX][TF_DIR_MAX];\n-\t/** [in] Requested Index Table resource counts\n+\tstruct tf_identifier_resources ident_cnt[TF_DIR_MAX];\n+\t/**\n+\t * [in] Requested Index Table resource counts\n \t *\n-\t * The number of index table resources requested for the session.\n-\t * The index used is tf_tbl_type.\n+\t * The number of index table resources requested for the\n+\t * session.\n \t */\n-\tuint16_t tbl_cnt[TF_TBL_TYPE_MAX][TF_DIR_MAX];\n-\t/** [in] Requested TCAM Table resource counts\n+\tstruct tf_tbl_resources tbl_cnt[TF_DIR_MAX];\n+\t/**\n+\t * [in] Requested TCAM Table resource counts\n \t *\n-\t * The number of TCAM table resources requested for the session.\n-\t * The index used is tf_tcam_tbl_type.\n+\t * The number of TCAM table resources requested for the\n+\t * session.\n \t */\n-\tuint16_t tcam_tbl_cnt[TF_TCAM_TBL_TYPE_MAX][TF_DIR_MAX];\n-\t/** [in] Requested EM resource counts\n+\n+\tstruct tf_tcam_resources tcam_cnt[TF_DIR_MAX];\n+\t/**\n+\t * [in] Requested EM resource counts\n \t *\n-\t * The number of internal EM table resources requested for the session\n-\t * The index used is tf_em_tbl_type.\n+\t * The number of internal EM table resources requested for the\n+\t * session.\n \t */\n-\tuint16_t em_tbl_cnt[TF_EM_TBL_TYPE_MAX][TF_DIR_MAX];\n+\tstruct tf_em_resources em_cnt[TF_DIR_MAX];\n };\n \n /**\n@@ -497,9 +550,6 @@ struct tf_open_session_parms {\n int tf_open_session(struct tf *tfp,\n \t\t    struct tf_open_session_parms *parms);\n \n-int tf_open_session_new(struct tf *tfp,\n-\t\t\tstruct tf_open_session_parms *parms);\n-\n struct tf_attach_session_parms {\n \t/**\n \t * [in] ctrl_chan_name\n@@ -565,8 +615,6 @@ struct tf_attach_session_parms {\n  */\n int tf_attach_session(struct tf *tfp,\n \t\t      struct tf_attach_session_parms *parms);\n-int tf_attach_session_new(struct tf *tfp,\n-\t\t\t  struct tf_attach_session_parms *parms);\n \n /**\n  * Closes an existing session. Cleans up all hardware and firmware\n@@ -576,7 +624,6 @@ int tf_attach_session_new(struct tf *tfp,\n  * Returns success or failure code.\n  */\n int tf_close_session(struct tf *tfp);\n-int tf_close_session_new(struct tf *tfp);\n \n /**\n  * @page  ident Identity Management\n@@ -631,8 +678,6 @@ struct tf_free_identifier_parms {\n  */\n int tf_alloc_identifier(struct tf *tfp,\n \t\t\tstruct tf_alloc_identifier_parms *parms);\n-int tf_alloc_identifier_new(struct tf *tfp,\n-\t\t\t    struct tf_alloc_identifier_parms *parms);\n \n /**\n  * free identifier resource\n@@ -645,8 +690,6 @@ int tf_alloc_identifier_new(struct tf *tfp,\n  */\n int tf_free_identifier(struct tf *tfp,\n \t\t       struct tf_free_identifier_parms *parms);\n-int tf_free_identifier_new(struct tf *tfp,\n-\t\t\t   struct tf_free_identifier_parms *parms);\n \n /**\n  * @page dram_table DRAM Table Scope Interface\n@@ -1277,7 +1320,7 @@ struct tf_bulk_get_tbl_entry_parms {\n  * provided data buffer is too small for the data type requested.\n  */\n int tf_bulk_get_tbl_entry(struct tf *tfp,\n-\t\t     struct tf_bulk_get_tbl_entry_parms *parms);\n+\t\t\t  struct tf_bulk_get_tbl_entry_parms *parms);\n \n /**\n  * @page exact_match Exact Match Table\ndiff --git a/drivers/net/bnxt/tf_core/tf_device.c b/drivers/net/bnxt/tf_core/tf_device.c\nindex 4c46cadc6..b474e8c25 100644\n--- a/drivers/net/bnxt/tf_core/tf_device.c\n+++ b/drivers/net/bnxt/tf_core/tf_device.c\n@@ -43,6 +43,14 @@ dev_bind_p4(struct tf *tfp,\n \tstruct tf_tbl_cfg_parms tbl_cfg;\n \tstruct tf_tcam_cfg_parms tcam_cfg;\n \n+\tdev_handle->type = TF_DEVICE_TYPE_WH;\n+\t/* Initial function initialization */\n+\tdev_handle->ops = &tf_dev_ops_p4_init;\n+\n+\tdev_handle->type = TF_DEVICE_TYPE_WH;\n+\t/* Initial function initialization */\n+\tdev_handle->ops = &tf_dev_ops_p4_init;\n+\n \t/* Initialize the modules */\n \n \tident_cfg.num_elements = TF_IDENT_TYPE_MAX;\n@@ -78,7 +86,7 @@ dev_bind_p4(struct tf *tfp,\n \t\tgoto fail;\n \t}\n \n-\tdev_handle->type = TF_DEVICE_TYPE_WH;\n+\t/* Final function initialization */\n \tdev_handle->ops = &tf_dev_ops_p4;\n \n \treturn 0;\ndiff --git a/drivers/net/bnxt/tf_core/tf_device.h b/drivers/net/bnxt/tf_core/tf_device.h\nindex 32d9a5442..c31bf2357 100644\n--- a/drivers/net/bnxt/tf_core/tf_device.h\n+++ b/drivers/net/bnxt/tf_core/tf_device.h\n@@ -407,6 +407,7 @@ struct tf_dev_ops {\n /**\n  * Supported device operation structures\n  */\n+extern const struct tf_dev_ops tf_dev_ops_p4_init;\n extern const struct tf_dev_ops tf_dev_ops_p4;\n \n #endif /* _TF_DEVICE_H_ */\ndiff --git a/drivers/net/bnxt/tf_core/tf_device_p4.c b/drivers/net/bnxt/tf_core/tf_device_p4.c\nindex 77fb693dd..9e332c594 100644\n--- a/drivers/net/bnxt/tf_core/tf_device_p4.c\n+++ b/drivers/net/bnxt/tf_core/tf_device_p4.c\n@@ -75,6 +75,26 @@ tf_dev_p4_get_tcam_slice_info(struct tf *tfp __rte_unused,\n \treturn 0;\n }\n \n+/**\n+ * Truflow P4 device specific functions\n+ */\n+const struct tf_dev_ops tf_dev_ops_p4_init = {\n+\t.tf_dev_get_max_types = tf_dev_p4_get_max_types,\n+\t.tf_dev_get_tcam_slice_info = tf_dev_p4_get_tcam_slice_info,\n+\t.tf_dev_alloc_ident = NULL,\n+\t.tf_dev_free_ident = NULL,\n+\t.tf_dev_alloc_tbl = NULL,\n+\t.tf_dev_free_tbl = NULL,\n+\t.tf_dev_alloc_search_tbl = NULL,\n+\t.tf_dev_set_tbl = NULL,\n+\t.tf_dev_get_tbl = NULL,\n+\t.tf_dev_alloc_tcam = NULL,\n+\t.tf_dev_free_tcam = NULL,\n+\t.tf_dev_alloc_search_tcam = NULL,\n+\t.tf_dev_set_tcam = NULL,\n+\t.tf_dev_get_tcam = NULL,\n+};\n+\n /**\n  * Truflow P4 device specific functions\n  */\n@@ -85,14 +105,14 @@ const struct tf_dev_ops tf_dev_ops_p4 = {\n \t.tf_dev_free_ident = tf_ident_free,\n \t.tf_dev_alloc_tbl = tf_tbl_alloc,\n \t.tf_dev_free_tbl = tf_tbl_free,\n-\t.tf_dev_alloc_search_tbl = tf_tbl_alloc_search,\n+\t.tf_dev_alloc_search_tbl = NULL,\n \t.tf_dev_set_tbl = tf_tbl_set,\n \t.tf_dev_get_tbl = tf_tbl_get,\n \t.tf_dev_alloc_tcam = tf_tcam_alloc,\n \t.tf_dev_free_tcam = tf_tcam_free,\n-\t.tf_dev_alloc_search_tcam = tf_tcam_alloc_search,\n+\t.tf_dev_alloc_search_tcam = NULL,\n \t.tf_dev_set_tcam = tf_tcam_set,\n-\t.tf_dev_get_tcam = tf_tcam_get,\n+\t.tf_dev_get_tcam = NULL,\n \t.tf_dev_insert_em_entry = tf_em_insert_entry,\n \t.tf_dev_delete_em_entry = tf_em_delete_entry,\n };\ndiff --git a/drivers/net/bnxt/tf_core/tf_identifier.c b/drivers/net/bnxt/tf_core/tf_identifier.c\nindex e89f9768b..ee07a6aea 100644\n--- a/drivers/net/bnxt/tf_core/tf_identifier.c\n+++ b/drivers/net/bnxt/tf_core/tf_identifier.c\n@@ -45,19 +45,22 @@ tf_ident_bind(struct tf *tfp,\n \t\tdb_cfg.dir = i;\n \t\tdb_cfg.num_elements = parms->num_elements;\n \t\tdb_cfg.cfg = parms->cfg;\n-\t\tdb_cfg.alloc_num = parms->resources->identifier_cnt[i];\n-\t\tdb_cfg.rm_db = ident_db[i];\n+\t\tdb_cfg.alloc_cnt = parms->resources->ident_cnt[i].cnt;\n+\t\tdb_cfg.rm_db = &ident_db[i];\n \t\trc = tf_rm_create_db(tfp, &db_cfg);\n \t\tif (rc) {\n \t\t\tTFP_DRV_LOG(ERR,\n \t\t\t\t    \"%s: Identifier DB creation failed\\n\",\n \t\t\t\t    tf_dir_2_str(i));\n+\n \t\t\treturn rc;\n \t\t}\n \t}\n \n \tinit = 1;\n \n+\tprintf(\"Identifier - initialized\\n\");\n+\n \treturn 0;\n }\n \n@@ -73,8 +76,11 @@ tf_ident_unbind(struct tf *tfp __rte_unused)\n \t/* Bail if nothing has been initialized done silent as to\n \t * allow for creation cleanup.\n \t */\n-\tif (!init)\n+\tif (!init) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"No Identifier DBs created\\n\");\n \t\treturn -EINVAL;\n+\t}\n \n \tfor (i = 0; i < TF_DIR_MAX; i++) {\n \t\tfparms.dir = i;\n@@ -96,6 +102,7 @@ tf_ident_alloc(struct tf *tfp __rte_unused,\n \t       struct tf_ident_alloc_parms *parms)\n {\n \tint rc;\n+\tuint32_t id;\n \tstruct tf_rm_allocate_parms aparms = { 0 };\n \n \tTF_CHECK_PARMS2(tfp, parms);\n@@ -109,17 +116,19 @@ tf_ident_alloc(struct tf *tfp __rte_unused,\n \n \t/* Allocate requested element */\n \taparms.rm_db = ident_db[parms->dir];\n-\taparms.db_index = parms->ident_type;\n-\taparms.index = (uint32_t *)&parms->id;\n+\taparms.db_index = parms->type;\n+\taparms.index = &id;\n \trc = tf_rm_allocate(&aparms);\n \tif (rc) {\n \t\tTFP_DRV_LOG(ERR,\n \t\t\t    \"%s: Failed allocate, type:%d\\n\",\n \t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t    parms->ident_type);\n+\t\t\t    parms->type);\n \t\treturn rc;\n \t}\n \n+\t*parms->id = id;\n+\n \treturn 0;\n }\n \n@@ -143,7 +152,7 @@ tf_ident_free(struct tf *tfp __rte_unused,\n \n \t/* Check if element is in use */\n \taparms.rm_db = ident_db[parms->dir];\n-\taparms.db_index = parms->ident_type;\n+\taparms.db_index = parms->type;\n \taparms.index = parms->id;\n \taparms.allocated = &allocated;\n \trc = tf_rm_is_allocated(&aparms);\n@@ -154,21 +163,21 @@ tf_ident_free(struct tf *tfp __rte_unused,\n \t\tTFP_DRV_LOG(ERR,\n \t\t\t    \"%s: Entry already free, type:%d, index:%d\\n\",\n \t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t    parms->ident_type,\n+\t\t\t    parms->type,\n \t\t\t    parms->id);\n \t\treturn rc;\n \t}\n \n \t/* Free requested element */\n \tfparms.rm_db = ident_db[parms->dir];\n-\tfparms.db_index = parms->ident_type;\n+\tfparms.db_index = parms->type;\n \tfparms.index = parms->id;\n \trc = tf_rm_free(&fparms);\n \tif (rc) {\n \t\tTFP_DRV_LOG(ERR,\n \t\t\t    \"%s: Free failed, type:%d, index:%d\\n\",\n \t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t    parms->ident_type,\n+\t\t\t    parms->type,\n \t\t\t    parms->id);\n \t\treturn rc;\n \t}\ndiff --git a/drivers/net/bnxt/tf_core/tf_identifier.h b/drivers/net/bnxt/tf_core/tf_identifier.h\nindex 1c5319b5e..6e36c525f 100644\n--- a/drivers/net/bnxt/tf_core/tf_identifier.h\n+++ b/drivers/net/bnxt/tf_core/tf_identifier.h\n@@ -43,7 +43,7 @@ struct tf_ident_alloc_parms {\n \t/**\n \t * [in] Identifier type\n \t */\n-\tenum tf_identifier_type ident_type;\n+\tenum tf_identifier_type type;\n \t/**\n \t * [out] Identifier allocated\n \t */\n@@ -61,7 +61,7 @@ struct tf_ident_free_parms {\n \t/**\n \t * [in] Identifier type\n \t */\n-\tenum tf_identifier_type ident_type;\n+\tenum tf_identifier_type type;\n \t/**\n \t * [in] ID to free\n \t */\ndiff --git a/drivers/net/bnxt/tf_core/tf_msg.c b/drivers/net/bnxt/tf_core/tf_msg.c\nindex b50e1d48c..a2e3840f0 100644\n--- a/drivers/net/bnxt/tf_core/tf_msg.c\n+++ b/drivers/net/bnxt/tf_core/tf_msg.c\n@@ -12,6 +12,7 @@\n #include \"tf_device.h\"\n #include \"tf_msg.h\"\n #include \"tf_util.h\"\n+#include \"tf_common.h\"\n #include \"tf_session.h\"\n #include \"tfp.h\"\n #include \"hwrm_tf.h\"\n@@ -935,13 +936,7 @@ tf_msg_session_resc_qcaps(struct tf *tfp,\n \tstruct tf_rm_resc_req_entry *data;\n \tint dma_size;\n \n-\tif (size == 0 || query == NULL || resv_strategy == NULL) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s: Resource QCAPS parameter error, rc:%s\\n\",\n-\t\t\t    tf_dir_2_str(dir),\n-\t\t\t    strerror(-EINVAL));\n-\t\treturn -EINVAL;\n-\t}\n+\tTF_CHECK_PARMS3(tfp, query, resv_strategy);\n \n \trc = tf_session_get_fw_session_id(tfp, &fw_session_id);\n \tif (rc) {\n@@ -962,7 +957,7 @@ tf_msg_session_resc_qcaps(struct tf *tfp,\n \treq.fw_session_id = tfp_cpu_to_le_32(fw_session_id);\n \treq.flags = tfp_cpu_to_le_16(dir);\n \treq.qcaps_size = size;\n-\treq.qcaps_addr = qcaps_buf.pa_addr;\n+\treq.qcaps_addr = tfp_cpu_to_le_64(qcaps_buf.pa_addr);\n \n \tparms.tf_type = HWRM_TF_SESSION_RESC_QCAPS;\n \tparms.req_data = (uint32_t *)&req;\n@@ -980,18 +975,29 @@ tf_msg_session_resc_qcaps(struct tf *tfp,\n \t */\n \tif (resp.size != size) {\n \t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s: QCAPS message error, rc:%s\\n\",\n+\t\t\t    \"%s: QCAPS message size error, rc:%s\\n\",\n \t\t\t    tf_dir_2_str(dir),\n \t\t\t    strerror(-EINVAL));\n \t\treturn -EINVAL;\n \t}\n \n+\tprintf(\"size: %d\\n\", resp.size);\n+\n \t/* Post process the response */\n \tdata = (struct tf_rm_resc_req_entry *)qcaps_buf.va_addr;\n+\n+\tprintf(\"\\nQCAPS\\n\");\n \tfor (i = 0; i < size; i++) {\n \t\tquery[i].type = tfp_cpu_to_le_32(data[i].type);\n \t\tquery[i].min = tfp_le_to_cpu_16(data[i].min);\n \t\tquery[i].max = tfp_le_to_cpu_16(data[i].max);\n+\n+\t\tprintf(\"type: %d(0x%x) %d %d\\n\",\n+\t\t       query[i].type,\n+\t\t       query[i].type,\n+\t\t       query[i].min,\n+\t\t       query[i].max);\n+\n \t}\n \n \t*resv_strategy = resp.flags &\n@@ -1021,6 +1027,8 @@ tf_msg_session_resc_alloc(struct tf *tfp,\n \tstruct tf_rm_resc_entry *resv_data;\n \tint dma_size;\n \n+\tTF_CHECK_PARMS3(tfp, request, resv);\n+\n \trc = tf_session_get_fw_session_id(tfp, &fw_session_id);\n \tif (rc) {\n \t\tTFP_DRV_LOG(ERR,\n@@ -1053,8 +1061,8 @@ tf_msg_session_resc_alloc(struct tf *tfp,\n \t\treq_data[i].max = tfp_cpu_to_le_16(request[i].max);\n \t}\n \n-\treq.req_addr = req_buf.pa_addr;\n-\treq.resp_addr = resv_buf.pa_addr;\n+\treq.req_addr = tfp_cpu_to_le_64(req_buf.pa_addr);\n+\treq.resc_addr = tfp_cpu_to_le_64(resv_buf.pa_addr);\n \n \tparms.tf_type = HWRM_TF_SESSION_RESC_ALLOC;\n \tparms.req_data = (uint32_t *)&req;\n@@ -1072,18 +1080,28 @@ tf_msg_session_resc_alloc(struct tf *tfp,\n \t */\n \tif (resp.size != size) {\n \t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s: Alloc message error, rc:%s\\n\",\n+\t\t\t    \"%s: Alloc message size error, rc:%s\\n\",\n \t\t\t    tf_dir_2_str(dir),\n \t\t\t    strerror(-EINVAL));\n \t\treturn -EINVAL;\n \t}\n \n+\tprintf(\"\\nRESV\\n\");\n+\tprintf(\"size: %d\\n\", resp.size);\n+\n \t/* Post process the response */\n \tresv_data = (struct tf_rm_resc_entry *)resv_buf.va_addr;\n \tfor (i = 0; i < size; i++) {\n \t\tresv[i].type = tfp_cpu_to_le_32(resv_data[i].type);\n \t\tresv[i].start = tfp_cpu_to_le_16(resv_data[i].start);\n \t\tresv[i].stride = tfp_cpu_to_le_16(resv_data[i].stride);\n+\n+\t\tprintf(\"%d type: %d(0x%x) %d %d\\n\",\n+\t\t       i,\n+\t\t       resv[i].type,\n+\t\t       resv[i].type,\n+\t\t       resv[i].start,\n+\t\t       resv[i].stride);\n \t}\n \n \ttf_msg_free_dma_buf(&req_buf);\n@@ -1460,7 +1478,8 @@ tf_msg_bulk_get_tbl_entry(struct tf *tfp,\n \treq.start_index = tfp_cpu_to_le_32(params->starting_idx);\n \treq.num_entries = tfp_cpu_to_le_32(params->num_entries);\n \n-\tdata_size = (params->num_entries * params->entry_sz_in_bytes);\n+\tdata_size = params->num_entries * params->entry_sz_in_bytes;\n+\n \treq.host_addr = tfp_cpu_to_le_64(params->physical_mem_addr);\n \n \tMSG_PREP(parms,\ndiff --git a/drivers/net/bnxt/tf_core/tf_msg.h b/drivers/net/bnxt/tf_core/tf_msg.h\nindex a3e0f7bba..fb635f6dc 100644\n--- a/drivers/net/bnxt/tf_core/tf_msg.h\n+++ b/drivers/net/bnxt/tf_core/tf_msg.h\n@@ -12,6 +12,7 @@\n #include \"tf_tbl.h\"\n #include \"tf_rm.h\"\n #include \"tf_rm_new.h\"\n+#include \"tf_tcam.h\"\n \n struct tf;\n \ndiff --git a/drivers/net/bnxt/tf_core/tf_rm_new.c b/drivers/net/bnxt/tf_core/tf_rm_new.c\nindex 7cadb231f..6abf79aa1 100644\n--- a/drivers/net/bnxt/tf_core/tf_rm_new.c\n+++ b/drivers/net/bnxt/tf_core/tf_rm_new.c\n@@ -10,6 +10,7 @@\n #include <cfa_resource_types.h>\n \n #include \"tf_rm_new.h\"\n+#include \"tf_common.h\"\n #include \"tf_util.h\"\n #include \"tf_session.h\"\n #include \"tf_device.h\"\n@@ -65,6 +66,46 @@ struct tf_rm_new_db {\n \tstruct tf_rm_element *db;\n };\n \n+/**\n+ * Adjust an index according to the allocation information.\n+ *\n+ * All resources are controlled in a 0 based pool. Some resources, by\n+ * design, are not 0 based, i.e. Full Action Records (SRAM) thus they\n+ * need to be adjusted before they are handed out.\n+ *\n+ * [in] cfg\n+ *   Pointer to the DB configuration\n+ *\n+ * [in] reservations\n+ *   Pointer to the allocation values associated with the module\n+ *\n+ * [in] count\n+ *   Number of DB configuration elements\n+ *\n+ * [out] valid_count\n+ *   Number of HCAPI entries with a reservation value greater than 0\n+ *\n+ * Returns:\n+ *     0          - Success\n+ *   - EOPNOTSUPP - Operation not supported\n+ */\n+static void\n+tf_rm_count_hcapi_reservations(struct tf_rm_element_cfg *cfg,\n+\t\t\t       uint16_t *reservations,\n+\t\t\t       uint16_t count,\n+\t\t\t       uint16_t *valid_count)\n+{\n+\tint i;\n+\tuint16_t cnt = 0;\n+\n+\tfor (i = 0; i < count; i++) {\n+\t\tif (cfg[i].cfg_type == TF_RM_ELEM_CFG_HCAPI &&\n+\t\t    reservations[i] > 0)\n+\t\t\tcnt++;\n+\t}\n+\n+\t*valid_count = cnt;\n+}\n \n /**\n  * Resource Manager Adjust of base index definitions.\n@@ -132,6 +173,7 @@ tf_rm_create_db(struct tf *tfp,\n {\n \tint rc;\n \tint i;\n+\tint j;\n \tstruct tf_session *tfs;\n \tstruct tf_dev_info *dev;\n \tuint16_t max_types;\n@@ -143,6 +185,9 @@ tf_rm_create_db(struct tf *tfp,\n \tstruct tf_rm_new_db *rm_db;\n \tstruct tf_rm_element *db;\n \tuint32_t pool_size;\n+\tuint16_t hcapi_items;\n+\n+\tTF_CHECK_PARMS2(tfp, parms);\n \n \t/* Retrieve the session information */\n \trc = tf_session_get_session(tfp, &tfs);\n@@ -177,10 +222,19 @@ tf_rm_create_db(struct tf *tfp,\n \tif (rc)\n \t\treturn rc;\n \n-\t/* Process capabilities against db requirements */\n+\t/* Process capabilities against DB requirements. However, as a\n+\t * DB can hold elements that are not HCAPI we can reduce the\n+\t * req msg content by removing those out of the request yet\n+\t * the DB holds them all as to give a fast lookup. We can also\n+\t * remove entries where there are no request for elements.\n+\t */\n+\ttf_rm_count_hcapi_reservations(parms->cfg,\n+\t\t\t\t       parms->alloc_cnt,\n+\t\t\t\t       parms->num_elements,\n+\t\t\t\t       &hcapi_items);\n \n \t/* Alloc request, alignment already set */\n-\tcparms.nitems = parms->num_elements;\n+\tcparms.nitems = (size_t)hcapi_items;\n \tcparms.size = sizeof(struct tf_rm_resc_req_entry);\n \trc = tfp_calloc(&cparms);\n \tif (rc)\n@@ -195,15 +249,24 @@ tf_rm_create_db(struct tf *tfp,\n \tresv = (struct tf_rm_resc_entry *)cparms.mem_va;\n \n \t/* Build the request */\n-\tfor (i = 0; i < parms->num_elements; i++) {\n+\tfor (i = 0, j = 0; i < parms->num_elements; i++) {\n \t\t/* Skip any non HCAPI cfg elements */\n \t\tif (parms->cfg[i].cfg_type == TF_RM_ELEM_CFG_HCAPI) {\n-\t\t\treq[i].type = parms->cfg[i].hcapi_type;\n-\t\t\t/* Check that we can get the full amount allocated */\n-\t\t\tif (parms->alloc_num[i] <=\n+\t\t\t/* Only perform reservation for entries that\n+\t\t\t * has been requested\n+\t\t\t */\n+\t\t\tif (parms->alloc_cnt[i] == 0)\n+\t\t\t\tcontinue;\n+\n+\t\t\t/* Verify that we can get the full amount\n+\t\t\t * allocated per the qcaps availability.\n+\t\t\t */\n+\t\t\tif (parms->alloc_cnt[i] <=\n \t\t\t    query[parms->cfg[i].hcapi_type].max) {\n-\t\t\t\treq[i].min = parms->alloc_num[i];\n-\t\t\t\treq[i].max = parms->alloc_num[i];\n+\t\t\t\treq[j].type = parms->cfg[i].hcapi_type;\n+\t\t\t\treq[j].min = parms->alloc_cnt[i];\n+\t\t\t\treq[j].max = parms->alloc_cnt[i];\n+\t\t\t\tj++;\n \t\t\t} else {\n \t\t\t\tTFP_DRV_LOG(ERR,\n \t\t\t\t\t    \"%s: Resource failure, type:%d\\n\",\n@@ -211,19 +274,16 @@ tf_rm_create_db(struct tf *tfp,\n \t\t\t\t\t    parms->cfg[i].hcapi_type);\n \t\t\t\tTFP_DRV_LOG(ERR,\n \t\t\t\t\t\"req:%d, avail:%d\\n\",\n-\t\t\t\t\tparms->alloc_num[i],\n+\t\t\t\t\tparms->alloc_cnt[i],\n \t\t\t\t\tquery[parms->cfg[i].hcapi_type].max);\n \t\t\t\treturn -EINVAL;\n \t\t\t}\n-\t\t} else {\n-\t\t\t/* Skip the element */\n-\t\t\treq[i].type = CFA_RESOURCE_TYPE_INVALID;\n \t\t}\n \t}\n \n \trc = tf_msg_session_resc_alloc(tfp,\n \t\t\t\t       parms->dir,\n-\t\t\t\t       parms->num_elements,\n+\t\t\t\t       hcapi_items,\n \t\t\t\t       req,\n \t\t\t\t       resv);\n \tif (rc)\n@@ -246,42 +306,74 @@ tf_rm_create_db(struct tf *tfp,\n \trm_db->db = (struct tf_rm_element *)cparms.mem_va;\n \n \tdb = rm_db->db;\n-\tfor (i = 0; i < parms->num_elements; i++) {\n-\t\t/* If allocation failed for a single entry the DB\n-\t\t * creation is considered a failure.\n+\tfor (i = 0, j = 0; i < parms->num_elements; i++) {\n+\t\tdb[i].cfg_type = parms->cfg[i].cfg_type;\n+\t\tdb[i].hcapi_type = parms->cfg[i].hcapi_type;\n+\n+\t\t/* Skip any non HCAPI types as we didn't include them\n+\t\t * in the reservation request.\n+\t\t */\n+\t\tif (parms->cfg[i].cfg_type != TF_RM_ELEM_CFG_HCAPI)\n+\t\t\tcontinue;\n+\n+\t\t/* If the element didn't request an allocation no need\n+\t\t * to create a pool nor verify if we got a reservation.\n \t\t */\n-\t\tif (parms->alloc_num[i] != resv[i].stride) {\n+\t\tif (parms->alloc_cnt[i] == 0)\n+\t\t\tcontinue;\n+\n+\t\t/* If the element had requested an allocation and that\n+\t\t * allocation was a success (full amount) then\n+\t\t * allocate the pool.\n+\t\t */\n+\t\tif (parms->alloc_cnt[i] == resv[j].stride) {\n+\t\t\tdb[i].alloc.entry.start = resv[j].start;\n+\t\t\tdb[i].alloc.entry.stride = resv[j].stride;\n+\n+\t\t\t/* Create pool */\n+\t\t\tpool_size = (BITALLOC_SIZEOF(resv[j].stride) /\n+\t\t\t\t     sizeof(struct bitalloc));\n+\t\t\t/* Alloc request, alignment already set */\n+\t\t\tcparms.nitems = pool_size;\n+\t\t\tcparms.size = sizeof(struct bitalloc);\n+\t\t\trc = tfp_calloc(&cparms);\n+\t\t\tif (rc) {\n+\t\t\t\tTFP_DRV_LOG(ERR,\n+\t\t\t\t\t    \"%s: Pool alloc failed, type:%d\\n\",\n+\t\t\t\t\t    tf_dir_2_str(parms->dir),\n+\t\t\t\t\t    db[i].cfg_type);\n+\t\t\t\tgoto fail;\n+\t\t\t}\n+\t\t\tdb[i].pool = (struct bitalloc *)cparms.mem_va;\n+\n+\t\t\trc = ba_init(db[i].pool, resv[j].stride);\n+\t\t\tif (rc) {\n+\t\t\t\tTFP_DRV_LOG(ERR,\n+\t\t\t\t\t    \"%s: Pool init failed, type:%d\\n\",\n+\t\t\t\t\t    tf_dir_2_str(parms->dir),\n+\t\t\t\t\t    db[i].cfg_type);\n+\t\t\t\tgoto fail;\n+\t\t\t}\n+\t\t\tj++;\n+\t\t} else {\n+\t\t\t/* Bail out as we want what we requested for\n+\t\t\t * all elements, not any less.\n+\t\t\t */\n \t\t\tTFP_DRV_LOG(ERR,\n \t\t\t\t    \"%s: Alloc failed, type:%d\\n\",\n \t\t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t\t    i);\n+\t\t\t\t    db[i].cfg_type);\n \t\t\tTFP_DRV_LOG(ERR,\n \t\t\t\t    \"req:%d, alloc:%d\\n\",\n-\t\t\t\t    parms->alloc_num[i],\n-\t\t\t\t    resv[i].stride);\n+\t\t\t\t    parms->alloc_cnt[i],\n+\t\t\t\t    resv[j].stride);\n \t\t\tgoto fail;\n \t\t}\n-\n-\t\tdb[i].cfg_type = parms->cfg[i].cfg_type;\n-\t\tdb[i].hcapi_type = parms->cfg[i].hcapi_type;\n-\t\tdb[i].alloc.entry.start = resv[i].start;\n-\t\tdb[i].alloc.entry.stride = resv[i].stride;\n-\n-\t\t/* Create pool */\n-\t\tpool_size = (BITALLOC_SIZEOF(resv[i].stride) /\n-\t\t\t     sizeof(struct bitalloc));\n-\t\t/* Alloc request, alignment already set */\n-\t\tcparms.nitems = pool_size;\n-\t\tcparms.size = sizeof(struct bitalloc);\n-\t\trc = tfp_calloc(&cparms);\n-\t\tif (rc)\n-\t\t\treturn rc;\n-\t\tdb[i].pool = (struct bitalloc *)cparms.mem_va;\n \t}\n \n \trm_db->num_entries = i;\n \trm_db->dir = parms->dir;\n-\tparms->rm_db = (void *)rm_db;\n+\t*parms->rm_db = (void *)rm_db;\n \n \ttfp_free((void *)req);\n \ttfp_free((void *)resv);\n@@ -307,13 +399,15 @@ tf_rm_free_db(struct tf *tfp __rte_unused,\n \tint i;\n \tstruct tf_rm_new_db *rm_db;\n \n+\tTF_CHECK_PARMS1(parms);\n+\n \t/* Traverse the DB and clear each pool.\n \t * NOTE:\n \t *   Firmware is not cleared. It will be cleared on close only.\n \t */\n \trm_db = (struct tf_rm_new_db *)parms->rm_db;\n \tfor (i = 0; i < rm_db->num_entries; i++)\n-\t\ttfp_free((void *)rm_db->db->pool);\n+\t\ttfp_free((void *)rm_db->db[i].pool);\n \n \ttfp_free((void *)parms->rm_db);\n \n@@ -325,11 +419,11 @@ tf_rm_allocate(struct tf_rm_allocate_parms *parms)\n {\n \tint rc = 0;\n \tint id;\n+\tuint32_t index;\n \tstruct tf_rm_new_db *rm_db;\n \tenum tf_rm_elem_cfg_type cfg_type;\n \n-\tif (parms == NULL || parms->rm_db == NULL)\n-\t\treturn -EINVAL;\n+\tTF_CHECK_PARMS2(parms, parms->rm_db);\n \n \trm_db = (struct tf_rm_new_db *)parms->rm_db;\n \tcfg_type = rm_db->db[parms->db_index].cfg_type;\n@@ -339,6 +433,17 @@ tf_rm_allocate(struct tf_rm_allocate_parms *parms)\n \t    cfg_type != TF_RM_ELEM_CFG_PRIVATE)\n \t\treturn -ENOTSUP;\n \n+\t/* Bail out if the pool is not valid, should never happen */\n+\tif (rm_db->db[parms->db_index].pool == NULL) {\n+\t\trc = -ENOTSUP;\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"%s: Invalid pool for this type:%d, rc:%s\\n\",\n+\t\t\t    tf_dir_2_str(rm_db->dir),\n+\t\t\t    parms->db_index,\n+\t\t\t    strerror(-rc));\n+\t\treturn rc;\n+\t}\n+\n \tid = ba_alloc(rm_db->db[parms->db_index].pool);\n \tif (id == BA_FAIL) {\n \t\tTFP_DRV_LOG(ERR,\n@@ -353,15 +458,17 @@ tf_rm_allocate(struct tf_rm_allocate_parms *parms)\n \t\t\t\tTF_RM_ADJUST_ADD_BASE,\n \t\t\t\tparms->db_index,\n \t\t\t\tid,\n-\t\t\t\tparms->index);\n+\t\t\t\t&index);\n \tif (rc) {\n \t\tTFP_DRV_LOG(ERR,\n \t\t\t    \"%s: Alloc adjust of base index failed, rc:%s\\n\",\n \t\t\t    tf_dir_2_str(rm_db->dir),\n \t\t\t    strerror(-rc));\n-\t\treturn -1;\n+\t\treturn -EINVAL;\n \t}\n \n+\t*parms->index = index;\n+\n \treturn rc;\n }\n \n@@ -373,8 +480,7 @@ tf_rm_free(struct tf_rm_free_parms *parms)\n \tstruct tf_rm_new_db *rm_db;\n \tenum tf_rm_elem_cfg_type cfg_type;\n \n-\tif (parms == NULL || parms->rm_db == NULL)\n-\t\treturn -EINVAL;\n+\tTF_CHECK_PARMS2(parms, parms->rm_db);\n \n \trm_db = (struct tf_rm_new_db *)parms->rm_db;\n \tcfg_type = rm_db->db[parms->db_index].cfg_type;\n@@ -384,6 +490,17 @@ tf_rm_free(struct tf_rm_free_parms *parms)\n \t    cfg_type != TF_RM_ELEM_CFG_PRIVATE)\n \t\treturn -ENOTSUP;\n \n+\t/* Bail out if the pool is not valid, should never happen */\n+\tif (rm_db->db[parms->db_index].pool == NULL) {\n+\t\trc = -ENOTSUP;\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"%s: Invalid pool for this type:%d, rc:%s\\n\",\n+\t\t\t    tf_dir_2_str(rm_db->dir),\n+\t\t\t    parms->db_index,\n+\t\t\t    strerror(-rc));\n+\t\treturn rc;\n+\t}\n+\n \t/* Adjust for any non zero start value */\n \trc = tf_rm_adjust_index(rm_db->db,\n \t\t\t\tTF_RM_ADJUST_RM_BASE,\n@@ -409,8 +526,7 @@ tf_rm_is_allocated(struct tf_rm_is_allocated_parms *parms)\n \tstruct tf_rm_new_db *rm_db;\n \tenum tf_rm_elem_cfg_type cfg_type;\n \n-\tif (parms == NULL || parms->rm_db == NULL)\n-\t\treturn -EINVAL;\n+\tTF_CHECK_PARMS2(parms, parms->rm_db);\n \n \trm_db = (struct tf_rm_new_db *)parms->rm_db;\n \tcfg_type = rm_db->db[parms->db_index].cfg_type;\n@@ -420,6 +536,17 @@ tf_rm_is_allocated(struct tf_rm_is_allocated_parms *parms)\n \t    cfg_type != TF_RM_ELEM_CFG_PRIVATE)\n \t\treturn -ENOTSUP;\n \n+\t/* Bail out if the pool is not valid, should never happen */\n+\tif (rm_db->db[parms->db_index].pool == NULL) {\n+\t\trc = -ENOTSUP;\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"%s: Invalid pool for this type:%d, rc:%s\\n\",\n+\t\t\t    tf_dir_2_str(rm_db->dir),\n+\t\t\t    parms->db_index,\n+\t\t\t    strerror(-rc));\n+\t\treturn rc;\n+\t}\n+\n \t/* Adjust for any non zero start value */\n \trc = tf_rm_adjust_index(rm_db->db,\n \t\t\t\tTF_RM_ADJUST_RM_BASE,\n@@ -442,8 +569,7 @@ tf_rm_get_info(struct tf_rm_get_alloc_info_parms *parms)\n \tstruct tf_rm_new_db *rm_db;\n \tenum tf_rm_elem_cfg_type cfg_type;\n \n-\tif (parms == NULL || parms->rm_db == NULL)\n-\t\treturn -EINVAL;\n+\tTF_CHECK_PARMS2(parms, parms->rm_db);\n \n \trm_db = (struct tf_rm_new_db *)parms->rm_db;\n \tcfg_type = rm_db->db[parms->db_index].cfg_type;\n@@ -465,8 +591,7 @@ tf_rm_get_hcapi_type(struct tf_rm_get_hcapi_parms *parms)\n \tstruct tf_rm_new_db *rm_db;\n \tenum tf_rm_elem_cfg_type cfg_type;\n \n-\tif (parms == NULL || parms->rm_db == NULL)\n-\t\treturn -EINVAL;\n+\tTF_CHECK_PARMS2(parms, parms->rm_db);\n \n \trm_db = (struct tf_rm_new_db *)parms->rm_db;\n \tcfg_type = rm_db->db[parms->db_index].cfg_type;\ndiff --git a/drivers/net/bnxt/tf_core/tf_rm_new.h b/drivers/net/bnxt/tf_core/tf_rm_new.h\nindex 6d8234ddc..ebf38c411 100644\n--- a/drivers/net/bnxt/tf_core/tf_rm_new.h\n+++ b/drivers/net/bnxt/tf_core/tf_rm_new.h\n@@ -135,13 +135,16 @@ struct tf_rm_create_db_parms {\n \t */\n \tstruct tf_rm_element_cfg *cfg;\n \t/**\n-\t * Allocation number array. Array size is num_elements.\n+\t * Resource allocation count array. This array content\n+\t * originates from the tf_session_resources that is passed in\n+\t * on session open.\n+\t * Array size is num_elements.\n \t */\n-\tuint16_t *alloc_num;\n+\tuint16_t *alloc_cnt;\n \t/**\n \t * [out] RM DB Handle\n \t */\n-\tvoid *rm_db;\n+\tvoid **rm_db;\n };\n \n /**\n@@ -382,7 +385,7 @@ int tf_rm_get_info(struct tf_rm_get_alloc_info_parms *parms);\n \n /**\n  * Performs a lookup in the Resource Manager DB and retrives the\n- * requested HCAPI type.\n+ * requested HCAPI RM type.\n  *\n  * [in] parms\n  *   Pointer to get hcapi parameters\ndiff --git a/drivers/net/bnxt/tf_core/tf_session.c b/drivers/net/bnxt/tf_core/tf_session.c\nindex 1917f8100..3a602618c 100644\n--- a/drivers/net/bnxt/tf_core/tf_session.c\n+++ b/drivers/net/bnxt/tf_core/tf_session.c\n@@ -95,21 +95,11 @@ tf_session_open_session(struct tf *tfp,\n \t\t      parms->open_cfg->device_type,\n \t\t      session->shadow_copy,\n \t\t      &parms->open_cfg->resources,\n-\t\t      session->dev);\n+\t\t      &session->dev);\n \t/* Logging handled by dev_bind */\n \tif (rc)\n \t\treturn rc;\n \n-\t/* Query for Session Config\n-\t */\n-\trc = tf_msg_session_qcfg(tfp);\n-\tif (rc) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"Query config message send failed, rc:%s\\n\",\n-\t\t\t    strerror(-rc));\n-\t\tgoto cleanup_close;\n-\t}\n-\n \tsession->ref_count++;\n \n \treturn 0;\n@@ -119,10 +109,6 @@ tf_session_open_session(struct tf *tfp,\n \ttfp_free(tfp->session);\n \ttfp->session = NULL;\n \treturn rc;\n-\n- cleanup_close:\n-\ttf_close_session(tfp);\n-\treturn -EINVAL;\n }\n \n int\n@@ -231,17 +217,7 @@ int\n tf_session_get_device(struct tf_session *tfs,\n \t\t      struct tf_dev_info **tfd)\n {\n-\tint rc;\n-\n-\tif (tfs->dev == NULL) {\n-\t\trc = -EINVAL;\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"Device not created, rc:%s\\n\",\n-\t\t\t    strerror(-rc));\n-\t\treturn rc;\n-\t}\n-\n-\t*tfd = tfs->dev;\n+\t*tfd = &tfs->dev;\n \n \treturn 0;\n }\ndiff --git a/drivers/net/bnxt/tf_core/tf_session.h b/drivers/net/bnxt/tf_core/tf_session.h\nindex 92792518b..705bb0955 100644\n--- a/drivers/net/bnxt/tf_core/tf_session.h\n+++ b/drivers/net/bnxt/tf_core/tf_session.h\n@@ -97,7 +97,7 @@ struct tf_session {\n \tuint8_t ref_count;\n \n \t/** Device handle */\n-\tstruct tf_dev_info *dev;\n+\tstruct tf_dev_info dev;\n \n \t/** Session HW and SRAM resources */\n \tstruct tf_rm_db resc;\ndiff --git a/drivers/net/bnxt/tf_core/tf_tbl.c b/drivers/net/bnxt/tf_core/tf_tbl.c\nindex a68335304..e594f0248 100644\n--- a/drivers/net/bnxt/tf_core/tf_tbl.c\n+++ b/drivers/net/bnxt/tf_core/tf_tbl.c\n@@ -761,163 +761,6 @@ tf_em_validate_num_entries(struct tf_tbl_scope_cb *tbl_scope_cb,\n \treturn 0;\n }\n \n-/**\n- * Internal function to set a Table Entry. Supports all internal Table Types\n- *\n- * [in] tfp\n- *   Pointer to TruFlow handle\n- *\n- * [in] parms\n- *   Pointer to input parameters\n- *\n- * Returns:\n- *   0       - Success\n- *   -EINVAL - Parameter error\n- */\n-static int\n-tf_set_tbl_entry_internal(struct tf *tfp,\n-\t\t\t  struct tf_set_tbl_entry_parms *parms)\n-{\n-\tint rc;\n-\tint id;\n-\tuint32_t index;\n-\tstruct bitalloc *session_pool;\n-\tstruct tf_session *tfs = (struct tf_session *)(tfp->session->core_data);\n-\n-\t/* Lookup the pool using the table type of the element */\n-\trc = tf_rm_lookup_tbl_type_pool(tfs,\n-\t\t\t\t\tparms->dir,\n-\t\t\t\t\tparms->type,\n-\t\t\t\t\t&session_pool);\n-\t/* Error logging handled by tf_rm_lookup_tbl_type_pool */\n-\tif (rc)\n-\t\treturn rc;\n-\n-\tindex = parms->idx;\n-\n-\tif (parms->type != TF_TBL_TYPE_FULL_ACT_RECORD &&\n-\t    parms->type != TF_TBL_TYPE_ACT_SP_SMAC_IPV4 &&\n-\t    parms->type != TF_TBL_TYPE_ACT_STATS_64) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s, Type not supported, type:%d\\n\",\n-\t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t    parms->type);\n-\t\treturn -EOPNOTSUPP;\n-\t}\n-\n-\t/* Adjust the returned index/offset as there is no guarantee\n-\t * that the start is 0 at time of RM allocation\n-\t */\n-\ttf_rm_convert_index(tfs,\n-\t\t\t    parms->dir,\n-\t\t\t    parms->type,\n-\t\t\t    TF_RM_CONVERT_RM_BASE,\n-\t\t\t    parms->idx,\n-\t\t\t    &index);\n-\n-\t/* Verify that the entry has been previously allocated */\n-\tid = ba_inuse(session_pool, index);\n-\tif (id != 1) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t   \"%s, Invalid or not allocated index, type:%d, idx:%d\\n\",\n-\t\t   tf_dir_2_str(parms->dir),\n-\t\t   parms->type,\n-\t\t   index);\n-\t\treturn -EINVAL;\n-\t}\n-\n-\t/* Set the entry */\n-\trc = tf_msg_set_tbl_entry(tfp,\n-\t\t\t\t  parms->dir,\n-\t\t\t\t  parms->type,\n-\t\t\t\t  parms->data_sz_in_bytes,\n-\t\t\t\t  parms->data,\n-\t\t\t\t  parms->idx);\n-\tif (rc) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s, Set failed, type:%d, rc:%s\\n\",\n-\t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t    parms->type,\n-\t\t\t    strerror(-rc));\n-\t}\n-\n-\treturn rc;\n-}\n-\n-/**\n- * Internal function to get a Table Entry. Supports all Table Types\n- * except the TF_TBL_TYPE_EXT as that is handled as a table scope.\n- *\n- * [in] tfp\n- *   Pointer to TruFlow handle\n- *\n- * [in] parms\n- *   Pointer to input parameters\n- *\n- * Returns:\n- *   0       - Success\n- *   -EINVAL - Parameter error\n- */\n-static int\n-tf_get_tbl_entry_internal(struct tf *tfp,\n-\t\t\t  struct tf_get_tbl_entry_parms *parms)\n-{\n-\tint rc;\n-\tint id;\n-\tuint32_t index;\n-\tstruct bitalloc *session_pool;\n-\tstruct tf_session *tfs = (struct tf_session *)(tfp->session->core_data);\n-\n-\t/* Lookup the pool using the table type of the element */\n-\trc = tf_rm_lookup_tbl_type_pool(tfs,\n-\t\t\t\t\tparms->dir,\n-\t\t\t\t\tparms->type,\n-\t\t\t\t\t&session_pool);\n-\t/* Error logging handled by tf_rm_lookup_tbl_type_pool */\n-\tif (rc)\n-\t\treturn rc;\n-\n-\tindex = parms->idx;\n-\n-\t/* Adjust the returned index/offset as there is no guarantee\n-\t * that the start is 0 at time of RM allocation\n-\t */\n-\ttf_rm_convert_index(tfs,\n-\t\t\t    parms->dir,\n-\t\t\t    parms->type,\n-\t\t\t    TF_RM_CONVERT_RM_BASE,\n-\t\t\t    parms->idx,\n-\t\t\t    &index);\n-\n-\t/* Verify that the entry has been previously allocated */\n-\tid = ba_inuse(session_pool, index);\n-\tif (id != 1) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t   \"%s, Invalid or not allocated index, type:%d, idx:%d\\n\",\n-\t\t   tf_dir_2_str(parms->dir),\n-\t\t   parms->type,\n-\t\t   index);\n-\t\treturn -EINVAL;\n-\t}\n-\n-\t/* Get the entry */\n-\trc = tf_msg_get_tbl_entry(tfp,\n-\t\t\t\t  parms->dir,\n-\t\t\t\t  parms->type,\n-\t\t\t\t  parms->data_sz_in_bytes,\n-\t\t\t\t  parms->data,\n-\t\t\t\t  parms->idx);\n-\tif (rc) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s, Get failed, type:%d, rc:%s\\n\",\n-\t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t    parms->type,\n-\t\t\t    strerror(-rc));\n-\t}\n-\n-\treturn rc;\n-}\n-\n /**\n  * Internal function to get a Table Entry. Supports all Table Types\n  * except the TF_TBL_TYPE_EXT as that is handled as a table scope.\n@@ -1145,266 +988,6 @@ tf_destroy_tbl_pool_external(enum tf_dir dir,\n \ttfp_free(ext_act_pool_mem);\n }\n \n-/**\n- * Allocate External Tbl entry from the Session Pool.\n- *\n- * [in] tfp\n- *   Pointer to Truflow Handle\n- * [in] parms\n- *   Allocation parameters\n- *\n- * Return:\n- *  0       - Success, entry allocated - no search support\n- *  -ENOMEM -EINVAL -EOPNOTSUPP\n- *          - Failure, entry not allocated, out of resources\n- */\n-static int\n-tf_alloc_tbl_entry_pool_external(struct tf *tfp,\n-\t\t\t\t struct tf_alloc_tbl_entry_parms *parms)\n-{\n-\tint rc;\n-\tuint32_t index;\n-\tstruct tf_session *tfs;\n-\tstruct tf_tbl_scope_cb *tbl_scope_cb;\n-\tstruct stack *pool;\n-\n-\tTF_CHECK_PARMS_SESSION(tfp, parms);\n-\n-\ttfs = (struct tf_session *)(tfp->session->core_data);\n-\n-\t/* Get the pool info from the table scope\n-\t */\n-\ttbl_scope_cb = tbl_scope_cb_find(tfs, parms->tbl_scope_id);\n-\n-\tif (tbl_scope_cb == NULL) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s, table scope not allocated\\n\",\n-\t\t\t    tf_dir_2_str(parms->dir));\n-\t\treturn -EINVAL;\n-\t}\n-\tpool = &tbl_scope_cb->ext_act_pool[parms->dir];\n-\n-\t/* Allocate an element\n-\t */\n-\trc = stack_pop(pool, &index);\n-\n-\tif (rc != 0) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t   \"%s, Allocation failed, type:%d\\n\",\n-\t\t   tf_dir_2_str(parms->dir),\n-\t\t   parms->type);\n-\t\treturn rc;\n-\t}\n-\tparms->idx = index;\n-\treturn rc;\n-}\n-\n-/**\n- * Allocate Internal Tbl entry from the Session Pool.\n- *\n- * [in] tfp\n- *   Pointer to Truflow Handle\n- * [in] parms\n- *   Allocation parameters\n- *\n- * Return:\n- *  0       - Success, entry found and ref count decremented\n- *  -ENOMEM - Failure, entry not allocated, out of resources\n- */\n-static int\n-tf_alloc_tbl_entry_pool_internal(struct tf *tfp,\n-\t\t\t\t struct tf_alloc_tbl_entry_parms *parms)\n-{\n-\tint rc;\n-\tint id;\n-\tint free_cnt;\n-\tuint32_t index;\n-\tstruct bitalloc *session_pool;\n-\tstruct tf_session *tfs;\n-\n-\tTF_CHECK_PARMS_SESSION(tfp, parms);\n-\n-\ttfs = (struct tf_session *)(tfp->session->core_data);\n-\n-\tif (parms->type != TF_TBL_TYPE_FULL_ACT_RECORD &&\n-\t    parms->type != TF_TBL_TYPE_ACT_SP_SMAC &&\n-\t    parms->type != TF_TBL_TYPE_ACT_SP_SMAC_IPV4 &&\n-\t    parms->type != TF_TBL_TYPE_ACT_ENCAP_8B &&\n-\t    parms->type != TF_TBL_TYPE_ACT_ENCAP_16B &&\n-\t    parms->type != TF_TBL_TYPE_ACT_ENCAP_64B &&\n-\t    parms->type != TF_TBL_TYPE_ACT_STATS_64) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s, Type not supported, type:%d\\n\",\n-\t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t    parms->type);\n-\t\treturn -EOPNOTSUPP;\n-\t}\n-\n-\t/* Lookup the pool using the table type of the element */\n-\trc = tf_rm_lookup_tbl_type_pool(tfs,\n-\t\t\t\t\tparms->dir,\n-\t\t\t\t\tparms->type,\n-\t\t\t\t\t&session_pool);\n-\t/* Error logging handled by tf_rm_lookup_tbl_type_pool */\n-\tif (rc)\n-\t\treturn rc;\n-\n-\tid = ba_alloc(session_pool);\n-\tif (id == -1) {\n-\t\tfree_cnt = ba_free_count(session_pool);\n-\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t   \"%s, Allocation failed, type:%d, free:%d\\n\",\n-\t\t   tf_dir_2_str(parms->dir),\n-\t\t   parms->type,\n-\t\t   free_cnt);\n-\t\treturn -ENOMEM;\n-\t}\n-\n-\t/* Adjust the returned index/offset as there is no guarantee\n-\t * that the start is 0 at time of RM allocation\n-\t */\n-\ttf_rm_convert_index(tfs,\n-\t\t\t    parms->dir,\n-\t\t\t    parms->type,\n-\t\t\t    TF_RM_CONVERT_ADD_BASE,\n-\t\t\t    id,\n-\t\t\t    &index);\n-\tparms->idx = index;\n-\treturn rc;\n-}\n-\n-/**\n- * Free External Tbl entry to the session pool.\n- *\n- * [in] tfp\n- *   Pointer to Truflow Handle\n- * [in] parms\n- *   Allocation parameters\n- *\n- * Return:\n- *  0       - Success, entry freed\n- *\n- * - Failure, entry not successfully freed for these reasons\n- *  -ENOMEM\n- *  -EOPNOTSUPP\n- *  -EINVAL\n- */\n-static int\n-tf_free_tbl_entry_pool_external(struct tf *tfp,\n-\t\t\t\tstruct tf_free_tbl_entry_parms *parms)\n-{\n-\tint rc = 0;\n-\tstruct tf_session *tfs;\n-\tuint32_t index;\n-\tstruct tf_tbl_scope_cb *tbl_scope_cb;\n-\tstruct stack *pool;\n-\n-\tTF_CHECK_PARMS_SESSION(tfp, parms);\n-\n-\ttfs = (struct tf_session *)(tfp->session->core_data);\n-\n-\t/* Get the pool info from the table scope\n-\t */\n-\ttbl_scope_cb = tbl_scope_cb_find(tfs, parms->tbl_scope_id);\n-\n-\tif (tbl_scope_cb == NULL) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s, table scope error\\n\",\n-\t\t\t    tf_dir_2_str(parms->dir));\n-\t\treturn -EINVAL;\n-\t}\n-\tpool = &tbl_scope_cb->ext_act_pool[parms->dir];\n-\n-\tindex = parms->idx;\n-\n-\trc = stack_push(pool, index);\n-\n-\tif (rc != 0) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t   \"%s, consistency error, stack full, type:%d, idx:%d\\n\",\n-\t\t   tf_dir_2_str(parms->dir),\n-\t\t   parms->type,\n-\t\t   index);\n-\t}\n-\treturn rc;\n-}\n-\n-/**\n- * Free Internal Tbl entry from the Session Pool.\n- *\n- * [in] tfp\n- *   Pointer to Truflow Handle\n- * [in] parms\n- *   Allocation parameters\n- *\n- * Return:\n- *  0       - Success, entry found and ref count decremented\n- *  -ENOMEM - Failure, entry not allocated, out of resources\n- */\n-static int\n-tf_free_tbl_entry_pool_internal(struct tf *tfp,\n-\t\t       struct tf_free_tbl_entry_parms *parms)\n-{\n-\tint rc = 0;\n-\tint id;\n-\tstruct bitalloc *session_pool;\n-\tstruct tf_session *tfs;\n-\tuint32_t index;\n-\n-\tTF_CHECK_PARMS_SESSION(tfp, parms);\n-\n-\ttfs = (struct tf_session *)(tfp->session->core_data);\n-\n-\tif (parms->type != TF_TBL_TYPE_FULL_ACT_RECORD &&\n-\t    parms->type != TF_TBL_TYPE_ACT_SP_SMAC &&\n-\t    parms->type != TF_TBL_TYPE_ACT_SP_SMAC_IPV4 &&\n-\t    parms->type != TF_TBL_TYPE_ACT_ENCAP_8B &&\n-\t    parms->type != TF_TBL_TYPE_ACT_ENCAP_16B &&\n-\t    parms->type != TF_TBL_TYPE_ACT_ENCAP_64B &&\n-\t    parms->type != TF_TBL_TYPE_ACT_STATS_64) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s, Type not supported, type:%d\\n\",\n-\t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t    parms->type);\n-\t\treturn -EOPNOTSUPP;\n-\t}\n-\n-\t/* Lookup the pool using the table type of the element */\n-\trc = tf_rm_lookup_tbl_type_pool(tfs,\n-\t\t\t\t\tparms->dir,\n-\t\t\t\t\tparms->type,\n-\t\t\t\t\t&session_pool);\n-\t/* Error logging handled by tf_rm_lookup_tbl_type_pool */\n-\tif (rc)\n-\t\treturn rc;\n-\n-\tindex = parms->idx;\n-\n-\t/* Adjust the returned index/offset as there is no guarantee\n-\t * that the start is 0 at time of RM allocation\n-\t */\n-\ttf_rm_convert_index(tfs,\n-\t\t\t    parms->dir,\n-\t\t\t    parms->type,\n-\t\t\t    TF_RM_CONVERT_RM_BASE,\n-\t\t\t    parms->idx,\n-\t\t\t    &index);\n-\n-\t/* Check if element was indeed allocated */\n-\tid = ba_inuse_free(session_pool, index);\n-\tif (id == -1) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t   \"%s, Element not previously alloc'ed, type:%d, idx:%d\\n\",\n-\t\t   tf_dir_2_str(parms->dir),\n-\t\t   parms->type,\n-\t\t   index);\n-\t\treturn -ENOMEM;\n-\t}\n-\n-\treturn rc;\n-}\n-\n /* API defined in tf_em.h */\n struct tf_tbl_scope_cb *\n tbl_scope_cb_find(struct tf_session *session,\n@@ -1584,113 +1167,7 @@ tf_alloc_eem_tbl_scope(struct tf *tfp,\n \treturn -EINVAL;\n }\n \n-/* API defined in tf_core.h */\n-int\n-tf_set_tbl_entry(struct tf *tfp,\n-\t\t struct tf_set_tbl_entry_parms *parms)\n-{\n-\tint rc = 0;\n-\tstruct tf_tbl_scope_cb *tbl_scope_cb;\n-\tstruct tf_session *session;\n-\n-\tTF_CHECK_PARMS_SESSION(tfp, parms);\n-\n-\tif (parms->data == NULL) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s, invalid parms->data\\n\",\n-\t\t\t    tf_dir_2_str(parms->dir));\n-\t\treturn -EINVAL;\n-\t}\n-\n-\tif (parms->type == TF_TBL_TYPE_EXT) {\n-\t\tvoid *base_addr;\n-\t\tuint32_t offset = parms->idx;\n-\t\tuint32_t tbl_scope_id;\n-\n-\t\tsession = (struct tf_session *)(tfp->session->core_data);\n-\n-\t\ttbl_scope_id = parms->tbl_scope_id;\n-\n-\t\tif (tbl_scope_id == TF_TBL_SCOPE_INVALID)  {\n-\t\t\tTFP_DRV_LOG(ERR,\n-\t\t\t\t    \"%s, Table scope not allocated\\n\",\n-\t\t\t\t    tf_dir_2_str(parms->dir));\n-\t\t\treturn -EINVAL;\n-\t\t}\n-\n-\t\t/* Get the table scope control block associated with the\n-\t\t * external pool\n-\t\t */\n-\t\ttbl_scope_cb = tbl_scope_cb_find(session, tbl_scope_id);\n-\n-\t\tif (tbl_scope_cb == NULL) {\n-\t\t\tTFP_DRV_LOG(ERR,\n-\t\t\t\t    \"%s, table scope error\\n\",\n-\t\t\t\t    tf_dir_2_str(parms->dir));\n-\t\t\t\treturn -EINVAL;\n-\t\t}\n-\n-\t\t/* External table, implicitly the Action table */\n-\t\tbase_addr = (void *)(uintptr_t)\n-\t\thcapi_get_table_page(&tbl_scope_cb->em_ctx_info[parms->dir].em_tables[TF_RECORD_TABLE], offset);\n-\n-\t\tif (base_addr == NULL) {\n-\t\t\tTFP_DRV_LOG(ERR,\n-\t\t\t\t    \"%s, Base address lookup failed\\n\",\n-\t\t\t\t    tf_dir_2_str(parms->dir));\n-\t\t\treturn -EINVAL;\n-\t\t}\n-\n-\t\toffset %= TF_EM_PAGE_SIZE;\n-\t\trte_memcpy((char *)base_addr + offset,\n-\t\t\t   parms->data,\n-\t\t\t   parms->data_sz_in_bytes);\n-\t} else {\n-\t\t/* Internal table type processing */\n-\t\trc = tf_set_tbl_entry_internal(tfp, parms);\n-\t\tif (rc) {\n-\t\t\tTFP_DRV_LOG(ERR,\n-\t\t\t\t    \"%s, Set failed, type:%d, rc:%s\\n\",\n-\t\t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t\t    parms->type,\n-\t\t\t\t    strerror(-rc));\n-\t\t}\n-\t}\n-\n-\treturn rc;\n-}\n-\n-/* API defined in tf_core.h */\n-int\n-tf_get_tbl_entry(struct tf *tfp,\n-\t\t struct tf_get_tbl_entry_parms *parms)\n-{\n-\tint rc = 0;\n-\n-\tTF_CHECK_PARMS_SESSION(tfp, parms);\n-\n-\tif (parms->type == TF_TBL_TYPE_EXT) {\n-\t\t/* Not supported, yet */\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s, External table type not supported\\n\",\n-\t\t\t    tf_dir_2_str(parms->dir));\n-\n-\t\trc = -EOPNOTSUPP;\n-\t} else {\n-\t\t/* Internal table type processing */\n-\t\trc = tf_get_tbl_entry_internal(tfp, parms);\n-\t\tif (rc)\n-\t\t\tTFP_DRV_LOG(ERR,\n-\t\t\t\t    \"%s, Get failed, type:%d, rc:%s\\n\",\n-\t\t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t\t    parms->type,\n-\t\t\t\t    strerror(-rc));\n-\t}\n-\n-\treturn rc;\n-}\n-\n-/* API defined in tf_core.h */\n+ /* API defined in tf_core.h */\n int\n tf_bulk_get_tbl_entry(struct tf *tfp,\n \t\t struct tf_bulk_get_tbl_entry_parms *parms)\n@@ -1749,92 +1226,6 @@ tf_free_tbl_scope(struct tf *tfp,\n \treturn rc;\n }\n \n-/* API defined in tf_core.h */\n-int\n-tf_alloc_tbl_entry(struct tf *tfp,\n-\t\t   struct tf_alloc_tbl_entry_parms *parms)\n-{\n-\tint rc;\n-#if (TF_SHADOW == 1)\n-\tstruct tf_session *tfs;\n-#endif /* TF_SHADOW */\n-\n-\tTF_CHECK_PARMS_SESSION(tfp, parms);\n-\t/*\n-\t * No shadow copy support for external tables, allocate and return\n-\t */\n-\tif (parms->type == TF_TBL_TYPE_EXT) {\n-\t\trc = tf_alloc_tbl_entry_pool_external(tfp, parms);\n-\t\treturn rc;\n-\t}\n-\n-#if (TF_SHADOW == 1)\n-\ttfs = (struct tf_session *)(tfp->session->core_data);\n-\n-\t/* Search the Shadow DB for requested element. If not found go\n-\t * allocate one from the Session Pool\n-\t */\n-\tif (parms->search_enable && tfs->shadow_copy) {\n-\t\trc = tf_alloc_tbl_entry_shadow(tfs, parms);\n-\t\t/* Entry found and parms populated with return data */\n-\t\tif (rc == 0)\n-\t\t\treturn rc;\n-\t}\n-#endif /* TF_SHADOW */\n-\n-\trc = tf_alloc_tbl_entry_pool_internal(tfp, parms);\n-\tif (rc)\n-\t\tTFP_DRV_LOG(ERR, \"%s, Alloc failed, rc:%s\\n\",\n-\t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t    strerror(-rc));\n-\n-\treturn rc;\n-}\n-\n-/* API defined in tf_core.h */\n-int\n-tf_free_tbl_entry(struct tf *tfp,\n-\t\t  struct tf_free_tbl_entry_parms *parms)\n-{\n-\tint rc;\n-#if (TF_SHADOW == 1)\n-\tstruct tf_session *tfs;\n-#endif /* TF_SHADOW */\n-\n-\tTF_CHECK_PARMS_SESSION(tfp, parms);\n-\n-\t/*\n-\t * No shadow of external tables so just free the entry\n-\t */\n-\tif (parms->type == TF_TBL_TYPE_EXT) {\n-\t\trc = tf_free_tbl_entry_pool_external(tfp, parms);\n-\t\treturn rc;\n-\t}\n-\n-#if (TF_SHADOW == 1)\n-\ttfs = (struct tf_session *)(tfp->session->core_data);\n-\n-\t/* Search the Shadow DB for requested element. If not found go\n-\t * allocate one from the Session Pool\n-\t */\n-\tif (parms->search_enable && tfs->shadow_copy) {\n-\t\trc = tf_free_tbl_entry_shadow(tfs, parms);\n-\t\t/* Entry free'ed and parms populated with return data */\n-\t\tif (rc == 0)\n-\t\t\treturn rc;\n-\t}\n-#endif /* TF_SHADOW */\n-\n-\trc = tf_free_tbl_entry_pool_internal(tfp, parms);\n-\n-\tif (rc)\n-\t\tTFP_DRV_LOG(ERR, \"%s, Alloc failed, rc:%s\\n\",\n-\t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t    strerror(-rc));\n-\treturn rc;\n-}\n-\n-\n static void\n tf_dump_link_page_table(struct hcapi_cfa_em_page_tbl *tp,\n \t\t\tstruct hcapi_cfa_em_page_tbl *tp_next)\ndiff --git a/drivers/net/bnxt/tf_core/tf_tbl_type.c b/drivers/net/bnxt/tf_core/tf_tbl_type.c\nindex b79706f97..51f8f0740 100644\n--- a/drivers/net/bnxt/tf_core/tf_tbl_type.c\n+++ b/drivers/net/bnxt/tf_core/tf_tbl_type.c\n@@ -6,13 +6,18 @@\n #include <rte_common.h>\n \n #include \"tf_tbl_type.h\"\n+#include \"tf_common.h\"\n+#include \"tf_rm_new.h\"\n+#include \"tf_util.h\"\n+#include \"tf_msg.h\"\n+#include \"tfp.h\"\n \n struct tf;\n \n /**\n  * Table DBs.\n  */\n-/* static void *tbl_db[TF_DIR_MAX]; */\n+static void *tbl_db[TF_DIR_MAX];\n \n /**\n  * Table Shadow DBs\n@@ -22,7 +27,7 @@ struct tf;\n /**\n  * Init flag, set on bind and cleared on unbind\n  */\n-/* static uint8_t init; */\n+static uint8_t init;\n \n /**\n  * Shadow init flag, set on bind and cleared on unbind\n@@ -30,29 +35,164 @@ struct tf;\n /* static uint8_t shadow_init; */\n \n int\n-tf_tbl_bind(struct tf *tfp __rte_unused,\n-\t    struct tf_tbl_cfg_parms *parms __rte_unused)\n+tf_tbl_bind(struct tf *tfp,\n+\t    struct tf_tbl_cfg_parms *parms)\n {\n+\tint rc;\n+\tint i;\n+\tstruct tf_rm_create_db_parms db_cfg = { 0 };\n+\n+\tTF_CHECK_PARMS2(tfp, parms);\n+\n+\tif (init) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"Table already initialized\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tdb_cfg.num_elements = parms->num_elements;\n+\n+\tfor (i = 0; i < TF_DIR_MAX; i++) {\n+\t\tdb_cfg.dir = i;\n+\t\tdb_cfg.num_elements = parms->num_elements;\n+\t\tdb_cfg.cfg = parms->cfg;\n+\t\tdb_cfg.alloc_cnt = parms->resources->tbl_cnt[i].cnt;\n+\t\tdb_cfg.rm_db = &tbl_db[i];\n+\t\trc = tf_rm_create_db(tfp, &db_cfg);\n+\t\tif (rc) {\n+\t\t\tTFP_DRV_LOG(ERR,\n+\t\t\t\t    \"%s: Table DB creation failed\\n\",\n+\t\t\t\t    tf_dir_2_str(i));\n+\n+\t\t\treturn rc;\n+\t\t}\n+\t}\n+\n+\tinit = 1;\n+\n+\tprintf(\"Table Type - initialized\\n\");\n+\n \treturn 0;\n }\n \n int\n tf_tbl_unbind(struct tf *tfp __rte_unused)\n {\n+\tint rc;\n+\tint i;\n+\tstruct tf_rm_free_db_parms fparms = { 0 };\n+\n+\tTF_CHECK_PARMS1(tfp);\n+\n+\t/* Bail if nothing has been initialized done silent as to\n+\t * allow for creation cleanup.\n+\t */\n+\tif (!init) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"No Table DBs created\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tfor (i = 0; i < TF_DIR_MAX; i++) {\n+\t\tfparms.dir = i;\n+\t\tfparms.rm_db = tbl_db[i];\n+\t\trc = tf_rm_free_db(tfp, &fparms);\n+\t\tif (rc)\n+\t\t\treturn rc;\n+\n+\t\ttbl_db[i] = NULL;\n+\t}\n+\n+\tinit = 0;\n+\n \treturn 0;\n }\n \n int\n tf_tbl_alloc(struct tf *tfp __rte_unused,\n-\t     struct tf_tbl_alloc_parms *parms __rte_unused)\n+\t     struct tf_tbl_alloc_parms *parms)\n {\n+\tint rc;\n+\tuint32_t idx;\n+\tstruct tf_rm_allocate_parms aparms = { 0 };\n+\n+\tTF_CHECK_PARMS2(tfp, parms);\n+\n+\tif (!init) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"%s: No Table DBs created\\n\",\n+\t\t\t    tf_dir_2_str(parms->dir));\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* Allocate requested element */\n+\taparms.rm_db = tbl_db[parms->dir];\n+\taparms.db_index = parms->type;\n+\taparms.index = &idx;\n+\trc = tf_rm_allocate(&aparms);\n+\tif (rc) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"%s: Failed allocate, type:%d\\n\",\n+\t\t\t    tf_dir_2_str(parms->dir),\n+\t\t\t    parms->type);\n+\t\treturn rc;\n+\t}\n+\n+\t*parms->idx = idx;\n+\n \treturn 0;\n }\n \n int\n tf_tbl_free(struct tf *tfp __rte_unused,\n-\t    struct tf_tbl_free_parms *parms __rte_unused)\n+\t    struct tf_tbl_free_parms *parms)\n {\n+\tint rc;\n+\tstruct tf_rm_is_allocated_parms aparms = { 0 };\n+\tstruct tf_rm_free_parms fparms = { 0 };\n+\tint allocated = 0;\n+\n+\tTF_CHECK_PARMS2(tfp, parms);\n+\n+\tif (!init) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"%s: No Table DBs created\\n\",\n+\t\t\t    tf_dir_2_str(parms->dir));\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* Check if element is in use */\n+\taparms.rm_db = tbl_db[parms->dir];\n+\taparms.db_index = parms->type;\n+\taparms.index = parms->idx;\n+\taparms.allocated = &allocated;\n+\trc = tf_rm_is_allocated(&aparms);\n+\tif (rc)\n+\t\treturn rc;\n+\n+\tif (!allocated) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"%s: Entry already free, type:%d, index:%d\\n\",\n+\t\t\t    tf_dir_2_str(parms->dir),\n+\t\t\t    parms->type,\n+\t\t\t    parms->idx);\n+\t\treturn rc;\n+\t}\n+\n+\t/* Free requested element */\n+\tfparms.rm_db = tbl_db[parms->dir];\n+\tfparms.db_index = parms->type;\n+\tfparms.index = parms->idx;\n+\trc = tf_rm_free(&fparms);\n+\tif (rc) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"%s: Free failed, type:%d, index:%d\\n\",\n+\t\t\t    tf_dir_2_str(parms->dir),\n+\t\t\t    parms->type,\n+\t\t\t    parms->idx);\n+\t\treturn rc;\n+\t}\n+\n \treturn 0;\n }\n \n@@ -64,15 +204,107 @@ tf_tbl_alloc_search(struct tf *tfp __rte_unused,\n }\n \n int\n-tf_tbl_set(struct tf *tfp __rte_unused,\n-\t   struct tf_tbl_set_parms *parms __rte_unused)\n+tf_tbl_set(struct tf *tfp,\n+\t   struct tf_tbl_set_parms *parms)\n {\n+\tint rc;\n+\tstruct tf_rm_is_allocated_parms aparms;\n+\tint allocated = 0;\n+\n+\tTF_CHECK_PARMS3(tfp, parms, parms->data);\n+\n+\tif (!init) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"%s: No Table DBs created\\n\",\n+\t\t\t    tf_dir_2_str(parms->dir));\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* Verify that the entry has been previously allocated */\n+\taparms.rm_db = tbl_db[parms->dir];\n+\taparms.db_index = parms->type;\n+\taparms.index = parms->idx;\n+\taparms.allocated = &allocated;\n+\trc = tf_rm_is_allocated(&aparms);\n+\tif (rc)\n+\t\treturn rc;\n+\n+\tif (!allocated) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t   \"%s, Invalid or not allocated index, type:%d, idx:%d\\n\",\n+\t\t   tf_dir_2_str(parms->dir),\n+\t\t   parms->type,\n+\t\t   parms->idx);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* Set the entry */\n+\trc = tf_msg_set_tbl_entry(tfp,\n+\t\t\t\t  parms->dir,\n+\t\t\t\t  parms->type,\n+\t\t\t\t  parms->data_sz_in_bytes,\n+\t\t\t\t  parms->data,\n+\t\t\t\t  parms->idx);\n+\tif (rc) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"%s, Set failed, type:%d, rc:%s\\n\",\n+\t\t\t    tf_dir_2_str(parms->dir),\n+\t\t\t    parms->type,\n+\t\t\t    strerror(-rc));\n+\t}\n+\n \treturn 0;\n }\n \n int\n-tf_tbl_get(struct tf *tfp __rte_unused,\n-\t   struct tf_tbl_get_parms *parms __rte_unused)\n+tf_tbl_get(struct tf *tfp,\n+\t   struct tf_tbl_get_parms *parms)\n {\n+\tint rc;\n+\tstruct tf_rm_is_allocated_parms aparms;\n+\tint allocated = 0;\n+\n+\tTF_CHECK_PARMS3(tfp, parms, parms->data);\n+\n+\tif (!init) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"%s: No Table DBs created\\n\",\n+\t\t\t    tf_dir_2_str(parms->dir));\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* Verify that the entry has been previously allocated */\n+\taparms.rm_db = tbl_db[parms->dir];\n+\taparms.db_index = parms->type;\n+\taparms.index = parms->idx;\n+\taparms.allocated = &allocated;\n+\trc = tf_rm_is_allocated(&aparms);\n+\tif (rc)\n+\t\treturn rc;\n+\n+\tif (!allocated) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t   \"%s, Invalid or not allocated index, type:%d, idx:%d\\n\",\n+\t\t   tf_dir_2_str(parms->dir),\n+\t\t   parms->type,\n+\t\t   parms->idx);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* Get the entry */\n+\trc = tf_msg_get_tbl_entry(tfp,\n+\t\t\t\t  parms->dir,\n+\t\t\t\t  parms->type,\n+\t\t\t\t  parms->data_sz_in_bytes,\n+\t\t\t\t  parms->data,\n+\t\t\t\t  parms->idx);\n+\tif (rc) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"%s, Get failed, type:%d, rc:%s\\n\",\n+\t\t\t    tf_dir_2_str(parms->dir),\n+\t\t\t    parms->type,\n+\t\t\t    strerror(-rc));\n+\t}\n+\n \treturn 0;\n }\ndiff --git a/drivers/net/bnxt/tf_core/tf_tbl_type.h b/drivers/net/bnxt/tf_core/tf_tbl_type.h\nindex 11f2aa333..3474489a6 100644\n--- a/drivers/net/bnxt/tf_core/tf_tbl_type.h\n+++ b/drivers/net/bnxt/tf_core/tf_tbl_type.h\n@@ -55,7 +55,7 @@ struct tf_tbl_alloc_parms {\n \t/**\n \t * [out] Idx of allocated entry or found entry (if search_enable)\n \t */\n-\tuint32_t idx;\n+\tuint32_t *idx;\n };\n \n /**\ndiff --git a/drivers/net/bnxt/tf_core/tf_tcam.c b/drivers/net/bnxt/tf_core/tf_tcam.c\nindex b9dba5323..e0fac31f2 100644\n--- a/drivers/net/bnxt/tf_core/tf_tcam.c\n+++ b/drivers/net/bnxt/tf_core/tf_tcam.c\n@@ -38,8 +38,8 @@ static uint8_t init;\n /* static uint8_t shadow_init; */\n \n int\n-tf_tcam_bind(struct tf *tfp __rte_unused,\n-\t     struct tf_tcam_cfg_parms *parms __rte_unused)\n+tf_tcam_bind(struct tf *tfp,\n+\t     struct tf_tcam_cfg_parms *parms)\n {\n \tint rc;\n \tint i;\n@@ -59,8 +59,8 @@ tf_tcam_bind(struct tf *tfp __rte_unused,\n \t\tdb_cfg.dir = i;\n \t\tdb_cfg.num_elements = parms->num_elements;\n \t\tdb_cfg.cfg = parms->cfg;\n-\t\tdb_cfg.alloc_num = parms->resources->tcam_tbl_cnt[i];\n-\t\tdb_cfg.rm_db = tcam_db[i];\n+\t\tdb_cfg.alloc_cnt = parms->resources->tcam_cnt[i].cnt;\n+\t\tdb_cfg.rm_db = &tcam_db[i];\n \t\trc = tf_rm_create_db(tfp, &db_cfg);\n \t\tif (rc) {\n \t\t\tTFP_DRV_LOG(ERR,\n@@ -72,11 +72,13 @@ tf_tcam_bind(struct tf *tfp __rte_unused,\n \n \tinit = 1;\n \n+\tprintf(\"TCAM - initialized\\n\");\n+\n \treturn 0;\n }\n \n int\n-tf_tcam_unbind(struct tf *tfp __rte_unused)\n+tf_tcam_unbind(struct tf *tfp)\n {\n \tint rc;\n \tint i;\ndiff --git a/drivers/net/bnxt/tf_core/tf_util.h b/drivers/net/bnxt/tf_core/tf_util.h\nindex 4099629ea..ad8edaf30 100644\n--- a/drivers/net/bnxt/tf_core/tf_util.h\n+++ b/drivers/net/bnxt/tf_core/tf_util.h\n@@ -10,32 +10,57 @@\n \n /**\n  * Helper function converting direction to text string\n+ *\n+ * [in] dir\n+ *   Receive or transmit direction identifier\n+ *\n+ * Returns:\n+ *   Pointer to a char string holding the string for the direction\n  */\n-const char\n-*tf_dir_2_str(enum tf_dir dir);\n+const char *tf_dir_2_str(enum tf_dir dir);\n \n /**\n  * Helper function converting identifier to text string\n+ *\n+ * [in] id_type\n+ *   Identifier type\n+ *\n+ * Returns:\n+ *   Pointer to a char string holding the string for the identifier\n  */\n-const char\n-*tf_ident_2_str(enum tf_identifier_type id_type);\n+const char *tf_ident_2_str(enum tf_identifier_type id_type);\n \n /**\n  * Helper function converting tcam type to text string\n+ *\n+ * [in] tcam_type\n+ *   TCAM type\n+ *\n+ * Returns:\n+ *   Pointer to a char string holding the string for the tcam\n  */\n-const char\n-*tf_tcam_tbl_2_str(enum tf_tcam_tbl_type tcam_type);\n+const char *tf_tcam_tbl_2_str(enum tf_tcam_tbl_type tcam_type);\n \n /**\n  * Helper function converting tbl type to text string\n+ *\n+ * [in] tbl_type\n+ *   Table type\n+ *\n+ * Returns:\n+ *   Pointer to a char string holding the string for the table type\n  */\n-const char\n-*tf_tbl_type_2_str(enum tf_tbl_type tbl_type);\n+const char *tf_tbl_type_2_str(enum tf_tbl_type tbl_type);\n \n /**\n  * Helper function converting em tbl type to text string\n+ *\n+ * [in] em_type\n+ *   EM type\n+ *\n+ * Returns:\n+ *   Pointer to a char string holding the string for the EM type\n  */\n-const char\n-*tf_em_tbl_type_2_str(enum tf_em_tbl_type em_type);\n+const char *tf_em_tbl_type_2_str(enum tf_em_tbl_type em_type);\n \n #endif /* _TF_UTIL_H_ */\ndiff --git a/drivers/net/bnxt/tf_core/tfp.c b/drivers/net/bnxt/tf_core/tfp.c\nindex 3bce3ade1..69d1c9a1f 100644\n--- a/drivers/net/bnxt/tf_core/tfp.c\n+++ b/drivers/net/bnxt/tf_core/tfp.c\n@@ -102,13 +102,13 @@ tfp_calloc(struct tfp_calloc_parms *parms)\n \t\t\t\t    (parms->nitems * parms->size),\n \t\t\t\t    parms->alignment);\n \tif (parms->mem_va == NULL) {\n-\t\tPMD_DRV_LOG(ERR, \"Allocate failed mem_va\\n\");\n+\t\tTFP_DRV_LOG(ERR, \"Allocate failed mem_va\\n\");\n \t\treturn -ENOMEM;\n \t}\n \n \tparms->mem_pa = (void *)((uintptr_t)rte_mem_virt2iova(parms->mem_va));\n \tif (parms->mem_pa == (void *)((uintptr_t)RTE_BAD_IOVA)) {\n-\t\tPMD_DRV_LOG(ERR, \"Allocate failed mem_pa\\n\");\n+\t\tTFP_DRV_LOG(ERR, \"Allocate failed mem_pa\\n\");\n \t\treturn -ENOMEM;\n \t}\n \n",
    "prefixes": [
        "v5",
        "18/51"
    ]
}