get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 129063,
    "url": "http://patchwork.dpdk.org/api/patches/129063/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20230628162927.92858-5-ajit.khaparde@broadcom.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20230628162927.92858-5-ajit.khaparde@broadcom.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230628162927.92858-5-ajit.khaparde@broadcom.com",
    "date": "2023-06-28T16:29:20",
    "name": "[v4,04/11] net/bnxt: update Truflow core",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "fc6a5fc6a98f9e71b29d8d24a3c134b08cb0581f",
    "submitter": {
        "id": 501,
        "url": "http://patchwork.dpdk.org/api/people/501/?format=api",
        "name": "Ajit Khaparde",
        "email": "ajit.khaparde@broadcom.com"
    },
    "delegate": {
        "id": 1766,
        "url": "http://patchwork.dpdk.org/api/users/1766/?format=api",
        "username": "ajitkhaparde",
        "first_name": "Ajit",
        "last_name": "Khaparde",
        "email": "ajit.khaparde@broadcom.com"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20230628162927.92858-5-ajit.khaparde@broadcom.com/mbox/",
    "series": [
        {
            "id": 28693,
            "url": "http://patchwork.dpdk.org/api/series/28693/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=28693",
            "date": "2023-06-28T16:29:16",
            "name": "sync Truflow support with latest release",
            "version": 4,
            "mbox": "http://patchwork.dpdk.org/series/28693/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/129063/comments/",
    "check": "warning",
    "checks": "http://patchwork.dpdk.org/api/patches/129063/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 6453C42D82;\n\tWed, 28 Jun 2023 18:31:35 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 7E10442D3A;\n\tWed, 28 Jun 2023 18:30:58 +0200 (CEST)",
            "from mail-pl1-f179.google.com (mail-pl1-f179.google.com\n [209.85.214.179])\n by mails.dpdk.org (Postfix) with ESMTP id AA12A42D3A\n for <dev@dpdk.org>; Wed, 28 Jun 2023 18:30:54 +0200 (CEST)",
            "by mail-pl1-f179.google.com with SMTP id\n d9443c01a7336-1b7f92b764dso603465ad.2\n for <dev@dpdk.org>; Wed, 28 Jun 2023 09:30:54 -0700 (PDT)",
            "from localhost.localdomain ([192.19.252.250])\n by smtp.gmail.com with ESMTPSA id\n h12-20020a170902f7cc00b001b8229942a0sm3092403plw.34.2023.06.28.09.30.45\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 28 Jun 2023 09:30:49 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=broadcom.com; s=google; t=1687969853; x=1690561853;\n h=mime-version:references:in-reply-to:message-id:date:subject:cc:to\n :from:from:to:cc:subject:date:message-id:reply-to;\n bh=T159d61y5EmE4obQrLFJZIYUzzUSTYPqnT/ReQgb4bU=;\n b=D68gQj98INnuzF2Hjt8tqIo+g+MxoystNfIuTa4df3wDdlQeW3NWvOf9RQKJN/HmOE\n qGtZ8tBqCdUWvzvf9voGiRyMKjKcIDAhP+cL1GNlsBXqzewCsOnrt8dAxIZlX7jPekRV\n qGEJm+jCgHsRshaUG7EEnjJtMDQSey0ywM+i8=",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20221208; t=1687969853; x=1690561853;\n h=mime-version:references:in-reply-to:message-id:date:subject:cc:to\n :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;\n bh=T159d61y5EmE4obQrLFJZIYUzzUSTYPqnT/ReQgb4bU=;\n b=DG9qVyfmK9V90vlYzSrjfRqIpbuP7bf3D7v9o2MdBCFtmEHVWIegALjDCYG9PgrXsX\n u/xGirBXo64pjOPLSBMtxlPz5JOBo90EJbrkQLpikrBx1AN9GeOGYWQoVl0KDVZynY79\n m2QpvDzW6JDH2126nGx9HXYXl4xJ26ctsFiKPuINLt3l12VIj9fzU5LijX/9OCHK0CQb\n GD/buV0DUNsL0Bc/1A7U04s0pH75fhFNBbv84H26Oz65PMZHWWJBSbZEAXkBVjRJV5QI\n Ewhm90KhJv540YYYZrCfVoyW88tfi7ke1hyKCRa3QgKsWeCo0eTZkZquI8rpVZxJA42J\n C4rw==",
        "X-Gm-Message-State": "AC+VfDwh3czF2OFb564F6A860WhsMnwK4U1sG8K1wnj003pEsa8aEXAY\n ONij3mgvQDnORzutDQt/bLC1axyQABzFyh/meDiKrECn7LDtxepxE+/AfzwQeW2wxa4jU/8Idmx\n zwo2ArhXkE4n3bBX1EmB57hbZuC8KOHCf9r/ERv8dojBCaZoMezQL3FAbH95Hu7Acs27Ckw8=",
        "X-Google-Smtp-Source": "\n ACHHUZ5kxPs7dsxG22cOkbiQkhcJRl6mYnFtV3ZRt4n9N+3GvTfyLZC1x76vKu4KW7Yy7S7LRIbiFw==",
        "X-Received": "by 2002:a17:903:2446:b0:1b8:1c4f:4f72 with SMTP id\n l6-20020a170903244600b001b81c4f4f72mr5301312pls.61.1687969850094;\n Wed, 28 Jun 2023 09:30:50 -0700 (PDT)",
        "From": "Ajit Khaparde <ajit.khaparde@broadcom.com>",
        "To": "dev@dpdk.org",
        "Cc": "ferruh.yigit@intel.com, thomas@monjalon.net,\n Randy Schacher <stuart.schacher@broadcom.com>,\n Farah Smith <farah.smith@broadcom.com>,\n Shahaji Bhosle <sbhosle@broadcom.com>",
        "Subject": "[PATCH v4 04/11] net/bnxt: update Truflow core",
        "Date": "Wed, 28 Jun 2023 09:29:20 -0700",
        "Message-Id": "<20230628162927.92858-5-ajit.khaparde@broadcom.com>",
        "X-Mailer": "git-send-email 2.39.2 (Apple Git-143)",
        "In-Reply-To": "<20230628162927.92858-1-ajit.khaparde@broadcom.com>",
        "References": "<1826961.atdPhlSkOF@thomas>\n <20230628162927.92858-1-ajit.khaparde@broadcom.com>",
        "MIME-Version": "1.0",
        "Content-Type": "multipart/signed; protocol=\"application/pkcs7-signature\";\n micalg=sha-256; boundary=\"000000000000856a0505ff331b96\"",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "From: Randy Schacher <stuart.schacher@broadcom.com>\n\nUpdate TruFlow core code to:\n- Add shared session management\n- Add SRAM session management\n- Add dynamic TCAM management\n- Add shared TCAM session management\n- Add Hot Upgrade support\n- Update copyright year\n\nSigned-off-by: Randy Schacher <stuart.schacher@broadcom.com>\nSigned-off-by: Farah Smith <farah.smith@broadcom.com>\nReviewed-by: Shahaji Bhosle <sbhosle@broadcom.com>\nReviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>\n---\n drivers/net/bnxt/bnxt.h                       |    1 -\n drivers/net/bnxt/bnxt_irq.h                   |    1 -\n drivers/net/bnxt/bnxt_nvm_defs.h              |    1 -\n drivers/net/bnxt/bnxt_ring.h                  |    1 -\n drivers/net/bnxt/bnxt_rxr.h                   |    1 -\n drivers/net/bnxt/bnxt_txr.h                   |    1 -\n drivers/net/bnxt/bnxt_util.h                  |    1 -\n drivers/net/bnxt/tf_core/cfa_resource_types.h |    2 -\n drivers/net/bnxt/tf_core/cfa_tcam_mgr.c       | 2116 +++++++++++++++++\n drivers/net/bnxt/tf_core/cfa_tcam_mgr.h       |  523 ++++\n .../net/bnxt/tf_core/cfa_tcam_mgr_device.h    |  101 +\n .../net/bnxt/tf_core/cfa_tcam_mgr_hwop_msg.c  |  201 ++\n .../net/bnxt/tf_core/cfa_tcam_mgr_hwop_msg.h  |   28 +\n drivers/net/bnxt/tf_core/cfa_tcam_mgr_p4.c    |  921 +++++++\n drivers/net/bnxt/tf_core/cfa_tcam_mgr_p4.h    |   20 +\n drivers/net/bnxt/tf_core/cfa_tcam_mgr_p58.c   |  926 ++++++++\n drivers/net/bnxt/tf_core/cfa_tcam_mgr_p58.h   |   20 +\n drivers/net/bnxt/tf_core/cfa_tcam_mgr_sbmp.h  |  126 +\n .../net/bnxt/tf_core/cfa_tcam_mgr_session.c   |  377 +++\n .../net/bnxt/tf_core/cfa_tcam_mgr_session.h   |   54 +\n drivers/net/bnxt/tf_core/meson.build          |   36 +-\n drivers/net/bnxt/tf_core/tf_core.c            |   54 +-\n drivers/net/bnxt/tf_core/tf_core.h            |   97 +-\n drivers/net/bnxt/tf_core/tf_device.c          |   18 +-\n drivers/net/bnxt/tf_core/tf_device.h          |    2 +-\n drivers/net/bnxt/tf_core/tf_device_p4.c       |   14 +-\n drivers/net/bnxt/tf_core/tf_device_p58.c      |   84 +-\n drivers/net/bnxt/tf_core/tf_em_common.c       |    2 +-\n drivers/net/bnxt/tf_core/tf_em_internal.c     |   10 +-\n drivers/net/bnxt/tf_core/tf_identifier.c      |    1 +\n drivers/net/bnxt/tf_core/tf_if_tbl.c          |   59 +-\n drivers/net/bnxt/tf_core/tf_msg.c             |  217 +-\n drivers/net/bnxt/tf_core/tf_msg.h             |   38 +-\n drivers/net/bnxt/tf_core/tf_rm.c              |  117 +-\n drivers/net/bnxt/tf_core/tf_session.c         |  112 +-\n drivers/net/bnxt/tf_core/tf_session.h         |   65 +-\n drivers/net/bnxt/tf_core/tf_sram_mgr.c        |  117 +-\n drivers/net/bnxt/tf_core/tf_sram_mgr.h        |   22 +-\n drivers/net/bnxt/tf_core/tf_tbl.c             |    8 +-\n drivers/net/bnxt/tf_core/tf_tbl_sram.c        |   25 +-\n drivers/net/bnxt/tf_core/tf_tcam.c            |  226 +-\n drivers/net/bnxt/tf_core/tf_tcam_mgr_msg.c    |  286 +++\n drivers/net/bnxt/tf_core/tf_tcam_mgr_msg.h    |   49 +\n drivers/net/bnxt/tf_core/tf_tcam_shared.c     | 1146 +--------\n drivers/net/bnxt/tf_core/tf_tcam_shared.h     |    3 +-\n drivers/net/bnxt/tf_ulp/bnxt_ulp.c            |    8 +-\n 46 files changed, 6686 insertions(+), 1552 deletions(-)\n create mode 100644 drivers/net/bnxt/tf_core/cfa_tcam_mgr.c\n create mode 100644 drivers/net/bnxt/tf_core/cfa_tcam_mgr.h\n create mode 100644 drivers/net/bnxt/tf_core/cfa_tcam_mgr_device.h\n create mode 100644 drivers/net/bnxt/tf_core/cfa_tcam_mgr_hwop_msg.c\n create mode 100644 drivers/net/bnxt/tf_core/cfa_tcam_mgr_hwop_msg.h\n create mode 100644 drivers/net/bnxt/tf_core/cfa_tcam_mgr_p4.c\n create mode 100644 drivers/net/bnxt/tf_core/cfa_tcam_mgr_p4.h\n create mode 100644 drivers/net/bnxt/tf_core/cfa_tcam_mgr_p58.c\n create mode 100644 drivers/net/bnxt/tf_core/cfa_tcam_mgr_p58.h\n create mode 100644 drivers/net/bnxt/tf_core/cfa_tcam_mgr_sbmp.h\n create mode 100644 drivers/net/bnxt/tf_core/cfa_tcam_mgr_session.c\n create mode 100644 drivers/net/bnxt/tf_core/cfa_tcam_mgr_session.h\n create mode 100644 drivers/net/bnxt/tf_core/tf_tcam_mgr_msg.c\n create mode 100644 drivers/net/bnxt/tf_core/tf_tcam_mgr_msg.h",
    "diff": "diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h\nindex 48bd8f2418..2bccdec7e0 100644\n--- a/drivers/net/bnxt/bnxt.h\n+++ b/drivers/net/bnxt/bnxt.h\n@@ -1044,5 +1044,4 @@ int bnxt_flow_ops_get_op(struct rte_eth_dev *dev,\n int bnxt_dev_start_op(struct rte_eth_dev *eth_dev);\n int bnxt_dev_stop_op(struct rte_eth_dev *eth_dev);\n void bnxt_handle_vf_cfg_change(void *arg);\n-\n #endif\ndiff --git a/drivers/net/bnxt/bnxt_irq.h b/drivers/net/bnxt/bnxt_irq.h\nindex e498578968..e2d61bae7a 100644\n--- a/drivers/net/bnxt/bnxt_irq.h\n+++ b/drivers/net/bnxt/bnxt_irq.h\n@@ -20,5 +20,4 @@ void bnxt_enable_int(struct bnxt *bp);\n int bnxt_setup_int(struct bnxt *bp);\n int bnxt_request_int(struct bnxt *bp);\n void bnxt_int_handler(void *param);\n-\n #endif\ndiff --git a/drivers/net/bnxt/bnxt_nvm_defs.h b/drivers/net/bnxt/bnxt_nvm_defs.h\nindex f5ac4e8c84..57ddefa7a1 100644\n--- a/drivers/net/bnxt/bnxt_nvm_defs.h\n+++ b/drivers/net/bnxt/bnxt_nvm_defs.h\n@@ -66,5 +66,4 @@ enum bnxnvm_pkglog_field_index {\n \tBNX_PKG_LOG_FIELD_IDX_INSTALLED_ITEMS\t\t= 5,\n \tBNX_PKG_LOG_FIELD_IDX_INSTALLED_MASK\t\t= 6\n };\n-\n #endif\t\t\t\t/* Don't add anything after this line */\ndiff --git a/drivers/net/bnxt/bnxt_ring.h b/drivers/net/bnxt/bnxt_ring.h\nindex 3d747aba54..baa60b2627 100644\n--- a/drivers/net/bnxt/bnxt_ring.h\n+++ b/drivers/net/bnxt/bnxt_ring.h\n@@ -142,5 +142,4 @@ static inline void bnxt_db_cq(struct bnxt_cp_ring_info *cpr)\n \t\tB_CP_DIS_DB(cpr, cp_raw_cons);\n \t}\n }\n-\n #endif\ndiff --git a/drivers/net/bnxt/bnxt_rxr.h b/drivers/net/bnxt/bnxt_rxr.h\nindex e132166a18..8e722b7bf0 100644\n--- a/drivers/net/bnxt/bnxt_rxr.h\n+++ b/drivers/net/bnxt/bnxt_rxr.h\n@@ -386,5 +386,4 @@ bnxt_parse_pkt_type_v2(struct rte_mbuf *mbuf,\n \n \tmbuf->packet_type = pkt_type;\n }\n-\n #endif /*  _BNXT_RXR_H_ */\ndiff --git a/drivers/net/bnxt/bnxt_txr.h b/drivers/net/bnxt/bnxt_txr.h\nindex e11343c082..75456df5bd 100644\n--- a/drivers/net/bnxt/bnxt_txr.h\n+++ b/drivers/net/bnxt/bnxt_txr.h\n@@ -90,5 +90,4 @@ int bnxt_flush_tx_cmp(struct bnxt_cp_ring_info *cpr);\n \t\t\t\t\tTX_BD_LONG_LFLAGS_IP_CHKSUM)\n #define TX_BD_FLG_TIP_TCP_UDP_CHKSUM\t(TX_BD_LONG_LFLAGS_TCP_UDP_CHKSUM | \\\n \t\t\t\t\tTX_BD_LONG_LFLAGS_T_IP_CHKSUM)\n-\n #endif\ndiff --git a/drivers/net/bnxt/bnxt_util.h b/drivers/net/bnxt/bnxt_util.h\nindex 3437dc75ae..7f5b4c160e 100644\n--- a/drivers/net/bnxt/bnxt_util.h\n+++ b/drivers/net/bnxt/bnxt_util.h\n@@ -17,5 +17,4 @@\n \n int bnxt_check_zero_bytes(const uint8_t *bytes, int len);\n void bnxt_eth_hw_addr_random(uint8_t *mac_addr);\n-\n #endif /* _BNXT_UTIL_H_ */\ndiff --git a/drivers/net/bnxt/tf_core/cfa_resource_types.h b/drivers/net/bnxt/tf_core/cfa_resource_types.h\nindex 874d7b834f..8431c778e4 100644\n--- a/drivers/net/bnxt/tf_core/cfa_resource_types.h\n+++ b/drivers/net/bnxt/tf_core/cfa_resource_types.h\n@@ -63,7 +63,6 @@\n #define CFA_RESOURCE_TYPE_P59_VEB_TCAM           0x18UL\n #define CFA_RESOURCE_TYPE_P59_LAST              CFA_RESOURCE_TYPE_P59_VEB_TCAM\n \n-\n /* Meter */\n #define CFA_RESOURCE_TYPE_P58_METER              0x0UL\n /* SRAM_Bank_0 */\n@@ -184,7 +183,6 @@\n #define CFA_RESOURCE_TYPE_P45_TBL_SCOPE           0x23UL\n #define CFA_RESOURCE_TYPE_P45_LAST               CFA_RESOURCE_TYPE_P45_TBL_SCOPE\n \n-\n /* Multicast Group */\n #define CFA_RESOURCE_TYPE_P4_MCG                 0x0UL\n /* Encap 8 byte record */\ndiff --git a/drivers/net/bnxt/tf_core/cfa_tcam_mgr.c b/drivers/net/bnxt/tf_core/cfa_tcam_mgr.c\nnew file mode 100644\nindex 0000000000..f26d93e7a9\n--- /dev/null\n+++ b/drivers/net/bnxt/tf_core/cfa_tcam_mgr.c\n@@ -0,0 +1,2116 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2021-2023 Broadcom\n+ * All rights reserved.\n+ */\n+\n+#include <inttypes.h>\n+#include <signal.h>\n+\n+#include \"hcapi_cfa_defs.h\"\n+\n+#include \"tfp.h\"\n+#include \"tf_session.h\"\n+#include \"tf_util.h\"\n+#include \"cfa_tcam_mgr.h\"\n+#include \"cfa_tcam_mgr_hwop_msg.h\"\n+#include \"cfa_tcam_mgr_device.h\"\n+#include \"cfa_tcam_mgr_session.h\"\n+#include \"cfa_tcam_mgr_p58.h\"\n+#include \"cfa_tcam_mgr_p4.h\"\n+\n+#define TF_TCAM_SLICE_INVALID (-1)\n+\n+/*\n+ * The following macros are for setting the entry status in a row entry.\n+ * row is (struct cfa_tcam_mgr_table_rows_0 *)\n+ */\n+#define ROW_ENTRY_INUSE(row, entry)  ((row)->entry_inuse &   (1U << (entry)))\n+#define ROW_ENTRY_SET(row, entry)    ((row)->entry_inuse |=  (1U << (entry)))\n+#define ROW_ENTRY_CLEAR(row, entry)  ((row)->entry_inuse &= ~(1U << (entry)))\n+#define ROW_INUSE(row)               ((row)->entry_inuse != 0)\n+\n+static struct cfa_tcam_mgr_entry_data *entry_data[TF_TCAM_MAX_SESSIONS];\n+\n+static int global_data_initialized[TF_TCAM_MAX_SESSIONS];\n+int cfa_tcam_mgr_max_entries[TF_TCAM_MAX_SESSIONS];\n+\n+struct cfa_tcam_mgr_table_data\n+cfa_tcam_mgr_tables[TF_TCAM_MAX_SESSIONS][TF_DIR_MAX][CFA_TCAM_MGR_TBL_TYPE_MAX];\n+\n+static int physical_table_types[CFA_TCAM_MGR_TBL_TYPE_MAX] = {\n+\t[CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_HIGH_APPS] =\n+\t\tTF_TCAM_TBL_TYPE_L2_CTXT_TCAM_HIGH,\n+\t[CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_LOW_APPS]  =\n+\t\tTF_TCAM_TBL_TYPE_L2_CTXT_TCAM_LOW,\n+\t[CFA_TCAM_MGR_TBL_TYPE_PROF_TCAM_APPS]\t      =\n+\t\tTF_TCAM_TBL_TYPE_PROF_TCAM,\n+\t[CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_APPS]\t      =\n+\t\tTF_TCAM_TBL_TYPE_WC_TCAM,\n+\t[CFA_TCAM_MGR_TBL_TYPE_SP_TCAM_APPS]\t      =\n+\t\tTF_TCAM_TBL_TYPE_SP_TCAM,\n+\t[CFA_TCAM_MGR_TBL_TYPE_CT_RULE_TCAM_APPS]      =\n+\t\tTF_TCAM_TBL_TYPE_CT_RULE_TCAM,\n+\t[CFA_TCAM_MGR_TBL_TYPE_VEB_TCAM_APPS]\t      =\n+\t\tTF_TCAM_TBL_TYPE_VEB_TCAM,\n+\t[CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_APPS]     =\n+\t\tTF_TCAM_TBL_TYPE_WC_TCAM_HIGH,\n+\t[CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_APPS]      =\n+\t\tTF_TCAM_TBL_TYPE_WC_TCAM_LOW,\n+};\n+\n+int\n+cfa_tcam_mgr_get_phys_table_type(enum cfa_tcam_mgr_tbl_type type)\n+{\n+\tif (type >= CFA_TCAM_MGR_TBL_TYPE_MAX)\n+\t\tassert(0);\n+\telse\n+\t\treturn physical_table_types[type];\n+}\n+\n+const char *\n+cfa_tcam_mgr_tbl_2_str(enum cfa_tcam_mgr_tbl_type tcam_type)\n+{\n+\tswitch (tcam_type) {\n+\tcase CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_HIGH_AFM:\n+\t\treturn \"l2_ctxt_tcam_high AFM\";\n+\tcase CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_HIGH_APPS:\n+\t\treturn \"l2_ctxt_tcam_high Apps\";\n+\tcase CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_LOW_AFM:\n+\t\treturn \"l2_ctxt_tcam_low AFM\";\n+\tcase CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_LOW_APPS:\n+\t\treturn \"l2_ctxt_tcam_low Apps\";\n+\tcase CFA_TCAM_MGR_TBL_TYPE_PROF_TCAM_AFM:\n+\t\treturn \"prof_tcam AFM\";\n+\tcase CFA_TCAM_MGR_TBL_TYPE_PROF_TCAM_APPS:\n+\t\treturn \"prof_tcam Apps\";\n+\tcase CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_AFM:\n+\t\treturn \"wc_tcam AFM\";\n+\tcase CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_APPS:\n+\t\treturn \"wc_tcam Apps\";\n+\tcase CFA_TCAM_MGR_TBL_TYPE_VEB_TCAM_AFM:\n+\t\treturn \"veb_tcam AFM\";\n+\tcase CFA_TCAM_MGR_TBL_TYPE_VEB_TCAM_APPS:\n+\t\treturn \"veb_tcam Apps\";\n+\tcase CFA_TCAM_MGR_TBL_TYPE_SP_TCAM_AFM:\n+\t\treturn \"sp_tcam AFM\";\n+\tcase CFA_TCAM_MGR_TBL_TYPE_SP_TCAM_APPS:\n+\t\treturn \"sp_tcam Apps\";\n+\tcase CFA_TCAM_MGR_TBL_TYPE_CT_RULE_TCAM_AFM:\n+\t\treturn \"ct_rule_tcam AFM\";\n+\tcase CFA_TCAM_MGR_TBL_TYPE_CT_RULE_TCAM_APPS:\n+\t\treturn \"ct_rule_tcam Apps\";\n+\tcase CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_AFM:\n+\t\treturn \"wc_tcam_high AFM\";\n+\tcase CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_APPS:\n+\t\treturn \"wc_tcam_high Apps\";\n+\tcase CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_AFM:\n+\t\treturn \"wc_tcam_low AFM\";\n+\tcase CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_APPS:\n+\t\treturn \"wc_tcam_low Apps\";\n+\tdefault:\n+\t\treturn \"Invalid tcam table type\";\n+\t}\n+}\n+\n+/* key_size and slice_width are in bytes */\n+static int\n+cfa_tcam_mgr_get_num_slices(unsigned int key_size, unsigned int slice_width)\n+{\n+\tint num_slices = 0;\n+\n+\tif (key_size == 0)\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\n+\n+\tnum_slices = ((key_size - 1U) / slice_width) + 1U;\n+\t/* Round up to next highest power of 2 */\n+\t/* This is necessary since, for example, 3 slices is not a valid entry\n+\t * width.\n+\t */\n+\tnum_slices--;\n+\t/* Repeat to maximum number of bits actually used */\n+\t/* This fills in all the bits. */\n+\tnum_slices |= num_slices >> 1;\n+\tnum_slices |= num_slices >> 2;\n+\tnum_slices |= num_slices >> 4;\n+\t/*\n+\t * If the maximum number of slices that are supported by the HW\n+\t * increases, then additional shifts are needed.\n+\t */\n+\tnum_slices++;\n+\treturn num_slices;\n+}\n+\n+static struct cfa_tcam_mgr_entry_data *\n+cfa_tcam_mgr_entry_get(int sess_idx, uint16_t id)\n+{\n+\tif (id > cfa_tcam_mgr_max_entries[sess_idx])\n+\t\treturn NULL;\n+\n+\treturn &entry_data[sess_idx][id];\n+}\n+\n+/* Insert an entry into the entry table */\n+static int\n+cfa_tcam_mgr_entry_insert(int sess_idx, uint16_t id,\n+\t\t\t  struct cfa_tcam_mgr_entry_data *entry)\n+{\n+\tif (id > cfa_tcam_mgr_max_entries[sess_idx])\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\n+\n+\tmemcpy(&entry_data[sess_idx][id], entry,\n+\t       sizeof(entry_data[sess_idx][id]));\n+\n+\treturn 0;\n+}\n+\n+/* Delete an entry from the entry table */\n+static int\n+cfa_tcam_mgr_entry_delete(int sess_idx, uint16_t id)\n+{\n+\tif (id > cfa_tcam_mgr_max_entries[sess_idx])\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\n+\n+\tmemset(&entry_data[sess_idx][id], 0, sizeof(entry_data[sess_idx][id]));\n+\n+\treturn 0;\n+}\n+\n+/* Returns the size of the row structure taking into account how many slices a\n+ * TCAM supports.\n+ */\n+static int\n+cfa_tcam_mgr_row_size_get(int sess_idx, enum tf_dir dir,\n+\t\t\t  enum cfa_tcam_mgr_tbl_type type)\n+{\n+\treturn sizeof(struct cfa_tcam_mgr_table_rows_0) +\n+\t\t(cfa_tcam_mgr_tables[sess_idx][dir][type].max_slices *\n+\t\t sizeof(((struct cfa_tcam_mgr_table_rows_0 *)0)->entries[0]));\n+}\n+\n+static void *\n+cfa_tcam_mgr_row_ptr_get(void *base, int index, int row_size)\n+{\n+\treturn (uint8_t *)base + (index * row_size);\n+}\n+\n+/*\n+ * Searches a table to find the direction and type of an entry.\n+ */\n+static int\n+cfa_tcam_mgr_entry_find_in_table(int sess_idx, int id, enum tf_dir dir,\n+\t\t\t\t enum cfa_tcam_mgr_tbl_type type)\n+{\n+\tstruct cfa_tcam_mgr_table_data *table_data;\n+\tstruct cfa_tcam_mgr_table_rows_0 *row;\n+\tint max_slices, row_idx, row_size, slice;\n+\n+\ttable_data = &cfa_tcam_mgr_tables[sess_idx][dir][type];\n+\tif (table_data->max_entries > 0 &&\n+\t    table_data->hcapi_type > 0) {\n+\t\tmax_slices = table_data->max_slices;\n+\t\trow_size = cfa_tcam_mgr_row_size_get(sess_idx, dir, type);\n+\t\tfor (row_idx = table_data->start_row;\n+\t\t     row_idx <= table_data->end_row;\n+\t\t     row_idx++) {\n+\t\t\trow = cfa_tcam_mgr_row_ptr_get(table_data->tcam_rows,\n+\t\t\t\t\t\t       row_idx, row_size);\n+\t\t\tif (!ROW_INUSE(row))\n+\t\t\t\tcontinue;\n+\t\t\tfor (slice = 0;\n+\t\t\t     slice < (max_slices / row->entry_size);\n+\t\t\t     slice++) {\n+\t\t\t\tif (!ROW_ENTRY_INUSE(row, slice))\n+\t\t\t\t\tcontinue;\n+\t\t\t\tif (row->entries[slice] == id)\n+\t\t\t\t\treturn 0;\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\treturn -CFA_TCAM_MGR_ERR_CODE(NOENT);\n+}\n+\n+/*\n+ * Searches all the tables to find the direction and type of an entry.\n+ */\n+static int\n+cfa_tcam_mgr_entry_find(int sess_idx, int id, enum tf_dir *tbl_dir,\n+\t\t\tenum cfa_tcam_mgr_tbl_type *tbl_type)\n+{\n+\tenum tf_dir dir;\n+\tenum cfa_tcam_mgr_tbl_type type;\n+\tint rc = -CFA_TCAM_MGR_ERR_CODE(NOENT);\n+\n+\tfor (dir = TF_DIR_RX; dir < ARRAY_SIZE(cfa_tcam_mgr_tables[sess_idx]); dir++) {\n+\t\tfor (type = CFA_TCAM_MGR_TBL_TYPE_START;\n+\t\t     type < ARRAY_SIZE(cfa_tcam_mgr_tables[sess_idx][dir]);\n+\t\t     type++) {\n+\t\t\trc = cfa_tcam_mgr_entry_find_in_table(sess_idx, id, dir, type);\n+\t\t\tif (rc == 0) {\n+\t\t\t\t*tbl_dir  = dir;\n+\t\t\t\t*tbl_type = type;\n+\t\t\t\treturn rc;\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\treturn rc;\n+}\n+\n+static int\n+cfa_tcam_mgr_row_is_entry_free(struct cfa_tcam_mgr_table_rows_0 *row,\n+\t\t\t      int max_slices,\n+\t\t\t      int key_slices)\n+{\n+\tint j;\n+\n+\tif (ROW_INUSE(row) &&\n+\t    row->entry_size == key_slices) {\n+\t\tfor (j = 0; j < (max_slices / row->entry_size); j++) {\n+\t\t\tif (!ROW_ENTRY_INUSE(row, j))\n+\t\t\t\treturn j;\n+\t\t}\n+\t}\n+\treturn -1;\n+}\n+\n+static int\n+cfa_tcam_mgr_entry_move(int sess_idx, struct cfa_tcam_mgr_context *context,\n+\t\t       enum tf_dir dir, enum cfa_tcam_mgr_tbl_type type,\n+\t\t       int entry_id,\n+\t\t       struct cfa_tcam_mgr_table_data *table_data,\n+\t\t       int dest_row_index, int dest_row_slice,\n+\t\t       struct cfa_tcam_mgr_table_rows_0 *dest_row,\n+\t\t       int source_row_index,\n+\t\t       struct cfa_tcam_mgr_table_rows_0 *source_row,\n+\t\t       bool free_source_entry)\n+{\n+\tstruct cfa_tcam_mgr_get_parms gparms = { 0 };\n+\tstruct cfa_tcam_mgr_set_parms sparms = { 0 };\n+\tstruct cfa_tcam_mgr_free_parms fparms = { 0 };\n+\tstruct cfa_tcam_mgr_entry_data *entry;\n+\tuint8_t  key[CFA_TCAM_MGR_MAX_KEY_SIZE];\n+\tuint8_t  mask[CFA_TCAM_MGR_MAX_KEY_SIZE];\n+\tuint8_t  result[CFA_TCAM_MGR_MAX_KEY_SIZE];\n+\n+\tint j, rc;\n+\n+\tentry = cfa_tcam_mgr_entry_get(sess_idx, entry_id);\n+\tif (entry == NULL)\n+\t\treturn -1;\n+\n+\tgparms.dir\t   = dir;\n+\tgparms.type\t   = type;\n+\tgparms.hcapi_type  = table_data->hcapi_type;\n+\tgparms.key\t   = key;\n+\tgparms.mask\t   = mask;\n+\tgparms.result\t   = result;\n+\tgparms.id\t   = source_row->entries[entry->slice];\n+\tgparms.key_size\t   = sizeof(key);\n+\tgparms.result_size = sizeof(result);\n+\n+\trc = cfa_tcam_mgr_entry_get_msg(sess_idx, context, &gparms,\n+\t\t\t\t\tsource_row_index,\n+\t\t\t\t\tentry->slice * source_row->entry_size,\n+\t\t\t\t\ttable_data->max_slices);\n+\tif (rc != 0)\n+\t\treturn rc;\n+\n+\tsparms.dir\t   = dir;\n+\tsparms.type\t   = type;\n+\tsparms.hcapi_type  = table_data->hcapi_type;\n+\tsparms.key\t   = key;\n+\tsparms.mask\t   = mask;\n+\tsparms.result\t   = result;\n+\tsparms.id\t   = gparms.id;\n+\tsparms.key_size\t   = gparms.key_size;\n+\tsparms.result_size = gparms.result_size;\n+\n+\t/* Slice in destination row not specified. Find first free slice. */\n+\tif (dest_row_slice < 0)\n+\t\tfor (j = 0;\n+\t\t     j < (table_data->max_slices / dest_row->entry_size);\n+\t\t     j++) {\n+\t\t\tif (!ROW_ENTRY_INUSE(dest_row, j)) {\n+\t\t\t\tdest_row_slice = j;\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n+\n+\t/* If no free slice found, return error. */\n+\tif (dest_row_slice < 0)\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(PERM);\n+\n+\trc = cfa_tcam_mgr_entry_set_msg(sess_idx, context, &sparms,\n+\t\t\t\t\tdest_row_index,\n+\t\t\t\t\tdest_row_slice * dest_row->entry_size,\n+\t\t\t\t\ttable_data->max_slices);\n+\tif (rc != 0)\n+\t\treturn rc;\n+\n+\tif (free_source_entry) {\n+\t\tfparms.dir\t  = dir;\n+\t\tfparms.type\t  = type;\n+\t\tfparms.hcapi_type = table_data->hcapi_type;\n+\t\trc = cfa_tcam_mgr_entry_free_msg(sess_idx, context, &fparms,\n+\t\t\t\t\t\t source_row_index,\n+\t\t\t\t\t\t entry->slice *\n+\t\t\t\t\t\t dest_row->entry_size,\n+\t\t\t\t\t\t table_data->row_width /\n+\t\t\t\t\t\t table_data->max_slices *\n+\t\t\t\t\t\t source_row->entry_size,\n+\t\t\t\t\t\t table_data->result_size,\n+\t\t\t\t\t\t table_data->max_slices);\n+\t\tif (rc != 0) {\n+\t\t\tCFA_TCAM_MGR_LOG_DIR_TYPE(ERR,\n+\t\t\t\t\t\t  dir, type,\n+\t\t\t\t\t\t \"Failed to free entry ID %d at\"\n+\t\t\t\t\t\t \" row %d, slice %d for sess_idx %d. rc: %d.\\n\",\n+\t\t\t\t\t\t  gparms.id,\n+\t\t\t\t\t\t  source_row_index,\n+\t\t\t\t\t\t  entry->slice,\n+\t\t\t\t\t\t  sess_idx,\n+\t\t\t\t\t\t  -rc);\n+\t\t}\n+\t}\n+\n+\tROW_ENTRY_SET(dest_row, dest_row_slice);\n+\tdest_row->entries[dest_row_slice] = entry_id;\n+\tROW_ENTRY_CLEAR(source_row, entry->slice);\n+\tentry->row   = dest_row_index;\n+\tentry->slice = dest_row_slice;\n+\n+\treturn 0;\n+}\n+\n+static int\n+cfa_tcam_mgr_row_move(int sess_idx, struct cfa_tcam_mgr_context *context,\n+\t\t      enum tf_dir dir, enum cfa_tcam_mgr_tbl_type type,\n+\t\t      struct cfa_tcam_mgr_table_data *table_data,\n+\t\t      int dest_row_index,\n+\t\t      struct cfa_tcam_mgr_table_rows_0 *dest_row,\n+\t\t      int source_row_index,\n+\t\t      struct cfa_tcam_mgr_table_rows_0 *source_row)\n+{\n+\tstruct cfa_tcam_mgr_free_parms fparms = { 0 };\n+\tint j, rc;\n+\n+\tdest_row->priority   = source_row->priority;\n+\tdest_row->entry_size = source_row->entry_size;\n+\tdest_row->entry_inuse = 0;\n+\n+\tfparms.dir\t  = dir;\n+\tfparms.type\t  = type;\n+\tfparms.hcapi_type = table_data->hcapi_type;\n+\n+\tfor (j = 0;\n+\t     j < (table_data->max_slices / source_row->entry_size);\n+\t     j++) {\n+\t\tif (ROW_ENTRY_INUSE(source_row, j)) {\n+\t\t\tcfa_tcam_mgr_entry_move(sess_idx, context, dir, type,\n+\t\t\t\t\t\tsource_row->entries[j],\n+\t\t\t\t\t\ttable_data,\n+\t\t\t\t\t\tdest_row_index, j, dest_row,\n+\t\t\t\t\t\tsource_row_index, source_row,\n+\t\t\t\t\t\ttrue);\n+\t\t} else {\n+\t\t\t/* Slice not in use, write an empty slice. */\n+\t\t\trc = cfa_tcam_mgr_entry_free_msg(sess_idx, context, &fparms,\n+\t\t\t\t\t\t\tdest_row_index,\n+\t\t\t\t\t\t\tj *\n+\t\t\t\t\t\t\tdest_row->entry_size,\n+\t\t\t\t\t\t\ttable_data->row_width /\n+\t\t\t\t\t\t\ttable_data->max_slices *\n+\t\t\t\t\t\t\tdest_row->entry_size,\n+\t\t\t\t\t\t\ttable_data->result_size,\n+\t\t\t\t\t\t\ttable_data->max_slices);\n+\t\t\tif (rc != 0)\n+\t\t\t\treturn rc;\n+\t\t}\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/* Install entry into in-memory tables, not into TCAM (yet). */\n+static void\n+cfa_tcam_mgr_row_entry_install(int sess_idx,\n+\t\t\t       struct cfa_tcam_mgr_table_rows_0 *row,\n+\t\t\t       struct cfa_tcam_mgr_alloc_parms *parms,\n+\t\t\t       struct cfa_tcam_mgr_entry_data *entry,\n+\t\t\t       uint16_t id,\n+\t\t\t       int key_slices,\n+\t\t\t       int row_index, int slice)\n+{\n+\tif (global_data_initialized[sess_idx] == 0) {\n+\t\tCFA_TCAM_MGR_LOG(INFO, \"PANIC: No TCAM data created for sess_idx %d\\n\",\n+\t\t\t\t sess_idx);\n+\t\treturn;\n+\t}\n+\n+\tif (slice == TF_TCAM_SLICE_INVALID) {\n+\t\tslice = 0;\n+\t\trow->entry_size = key_slices;\n+\t\trow->priority = parms->priority;\n+\t}\n+\n+\tROW_ENTRY_SET(row, slice);\n+\trow->entries[slice] = id;\n+\tentry->row = row_index;\n+\tentry->slice = slice;\n+}\n+\n+/* Finds an empty row that can be used and reserve for entry.  If necessary,\n+ * entries will be shuffled in order to make room.\n+ */\n+static struct cfa_tcam_mgr_table_rows_0 *\n+cfa_tcam_mgr_empty_row_alloc(int sess_idx, struct cfa_tcam_mgr_context *context,\n+\t\t\t     struct cfa_tcam_mgr_alloc_parms *parms,\n+\t\t\t     struct cfa_tcam_mgr_entry_data *entry,\n+\t\t\t     uint16_t id,\n+\t\t\t     int key_slices)\n+{\n+\tstruct cfa_tcam_mgr_table_rows_0 *tcam_rows;\n+\tstruct cfa_tcam_mgr_table_rows_0 *from_row;\n+\tstruct cfa_tcam_mgr_table_rows_0 *to_row;\n+\tstruct cfa_tcam_mgr_table_rows_0 *row;\n+\tstruct cfa_tcam_mgr_table_data *table_data;\n+\tint i, max_slices, row_size;\n+\tint to_row_idx, from_row_idx, slice, start_row, end_row;\n+\tint empty_row = -1;\n+\tint target_row = -1;\n+\n+\ttable_data = &cfa_tcam_mgr_tables[sess_idx][parms->dir][parms->type];\n+\n+\tstart_row  = table_data->start_row;\n+\tend_row\t   = table_data->end_row;\n+\tmax_slices = table_data->max_slices;\n+\ttcam_rows  = table_data->tcam_rows;\n+\n+\trow_size   = cfa_tcam_mgr_row_size_get(sess_idx, parms->dir, parms->type);\n+\n+\t/*\n+\t * First check for partially used entries, but only if the key needs\n+\t * fewer slices than there are in a row.\n+\t */\n+\tif (key_slices < max_slices) {\n+\t\tfor (i = start_row; i <= end_row; i++) {\n+\t\t\trow = cfa_tcam_mgr_row_ptr_get(tcam_rows, i, row_size);\n+\t\t\tif (!ROW_INUSE(row))\n+\t\t\t\tcontinue;\n+\t\t\tif (row->priority < parms->priority)\n+\t\t\t\tbreak;\n+\t\t\tif (row->priority > parms->priority)\n+\t\t\t\tcontinue;\n+\t\t\tslice = cfa_tcam_mgr_row_is_entry_free(row,\n+\t\t\t\t\t\t\t       max_slices,\n+\t\t\t\t\t\t\t       key_slices);\n+\t\t\tif (slice >= 0) {\n+\t\t\t\tcfa_tcam_mgr_row_entry_install(sess_idx, row, parms,\n+\t\t\t\t\t\t\t       entry, id,\n+\t\t\t\t\t\t\t       key_slices,\n+\t\t\t\t\t\t\t       i, slice);\n+\t\t\t\treturn row;\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\t/* No partially used rows available.  Find an empty row, if any. */\n+\n+\t/*\n+\t * All max priority entries are placed in the beginning of the TCAM.  It\n+\t * should not be necessary to shuffle any of these entries.  All other\n+\t * priorities are placed from the end of the TCAM and may require\n+\t * shuffling.\n+\t */\n+\tif (parms->priority == TF_TCAM_PRIORITY_MAX) {\n+\t\t/* Handle max priority first. */\n+\t\tfor (i = start_row; i <= end_row; i++) {\n+\t\t\trow = cfa_tcam_mgr_row_ptr_get(tcam_rows, i, row_size);\n+\t\t\tif (!ROW_INUSE(row)) {\n+\t\t\t\tcfa_tcam_mgr_row_entry_install(sess_idx,\n+\t\t\t\t\t\t\t       row, parms,\n+\t\t\t\t\t\t\t       entry,\n+\t\t\t\t\t\t\t       id, key_slices,\n+\t\t\t\t\t\t\t       i,\n+\t\t\t\t\t\t\t TF_TCAM_SLICE_INVALID);\n+\t\t\t\treturn row;\n+\t\t\t}\n+\t\t\tif (row->priority < parms->priority) {\n+\t\t\t\t/*\n+\t\t\t\t * No free entries before priority change, table\n+\t\t\t\t * is full.\n+\t\t\t\t */\n+\t\t\t\treturn NULL;\n+\t\t\t}\n+\t\t}\n+\t\t/* No free entries found, table is full. */\n+\t\treturn NULL;\n+\t}\n+\n+\t/* Use the highest available entry */\n+\tfor (i = end_row; i >= start_row; i--) {\n+\t\trow = cfa_tcam_mgr_row_ptr_get(tcam_rows, i, row_size);\n+\t\tif (!ROW_INUSE(row)) {\n+\t\t\tempty_row = i;\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tif (row->priority > parms->priority &&\n+\t\t    target_row < 0)\n+\t\t\ttarget_row = i;\n+\t}\n+\n+\tif (empty_row < 0) {\n+\t\t/* No free entries found, table is full. */\n+\t\treturn NULL;\n+\t}\n+\n+\tif (target_row < 0) {\n+\t\t/*\n+\t\t * Did not find a row with higher priority before unused row so\n+\t\t * just install new entry in empty_row.\n+\t\t */\n+\t\trow = cfa_tcam_mgr_row_ptr_get(tcam_rows, empty_row, row_size);\n+\t\tcfa_tcam_mgr_row_entry_install(sess_idx, row, parms, entry, id,\n+\t\t\t\t\t       key_slices, empty_row,\n+\t\t\t\t\t       TF_TCAM_SLICE_INVALID);\n+\t\treturn row;\n+\t}\n+\n+\tto_row_idx = empty_row;\n+\tto_row = cfa_tcam_mgr_row_ptr_get(tcam_rows, to_row_idx, row_size);\n+\twhile (to_row_idx < target_row) {\n+\t\tfrom_row_idx = to_row_idx + 1;\n+\t\tfrom_row = cfa_tcam_mgr_row_ptr_get(tcam_rows, from_row_idx,\n+\t\t\t\t\t\t    row_size);\n+\t\t/*\n+\t\t * Find the highest row with the same priority as the initial\n+\t\t * source row (from_row).  It's only necessary to copy one row\n+\t\t * of each priority.\n+\t\t */\n+\t\tfor (i = from_row_idx + 1; i <= target_row; i++) {\n+\t\t\trow = cfa_tcam_mgr_row_ptr_get(tcam_rows, i, row_size);\n+\t\t\tif (row->priority != from_row->priority)\n+\t\t\t\tbreak;\n+\t\t\tfrom_row_idx = i;\n+\t\t\tfrom_row = row;\n+\t\t}\n+\t\tcfa_tcam_mgr_row_move(sess_idx, context, parms->dir, parms->type,\n+\t\t\t\t      table_data, to_row_idx, to_row,\n+\t\t\t\t      from_row_idx, from_row);\n+\t\tto_row = from_row;\n+\t\tto_row_idx = from_row_idx;\n+\t}\n+\tto_row = cfa_tcam_mgr_row_ptr_get(tcam_rows, target_row, row_size);\n+\tmemset(to_row, 0, row_size);\n+\tcfa_tcam_mgr_row_entry_install(sess_idx, to_row, parms, entry, id,\n+\t\t\t\t       key_slices, target_row,\n+\t\t\t\t       TF_TCAM_SLICE_INVALID);\n+\n+\treturn row;\n+}\n+\n+/*\n+ * This function will combine rows when possible to result in the fewest rows\n+ * used necessary for the entries that are installed.\n+ */\n+static void\n+cfa_tcam_mgr_rows_combine(int sess_idx, struct cfa_tcam_mgr_context *context,\n+\t\t\t  struct cfa_tcam_mgr_free_parms *parms,\n+\t\t\t  struct cfa_tcam_mgr_table_data *table_data,\n+\t\t\t  int changed_row_index)\n+{\n+\tstruct cfa_tcam_mgr_table_rows_0 *from_row = NULL;\n+\tstruct cfa_tcam_mgr_table_rows_0 *to_row;\n+\tstruct cfa_tcam_mgr_table_rows_0 *tcam_rows;\n+\tint  i, j, row_size;\n+\tint  to_row_idx, from_row_idx, start_row, end_row, max_slices;\n+\tbool entry_moved = false;\n+\n+\tstart_row  = table_data->start_row;\n+\tend_row\t   = table_data->end_row;\n+\tmax_slices = table_data->max_slices;\n+\ttcam_rows  = table_data->tcam_rows;\n+\n+\trow_size   = cfa_tcam_mgr_row_size_get(sess_idx, parms->dir, parms->type);\n+\n+\tfrom_row_idx = changed_row_index;\n+\tfrom_row = cfa_tcam_mgr_row_ptr_get(tcam_rows, from_row_idx, row_size);\n+\n+\tif (ROW_INUSE(from_row)) {\n+\t\t/*\n+\t\t * Row is still in partial use.  See if remaining entry(s) can\n+\t\t * be moved to free up a row.\n+\t\t */\n+\t\tfor (i = 0; i < (max_slices / from_row->entry_size); i++) {\n+\t\t\tif (!ROW_ENTRY_INUSE(from_row, i))\n+\t\t\t\tcontinue;\n+\t\t\tfor (to_row_idx = end_row;\n+\t\t\t     to_row_idx >= start_row;\n+\t\t\t     to_row_idx--) {\n+\t\t\t\tto_row = cfa_tcam_mgr_row_ptr_get(tcam_rows,\n+\t\t\t\t\t\t\t\t  to_row_idx,\n+\t\t\t\t\t\t\t\t  row_size);\n+\t\t\t\tif (!ROW_INUSE(to_row))\n+\t\t\t\t\tcontinue;\n+\t\t\t\tif (to_row->priority > from_row->priority)\n+\t\t\t\t\tbreak;\n+\t\t\t\tif (to_row->priority != from_row->priority)\n+\t\t\t\t\tcontinue;\n+\t\t\t\tif (to_row->entry_size != from_row->entry_size)\n+\t\t\t\t\tcontinue;\n+\t\t\t\tif (to_row_idx == changed_row_index)\n+\t\t\t\t\tcontinue;\n+\t\t\t\tfor (j = 0;\n+\t\t\t\t     j < (max_slices / to_row->entry_size);\n+\t\t\t\t     j++) {\n+\t\t\t\t\tif (!ROW_ENTRY_INUSE(to_row, j)) {\n+\t\t\t\t\t\tcfa_tcam_mgr_entry_move\n+\t\t\t\t\t\t\t(sess_idx,\n+\t\t\t\t\t\t\t context,\n+\t\t\t\t\t\t\t parms->dir,\n+\t\t\t\t\t\t\t parms->type,\n+\t\t\t\t\t\t\t from_row->entries[i],\n+\t\t\t\t\t\t\t table_data,\n+\t\t\t\t\t\t\t to_row_idx,\n+\t\t\t\t\t\t\t -1, to_row,\n+\t\t\t\t\t\t\t from_row_idx,\n+\t\t\t\t\t\t\t from_row,\n+\t\t\t\t\t\t\t true);\n+\t\t\t\t\t\tentry_moved = true;\n+\t\t\t\t\t\tbreak;\n+\t\t\t\t\t}\n+\t\t\t\t}\n+\t\t\t\tif (entry_moved)\n+\t\t\t\t\tbreak;\n+\t\t\t}\n+\t\t\tif (ROW_INUSE(from_row))\n+\t\t\t\tentry_moved = false;\n+\t\t\telse\n+\t\t\t\tbreak;\n+\t\t}\n+\t}\n+}\n+\n+/*\n+ * This function will ensure that all rows, except those of the highest\n+ * priority, at the end of the table.  When this function is finished, all the\n+ * empty rows should be between the highest priority rows at the beginning of\n+ * the table and the rest of the rows with lower priorities.\n+ */\n+/*\n+ * Will need to free the row left newly empty as a result of moving.\n+ *\n+ * Return row to free to caller.  If new_row_to_free < 0, then no new row to\n+ * free.\n+ */\n+static void\n+cfa_tcam_mgr_rows_compact(int sess_idx, struct cfa_tcam_mgr_context *context,\n+\t\t\t  struct cfa_tcam_mgr_free_parms *parms,\n+\t\t\t  struct cfa_tcam_mgr_table_data *table_data,\n+\t\t\t  int *new_row_to_free,\n+\t\t\t  int changed_row_index)\n+{\n+\tstruct cfa_tcam_mgr_table_rows_0 *from_row = NULL;\n+\tstruct cfa_tcam_mgr_table_rows_0 *to_row;\n+\tstruct cfa_tcam_mgr_table_rows_0 *row;\n+\tstruct cfa_tcam_mgr_table_rows_0 *tcam_rows;\n+\tint  i, row_size, priority;\n+\tint  to_row_idx = 0, from_row_idx = 0, start_row = 0, end_row = 0;\n+\n+\t*new_row_to_free = -1;\n+\n+\tstart_row  = table_data->start_row;\n+\tend_row\t   = table_data->end_row;\n+\ttcam_rows  = table_data->tcam_rows;\n+\n+\trow_size   = cfa_tcam_mgr_row_size_get(sess_idx, parms->dir, parms->type);\n+\n+\t/*\n+\t * The row is no longer in use, so see if rows need to be moved in order\n+\t * to not leave any gaps.\n+\t */\n+\tto_row_idx = changed_row_index;\n+\tto_row = cfa_tcam_mgr_row_ptr_get(tcam_rows, to_row_idx, row_size);\n+\n+\tpriority = to_row->priority;\n+\tif (priority == TF_TCAM_PRIORITY_MAX) {\n+\t\tif (changed_row_index == end_row)\n+\t\t\t/*\n+\t\t\t * Nothing to move - the last row in the TCAM is being\n+\t\t\t * deleted.\n+\t\t\t */\n+\t\t\treturn;\n+\t\tfor (i = changed_row_index + 1; i <= end_row; i++) {\n+\t\t\trow = cfa_tcam_mgr_row_ptr_get(tcam_rows, i, row_size);\n+\t\t\tif (!ROW_INUSE(row))\n+\t\t\t\tbreak;\n+\n+\t\t\tif (row->priority < priority)\n+\t\t\t\tbreak;\n+\n+\t\t\tfrom_row = row;\n+\t\t\tfrom_row_idx = i;\n+\t\t}\n+\t} else {\n+\t\tif (changed_row_index == start_row)\n+\t\t\t/*\n+\t\t\t * Nothing to move - the first row in the TCAM is being\n+\t\t\t * deleted.\n+\t\t\t */\n+\t\t\treturn;\n+\t\tfor (i = changed_row_index - 1; i >= start_row; i--) {\n+\t\t\trow = cfa_tcam_mgr_row_ptr_get(tcam_rows, i, row_size);\n+\t\t\tif (!ROW_INUSE(row))\n+\t\t\t\tbreak;\n+\n+\t\t\tif (row->priority > priority) {\n+\t\t\t\t/* Don't move the highest priority rows. */\n+\t\t\t\tif (row->priority == TF_TCAM_PRIORITY_MAX)\n+\t\t\t\t\tbreak;\n+\t\t\t\t/*\n+\t\t\t\t * If from_row is NULL, that means that there\n+\t\t\t\t * were no rows of the deleted priority.\n+\t\t\t\t * Nothing to move yet.\n+\t\t\t\t *\n+\t\t\t\t * If from_row is not NULL, then it is the last\n+\t\t\t\t * row with the same priority and must be moved\n+\t\t\t\t * to fill the newly empty (by free or by move)\n+\t\t\t\t * row.\n+\t\t\t\t */\n+\t\t\t\tif (from_row != NULL) {\n+\t\t\t\t\tcfa_tcam_mgr_row_move(sess_idx, context,\n+\t\t\t\t\t\t\t      parms->dir,\n+\t\t\t\t\t\t\t      parms->type,\n+\t\t\t\t\t\t\t      table_data,\n+\t\t\t\t\t\t\t     to_row_idx, to_row,\n+\t\t\t\t\t\t\t      from_row_idx,\n+\t\t\t\t\t\t\t      from_row);\n+\t\t\t\t\t*new_row_to_free = from_row_idx;\n+\t\t\t\t\tto_row\t   = from_row;\n+\t\t\t\t\tto_row_idx = from_row_idx;\n+\t\t\t\t}\n+\n+\t\t\t\tpriority = row->priority;\n+\t\t\t}\n+\t\t\tfrom_row = row;\n+\t\t\tfrom_row_idx = i;\n+\t\t}\n+\t}\n+\n+\tif (from_row != NULL) {\n+\t\tcfa_tcam_mgr_row_move(sess_idx, context, parms->dir, parms->type,\n+\t\t\t\t      table_data,\n+\t\t\t\t      to_row_idx, to_row,\n+\t\t\t\t      from_row_idx, from_row);\n+\t\t*new_row_to_free = from_row_idx;\n+\t}\n+}\n+\n+/*\n+ * This function is to set table limits for the logical TCAM tables.\n+ */\n+static int\n+cfa_tcam_mgr_table_limits_set(int sess_idx, struct cfa_tcam_mgr_init_parms *parms)\n+{\n+\tstruct cfa_tcam_mgr_table_data *table_data;\n+\tunsigned int dir, type;\n+\tint start, stride;\n+\n+\tif (parms == NULL)\n+\t\treturn 0;\n+\n+\tfor (dir = 0; dir < ARRAY_SIZE(cfa_tcam_mgr_tables[sess_idx]); dir++)\n+\t\tfor (type = 0;\n+\t\t     type < ARRAY_SIZE(cfa_tcam_mgr_tables[sess_idx][dir]);\n+\t\t     type++) {\n+\t\t\ttable_data = &cfa_tcam_mgr_tables[sess_idx][dir][type];\n+\t\t\t/*\n+\t\t\t * If num_rows is zero, then TCAM Manager did not\n+\t\t\t * allocate any row storage for that table so cannot\n+\t\t\t * manage it.\n+\t\t\t */\n+\t\t\tif (table_data->num_rows == 0)\n+\t\t\t\tcontinue;\n+\t\t\tstart  = parms->resc[dir][type].start;\n+\t\t\tstride = parms->resc[dir][type].stride;\n+\t\t\tif (start % table_data->max_slices > 0) {\n+\t\t\t\tCFA_TCAM_MGR_LOG_DIR_TYPE(ERR, dir, type,\n+\t\t\t\t\t\t\t  \"Start of resources (%d) for table (%d) \"\n+\t\t\t\t\t\t\t  \"does not begin on row boundary.\\n\",\n+\t\t\t\t\t\t\t  start, sess_idx);\n+\t\t\t\tCFA_TCAM_MGR_LOG_DIR(ERR, dir,\n+\t\t\t\t\t\t     \"Start is %d, number of slices \"\n+\t\t\t\t\t\t     \"is %d.\\n\",\n+\t\t\t\t\t\t     start,\n+\t\t\t\t\t\t     table_data->max_slices);\n+\t\t\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\n+\t\t\t}\n+\t\t\tif (stride % table_data->max_slices > 0) {\n+\t\t\t\tCFA_TCAM_MGR_LOG_DIR_TYPE(ERR, dir, type,\n+\t\t\t\t\t\t\t  \"Stride of resources (%d) for table (%d)\"\n+\t\t\t\t\t\t\t  \" does not end on row boundary.\\n\",\n+\t\t\t\t\t\t\t  stride, sess_idx);\n+\t\t\t\tCFA_TCAM_MGR_LOG_DIR(ERR, dir,\n+\t\t\t\t\t\t     \"Stride is %d, number of \"\n+\t\t\t\t\t\t     \"slices is %d.\\n\",\n+\t\t\t\t\t\t     stride,\n+\t\t\t\t\t\t     table_data->max_slices);\n+\t\t\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\n+\t\t\t}\n+\t\t\tif (stride == 0) {\n+\t\t\t\ttable_data->start_row\t= 0;\n+\t\t\t\ttable_data->end_row\t= 0;\n+\t\t\t\ttable_data->max_entries = 0;\n+\t\t\t} else {\n+\t\t\t\ttable_data->start_row = start /\n+\t\t\t\t\ttable_data->max_slices;\n+\t\t\t\ttable_data->end_row = table_data->start_row +\n+\t\t\t\t\t(stride / table_data->max_slices) - 1;\n+\t\t\t\ttable_data->max_entries =\n+\t\t\t\t\ttable_data->max_slices *\n+\t\t\t\t\t(table_data->end_row -\n+\t\t\t\t\t table_data->start_row + 1);\n+\t\t\t}\n+\t\t}\n+\n+\treturn 0;\n+}\n+\n+int\n+cfa_tcam_mgr_init(int sess_idx, enum cfa_tcam_mgr_device_type type,\n+\t\t  struct cfa_tcam_mgr_init_parms *parms)\n+{\n+\tstruct cfa_tcam_mgr_table_data *table_data;\n+\tunsigned int dir, tbl_type;\n+\tint rc;\n+\n+\tswitch (type) {\n+\tcase CFA_TCAM_MGR_DEVICE_TYPE_P4:\n+\tcase CFA_TCAM_MGR_DEVICE_TYPE_SR:\n+\t\trc = cfa_tcam_mgr_init_p4(sess_idx, &entry_data[sess_idx]);\n+\t\tbreak;\n+\tcase CFA_TCAM_MGR_DEVICE_TYPE_P5:\n+\t\trc = cfa_tcam_mgr_init_p58(sess_idx, &entry_data[sess_idx]);\n+\t\tbreak;\n+\tdefault:\n+\t\tCFA_TCAM_MGR_LOG(ERR, \"No such device %d for sess_idx %d\\n\",\n+\t\t\t\t type, sess_idx);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(NODEV);\n+\t}\n+\tif (rc < 0)\n+\t\treturn rc;\n+\n+\trc = cfa_tcam_mgr_table_limits_set(sess_idx, parms);\n+\tif (rc < 0)\n+\t\treturn rc;\n+\n+\t/* Now calculate the max entries per table and global max entries based\n+\t * on the updated table limits.\n+\t */\n+\tfor (dir = 0; dir < ARRAY_SIZE(cfa_tcam_mgr_tables[sess_idx]); dir++)\n+\t\tfor (tbl_type = 0;\n+\t\t     tbl_type < ARRAY_SIZE(cfa_tcam_mgr_tables[sess_idx][dir]);\n+\t\t     tbl_type++) {\n+\t\t\ttable_data = &cfa_tcam_mgr_tables[sess_idx][dir][tbl_type];\n+\t\t\t/*\n+\t\t\t * If num_rows is zero, then TCAM Manager did not\n+\t\t\t * allocate any row storage for that table so cannot\n+\t\t\t * manage it.\n+\t\t\t */\n+\t\t\tif (table_data->num_rows == 0) {\n+\t\t\t\ttable_data->start_row = 0;\n+\t\t\t\ttable_data->end_row = 0;\n+\t\t\t\ttable_data->max_entries = 0;\n+\t\t\t} else if (table_data->end_row >=\n+\t\t\t\t   table_data->num_rows) {\n+\t\t\t\tCFA_TCAM_MGR_LOG_DIR_TYPE(EMERG, dir, tbl_type,\n+\t\t\t\t\t\t\t  \"End row is out of \"\n+\t\t\t\t\t\t\t  \"range (%d >= %d) for sess_idx %d\\n\",\n+\t\t\t\t\t\t\t  table_data->end_row,\n+\t\t\t\t\t\t\t  table_data->num_rows,\n+\t\t\t\t\t\t\t  sess_idx);\n+\t\t\t\treturn -CFA_TCAM_MGR_ERR_CODE(FAULT);\n+\t\t\t} else if (table_data->max_entries == 0 &&\n+\t\t\t\t   table_data->start_row == 0 &&\n+\t\t\t\t   table_data->end_row == 0) {\n+\t\t\t\t/* Nothing to do */\n+\t\t\t} else {\n+\t\t\t\ttable_data->max_entries =\n+\t\t\t\t\ttable_data->max_slices *\n+\t\t\t\t\t(table_data->end_row -\n+\t\t\t\t\t table_data->start_row + 1);\n+\t\t\t}\n+\t\t\tcfa_tcam_mgr_max_entries[sess_idx] += table_data->max_entries;\n+\t\t}\n+\n+\trc = cfa_tcam_mgr_hwops_init(type);\n+\tif (rc < 0)\n+\t\treturn rc;\n+\n+\trc = cfa_tcam_mgr_session_init(sess_idx, type);\n+\tif (rc < 0)\n+\t\treturn rc;\n+\n+\tglobal_data_initialized[sess_idx] = 1;\n+\n+\tif (parms != NULL)\n+\t\tparms->max_entries = cfa_tcam_mgr_max_entries[sess_idx];\n+\n+\tCFA_TCAM_MGR_LOG(INFO, \"Global TCAM table initialized for sess_idx %d.\\n\",\n+\t\t\t sess_idx);\n+\n+\treturn 0;\n+}\n+\n+int\n+cfa_tcam_mgr_qcaps(struct cfa_tcam_mgr_context *context __rte_unused,\n+\t\t   struct cfa_tcam_mgr_qcaps_parms *parms)\n+{\n+\tunsigned int type;\n+\tint rc, sess_idx;\n+\tuint32_t session_id;\n+\n+\tCFA_TCAM_MGR_CHECK_PARMS2(context, parms);\n+\n+\trc = cfa_tcam_mgr_get_session_from_context(context, &session_id);\n+\tif (rc < 0)\n+\t\treturn rc;\n+\n+\tsess_idx = cfa_tcam_mgr_session_find(session_id);\n+\tif (sess_idx < 0) {\n+\t\tCFA_TCAM_MGR_LOG_0(ERR, \"Session not found.\\n\");\n+\t\treturn sess_idx;\n+\t}\n+\n+\tif (global_data_initialized[sess_idx] == 0) {\n+\t\tCFA_TCAM_MGR_LOG(ERR, \"PANIC: No TCAM data created for sess_idx %d\\n\",\n+\t\t\t\t sess_idx);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(PERM);\n+\t}\n+\n+\t/*\n+\t * This code will indicate if TCAM Manager is managing a logical TCAM\n+\t * table or not.  If not, then the physical TCAM will have to be\n+\t * accessed using the traditional methods.\n+\t */\n+\tparms->rx_tcam_supported = 0;\n+\tparms->tx_tcam_supported = 0;\n+\tfor (type = 0; type < CFA_TCAM_MGR_TBL_TYPE_MAX; type++) {\n+\t\tif (cfa_tcam_mgr_tables[sess_idx][TF_DIR_RX][type].max_entries > 0 &&\n+\t\t    cfa_tcam_mgr_tables[sess_idx][TF_DIR_RX][type].hcapi_type > 0)\n+\t\t\tparms->rx_tcam_supported |= 1 << cfa_tcam_mgr_get_phys_table_type(type);\n+\t\tif (cfa_tcam_mgr_tables[sess_idx][TF_DIR_TX][type].max_entries > 0 &&\n+\t\t    cfa_tcam_mgr_tables[sess_idx][TF_DIR_TX][type].hcapi_type > 0)\n+\t\t\tparms->tx_tcam_supported |= 1 << cfa_tcam_mgr_get_phys_table_type(type);\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/*\n+ * Manipulate the tables to split the WC TCAM into HIGH and LOW ranges\n+ * and also update the sizes in the tcam count array\n+ */\n+static int\n+cfa_tcam_mgr_shared_wc_bind(uint32_t sess_idx, bool dual_ha_app,\n+\t\t\t    uint16_t tcam_cnt[][CFA_TCAM_MGR_TBL_TYPE_MAX])\n+{\n+\tuint16_t start_row, end_row, max_entries, slices;\n+\tuint16_t num_pools = dual_ha_app ? 4 : 2;\n+\tenum tf_dir dir;\n+\tint rc;\n+\n+\tfor (dir = 0; dir < TF_DIR_MAX; dir++) {\n+\t\trc = cfa_tcam_mgr_tables_get(sess_idx, dir,\n+\t\t\t\t\t     CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_APPS,\n+\t\t\t\t\t     &start_row, &end_row, &max_entries, &slices);\n+\t\tif (rc)\n+\t\t\treturn rc;\n+\t\tif (max_entries) {\n+\t\t\trc = cfa_tcam_mgr_tables_set(sess_idx, dir,\n+\t\t\t\t\t\t     CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_APPS,\n+\t\t\t\t\t\t     start_row,\n+\t\t\t\t\t\t     start_row +\n+\t\t\t\t\t\t     ((max_entries / slices) / num_pools) - 1,\n+\t\t\t\t\t\t     max_entries / num_pools);\n+\t\t\tif (rc)\n+\t\t\t\treturn rc;\n+\t\t\trc = cfa_tcam_mgr_tables_set(sess_idx, dir,\n+\t\t\t\t\t\t     CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_APPS,\n+\t\t\t\t\t\t     start_row +\n+\t\t\t\t\t\t     ((max_entries / slices) / num_pools),\n+\t\t\t\t\t\t     start_row +\n+\t\t\t\t\t\t     (max_entries / slices) - 1,\n+\t\t\t\t\t\t     max_entries / num_pools);\n+\t\t\tif (rc)\n+\t\t\t\treturn rc;\n+\t\t\trc = cfa_tcam_mgr_tables_set(sess_idx, dir,\n+\t\t\t\t\t\t     CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_APPS,\n+\t\t\t\t\t\t     0, 0, 0);\n+\t\t\tif (rc)\n+\t\t\t\treturn rc;\n+\t\t\ttcam_cnt[dir][CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_APPS] =\n+\t\t\t\tmax_entries / num_pools;\n+\t\t\ttcam_cnt[dir][CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_APPS] =\n+\t\t\t\tmax_entries / num_pools;\n+\t\t\ttcam_cnt[dir][CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_APPS] = 0;\n+\t\t}\n+\t}\n+\n+\treturn 0;\n+}\n+\n+int\n+cfa_tcam_mgr_bind(struct cfa_tcam_mgr_context *context,\n+\t\t  struct cfa_tcam_mgr_cfg_parms *parms)\n+{\n+\tstruct cfa_tcam_mgr_table_data   *table_data;\n+\tstruct tf_dev_info *dev;\n+\tunsigned int dir;\n+\tint rc, sess_idx;\n+\tuint32_t session_id;\n+\tstruct tf_session *tfs;\n+\tunsigned int type;\n+\tint prev_max_entries;\n+\tint start, stride;\n+\tenum cfa_tcam_mgr_device_type device_type;\n+\n+\tCFA_TCAM_MGR_CHECK_PARMS2(context, parms);\n+\n+\t/* Retrieve the session information */\n+\trc = tf_session_get_session_internal(context->tfp, &tfs);\n+\tif (rc)\n+\t\treturn rc;\n+\n+\t/* Retrieve the device information */\n+\trc = tf_session_get_device(tfs, &dev);\n+\tif (rc)\n+\t\treturn rc;\n+\n+\tswitch (dev->type) {\n+\tcase TF_DEVICE_TYPE_P4:\n+\t\tdevice_type = CFA_TCAM_MGR_DEVICE_TYPE_P4;\n+\t\tbreak;\n+\tcase TF_DEVICE_TYPE_SR:\n+\t\tdevice_type = CFA_TCAM_MGR_DEVICE_TYPE_SR;\n+\t\tbreak;\n+\tcase TF_DEVICE_TYPE_P5:\n+\t\tdevice_type = CFA_TCAM_MGR_DEVICE_TYPE_P5;\n+\t\tbreak;\n+\tdefault:\n+\t\tCFA_TCAM_MGR_LOG(ERR, \"No such device %d\\n\", dev->type);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(NODEV);\n+\t}\n+\n+\trc = cfa_tcam_mgr_get_session_from_context(context, &session_id);\n+\tif (rc < 0)\n+\t\treturn rc;\n+\n+\tsess_idx = cfa_tcam_mgr_session_add(session_id);\n+\tif (sess_idx < 0)\n+\t\treturn sess_idx;\n+\n+\tif (global_data_initialized[sess_idx] == 0) {\n+\t\trc = cfa_tcam_mgr_init(sess_idx, device_type, NULL);\n+\t\tif (rc < 0)\n+\t\t\treturn rc;\n+\t}\n+\n+\tif (parms->num_elements != ARRAY_SIZE(cfa_tcam_mgr_tables[sess_idx][dir])) {\n+\t\tCFA_TCAM_MGR_LOG(ERR,\n+\t\t\t\t \"Session element count (%d) differs \"\n+\t\t\t\t \"from table count (%zu) for sess_idx %d.\\n\",\n+\t\t\t\t parms->num_elements,\n+\t\t\t\t ARRAY_SIZE(cfa_tcam_mgr_tables[sess_idx][dir]),\n+\t\t\t\t sess_idx);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\n+\t}\n+\n+\t/*\n+\t * Only managing one session. resv_res contains the resources allocated\n+\t * to this session by the resource manager.  Update the limits on TCAMs.\n+\t */\n+\tfor (dir = 0; dir < ARRAY_SIZE(cfa_tcam_mgr_tables[sess_idx]); dir++) {\n+\t\tfor (type = 0;\n+\t\t     type < ARRAY_SIZE(cfa_tcam_mgr_tables[sess_idx][dir]);\n+\t\t     type++) {\n+\t\t\ttable_data = &cfa_tcam_mgr_tables[sess_idx][dir][type];\n+\t\t\tprev_max_entries = table_data->max_entries;\n+\t\t\t/*\n+\t\t\t * In AFM logical tables, max_entries is initialized to\n+\t\t\t * zero.  These logical tables are not used when TCAM\n+\t\t\t * Manager is in the core so skip.\n+\t\t\t */\n+\t\t\tif (prev_max_entries == 0)\n+\t\t\t\tcontinue;\n+\t\t\tstart  = parms->resv_res[dir][type].start;\n+\t\t\tstride = parms->resv_res[dir][type].stride;\n+\t\t\tif (start % table_data->max_slices > 0) {\n+\t\t\t\tCFA_TCAM_MGR_LOG_DIR_TYPE(ERR, dir, type,\n+\t\t\t\t\t \"Start of resources (%d) for table(%d) \"\n+\t\t\t\t\t \"does not begin on row boundary.\\n\",\n+\t\t\t\t\t start, sess_idx);\n+\t\t\t\tCFA_TCAM_MGR_LOG_DIR(ERR, dir,\n+\t\t\t\t\t    \"Start is %d, number of slices \"\n+\t\t\t\t\t    \"is %d.\\n\",\n+\t\t\t\t\t    start,\n+\t\t\t\t\t    table_data->max_slices);\n+\t\t\t\t(void)cfa_tcam_mgr_session_free(session_id, context);\n+\t\t\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\n+\t\t\t}\n+\t\t\tif (stride % table_data->max_slices > 0) {\n+\t\t\t\tCFA_TCAM_MGR_LOG_DIR_TYPE(ERR, dir, type,\n+\t\t\t\t\t   \"Stride of resources (%d) for table(%d) \"\n+\t\t\t\t\t   \"does not end on row boundary.\\n\",\n+\t\t\t\t\t   stride, sess_idx);\n+\t\t\t\tCFA_TCAM_MGR_LOG_DIR(ERR, dir,\n+\t\t\t\t\t    \"Stride is %d, number of \"\n+\t\t\t\t\t    \"slices is %d.\\n\",\n+\t\t\t\t\t    stride,\n+\t\t\t\t\t    table_data->max_slices);\n+\t\t\t\t(void)cfa_tcam_mgr_session_free(session_id, context);\n+\t\t\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\n+\t\t\t}\n+\t\t\tif (stride == 0) {\n+\t\t\t\ttable_data->start_row\t= 0;\n+\t\t\t\ttable_data->end_row\t= 0;\n+\t\t\t\ttable_data->max_entries = 0;\n+\t\t\t} else {\n+\t\t\t\ttable_data->start_row = start /\n+\t\t\t\t\ttable_data->max_slices;\n+\t\t\t\ttable_data->end_row = table_data->start_row +\n+\t\t\t\t\t(stride / table_data->max_slices) - 1;\n+\t\t\t\ttable_data->max_entries =\n+\t\t\t\t\ttable_data->max_slices *\n+\t\t\t\t\t(table_data->end_row -\n+\t\t\t\t\t table_data->start_row + 1);\n+\t\t\t}\n+\t\t\tcfa_tcam_mgr_max_entries[sess_idx] += (table_data->max_entries -\n+\t\t\t\t\t\t     prev_max_entries);\n+\t\t}\n+\t}\n+\n+\tif (tf_session_is_shared_hotup_session(tfs)) {\n+\t\trc = cfa_tcam_mgr_shared_wc_bind(sess_idx, false, parms->tcam_cnt);\n+\t\tif (rc) {\n+\t\t\t(void)cfa_tcam_mgr_session_free(session_id, context);\n+\t\t\treturn rc;\n+\t\t}\n+\t}\n+\n+\trc = cfa_tcam_mgr_session_cfg(session_id, parms->tcam_cnt);\n+\tif (rc < 0) {\n+\t\t(void)cfa_tcam_mgr_session_free(session_id, context);\n+\t\treturn rc;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+int\n+cfa_tcam_mgr_unbind(struct cfa_tcam_mgr_context *context)\n+{\n+\tint rc, sess_idx;\n+\tuint32_t session_id;\n+\n+\tCFA_TCAM_MGR_CHECK_PARMS1(context);\n+\n+\trc = cfa_tcam_mgr_get_session_from_context(context, &session_id);\n+\tif (rc < 0)\n+\t\treturn rc;\n+\n+\tsess_idx = cfa_tcam_mgr_session_find(session_id);\n+\tif (sess_idx < 0) {\n+\t\tCFA_TCAM_MGR_LOG_0(ERR, \"Session not found.\\n\");\n+\t\treturn sess_idx;\n+\t}\n+\n+\tif (global_data_initialized[sess_idx] == 0) {\n+\t\tCFA_TCAM_MGR_LOG(INFO, \"PANIC: No TCAM data created for sess_idx %d\\n\",\n+\t\t\t\t sess_idx);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(PERM);\n+\t}\n+\n+\t(void)cfa_tcam_mgr_session_free(session_id, context);\n+\n+\tglobal_data_initialized[sess_idx] = 0;\n+\treturn 0;\n+}\n+\n+int\n+cfa_tcam_mgr_alloc(struct cfa_tcam_mgr_context *context,\n+\t\t   struct cfa_tcam_mgr_alloc_parms *parms)\n+{\n+\tstruct cfa_tcam_mgr_entry_data    entry;\n+\tstruct cfa_tcam_mgr_table_rows_0 *row;\n+\tstruct cfa_tcam_mgr_table_data   *table_data;\n+\tint dir, tbl_type;\n+\tint key_slices, rc, sess_idx;\n+\tint new_entry_id;\n+\tuint32_t session_id;\n+\n+\tCFA_TCAM_MGR_CHECK_PARMS2(context, parms);\n+\n+\tdir = parms->dir;\n+\ttbl_type = parms->type;\n+\n+\tif (dir >= TF_DIR_MAX) {\n+\t\tCFA_TCAM_MGR_LOG(ERR, \"Invalid direction: %d.\\n\", dir);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\n+\t}\n+\n+\tif (tbl_type >= CFA_TCAM_MGR_TBL_TYPE_MAX) {\n+\t\tCFA_TCAM_MGR_LOG_DIR(ERR, dir,\n+\t\t\t\t     \"Invalid table type: %d.\\n\",\n+\t\t\t\t     tbl_type);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\n+\t}\n+\n+#if TF_TCAM_PRIORITY_MAX < UINT16_MAX\n+\tif (parms->priority > TF_TCAM_PRIORITY_MAX) {\n+\t\tCFA_TCAM_MGR_LOG_DIR(ERR, dir,\n+\t\t\t\t     \"Priority (%u) out of range (%u -%u).\\n\",\n+\t\t\t\t     parms->priority,\n+\t\t\t\t     TF_TCAM_PRIORITY_MIN,\n+\t\t\t\t     TF_TCAM_PRIORITY_MAX);\n+\t}\n+#endif\n+\n+\t/* Check for session limits */\n+\trc = cfa_tcam_mgr_get_session_from_context(context, &session_id);\n+\tif (rc < 0)\n+\t\treturn rc;\n+\n+\tsess_idx = cfa_tcam_mgr_session_find(session_id);\n+\tif (sess_idx < 0) {\n+\t\tCFA_TCAM_MGR_LOG(ERR, \"Session 0x%08x not found.\\n\",\n+\t\t\t\t session_id);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(NODEV);\n+\t}\n+\n+\tif (global_data_initialized[sess_idx] == 0) {\n+\t\tCFA_TCAM_MGR_LOG(ERR, \"PANIC: No TCAM data created for sess_idx %d\\n\",\n+\t\t\t\t sess_idx);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(PERM);\n+\t}\n+\n+\ttable_data = &cfa_tcam_mgr_tables[sess_idx][dir][tbl_type];\n+\n+\tif (parms->key_size == 0 ||\n+\t    parms->key_size > table_data->row_width) {\n+\t\tCFA_TCAM_MGR_LOG_DIR(ERR, dir,\n+\t\t\t\t     \"Invalid key size:%d (range 1-%d) sess_idx %d.\\n\",\n+\t\t\t\t     parms->key_size,\n+\t\t\t\t     table_data->row_width,\n+\t\t\t\t     sess_idx);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\n+\t}\n+\n+\t/* Check global limits */\n+\tif (table_data->used_entries >=\n+\t    table_data->max_entries) {\n+\t\tCFA_TCAM_MGR_LOG_DIR_TYPE(ERR, dir, tbl_type,\n+\t\t\t\t\t    \"Table full sess_idx %d.\\n\",\n+\t\t\t\t\t    sess_idx);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(NOSPC);\n+\t}\n+\n+\t/* There is room, now increment counts and allocate an entry. */\n+\tnew_entry_id = cfa_tcam_mgr_session_entry_alloc(session_id,\n+\t\t\t\t\t\t\tparms->dir,\n+\t\t\t\t\t\t\tparms->type);\n+\tif (new_entry_id < 0)\n+\t\treturn new_entry_id;\n+\n+\tmemset(&entry, 0, sizeof(entry));\n+\tentry.ref_cnt++;\n+\n+\tkey_slices = cfa_tcam_mgr_get_num_slices(parms->key_size,\n+\t\t\t\t\t\t (table_data->row_width /\n+\t\t\t\t\t\t  table_data->max_slices));\n+\n+\trow = cfa_tcam_mgr_empty_row_alloc(sess_idx, context, parms, &entry,\n+\t\t\t\t\t   new_entry_id, key_slices);\n+\tif (row == NULL) {\n+\t\tCFA_TCAM_MGR_LOG_DIR_TYPE(ERR, parms->dir, parms->type,\n+\t\t\t\t\t    \"Table full (HW) sess_idx %d.\\n\",\n+\t\t\t\t\t    sess_idx);\n+\t\t(void)cfa_tcam_mgr_session_entry_free(session_id, new_entry_id,\n+\t\t\t\t\t\t      parms->dir, parms->type);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(NOSPC);\n+\t}\n+\n+\tmemcpy(&entry_data[sess_idx][new_entry_id],\n+\t       &entry,\n+\t       sizeof(entry_data[sess_idx][new_entry_id]));\n+\ttable_data->used_entries += 1;\n+\n+\tcfa_tcam_mgr_entry_insert(sess_idx, new_entry_id, &entry);\n+\n+\tparms->id = new_entry_id;\n+\n+\treturn 0;\n+}\n+\n+int\n+cfa_tcam_mgr_free(struct cfa_tcam_mgr_context *context,\n+\t\t  struct cfa_tcam_mgr_free_parms *parms)\n+{\n+\tstruct cfa_tcam_mgr_entry_data *entry;\n+\tstruct cfa_tcam_mgr_table_rows_0 *row;\n+\tstruct cfa_tcam_mgr_table_data *table_data;\n+\tint row_size, rc, sess_idx, new_row_to_free;\n+\tuint32_t session_id;\n+\tuint16_t id;\n+\n+\tCFA_TCAM_MGR_CHECK_PARMS2(context, parms);\n+\n+\trc = cfa_tcam_mgr_get_session_from_context(context, &session_id);\n+\tif (rc < 0)\n+\t\treturn rc;\n+\n+\tsess_idx = cfa_tcam_mgr_session_find(session_id);\n+\tif (sess_idx < 0) {\n+\t\tCFA_TCAM_MGR_LOG(ERR, \"Session 0x%08x not found.\\n\",\n+\t\t\t\t session_id);\n+\t\treturn sess_idx;\n+\t}\n+\n+\tif (global_data_initialized[sess_idx] == 0) {\n+\t\tCFA_TCAM_MGR_LOG(INFO, \"PANIC: No TCAM data created for sess_idx %d\\n\",\n+\t\t\t\t sess_idx);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(PERM);\n+\t}\n+\n+\tid = parms->id;\n+\tentry = cfa_tcam_mgr_entry_get(sess_idx, id);\n+\tif (entry == NULL) {\n+\t\tCFA_TCAM_MGR_LOG(INFO, \"Entry %d not found for sess_idx %d.\\n\",\n+\t\t\t\t id, sess_idx);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\n+\t}\n+\n+\tif (entry->ref_cnt == 0) {\n+\t\tCFA_TCAM_MGR_LOG(ERR, \"Entry %d not in use for sess_idx %d.\\n\",\n+\t\t\t\t id, sess_idx);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\n+\t}\n+\n+\t/*\n+\t * If the TCAM type is CFA_TCAM_MGR_TBL_TYPE_MAX, that implies that the\n+\t * caller does not know the table or direction of the entry and TCAM\n+\t * Manager must search the tables to find out which table has the entry\n+\t * installed.\n+\t *\n+\t * This would be the case if RM has informed TCAM Mgr that an entry must\n+\t * be freed.  Clients (sessions, AFM) should always know the type and\n+\t * direction of the table where an entry is installed.\n+\t */\n+\tif (parms->type == CFA_TCAM_MGR_TBL_TYPE_MAX) {\n+\t\t/* Need to search for the entry in the tables */\n+\t\trc = cfa_tcam_mgr_entry_find(sess_idx, id, &parms->dir, &parms->type);\n+\t\tif (rc < 0) {\n+\t\t\tCFA_TCAM_MGR_LOG(ERR, \"Entry %d not in tables for sess_idx %d.\\n\",\n+\t\t\t\t\t id, sess_idx);\n+\t\t\treturn rc;\n+\t\t}\n+\t}\n+\n+\ttable_data = &cfa_tcam_mgr_tables[sess_idx][parms->dir][parms->type];\n+\tparms->hcapi_type = table_data->hcapi_type;\n+\n+\trow_size = cfa_tcam_mgr_row_size_get(sess_idx, parms->dir, parms->type);\n+\n+\trow = cfa_tcam_mgr_row_ptr_get(table_data->tcam_rows, entry->row,\n+\t\t\t\t       row_size);\n+\n+\tentry->ref_cnt--;\n+\n+\t(void)cfa_tcam_mgr_session_entry_free(session_id, id,\n+\t\t\t\t\t      parms->dir, parms->type);\n+\n+\tif (entry->ref_cnt == 0) {\n+\t\tcfa_tcam_mgr_entry_free_msg(sess_idx, context, parms,\n+\t\t\t\t\t    entry->row,\n+\t\t\t\t\t    entry->slice * row->entry_size,\n+\t\t\t\t\t    table_data->row_width /\n+\t\t\t\t\t    table_data->max_slices *\n+\t\t\t\t\t    row->entry_size,\n+\t\t\t\t\t    table_data->result_size,\n+\t\t\t\t\t    table_data->max_slices);\n+\t\tROW_ENTRY_CLEAR(row, entry->slice);\n+\n+\t\tnew_row_to_free = entry->row;\n+\t\tcfa_tcam_mgr_rows_combine(sess_idx, context, parms, table_data,\n+\t\t\t\t\t  new_row_to_free);\n+\n+\t\tif (!ROW_INUSE(row)) {\n+\t\t\tcfa_tcam_mgr_rows_compact(sess_idx, context,\n+\t\t\t\t\t\t  parms, table_data,\n+\t\t\t\t\t\t  &new_row_to_free,\n+\t\t\t\t\t\t  new_row_to_free);\n+\t\t\tif (new_row_to_free >= 0)\n+\t\t\t\tcfa_tcam_mgr_entry_free_msg(sess_idx, context, parms,\n+\t\t\t\t\t\t   new_row_to_free, 0,\n+\t\t\t\t\t\t   table_data->row_width,\n+\t\t\t\t\t\t   table_data->result_size,\n+\t\t\t\t\t\t   table_data->max_slices);\n+\t\t}\n+\n+\t\tcfa_tcam_mgr_entry_delete(sess_idx, id);\n+\t\ttable_data->used_entries -= 1;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+int\n+cfa_tcam_mgr_set(struct cfa_tcam_mgr_context *context,\n+\t\t struct cfa_tcam_mgr_set_parms *parms)\n+{\n+\tstruct cfa_tcam_mgr_entry_data *entry;\n+\tstruct cfa_tcam_mgr_table_rows_0 *row;\n+\tstruct cfa_tcam_mgr_table_data *table_data;\n+\tint rc;\n+\tint row_size, sess_idx;\n+\tint entry_size_in_bytes;\n+\tuint32_t session_id;\n+\n+\tCFA_TCAM_MGR_CHECK_PARMS2(context, parms);\n+\n+\trc = cfa_tcam_mgr_get_session_from_context(context, &session_id);\n+\tif (rc < 0)\n+\t\treturn rc;\n+\n+\tsess_idx = cfa_tcam_mgr_session_find(session_id);\n+\tif (sess_idx < 0) {\n+\t\tCFA_TCAM_MGR_LOG(ERR, \"Session 0x%08x not found.\\n\",\n+\t\t\t\t session_id);\n+\t\treturn sess_idx;\n+\t}\n+\n+\tif (global_data_initialized[sess_idx] == 0) {\n+\t\tCFA_TCAM_MGR_LOG(ERR, \"PANIC: No TCAM data created for sess_idx %d\\n\",\n+\t\t\t\t sess_idx);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(PERM);\n+\t}\n+\n+\tentry = cfa_tcam_mgr_entry_get(sess_idx, parms->id);\n+\tif (entry == NULL) {\n+\t\tCFA_TCAM_MGR_LOG(ERR, \"Entry %d not found for sess_idx %d.\\n\",\n+\t\t\t\t parms->id, sess_idx);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\n+\t}\n+\n+\ttable_data = &cfa_tcam_mgr_tables[sess_idx][parms->dir][parms->type];\n+\tparms->hcapi_type = table_data->hcapi_type;\n+\n+\trow_size = cfa_tcam_mgr_row_size_get(sess_idx, parms->dir, parms->type);\n+\trow = cfa_tcam_mgr_row_ptr_get(table_data->tcam_rows, entry->row,\n+\t\t\t\t       row_size);\n+\n+\tentry_size_in_bytes = table_data->row_width /\n+\t\t\t      table_data->max_slices *\n+\t\t\t      row->entry_size;\n+\tif (parms->key_size != entry_size_in_bytes) {\n+\t\tCFA_TCAM_MGR_LOG(ERR,\n+\t\t\t\t\"Key size(%d) is different from entry \"\n+\t\t\t\t\"size(%d).\\n\",\n+\t\t\t\tparms->key_size,\n+\t\t\t\tentry_size_in_bytes);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\n+\t}\n+\n+\trc = cfa_tcam_mgr_entry_set_msg(sess_idx, context, parms,\n+\t\t\t\t\tentry->row,\n+\t\t\t\t\tentry->slice * row->entry_size,\n+\t\t\t\t\ttable_data->max_slices);\n+\tif (rc < 0) {\n+\t\tCFA_TCAM_MGR_LOG_0(ERR, \"Failed to set TCAM data.\\n\");\n+\t\treturn rc;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+int\n+cfa_tcam_mgr_get(struct cfa_tcam_mgr_context *context __rte_unused,\n+\t\t struct cfa_tcam_mgr_get_parms *parms)\n+{\n+\tstruct cfa_tcam_mgr_entry_data *entry;\n+\tstruct cfa_tcam_mgr_table_rows_0 *row;\n+\tstruct cfa_tcam_mgr_table_data *table_data;\n+\tint rc;\n+\tint row_size, sess_idx;\n+\tuint32_t session_id;\n+\n+\tCFA_TCAM_MGR_CHECK_PARMS2(context, parms);\n+\n+\trc = cfa_tcam_mgr_get_session_from_context(context, &session_id);\n+\tif (rc < 0)\n+\t\treturn rc;\n+\n+\tsess_idx = cfa_tcam_mgr_session_find(session_id);\n+\tif (sess_idx < 0) {\n+\t\tCFA_TCAM_MGR_LOG(ERR, \"Session 0x%08x not found.\\n\",\n+\t\t\t\t session_id);\n+\t\treturn sess_idx;\n+\t}\n+\n+\tif (global_data_initialized[sess_idx] == 0) {\n+\t\tCFA_TCAM_MGR_LOG(ERR, \"PANIC: No TCAM data created for sess_idx %d\\n\",\n+\t\t\t\t sess_idx);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(PERM);\n+\t}\n+\n+\tentry = cfa_tcam_mgr_entry_get(sess_idx, parms->id);\n+\tif (entry == NULL) {\n+\t\tCFA_TCAM_MGR_LOG(ERR, \"Entry %d not found.\\n\", parms->id);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\n+\t}\n+\n+\ttable_data = &cfa_tcam_mgr_tables[sess_idx][parms->dir][parms->type];\n+\tparms->hcapi_type = table_data->hcapi_type;\n+\n+\trow_size = cfa_tcam_mgr_row_size_get(sess_idx, parms->dir, parms->type);\n+\trow = cfa_tcam_mgr_row_ptr_get(table_data->tcam_rows, entry->row,\n+\t\t\t\t       row_size);\n+\n+\trc = cfa_tcam_mgr_entry_get_msg(sess_idx, context, parms,\n+\t\t\t\t\tentry->row,\n+\t\t\t\t\tentry->slice * row->entry_size,\n+\t\t\t\t\ttable_data->max_slices);\n+\tif (rc < 0) {\n+\t\tCFA_TCAM_MGR_LOG_0(ERR, \"Failed to read from TCAM.\\n\");\n+\t\treturn rc;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+int cfa_tcam_mgr_shared_clear(struct cfa_tcam_mgr_context *context,\n+\t\t     struct cfa_tcam_mgr_shared_clear_parms *parms)\n+{\n+\tint rc;\n+\tuint16_t row, slice = 0;\n+\tint sess_idx;\n+\tuint32_t session_id;\n+\tstruct cfa_tcam_mgr_free_parms fparms;\n+\tstruct cfa_tcam_mgr_table_data *table_data;\n+\tuint16_t start_row, end_row, max_entries, max_slices;\n+\n+\tCFA_TCAM_MGR_CHECK_PARMS2(context, parms);\n+\n+\trc = cfa_tcam_mgr_get_session_from_context(context, &session_id);\n+\tif (rc < 0)\n+\t\treturn rc;\n+\n+\tsess_idx = cfa_tcam_mgr_session_find(session_id);\n+\tif (sess_idx < 0) {\n+\t\tCFA_TCAM_MGR_LOG(ERR, \"Session 0x%08x not found.\\n\",\n+\t\t\t\t session_id);\n+\t\treturn sess_idx;\n+\t}\n+\n+\tif (global_data_initialized[sess_idx] == 0) {\n+\t\tCFA_TCAM_MGR_LOG(ERR, \"PANIC: No TCAM data created for sess_idx %d\\n\",\n+\t\t\t\t sess_idx);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(PERM);\n+\t}\n+\n+\ttable_data = &cfa_tcam_mgr_tables[sess_idx][parms->dir][parms->type];\n+\tfparms.dir = parms->dir;\n+\tfparms.type = parms->type;\n+\tfparms.hcapi_type = table_data->hcapi_type;\n+\tfparms.id = 0;\n+\n+\trc = cfa_tcam_mgr_tables_get(sess_idx, parms->dir, parms->type,\n+\t\t\t\t&start_row, &end_row, &max_entries, &max_slices);\n+\tif (rc)\n+\t\treturn rc;\n+\n+\tfor (row = start_row; row <= end_row; row++) {\n+\t\tcfa_tcam_mgr_entry_free_msg(sess_idx, context, &fparms,\n+\t\t\t\t\t    row,\n+\t\t\t\t\t    slice,\n+\t\t\t\t\t    table_data->row_width,\n+\t\t\t\t\t    table_data->result_size,\n+\t\t\t\t\t    table_data->max_slices);\n+\t}\n+\treturn rc;\n+}\n+\n+static void\n+cfa_tcam_mgr_mv_used_entries_cnt(int sess_idx, enum tf_dir dir,\n+\t\t\t\t struct cfa_tcam_mgr_table_data *dst_table_data,\n+\t\t\t\t struct cfa_tcam_mgr_table_data *src_table_data)\n+{\n+\tdst_table_data->used_entries++;\n+\tsrc_table_data->used_entries--;\n+\n+\tcfa_tcam_mgr_mv_session_used_entries_cnt(sess_idx, dir,\n+\t\t\t\t\t\t CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_APPS,\n+\t\t\t\t\t\t CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_APPS);\n+}\n+\n+/*\n+ * Move HI WC TCAM entries to LOW TCAM region for HA\n+ * This happens when secondary is becoming primary\n+ */\n+static int\n+cfa_tcam_mgr_shared_entry_move(int sess_idx, struct cfa_tcam_mgr_context *context,\n+\t\t       enum tf_dir dir, enum cfa_tcam_mgr_tbl_type type,\n+\t\t       int entry_id,\n+\t\t       struct cfa_tcam_mgr_table_data *dst_table_data,\n+\t\t       struct cfa_tcam_mgr_table_data *table_data,\n+\t\t       int dst_row_index, int dst_row_slice,\n+\t\t       struct cfa_tcam_mgr_table_rows_0 *dst_row,\n+\t\t       int src_row_index,\n+\t\t       struct cfa_tcam_mgr_table_rows_0 *src_row)\n+{\n+\tstruct cfa_tcam_mgr_get_parms gparms = { 0 };\n+\tstruct cfa_tcam_mgr_set_parms sparms = { 0 };\n+\tstruct cfa_tcam_mgr_free_parms fparms = { 0 };\n+\tstruct cfa_tcam_mgr_entry_data *entry;\n+\tuint8_t  key[CFA_TCAM_MGR_MAX_KEY_SIZE];\n+\tuint8_t  mask[CFA_TCAM_MGR_MAX_KEY_SIZE];\n+\tuint8_t  result[CFA_TCAM_MGR_MAX_KEY_SIZE];\n+\n+\tint rc;\n+\n+\tentry = cfa_tcam_mgr_entry_get(sess_idx, entry_id);\n+\tif (entry == NULL)\n+\t\treturn -1;\n+\n+\tgparms.dir\t   = dir;\n+\tgparms.type\t   = type;\n+\tgparms.hcapi_type  = table_data->hcapi_type;\n+\tgparms.key\t   = key;\n+\tgparms.mask\t   = mask;\n+\tgparms.result\t   = result;\n+\tgparms.id\t   = src_row->entries[entry->slice];\n+\tgparms.key_size\t   = sizeof(key);\n+\tgparms.result_size = sizeof(result);\n+\n+\trc = cfa_tcam_mgr_entry_get_msg(sess_idx, context, &gparms,\n+\t\t\t\t\tsrc_row_index,\n+\t\t\t\t\tentry->slice * src_row->entry_size,\n+\t\t\t\t\ttable_data->max_slices);\n+\tif (rc != 0)\n+\t\treturn rc;\n+\n+\tsparms.dir\t   = dir;\n+\tsparms.type\t   = CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_APPS;\n+\tsparms.hcapi_type  = table_data->hcapi_type;\n+\tsparms.key\t   = key;\n+\tsparms.mask\t   = mask;\n+\tsparms.result\t   = result;\n+\tsparms.id\t   = gparms.id;\n+\tsparms.key_size\t   = gparms.key_size;\n+\tsparms.result_size = gparms.result_size;\n+\n+\trc = cfa_tcam_mgr_entry_set_msg(sess_idx, context, &sparms,\n+\t\t\t\t\tdst_row_index,\n+\t\t\t\t\tdst_row_slice * dst_row->entry_size,\n+\t\t\t\t\ttable_data->max_slices);\n+\tif (rc != 0)\n+\t\treturn rc;\n+\n+\tfparms.dir\t  = dir;\n+\tfparms.type\t  = type;\n+\tfparms.hcapi_type = table_data->hcapi_type;\n+\trc = cfa_tcam_mgr_entry_free_msg(sess_idx, context, &fparms,\n+\t\t\t\t\t src_row_index,\n+\t\t\t\t\t entry->slice *\n+\t\t\t\t\t dst_row->entry_size,\n+\t\t\t\t\t table_data->row_width /\n+\t\t\t\t\t table_data->max_slices *\n+\t\t\t\t\t src_row->entry_size,\n+\t\t\t\t\t table_data->result_size,\n+\t\t\t\t\t table_data->max_slices);\n+\tif (rc != 0) {\n+\t\tCFA_TCAM_MGR_LOG_DIR_TYPE(ERR,\n+\t\t\t\t\t  dir, type,\n+\t\t\t\t\t  \"Failed to free entry ID %d at\"\n+\t\t\t\t\t  \" row %d, slice %d for sess_idx %d. rc: %d.\\n\",\n+\t\t\t\t\t  gparms.id,\n+\t\t\t\t\t  src_row_index,\n+\t\t\t\t\t  entry->slice,\n+\t\t\t\t\t  sess_idx,\n+\t\t\t\t\t  -rc);\n+\t}\n+\n+#ifdef CFA_TCAM_MGR_TRACING\n+\tCFA_TCAM_MGR_TRACE(INFO, \"Moved entry %d from row %d, slice %d to \"\n+\t\t\t   \"row %d, slice %d.\\n\",\n+\t\t\t   entry_id, src_row_index, entry->slice,\n+\t\t\t   dst_row_index, dst_row_slice);\n+#endif\n+\n+\tROW_ENTRY_SET(dst_row, dst_row_slice);\n+\tdst_row->entries[dst_row_slice] = entry_id;\n+\tdst_row->entry_size = src_row->entry_size;\n+\tdst_row->priority = src_row->priority;\n+\tROW_ENTRY_CLEAR(src_row, entry->slice);\n+\tentry->row = dst_row_index;\n+\tentry->slice = dst_row_slice;\n+\n+\tcfa_tcam_mgr_mv_used_entries_cnt(sess_idx, dir, dst_table_data, table_data);\n+\n+#ifdef CFA_TCAM_MGR_TRACING\n+\tcfa_tcam_mgr_rows_dump(sess_idx, dir, type);\n+\tcfa_tcam_mgr_rows_dump(sess_idx, dir, CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_APPS);\n+#endif\n+\n+\treturn 0;\n+}\n+\n+int cfa_tcam_mgr_shared_move(struct cfa_tcam_mgr_context *context,\n+\t\t     struct cfa_tcam_mgr_shared_move_parms *parms)\n+{\n+\tint rc;\n+\tint sess_idx;\n+\tuint32_t session_id;\n+\tuint16_t src_row, dst_row, row_size, slice;\n+\tstruct cfa_tcam_mgr_table_rows_0 *src_table_row;\n+\tstruct cfa_tcam_mgr_table_rows_0 *dst_table_row;\n+\tstruct cfa_tcam_mgr_table_data *src_table_data;\n+\tstruct cfa_tcam_mgr_table_data *dst_table_data;\n+\n+\tCFA_TCAM_MGR_CHECK_PARMS2(context, parms);\n+\n+\trc = cfa_tcam_mgr_get_session_from_context(context, &session_id);\n+\tif (rc < 0)\n+\t\treturn rc;\n+\n+\tsess_idx = cfa_tcam_mgr_session_find(session_id);\n+\tif (sess_idx < 0) {\n+\t\tCFA_TCAM_MGR_LOG(ERR, \"Session 0x%08x not found.\\n\",\n+\t\t\t\t session_id);\n+\t\treturn sess_idx;\n+\t}\n+\n+\tif (global_data_initialized[sess_idx] == 0) {\n+\t\tCFA_TCAM_MGR_LOG(ERR, \"PANIC: No TCAM data created for sess_idx %d\\n\",\n+\t\t\t\t sess_idx);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(PERM);\n+\t}\n+\n+\tsrc_table_data =\n+\t\t&cfa_tcam_mgr_tables[sess_idx][parms->dir][CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_APPS];\n+\tdst_table_data =\n+\t\t&cfa_tcam_mgr_tables[sess_idx][parms->dir][CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_APPS];\n+\n+\trow_size =\n+\t\tcfa_tcam_mgr_row_size_get(sess_idx,\n+\t\t\t\t\t  parms->dir,\n+\t\t\t\t\t  CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_APPS);\n+\n+\tfor (src_row = src_table_data->start_row,\n+\t     dst_row = dst_table_data->start_row;\n+\t     src_row <= src_table_data->end_row;\n+\t     src_row++, dst_row++) {\n+\t\tsrc_table_row = cfa_tcam_mgr_row_ptr_get(src_table_data->tcam_rows,\n+\t\t\t\t\t\t\t src_row, row_size);\n+\t\tdst_table_row = cfa_tcam_mgr_row_ptr_get(dst_table_data->tcam_rows,\n+\t\t\t\t\t\t\t dst_row, row_size);\n+\t\tif (ROW_INUSE(src_table_row)) {\n+\t\t\tfor (slice = 0;\n+\t\t\t     slice < src_table_data->max_slices / src_table_row->entry_size;\n+\t\t\t     slice++) {\n+\t\t\t\tif (ROW_ENTRY_INUSE(src_table_row, slice)) {\n+#ifdef CFA_TCAM_MGR_TRACING\n+\t\t\t\t\tCFA_TCAM_MGR_TRACE(INFO, \"Move entry id %d \"\n+\t\t\t\t\t\t\t   \"from src_row %d, slice %d \"\n+\t\t\t\t\t\t\t   \"to dst_row %d, slice %d.\\n\",\n+\t\t\t\t\t\t\t   src_table_row->entries[slice],\n+\t\t\t\t\t\t\t   src_row, slice,\n+\t\t\t\t\t\t\t   dst_row, slice);\n+#endif\n+\t\t\t\t\trc = cfa_tcam_mgr_shared_entry_move(sess_idx,\n+\t\t\t\t\t\t\tcontext,\n+\t\t\t\t\t\t\tparms->dir,\n+\t\t\t\t\t\t\tCFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_APPS,\n+\t\t\t\t\t\t\tsrc_table_row->entries[slice],\n+\t\t\t\t\t\t\tdst_table_data,\n+\t\t\t\t\t\t\tsrc_table_data,\n+\t\t\t\t\t\t\tdst_row, slice,\n+\t\t\t\t\t\t\tdst_table_row,\n+\t\t\t\t\t\t\tsrc_row,\n+\t\t\t\t\t\t\tsrc_table_row);\n+\t\t\t\t}\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\treturn rc;\n+}\n+\n+static void\n+cfa_tcam_mgr_tbl_get(int sess_idx, enum tf_dir dir,\n+\t\t\tenum cfa_tcam_mgr_tbl_type type,\n+\t\t\t\tuint16_t *start_row,\n+\t\t\t\tuint16_t *end_row,\n+\t\t\t\tuint16_t *max_entries,\n+\t\t\t\tuint16_t *slices)\n+{\n+\tstruct cfa_tcam_mgr_table_data *table_data =\n+\t\t&cfa_tcam_mgr_tables[sess_idx][dir][type];\n+\n+\t/* Get start, end and max for tcam type*/\n+\t*start_row = table_data->start_row;\n+\t*end_row = table_data->end_row;\n+\t*max_entries = table_data->max_entries;\n+\t*slices = table_data->max_slices;\n+}\n+\n+int\n+cfa_tcam_mgr_tables_get(int sess_idx, enum tf_dir dir,\n+\t\t\tenum cfa_tcam_mgr_tbl_type type,\n+\t\t\tuint16_t *start_row,\n+\t\t\tuint16_t *end_row,\n+\t\t\tuint16_t *max_entries,\n+\t\t\tuint16_t *slices)\n+{\n+\tCFA_TCAM_MGR_CHECK_PARMS3(start_row, end_row, max_entries);\n+\n+\tif (global_data_initialized[sess_idx] == 0) {\n+\t\tCFA_TCAM_MGR_LOG(ERR, \"PANIC: TCAM not initialized for sess_idx %d.\\n\",\n+\t\t\t\t sess_idx);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\n+\t}\n+\n+\tif (dir >= TF_DIR_MAX) {\n+\t\tCFA_TCAM_MGR_LOG(ERR, \"Must specify valid dir (0-%d) forsess_idx %d.\\n\",\n+\t\t\t\t TF_DIR_MAX - 1, sess_idx);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\n+\t}\n+\n+\tif (type >= CFA_TCAM_MGR_TBL_TYPE_MAX) {\n+\t\tCFA_TCAM_MGR_LOG(ERR, \"Must specify valid tbl type (0-%d) forsess_idx %d.\\n\",\n+\t\t\t\t CFA_TCAM_MGR_TBL_TYPE_MAX - 1, sess_idx);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\n+\t}\n+\n+\tcfa_tcam_mgr_tbl_get(sess_idx, dir,\n+\t\t\t\t  type,\n+\t\t\t\t  start_row,\n+\t\t\t\t  end_row,\n+\t\t\t\t  max_entries,\n+\t\t\t\t  slices);\n+\treturn 0;\n+}\n+\n+static void\n+cfa_tcam_mgr_tbl_set(int sess_idx, enum tf_dir dir,\n+\t\t\tenum cfa_tcam_mgr_tbl_type type,\n+\t\t\t\tuint16_t start_row,\n+\t\t\t\tuint16_t end_row,\n+\t\t\t\tuint16_t max_entries)\n+{\n+\tstruct cfa_tcam_mgr_table_data *table_data =\n+\t\t&cfa_tcam_mgr_tables[sess_idx][dir][type];\n+\n+\t/* Update start, end and max for tcam type*/\n+\ttable_data->start_row = start_row;\n+\ttable_data->end_row = end_row;\n+\ttable_data->max_entries = max_entries;\n+}\n+\n+int\n+cfa_tcam_mgr_tables_set(int sess_idx, enum tf_dir dir,\n+\t\t\tenum cfa_tcam_mgr_tbl_type type,\n+\t\t\tuint16_t start_row,\n+\t\t\tuint16_t end_row,\n+\t\t\tuint16_t max_entries)\n+{\n+\tif (global_data_initialized[sess_idx] == 0) {\n+\t\tCFA_TCAM_MGR_LOG(ERR, \"PANIC: TCAM not initialized for sess_idx %d.\\n\",\n+\t\t\t\t sess_idx);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\n+\t}\n+\n+\tif (dir >= TF_DIR_MAX) {\n+\t\tCFA_TCAM_MGR_LOG(ERR, \"Must specify valid dir (0-%d) forsess_idx %d.\\n\",\n+\t\t\t\t TF_DIR_MAX - 1, sess_idx);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\n+\t}\n+\n+\tif (type >= CFA_TCAM_MGR_TBL_TYPE_MAX) {\n+\t\tCFA_TCAM_MGR_LOG(ERR, \"Must specify valid tbl type (0-%d) forsess_idx %d.\\n\",\n+\t\t\t\t CFA_TCAM_MGR_TBL_TYPE_MAX - 1, sess_idx);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\n+\t}\n+\n+\tcfa_tcam_mgr_tbl_set(sess_idx, dir,\n+\t\t\t\t  type,\n+\t\t\t\t  start_row,\n+\t\t\t\t  end_row,\n+\t\t\t\t  max_entries);\n+\treturn 0;\n+}\n+\n+void\n+cfa_tcam_mgr_rows_dump(int sess_idx, enum tf_dir dir,\n+\t\t       enum cfa_tcam_mgr_tbl_type type)\n+{\n+\tstruct cfa_tcam_mgr_table_data *table_data;\n+\tstruct cfa_tcam_mgr_table_rows_0 *table_row;\n+\tint i, row, row_size;\n+\tbool row_found = false;\n+\tbool empty_row = false;\n+\n+\tif (global_data_initialized[sess_idx] == 0) {\n+\t\tprintf(\"PANIC: TCAM not initialized for sess_idx %d.\\n\", sess_idx);\n+\t\treturn;\n+\t}\n+\n+\tif (dir >= TF_DIR_MAX) {\n+\t\tprintf(\"Must specify a valid direction (0-%d).\\n\",\n+\t\t       TF_DIR_MAX - 1);\n+\t\treturn;\n+\t}\n+\tif (type >= CFA_TCAM_MGR_TBL_TYPE_MAX) {\n+\t\tprintf(\"Must specify a valid type (0-%d).\\n\",\n+\t\t       CFA_TCAM_MGR_TBL_TYPE_MAX - 1);\n+\t\treturn;\n+\t}\n+\n+\ttable_data = &cfa_tcam_mgr_tables[sess_idx][dir][type];\n+\trow_size = cfa_tcam_mgr_row_size_get(sess_idx, dir, type);\n+\n+\tprintf(\"\\nTCAM Rows:\\n\");\n+\tprintf(\"Rows for direction %s, Logical table type %s\\n\",\n+\t       tf_dir_2_str(dir), cfa_tcam_mgr_tbl_2_str(type));\n+\tprintf(\"Managed rows %d-%d for sess_idx %d:\\n\",\n+\t       table_data->start_row, table_data->end_row, sess_idx);\n+\n+\tprintf(\"Index Pri   Size  Entry IDs\\n\");\n+\tprintf(\"                  Sl 0\");\n+\tfor (i = 1; i < table_data->max_slices; i++)\n+\t\tprintf(\"  Sl %d\", i);\n+\tprintf(\"\\n\");\n+\tfor (row = table_data->start_row; row <= table_data->end_row; row++) {\n+\t\ttable_row = cfa_tcam_mgr_row_ptr_get(table_data->tcam_rows, row,\n+\t\t\t\t\t\t    row_size);\n+\t\tif (ROW_INUSE(table_row)) {\n+\t\t\tempty_row = false;\n+\t\t\tprintf(\"%5u %5u %4u\",\n+\t\t\t       row,\n+\t\t\t       TF_TCAM_PRIORITY_MAX - table_row->priority - 1,\n+\t\t\t       table_row->entry_size);\n+\t\t\tfor (i = 0;\n+\t\t\t     i < table_data->max_slices / table_row->entry_size;\n+\t\t\t     i++) {\n+\t\t\t\tif (ROW_ENTRY_INUSE(table_row, i))\n+\t\t\t\t\tprintf(\" %5u\", table_row->entries[i]);\n+\t\t\t\telse\n+\t\t\t\t\tprintf(\"     x\");\n+\t\t\t}\n+\t\t\tprintf(\"\\n\");\n+\t\t\trow_found = true;\n+\t\t} else if (!empty_row) {\n+\t\t\tempty_row = true;\n+\t\t\tprintf(\"\\n\");\n+\t\t}\n+\t}\n+\n+\tif (!row_found)\n+\t\tprintf(\"No rows in use.\\n\");\n+}\n+\n+static void\n+cfa_tcam_mgr_table_dump(int sess_idx, enum tf_dir dir,\n+\t\t\tenum cfa_tcam_mgr_tbl_type type)\n+{\n+\tstruct cfa_tcam_mgr_table_data *table_data =\n+\t\t&cfa_tcam_mgr_tables[sess_idx][dir][type];\n+\n+\tprintf(\"%3s %-22s %5u %5u %5u %5u %6u %7u %2u\\n\",\n+\t       tf_dir_2_str(dir),\n+\t       cfa_tcam_mgr_tbl_2_str(type),\n+\t       table_data->row_width,\n+\t       table_data->num_rows,\n+\t       table_data->start_row,\n+\t       table_data->end_row,\n+\t       table_data->max_entries,\n+\t       table_data->used_entries,\n+\t       table_data->max_slices);\n+}\n+\n+#define TABLE_DUMP_HEADER \\\n+\t\"Dir Table                  Width  Rows Start   End \" \\\n+\t\"MaxEnt UsedEnt Slices\\n\"\n+\n+void\n+cfa_tcam_mgr_tables_dump(int sess_idx, enum tf_dir dir,\n+\t\t\t enum cfa_tcam_mgr_tbl_type type)\n+{\n+\tif (global_data_initialized[sess_idx] == 0) {\n+\t\tprintf(\"PANIC: TCAM not initialized for sess_idx %d.\\n\", sess_idx);\n+\t\treturn;\n+\t}\n+\n+\tprintf(\"\\nTCAM Table(s) for sess_idx %d:\\n\", sess_idx);\n+\tprintf(TABLE_DUMP_HEADER);\n+\tif (dir >= TF_DIR_MAX) {\n+\t\t/* Iterate over all directions */\n+\t\tfor (dir = 0; dir < TF_DIR_MAX; dir++) {\n+\t\t\tif (type >= CFA_TCAM_MGR_TBL_TYPE_MAX) {\n+\t\t\t\t/* Iterate over all types */\n+\t\t\t\tfor (type = 0;\n+\t\t\t\t     type < CFA_TCAM_MGR_TBL_TYPE_MAX;\n+\t\t\t\t     type++) {\n+\t\t\t\t\tcfa_tcam_mgr_table_dump(sess_idx, dir, type);\n+\t\t\t\t}\n+\t\t\t} else {\n+\t\t\t\t/* Display a specific type */\n+\t\t\t\tcfa_tcam_mgr_table_dump(sess_idx, dir, type);\n+\t\t\t}\n+\t\t}\n+\t} else if (type >= CFA_TCAM_MGR_TBL_TYPE_MAX) {\n+\t\t/* Iterate over all types for a direction */\n+\t\tfor (type = 0; type < CFA_TCAM_MGR_TBL_TYPE_MAX; type++)\n+\t\t\tcfa_tcam_mgr_table_dump(sess_idx, dir, type);\n+\t} else {\n+\t\t/* Display a specific direction and type */\n+\t\tcfa_tcam_mgr_table_dump(sess_idx, dir, type);\n+\t}\n+}\n+\n+#define ENTRY_DUMP_HEADER \"Entry RefCnt  Row Slice\\n\"\n+\n+void\n+cfa_tcam_mgr_entries_dump(int sess_idx)\n+{\n+\tstruct cfa_tcam_mgr_entry_data *entry;\n+\tbool entry_found = false;\n+\tuint16_t id;\n+\n+\tif (global_data_initialized[sess_idx] == 0) {\n+\t\tCFA_TCAM_MGR_LOG(INFO, \"PANIC: No TCAM data created for sess_idx %d\\n\",\n+\t\t\t\t sess_idx);\n+\t\treturn;\n+\t}\n+\n+\tprintf(\"\\nGlobal Maximum Entries: %d\\n\\n\",\n+\t       cfa_tcam_mgr_max_entries[sess_idx]);\n+\tprintf(\"TCAM Entry Table:\\n\");\n+\tfor (id = 0; id < cfa_tcam_mgr_max_entries[sess_idx]; id++) {\n+\t\tif (entry_data[sess_idx][id].ref_cnt > 0) {\n+\t\t\tentry = &entry_data[sess_idx][id];\n+\t\t\tif (!entry_found)\n+\t\t\t\tprintf(ENTRY_DUMP_HEADER);\n+\t\t\tprintf(\"%5u %5u %5u %5u\",\n+\t\t\t       id, entry->ref_cnt,\n+\t\t\t       entry->row, entry->slice);\n+\t\t\tprintf(\"\\n\");\n+\t\t\tentry_found = true;\n+\t\t}\n+\t}\n+\n+\tif (!entry_found)\n+\t\tprintf(\"No entries found.\\n\");\n+}\ndiff --git a/drivers/net/bnxt/tf_core/cfa_tcam_mgr.h b/drivers/net/bnxt/tf_core/cfa_tcam_mgr.h\nnew file mode 100644\nindex 0000000000..40bfe8e225\n--- /dev/null\n+++ b/drivers/net/bnxt/tf_core/cfa_tcam_mgr.h\n@@ -0,0 +1,523 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2021-2023 Broadcom\n+ * All rights reserved.\n+ */\n+\n+#ifndef _CFA_TCAM_MGR_H_\n+#define _CFA_TCAM_MGR_H_\n+\n+#include <errno.h>\n+#include \"rte_common.h\"\n+#include \"hsi_struct_def_dpdk.h\"\n+#include \"tf_core.h\"\n+\n+#ifndef __rte_unused\n+#define __rte_unused __attribute__((unused))\n+#endif\n+\n+/**\n+ * The TCAM module provides processing of Internal TCAM types.\n+ */\n+\n+#ifndef TF_TCAM_MAX_SESSIONS\n+#define TF_TCAM_MAX_SESSIONS 16\n+#endif\n+\n+#define ENTRY_ID_INVALID UINT16_MAX\n+\n+#define TF_TCAM_PRIORITY_MIN 0\n+#define TF_TCAM_PRIORITY_MAX UINT16_MAX\n+\n+#ifndef ARRAY_SIZE\n+#define ARRAY_SIZE(_array) (sizeof(_array) / sizeof(_array[0]))\n+#endif\n+\n+/* Use TFP_DRV_LOG definition in tfp.h */\n+#define CFA_TCAM_MGR_LOG(level, fmt, args...)\t\\\n+\tTFP_DRV_LOG(level, fmt, ## args)\n+#define CFA_TCAM_MGR_LOG_DIR(level, dir, fmt, args...)\t\t\t\\\n+\tTFP_DRV_LOG(level, \"%s: \" fmt, tf_dir_2_str(dir), ## args)\n+#define CFA_TCAM_MGR_LOG_DIR_TYPE(level, dir, type, fmt, args...)\t\\\n+\tTFP_DRV_LOG(level, \"%s: %s \" fmt, tf_dir_2_str(dir),\t\t\\\n+\t\t    cfa_tcam_mgr_tbl_2_str(type), ## args)\n+\n+#define CFA_TCAM_MGR_LOG_0(level, fmt)\t\t\\\n+\tTFP_DRV_LOG(level, fmt)\n+#define CFA_TCAM_MGR_LOG_DIR_0(level, dir, fmt)\t\t\t\\\n+\tTFP_DRV_LOG(level, \"%s: \" fmt, tf_dir_2_str(dir))\n+#define CFA_TCAM_MGR_LOG_DIR_TYPE_0(level, dir, type, fmt)\t\\\n+\tTFP_DRV_LOG(level, \"%s: %s \" fmt, tf_dir_2_str(dir),\t\\\n+\t\t    cfa_tcam_mgr_tbl_2_str(type))\n+\n+#define CFA_TCAM_MGR_ERR_CODE(type) E ## type\n+\n+/**\n+ * Checks 1 parameter against NULL.\n+ */\n+#define CFA_TCAM_MGR_CHECK_PARMS1(parms) do {\t\t\t\t\\\n+\t\tif ((parms) == NULL) {\t\t\t\t\t\\\n+\t\t\tCFA_TCAM_MGR_LOG_0(ERR, \"Invalid Argument(s)\\n\"); \\\n+\t\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\t\t\\\n+\t\t}\t\t\t\t\t\t\t\\\n+\t} while (0)\n+\n+/**\n+ * Checks 2 parameters against NULL.\n+ */\n+#define CFA_TCAM_MGR_CHECK_PARMS2(parms1, parms2) do {\t\t\t\\\n+\t\tif ((parms1) == NULL || (parms2) == NULL) {\t\t\\\n+\t\t\tCFA_TCAM_MGR_LOG_0(ERR, \"Invalid Argument(s)\\n\"); \\\n+\t\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\t\t\\\n+\t\t}\t\t\t\t\t\t\t\\\n+\t} while (0)\n+\n+/**\n+ * Checks 3 parameters against NULL.\n+ */\n+#define CFA_TCAM_MGR_CHECK_PARMS3(parms1, parms2, parms3) do {\t\t\\\n+\t\tif ((parms1) == NULL ||\t\t\t\t\t\\\n+\t\t    (parms2) == NULL ||\t\t\t\t\t\\\n+\t\t    (parms3) == NULL) {\t\t\t\t\t\\\n+\t\t\tCFA_TCAM_MGR_LOG_0(ERR, \"Invalid Argument(s)\\n\"); \\\n+\t\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\t\t\\\n+\t\t}\t\t\t\t\t\t\t\\\n+\t} while (0)\n+\n+enum cfa_tcam_mgr_tbl_type {\n+\t/* Logical TCAM tables */\n+\tCFA_TCAM_MGR_TBL_TYPE_START,\n+\tCFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_HIGH_AFM =\n+\t\tCFA_TCAM_MGR_TBL_TYPE_START,\n+\tCFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_HIGH_APPS,\n+\tCFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_LOW_AFM,\n+\tCFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_LOW_APPS,\n+\tCFA_TCAM_MGR_TBL_TYPE_PROF_TCAM_AFM,\n+\tCFA_TCAM_MGR_TBL_TYPE_PROF_TCAM_APPS,\n+\tCFA_TCAM_MGR_TBL_TYPE_WC_TCAM_AFM,\n+\tCFA_TCAM_MGR_TBL_TYPE_WC_TCAM_APPS,\n+\tCFA_TCAM_MGR_TBL_TYPE_SP_TCAM_AFM,\n+\tCFA_TCAM_MGR_TBL_TYPE_SP_TCAM_APPS,\n+\tCFA_TCAM_MGR_TBL_TYPE_CT_RULE_TCAM_AFM,\n+\tCFA_TCAM_MGR_TBL_TYPE_CT_RULE_TCAM_APPS,\n+\tCFA_TCAM_MGR_TBL_TYPE_VEB_TCAM_AFM,\n+\tCFA_TCAM_MGR_TBL_TYPE_VEB_TCAM_APPS,\n+\tCFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_AFM,\n+\tCFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_APPS,\n+\tCFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_AFM,\n+\tCFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_APPS,\n+\tCFA_TCAM_MGR_TBL_TYPE_MAX\n+};\n+\n+enum cfa_tcam_mgr_device_type {\n+\tCFA_TCAM_MGR_DEVICE_TYPE_P4 = 0,\n+\tCFA_TCAM_MGR_DEVICE_TYPE_SR,\n+\tCFA_TCAM_MGR_DEVICE_TYPE_P5,\n+\tCFA_TCAM_MGR_DEVICE_TYPE_MAX\n+};\n+\n+struct cfa_tcam_mgr_context {\n+\tstruct tf *tfp;\n+};\n+\n+/**\n+ * TCAM Manager initialization parameters\n+ */\n+struct cfa_tcam_mgr_init_parms {\n+\t/**\n+\t * [in] TCAM resources reserved\n+\t *      type element is not used.\n+\t */\n+\tstruct tf_rm_resc_entry resc[TF_DIR_MAX][CFA_TCAM_MGR_TBL_TYPE_MAX];\n+\t/**\n+\t * [out] maximum number of entries available.\n+\t */\n+\tuint32_t max_entries;\n+};\n+\n+/**\n+ * TCAM Manager initialization parameters\n+ */\n+struct cfa_tcam_mgr_qcaps_parms {\n+\t/**\n+\t * [out] Bitmasks.  Set if TCAM Manager is managing a logical TCAM.\n+\t * Each bitmask is indexed by logical TCAM table ID.\n+\t */\n+\tuint32_t rx_tcam_supported;\n+\tuint32_t tx_tcam_supported;\n+};\n+\n+/**\n+ * TCAM Manager configuration parameters\n+ */\n+struct cfa_tcam_mgr_cfg_parms {\n+\t/**\n+\t * [in] Number of tcam types in each of the configuration arrays\n+\t */\n+\tuint16_t num_elements;\n+\t/**\n+\t * [in] Session resource allocations\n+\t */\n+\tuint16_t tcam_cnt[TF_DIR_MAX][CFA_TCAM_MGR_TBL_TYPE_MAX];\n+\n+\t/**\n+\t * [in] TCAM Locations reserved\n+\t */\n+\tstruct tf_rm_resc_entry (*resv_res)[CFA_TCAM_MGR_TBL_TYPE_MAX];\n+};\n+\n+/**\n+ * TCAM Manager allocation parameters\n+ */\n+struct cfa_tcam_mgr_alloc_parms {\n+\t/**\n+\t * [in] Receive or transmit direction\n+\t */\n+\tenum tf_dir dir;\n+\t/**\n+\t * [in] Type of the allocation\n+\t */\n+\tenum cfa_tcam_mgr_tbl_type type;\n+\t/**\n+\t * [in] Type of HCAPI\n+\t */\n+\tuint16_t hcapi_type;\n+\t/**\n+\t * [in] key size (bytes)\n+\t */\n+\tuint16_t key_size;\n+\t/**\n+\t * [in] Priority of entry requested (definition TBD)\n+\t */\n+\tuint16_t priority;\n+\t/**\n+\t * [out] Id of allocated entry or found entry (if search_enable)\n+\t */\n+\tuint16_t id;\n+};\n+\n+/**\n+ * TCAM Manager free parameters\n+ */\n+struct cfa_tcam_mgr_free_parms {\n+\t/**\n+\t * [in] Receive or transmit direction\n+\t */\n+\tenum tf_dir dir;\n+\t/**\n+\t * [in] Type of the allocation\n+\t * If the type is not known, set the type to CFA_TCAM_MGR_TBL_TYPE_MAX.\n+\t */\n+\tenum cfa_tcam_mgr_tbl_type type;\n+\t/**\n+\t * [in] Type of HCAPI\n+\t */\n+\tuint16_t hcapi_type;\n+\t/**\n+\t * [in] Entry ID to free\n+\t */\n+\tuint16_t id;\n+};\n+\n+/**\n+ * TCAM Manager set parameters\n+ */\n+struct cfa_tcam_mgr_set_parms {\n+\t/**\n+\t * [in] Receive or transmit direction\n+\t */\n+\tenum tf_dir dir;\n+\t/**\n+\t * [in] Type of object to set\n+\t */\n+\tenum cfa_tcam_mgr_tbl_type type;\n+\t/**\n+\t * [in] Type of HCAPI\n+\t */\n+\tuint16_t hcapi_type;\n+\t/**\n+\t * [in] Entry ID to write to\n+\t */\n+\tuint16_t id;\n+\t/**\n+\t * [in] array containing key\n+\t */\n+\tuint8_t *key;\n+\t/**\n+\t * [in] array containing mask fields\n+\t */\n+\tuint8_t *mask;\n+\t/**\n+\t * [in] key size (bytes)\n+\t */\n+\tuint16_t key_size;\n+\t/**\n+\t * [in] array containing result\n+\t */\n+\tuint8_t *result;\n+\t/**\n+\t * [in] result size (bytes)\n+\t */\n+\tuint16_t result_size;\n+};\n+\n+/**\n+ * TCAM Manager get parameters\n+ */\n+struct cfa_tcam_mgr_get_parms {\n+\t/**\n+\t * [in] Receive or transmit direction\n+\t */\n+\tenum tf_dir dir;\n+\t/**\n+\t * [in] Type of object to get\n+\t */\n+\tenum cfa_tcam_mgr_tbl_type type;\n+\t/**\n+\t * [in] Type of HCAPI\n+\t */\n+\tuint16_t hcapi_type;\n+\t/**\n+\t * [in] Entry ID to read\n+\t */\n+\tuint16_t id;\n+\t/**\n+\t * [out] array containing key\n+\t */\n+\tuint8_t *key;\n+\t/**\n+\t * [out] array containing mask fields\n+\t */\n+\tuint8_t *mask;\n+\t/**\n+\t * [out] key size (bytes)\n+\t */\n+\tuint16_t key_size;\n+\t/**\n+\t * [out] array containing result\n+\t */\n+\tuint8_t *result;\n+\t/**\n+\t * [out] result size (bytes)\n+\t */\n+\tuint16_t result_size;\n+};\n+\n+/**\n+ * cfa_tcam_mgr_shared_clear_parms parameter definition\n+ */\n+struct cfa_tcam_mgr_shared_clear_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 cfa_tcam_mgr_tbl_type type;\n+};\n+\n+/**\n+ * cfa_tcam_mgr_shared_move_parms parameter definition\n+ */\n+struct cfa_tcam_mgr_shared_move_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 cfa_tcam_mgr_tbl_type type;\n+};\n+\n+/**\n+ * @page tcam TCAM Manager\n+ *\n+ * @ref cfa_tcam_mgr_init\n+ *\n+ * @ref cfa_tcam_mgr_get_phys_table_type\n+ *\n+ * @ref cfa_tcam_mgr_bind\n+ *\n+ * @ref cfa_tcam_mgr_unbind\n+ *\n+ * @ref cfa_tcam_mgr_alloc\n+ *\n+ * @ref cfa_tcam_mgr_free\n+ *\n+ * @ref cfa_tcam_mgr_set\n+ *\n+ * @ref cfa_tcam_mgr_get\n+ *\n+ */\n+\n+const char *\n+cfa_tcam_mgr_tbl_2_str(enum cfa_tcam_mgr_tbl_type tcam_type);\n+\n+/**\n+ * Initializes the TCAM Manager\n+ *\n+ * [in] type\n+ *   Device type\n+ *\n+ * Returns\n+ *   - (0) if successful.\n+ *   - (<0) on failure.\n+ */\n+int\n+cfa_tcam_mgr_init(int sess_idx, enum cfa_tcam_mgr_device_type type,\n+\t\t  struct cfa_tcam_mgr_init_parms *parms);\n+\n+/**\n+ * Returns the physical TCAM table that a logical TCAM table uses.\n+ *\n+ * [in] type\n+ *   Logical table type\n+ *\n+ * Returns\n+ *   - (tf_tcam_tbl_type) if successful.\n+ *   - (<0) on failure.\n+ */\n+int\n+cfa_tcam_mgr_get_phys_table_type(enum cfa_tcam_mgr_tbl_type type);\n+\n+/**\n+ * Queries the capabilities of TCAM Manager.\n+ *\n+ * [in] context\n+ *   Pointer to context information\n+ *\n+ * [out] parms\n+ *   Pointer to parameters to be returned\n+ *\n+ * Returns\n+ *   - (0) if successful.\n+ *   - (<0) on failure.\n+ */\n+int\n+cfa_tcam_mgr_qcaps(struct cfa_tcam_mgr_context *context __rte_unused,\n+\t\t   struct cfa_tcam_mgr_qcaps_parms *parms);\n+\n+/**\n+ * Initializes the TCAM module with the requested DBs. Must be\n+ * invoked as the first thing before any of the access functions.\n+ *\n+ * [in] context\n+ *   Pointer to context information\n+ *\n+ * [in] parms\n+ *   Pointer to parameters\n+ *\n+ * Returns\n+ *   - (0) if successful.\n+ *   - (-EINVAL) on failure.\n+ */\n+int cfa_tcam_mgr_bind(struct cfa_tcam_mgr_context *context,\n+\t\t      struct cfa_tcam_mgr_cfg_parms *parms);\n+\n+/**\n+ * Cleans up the private DBs and releases all the data.\n+ *\n+ * [in] context\n+ *   Pointer to context information\n+ *\n+ * [in] parms\n+ *   Pointer to parameters\n+ *\n+ * Returns\n+ *   - (0) if successful.\n+ *   - (-EINVAL) on failure.\n+ */\n+int cfa_tcam_mgr_unbind(struct cfa_tcam_mgr_context *context);\n+\n+/**\n+ * Allocates the requested tcam type from the internal RM DB.\n+ *\n+ * [in] context\n+ *   Pointer to context information\n+ *\n+ * [in] parms\n+ *   Pointer to parameters\n+ *\n+ * Returns\n+ *   - (0) if successful.\n+ *   - (-EINVAL) on failure.\n+ */\n+int cfa_tcam_mgr_alloc(struct cfa_tcam_mgr_context *context,\n+\t\t       struct cfa_tcam_mgr_alloc_parms *parms);\n+\n+/**\n+ * Free's the requested table type and returns it to the DB.\n+ * If refcount goes to 0 then it is returned to the table type DB.\n+ *\n+ * [in] context\n+ *   Pointer to context information\n+ *\n+ * [in] parms\n+ *   Pointer to parameters\n+ *\n+ * Returns\n+ *   - (0) if successful.\n+ *   - (-EINVAL) on failure.\n+ */\n+int cfa_tcam_mgr_free(struct cfa_tcam_mgr_context *context,\n+\t\t      struct cfa_tcam_mgr_free_parms *parms);\n+\n+/**\n+ * Configures the requested element by sending a firmware request which\n+ * then installs it into the device internal structures.\n+ *\n+ * [in] context\n+ *   Pointer to context information\n+ *\n+ * [in] parms\n+ *   Pointer to parameters\n+ *\n+ * Returns\n+ *   - (0) if successful.\n+ *   - (-EINVAL) on failure.\n+ */\n+int cfa_tcam_mgr_set(struct cfa_tcam_mgr_context *context,\n+\t\t     struct cfa_tcam_mgr_set_parms *parms);\n+\n+/**\n+ * Retrieves the requested element by sending a firmware request to get\n+ * the element.\n+ *\n+ * [in] context\n+ *   Pointer to context information\n+ *\n+ * [in] parms\n+ *   Pointer to parameters\n+ *\n+ * Returns\n+ *   - (0) if successful.\n+ *   - (-EINVAL) on failure.\n+ */\n+int cfa_tcam_mgr_get(struct cfa_tcam_mgr_context *context,\n+\t\t     struct cfa_tcam_mgr_get_parms *parms);\n+\n+int\n+cfa_tcam_mgr_tables_get(int sess_idx, enum tf_dir dir,\n+\t\t\tenum cfa_tcam_mgr_tbl_type type,\n+\t\t\tuint16_t *start_row,\n+\t\t\tuint16_t *end_row,\n+\t\t\tuint16_t *max_entries,\n+\t\t\tuint16_t *slices);\n+int\n+cfa_tcam_mgr_tables_set(int sess_idx, enum tf_dir dir,\n+\t\t\tenum cfa_tcam_mgr_tbl_type type,\n+\t\t\tuint16_t start_row,\n+\t\t\tuint16_t end_row,\n+\t\t\tuint16_t max_entries);\n+\n+int cfa_tcam_mgr_shared_clear(struct cfa_tcam_mgr_context *context,\n+\t\t     struct cfa_tcam_mgr_shared_clear_parms *parms);\n+\n+int cfa_tcam_mgr_shared_move(struct cfa_tcam_mgr_context *context,\n+\t\t     struct cfa_tcam_mgr_shared_move_parms *parms);\n+\n+void cfa_tcam_mgr_rows_dump(int sess_idx, enum tf_dir dir, enum cfa_tcam_mgr_tbl_type type);\n+void cfa_tcam_mgr_tables_dump(int sess_idx, enum tf_dir dir, enum cfa_tcam_mgr_tbl_type type);\n+void cfa_tcam_mgr_entries_dump(int sess_idx);\n+#endif /* _CFA_TCAM_MGR_H */\ndiff --git a/drivers/net/bnxt/tf_core/cfa_tcam_mgr_device.h b/drivers/net/bnxt/tf_core/cfa_tcam_mgr_device.h\nnew file mode 100644\nindex 0000000000..6ab9b5e118\n--- /dev/null\n+++ b/drivers/net/bnxt/tf_core/cfa_tcam_mgr_device.h\n@@ -0,0 +1,101 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2021-2023 Broadcom\n+ * All rights reserved.\n+ */\n+\n+#ifndef CFA_TCAM_MGR_DEVICE_H\n+#define CFA_TCAM_MGR_DEVICE_H\n+\n+#include <inttypes.h>\n+#include \"cfa_tcam_mgr.h\"\n+\n+/*\n+ * This identifier is to be used for one-off variable sizes.  Do not use it for\n+ * sizing keys in an array.\n+ */\n+#define CFA_TCAM_MGR_MAX_KEY_SIZE 96\n+\n+/* Note that this macro's arguments are not macro expanded due to\n+ * concatenation.\n+ */\n+#define TF_TCAM_TABLE_ROWS_DEF(_slices)\t\t\t\t\t\\\n+\tstruct cfa_tcam_mgr_table_rows_ ## _slices {\t\t\t\\\n+\t\tuint16_t priority;\t\t\t\t\t\\\n+\t\tuint8_t entry_size;\t\t/* Slices per entry */\t\\\n+\t\tuint8_t entry_inuse;\t        /* bit[entry] set if in use */ \\\n+\t\tuint16_t entries[_slices];\t\t\t\t\\\n+\t}\n+\n+/*\n+ * Have to explicitly declare this struct since some compilers don't accept the\n+ * GNU C extension of zero length arrays.\n+ */\n+struct cfa_tcam_mgr_table_rows_0 {\n+\tuint16_t priority;\n+\tuint8_t entry_size;\t\t/* Slices per entry */\n+\tuint8_t entry_inuse;\t        /* bit[entry] set if in use */\n+\tuint16_t entries[];\n+};\n+\n+TF_TCAM_TABLE_ROWS_DEF(1);\n+TF_TCAM_TABLE_ROWS_DEF(2);\n+TF_TCAM_TABLE_ROWS_DEF(4);\n+TF_TCAM_TABLE_ROWS_DEF(8);\n+\n+#define TF_TCAM_MAX_ENTRIES (L2_CTXT_TCAM_RX_MAX_ENTRIES +\t\\\n+\t\t\t     L2_CTXT_TCAM_TX_MAX_ENTRIES +\t\\\n+\t\t\t     PROF_TCAM_RX_MAX_ENTRIES +\t\t\\\n+\t\t\t     PROF_TCAM_TX_MAX_ENTRIES +\t\t\\\n+\t\t\t     WC_TCAM_RX_MAX_ENTRIES +\t\t\\\n+\t\t\t     WC_TCAM_TX_MAX_ENTRIES +\t\t\\\n+\t\t\t     SP_TCAM_RX_MAX_ENTRIES +\t\t\\\n+\t\t\t     SP_TCAM_TX_MAX_ENTRIES +\t\t\\\n+\t\t\t     CT_RULE_TCAM_RX_MAX_ENTRIES +\t\\\n+\t\t\t     CT_RULE_TCAM_TX_MAX_ENTRIES +\t\\\n+\t\t\t     VEB_TCAM_RX_MAX_ENTRIES +\t\t\\\n+\t\t\t     VEB_TCAM_TX_MAX_ENTRIES)\n+\n+struct cfa_tcam_mgr_entry_data {\n+\tuint16_t row;\n+\tuint8_t slice;\n+\tuint8_t ref_cnt;\n+};\n+\n+struct cfa_tcam_mgr_table_data {\n+\tstruct cfa_tcam_mgr_table_rows_0 *tcam_rows;\n+\tuint16_t hcapi_type;\n+\tuint16_t num_rows;\t\t/* Rows in physical TCAM */\n+\tuint16_t start_row;\t\t/* Where the logical TCAM starts */\n+\tuint16_t end_row;\t\t/* Where the logical TCAM ends */\n+\tuint16_t max_entries;\n+\tuint16_t used_entries;\n+\tuint8_t  row_width;\t\t/* bytes */\n+\tuint8_t  result_size;\t\t/* bytes */\n+\tuint8_t  max_slices;\n+};\n+\n+extern int cfa_tcam_mgr_max_entries[TF_TCAM_MAX_SESSIONS];\n+\n+extern struct cfa_tcam_mgr_table_data\n+cfa_tcam_mgr_tables[TF_TCAM_MAX_SESSIONS][TF_DIR_MAX][CFA_TCAM_MGR_TBL_TYPE_MAX];\n+\n+/* HW OP definitions begin here */\n+typedef int (*cfa_tcam_mgr_hwop_set_func_t)(int sess_idx,\n+\t\t\t\t\t    struct cfa_tcam_mgr_set_parms\n+\t\t\t\t\t    *parms, int row, int slice,\n+\t\t\t\t\t    int max_slices);\n+typedef int (*cfa_tcam_mgr_hwop_get_func_t)(int sess_idx,\n+\t\t\t\t\t    struct cfa_tcam_mgr_get_parms\n+\t\t\t\t\t    *parms, int row, int slice,\n+\t\t\t\t\t    int max_slices);\n+typedef int (*cfa_tcam_mgr_hwop_free_func_t)(int sess_idx,\n+\t\t\t\t\t     struct cfa_tcam_mgr_free_parms\n+\t\t\t\t\t     *parms, int row, int slice,\n+\t\t\t\t\t     int max_slices);\n+\n+struct cfa_tcam_mgr_hwops_funcs {\n+\tcfa_tcam_mgr_hwop_set_func_t set;\n+\tcfa_tcam_mgr_hwop_get_func_t get;\n+\tcfa_tcam_mgr_hwop_free_func_t free;\n+};\n+#endif /* CFA_TCAM_MGR_DEVICE_H */\ndiff --git a/drivers/net/bnxt/tf_core/cfa_tcam_mgr_hwop_msg.c b/drivers/net/bnxt/tf_core/cfa_tcam_mgr_hwop_msg.c\nnew file mode 100644\nindex 0000000000..0fb5563cc3\n--- /dev/null\n+++ b/drivers/net/bnxt/tf_core/cfa_tcam_mgr_hwop_msg.c\n@@ -0,0 +1,201 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2021-2023 Broadcom\n+ * All rights reserved.\n+ */\n+\n+/*\n+ * This file will \"do the right thing\" for each of the primitives set, get and\n+ * free. The TCAM manager is running in the core, so the tables will be cached.\n+ * Set and free messages will also be sent to the firmware.  Instead of sending\n+ * get messages, the entry will be read from the cached copy thus saving a\n+ * firmware message.\n+ */\n+\n+#include \"tf_tcam.h\"\n+#include \"hcapi_cfa_defs.h\"\n+#include \"cfa_tcam_mgr.h\"\n+#include \"cfa_tcam_mgr_hwop_msg.h\"\n+#include \"cfa_tcam_mgr_device.h\"\n+#include \"cfa_tcam_mgr_p58.h\"\n+#include \"cfa_tcam_mgr_p4.h\"\n+#include \"tf_session.h\"\n+#include \"tf_msg.h\"\n+#include \"tfp.h\"\n+#include \"tf_util.h\"\n+\n+/*\n+ * The free hwop will free more than a single slice so cannot be used.\n+ */\n+struct cfa_tcam_mgr_hwops_funcs hwop_funcs;\n+\n+int\n+cfa_tcam_mgr_hwops_init(enum cfa_tcam_mgr_device_type type)\n+{\n+\tswitch (type) {\n+\tcase CFA_TCAM_MGR_DEVICE_TYPE_P4:\n+\tcase CFA_TCAM_MGR_DEVICE_TYPE_SR:\n+\t\treturn cfa_tcam_mgr_hwops_get_funcs_p4(&hwop_funcs);\n+\tcase CFA_TCAM_MGR_DEVICE_TYPE_P5:\n+\t\treturn cfa_tcam_mgr_hwops_get_funcs_p58(&hwop_funcs);\n+\tdefault:\n+\t\tCFA_TCAM_MGR_LOG(ERR, \"No such device\\n\");\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(NODEV);\n+\t}\n+}\n+\n+/*\n+ * This is the glue between the TCAM manager and the firmware HW operations.  It\n+ * is intended to abstract out the location of the TCAM manager so that the TCAM\n+ * manager code will be the same whether or not it is actually using the\n+ * firmware.\n+ */\n+\n+int\n+cfa_tcam_mgr_entry_set_msg(int sess_idx, struct cfa_tcam_mgr_context *context\n+\t\t\t   __rte_unused,\n+\t\t\t   struct cfa_tcam_mgr_set_parms *parms,\n+\t\t\t   int row, int slice,\n+\t\t\t   int max_slices __rte_unused)\n+{\n+\tcfa_tcam_mgr_hwop_set_func_t set_func;\n+\n+\tset_func = hwop_funcs.set;\n+\tif (set_func == NULL)\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(PERM);\n+\n+\tstruct tf_tcam_set_parms sparms;\n+\tstruct tf_session *tfs;\n+\tstruct tf_dev_info *dev;\n+\tint rc;\n+\tenum tf_tcam_tbl_type type =\n+\t\tcfa_tcam_mgr_get_phys_table_type(parms->type);\n+\n+\t/* Retrieve the session information */\n+\trc = tf_session_get_session_internal(context->tfp, &tfs);\n+\tif (rc)\n+\t\treturn rc;\n+\n+\t/* Retrieve the device information */\n+\trc = tf_session_get_device(tfs, &dev);\n+\tif (rc)\n+\t\treturn rc;\n+\n+\tmemset(&sparms, 0, sizeof(sparms));\n+\tsparms.dir\t   = parms->dir;\n+\tsparms.type\t   = type;\n+\tsparms.hcapi_type  = parms->hcapi_type;\n+\tsparms.idx\t   = (row * max_slices) + slice;\n+\tsparms.key\t   = parms->key;\n+\tsparms.mask\t   = parms->mask;\n+\tsparms.key_size\t   = parms->key_size;\n+\tsparms.result\t   = parms->result;\n+\tsparms.result_size = parms->result_size;\n+\n+\trc = tf_msg_tcam_entry_set(context->tfp, dev, &sparms);\n+\tif (rc) {\n+\t\t/* Log error */\n+\t\tCFA_TCAM_MGR_LOG_DIR_TYPE(ERR, parms->dir, parms->type,\n+\t\t\t\t\t  \"Entry %d set failed, rc:%d\\n\",\n+\t\t\t\t\t  parms->id, -rc);\n+\t\treturn rc;\n+\t}\n+\n+\treturn set_func(sess_idx, parms, row, slice, max_slices);\n+}\n+\n+int\n+cfa_tcam_mgr_entry_get_msg(int sess_idx, struct cfa_tcam_mgr_context *context\n+\t\t\t   __rte_unused,\n+\t\t\t   struct cfa_tcam_mgr_get_parms *parms,\n+\t\t\t   int row, int slice,\n+\t\t\t   int max_slices __rte_unused)\n+{\n+\tcfa_tcam_mgr_hwop_get_func_t get_func;\n+\n+\tget_func = hwop_funcs.get;\n+\tif (get_func == NULL)\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(PERM);\n+\n+\treturn get_func(sess_idx, parms, row, slice, max_slices);\n+}\n+\n+int\n+cfa_tcam_mgr_entry_free_msg(int sess_idx, struct cfa_tcam_mgr_context *context\n+\t\t\t    __rte_unused,\n+\t\t\t    struct cfa_tcam_mgr_free_parms *parms,\n+\t\t\t    int row, int slice,\n+\t\t\t    int key_size,\n+\t\t\t    int result_size,\n+\t\t\t    int max_slices)\n+{\n+\tcfa_tcam_mgr_hwop_free_func_t free_func;\n+\n+\tfree_func = hwop_funcs.free;\n+\tif (free_func == NULL)\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(PERM);\n+\n+\tstruct tf_dev_info *dev;\n+\tstruct tf_session *tfs;\n+\tint rc;\n+\tenum tf_tcam_tbl_type type =\n+\t\tcfa_tcam_mgr_get_phys_table_type(parms->type);\n+\n+\t/* Free will clear an entire row. */\n+\t/* Use set message to clear an individual entry */\n+\tstruct tf_tcam_set_parms sparms;\n+\tuint8_t key[CFA_TCAM_MGR_MAX_KEY_SIZE] = { 0 };\n+\tuint8_t mask[CFA_TCAM_MGR_MAX_KEY_SIZE] = { 0 };\n+\n+\t/* Retrieve the session information */\n+\trc = tf_session_get_session_internal(context->tfp, &tfs);\n+\tif (rc)\n+\t\treturn rc;\n+\n+\t/* Retrieve the device information */\n+\trc = tf_session_get_device(tfs, &dev);\n+\tif (rc)\n+\t\treturn rc;\n+\n+\tif (key_size > CFA_TCAM_MGR_MAX_KEY_SIZE) {\n+\t\tCFA_TCAM_MGR_LOG_DIR_TYPE(ERR, parms->dir, parms->type,\n+\t\t\t\t\t  \"Entry %d key size is %d greater than:%d\\n\",\n+\t\t\t\t\t  parms->id, key_size,\n+\t\t\t\t\t  CFA_TCAM_MGR_MAX_KEY_SIZE);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (result_size > CFA_TCAM_MGR_MAX_KEY_SIZE) {\n+\t\tCFA_TCAM_MGR_LOG_DIR_TYPE(ERR, parms->dir, parms->type,\n+\t\t\t\t\t  \"Entry %d result size is %d greater than:%d\\n\",\n+\t\t\t\t\t  parms->id, result_size,\n+\t\t\t\t\t  CFA_TCAM_MGR_MAX_KEY_SIZE);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tmemset(&sparms, 0, sizeof(sparms));\n+\tmemset(&key, 0, sizeof(key));\n+\tmemset(&mask, 0xff, sizeof(mask));\n+\n+\tsparms.dir\t   = parms->dir;\n+\tsparms.type\t   = type;\n+\tsparms.hcapi_type  = parms->hcapi_type;\n+\tsparms.key\t   = key;\n+\tsparms.mask\t   = mask;\n+\tsparms.result\t   = key;\n+\tsparms.idx\t   = (row * max_slices) + slice;\n+\tsparms.key_size\t   = key_size;\n+\tsparms.result_size = result_size;\n+\n+\trc = tf_msg_tcam_entry_set(context->tfp, dev, &sparms);\n+\tif (rc) {\n+\t\t/* Log error */\n+\t\tCFA_TCAM_MGR_LOG_DIR_TYPE(ERR, parms->dir, parms->type,\n+\t\t\t\t\t  \"Row %d, slice %d set failed, \"\n+\t\t\t\t\t  \"rc:%d.\\n\",\n+\t\t\t\t\t  row,\n+\t\t\t\t\t  slice,\n+\t\t\t\t\t  rc);\n+\t\treturn rc;\n+\t}\n+\treturn free_func(sess_idx, parms, row, slice, max_slices);\n+}\ndiff --git a/drivers/net/bnxt/tf_core/cfa_tcam_mgr_hwop_msg.h b/drivers/net/bnxt/tf_core/cfa_tcam_mgr_hwop_msg.h\nnew file mode 100644\nindex 0000000000..f7ba625c07\n--- /dev/null\n+++ b/drivers/net/bnxt/tf_core/cfa_tcam_mgr_hwop_msg.h\n@@ -0,0 +1,28 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2021-2023 Broadcom\n+ * All rights reserved.\n+ */\n+\n+#ifndef CFA_TCAM_MGR_HWOP_MSG_H\n+#define CFA_TCAM_MGR_HWOP_MSG_H\n+\n+int\n+cfa_tcam_mgr_hwops_init(enum cfa_tcam_mgr_device_type type);\n+\n+int\n+cfa_tcam_mgr_entry_set_msg(int sess_idx,\n+\t\t\t   struct cfa_tcam_mgr_context *context,\n+\t\t\t   struct cfa_tcam_mgr_set_parms *parms,\n+\t\t\t   int row, int slice, int max_slices);\n+int\n+cfa_tcam_mgr_entry_get_msg(int sess_idx,\n+\t\t\t   struct cfa_tcam_mgr_context *context,\n+\t\t\t   struct cfa_tcam_mgr_get_parms *parms,\n+\t\t\t   int row, int slice, int max_slices);\n+int\n+cfa_tcam_mgr_entry_free_msg(int sess_idx,\n+\t\t\t    struct cfa_tcam_mgr_context *context,\n+\t\t\t    struct cfa_tcam_mgr_free_parms *parms,\n+\t\t\t    int row, int slice, int key_size,\n+\t\t\t    int result_size, int max_slices);\n+#endif  /* CFA_TCAM_MGR_HWOP_MSG_H */\ndiff --git a/drivers/net/bnxt/tf_core/cfa_tcam_mgr_p4.c b/drivers/net/bnxt/tf_core/cfa_tcam_mgr_p4.c\nnew file mode 100644\nindex 0000000000..63c84c5938\n--- /dev/null\n+++ b/drivers/net/bnxt/tf_core/cfa_tcam_mgr_p4.c\n@@ -0,0 +1,921 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2021-2023 Broadcom\n+ * All rights reserved.\n+ */\n+\n+#include \"hcapi_cfa_defs.h\"\n+\n+#include \"cfa_tcam_mgr.h\"\n+#include \"cfa_tcam_mgr_p4.h\"\n+#include \"cfa_tcam_mgr_device.h\"\n+#include \"cfa_resource_types.h\"\n+#include \"tfp.h\"\n+#include \"assert.h\"\n+#include \"tf_util.h\"\n+\n+/*\n+ * Sizings of the TCAMs on P4\n+ */\n+\n+#define MAX_ROW_WIDTH    48\n+#define MAX_RESULT_SIZE  8\n+\n+#if MAX_ROW_WIDTH > CFA_TCAM_MGR_MAX_KEY_SIZE\n+#error MAX_ROW_WIDTH > CFA_TCAM_MGR_MAX_KEY_SIZE\n+#endif\n+\n+/*\n+ * TCAM definitions\n+ *\n+ * These define the TCAMs in HW.\n+ *\n+ * Note: Set xxx_TCAM_[R|T]X_NUM_ROWS to zero if a TCAM is either not supported\n+ * by HW or not supported by TCAM Manager.\n+ */\n+\n+/** L2 Context TCAM */\n+#define L2_CTXT_TCAM_RX_MAX_SLICES  1\n+#define L2_CTXT_TCAM_RX_ROW_WIDTH   TF_BITS2BYTES_WORD_ALIGN(167)\n+#define L2_CTXT_TCAM_RX_NUM_ROWS    1024\n+#define L2_CTXT_TCAM_RX_MAX_ENTRIES (L2_CTXT_TCAM_RX_MAX_SLICES * \\\n+\t\t\t\t     L2_CTXT_TCAM_RX_NUM_ROWS)\n+#define L2_CTXT_TCAM_RX_RESULT_SIZE 8\n+\n+#define L2_CTXT_TCAM_TX_MAX_SLICES  L2_CTXT_TCAM_RX_MAX_SLICES\n+#define L2_CTXT_TCAM_TX_ROW_WIDTH   L2_CTXT_TCAM_RX_ROW_WIDTH\n+#define L2_CTXT_TCAM_TX_NUM_ROWS    L2_CTXT_TCAM_RX_NUM_ROWS\n+#define L2_CTXT_TCAM_TX_MAX_ENTRIES L2_CTXT_TCAM_RX_MAX_ENTRIES\n+#define L2_CTXT_TCAM_TX_RESULT_SIZE L2_CTXT_TCAM_RX_RESULT_SIZE\n+\n+/** Profile TCAM */\n+#define PROF_TCAM_RX_MAX_SLICES  1\n+#define PROF_TCAM_RX_ROW_WIDTH   TF_BITS2BYTES_WORD_ALIGN(81)\n+#define PROF_TCAM_RX_NUM_ROWS    1024\n+#define PROF_TCAM_RX_MAX_ENTRIES (PROF_TCAM_RX_MAX_SLICES * \\\n+\t\t\t\t  PROF_TCAM_RX_NUM_ROWS)\n+#define PROF_TCAM_RX_RESULT_SIZE 8\n+\n+#define PROF_TCAM_TX_MAX_SLICES  PROF_TCAM_RX_MAX_SLICES\n+#define PROF_TCAM_TX_ROW_WIDTH   PROF_TCAM_RX_ROW_WIDTH\n+#define PROF_TCAM_TX_NUM_ROWS    PROF_TCAM_RX_NUM_ROWS\n+#define PROF_TCAM_TX_MAX_ENTRIES PROF_TCAM_RX_MAX_ENTRIES\n+#define PROF_TCAM_TX_RESULT_SIZE PROF_TCAM_RX_RESULT_SIZE\n+\n+/** Wildcard TCAM */\n+#define WC_TCAM_RX_MAX_SLICES  4\n+/* 82 bits per slice */\n+#define WC_TCAM_RX_ROW_WIDTH   (TF_BITS2BYTES_WORD_ALIGN(82) *\t\\\n+\t\t\t\tWC_TCAM_RX_MAX_SLICES)\n+#define WC_TCAM_RX_NUM_ROWS    256\n+#define WC_TCAM_RX_MAX_ENTRIES (WC_TCAM_RX_MAX_SLICES * WC_TCAM_RX_NUM_ROWS)\n+#define WC_TCAM_RX_RESULT_SIZE 4\n+\n+#define WC_TCAM_TX_MAX_SLICES  WC_TCAM_RX_MAX_SLICES\n+#define WC_TCAM_TX_ROW_WIDTH   WC_TCAM_RX_ROW_WIDTH\n+#define WC_TCAM_TX_NUM_ROWS    WC_TCAM_RX_NUM_ROWS\n+#define WC_TCAM_TX_MAX_ENTRIES WC_TCAM_RX_MAX_ENTRIES\n+#define WC_TCAM_TX_RESULT_SIZE WC_TCAM_RX_RESULT_SIZE\n+\n+/** Source Properties TCAM */\n+#define SP_TCAM_RX_MAX_SLICES  1\n+#define SP_TCAM_RX_ROW_WIDTH   TF_BITS2BYTES_WORD_ALIGN(89)\n+#define SP_TCAM_RX_NUM_ROWS    512\n+#define SP_TCAM_RX_MAX_ENTRIES (SP_TCAM_RX_MAX_SLICES * SP_TCAM_RX_NUM_ROWS)\n+#define SP_TCAM_RX_RESULT_SIZE 8\n+\n+#define SP_TCAM_TX_MAX_SLICES  SP_TCAM_RX_MAX_SLICES\n+#define SP_TCAM_TX_ROW_WIDTH   SP_TCAM_RX_ROW_WIDTH\n+#define SP_TCAM_TX_NUM_ROWS    SP_TCAM_RX_NUM_ROWS\n+#define SP_TCAM_TX_MAX_ENTRIES SP_TCAM_RX_MAX_ENTRIES\n+#define SP_TCAM_TX_RESULT_SIZE SP_TCAM_RX_RESULT_SIZE\n+\n+/** Connection Tracking Rule TCAM */\n+#define CT_RULE_TCAM_RX_MAX_SLICES  1\n+#define CT_RULE_TCAM_RX_ROW_WIDTH   TF_BITS2BYTES_WORD_ALIGN(16)\n+#define CT_RULE_TCAM_RX_NUM_ROWS    0\n+#define CT_RULE_TCAM_RX_MAX_ENTRIES (CT_RULE_TCAM_RX_MAX_SLICES * \\\n+\t\t\t\t     CT_RULE_TCAM_RX_NUM_ROWS)\n+#define CT_RULE_TCAM_RX_RESULT_SIZE 8\n+\n+#define CT_RULE_TCAM_TX_MAX_SLICES  CT_RULE_TCAM_RX_MAX_SLICES\n+#define CT_RULE_TCAM_TX_ROW_WIDTH   CT_RULE_TCAM_RX_ROW_WIDTH\n+#define CT_RULE_TCAM_TX_NUM_ROWS    CT_RULE_TCAM_RX_NUM_ROWS\n+#define CT_RULE_TCAM_TX_MAX_ENTRIES CT_RULE_TCAM_RX_MAX_ENTRIES\n+#define CT_RULE_TCAM_TX_RESULT_SIZE CT_RULE_TCAM_RX_RESULT_SIZE\n+\n+/** Virtual Edge Bridge TCAM */\n+#define VEB_TCAM_RX_MAX_SLICES  1\n+#define VEB_TCAM_RX_ROW_WIDTH   TF_BITS2BYTES_WORD_ALIGN(78)\n+/* Tx only */\n+#define VEB_TCAM_RX_NUM_ROWS    0\n+#define VEB_TCAM_RX_MAX_ENTRIES (VEB_TCAM_RX_MAX_SLICES * VEB_TCAM_RX_NUM_ROWS)\n+#define VEB_TCAM_RX_RESULT_SIZE 8\n+\n+#define VEB_TCAM_TX_MAX_SLICES  VEB_TCAM_RX_MAX_SLICES\n+#define VEB_TCAM_TX_ROW_WIDTH   VEB_TCAM_RX_ROW_WIDTH\n+#define VEB_TCAM_TX_NUM_ROWS    1024\n+#define VEB_TCAM_TX_MAX_ENTRIES (VEB_TCAM_TX_MAX_SLICES * VEB_TCAM_TX_NUM_ROWS)\n+#define VEB_TCAM_TX_RESULT_SIZE VEB_TCAM_RX_RESULT_SIZE\n+\n+/* Declare the table rows for each table here.  If new tables are added to the\n+ * enum tf_tcam_tbl_type, then new declarations will be needed here.\n+ *\n+ * The numeric suffix of the structure type indicates how many slices a\n+ * particular TCAM supports.\n+ *\n+ * Array sizes have 1 added to avoid zero length arrays.\n+ */\n+\n+static struct cfa_tcam_mgr_table_rows_1\n+\tcfa_tcam_mgr_table_rows_L2_CTXT_TCAM_RX[TF_TCAM_MAX_SESSIONS][L2_CTXT_TCAM_RX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_1\n+\tcfa_tcam_mgr_table_rows_L2_CTXT_TCAM_TX[TF_TCAM_MAX_SESSIONS][L2_CTXT_TCAM_TX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_1\n+\tcfa_tcam_mgr_table_rows_PROF_TCAM_RX[TF_TCAM_MAX_SESSIONS][PROF_TCAM_RX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_1\n+\tcfa_tcam_mgr_table_rows_PROF_TCAM_TX[TF_TCAM_MAX_SESSIONS][PROF_TCAM_TX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_4\n+\tcfa_tcam_mgr_table_rows_WC_TCAM_RX[TF_TCAM_MAX_SESSIONS][WC_TCAM_RX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_4\n+\tcfa_tcam_mgr_table_rows_WC_TCAM_TX[TF_TCAM_MAX_SESSIONS][WC_TCAM_TX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_1\n+\tcfa_tcam_mgr_table_rows_SP_TCAM_RX[TF_TCAM_MAX_SESSIONS][SP_TCAM_RX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_1\n+\tcfa_tcam_mgr_table_rows_SP_TCAM_TX[TF_TCAM_MAX_SESSIONS][SP_TCAM_TX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_1\n+\tcfa_tcam_mgr_table_rows_CT_RULE_TCAM_RX[TF_TCAM_MAX_SESSIONS][CT_RULE_TCAM_RX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_1\n+\tcfa_tcam_mgr_table_rows_CT_RULE_TCAM_TX[TF_TCAM_MAX_SESSIONS][CT_RULE_TCAM_TX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_1\n+\tcfa_tcam_mgr_table_rows_VEB_TCAM_RX[TF_TCAM_MAX_SESSIONS][VEB_TCAM_RX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_1\n+\tcfa_tcam_mgr_table_rows_VEB_TCAM_TX[TF_TCAM_MAX_SESSIONS][VEB_TCAM_TX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_4\n+\tcfa_tcam_mgr_table_rows_WC_TCAM_RX_HIGH[TF_TCAM_MAX_SESSIONS][WC_TCAM_RX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_4\n+\tcfa_tcam_mgr_table_rows_WC_TCAM_RX_LOW[TF_TCAM_MAX_SESSIONS][WC_TCAM_RX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_4\n+\tcfa_tcam_mgr_table_rows_WC_TCAM_TX_HIGH[TF_TCAM_MAX_SESSIONS][WC_TCAM_TX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_4\n+\tcfa_tcam_mgr_table_rows_WC_TCAM_TX_LOW[TF_TCAM_MAX_SESSIONS][WC_TCAM_TX_NUM_ROWS + 1];\n+\n+struct cfa_tcam_mgr_table_data\n+cfa_tcam_mgr_tables_p4[TF_DIR_MAX][CFA_TCAM_MGR_TBL_TYPE_MAX] = {\n+\t{\t\t\t\t/* RX */\n+\t\t{\t\t\t/* High AFM */\n+\t\t\t.max_slices  = L2_CTXT_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = L2_CTXT_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = L2_CTXT_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = L2_CTXT_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_HIGH,\n+\t\t},\n+\t\t{\t\t\t/* High APPS */\n+\t\t\t.max_slices  = L2_CTXT_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = L2_CTXT_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = L2_CTXT_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = (L2_CTXT_TCAM_RX_NUM_ROWS / 2) - 1,\n+\t\t\t.max_entries = (L2_CTXT_TCAM_RX_MAX_ENTRIES / 2),\n+\t\t\t.result_size = L2_CTXT_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_HIGH,\n+\t\t},\n+\t\t{\t\t\t/* Low AFM */\n+\t\t\t.max_slices  = L2_CTXT_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = L2_CTXT_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = L2_CTXT_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = L2_CTXT_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_LOW,\n+\t\t},\n+\t\t{\t\t\t/* Low APPS */\n+\t\t\t.max_slices  = L2_CTXT_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = L2_CTXT_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = L2_CTXT_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = (L2_CTXT_TCAM_RX_NUM_ROWS / 2),\n+\t\t\t.end_row     = L2_CTXT_TCAM_RX_NUM_ROWS - 1,\n+\t\t\t.max_entries = (L2_CTXT_TCAM_RX_MAX_ENTRIES / 2),\n+\t\t\t.result_size = L2_CTXT_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_LOW,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = PROF_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = PROF_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = PROF_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = PROF_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P4_PROF_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = PROF_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = PROF_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = PROF_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = PROF_TCAM_RX_NUM_ROWS - 1,\n+\t\t\t.max_entries = PROF_TCAM_RX_MAX_ENTRIES,\n+\t\t\t.result_size = PROF_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P4_PROF_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = WC_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = WC_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = WC_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = WC_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P4_WC_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = WC_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = WC_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = WC_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = WC_TCAM_RX_NUM_ROWS - 1,\n+\t\t\t.max_entries = WC_TCAM_RX_MAX_ENTRIES,\n+\t\t\t.result_size = WC_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P4_WC_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = SP_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = SP_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = SP_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = SP_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P4_SP_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = SP_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = SP_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = SP_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = SP_TCAM_RX_NUM_ROWS - 1,\n+\t\t\t.max_entries = SP_TCAM_RX_MAX_ENTRIES,\n+\t\t\t.result_size = SP_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P4_SP_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = CT_RULE_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = CT_RULE_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = CT_RULE_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = CT_RULE_TCAM_RX_RESULT_SIZE,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = CT_RULE_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = CT_RULE_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = CT_RULE_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+#if CT_RULE_TCAM_RX_NUM_ROWS > 0\n+\t\t\t.end_row     = CT_RULE_TCAM_RX_NUM_ROWS - 1,\n+#else\n+\t\t\t.end_row     = CT_RULE_TCAM_RX_NUM_ROWS,\n+#endif\n+\t\t\t.max_entries = CT_RULE_TCAM_RX_MAX_ENTRIES,\n+\t\t\t.result_size = CT_RULE_TCAM_RX_RESULT_SIZE,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = VEB_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = VEB_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = VEB_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = VEB_TCAM_RX_RESULT_SIZE,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = VEB_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = VEB_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = VEB_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+#if VEB_TCAM_RX_NUM_ROWS > 0\n+\t\t\t.end_row     = VEB_TCAM_RX_NUM_ROWS - 1,\n+#else\n+\t\t\t.end_row     = VEB_TCAM_RX_NUM_ROWS,\n+#endif\n+\t\t\t.max_entries = VEB_TCAM_RX_MAX_ENTRIES,\n+\t\t\t.result_size = VEB_TCAM_RX_RESULT_SIZE,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = WC_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = WC_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = WC_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = WC_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P4_WC_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = WC_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = WC_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = WC_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = WC_TCAM_RX_NUM_ROWS - 1,\n+\t\t\t.max_entries = WC_TCAM_RX_MAX_ENTRIES,\n+\t\t\t.result_size = WC_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P4_WC_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = WC_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = WC_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = WC_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = WC_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P4_WC_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = WC_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = WC_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = WC_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = WC_TCAM_RX_NUM_ROWS - 1,\n+\t\t\t.max_entries = WC_TCAM_RX_MAX_ENTRIES,\n+\t\t\t.result_size = WC_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P4_WC_TCAM,\n+\t\t},\n+\t},\n+\t{\t\t\t\t/* TX */\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = L2_CTXT_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = L2_CTXT_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = L2_CTXT_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = L2_CTXT_TCAM_TX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_HIGH,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = L2_CTXT_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = L2_CTXT_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = L2_CTXT_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = (L2_CTXT_TCAM_TX_NUM_ROWS / 2) - 1,\n+\t\t\t.max_entries = (L2_CTXT_TCAM_TX_MAX_ENTRIES / 2),\n+\t\t\t.result_size = L2_CTXT_TCAM_TX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_HIGH,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = L2_CTXT_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = L2_CTXT_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = L2_CTXT_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = L2_CTXT_TCAM_TX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_LOW,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = L2_CTXT_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = L2_CTXT_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = L2_CTXT_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = (L2_CTXT_TCAM_TX_NUM_ROWS / 2),\n+\t\t\t.end_row     = L2_CTXT_TCAM_TX_NUM_ROWS - 1,\n+\t\t\t.max_entries = (L2_CTXT_TCAM_TX_MAX_ENTRIES / 2),\n+\t\t\t.result_size = L2_CTXT_TCAM_TX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_LOW,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = PROF_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = PROF_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = PROF_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = PROF_TCAM_TX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P4_PROF_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = PROF_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = PROF_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = PROF_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = PROF_TCAM_TX_NUM_ROWS - 1,\n+\t\t\t.max_entries = PROF_TCAM_TX_MAX_ENTRIES,\n+\t\t\t.result_size = PROF_TCAM_TX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P4_PROF_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = WC_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = WC_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = WC_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = WC_TCAM_TX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P4_WC_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = WC_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = WC_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = WC_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = WC_TCAM_TX_NUM_ROWS - 1,\n+\t\t\t.max_entries = WC_TCAM_TX_MAX_ENTRIES,\n+\t\t\t.result_size = WC_TCAM_TX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P4_WC_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = SP_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = SP_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = SP_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = SP_TCAM_TX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P4_SP_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = SP_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = SP_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = SP_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = SP_TCAM_TX_NUM_ROWS - 1,\n+\t\t\t.max_entries = SP_TCAM_TX_MAX_ENTRIES,\n+\t\t\t.result_size = SP_TCAM_TX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P4_SP_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = CT_RULE_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = CT_RULE_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = CT_RULE_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = CT_RULE_TCAM_RX_RESULT_SIZE,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = CT_RULE_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = CT_RULE_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = CT_RULE_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+#if CT_RULE_TCAM_TX_NUM_ROWS > 0\n+\t\t\t.end_row     = CT_RULE_TCAM_TX_NUM_ROWS - 1,\n+#else\n+\t\t\t.end_row     = CT_RULE_TCAM_TX_NUM_ROWS,\n+#endif\n+\t\t\t.max_entries = CT_RULE_TCAM_TX_MAX_ENTRIES,\n+\t\t\t.result_size = CT_RULE_TCAM_RX_RESULT_SIZE,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = VEB_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = VEB_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = VEB_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = VEB_TCAM_RX_RESULT_SIZE,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = VEB_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = VEB_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = VEB_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = VEB_TCAM_TX_NUM_ROWS - 1,\n+\t\t\t.max_entries = VEB_TCAM_TX_MAX_ENTRIES,\n+\t\t\t.result_size = VEB_TCAM_RX_RESULT_SIZE,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = WC_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = WC_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = WC_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = WC_TCAM_TX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P4_WC_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = WC_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = WC_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = WC_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = WC_TCAM_TX_NUM_ROWS - 1,\n+\t\t\t.max_entries = WC_TCAM_TX_MAX_ENTRIES,\n+\t\t\t.result_size = WC_TCAM_TX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P4_WC_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = WC_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = WC_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = WC_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = WC_TCAM_TX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P4_WC_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = WC_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = WC_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = WC_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = WC_TCAM_TX_NUM_ROWS - 1,\n+\t\t\t.max_entries = WC_TCAM_TX_MAX_ENTRIES,\n+\t\t\t.result_size = WC_TCAM_TX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P4_WC_TCAM,\n+\t\t},\n+\t},\n+};\n+\n+static struct cfa_tcam_mgr_entry_data entry_data_p4[TF_TCAM_MAX_SESSIONS][TF_TCAM_MAX_ENTRIES];\n+\n+static struct sbmp session_bmp_p4[TF_TCAM_MAX_SESSIONS][TF_TCAM_MAX_ENTRIES];\n+\n+int\n+cfa_tcam_mgr_sess_table_get_p4(int sess_idx, struct sbmp **session_bmp)\n+{\n+\t*session_bmp = session_bmp_p4[sess_idx];\n+\treturn 0;\n+}\n+\n+int\n+cfa_tcam_mgr_init_p4(int sess_idx, struct cfa_tcam_mgr_entry_data **global_entry_data)\n+{\n+\tint max_row_width = 0;\n+\tint max_result_size = 0;\n+\tint dir, type;\n+\n+\t*global_entry_data = entry_data_p4[sess_idx];\n+\n+\tmemcpy(&cfa_tcam_mgr_tables[sess_idx],\n+\t       &cfa_tcam_mgr_tables_p4,\n+\t       sizeof(cfa_tcam_mgr_tables[sess_idx]));\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_HIGH_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_L2_CTXT_TCAM_RX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_HIGH_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_L2_CTXT_TCAM_RX[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_HIGH_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_L2_CTXT_TCAM_TX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_HIGH_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_L2_CTXT_TCAM_TX[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_LOW_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_L2_CTXT_TCAM_RX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_LOW_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_L2_CTXT_TCAM_RX[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_LOW_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_L2_CTXT_TCAM_TX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_LOW_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_L2_CTXT_TCAM_TX[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_PROF_TCAM_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_PROF_TCAM_RX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_PROF_TCAM_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_PROF_TCAM_RX[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_PROF_TCAM_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_PROF_TCAM_TX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_PROF_TCAM_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_PROF_TCAM_TX[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_WC_TCAM_RX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_WC_TCAM_RX[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_WC_TCAM_TX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_WC_TCAM_TX[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_SP_TCAM_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_SP_TCAM_RX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_SP_TCAM_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_SP_TCAM_RX[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_SP_TCAM_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_SP_TCAM_TX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_SP_TCAM_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_SP_TCAM_TX[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_CT_RULE_TCAM_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_CT_RULE_TCAM_RX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_CT_RULE_TCAM_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_CT_RULE_TCAM_RX[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_CT_RULE_TCAM_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_CT_RULE_TCAM_TX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_CT_RULE_TCAM_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_CT_RULE_TCAM_TX[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_VEB_TCAM_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_VEB_TCAM_RX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_VEB_TCAM_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_VEB_TCAM_RX[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_VEB_TCAM_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_VEB_TCAM_TX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_VEB_TCAM_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_VEB_TCAM_TX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_WC_TCAM_RX_HIGH[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_WC_TCAM_RX_HIGH[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_WC_TCAM_TX_HIGH[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_WC_TCAM_TX_HIGH[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_WC_TCAM_RX_LOW[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_WC_TCAM_RX_LOW[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_WC_TCAM_TX_LOW[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_WC_TCAM_TX_LOW[sess_idx];\n+\n+\tfor (dir = 0; dir < TF_DIR_MAX; dir++) {\n+\t\tfor (type = 0; type < CFA_TCAM_MGR_TBL_TYPE_MAX; type++) {\n+\t\t\tif (cfa_tcam_mgr_tables[sess_idx][dir][type].row_width >\n+\t\t\t    max_row_width)\n+\t\t\t\tmax_row_width =\n+\t\t\t\t       cfa_tcam_mgr_tables[sess_idx][dir][type].row_width;\n+\t\t\tif (cfa_tcam_mgr_tables[sess_idx][dir][type].result_size >\n+\t\t\t    max_result_size)\n+\t\t\t\tmax_result_size =\n+\t\t\t\t     cfa_tcam_mgr_tables[sess_idx][dir][type].result_size;\n+\t\t}\n+\t}\n+\n+\tif (max_row_width != MAX_ROW_WIDTH) {\n+\t\tCFA_TCAM_MGR_LOG(ERR,\n+\t\t\t\t \"MAX_ROW_WIDTH (%d) does not match actual \"\n+\t\t\t\t \"value (%d).\\n\",\n+\t\t\t\t MAX_ROW_WIDTH,\n+\t\t\t\t max_row_width);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\n+\t}\n+\tif (max_result_size != MAX_RESULT_SIZE) {\n+\t\tCFA_TCAM_MGR_LOG(ERR,\n+\t\t\t\t \"MAX_RESULT_SIZE (%d) does not match actual \"\n+\t\t\t\t \"value (%d).\\n\",\n+\t\t\t\t MAX_RESULT_SIZE,\n+\t\t\t\t max_result_size);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\n+\t}\n+\treturn 0;\n+}\n+\n+/* HW OP declarations begin here */\n+struct cfa_tcam_mgr_TCAM_row_data {\n+\tint key_size;\n+\tint result_size;\n+\tuint8_t key[MAX_ROW_WIDTH];\n+\tuint8_t mask[MAX_ROW_WIDTH];\n+\tuint8_t result[MAX_RESULT_SIZE];\n+};\n+\n+/* These macros are only needed to avoid exceeding 80 columns */\n+#define L2_CTXT_RX_MAX_ROWS \\\n+\t(L2_CTXT_TCAM_RX_MAX_SLICES * L2_CTXT_TCAM_RX_NUM_ROWS)\n+#define PROF_RX_MAX_ROWS    (PROF_TCAM_RX_MAX_SLICES * PROF_TCAM_RX_NUM_ROWS)\n+#define WC_RX_MAX_ROWS\t    (WC_TCAM_RX_MAX_SLICES * WC_TCAM_RX_NUM_ROWS)\n+#define SP_RX_MAX_ROWS\t    (SP_TCAM_RX_MAX_SLICES * SP_TCAM_RX_NUM_ROWS)\n+#define CT_RULE_RX_MAX_ROWS \\\n+\t(CT_RULE_TCAM_RX_MAX_SLICES * CT_RULE_TCAM_RX_NUM_ROWS)\n+#define VEB_RX_MAX_ROWS\t    (VEB_TCAM_RX_MAX_SLICES * VEB_TCAM_RX_NUM_ROWS)\n+\n+#define L2_CTXT_TX_MAX_ROWS \\\n+\t(L2_CTXT_TCAM_TX_MAX_SLICES * L2_CTXT_TCAM_TX_NUM_ROWS)\n+#define PROF_TX_MAX_ROWS    (PROF_TCAM_TX_MAX_SLICES * PROF_TCAM_TX_NUM_ROWS)\n+#define WC_TX_MAX_ROWS\t    (WC_TCAM_TX_MAX_SLICES * WC_TCAM_TX_NUM_ROWS)\n+#define SP_TX_MAX_ROWS\t    (SP_TCAM_TX_MAX_SLICES * SP_TCAM_TX_NUM_ROWS)\n+#define CT_RULE_TX_MAX_ROWS \\\n+\t(CT_RULE_TCAM_TX_MAX_SLICES * CT_RULE_TCAM_TX_NUM_ROWS)\n+#define VEB_TX_MAX_ROWS\t    (VEB_TCAM_TX_MAX_SLICES * VEB_TCAM_TX_NUM_ROWS)\n+\n+static int cfa_tcam_mgr_max_rows[TF_TCAM_TBL_TYPE_MAX] = {\n+\tL2_CTXT_RX_MAX_ROWS,\n+\tL2_CTXT_RX_MAX_ROWS,\n+\tPROF_RX_MAX_ROWS,\n+\tWC_RX_MAX_ROWS,\n+\tSP_RX_MAX_ROWS,\n+\tCT_RULE_RX_MAX_ROWS,\n+\tVEB_RX_MAX_ROWS,\n+\tWC_RX_MAX_ROWS,\n+\tWC_RX_MAX_ROWS\n+};\n+static struct cfa_tcam_mgr_TCAM_row_data\n+\tcfa_tcam_mgr_L2_CTXT_TCAM_RX_row_data[TF_TCAM_MAX_SESSIONS][L2_CTXT_RX_MAX_ROWS];\n+static struct cfa_tcam_mgr_TCAM_row_data\n+\tcfa_tcam_mgr_PROF_TCAM_RX_row_data[TF_TCAM_MAX_SESSIONS][PROF_RX_MAX_ROWS];\n+static struct cfa_tcam_mgr_TCAM_row_data\n+\tcfa_tcam_mgr_WC_TCAM_RX_row_data[TF_TCAM_MAX_SESSIONS][WC_RX_MAX_ROWS];\n+static struct cfa_tcam_mgr_TCAM_row_data\n+\tcfa_tcam_mgr_SP_TCAM_RX_row_data[TF_TCAM_MAX_SESSIONS][SP_RX_MAX_ROWS];\n+static struct cfa_tcam_mgr_TCAM_row_data\n+\tcfa_tcam_mgr_CT_RULE_TCAM_RX_row_data[TF_TCAM_MAX_SESSIONS][CT_RULE_RX_MAX_ROWS];\n+static struct cfa_tcam_mgr_TCAM_row_data\n+\tcfa_tcam_mgr_VEB_TCAM_RX_row_data[TF_TCAM_MAX_SESSIONS][VEB_RX_MAX_ROWS];\n+static struct cfa_tcam_mgr_TCAM_row_data\n+\tcfa_tcam_mgr_WC_TCAM_RX_row_data[TF_TCAM_MAX_SESSIONS][WC_RX_MAX_ROWS];\n+\n+static struct cfa_tcam_mgr_TCAM_row_data\n+\tcfa_tcam_mgr_L2_CTXT_TCAM_TX_row_data[TF_TCAM_MAX_SESSIONS][L2_CTXT_TX_MAX_ROWS];\n+static struct cfa_tcam_mgr_TCAM_row_data\n+\tcfa_tcam_mgr_PROF_TCAM_TX_row_data[TF_TCAM_MAX_SESSIONS][PROF_TX_MAX_ROWS];\n+static struct cfa_tcam_mgr_TCAM_row_data\n+\tcfa_tcam_mgr_WC_TCAM_TX_row_data[TF_TCAM_MAX_SESSIONS][WC_TX_MAX_ROWS];\n+static struct cfa_tcam_mgr_TCAM_row_data\n+\tcfa_tcam_mgr_SP_TCAM_TX_row_data[TF_TCAM_MAX_SESSIONS][SP_TX_MAX_ROWS];\n+static struct cfa_tcam_mgr_TCAM_row_data\n+\tcfa_tcam_mgr_CT_RULE_TCAM_TX_row_data[TF_TCAM_MAX_SESSIONS][CT_RULE_TX_MAX_ROWS];\n+static struct cfa_tcam_mgr_TCAM_row_data\n+\tcfa_tcam_mgr_VEB_TCAM_TX_row_data[TF_TCAM_MAX_SESSIONS][VEB_TX_MAX_ROWS];\n+static struct cfa_tcam_mgr_TCAM_row_data\n+\tcfa_tcam_mgr_WC_TCAM_TX_row_data[TF_TCAM_MAX_SESSIONS][WC_TX_MAX_ROWS];\n+\n+static struct cfa_tcam_mgr_TCAM_row_data *\n+row_tables[TF_DIR_MAX][TF_TCAM_TBL_TYPE_MAX] = {\n+\t{\n+\t\tcfa_tcam_mgr_L2_CTXT_TCAM_RX_row_data[0],\n+\t\tcfa_tcam_mgr_L2_CTXT_TCAM_RX_row_data[0],\n+\t\tcfa_tcam_mgr_PROF_TCAM_RX_row_data[0],\n+\t\tcfa_tcam_mgr_WC_TCAM_RX_row_data[0],\n+\t\tcfa_tcam_mgr_SP_TCAM_RX_row_data[0],\n+\t\tcfa_tcam_mgr_CT_RULE_TCAM_RX_row_data[0],\n+\t\tcfa_tcam_mgr_VEB_TCAM_RX_row_data[0],\n+\t\tcfa_tcam_mgr_WC_TCAM_RX_row_data[0],\n+\t\tcfa_tcam_mgr_WC_TCAM_RX_row_data[0],\n+\t},\n+\t{\n+\t\tcfa_tcam_mgr_L2_CTXT_TCAM_TX_row_data[0],\n+\t\tcfa_tcam_mgr_L2_CTXT_TCAM_TX_row_data[0],\n+\t\tcfa_tcam_mgr_PROF_TCAM_TX_row_data[0],\n+\t\tcfa_tcam_mgr_WC_TCAM_TX_row_data[0],\n+\t\tcfa_tcam_mgr_SP_TCAM_TX_row_data[0],\n+\t\tcfa_tcam_mgr_CT_RULE_TCAM_TX_row_data[0],\n+\t\tcfa_tcam_mgr_VEB_TCAM_TX_row_data[0],\n+\t\tcfa_tcam_mgr_WC_TCAM_TX_row_data[0],\n+\t\tcfa_tcam_mgr_WC_TCAM_TX_row_data[0],\n+\t}\n+};\n+\n+static int cfa_tcam_mgr_get_max_rows(enum tf_tcam_tbl_type type)\n+{\n+\tif (type >= TF_TCAM_TBL_TYPE_MAX)\n+\t\tassert(0);\n+\telse\n+\t\treturn cfa_tcam_mgr_max_rows[type];\n+}\n+\n+static int cfa_tcam_mgr_hwop_set(int sess_idx,\n+\t\t\t\t struct cfa_tcam_mgr_set_parms *parms, int row,\n+\t\t\t\t int slice, int max_slices)\n+{\n+\tstruct cfa_tcam_mgr_TCAM_row_data *this_table;\n+\tstruct cfa_tcam_mgr_TCAM_row_data *this_row;\n+\tthis_table = row_tables[parms->dir]\n+\t\t[cfa_tcam_mgr_get_phys_table_type(parms->type)];\n+\tthis_table += (sess_idx *\n+\t\t       cfa_tcam_mgr_get_max_rows(cfa_tcam_mgr_get_phys_table_type(parms->type)));\n+\tthis_row   = &this_table[row * max_slices + slice];\n+\tthis_row->key_size = parms->key_size;\n+\tmemcpy(&this_row->key, parms->key, parms->key_size);\n+\tmemcpy(&this_row->mask, parms->mask, parms->key_size);\n+\tthis_row->result_size = parms->result_size;\n+\tif (parms->result != ((void *)0))\n+\t\tmemcpy(&this_row->result, parms->result, parms->result_size);\n+\treturn 0;\n+};\n+\n+static int cfa_tcam_mgr_hwop_get(int sess_idx,\n+\t\t\t\t struct cfa_tcam_mgr_get_parms *parms, int row,\n+\t\t\t\t int slice, int max_slices)\n+{\n+\tstruct cfa_tcam_mgr_TCAM_row_data *this_table;\n+\tstruct cfa_tcam_mgr_TCAM_row_data *this_row;\n+\tthis_table = row_tables[parms->dir]\n+\t\t[cfa_tcam_mgr_get_phys_table_type(parms->type)];\n+\tthis_table += (sess_idx *\n+\t\t       cfa_tcam_mgr_get_max_rows(cfa_tcam_mgr_get_phys_table_type(parms->type)));\n+\tthis_row   = &this_table[row * max_slices + slice];\n+\tparms->key_size = this_row->key_size;\n+\tparms->result_size = this_row->result_size;\n+\tif (parms->key != ((void *)0))\n+\t\tmemcpy(parms->key, &this_row->key, parms->key_size);\n+\tif (parms->mask != ((void *)0))\n+\t\tmemcpy(parms->mask, &this_row->mask, parms->key_size);\n+\tif (parms->result != ((void *)0))\n+\t\tmemcpy(parms->result, &this_row->result, parms->result_size);\n+\treturn 0;\n+};\n+\n+static int cfa_tcam_mgr_hwop_free(int sess_idx,\n+\t\t\t\t  struct cfa_tcam_mgr_free_parms *parms,\n+\t\t\t\t  int row, int slice, int max_slices)\n+{\n+\tstruct cfa_tcam_mgr_TCAM_row_data *this_table;\n+\tstruct cfa_tcam_mgr_TCAM_row_data *this_row;\n+\tthis_table = row_tables[parms->dir]\n+\t\t[cfa_tcam_mgr_get_phys_table_type(parms->type)];\n+\tthis_table += (sess_idx *\n+\t\t       cfa_tcam_mgr_get_max_rows(cfa_tcam_mgr_get_phys_table_type(parms->type)));\n+\tthis_row   = &this_table[row * max_slices + slice];\n+\tmemset(&this_row->key, 0, sizeof(this_row->key));\n+\tmemset(&this_row->mask, 0, sizeof(this_row->mask));\n+\tmemset(&this_row->result, 0, sizeof(this_row->result));\n+\tthis_row->key_size = 0;\n+\tthis_row->result_size = 0;\n+\treturn 0;\n+};\n+\n+int cfa_tcam_mgr_hwops_get_funcs_p4(struct cfa_tcam_mgr_hwops_funcs *hwop_funcs)\n+{\n+\thwop_funcs->set\t = cfa_tcam_mgr_hwop_set;\n+\thwop_funcs->get\t = cfa_tcam_mgr_hwop_get;\n+\thwop_funcs->free = cfa_tcam_mgr_hwop_free;\n+\treturn 0;\n+}\ndiff --git a/drivers/net/bnxt/tf_core/cfa_tcam_mgr_p4.h b/drivers/net/bnxt/tf_core/cfa_tcam_mgr_p4.h\nnew file mode 100644\nindex 0000000000..3ca59b2aeb\n--- /dev/null\n+++ b/drivers/net/bnxt/tf_core/cfa_tcam_mgr_p4.h\n@@ -0,0 +1,20 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2021-2023 Broadcom\n+ * All rights reserved.\n+ */\n+\n+#ifndef CFA_TCAM_MGR_P4_H\n+#define CFA_TCAM_MGR_P4_H\n+\n+#include \"cfa_tcam_mgr_device.h\"\n+#include \"cfa_tcam_mgr_sbmp.h\"\n+\n+int\n+cfa_tcam_mgr_init_p4(int sess_idx, struct cfa_tcam_mgr_entry_data **global_entry_data);\n+\n+int\n+cfa_tcam_mgr_sess_table_get_p4(int sess_idx, struct sbmp **session_bmp);\n+\n+int\n+cfa_tcam_mgr_hwops_get_funcs_p4(struct cfa_tcam_mgr_hwops_funcs *hwop_funcs);\n+#endif /* CFA_TCAM_MGR_P4_H */\ndiff --git a/drivers/net/bnxt/tf_core/cfa_tcam_mgr_p58.c b/drivers/net/bnxt/tf_core/cfa_tcam_mgr_p58.c\nnew file mode 100644\nindex 0000000000..c9a04dc4e9\n--- /dev/null\n+++ b/drivers/net/bnxt/tf_core/cfa_tcam_mgr_p58.c\n@@ -0,0 +1,926 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2021-2023 Broadcom\n+ * All rights reserved.\n+ */\n+\n+#include \"hcapi_cfa_defs.h\"\n+\n+#include \"cfa_tcam_mgr.h\"\n+#include \"cfa_tcam_mgr_p58.h\"\n+#include \"cfa_tcam_mgr.h\"\n+#include \"cfa_tcam_mgr_device.h\"\n+#include \"cfa_resource_types.h\"\n+#include \"tfp.h\"\n+#include \"assert.h\"\n+#include \"tf_util.h\"\n+\n+/*\n+ * Sizings of the TCAMs on P5\n+ */\n+\n+#define MAX_ROW_WIDTH    96\n+#define MAX_RESULT_SIZE  8\n+\n+#if MAX_ROW_WIDTH > CFA_TCAM_MGR_MAX_KEY_SIZE\n+#error MAX_ROW_WIDTH > CFA_TCAM_MGR_MAX_KEY_SIZE\n+#endif\n+\n+/*\n+ * TCAM definitions\n+ *\n+ * These define the TCAMs in HW.\n+ *\n+ * Note: Set xxx_TCAM_[R|T]X_NUM_ROWS to zero if a TCAM is either not supported\n+ * by HW or not supported by TCAM Manager.\n+ */\n+\n+/** L2 Context TCAM */\n+#define L2_CTXT_TCAM_RX_MAX_SLICES  1\n+#define L2_CTXT_TCAM_RX_ROW_WIDTH   TF_BITS2BYTES_64B_WORD_ALIGN(214)\n+#define L2_CTXT_TCAM_RX_NUM_ROWS    1024\n+#define L2_CTXT_TCAM_RX_MAX_ENTRIES (L2_CTXT_TCAM_RX_MAX_SLICES * \\\n+\t\t\t\t     L2_CTXT_TCAM_RX_NUM_ROWS)\n+#define L2_CTXT_TCAM_RX_RESULT_SIZE 8\n+\n+#define L2_CTXT_TCAM_TX_MAX_SLICES  L2_CTXT_TCAM_RX_MAX_SLICES\n+#define L2_CTXT_TCAM_TX_ROW_WIDTH   L2_CTXT_TCAM_RX_ROW_WIDTH\n+#define L2_CTXT_TCAM_TX_NUM_ROWS    L2_CTXT_TCAM_RX_NUM_ROWS\n+#define L2_CTXT_TCAM_TX_MAX_ENTRIES L2_CTXT_TCAM_RX_MAX_ENTRIES\n+#define L2_CTXT_TCAM_TX_RESULT_SIZE L2_CTXT_TCAM_RX_RESULT_SIZE\n+\n+/** Profile TCAM */\n+#define PROF_TCAM_RX_MAX_SLICES  1\n+#define PROF_TCAM_RX_ROW_WIDTH   TF_BITS2BYTES_64B_WORD_ALIGN(94)\n+#define PROF_TCAM_RX_NUM_ROWS    256\n+#define PROF_TCAM_RX_MAX_ENTRIES (PROF_TCAM_RX_MAX_SLICES * \\\n+\t\t\t\t  PROF_TCAM_RX_NUM_ROWS)\n+#define PROF_TCAM_RX_RESULT_SIZE 8\n+\n+#define PROF_TCAM_TX_MAX_SLICES  PROF_TCAM_RX_MAX_SLICES\n+#define PROF_TCAM_TX_ROW_WIDTH   PROF_TCAM_RX_ROW_WIDTH\n+#define PROF_TCAM_TX_NUM_ROWS    PROF_TCAM_RX_NUM_ROWS\n+#define PROF_TCAM_TX_MAX_ENTRIES PROF_TCAM_RX_MAX_ENTRIES\n+#define PROF_TCAM_TX_RESULT_SIZE PROF_TCAM_RX_RESULT_SIZE\n+\n+/** Wildcard TCAM */\n+#define WC_TCAM_RX_MAX_SLICES  4\n+/* 162 bits per slice */\n+#define WC_TCAM_RX_ROW_WIDTH   (TF_BITS2BYTES_64B_WORD_ALIGN(162) *\t\\\n+\t\t\t\tWC_TCAM_RX_MAX_SLICES)\n+#define WC_TCAM_RX_NUM_ROWS    2048\n+#define WC_TCAM_RX_MAX_ENTRIES (WC_TCAM_RX_MAX_SLICES * WC_TCAM_RX_NUM_ROWS)\n+#define WC_TCAM_RX_RESULT_SIZE 8\n+\n+#define WC_TCAM_TX_MAX_SLICES  WC_TCAM_RX_MAX_SLICES\n+#define WC_TCAM_TX_ROW_WIDTH   WC_TCAM_RX_ROW_WIDTH\n+#define WC_TCAM_TX_NUM_ROWS    WC_TCAM_RX_NUM_ROWS\n+#define WC_TCAM_TX_MAX_ENTRIES WC_TCAM_RX_MAX_ENTRIES\n+#define WC_TCAM_TX_RESULT_SIZE WC_TCAM_RX_RESULT_SIZE\n+\n+/** Source Properties TCAM */\n+#define SP_TCAM_RX_MAX_SLICES  1\n+#define SP_TCAM_RX_ROW_WIDTH   TF_BITS2BYTES_64B_WORD_ALIGN(89)\n+#define SP_TCAM_RX_NUM_ROWS    0\n+#define SP_TCAM_RX_MAX_ENTRIES (SP_TCAM_RX_MAX_SLICES * SP_TCAM_RX_NUM_ROWS)\n+#define SP_TCAM_RX_RESULT_SIZE 8\n+\n+#define SP_TCAM_TX_MAX_SLICES  SP_TCAM_RX_MAX_SLICES\n+#define SP_TCAM_TX_ROW_WIDTH   SP_TCAM_RX_ROW_WIDTH\n+#define SP_TCAM_TX_NUM_ROWS    SP_TCAM_RX_NUM_ROWS\n+#define SP_TCAM_TX_MAX_ENTRIES SP_TCAM_RX_MAX_ENTRIES\n+#define SP_TCAM_TX_RESULT_SIZE SP_TCAM_RX_RESULT_SIZE\n+\n+/** Connection Tracking Rule TCAM */\n+#define CT_RULE_TCAM_RX_MAX_SLICES  1\n+#define CT_RULE_TCAM_RX_ROW_WIDTH   TF_BITS2BYTES_64B_WORD_ALIGN(16)\n+#define CT_RULE_TCAM_RX_NUM_ROWS    0\n+#define CT_RULE_TCAM_RX_MAX_ENTRIES (CT_RULE_TCAM_RX_MAX_SLICES * \\\n+\t\t\t\t     CT_RULE_TCAM_RX_NUM_ROWS)\n+#define CT_RULE_TCAM_RX_RESULT_SIZE 8\n+\n+#define CT_RULE_TCAM_TX_MAX_SLICES  CT_RULE_TCAM_RX_MAX_SLICES\n+#define CT_RULE_TCAM_TX_ROW_WIDTH   CT_RULE_TCAM_RX_ROW_WIDTH\n+#define CT_RULE_TCAM_TX_NUM_ROWS    CT_RULE_TCAM_RX_NUM_ROWS\n+#define CT_RULE_TCAM_TX_MAX_ENTRIES CT_RULE_TCAM_RX_MAX_ENTRIES\n+#define CT_RULE_TCAM_TX_RESULT_SIZE CT_RULE_TCAM_RX_RESULT_SIZE\n+\n+/** Virtual Edge Bridge TCAM */\n+#define VEB_TCAM_RX_MAX_SLICES  1\n+#define VEB_TCAM_RX_ROW_WIDTH   TF_BITS2BYTES_WORD_ALIGN(79)\n+/* Tx only */\n+#define VEB_TCAM_RX_NUM_ROWS    0\n+#define VEB_TCAM_RX_MAX_ENTRIES (VEB_TCAM_RX_MAX_SLICES * VEB_TCAM_RX_NUM_ROWS)\n+#define VEB_TCAM_RX_RESULT_SIZE 8\n+\n+#define VEB_TCAM_TX_MAX_SLICES  VEB_TCAM_RX_MAX_SLICES\n+#define VEB_TCAM_TX_ROW_WIDTH   VEB_TCAM_RX_ROW_WIDTH\n+#define VEB_TCAM_TX_NUM_ROWS    1024\n+#define VEB_TCAM_TX_MAX_ENTRIES (VEB_TCAM_TX_MAX_SLICES * VEB_TCAM_TX_NUM_ROWS)\n+#define VEB_TCAM_TX_RESULT_SIZE VEB_TCAM_RX_RESULT_SIZE\n+\n+/* Declare the table rows for each table here.  If new tables are added to the\n+ * enum tf_tcam_tbl_type, then new declarations will be needed here.\n+ *\n+ * The numeric suffix of the structure type indicates how many slices a\n+ * particular TCAM supports.\n+ *\n+ * Array sizes have 1 added to avoid zero length arrays.\n+ */\n+\n+static struct cfa_tcam_mgr_table_rows_1\n+\tcfa_tcam_mgr_table_rows_L2_CTXT_TCAM_RX[TF_TCAM_MAX_SESSIONS][L2_CTXT_TCAM_RX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_1\n+\tcfa_tcam_mgr_table_rows_L2_CTXT_TCAM_TX[TF_TCAM_MAX_SESSIONS][L2_CTXT_TCAM_TX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_1\n+\tcfa_tcam_mgr_table_rows_PROF_TCAM_RX[TF_TCAM_MAX_SESSIONS][PROF_TCAM_RX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_1\n+\tcfa_tcam_mgr_table_rows_PROF_TCAM_TX[TF_TCAM_MAX_SESSIONS][PROF_TCAM_TX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_4\n+\tcfa_tcam_mgr_table_rows_WC_TCAM_RX[TF_TCAM_MAX_SESSIONS][WC_TCAM_RX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_4\n+\tcfa_tcam_mgr_table_rows_WC_TCAM_TX[TF_TCAM_MAX_SESSIONS][WC_TCAM_TX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_1\n+\tcfa_tcam_mgr_table_rows_SP_TCAM_RX[TF_TCAM_MAX_SESSIONS][SP_TCAM_RX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_1\n+\tcfa_tcam_mgr_table_rows_SP_TCAM_TX[TF_TCAM_MAX_SESSIONS][SP_TCAM_TX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_1\n+\tcfa_tcam_mgr_table_rows_CT_RULE_TCAM_RX[TF_TCAM_MAX_SESSIONS][CT_RULE_TCAM_RX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_1\n+\tcfa_tcam_mgr_table_rows_CT_RULE_TCAM_TX[TF_TCAM_MAX_SESSIONS][CT_RULE_TCAM_TX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_1\n+\tcfa_tcam_mgr_table_rows_VEB_TCAM_RX[TF_TCAM_MAX_SESSIONS][VEB_TCAM_RX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_1\n+\tcfa_tcam_mgr_table_rows_VEB_TCAM_TX[TF_TCAM_MAX_SESSIONS][VEB_TCAM_TX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_4\n+\tcfa_tcam_mgr_table_rows_WC_TCAM_RX_HIGH[TF_TCAM_MAX_SESSIONS][WC_TCAM_RX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_4\n+\tcfa_tcam_mgr_table_rows_WC_TCAM_RX_LOW[TF_TCAM_MAX_SESSIONS][WC_TCAM_RX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_4\n+\tcfa_tcam_mgr_table_rows_WC_TCAM_TX_HIGH[TF_TCAM_MAX_SESSIONS][WC_TCAM_TX_NUM_ROWS + 1];\n+static struct cfa_tcam_mgr_table_rows_4\n+\tcfa_tcam_mgr_table_rows_WC_TCAM_TX_LOW[TF_TCAM_MAX_SESSIONS][WC_TCAM_TX_NUM_ROWS + 1];\n+\n+struct cfa_tcam_mgr_table_data\n+cfa_tcam_mgr_tables_p58[TF_DIR_MAX][CFA_TCAM_MGR_TBL_TYPE_MAX] = {\n+\t{\t\t\t\t/* RX */\n+\t\t{\t\t\t/* High AFM */\n+\t\t\t.max_slices  = L2_CTXT_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = L2_CTXT_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = 0,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = L2_CTXT_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_HIGH,\n+\t\t},\n+\t\t{\t\t\t/* High APPS */\n+\t\t\t.max_slices  = L2_CTXT_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = L2_CTXT_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = L2_CTXT_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = (L2_CTXT_TCAM_RX_NUM_ROWS / 2) - 1,\n+\t\t\t.max_entries = (L2_CTXT_TCAM_RX_MAX_ENTRIES / 2),\n+\t\t\t.result_size = L2_CTXT_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_HIGH,\n+\t\t},\n+\t\t{\t\t\t/* Low AFM */\n+\t\t\t.max_slices  = L2_CTXT_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = L2_CTXT_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = 0,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = L2_CTXT_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_LOW,\n+\t\t},\n+\t\t{\t\t\t/* Low APPS */\n+\t\t\t.max_slices  = L2_CTXT_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = L2_CTXT_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = L2_CTXT_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = (L2_CTXT_TCAM_RX_NUM_ROWS / 2),\n+\t\t\t.end_row     = L2_CTXT_TCAM_RX_NUM_ROWS - 1,\n+\t\t\t.max_entries = (L2_CTXT_TCAM_RX_MAX_ENTRIES / 2),\n+\t\t\t.result_size = L2_CTXT_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_LOW,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = PROF_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = PROF_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = 0,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = PROF_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P58_PROF_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = PROF_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = PROF_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = PROF_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = PROF_TCAM_RX_NUM_ROWS - 1,\n+\t\t\t.max_entries = PROF_TCAM_RX_MAX_ENTRIES,\n+\t\t\t.result_size = PROF_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P58_PROF_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = WC_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = WC_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = WC_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = WC_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P58_WC_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = WC_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = WC_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = WC_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = WC_TCAM_RX_NUM_ROWS - 1,\n+\t\t\t.max_entries = WC_TCAM_RX_MAX_ENTRIES,\n+\t\t\t.result_size = WC_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P58_WC_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = SP_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = SP_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = 0,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = SP_TCAM_RX_RESULT_SIZE,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = SP_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = SP_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = SP_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = SP_TCAM_RX_NUM_ROWS - 1,\n+\t\t\t.max_entries = SP_TCAM_RX_MAX_ENTRIES,\n+\t\t\t.result_size = SP_TCAM_RX_RESULT_SIZE,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = CT_RULE_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = CT_RULE_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = CT_RULE_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = CT_RULE_TCAM_RX_RESULT_SIZE,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = CT_RULE_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = CT_RULE_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = CT_RULE_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+#if CT_RULE_TCAM_RX_NUM_ROWS > 0\n+\t\t\t.end_row     = CT_RULE_TCAM_RX_NUM_ROWS - 1,\n+#else\n+\t\t\t.end_row     = CT_RULE_TCAM_RX_NUM_ROWS,\n+#endif\n+\t\t\t.max_entries = CT_RULE_TCAM_RX_MAX_ENTRIES,\n+\t\t\t.result_size = CT_RULE_TCAM_RX_RESULT_SIZE,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = VEB_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = VEB_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = VEB_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = VEB_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P58_VEB_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = VEB_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = VEB_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = VEB_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+#if VEB_TCAM_RX_NUM_ROWS > 0\n+\t\t\t.end_row     = VEB_TCAM_RX_NUM_ROWS - 1,\n+#else\n+\t\t\t.end_row     = VEB_TCAM_RX_NUM_ROWS,\n+#endif\n+\t\t\t.max_entries = VEB_TCAM_RX_MAX_ENTRIES,\n+\t\t\t.result_size = VEB_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P58_VEB_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = WC_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = WC_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = WC_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = WC_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P58_WC_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = WC_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = WC_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = WC_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = WC_TCAM_RX_NUM_ROWS - 1,\n+\t\t\t.max_entries = WC_TCAM_RX_MAX_ENTRIES,\n+\t\t\t.result_size = WC_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P58_WC_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = WC_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = WC_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = WC_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = WC_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P58_WC_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = WC_TCAM_RX_MAX_SLICES,\n+\t\t\t.row_width   = WC_TCAM_RX_ROW_WIDTH,\n+\t\t\t.num_rows    = WC_TCAM_RX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = WC_TCAM_RX_NUM_ROWS - 1,\n+\t\t\t.max_entries = WC_TCAM_RX_MAX_ENTRIES,\n+\t\t\t.result_size = WC_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P58_WC_TCAM,\n+\t\t},\n+\t},\n+\t{\t\t\t\t/* TX */\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = L2_CTXT_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = L2_CTXT_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = L2_CTXT_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = L2_CTXT_TCAM_TX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_HIGH,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = L2_CTXT_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = L2_CTXT_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = L2_CTXT_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = (L2_CTXT_TCAM_TX_NUM_ROWS / 2) - 1,\n+\t\t\t.max_entries = (L2_CTXT_TCAM_TX_MAX_ENTRIES / 2),\n+\t\t\t.result_size = L2_CTXT_TCAM_TX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_HIGH,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = L2_CTXT_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = L2_CTXT_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = L2_CTXT_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = L2_CTXT_TCAM_TX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_LOW,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = L2_CTXT_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = L2_CTXT_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = L2_CTXT_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = (L2_CTXT_TCAM_TX_NUM_ROWS / 2),\n+\t\t\t.end_row     = L2_CTXT_TCAM_TX_NUM_ROWS - 1,\n+\t\t\t.max_entries = (L2_CTXT_TCAM_TX_MAX_ENTRIES / 2),\n+\t\t\t.result_size = L2_CTXT_TCAM_TX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_LOW,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = PROF_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = PROF_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = PROF_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = PROF_TCAM_TX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P58_PROF_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = PROF_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = PROF_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = PROF_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = PROF_TCAM_TX_NUM_ROWS - 1,\n+\t\t\t.max_entries = PROF_TCAM_TX_MAX_ENTRIES,\n+\t\t\t.result_size = PROF_TCAM_TX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P58_PROF_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = WC_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = WC_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = WC_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = WC_TCAM_TX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P58_WC_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = WC_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = WC_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = WC_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = WC_TCAM_TX_NUM_ROWS - 1,\n+\t\t\t.max_entries = WC_TCAM_TX_MAX_ENTRIES,\n+\t\t\t.result_size = WC_TCAM_TX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P58_WC_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = SP_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = SP_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = SP_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = SP_TCAM_TX_RESULT_SIZE,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = SP_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = SP_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = SP_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = SP_TCAM_TX_NUM_ROWS - 1,\n+\t\t\t.max_entries = SP_TCAM_TX_MAX_ENTRIES,\n+\t\t\t.result_size = SP_TCAM_TX_RESULT_SIZE,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = CT_RULE_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = CT_RULE_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = CT_RULE_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = CT_RULE_TCAM_RX_RESULT_SIZE,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = CT_RULE_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = CT_RULE_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = CT_RULE_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+#if CT_RULE_TCAM_TX_NUM_ROWS > 0\n+\t\t\t.end_row     = CT_RULE_TCAM_TX_NUM_ROWS - 1,\n+#else\n+\t\t\t.end_row     = CT_RULE_TCAM_TX_NUM_ROWS,\n+#endif\n+\t\t\t.max_entries = CT_RULE_TCAM_TX_MAX_ENTRIES,\n+\t\t\t.result_size = CT_RULE_TCAM_RX_RESULT_SIZE,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = VEB_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = VEB_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = VEB_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = VEB_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P58_VEB_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = VEB_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = VEB_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = VEB_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = VEB_TCAM_TX_NUM_ROWS - 1,\n+\t\t\t.max_entries = VEB_TCAM_TX_MAX_ENTRIES,\n+\t\t\t.result_size = VEB_TCAM_RX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P58_VEB_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = WC_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = WC_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = WC_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = WC_TCAM_TX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P58_WC_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = WC_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = WC_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = WC_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = WC_TCAM_TX_NUM_ROWS - 1,\n+\t\t\t.max_entries = WC_TCAM_TX_MAX_ENTRIES,\n+\t\t\t.result_size = WC_TCAM_TX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P58_WC_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* AFM */\n+\t\t\t.max_slices  = WC_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = WC_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = WC_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = 0,\n+\t\t\t.max_entries = 0,\n+\t\t\t.result_size = WC_TCAM_TX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P58_WC_TCAM,\n+\t\t},\n+\t\t{\t\t\t/* APPS */\n+\t\t\t.max_slices  = WC_TCAM_TX_MAX_SLICES,\n+\t\t\t.row_width   = WC_TCAM_TX_ROW_WIDTH,\n+\t\t\t.num_rows    = WC_TCAM_TX_NUM_ROWS,\n+\t\t\t.start_row   = 0,\n+\t\t\t.end_row     = WC_TCAM_TX_NUM_ROWS - 1,\n+\t\t\t.max_entries = WC_TCAM_TX_MAX_ENTRIES,\n+\t\t\t.result_size = WC_TCAM_TX_RESULT_SIZE,\n+\t\t\t.hcapi_type  = CFA_RESOURCE_TYPE_P58_WC_TCAM,\n+\t\t},\n+\t},\n+};\n+\n+static struct cfa_tcam_mgr_entry_data entry_data_p58[TF_TCAM_MAX_SESSIONS][TF_TCAM_MAX_ENTRIES];\n+\n+static struct sbmp session_bmp_p58[TF_TCAM_MAX_SESSIONS][TF_TCAM_MAX_ENTRIES];\n+\n+int\n+cfa_tcam_mgr_sess_table_get_p58(int sess_idx, struct sbmp **session_bmp)\n+{\n+\t*session_bmp = session_bmp_p58[sess_idx];\n+\treturn 0;\n+}\n+\n+int\n+cfa_tcam_mgr_init_p58(int sess_idx, struct cfa_tcam_mgr_entry_data **global_entry_data)\n+{\n+\tint max_row_width = 0;\n+\tint max_result_size = 0;\n+\tint dir, type;\n+\n+\t*global_entry_data = entry_data_p58[sess_idx];\n+\n+\tmemcpy(&cfa_tcam_mgr_tables[sess_idx],\n+\t       &cfa_tcam_mgr_tables_p58,\n+\t       sizeof(cfa_tcam_mgr_tables[sess_idx]));\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_HIGH_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_L2_CTXT_TCAM_RX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_HIGH_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_L2_CTXT_TCAM_RX[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_HIGH_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_L2_CTXT_TCAM_TX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_HIGH_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_L2_CTXT_TCAM_TX[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_LOW_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_L2_CTXT_TCAM_RX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_LOW_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_L2_CTXT_TCAM_RX[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_LOW_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_L2_CTXT_TCAM_TX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_LOW_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_L2_CTXT_TCAM_TX[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_PROF_TCAM_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_PROF_TCAM_RX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_PROF_TCAM_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_PROF_TCAM_RX[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_PROF_TCAM_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_PROF_TCAM_TX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_PROF_TCAM_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_PROF_TCAM_TX[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_WC_TCAM_RX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_WC_TCAM_RX[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_WC_TCAM_TX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_WC_TCAM_TX[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_SP_TCAM_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_SP_TCAM_RX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_SP_TCAM_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_SP_TCAM_RX[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_SP_TCAM_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_SP_TCAM_TX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_SP_TCAM_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_SP_TCAM_TX[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_CT_RULE_TCAM_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_CT_RULE_TCAM_RX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_CT_RULE_TCAM_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_CT_RULE_TCAM_RX[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_CT_RULE_TCAM_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_CT_RULE_TCAM_TX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_CT_RULE_TCAM_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_CT_RULE_TCAM_TX[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_VEB_TCAM_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_VEB_TCAM_RX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_VEB_TCAM_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_VEB_TCAM_RX[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_VEB_TCAM_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_VEB_TCAM_TX[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_VEB_TCAM_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_VEB_TCAM_TX[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_WC_TCAM_RX_HIGH[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_WC_TCAM_RX_HIGH[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_WC_TCAM_TX_HIGH[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_WC_TCAM_TX_HIGH[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_WC_TCAM_RX_LOW[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_WC_TCAM_RX_LOW[sess_idx];\n+\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_AFM].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_WC_TCAM_TX_LOW[sess_idx];\n+\tcfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]\n+\t\t[CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_APPS].tcam_rows =\n+\t\t(struct cfa_tcam_mgr_table_rows_0 *)\n+\t\t&cfa_tcam_mgr_table_rows_WC_TCAM_TX_LOW[sess_idx];\n+\n+\tfor (dir = 0; dir < TF_DIR_MAX; dir++) {\n+\t\tfor (type = 0; type < CFA_TCAM_MGR_TBL_TYPE_MAX; type++) {\n+\t\t\tif (cfa_tcam_mgr_tables[sess_idx][dir][type].row_width >\n+\t\t\t    max_row_width)\n+\t\t\t\tmax_row_width =\n+\t\t\t\t       cfa_tcam_mgr_tables[sess_idx][dir][type].row_width;\n+\t\t\tif (cfa_tcam_mgr_tables[sess_idx][dir][type].result_size >\n+\t\t\t    max_result_size)\n+\t\t\t\tmax_result_size =\n+\t\t\t\t     cfa_tcam_mgr_tables[sess_idx][dir][type].result_size;\n+\t\t}\n+\t}\n+\n+\tif (max_row_width != MAX_ROW_WIDTH) {\n+\t\tCFA_TCAM_MGR_LOG(ERR,\n+\t\t\t\t \"MAX_ROW_WIDTH (%d) does not match actual \"\n+\t\t\t\t \"value (%d).\\n\",\n+\t\t\t\t MAX_ROW_WIDTH,\n+\t\t\t\t max_row_width);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\n+\t}\n+\tif (max_result_size != MAX_RESULT_SIZE) {\n+\t\tCFA_TCAM_MGR_LOG(ERR,\n+\t\t\t\t \"MAX_RESULT_SIZE (%d) does not match actual \"\n+\t\t\t\t \"value (%d).\\n\",\n+\t\t\t\t MAX_RESULT_SIZE,\n+\t\t\t\t max_result_size);\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\n+\t}\n+\treturn 0;\n+}\n+\n+/* HW OP declarations begin here */\n+\n+struct cfa_tcam_mgr_TCAM_row_data {\n+\tint key_size;\n+\tint result_size;\n+\tuint8_t key[MAX_ROW_WIDTH];\n+\tuint8_t mask[MAX_ROW_WIDTH];\n+\tuint8_t result[MAX_RESULT_SIZE];\n+};\n+\n+/* These macros are only needed to avoid exceeding 80 columns */\n+#define L2_CTXT_RX_MAX_ROWS \\\n+\t(L2_CTXT_TCAM_RX_MAX_SLICES * L2_CTXT_TCAM_RX_NUM_ROWS)\n+#define PROF_RX_MAX_ROWS    (PROF_TCAM_RX_MAX_SLICES * PROF_TCAM_RX_NUM_ROWS)\n+#define WC_RX_MAX_ROWS\t    (WC_TCAM_RX_MAX_SLICES * WC_TCAM_RX_NUM_ROWS)\n+#define SP_RX_MAX_ROWS\t    (SP_TCAM_RX_MAX_SLICES * SP_TCAM_RX_NUM_ROWS)\n+#define CT_RULE_RX_MAX_ROWS \\\n+\t(CT_RULE_TCAM_RX_MAX_SLICES * CT_RULE_TCAM_RX_NUM_ROWS)\n+#define VEB_RX_MAX_ROWS\t    (VEB_TCAM_RX_MAX_SLICES * VEB_TCAM_RX_NUM_ROWS)\n+\n+#define L2_CTXT_TX_MAX_ROWS \\\n+\t(L2_CTXT_TCAM_TX_MAX_SLICES * L2_CTXT_TCAM_TX_NUM_ROWS)\n+#define PROF_TX_MAX_ROWS    (PROF_TCAM_TX_MAX_SLICES * PROF_TCAM_TX_NUM_ROWS)\n+#define WC_TX_MAX_ROWS\t    (WC_TCAM_TX_MAX_SLICES * WC_TCAM_TX_NUM_ROWS)\n+#define SP_TX_MAX_ROWS\t    (SP_TCAM_TX_MAX_SLICES * SP_TCAM_TX_NUM_ROWS)\n+#define CT_RULE_TX_MAX_ROWS \\\n+\t(CT_RULE_TCAM_TX_MAX_SLICES * CT_RULE_TCAM_TX_NUM_ROWS)\n+#define VEB_TX_MAX_ROWS\t    (VEB_TCAM_TX_MAX_SLICES * VEB_TCAM_TX_NUM_ROWS)\n+\n+static int cfa_tcam_mgr_max_rows[TF_TCAM_TBL_TYPE_MAX] = {\n+\tL2_CTXT_RX_MAX_ROWS,\n+\tL2_CTXT_RX_MAX_ROWS,\n+\tPROF_RX_MAX_ROWS,\n+\tWC_RX_MAX_ROWS,\n+\tSP_RX_MAX_ROWS,\n+\tCT_RULE_RX_MAX_ROWS,\n+\tVEB_RX_MAX_ROWS,\n+\tWC_RX_MAX_ROWS,\n+\tWC_RX_MAX_ROWS\n+};\n+\n+static struct cfa_tcam_mgr_TCAM_row_data\n+\tcfa_tcam_mgr_L2_CTXT_TCAM_RX_row_data[TF_TCAM_MAX_SESSIONS][L2_CTXT_RX_MAX_ROWS];\n+static struct cfa_tcam_mgr_TCAM_row_data\n+\tcfa_tcam_mgr_PROF_TCAM_RX_row_data[TF_TCAM_MAX_SESSIONS][PROF_RX_MAX_ROWS];\n+static struct cfa_tcam_mgr_TCAM_row_data\n+\tcfa_tcam_mgr_WC_TCAM_RX_row_data[TF_TCAM_MAX_SESSIONS][WC_RX_MAX_ROWS];\n+static struct cfa_tcam_mgr_TCAM_row_data\n+\tcfa_tcam_mgr_SP_TCAM_RX_row_data[TF_TCAM_MAX_SESSIONS][SP_RX_MAX_ROWS];\n+static struct cfa_tcam_mgr_TCAM_row_data\n+\tcfa_tcam_mgr_CT_RULE_TCAM_RX_row_data[TF_TCAM_MAX_SESSIONS][CT_RULE_RX_MAX_ROWS];\n+static struct cfa_tcam_mgr_TCAM_row_data\n+\tcfa_tcam_mgr_VEB_TCAM_RX_row_data[TF_TCAM_MAX_SESSIONS][VEB_RX_MAX_ROWS];\n+static struct cfa_tcam_mgr_TCAM_row_data\n+\tcfa_tcam_mgr_WC_TCAM_RX_row_data[TF_TCAM_MAX_SESSIONS][WC_RX_MAX_ROWS];\n+\n+static struct cfa_tcam_mgr_TCAM_row_data\n+\tcfa_tcam_mgr_L2_CTXT_TCAM_TX_row_data[TF_TCAM_MAX_SESSIONS][L2_CTXT_TX_MAX_ROWS];\n+static struct cfa_tcam_mgr_TCAM_row_data\n+\tcfa_tcam_mgr_PROF_TCAM_TX_row_data[TF_TCAM_MAX_SESSIONS][PROF_TX_MAX_ROWS];\n+static struct cfa_tcam_mgr_TCAM_row_data\n+\tcfa_tcam_mgr_WC_TCAM_TX_row_data[TF_TCAM_MAX_SESSIONS][WC_TX_MAX_ROWS];\n+static struct cfa_tcam_mgr_TCAM_row_data\n+\tcfa_tcam_mgr_SP_TCAM_TX_row_data[TF_TCAM_MAX_SESSIONS][SP_TX_MAX_ROWS];\n+static struct cfa_tcam_mgr_TCAM_row_data\n+\tcfa_tcam_mgr_CT_RULE_TCAM_TX_row_data[TF_TCAM_MAX_SESSIONS][CT_RULE_TX_MAX_ROWS];\n+static struct cfa_tcam_mgr_TCAM_row_data\n+\tcfa_tcam_mgr_VEB_TCAM_TX_row_data[TF_TCAM_MAX_SESSIONS][VEB_TX_MAX_ROWS];\n+static struct cfa_tcam_mgr_TCAM_row_data\n+\tcfa_tcam_mgr_WC_TCAM_TX_row_data[TF_TCAM_MAX_SESSIONS][WC_TX_MAX_ROWS];\n+\n+static struct cfa_tcam_mgr_TCAM_row_data *\n+row_tables[TF_DIR_MAX][TF_TCAM_TBL_TYPE_MAX] = {\n+\t{\n+\t\tcfa_tcam_mgr_L2_CTXT_TCAM_RX_row_data[0],\n+\t\tcfa_tcam_mgr_L2_CTXT_TCAM_RX_row_data[0],\n+\t\tcfa_tcam_mgr_PROF_TCAM_RX_row_data[0],\n+\t\tcfa_tcam_mgr_WC_TCAM_RX_row_data[0],\n+\t\tcfa_tcam_mgr_SP_TCAM_RX_row_data[0],\n+\t\tcfa_tcam_mgr_CT_RULE_TCAM_RX_row_data[0],\n+\t\tcfa_tcam_mgr_VEB_TCAM_RX_row_data[0],\n+\t\tcfa_tcam_mgr_WC_TCAM_RX_row_data[0],\n+\t\tcfa_tcam_mgr_WC_TCAM_RX_row_data[0],\n+\t},\n+\t{\n+\t\tcfa_tcam_mgr_L2_CTXT_TCAM_TX_row_data[0],\n+\t\tcfa_tcam_mgr_L2_CTXT_TCAM_TX_row_data[0],\n+\t\tcfa_tcam_mgr_PROF_TCAM_TX_row_data[0],\n+\t\tcfa_tcam_mgr_WC_TCAM_TX_row_data[0],\n+\t\tcfa_tcam_mgr_SP_TCAM_TX_row_data[0],\n+\t\tcfa_tcam_mgr_CT_RULE_TCAM_TX_row_data[0],\n+\t\tcfa_tcam_mgr_VEB_TCAM_TX_row_data[0],\n+\t\tcfa_tcam_mgr_WC_TCAM_TX_row_data[0],\n+\t\tcfa_tcam_mgr_WC_TCAM_TX_row_data[0],\n+\t}\n+};\n+\n+static int cfa_tcam_mgr_get_max_rows(enum tf_tcam_tbl_type type)\n+{\n+\tif (type >= TF_TCAM_TBL_TYPE_MAX)\n+\t\tassert(0);\n+\telse\n+\t\treturn cfa_tcam_mgr_max_rows[type];\n+}\n+\n+static int cfa_tcam_mgr_hwop_set(int sess_idx,\n+\t\t\t\t struct cfa_tcam_mgr_set_parms *parms, int row,\n+\t\t\t\t int slice, int max_slices)\n+{\n+\tstruct cfa_tcam_mgr_TCAM_row_data *this_table;\n+\tstruct cfa_tcam_mgr_TCAM_row_data *this_row;\n+\tthis_table = row_tables[parms->dir]\n+\t\t[cfa_tcam_mgr_get_phys_table_type(parms->type)];\n+\tthis_table += (sess_idx *\n+\t\t       cfa_tcam_mgr_get_max_rows(cfa_tcam_mgr_get_phys_table_type(parms->type)));\n+\tthis_row   = &this_table[row * max_slices + slice];\n+\tthis_row->key_size = parms->key_size;\n+\tmemcpy(&this_row->key, parms->key, parms->key_size);\n+\tmemcpy(&this_row->mask, parms->mask, parms->key_size);\n+\tthis_row->result_size = parms->result_size;\n+\tif (parms->result != ((void *)0))\n+\t\tmemcpy(&this_row->result, parms->result, parms->result_size);\n+\treturn 0;\n+};\n+\n+static int cfa_tcam_mgr_hwop_get(int sess_idx,\n+\t\t\t\t struct cfa_tcam_mgr_get_parms *parms, int row,\n+\t\t\t\t int slice, int max_slices)\n+{\n+\tstruct cfa_tcam_mgr_TCAM_row_data *this_table;\n+\tstruct cfa_tcam_mgr_TCAM_row_data *this_row;\n+\tthis_table = row_tables[parms->dir]\n+\t\t[cfa_tcam_mgr_get_phys_table_type(parms->type)];\n+\tthis_table += (sess_idx *\n+\t\t       cfa_tcam_mgr_get_max_rows(cfa_tcam_mgr_get_phys_table_type(parms->type)));\n+\tthis_row   = &this_table[row * max_slices + slice];\n+\tparms->key_size = this_row->key_size;\n+\tparms->result_size = this_row->result_size;\n+\tif (parms->key != ((void *)0))\n+\t\tmemcpy(parms->key, &this_row->key, parms->key_size);\n+\tif (parms->mask != ((void *)0))\n+\t\tmemcpy(parms->mask, &this_row->mask, parms->key_size);\n+\tif (parms->result != ((void *)0))\n+\t\tmemcpy(parms->result, &this_row->result, parms->result_size);\n+\treturn 0;\n+};\n+\n+static int cfa_tcam_mgr_hwop_free(int sess_idx,\n+\t\t\t\t  struct cfa_tcam_mgr_free_parms *parms,\n+\t\t\t\t  int row, int slice, int max_slices)\n+{\n+\tstruct cfa_tcam_mgr_TCAM_row_data *this_table;\n+\tstruct cfa_tcam_mgr_TCAM_row_data *this_row;\n+\tthis_table = row_tables[parms->dir]\n+\t\t[cfa_tcam_mgr_get_phys_table_type(parms->type)];\n+\tthis_table += (sess_idx *\n+\t\t       cfa_tcam_mgr_get_max_rows(cfa_tcam_mgr_get_phys_table_type(parms->type)));\n+\tthis_row   = &this_table[row * max_slices + slice];\n+\tmemset(&this_row->key, 0, sizeof(this_row->key));\n+\tmemset(&this_row->mask, 0, sizeof(this_row->mask));\n+\tmemset(&this_row->result, 0, sizeof(this_row->result));\n+\tthis_row->key_size = 0;\n+\tthis_row->result_size = 0;\n+\treturn 0;\n+};\n+\n+int cfa_tcam_mgr_hwops_get_funcs_p58(struct cfa_tcam_mgr_hwops_funcs\n+\t\t\t\t     *hwop_funcs)\n+{\n+\thwop_funcs->set\t = cfa_tcam_mgr_hwop_set;\n+\thwop_funcs->get\t = cfa_tcam_mgr_hwop_get;\n+\thwop_funcs->free = cfa_tcam_mgr_hwop_free;\n+\treturn 0;\n+}\ndiff --git a/drivers/net/bnxt/tf_core/cfa_tcam_mgr_p58.h b/drivers/net/bnxt/tf_core/cfa_tcam_mgr_p58.h\nnew file mode 100644\nindex 0000000000..7640f91911\n--- /dev/null\n+++ b/drivers/net/bnxt/tf_core/cfa_tcam_mgr_p58.h\n@@ -0,0 +1,20 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2021-2023 Broadcom\n+ * All rights reserved.\n+ */\n+\n+#ifndef CFA_TCAM_MGR_P58_H\n+#define CFA_TCAM_MGR_P58_H\n+\n+#include \"cfa_tcam_mgr_device.h\"\n+#include \"cfa_tcam_mgr_sbmp.h\"\n+\n+int\n+cfa_tcam_mgr_init_p58(int sess_idx, struct cfa_tcam_mgr_entry_data **global_entry_data);\n+\n+int\n+cfa_tcam_mgr_sess_table_get_p58(int sess_idx, struct sbmp **session_bmp);\n+\n+int\n+cfa_tcam_mgr_hwops_get_funcs_p58(struct cfa_tcam_mgr_hwops_funcs *hwop_funcs);\n+#endif /* CFA_TCAM_MGR_P58_H */\ndiff --git a/drivers/net/bnxt/tf_core/cfa_tcam_mgr_sbmp.h b/drivers/net/bnxt/tf_core/cfa_tcam_mgr_sbmp.h\nnew file mode 100644\nindex 0000000000..6ad158abe8\n--- /dev/null\n+++ b/drivers/net/bnxt/tf_core/cfa_tcam_mgr_sbmp.h\n@@ -0,0 +1,126 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2021-2023 Broadcom\n+ * All rights reserved.\n+ */\n+\n+#ifndef CFA_TCAM_MGR_SBMP_H\n+#define CFA_TCAM_MGR_SBMP_H\n+\n+#include <inttypes.h>\n+\n+#include \"cfa_tcam_mgr.h\"\n+\n+#define SBMP_SESSION_MAX TF_TCAM_MAX_SESSIONS\n+#if SBMP_SESSION_MAX <= 16\n+#define SBMP_WORD_WIDTH  16\n+#else\n+#define SBMP_WORD_WIDTH  32\n+#endif\n+\n+#define SBMP_WIDTH       (((SBMP_SESSION_MAX + SBMP_WORD_WIDTH - 1) / \\\n+\t\t\t   SBMP_WORD_WIDTH) * SBMP_WORD_WIDTH)\n+#define\tSBMP_WORD_MAX    ((SBMP_WIDTH + SBMP_WORD_WIDTH - 1) / SBMP_WORD_WIDTH)\n+\n+struct sbmp {\n+#if SBMP_WORD_WIDTH == 16\n+\tuint16_t bits[SBMP_WORD_MAX];\n+#elif SBMP_WORD_WIDTH == 32\n+\tuint32_t bits[SBMP_WORD_MAX];\n+#else\n+\tuint64_t bits[SBMP_WORD_MAX];\n+#endif\n+};\n+\n+#define\tSBMP_WORD_GET(bm, word)\t\t((bm).bits[(word)])\n+\n+#if SBMP_WORD_MAX == 1\n+#define\tSBMP_WENT(session)\t\t(0)\n+#define\tSBMP_WBIT(session)\t\t(1U << (session))\n+#define SBMP_CLEAR(bm)                  (SBMP_WORD_GET(bm, 0) = 0)\n+#define SBMP_IS_NULL(bm)\t\t(SBMP_WORD_GET(bm, 0) == 0)\n+#define\tSBMP_COUNT(bm, count)\t\\\n+\t(count = __builtin_popcount(SBMP_WORD_GET(bm, 0)))\n+#elif SBMP_WORD_MAX == 2\n+#define\tSBMP_WENT(session)\t\t((session) / SBMP_WORD_WIDTH)\n+#define\tSBMP_WBIT(session)\t\t(1U << ((session) % SBMP_WORD_WIDTH))\n+#define SBMP_CLEAR(bm)\t\t\t\t\t\t\t\\\n+\tdo {\t\t\t\t\t\t\t\t\\\n+\t\ttypeof(bm) *_bm = &(bm);\t\t\t\t\\\n+\t\tSBMP_WORD_GET(*_bm, 0) = SBMP_WORD_GET(*_bm, 1) = 0;\t\\\n+\t} while (0)\n+#define SBMP_IS_NULL(bm)\t\t\\\n+\t(SBMP_WORD_GET(bm, 0) == 0 && SBMP_WORD_GET(bm, 1) == 0)\n+#define\tSBMP_COUNT(bm, count)\t\t\t\t\t\t\\\n+\tdo {\t\t\t\t\t\t\t\t\\\n+\t\ttypeof(bm) *_bm = &(bm);\t\t\t\t\\\n+\t\tcount = __builtin_popcount(SBMP_WORD_GET(*_bm, 0)) +\t\\\n+\t\t\t__builtin_popcount(SBMP_WORD_GET(*_bm, 1)));\t\\\n+\t} while (0)\n+#elif SBMP_WORD_MAX == 3\n+#define\tSBMP_WENT(session)\t\t((session) / SBMP_WORD_WIDTH)\n+#define\tSBMP_WBIT(session)\t\t(1U << ((session) % SBMP_WORD_WIDTH))\n+#define SBMP_CLEAR(bm)\t\t\t\t\t\t\t\\\n+\tdo {\t\t\t\t\t\t\t\t\\\n+\t\ttypeof(bm) *_bm = &(bm);\t\t\t\t\\\n+\t\tSBMP_WORD_GET(*_bm, 0) = SBMP_WORD_GET(*_bm, 1) =\t\\\n+\t\t\tSBMP_WORD_GET(*_bm, 2) = 0;\t\t\t\\\n+\t} while (0)\n+#define SBMP_IS_NULL(bm)\t\t\\\n+\t(SBMP_WORD_GET(bm, 0) == 0 && SBMP_WORD_GET(bm, 1) == 0 && \\\n+\t SBMP_WORD_GET(bm, 2) == 0)\n+#define\tSBMP_COUNT(bm, count)\t\t\t\t\t\t\\\n+\tdo {\t\t\t\t\t\t\t\t\\\n+\t\ttypeof(bm) *_bm = &(bm);\t\t\t\t\\\n+\t\tcount = __builtin_popcount(SBMP_WORD_GET(*_bm, 0)) +\t\\\n+\t\t\t__builtin_popcount(SBMP_WORD_GET(*_bm, 1)) +\t\\\n+\t\t\t__builtin_popcount(SBMP_WORD_GET(*_bm, 2));\t\\\n+\t} while (0)\n+#else  /* SBMP_WORD_MAX > 3 */\n+#define\tSBMP_WENT(session)\t\t((session) / SBMP_WORD_WIDTH)\n+#define\tSBMP_WBIT(session)\t\t(1U << ((session) % SBMP_WORD_WIDTH))\n+#define SBMP_CLEAR(bm)\t\t\t\t\t\t\t\\\n+\tdo {\t\t\t\t\t\t\t\t\\\n+\t\ttypeof(bm) *_bm = &(bm);\t\t\t\t\\\n+\t\tint\t_w;\t\t\t\t\t\t\\\n+\t\tfor (_w = 0; _w < SBMP_WORD_MAX; _w++) {\t\t\\\n+\t\t\tSBMP_WORD_GET(*_bm, _w) = 0;\t\t\t\\\n+\t\t}\t\t\t\t\t\t\t\\\n+\t} while (0)\n+#define SBMP_IS_NULL(bm)\t\t(sbmp_bmnull(&(bm)))\n+#define\tSBMP_COUNT(bm, count)\t\t\t\t\t\t\\\n+\tdo {\t\t\t\t\t\t\t\t\\\n+\t\ttypeof(bm) *_bm = &(bm);\t\t\t\t\\\n+\t\tint\t_count, _w;\t\t\t\t\t\\\n+\t\t_count = 0;\t\t\t\t\t\t\\\n+\t\tfor (_w = 0; _w < SBMP_WORD_MAX; _w++) {\t\t\\\n+\t\t\t_count += __builtin_popcount(SBMP_WORD_GET(*_bm, _w)); \\\n+\t\t}\t\t\t\t\t\t\t\\\n+\t\tcount = _count;\t\t\t\t\t\t\\\n+\t} while (0)\n+\n+/* Only needed if SBMP_WORD_MAX > 3 */\n+static int\n+sbmp_bmnull(struct ebmp *bmp)\n+{\n+\tint\ti;\n+\n+\tfor (i = 0; i < SBMP_WORD_MAX; i++) {\n+\t\tif (SBMP_WORD_GET(*bmp, i) != 0)\n+\t\t\treturn 0;\n+\t}\n+\treturn 1;\n+}\n+#endif\n+\n+/* generics that use the previously defined helpers */\n+#define SBMP_NOT_NULL(bm)\t\t(!SBMP_IS_NULL(bm))\n+\n+#define\tSBMP_ENTRY(bm, session)\t\\\n+\t(SBMP_WORD_GET(bm, SBMP_WENT(session)))\n+#define SBMP_MEMBER(bm, session)\t\\\n+\t((SBMP_ENTRY(bm, session) & SBMP_WBIT(session)) != 0)\n+#define SBMP_SESSION_ADD(bm, session)\t\\\n+\t(SBMP_ENTRY(bm, session) |= SBMP_WBIT(session))\n+#define SBMP_SESSION_REMOVE(bm, session)\t\\\n+\t(SBMP_ENTRY(bm, session) &= ~SBMP_WBIT(session))\n+#endif  /* CFA_TCAM_MGR_SBMP_H */\ndiff --git a/drivers/net/bnxt/tf_core/cfa_tcam_mgr_session.c b/drivers/net/bnxt/tf_core/cfa_tcam_mgr_session.c\nnew file mode 100644\nindex 0000000000..3d085bc69e\n--- /dev/null\n+++ b/drivers/net/bnxt/tf_core/cfa_tcam_mgr_session.c\n@@ -0,0 +1,377 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2021-2023 Broadcom\n+ * All rights reserved.\n+ */\n+\n+#include <inttypes.h>\n+#include \"hcapi_cfa_defs.h\"\n+#include \"tf_util.h\"\n+#include \"cfa_tcam_mgr.h\"\n+#include \"cfa_tcam_mgr_device.h\"\n+#include \"cfa_tcam_mgr_session.h\"\n+#include \"cfa_tcam_mgr_sbmp.h\"\n+#include \"tfp.h\"\n+#include \"cfa_tcam_mgr_p58.h\"\n+#include \"cfa_tcam_mgr_p4.h\"\n+\n+struct cfa_tcam_mgr_session_data {\n+\tuint32_t session_id;\n+\t/* The following are per-session values */\n+\tuint16_t max_entries[TF_DIR_MAX][CFA_TCAM_MGR_TBL_TYPE_MAX];\n+\tuint16_t used_entries[TF_DIR_MAX][CFA_TCAM_MGR_TBL_TYPE_MAX];\n+};\n+\n+static struct cfa_tcam_mgr_session_data session_data[TF_TCAM_MAX_SESSIONS];\n+\n+static uint16_t last_entry_id;\n+\n+static struct sbmp *session_bmp[TF_TCAM_MAX_SESSIONS];\n+\n+int\n+cfa_tcam_mgr_session_init(int sess_idx, enum cfa_tcam_mgr_device_type type)\n+{\n+\tint rc;\n+\n+\tswitch (type) {\n+\tcase CFA_TCAM_MGR_DEVICE_TYPE_P4:\n+\tcase CFA_TCAM_MGR_DEVICE_TYPE_SR:\n+\t\trc = cfa_tcam_mgr_sess_table_get_p4(sess_idx, &session_bmp[sess_idx]);\n+\t\tbreak;\n+\tcase CFA_TCAM_MGR_DEVICE_TYPE_P5:\n+\t\trc = cfa_tcam_mgr_sess_table_get_p58(sess_idx, &session_bmp[sess_idx]);\n+\t\tbreak;\n+\tdefault:\n+\t\tCFA_TCAM_MGR_LOG(ERR, \"No such device %d\\n\", type);\n+\t\trc = -CFA_TCAM_MGR_ERR_CODE(NODEV);\n+\t}\n+\n+\treturn rc;\n+}\n+\n+int\n+cfa_tcam_mgr_get_session_from_context(struct cfa_tcam_mgr_context *context,\n+\t\t\t\t      uint32_t *session_id)\n+{\n+\tif (context == NULL) {\n+\t\tCFA_TCAM_MGR_LOG_0(ERR, \"context passed as NULL pointer.\\n\");\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\n+\t}\n+\n+\t*session_id = context->tfp->session->session_id.id;\n+\treturn 0;\n+}\n+\n+int\n+cfa_tcam_mgr_session_find(unsigned int session_id)\n+{\n+\tunsigned int sess_idx;\n+\n+\tfor (sess_idx = 0; sess_idx < ARRAY_SIZE(session_data); sess_idx++) {\n+\t\tif (session_data[sess_idx].session_id == session_id)\n+\t\t\treturn sess_idx;\n+\t}\n+\n+\treturn -CFA_TCAM_MGR_ERR_CODE(INVAL);\n+}\n+\n+int\n+cfa_tcam_mgr_session_add(unsigned int session_id)\n+{\n+\tint sess_idx;\n+\n+\tsess_idx = cfa_tcam_mgr_session_find(session_id);\n+\tif (sess_idx >= 0) {\n+\t\tCFA_TCAM_MGR_LOG_0(ERR, \"Session is already bound.\\n\");\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(BUSY);\n+\t}\n+\n+\t/* Session not found in table, find first empty entry. */\n+\tfor (sess_idx = 0;\n+\t     sess_idx < (signed int)ARRAY_SIZE(session_data);\n+\t     sess_idx++) {\n+\t\tif (session_data[sess_idx].session_id == 0)\n+\t\t\tbreak;\n+\t}\n+\n+\tif (sess_idx >= (signed int)ARRAY_SIZE(session_data)) {\n+\t\t/* No room in the session table */\n+\t\tCFA_TCAM_MGR_LOG_0(ERR, \"Session table is full.\\n\");\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(NOMEM);\n+\t}\n+\n+\tsession_data[sess_idx].session_id = session_id;\n+\n+\treturn sess_idx;\n+}\n+\n+int\n+cfa_tcam_mgr_session_free(unsigned int session_id,\n+\t\tstruct cfa_tcam_mgr_context *context)\n+{\n+\tstruct cfa_tcam_mgr_free_parms free_parms;\n+\tint entry_id;\n+\tint sess_idx = cfa_tcam_mgr_session_find(session_id);\n+\n+\tif (sess_idx < 0)\n+\t\treturn sess_idx;\n+\n+\tmemset(&free_parms, 0, sizeof(free_parms));\n+\t/* Since we are freeing all pending TCAM entries (which is typically\n+\t * done during tcam_unbind), we don't know the type of each entry.\n+\t * So we set the type to MAX as a hint to cfa_tcam_mgr_free() to\n+\t * figure out the actual type. We need to set it through each\n+\t * iteration in the loop below; otherwise, the type determined for\n+\t * the first entry would be used for subsequent entries that may or\n+\t * may not be of the same type, resulting in errors.\n+\t */\n+\tfor (entry_id = 0; entry_id < cfa_tcam_mgr_max_entries[sess_idx]; entry_id++) {\n+\t\tif (SBMP_MEMBER(session_bmp[sess_idx][entry_id], sess_idx)) {\n+\t\t\tSBMP_SESSION_REMOVE(session_bmp[sess_idx][entry_id], sess_idx);\n+\n+\t\t\tfree_parms.id = entry_id;\n+\t\t\tfree_parms.type = CFA_TCAM_MGR_TBL_TYPE_MAX;\n+\t\t\tcfa_tcam_mgr_free(context, &free_parms);\n+\t\t}\n+\t}\n+\n+\tmemset(&session_data[sess_idx], 0, sizeof(session_data[sess_idx]));\n+\treturn 0;\n+}\n+\n+int\n+cfa_tcam_mgr_session_cfg(unsigned int session_id,\n+\t\t\t uint16_t tcam_cnt[][CFA_TCAM_MGR_TBL_TYPE_MAX])\n+{\n+\tstruct cfa_tcam_mgr_table_data *table_data;\n+\tstruct cfa_tcam_mgr_session_data *session_entry;\n+\tunsigned int dir, type;\n+\tint sess_idx = cfa_tcam_mgr_session_find(session_id);\n+\tuint16_t requested_cnt;\n+\n+\tif (sess_idx < 0)\n+\t\treturn sess_idx;\n+\n+\tsession_entry = &session_data[sess_idx];\n+\n+\t/* Validate session request */\n+\tfor (dir = 0; dir < ARRAY_SIZE(cfa_tcam_mgr_tables[sess_idx]); dir++) {\n+\t\tfor (type = 0;\n+\t\t     type < ARRAY_SIZE(cfa_tcam_mgr_tables[sess_idx][dir]);\n+\t\t     type++) {\n+\t\t\ttable_data = &cfa_tcam_mgr_tables[sess_idx][dir][type];\n+\t\t\trequested_cnt = tcam_cnt[dir][type];\n+\t\t\t/*\n+\t\t\t * Only check if table supported (max_entries > 0).\n+\t\t\t */\n+\t\t\tif (table_data->max_entries > 0 &&\n+\t\t\t    requested_cnt > table_data->max_entries) {\n+\t\t\t\tCFA_TCAM_MGR_LOG_DIR_TYPE(ERR, dir, type,\n+\t\t\t\t\t\t\"Requested %d, available %d.\\n\",\n+\t\t\t\t\t\trequested_cnt,\n+\t\t\t\t\t\ttable_data->max_entries);\n+\t\t\t\treturn -CFA_TCAM_MGR_ERR_CODE(NOSPC);\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\tmemcpy(session_entry->max_entries, tcam_cnt,\n+\t       sizeof(session_entry->max_entries));\n+\treturn 0;\n+}\n+\n+void\n+cfa_tcam_mgr_mv_session_used_entries_cnt(int sess_idx, enum tf_dir dir,\n+\t\t\t\t\t enum cfa_tcam_mgr_tbl_type dst_type,\n+\t\t\t\t\t enum cfa_tcam_mgr_tbl_type src_type)\n+{\n+\tsession_data[sess_idx].used_entries[dir][dst_type]++;\n+\tsession_data[sess_idx].used_entries[dir][src_type]--;\n+}\n+\n+int\n+cfa_tcam_mgr_session_entry_alloc(unsigned int session_id,\n+\t\t\t\t enum tf_dir dir,\n+\t\t\t\t enum cfa_tcam_mgr_tbl_type type)\n+{\n+\tint sess_idx;\n+\n+\tsess_idx = cfa_tcam_mgr_session_find(session_id);\n+\tif (sess_idx < 0) {\n+\t\tCFA_TCAM_MGR_LOG_0(ERR, \"Session not found.\\n\");\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(NODEV);\n+\t}\n+\n+\tif (session_data[sess_idx].used_entries[dir][type] >=\n+\t    session_data[sess_idx].max_entries[dir][type]) {\n+\t\tCFA_TCAM_MGR_LOG_0(ERR, \"Table full (session).\\n\");\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(NOSPC);\n+\t}\n+\n+\tdo {\n+\t\tlast_entry_id++;\n+\t\tif (cfa_tcam_mgr_max_entries[sess_idx] <= last_entry_id)\n+\t\t\tlast_entry_id = 0;\n+\t} while (!SBMP_IS_NULL(session_bmp[sess_idx][last_entry_id]));\n+\n+\tSBMP_SESSION_ADD(session_bmp[sess_idx][last_entry_id], sess_idx);\n+\n+\tsession_data[sess_idx].used_entries[dir][type] += 1;\n+\n+\treturn last_entry_id;\n+}\n+\n+int\n+cfa_tcam_mgr_session_entry_free(unsigned int session_id,\n+\t\t\t\tunsigned int entry_id,\n+\t\t\t\tenum tf_dir dir,\n+\t\t\t\tenum cfa_tcam_mgr_tbl_type type)\n+{\n+\tint sess_idx;\n+\n+\tsess_idx = cfa_tcam_mgr_session_find(session_id);\n+\tif (sess_idx < 0) {\n+\t\tCFA_TCAM_MGR_LOG_0(ERR, \"Session not found.\\n\");\n+\t\treturn -CFA_TCAM_MGR_ERR_CODE(NODEV);\n+\t}\n+\n+\tSBMP_SESSION_REMOVE(session_bmp[sess_idx][entry_id], sess_idx);\n+\tsession_data[sess_idx].used_entries[dir][type] -= 1;\n+\n+\treturn 0;\n+}\n+\n+#if SBMP_WORD_WIDTH == 16\n+#define SBMP_FORMAT PRIX16\n+#define SBMP_PRECISION \"4\"\n+#elif SBMP_WORD_WIDTH == 32\n+#define SBMP_FORMAT PRIX32\n+#define SBMP_PRECISION \"8\"\n+#elif SBMP_WORD_WIDTH == 64\n+#define SBMP_FORMAT PRIX64\n+#define SBMP_PRECISION \"16\"\n+#else\n+#error \"Invalid value for SBMP_WORD_WIDTH.\"\n+#endif\n+\n+static void\n+cfa_tcam_mgr_session_bitmap_print(struct sbmp *session_bmp)\n+{\n+\tunsigned int i;\n+\n+\tprintf(\"0x\");\n+\tfor (i = 0;\n+\t     i < ARRAY_SIZE(session_bmp->bits);\n+\t     i++) {\n+\t\tprintf(\"%0\" SBMP_PRECISION SBMP_FORMAT,\n+\t\t       session_bmp->bits[i]);\n+\t}\n+}\n+\n+#define SESSION_DUMP_HEADER_1 \"                             RX          TX\\n\"\n+#define SESSION_DUMP_HEADER_2 \\\n+\t\"                         Max   Used  Max   Used\\n\"\n+\n+static void\n+cfa_tcam_mgr_session_printf(struct cfa_tcam_mgr_session_data *session,\n+\t\t\t    enum cfa_tcam_mgr_tbl_type tbl_type)\n+{\n+\tprintf(\"%-22s: %5u %5u %5u %5u\\n\",\n+\t       cfa_tcam_mgr_tbl_2_str(tbl_type),\n+\t       session->max_entries[TF_DIR_RX][tbl_type],\n+\t       session->used_entries[TF_DIR_RX][tbl_type],\n+\t       session->max_entries[TF_DIR_TX][tbl_type],\n+\t       session->used_entries[TF_DIR_TX][tbl_type]);\n+}\n+\n+void\n+cfa_tcam_mgr_sessions_dump(void)\n+{\n+\tstruct cfa_tcam_mgr_session_data *session;\n+\tunsigned int sess_idx;\n+\tbool sess_found = false;\n+\tenum cfa_tcam_mgr_tbl_type tbl_type;\n+\n+\tprintf(\"\\nTCAM Sessions Table:\\n\");\n+\tfor (sess_idx = 0; sess_idx < ARRAY_SIZE(session_data); sess_idx++) {\n+\t\tif (session_data[sess_idx].session_id != 0) {\n+\t\t\tsession = &session_data[sess_idx];\n+\t\t\tif (!sess_found) {\n+\t\t\t\tprintf(SESSION_DUMP_HEADER_1);\n+\t\t\t\tprintf(SESSION_DUMP_HEADER_2);\n+\t\t\t}\n+\t\t\tprintf(\"Session 0x%08x:\\n\",\n+\t\t\t       session->session_id);\n+\t\t\tfor (tbl_type = CFA_TCAM_MGR_TBL_TYPE_START;\n+\t\t\t     tbl_type < CFA_TCAM_MGR_TBL_TYPE_MAX;\n+\t\t\t     tbl_type++) {\n+\t\t\t\tcfa_tcam_mgr_session_printf(session, tbl_type);\n+\t\t\t}\n+\t\t\tsess_found = true;\n+\t\t}\n+\t}\n+\n+\tif (!sess_found)\n+\t\tprintf(\"No sessions found.\\n\");\n+}\n+\n+/* This dumps all the sessions using an entry */\n+void\n+cfa_tcam_mgr_entry_sessions_dump(int sess_idx, uint16_t id)\n+{\n+\tbool session_found = false;\n+\n+\tif (id >= cfa_tcam_mgr_max_entries[sess_idx]) {\n+\t\tprintf(\"Entry ID %u out of range for sess_idx %d.  Max ID %u.\\n\",\n+\t\t       id, sess_idx, cfa_tcam_mgr_max_entries[sess_idx] - 1);\n+\t\treturn;\n+\t}\n+\n+\tif (!SBMP_IS_NULL(session_bmp[sess_idx][id])) {\n+\t\tprintf(\"Sessions using entry ID %u:\\n\", id);\n+\t\tfor (sess_idx = 0; sess_idx < SBMP_SESSION_MAX; sess_idx++)\n+\t\t\tif (SBMP_MEMBER(session_bmp[sess_idx][id], (sess_idx))) {\n+\t\t\t\tif (session_data[sess_idx].session_id != 0) {\n+\t\t\t\t\tprintf(\"0x%08x (index %d)\\n\",\n+\t\t\t\t\t  session_data[sess_idx].session_id,\n+\t\t\t\t\t  sess_idx);\n+\t\t\t\t\tsession_found = true;\n+\t\t\t\t} else {\n+\t\t\t\t\tprintf(\"Error! Entry ID %u used by \"\n+\t\t\t\t\t       \"session index %d which is not \"\n+\t\t\t\t\t       \"in use.\\n\",\n+\t\t\t\t\t       id, sess_idx);\n+\t\t\t\t}\n+\t\t\t}\n+\t\tif (!session_found)\n+\t\t\tprintf(\"No sessions using entry ID %u.\\n\", id);\n+\t} else {\n+\t\tprintf(\"Entry ID %u not in use.\\n\",\n+\t\t       id);\n+\t\treturn;\n+\t}\n+}\n+\n+/* This dumps all the entries in use by any session */\n+void\n+cfa_tcam_mgr_session_entries_dump(int sess_idx)\n+{\n+\tbool entry_found = false;\n+\tuint16_t id;\n+\n+\tprintf(\"\\nGlobal Maximum Entries for sess_idx %d: %d\\n\\n\",\n+\t       sess_idx, cfa_tcam_mgr_max_entries[sess_idx]);\n+\tprintf(\"TCAM Session Entry Table:\\n\");\n+\tfor (id = 0; id < cfa_tcam_mgr_max_entries[sess_idx]; id++) {\n+\t\tif (!SBMP_IS_NULL(session_bmp[sess_idx][id])) {\n+\t\t\tif (!entry_found)\n+\t\t\t\tprintf(\"  EID Session bitmap\\n\");\n+\t\t\tprintf(\"%5u \", id);\n+\t\t\tcfa_tcam_mgr_session_bitmap_print(&session_bmp[sess_idx][id]);\n+\t\t\tprintf(\"\\n\");\n+\t\t\tentry_found = true;\n+\t\t}\n+\t}\n+\n+\tif (!entry_found)\n+\t\tprintf(\"No entries found.\\n\");\n+}\ndiff --git a/drivers/net/bnxt/tf_core/cfa_tcam_mgr_session.h b/drivers/net/bnxt/tf_core/cfa_tcam_mgr_session.h\nnew file mode 100644\nindex 0000000000..69311b7e1d\n--- /dev/null\n+++ b/drivers/net/bnxt/tf_core/cfa_tcam_mgr_session.h\n@@ -0,0 +1,54 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2019-2023 Broadcom\n+ * All rights reserved.\n+ */\n+\n+#ifndef CFA_TCAM_MGR_SESSION_H\n+#define CFA_TCAM_MGR_SESSION_H\n+\n+#include <inttypes.h>\n+#include \"cfa_tcam_mgr.h\"\n+\n+int\n+cfa_tcam_mgr_session_init(int sess_idx, enum cfa_tcam_mgr_device_type type);\n+\n+int\n+cfa_tcam_mgr_get_session_from_context(struct cfa_tcam_mgr_context *context,\n+\t\t\t\t      uint32_t *session_id);\n+\n+int\n+cfa_tcam_mgr_session_find(unsigned int session_id);\n+\n+int\n+cfa_tcam_mgr_session_add(unsigned int session_id);\n+\n+int\n+cfa_tcam_mgr_session_free(unsigned int session_id,\n+\t\tstruct cfa_tcam_mgr_context *context);\n+\n+int\n+cfa_tcam_mgr_session_cfg(unsigned int session_id,\n+\t\t\t uint16_t tcam_cnt[][CFA_TCAM_MGR_TBL_TYPE_MAX]);\n+\n+int\n+cfa_tcam_mgr_session_entry_alloc(unsigned int session_id,\n+\t\t\t\t enum tf_dir dir,\n+\t\t\t\t enum cfa_tcam_mgr_tbl_type type);\n+int\n+cfa_tcam_mgr_session_entry_free(unsigned int session_id,\n+\t\t\t\tunsigned int entry_id,\n+\t\t\t\tenum tf_dir dir,\n+\t\t\t\tenum cfa_tcam_mgr_tbl_type type);\n+\n+void\n+cfa_tcam_mgr_sessions_dump(void);\n+void\n+cfa_tcam_mgr_entry_sessions_dump(int sess_idx, uint16_t id);\n+void\n+cfa_tcam_mgr_session_entries_dump(int sess_idx);\n+\n+void\n+cfa_tcam_mgr_mv_session_used_entries_cnt(int sess_idx, enum tf_dir dir,\n+\t\t\t\t\t enum cfa_tcam_mgr_tbl_type dst_type,\n+\t\t\t\t\t enum cfa_tcam_mgr_tbl_type src_type);\n+#endif  /* CFA_TCAM_MGR_SESSION_H */\ndiff --git a/drivers/net/bnxt/tf_core/meson.build b/drivers/net/bnxt/tf_core/meson.build\nindex f812e471d1..ae44aa34cf 100644\n--- a/drivers/net/bnxt/tf_core/meson.build\n+++ b/drivers/net/bnxt/tf_core/meson.build\n@@ -1,36 +1,42 @@\n # SPDX-License-Identifier: BSD-3-Clause\n # Copyright(c) 2018 Intel Corporation\n-# Copyright(c) 2021 Broadcom\n+# Copyright(c) 2023 Broadcom\n \n #Include the folder for headers\n includes += include_directories('.')\n \n #Add the source files\n sources += files(\n-        'tf_core.c',\n         'bitalloc.c',\n-        'tf_msg.c',\n-        'll.c',\n+        'cfa_tcam_mgr.c',\n+        'cfa_tcam_mgr_hwop_msg.c',\n+        'cfa_tcam_mgr_p4.c',\n+        'cfa_tcam_mgr_p58.c',\n+        'cfa_tcam_mgr_session.c',\n         'dpool.c',\n+        'll.c',\n         'rand.c',\n         'stack.c',\n-        'tf_rm.c',\n-        'tf_tbl.c',\n-        'tf_tbl_sram.c',\n-        'tf_sram_mgr.c',\n+        'tf_core.c',\n+        'tf_device.c',\n+        'tf_device_p4.c',\n+        'tf_device_p58.c',\n         'tf_em_common.c',\n+        'tf_em_hash_internal.c',\n         'tf_em_host.c',\n         'tf_em_internal.c',\n-        'tf_em_hash_internal.c',\n-        'tfp.c',\n-        'tf_util.c',\n-        'tf_device.c',\n-        'tf_device_p4.c',\n         'tf_global_cfg.c',\n+        'tf_hash.c',\n         'tf_identifier.c',\n         'tf_if_tbl.c',\n+        'tf_msg.c',\n+        'tfp.c',\n+        'tf_rm.c',\n         'tf_session.c',\n+        'tf_sram_mgr.c',\n+        'tf_tbl.c',\n+        'tf_tbl_sram.c',\n         'tf_tcam.c',\n+        'tf_tcam_mgr_msg.c',\n         'tf_tcam_shared.c',\n-        'tf_hash.c',\n-        'tf_device_p58.c')\n+        'tf_util.c')\ndiff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c\nindex 038e439101..3a812bee3a 100644\n--- a/drivers/net/bnxt/tf_core/tf_core.c\n+++ b/drivers/net/bnxt/tf_core/tf_core.c\n@@ -1,5 +1,5 @@\n /* SPDX-License-Identifier: BSD-3-Clause\n- * Copyright(c) 2019-2021 Broadcom\n+ * Copyright(c) 2019-2023 Broadcom\n  * All rights reserved.\n  */\n \n@@ -34,8 +34,8 @@ tf_open_session(struct tf *tfp,\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    parms->device_type != TF_DEVICE_TYPE_THOR &&\n+\tif (parms->device_type != TF_DEVICE_TYPE_P4 &&\n+\t    parms->device_type != TF_DEVICE_TYPE_P5 &&\n \t    parms->device_type != TF_DEVICE_TYPE_SR) {\n \t\tTFP_DRV_LOG(ERR,\n \t\t\t    \"Unsupported device type %d\\n\",\n@@ -83,7 +83,7 @@ tf_open_session(struct tf *tfp,\n \t\treturn rc;\n \n \tTFP_DRV_LOG(INFO,\n-\t\t    \"domain:%d, bus:%d, device:%u\\n\",\n+\t\t    \"domain:%x, bus:%x, device:%u\\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@@ -176,7 +176,7 @@ tf_close_session(struct tf *tfp)\n \t\treturn rc;\n \n \tTFP_DRV_LOG(INFO,\n-\t\t    \"domain:%d, bus:%d, device:%d\\n\",\n+\t\t    \"domain:%d, bus:%x, device:%d\\n\",\n \t\t    cparms.session_id->internal.domain,\n \t\t    cparms.session_id->internal.bus,\n \t\t    cparms.session_id->internal.device);\n@@ -742,7 +742,6 @@ tf_set_tcam_entry(struct tf *tfp,\n \n \tmemset(&sparms, 0, sizeof(struct tf_tcam_set_parms));\n \n-\n \t/* Retrieve the session information */\n \trc = tf_session_get_session(tfp, &tfs);\n \tif (rc) {\n@@ -790,6 +789,10 @@ tf_set_tcam_entry(struct tf *tfp,\n \t\t\t    strerror(-rc));\n \t\treturn rc;\n \t}\n+\tTFP_DRV_LOG(DEBUG,\n+\t\t    \"%s: TCAM type %d set idx:%d key size %d result size %d\\n\",\n+\t\t    tf_dir_2_str(parms->dir), sparms.type,\n+\t\t    sparms.idx, sparms.key_size, sparms.result_size);\n \n \treturn 0;\n }\n@@ -807,7 +810,6 @@ tf_get_tcam_entry(struct tf *tfp __rte_unused,\n \n \tmemset(&gparms, 0, sizeof(struct tf_tcam_get_parms));\n \n-\n \t/* Retrieve the session information */\n \trc = tf_session_get_session(tfp, &tfs);\n \tif (rc) {\n@@ -1812,8 +1814,8 @@ int tf_get_version(struct tf *tfp,\n \t/* This function can be called before open session, filter\n \t * out any non-supported device types on the Core side.\n \t */\n-\tif (parms->device_type != TF_DEVICE_TYPE_WH &&\n-\t    parms->device_type != TF_DEVICE_TYPE_THOR &&\n+\tif (parms->device_type != TF_DEVICE_TYPE_P4 &&\n+\t    parms->device_type != TF_DEVICE_TYPE_P5 &&\n \t    parms->device_type != TF_DEVICE_TYPE_SR) {\n \t\tTFP_DRV_LOG(ERR,\n \t\t\t    \"Unsupported device type %d\\n\",\n@@ -1845,7 +1847,7 @@ int tf_query_sram_resources(struct tf *tfp,\n \t/* This function can be called before open session, filter\n \t * out any non-supported device types on the Core side.\n \t */\n-\tif (parms->device_type != TF_DEVICE_TYPE_THOR) {\n+\tif (parms->device_type != TF_DEVICE_TYPE_P5) {\n \t\tTFP_DRV_LOG(ERR,\n \t\t\t    \"Unsupported device type %d\\n\",\n \t\t\t    parms->device_type);\n@@ -1927,7 +1929,7 @@ int tf_set_sram_policy(struct tf *tfp,\n \t/* This function can be called before open session, filter\n \t * out any non-supported device types on the Core side.\n \t */\n-\tif (parms->device_type != TF_DEVICE_TYPE_THOR) {\n+\tif (parms->device_type != TF_DEVICE_TYPE_P5) {\n \t\tTFP_DRV_LOG(ERR,\n \t\t\t    \"Unsupported device type %d\\n\",\n \t\t\t    parms->device_type);\n@@ -1968,7 +1970,7 @@ int tf_get_sram_policy(struct tf *tfp,\n \t/* This function can be called before open session, filter\n \t * out any non-supported device types on the Core side.\n \t */\n-\tif (parms->device_type != TF_DEVICE_TYPE_THOR) {\n+\tif (parms->device_type != TF_DEVICE_TYPE_P5) {\n \t\tTFP_DRV_LOG(ERR,\n \t\t\t    \"Unsupported device type %d\\n\",\n \t\t\t    parms->device_type);\n@@ -1997,3 +1999,31 @@ int tf_get_sram_policy(struct tf *tfp,\n \n \treturn rc;\n }\n+\n+int tf_set_session_hotup_state(struct tf *tfp,\n+\t\t\t       struct tf_set_session_hotup_state_parms *parms)\n+{\n+\tint rc = 0;\n+\n+\tTF_CHECK_PARMS1(tfp);\n+\n+\trc = tf_session_set_hotup_state(tfp, parms);\n+\tif (rc)\n+\t\treturn rc;\n+\n+\treturn rc;\n+}\n+\n+int tf_get_session_hotup_state(struct tf *tfp,\n+\t\t\t       struct tf_get_session_hotup_state_parms *parms)\n+{\n+\tint rc = 0;\n+\n+\tTF_CHECK_PARMS1(tfp);\n+\n+\trc = tf_session_get_hotup_state(tfp, parms);\n+\tif (rc)\n+\t\treturn rc;\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 f5fe0a9098..3da1d2a5ca 100644\n--- a/drivers/net/bnxt/tf_core/tf_core.h\n+++ b/drivers/net/bnxt/tf_core/tf_core.h\n@@ -1,5 +1,5 @@\n /* SPDX-License-Identifier: BSD-3-Clause\n- * Copyright(c) 2019-2021 Broadcom\n+ * Copyright(c) 2019-2023 Broadcom\n  * All rights reserved.\n  */\n \n@@ -112,6 +112,10 @@ enum tf_sram_bank_id {\n  * @ref tf_attach_session\n  *\n  * @ref tf_close_session\n+ *\n+ * @ref tf_get_session_info\n+ *\n+ * @ref tf_get_session_info\n  */\n \n /**\n@@ -188,10 +192,10 @@ struct tf_session_version {\n  * Session supported device types\n  */\n enum tf_device_type {\n-\tTF_DEVICE_TYPE_WH = 0, /**< Whitney+  */\n-\tTF_DEVICE_TYPE_SR,     /**< Stingray  */\n-\tTF_DEVICE_TYPE_THOR,   /**< Thor      */\n-\tTF_DEVICE_TYPE_MAX     /**< Maximum   */\n+\tTF_DEVICE_TYPE_P4 = 0,\n+\tTF_DEVICE_TYPE_SR,\n+\tTF_DEVICE_TYPE_P5,\n+\tTF_DEVICE_TYPE_MAX\n };\n \n /**\n@@ -286,6 +290,8 @@ enum tf_tbl_type {\n \tTF_TBL_TYPE_ACT_ENCAP_32B,\n \t/** Wh+/SR/TH Action Encap 64 Bytes */\n \tTF_TBL_TYPE_ACT_ENCAP_64B,\n+\t/* TH Action Encap 128 Bytes */\n+\tTF_TBL_TYPE_ACT_ENCAP_128B,\n \t/** WH+/SR/TH Action Source Properties SMAC */\n \tTF_TBL_TYPE_ACT_SP_SMAC,\n \t/** Wh+/SR/TH Action Source Properties SMAC IPv4 */\n@@ -331,7 +337,7 @@ enum tf_tbl_type {\n \t * External table type - initially 1 poolsize entries.\n \t * All External table types are associated with a table\n \t * scope. Internal types are not.  Currently this is\n-\t * a pool of 64B entries.\n+\t * a pool of 128B entries.\n \t */\n \tTF_TBL_TYPE_EXT,\n \tTF_TBL_TYPE_MAX\n@@ -914,6 +920,71 @@ int tf_attach_session(struct tf *tfp,\n  */\n int tf_close_session(struct tf *tfp);\n \n+/**\n+ * tf_set_session_hotup_state parameter definition.\n+ */\n+struct tf_set_session_hotup_state_parms {\n+\t/**\n+\t * [in] the structure is used to set the state of\n+\t * the hotup shared session.\n+\t *\n+\t */\n+\tuint16_t state;\n+};\n+\n+/**\n+ * set hot upgrade shared session state\n+ *\n+ * This API is used to set the state of the shared session.\n+ *\n+ * [in] tfp\n+ *   Pointer to TF handle\n+ *\n+ * [in] parms\n+ *   Pointer to set hotup state parameters\n+ *\n+ * Returns\n+ *   - (0) if successful.\n+ *   - (-EINVAL) on failure.\n+ */\n+int tf_set_session_hotup_state(struct tf *tfp,\n+\t\t\t       struct tf_set_session_hotup_state_parms *parms);\n+\n+/**\n+ * tf_get_session_hotup_state parameter definition.\n+ */\n+struct tf_get_session_hotup_state_parms {\n+\t/**\n+\t * [out] the structure is used to get the state of\n+\t * the hotup shared session.\n+\t *\n+\t */\n+\tuint16_t state;\n+\t/**\n+\t * [out] get the ref_cnt of the hotup shared session.\n+\t *\n+\t */\n+\tuint16_t ref_cnt;\n+};\n+\n+/**\n+ * get hot upgrade shared session state\n+ *\n+ * This API is used to set the state of the shared session.\n+ *\n+ * [in] tfp\n+ *   Pointer to TF handle\n+ *\n+ * [in] parms\n+ *   Pointer to get hotup state parameters\n+ *\n+ * Returns\n+ *   - (0) if successful.\n+ *   - (-EINVAL) on failure.\n+ */\n+int tf_get_session_hotup_state(struct tf *tfp,\n+\t\t\t       struct tf_get_session_hotup_state_parms *parms);\n+\n /**\n  * @page  ident Identity Management\n  *\n@@ -1192,8 +1263,6 @@ int tf_free_tbl_scope(struct tf *tfp,\n  *\n  * @ref tf_get_tcam_entry\n  *\n- * @ref tf_free_tcam_entry\n- *\n  * @ref tf_move_tcam_shared_entries\n  *\n  * @ref tf_clear_tcam_shared_entries\n@@ -1258,7 +1327,7 @@ struct tf_search_tcam_entry_parms {\n };\n \n /**\n- * search TCAM entry (experimental)\n+ * search TCAM entry\n  *\n  * Search for a TCAM entry\n  *\n@@ -1732,7 +1801,7 @@ struct tf_get_shared_tbl_increment_parms {\n  * tf_get_shared_tbl_increment\n  *\n  * This API is currently only required for use in the shared\n- * session for Thor (p58) actions.  An increment count is returned per\n+ * session for P5 actions.  An increment count is returned per\n  * type to indicate how much to increment the start by for each\n  * entry (see tf_resource_info)\n  *\n@@ -1898,6 +1967,7 @@ struct tf_insert_em_entry_parms {\n \t */\n \tuint64_t flow_id;\n };\n+\n /**\n  * tf_delete_em_entry parameter definition\n  */\n@@ -1927,6 +1997,7 @@ struct tf_delete_em_entry_parms {\n \t */\n \tuint64_t flow_handle;\n };\n+\n /**\n  * tf_move_em_entry parameter definition\n  */\n@@ -1969,6 +2040,7 @@ struct tf_move_em_entry_parms {\n \t */\n \tuint64_t flow_handle;\n };\n+\n /**\n  * tf_search_em_entry parameter definition (Future)\n  */\n@@ -2108,6 +2180,7 @@ int tf_search_em_entry(struct tf *tfp,\n  *\n  * @ref tf_get_global_cfg\n  */\n+\n /**\n  * Tunnel Encapsulation Offsets\n  */\n@@ -2121,6 +2194,7 @@ enum tf_tunnel_encap_offsets {\n \tTF_TUNNEL_ENCAP_GRE,\n \tTF_TUNNEL_ENCAP_FULL_GENERIC\n };\n+\n /**\n  * Global Configuration Table Types\n  */\n@@ -2193,9 +2267,8 @@ int tf_set_global_cfg(struct tf *tfp,\n  * @ref tf_set_if_tbl_entry\n  *\n  * @ref tf_get_if_tbl_entry\n- *\n- * @ref tf_restore_if_tbl_entry\n  */\n+\n /**\n  * Enumeration of TruFlow interface table types.\n  */\ndiff --git a/drivers/net/bnxt/tf_core/tf_device.c b/drivers/net/bnxt/tf_core/tf_device.c\nindex 1c97218b5b..02a9ebd7b2 100644\n--- a/drivers/net/bnxt/tf_core/tf_device.c\n+++ b/drivers/net/bnxt/tf_core/tf_device.c\n@@ -1,5 +1,5 @@\n /* SPDX-License-Identifier: BSD-3-Clause\n- * Copyright(c) 2019-2021 Broadcom\n+ * Copyright(c) 2019-2023 Broadcom\n  * All rights reserved.\n  */\n \n@@ -332,7 +332,7 @@ tf_dev_unbind_p4(struct tf *tfp)\n }\n \n /**\n- * Device specific bind function, THOR\n+ * Device specific bind function, P5\n  *\n  * [in] tfp\n  *   Pointer to TF handle\n@@ -504,7 +504,7 @@ tf_dev_bind_p58(struct tf *tfp,\n }\n \n /**\n- * Device specific unbind function, THOR\n+ * Device specific unbind function, P5\n  *\n  * [in] tfp\n  *   Pointer to TF handle\n@@ -602,14 +602,14 @@ tf_dev_bind(struct tf *tfp __rte_unused,\n \t    struct tf_dev_info *dev_handle)\n {\n \tswitch (type) {\n-\tcase TF_DEVICE_TYPE_WH:\n+\tcase TF_DEVICE_TYPE_P4:\n \tcase TF_DEVICE_TYPE_SR:\n \t\tdev_handle->type = type;\n \t\treturn tf_dev_bind_p4(tfp,\n \t\t\t\t      resources,\n \t\t\t\t      dev_handle,\n \t\t\t\t      wc_num_slices);\n-\tcase TF_DEVICE_TYPE_THOR:\n+\tcase TF_DEVICE_TYPE_P5:\n \t\tdev_handle->type = type;\n \t\treturn tf_dev_bind_p58(tfp,\n \t\t\t\t       resources,\n@@ -627,11 +627,11 @@ tf_dev_bind_ops(enum tf_device_type type,\n \t\tstruct tf_dev_info *dev_handle)\n {\n \tswitch (type) {\n-\tcase TF_DEVICE_TYPE_WH:\n+\tcase TF_DEVICE_TYPE_P4:\n \tcase TF_DEVICE_TYPE_SR:\n \t\tdev_handle->ops = &tf_dev_ops_p4_init;\n \t\tbreak;\n-\tcase TF_DEVICE_TYPE_THOR:\n+\tcase TF_DEVICE_TYPE_P5:\n \t\tdev_handle->ops = &tf_dev_ops_p58_init;\n \t\tbreak;\n \tdefault:\n@@ -648,10 +648,10 @@ tf_dev_unbind(struct tf *tfp,\n \t      struct tf_dev_info *dev_handle)\n {\n \tswitch (dev_handle->type) {\n-\tcase TF_DEVICE_TYPE_WH:\n+\tcase TF_DEVICE_TYPE_P4:\n \tcase TF_DEVICE_TYPE_SR:\n \t\treturn tf_dev_unbind_p4(tfp);\n-\tcase TF_DEVICE_TYPE_THOR:\n+\tcase TF_DEVICE_TYPE_P5:\n \t\treturn tf_dev_unbind_p58(tfp);\n \tdefault:\n \t\tTFP_DRV_LOG(ERR,\ndiff --git a/drivers/net/bnxt/tf_core/tf_device.h b/drivers/net/bnxt/tf_core/tf_device.h\nindex 5a42180719..06c17a7212 100644\n--- a/drivers/net/bnxt/tf_core/tf_device.h\n+++ b/drivers/net/bnxt/tf_core/tf_device.h\n@@ -1,5 +1,5 @@\n /* SPDX-License-Identifier: BSD-3-Clause\n- * Copyright(c) 2019-2021 Broadcom\n+ * Copyright(c) 2019-2023 Broadcom\n  * All rights reserved.\n  */\n \ndiff --git a/drivers/net/bnxt/tf_core/tf_device_p4.c b/drivers/net/bnxt/tf_core/tf_device_p4.c\nindex 72c6b1cde8..911ea92471 100644\n--- a/drivers/net/bnxt/tf_core/tf_device_p4.c\n+++ b/drivers/net/bnxt/tf_core/tf_device_p4.c\n@@ -1,5 +1,5 @@\n /* SPDX-License-Identifier: BSD-3-Clause\n- * Copyright(c) 2019-2021 Broadcom\n+ * Copyright(c) 2019-2023 Broadcom\n  * All rights reserved.\n  */\n \n@@ -296,11 +296,15 @@ tf_dev_p4_get_tcam_slice_info(struct tf *tfp,\n \t\treturn rc;\n \n /* Single slice support */\n-#define CFA_P4_WC_TCAM_SLICE_SIZE     12\n-\n+#define CFA_P4_WC_TCAM_SLICE_SIZE   (12)\n \tif (type == TF_TCAM_TBL_TYPE_WC_TCAM) {\n-\t\t*num_slices_per_row = tfs->wc_num_slices_per_row;\n-\t\tif (key_sz > *num_slices_per_row * CFA_P4_WC_TCAM_SLICE_SIZE)\n+\t\tif (key_sz <= 1 * CFA_P4_WC_TCAM_SLICE_SIZE)\n+\t\t\t*num_slices_per_row = TF_WC_TCAM_1_SLICE_PER_ROW;\n+\t\telse if (key_sz <= 2 * CFA_P4_WC_TCAM_SLICE_SIZE)\n+\t\t\t*num_slices_per_row = TF_WC_TCAM_2_SLICE_PER_ROW;\n+\t\telse if (key_sz <= 4 * CFA_P4_WC_TCAM_SLICE_SIZE)\n+\t\t\t*num_slices_per_row = TF_WC_TCAM_4_SLICE_PER_ROW;\n+\t\telse\n \t\t\treturn -ENOTSUP;\n \t} else { /* for other type of tcam */\n \t\t*num_slices_per_row = 1;\ndiff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c\nindex f8b424ebc9..6916c50fdc 100644\n--- a/drivers/net/bnxt/tf_core/tf_device_p58.c\n+++ b/drivers/net/bnxt/tf_core/tf_device_p58.c\n@@ -1,5 +1,5 @@\n /* SPDX-License-Identifier: BSD-3-Clause\n- * Copyright(c) 2019-2021 Broadcom\n+ * Copyright(c) 2019-2023 Broadcom\n  * All rights reserved.\n  */\n \n@@ -16,6 +16,7 @@\n #include \"tfp.h\"\n #include \"tf_msg_common.h\"\n #include \"tf_tbl_sram.h\"\n+#include \"tf_util.h\"\n \n #define TF_DEV_P58_PARIF_MAX 16\n #define TF_DEV_P58_PF_MASK 0xfUL\n@@ -79,33 +80,39 @@ struct tf_rm_element_cfg tf_tbl_p58[TF_DIR_MAX][TF_TBL_TYPE_MAX] = {\n \t[TF_DIR_RX][TF_TBL_TYPE_FULL_ACT_RECORD] = {\n \t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_PARENT,\n \t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_1,\n-\t\t.slices          = 4,\n+\t\t.slices          = 8,\n \t},\n \t[TF_DIR_RX][TF_TBL_TYPE_COMPACT_ACT_RECORD] = {\n \t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,\n \t\t.parent_subtype  = TF_TBL_TYPE_FULL_ACT_RECORD,\n \t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_1,\n-\t\t.slices          = 8,\n+\t\t.slices          = 16,\n \t},\n \t/* Policy - Encaps in bank 2 */\n \t[TF_DIR_RX][TF_TBL_TYPE_ACT_ENCAP_8B] = {\n \t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_PARENT,\n \t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,\n-\t\t.slices          = 8,\n+\t\t.slices          = 16,\n \t},\n \t[TF_DIR_RX][TF_TBL_TYPE_ACT_ENCAP_16B] = {\n \t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,\n \t\t.parent_subtype  = TF_TBL_TYPE_ACT_ENCAP_8B,\n \t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,\n-\t\t.slices          = 4,\n+\t\t.slices          = 8,\n \t},\n \t[TF_DIR_RX][TF_TBL_TYPE_ACT_ENCAP_32B] = {\n \t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,\n \t\t.parent_subtype  = TF_TBL_TYPE_ACT_ENCAP_8B,\n \t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,\n-\t\t.slices          = 2,\n+\t\t.slices          = 4,\n \t},\n \t[TF_DIR_RX][TF_TBL_TYPE_ACT_ENCAP_64B] = {\n+\t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,\n+\t\t.parent_subtype  = TF_TBL_TYPE_ACT_ENCAP_8B,\n+\t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,\n+\t\t.slices          = 2,\n+\t},\n+\t[TF_DIR_RX][TF_TBL_TYPE_ACT_ENCAP_128B] = {\n \t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,\n \t\t.parent_subtype  = TF_TBL_TYPE_ACT_ENCAP_8B,\n \t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,\n@@ -116,49 +123,49 @@ struct tf_rm_element_cfg tf_tbl_p58[TF_DIR_MAX][TF_TBL_TYPE_MAX] = {\n \t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,\n \t\t.parent_subtype  = TF_TBL_TYPE_ACT_ENCAP_8B,\n \t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,\n-\t\t.slices          = 8,\n+\t\t.slices          = 16,\n \t},\n \t[TF_DIR_RX][TF_TBL_TYPE_ACT_MODIFY_16B] = {\n \t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,\n \t\t.parent_subtype  = TF_TBL_TYPE_ACT_ENCAP_8B,\n \t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,\n-\t\t.slices          = 4,\n+\t\t.slices          = 8,\n \t},\n \t[TF_DIR_RX][TF_TBL_TYPE_ACT_MODIFY_32B] = {\n \t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,\n \t\t.parent_subtype  = TF_TBL_TYPE_ACT_ENCAP_8B,\n \t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,\n-\t\t.slices          = 2,\n+\t\t.slices          = 4,\n \t},\n \t[TF_DIR_RX][TF_TBL_TYPE_ACT_MODIFY_64B] = {\n \t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,\n \t\t.parent_subtype  = TF_TBL_TYPE_ACT_ENCAP_8B,\n \t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,\n-\t\t.slices          = 1,\n+\t\t.slices          = 2,\n \t},\n \t/* Policy - SP in bank 0 */\n \t[TF_DIR_RX][TF_TBL_TYPE_ACT_SP_SMAC] = {\n \t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_PARENT,\n \t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_0,\n-\t\t.slices          = 8,\n+\t\t.slices          = 16,\n \t},\n \t[TF_DIR_RX][TF_TBL_TYPE_ACT_SP_SMAC_IPV4] = {\n \t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,\n \t\t.parent_subtype  = TF_TBL_TYPE_ACT_SP_SMAC,\n \t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_0,\n-\t\t.slices          = 4,\n+\t\t.slices          = 8,\n \t},\n \t[TF_DIR_RX][TF_TBL_TYPE_ACT_SP_SMAC_IPV6] = {\n \t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,\n \t\t.parent_subtype  = TF_TBL_TYPE_ACT_SP_SMAC,\n \t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_0,\n-\t\t.slices          = 2,\n+\t\t.slices          = 4,\n \t},\n \t/* Policy - Stats in bank 3 */\n \t[TF_DIR_RX][TF_TBL_TYPE_ACT_STATS_64] = {\n \t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_PARENT,\n \t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_3,\n-\t\t.slices          = 8,\n+\t\t.slices          = 16,\n \t},\n \t[TF_DIR_TX][TF_TBL_TYPE_EM_FKB] = {\n \t\tTF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_EM_FKB,\n@@ -192,33 +199,39 @@ struct tf_rm_element_cfg tf_tbl_p58[TF_DIR_MAX][TF_TBL_TYPE_MAX] = {\n \t[TF_DIR_TX][TF_TBL_TYPE_FULL_ACT_RECORD] = {\n \t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_PARENT,\n \t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_1,\n-\t\t.slices          = 4,\n+\t\t.slices          = 8,\n \t},\n \t[TF_DIR_TX][TF_TBL_TYPE_COMPACT_ACT_RECORD] = {\n \t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,\n \t\t.parent_subtype  = TF_TBL_TYPE_FULL_ACT_RECORD,\n \t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_1,\n-\t\t.slices          = 8,\n+\t\t.slices          = 16,\n \t},\n \t/* Policy - Encaps in bank 2 */\n \t[TF_DIR_TX][TF_TBL_TYPE_ACT_ENCAP_8B] = {\n \t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_PARENT,\n \t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,\n-\t\t.slices          = 8,\n+\t\t.slices          = 16,\n \t},\n \t[TF_DIR_TX][TF_TBL_TYPE_ACT_ENCAP_16B] = {\n \t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,\n \t\t.parent_subtype  = TF_TBL_TYPE_ACT_ENCAP_8B,\n \t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,\n-\t\t.slices          = 4,\n+\t\t.slices          = 8,\n \t},\n \t[TF_DIR_TX][TF_TBL_TYPE_ACT_ENCAP_32B] = {\n \t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,\n \t\t.parent_subtype  = TF_TBL_TYPE_ACT_ENCAP_8B,\n \t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,\n-\t\t.slices          = 2,\n+\t\t.slices          = 4,\n \t},\n \t[TF_DIR_TX][TF_TBL_TYPE_ACT_ENCAP_64B] = {\n+\t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,\n+\t\t.parent_subtype  = TF_TBL_TYPE_ACT_ENCAP_8B,\n+\t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,\n+\t\t.slices          = 2,\n+\t},\n+\t[TF_DIR_TX][TF_TBL_TYPE_ACT_ENCAP_128B] = {\n \t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,\n \t\t.parent_subtype  = TF_TBL_TYPE_ACT_ENCAP_8B,\n \t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,\n@@ -229,49 +242,49 @@ struct tf_rm_element_cfg tf_tbl_p58[TF_DIR_MAX][TF_TBL_TYPE_MAX] = {\n \t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,\n \t\t.parent_subtype  = TF_TBL_TYPE_ACT_ENCAP_8B,\n \t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,\n-\t\t.slices          = 8,\n+\t\t.slices          = 16,\n \t},\n \t[TF_DIR_TX][TF_TBL_TYPE_ACT_MODIFY_16B] = {\n \t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,\n \t\t.parent_subtype  = TF_TBL_TYPE_ACT_ENCAP_8B,\n \t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,\n-\t\t.slices          = 4,\n+\t\t.slices          = 8,\n \t},\n \t[TF_DIR_TX][TF_TBL_TYPE_ACT_MODIFY_32B] = {\n \t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,\n \t\t.parent_subtype  = TF_TBL_TYPE_ACT_ENCAP_8B,\n \t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,\n-\t\t.slices          = 2,\n+\t\t.slices          = 4,\n \t},\n \t[TF_DIR_TX][TF_TBL_TYPE_ACT_MODIFY_64B] = {\n \t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,\n \t\t.parent_subtype  = TF_TBL_TYPE_ACT_ENCAP_8B,\n \t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,\n-\t\t.slices          = 1,\n+\t\t.slices          = 2,\n \t},\n \t/* Policy - SP in bank 0 */\n \t[TF_DIR_TX][TF_TBL_TYPE_ACT_SP_SMAC] = {\n \t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_PARENT,\n \t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_0,\n-\t\t.slices\t         = 8,\n+\t\t.slices\t         = 16,\n \t},\n \t[TF_DIR_TX][TF_TBL_TYPE_ACT_SP_SMAC_IPV4] = {\n \t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,\n \t\t.parent_subtype  = TF_TBL_TYPE_ACT_SP_SMAC,\n \t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_0,\n-\t\t.slices\t         = 4,\n+\t\t.slices\t         = 8,\n \t},\n \t[TF_DIR_TX][TF_TBL_TYPE_ACT_SP_SMAC_IPV6] = {\n \t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,\n \t\t.parent_subtype  = TF_TBL_TYPE_ACT_SP_SMAC,\n \t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_0,\n-\t\t.slices\t         = 2,\n+\t\t.slices\t         = 4,\n \t},\n \t/* Policy - Stats in bank 3 */\n \t[TF_DIR_TX][TF_TBL_TYPE_ACT_STATS_64] = {\n \t\t.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_PARENT,\n \t\t.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_3,\n-\t\t.slices          = 8,\n+\t\t.slices          = 16,\n \t},\n };\n \n@@ -406,10 +419,15 @@ tf_dev_p58_get_tcam_slice_info(struct tf *tfp,\n \tif (rc)\n \t\treturn rc;\n \n-#define CFA_P58_WC_TCAM_SLICE_SIZE     24\n+#define CFA_P58_WC_TCAM_SLICE_SIZE (24)\n \tif (type == TF_TCAM_TBL_TYPE_WC_TCAM) {\n-\t\t*num_slices_per_row = tfs->wc_num_slices_per_row;\n-\t\tif (key_sz > *num_slices_per_row * CFA_P58_WC_TCAM_SLICE_SIZE)\n+\t\tif (key_sz <= 1 * CFA_P58_WC_TCAM_SLICE_SIZE)\n+\t\t\t*num_slices_per_row = TF_WC_TCAM_1_SLICE_PER_ROW;\n+\t\telse if (key_sz <= 2 * CFA_P58_WC_TCAM_SLICE_SIZE)\n+\t\t\t*num_slices_per_row = TF_WC_TCAM_2_SLICE_PER_ROW;\n+\t\telse if (key_sz <= 4 * CFA_P58_WC_TCAM_SLICE_SIZE)\n+\t\t\t*num_slices_per_row = TF_WC_TCAM_4_SLICE_PER_ROW;\n+\t\telse\n \t\t\treturn -ENOTSUP;\n \t} else { /* for other type of tcam */\n \t\t*num_slices_per_row = 1;\n@@ -452,6 +470,7 @@ static int tf_dev_p58_get_shared_tbl_increment(struct tf *tfp __rte_unused,\n \tcase TF_TBL_TYPE_ACT_ENCAP_16B:\n \tcase TF_TBL_TYPE_ACT_ENCAP_32B:\n \tcase TF_TBL_TYPE_ACT_ENCAP_64B:\n+\tcase TF_TBL_TYPE_ACT_ENCAP_128B:\n \tcase TF_TBL_TYPE_ACT_SP_SMAC:\n \tcase TF_TBL_TYPE_ACT_SP_SMAC_IPV4:\n \tcase TF_TBL_TYPE_ACT_SP_SMAC_IPV6:\n@@ -461,7 +480,7 @@ static int tf_dev_p58_get_shared_tbl_increment(struct tf *tfp __rte_unused,\n \tcase TF_TBL_TYPE_ACT_MODIFY_16B:\n \tcase TF_TBL_TYPE_ACT_MODIFY_32B:\n \tcase TF_TBL_TYPE_ACT_MODIFY_64B:\n-\t\tparms->increment_cnt = 8;\n+\t\tparms->increment_cnt = 16;\n \t\tbreak;\n \tdefault:\n \t\tparms->increment_cnt = 1;\n@@ -493,6 +512,7 @@ static bool tf_dev_p58_is_sram_managed(struct tf *tfp __rte_unused,\n \tcase TF_TBL_TYPE_ACT_ENCAP_16B:\n \tcase TF_TBL_TYPE_ACT_ENCAP_32B:\n \tcase TF_TBL_TYPE_ACT_ENCAP_64B:\n+\tcase TF_TBL_TYPE_ACT_ENCAP_128B:\n \tcase TF_TBL_TYPE_ACT_SP_SMAC:\n \tcase TF_TBL_TYPE_ACT_SP_SMAC_IPV4:\n \tcase TF_TBL_TYPE_ACT_SP_SMAC_IPV6:\n@@ -527,7 +547,7 @@ static bool tf_dev_p58_is_sram_managed(struct tf *tfp __rte_unused,\n  *\n  * [in/out] shift\n  *   Pointer to the factor to be used as a multiplier to translate\n- *   between the RM units to the user address.  SRAM manages 64B entries\n+ *   between the RM units to the user address.  SRAM manages 128B entries\n  *   Addresses must be shifted to an 8B address.\n  *\n  * Returns\ndiff --git a/drivers/net/bnxt/tf_core/tf_em_common.c b/drivers/net/bnxt/tf_core/tf_em_common.c\nindex b56b7cc188..c518150d1f 100644\n--- a/drivers/net/bnxt/tf_core/tf_em_common.c\n+++ b/drivers/net/bnxt/tf_core/tf_em_common.c\n@@ -1000,8 +1000,8 @@ tf_em_ext_common_unbind(struct tf *tfp)\n \t\t\t    strerror(-rc));\n \t\treturn rc;\n \t}\n-\text_db = (struct em_ext_db *)ext_ptr;\n \n+\text_db = (struct em_ext_db *)ext_ptr;\n \tif (ext_db != NULL) {\n \t\tentry = ext_db->tbl_scope_ll.head;\n \t\twhile (entry != NULL) {\ndiff --git a/drivers/net/bnxt/tf_core/tf_em_internal.c b/drivers/net/bnxt/tf_core/tf_em_internal.c\nindex 8ea5d93672..46de63a9da 100644\n--- a/drivers/net/bnxt/tf_core/tf_em_internal.c\n+++ b/drivers/net/bnxt/tf_core/tf_em_internal.c\n@@ -7,7 +7,6 @@\n #include <rte_common.h>\n #include <rte_errno.h>\n #include <rte_log.h>\n-\n #include \"tf_core.h\"\n #include \"tf_util.h\"\n #include \"tf_common.h\"\n@@ -63,7 +62,6 @@ tf_em_insert_int_entry(struct tf *tfp,\n \t\treturn -1;\n \t}\n \n-\n \trptr_index = index;\n \trc = tf_msg_insert_em_internal_entry(tfp,\n \t\t\t\t\t     parms,\n@@ -75,6 +73,7 @@ tf_em_insert_int_entry(struct tf *tfp,\n \t\tdpool_free(pool, index);\n \t\treturn -1;\n \t}\n+\n \tTF_SET_GFID(gfid,\n \t\t    ((rptr_index << TF_EM_INTERNAL_INDEX_SHIFT) |\n \t\t     rptr_entry),\n@@ -95,7 +94,6 @@ tf_em_insert_int_entry(struct tf *tfp,\n \treturn 0;\n }\n \n-\n /** Delete EM internal entry API\n  *\n  * returns:\n@@ -253,7 +251,6 @@ tf_em_int_bind(struct tf *tfp,\n \t\treturn db_rc[TF_DIR_RX];\n \t}\n \n-\n \tif (!tf_session_is_shared_session(tfs)) {\n \t\tfor (i = 0; i < TF_DIR_MAX; i++) {\n \t\t\tiparms.rm_db = em_db->em_db[i];\n@@ -335,11 +332,10 @@ tf_em_int_unbind(struct tf *tfp)\n \t}\n \n \trc = tf_session_get_db(tfp, TF_MODULE_TYPE_EM, &em_db_ptr);\n-\tif (rc) {\n+\tif (rc)\n \t\treturn 0;\n-\t}\n-\tem_db = (struct em_rm_db *)em_db_ptr;\n \n+\tem_db = (struct em_rm_db *)em_db_ptr;\n \tfor (i = 0; i < TF_DIR_MAX; i++) {\n \t\tif (em_db->em_db[i] == NULL)\n \t\t\tcontinue;\ndiff --git a/drivers/net/bnxt/tf_core/tf_identifier.c b/drivers/net/bnxt/tf_core/tf_identifier.c\nindex 1846675916..7d9d9595dd 100644\n--- a/drivers/net/bnxt/tf_core/tf_identifier.c\n+++ b/drivers/net/bnxt/tf_core/tf_identifier.c\n@@ -89,6 +89,7 @@ tf_ident_unbind(struct tf *tfp)\n \trc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr);\n \tif (rc)\n \t\treturn 0;\n+\n \tident_db = (struct ident_rm_db *)ident_db_ptr;\n \n \tfor (i = 0; i < TF_DIR_MAX; i++) {\ndiff --git a/drivers/net/bnxt/tf_core/tf_if_tbl.c b/drivers/net/bnxt/tf_core/tf_if_tbl.c\nindex e667d6fa6d..578d361417 100644\n--- a/drivers/net/bnxt/tf_core/tf_if_tbl.c\n+++ b/drivers/net/bnxt/tf_core/tf_if_tbl.c\n@@ -1,5 +1,5 @@\n /* SPDX-License-Identifier: BSD-3-Clause\n- * Copyright(c) 2019-2021 Broadcom\n+ * Copyright(c) 2019-2023 Broadcom\n  * All rights reserved.\n  */\n \n@@ -21,12 +21,6 @@ struct tf_if_tbl_db {\n \tstruct tf_if_tbl_cfg *if_tbl_cfg_db[TF_DIR_MAX];\n };\n \n-/**\n- * Init flag, set on bind and cleared on unbind\n- * TODO: Store this data in session db\n- */\n-static uint8_t init;\n-\n /**\n  * Convert if_tbl_type to hwrm type.\n  *\n@@ -80,8 +74,6 @@ tf_if_tbl_bind(struct tf *tfp,\n \tif_tbl_db->if_tbl_cfg_db[TF_DIR_TX] = parms->cfg;\n \ttf_session_set_if_tbl_db(tfp, (void *)if_tbl_db);\n \n-\tinit = 1;\n-\n \tTFP_DRV_LOG(INFO,\n \t\t    \"Table Type - initialized\\n\");\n \n@@ -92,14 +84,7 @@ int\n tf_if_tbl_unbind(struct tf *tfp)\n {\n \tint rc;\n-\tstruct tf_if_tbl_db *if_tbl_db_ptr;\n-\n-\t/* Bail if nothing has been initialized */\n-\tif (!init) {\n-\t\tTFP_DRV_LOG(INFO,\n-\t\t\t    \"No Table DBs created\\n\");\n-\t\treturn 0;\n-\t}\n+\tstruct tf_if_tbl_db *if_tbl_db_ptr = NULL;\n \n \tTF_CHECK_PARMS1(tfp);\n \n@@ -108,9 +93,15 @@ tf_if_tbl_unbind(struct tf *tfp)\n \t\tTFP_DRV_LOG(INFO, \"No IF Table DBs initialized\\n\");\n \t\treturn 0;\n \t}\n+\t/* Bail if nothing has been initialized */\n+\tif (!if_tbl_db_ptr) {\n+\t\tTFP_DRV_LOG(INFO,\n+\t\t\t    \"No Table DBs created\\n\");\n+\t\treturn 0;\n+\t}\n \n \ttfp_free((void *)if_tbl_db_ptr);\n-\tinit = 0;\n+\ttf_session_set_if_tbl_db(tfp, NULL);\n \n \treturn 0;\n }\n@@ -120,24 +111,24 @@ tf_if_tbl_set(struct tf *tfp,\n \t      struct tf_if_tbl_set_parms *parms)\n {\n \tint rc;\n-\tstruct tf_if_tbl_db *if_tbl_db_ptr;\n+\tstruct tf_if_tbl_db *if_tbl_db_ptr = NULL;\n \tstruct tf_if_tbl_get_hcapi_parms hparms;\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 \trc = tf_session_get_if_tbl_db(tfp, (void **)&if_tbl_db_ptr);\n \tif (rc) {\n \t\tTFP_DRV_LOG(INFO, \"No IF Table DBs initialized\\n\");\n \t\treturn 0;\n \t}\n \n+\tif (!if_tbl_db_ptr) {\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/* Convert TF type to HCAPI type */\n \thparms.tbl_db = if_tbl_db_ptr->if_tbl_cfg_db[parms->dir];\n \thparms.db_index = parms->type;\n@@ -163,24 +154,24 @@ tf_if_tbl_get(struct tf *tfp,\n \t      struct tf_if_tbl_get_parms *parms)\n {\n \tint rc = 0;\n-\tstruct tf_if_tbl_db *if_tbl_db_ptr;\n+\tstruct tf_if_tbl_db *if_tbl_db_ptr = NULL;\n \tstruct tf_if_tbl_get_hcapi_parms hparms;\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 \trc = tf_session_get_if_tbl_db(tfp, (void **)&if_tbl_db_ptr);\n \tif (rc) {\n \t\tTFP_DRV_LOG(INFO, \"No IF Table DBs initialized\\n\");\n \t\treturn 0;\n \t}\n \n+\tif (!if_tbl_db_ptr) {\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/* Convert TF type to HCAPI type */\n \thparms.tbl_db = if_tbl_db_ptr->if_tbl_cfg_db[parms->dir];\n \thparms.db_index = parms->type;\ndiff --git a/drivers/net/bnxt/tf_core/tf_msg.c b/drivers/net/bnxt/tf_core/tf_msg.c\nindex fbc96d374c..1c66c7e01a 100644\n--- a/drivers/net/bnxt/tf_core/tf_msg.c\n+++ b/drivers/net/bnxt/tf_core/tf_msg.c\n@@ -1,5 +1,5 @@\n /* SPDX-License-Identifier: BSD-3-Clause\n- * Copyright(c) 2019-2021 Broadcom\n+ * Copyright(c) 2019-2023 Broadcom\n  * All rights reserved.\n  */\n \n@@ -47,7 +47,6 @@ static_assert(sizeof(struct hwrm_tf_global_cfg_set_input) ==\n static_assert(sizeof(struct hwrm_tf_em_insert_input) ==\n \t      TF_MSG_SIZE_HWRM_TF_EM_INSERT,\n \t      \"HWRM message size changed: hwrm_tf_em_insert_input\");\n-\n #define TF_MSG_SIZE_HWRM_TF_TBL_TYPE_SET   128\n static_assert(sizeof(struct hwrm_tf_tbl_type_set_input) ==\n \t      TF_MSG_SIZE_HWRM_TF_TBL_TYPE_SET,\n@@ -61,13 +60,18 @@ static_assert(sizeof(struct hwrm_tf_tbl_type_set_input) ==\n /**\n  * This is the length of shared session name \"tf_share\"\n  */\n-#define TF_SHARED_SESSION_NAME_LEN 8\n+#define TF_SHARED_SESSION_NAME_LEN 9\n \n /**\n  * This is the length of tcam shared session name \"tf_shared-wc_tcam\"\n  */\n #define TF_TCAM_SHARED_SESSION_NAME_LEN 17\n \n+/**\n+ * This is the length of tcam shared session name \"tf_shared-poolx\"\n+ */\n+#define TF_POOL_SHARED_SESSION_NAME_LEN 16\n+\n /**\n  * If data bigger than TF_PCI_BUF_SIZE_MAX then use DMA method\n  */\n@@ -135,18 +139,30 @@ tf_msg_session_open(struct bnxt *bp,\n \tstruct hwrm_tf_session_open_input req = { 0 };\n \tstruct hwrm_tf_session_open_output resp = { 0 };\n \tstruct tfp_send_msg_parms parms = { 0 };\n-\tint name_len;\n \tchar *session_name;\n \tchar *tcam_session_name;\n+\tchar *pool_session_name;\n \n-\t/* Populate the request */\n-\tname_len = strnlen(ctrl_chan_name, TF_SESSION_NAME_MAX);\n-\tsession_name = &ctrl_chan_name[name_len - strlen(\"tf_shared\")];\n-\ttcam_session_name = &ctrl_chan_name[name_len - strlen(\"tf_shared-wc_tcam\")];\n-\tif (!strncmp(tcam_session_name, \"tf_shared-wc_tcam\", strlen(\"tf_shared-wc_tcam\")))\n-\t\ttfp_memcpy(&req.session_name, tcam_session_name, TF_TCAM_SHARED_SESSION_NAME_LEN);\n-\telse if (!strncmp(session_name, \"tf_shared\", strlen(\"tf_shared\")))\n-\t\ttfp_memcpy(&req.session_name, session_name, TF_SHARED_SESSION_NAME_LEN);\n+\t/*\n+\t * \"tf_shared-wc_tcam\" is defined for tf_fw version 1.0.0.\n+\t * \"tf_shared-pool\" is defined for version 1.0.1.\n+\t * \"tf_shared\" is used by both verions.\n+\t */\n+\ttcam_session_name = strstr(ctrl_chan_name, \"tf_shared-wc_tcam\");\n+\tpool_session_name = strstr(ctrl_chan_name, \"tf_shared-pool\");\n+\tsession_name = strstr(ctrl_chan_name, \"tf_shared\");\n+\tif (tcam_session_name)\n+\t\ttfp_memcpy(&req.session_name,\n+\t\t\t   tcam_session_name,\n+\t\t\t   TF_TCAM_SHARED_SESSION_NAME_LEN);\n+\telse if (pool_session_name)\n+\t\ttfp_memcpy(&req.session_name,\n+\t\t\t   pool_session_name,\n+\t\t\t   TF_POOL_SHARED_SESSION_NAME_LEN);\n+\telse if (session_name)\n+\t\ttfp_memcpy(&req.session_name,\n+\t\t\t   session_name,\n+\t\t\t   TF_SHARED_SESSION_NAME_LEN);\n \telse\n \t\ttfp_memcpy(&req.session_name, ctrl_chan_name, TF_SESSION_NAME_MAX);\n \n@@ -191,9 +207,9 @@ tf_msg_session_client_register(struct tf *tfp,\n \tstruct tfp_send_msg_parms parms = { 0 };\n \tuint8_t fw_session_id;\n \tstruct tf_dev_info *dev;\n-\tint name_len;\n \tchar *session_name;\n \tchar *tcam_session_name;\n+\tchar *pool_session_name;\n \n \t/* Retrieve the device information */\n \trc = tf_session_get_device(tfs, &dev);\n@@ -214,24 +230,31 @@ tf_msg_session_client_register(struct tf *tfp,\n \n \t/* Populate the request */\n \treq.fw_session_id = tfp_cpu_to_le_32(fw_session_id);\n-\tname_len = strnlen(ctrl_channel_name, TF_SESSION_NAME_MAX);\n-\tsession_name = &ctrl_channel_name[name_len - strlen(\"tf_shared\")];\n-\ttcam_session_name = &ctrl_channel_name[name_len -\n-\t\tstrlen(\"tf_shared-wc_tcam\")];\n-\tif (!strncmp(tcam_session_name,\n-\t\t\t\t\"tf_shared-wc_tcam\",\n-\t\t\t\tstrlen(\"tf_shared-wc_tcam\")))\n+\n+\t/*\n+\t * \"tf_shared-wc_tcam\" is defined for tf_fw version 1.0.0.\n+\t * \"tf_shared-pool\" is defined for version 1.0.1.\n+\t * \"tf_shared\" is used by both verions.\n+\t */\n+\ttcam_session_name = strstr(ctrl_channel_name, \"tf_shared-wc_tcam\");\n+\tpool_session_name = strstr(ctrl_channel_name, \"tf_shared-pool\");\n+\tsession_name = strstr(ctrl_channel_name, \"tf_shared\");\n+\tif (tcam_session_name)\n+\t\ttfp_memcpy(&req.session_client_name,\n+\t\t\t   tcam_session_name,\n+\t\t\t   TF_TCAM_SHARED_SESSION_NAME_LEN);\n+\telse if (pool_session_name)\n \t\ttfp_memcpy(&req.session_client_name,\n-\t\t\t\ttcam_session_name,\n-\t\t\t\tTF_TCAM_SHARED_SESSION_NAME_LEN);\n-\telse if (!strncmp(session_name, \"tf_shared\", strlen(\"tf_shared\")))\n+\t\t\t   pool_session_name,\n+\t\t\t   TF_POOL_SHARED_SESSION_NAME_LEN);\n+\telse if (session_name)\n \t\ttfp_memcpy(&req.session_client_name,\n-\t\t\t\tsession_name,\n-\t\t\t\tTF_SHARED_SESSION_NAME_LEN);\n+\t\t\t   session_name,\n+\t\t\t   TF_SHARED_SESSION_NAME_LEN);\n \telse\n \t\ttfp_memcpy(&req.session_client_name,\n-\t\t\t\tctrl_channel_name,\n-\t\t\t\tTF_SESSION_NAME_MAX);\n+\t\t\t   ctrl_channel_name,\n+\t\t\t   TF_SESSION_NAME_MAX);\n \n \tparms.tf_type = HWRM_TF_SESSION_REGISTER;\n \tparms.req_data = (uint32_t *)&req;\n@@ -431,7 +454,6 @@ tf_msg_session_resc_qcaps(struct tf *tfp,\n \n \t/* Post process the response */\n \tdata = (struct tf_rm_resc_req_entry *)qcaps_buf.va_addr;\n-\n \tfor (i = 0; i < resp.size; i++) {\n \t\tquery[i].type = tfp_le_to_cpu_32(data[i].type);\n \t\tquery[i].min = tfp_le_to_cpu_16(data[i].min);\n@@ -1757,6 +1779,7 @@ tf_msg_set_tbl_entry(struct tf *tfp,\n \tstruct hwrm_tf_tbl_type_set_input req = { 0 };\n \tstruct hwrm_tf_tbl_type_set_output resp = { 0 };\n \tstruct tfp_send_msg_parms parms = { 0 };\n+\tstruct tf_msg_dma_buf buf = { 0 };\n \tuint8_t fw_session_id;\n \tstruct tf_dev_info *dev;\n \tstruct tf_session *tfs;\n@@ -1802,18 +1825,19 @@ tf_msg_set_tbl_entry(struct tf *tfp,\n \n \t/* Check for data size conformity */\n \tif (size > TF_MSG_TBL_TYPE_SET_DATA_SIZE) {\n-\t\trc = -EINVAL;\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s: Invalid parameters for msg type, rc:%s\\n\",\n-\t\t\t    tf_dir_2_str(dir),\n-\t\t\t    strerror(-rc));\n-\t\treturn rc;\n+\t\t/* use dma buffer */\n+\t\treq.flags |= HWRM_TF_TBL_TYPE_SET_INPUT_FLAGS_DMA;\n+\t\trc = tf_msg_alloc_dma_buf(&buf, size);\n+\t\tif (rc)\n+\t\t\tgoto cleanup;\n+\t\ttfp_memcpy(buf.va_addr, data, size);\n+\t\ttfp_memcpy(&req.data[0],\n+\t\t\t   &buf.pa_addr,\n+\t\t\t   sizeof(buf.pa_addr));\n+\t} else {\n+\t\ttfp_memcpy(&req.data, data, size);\n \t}\n \n-\ttfp_memcpy(&req.data,\n-\t\t   data,\n-\t\t   size);\n-\n \tparms.tf_type = HWRM_TF_TBL_TYPE_SET;\n \tparms.req_data = (uint32_t *)&req;\n \tparms.req_size = sizeof(req);\n@@ -1823,10 +1847,10 @@ tf_msg_set_tbl_entry(struct tf *tfp,\n \n \trc = tfp_send_msg_direct(tf_session_get_bp(tfp),\n \t\t\t\t &parms);\n-\tif (rc)\n-\t\treturn rc;\n+cleanup:\n+\ttf_msg_free_dma_buf(&buf);\n \n-\treturn 0;\n+\treturn rc;\n }\n \n int\n@@ -2325,3 +2349,114 @@ tf_msg_get_version(struct bnxt *bp,\n \n \treturn rc;\n }\n+\n+int\n+tf_msg_session_set_hotup_state(struct tf *tfp, uint16_t state)\n+{\n+\tint rc;\n+\tstruct hwrm_tf_session_hotup_state_set_input req = { 0 };\n+\tstruct hwrm_tf_session_hotup_state_set_output resp = { 0 };\n+\tstruct tfp_send_msg_parms parms = { 0 };\n+\tuint8_t fw_session_id;\n+\tstruct tf_dev_info *dev;\n+\tstruct tf_session *tfs;\n+\n+\t/* Retrieve the session information */\n+\trc = tf_session_get_session_internal(tfp, &tfs);\n+\tif (rc) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"Failed to lookup session, rc:%s\\n\",\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    \"Failed to lookup device, rc:%s\\n\",\n+\t\t\t    strerror(-rc));\n+\t\treturn rc;\n+\t}\n+\n+\trc = tf_session_get_fw_session_id(tfp, &fw_session_id);\n+\tif (rc) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"Unable to lookup FW id, rc:%s\\n\",\n+\t\t\t    strerror(-rc));\n+\t\treturn rc;\n+\t}\n+\n+\t/* Populate the request */\n+\treq.fw_session_id = tfp_cpu_to_le_32(fw_session_id);\n+\treq.state = tfp_cpu_to_le_16(state);\n+\n+\tparms.tf_type = HWRM_TF_SESSION_HOTUP_STATE_SET;\n+\tparms.req_data = (uint32_t *)&req;\n+\tparms.req_size = sizeof(req);\n+\tparms.resp_data = (uint32_t *)&resp;\n+\tparms.resp_size = sizeof(resp);\n+\tparms.mailbox = dev->ops->tf_dev_get_mailbox();\n+\n+\trc = tfp_send_msg_direct(tf_session_get_bp(tfp),\n+\t\t\t\t &parms);\n+\treturn rc;\n+}\n+\n+int\n+tf_msg_session_get_hotup_state(struct tf *tfp,\n+\t\t\t       uint16_t *state,\n+\t\t\t       uint16_t *ref_cnt)\n+{\n+\tint rc;\n+\tstruct hwrm_tf_session_hotup_state_get_input req = { 0 };\n+\tstruct hwrm_tf_session_hotup_state_get_output resp = { 0 };\n+\tstruct tfp_send_msg_parms parms = { 0 };\n+\tuint8_t fw_session_id;\n+\tstruct tf_dev_info *dev;\n+\tstruct tf_session *tfs;\n+\n+\t/* Retrieve the session information */\n+\trc = tf_session_get_session_internal(tfp, &tfs);\n+\tif (rc) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"Failed to lookup session, rc:%s\\n\",\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    \"Failed to lookup device, rc:%s\\n\",\n+\t\t\t    strerror(-rc));\n+\t\treturn rc;\n+\t}\n+\n+\trc = tf_session_get_fw_session_id(tfp, &fw_session_id);\n+\tif (rc) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"Unable to lookup FW id, rc:%s\\n\",\n+\t\t\t    strerror(-rc));\n+\t\treturn rc;\n+\t}\n+\n+\t/* Populate the request */\n+\treq.fw_session_id = tfp_cpu_to_le_32(fw_session_id);\n+\n+\tparms.tf_type = HWRM_TF_SESSION_HOTUP_STATE_GET;\n+\tparms.req_data = (uint32_t *)&req;\n+\tparms.req_size = sizeof(req);\n+\tparms.resp_data = (uint32_t *)&resp;\n+\tparms.resp_size = sizeof(resp);\n+\tparms.mailbox = dev->ops->tf_dev_get_mailbox();\n+\n+\trc = tfp_send_msg_direct(tf_session_get_bp(tfp),\n+\t\t\t\t &parms);\n+\n+\t*state = tfp_le_to_cpu_16(resp.state);\n+\t*ref_cnt = tfp_le_to_cpu_16(resp.ref_cnt);\n+\n+\treturn rc;\n+}\ndiff --git a/drivers/net/bnxt/tf_core/tf_msg.h b/drivers/net/bnxt/tf_core/tf_msg.h\nindex 188b361d71..24d0ae5f43 100644\n--- a/drivers/net/bnxt/tf_core/tf_msg.h\n+++ b/drivers/net/bnxt/tf_core/tf_msg.h\n@@ -1,5 +1,5 @@\n /* SPDX-License-Identifier: BSD-3-Clause\n- * Copyright(c) 2019-2021 Broadcom\n+ * Copyright(c) 2019-2023 Broadcom\n  * All rights reserved.\n  */\n \n@@ -761,4 +761,40 @@ int\n tf_msg_get_version(struct bnxt *bp,\n \t\t   struct tf_dev_info *dev,\n \t\t   struct tf_get_version_parms *parms);\n+\n+/**\n+ * Send set hot upgrade state request to the firmware.\n+ *\n+ * [in] tfp\n+ *   Pointer to session handle\n+ *\n+ * [in] state\n+ *   Hot upgrade session state\n+ *\n+ * Returns:\n+ *  0 on Success else internal Truflow error\n+ */\n+int\n+tf_msg_session_set_hotup_state(struct tf *tfp,\n+\t\t\t       uint16_t state);\n+\n+/**\n+ * Send get hot upgrade state request to the firmware.\n+ *\n+ * [in] tfp\n+ *   Pointer to session handle\n+ *\n+ * [out] state\n+ *   Pointer to hot upgrade session state\n+ *\n+ * [out] ref_cnt\n+ *   Pointer to hot upgrade session reference count\n+ *\n+ * Returns:\n+ *  0 on Success else internal Truflow error\n+ */\n+int\n+tf_msg_session_get_hotup_state(struct tf *tfp,\n+\t\t\t       uint16_t *state,\n+\t\t\t       uint16_t *ref_cnt);\n #endif  /* _TF_MSG_H_ */\ndiff --git a/drivers/net/bnxt/tf_core/tf_rm.c b/drivers/net/bnxt/tf_core/tf_rm.c\nindex d2045921b9..1fccb698d0 100644\n--- a/drivers/net/bnxt/tf_core/tf_rm.c\n+++ b/drivers/net/bnxt/tf_core/tf_rm.c\n@@ -1,15 +1,12 @@\n /* SPDX-License-Identifier: BSD-3-Clause\n- * Copyright(c) 2019-2021 Broadcom\n+ * Copyright(c) 2019-2023 Broadcom\n  * All rights reserved.\n  */\n \n #include <string.h>\n-\n #include <rte_common.h>\n #include <rte_debug.h>\n-\n #include <cfa_resource_types.h>\n-\n #include \"tf_rm.h\"\n #include \"tf_common.h\"\n #include \"tf_util.h\"\n@@ -18,9 +15,6 @@\n #include \"tfp.h\"\n #include \"tf_msg.h\"\n \n-/* Logging defines */\n-#define TF_RM_DEBUG  0\n-\n /**\n  * Generic RM Element data type that an RM DB is build upon.\n  */\n@@ -210,45 +204,6 @@ tf_rm_adjust_index(struct tf_rm_element *db,\n \treturn rc;\n }\n \n-/**\n- * Logs an array of found residual entries to the console.\n- *\n- * [in] dir\n- *   Receive or transmit direction\n- *\n- * [in] module\n- *   Type of Device Module\n- *\n- * [in] count\n- *   Number of entries in the residual array\n- *\n- * [in] residuals\n- *   Pointer to an array of residual entries. Array is index same as\n- *   the DB in which this function is used. Each entry holds residual\n- *   value for that entry.\n- */\n-#if (TF_RM_DEBUG == 1)\n-static void\n-tf_rm_log_residuals(enum tf_dir dir,\n-\t\t    enum tf_module_type module,\n-\t\t    uint16_t count,\n-\t\t    uint16_t *residuals)\n-{\n-\tint i;\n-\n-\t/* Walk the residual array and log the types that wasn't\n-\t * cleaned up to the console.\n-\t */\n-\tfor (i = 0; i < count; i++) {\n-\t\tif (residuals[i] != 0)\n-\t\t\tTFP_DRV_LOG(INFO,\n-\t\t\t\t\"%s, %s was not cleaned up, %d outstanding\\n\",\n-\t\t\t\ttf_dir_2_str(dir),\n-\t\t\t\ttf_module_subtype_2_str(module, i),\n-\t\t\t\tresiduals[i]);\n-\t}\n-}\n-#endif /* TF_RM_DEBUG == 1 */\n /**\n  * Performs a check of the passed in DB for any lingering elements. If\n  * a resource type was found to not have been cleaned up by the caller\n@@ -364,12 +319,6 @@ tf_rm_check_residuals(struct tf_rm_new_db *rm_db,\n \t\t*resv_size = found;\n \t}\n \n-#if (TF_RM_DEBUG == 1)\n-\ttf_rm_log_residuals(rm_db->dir,\n-\t\t\t    rm_db->module,\n-\t\t\t    rm_db->num_entries,\n-\t\t\t    residuals);\n-#endif\n \ttfp_free((void *)residuals);\n \t*resv = local_resv;\n \n@@ -419,7 +368,7 @@ tf_rm_update_parent_reservations(struct tf *tfp,\n \t\t\t\t bool shared_session)\n {\n \tint parent, child;\n-\tconst char *type_str;\n+\tconst char *type_str = NULL;\n \n \t/* Search through all the elements */\n \tfor (parent = 0; parent < num_elements; parent++) {\n@@ -444,11 +393,6 @@ tf_rm_update_parent_reservations(struct tf *tfp,\n \t\t\t\tdev->ops->tf_dev_get_resource_str(tfp,\n \t\t\t\t\t\t\t cfg[parent].hcapi_type,\n \t\t\t\t\t\t\t &type_str);\n-#if (TF_RM_DEBUG == 1)\n-\t\t\t\tprintf(\"%s:%s cnt(%d) slices(%d)\\n\",\n-\t\t\t\t       type_str, tf_tbl_type_2_str(parent),\n-\t\t\t\t       alloc_cnt[parent], p_slices);\n-#endif /* (TF_RM_DEBUG == 1) */\n \t\t\t}\n \n \t\t\t/* Search again through all the elements */\n@@ -469,13 +413,7 @@ tf_rm_update_parent_reservations(struct tf *tfp,\n \t\t\t\t\tdev->ops->tf_dev_get_resource_str(tfp,\n \t\t\t\t\t\t\t  cfg[child].hcapi_type,\n \t\t\t\t\t\t\t   &type_str);\n-#if (TF_RM_DEBUG == 1)\n-\t\t\t\t\tprintf(\"%s:%s cnt(%d) slices(%d)\\n\",\n-\t\t\t\t\t       type_str,\n-\t\t\t\t\t       tf_tbl_type_2_str(child),\n-\t\t\t\t\t       alloc_cnt[child],\n-\t\t\t\t\t       c_slices);\n-#endif /* (TF_RM_DEBUG == 1) */\n+\n \t\t\t\t\t/* Increment the parents combined count\n \t\t\t\t\t * with each child's count adjusted for\n \t\t\t\t\t * number of slices per RM alloc item.\n@@ -492,10 +430,6 @@ tf_rm_update_parent_reservations(struct tf *tfp,\n \t\t\t}\n \t\t\t/* Save the parent count to be requested */\n \t\t\treq_cnt[parent] = combined_cnt;\n-#if (TF_RM_DEBUG == 1)\n-\t\t\tprintf(\"%s calculated total:%d\\n\\n\",\n-\t\t\t       type_str, req_cnt[parent]);\n-#endif /* (TF_RM_DEBUG == 1) */\n \t\t}\n \t}\n \treturn 0;\n@@ -595,12 +529,6 @@ tf_rm_create_db(struct tf *tfp,\n \t\t\t\t       &hcapi_items);\n \n \tif (hcapi_items == 0) {\n-#if (TF_RM_DEBUG == 1)\n-\t\tTFP_DRV_LOG(INFO,\n-\t\t\t\"%s: module: %s Empty RM DB create request\\n\",\n-\t\t\ttf_dir_2_str(parms->dir),\n-\t\t\ttf_module_2_str(parms->module));\n-#endif\n \t\tparms->rm_db = NULL;\n \t\treturn -ENOMEM;\n \t}\n@@ -746,7 +674,7 @@ tf_rm_create_db(struct tf *tfp,\n \n \t\t\t\trc = ba_init(db[i].pool,\n \t\t\t\t\t     resv[j].stride,\n-\t\t\t\t\t     !tf_session_is_shared_session(tfs));\n+\t\t\t\t\t     true);\n \t\t\t\tif (rc) {\n \t\t\t\t\tTFP_DRV_LOG(ERR,\n \t\t\t\t\t  \"%s: Pool init failed, type:%d:%s\\n\",\n@@ -773,13 +701,6 @@ tf_rm_create_db(struct tf *tfp,\n \trm_db->module = parms->module;\n \t*parms->rm_db = (void *)rm_db;\n \n-#if (TF_RM_DEBUG == 1)\n-\n-\tprintf(\"%s: module:%s\\n\",\n-\t       tf_dir_2_str(parms->dir),\n-\t       tf_module_2_str(parms->module));\n-#endif /* (TF_RM_DEBUG == 1) */\n-\n \ttfp_free((void *)req);\n \ttfp_free((void *)resv);\n \ttfp_free((void *)req_cnt);\n@@ -812,6 +733,7 @@ tf_rm_create_db_no_reservation(struct tf *tfp,\n \tstruct tf_rm_new_db *rm_db;\n \tstruct tf_rm_element *db;\n \tuint32_t pool_size;\n+\tbool shared_session = 0;\n \n \tTF_CHECK_PARMS2(tfp, parms);\n \n@@ -841,6 +763,16 @@ tf_rm_create_db_no_reservation(struct tf *tfp,\n \ttfp_memcpy(req_cnt, parms->alloc_cnt,\n \t\t   parms->num_elements * sizeof(uint16_t));\n \n+\tshared_session = tf_session_is_shared_session(tfs);\n+\n+\t/* Update the req_cnt based upon the element configuration\n+\t */\n+\ttf_rm_update_parent_reservations(tfp, dev, parms->cfg,\n+\t\t\t\t\t parms->alloc_cnt,\n+\t\t\t\t\t parms->num_elements,\n+\t\t\t\t\t req_cnt,\n+\t\t\t\t\t shared_session);\n+\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@@ -855,11 +787,6 @@ tf_rm_create_db_no_reservation(struct tf *tfp,\n \t\t\t\t       &hcapi_items);\n \n \tif (hcapi_items == 0) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t\"%s: module:%s Empty RM DB create request\\n\",\n-\t\t\ttf_dir_2_str(parms->dir),\n-\t\t\ttf_module_2_str(parms->module));\n-\n \t\tparms->rm_db = NULL;\n \t\treturn -ENOMEM;\n \t}\n@@ -938,6 +865,7 @@ tf_rm_create_db_no_reservation(struct tf *tfp,\n \n \t\tdb[i].cfg_type = cfg->cfg_type;\n \t\tdb[i].hcapi_type = cfg->hcapi_type;\n+\t\tdb[i].slices = cfg->slices;\n \n \t\t/* Save the parent subtype for later use to find the pool\n \t\t */\n@@ -986,7 +914,7 @@ tf_rm_create_db_no_reservation(struct tf *tfp,\n \n \t\t\t\trc = ba_init(db[i].pool,\n \t\t\t\t\t     resv[j].stride,\n-\t\t\t\t\t     !tf_session_is_shared_session(tfs));\n+\t\t\t\t\t     true);\n \t\t\t\tif (rc) {\n \t\t\t\t\tTFP_DRV_LOG(ERR,\n \t\t\t\t\t  \"%s: Pool init failed, type:%d:%s\\n\",\n@@ -1013,13 +941,6 @@ tf_rm_create_db_no_reservation(struct tf *tfp,\n \trm_db->module = parms->module;\n \t*parms->rm_db = (void *)rm_db;\n \n-#if (TF_RM_DEBUG == 1)\n-\n-\tprintf(\"%s: module:%s\\n\",\n-\t       tf_dir_2_str(parms->dir),\n-\t       tf_module_2_str(parms->module));\n-#endif /* (TF_RM_DEBUG == 1) */\n-\n \ttfp_free((void *)req);\n \ttfp_free((void *)resv);\n \ttfp_free((void *)req_cnt);\n@@ -1036,6 +957,7 @@ tf_rm_create_db_no_reservation(struct tf *tfp,\n \n \treturn -EINVAL;\n }\n+\n int\n tf_rm_free_db(struct tf *tfp,\n \t      struct tf_rm_free_db_parms *parms)\n@@ -1110,6 +1032,7 @@ tf_rm_free_db(struct tf *tfp,\n \n \treturn rc;\n }\n+\n /**\n  * Get the bit allocator pool associated with the subtype and the db\n  *\n@@ -1388,6 +1311,7 @@ tf_rm_get_hcapi_type(struct tf_rm_get_hcapi_parms *parms)\n \n \treturn 0;\n }\n+\n int\n tf_rm_get_slices(struct tf_rm_get_slices_parms *parms)\n {\n@@ -1440,6 +1364,7 @@ tf_rm_get_inuse_count(struct tf_rm_get_inuse_count_parms *parms)\n \n \treturn rc;\n }\n+\n /* Only used for table bulk get at this time\n  */\n int\ndiff --git a/drivers/net/bnxt/tf_core/tf_session.c b/drivers/net/bnxt/tf_core/tf_session.c\nindex d0a0916c6a..253d716572 100644\n--- a/drivers/net/bnxt/tf_core/tf_session.c\n+++ b/drivers/net/bnxt/tf_core/tf_session.c\n@@ -1,12 +1,10 @@\n /* SPDX-License-Identifier: BSD-3-Clause\n- * Copyright(c) 2019-2021 Broadcom\n+ * Copyright(c) 2019-2023 Broadcom\n  * All rights reserved.\n  */\n \n #include <string.h>\n-\n #include <rte_common.h>\n-\n #include \"tf_session.h\"\n #include \"tf_common.h\"\n #include \"tf_msg.h\"\n@@ -59,8 +57,9 @@ tf_session_create(struct tf *tfp,\n \tunion tf_session_id *session_id;\n \tstruct tf_dev_info dev;\n \tbool shared_session_creator;\n-\tint name_len;\n-\tchar *name;\n+\tchar *shared_name;\n+\tchar *tcam_session_name;\n+\tchar *pool_session_name;\n \n \tTF_CHECK_PARMS2(tfp, parms);\n \n@@ -180,16 +179,18 @@ tf_session_create(struct tf *tfp,\n \tsession->em_ext_db_handle = NULL;\n \n \t/* Populate the request */\n-\tname_len = strnlen(parms->open_cfg->ctrl_chan_name,\n-\t\t\t   TF_SESSION_NAME_MAX);\n-\tname = &parms->open_cfg->ctrl_chan_name[name_len - strlen(\"tf_shared\")];\n-\tif (!strncmp(name, \"tf_shared\", strlen(\"tf_shared\")))\n-\t\tsession->shared_session = true;\n-\n-\tname = &parms->open_cfg->ctrl_chan_name[name_len -\n-\t\tstrlen(\"tf_shared-wc_tcam\")];\n-\tif (!strncmp(name, \"tf_shared-wc_tcam\", strlen(\"tf_shared-wc_tcam\")))\n+\tshared_name = strstr(parms->open_cfg->ctrl_chan_name, \"tf_shared\");\n+\tif (shared_name) {\n \t\tsession->shared_session = true;\n+\t\t/*\n+\t\t * \"tf_shared-wc_tcam\" is defined for tf_fw version 1.0.0.\n+\t\t * \"tf_shared-pool\" is defined for version 1.0.1.\n+\t\t */\n+\t\ttcam_session_name = strstr(parms->open_cfg->ctrl_chan_name, \"tf_shared-wc_tcam\");\n+\t\tpool_session_name = strstr(parms->open_cfg->ctrl_chan_name, \"tf_shared-pool\");\n+\t\tif (tcam_session_name || pool_session_name)\n+\t\t\tsession->shared_session_hotup = true;\n+\t}\n \n \tif (session->shared_session && shared_session_creator) {\n \t\tsession->shared_session_creator = true;\n@@ -342,7 +343,6 @@ tf_session_client_create(struct tf *tfp,\n \treturn rc;\n }\n \n-\n /**\n  * Destroys a Session Client on an existing Session.\n  *\n@@ -441,7 +441,7 @@ tf_session_open_session(struct tf *tfp,\n \n \t\tTFP_DRV_LOG(INFO,\n \t\t       \"Session created, session_client_id:%d,\"\n-\t\t       \"session_id:0x%08x, fw_session_id:%d\\n\",\n+\t\t       \" session_id:0x%08x, fw_session_id:%d\\n\",\n \t\t       parms->open_cfg->session_client_id.id,\n \t\t       parms->open_cfg->session_id.id,\n \t\t       parms->open_cfg->session_id.internal.fw_session_id);\n@@ -462,7 +462,7 @@ tf_session_open_session(struct tf *tfp,\n \t\t}\n \n \t\tTFP_DRV_LOG(INFO,\n-\t\t\t\"Session Client:%d registered on session:0x%8x\\n\",\n+\t\t\t\"Session Client:%d registered on session:0x%08x\\n\",\n \t\t\tscparms.session_client_id->internal.fw_session_client_id,\n \t\t\ttfp->session->session_id.id);\n \t}\n@@ -535,6 +535,11 @@ tf_session_close_session(struct tf *tfp,\n \t\treturn rc;\n \t}\n \n+\t/* Record the session we're closing so the caller knows the\n+\t * details.\n+\t */\n+\t*parms->session_id = tfs->session_id;\n+\n \t/* In case multiple clients we chose to close those first */\n \tif (tfs->ref_count > 1) {\n \t\t/* Linaro gcc can't static init this structure */\n@@ -567,11 +572,6 @@ tf_session_close_session(struct tf *tfp,\n \t\treturn 0;\n \t}\n \n-\t/* Record the session we're closing so the caller knows the\n-\t * details.\n-\t */\n-\t*parms->session_id = tfs->session_id;\n-\n \trc = tf_session_get_device(tfs, &tfd);\n \tif (rc) {\n \t\tTFP_DRV_LOG(ERR,\n@@ -1140,3 +1140,71 @@ tf_session_set_if_tbl_db(struct tf *tfp,\n \ttfs->if_tbl_db_handle = if_tbl_handle;\n \treturn rc;\n }\n+\n+int\n+tf_session_set_hotup_state(struct tf *tfp,\n+\t\t\t   struct tf_set_session_hotup_state_parms *parms)\n+{\n+\tint rc = 0;\n+\tstruct tf_session *tfs = NULL;\n+\n+\trc = tf_session_get_session(tfp, &tfs);\n+\tif (rc) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"Session lookup failed, rc:%s\\n\",\n+\t\t\t    strerror(-rc));\n+\t\treturn rc;\n+\t}\n+\n+\tif (!tf_session_is_shared_session(tfs)) {\n+\t\trc = -EINVAL;\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"Only shared session able to set state, rc:%s\\n\",\n+\t\t\t    strerror(-rc));\n+\t\treturn rc;\n+\t}\n+\n+\trc = tf_msg_session_set_hotup_state(tfp, parms->state);\n+\tif (rc) {\n+\t\t/* Log error */\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"Set session hot upgrade state failed, rc:%s\\n\",\n+\t\t\t    strerror(-rc));\n+\t}\n+\n+\treturn rc;\n+}\n+\n+int\n+tf_session_get_hotup_state(struct tf *tfp,\n+\t\t\t   struct tf_get_session_hotup_state_parms *parms)\n+{\n+\tint rc = 0;\n+\tstruct tf_session *tfs = NULL;\n+\n+\trc = tf_session_get_session(tfp, &tfs);\n+\tif (rc) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"Session lookup failed, rc:%s\\n\",\n+\t\t\t    strerror(-rc));\n+\t\treturn rc;\n+\t}\n+\n+\tif (!tf_session_is_shared_session(tfs)) {\n+\t\trc = -EINVAL;\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"Only shared session able to get state, rc:%s\\n\",\n+\t\t\t    strerror(-rc));\n+\t\treturn rc;\n+\t}\n+\n+\trc = tf_msg_session_get_hotup_state(tfp, &parms->state, &parms->ref_cnt);\n+\tif (rc) {\n+\t\t/* Log error */\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"Get session hot upgrade state failed, rc:%s\\n\",\n+\t\t\t    strerror(-rc));\n+\t}\n+\n+\treturn rc;\n+}\ndiff --git a/drivers/net/bnxt/tf_core/tf_session.h b/drivers/net/bnxt/tf_core/tf_session.h\nindex 5a94b941fa..9bbbccf125 100644\n--- a/drivers/net/bnxt/tf_core/tf_session.h\n+++ b/drivers/net/bnxt/tf_core/tf_session.h\n@@ -1,5 +1,5 @@\n /* SPDX-License-Identifier: BSD-3-Clause\n- * Copyright(c) 2019-2021 Broadcom\n+ * Copyright(c) 2019-2023 Broadcom\n  * All rights reserved.\n  */\n \n@@ -8,7 +8,6 @@\n \n #include <stdint.h>\n #include <stdlib.h>\n-\n #include \"bitalloc.h\"\n #include \"tf_core.h\"\n #include \"tf_device.h\"\n@@ -48,7 +47,7 @@\n  *\n  * Shared memory containing private TruFlow session information.\n  * Through this structure the session can keep track of resource\n- * allocations.  It also holds info about Session Clients.\n+ * allocations. It also holds info about Session Clients.\n  *\n  * Memory is assigned to the Truflow instance by way of\n  * tf_open_session. Memory is allocated and owned by i.e. ULP.\n@@ -78,6 +77,11 @@ struct tf_session {\n \t */\n \tbool shared_session;\n \n+\t/**\n+\t * Boolean controlling the split of hardware resources for hotupgrade.\n+\t */\n+\tbool shared_session_hotup;\n+\n \t/**\n \t * This flag indicates the shared session on firmware side is created\n \t * by this session. Some privileges may be assigned to this session.\n@@ -169,6 +173,12 @@ struct tf_session {\n \t * Number of slices per row for WC TCAM\n \t */\n \tuint16_t wc_num_slices_per_row;\n+\n+\t/**\n+\t * Indicates if TCAM is controlled by TCAM Manager\n+\t */\n+\tint tcam_mgr_control[TF_DIR_MAX][TF_TCAM_TBL_TYPE_MAX];\n+\n };\n \n /**\n@@ -276,11 +286,9 @@ struct tf_session_close_session_parms {\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  * @ref tf_session_get_sram_db\n  *\n@@ -588,6 +596,21 @@ tf_session_is_shared_session(struct tf_session *tfs)\n \treturn tfs->shared_session;\n }\n \n+/**\n+ * Check if the session is shared session for hot upgrade.\n+ *\n+ * [in] session, pointer to the session\n+ *\n+ * Returns:\n+ *   - true if it is shared session for hot upgrade\n+ *   - false if it is not shared session for hot upgrade\n+ */\n+static inline bool\n+tf_session_is_shared_hotup_session(struct tf_session *tfs)\n+{\n+\treturn tfs->shared_session_hotup;\n+}\n+\n /**\n  * Check if the session is the shared session creator\n  *\n@@ -716,4 +739,36 @@ tf_session_set_if_tbl_db(struct tf *tfp,\n int\n tf_session_get_if_tbl_db(struct tf *tfp,\n \t\t\t void **if_tbl_handle);\n+\n+/**\n+ * Set hot upgrade session state.\n+ *\n+ * [in] tfp\n+ *   Pointer to session handle\n+ *\n+ * [in] parms\n+ *   Hot upgrade session state parms\n+ *\n+ * Returns:\n+ *  0 on Success else internal Truflow error\n+ */\n+int\n+tf_session_set_hotup_state(struct tf *tfp,\n+\t\t\t   struct tf_set_session_hotup_state_parms *parms);\n+\n+/**\n+ * Get hot upgrade session state.\n+ *\n+ * [in] tfp\n+ *   Pointer to session handle\n+ *\n+ * [out] parms\n+ *   Pointer to hot upgrade session state parms\n+ *\n+ * Returns:\n+ *  0 on Success else internal Truflow error\n+ */\n+int\n+tf_session_get_hotup_state(struct tf *tfp,\n+\t\t\t   struct tf_get_session_hotup_state_parms *parms);\n #endif /* _TF_SESSION_H_ */\ndiff --git a/drivers/net/bnxt/tf_core/tf_sram_mgr.c b/drivers/net/bnxt/tf_core/tf_sram_mgr.c\nindex acb3372486..87e8882fed 100644\n--- a/drivers/net/bnxt/tf_core/tf_sram_mgr.c\n+++ b/drivers/net/bnxt/tf_core/tf_sram_mgr.c\n@@ -1,5 +1,5 @@\n /* SPDX-License-Identifier: BSD-3-Clause\n- * Copyright(c) 2019-2021 Broadcom\n+ * Copyright(c) 2019-2023 Broadcom\n  * All rights reserved.\n  */\n #include <stdlib.h>\n@@ -21,7 +21,7 @@\n /**\n  * TF SRAM block info\n  *\n- * Contains all the information about a particular 64B SRAM\n+ * Contains all the information about a particular 128B SRAM\n  * block and the slices within it.\n  */\n struct tf_sram_block {\n@@ -36,9 +36,9 @@ struct tf_sram_block {\n \t *  If a bit is set, it indicates the slice\n \t *  in the row is in use.\n \t */\n-\tuint8_t in_use_mask;\n+\tuint16_t in_use_mask;\n \n-\t/** Block id - this is a 64B offset\n+\t/** Block id - this is a 128B offset\n \t */\n \tuint16_t block_id;\n };\n@@ -46,7 +46,7 @@ struct tf_sram_block {\n /**\n  * TF SRAM block list\n  *\n- * List of 64B SRAM blocks used for fixed size slices (8, 16, 32, 64B)\n+ * List of 128B SRAM blocks used for fixed size slices (8, 16, 32, 64B, 128B)\n  */\n struct tf_sram_slice_list {\n \t/** Pointer to head of linked list of blocks.\n@@ -70,7 +70,6 @@ struct tf_sram_slice_list {\n \tenum tf_sram_slice_size size;\n };\n \n-\n /**\n  * TF SRAM bank info consists of lists of different slice sizes per bank\n  */\n@@ -111,6 +110,8 @@ const char\n \t\treturn \"32B slice\";\n \tcase TF_SRAM_SLICE_SIZE_64B:\n \t\treturn \"64B slice\";\n+\tcase TF_SRAM_SLICE_SIZE_128B:\n+\t\treturn \"128B slice\";\n \tdefault:\n \t\treturn \"Invalid slice size\";\n \t}\n@@ -179,8 +180,8 @@ static void\n tf_sram_offset_2_block_id(enum tf_sram_bank_id bank_id, uint16_t offset,\n \t\t\t  uint16_t *block_id, uint16_t *slice_offset)\n {\n-\t*slice_offset = offset & 0x7;\n-\t*block_id = ((offset & ~0x7) >> 3) -\n+\t*slice_offset = offset & 0xf;\n+\t*block_id = ((offset & ~0xf) >> 3) -\n \t\t    tf_sram_bank_2_base_offset[bank_id];\n }\n \n@@ -232,31 +233,37 @@ tf_sram_free_slice(enum tf_sram_slice_size slice_size,\n \t\t   bool *block_is_empty)\n {\n \tint rc = 0;\n-\tuint8_t shift;\n-\tuint8_t slice_mask = 0;\n+\tuint16_t shift;\n+\tuint16_t slice_mask = 0;\n \n \tTF_CHECK_PARMS2(block, block_is_empty);\n \n \tswitch (slice_size) {\n \tcase TF_SRAM_SLICE_SIZE_8B:\n \t\tshift = slice_offset >> 0;\n-\t\tassert(shift < 8);\n+\t\tassert(shift < 16);\n \t\tslice_mask = 1 << shift;\n \t\tbreak;\n \n \tcase TF_SRAM_SLICE_SIZE_16B:\n \t\tshift = slice_offset >> 1;\n-\t\tassert(shift < 4);\n+\t\tassert(shift < 8);\n \t\tslice_mask = 1 << shift;\n \t\tbreak;\n \n \tcase TF_SRAM_SLICE_SIZE_32B:\n \t\tshift = slice_offset >> 2;\n-\t\tassert(shift < 2);\n+\t\tassert(shift < 4);\n \t\tslice_mask = 1 << shift;\n \t\tbreak;\n \n \tcase TF_SRAM_SLICE_SIZE_64B:\n+\t\tshift = slice_offset >> 3;\n+\t\tassert(shift < 2);\n+\t\tslice_mask = 1 << shift;\n+\t\tbreak;\n+\n+\tcase TF_SRAM_SLICE_SIZE_128B:\n \tdefault:\n \t\tshift = slice_offset >> 0;\n \t\tassert(shift < 1);\n@@ -294,27 +301,32 @@ tf_sram_get_next_slice_in_block(struct tf_sram_block *block,\n \t\t\t\tbool *block_is_full)\n {\n \tint rc, free_id = -1;\n-\tuint8_t shift, max_slices, mask, i, full_mask;\n+\tuint16_t shift, max_slices, mask, i, full_mask;\n \n \tTF_CHECK_PARMS3(block, slice_offset, block_is_full);\n \n \tswitch (slice_size) {\n \tcase TF_SRAM_SLICE_SIZE_8B:\n \t\tshift      = 0;\n-\t\tmax_slices = 8;\n-\t\tfull_mask  = 0xff;\n+\t\tmax_slices = 16;\n+\t\tfull_mask  = 0xffff;\n \t\tbreak;\n \tcase TF_SRAM_SLICE_SIZE_16B:\n \t\tshift      = 1;\n-\t\tmax_slices = 4;\n-\t\tfull_mask  = 0xf;\n+\t\tmax_slices = 8;\n+\t\tfull_mask  = 0xff;\n \t\tbreak;\n \tcase TF_SRAM_SLICE_SIZE_32B:\n \t\tshift      = 2;\n+\t\tmax_slices = 4;\n+\t\tfull_mask  = 0xf;\n+\t\tbreak;\n+\tcase TF_SRAM_SLICE_SIZE_64B:\n+\t\tshift      = 3;\n \t\tmax_slices = 2;\n \t\tfull_mask  = 0x3;\n \t\tbreak;\n-\tcase TF_SRAM_SLICE_SIZE_64B:\n+\tcase TF_SRAM_SLICE_SIZE_128B:\n \tdefault:\n \t\tshift      = 0;\n \t\tmax_slices = 1;\n@@ -338,7 +350,6 @@ tf_sram_get_next_slice_in_block(struct tf_sram_block *block,\n \telse\n \t\t*block_is_full = false;\n \n-\n \tif (free_id >= 0) {\n \t\t*slice_offset = free_id << shift;\n \t\trc = 0;\n@@ -362,8 +373,8 @@ tf_sram_is_slice_allocated_in_block(struct tf_sram_block *block,\n \t\t\t\t    bool *is_allocated)\n {\n \tint rc = 0;\n-\tuint8_t shift;\n-\tuint8_t slice_mask = 0;\n+\tuint16_t shift;\n+\tuint16_t slice_mask = 0;\n \n \tTF_CHECK_PARMS2(block, is_allocated);\n \n@@ -372,23 +383,29 @@ tf_sram_is_slice_allocated_in_block(struct tf_sram_block *block,\n \tswitch (slice_size) {\n \tcase TF_SRAM_SLICE_SIZE_8B:\n \t\tshift = slice_offset >> 0;\n-\t\tassert(shift < 8);\n+\t\tassert(shift < 16);\n \t\tslice_mask = 1 << shift;\n \t\tbreak;\n \n \tcase TF_SRAM_SLICE_SIZE_16B:\n \t\tshift = slice_offset >> 1;\n-\t\tassert(shift < 4);\n+\t\tassert(shift < 8);\n \t\tslice_mask = 1 << shift;\n \t\tbreak;\n \n \tcase TF_SRAM_SLICE_SIZE_32B:\n \t\tshift = slice_offset >> 2;\n-\t\tassert(shift < 2);\n+\t\tassert(shift < 4);\n \t\tslice_mask = 1 << shift;\n \t\tbreak;\n \n \tcase TF_SRAM_SLICE_SIZE_64B:\n+\t\tshift = slice_offset >> 3;\n+\t\tassert(shift < 2);\n+\t\tslice_mask = 1 << shift;\n+\t\tbreak;\n+\n+\tcase TF_SRAM_SLICE_SIZE_128B:\n \tdefault:\n \t\tshift = slice_offset >> 0;\n \t\tassert(shift < 1);\n@@ -416,7 +433,6 @@ tf_sram_get_block_cnt(struct tf_sram_slice_list *slice_list)\n \treturn slice_list->cnt;\n }\n \n-\n /**\n  * Free a block data structure - does not free to the RM\n  */\n@@ -508,22 +524,26 @@ tf_sram_find_first_not_full_block(struct tf_sram_slice_list *slice_list,\n \t\t\t\t  struct tf_sram_block **first_not_full_block)\n {\n \tstruct tf_sram_block *block = slice_list->head;\n-\tuint8_t slice_mask, mask;\n+\tuint16_t slice_mask, mask;\n \n \tswitch (slice_size) {\n \tcase TF_SRAM_SLICE_SIZE_8B:\n-\t\tslice_mask = 0xff;\n+\t\tslice_mask = 0xffff;\n \t\tbreak;\n \n \tcase TF_SRAM_SLICE_SIZE_16B:\n-\t\tslice_mask = 0xf;\n+\t\tslice_mask = 0xff;\n \t\tbreak;\n \n \tcase TF_SRAM_SLICE_SIZE_32B:\n-\t\tslice_mask = 0x3;\n+\t\tslice_mask = 0xf;\n \t\tbreak;\n \n \tcase TF_SRAM_SLICE_SIZE_64B:\n+\t\tslice_mask = 0x3;\n+\t\tbreak;\n+\n+\tcase TF_SRAM_SLICE_SIZE_128B:\n \tdefault:\n \t\tslice_mask = 0x1;\n \t\tbreak;\n@@ -543,7 +563,7 @@ tf_sram_find_first_not_full_block(struct tf_sram_slice_list *slice_list,\n static void\n tf_sram_dump_block(struct tf_sram_block *block)\n {\n-\tTFP_DRV_LOG(INFO, \"block_id(0x%x) in_use_mask(0x%02x)\\n\",\n+\tTFP_DRV_LOG(INFO, \"block_id(0x%x) in_use_mask(0x%04x)\\n\",\n \t\t    block->block_id,\n \t\t    block->in_use_mask);\n }\n@@ -631,9 +651,10 @@ int tf_sram_mgr_alloc(void *sram_handle,\n \tstruct tf_sram *sram;\n \tstruct tf_sram_slice_list *slice_list;\n \tuint16_t block_id, slice_offset = 0;\n-\tuint32_t index;\n+\tuint32_t index, next_index;\n \tstruct tf_sram_block *block;\n \tstruct tf_rm_allocate_parms aparms = { 0 };\n+\tstruct tf_rm_free_parms fparms = { 0 };\n \tbool block_is_full;\n \tuint16_t block_offset;\n \n@@ -662,11 +683,34 @@ int tf_sram_mgr_alloc(void *sram_handle,\n \t\taparms.subtype = parms->tbl_type;\n \t\taparms.rm_db = parms->rm_db;\n \t\trc = tf_rm_allocate(&aparms);\n+\t\tif (rc)\n+\t\t\treturn rc;\n+\t\t/* to support 128B block rows, we are allocating\n+\t\t * 2 sequential 64B blocks from RM, if they are not next to\n+\t\t * each other we are going to have issues\n+\t\t */\n+\t\taparms.index = &next_index;\n+\t\trc = tf_rm_allocate(&aparms);\n \t\tif (rc)\n \t\t\treturn rc;\n \n+\t\t/* make sure we do get the next 64B block, else free the\n+\t\t * allocated indexes and return error\n+\t\t */\n+\t\tif (unlikely(index + 1 != next_index)) {\n+\t\t\tfparms.index = index;\n+\t\t\tfparms.subtype = parms->tbl_type;\n+\t\t\tfparms.rm_db = parms->rm_db;\n+\t\t\ttf_rm_free(&fparms);\n+\t\t\tfparms.index = next_index;\n+\t\t\ttf_rm_free(&fparms);\n+\t\t\tTFP_DRV_LOG(ERR,\n+\t\t\t\t    \"Could not allocate two sequential 64B blocks\\n\");\n+\t\t\treturn -ENOMEM;\n+\t\t}\n \t\tblock_id = index;\n \t\tblock = tf_sram_alloc_block(slice_list, block_id);\n+\n \t} else {\n \t\t/* Block exists\n \t\t */\n@@ -742,7 +786,7 @@ tf_sram_mgr_free(void *sram_handle,\n \t}\n #if (STATS_CLEAR_ON_READ_SUPPORT == 0)\n \t/* If this is a counter, clear it.  In the future we need to switch to\n-\t * using the special access registers on Thor to automatically clear on\n+\t * using the special access registers on P5 to automatically clear on\n \t * read.\n \t */\n \t/* If this is counter table, clear the entry on free */\n@@ -794,6 +838,13 @@ tf_sram_mgr_free(void *sram_handle,\n \t\t\tTFP_DRV_LOG(ERR, \"Free block_id(%d) failed error(%s)\\n\",\n \t\t\t\t    block_id, strerror(-rc));\n \t\t}\n+\t\tfparms.index = block_id + 1;\n+\t\trc = tf_rm_free(&fparms);\n+\n+\t\tif (rc) {\n+\t\t\tTFP_DRV_LOG(ERR, \"Free next block_id(%d) failed error(%s)\\n\",\n+\t\t\t\t    block_id + 1, strerror(-rc));\n+\t\t}\n \t\t/* Free local entry regardless */\n \t\ttf_sram_free_block(slice_list, block);\n \ndiff --git a/drivers/net/bnxt/tf_core/tf_sram_mgr.h b/drivers/net/bnxt/tf_core/tf_sram_mgr.h\nindex fc78426130..878195c404 100644\n--- a/drivers/net/bnxt/tf_core/tf_sram_mgr.h\n+++ b/drivers/net/bnxt/tf_core/tf_sram_mgr.h\n@@ -1,5 +1,5 @@\n /* SPDX-License-Identifier: BSD-3-Clause\n- * Copyright(c) 2019-2021 Broadcom\n+ * Copyright(c) 2019-2023 Broadcom\n  * All rights reserved.\n  */\n \n@@ -26,28 +26,28 @@\n  */\n #define STATS_CLEAR_ON_READ_SUPPORT 0\n \n-#define TF_SRAM_MGR_BLOCK_SZ_BYTES 64\n+#define TF_SRAM_MGR_BLOCK_SZ_BYTES 128\n #define TF_SRAM_MGR_MIN_SLICE_BYTES 8\n \n /**\n  * TF slice size.\n  *\n- * A slice is part of a 64B row\n+ * A slice is part of a 128B row\n  *\n  * Each slice is a multiple of 8B\n  */\n enum tf_sram_slice_size {\n-\tTF_SRAM_SLICE_SIZE_8B,\t/**< 8 byte SRAM slice */\n-\tTF_SRAM_SLICE_SIZE_16B,\t/**< 16 byte SRAM slice */\n-\tTF_SRAM_SLICE_SIZE_32B,\t/**< 32 byte SRAM slice */\n-\tTF_SRAM_SLICE_SIZE_64B,\t/**< 64 byte SRAM slice */\n-\tTF_SRAM_SLICE_SIZE_MAX  /**< slice limit */\n+\tTF_SRAM_SLICE_SIZE_8B,\t\t/**< 8 byte SRAM slice */\n+\tTF_SRAM_SLICE_SIZE_16B,\t\t/**< 16 byte SRAM slice */\n+\tTF_SRAM_SLICE_SIZE_32B,\t\t/**< 32 byte SRAM slice */\n+\tTF_SRAM_SLICE_SIZE_64B,\t\t/**< 64 byte SRAM slice */\n+\tTF_SRAM_SLICE_SIZE_128B,\t/**< 128 byte SRAM slice */\n+\tTF_SRAM_SLICE_SIZE_MAX\t\t/**< slice limit */\n };\n \n-\n /** Initialize the SRAM slice manager\n  *\n- *  The SRAM slice manager manages slices within 64B rows. Slices are of size\n+ *  The SRAM slice manager manages slices within 128B rows. Slices are of size\n  *  tf_sram_slice_size.  This function provides a handle to the SRAM manager\n  *  data.\n  *\n@@ -181,7 +181,7 @@ struct tf_sram_mgr_free_parms {\n /**\n  * Free an SRAM Slice\n  *\n- * Free an SRAM slice to the indicated bank.  This may result in a 64B row\n+ * Free an SRAM slice to the indicated bank.  This may result in a 128B row\n  * being returned to the RM SRAM bank pool.\n  *\n  * [in] sram_handle\ndiff --git a/drivers/net/bnxt/tf_core/tf_tbl.c b/drivers/net/bnxt/tf_core/tf_tbl.c\nindex f18e4ba346..f5f3889934 100644\n--- a/drivers/net/bnxt/tf_core/tf_tbl.c\n+++ b/drivers/net/bnxt/tf_core/tf_tbl.c\n@@ -1,12 +1,11 @@\n /* SPDX-License-Identifier: BSD-3-Clause\n- * Copyright(c) 2019-2021 Broadcom\n+ * Copyright(c) 2019-2023 Broadcom\n  * All rights reserved.\n  */\n \n /* Truflow Table APIs and supporting code */\n \n #include <rte_common.h>\n-\n #include \"tf_tbl.h\"\n #include \"tf_common.h\"\n #include \"tf_rm.h\"\n@@ -18,8 +17,8 @@\n \n struct tf;\n \n-#define TF_TBL_RM_TO_PTR(new_idx, idx, base, shift) {          \\\n-\t\t*(new_idx) = (((idx) + (base)) << (shift));    \\\n+#define TF_TBL_RM_TO_PTR(new_idx, idx, base, shift) {\t\t\\\n+\t\t*(new_idx) = (((idx) + (base)) << (shift));\t\\\n }\n \n int\n@@ -98,6 +97,7 @@ tf_tbl_unbind(struct tf *tfp)\n \trc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);\n \tif (rc)\n \t\treturn 0;\n+\n \ttbl_db = (struct tbl_rm_db *)tbl_db_ptr;\n \n \tfor (i = 0; i < TF_DIR_MAX; i++) {\ndiff --git a/drivers/net/bnxt/tf_core/tf_tbl_sram.c b/drivers/net/bnxt/tf_core/tf_tbl_sram.c\nindex 567f912dfa..3a6f1c68c7 100644\n--- a/drivers/net/bnxt/tf_core/tf_tbl_sram.c\n+++ b/drivers/net/bnxt/tf_core/tf_tbl_sram.c\n@@ -1,5 +1,5 @@\n /* SPDX-License-Identifier: BSD-3-Clause\n- * Copyright(c) 2019-2021 Broadcom\n+ * Copyright(c) 2019-2023 Broadcom\n  * All rights reserved.\n  */\n \n@@ -73,11 +73,12 @@ const uint16_t tf_tbl_sram_hcapi_2_bank[CFA_RESOURCE_TYPE_P58_LAST] = {\n  * Translate HCAPI type to SRAM Manager bank\n  */\n const uint8_t tf_tbl_sram_slices_2_size[TF_TBL_SRAM_SLICES_MAX + 1] = {\n-\t[0] = TF_SRAM_SLICE_SIZE_64B, /* if 0 slices assume 1 64B block */\n-\t[1] = TF_SRAM_SLICE_SIZE_64B, /* 1 slice  per 64B block */\n-\t[2] = TF_SRAM_SLICE_SIZE_32B, /* 2 slices per 64B block */\n-\t[4] = TF_SRAM_SLICE_SIZE_16B, /* 4 slices per 64B block */\n-\t[8] = TF_SRAM_SLICE_SIZE_8B   /* 8 slices per 64B block */\n+\t[0] = TF_SRAM_SLICE_SIZE_128B,\t/* if 0 slices assume 1 128B block */\n+\t[1] = TF_SRAM_SLICE_SIZE_128B,\t/* 1 slice  per 128B block */\n+\t[2] = TF_SRAM_SLICE_SIZE_64B,\t/* 2 slice  per 128B block */\n+\t[4] = TF_SRAM_SLICE_SIZE_32B,\t/* 4 slices per 128B block */\n+\t[8] = TF_SRAM_SLICE_SIZE_16B,\t/* 8 slices per 128B block */\n+\t[16] = TF_SRAM_SLICE_SIZE_8B\t/* 16 slices per 128B block */\n };\n \n /**\n@@ -340,7 +341,7 @@ tf_tbl_sram_free(struct tf *tfp __rte_unused,\n \trc = tf_sram_mgr_is_allocated(sram_handle, &aparms);\n \tif (rc || !allocated) {\n \t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s: Free of invalid entry:%s idx(%d):(%s)\\n\",\n+\t\t\t    \"%s: Free of invalid entry:%s idx(0x%x):(%s)\\n\",\n \t\t\t    tf_dir_2_str(parms->dir),\n \t\t\t    tf_tbl_type_2_str(parms->type),\n \t\t\t    parms->idx,\n@@ -361,7 +362,7 @@ tf_tbl_sram_free(struct tf *tfp __rte_unused,\n \trc = tf_sram_mgr_free(sram_handle, &fparms);\n \tif (rc) {\n \t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s: Failed to free entry:%s idx(%d)\\n\",\n+\t\t\t    \"%s: Failed to free entry:%s idx(0x%x)\\n\",\n \t\t\t    tf_dir_2_str(parms->dir),\n \t\t\t    tf_tbl_type_2_str(parms->type),\n \t\t\t    parms->idx);\n@@ -469,7 +470,7 @@ tf_tbl_sram_set(struct tf *tfp,\n \n \t\tif (rallocated != TF_RM_ALLOCATED_ENTRY_IN_USE) {\n \t\t\tTFP_DRV_LOG(ERR,\n-\t\t\t   \"%s, Invalid or not allocated index, type:%s, idx:%d\\n\",\n+\t\t\t   \"%s, Invalid or not allocated index, type:%s, idx:0x%x\\n\",\n \t\t\t   tf_dir_2_str(parms->dir),\n \t\t\t   tf_tbl_type_2_str(parms->type),\n \t\t\t   parms->idx);\n@@ -484,7 +485,7 @@ tf_tbl_sram_set(struct tf *tfp,\n \t\trc = tf_sram_mgr_is_allocated(sram_handle, &aparms);\n \t\tif (rc || !allocated) {\n \t\t\tTFP_DRV_LOG(ERR,\n-\t\t\t\t    \"%s: Entry not allocated:%s idx(%d):(%s)\\n\",\n+\t\t\t\t    \"%s: Entry not allocated:%s idx(0x%x):(%s)\\n\",\n \t\t\t\t    tf_dir_2_str(parms->dir),\n \t\t\t\t    tf_tbl_type_2_str(parms->type),\n \t\t\t\t    parms->idx,\n@@ -587,7 +588,7 @@ tf_tbl_sram_get(struct tf *tfp,\n \trc = tf_sram_mgr_is_allocated(sram_handle, &aparms);\n \tif (rc || !allocated) {\n \t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s: Entry not allocated:%s idx(%d):(%s)\\n\",\n+\t\t\t    \"%s: Entry not allocated:%s idx(0x%x):(%s)\\n\",\n \t\t\t    tf_dir_2_str(parms->dir),\n \t\t\t    tf_tbl_type_2_str(parms->type),\n \t\t\t    parms->idx,\n@@ -711,7 +712,7 @@ tf_tbl_sram_bulk_get(struct tf *tfp,\n \trc = tf_sram_mgr_is_allocated(sram_handle, &aparms);\n \tif (rc || !allocated) {\n \t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s: Entry not allocated:%s last_idx(%d):(%s)\\n\",\n+\t\t\t    \"%s: Entry not allocated:%s last_idx(0x%x):(%s)\\n\",\n \t\t\t    tf_dir_2_str(parms->dir),\n \t\t\t    tf_tbl_type_2_str(parms->type),\n \t\t\t    idx,\ndiff --git a/drivers/net/bnxt/tf_core/tf_tcam.c b/drivers/net/bnxt/tf_core/tf_tcam.c\nindex 1c42a6adc7..9e0671d47b 100644\n--- a/drivers/net/bnxt/tf_core/tf_tcam.c\n+++ b/drivers/net/bnxt/tf_core/tf_tcam.c\n@@ -1,5 +1,5 @@\n /* SPDX-License-Identifier: BSD-3-Clause\n- * Copyright(c) 2019-2021 Broadcom\n+ * Copyright(c) 2019-2023 Broadcom\n  * All rights reserved.\n  */\n \n@@ -14,6 +14,7 @@\n #include \"tfp.h\"\n #include \"tf_session.h\"\n #include \"tf_msg.h\"\n+#include \"tf_tcam_mgr_msg.h\"\n \n struct tf;\n \n@@ -23,17 +24,22 @@ tf_tcam_bind(struct tf *tfp,\n {\n \tint rc;\n \tint db_rc[TF_DIR_MAX] = { 0 };\n-\tint i, d;\n+\tint d, t;\n \tstruct tf_rm_alloc_info info;\n \tstruct tf_rm_free_db_parms fparms;\n \tstruct tf_rm_create_db_parms db_cfg;\n+\tstruct tf_tcam_resources local_tcam_cnt[TF_DIR_MAX];\n \tstruct tf_tcam_resources *tcam_cnt;\n \tstruct tf_rm_get_alloc_info_parms ainfo;\n-\tuint16_t num_slices = parms->wc_num_slices;\n+\tuint16_t num_slices = 1;\n \tstruct tf_session *tfs;\n \tstruct tf_dev_info *dev;\n \tstruct tcam_rm_db *tcam_db;\n \tstruct tfp_calloc_parms cparms;\n+\tstruct tf_resource_info resv_res[TF_DIR_MAX][TF_TCAM_TBL_TYPE_MAX];\n+\tuint32_t rx_supported;\n+\tuint32_t tx_supported;\n+\tbool no_req = true;\n \n \tTF_CHECK_PARMS2(tfp, parms);\n \n@@ -47,7 +53,7 @@ tf_tcam_bind(struct tf *tfp,\n \tif (rc)\n \t\treturn rc;\n \n-\tif (dev->ops->tf_dev_set_tcam_slice_info == NULL) {\n+\tif (dev->ops->tf_dev_get_tcam_slice_info == NULL) {\n \t\trc = -EOPNOTSUPP;\n \t\tTFP_DRV_LOG(ERR,\n \t\t\t    \"Operation not supported, rc:%s\\n\",\n@@ -55,18 +61,28 @@ tf_tcam_bind(struct tf *tfp,\n \t\treturn rc;\n \t}\n \n-\trc = dev->ops->tf_dev_set_tcam_slice_info(tfp,\n-\t\t\t\t\t\t  num_slices);\n+\ttcam_cnt = parms->resources->tcam_cnt;\n+\n+\tfor (d = 0; d < TF_DIR_MAX; d++) {\n+\t\tfor (t = 0; t < TF_TCAM_TBL_TYPE_MAX; t++) {\n+\t\t\trc = dev->ops->tf_dev_get_tcam_slice_info(tfp, t, 0,\n+\t\t\t\t\t\t\t\t  &num_slices);\n \tif (rc)\n \t\treturn rc;\n \n-\ttcam_cnt = parms->resources->tcam_cnt;\n-\tif ((tcam_cnt[TF_DIR_RX].cnt[TF_TCAM_TBL_TYPE_WC_TCAM] % num_slices) ||\n-\t    (tcam_cnt[TF_DIR_TX].cnt[TF_TCAM_TBL_TYPE_WC_TCAM] % num_slices)) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"Requested num of WC TCAM entries has to be multiple %d\\n\",\n-\t\t\t    num_slices);\n-\t\treturn -EINVAL;\n+\t\t\tif (num_slices == 1)\n+\t\t\t\tcontinue;\n+\n+\t\t\tif (tcam_cnt[d].cnt[t] % num_slices) {\n+\t\t\t\tTFP_DRV_LOG(ERR,\n+\t\t\t\t\t    \"%s: Requested num of %s entries \"\n+\t\t\t\t\t    \"has to be multiple of %d\\n\",\n+\t\t\t\t\t    tf_dir_2_str(d),\n+\t\t\t\t\t    tf_tcam_tbl_2_str(t),\n+\t\t\t\t\t    num_slices);\n+\t\t\t\treturn -EINVAL;\n+\t\t\t}\n+\t\t}\n \t}\n \n \tmemset(&db_cfg, 0, sizeof(db_cfg));\n@@ -80,8 +96,8 @@ tf_tcam_bind(struct tf *tfp,\n \t}\n \n \ttcam_db = cparms.mem_va;\n-\tfor (i = 0; i < TF_DIR_MAX; i++)\n-\t\ttcam_db->tcam_db[i] = NULL;\n+\tfor (d = 0; d < TF_DIR_MAX; d++)\n+\t\ttcam_db->tcam_db[d] = NULL;\n \ttf_session_set_db(tfp, TF_MODULE_TYPE_TCAM, tcam_db);\n \n \tdb_cfg.module = TF_MODULE_TYPE_TCAM;\n@@ -90,7 +106,7 @@ tf_tcam_bind(struct tf *tfp,\n \n \tfor (d = 0; d < TF_DIR_MAX; d++) {\n \t\tdb_cfg.dir = d;\n-\t\tdb_cfg.alloc_cnt = parms->resources->tcam_cnt[d].cnt;\n+\t\tdb_cfg.alloc_cnt = tcam_cnt[d].cnt;\n \t\tdb_cfg.rm_db = (void *)&tcam_db->tcam_db[d];\n \t\tif (tf_session_is_shared_session(tfs) &&\n \t\t\t(!tf_session_is_shared_session_creator(tfs)))\n@@ -98,53 +114,112 @@ tf_tcam_bind(struct tf *tfp,\n \t\telse\n \t\t\tdb_rc[d] = tf_rm_create_db(tfp, &db_cfg);\n \t}\n-\n \t/* No db created */\n \tif (db_rc[TF_DIR_RX] && db_rc[TF_DIR_TX]) {\n \t\tTFP_DRV_LOG(ERR, \"No TCAM DB created\\n\");\n \t\treturn db_rc[TF_DIR_RX];\n \t}\n \n-\t/* check if reserved resource for WC is multiple of num_slices */\n+\t/* Collect info on which entries were reserved. */\n \tfor (d = 0; d < TF_DIR_MAX; d++) {\n-\t\tif (!tcam_db->tcam_db[d])\n-\t\t\tcontinue;\n+\t\tfor (t = 0; t < TF_TCAM_TBL_TYPE_MAX; t++) {\n+\t\t\tmemset(&info, 0, sizeof(info));\n+\t\t\tif (tcam_cnt[d].cnt[t] == 0) {\n+\t\t\t\tresv_res[d][t].start  = 0;\n+\t\t\t\tresv_res[d][t].stride = 0;\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\t\t\tainfo.rm_db = tcam_db->tcam_db[d];\n+\t\t\tainfo.subtype = t;\n+\t\t\tainfo.info = &info;\n+\t\t\trc = tf_rm_get_info(&ainfo);\n+\t\t\tif (rc)\n+\t\t\t\tgoto error;\n+\n+\t\t\trc = dev->ops->tf_dev_get_tcam_slice_info(tfp, t, 0,\n+\t\t\t\t\t\t\t\t  &num_slices);\n+\t\t\tif (rc)\n+\t\t\t\treturn rc;\n+\n+\t\t\tif (num_slices > 1) {\n+\t\t\t\t/* check if reserved resource for is multiple of\n+\t\t\t\t * num_slices\n+\t\t\t\t */\n+\t\t\t\tif (info.entry.start % num_slices != 0 ||\n+\t\t\t\t    info.entry.stride % num_slices != 0) {\n+\t\t\t\t\tTFP_DRV_LOG(ERR,\n+\t\t\t\t\t\t    \"%s: %s reserved resource\"\n+\t\t\t\t\t\t    \" is not multiple of %d\\n\",\n+\t\t\t\t\t\t    tf_dir_2_str(d),\n+\t\t\t\t\t\t    tf_tcam_tbl_2_str(t),\n+\t\t\t\t\t\t    num_slices);\n+\t\t\t\t\trc = -EINVAL;\n+\t\t\t\t\tgoto error;\n+\t\t\t\t}\n+\t\t\t}\n+\n+\t\t\tresv_res[d][t].start  = info.entry.start;\n+\t\t\tresv_res[d][t].stride = info.entry.stride;\n+\t\t}\n+\t}\n \n-\t\tmemset(&info, 0, sizeof(info));\n-\t\tainfo.rm_db = tcam_db->tcam_db[d];\n-\t\tainfo.subtype = TF_TCAM_TBL_TYPE_WC_TCAM;\n-\t\tainfo.info = &info;\n-\t\trc = tf_rm_get_info(&ainfo);\n-\t\tif (rc)\n-\t\t\tgoto error;\n-\n-\t\tif (info.entry.start % num_slices != 0 ||\n-\t\t    info.entry.stride % num_slices != 0) {\n-\t\t\tTFP_DRV_LOG(ERR,\n-\t\t\t\t    \"%s: TCAM reserved resource is not multiple of %d\\n\",\n-\t\t\t\t    tf_dir_2_str(d),\n-\t\t\t\t    num_slices);\n-\t\t\trc = -EINVAL;\n-\t\t\tgoto error;\n+\trc = tf_tcam_mgr_bind_msg(tfp, dev, parms, resv_res);\n+\tif (rc)\n+\t\treturn rc;\n+\n+\trc = tf_tcam_mgr_qcaps_msg(tfp, dev,\n+\t\t\t\t   &rx_supported, &tx_supported);\n+\tif (rc)\n+\t\treturn rc;\n+\n+\tfor (t = 0; t < TF_TCAM_TBL_TYPE_MAX; t++) {\n+\t\tif (rx_supported & 1 << t)\n+\t\t\ttfs->tcam_mgr_control[TF_DIR_RX][t] = 1;\n+\t\tif (tx_supported & 1 << t)\n+\t\t\ttfs->tcam_mgr_control[TF_DIR_TX][t] = 1;\n+\t}\n+\n+\t/*\n+\t * Make a local copy of tcam_cnt with only resources not managed by TCAM\n+\t * Manager requested.\n+\t */\n+\tmemcpy(&local_tcam_cnt, tcam_cnt, sizeof(local_tcam_cnt));\n+\ttcam_cnt = local_tcam_cnt;\n+\tfor (d = 0; d < TF_DIR_MAX; d++) {\n+\t\tfor (t = 0; t < TF_TCAM_TBL_TYPE_MAX; t++) {\n+\t\t\t/* If controlled by TCAM Manager */\n+\t\t\tif (tfs->tcam_mgr_control[d][t])\n+\t\t\t\ttcam_cnt[d].cnt[t] = 0;\n+\t\t\telse if (tcam_cnt[d].cnt[t] > 0)\n+\t\t\t\tno_req = false;\n \t\t}\n \t}\n \n-\t/* Initialize the TCAM manager. */\n+\t/* If no resources left to request */\n+\tif (no_req)\n+\t\tgoto finished;\n+\n+finished:\n \tTFP_DRV_LOG(INFO,\n \t\t    \"TCAM - initialized\\n\");\n \n \treturn 0;\n error:\n-\tfor (i = 0; i < TF_DIR_MAX; i++) {\n-\t\tmemset(&fparms, 0, sizeof(fparms));\n-\t\tfparms.dir = i;\n-\t\tfparms.rm_db = tcam_db->tcam_db[i];\n-\t\t/* Ignoring return here since we are in the error case */\n-\t\t(void)tf_rm_free_db(tfp, &fparms);\n-\t\ttcam_db->tcam_db[i] = NULL;\n+\tfor (d = 0; d < TF_DIR_MAX; d++) {\n+\t\tif (tcam_db->tcam_db[d] != NULL) {\n+\t\t\tmemset(&fparms, 0, sizeof(fparms));\n+\t\t\tfparms.dir = d;\n+\t\t\tfparms.rm_db = tcam_db->tcam_db[d];\n+\t\t\t/*\n+\t\t\t * Ignoring return here since we are in the error case\n+\t\t\t */\n+\t\t\t(void)tf_rm_free_db(tfp, &fparms);\n+\n+\t\t\ttcam_db->tcam_db[d] = NULL;\n+\t\t}\n+\t\ttcam_db->tcam_db[d] = NULL;\n \t\ttf_session_set_db(tfp, TF_MODULE_TYPE_TCAM, NULL);\n \t}\n-\n \treturn rc;\n }\n \n@@ -156,27 +231,43 @@ tf_tcam_unbind(struct tf *tfp)\n \tstruct tf_rm_free_db_parms fparms;\n \tstruct tcam_rm_db *tcam_db;\n \tvoid *tcam_db_ptr = NULL;\n+\tstruct tf_session *tfs;\n+\tstruct tf_dev_info *dev;\n \tTF_CHECK_PARMS1(tfp);\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/* Retrieve the device information */\n+\trc = tf_session_get_device(tfs, &dev);\n+\tif (rc)\n+\t\treturn rc;\n \trc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);\n-\tif (rc) {\n+\tif (rc)\n \t\treturn 0;\n-\t}\n+\n \ttcam_db = (struct tcam_rm_db *)tcam_db_ptr;\n \n \tfor (i = 0; i < TF_DIR_MAX; i++) {\n-\t\tif (tcam_db->tcam_db[i] == NULL)\n-\t\t\tcontinue;\n-\t\tmemset(&fparms, 0, sizeof(fparms));\n-\t\tfparms.dir = i;\n-\t\tfparms.rm_db = tcam_db->tcam_db[i];\n-\t\trc = tf_rm_free_db(tfp, &fparms);\n-\t\tif (rc)\n-\t\t\treturn rc;\n+\t\tif (tcam_db->tcam_db[i] != NULL) {\n+\t\t\tmemset(&fparms, 0, sizeof(fparms));\n+\t\t\tfparms.dir = i;\n+\t\t\tfparms.rm_db = tcam_db->tcam_db[i];\n+\t\t\trc = tf_rm_free_db(tfp, &fparms);\n+\t\t\tif (rc)\n+\t\t\t\treturn rc;\n+\n+\t\t\ttcam_db->tcam_db[i] = NULL;\n+\t\t}\n \n-\t\ttcam_db->tcam_db[i] = NULL;\n \t}\n \n+\trc = tf_tcam_mgr_unbind_msg(tfp, dev);\n+\tif (rc)\n+\t\treturn rc;\n+\n \treturn 0;\n }\n \n@@ -222,6 +313,9 @@ tf_tcam_alloc(struct tf *tfp,\n \tif (rc)\n \t\treturn rc;\n \n+\t/* If TCAM controlled by TCAM Manager */\n+\tif (tfs->tcam_mgr_control[parms->dir][parms->type])\n+\t\treturn tf_tcam_mgr_alloc_msg(tfp, dev, parms);\n \trc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);\n \tif (rc) {\n \t\tTFP_DRV_LOG(ERR,\n@@ -251,12 +345,8 @@ tf_tcam_alloc(struct tf *tfp,\n \t\t}\n \n \t\t/* return the start index of each row */\n-\t\tif (parms->priority == 0) {\n \t\t\tif (i == 0)\n \t\t\t\tparms->idx = index;\n-\t\t} else {\n-\t\t\tparms->idx = index;\n-\t\t}\n \t}\n \n \treturn 0;\n@@ -307,6 +397,14 @@ tf_tcam_free(struct tf *tfp,\n \tif (rc)\n \t\treturn rc;\n \n+\t/* If TCAM controlled by TCAM Manager */\n+\tif (tfs->tcam_mgr_control[parms->dir][parms->type])\n+\t\t/*\n+\t\t * If a session can have multiple references to an entry, check\n+\t\t * the reference count here before actually freeing the entry.\n+\t\t */\n+\t\treturn tf_tcam_mgr_free_msg(tfp, dev, parms);\n+\n \tif (parms->idx % num_slices) {\n \t\tTFP_DRV_LOG(ERR,\n \t\t\t    \"%s: TCAM reserved resource is not multiple of %d\\n\",\n@@ -429,6 +527,10 @@ tf_tcam_set(struct tf *tfp __rte_unused,\n \tif (rc)\n \t\treturn rc;\n \n+\t/* If TCAM controlled by TCAM Manager */\n+\tif (tfs->tcam_mgr_control[parms->dir][parms->type])\n+\t\treturn tf_tcam_mgr_set_msg(tfp, dev, parms);\n+\n \trc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);\n \tif (rc) {\n \t\tTFP_DRV_LOG(ERR,\n@@ -508,6 +610,10 @@ tf_tcam_get(struct tf *tfp __rte_unused,\n \tif (rc)\n \t\treturn rc;\n \n+\t/* If TCAM controlled by TCAM Manager */\n+\tif (tfs->tcam_mgr_control[parms->dir][parms->type])\n+\t\treturn tf_tcam_mgr_get_msg(tfp, dev, parms);\n+\n \trc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);\n \tif (rc) {\n \t\tTFP_DRV_LOG(ERR,\ndiff --git a/drivers/net/bnxt/tf_core/tf_tcam_mgr_msg.c b/drivers/net/bnxt/tf_core/tf_tcam_mgr_msg.c\nnew file mode 100644\nindex 0000000000..c535f4f4f6\n--- /dev/null\n+++ b/drivers/net/bnxt/tf_core/tf_tcam_mgr_msg.c\n@@ -0,0 +1,286 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2021-2023 Broadcom\n+ * All rights reserved.\n+ */\n+\n+#include <errno.h>\n+\n+#include \"tfp.h\"\n+#include \"tf_tcam.h\"\n+#include \"cfa_tcam_mgr.h\"\n+#include \"tf_tcam_mgr_msg.h\"\n+\n+/*\n+ * Table to convert TCAM type to logical TCAM type for applications.\n+ * Index is tf_tcam_tbl_type.\n+ */\n+static enum cfa_tcam_mgr_tbl_type tcam_types[TF_TCAM_TBL_TYPE_MAX] = {\n+\t[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_HIGH] =\n+\t\tCFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_HIGH_APPS,\n+\t[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_LOW]  =\n+\t\tCFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_LOW_APPS,\n+\t[TF_TCAM_TBL_TYPE_PROF_TCAM]\t     =\n+\t\tCFA_TCAM_MGR_TBL_TYPE_PROF_TCAM_APPS,\n+\t[TF_TCAM_TBL_TYPE_WC_TCAM]\t     =\n+\t\tCFA_TCAM_MGR_TBL_TYPE_WC_TCAM_APPS,\n+\t[TF_TCAM_TBL_TYPE_SP_TCAM]\t     =\n+\t\tCFA_TCAM_MGR_TBL_TYPE_SP_TCAM_APPS,\n+\t[TF_TCAM_TBL_TYPE_CT_RULE_TCAM]\t     =\n+\t\tCFA_TCAM_MGR_TBL_TYPE_CT_RULE_TCAM_APPS,\n+\t[TF_TCAM_TBL_TYPE_VEB_TCAM]\t     =\n+\t\tCFA_TCAM_MGR_TBL_TYPE_VEB_TCAM_APPS,\n+\t[TF_TCAM_TBL_TYPE_WC_TCAM_HIGH]      =\n+\t\tCFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_APPS,\n+\t[TF_TCAM_TBL_TYPE_WC_TCAM_LOW]       =\n+\t\tCFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_APPS,\n+};\n+\n+static uint16_t hcapi_type[TF_TCAM_TBL_TYPE_MAX];\n+\n+/*\n+ * This is the glue between the core tf_tcam and the TCAM manager.  It is\n+ * intended to abstract out the location of the TCAM manager so that the core\n+ * code will be the same if the TCAM manager is in the core or in firmware.\n+ *\n+ * If the TCAM manager is in the core, then this file will just translate to\n+ * TCAM manager APIs.  If TCAM manager is in firmware, then this file will cause\n+ * messages to be sent (except for bind and unbind).\n+ */\n+\n+int\n+tf_tcam_mgr_qcaps_msg(struct tf *tfp,\n+\t\t      struct tf_dev_info *dev __rte_unused,\n+\t\t      uint32_t *rx_tcam_supported,\n+\t\t      uint32_t *tx_tcam_supported)\n+{\n+\tstruct cfa_tcam_mgr_context   context;\n+\tstruct cfa_tcam_mgr_qcaps_parms mgr_parms;\n+\tint rc;\n+\n+\tcontext.tfp = tfp;\n+\tmemset(&mgr_parms, 0, sizeof(mgr_parms));\n+\trc = cfa_tcam_mgr_qcaps(&context, &mgr_parms);\n+\tif (rc >= 0) {\n+\t\t*rx_tcam_supported = mgr_parms.rx_tcam_supported;\n+\t\t*tx_tcam_supported = mgr_parms.tx_tcam_supported;\n+\t}\n+\treturn rc;\n+}\n+\n+int\n+tf_tcam_mgr_bind_msg(struct tf *tfp,\n+\t\t     struct tf_dev_info *dev __rte_unused,\n+\t\t     struct tf_tcam_cfg_parms *parms,\n+\t\t     struct tf_resource_info resv_res[][TF_TCAM_TBL_TYPE_MAX]\n+\t\t     __rte_unused\n+\t)\n+{\n+\t/* Common Code */\n+\tint type;\n+\n+\tif (parms->num_elements != TF_TCAM_TBL_TYPE_MAX) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"Invalid number of elements in bind request.\\n\");\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"Expected %d, received %d.\\n\",\n+\t\t\t    TF_TCAM_TBL_TYPE_MAX,\n+\t\t\t    parms->num_elements);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tfor (type = 0; type < TF_TCAM_TBL_TYPE_MAX; type++)\n+\t\thcapi_type[type] = parms->cfg[type].hcapi_type;\n+\n+\tstruct cfa_tcam_mgr_context   context;\n+\tstruct cfa_tcam_mgr_cfg_parms mgr_parms;\n+\tstruct tf_rm_resc_entry\n+\t\tmgr_resv_res[TF_DIR_MAX][CFA_TCAM_MGR_TBL_TYPE_MAX];\n+\tint dir, rc;\n+\n+\tcontext.tfp = tfp;\n+\n+\tmemset(&mgr_parms, 0, sizeof(mgr_parms));\n+\n+\tmgr_parms.num_elements = CFA_TCAM_MGR_TBL_TYPE_MAX;\n+\n+\t/* Convert the data to logical tables */\n+\tfor (dir = 0; dir < TF_DIR_MAX; dir++) {\n+\t\tfor (type = 0; type < TF_TCAM_TBL_TYPE_MAX; type++) {\n+\t\t\tmgr_parms.tcam_cnt[dir][tcam_types[type]] =\n+\t\t\t\tparms->resources->tcam_cnt[dir].cnt[type];\n+\t\t\tmgr_resv_res[dir][tcam_types[type]].start =\n+\t\t\t\tresv_res[dir][type].start;\n+\t\t\tmgr_resv_res[dir][tcam_types[type]].stride =\n+\t\t\t\tresv_res[dir][type].stride;\n+\t\t}\n+\t}\n+\tmgr_parms.resv_res = mgr_resv_res;\n+\n+\trc = cfa_tcam_mgr_bind(&context, &mgr_parms);\n+\n+\treturn rc;\n+}\n+\n+int\n+tf_tcam_mgr_unbind_msg(struct tf *tfp,\n+\t\t       struct tf_dev_info *dev __rte_unused)\n+{\n+\tstruct cfa_tcam_mgr_context context;\n+\n+\tcontext.tfp = tfp;\n+\n+\treturn cfa_tcam_mgr_unbind(&context);\n+}\n+\n+int\n+tf_tcam_mgr_alloc_msg(struct tf *tfp,\n+\t\t      struct tf_dev_info *dev __rte_unused,\n+\t\t      struct tf_tcam_alloc_parms *parms)\n+{\n+\tstruct cfa_tcam_mgr_context context;\n+\tstruct cfa_tcam_mgr_alloc_parms mgr_parms;\n+\tint rc;\n+\n+\tif (parms->type >= TF_TCAM_TBL_TYPE_MAX) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"No such TCAM table %d.\\n\",\n+\t\t\t    parms->type);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tcontext.tfp = tfp;\n+\n+\tmgr_parms.dir\t     = parms->dir;\n+\tmgr_parms.type\t     = tcam_types[parms->type];\n+\tmgr_parms.hcapi_type = hcapi_type[parms->type];\n+\tmgr_parms.key_size   = parms->key_size;\n+\tif (parms->priority > TF_TCAM_PRIORITY_MAX)\n+\t\tmgr_parms.priority = 0;\n+\telse\n+\t\tmgr_parms.priority = TF_TCAM_PRIORITY_MAX - parms->priority - 1;\n+\n+\trc = cfa_tcam_mgr_alloc(&context, &mgr_parms);\n+\tif (rc)\n+\t\treturn rc;\n+\n+\tparms->idx = mgr_parms.id;\n+\treturn 0;\n+}\n+\n+int\n+tf_tcam_mgr_free_msg(struct tf *tfp,\n+\t\t     struct tf_dev_info *dev __rte_unused,\n+\t\t     struct tf_tcam_free_parms *parms)\n+{\n+\tstruct cfa_tcam_mgr_context context;\n+\tstruct cfa_tcam_mgr_free_parms mgr_parms;\n+\n+\tif (parms->type >= TF_TCAM_TBL_TYPE_MAX) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"No such TCAM table %d.\\n\",\n+\t\t\t    parms->type);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tcontext.tfp = tfp;\n+\tmgr_parms.dir\t     = parms->dir;\n+\tmgr_parms.type\t     = tcam_types[parms->type];\n+\tmgr_parms.hcapi_type = hcapi_type[parms->type];\n+\tmgr_parms.id\t     = parms->idx;\n+\n+\treturn cfa_tcam_mgr_free(&context, &mgr_parms);\n+}\n+\n+int\n+tf_tcam_mgr_set_msg(struct tf *tfp,\n+\t\t    struct tf_dev_info *dev __rte_unused,\n+\t\t    struct tf_tcam_set_parms *parms)\n+{\n+\tstruct cfa_tcam_mgr_context context;\n+\tstruct cfa_tcam_mgr_set_parms mgr_parms;\n+\n+\tif (parms->type >= TF_TCAM_TBL_TYPE_MAX) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"No such TCAM table %d.\\n\",\n+\t\t\t    parms->type);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tcontext.tfp = tfp;\n+\tmgr_parms.dir\t      = parms->dir;\n+\tmgr_parms.type\t      = tcam_types[parms->type];\n+\tmgr_parms.hcapi_type  = hcapi_type[parms->type];\n+\tmgr_parms.id\t      = parms->idx;\n+\tmgr_parms.key\t      = parms->key;\n+\tmgr_parms.mask\t      = parms->mask;\n+\tmgr_parms.key_size    = parms->key_size;\n+\tmgr_parms.result      = parms->result;\n+\tmgr_parms.result_size = parms->result_size;\n+\n+\treturn cfa_tcam_mgr_set(&context, &mgr_parms);\n+}\n+\n+int\n+tf_tcam_mgr_get_msg(struct tf *tfp,\n+\t\t    struct tf_dev_info *dev __rte_unused,\n+\t\t    struct tf_tcam_get_parms *parms)\n+{\n+\tint rc;\n+\tstruct cfa_tcam_mgr_context context;\n+\tstruct cfa_tcam_mgr_get_parms mgr_parms;\n+\n+\tif (parms->type >= TF_TCAM_TBL_TYPE_MAX) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"No such TCAM table %d.\\n\",\n+\t\t\t    parms->type);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tcontext.tfp = tfp;\n+\tmgr_parms.dir\t      = parms->dir;\n+\tmgr_parms.type\t      = tcam_types[parms->type];\n+\tmgr_parms.hcapi_type  = hcapi_type[parms->type];\n+\tmgr_parms.id\t      = parms->idx;\n+\tmgr_parms.key\t      = parms->key;\n+\tmgr_parms.mask\t      = parms->mask;\n+\tmgr_parms.key_size    = parms->key_size;\n+\tmgr_parms.result      = parms->result;\n+\tmgr_parms.result_size = parms->result_size;\n+\n+\trc = cfa_tcam_mgr_get(&context, &mgr_parms);\n+\tif (rc)\n+\t\treturn rc;\n+\n+\tparms->key_size\t   = mgr_parms.key_size;\n+\tparms->result_size = mgr_parms.result_size;\n+\n+\treturn rc;\n+}\n+\n+int\n+tf_tcam_mgr_shared_clear_msg(struct tf *tfp,\n+\t\t     struct tf_clear_tcam_shared_entries_parms *parms)\n+{\n+\tstruct cfa_tcam_mgr_context context;\n+\tstruct cfa_tcam_mgr_shared_clear_parms mgr_parms;\n+\n+\tcontext.tfp = tfp;\n+\tmgr_parms.dir = parms->dir;\n+\tmgr_parms.type = tcam_types[parms->tcam_tbl_type];\n+\n+\treturn cfa_tcam_mgr_shared_clear(&context, &mgr_parms);\n+}\n+\n+int\n+tf_tcam_mgr_shared_move_msg(struct tf *tfp,\n+\t\t     struct tf_move_tcam_shared_entries_parms *parms)\n+{\n+\tstruct cfa_tcam_mgr_context context;\n+\tstruct cfa_tcam_mgr_shared_move_parms mgr_parms;\n+\n+\tcontext.tfp = tfp;\n+\tmgr_parms.dir = parms->dir;\n+\tmgr_parms.type = tcam_types[parms->tcam_tbl_type];\n+\n+\treturn cfa_tcam_mgr_shared_move(&context, &mgr_parms);\n+}\ndiff --git a/drivers/net/bnxt/tf_core/tf_tcam_mgr_msg.h b/drivers/net/bnxt/tf_core/tf_tcam_mgr_msg.h\nnew file mode 100644\nindex 0000000000..8a8d136f5e\n--- /dev/null\n+++ b/drivers/net/bnxt/tf_core/tf_tcam_mgr_msg.h\n@@ -0,0 +1,49 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2021-2023 Broadcom\n+ * All rights reserved.\n+ */\n+\n+#ifndef _TF_TCAM_MGR_MSG_H_\n+#define _TF_TCAM_MGR_MSG_H_\n+\n+#include \"tf_tcam.h\"\n+#include \"tf_rm.h\"\n+\n+int\n+tf_tcam_mgr_qcaps_msg(struct tf *tfp,\n+\t\t      struct tf_dev_info *dev __rte_unused,\n+\t\t      uint32_t *rx_tcam_supported,\n+\t\t      uint32_t *tx_tcam_supported);\n+\n+int\n+tf_tcam_mgr_bind_msg(struct tf *tfp,\n+\t\t     struct tf_dev_info *dev,\n+\t\t     struct tf_tcam_cfg_parms *parms,\n+\t\t     struct tf_resource_info resv_res[][TF_TCAM_TBL_TYPE_MAX]);\n+int\n+tf_tcam_mgr_unbind_msg(struct tf *tfp,\n+\t\t       struct tf_dev_info *dev);\n+int\n+tf_tcam_mgr_alloc_msg(struct tf *tfp,\n+\t\t      struct tf_dev_info *dev,\n+\t\t      struct tf_tcam_alloc_parms *parms);\n+int\n+tf_tcam_mgr_free_msg(struct tf *tfp,\n+\t\t     struct tf_dev_info *dev,\n+\t\t     struct tf_tcam_free_parms *parms);\n+int\n+tf_tcam_mgr_set_msg(struct tf *tfp,\n+\t\t    struct tf_dev_info *dev,\n+\t\t    struct tf_tcam_set_parms *parms);\n+int\n+tf_tcam_mgr_get_msg(struct tf *tfp,\n+\t\t    struct tf_dev_info *dev,\n+\t\t    struct tf_tcam_get_parms *parms);\n+int\n+tf_tcam_mgr_shared_clear_msg(struct tf *tfp,\n+\t\t     struct tf_clear_tcam_shared_entries_parms *parms);\n+\n+int\n+tf_tcam_mgr_shared_move_msg(struct tf *tfp,\n+\t\t     struct tf_move_tcam_shared_entries_parms *parms);\n+#endif /* _TF_TCAM_MGR_MSG_H_ */\ndiff --git a/drivers/net/bnxt/tf_core/tf_tcam_shared.c b/drivers/net/bnxt/tf_core/tf_tcam_shared.c\nindex c120c6f577..e853f616f9 100644\n--- a/drivers/net/bnxt/tf_core/tf_tcam_shared.c\n+++ b/drivers/net/bnxt/tf_core/tf_tcam_shared.c\n@@ -1,11 +1,13 @@\n /* SPDX-License-Identifier: BSD-3-Clause\n- * Copyright(c) 2019-2021 Broadcom\n+ * Copyright(c) 2019-2023 Broadcom\n  * All rights reserved.\n  */\n \n #include <string.h>\n #include <rte_common.h>\n \n+#include \"tf_core.h\"\n+\n #include \"tf_tcam_shared.h\"\n #include \"tf_tcam.h\"\n #include \"tf_common.h\"\n@@ -16,229 +18,8 @@\n #include \"tf_session.h\"\n #include \"tf_msg.h\"\n #include \"bitalloc.h\"\n-#include \"tf_core.h\"\n-\n-/** Shared WC TCAM pool identifiers\n- */\n-enum tf_tcam_shared_wc_pool_id {\n-\tTF_TCAM_SHARED_WC_POOL_HI  = 0,\n-\tTF_TCAM_SHARED_WC_POOL_LO  = 1,\n-\tTF_TCAM_SHARED_WC_POOL_MAX = 2\n-};\n-\n-/** Get string representation of a WC TCAM shared pool id\n- */\n-static const char *\n-tf_pool_2_str(enum tf_tcam_shared_wc_pool_id id)\n-{\n-\tswitch (id) {\n-\tcase TF_TCAM_SHARED_WC_POOL_HI:\n-\t\treturn \"TCAM_SHARED_WC_POOL_HI\";\n-\tcase TF_TCAM_SHARED_WC_POOL_LO:\n-\t\treturn \"TCAM_SHARED_WC_POOL_LO\";\n-\tdefault:\n-\t\treturn \"Invalid TCAM_SHARED_WC_POOL\";\n-\t}\n-}\n-\n-/** The WC TCAM shared pool datastructure\n- */\n-struct tf_tcam_shared_wc_pool {\n-\t/** Start and stride data */\n-\tstruct tf_resource_info info;\n-\t/** bitalloc 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- */\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-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      struct tf_tcam_shared_wc_pools *tcam_shared_wc)\n-{\n-\tint rc = 0;\n-\tbool free = true;\n-\tstruct tfp_calloc_parms cparms;\n-\tuint32_t pool_size;\n-\n-\t/* Create pool */\n-\tpool_size = (BITALLOC_SIZEOF(stride) / sizeof(struct bitalloc));\n-\tcparms.nitems = pool_size;\n-\tcparms.alignment = 0;\n-\tcparms.size = sizeof(struct bitalloc);\n-\trc = tfp_calloc(&cparms);\n-\tif (rc) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s: pool memory alloc failed %s:%s\\n\",\n-\t\t\t    tf_dir_2_str(dir), tf_pool_2_str(id),\n-\t\t\t    strerror(-rc));\n-\t\treturn rc;\n-\t}\n-\ttcam_shared_wc->db[dir][id].pool = (struct bitalloc *)cparms.mem_va;\n-\n-\trc = ba_init(tcam_shared_wc->db[dir][id].pool,\n-\t\t     stride,\n-\t\t     free);\n-\n-\tif (rc) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s: pool bitalloc failed %s\\n\",\n-\t\t\t    tf_dir_2_str(dir), tf_pool_2_str(id));\n-\t\treturn rc;\n-\t}\n-\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 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    struct tf_tcam_shared_wc_pools *tcam_shared_wc)\n-{\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->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- */\n-static int\n-tf_tcam_shared_get_slices(struct tf *tfp,\n-\t\t\t  struct tf_dev_info *dev,\n-\t\t\t  uint16_t *num_slices)\n-{\n-\tint rc;\n-\n-\tif (dev->ops->tf_dev_get_tcam_slice_info == NULL) {\n-\t\trc = -EOPNOTSUPP;\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"Operation not supported, rc:%s\\n\", strerror(-rc));\n-\t\treturn rc;\n-\t}\n-\trc = dev->ops->tf_dev_get_tcam_slice_info(tfp,\n-\t\t\t\t\t\t  TF_TCAM_TBL_TYPE_WC_TCAM,\n-\t\t\t\t\t\t  0,\n-\t\t\t\t\t\t  num_slices);\n-\treturn rc;\n-}\n-\n-static bool\n-tf_tcam_db_valid(struct tf *tfp,\n-\t\t\tenum tf_dir dir)\n-{\n-\tstruct tcam_rm_db *tcam_db;\n-\tvoid *tcam_db_ptr = NULL;\n-\tint rc;\n-\n-\tTF_CHECK_PARMS1(tfp);\n-\n-\trc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);\n-\tif (rc)\n-\t\treturn false;\n-\n-\ttcam_db = (struct tcam_rm_db *)tcam_db_ptr;\n-\n-\tif (tcam_db->tcam_db[dir])\n-\t\treturn true;\n-\n-\treturn false;\n-}\n-\n-static int\n-tf_tcam_shared_get_rm_info(struct tf *tfp,\n-\t\t\t   enum tf_dir dir,\n-\t\t\t   uint16_t *hcapi_type,\n-\t\t\t   struct tf_rm_alloc_info *info)\n-{\n-\tint rc;\n-\tstruct tcam_rm_db *tcam_db;\n-\tvoid *tcam_db_ptr = NULL;\n-\tstruct tf_rm_get_alloc_info_parms ainfo;\n-\tstruct tf_rm_get_hcapi_parms hparms;\n-\n-\tTF_CHECK_PARMS3(tfp, hcapi_type, info);\n-\n-\trc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);\n-\tif (rc) {\n-\t\tTFP_DRV_LOG(INFO,\n-\t\t\t    \"Tcam_db is not initialized, rc:%s\\n\",\n-\t\t\t    strerror(-rc));\n-\t\treturn 0;\n-\t}\n-\ttcam_db = (struct tcam_rm_db *)tcam_db_ptr;\n-\n-\t/* Convert TF type to HCAPI RM type */\n-\tmemset(&hparms, 0, sizeof(hparms));\n-\thparms.rm_db = tcam_db->tcam_db[dir];\n-\thparms.subtype = TF_TCAM_TBL_TYPE_WC_TCAM;\n-\thparms.hcapi_type = hcapi_type;\n-\n-\trc = tf_rm_get_hcapi_type(&hparms);\n-\tif (rc) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s: Get RM hcapi type failed %s\\n\",\n-\t\t\t    tf_dir_2_str(dir),\n-\t\t\t    strerror(-rc));\n-\t\treturn rc;\n-\t}\n-\n-\tmemset(info, 0, sizeof(struct tf_rm_alloc_info));\n-\tainfo.rm_db = tcam_db->tcam_db[dir];\n-\tainfo.subtype = TF_TCAM_TBL_TYPE_WC_TCAM;\n-\tainfo.info = info;\n-\n-\trc = tf_rm_get_info(&ainfo);\n-\tif (rc) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s: TCAM rm info get failed %s\\n\",\n-\t\t\t    tf_dir_2_str(dir),\n-\t\t\t    strerror(-rc));\n-\t\treturn rc;\n-\t}\n-\treturn rc;\n-}\n+#include \"tf_rm.h\"\n+#include \"tf_tcam_mgr_msg.h\"\n \n /**\n  * tf_tcam_shared_bind\n@@ -247,92 +28,15 @@ int\n tf_tcam_shared_bind(struct tf *tfp,\n \t\t    struct tf_tcam_cfg_parms *parms)\n {\n-\tint rc, dir;\n-\tstruct tf_session *tfs;\n-\tstruct tf_dev_info *dev;\n-\tstruct tf_rm_alloc_info info;\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+\tint rc;\n \n \tTF_CHECK_PARMS2(tfp, parms);\n \n \t/* Perform normal bind\n \t */\n \trc = tf_tcam_bind(tfp, parms);\n-\tif (rc)\n-\t\treturn rc;\n-\n-\t/* After the normal TCAM bind, if this is a shared session\n-\t * create all required databases for the WC_HI and WC_LO pools\n-\t */\n-\trc = tf_session_get_session_internal(tfp, &tfs);\n-\tif (rc) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"Session access failure: %s\\n\", strerror(-rc));\n-\t\treturn rc;\n-\t}\n-\tif (tf_session_is_shared_session(tfs)) {\n-\t\t/* Retrieve the device information */\n-\t\trc = tf_session_get_device(tfs, &dev);\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_db_valid(tfp, dir))\n-\t\t\t\tcontinue;\n-\n-\t\t\trc = tf_tcam_shared_get_rm_info(tfp,\n-\t\t\t\t\t\t\tdir,\n-\t\t\t\t\t\t\t&hcapi_type,\n-\t\t\t\t\t\t\t&info);\n-\t\t\tif (rc) {\n-\t\t\t\tTFP_DRV_LOG(ERR,\n-\t\t\t\t\t    \"%s: TCAM rm info get failed\\n\",\n-\t\t\t\t\t    tf_dir_2_str(dir));\n-\t\t\t\tgoto done;\n-\t\t\t}\n-\n-\t\t\tstart = info.entry.start;\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\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\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-\n-\t\trc = tf_tcam_shared_get_slices(tfp,\n-\t\t\t\t\t       dev,\n-\t\t\t\t\t       &num_slices);\n-\t\tif (rc)\n-\t\t\treturn rc;\n-\n-\t\tif (num_slices > 1) {\n-\t\t\tTFP_DRV_LOG(ERR,\n-\t\t\t\t    \"Only single slice supported\\n\");\n-\t\t\treturn -EOPNOTSUPP;\n-\t\t}\n-\t}\n-done:\n \treturn rc;\n+\n }\n /**\n  * tf_tcam_shared_unbind\n@@ -340,132 +44,10 @@ tf_tcam_shared_bind(struct tf *tfp,\n int\n tf_tcam_shared_unbind(struct tf *tfp)\n {\n-\tint rc, dir;\n-\tstruct tf_dev_info *dev;\n-\tstruct tf_session *tfs;\n-\tvoid *tcam_shared_db_ptr = NULL;\n-\tstruct tf_tcam_shared_wc_pools *tcam_shared_wc;\n-\tenum tf_tcam_shared_wc_pool_id pool_id;\n-\tstruct tf_tcam_free_parms parms;\n-\tstruct bitalloc *pool;\n-\tuint16_t start;\n-\tint log_idx, phy_idx;\n-\tuint16_t hcapi_type;\n-\tstruct tf_rm_alloc_info info;\n-\tint i, pool_cnt;\n+\tint rc;\n \n \tTF_CHECK_PARMS1(tfp);\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 not the shared session, call the normal\n-\t * tcam unbind and exit\n-\t */\n-\tif (!tf_session_is_shared_session(tfs)) {\n-\t\trc = tf_tcam_unbind(tfp);\n-\t\treturn rc;\n-\t}\n-\n-\t/* We must be a shared session, get the database\n-\t */\n-\trc = tf_session_get_tcam_shared_db(tfp,\n-\t\t\t\t\t   (void *)&tcam_shared_db_ptr);\n-\tif (rc) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"Failed to get tcam_shared_db, rc:%s\\n\",\n-\t\t\t    strerror(-rc));\n-\t\treturn rc;\n-\t}\n-\n-\ttcam_shared_wc =\n-\t\t(struct tf_tcam_shared_wc_pools *)tcam_shared_db_ptr;\n-\n-\n-\t/* Get the device\n-\t */\n-\trc = tf_session_get_device(tfs, &dev);\n-\tif (rc)\n-\t\treturn rc;\n-\n-\n-\t/* If there are WC TCAM entries allocated, free them\n-\t */\n-\tfor (dir = 0; dir < TF_DIR_MAX; dir++) {\n-\t\t/* If the database is invalid, skip\n-\t\t */\n-\t\tif (!tf_tcam_db_valid(tfp, dir))\n-\t\t\tcontinue;\n-\n-\t\trc = tf_tcam_shared_get_rm_info(tfp,\n-\t\t\t\t\t\tdir,\n-\t\t\t\t\t\t&hcapi_type,\n-\t\t\t\t\t\t&info);\n-\t\tif (rc) {\n-\t\t\tTFP_DRV_LOG(ERR,\n-\t\t\t\t    \"%s: TCAM shared rm info get failed\\n\",\n-\t\t\t\t    tf_dir_2_str(dir));\n-\t\t\treturn rc;\n-\t\t}\n-\n-\t\tfor (pool_id = TF_TCAM_SHARED_WC_POOL_HI;\n-\t\t     pool_id < TF_TCAM_SHARED_WC_POOL_MAX;\n-\t\t     pool_id++) {\n-\t\t\tpool = tcam_shared_wc->db[dir][pool_id].pool;\n-\t\t\tstart = tcam_shared_wc->db[dir][pool_id].info.start;\n-\t\t\tpool_cnt = ba_inuse_count(pool);\n-\n-\t\t\tif (pool_cnt) {\n-\t\t\t\tTFP_DRV_LOG(INFO,\n-\t\t\t\t\t    \"%s: %s: %d residuals found, freeing\\n\",\n-\t\t\t\t\t    tf_dir_2_str(dir),\n-\t\t\t\t\t    tf_pool_2_str(pool_id),\n-\t\t\t\t\t    pool_cnt);\n-\t\t\t}\n-\n-\t\t\tlog_idx = 0;\n-\n-\t\t\tfor (i = 0; i < pool_cnt; i++) {\n-\t\t\t\tlog_idx = ba_find_next_inuse(pool, log_idx);\n-\n-\t\t\t\tif (log_idx < 0) {\n-\t\t\t\t\tTFP_DRV_LOG(ERR,\n-\t\t\t\t\t\t    \"Expected a found %s entry %d\\n\",\n-\t\t\t\t\t\t    tf_pool_2_str(pool_id),\n-\t\t\t\t\t\t    i);\n-\t\t\t\t\t/* attempt normal unbind\n-\t\t\t\t\t */\n-\t\t\t\t\tgoto done;\n-\t\t\t\t}\n-\t\t\t\tphy_idx = start + log_idx;\n-\n-\t\t\t\tparms.type = TF_TCAM_TBL_TYPE_WC_TCAM;\n-\t\t\t\tparms.hcapi_type = hcapi_type;\n-\t\t\t\tparms.idx = phy_idx;\n-\t\t\t\tparms.dir = dir;\n-\t\t\t\trc = tf_msg_tcam_entry_free(tfp, dev, &parms);\n-\t\t\t\tif (rc) {\n-\t\t\t\t\t/* Log error */\n-\t\t\t\t\tTFP_DRV_LOG(ERR,\n-\t\t\t\t\t\t    \"%s: %s: %d free failed, rc:%s\\n\",\n-\t\t\t\t\t\t    tf_dir_2_str(parms.dir),\n-\t\t\t\t\t\t    tf_tcam_tbl_2_str(parms.type),\n-\t\t\t\t\t\t    phy_idx,\n-\t\t\t\t\t\t    strerror(-rc));\n-\t\t\t\t\treturn rc;\n-\t\t\t\t}\n-\t\t\t}\n-\t\t\t/* Free the pool once all the entries\n-\t\t\t * have been cleared\n-\t\t\t */\n-\t\t\ttf_tcam_shared_free_wc_pool(dir,\n-\t\t\t\t\t\t    pool_id,\n-\t\t\t\t\t\t    tcam_shared_wc);\n-\t\t}\n-\t}\n-done:\n \trc = tf_tcam_unbind(tfp);\n \treturn rc;\n }\n@@ -478,79 +60,11 @@ tf_tcam_shared_alloc(struct tf *tfp,\n \t\t     struct tf_tcam_alloc_parms *parms)\n {\n \tint rc;\n-\tstruct tf_session *tfs;\n-\tstruct tf_dev_info *dev;\n-\tint log_idx;\n-\tstruct bitalloc *pool;\n-\tenum tf_tcam_shared_wc_pool_id id;\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 the type is\n-\t * not one of the special WC TCAM types, call the normal\n-\t * allocation.\n-\t */\n-\tif (!tf_session_is_shared_session(tfs) ||\n-\t    (parms->type != TF_TCAM_TBL_TYPE_WC_TCAM_HIGH &&\n-\t     parms->type != TF_TCAM_TBL_TYPE_WC_TCAM_LOW)) {\n-\t\t/* Perform normal alloc\n-\t\t */\n-\t\trc = tf_tcam_alloc(tfp, parms);\n-\t\treturn rc;\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-\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-\t\tid = TF_TCAM_SHARED_WC_POOL_LO;\n-\n-\t/* Retrieve the device information */\n-\trc = tf_session_get_device(tfs, &dev);\n-\tif (rc)\n-\t\treturn rc;\n-\n-\tpool = tcam_shared_wc->db[parms->dir][id].pool;\n-\n-\t/*\n-\t * priority  0: allocate from top of the tcam i.e. high\n-\t * priority !0: allocate index from bottom i.e lowest\n-\t */\n-\tif (parms->priority)\n-\t\tlog_idx = ba_alloc_reverse(pool);\n-\telse\n-\t\tlog_idx = ba_alloc(pool);\n-\tif (log_idx == BA_FAIL) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s: Allocation failed, rc:%s\\n\",\n-\t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t    strerror(ENOMEM));\n-\t\treturn -ENOMEM;\n-\t}\n-\tparms->idx = log_idx;\n-\treturn 0;\n+\trc = tf_tcam_alloc(tfp, parms);\n+\treturn rc;\n }\n \n int\n@@ -558,118 +72,11 @@ tf_tcam_shared_free(struct tf *tfp,\n \t\t    struct tf_tcam_free_parms *parms)\n {\n \tint rc;\n-\tstruct tf_session *tfs;\n-\tstruct tf_dev_info *dev;\n-\tint allocated = 0;\n-\tuint16_t start;\n-\tint phy_idx;\n-\tstruct bitalloc *pool;\n-\tenum tf_tcam_shared_wc_pool_id id;\n-\tstruct tf_tcam_free_parms nparms;\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-\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 the type is\n-\t * not one of the special WC TCAM types, call the normal\n-\t * allocation.\n-\t */\n-\tif (!tf_session_is_shared_session(tfs) ||\n-\t    (parms->type != TF_TCAM_TBL_TYPE_WC_TCAM_HIGH &&\n-\t     parms->type != TF_TCAM_TBL_TYPE_WC_TCAM_LOW)) {\n-\t\t/* Perform normal free\n-\t\t */\n-\t\trc = tf_tcam_free(tfp, parms);\n-\t\treturn rc;\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-\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-\t\tid = TF_TCAM_SHARED_WC_POOL_LO;\n-\n-\t/* Retrieve the device information */\n-\trc = tf_session_get_device(tfs, &dev);\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-\tpool = tcam_shared_wc->db[parms->dir][id].pool;\n-\tstart = tcam_shared_wc->db[parms->dir][id].info.start;\n-\n-\tphy_idx = parms->idx + start;\n-\tallocated = ba_inuse(pool, parms->idx);\n-\n-\tif (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s: Entry already free, type:%d, idx:%d\\n\",\n-\t\t\t    tf_dir_2_str(parms->dir), parms->type, parms->idx);\n-\t\treturn -EINVAL;\n-\t}\n-\n-\trc = ba_free(pool, parms->idx);\n-\tif (rc) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s: Free failed, type:%s, idx:%d\\n\",\n-\t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t    tf_tcam_tbl_2_str(parms->type),\n-\t\t\t    parms->idx);\n-\t\treturn rc;\n-\t}\n-\n-\t/* Override HI/LO type with parent WC TCAM type */\n-\tnparms = *parms;\n-\tnparms.type = TF_TCAM_TBL_TYPE_WC_TCAM;\n-\tnparms.hcapi_type = hcapi_type;\n-\tnparms.idx = phy_idx;\n-\n-\trc = tf_msg_tcam_entry_free(tfp, dev, &nparms);\n-\tif (rc) {\n-\t\t/* Log error */\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s: %s: log%d free failed, rc:%s\\n\",\n-\t\t\t    tf_dir_2_str(nparms.dir),\n-\t\t\t    tf_tcam_tbl_2_str(nparms.type),\n-\t\t\t    phy_idx,\n-\t\t\t    strerror(-rc));\n-\t\treturn rc;\n-\t}\n-\treturn 0;\n+\trc = tf_tcam_free(tfp, parms);\n+\treturn rc;\n }\n \n int\n@@ -677,109 +84,11 @@ tf_tcam_shared_set(struct tf *tfp __rte_unused,\n \t\t   struct tf_tcam_set_parms *parms __rte_unused)\n {\n \tint rc;\n-\tstruct tf_session *tfs;\n-\tstruct tf_dev_info *dev;\n-\tint allocated = 0;\n-\tint phy_idx, log_idx;\n-\tstruct tf_tcam_set_parms nparms;\n-\tstruct bitalloc *pool;\n-\tuint16_t start;\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-\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->type != TF_TCAM_TBL_TYPE_WC_TCAM_HIGH &&\n-\t     parms->type != TF_TCAM_TBL_TYPE_WC_TCAM_LOW)) {\n-\t\t/* Perform normal set and exit\n-\t\t */\n-\t\trc = tf_tcam_set(tfp, parms);\n-\t\treturn rc;\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\treturn rc;\n-\n-\tif (parms->type == TF_TCAM_TBL_TYPE_WC_TCAM_HIGH)\n-\t\tid = TF_TCAM_SHARED_WC_POOL_HI;\n-\telse\n-\t\tid = TF_TCAM_SHARED_WC_POOL_LO;\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-\tlog_idx = parms->idx;\n-\tphy_idx = parms->idx + start;\n-\tallocated = ba_inuse(pool, parms->idx);\n-\n-\tif (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s: Entry is not allocated, type:%d, logid:%d\\n\",\n-\t\t\t    tf_dir_2_str(parms->dir), parms->type, log_idx);\n-\t\treturn -EINVAL;\n-\t}\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\treturn rc;\n-\n-\t/* Override HI/LO type with parent WC TCAM type */\n-\tnparms.hcapi_type = hcapi_type;\n-\tnparms.dir = parms->dir;\n-\tnparms.type = TF_TCAM_TBL_TYPE_WC_TCAM;\n-\tnparms.idx = phy_idx;\n-\tnparms.key = parms->key;\n-\tnparms.mask = parms->mask;\n-\tnparms.key_size = parms->key_size;\n-\tnparms.result = parms->result;\n-\tnparms.result_size = parms->result_size;\n-\n-\trc = tf_msg_tcam_entry_set(tfp, dev, &nparms);\n-\tif (rc) {\n-\t\t/* Log error */\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s: %s: phy entry %d set failed, rc:%s\",\n-\t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t    tf_tcam_tbl_2_str(nparms.type),\n-\t\t\t    phy_idx,\n-\t\t\t    strerror(-rc));\n-\t\treturn rc;\n-\t}\n-\treturn 0;\n+\trc = tf_tcam_set(tfp, parms);\n+\treturn rc;\n }\n \n int\n@@ -787,226 +96,10 @@ tf_tcam_shared_get(struct tf *tfp __rte_unused,\n \t\t   struct tf_tcam_get_parms *parms)\n {\n \tint rc;\n-\tstruct tf_session *tfs;\n-\tstruct tf_dev_info *dev;\n-\tint allocated = 0;\n-\tint phy_idx, log_idx;\n-\tstruct tf_tcam_get_parms nparms;\n-\tstruct bitalloc *pool;\n-\tuint16_t start;\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-\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->type != TF_TCAM_TBL_TYPE_WC_TCAM_HIGH &&\n-\t     parms->type != TF_TCAM_TBL_TYPE_WC_TCAM_LOW)) {\n-\t\t/* Perform normal get and exit\n-\t\t */\n-\t\trc = tf_tcam_get(tfp, parms);\n-\t\treturn rc;\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\treturn rc;\n-\tif (parms->type == TF_TCAM_TBL_TYPE_WC_TCAM_HIGH)\n-\t\tid = TF_TCAM_SHARED_WC_POOL_HI;\n-\telse\n-\t\tid = TF_TCAM_SHARED_WC_POOL_LO;\n-\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-\tlog_idx = parms->idx;\n-\tphy_idx = parms->idx + start;\n-\tallocated = ba_inuse(pool, parms->idx);\n-\n-\tif (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s: Entry is not allocated, type:%d, logid:%d\\n\",\n-\t\t\t    tf_dir_2_str(parms->dir), parms->type, log_idx);\n-\t\treturn -EINVAL;\n-\t}\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\treturn rc;\n-\n-\t/* Override HI/LO type with parent WC TCAM type */\n-\tnparms = *parms;\n-\tnparms.type = TF_TCAM_TBL_TYPE_WC_TCAM;\n-\tnparms.hcapi_type = hcapi_type;\n-\tnparms.idx = phy_idx;\n-\n-\trc = tf_msg_tcam_entry_get(tfp, dev, &nparms);\n-\tif (rc) {\n-\t\t/* Log error */\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s: %s: Entry %d set failed, rc:%s\",\n-\t\t\t    tf_dir_2_str(nparms.dir),\n-\t\t\t    tf_tcam_tbl_2_str(nparms.type),\n-\t\t\t    nparms.idx,\n-\t\t\t    strerror(-rc));\n-\t\treturn rc;\n-\t}\n-\treturn 0;\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-#define TF_TCAM_SHARED_KEY_SLICE_SZ_BYTES_P58 24\n-#define TF_TCAM_SHARED_REMAP_SZ_BYTES_P58 8\n-\n-/* Temporary builder defines pulled in here and adjusted\n- * for max WC TCAM values\n- */\n-union tf_tmp_field_obj {\n-\tuint32_t words[(TF_TCAM_SHARED_REMAP_SZ_BYTES_P58 + 3) / 4];\n-\tuint8_t bytes[TF_TCAM_SHARED_REMAP_SZ_BYTES_P58];\n-};\n-\n-union tf_tmp_key {\n-\tuint32_t words[(TF_TCAM_SHARED_KEY_SLICE_SZ_BYTES_P58 + 3) / 4];\n-\tuint8_t bytes[TF_TCAM_SHARED_KEY_SLICE_SZ_BYTES_P58];\n-};\n-\n-/** p58 has an enable bit, p4 does not\n- */\n-#define TF_TCAM_SHARED_ENTRY_ENABLE 0x8\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  bool set_enable_bit)\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-\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: %s: phyid(%d) get failed, rc:%s\\n\",\n-\t\t\t    tf_tcam_tbl_2_str(gparms.type),\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-\tif (set_enable_bit)\n-\t\ttcam_key_obj.bytes[0] |= TF_TCAM_SHARED_ENTRY_ENABLE;\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 = key_sz_bytes;\n-\tsparms.result = gparms.result;\n-\tsparms.result_size = remap_sz_bytes;\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: %s phyid(%d/0x%x) set failed, rc:%s\\n\",\n-\t\t\t    tf_tcam_tbl_2_str(sparms.type),\n-\t\t\t    tf_dir_2_str(dir),\n-\t\t\t    sparms.idx,\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/0x%x) 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    sphy_idx,\n-\t\t\t    strerror(-rc));\n-\t\treturn rc;\n-\t}\n+\trc = tf_tcam_get(tfp, parms);\n \treturn rc;\n }\n \n@@ -1015,23 +108,10 @@ tf_tcam_shared_move_entry(struct tf *tfp,\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-\t\t\tbool set_enable_bit)\n+\t\t\tstruct tf_move_tcam_shared_entries_parms *parms)\n {\n-\tint rc;\n \tstruct tf_session *tfs;\n-\tstruct tf_dev_info *dev;\n-\tint log_idx;\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;\n-\tstruct tf_tcam_shared_wc_pools *tcam_shared_wc;\n-\tvoid *tcam_shared_db_ptr = NULL;\n+\tint rc;\n \n \tTF_CHECK_PARMS2(tfp, parms);\n \n@@ -1052,104 +132,7 @@ int tf_tcam_shared_move(struct tf *tfp,\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-\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-\tlog_idx = 0;\n-\n-\tfor (i = 0; i < hi_cnt; i++) {\n-\t\t/* Find next free index starting from where we left off\n-\t\t */\n-\t\tlog_idx = ba_find_next_inuse(hi_pool, log_idx);\n-\t\tif (log_idx < 0) {\n-\t\t\tTFP_DRV_LOG(ERR,\n-\t\t\t\t    \"Expected a found %s entry %d\\n\",\n-\t\t\t\t    tf_pool_2_str(hi_id),\n-\t\t\t\t    i);\n-\t\t\tgoto done;\n-\t\t}\n-\t\t/* The user should have never allocated from the low\n-\t\t * pool because the move only happens when switching\n-\t\t * from the high to the low pool\n-\t\t */\n-\t\tif (ba_alloc_index(lo_pool, log_idx) < 0) {\n-\t\t\tTFP_DRV_LOG(ERR,\n-\t\t\t\t    \"Warning %s index %d already allocated\\n\",\n-\t\t\t\t    tf_pool_2_str(lo_id),\n-\t\t\t\t    i);\n-\n-\t\t\t/* Since already allocated, continue with move\n-\t\t\t */\n-\t\t}\n-\n-\t\trc = tf_tcam_shared_move_entry(tfp, dev,\n-\t\t\t\t\t       hcapi_type,\n-\t\t\t\t\t       parms->dir,\n-\t\t\t\t\t       hi_start + log_idx,\n-\t\t\t\t\t       lo_start + log_idx,\n-\t\t\t\t\t       key_sz_bytes,\n-\t\t\t\t\t       remap_sz_bytes,\n-\t\t\t\t\t       set_enable_bit);\n-\t\tif (rc) {\n-\t\t\tTFP_DRV_LOG(ERR,\n-\t\t\t\t    \"%s: Move error %s to %s index %d\\n\",\n-\t\t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t\t    tf_pool_2_str(hi_id),\n-\t\t\t\t    tf_pool_2_str(lo_id),\n-\t\t\t\t    i);\n-\t\t\tgoto done;\n-\t\t}\n-\t\tba_free(hi_pool, log_idx);\n-\t}\n-done:\n+\trc = tf_tcam_mgr_shared_move_msg(tfp, parms);\n \treturn rc;\n }\n \n@@ -1159,24 +142,17 @@ tf_tcam_shared_move_p4(struct tf *tfp,\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-\t\t\t\t false); /* no enable bit */\n+\t\t\t\t parms);\n \treturn rc;\n }\n \n-\n int\n tf_tcam_shared_move_p58(struct tf *tfp,\n \t\t\tstruct 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-\t\t\t\t true); /* set enable bit */\n+\t\t\t\t parms);\n \treturn rc;\n }\n \n@@ -1186,16 +162,6 @@ tf_tcam_shared_clear(struct tf *tfp,\n {\n \tint rc = 0;\n \tstruct tf_session *tfs;\n-\tstruct tf_dev_info *dev;\n-\tuint16_t start;\n-\tint phy_idx;\n-\tenum tf_tcam_shared_wc_pool_id id;\n-\tstruct tf_tcam_free_parms nparms;\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-\tint i, cnt;\n \n \tTF_CHECK_PARMS2(tfp, parms);\n \n@@ -1209,74 +175,6 @@ tf_tcam_shared_clear(struct tf *tfp,\n \t     parms->tcam_tbl_type != TF_TCAM_TBL_TYPE_WC_TCAM_LOW))\n \t\treturn -EOPNOTSUPP;\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-\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->tcam_tbl_type == TF_TCAM_TBL_TYPE_WC_TCAM_HIGH)\n-\t\tid = TF_TCAM_SHARED_WC_POOL_HI;\n-\telse\n-\t\tid = TF_TCAM_SHARED_WC_POOL_LO;\n-\n-\n-\t/* Retrieve the device information */\n-\trc = tf_session_get_device(tfs, &dev);\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-\tstart = tcam_shared_wc->db[parms->dir][id].info.start;\n-\tcnt = tcam_shared_wc->db[parms->dir][id].info.stride;\n-\n-\t/* Override HI/LO type with parent WC TCAM type */\n-\tnparms.dir = parms->dir;\n-\tnparms.type = TF_TCAM_TBL_TYPE_WC_TCAM;\n-\tnparms.hcapi_type = hcapi_type;\n-\n-\tfor (i = 0; i < cnt; i++) {\n-\t\tphy_idx = start + i;\n-\t\tnparms.idx = phy_idx;\n-\n-\t\t/* Clear entry */\n-\t\trc = tf_msg_tcam_entry_free(tfp, dev, &nparms);\n-\t\tif (rc) {\n-\t\t\t/* Log error */\n-\t\t\tTFP_DRV_LOG(ERR,\n-\t\t\t\t    \"%s: %s: log%d free failed, rc:%s\\n\",\n-\t\t\t\t    tf_dir_2_str(nparms.dir),\n-\t\t\t\t    tf_tcam_tbl_2_str(nparms.type),\n-\t\t\t\t    phy_idx,\n-\t\t\t\t    strerror(-rc));\n-\t\t\treturn rc;\n-\t\t}\n-\t}\n-\n-\tTFP_DRV_LOG(DEBUG,\n-\t\t    \"%s: TCAM shared clear pool(%s)\\n\",\n-\t\t    tf_dir_2_str(nparms.dir),\n-\t\t    tf_pool_2_str(id));\n-\treturn 0;\n+\trc = tf_tcam_mgr_shared_clear_msg(tfp, parms);\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 524631f262..e25babcd18 100644\n--- a/drivers/net/bnxt/tf_core/tf_tcam_shared.h\n+++ b/drivers/net/bnxt/tf_core/tf_tcam_shared.h\n@@ -1,5 +1,5 @@\n /* SPDX-License-Identifier: BSD-3-Clause\n- * Copyright(c) 2019-2021 Broadcom\n+ * Copyright(c) 2019-2023 Broadcom\n  * All rights reserved.\n  */\n \n@@ -129,7 +129,6 @@ 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.\ndiff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c\nindex 1bb38399e4..8513ee06a9 100644\n--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c\n+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c\n@@ -448,13 +448,13 @@ ulp_ctx_shared_session_open(struct bnxt *bp,\n \n \tswitch (ulp_dev_id) {\n \tcase BNXT_ULP_DEVICE_ID_WH_PLUS:\n-\t\tparms.device_type = TF_DEVICE_TYPE_WH;\n+\t\tparms.device_type = TF_DEVICE_TYPE_P5;\n \t\tbreak;\n \tcase BNXT_ULP_DEVICE_ID_STINGRAY:\n \t\tparms.device_type = TF_DEVICE_TYPE_SR;\n \t\tbreak;\n \tcase BNXT_ULP_DEVICE_ID_THOR:\n-\t\tparms.device_type = TF_DEVICE_TYPE_THOR;\n+\t\tparms.device_type = TF_DEVICE_TYPE_P4;\n \t\tbreak;\n \tdefault:\n \t\tBNXT_TF_DBG(ERR, \"Unable to determine dev for opening session.\\n\");\n@@ -563,13 +563,13 @@ ulp_ctx_session_open(struct bnxt *bp,\n \n \tswitch (ulp_dev_id) {\n \tcase BNXT_ULP_DEVICE_ID_WH_PLUS:\n-\t\tparams.device_type = TF_DEVICE_TYPE_WH;\n+\t\tparams.device_type = TF_DEVICE_TYPE_P5;\n \t\tbreak;\n \tcase BNXT_ULP_DEVICE_ID_STINGRAY:\n \t\tparams.device_type = TF_DEVICE_TYPE_SR;\n \t\tbreak;\n \tcase BNXT_ULP_DEVICE_ID_THOR:\n-\t\tparams.device_type = TF_DEVICE_TYPE_THOR;\n+\t\tparams.device_type = TF_DEVICE_TYPE_P4;\n \t\tbreak;\n \tdefault:\n \t\tBNXT_TF_DBG(ERR, \"Unable to determine device for opening session.\\n\");\n",
    "prefixes": [
        "v4",
        "04/11"
    ]
}