DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 00/58] enhancements to host based flow table management
@ 2021-05-30  8:58 Venkat Duvvuru
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 01/58] net/bnxt: add CFA folder to HCAPI directory Venkat Duvvuru
                   ` (58 more replies)
  0 siblings, 59 replies; 129+ messages in thread
From: Venkat Duvvuru @ 2021-05-30  8:58 UTC (permalink / raw)
  To: dev; +Cc: Venkat Duvvuru

This patchset adds flow table management support for
Thor network adapter and introduces enhancements to
the existing flow table management functionality.

Farah Smith (11):
  net/bnxt: add base TRUFLOW support for Thor
  net/bnxt: update TRUFLOW resources
  net/bnxt: add action SRAM Translation
  net/bnxt: add 64B SRAM record management with RM
  net/bnxt: modify TRUFLOW HWRM messages
  net/bnxt: shared TCAM region support
  net/bnxt: cleanup session open/close messages
  net/bnxt: add WC TCAM hi/lo move support
  net/bnxt: add API to get shared table increments
  net/bnxt: cleanup of WC TCAM shared unbind
  net/bnxt: add API to clear hi/lo WC region

Jay Ding (9):
  net/bnxt: check resource reservation in TRUFLOW
  net/bnxt: add L2 Context TCAM get support
  net/bnxt: add Thor WC TCAM support
  net/bnxt: change RM database type
  net/bnxt: add shared session support
  net/bnxt: update shared session functionality
  net/bnxt: modify resource reservation strategy
  net/bnxt: modify host session failure cleanup
  net/bnxt: add support for WC TCAM shared session

Jeffrey Huang (1):
  net/bnxt: add CFA folder to HCAPI directory

Kishore Padmanabha (23):
  net/bnxt: add support for generic table processing
  net/bnxt: add support for mapper flow database opcodes
  net/bnxt: modify TCAM opcode processing
  net/bnxt: modify table processing
  net/bnxt: modify ULP priority opcode processing
  net/bnxt: add support for conflict resolution
  net/bnxt: add support for conditional goto processing
  net/bnxt: set shared handle for generic table
  net/bnxt: modify ULP template
  net/bnxt: add conditional opcode and L4 port fields
  net/bnxt: refactor TF ULP
  net/bnxt: add partial header field processing
  net/bnxt: add support for wild card pattern match
  net/bnxt: enable extended exact match support
  net/bnxt: refactor ULP mapper and parser
  net/bnxt: add support for generic hash table
  net/bnxt: add support for Thor platform
  net/bnxt: refactor flow parser in ULP
  net/bnxt: add field opcodes in ULP
  net/bnxt: add support for application ID in ULP matcher
  net/bnxt: add support for shared sessions in ULP
  net/bnxt: add support for icmp6 ULP parsing
  net/bnxt: add support for ULP context list for timers

Mike Baucom (5):
  net/bnxt: add conditional execution and rejection
  net/bnxt: add shared session support to ULP
  net/bnxt: process resource lists before session open
  net/bnxt: add HA support in ULP
  net/bnxt: add Thor template support

Peter Spreadborough (4):
  net/bnxt: add mailbox selection via dev op
  net/bnxt: add support for EM with FKB
  net/bnxt: add hashing changes for Thor
  net/bnxt: add dpool allocator for EM allocation

Shahaji Bhosle (1):
  net/bnxt: cleanup ULP parser and mapper

Venkat Duvvuru (4):
  net/bnxt: check FW capability to support TRUFLOW
  net/bnxt: modify VXLAN decap for multichannel mode
  net/bnxt: add support for GRE flows
  net/bnxt: reorganize ULP template directory structure

 doc/guides/nics/bnxt.rst                      |     3 +-
 drivers/net/bnxt/bnxt.h                       |    19 +-
 drivers/net/bnxt/bnxt_ethdev.c                |   162 +-
 drivers/net/bnxt/bnxt_hwrm.c                  |     7 +-
 drivers/net/bnxt/bnxt_util.h                  |     3 +
 drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h        |   126 +
 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_common.c |    83 +
 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_defs.h   |   381 +
 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.c     |   292 +
 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.h     |   185 +
 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.c    |   122 +
 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.h    |   142 +
 drivers/net/bnxt/hcapi/cfa/meson.build        |    12 +
 drivers/net/bnxt/hcapi/cfa_p40_hw.h           |   781 -
 drivers/net/bnxt/hcapi/cfa_p40_tbl.h          |   303 -
 drivers/net/bnxt/hcapi/hcapi_cfa.h            |   295 -
 drivers/net/bnxt/hcapi/hcapi_cfa_defs.h       |   672 -
 drivers/net/bnxt/hcapi/hcapi_cfa_p4.c         |   399 -
 drivers/net/bnxt/hcapi/hcapi_cfa_p4.h         |   467 -
 drivers/net/bnxt/hsi_struct_def_dpdk.h        |   281 +-
 drivers/net/bnxt/meson.build                  |    65 +-
 drivers/net/bnxt/tf_core/bitalloc.c           |    10 +-
 drivers/net/bnxt/tf_core/bitalloc.h           |     5 +-
 drivers/net/bnxt/tf_core/cfa_resource_types.h |     3 +-
 drivers/net/bnxt/tf_core/dpool.c              |   373 +
 drivers/net/bnxt/tf_core/dpool.h              |   309 +
 drivers/net/bnxt/tf_core/hwrm_tf.h            |   195 -
 drivers/net/bnxt/tf_core/lookup3.h            |     2 +-
 drivers/net/bnxt/tf_core/meson.build          |    36 +
 drivers/net/bnxt/tf_core/tf_core.c            |   326 +-
 drivers/net/bnxt/tf_core/tf_core.h            |   563 +-
 drivers/net/bnxt/tf_core/tf_device.c          |   530 +-
 drivers/net/bnxt/tf_core/tf_device.h          |   276 +-
 drivers/net/bnxt/tf_core/tf_device_p4.c       |   164 +-
 drivers/net/bnxt/tf_core/tf_device_p4.h       |   203 +-
 drivers/net/bnxt/tf_core/tf_device_p45.h      |   105 -
 drivers/net/bnxt/tf_core/tf_device_p58.c      |   375 +
 drivers/net/bnxt/tf_core/tf_device_p58.h      |   212 +
 drivers/net/bnxt/tf_core/tf_em.h              |    99 +-
 drivers/net/bnxt/tf_core/tf_em_common.c       |   332 +-
 drivers/net/bnxt/tf_core/tf_em_common.h       |    68 +-
 .../net/bnxt/tf_core/tf_em_hash_internal.c    |   215 +
 drivers/net/bnxt/tf_core/tf_em_host.c         |   115 +-
 drivers/net/bnxt/tf_core/tf_em_internal.c     |   376 +-
 drivers/net/bnxt/tf_core/tf_ext_flow_handle.h |    15 +-
 drivers/net/bnxt/tf_core/tf_identifier.c      |   174 +-
 drivers/net/bnxt/tf_core/tf_identifier.h      |    26 +
 drivers/net/bnxt/tf_core/tf_if_tbl.c          |    20 +-
 drivers/net/bnxt/tf_core/tf_msg.c             |  1219 +-
 drivers/net/bnxt/tf_core/tf_msg.h             |   217 +-
 drivers/net/bnxt/tf_core/tf_msg_common.h      |     3 -
 drivers/net/bnxt/tf_core/tf_rm.c              |   834 +-
 drivers/net/bnxt/tf_core/tf_rm.h              |   143 +-
 drivers/net/bnxt/tf_core/tf_session.c         |   261 +-
 drivers/net/bnxt/tf_core/tf_session.h         |   206 +-
 drivers/net/bnxt/tf_core/tf_shadow_tbl.c      |   785 -
 drivers/net/bnxt/tf_core/tf_shadow_tbl.h      |   256 -
 drivers/net/bnxt/tf_core/tf_shadow_tcam.c     |     6 +-
 drivers/net/bnxt/tf_core/tf_tbl.c             |   656 +-
 drivers/net/bnxt/tf_core/tf_tbl.h             |    57 +-
 drivers/net/bnxt/tf_core/tf_tcam.c            |   435 +-
 drivers/net/bnxt/tf_core/tf_tcam.h            |    30 +
 drivers/net/bnxt/tf_core/tf_tcam_shared.c     |  1283 +
 drivers/net/bnxt/tf_core/tf_tcam_shared.h     |   183 +
 drivers/net/bnxt/tf_core/tf_util.c            |    62 +-
 drivers/net/bnxt/tf_core/tf_util.h            |    31 +-
 drivers/net/bnxt/tf_core/tfp.c                |    44 +-
 drivers/net/bnxt/tf_core/tfp.h                |    61 +-
 drivers/net/bnxt/tf_ulp/bnxt_tf_common.h      |     2 -
 drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c    |   378 +
 drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.h    |    29 +
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c            |   943 +-
 drivers/net/bnxt/tf_ulp/bnxt_ulp.h            |    85 +-
 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c       |    74 +-
 .../bnxt/tf_ulp/generic_templates/meson.build |    13 +
 .../generic_templates/ulp_template_db_act.c   |  1017 +
 .../generic_templates/ulp_template_db_class.c | 13188 ++++++++++
 .../generic_templates/ulp_template_db_enum.h  |  1883 ++
 .../generic_templates/ulp_template_db_field.h |   686 +
 .../generic_templates/ulp_template_db_tbl.c   |  3335 +++
 .../generic_templates/ulp_template_db_tbl.h   |   112 +
 .../ulp_template_db_thor_act.c                |   225 +
 .../ulp_template_db_thor_class.c              |  6107 +++++
 .../ulp_template_db_wh_plus_act.c             |  4974 ++++
 .../ulp_template_db_wh_plus_class.c           | 14270 +++++++++++
 drivers/net/bnxt/tf_ulp/meson.build           |    28 +
 drivers/net/bnxt/tf_ulp/ulp_def_rules.c       |    91 +-
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c          |   171 +-
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h          |     1 +
 drivers/net/bnxt/tf_ulp/ulp_flow_db.c         |   129 +-
 drivers/net/bnxt/tf_ulp/ulp_flow_db.h         |    20 +-
 drivers/net/bnxt/tf_ulp/ulp_gen_hash.c        |   369 +
 drivers/net/bnxt/tf_ulp/ulp_gen_hash.h        |   166 +
 drivers/net/bnxt/tf_ulp/ulp_gen_tbl.c         |   417 +
 drivers/net/bnxt/tf_ulp/ulp_gen_tbl.h         |   171 +
 drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c          |   637 +
 drivers/net/bnxt/tf_ulp/ulp_ha_mgr.h          |    67 +
 drivers/net/bnxt/tf_ulp/ulp_mapper.c          |  3572 ++-
 drivers/net/bnxt/tf_ulp/ulp_mapper.h          |    59 +-
 drivers/net/bnxt/tf_ulp/ulp_mark_mgr.c        |    10 +-
 drivers/net/bnxt/tf_ulp/ulp_matcher.c         |    36 +-
 drivers/net/bnxt/tf_ulp/ulp_port_db.c         |   140 +-
 drivers/net/bnxt/tf_ulp/ulp_port_db.h         |    42 +
 ...emplate_db_tbl.c => ulp_rte_handler_tbl.c} |   269 +-
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.c      |  1207 +-
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.h      |    36 +-
 drivers/net/bnxt/tf_ulp/ulp_template_db.c     |  4622 ----
 drivers/net/bnxt/tf_ulp/ulp_template_db.h     |   614 -
 drivers/net/bnxt/tf_ulp/ulp_template_db_act.c |   815 -
 .../net/bnxt/tf_ulp/ulp_template_db_class.c   |  3985 ---
 .../net/bnxt/tf_ulp/ulp_template_db_enum.h    |   973 -
 .../net/bnxt/tf_ulp/ulp_template_db_field.h   |  1191 -
 .../tf_ulp/ulp_template_db_stingray_act.c     |  3305 ---
 .../tf_ulp/ulp_template_db_stingray_class.c   | 20566 ----------------
 drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.h |    48 -
 .../bnxt/tf_ulp/ulp_template_db_wh_plus_act.c |  3304 ---
 .../tf_ulp/ulp_template_db_wh_plus_class.c    | 20566 ----------------
 .../net/bnxt/tf_ulp/ulp_template_field_db.h   |   224 -
 drivers/net/bnxt/tf_ulp/ulp_template_struct.h |   192 +-
 drivers/net/bnxt/tf_ulp/ulp_tun.c             |   194 +-
 drivers/net/bnxt/tf_ulp/ulp_tun.h             |    33 +-
 drivers/net/bnxt/tf_ulp/ulp_utils.c           |   339 +-
 drivers/net/bnxt/tf_ulp/ulp_utils.h           |   153 +-
 123 files changed, 63946 insertions(+), 68836 deletions(-)
 create mode 100644 drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h
 create mode 100644 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_common.c
 create mode 100644 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_defs.h
 create mode 100644 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.c
 create mode 100644 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.h
 create mode 100644 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.c
 create mode 100644 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.h
 create mode 100644 drivers/net/bnxt/hcapi/cfa/meson.build
 delete mode 100644 drivers/net/bnxt/hcapi/cfa_p40_hw.h
 delete mode 100644 drivers/net/bnxt/hcapi/cfa_p40_tbl.h
 delete mode 100644 drivers/net/bnxt/hcapi/hcapi_cfa.h
 delete mode 100644 drivers/net/bnxt/hcapi/hcapi_cfa_defs.h
 delete mode 100644 drivers/net/bnxt/hcapi/hcapi_cfa_p4.c
 delete mode 100644 drivers/net/bnxt/hcapi/hcapi_cfa_p4.h
 create mode 100644 drivers/net/bnxt/tf_core/dpool.c
 create mode 100644 drivers/net/bnxt/tf_core/dpool.h
 delete mode 100644 drivers/net/bnxt/tf_core/hwrm_tf.h
 create mode 100644 drivers/net/bnxt/tf_core/meson.build
 delete mode 100644 drivers/net/bnxt/tf_core/tf_device_p45.h
 create mode 100644 drivers/net/bnxt/tf_core/tf_device_p58.c
 create mode 100644 drivers/net/bnxt/tf_core/tf_device_p58.h
 create mode 100644 drivers/net/bnxt/tf_core/tf_em_hash_internal.c
 delete mode 100644 drivers/net/bnxt/tf_core/tf_shadow_tbl.c
 delete mode 100644 drivers/net/bnxt/tf_core/tf_shadow_tbl.h
 create mode 100644 drivers/net/bnxt/tf_core/tf_tcam_shared.c
 create mode 100644 drivers/net/bnxt/tf_core/tf_tcam_shared.h
 create mode 100644 drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c
 create mode 100644 drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.h
 create mode 100644 drivers/net/bnxt/tf_ulp/generic_templates/meson.build
 create mode 100644 drivers/net/bnxt/tf_ulp/generic_templates/ulp_template_db_act.c
 create mode 100644 drivers/net/bnxt/tf_ulp/generic_templates/ulp_template_db_class.c
 create mode 100644 drivers/net/bnxt/tf_ulp/generic_templates/ulp_template_db_enum.h
 create mode 100644 drivers/net/bnxt/tf_ulp/generic_templates/ulp_template_db_field.h
 create mode 100644 drivers/net/bnxt/tf_ulp/generic_templates/ulp_template_db_tbl.c
 create mode 100644 drivers/net/bnxt/tf_ulp/generic_templates/ulp_template_db_tbl.h
 create mode 100644 drivers/net/bnxt/tf_ulp/generic_templates/ulp_template_db_thor_act.c
 create mode 100644 drivers/net/bnxt/tf_ulp/generic_templates/ulp_template_db_thor_class.c
 create mode 100644 drivers/net/bnxt/tf_ulp/generic_templates/ulp_template_db_wh_plus_act.c
 create mode 100644 drivers/net/bnxt/tf_ulp/generic_templates/ulp_template_db_wh_plus_class.c
 create mode 100644 drivers/net/bnxt/tf_ulp/meson.build
 create mode 100644 drivers/net/bnxt/tf_ulp/ulp_gen_hash.c
 create mode 100644 drivers/net/bnxt/tf_ulp/ulp_gen_hash.h
 create mode 100644 drivers/net/bnxt/tf_ulp/ulp_gen_tbl.c
 create mode 100644 drivers/net/bnxt/tf_ulp/ulp_gen_tbl.h
 create mode 100644 drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c
 create mode 100644 drivers/net/bnxt/tf_ulp/ulp_ha_mgr.h
 rename drivers/net/bnxt/tf_ulp/{ulp_template_db_tbl.c => ulp_rte_handler_tbl.c} (60%)
 delete mode 100644 drivers/net/bnxt/tf_ulp/ulp_template_db.c
 delete mode 100644 drivers/net/bnxt/tf_ulp/ulp_template_db.h
 delete mode 100644 drivers/net/bnxt/tf_ulp/ulp_template_db_act.c
 delete mode 100644 drivers/net/bnxt/tf_ulp/ulp_template_db_class.c
 delete mode 100644 drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h
 delete mode 100644 drivers/net/bnxt/tf_ulp/ulp_template_db_field.h
 delete mode 100644 drivers/net/bnxt/tf_ulp/ulp_template_db_stingray_act.c
 delete mode 100644 drivers/net/bnxt/tf_ulp/ulp_template_db_stingray_class.c
 delete mode 100644 drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.h
 delete mode 100644 drivers/net/bnxt/tf_ulp/ulp_template_db_wh_plus_act.c
 delete mode 100644 drivers/net/bnxt/tf_ulp/ulp_template_db_wh_plus_class.c
 delete mode 100644 drivers/net/bnxt/tf_ulp/ulp_template_field_db.h

-- 
2.17.1


^ permalink raw reply	[flat|nested] 129+ messages in thread

* [dpdk-dev] [PATCH 01/58] net/bnxt: add CFA folder to HCAPI directory
  2021-05-30  8:58 [dpdk-dev] [PATCH 00/58] enhancements to host based flow table management Venkat Duvvuru
@ 2021-05-30  8:58 ` Venkat Duvvuru
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 02/58] net/bnxt: add base TRUFLOW support for Thor Venkat Duvvuru
                   ` (57 subsequent siblings)
  58 siblings, 0 replies; 129+ messages in thread
From: Venkat Duvvuru @ 2021-05-30  8:58 UTC (permalink / raw)
  To: dev; +Cc: Jeffrey Huang, Randy Schacher, Venkat Duvvuru

From: Jeffrey Huang <jeffrey.huang@broadcom.com>

Before introducing more HCAPI components to DPDK, the CFA code needs
to be organized into a dedicated folder so it is separated from
other new HCAPI components

Signed-off-by: Jeffrey Huang <jeffrey.huang@broadcom.com>
Signed-off-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Farah Smith <farah.smith@broadcom.com>
---
 drivers/net/bnxt/hcapi/{ => cfa}/hcapi_cfa.h  |  14 -
 .../net/bnxt/hcapi/{ => cfa}/hcapi_cfa_defs.h |   8 +-
 .../net/bnxt/hcapi/{ => cfa}/hcapi_cfa_p4.c   |   0
 .../net/bnxt/hcapi/{ => cfa}/hcapi_cfa_p4.h   |   2 -
 drivers/net/bnxt/hcapi/cfa/meson.build        |  10 +
 drivers/net/bnxt/hcapi/cfa_p40_hw.h           | 781 ------------------
 drivers/net/bnxt/hcapi/cfa_p40_tbl.h          | 303 -------
 drivers/net/bnxt/meson.build                  |  65 +-
 drivers/net/bnxt/tf_core/meson.build          |  33 +
 drivers/net/bnxt/tf_core/tf_core.h            |   2 +-
 drivers/net/bnxt/tf_core/tf_em.h              |   2 +-
 drivers/net/bnxt/tf_ulp/meson.build           |  28 +
 12 files changed, 89 insertions(+), 1159 deletions(-)
 rename drivers/net/bnxt/hcapi/{ => cfa}/hcapi_cfa.h (96%)
 rename drivers/net/bnxt/hcapi/{ => cfa}/hcapi_cfa_defs.h (98%)
 rename drivers/net/bnxt/hcapi/{ => cfa}/hcapi_cfa_p4.c (100%)
 rename drivers/net/bnxt/hcapi/{ => cfa}/hcapi_cfa_p4.h (99%)
 create mode 100644 drivers/net/bnxt/hcapi/cfa/meson.build
 delete mode 100644 drivers/net/bnxt/hcapi/cfa_p40_hw.h
 delete mode 100644 drivers/net/bnxt/hcapi/cfa_p40_tbl.h
 create mode 100644 drivers/net/bnxt/tf_core/meson.build
 create mode 100644 drivers/net/bnxt/tf_ulp/meson.build

diff --git a/drivers/net/bnxt/hcapi/hcapi_cfa.h b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h
similarity index 96%
rename from drivers/net/bnxt/hcapi/hcapi_cfa.h
rename to drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h
index c58092e72d..b8c85a0fca 100644
--- a/drivers/net/bnxt/hcapi/hcapi_cfa.h
+++ b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h
@@ -14,20 +14,6 @@
 
 #include "hcapi_cfa_defs.h"
 
-#if CHIP_CFG == SR_A
-#define SUPPORT_CFA_HW_P45  1
-#undef SUPPORT_CFA_HW_P4
-#define SUPPORT_CFA_HW_P4   0
-#elif CHIP_CFG == CMB_A
-#define SUPPORT_CFA_HW_P4  1
-#else
-#error "Chip not supported"
-#endif
-
-#if SUPPORT_CFA_HW_P4 && SUPPORT_CFA_HW_P58 && SUPPORT_CFA_HW_P59
-#define SUPPORT_CFA_HW_ALL  1
-#endif
-
 /**
  * Index used for the sram_entries field
  */
diff --git a/drivers/net/bnxt/hcapi/hcapi_cfa_defs.h b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_defs.h
similarity index 98%
rename from drivers/net/bnxt/hcapi/hcapi_cfa_defs.h
rename to drivers/net/bnxt/hcapi/cfa/hcapi_cfa_defs.h
index b3d6892b0b..08f098ec86 100644
--- a/drivers/net/bnxt/hcapi/hcapi_cfa_defs.h
+++ b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_defs.h
@@ -17,11 +17,6 @@
 #include <stdint.h>
 #include <stddef.h>
 
-#define SUPPORT_CFA_HW_ALL 0
-#define SUPPORT_CFA_HW_P4  1
-#define SUPPORT_CFA_HW_P58 0
-#define SUPPORT_CFA_HW_P59 0
-
 #define CFA_BITS_PER_BYTE (8)
 #define __CFA_ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask))
 #define CFA_ALIGN(x, a) __CFA_ALIGN_MASK(x, (a) - 1)
@@ -49,8 +44,7 @@ enum hcapi_cfa_ver {
 	HCAPI_CFA_P40 = 0, /**< CFA phase 4.0 */
 	HCAPI_CFA_P45 = 1, /**< CFA phase 4.5 */
 	HCAPI_CFA_P58 = 2, /**< CFA phase 5.8 */
-	HCAPI_CFA_P59 = 3, /**< CFA phase 5.9 */
-	HCAPI_CFA_PMAX = 4
+	HCAPI_CFA_PMAX = 3
 };
 
 /**
diff --git a/drivers/net/bnxt/hcapi/hcapi_cfa_p4.c b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.c
similarity index 100%
rename from drivers/net/bnxt/hcapi/hcapi_cfa_p4.c
rename to drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.c
diff --git a/drivers/net/bnxt/hcapi/hcapi_cfa_p4.h b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.h
similarity index 99%
rename from drivers/net/bnxt/hcapi/hcapi_cfa_p4.h
rename to drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.h
index 305c83bc9f..74a5483c0b 100644
--- a/drivers/net/bnxt/hcapi/hcapi_cfa_p4.h
+++ b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.h
@@ -6,8 +6,6 @@
 #ifndef _HCAPI_CFA_P4_H_
 #define _HCAPI_CFA_P4_H_
 
-#include "cfa_p40_hw.h"
-
 /** CFA phase 4 fix formatted table(layout) ID definition
  *
  */
diff --git a/drivers/net/bnxt/hcapi/cfa/meson.build b/drivers/net/bnxt/hcapi/cfa/meson.build
new file mode 100644
index 0000000000..8b70d273f4
--- /dev/null
+++ b/drivers/net/bnxt/hcapi/cfa/meson.build
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 Intel Corporation
+# Copyright(c) 2021 Broadcom
+
+#Include the folder for headers
+includes += include_directories('.')
+
+#Add the source files
+sources += files(
+        'hcapi_cfa_p4.c')
diff --git a/drivers/net/bnxt/hcapi/cfa_p40_hw.h b/drivers/net/bnxt/hcapi/cfa_p40_hw.h
deleted file mode 100644
index 5e32529886..0000000000
--- a/drivers/net/bnxt/hcapi/cfa_p40_hw.h
+++ /dev/null
@@ -1,781 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2019-2021 Broadcom
- * All rights reserved.
- */
-/*
- * Name:  cfa_p40_hw.h
- *
- * Description: header for SWE based on Truflow
- *
- * Date:  taken from 12/16/19 17:18:12
- *
- * Note:  This file was first generated using  tflib_decode.py.
- *
- *        Changes have been made due to lack of availability of xml for
- *        additional tables at this time (EEM Record and union table fields)
- *        Changes not autogenerated are noted in comments.
- */
-
-#ifndef _CFA_P40_HW_H_
-#define _CFA_P40_HW_H_
-
-/**
- * Valid TCAM entry. (for idx 5 ...)
- */
-#define CFA_P40_PROF_L2_CTXT_TCAM_VALID_BITPOS   166
-#define CFA_P40_PROF_L2_CTXT_TCAM_VALID_NUM_BITS 1
-/**
- * Key type (pass). (for idx 5 ...)
- */
-#define CFA_P40_PROF_L2_CTXT_TCAM_KEY_TYPE_BITPOS 164
-#define CFA_P40_PROF_L2_CTXT_TCAM_KEY_TYPE_NUM_BITS 2
-/**
- * Tunnel HDR type. (for idx 5 ...)
- */
-#define CFA_P40_PROF_L2_CTXT_TCAM_TUN_HDR_TYPE_BITPOS 160
-#define CFA_P40_PROF_L2_CTXT_TCAM_TUN_HDR_TYPE_NUM_BITS 4
-/**
- * Number of VLAN tags in tunnel l2 header. (for idx 4 ...)
- */
-#define CFA_P40_PROF_L2_CTXT_TCAM_T_L2_NUMTAGS_BITPOS 158
-#define CFA_P40_PROF_L2_CTXT_TCAM_T_L2_NUMTAGS_NUM_BITS 2
-/**
- * Number of VLAN tags in l2 header. (for idx 4 ...)
- */
-#define CFA_P40_PROF_L2_CTXT_TCAM_L2_NUMTAGS_BITPOS 156
-#define CFA_P40_PROF_L2_CTXT_TCAM_L2_NUMTAGS_NUM_BITS 2
-/**
- * Tunnel/Inner Source/Dest. MAC Address.
- */
-#define CFA_P40_PROF_L2_CTXT_TCAM_MAC1_BITPOS    108
-#define CFA_P40_PROF_L2_CTXT_TCAM_MAC1_NUM_BITS  48
-/**
- * Tunnel Outer VLAN Tag ID. (for idx 3 ...)
- */
-#define CFA_P40_PROF_L2_CTXT_TCAM_T_OVID_BITPOS  96
-#define CFA_P40_PROF_L2_CTXT_TCAM_T_OVID_NUM_BITS 12
-/**
- * Tunnel Inner VLAN Tag ID. (for idx 2 ...)
- */
-#define CFA_P40_PROF_L2_CTXT_TCAM_T_IVID_BITPOS  84
-#define CFA_P40_PROF_L2_CTXT_TCAM_T_IVID_NUM_BITS 12
-/**
- * Source Partition. (for idx 2 ...)
- */
-#define CFA_P40_PROF_L2_CTXT_TCAM_SPARIF_BITPOS  80
-#define CFA_P40_PROF_L2_CTXT_TCAM_SPARIF_NUM_BITS 4
-/**
- * Source Virtual I/F. (for idx 2 ...)
- */
-#define CFA_P40_PROF_L2_CTXT_TCAM_SVIF_BITPOS    72
-#define CFA_P40_PROF_L2_CTXT_TCAM_SVIF_NUM_BITS  8
-/**
- * Tunnel/Inner Source/Dest. MAC Address.
- */
-#define CFA_P40_PROF_L2_CTXT_TCAM_MAC0_BITPOS    24
-#define CFA_P40_PROF_L2_CTXT_TCAM_MAC0_NUM_BITS  48
-/**
- * Outer VLAN Tag ID.
- */
-#define CFA_P40_PROF_L2_CTXT_TCAM_OVID_BITPOS    12
-#define CFA_P40_PROF_L2_CTXT_TCAM_OVID_NUM_BITS  12
-/**
- * Inner VLAN Tag ID.
- */
-#define CFA_P40_PROF_L2_CTXT_TCAM_IVID_BITPOS    0
-#define CFA_P40_PROF_L2_CTXT_TCAM_IVID_NUM_BITS  12
-
-enum cfa_p40_prof_l2_ctxt_tcam_flds {
-	CFA_P40_PROF_L2_CTXT_TCAM_VALID_FLD = 0,
-	CFA_P40_PROF_L2_CTXT_TCAM_KEY_TYPE_FLD = 1,
-	CFA_P40_PROF_L2_CTXT_TCAM_TUN_HDR_TYPE_FLD = 2,
-	CFA_P40_PROF_L2_CTXT_TCAM_T_L2_NUMTAGS_FLD = 3,
-	CFA_P40_PROF_L2_CTXT_TCAM_L2_NUMTAGS_FLD = 4,
-	CFA_P40_PROF_L2_CTXT_TCAM_MAC1_FLD = 5,
-	CFA_P40_PROF_L2_CTXT_TCAM_T_OVID_FLD = 6,
-	CFA_P40_PROF_L2_CTXT_TCAM_T_IVID_FLD = 7,
-	CFA_P40_PROF_L2_CTXT_TCAM_SPARIF_FLD = 8,
-	CFA_P40_PROF_L2_CTXT_TCAM_SVIF_FLD = 9,
-	CFA_P40_PROF_L2_CTXT_TCAM_MAC0_FLD = 10,
-	CFA_P40_PROF_L2_CTXT_TCAM_OVID_FLD = 11,
-	CFA_P40_PROF_L2_CTXT_TCAM_IVID_FLD = 12,
-	CFA_P40_PROF_L2_CTXT_TCAM_MAX_FLD
-};
-
-#define CFA_P40_PROF_L2_CTXT_TCAM_TOTAL_NUM_BITS 167
-
-/**
- * Valid entry. (for idx 2 ...)
- */
-#define CFA_P40_ACT_VEB_TCAM_VALID_BITPOS        79
-#define CFA_P40_ACT_VEB_TCAM_VALID_NUM_BITS      1
-/**
- * reserved program to 0. (for idx 2 ...)
- */
-#define CFA_P40_ACT_VEB_TCAM_RESERVED_BITPOS     78
-#define CFA_P40_ACT_VEB_TCAM_RESERVED_NUM_BITS   1
-/**
- * PF Parif Number. (for idx 2 ...)
- */
-#define CFA_P40_ACT_VEB_TCAM_PARIF_IN_BITPOS     74
-#define CFA_P40_ACT_VEB_TCAM_PARIF_IN_NUM_BITS   4
-/**
- * Number of VLAN Tags. (for idx 2 ...)
- */
-#define CFA_P40_ACT_VEB_TCAM_NUM_VTAGS_BITPOS    72
-#define CFA_P40_ACT_VEB_TCAM_NUM_VTAGS_NUM_BITS  2
-/**
- * Dest. MAC Address.
- */
-#define CFA_P40_ACT_VEB_TCAM_MAC_BITPOS          24
-#define CFA_P40_ACT_VEB_TCAM_MAC_NUM_BITS        48
-/**
- * Outer VLAN Tag ID.
- */
-#define CFA_P40_ACT_VEB_TCAM_OVID_BITPOS         12
-#define CFA_P40_ACT_VEB_TCAM_OVID_NUM_BITS       12
-/**
- * Inner VLAN Tag ID.
- */
-#define CFA_P40_ACT_VEB_TCAM_IVID_BITPOS         0
-#define CFA_P40_ACT_VEB_TCAM_IVID_NUM_BITS       12
-
-enum cfa_p40_act_veb_tcam_flds {
-	CFA_P40_ACT_VEB_TCAM_VALID_FLD = 0,
-	CFA_P40_ACT_VEB_TCAM_RESERVED_FLD = 1,
-	CFA_P40_ACT_VEB_TCAM_PARIF_IN_FLD = 2,
-	CFA_P40_ACT_VEB_TCAM_NUM_VTAGS_FLD = 3,
-	CFA_P40_ACT_VEB_TCAM_MAC_FLD = 4,
-	CFA_P40_ACT_VEB_TCAM_OVID_FLD = 5,
-	CFA_P40_ACT_VEB_TCAM_IVID_FLD = 6,
-	CFA_P40_ACT_VEB_TCAM_MAX_FLD
-};
-
-#define CFA_P40_ACT_VEB_TCAM_TOTAL_NUM_BITS 80
-
-/**
- * Entry is valid.
- */
-#define CFA_P40_LKUP_TCAM_RECORD_MEM_VALID_BITPOS 18
-#define CFA_P40_LKUP_TCAM_RECORD_MEM_VALID_NUM_BITS 1
-/**
- * Action Record Pointer
- */
-#define CFA_P40_LKUP_TCAM_RECORD_MEM_ACT_REC_PTR_BITPOS 2
-#define CFA_P40_LKUP_TCAM_RECORD_MEM_ACT_REC_PTR_NUM_BITS 16
-/**
- * for resolving TCAM/EM conflicts
- */
-#define CFA_P40_LKUP_TCAM_RECORD_MEM_STRENGTH_BITPOS 0
-#define CFA_P40_LKUP_TCAM_RECORD_MEM_STRENGTH_NUM_BITS 2
-
-enum cfa_p40_lkup_tcam_record_mem_flds {
-	CFA_P40_LKUP_TCAM_RECORD_MEM_VALID_FLD = 0,
-	CFA_P40_LKUP_TCAM_RECORD_MEM_ACT_REC_PTR_FLD = 1,
-	CFA_P40_LKUP_TCAM_RECORD_MEM_STRENGTH_FLD = 2,
-	CFA_P40_LKUP_TCAM_RECORD_MEM_MAX_FLD
-};
-
-#define CFA_P40_LKUP_TCAM_RECORD_MEM_TOTAL_NUM_BITS 19
-
-/**
- * (for idx 1 ...)
- */
-#define CFA_P40_PROF_CTXT_REMAP_MEM_TPID_ANTI_SPOOF_CTL_BITPOS 62
-#define CFA_P40_PROF_CTXT_REMAP_MEM_TPID_ANTI_SPOOF_CTL_NUM_BITS 2
-enum cfa_p40_prof_ctxt_remap_mem_tpid_anti_spoof_ctl {
-	CFA_P40_PROF_CTXT_REMAP_MEM_TPID_IGNORE = 0x0UL,
-
-	CFA_P40_PROF_CTXT_REMAP_MEM_TPID_DROP = 0x1UL,
-
-	CFA_P40_PROF_CTXT_REMAP_MEM_TPID_DEFAULT = 0x2UL,
-
-	CFA_P40_PROF_CTXT_REMAP_MEM_TPID_SPIF = 0x3UL,
-	CFA_P40_PROF_CTXT_REMAP_MEM_TPID_MAX = 0x3UL
-};
-/**
- * (for idx 1 ...)
- */
-#define CFA_P40_PROF_CTXT_REMAP_MEM_PRI_ANTI_SPOOF_CTL_BITPOS 60
-#define CFA_P40_PROF_CTXT_REMAP_MEM_PRI_ANTI_SPOOF_CTL_NUM_BITS 2
-enum cfa_p40_prof_ctxt_remap_mem_pri_anti_spoof_ctl {
-	CFA_P40_PROF_CTXT_REMAP_MEM_PRI_IGNORE = 0x0UL,
-
-	CFA_P40_PROF_CTXT_REMAP_MEM_PRI_DROP = 0x1UL,
-
-	CFA_P40_PROF_CTXT_REMAP_MEM_PRI_DEFAULT = 0x2UL,
-
-	CFA_P40_PROF_CTXT_REMAP_MEM_PRI_SPIF = 0x3UL,
-	CFA_P40_PROF_CTXT_REMAP_MEM_PRI_MAX = 0x3UL
-};
-/**
- * Bypass Source Properties Lookup. (for idx 1 ...)
- */
-#define CFA_P40_PROF_CTXT_REMAP_MEM_BYP_SP_LKUP_BITPOS 59
-#define CFA_P40_PROF_CTXT_REMAP_MEM_BYP_SP_LKUP_NUM_BITS 1
-/**
- * SP Record Pointer. (for idx 1 ...)
- */
-#define CFA_P40_PROF_CTXT_REMAP_MEM_SP_REC_PTR_BITPOS 43
-#define CFA_P40_PROF_CTXT_REMAP_MEM_SP_REC_PTR_NUM_BITS 16
-/**
- * BD Action pointer passing enable. (for idx 1 ...)
- */
-#define CFA_P40_PROF_CTXT_REMAP_MEM_BD_ACT_EN_BITPOS 42
-#define CFA_P40_PROF_CTXT_REMAP_MEM_BD_ACT_EN_NUM_BITS 1
-/**
- * Default VLAN TPID. (for idx 1 ...)
- */
-#define CFA_P40_PROF_CTXT_REMAP_MEM_DEFAULT_TPID_BITPOS 39
-#define CFA_P40_PROF_CTXT_REMAP_MEM_DEFAULT_TPID_NUM_BITS 3
-/**
- * Allowed VLAN TPIDs. (for idx 1 ...)
- */
-#define CFA_P40_PROF_CTXT_REMAP_MEM_ALLOWED_TPID_BITPOS 33
-#define CFA_P40_PROF_CTXT_REMAP_MEM_ALLOWED_TPID_NUM_BITS 6
-/**
- * Default VLAN PRI.
- */
-#define CFA_P40_PROF_CTXT_REMAP_MEM_DEFAULT_PRI_BITPOS 30
-#define CFA_P40_PROF_CTXT_REMAP_MEM_DEFAULT_PRI_NUM_BITS 3
-/**
- * Allowed VLAN PRIs.
- */
-#define CFA_P40_PROF_CTXT_REMAP_MEM_ALLOWED_PRI_BITPOS 22
-#define CFA_P40_PROF_CTXT_REMAP_MEM_ALLOWED_PRI_NUM_BITS 8
-/**
- * Partition.
- */
-#define CFA_P40_PROF_CTXT_REMAP_MEM_PARIF_BITPOS 18
-#define CFA_P40_PROF_CTXT_REMAP_MEM_PARIF_NUM_BITS 4
-/**
- * Bypass Lookup.
- */
-#define CFA_P40_PROF_CTXT_REMAP_MEM_BYP_LKUP_EN_BITPOS 17
-#define CFA_P40_PROF_CTXT_REMAP_MEM_BYP_LKUP_EN_NUM_BITS 1
-
-/**
- * L2 Context Remap Data. Action bypass mode (1) {7'd0,prof_vnic[9:0]} Note:
- * should also set byp_lkup_en. Action bypass mode (0) byp_lkup_en(0) -
- * {prof_func[6:0],l2_context[9:0]} byp_lkup_en(1) - {1'b0,act_rec_ptr[15:0]}
- */
-
-#define CFA_P40_PROF_CTXT_REMAP_MEM_PROF_VNIC_BITPOS 0
-#define CFA_P40_PROF_CTXT_REMAP_MEM_PROF_VNIC_NUM_BITS 12
-
-#define CFA_P40_PROF_CTXT_REMAP_MEM_PROF_FUNC_BITPOS 10
-#define CFA_P40_PROF_CTXT_REMAP_MEM_PROF_FUNC_NUM_BITS 7
-
-#define CFA_P40_PROF_CTXT_REMAP_MEM_L2_CTXT_BITPOS 0
-#define CFA_P40_PROF_CTXT_REMAP_MEM_L2_CTXT_NUM_BITS 10
-
-#define CFA_P40_PROF_CTXT_REMAP_MEM_ARP_BITPOS 0
-#define CFA_P40_PROF_CTXT_REMAP_MEM_ARP_NUM_BITS 16
-
-enum cfa_p40_prof_ctxt_remap_mem_flds {
-	CFA_P40_PROF_CTXT_REMAP_MEM_TPID_ANTI_SPOOF_CTL_FLD = 0,
-	CFA_P40_PROF_CTXT_REMAP_MEM_PRI_ANTI_SPOOF_CTL_FLD = 1,
-	CFA_P40_PROF_CTXT_REMAP_MEM_BYP_SP_LKUP_FLD = 2,
-	CFA_P40_PROF_CTXT_REMAP_MEM_SP_REC_PTR_FLD = 3,
-	CFA_P40_PROF_CTXT_REMAP_MEM_BD_ACT_EN_FLD = 4,
-	CFA_P40_PROF_CTXT_REMAP_MEM_DEFAULT_TPID_FLD = 5,
-	CFA_P40_PROF_CTXT_REMAP_MEM_ALLOWED_TPID_FLD = 6,
-	CFA_P40_PROF_CTXT_REMAP_MEM_DEFAULT_PRI_FLD = 7,
-	CFA_P40_PROF_CTXT_REMAP_MEM_ALLOWED_PRI_FLD = 8,
-	CFA_P40_PROF_CTXT_REMAP_MEM_PARIF_FLD = 9,
-	CFA_P40_PROF_CTXT_REMAP_MEM_BYP_LKUP_EN_FLD = 10,
-	CFA_P40_PROF_CTXT_REMAP_MEM_PROF_VNIC_FLD = 11,
-	CFA_P40_PROF_CTXT_REMAP_MEM_PROF_FUNC_FLD = 12,
-	CFA_P40_PROF_CTXT_REMAP_MEM_L2_CTXT_FLD = 13,
-	CFA_P40_PROF_CTXT_REMAP_MEM_ARP_FLD = 14,
-	CFA_P40_PROF_CTXT_REMAP_MEM_MAX_FLD
-};
-
-#define CFA_P40_PROF_CTXT_REMAP_MEM_TOTAL_NUM_BITS 64
-
-/**
- * Bypass action pointer look up (for idx 1 ...)
- */
-#define CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_PL_BYP_LKUP_EN_BITPOS 37
-#define CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_PL_BYP_LKUP_EN_NUM_BITS 1
-/**
- * Exact match search enable (for idx 1 ...)
- */
-#define CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_EM_SEARCH_ENB_BITPOS 36
-#define CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_EM_SEARCH_ENB_NUM_BITS 1
-/**
- * Exact match profile
- */
-#define CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_EM_PROFILE_ID_BITPOS 28
-#define CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_EM_PROFILE_ID_NUM_BITS 8
-/**
- * Exact match key format
- */
-#define CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_EM_KEY_ID_BITPOS 23
-#define CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_EM_KEY_ID_NUM_BITS 5
-/**
- * Exact match key mask
- */
-#define CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_EM_KEY_MASK_BITPOS 13
-#define CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_EM_KEY_MASK_NUM_BITS 10
-/**
- * TCAM search enable
- */
-#define CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_TCAM_SEARCH_ENB_BITPOS 12
-#define CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_TCAM_SEARCH_ENB_NUM_BITS 1
-/**
- * TCAM profile
- */
-#define CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_TCAM_PROFILE_ID_BITPOS 4
-#define CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_TCAM_PROFILE_ID_NUM_BITS 8
-/**
- * TCAM key format
- */
-#define CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_TCAM_KEY_ID_BITPOS 0
-#define CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_TCAM_KEY_ID_NUM_BITS 4
-
-#define CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_BYPASS_OPT_BITPOS 16
-#define CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_BYPASS_OPT_NUM_BITS 2
-
-#define CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_ACT_REC_PTR_BITPOS 0
-#define CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_ACT_REC_PTR_NUM_BITS 16
-
-enum cfa_p40_prof_profile_tcam_remap_mem_flds {
-	CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_PL_BYP_LKUP_EN_FLD = 0,
-	CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_EM_SEARCH_ENB_FLD = 1,
-	CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_EM_PROFILE_ID_FLD = 2,
-	CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_EM_KEY_ID_FLD = 3,
-	CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_EM_KEY_MASK_FLD = 4,
-	CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_TCAM_SEARCH_ENB_FLD = 5,
-	CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_TCAM_PROFILE_ID_FLD = 6,
-	CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_TCAM_KEY_ID_FLD = 7,
-	CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_BYPASS_OPT_FLD = 8,
-	CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_ACT_REC_PTR_FLD = 9,
-	CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_MAX_FLD
-};
-
-#define CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_TOTAL_NUM_BITS 38
-
-/**
- * Valid TCAM entry (for idx 2 ...)
- */
-#define CFA_P40_PROF_PROFILE_TCAM_VALID_BITPOS   80
-#define CFA_P40_PROF_PROFILE_TCAM_VALID_NUM_BITS 1
-/**
- * Packet type (for idx 2 ...)
- */
-#define CFA_P40_PROF_PROFILE_TCAM_PKT_TYPE_BITPOS 76
-#define CFA_P40_PROF_PROFILE_TCAM_PKT_TYPE_NUM_BITS 4
-/**
- * Pass through CFA (for idx 2 ...)
- */
-#define CFA_P40_PROF_PROFILE_TCAM_RECYCLE_CNT_BITPOS 74
-#define CFA_P40_PROF_PROFILE_TCAM_RECYCLE_CNT_NUM_BITS 2
-/**
- * Aggregate error (for idx 2 ...)
- */
-#define CFA_P40_PROF_PROFILE_TCAM_AGG_ERROR_BITPOS 73
-#define CFA_P40_PROF_PROFILE_TCAM_AGG_ERROR_NUM_BITS 1
-/**
- * Profile function (for idx 2 ...)
- */
-#define CFA_P40_PROF_PROFILE_TCAM_PROF_FUNC_BITPOS 66
-#define CFA_P40_PROF_PROFILE_TCAM_PROF_FUNC_NUM_BITS 7
-/**
- * Reserved for future use. Set to 0.
- */
-#define CFA_P40_PROF_PROFILE_TCAM_RESERVED_BITPOS 57
-#define CFA_P40_PROF_PROFILE_TCAM_RESERVED_NUM_BITS 9
-/**
- * non-tunnel(0)/tunneled(1) packet (for idx 1 ...)
- */
-#define CFA_P40_PROF_PROFILE_TCAM_HREC_NEXT_BITPOS 56
-#define CFA_P40_PROF_PROFILE_TCAM_HREC_NEXT_NUM_BITS 1
-/**
- * Tunnel L2 tunnel valid (for idx 1 ...)
- */
-#define CFA_P40_PROF_PROFILE_TCAM_TL2_HDR_VALID_BITPOS 55
-#define CFA_P40_PROF_PROFILE_TCAM_TL2_HDR_VALID_NUM_BITS 1
-/**
- * Tunnel L2 header type (for idx 1 ...)
- */
-#define CFA_P40_PROF_PROFILE_TCAM_TL2_HDR_TYPE_BITPOS 53
-#define CFA_P40_PROF_PROFILE_TCAM_TL2_HDR_TYPE_NUM_BITS 2
-/**
- * Remapped tunnel L2 dest_type UC(0)/MC(2)/BC(3) (for idx 1 ...)
- */
-#define CFA_P40_PROF_PROFILE_TCAM_TL2_UC_MC_BC_BITPOS 51
-#define CFA_P40_PROF_PROFILE_TCAM_TL2_UC_MC_BC_NUM_BITS 2
-/**
- * Tunnel L2 1+ VLAN tags present (for idx 1 ...)
- */
-#define CFA_P40_PROF_PROFILE_TCAM_TL2_VTAG_PRESENT_BITPOS 50
-#define CFA_P40_PROF_PROFILE_TCAM_TL2_VTAG_PRESENT_NUM_BITS 1
-/**
- * Tunnel L2 2 VLAN tags present (for idx 1 ...)
- */
-#define CFA_P40_PROF_PROFILE_TCAM_TL2_TWO_VTAGS_BITPOS 49
-#define CFA_P40_PROF_PROFILE_TCAM_TL2_TWO_VTAGS_NUM_BITS 1
-/**
- * Tunnel L3 valid (for idx 1 ...)
- */
-#define CFA_P40_PROF_PROFILE_TCAM_TL3_VALID_BITPOS 48
-#define CFA_P40_PROF_PROFILE_TCAM_TL3_VALID_NUM_BITS 1
-/**
- * Tunnel L3 error (for idx 1 ...)
- */
-#define CFA_P40_PROF_PROFILE_TCAM_TL3_ERROR_BITPOS 47
-#define CFA_P40_PROF_PROFILE_TCAM_TL3_ERROR_NUM_BITS 1
-/**
- * Tunnel L3 header type (for idx 1 ...)
- */
-#define CFA_P40_PROF_PROFILE_TCAM_TL3_HDR_TYPE_BITPOS 43
-#define CFA_P40_PROF_PROFILE_TCAM_TL3_HDR_TYPE_NUM_BITS 4
-/**
- * Tunnel L3 header is IPV4 or IPV6. (for idx 1 ...)
- */
-#define CFA_P40_PROF_PROFILE_TCAM_TL3_HDR_ISIP_BITPOS 42
-#define CFA_P40_PROF_PROFILE_TCAM_TL3_HDR_ISIP_NUM_BITS 1
-/**
- * Tunnel L3 IPV6 src address is compressed (for idx 1 ...)
- */
-#define CFA_P40_PROF_PROFILE_TCAM_TL3_IPV6_CMP_SRC_BITPOS 41
-#define CFA_P40_PROF_PROFILE_TCAM_TL3_IPV6_CMP_SRC_NUM_BITS 1
-/**
- * Tunnel L3 IPV6 dest address is compressed (for idx 1 ...)
- */
-#define CFA_P40_PROF_PROFILE_TCAM_TL3_IPV6_CMP_DEST_BITPOS 40
-#define CFA_P40_PROF_PROFILE_TCAM_TL3_IPV6_CMP_DEST_NUM_BITS 1
-/**
- * Tunnel L4 valid (for idx 1 ...)
- */
-#define CFA_P40_PROF_PROFILE_TCAM_TL4_HDR_VALID_BITPOS 39
-#define CFA_P40_PROF_PROFILE_TCAM_TL4_HDR_VALID_NUM_BITS 1
-/**
- * Tunnel L4 error (for idx 1 ...)
- */
-#define CFA_P40_PROF_PROFILE_TCAM_TL4_HDR_ERROR_BITPOS 38
-#define CFA_P40_PROF_PROFILE_TCAM_TL4_HDR_ERROR_NUM_BITS 1
-/**
- * Tunnel L4 header type (for idx 1 ...)
- */
-#define CFA_P40_PROF_PROFILE_TCAM_TL4_HDR_TYPE_BITPOS 34
-#define CFA_P40_PROF_PROFILE_TCAM_TL4_HDR_TYPE_NUM_BITS 4
-/**
- * Tunnel L4 header is UDP or TCP (for idx 1 ...)
- */
-#define CFA_P40_PROF_PROFILE_TCAM_TL4_HDR_IS_UDP_TCP_BITPOS 33
-#define CFA_P40_PROF_PROFILE_TCAM_TL4_HDR_IS_UDP_TCP_NUM_BITS 1
-/**
- * Tunnel valid (for idx 1 ...)
- */
-#define CFA_P40_PROF_PROFILE_TCAM_TUN_HDR_VALID_BITPOS 32
-#define CFA_P40_PROF_PROFILE_TCAM_TUN_HDR_VALID_NUM_BITS 1
-/**
- * Tunnel error
- */
-#define CFA_P40_PROF_PROFILE_TCAM_TUN_HDR_ERR_BITPOS 31
-#define CFA_P40_PROF_PROFILE_TCAM_TUN_HDR_ERR_NUM_BITS 1
-/**
- * Tunnel header type
- */
-#define CFA_P40_PROF_PROFILE_TCAM_TUN_HDR_TYPE_BITPOS 27
-#define CFA_P40_PROF_PROFILE_TCAM_TUN_HDR_TYPE_NUM_BITS 4
-/**
- * Tunnel header flags
- */
-#define CFA_P40_PROF_PROFILE_TCAM_TUN_HDR_FLAGS_BITPOS 24
-#define CFA_P40_PROF_PROFILE_TCAM_TUN_HDR_FLAGS_NUM_BITS 3
-/**
- * L2 header valid
- */
-#define CFA_P40_PROF_PROFILE_TCAM_L2_HDR_VALID_BITPOS 23
-#define CFA_P40_PROF_PROFILE_TCAM_L2_HDR_VALID_NUM_BITS 1
-/**
- * L2 header error
- */
-#define CFA_P40_PROF_PROFILE_TCAM_L2_HDR_ERROR_BITPOS 22
-#define CFA_P40_PROF_PROFILE_TCAM_L2_HDR_ERROR_NUM_BITS 1
-/**
- * L2 header type
- */
-#define CFA_P40_PROF_PROFILE_TCAM_L2_HDR_TYPE_BITPOS 20
-#define CFA_P40_PROF_PROFILE_TCAM_L2_HDR_TYPE_NUM_BITS 2
-/**
- * Remapped L2 dest_type UC(0)/MC(2)/BC(3)
- */
-#define CFA_P40_PROF_PROFILE_TCAM_L2_UC_MC_BC_BITPOS 18
-#define CFA_P40_PROF_PROFILE_TCAM_L2_UC_MC_BC_NUM_BITS 2
-/**
- * L2 header 1+ VLAN tags present
- */
-#define CFA_P40_PROF_PROFILE_TCAM_L2_VTAG_PRESENT_BITPOS 17
-#define CFA_P40_PROF_PROFILE_TCAM_L2_VTAG_PRESENT_NUM_BITS 1
-/**
- * L2 header 2 VLAN tags present
- */
-#define CFA_P40_PROF_PROFILE_TCAM_L2_TWO_VTAGS_BITPOS 16
-#define CFA_P40_PROF_PROFILE_TCAM_L2_TWO_VTAGS_NUM_BITS 1
-/**
- * L3 header valid
- */
-#define CFA_P40_PROF_PROFILE_TCAM_L3_VALID_BITPOS 15
-#define CFA_P40_PROF_PROFILE_TCAM_L3_VALID_NUM_BITS 1
-/**
- * L3 header error
- */
-#define CFA_P40_PROF_PROFILE_TCAM_L3_ERROR_BITPOS 14
-#define CFA_P40_PROF_PROFILE_TCAM_L3_ERROR_NUM_BITS 1
-/**
- * L3 header type
- */
-#define CFA_P40_PROF_PROFILE_TCAM_L3_HDR_TYPE_BITPOS 10
-#define CFA_P40_PROF_PROFILE_TCAM_L3_HDR_TYPE_NUM_BITS 4
-/**
- * L3 header is IPV4 or IPV6.
- */
-#define CFA_P40_PROF_PROFILE_TCAM_L3_HDR_ISIP_BITPOS 9
-#define CFA_P40_PROF_PROFILE_TCAM_L3_HDR_ISIP_NUM_BITS 1
-/**
- * L3 header IPV6 src address is compressed
- */
-#define CFA_P40_PROF_PROFILE_TCAM_L3_IPV6_CMP_SRC_BITPOS 8
-#define CFA_P40_PROF_PROFILE_TCAM_L3_IPV6_CMP_SRC_NUM_BITS 1
-/**
- * L3 header IPV6 dest address is compressed
- */
-#define CFA_P40_PROF_PROFILE_TCAM_L3_IPV6_CMP_DEST_BITPOS 7
-#define CFA_P40_PROF_PROFILE_TCAM_L3_IPV6_CMP_DEST_NUM_BITS 1
-/**
- * L4 header valid
- */
-#define CFA_P40_PROF_PROFILE_TCAM_L4_HDR_VALID_BITPOS 6
-#define CFA_P40_PROF_PROFILE_TCAM_L4_HDR_VALID_NUM_BITS 1
-/**
- * L4 header error
- */
-#define CFA_P40_PROF_PROFILE_TCAM_L4_HDR_ERROR_BITPOS 5
-#define CFA_P40_PROF_PROFILE_TCAM_L4_HDR_ERROR_NUM_BITS 1
-/**
- * L4 header type
- */
-#define CFA_P40_PROF_PROFILE_TCAM_L4_HDR_TYPE_BITPOS 1
-#define CFA_P40_PROF_PROFILE_TCAM_L4_HDR_TYPE_NUM_BITS 4
-/**
- * L4 header is UDP or TCP
- */
-#define CFA_P40_PROF_PROFILE_TCAM_L4_HDR_IS_UDP_TCP_BITPOS 0
-#define CFA_P40_PROF_PROFILE_TCAM_L4_HDR_IS_UDP_TCP_NUM_BITS 1
-
-enum cfa_p40_prof_profile_tcam_flds {
-	CFA_P40_PROF_PROFILE_TCAM_VALID_FLD = 0,
-	CFA_P40_PROF_PROFILE_TCAM_PKT_TYPE_FLD = 1,
-	CFA_P40_PROF_PROFILE_TCAM_RECYCLE_CNT_FLD = 2,
-	CFA_P40_PROF_PROFILE_TCAM_AGG_ERROR_FLD = 3,
-	CFA_P40_PROF_PROFILE_TCAM_PROF_FUNC_FLD = 4,
-	CFA_P40_PROF_PROFILE_TCAM_RESERVED_FLD = 5,
-	CFA_P40_PROF_PROFILE_TCAM_HREC_NEXT_FLD = 6,
-	CFA_P40_PROF_PROFILE_TCAM_TL2_HDR_VALID_FLD = 7,
-	CFA_P40_PROF_PROFILE_TCAM_TL2_HDR_TYPE_FLD = 8,
-	CFA_P40_PROF_PROFILE_TCAM_TL2_UC_MC_BC_FLD = 9,
-	CFA_P40_PROF_PROFILE_TCAM_TL2_VTAG_PRESENT_FLD = 10,
-	CFA_P40_PROF_PROFILE_TCAM_TL2_TWO_VTAGS_FLD = 11,
-	CFA_P40_PROF_PROFILE_TCAM_TL3_VALID_FLD = 12,
-	CFA_P40_PROF_PROFILE_TCAM_TL3_ERROR_FLD = 13,
-	CFA_P40_PROF_PROFILE_TCAM_TL3_HDR_TYPE_FLD = 14,
-	CFA_P40_PROF_PROFILE_TCAM_TL3_HDR_ISIP_FLD = 15,
-	CFA_P40_PROF_PROFILE_TCAM_TL3_IPV6_CMP_SRC_FLD = 16,
-	CFA_P40_PROF_PROFILE_TCAM_TL3_IPV6_CMP_DEST_FLD = 17,
-	CFA_P40_PROF_PROFILE_TCAM_TL4_HDR_VALID_FLD = 18,
-	CFA_P40_PROF_PROFILE_TCAM_TL4_HDR_ERROR_FLD = 19,
-	CFA_P40_PROF_PROFILE_TCAM_TL4_HDR_TYPE_FLD = 20,
-	CFA_P40_PROF_PROFILE_TCAM_TL4_HDR_IS_UDP_TCP_FLD = 21,
-	CFA_P40_PROF_PROFILE_TCAM_TUN_HDR_VALID_FLD = 22,
-	CFA_P40_PROF_PROFILE_TCAM_TUN_HDR_ERR_FLD = 23,
-	CFA_P40_PROF_PROFILE_TCAM_TUN_HDR_TYPE_FLD = 24,
-	CFA_P40_PROF_PROFILE_TCAM_TUN_HDR_FLAGS_FLD = 25,
-	CFA_P40_PROF_PROFILE_TCAM_L2_HDR_VALID_FLD = 26,
-	CFA_P40_PROF_PROFILE_TCAM_L2_HDR_ERROR_FLD = 27,
-	CFA_P40_PROF_PROFILE_TCAM_L2_HDR_TYPE_FLD = 28,
-	CFA_P40_PROF_PROFILE_TCAM_L2_UC_MC_BC_FLD = 29,
-	CFA_P40_PROF_PROFILE_TCAM_L2_VTAG_PRESENT_FLD = 30,
-	CFA_P40_PROF_PROFILE_TCAM_L2_TWO_VTAGS_FLD = 31,
-	CFA_P40_PROF_PROFILE_TCAM_L3_VALID_FLD = 32,
-	CFA_P40_PROF_PROFILE_TCAM_L3_ERROR_FLD = 33,
-	CFA_P40_PROF_PROFILE_TCAM_L3_HDR_TYPE_FLD = 34,
-	CFA_P40_PROF_PROFILE_TCAM_L3_HDR_ISIP_FLD = 35,
-	CFA_P40_PROF_PROFILE_TCAM_L3_IPV6_CMP_SRC_FLD = 36,
-	CFA_P40_PROF_PROFILE_TCAM_L3_IPV6_CMP_DEST_FLD = 37,
-	CFA_P40_PROF_PROFILE_TCAM_L4_HDR_VALID_FLD = 38,
-	CFA_P40_PROF_PROFILE_TCAM_L4_HDR_ERROR_FLD = 39,
-	CFA_P40_PROF_PROFILE_TCAM_L4_HDR_TYPE_FLD = 40,
-	CFA_P40_PROF_PROFILE_TCAM_L4_HDR_IS_UDP_TCP_FLD = 41,
-	CFA_P40_PROF_PROFILE_TCAM_MAX_FLD
-};
-
-#define CFA_P40_PROF_PROFILE_TCAM_TOTAL_NUM_BITS 81
-
-/**
- * CFA flexible key layout definition
- */
-enum cfa_p40_key_fld_id {
-	CFA_P40_KEY_FLD_ID_MAX
-};
-
-/**************************************************************************/
-/**
- * Non-autogenerated fields
- */
-
-/**
- * Valid
- */
-#define CFA_P40_EEM_KEY_TBL_VALID_BITPOS 0
-#define CFA_P40_EEM_KEY_TBL_VALID_NUM_BITS 1
-
-/**
- * L1 Cacheable
- */
-#define CFA_P40_EEM_KEY_TBL_L1_CACHEABLE_BITPOS 1
-#define CFA_P40_EEM_KEY_TBL_L1_CACHEABLE_NUM_BITS 1
-
-/**
- * Strength
- */
-#define CFA_P40_EEM_KEY_TBL_STRENGTH_BITPOS 2
-#define CFA_P40_EEM_KEY_TBL_STRENGTH_NUM_BITS 2
-
-/**
- * Key Size
- */
-#define CFA_P40_EEM_KEY_TBL_KEY_SZ_BITPOS 15
-#define CFA_P40_EEM_KEY_TBL_KEY_SZ_NUM_BITS 9
-
-/**
- * Record Size
- */
-#define CFA_P40_EEM_KEY_TBL_REC_SZ_BITPOS 24
-#define CFA_P40_EEM_KEY_TBL_REC_SZ_NUM_BITS 5
-
-/**
- * Action Record Internal
- */
-#define CFA_P40_EEM_KEY_TBL_ACT_REC_INT_BITPOS 29
-#define CFA_P40_EEM_KEY_TBL_ACT_REC_INT_NUM_BITS 1
-
-/**
- * External Flow Counter
- */
-#define CFA_P40_EEM_KEY_TBL_EXT_FLOW_CTR_BITPOS 30
-#define CFA_P40_EEM_KEY_TBL_EXT_FLOW_CTR_NUM_BITS 1
-
-/**
- * Action Record Pointer
- */
-#define CFA_P40_EEM_KEY_TBL_AR_PTR_BITPOS 31
-#define CFA_P40_EEM_KEY_TBL_AR_PTR_NUM_BITS 33
-
-/**
- * EEM Key omitted - create using keybuilder
- * Fields here cannot be larger than a uint64_t
- */
-
-#define CFA_P40_EEM_KEY_TBL_TOTAL_NUM_BITS 64
-
-enum cfa_p40_eem_key_tbl_flds {
-	CFA_P40_EEM_KEY_TBL_VALID_FLD = 0,
-	CFA_P40_EEM_KEY_TBL_L1_CACHEABLE_FLD = 1,
-	CFA_P40_EEM_KEY_TBL_STRENGTH_FLD = 2,
-	CFA_P40_EEM_KEY_TBL_KEY_SZ_FLD = 3,
-	CFA_P40_EEM_KEY_TBL_REC_SZ_FLD = 4,
-	CFA_P40_EEM_KEY_TBL_ACT_REC_INT_FLD = 5,
-	CFA_P40_EEM_KEY_TBL_EXT_FLOW_CTR_FLD = 6,
-	CFA_P40_EEM_KEY_TBL_AR_PTR_FLD = 7,
-	CFA_P40_EEM_KEY_TBL_MAX_FLD
-};
-
-/**
- * Mirror Destination 0 Source Property Record Pointer
- */
-#define CFA_P40_MIRROR_TBL_SP_PTR_BITPOS 0
-#define CFA_P40_MIRROR_TBL_SP_PTR_NUM_BITS 11
-
-/**
- * ignore or honor drop
- */
-#define CFA_P40_MIRROR_TBL_IGN_DROP_BITPOS 13
-#define CFA_P40_MIRROR_TBL_IGN_DROP_NUM_BITS 1
-
-/**
- * ingress or egress copy
- */
-#define CFA_P40_MIRROR_TBL_COPY_BITPOS 14
-#define CFA_P40_MIRROR_TBL_COPY_NUM_BITS 1
-
-/**
- * Mirror Destination enable.
- */
-#define CFA_P40_MIRROR_TBL_EN_BITPOS 15
-#define CFA_P40_MIRROR_TBL_EN_NUM_BITS 1
-
-/**
- * Action Record Pointer
- */
-#define CFA_P40_MIRROR_TBL_AR_PTR_BITPOS 16
-#define CFA_P40_MIRROR_TBL_AR_PTR_NUM_BITS 16
-
-#define CFA_P40_MIRROR_TBL_TOTAL_NUM_BITS 32
-
-enum cfa_p40_mirror_tbl_flds {
-	CFA_P40_MIRROR_TBL_SP_PTR_FLD = 0,
-	CFA_P40_MIRROR_TBL_IGN_DROP_FLD = 1,
-	CFA_P40_MIRROR_TBL_COPY_FLD = 2,
-	CFA_P40_MIRROR_TBL_EN_FLD = 3,
-	CFA_P40_MIRROR_TBL_AR_PTR_FLD = 4,
-	CFA_P40_MIRROR_TBL_MAX_FLD
-};
-
-/**
- * P45 Specific Updates (SR) - Non-autogenerated
- */
-/**
- * Valid TCAM entry.
- */
-#define CFA_P45_PROF_L2_CTXT_TCAM_VALID_BITPOS   166
-#define CFA_P45_PROF_L2_CTXT_TCAM_VALID_NUM_BITS 1
-/**
- * Source Partition.
- */
-#define CFA_P45_PROF_L2_CTXT_TCAM_SPARIF_BITPOS  166
-#define CFA_P45_PROF_L2_CTXT_TCAM_SPARIF_NUM_BITS 4
-
-/**
- * Source Virtual I/F.
- */
-#define CFA_P45_PROF_L2_CTXT_TCAM_SVIF_BITPOS    72
-#define CFA_P45_PROF_L2_CTXT_TCAM_SVIF_NUM_BITS  12
-
-
-/* The SR layout of the l2 ctxt key is different from the Wh+.  Switch to
- * cfa_p45_hw.h definition when available.
- */
-enum cfa_p45_prof_l2_ctxt_tcam_flds {
-	CFA_P45_PROF_L2_CTXT_TCAM_VALID_FLD = 0,
-	CFA_P45_PROF_L2_CTXT_TCAM_SPARIF_FLD = 1,
-	CFA_P45_PROF_L2_CTXT_TCAM_KEY_TYPE_FLD = 2,
-	CFA_P45_PROF_L2_CTXT_TCAM_TUN_HDR_TYPE_FLD = 3,
-	CFA_P45_PROF_L2_CTXT_TCAM_T_L2_NUMTAGS_FLD = 4,
-	CFA_P45_PROF_L2_CTXT_TCAM_L2_NUMTAGS_FLD = 5,
-	CFA_P45_PROF_L2_CTXT_TCAM_MAC1_FLD = 6,
-	CFA_P45_PROF_L2_CTXT_TCAM_T_OVID_FLD = 7,
-	CFA_P45_PROF_L2_CTXT_TCAM_T_IVID_FLD = 8,
-	CFA_P45_PROF_L2_CTXT_TCAM_SVIF_FLD = 9,
-	CFA_P45_PROF_L2_CTXT_TCAM_MAC0_FLD = 10,
-	CFA_P45_PROF_L2_CTXT_TCAM_OVID_FLD = 11,
-	CFA_P45_PROF_L2_CTXT_TCAM_IVID_FLD = 12,
-	CFA_P45_PROF_L2_CTXT_TCAM_MAX_FLD
-};
-
-#define CFA_P45_PROF_L2_CTXT_TCAM_TOTAL_NUM_BITS 171
-
-#endif /* _CFA_P40_HW_H_ */
diff --git a/drivers/net/bnxt/hcapi/cfa_p40_tbl.h b/drivers/net/bnxt/hcapi/cfa_p40_tbl.h
deleted file mode 100644
index 539241ad0e..0000000000
--- a/drivers/net/bnxt/hcapi/cfa_p40_tbl.h
+++ /dev/null
@@ -1,303 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2019-2021 Broadcom
- * All rights reserved.
- */
-/*
- * Name:  cfa_p40_tbl.h
- *
- * Description: header for SWE based on Truflow
- *
- * Date:  12/16/19 17:18:12
- *
- * Note:  This file was originally generated by tflib_decode.py.
- *        Remainder is hand coded due to lack of availability of xml for
- *        additional tables at this time (EEM Record and union fields)
- *
- **/
-#ifndef _CFA_P40_TBL_H_
-#define _CFA_P40_TBL_H_
-
-#include "cfa_p40_hw.h"
-
-#include "hcapi_cfa_defs.h"
-
-const struct hcapi_cfa_field cfa_p40_prof_l2_ctxt_tcam_layout[] = {
-	{CFA_P40_PROF_L2_CTXT_TCAM_VALID_BITPOS,
-	 CFA_P40_PROF_L2_CTXT_TCAM_VALID_NUM_BITS},
-	{CFA_P40_PROF_L2_CTXT_TCAM_KEY_TYPE_BITPOS,
-	 CFA_P40_PROF_L2_CTXT_TCAM_KEY_TYPE_NUM_BITS},
-	{CFA_P40_PROF_L2_CTXT_TCAM_TUN_HDR_TYPE_BITPOS,
-	 CFA_P40_PROF_L2_CTXT_TCAM_TUN_HDR_TYPE_NUM_BITS},
-	{CFA_P40_PROF_L2_CTXT_TCAM_T_L2_NUMTAGS_BITPOS,
-	 CFA_P40_PROF_L2_CTXT_TCAM_T_L2_NUMTAGS_NUM_BITS},
-	{CFA_P40_PROF_L2_CTXT_TCAM_L2_NUMTAGS_BITPOS,
-	 CFA_P40_PROF_L2_CTXT_TCAM_L2_NUMTAGS_NUM_BITS},
-	{CFA_P40_PROF_L2_CTXT_TCAM_MAC1_BITPOS,
-	 CFA_P40_PROF_L2_CTXT_TCAM_MAC1_NUM_BITS},
-	{CFA_P40_PROF_L2_CTXT_TCAM_T_OVID_BITPOS,
-	 CFA_P40_PROF_L2_CTXT_TCAM_T_OVID_NUM_BITS},
-	{CFA_P40_PROF_L2_CTXT_TCAM_T_IVID_BITPOS,
-	 CFA_P40_PROF_L2_CTXT_TCAM_T_IVID_NUM_BITS},
-	{CFA_P40_PROF_L2_CTXT_TCAM_SPARIF_BITPOS,
-	 CFA_P40_PROF_L2_CTXT_TCAM_SPARIF_NUM_BITS},
-	{CFA_P40_PROF_L2_CTXT_TCAM_SVIF_BITPOS,
-	 CFA_P40_PROF_L2_CTXT_TCAM_SVIF_NUM_BITS},
-	{CFA_P40_PROF_L2_CTXT_TCAM_MAC0_BITPOS,
-	 CFA_P40_PROF_L2_CTXT_TCAM_MAC0_NUM_BITS},
-	{CFA_P40_PROF_L2_CTXT_TCAM_OVID_BITPOS,
-	 CFA_P40_PROF_L2_CTXT_TCAM_OVID_NUM_BITS},
-	{CFA_P40_PROF_L2_CTXT_TCAM_IVID_BITPOS,
-	 CFA_P40_PROF_L2_CTXT_TCAM_IVID_NUM_BITS},
-};
-
-const struct hcapi_cfa_field cfa_p40_act_veb_tcam_layout[] = {
-	{CFA_P40_ACT_VEB_TCAM_VALID_BITPOS,
-	 CFA_P40_ACT_VEB_TCAM_VALID_NUM_BITS},
-	{CFA_P40_ACT_VEB_TCAM_RESERVED_BITPOS,
-	 CFA_P40_ACT_VEB_TCAM_RESERVED_NUM_BITS},
-	{CFA_P40_ACT_VEB_TCAM_PARIF_IN_BITPOS,
-	 CFA_P40_ACT_VEB_TCAM_PARIF_IN_NUM_BITS},
-	{CFA_P40_ACT_VEB_TCAM_NUM_VTAGS_BITPOS,
-	 CFA_P40_ACT_VEB_TCAM_NUM_VTAGS_NUM_BITS},
-	{CFA_P40_ACT_VEB_TCAM_MAC_BITPOS,
-	 CFA_P40_ACT_VEB_TCAM_MAC_NUM_BITS},
-	{CFA_P40_ACT_VEB_TCAM_OVID_BITPOS,
-	 CFA_P40_ACT_VEB_TCAM_OVID_NUM_BITS},
-	{CFA_P40_ACT_VEB_TCAM_IVID_BITPOS,
-	 CFA_P40_ACT_VEB_TCAM_IVID_NUM_BITS},
-};
-
-const struct hcapi_cfa_field cfa_p40_lkup_tcam_record_mem_layout[] = {
-	{CFA_P40_LKUP_TCAM_RECORD_MEM_VALID_BITPOS,
-	 CFA_P40_LKUP_TCAM_RECORD_MEM_VALID_NUM_BITS},
-	{CFA_P40_LKUP_TCAM_RECORD_MEM_ACT_REC_PTR_BITPOS,
-	 CFA_P40_LKUP_TCAM_RECORD_MEM_ACT_REC_PTR_NUM_BITS},
-	{CFA_P40_LKUP_TCAM_RECORD_MEM_STRENGTH_BITPOS,
-	 CFA_P40_LKUP_TCAM_RECORD_MEM_STRENGTH_NUM_BITS},
-};
-
-const struct hcapi_cfa_field cfa_p40_prof_ctxt_remap_mem_layout[] = {
-	{CFA_P40_PROF_CTXT_REMAP_MEM_TPID_ANTI_SPOOF_CTL_BITPOS,
-	 CFA_P40_PROF_CTXT_REMAP_MEM_TPID_ANTI_SPOOF_CTL_NUM_BITS},
-	{CFA_P40_PROF_CTXT_REMAP_MEM_PRI_ANTI_SPOOF_CTL_BITPOS,
-	 CFA_P40_PROF_CTXT_REMAP_MEM_PRI_ANTI_SPOOF_CTL_NUM_BITS},
-	{CFA_P40_PROF_CTXT_REMAP_MEM_BYP_SP_LKUP_BITPOS,
-	 CFA_P40_PROF_CTXT_REMAP_MEM_BYP_SP_LKUP_NUM_BITS},
-	{CFA_P40_PROF_CTXT_REMAP_MEM_SP_REC_PTR_BITPOS,
-	 CFA_P40_PROF_CTXT_REMAP_MEM_SP_REC_PTR_NUM_BITS},
-	{CFA_P40_PROF_CTXT_REMAP_MEM_BD_ACT_EN_BITPOS,
-	 CFA_P40_PROF_CTXT_REMAP_MEM_BD_ACT_EN_NUM_BITS},
-	{CFA_P40_PROF_CTXT_REMAP_MEM_DEFAULT_TPID_BITPOS,
-	 CFA_P40_PROF_CTXT_REMAP_MEM_DEFAULT_TPID_NUM_BITS},
-	{CFA_P40_PROF_CTXT_REMAP_MEM_ALLOWED_TPID_BITPOS,
-	 CFA_P40_PROF_CTXT_REMAP_MEM_ALLOWED_TPID_NUM_BITS},
-	{CFA_P40_PROF_CTXT_REMAP_MEM_DEFAULT_PRI_BITPOS,
-	 CFA_P40_PROF_CTXT_REMAP_MEM_DEFAULT_PRI_NUM_BITS},
-	{CFA_P40_PROF_CTXT_REMAP_MEM_ALLOWED_PRI_BITPOS,
-	 CFA_P40_PROF_CTXT_REMAP_MEM_ALLOWED_PRI_NUM_BITS},
-	{CFA_P40_PROF_CTXT_REMAP_MEM_PARIF_BITPOS,
-	 CFA_P40_PROF_CTXT_REMAP_MEM_PARIF_NUM_BITS},
-	{CFA_P40_PROF_CTXT_REMAP_MEM_BYP_LKUP_EN_BITPOS,
-	 CFA_P40_PROF_CTXT_REMAP_MEM_BYP_LKUP_EN_NUM_BITS},
-	/* Fields below not generated through automation */
-	{CFA_P40_PROF_CTXT_REMAP_MEM_PROF_VNIC_BITPOS,
-	 CFA_P40_PROF_CTXT_REMAP_MEM_PROF_VNIC_NUM_BITS},
-	{CFA_P40_PROF_CTXT_REMAP_MEM_PROF_FUNC_BITPOS,
-	 CFA_P40_PROF_CTXT_REMAP_MEM_PROF_FUNC_NUM_BITS},
-	{CFA_P40_PROF_CTXT_REMAP_MEM_L2_CTXT_BITPOS,
-	 CFA_P40_PROF_CTXT_REMAP_MEM_L2_CTXT_NUM_BITS},
-	{CFA_P40_PROF_CTXT_REMAP_MEM_ARP_BITPOS,
-	 CFA_P40_PROF_CTXT_REMAP_MEM_ARP_NUM_BITS},
-};
-
-const struct hcapi_cfa_field cfa_p40_prof_profile_tcam_remap_mem_layout[] = {
-	{CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_PL_BYP_LKUP_EN_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_PL_BYP_LKUP_EN_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_EM_SEARCH_ENB_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_EM_SEARCH_ENB_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_EM_PROFILE_ID_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_EM_PROFILE_ID_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_EM_KEY_ID_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_EM_KEY_ID_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_EM_KEY_MASK_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_EM_KEY_MASK_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_TCAM_SEARCH_ENB_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_TCAM_SEARCH_ENB_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_TCAM_PROFILE_ID_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_TCAM_PROFILE_ID_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_TCAM_KEY_ID_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_TCAM_KEY_ID_NUM_BITS},
-	/* Fields below not generated through automation */
-	{CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_BYPASS_OPT_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_BYPASS_OPT_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_ACT_REC_PTR_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_ACT_REC_PTR_NUM_BITS},
-};
-
-const struct hcapi_cfa_field cfa_p40_prof_profile_tcam_layout[] = {
-	{CFA_P40_PROF_PROFILE_TCAM_VALID_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_VALID_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_PKT_TYPE_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_PKT_TYPE_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_RECYCLE_CNT_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_RECYCLE_CNT_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_AGG_ERROR_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_AGG_ERROR_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_PROF_FUNC_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_PROF_FUNC_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_RESERVED_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_RESERVED_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_HREC_NEXT_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_HREC_NEXT_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_TL2_HDR_VALID_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_TL2_HDR_VALID_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_TL2_HDR_TYPE_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_TL2_HDR_TYPE_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_TL2_UC_MC_BC_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_TL2_UC_MC_BC_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_TL2_VTAG_PRESENT_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_TL2_VTAG_PRESENT_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_TL2_TWO_VTAGS_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_TL2_TWO_VTAGS_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_TL3_VALID_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_TL3_VALID_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_TL3_ERROR_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_TL3_ERROR_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_TL3_HDR_TYPE_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_TL3_HDR_TYPE_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_TL3_HDR_ISIP_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_TL3_HDR_ISIP_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_TL3_IPV6_CMP_SRC_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_TL3_IPV6_CMP_SRC_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_TL3_IPV6_CMP_DEST_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_TL3_IPV6_CMP_DEST_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_TL4_HDR_VALID_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_TL4_HDR_VALID_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_TL4_HDR_ERROR_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_TL4_HDR_ERROR_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_TL4_HDR_TYPE_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_TL4_HDR_TYPE_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_TL4_HDR_IS_UDP_TCP_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_TL4_HDR_IS_UDP_TCP_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_TUN_HDR_VALID_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_TUN_HDR_VALID_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_TUN_HDR_ERR_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_TUN_HDR_ERR_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_TUN_HDR_TYPE_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_TUN_HDR_TYPE_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_TUN_HDR_FLAGS_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_TUN_HDR_FLAGS_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_L2_HDR_VALID_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_L2_HDR_VALID_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_L2_HDR_ERROR_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_L2_HDR_ERROR_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_L2_HDR_TYPE_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_L2_HDR_TYPE_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_L2_UC_MC_BC_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_L2_UC_MC_BC_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_L2_VTAG_PRESENT_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_L2_VTAG_PRESENT_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_L2_TWO_VTAGS_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_L2_TWO_VTAGS_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_L3_VALID_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_L3_VALID_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_L3_ERROR_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_L3_ERROR_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_L3_HDR_TYPE_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_L3_HDR_TYPE_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_L3_HDR_ISIP_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_L3_HDR_ISIP_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_L3_IPV6_CMP_SRC_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_L3_IPV6_CMP_SRC_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_L3_IPV6_CMP_DEST_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_L3_IPV6_CMP_DEST_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_L4_HDR_VALID_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_L4_HDR_VALID_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_L4_HDR_ERROR_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_L4_HDR_ERROR_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_L4_HDR_TYPE_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_L4_HDR_TYPE_NUM_BITS},
-	{CFA_P40_PROF_PROFILE_TCAM_L4_HDR_IS_UDP_TCP_BITPOS,
-	 CFA_P40_PROF_PROFILE_TCAM_L4_HDR_IS_UDP_TCP_NUM_BITS},
-};
-
-/**************************************************************************/
-/**
- * Non-autogenerated fields
- */
-
-const struct hcapi_cfa_field cfa_p40_eem_key_tbl_layout[] = {
-	{CFA_P40_EEM_KEY_TBL_VALID_BITPOS,
-	 CFA_P40_EEM_KEY_TBL_VALID_NUM_BITS},
-
-	{CFA_P40_EEM_KEY_TBL_L1_CACHEABLE_BITPOS,
-	 CFA_P40_EEM_KEY_TBL_L1_CACHEABLE_NUM_BITS},
-
-	{CFA_P40_EEM_KEY_TBL_STRENGTH_BITPOS,
-	 CFA_P40_EEM_KEY_TBL_STRENGTH_NUM_BITS},
-
-	{CFA_P40_EEM_KEY_TBL_KEY_SZ_BITPOS,
-	 CFA_P40_EEM_KEY_TBL_KEY_SZ_NUM_BITS},
-
-	{CFA_P40_EEM_KEY_TBL_REC_SZ_BITPOS,
-	 CFA_P40_EEM_KEY_TBL_REC_SZ_NUM_BITS},
-
-	{CFA_P40_EEM_KEY_TBL_ACT_REC_INT_BITPOS,
-	 CFA_P40_EEM_KEY_TBL_ACT_REC_INT_NUM_BITS},
-
-	{CFA_P40_EEM_KEY_TBL_EXT_FLOW_CTR_BITPOS,
-	 CFA_P40_EEM_KEY_TBL_EXT_FLOW_CTR_NUM_BITS},
-
-	{CFA_P40_EEM_KEY_TBL_AR_PTR_BITPOS,
-	 CFA_P40_EEM_KEY_TBL_AR_PTR_NUM_BITS},
-
-};
-
-const struct hcapi_cfa_field cfa_p40_mirror_tbl_layout[] = {
-	{CFA_P40_MIRROR_TBL_SP_PTR_BITPOS,
-	 CFA_P40_MIRROR_TBL_SP_PTR_NUM_BITS},
-
-	{CFA_P40_MIRROR_TBL_IGN_DROP_BITPOS,
-	 CFA_P40_MIRROR_TBL_IGN_DROP_NUM_BITS},
-
-	{CFA_P40_MIRROR_TBL_COPY_BITPOS,
-	 CFA_P40_MIRROR_TBL_COPY_NUM_BITS},
-
-	{CFA_P40_MIRROR_TBL_EN_BITPOS,
-	 CFA_P40_MIRROR_TBL_EN_NUM_BITS},
-
-	{CFA_P40_MIRROR_TBL_AR_PTR_BITPOS,
-	 CFA_P40_MIRROR_TBL_AR_PTR_NUM_BITS},
-};
-
-/* P45 Defines */
-
-const struct hcapi_cfa_field cfa_p45_prof_l2_ctxt_tcam_layout[] = {
-	{CFA_P45_PROF_L2_CTXT_TCAM_VALID_BITPOS,
-	 CFA_P45_PROF_L2_CTXT_TCAM_VALID_NUM_BITS},
-	{CFA_P45_PROF_L2_CTXT_TCAM_SPARIF_BITPOS,
-	 CFA_P45_PROF_L2_CTXT_TCAM_SPARIF_NUM_BITS},
-	{CFA_P40_PROF_L2_CTXT_TCAM_KEY_TYPE_BITPOS,
-	 CFA_P40_PROF_L2_CTXT_TCAM_KEY_TYPE_NUM_BITS},
-	{CFA_P40_PROF_L2_CTXT_TCAM_TUN_HDR_TYPE_BITPOS,
-	 CFA_P40_PROF_L2_CTXT_TCAM_TUN_HDR_TYPE_NUM_BITS},
-	{CFA_P40_PROF_L2_CTXT_TCAM_T_L2_NUMTAGS_BITPOS,
-	 CFA_P40_PROF_L2_CTXT_TCAM_T_L2_NUMTAGS_NUM_BITS},
-	{CFA_P40_PROF_L2_CTXT_TCAM_L2_NUMTAGS_BITPOS,
-	 CFA_P40_PROF_L2_CTXT_TCAM_L2_NUMTAGS_NUM_BITS},
-	{CFA_P40_PROF_L2_CTXT_TCAM_MAC1_BITPOS,
-	 CFA_P40_PROF_L2_CTXT_TCAM_MAC1_NUM_BITS},
-	{CFA_P40_PROF_L2_CTXT_TCAM_T_OVID_BITPOS,
-	 CFA_P40_PROF_L2_CTXT_TCAM_T_OVID_NUM_BITS},
-	{CFA_P40_PROF_L2_CTXT_TCAM_T_IVID_BITPOS,
-	 CFA_P40_PROF_L2_CTXT_TCAM_T_IVID_NUM_BITS},
-	{CFA_P45_PROF_L2_CTXT_TCAM_SVIF_BITPOS,
-	 CFA_P45_PROF_L2_CTXT_TCAM_SVIF_NUM_BITS},
-	{CFA_P40_PROF_L2_CTXT_TCAM_MAC0_BITPOS,
-	 CFA_P40_PROF_L2_CTXT_TCAM_MAC0_NUM_BITS},
-	{CFA_P40_PROF_L2_CTXT_TCAM_OVID_BITPOS,
-	 CFA_P40_PROF_L2_CTXT_TCAM_OVID_NUM_BITS},
-	{CFA_P40_PROF_L2_CTXT_TCAM_IVID_BITPOS,
-	 CFA_P40_PROF_L2_CTXT_TCAM_IVID_NUM_BITS},
-};
-#endif /* _CFA_P40_TBL_H_ */
diff --git a/drivers/net/bnxt/meson.build b/drivers/net/bnxt/meson.build
index 117c753489..f7a4e7a013 100644
--- a/drivers/net/bnxt/meson.build
+++ b/drivers/net/bnxt/meson.build
@@ -8,10 +8,17 @@ if is_windows
     subdir_done()
 endif
 
-headers = files('rte_pmd_bnxt.h')
+cflags_options = [
+        '-DSUPPORT_CFA_HW_ALL=1',
+]
+
+foreach option:cflags_options
+        if cc.has_argument(option)
+                cflags += option
+        endif
+endforeach
 
-includes += include_directories('tf_ulp')
-includes += include_directories('tf_core')
+headers = files('rte_pmd_bnxt.h')
 
 sources = files(
         'bnxt_cpr.c',
@@ -30,53 +37,6 @@ sources = files(
         'bnxt_vnic.c',
         'bnxt_reps.c',
 
-        'tf_core/tf_core.c',
-        'tf_core/bitalloc.c',
-        'tf_core/tf_msg.c',
-        'tf_core/rand.c',
-        'tf_core/stack.c',
-        'tf_core/tf_em_common.c',
-        'tf_core/tf_em_internal.c',
-        'tf_core/tf_rm.c',
-        'tf_core/tf_tbl.c',
-        'tf_core/tfp.c',
-        'tf_core/tf_session.c',
-        'tf_core/tf_device.c',
-        'tf_core/tf_device_p4.c',
-        'tf_core/tf_identifier.c',
-        'tf_core/tf_shadow_tbl.c',
-        'tf_core/tf_shadow_tcam.c',
-        'tf_core/tf_tcam.c',
-        'tf_core/tf_util.c',
-        'tf_core/tf_if_tbl.c',
-        'tf_core/ll.c',
-        'tf_core/tf_global_cfg.c',
-        'tf_core/tf_em_host.c',
-        'tf_core/tf_shadow_identifier.c',
-        'tf_core/tf_hash.c',
-
-        'hcapi/hcapi_cfa_p4.c',
-
-        'tf_ulp/bnxt_ulp.c',
-        'tf_ulp/ulp_mark_mgr.c',
-        'tf_ulp/ulp_flow_db.c',
-        'tf_ulp/ulp_template_db_tbl.c',
-        'tf_ulp/ulp_template_db_class.c',
-        'tf_ulp/ulp_template_db_act.c',
-        'tf_ulp/ulp_utils.c',
-        'tf_ulp/ulp_mapper.c',
-        'tf_ulp/ulp_matcher.c',
-        'tf_ulp/ulp_rte_parser.c',
-        'tf_ulp/bnxt_ulp_flow.c',
-        'tf_ulp/ulp_port_db.c',
-        'tf_ulp/ulp_def_rules.c',
-        'tf_ulp/ulp_fc_mgr.c',
-        'tf_ulp/ulp_tun.c',
-        'tf_ulp/ulp_template_db_wh_plus_act.c',
-        'tf_ulp/ulp_template_db_wh_plus_class.c',
-        'tf_ulp/ulp_template_db_stingray_act.c',
-        'tf_ulp/ulp_template_db_stingray_class.c',
-
         'rte_pmd_bnxt.c',
 )
 
@@ -85,3 +45,8 @@ if arch_subdir == 'x86'
 elif arch_subdir == 'arm' and host_machine.cpu_family().startswith('aarch64')
     sources += files('bnxt_rxtx_vec_neon.c')
 endif
+
+#Add the subdirectories that need to be compiled
+subdir('tf_ulp')
+subdir('tf_core')
+subdir('hcapi/cfa')
diff --git a/drivers/net/bnxt/tf_core/meson.build b/drivers/net/bnxt/tf_core/meson.build
new file mode 100644
index 0000000000..b23e0fbe70
--- /dev/null
+++ b/drivers/net/bnxt/tf_core/meson.build
@@ -0,0 +1,33 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 Intel Corporation
+# Copyright(c) 2021 Broadcom
+
+#Include the folder for headers
+includes += include_directories('.')
+
+#Add the source files
+sources += files(
+        'tf_core.c',
+        'bitalloc.c',
+        'tf_msg.c',
+        'rand.c',
+        'stack.c',
+        'tf_em_common.c',
+        'tf_em_internal.c',
+        'tf_rm.c',
+        'tf_tbl.c',
+        'tfp.c',
+        'tf_session.c',
+        'tf_device.c',
+        'tf_device_p4.c',
+        'tf_identifier.c',
+        'tf_shadow_tbl.c',
+        'tf_shadow_tcam.c',
+        'tf_tcam.c',
+        'tf_util.c',
+        'tf_if_tbl.c',
+        'll.c',
+        'tf_global_cfg.c',
+        'tf_em_host.c',
+        'tf_shadow_identifier.c',
+        'tf_hash.c')
diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h
index a47edff1e3..5e458c58fb 100644
--- a/drivers/net/bnxt/tf_core/tf_core.h
+++ b/drivers/net/bnxt/tf_core/tf_core.h
@@ -10,7 +10,7 @@
 #include <stdlib.h>
 #include <stdbool.h>
 #include <stdio.h>
-#include "hcapi/hcapi_cfa_defs.h"
+#include "hcapi/cfa/hcapi_cfa_defs.h"
 #include "tf_project.h"
 
 /**
diff --git a/drivers/net/bnxt/tf_core/tf_em.h b/drivers/net/bnxt/tf_core/tf_em.h
index 23591272bd..b5c3acb09a 100644
--- a/drivers/net/bnxt/tf_core/tf_em.h
+++ b/drivers/net/bnxt/tf_core/tf_em.h
@@ -9,7 +9,7 @@
 #include "tf_core.h"
 #include "tf_session.h"
 
-#include "hcapi/hcapi_cfa_defs.h"
+#include "hcapi/cfa/hcapi_cfa_defs.h"
 
 #define TF_EM_MIN_ENTRIES     (1 << 15) /* 32K */
 #define TF_EM_MAX_ENTRIES     (1 << 27) /* 128M */
diff --git a/drivers/net/bnxt/tf_ulp/meson.build b/drivers/net/bnxt/tf_ulp/meson.build
new file mode 100644
index 0000000000..98cbdf3177
--- /dev/null
+++ b/drivers/net/bnxt/tf_ulp/meson.build
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 Intel Corporation
+# Copyright(c) 2021 Broadcom
+
+#Include the folder for headers
+includes += include_directories('.')
+
+#Add the source files
+sources += files(
+        'bnxt_ulp.c',
+        'ulp_mark_mgr.c',
+        'ulp_flow_db.c',
+        'ulp_template_db_tbl.c',
+        'ulp_template_db_class.c',
+        'ulp_template_db_act.c',
+        'ulp_utils.c',
+        'ulp_mapper.c',
+        'ulp_matcher.c',
+        'ulp_rte_parser.c',
+        'bnxt_ulp_flow.c',
+        'ulp_port_db.c',
+        'ulp_def_rules.c',
+        'ulp_fc_mgr.c',
+        'ulp_tun.c',
+        'ulp_template_db_wh_plus_act.c',
+        'ulp_template_db_wh_plus_class.c',
+        'ulp_template_db_stingray_act.c',
+        'ulp_template_db_stingray_class.c')
-- 
2.17.1


^ permalink raw reply	[flat|nested] 129+ messages in thread

* [dpdk-dev] [PATCH 02/58] net/bnxt: add base TRUFLOW support for Thor
  2021-05-30  8:58 [dpdk-dev] [PATCH 00/58] enhancements to host based flow table management Venkat Duvvuru
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 01/58] net/bnxt: add CFA folder to HCAPI directory Venkat Duvvuru
@ 2021-05-30  8:58 ` Venkat Duvvuru
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 03/58] net/bnxt: add mailbox selection via dev op Venkat Duvvuru
                   ` (56 subsequent siblings)
  58 siblings, 0 replies; 129+ messages in thread
From: Venkat Duvvuru @ 2021-05-30  8:58 UTC (permalink / raw)
  To: dev; +Cc: Farah Smith, Peter Spreadborough, Randy Schacher, Venkat Duvvuru

From: Farah Smith <farah.smith@broadcom.com>

Add infrastructure code to support TRUFLOW on Thor NICs.
Also update meson.build

Signed-off-by: Farah Smith <farah.smith@broadcom.com>
Signed-off-by: Peter Spreadborough <peter.spreadborough@broadcom.com>
Signed-off-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Randy Schacher <stuart.schacher@broadcom.com>
---
 drivers/net/bnxt/tf_core/cfa_resource_types.h |   1 -
 drivers/net/bnxt/tf_core/meson.build          |   1 +
 drivers/net/bnxt/tf_core/tf_core.c            |   1 +
 drivers/net/bnxt/tf_core/tf_device.c          | 207 +++++++++++++
 drivers/net/bnxt/tf_core/tf_device.h          |  24 ++
 drivers/net/bnxt/tf_core/tf_device_p4.c       | 111 ++++++-
 drivers/net/bnxt/tf_core/tf_device_p4.h       |   3 +-
 drivers/net/bnxt/tf_core/tf_device_p58.c      | 284 ++++++++++++++++++
 drivers/net/bnxt/tf_core/tf_device_p58.h      |  79 +++++
 drivers/net/bnxt/tf_core/tf_em_common.c       |   4 +-
 drivers/net/bnxt/tf_core/tf_msg.c             |  33 --
 drivers/net/bnxt/tf_core/tf_rm.c              |   8 +-
 drivers/net/bnxt/tf_core/tf_shadow_tcam.c     |   4 +-
 13 files changed, 711 insertions(+), 49 deletions(-)
 create mode 100644 drivers/net/bnxt/tf_core/tf_device_p58.c
 create mode 100644 drivers/net/bnxt/tf_core/tf_device_p58.h

diff --git a/drivers/net/bnxt/tf_core/cfa_resource_types.h b/drivers/net/bnxt/tf_core/cfa_resource_types.h
index f55a98a388..b63b87bcf3 100644
--- a/drivers/net/bnxt/tf_core/cfa_resource_types.h
+++ b/drivers/net/bnxt/tf_core/cfa_resource_types.h
@@ -254,5 +254,4 @@
 #define CFA_RESOURCE_TYPE_P4_TBL_SCOPE           0x22UL
 #define CFA_RESOURCE_TYPE_P4_LAST               CFA_RESOURCE_TYPE_P4_TBL_SCOPE
 
-
 #endif /* _CFA_RESOURCE_TYPES_H_ */
diff --git a/drivers/net/bnxt/tf_core/meson.build b/drivers/net/bnxt/tf_core/meson.build
index b23e0fbe70..d7e8f664fd 100644
--- a/drivers/net/bnxt/tf_core/meson.build
+++ b/drivers/net/bnxt/tf_core/meson.build
@@ -20,6 +20,7 @@ sources += files(
         'tf_session.c',
         'tf_device.c',
         'tf_device_p4.c',
+        'tf_device_p58.c',
         'tf_identifier.c',
         'tf_shadow_tbl.c',
         'tf_shadow_tcam.c',
diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c
index feec3cf459..b1ce4e721c 100644
--- a/drivers/net/bnxt/tf_core/tf_core.c
+++ b/drivers/net/bnxt/tf_core/tf_core.c
@@ -35,6 +35,7 @@ tf_open_session(struct tf *tfp,
 	 * firmware open session succeeds.
 	 */
 	if (parms->device_type != TF_DEVICE_TYPE_WH &&
+	    parms->device_type != TF_DEVICE_TYPE_THOR &&
 	    parms->device_type != TF_DEVICE_TYPE_SR) {
 		TFP_DRV_LOG(ERR,
 			    "Unsupported device type %d\n",
diff --git a/drivers/net/bnxt/tf_core/tf_device.c b/drivers/net/bnxt/tf_core/tf_device.c
index f68eb723fe..9c63f6d5d4 100644
--- a/drivers/net/bnxt/tf_core/tf_device.c
+++ b/drivers/net/bnxt/tf_core/tf_device.c
@@ -5,6 +5,7 @@
 
 #include "tf_device.h"
 #include "tf_device_p4.h"
+#include "tf_device_p58.h"
 #include "tfp.h"
 #include "tf_em.h"
 
@@ -12,6 +13,7 @@ struct tf;
 
 /* Forward declarations */
 static int tf_dev_unbind_p4(struct tf *tfp);
+static int tf_dev_unbind_p58(struct tf *tfp);
 
 /**
  * Device specific bind function, WH+
@@ -234,6 +236,203 @@ tf_dev_unbind_p4(struct tf *tfp)
 	return rc;
 }
 
+/**
+ * Device specific bind function, THOR
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [in] shadow_copy
+ *   Flag controlling shadow copy DB creation
+ *
+ * [in] resources
+ *   Pointer to resource allocation information
+ *
+ * [out] dev_handle
+ *   Device handle
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on parameter or internal failure.
+ */
+static int
+tf_dev_bind_p58(struct tf *tfp,
+		bool shadow_copy,
+		struct tf_session_resources *resources,
+		struct tf_dev_info *dev_handle)
+{
+	int rc;
+	int frc;
+	struct tf_ident_cfg_parms ident_cfg;
+	struct tf_tbl_cfg_parms tbl_cfg;
+	struct tf_tcam_cfg_parms tcam_cfg;
+	struct tf_em_cfg_parms em_cfg;
+	struct tf_if_tbl_cfg_parms if_tbl_cfg;
+	struct tf_global_cfg_cfg_parms global_cfg;
+
+	/* Initial function initialization */
+	dev_handle->ops = &tf_dev_ops_p58_init;
+
+	/* Initialize the modules */
+
+	ident_cfg.num_elements = TF_IDENT_TYPE_MAX;
+	ident_cfg.cfg = tf_ident_p58;
+	ident_cfg.shadow_copy = shadow_copy;
+	ident_cfg.resources = resources;
+	rc = tf_ident_bind(tfp, &ident_cfg);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Identifier initialization failure\n");
+		goto fail;
+	}
+
+	tbl_cfg.num_elements = TF_TBL_TYPE_MAX;
+	tbl_cfg.cfg = tf_tbl_p58;
+	tbl_cfg.shadow_copy = shadow_copy;
+	tbl_cfg.resources = resources;
+	rc = tf_tbl_bind(tfp, &tbl_cfg);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Table initialization failure\n");
+		goto fail;
+	}
+
+	tcam_cfg.num_elements = TF_TCAM_TBL_TYPE_MAX;
+	tcam_cfg.cfg = tf_tcam_p58;
+	tcam_cfg.shadow_copy = shadow_copy;
+	tcam_cfg.resources = resources;
+	rc = tf_tcam_bind(tfp, &tcam_cfg);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "TCAM initialization failure\n");
+		goto fail;
+	}
+
+	/*
+	 * EM
+	 */
+	em_cfg.num_elements = TF_EM_TBL_TYPE_MAX;
+	em_cfg.cfg = tf_em_int_p58;
+	em_cfg.resources = resources;
+	em_cfg.mem_type = 0; /* Not used by EM */
+
+	rc = tf_em_int_bind(tfp, &em_cfg);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "EM initialization failure\n");
+		goto fail;
+	}
+
+	/*
+	 * IF_TBL
+	 */
+	if_tbl_cfg.num_elements = TF_IF_TBL_TYPE_MAX;
+	if_tbl_cfg.cfg = tf_if_tbl_p58;
+	if_tbl_cfg.shadow_copy = shadow_copy;
+	rc = tf_if_tbl_bind(tfp, &if_tbl_cfg);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "IF Table initialization failure\n");
+		goto fail;
+	}
+
+	/*
+	 * GLOBAL_CFG
+	 */
+	global_cfg.num_elements = TF_GLOBAL_CFG_TYPE_MAX;
+	global_cfg.cfg = tf_global_cfg_p58;
+	rc = tf_global_cfg_bind(tfp, &global_cfg);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Global Cfg initialization failure\n");
+		goto fail;
+	}
+
+	/* Final function initialization */
+	dev_handle->ops = &tf_dev_ops_p58;
+
+	return 0;
+
+ fail:
+	/* Cleanup of already created modules */
+	frc = tf_dev_unbind_p58(tfp);
+	if (frc)
+		return frc;
+
+	return rc;
+}
+
+/**
+ * Device specific unbind function, THOR
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+static int
+	tf_dev_unbind_p58(struct tf *tfp)
+{
+	int rc = 0;
+	bool fail = false;
+
+	/* Unbind all the support modules. As this is only done on
+	 * close we only report errors as everything has to be cleaned
+	 * up regardless.
+	 *
+	 * In case of residuals TCAMs are cleaned up first as to
+	 * invalidate the pipeline in a clean manner.
+	 */
+	rc = tf_tcam_unbind(tfp);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Device unbind failed, TCAM\n");
+		fail = true;
+	}
+
+	rc = tf_ident_unbind(tfp);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Device unbind failed, Identifier\n");
+		fail = true;
+	}
+
+	rc = tf_tbl_unbind(tfp);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Device unbind failed, Table Type\n");
+		fail = true;
+	}
+
+	rc = tf_em_int_unbind(tfp);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Device unbind failed, EM\n");
+		fail = true;
+	}
+
+	rc = tf_if_tbl_unbind(tfp);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Device unbind failed, IF Table Type\n");
+		fail = true;
+	}
+
+	rc = tf_global_cfg_unbind(tfp);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Device unbind failed, Global Cfg Type\n");
+		fail = true;
+	}
+
+	if (fail)
+		return -1;
+
+	return rc;
+}
+
 int
 tf_dev_bind(struct tf *tfp __rte_unused,
 	    enum tf_device_type type,
@@ -249,6 +448,12 @@ tf_dev_bind(struct tf *tfp __rte_unused,
 				      shadow_copy,
 				      resources,
 				      dev_handle);
+	case TF_DEVICE_TYPE_THOR:
+		dev_handle->type = type;
+		return tf_dev_bind_p58(tfp,
+				       shadow_copy,
+				       resources,
+				       dev_handle);
 	default:
 		TFP_DRV_LOG(ERR,
 			    "No such device\n");
@@ -264,6 +469,8 @@ tf_dev_unbind(struct tf *tfp,
 	case TF_DEVICE_TYPE_WH:
 	case TF_DEVICE_TYPE_SR:
 		return tf_dev_unbind_p4(tfp);
+	case TF_DEVICE_TYPE_THOR:
+		return tf_dev_unbind_p58(tfp);
 	default:
 		TFP_DRV_LOG(ERR,
 			    "No such device\n");
diff --git a/drivers/net/bnxt/tf_core/tf_device.h b/drivers/net/bnxt/tf_core/tf_device.h
index d0c4ec80d0..d5ef72309f 100644
--- a/drivers/net/bnxt/tf_core/tf_device.h
+++ b/drivers/net/bnxt/tf_core/tf_device.h
@@ -134,6 +134,28 @@ struct tf_dev_ops {
 	int (*tf_dev_get_max_types)(struct tf *tfp,
 				    uint16_t *max_types);
 
+	/**
+	 * Retrieves the string description for the CFA resource
+	 * type
+	 *
+	 * [in] tfp
+	 *   Pointer to TF handle
+	 *
+	 * [in] resource_id
+	 *   HCAPI cfa resource type id
+	 *
+	 * [out] resource_str
+	 *   Pointer to a string
+	 *
+	 * Returns
+	 *   - (0) if successful.
+	 *   - (-EINVAL) on failure.
+	 */
+	int (*tf_dev_get_resource_str)(struct tf *tfp,
+				       uint16_t resource_id,
+				       const char **resource_str);
+
+
 	/**
 	 * Retrieves the WC TCAM slice information that the device
 	 * supports.
@@ -709,5 +731,7 @@ struct tf_dev_ops {
  */
 extern const struct tf_dev_ops tf_dev_ops_p4_init;
 extern const struct tf_dev_ops tf_dev_ops_p4;
+extern const struct tf_dev_ops tf_dev_ops_p58_init;
+extern const struct tf_dev_ops tf_dev_ops_p58;
 
 #endif /* _TF_DEVICE_H_ */
diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.c b/drivers/net/bnxt/tf_core/tf_device_p4.c
index 17d2f05bcc..257a0fb2d0 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p4.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p4.c
@@ -4,8 +4,8 @@
  */
 
 #include <rte_common.h>
-#include <cfa_resource_types.h>
 
+#include "cfa_resource_types.h"
 #include "tf_device.h"
 #include "tf_identifier.h"
 #include "tf_tbl.h"
@@ -17,6 +17,79 @@
 #define TF_DEV_P4_PARIF_MAX 16
 #define TF_DEV_P4_PF_MASK 0xfUL
 
+const char *tf_resource_str_p4[CFA_RESOURCE_TYPE_P4_LAST + 1] = {
+	/* CFA_RESOURCE_TYPE_P4_MCG */
+	"mc_group",
+	/* CFA_RESOURCE_TYPE_P4_ENCAP_8B */
+	"encap_8 ",
+	/* CFA_RESOURCE_TYPE_P4_ENCAP_16B */
+	"encap_16",
+	/* CFA_RESOURCE_TYPE_P4_ENCAP_64B */
+	"encap_64",
+	/* CFA_RESOURCE_TYPE_P4_SP_MAC */
+	"sp_mac  ",
+	/* CFA_RESOURCE_TYPE_P4_SP_MAC_IPV4 */
+	"sp_macv4",
+	/* CFA_RESOURCE_TYPE_P4_SP_MAC_IPV6 */
+	"sp_macv6",
+	/* CFA_RESOURCE_TYPE_P4_COUNTER_64B */
+	"ctr_64b ",
+	/* CFA_RESOURCE_TYPE_P4_NAT_PORT */
+	"nat_port",
+	/* CFA_RESOURCE_TYPE_P4_NAT_IPV4 */
+	"nat_ipv4",
+	/* CFA_RESOURCE_TYPE_P4_METER */
+	"meter   ",
+	/* CFA_RESOURCE_TYPE_P4_FLOW_STATE */
+	"flow_st ",
+	/* CFA_RESOURCE_TYPE_P4_FULL_ACTION */
+	"full_act",
+	/* CFA_RESOURCE_TYPE_P4_FORMAT_0_ACTION */
+	"fmt0_act",
+	/* CFA_RESOURCE_TYPE_P4_EXT_FORMAT_0_ACTION */
+	"ext0_act",
+	/* CFA_RESOURCE_TYPE_P4_FORMAT_1_ACTION */
+	"fmt1_act",
+	/* CFA_RESOURCE_TYPE_P4_FORMAT_2_ACTION */
+	"fmt2_act",
+	/* CFA_RESOURCE_TYPE_P4_FORMAT_3_ACTION */
+	"fmt3_act",
+	/* CFA_RESOURCE_TYPE_P4_FORMAT_4_ACTION */
+	"fmt4_act",
+	/* CFA_RESOURCE_TYPE_P4_FORMAT_5_ACTION */
+	"fmt5_act",
+	/* CFA_RESOURCE_TYPE_P4_FORMAT_6_ACTION */
+	"fmt6_act",
+	/* CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_HIGH */
+	"l2ctx_hi",
+	/* CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_LOW */
+	"l2ctx_lo",
+	/* CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP_HIGH */
+	"l2ctr_hi",
+	/* CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP_LOW */
+	"l2ctr_lo",
+	/* CFA_RESOURCE_TYPE_P4_PROF_FUNC */
+	"prf_func",
+	/* CFA_RESOURCE_TYPE_P4_PROF_TCAM */
+	"prf_tcam",
+	/* CFA_RESOURCE_TYPE_P4_EM_PROF_ID */
+	"em_prof ",
+	/* CFA_RESOURCE_TYPE_P4_EM_REC */
+	"em_rec  ",
+	/* CFA_RESOURCE_TYPE_P4_WC_TCAM_PROF_ID */
+	"wc_prof ",
+	/* CFA_RESOURCE_TYPE_P4_WC_TCAM */
+	"wc_tcam ",
+	/* CFA_RESOURCE_TYPE_P4_METER_PROF */
+	"mtr_prof",
+	/* CFA_RESOURCE_TYPE_P4_MIRROR */
+	"mirror  ",
+	/* CFA_RESOURCE_TYPE_P4_SP_TCAM */
+	"sp_tcam ",
+	/* CFA_RESOURCE_TYPE_P4_TBL_SCOPE */
+	"tb_scope",
+};
+
 /**
  * Device specific function that retrieves the MAX number of HCAPI
  * types the device supports.
@@ -25,7 +98,7 @@
  *   Pointer to TF handle
  *
  * [out] max_types
- *   Pointer to the MAX number of HCAPI types supported
+ *   Pointer to the MAX number of CFA resource types supported
  *
  * Returns
  *   - (0) if successful.
@@ -61,6 +134,38 @@ tf_dev_p4_get_max_types(struct tf *tfp,
 
 	return 0;
 }
+/**
+ * Device specific function that retrieves a human readable
+ * string to identify a CFA resource type.
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [in] resource_id
+ *   HCAPI CFA resource id
+ *
+ * [out] resource_str
+ *   Resource string
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+static int
+tf_dev_p4_get_resource_str(struct tf *tfp __rte_unused,
+			   uint16_t resource_id,
+			   const char **resource_str)
+{
+	if (resource_str == NULL)
+		return -EINVAL;
+
+	if (resource_id > CFA_RESOURCE_TYPE_P4_LAST)
+		return -EINVAL;
+
+	*resource_str = tf_resource_str_p4[resource_id];
+
+	return 0;
+}
 
 /**
  * Device specific function that retrieves the WC TCAM slices the
@@ -142,6 +247,7 @@ tf_dev_p4_map_parif(struct tf *tfp __rte_unused,
  */
 const struct tf_dev_ops tf_dev_ops_p4_init = {
 	.tf_dev_get_max_types = tf_dev_p4_get_max_types,
+	.tf_dev_get_resource_str = tf_dev_p4_get_resource_str,
 	.tf_dev_get_tcam_slice_info = tf_dev_p4_get_tcam_slice_info,
 	.tf_dev_alloc_ident = NULL,
 	.tf_dev_free_ident = NULL,
@@ -179,6 +285,7 @@ const struct tf_dev_ops tf_dev_ops_p4_init = {
  */
 const struct tf_dev_ops tf_dev_ops_p4 = {
 	.tf_dev_get_max_types = tf_dev_p4_get_max_types,
+	.tf_dev_get_resource_str = tf_dev_p4_get_resource_str,
 	.tf_dev_get_tcam_slice_info = tf_dev_p4_get_tcam_slice_info,
 	.tf_dev_alloc_ident = tf_ident_alloc,
 	.tf_dev_free_ident = tf_ident_free,
diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.h b/drivers/net/bnxt/tf_core/tf_device_p4.h
index 81ed2322d1..bfad02a0b8 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p4.h
+++ b/drivers/net/bnxt/tf_core/tf_device_p4.h
@@ -6,8 +6,7 @@
 #ifndef _TF_DEVICE_P4_H_
 #define _TF_DEVICE_P4_H_
 
-#include <cfa_resource_types.h>
-
+#include "cfa_resource_types.h"
 #include "tf_core.h"
 #include "tf_rm.h"
 #include "tf_if_tbl.h"
diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c
new file mode 100644
index 0000000000..fb5ad29a5c
--- /dev/null
+++ b/drivers/net/bnxt/tf_core/tf_device_p58.c
@@ -0,0 +1,284 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019-2021 Broadcom
+ * All rights reserved.
+ */
+
+#include <rte_common.h>
+
+#include "cfa_resource_types.h"
+#include "tf_device.h"
+#include "tf_identifier.h"
+#include "tf_tbl.h"
+#include "tf_tcam.h"
+#include "tf_em.h"
+#include "tf_if_tbl.h"
+#include "tfp.h"
+
+#define TF_DEV_P58_PARIF_MAX 16
+#define TF_DEV_P58_PF_MASK 0xfUL
+
+const char *tf_resource_str_p58[CFA_RESOURCE_TYPE_P58_LAST + 1] = {
+	/* CFA_RESOURCE_TYPE_P58_METER */
+	"meter   ",
+	/* CFA_RESOURCE_TYPE_P58_SRAM_BANK_0 */
+	"sram_bk0",
+	/* CFA_RESOURCE_TYPE_P58_SRAM_BANK_1 */
+	"sram_bk1",
+	/* CFA_RESOURCE_TYPE_P58_SRAM_BANK_2 */
+	"sram_bk2",
+	/* CFA_RESOURCE_TYPE_P58_SRAM_BANK_3 */
+	"sram_bk3",
+	/* CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_HIGH */
+	"l2ctx_hi",
+	/* CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_LOW */
+	"l2ctx_lo",
+	/* CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP_HIGH */
+	"l2ctr_hi",
+	/* CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP_LOW */
+	"l2ctr_lo",
+	/* CFA_RESOURCE_TYPE_P58_PROF_FUNC */
+	"prf_func",
+	/* CFA_RESOURCE_TYPE_P58_PROF_TCAM */
+	"prf_tcam",
+	/* CFA_RESOURCE_TYPE_P58_EM_PROF_ID */
+	"em_prof ",
+	/* CFA_RESOURCE_TYPE_P58_WC_TCAM_PROF_ID */
+	"wc_prof ",
+	/* CFA_RESOURCE_TYPE_P58_EM_REC */
+	"em_rec  ",
+	/* CFA_RESOURCE_TYPE_P58_WC_TCAM */
+	"wc_tcam ",
+	/* CFA_RESOURCE_TYPE_P58_METER_PROF */
+	"mtr_prof",
+	/* CFA_RESOURCE_TYPE_P58_MIRROR */
+	"mirror  ",
+	/* CFA_RESOURCE_TYPE_P58_EM_FKB */
+	"em_fkb  ",
+	/* CFA_RESOURCE_TYPE_P58_WC_FKB */
+	"wc_fkb  ",
+	/* CFA_RESOURCE_TYPE_P58_VEB_TCAM */
+	"veb     ",
+};
+
+/**
+ * Device specific function that retrieves the MAX number of HCAPI
+ * types the device supports.
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [out] max_types
+ *   Pointer to the MAX number of HCAPI types supported
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+static int
+tf_dev_p58_get_max_types(struct tf *tfp,
+			uint16_t *max_types)
+{
+	struct tf_session *tfs;
+	struct tf_dev_info *dev;
+	int rc;
+
+	if (max_types == NULL || tfp == NULL)
+		return -EINVAL;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session(tfp, &tfs);
+	if (rc)
+		return rc;
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc)
+		return rc;
+
+	*max_types = CFA_RESOURCE_TYPE_P58_LAST + 1;
+
+	return 0;
+}
+/**
+ * Device specific function that retrieves a human readable
+ * string to identify a CFA resource type.
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [in] resource_id
+ *   HCAPI CFA resource id
+ *
+ * [out] resource_str
+ *   Resource string
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+static int
+tf_dev_p58_get_resource_str(struct tf *tfp __rte_unused,
+			    uint16_t resource_id,
+			    const char **resource_str)
+{
+	if (resource_str == NULL)
+		return -EINVAL;
+
+	if (resource_id > CFA_RESOURCE_TYPE_P58_LAST)
+		return -EINVAL;
+
+	*resource_str = tf_resource_str_p58[resource_id];
+
+	return 0;
+}
+
+/**
+ * Device specific function that retrieves the WC TCAM slices the
+ * device supports.
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [out] slice_size
+ *   Pointer to the WC TCAM slice size
+ *
+ * [out] num_slices_per_row
+ *   Pointer to the WC TCAM row slice configuration
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+static int
+tf_dev_p58_get_tcam_slice_info(struct tf *tfp __rte_unused,
+			      enum tf_tcam_tbl_type type,
+			      uint16_t key_sz,
+			      uint16_t *num_slices_per_row)
+{
+#define CFA_P58_WC_TCAM_SLICES_PER_ROW 2
+#define CFA_P58_WC_TCAM_SLICE_SIZE     12
+
+	if (type == TF_TCAM_TBL_TYPE_WC_TCAM) {
+		*num_slices_per_row = CFA_P58_WC_TCAM_SLICES_PER_ROW;
+		if (key_sz > *num_slices_per_row * CFA_P58_WC_TCAM_SLICE_SIZE)
+			return -ENOTSUP;
+
+		*num_slices_per_row = 1;
+	} else { /* for other type of tcam */
+		*num_slices_per_row = 1;
+	}
+
+	return 0;
+}
+
+static int
+tf_dev_p58_map_parif(struct tf *tfp __rte_unused,
+		    uint16_t parif_bitmask,
+		    uint16_t pf,
+		    uint8_t *data,
+		    uint8_t *mask,
+		    uint16_t sz_in_bytes)
+{
+	uint32_t parif_pf[2] = { 0 };
+	uint32_t parif_pf_mask[2] = { 0 };
+	uint32_t parif;
+	uint32_t shift;
+
+	if (sz_in_bytes != sizeof(uint64_t))
+		return -ENOTSUP;
+
+	for (parif = 0; parif < TF_DEV_P58_PARIF_MAX; parif++) {
+		if (parif_bitmask & (1UL << parif)) {
+			if (parif < 8) {
+				shift = 4 * parif;
+				parif_pf_mask[0] |= TF_DEV_P58_PF_MASK << shift;
+				parif_pf[0] |= pf << shift;
+			} else {
+				shift = 4 * (parif - 8);
+				parif_pf_mask[1] |= TF_DEV_P58_PF_MASK << shift;
+				parif_pf[1] |= pf << shift;
+			}
+		}
+	}
+	tfp_memcpy(data, parif_pf, sz_in_bytes);
+	tfp_memcpy(mask, parif_pf_mask, sz_in_bytes);
+
+	return 0;
+}
+
+
+/**
+ * Truflow P58 device specific functions
+ */
+const struct tf_dev_ops tf_dev_ops_p58_init = {
+	.tf_dev_get_max_types = tf_dev_p58_get_max_types,
+	.tf_dev_get_resource_str = tf_dev_p58_get_resource_str,
+	.tf_dev_get_tcam_slice_info = tf_dev_p58_get_tcam_slice_info,
+	.tf_dev_alloc_ident = NULL,
+	.tf_dev_free_ident = NULL,
+	.tf_dev_search_ident = NULL,
+	.tf_dev_alloc_ext_tbl = NULL,
+	.tf_dev_alloc_tbl = NULL,
+	.tf_dev_free_ext_tbl = NULL,
+	.tf_dev_free_tbl = NULL,
+	.tf_dev_alloc_search_tbl = NULL,
+	.tf_dev_set_tbl = NULL,
+	.tf_dev_set_ext_tbl = NULL,
+	.tf_dev_get_tbl = NULL,
+	.tf_dev_get_bulk_tbl = NULL,
+	.tf_dev_alloc_tcam = NULL,
+	.tf_dev_free_tcam = NULL,
+	.tf_dev_alloc_search_tcam = NULL,
+	.tf_dev_set_tcam = NULL,
+	.tf_dev_get_tcam = NULL,
+	.tf_dev_insert_int_em_entry = NULL,
+	.tf_dev_delete_int_em_entry = NULL,
+	.tf_dev_insert_ext_em_entry = NULL,
+	.tf_dev_delete_ext_em_entry = NULL,
+	.tf_dev_alloc_tbl_scope = NULL,
+	.tf_dev_map_tbl_scope = NULL,
+	.tf_dev_map_parif = NULL,
+	.tf_dev_free_tbl_scope = NULL,
+	.tf_dev_set_if_tbl = NULL,
+	.tf_dev_get_if_tbl = NULL,
+	.tf_dev_set_global_cfg = NULL,
+	.tf_dev_get_global_cfg = NULL,
+};
+
+/**
+ * Truflow P58 device specific functions
+ */
+const struct tf_dev_ops tf_dev_ops_p58 = {
+	.tf_dev_get_max_types = tf_dev_p58_get_max_types,
+	.tf_dev_get_resource_str = tf_dev_p58_get_resource_str,
+	.tf_dev_get_tcam_slice_info = tf_dev_p58_get_tcam_slice_info,
+	.tf_dev_alloc_ident = tf_ident_alloc,
+	.tf_dev_free_ident = tf_ident_free,
+	.tf_dev_search_ident = tf_ident_search,
+	.tf_dev_alloc_tbl = tf_tbl_alloc,
+	.tf_dev_alloc_ext_tbl = tf_tbl_ext_alloc,
+	.tf_dev_free_tbl = tf_tbl_free,
+	.tf_dev_free_ext_tbl = tf_tbl_ext_free,
+	.tf_dev_alloc_search_tbl = tf_tbl_alloc_search,
+	.tf_dev_set_tbl = tf_tbl_set,
+	.tf_dev_set_ext_tbl = tf_tbl_ext_common_set,
+	.tf_dev_get_tbl = tf_tbl_get,
+	.tf_dev_get_bulk_tbl = tf_tbl_bulk_get,
+	.tf_dev_alloc_tcam = tf_tcam_alloc,
+	.tf_dev_free_tcam = tf_tcam_free,
+	.tf_dev_alloc_search_tcam = tf_tcam_alloc_search,
+	.tf_dev_set_tcam = tf_tcam_set,
+	.tf_dev_get_tcam = NULL,
+	.tf_dev_insert_int_em_entry = tf_em_insert_int_entry,
+	.tf_dev_delete_int_em_entry = tf_em_delete_int_entry,
+	.tf_dev_insert_ext_em_entry = tf_em_insert_ext_entry,
+	.tf_dev_delete_ext_em_entry = tf_em_delete_ext_entry,
+	.tf_dev_alloc_tbl_scope = tf_em_ext_common_alloc,
+	.tf_dev_map_tbl_scope = tf_em_ext_map_tbl_scope,
+	.tf_dev_map_parif = tf_dev_p58_map_parif,
+	.tf_dev_free_tbl_scope = tf_em_ext_common_free,
+	.tf_dev_set_if_tbl = tf_if_tbl_set,
+	.tf_dev_get_if_tbl = tf_if_tbl_get,
+	.tf_dev_set_global_cfg = tf_global_cfg_set,
+	.tf_dev_get_global_cfg = tf_global_cfg_get,
+};
diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.h b/drivers/net/bnxt/tf_core/tf_device_p58.h
new file mode 100644
index 0000000000..3d6e3240bf
--- /dev/null
+++ b/drivers/net/bnxt/tf_core/tf_device_p58.h
@@ -0,0 +1,79 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019-2021 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _TF_DEVICE_P58_H_
+#define _TF_DEVICE_P58_H_
+
+#include "cfa_resource_types.h"
+#include "tf_core.h"
+#include "tf_rm.h"
+#include "tf_if_tbl.h"
+#include "tf_global_cfg.h"
+
+struct tf_rm_element_cfg tf_ident_p58[TF_IDENT_TYPE_MAX] = {
+	[TF_IDENT_TYPE_L2_CTXT_HIGH] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP_HIGH
+	},
+	[TF_IDENT_TYPE_L2_CTXT_LOW] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP_LOW
+	},
+	[TF_IDENT_TYPE_PROF_FUNC] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_PROF_FUNC
+	},
+	[TF_IDENT_TYPE_WC_PROF] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_WC_TCAM_PROF_ID
+	},
+	[TF_IDENT_TYPE_EM_PROF] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_EM_PROF_ID
+	},
+};
+
+struct tf_rm_element_cfg tf_tcam_p58[TF_TCAM_TBL_TYPE_MAX] = {
+	[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_HIGH] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_HIGH
+	},
+	[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_LOW] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_LOW
+	},
+	[TF_TCAM_TBL_TYPE_PROF_TCAM] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_PROF_TCAM
+	},
+	[TF_TCAM_TBL_TYPE_WC_TCAM] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_WC_TCAM
+	},
+	[TF_TCAM_TBL_TYPE_VEB_TCAM] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_VEB_TCAM
+	},
+};
+
+struct tf_rm_element_cfg tf_tbl_p58[TF_TBL_TYPE_MAX] = {
+	[TF_TBL_TYPE_METER_PROF] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_METER_PROF
+	},
+	[TF_TBL_TYPE_METER_INST] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_METER
+	},
+	[TF_TBL_TYPE_MIRROR_CONFIG] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_MIRROR
+	},
+};
+
+struct tf_rm_element_cfg tf_em_int_p58[TF_EM_TBL_TYPE_MAX] = {
+	[TF_EM_TBL_TYPE_EM_RECORD] = {
+		TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P58_EM_REC
+	},
+};
+
+struct tf_if_tbl_cfg tf_if_tbl_p58[TF_IF_TBL_TYPE_MAX];
+
+struct tf_global_cfg_cfg tf_global_cfg_p58[TF_GLOBAL_CFG_TYPE_MAX] = {
+	[TF_TUNNEL_ENCAP] = {
+		TF_GLOBAL_CFG_CFG_HCAPI, TF_TUNNEL_ENCAP
+	},
+	[TF_ACTION_BLOCK] = {
+		TF_GLOBAL_CFG_CFG_HCAPI, TF_ACTION_BLOCK
+	},
+};
+#endif /* _TF_DEVICE_P58_H_ */
diff --git a/drivers/net/bnxt/tf_core/tf_em_common.c b/drivers/net/bnxt/tf_core/tf_em_common.c
index c4137af2bd..ddc6b3c4dd 100644
--- a/drivers/net/bnxt/tf_core/tf_em_common.c
+++ b/drivers/net/bnxt/tf_core/tf_em_common.c
@@ -1115,8 +1115,8 @@ int tf_em_ext_map_tbl_scope(struct tf *tfp,
 		goto cleaner;
 	}
 
-	gcfg_parms.type =
-		(enum tf_global_config_type)TF_GLOBAL_CFG_INTERNAL_PARIF_2_PF;
+	/* Note that TF_GLOBAL_CFG_INTERNAL_PARIF_2_PF is same as below enum */
+	gcfg_parms.type = TF_GLOBAL_CFG_TYPE_MAX;
 	gcfg_parms.offset = 0;
 	gcfg_parms.config = (uint8_t *)data;
 	gcfg_parms.config_mask = (uint8_t *)mask;
diff --git a/drivers/net/bnxt/tf_core/tf_msg.c b/drivers/net/bnxt/tf_core/tf_msg.c
index 46fc6288b2..f20a5113bf 100644
--- a/drivers/net/bnxt/tf_core/tf_msg.c
+++ b/drivers/net/bnxt/tf_core/tf_msg.c
@@ -19,9 +19,6 @@
 #include "hwrm_tf.h"
 #include "tf_em.h"
 
-/* Logging defines */
-#define TF_RM_MSG_DEBUG  0
-
 /* Specific msg size defines as we cannot use defines in tf.yaml. This
  * means we have to manually sync hwrm with these defines if the
  * tf.yaml changes.
@@ -361,29 +358,13 @@ tf_msg_session_resc_qcaps(struct tf *tfp,
 		goto cleanup;
 	}
 
-#if (TF_RM_MSG_DEBUG == 1)
-	printf("size: %d\n", tfp_le_to_cpu_32(resp.size));
-#endif /* (TF_RM_MSG_DEBUG == 1) */
-
 	/* Post process the response */
 	data = (struct tf_rm_resc_req_entry *)qcaps_buf.va_addr;
 
-#if (TF_RM_MSG_DEBUG == 1)
-	printf("\nQCAPS\n");
-#endif /* (TF_RM_MSG_DEBUG == 1) */
 	for (i = 0; i < size; i++) {
 		query[i].type = tfp_le_to_cpu_32(data[i].type);
 		query[i].min = tfp_le_to_cpu_16(data[i].min);
 		query[i].max = tfp_le_to_cpu_16(data[i].max);
-
-#if (TF_RM_MSG_DEBUG == 1)
-		printf("type: %d(0x%x) %d %d\n",
-		       query[i].type,
-		       query[i].type,
-		       query[i].min,
-		       query[i].max);
-#endif /* (TF_RM_MSG_DEBUG == 1) */
-
 	}
 
 	*resv_strategy = resp.flags &
@@ -476,26 +457,12 @@ tf_msg_session_resc_alloc(struct tf *tfp,
 		goto cleanup;
 	}
 
-#if (TF_RM_MSG_DEBUG == 1)
-	printf("\nRESV\n");
-	printf("size: %d\n", tfp_le_to_cpu_32(resp.size));
-#endif /* (TF_RM_MSG_DEBUG == 1) */
-
 	/* Post process the response */
 	resv_data = (struct tf_rm_resc_entry *)resv_buf.va_addr;
 	for (i = 0; i < size; i++) {
 		resv[i].type = tfp_le_to_cpu_32(resv_data[i].type);
 		resv[i].start = tfp_le_to_cpu_16(resv_data[i].start);
 		resv[i].stride = tfp_le_to_cpu_16(resv_data[i].stride);
-
-#if (TF_RM_MSG_DEBUG == 1)
-		printf("%d type: %d(0x%x) %d %d\n",
-		       i,
-		       resv[i].type,
-		       resv[i].type,
-		       resv[i].start,
-		       resv[i].stride);
-#endif /* (TF_RM_MSG_DEBUG == 1) */
 	}
 
 cleanup:
diff --git a/drivers/net/bnxt/tf_core/tf_rm.c b/drivers/net/bnxt/tf_core/tf_rm.c
index 887a3dccf8..f93a6d9018 100644
--- a/drivers/net/bnxt/tf_core/tf_rm.c
+++ b/drivers/net/bnxt/tf_core/tf_rm.c
@@ -6,6 +6,7 @@
 #include <string.h>
 
 #include <rte_common.h>
+#include <rte_debug.h>
 
 #include <cfa_resource_types.h>
 
@@ -596,13 +597,6 @@ tf_rm_create_db(struct tf *tfp,
 	rm_db->type = parms->type;
 	*parms->rm_db = (void *)rm_db;
 
-#if (TF_RM_DEBUG == 1)
-	printf("%s: type:%d num_entries:%d\n",
-	       tf_dir_2_str(parms->dir),
-	       parms->type,
-	       i);
-#endif /* (TF_RM_DEBUG == 1) */
-
 	tfp_free((void *)req);
 	tfp_free((void *)resv);
 
diff --git a/drivers/net/bnxt/tf_core/tf_shadow_tcam.c b/drivers/net/bnxt/tf_core/tf_shadow_tcam.c
index 38b1e7687b..523261f189 100644
--- a/drivers/net/bnxt/tf_core/tf_shadow_tcam.c
+++ b/drivers/net/bnxt/tf_core/tf_shadow_tcam.c
@@ -6,6 +6,7 @@
 #include "tf_common.h"
 #include "tf_util.h"
 #include "tfp.h"
+#include "tf_tcam.h"
 #include "tf_shadow_tcam.h"
 #include "tf_hash.h"
 
@@ -634,8 +635,7 @@ tf_shadow_tcam_search(struct tf_shadow_tcam_search_parms *parms)
 			 * requested allocation and return the info
 			 */
 			if (sparms->alloc)
-				ctxt->shadow_ctxt.sh_res_tbl[shtbl_key].refcnt =
-			ctxt->shadow_ctxt.sh_res_tbl[shtbl_key].refcnt + 1;
+				ctxt->shadow_ctxt.sh_res_tbl[shtbl_key].refcnt++;
 
 			sparms->hit = 1;
 			sparms->search_status = HIT;
-- 
2.17.1


^ permalink raw reply	[flat|nested] 129+ messages in thread

* [dpdk-dev] [PATCH 03/58] net/bnxt: add mailbox selection via dev op
  2021-05-30  8:58 [dpdk-dev] [PATCH 00/58] enhancements to host based flow table management Venkat Duvvuru
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 01/58] net/bnxt: add CFA folder to HCAPI directory Venkat Duvvuru
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 02/58] net/bnxt: add base TRUFLOW support for Thor Venkat Duvvuru
@ 2021-05-30  8:58 ` Venkat Duvvuru
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 04/58] net/bnxt: check resource reservation in TRUFLOW Venkat Duvvuru
                   ` (55 subsequent siblings)
  58 siblings, 0 replies; 129+ messages in thread
From: Venkat Duvvuru @ 2021-05-30  8:58 UTC (permalink / raw)
  To: dev; +Cc: Peter Spreadborough, Randy Schacher, Venkat Duvvuru

From: Peter Spreadborough <peter.spreadborough@broadcom.com>

Add get mailbox dev op so that mailbox offset is based on device
rather than hard coded.

Signed-off-by: Peter Spreadborough <peter.spreadborough@broadcom.com>
Signed-off-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Farah Smith <farah.smith@broadcom.com>
---
 drivers/net/bnxt/tf_core/tf_device.c     |  21 ++
 drivers/net/bnxt/tf_core/tf_device.h     |  12 +
 drivers/net/bnxt/tf_core/tf_device_p4.c  |   8 +
 drivers/net/bnxt/tf_core/tf_device_p58.c |   7 +
 drivers/net/bnxt/tf_core/tf_msg.c        | 410 +++++++++++++++++++++--
 drivers/net/bnxt/tf_core/tf_msg.h        |  12 +-
 drivers/net/bnxt/tf_core/tf_rm.c         |   2 +
 drivers/net/bnxt/tf_core/tf_session.c    |  22 +-
 drivers/net/bnxt/tf_core/tf_tcam.c       |   4 +-
 9 files changed, 463 insertions(+), 35 deletions(-)

diff --git a/drivers/net/bnxt/tf_core/tf_device.c b/drivers/net/bnxt/tf_core/tf_device.c
index 9c63f6d5d4..5116601a69 100644
--- a/drivers/net/bnxt/tf_core/tf_device.c
+++ b/drivers/net/bnxt/tf_core/tf_device.c
@@ -461,6 +461,27 @@ tf_dev_bind(struct tf *tfp __rte_unused,
 	}
 }
 
+int
+tf_dev_bind_ops(enum tf_device_type type,
+		struct tf_dev_info *dev_handle)
+{
+	switch (type) {
+	case TF_DEVICE_TYPE_WH:
+	case TF_DEVICE_TYPE_SR:
+		dev_handle->ops = &tf_dev_ops_p4;
+		break;
+	case TF_DEVICE_TYPE_THOR:
+		dev_handle->ops = &tf_dev_ops_p58;
+		break;
+	default:
+		TFP_DRV_LOG(ERR,
+			    "No such device\n");
+		return -ENODEV;
+	}
+
+	return 0;
+}
+
 int
 tf_dev_unbind(struct tf *tfp,
 	      struct tf_dev_info *dev_handle)
diff --git a/drivers/net/bnxt/tf_core/tf_device.h b/drivers/net/bnxt/tf_core/tf_device.h
index d5ef72309f..cbacc09ea5 100644
--- a/drivers/net/bnxt/tf_core/tf_device.h
+++ b/drivers/net/bnxt/tf_core/tf_device.h
@@ -108,6 +108,10 @@ int tf_dev_bind(struct tf *tfp,
 int tf_dev_unbind(struct tf *tfp,
 		  struct tf_dev_info *dev_handle);
 
+int
+tf_dev_bind_ops(enum tf_device_type type,
+		struct tf_dev_info *dev_handle);
+
 /**
  * Truflow device specific function hooks structure
  *
@@ -724,6 +728,14 @@ struct tf_dev_ops {
 	 */
 	int (*tf_dev_get_global_cfg)(struct tf *tfp,
 				     struct tf_global_cfg_parms *parms);
+
+	/**
+	 * Get mailbox
+	 *
+	 *    returns:
+	 *      mailbox
+	 */
+	int (*tf_dev_get_mailbox)(void);
 };
 
 /**
diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.c b/drivers/net/bnxt/tf_core/tf_device_p4.c
index 257a0fb2d0..6b28f6ce59 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p4.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p4.c
@@ -13,6 +13,7 @@
 #include "tf_em.h"
 #include "tf_if_tbl.h"
 #include "tfp.h"
+#include "tf_msg_common.h"
 
 #define TF_DEV_P4_PARIF_MAX 16
 #define TF_DEV_P4_PF_MASK 0xfUL
@@ -241,6 +242,11 @@ tf_dev_p4_map_parif(struct tf *tfp __rte_unused,
 	return 0;
 }
 
+static int tf_dev_p4_get_mailbox(void)
+{
+	return TF_KONG_MB;
+}
+
 
 /**
  * Truflow P4 device specific functions
@@ -278,6 +284,7 @@ const struct tf_dev_ops tf_dev_ops_p4_init = {
 	.tf_dev_get_if_tbl = NULL,
 	.tf_dev_set_global_cfg = NULL,
 	.tf_dev_get_global_cfg = NULL,
+	.tf_dev_get_mailbox = tf_dev_p4_get_mailbox,
 };
 
 /**
@@ -316,4 +323,5 @@ const struct tf_dev_ops tf_dev_ops_p4 = {
 	.tf_dev_get_if_tbl = tf_if_tbl_get,
 	.tf_dev_set_global_cfg = tf_global_cfg_set,
 	.tf_dev_get_global_cfg = tf_global_cfg_get,
+	.tf_dev_get_mailbox = tf_dev_p4_get_mailbox,
 };
diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c
index fb5ad29a5c..b4530f8762 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p58.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p58.c
@@ -13,6 +13,7 @@
 #include "tf_em.h"
 #include "tf_if_tbl.h"
 #include "tfp.h"
+#include "tf_msg_common.h"
 
 #define TF_DEV_P58_PARIF_MAX 16
 #define TF_DEV_P58_PF_MASK 0xfUL
@@ -206,6 +207,10 @@ tf_dev_p58_map_parif(struct tf *tfp __rte_unused,
 	return 0;
 }
 
+static int tf_dev_p58_get_mailbox(void)
+{
+	return TF_CHIMP_MB;
+}
 
 /**
  * Truflow P58 device specific functions
@@ -243,6 +248,7 @@ const struct tf_dev_ops tf_dev_ops_p58_init = {
 	.tf_dev_get_if_tbl = NULL,
 	.tf_dev_set_global_cfg = NULL,
 	.tf_dev_get_global_cfg = NULL,
+	.tf_dev_get_mailbox = tf_dev_p58_get_mailbox,
 };
 
 /**
@@ -281,4 +287,5 @@ const struct tf_dev_ops tf_dev_ops_p58 = {
 	.tf_dev_get_if_tbl = tf_if_tbl_get,
 	.tf_dev_set_global_cfg = tf_global_cfg_set,
 	.tf_dev_get_global_cfg = tf_global_cfg_get,
+	.tf_dev_get_mailbox = tf_dev_p58_get_mailbox,
 };
diff --git a/drivers/net/bnxt/tf_core/tf_msg.c b/drivers/net/bnxt/tf_core/tf_msg.c
index f20a5113bf..1007211363 100644
--- a/drivers/net/bnxt/tf_core/tf_msg.c
+++ b/drivers/net/bnxt/tf_core/tf_msg.c
@@ -116,7 +116,8 @@ int
 tf_msg_session_open(struct tf *tfp,
 		    char *ctrl_chan_name,
 		    uint8_t *fw_session_id,
-		    uint8_t *fw_session_client_id)
+		    uint8_t *fw_session_client_id,
+		    struct tf_dev_info *dev)
 {
 	int rc;
 	struct hwrm_tf_session_open_input req = { 0 };
@@ -131,7 +132,7 @@ tf_msg_session_open(struct tf *tfp,
 	parms.req_size = sizeof(req);
 	parms.resp_data = (uint32_t *)&resp;
 	parms.resp_size = sizeof(resp);
-	parms.mailbox = TF_KONG_MB;
+	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
 	rc = tfp_send_msg_direct(tfp,
 				 &parms);
@@ -155,6 +156,7 @@ tf_msg_session_attach(struct tf *tfp __rte_unused,
 
 int
 tf_msg_session_client_register(struct tf *tfp,
+			       struct tf_session *tfs,
 			       char *ctrl_channel_name,
 			       uint8_t *fw_session_client_id)
 {
@@ -163,6 +165,16 @@ tf_msg_session_client_register(struct tf *tfp,
 	struct hwrm_tf_session_register_output resp = { 0 };
 	struct tfp_send_msg_parms parms = { 0 };
 	uint8_t fw_session_id;
+	struct tf_dev_info *dev;
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to lookup device, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
 
 	rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
 	if (rc) {
@@ -183,7 +195,7 @@ tf_msg_session_client_register(struct tf *tfp,
 	parms.req_size = sizeof(req);
 	parms.resp_data = (uint32_t *)&resp;
 	parms.resp_size = sizeof(resp);
-	parms.mailbox = TF_KONG_MB;
+	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
 	rc = tfp_send_msg_direct(tfp,
 				 &parms);
@@ -198,6 +210,7 @@ tf_msg_session_client_register(struct tf *tfp,
 
 int
 tf_msg_session_client_unregister(struct tf *tfp,
+				 struct tf_session *tfs,
 				 uint8_t fw_session_client_id)
 {
 	int rc;
@@ -205,6 +218,16 @@ tf_msg_session_client_unregister(struct tf *tfp,
 	struct hwrm_tf_session_unregister_output resp = { 0 };
 	struct tfp_send_msg_parms parms = { 0 };
 	uint8_t fw_session_id;
+	struct tf_dev_info *dev;
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to lookup device, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
 
 	rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
 	if (rc) {
@@ -223,7 +246,7 @@ tf_msg_session_client_unregister(struct tf *tfp,
 	parms.req_size = sizeof(req);
 	parms.resp_data = (uint32_t *)&resp;
 	parms.resp_size = sizeof(resp);
-	parms.mailbox = TF_KONG_MB;
+	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
 	rc = tfp_send_msg_direct(tfp,
 				 &parms);
@@ -232,13 +255,24 @@ tf_msg_session_client_unregister(struct tf *tfp,
 }
 
 int
-tf_msg_session_close(struct tf *tfp)
+tf_msg_session_close(struct tf *tfp,
+		     struct tf_session *tfs)
 {
 	int rc;
 	struct hwrm_tf_session_close_input req = { 0 };
 	struct hwrm_tf_session_close_output resp = { 0 };
 	struct tfp_send_msg_parms parms = { 0 };
 	uint8_t fw_session_id;
+	struct tf_dev_info *dev;
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to lookup device, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
 
 	rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
 	if (rc) {
@@ -256,7 +290,7 @@ tf_msg_session_close(struct tf *tfp)
 	parms.req_size = sizeof(req);
 	parms.resp_data = (uint32_t *)&resp;
 	parms.resp_size = sizeof(resp);
-	parms.mailbox = TF_KONG_MB;
+	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
 	rc = tfp_send_msg_direct(tfp,
 				 &parms);
@@ -271,6 +305,26 @@ tf_msg_session_qcfg(struct tf *tfp)
 	struct hwrm_tf_session_qcfg_output resp = { 0 };
 	struct tfp_send_msg_parms parms = { 0 };
 	uint8_t fw_session_id;
+	struct tf_dev_info *dev;
+	struct tf_session *tfs;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to lookup session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to lookup device, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
 
 	rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
 	if (rc) {
@@ -288,7 +342,7 @@ tf_msg_session_qcfg(struct tf *tfp)
 	parms.req_size = sizeof(req);
 	parms.resp_data = (uint32_t *)&resp;
 	parms.resp_size = sizeof(resp);
-	parms.mailbox = TF_KONG_MB;
+	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
 	rc = tfp_send_msg_direct(tfp,
 				 &parms);
@@ -297,6 +351,7 @@ tf_msg_session_qcfg(struct tf *tfp)
 
 int
 tf_msg_session_resc_qcaps(struct tf *tfp,
+			  struct tf_dev_info *dev,
 			  enum tf_dir dir,
 			  uint16_t size,
 			  struct tf_rm_resc_req_entry *query,
@@ -340,7 +395,7 @@ tf_msg_session_resc_qcaps(struct tf *tfp,
 	parms.req_size = sizeof(req);
 	parms.resp_data = (uint32_t *)&resp;
 	parms.resp_size = sizeof(resp);
-	parms.mailbox = TF_KONG_MB;
+	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
 	rc = tfp_send_msg_direct(tfp, &parms);
 	if (rc)
@@ -378,6 +433,7 @@ tf_msg_session_resc_qcaps(struct tf *tfp,
 
 int
 tf_msg_session_resc_alloc(struct tf *tfp,
+			  struct tf_dev_info *dev,
 			  enum tf_dir dir,
 			  uint16_t size,
 			  struct tf_rm_resc_req_entry *request,
@@ -439,7 +495,7 @@ tf_msg_session_resc_alloc(struct tf *tfp,
 	parms.req_size = sizeof(req);
 	parms.resp_data = (uint32_t *)&resp;
 	parms.resp_size = sizeof(resp);
-	parms.mailbox = TF_KONG_MB;
+	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
 	rc = tfp_send_msg_direct(tfp, &parms);
 	if (rc)
@@ -487,9 +543,31 @@ tf_msg_session_resc_flush(struct tf *tfp,
 	struct tf_msg_dma_buf resv_buf = { 0 };
 	struct tf_rm_resc_entry *resv_data;
 	int dma_size;
+	struct tf_dev_info *dev;
+	struct tf_session *tfs;
 
 	TF_CHECK_PARMS2(tfp, resv);
 
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup device, rc:%s\n",
+			    tf_dir_2_str(dir),
+			    strerror(-rc));
+		return rc;
+	}
+
 	rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
 	if (rc) {
 		TFP_DRV_LOG(ERR,
@@ -524,7 +602,7 @@ tf_msg_session_resc_flush(struct tf *tfp,
 	parms.req_size = sizeof(req);
 	parms.resp_data = (uint32_t *)&resp;
 	parms.resp_size = sizeof(resp);
-	parms.mailbox = TF_KONG_MB;
+	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
 	rc = tfp_send_msg_direct(tfp, &parms);
 
@@ -549,6 +627,28 @@ tf_msg_insert_em_internal_entry(struct tf *tfp,
 	uint16_t flags;
 	uint8_t fw_session_id;
 	uint8_t msg_key_size;
+	struct tf_dev_info *dev;
+	struct tf_session *tfs;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(em_parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup device, rc:%s\n",
+			    tf_dir_2_str(em_parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
 
 	rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
 	if (rc) {
@@ -593,7 +693,7 @@ tf_msg_insert_em_internal_entry(struct tf *tfp,
 	parms.req_size = sizeof(req);
 	parms.resp_data = (uint32_t *)&resp;
 	parms.resp_size = sizeof(resp);
-	parms.mailbox = TF_KONG_MB;
+	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
 	rc = tfp_send_msg_direct(tfp,
 				 &parms);
@@ -617,6 +717,28 @@ tf_msg_delete_em_entry(struct tf *tfp,
 	struct hwrm_tf_em_delete_output resp = { 0 };
 	uint16_t flags;
 	uint8_t fw_session_id;
+	struct tf_dev_info *dev;
+	struct tf_session *tfs;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(em_parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup device, rc:%s\n",
+			    tf_dir_2_str(em_parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
 
 	rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
 	if (rc) {
@@ -641,7 +763,7 @@ tf_msg_delete_em_entry(struct tf *tfp,
 	parms.req_size = sizeof(req);
 	parms.resp_data = (uint32_t *)&resp;
 	parms.resp_size = sizeof(resp);
-	parms.mailbox = TF_KONG_MB;
+	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
 	rc = tfp_send_msg_direct(tfp,
 				 &parms);
@@ -664,6 +786,26 @@ tf_msg_em_mem_rgtr(struct tf *tfp,
 	struct hwrm_tf_ctxt_mem_rgtr_input req = { 0 };
 	struct hwrm_tf_ctxt_mem_rgtr_output resp = { 0 };
 	struct tfp_send_msg_parms parms = { 0 };
+	struct tf_dev_info *dev;
+	struct tf_session *tfs;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to lookup session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to lookup device, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
 
 	req.page_level = page_lvl;
 	req.page_size = page_size;
@@ -674,7 +816,7 @@ tf_msg_em_mem_rgtr(struct tf *tfp,
 	parms.req_size = sizeof(req);
 	parms.resp_data = (uint32_t *)&resp;
 	parms.resp_size = sizeof(resp);
-	parms.mailbox = TF_KONG_MB;
+	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
 	rc = tfp_send_msg_direct(tfp,
 				 &parms);
@@ -694,6 +836,26 @@ tf_msg_em_mem_unrgtr(struct tf *tfp,
 	struct hwrm_tf_ctxt_mem_unrgtr_input req = {0};
 	struct hwrm_tf_ctxt_mem_unrgtr_output resp = {0};
 	struct tfp_send_msg_parms parms = { 0 };
+	struct tf_dev_info *dev;
+	struct tf_session *tfs;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to lookup session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to lookup device, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
 
 	req.ctx_id = tfp_cpu_to_le_32(*ctx_id);
 
@@ -702,7 +864,7 @@ tf_msg_em_mem_unrgtr(struct tf *tfp,
 	parms.req_size = sizeof(req);
 	parms.resp_data = (uint32_t *)&resp;
 	parms.resp_size = sizeof(resp);
-	parms.mailbox = TF_KONG_MB;
+	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
 	rc = tfp_send_msg_direct(tfp,
 				 &parms);
@@ -719,6 +881,28 @@ tf_msg_em_qcaps(struct tf *tfp,
 	struct hwrm_tf_ext_em_qcaps_output resp = { 0 };
 	uint32_t             flags;
 	struct tfp_send_msg_parms parms = { 0 };
+	struct tf_dev_info *dev;
+	struct tf_session *tfs;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup device, rc:%s\n",
+			    tf_dir_2_str(dir),
+			    strerror(-rc));
+		return rc;
+	}
 
 	flags = (dir == TF_DIR_TX ? HWRM_TF_EXT_EM_QCAPS_INPUT_FLAGS_DIR_TX :
 		 HWRM_TF_EXT_EM_QCAPS_INPUT_FLAGS_DIR_RX);
@@ -729,7 +913,7 @@ tf_msg_em_qcaps(struct tf *tfp,
 	parms.req_size = sizeof(req);
 	parms.resp_data = (uint32_t *)&resp;
 	parms.resp_size = sizeof(resp);
-	parms.mailbox = TF_KONG_MB;
+	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
 	rc = tfp_send_msg_direct(tfp,
 				 &parms);
@@ -762,6 +946,28 @@ tf_msg_em_cfg(struct tf *tfp,
 	struct hwrm_tf_ext_em_cfg_output resp = {0};
 	uint32_t flags;
 	struct tfp_send_msg_parms parms = { 0 };
+	struct tf_dev_info *dev;
+	struct tf_session *tfs;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup device, rc:%s\n",
+			    tf_dir_2_str(dir),
+			    strerror(-rc));
+		return rc;
+	}
 
 	flags = (dir == TF_DIR_TX ? HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_TX :
 		 HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_RX);
@@ -782,7 +988,7 @@ tf_msg_em_cfg(struct tf *tfp,
 	parms.req_size = sizeof(req);
 	parms.resp_data = (uint32_t *)&resp;
 	parms.resp_size = sizeof(resp);
-	parms.mailbox = TF_KONG_MB;
+	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
 	rc = tfp_send_msg_direct(tfp,
 				 &parms);
@@ -799,6 +1005,28 @@ tf_msg_em_op(struct tf *tfp,
 	struct hwrm_tf_ext_em_op_output resp = {0};
 	uint32_t flags;
 	struct tfp_send_msg_parms parms = { 0 };
+	struct tf_dev_info *dev;
+	struct tf_session *tfs;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup device, rc:%s\n",
+			    tf_dir_2_str(dir),
+			    strerror(-rc));
+		return rc;
+	}
 
 	flags = (dir == TF_DIR_TX ? HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_TX :
 		 HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_RX);
@@ -810,7 +1038,7 @@ tf_msg_em_op(struct tf *tfp,
 	parms.req_size = sizeof(req);
 	parms.resp_data = (uint32_t *)&resp;
 	parms.resp_size = sizeof(resp);
-	parms.mailbox = TF_KONG_MB;
+	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
 	rc = tfp_send_msg_direct(tfp,
 				 &parms);
@@ -819,6 +1047,7 @@ tf_msg_em_op(struct tf *tfp,
 
 int
 tf_msg_tcam_entry_set(struct tf *tfp,
+		      struct tf_dev_info *dev,
 		      struct tf_tcam_set_parms *parms)
 {
 	int rc;
@@ -877,7 +1106,7 @@ tf_msg_tcam_entry_set(struct tf *tfp,
 	mparms.req_size = sizeof(req);
 	mparms.resp_data = (uint32_t *)&resp;
 	mparms.resp_size = sizeof(resp);
-	mparms.mailbox = TF_KONG_MB;
+	mparms.mailbox = dev->ops->tf_dev_get_mailbox();
 
 	rc = tfp_send_msg_direct(tfp,
 				 &mparms);
@@ -890,6 +1119,7 @@ tf_msg_tcam_entry_set(struct tf *tfp,
 
 int
 tf_msg_tcam_entry_free(struct tf *tfp,
+		       struct tf_dev_info *dev,
 		       struct tf_tcam_free_parms *in_parms)
 {
 	int rc;
@@ -920,7 +1150,7 @@ tf_msg_tcam_entry_free(struct tf *tfp,
 	parms.req_size = sizeof(req);
 	parms.resp_data = (uint32_t *)&resp;
 	parms.resp_size = sizeof(resp);
-	parms.mailbox = TF_KONG_MB;
+	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
 	rc = tfp_send_msg_direct(tfp,
 				 &parms);
@@ -940,6 +1170,28 @@ tf_msg_set_tbl_entry(struct tf *tfp,
 	struct hwrm_tf_tbl_type_set_output resp = { 0 };
 	struct tfp_send_msg_parms parms = { 0 };
 	uint8_t fw_session_id;
+	struct tf_dev_info *dev;
+	struct tf_session *tfs;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup device, rc:%s\n",
+			    tf_dir_2_str(dir),
+			    strerror(-rc));
+		return rc;
+	}
 
 	rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
 	if (rc) {
@@ -976,7 +1228,7 @@ tf_msg_set_tbl_entry(struct tf *tfp,
 	parms.req_size = sizeof(req);
 	parms.resp_data = (uint32_t *)&resp;
 	parms.resp_size = sizeof(resp);
-	parms.mailbox = TF_KONG_MB;
+	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
 	rc = tfp_send_msg_direct(tfp,
 				 &parms);
@@ -999,6 +1251,28 @@ tf_msg_get_tbl_entry(struct tf *tfp,
 	struct hwrm_tf_tbl_type_get_output resp = { 0 };
 	struct tfp_send_msg_parms parms = { 0 };
 	uint8_t fw_session_id;
+	struct tf_dev_info *dev;
+	struct tf_session *tfs;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup device, rc:%s\n",
+			    tf_dir_2_str(dir),
+			    strerror(-rc));
+		return rc;
+	}
 
 	rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
 	if (rc) {
@@ -1020,7 +1294,7 @@ tf_msg_get_tbl_entry(struct tf *tfp,
 	parms.req_size = sizeof(req);
 	parms.resp_data = (uint32_t *)&resp;
 	parms.resp_size = sizeof(resp);
-	parms.mailbox = TF_KONG_MB;
+	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
 	rc = tfp_send_msg_direct(tfp,
 				 &parms);
@@ -1051,6 +1325,28 @@ tf_msg_get_global_cfg(struct tf *tfp,
 	uint32_t flags = 0;
 	uint8_t fw_session_id;
 	uint16_t resp_size = 0;
+	struct tf_dev_info *dev;
+	struct tf_session *tfs;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(params->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup device, rc:%s\n",
+			    tf_dir_2_str(params->dir),
+			    strerror(-rc));
+		return rc;
+	}
 
 	rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
 	if (rc) {
@@ -1077,7 +1373,7 @@ tf_msg_get_global_cfg(struct tf *tfp,
 	parms.req_size = sizeof(req);
 	parms.resp_data = (uint32_t *)&resp;
 	parms.resp_size = sizeof(resp);
-	parms.mailbox = TF_KONG_MB;
+	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
 	rc = tfp_send_msg_direct(tfp, &parms);
 	if (rc != 0)
@@ -1108,6 +1404,28 @@ tf_msg_set_global_cfg(struct tf *tfp,
 	struct hwrm_tf_global_cfg_set_output resp = { 0 };
 	uint32_t flags = 0;
 	uint8_t fw_session_id;
+	struct tf_dev_info *dev;
+	struct tf_session *tfs;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(params->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup device, rc:%s\n",
+			    tf_dir_2_str(params->dir),
+			    strerror(-rc));
+		return rc;
+	}
 
 	rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
 	if (rc) {
@@ -1156,7 +1474,7 @@ tf_msg_set_global_cfg(struct tf *tfp,
 	parms.req_size = sizeof(req);
 	parms.resp_data = (uint32_t *)&resp;
 	parms.resp_size = sizeof(resp);
-	parms.mailbox = TF_KONG_MB;
+	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
 	rc = tfp_send_msg_direct(tfp, &parms);
 
@@ -1181,6 +1499,28 @@ tf_msg_bulk_get_tbl_entry(struct tf *tfp,
 	struct tf_tbl_type_bulk_get_output resp = { 0 };
 	int data_size = 0;
 	uint8_t fw_session_id;
+	struct tf_dev_info *dev;
+	struct tf_session *tfs;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup device, rc:%s\n",
+			    tf_dir_2_str(dir),
+			    strerror(-rc));
+		return rc;
+	}
 
 	rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
 	if (rc) {
@@ -1203,7 +1543,7 @@ tf_msg_bulk_get_tbl_entry(struct tf *tfp,
 	req.host_addr = tfp_cpu_to_le_64(physical_mem_addr);
 
 	MSG_PREP(parms,
-		 TF_KONG_MB,
+		 dev->ops->tf_dev_get_mailbox(),
 		 HWRM_TF,
 		 HWRM_TFT_TBL_TYPE_BULK_GET,
 		 req,
@@ -1229,6 +1569,7 @@ tf_msg_get_if_tbl_entry(struct tf *tfp,
 	struct hwrm_tf_if_tbl_get_input req = { 0 };
 	struct hwrm_tf_if_tbl_get_output resp = { 0 };
 	uint32_t flags = 0;
+	struct tf_dev_info *dev;
 	struct tf_session *tfs;
 
 	/* Retrieve the session information */
@@ -1241,6 +1582,16 @@ tf_msg_get_if_tbl_entry(struct tf *tfp,
 		return rc;
 	}
 
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup device, rc:%s\n",
+			    tf_dir_2_str(params->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
 	flags = (params->dir == TF_DIR_TX ?
 		HWRM_TF_IF_TBL_GET_INPUT_FLAGS_DIR_TX :
 		HWRM_TF_IF_TBL_GET_INPUT_FLAGS_DIR_RX);
@@ -1258,7 +1609,7 @@ tf_msg_get_if_tbl_entry(struct tf *tfp,
 	parms.req_size = sizeof(req);
 	parms.resp_data = (uint32_t *)&resp;
 	parms.resp_size = sizeof(resp);
-	parms.mailbox = TF_KONG_MB;
+	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
 	rc = tfp_send_msg_direct(tfp, &parms);
 
@@ -1268,7 +1619,7 @@ tf_msg_get_if_tbl_entry(struct tf *tfp,
 	if (parms.tf_resp_code != 0)
 		return tfp_le_to_cpu_32(parms.tf_resp_code);
 
-	tfp_memcpy(&params->data[0], resp.data, req.size);
+	tfp_memcpy(params->data, resp.data, req.size);
 
 	return tfp_le_to_cpu_32(parms.tf_resp_code);
 }
@@ -1282,6 +1633,7 @@ tf_msg_set_if_tbl_entry(struct tf *tfp,
 	struct hwrm_tf_if_tbl_set_input req = { 0 };
 	struct hwrm_tf_if_tbl_get_output resp = { 0 };
 	uint32_t flags = 0;
+	struct tf_dev_info *dev;
 	struct tf_session *tfs;
 
 	/* Retrieve the session information */
@@ -1294,6 +1646,10 @@ tf_msg_set_if_tbl_entry(struct tf *tfp,
 		return rc;
 	}
 
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc)
+		return rc;
 
 	flags = (params->dir == TF_DIR_TX ?
 		HWRM_TF_IF_TBL_SET_INPUT_FLAGS_DIR_TX :
@@ -1313,7 +1669,7 @@ tf_msg_set_if_tbl_entry(struct tf *tfp,
 	parms.req_size = sizeof(req);
 	parms.resp_data = (uint32_t *)&resp;
 	parms.resp_size = sizeof(resp);
-	parms.mailbox = TF_KONG_MB;
+	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
 	rc = tfp_send_msg_direct(tfp, &parms);
 
diff --git a/drivers/net/bnxt/tf_core/tf_msg.h b/drivers/net/bnxt/tf_core/tf_msg.h
index 0a2566010c..25e29a554f 100644
--- a/drivers/net/bnxt/tf_core/tf_msg.h
+++ b/drivers/net/bnxt/tf_core/tf_msg.h
@@ -36,7 +36,8 @@ struct tf;
 int tf_msg_session_open(struct tf *tfp,
 			char *ctrl_chan_name,
 			uint8_t *fw_session_id,
-			uint8_t *fw_session_client_id);
+			uint8_t *fw_session_client_id,
+			struct tf_dev_info *dev);
 
 /**
  * Sends session close request to Firmware
@@ -75,6 +76,7 @@ int tf_msg_session_attach(struct tf *tfp,
  *   0 on Success else internal Truflow error
  */
 int tf_msg_session_client_register(struct tf *tfp,
+				   struct tf_session *tfs,
 				   char *ctrl_channel_name,
 				   uint8_t *fw_session_client_id);
 
@@ -92,6 +94,7 @@ int tf_msg_session_client_register(struct tf *tfp,
  *   0 on Success else internal Truflow error
  */
 int tf_msg_session_client_unregister(struct tf *tfp,
+				     struct tf_session *tfs,
 				     uint8_t fw_session_client_id);
 
 /**
@@ -103,7 +106,8 @@ int tf_msg_session_client_unregister(struct tf *tfp,
  * Returns:
  *   0 on Success else internal Truflow error
  */
-int tf_msg_session_close(struct tf *tfp);
+int tf_msg_session_close(struct tf *tfp,
+			 struct tf_session *tfs);
 
 /**
  * Sends session query config request to TF Firmware
@@ -139,6 +143,7 @@ int tf_msg_session_qcfg(struct tf *tfp);
  *   0 on Success else internal Truflow error
  */
 int tf_msg_session_resc_qcaps(struct tf *tfp,
+			      struct tf_dev_info *dev,
 			      enum tf_dir dir,
 			      uint16_t size,
 			      struct tf_rm_resc_req_entry *query,
@@ -166,6 +171,7 @@ int tf_msg_session_resc_qcaps(struct tf *tfp,
  *   0 on Success else internal Truflow error
  */
 int tf_msg_session_resc_alloc(struct tf *tfp,
+			      struct tf_dev_info *dev,
 			      enum tf_dir dir,
 			      uint16_t size,
 			      struct tf_rm_resc_req_entry *request,
@@ -368,6 +374,7 @@ int tf_msg_em_op(struct tf *tfp,
  *  0 on Success else internal Truflow error
  */
 int tf_msg_tcam_entry_set(struct tf *tfp,
+			  struct tf_dev_info *dev,
 			  struct tf_tcam_set_parms *parms);
 
 /**
@@ -383,6 +390,7 @@ int tf_msg_tcam_entry_set(struct tf *tfp,
  *  0 on Success else internal Truflow error
  */
 int tf_msg_tcam_entry_free(struct tf *tfp,
+			   struct tf_dev_info *dev,
 			   struct tf_tcam_free_parms *parms);
 
 /**
diff --git a/drivers/net/bnxt/tf_core/tf_rm.c b/drivers/net/bnxt/tf_core/tf_rm.c
index f93a6d9018..2c08fb80fe 100644
--- a/drivers/net/bnxt/tf_core/tf_rm.c
+++ b/drivers/net/bnxt/tf_core/tf_rm.c
@@ -415,6 +415,7 @@ tf_rm_create_db(struct tf *tfp,
 
 	/* Get Firmware Capabilities */
 	rc = tf_msg_session_resc_qcaps(tfp,
+				       dev,
 				       parms->dir,
 				       max_types,
 				       query,
@@ -499,6 +500,7 @@ tf_rm_create_db(struct tf *tfp,
 	}
 
 	rc = tf_msg_session_resc_alloc(tfp,
+				       dev,
 				       parms->dir,
 				       hcapi_items,
 				       req,
diff --git a/drivers/net/bnxt/tf_core/tf_session.c b/drivers/net/bnxt/tf_core/tf_session.c
index 6335ad358c..b3fa7e13ff 100644
--- a/drivers/net/bnxt/tf_core/tf_session.c
+++ b/drivers/net/bnxt/tf_core/tf_session.c
@@ -56,14 +56,19 @@ tf_session_create(struct tf *tfp,
 	uint8_t fw_session_id;
 	uint8_t fw_session_client_id;
 	union tf_session_id *session_id;
+	struct tf_dev_info dev;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
+	tf_dev_bind_ops(parms->open_cfg->device_type,
+			&dev);
+
 	/* Open FW session and get a new session_id */
 	rc = tf_msg_session_open(tfp,
 				 parms->open_cfg->ctrl_chan_name,
 				 &fw_session_id,
-				 &fw_session_client_id);
+				 &fw_session_client_id,
+				 &dev);
 	if (rc) {
 		/* Log error */
 		if (rc == -EEXIST)
@@ -177,6 +182,13 @@ tf_session_create(struct tf *tfp,
 	if (rc)
 		return rc;
 
+	if (session->dev.ops->tf_dev_get_mailbox == NULL) {
+		/* Log error */
+		TFP_DRV_LOG(ERR,
+			    "No tf_dev_get_mailbox() defined for device\n");
+		goto cleanup;
+	}
+
 	session->dev_init = true;
 
 	return 0;
@@ -234,8 +246,9 @@ tf_session_client_create(struct tf *tfp,
 
 	rc = tf_msg_session_client_register
 		    (tfp,
-		    parms->ctrl_chan_name,
-		    &session_client_id.internal.fw_session_client_id);
+		     session,
+		     parms->ctrl_chan_name,
+		     &session_client_id.internal.fw_session_client_id);
 	if (rc) {
 		TFP_DRV_LOG(ERR,
 			    "Failed to create client on session, rc:%s\n",
@@ -346,6 +359,7 @@ tf_session_client_destroy(struct tf *tfp,
 
 	rc = tf_msg_session_client_unregister
 			(tfp,
+			tfs,
 			parms->session_client_id.internal.fw_session_client_id);
 
 	/* Log error, but continue. If FW fails we do not really have
@@ -534,7 +548,7 @@ tf_session_close_session(struct tf *tfp,
 			    strerror(-rc));
 	}
 
-	rc = tf_msg_session_close(tfp);
+	rc = tf_msg_session_close(tfp, tfs);
 	if (rc) {
 		/* Log error */
 		TFP_DRV_LOG(ERR,
diff --git a/drivers/net/bnxt/tf_core/tf_tcam.c b/drivers/net/bnxt/tf_core/tf_tcam.c
index 22bc01c95d..038aa40e92 100644
--- a/drivers/net/bnxt/tf_core/tf_tcam.c
+++ b/drivers/net/bnxt/tf_core/tf_tcam.c
@@ -428,7 +428,7 @@ tf_tcam_free(struct tf *tfp,
 	if (rc)
 		return rc;
 
-	rc = tf_msg_tcam_entry_free(tfp, parms);
+	rc = tf_msg_tcam_entry_free(tfp, dev, parms);
 	if (rc) {
 		/* Log error */
 		TFP_DRV_LOG(ERR,
@@ -652,7 +652,7 @@ tf_tcam_set(struct tf *tfp __rte_unused,
 	if (rc)
 		return rc;
 
-	rc = tf_msg_tcam_entry_set(tfp, parms);
+	rc = tf_msg_tcam_entry_set(tfp, dev, parms);
 	if (rc) {
 		/* Log error */
 		TFP_DRV_LOG(ERR,
-- 
2.17.1


^ permalink raw reply	[flat|nested] 129+ messages in thread

* [dpdk-dev] [PATCH 04/58] net/bnxt: check resource reservation in TRUFLOW
  2021-05-30  8:58 [dpdk-dev] [PATCH 00/58] enhancements to host based flow table management Venkat Duvvuru
                   ` (2 preceding siblings ...)
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 03/58] net/bnxt: add mailbox selection via dev op Venkat Duvvuru
@ 2021-05-30  8:58 ` Venkat Duvvuru
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 05/58] net/bnxt: update TRUFLOW resources Venkat Duvvuru
                   ` (54 subsequent siblings)
  58 siblings, 0 replies; 129+ messages in thread
From: Venkat Duvvuru @ 2021-05-30  8:58 UTC (permalink / raw)
  To: dev; +Cc: Jay Ding, Randy Schacher, Venkat Duvvuru

From: Jay Ding <jay.ding@broadcom.com>

- Allow tf_open to continue if no resource is allocated
  for some table type.
- Close the session if binding fails for any table.
- Close the session if no resource is allocated for all tables.

Signed-off-by: Jay Ding <jay.ding@broadcom.com>
Signed-off-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Peter Spreadborough <peter.spreadborough@broadcom.com>
---
 drivers/net/bnxt/tf_core/tf_device.c  | 284 +++++++++++++++++++-------
 drivers/net/bnxt/tf_core/tf_session.c |   2 +-
 2 files changed, 207 insertions(+), 79 deletions(-)

diff --git a/drivers/net/bnxt/tf_core/tf_device.c b/drivers/net/bnxt/tf_core/tf_device.c
index 5116601a69..d4c93439ec 100644
--- a/drivers/net/bnxt/tf_core/tf_device.c
+++ b/drivers/net/bnxt/tf_core/tf_device.c
@@ -15,6 +15,44 @@ struct tf;
 static int tf_dev_unbind_p4(struct tf *tfp);
 static int tf_dev_unbind_p58(struct tf *tfp);
 
+/**
+ * Resource Reservation Check function
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [in] cfg
+ *   Pointer to rm element config
+ *
+ * [in] reservations
+ *   Pointer to resource reservation array
+ *
+ * Returns
+ *   - (n) number of tables that have non-zero reservation count.
+ */
+static int
+tf_dev_reservation_check(struct tf *tfp __rte_unused,
+			 uint16_t count,
+			 struct tf_rm_element_cfg *cfg,
+			 uint16_t *reservations)
+{
+	uint16_t cnt = 0;
+	uint16_t *rm_num;
+	int i, j;
+
+	for (i = 0; i < TF_DIR_MAX; i++) {
+		rm_num = (uint16_t *)reservations + i * count;
+		for (j = 0; j < count; j++) {
+			if ((cfg[j].cfg_type == TF_RM_ELEM_CFG_HCAPI ||
+			     cfg[j].cfg_type == TF_RM_ELEM_CFG_HCAPI_BA) &&
+			     rm_num[j] > 0)
+				cnt++;
+		}
+	}
+
+	return cnt;
+}
+
 /**
  * Device specific bind function, WH+
  *
@@ -42,6 +80,8 @@ tf_dev_bind_p4(struct tf *tfp,
 {
 	int rc;
 	int frc;
+	int rsv_cnt;
+	bool no_rsv_flag = true;
 	struct tf_ident_cfg_parms ident_cfg;
 	struct tf_tbl_cfg_parms tbl_cfg;
 	struct tf_tcam_cfg_parms tcam_cfg;
@@ -54,69 +94,117 @@ tf_dev_bind_p4(struct tf *tfp,
 
 	/* Initialize the modules */
 
-	ident_cfg.num_elements = TF_IDENT_TYPE_MAX;
-	ident_cfg.cfg = tf_ident_p4;
-	ident_cfg.shadow_copy = shadow_copy;
-	ident_cfg.resources = resources;
-	rc = tf_ident_bind(tfp, &ident_cfg);
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "Identifier initialization failure\n");
-		goto fail;
+	rsv_cnt = tf_dev_reservation_check(tfp,
+					   TF_IDENT_TYPE_MAX,
+					   tf_ident_p4,
+					   (uint16_t *)resources->ident_cnt);
+	if (rsv_cnt) {
+		ident_cfg.num_elements = TF_IDENT_TYPE_MAX;
+		ident_cfg.cfg = tf_ident_p4;
+		ident_cfg.shadow_copy = shadow_copy;
+		ident_cfg.resources = resources;
+		rc = tf_ident_bind(tfp, &ident_cfg);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "Identifier initialization failure\n");
+			goto fail;
+		}
+
+		no_rsv_flag = false;
 	}
 
-	tbl_cfg.num_elements = TF_TBL_TYPE_MAX;
-	tbl_cfg.cfg = tf_tbl_p4;
-	tbl_cfg.shadow_copy = shadow_copy;
-	tbl_cfg.resources = resources;
-	rc = tf_tbl_bind(tfp, &tbl_cfg);
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "Table initialization failure\n");
-		goto fail;
+	rsv_cnt = tf_dev_reservation_check(tfp,
+					   TF_TBL_TYPE_MAX,
+					   tf_tbl_p4,
+					   (uint16_t *)resources->tbl_cnt);
+	if (rsv_cnt) {
+		tbl_cfg.num_elements = TF_TBL_TYPE_MAX;
+		tbl_cfg.cfg = tf_tbl_p4;
+		tbl_cfg.shadow_copy = shadow_copy;
+		tbl_cfg.resources = resources;
+		rc = tf_tbl_bind(tfp, &tbl_cfg);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "Table initialization failure\n");
+			goto fail;
+		}
+
+		no_rsv_flag = false;
 	}
 
-	tcam_cfg.num_elements = TF_TCAM_TBL_TYPE_MAX;
-	tcam_cfg.cfg = tf_tcam_p4;
-	tcam_cfg.shadow_copy = shadow_copy;
-	tcam_cfg.resources = resources;
-	rc = tf_tcam_bind(tfp, &tcam_cfg);
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "TCAM initialization failure\n");
-		goto fail;
+	rsv_cnt = tf_dev_reservation_check(tfp,
+					   TF_TCAM_TBL_TYPE_MAX,
+					   tf_tcam_p4,
+					   (uint16_t *)resources->tcam_cnt);
+	if (rsv_cnt) {
+		tcam_cfg.num_elements = TF_TCAM_TBL_TYPE_MAX;
+		tcam_cfg.cfg = tf_tcam_p4;
+		tcam_cfg.shadow_copy = shadow_copy;
+		tcam_cfg.resources = resources;
+		rc = tf_tcam_bind(tfp, &tcam_cfg);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "TCAM initialization failure\n");
+			goto fail;
+		}
+		no_rsv_flag = false;
 	}
 
 	/*
 	 * EEM
 	 */
-	em_cfg.num_elements = TF_EM_TBL_TYPE_MAX;
 	if (dev_handle->type == TF_DEVICE_TYPE_WH)
 		em_cfg.cfg = tf_em_ext_p4;
 	else
 		em_cfg.cfg = tf_em_ext_p45;
-	em_cfg.resources = resources;
-	em_cfg.mem_type = TF_EEM_MEM_TYPE_HOST;
-	rc = tf_em_ext_common_bind(tfp, &em_cfg);
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "EEM initialization failure\n");
-		goto fail;
+
+	rsv_cnt = tf_dev_reservation_check(tfp,
+					   TF_EM_TBL_TYPE_MAX,
+					   em_cfg.cfg,
+					   (uint16_t *)resources->em_cnt);
+	if (rsv_cnt) {
+		em_cfg.num_elements = TF_EM_TBL_TYPE_MAX;
+		em_cfg.resources = resources;
+		em_cfg.mem_type = TF_EEM_MEM_TYPE_HOST;
+		rc = tf_em_ext_common_bind(tfp, &em_cfg);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "EEM initialization failure\n");
+			goto fail;
+		}
+		no_rsv_flag = false;
 	}
 
 	/*
 	 * EM
 	 */
-	em_cfg.num_elements = TF_EM_TBL_TYPE_MAX;
-	em_cfg.cfg = tf_em_int_p4;
-	em_cfg.resources = resources;
-	em_cfg.mem_type = 0; /* Not used by EM */
+	rsv_cnt = tf_dev_reservation_check(tfp,
+					   TF_EM_TBL_TYPE_MAX,
+					   tf_em_int_p4,
+					   (uint16_t *)resources->em_cnt);
+	if (rsv_cnt) {
+		em_cfg.num_elements = TF_EM_TBL_TYPE_MAX;
+		em_cfg.cfg = tf_em_int_p4;
+		em_cfg.resources = resources;
+		em_cfg.mem_type = 0; /* Not used by EM */
+
+		rc = tf_em_int_bind(tfp, &em_cfg);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "EM initialization failure\n");
+			goto fail;
+		}
+		no_rsv_flag = false;
+	}
 
-	rc = tf_em_int_bind(tfp, &em_cfg);
-	if (rc) {
+	/*
+	 * There is no rm reserved for any tables
+	 *
+	 */
+	if (no_rsv_flag) {
 		TFP_DRV_LOG(ERR,
-			    "EM initialization failure\n");
-		goto fail;
+			    "No rm reserved for any tables\n");
+		return -ENOMEM;
 	}
 
 	/*
@@ -263,6 +351,8 @@ tf_dev_bind_p58(struct tf *tfp,
 {
 	int rc;
 	int frc;
+	int rsv_cnt;
+	bool no_rsv_flag = true;
 	struct tf_ident_cfg_parms ident_cfg;
 	struct tf_tbl_cfg_parms tbl_cfg;
 	struct tf_tcam_cfg_parms tcam_cfg;
@@ -275,52 +365,90 @@ tf_dev_bind_p58(struct tf *tfp,
 
 	/* Initialize the modules */
 
-	ident_cfg.num_elements = TF_IDENT_TYPE_MAX;
-	ident_cfg.cfg = tf_ident_p58;
-	ident_cfg.shadow_copy = shadow_copy;
-	ident_cfg.resources = resources;
-	rc = tf_ident_bind(tfp, &ident_cfg);
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "Identifier initialization failure\n");
-		goto fail;
+	rsv_cnt = tf_dev_reservation_check(tfp,
+					   TF_IDENT_TYPE_MAX,
+					   tf_ident_p58,
+					   (uint16_t *)resources->ident_cnt);
+	if (rsv_cnt) {
+		ident_cfg.num_elements = TF_IDENT_TYPE_MAX;
+		ident_cfg.cfg = tf_ident_p58;
+		ident_cfg.shadow_copy = shadow_copy;
+		ident_cfg.resources = resources;
+		rc = tf_ident_bind(tfp, &ident_cfg);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "Identifier initialization failure\n");
+			goto fail;
+		}
+		no_rsv_flag = false;
 	}
 
-	tbl_cfg.num_elements = TF_TBL_TYPE_MAX;
-	tbl_cfg.cfg = tf_tbl_p58;
-	tbl_cfg.shadow_copy = shadow_copy;
-	tbl_cfg.resources = resources;
-	rc = tf_tbl_bind(tfp, &tbl_cfg);
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "Table initialization failure\n");
-		goto fail;
+	rsv_cnt = tf_dev_reservation_check(tfp,
+					   TF_TBL_TYPE_MAX,
+					   tf_tbl_p58,
+					   (uint16_t *)resources->tbl_cnt);
+	if (rsv_cnt) {
+		tbl_cfg.num_elements = TF_TBL_TYPE_MAX;
+		tbl_cfg.cfg = tf_tbl_p58;
+		tbl_cfg.shadow_copy = shadow_copy;
+		tbl_cfg.resources = resources;
+		rc = tf_tbl_bind(tfp, &tbl_cfg);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "Table initialization failure\n");
+			goto fail;
+		}
+		no_rsv_flag = false;
 	}
 
-	tcam_cfg.num_elements = TF_TCAM_TBL_TYPE_MAX;
-	tcam_cfg.cfg = tf_tcam_p58;
-	tcam_cfg.shadow_copy = shadow_copy;
-	tcam_cfg.resources = resources;
-	rc = tf_tcam_bind(tfp, &tcam_cfg);
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "TCAM initialization failure\n");
-		goto fail;
+	rsv_cnt = tf_dev_reservation_check(tfp,
+					   TF_TCAM_TBL_TYPE_MAX,
+					   tf_tcam_p58,
+					   (uint16_t *)resources->tcam_cnt);
+	if (rsv_cnt) {
+		tcam_cfg.num_elements = TF_TCAM_TBL_TYPE_MAX;
+		tcam_cfg.cfg = tf_tcam_p58;
+		tcam_cfg.shadow_copy = shadow_copy;
+		tcam_cfg.resources = resources;
+		rc = tf_tcam_bind(tfp, &tcam_cfg);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "TCAM initialization failure\n");
+			goto fail;
+		}
+		no_rsv_flag = false;
 	}
 
 	/*
 	 * EM
 	 */
-	em_cfg.num_elements = TF_EM_TBL_TYPE_MAX;
-	em_cfg.cfg = tf_em_int_p58;
-	em_cfg.resources = resources;
-	em_cfg.mem_type = 0; /* Not used by EM */
+	rsv_cnt = tf_dev_reservation_check(tfp,
+					   TF_EM_TBL_TYPE_MAX,
+					   tf_em_int_p58,
+					   (uint16_t *)resources->em_cnt);
+	if (rsv_cnt) {
+		em_cfg.num_elements = TF_EM_TBL_TYPE_MAX;
+		em_cfg.cfg = tf_em_int_p58;
+		em_cfg.resources = resources;
+		em_cfg.mem_type = 0; /* Not used by EM */
+
+		rc = tf_em_int_bind(tfp, &em_cfg);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "EM initialization failure\n");
+			goto fail;
+		}
+		no_rsv_flag = false;
+	}
 
-	rc = tf_em_int_bind(tfp, &em_cfg);
-	if (rc) {
+	/*
+	 * There is no rm reserved for any tables
+	 *
+	 */
+	if (no_rsv_flag) {
 		TFP_DRV_LOG(ERR,
-			    "EM initialization failure\n");
-		goto fail;
+			    "No rm reserved for any tables\n");
+		return -ENOMEM;
 	}
 
 	/*
diff --git a/drivers/net/bnxt/tf_core/tf_session.c b/drivers/net/bnxt/tf_core/tf_session.c
index b3fa7e13ff..d2b24f5e20 100644
--- a/drivers/net/bnxt/tf_core/tf_session.c
+++ b/drivers/net/bnxt/tf_core/tf_session.c
@@ -180,7 +180,7 @@ tf_session_create(struct tf *tfp,
 			 &session->dev);
 	/* Logging handled by dev_bind */
 	if (rc)
-		return rc;
+		goto cleanup;
 
 	if (session->dev.ops->tf_dev_get_mailbox == NULL) {
 		/* Log error */
-- 
2.17.1


^ permalink raw reply	[flat|nested] 129+ messages in thread

* [dpdk-dev] [PATCH 05/58] net/bnxt: update TRUFLOW resources
  2021-05-30  8:58 [dpdk-dev] [PATCH 00/58] enhancements to host based flow table management Venkat Duvvuru
                   ` (3 preceding siblings ...)
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 04/58] net/bnxt: check resource reservation in TRUFLOW Venkat Duvvuru
@ 2021-05-30  8:58 ` Venkat Duvvuru
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 06/58] net/bnxt: add support for EM with FKB Venkat Duvvuru
                   ` (53 subsequent siblings)
  58 siblings, 0 replies; 129+ messages in thread
From: Venkat Duvvuru @ 2021-05-30  8:58 UTC (permalink / raw)
  To: dev; +Cc: Farah Smith, Randy Schacher, Venkat Duvvuru

From: Farah Smith <farah.smith@broadcom.com>

- Remove unused tables from tf_tbl_type
- Encode flow type into flow handle (internal or external)
- Clean up Whitney resource tables
- Clean up Truflow CLI open tables and update Thor resources
- Add Thor SRAM and external pool types to core API
- Remove unneeded Stingray table reference

Signed-off-by: Farah Smith <farah.smith@broadcom.com>
Signed-off-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Jay Ding <jay.ding@broadcom.com>
Reviewed-by: Peter Spreadborough <peter.spreadborough@broadcom.com>
---
 drivers/net/bnxt/tf_core/tf_core.c            |   9 +-
 drivers/net/bnxt/tf_core/tf_core.h            |  83 +++++----
 drivers/net/bnxt/tf_core/tf_device.c          |   5 +-
 drivers/net/bnxt/tf_core/tf_device_p4.c       | 105 ++++-------
 drivers/net/bnxt/tf_core/tf_device_p4.h       | 175 ++++++++++--------
 drivers/net/bnxt/tf_core/tf_device_p45.h      | 105 -----------
 drivers/net/bnxt/tf_core/tf_device_p58.c      |  61 +++---
 drivers/net/bnxt/tf_core/tf_device_p58.h      |   6 +
 drivers/net/bnxt/tf_core/tf_em_common.c       |   2 +-
 drivers/net/bnxt/tf_core/tf_em_internal.c     |   2 +-
 drivers/net/bnxt/tf_core/tf_ext_flow_handle.h |  15 +-
 drivers/net/bnxt/tf_core/tf_msg.c             |   3 +-
 drivers/net/bnxt/tf_core/tf_rm.c              |  14 +-
 drivers/net/bnxt/tf_core/tf_shadow_tbl.c      |   2 -
 drivers/net/bnxt/tf_core/tf_util.c            |   8 +-
 15 files changed, 246 insertions(+), 349 deletions(-)
 delete mode 100644 drivers/net/bnxt/tf_core/tf_device_p45.h

diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c
index b1ce4e721c..ebe0fc34aa 100644
--- a/drivers/net/bnxt/tf_core/tf_core.c
+++ b/drivers/net/bnxt/tf_core/tf_core.c
@@ -19,6 +19,7 @@
 #include "rand.h"
 #include "tf_common.h"
 #include "hwrm_tf.h"
+#include "tf_ext_flow_handle.h"
 
 int
 tf_open_session(struct tf *tfp,
@@ -251,6 +252,7 @@ int tf_delete_em_entry(struct tf *tfp,
 	struct tf_session      *tfs;
 	struct tf_dev_info     *dev;
 	int rc;
+	unsigned int flag = 0;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -274,12 +276,11 @@ int tf_delete_em_entry(struct tf *tfp,
 		return rc;
 	}
 
-	if (parms->mem == TF_MEM_EXTERNAL)
-		rc = dev->ops->tf_dev_delete_ext_em_entry(tfp, parms);
-	else if (parms->mem == TF_MEM_INTERNAL)
+	TF_GET_FLAG_FROM_FLOW_HANDLE(parms->flow_handle, flag);
+	if ((flag & TF_FLAGS_FLOW_HANDLE_INTERNAL))
 		rc = dev->ops->tf_dev_delete_int_em_entry(tfp, parms);
 	else
-		return -EINVAL;
+		rc = dev->ops->tf_dev_delete_ext_em_entry(tfp, parms);
 
 	if (rc) {
 		TFP_DRV_LOG(ERR,
diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h
index 5e458c58fb..4fe0590569 100644
--- a/drivers/net/bnxt/tf_core/tf_core.h
+++ b/drivers/net/bnxt/tf_core/tf_core.h
@@ -158,34 +158,40 @@ enum tf_device_type {
  */
 enum tf_identifier_type {
 	/**
+	 *  WH/SR/TH/SR2
 	 *  The L2 Context is returned from the L2 Ctxt TCAM lookup
 	 *  and can be used in WC TCAM or EM keys to virtualize further
 	 *  lookups.
 	 */
 	TF_IDENT_TYPE_L2_CTXT_HIGH,
 	/**
+	 *  WH/SR/TH/SR2
 	 *  The L2 Context is returned from the L2 Ctxt TCAM lookup
 	 *  and can be used in WC TCAM or EM keys to virtualize further
 	 *  lookups.
 	 */
 	TF_IDENT_TYPE_L2_CTXT_LOW,
 	/**
+	 *  WH/SR/TH/SR2
 	 *  The WC profile func is returned from the L2 Ctxt TCAM lookup
 	 *  to enable virtualization of the profile TCAM.
 	 */
 	TF_IDENT_TYPE_PROF_FUNC,
 	/**
+	 *  WH/SR/TH/SR2
 	 *  The WC profile ID is included in the WC lookup key
 	 *  to enable virtualization of the WC TCAM hardware.
 	 */
 	TF_IDENT_TYPE_WC_PROF,
 	/**
+	 *  WH/SR/TH/SR2
 	 *  The EM profile ID is included in the EM lookup key
 	 *  to enable virtualization of the EM hardware. (not required for SR2
 	 *  as it has table scope)
 	 */
 	TF_IDENT_TYPE_EM_PROF,
 	/**
+	 *  TH/SR2
 	 *  The L2 func is included in the ILT result and from recycling to
 	 *  enable virtualization of further lookups.
 	 */
@@ -203,59 +209,63 @@ enum tf_identifier_type {
 enum tf_tbl_type {
 	/* Internal */
 
-	/** Wh+/SR Action Record */
+	/** Wh+/SR/TH Action Record */
 	TF_TBL_TYPE_FULL_ACT_RECORD,
-	/** Wh+/SR/Th Multicast Groups */
+	/** TH Compact Action Record */
+	TF_TBL_TYPE_COMPACT_ACT_RECORD,
+	/** (Future) Multicast Groups */
 	TF_TBL_TYPE_MCAST_GROUPS,
-	/** Wh+/SR Action Encap 8 Bytes */
+	/** Wh+/SR/TH Action Encap 8 Bytes */
 	TF_TBL_TYPE_ACT_ENCAP_8B,
-	/** Wh+/SR Action Encap 16 Bytes */
+	/** Wh+/SR/TH Action Encap 16 Bytes */
 	TF_TBL_TYPE_ACT_ENCAP_16B,
-	/** Action Encap 32 Bytes */
+	/** WH+/SR/TH Action Encap 32 Bytes */
 	TF_TBL_TYPE_ACT_ENCAP_32B,
-	/** Wh+/SR Action Encap 64 Bytes */
+	/** Wh+/SR/TH Action Encap 64 Bytes */
 	TF_TBL_TYPE_ACT_ENCAP_64B,
-	/** Action Source Properties SMAC */
+	/** WH+/SR/TH Action Source Properties SMAC */
 	TF_TBL_TYPE_ACT_SP_SMAC,
-	/** Wh+/SR Action Source Properties SMAC IPv4 */
+	/** Wh+/SR/TH Action Source Properties SMAC IPv4 */
 	TF_TBL_TYPE_ACT_SP_SMAC_IPV4,
-	/** Action Source Properties SMAC IPv6 */
+	/** WH+/SR/TH Action Source Properties SMAC IPv6 */
 	TF_TBL_TYPE_ACT_SP_SMAC_IPV6,
-	/** Wh+/SR Action Statistics 64 Bits */
+	/** Wh+/SR/TH Action Statistics 64 Bits */
 	TF_TBL_TYPE_ACT_STATS_64,
-	/** Wh+/SR Action Modify L4 Src Port */
-	TF_TBL_TYPE_ACT_MODIFY_SPORT,
-	/** Wh+/SR Action Modify L4 Dest Port */
-	TF_TBL_TYPE_ACT_MODIFY_DPORT,
 	/** Wh+/SR Action Modify IPv4 Source */
 	TF_TBL_TYPE_ACT_MODIFY_IPV4,
-	/** Meter Profiles */
+	/** TH 8B Modify Record */
+	TF_TBL_TYPE_ACT_MODIFY_8B,
+	/** TH 16B Modify Record */
+	TF_TBL_TYPE_ACT_MODIFY_16B,
+	/** TH 32B Modify Record */
+	TF_TBL_TYPE_ACT_MODIFY_32B,
+	/** TH 64B Modify Record */
+	TF_TBL_TYPE_ACT_MODIFY_64B,
+	/** (Future) Meter Profiles */
 	TF_TBL_TYPE_METER_PROF,
-	/** Meter Instance */
+	/** (Future) Meter Instance */
 	TF_TBL_TYPE_METER_INST,
-	/** Mirror Config */
+	/** Wh+/SR/Th Mirror Config */
 	TF_TBL_TYPE_MIRROR_CONFIG,
-	/** UPAR */
+	/** (Future) UPAR */
 	TF_TBL_TYPE_UPAR,
-	/** SR2 Epoch 0 table */
+	/** (Future) SR2 Epoch 0 table */
 	TF_TBL_TYPE_EPOCH0,
-	/** SR2 Epoch 1 table  */
+	/** (Future) SR2 Epoch 1 table  */
 	TF_TBL_TYPE_EPOCH1,
-	/** SR2 Metadata  */
+	/** (Future) TH/SR2 Metadata  */
 	TF_TBL_TYPE_METADATA,
-	/** SR2 CT State  */
+	/** (Future) TH/SR2 CT State  */
 	TF_TBL_TYPE_CT_STATE,
-	/** SR2 Range Profile  */
+	/** (Future) TH/SR2 Range Profile  */
 	TF_TBL_TYPE_RANGE_PROF,
-	/** SR2 Range Entry  */
+	/** (Future) SR2 Range Entry  */
 	TF_TBL_TYPE_RANGE_ENTRY,
-	/** SR2 LAG Entry  */
+	/** (Future) SR2 LAG Entry  */
 	TF_TBL_TYPE_LAG,
-	/** SR2 VNIC/SVIF Table */
-	TF_TBL_TYPE_VNIC_SVIF,
-	/** Th/SR2 EM Flexible Key builder */
+	/** TH/SR2 EM Flexible Key builder */
 	TF_TBL_TYPE_EM_FKB,
-	/** Th/SR2 WC Flexible Key builder */
+	/** TH/SR2 WC Flexible Key builder */
 	TF_TBL_TYPE_WC_FKB,
 
 	/* External */
@@ -263,9 +273,18 @@ enum tf_tbl_type {
 	/**
 	 * External table type - initially 1 poolsize entries.
 	 * All External table types are associated with a table
-	 * scope. Internal types are not.
+	 * scope. Internal types are not.  Currently this is
+	 * a pool of 64B entries.
 	 */
 	TF_TBL_TYPE_EXT,
+	/* (Future) SR2 32B External EM Action 32B Pool */
+	TF_TBL_TYPE_EXT_32B,
+	/* (Future) SR2 64B External EM Action 64B Pool */
+	TF_TBL_TYPE_EXT_64B,
+	/* (Future) SR2 96B External EM Action 96B Pool */
+	TF_TBL_TYPE_EXT_96B,
+	/* (Future) SR2 128B External EM Action 128B Pool */
+	TF_TBL_TYPE_EXT_128B,
 	TF_TBL_TYPE_MAX
 };
 
@@ -1998,8 +2017,8 @@ enum tf_if_tbl_type {
 	TF_IF_TBL_TYPE_LKUP_PARIF_DFLT_ACT_REC_PTR,
 	/** SR2 Ingress lookup table */
 	TF_IF_TBL_TYPE_ILT,
-	/** SR2 VNIC/SVIF Table */
-	TF_IF_TBL_TYPE_VNIC_SVIF,
+	/** SR2 VNIC/SVIF Properties Table */
+	TF_IF_TBL_TYPE_VSPT,
 	TF_IF_TBL_TYPE_MAX
 };
 
diff --git a/drivers/net/bnxt/tf_core/tf_device.c b/drivers/net/bnxt/tf_core/tf_device.c
index d4c93439ec..d072b9877c 100644
--- a/drivers/net/bnxt/tf_core/tf_device.c
+++ b/drivers/net/bnxt/tf_core/tf_device.c
@@ -153,11 +153,8 @@ tf_dev_bind_p4(struct tf *tfp,
 	/*
 	 * EEM
 	 */
-	if (dev_handle->type == TF_DEVICE_TYPE_WH)
-		em_cfg.cfg = tf_em_ext_p4;
-	else
-		em_cfg.cfg = tf_em_ext_p45;
 
+	em_cfg.cfg = tf_em_ext_p4;
 	rsv_cnt = tf_dev_reservation_check(tfp,
 					   TF_EM_TBL_TYPE_MAX,
 					   em_cfg.cfg,
diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.c b/drivers/net/bnxt/tf_core/tf_device_p4.c
index 6b28f6ce59..f6c8f5efd0 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p4.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p4.c
@@ -19,76 +19,41 @@
 #define TF_DEV_P4_PF_MASK 0xfUL
 
 const char *tf_resource_str_p4[CFA_RESOURCE_TYPE_P4_LAST + 1] = {
-	/* CFA_RESOURCE_TYPE_P4_MCG */
-	"mc_group",
-	/* CFA_RESOURCE_TYPE_P4_ENCAP_8B */
-	"encap_8 ",
-	/* CFA_RESOURCE_TYPE_P4_ENCAP_16B */
-	"encap_16",
-	/* CFA_RESOURCE_TYPE_P4_ENCAP_64B */
-	"encap_64",
-	/* CFA_RESOURCE_TYPE_P4_SP_MAC */
-	"sp_mac  ",
-	/* CFA_RESOURCE_TYPE_P4_SP_MAC_IPV4 */
-	"sp_macv4",
-	/* CFA_RESOURCE_TYPE_P4_SP_MAC_IPV6 */
-	"sp_macv6",
-	/* CFA_RESOURCE_TYPE_P4_COUNTER_64B */
-	"ctr_64b ",
-	/* CFA_RESOURCE_TYPE_P4_NAT_PORT */
-	"nat_port",
-	/* CFA_RESOURCE_TYPE_P4_NAT_IPV4 */
-	"nat_ipv4",
-	/* CFA_RESOURCE_TYPE_P4_METER */
-	"meter   ",
-	/* CFA_RESOURCE_TYPE_P4_FLOW_STATE */
-	"flow_st ",
-	/* CFA_RESOURCE_TYPE_P4_FULL_ACTION */
-	"full_act",
-	/* CFA_RESOURCE_TYPE_P4_FORMAT_0_ACTION */
-	"fmt0_act",
-	/* CFA_RESOURCE_TYPE_P4_EXT_FORMAT_0_ACTION */
-	"ext0_act",
-	/* CFA_RESOURCE_TYPE_P4_FORMAT_1_ACTION */
-	"fmt1_act",
-	/* CFA_RESOURCE_TYPE_P4_FORMAT_2_ACTION */
-	"fmt2_act",
-	/* CFA_RESOURCE_TYPE_P4_FORMAT_3_ACTION */
-	"fmt3_act",
-	/* CFA_RESOURCE_TYPE_P4_FORMAT_4_ACTION */
-	"fmt4_act",
-	/* CFA_RESOURCE_TYPE_P4_FORMAT_5_ACTION */
-	"fmt5_act",
-	/* CFA_RESOURCE_TYPE_P4_FORMAT_6_ACTION */
-	"fmt6_act",
-	/* CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_HIGH */
-	"l2ctx_hi",
-	/* CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_LOW */
-	"l2ctx_lo",
-	/* CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP_HIGH */
-	"l2ctr_hi",
-	/* CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP_LOW */
-	"l2ctr_lo",
-	/* CFA_RESOURCE_TYPE_P4_PROF_FUNC */
-	"prf_func",
-	/* CFA_RESOURCE_TYPE_P4_PROF_TCAM */
-	"prf_tcam",
-	/* CFA_RESOURCE_TYPE_P4_EM_PROF_ID */
-	"em_prof ",
-	/* CFA_RESOURCE_TYPE_P4_EM_REC */
-	"em_rec  ",
-	/* CFA_RESOURCE_TYPE_P4_WC_TCAM_PROF_ID */
-	"wc_prof ",
-	/* CFA_RESOURCE_TYPE_P4_WC_TCAM */
-	"wc_tcam ",
-	/* CFA_RESOURCE_TYPE_P4_METER_PROF */
-	"mtr_prof",
-	/* CFA_RESOURCE_TYPE_P4_MIRROR */
-	"mirror  ",
-	/* CFA_RESOURCE_TYPE_P4_SP_TCAM */
-	"sp_tcam ",
-	/* CFA_RESOURCE_TYPE_P4_TBL_SCOPE */
-	"tb_scope",
+	[CFA_RESOURCE_TYPE_P4_MCG] = "mc_group",
+	[CFA_RESOURCE_TYPE_P4_ENCAP_8B] = "encap_8 ",
+	[CFA_RESOURCE_TYPE_P4_ENCAP_16B] = "encap_16",
+	[CFA_RESOURCE_TYPE_P4_ENCAP_64B] = "encap_64",
+	[CFA_RESOURCE_TYPE_P4_SP_MAC] =	"sp_mac  ",
+	[CFA_RESOURCE_TYPE_P4_SP_MAC_IPV4] = "sp_macv4",
+	[CFA_RESOURCE_TYPE_P4_SP_MAC_IPV6] = "sp_macv6",
+	[CFA_RESOURCE_TYPE_P4_COUNTER_64B] = "ctr_64b ",
+	[CFA_RESOURCE_TYPE_P4_NAT_PORT] = "nat_port",
+	[CFA_RESOURCE_TYPE_P4_NAT_IPV4] = "nat_ipv4",
+	[CFA_RESOURCE_TYPE_P4_METER] = "meter   ",
+	[CFA_RESOURCE_TYPE_P4_FLOW_STATE] = "flow_st ",
+	[CFA_RESOURCE_TYPE_P4_FULL_ACTION] = "full_act",
+	[CFA_RESOURCE_TYPE_P4_FORMAT_0_ACTION] = "fmt0_act",
+	[CFA_RESOURCE_TYPE_P4_EXT_FORMAT_0_ACTION] = "ext0_act",
+	[CFA_RESOURCE_TYPE_P4_FORMAT_1_ACTION] = "fmt1_act",
+	[CFA_RESOURCE_TYPE_P4_FORMAT_2_ACTION] = "fmt2_act",
+	[CFA_RESOURCE_TYPE_P4_FORMAT_3_ACTION] = "fmt3_act",
+	[CFA_RESOURCE_TYPE_P4_FORMAT_4_ACTION] = "fmt4_act",
+	[CFA_RESOURCE_TYPE_P4_FORMAT_5_ACTION] = "fmt5_act",
+	[CFA_RESOURCE_TYPE_P4_FORMAT_6_ACTION] = "fmt6_act",
+	[CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_HIGH] = "l2ctx_hi",
+	[CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_LOW] = "l2ctx_lo",
+	[CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP_HIGH] = "l2ctr_hi",
+	[CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP_LOW] = "l2ctr_lo",
+	[CFA_RESOURCE_TYPE_P4_PROF_FUNC] = "prf_func",
+	[CFA_RESOURCE_TYPE_P4_PROF_TCAM] = "prf_tcam",
+	[CFA_RESOURCE_TYPE_P4_EM_PROF_ID] = "em_prof ",
+	[CFA_RESOURCE_TYPE_P4_EM_REC] = "em_rec  ",
+	[CFA_RESOURCE_TYPE_P4_WC_TCAM_PROF_ID] = "wc_prof ",
+	[CFA_RESOURCE_TYPE_P4_WC_TCAM] = "wc_tcam ",
+	[CFA_RESOURCE_TYPE_P4_METER_PROF] = "mtr_prof",
+	[CFA_RESOURCE_TYPE_P4_MIRROR] = "mirror  ",
+	[CFA_RESOURCE_TYPE_P4_SP_TCAM] = "sp_tcam ",
+	[CFA_RESOURCE_TYPE_P4_TBL_SCOPE] = "tb_scope",
 };
 
 /**
diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.h b/drivers/net/bnxt/tf_core/tf_device_p4.h
index bfad02a0b8..ee283ce29d 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p4.h
+++ b/drivers/net/bnxt/tf_core/tf_device_p4.h
@@ -13,98 +13,123 @@
 #include "tf_global_cfg.h"
 
 struct tf_rm_element_cfg tf_ident_p4[TF_IDENT_TYPE_MAX] = {
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP_HIGH },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP_LOW },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_PROF_FUNC },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_WC_TCAM_PROF_ID },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_EM_PROF_ID },
-	/* CFA_RESOURCE_TYPE_P4_L2_FUNC */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID }
+	[TF_IDENT_TYPE_L2_CTXT_HIGH] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP_HIGH
+	},
+	[TF_IDENT_TYPE_L2_CTXT_LOW] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP_LOW
+	},
+	[TF_IDENT_TYPE_PROF_FUNC] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_PROF_FUNC
+	},
+	[TF_IDENT_TYPE_WC_PROF] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_WC_TCAM_PROF_ID
+	},
+	[TF_IDENT_TYPE_EM_PROF] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_EM_PROF_ID
+	},
 };
 
 struct tf_rm_element_cfg tf_tcam_p4[TF_TCAM_TBL_TYPE_MAX] = {
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_HIGH },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_LOW },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_PROF_TCAM },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_WC_TCAM },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_SP_TCAM },
-	/* CFA_RESOURCE_TYPE_P4_CT_RULE_TCAM */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-	/* CFA_RESOURCE_TYPE_P4_VEB_TCAM */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID }
+	[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_HIGH] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_HIGH
+	},
+	[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_LOW] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_LOW
+	},
+	[TF_TCAM_TBL_TYPE_PROF_TCAM] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_PROF_TCAM
+	},
+	[TF_TCAM_TBL_TYPE_WC_TCAM] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_WC_TCAM
+	},
+	[TF_TCAM_TBL_TYPE_SP_TCAM] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_SP_TCAM
+	},
 };
 
 struct tf_rm_element_cfg tf_tbl_p4[TF_TBL_TYPE_MAX] = {
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_FULL_ACTION },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_MCG },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_ENCAP_8B },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_ENCAP_16B },
-	/* CFA_RESOURCE_TYPE_P4_ENCAP_32B */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_ENCAP_64B },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_SP_MAC },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_SP_MAC_IPV4 },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_SP_MAC_IPV6 },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_COUNTER_64B },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_NAT_PORT },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_NAT_PORT },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_NAT_IPV4 },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_METER_PROF },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_METER },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_MIRROR },
-	/* CFA_RESOURCE_TYPE_P4_UPAR */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-	/* CFA_RESOURCE_TYPE_P4_EPOC */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-	/* CFA_RESOURCE_TYPE_P4_METADATA */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-	/* CFA_RESOURCE_TYPE_P4_CT_STATE */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-	/* CFA_RESOURCE_TYPE_P4_RANGE_PROF */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-	/* CFA_RESOURCE_TYPE_P4_RANGE_ENTRY */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-	/* CFA_RESOURCE_TYPE_P4_LAG */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-	/* CFA_RESOURCE_TYPE_P4_VNIC_SVIF */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-	/* CFA_RESOURCE_TYPE_P4_EM_FBK */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-	/* CFA_RESOURCE_TYPE_P4_WC_FKB */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-	/* CFA_RESOURCE_TYPE_P4_EXT */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID }
-};
+	[TF_TBL_TYPE_FULL_ACT_RECORD] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_FULL_ACTION
+	},
+	[TF_TBL_TYPE_MCAST_GROUPS] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_MCG
+	},
+	[TF_TBL_TYPE_ACT_ENCAP_8B] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_ENCAP_8B
+	},
+	[TF_TBL_TYPE_ACT_ENCAP_16B] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_ENCAP_16B
+	},
+	[TF_TBL_TYPE_ACT_ENCAP_64B] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_ENCAP_64B
+	},
+	[TF_TBL_TYPE_ACT_SP_SMAC] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_SP_MAC
+	},
+	[TF_TBL_TYPE_ACT_SP_SMAC_IPV4] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_SP_MAC_IPV4
+	},
+	[TF_TBL_TYPE_ACT_SP_SMAC_IPV6] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_SP_MAC_IPV6
+	},
+	[TF_TBL_TYPE_ACT_STATS_64] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_COUNTER_64B
+	},
+	[TF_TBL_TYPE_ACT_MODIFY_IPV4] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_NAT_IPV4
+	},
+	[TF_TBL_TYPE_METER_PROF] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_METER_PROF
+	},
+	[TF_TBL_TYPE_METER_INST] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_METER
+	},
+	[TF_TBL_TYPE_MIRROR_CONFIG] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_MIRROR
+	},
 
-struct tf_rm_element_cfg tf_em_ext_p4[TF_EM_TBL_TYPE_MAX] = {
-	/* CFA_RESOURCE_TYPE_P4_EM_REC */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_TBL_SCOPE },
 };
 
-struct tf_rm_element_cfg tf_em_ext_p45[TF_EM_TBL_TYPE_MAX] = {
-	/* CFA_RESOURCE_TYPE_P4_EM_REC */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_TBL_SCOPE },
+struct tf_rm_element_cfg tf_em_ext_p4[TF_EM_TBL_TYPE_MAX] = {
+	[TF_EM_TBL_TYPE_TBL_SCOPE] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_TBL_SCOPE
+	},
 };
 
 struct tf_rm_element_cfg tf_em_int_p4[TF_EM_TBL_TYPE_MAX] = {
-	{ TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_EM_REC },
-	/* CFA_RESOURCE_TYPE_P4_TBL_SCOPE */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
+	[TF_EM_TBL_TYPE_EM_RECORD] = {
+		TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_EM_REC
+	},
 };
 
+/* Note that hcapi_types from this table are from hcapi_cfa_p4.h
+ * These are not CFA resource types because they are not allocated
+ * CFA resources - they are identifiers for the interface tables
+ * shared between the firmware and the host.  It may make sense to
+ * move these types to cfa_resource_types.h.
+ */
 struct tf_if_tbl_cfg tf_if_tbl_p4[TF_IF_TBL_TYPE_MAX] = {
-	{ TF_IF_TBL_CFG, CFA_P4_TBL_PROF_SPIF_DFLT_L2CTXT },
-	{ TF_IF_TBL_CFG, CFA_P4_TBL_PROF_PARIF_DFLT_ACT_REC_PTR },
-	{ TF_IF_TBL_CFG, CFA_P4_TBL_PROF_PARIF_ERR_ACT_REC_PTR },
-	{ TF_IF_TBL_CFG, CFA_P4_TBL_LKUP_PARIF_DFLT_ACT_REC_PTR },
-	{ TF_IF_TBL_CFG_NULL, CFA_IF_TBL_TYPE_INVALID },
-	{ TF_IF_TBL_CFG_NULL, CFA_IF_TBL_TYPE_INVALID }
+	[TF_IF_TBL_TYPE_PROF_SPIF_DFLT_L2_CTXT] = {
+		TF_IF_TBL_CFG, CFA_P4_TBL_PROF_SPIF_DFLT_L2CTXT
+	},
+	[TF_IF_TBL_TYPE_PROF_PARIF_DFLT_ACT_REC_PTR] = {
+		TF_IF_TBL_CFG, CFA_P4_TBL_PROF_PARIF_DFLT_ACT_REC_PTR
+	},
+	[TF_IF_TBL_TYPE_PROF_PARIF_ERR_ACT_REC_PTR] = {
+		TF_IF_TBL_CFG, CFA_P4_TBL_PROF_PARIF_ERR_ACT_REC_PTR
+	},
+	[TF_IF_TBL_TYPE_LKUP_PARIF_DFLT_ACT_REC_PTR] = {
+		TF_IF_TBL_CFG, CFA_P4_TBL_LKUP_PARIF_DFLT_ACT_REC_PTR
+	},
 };
 
 struct tf_global_cfg_cfg tf_global_cfg_p4[TF_GLOBAL_CFG_TYPE_MAX] = {
-	{ TF_GLOBAL_CFG_CFG_HCAPI, TF_TUNNEL_ENCAP },
-	{ TF_GLOBAL_CFG_CFG_HCAPI, TF_ACTION_BLOCK },
+	[TF_TUNNEL_ENCAP] = {
+		TF_GLOBAL_CFG_CFG_HCAPI, TF_TUNNEL_ENCAP
+	},
+	[TF_ACTION_BLOCK] = {
+		TF_GLOBAL_CFG_CFG_HCAPI, TF_ACTION_BLOCK
+	},
 };
 #endif /* _TF_DEVICE_P4_H_ */
diff --git a/drivers/net/bnxt/tf_core/tf_device_p45.h b/drivers/net/bnxt/tf_core/tf_device_p45.h
deleted file mode 100644
index 13e04c63fc..0000000000
--- a/drivers/net/bnxt/tf_core/tf_device_p45.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2019-2021 Broadcom
- * All rights reserved.
- */
-
-#ifndef _TF_DEVICE_P45_H_
-#define _TF_DEVICE_P45_H_
-
-#include <cfa_resource_types.h>
-
-#include "tf_core.h"
-#include "tf_rm.h"
-#include "tf_if_tbl.h"
-#include "tf_global_cfg.h"
-
-struct tf_rm_element_cfg tf_ident_p4[TF_IDENT_TYPE_MAX] = {
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_L2_CTXT_REMAP_HIGH },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_L2_CTXT_REMAP_LOW },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_PROF_FUNC },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_WC_TCAM_PROF_ID },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_EM_PROF_ID },
-	/* CFA_RESOURCE_TYPE_P45_L2_FUNC */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID }
-};
-
-struct tf_rm_element_cfg tf_tcam_p4[TF_TCAM_TBL_TYPE_MAX] = {
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_L2_CTXT_TCAM_HIGH },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_L2_CTXT_TCAM_LOW },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_PROF_TCAM },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_WC_TCAM },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_SP_TCAM },
-	/* CFA_RESOURCE_TYPE_P45_CT_RULE_TCAM */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-	/* CFA_RESOURCE_TYPE_P45_VEB_TCAM */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID }
-};
-
-struct tf_rm_element_cfg tf_tbl_p4[TF_TBL_TYPE_MAX] = {
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_FULL_ACTION },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_MCG },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_ENCAP_8B },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_ENCAP_16B },
-	/* CFA_RESOURCE_TYPE_P45_ENCAP_32B */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_ENCAP_64B },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_SP_MAC },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_SP_MAC_IPV4 },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_SP_MAC_IPV6 },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_COUNTER_64B },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_NAT_PORT },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_NAT_PORT },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_NAT_IPV4 },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_METER_PROF },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_METER },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_MIRROR },
-	/* CFA_RESOURCE_TYPE_P45_UPAR */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-	/* CFA_RESOURCE_TYPE_P45_EPOC */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-	/* CFA_RESOURCE_TYPE_P45_METADATA */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-	/* CFA_RESOURCE_TYPE_P45_CT_STATE */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-	/* CFA_RESOURCE_TYPE_P45_RANGE_PROF */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-	/* CFA_RESOURCE_TYPE_P45_RANGE_ENTRY */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-	/* CFA_RESOURCE_TYPE_P45_LAG */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-	/* CFA_RESOURCE_TYPE_P45_VNIC_SVIF */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-	/* CFA_RESOURCE_TYPE_P45_EM_FBK */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-	/* CFA_RESOURCE_TYPE_P45_WC_FKB */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-	/* CFA_RESOURCE_TYPE_P45_EXT */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID }
-};
-
-struct tf_rm_element_cfg tf_em_ext_p4[TF_EM_TBL_TYPE_MAX] = {
-	/* CFA_RESOURCE_TYPE_P45_EM_REC */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_TBL_SCOPE },
-};
-
-struct tf_rm_element_cfg tf_em_int_p4[TF_EM_TBL_TYPE_MAX] = {
-	{ TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P45_EM_REC },
-	/* CFA_RESOURCE_TYPE_P45_TBL_SCOPE */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-};
-
-struct tf_if_tbl_cfg tf_if_tbl_p4[TF_IF_TBL_TYPE_MAX] = {
-	{ TF_IF_TBL_CFG, CFA_P4_TBL_PROF_SPIF_DFLT_L2CTXT },
-	{ TF_IF_TBL_CFG, CFA_P4_TBL_PROF_PARIF_DFLT_ACT_REC_PTR },
-	{ TF_IF_TBL_CFG, CFA_P4_TBL_PROF_PARIF_ERR_ACT_REC_PTR },
-	{ TF_IF_TBL_CFG, CFA_P4_TBL_LKUP_PARIF_DFLT_ACT_REC_PTR },
-	{ TF_IF_TBL_CFG_NULL, CFA_IF_TBL_TYPE_INVALID },
-	{ TF_IF_TBL_CFG_NULL, CFA_IF_TBL_TYPE_INVALID }
-};
-
-struct tf_global_cfg_cfg tf_global_cfg_p4[TF_GLOBAL_CFG_TYPE_MAX] = {
-	{ TF_GLOBAL_CFG_CFG_HCAPI, TF_TUNNEL_ENCAP },
-	{ TF_GLOBAL_CFG_CFG_HCAPI, TF_ACTION_BLOCK },
-};
-#endif /* _TF_DEVICE_P45_H_ */
diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c
index b4530f8762..7dd806000c 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p58.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p58.c
@@ -18,47 +18,28 @@
 #define TF_DEV_P58_PARIF_MAX 16
 #define TF_DEV_P58_PF_MASK 0xfUL
 
+/* For print alignment, make all entries 8 chars in this table */
 const char *tf_resource_str_p58[CFA_RESOURCE_TYPE_P58_LAST + 1] = {
-	/* CFA_RESOURCE_TYPE_P58_METER */
-	"meter   ",
-	/* CFA_RESOURCE_TYPE_P58_SRAM_BANK_0 */
-	"sram_bk0",
-	/* CFA_RESOURCE_TYPE_P58_SRAM_BANK_1 */
-	"sram_bk1",
-	/* CFA_RESOURCE_TYPE_P58_SRAM_BANK_2 */
-	"sram_bk2",
-	/* CFA_RESOURCE_TYPE_P58_SRAM_BANK_3 */
-	"sram_bk3",
-	/* CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_HIGH */
-	"l2ctx_hi",
-	/* CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_LOW */
-	"l2ctx_lo",
-	/* CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP_HIGH */
-	"l2ctr_hi",
-	/* CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP_LOW */
-	"l2ctr_lo",
-	/* CFA_RESOURCE_TYPE_P58_PROF_FUNC */
-	"prf_func",
-	/* CFA_RESOURCE_TYPE_P58_PROF_TCAM */
-	"prf_tcam",
-	/* CFA_RESOURCE_TYPE_P58_EM_PROF_ID */
-	"em_prof ",
-	/* CFA_RESOURCE_TYPE_P58_WC_TCAM_PROF_ID */
-	"wc_prof ",
-	/* CFA_RESOURCE_TYPE_P58_EM_REC */
-	"em_rec  ",
-	/* CFA_RESOURCE_TYPE_P58_WC_TCAM */
-	"wc_tcam ",
-	/* CFA_RESOURCE_TYPE_P58_METER_PROF */
-	"mtr_prof",
-	/* CFA_RESOURCE_TYPE_P58_MIRROR */
-	"mirror  ",
-	/* CFA_RESOURCE_TYPE_P58_EM_FKB */
-	"em_fkb  ",
-	/* CFA_RESOURCE_TYPE_P58_WC_FKB */
-	"wc_fkb  ",
-	/* CFA_RESOURCE_TYPE_P58_VEB_TCAM */
-	"veb     ",
+	[CFA_RESOURCE_TYPE_P58_METER]              = "meter   ",
+	[CFA_RESOURCE_TYPE_P58_SRAM_BANK_0]        = "sram_bk0",
+	[CFA_RESOURCE_TYPE_P58_SRAM_BANK_1]        = "sram_bk1",
+	[CFA_RESOURCE_TYPE_P58_SRAM_BANK_2]        = "sram_bk2",
+	[CFA_RESOURCE_TYPE_P58_SRAM_BANK_3]        = "sram_bk3",
+	[CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_HIGH]  = "l2ctx_hi",
+	[CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_LOW]   = "l2ctx_lo",
+	[CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP_HIGH] = "l2ctr_hi",
+	[CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP_LOW]  = "l2ctr_lo",
+	[CFA_RESOURCE_TYPE_P58_PROF_FUNC]          = "prf_func",
+	[CFA_RESOURCE_TYPE_P58_PROF_TCAM]          = "prf_tcam",
+	[CFA_RESOURCE_TYPE_P58_EM_PROF_ID]         = "em_prof ",
+	[CFA_RESOURCE_TYPE_P58_WC_TCAM_PROF_ID]    = "wc_prof ",
+	[CFA_RESOURCE_TYPE_P58_EM_REC]             = "em_rec  ",
+	[CFA_RESOURCE_TYPE_P58_WC_TCAM]            = "wc_tcam ",
+	[CFA_RESOURCE_TYPE_P58_METER_PROF]         = "mtr_prof",
+	[CFA_RESOURCE_TYPE_P58_MIRROR]             = "mirror  ",
+	[CFA_RESOURCE_TYPE_P58_EM_FKB]             = "em_fkb  ",
+	[CFA_RESOURCE_TYPE_P58_WC_FKB]             = "wc_fkb  ",
+	[CFA_RESOURCE_TYPE_P58_VEB_TCAM]           = "veb     ",
 };
 
 /**
diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.h b/drivers/net/bnxt/tf_core/tf_device_p58.h
index 3d6e3240bf..de7bb1cd76 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p58.h
+++ b/drivers/net/bnxt/tf_core/tf_device_p58.h
@@ -49,6 +49,12 @@ struct tf_rm_element_cfg tf_tcam_p58[TF_TCAM_TBL_TYPE_MAX] = {
 };
 
 struct tf_rm_element_cfg tf_tbl_p58[TF_TBL_TYPE_MAX] = {
+	[TF_TBL_TYPE_EM_FKB] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_EM_FKB
+	},
+	[TF_TBL_TYPE_WC_FKB] = {
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_WC_FKB
+	},
 	[TF_TBL_TYPE_METER_PROF] = {
 		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_METER_PROF
 	},
diff --git a/drivers/net/bnxt/tf_core/tf_em_common.c b/drivers/net/bnxt/tf_core/tf_em_common.c
index ddc6b3c4dd..6cd6086685 100644
--- a/drivers/net/bnxt/tf_core/tf_em_common.c
+++ b/drivers/net/bnxt/tf_core/tf_em_common.c
@@ -777,7 +777,7 @@ tf_insert_eem_entry(struct tf_tbl_scope_cb *tbl_scope_cb,
 	TF_SET_FIELDS_IN_FLOW_HANDLE(parms->flow_handle,
 				     0,
 				     0,
-				     0,
+				     TF_FLAGS_FLOW_HANDLE_EXTERNAL,
 				     index,
 				     0,
 				     table_type);
diff --git a/drivers/net/bnxt/tf_core/tf_em_internal.c b/drivers/net/bnxt/tf_core/tf_em_internal.c
index 62ccd7b78f..bdffd801b3 100644
--- a/drivers/net/bnxt/tf_core/tf_em_internal.c
+++ b/drivers/net/bnxt/tf_core/tf_em_internal.c
@@ -203,7 +203,7 @@ tf_em_insert_int_entry(struct tf *tfp,
 	TF_SET_FIELDS_IN_FLOW_HANDLE(parms->flow_handle,
 				     (uint32_t)num_of_entries,
 				     0,
-				     0,
+				     TF_FLAGS_FLOW_HANDLE_INTERNAL,
 				     rptr_index,
 				     rptr_entry,
 				     0);
diff --git a/drivers/net/bnxt/tf_core/tf_ext_flow_handle.h b/drivers/net/bnxt/tf_core/tf_ext_flow_handle.h
index 9eb5aeb771..bf6dbcd238 100644
--- a/drivers/net/bnxt/tf_core/tf_ext_flow_handle.h
+++ b/drivers/net/bnxt/tf_core/tf_ext_flow_handle.h
@@ -19,6 +19,9 @@
 #define TF_HASH_TYPE_FLOW_HANDLE_MASK		0x0000000100000000ULL
 #define TF_HASH_TYPE_FLOW_HANDLE_SFT		32
 
+#define TF_FLAGS_FLOW_HANDLE_INTERNAL		0x2
+#define TF_FLAGS_FLOW_HANDLE_EXTERNAL		0x0
+
 #define TF_FLOW_HANDLE_MASK (TF_NUM_KEY_ENTRIES_FLOW_HANDLE_MASK |	\
 				TF_FLOW_TYPE_FLOW_HANDLE_MASK |		\
 				TF_FLAGS_FLOW_HANDLE_MASK |		\
@@ -92,15 +95,23 @@ do {									\
 
 #define TF_GET_NUM_KEY_ENTRIES_FROM_FLOW_HANDLE(flow_handle,		\
 					  num_key_entries)		\
+do {									\
 	(num_key_entries =						\
 		(((flow_handle) & TF_NUM_KEY_ENTRIES_FLOW_HANDLE_MASK) >> \
-		     TF_NUM_KEY_ENTRIES_FLOW_HANDLE_SFT))		\
+		     TF_NUM_KEY_ENTRIES_FLOW_HANDLE_SFT));		\
+} while (0)
 
 #define TF_GET_ENTRY_NUM_FROM_FLOW_HANDLE(flow_handle,		\
 					  entry_num)		\
+do {									\
 	(entry_num =						\
 		(((flow_handle) & TF_ENTRY_NUM_FLOW_HANDLE_MASK) >> \
-		     TF_ENTRY_NUM_FLOW_HANDLE_SFT))		\
+		     TF_ENTRY_NUM_FLOW_HANDLE_SFT));		\
+} while (0)
+
+#define TF_GET_FLAG_FROM_FLOW_HANDLE(flow_handle, flag)		\
+	(flag =	(((flow_handle) & TF_FLAGS_FLOW_HANDLE_MASK) >>\
+		     TF_FLAGS_FLOW_HANDLE_SFT))
 
 /*
  * 32 bit Flow ID handlers
diff --git a/drivers/net/bnxt/tf_core/tf_msg.c b/drivers/net/bnxt/tf_core/tf_msg.c
index 1007211363..be30d4a09f 100644
--- a/drivers/net/bnxt/tf_core/tf_msg.c
+++ b/drivers/net/bnxt/tf_core/tf_msg.c
@@ -415,7 +415,6 @@ tf_msg_session_resc_qcaps(struct tf *tfp,
 
 	/* Post process the response */
 	data = (struct tf_rm_resc_req_entry *)qcaps_buf.va_addr;
-
 	for (i = 0; i < size; i++) {
 		query[i].type = tfp_le_to_cpu_32(data[i].type);
 		query[i].min = tfp_le_to_cpu_16(data[i].min);
@@ -1462,7 +1461,7 @@ tf_msg_set_global_cfg(struct tf *tfp,
 	/* Only set mask if pointer is provided
 	 */
 	if (params->config_mask) {
-		tfp_memcpy(req.data + params->config_sz_in_bytes,
+		tfp_memcpy(req.mask,
 			   params->config_mask,
 			   params->config_sz_in_bytes);
 	}
diff --git a/drivers/net/bnxt/tf_core/tf_rm.c b/drivers/net/bnxt/tf_core/tf_rm.c
index 2c08fb80fe..19de6e4c63 100644
--- a/drivers/net/bnxt/tf_core/tf_rm.c
+++ b/drivers/net/bnxt/tf_core/tf_rm.c
@@ -486,14 +486,20 @@ tf_rm_create_db(struct tf *tfp,
 				req[j].max = parms->alloc_cnt[i];
 				j++;
 			} else {
+				const char *type_str;
+				uint16_t hcapi_type = parms->cfg[i].hcapi_type;
+
+				dev->ops->tf_dev_get_resource_str(tfp,
+								  hcapi_type,
+								  &type_str);
 				TFP_DRV_LOG(ERR,
-					    "%s: Resource failure, type:%d\n",
-					    tf_dir_2_str(parms->dir),
-					    parms->cfg[i].hcapi_type);
+					"%s: Resource failure, type:%d:%s\n",
+					tf_dir_2_str(parms->dir),
+					hcapi_type, type_str);
 				TFP_DRV_LOG(ERR,
 					"req:%d, avail:%d\n",
 					parms->alloc_cnt[i],
-					query[parms->cfg[i].hcapi_type].max);
+					query[hcapi_type].max);
 				return -EINVAL;
 			}
 		}
diff --git a/drivers/net/bnxt/tf_core/tf_shadow_tbl.c b/drivers/net/bnxt/tf_core/tf_shadow_tbl.c
index 014e4f3c83..396ebdb0a9 100644
--- a/drivers/net/bnxt/tf_core/tf_shadow_tbl.c
+++ b/drivers/net/bnxt/tf_core/tf_shadow_tbl.c
@@ -177,8 +177,6 @@ static int tf_shadow_tbl_is_searchable(enum tf_tbl_type type)
 	case TF_TBL_TYPE_ACT_SP_SMAC_IPV4:
 	case TF_TBL_TYPE_ACT_SP_SMAC_IPV6:
 	case TF_TBL_TYPE_ACT_MODIFY_IPV4:
-	case TF_TBL_TYPE_ACT_MODIFY_SPORT:
-	case TF_TBL_TYPE_ACT_MODIFY_DPORT:
 		rc = 1;
 		break;
 	default:
diff --git a/drivers/net/bnxt/tf_core/tf_util.c b/drivers/net/bnxt/tf_core/tf_util.c
index ca37df5102..74c8f26204 100644
--- a/drivers/net/bnxt/tf_core/tf_util.c
+++ b/drivers/net/bnxt/tf_core/tf_util.c
@@ -88,12 +88,8 @@ tf_tbl_type_2_str(enum tf_tbl_type tbl_type)
 		return "Source Properties SMAC IPv6";
 	case TF_TBL_TYPE_ACT_STATS_64:
 		return "Stats 64B";
-	case TF_TBL_TYPE_ACT_MODIFY_SPORT:
-		return "NAT Source Port";
-	case TF_TBL_TYPE_ACT_MODIFY_DPORT:
-		return "NAT Destination Port";
 	case TF_TBL_TYPE_ACT_MODIFY_IPV4:
-		return "NAT IPv4";
+		return "Modify IPv4";
 	case TF_TBL_TYPE_METER_PROF:
 		return "Meter Profile";
 	case TF_TBL_TYPE_METER_INST:
@@ -116,8 +112,6 @@ tf_tbl_type_2_str(enum tf_tbl_type tbl_type)
 		return "Range";
 	case TF_TBL_TYPE_LAG:
 		return "Link Aggregation";
-	case TF_TBL_TYPE_VNIC_SVIF:
-		return "VNIC SVIF";
 	case TF_TBL_TYPE_EM_FKB:
 		return "EM Flexible Key Builder";
 	case TF_TBL_TYPE_WC_FKB:
-- 
2.17.1


^ permalink raw reply	[flat|nested] 129+ messages in thread

* [dpdk-dev] [PATCH 06/58] net/bnxt: add support for EM with FKB
  2021-05-30  8:58 [dpdk-dev] [PATCH 00/58] enhancements to host based flow table management Venkat Duvvuru
                   ` (4 preceding siblings ...)
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 05/58] net/bnxt: update TRUFLOW resources Venkat Duvvuru
@ 2021-05-30  8:58 ` Venkat Duvvuru
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 07/58] net/bnxt: add L2 Context TCAM get support Venkat Duvvuru
                   ` (52 subsequent siblings)
  58 siblings, 0 replies; 129+ messages in thread
From: Venkat Duvvuru @ 2021-05-30  8:58 UTC (permalink / raw)
  To: dev; +Cc: Peter Spreadborough, Randy Schacher, Venkat Duvvuru

From: Peter Spreadborough <peter.spreadborough@broadcom.com>

Main TF changes to support EM insert with FKB.
Flexible Key builder is required to create Wild Card
and Exact Match keys for TCAM lookups.

Signed-off-by: Peter Spreadborough <peter.spreadborough@broadcom.com>
Signed-off-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Farah Smith <farah.smith@broadcom.com>
---
 drivers/net/bnxt/tf_core/meson.build          |   1 +
 drivers/net/bnxt/tf_core/tf_device_p58.c      |  14 +-
 drivers/net/bnxt/tf_core/tf_em.h              |  32 +++++
 .../net/bnxt/tf_core/tf_em_hash_internal.c    | 123 ++++++++++++++++++
 drivers/net/bnxt/tf_core/tf_em_internal.c     |   3 +-
 drivers/net/bnxt/tf_core/tf_msg.c             |  96 ++++++++++++++
 drivers/net/bnxt/tf_core/tf_msg.h             |  35 +++++
 7 files changed, 295 insertions(+), 9 deletions(-)
 create mode 100644 drivers/net/bnxt/tf_core/tf_em_hash_internal.c

diff --git a/drivers/net/bnxt/tf_core/meson.build b/drivers/net/bnxt/tf_core/meson.build
index d7e8f664fd..373ee0413b 100644
--- a/drivers/net/bnxt/tf_core/meson.build
+++ b/drivers/net/bnxt/tf_core/meson.build
@@ -30,5 +30,6 @@ sources += files(
         'll.c',
         'tf_global_cfg.c',
         'tf_em_host.c',
+        'tf_em_hash_internal.c',
         'tf_shadow_identifier.c',
         'tf_hash.c')
diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c
index 7dd806000c..6cef1d5ba5 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p58.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p58.c
@@ -256,14 +256,14 @@ const struct tf_dev_ops tf_dev_ops_p58 = {
 	.tf_dev_alloc_search_tcam = tf_tcam_alloc_search,
 	.tf_dev_set_tcam = tf_tcam_set,
 	.tf_dev_get_tcam = NULL,
-	.tf_dev_insert_int_em_entry = tf_em_insert_int_entry,
-	.tf_dev_delete_int_em_entry = tf_em_delete_int_entry,
-	.tf_dev_insert_ext_em_entry = tf_em_insert_ext_entry,
-	.tf_dev_delete_ext_em_entry = tf_em_delete_ext_entry,
-	.tf_dev_alloc_tbl_scope = tf_em_ext_common_alloc,
-	.tf_dev_map_tbl_scope = tf_em_ext_map_tbl_scope,
+	.tf_dev_insert_int_em_entry = tf_em_hash_insert_int_entry,
+	.tf_dev_delete_int_em_entry = tf_em_hash_delete_int_entry,
+	.tf_dev_insert_ext_em_entry = NULL,
+	.tf_dev_delete_ext_em_entry = NULL,
+	.tf_dev_alloc_tbl_scope = NULL,
+	.tf_dev_map_tbl_scope = NULL,
 	.tf_dev_map_parif = tf_dev_p58_map_parif,
-	.tf_dev_free_tbl_scope = tf_em_ext_common_free,
+	.tf_dev_free_tbl_scope = NULL,
 	.tf_dev_set_if_tbl = tf_if_tbl_set,
 	.tf_dev_get_if_tbl = tf_if_tbl_get,
 	.tf_dev_set_global_cfg = tf_global_cfg_set,
diff --git a/drivers/net/bnxt/tf_core/tf_em.h b/drivers/net/bnxt/tf_core/tf_em.h
index b5c3acb09a..5a67ca3509 100644
--- a/drivers/net/bnxt/tf_core/tf_em.h
+++ b/drivers/net/bnxt/tf_core/tf_em.h
@@ -197,6 +197,38 @@ int tf_em_insert_int_entry(struct tf *tfp,
 int tf_em_delete_int_entry(struct tf *tfp,
 			   struct tf_delete_em_entry_parms *parms);
 
+/**
+ * Insert record in to internal EM table
+ *
+ * [in] tfp
+ *   Pointer to TruFlow handle
+ *
+ * [in] parms
+ *   Pointer to input parameters
+ *
+ * Returns:
+ *   0       - Success
+ *   -EINVAL - Parameter error
+ */
+int tf_em_hash_insert_int_entry(struct tf *tfp,
+				struct tf_insert_em_entry_parms *parms);
+
+/**
+ * Delete record from internal EM table
+ *
+ * [in] tfp
+ *   Pointer to TruFlow handle
+ *
+ * [in] parms
+ *   Pointer to input parameters
+ *
+ * Returns:
+ *   0       - Success
+ *   -EINVAL - Parameter error
+ */
+int tf_em_hash_delete_int_entry(struct tf *tfp,
+				struct tf_delete_em_entry_parms *parms);
+
 /**
  * Insert record in to external EEM table
  *
diff --git a/drivers/net/bnxt/tf_core/tf_em_hash_internal.c b/drivers/net/bnxt/tf_core/tf_em_hash_internal.c
new file mode 100644
index 0000000000..09183b42f0
--- /dev/null
+++ b/drivers/net/bnxt/tf_core/tf_em_hash_internal.c
@@ -0,0 +1,123 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019-2021 Broadcom
+ * All rights reserved.
+ */
+
+#include <string.h>
+#include <rte_common.h>
+#include <rte_errno.h>
+#include <rte_log.h>
+
+#include "tf_core.h"
+#include "tf_util.h"
+#include "tf_common.h"
+#include "tf_em.h"
+#include "tf_msg.h"
+#include "tfp.h"
+#include "tf_ext_flow_handle.h"
+
+#include "bnxt.h"
+
+/**
+ * EM Pool
+ */
+extern struct stack em_pool[TF_DIR_MAX];
+
+/**
+ * Insert EM internal entry API
+ *
+ *  returns:
+ *     0 - Success
+ */
+int
+tf_em_hash_insert_int_entry(struct tf *tfp,
+			    struct tf_insert_em_entry_parms *parms)
+{
+	int rc;
+	uint32_t gfid;
+	uint16_t rptr_index = 0;
+	uint8_t rptr_entry = 0;
+	uint8_t num_of_entries = 0;
+	struct stack *pool = &em_pool[parms->dir];
+	uint32_t index;
+	uint32_t key0_hash;
+	uint32_t key1_hash;
+	uint64_t big_hash;
+
+	rc = stack_pop(pool, &index);
+	if (rc) {
+		PMD_DRV_LOG(ERR,
+			    "%s, EM entry index allocation failed\n",
+			    tf_dir_2_str(parms->dir));
+		return rc;
+	}
+
+	big_hash = hcapi_cfa_key_hash((uint64_t *)parms->key,
+				      (TF_HW_EM_KEY_MAX_SIZE + 4) * 8);
+	key0_hash = (uint32_t)(big_hash >> 32);
+	key1_hash = (uint32_t)(big_hash & 0xFFFFFFFF);
+
+	rptr_index = index;
+	rc = tf_msg_hash_insert_em_internal_entry(tfp,
+						  parms,
+						  key0_hash,
+						  key1_hash,
+						  &rptr_index,
+						  &rptr_entry,
+						  &num_of_entries);
+	if (rc) {
+		/* Free the allocated index before returning */
+		stack_push(pool, index);
+		return -1;
+	}
+
+	PMD_DRV_LOG
+		  (DEBUG,
+		   "%s, Internal entry @ Index:%d rptr_index:0x%x rptr_entry:0x%x num_of_entries:%d\n",
+		   tf_dir_2_str(parms->dir),
+		   index,
+		   rptr_index,
+		   rptr_entry,
+		   num_of_entries);
+
+	TF_SET_GFID(gfid,
+		    ((rptr_index << TF_EM_INTERNAL_INDEX_SHIFT) |
+		     rptr_entry),
+		    0); /* N/A for internal table */
+
+	TF_SET_FLOW_ID(parms->flow_id,
+		       gfid,
+		       TF_GFID_TABLE_INTERNAL,
+		       parms->dir);
+
+	TF_SET_FIELDS_IN_FLOW_HANDLE(parms->flow_handle,
+				     (uint32_t)num_of_entries,
+				     0,
+				     0,
+				     rptr_index,
+				     rptr_entry,
+				     0);
+	return 0;
+}
+
+/** Delete EM internal entry API
+ *
+ * returns:
+ * 0
+ * -EINVAL
+ */
+int
+tf_em_hash_delete_int_entry(struct tf *tfp,
+			    struct tf_delete_em_entry_parms *parms)
+{
+	int rc = 0;
+	struct stack *pool = &em_pool[parms->dir];
+
+	rc = tf_msg_delete_em_entry(tfp, parms);
+
+	/* Return resource to pool */
+	if (rc == 0)
+		stack_push(pool, parms->index);
+
+	return rc;
+}
diff --git a/drivers/net/bnxt/tf_core/tf_em_internal.c b/drivers/net/bnxt/tf_core/tf_em_internal.c
index bdffd801b3..0864218469 100644
--- a/drivers/net/bnxt/tf_core/tf_em_internal.c
+++ b/drivers/net/bnxt/tf_core/tf_em_internal.c
@@ -30,11 +30,10 @@ static void *em_db[TF_DIR_MAX];
  */
 static uint8_t init;
 
-
 /**
  * EM Pool
  */
-static struct stack em_pool[TF_DIR_MAX];
+struct stack em_pool[TF_DIR_MAX];
 
 /**
  * Create EM Tbl pool of memory indexes.
diff --git a/drivers/net/bnxt/tf_core/tf_msg.c b/drivers/net/bnxt/tf_core/tf_msg.c
index be30d4a09f..39d7e3eace 100644
--- a/drivers/net/bnxt/tf_core/tf_msg.c
+++ b/drivers/net/bnxt/tf_core/tf_msg.c
@@ -25,6 +25,7 @@
  */
 #define TF_MSG_SET_GLOBAL_CFG_DATA_SIZE  16
 #define TF_MSG_EM_INSERT_KEY_SIZE        64
+#define TF_MSG_EM_INSERT_RECORD_SIZE     80
 #define TF_MSG_TBL_TYPE_SET_DATA_SIZE    88
 
 /* Compile check - Catch any msg changes that we depend on, like the
@@ -706,6 +707,101 @@ tf_msg_insert_em_internal_entry(struct tf *tfp,
 	return 0;
 }
 
+int
+tf_msg_hash_insert_em_internal_entry(struct tf *tfp,
+				     struct tf_insert_em_entry_parms *em_parms,
+				     uint32_t key0_hash,
+				     uint32_t key1_hash,
+				     uint16_t *rptr_index,
+				     uint8_t *rptr_entry,
+				     uint8_t *num_of_entries)
+{
+	int rc;
+	struct tfp_send_msg_parms parms = { 0 };
+	struct hwrm_tf_em_hash_insert_input req = { 0 };
+	struct hwrm_tf_em_hash_insert_output resp = { 0 };
+	uint16_t flags;
+	uint8_t fw_session_id;
+	uint8_t msg_record_size;
+	struct tf_dev_info *dev;
+	struct tf_session *tfs;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(em_parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup device, rc:%s\n",
+			    tf_dir_2_str(em_parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Unable to lookup FW id, rc:%s\n",
+			    tf_dir_2_str(em_parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Populate the request */
+	req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
+
+	/* Check for key size conformity */
+	msg_record_size = (em_parms->em_record_sz_in_bits + 7) / 8;
+
+	if (msg_record_size > TF_MSG_EM_INSERT_RECORD_SIZE) {
+		rc = -EINVAL;
+		TFP_DRV_LOG(ERR,
+			    "%s: Record size to large, rc:%s\n",
+			    tf_dir_2_str(em_parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	tfp_memcpy((char *)req.em_record,
+		   em_parms->em_record,
+		   msg_record_size);
+
+	flags = (em_parms->dir == TF_DIR_TX ?
+		 HWRM_TF_EM_INSERT_INPUT_FLAGS_DIR_TX :
+		 HWRM_TF_EM_INSERT_INPUT_FLAGS_DIR_RX);
+	req.flags = tfp_cpu_to_le_16(flags);
+	req.em_record_size_bits = em_parms->em_record_sz_in_bits;
+	req.em_record_idx = *rptr_index;
+	req.key0_hash = key0_hash;
+	req.key1_hash = key1_hash;
+
+	parms.tf_type = HWRM_TF_EM_HASH_INSERT;
+	parms.req_data = (uint32_t *)&req;
+	parms.req_size = sizeof(req);
+	parms.resp_data = (uint32_t *)&resp;
+	parms.resp_size = sizeof(resp);
+	parms.mailbox = dev->ops->tf_dev_get_mailbox();
+
+	rc = tfp_send_msg_direct(tfp,
+				 &parms);
+	if (rc)
+		return rc;
+
+	*rptr_entry = resp.rptr_entry;
+	*rptr_index = resp.rptr_index;
+	*num_of_entries = resp.num_of_entries;
+
+	return 0;
+}
+
 int
 tf_msg_delete_em_entry(struct tf *tfp,
 		       struct tf_delete_em_entry_parms *em_parms)
diff --git a/drivers/net/bnxt/tf_core/tf_msg.h b/drivers/net/bnxt/tf_core/tf_msg.h
index 25e29a554f..1d82ce5049 100644
--- a/drivers/net/bnxt/tf_core/tf_msg.h
+++ b/drivers/net/bnxt/tf_core/tf_msg.h
@@ -225,6 +225,41 @@ int tf_msg_insert_em_internal_entry(struct tf *tfp,
 				    uint16_t *rptr_index,
 				    uint8_t *rptr_entry,
 				    uint8_t *num_of_entries);
+/**
+ * Sends EM hash internal insert request to Firmware
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [in] params
+ *   Pointer to em insert parameter list
+ *
+ * [in] key0_hash
+ *      CRC32 hash of key
+ *
+ * [in] key1_hash
+ *      Lookup3 hash of key
+ *
+ * [in] rptr_index
+ *   Record ptr index
+ *
+ * [in] rptr_entry
+ *   Record ptr entry
+ *
+ * [in] num_of_entries
+ *   Number of entries to insert
+ *
+ * Returns:
+ *   0 on Success else internal Truflow error
+ */
+int
+tf_msg_hash_insert_em_internal_entry(struct tf *tfp,
+				struct tf_insert_em_entry_parms *em_parms,
+				uint32_t key0_hash,
+				uint32_t key1_hash,
+				uint16_t *rptr_index,
+				uint8_t *rptr_entry,
+				uint8_t *num_of_entries);
 /**
  * Sends EM internal delete request to Firmware
  *
-- 
2.17.1


^ permalink raw reply	[flat|nested] 129+ messages in thread

* [dpdk-dev] [PATCH 07/58] net/bnxt: add L2 Context TCAM get support
  2021-05-30  8:58 [dpdk-dev] [PATCH 00/58] enhancements to host based flow table management Venkat Duvvuru
                   ` (5 preceding siblings ...)
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 06/58] net/bnxt: add support for EM with FKB Venkat Duvvuru
@ 2021-05-30  8:58 ` Venkat Duvvuru
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 08/58] net/bnxt: add action SRAM Translation Venkat Duvvuru
                   ` (51 subsequent siblings)
  58 siblings, 0 replies; 129+ messages in thread
From: Venkat Duvvuru @ 2021-05-30  8:58 UTC (permalink / raw)
  To: dev; +Cc: Jay Ding, Randy Schacher, Venkat Duvvuru

From: Jay Ding <jay.ding@broadcom.com>

- Implement TCAM get in host
- Add Thor support for TCAM set/free

Signed-off-by: Jay Ding <jay.ding@broadcom.com>
Signed-off-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Peter Spreadborough <peter.spreadborough@broadcom.com>
Reviewed-by: Farah Smith <farah.smith@broadcom.com>
---
 drivers/net/bnxt/tf_core/hwrm_tf.h       |  1 +
 drivers/net/bnxt/tf_core/tf_core.c       | 65 +++++++++++++++--
 drivers/net/bnxt/tf_core/tf_device.h     | 12 ++++
 drivers/net/bnxt/tf_core/tf_device_p4.c  |  6 ++
 drivers/net/bnxt/tf_core/tf_device_p58.c |  9 ++-
 drivers/net/bnxt/tf_core/tf_msg.c        | 52 ++++++++++++++
 drivers/net/bnxt/tf_core/tf_msg.h        | 16 +++++
 drivers/net/bnxt/tf_core/tf_tcam.c       | 89 +++++++++++++++++++++++-
 drivers/net/bnxt/tf_core/tf_tcam.h       |  4 ++
 9 files changed, 248 insertions(+), 6 deletions(-)

diff --git a/drivers/net/bnxt/tf_core/hwrm_tf.h b/drivers/net/bnxt/tf_core/hwrm_tf.h
index a707cd2758..9cc9a1435c 100644
--- a/drivers/net/bnxt/tf_core/hwrm_tf.h
+++ b/drivers/net/bnxt/tf_core/hwrm_tf.h
@@ -65,6 +65,7 @@ typedef enum tf_subtype {
 
 #define TF_BITS2BYTES(x) (((x) + 7) >> 3)
 #define TF_BITS2BYTES_WORD_ALIGN(x) ((((x) + 31) >> 5) * 4)
+#define TF_BITS2BYTES_64B_WORD_ALIGN(x) ((((x) + 63) >> 6) * 8)
 
 struct tf_set_global_cfg_input;
 struct tf_get_global_cfg_input;
diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c
index ebe0fc34aa..a3b6afbc88 100644
--- a/drivers/net/bnxt/tf_core/tf_core.c
+++ b/drivers/net/bnxt/tf_core/tf_core.c
@@ -764,7 +764,8 @@ tf_set_tcam_entry(struct tf *tfp,
 		return rc;
 	}
 
-	if (dev->ops->tf_dev_set_tcam == NULL) {
+	if (dev->ops->tf_dev_set_tcam == NULL ||
+	    dev->ops->tf_dev_word_align == NULL) {
 		rc = -EOPNOTSUPP;
 		TFP_DRV_LOG(ERR,
 			    "%s: Operation not supported, rc:%s\n",
@@ -778,7 +779,7 @@ tf_set_tcam_entry(struct tf *tfp,
 	sparms.idx = parms->idx;
 	sparms.key = parms->key;
 	sparms.mask = parms->mask;
-	sparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
+	sparms.key_size = dev->ops->tf_dev_word_align(parms->key_sz_in_bits);
 	sparms.result = parms->result;
 	sparms.result_size = TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
 
@@ -796,10 +797,66 @@ tf_set_tcam_entry(struct tf *tfp,
 
 int
 tf_get_tcam_entry(struct tf *tfp __rte_unused,
-		  struct tf_get_tcam_entry_parms *parms __rte_unused)
+		  struct tf_get_tcam_entry_parms *parms)
 {
+	int rc;
+	struct tf_session *tfs;
+	struct tf_dev_info *dev;
+	struct tf_tcam_get_parms gparms;
+
 	TF_CHECK_PARMS2(tfp, parms);
-	return -EOPNOTSUPP;
+
+	memset(&gparms, 0, sizeof(struct tf_tcam_get_parms));
+
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup device, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	if (dev->ops->tf_dev_get_tcam == NULL) {
+		rc = -EOPNOTSUPP;
+		TFP_DRV_LOG(ERR,
+			    "%s: Operation not supported, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	gparms.dir = parms->dir;
+	gparms.type = parms->tcam_tbl_type;
+	gparms.idx = parms->idx;
+	gparms.key = parms->key;
+	gparms.mask = parms->mask;
+	gparms.result = parms->result;
+
+	rc = dev->ops->tf_dev_get_tcam(tfp, &gparms);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: TCAM get failed, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+	parms->key_sz_in_bits = gparms.key_size * 8;
+	parms->result_sz_in_bits = gparms.result_size * 8;
+
+	return 0;
 }
 
 int
diff --git a/drivers/net/bnxt/tf_core/tf_device.h b/drivers/net/bnxt/tf_core/tf_device.h
index cbacc09ea5..4f4120c603 100644
--- a/drivers/net/bnxt/tf_core/tf_device.h
+++ b/drivers/net/bnxt/tf_core/tf_device.h
@@ -736,6 +736,18 @@ struct tf_dev_ops {
 	 *      mailbox
 	 */
 	int (*tf_dev_get_mailbox)(void);
+
+	/**
+	 * Convert length in bit to length in byte and align to word.
+	 * The word length depends on device type.
+	 *
+	 * [in] size
+	 *   Size in bit
+	 *
+	 * Returns
+	 *   Size in byte
+	 */
+	int (*tf_dev_word_align)(uint16_t size);
 };
 
 /**
diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.c b/drivers/net/bnxt/tf_core/tf_device_p4.c
index f6c8f5efd0..fbe92b7733 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p4.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p4.c
@@ -212,6 +212,10 @@ static int tf_dev_p4_get_mailbox(void)
 	return TF_KONG_MB;
 }
 
+static int tf_dev_p4_word_align(uint16_t size)
+{
+	return ((((size) + 31) >> 5) * 4);
+}
 
 /**
  * Truflow P4 device specific functions
@@ -250,6 +254,7 @@ const struct tf_dev_ops tf_dev_ops_p4_init = {
 	.tf_dev_set_global_cfg = NULL,
 	.tf_dev_get_global_cfg = NULL,
 	.tf_dev_get_mailbox = tf_dev_p4_get_mailbox,
+	.tf_dev_word_align = NULL,
 };
 
 /**
@@ -289,4 +294,5 @@ const struct tf_dev_ops tf_dev_ops_p4 = {
 	.tf_dev_set_global_cfg = tf_global_cfg_set,
 	.tf_dev_get_global_cfg = tf_global_cfg_get,
 	.tf_dev_get_mailbox = tf_dev_p4_get_mailbox,
+	.tf_dev_word_align = tf_dev_p4_word_align,
 };
diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c
index 6cef1d5ba5..688d987cb7 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p58.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p58.c
@@ -193,6 +193,11 @@ static int tf_dev_p58_get_mailbox(void)
 	return TF_CHIMP_MB;
 }
 
+static int tf_dev_p58_word_align(uint16_t size)
+{
+	return ((((size) + 63) >> 6) * 8);
+}
+
 /**
  * Truflow P58 device specific functions
  */
@@ -230,6 +235,7 @@ const struct tf_dev_ops tf_dev_ops_p58_init = {
 	.tf_dev_set_global_cfg = NULL,
 	.tf_dev_get_global_cfg = NULL,
 	.tf_dev_get_mailbox = tf_dev_p58_get_mailbox,
+	.tf_dev_word_align = NULL,
 };
 
 /**
@@ -255,7 +261,7 @@ const struct tf_dev_ops tf_dev_ops_p58 = {
 	.tf_dev_free_tcam = tf_tcam_free,
 	.tf_dev_alloc_search_tcam = tf_tcam_alloc_search,
 	.tf_dev_set_tcam = tf_tcam_set,
-	.tf_dev_get_tcam = NULL,
+	.tf_dev_get_tcam = tf_tcam_get,
 	.tf_dev_insert_int_em_entry = tf_em_hash_insert_int_entry,
 	.tf_dev_delete_int_em_entry = tf_em_hash_delete_int_entry,
 	.tf_dev_insert_ext_em_entry = NULL,
@@ -269,4 +275,5 @@ const struct tf_dev_ops tf_dev_ops_p58 = {
 	.tf_dev_set_global_cfg = tf_global_cfg_set,
 	.tf_dev_get_global_cfg = tf_global_cfg_get,
 	.tf_dev_get_mailbox = tf_dev_p58_get_mailbox,
+	.tf_dev_word_align = tf_dev_p58_word_align,
 };
diff --git a/drivers/net/bnxt/tf_core/tf_msg.c b/drivers/net/bnxt/tf_core/tf_msg.c
index 39d7e3eace..1af5c6d11c 100644
--- a/drivers/net/bnxt/tf_core/tf_msg.c
+++ b/drivers/net/bnxt/tf_core/tf_msg.c
@@ -1212,6 +1212,58 @@ tf_msg_tcam_entry_set(struct tf *tfp,
 	return rc;
 }
 
+int
+tf_msg_tcam_entry_get(struct tf *tfp,
+		      struct tf_dev_info *dev,
+		      struct tf_tcam_get_parms *parms)
+{
+	int rc;
+	struct tfp_send_msg_parms mparms = { 0 };
+	struct hwrm_tf_tcam_get_input req = { 0 };
+	struct hwrm_tf_tcam_get_output resp = { 0 };
+	uint8_t fw_session_id;
+
+	rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Unable to lookup FW id, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Populate the request */
+	req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
+	req.type = parms->hcapi_type;
+	req.idx = tfp_cpu_to_le_16(parms->idx);
+	if (parms->dir == TF_DIR_TX)
+		req.flags |= HWRM_TF_TCAM_GET_INPUT_FLAGS_DIR_TX;
+
+	mparms.tf_type = HWRM_TF_TCAM_GET;
+	mparms.req_data = (uint32_t *)&req;
+	mparms.req_size = sizeof(req);
+	mparms.resp_data = (uint32_t *)&resp;
+	mparms.resp_size = sizeof(resp);
+	mparms.mailbox = dev->ops->tf_dev_get_mailbox();
+
+	rc = tfp_send_msg_direct(tfp,
+				 &mparms);
+
+	if (rc != 0)
+		return rc;
+
+	if (mparms.tf_resp_code != 0)
+		return tfp_le_to_cpu_32(mparms.tf_resp_code);
+
+	parms->key_size = resp.key_size;
+	parms->result_size = resp.result_size;
+	tfp_memcpy(parms->key, resp.dev_data, resp.key_size);
+	tfp_memcpy(parms->mask, &resp.dev_data[resp.key_size], resp.key_size);
+	tfp_memcpy(parms->result, &resp.dev_data[resp.result_offset], resp.result_size);
+
+	return tfp_le_to_cpu_32(mparms.tf_resp_code);
+}
+
 int
 tf_msg_tcam_entry_free(struct tf *tfp,
 		       struct tf_dev_info *dev,
diff --git a/drivers/net/bnxt/tf_core/tf_msg.h b/drivers/net/bnxt/tf_core/tf_msg.h
index 1d82ce5049..a14bcd3927 100644
--- a/drivers/net/bnxt/tf_core/tf_msg.h
+++ b/drivers/net/bnxt/tf_core/tf_msg.h
@@ -412,6 +412,22 @@ int tf_msg_tcam_entry_set(struct tf *tfp,
 			  struct tf_dev_info *dev,
 			  struct tf_tcam_set_parms *parms);
 
+/**
+ * Sends tcam entry 'get' to the Firmware.
+ *
+ * [in] tfp
+ *   Pointer to session handle
+ *
+ * [in] parms
+ *   Pointer to get parameters
+ *
+ * Returns:
+ *  0 on Success else internal Truflow error
+ */
+int tf_msg_tcam_entry_get(struct tf *tfp,
+			  struct tf_dev_info *dev,
+			  struct tf_tcam_get_parms *parms);
+
 /**
  * Sends tcam entry 'free' to the Firmware.
  *
diff --git a/drivers/net/bnxt/tf_core/tf_tcam.c b/drivers/net/bnxt/tf_core/tf_tcam.c
index 038aa40e92..a18d0e1e19 100644
--- a/drivers/net/bnxt/tf_core/tf_tcam.c
+++ b/drivers/net/bnxt/tf_core/tf_tcam.c
@@ -686,7 +686,94 @@ tf_tcam_set(struct tf *tfp __rte_unused,
 
 int
 tf_tcam_get(struct tf *tfp __rte_unused,
-	    struct tf_tcam_get_parms *parms __rte_unused)
+	    struct tf_tcam_get_parms *parms)
 {
+	int rc;
+	struct tf_session *tfs;
+	struct tf_dev_info *dev;
+	struct tf_rm_is_allocated_parms aparms;
+	struct tf_rm_get_hcapi_parms hparms;
+	uint16_t num_slice_per_row = 1;
+	int allocated = 0;
+
+	TF_CHECK_PARMS2(tfp, parms);
+
+	if (!init) {
+		TFP_DRV_LOG(ERR,
+			    "%s: No TCAM DBs created\n",
+			    tf_dir_2_str(parms->dir));
+		return -EINVAL;
+	}
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc)
+		return rc;
+
+	if (dev->ops->tf_dev_get_tcam_slice_info == NULL) {
+		rc = -EOPNOTSUPP;
+		TFP_DRV_LOG(ERR,
+			    "%s: Operation not supported, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Need to retrieve row size etc */
+	rc = dev->ops->tf_dev_get_tcam_slice_info(tfp,
+						  parms->type,
+						  parms->key_size,
+						  &num_slice_per_row);
+	if (rc)
+		return rc;
+
+	/* Check if element is in use */
+	memset(&aparms, 0, sizeof(aparms));
+
+	aparms.rm_db = tcam_db[parms->dir];
+	aparms.db_index = parms->type;
+	aparms.index = parms->idx / num_slice_per_row;
+	aparms.allocated = &allocated;
+	rc = tf_rm_is_allocated(&aparms);
+	if (rc)
+		return rc;
+
+	if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Entry is not allocated, type:%d, index:%d\n",
+			    tf_dir_2_str(parms->dir),
+			    parms->type,
+			    parms->idx);
+		return -EINVAL;
+	}
+
+	/* Convert TF type to HCAPI RM type */
+	memset(&hparms, 0, sizeof(hparms));
+
+	hparms.rm_db = tcam_db[parms->dir];
+	hparms.db_index = parms->type;
+	hparms.hcapi_type = &parms->hcapi_type;
+
+	rc = tf_rm_get_hcapi_type(&hparms);
+	if (rc)
+		return rc;
+
+	rc = tf_msg_tcam_entry_get(tfp, dev, parms);
+	if (rc) {
+		/* Log error */
+		TFP_DRV_LOG(ERR,
+			    "%s: %s: Entry %d set failed, rc:%s",
+			    tf_dir_2_str(parms->dir),
+			    tf_tcam_tbl_2_str(parms->type),
+			    parms->idx,
+			    strerror(-rc));
+		return rc;
+	}
+
 	return 0;
 }
diff --git a/drivers/net/bnxt/tf_core/tf_tcam.h b/drivers/net/bnxt/tf_core/tf_tcam.h
index 40d010b09a..b550fa43ca 100644
--- a/drivers/net/bnxt/tf_core/tf_tcam.h
+++ b/drivers/net/bnxt/tf_core/tf_tcam.h
@@ -207,6 +207,10 @@ struct tf_tcam_get_parms {
 	 * [in] Type of object to get
 	 */
 	enum tf_tcam_tbl_type type;
+	/**
+	 * [in] Type of HCAPI
+	 */
+	uint16_t hcapi_type;
 	/**
 	 * [in] Entry index to read
 	 */
-- 
2.17.1


^ permalink raw reply	[flat|nested] 129+ messages in thread

* [dpdk-dev] [PATCH 08/58] net/bnxt: add action SRAM Translation
  2021-05-30  8:58 [dpdk-dev] [PATCH 00/58] enhancements to host based flow table management Venkat Duvvuru
                   ` (6 preceding siblings ...)
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 07/58] net/bnxt: add L2 Context TCAM get support Venkat Duvvuru
@ 2021-05-30  8:58 ` Venkat Duvvuru
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 09/58] net/bnxt: add Thor WC TCAM support Venkat Duvvuru
                   ` (50 subsequent siblings)
  58 siblings, 0 replies; 129+ messages in thread
From: Venkat Duvvuru @ 2021-05-30  8:58 UTC (permalink / raw)
  To: dev; +Cc: Farah Smith, Randy Schacher, Venkat Duvvuru

From: Farah Smith <farah.smith@broadcom.com>

- Translate Truflow action types for Thor to HCAPI RM
  resource defined SRAM banks.
- move module type enum definitions to tf_core API
- Switch to subtype concept for RM.
- alloc/free working for Thor SRAM table type for full AR.

Signed-off-by: Farah Smith <farah.smith@broadcom.com>
Signed-off-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Peter Spreadborough <peter.spreadborough@broadcom.com>
Reviewed-by: Randy Schacher <stuart.schacher@broadcom.com>
---
 drivers/net/bnxt/bnxt_util.h                |   3 +
 drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h      | 339 +++------
 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_defs.h | 387 +---------
 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.h  | 411 ++++++++++
 drivers/net/bnxt/tf_core/meson.build        |   1 -
 drivers/net/bnxt/tf_core/tf_core.h          |  24 +
 drivers/net/bnxt/tf_core/tf_device.c        |  43 +-
 drivers/net/bnxt/tf_core/tf_device.h        |  23 -
 drivers/net/bnxt/tf_core/tf_device_p4.c     |  21 +-
 drivers/net/bnxt/tf_core/tf_device_p58.c    |  53 +-
 drivers/net/bnxt/tf_core/tf_device_p58.h    | 110 ++-
 drivers/net/bnxt/tf_core/tf_em_common.c     |   4 +-
 drivers/net/bnxt/tf_core/tf_em_host.c       |   6 +-
 drivers/net/bnxt/tf_core/tf_em_internal.c   |   4 +-
 drivers/net/bnxt/tf_core/tf_identifier.c    |  10 +-
 drivers/net/bnxt/tf_core/tf_if_tbl.c        |   2 +-
 drivers/net/bnxt/tf_core/tf_rm.c            | 508 ++++++++-----
 drivers/net/bnxt/tf_core/tf_rm.h            | 109 ++-
 drivers/net/bnxt/tf_core/tf_shadow_tbl.c    | 783 --------------------
 drivers/net/bnxt/tf_core/tf_shadow_tbl.h    | 256 -------
 drivers/net/bnxt/tf_core/tf_tbl.c           | 238 +-----
 drivers/net/bnxt/tf_core/tf_tcam.c          |  20 +-
 drivers/net/bnxt/tf_core/tf_util.c          |  36 +-
 drivers/net/bnxt/tf_core/tf_util.h          |  26 +-
 24 files changed, 1130 insertions(+), 2287 deletions(-)
 create mode 100644 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.h
 delete mode 100644 drivers/net/bnxt/tf_core/tf_shadow_tbl.c
 delete mode 100644 drivers/net/bnxt/tf_core/tf_shadow_tbl.h

diff --git a/drivers/net/bnxt/bnxt_util.h b/drivers/net/bnxt/bnxt_util.h
index 64e97eed15..b243c21ec2 100644
--- a/drivers/net/bnxt/bnxt_util.h
+++ b/drivers/net/bnxt/bnxt_util.h
@@ -9,6 +9,9 @@
 #ifndef BIT
 #define BIT(n)	(1UL << (n))
 #endif /* BIT */
+#ifndef BIT_MASK
+#define BIT_MASK(len) (BIT(len) - 1)
+#endif /* BIT_MASK */
 
 #define PCI_SUBSYSTEM_ID_OFFSET	0x2e
 
diff --git a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h
index b8c85a0fca..c67aa29ad0 100644
--- a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h
+++ b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h
@@ -1,281 +1,126 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2019-2021 Broadcom
- * All rights reserved.
+/*
+ *   Copyright(c) Broadcom Limited.
+ *   All rights reserved.
  */
 
+/*!
+ *   \file
+ *   \brief Exported functions for CFA HW programming
+ */
 #ifndef _HCAPI_CFA_H_
 #define _HCAPI_CFA_H_
 
 #include <stdio.h>
+#include <stddef.h>
 #include <string.h>
 #include <stdbool.h>
 #include <stdint.h>
 #include <stddef.h>
+#include <errno.h>
 
 #include "hcapi_cfa_defs.h"
 
-/**
- * Index used for the sram_entries field
- */
-enum hcapi_cfa_resc_type_sram {
-	HCAPI_CFA_RESC_TYPE_SRAM_FULL_ACTION,
-	HCAPI_CFA_RESC_TYPE_SRAM_MCG,
-	HCAPI_CFA_RESC_TYPE_SRAM_ENCAP_8B,
-	HCAPI_CFA_RESC_TYPE_SRAM_ENCAP_16B,
-	HCAPI_CFA_RESC_TYPE_SRAM_ENCAP_64B,
-	HCAPI_CFA_RESC_TYPE_SRAM_SP_SMAC,
-	HCAPI_CFA_RESC_TYPE_SRAM_SP_SMAC_IPV4,
-	HCAPI_CFA_RESC_TYPE_SRAM_SP_SMAC_IPV6,
-	HCAPI_CFA_RESC_TYPE_SRAM_COUNTER_64B,
-	HCAPI_CFA_RESC_TYPE_SRAM_NAT_SPORT,
-	HCAPI_CFA_RESC_TYPE_SRAM_NAT_DPORT,
-	HCAPI_CFA_RESC_TYPE_SRAM_NAT_S_IPV4,
-	HCAPI_CFA_RESC_TYPE_SRAM_NAT_D_IPV4,
-	HCAPI_CFA_RESC_TYPE_SRAM_MAX
-};
-
-/**
- * Index used for the hw_entries field in struct cfa_rm_db
- */
-enum hcapi_cfa_resc_type_hw {
-	/* common HW resources for all chip variants */
-	HCAPI_CFA_RESC_TYPE_HW_L2_CTXT_TCAM,
-	HCAPI_CFA_RESC_TYPE_HW_PROF_FUNC,
-	HCAPI_CFA_RESC_TYPE_HW_PROF_TCAM,
-	HCAPI_CFA_RESC_TYPE_HW_EM_PROF_ID,
-	HCAPI_CFA_RESC_TYPE_HW_EM_REC,
-	HCAPI_CFA_RESC_TYPE_HW_WC_TCAM_PROF_ID,
-	HCAPI_CFA_RESC_TYPE_HW_WC_TCAM,
-	HCAPI_CFA_RESC_TYPE_HW_METER_PROF,
-	HCAPI_CFA_RESC_TYPE_HW_METER_INST,
-	HCAPI_CFA_RESC_TYPE_HW_MIRROR,
-	HCAPI_CFA_RESC_TYPE_HW_UPAR,
-	/* Wh+/SR specific HW resources */
-	HCAPI_CFA_RESC_TYPE_HW_SP_TCAM,
-	/* Thor, SR2 common HW resources */
-	HCAPI_CFA_RESC_TYPE_HW_FKB,
-	/* SR specific HW resources */
-	HCAPI_CFA_RESC_TYPE_HW_TBL_SCOPE,
-	HCAPI_CFA_RESC_TYPE_HW_L2_FUNC,
-	HCAPI_CFA_RESC_TYPE_HW_EPOCH0,
-	HCAPI_CFA_RESC_TYPE_HW_EPOCH1,
-	HCAPI_CFA_RESC_TYPE_HW_METADATA,
-	HCAPI_CFA_RESC_TYPE_HW_CT_STATE,
-	HCAPI_CFA_RESC_TYPE_HW_RANGE_PROF,
-	HCAPI_CFA_RESC_TYPE_HW_RANGE_ENTRY,
-	HCAPI_CFA_RESC_TYPE_HW_LAG_ENTRY,
-	HCAPI_CFA_RESC_TYPE_HW_MAX
-};
-
-struct hcapi_cfa_key_result {
-	uint64_t bucket_mem_ptr;
-	uint8_t bucket_idx;
-};
-
-/* common CFA register access macros */
-#define CFA_REG(x)		OFFSETOF(cfa_reg_t, cfa_##x)
-
-#ifndef TF_REG_WR
-#define TF_REG_WR(_p, x, y)  (*((uint32_t volatile *)(x)) = (y))
-#endif
-#ifndef TF_REG_RD
-#define TF_REG_RD(_p, x)  (*((uint32_t volatile *)(x)))
-#endif
-#ifndef TF_CFA_REG_RD
-#define TF_CFA_REG_RD(_p, x)	\
-	TF_REG_RD(0, (uint32_t)(_p)->base_addr + CFA_REG(x))
-#endif
-#ifndef TF_CFA_REG_WR
-#define TF_CFA_REG_WR(_p, x, y)	\
-	TF_REG_WR(0, (uint32_t)(_p)->base_addr + CFA_REG(x), y)
-#endif
+#define INVALID_U64 (0xFFFFFFFFFFFFFFFFULL)
+#define INVALID_U32 (0xFFFFFFFFUL)
+#define INVALID_U16 (0xFFFFUL)
+#define INVALID_U8 (0xFFUL)
 
-/* Constants used by Resource Manager Registration*/
-#define RM_CLIENT_NAME_MAX_LEN          32
+struct hcapi_cfa_devops;
 
 /**
- *  Resource Manager Data Structures used for resource requests
+ * CFA device information
  */
-struct hcapi_cfa_resc_req_entry {
-	uint16_t min;
-	uint16_t max;
-};
-
-struct hcapi_cfa_resc_req {
-	/* Wh+/SR specific onchip Action SRAM resources */
-	/* Validity of each sram type is indicated by the
-	 * corresponding sram type bit in the sram_resc_flags. When
-	 * set to 1, the CFA sram resource type is valid and amount of
-	 * resources for this type is reserved. Each sram resource
-	 * pool is identified by the starting index and number of
-	 * resources in the pool.
-	 */
-	uint32_t sram_resc_flags;
-	struct hcapi_cfa_resc_req_entry sram_resc[HCAPI_CFA_RESC_TYPE_SRAM_MAX];
-
-	/* Validity of each resource type is indicated by the
-	 * corresponding resource type bit in the hw_resc_flags. When
-	 * set to 1, the CFA resource type is valid and amount of
-	 * resource of this type is reserved. Each resource pool is
-	 * identified by the starting index and the number of
-	 * resources in the pool.
-	 */
-	uint32_t hw_resc_flags;
-	struct hcapi_cfa_resc_req_entry hw_resc[HCAPI_CFA_RESC_TYPE_HW_MAX];
-};
-
-struct hcapi_cfa_resc_req_db {
-	struct hcapi_cfa_resc_req rx;
-	struct hcapi_cfa_resc_req tx;
-};
-
-struct hcapi_cfa_resc_entry {
-	uint16_t start;
-	uint16_t stride;
-	uint16_t tag;
-};
-
-struct hcapi_cfa_resc {
-	/* Wh+/SR specific onchip Action SRAM resources */
-	/* Validity of each sram type is indicated by the
-	 * corresponding sram type bit in the sram_resc_flags. When
-	 * set to 1, the CFA sram resource type is valid and amount of
-	 * resources for this type is reserved. Each sram resource
-	 * pool is identified by the starting index and number of
-	 * resources in the pool.
-	 */
-	uint32_t sram_resc_flags;
-	struct hcapi_cfa_resc_entry sram_resc[HCAPI_CFA_RESC_TYPE_SRAM_MAX];
-
-	/* Validity of each resource type is indicated by the
-	 * corresponding resource type bit in the hw_resc_flags. When
-	 * set to 1, the CFA resource type is valid and amount of
-	 * resource of this type is reserved. Each resource pool is
-	 * identified by the starting index and the number of resources
-	 * in the pool.
-	 */
-	uint32_t hw_resc_flags;
-	struct hcapi_cfa_resc_entry hw_resc[HCAPI_CFA_RESC_TYPE_HW_MAX];
-};
-
-struct hcapi_cfa_resc_db {
-	struct hcapi_cfa_resc rx;
-	struct hcapi_cfa_resc tx;
+struct hcapi_cfa_devinfo {
+	/** [out] CFA device ops function pointer table */
+	const struct hcapi_cfa_devops *devops;
 };
 
 /**
- * This is the main data structure used by the CFA Resource
- * Manager.  This data structure holds all the state and table
- * management information.
+ *  \defgroup CFA_HCAPI_DEVICE_API
+ *  HCAPI used for writing to the hardware
+ *  @{
  */
-typedef struct hcapi_cfa_rm_data {
-	uint32_t dummy_data;
-} hcapi_cfa_rm_data_t;
-
-/* End RM support */
-
-struct hcapi_cfa_devops;
-
-struct hcapi_cfa_devinfo {
-	uint8_t global_cfg_data[CFA_GLOBAL_CFG_DATA_SZ];
-	struct hcapi_cfa_layout_tbl layouts;
-	struct hcapi_cfa_devops *devops;
-};
-
-int hcapi_cfa_dev_bind(enum hcapi_cfa_ver hw_ver,
-		       struct hcapi_cfa_devinfo *dev_info);
-
-int hcapi_cfa_key_compile_layout(struct hcapi_cfa_key_template *key_template,
-				 struct hcapi_cfa_key_layout *key_layout);
-uint64_t hcapi_cfa_key_hash(uint64_t *key_data, uint16_t bitlen);
-int
-hcapi_cfa_action_compile_layout(struct hcapi_cfa_action_template *act_template,
-				struct hcapi_cfa_action_layout *act_layout);
-int hcapi_cfa_action_init_obj(uint64_t *act_obj,
-			      struct hcapi_cfa_action_layout *act_layout);
-int hcapi_cfa_action_compute_ptr(uint64_t *act_obj,
-				 struct hcapi_cfa_action_layout *act_layout,
-				 uint32_t base_ptr);
-
-int hcapi_cfa_action_hw_op(struct hcapi_cfa_hwop *op,
-			   uint8_t *act_tbl,
-			   struct hcapi_cfa_data *act_obj);
-int hcapi_cfa_dev_hw_op(struct hcapi_cfa_hwop *op, uint16_t tbl_id,
-			struct hcapi_cfa_data *obj_data);
-int hcapi_cfa_rm_register_client(hcapi_cfa_rm_data_t *data,
-				 const char *client_name,
-				 int *client_id);
-int hcapi_cfa_rm_unregister_client(hcapi_cfa_rm_data_t *data,
-				   int client_id);
-int hcapi_cfa_rm_query_resources(hcapi_cfa_rm_data_t *data,
-				 int client_id,
-				 uint16_t chnl_id,
-				 struct hcapi_cfa_resc_req_db *req_db);
-int hcapi_cfa_rm_query_resources_one(hcapi_cfa_rm_data_t *data,
-				     int clien_id,
-				     struct hcapi_cfa_resc_db *resc_db);
-int hcapi_cfa_rm_reserve_resources(hcapi_cfa_rm_data_t *data,
-				   int client_id,
-				   struct hcapi_cfa_resc_req_db *resc_req,
-				   struct hcapi_cfa_resc_db *resc_db);
-int hcapi_cfa_rm_release_resources(hcapi_cfa_rm_data_t *data,
-				   int client_id,
-				   struct hcapi_cfa_resc_req_db *resc_req,
-				   struct hcapi_cfa_resc_db *resc_db);
-int hcapi_cfa_rm_initialize(hcapi_cfa_rm_data_t *data);
 
-#if SUPPORT_CFA_HW_P4
-
-int hcapi_cfa_p4_dev_hw_op(struct hcapi_cfa_hwop *op, uint16_t tbl_id,
-			    struct hcapi_cfa_data *obj_data);
-int hcapi_cfa_p4_prof_l2ctxt_hwop(struct hcapi_cfa_hwop *op,
-				   struct hcapi_cfa_data *obj_data);
-int hcapi_cfa_p4_prof_l2ctxtrmp_hwop(struct hcapi_cfa_hwop *op,
-				      struct hcapi_cfa_data *obj_data);
-int hcapi_cfa_p4_prof_tcam_hwop(struct hcapi_cfa_hwop *op,
-				 struct hcapi_cfa_data *obj_data);
-int hcapi_cfa_p4_prof_tcamrmp_hwop(struct hcapi_cfa_hwop *op,
-				    struct hcapi_cfa_data *obj_data);
-int hcapi_cfa_p4_wc_tcam_hwop(struct hcapi_cfa_hwop *op,
-			       struct hcapi_cfa_data *obj_data);
-int hcapi_cfa_p4_wc_tcam_rec_hwop(struct hcapi_cfa_hwop *op,
-				   struct hcapi_cfa_data *obj_data);
-int hcapi_cfa_p4_mirror_hwop(struct hcapi_cfa_hwop *op,
-			     struct hcapi_cfa_data *mirror);
-int hcapi_cfa_p4_global_cfg_hwop(struct hcapi_cfa_hwop *op,
-				 uint32_t type,
-				 struct hcapi_cfa_data *config);
-/* SUPPORT_CFA_HW_P4 */
-#elif SUPPORT_CFA_HW_P45
-int hcapi_cfa_p45_mirror_hwop(struct hcapi_cfa_hwop *op,
-			      struct hcapi_cfa_data *mirror);
-int hcapi_cfa_p45_global_cfg_hwop(struct hcapi_cfa_hwop *op,
-				  uint32_t type,
-				  struct hcapi_cfa_data *config);
-/* SUPPORT_CFA_HW_P45 */
-#endif
-/**
- *  HCAPI CFA device HW operation function callback definition
- *  This is standardized function callback hook to install different
- *  CFA HW table programming function callback.
+/** CFA device specific function hooks structure
+ *
+ * The following device hooks can be defined; unless noted otherwise, they are
+ * optional and can be filled with a null pointer. The pupose of these hooks
+ * to support CFA device operations for different device variants.
  */
+struct hcapi_cfa_devops {
+	/** calculate a key hash for the provided key_data
+	 *
+	 * This API computes hash for a key.
+	 *
+	 * @param[in] key_data
+	 *   A pointer of the key data buffer
+	 *
+	 * @param[in] bitlen
+	 *   Number of bits of the key data
+	 *
+	 * @return
+	 *   0 for SUCCESS, negative value for FAILURE
+	 */
+	uint64_t (*hcapi_cfa_key_hash)(uint64_t *key_data, uint16_t bitlen);
 
-struct hcapi_cfa_tbl_cb {
-	/**
-	 * This function callback provides the functionality to read/write
-	 * HW table entry from a HW table.
+	/** hardware operation on the CFA EM key
+	 *
+	 * This API provides the functionality to program the exact match and
+	 * key data to exact match record memory.
 	 *
 	 * @param[in] op
 	 *   A pointer to the Hardware operation parameter
 	 *
-	 * @param[in] obj_data
-	 *   A pointer to the HW data object for the hardware operation
+	 * @param[in] key_tbl
+	 *   A pointer to the off-chip EM key table (applicable to EEM and
+	 *   SR2 EM only), set to NULL for on-chip EM key table or WC
+	 *   TCAM table.
 	 *
+	 * @param[in/out] key_obj
+	 *   A pointer to the key data object for the hardware operation which
+	 *   has the following contents:
+	 *     1. key record memory offset (index to WC TCAM or EM key hash
+	 *        value)
+	 *     2. key data
+	 *   When using the HWOP PUT, the key_obj holds the LREC and key to
+	 *   be written.
+	 *   When using the HWOP GET, the key_obj be populated with the LREC
+	 *   and key which was specified by the key location object.
+	 *
+	 * @param[in/out] key_loc
+	 *   When using the HWOP PUT, this is a pointer to the key location
+	 *   data structure which holds the information of where the EM key
+	 *   is stored.  It holds the bucket index and the data pointer of
+	 *   a dynamic bucket that is chained to static bucket
+	 *   When using the HWOP GET, this is a pointer to the key location
+	 *   which should be retreved.
+	 *
+	 *   (valid for SR2 only).
 	 * @return
 	 *   0 for SUCCESS, negative value for FAILURE
 	 */
-	int (*hwop_cb)(struct hcapi_cfa_hwop *op,
-		       struct hcapi_cfa_data *obj_data);
+	int (*hcapi_cfa_key_hw_op)(struct hcapi_cfa_hwop *op,
+				   struct hcapi_cfa_key_tbl *key_tbl,
+				   struct hcapi_cfa_key_data *key_data,
+				   struct hcapi_cfa_key_loc *key_loc);
 };
 
-#endif  /* HCAPI_CFA_H_ */
+/*@}*/
+
+extern const size_t CFA_RM_HANDLE_DATA_SIZE;
+
+#if SUPPORT_CFA_HW_ALL
+extern const struct hcapi_cfa_devops cfa_p4_devops;
+extern const struct hcapi_cfa_devops cfa_p58_devops;
+
+#elif defined(SUPPORT_CFA_HW_P4) && SUPPORT_CFA_HW_P4
+extern const struct hcapi_cfa_devops cfa_p4_devops;
+uint64_t hcapi_cfa_p4_key_hash(uint64_t *key_data, uint16_t bitlen);
+/* SUPPORT_CFA_HW_P4 */
+#elif defined(SUPPORT_CFA_HW_P58) && SUPPORT_CFA_HW_P58
+extern const struct hcapi_cfa_devops cfa_p58_devops;
+uint64_t hcapi_cfa_p58_key_hash(uint64_t *key_data, uint16_t bitlen);
+/* SUPPORT_CFA_HW_P58 */
+#endif
+
+#endif /* HCAPI_CFA_H_ */
diff --git a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_defs.h b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_defs.h
index 08f098ec86..8e5095a6ef 100644
--- a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_defs.h
+++ b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_defs.h
@@ -30,12 +30,10 @@
 
 #define CFA_GLOBAL_CFG_DATA_SZ (100)
 
+#if SUPPORT_CFA_HW_ALL
 #include "hcapi_cfa_p4.h"
-#define CFA_PROF_L2CTXT_TCAM_MAX_FIELD_CNT CFA_P40_PROF_L2_CTXT_TCAM_MAX_FLD
-#define CFA_PROF_L2CTXT_REMAP_MAX_FIELD_CNT CFA_P40_PROF_L2_CTXT_RMP_DR_MAX_FLD
-#define CFA_PROF_MAX_KEY_CFG_SZ sizeof(struct cfa_p4_prof_key_cfg)
-#define CFA_KEY_MAX_FIELD_CNT 41
-#define CFA_ACT_MAX_TEMPLATE_SZ sizeof(struct cfa_p4_action_template)
+#include "hcapi_cfa_p58.h"
+#endif /* SUPPORT_CFA_HW_ALL */
 
 /**
  * CFA HW version definition
@@ -87,43 +85,6 @@ enum hcapi_cfa_key_ctrlops {
 	HCAPI_CFA_KEY_CTRLOPS_MAX
 };
 
-/**
- * CFA HW field structure definition
- */
-struct hcapi_cfa_field {
-	/** [in] Starting bit position pf the HW field within a HW table
-	 *  entry.
-	 */
-	uint16_t bitpos;
-	/** [in] Number of bits for the HW field. */
-	uint8_t bitlen;
-};
-
-/**
- * CFA HW table entry layout structure definition
- */
-struct hcapi_cfa_layout {
-	/** [out] Bit order of layout */
-	bool is_msb_order;
-	/** [out] Size in bits of entry */
-	uint32_t total_sz_in_bits;
-	/** [out] data pointer of the HW layout fields array */
-	const struct hcapi_cfa_field *field_array;
-	/** [out] number of HW field entries in the HW layout field array */
-	uint32_t array_sz;
-	/** [out] layout_id - layout id associated with the layout */
-	uint16_t layout_id;
-};
-
-/**
- * CFA HW data object definition
- */
-struct hcapi_cfa_data_obj {
-	/** [in] HW field identifier. Used as an index to a HW table layout */
-	uint16_t field_id;
-	/** [in] Value of the HW field */
-	uint64_t val;
-};
 
 /**
  * CFA HW definition
@@ -280,348 +241,6 @@ struct hcapi_cfa_key_loc {
 	uint8_t bucket_idx;
 };
 
-/**
- * CFA HW layout table definition
- */
-struct hcapi_cfa_layout_tbl {
-	/** [out] data pointer to an array of fix formatted layouts supported.
-	 *  The index to the array is the CFA HW table ID
-	 */
-	const struct hcapi_cfa_layout *tbl;
-	/** [out] number of fix formatted layouts in the layout array */
-	uint16_t num_layouts;
-};
-
-/**
- * Key template consists of key fields that can be enabled/disabled
- * individually.
- */
-struct hcapi_cfa_key_template {
-	/** [in] key field enable field array, set 1 to the correspeonding
-	 *  field enable to make a field valid
-	 */
-	uint8_t field_en[CFA_KEY_MAX_FIELD_CNT];
-	/** [in] Identified if the key template is for TCAM. If false, the
-	 *  the key template is for EM. This field is mandantory for device that
-	 *  only support fix key formats.
-	 */
-	bool is_wc_tcam_key;
-};
-
-/**
- * key layout consist of field array, key bitlen, key ID, and other meta data
- * pertain to a key
- */
-struct hcapi_cfa_key_layout {
-	/** [out] key layout data */
-	struct hcapi_cfa_layout *layout;
-	/** [out] actual key size in number of bits */
-	uint16_t bitlen;
-	/** [out] key identifier and this field is only valid for device
-	 *  that supports fix key formats
-	 */
-	uint16_t id;
-	/** [out] Identified the key layout is WC TCAM key */
-	bool is_wc_tcam_key;
-	/** [out] total slices size, valid for WC TCAM key only. It can be
-	 *  used by the user to determine the total size of WC TCAM key slices
-	 *  in bytes.
-	 */
-	uint16_t slices_size;
-};
-
-/**
- * key layout memory contents
- */
-struct hcapi_cfa_key_layout_contents {
-	/** key layouts */
-	struct hcapi_cfa_key_layout key_layout;
-
-	/** layout */
-	struct hcapi_cfa_layout layout;
-
-	/** fields */
-	struct hcapi_cfa_field field_array[CFA_KEY_MAX_FIELD_CNT];
-};
-
-/**
- * Action template consists of action fields that can be enabled/disabled
- * individually.
- */
-struct hcapi_cfa_action_template {
-	/** [in] CFA version for the action template */
-	enum hcapi_cfa_ver hw_ver;
-	/** [in] action field enable field array, set 1 to the correspeonding
-	 *  field enable to make a field valid
-	 */
-	uint8_t data[CFA_ACT_MAX_TEMPLATE_SZ];
-};
-
-/**
- * action layout consist of field array, action wordlen and action format ID
- */
-struct hcapi_cfa_action_layout {
-	/** [in] action identifier */
-	uint16_t id;
-	/** [out] action layout data */
-	struct hcapi_cfa_layout *layout;
-	/** [out] actual action record size in number of bits */
-	uint16_t wordlen;
-};
-
-/**
- *  \defgroup CFA_HCAPI_PUT_API
- *  HCAPI used for writing to the hardware
- *  @{
- */
-
-/**
- * This API provides the functionality to program a specified value to a
- * HW field based on the provided programming layout.
- *
- * @param[in,out] obj_data
- *   A data pointer to a CFA HW key/mask data
- *
- * @param[in] layout
- *   A pointer to CFA HW programming layout
- *
- * @param[in] field_id
- *   ID of the HW field to be programmed
- *
- * @param[in] val
- *   Value of the HW field to be programmed
- *
- * @return
- *   0 for SUCCESS, negative value for FAILURE
- */
-int hcapi_cfa_put_field(uint64_t *data_buf,
-			const struct hcapi_cfa_layout *layout,
-			uint16_t field_id, uint64_t val);
-
-/**
- * This API provides the functionality to program an array of field values
- * with corresponding field IDs to a number of profiler sub-block fields
- * based on the fixed profiler sub-block hardware programming layout.
- *
- * @param[in, out] obj_data
- *   A pointer to a CFA profiler key/mask object data
- *
- * @param[in] layout
- *   A pointer to CFA HW programming layout
- *
- * @param[in] field_tbl
- *   A pointer to an array that consists of the object field
- *   ID/value pairs
- *
- * @param[in] field_tbl_sz
- *   Number of entries in the table
- *
- * @return
- *   0 for SUCCESS, negative value for FAILURE
- */
-int hcapi_cfa_put_fields(uint64_t *obj_data,
-			 const struct hcapi_cfa_layout *layout,
-			 struct hcapi_cfa_data_obj *field_tbl,
-			 uint16_t field_tbl_sz);
-
-/**
- * This API provides the functionality to write a value to a
- * field within the bit position and bit length of a HW data
- * object based on a provided programming layout.
- *
- * @param[in, out] act_obj
- *   A pointer of the action object to be initialized
- *
- * @param[in] layout
- *   A pointer of the programming layout
- *
- * @param field_id
- *   [in] Identifier of the HW field
- *
- * @param[in] bitpos_adj
- *   Bit position adjustment value
- *
- * @param[in] bitlen_adj
- *   Bit length adjustment value
- *
- * @param[in] val
- *   HW field value to be programmed
- *
- * @return
- *   0 for SUCCESS, negative value for FAILURE
- */
-int hcapi_cfa_put_field_rel(uint64_t *obj_data,
-			    const struct hcapi_cfa_layout *layout,
-			    uint16_t field_id, int16_t bitpos_adj,
-			    int16_t bitlen_adj, uint64_t val);
-
-/*@}*/
-
-/**
- *  \defgroup CFA_HCAPI_GET_API
- *  HCAPI used for writing to the hardware
- *  @{
- */
-
-/**
- * This API provides the functionality to get the word length of
- * a layout object.
- *
- * @param[in] layout
- *   A pointer of the HW layout
- *
- * @return
- *   Word length of the layout object
- */
-uint16_t hcapi_cfa_get_wordlen(const struct hcapi_cfa_layout *layout);
-
-/**
- * The API provides the functionality to get bit offset and bit
- * length information of a field from a programming layout.
- *
- * @param[in] layout
- *   A pointer of the action layout
- *
- * @param[out] slice
- *   A pointer to the action offset info data structure
- *
- * @return
- *   0 for SUCCESS, negative value for FAILURE
- */
-int hcapi_cfa_get_slice(const struct hcapi_cfa_layout *layout,
-			uint16_t field_id, struct hcapi_cfa_field *slice);
-
-/**
- * This API provides the functionality to read the value of a
- * CFA HW field from CFA HW data object based on the hardware
- * programming layout.
- *
- * @param[in] obj_data
- *   A pointer to a CFA HW key/mask object data
- *
- * @param[in] layout
- *   A pointer to CFA HW programming layout
- *
- * @param[in] field_id
- *   ID of the HW field to be programmed
- *
- * @param[out] val
- *   Value of the HW field
- *
- * @return
- *   0 for SUCCESS, negative value for FAILURE
- */
-int hcapi_cfa_get_field(uint64_t *obj_data,
-			const struct hcapi_cfa_layout *layout,
-			uint16_t field_id, uint64_t *val);
-
-/**
- * This API provides the functionality to read a number of
- * HW fields from a CFA HW data object based on the hardware
- * programming layout.
- *
- * @param[in] obj_data
- *   A pointer to a CFA profiler key/mask object data
- *
- * @param[in] layout
- *   A pointer to CFA HW programming layout
- *
- * @param[in, out] field_tbl
- *   A pointer to an array that consists of the object field
- *   ID/value pairs
- *
- * @param[in] field_tbl_sz
- *   Number of entries in the table
- *
- * @return
- *   0 for SUCCESS, negative value for FAILURE
- */
-int hcapi_cfa_get_fields(uint64_t *obj_data,
-			 const struct hcapi_cfa_layout *layout,
-			 struct hcapi_cfa_data_obj *field_tbl,
-			 uint16_t field_tbl_sz);
-
-/**
- * Get a value to a specific location relative to a HW field
- *
- * This API provides the functionality to read HW field from
- * a section of a HW data object identified by the bit position
- * and bit length from a given programming layout in order to avoid
- * reading the entire HW data object.
- *
- * @param[in] obj_data
- *   A pointer of the data object to read from
- *
- * @param[in] layout
- *   A pointer of the programming layout
- *
- * @param[in] field_id
- *   Identifier of the HW field
- *
- * @param[in] bitpos_adj
- *   Bit position adjustment value
- *
- * @param[in] bitlen_adj
- *   Bit length adjustment value
- *
- * @param[out] val
- *   Value of the HW field
- *
- * @return
- *   0 for SUCCESS, negative value for FAILURE
- */
-int hcapi_cfa_get_field_rel(uint64_t *obj_data,
-			    const struct hcapi_cfa_layout *layout,
-			    uint16_t field_id, int16_t bitpos_adj,
-			    int16_t bitlen_adj, uint64_t *val);
-
-/**
- * This function is used to initialize a layout_contents structure
- *
- * The struct hcapi_cfa_key_layout is complex as there are three
- * layers of abstraction.  Each of those layer need to be properly
- * initialized.
- *
- * @param[in] layout_contents
- *  A pointer of the layout contents to initialize
- *
- * @return
- *   0 for SUCCESS, negative value for FAILURE
- */
-int
-hcapi_cfa_init_key_layout_contents(struct hcapi_cfa_key_layout_contents *cont);
-
-/**
- * This function is used to validate a key template
- *
- * The struct hcapi_cfa_key_template is complex as there are three
- * layers of abstraction.  Each of those layer need to be properly
- * validated.
- *
- * @param[in] key_template
- *  A pointer of the key template contents to validate
- *
- * @return
- *   0 for SUCCESS, negative value for FAILURE
- */
-int
-hcapi_cfa_is_valid_key_template(struct hcapi_cfa_key_template *key_template);
-
-/**
- * This function is used to validate a key layout
- *
- * The struct hcapi_cfa_key_layout is complex as there are three
- * layers of abstraction.  Each of those layer need to be properly
- * validated.
- *
- * @param[in] key_layout
- *  A pointer of the key layout contents to validate
- *
- * @return
- *   0 for SUCCESS, negative value for FAILURE
- */
-int hcapi_cfa_is_valid_key_layout(struct hcapi_cfa_key_layout *key_layout);
-
 /**
  * This function is used to hash E/EM keys
  *
diff --git a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.h b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.h
new file mode 100644
index 0000000000..b2535098d2
--- /dev/null
+++ b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.h
@@ -0,0 +1,411 @@
+/*
+ *   Copyright(c) Broadcom Limited.
+ *   All rights reserved.
+ */
+
+#ifndef _HCAPI_CFA_P58_H_
+#define _HCAPI_CFA_P58_H_
+
+/** CFA phase 5.8 fix formatted table(layout) ID definition
+ *
+ */
+enum cfa_p58_tbl_id {
+	CFA_P58_TBL_ILT = 0,
+	CFA_P58_TBL_L2CTXT_TCAM,
+	CFA_P58_TBL_L2CTXT_REMAP,
+	CFA_P58_TBL_PROF_TCAM,
+	CFA_P58_TBL_PROF_TCAM_REMAP,
+	CFA_P58_TBL_WC_TCAM,
+	CFA_P58_TBL_WC_TCAM_REC,
+	CFA_P58_TBL_VEB_TCAM,
+	CFA_P58_TBL_SP_TCAM,
+	/** Default Profile TCAM/Lookup Action Record Pointer Table */
+	CFA_P58_TBL_PROF_PARIF_DFLT_ACT_REC_PTR,
+	/** Error Profile TCAM Miss Action Record Pointer Table */
+	CFA_P58_TBL_PROF_PARIF_ERR_ACT_REC_PTR,
+	/** SR2 VNIC/SVIF Properties Table */
+	CFA_P58_TBL_VSPT,
+	CFA_P58_TBL_MAX
+};
+
+#define CFA_P58_PROF_MAX_KEYS 4
+enum cfa_p58_mac_sel_mode {
+	CFA_P58_MAC_SEL_MODE_FIRST = 0,
+	CFA_P58_MAC_SEL_MODE_LOWEST = 1,
+};
+
+struct cfa_p58_prof_key_cfg {
+	uint8_t mac_sel[CFA_P58_PROF_MAX_KEYS];
+#define CFA_P58_PROF_MAC_SEL_DMAC0 (1 << 0)
+#define CFA_P58_PROF_MAC_SEL_T_MAC0 (1 << 1)
+#define CFA_P58_PROF_MAC_SEL_OUTERMOST_MAC0 (1 << 2)
+#define CFA_P58_PROF_MAC_SEL_DMAC1 (1 << 3)
+#define CFA_P58_PROF_MAC_SEL_T_MAC1 (1 << 4)
+#define CFA_P58_PROF_MAC_OUTERMOST_MAC1 (1 << 5)
+	uint8_t vlan_sel[CFA_P58_PROF_MAX_KEYS];
+#define CFA_P58_PROFILER_VLAN_SEL_INNER_HDR 0
+#define CFA_P58_PROFILER_VLAN_SEL_TUNNEL_HDR 1
+#define CFA_P58_PROFILER_VLAN_SEL_OUTERMOST_HDR 2
+	uint8_t pass_cnt;
+	enum cfa_p58_mac_sel_mode mode;
+};
+
+/**
+ * CFA action layout definition
+ */
+
+#define CFA_P58_ACTION_MAX_LAYOUT_SIZE 184
+
+/**
+ * Action object template structure
+ *
+ * Template structure presents data fields that are necessary to know
+ * at the beginning of Action Builder (AB) processing. Like before the
+ * AB compilation. One such example could be a template that is
+ * flexible in size (Encap Record) and the presence of these fields
+ * allows for determining the template size as well as where the
+ * fields are located in the record.
+ *
+ * The template may also present fields that are not made visible to
+ * the caller by way of the action fields.
+ *
+ * Template fields also allow for additional checking on user visible
+ * fields. One such example could be the encap pointer behavior on a
+ * CFA_P58_ACT_OBJ_TYPE_ACT or CFA_P58_ACT_OBJ_TYPE_ACT_SRAM.
+ */
+struct cfa_p58_action_template {
+	/** Action Object type
+	 *
+	 * Controls the type of the Action Template
+	 */
+	enum {
+		/** Select this type to build an Action Record Object
+		 */
+		CFA_P58_ACT_OBJ_TYPE_ACT,
+		/** Select this type to build an Action Statistics
+		 * Object
+		 */
+		CFA_P58_ACT_OBJ_TYPE_STAT,
+		/** Select this type to build a SRAM Action Record
+		 * Object.
+		 */
+		CFA_P58_ACT_OBJ_TYPE_ACT_SRAM,
+		/** Select this type to build a SRAM Action
+		 * Encapsulation Object.
+		 */
+		CFA_P58_ACT_OBJ_TYPE_ENCAP_SRAM,
+		/** Select this type to build a SRAM Action Modify
+		 * Object, with IPv4 capability.
+		 */
+		/* In case of Stingray the term Modify is used for the 'NAT
+		 * action'. Action builder is leveraged to fill in the NAT
+		 * object which then can be referenced by the action
+		 * record.
+		 */
+		CFA_P58_ACT_OBJ_TYPE_MODIFY_IPV4_SRAM,
+		/** Select this type to build a SRAM Action Source
+		 * Property Object.
+		 */
+		/* In case of Stingray this is not a 'pure' action record.
+		 * Action builder is leveraged to full in the Source Property
+		 * object which can then be referenced by the action
+		 * record.
+		 */
+		CFA_P58_ACT_OBJ_TYPE_SRC_PROP_SRAM,
+		/** Select this type to build a SRAM Action Statistics
+		 * Object
+		 */
+		CFA_P58_ACT_OBJ_TYPE_STAT_SRAM,
+	} obj_type;
+
+	/** Action Control
+	 *
+	 * Controls the internals of the Action Template
+	 *
+	 * act is valid when:
+	 * (obj_type == CFA_P58_ACT_OBJ_TYPE_ACT)
+	 */
+	/*
+	 * Stat and encap are always inline for EEM as table scope
+	 * allocation does not allow for separate Stats allocation,
+	 * but has the xx_inline flags as to be forward compatible
+	 * with Stingray 2, always treated as TRUE.
+	 */
+	struct {
+		/** Set to CFA_HCAPI_TRUE to enable statistics
+		 */
+		uint8_t stat_enable;
+		/** Set to CFA_HCAPI_TRUE to enable statistics to be inlined
+		 */
+		uint8_t stat_inline;
+
+		/** Set to CFA_HCAPI_TRUE to enable encapsulation
+		 */
+		uint8_t encap_enable;
+		/** Set to CFA_HCAPI_TRUE to enable encapsulation to be inlined
+		 */
+		uint8_t encap_inline;
+	} act;
+
+	/** Modify Setting
+	 *
+	 * Controls the type of the Modify Action the template is
+	 * describing
+	 *
+	 * modify is valid when:
+	 * (obj_type == CFA_P58_ACT_OBJ_TYPE_MODIFY_SRAM)
+	 */
+	enum {
+		/** Set to enable Modify of Source IPv4 Address
+		 */
+		CFA_P58_MR_REPLACE_SOURCE_IPV4 = 0,
+		/** Set to enable Modify of Destination IPv4 Address
+		 */
+		CFA_P58_MR_REPLACE_DEST_IPV4
+	} modify;
+
+	/** Encap Control
+	 * Controls the type of encapsulation the template is
+	 * describing
+	 *
+	 * encap is valid when:
+	 * ((obj_type == CFA_P58_ACT_OBJ_TYPE_ACT) &&
+	 *   act.encap_enable) ||
+	 * ((obj_type == CFA_P58_ACT_OBJ_TYPE_SRC_PROP_SRAM)
+	 */
+	struct {
+		/* Direction is required as Stingray Encap on RX is
+		 * limited to l2 and VTAG only.
+		 */
+		/** Receive or Transmit direction
+		 */
+		uint8_t direction;
+		/** Set to CFA_HCAPI_TRUE to enable L2 capability in the
+		 *  template
+		 */
+		uint8_t l2_enable;
+		/** vtag controls the Encap Vector - VTAG Encoding, 4 bits
+		 *
+		 * <ul>
+		 * <li> CFA_P58_ACT_ENCAP_VTAGS_PUSH_0, default, no VLAN
+		 *      Tags applied
+		 * <li> CFA_P58_ACT_ENCAP_VTAGS_PUSH_1, adds capability to
+		 *      set 1 VLAN Tag. Action Template compile adds
+		 *      the following field to the action object
+		 *      ::TF_ER_VLAN1
+		 * <li> CFA_P58_ACT_ENCAP_VTAGS_PUSH_2, adds capability to
+		 *      set 2 VLAN Tags. Action Template compile adds
+		 *      the following fields to the action object
+		 *      ::TF_ER_VLAN1 and ::TF_ER_VLAN2
+		 * </ul>
+		 */
+		enum { CFA_P58_ACT_ENCAP_VTAGS_PUSH_0 = 0,
+		       CFA_P58_ACT_ENCAP_VTAGS_PUSH_1,
+		       CFA_P58_ACT_ENCAP_VTAGS_PUSH_2 } vtag;
+
+		/*
+		 * The remaining fields are NOT supported when
+		 * direction is RX and ((obj_type ==
+		 * CFA_P58_ACT_OBJ_TYPE_ACT) && act.encap_enable).
+		 * ab_compile_layout will perform the checking and
+		 * skip remaining fields.
+		 */
+		/** L3 Encap controls the Encap Vector - L3 Encoding,
+		 *  3 bits. Defines the type of L3 Encapsulation the
+		 *  template is describing.
+		 * <ul>
+		 * <li> CFA_P58_ACT_ENCAP_L3_NONE, default, no L3
+		 *      Encapsulation processing.
+		 * <li> CFA_P58_ACT_ENCAP_L3_IPV4, enables L3 IPv4
+		 *      Encapsulation.
+		 * <li> CFA_P58_ACT_ENCAP_L3_IPV6, enables L3 IPv6
+		 *      Encapsulation.
+		 * <li> CFA_P58_ACT_ENCAP_L3_MPLS_8847, enables L3 MPLS
+		 *      8847 Encapsulation.
+		 * <li> CFA_P58_ACT_ENCAP_L3_MPLS_8848, enables L3 MPLS
+		 *      8848 Encapsulation.
+		 * </ul>
+		 */
+		enum {
+			/** Set to disable any L3 encapsulation
+			 * processing, default
+			 */
+			CFA_P58_ACT_ENCAP_L3_NONE = 0,
+			/** Set to enable L3 IPv4 encapsulation
+			 */
+			CFA_P58_ACT_ENCAP_L3_IPV4 = 4,
+			/** Set to enable L3 IPv6 encapsulation
+			 */
+			CFA_P58_ACT_ENCAP_L3_IPV6 = 5,
+			/** Set to enable L3 MPLS 8847 encapsulation
+			 */
+			CFA_P58_ACT_ENCAP_L3_MPLS_8847 = 6,
+			/** Set to enable L3 MPLS 8848 encapsulation
+			 */
+			CFA_P58_ACT_ENCAP_L3_MPLS_8848 = 7
+		} l3;
+
+#define CFA_P58_ACT_ENCAP_MAX_MPLS_LABELS 8
+		/** 1-8 labels, valid when
+		 * (l3 == CFA_P58_ACT_ENCAP_L3_MPLS_8847) ||
+		 * (l3 == CFA_P58_ACT_ENCAP_L3_MPLS_8848)
+		 *
+		 * MAX number of MPLS Labels 8.
+		 */
+		uint8_t l3_num_mpls_labels;
+
+		/** Set to CFA_HCAPI_TRUE to enable L4 capability in the
+		 * template.
+		 *
+		 * CFA_HCAPI_TRUE adds ::TF_EN_UDP_SRC_PORT and
+		 * ::TF_EN_UDP_DST_PORT to the template.
+		 */
+		uint8_t l4_enable;
+
+		/** Tunnel Encap controls the Encap Vector - Tunnel
+		 *  Encap, 3 bits. Defines the type of Tunnel
+		 *  encapsulation the template is describing
+		 * <ul>
+		 * <li> CFA_P58_ACT_ENCAP_TNL_NONE, default, no Tunnel
+		 *      Encapsulation processing.
+		 * <li> CFA_P58_ACT_ENCAP_TNL_GENERIC_FULL
+		 * <li> CFA_P58_ACT_ENCAP_TNL_VXLAN. NOTE: Expects
+		 *      l4_enable set to CFA_P58_TRUE;
+		 * <li> CFA_P58_ACT_ENCAP_TNL_NGE. NOTE: Expects l4_enable
+		 *      set to CFA_P58_TRUE;
+		 * <li> CFA_P58_ACT_ENCAP_TNL_NVGRE. NOTE: only valid if
+		 *      l4_enable set to CFA_HCAPI_FALSE.
+		 * <li> CFA_P58_ACT_ENCAP_TNL_GRE.NOTE: only valid if
+		 *      l4_enable set to CFA_HCAPI_FALSE.
+		 * <li> CFA_P58_ACT_ENCAP_TNL_GENERIC_AFTER_TL4
+		 * <li> CFA_P58_ACT_ENCAP_TNL_GENERIC_AFTER_TNL
+		 * </ul>
+		 */
+		enum {
+			/** Set to disable Tunnel header encapsulation
+			 * processing, default
+			 */
+			CFA_P58_ACT_ENCAP_TNL_NONE = 0,
+			/** Set to enable Tunnel Generic Full header
+			 * encapsulation
+			 */
+			CFA_P58_ACT_ENCAP_TNL_GENERIC_FULL,
+			/** Set to enable VXLAN header encapsulation
+			 */
+			CFA_P58_ACT_ENCAP_TNL_VXLAN,
+			/** Set to enable NGE (VXLAN2) header encapsulation
+			 */
+			CFA_P58_ACT_ENCAP_TNL_NGE,
+			/** Set to enable NVGRE header encapsulation
+			 */
+			CFA_P58_ACT_ENCAP_TNL_NVGRE,
+			/** Set to enable GRE header encapsulation
+			 */
+			CFA_P58_ACT_ENCAP_TNL_GRE,
+			/** Set to enable Generic header after Tunnel
+			 * L4 encapsulation
+			 */
+			CFA_P58_ACT_ENCAP_TNL_GENERIC_AFTER_TL4,
+			/** Set to enable Generic header after Tunnel
+			 * encapsulation
+			 */
+			CFA_P58_ACT_ENCAP_TNL_GENERIC_AFTER_TNL
+		} tnl;
+
+		/** Number of bytes of generic tunnel header,
+		 * valid when
+		 * (tnl == CFA_P58_ACT_ENCAP_TNL_GENERIC_FULL) ||
+		 * (tnl == CFA_P58_ACT_ENCAP_TNL_GENERIC_AFTER_TL4) ||
+		 * (tnl == CFA_P58_ACT_ENCAP_TNL_GENERIC_AFTER_TNL)
+		 */
+		uint8_t tnl_generic_size;
+		/** Number of 32b words of nge options,
+		 * valid when
+		 * (tnl == CFA_P58_ACT_ENCAP_TNL_NGE)
+		 */
+		uint8_t tnl_nge_op_len;
+		/* Currently not planned */
+		/* Custom Header */
+		/*	uint8_t custom_enable; */
+	} encap;
+};
+
+/**
+ * Enumeration of SRAM entry types, used for allocation of
+ * fixed SRAM entities. The memory model for CFA HCAPI
+ * determines if an SRAM entry type is supported.
+ */
+enum cfa_p58_action_sram_entry_type {
+	/* NOTE: Any additions to this enum must be reflected on FW
+	 * side as well.
+	 */
+
+	/** SRAM Action Record */
+	CFA_P58_ACTION_SRAM_ENTRY_TYPE_ACT,
+	/** SRAM Action Encap 8 Bytes */
+	CFA_P58_ACTION_SRAM_ENTRY_TYPE_ENCAP_8B,
+	/** SRAM Action Encap 16 Bytes */
+	CFA_P58_ACTION_SRAM_ENTRY_TYPE_ENCAP_16B,
+	/** SRAM Action Encap 64 Bytes */
+	CFA_P58_ACTION_SRAM_ENTRY_TYPE_ENCAP_64B,
+	/** SRAM Action Modify IPv4 Source */
+	CFA_P58_ACTION_SRAM_ENTRY_TYPE_MODIFY_IPV4_SRC,
+	/** SRAM Action Modify IPv4 Destination */
+	CFA_P58_ACTION_SRAM_ENTRY_TYPE_MODIFY_IPV4_DEST,
+	/** SRAM Action Source Properties SMAC */
+	CFA_P58_ACTION_SRAM_ENTRY_TYPE_SP_SMAC,
+	/** SRAM Action Source Properties SMAC IPv4 */
+	CFA_P58_ACTION_SRAM_ENTRY_TYPE_SP_SMAC_IPV4,
+	/** SRAM Action Source Properties SMAC IPv6 */
+	CFA_P58_ACTION_SRAM_ENTRY_TYPE_SP_SMAC_IPV6,
+	/** SRAM Action Statistics 64 Bits */
+	CFA_P58_ACTION_SRAM_ENTRY_TYPE_STATS_64,
+	CFA_P58_ACTION_SRAM_ENTRY_TYPE_MAX
+};
+
+/**
+ * SRAM Action Record structure holding either an action index or an
+ * action ptr.
+ */
+union cfa_p58_action_sram_act_record {
+	/** SRAM Action idx specifies the offset of the SRAM
+	 * element within its SRAM Entry Type block. This
+	 * index can be written into i.e. an L2 Context. Use
+	 * this type for all SRAM Action Record types except
+	 * SRAM Full Action records. Use act_ptr instead.
+	 */
+	uint16_t act_idx;
+	/** SRAM Full Action is special in that it needs an
+	 * action record pointer. This pointer can be written
+	 * into i.e. a Wildcard TCAM entry.
+	 */
+	uint32_t act_ptr;
+};
+
+/**
+ * cfa_p58_action_param parameter definition
+ */
+struct cfa_p58_action_param {
+	/**
+	 * [in] receive or transmit direction
+	 */
+	uint8_t dir;
+	/**
+	 * [in] type of the sram allocation type
+	 */
+	enum cfa_p58_action_sram_entry_type type;
+	/**
+	 * [in] action record to set. The 'type' specified lists the
+	 *	record definition to use in the passed in record.
+	 */
+	union cfa_p58_action_sram_act_record record;
+	/**
+	 * [in] number of elements in act_data
+	 */
+	uint32_t act_size;
+	/**
+	 * [in] ptr to array of action data
+	 */
+	uint64_t *act_data;
+};
+#endif /* _CFA_HW_P58_H_ */
diff --git a/drivers/net/bnxt/tf_core/meson.build b/drivers/net/bnxt/tf_core/meson.build
index 373ee0413b..2c02214d83 100644
--- a/drivers/net/bnxt/tf_core/meson.build
+++ b/drivers/net/bnxt/tf_core/meson.build
@@ -22,7 +22,6 @@ sources += files(
         'tf_device_p4.c',
         'tf_device_p58.c',
         'tf_identifier.c',
-        'tf_shadow_tbl.c',
         'tf_shadow_tcam.c',
         'tf_tcam.c',
         'tf_util.c',
diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h
index 4fe0590569..0cc3719a1b 100644
--- a/drivers/net/bnxt/tf_core/tf_core.h
+++ b/drivers/net/bnxt/tf_core/tf_core.h
@@ -153,6 +153,30 @@ enum tf_device_type {
 	TF_DEVICE_TYPE_MAX     /**< Maximum   */
 };
 
+/**
+ * Module types
+ */
+enum tf_module_type {
+	/**
+	 * Identifier module
+	 */
+	TF_MODULE_TYPE_IDENTIFIER,
+	/**
+	 * Table type module
+	 */
+	TF_MODULE_TYPE_TABLE,
+	/**
+	 * TCAM module
+	 */
+	TF_MODULE_TYPE_TCAM,
+	/**
+	 * EM module
+	 */
+	TF_MODULE_TYPE_EM,
+	TF_MODULE_TYPE_MAX
+};
+
+
 /**
  * Identifier resource types
  */
diff --git a/drivers/net/bnxt/tf_core/tf_device.c b/drivers/net/bnxt/tf_core/tf_device.c
index d072b9877c..61b3746d8b 100644
--- a/drivers/net/bnxt/tf_core/tf_device.c
+++ b/drivers/net/bnxt/tf_core/tf_device.c
@@ -8,6 +8,7 @@
 #include "tf_device_p58.h"
 #include "tfp.h"
 #include "tf_em.h"
+#include "tf_rm.h"
 
 struct tf;
 
@@ -18,8 +19,8 @@ static int tf_dev_unbind_p58(struct tf *tfp);
 /**
  * Resource Reservation Check function
  *
- * [in] tfp
- *   Pointer to TF handle
+ * [in] count
+ *   Number of module subtypes
  *
  * [in] cfg
  *   Pointer to rm element config
@@ -28,11 +29,10 @@ static int tf_dev_unbind_p58(struct tf *tfp);
  *   Pointer to resource reservation array
  *
  * Returns
- *   - (n) number of tables that have non-zero reservation count.
+ *   - (n) number of tables in module that have non-zero reservation count.
  */
 static int
-tf_dev_reservation_check(struct tf *tfp __rte_unused,
-			 uint16_t count,
+tf_dev_reservation_check(uint16_t count,
 			 struct tf_rm_element_cfg *cfg,
 			 uint16_t *reservations)
 {
@@ -94,8 +94,7 @@ tf_dev_bind_p4(struct tf *tfp,
 
 	/* Initialize the modules */
 
-	rsv_cnt = tf_dev_reservation_check(tfp,
-					   TF_IDENT_TYPE_MAX,
+	rsv_cnt = tf_dev_reservation_check(TF_IDENT_TYPE_MAX,
 					   tf_ident_p4,
 					   (uint16_t *)resources->ident_cnt);
 	if (rsv_cnt) {
@@ -113,8 +112,7 @@ tf_dev_bind_p4(struct tf *tfp,
 		no_rsv_flag = false;
 	}
 
-	rsv_cnt = tf_dev_reservation_check(tfp,
-					   TF_TBL_TYPE_MAX,
+	rsv_cnt = tf_dev_reservation_check(TF_TBL_TYPE_MAX,
 					   tf_tbl_p4,
 					   (uint16_t *)resources->tbl_cnt);
 	if (rsv_cnt) {
@@ -132,8 +130,7 @@ tf_dev_bind_p4(struct tf *tfp,
 		no_rsv_flag = false;
 	}
 
-	rsv_cnt = tf_dev_reservation_check(tfp,
-					   TF_TCAM_TBL_TYPE_MAX,
+	rsv_cnt = tf_dev_reservation_check(TF_TCAM_TBL_TYPE_MAX,
 					   tf_tcam_p4,
 					   (uint16_t *)resources->tcam_cnt);
 	if (rsv_cnt) {
@@ -155,8 +152,7 @@ tf_dev_bind_p4(struct tf *tfp,
 	 */
 
 	em_cfg.cfg = tf_em_ext_p4;
-	rsv_cnt = tf_dev_reservation_check(tfp,
-					   TF_EM_TBL_TYPE_MAX,
+	rsv_cnt = tf_dev_reservation_check(TF_EM_TBL_TYPE_MAX,
 					   em_cfg.cfg,
 					   (uint16_t *)resources->em_cnt);
 	if (rsv_cnt) {
@@ -175,8 +171,7 @@ tf_dev_bind_p4(struct tf *tfp,
 	/*
 	 * EM
 	 */
-	rsv_cnt = tf_dev_reservation_check(tfp,
-					   TF_EM_TBL_TYPE_MAX,
+	rsv_cnt = tf_dev_reservation_check(TF_EM_TBL_TYPE_MAX,
 					   tf_em_int_p4,
 					   (uint16_t *)resources->em_cnt);
 	if (rsv_cnt) {
@@ -360,10 +355,7 @@ tf_dev_bind_p58(struct tf *tfp,
 	/* Initial function initialization */
 	dev_handle->ops = &tf_dev_ops_p58_init;
 
-	/* Initialize the modules */
-
-	rsv_cnt = tf_dev_reservation_check(tfp,
-					   TF_IDENT_TYPE_MAX,
+	rsv_cnt = tf_dev_reservation_check(TF_IDENT_TYPE_MAX,
 					   tf_ident_p58,
 					   (uint16_t *)resources->ident_cnt);
 	if (rsv_cnt) {
@@ -380,8 +372,7 @@ tf_dev_bind_p58(struct tf *tfp,
 		no_rsv_flag = false;
 	}
 
-	rsv_cnt = tf_dev_reservation_check(tfp,
-					   TF_TBL_TYPE_MAX,
+	rsv_cnt = tf_dev_reservation_check(TF_TBL_TYPE_MAX,
 					   tf_tbl_p58,
 					   (uint16_t *)resources->tbl_cnt);
 	if (rsv_cnt) {
@@ -398,8 +389,7 @@ tf_dev_bind_p58(struct tf *tfp,
 		no_rsv_flag = false;
 	}
 
-	rsv_cnt = tf_dev_reservation_check(tfp,
-					   TF_TCAM_TBL_TYPE_MAX,
+	rsv_cnt = tf_dev_reservation_check(TF_TCAM_TBL_TYPE_MAX,
 					   tf_tcam_p58,
 					   (uint16_t *)resources->tcam_cnt);
 	if (rsv_cnt) {
@@ -419,8 +409,7 @@ tf_dev_bind_p58(struct tf *tfp,
 	/*
 	 * EM
 	 */
-	rsv_cnt = tf_dev_reservation_check(tfp,
-					   TF_EM_TBL_TYPE_MAX,
+	rsv_cnt = tf_dev_reservation_check(TF_EM_TBL_TYPE_MAX,
 					   tf_em_int_p58,
 					   (uint16_t *)resources->em_cnt);
 	if (rsv_cnt) {
@@ -593,10 +582,10 @@ tf_dev_bind_ops(enum tf_device_type type,
 	switch (type) {
 	case TF_DEVICE_TYPE_WH:
 	case TF_DEVICE_TYPE_SR:
-		dev_handle->ops = &tf_dev_ops_p4;
+		dev_handle->ops = &tf_dev_ops_p4_init;
 		break;
 	case TF_DEVICE_TYPE_THOR:
-		dev_handle->ops = &tf_dev_ops_p58;
+		dev_handle->ops = &tf_dev_ops_p58_init;
 		break;
 	default:
 		TFP_DRV_LOG(ERR,
diff --git a/drivers/net/bnxt/tf_core/tf_device.h b/drivers/net/bnxt/tf_core/tf_device.h
index 4f4120c603..2cbb42fe2a 100644
--- a/drivers/net/bnxt/tf_core/tf_device.h
+++ b/drivers/net/bnxt/tf_core/tf_device.h
@@ -16,29 +16,6 @@
 struct tf;
 struct tf_session;
 
-/**
- * Device module types
- */
-enum tf_device_module_type {
-	/**
-	 * Identifier module
-	 */
-	TF_DEVICE_MODULE_TYPE_IDENTIFIER,
-	/**
-	 * Table type module
-	 */
-	TF_DEVICE_MODULE_TYPE_TABLE,
-	/**
-	 * TCAM module
-	 */
-	TF_DEVICE_MODULE_TYPE_TCAM,
-	/**
-	 * EM module
-	 */
-	TF_DEVICE_MODULE_TYPE_EM,
-	TF_DEVICE_MODULE_TYPE_MAX
-};
-
 /**
  * The Device module provides a general device template. A supported
  * device type should implement one or more of the listed function
diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.c b/drivers/net/bnxt/tf_core/tf_device_p4.c
index fbe92b7733..d0bede89e3 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p4.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p4.c
@@ -74,29 +74,10 @@ static int
 tf_dev_p4_get_max_types(struct tf *tfp,
 			uint16_t *max_types)
 {
-	struct tf_session *tfs;
-	struct tf_dev_info *dev;
-	int rc;
-
 	if (max_types == NULL || tfp == NULL)
 		return -EINVAL;
 
-	/* Retrieve the session information */
-	rc = tf_session_get_session(tfp, &tfs);
-	if (rc)
-		return rc;
-
-	/* Retrieve the device information */
-	rc = tf_session_get_device(tfs, &dev);
-	if (rc)
-		return rc;
-
-	if (dev->type == TF_DEVICE_TYPE_WH)
-		*max_types = CFA_RESOURCE_TYPE_P4_LAST + 1;
-	else if (dev->type == TF_DEVICE_TYPE_SR)
-		*max_types = CFA_RESOURCE_TYPE_P45_LAST + 1;
-	else
-		return -ENODEV;
+	*max_types = CFA_RESOURCE_TYPE_P4_LAST + 1;
 
 	return 0;
 }
diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c
index 688d987cb7..50a8d82074 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p58.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p58.c
@@ -58,25 +58,11 @@ const char *tf_resource_str_p58[CFA_RESOURCE_TYPE_P58_LAST + 1] = {
  */
 static int
 tf_dev_p58_get_max_types(struct tf *tfp,
-			uint16_t *max_types)
+			 uint16_t *max_types)
 {
-	struct tf_session *tfs;
-	struct tf_dev_info *dev;
-	int rc;
-
 	if (max_types == NULL || tfp == NULL)
 		return -EINVAL;
 
-	/* Retrieve the session information */
-	rc = tf_session_get_session(tfp, &tfs);
-	if (rc)
-		return rc;
-
-	/* Retrieve the device information */
-	rc = tf_session_get_device(tfs, &dev);
-	if (rc)
-		return rc;
-
 	*max_types = CFA_RESOURCE_TYPE_P58_LAST + 1;
 
 	return 0;
@@ -153,41 +139,6 @@ tf_dev_p58_get_tcam_slice_info(struct tf *tfp __rte_unused,
 	return 0;
 }
 
-static int
-tf_dev_p58_map_parif(struct tf *tfp __rte_unused,
-		    uint16_t parif_bitmask,
-		    uint16_t pf,
-		    uint8_t *data,
-		    uint8_t *mask,
-		    uint16_t sz_in_bytes)
-{
-	uint32_t parif_pf[2] = { 0 };
-	uint32_t parif_pf_mask[2] = { 0 };
-	uint32_t parif;
-	uint32_t shift;
-
-	if (sz_in_bytes != sizeof(uint64_t))
-		return -ENOTSUP;
-
-	for (parif = 0; parif < TF_DEV_P58_PARIF_MAX; parif++) {
-		if (parif_bitmask & (1UL << parif)) {
-			if (parif < 8) {
-				shift = 4 * parif;
-				parif_pf_mask[0] |= TF_DEV_P58_PF_MASK << shift;
-				parif_pf[0] |= pf << shift;
-			} else {
-				shift = 4 * (parif - 8);
-				parif_pf_mask[1] |= TF_DEV_P58_PF_MASK << shift;
-				parif_pf[1] |= pf << shift;
-			}
-		}
-	}
-	tfp_memcpy(data, parif_pf, sz_in_bytes);
-	tfp_memcpy(mask, parif_pf_mask, sz_in_bytes);
-
-	return 0;
-}
-
 static int tf_dev_p58_get_mailbox(void)
 {
 	return TF_CHIMP_MB;
@@ -268,7 +219,7 @@ const struct tf_dev_ops tf_dev_ops_p58 = {
 	.tf_dev_delete_ext_em_entry = NULL,
 	.tf_dev_alloc_tbl_scope = NULL,
 	.tf_dev_map_tbl_scope = NULL,
-	.tf_dev_map_parif = tf_dev_p58_map_parif,
+	.tf_dev_map_parif = NULL,
 	.tf_dev_free_tbl_scope = NULL,
 	.tf_dev_set_if_tbl = tf_if_tbl_set,
 	.tf_dev_get_if_tbl = tf_if_tbl_get,
diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.h b/drivers/net/bnxt/tf_core/tf_device_p58.h
index de7bb1cd76..abd916985e 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p58.h
+++ b/drivers/net/bnxt/tf_core/tf_device_p58.h
@@ -64,6 +64,105 @@ struct tf_rm_element_cfg tf_tbl_p58[TF_TBL_TYPE_MAX] = {
 	[TF_TBL_TYPE_MIRROR_CONFIG] = {
 		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_MIRROR
 	},
+	/* Policy - ARs in bank 1 */
+	[TF_TBL_TYPE_FULL_ACT_RECORD] = {
+		.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_PARENT,
+		.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_1,
+		.slices          = 4,
+		.divider         = 8,
+	},
+	[TF_TBL_TYPE_COMPACT_ACT_RECORD] = {
+		.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,
+		.parent_subtype  = TF_TBL_TYPE_FULL_ACT_RECORD,
+		.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_1,
+		.slices          = 8,
+		.divider         = 8,
+	},
+	/* Policy - Encaps in bank 2 */
+	[TF_TBL_TYPE_ACT_ENCAP_8B] = {
+		.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_PARENT,
+		.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,
+		.slices          = 8,
+		.divider         = 8,
+	},
+	[TF_TBL_TYPE_ACT_ENCAP_16B] = {
+		.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,
+		.parent_subtype  = TF_TBL_TYPE_ACT_ENCAP_8B,
+		.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,
+		.slices          = 4,
+		.divider         = 8,
+	},
+	[TF_TBL_TYPE_ACT_ENCAP_32B] = {
+		.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,
+		.parent_subtype  = TF_TBL_TYPE_ACT_ENCAP_8B,
+		.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,
+		.slices          = 2,
+		.divider         = 8,
+	},
+	[TF_TBL_TYPE_ACT_ENCAP_64B] = {
+		.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,
+		.parent_subtype  = TF_TBL_TYPE_ACT_ENCAP_8B,
+		.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,
+		.slices          = 1,
+		.divider         = 8,
+	},
+	/* Policy - Modify in bank 2 with Encaps */
+	[TF_TBL_TYPE_ACT_MODIFY_8B] = {
+		.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,
+		.parent_subtype  = TF_TBL_TYPE_ACT_ENCAP_8B,
+		.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,
+		.slices          = 8,
+		.divider         = 8,
+	},
+	[TF_TBL_TYPE_ACT_MODIFY_16B] = {
+		.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,
+		.parent_subtype  = TF_TBL_TYPE_ACT_ENCAP_8B,
+		.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,
+		.slices          = 4,
+		.divider         = 8,
+	},
+	[TF_TBL_TYPE_ACT_MODIFY_32B] = {
+		.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,
+		.parent_subtype  = TF_TBL_TYPE_ACT_ENCAP_8B,
+		.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,
+		.slices          = 2,
+		.divider         = 8,
+	},
+	[TF_TBL_TYPE_ACT_MODIFY_64B] = {
+		.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,
+		.parent_subtype  = TF_TBL_TYPE_ACT_ENCAP_8B,
+		.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,
+		.slices          = 1,
+		.divider         = 8,
+	},
+	/* Policy - SP in bank 0 */
+	[TF_TBL_TYPE_ACT_SP_SMAC] = {
+		.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_PARENT,
+		.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_0,
+		.slices          = 8,
+		.divider         = 8,
+	},
+	[TF_TBL_TYPE_ACT_SP_SMAC_IPV4] = {
+		.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,
+		.parent_subtype  = TF_TBL_TYPE_ACT_SP_SMAC,
+		.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_0,
+		.slices          = 4,
+		.divider         = 8,
+	},
+	[TF_TBL_TYPE_ACT_SP_SMAC_IPV6] = {
+		.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,
+		.parent_subtype  = TF_TBL_TYPE_ACT_SP_SMAC,
+		.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_0,
+		.slices          = 2,
+		.divider         = 8,
+	},
+	/* Policy - Stats in bank 3 */
+	[TF_TBL_TYPE_ACT_STATS_64] = {
+		.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_PARENT,
+		.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_3,
+		.slices          = 8,
+		.divider         = 8,
+	},
 };
 
 struct tf_rm_element_cfg tf_em_int_p58[TF_EM_TBL_TYPE_MAX] = {
@@ -72,7 +171,16 @@ struct tf_rm_element_cfg tf_em_int_p58[TF_EM_TBL_TYPE_MAX] = {
 	},
 };
 
-struct tf_if_tbl_cfg tf_if_tbl_p58[TF_IF_TBL_TYPE_MAX];
+struct tf_if_tbl_cfg tf_if_tbl_p58[TF_IF_TBL_TYPE_MAX] = {
+	[TF_IF_TBL_TYPE_PROF_PARIF_DFLT_ACT_REC_PTR] = {
+		TF_IF_TBL_CFG, CFA_P58_TBL_PROF_PARIF_DFLT_ACT_REC_PTR},
+	[TF_IF_TBL_TYPE_PROF_PARIF_ERR_ACT_REC_PTR] = {
+		TF_IF_TBL_CFG, CFA_P58_TBL_PROF_PARIF_ERR_ACT_REC_PTR},
+	[TF_IF_TBL_TYPE_ILT] = {
+		TF_IF_TBL_CFG, CFA_P58_TBL_ILT},
+	[TF_IF_TBL_TYPE_VSPT] = {
+		TF_IF_TBL_CFG, CFA_P58_TBL_VSPT},
+};
 
 struct tf_global_cfg_cfg tf_global_cfg_p58[TF_GLOBAL_CFG_TYPE_MAX] = {
 	[TF_TUNNEL_ENCAP] = {
diff --git a/drivers/net/bnxt/tf_core/tf_em_common.c b/drivers/net/bnxt/tf_core/tf_em_common.c
index 6cd6086685..589df60041 100644
--- a/drivers/net/bnxt/tf_core/tf_em_common.c
+++ b/drivers/net/bnxt/tf_core/tf_em_common.c
@@ -54,7 +54,7 @@ tbl_scope_cb_find(uint32_t tbl_scope_id)
 
 	/* Check that id is valid */
 	parms.rm_db = eem_db[TF_DIR_RX];
-	parms.db_index = TF_EM_TBL_TYPE_TBL_SCOPE;
+	parms.subtype = TF_EM_TBL_TYPE_TBL_SCOPE;
 	parms.index = tbl_scope_id;
 	parms.allocated = &allocated;
 
@@ -895,7 +895,7 @@ tf_em_ext_common_bind(struct tf *tfp,
 		return -EINVAL;
 	}
 
-	db_cfg.type = TF_DEVICE_MODULE_TYPE_EM;
+	db_cfg.module = TF_MODULE_TYPE_EM;
 	db_cfg.num_elements = parms->num_elements;
 	db_cfg.cfg = parms->cfg;
 
diff --git a/drivers/net/bnxt/tf_core/tf_em_host.c b/drivers/net/bnxt/tf_core/tf_em_host.c
index 69f7e5bddd..166f397935 100644
--- a/drivers/net/bnxt/tf_core/tf_em_host.c
+++ b/drivers/net/bnxt/tf_core/tf_em_host.c
@@ -379,7 +379,7 @@ tf_em_ext_alloc(struct tf *tfp, struct tf_alloc_tbl_scope_parms *parms)
 
 	/* Get Table Scope control block from the session pool */
 	aparms.rm_db = eem_db[TF_DIR_RX];
-	aparms.db_index = TF_EM_TBL_TYPE_TBL_SCOPE;
+	aparms.subtype = TF_EM_TBL_TYPE_TBL_SCOPE;
 	aparms.index = (uint32_t *)&parms->tbl_scope_id;
 	rc = tf_rm_allocate(&aparms);
 	if (rc) {
@@ -488,7 +488,7 @@ tf_em_ext_alloc(struct tf *tfp, struct tf_alloc_tbl_scope_parms *parms)
 cleanup:
 	/* Free Table control block */
 	fparms.rm_db = eem_db[TF_DIR_RX];
-	fparms.db_index = TF_EM_TBL_TYPE_TBL_SCOPE;
+	fparms.subtype = TF_EM_TBL_TYPE_TBL_SCOPE;
 	fparms.index = parms->tbl_scope_id;
 	tf_rm_free(&fparms);
 	return -EINVAL;
@@ -512,7 +512,7 @@ tf_em_ext_free(struct tf *tfp,
 
 	/* Free Table control block */
 	aparms.rm_db = eem_db[TF_DIR_RX];
-	aparms.db_index = TF_EM_TBL_TYPE_TBL_SCOPE;
+	aparms.subtype = TF_EM_TBL_TYPE_TBL_SCOPE;
 	aparms.index = parms->tbl_scope_id;
 	rc = tf_rm_free(&aparms);
 	if (rc) {
diff --git a/drivers/net/bnxt/tf_core/tf_em_internal.c b/drivers/net/bnxt/tf_core/tf_em_internal.c
index 0864218469..043f9be4da 100644
--- a/drivers/net/bnxt/tf_core/tf_em_internal.c
+++ b/drivers/net/bnxt/tf_core/tf_em_internal.c
@@ -251,7 +251,7 @@ tf_em_int_bind(struct tf *tfp,
 		return -EINVAL;
 	}
 
-	db_cfg.type = TF_DEVICE_MODULE_TYPE_EM;
+	db_cfg.module = TF_MODULE_TYPE_EM;
 	db_cfg.num_elements = parms->num_elements;
 	db_cfg.cfg = parms->cfg;
 
@@ -294,7 +294,7 @@ tf_em_int_bind(struct tf *tfp,
 
 	for (i = 0; i < TF_DIR_MAX; i++) {
 		iparms.rm_db = em_db[i];
-		iparms.db_index = TF_EM_DB_EM_REC;
+		iparms.subtype = TF_EM_DB_EM_REC;
 		iparms.info = &info;
 
 		rc = tf_rm_get_info(&iparms);
diff --git a/drivers/net/bnxt/tf_core/tf_identifier.c b/drivers/net/bnxt/tf_core/tf_identifier.c
index 41ab13c132..9d0a578085 100644
--- a/drivers/net/bnxt/tf_core/tf_identifier.c
+++ b/drivers/net/bnxt/tf_core/tf_identifier.c
@@ -52,7 +52,7 @@ tf_ident_bind(struct tf *tfp,
 		return -EINVAL;
 	}
 
-	db_cfg.type = TF_DEVICE_MODULE_TYPE_IDENTIFIER;
+	db_cfg.module = TF_MODULE_TYPE_IDENTIFIER;
 	db_cfg.num_elements = parms->num_elements;
 	db_cfg.cfg = parms->cfg;
 
@@ -161,7 +161,7 @@ tf_ident_alloc(struct tf *tfp __rte_unused,
 
 	/* Allocate requested element */
 	aparms.rm_db = ident_db[parms->dir];
-	aparms.db_index = parms->type;
+	aparms.subtype = parms->type;
 	aparms.index = &id;
 	aparms.base_index = &base_id;
 	rc = tf_rm_allocate(&aparms);
@@ -215,7 +215,7 @@ tf_ident_free(struct tf *tfp __rte_unused,
 
 	/* Check if element is in use */
 	aparms.rm_db = ident_db[parms->dir];
-	aparms.db_index = parms->type;
+	aparms.subtype = parms->type;
 	aparms.index = parms->id;
 	aparms.base_index = &base_id;
 	aparms.allocated = &allocated;
@@ -255,7 +255,7 @@ tf_ident_free(struct tf *tfp __rte_unused,
 
 	/* Free requested element */
 	fparms.rm_db = ident_db[parms->dir];
-	fparms.db_index = parms->type;
+	fparms.subtype = parms->type;
 	fparms.index = parms->id;
 	rc = tf_rm_free(&fparms);
 	if (rc) {
@@ -298,7 +298,7 @@ tf_ident_search(struct tf *tfp __rte_unused,
 
 	/* Check if element is in use */
 	aparms.rm_db = ident_db[parms->dir];
-	aparms.db_index = parms->type;
+	aparms.subtype = parms->type;
 	aparms.index = parms->search_id;
 	aparms.base_index = &base_id;
 	aparms.allocated = &allocated;
diff --git a/drivers/net/bnxt/tf_core/tf_if_tbl.c b/drivers/net/bnxt/tf_core/tf_if_tbl.c
index 16afa95e38..f58fa79b63 100644
--- a/drivers/net/bnxt/tf_core/tf_if_tbl.c
+++ b/drivers/net/bnxt/tf_core/tf_if_tbl.c
@@ -144,7 +144,7 @@ int
 tf_if_tbl_get(struct tf *tfp,
 	      struct tf_if_tbl_get_parms *parms)
 {
-	int rc;
+	int rc = 0;
 	struct tf_if_tbl_get_hcapi_parms hparms;
 
 	TF_CHECK_PARMS3(tfp, parms, parms->data);
diff --git a/drivers/net/bnxt/tf_core/tf_rm.c b/drivers/net/bnxt/tf_core/tf_rm.c
index 19de6e4c63..9fd660543c 100644
--- a/drivers/net/bnxt/tf_core/tf_rm.c
+++ b/drivers/net/bnxt/tf_core/tf_rm.c
@@ -42,10 +42,18 @@ struct tf_rm_element {
 	 */
 	struct tf_rm_alloc_info alloc;
 
+	/**
+	 * If cfg_type == HCAPI_BA_CHILD, this field indicates
+	 * the parent module subtype for look up into the parent pool.
+	 * An example subtype is TF_TBL_TYPE_FULL_ACT_RECORD which is a
+	 * module subtype of TF_MODULE_TYPE_TABLE.
+	 */
+	uint16_t parent_subtype;
+
 	/**
 	 * Bit allocator pool for the element. Pool size is controlled
 	 * by the struct tf_session_resources at time of session creation.
-	 * Null indicates that the element is not used for the device.
+	 * Null indicates that the pool is not used for the element.
 	 */
 	struct bitalloc *pool;
 };
@@ -67,7 +75,7 @@ struct tf_rm_new_db {
 	/**
 	 * Module type, used for logging purposes.
 	 */
-	enum tf_device_module_type type;
+	enum tf_module_type module;
 
 	/**
 	 * The DB consists of an array of elements
@@ -100,7 +108,7 @@ struct tf_rm_new_db {
  */
 static void
 tf_rm_count_hcapi_reservations(enum tf_dir dir,
-			       enum tf_device_module_type type,
+			       enum tf_module_type module,
 			       struct tf_rm_element_cfg *cfg,
 			       uint16_t *reservations,
 			       uint16_t count,
@@ -110,8 +118,7 @@ tf_rm_count_hcapi_reservations(enum tf_dir dir,
 	uint16_t cnt = 0;
 
 	for (i = 0; i < count; i++) {
-		if ((cfg[i].cfg_type == TF_RM_ELEM_CFG_HCAPI ||
-		     cfg[i].cfg_type == TF_RM_ELEM_CFG_HCAPI_BA) &&
+		if (cfg[i].cfg_type != TF_RM_ELEM_CFG_NULL &&
 		    reservations[i] > 0)
 			cnt++;
 
@@ -120,14 +127,14 @@ tf_rm_count_hcapi_reservations(enum tf_dir dir,
 		 * split configuration array thus it would fail for
 		 * this type of check.
 		 */
-		if (type != TF_DEVICE_MODULE_TYPE_EM &&
+		if (module != TF_MODULE_TYPE_EM &&
 		    cfg[i].cfg_type == TF_RM_ELEM_CFG_NULL &&
 		    reservations[i] > 0) {
 			TFP_DRV_LOG(ERR,
 				"%s, %s, %s allocation of %d not supported\n",
-				tf_device_module_type_2_str(type),
+				tf_module_2_str(module),
 				tf_dir_2_str(dir),
-				tf_device_module_type_subtype_2_str(type, i),
+				tf_module_subtype_2_str(module, i),
 				reservations[i]);
 		}
 	}
@@ -156,8 +163,10 @@ enum tf_rm_adjust_type {
  * [in] action
  *   Adjust action
  *
- * [in] db_index
- *   DB index for the element type
+ * [in] subtype
+ *   TF module subtype used as an index into the database.
+ *   An example subtype is TF_TBL_TYPE_FULL_ACT_RECORD which is a
+ *   module subtype of TF_MODULE_TYPE_TABLE.
  *
  * [in] index
  *   Index to convert
@@ -172,14 +181,14 @@ enum tf_rm_adjust_type {
 static int
 tf_rm_adjust_index(struct tf_rm_element *db,
 		   enum tf_rm_adjust_type action,
-		   uint32_t db_index,
+		   uint32_t subtype,
 		   uint32_t index,
 		   uint32_t *adj_index)
 {
 	int rc = 0;
 	uint32_t base_index;
 
-	base_index = db[db_index].alloc.entry.start;
+	base_index = db[subtype].alloc.entry.start;
 
 	switch (action) {
 	case TF_RM_ADJUST_RM_BASE:
@@ -201,7 +210,7 @@ tf_rm_adjust_index(struct tf_rm_element *db,
  * [in] dir
  *   Receive or transmit direction
  *
- * [in] type
+ * [in] module
  *   Type of Device Module
  *
  * [in] count
@@ -214,7 +223,7 @@ tf_rm_adjust_index(struct tf_rm_element *db,
  */
 static void
 tf_rm_log_residuals(enum tf_dir dir,
-		    enum tf_device_module_type type,
+		    enum tf_module_type module,
 		    uint16_t count,
 		    uint16_t *residuals)
 {
@@ -228,7 +237,7 @@ tf_rm_log_residuals(enum tf_dir dir,
 			TFP_DRV_LOG(ERR,
 				"%s, %s was not cleaned up, %d outstanding\n",
 				tf_dir_2_str(dir),
-				tf_device_module_type_subtype_2_str(type, i),
+				tf_module_subtype_2_str(module, i),
 				residuals[i]);
 	}
 }
@@ -295,7 +304,7 @@ tf_rm_check_residuals(struct tf_rm_new_db *rm_db,
 	iparms.rm_db = rm_db;
 	iparms.count = &count;
 	for (i = 0, found = 0; i < rm_db->num_entries; i++) {
-		iparms.db_index = i;
+		iparms.subtype = i;
 		rc = tf_rm_get_inuse_count(&iparms);
 		/* Not a device supported entry, just skip */
 		if (rc == -ENOTSUP)
@@ -329,13 +338,13 @@ tf_rm_check_residuals(struct tf_rm_new_db *rm_db,
 		for (i = 0, f = 0; i < rm_db->num_entries; i++) {
 			if (residuals[i] == 0)
 				continue;
-			aparms.db_index = i;
+			aparms.subtype = i;
 			aparms.info = &info;
 			rc = tf_rm_get_info(&aparms);
 			if (rc)
 				goto cleanup_all;
 
-			hparms.db_index = i;
+			hparms.subtype = i;
 			rc = tf_rm_get_hcapi_type(&hparms);
 			if (rc)
 				goto cleanup_all;
@@ -349,7 +358,7 @@ tf_rm_check_residuals(struct tf_rm_new_db *rm_db,
 	}
 
 	tf_rm_log_residuals(rm_db->dir,
-			    rm_db->type,
+			    rm_db->module,
 			    rm_db->num_entries,
 			    residuals);
 
@@ -367,16 +376,93 @@ tf_rm_check_residuals(struct tf_rm_new_db *rm_db,
 	return rc;
 }
 
+/**
+ * Some resources do not have a 1:1 mapping between the Truflow type and the cfa
+ * resource type (HCAPI RM).  These resources have multiple Truflow types which
+ * map to a single HCAPI RM type.  In order to support this, one Truflow type
+ * sharing the HCAPI resources is designated the parent.  All other Truflow
+ * types associated with that HCAPI RM type are designated the children.
+ *
+ * This function updates the resource counts of any HCAPI_BA_PARENT with the
+ * counts of the HCAPI_BA_CHILDREN.  These are read from the alloc_cnt and
+ * written back to the req_cnt.
+ *
+ * [in] cfg
+ *   Pointer to an array of module specific Truflow type indexed RM cfg items
+ *
+ * [in] alloc_cnt
+ *   Pointer to the tf_open_session() configured array of module specific
+ *   Truflow type indexed requested counts.
+ *
+ * [in/out] req_cnt
+ *   Pointer to the location to put the updated resource counts.
+ *
+ * Returns:
+ *     0          - Success
+ *     -          - Failure if negative
+ */
+static int
+tf_rm_update_parent_reservations(struct tf_rm_element_cfg *cfg,
+				 uint16_t *alloc_cnt,
+				 uint16_t num_elements,
+				 uint16_t *req_cnt)
+{
+	int parent, child;
+
+	/* Search through all the elements */
+	for (parent = 0; parent < num_elements; parent++) {
+		uint16_t combined_cnt = 0;
+
+		/* If I am a parent */
+		if (cfg[parent].cfg_type == TF_RM_ELEM_CFG_HCAPI_BA_PARENT) {
+			/* start with my own count */
+			RTE_ASSERT(cfg[parent].slices);
+			combined_cnt =
+				alloc_cnt[parent] / cfg[parent].slices;
+
+			if (alloc_cnt[parent] % cfg[parent].slices)
+				combined_cnt++;
+
+			/* Search again through all the elements */
+			for (child = 0; child < num_elements; child++) {
+				/* If this is one of my children */
+				if (cfg[child].cfg_type ==
+				    TF_RM_ELEM_CFG_HCAPI_BA_CHILD &&
+				    cfg[child].parent_subtype == parent) {
+					uint16_t cnt = 0;
+					RTE_ASSERT(cfg[child].slices);
+
+					/* Increment the parents combined count
+					 * with each child's count adjusted for
+					 * number of slices per RM alloced item.
+					 */
+					cnt =
+					 alloc_cnt[child] / cfg[child].slices;
+
+					if (alloc_cnt[child] % cfg[child].slices)
+						cnt++;
+
+					combined_cnt += cnt;
+					/* Clear the requested child count */
+					req_cnt[child] = 0;
+				}
+			}
+			/* Save the parent count to be requested */
+			req_cnt[parent] = combined_cnt;
+		}
+	}
+	return 0;
+}
+
 int
 tf_rm_create_db(struct tf *tfp,
 		struct tf_rm_create_db_parms *parms)
 {
 	int rc;
-	int i;
-	int j;
 	struct tf_session *tfs;
 	struct tf_dev_info *dev;
-	uint16_t max_types;
+	int i, j;
+	uint16_t max_types, hcapi_items, *req_cnt;
 	struct tfp_calloc_parms cparms;
 	struct tf_rm_resc_req_entry *query;
 	enum tf_rm_resc_resv_strategy resv_strategy;
@@ -385,7 +471,6 @@ tf_rm_create_db(struct tf *tfp,
 	struct tf_rm_new_db *rm_db;
 	struct tf_rm_element *db;
 	uint32_t pool_size;
-	uint16_t hcapi_items;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -401,9 +486,9 @@ tf_rm_create_db(struct tf *tfp,
 
 	/* Need device max number of elements for the RM QCAPS */
 	rc = dev->ops->tf_dev_get_max_types(tfp, &max_types);
-	if (rc)
-		return rc;
 
+
+	/* Allocate memory for RM QCAPS request */
 	cparms.nitems = max_types;
 	cparms.size = sizeof(struct tf_rm_resc_req_entry);
 	cparms.alignment = 0;
@@ -423,6 +508,28 @@ tf_rm_create_db(struct tf *tfp,
 	if (rc)
 		return rc;
 
+	/* Copy requested counts (alloc_cnt) from tf_open_session() to local
+	 * copy (req_cnt) so that it can be updated if required.
+	 */
+
+	cparms.nitems = parms->num_elements;
+	cparms.size = sizeof(uint16_t);
+	rc = tfp_calloc(&cparms);
+	if (rc)
+		return rc;
+
+	req_cnt = (uint16_t *)cparms.mem_va;
+
+	tfp_memcpy(req_cnt, parms->alloc_cnt,
+		   parms->num_elements * sizeof(uint16_t));
+
+	/* Update the req_cnt based upon the element configuration
+	 */
+	tf_rm_update_parent_reservations(parms->cfg,
+					 parms->alloc_cnt,
+					 parms->num_elements,
+					 req_cnt);
+
 	/* Process capabilities against DB requirements. However, as a
 	 * DB can hold elements that are not HCAPI we can reduce the
 	 * req msg content by removing those out of the request yet
@@ -430,21 +537,17 @@ tf_rm_create_db(struct tf *tfp,
 	 * remove entries where there are no request for elements.
 	 */
 	tf_rm_count_hcapi_reservations(parms->dir,
-				       parms->type,
+				       parms->module,
 				       parms->cfg,
-				       parms->alloc_cnt,
+				       req_cnt,
 				       parms->num_elements,
 				       &hcapi_items);
 
-	/* Handle the case where a DB create request really ends up
-	 * being empty. Unsupported (if not rare) case but possible
-	 * that no resources are necessary for a 'direction'.
-	 */
 	if (hcapi_items == 0) {
 		TFP_DRV_LOG(ERR,
-			"%s: DB create request for Zero elements, DB Type:%s\n",
-			tf_dir_2_str(parms->dir),
-			tf_device_module_type_2_str(parms->type));
+			    "%s: module:%s Empty RM DB create request\n",
+			    tf_dir_2_str(parms->dir),
+			    tf_module_2_str(parms->module));
 
 		parms->rm_db = NULL;
 		return -ENOMEM;
@@ -467,44 +570,45 @@ tf_rm_create_db(struct tf *tfp,
 
 	/* Build the request */
 	for (i = 0, j = 0; i < parms->num_elements; i++) {
-		/* Skip any non HCAPI cfg elements */
-		if (parms->cfg[i].cfg_type == TF_RM_ELEM_CFG_HCAPI ||
-		    parms->cfg[i].cfg_type == TF_RM_ELEM_CFG_HCAPI_BA) {
-			/* Only perform reservation for entries that
-			 * has been requested
-			 */
-			if (parms->alloc_cnt[i] == 0)
-				continue;
+		struct tf_rm_element_cfg *cfg = &parms->cfg[i];
+		uint16_t hcapi_type = cfg->hcapi_type;
+
+		/* Only perform reservation for requested entries
+		 */
+		if (req_cnt[i] == 0)
+			continue;
+
+		/* Skip any children in the request */
+		if (cfg->cfg_type == TF_RM_ELEM_CFG_HCAPI ||
+		    cfg->cfg_type == TF_RM_ELEM_CFG_HCAPI_BA ||
+		    cfg->cfg_type == TF_RM_ELEM_CFG_HCAPI_BA_PARENT) {
 
-			/* Verify that we can get the full amount
-			 * allocated per the qcaps availability.
+			/* Verify that we can get the full amount per qcaps.
 			 */
-			if (parms->alloc_cnt[i] <=
-			    query[parms->cfg[i].hcapi_type].max) {
-				req[j].type = parms->cfg[i].hcapi_type;
-				req[j].min = parms->alloc_cnt[i];
-				req[j].max = parms->alloc_cnt[i];
+			if (req_cnt[i] <= query[hcapi_type].max) {
+				req[j].type = hcapi_type;
+				req[j].min = req_cnt[i];
+				req[j].max = req_cnt[i];
 				j++;
 			} else {
 				const char *type_str;
-				uint16_t hcapi_type = parms->cfg[i].hcapi_type;
 
 				dev->ops->tf_dev_get_resource_str(tfp,
-								  hcapi_type,
-								  &type_str);
+							      hcapi_type,
+							      &type_str);
 				TFP_DRV_LOG(ERR,
-					"%s: Resource failure, type:%d:%s\n",
-					tf_dir_2_str(parms->dir),
-					hcapi_type, type_str);
-				TFP_DRV_LOG(ERR,
-					"req:%d, avail:%d\n",
-					parms->alloc_cnt[i],
-					query[hcapi_type].max);
+					    "Failure, %s:%d:%s req:%d avail:%d\n",
+					    tf_dir_2_str(parms->dir),
+					    hcapi_type, type_str,
+					    req_cnt[i],
+					    query[hcapi_type].max);
 				return -EINVAL;
 			}
 		}
 	}
 
+	/* Allocate all resources for the module type
+	 */
 	rc = tf_msg_session_resc_alloc(tfp,
 				       dev,
 				       parms->dir,
@@ -532,32 +636,56 @@ tf_rm_create_db(struct tf *tfp,
 
 	db = rm_db->db;
 	for (i = 0, j = 0; i < parms->num_elements; i++) {
-		db[i].cfg_type = parms->cfg[i].cfg_type;
-		db[i].hcapi_type = parms->cfg[i].hcapi_type;
+		struct tf_rm_element_cfg *cfg = &parms->cfg[i];
+		const char *type_str;
+
+		dev->ops->tf_dev_get_resource_str(tfp,
+						  cfg->hcapi_type,
+						  &type_str);
 
-		/* Skip any non HCAPI types as we didn't include them
-		 * in the reservation request.
+		db[i].cfg_type = cfg->cfg_type;
+		db[i].hcapi_type = cfg->hcapi_type;
+
+		/* Save the parent subtype for later use to find the pool
 		 */
-		if (parms->cfg[i].cfg_type != TF_RM_ELEM_CFG_HCAPI &&
-		    parms->cfg[i].cfg_type != TF_RM_ELEM_CFG_HCAPI_BA)
-			continue;
+		if (cfg->cfg_type == TF_RM_ELEM_CFG_HCAPI_BA_CHILD)
+			db[i].parent_subtype = cfg->parent_subtype;
 
 		/* If the element didn't request an allocation no need
 		 * to create a pool nor verify if we got a reservation.
 		 */
-		if (parms->alloc_cnt[i] == 0)
+		if (req_cnt[i] == 0)
+			continue;
+
+		/* Skip any children or invalid
+		 */
+		if (cfg->cfg_type != TF_RM_ELEM_CFG_HCAPI &&
+		    cfg->cfg_type != TF_RM_ELEM_CFG_HCAPI_BA &&
+		    cfg->cfg_type != TF_RM_ELEM_CFG_HCAPI_BA_PARENT)
 			continue;
 
 		/* If the element had requested an allocation and that
 		 * allocation was a success (full amount) then
 		 * allocate the pool.
 		 */
-		if (parms->alloc_cnt[i] == resv[j].stride) {
+		if (req_cnt[i] == resv[j].stride) {
 			db[i].alloc.entry.start = resv[j].start;
 			db[i].alloc.entry.stride = resv[j].stride;
 
-			/* Only allocate BA pool if so requested */
-			if (parms->cfg[i].cfg_type == TF_RM_ELEM_CFG_HCAPI_BA) {
+			/* Only allocate BA pool if a BA type not a child */
+			if (cfg->cfg_type == TF_RM_ELEM_CFG_HCAPI_BA ||
+			    cfg->cfg_type == TF_RM_ELEM_CFG_HCAPI_BA_PARENT) {
+				if (cfg->divider) {
+					resv[j].stride =
+						resv[j].stride / cfg->divider;
+					if (resv[j].stride <= 0) {
+						TFP_DRV_LOG(ERR,
+						     "%s:Divide fails:%d:%s\n",
+						     tf_dir_2_str(parms->dir),
+						     cfg->hcapi_type, type_str);
+						goto fail;
+					}
+				}
 				/* Create pool */
 				pool_size = (BITALLOC_SIZEOF(resv[j].stride) /
 					     sizeof(struct bitalloc));
@@ -567,9 +695,9 @@ tf_rm_create_db(struct tf *tfp,
 				rc = tfp_calloc(&cparms);
 				if (rc) {
 					TFP_DRV_LOG(ERR,
-					     "%s: Pool alloc failed, type:%d\n",
-					     tf_dir_2_str(parms->dir),
-					     db[i].cfg_type);
+					 "%s: Pool alloc failed, type:%d:%s\n",
+					 tf_dir_2_str(parms->dir),
+					 cfg->hcapi_type, type_str);
 					goto fail;
 				}
 				db[i].pool = (struct bitalloc *)cparms.mem_va;
@@ -577,9 +705,9 @@ tf_rm_create_db(struct tf *tfp,
 				rc = ba_init(db[i].pool, resv[j].stride);
 				if (rc) {
 					TFP_DRV_LOG(ERR,
-					     "%s: Pool init failed, type:%d\n",
-					     tf_dir_2_str(parms->dir),
-					     db[i].cfg_type);
+					  "%s: Pool init failed, type:%d:%s\n",
+					  tf_dir_2_str(parms->dir),
+					  cfg->hcapi_type, type_str);
 					goto fail;
 				}
 			}
@@ -589,25 +717,21 @@ tf_rm_create_db(struct tf *tfp,
 			 * all elements, not any less.
 			 */
 			TFP_DRV_LOG(ERR,
-				    "%s: Alloc failed, type:%d\n",
-				    tf_dir_2_str(parms->dir),
-				    db[i].cfg_type);
-			TFP_DRV_LOG(ERR,
-				    "req:%d, alloc:%d\n",
-				    parms->alloc_cnt[i],
-				    resv[j].stride);
+				    "%s: Alloc failed %d:%s req:%d, alloc:%d\n",
+				    tf_dir_2_str(parms->dir), cfg->hcapi_type,
+				    type_str, req_cnt[i], resv[j].stride);
 			goto fail;
 		}
 	}
 
 	rm_db->num_entries = parms->num_elements;
 	rm_db->dir = parms->dir;
-	rm_db->type = parms->type;
+	rm_db->module = parms->module;
 	*parms->rm_db = (void *)rm_db;
 
 	tfp_free((void *)req);
 	tfp_free((void *)resv);
-
+	tfp_free((void *)req_cnt);
 	return 0;
 
  fail:
@@ -616,6 +740,7 @@ tf_rm_create_db(struct tf *tfp,
 	tfp_free((void *)db->pool);
 	tfp_free((void *)db);
 	tfp_free((void *)rm_db);
+	tfp_free((void *)req_cnt);
 	parms->rm_db = NULL;
 
 	return -EINVAL;
@@ -682,7 +807,7 @@ tf_rm_free_db(struct tf *tfp,
 			TFP_DRV_LOG(ERR,
 				    "%s: Internal Flush error, module:%s\n",
 				    tf_dir_2_str(parms->dir),
-				    tf_device_module_type_2_str(rm_db->type));
+				    tf_module_2_str(rm_db->module));
 	}
 
 	/* No need to check for configuration type, even if we do not
@@ -695,6 +820,54 @@ tf_rm_free_db(struct tf *tfp,
 
 	return rc;
 }
+/**
+ * Get the bit allocator pool associated with the subtype and the db
+ *
+ * [in] rm_db
+ *   Pointer to the DB
+ *
+ * [in] subtype
+ *   Module subtype used to index into the module specific database.
+ *   An example subtype is TF_TBL_TYPE_FULL_ACT_RECORD which is a
+ *   module subtype of TF_MODULE_TYPE_TABLE.
+ *
+ * [in/out] pool
+ *   Pointer to the bit allocator pool used
+ *
+ * [in/out] new_subtype
+ *   Pointer to the subtype of the actual pool used
+ * Returns:
+ *     0          - Success
+ *   - ENOTSUP    - Operation not supported
+ */
+static int
+tf_rm_get_pool(struct tf_rm_new_db *rm_db,
+	       uint16_t subtype,
+	       struct bitalloc **pool,
+	       uint16_t *new_subtype)
+{
+	int rc = 0;
+	uint16_t tmp_subtype = subtype;
+
+	/* If we are a child, get the parent table index */
+	if (rm_db->db[subtype].cfg_type == TF_RM_ELEM_CFG_HCAPI_BA_CHILD)
+		tmp_subtype = rm_db->db[subtype].parent_subtype;
+
+	*pool = rm_db->db[tmp_subtype].pool;
+
+	/* Bail out if the pool is not valid, should never happen */
+	if (rm_db->db[tmp_subtype].pool == NULL) {
+		rc = -ENOTSUP;
+		TFP_DRV_LOG(ERR,
+			    "%s: Invalid pool for this type:%d, rc:%s\n",
+			    tf_dir_2_str(rm_db->dir),
+			    tmp_subtype,
+			    strerror(-rc));
+		return rc;
+	}
+	*new_subtype = tmp_subtype;
+	return rc;
+}
 
 int
 tf_rm_allocate(struct tf_rm_allocate_parms *parms)
@@ -704,37 +877,33 @@ tf_rm_allocate(struct tf_rm_allocate_parms *parms)
 	uint32_t index;
 	struct tf_rm_new_db *rm_db;
 	enum tf_rm_elem_cfg_type cfg_type;
+	struct bitalloc *pool;
+	uint16_t subtype;
 
 	TF_CHECK_PARMS2(parms, parms->rm_db);
 
 	rm_db = (struct tf_rm_new_db *)parms->rm_db;
-	if (!rm_db->db)
-		return -EINVAL;
-	cfg_type = rm_db->db[parms->db_index].cfg_type;
+	TF_CHECK_PARMS1(rm_db->db);
+
+	cfg_type = rm_db->db[parms->subtype].cfg_type;
 
 	/* Bail out if not controlled by RM */
-	if (cfg_type != TF_RM_ELEM_CFG_HCAPI_BA)
+	if (cfg_type != TF_RM_ELEM_CFG_HCAPI_BA &&
+	    cfg_type != TF_RM_ELEM_CFG_HCAPI_BA_PARENT &&
+	    cfg_type != TF_RM_ELEM_CFG_HCAPI_BA_CHILD)
 		return -ENOTSUP;
 
-	/* Bail out if the pool is not valid, should never happen */
-	if (rm_db->db[parms->db_index].pool == NULL) {
-		rc = -ENOTSUP;
-		TFP_DRV_LOG(ERR,
-			    "%s: Invalid pool for this type:%d, rc:%s\n",
-			    tf_dir_2_str(rm_db->dir),
-			    parms->db_index,
-			    strerror(-rc));
+	rc = tf_rm_get_pool(rm_db, parms->subtype, &pool, &subtype);
+	if (rc)
 		return rc;
-	}
-
 	/*
 	 * priority  0: allocate from top of the tcam i.e. high
 	 * priority !0: allocate index from bottom i.e lowest
 	 */
 	if (parms->priority)
-		id = ba_alloc_reverse(rm_db->db[parms->db_index].pool);
+		id = ba_alloc_reverse(pool);
 	else
-		id = ba_alloc(rm_db->db[parms->db_index].pool);
+		id = ba_alloc(pool);
 	if (id == BA_FAIL) {
 		rc = -ENOMEM;
 		TFP_DRV_LOG(ERR,
@@ -747,7 +916,7 @@ tf_rm_allocate(struct tf_rm_allocate_parms *parms)
 	/* Adjust for any non zero start value */
 	rc = tf_rm_adjust_index(rm_db->db,
 				TF_RM_ADJUST_ADD_BASE,
-				parms->db_index,
+				subtype,
 				id,
 				&index);
 	if (rc) {
@@ -772,39 +941,35 @@ tf_rm_free(struct tf_rm_free_parms *parms)
 	uint32_t adj_index;
 	struct tf_rm_new_db *rm_db;
 	enum tf_rm_elem_cfg_type cfg_type;
+	struct bitalloc *pool;
+	uint16_t subtype;
 
 	TF_CHECK_PARMS2(parms, parms->rm_db);
-
 	rm_db = (struct tf_rm_new_db *)parms->rm_db;
-	if (!rm_db->db)
-		return -EINVAL;
-	cfg_type = rm_db->db[parms->db_index].cfg_type;
+	TF_CHECK_PARMS1(rm_db->db);
+
+	cfg_type = rm_db->db[parms->subtype].cfg_type;
 
 	/* Bail out if not controlled by RM */
-	if (cfg_type != TF_RM_ELEM_CFG_HCAPI_BA)
+	if (cfg_type != TF_RM_ELEM_CFG_HCAPI_BA &&
+	    cfg_type != TF_RM_ELEM_CFG_HCAPI_BA_PARENT &&
+	    cfg_type != TF_RM_ELEM_CFG_HCAPI_BA_CHILD)
 		return -ENOTSUP;
 
-	/* Bail out if the pool is not valid, should never happen */
-	if (rm_db->db[parms->db_index].pool == NULL) {
-		rc = -ENOTSUP;
-		TFP_DRV_LOG(ERR,
-			    "%s: Invalid pool for this type:%d, rc:%s\n",
-			    tf_dir_2_str(rm_db->dir),
-			    parms->db_index,
-			    strerror(-rc));
+	rc = tf_rm_get_pool(rm_db, parms->subtype, &pool, &subtype);
+	if (rc)
 		return rc;
-	}
 
 	/* Adjust for any non zero start value */
 	rc = tf_rm_adjust_index(rm_db->db,
 				TF_RM_ADJUST_RM_BASE,
-				parms->db_index,
+				subtype,
 				parms->index,
 				&adj_index);
 	if (rc)
 		return rc;
 
-	rc = ba_free(rm_db->db[parms->db_index].pool, adj_index);
+	rc = ba_free(pool, adj_index);
 	/* No logging direction matters and that is not available here */
 	if (rc)
 		return rc;
@@ -819,33 +984,30 @@ tf_rm_is_allocated(struct tf_rm_is_allocated_parms *parms)
 	uint32_t adj_index;
 	struct tf_rm_new_db *rm_db;
 	enum tf_rm_elem_cfg_type cfg_type;
+	struct bitalloc *pool;
+	uint16_t subtype;
 
 	TF_CHECK_PARMS2(parms, parms->rm_db);
-
 	rm_db = (struct tf_rm_new_db *)parms->rm_db;
-	if (!rm_db->db)
-		return -EINVAL;
-	cfg_type = rm_db->db[parms->db_index].cfg_type;
+	TF_CHECK_PARMS1(rm_db->db);
+
+	cfg_type = rm_db->db[parms->subtype].cfg_type;
+
 
 	/* Bail out if not controlled by RM */
-	if (cfg_type != TF_RM_ELEM_CFG_HCAPI_BA)
+	if (cfg_type != TF_RM_ELEM_CFG_HCAPI_BA &&
+	    cfg_type != TF_RM_ELEM_CFG_HCAPI_BA_PARENT &&
+	    cfg_type != TF_RM_ELEM_CFG_HCAPI_BA_CHILD)
 		return -ENOTSUP;
 
-	/* Bail out if the pool is not valid, should never happen */
-	if (rm_db->db[parms->db_index].pool == NULL) {
-		rc = -ENOTSUP;
-		TFP_DRV_LOG(ERR,
-			    "%s: Invalid pool for this type:%d, rc:%s\n",
-			    tf_dir_2_str(rm_db->dir),
-			    parms->db_index,
-			    strerror(-rc));
+	rc = tf_rm_get_pool(rm_db, parms->subtype, &pool, &subtype);
+	if (rc)
 		return rc;
-	}
 
 	/* Adjust for any non zero start value */
 	rc = tf_rm_adjust_index(rm_db->db,
 				TF_RM_ADJUST_RM_BASE,
-				parms->db_index,
+				subtype,
 				parms->index,
 				&adj_index);
 	if (rc)
@@ -853,8 +1015,7 @@ tf_rm_is_allocated(struct tf_rm_is_allocated_parms *parms)
 
 	if (parms->base_index)
 		*parms->base_index = adj_index;
-	*parms->allocated = ba_inuse(rm_db->db[parms->db_index].pool,
-				     adj_index);
+	*parms->allocated = ba_inuse(pool, adj_index);
 
 	return rc;
 }
@@ -866,19 +1027,17 @@ tf_rm_get_info(struct tf_rm_get_alloc_info_parms *parms)
 	enum tf_rm_elem_cfg_type cfg_type;
 
 	TF_CHECK_PARMS2(parms, parms->rm_db);
-
 	rm_db = (struct tf_rm_new_db *)parms->rm_db;
-	if (!rm_db->db)
-		return -EINVAL;
-	cfg_type = rm_db->db[parms->db_index].cfg_type;
+	TF_CHECK_PARMS1(rm_db->db);
+
+	cfg_type = rm_db->db[parms->subtype].cfg_type;
 
 	/* Bail out if not controlled by HCAPI */
-	if (cfg_type != TF_RM_ELEM_CFG_HCAPI &&
-	    cfg_type != TF_RM_ELEM_CFG_HCAPI_BA)
+	if (cfg_type == TF_RM_ELEM_CFG_NULL)
 		return -ENOTSUP;
 
 	memcpy(parms->info,
-	       &rm_db->db[parms->db_index].alloc,
+	       &rm_db->db[parms->subtype].alloc,
 	       sizeof(struct tf_rm_alloc_info));
 
 	return 0;
@@ -891,18 +1050,16 @@ tf_rm_get_hcapi_type(struct tf_rm_get_hcapi_parms *parms)
 	enum tf_rm_elem_cfg_type cfg_type;
 
 	TF_CHECK_PARMS2(parms, parms->rm_db);
-
 	rm_db = (struct tf_rm_new_db *)parms->rm_db;
-	if (!rm_db->db)
-		return -EINVAL;
-	cfg_type = rm_db->db[parms->db_index].cfg_type;
+	TF_CHECK_PARMS1(rm_db->db);
+
+	cfg_type = rm_db->db[parms->subtype].cfg_type;
 
 	/* Bail out if not controlled by HCAPI */
-	if (cfg_type != TF_RM_ELEM_CFG_HCAPI &&
-	    cfg_type != TF_RM_ELEM_CFG_HCAPI_BA)
+	if (cfg_type == TF_RM_ELEM_CFG_NULL)
 		return -ENOTSUP;
 
-	*parms->hcapi_type = rm_db->db[parms->db_index].hcapi_type;
+	*parms->hcapi_type = rm_db->db[parms->subtype].hcapi_type;
 
 	return 0;
 }
@@ -915,30 +1072,31 @@ tf_rm_get_inuse_count(struct tf_rm_get_inuse_count_parms *parms)
 	enum tf_rm_elem_cfg_type cfg_type;
 
 	TF_CHECK_PARMS2(parms, parms->rm_db);
-
 	rm_db = (struct tf_rm_new_db *)parms->rm_db;
-	if (!rm_db->db)
-		return -EINVAL;
-	cfg_type = rm_db->db[parms->db_index].cfg_type;
+	TF_CHECK_PARMS1(rm_db->db);
 
-	/* Bail out if not controlled by RM */
-	if (cfg_type != TF_RM_ELEM_CFG_HCAPI_BA)
+	cfg_type = rm_db->db[parms->subtype].cfg_type;
+
+	/* Bail out if not a BA pool */
+	if (cfg_type != TF_RM_ELEM_CFG_HCAPI_BA &&
+	    cfg_type != TF_RM_ELEM_CFG_HCAPI_BA_PARENT &&
+	    cfg_type != TF_RM_ELEM_CFG_HCAPI_BA_CHILD)
 		return -ENOTSUP;
 
 	/* Bail silently (no logging), if the pool is not valid there
 	 * was no elements allocated for it.
 	 */
-	if (rm_db->db[parms->db_index].pool == NULL) {
+	if (rm_db->db[parms->subtype].pool == NULL) {
 		*parms->count = 0;
 		return 0;
 	}
 
-	*parms->count = ba_inuse_count(rm_db->db[parms->db_index].pool);
+	*parms->count = ba_inuse_count(rm_db->db[parms->subtype].pool);
 
 	return rc;
-
 }
-
+/* Only used for table bulk get at this time
+ */
 int
 tf_rm_check_indexes_in_range(struct tf_rm_check_indexes_in_range_parms *parms)
 {
@@ -947,31 +1105,27 @@ tf_rm_check_indexes_in_range(struct tf_rm_check_indexes_in_range_parms *parms)
 	uint32_t base_index;
 	uint32_t stride;
 	int rc = 0;
+	struct bitalloc *pool;
+	uint16_t subtype;
 
 	TF_CHECK_PARMS2(parms, parms->rm_db);
-
 	rm_db = (struct tf_rm_new_db *)parms->rm_db;
-	if (!rm_db->db)
-		return -EINVAL;
-	cfg_type = rm_db->db[parms->db_index].cfg_type;
+	TF_CHECK_PARMS1(rm_db->db);
 
-	/* Bail out if not controlled by RM */
-	if (cfg_type != TF_RM_ELEM_CFG_HCAPI_BA)
+	cfg_type = rm_db->db[parms->subtype].cfg_type;
+
+	/* Bail out if not a BA pool */
+	if (cfg_type != TF_RM_ELEM_CFG_HCAPI_BA &&
+	    cfg_type != TF_RM_ELEM_CFG_HCAPI_BA_PARENT &&
+	    cfg_type != TF_RM_ELEM_CFG_HCAPI_BA_CHILD)
 		return -ENOTSUP;
 
-	/* Bail out if the pool is not valid, should never happen */
-	if (rm_db->db[parms->db_index].pool == NULL) {
-		rc = -ENOTSUP;
-		TFP_DRV_LOG(ERR,
-			    "%s: Invalid pool for this type:%d, rc:%s\n",
-			    tf_dir_2_str(rm_db->dir),
-			    parms->db_index,
-			    strerror(-rc));
+	rc = tf_rm_get_pool(rm_db, parms->subtype, &pool, &subtype);
+	if (rc)
 		return rc;
-	}
 
-	base_index = rm_db->db[parms->db_index].alloc.entry.start;
-	stride = rm_db->db[parms->db_index].alloc.entry.stride;
+	base_index = rm_db->db[subtype].alloc.entry.start;
+	stride = rm_db->db[subtype].alloc.entry.stride;
 
 	if (parms->starting_index < base_index ||
 	    parms->starting_index + parms->num_entries > base_index + stride)
diff --git a/drivers/net/bnxt/tf_core/tf_rm.h b/drivers/net/bnxt/tf_core/tf_rm.h
index 291086c7c7..407c7d5bf9 100644
--- a/drivers/net/bnxt/tf_core/tf_rm.h
+++ b/drivers/net/bnxt/tf_core/tf_rm.h
@@ -35,11 +35,11 @@ struct tf;
  * The RM DB will work on its initial allocated sizes so the
  * capability of dynamically growing a particular resource is not
  * possible. If this capability later becomes a requirement then the
- * MAX pool size of the Chip œneeds to be added to the tf_rm_elem_info
+ * MAX pool size of the chip needs to be added to the tf_rm_elem_info
  * structure and several new APIs would need to be added to allow for
  * growth of a single TF resource type.
  *
- * The access functions does not check for NULL pointers as it's a
+ * The access functions do not check for NULL pointers as they are a
  * support module, not called directly.
  */
 
@@ -65,19 +65,28 @@ enum tf_rm_elem_cfg_type {
 	 * No configuration
 	 */
 	TF_RM_ELEM_CFG_NULL,
-	/** HCAPI 'controlled', no RM storage thus the Device Module
+	/** HCAPI 'controlled', no RM storage so the module
 	 *  using the RM can chose to handle storage locally.
 	 */
 	TF_RM_ELEM_CFG_HCAPI,
-	/** HCAPI 'controlled', uses a Bit Allocator Pool for internal
+	/** HCAPI 'controlled', uses a bit allocator pool for internal
 	 *  storage in the RM.
 	 */
 	TF_RM_ELEM_CFG_HCAPI_BA,
 	/**
-	 * Shared element thus it belongs to a shared FW Session and
-	 * is not controlled by the Host.
+	 * HCAPI 'controlled', uses a bit allocator pool for internal
+	 * storage in the RM but multiple TF types map to a single
+	 * HCAPI type.  Parent manages the table.
 	 */
-	TF_RM_ELEM_CFG_SHARED,
+	TF_RM_ELEM_CFG_HCAPI_BA_PARENT,
+	/**
+	 * HCAPI 'controlled', uses a bit allocator pool for internal
+	 * storage in the RM but multiple TF types map to a single
+	 * HCAPI type.  Child accesses the parent db.
+	 */
+	TF_RM_ELEM_CFG_HCAPI_BA_CHILD,
+
+
 	TF_RM_TYPE_MAX
 };
 
@@ -114,6 +123,30 @@ struct tf_rm_element_cfg {
 	 * conversion.
 	 */
 	uint16_t hcapi_type;
+
+	/**
+	 * if cfg_type == TF_RM_ELEM_CFG_HCAPI_BA_CHILD
+	 *
+	 * Parent Truflow module subtype associated with this resource type.
+	 */
+	uint16_t parent_subtype;
+
+	/**
+	 * if cfg_type == TF_RM_ELEM_CFG_HCAPI_BA_CHILD
+	 *
+	 * Resource slices.  How many slices will fit in the
+	 * resource pool chunk size.
+	 */
+	uint8_t slices;
+	/**
+	 * Pool element divider count
+	 * If 0 or 1, there is 1:1 correspondence between the RM
+	 * BA pool resource element and the HCAPI RM firmware
+	 * resource.  If > 1, the RM BA pool element has a 1:n
+	 * correspondence to the HCAPI RM firmware resource.
+	 */
+	uint8_t divider;
+
 };
 
 /**
@@ -135,9 +168,9 @@ struct tf_rm_alloc_info {
  */
 struct tf_rm_create_db_parms {
 	/**
-	 * [in] Device module type. Used for logging purposes.
+	 * [in] Module type. Used for logging purposes.
 	 */
-	enum tf_device_module_type type;
+	enum tf_module_type module;
 	/**
 	 * [in] Receive or transmit direction.
 	 */
@@ -153,8 +186,7 @@ struct tf_rm_create_db_parms {
 	/**
 	 * Resource allocation count array. This array content
 	 * originates from the tf_session_resources that is passed in
-	 * on session open.
-	 * Array size is num_elements.
+	 * on session open. Array size is num_elements.
 	 */
 	uint16_t *alloc_cnt;
 	/**
@@ -186,10 +218,11 @@ struct tf_rm_allocate_parms {
 	 */
 	void *rm_db;
 	/**
-	 * [in] DB Index, indicates which DB entry to perform the
-	 * action on.
+	 * [in] Module subtype indicates which DB entry to perform the
+	 * action on.  (e.g. TF_TCAM_TBL_TYPE_L2_CTXT subtype of module
+	 * TF_MODULE_TYPE_TCAM)
 	 */
-	uint16_t db_index;
+	uint16_t subtype;
 	/**
 	 * [in] Pointer to the allocated index in normalized
 	 * form. Normalized means the index has been adjusted,
@@ -219,10 +252,11 @@ struct tf_rm_free_parms {
 	 */
 	void *rm_db;
 	/**
-	 * [in] DB Index, indicates which DB entry to perform the
-	 * action on.
+	 * [in] TF subtype indicates which DB entry to perform the
+	 * action on. (e.g. TF_TCAM_TBL_TYPE_L2_CTXT subtype of module
+	 * TF_MODULE_TYPE_TCAM)
 	 */
-	uint16_t db_index;
+	uint16_t subtype;
 	/**
 	 * [in] Index to free
 	 */
@@ -238,10 +272,11 @@ struct tf_rm_is_allocated_parms {
 	 */
 	void *rm_db;
 	/**
-	 * [in] DB Index, indicates which DB entry to perform the
-	 * action on.
+	 * [in] TF subtype indicates which DB entry to perform the
+	 * action on. (e.g. TF_TCAM_TBL_TYPE_L2_CTXT subtype of module
+	 * TF_MODULE_TYPE_TCAM)
 	 */
-	uint16_t db_index;
+	uint16_t subtype;
 	/**
 	 * [in] Index to free
 	 */
@@ -265,13 +300,14 @@ struct tf_rm_get_alloc_info_parms {
 	 */
 	void *rm_db;
 	/**
-	 * [in] DB Index, indicates which DB entry to perform the
-	 * action on.
+	 * [in] TF subtype indicates which DB entry to perform the
+	 * action on. (e.g. TF_TCAM_TBL_TYPE_L2_CTXT subtype of module
+	 * TF_MODULE_TYPE_TCAM)
 	 */
-	uint16_t db_index;
+	uint16_t subtype;
 	/**
 	 * [out] Pointer to the requested allocation information for
-	 * the specified db_index
+	 * the specified subtype
 	 */
 	struct tf_rm_alloc_info *info;
 };
@@ -285,12 +321,13 @@ struct tf_rm_get_hcapi_parms {
 	 */
 	void *rm_db;
 	/**
-	 * [in] DB Index, indicates which DB entry to perform the
-	 * action on.
+	 * [in] TF subtype indicates which DB entry to perform the
+	 * action on. (e.g. TF_TCAM_TBL_TYPE_L2_CTXT subtype of module
+	 * TF_MODULE_TYPE_TCAM)
 	 */
-	uint16_t db_index;
+	uint16_t subtype;
 	/**
-	 * [out] Pointer to the hcapi type for the specified db_index
+	 * [out] Pointer to the hcapi type for the specified subtype
 	 */
 	uint16_t *hcapi_type;
 };
@@ -304,12 +341,13 @@ struct tf_rm_get_inuse_count_parms {
 	 */
 	void *rm_db;
 	/**
-	 * [in] DB Index, indicates which DB entry to perform the
-	 * action on.
+	 * [in] TF subtype indicates which DB entry to perform the
+	 * action on. (e.g. TF_TCAM_TBL_TYPE_L2_CTXT subtype of module
+	 * TF_MODULE_TYPE_TCAM)
 	 */
-	uint16_t db_index;
+	uint16_t subtype;
 	/**
-	 * [out] Pointer to the inuse count for the specified db_index
+	 * [out] Pointer to the inuse count for the specified subtype
 	 */
 	uint16_t *count;
 };
@@ -323,10 +361,11 @@ struct tf_rm_check_indexes_in_range_parms {
 	 */
 	void *rm_db;
 	/**
-	 * [in] DB Index, indicates which DB entry to perform the
-	 * action on.
+	 * [in] TF subtype indicates which DB entry to perform the
+	 * action on. (e.g. TF_TCAM_TBL_TYPE_L2_CTXT subtype of module
+	 * TF_MODULE_TYPE_TCAM)
 	 */
-	uint16_t db_index;
+	uint16_t subtype;
 	/**
 	 * [in] Starting index
 	 */
diff --git a/drivers/net/bnxt/tf_core/tf_shadow_tbl.c b/drivers/net/bnxt/tf_core/tf_shadow_tbl.c
deleted file mode 100644
index 396ebdb0a9..0000000000
--- a/drivers/net/bnxt/tf_core/tf_shadow_tbl.c
+++ /dev/null
@@ -1,783 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2019-2021 Broadcom
- * All rights reserved.
- */
-
-#include "tf_common.h"
-#include "tf_util.h"
-#include "tfp.h"
-#include "tf_core.h"
-#include "tf_shadow_tbl.h"
-#include "tf_hash.h"
-
-/**
- * The implementation includes 3 tables per table table type.
- * - hash table
- *   - sized so that a minimum of 4 slots per shadow entry are available to
- *   minimize the likelihood of collisions.
- * - shadow key table
- *   - sized to the number of entries requested and is directly indexed
- *   - the index is zero based and is the table index - the base address
- *   - the data associated with the entry is stored in the key table.
- *   - The stored key is actually the data associated with the entry.
- * - shadow result table
- *   - the result table is stored separately since it only needs to be accessed
- *   when the key matches.
- *   - the result has a back pointer to the hash table via the hb handle.  The
- *   hb handle is a 32 bit represention of the hash with a valid bit, bucket
- *   element index, and the hash index.  It is necessary to store the hb handle
- *   with the result since subsequent removes only provide the table index.
- *
- * - Max entries is limited in the current implementation since bit 15 is the
- *   valid bit in the hash table.
- * - A 16bit hash is calculated and masked based on the number of entries
- * - 64b wide bucket is used and broken into 4x16bit elements.
- *   This decision is based on quicker bucket scanning to determine if any
- *   elements are in use.
- * - bit 15 of each bucket element is the valid, this is done to prevent having
- *   to read the larger key/result data for determining VALID.  It also aids
- *   in the more efficient scanning of the bucket for slot usage.
- */
-
-/*
- * The maximum number of shadow entries supported.  The value also doubles as
- * the maximum number of hash buckets.  There are only 15 bits of data per
- * bucket to point to the shadow tables.
- */
-#define TF_SHADOW_ENTRIES_MAX (1 << 15)
-
-/* The number of elements(BE) per hash bucket (HB) */
-#define TF_SHADOW_HB_NUM_ELEM (4)
-#define TF_SHADOW_BE_VALID (1 << 15)
-#define TF_SHADOW_BE_IS_VALID(be) (((be) & TF_SHADOW_BE_VALID) != 0)
-
-/**
- * The hash bucket handle is 32b
- * - bit 31, the Valid bit
- * - bit 29-30, the element
- * - bits 0-15, the hash idx (is masked based on the allocated size)
- */
-#define TF_SHADOW_HB_HANDLE_IS_VALID(hndl) (((hndl) & (1 << 31)) != 0)
-#define TF_SHADOW_HB_HANDLE_CREATE(idx, be) ((1 << 31) | \
-					     ((be) << 29) | (idx))
-
-#define TF_SHADOW_HB_HANDLE_BE_GET(hdl) (((hdl) >> 29) & \
-					 (TF_SHADOW_HB_NUM_ELEM - 1))
-
-#define TF_SHADOW_HB_HANDLE_HASH_GET(ctxt, hdl)((hdl) & \
-						(ctxt)->hash_ctxt.hid_mask)
-
-/**
- * The idx provided by the caller is within a region, so currently the base is
- * either added or subtracted from the idx to ensure it can be used as a
- * compressed index
- */
-
-/* Convert the table index to a shadow index */
-#define TF_SHADOW_IDX_TO_SHIDX(ctxt, idx) ((idx) - \
-					   (ctxt)->shadow_ctxt.base_addr)
-
-/* Convert the shadow index to a tbl index */
-#define TF_SHADOW_SHIDX_TO_IDX(ctxt, idx) ((idx) + \
-					   (ctxt)->shadow_ctxt.base_addr)
-
-/* Simple helper masks for clearing en element from the bucket */
-#define TF_SHADOW_BE0_MASK_CLEAR(hb) ((hb) & 0xffffffffffff0000ull)
-#define TF_SHADOW_BE1_MASK_CLEAR(hb) ((hb) & 0xffffffff0000ffffull)
-#define TF_SHADOW_BE2_MASK_CLEAR(hb) ((hb) & 0xffff0000ffffffffull)
-#define TF_SHADOW_BE3_MASK_CLEAR(hb) ((hb) & 0x0000ffffffffffffull)
-
-/**
- * This should be coming from external, but for now it is assumed that no key
- * is greater than 512 bits (64B).  This makes allocation of the key table
- * easier without having to allocate on the fly.
- */
-#define TF_SHADOW_MAX_KEY_SZ 64
-
-/*
- * Local only defines for the internal data.
- */
-
-/**
- * tf_shadow_tbl_shadow_key_entry is the key entry of the key table.
- * The key stored in the table is the result data of the index table.
- */
-struct tf_shadow_tbl_shadow_key_entry {
-	uint8_t key[TF_SHADOW_MAX_KEY_SZ];
-};
-
-/**
- * tf_shadow_tbl_shadow_result_entry is the result table entry.
- * The result table writes are broken into two phases:
- * - The search phase, which stores the hb_handle and key size and
- * - The set phase, which writes the refcnt
- */
-struct tf_shadow_tbl_shadow_result_entry {
-	uint16_t key_size;
-	uint32_t refcnt;
-	uint32_t hb_handle;
-};
-
-/**
- * tf_shadow_tbl_shadow_ctxt holds all information for accessing the key and
- * result tables.
- */
-struct tf_shadow_tbl_shadow_ctxt {
-	struct tf_shadow_tbl_shadow_key_entry *sh_key_tbl;
-	struct tf_shadow_tbl_shadow_result_entry *sh_res_tbl;
-	uint32_t base_addr;
-	uint16_t num_entries;
-	uint16_t alloc_idx;
-};
-
-/**
- * tf_shadow_tbl_hash_ctxt holds all information related to accessing the hash
- * table.
- */
-struct tf_shadow_tbl_hash_ctxt {
-	uint64_t *hashtbl;
-	uint16_t hid_mask;
-	uint16_t hash_entries;
-};
-
-/**
- * tf_shadow_tbl_ctxt holds the hash and shadow tables for the current shadow
- * table db.  This structure is per table table type as each table table has
- * it's own shadow and hash table.
- */
-struct tf_shadow_tbl_ctxt {
-	struct tf_shadow_tbl_shadow_ctxt shadow_ctxt;
-	struct tf_shadow_tbl_hash_ctxt hash_ctxt;
-};
-
-/**
- * tf_shadow_tbl_db is the allocated db structure returned as an opaque
- * void * pointer to the caller during create db.  It holds the pointers for
- * each table associated with the db.
- */
-struct tf_shadow_tbl_db {
-	/* Each context holds the shadow and hash table information */
-	struct tf_shadow_tbl_ctxt *ctxt[TF_TBL_TYPE_MAX];
-};
-
-/**
- * Simple routine that decides what table types can be searchable.
- *
- */
-static int tf_shadow_tbl_is_searchable(enum tf_tbl_type type)
-{
-	int rc = 0;
-
-	switch (type) {
-	case TF_TBL_TYPE_ACT_ENCAP_8B:
-	case TF_TBL_TYPE_ACT_ENCAP_16B:
-	case TF_TBL_TYPE_ACT_ENCAP_32B:
-	case TF_TBL_TYPE_ACT_ENCAP_64B:
-	case TF_TBL_TYPE_ACT_SP_SMAC:
-	case TF_TBL_TYPE_ACT_SP_SMAC_IPV4:
-	case TF_TBL_TYPE_ACT_SP_SMAC_IPV6:
-	case TF_TBL_TYPE_ACT_MODIFY_IPV4:
-		rc = 1;
-		break;
-	default:
-		rc = 0;
-		break;
-	};
-
-	return rc;
-}
-
-/**
- * Returns the number of entries in the contexts shadow table.
- */
-static inline uint16_t
-tf_shadow_tbl_sh_num_entries_get(struct tf_shadow_tbl_ctxt *ctxt)
-{
-	return ctxt->shadow_ctxt.num_entries;
-}
-
-/**
- * Compare the give key with the key in the shadow table.
- *
- * Returns 0 if the keys match
- */
-static int
-tf_shadow_tbl_key_cmp(struct tf_shadow_tbl_ctxt *ctxt,
-		      uint8_t *key,
-		      uint16_t sh_idx,
-		      uint16_t size)
-{
-	if (size != ctxt->shadow_ctxt.sh_res_tbl[sh_idx].key_size ||
-	    sh_idx >= tf_shadow_tbl_sh_num_entries_get(ctxt) || !key)
-		return -1;
-
-	return memcmp(key, ctxt->shadow_ctxt.sh_key_tbl[sh_idx].key, size);
-}
-
-/**
- * Free the memory associated with the context.
- */
-static void
-tf_shadow_tbl_ctxt_delete(struct tf_shadow_tbl_ctxt *ctxt)
-{
-	if (!ctxt)
-		return;
-
-	tfp_free(ctxt->hash_ctxt.hashtbl);
-	tfp_free(ctxt->shadow_ctxt.sh_key_tbl);
-	tfp_free(ctxt->shadow_ctxt.sh_res_tbl);
-}
-
-/**
- * The TF Shadow TBL context is per TBL and holds all information relating to
- * managing the shadow and search capability.  This routine allocated data that
- * needs to be deallocated by the tf_shadow_tbl_ctxt_delete prior when deleting
- * the shadow db.
- */
-static int
-tf_shadow_tbl_ctxt_create(struct tf_shadow_tbl_ctxt *ctxt,
-			  uint16_t num_entries,
-			  uint16_t base_addr)
-{
-	struct tfp_calloc_parms cparms;
-	uint16_t hash_size = 1;
-	uint16_t hash_mask;
-	int rc;
-
-	/* Hash table is a power of two that holds the number of entries */
-	if (num_entries > TF_SHADOW_ENTRIES_MAX) {
-		TFP_DRV_LOG(ERR, "Too many entries for shadow %d > %d\n",
-			    num_entries,
-			    TF_SHADOW_ENTRIES_MAX);
-		return -ENOMEM;
-	}
-
-	while (hash_size < num_entries)
-		hash_size = hash_size << 1;
-
-	hash_mask = hash_size - 1;
-
-	/* Allocate the hash table */
-	cparms.nitems = hash_size;
-	cparms.size = sizeof(uint64_t);
-	cparms.alignment = 0;
-	rc = tfp_calloc(&cparms);
-	if (rc)
-		goto error;
-	ctxt->hash_ctxt.hashtbl = cparms.mem_va;
-	ctxt->hash_ctxt.hid_mask = hash_mask;
-	ctxt->hash_ctxt.hash_entries = hash_size;
-
-	/* allocate the shadow tables */
-	/* allocate the shadow key table */
-	cparms.nitems = num_entries;
-	cparms.size = sizeof(struct tf_shadow_tbl_shadow_key_entry);
-	cparms.alignment = 0;
-	rc = tfp_calloc(&cparms);
-	if (rc)
-		goto error;
-	ctxt->shadow_ctxt.sh_key_tbl = cparms.mem_va;
-
-	/* allocate the shadow result table */
-	cparms.nitems = num_entries;
-	cparms.size = sizeof(struct tf_shadow_tbl_shadow_result_entry);
-	cparms.alignment = 0;
-	rc = tfp_calloc(&cparms);
-	if (rc)
-		goto error;
-	ctxt->shadow_ctxt.sh_res_tbl = cparms.mem_va;
-
-	ctxt->shadow_ctxt.num_entries = num_entries;
-	ctxt->shadow_ctxt.base_addr = base_addr;
-
-	return 0;
-error:
-	tf_shadow_tbl_ctxt_delete(ctxt);
-
-	return -ENOMEM;
-}
-
-/**
- * Get a shadow table context given the db and the table type
- */
-static struct tf_shadow_tbl_ctxt *
-tf_shadow_tbl_ctxt_get(struct tf_shadow_tbl_db *shadow_db,
-		       enum tf_tbl_type type)
-{
-	if (type >= TF_TBL_TYPE_MAX ||
-	    !shadow_db ||
-	    !shadow_db->ctxt[type])
-		return NULL;
-
-	return shadow_db->ctxt[type];
-}
-
-/**
- * Sets the hash entry into the table given the table context, hash bucket
- * handle, and shadow index.
- */
-static inline int
-tf_shadow_tbl_set_hash_entry(struct tf_shadow_tbl_ctxt *ctxt,
-			     uint32_t hb_handle,
-			     uint16_t sh_idx)
-{
-	uint16_t hid = TF_SHADOW_HB_HANDLE_HASH_GET(ctxt, hb_handle);
-	uint16_t be = TF_SHADOW_HB_HANDLE_BE_GET(hb_handle);
-	uint64_t entry = sh_idx | TF_SHADOW_BE_VALID;
-
-	if (hid >= ctxt->hash_ctxt.hash_entries)
-		return -EINVAL;
-
-	ctxt->hash_ctxt.hashtbl[hid] |= entry << (be * 16);
-	return 0;
-}
-
-/**
- * Clears the hash entry given the TBL context and hash bucket handle.
- */
-static inline void
-tf_shadow_tbl_clear_hash_entry(struct tf_shadow_tbl_ctxt *ctxt,
-			       uint32_t hb_handle)
-{
-	uint16_t hid, be;
-	uint64_t *bucket;
-
-	if (!TF_SHADOW_HB_HANDLE_IS_VALID(hb_handle))
-		return;
-
-	hid = TF_SHADOW_HB_HANDLE_HASH_GET(ctxt, hb_handle);
-	be = TF_SHADOW_HB_HANDLE_BE_GET(hb_handle);
-	bucket = &ctxt->hash_ctxt.hashtbl[hid];
-
-	switch (be) {
-	case 0:
-		*bucket = TF_SHADOW_BE0_MASK_CLEAR(*bucket);
-		break;
-	case 1:
-		*bucket = TF_SHADOW_BE1_MASK_CLEAR(*bucket);
-		break;
-	case 2:
-		*bucket = TF_SHADOW_BE2_MASK_CLEAR(*bucket);
-		break;
-	case 3:
-		*bucket = TF_SHADOW_BE2_MASK_CLEAR(*bucket);
-		break;
-	default:
-		/*
-		 * Since the BE_GET masks non-inclusive bits, this will not
-		 * happen.
-		 */
-		break;
-	}
-}
-
-/**
- * Clears the shadow key and result entries given the table context and
- * shadow index.
- */
-static void
-tf_shadow_tbl_clear_sh_entry(struct tf_shadow_tbl_ctxt *ctxt,
-			     uint16_t sh_idx)
-{
-	struct tf_shadow_tbl_shadow_key_entry *sk_entry;
-	struct tf_shadow_tbl_shadow_result_entry *sr_entry;
-
-	if (sh_idx >= tf_shadow_tbl_sh_num_entries_get(ctxt))
-		return;
-
-	sk_entry = &ctxt->shadow_ctxt.sh_key_tbl[sh_idx];
-	sr_entry = &ctxt->shadow_ctxt.sh_res_tbl[sh_idx];
-
-	/*
-	 * memset key/result to zero for now, possibly leave the data alone
-	 * in the future and rely on the valid bit in the hash table.
-	 */
-	memset(sk_entry, 0, sizeof(struct tf_shadow_tbl_shadow_key_entry));
-	memset(sr_entry, 0, sizeof(struct tf_shadow_tbl_shadow_result_entry));
-}
-
-/**
- * Binds the allocated tbl index with the hash and shadow tables.
- * The entry will be incomplete until the set has happened with the result
- * data.
- */
-int
-tf_shadow_tbl_bind_index(struct tf_shadow_tbl_bind_index_parms *parms)
-{
-	int rc;
-	uint16_t idx, len;
-	struct tf_shadow_tbl_ctxt *ctxt;
-	struct tf_shadow_tbl_db *shadow_db;
-	struct tf_shadow_tbl_shadow_key_entry *sk_entry;
-	struct tf_shadow_tbl_shadow_result_entry *sr_entry;
-
-	if (!parms || !TF_SHADOW_HB_HANDLE_IS_VALID(parms->hb_handle) ||
-	    !parms->data) {
-		TFP_DRV_LOG(ERR, "Invalid parms\n");
-		return -EINVAL;
-	}
-
-	shadow_db = (struct tf_shadow_tbl_db *)parms->shadow_db;
-	ctxt = tf_shadow_tbl_ctxt_get(shadow_db, parms->type);
-	if (!ctxt) {
-		TFP_DRV_LOG(DEBUG, "%s no ctxt for table\n",
-			    tf_tbl_type_2_str(parms->type));
-		return -EINVAL;
-	}
-
-	idx = TF_SHADOW_IDX_TO_SHIDX(ctxt, parms->idx);
-	len = parms->data_sz_in_bytes;
-	if (idx >= tf_shadow_tbl_sh_num_entries_get(ctxt) ||
-	    len > TF_SHADOW_MAX_KEY_SZ) {
-		TFP_DRV_LOG(ERR, "%s:%s Invalid len (%d) > %d || oob idx %d\n",
-			    tf_dir_2_str(parms->dir),
-			    tf_tbl_type_2_str(parms->type),
-			    len,
-			    TF_SHADOW_MAX_KEY_SZ, idx);
-
-		return -EINVAL;
-	}
-
-	rc = tf_shadow_tbl_set_hash_entry(ctxt, parms->hb_handle, idx);
-	if (rc)
-		return -EINVAL;
-
-	sk_entry = &ctxt->shadow_ctxt.sh_key_tbl[idx];
-	sr_entry = &ctxt->shadow_ctxt.sh_res_tbl[idx];
-
-	/* For tables, the data is the key */
-	memcpy(sk_entry->key, parms->data, len);
-
-	/* Write the result table */
-	sr_entry->key_size = len;
-	sr_entry->hb_handle = parms->hb_handle;
-	sr_entry->refcnt = 1;
-
-	return 0;
-}
-
-/**
- * Deletes hash/shadow information if no more references.
- *
- * Returns 0 - The caller should delete the table entry in hardware.
- * Returns non-zero - The number of references to the entry
- */
-int
-tf_shadow_tbl_remove(struct tf_shadow_tbl_remove_parms *parms)
-{
-	uint16_t idx;
-	uint32_t hb_handle;
-	struct tf_shadow_tbl_ctxt *ctxt;
-	struct tf_shadow_tbl_db *shadow_db;
-	struct tf_tbl_free_parms *fparms;
-	struct tf_shadow_tbl_shadow_result_entry *sr_entry;
-
-	if (!parms || !parms->fparms) {
-		TFP_DRV_LOG(ERR, "Invalid parms\n");
-		return -EINVAL;
-	}
-
-	fparms = parms->fparms;
-	if (!tf_shadow_tbl_is_searchable(fparms->type))
-		return 0;
-	/*
-	 * Initialize the ref count to zero.  The default would be to remove
-	 * the entry.
-	 */
-	fparms->ref_cnt = 0;
-
-	shadow_db = (struct tf_shadow_tbl_db *)parms->shadow_db;
-	ctxt = tf_shadow_tbl_ctxt_get(shadow_db, fparms->type);
-	if (!ctxt) {
-		TFP_DRV_LOG(DEBUG, "%s no ctxt for table\n",
-			    tf_tbl_type_2_str(fparms->type));
-		return 0;
-	}
-
-	idx = TF_SHADOW_IDX_TO_SHIDX(ctxt, fparms->idx);
-	if (idx >= tf_shadow_tbl_sh_num_entries_get(ctxt)) {
-		TFP_DRV_LOG(DEBUG, "%s %d >= %d\n",
-			    tf_tbl_type_2_str(fparms->type),
-			    fparms->idx,
-			    tf_shadow_tbl_sh_num_entries_get(ctxt));
-		return 0;
-	}
-
-	sr_entry = &ctxt->shadow_ctxt.sh_res_tbl[idx];
-	if (sr_entry->refcnt <= 1) {
-		hb_handle = sr_entry->hb_handle;
-		tf_shadow_tbl_clear_hash_entry(ctxt, hb_handle);
-		tf_shadow_tbl_clear_sh_entry(ctxt, idx);
-	} else {
-		sr_entry->refcnt--;
-		fparms->ref_cnt = sr_entry->refcnt;
-	}
-
-	return 0;
-}
-
-int
-tf_shadow_tbl_search(struct tf_shadow_tbl_search_parms *parms)
-{
-	uint16_t len;
-	uint64_t bucket;
-	uint32_t i, hid32;
-	struct tf_shadow_tbl_ctxt *ctxt;
-	struct tf_shadow_tbl_db *shadow_db;
-	uint16_t hid16, hb_idx, hid_mask, shtbl_idx, shtbl_key, be_valid;
-	struct tf_tbl_alloc_search_parms *sparms;
-	uint32_t be_avail = TF_SHADOW_HB_NUM_ELEM;
-
-	if (!parms || !parms->sparms) {
-		TFP_DRV_LOG(ERR, "tbl search with invalid parms\n");
-		return -EINVAL;
-	}
-
-	sparms = parms->sparms;
-	/* Check that caller was supposed to call search */
-	if (!tf_shadow_tbl_is_searchable(sparms->type))
-		return -EINVAL;
-
-	/* Initialize return values to invalid */
-	sparms->hit = 0;
-	sparms->search_status = REJECT;
-	parms->hb_handle = 0;
-	sparms->ref_cnt = 0;
-
-	shadow_db = (struct tf_shadow_tbl_db *)parms->shadow_db;
-	ctxt = tf_shadow_tbl_ctxt_get(shadow_db, sparms->type);
-	if (!ctxt) {
-		TFP_DRV_LOG(ERR, "%s Unable to get tbl mgr context\n",
-			    tf_tbl_type_2_str(sparms->type));
-		return -EINVAL;
-	}
-
-	len = sparms->result_sz_in_bytes;
-	if (len > TF_SHADOW_MAX_KEY_SZ || !sparms->result || !len) {
-		TFP_DRV_LOG(ERR, "%s:%s Invalid parms %d : %p\n",
-			    tf_dir_2_str(sparms->dir),
-			    tf_tbl_type_2_str(sparms->type),
-			    len,
-			    sparms->result);
-		return -EINVAL;
-	}
-
-	/*
-	 * Calculate the crc32
-	 * Fold it to create a 16b value
-	 * Reduce it to fit the table
-	 */
-	hid32 = tf_hash_calc_crc32(sparms->result, len);
-	hid16 = (uint16_t)(((hid32 >> 16) & 0xffff) ^ (hid32 & 0xffff));
-	hid_mask = ctxt->hash_ctxt.hid_mask;
-	hb_idx = hid16 & hid_mask;
-
-	bucket = ctxt->hash_ctxt.hashtbl[hb_idx];
-	if (!bucket) {
-		/* empty bucket means a miss and available entry */
-		sparms->search_status = MISS;
-		parms->hb_handle = TF_SHADOW_HB_HANDLE_CREATE(hb_idx, 0);
-		sparms->idx = 0;
-		return 0;
-	}
-
-	/* Set the avail to max so we can detect when there is an avail entry */
-	be_avail = TF_SHADOW_HB_NUM_ELEM;
-	for (i = 0; i < TF_SHADOW_HB_NUM_ELEM; i++) {
-		shtbl_idx = (uint16_t)((bucket >> (i * 16)) & 0xffff);
-		be_valid = TF_SHADOW_BE_IS_VALID(shtbl_idx);
-		if (!be_valid) {
-			/* The element is avail, keep going */
-			be_avail = i;
-			continue;
-		}
-		/* There is a valid entry, compare it */
-		shtbl_key = shtbl_idx & ~TF_SHADOW_BE_VALID;
-		if (!tf_shadow_tbl_key_cmp(ctxt,
-					   sparms->result,
-					   shtbl_key,
-					   len)) {
-			/*
-			 * It matches, increment the ref count if the caller
-			 * requested allocation and return the info
-			 */
-			if (sparms->alloc)
-				ctxt->shadow_ctxt.sh_res_tbl[shtbl_key].refcnt =
-			ctxt->shadow_ctxt.sh_res_tbl[shtbl_key].refcnt + 1;
-
-			sparms->hit = 1;
-			sparms->search_status = HIT;
-			parms->hb_handle =
-				TF_SHADOW_HB_HANDLE_CREATE(hb_idx, i);
-			sparms->idx = TF_SHADOW_SHIDX_TO_IDX(ctxt, shtbl_key);
-			sparms->ref_cnt =
-				ctxt->shadow_ctxt.sh_res_tbl[shtbl_key].refcnt;
-
-			return 0;
-		}
-	}
-
-	/* No hits, return avail entry if exists */
-	if (be_avail < TF_SHADOW_HB_NUM_ELEM) {
-		/*
-		 * There is an available hash entry, so return MISS and the
-		 * hash handle for the subsequent bind.
-		 */
-		parms->hb_handle = TF_SHADOW_HB_HANDLE_CREATE(hb_idx, be_avail);
-		sparms->search_status = MISS;
-		sparms->hit = 0;
-		sparms->idx = 0;
-	} else {
-		/* No room for the entry in the hash table, must REJECT */
-		sparms->search_status = REJECT;
-	}
-
-	return 0;
-}
-
-int
-tf_shadow_tbl_insert(struct tf_shadow_tbl_insert_parms *parms)
-{
-	uint16_t idx;
-	struct tf_shadow_tbl_ctxt *ctxt;
-	struct tf_tbl_set_parms *sparms;
-	struct tf_shadow_tbl_db *shadow_db;
-	struct tf_shadow_tbl_shadow_result_entry *sr_entry;
-
-	if (!parms || !parms->sparms) {
-		TFP_DRV_LOG(ERR, "Null parms\n");
-		return -EINVAL;
-	}
-
-	sparms = parms->sparms;
-	if (!sparms->data || !sparms->data_sz_in_bytes) {
-		TFP_DRV_LOG(ERR, "%s:%s No result to set.\n",
-			    tf_dir_2_str(sparms->dir),
-			    tf_tbl_type_2_str(sparms->type));
-		return -EINVAL;
-	}
-
-	shadow_db = (struct tf_shadow_tbl_db *)parms->shadow_db;
-	ctxt = tf_shadow_tbl_ctxt_get(shadow_db, sparms->type);
-	if (!ctxt) {
-		/* We aren't tracking this table, so return success */
-		TFP_DRV_LOG(DEBUG, "%s Unable to get tbl mgr context\n",
-			    tf_tbl_type_2_str(sparms->type));
-		return 0;
-	}
-
-	idx = TF_SHADOW_IDX_TO_SHIDX(ctxt, sparms->idx);
-	if (idx >= tf_shadow_tbl_sh_num_entries_get(ctxt)) {
-		TFP_DRV_LOG(ERR, "%s:%s Invalid idx(0x%x)\n",
-			    tf_dir_2_str(sparms->dir),
-			    tf_tbl_type_2_str(sparms->type),
-			    sparms->idx);
-		return -EINVAL;
-	}
-
-	/* Write the result table, the key/hash has been written already */
-	sr_entry = &ctxt->shadow_ctxt.sh_res_tbl[idx];
-
-	/*
-	 * If the handle is not valid, the bind was never called.  We aren't
-	 * tracking this entry.
-	 */
-	if (!TF_SHADOW_HB_HANDLE_IS_VALID(sr_entry->hb_handle))
-		return 0;
-
-	return 0;
-}
-
-int
-tf_shadow_tbl_free_db(struct tf_shadow_tbl_free_db_parms *parms)
-{
-	struct tf_shadow_tbl_db *shadow_db;
-	int i;
-
-	TF_CHECK_PARMS1(parms);
-
-	shadow_db = (struct tf_shadow_tbl_db *)parms->shadow_db;
-	if (!shadow_db) {
-		TFP_DRV_LOG(DEBUG, "Shadow db is NULL cannot be freed\n");
-		return -EINVAL;
-	}
-
-	for (i = 0; i < TF_TBL_TYPE_MAX; i++) {
-		if (shadow_db->ctxt[i]) {
-			tf_shadow_tbl_ctxt_delete(shadow_db->ctxt[i]);
-			tfp_free(shadow_db->ctxt[i]);
-		}
-	}
-
-	tfp_free(shadow_db);
-
-	return 0;
-}
-
-/**
- * Allocate the table resources for search and allocate
- *
- */
-int tf_shadow_tbl_create_db(struct tf_shadow_tbl_create_db_parms *parms)
-{
-	int rc;
-	int i;
-	uint16_t base;
-	struct tfp_calloc_parms cparms;
-	struct tf_shadow_tbl_db *shadow_db = NULL;
-
-	TF_CHECK_PARMS1(parms);
-
-	/* Build the shadow DB per the request */
-	cparms.nitems = 1;
-	cparms.size = sizeof(struct tf_shadow_tbl_db);
-	cparms.alignment = 0;
-	rc = tfp_calloc(&cparms);
-	if (rc)
-		return rc;
-	shadow_db = (void *)cparms.mem_va;
-
-	for (i = 0; i < TF_TBL_TYPE_MAX; i++) {
-		/* If the element didn't request an allocation no need
-		 * to create a pool nor verify if we got a reservation.
-		 */
-		if (!parms->cfg->alloc_cnt[i] ||
-		    !tf_shadow_tbl_is_searchable(i)) {
-			shadow_db->ctxt[i] = NULL;
-			continue;
-		}
-
-		cparms.nitems = 1;
-		cparms.size = sizeof(struct tf_shadow_tbl_ctxt);
-		cparms.alignment = 0;
-		rc = tfp_calloc(&cparms);
-		if (rc)
-			goto error;
-
-		shadow_db->ctxt[i] = cparms.mem_va;
-		base = parms->cfg->base_addr[i];
-		rc = tf_shadow_tbl_ctxt_create(shadow_db->ctxt[i],
-						parms->cfg->alloc_cnt[i],
-						base);
-		if (rc)
-			goto error;
-	}
-
-	*parms->shadow_db = (void *)shadow_db;
-
-	TFP_DRV_LOG(INFO,
-		    "TF SHADOW TABLE - initialized\n");
-
-	return 0;
-error:
-	for (i = 0; i < TF_TBL_TYPE_MAX; i++) {
-		if (shadow_db->ctxt[i]) {
-			tf_shadow_tbl_ctxt_delete(shadow_db->ctxt[i]);
-			tfp_free(shadow_db->ctxt[i]);
-		}
-	}
-
-	tfp_free(shadow_db);
-
-	return -ENOMEM;
-}
diff --git a/drivers/net/bnxt/tf_core/tf_shadow_tbl.h b/drivers/net/bnxt/tf_core/tf_shadow_tbl.h
deleted file mode 100644
index 354240efce..0000000000
--- a/drivers/net/bnxt/tf_core/tf_shadow_tbl.h
+++ /dev/null
@@ -1,256 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2019-2021 Broadcom
- * All rights reserved.
- */
-
-#ifndef _TF_SHADOW_TBL_H_
-#define _TF_SHADOW_TBL_H_
-
-#include "tf_core.h"
-
-/**
- * The Shadow Table module provides shadow DB handling for table based
- * TF types. A shadow DB provides the capability that allows for reuse
- * of TF resources.
- *
- * A Shadow table DB is intended to be used by the Table Type module
- * only.
- */
-
-/**
- * Shadow DB configuration information for a single table type.
- *
- * During Device initialization the HCAPI device specifics are learned
- * and as well as the RM DB creation. From that those initial steps
- * this structure can be populated.
- *
- * NOTE:
- * If used in an array of table types then such array must be ordered
- * by the TF type is represents.
- */
-struct tf_shadow_tbl_cfg_parms {
-	/**
-	 * [in] The number of elements in the alloc_cnt and base_addr
-	 * For now, it should always be equal to TF_TBL_TYPE_MAX
-	 */
-	int num_entries;
-
-	/**
-	 * [in] Resource allocation count array
-	 * This array content originates from the tf_session_resources
-	 * that is passed in on session open
-	 * Array size is TF_TBL_TYPE_MAX
-	 */
-	uint16_t *alloc_cnt;
-	/**
-	 * [in] The base index for each table
-	 */
-	uint16_t base_addr[TF_TBL_TYPE_MAX];
-};
-
-/**
- * Shadow table DB creation parameters
- */
-struct tf_shadow_tbl_create_db_parms {
-	/**
-	 * [in] Receive or transmit direction
-	 */
-	enum tf_dir dir;
-	/**
-	 * [in] Configuration information for the shadow db
-	 */
-	struct tf_shadow_tbl_cfg_parms *cfg;
-	/**
-	 * [out] Shadow table DB handle
-	 */
-	void **shadow_db;
-};
-
-/**
- * Shadow table DB free parameters
- */
-struct tf_shadow_tbl_free_db_parms {
-	/**
-	 * [in] Shadow table DB handle
-	 */
-	void *shadow_db;
-};
-
-/**
- * Shadow table search parameters
- */
-struct tf_shadow_tbl_search_parms {
-	/**
-	 * [in] Shadow table DB handle
-	 */
-	void *shadow_db;
-	/**
-	 * [in,out] The search parms from tf core
-	 */
-	struct tf_tbl_alloc_search_parms *sparms;
-	/**
-	 * [out] Reference count incremented if hit
-	 */
-	uint32_t hb_handle;
-};
-
-/**
- * Shadow Table bind index parameters
- */
-struct tf_shadow_tbl_bind_index_parms {
-	/**
-	 * [in] Shadow tcam DB handle
-	 */
-	void *shadow_db;
-	/**
-	 * [in] receive or transmit direction
-	 */
-	enum tf_dir dir;
-	/**
-	 * [in] TCAM table type
-	 */
-	enum tf_tbl_type type;
-	/**
-	 * [in] index of the entry to program
-	 */
-	uint16_t idx;
-	/**
-	 * [in] struct containing key
-	 */
-	uint8_t *data;
-	/**
-	 * [in] data size in bytes
-	 */
-	uint16_t data_sz_in_bytes;
-	/**
-	 * [in] The hash bucket handled returned from the search
-	 */
-	uint32_t hb_handle;
-};
-
-/**
- * Shadow table insert parameters
- */
-struct tf_shadow_tbl_insert_parms {
-	/**
-	 * [in] Shadow table DB handle
-	 */
-	void *shadow_db;
-	/**
-	 * [in] The insert parms from tf core
-	 */
-	struct tf_tbl_set_parms *sparms;
-};
-
-/**
- * Shadow table remove parameters
- */
-struct tf_shadow_tbl_remove_parms {
-	/**
-	 * [in] Shadow table DB handle
-	 */
-	void *shadow_db;
-	/**
-	 * [in] The free parms from tf core
-	 */
-	struct tf_tbl_free_parms *fparms;
-};
-
-/**
- * @page shadow_tbl Shadow table DB
- *
- * @ref tf_shadow_tbl_create_db
- *
- * @ref tf_shadow_tbl_free_db
- *
- * @reg tf_shadow_tbl_search
- *
- * @reg tf_shadow_tbl_insert
- *
- * @reg tf_shadow_tbl_remove
- */
-
-/**
- * Creates and fills a Shadow table DB. The DB is indexed per the
- * parms structure.
- *
- * [in] parms
- *   Pointer to create db parameters
- *
- * Returns
- *   - (0) if successful.
- *   - (-EINVAL) on failure.
- */
-int tf_shadow_tbl_create_db(struct tf_shadow_tbl_create_db_parms *parms);
-
-/**
- * Closes the Shadow table DB and frees all allocated
- * resources per the associated database.
- *
- * [in] parms
- *   Pointer to the free DB parameters
- *
- * Returns
- *   - (0) if successful.
- *   - (-EINVAL) on failure.
- */
-int tf_shadow_tbl_free_db(struct tf_shadow_tbl_free_db_parms *parms);
-
-/**
- * Search Shadow table db for matching result
- *
- * [in] parms
- *   Pointer to the search parameters
- *
- * Returns
- *   - (0) if successful, element was found.
- *   - (-EINVAL) on failure.
- *
- * If there is a miss, but there is room for insertion, the hb_handle returned
- * is used for insertion during the bind index API
- */
-int tf_shadow_tbl_search(struct tf_shadow_tbl_search_parms *parms);
-
-/**
- * Bind Shadow table db hash and result tables with result from search/alloc
- *
- * [in] parms
- *   Pointer to the search parameters
- *
- * Returns
- *   - (0) if successful
- *   - (-EINVAL) on failure.
- *
- * This is only called after a MISS in the search returns a hb_handle
- */
-int tf_shadow_tbl_bind_index(struct tf_shadow_tbl_bind_index_parms *parms);
-
-/**
- * Inserts an element into the Shadow table DB. Will fail if the
- * elements ref_count is different from 0. Ref_count after insert will
- * be incremented.
- *
- * [in] parms
- *   Pointer to insert parameters
- *
- * Returns
- *   - (0) if successful.
- *   - (-EINVAL) on failure.
- */
-int tf_shadow_tbl_insert(struct tf_shadow_tbl_insert_parms *parms);
-
-/**
- * Removes an element from the Shadow table DB. Will fail if the
- * elements ref_count is 0. Ref_count after removal will be
- * decremented.
- *
- * [in] parms
- *   Pointer to remove parameter
- *
- * Returns
- *   - (0) if successful.
- *   - (-EINVAL) on failure.
- */
-int tf_shadow_tbl_remove(struct tf_shadow_tbl_remove_parms *parms);
-
-#endif /* _TF_SHADOW_TBL_H_ */
diff --git a/drivers/net/bnxt/tf_core/tf_tbl.c b/drivers/net/bnxt/tf_core/tf_tbl.c
index 67a43311cc..7d15c3c5d4 100644
--- a/drivers/net/bnxt/tf_core/tf_tbl.c
+++ b/drivers/net/bnxt/tf_core/tf_tbl.c
@@ -13,11 +13,9 @@
 #include "tf_util.h"
 #include "tf_msg.h"
 #include "tfp.h"
-#include "tf_shadow_tbl.h"
 #include "tf_session.h"
 #include "tf_device.h"
 
-
 struct tf;
 
 /**
@@ -44,13 +42,7 @@ int
 tf_tbl_bind(struct tf *tfp,
 	    struct tf_tbl_cfg_parms *parms)
 {
-	int rc, d, i;
-	struct tf_rm_alloc_info info;
-	struct tf_rm_free_db_parms fparms;
-	struct tf_shadow_tbl_free_db_parms fshadow;
-	struct tf_rm_get_alloc_info_parms ainfo;
-	struct tf_shadow_tbl_cfg_parms shadow_cfg;
-	struct tf_shadow_tbl_create_db_parms shadow_cdb;
+	int rc, d;
 	struct tf_rm_create_db_parms db_cfg = { 0 };
 
 	TF_CHECK_PARMS2(tfp, parms);
@@ -62,7 +54,7 @@ tf_tbl_bind(struct tf *tfp,
 	}
 
 	db_cfg.num_elements = parms->num_elements;
-	db_cfg.type = TF_DEVICE_MODULE_TYPE_TABLE;
+	db_cfg.module = TF_MODULE_TYPE_TABLE;
 	db_cfg.num_elements = parms->num_elements;
 	db_cfg.cfg = parms->cfg;
 
@@ -80,72 +72,12 @@ tf_tbl_bind(struct tf *tfp,
 		}
 	}
 
-	/* Initialize the Shadow Table. */
-	if (parms->shadow_copy) {
-		for (d = 0; d < TF_DIR_MAX; d++) {
-			memset(&shadow_cfg, 0, sizeof(shadow_cfg));
-			memset(&shadow_cdb, 0, sizeof(shadow_cdb));
-			/* Get the base addresses of the tables */
-			for (i = 0; i < TF_TBL_TYPE_MAX; i++) {
-				memset(&info, 0, sizeof(info));
-
-				if (!parms->resources->tbl_cnt[d].cnt[i])
-					continue;
-				ainfo.rm_db = tbl_db[d];
-				ainfo.db_index = i;
-				ainfo.info = &info;
-				rc = tf_rm_get_info(&ainfo);
-				if (rc)
-					goto error;
-
-				shadow_cfg.base_addr[i] = info.entry.start;
-			}
-
-			/* Create the shadow db */
-			shadow_cfg.alloc_cnt =
-				parms->resources->tbl_cnt[d].cnt;
-			shadow_cfg.num_entries = parms->num_elements;
-
-			shadow_cdb.shadow_db = &shadow_tbl_db[d];
-			shadow_cdb.cfg = &shadow_cfg;
-			rc = tf_shadow_tbl_create_db(&shadow_cdb);
-			if (rc) {
-				TFP_DRV_LOG(ERR,
-					    "Shadow TBL DB creation failed "
-					    "rc=%d\n", rc);
-				goto error;
-			}
-		}
-		shadow_init = 1;
-	}
-
 	init = 1;
 
 	TFP_DRV_LOG(INFO,
 		    "Table Type - initialized\n");
 
 	return 0;
-error:
-	for (d = 0; d < TF_DIR_MAX; d++) {
-		memset(&fparms, 0, sizeof(fparms));
-		fparms.dir = d;
-		fparms.rm_db = tbl_db[d];
-		/* Ignoring return here since we are in the error case */
-		(void)tf_rm_free_db(tfp, &fparms);
-
-		if (parms->shadow_copy) {
-			fshadow.shadow_db = shadow_tbl_db[d];
-			tf_shadow_tbl_free_db(&fshadow);
-			shadow_tbl_db[d] = NULL;
-		}
-
-		tbl_db[d] = NULL;
-	}
-
-	shadow_init = 0;
-	init = 0;
-
-	return rc;
 }
 
 int
@@ -154,8 +86,6 @@ tf_tbl_unbind(struct tf *tfp)
 	int rc;
 	int i;
 	struct tf_rm_free_db_parms fparms = { 0 };
-	struct tf_shadow_tbl_free_db_parms fshadow;
-
 	TF_CHECK_PARMS1(tfp);
 
 	/* Bail if nothing has been initialized */
@@ -173,13 +103,6 @@ tf_tbl_unbind(struct tf *tfp)
 			return rc;
 
 		tbl_db[i] = NULL;
-
-		if (shadow_init) {
-			memset(&fshadow, 0, sizeof(fshadow));
-			fshadow.shadow_db = shadow_tbl_db[i];
-			tf_shadow_tbl_free_db(&fshadow);
-			shadow_tbl_db[i] = NULL;
-		}
 	}
 
 	init = 0;
@@ -207,7 +130,7 @@ tf_tbl_alloc(struct tf *tfp __rte_unused,
 
 	/* Allocate requested element */
 	aparms.rm_db = tbl_db[parms->dir];
-	aparms.db_index = parms->type;
+	aparms.subtype = parms->type;
 	aparms.index = &idx;
 	rc = tf_rm_allocate(&aparms);
 	if (rc) {
@@ -230,7 +153,6 @@ tf_tbl_free(struct tf *tfp __rte_unused,
 	int rc;
 	struct tf_rm_is_allocated_parms aparms = { 0 };
 	struct tf_rm_free_parms fparms = { 0 };
-	struct tf_shadow_tbl_remove_parms shparms;
 	int allocated = 0;
 
 	TF_CHECK_PARMS2(tfp, parms);
@@ -244,7 +166,7 @@ tf_tbl_free(struct tf *tfp __rte_unused,
 
 	/* Check if element is in use */
 	aparms.rm_db = tbl_db[parms->dir];
-	aparms.db_index = parms->type;
+	aparms.subtype = parms->type;
 	aparms.index = parms->idx;
 	aparms.allocated = &allocated;
 	rc = tf_rm_is_allocated(&aparms);
@@ -259,40 +181,9 @@ tf_tbl_free(struct tf *tfp __rte_unused,
 			    parms->idx);
 		return -EINVAL;
 	}
-
-	/*
-	 * The Shadow mgmt, if enabled, determines if the entry needs
-	 * to be deleted.
-	 */
-	if (shadow_init) {
-		memset(&shparms, 0, sizeof(shparms));
-		shparms.shadow_db = shadow_tbl_db[parms->dir];
-		shparms.fparms = parms;
-		rc = tf_shadow_tbl_remove(&shparms);
-		if (rc) {
-			/*
-			 * Should not get here, log it and let the entry be
-			 * deleted.
-			 */
-			TFP_DRV_LOG(ERR, "%s: Shadow free fail, "
-				    "type:%d index:%d deleting the entry.\n",
-				    tf_dir_2_str(parms->dir),
-				    parms->type,
-				    parms->idx);
-		} else {
-			/*
-			 * If the entry still has references, just return the
-			 * ref count to the caller.  No need to remove entry
-			 * from rm.
-			 */
-			if (parms->ref_cnt >= 1)
-				return rc;
-		}
-	}
-
 	/* Free requested element */
 	fparms.rm_db = tbl_db[parms->dir];
-	fparms.db_index = parms->type;
+	fparms.subtype = parms->type;
 	fparms.index = parms->idx;
 	rc = tf_rm_free(&fparms);
 	if (rc) {
@@ -311,15 +202,7 @@ int
 tf_tbl_alloc_search(struct tf *tfp,
 		    struct tf_tbl_alloc_search_parms *parms)
 {
-	int rc, frc;
-	uint32_t idx;
-	struct tf_session *tfs;
-	struct tf_dev_info *dev;
-	struct tf_tbl_alloc_parms aparms;
-	struct tf_shadow_tbl_search_parms sparms;
-	struct tf_shadow_tbl_bind_index_parms bparms;
-	struct tf_tbl_free_parms fparms;
-
+	int rc = 0;
 	TF_CHECK_PARMS2(tfp, parms);
 
 	if (!shadow_init || !shadow_tbl_db[parms->dir]) {
@@ -328,103 +211,6 @@ tf_tbl_alloc_search(struct tf *tfp,
 		return -EINVAL;
 	}
 
-	memset(&sparms, 0, sizeof(sparms));
-	sparms.sparms = parms;
-	sparms.shadow_db = shadow_tbl_db[parms->dir];
-	rc = tf_shadow_tbl_search(&sparms);
-	if (rc)
-		return rc;
-
-	/*
-	 * The app didn't request us to alloc the entry, so return now.
-	 * The hit should have been updated in the original search parm.
-	 */
-	if (!parms->alloc || parms->search_status != MISS)
-		return rc;
-
-	/* Retrieve the session information */
-	rc = tf_session_get_session(tfp, &tfs);
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "%s: Failed to lookup session, rc:%s\n",
-			    tf_dir_2_str(parms->dir),
-			    strerror(-rc));
-		return rc;
-	}
-
-	/* Retrieve the device information */
-	rc = tf_session_get_device(tfs, &dev);
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "%s: Failed to lookup device, rc:%s\n",
-			    tf_dir_2_str(parms->dir),
-			    strerror(-rc));
-		return rc;
-	}
-
-	/* Allocate the index */
-	if (dev->ops->tf_dev_alloc_tbl == NULL) {
-		rc = -EOPNOTSUPP;
-		TFP_DRV_LOG(ERR,
-			    "%s: Operation not supported, rc:%s\n",
-			    tf_dir_2_str(parms->dir),
-			    strerror(-rc));
-		return -EOPNOTSUPP;
-	}
-
-	memset(&aparms, 0, sizeof(aparms));
-	aparms.dir = parms->dir;
-	aparms.type = parms->type;
-	aparms.tbl_scope_id = parms->tbl_scope_id;
-	aparms.idx = &idx;
-	rc = dev->ops->tf_dev_alloc_tbl(tfp, &aparms);
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "%s: Table allocation failed, rc:%s\n",
-			    tf_dir_2_str(parms->dir),
-			    strerror(-rc));
-		return rc;
-	}
-
-	/* Bind the allocated index to the data */
-	memset(&bparms, 0, sizeof(bparms));
-	bparms.shadow_db = shadow_tbl_db[parms->dir];
-	bparms.dir = parms->dir;
-	bparms.type = parms->type;
-	bparms.idx = idx;
-	bparms.data = parms->result;
-	bparms.data_sz_in_bytes = parms->result_sz_in_bytes;
-	bparms.hb_handle = sparms.hb_handle;
-	rc = tf_shadow_tbl_bind_index(&bparms);
-	if (rc) {
-		/* Error binding entry, need to free the allocated idx */
-		if (dev->ops->tf_dev_free_tbl == NULL) {
-			rc = -EOPNOTSUPP;
-			TFP_DRV_LOG(ERR,
-				    "%s: Operation not supported, rc:%s\n",
-				    tf_dir_2_str(parms->dir),
-				    strerror(-rc));
-			return rc;
-		}
-
-		memset(&fparms, 0, sizeof(fparms));
-		fparms.dir = parms->dir;
-		fparms.type = parms->type;
-		fparms.idx = idx;
-		frc = dev->ops->tf_dev_free_tbl(tfp, &fparms);
-		if (frc) {
-			TFP_DRV_LOG(ERR,
-				    "%s: Failed free index allocated during "
-				    "search. rc=%s\n",
-				    tf_dir_2_str(parms->dir),
-				    strerror(-frc));
-			/* return the original failure. */
-			return rc;
-		}
-	}
-
-	parms->idx = idx;
-
 	return rc;
 }
 
@@ -449,7 +235,7 @@ tf_tbl_set(struct tf *tfp,
 
 	/* Verify that the entry has been previously allocated */
 	aparms.rm_db = tbl_db[parms->dir];
-	aparms.db_index = parms->type;
+	aparms.subtype = parms->type;
 	aparms.index = parms->idx;
 	aparms.allocated = &allocated;
 	rc = tf_rm_is_allocated(&aparms);
@@ -467,7 +253,7 @@ tf_tbl_set(struct tf *tfp,
 
 	/* Set the entry */
 	hparms.rm_db = tbl_db[parms->dir];
-	hparms.db_index = parms->type;
+	hparms.subtype = parms->type;
 	hparms.hcapi_type = &hcapi_type;
 	rc = tf_rm_get_hcapi_type(&hparms);
 	if (rc) {
@@ -518,7 +304,7 @@ tf_tbl_get(struct tf *tfp,
 
 	/* Verify that the entry has been previously allocated */
 	aparms.rm_db = tbl_db[parms->dir];
-	aparms.db_index = parms->type;
+	aparms.subtype = parms->type;
 	aparms.index = parms->idx;
 	aparms.allocated = &allocated;
 	rc = tf_rm_is_allocated(&aparms);
@@ -536,7 +322,7 @@ tf_tbl_get(struct tf *tfp,
 
 	/* Set the entry */
 	hparms.rm_db = tbl_db[parms->dir];
-	hparms.db_index = parms->type;
+	hparms.subtype = parms->type;
 	hparms.hcapi_type = &hcapi_type;
 	rc = tf_rm_get_hcapi_type(&hparms);
 	if (rc) {
@@ -588,7 +374,7 @@ tf_tbl_bulk_get(struct tf *tfp,
 
 	/* Verify that the entries are in the range of reserved resources. */
 	cparms.rm_db = tbl_db[parms->dir];
-	cparms.db_index = parms->type;
+	cparms.subtype = parms->type;
 	cparms.starting_index = parms->starting_idx;
 	cparms.num_entries = parms->num_entries;
 
@@ -605,7 +391,7 @@ tf_tbl_bulk_get(struct tf *tfp,
 	}
 
 	hparms.rm_db = tbl_db[parms->dir];
-	hparms.db_index = parms->type;
+	hparms.subtype = parms->type;
 	hparms.hcapi_type = &hcapi_type;
 	rc = tf_rm_get_hcapi_type(&hparms);
 	if (rc) {
diff --git a/drivers/net/bnxt/tf_core/tf_tcam.c b/drivers/net/bnxt/tf_core/tf_tcam.c
index a18d0e1e19..42d503f500 100644
--- a/drivers/net/bnxt/tf_core/tf_tcam.c
+++ b/drivers/net/bnxt/tf_core/tf_tcam.c
@@ -71,7 +71,7 @@ tf_tcam_bind(struct tf *tfp,
 
 	memset(&db_cfg, 0, sizeof(db_cfg));
 
-	db_cfg.type = TF_DEVICE_MODULE_TYPE_TCAM;
+	db_cfg.module = TF_MODULE_TYPE_TCAM;
 	db_cfg.num_elements = parms->num_elements;
 	db_cfg.cfg = parms->cfg;
 
@@ -100,7 +100,7 @@ tf_tcam_bind(struct tf *tfp,
 				if (!parms->resources->tcam_cnt[d].cnt[i])
 					continue;
 				ainfo.rm_db = tcam_db[d];
-				ainfo.db_index = i;
+				ainfo.subtype = i;
 				ainfo.info = &info;
 				rc = tf_rm_get_info(&ainfo);
 				if (rc)
@@ -248,7 +248,7 @@ tf_tcam_alloc(struct tf *tfp,
 	memset(&aparms, 0, sizeof(aparms));
 
 	aparms.rm_db = tcam_db[parms->dir];
-	aparms.db_index = parms->type;
+	aparms.subtype = parms->type;
 	aparms.priority = parms->priority;
 	aparms.index = (uint32_t *)&parms->idx;
 	rc = tf_rm_allocate(&aparms);
@@ -331,7 +331,7 @@ tf_tcam_free(struct tf *tfp,
 	memset(&aparms, 0, sizeof(aparms));
 
 	aparms.rm_db = tcam_db[parms->dir];
-	aparms.db_index = parms->type;
+	aparms.subtype = parms->type;
 	aparms.index = parms->idx / num_slice_per_row;
 	aparms.allocated = &allocated;
 	rc = tf_rm_is_allocated(&aparms);
@@ -379,7 +379,7 @@ tf_tcam_free(struct tf *tfp,
 	/* Free requested element */
 	memset(&fparms, 0, sizeof(fparms));
 	fparms.rm_db = tcam_db[parms->dir];
-	fparms.db_index = parms->type;
+	fparms.subtype = parms->type;
 	fparms.index = parms->idx / num_slice_per_row;
 	rc = tf_rm_free(&fparms);
 	if (rc) {
@@ -421,7 +421,7 @@ tf_tcam_free(struct tf *tfp,
 	memset(&hparms, 0, sizeof(hparms));
 
 	hparms.rm_db = tcam_db[parms->dir];
-	hparms.db_index = parms->type;
+	hparms.subtype = parms->type;
 	hparms.hcapi_type = &parms->hcapi_type;
 
 	rc = tf_rm_get_hcapi_type(&hparms);
@@ -625,7 +625,7 @@ tf_tcam_set(struct tf *tfp __rte_unused,
 	memset(&aparms, 0, sizeof(aparms));
 
 	aparms.rm_db = tcam_db[parms->dir];
-	aparms.db_index = parms->type;
+	aparms.subtype = parms->type;
 	aparms.index = parms->idx / num_slice_per_row;
 	aparms.allocated = &allocated;
 	rc = tf_rm_is_allocated(&aparms);
@@ -645,7 +645,7 @@ tf_tcam_set(struct tf *tfp __rte_unused,
 	memset(&hparms, 0, sizeof(hparms));
 
 	hparms.rm_db = tcam_db[parms->dir];
-	hparms.db_index = parms->type;
+	hparms.subtype = parms->type;
 	hparms.hcapi_type = &parms->hcapi_type;
 
 	rc = tf_rm_get_hcapi_type(&hparms);
@@ -736,7 +736,7 @@ tf_tcam_get(struct tf *tfp __rte_unused,
 	memset(&aparms, 0, sizeof(aparms));
 
 	aparms.rm_db = tcam_db[parms->dir];
-	aparms.db_index = parms->type;
+	aparms.subtype = parms->type;
 	aparms.index = parms->idx / num_slice_per_row;
 	aparms.allocated = &allocated;
 	rc = tf_rm_is_allocated(&aparms);
@@ -756,7 +756,7 @@ tf_tcam_get(struct tf *tfp __rte_unused,
 	memset(&hparms, 0, sizeof(hparms));
 
 	hparms.rm_db = tcam_db[parms->dir];
-	hparms.db_index = parms->type;
+	hparms.subtype = parms->type;
 	hparms.hcapi_type = &parms->hcapi_type;
 
 	rc = tf_rm_get_hcapi_type(&hparms);
diff --git a/drivers/net/bnxt/tf_core/tf_util.c b/drivers/net/bnxt/tf_core/tf_util.c
index 74c8f26204..b4d47d5a8c 100644
--- a/drivers/net/bnxt/tf_core/tf_util.c
+++ b/drivers/net/bnxt/tf_core/tf_util.c
@@ -137,34 +137,34 @@ tf_em_tbl_type_2_str(enum tf_em_tbl_type em_type)
 }
 
 const char *
-tf_device_module_type_subtype_2_str(enum tf_device_module_type dm_type,
-				    uint16_t mod_type)
+tf_module_subtype_2_str(enum tf_module_type module,
+			uint16_t subtype)
 {
-	switch (dm_type) {
-	case TF_DEVICE_MODULE_TYPE_IDENTIFIER:
-		return tf_ident_2_str(mod_type);
-	case TF_DEVICE_MODULE_TYPE_TABLE:
-		return tf_tbl_type_2_str(mod_type);
-	case TF_DEVICE_MODULE_TYPE_TCAM:
-		return tf_tcam_tbl_2_str(mod_type);
-	case TF_DEVICE_MODULE_TYPE_EM:
-		return tf_em_tbl_type_2_str(mod_type);
+	switch (module) {
+	case TF_MODULE_TYPE_IDENTIFIER:
+		return tf_ident_2_str(subtype);
+	case TF_MODULE_TYPE_TABLE:
+		return tf_tbl_type_2_str(subtype);
+	case TF_MODULE_TYPE_TCAM:
+		return tf_tcam_tbl_2_str(subtype);
+	case TF_MODULE_TYPE_EM:
+		return tf_em_tbl_type_2_str(subtype);
 	default:
-		return "Invalid Device Module type";
+		return "Invalid Module type";
 	}
 }
 
 const char *
-tf_device_module_type_2_str(enum tf_device_module_type dm_type)
+tf_module_2_str(enum tf_module_type module)
 {
-	switch (dm_type) {
-	case TF_DEVICE_MODULE_TYPE_IDENTIFIER:
+	switch (module) {
+	case TF_MODULE_TYPE_IDENTIFIER:
 		return "Identifier";
-	case TF_DEVICE_MODULE_TYPE_TABLE:
+	case TF_MODULE_TYPE_TABLE:
 		return "Table";
-	case TF_DEVICE_MODULE_TYPE_TCAM:
+	case TF_MODULE_TYPE_TCAM:
 		return "TCAM";
-	case TF_DEVICE_MODULE_TYPE_EM:
+	case TF_MODULE_TYPE_EM:
 		return "EM";
 	default:
 		return "Invalid Device Module type";
diff --git a/drivers/net/bnxt/tf_core/tf_util.h b/drivers/net/bnxt/tf_core/tf_util.h
index 4225c756f6..1aa35b6b82 100644
--- a/drivers/net/bnxt/tf_core/tf_util.h
+++ b/drivers/net/bnxt/tf_core/tf_util.h
@@ -65,34 +65,30 @@ const char *tf_tbl_type_2_str(enum tf_tbl_type tbl_type);
 const char *tf_em_tbl_type_2_str(enum tf_em_tbl_type em_type);
 
 /**
- * Helper function converting device module type and module type to
+ * Helper function converting module and submodule type to
  * text string.
  *
- * [in] dm_type
- *   Device Module type
+ * [in] module
+ *   Module type
  *
- * [in] mod_type
- *   Module specific type
+ * [in] submodule
+ *   Module specific subtype
  *
  * Returns:
  *   Pointer to a char string holding the string for the EM type
  */
-const char *tf_device_module_type_subtype_2_str
-					(enum tf_device_module_type dm_type,
-					 uint16_t mod_type);
+const char *tf_module_subtype_2_str(enum tf_module_type module,
+				    uint16_t subtype);
 
 /**
- * Helper function converting device module type to text string
+ * Helper function converting module type to text string
  *
- * [in] dm_type
- *   Device Module type
- *
- * [in] mod_type
- *   Module specific type
+ * [in] module
+ *   Module type
  *
  * Returns:
  *   Pointer to a char string holding the string for the EM type
  */
-const char *tf_device_module_type_2_str(enum tf_device_module_type dm_type);
+const char *tf_module_2_str(enum tf_module_type module);
 
 #endif /* _TF_UTIL_H_ */
-- 
2.17.1


^ permalink raw reply	[flat|nested] 129+ messages in thread

* [dpdk-dev] [PATCH 09/58] net/bnxt: add Thor WC TCAM support
  2021-05-30  8:58 [dpdk-dev] [PATCH 00/58] enhancements to host based flow table management Venkat Duvvuru
                   ` (7 preceding siblings ...)
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 08/58] net/bnxt: add action SRAM Translation Venkat Duvvuru
@ 2021-05-30  8:58 ` Venkat Duvvuru
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 10/58] net/bnxt: add 64B SRAM record management with RM Venkat Duvvuru
                   ` (49 subsequent siblings)
  58 siblings, 0 replies; 129+ messages in thread
From: Venkat Duvvuru @ 2021-05-30  8:58 UTC (permalink / raw)
  To: dev; +Cc: Jay Ding, Randy Schacher, Venkat Duvvuru

From: Jay Ding <jay.ding@broadcom.com>

1. Add set/get/free/alloc for WC TCAM
2. Rework the key size in slice management.
3. Add 3 FKB WC keys for WC TCAM set cli cmd
4. Add transform key function for WC TCAM FKB key
5. Add checking for key buffer length for get_tcam

Signed-off-by: Jay Ding <jay.ding@broadcom.com>
Signed-off-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Farah Smith <farah.smith@broadcom.com>
---
 drivers/net/bnxt/tf_core/tf_core.c       |   2 +
 drivers/net/bnxt/tf_core/tf_core.h       |   5 +-
 drivers/net/bnxt/tf_core/tf_device_p4.c  |   2 -
 drivers/net/bnxt/tf_core/tf_device_p58.c |   7 +-
 drivers/net/bnxt/tf_core/tf_device_p58.h |   3 +
 drivers/net/bnxt/tf_core/tf_msg.c        |  31 ++--
 drivers/net/bnxt/tf_core/tf_tcam.c       | 192 ++++++++++++-----------
 7 files changed, 132 insertions(+), 110 deletions(-)

diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c
index a3b6afbc88..573fa0b1ed 100644
--- a/drivers/net/bnxt/tf_core/tf_core.c
+++ b/drivers/net/bnxt/tf_core/tf_core.c
@@ -842,8 +842,10 @@ tf_get_tcam_entry(struct tf *tfp __rte_unused,
 	gparms.type = parms->tcam_tbl_type;
 	gparms.idx = parms->idx;
 	gparms.key = parms->key;
+	gparms.key_size = dev->ops->tf_dev_word_align(parms->key_sz_in_bits);
 	gparms.mask = parms->mask;
 	gparms.result = parms->result;
+	gparms.result_size = TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
 
 	rc = dev->ops->tf_dev_get_tcam(tfp, &gparms);
 	if (rc) {
diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h
index 0cc3719a1b..fcba492dc5 100644
--- a/drivers/net/bnxt/tf_core/tf_core.h
+++ b/drivers/net/bnxt/tf_core/tf_core.h
@@ -1286,7 +1286,7 @@ struct tf_get_tcam_entry_parms {
 	 */
 	uint8_t *mask;
 	/**
-	 * [out] key size in bits
+	 * [in/out] key size in bits
 	 */
 	uint16_t key_sz_in_bits;
 	/**
@@ -1294,7 +1294,7 @@ struct tf_get_tcam_entry_parms {
 	 */
 	uint8_t *result;
 	/**
-	 * [out] struct containing result size in bits
+	 * [in/out] struct containing result size in bits
 	 */
 	uint16_t result_sz_in_bits;
 };
@@ -1961,6 +1961,7 @@ enum tf_tunnel_encap_offsets {
 enum tf_global_config_type {
 	TF_TUNNEL_ENCAP,  /**< Tunnel Encap Config(TECT) */
 	TF_ACTION_BLOCK,  /**< Action Block Config(ABCR) */
+	TF_COUNTER_CFG,   /**< Counter Configuration (CNTRS_CTRL) */
 	TF_GLOBAL_CFG_TYPE_MAX
 };
 
diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.c b/drivers/net/bnxt/tf_core/tf_device_p4.c
index d0bede89e3..e5aaaac9a0 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p4.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p4.c
@@ -144,8 +144,6 @@ tf_dev_p4_get_tcam_slice_info(struct tf *tfp __rte_unused,
 		*num_slices_per_row = CFA_P4_WC_TCAM_SLICES_PER_ROW;
 		if (key_sz > *num_slices_per_row * CFA_P4_WC_TCAM_SLICE_SIZE)
 			return -ENOTSUP;
-
-		*num_slices_per_row = 1;
 	} else { /* for other type of tcam */
 		*num_slices_per_row = 1;
 	}
diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c
index 50a8d82074..65e283ed11 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p58.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p58.c
@@ -123,15 +123,14 @@ tf_dev_p58_get_tcam_slice_info(struct tf *tfp __rte_unused,
 			      uint16_t key_sz,
 			      uint16_t *num_slices_per_row)
 {
-#define CFA_P58_WC_TCAM_SLICES_PER_ROW 2
-#define CFA_P58_WC_TCAM_SLICE_SIZE     12
+#define CFA_P58_WC_TCAM_SLICES_PER_ROW 1
+#define CFA_P58_WC_TCAM_SLICE_SIZE     24
 
 	if (type == TF_TCAM_TBL_TYPE_WC_TCAM) {
+		/* only support single slice key size now */
 		*num_slices_per_row = CFA_P58_WC_TCAM_SLICES_PER_ROW;
 		if (key_sz > *num_slices_per_row * CFA_P58_WC_TCAM_SLICE_SIZE)
 			return -ENOTSUP;
-
-		*num_slices_per_row = 1;
 	} else { /* for other type of tcam */
 		*num_slices_per_row = 1;
 	}
diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.h b/drivers/net/bnxt/tf_core/tf_device_p58.h
index abd916985e..07f022769b 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p58.h
+++ b/drivers/net/bnxt/tf_core/tf_device_p58.h
@@ -189,5 +189,8 @@ struct tf_global_cfg_cfg tf_global_cfg_p58[TF_GLOBAL_CFG_TYPE_MAX] = {
 	[TF_ACTION_BLOCK] = {
 		TF_GLOBAL_CFG_CFG_HCAPI, TF_ACTION_BLOCK
 	},
+	[TF_COUNTER_CFG] = {
+		TF_GLOBAL_CFG_CFG_HCAPI, TF_COUNTER_CFG
+	},
 };
 #endif /* _TF_DEVICE_P58_H_ */
diff --git a/drivers/net/bnxt/tf_core/tf_msg.c b/drivers/net/bnxt/tf_core/tf_msg.c
index 1af5c6d11c..ec4c7890c3 100644
--- a/drivers/net/bnxt/tf_core/tf_msg.c
+++ b/drivers/net/bnxt/tf_core/tf_msg.c
@@ -39,19 +39,8 @@
  * array size (define above) should be checked and compared.
  */
 #define TF_MSG_SIZE_HWRM_TF_GLOBAL_CFG_SET 56
-static_assert(sizeof(struct hwrm_tf_global_cfg_set_input) ==
-	      TF_MSG_SIZE_HWRM_TF_GLOBAL_CFG_SET,
-	      "HWRM message size changed: hwrm_tf_global_cfg_set_input");
-
 #define TF_MSG_SIZE_HWRM_TF_EM_INSERT      104
-static_assert(sizeof(struct hwrm_tf_em_insert_input) ==
-	      TF_MSG_SIZE_HWRM_TF_EM_INSERT,
-	      "HWRM message size changed: hwrm_tf_em_insert_input");
-
 #define TF_MSG_SIZE_HWRM_TF_TBL_TYPE_SET   128
-static_assert(sizeof(struct hwrm_tf_tbl_type_set_input) ==
-	      TF_MSG_SIZE_HWRM_TF_TBL_TYPE_SET,
-	      "HWRM message size changed: hwrm_tf_tbl_type_set_input");
 
 /**
  * This is the MAX data we can transport across regular HWRM
@@ -630,6 +619,9 @@ tf_msg_insert_em_internal_entry(struct tf *tfp,
 	struct tf_dev_info *dev;
 	struct tf_session *tfs;
 
+	RTE_BUILD_BUG_ON(sizeof(struct hwrm_tf_em_insert_input) !=
+			 TF_MSG_SIZE_HWRM_TF_EM_INSERT);
+
 	/* Retrieve the session information */
 	rc = tf_session_get_session_internal(tfp, &tfs);
 	if (rc) {
@@ -1255,6 +1247,17 @@ tf_msg_tcam_entry_get(struct tf *tfp,
 	if (mparms.tf_resp_code != 0)
 		return tfp_le_to_cpu_32(mparms.tf_resp_code);
 
+	if (parms->key_size < resp.key_size ||
+	    parms->result_size < resp.result_size) {
+		rc = -EINVAL;
+		TFP_DRV_LOG(ERR,
+			    "%s: Key buffer(%d) is smaller than the key(%d), rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    parms->key_size,
+			    resp.key_size,
+			    strerror(-rc));
+		return rc;
+	}
 	parms->key_size = resp.key_size;
 	parms->result_size = resp.result_size;
 	tfp_memcpy(parms->key, resp.dev_data, resp.key_size);
@@ -1320,6 +1323,9 @@ tf_msg_set_tbl_entry(struct tf *tfp,
 	struct tf_dev_info *dev;
 	struct tf_session *tfs;
 
+	RTE_BUILD_BUG_ON(sizeof(struct hwrm_tf_tbl_type_set_input) !=
+			 TF_MSG_SIZE_HWRM_TF_TBL_TYPE_SET);
+
 	/* Retrieve the session information */
 	rc = tf_session_get_session_internal(tfp, &tfs);
 	if (rc) {
@@ -1554,6 +1560,9 @@ tf_msg_set_global_cfg(struct tf *tfp,
 	struct tf_dev_info *dev;
 	struct tf_session *tfs;
 
+	RTE_BUILD_BUG_ON(sizeof(struct hwrm_tf_global_cfg_set_input) !=
+			 TF_MSG_SIZE_HWRM_TF_GLOBAL_CFG_SET);
+
 	/* Retrieve the session information */
 	rc = tf_session_get_session_internal(tfp, &tfs);
 	if (rc) {
diff --git a/drivers/net/bnxt/tf_core/tf_tcam.c b/drivers/net/bnxt/tf_core/tf_tcam.c
index 42d503f500..1b5c29815d 100644
--- a/drivers/net/bnxt/tf_core/tf_tcam.c
+++ b/drivers/net/bnxt/tf_core/tf_tcam.c
@@ -48,10 +48,13 @@ tf_tcam_bind(struct tf *tfp,
 	struct tf_rm_free_db_parms fparms;
 	struct tf_rm_create_db_parms db_cfg;
 	struct tf_tcam_resources *tcam_cnt;
-	struct tf_shadow_tcam_free_db_parms fshadow;
 	struct tf_rm_get_alloc_info_parms ainfo;
+	struct tf_shadow_tcam_free_db_parms fshadow;
 	struct tf_shadow_tcam_cfg_parms shadow_cfg;
 	struct tf_shadow_tcam_create_db_parms shadow_cdb;
+	uint16_t num_slices = 1;
+	struct tf_session *tfs;
+	struct tf_dev_info *dev;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -61,11 +64,37 @@ tf_tcam_bind(struct tf *tfp,
 		return -EINVAL;
 	}
 
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc)
+		return rc;
+
+	if (dev->ops->tf_dev_get_tcam_slice_info == NULL) {
+		rc = -EOPNOTSUPP;
+		TFP_DRV_LOG(ERR,
+			    "Operation not supported, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+
+	rc = dev->ops->tf_dev_get_tcam_slice_info(tfp,
+						  TF_TCAM_TBL_TYPE_WC_TCAM,
+						  0,
+						  &num_slices);
+	if (rc)
+		return rc;
+
 	tcam_cnt = parms->resources->tcam_cnt;
-	if ((tcam_cnt[TF_DIR_RX].cnt[TF_TCAM_TBL_TYPE_WC_TCAM] % 2) ||
-	    (tcam_cnt[TF_DIR_TX].cnt[TF_TCAM_TBL_TYPE_WC_TCAM] % 2)) {
+	if ((tcam_cnt[TF_DIR_RX].cnt[TF_TCAM_TBL_TYPE_WC_TCAM] % num_slices) ||
+	    (tcam_cnt[TF_DIR_TX].cnt[TF_TCAM_TBL_TYPE_WC_TCAM] % num_slices)) {
 		TFP_DRV_LOG(ERR,
-			    "Number of WC TCAM entries cannot be odd num\n");
+			    "Requested num of WC TCAM entries has to be multiple %d\n",
+			    num_slices);
 		return -EINVAL;
 	}
 
@@ -88,6 +117,26 @@ tf_tcam_bind(struct tf *tfp,
 		}
 	}
 
+	/* check if reserved resource for WC is multiple of num_slices */
+	for (d = 0; d < TF_DIR_MAX; d++) {
+		memset(&info, 0, sizeof(info));
+		ainfo.rm_db = tcam_db[d];
+		ainfo.subtype = TF_TCAM_TBL_TYPE_WC_TCAM;
+		ainfo.info = &info;
+		rc = tf_rm_get_info(&ainfo);
+		if (rc)
+			goto error;
+
+		if (info.entry.start % num_slices != 0 ||
+		    info.entry.stride % num_slices != 0) {
+			TFP_DRV_LOG(ERR,
+				    "%s: TCAM reserved resource is not multiple of %d\n",
+				    tf_dir_2_str(d),
+				    num_slices);
+			return -EINVAL;
+		}
+	}
+
 	/* Initialize the TCAM manager. */
 	if (parms->shadow_copy) {
 		for (d = 0; d < TF_DIR_MAX; d++) {
@@ -163,7 +212,6 @@ tf_tcam_unbind(struct tf *tfp)
 	int i;
 	struct tf_rm_free_db_parms fparms;
 	struct tf_shadow_tcam_free_db_parms fshadow;
-
 	TF_CHECK_PARMS1(tfp);
 
 	/* Bail if nothing has been initialized */
@@ -202,11 +250,12 @@ int
 tf_tcam_alloc(struct tf *tfp,
 	      struct tf_tcam_alloc_parms *parms)
 {
-	int rc;
+	int rc, i;
 	struct tf_session *tfs;
 	struct tf_dev_info *dev;
 	struct tf_rm_allocate_parms aparms;
-	uint16_t num_slice_per_row = 1;
+	uint16_t num_slices = 1;
+	uint32_t index;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -236,32 +285,24 @@ tf_tcam_alloc(struct tf *tfp,
 		return rc;
 	}
 
-	/* Need to retrieve row size etc */
+	/* Need to retrieve number of slices based on the key_size */
 	rc = dev->ops->tf_dev_get_tcam_slice_info(tfp,
 						  parms->type,
 						  parms->key_size,
-						  &num_slice_per_row);
+						  &num_slices);
 	if (rc)
 		return rc;
 
-	/* Allocate requested element */
-	memset(&aparms, 0, sizeof(aparms));
-
-	aparms.rm_db = tcam_db[parms->dir];
-	aparms.subtype = parms->type;
-	aparms.priority = parms->priority;
-	aparms.index = (uint32_t *)&parms->idx;
-	rc = tf_rm_allocate(&aparms);
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "%s: Failed tcam, type:%d\n",
-			    tf_dir_2_str(parms->dir),
-			    parms->type);
-		return rc;
-	}
-
-	if (parms->type == TF_TCAM_TBL_TYPE_WC_TCAM &&
-	    (parms->idx % 2) != 0) {
+	/*
+	 * For WC TCAM, number of slices could be 4, 2, 1 based on
+	 * the key_size. For other TCAM, it is always 1
+	 */
+	for (i = 0; i < num_slices; i++) {
+		memset(&aparms, 0, sizeof(aparms));
+		aparms.rm_db = tcam_db[parms->dir];
+		aparms.subtype = parms->type;
+		aparms.priority = parms->priority;
+		aparms.index = &index;
 		rc = tf_rm_allocate(&aparms);
 		if (rc) {
 			TFP_DRV_LOG(ERR,
@@ -270,9 +311,11 @@ tf_tcam_alloc(struct tf *tfp,
 				    parms->type);
 			return rc;
 		}
-	}
 
-	parms->idx *= num_slice_per_row;
+		/* return the start index of each row */
+		if (i == 0)
+			parms->idx = index;
+	}
 
 	return 0;
 }
@@ -287,9 +330,10 @@ tf_tcam_free(struct tf *tfp,
 	struct tf_rm_is_allocated_parms aparms;
 	struct tf_rm_free_parms fparms;
 	struct tf_rm_get_hcapi_parms hparms;
-	uint16_t num_slice_per_row = 1;
+	uint16_t num_slices = 1;
 	int allocated = 0;
 	struct tf_shadow_tcam_remove_parms shparms;
+	int i;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -323,16 +367,24 @@ tf_tcam_free(struct tf *tfp,
 	rc = dev->ops->tf_dev_get_tcam_slice_info(tfp,
 						  parms->type,
 						  0,
-						  &num_slice_per_row);
+						  &num_slices);
 	if (rc)
 		return rc;
 
+	if (parms->idx % num_slices) {
+		TFP_DRV_LOG(ERR,
+			    "%s: TCAM reserved resource is not multiple of %d\n",
+			    tf_dir_2_str(parms->dir),
+			    num_slices);
+		return -EINVAL;
+	}
+
 	/* Check if element is in use */
 	memset(&aparms, 0, sizeof(aparms));
 
 	aparms.rm_db = tcam_db[parms->dir];
 	aparms.subtype = parms->type;
-	aparms.index = parms->idx / num_slice_per_row;
+	aparms.index = parms->idx;
 	aparms.allocated = &allocated;
 	rc = tf_rm_is_allocated(&aparms);
 	if (rc)
@@ -376,44 +428,20 @@ tf_tcam_free(struct tf *tfp,
 		}
 	}
 
-	/* Free requested element */
-	memset(&fparms, 0, sizeof(fparms));
-	fparms.rm_db = tcam_db[parms->dir];
-	fparms.subtype = parms->type;
-	fparms.index = parms->idx / num_slice_per_row;
-	rc = tf_rm_free(&fparms);
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "%s: Free failed, type:%d, index:%d\n",
-			    tf_dir_2_str(parms->dir),
-			    parms->type,
-			    parms->idx);
-		return rc;
-	}
-
-	if (parms->type == TF_TCAM_TBL_TYPE_WC_TCAM) {
-		int i;
-
-		for (i = -1; i < 3; i += 3) {
-			aparms.index += i;
-			rc = tf_rm_is_allocated(&aparms);
-			if (rc)
-				return rc;
-
-			if (allocated == TF_RM_ALLOCATED_ENTRY_IN_USE) {
-				/* Free requested element */
-				fparms.index = aparms.index;
-				rc = tf_rm_free(&fparms);
-				if (rc) {
-					TFP_DRV_LOG(ERR,
-						    "%s: Free failed, type:%d, "
-						    "index:%d\n",
-						    tf_dir_2_str(parms->dir),
-						    parms->type,
-						    fparms.index);
-					return rc;
-				}
-			}
+	for (i = 0; i < num_slices; i++) {
+		/* Free requested element */
+		memset(&fparms, 0, sizeof(fparms));
+		fparms.rm_db = tcam_db[parms->dir];
+		fparms.subtype = parms->type;
+		fparms.index = parms->idx + i;
+		rc = tf_rm_free(&fparms);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "%s: Free failed, type:%d, index:%d\n",
+				    tf_dir_2_str(parms->dir),
+				    parms->type,
+				    parms->idx);
+			return rc;
 		}
 	}
 
@@ -449,8 +477,8 @@ tf_tcam_alloc_search(struct tf *tfp,
 {
 	struct tf_shadow_tcam_search_parms sparms;
 	struct tf_shadow_tcam_bind_index_parms bparms;
-	struct tf_tcam_alloc_parms aparms;
 	struct tf_tcam_free_parms fparms;
+	struct tf_tcam_alloc_parms aparms;
 	uint16_t num_slice_per_row = 1;
 	struct tf_session *tfs;
 	struct tf_dev_info *dev;
@@ -626,7 +654,7 @@ tf_tcam_set(struct tf *tfp __rte_unused,
 
 	aparms.rm_db = tcam_db[parms->dir];
 	aparms.subtype = parms->type;
-	aparms.index = parms->idx / num_slice_per_row;
+	aparms.index = parms->idx;
 	aparms.allocated = &allocated;
 	rc = tf_rm_is_allocated(&aparms);
 	if (rc)
@@ -693,7 +721,6 @@ tf_tcam_get(struct tf *tfp __rte_unused,
 	struct tf_dev_info *dev;
 	struct tf_rm_is_allocated_parms aparms;
 	struct tf_rm_get_hcapi_parms hparms;
-	uint16_t num_slice_per_row = 1;
 	int allocated = 0;
 
 	TF_CHECK_PARMS2(tfp, parms);
@@ -715,29 +742,12 @@ tf_tcam_get(struct tf *tfp __rte_unused,
 	if (rc)
 		return rc;
 
-	if (dev->ops->tf_dev_get_tcam_slice_info == NULL) {
-		rc = -EOPNOTSUPP;
-		TFP_DRV_LOG(ERR,
-			    "%s: Operation not supported, rc:%s\n",
-			    tf_dir_2_str(parms->dir),
-			    strerror(-rc));
-		return rc;
-	}
-
-	/* Need to retrieve row size etc */
-	rc = dev->ops->tf_dev_get_tcam_slice_info(tfp,
-						  parms->type,
-						  parms->key_size,
-						  &num_slice_per_row);
-	if (rc)
-		return rc;
-
 	/* Check if element is in use */
 	memset(&aparms, 0, sizeof(aparms));
 
 	aparms.rm_db = tcam_db[parms->dir];
 	aparms.subtype = parms->type;
-	aparms.index = parms->idx / num_slice_per_row;
+	aparms.index = parms->idx;
 	aparms.allocated = &allocated;
 	rc = tf_rm_is_allocated(&aparms);
 	if (rc)
-- 
2.17.1


^ permalink raw reply	[flat|nested] 129+ messages in thread

* [dpdk-dev] [PATCH 10/58] net/bnxt: add 64B SRAM record management with RM
  2021-05-30  8:58 [dpdk-dev] [PATCH 00/58] enhancements to host based flow table management Venkat Duvvuru
                   ` (8 preceding siblings ...)
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 09/58] net/bnxt: add Thor WC TCAM support Venkat Duvvuru
@ 2021-05-30  8:58 ` Venkat Duvvuru
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 11/58] net/bnxt: add hashing changes for Thor Venkat Duvvuru
                   ` (48 subsequent siblings)
  58 siblings, 0 replies; 129+ messages in thread
From: Venkat Duvvuru @ 2021-05-30  8:58 UTC (permalink / raw)
  To: dev; +Cc: Farah Smith, Randy Schacher, Venkat Duvvuru

From: Farah Smith <farah.smith@broadcom.com>

HCAPI RM now manages 64B records instead of 8B.
Truflow core RM will manage the same. The tf_tbl core
APIs now return 8B pointer addresses. These can
be used directly as SRAM pointers in Action Records.
When communicating with the firmware 8B addresses
will be used.

Signed-off-by: Farah Smith <farah.smith@broadcom.com>
Signed-off-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Randy Schacher <stuart.schacher@broadcom.com>
---
 drivers/net/bnxt/tf_core/tf_device.h     |  29 ++++-
 drivers/net/bnxt/tf_core/tf_device_p4.c  |   2 +
 drivers/net/bnxt/tf_core/tf_device_p58.c |  71 ++++++++++
 drivers/net/bnxt/tf_core/tf_device_p58.h |  24 ++--
 drivers/net/bnxt/tf_core/tf_rm.h         |   2 +-
 drivers/net/bnxt/tf_core/tf_tbl.c        | 158 ++++++++++++++++++++++-
 6 files changed, 267 insertions(+), 19 deletions(-)

diff --git a/drivers/net/bnxt/tf_core/tf_device.h b/drivers/net/bnxt/tf_core/tf_device.h
index 2cbb42fe2a..a18d59660b 100644
--- a/drivers/net/bnxt/tf_core/tf_device.h
+++ b/drivers/net/bnxt/tf_core/tf_device.h
@@ -220,9 +220,36 @@ struct tf_dev_ops {
 	 */
 	int (*tf_dev_search_ident)(struct tf *tfp,
 				   struct tf_ident_search_parms *parms);
+	/**
+	 * Get SRAM table information.
+	 *
+	 * Converts an internal RM allocated element offset to
+	 * a user address and vice versa.
+	 *
+	 * [in] tfp
+	 *   Pointer to TF handle
+	 *
+	 * [in] type
+	 *   Truflow index table type, e.g. TF_TYPE_FULL_ACT_RECORD
+	 *
+	 * [in/out] base
+	 *   Pointer to the base address of the associated table type.
+	 *
+	 * [in/out] shift
+	 *   Pointer to any shift required for the associated table type.
+	 *
+	 * Returns
+	 *   - (0) if successful.
+	 *   - (-EINVAL) on failure.
+	 */
+	int (*tf_dev_get_tbl_info)(struct tf *tfp,
+				   void *tbl_db,
+				   enum tf_tbl_type type,
+				   uint16_t *base,
+				   uint16_t *shift);
 
 	/**
-	 * Allocation of a table type element.
+	 * Allocation of an index table type element.
 	 *
 	 * This API allocates the specified table type element from a
 	 * device specific table type DB. The allocated element is
diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.c b/drivers/net/bnxt/tf_core/tf_device_p4.c
index e5aaaac9a0..8274978bfe 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p4.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p4.c
@@ -206,6 +206,7 @@ const struct tf_dev_ops tf_dev_ops_p4_init = {
 	.tf_dev_alloc_ident = NULL,
 	.tf_dev_free_ident = NULL,
 	.tf_dev_search_ident = NULL,
+	.tf_dev_get_tbl_info = NULL,
 	.tf_dev_alloc_ext_tbl = NULL,
 	.tf_dev_alloc_tbl = NULL,
 	.tf_dev_free_ext_tbl = NULL,
@@ -246,6 +247,7 @@ const struct tf_dev_ops tf_dev_ops_p4 = {
 	.tf_dev_alloc_ident = tf_ident_alloc,
 	.tf_dev_free_ident = tf_ident_free,
 	.tf_dev_search_ident = tf_ident_search,
+	.tf_dev_get_tbl_info = NULL,
 	.tf_dev_alloc_tbl = tf_tbl_alloc,
 	.tf_dev_alloc_ext_tbl = tf_tbl_ext_alloc,
 	.tf_dev_free_tbl = tf_tbl_free,
diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c
index 65e283ed11..b61c58e41b 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p58.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p58.c
@@ -148,6 +148,75 @@ static int tf_dev_p58_word_align(uint16_t size)
 	return ((((size) + 63) >> 6) * 8);
 }
 
+
+#define TF_DEV_P58_BANK_SZ_64B 2048
+/**
+ * Get SRAM table information.
+ *
+ * Converts an internal RM allocated element offset to
+ * a user address and vice versa.
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [in] type
+ *   Truflow index table type, e.g. TF_TYPE_FULL_ACT_RECORD
+ *
+ * [in/out] base
+ *   Pointer to the Base address of the associated SRAM bank used for
+ *   the type of record allocated.
+ *
+ * [in/out] shift
+ *   Pointer to the factor to be used as a multiplier to translate
+ *   between the RM units to the user address.  SRAM manages 64B entries
+ *   Addresses must be shifted to an 8B address.
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+static int tf_dev_p58_get_sram_tbl_info(struct tf *tfp __rte_unused,
+					void *db,
+					enum tf_tbl_type type,
+					uint16_t *base,
+					uint16_t *shift)
+{
+	uint16_t hcapi_type;
+	struct tf_rm_get_hcapi_parms parms;
+	int rc;
+
+	parms.rm_db = db;
+	parms.subtype = type;
+	parms.hcapi_type = &hcapi_type;
+
+	rc = tf_rm_get_hcapi_type(&parms);
+	if (rc)
+		return rc;
+
+	switch (hcapi_type) {
+	case CFA_RESOURCE_TYPE_P58_SRAM_BANK_0:
+		*base = 0;
+		*shift = 3;
+		break;
+	case CFA_RESOURCE_TYPE_P58_SRAM_BANK_1:
+		*base = TF_DEV_P58_BANK_SZ_64B;
+		*shift = 3;
+		break;
+	case CFA_RESOURCE_TYPE_P58_SRAM_BANK_2:
+		*base = TF_DEV_P58_BANK_SZ_64B * 2;
+		*shift = 3;
+		break;
+	case CFA_RESOURCE_TYPE_P58_SRAM_BANK_3:
+		*base = TF_DEV_P58_BANK_SZ_64B * 3;
+		*shift = 3;
+		break;
+	default:
+		*base = 0;
+		*shift = 0;
+		break;
+	}
+	return 0;
+}
 /**
  * Truflow P58 device specific functions
  */
@@ -158,6 +227,7 @@ const struct tf_dev_ops tf_dev_ops_p58_init = {
 	.tf_dev_alloc_ident = NULL,
 	.tf_dev_free_ident = NULL,
 	.tf_dev_search_ident = NULL,
+	.tf_dev_get_tbl_info = NULL,
 	.tf_dev_alloc_ext_tbl = NULL,
 	.tf_dev_alloc_tbl = NULL,
 	.tf_dev_free_ext_tbl = NULL,
@@ -198,6 +268,7 @@ const struct tf_dev_ops tf_dev_ops_p58 = {
 	.tf_dev_alloc_ident = tf_ident_alloc,
 	.tf_dev_free_ident = tf_ident_free,
 	.tf_dev_search_ident = tf_ident_search,
+	.tf_dev_get_tbl_info = tf_dev_p58_get_sram_tbl_info,
 	.tf_dev_alloc_tbl = tf_tbl_alloc,
 	.tf_dev_alloc_ext_tbl = tf_tbl_ext_alloc,
 	.tf_dev_free_tbl = tf_tbl_free,
diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.h b/drivers/net/bnxt/tf_core/tf_device_p58.h
index 07f022769b..4d7a78e52c 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p58.h
+++ b/drivers/net/bnxt/tf_core/tf_device_p58.h
@@ -68,35 +68,35 @@ struct tf_rm_element_cfg tf_tbl_p58[TF_TBL_TYPE_MAX] = {
 	[TF_TBL_TYPE_FULL_ACT_RECORD] = {
 		.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_PARENT,
 		.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_1,
-		.slices          = 4,
+		.slices          = 1,
 		.divider         = 8,
 	},
 	[TF_TBL_TYPE_COMPACT_ACT_RECORD] = {
 		.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,
 		.parent_subtype  = TF_TBL_TYPE_FULL_ACT_RECORD,
 		.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_1,
-		.slices          = 8,
+		.slices          = 1,
 		.divider         = 8,
 	},
 	/* Policy - Encaps in bank 2 */
 	[TF_TBL_TYPE_ACT_ENCAP_8B] = {
 		.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_PARENT,
 		.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,
-		.slices          = 8,
+		.slices          = 1,
 		.divider         = 8,
 	},
 	[TF_TBL_TYPE_ACT_ENCAP_16B] = {
 		.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,
 		.parent_subtype  = TF_TBL_TYPE_ACT_ENCAP_8B,
 		.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,
-		.slices          = 4,
+		.slices          = 1,
 		.divider         = 8,
 	},
 	[TF_TBL_TYPE_ACT_ENCAP_32B] = {
 		.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,
 		.parent_subtype  = TF_TBL_TYPE_ACT_ENCAP_8B,
 		.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,
-		.slices          = 2,
+		.slices          = 1,
 		.divider         = 8,
 	},
 	[TF_TBL_TYPE_ACT_ENCAP_64B] = {
@@ -111,21 +111,21 @@ struct tf_rm_element_cfg tf_tbl_p58[TF_TBL_TYPE_MAX] = {
 		.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,
 		.parent_subtype  = TF_TBL_TYPE_ACT_ENCAP_8B,
 		.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,
-		.slices          = 8,
+		.slices          = 1,
 		.divider         = 8,
 	},
 	[TF_TBL_TYPE_ACT_MODIFY_16B] = {
 		.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,
 		.parent_subtype  = TF_TBL_TYPE_ACT_ENCAP_8B,
 		.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,
-		.slices          = 4,
+		.slices          = 1,
 		.divider         = 8,
 	},
 	[TF_TBL_TYPE_ACT_MODIFY_32B] = {
 		.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,
 		.parent_subtype  = TF_TBL_TYPE_ACT_ENCAP_8B,
 		.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_2,
-		.slices          = 2,
+		.slices          = 1,
 		.divider         = 8,
 	},
 	[TF_TBL_TYPE_ACT_MODIFY_64B] = {
@@ -139,28 +139,28 @@ struct tf_rm_element_cfg tf_tbl_p58[TF_TBL_TYPE_MAX] = {
 	[TF_TBL_TYPE_ACT_SP_SMAC] = {
 		.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_PARENT,
 		.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_0,
-		.slices          = 8,
+		.slices          = 1,
 		.divider         = 8,
 	},
 	[TF_TBL_TYPE_ACT_SP_SMAC_IPV4] = {
 		.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,
 		.parent_subtype  = TF_TBL_TYPE_ACT_SP_SMAC,
 		.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_0,
-		.slices          = 4,
+		.slices          = 1,
 		.divider         = 8,
 	},
 	[TF_TBL_TYPE_ACT_SP_SMAC_IPV6] = {
 		.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_CHILD,
 		.parent_subtype  = TF_TBL_TYPE_ACT_SP_SMAC,
 		.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_0,
-		.slices          = 2,
+		.slices          = 1,
 		.divider         = 8,
 	},
 	/* Policy - Stats in bank 3 */
 	[TF_TBL_TYPE_ACT_STATS_64] = {
 		.cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_PARENT,
 		.hcapi_type      = CFA_RESOURCE_TYPE_P58_SRAM_BANK_3,
-		.slices          = 8,
+		.slices          = 1,
 		.divider         = 8,
 	},
 };
diff --git a/drivers/net/bnxt/tf_core/tf_rm.h b/drivers/net/bnxt/tf_core/tf_rm.h
index 407c7d5bf9..6eb6865dac 100644
--- a/drivers/net/bnxt/tf_core/tf_rm.h
+++ b/drivers/net/bnxt/tf_core/tf_rm.h
@@ -138,6 +138,7 @@ struct tf_rm_element_cfg {
 	 * resource pool chunk size.
 	 */
 	uint8_t slices;
+
 	/**
 	 * Pool element divider count
 	 * If 0 or 1, there is 1:1 correspondence between the RM
@@ -146,7 +147,6 @@ struct tf_rm_element_cfg {
 	 * correspondence to the HCAPI RM firmware resource.
 	 */
 	uint8_t divider;
-
 };
 
 /**
diff --git a/drivers/net/bnxt/tf_core/tf_tbl.c b/drivers/net/bnxt/tf_core/tf_tbl.c
index 7d15c3c5d4..75dbe2066f 100644
--- a/drivers/net/bnxt/tf_core/tf_tbl.c
+++ b/drivers/net/bnxt/tf_core/tf_tbl.c
@@ -16,6 +16,14 @@
 #include "tf_session.h"
 #include "tf_device.h"
 
+#define TF_TBL_RM_TO_PTR(new_idx, idx, base, shift) {		\
+		*(new_idx) = (((idx) + (base)) << (shift));	\
+}
+
+#define TF_TBL_PTR_TO_RM(new_idx, idx, base, shift) {		\
+		*(new_idx) = (((idx) >> (shift)) - (base));	\
+}
+
 struct tf;
 
 /**
@@ -118,6 +126,9 @@ tf_tbl_alloc(struct tf *tfp __rte_unused,
 	int rc;
 	uint32_t idx;
 	struct tf_rm_allocate_parms aparms = { 0 };
+	struct tf_session *tfs;
+	struct tf_dev_info *dev;
+	uint16_t base = 0, shift = 0;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -128,6 +139,29 @@ tf_tbl_alloc(struct tf *tfp __rte_unused,
 		return -EINVAL;
 	}
 
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc)
+		return rc;
+
+	/* Only get table info if required for the device */
+	if (dev->ops->tf_dev_get_tbl_info) {
+		rc = dev->ops->tf_dev_get_tbl_info(tfp, tbl_db[parms->dir],
+						   parms->type, &base, &shift);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "%s: Failed to get table info:%d\n",
+				    tf_dir_2_str(parms->dir),
+				    parms->type);
+			return rc;
+		}
+	}
+
 	/* Allocate requested element */
 	aparms.rm_db = tbl_db[parms->dir];
 	aparms.subtype = parms->type;
@@ -141,6 +175,7 @@ tf_tbl_alloc(struct tf *tfp __rte_unused,
 		return rc;
 	}
 
+	TF_TBL_RM_TO_PTR(&idx, idx, base, shift);
 	*parms->idx = idx;
 
 	return 0;
@@ -154,6 +189,9 @@ tf_tbl_free(struct tf *tfp __rte_unused,
 	struct tf_rm_is_allocated_parms aparms = { 0 };
 	struct tf_rm_free_parms fparms = { 0 };
 	int allocated = 0;
+	struct tf_session *tfs;
+	struct tf_dev_info *dev;
+	uint16_t base = 0, shift = 0;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -163,11 +201,35 @@ tf_tbl_free(struct tf *tfp __rte_unused,
 			    tf_dir_2_str(parms->dir));
 		return -EINVAL;
 	}
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc)
+		return rc;
+
+	/* Only get table info if required for the device */
+	if (dev->ops->tf_dev_get_tbl_info) {
+		rc = dev->ops->tf_dev_get_tbl_info(tfp, tbl_db[parms->dir],
+						   parms->type, &base, &shift);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "%s: Failed to get table info:%d\n",
+				    tf_dir_2_str(parms->dir),
+				    parms->type);
+			return rc;
+		}
+	}
 
 	/* Check if element is in use */
 	aparms.rm_db = tbl_db[parms->dir];
 	aparms.subtype = parms->type;
-	aparms.index = parms->idx;
+
+	TF_TBL_PTR_TO_RM(&aparms.index, parms->idx, base, shift);
+
 	aparms.allocated = &allocated;
 	rc = tf_rm_is_allocated(&aparms);
 	if (rc)
@@ -184,7 +246,9 @@ tf_tbl_free(struct tf *tfp __rte_unused,
 	/* Free requested element */
 	fparms.rm_db = tbl_db[parms->dir];
 	fparms.subtype = parms->type;
-	fparms.index = parms->idx;
+
+	TF_TBL_PTR_TO_RM(&fparms.index, parms->idx, base, shift);
+
 	rc = tf_rm_free(&fparms);
 	if (rc) {
 		TFP_DRV_LOG(ERR,
@@ -223,6 +287,9 @@ tf_tbl_set(struct tf *tfp,
 	uint16_t hcapi_type;
 	struct tf_rm_is_allocated_parms aparms = { 0 };
 	struct tf_rm_get_hcapi_parms hparms = { 0 };
+	struct tf_session *tfs;
+	struct tf_dev_info *dev;
+	uint16_t base = 0, shift = 0;
 
 	TF_CHECK_PARMS3(tfp, parms, parms->data);
 
@@ -233,10 +300,34 @@ tf_tbl_set(struct tf *tfp,
 		return -EINVAL;
 	}
 
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc)
+		return rc;
+
+	/* Only get table info if required for the device */
+	if (dev->ops->tf_dev_get_tbl_info) {
+		rc = dev->ops->tf_dev_get_tbl_info(tfp, tbl_db[parms->dir],
+						   parms->type, &base, &shift);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "%s: Failed to get table info:%d\n",
+				    tf_dir_2_str(parms->dir),
+				    parms->type);
+			return rc;
+		}
+	}
+
 	/* Verify that the entry has been previously allocated */
 	aparms.rm_db = tbl_db[parms->dir];
 	aparms.subtype = parms->type;
-	aparms.index = parms->idx;
+	TF_TBL_PTR_TO_RM(&aparms.index, parms->idx, base, shift);
+
 	aparms.allocated = &allocated;
 	rc = tf_rm_is_allocated(&aparms);
 	if (rc)
@@ -292,6 +383,9 @@ tf_tbl_get(struct tf *tfp,
 	int allocated = 0;
 	struct tf_rm_is_allocated_parms aparms = { 0 };
 	struct tf_rm_get_hcapi_parms hparms = { 0 };
+	struct tf_session *tfs;
+	struct tf_dev_info *dev;
+	uint16_t base = 0, shift = 0;
 
 	TF_CHECK_PARMS3(tfp, parms, parms->data);
 
@@ -302,10 +396,35 @@ tf_tbl_get(struct tf *tfp,
 		return -EINVAL;
 	}
 
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc)
+		return rc;
+
+	/* Only get table info if required for the device */
+	if (dev->ops->tf_dev_get_tbl_info) {
+		rc = dev->ops->tf_dev_get_tbl_info(tfp, tbl_db[parms->dir],
+						   parms->type, &base, &shift);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "%s: Failed to get table info:%d\n",
+				    tf_dir_2_str(parms->dir),
+				    parms->type);
+			return rc;
+		}
+	}
+
 	/* Verify that the entry has been previously allocated */
 	aparms.rm_db = tbl_db[parms->dir];
 	aparms.subtype = parms->type;
-	aparms.index = parms->idx;
+	TF_TBL_PTR_TO_RM(&aparms.index, parms->idx, base, shift);
+
 	aparms.allocated = &allocated;
 	rc = tf_rm_is_allocated(&aparms);
 	if (rc)
@@ -361,6 +480,9 @@ tf_tbl_bulk_get(struct tf *tfp,
 	uint16_t hcapi_type;
 	struct tf_rm_get_hcapi_parms hparms = { 0 };
 	struct tf_rm_check_indexes_in_range_parms cparms = { 0 };
+	struct tf_session *tfs;
+	struct tf_dev_info *dev;
+	uint16_t base = 0, shift = 0;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -372,10 +494,36 @@ tf_tbl_bulk_get(struct tf *tfp,
 		return -EINVAL;
 	}
 
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc)
+		return rc;
+
+	/* Only get table info if required for the device */
+	if (dev->ops->tf_dev_get_tbl_info) {
+		rc = dev->ops->tf_dev_get_tbl_info(tfp, tbl_db[parms->dir],
+						   parms->type, &base, &shift);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "%s: Failed to get table info:%d\n",
+				    tf_dir_2_str(parms->dir),
+				    parms->type);
+			return rc;
+		}
+	}
+
 	/* Verify that the entries are in the range of reserved resources. */
 	cparms.rm_db = tbl_db[parms->dir];
 	cparms.subtype = parms->type;
-	cparms.starting_index = parms->starting_idx;
+
+	TF_TBL_PTR_TO_RM(&cparms.starting_index, parms->starting_idx,
+			 base, shift);
+
 	cparms.num_entries = parms->num_entries;
 
 	rc = tf_rm_check_indexes_in_range(&cparms);
-- 
2.17.1


^ permalink raw reply	[flat|nested] 129+ messages in thread

* [dpdk-dev] [PATCH 11/58] net/bnxt: add hashing changes for Thor
  2021-05-30  8:58 [dpdk-dev] [PATCH 00/58] enhancements to host based flow table management Venkat Duvvuru
                   ` (9 preceding siblings ...)
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 10/58] net/bnxt: add 64B SRAM record management with RM Venkat Duvvuru
@ 2021-05-30  8:58 ` Venkat Duvvuru
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 12/58] net/bnxt: modify TRUFLOW HWRM messages Venkat Duvvuru
                   ` (47 subsequent siblings)
  58 siblings, 0 replies; 129+ messages in thread
From: Venkat Duvvuru @ 2021-05-30  8:58 UTC (permalink / raw)
  To: dev; +Cc: Peter Spreadborough, Randy Schacher, Venkat Duvvuru

From: Peter Spreadborough <peter.spreadborough@broadcom.com>

- Move HCAPI hashing code to common file and add Thor support.
- Change DPDK EM insert for FKB to use limited size Type 3 key.
- Update FKB builder to be able to tell between EM and WC keys
  during transform.

Signed-off-by: Peter Spreadborough <peter.spreadborough@broadcom.com>
Signed-off-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Randy Schacher <stuart.schacher@broadcom.com>
Reviewed-by: Farah Smith <farah.smith@broadcom.com>
---
 drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h        |  72 ++++++++++-
 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_common.c |  85 ++++++++++++
 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_defs.h   |  15 +++
 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.c     | 109 +---------------
 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.c    | 122 ++++++++++++++++++
 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.h    |   6 +
 drivers/net/bnxt/hcapi/cfa/meson.build        |   4 +-
 drivers/net/bnxt/tf_core/tf_device.h          |  15 +++
 drivers/net/bnxt/tf_core/tf_device_p4.c       |   4 +
 drivers/net/bnxt/tf_core/tf_device_p58.c      |   4 +
 drivers/net/bnxt/tf_core/tf_em.h              |   8 +-
 drivers/net/bnxt/tf_core/tf_em_common.c       |  42 ++++--
 .../net/bnxt/tf_core/tf_em_hash_internal.c    |  22 +++-
 13 files changed, 383 insertions(+), 125 deletions(-)
 create mode 100644 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_common.c
 create mode 100644 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.c

diff --git a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h
index c67aa29ad0..0580e07c45 100644
--- a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h
+++ b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h
@@ -63,10 +63,74 @@ struct hcapi_cfa_devops {
 	 */
 	uint64_t (*hcapi_cfa_key_hash)(uint64_t *key_data, uint16_t bitlen);
 
-	/** hardware operation on the CFA EM key
-	 *
-	 * This API provides the functionality to program the exact match and
-	 * key data to exact match record memory.
+int hcapi_cfa_action_hw_op(struct hcapi_cfa_hwop *op,
+			   uint8_t *act_tbl,
+			   struct hcapi_cfa_data *act_obj);
+int hcapi_cfa_dev_hw_op(struct hcapi_cfa_hwop *op, uint16_t tbl_id,
+			struct hcapi_cfa_data *obj_data);
+int hcapi_cfa_rm_register_client(hcapi_cfa_rm_data_t *data,
+				 const char *client_name,
+				 int *client_id);
+int hcapi_cfa_rm_unregister_client(hcapi_cfa_rm_data_t *data,
+				   int client_id);
+int hcapi_cfa_rm_query_resources(hcapi_cfa_rm_data_t *data,
+				 int client_id,
+				 uint16_t chnl_id,
+				 struct hcapi_cfa_resc_req_db *req_db);
+int hcapi_cfa_rm_query_resources_one(hcapi_cfa_rm_data_t *data,
+				     int clien_id,
+				     struct hcapi_cfa_resc_db *resc_db);
+int hcapi_cfa_rm_reserve_resources(hcapi_cfa_rm_data_t *data,
+				   int client_id,
+				   struct hcapi_cfa_resc_req_db *resc_req,
+				   struct hcapi_cfa_resc_db *resc_db);
+int hcapi_cfa_rm_release_resources(hcapi_cfa_rm_data_t *data,
+				   int client_id,
+				   struct hcapi_cfa_resc_req_db *resc_req,
+				   struct hcapi_cfa_resc_db *resc_db);
+int hcapi_cfa_rm_initialize(hcapi_cfa_rm_data_t *data);
+
+#if SUPPORT_CFA_HW_P4
+
+int hcapi_cfa_p4_dev_hw_op(struct hcapi_cfa_hwop *op, uint16_t tbl_id,
+			    struct hcapi_cfa_data *obj_data);
+int hcapi_cfa_p4_prof_l2ctxt_hwop(struct hcapi_cfa_hwop *op,
+				   struct hcapi_cfa_data *obj_data);
+int hcapi_cfa_p4_prof_l2ctxtrmp_hwop(struct hcapi_cfa_hwop *op,
+				      struct hcapi_cfa_data *obj_data);
+int hcapi_cfa_p4_prof_tcam_hwop(struct hcapi_cfa_hwop *op,
+				 struct hcapi_cfa_data *obj_data);
+int hcapi_cfa_p4_prof_tcamrmp_hwop(struct hcapi_cfa_hwop *op,
+				    struct hcapi_cfa_data *obj_data);
+int hcapi_cfa_p4_wc_tcam_hwop(struct hcapi_cfa_hwop *op,
+			       struct hcapi_cfa_data *obj_data);
+int hcapi_cfa_p4_wc_tcam_rec_hwop(struct hcapi_cfa_hwop *op,
+				   struct hcapi_cfa_data *obj_data);
+int hcapi_cfa_p4_mirror_hwop(struct hcapi_cfa_hwop *op,
+			     struct hcapi_cfa_data *mirror);
+int hcapi_cfa_p4_global_cfg_hwop(struct hcapi_cfa_hwop *op,
+				 uint32_t type,
+				 struct hcapi_cfa_data *config);
+/* SUPPORT_CFA_HW_P4 */
+#elif SUPPORT_CFA_HW_P45
+int hcapi_cfa_p45_mirror_hwop(struct hcapi_cfa_hwop *op,
+			      struct hcapi_cfa_data *mirror);
+int hcapi_cfa_p45_global_cfg_hwop(struct hcapi_cfa_hwop *op,
+				  uint32_t type,
+				  struct hcapi_cfa_data *config);
+/* SUPPORT_CFA_HW_P45 */
+#endif
+
+/**
+ *  HCAPI CFA device HW operation function callback definition
+ *  This is standardized function callback hook to install different
+ *  CFA HW table programming function callback.
+ */
+
+struct hcapi_cfa_tbl_cb {
+	/**
+	 * This function callback provides the functionality to read/write
+	 * HW table entry from a HW table.
 	 *
 	 * @param[in] op
 	 *   A pointer to the Hardware operation parameter
diff --git a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_common.c b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_common.c
new file mode 100644
index 0000000000..fc96e3bff7
--- /dev/null
+++ b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_common.c
@@ -0,0 +1,85 @@
+/*
+ *   Copyright(c) 2019-2021 Broadcom Limited.
+ *   All rights reserved.
+ */
+
+#include "hcapi_cfa_defs.h"
+#include <errno.h>
+#include "assert.h"
+
+const uint32_t crc32tbl[] = {	/* CRC polynomial 0xedb88320 */
+0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
+0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
+0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
+0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
+0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
+0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
+0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
+0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
+0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
+0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
+0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940,
+0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
+0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116,
+0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
+0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
+0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
+0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a,
+0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
+0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
+0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
+0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
+0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
+0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
+0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
+0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
+0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
+0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
+0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
+0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
+0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
+0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
+0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
+0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
+0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
+0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
+0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
+0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
+0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
+0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
+0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
+0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
+0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
+0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
+0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
+0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
+0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
+0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
+0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
+0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
+0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
+0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
+0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
+0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
+0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
+0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
+0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
+0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
+0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
+0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
+0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
+0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
+0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
+0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
+0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
+};
+
+uint32_t hcapi_cfa_crc32i(uint32_t crc, const uint8_t *buf, size_t len)
+{
+	int l;
+
+	for (l = (len - 1); l >= 0; l--)
+		crc = ucrc32(buf[l], crc);
+
+	return ~crc;
+}
diff --git a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_defs.h b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_defs.h
index 8e5095a6ef..579f1d5693 100644
--- a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_defs.h
+++ b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_defs.h
@@ -54,6 +54,16 @@ enum hcapi_cfa_dir {
 	HCAPI_CFA_DIR_MAX = 2
 };
 
+/*
+ * Hashing defines
+ */
+#define HCAPI_CFA_LKUP_SEED_MEM_SIZE 512
+
+/* CRC32i support for Key0 hash */
+#define ucrc32(ch, crc) (crc32tbl[((crc) ^ (ch)) & 0xff] ^ ((crc) >> 8))
+#define crc32(x, y) crc32i(~0, x, y)
+
+
 /**
  * CFA HW OPCODE definition
  */
@@ -282,4 +292,9 @@ int hcapi_cfa_key_hw_op(struct hcapi_cfa_hwop *op,
 
 uint64_t hcapi_get_table_page(struct hcapi_cfa_em_table *mem,
 			      uint32_t page);
+uint32_t hcapi_cfa_crc32i(uint32_t crc, const uint8_t *buf, size_t len);
+uint64_t hcapi_cfa_p4_key_hash(uint64_t *key_data,
+			       uint16_t bitlen);
+uint64_t hcapi_cfa_p58_key_hash(uint64_t *key_data,
+				uint16_t bitlen);
 #endif /* HCAPI_CFA_DEFS_H_ */
diff --git a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.c b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.c
index 3a0476a33d..0544b667dd 100644
--- a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.c
+++ b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.c
@@ -12,10 +12,11 @@
 
 #include "hcapi_cfa_defs.h"
 
-#define HCAPI_CFA_LKUP_SEED_MEM_SIZE 512
-uint32_t hcapi_cfa_lkup_lkup3_init_cfg;
-uint32_t hcapi_cfa_lkup_em_seed_mem[HCAPI_CFA_LKUP_SEED_MEM_SIZE];
-bool hcapi_cfa_lkup_init;
+static uint32_t hcapi_cfa_lkup_lkup3_init_cfg;
+static uint32_t hcapi_cfa_lkup_em_seed_mem[HCAPI_CFA_LKUP_SEED_MEM_SIZE];
+static bool hcapi_cfa_lkup_init;
+
+extern const uint32_t crc32tbl[];
 
 static inline uint32_t SWAP_WORDS32(uint32_t val32)
 {
@@ -47,102 +48,6 @@ static void hcapi_cfa_seeds_init(void)
 	}
 }
 
-/* CRC32i support for Key0 hash */
-#define ucrc32(ch, crc) (crc32tbl[((crc) ^ (ch)) & 0xff] ^ ((crc) >> 8))
-#define crc32(x, y) crc32i(~0, x, y)
-
-static const uint32_t crc32tbl[] = {	/* CRC polynomial 0xedb88320 */
-0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
-0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
-0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
-0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
-0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
-0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
-0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
-0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
-0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
-0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
-0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940,
-0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
-0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116,
-0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
-0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
-0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
-0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a,
-0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
-0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
-0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
-0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
-0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
-0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
-0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
-0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
-0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
-0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
-0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
-0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
-0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
-0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
-0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
-0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
-0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
-0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
-0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
-0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
-0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
-0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
-0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
-0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
-0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
-0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
-0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
-0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
-0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
-0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
-0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
-0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
-0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
-0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
-0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
-0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
-0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
-0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
-0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
-0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
-0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
-0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
-0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
-0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
-0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
-0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
-0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
-};
-
-static uint32_t hcapi_cfa_crc32i(uint32_t crc, const uint8_t *buf, size_t len)
-{
-	int l;
-
-#ifdef TF_EEM_DEBUG
-	TFP_DRV_LOG(DEBUG, "CRC2:");
-#endif
-	for (l = (len - 1); l >= 0; l--) {
-		crc = ucrc32(buf[l], crc);
-#ifdef TF_EEM_DEBUG
-		TFP_DRV_LOG(DEBUG,
-			    "%02X %08X %08X\n",
-			    (buf[l] & 0xff),
-			    crc,
-			    ~crc);
-#endif
-	}
-
-#ifdef TF_EEM_DEBUG
-	TFP_DRV_LOG(DEBUG, "\n");
-#endif
-
-	return ~crc;
-}
-
 static uint32_t hcapi_cfa_crc32_hash(uint8_t *key)
 {
 	int i;
@@ -221,8 +126,8 @@ uint64_t hcapi_get_table_page(struct hcapi_cfa_em_table *mem,
  * Return:
  *
  */
-uint64_t hcapi_cfa_key_hash(uint64_t *key_data,
-			    uint16_t bitlen)
+uint64_t hcapi_cfa_p4_key_hash(uint64_t *key_data,
+			       uint16_t bitlen)
 {
 	uint32_t key0_hash;
 	uint32_t key1_hash;
diff --git a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.c b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.c
new file mode 100644
index 0000000000..723b8393b9
--- /dev/null
+++ b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.c
@@ -0,0 +1,122 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019-2021 Broadcom
+ * All rights reserved.
+ */
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
+#include "lookup3.h"
+#include "rand.h"
+
+#include "hcapi_cfa_defs.h"
+
+static uint32_t hcapi_cfa_lkup_lkup3_init_cfg;
+static uint32_t hcapi_cfa_lkup_em_seed_mem[HCAPI_CFA_LKUP_SEED_MEM_SIZE];
+static bool hcapi_cfa_lkup_init;
+
+extern const uint32_t crc32tbl[];
+
+static void hcapi_cfa_seeds_init(void)
+{
+	int i;
+	uint32_t r;
+
+	if (hcapi_cfa_lkup_init)
+		return;
+
+	hcapi_cfa_lkup_init = true;
+
+	/* Initialize the lfsr */
+	rand_init();
+
+	/* RX and TX use the same seed values */
+	hcapi_cfa_lkup_lkup3_init_cfg = rand32();
+
+	for (i = 0; i < HCAPI_CFA_LKUP_SEED_MEM_SIZE / 2; i++) {
+		r = rand32();
+		hcapi_cfa_lkup_em_seed_mem[i * 2] = r;
+		r = rand32();
+		hcapi_cfa_lkup_em_seed_mem[i * 2 + 1] = (r & 0x1);
+	}
+}
+
+static uint32_t hcapi_cfa_crc32_hash(uint8_t *key)
+{
+	int i;
+	uint32_t index;
+	uint32_t val1, val2;
+	uint8_t temp[4];
+	uint8_t *kptr = key;
+
+	/* Do byte-wise XOR of the 52-byte HASH key first. */
+	index = *key;
+	kptr--;
+
+	for (i = CFA_P58_EEM_KEY_MAX_SIZE - 2; i >= 0; i--) {
+		index = index ^ *kptr;
+		kptr--;
+	}
+
+	/* Get seeds */
+	val1 = hcapi_cfa_lkup_em_seed_mem[index * 2];
+	val2 = hcapi_cfa_lkup_em_seed_mem[index * 2 + 1];
+
+	temp[3] = (uint8_t)(val1 >> 24);
+	temp[2] = (uint8_t)(val1 >> 16);
+	temp[1] = (uint8_t)(val1 >> 8);
+	temp[0] = (uint8_t)(val1 & 0xff);
+	val1 = 0;
+
+	/* Start with seed */
+	if (!(val2 & 0x1))
+		val1 = hcapi_cfa_crc32i(~val1, temp, 4);
+
+	val1 = hcapi_cfa_crc32i(~val1,
+		      (key - (CFA_P58_EEM_KEY_MAX_SIZE - 1)),
+		      CFA_P58_EEM_KEY_MAX_SIZE);
+
+	/* End with seed */
+	if (val2 & 0x1)
+		val1 = hcapi_cfa_crc32i(~val1, temp, 4);
+
+	return val1;
+}
+
+static uint32_t hcapi_cfa_lookup3_hash(uint8_t *in_key)
+{
+	uint32_t val1;
+
+	val1 = hashword(((uint32_t *)in_key) + 1,
+			 CFA_P58_EEM_KEY_MAX_SIZE / (sizeof(uint32_t)),
+			 hcapi_cfa_lkup_lkup3_init_cfg);
+
+	return val1;
+}
+
+
+/** Approximation of HCAPI hcapi_cfa_key_hash()
+ *
+ * Return:
+ *
+ */
+uint64_t hcapi_cfa_p58_key_hash(uint64_t *key_data,
+				uint16_t bitlen)
+{
+	uint32_t key0_hash;
+	uint32_t key1_hash;
+
+	/*
+	 * Init the seeds if needed
+	 */
+	if (!hcapi_cfa_lkup_init)
+		hcapi_cfa_seeds_init();
+
+	key0_hash = hcapi_cfa_crc32_hash(((uint8_t *)key_data) +
+					      (bitlen / 8) - 1);
+
+	key1_hash = hcapi_cfa_lookup3_hash((uint8_t *)key_data);
+
+	return ((uint64_t)key0_hash) << 32 | (uint64_t)key1_hash;
+}
diff --git a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.h b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.h
index b2535098d2..27796b1b2f 100644
--- a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.h
+++ b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.h
@@ -6,6 +6,12 @@
 #ifndef _HCAPI_CFA_P58_H_
 #define _HCAPI_CFA_P58_H_
 
+/**
+ * EEM Key entry sizes
+ */
+#define CFA_P58_EEM_KEY_MAX_SIZE 80
+#define CFA_P58_EEM_KEY_RECORD_SIZE 80
+
 /** CFA phase 5.8 fix formatted table(layout) ID definition
  *
  */
diff --git a/drivers/net/bnxt/hcapi/cfa/meson.build b/drivers/net/bnxt/hcapi/cfa/meson.build
index 8b70d273f4..5cdb1862f3 100644
--- a/drivers/net/bnxt/hcapi/cfa/meson.build
+++ b/drivers/net/bnxt/hcapi/cfa/meson.build
@@ -7,4 +7,6 @@ includes += include_directories('.')
 
 #Add the source files
 sources += files(
-        'hcapi_cfa_p4.c')
+	'hcapi_cfa_p4.c',
+	'hcapi_cfa_p58.c',
+	'hcapi_cfa_common.c')
diff --git a/drivers/net/bnxt/tf_core/tf_device.h b/drivers/net/bnxt/tf_core/tf_device.h
index a18d59660b..3f2c24a0c6 100644
--- a/drivers/net/bnxt/tf_core/tf_device.h
+++ b/drivers/net/bnxt/tf_core/tf_device.h
@@ -752,6 +752,21 @@ struct tf_dev_ops {
 	 *   Size in byte
 	 */
 	int (*tf_dev_word_align)(uint16_t size);
+
+	/**
+	 * Hash key using crc32 and lookup3
+	 *
+	 * [in] key_data
+	 *   Pointer to key
+	 *
+	 * [in] bitlen
+	 *   Number of key bits
+	 *
+	 * Returns
+	 *   Hashes
+	 */
+	uint64_t (*tf_dev_cfa_key_hash)(uint64_t *key_data,
+					  uint16_t bitlen);
 };
 
 /**
diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.c b/drivers/net/bnxt/tf_core/tf_device_p4.c
index 8274978bfe..2fb8fadb56 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p4.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p4.c
@@ -18,6 +18,9 @@
 #define TF_DEV_P4_PARIF_MAX 16
 #define TF_DEV_P4_PF_MASK 0xfUL
 
+uint64_t hcapi_cfa_key_hash_p4(uint64_t *key_data,
+			       uint16_t bitlen);
+
 const char *tf_resource_str_p4[CFA_RESOURCE_TYPE_P4_LAST + 1] = {
 	[CFA_RESOURCE_TYPE_P4_MCG] = "mc_group",
 	[CFA_RESOURCE_TYPE_P4_ENCAP_8B] = "encap_8 ",
@@ -276,4 +279,5 @@ const struct tf_dev_ops tf_dev_ops_p4 = {
 	.tf_dev_get_global_cfg = tf_global_cfg_get,
 	.tf_dev_get_mailbox = tf_dev_p4_get_mailbox,
 	.tf_dev_word_align = tf_dev_p4_word_align,
+	.tf_dev_cfa_key_hash = hcapi_cfa_p4_key_hash
 };
diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c
index b61c58e41b..517ffc811b 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p58.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p58.c
@@ -18,6 +18,9 @@
 #define TF_DEV_P58_PARIF_MAX 16
 #define TF_DEV_P58_PF_MASK 0xfUL
 
+uint64_t hcapi_cfa_key_hash_p58(uint64_t *key_data,
+				uint16_t bitlen);
+
 /* For print alignment, make all entries 8 chars in this table */
 const char *tf_resource_str_p58[CFA_RESOURCE_TYPE_P58_LAST + 1] = {
 	[CFA_RESOURCE_TYPE_P58_METER]              = "meter   ",
@@ -297,4 +300,5 @@ const struct tf_dev_ops tf_dev_ops_p58 = {
 	.tf_dev_get_global_cfg = tf_global_cfg_get,
 	.tf_dev_get_mailbox = tf_dev_p58_get_mailbox,
 	.tf_dev_word_align = tf_dev_p58_word_align,
+	.tf_dev_cfa_key_hash = hcapi_cfa_p58_key_hash
 };
diff --git a/drivers/net/bnxt/tf_core/tf_em.h b/drivers/net/bnxt/tf_core/tf_em.h
index 5a67ca3509..4de9e42cbc 100644
--- a/drivers/net/bnxt/tf_core/tf_em.h
+++ b/drivers/net/bnxt/tf_core/tf_em.h
@@ -14,8 +14,10 @@
 #define TF_EM_MIN_ENTRIES     (1 << 15) /* 32K */
 #define TF_EM_MAX_ENTRIES     (1 << 27) /* 128M */
 
-#define TF_HW_EM_KEY_MAX_SIZE 52
-#define TF_EM_KEY_RECORD_SIZE 64
+#define TF_P4_HW_EM_KEY_MAX_SIZE 52
+#define TF_P4_EM_KEY_RECORD_SIZE 64
+
+#define TF_P58_HW_EM_KEY_MAX_SIZE 80
 
 #define TF_EM_MAX_MASK 0x7FFF
 #define TF_EM_MAX_ENTRY (128 * 1024 * 1024)
@@ -95,7 +97,7 @@ struct tf_em_64b_entry {
 	/** Header is 8 bytes long */
 	struct cfa_p4_eem_entry_hdr hdr;
 	/** Key is 448 bits - 56 bytes */
-	uint8_t key[TF_EM_KEY_RECORD_SIZE - sizeof(struct cfa_p4_eem_entry_hdr)];
+	uint8_t key[TF_P4_EM_KEY_RECORD_SIZE - sizeof(struct cfa_p4_eem_entry_hdr)];
 };
 
 /** EEM Memory Type
diff --git a/drivers/net/bnxt/tf_core/tf_em_common.c b/drivers/net/bnxt/tf_core/tf_em_common.c
index 589df60041..d8278f1ce1 100644
--- a/drivers/net/bnxt/tf_core/tf_em_common.c
+++ b/drivers/net/bnxt/tf_core/tf_em_common.c
@@ -284,7 +284,7 @@ tf_em_create_key_entry(struct cfa_p4_eem_entry_hdr *result,
 {
 	key_entry->hdr.word1 = result->word1;
 	key_entry->hdr.pointer = result->pointer;
-	memcpy(key_entry->key, in_key, TF_HW_EM_KEY_MAX_SIZE + 4);
+	memcpy(key_entry->key, in_key, TF_P4_HW_EM_KEY_MAX_SIZE + 4);
 }
 
 
@@ -680,7 +680,8 @@ tf_em_validate_num_entries(struct tf_tbl_scope_cb *tbl_scope_cb,
  *   TF_ERR_EM_DUP  - key is already in table
  */
 static int
-tf_insert_eem_entry(struct tf_tbl_scope_cb *tbl_scope_cb,
+tf_insert_eem_entry(struct tf_dev_info *dev,
+		    struct tf_tbl_scope_cb *tbl_scope_cb,
 		    struct tf_insert_em_entry_parms *parms)
 {
 	uint32_t mask;
@@ -706,11 +707,14 @@ tf_insert_eem_entry(struct tf_tbl_scope_cb *tbl_scope_cb,
 		return -EINVAL;
 
 #ifdef TF_EEM_DEBUG
-	dump_raw((uint8_t *)parms->key, TF_HW_EM_KEY_MAX_SIZE + 4, "In Key");
+	dump_raw((uint8_t *)parms->key, TF_P4_HW_EM_KEY_MAX_SIZE + 4, "In Key");
 #endif
 
-	big_hash = hcapi_cfa_key_hash((uint64_t *)parms->key,
-				      (TF_HW_EM_KEY_MAX_SIZE + 4) * 8);
+	if (dev->ops->tf_dev_cfa_key_hash == NULL)
+		return -EINVAL;
+
+	big_hash = dev->ops->tf_dev_cfa_key_hash((uint64_t *)parms->key,
+					 (TF_P4_HW_EM_KEY_MAX_SIZE + 4) * 8);
 	key0_hash = (uint32_t)(big_hash >> 32);
 	key1_hash = (uint32_t)(big_hash & 0xFFFFFFFF);
 
@@ -739,9 +743,9 @@ tf_insert_eem_entry(struct tf_tbl_scope_cb *tbl_scope_cb,
 	key_tbl.base0 =
 		(uint8_t *)&tbl_scope_cb->em_ctx_info[parms->dir].em_tables[TF_KEY0_TABLE];
 	key_tbl.page_size = TF_EM_PAGE_SIZE;
-	key_obj.offset = index * TF_EM_KEY_RECORD_SIZE;
+	key_obj.offset = index * TF_P4_EM_KEY_RECORD_SIZE;
 	key_obj.data = (uint8_t *)&key_entry;
-	key_obj.size = TF_EM_KEY_RECORD_SIZE;
+	key_obj.size = TF_P4_EM_KEY_RECORD_SIZE;
 
 	rc = hcapi_cfa_key_hw_op(&op,
 				 &key_tbl,
@@ -755,7 +759,7 @@ tf_insert_eem_entry(struct tf_tbl_scope_cb *tbl_scope_cb,
 
 		key_tbl.base0 =
 			(uint8_t *)&tbl_scope_cb->em_ctx_info[parms->dir].em_tables[TF_KEY1_TABLE];
-		key_obj.offset = index * TF_EM_KEY_RECORD_SIZE;
+		key_obj.offset = index * TF_P4_EM_KEY_RECORD_SIZE;
 
 		rc = hcapi_cfa_key_hw_op(&op,
 					 &key_tbl,
@@ -818,9 +822,9 @@ tf_delete_eem_entry(struct tf_tbl_scope_cb *tbl_scope_cb,
 		(uint8_t *)&tbl_scope_cb->em_ctx_info[parms->dir].em_tables
 			[(hash_type == 0 ? TF_KEY0_TABLE : TF_KEY1_TABLE)];
 	key_tbl.page_size = TF_EM_PAGE_SIZE;
-	key_obj.offset = index * TF_EM_KEY_RECORD_SIZE;
+	key_obj.offset = index * TF_P4_EM_KEY_RECORD_SIZE;
 	key_obj.data = NULL;
-	key_obj.size = TF_EM_KEY_RECORD_SIZE;
+	key_obj.size = TF_P4_EM_KEY_RECORD_SIZE;
 
 	rc = hcapi_cfa_key_hw_op(&op,
 				 &key_tbl,
@@ -843,7 +847,10 @@ int
 tf_em_insert_ext_entry(struct tf *tfp __rte_unused,
 		       struct tf_insert_em_entry_parms *parms)
 {
+	int rc;
 	struct tf_tbl_scope_cb *tbl_scope_cb;
+	struct tf_session *tfs;
+	struct tf_dev_info *dev;
 
 	tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id);
 	if (tbl_scope_cb == NULL) {
@@ -851,9 +858,20 @@ tf_em_insert_ext_entry(struct tf *tfp __rte_unused,
 		return -EINVAL;
 	}
 
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc)
+		return rc;
+
 	return tf_insert_eem_entry
-		(tbl_scope_cb,
-		parms);
+		(dev,
+		 tbl_scope_cb,
+		 parms);
 }
 
 /** Delete EM hash entry API
diff --git a/drivers/net/bnxt/tf_core/tf_em_hash_internal.c b/drivers/net/bnxt/tf_core/tf_em_hash_internal.c
index 09183b42f0..f6c9772b44 100644
--- a/drivers/net/bnxt/tf_core/tf_em_hash_internal.c
+++ b/drivers/net/bnxt/tf_core/tf_em_hash_internal.c
@@ -15,6 +15,7 @@
 #include "tf_msg.h"
 #include "tfp.h"
 #include "tf_ext_flow_handle.h"
+#include "tf_device.h"
 
 #include "bnxt.h"
 
@@ -43,6 +44,18 @@ tf_em_hash_insert_int_entry(struct tf *tfp,
 	uint32_t key0_hash;
 	uint32_t key1_hash;
 	uint64_t big_hash;
+	struct tf_dev_info *dev;
+	struct tf_session *tfs;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc)
+		return rc;
 
 	rc = stack_pop(pool, &index);
 	if (rc) {
@@ -52,8 +65,11 @@ tf_em_hash_insert_int_entry(struct tf *tfp,
 		return rc;
 	}
 
-	big_hash = hcapi_cfa_key_hash((uint64_t *)parms->key,
-				      (TF_HW_EM_KEY_MAX_SIZE + 4) * 8);
+	if (dev->ops->tf_dev_cfa_key_hash == NULL)
+		return -EINVAL;
+
+	big_hash = dev->ops->tf_dev_cfa_key_hash((uint64_t *)parms->key,
+					TF_P58_HW_EM_KEY_MAX_SIZE * 8);
 	key0_hash = (uint32_t)(big_hash >> 32);
 	key1_hash = (uint32_t)(big_hash & 0xFFFFFFFF);
 
@@ -93,7 +109,7 @@ tf_em_hash_insert_int_entry(struct tf *tfp,
 	TF_SET_FIELDS_IN_FLOW_HANDLE(parms->flow_handle,
 				     (uint32_t)num_of_entries,
 				     0,
-				     0,
+				     TF_FLAGS_FLOW_HANDLE_INTERNAL,
 				     rptr_index,
 				     rptr_entry,
 				     0);
-- 
2.17.1


^ permalink raw reply	[flat|nested] 129+ messages in thread

* [dpdk-dev] [PATCH 12/58] net/bnxt: modify TRUFLOW HWRM messages
  2021-05-30  8:58 [dpdk-dev] [PATCH 00/58] enhancements to host based flow table management Venkat Duvvuru
                   ` (10 preceding siblings ...)
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 11/58] net/bnxt: add hashing changes for Thor Venkat Duvvuru
@ 2021-05-30  8:58 ` Venkat Duvvuru
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 13/58] net/bnxt: change RM database type Venkat Duvvuru
                   ` (46 subsequent siblings)
  58 siblings, 0 replies; 129+ messages in thread
From: Venkat Duvvuru @ 2021-05-30  8:58 UTC (permalink / raw)
  To: dev; +Cc: Farah Smith, Peter Spreadborough, Randy Schacher, Venkat Duvvuru

From: Farah Smith <farah.smith@broadcom.com>

- Move Bulk get to a direct HWRM message
- Deprecate code based on HCAPI changes

Signed-off-by: Farah Smith <farah.smith@broadcom.com>
Signed-off-by: Peter Spreadborough <peter.spreadborough@broadcom.com>
Signed-off-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Randy Schacher <stuart.schacher@broadcom.com>
---
 drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h        |  72 +----
 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_common.c |   4 +-
 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_defs.h   | 197 ++++++++----
 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.c     | 116 ++++---
 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.h     | 282 +----------------
 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.c    |   2 +-
 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.h    | 287 +-----------------
 drivers/net/bnxt/tf_core/hwrm_tf.h            | 196 ------------
 drivers/net/bnxt/tf_core/lookup3.h            |   2 +-
 drivers/net/bnxt/tf_core/tf_core.c            |   1 -
 drivers/net/bnxt/tf_core/tf_core.h            | 127 ++++----
 drivers/net/bnxt/tf_core/tf_device.c          |   2 +-
 drivers/net/bnxt/tf_core/tf_device_p4.h       |  75 +++--
 drivers/net/bnxt/tf_core/tf_device_p58.h      |  48 ++-
 drivers/net/bnxt/tf_core/tf_em.h              |   4 +-
 drivers/net/bnxt/tf_core/tf_em_common.c       | 250 ++++++++++-----
 drivers/net/bnxt/tf_core/tf_em_common.h       |  68 ++++-
 drivers/net/bnxt/tf_core/tf_em_host.c         | 109 +++++--
 drivers/net/bnxt/tf_core/tf_msg.c             | 263 ++++++++++++++--
 drivers/net/bnxt/tf_core/tf_msg.h             |  87 ++++++
 drivers/net/bnxt/tf_core/tf_msg_common.h      |   3 -
 drivers/net/bnxt/tf_core/tf_session.c         | 115 +++++++
 drivers/net/bnxt/tf_core/tf_session.h         |  90 ++++++
 drivers/net/bnxt/tf_core/tf_tbl.h             |  30 --
 drivers/net/bnxt/tf_core/tf_util.c            |  12 -
 drivers/net/bnxt/tf_core/tf_util.h            |   4 +
 drivers/net/bnxt/tf_core/tfp.c                |  34 ---
 drivers/net/bnxt/tf_core/tfp.h                |  52 ----
 28 files changed, 1202 insertions(+), 1330 deletions(-)
 delete mode 100644 drivers/net/bnxt/tf_core/hwrm_tf.h

diff --git a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h
index 0580e07c45..c67aa29ad0 100644
--- a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h
+++ b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h
@@ -63,74 +63,10 @@ struct hcapi_cfa_devops {
 	 */
 	uint64_t (*hcapi_cfa_key_hash)(uint64_t *key_data, uint16_t bitlen);
 
-int hcapi_cfa_action_hw_op(struct hcapi_cfa_hwop *op,
-			   uint8_t *act_tbl,
-			   struct hcapi_cfa_data *act_obj);
-int hcapi_cfa_dev_hw_op(struct hcapi_cfa_hwop *op, uint16_t tbl_id,
-			struct hcapi_cfa_data *obj_data);
-int hcapi_cfa_rm_register_client(hcapi_cfa_rm_data_t *data,
-				 const char *client_name,
-				 int *client_id);
-int hcapi_cfa_rm_unregister_client(hcapi_cfa_rm_data_t *data,
-				   int client_id);
-int hcapi_cfa_rm_query_resources(hcapi_cfa_rm_data_t *data,
-				 int client_id,
-				 uint16_t chnl_id,
-				 struct hcapi_cfa_resc_req_db *req_db);
-int hcapi_cfa_rm_query_resources_one(hcapi_cfa_rm_data_t *data,
-				     int clien_id,
-				     struct hcapi_cfa_resc_db *resc_db);
-int hcapi_cfa_rm_reserve_resources(hcapi_cfa_rm_data_t *data,
-				   int client_id,
-				   struct hcapi_cfa_resc_req_db *resc_req,
-				   struct hcapi_cfa_resc_db *resc_db);
-int hcapi_cfa_rm_release_resources(hcapi_cfa_rm_data_t *data,
-				   int client_id,
-				   struct hcapi_cfa_resc_req_db *resc_req,
-				   struct hcapi_cfa_resc_db *resc_db);
-int hcapi_cfa_rm_initialize(hcapi_cfa_rm_data_t *data);
-
-#if SUPPORT_CFA_HW_P4
-
-int hcapi_cfa_p4_dev_hw_op(struct hcapi_cfa_hwop *op, uint16_t tbl_id,
-			    struct hcapi_cfa_data *obj_data);
-int hcapi_cfa_p4_prof_l2ctxt_hwop(struct hcapi_cfa_hwop *op,
-				   struct hcapi_cfa_data *obj_data);
-int hcapi_cfa_p4_prof_l2ctxtrmp_hwop(struct hcapi_cfa_hwop *op,
-				      struct hcapi_cfa_data *obj_data);
-int hcapi_cfa_p4_prof_tcam_hwop(struct hcapi_cfa_hwop *op,
-				 struct hcapi_cfa_data *obj_data);
-int hcapi_cfa_p4_prof_tcamrmp_hwop(struct hcapi_cfa_hwop *op,
-				    struct hcapi_cfa_data *obj_data);
-int hcapi_cfa_p4_wc_tcam_hwop(struct hcapi_cfa_hwop *op,
-			       struct hcapi_cfa_data *obj_data);
-int hcapi_cfa_p4_wc_tcam_rec_hwop(struct hcapi_cfa_hwop *op,
-				   struct hcapi_cfa_data *obj_data);
-int hcapi_cfa_p4_mirror_hwop(struct hcapi_cfa_hwop *op,
-			     struct hcapi_cfa_data *mirror);
-int hcapi_cfa_p4_global_cfg_hwop(struct hcapi_cfa_hwop *op,
-				 uint32_t type,
-				 struct hcapi_cfa_data *config);
-/* SUPPORT_CFA_HW_P4 */
-#elif SUPPORT_CFA_HW_P45
-int hcapi_cfa_p45_mirror_hwop(struct hcapi_cfa_hwop *op,
-			      struct hcapi_cfa_data *mirror);
-int hcapi_cfa_p45_global_cfg_hwop(struct hcapi_cfa_hwop *op,
-				  uint32_t type,
-				  struct hcapi_cfa_data *config);
-/* SUPPORT_CFA_HW_P45 */
-#endif
-
-/**
- *  HCAPI CFA device HW operation function callback definition
- *  This is standardized function callback hook to install different
- *  CFA HW table programming function callback.
- */
-
-struct hcapi_cfa_tbl_cb {
-	/**
-	 * This function callback provides the functionality to read/write
-	 * HW table entry from a HW table.
+	/** hardware operation on the CFA EM key
+	 *
+	 * This API provides the functionality to program the exact match and
+	 * key data to exact match record memory.
 	 *
 	 * @param[in] op
 	 *   A pointer to the Hardware operation parameter
diff --git a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_common.c b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_common.c
index fc96e3bff7..93a9f555df 100644
--- a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_common.c
+++ b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_common.c
@@ -3,9 +3,7 @@
  *   All rights reserved.
  */
 
-#include "hcapi_cfa_defs.h"
-#include <errno.h>
-#include "assert.h"
+#include "hcapi_cfa.h"
 
 const uint32_t crc32tbl[] = {	/* CRC polynomial 0xedb88320 */
 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
diff --git a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_defs.h b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_defs.h
index 579f1d5693..5135a857e1 100644
--- a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_defs.h
+++ b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_defs.h
@@ -1,7 +1,6 @@
-
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2014-2021 Broadcom
- * All rights reserved.
+/*
+ *   Copyright(c) Broadcom Limited.
+ *   All rights reserved.
  */
 
 /*!
@@ -14,27 +13,54 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdbool.h>
-#include <stdint.h>
 #include <stddef.h>
+#include <stdint.h>
+
+#if !defined(__GNUC__)
+#pragma anon_unions
+#endif
 
 #define CFA_BITS_PER_BYTE (8)
+#define CFA_BITS_PER_WORD (sizeof(uint32_t) * CFA_BITS_PER_BYTE)
 #define __CFA_ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask))
-#define CFA_ALIGN(x, a) __CFA_ALIGN_MASK(x, (a) - 1)
+#define CFA_ALIGN(x, a) __CFA_ALIGN_MASK((x), (a) - 1)
+#define CFA_ALIGN_256(x) CFA_ALIGN(x, 256)
 #define CFA_ALIGN_128(x) CFA_ALIGN(x, 128)
 #define CFA_ALIGN_32(x) CFA_ALIGN(x, 32)
 
-#define NUM_WORDS_ALIGN_32BIT(x)                                               \
-	(CFA_ALIGN_32(x) / (sizeof(uint32_t) * CFA_BITS_PER_BYTE))
-#define NUM_WORDS_ALIGN_128BIT(x)                                              \
-	(CFA_ALIGN_128(x) / (sizeof(uint32_t) * CFA_BITS_PER_BYTE))
+#define NUM_WORDS_ALIGN_32BIT(x) (CFA_ALIGN_32(x) / CFA_BITS_PER_WORD)
+#define NUM_WORDS_ALIGN_128BIT(x) (CFA_ALIGN_128(x) / CFA_BITS_PER_WORD)
+#define NUM_WORDS_ALIGN_256BIT(x) (CFA_ALIGN_256(x) / CFA_BITS_PER_WORD)
 
+/* TODO: redefine according to chip variant */
 #define CFA_GLOBAL_CFG_DATA_SZ (100)
 
+#ifndef SUPPORT_CFA_HW_P4
+#define SUPPORT_CFA_HW_P4 (0)
+#endif
+
+#ifndef SUPPORT_CFA_HW_P45
+#define SUPPORT_CFA_HW_P45 (0)
+#endif
+
+#ifndef SUPPORT_CFA_HW_P58
+#define SUPPORT_CFA_HW_P58 (0)
+#endif
+
 #if SUPPORT_CFA_HW_ALL
 #include "hcapi_cfa_p4.h"
 #include "hcapi_cfa_p58.h"
 #endif /* SUPPORT_CFA_HW_ALL */
 
+/*
+ * Hashing defines
+ */
+#define HCAPI_CFA_LKUP_SEED_MEM_SIZE 512
+
+/* CRC32i support for Key0 hash */
+#define ucrc32(ch, crc) (crc32tbl[((crc) ^ (ch)) & 0xff] ^ ((crc) >> 8))
+#define crc32(x, y) crc32i(~0, x, y)
+
 /**
  * CFA HW version definition
  */
@@ -54,35 +80,30 @@ enum hcapi_cfa_dir {
 	HCAPI_CFA_DIR_MAX = 2
 };
 
-/*
- * Hashing defines
- */
-#define HCAPI_CFA_LKUP_SEED_MEM_SIZE 512
-
-/* CRC32i support for Key0 hash */
-#define ucrc32(ch, crc) (crc32tbl[((crc) ^ (ch)) & 0xff] ^ ((crc) >> 8))
-#define crc32(x, y) crc32i(~0, x, y)
-
-
 /**
  * CFA HW OPCODE definition
  */
 enum hcapi_cfa_hwops {
-	HCAPI_CFA_HWOPS_PUT, /**< Write to HW operation */
-	HCAPI_CFA_HWOPS_GET, /**< Read from HW operation */
-	HCAPI_CFA_HWOPS_ADD, /**< For operations which require more than simple
-			      * writes to HW, this operation is used. The
-			      * distinction with this operation when compared
-			      * to the PUT ops is that this operation is used
-			      * in conjunction with the HCAPI_CFA_HWOPS_DEL
-			      * op to remove the operations issued by the
-			      * ADD OP.
-			      */
-	HCAPI_CFA_HWOPS_DEL, /**< This issues operations to clear the hardware.
-			      * This operation is used in conjunction
-			      * with the HCAPI_CFA_HWOPS_ADD op and is the
-			      * way to undo/clear the ADD op.
-			      */
+	HCAPI_CFA_HWOPS_PUT,   /**< Write to HW operation */
+	HCAPI_CFA_HWOPS_GET,   /**< Read from HW operation */
+	HCAPI_CFA_HWOPS_ADD,   /*<
+				* For operations which require more then
+				* simple writes to HW, this operation is
+				* used.  The distinction with this operation
+				* when compared to the PUT ops is that this
+				* operation is used in conjunction with
+				* the HCAPI_CFA_HWOPS_DEL op to remove
+				* the operations issued by the ADD OP.
+				*/
+	HCAPI_CFA_HWOPS_DEL,   /*<
+				*  Beside to delete from the hardware, this
+				*   operation is also undo the add operation
+				*   performed by the HCAPI_CFA_HWOPS_ADD op.
+				*/
+	HCAPI_CFA_HWOPS_EVICT, /*< This operaton is used to evit entries from
+				*   CFA cache memories. This operation is only
+				*   applicable to tables that use CFA caches.
+				*/
 	HCAPI_CFA_HWOPS_MAX
 };
 
@@ -91,11 +112,10 @@ enum hcapi_cfa_hwops {
  */
 enum hcapi_cfa_key_ctrlops {
 	HCAPI_CFA_KEY_CTRLOPS_INSERT, /**< insert control bits */
-	HCAPI_CFA_KEY_CTRLOPS_STRIP, /**< strip control bits */
+	HCAPI_CFA_KEY_CTRLOPS_STRIP,  /**< strip control bits */
 	HCAPI_CFA_KEY_CTRLOPS_MAX
 };
 
-
 /**
  * CFA HW definition
  */
@@ -132,18 +152,23 @@ struct hcapi_cfa_data {
 	/** [in] physical offset to the HW table for the data to be
 	 *  written to.  If this is an array of registers, this is the
 	 *  index into the array of registers.  For writing keys, this
-	 *  is the byte offset into the memory where the key should be
+	 *  is the byte pointer into the memory where the key should be
 	 *  written.
 	 */
 	union {
 		uint32_t index;
 		uint32_t byte_offset;
-	} u;
+	};
 	/** [in] HW data buffer pointer */
 	uint8_t *data;
-	/** [in] HW data mask buffer pointer */
+	/** [in] HW data mask buffer pointer.
+	 *  When the CFA data is a FKB and  data_mask pointer
+	 *  is NULL, then the default mask to enable all bit will
+	 *  be used.
+	 */
 	uint8_t *data_mask;
-	/** [in] size of the HW data buffer in bytes */
+	/** [in/out] size of the HW data buffer in bytes
+	 */
 	uint16_t data_sz;
 };
 
@@ -160,35 +185,36 @@ enum hcapi_cfa_em_table_type {
 	TF_KEY1_TABLE,
 	TF_RECORD_TABLE,
 	TF_EFC_TABLE,
+	TF_ACTION_TABLE,
+	TF_EM_LKUP_TABLE,
 	TF_MAX_TABLE
 };
 
 struct hcapi_cfa_em_page_tbl {
-	uint32_t	pg_count;
-	uint32_t	pg_size;
-	void		**pg_va_tbl;
-	uint64_t	*pg_pa_tbl;
+	uint32_t pg_count;
+	uint32_t pg_size;
+	void **pg_va_tbl;
+	uint64_t *pg_pa_tbl;
 };
 
 struct hcapi_cfa_em_table {
-	int				type;
-	uint32_t			num_entries;
-	uint16_t			ctx_id;
-	uint32_t			entry_size;
-	int				num_lvl;
-	uint32_t			page_cnt[TF_PT_LVL_MAX];
-	uint64_t			num_data_pages;
-	void				*l0_addr;
-	uint64_t			l0_dma_addr;
-	struct hcapi_cfa_em_page_tbl    pg_tbl[TF_PT_LVL_MAX];
+	int type;
+	uint32_t num_entries;
+	uint16_t ctx_id;
+	uint32_t entry_size;
+	int num_lvl;
+	uint32_t page_cnt[TF_PT_LVL_MAX];
+	uint64_t num_data_pages;
+	void *l0_addr;
+	uint64_t l0_dma_addr;
+	struct hcapi_cfa_em_page_tbl pg_tbl[TF_PT_LVL_MAX];
 };
 
 struct hcapi_cfa_em_ctx_mem_info {
-	struct hcapi_cfa_em_table		em_tables[TF_MAX_TABLE];
+	struct hcapi_cfa_em_table em_tables[TF_MAX_TABLE];
 };
 
 /*********************** Truflow end ****************************/
-
 /**
  * CFA HW key table definition
  *
@@ -210,6 +236,10 @@ struct hcapi_cfa_key_tbl {
 	 *  applicable for newer chip
 	 */
 	uint8_t *base1;
+	/** [in] Optional - If the table is managed by a Backing Store
+	 *  database, then this object can be use to configure the EM Key.
+	 */
+	struct hcapi_cfa_bs_db *bs_db;
 	/** [in] Page size for EEM tables */
 	uint32_t page_size;
 };
@@ -220,7 +250,7 @@ struct hcapi_cfa_key_tbl {
 struct hcapi_cfa_key_obj {
 	/** [in] pointer to the key data buffer */
 	uint32_t *data;
-	/** [in] buffer len in bits */
+	/** [in] buffer len in bytes */
 	uint32_t len;
 	/** [in] Pointer to the key layout */
 	struct hcapi_cfa_key_layout *layout;
@@ -239,6 +269,13 @@ struct hcapi_cfa_key_data {
 	uint8_t *data;
 	/** [in] size of the key in bytes */
 	uint16_t size;
+	/** [in] optional table scope ID */
+	uint8_t tbl_scope;
+	/** [in] the fid owner of the key */
+	uint64_t metadata;
+	/** [in] stored with the bucket which can be used to by
+	 *       the caller to retreved later via the GET HW OP.
+	 */
 };
 
 /**
@@ -247,8 +284,52 @@ struct hcapi_cfa_key_data {
 struct hcapi_cfa_key_loc {
 	/** [out] on-chip EM bucket offset or off-chip EM bucket mem pointer */
 	uint64_t bucket_mem_ptr;
+	/** [out] off-chip EM key offset mem pointer */
+	uint64_t mem_ptr;
+	/** [out] index within the array of the EM buckets */
+	uint32_t bucket_mem_idx;
 	/** [out] index within the EM bucket */
 	uint8_t bucket_idx;
+	/** [out] index within the EM records */
+	uint32_t mem_idx;
+};
+
+/**
+ *  Action record info
+ */
+struct hcapi_cfa_action_addr {
+	/** [in] action SRAM block ID for on-chip action records or table
+	 *  scope of the action backing store
+	 */
+	uint16_t blk_id;
+	/** [in] ar_id or cache line aligned address offset for the action
+	 *  record
+	 */
+	uint32_t offset;
+};
+
+/**
+ * Action data definition
+ */
+struct hcapi_cfa_action_data {
+	/** [in] action record addr info for on-chip action records */
+	struct hcapi_cfa_action_addr addr;
+	/** [in/out] pointer to the action data buffer */
+	uint32_t *data;
+	/** [in] action data buffer len in bytes */
+	uint32_t len;
+};
+
+/**
+ * Action object definition
+ */
+struct hcapi_cfa_action_obj {
+	/** [in] pointer to the action data buffer */
+	uint32_t *data;
+	/** [in] buffer len in bytes */
+	uint32_t len;
+	/** [in] pointer to the action layout */
+	struct hcapi_cfa_action_layout *layout;
 };
 
 /**
diff --git a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.c b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.c
index 0544b667dd..79bc569989 100644
--- a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.c
+++ b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.c
@@ -1,8 +1,9 @@
+
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2019-2021 Broadcom
  * All rights reserved.
  */
-#include <inttypes.h>
+
 #include <stdint.h>
 #include <stdlib.h>
 #include <stdbool.h>
@@ -10,6 +11,7 @@
 #include "lookup3.h"
 #include "rand.h"
 
+#include "hcapi_cfa.h"
 #include "hcapi_cfa_defs.h"
 
 static uint32_t hcapi_cfa_lkup_lkup3_init_cfg;
@@ -18,10 +20,9 @@ static bool hcapi_cfa_lkup_init;
 
 extern const uint32_t crc32tbl[];
 
-static inline uint32_t SWAP_WORDS32(uint32_t val32)
+static __inline uint32_t SWAP_WORDS32(uint32_t val32)
 {
-	return (((val32 & 0x0000ffff) << 16) |
-		((val32 & 0xffff0000) >> 16));
+	return (((val32 & 0x0000ffff) << 16) | ((val32 & 0xffff0000) >> 16));
 }
 
 static void hcapi_cfa_seeds_init(void)
@@ -79,9 +80,8 @@ static uint32_t hcapi_cfa_crc32_hash(uint8_t *key)
 	if (!(val2 & 0x1))
 		val1 = hcapi_cfa_crc32i(~val1, temp, 4);
 
-	val1 = hcapi_cfa_crc32i(~val1,
-		      (key - (CFA_P4_EEM_KEY_MAX_SIZE - 1)),
-		      CFA_P4_EEM_KEY_MAX_SIZE);
+	val1 = hcapi_cfa_crc32i(~val1, (key - (CFA_P4_EEM_KEY_MAX_SIZE - 1)),
+				CFA_P4_EEM_KEY_MAX_SIZE);
 
 	/* End with seed */
 	if (val2 & 0x1)
@@ -94,16 +94,14 @@ static uint32_t hcapi_cfa_lookup3_hash(uint8_t *in_key)
 {
 	uint32_t val1;
 
-	val1 = hashword(((const uint32_t *)(uintptr_t *)in_key) + 1,
-			 CFA_P4_EEM_KEY_MAX_SIZE / (sizeof(uint32_t)),
-			 hcapi_cfa_lkup_lkup3_init_cfg);
+	val1 = hashword(((uint32_t *)in_key) + 1,
+			CFA_P4_EEM_KEY_MAX_SIZE / (sizeof(uint32_t)),
+			hcapi_cfa_lkup_lkup3_init_cfg);
 
 	return val1;
 }
 
-
-uint64_t hcapi_get_table_page(struct hcapi_cfa_em_table *mem,
-			      uint32_t page)
+uint64_t hcapi_get_table_page(struct hcapi_cfa_em_table *mem, uint32_t page)
 {
 	int level = 0;
 	uint64_t addr;
@@ -116,7 +114,7 @@ uint64_t hcapi_get_table_page(struct hcapi_cfa_em_table *mem,
 	 */
 	level = mem->num_lvl - 1;
 
-	addr = (uintptr_t)mem->pg_tbl[level].pg_va_tbl[page];
+	addr = (uint64_t)mem->pg_tbl[level].pg_va_tbl[page];
 
 	return addr;
 }
@@ -138,42 +136,39 @@ uint64_t hcapi_cfa_p4_key_hash(uint64_t *key_data,
 	if (!hcapi_cfa_lkup_init)
 		hcapi_cfa_seeds_init();
 
-	key0_hash = hcapi_cfa_crc32_hash(((uint8_t *)key_data) +
-					      (bitlen / 8) - 1);
+	key0_hash =
+		hcapi_cfa_crc32_hash(((uint8_t *)key_data) + (bitlen / 8) - 1);
 
 	key1_hash = hcapi_cfa_lookup3_hash((uint8_t *)key_data);
 
 	return ((uint64_t)key0_hash) << 32 | (uint64_t)key1_hash;
 }
 
-static int hcapi_cfa_key_hw_op_put(struct hcapi_cfa_hwop *op,
-				   struct hcapi_cfa_key_data *key_obj)
+static int hcapi_cfa_p4_key_hw_op_put(struct hcapi_cfa_hwop *op,
+				      struct hcapi_cfa_key_data *key_obj)
 {
 	int rc = 0;
 
-	memcpy((uint8_t *)(uintptr_t)op->hw.base_addr +
-	       key_obj->offset,
-	       key_obj->data,
-	       key_obj->size);
+	memcpy((uint8_t *)(uintptr_t)op->hw.base_addr + key_obj->offset,
+	       key_obj->data, key_obj->size);
 
 	return rc;
 }
 
-static int hcapi_cfa_key_hw_op_get(struct hcapi_cfa_hwop *op,
-				   struct hcapi_cfa_key_data *key_obj)
+static int hcapi_cfa_p4_key_hw_op_get(struct hcapi_cfa_hwop *op,
+				      struct hcapi_cfa_key_data *key_obj)
 {
 	int rc = 0;
 
 	memcpy(key_obj->data,
-	       (uint8_t *)(uintptr_t)op->hw.base_addr +
-	       key_obj->offset,
+	       (uint8_t *)(uintptr_t)op->hw.base_addr + key_obj->offset,
 	       key_obj->size);
 
 	return rc;
 }
 
-static int hcapi_cfa_key_hw_op_add(struct hcapi_cfa_hwop *op,
-				   struct hcapi_cfa_key_data *key_obj)
+static int hcapi_cfa_p4_key_hw_op_add(struct hcapi_cfa_hwop *op,
+				      struct hcapi_cfa_key_data *key_obj)
 {
 	int rc = 0;
 	struct cfa_p4_eem_64b_entry table_entry;
@@ -182,8 +177,7 @@ static int hcapi_cfa_key_hw_op_add(struct hcapi_cfa_hwop *op,
 	 * Is entry free?
 	 */
 	memcpy(&table_entry,
-	       (uint8_t *)(uintptr_t)op->hw.base_addr +
-	       key_obj->offset,
+	       (uint8_t *)(uintptr_t)op->hw.base_addr + key_obj->offset,
 	       key_obj->size);
 
 	/*
@@ -192,16 +186,14 @@ static int hcapi_cfa_key_hw_op_add(struct hcapi_cfa_hwop *op,
 	if (table_entry.hdr.word1 & (1 << CFA_P4_EEM_ENTRY_VALID_SHIFT))
 		return -1;
 
-	memcpy((uint8_t *)(uintptr_t)op->hw.base_addr +
-	       key_obj->offset,
-	       key_obj->data,
-	       key_obj->size);
+	memcpy((uint8_t *)(uintptr_t)op->hw.base_addr + key_obj->offset,
+	       key_obj->data, key_obj->size);
 
 	return rc;
 }
 
-static int hcapi_cfa_key_hw_op_del(struct hcapi_cfa_hwop *op,
-				   struct hcapi_cfa_key_data *key_obj)
+static int hcapi_cfa_p4_key_hw_op_del(struct hcapi_cfa_hwop *op,
+				      struct hcapi_cfa_key_data *key_obj)
 {
 	int rc = 0;
 	struct cfa_p4_eem_64b_entry table_entry;
@@ -210,8 +202,7 @@ static int hcapi_cfa_key_hw_op_del(struct hcapi_cfa_hwop *op,
 	 * Read entry
 	 */
 	memcpy(&table_entry,
-	       (uint8_t *)(uintptr_t)op->hw.base_addr +
-	       key_obj->offset,
+	       (uint8_t *)(uintptr_t)op->hw.base_addr + key_obj->offset,
 	       key_obj->size);
 
 	/*
@@ -223,8 +214,7 @@ static int hcapi_cfa_key_hw_op_del(struct hcapi_cfa_hwop *op,
 		 * before deleting the entry.
 		 */
 		if (key_obj->data != NULL) {
-			if (memcmp(&table_entry,
-				   key_obj->data,
+			if (memcmp(&table_entry, key_obj->data,
 				   key_obj->size) != 0)
 				return -1;
 		}
@@ -232,40 +222,33 @@ static int hcapi_cfa_key_hw_op_del(struct hcapi_cfa_hwop *op,
 		return -1;
 	}
 
-
 	/*
 	 * Delete entry
 	 */
-	memset((uint8_t *)(uintptr_t)op->hw.base_addr +
-	       key_obj->offset,
-	       0,
-	       key_obj->size);
+	memset((uint8_t *)(uintptr_t)op->hw.base_addr + key_obj->offset, 0, key_obj->size);
 
 	return rc;
 }
 
-
 /** Apporiximation of hcapi_cfa_key_hw_op()
  *
  *
  */
-int hcapi_cfa_key_hw_op(struct hcapi_cfa_hwop *op,
-			struct hcapi_cfa_key_tbl *key_tbl,
-			struct hcapi_cfa_key_data *key_obj,
-			struct hcapi_cfa_key_loc *key_loc)
+static int hcapi_cfa_p4_key_hw_op(struct hcapi_cfa_hwop *op,
+				  struct hcapi_cfa_key_tbl *key_tbl,
+				  struct hcapi_cfa_key_data *key_obj,
+				  struct hcapi_cfa_key_loc *key_loc)
 {
 	int rc = 0;
+	struct hcapi_cfa_em_table *em_tbl;
+	uint32_t page;
 
-	if (op == NULL ||
-	    key_tbl == NULL ||
-	    key_obj == NULL ||
-	    key_loc == NULL)
+	if (op == NULL || key_tbl == NULL || key_obj == NULL || key_loc == NULL)
 		return -1;
 
-	op->hw.base_addr =
-		hcapi_get_table_page((struct hcapi_cfa_em_table *)
-				     key_tbl->base0,
-				     key_obj->offset / key_tbl->page_size);
+	page = key_obj->offset / key_tbl->page_size;
+	em_tbl = (struct hcapi_cfa_em_table *)key_tbl->base0;
+	op->hw.base_addr = hcapi_get_table_page(em_tbl, page);
 	/* Offset is adjusted to be the offset into the page */
 	key_obj->offset = key_obj->offset % key_tbl->page_size;
 
@@ -274,14 +257,14 @@ int hcapi_cfa_key_hw_op(struct hcapi_cfa_hwop *op,
 
 	switch (op->opcode) {
 	case HCAPI_CFA_HWOPS_PUT: /**< Write to HW operation */
-		rc = hcapi_cfa_key_hw_op_put(op, key_obj);
+		rc = hcapi_cfa_p4_key_hw_op_put(op, key_obj);
 		break;
 	case HCAPI_CFA_HWOPS_GET: /**< Read from HW operation */
-		rc = hcapi_cfa_key_hw_op_get(op, key_obj);
+		rc = hcapi_cfa_p4_key_hw_op_get(op, key_obj);
 		break;
 	case HCAPI_CFA_HWOPS_ADD:
-		/**< For operations which require more than
-		 * simple writes to HW, this operation is used. The
+		/**< For operations which require more then simple
+		 * writes to HW, this operation is used.  The
 		 * distinction with this operation when compared
 		 * to the PUT ops is that this operation is used
 		 * in conjunction with the HCAPI_CFA_HWOPS_DEL
@@ -289,11 +272,11 @@ int hcapi_cfa_key_hw_op(struct hcapi_cfa_hwop *op,
 		 * ADD OP.
 		 */
 
-		rc = hcapi_cfa_key_hw_op_add(op, key_obj);
+		rc = hcapi_cfa_p4_key_hw_op_add(op, key_obj);
 
 		break;
 	case HCAPI_CFA_HWOPS_DEL:
-		rc = hcapi_cfa_key_hw_op_del(op, key_obj);
+		rc = hcapi_cfa_p4_key_hw_op_del(op, key_obj);
 		break;
 	default:
 		rc = -1;
@@ -302,3 +285,8 @@ int hcapi_cfa_key_hw_op(struct hcapi_cfa_hwop *op,
 
 	return rc;
 }
+
+const struct hcapi_cfa_devops cfa_p4_devops = {
+	.hcapi_cfa_key_hash = hcapi_cfa_p4_key_hash,
+	.hcapi_cfa_key_hw_op = hcapi_cfa_p4_key_hw_op,
+};
diff --git a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.h b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.h
index 74a5483c0b..363ffcd57c 100644
--- a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.h
+++ b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.h
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2014-2021 Broadcom
+ * Copyright(c) 2019-2021 Broadcom
  * All rights reserved.
  */
 
@@ -44,286 +44,6 @@ struct cfa_p4_prof_key_cfg {
 	enum cfa_p4_mac_sel_mode mode;
 };
 
-/**
- * CFA action layout definition
- */
-
-#define CFA_P4_ACTION_MAX_LAYOUT_SIZE 184
-
-/**
- * Action object template structure
- *
- * Template structure presents data fields that are necessary to know
- * at the beginning of Action Builder (AB) processing. Like before the
- * AB compilation. One such example could be a template that is
- * flexible in size (Encap Record) and the presence of these fields
- * allows for determining the template size as well as where the
- * fields are located in the record.
- *
- * The template may also present fields that are not made visible to
- * the caller by way of the action fields.
- *
- * Template fields also allow for additional checking on user visible
- * fields. One such example could be the encap pointer behavior on a
- * CFA_P4_ACT_OBJ_TYPE_ACT or CFA_P4_ACT_OBJ_TYPE_ACT_SRAM.
- */
-struct cfa_p4_action_template {
-	/** Action Object type
-	 *
-	 * Controls the type of the Action Template
-	 */
-	enum {
-		/** Select this type to build an Action Record Object
-		 */
-		CFA_P4_ACT_OBJ_TYPE_ACT,
-		/** Select this type to build an Action Statistics
-		 * Object
-		 */
-		CFA_P4_ACT_OBJ_TYPE_STAT,
-		/** Select this type to build a SRAM Action Record
-		 * Object.
-		 */
-		CFA_P4_ACT_OBJ_TYPE_ACT_SRAM,
-		/** Select this type to build a SRAM Action
-		 * Encapsulation Object.
-		 */
-		CFA_P4_ACT_OBJ_TYPE_ENCAP_SRAM,
-		/** Select this type to build a SRAM Action Modify
-		 * Object, with IPv4 capability.
-		 */
-		/* In case of Stingray the term Modify is used for the 'NAT
-		 * action'. Action builder is leveraged to fill in the NAT
-		 * object which then can be referenced by the action
-		 * record.
-		 */
-		CFA_P4_ACT_OBJ_TYPE_MODIFY_IPV4_SRAM,
-		/** Select this type to build a SRAM Action Source
-		 * Property Object.
-		 */
-		/* In case of Stingray this is not a 'pure' action record.
-		 * Action builder is leveraged to full in the Source Property
-		 * object which can then be referenced by the action
-		 * record.
-		 */
-		CFA_P4_ACT_OBJ_TYPE_SRC_PROP_SRAM,
-		/** Select this type to build a SRAM Action Statistics
-		 * Object
-		 */
-		CFA_P4_ACT_OBJ_TYPE_STAT_SRAM,
-	} obj_type;
-
-	/** Action Control
-	 *
-	 * Controls the internals of the Action Template
-	 *
-	 * act is valid when:
-	 * (obj_type == CFA_P4_ACT_OBJ_TYPE_ACT)
-	 */
-	/*
-	 * Stat and encap are always inline for EEM as table scope
-	 * allocation does not allow for separate Stats allocation,
-	 * but has the xx_inline flags as to be forward compatible
-	 * with Stingray 2, always treated as TRUE.
-	 */
-	struct {
-		/** Set to CFA_HCAPI_TRUE to enable statistics
-		 */
-		uint8_t stat_enable;
-		/** Set to CFA_HCAPI_TRUE to enable statistics to be inlined
-		 */
-		uint8_t stat_inline;
-
-		/** Set to CFA_HCAPI_TRUE to enable encapsulation
-		 */
-		uint8_t encap_enable;
-		/** Set to CFA_HCAPI_TRUE to enable encapsulation to be inlined
-		 */
-		uint8_t encap_inline;
-	} act;
-
-	/** Modify Setting
-	 *
-	 * Controls the type of the Modify Action the template is
-	 * describing
-	 *
-	 * modify is valid when:
-	 * (obj_type == CFA_P4_ACT_OBJ_TYPE_MODIFY_SRAM)
-	 */
-	enum {
-		/** Set to enable Modify of Source IPv4 Address
-		 */
-		CFA_P4_MR_REPLACE_SOURCE_IPV4 = 0,
-		/** Set to enable Modify of Destination IPv4 Address
-		 */
-		CFA_P4_MR_REPLACE_DEST_IPV4
-	} modify;
-
-	/** Encap Control
-	 * Controls the type of encapsulation the template is
-	 * describing
-	 *
-	 * encap is valid when:
-	 * ((obj_type == CFA_P4_ACT_OBJ_TYPE_ACT) &&
-	 *   act.encap_enable) ||
-	 * ((obj_type == CFA_P4_ACT_OBJ_TYPE_SRC_PROP_SRAM)
-	 */
-	struct {
-		/* Direction is required as Stingray Encap on RX is
-		 * limited to l2 and VTAG only.
-		 */
-		/** Receive or Transmit direction
-		 */
-		uint8_t direction;
-		/** Set to CFA_HCAPI_TRUE to enable L2 capability in the
-		 *  template
-		 */
-		uint8_t l2_enable;
-		/** vtag controls the Encap Vector - VTAG Encoding, 4 bits
-		 *
-		 * <ul>
-		 * <li> CFA_P4_ACT_ENCAP_VTAGS_PUSH_0, default, no VLAN
-		 *      Tags applied
-		 * <li> CFA_P4_ACT_ENCAP_VTAGS_PUSH_1, adds capability to
-		 *      set 1 VLAN Tag. Action Template compile adds
-		 *      the following field to the action object
-		 *      ::TF_ER_VLAN1
-		 * <li> CFA_P4_ACT_ENCAP_VTAGS_PUSH_2, adds capability to
-		 *      set 2 VLAN Tags. Action Template compile adds
-		 *      the following fields to the action object
-		 *      ::TF_ER_VLAN1 and ::TF_ER_VLAN2
-		 * </ul>
-		 */
-		enum { CFA_P4_ACT_ENCAP_VTAGS_PUSH_0 = 0,
-		       CFA_P4_ACT_ENCAP_VTAGS_PUSH_1,
-		       CFA_P4_ACT_ENCAP_VTAGS_PUSH_2 } vtag;
-
-		/*
-		 * The remaining fields are NOT supported when
-		 * direction is RX and ((obj_type ==
-		 * CFA_P4_ACT_OBJ_TYPE_ACT) && act.encap_enable).
-		 * ab_compile_layout will perform the checking and
-		 * skip remaining fields.
-		 */
-		/** L3 Encap controls the Encap Vector - L3 Encoding,
-		 *  3 bits. Defines the type of L3 Encapsulation the
-		 *  template is describing.
-		 * <ul>
-		 * <li> CFA_P4_ACT_ENCAP_L3_NONE, default, no L3
-		 *      Encapsulation processing.
-		 * <li> CFA_P4_ACT_ENCAP_L3_IPV4, enables L3 IPv4
-		 *      Encapsulation.
-		 * <li> CFA_P4_ACT_ENCAP_L3_IPV6, enables L3 IPv6
-		 *      Encapsulation.
-		 * <li> CFA_P4_ACT_ENCAP_L3_MPLS_8847, enables L3 MPLS
-		 *      8847 Encapsulation.
-		 * <li> CFA_P4_ACT_ENCAP_L3_MPLS_8848, enables L3 MPLS
-		 *      8848 Encapsulation.
-		 * </ul>
-		 */
-		enum {
-			/** Set to disable any L3 encapsulation
-			 * processing, default
-			 */
-			CFA_P4_ACT_ENCAP_L3_NONE = 0,
-			/** Set to enable L3 IPv4 encapsulation
-			 */
-			CFA_P4_ACT_ENCAP_L3_IPV4 = 4,
-			/** Set to enable L3 IPv6 encapsulation
-			 */
-			CFA_P4_ACT_ENCAP_L3_IPV6 = 5,
-			/** Set to enable L3 MPLS 8847 encapsulation
-			 */
-			CFA_P4_ACT_ENCAP_L3_MPLS_8847 = 6,
-			/** Set to enable L3 MPLS 8848 encapsulation
-			 */
-			CFA_P4_ACT_ENCAP_L3_MPLS_8848 = 7
-		} l3;
-
-#define CFA_P4_ACT_ENCAP_MAX_MPLS_LABELS 8
-		/** 1-8 labels, valid when
-		 * (l3 == CFA_P4_ACT_ENCAP_L3_MPLS_8847) ||
-		 * (l3 == CFA_P4_ACT_ENCAP_L3_MPLS_8848)
-		 *
-		 * MAX number of MPLS Labels 8.
-		 */
-		uint8_t l3_num_mpls_labels;
-
-		/** Set to CFA_HCAPI_TRUE to enable L4 capability in the
-		 * template.
-		 *
-		 * CFA_HCAPI_TRUE adds ::TF_EN_UDP_SRC_PORT and
-		 * ::TF_EN_UDP_DST_PORT to the template.
-		 */
-		uint8_t l4_enable;
-
-		/** Tunnel Encap controls the Encap Vector - Tunnel
-		 *  Encap, 3 bits. Defines the type of Tunnel
-		 *  encapsulation the template is describing
-		 * <ul>
-		 * <li> CFA_P4_ACT_ENCAP_TNL_NONE, default, no Tunnel
-		 *      Encapsulation processing.
-		 * <li> CFA_P4_ACT_ENCAP_TNL_GENERIC_FULL
-		 * <li> CFA_P4_ACT_ENCAP_TNL_VXLAN. NOTE: Expects
-		 *      l4_enable set to CFA_P4_TRUE;
-		 * <li> CFA_P4_ACT_ENCAP_TNL_NGE. NOTE: Expects l4_enable
-		 *      set to CFA_P4_TRUE;
-		 * <li> CFA_P4_ACT_ENCAP_TNL_NVGRE. NOTE: only valid if
-		 *      l4_enable set to CFA_HCAPI_FALSE.
-		 * <li> CFA_P4_ACT_ENCAP_TNL_GRE.NOTE: only valid if
-		 *      l4_enable set to CFA_HCAPI_FALSE.
-		 * <li> CFA_P4_ACT_ENCAP_TNL_GENERIC_AFTER_TL4
-		 * <li> CFA_P4_ACT_ENCAP_TNL_GENERIC_AFTER_TNL
-		 * </ul>
-		 */
-		enum {
-			/** Set to disable Tunnel header encapsulation
-			 * processing, default
-			 */
-			CFA_P4_ACT_ENCAP_TNL_NONE = 0,
-			/** Set to enable Tunnel Generic Full header
-			 * encapsulation
-			 */
-			CFA_P4_ACT_ENCAP_TNL_GENERIC_FULL,
-			/** Set to enable VXLAN header encapsulation
-			 */
-			CFA_P4_ACT_ENCAP_TNL_VXLAN,
-			/** Set to enable NGE (VXLAN2) header encapsulation
-			 */
-			CFA_P4_ACT_ENCAP_TNL_NGE,
-			/** Set to enable NVGRE header encapsulation
-			 */
-			CFA_P4_ACT_ENCAP_TNL_NVGRE,
-			/** Set to enable GRE header encapsulation
-			 */
-			CFA_P4_ACT_ENCAP_TNL_GRE,
-			/** Set to enable Generic header after Tunnel
-			 * L4 encapsulation
-			 */
-			CFA_P4_ACT_ENCAP_TNL_GENERIC_AFTER_TL4,
-			/** Set to enable Generic header after Tunnel
-			 * encapsulation
-			 */
-			CFA_P4_ACT_ENCAP_TNL_GENERIC_AFTER_TNL
-		} tnl;
-
-		/** Number of bytes of generic tunnel header,
-		 * valid when
-		 * (tnl == CFA_P4_ACT_ENCAP_TNL_GENERIC_FULL) ||
-		 * (tnl == CFA_P4_ACT_ENCAP_TNL_GENERIC_AFTER_TL4) ||
-		 * (tnl == CFA_P4_ACT_ENCAP_TNL_GENERIC_AFTER_TNL)
-		 */
-		uint8_t tnl_generic_size;
-		/** Number of 32b words of nge options,
-		 * valid when
-		 * (tnl == CFA_P4_ACT_ENCAP_TNL_NGE)
-		 */
-		uint8_t tnl_nge_op_len;
-		/* Currently not planned */
-		/* Custom Header */
-		/*	uint8_t custom_enable; */
-	} encap;
-};
-
 /**
  * Enumeration of SRAM entry types, used for allocation of
  * fixed SRAM entities. The memory model for CFA HCAPI
diff --git a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.c b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.c
index 723b8393b9..a70c6f4eaa 100644
--- a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.c
+++ b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.c
@@ -88,7 +88,7 @@ static uint32_t hcapi_cfa_lookup3_hash(uint8_t *in_key)
 {
 	uint32_t val1;
 
-	val1 = hashword(((uint32_t *)in_key) + 1,
+	val1 = hashword(((uint32_t *)in_key),
 			 CFA_P58_EEM_KEY_MAX_SIZE / (sizeof(uint32_t)),
 			 hcapi_cfa_lkup_lkup3_init_cfg);
 
diff --git a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.h b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.h
index 27796b1b2f..d272d3ffec 100644
--- a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.h
+++ b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.h
@@ -12,6 +12,11 @@
 #define CFA_P58_EEM_KEY_MAX_SIZE 80
 #define CFA_P58_EEM_KEY_RECORD_SIZE 80
 
+#define CFA_P58_EM_FKB_NUM_WORDS 4
+#define CFA_P58_EM_FKB_NUM_ENTRIES 64
+#define CFA_P58_WC_TCAM_FKB_NUM_WORDS 4
+#define CFA_P58_WC_TCAM_FKB_NUM_ENTRIES 64
+
 /** CFA phase 5.8 fix formatted table(layout) ID definition
  *
  */
@@ -29,7 +34,7 @@ enum cfa_p58_tbl_id {
 	CFA_P58_TBL_PROF_PARIF_DFLT_ACT_REC_PTR,
 	/** Error Profile TCAM Miss Action Record Pointer Table */
 	CFA_P58_TBL_PROF_PARIF_ERR_ACT_REC_PTR,
-	/** SR2 VNIC/SVIF Properties Table */
+	/** VNIC/SVIF Properties Table */
 	CFA_P58_TBL_VSPT,
 	CFA_P58_TBL_MAX
 };
@@ -56,286 +61,6 @@ struct cfa_p58_prof_key_cfg {
 	enum cfa_p58_mac_sel_mode mode;
 };
 
-/**
- * CFA action layout definition
- */
-
-#define CFA_P58_ACTION_MAX_LAYOUT_SIZE 184
-
-/**
- * Action object template structure
- *
- * Template structure presents data fields that are necessary to know
- * at the beginning of Action Builder (AB) processing. Like before the
- * AB compilation. One such example could be a template that is
- * flexible in size (Encap Record) and the presence of these fields
- * allows for determining the template size as well as where the
- * fields are located in the record.
- *
- * The template may also present fields that are not made visible to
- * the caller by way of the action fields.
- *
- * Template fields also allow for additional checking on user visible
- * fields. One such example could be the encap pointer behavior on a
- * CFA_P58_ACT_OBJ_TYPE_ACT or CFA_P58_ACT_OBJ_TYPE_ACT_SRAM.
- */
-struct cfa_p58_action_template {
-	/** Action Object type
-	 *
-	 * Controls the type of the Action Template
-	 */
-	enum {
-		/** Select this type to build an Action Record Object
-		 */
-		CFA_P58_ACT_OBJ_TYPE_ACT,
-		/** Select this type to build an Action Statistics
-		 * Object
-		 */
-		CFA_P58_ACT_OBJ_TYPE_STAT,
-		/** Select this type to build a SRAM Action Record
-		 * Object.
-		 */
-		CFA_P58_ACT_OBJ_TYPE_ACT_SRAM,
-		/** Select this type to build a SRAM Action
-		 * Encapsulation Object.
-		 */
-		CFA_P58_ACT_OBJ_TYPE_ENCAP_SRAM,
-		/** Select this type to build a SRAM Action Modify
-		 * Object, with IPv4 capability.
-		 */
-		/* In case of Stingray the term Modify is used for the 'NAT
-		 * action'. Action builder is leveraged to fill in the NAT
-		 * object which then can be referenced by the action
-		 * record.
-		 */
-		CFA_P58_ACT_OBJ_TYPE_MODIFY_IPV4_SRAM,
-		/** Select this type to build a SRAM Action Source
-		 * Property Object.
-		 */
-		/* In case of Stingray this is not a 'pure' action record.
-		 * Action builder is leveraged to full in the Source Property
-		 * object which can then be referenced by the action
-		 * record.
-		 */
-		CFA_P58_ACT_OBJ_TYPE_SRC_PROP_SRAM,
-		/** Select this type to build a SRAM Action Statistics
-		 * Object
-		 */
-		CFA_P58_ACT_OBJ_TYPE_STAT_SRAM,
-	} obj_type;
-
-	/** Action Control
-	 *
-	 * Controls the internals of the Action Template
-	 *
-	 * act is valid when:
-	 * (obj_type == CFA_P58_ACT_OBJ_TYPE_ACT)
-	 */
-	/*
-	 * Stat and encap are always inline for EEM as table scope
-	 * allocation does not allow for separate Stats allocation,
-	 * but has the xx_inline flags as to be forward compatible
-	 * with Stingray 2, always treated as TRUE.
-	 */
-	struct {
-		/** Set to CFA_HCAPI_TRUE to enable statistics
-		 */
-		uint8_t stat_enable;
-		/** Set to CFA_HCAPI_TRUE to enable statistics to be inlined
-		 */
-		uint8_t stat_inline;
-
-		/** Set to CFA_HCAPI_TRUE to enable encapsulation
-		 */
-		uint8_t encap_enable;
-		/** Set to CFA_HCAPI_TRUE to enable encapsulation to be inlined
-		 */
-		uint8_t encap_inline;
-	} act;
-
-	/** Modify Setting
-	 *
-	 * Controls the type of the Modify Action the template is
-	 * describing
-	 *
-	 * modify is valid when:
-	 * (obj_type == CFA_P58_ACT_OBJ_TYPE_MODIFY_SRAM)
-	 */
-	enum {
-		/** Set to enable Modify of Source IPv4 Address
-		 */
-		CFA_P58_MR_REPLACE_SOURCE_IPV4 = 0,
-		/** Set to enable Modify of Destination IPv4 Address
-		 */
-		CFA_P58_MR_REPLACE_DEST_IPV4
-	} modify;
-
-	/** Encap Control
-	 * Controls the type of encapsulation the template is
-	 * describing
-	 *
-	 * encap is valid when:
-	 * ((obj_type == CFA_P58_ACT_OBJ_TYPE_ACT) &&
-	 *   act.encap_enable) ||
-	 * ((obj_type == CFA_P58_ACT_OBJ_TYPE_SRC_PROP_SRAM)
-	 */
-	struct {
-		/* Direction is required as Stingray Encap on RX is
-		 * limited to l2 and VTAG only.
-		 */
-		/** Receive or Transmit direction
-		 */
-		uint8_t direction;
-		/** Set to CFA_HCAPI_TRUE to enable L2 capability in the
-		 *  template
-		 */
-		uint8_t l2_enable;
-		/** vtag controls the Encap Vector - VTAG Encoding, 4 bits
-		 *
-		 * <ul>
-		 * <li> CFA_P58_ACT_ENCAP_VTAGS_PUSH_0, default, no VLAN
-		 *      Tags applied
-		 * <li> CFA_P58_ACT_ENCAP_VTAGS_PUSH_1, adds capability to
-		 *      set 1 VLAN Tag. Action Template compile adds
-		 *      the following field to the action object
-		 *      ::TF_ER_VLAN1
-		 * <li> CFA_P58_ACT_ENCAP_VTAGS_PUSH_2, adds capability to
-		 *      set 2 VLAN Tags. Action Template compile adds
-		 *      the following fields to the action object
-		 *      ::TF_ER_VLAN1 and ::TF_ER_VLAN2
-		 * </ul>
-		 */
-		enum { CFA_P58_ACT_ENCAP_VTAGS_PUSH_0 = 0,
-		       CFA_P58_ACT_ENCAP_VTAGS_PUSH_1,
-		       CFA_P58_ACT_ENCAP_VTAGS_PUSH_2 } vtag;
-
-		/*
-		 * The remaining fields are NOT supported when
-		 * direction is RX and ((obj_type ==
-		 * CFA_P58_ACT_OBJ_TYPE_ACT) && act.encap_enable).
-		 * ab_compile_layout will perform the checking and
-		 * skip remaining fields.
-		 */
-		/** L3 Encap controls the Encap Vector - L3 Encoding,
-		 *  3 bits. Defines the type of L3 Encapsulation the
-		 *  template is describing.
-		 * <ul>
-		 * <li> CFA_P58_ACT_ENCAP_L3_NONE, default, no L3
-		 *      Encapsulation processing.
-		 * <li> CFA_P58_ACT_ENCAP_L3_IPV4, enables L3 IPv4
-		 *      Encapsulation.
-		 * <li> CFA_P58_ACT_ENCAP_L3_IPV6, enables L3 IPv6
-		 *      Encapsulation.
-		 * <li> CFA_P58_ACT_ENCAP_L3_MPLS_8847, enables L3 MPLS
-		 *      8847 Encapsulation.
-		 * <li> CFA_P58_ACT_ENCAP_L3_MPLS_8848, enables L3 MPLS
-		 *      8848 Encapsulation.
-		 * </ul>
-		 */
-		enum {
-			/** Set to disable any L3 encapsulation
-			 * processing, default
-			 */
-			CFA_P58_ACT_ENCAP_L3_NONE = 0,
-			/** Set to enable L3 IPv4 encapsulation
-			 */
-			CFA_P58_ACT_ENCAP_L3_IPV4 = 4,
-			/** Set to enable L3 IPv6 encapsulation
-			 */
-			CFA_P58_ACT_ENCAP_L3_IPV6 = 5,
-			/** Set to enable L3 MPLS 8847 encapsulation
-			 */
-			CFA_P58_ACT_ENCAP_L3_MPLS_8847 = 6,
-			/** Set to enable L3 MPLS 8848 encapsulation
-			 */
-			CFA_P58_ACT_ENCAP_L3_MPLS_8848 = 7
-		} l3;
-
-#define CFA_P58_ACT_ENCAP_MAX_MPLS_LABELS 8
-		/** 1-8 labels, valid when
-		 * (l3 == CFA_P58_ACT_ENCAP_L3_MPLS_8847) ||
-		 * (l3 == CFA_P58_ACT_ENCAP_L3_MPLS_8848)
-		 *
-		 * MAX number of MPLS Labels 8.
-		 */
-		uint8_t l3_num_mpls_labels;
-
-		/** Set to CFA_HCAPI_TRUE to enable L4 capability in the
-		 * template.
-		 *
-		 * CFA_HCAPI_TRUE adds ::TF_EN_UDP_SRC_PORT and
-		 * ::TF_EN_UDP_DST_PORT to the template.
-		 */
-		uint8_t l4_enable;
-
-		/** Tunnel Encap controls the Encap Vector - Tunnel
-		 *  Encap, 3 bits. Defines the type of Tunnel
-		 *  encapsulation the template is describing
-		 * <ul>
-		 * <li> CFA_P58_ACT_ENCAP_TNL_NONE, default, no Tunnel
-		 *      Encapsulation processing.
-		 * <li> CFA_P58_ACT_ENCAP_TNL_GENERIC_FULL
-		 * <li> CFA_P58_ACT_ENCAP_TNL_VXLAN. NOTE: Expects
-		 *      l4_enable set to CFA_P58_TRUE;
-		 * <li> CFA_P58_ACT_ENCAP_TNL_NGE. NOTE: Expects l4_enable
-		 *      set to CFA_P58_TRUE;
-		 * <li> CFA_P58_ACT_ENCAP_TNL_NVGRE. NOTE: only valid if
-		 *      l4_enable set to CFA_HCAPI_FALSE.
-		 * <li> CFA_P58_ACT_ENCAP_TNL_GRE.NOTE: only valid if
-		 *      l4_enable set to CFA_HCAPI_FALSE.
-		 * <li> CFA_P58_ACT_ENCAP_TNL_GENERIC_AFTER_TL4
-		 * <li> CFA_P58_ACT_ENCAP_TNL_GENERIC_AFTER_TNL
-		 * </ul>
-		 */
-		enum {
-			/** Set to disable Tunnel header encapsulation
-			 * processing, default
-			 */
-			CFA_P58_ACT_ENCAP_TNL_NONE = 0,
-			/** Set to enable Tunnel Generic Full header
-			 * encapsulation
-			 */
-			CFA_P58_ACT_ENCAP_TNL_GENERIC_FULL,
-			/** Set to enable VXLAN header encapsulation
-			 */
-			CFA_P58_ACT_ENCAP_TNL_VXLAN,
-			/** Set to enable NGE (VXLAN2) header encapsulation
-			 */
-			CFA_P58_ACT_ENCAP_TNL_NGE,
-			/** Set to enable NVGRE header encapsulation
-			 */
-			CFA_P58_ACT_ENCAP_TNL_NVGRE,
-			/** Set to enable GRE header encapsulation
-			 */
-			CFA_P58_ACT_ENCAP_TNL_GRE,
-			/** Set to enable Generic header after Tunnel
-			 * L4 encapsulation
-			 */
-			CFA_P58_ACT_ENCAP_TNL_GENERIC_AFTER_TL4,
-			/** Set to enable Generic header after Tunnel
-			 * encapsulation
-			 */
-			CFA_P58_ACT_ENCAP_TNL_GENERIC_AFTER_TNL
-		} tnl;
-
-		/** Number of bytes of generic tunnel header,
-		 * valid when
-		 * (tnl == CFA_P58_ACT_ENCAP_TNL_GENERIC_FULL) ||
-		 * (tnl == CFA_P58_ACT_ENCAP_TNL_GENERIC_AFTER_TL4) ||
-		 * (tnl == CFA_P58_ACT_ENCAP_TNL_GENERIC_AFTER_TNL)
-		 */
-		uint8_t tnl_generic_size;
-		/** Number of 32b words of nge options,
-		 * valid when
-		 * (tnl == CFA_P58_ACT_ENCAP_TNL_NGE)
-		 */
-		uint8_t tnl_nge_op_len;
-		/* Currently not planned */
-		/* Custom Header */
-		/*	uint8_t custom_enable; */
-	} encap;
-};
-
 /**
  * Enumeration of SRAM entry types, used for allocation of
  * fixed SRAM entities. The memory model for CFA HCAPI
diff --git a/drivers/net/bnxt/tf_core/hwrm_tf.h b/drivers/net/bnxt/tf_core/hwrm_tf.h
deleted file mode 100644
index 9cc9a1435c..0000000000
--- a/drivers/net/bnxt/tf_core/hwrm_tf.h
+++ /dev/null
@@ -1,196 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2019-2021 Broadcom
- * All rights reserved.
- */
-#ifndef _HWRM_TF_H_
-#define _HWRM_TF_H_
-
-#include "tf_core.h"
-
-typedef enum tf_type {
-	TF_TYPE_TRUFLOW,
-	TF_TYPE_LAST = TF_TYPE_TRUFLOW,
-} tf_type_t;
-
-typedef enum tf_subtype {
-	HWRM_TFT_GET_GLOBAL_CFG = 821,
-	HWRM_TFT_SET_GLOBAL_CFG = 822,
-	HWRM_TFT_TBL_TYPE_BULK_GET = 825,
-	HWRM_TFT_IF_TBL_SET = 827,
-	HWRM_TFT_IF_TBL_GET = 828,
-	TF_SUBTYPE_LAST = HWRM_TFT_IF_TBL_GET,
-} tf_subtype_t;
-
-/* Request and Response compile time checking */
-/* u32_t	tlv_req_value[26]; */
-#define TF_MAX_REQ_SIZE 104
-/* u32_t	tlv_resp_value[170]; */
-#define TF_MAX_RESP_SIZE 680
-
-/* Use this to allocate/free any kind of
- * indexes over HWRM and fill the parms pointer
- */
-#define TF_BULK_RECV	 128
-#define TF_BULK_SEND	  16
-
-/* EM Key value */
-#define TF_DEV_DATA_TYPE_TF_EM_RULE_INSERT_KEY_DATA 0x2e30UL
-/* EM Key value */
-#define TF_DEV_DATA_TYPE_TF_EM_RULE_DELETE_KEY_DATA 0x2e40UL
-/* L2 Context DMA Address Type */
-#define TF_DEV_DATA_TYPE_TF_L2_CTX_DMA_ADDR		0x2fe0UL
-/* L2 Context Entry */
-#define TF_DEV_DATA_TYPE_TF_L2_CTX_ENTRY		0x2fe1UL
-/* Prof tcam DMA Address Type */
-#define TF_DEV_DATA_TYPE_TF_PROF_TCAM_DMA_ADDR		0x3030UL
-/* Prof tcam Entry */
-#define TF_DEV_DATA_TYPE_TF_PROF_TCAM_ENTRY		0x3031UL
-/* WC DMA Address Type */
-#define TF_DEV_DATA_TYPE_TF_WC_DMA_ADDR			0x30d0UL
-/* WC Entry */
-#define TF_DEV_DATA_TYPE_TF_WC_ENTRY				0x30d1UL
-/* SPIF DFLT L2 CTXT Entry */
-#define TF_DEV_DATA_TYPE_SPIF_DFLT_L2_CTXT		  0x3131UL
-/* PARIF DFLT ACT REC PTR Entry */
-#define TF_DEV_DATA_TYPE_PARIF_DFLT_ACT_REC		0x3132UL
-/* PARIF ERR DFLT ACT REC PTR Entry */
-#define TF_DEV_DATA_TYPE_PARIF_ERR_DFLT_ACT_REC	 0x3133UL
-/* ILT Entry */
-#define TF_DEV_DATA_TYPE_ILT				0x3134UL
-/* VNIC SVIF entry */
-#define TF_DEV_DATA_TYPE_VNIC_SVIF			0x3135UL
-/* Action Data */
-#define TF_DEV_DATA_TYPE_TF_ACTION_DATA			0x3170UL
-#define TF_DEV_DATA_TYPE_LAST   TF_DEV_DATA_TYPE_TF_ACTION_DATA
-
-#define TF_BITS2BYTES(x) (((x) + 7) >> 3)
-#define TF_BITS2BYTES_WORD_ALIGN(x) ((((x) + 31) >> 5) * 4)
-#define TF_BITS2BYTES_64B_WORD_ALIGN(x) ((((x) + 63) >> 6) * 8)
-
-struct tf_set_global_cfg_input;
-struct tf_get_global_cfg_input;
-struct tf_get_global_cfg_output;
-struct tf_tbl_type_bulk_get_input;
-struct tf_tbl_type_bulk_get_output;
-struct tf_if_tbl_set_input;
-struct tf_if_tbl_get_input;
-struct tf_if_tbl_get_output;
-/* Input params for global config set */
-typedef struct tf_set_global_cfg_input {
-	/* Session Id */
-	uint32_t			 fw_session_id;
-	/* flags */
-	uint32_t			 flags;
-	/* When set to 0, indicates the query apply to RX */
-#define TF_SET_GLOBAL_CFG_INPUT_FLAGS_DIR_RX		  (0x0)
-	/* When set to 1, indicates the query apply to TX */
-#define TF_SET_GLOBAL_CFG_INPUT_FLAGS_DIR_TX		  (0x1)
-	/* Config type */
-	uint32_t			 type;
-	/* Offset of the type */
-	uint32_t			 offset;
-	/* Size of the data to set in bytes */
-	uint16_t			 size;
-	/* Data to set */
-	uint8_t			  data[TF_BULK_SEND];
-} tf_set_global_cfg_input_t, *ptf_set_global_cfg_input_t;
-
-/* Input params for global config to get */
-typedef struct tf_get_global_cfg_input {
-	/* Session Id */
-	uint32_t			 fw_session_id;
-	/* flags */
-	uint32_t			 flags;
-	/* When set to 0, indicates the query apply to RX */
-#define TF_GET_GLOBAL_CFG_INPUT_FLAGS_DIR_RX		  (0x0)
-	/* When set to 1, indicates the query apply to TX */
-#define TF_GET_GLOBAL_CFG_INPUT_FLAGS_DIR_TX		  (0x1)
-	/* Config to retrieve */
-	uint32_t			 type;
-	/* Offset to retrieve */
-	uint32_t			 offset;
-	/* Size of the data to set in bytes */
-	uint16_t			 size;
-} tf_get_global_cfg_input_t, *ptf_get_global_cfg_input_t;
-
-/* Output params for global config */
-typedef struct tf_get_global_cfg_output {
-	/* Size of the total data read in bytes */
-	uint16_t			 size;
-	/* Data to get */
-	uint8_t			  data[TF_BULK_SEND];
-} tf_get_global_cfg_output_t, *ptf_get_global_cfg_output_t;
-
-/* Input params for table type get */
-typedef struct tf_tbl_type_bulk_get_input {
-	/* Session Id */
-	uint32_t			 fw_session_id;
-	/* flags */
-	uint32_t			 flags;
-	/* When set to 0, indicates the get apply to RX */
-#define TF_TBL_TYPE_BULK_GET_INPUT_FLAGS_DIR_RX	   (0x0)
-	/* When set to 1, indicates the get apply to TX */
-#define TF_TBL_TYPE_BULK_GET_INPUT_FLAGS_DIR_TX	   (0x1)
-	/* When set to 1, indicates the clear entry on read */
-#define TF_TBL_TYPE_BULK_GET_INPUT_FLAGS_CLEAR_ON_READ	  (0x2)
-	/* Type of the object to set */
-	uint32_t			 type;
-	/* Starting index to get from */
-	uint32_t			 start_index;
-	/* Number of entries to get */
-	uint32_t			 num_entries;
-	/* Host memory where data will be stored */
-	uint64_t			 host_addr;
-} tf_tbl_type_bulk_get_input_t, *ptf_tbl_type_bulk_get_input_t;
-
-/* Output params for table type get */
-typedef struct tf_tbl_type_bulk_get_output {
-	/* Size of the total data read in bytes */
-	uint16_t			 size;
-} tf_tbl_type_bulk_get_output_t, *ptf_tbl_type_bulk_get_output_t;
-
-/* Input params for if tbl set */
-typedef struct tf_if_tbl_set_input {
-	/* Session Id */
-	uint32_t			 fw_session_id;
-	/* flags */
-	uint16_t			 flags;
-	/* When set to 0, indicates the query apply to RX */
-#define TF_IF_TBL_SET_INPUT_FLAGS_DIR_RX			  (0x0)
-	/* When set to 1, indicates the query apply to TX */
-#define TF_IF_TBL_SET_INPUT_FLAGS_DIR_TX			  (0x1)
-	/* if table type */
-	uint16_t			 tf_if_tbl_type;
-	/* index of table entry */
-	uint16_t			 idx;
-	/* size of the data write to table entry */
-	uint32_t			 data_sz_in_bytes;
-	/* data to write into table entry */
-	uint32_t			 data[2];
-} tf_if_tbl_set_input_t, *ptf_if_tbl_set_input_t;
-
-/* Input params for if tbl get */
-typedef struct tf_if_tbl_get_input {
-	/* Session Id */
-	uint32_t			 fw_session_id;
-	/* flags */
-	uint16_t			 flags;
-	/* When set to 0, indicates the query apply to RX */
-#define TF_IF_TBL_GET_INPUT_FLAGS_DIR_RX			  (0x0)
-	/* When set to 1, indicates the query apply to TX */
-#define TF_IF_TBL_GET_INPUT_FLAGS_DIR_TX			  (0x1)
-	/* if table type */
-	uint16_t			 tf_if_tbl_type;
-	/* size of the data get from table entry */
-	uint32_t			 data_sz_in_bytes;
-	/* index of table entry */
-	uint16_t			 idx;
-} tf_if_tbl_get_input_t, *ptf_if_tbl_get_input_t;
-
-/* output params for if tbl get */
-typedef struct tf_if_tbl_get_output {
-	/* Value read from table entry */
-	uint32_t			 data[2];
-} tf_if_tbl_get_output_t, *ptf_if_tbl_get_output_t;
-
-#endif /* _HWRM_TF_H_ */
diff --git a/drivers/net/bnxt/tf_core/lookup3.h b/drivers/net/bnxt/tf_core/lookup3.h
index b1fd2cd436..743c4d9c4f 100644
--- a/drivers/net/bnxt/tf_core/lookup3.h
+++ b/drivers/net/bnxt/tf_core/lookup3.h
@@ -122,7 +122,7 @@ static inline uint32_t hashword(const uint32_t *k,
 				size_t length,
 				uint32_t initval) {
 	uint32_t a, b, c;
-	int index = 12;
+	int index = length - 1;
 
 	/* Set up the internal state */
 	a = 0xdeadbeef + (((uint32_t)length) << 2) + initval;
diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c
index 573fa0b1ed..9b8677caac 100644
--- a/drivers/net/bnxt/tf_core/tf_core.c
+++ b/drivers/net/bnxt/tf_core/tf_core.c
@@ -18,7 +18,6 @@
 #include "bnxt.h"
 #include "rand.h"
 #include "tf_common.h"
-#include "hwrm_tf.h"
 #include "tf_ext_flow_handle.h"
 
 int
diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h
index fcba492dc5..7b26b58000 100644
--- a/drivers/net/bnxt/tf_core/tf_core.h
+++ b/drivers/net/bnxt/tf_core/tf_core.h
@@ -10,7 +10,7 @@
 #include <stdlib.h>
 #include <stdbool.h>
 #include <stdio.h>
-#include "hcapi/cfa/hcapi_cfa_defs.h"
+#include "hcapi_cfa_defs.h"
 #include "tf_project.h"
 
 /**
@@ -43,6 +43,29 @@ enum tf_mem {
 	TF_MEM_MAX
 };
 
+/**
+ * External memory control channel type
+ */
+enum tf_ext_mem_chan_type {
+	/**
+	 * Direct memory write(Wh+/SR)
+	 */
+	TF_EXT_MEM_CHAN_TYPE_DIRECT = 0,
+	/**
+	 * Ring interface MPC
+	 */
+	TF_EXT_MEM_CHAN_TYPE_RING_IF,
+	/**
+	 * Use HWRM message to firmware
+	 */
+	TF_EXT_MEM_CHAN_TYPE_FW,
+	/**
+	 * Use ring_if message to firmware
+	 */
+	TF_EXT_MEM_CHAN_TYPE_RING_IF_FW,
+	TF_EXT_MEM_CHAN_TYPE_MAX
+};
+
 /**
  * EEM record AR helper
  *
@@ -149,7 +172,6 @@ enum tf_device_type {
 	TF_DEVICE_TYPE_WH = 0, /**< Whitney+  */
 	TF_DEVICE_TYPE_SR,     /**< Stingray  */
 	TF_DEVICE_TYPE_THOR,   /**< Thor      */
-	TF_DEVICE_TYPE_SR2,    /**< Stingray2 */
 	TF_DEVICE_TYPE_MAX     /**< Maximum   */
 };
 
@@ -182,40 +204,39 @@ enum tf_module_type {
  */
 enum tf_identifier_type {
 	/**
-	 *  WH/SR/TH/SR2
+	 *  WH/SR/TH
 	 *  The L2 Context is returned from the L2 Ctxt TCAM lookup
 	 *  and can be used in WC TCAM or EM keys to virtualize further
 	 *  lookups.
 	 */
 	TF_IDENT_TYPE_L2_CTXT_HIGH,
 	/**
-	 *  WH/SR/TH/SR2
+	 *  WH/SR/TH
 	 *  The L2 Context is returned from the L2 Ctxt TCAM lookup
 	 *  and can be used in WC TCAM or EM keys to virtualize further
 	 *  lookups.
 	 */
 	TF_IDENT_TYPE_L2_CTXT_LOW,
 	/**
-	 *  WH/SR/TH/SR2
+	 *  WH/SR/TH
 	 *  The WC profile func is returned from the L2 Ctxt TCAM lookup
 	 *  to enable virtualization of the profile TCAM.
 	 */
 	TF_IDENT_TYPE_PROF_FUNC,
 	/**
-	 *  WH/SR/TH/SR2
+	 *  WH/SR/TH
 	 *  The WC profile ID is included in the WC lookup key
 	 *  to enable virtualization of the WC TCAM hardware.
 	 */
 	TF_IDENT_TYPE_WC_PROF,
 	/**
-	 *  WH/SR/TH/SR2
+	 *  WH/SR/TH
 	 *  The EM profile ID is included in the EM lookup key
-	 *  to enable virtualization of the EM hardware. (not required for SR2
-	 *  as it has table scope)
+	 *  to enable virtualization of the EM hardware.
 	 */
 	TF_IDENT_TYPE_EM_PROF,
 	/**
-	 *  TH/SR2
+	 *  TH
 	 *  The L2 func is included in the ILT result and from recycling to
 	 *  enable virtualization of further lookups.
 	 */
@@ -273,23 +294,15 @@ enum tf_tbl_type {
 	TF_TBL_TYPE_MIRROR_CONFIG,
 	/** (Future) UPAR */
 	TF_TBL_TYPE_UPAR,
-	/** (Future) SR2 Epoch 0 table */
-	TF_TBL_TYPE_EPOCH0,
-	/** (Future) SR2 Epoch 1 table  */
-	TF_TBL_TYPE_EPOCH1,
-	/** (Future) TH/SR2 Metadata  */
+	/** (Future) TH Metadata  */
 	TF_TBL_TYPE_METADATA,
-	/** (Future) TH/SR2 CT State  */
+	/** (Future) TH CT State  */
 	TF_TBL_TYPE_CT_STATE,
-	/** (Future) TH/SR2 Range Profile  */
+	/** (Future) TH Range Profile  */
 	TF_TBL_TYPE_RANGE_PROF,
-	/** (Future) SR2 Range Entry  */
-	TF_TBL_TYPE_RANGE_ENTRY,
-	/** (Future) SR2 LAG Entry  */
-	TF_TBL_TYPE_LAG,
-	/** TH/SR2 EM Flexible Key builder */
+	/** TH EM Flexible Key builder */
 	TF_TBL_TYPE_EM_FKB,
-	/** TH/SR2 WC Flexible Key builder */
+	/** TH WC Flexible Key builder */
 	TF_TBL_TYPE_WC_FKB,
 
 	/* External */
@@ -301,14 +314,6 @@ enum tf_tbl_type {
 	 * a pool of 64B entries.
 	 */
 	TF_TBL_TYPE_EXT,
-	/* (Future) SR2 32B External EM Action 32B Pool */
-	TF_TBL_TYPE_EXT_32B,
-	/* (Future) SR2 64B External EM Action 64B Pool */
-	TF_TBL_TYPE_EXT_64B,
-	/* (Future) SR2 96B External EM Action 96B Pool */
-	TF_TBL_TYPE_EXT_96B,
-	/* (Future) SR2 128B External EM Action 128B Pool */
-	TF_TBL_TYPE_EXT_128B,
 	TF_TBL_TYPE_MAX
 };
 
@@ -969,20 +974,13 @@ struct tf_map_tbl_scope_parms {
 /**
  * allocate a table scope
  *
- * On SR2 Firmware will allocate a scope ID.  On other devices, the scope
- * is a software construct to identify an EEM table.  This function will
+ * The scope is a software construct to identify an EEM table.  This function will
  * divide the hash memory/buckets and records according to the device
  * device constraints based upon calculations using either the number of flows
  * requested or the size of memory indicated.  Other parameters passed in
  * determine the configuration (maximum key size, maximum external action record
  * size).
  *
- * This API will allocate the table region in DRAM, program the PTU page table
- * entries, and program the number of static buckets (if SR2) in the RX and TX
- * CFAs.  Buckets are assumed to start at 0 in the EM memory for the scope.
- * Upon successful completion of this API, hash tables are fully initialized and
- * ready for entries to be inserted.
- *
  * A single API is used to allocate a common table scope identifier in both
  * receive and transmit CFA. The scope identifier is common due to nature of
  * connection tracking sending notifications between RX and TX direction.
@@ -1028,7 +1026,7 @@ int tf_map_tbl_scope(struct tf *tfp,
  *
  * Firmware checks that the table scope ID is owned by the TruFlow
  * session, verifies that no references to this table scope remains
- * (SR2 ILT) or Profile TCAM entries for either CFA (RX/TX) direction,
+ * or Profile TCAM entries for either CFA (RX/TX) direction,
  * then frees the table scope ID.
  *
  * Returns success or failure code.
@@ -1589,6 +1587,10 @@ struct tf_set_tbl_entry_parms {
 	 * [in] Entry size
 	 */
 	uint16_t data_sz_in_bytes;
+	/**
+	 * [in] External memory channel type to use
+	 */
+	enum tf_ext_mem_chan_type chan_type;
 	/**
 	 * [in] Entry index to write to
 	 */
@@ -1627,6 +1629,10 @@ struct tf_get_tbl_entry_parms {
 	 * [in] Entry size
 	 */
 	uint16_t data_sz_in_bytes;
+	/**
+	 * [in] External memory channel type to use
+	 */
+	enum tf_ext_mem_chan_type chan_type;
 	/**
 	 * [in] Entry index to read
 	 */
@@ -1679,6 +1685,10 @@ struct tf_bulk_get_tbl_entry_parms {
 	 * structure for the physical address.
 	 */
 	uint64_t physical_mem_addr;
+	/**
+	 * [in] External memory channel type to use
+	 */
+	enum tf_ext_mem_chan_type chan_type;
 };
 
 /**
@@ -1723,10 +1733,6 @@ struct tf_insert_em_entry_parms {
 	 * [in] ID of table scope to use (external only)
 	 */
 	uint32_t tbl_scope_id;
-	/**
-	 * [in] ID of table interface to use (SR2 only)
-	 */
-	uint32_t tbl_if_id;
 	/**
 	 * [in] ptr to structure containing key fields
 	 */
@@ -1747,6 +1753,10 @@ struct tf_insert_em_entry_parms {
 	 * [in] duplicate check flag
 	 */
 	uint8_t	dup_check;
+	/**
+	 * [in] External memory channel type to use
+	 */
+	enum tf_ext_mem_chan_type chan_type;
 	/**
 	 * [out] Flow handle value for the inserted entry.  This is encoded
 	 * as the entries[4]:bucket[2]:hashId[1]:hash[14]
@@ -1775,19 +1785,14 @@ struct tf_delete_em_entry_parms {
 	 * [in] ID of table scope to use (external only)
 	 */
 	uint32_t tbl_scope_id;
-	/**
-	 * [in] ID of table interface to use (SR2 only)
-	 */
-	uint32_t tbl_if_id;
-	/**
-	 * [in] epoch group IDs of entry to delete
-	 * 2 element array with 2 ids. (SR2 only)
-	 */
-	uint16_t *epochs;
 	/**
 	 * [out] The index of the entry
 	 */
 	uint16_t index;
+	/**
+	 * [in] External memory channel type to use
+	 */
+	enum tf_ext_mem_chan_type chan_type;
 	/**
 	 * [in] structure containing flow delete handle information
 	 */
@@ -1809,10 +1814,6 @@ struct tf_search_em_entry_parms {
 	 * [in] ID of table scope to use (external only)
 	 */
 	uint32_t tbl_scope_id;
-	/**
-	 * [in] ID of table interface to use (SR2 only)
-	 */
-	uint32_t tbl_if_id;
 	/**
 	 * [in] ptr to structure containing key fields
 	 */
@@ -1830,10 +1831,9 @@ struct tf_search_em_entry_parms {
 	 */
 	uint16_t em_record_sz_in_bits;
 	/**
-	 * [in] epoch group IDs of entry to lookup
-	 * 2 element array with 2 ids. (SR2 only)
+	 * [in] External memory channel type to use
 	 */
-	uint16_t *epochs;
+	enum tf_ext_mem_chan_type chan_type;
 	/**
 	 * [in] ptr to structure containing flow delete handle
 	 */
@@ -1858,9 +1858,6 @@ struct tf_search_em_entry_parms {
  * This API inserts an exact match entry into DRAM EM table memory of the
  * specified direction and table scope.
  *
- * When inserting an entry into an exact match table, the TruFlow library may
- * need to allocate a dynamic bucket for the entry (SR2 only).
- *
  * The insertion of duplicate entries in an EM table is not permitted.	If a
  * TruFlow application can guarantee that it will never insert duplicates, it
  * can disable duplicate checking by passing a zero value in the  dup_check
@@ -2040,9 +2037,9 @@ enum tf_if_tbl_type {
 	TF_IF_TBL_TYPE_PROF_PARIF_ERR_ACT_REC_PTR,
 	/** Default Error Profile TCAM Miss Action Record Pointer Table */
 	TF_IF_TBL_TYPE_LKUP_PARIF_DFLT_ACT_REC_PTR,
-	/** SR2 Ingress lookup table */
+	/** Ingress lookup table */
 	TF_IF_TBL_TYPE_ILT,
-	/** SR2 VNIC/SVIF Properties Table */
+	/** VNIC/SVIF Properties Table */
 	TF_IF_TBL_TYPE_VSPT,
 	TF_IF_TBL_TYPE_MAX
 };
diff --git a/drivers/net/bnxt/tf_core/tf_device.c b/drivers/net/bnxt/tf_core/tf_device.c
index 61b3746d8b..9e71c04bf2 100644
--- a/drivers/net/bnxt/tf_core/tf_device.c
+++ b/drivers/net/bnxt/tf_core/tf_device.c
@@ -487,7 +487,7 @@ tf_dev_bind_p58(struct tf *tfp,
  *   - (-EINVAL) on failure.
  */
 static int
-	tf_dev_unbind_p58(struct tf *tfp)
+tf_dev_unbind_p58(struct tf *tfp)
 {
 	int rc = 0;
 	bool fail = false;
diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.h b/drivers/net/bnxt/tf_core/tf_device_p4.h
index ee283ce29d..a73ba3cd70 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p4.h
+++ b/drivers/net/bnxt/tf_core/tf_device_p4.h
@@ -14,92 +14,117 @@
 
 struct tf_rm_element_cfg tf_ident_p4[TF_IDENT_TYPE_MAX] = {
 	[TF_IDENT_TYPE_L2_CTXT_HIGH] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP_HIGH
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP_HIGH,
+		0, 0, 0
 	},
 	[TF_IDENT_TYPE_L2_CTXT_LOW] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP_LOW
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP_LOW,
+		0, 0, 0
 	},
 	[TF_IDENT_TYPE_PROF_FUNC] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_PROF_FUNC
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_PROF_FUNC,
+		0, 0, 0
 	},
 	[TF_IDENT_TYPE_WC_PROF] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_WC_TCAM_PROF_ID
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_WC_TCAM_PROF_ID,
+		0, 0, 0
 	},
 	[TF_IDENT_TYPE_EM_PROF] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_EM_PROF_ID
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_EM_PROF_ID,
+		0, 0, 0
 	},
 };
 
 struct tf_rm_element_cfg tf_tcam_p4[TF_TCAM_TBL_TYPE_MAX] = {
 	[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_HIGH] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_HIGH
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_HIGH,
+		0, 0, 0
 	},
 	[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_LOW] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_LOW
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_LOW,
+		0, 0, 0
 	},
 	[TF_TCAM_TBL_TYPE_PROF_TCAM] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_PROF_TCAM
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_PROF_TCAM,
+		0, 0, 0
 	},
 	[TF_TCAM_TBL_TYPE_WC_TCAM] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_WC_TCAM
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_WC_TCAM,
+		0, 0, 0
 	},
 	[TF_TCAM_TBL_TYPE_SP_TCAM] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_SP_TCAM
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_SP_TCAM,
+		0, 0, 0
 	},
 };
 
 struct tf_rm_element_cfg tf_tbl_p4[TF_TBL_TYPE_MAX] = {
 	[TF_TBL_TYPE_FULL_ACT_RECORD] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_FULL_ACTION
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_FULL_ACTION,
+		0, 0, 0
 	},
 	[TF_TBL_TYPE_MCAST_GROUPS] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_MCG
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_MCG,
+		0, 0, 0
 	},
 	[TF_TBL_TYPE_ACT_ENCAP_8B] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_ENCAP_8B
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_ENCAP_8B,
+		0, 0, 0
 	},
 	[TF_TBL_TYPE_ACT_ENCAP_16B] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_ENCAP_16B
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_ENCAP_16B,
+		0, 0, 0
 	},
 	[TF_TBL_TYPE_ACT_ENCAP_64B] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_ENCAP_64B
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_ENCAP_64B,
+		0, 0, 0
 	},
 	[TF_TBL_TYPE_ACT_SP_SMAC] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_SP_MAC
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_SP_MAC,
+		0, 0, 0
 	},
 	[TF_TBL_TYPE_ACT_SP_SMAC_IPV4] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_SP_MAC_IPV4
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_SP_MAC_IPV4,
+		0, 0, 0
 	},
 	[TF_TBL_TYPE_ACT_SP_SMAC_IPV6] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_SP_MAC_IPV6
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_SP_MAC_IPV6,
+		0, 0, 0
 	},
 	[TF_TBL_TYPE_ACT_STATS_64] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_COUNTER_64B
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_COUNTER_64B,
+		0, 0, 0
 	},
 	[TF_TBL_TYPE_ACT_MODIFY_IPV4] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_NAT_IPV4
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_NAT_IPV4,
+		0, 0, 0
 	},
 	[TF_TBL_TYPE_METER_PROF] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_METER_PROF
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_METER_PROF,
+		0, 0, 0
 	},
 	[TF_TBL_TYPE_METER_INST] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_METER
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_METER,
+		0, 0, 0
 	},
 	[TF_TBL_TYPE_MIRROR_CONFIG] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_MIRROR
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_MIRROR,
+		0, 0, 0
 	},
 
 };
 
 struct tf_rm_element_cfg tf_em_ext_p4[TF_EM_TBL_TYPE_MAX] = {
 	[TF_EM_TBL_TYPE_TBL_SCOPE] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_TBL_SCOPE
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_TBL_SCOPE,
+		0, 0, 0
 	},
 };
 
 struct tf_rm_element_cfg tf_em_int_p4[TF_EM_TBL_TYPE_MAX] = {
 	[TF_EM_TBL_TYPE_EM_RECORD] = {
-		TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_EM_REC
+		TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_EM_REC,
+		0, 0, 0
 	},
 };
 
diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.h b/drivers/net/bnxt/tf_core/tf_device_p58.h
index 4d7a78e52c..b5e2598cb6 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p58.h
+++ b/drivers/net/bnxt/tf_core/tf_device_p58.h
@@ -14,55 +14,70 @@
 
 struct tf_rm_element_cfg tf_ident_p58[TF_IDENT_TYPE_MAX] = {
 	[TF_IDENT_TYPE_L2_CTXT_HIGH] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP_HIGH
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP_HIGH,
+		0, 0, 0
 	},
 	[TF_IDENT_TYPE_L2_CTXT_LOW] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP_LOW
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP_LOW,
+		0, 0, 0
 	},
 	[TF_IDENT_TYPE_PROF_FUNC] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_PROF_FUNC
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_PROF_FUNC,
+		0, 0, 0
 	},
 	[TF_IDENT_TYPE_WC_PROF] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_WC_TCAM_PROF_ID
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_WC_TCAM_PROF_ID,
+		0, 0, 0
 	},
 	[TF_IDENT_TYPE_EM_PROF] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_EM_PROF_ID
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_EM_PROF_ID,
+		0, 0, 0
 	},
 };
 
 struct tf_rm_element_cfg tf_tcam_p58[TF_TCAM_TBL_TYPE_MAX] = {
 	[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_HIGH] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_HIGH
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_HIGH,
+		0, 0, 0
 	},
 	[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_LOW] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_LOW
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_LOW,
+		0, 0, 0
 	},
 	[TF_TCAM_TBL_TYPE_PROF_TCAM] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_PROF_TCAM
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_PROF_TCAM,
+		0, 0, 0
 	},
 	[TF_TCAM_TBL_TYPE_WC_TCAM] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_WC_TCAM
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_WC_TCAM,
+		0, 0, 0
 	},
 	[TF_TCAM_TBL_TYPE_VEB_TCAM] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_VEB_TCAM
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_VEB_TCAM,
+		0, 0, 0
 	},
 };
 
 struct tf_rm_element_cfg tf_tbl_p58[TF_TBL_TYPE_MAX] = {
 	[TF_TBL_TYPE_EM_FKB] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_EM_FKB
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_EM_FKB,
+		0, 0, 0
 	},
 	[TF_TBL_TYPE_WC_FKB] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_WC_FKB
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_WC_FKB,
+		0, 0, 0
 	},
 	[TF_TBL_TYPE_METER_PROF] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_METER_PROF
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_METER_PROF,
+		0, 0, 0
 	},
 	[TF_TBL_TYPE_METER_INST] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_METER
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_METER,
+		0, 0, 0
 	},
 	[TF_TBL_TYPE_MIRROR_CONFIG] = {
-		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_MIRROR
+		TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_MIRROR,
+		0, 0, 0
 	},
 	/* Policy - ARs in bank 1 */
 	[TF_TBL_TYPE_FULL_ACT_RECORD] = {
@@ -167,7 +182,8 @@ struct tf_rm_element_cfg tf_tbl_p58[TF_TBL_TYPE_MAX] = {
 
 struct tf_rm_element_cfg tf_em_int_p58[TF_EM_TBL_TYPE_MAX] = {
 	[TF_EM_TBL_TYPE_EM_RECORD] = {
-		TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P58_EM_REC
+		TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P58_EM_REC,
+		0, 0, 0
 	},
 };
 
diff --git a/drivers/net/bnxt/tf_core/tf_em.h b/drivers/net/bnxt/tf_core/tf_em.h
index 4de9e42cbc..2de1862cd9 100644
--- a/drivers/net/bnxt/tf_core/tf_em.h
+++ b/drivers/net/bnxt/tf_core/tf_em.h
@@ -9,7 +9,9 @@
 #include "tf_core.h"
 #include "tf_session.h"
 
-#include "hcapi/cfa/hcapi_cfa_defs.h"
+#include "tf_em_common.h"
+
+#include "hcapi_cfa_defs.h"
 
 #define TF_EM_MIN_ENTRIES     (1 << 15) /* 32K */
 #define TF_EM_MAX_ENTRIES     (1 << 27) /* 128M */
diff --git a/drivers/net/bnxt/tf_core/tf_em_common.c b/drivers/net/bnxt/tf_core/tf_em_common.c
index d8278f1ce1..4dc3c86b57 100644
--- a/drivers/net/bnxt/tf_core/tf_em_common.c
+++ b/drivers/net/bnxt/tf_core/tf_em_common.c
@@ -19,18 +19,13 @@
 #include "tfp.h"
 #include "tf_device.h"
 #include "tf_ext_flow_handle.h"
-#include "cfa_resource_types.h"
+#include "hcapi_cfa.h"
 
 #include "bnxt.h"
 
 /* Number of pointers per page_size */
 #define MAX_PAGE_PTRS(page_size)  ((page_size) / sizeof(void *))
 
-/**
- * EM DBs.
- */
-void *eem_db[TF_DIR_MAX];
-
 /**
  * Init flag, set on bind and cleared on unbind
  */
@@ -41,36 +36,7 @@ static uint8_t init;
  */
 static enum tf_mem_type mem_type;
 
-/** Table scope array */
-struct tf_tbl_scope_cb tbl_scopes[TF_NUM_TBL_SCOPE];
-
 /* API defined in tf_em.h */
-struct tf_tbl_scope_cb *
-tbl_scope_cb_find(uint32_t tbl_scope_id)
-{
-	int i;
-	struct tf_rm_is_allocated_parms parms = { 0 };
-	int allocated;
-
-	/* Check that id is valid */
-	parms.rm_db = eem_db[TF_DIR_RX];
-	parms.subtype = TF_EM_TBL_TYPE_TBL_SCOPE;
-	parms.index = tbl_scope_id;
-	parms.allocated = &allocated;
-
-	i = tf_rm_is_allocated(&parms);
-
-	if (i < 0 || allocated != TF_RM_ALLOCATED_ENTRY_IN_USE)
-		return NULL;
-
-	for (i = 0; i < TF_NUM_TBL_SCOPE; i++) {
-		if (tbl_scopes[i].tbl_scope_id == tbl_scope_id)
-			return &tbl_scopes[i];
-	}
-
-	return NULL;
-}
-
 int
 tf_create_tbl_pool_external(enum tf_dir dir,
 			    struct tf_tbl_scope_cb *tbl_scope_cb,
@@ -158,6 +124,44 @@ tf_destroy_tbl_pool_external(enum tf_dir dir,
 	tfp_free(ext_act_pool_mem);
 }
 
+/**
+ * Looks up table scope control block using tbl_scope_id from tf_session.
+ *
+ * [in] tfp
+ *   Pointer to Truflow Handle
+ * [in] tbl_scope_id
+ *   table scope id
+ *
+ * Return:
+ *  - Pointer to the tf_tbl_scope_cb, if found.
+ *  - (NULL) on failure, not found.
+ */
+struct tf_tbl_scope_cb *
+tf_em_ext_common_tbl_scope_find(struct tf *tfp,
+			uint32_t tbl_scope_id)
+{
+	int rc;
+	struct em_ext_db *ext_db;
+	void *ext_ptr = NULL;
+	struct tf_tbl_scope_cb *tbl_scope_cb = NULL;
+	struct ll_entry *entry;
+
+	rc = tf_session_get_em_ext_db(tfp, &ext_ptr);
+	if (rc)
+		return NULL;
+
+	ext_db = (struct em_ext_db *)ext_ptr;
+
+	for (entry = ext_db->tbl_scope_ll.head; entry != NULL;
+			entry = entry->next) {
+		tbl_scope_cb = (struct tf_tbl_scope_cb *)entry;
+		if (tbl_scope_cb->tbl_scope_id == tbl_scope_id)
+			return tbl_scope_cb;
+	}
+
+	return NULL;
+}
+
 /**
  * Allocate External Tbl entry from the scope pool.
  *
@@ -182,16 +186,14 @@ tf_tbl_ext_alloc(struct tf *tfp,
 
 	TF_CHECK_PARMS2(tfp, parms);
 
-	/* Get the pool info from the table scope
-	 */
-	tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id);
-
+	tbl_scope_cb = tf_em_ext_common_tbl_scope_find(tfp, parms->tbl_scope_id);
 	if (tbl_scope_cb == NULL) {
 		TFP_DRV_LOG(ERR,
 			    "%s, table scope not allocated\n",
 			    tf_dir_2_str(parms->dir));
 		return -EINVAL;
 	}
+
 	pool = &tbl_scope_cb->ext_act_pool[parms->dir];
 
 	/* Allocate an element
@@ -237,10 +239,7 @@ tf_tbl_ext_free(struct tf *tfp,
 
 	TF_CHECK_PARMS2(tfp, parms);
 
-	/* Get the pool info from the table scope
-	 */
-	tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id);
-
+	tbl_scope_cb = tf_em_ext_common_tbl_scope_find(tfp, parms->tbl_scope_id);
 	if (tbl_scope_cb == NULL) {
 		TFP_DRV_LOG(ERR,
 			    "%s, table scope error\n",
@@ -646,7 +645,18 @@ tf_em_validate_num_entries(struct tf_tbl_scope_cb *tbl_scope_cb,
 	tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[TF_RECORD_TABLE].entry_size =
 		parms->rx_max_action_entry_sz_in_bits / 8;
 
-	tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[TF_EFC_TABLE].num_entries = 0;
+	tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[TF_EFC_TABLE].num_entries =
+		0;
+
+	tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[TF_ACTION_TABLE].num_entries =
+		parms->rx_num_flows_in_k * TF_KILOBYTE;
+	tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[TF_ACTION_TABLE].entry_size =
+		parms->rx_max_action_entry_sz_in_bits / 8;
+
+	tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[TF_EM_LKUP_TABLE].num_entries =
+		parms->rx_num_flows_in_k * TF_KILOBYTE;
+	tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[TF_EM_LKUP_TABLE].entry_size =
+		parms->rx_max_key_sz_in_bits / 8;
 
 	/* Tx */
 	tbl_scope_cb->em_ctx_info[TF_DIR_TX].em_tables[TF_KEY0_TABLE].num_entries =
@@ -664,7 +674,18 @@ tf_em_validate_num_entries(struct tf_tbl_scope_cb *tbl_scope_cb,
 	tbl_scope_cb->em_ctx_info[TF_DIR_TX].em_tables[TF_RECORD_TABLE].entry_size =
 		parms->tx_max_action_entry_sz_in_bits / 8;
 
-	tbl_scope_cb->em_ctx_info[TF_DIR_TX].em_tables[TF_EFC_TABLE].num_entries = 0;
+	tbl_scope_cb->em_ctx_info[TF_DIR_TX].em_tables[TF_EFC_TABLE].num_entries =
+		0;
+
+	tbl_scope_cb->em_ctx_info[TF_DIR_TX].em_tables[TF_ACTION_TABLE].num_entries =
+		parms->rx_num_flows_in_k * TF_KILOBYTE;
+	tbl_scope_cb->em_ctx_info[TF_DIR_TX].em_tables[TF_ACTION_TABLE].entry_size =
+		parms->tx_max_action_entry_sz_in_bits / 8;
+
+	tbl_scope_cb->em_ctx_info[TF_DIR_TX].em_tables[TF_EM_LKUP_TABLE].num_entries =
+		parms->rx_num_flows_in_k * TF_KILOBYTE;
+	tbl_scope_cb->em_ctx_info[TF_DIR_TX].em_tables[TF_EM_LKUP_TABLE].entry_size =
+		parms->tx_max_key_sz_in_bits / 8;
 
 	return 0;
 }
@@ -747,10 +768,10 @@ tf_insert_eem_entry(struct tf_dev_info *dev,
 	key_obj.data = (uint8_t *)&key_entry;
 	key_obj.size = TF_P4_EM_KEY_RECORD_SIZE;
 
-	rc = hcapi_cfa_key_hw_op(&op,
-				 &key_tbl,
-				 &key_obj,
-				 &key_loc);
+	rc = cfa_p4_devops.hcapi_cfa_key_hw_op(&op,
+					       &key_tbl,
+					       &key_obj,
+					       &key_loc);
 
 	if (rc == 0) {
 		table_type = TF_KEY0_TABLE;
@@ -761,10 +782,10 @@ tf_insert_eem_entry(struct tf_dev_info *dev,
 			(uint8_t *)&tbl_scope_cb->em_ctx_info[parms->dir].em_tables[TF_KEY1_TABLE];
 		key_obj.offset = index * TF_P4_EM_KEY_RECORD_SIZE;
 
-		rc = hcapi_cfa_key_hw_op(&op,
-					 &key_tbl,
-					 &key_obj,
-					 &key_loc);
+		rc = cfa_p4_devops.hcapi_cfa_key_hw_op(&op,
+						       &key_tbl,
+						       &key_obj,
+						       &key_loc);
 		if (rc != 0)
 			return rc;
 
@@ -781,7 +802,7 @@ tf_insert_eem_entry(struct tf_dev_info *dev,
 	TF_SET_FIELDS_IN_FLOW_HANDLE(parms->flow_handle,
 				     0,
 				     0,
-				     TF_FLAGS_FLOW_HANDLE_EXTERNAL,
+				     0,
 				     index,
 				     0,
 				     table_type);
@@ -826,10 +847,10 @@ tf_delete_eem_entry(struct tf_tbl_scope_cb *tbl_scope_cb,
 	key_obj.data = NULL;
 	key_obj.size = TF_P4_EM_KEY_RECORD_SIZE;
 
-	rc = hcapi_cfa_key_hw_op(&op,
-				 &key_tbl,
-				 &key_obj,
-				 &key_loc);
+	rc = cfa_p4_devops.hcapi_cfa_key_hw_op(&op,
+					       &key_tbl,
+					       &key_obj,
+					       &key_loc);
 
 	if (!rc)
 		return rc;
@@ -844,7 +865,7 @@ tf_delete_eem_entry(struct tf_tbl_scope_cb *tbl_scope_cb,
  *    -EINVAL - Error
  */
 int
-tf_em_insert_ext_entry(struct tf *tfp __rte_unused,
+tf_em_insert_ext_entry(struct tf *tfp,
 		       struct tf_insert_em_entry_parms *parms)
 {
 	int rc;
@@ -852,7 +873,7 @@ tf_em_insert_ext_entry(struct tf *tfp __rte_unused,
 	struct tf_session *tfs;
 	struct tf_dev_info *dev;
 
-	tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id);
+	tbl_scope_cb = tf_em_ext_common_tbl_scope_find(tfp, parms->tbl_scope_id);
 	if (tbl_scope_cb == NULL) {
 		TFP_DRV_LOG(ERR, "Invalid tbl_scope_cb\n");
 		return -EINVAL;
@@ -881,12 +902,12 @@ tf_em_insert_ext_entry(struct tf *tfp __rte_unused,
  *    -EINVAL - Error
  */
 int
-tf_em_delete_ext_entry(struct tf *tfp __rte_unused,
+tf_em_delete_ext_entry(struct tf *tfp,
 		       struct tf_delete_em_entry_parms *parms)
 {
 	struct tf_tbl_scope_cb *tbl_scope_cb;
 
-	tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id);
+	tbl_scope_cb = tf_em_ext_common_tbl_scope_find(tfp, parms->tbl_scope_id);
 	if (tbl_scope_cb == NULL) {
 		TFP_DRV_LOG(ERR, "Invalid tbl_scope_cb\n");
 		return -EINVAL;
@@ -904,6 +925,8 @@ tf_em_ext_common_bind(struct tf *tfp,
 	int i;
 	struct tf_rm_create_db_parms db_cfg = { 0 };
 	uint8_t db_exists = 0;
+	struct em_ext_db *ext_db;
+	struct tfp_calloc_parms cparms;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -913,6 +936,21 @@ tf_em_ext_common_bind(struct tf *tfp,
 		return -EINVAL;
 	}
 
+	cparms.nitems = 1;
+	cparms.size = sizeof(struct em_ext_db);
+	cparms.alignment = 0;
+	if (tfp_calloc(&cparms) != 0) {
+		TFP_DRV_LOG(ERR, "em_ext_db alloc error %s\n",
+			    strerror(ENOMEM));
+		return -ENOMEM;
+	}
+
+	ext_db = cparms.mem_va;
+	ll_init(&ext_db->tbl_scope_ll);
+	for (i = 0; i < TF_DIR_MAX; i++)
+		ext_db->eem_db[i] = NULL;
+	tf_session_set_em_ext_db(tfp, ext_db);
+
 	db_cfg.module = TF_MODULE_TYPE_EM;
 	db_cfg.num_elements = parms->num_elements;
 	db_cfg.cfg = parms->cfg;
@@ -927,7 +965,7 @@ tf_em_ext_common_bind(struct tf *tfp,
 		if (db_cfg.alloc_cnt[TF_EM_TBL_TYPE_TBL_SCOPE] == 0)
 			continue;
 
-		db_cfg.rm_db = &eem_db[i];
+		db_cfg.rm_db = (void *)&ext_db->eem_db[i];
 		rc = tf_rm_create_db(tfp, &db_cfg);
 		if (rc) {
 			TFP_DRV_LOG(ERR,
@@ -953,6 +991,13 @@ tf_em_ext_common_unbind(struct tf *tfp)
 	int rc;
 	int i;
 	struct tf_rm_free_db_parms fparms = { 0 };
+	struct em_ext_db *ext_db = NULL;
+	struct tf_session *tfs = NULL;
+	struct tf_dev_info *dev;
+	struct ll_entry *entry;
+	struct tf_tbl_scope_cb *tbl_scope_cb = NULL;
+	void *ext_ptr = NULL;
+	struct tf_free_tbl_scope_parms tparms = { 0 };
 
 	TF_CHECK_PARMS1(tfp);
 
@@ -963,16 +1008,62 @@ tf_em_ext_common_unbind(struct tf *tfp)
 		return 0;
 	}
 
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR, "Failed to get tf_session, rc:%s\n",
+		strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to lookup device, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+
+	rc = tf_session_get_em_ext_db(tfp, &ext_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to get em_ext_db from session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	ext_db = (struct em_ext_db *)ext_ptr;
+
+	entry = ext_db->tbl_scope_ll.head;
+	while (entry != NULL) {
+		tbl_scope_cb = (struct tf_tbl_scope_cb *)entry;
+		entry = entry->next;
+		tparms.tbl_scope_id = tbl_scope_cb->tbl_scope_id;
+
+		if (dev->ops->tf_dev_free_tbl_scope) {
+			dev->ops->tf_dev_free_tbl_scope(tfp, &tparms);
+		} else {
+			/* should not reach here */
+			ll_delete(&ext_db->tbl_scope_ll, &tbl_scope_cb->ll_entry);
+			tfp_free(tbl_scope_cb);
+		}
+	}
+
 	for (i = 0; i < TF_DIR_MAX; i++) {
+		if (ext_db->eem_db[i] == NULL)
+			continue;
+
 		fparms.dir = i;
-		fparms.rm_db = eem_db[i];
+		fparms.rm_db = ext_db->eem_db[i];
 		rc = tf_rm_free_db(tfp, &fparms);
 		if (rc)
 			return rc;
 
-		eem_db[i] = NULL;
+		ext_db->eem_db[i] = NULL;
 	}
 
+	tfp_free(ext_db);
+	tf_session_set_em_ext_db(tfp, NULL);
+
 	init = 0;
 
 	return 0;
@@ -1022,11 +1113,7 @@ int tf_tbl_ext_common_set(struct tf *tfp,
 		return -EINVAL;
 	}
 
-	/* Get the table scope control block associated with the
-	 * external pool
-	 */
-	tbl_scope_cb = tbl_scope_cb_find(tbl_scope_id);
-
+	tbl_scope_cb = tf_em_ext_common_tbl_scope_find(tfp, tbl_scope_id);
 	if (tbl_scope_cb == NULL) {
 		TFP_DRV_LOG(ERR,
 			    "%s, table scope error\n",
@@ -1042,10 +1129,10 @@ int tf_tbl_ext_common_set(struct tf *tfp,
 	key_obj.data = parms->data;
 	key_obj.size = parms->data_sz_in_bytes;
 
-	rc = hcapi_cfa_key_hw_op(&op,
-				 &key_tbl,
-				 &key_obj,
-				 &key_loc);
+	rc = cfa_p4_devops.hcapi_cfa_key_hw_op(&op,
+					       &key_tbl,
+					       &key_obj,
+					       &key_loc);
 
 	return rc;
 }
@@ -1076,14 +1163,6 @@ int tf_em_ext_map_tbl_scope(struct tf *tfp,
 	uint32_t sz_in_bytes = 8;
 	struct tf_dev_info *dev;
 
-	tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id);
-
-	if (tbl_scope_cb == NULL) {
-		TFP_DRV_LOG(ERR, "Invalid tbl_scope_cb tbl_scope_id(%d)\n",
-			    parms->tbl_scope_id);
-		return -EINVAL;
-	}
-
 	/* Retrieve the session information */
 	rc = tf_session_get_session_internal(tfp, &tfs);
 	if (rc)
@@ -1094,6 +1173,13 @@ int tf_em_ext_map_tbl_scope(struct tf *tfp,
 	if (rc)
 		return rc;
 
+	tbl_scope_cb = tf_em_ext_common_tbl_scope_find(tfp, parms->tbl_scope_id);
+	if (tbl_scope_cb == NULL) {
+		TFP_DRV_LOG(ERR, "Invalid tbl_scope_cb tbl_scope_id(%d)\n",
+			    parms->tbl_scope_id);
+		return -EINVAL;
+	}
+
 	if (dev->ops->tf_dev_map_tbl_scope == NULL) {
 		rc = -EOPNOTSUPP;
 		TFP_DRV_LOG(ERR,
diff --git a/drivers/net/bnxt/tf_core/tf_em_common.h b/drivers/net/bnxt/tf_core/tf_em_common.h
index 5e55f4e968..7f215adef2 100644
--- a/drivers/net/bnxt/tf_core/tf_em_common.h
+++ b/drivers/net/bnxt/tf_core/tf_em_common.h
@@ -8,7 +8,7 @@
 
 #include "tf_core.h"
 #include "tf_session.h"
-
+#include "ll.h"
 
 /**
  * Function to search for table scope control block structure
@@ -23,6 +23,53 @@
  */
 struct tf_tbl_scope_cb *tbl_scope_cb_find(uint32_t tbl_scope_id);
 
+/**
+ * Table scope control block content
+ */
+struct tf_em_caps {
+	uint32_t flags;
+	uint32_t supported;
+	uint32_t max_entries_supported;
+	uint16_t key_entry_size;
+	uint16_t record_entry_size;
+	uint16_t efc_entry_size;
+};
+
+/**
+ *  EEM data
+ *
+ *  Link list of ext em data allocated and managed by EEM module
+ *  for a TruFlow session.
+ */
+struct em_ext_db {
+	struct ll tbl_scope_ll;
+	struct rm_db *eem_db[TF_DIR_MAX];
+};
+
+/**
+ * Table Scope Control Block
+ *
+ * Holds private data for a table scope.
+ */
+struct tf_tbl_scope_cb {
+	/**
+	 * Linked list of tbl_scope
+	 */
+	struct ll_entry ll_entry; /* For inserting in link list, must be
+				   * first field of struct.
+				   */
+
+	uint32_t tbl_scope_id;
+
+       /** The pf or parent pf of the vf used for table scope creation
+	*/
+	uint16_t pf;
+	struct hcapi_cfa_em_ctx_mem_info em_ctx_info[TF_DIR_MAX];
+	struct tf_em_caps em_caps[TF_DIR_MAX];
+	struct stack ext_act_pool[TF_DIR_MAX];
+	uint32_t *ext_act_pool_mem[TF_DIR_MAX];
+};
+
 /**
  * Create and initialize a stack to use for action entries
  *
@@ -131,4 +178,23 @@ int tf_em_validate_num_entries(struct tf_tbl_scope_cb *tbl_scope_cb,
 int tf_em_size_table(struct hcapi_cfa_em_table *tbl,
 		     uint32_t page_size);
 
+
+/**
+ * Look up table scope control block using tbl_scope_id from
+ * tf_session
+ *
+ * [in] tbl_scope_cb
+ *   Pointer to Truflow Handle
+ *
+ * [in] tbl_scope_id
+ *   table scope id
+ *
+ * Returns:
+ *   - Pointer to the tf_tbl_scope_cb, if found.
+ *   - (NULL) on failure, not found.
+ */
+struct tf_tbl_scope_cb *
+tf_em_ext_common_tbl_scope_find(struct tf *tfp,
+				uint32_t tbl_scope_id);
+
 #endif /* _TF_EM_COMMON_H_ */
diff --git a/drivers/net/bnxt/tf_core/tf_em_host.c b/drivers/net/bnxt/tf_core/tf_em_host.c
index 166f397935..869a78e904 100644
--- a/drivers/net/bnxt/tf_core/tf_em_host.c
+++ b/drivers/net/bnxt/tf_core/tf_em_host.c
@@ -29,13 +29,6 @@
 /* Number of pointers per page_size */
 #define MAX_PAGE_PTRS(page_size)  ((page_size) / sizeof(void *))
 
-/**
- * EM DBs.
- */
-extern void *eem_db[TF_DIR_MAX];
-
-extern struct tf_tbl_scope_cb tbl_scopes[TF_NUM_TBL_SCOPE];
-
 /**
  * Function to free a page table
  *
@@ -367,7 +360,8 @@ tf_em_ctx_reg(struct tf *tfp,
 }
 
 int
-tf_em_ext_alloc(struct tf *tfp, struct tf_alloc_tbl_scope_parms *parms)
+tf_em_ext_alloc(struct tf *tfp,
+		struct tf_alloc_tbl_scope_parms *parms)
 {
 	int rc;
 	enum tf_dir dir;
@@ -376,30 +370,65 @@ tf_em_ext_alloc(struct tf *tfp, struct tf_alloc_tbl_scope_parms *parms)
 	struct tf_free_tbl_scope_parms free_parms;
 	struct tf_rm_allocate_parms aparms = { 0 };
 	struct tf_rm_free_parms fparms = { 0 };
+	struct tfp_calloc_parms cparms;
+	struct tf_session *tfs = NULL;
+	struct em_ext_db *ext_db = NULL;
+	void *ext_ptr = NULL;
+	uint16_t pf;
+
+
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR, "Failed to get tf_session, rc:%s\n",
+		strerror(-rc));
+		return rc;
+	}
+
+	rc = tf_session_get_em_ext_db(tfp, &ext_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			"Failed to get em_ext_db from session, rc:%s\n",
+			strerror(-rc));
+		return rc;
+	}
+	ext_db = (struct em_ext_db *)ext_ptr;
+
+	rc = tfp_get_pf(tfp, &pf);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "EEM: PF query error rc:%s\n",
+			    strerror(-rc));
+		goto cleanup;
+	}
 
 	/* Get Table Scope control block from the session pool */
-	aparms.rm_db = eem_db[TF_DIR_RX];
+	aparms.rm_db = ext_db->eem_db[TF_DIR_RX];
 	aparms.subtype = TF_EM_TBL_TYPE_TBL_SCOPE;
 	aparms.index = (uint32_t *)&parms->tbl_scope_id;
 	rc = tf_rm_allocate(&aparms);
 	if (rc) {
 		TFP_DRV_LOG(ERR,
 			    "Failed to allocate table scope\n");
-		return rc;
+		goto cleanup;
 	}
 
-	tbl_scope_cb = &tbl_scopes[parms->tbl_scope_id];
-	tbl_scope_cb->index = parms->tbl_scope_id;
-	tbl_scope_cb->tbl_scope_id = parms->tbl_scope_id;
-
-	rc = tfp_get_pf(tfp, &tbl_scope_cb->pf);
+	/* Create tbl_scope, initialize and attach to the session */
+	cparms.nitems = 1;
+	cparms.size = sizeof(struct tf_tbl_scope_cb);
+	cparms.alignment = 0;
+	rc = tfp_calloc(&cparms);
 	if (rc) {
+		/* Log error */
 		TFP_DRV_LOG(ERR,
-			    "EEM: PF query error rc:%s\n",
-			    strerror(-rc));
+			"Failed to allocate session table scope, rc:%s\n",
+			strerror(-rc));
 		goto cleanup;
 	}
 
+	tbl_scope_cb = cparms.mem_va;
+	tbl_scope_cb->tbl_scope_id = parms->tbl_scope_id;
+	tbl_scope_cb->pf = pf;
+
 	for (dir = 0; dir < TF_DIR_MAX; dir++) {
 		rc = tf_msg_em_qcaps(tfp,
 				     dir,
@@ -409,7 +438,7 @@ tf_em_ext_alloc(struct tf *tfp, struct tf_alloc_tbl_scope_parms *parms)
 				    "EEM: Unable to query for EEM capability,"
 				    " rc:%s\n",
 				    strerror(-rc));
-			goto cleanup;
+			goto cleanup_ts;
 		}
 	}
 
@@ -417,7 +446,7 @@ tf_em_ext_alloc(struct tf *tfp, struct tf_alloc_tbl_scope_parms *parms)
 	 * Validate and setup table sizes
 	 */
 	if (tf_em_validate_num_entries(tbl_scope_cb, parms))
-		goto cleanup;
+		goto cleanup_ts;
 
 	for (dir = 0; dir < TF_DIR_MAX; dir++) {
 		/*
@@ -429,7 +458,7 @@ tf_em_ext_alloc(struct tf *tfp, struct tf_alloc_tbl_scope_parms *parms)
 				    "EEM: Unable to register for EEM ctx,"
 				    " rc:%s\n",
 				    strerror(-rc));
-			goto cleanup;
+			goto cleanup_ts;
 		}
 
 		em_tables = tbl_scope_cb->em_ctx_info[dir].em_tables;
@@ -478,19 +507,29 @@ tf_em_ext_alloc(struct tf *tfp, struct tf_alloc_tbl_scope_parms *parms)
 		}
 	}
 
+	/* Insert into session tbl_scope list */
+	ll_insert(&ext_db->tbl_scope_ll, &tbl_scope_cb->ll_entry);
 	return 0;
 
 cleanup_full:
 	free_parms.tbl_scope_id = parms->tbl_scope_id;
+	/* Insert into session list prior to ext_free */
+	ll_insert(&ext_db->tbl_scope_ll, &tbl_scope_cb->ll_entry);
 	tf_em_ext_free(tfp, &free_parms);
 	return -EINVAL;
 
+cleanup_ts:
+	tfp_free(tbl_scope_cb);
+
 cleanup:
 	/* Free Table control block */
-	fparms.rm_db = eem_db[TF_DIR_RX];
+	fparms.rm_db = ext_db->eem_db[TF_DIR_RX];
 	fparms.subtype = TF_EM_TBL_TYPE_TBL_SCOPE;
 	fparms.index = parms->tbl_scope_id;
-	tf_rm_free(&fparms);
+	rc = tf_rm_free(&fparms);
+	if (rc)
+		TFP_DRV_LOG(ERR, "Failed to free table scope\n");
+
 	return -EINVAL;
 }
 
@@ -501,17 +540,35 @@ tf_em_ext_free(struct tf *tfp,
 	int rc = 0;
 	enum tf_dir  dir;
 	struct tf_tbl_scope_cb *tbl_scope_cb;
+	struct tf_session *tfs;
+	struct em_ext_db *ext_db = NULL;
+	void *ext_ptr = NULL;
 	struct tf_rm_free_parms aparms = { 0 };
 
-	tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id);
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR, "Failed to get tf_session, rc:%s\n",
+			    strerror(-rc));
+		return -EINVAL;
+	}
+
+	rc = tf_session_get_em_ext_db(tfp, &ext_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			"Failed to get em_ext_db from session, rc:%s\n",
+			strerror(-rc));
+		return rc;
+	}
+	ext_db = (struct em_ext_db *)ext_ptr;
 
+	tbl_scope_cb = tf_em_ext_common_tbl_scope_find(tfp, parms->tbl_scope_id);
 	if (tbl_scope_cb == NULL) {
 		TFP_DRV_LOG(ERR, "Table scope error\n");
 		return -EINVAL;
 	}
 
 	/* Free Table control block */
-	aparms.rm_db = eem_db[TF_DIR_RX];
+	aparms.rm_db = ext_db->eem_db[TF_DIR_RX];
 	aparms.subtype = TF_EM_TBL_TYPE_TBL_SCOPE;
 	aparms.index = parms->tbl_scope_id;
 	rc = tf_rm_free(&aparms);
@@ -534,6 +591,8 @@ tf_em_ext_free(struct tf *tfp,
 		tf_em_ctx_unreg(tfp, tbl_scope_cb, dir);
 	}
 
-	tbl_scopes[parms->tbl_scope_id].tbl_scope_id = TF_TBL_SCOPE_INVALID;
+	/* remove from session list and free tbl_scope */
+	ll_delete(&ext_db->tbl_scope_ll, &tbl_scope_cb->ll_entry);
+	tfp_free(tbl_scope_cb);
 	return rc;
 }
diff --git a/drivers/net/bnxt/tf_core/tf_msg.c b/drivers/net/bnxt/tf_core/tf_msg.c
index ec4c7890c3..c6eb94bee0 100644
--- a/drivers/net/bnxt/tf_core/tf_msg.c
+++ b/drivers/net/bnxt/tf_core/tf_msg.c
@@ -9,6 +9,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "tf_em_common.h"
 #include "tf_msg_common.h"
 #include "tf_device.h"
 #include "tf_msg.h"
@@ -16,7 +17,6 @@
 #include "tf_common.h"
 #include "tf_session.h"
 #include "tfp.h"
-#include "hwrm_tf.h"
 #include "tf_em.h"
 
 /* Specific msg size defines as we cannot use defines in tf.yaml. This
@@ -39,8 +39,19 @@
  * array size (define above) should be checked and compared.
  */
 #define TF_MSG_SIZE_HWRM_TF_GLOBAL_CFG_SET 56
+static_assert(sizeof(struct hwrm_tf_global_cfg_set_input) ==
+	      TF_MSG_SIZE_HWRM_TF_GLOBAL_CFG_SET,
+	      "HWRM message size changed: hwrm_tf_global_cfg_set_input");
+
 #define TF_MSG_SIZE_HWRM_TF_EM_INSERT      104
+static_assert(sizeof(struct hwrm_tf_em_insert_input) ==
+	      TF_MSG_SIZE_HWRM_TF_EM_INSERT,
+	      "HWRM message size changed: hwrm_tf_em_insert_input");
+
 #define TF_MSG_SIZE_HWRM_TF_TBL_TYPE_SET   128
+static_assert(sizeof(struct hwrm_tf_tbl_type_set_input) ==
+	      TF_MSG_SIZE_HWRM_TF_TBL_TYPE_SET,
+	      "HWRM message size changed: hwrm_tf_tbl_type_set_input");
 
 /**
  * This is the MAX data we can transport across regular HWRM
@@ -862,6 +873,117 @@ tf_msg_delete_em_entry(struct tf *tfp,
 	return 0;
 }
 
+int tf_msg_ext_em_ctxt_mem_alloc(struct tf *tfp,
+				struct hcapi_cfa_em_table *tbl,
+				uint64_t *dma_addr,
+				uint32_t *page_lvl,
+				uint32_t *page_size)
+{
+	struct tfp_send_msg_parms parms = { 0 };
+	struct hwrm_tf_ctxt_mem_alloc_input req = {0};
+	struct hwrm_tf_ctxt_mem_alloc_output resp = {0};
+	uint32_t mem_size_k;
+	int rc = 0;
+	struct tf_dev_info *dev;
+	struct tf_session *tfs;
+	uint32_t fw_se_id;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to lookup session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to lookup device, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	/* Retrieve the session information */
+	fw_se_id = tfs->session_id.internal.fw_session_id;
+
+	if (tbl->num_entries && tbl->entry_size) {
+		/* unit: kbytes */
+		mem_size_k = (tbl->num_entries / TF_KILOBYTE) * tbl->entry_size;
+		req.mem_size = tfp_cpu_to_le_32(mem_size_k);
+		req.fw_session_id = tfp_cpu_to_le_32(fw_se_id);
+		parms.tf_type = HWRM_TF_CTXT_MEM_ALLOC;
+		parms.req_data = (uint32_t *)&req;
+		parms.req_size = sizeof(req);
+		parms.resp_data = (uint32_t *)&resp;
+		parms.resp_size = sizeof(resp);
+		parms.mailbox = dev->ops->tf_dev_get_mailbox();
+		rc = tfp_send_msg_direct(tfp, &parms);
+		if (rc) {
+			TFP_DRV_LOG(ERR, "Failed ext_em_alloc error rc:%s\n",
+				strerror(-rc));
+			return rc;
+		}
+
+		*dma_addr = tfp_le_to_cpu_64(resp.page_dir);
+		*page_lvl = resp.page_level;
+		*page_size = resp.page_size;
+	}
+
+	return rc;
+}
+
+int tf_msg_ext_em_ctxt_mem_free(struct tf *tfp,
+				uint32_t mem_size_k,
+				uint64_t dma_addr,
+				uint8_t page_level,
+				uint8_t page_size)
+{
+	struct tfp_send_msg_parms parms = { 0 };
+	struct hwrm_tf_ctxt_mem_free_input req = {0};
+	struct hwrm_tf_ctxt_mem_free_output resp = {0};
+	int rc = 0;
+	struct tf_dev_info *dev;
+	struct tf_session *tfs;
+	uint32_t fw_se_id;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to lookup session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to lookup device, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	/* Retrieve the session information */
+	fw_se_id = tfs->session_id.internal.fw_session_id;
+
+	req.fw_session_id = tfp_cpu_to_le_32(fw_se_id);
+	req.mem_size = tfp_cpu_to_le_32(mem_size_k);
+	req.page_dir = tfp_cpu_to_le_64(dma_addr);
+	req.page_level = page_level;
+	req.page_size = page_size;
+	parms.tf_type = HWRM_TF_CTXT_MEM_FREE;
+	parms.req_data = (uint32_t *)&req;
+	parms.req_size = sizeof(req);
+	parms.resp_data = (uint32_t *)&resp;
+	parms.resp_size = sizeof(resp);
+	parms.mailbox = dev->ops->tf_dev_get_mailbox();
+	rc = tfp_send_msg_direct(tfp, &parms);
+
+	return rc;
+}
+
 int
 tf_msg_em_mem_rgtr(struct tf *tfp,
 		   int page_lvl,
@@ -875,6 +997,7 @@ tf_msg_em_mem_rgtr(struct tf *tfp,
 	struct tfp_send_msg_parms parms = { 0 };
 	struct tf_dev_info *dev;
 	struct tf_session *tfs;
+	uint32_t fw_se_id;
 
 	/* Retrieve the session information */
 	rc = tf_session_get_session_internal(tfp, &tfs);
@@ -893,7 +1016,9 @@ tf_msg_em_mem_rgtr(struct tf *tfp,
 			    strerror(-rc));
 		return rc;
 	}
+	fw_se_id = tfs->session_id.internal.fw_session_id;
 
+	req.fw_session_id = tfp_cpu_to_le_32(fw_se_id);
 	req.page_level = page_lvl;
 	req.page_size = page_size;
 	req.page_dir = tfp_cpu_to_le_64(dma_addr);
@@ -925,6 +1050,7 @@ tf_msg_em_mem_unrgtr(struct tf *tfp,
 	struct tfp_send_msg_parms parms = { 0 };
 	struct tf_dev_info *dev;
 	struct tf_session *tfs;
+	uint32_t fw_se_id;
 
 	/* Retrieve the session information */
 	rc = tf_session_get_session_internal(tfp, &tfs);
@@ -944,6 +1070,9 @@ tf_msg_em_mem_unrgtr(struct tf *tfp,
 		return rc;
 	}
 
+	fw_se_id = tfs->session_id.internal.fw_session_id;
+	req.fw_session_id = tfp_cpu_to_le_32(fw_se_id);
+
 	req.ctx_id = tfp_cpu_to_le_32(*ctx_id);
 
 	parms.tf_type = HWRM_TF_CTXT_MEM_UNRGTR;
@@ -970,6 +1099,7 @@ tf_msg_em_qcaps(struct tf *tfp,
 	struct tfp_send_msg_parms parms = { 0 };
 	struct tf_dev_info *dev;
 	struct tf_session *tfs;
+	uint32_t fw_se_id;
 
 	/* Retrieve the session information */
 	rc = tf_session_get_session_internal(tfp, &tfs);
@@ -980,6 +1110,7 @@ tf_msg_em_qcaps(struct tf *tfp,
 			    strerror(-rc));
 		return rc;
 	}
+	fw_se_id = tfs->session_id.internal.fw_session_id;
 
 	/* Retrieve the device information */
 	rc = tf_session_get_device(tfs, &dev);
@@ -996,6 +1127,7 @@ tf_msg_em_qcaps(struct tf *tfp,
 	req.flags = tfp_cpu_to_le_32(flags);
 
 	parms.tf_type = HWRM_TF_EXT_EM_QCAPS;
+	req.fw_session_id = tfp_cpu_to_le_32(fw_se_id);
 	parms.req_data = (uint32_t *)&req;
 	parms.req_size = sizeof(req);
 	parms.resp_data = (uint32_t *)&resp;
@@ -1082,6 +1214,80 @@ tf_msg_em_cfg(struct tf *tfp,
 	return rc;
 }
 
+int
+tf_msg_ext_em_cfg(struct tf *tfp,
+		  struct tf_tbl_scope_cb *tbl_scope_cb,
+		  uint32_t st_buckets,
+		  uint8_t flush_interval,
+		  enum tf_dir dir)
+{
+	struct hcapi_cfa_em_ctx_mem_info *ctxp = &tbl_scope_cb->em_ctx_info[dir];
+	struct hcapi_cfa_em_table *lkup_tbl, *act_tbl;
+	struct hwrm_tf_ext_em_cfg_input  req = {0};
+	struct hwrm_tf_ext_em_cfg_output resp = {0};
+	struct tfp_send_msg_parms parms = { 0 };
+	uint32_t flags;
+	struct tf_dev_info *dev;
+	struct tf_session *tfs;
+	uint32_t fw_se_id;
+	int rc;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup device, rc:%s\n",
+			    tf_dir_2_str(dir),
+			    strerror(-rc));
+		return rc;
+	}
+	fw_se_id = tfs->session_id.internal.fw_session_id;
+
+	lkup_tbl = &ctxp->em_tables[TF_EM_LKUP_TABLE];
+	act_tbl = &ctxp->em_tables[TF_ACTION_TABLE];
+	flags = (dir == TF_DIR_TX ? HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_TX :
+		 HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_RX);
+	flags |= HWRM_TF_EXT_EM_QCAPS_INPUT_FLAGS_PREFERRED_OFFLOAD;
+
+	req.flags = tfp_cpu_to_le_32(flags);
+	req.num_entries = tfp_cpu_to_le_32(act_tbl->num_entries);
+	req.lkup_static_buckets = tfp_cpu_to_le_32(st_buckets);
+	req.fw_session_id = tfp_cpu_to_le_32(fw_se_id);
+	req.flush_interval = flush_interval;
+	req.action_ctx_id = tfp_cpu_to_le_16(act_tbl->ctx_id);
+	req.action_tbl_scope = tfp_cpu_to_le_16(tbl_scope_cb->tbl_scope_id);
+	req.lkup_ctx_id = tfp_cpu_to_le_16(lkup_tbl->ctx_id);
+	req.lkup_tbl_scope = tfp_cpu_to_le_16(tbl_scope_cb->tbl_scope_id);
+
+	req.enables = (HWRM_TF_EXT_EM_CFG_INPUT_ENABLES_ACTION_CTX_ID |
+		       HWRM_TF_EXT_EM_CFG_INPUT_ENABLES_ACTION_TBL_SCOPE |
+		       HWRM_TF_EXT_EM_CFG_INPUT_ENABLES_LKUP_CTX_ID |
+		       HWRM_TF_EXT_EM_CFG_INPUT_ENABLES_LKUP_TBL_SCOPE |
+		       HWRM_TF_EXT_EM_CFG_INPUT_ENABLES_LKUP_STATIC_BUCKETS |
+		       HWRM_TF_EXT_EM_CFG_INPUT_ENABLES_NUM_ENTRIES);
+
+	parms.tf_type = HWRM_TF_EXT_EM_CFG;
+	parms.req_data = (uint32_t *)&req;
+	parms.req_size = sizeof(req);
+	parms.resp_data = (uint32_t *)&resp;
+	parms.resp_size = sizeof(resp);
+	parms.mailbox = dev->ops->tf_dev_get_mailbox();
+
+	rc = tfp_send_msg_direct(tfp,
+				 &parms);
+	return rc;
+}
+
 int
 tf_msg_em_op(struct tf *tfp,
 	     int dir,
@@ -1244,9 +1450,6 @@ tf_msg_tcam_entry_get(struct tf *tfp,
 	if (rc != 0)
 		return rc;
 
-	if (mparms.tf_resp_code != 0)
-		return tfp_le_to_cpu_32(mparms.tf_resp_code);
-
 	if (parms->key_size < resp.key_size ||
 	    parms->result_size < resp.result_size) {
 		rc = -EINVAL;
@@ -1264,7 +1467,7 @@ tf_msg_tcam_entry_get(struct tf *tfp,
 	tfp_memcpy(parms->mask, &resp.dev_data[resp.key_size], resp.key_size);
 	tfp_memcpy(parms->result, &resp.dev_data[resp.result_offset], resp.result_size);
 
-	return tfp_le_to_cpu_32(mparms.tf_resp_code);
+	return 0;
 }
 
 int
@@ -1388,7 +1591,7 @@ tf_msg_set_tbl_entry(struct tf *tfp,
 	if (rc)
 		return rc;
 
-	return tfp_le_to_cpu_32(parms.tf_resp_code);
+	return 0;
 }
 
 int
@@ -1454,15 +1657,22 @@ tf_msg_get_tbl_entry(struct tf *tfp,
 	if (rc)
 		return rc;
 
-	/* Verify that we got enough buffer to return the requested data */
-	if (tfp_le_to_cpu_32(resp.size) != size)
+	/*
+	 * The response will be 64 bytes long, the response size will
+	 * be in words (16). All we can test for is that the response
+	 * size is < to the requested size.
+	 */
+	if ((tfp_le_to_cpu_32(resp.size) * 4) < size)
 		return -EINVAL;
 
+	/*
+	 * Copy the requested number of bytes
+	 */
 	tfp_memcpy(data,
 		   &resp.data,
 		   size);
 
-	return tfp_le_to_cpu_32(parms.tf_resp_code);
+	return 0;
 }
 
 /* HWRM Tunneled messages */
@@ -1544,7 +1754,7 @@ tf_msg_get_global_cfg(struct tf *tfp,
 	else
 		return -EFAULT;
 
-	return tfp_le_to_cpu_32(parms.tf_resp_code);
+	return 0;
 }
 
 int
@@ -1560,9 +1770,6 @@ tf_msg_set_global_cfg(struct tf *tfp,
 	struct tf_dev_info *dev;
 	struct tf_session *tfs;
 
-	RTE_BUILD_BUG_ON(sizeof(struct hwrm_tf_global_cfg_set_input) !=
-			 TF_MSG_SIZE_HWRM_TF_GLOBAL_CFG_SET);
-
 	/* Retrieve the session information */
 	rc = tf_session_get_session_internal(tfp, &tfs);
 	if (rc) {
@@ -1637,7 +1844,7 @@ tf_msg_set_global_cfg(struct tf *tfp,
 	if (rc != 0)
 		return rc;
 
-	return tfp_le_to_cpu_32(parms.tf_resp_code);
+	return 0;
 }
 
 int
@@ -1651,8 +1858,8 @@ tf_msg_bulk_get_tbl_entry(struct tf *tfp,
 {
 	int rc;
 	struct tfp_send_msg_parms parms = { 0 };
-	struct tf_tbl_type_bulk_get_input req = { 0 };
-	struct tf_tbl_type_bulk_get_output resp = { 0 };
+	struct hwrm_tf_tbl_type_bulk_get_input req = { 0 };
+	struct hwrm_tf_tbl_type_bulk_get_output resp = { 0 };
 	int data_size = 0;
 	uint8_t fw_session_id;
 	struct tf_dev_info *dev;
@@ -1698,14 +1905,15 @@ tf_msg_bulk_get_tbl_entry(struct tf *tfp,
 
 	req.host_addr = tfp_cpu_to_le_64(physical_mem_addr);
 
-	MSG_PREP(parms,
-		 dev->ops->tf_dev_get_mailbox(),
-		 HWRM_TF,
-		 HWRM_TFT_TBL_TYPE_BULK_GET,
-		 req,
-		 resp);
+	parms.tf_type = HWRM_TF_TBL_TYPE_BULK_GET;
+	parms.req_data = (uint32_t *)&req;
+	parms.req_size = sizeof(req);
+	parms.resp_data = (uint32_t *)&resp;
+	parms.resp_size = sizeof(resp);
+	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_tunneled(tfp, &parms);
+	rc = tfp_send_msg_direct(tfp,
+				 &parms);
 	if (rc)
 		return rc;
 
@@ -1713,7 +1921,7 @@ tf_msg_bulk_get_tbl_entry(struct tf *tfp,
 	if (tfp_le_to_cpu_32(resp.size) != data_size)
 		return -EINVAL;
 
-	return tfp_le_to_cpu_32(parms.tf_resp_code);
+	return 0;
 }
 
 int
@@ -1772,12 +1980,9 @@ tf_msg_get_if_tbl_entry(struct tf *tfp,
 	if (rc != 0)
 		return rc;
 
-	if (parms.tf_resp_code != 0)
-		return tfp_le_to_cpu_32(parms.tf_resp_code);
-
 	tfp_memcpy(params->data, resp.data, req.size);
 
-	return tfp_le_to_cpu_32(parms.tf_resp_code);
+	return 0;
 }
 
 int
@@ -1832,5 +2037,5 @@ tf_msg_set_if_tbl_entry(struct tf *tfp,
 	if (rc != 0)
 		return rc;
 
-	return tfp_le_to_cpu_32(parms.tf_resp_code);
+	return 0;
 }
diff --git a/drivers/net/bnxt/tf_core/tf_msg.h b/drivers/net/bnxt/tf_core/tf_msg.h
index a14bcd3927..7b4a6a3d92 100644
--- a/drivers/net/bnxt/tf_core/tf_msg.h
+++ b/drivers/net/bnxt/tf_core/tf_msg.h
@@ -9,6 +9,7 @@
 #include <rte_common.h>
 #include <hsi_struct_def_dpdk.h>
 
+#include "tf_em_common.h"
 #include "tf_tbl.h"
 #include "tf_rm.h"
 #include "tf_tcam.h"
@@ -275,6 +276,60 @@ tf_msg_hash_insert_em_internal_entry(struct tf *tfp,
 int tf_msg_delete_em_entry(struct tf *tfp,
 			   struct tf_delete_em_entry_parms *em_parms);
 
+/**
+ * Sends Ext EM mem allocation request to Firmware
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [in] tbl
+ *   memory allocation details
+ *
+ * [out] dma_addr
+ *   memory address
+ *
+ * [out] page_lvl
+ *   page level
+ *
+ * [out] page_size
+ *   page size
+ *
+ * Returns:
+ *   0 on Success else internal Truflow error
+ */
+int tf_msg_ext_em_ctxt_mem_alloc(struct tf *tfp,
+			struct hcapi_cfa_em_table *tbl,
+			uint64_t *dma_addr,
+			uint32_t *page_lvl,
+			uint32_t *page_size);
+
+/**
+ * Sends Ext EM mem allocation request to Firmware
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [in] mem_size_k
+ *   memory size in KB
+ *
+ * [in] page_dir
+ *   Pointer to the PBL or PDL depending on number of levels
+ *
+ * [in] page_level
+ *   PBL indirect levels
+ *
+ * [in] page_size
+ *   page size
+ *
+ * Returns:
+ *   0 on Success else internal Truflow error
+ */
+int tf_msg_ext_em_ctxt_mem_free(struct tf *tfp,
+				uint32_t mem_size_k,
+				uint64_t dma_addr,
+				uint8_t page_level,
+				uint8_t page_size);
+
 /**
  * Sends EM mem register request to Firmware
  *
@@ -377,6 +432,38 @@ int tf_msg_em_cfg(struct tf *tfp,
 		  uint8_t flush_interval,
 		  int dir);
 
+/**
+ * Sends Ext EM config request to Firmware
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [in] fw_se_id
+ *   FW session id
+ *
+ * [in] tbl_scope_cb
+ *   Table scope parameters
+ *
+ * [in] st_buckets
+ *   static bucket size
+ *
+ * [in] flush_interval
+ *   Flush pending HW cached flows every 1/10th of value set in
+ *   seconds, both idle and active flows are flushed from the HW
+ *   cache. If set to 0, this feature will be disabled.
+ *
+ * [in] dir
+ *   Receive or Transmit direction
+ *
+ * Returns:
+ *   0 on Success else internal Truflow error
+ */
+int tf_msg_ext_em_cfg(struct tf *tfp,
+		      struct tf_tbl_scope_cb *tbl_scope_cb,
+		      uint32_t st_buckets,
+		      uint8_t flush_interval,
+		      enum tf_dir dir);
+
 /**
  * Sends EM operation request to Firmware
  *
diff --git a/drivers/net/bnxt/tf_core/tf_msg_common.h b/drivers/net/bnxt/tf_core/tf_msg_common.h
index 0c5c21fd68..49f334717d 100644
--- a/drivers/net/bnxt/tf_core/tf_msg_common.h
+++ b/drivers/net/bnxt/tf_core/tf_msg_common.h
@@ -15,7 +15,6 @@
 		parms.mailbox = mb;				\
 		parms.tf_type = type;				\
 		parms.tf_subtype = subtype;			\
-		parms.tf_resp_code = 0;				\
 		parms.req_size = sizeof(req);			\
 		parms.req_data = (uint32_t *)&(req);		\
 		parms.resp_size = sizeof(resp);			\
@@ -26,7 +25,6 @@
 		parms.mailbox = mb;				\
 		parms.tf_type = type;				\
 		parms.tf_subtype = subtype;			\
-		parms.tf_resp_code = 0;				\
 		parms.req_size  = 0;				\
 		parms.req_data  = NULL;				\
 		parms.resp_size = sizeof(resp);			\
@@ -37,7 +35,6 @@
 		parms.mailbox = mb;				\
 		parms.tf_type = type;				\
 		parms.tf_subtype = subtype;			\
-		parms.tf_resp_code = 0;				\
 		parms.req_size = sizeof(req);			\
 		parms.req_data = (uint32_t *)&(req);		\
 		parms.resp_size = 0;				\
diff --git a/drivers/net/bnxt/tf_core/tf_session.c b/drivers/net/bnxt/tf_core/tf_session.c
index d2b24f5e20..f591fbe3f5 100644
--- a/drivers/net/bnxt/tf_core/tf_session.c
+++ b/drivers/net/bnxt/tf_core/tf_session.c
@@ -173,6 +173,9 @@ tf_session_create(struct tf *tfp,
 	ll_insert(&session->client_ll, &client->ll_entry);
 	session->ref_count++;
 
+	/* Init session em_ext_db */
+	session->em_ext_db_handle = NULL;
+
 	rc = tf_dev_bind(tfp,
 			 parms->open_cfg->device_type,
 			 session->shadow_copy,
@@ -796,3 +799,115 @@ tf_session_get_session_id(struct tf *tfp,
 
 	return 0;
 }
+
+int
+tf_session_get_em_ext_db(struct tf *tfp,
+			 void **em_ext_db_handle)
+{
+	struct tf_session *tfs = NULL;
+	int rc = 0;
+
+	*em_ext_db_handle = NULL;
+
+	if (tfp == NULL)
+		return (-EINVAL);
+
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
+
+	*em_ext_db_handle = tfs->em_ext_db_handle;
+	return rc;
+}
+
+int
+tf_session_set_em_ext_db(struct tf *tfp,
+			 void *em_ext_db_handle)
+{
+	struct tf_session *tfs = NULL;
+	int rc = 0;
+
+	if (tfp == NULL)
+		return (-EINVAL);
+
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
+
+	tfs->em_ext_db_handle = em_ext_db_handle;
+	return rc;
+}
+
+int
+tf_session_get_db(struct tf *tfp,
+		  enum tf_module_type type,
+		  void **db_handle)
+{
+	struct tf_session *tfs = NULL;
+	int rc = 0;
+
+	*db_handle = NULL;
+
+	if (tfp == NULL)
+		return (-EINVAL);
+
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
+
+	switch (type) {
+	case TF_MODULE_TYPE_IDENTIFIER:
+		*db_handle = tfs->id_db_handle;
+		break;
+	case TF_MODULE_TYPE_TABLE:
+		*db_handle = tfs->tbl_db_handle;
+		break;
+	case TF_MODULE_TYPE_TCAM:
+		*db_handle = tfs->tcam_db_handle;
+		break;
+	case TF_MODULE_TYPE_EM:
+		*db_handle = tfs->em_db_handle;
+		break;
+	default:
+		rc = -EINVAL;
+		break;
+	}
+
+	return rc;
+}
+
+int
+tf_session_set_db(struct tf *tfp,
+		  enum tf_module_type type,
+		  void *db_handle)
+{
+	struct tf_session *tfs = NULL;
+	int rc = 0;
+
+	if (tfp == NULL)
+		return (-EINVAL);
+
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
+
+	switch (type) {
+	case TF_MODULE_TYPE_IDENTIFIER:
+		tfs->id_db_handle = db_handle;
+		break;
+	case TF_MODULE_TYPE_TABLE:
+		tfs->tbl_db_handle = db_handle;
+		break;
+	case TF_MODULE_TYPE_TCAM:
+		tfs->tcam_db_handle = db_handle;
+		break;
+	case TF_MODULE_TYPE_EM:
+		tfs->em_db_handle = db_handle;
+		break;
+	default:
+		rc = -EINVAL;
+		break;
+	}
+
+	return rc;
+}
diff --git a/drivers/net/bnxt/tf_core/tf_session.h b/drivers/net/bnxt/tf_core/tf_session.h
index 1d51fa12f8..e5c7a07daf 100644
--- a/drivers/net/bnxt/tf_core/tf_session.h
+++ b/drivers/net/bnxt/tf_core/tf_session.h
@@ -112,6 +112,31 @@ struct tf_session {
 	 * Linked list of clients registered for this session
 	 */
 	struct ll client_ll;
+
+	/**
+	 * em ext db reference for the session
+	 */
+	void *em_ext_db_handle;
+
+	/**
+	 * tcam db reference for the session
+	 */
+	void *tcam_db_handle;
+
+	/**
+	 * table db reference for the session
+	 */
+	void *tbl_db_handle;
+
+	/**
+	 * identifier db reference for the session
+	 */
+	void *id_db_handle;
+
+	/**
+	 * em db reference for the session
+	 */
+	void *em_db_handle;
 };
 
 /**
@@ -410,4 +435,69 @@ int tf_session_get_fw_session_id(struct tf *tfp,
 int tf_session_get_session_id(struct tf *tfp,
 			      union tf_session_id *session_id);
 
+/**
+ * API to get the em_ext_db from tf_session.
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [out] em_ext_db_handle, pointer to eem handle
+ *
+ * Returns:
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+int
+tf_session_get_em_ext_db(struct tf *tfp,
+			void **em_ext_db_handle);
+
+/**
+ * API to set the em_ext_db in tf_session.
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [in] em_ext_db_handle, pointer to eem handle
+ *
+ * Returns:
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+int
+tf_session_set_em_ext_db(struct tf *tfp,
+			void *em_ext_db_handle);
+
+/**
+ * API to get the db from tf_session.
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [out] db_handle, pointer to db handle
+ *
+ * Returns:
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+int
+tf_session_get_db(struct tf *tfp,
+		   enum tf_module_type type,
+		  void **db_handle);
+
+/**
+ * API to set the db in tf_session.
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [in] db_handle, pointer to db handle
+ *
+ * Returns:
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+int
+tf_session_set_db(struct tf *tfp,
+		   enum tf_module_type type,
+		  void *db_handle);
 #endif /* _TF_SESSION_H_ */
diff --git a/drivers/net/bnxt/tf_core/tf_tbl.h b/drivers/net/bnxt/tf_core/tf_tbl.h
index f0d8e94f7e..9271cf28eb 100644
--- a/drivers/net/bnxt/tf_core/tf_tbl.h
+++ b/drivers/net/bnxt/tf_core/tf_tbl.h
@@ -15,39 +15,9 @@ struct tf;
  * The Table module provides processing of Internal TF table types.
  */
 
-/**
- * Table scope control block content
- */
-struct tf_em_caps {
-	uint32_t flags;
-	uint32_t supported;
-	uint32_t max_entries_supported;
-	uint16_t key_entry_size;
-	uint16_t record_entry_size;
-	uint16_t efc_entry_size;
-};
-
 /** Invalid table scope id */
 #define TF_TBL_SCOPE_INVALID 0xffffffff
 
-/**
- * Table Scope Control Block
- *
- * Holds private data for a table scope. Only one instance of a table
- * scope with Internal EM is supported.
- */
-struct tf_tbl_scope_cb {
-	uint32_t tbl_scope_id;
-       /** The pf or parent pf of the vf used for table scope creation
-	*/
-	uint16_t pf;
-	int index;
-	struct hcapi_cfa_em_ctx_mem_info em_ctx_info[TF_DIR_MAX];
-	struct tf_em_caps em_caps[TF_DIR_MAX];
-	struct stack ext_act_pool[TF_DIR_MAX];
-	uint32_t *ext_act_pool_mem[TF_DIR_MAX];
-};
-
 /**
  * Table configuration parameters
  */
diff --git a/drivers/net/bnxt/tf_core/tf_util.c b/drivers/net/bnxt/tf_core/tf_util.c
index b4d47d5a8c..25f5c152d2 100644
--- a/drivers/net/bnxt/tf_core/tf_util.c
+++ b/drivers/net/bnxt/tf_core/tf_util.c
@@ -98,20 +98,8 @@ tf_tbl_type_2_str(enum tf_tbl_type tbl_type)
 		return "Mirror";
 	case TF_TBL_TYPE_UPAR:
 		return "UPAR";
-	case TF_TBL_TYPE_EPOCH0:
-		return "EPOCH0";
-	case TF_TBL_TYPE_EPOCH1:
-		return "EPOCH1";
 	case TF_TBL_TYPE_METADATA:
 		return "Metadata";
-	case TF_TBL_TYPE_CT_STATE:
-		return "Connection State";
-	case TF_TBL_TYPE_RANGE_PROF:
-		return "Range Profile";
-	case TF_TBL_TYPE_RANGE_ENTRY:
-		return "Range";
-	case TF_TBL_TYPE_LAG:
-		return "Link Aggregation";
 	case TF_TBL_TYPE_EM_FKB:
 		return "EM Flexible Key Builder";
 	case TF_TBL_TYPE_WC_FKB:
diff --git a/drivers/net/bnxt/tf_core/tf_util.h b/drivers/net/bnxt/tf_core/tf_util.h
index 1aa35b6b82..4caf50349d 100644
--- a/drivers/net/bnxt/tf_core/tf_util.h
+++ b/drivers/net/bnxt/tf_core/tf_util.h
@@ -9,6 +9,10 @@
 #include "tf_core.h"
 #include "tf_device.h"
 
+#define TF_BITS2BYTES(x) (((x) + 7) >> 3)
+#define TF_BITS2BYTES_WORD_ALIGN(x) ((((x) + 31) >> 5) * 4)
+#define TF_BITS2BYTES_64B_WORD_ALIGN(x) ((((x) + 63) >> 6) * 8)
+
 /**
  * Helper function converting direction to text string
  *
diff --git a/drivers/net/bnxt/tf_core/tfp.c b/drivers/net/bnxt/tf_core/tfp.c
index b88affcf1e..37c49b587d 100644
--- a/drivers/net/bnxt/tf_core/tfp.c
+++ b/drivers/net/bnxt/tf_core/tfp.c
@@ -53,40 +53,6 @@ tfp_send_msg_direct(struct tf *tfp,
 	return rc;
 }
 
-/**
- * Sends preformatted TruFlow msg to the TruFlow Firmware using
- * the Truflow tunnel HWRM message type.
- *
- * Returns success or failure code.
- */
-int
-tfp_send_msg_tunneled(struct tf *tfp,
-		      struct tfp_send_msg_parms *parms)
-{
-	int      rc = 0;
-	uint8_t  use_kong_mb = 1;
-
-	if (parms == NULL)
-		return -EINVAL;
-
-	if (parms->mailbox == TF_CHIMP_MB)
-		use_kong_mb = 0;
-
-	rc = bnxt_hwrm_tf_message_tunneled(container_of(tfp,
-						  struct bnxt,
-						  tfp),
-					   use_kong_mb,
-					   parms->tf_type,
-					   parms->tf_subtype,
-					   &parms->tf_resp_code,
-					   parms->req_data,
-					   parms->req_size,
-					   parms->resp_data,
-					   parms->resp_size);
-
-	return rc;
-}
-
 /**
  * Allocates zero'ed memory from the heap.
  *
diff --git a/drivers/net/bnxt/tf_core/tfp.h b/drivers/net/bnxt/tf_core/tfp.h
index 2e4ca7ac44..bcc56b0a54 100644
--- a/drivers/net/bnxt/tf_core/tfp.h
+++ b/drivers/net/bnxt/tf_core/tfp.h
@@ -56,11 +56,6 @@ struct tfp_send_msg_parms {
 	 * [in] tlv_subtype, specifies the tlv_subtype.
 	 */
 	uint16_t  tf_subtype;
-	/**
-	 * [out] tf_resp_code, response code from the internal tlv
-	 *       message. Only supported on tunneled messages.
-	 */
-	uint32_t tf_resp_code;
 	/**
 	 * [out] size, number specifying the request size of the data in bytes
 	 */
@@ -111,7 +106,6 @@ struct tfp_calloc_parms {
  * @page Portability
  *
  * @ref tfp_send_direct
- * @ref tfp_send_msg_tunneled
  *
  * @ref tfp_calloc
  * @ref tfp_memcpy
@@ -139,37 +133,6 @@ struct tfp_calloc_parms {
 int tfp_send_msg_direct(struct tf *tfp,
 			struct tfp_send_msg_parms *parms);
 
-/**
- * Provides communication capability from the TrueFlow API layer to
- * the TrueFlow firmware. The portability layer internally provides
- * the transport to the firmware.
- *
- * [in] session, pointer to session handle
- * [in] parms, parameter structure
- *
- * Returns:
- *   0              - Success
- *   -1             - Global error like not supported
- *   -EINVAL        - Parameter Error
- */
-int tfp_send_msg_tunneled(struct tf *tfp,
-			  struct tfp_send_msg_parms *parms);
-
-/**
- * Sends OEM command message to Chimp
- *
- * [in] session, pointer to session handle
- * [in] max_flows, max number of flows requested
- *
- * Returns:
- *   0              - Success
- *   -1             - Global error like not supported
- *   -EINVAL        - Parameter Error
- */
-int
-tfp_msg_hwrm_oem_cmd(struct tf *tfp,
-		     uint32_t max_flows);
-
 /**
  * Sends OEM command message to Chimp
  *
@@ -253,21 +216,6 @@ int tfp_get_fid(struct tf *tfp, uint16_t *fw_fid);
 #define tfp_bswap_32(val) rte_bswap32(val)
 #define tfp_bswap_64(val) rte_bswap64(val)
 
-/**
- * Lookup of the FID in the platform specific structure.
- *
- * [in] session
- *   Pointer to session handle
- *
- * [out] fw_fid
- *   Pointer to the fw_fid
- *
- * Returns:
- *   0       - Success
- *   -EINVAL - Parameter error
- */
-int tfp_get_fid(struct tf *tfp, uint16_t *fw_fid);
-
 /**
  * Get the PF associated with the fw communications channel.
  *
-- 
2.17.1


^ permalink raw reply	[flat|nested] 129+ messages in thread

* [dpdk-dev] [PATCH 13/58] net/bnxt: change RM database type
  2021-05-30  8:58 [dpdk-dev] [PATCH 00/58] enhancements to host based flow table management Venkat Duvvuru
                   ` (11 preceding siblings ...)
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 12/58] net/bnxt: modify TRUFLOW HWRM messages Venkat Duvvuru
@ 2021-05-30  8:58 ` Venkat Duvvuru
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 14/58] net/bnxt: add shared session support Venkat Duvvuru
                   ` (45 subsequent siblings)
  58 siblings, 0 replies; 129+ messages in thread
From: Venkat Duvvuru @ 2021-05-30  8:58 UTC (permalink / raw)
  To: dev; +Cc: Jay Ding, Randy Schacher, Venkat Duvvuru

From: Jay Ding <jay.ding@broadcom.com>

RM databases are statically defined in each module. New static
database needs to be defined in the code when multiple sessions
are added. Add dynamic alloc database and associate it to each
session.

Signed-off-by: Jay Ding <jay.ding@broadcom.com>
Signed-off-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Farah Smith <farah.smith@broadcom.com>
---
 drivers/net/bnxt/tf_core/tf_em.h          |  10 ++
 drivers/net/bnxt/tf_core/tf_em_internal.c |  44 +++++--
 drivers/net/bnxt/tf_core/tf_identifier.c  |  82 ++++++++++--
 drivers/net/bnxt/tf_core/tf_identifier.h  |  10 ++
 drivers/net/bnxt/tf_core/tf_tbl.c         | 151 +++++++++++++++++-----
 drivers/net/bnxt/tf_core/tf_tbl.h         |  10 ++
 drivers/net/bnxt/tf_core/tf_tcam.c        | 107 ++++++++++++---
 drivers/net/bnxt/tf_core/tf_tcam.h        |  10 ++
 8 files changed, 351 insertions(+), 73 deletions(-)

diff --git a/drivers/net/bnxt/tf_core/tf_em.h b/drivers/net/bnxt/tf_core/tf_em.h
index 2de1862cd9..19ad7f12be 100644
--- a/drivers/net/bnxt/tf_core/tf_em.h
+++ b/drivers/net/bnxt/tf_core/tf_em.h
@@ -133,6 +133,16 @@ struct tf_em_cfg_parms {
 	enum tf_mem_type mem_type;
 };
 
+/**
+ * EM database
+ *
+ * EM rm database
+ *
+ */
+struct em_rm_db {
+	struct rm_db *em_db[TF_DIR_MAX];
+};
+
 /**
  * @page em EM
  *
diff --git a/drivers/net/bnxt/tf_core/tf_em_internal.c b/drivers/net/bnxt/tf_core/tf_em_internal.c
index 043f9be4da..5a100ef1de 100644
--- a/drivers/net/bnxt/tf_core/tf_em_internal.c
+++ b/drivers/net/bnxt/tf_core/tf_em_internal.c
@@ -18,11 +18,6 @@
 
 #include "bnxt.h"
 
-/**
- * EM DBs.
- */
-static void *em_db[TF_DIR_MAX];
-
 #define TF_EM_DB_EM_REC 0
 
 /**
@@ -242,6 +237,8 @@ tf_em_int_bind(struct tf *tfp,
 	uint8_t db_exists = 0;
 	struct tf_rm_get_alloc_info_parms iparms;
 	struct tf_rm_alloc_info info;
+	struct em_rm_db *em_db;
+	struct tfp_calloc_parms cparms;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -251,6 +248,21 @@ tf_em_int_bind(struct tf *tfp,
 		return -EINVAL;
 	}
 
+	memset(&db_cfg, 0, sizeof(db_cfg));
+	cparms.nitems = 1;
+	cparms.size = sizeof(struct em_rm_db);
+	cparms.alignment = 0;
+	if (tfp_calloc(&cparms) != 0) {
+		TFP_DRV_LOG(ERR, "em_rm_db alloc error %s\n",
+			    strerror(ENOMEM));
+		return -ENOMEM;
+	}
+
+	em_db = cparms.mem_va;
+	for (i = 0; i < TF_DIR_MAX; i++)
+		em_db->em_db[i] = NULL;
+	tf_session_set_db(tfp, TF_MODULE_TYPE_EM, em_db);
+
 	db_cfg.module = TF_MODULE_TYPE_EM;
 	db_cfg.num_elements = parms->num_elements;
 	db_cfg.cfg = parms->cfg;
@@ -277,7 +289,8 @@ tf_em_int_bind(struct tf *tfp,
 			return rc;
 		}
 
-		db_cfg.rm_db = &em_db[i];
+		db_cfg.rm_db = (void *)&em_db->em_db[i];
+
 		rc = tf_rm_create_db(tfp, &db_cfg);
 		if (rc) {
 			TFP_DRV_LOG(ERR,
@@ -293,7 +306,7 @@ tf_em_int_bind(struct tf *tfp,
 		init = 1;
 
 	for (i = 0; i < TF_DIR_MAX; i++) {
-		iparms.rm_db = em_db[i];
+		iparms.rm_db = em_db->em_db[i];
 		iparms.subtype = TF_EM_DB_EM_REC;
 		iparms.info = &info;
 
@@ -323,6 +336,8 @@ tf_em_int_unbind(struct tf *tfp)
 	int rc;
 	int i;
 	struct tf_rm_free_db_parms fparms = { 0 };
+	struct em_rm_db *em_db;
+	void *em_db_ptr = NULL;
 
 	TF_CHECK_PARMS1(tfp);
 
@@ -336,16 +351,25 @@ tf_em_int_unbind(struct tf *tfp)
 	for (i = 0; i < TF_DIR_MAX; i++)
 		tf_free_em_pool(i);
 
+	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_EM, &em_db_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to get em_ext_db from session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	em_db = (struct em_rm_db *)em_db_ptr;
+
 	for (i = 0; i < TF_DIR_MAX; i++) {
 		fparms.dir = i;
-		fparms.rm_db = em_db[i];
-		if (em_db[i] != NULL) {
+		fparms.rm_db = em_db->em_db[i];
+		if (em_db->em_db[i] != NULL) {
 			rc = tf_rm_free_db(tfp, &fparms);
 			if (rc)
 				return rc;
 		}
 
-		em_db[i] = NULL;
+		em_db->em_db[i] = NULL;
 	}
 
 	init = 0;
diff --git a/drivers/net/bnxt/tf_core/tf_identifier.c b/drivers/net/bnxt/tf_core/tf_identifier.c
index 9d0a578085..ee68b6ca58 100644
--- a/drivers/net/bnxt/tf_core/tf_identifier.c
+++ b/drivers/net/bnxt/tf_core/tf_identifier.c
@@ -11,14 +11,10 @@
 #include "tf_rm.h"
 #include "tf_util.h"
 #include "tfp.h"
+#include "tf_session.h"
 
 struct tf;
 
-/**
- * Identifier DBs.
- */
-static void *ident_db[TF_DIR_MAX];
-
 /**
  * Init flag, set on bind and cleared on unbind
  */
@@ -43,6 +39,8 @@ tf_ident_bind(struct tf *tfp,
 	struct tf_rm_create_db_parms db_cfg = { 0 };
 	struct tf_shadow_ident_cfg_parms shadow_cfg = { 0 };
 	struct tf_shadow_ident_create_db_parms shadow_cdb = { 0 };
+	struct ident_rm_db *ident_db;
+	struct tfp_calloc_parms cparms;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -52,14 +50,29 @@ tf_ident_bind(struct tf *tfp,
 		return -EINVAL;
 	}
 
+	memset(&db_cfg, 0, sizeof(db_cfg));
+	cparms.nitems = 1;
+	cparms.size = sizeof(struct ident_rm_db);
+	cparms.alignment = 0;
+	if (tfp_calloc(&cparms) != 0) {
+		TFP_DRV_LOG(ERR, "ident_rm_db alloc error %s\n",
+			    strerror(ENOMEM));
+		return -ENOMEM;
+	}
+
+	ident_db = cparms.mem_va;
+	for (i = 0; i < TF_DIR_MAX; i++)
+		ident_db->ident_db[i] = NULL;
+	tf_session_set_db(tfp, TF_MODULE_TYPE_IDENTIFIER, ident_db);
+
 	db_cfg.module = TF_MODULE_TYPE_IDENTIFIER;
 	db_cfg.num_elements = parms->num_elements;
 	db_cfg.cfg = parms->cfg;
 
 	for (i = 0; i < TF_DIR_MAX; i++) {
+		db_cfg.rm_db = (void *)&ident_db->ident_db[i];
 		db_cfg.dir = i;
 		db_cfg.alloc_cnt = parms->resources->ident_cnt[i].cnt;
-		db_cfg.rm_db = &ident_db[i];
 		rc = tf_rm_create_db(tfp, &db_cfg);
 		if (rc) {
 			TFP_DRV_LOG(ERR,
@@ -102,6 +115,8 @@ tf_ident_unbind(struct tf *tfp)
 	int i;
 	struct tf_rm_free_db_parms fparms = { 0 };
 	struct tf_shadow_ident_free_db_parms sparms = { 0 };
+	struct ident_rm_db *ident_db;
+	void *ident_db_ptr = NULL;
 
 	TF_CHECK_PARMS1(tfp);
 
@@ -112,9 +127,18 @@ tf_ident_unbind(struct tf *tfp)
 		return 0;
 	}
 
+	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to get ident_db from session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	ident_db = (struct ident_rm_db *)ident_db_ptr;
+
 	for (i = 0; i < TF_DIR_MAX; i++) {
+		fparms.rm_db = ident_db->ident_db[i];
 		fparms.dir = i;
-		fparms.rm_db = ident_db[i];
 		rc = tf_rm_free_db(tfp, &fparms);
 		if (rc) {
 			TFP_DRV_LOG(ERR,
@@ -131,7 +155,7 @@ tf_ident_unbind(struct tf *tfp)
 			}
 			ident_shadow_db[i] = NULL;
 		}
-		ident_db[i] = NULL;
+		ident_db->ident_db[i] = NULL;
 	}
 
 	init = 0;
@@ -149,6 +173,8 @@ tf_ident_alloc(struct tf *tfp __rte_unused,
 	uint32_t base_id;
 	struct tf_rm_allocate_parms aparms = { 0 };
 	struct tf_shadow_ident_insert_parms iparms = { 0 };
+	struct ident_rm_db *ident_db;
+	void *ident_db_ptr = NULL;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -159,8 +185,16 @@ tf_ident_alloc(struct tf *tfp __rte_unused,
 		return -EINVAL;
 	}
 
-	/* Allocate requested element */
-	aparms.rm_db = ident_db[parms->dir];
+	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to get ident_db from session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	ident_db = (struct ident_rm_db *)ident_db_ptr;
+
+	aparms.rm_db = ident_db->ident_db[parms->dir];
 	aparms.subtype = parms->type;
 	aparms.index = &id;
 	aparms.base_index = &base_id;
@@ -203,6 +237,8 @@ tf_ident_free(struct tf *tfp __rte_unused,
 	struct tf_shadow_ident_remove_parms rparms = { 0 };
 	int allocated = 0;
 	uint32_t base_id;
+	struct ident_rm_db *ident_db;
+	void *ident_db_ptr = NULL;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -213,8 +249,17 @@ tf_ident_free(struct tf *tfp __rte_unused,
 		return -EINVAL;
 	}
 
+	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to get ident_db from session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	ident_db = (struct ident_rm_db *)ident_db_ptr;
+
 	/* Check if element is in use */
-	aparms.rm_db = ident_db[parms->dir];
+	aparms.rm_db = ident_db->ident_db[parms->dir];
 	aparms.subtype = parms->type;
 	aparms.index = parms->id;
 	aparms.base_index = &base_id;
@@ -254,7 +299,7 @@ tf_ident_free(struct tf *tfp __rte_unused,
 	}
 
 	/* Free requested element */
-	fparms.rm_db = ident_db[parms->dir];
+	fparms.rm_db = ident_db->ident_db[parms->dir];
 	fparms.subtype = parms->type;
 	fparms.index = parms->id;
 	rc = tf_rm_free(&fparms);
@@ -279,6 +324,8 @@ tf_ident_search(struct tf *tfp __rte_unused,
 	struct tf_shadow_ident_search_parms sparms = { 0 };
 	int allocated = 0;
 	uint32_t base_id;
+	struct ident_rm_db *ident_db;
+	void *ident_db_ptr = NULL;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -296,8 +343,17 @@ tf_ident_search(struct tf *tfp __rte_unused,
 		return -EINVAL;
 	}
 
+	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to get ident_db from session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	ident_db = (struct ident_rm_db *)ident_db_ptr;
+
 	/* Check if element is in use */
-	aparms.rm_db = ident_db[parms->dir];
+	aparms.rm_db = ident_db->ident_db[parms->dir];
 	aparms.subtype = parms->type;
 	aparms.index = parms->search_id;
 	aparms.base_index = &base_id;
diff --git a/drivers/net/bnxt/tf_core/tf_identifier.h b/drivers/net/bnxt/tf_core/tf_identifier.h
index 2700416c71..54cecbfd4c 100644
--- a/drivers/net/bnxt/tf_core/tf_identifier.h
+++ b/drivers/net/bnxt/tf_core/tf_identifier.h
@@ -99,6 +99,16 @@ struct tf_ident_search_parms {
 	uint32_t *ref_cnt;
 };
 
+/**
+ * Identifier database
+ *
+ * Identifier rm database
+ *
+ */
+struct ident_rm_db {
+	struct rm_db *ident_db[TF_DIR_MAX];
+};
+
 /**
  * @page ident Identity Management
  *
diff --git a/drivers/net/bnxt/tf_core/tf_tbl.c b/drivers/net/bnxt/tf_core/tf_tbl.c
index 75dbe2066f..2d0dda18c9 100644
--- a/drivers/net/bnxt/tf_core/tf_tbl.c
+++ b/drivers/net/bnxt/tf_core/tf_tbl.c
@@ -26,11 +26,6 @@
 
 struct tf;
 
-/**
- * Table DBs.
- */
-static void *tbl_db[TF_DIR_MAX];
-
 /**
  * Table Shadow DBs
  */
@@ -50,8 +45,10 @@ int
 tf_tbl_bind(struct tf *tfp,
 	    struct tf_tbl_cfg_parms *parms)
 {
-	int rc, d;
+	int rc, d, i;
 	struct tf_rm_create_db_parms db_cfg = { 0 };
+	struct tbl_rm_db *tbl_db;
+	struct tfp_calloc_parms cparms;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -61,6 +58,21 @@ tf_tbl_bind(struct tf *tfp,
 		return -EINVAL;
 	}
 
+	memset(&db_cfg, 0, sizeof(db_cfg));
+	cparms.nitems = 1;
+	cparms.size = sizeof(struct tbl_rm_db);
+	cparms.alignment = 0;
+	if (tfp_calloc(&cparms) != 0) {
+		TFP_DRV_LOG(ERR, "tbl_rm_db alloc error %s\n",
+			    strerror(ENOMEM));
+		return -ENOMEM;
+	}
+
+	tbl_db = cparms.mem_va;
+	for (i = 0; i < TF_DIR_MAX; i++)
+		tbl_db->tbl_db[i] = NULL;
+	tf_session_set_db(tfp, TF_MODULE_TYPE_TABLE, tbl_db);
+
 	db_cfg.num_elements = parms->num_elements;
 	db_cfg.module = TF_MODULE_TYPE_TABLE;
 	db_cfg.num_elements = parms->num_elements;
@@ -69,7 +81,8 @@ tf_tbl_bind(struct tf *tfp,
 	for (d = 0; d < TF_DIR_MAX; d++) {
 		db_cfg.dir = d;
 		db_cfg.alloc_cnt = parms->resources->tbl_cnt[d].cnt;
-		db_cfg.rm_db = &tbl_db[d];
+		db_cfg.rm_db = (void *)&tbl_db->tbl_db[d];
+
 		rc = tf_rm_create_db(tfp, &db_cfg);
 		if (rc) {
 			TFP_DRV_LOG(ERR,
@@ -79,7 +92,6 @@ tf_tbl_bind(struct tf *tfp,
 			return rc;
 		}
 	}
-
 	init = 1;
 
 	TFP_DRV_LOG(INFO,
@@ -94,6 +106,8 @@ tf_tbl_unbind(struct tf *tfp)
 	int rc;
 	int i;
 	struct tf_rm_free_db_parms fparms = { 0 };
+	struct tbl_rm_db *tbl_db;
+	void *tbl_db_ptr = NULL;
 	TF_CHECK_PARMS1(tfp);
 
 	/* Bail if nothing has been initialized */
@@ -103,14 +117,23 @@ tf_tbl_unbind(struct tf *tfp)
 		return 0;
 	}
 
+	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to get em_ext_db from session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
+
 	for (i = 0; i < TF_DIR_MAX; i++) {
 		fparms.dir = i;
-		fparms.rm_db = tbl_db[i];
+		fparms.rm_db = tbl_db->tbl_db[i];
 		rc = tf_rm_free_db(tfp, &fparms);
 		if (rc)
 			return rc;
 
-		tbl_db[i] = NULL;
+		tbl_db->tbl_db[i] = NULL;
 	}
 
 	init = 0;
@@ -129,6 +152,8 @@ tf_tbl_alloc(struct tf *tfp __rte_unused,
 	struct tf_session *tfs;
 	struct tf_dev_info *dev;
 	uint16_t base = 0, shift = 0;
+	struct tbl_rm_db *tbl_db;
+	void *tbl_db_ptr = NULL;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -149,10 +174,22 @@ tf_tbl_alloc(struct tf *tfp __rte_unused,
 	if (rc)
 		return rc;
 
+	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to get em_ext_db from session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
+
 	/* Only get table info if required for the device */
 	if (dev->ops->tf_dev_get_tbl_info) {
-		rc = dev->ops->tf_dev_get_tbl_info(tfp, tbl_db[parms->dir],
-						   parms->type, &base, &shift);
+		rc = dev->ops->tf_dev_get_tbl_info(tfp,
+						   tbl_db->tbl_db[parms->dir],
+						   parms->type,
+						   &base,
+						   &shift);
 		if (rc) {
 			TFP_DRV_LOG(ERR,
 				    "%s: Failed to get table info:%d\n",
@@ -163,7 +200,7 @@ tf_tbl_alloc(struct tf *tfp __rte_unused,
 	}
 
 	/* Allocate requested element */
-	aparms.rm_db = tbl_db[parms->dir];
+	aparms.rm_db = tbl_db->tbl_db[parms->dir];
 	aparms.subtype = parms->type;
 	aparms.index = &idx;
 	rc = tf_rm_allocate(&aparms);
@@ -192,6 +229,8 @@ tf_tbl_free(struct tf *tfp __rte_unused,
 	struct tf_session *tfs;
 	struct tf_dev_info *dev;
 	uint16_t base = 0, shift = 0;
+	struct tbl_rm_db *tbl_db;
+	void *tbl_db_ptr = NULL;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -211,10 +250,22 @@ tf_tbl_free(struct tf *tfp __rte_unused,
 	if (rc)
 		return rc;
 
+	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to get em_ext_db from session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
+
 	/* Only get table info if required for the device */
 	if (dev->ops->tf_dev_get_tbl_info) {
-		rc = dev->ops->tf_dev_get_tbl_info(tfp, tbl_db[parms->dir],
-						   parms->type, &base, &shift);
+		rc = dev->ops->tf_dev_get_tbl_info(tfp,
+						   tbl_db->tbl_db[parms->dir],
+						   parms->type,
+						   &base,
+						   &shift);
 		if (rc) {
 			TFP_DRV_LOG(ERR,
 				    "%s: Failed to get table info:%d\n",
@@ -225,7 +276,7 @@ tf_tbl_free(struct tf *tfp __rte_unused,
 	}
 
 	/* Check if element is in use */
-	aparms.rm_db = tbl_db[parms->dir];
+	aparms.rm_db = tbl_db->tbl_db[parms->dir];
 	aparms.subtype = parms->type;
 
 	TF_TBL_PTR_TO_RM(&aparms.index, parms->idx, base, shift);
@@ -244,7 +295,7 @@ tf_tbl_free(struct tf *tfp __rte_unused,
 		return -EINVAL;
 	}
 	/* Free requested element */
-	fparms.rm_db = tbl_db[parms->dir];
+	fparms.rm_db = tbl_db->tbl_db[parms->dir];
 	fparms.subtype = parms->type;
 
 	TF_TBL_PTR_TO_RM(&fparms.index, parms->idx, base, shift);
@@ -290,6 +341,8 @@ tf_tbl_set(struct tf *tfp,
 	struct tf_session *tfs;
 	struct tf_dev_info *dev;
 	uint16_t base = 0, shift = 0;
+	struct tbl_rm_db *tbl_db;
+	void *tbl_db_ptr = NULL;
 
 	TF_CHECK_PARMS3(tfp, parms, parms->data);
 
@@ -310,10 +363,22 @@ tf_tbl_set(struct tf *tfp,
 	if (rc)
 		return rc;
 
+	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to get em_ext_db from session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
+
 	/* Only get table info if required for the device */
 	if (dev->ops->tf_dev_get_tbl_info) {
-		rc = dev->ops->tf_dev_get_tbl_info(tfp, tbl_db[parms->dir],
-						   parms->type, &base, &shift);
+		rc = dev->ops->tf_dev_get_tbl_info(tfp,
+						   tbl_db->tbl_db[parms->dir],
+						   parms->type,
+						   &base,
+						   &shift);
 		if (rc) {
 			TFP_DRV_LOG(ERR,
 				    "%s: Failed to get table info:%d\n",
@@ -324,7 +389,7 @@ tf_tbl_set(struct tf *tfp,
 	}
 
 	/* Verify that the entry has been previously allocated */
-	aparms.rm_db = tbl_db[parms->dir];
+	aparms.rm_db = tbl_db->tbl_db[parms->dir];
 	aparms.subtype = parms->type;
 	TF_TBL_PTR_TO_RM(&aparms.index, parms->idx, base, shift);
 
@@ -343,7 +408,7 @@ tf_tbl_set(struct tf *tfp,
 	}
 
 	/* Set the entry */
-	hparms.rm_db = tbl_db[parms->dir];
+	hparms.rm_db = tbl_db->tbl_db[parms->dir];
 	hparms.subtype = parms->type;
 	hparms.hcapi_type = &hcapi_type;
 	rc = tf_rm_get_hcapi_type(&hparms);
@@ -386,6 +451,8 @@ tf_tbl_get(struct tf *tfp,
 	struct tf_session *tfs;
 	struct tf_dev_info *dev;
 	uint16_t base = 0, shift = 0;
+	struct tbl_rm_db *tbl_db;
+	void *tbl_db_ptr = NULL;
 
 	TF_CHECK_PARMS3(tfp, parms, parms->data);
 
@@ -407,10 +474,22 @@ tf_tbl_get(struct tf *tfp,
 	if (rc)
 		return rc;
 
+	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to get em_ext_db from session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
+
 	/* Only get table info if required for the device */
 	if (dev->ops->tf_dev_get_tbl_info) {
-		rc = dev->ops->tf_dev_get_tbl_info(tfp, tbl_db[parms->dir],
-						   parms->type, &base, &shift);
+		rc = dev->ops->tf_dev_get_tbl_info(tfp,
+						   tbl_db->tbl_db[parms->dir],
+						   parms->type,
+						   &base,
+						   &shift);
 		if (rc) {
 			TFP_DRV_LOG(ERR,
 				    "%s: Failed to get table info:%d\n",
@@ -421,7 +500,7 @@ tf_tbl_get(struct tf *tfp,
 	}
 
 	/* Verify that the entry has been previously allocated */
-	aparms.rm_db = tbl_db[parms->dir];
+	aparms.rm_db = tbl_db->tbl_db[parms->dir];
 	aparms.subtype = parms->type;
 	TF_TBL_PTR_TO_RM(&aparms.index, parms->idx, base, shift);
 
@@ -440,7 +519,7 @@ tf_tbl_get(struct tf *tfp,
 	}
 
 	/* Set the entry */
-	hparms.rm_db = tbl_db[parms->dir];
+	hparms.rm_db = tbl_db->tbl_db[parms->dir];
 	hparms.subtype = parms->type;
 	hparms.hcapi_type = &hcapi_type;
 	rc = tf_rm_get_hcapi_type(&hparms);
@@ -483,6 +562,8 @@ tf_tbl_bulk_get(struct tf *tfp,
 	struct tf_session *tfs;
 	struct tf_dev_info *dev;
 	uint16_t base = 0, shift = 0;
+	struct tbl_rm_db *tbl_db;
+	void *tbl_db_ptr = NULL;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -504,10 +585,22 @@ tf_tbl_bulk_get(struct tf *tfp,
 	if (rc)
 		return rc;
 
+	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to get em_ext_db from session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
+
 	/* Only get table info if required for the device */
 	if (dev->ops->tf_dev_get_tbl_info) {
-		rc = dev->ops->tf_dev_get_tbl_info(tfp, tbl_db[parms->dir],
-						   parms->type, &base, &shift);
+		rc = dev->ops->tf_dev_get_tbl_info(tfp,
+						   tbl_db->tbl_db[parms->dir],
+						   parms->type,
+						   &base,
+						   &shift);
 		if (rc) {
 			TFP_DRV_LOG(ERR,
 				    "%s: Failed to get table info:%d\n",
@@ -518,7 +611,7 @@ tf_tbl_bulk_get(struct tf *tfp,
 	}
 
 	/* Verify that the entries are in the range of reserved resources. */
-	cparms.rm_db = tbl_db[parms->dir];
+	cparms.rm_db = tbl_db->tbl_db[parms->dir];
 	cparms.subtype = parms->type;
 
 	TF_TBL_PTR_TO_RM(&cparms.starting_index, parms->starting_idx,
@@ -538,7 +631,7 @@ tf_tbl_bulk_get(struct tf *tfp,
 		return rc;
 	}
 
-	hparms.rm_db = tbl_db[parms->dir];
+	hparms.rm_db = tbl_db->tbl_db[parms->dir];
 	hparms.subtype = parms->type;
 	hparms.hcapi_type = &hcapi_type;
 	rc = tf_rm_get_hcapi_type(&hparms);
diff --git a/drivers/net/bnxt/tf_core/tf_tbl.h b/drivers/net/bnxt/tf_core/tf_tbl.h
index 9271cf28eb..83b72d1b3f 100644
--- a/drivers/net/bnxt/tf_core/tf_tbl.h
+++ b/drivers/net/bnxt/tf_core/tf_tbl.h
@@ -229,6 +229,16 @@ struct tf_tbl_get_bulk_parms {
 	uint64_t physical_mem_addr;
 };
 
+/**
+ * Table RM database
+ *
+ * Table rm database
+ *
+ */
+struct tbl_rm_db {
+	struct rm_db *tbl_db[TF_DIR_MAX];
+};
+
 /**
  * @page tbl Table
  *
diff --git a/drivers/net/bnxt/tf_core/tf_tcam.c b/drivers/net/bnxt/tf_core/tf_tcam.c
index 1b5c29815d..c2eef26dbb 100644
--- a/drivers/net/bnxt/tf_core/tf_tcam.c
+++ b/drivers/net/bnxt/tf_core/tf_tcam.c
@@ -18,11 +18,6 @@
 
 struct tf;
 
-/**
- * TCAM DBs.
- */
-static void *tcam_db[TF_DIR_MAX];
-
 /**
  * TCAM Shadow DBs
  */
@@ -55,6 +50,8 @@ tf_tcam_bind(struct tf *tfp,
 	uint16_t num_slices = 1;
 	struct tf_session *tfs;
 	struct tf_dev_info *dev;
+	struct tcam_rm_db *tcam_db;
+	struct tfp_calloc_parms cparms;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -99,6 +96,19 @@ tf_tcam_bind(struct tf *tfp,
 	}
 
 	memset(&db_cfg, 0, sizeof(db_cfg));
+	cparms.nitems = 1;
+	cparms.size = sizeof(struct tcam_rm_db);
+	cparms.alignment = 0;
+	if (tfp_calloc(&cparms) != 0) {
+		TFP_DRV_LOG(ERR, "tcam_rm_db alloc error %s\n",
+			    strerror(ENOMEM));
+		return -ENOMEM;
+	}
+
+	tcam_db = cparms.mem_va;
+	for (i = 0; i < TF_DIR_MAX; i++)
+		tcam_db->tcam_db[i] = NULL;
+	tf_session_set_db(tfp, TF_MODULE_TYPE_TCAM, tcam_db);
 
 	db_cfg.module = TF_MODULE_TYPE_TCAM;
 	db_cfg.num_elements = parms->num_elements;
@@ -107,7 +117,7 @@ tf_tcam_bind(struct tf *tfp,
 	for (d = 0; d < TF_DIR_MAX; d++) {
 		db_cfg.dir = d;
 		db_cfg.alloc_cnt = parms->resources->tcam_cnt[d].cnt;
-		db_cfg.rm_db = &tcam_db[d];
+		db_cfg.rm_db = (void *)&tcam_db->tcam_db[d];
 		rc = tf_rm_create_db(tfp, &db_cfg);
 		if (rc) {
 			TFP_DRV_LOG(ERR,
@@ -120,7 +130,7 @@ tf_tcam_bind(struct tf *tfp,
 	/* check if reserved resource for WC is multiple of num_slices */
 	for (d = 0; d < TF_DIR_MAX; d++) {
 		memset(&info, 0, sizeof(info));
-		ainfo.rm_db = tcam_db[d];
+		ainfo.rm_db = tcam_db->tcam_db[d];
 		ainfo.subtype = TF_TCAM_TBL_TYPE_WC_TCAM;
 		ainfo.info = &info;
 		rc = tf_rm_get_info(&ainfo);
@@ -148,7 +158,7 @@ tf_tcam_bind(struct tf *tfp,
 
 				if (!parms->resources->tcam_cnt[d].cnt[i])
 					continue;
-				ainfo.rm_db = tcam_db[d];
+				ainfo.rm_db = tcam_db->tcam_db[d];
 				ainfo.subtype = i;
 				ainfo.info = &info;
 				rc = tf_rm_get_info(&ainfo);
@@ -186,7 +196,7 @@ tf_tcam_bind(struct tf *tfp,
 	for (i = 0; i < TF_DIR_MAX; i++) {
 		memset(&fparms, 0, sizeof(fparms));
 		fparms.dir = i;
-		fparms.rm_db = tcam_db[i];
+		fparms.rm_db = tcam_db->tcam_db[i];
 		/* Ignoring return here since we are in the error case */
 		(void)tf_rm_free_db(tfp, &fparms);
 
@@ -196,7 +206,8 @@ tf_tcam_bind(struct tf *tfp,
 			shadow_tcam_db[i] = NULL;
 		}
 
-		tcam_db[i] = NULL;
+		tcam_db->tcam_db[i] = NULL;
+		tf_session_set_db(tfp, TF_MODULE_TYPE_TCAM, NULL);
 	}
 
 	shadow_init = 0;
@@ -211,6 +222,8 @@ tf_tcam_unbind(struct tf *tfp)
 	int rc;
 	int i;
 	struct tf_rm_free_db_parms fparms;
+	struct tcam_rm_db *tcam_db;
+	void *tcam_db_ptr = NULL;
 	struct tf_shadow_tcam_free_db_parms fshadow;
 	TF_CHECK_PARMS1(tfp);
 
@@ -221,15 +234,24 @@ tf_tcam_unbind(struct tf *tfp)
 		return 0;
 	}
 
+	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to get em_ext_db from session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	tcam_db = (struct tcam_rm_db *)tcam_db_ptr;
+
 	for (i = 0; i < TF_DIR_MAX; i++) {
 		memset(&fparms, 0, sizeof(fparms));
 		fparms.dir = i;
-		fparms.rm_db = tcam_db[i];
+		fparms.rm_db = tcam_db->tcam_db[i];
 		rc = tf_rm_free_db(tfp, &fparms);
 		if (rc)
 			return rc;
 
-		tcam_db[i] = NULL;
+		tcam_db->tcam_db[i] = NULL;
 
 		if (shadow_init) {
 			memset(&fshadow, 0, sizeof(fshadow));
@@ -256,6 +278,8 @@ tf_tcam_alloc(struct tf *tfp,
 	struct tf_rm_allocate_parms aparms;
 	uint16_t num_slices = 1;
 	uint32_t index;
+	struct tcam_rm_db *tcam_db;
+	void *tcam_db_ptr = NULL;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -293,13 +317,22 @@ tf_tcam_alloc(struct tf *tfp,
 	if (rc)
 		return rc;
 
+	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to get em_ext_db from session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	tcam_db = (struct tcam_rm_db *)tcam_db_ptr;
+
 	/*
 	 * For WC TCAM, number of slices could be 4, 2, 1 based on
 	 * the key_size. For other TCAM, it is always 1
 	 */
 	for (i = 0; i < num_slices; i++) {
 		memset(&aparms, 0, sizeof(aparms));
-		aparms.rm_db = tcam_db[parms->dir];
+		aparms.rm_db = tcam_db->tcam_db[parms->dir];
 		aparms.subtype = parms->type;
 		aparms.priority = parms->priority;
 		aparms.index = &index;
@@ -334,6 +367,8 @@ tf_tcam_free(struct tf *tfp,
 	int allocated = 0;
 	struct tf_shadow_tcam_remove_parms shparms;
 	int i;
+	struct tcam_rm_db *tcam_db;
+	void *tcam_db_ptr = NULL;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -379,10 +414,18 @@ tf_tcam_free(struct tf *tfp,
 		return -EINVAL;
 	}
 
+	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to get em_ext_db from session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	tcam_db = (struct tcam_rm_db *)tcam_db_ptr;
+
 	/* Check if element is in use */
 	memset(&aparms, 0, sizeof(aparms));
-
-	aparms.rm_db = tcam_db[parms->dir];
+	aparms.rm_db = tcam_db->tcam_db[parms->dir];
 	aparms.subtype = parms->type;
 	aparms.index = parms->idx;
 	aparms.allocated = &allocated;
@@ -431,7 +474,7 @@ tf_tcam_free(struct tf *tfp,
 	for (i = 0; i < num_slices; i++) {
 		/* Free requested element */
 		memset(&fparms, 0, sizeof(fparms));
-		fparms.rm_db = tcam_db[parms->dir];
+		fparms.rm_db = tcam_db->tcam_db[parms->dir];
 		fparms.subtype = parms->type;
 		fparms.index = parms->idx + i;
 		rc = tf_rm_free(&fparms);
@@ -448,7 +491,7 @@ tf_tcam_free(struct tf *tfp,
 	/* Convert TF type to HCAPI RM type */
 	memset(&hparms, 0, sizeof(hparms));
 
-	hparms.rm_db = tcam_db[parms->dir];
+	hparms.rm_db = tcam_db->tcam_db[parms->dir];
 	hparms.subtype = parms->type;
 	hparms.hcapi_type = &parms->hcapi_type;
 
@@ -612,6 +655,8 @@ tf_tcam_set(struct tf *tfp __rte_unused,
 	struct tf_shadow_tcam_insert_parms iparms;
 	uint16_t num_slice_per_row = 1;
 	int allocated = 0;
+	struct tcam_rm_db *tcam_db;
+	void *tcam_db_ptr = NULL;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -649,10 +694,19 @@ tf_tcam_set(struct tf *tfp __rte_unused,
 	if (rc)
 		return rc;
 
+	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to get em_ext_db from session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	tcam_db = (struct tcam_rm_db *)tcam_db_ptr;
+
 	/* Check if element is in use */
 	memset(&aparms, 0, sizeof(aparms));
 
-	aparms.rm_db = tcam_db[parms->dir];
+	aparms.rm_db = tcam_db->tcam_db[parms->dir];
 	aparms.subtype = parms->type;
 	aparms.index = parms->idx;
 	aparms.allocated = &allocated;
@@ -672,7 +726,7 @@ tf_tcam_set(struct tf *tfp __rte_unused,
 	/* Convert TF type to HCAPI RM type */
 	memset(&hparms, 0, sizeof(hparms));
 
-	hparms.rm_db = tcam_db[parms->dir];
+	hparms.rm_db = tcam_db->tcam_db[parms->dir];
 	hparms.subtype = parms->type;
 	hparms.hcapi_type = &parms->hcapi_type;
 
@@ -722,6 +776,8 @@ tf_tcam_get(struct tf *tfp __rte_unused,
 	struct tf_rm_is_allocated_parms aparms;
 	struct tf_rm_get_hcapi_parms hparms;
 	int allocated = 0;
+	struct tcam_rm_db *tcam_db;
+	void *tcam_db_ptr = NULL;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -742,10 +798,19 @@ tf_tcam_get(struct tf *tfp __rte_unused,
 	if (rc)
 		return rc;
 
+	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to get em_ext_db from session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	tcam_db = (struct tcam_rm_db *)tcam_db_ptr;
+
 	/* Check if element is in use */
 	memset(&aparms, 0, sizeof(aparms));
 
-	aparms.rm_db = tcam_db[parms->dir];
+	aparms.rm_db = tcam_db->tcam_db[parms->dir];
 	aparms.subtype = parms->type;
 	aparms.index = parms->idx;
 	aparms.allocated = &allocated;
@@ -765,7 +830,7 @@ tf_tcam_get(struct tf *tfp __rte_unused,
 	/* Convert TF type to HCAPI RM type */
 	memset(&hparms, 0, sizeof(hparms));
 
-	hparms.rm_db = tcam_db[parms->dir];
+	hparms.rm_db = tcam_db->tcam_db[parms->dir];
 	hparms.subtype = parms->type;
 	hparms.hcapi_type = &parms->hcapi_type;
 
diff --git a/drivers/net/bnxt/tf_core/tf_tcam.h b/drivers/net/bnxt/tf_core/tf_tcam.h
index b550fa43ca..acab223532 100644
--- a/drivers/net/bnxt/tf_core/tf_tcam.h
+++ b/drivers/net/bnxt/tf_core/tf_tcam.h
@@ -237,6 +237,16 @@ struct tf_tcam_get_parms {
 	uint16_t result_size;
 };
 
+/**
+ * TCAM database
+ *
+ * Tcam rm database
+ *
+ */
+struct tcam_rm_db {
+	struct rm_db *tcam_db[TF_DIR_MAX];
+};
+
 /**
  * @page tcam TCAM
  *
-- 
2.17.1


^ permalink raw reply	[flat|nested] 129+ messages in thread

* [dpdk-dev] [PATCH 14/58] net/bnxt: add shared session support
  2021-05-30  8:58 [dpdk-dev] [PATCH 00/58] enhancements to host based flow table management Venkat Duvvuru
                   ` (12 preceding siblings ...)
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 13/58] net/bnxt: change RM database type Venkat Duvvuru
@ 2021-05-30  8:58 ` Venkat Duvvuru
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 15/58] net/bnxt: add dpool allocator for EM allocation Venkat Duvvuru
                   ` (44 subsequent siblings)
  58 siblings, 0 replies; 129+ messages in thread
From: Venkat Duvvuru @ 2021-05-30  8:58 UTC (permalink / raw)
  To: dev; +Cc: Jay Ding, Randy Schacher, Venkat Duvvuru

From: Jay Ding <jay.ding@broadcom.com>

There are 2 types of sessions - shared and non-shared.  For non-shared
all the allocated resources are owned and managed by a single
session instance. No other applications have access to the
resources owned by the non-shared session.  For a shared session,
resources are shared between 2 applications.

The FW shared session can only be created by one application and
shared by other apps. The host session that creates the FW shared
session is the creator.

Applications can retrieve the reserved resources through a new API
tf_get_session_resc_info.

Each module supports two sessions, one is shared session, the other
is non-shared session.

Signed-off-by: Jay Ding <jay.ding@broadcom.com>
Signed-off-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Farah Smith <farah.smith@broadcom.com>
---
 drivers/net/bnxt/hsi_struct_def_dpdk.h    | 281 +++++++++++++++++-----
 drivers/net/bnxt/tf_core/bitalloc.c       |  10 +-
 drivers/net/bnxt/tf_core/bitalloc.h       |   3 +-
 drivers/net/bnxt/tf_core/tf_core.c        | 105 ++++++++
 drivers/net/bnxt/tf_core/tf_core.h        | 177 +++++++++++++-
 drivers/net/bnxt/tf_core/tf_device.c      |  76 +++---
 drivers/net/bnxt/tf_core/tf_device.h      |  73 ++++++
 drivers/net/bnxt/tf_core/tf_device_p4.c   |   8 +
 drivers/net/bnxt/tf_core/tf_device_p58.c  |   8 +
 drivers/net/bnxt/tf_core/tf_em.h          |  17 ++
 drivers/net/bnxt/tf_core/tf_em_common.c   |  25 --
 drivers/net/bnxt/tf_core/tf_em_internal.c | 118 +++++----
 drivers/net/bnxt/tf_core/tf_identifier.c  |  89 +++----
 drivers/net/bnxt/tf_core/tf_identifier.h  |  16 ++
 drivers/net/bnxt/tf_core/tf_msg.c         | 223 ++++++++++++++---
 drivers/net/bnxt/tf_core/tf_msg.h         |  47 +++-
 drivers/net/bnxt/tf_core/tf_rm.c          | 277 ++++++++++++++++++++-
 drivers/net/bnxt/tf_core/tf_rm.h          |  34 +++
 drivers/net/bnxt/tf_core/tf_session.c     |  37 ++-
 drivers/net/bnxt/tf_core/tf_session.h     |  66 +++++
 drivers/net/bnxt/tf_core/tf_tbl.c         | 104 ++++----
 drivers/net/bnxt/tf_core/tf_tbl.h         |  17 ++
 drivers/net/bnxt/tf_core/tf_tcam.c        | 103 ++++----
 drivers/net/bnxt/tf_core/tf_tcam.h        |  16 ++
 drivers/net/bnxt/tf_core/tfp.c            |   6 +-
 drivers/net/bnxt/tf_core/tfp.h            |   3 +-
 26 files changed, 1560 insertions(+), 379 deletions(-)

diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h b/drivers/net/bnxt/hsi_struct_def_dpdk.h
index aea9305486..046acb8de2 100644
--- a/drivers/net/bnxt/hsi_struct_def_dpdk.h
+++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h
@@ -699,6 +699,8 @@ struct cmd_nums {
 	/* Experimental */
 	#define HWRM_TF_SESSION_RESC_FLUSH                UINT32_C(0x2cf)
 	/* Experimental */
+	#define HWRM_TF_SESSION_RESC_INFO                 UINT32_C(0x2d0)
+	/* Experimental */
 	#define HWRM_TF_TBL_TYPE_GET                      UINT32_C(0x2da)
 	/* Experimental */
 	#define HWRM_TF_TBL_TYPE_SET                      UINT32_C(0x2db)
@@ -727,6 +729,8 @@ struct cmd_nums {
 	/* Experimental */
 	#define HWRM_TF_EM_HASH_INSERT                    UINT32_C(0x2ec)
 	/* Experimental */
+	#define HWRM_TF_EM_MOVE                           UINT32_C(0x2ed)
+	/* Experimental */
 	#define HWRM_TF_TCAM_SET                          UINT32_C(0x2f8)
 	/* Experimental */
 	#define HWRM_TF_TCAM_GET                          UINT32_C(0x2f9)
@@ -986,8 +990,8 @@ struct hwrm_err_output {
 #define HWRM_VERSION_MINOR 10
 #define HWRM_VERSION_UPDATE 2
 /* non-zero means beta version */
-#define HWRM_VERSION_RSVD 15
-#define HWRM_VERSION_STR "1.10.2.15"
+#define HWRM_VERSION_RSVD 22
+#define HWRM_VERSION_STR "1.10.2.22"
 
 /****************
  * hwrm_ver_get *
@@ -11971,7 +11975,7 @@ struct hwrm_func_cfg_input {
 	/*
 	 * Function ID of the function that is being
 	 * configured.
-	 * If set to 0xFF... (All Fs), then the configuration is
+	 * If set to 0xFF... (All Fs), then the the configuration is
 	 * for the requesting function.
 	 */
 	uint16_t	fid;
@@ -12671,7 +12675,7 @@ struct hwrm_func_cfg_input {
 	/*
 	 * When this bit is '1', the caller requests to disable a MPC
 	 * channel with destination to the TX configurable flow processing
-	 * block. When this bit is ‘0’, this flag has no effect.
+	 * block block. When this bit is ‘0’, this flag has no effect.
 	 */
 	#define HWRM_FUNC_CFG_INPUT_MPC_CHNLS_TE_CFA_DISABLE \
 		UINT32_C(0x20)
@@ -12685,7 +12689,7 @@ struct hwrm_func_cfg_input {
 	/*
 	 * When this bit is '1', the caller requests to disable a MPC
 	 * channel with destination to the RX configurable flow processing
-	 * block. When this bit is ‘0’, this flag has no effect.
+	 * block block. When this bit is ‘0’, this flag has no effect.
 	 */
 	#define HWRM_FUNC_CFG_INPUT_MPC_CHNLS_RE_CFA_DISABLE \
 		UINT32_C(0x80)
@@ -18041,7 +18045,7 @@ struct hwrm_func_spd_cfg_input {
 		UINT32_C(0x10)
 	/*
 	 * Ethertype value used in the encapsulated SPD packet header.
-	 * The user must choose a value that is not conflicting with
+	 * The user must chooose a value that is not conflicting with
 	 * publicly defined ethertype values. By default, the ethertype
 	 * value of 0xffff is used if there is no user specified value.
 	 */
@@ -18300,7 +18304,7 @@ struct hwrm_func_spd_qcfg_output {
 	uint8_t	unused_1;
 	/*
 	 * Ethertype value used in the encapsulated SPD packet header.
-	 * The user must choose a value that is not conflicting with
+	 * The user must chooose a value that is not conflicting with
 	 * publicly defined ethertype values. By default, the ethertype
 	 * value of 0xffff is used if there is no user specified value.
 	 */
@@ -29815,7 +29819,7 @@ struct hwrm_vnic_cfg_input {
 	 * queue ID will be arriving on this VNIC.  Packet priority to CoS mapping
 	 * rules can be specified using HWRM_QUEUE_PRI2COS_CFG.  In this mode,
 	 * ntuple filters with VNIC destination specified are invalid since they
-	 * conflict with the CoS to VNIC steering rules in this mode.
+	 * conflict with the the CoS to VNIC steering rules in this mode.
 	 *
 	 * If this field is not specified, packet to VNIC steering will be
 	 * subject to the standard L2 filter rules and any additional ntuple
@@ -41312,14 +41316,14 @@ struct hwrm_cfa_eem_qcaps_output {
 	#define HWRM_CFA_EEM_QCAPS_OUTPUT_FLAGS_PATH_RX \
 		UINT32_C(0x2)
 	/*
-	 * When set to 1, indicates the FW supports the Centralized
+	 * When set to 1, indicates the the FW supports the Centralized
 	 * Memory Model. The concept designates one entity for the
 	 * memory allocation while all others ‘subscribe’ to it.
 	 */
 	#define HWRM_CFA_EEM_QCAPS_OUTPUT_FLAGS_CENTRALIZED_MEMORY_MODEL_SUPPORTED \
 		UINT32_C(0x4)
 	/*
-	 * When set to 1, indicates the FW supports the Detached
+	 * When set to 1, indicates the the FW supports the Detached
 	 * Centralized Memory Model. The memory is allocated and managed
 	 * as a separate entity. All PFs and VFs will be granted direct
 	 * or semi-direct access to the allocated memory while none of
@@ -42143,8 +42147,24 @@ struct hwrm_tf_session_open_output {
 	 * the newly created session.
 	 */
 	uint32_t	fw_session_client_id;
-	/* unused. */
-	uint32_t	unused0;
+	uint32_t	flags;
+	/* Indicates if the shared session has been created. */
+	#define HWRM_TF_SESSION_OPEN_OUTPUT_FLAGS_SHARED_SESSION \
+		UINT32_C(0x1)
+	/*
+	 * If this bit set to 0, then it indicates the shared session
+	 * has been created by another session.
+	 */
+	#define HWRM_TF_SESSION_OPEN_OUTPUT_FLAGS_SHARED_SESSION_NOT_CREATOR \
+		UINT32_C(0x0)
+	/*
+	 * If this bit is set to 1, then it indicates the shared session
+	 * is created by this session.
+	 */
+	#define HWRM_TF_SESSION_OPEN_OUTPUT_FLAGS_SHARED_SESSION_CREATOR \
+		UINT32_C(0x1)
+	#define HWRM_TF_SESSION_OPEN_OUTPUT_FLAGS_SHARED_SESSION_LAST \
+		HWRM_TF_SESSION_OPEN_OUTPUT_FLAGS_SHARED_SESSION_CREATOR
 	/* unused. */
 	uint8_t	unused1[3];
 	/*
@@ -42948,6 +42968,105 @@ struct hwrm_tf_session_resc_flush_output {
 	uint8_t	valid;
 } __rte_packed;
 
+/*****************************
+ * hwrm_tf_session_resc_info *
+ *****************************/
+
+
+/* hwrm_tf_session_resc_info_input (size:320b/40B) */
+struct hwrm_tf_session_resc_info_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
+	uint32_t	fw_session_id;
+	/* Control flags. */
+	uint16_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TF_SESSION_RESC_INFO_INPUT_FLAGS_DIR     UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+	#define HWRM_TF_SESSION_RESC_INFO_INPUT_FLAGS_DIR_RX    UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+	#define HWRM_TF_SESSION_RESC_INFO_INPUT_FLAGS_DIR_TX    UINT32_C(0x1)
+	#define HWRM_TF_SESSION_RESC_INFO_INPUT_FLAGS_DIR_LAST \
+		HWRM_TF_SESSION_RESC_INFO_INPUT_FLAGS_DIR_TX
+	/*
+	 * Defines the array size of the provided req_addr and
+	 * resv_addr array buffers. Should be set to the number of
+	 * request entries.
+	 */
+	uint16_t	req_size;
+	/*
+	 * This is the DMA address for the request input data array
+	 * buffer. Array is of tf_rm_resc_req_entry type. Size of the
+	 * array buffer is provided by the 'req_size' field in this
+	 * message.
+	 */
+	uint64_t	req_addr;
+	/*
+	 * This is the DMA address for the resc output data array
+	 * buffer. Array is of tf_rm_resc_entry type. Size of the array
+	 * buffer is provided by the 'req_size' field in this
+	 * message.
+	 */
+	uint64_t	resc_addr;
+} __rte_packed;
+
+/* hwrm_tf_session_resc_info_output (size:128b/16B) */
+struct hwrm_tf_session_resc_info_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * Size of the returned tf_rm_resc_entry data array. The value
+	 * cannot exceed the req_size defined by the input msg. The data
+	 * array is returned using the resv_addr specified DMA
+	 * address also provided by the input msg.
+	 */
+	uint16_t	size;
+	/* unused. */
+	uint8_t	unused0[5];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
+	 */
+	uint8_t	valid;
+} __rte_packed;
+
 /* TruFlow RM capability of a resource. */
 /* tf_rm_resc_req_entry (size:64b/8B) */
 struct tf_rm_resc_req_entry {
@@ -43608,14 +43727,14 @@ struct hwrm_tf_ext_em_qcaps_output {
 	uint16_t	resp_len;
 	uint32_t	flags;
 	/*
-	 * When set to 1, indicates the FW supports the Centralized
+	 * When set to 1, indicates the the FW supports the Centralized
 	 * Memory Model. The concept designates one entity for the
 	 * memory allocation while all others ‘subscribe’ to it.
 	 */
 	#define HWRM_TF_EXT_EM_QCAPS_OUTPUT_FLAGS_CENTRALIZED_MEMORY_MODEL_SUPPORTED \
 		UINT32_C(0x1)
 	/*
-	 * When set to 1, indicates the FW supports the Detached
+	 * When set to 1, indicates the the FW supports the Detached
 	 * Centralized Memory Model. The memory is allocated and managed
 	 * as a separate entity. All PFs and VFs will be granted direct
 	 * or semi-direct access to the allocated memory while none of
@@ -44434,6 +44553,79 @@ struct hwrm_tf_em_delete_output {
 	uint16_t	unused0[3];
 } __rte_packed;
 
+/*******************
+ * hwrm_tf_em_move *
+ *******************/
+
+
+/* hwrm_tf_em_move_input (size:320b/40B) */
+struct hwrm_tf_em_move_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Session Id. */
+	uint32_t	fw_session_id;
+	/* Control flags. */
+	uint16_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TF_EM_MOVE_INPUT_FLAGS_DIR     UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+	#define HWRM_TF_EM_MOVE_INPUT_FLAGS_DIR_RX    UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+	#define HWRM_TF_EM_MOVE_INPUT_FLAGS_DIR_TX    UINT32_C(0x1)
+	#define HWRM_TF_EM_MOVE_INPUT_FLAGS_DIR_LAST \
+		HWRM_TF_EM_MOVE_INPUT_FLAGS_DIR_TX
+	/* Number of EM entry blocks */
+	uint16_t	num_blocks;
+	/* New index for entry */
+	uint32_t	new_index;
+	/* Unused */
+	uint32_t	unused0;
+	/* EM internal flow handle. */
+	uint64_t	flow_handle;
+} __rte_packed;
+
+/* hwrm_tf_em_move_output (size:128b/16B) */
+struct hwrm_tf_em_move_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Index of old entry. */
+	uint16_t	em_index;
+	/* unused. */
+	uint16_t	unused0[3];
+} __rte_packed;
+
 /********************
  * hwrm_tf_tcam_set *
  ********************/
@@ -46988,10 +47180,7 @@ struct hwrm_nvm_write_input {
 	 * This is where the source data is.
 	 */
 	uint64_t	host_src_addr;
-	/*
-	 * The Directory Entry Type (valid values are defined in the bnxnvm
-	 * directory_type enum defined in the file bnxnvm_defs.h).
-	 */
+	/* The Directory Entry Type (valid values are defined in the bnxnvm_directory_type enum defined in the file bnxnvm_defs.h). */
 	uint16_t	dir_type;
 	/*
 	 * Directory ordinal.
@@ -47003,10 +47192,8 @@ struct hwrm_nvm_write_input {
 	/* Directory Entry Attribute flags (see BNX_DIR_ATTR_* in the file bnxnvm_defs.h). */
 	uint16_t	dir_attr;
 	/*
-	 * Length of data to write, in bytes. May be less than or equal to the allocated
-	 * size for the directory entry.
-	 * The data length stored in the directory entry will be updated to reflect
-	 * this value once the write is complete.
+	 * Length of data to write, in bytes. May be less than or equal to the allocated size for the directory entry.
+	 * The data length stored in the directory entry will be updated to reflect this value once the write is complete.
 	 */
 	uint32_t	dir_data_length;
 	/* Option. */
@@ -47019,15 +47206,11 @@ struct hwrm_nvm_write_input {
 	#define HWRM_NVM_WRITE_INPUT_FLAGS_KEEP_ORIG_ACTIVE_IMG \
 		UINT32_C(0x1)
 	/*
-	 * The requested length of the allocated NVM for the item, in bytes. This
-	 * value may be greater than or equal to the specified data length (dir_data_length).
+	 * The requested length of the allocated NVM for the item, in bytes. This value may be greater than or equal to the specified data length (dir_data_length).
 	 * If this value is less than the specified data length, it will be ignored.
-	 * The response will contain the actual allocated item length, which may be
-	 * greater than the requested item length.
-	 * The purpose for allocating more than the required number of bytes for
-	 * an item's data is to pre-allocate extra storage (padding) to accommodate
-	 * the potential future growth of an item (e.g. upgraded firmware with a
-	 * size increase, log growth, expanded configuration data).
+	 * The response will contain the actual allocated item length, which may be greater than the requested item length.
+	 * The purpose for allocating more than the required number of bytes for an item's data is to pre-allocate extra storage (padding) to accommodate
+	 * the potential future growth of an item (e.g. upgraded firmware with a size increase, log growth, expanded configuration data).
 	 */
 	uint32_t	dir_item_length;
 	uint32_t	unused_0;
@@ -47044,11 +47227,8 @@ struct hwrm_nvm_write_output {
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
 	/*
-	 * Length of the allocated NVM for the item, in bytes. The value may be
-	 * greater than or equal to the specified data length or the requested
-	 * item length.
-	 * The actual item length used when creating a new directory entry will be
-	 * a multiple of an NVM block size.
+	 * Length of the allocated NVM for the item, in bytes. The value may be greater than or equal to the specified data length or the requested item length.
+	 * The actual item length used when creating a new directory entry will be a multiple of an NVM block size.
 	 */
 	uint32_t	dir_item_length;
 	/* The directory index of the created or modified item. */
@@ -47392,10 +47572,7 @@ struct hwrm_nvm_get_dev_info_output {
 	/* Total size, in bytes of the NVRAM device. */
 	uint32_t	nvram_size;
 	uint32_t	reserved_size;
-	/*
-	 * Available size that can be used, in bytes.  Available size is the
-	 * NVRAM size take away the used size and reserved size.
-	 */
+	/* Available size that can be used, in bytes.  Available size is the NVRAM size take away the used size and reserved size. */
 	uint32_t	available_size;
 	/* This field represents the major version of NVM cfg */
 	uint8_t	nvm_cfg_ver_maj;
@@ -47537,15 +47714,9 @@ struct hwrm_nvm_mod_dir_entry_input {
 	 * The (0-based) instance of this Directory Type.
 	 */
 	uint16_t	dir_ordinal;
-	/*
-	 * The Directory Entry Extension flags (see BNX_DIR_EXT_* for extension
-	 * flag definitions).
-	 */
+	/* The Directory Entry Extension flags (see BNX_DIR_EXT_* for extension flag definitions). */
 	uint16_t	dir_ext;
-	/*
-	 * Directory Entry Attribute flags (see BNX_DIR_ATTR_* for attribute flag
-	 * definitions).
-	 */
+	/* Directory Entry Attribute flags (see BNX_DIR_ATTR_* for attribute flag definitions). */
 	uint16_t	dir_attr;
 	/*
 	 * If valid, then this field updates the checksum
@@ -47712,10 +47883,8 @@ struct hwrm_nvm_install_update_input {
 	#define HWRM_NVM_INSTALL_UPDATE_INPUT_FLAGS_ERASE_UNUSED_SPACE \
 		UINT32_C(0x1)
 	/*
-	 * If set to 1, then unspecified images, images not in the package file,
-	 * will be safely deleted.
-	 * When combined with erase_unused_space then unspecified images will be
-	 * securely erased.
+	 * If set to 1, then unspecified images, images not in the package file, will be safely deleted.
+	 * When combined with erase_unused_space then unspecified images will be securely erased.
 	 */
 	#define HWRM_NVM_INSTALL_UPDATE_INPUT_FLAGS_REMOVE_UNUSED_PKG \
 		UINT32_C(0x2)
@@ -48100,10 +48269,7 @@ struct hwrm_nvm_set_variable_input {
 	/* index for the 4th dimensions */
 	uint16_t	index_3;
 	uint8_t	flags;
-	/*
-	 * When this bit is 1, flush internal cache after this write operation
-	 * (see hwrm_nvm_flush command.)
-	 */
+	/* When this bit is 1, flush internal cache after this write operation (see hwrm_nvm_flush command.) */
 	#define HWRM_NVM_SET_VARIABLE_INPUT_FLAGS_FORCE_FLUSH \
 		UINT32_C(0x1)
 	/* encryption method */
@@ -48405,10 +48571,7 @@ struct hwrm_fw_reset_input {
 	 */
 	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_HOST \
 		UINT32_C(0x4)
-	/*
-	 * AP processor complex (in multi-host environment). Use host_idx to
-	 * control which core is reset
-	 */
+	/* AP processor complex (in multi-host environment). Use host_idx to control which core is reset */
 	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_AP \
 		UINT32_C(0x5)
 	/* Reset all blocks of the chip (including all processors) */
diff --git a/drivers/net/bnxt/tf_core/bitalloc.c b/drivers/net/bnxt/tf_core/bitalloc.c
index af1397071b..e253cfc3a6 100644
--- a/drivers/net/bnxt/tf_core/bitalloc.c
+++ b/drivers/net/bnxt/tf_core/bitalloc.c
@@ -65,7 +65,7 @@ ba_ffs(bitalloc_word_t v)
 }
 
 int
-ba_init(struct bitalloc *pool, int size)
+ba_init(struct bitalloc *pool, int size, bool free)
 {
 	bitalloc_word_t *mem = (bitalloc_word_t *)pool;
 	int       i;
@@ -101,9 +101,11 @@ ba_init(struct bitalloc *pool, int size)
 		pool->storage[offset++] = words[--lev];
 	}
 
-	/* Free the entire pool */
-	for (i = 0; i < size; i++)
-		ba_free(pool, i);
+	/* Free the entire pool if it is required*/
+	if (free) {
+		for (i = 0; i < size; i++)
+			ba_free(pool, i);
+	}
 
 	return 0;
 }
diff --git a/drivers/net/bnxt/tf_core/bitalloc.h b/drivers/net/bnxt/tf_core/bitalloc.h
index 7244b86e95..e3b389e68d 100644
--- a/drivers/net/bnxt/tf_core/bitalloc.h
+++ b/drivers/net/bnxt/tf_core/bitalloc.h
@@ -7,6 +7,7 @@
 #define _BITALLOC_H_
 
 #include <stdint.h>
+#include <stdbool.h>
 
 /* Bitalloc works on uint32_t as its word size */
 typedef uint32_t bitalloc_word_t;
@@ -64,7 +65,7 @@ struct bitalloc {
  * Returns 0 on success, -1 on failure.  Size is arbitrary up to
  * BITALLOC_MAX_SIZE
  */
-int ba_init(struct bitalloc *pool, int size);
+int ba_init(struct bitalloc *pool, int size, bool free);
 
 /**
  * Returns -1 on failure, or index of allocated entry
diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c
index 9b8677caac..69f5c10293 100644
--- a/drivers/net/bnxt/tf_core/tf_core.c
+++ b/drivers/net/bnxt/tf_core/tf_core.c
@@ -27,6 +27,8 @@ tf_open_session(struct tf *tfp,
 	int rc;
 	unsigned int domain, bus, slot, device;
 	struct tf_session_open_session_parms oparms;
+	int name_len;
+	char *name;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -69,6 +71,13 @@ tf_open_session(struct tf *tfp,
 		}
 	}
 
+	name_len = strlen(parms->ctrl_chan_name);
+	name = &parms->ctrl_chan_name[name_len - strlen("tf_shared")];
+	if (!strncmp(name, "tf_shared", strlen("tf_shared"))) {
+		memset(parms->ctrl_chan_name, 0, strlen(parms->ctrl_chan_name));
+		strcpy(parms->ctrl_chan_name, "tf_share");
+	}
+
 	parms->session_id.internal.domain = domain;
 	parms->session_id.internal.bus = bus;
 	parms->session_id.internal.device = device;
@@ -1593,3 +1602,99 @@ tf_get_if_tbl_entry(struct tf *tfp,
 
 	return 0;
 }
+
+int tf_get_session_info(struct tf *tfp,
+			struct tf_get_session_info_parms *parms)
+{
+	int rc;
+	struct tf_session      *tfs;
+	struct tf_dev_info     *dev;
+
+	TF_CHECK_PARMS2(tfp, parms);
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to lookup session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to lookup device, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+
+	TF_CHECK_PARMS2(tfp, parms);
+
+	if (dev->ops->tf_dev_get_ident_resc_info == NULL) {
+		rc = -EOPNOTSUPP;
+		TFP_DRV_LOG(ERR,
+			    "Operation not supported, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+
+	rc = dev->ops->tf_dev_get_ident_resc_info(tfp, parms->session_info.ident);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Ident get resc info failed, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+
+	if (dev->ops->tf_dev_get_tbl_resc_info == NULL) {
+		rc = -EOPNOTSUPP;
+		TFP_DRV_LOG(ERR,
+			    "Operation not supported, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+
+	rc = dev->ops->tf_dev_get_tbl_resc_info(tfp, parms->session_info.tbl);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Tbl get resc info failed, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+
+	if (dev->ops->tf_dev_get_tcam_resc_info == NULL) {
+		rc = -EOPNOTSUPP;
+		TFP_DRV_LOG(ERR,
+			    "Operation not supported, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+
+	rc = dev->ops->tf_dev_get_tcam_resc_info(tfp, parms->session_info.tcam);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "TCAM get resc info failed, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+
+	if (dev->ops->tf_dev_get_em_resc_info == NULL) {
+		rc = -EOPNOTSUPP;
+		TFP_DRV_LOG(ERR,
+			    "Operation not supported, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+
+	rc = dev->ops->tf_dev_get_em_resc_info(tfp, parms->session_info.em);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "EM get resc info failed, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+
+	return 0;
+}
diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h
index 7b26b58000..4440d60fe5 100644
--- a/drivers/net/bnxt/tf_core/tf_core.h
+++ b/drivers/net/bnxt/tf_core/tf_core.h
@@ -557,7 +557,8 @@ struct tf_open_session_parms {
 	 * rte_eth_dev_get_name_by_port() within the ULP.
 	 *
 	 * ctrl_chan_name will be used as part of a name for any
-	 * shared memory allocation.
+	 * shared memory allocation. The ctrl_chan_name is usually in format
+	 * 0000:02:00.0. The name for shared session is 0000:02:00.0-tf_shared.
 	 */
 	char ctrl_chan_name[TF_SESSION_NAME_MAX];
 	/**
@@ -616,29 +617,63 @@ struct tf_open_session_parms {
 	 * Resource allocation for the session.
 	 */
 	struct tf_session_resources resources;
+
+	/**
+	 * [in] bp
+	 * The pointer to the parent bp struct. This is only used for HWRM
+	 * message passing within the portability layer. The type is struct
+	 * bnxt.
+	 */
+	void *bp;
+
+	/**
+	 * [out] shared_session_creator
+	 *
+	 * Indicates whether the application created the session if set.
+	 * Otherwise the shared session already existed.  Just for information
+	 * purposes.
+	 */
+	int shared_session_creator;
 };
 
 /**
  * Opens a new TruFlow Session or session client.
  *
- * What gets created depends on the passed in tfp content. If the tfp
- * does not have prior session data a new session with associated
- * session client. If tfp has a session already a session client will
- * be created. In both cases the session client is created using the
- * provided ctrl_chan_name.
+ * What gets created depends on the passed in tfp content. If the tfp does not
+ * have prior session data a new session with associated session client. If tfp
+ * has a session already a session client will be created. In both cases the
+ * session client is created using the provided ctrl_chan_name.
  *
- * In case of session creation TruFlow will allocate session specific
- * memory, shared memory, to hold its session data. This data is
- * private to TruFlow.
+ * In case of session creation TruFlow will allocate session specific memory to
+ * hold its session data. This data is private to TruFlow.
  *
  * No other TruFlow APIs will succeed unless this API is first called
  * and succeeds.
  *
- * tf_open_session() returns a session id and session client id that
- * is used on all other TF APIs.
+ * tf_open_session() returns a session id and session client id.  These are
+ * also stored within the tfp structure passed in to all other APIs.
  *
  * A Session or session client can be closed using tf_close_session().
  *
+ * There are 2 types of sessions - shared and not.  For non-shared all
+ * the allocated resources are owned and managed by a single session instance.
+ * No other applications have access to the resources owned by the non-shared
+ * session.  For a shared session, resources are shared between 2 applications.
+ *
+ * When the caller of tf_open_session() sets the ctrl_chan_name[] to a name
+ * like "0000:02:00.0-tf_shared", it is a request to create a new "shared"
+ * session in the firmware or access the existing shared session. There is
+ * only 1 shared session that can be created. If the shared session has
+ * already been created in the firmware, this API will return this indication
+ * by clearing the shared_session_creator flag. Only the first shared session
+ * create will have the shared_session_creator flag set.
+ *
+ * The shared session should always be the first session to be created by
+ * application and the last session closed due to RM management preference.
+ *
+ * Sessions remain open in the firmware until the last client of the session
+ * closes the session (tf_close_session()).
+ *
  * [in] tfp
  *   Pointer to TF handle
  *
@@ -652,6 +687,126 @@ struct tf_open_session_parms {
 int tf_open_session(struct tf *tfp,
 		    struct tf_open_session_parms *parms);
 
+/**
+ * General internal resource info
+ *
+ * TODO: remove tf_rm_new_entry structure and use this structure
+ * internally.
+ */
+struct tf_resource_info {
+	uint16_t start;
+	uint16_t stride;
+};
+
+/**
+ * Identifier resource definition
+ */
+struct tf_identifier_resource_info {
+	/**
+	 * Array of TF Identifiers. The index used is tf_identifier_type.
+	 */
+	struct tf_resource_info info[TF_IDENT_TYPE_MAX];
+};
+
+/**
+ * Table type resource info definition
+ */
+struct tf_tbl_resource_info {
+	/**
+	 * Array of TF Table types. The index used is tf_tbl_type.
+	 */
+	struct tf_resource_info info[TF_TBL_TYPE_MAX];
+};
+
+/**
+ * TCAM type resource definition
+ */
+struct tf_tcam_resource_info {
+	/**
+	 * Array of TF TCAM types. The index used is tf_tcam_tbl_type.
+	 */
+	struct tf_resource_info info[TF_TCAM_TBL_TYPE_MAX];
+};
+
+/**
+ * EM type resource definition
+ */
+struct tf_em_resource_info {
+	/**
+	 * Array of TF EM table types. The index used is tf_em_tbl_type.
+	 */
+	struct tf_resource_info info[TF_EM_TBL_TYPE_MAX];
+};
+
+/**
+ * tf_session_resources parameter definition.
+ */
+struct tf_session_resource_info {
+	/**
+	 * [in] Requested Identifier Resources
+	 *
+	 * Number of identifier resources requested for the
+	 * session.
+	 */
+	struct tf_identifier_resource_info ident[TF_DIR_MAX];
+	/**
+	 * [in] Requested Index Table resource counts
+	 *
+	 * The number of index table resources requested for the
+	 * session.
+	 */
+	struct tf_tbl_resource_info tbl[TF_DIR_MAX];
+	/**
+	 * [in] Requested TCAM Table resource counts
+	 *
+	 * The number of TCAM table resources requested for the
+	 * session.
+	 */
+
+	struct tf_tcam_resource_info tcam[TF_DIR_MAX];
+	/**
+	 * [in] Requested EM resource counts
+	 *
+	 * The number of internal EM table resources requested for the
+	 * session.
+	 */
+	struct tf_em_resource_info em[TF_DIR_MAX];
+};
+
+/**
+ * tf_get_session_resources parameter definition.
+ */
+struct tf_get_session_info_parms {
+	/**
+	 * [out] the structure is used to return the information of
+	 * allocated resources.
+	 *
+	 */
+	struct tf_session_resource_info session_info;
+};
+
+/** (experimental)
+ * Gets info about a TruFlow Session
+ *
+ * Get info about the session which has been created.  Whether it exists and
+ * what resource start and stride offsets are in use.  This API is primarily
+ * intended to be used by an application which has created a shared session
+ * This application needs to obtain the resources which have already been
+ * allocated for the shared session.
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [in] parms
+ *   Pointer to get parameters
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+int tf_get_session_info(struct tf *tfp,
+			struct tf_get_session_info_parms *parms);
+
 /**
  * Experimental
  *
diff --git a/drivers/net/bnxt/tf_core/tf_device.c b/drivers/net/bnxt/tf_core/tf_device.c
index 9e71c04bf2..fed4156200 100644
--- a/drivers/net/bnxt/tf_core/tf_device.c
+++ b/drivers/net/bnxt/tf_core/tf_device.c
@@ -351,10 +351,16 @@ tf_dev_bind_p58(struct tf *tfp,
 	struct tf_em_cfg_parms em_cfg;
 	struct tf_if_tbl_cfg_parms if_tbl_cfg;
 	struct tf_global_cfg_cfg_parms global_cfg;
+	struct tf_session *tfs;
 
 	/* Initial function initialization */
 	dev_handle->ops = &tf_dev_ops_p58_init;
 
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
+
 	rsv_cnt = tf_dev_reservation_check(TF_IDENT_TYPE_MAX,
 					   tf_ident_p58,
 					   (uint16_t *)resources->ident_cnt);
@@ -440,26 +446,28 @@ tf_dev_bind_p58(struct tf *tfp,
 	/*
 	 * IF_TBL
 	 */
-	if_tbl_cfg.num_elements = TF_IF_TBL_TYPE_MAX;
-	if_tbl_cfg.cfg = tf_if_tbl_p58;
-	if_tbl_cfg.shadow_copy = shadow_copy;
-	rc = tf_if_tbl_bind(tfp, &if_tbl_cfg);
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "IF Table initialization failure\n");
-		goto fail;
-	}
+	if (!tf_session_is_shared_session(tfs)) {
+		if_tbl_cfg.num_elements = TF_IF_TBL_TYPE_MAX;
+		if_tbl_cfg.cfg = tf_if_tbl_p58;
+		if_tbl_cfg.shadow_copy = shadow_copy;
+		rc = tf_if_tbl_bind(tfp, &if_tbl_cfg);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "IF Table initialization failure\n");
+			goto fail;
+		}
 
-	/*
-	 * GLOBAL_CFG
-	 */
-	global_cfg.num_elements = TF_GLOBAL_CFG_TYPE_MAX;
-	global_cfg.cfg = tf_global_cfg_p58;
-	rc = tf_global_cfg_bind(tfp, &global_cfg);
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "Global Cfg initialization failure\n");
-		goto fail;
+		/*
+		 * GLOBAL_CFG
+		 */
+		global_cfg.num_elements = TF_GLOBAL_CFG_TYPE_MAX;
+		global_cfg.cfg = tf_global_cfg_p58;
+		rc = tf_global_cfg_bind(tfp, &global_cfg);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "Global Cfg initialization failure\n");
+			goto fail;
+		}
 	}
 
 	/* Final function initialization */
@@ -491,6 +499,12 @@ tf_dev_unbind_p58(struct tf *tfp)
 {
 	int rc = 0;
 	bool fail = false;
+	struct tf_session *tfs;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
 
 	/* Unbind all the support modules. As this is only done on
 	 * close we only report errors as everything has to be cleaned
@@ -527,18 +541,20 @@ tf_dev_unbind_p58(struct tf *tfp)
 		fail = true;
 	}
 
-	rc = tf_if_tbl_unbind(tfp);
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "Device unbind failed, IF Table Type\n");
-		fail = true;
-	}
+	if (!tf_session_is_shared_session(tfs)) {
+		rc = tf_if_tbl_unbind(tfp);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "Device unbind failed, IF Table Type\n");
+			fail = true;
+		}
 
-	rc = tf_global_cfg_unbind(tfp);
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "Device unbind failed, Global Cfg Type\n");
-		fail = true;
+		rc = tf_global_cfg_unbind(tfp);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "Device unbind failed, Global Cfg Type\n");
+			fail = true;
+		}
 	}
 
 	if (fail)
diff --git a/drivers/net/bnxt/tf_core/tf_device.h b/drivers/net/bnxt/tf_core/tf_device.h
index 3f2c24a0c6..16c2fe0f64 100644
--- a/drivers/net/bnxt/tf_core/tf_device.h
+++ b/drivers/net/bnxt/tf_core/tf_device.h
@@ -220,6 +220,25 @@ struct tf_dev_ops {
 	 */
 	int (*tf_dev_search_ident)(struct tf *tfp,
 				   struct tf_ident_search_parms *parms);
+
+	/**
+	 * Retrieves the identifier resource info.
+	 *
+	 * This API retrieves the identifier resource info from the rm db.
+	 *
+	 * [in] tfp
+	 *   Pointer to TF handle
+	 *
+	 * [in] parms
+	 *   Pointer to identifier info
+	 *
+	 * Returns
+	 *   - (0) if successful.
+	 *   - (-EINVAL) on failure.
+	 */
+	int (*tf_dev_get_ident_resc_info)(struct tf *tfp,
+					  struct tf_identifier_resource_info *parms);
+
 	/**
 	 * Get SRAM table information.
 	 *
@@ -425,6 +444,24 @@ struct tf_dev_ops {
 	int (*tf_dev_get_bulk_tbl)(struct tf *tfp,
 				   struct tf_tbl_get_bulk_parms *parms);
 
+	/**
+	 * Retrieves the table resource info.
+	 *
+	 * This API retrieves the table resource info from the rm db.
+	 *
+	 * [in] tfp
+	 *   Pointer to TF handle
+	 *
+	 * [in] parms
+	 *   Pointer to tbl info
+	 *
+	 * Returns
+	 *   - (0) if successful.
+	 *   - (-EINVAL) on failure.
+	 */
+	int (*tf_dev_get_tbl_resc_info)(struct tf *tfp,
+					 struct tf_tbl_resource_info *parms);
+
 	/**
 	 * Allocation of a tcam element.
 	 *
@@ -524,6 +561,24 @@ struct tf_dev_ops {
 	int (*tf_dev_get_tcam)(struct tf *tfp,
 			       struct tf_tcam_get_parms *parms);
 
+	/**
+	 * Retrieves the tcam resource info.
+	 *
+	 * This API retrieves the tcam resource info from the rm db.
+	 *
+	 * [in] tfp
+	 *   Pointer to TF handle
+	 *
+	 * [in] parms
+	 *   Pointer to tcam info
+	 *
+	 * Returns
+	 *   - (0) if successful.
+	 *   - (-EINVAL) on failure.
+	 */
+	int (*tf_dev_get_tcam_resc_info)(struct tf *tfp,
+					 struct tf_tcam_resource_info *parms);
+
 	/**
 	 * Insert EM hash entry API
 	 *
@@ -588,6 +643,24 @@ struct tf_dev_ops {
 	int (*tf_dev_delete_ext_em_entry)(struct tf *tfp,
 					  struct tf_delete_em_entry_parms *parms);
 
+	/**
+	 * Retrieves the em resource info.
+	 *
+	 * This API retrieves the em resource info from the rm db.
+	 *
+	 * [in] tfp
+	 *   Pointer to TF handle
+	 *
+	 * [in] parms
+	 *   Pointer to em info
+	 *
+	 * Returns
+	 *   - (0) if successful.
+	 *   - (-EINVAL) on failure.
+	 */
+	int (*tf_dev_get_em_resc_info)(struct tf *tfp,
+				       struct tf_em_resource_info *parms);
+
 	/**
 	 * Allocate EEM table scope
 	 *
diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.c b/drivers/net/bnxt/tf_core/tf_device_p4.c
index 2fb8fadb56..3f788638c1 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p4.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p4.c
@@ -209,6 +209,7 @@ const struct tf_dev_ops tf_dev_ops_p4_init = {
 	.tf_dev_alloc_ident = NULL,
 	.tf_dev_free_ident = NULL,
 	.tf_dev_search_ident = NULL,
+	.tf_dev_get_ident_resc_info = NULL,
 	.tf_dev_get_tbl_info = NULL,
 	.tf_dev_alloc_ext_tbl = NULL,
 	.tf_dev_alloc_tbl = NULL,
@@ -219,15 +220,18 @@ const struct tf_dev_ops tf_dev_ops_p4_init = {
 	.tf_dev_set_ext_tbl = NULL,
 	.tf_dev_get_tbl = NULL,
 	.tf_dev_get_bulk_tbl = NULL,
+	.tf_dev_get_tbl_resc_info = NULL,
 	.tf_dev_alloc_tcam = NULL,
 	.tf_dev_free_tcam = NULL,
 	.tf_dev_alloc_search_tcam = NULL,
 	.tf_dev_set_tcam = NULL,
 	.tf_dev_get_tcam = NULL,
+	.tf_dev_get_tcam_resc_info = NULL,
 	.tf_dev_insert_int_em_entry = NULL,
 	.tf_dev_delete_int_em_entry = NULL,
 	.tf_dev_insert_ext_em_entry = NULL,
 	.tf_dev_delete_ext_em_entry = NULL,
+	.tf_dev_get_em_resc_info = NULL,
 	.tf_dev_alloc_tbl_scope = NULL,
 	.tf_dev_map_tbl_scope = NULL,
 	.tf_dev_map_parif = NULL,
@@ -250,6 +254,7 @@ const struct tf_dev_ops tf_dev_ops_p4 = {
 	.tf_dev_alloc_ident = tf_ident_alloc,
 	.tf_dev_free_ident = tf_ident_free,
 	.tf_dev_search_ident = tf_ident_search,
+	.tf_dev_get_ident_resc_info = tf_ident_get_resc_info,
 	.tf_dev_get_tbl_info = NULL,
 	.tf_dev_alloc_tbl = tf_tbl_alloc,
 	.tf_dev_alloc_ext_tbl = tf_tbl_ext_alloc,
@@ -260,15 +265,18 @@ const struct tf_dev_ops tf_dev_ops_p4 = {
 	.tf_dev_set_ext_tbl = tf_tbl_ext_common_set,
 	.tf_dev_get_tbl = tf_tbl_get,
 	.tf_dev_get_bulk_tbl = tf_tbl_bulk_get,
+	.tf_dev_get_tbl_resc_info = tf_tbl_get_resc_info,
 	.tf_dev_alloc_tcam = tf_tcam_alloc,
 	.tf_dev_free_tcam = tf_tcam_free,
 	.tf_dev_alloc_search_tcam = tf_tcam_alloc_search,
 	.tf_dev_set_tcam = tf_tcam_set,
 	.tf_dev_get_tcam = NULL,
+	.tf_dev_get_tcam_resc_info = tf_tcam_get_resc_info,
 	.tf_dev_insert_int_em_entry = tf_em_insert_int_entry,
 	.tf_dev_delete_int_em_entry = tf_em_delete_int_entry,
 	.tf_dev_insert_ext_em_entry = tf_em_insert_ext_entry,
 	.tf_dev_delete_ext_em_entry = tf_em_delete_ext_entry,
+	.tf_dev_get_em_resc_info = tf_em_get_resc_info,
 	.tf_dev_alloc_tbl_scope = tf_em_ext_common_alloc,
 	.tf_dev_map_tbl_scope = tf_em_ext_map_tbl_scope,
 	.tf_dev_map_parif = tf_dev_p4_map_parif,
diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c
index 517ffc811b..c2bc283220 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p58.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p58.c
@@ -230,6 +230,7 @@ const struct tf_dev_ops tf_dev_ops_p58_init = {
 	.tf_dev_alloc_ident = NULL,
 	.tf_dev_free_ident = NULL,
 	.tf_dev_search_ident = NULL,
+	.tf_dev_get_ident_resc_info = NULL,
 	.tf_dev_get_tbl_info = NULL,
 	.tf_dev_alloc_ext_tbl = NULL,
 	.tf_dev_alloc_tbl = NULL,
@@ -240,15 +241,18 @@ const struct tf_dev_ops tf_dev_ops_p58_init = {
 	.tf_dev_set_ext_tbl = NULL,
 	.tf_dev_get_tbl = NULL,
 	.tf_dev_get_bulk_tbl = NULL,
+	.tf_dev_get_tbl_resc_info = NULL,
 	.tf_dev_alloc_tcam = NULL,
 	.tf_dev_free_tcam = NULL,
 	.tf_dev_alloc_search_tcam = NULL,
 	.tf_dev_set_tcam = NULL,
 	.tf_dev_get_tcam = NULL,
+	.tf_dev_get_tcam_resc_info = NULL,
 	.tf_dev_insert_int_em_entry = NULL,
 	.tf_dev_delete_int_em_entry = NULL,
 	.tf_dev_insert_ext_em_entry = NULL,
 	.tf_dev_delete_ext_em_entry = NULL,
+	.tf_dev_get_em_resc_info = NULL,
 	.tf_dev_alloc_tbl_scope = NULL,
 	.tf_dev_map_tbl_scope = NULL,
 	.tf_dev_map_parif = NULL,
@@ -271,6 +275,7 @@ const struct tf_dev_ops tf_dev_ops_p58 = {
 	.tf_dev_alloc_ident = tf_ident_alloc,
 	.tf_dev_free_ident = tf_ident_free,
 	.tf_dev_search_ident = tf_ident_search,
+	.tf_dev_get_ident_resc_info = tf_ident_get_resc_info,
 	.tf_dev_get_tbl_info = tf_dev_p58_get_sram_tbl_info,
 	.tf_dev_alloc_tbl = tf_tbl_alloc,
 	.tf_dev_alloc_ext_tbl = tf_tbl_ext_alloc,
@@ -281,15 +286,18 @@ const struct tf_dev_ops tf_dev_ops_p58 = {
 	.tf_dev_set_ext_tbl = tf_tbl_ext_common_set,
 	.tf_dev_get_tbl = tf_tbl_get,
 	.tf_dev_get_bulk_tbl = tf_tbl_bulk_get,
+	.tf_dev_get_tbl_resc_info = tf_tbl_get_resc_info,
 	.tf_dev_alloc_tcam = tf_tcam_alloc,
 	.tf_dev_free_tcam = tf_tcam_free,
 	.tf_dev_alloc_search_tcam = tf_tcam_alloc_search,
 	.tf_dev_set_tcam = tf_tcam_set,
 	.tf_dev_get_tcam = tf_tcam_get,
+	.tf_dev_get_tcam_resc_info = tf_tcam_get_resc_info,
 	.tf_dev_insert_int_em_entry = tf_em_hash_insert_int_entry,
 	.tf_dev_delete_int_em_entry = tf_em_hash_delete_int_entry,
 	.tf_dev_insert_ext_em_entry = NULL,
 	.tf_dev_delete_ext_em_entry = NULL,
+	.tf_dev_get_em_resc_info = tf_em_get_resc_info,
 	.tf_dev_alloc_tbl_scope = NULL,
 	.tf_dev_map_tbl_scope = NULL,
 	.tf_dev_map_parif = NULL,
diff --git a/drivers/net/bnxt/tf_core/tf_em.h b/drivers/net/bnxt/tf_core/tf_em.h
index 19ad7f12be..60d90e28de 100644
--- a/drivers/net/bnxt/tf_core/tf_em.h
+++ b/drivers/net/bnxt/tf_core/tf_em.h
@@ -530,4 +530,21 @@ tf_em_ext_system_bind(struct tf *tfp,
 		      struct tf_em_cfg_parms *parms);
 
 int offload_system_mmap(struct tf_tbl_scope_cb *tbl_scope_cb);
+
+/**
+ * Retrieves the allocated resource info
+ *
+ * [in] tfp
+ *   Pointer to TF handle, used for HCAPI communication
+ *
+ * [in] parms
+ *   Pointer to parameters
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+int
+tf_em_get_resc_info(struct tf *tfp,
+		    struct tf_em_resource_info *em);
 #endif /* _TF_EM_H_ */
diff --git a/drivers/net/bnxt/tf_core/tf_em_common.c b/drivers/net/bnxt/tf_core/tf_em_common.c
index 4dc3c86b57..ed8f6db58c 100644
--- a/drivers/net/bnxt/tf_core/tf_em_common.c
+++ b/drivers/net/bnxt/tf_core/tf_em_common.c
@@ -26,11 +26,6 @@
 /* Number of pointers per page_size */
 #define MAX_PAGE_PTRS(page_size)  ((page_size) / sizeof(void *))
 
-/**
- * Init flag, set on bind and cleared on unbind
- */
-static uint8_t init;
-
 /**
  * Host or system
  */
@@ -924,18 +919,11 @@ tf_em_ext_common_bind(struct tf *tfp,
 	int rc;
 	int i;
 	struct tf_rm_create_db_parms db_cfg = { 0 };
-	uint8_t db_exists = 0;
 	struct em_ext_db *ext_db;
 	struct tfp_calloc_parms cparms;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
-	if (init) {
-		TFP_DRV_LOG(ERR,
-			    "EM Ext DB already initialized\n");
-		return -EINVAL;
-	}
-
 	cparms.nitems = 1;
 	cparms.size = sizeof(struct em_ext_db);
 	cparms.alignment = 0;
@@ -974,12 +962,8 @@ tf_em_ext_common_bind(struct tf *tfp,
 
 			return rc;
 		}
-		db_exists = 1;
 	}
 
-	if (db_exists)
-		init = 1;
-
 	mem_type = parms->mem_type;
 
 	return 0;
@@ -1001,13 +985,6 @@ tf_em_ext_common_unbind(struct tf *tfp)
 
 	TF_CHECK_PARMS1(tfp);
 
-	/* Bail if nothing has been initialized */
-	if (!init) {
-		TFP_DRV_LOG(INFO,
-			    "No EM Ext DBs created\n");
-		return 0;
-	}
-
 	rc = tf_session_get_session_internal(tfp, &tfs);
 	if (rc) {
 		TFP_DRV_LOG(ERR, "Failed to get tf_session, rc:%s\n",
@@ -1064,8 +1041,6 @@ tf_em_ext_common_unbind(struct tf *tfp)
 	tfp_free(ext_db);
 	tf_session_set_em_ext_db(tfp, NULL);
 
-	init = 0;
-
 	return 0;
 }
 
diff --git a/drivers/net/bnxt/tf_core/tf_em_internal.c b/drivers/net/bnxt/tf_core/tf_em_internal.c
index 5a100ef1de..e373a9b029 100644
--- a/drivers/net/bnxt/tf_core/tf_em_internal.c
+++ b/drivers/net/bnxt/tf_core/tf_em_internal.c
@@ -20,11 +20,6 @@
 
 #define TF_EM_DB_EM_REC 0
 
-/**
- * Init flag, set on bind and cleared on unbind
- */
-static uint8_t init;
-
 /**
  * EM Pool
  */
@@ -234,19 +229,18 @@ tf_em_int_bind(struct tf *tfp,
 	int rc;
 	int i;
 	struct tf_rm_create_db_parms db_cfg = { 0 };
-	uint8_t db_exists = 0;
 	struct tf_rm_get_alloc_info_parms iparms;
 	struct tf_rm_alloc_info info;
 	struct em_rm_db *em_db;
 	struct tfp_calloc_parms cparms;
+	struct tf_session *tfs;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
-	if (init) {
-		TFP_DRV_LOG(ERR,
-			    "EM Int DB already initialized\n");
-		return -EINVAL;
-	}
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
 
 	memset(&db_cfg, 0, sizeof(db_cfg));
 	cparms.nitems = 1;
@@ -290,8 +284,11 @@ tf_em_int_bind(struct tf *tfp,
 		}
 
 		db_cfg.rm_db = (void *)&em_db->em_db[i];
-
-		rc = tf_rm_create_db(tfp, &db_cfg);
+		if (tf_session_is_shared_session(tfs) &&
+			(!tf_session_is_shared_session_creator(tfs)))
+			rc = tf_rm_create_db_no_reservation(tfp, &db_cfg);
+		else
+			rc = tf_rm_create_db(tfp, &db_cfg);
 		if (rc) {
 			TFP_DRV_LOG(ERR,
 				    "%s: EM Int DB creation failed\n",
@@ -299,34 +296,31 @@ tf_em_int_bind(struct tf *tfp,
 
 			return rc;
 		}
-		db_exists = 1;
 	}
 
-	if (db_exists)
-		init = 1;
-
-	for (i = 0; i < TF_DIR_MAX; i++) {
-		iparms.rm_db = em_db->em_db[i];
-		iparms.subtype = TF_EM_DB_EM_REC;
-		iparms.info = &info;
+	if (!tf_session_is_shared_session(tfs)) {
+		for (i = 0; i < TF_DIR_MAX; i++) {
+			iparms.rm_db = em_db->em_db[i];
+			iparms.subtype = TF_EM_DB_EM_REC;
+			iparms.info = &info;
+
+			rc = tf_rm_get_info(&iparms);
+			if (rc) {
+				TFP_DRV_LOG(ERR,
+					    "%s: EM DB get info failed\n",
+					    tf_dir_2_str(i));
+				return rc;
+			}
 
-		rc = tf_rm_get_info(&iparms);
-		if (rc) {
-			TFP_DRV_LOG(ERR,
-				    "%s: EM DB get info failed\n",
-				    tf_dir_2_str(i));
-			return rc;
+			rc = tf_create_em_pool(i,
+					       iparms.info->entry.stride,
+					       iparms.info->entry.start);
+			/* Logging handled in tf_create_em_pool */
+			if (rc)
+				return rc;
 		}
-
-		rc = tf_create_em_pool(i,
-				       iparms.info->entry.stride,
-				       iparms.info->entry.start);
-		/* Logging handled in tf_create_em_pool */
-		if (rc)
-			return rc;
 	}
 
-
 	return 0;
 }
 
@@ -338,18 +332,19 @@ tf_em_int_unbind(struct tf *tfp)
 	struct tf_rm_free_db_parms fparms = { 0 };
 	struct em_rm_db *em_db;
 	void *em_db_ptr = NULL;
+	struct tf_session *tfs;
 
 	TF_CHECK_PARMS1(tfp);
 
-	/* Bail if nothing has been initialized */
-	if (!init) {
-		TFP_DRV_LOG(INFO,
-			    "No EM Int DBs created\n");
-		return 0;
-	}
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
 
-	for (i = 0; i < TF_DIR_MAX; i++)
-		tf_free_em_pool(i);
+	if (!tf_session_is_shared_session(tfs)) {
+		for (i = 0; i < TF_DIR_MAX; i++)
+			tf_free_em_pool(i);
+	}
 
 	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_EM, &em_db_ptr);
 	if (rc) {
@@ -372,7 +367,42 @@ tf_em_int_unbind(struct tf *tfp)
 		em_db->em_db[i] = NULL;
 	}
 
-	init = 0;
+	return 0;
+}
+
+int
+tf_em_get_resc_info(struct tf *tfp,
+		    struct tf_em_resource_info *em)
+{
+	int rc;
+	int d;
+	struct tf_resource_info *dinfo;
+	struct tf_rm_get_alloc_info_parms ainfo;
+	void *em_db_ptr = NULL;
+	struct em_rm_db *em_db;
+
+	TF_CHECK_PARMS2(tfp, em);
+
+	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_EM, &em_db_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to get em_ext_db from session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	em_db = (struct em_rm_db *)em_db_ptr;
+
+	/* check if reserved resource for WC is multiple of num_slices */
+	for (d = 0; d < TF_DIR_MAX; d++) {
+		ainfo.rm_db = em_db->em_db[d];
+		dinfo = em[d].info;
+
+		ainfo.info = (struct tf_rm_alloc_info *)dinfo;
+		ainfo.subtype = 0;
+		rc = tf_rm_get_all_info(&ainfo, TF_EM_TBL_TYPE_MAX);
+		if (rc && rc != -ENOTSUP)
+			return rc;
+	}
 
 	return 0;
 }
diff --git a/drivers/net/bnxt/tf_core/tf_identifier.c b/drivers/net/bnxt/tf_core/tf_identifier.c
index ee68b6ca58..4063f3ba17 100644
--- a/drivers/net/bnxt/tf_core/tf_identifier.c
+++ b/drivers/net/bnxt/tf_core/tf_identifier.c
@@ -15,11 +15,6 @@
 
 struct tf;
 
-/**
- * Init flag, set on bind and cleared on unbind
- */
-static uint8_t init;
-
 /**
  * Identifier shadow DBs.
  */
@@ -41,14 +36,14 @@ tf_ident_bind(struct tf *tfp,
 	struct tf_shadow_ident_create_db_parms shadow_cdb = { 0 };
 	struct ident_rm_db *ident_db;
 	struct tfp_calloc_parms cparms;
+	struct tf_session *tfs;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
-	if (init) {
-		TFP_DRV_LOG(ERR,
-			    "Identifier DB already initialized\n");
-		return -EINVAL;
-	}
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
 
 	memset(&db_cfg, 0, sizeof(db_cfg));
 	cparms.nitems = 1;
@@ -73,7 +68,11 @@ tf_ident_bind(struct tf *tfp,
 		db_cfg.rm_db = (void *)&ident_db->ident_db[i];
 		db_cfg.dir = i;
 		db_cfg.alloc_cnt = parms->resources->ident_cnt[i].cnt;
-		rc = tf_rm_create_db(tfp, &db_cfg);
+		if (tf_session_is_shared_session(tfs) &&
+			(!tf_session_is_shared_session_creator(tfs)))
+			rc = tf_rm_create_db_no_reservation(tfp, &db_cfg);
+		else
+			rc = tf_rm_create_db(tfp, &db_cfg);
 		if (rc) {
 			TFP_DRV_LOG(ERR,
 				    "%s: Identifier DB creation failed\n",
@@ -100,8 +99,6 @@ tf_ident_bind(struct tf *tfp,
 		}
 	}
 
-	init = 1;
-
 	TFP_DRV_LOG(INFO,
 		    "Identifier - initialized\n");
 
@@ -120,13 +117,6 @@ tf_ident_unbind(struct tf *tfp)
 
 	TF_CHECK_PARMS1(tfp);
 
-	/* Bail if nothing has been initialized */
-	if (!init) {
-		TFP_DRV_LOG(INFO,
-			    "No Identifier DBs created\n");
-		return 0;
-	}
-
 	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr);
 	if (rc) {
 		TFP_DRV_LOG(ERR,
@@ -158,7 +148,6 @@ tf_ident_unbind(struct tf *tfp)
 		ident_db->ident_db[i] = NULL;
 	}
 
-	init = 0;
 	shadow_init = 0;
 
 	return 0;
@@ -178,13 +167,6 @@ tf_ident_alloc(struct tf *tfp __rte_unused,
 
 	TF_CHECK_PARMS2(tfp, parms);
 
-	if (!init) {
-		TFP_DRV_LOG(ERR,
-			    "%s: No Identifier DBs created\n",
-			    tf_dir_2_str(parms->dir));
-		return -EINVAL;
-	}
-
 	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr);
 	if (rc) {
 		TFP_DRV_LOG(ERR,
@@ -242,13 +224,6 @@ tf_ident_free(struct tf *tfp __rte_unused,
 
 	TF_CHECK_PARMS2(tfp, parms);
 
-	if (!init) {
-		TFP_DRV_LOG(ERR,
-			    "%s: No Identifier DBs created\n",
-			    tf_dir_2_str(parms->dir));
-		return -EINVAL;
-	}
-
 	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr);
 	if (rc) {
 		TFP_DRV_LOG(ERR,
@@ -329,13 +304,6 @@ tf_ident_search(struct tf *tfp __rte_unused,
 
 	TF_CHECK_PARMS2(tfp, parms);
 
-	if (!init) {
-		TFP_DRV_LOG(ERR,
-			    "%s: No Identifier DBs created\n",
-			    tf_dir_2_str(parms->dir));
-		return -EINVAL;
-	}
-
 	if (!shadow_init) {
 		TFP_DRV_LOG(ERR,
 			    "%s: Identifier Shadow copy is not enabled\n",
@@ -388,3 +356,40 @@ tf_ident_search(struct tf *tfp __rte_unused,
 
 	return 0;
 }
+
+int
+tf_ident_get_resc_info(struct tf *tfp,
+		       struct tf_identifier_resource_info *ident)
+{
+	int rc;
+	int d;
+	struct tf_resource_info *dinfo;
+	struct tf_rm_get_alloc_info_parms ainfo;
+	void *ident_db_ptr = NULL;
+	struct ident_rm_db *ident_db;
+
+	TF_CHECK_PARMS2(tfp, ident);
+
+	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to get ident_db from session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	ident_db = (struct ident_rm_db *)ident_db_ptr;
+
+	/* check if reserved resource for WC is multiple of num_slices */
+	for (d = 0; d < TF_DIR_MAX; d++) {
+		ainfo.rm_db = ident_db->ident_db[d];
+		dinfo = ident[d].info;
+
+		ainfo.info = (struct tf_rm_alloc_info *)dinfo;
+		ainfo.subtype = 0;
+		rc = tf_rm_get_all_info(&ainfo, TF_IDENT_TYPE_MAX);
+		if (rc)
+			return rc;
+	}
+
+	return 0;
+}
diff --git a/drivers/net/bnxt/tf_core/tf_identifier.h b/drivers/net/bnxt/tf_core/tf_identifier.h
index 54cecbfd4c..55c093802e 100644
--- a/drivers/net/bnxt/tf_core/tf_identifier.h
+++ b/drivers/net/bnxt/tf_core/tf_identifier.h
@@ -201,4 +201,20 @@ int tf_ident_free(struct tf *tfp,
 int tf_ident_search(struct tf *tfp,
 		    struct tf_ident_search_parms *parms);
 
+/**
+ * Retrieves the allocated resource info
+ *
+ * [in] tfp
+ *   Pointer to TF handle, used for HCAPI communication
+ *
+ * [in] parms
+ *   Pointer to parameters
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+int tf_ident_get_resc_info(struct tf *tfp,
+			   struct tf_identifier_resource_info *parms);
+
 #endif /* _TF_IDENTIFIER_H_ */
diff --git a/drivers/net/bnxt/tf_core/tf_msg.c b/drivers/net/bnxt/tf_core/tf_msg.c
index c6eb94bee0..4a840f3473 100644
--- a/drivers/net/bnxt/tf_core/tf_msg.c
+++ b/drivers/net/bnxt/tf_core/tf_msg.c
@@ -114,11 +114,12 @@ tf_msg_free_dma_buf(struct tf_msg_dma_buf *buf)
 /* HWRM Direct messages */
 
 int
-tf_msg_session_open(struct tf *tfp,
+tf_msg_session_open(struct bnxt *bp,
 		    char *ctrl_chan_name,
 		    uint8_t *fw_session_id,
 		    uint8_t *fw_session_client_id,
-		    struct tf_dev_info *dev)
+		    struct tf_dev_info *dev,
+		    bool *shared_session_creator)
 {
 	int rc;
 	struct hwrm_tf_session_open_input req = { 0 };
@@ -135,7 +136,7 @@ tf_msg_session_open(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tfp,
+	rc = tfp_send_msg_direct(bp,
 				 &parms);
 	if (rc)
 		return rc;
@@ -143,6 +144,8 @@ tf_msg_session_open(struct tf *tfp,
 	*fw_session_id = (uint8_t)tfp_le_to_cpu_32(resp.fw_session_id);
 	*fw_session_client_id =
 		(uint8_t)tfp_le_to_cpu_32(resp.fw_session_client_id);
+	*shared_session_creator = (bool)tfp_le_to_cpu_32(resp.flags
+		& HWRM_TF_SESSION_OPEN_OUTPUT_FLAGS_SHARED_SESSION_CREATOR);
 
 	return rc;
 }
@@ -198,7 +201,7 @@ tf_msg_session_client_register(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tfp,
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
 				 &parms);
 	if (rc)
 		return rc;
@@ -249,7 +252,7 @@ tf_msg_session_client_unregister(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tfp,
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
 				 &parms);
 
 	return rc;
@@ -293,7 +296,7 @@ tf_msg_session_close(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tfp,
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
 				 &parms);
 	return rc;
 }
@@ -345,7 +348,7 @@ tf_msg_session_qcfg(struct tf *tfp)
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tfp,
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
 				 &parms);
 	return rc;
 }
@@ -367,6 +370,16 @@ tf_msg_session_resc_qcaps(struct tf *tfp,
 	struct tf_msg_dma_buf qcaps_buf = { 0 };
 	struct tf_rm_resc_req_entry *data;
 	int dma_size;
+	struct tf_session *tfs;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to lookup session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
 
 	TF_CHECK_PARMS3(tfp, query, resv_strategy);
 
@@ -398,7 +411,7 @@ tf_msg_session_resc_qcaps(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tfp, &parms);
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
 	if (rc)
 		goto cleanup;
 
@@ -416,6 +429,7 @@ tf_msg_session_resc_qcaps(struct tf *tfp,
 
 	/* Post process the response */
 	data = (struct tf_rm_resc_req_entry *)qcaps_buf.va_addr;
+
 	for (i = 0; i < size; i++) {
 		query[i].type = tfp_le_to_cpu_32(data[i].type);
 		query[i].min = tfp_le_to_cpu_16(data[i].min);
@@ -450,6 +464,16 @@ tf_msg_session_resc_alloc(struct tf *tfp,
 	struct tf_rm_resc_req_entry *req_data;
 	struct tf_rm_resc_entry *resv_data;
 	int dma_size;
+	struct tf_session *tfs;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to lookup session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
 
 	TF_CHECK_PARMS3(tfp, request, resv);
 
@@ -497,7 +521,114 @@ tf_msg_session_resc_alloc(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tfp, &parms);
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
+	if (rc)
+		goto cleanup;
+
+	/* Process the response
+	 * Should always get expected number of entries
+	 */
+	if (tfp_le_to_cpu_32(resp.size) != size) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Alloc message size error, rc:%s\n",
+			    tf_dir_2_str(dir),
+			    strerror(EINVAL));
+		rc = -EINVAL;
+		goto cleanup;
+	}
+
+	/* Post process the response */
+	resv_data = (struct tf_rm_resc_entry *)resv_buf.va_addr;
+	for (i = 0; i < size; i++) {
+		resv[i].type = tfp_le_to_cpu_32(resv_data[i].type);
+		resv[i].start = tfp_le_to_cpu_16(resv_data[i].start);
+		resv[i].stride = tfp_le_to_cpu_16(resv_data[i].stride);
+	}
+
+cleanup:
+	tf_msg_free_dma_buf(&req_buf);
+	tf_msg_free_dma_buf(&resv_buf);
+
+	return rc;
+}
+
+int
+tf_msg_session_resc_info(struct tf *tfp,
+			 struct tf_dev_info *dev,
+			 enum tf_dir dir,
+			 uint16_t size,
+			 struct tf_rm_resc_req_entry *request,
+			 struct tf_rm_resc_entry *resv)
+{
+	int rc;
+	int i;
+	struct tfp_send_msg_parms parms = { 0 };
+	struct hwrm_tf_session_resc_info_input req = { 0 };
+	struct hwrm_tf_session_resc_info_output resp = { 0 };
+	uint8_t fw_session_id;
+	struct tf_msg_dma_buf req_buf = { 0 };
+	struct tf_msg_dma_buf resv_buf = { 0 };
+	struct tf_rm_resc_req_entry *req_data;
+	struct tf_rm_resc_entry *resv_data;
+	int dma_size;
+	struct tf_session *tfs;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to lookup session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+
+	TF_CHECK_PARMS3(tfp, request, resv);
+
+	rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Unable to lookup FW id, rc:%s\n",
+			    tf_dir_2_str(dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Prepare DMA buffers */
+	dma_size = size * sizeof(struct tf_rm_resc_req_entry);
+	rc = tf_msg_alloc_dma_buf(&req_buf, dma_size);
+	if (rc)
+		return rc;
+
+	dma_size = size * sizeof(struct tf_rm_resc_entry);
+	rc = tf_msg_alloc_dma_buf(&resv_buf, dma_size);
+	if (rc) {
+		tf_msg_free_dma_buf(&req_buf);
+		return rc;
+	}
+
+	/* Populate the request */
+	req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
+	req.flags = tfp_cpu_to_le_16(dir);
+	req.req_size = size;
+
+	req_data = (struct tf_rm_resc_req_entry *)req_buf.va_addr;
+	for (i = 0; i < size; i++) {
+		req_data[i].type = tfp_cpu_to_le_32(request[i].type);
+		req_data[i].min = tfp_cpu_to_le_16(request[i].min);
+		req_data[i].max = tfp_cpu_to_le_16(request[i].max);
+	}
+
+	req.req_addr = tfp_cpu_to_le_64(req_buf.pa_addr);
+	req.resc_addr = tfp_cpu_to_le_64(resv_buf.pa_addr);
+
+	parms.tf_type = HWRM_TF_SESSION_RESC_INFO;
+	parms.req_data = (uint32_t *)&req;
+	parms.req_size = sizeof(req);
+	parms.resp_data = (uint32_t *)&resp;
+	parms.resp_size = sizeof(resp);
+	parms.mailbox = dev->ops->tf_dev_get_mailbox();
+
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
 	if (rc)
 		goto cleanup;
 
@@ -604,7 +735,7 @@ tf_msg_session_resc_flush(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tfp, &parms);
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
 
 	tf_msg_free_dma_buf(&resv_buf);
 
@@ -698,7 +829,7 @@ tf_msg_insert_em_internal_entry(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tfp,
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
 				 &parms);
 	if (rc)
 		return rc;
@@ -793,7 +924,7 @@ tf_msg_hash_insert_em_internal_entry(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tfp,
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
 				 &parms);
 	if (rc)
 		return rc;
@@ -863,7 +994,7 @@ tf_msg_delete_em_entry(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tfp,
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
 				 &parms);
 	if (rc)
 		return rc;
@@ -919,7 +1050,7 @@ int tf_msg_ext_em_ctxt_mem_alloc(struct tf *tfp,
 		parms.resp_data = (uint32_t *)&resp;
 		parms.resp_size = sizeof(resp);
 		parms.mailbox = dev->ops->tf_dev_get_mailbox();
-		rc = tfp_send_msg_direct(tfp, &parms);
+		rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
 		if (rc) {
 			TFP_DRV_LOG(ERR, "Failed ext_em_alloc error rc:%s\n",
 				strerror(-rc));
@@ -979,7 +1110,7 @@ int tf_msg_ext_em_ctxt_mem_free(struct tf *tfp,
 	parms.resp_data = (uint32_t *)&resp;
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
-	rc = tfp_send_msg_direct(tfp, &parms);
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
 
 	return rc;
 }
@@ -1030,7 +1161,7 @@ tf_msg_em_mem_rgtr(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tfp,
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
 				 &parms);
 	if (rc)
 		return rc;
@@ -1082,7 +1213,7 @@ tf_msg_em_mem_unrgtr(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tfp,
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
 				 &parms);
 	return rc;
 }
@@ -1134,7 +1265,7 @@ tf_msg_em_qcaps(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tfp,
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
 				 &parms);
 	if (rc)
 		return rc;
@@ -1209,7 +1340,7 @@ tf_msg_em_cfg(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tfp,
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
 				 &parms);
 	return rc;
 }
@@ -1283,7 +1414,7 @@ tf_msg_ext_em_cfg(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tfp,
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
 				 &parms);
 	return rc;
 }
@@ -1333,7 +1464,7 @@ tf_msg_em_op(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tfp,
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
 				 &parms);
 	return rc;
 }
@@ -1351,6 +1482,16 @@ tf_msg_tcam_entry_set(struct tf *tfp,
 	uint8_t *data = NULL;
 	int data_size = 0;
 	uint8_t fw_session_id;
+	struct tf_session *tfs;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to lookup session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
 
 	rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
 	if (rc) {
@@ -1401,7 +1542,7 @@ tf_msg_tcam_entry_set(struct tf *tfp,
 	mparms.resp_size = sizeof(resp);
 	mparms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tfp,
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
 				 &mparms);
 
 cleanup:
@@ -1420,6 +1561,16 @@ tf_msg_tcam_entry_get(struct tf *tfp,
 	struct hwrm_tf_tcam_get_input req = { 0 };
 	struct hwrm_tf_tcam_get_output resp = { 0 };
 	uint8_t fw_session_id;
+	struct tf_session *tfs;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to lookup session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
 
 	rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
 	if (rc) {
@@ -1444,7 +1595,7 @@ tf_msg_tcam_entry_get(struct tf *tfp,
 	mparms.resp_size = sizeof(resp);
 	mparms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tfp,
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
 				 &mparms);
 
 	if (rc != 0)
@@ -1480,6 +1631,16 @@ tf_msg_tcam_entry_free(struct tf *tfp,
 	struct hwrm_tf_tcam_free_output resp = { 0 };
 	struct tfp_send_msg_parms parms = { 0 };
 	uint8_t fw_session_id;
+	struct tf_session *tfs;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to lookup session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
 
 	rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
 	if (rc) {
@@ -1505,7 +1666,7 @@ tf_msg_tcam_entry_free(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tfp,
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
 				 &parms);
 	return rc;
 }
@@ -1586,7 +1747,7 @@ tf_msg_set_tbl_entry(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tfp,
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
 				 &parms);
 	if (rc)
 		return rc;
@@ -1652,7 +1813,7 @@ tf_msg_get_tbl_entry(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tfp,
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
 				 &parms);
 	if (rc)
 		return rc;
@@ -1738,7 +1899,7 @@ tf_msg_get_global_cfg(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tfp, &parms);
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
 	if (rc != 0)
 		return rc;
 
@@ -1839,7 +2000,7 @@ tf_msg_set_global_cfg(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tfp, &parms);
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
 
 	if (rc != 0)
 		return rc;
@@ -1912,7 +2073,7 @@ tf_msg_bulk_get_tbl_entry(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tfp,
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
 				 &parms);
 	if (rc)
 		return rc;
@@ -1975,7 +2136,7 @@ tf_msg_get_if_tbl_entry(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tfp, &parms);
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
 
 	if (rc != 0)
 		return rc;
@@ -2032,7 +2193,7 @@ tf_msg_set_if_tbl_entry(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tfp, &parms);
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
 
 	if (rc != 0)
 		return rc;
diff --git a/drivers/net/bnxt/tf_core/tf_msg.h b/drivers/net/bnxt/tf_core/tf_msg.h
index 7b4a6a3d92..5ecaf9e7e7 100644
--- a/drivers/net/bnxt/tf_core/tf_msg.h
+++ b/drivers/net/bnxt/tf_core/tf_msg.h
@@ -14,6 +14,7 @@
 #include "tf_rm.h"
 #include "tf_tcam.h"
 #include "tf_global_cfg.h"
+#include "bnxt.h"
 
 struct tf;
 
@@ -22,8 +23,8 @@ struct tf;
 /**
  * Sends session open request to Firmware
  *
- * [in] session
- *   Pointer to session handle
+ * [in] bp
+ *   Pointer to bnxt handle
  *
  * [in] ctrl_chan_name
  *   PCI name of the control channel
@@ -31,14 +32,24 @@ struct tf;
  * [in/out] fw_session_id
  *   Pointer to the fw_session_id that is allocated on firmware side
  *
+ * [in/out] fw_session_client_id
+ *   Pointer to the fw_session_client_id that is allocated on firmware side
+ *
+ * [in/out] dev
+ *   Pointer to the associated device
+ *
+ * [out] shared_session_creator
+ *   Pointer to the shared_session_creator
+ *
  * Returns:
  *   0 on Success else internal Truflow error
  */
-int tf_msg_session_open(struct tf *tfp,
+int tf_msg_session_open(struct bnxt *bp,
 			char *ctrl_chan_name,
 			uint8_t *fw_session_id,
 			uint8_t *fw_session_client_id,
-			struct tf_dev_info *dev);
+			struct tf_dev_info *dev,
+			bool *shared_session_creator);
 
 /**
  * Sends session close request to Firmware
@@ -178,6 +189,34 @@ int tf_msg_session_resc_alloc(struct tf *tfp,
 			      struct tf_rm_resc_req_entry *request,
 			      struct tf_rm_resc_entry *resv);
 
+/**
+ * Sends session HW resource allocation request to TF Firmware
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [in] dir
+ *   Receive or Transmit direction
+ *
+ * [in] size
+ *   Number of elements in the req and resv arrays
+ *
+ * [in] req
+ *   Pointer to an array of request elements
+ *
+ * [in] resv
+ *   Pointer to an array of reserved elements
+ *
+ * Returns:
+ *   0 on Success else internal Truflow error
+ */
+int tf_msg_session_resc_info(struct tf *tfp,
+			      struct tf_dev_info *dev,
+			      enum tf_dir dir,
+			      uint16_t size,
+			      struct tf_rm_resc_req_entry *request,
+			      struct tf_rm_resc_entry *resv);
+
 /**
  * Sends session resource flush request to TF Firmware
  *
diff --git a/drivers/net/bnxt/tf_core/tf_rm.c b/drivers/net/bnxt/tf_core/tf_rm.c
index 9fd660543c..761d18413b 100644
--- a/drivers/net/bnxt/tf_core/tf_rm.c
+++ b/drivers/net/bnxt/tf_core/tf_rm.c
@@ -702,7 +702,9 @@ tf_rm_create_db(struct tf *tfp,
 				}
 				db[i].pool = (struct bitalloc *)cparms.mem_va;
 
-				rc = ba_init(db[i].pool, resv[j].stride);
+				rc = ba_init(db[i].pool,
+					     resv[j].stride,
+					     !tf_session_is_shared_session(tfs));
 				if (rc) {
 					TFP_DRV_LOG(ERR,
 					  "%s: Pool init failed, type:%d:%s\n",
@@ -746,6 +748,249 @@ tf_rm_create_db(struct tf *tfp,
 	return -EINVAL;
 }
 
+int
+tf_rm_create_db_no_reservation(struct tf *tfp,
+			       struct tf_rm_create_db_parms *parms)
+{
+	int rc;
+	struct tf_session *tfs;
+	struct tf_dev_info *dev;
+	int i, j;
+	uint16_t hcapi_items, *req_cnt;
+	struct tfp_calloc_parms cparms;
+	struct tf_rm_resc_req_entry *req;
+	struct tf_rm_resc_entry *resv;
+	struct tf_rm_new_db *rm_db;
+	struct tf_rm_element *db;
+	uint32_t pool_size;
+
+	TF_CHECK_PARMS2(tfp, parms);
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
+
+	/* Retrieve device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc)
+		return rc;
+
+	/* Copy requested counts (alloc_cnt) from tf_open_session() to local
+	 * copy (req_cnt) so that it can be updated if required.
+	 */
+
+	cparms.nitems = parms->num_elements;
+	cparms.size = sizeof(uint16_t);
+	cparms.alignment = 0;
+	rc = tfp_calloc(&cparms);
+	if (rc)
+		return rc;
+
+	req_cnt = (uint16_t *)cparms.mem_va;
+
+	tfp_memcpy(req_cnt, parms->alloc_cnt,
+		   parms->num_elements * sizeof(uint16_t));
+
+	/* Process capabilities against DB requirements. However, as a
+	 * DB can hold elements that are not HCAPI we can reduce the
+	 * req msg content by removing those out of the request yet
+	 * the DB holds them all as to give a fast lookup. We can also
+	 * remove entries where there are no request for elements.
+	 */
+	tf_rm_count_hcapi_reservations(parms->dir,
+				       parms->module,
+				       parms->cfg,
+				       req_cnt,
+				       parms->num_elements,
+				       &hcapi_items);
+
+	if (hcapi_items == 0) {
+		TFP_DRV_LOG(ERR,
+			"%s: module:%s Empty RM DB create request\n",
+			tf_dir_2_str(parms->dir),
+			tf_module_2_str(parms->module));
+
+		parms->rm_db = NULL;
+		return -ENOMEM;
+	}
+
+	/* Alloc request, alignment already set */
+	cparms.nitems = (size_t)hcapi_items;
+	cparms.size = sizeof(struct tf_rm_resc_req_entry);
+	rc = tfp_calloc(&cparms);
+	if (rc)
+		return rc;
+	req = (struct tf_rm_resc_req_entry *)cparms.mem_va;
+
+	/* Alloc reservation, alignment and nitems already set */
+	cparms.size = sizeof(struct tf_rm_resc_entry);
+	rc = tfp_calloc(&cparms);
+	if (rc)
+		return rc;
+	resv = (struct tf_rm_resc_entry *)cparms.mem_va;
+
+	/* Build the request */
+	for (i = 0, j = 0; i < parms->num_elements; i++) {
+		struct tf_rm_element_cfg *cfg = &parms->cfg[i];
+		uint16_t hcapi_type = cfg->hcapi_type;
+
+		/* Only perform reservation for requested entries
+		 */
+		if (req_cnt[i] == 0)
+			continue;
+
+		/* Skip any children in the request */
+		if (cfg->cfg_type == TF_RM_ELEM_CFG_HCAPI ||
+		    cfg->cfg_type == TF_RM_ELEM_CFG_HCAPI_BA ||
+		    cfg->cfg_type == TF_RM_ELEM_CFG_HCAPI_BA_PARENT) {
+			req[j].type = hcapi_type;
+			req[j].min = req_cnt[i];
+			req[j].max = req_cnt[i];
+			j++;
+		}
+	}
+
+	/* Get all resources info for the module type
+	 */
+	rc = tf_msg_session_resc_info(tfp,
+				      dev,
+				      parms->dir,
+				      hcapi_items,
+				      req,
+				      resv);
+	if (rc)
+		return rc;
+
+	/* Build the RM DB per the request */
+	cparms.nitems = 1;
+	cparms.size = sizeof(struct tf_rm_new_db);
+	rc = tfp_calloc(&cparms);
+	if (rc)
+		return rc;
+	rm_db = (void *)cparms.mem_va;
+
+	/* Build the DB within RM DB */
+	cparms.nitems = parms->num_elements;
+	cparms.size = sizeof(struct tf_rm_element);
+	rc = tfp_calloc(&cparms);
+	if (rc)
+		return rc;
+	rm_db->db = (struct tf_rm_element *)cparms.mem_va;
+
+	db = rm_db->db;
+	for (i = 0, j = 0; i < parms->num_elements; i++) {
+		struct tf_rm_element_cfg *cfg = &parms->cfg[i];
+		const char *type_str;
+
+		dev->ops->tf_dev_get_resource_str(tfp,
+						  cfg->hcapi_type,
+						  &type_str);
+
+		db[i].cfg_type = cfg->cfg_type;
+		db[i].hcapi_type = cfg->hcapi_type;
+
+		/* Save the parent subtype for later use to find the pool
+		 */
+		if (cfg->cfg_type == TF_RM_ELEM_CFG_HCAPI_BA_CHILD)
+			db[i].parent_subtype = cfg->parent_subtype;
+
+		/* If the element didn't request an allocation no need
+		 * to create a pool nor verify if we got a reservation.
+		 */
+		if (req_cnt[i] == 0)
+			continue;
+
+		/* Skip any children or invalid
+		 */
+		if (cfg->cfg_type != TF_RM_ELEM_CFG_HCAPI &&
+		    cfg->cfg_type != TF_RM_ELEM_CFG_HCAPI_BA &&
+		    cfg->cfg_type != TF_RM_ELEM_CFG_HCAPI_BA_PARENT)
+			continue;
+
+		/* If the element had requested an allocation and that
+		 * allocation was a success (full amount) then
+		 * allocate the pool.
+		 */
+		if (req_cnt[i] == resv[j].stride) {
+			db[i].alloc.entry.start = resv[j].start;
+			db[i].alloc.entry.stride = resv[j].stride;
+
+			/* Only allocate BA pool if a BA type not a child */
+			if (cfg->cfg_type == TF_RM_ELEM_CFG_HCAPI_BA ||
+			    cfg->cfg_type == TF_RM_ELEM_CFG_HCAPI_BA_PARENT) {
+				if (cfg->divider) {
+					resv[j].stride =
+						resv[j].stride / cfg->divider;
+					if (resv[j].stride <= 0) {
+						TFP_DRV_LOG(ERR,
+						     "%s:Divide fails:%d:%s\n",
+						     tf_dir_2_str(parms->dir),
+						     cfg->hcapi_type, type_str);
+						goto fail;
+					}
+				}
+				/* Create pool */
+				pool_size = (BITALLOC_SIZEOF(resv[j].stride) /
+					     sizeof(struct bitalloc));
+				/* Alloc request, alignment already set */
+				cparms.nitems = pool_size;
+				cparms.size = sizeof(struct bitalloc);
+				rc = tfp_calloc(&cparms);
+				if (rc) {
+					TFP_DRV_LOG(ERR,
+					 "%s: Pool alloc failed, type:%d:%s\n",
+					 tf_dir_2_str(parms->dir),
+					 cfg->hcapi_type, type_str);
+					goto fail;
+				}
+				db[i].pool = (struct bitalloc *)cparms.mem_va;
+
+				rc = ba_init(db[i].pool,
+					     resv[j].stride,
+					     !tf_session_is_shared_session(tfs));
+				if (rc) {
+					TFP_DRV_LOG(ERR,
+					  "%s: Pool init failed, type:%d:%s\n",
+					  tf_dir_2_str(parms->dir),
+					  cfg->hcapi_type, type_str);
+					goto fail;
+				}
+			}
+			j++;
+		} else {
+			/* Bail out as we want what we requested for
+			 * all elements, not any less.
+			 */
+			TFP_DRV_LOG(ERR,
+				    "%s: Alloc failed %d:%s req:%d, alloc:%d\n",
+				    tf_dir_2_str(parms->dir), cfg->hcapi_type,
+				    type_str, req_cnt[i], resv[j].stride);
+			goto fail;
+		}
+	}
+
+	rm_db->num_entries = parms->num_elements;
+	rm_db->dir = parms->dir;
+	rm_db->module = parms->module;
+	*parms->rm_db = (void *)rm_db;
+
+	tfp_free((void *)req);
+	tfp_free((void *)resv);
+	tfp_free((void *)req_cnt);
+	return 0;
+
+ fail:
+	tfp_free((void *)req);
+	tfp_free((void *)resv);
+	tfp_free((void *)db->pool);
+	tfp_free((void *)db);
+	tfp_free((void *)rm_db);
+	tfp_free((void *)req_cnt);
+	parms->rm_db = NULL;
+
+	return -EINVAL;
+}
 int
 tf_rm_free_db(struct tf *tfp,
 	      struct tf_rm_free_db_parms *parms)
@@ -1043,6 +1288,36 @@ tf_rm_get_info(struct tf_rm_get_alloc_info_parms *parms)
 	return 0;
 }
 
+int
+tf_rm_get_all_info(struct tf_rm_get_alloc_info_parms *parms, int size)
+{
+	struct tf_rm_new_db *rm_db;
+	enum tf_rm_elem_cfg_type cfg_type;
+	struct tf_rm_alloc_info *info = parms->info;
+	int i;
+
+	TF_CHECK_PARMS2(parms, parms->rm_db);
+	rm_db = (struct tf_rm_new_db *)parms->rm_db;
+	TF_CHECK_PARMS1(rm_db->db);
+
+	for (i = 0; i < size; i++) {
+		cfg_type = rm_db->db[i].cfg_type;
+
+		/* Bail out if not controlled by HCAPI */
+		if (cfg_type == TF_RM_ELEM_CFG_NULL) {
+			info++;
+			continue;
+		}
+
+		memcpy(info,
+		       &rm_db->db[i].alloc,
+		       sizeof(struct tf_rm_alloc_info));
+		info++;
+	}
+
+	return 0;
+}
+
 int
 tf_rm_get_hcapi_type(struct tf_rm_get_hcapi_parms *parms)
 {
diff --git a/drivers/net/bnxt/tf_core/tf_rm.h b/drivers/net/bnxt/tf_core/tf_rm.h
index 6eb6865dac..8b984112e8 100644
--- a/drivers/net/bnxt/tf_core/tf_rm.h
+++ b/drivers/net/bnxt/tf_core/tf_rm.h
@@ -425,6 +425,24 @@ struct tf_rm_check_indexes_in_range_parms {
 int tf_rm_create_db(struct tf *tfp,
 		    struct tf_rm_create_db_parms *parms);
 
+/**
+ * Creates and fills a Resource Manager (RM) DB with requested
+ * elements. The DB is indexed per the parms structure. It only retrieve
+ * allocated resource information for a exist session.
+ *
+ * [in] tfp
+ *   Pointer to TF handle, used for HCAPI communication
+ *
+ * [in] parms
+ *   Pointer to create parameters
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+int tf_rm_create_db_no_reservation(struct tf *tfp,
+		    struct tf_rm_create_db_parms *parms);
+
 /**
  * Closes the Resource Manager (RM) DB and frees all allocated
  * resources per the associated database.
@@ -498,6 +516,22 @@ int tf_rm_is_allocated(struct tf_rm_is_allocated_parms *parms);
  */
 int tf_rm_get_info(struct tf_rm_get_alloc_info_parms *parms);
 
+/**
+ * Retrieves all elements allocation information from the Resource
+ * Manager (RM) DB.
+ *
+ * [in] parms
+ *   Pointer to get info parameters
+ *
+ * [in] size
+ *   number of the elements for the specific module
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+int tf_rm_get_all_info(struct tf_rm_get_alloc_info_parms *parms, int size);
+
 /**
  * Performs a lookup in the Resource Manager DB and retrieves the
  * requested HCAPI RM type.
diff --git a/drivers/net/bnxt/tf_core/tf_session.c b/drivers/net/bnxt/tf_core/tf_session.c
index f591fbe3f5..391d8786ab 100644
--- a/drivers/net/bnxt/tf_core/tf_session.c
+++ b/drivers/net/bnxt/tf_core/tf_session.c
@@ -11,6 +11,7 @@
 #include "tf_common.h"
 #include "tf_msg.h"
 #include "tfp.h"
+#include "bnxt.h"
 
 struct tf_session_client_create_parms {
 	/**
@@ -57,6 +58,7 @@ tf_session_create(struct tf *tfp,
 	uint8_t fw_session_client_id;
 	union tf_session_id *session_id;
 	struct tf_dev_info dev;
+	bool shared_session_creator;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -64,11 +66,12 @@ tf_session_create(struct tf *tfp,
 			&dev);
 
 	/* Open FW session and get a new session_id */
-	rc = tf_msg_session_open(tfp,
+	rc = tf_msg_session_open(parms->open_cfg->bp,
 				 parms->open_cfg->ctrl_chan_name,
 				 &fw_session_id,
 				 &fw_session_client_id,
-				 &dev);
+				 &dev,
+				 &shared_session_creator);
 	if (rc) {
 		/* Log error */
 		if (rc == -EEXIST)
@@ -137,6 +140,7 @@ tf_session_create(struct tf *tfp,
 	session_id->id = session->session_id.id;
 
 	session->shadow_copy = parms->open_cfg->shadow_copy;
+	session->bp = parms->open_cfg->bp;
 
 	/* Init session client list */
 	ll_init(&session->client_ll);
@@ -175,12 +179,20 @@ tf_session_create(struct tf *tfp,
 
 	/* Init session em_ext_db */
 	session->em_ext_db_handle = NULL;
+	if (!strcmp(parms->open_cfg->ctrl_chan_name, "tf_share"))
+		session->shared_session = true;
+
+	if (session->shared_session && shared_session_creator) {
+		session->shared_session_creator = true;
+		parms->open_cfg->shared_session_creator = true;
+	}
 
 	rc = tf_dev_bind(tfp,
 			 parms->open_cfg->device_type,
 			 session->shadow_copy,
 			 &parms->open_cfg->resources,
 			 &session->dev);
+
 	/* Logging handled by dev_bind */
 	if (rc)
 		goto cleanup;
@@ -857,16 +869,29 @@ tf_session_get_db(struct tf *tfp,
 
 	switch (type) {
 	case TF_MODULE_TYPE_IDENTIFIER:
-		*db_handle = tfs->id_db_handle;
+		if (tfs->id_db_handle)
+			*db_handle = tfs->id_db_handle;
+		else
+			rc = -EINVAL;
 		break;
 	case TF_MODULE_TYPE_TABLE:
-		*db_handle = tfs->tbl_db_handle;
+		if (tfs->tbl_db_handle)
+			*db_handle = tfs->tbl_db_handle;
+		else
+			rc = -EINVAL;
+
 		break;
 	case TF_MODULE_TYPE_TCAM:
-		*db_handle = tfs->tcam_db_handle;
+		if (tfs->tcam_db_handle)
+			*db_handle = tfs->tcam_db_handle;
+		else
+			rc = -EINVAL;
 		break;
 	case TF_MODULE_TYPE_EM:
-		*db_handle = tfs->em_db_handle;
+		if (tfs->em_db_handle)
+			*db_handle = tfs->em_db_handle;
+		else
+			rc = -EINVAL;
 		break;
 	default:
 		rc = -EINVAL;
diff --git a/drivers/net/bnxt/tf_core/tf_session.h b/drivers/net/bnxt/tf_core/tf_session.h
index e5c7a07daf..0b8f63c374 100644
--- a/drivers/net/bnxt/tf_core/tf_session.h
+++ b/drivers/net/bnxt/tf_core/tf_session.h
@@ -70,6 +70,23 @@ struct tf_session {
 	 */
 	union tf_session_id session_id;
 
+	/**
+	 * Boolean controlling the use and availability of shared session.
+	 * Shared session will allow the application to share resources
+	 * on the firmware side without having to allocate them on firmware.
+	 * Additional private session core_data will be allocated if this
+	 * boolean is set to 'true', default 'false'.
+	 *
+	 */
+	bool shared_session;
+
+	/**
+	 * This flag indicates the shared session on firmware side is created
+	 * by this session. Some privileges may be assigned to this session.
+	 *
+	 */
+	bool shared_session_creator;
+
 	/**
 	 * Boolean controlling the use and availability of shadow
 	 * copy. Shadow copy will allow the TruFlow Core to keep track
@@ -137,6 +154,11 @@ struct tf_session {
 	 * em db reference for the session
 	 */
 	void *em_db_handle;
+
+	/**
+	 * the pointer to the parent bp struct
+	 */
+	void *bp;
 };
 
 /**
@@ -500,4 +522,48 @@ int
 tf_session_set_db(struct tf *tfp,
 		   enum tf_module_type type,
 		  void *db_handle);
+
+/**
+ * Check if the session is shared session.
+ *
+ * [in] session, pointer to the session
+ *
+ * Returns:
+ *   - true if it is shared session
+ *   - false if it is not shared session
+ */
+static inline bool
+tf_session_is_shared_session(struct tf_session *tfs)
+{
+	return tfs->shared_session;
+}
+
+/**
+ * Check if the session is the shared session creator
+ *
+ * [in] session, pointer to the session
+ *
+ * Returns:
+ *   - true if it is the shared session creator
+ *   - false if it is not the shared session creator
+ */
+static inline bool
+tf_session_is_shared_session_creator(struct tf_session *tfs)
+{
+	return tfs->shared_session_creator;
+}
+
+/**
+ * Get the pointer to the parent bnxt struct
+ *
+ * [in] session, pointer to the session
+ *
+ * Returns:
+ *   - the pointer to the parent bnxt struct
+ */
+static inline struct bnxt*
+tf_session_get_bp(struct tf_session *tfs)
+{
+	return tfs->bp;
+}
 #endif /* _TF_SESSION_H_ */
diff --git a/drivers/net/bnxt/tf_core/tf_tbl.c b/drivers/net/bnxt/tf_core/tf_tbl.c
index 2d0dda18c9..17fb550917 100644
--- a/drivers/net/bnxt/tf_core/tf_tbl.c
+++ b/drivers/net/bnxt/tf_core/tf_tbl.c
@@ -31,11 +31,6 @@ struct tf;
  */
 static void *shadow_tbl_db[TF_DIR_MAX];
 
-/**
- * Init flag, set on bind and cleared on unbind
- */
-static uint8_t init;
-
 /**
  * Shadow init flag, set on bind and cleared on unbind
  */
@@ -49,14 +44,14 @@ tf_tbl_bind(struct tf *tfp,
 	struct tf_rm_create_db_parms db_cfg = { 0 };
 	struct tbl_rm_db *tbl_db;
 	struct tfp_calloc_parms cparms;
+	struct tf_session *tfs;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
-	if (init) {
-		TFP_DRV_LOG(ERR,
-			    "Table DB already initialized\n");
-		return -EINVAL;
-	}
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
 
 	memset(&db_cfg, 0, sizeof(db_cfg));
 	cparms.nitems = 1;
@@ -82,8 +77,11 @@ tf_tbl_bind(struct tf *tfp,
 		db_cfg.dir = d;
 		db_cfg.alloc_cnt = parms->resources->tbl_cnt[d].cnt;
 		db_cfg.rm_db = (void *)&tbl_db->tbl_db[d];
-
-		rc = tf_rm_create_db(tfp, &db_cfg);
+		if (tf_session_is_shared_session(tfs) &&
+			(!tf_session_is_shared_session_creator(tfs)))
+			rc = tf_rm_create_db_no_reservation(tfp, &db_cfg);
+		else
+			rc = tf_rm_create_db(tfp, &db_cfg);
 		if (rc) {
 			TFP_DRV_LOG(ERR,
 				    "%s: Table DB creation failed\n",
@@ -92,7 +90,6 @@ tf_tbl_bind(struct tf *tfp,
 			return rc;
 		}
 	}
-	init = 1;
 
 	TFP_DRV_LOG(INFO,
 		    "Table Type - initialized\n");
@@ -110,13 +107,6 @@ tf_tbl_unbind(struct tf *tfp)
 	void *tbl_db_ptr = NULL;
 	TF_CHECK_PARMS1(tfp);
 
-	/* Bail if nothing has been initialized */
-	if (!init) {
-		TFP_DRV_LOG(INFO,
-			    "No Table DBs created\n");
-		return 0;
-	}
-
 	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
 	if (rc) {
 		TFP_DRV_LOG(ERR,
@@ -136,7 +126,6 @@ tf_tbl_unbind(struct tf *tfp)
 		tbl_db->tbl_db[i] = NULL;
 	}
 
-	init = 0;
 	shadow_init = 0;
 
 	return 0;
@@ -157,13 +146,6 @@ tf_tbl_alloc(struct tf *tfp __rte_unused,
 
 	TF_CHECK_PARMS2(tfp, parms);
 
-	if (!init) {
-		TFP_DRV_LOG(ERR,
-			    "%s: No Table DBs created\n",
-			    tf_dir_2_str(parms->dir));
-		return -EINVAL;
-	}
-
 	/* Retrieve the session information */
 	rc = tf_session_get_session_internal(tfp, &tfs);
 	if (rc)
@@ -234,12 +216,6 @@ tf_tbl_free(struct tf *tfp __rte_unused,
 
 	TF_CHECK_PARMS2(tfp, parms);
 
-	if (!init) {
-		TFP_DRV_LOG(ERR,
-			    "%s: No Table DBs created\n",
-			    tf_dir_2_str(parms->dir));
-		return -EINVAL;
-	}
 	/* Retrieve the session information */
 	rc = tf_session_get_session_internal(tfp, &tfs);
 	if (rc)
@@ -346,13 +322,6 @@ tf_tbl_set(struct tf *tfp,
 
 	TF_CHECK_PARMS3(tfp, parms, parms->data);
 
-	if (!init) {
-		TFP_DRV_LOG(ERR,
-			    "%s: No Table DBs created\n",
-			    tf_dir_2_str(parms->dir));
-		return -EINVAL;
-	}
-
 	/* Retrieve the session information */
 	rc = tf_session_get_session_internal(tfp, &tfs);
 	if (rc)
@@ -456,14 +425,6 @@ tf_tbl_get(struct tf *tfp,
 
 	TF_CHECK_PARMS3(tfp, parms, parms->data);
 
-	if (!init) {
-		TFP_DRV_LOG(ERR,
-			    "%s: No Table DBs created\n",
-			    tf_dir_2_str(parms->dir));
-		return -EINVAL;
-	}
-
-
 	/* Retrieve the session information */
 	rc = tf_session_get_session_internal(tfp, &tfs);
 	if (rc)
@@ -567,14 +528,6 @@ tf_tbl_bulk_get(struct tf *tfp,
 
 	TF_CHECK_PARMS2(tfp, parms);
 
-	if (!init) {
-		TFP_DRV_LOG(ERR,
-			    "%s: No Table DBs created\n",
-			    tf_dir_2_str(parms->dir));
-
-		return -EINVAL;
-	}
-
 	/* Retrieve the session information */
 	rc = tf_session_get_session_internal(tfp, &tfs);
 	if (rc)
@@ -662,3 +615,40 @@ tf_tbl_bulk_get(struct tf *tfp,
 
 	return rc;
 }
+
+int
+tf_tbl_get_resc_info(struct tf *tfp,
+		     struct tf_tbl_resource_info *tbl)
+{
+	int rc;
+	int d;
+	struct tf_resource_info *dinfo;
+	struct tf_rm_get_alloc_info_parms ainfo;
+	void *tbl_db_ptr = NULL;
+	struct tbl_rm_db *tbl_db;
+
+	TF_CHECK_PARMS2(tfp, tbl);
+
+	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to get em_ext_db from session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
+
+	/* check if reserved resource for WC is multiple of num_slices */
+	for (d = 0; d < TF_DIR_MAX; d++) {
+		ainfo.rm_db = tbl_db->tbl_db[d];
+		dinfo = tbl[d].info;
+
+		ainfo.info = (struct tf_rm_alloc_info *)dinfo;
+		ainfo.subtype = 0;
+		rc = tf_rm_get_all_info(&ainfo, TF_TBL_TYPE_MAX);
+		if (rc)
+			return rc;
+	}
+
+	return 0;
+}
diff --git a/drivers/net/bnxt/tf_core/tf_tbl.h b/drivers/net/bnxt/tf_core/tf_tbl.h
index 83b72d1b3f..aba46fd161 100644
--- a/drivers/net/bnxt/tf_core/tf_tbl.h
+++ b/drivers/net/bnxt/tf_core/tf_tbl.h
@@ -396,4 +396,21 @@ int tf_tbl_get(struct tf *tfp,
 int tf_tbl_bulk_get(struct tf *tfp,
 		    struct tf_tbl_get_bulk_parms *parms);
 
+/**
+ * Retrieves the allocated resource info
+ *
+ * [in] tfp
+ *   Pointer to TF handle, used for HCAPI communication
+ *
+ * [in] parms
+ *   Pointer to Table resource info parameters
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+int
+tf_tbl_get_resc_info(struct tf *tfp,
+		     struct tf_tbl_resource_info *tbl);
+
 #endif /* TF_TBL_TYPE_H */
diff --git a/drivers/net/bnxt/tf_core/tf_tcam.c b/drivers/net/bnxt/tf_core/tf_tcam.c
index c2eef26dbb..70dc539f15 100644
--- a/drivers/net/bnxt/tf_core/tf_tcam.c
+++ b/drivers/net/bnxt/tf_core/tf_tcam.c
@@ -23,11 +23,6 @@ struct tf;
  */
 static void *shadow_tcam_db[TF_DIR_MAX];
 
-/**
- * Init flag, set on bind and cleared on unbind
- */
-static uint8_t init;
-
 /**
  * Shadow init flag, set on bind and cleared on unbind
  */
@@ -55,12 +50,6 @@ tf_tcam_bind(struct tf *tfp,
 
 	TF_CHECK_PARMS2(tfp, parms);
 
-	if (init) {
-		TFP_DRV_LOG(ERR,
-			    "TCAM DB already initialized\n");
-		return -EINVAL;
-	}
-
 	/* Retrieve the session information */
 	rc = tf_session_get_session_internal(tfp, &tfs);
 	if (rc)
@@ -118,7 +107,11 @@ tf_tcam_bind(struct tf *tfp,
 		db_cfg.dir = d;
 		db_cfg.alloc_cnt = parms->resources->tcam_cnt[d].cnt;
 		db_cfg.rm_db = (void *)&tcam_db->tcam_db[d];
-		rc = tf_rm_create_db(tfp, &db_cfg);
+		if (tf_session_is_shared_session(tfs) &&
+			(!tf_session_is_shared_session_creator(tfs)))
+			rc = tf_rm_create_db_no_reservation(tfp, &db_cfg);
+		else
+			rc = tf_rm_create_db(tfp, &db_cfg);
 		if (rc) {
 			TFP_DRV_LOG(ERR,
 				    "%s: TCAM DB creation failed\n",
@@ -143,7 +136,8 @@ tf_tcam_bind(struct tf *tfp,
 				    "%s: TCAM reserved resource is not multiple of %d\n",
 				    tf_dir_2_str(d),
 				    num_slices);
-			return -EINVAL;
+			rc = -EINVAL;
+			goto error;
 		}
 	}
 
@@ -186,8 +180,6 @@ tf_tcam_bind(struct tf *tfp,
 		shadow_init = 1;
 	}
 
-	init = 1;
-
 	TFP_DRV_LOG(INFO,
 		    "TCAM - initialized\n");
 
@@ -211,7 +203,6 @@ tf_tcam_bind(struct tf *tfp,
 	}
 
 	shadow_init = 0;
-	init = 0;
 
 	return rc;
 }
@@ -227,13 +218,6 @@ tf_tcam_unbind(struct tf *tfp)
 	struct tf_shadow_tcam_free_db_parms fshadow;
 	TF_CHECK_PARMS1(tfp);
 
-	/* Bail if nothing has been initialized */
-	if (!init) {
-		TFP_DRV_LOG(INFO,
-			    "No TCAM DBs created\n");
-		return 0;
-	}
-
 	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);
 	if (rc) {
 		TFP_DRV_LOG(ERR,
@@ -263,7 +247,6 @@ tf_tcam_unbind(struct tf *tfp)
 	}
 
 	shadow_init = 0;
-	init = 0;
 
 	return 0;
 }
@@ -283,13 +266,6 @@ tf_tcam_alloc(struct tf *tfp,
 
 	TF_CHECK_PARMS2(tfp, parms);
 
-	if (!init) {
-		TFP_DRV_LOG(ERR,
-			    "%s: No TCAM DBs created\n",
-			    tf_dir_2_str(parms->dir));
-		return -EINVAL;
-	}
-
 	/* Retrieve the session information */
 	rc = tf_session_get_session_internal(tfp, &tfs);
 	if (rc)
@@ -372,13 +348,6 @@ tf_tcam_free(struct tf *tfp,
 
 	TF_CHECK_PARMS2(tfp, parms);
 
-	if (!init) {
-		TFP_DRV_LOG(ERR,
-			    "%s: No TCAM DBs created\n",
-			    tf_dir_2_str(parms->dir));
-		return -EINVAL;
-	}
-
 	/* Retrieve the session information */
 	rc = tf_session_get_session_internal(tfp, &tfs);
 	if (rc)
@@ -529,13 +498,6 @@ tf_tcam_alloc_search(struct tf *tfp,
 
 	TF_CHECK_PARMS2(tfp, parms);
 
-	if (!init) {
-		TFP_DRV_LOG(ERR,
-			    "%s: No TCAM DBs created\n",
-			    tf_dir_2_str(parms->dir));
-		return -EINVAL;
-	}
-
 	if (!shadow_init || !shadow_tcam_db[parms->dir]) {
 		TFP_DRV_LOG(ERR, "%s: TCAM Shadow not initialized for %s\n",
 			    tf_dir_2_str(parms->dir),
@@ -660,13 +622,6 @@ tf_tcam_set(struct tf *tfp __rte_unused,
 
 	TF_CHECK_PARMS2(tfp, parms);
 
-	if (!init) {
-		TFP_DRV_LOG(ERR,
-			    "%s: No TCAM DBs created\n",
-			    tf_dir_2_str(parms->dir));
-		return -EINVAL;
-	}
-
 	/* Retrieve the session information */
 	rc = tf_session_get_session_internal(tfp, &tfs);
 	if (rc)
@@ -781,13 +736,6 @@ tf_tcam_get(struct tf *tfp __rte_unused,
 
 	TF_CHECK_PARMS2(tfp, parms);
 
-	if (!init) {
-		TFP_DRV_LOG(ERR,
-			    "%s: No TCAM DBs created\n",
-			    tf_dir_2_str(parms->dir));
-		return -EINVAL;
-	}
-
 	/* Retrieve the session information */
 	rc = tf_session_get_session_internal(tfp, &tfs);
 	if (rc)
@@ -852,3 +800,40 @@ tf_tcam_get(struct tf *tfp __rte_unused,
 
 	return 0;
 }
+
+int
+tf_tcam_get_resc_info(struct tf *tfp,
+		      struct tf_tcam_resource_info *tcam)
+{
+	int rc;
+	int d;
+	struct tf_resource_info *dinfo;
+	struct tf_rm_get_alloc_info_parms ainfo;
+	void *tcam_db_ptr = NULL;
+	struct tcam_rm_db *tcam_db;
+
+	TF_CHECK_PARMS2(tfp, tcam);
+
+	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to get em_ext_db from session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	tcam_db = (struct tcam_rm_db *)tcam_db_ptr;
+
+	/* check if reserved resource for WC is multiple of num_slices */
+	for (d = 0; d < TF_DIR_MAX; d++) {
+		ainfo.rm_db = tcam_db->tcam_db[d];
+		dinfo = tcam[d].info;
+
+		ainfo.info = (struct tf_rm_alloc_info *)dinfo;
+		ainfo.subtype = 0;
+		rc = tf_rm_get_all_info(&ainfo, TF_TCAM_TBL_TYPE_MAX);
+		if (rc && rc != -ENOTSUP)
+			return rc;
+	}
+
+	return 0;
+}
diff --git a/drivers/net/bnxt/tf_core/tf_tcam.h b/drivers/net/bnxt/tf_core/tf_tcam.h
index acab223532..bed17af6ae 100644
--- a/drivers/net/bnxt/tf_core/tf_tcam.h
+++ b/drivers/net/bnxt/tf_core/tf_tcam.h
@@ -386,4 +386,20 @@ int tf_tcam_set(struct tf *tfp,
 int tf_tcam_get(struct tf *tfp,
 		struct tf_tcam_get_parms *parms);
 
+/**
+ * Retrieves the allocated resource info
+ *
+ * [in] tfp
+ *   Pointer to TF handle, used for HCAPI communication
+ *
+ * [in] parms
+ *   Pointer to parameters
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+int tf_tcam_get_resc_info(struct tf *tfp,
+			  struct tf_tcam_resource_info *parms);
+
 #endif /* _TF_TCAM_H */
diff --git a/drivers/net/bnxt/tf_core/tfp.c b/drivers/net/bnxt/tf_core/tfp.c
index 37c49b587d..4d9b37f749 100644
--- a/drivers/net/bnxt/tf_core/tfp.c
+++ b/drivers/net/bnxt/tf_core/tfp.c
@@ -28,7 +28,7 @@
  * Returns success or failure code.
  */
 int
-tfp_send_msg_direct(struct tf *tfp,
+tfp_send_msg_direct(struct bnxt *bp,
 		    struct tfp_send_msg_parms *parms)
 {
 	int      rc = 0;
@@ -40,9 +40,7 @@ tfp_send_msg_direct(struct tf *tfp,
 	if (parms->mailbox == TF_CHIMP_MB)
 		use_kong_mb = 0;
 
-	rc = bnxt_hwrm_tf_message_direct(container_of(tfp,
-					       struct bnxt,
-					       tfp),
+	rc = bnxt_hwrm_tf_message_direct(bp,
 					 use_kong_mb,
 					 parms->tf_type,
 					 parms->req_data,
diff --git a/drivers/net/bnxt/tf_core/tfp.h b/drivers/net/bnxt/tf_core/tfp.h
index bcc56b0a54..58f34bbcab 100644
--- a/drivers/net/bnxt/tf_core/tfp.h
+++ b/drivers/net/bnxt/tf_core/tfp.h
@@ -15,6 +15,7 @@
 #include <rte_spinlock.h>
 #include <rte_log.h>
 #include <rte_byteorder.h>
+#include <bnxt.h>
 
 /**
  * DPDK/Driver specific log level for the BNXT Eth driver.
@@ -130,7 +131,7 @@ struct tfp_calloc_parms {
  *   -1             - Global error like not supported
  *   -EINVAL        - Parameter Error
  */
-int tfp_send_msg_direct(struct tf *tfp,
+int tfp_send_msg_direct(struct bnxt *bp,
 			struct tfp_send_msg_parms *parms);
 
 /**
-- 
2.17.1


^ permalink raw reply	[flat|nested] 129+ messages in thread

* [dpdk-dev] [PATCH 15/58] net/bnxt: add dpool allocator for EM allocation
  2021-05-30  8:58 [dpdk-dev] [PATCH 00/58] enhancements to host based flow table management Venkat Duvvuru
                   ` (13 preceding siblings ...)
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 14/58] net/bnxt: add shared session support Venkat Duvvuru
@ 2021-05-30  8:58 ` Venkat Duvvuru
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 16/58] net/bnxt: update shared session functionality Venkat Duvvuru
                   ` (43 subsequent siblings)
  58 siblings, 0 replies; 129+ messages in thread
From: Venkat Duvvuru @ 2021-05-30  8:58 UTC (permalink / raw)
  To: dev; +Cc: Peter Spreadborough, Randy Schacher, Venkat Duvvuru

From: Peter Spreadborough <peter.spreadborough@broadcom.com>

The dpool allocator supports variable size entries and
also supports defragmentation of the allocation space.
EM will by default use the fixed size stack allocator.
The dynamic allocator may be selected at build time.
The dpool allocator supports variable size entries and
also supports defragmentation of the allocation space.

Signed-off-by: Peter Spreadborough <peter.spreadborough@broadcom.com>
Signed-off-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Farah Smith <farah.smith@broadcom.com>
---
 drivers/net/bnxt/tf_core/dpool.c              | 373 ++++++++++++++++++
 drivers/net/bnxt/tf_core/dpool.h              | 309 +++++++++++++++
 drivers/net/bnxt/tf_core/meson.build          |   1 +
 drivers/net/bnxt/tf_core/tf_core.h            |  42 ++
 drivers/net/bnxt/tf_core/tf_device.h          |  34 ++
 drivers/net/bnxt/tf_core/tf_device_p58.c      |   5 +
 drivers/net/bnxt/tf_core/tf_em.h              |  26 ++
 .../net/bnxt/tf_core/tf_em_hash_internal.c    | 102 ++++-
 drivers/net/bnxt/tf_core/tf_em_internal.c     | 215 ++++++++--
 drivers/net/bnxt/tf_core/tf_msg.c             |  69 ++++
 drivers/net/bnxt/tf_core/tf_msg.h             |  15 +
 drivers/net/bnxt/tf_core/tf_session.h         |   5 +
 12 files changed, 1156 insertions(+), 40 deletions(-)
 create mode 100644 drivers/net/bnxt/tf_core/dpool.c
 create mode 100644 drivers/net/bnxt/tf_core/dpool.h

diff --git a/drivers/net/bnxt/tf_core/dpool.c b/drivers/net/bnxt/tf_core/dpool.c
new file mode 100644
index 0000000000..a5f9f866b7
--- /dev/null
+++ b/drivers/net/bnxt/tf_core/dpool.c
@@ -0,0 +1,373 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019-2021 Broadcom
+ * All rights reserved.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <errno.h>
+
+#include <rte_malloc.h>
+
+#include "tfp.h"
+#include "dpool.h"
+
+int dpool_init(struct dpool *dpool,
+	       uint32_t start_index,
+	       uint32_t size,
+	       uint8_t max_alloc_size,
+	       void *user_data,
+	       int (*move_callback)(void *, uint64_t, uint32_t))
+{
+	uint32_t i;
+	int rc;
+	struct tfp_calloc_parms parms;
+
+	parms.nitems = size;
+	parms.size = sizeof(struct dpool_entry);
+	parms.alignment = 0;
+
+	rc = tfp_calloc(&parms);
+
+	if (rc)
+		return rc;
+
+	dpool->entry = parms.mem_va;
+	dpool->start_index = start_index;
+	dpool->size = size;
+	dpool->max_alloc_size = max_alloc_size;
+	dpool->user_data = user_data;
+	dpool->move_callback = move_callback;
+	/*
+	 * Init entries
+	 */
+	for (i = 0; i < size; i++) {
+		dpool->entry[i].flags = 0;
+		dpool->entry[i].index = start_index;
+		dpool->entry[i].entry_data = 0UL;
+		start_index++;
+	}
+
+	return 0;
+}
+
+static int dpool_move(struct dpool *dpool,
+		      uint32_t dst_index,
+		      uint32_t src_index)
+{
+	uint32_t size;
+	uint32_t i;
+	if (DP_IS_FREE(dpool->entry[dst_index].flags)) {
+		size = DP_FLAGS_SIZE(dpool->entry[src_index].flags);
+
+		dpool->entry[dst_index].flags = dpool->entry[src_index].flags;
+		dpool->entry[dst_index].entry_data = dpool->entry[src_index].entry_data;
+
+		if (dpool->move_callback != NULL) {
+			dpool->move_callback(dpool->user_data,
+					     dpool->entry[src_index].entry_data,
+					     dst_index + dpool->start_index);
+		}
+
+		dpool->entry[src_index].flags = 0;
+		dpool->entry[src_index].entry_data = 0UL;
+
+		for (i = 1; i < size; i++) {
+			dpool->entry[dst_index + i].flags = size;
+			dpool->entry[src_index + i].flags = 0;
+		}
+	} else {
+		return -1;
+	}
+
+	return 0;
+}
+
+
+int dpool_defrag(struct dpool *dpool,
+		 uint32_t entry_size,
+		 uint8_t defrag)
+{
+	struct dpool_free_list *free_list;
+	struct dpool_adj_list *adj_list;
+	uint32_t count;
+	uint32_t index;
+	uint32_t used;
+	uint32_t i;
+	uint32_t size;
+	uint32_t largest_free_index = 0;
+	uint32_t largest_free_size;
+	uint32_t max;
+	uint32_t max_index;
+	uint32_t max_size = 0;
+	int rc;
+
+	free_list = rte_zmalloc("dpool_free_list",
+				sizeof(struct dpool_free_list), 0);
+	if (free_list == NULL) {
+		TFP_DRV_LOG(ERR, "dpool free list allocation failed\n");
+		return -ENOMEM;
+	}
+
+	adj_list = rte_zmalloc("dpool_adjacent_list",
+				sizeof(struct dpool_adj_list), 0);
+	if (adj_list == NULL) {
+		TFP_DRV_LOG(ERR, "dpool adjacent list allocation failed\n");
+		return -ENOMEM;
+	}
+
+	while (1) {
+		/*
+		 * Create list of free entries
+		 */
+		free_list->size = 0;
+		largest_free_size = 0;
+		largest_free_index = 0;
+		count = 0;
+
+		for (i = 0; i < dpool->size; i++) {
+			if (DP_IS_FREE(dpool->entry[i].flags)) {
+				if (count == 0)
+					index = i;
+				count++;
+			} else if (count > 0) {
+				free_list->entry[free_list->size].index = index;
+				free_list->entry[free_list->size].size = count;
+
+				if (count > largest_free_size) {
+					largest_free_index = free_list->size;
+					largest_free_size = count;
+				}
+
+				free_list->size++;
+				count = 0;
+			}
+		}
+
+		if (free_list->size == 0)
+			largest_free_size = count;
+
+		/*
+		 * If using defrag to fit and there's a large enough
+		 * space then we are done.
+		 */
+		if (defrag == DP_DEFRAG_TO_FIT &&
+		    largest_free_size >= entry_size)
+			goto done;
+
+		/*
+		 * Create list of entries adjacent to free entries
+		 */
+		count = 0;
+		adj_list->size = 0;
+		used = 0;
+
+		for (i = 0; i < dpool->size; ) {
+			if (DP_IS_USED(dpool->entry[i].flags)) {
+				used++;
+
+				if (count > 0) {
+					adj_list->entry[adj_list->size].index = i;
+					adj_list->entry[adj_list->size].size =
+						DP_FLAGS_SIZE(dpool->entry[i].flags);
+					adj_list->entry[adj_list->size].left = count;
+
+					if (adj_list->size > 0 && used == 1)
+						adj_list->entry[adj_list->size - 1].right = count;
+
+					adj_list->size++;
+				}
+
+				count = 0;
+				i += DP_FLAGS_SIZE(dpool->entry[i].flags);
+			} else {
+				used = 0;
+				count++;
+				i++;
+			}
+		}
+
+		/*
+		 * Using the size of the largest free space available
+		 * select the adjacency list entry of that size with
+		 * the largest left + right + size count. If there
+		 * are no entries of that size then decrement the size
+		 * and try again.
+		 */
+		max = 0;
+		max_index = 0;
+		max_size = 0;
+
+		for (size = largest_free_size; size > 0; size--) {
+			for (i = 0; i < adj_list->size; i++) {
+				if (adj_list->entry[i].size == size &&
+				    ((size +
+				      adj_list->entry[i].left +
+				      adj_list->entry[i].right) > max)) {
+					max = size +
+						adj_list->entry[i].left +
+						adj_list->entry[i].right;
+					max_size = size;
+					max_index = adj_list->entry[i].index;
+				}
+			}
+
+			if (max)
+				break;
+		}
+
+		/*
+		 * If the max entry is smaller than the largest_free_size
+		 * find the first entry in the free list that it cn fit in to.
+		 */
+		if (max_size < largest_free_size) {
+			for (i = 0; i < free_list->size; i++) {
+				if (free_list->entry[i].size >= max_size) {
+					largest_free_index = i;
+					break;
+				}
+			}
+		}
+
+		/*
+		 * If we have a contender then move it to the new spot.
+		 */
+		if (max) {
+			rc = dpool_move(dpool,
+					free_list->entry[largest_free_index].index,
+					max_index);
+			if (rc) {
+				rte_free(free_list);
+				rte_free(adj_list);
+				return rc;
+			}
+		} else {
+			break;
+		}
+	}
+
+done:
+	rte_free(free_list);
+	rte_free(adj_list);
+	return largest_free_size;
+}
+
+
+uint32_t dpool_alloc(struct dpool *dpool,
+		     uint32_t size,
+		     uint8_t defrag)
+{
+	uint32_t i;
+	uint32_t j;
+	uint32_t count = 0;
+	uint32_t first_entry_index;
+	int rc;
+
+	if (size > dpool->max_alloc_size || size == 0)
+		return DP_INVALID_INDEX;
+
+	/*
+	 * Defrag requires EM move support.
+	 */
+	if (defrag != DP_DEFRAG_NONE &&
+	    dpool->move_callback == NULL)
+		return DP_INVALID_INDEX;
+
+	while (1) {
+		/*
+		 * find <size> consecutive free entries
+		 */
+		for (i = 0; i < dpool->size; i++) {
+			if (DP_IS_FREE(dpool->entry[i].flags)) {
+				if (count == 0)
+					first_entry_index = i;
+
+				count++;
+
+				if (count == size) {
+					for (j = 0; j < size; j++) {
+						dpool->entry[j + first_entry_index].flags = size;
+						if (j == 0)
+							dpool->entry[j + first_entry_index].flags |= DP_FLAGS_START;
+					}
+
+					dpool->entry[i].entry_data = 0UL;
+					return (first_entry_index + dpool->start_index);
+				}
+			} else {
+				count = 0;
+			}
+		}
+
+		/*
+		 * If defragging then do it to it
+		 */
+		if (defrag != DP_DEFRAG_NONE) {
+			rc = dpool_defrag(dpool, size, defrag);
+
+			if (rc < 0)
+				return DP_INVALID_INDEX;
+		} else {
+			break;
+		}
+
+		/*
+		 * If the defrag created enough space then try the
+		 * alloc again else quit.
+		 */
+		if ((uint32_t)rc < size)
+			break;
+	}
+
+	return DP_INVALID_INDEX;
+}
+
+int dpool_free(struct dpool *dpool,
+	       uint32_t index)
+{
+	uint32_t i;
+	int start = (index - dpool->start_index);
+	uint32_t size;
+
+	if (start < 0)
+		return -1;
+
+	if (DP_IS_START(dpool->entry[start].flags)) {
+		size = DP_FLAGS_SIZE(dpool->entry[start].flags);
+		if (size > dpool->max_alloc_size || size == 0)
+			return -1;
+
+		for (i = start; i < (start + size); i++)
+			dpool->entry[i].flags = 0;
+
+		return 0;
+	}
+
+	return -1;
+}
+
+void dpool_free_all(struct dpool *dpool)
+{
+	uint32_t i;
+
+	for (i = 0; i < dpool->size; i++)
+		dpool_free(dpool, dpool->entry[i].index);
+}
+
+int dpool_set_entry_data(struct dpool *dpool,
+			 uint32_t index,
+			 uint64_t entry_data)
+{
+	int start = (index - dpool->start_index);
+
+	if (start < 0)
+		return -1;
+
+	if (DP_IS_START(dpool->entry[start].flags)) {
+		dpool->entry[start].entry_data = entry_data;
+		return 0;
+	}
+
+	return -1;
+}
diff --git a/drivers/net/bnxt/tf_core/dpool.h b/drivers/net/bnxt/tf_core/dpool.h
new file mode 100644
index 0000000000..db9d53f01f
--- /dev/null
+++ b/drivers/net/bnxt/tf_core/dpool.h
@@ -0,0 +1,309 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019-2021 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _DPOOL_H_
+#define _DPOOL_H_
+
+#include <stdint.h>
+#include <stdlib.h>
+
+#define DP_MAX_FREE_SIZE 0x8000 /* 32K */
+
+#define DP_INVALID_INDEX 0xffffffff
+
+#define DP_FLAGS_START   0x80000000
+#define DP_IS_START(flags) ((flags) & DP_FLAGS_START)
+
+#define DP_FLAGS_SIZE_SHIFT 0
+#define DP_FLAGS_SIZE_MASK  0x07
+
+#define DP_FLAGS_SIZE(flags) (((flags) >> DP_FLAGS_SIZE_SHIFT) & DP_FLAGS_SIZE_MASK)
+
+#define DP_IS_FREE(flags) (((flags) & DP_FLAGS_SIZE_MASK) == 0)
+#define DP_IS_USED(flags) ((flags) & DP_FLAGS_SIZE_MASK)
+
+#define DP_DEFRAG_NONE   0x0
+#define DP_DEFRAG_ALL    0x1
+#define DP_DEFRAG_TO_FIT 0x2
+
+/**
+ * Free list entry
+ *
+ * Each entry includes an index in to the dpool entry array
+ * and the size of dpool array entry.
+ */
+struct dpool_free_list_entry {
+	/*
+	 * Index in to dpool entry array
+	 */
+	uint32_t index;
+	/*
+	 * The size of the entry in the dpool entry array
+	 */
+	uint32_t size;
+};
+
+/**
+ * Free list
+ *
+ * Used internally to record free entries in the dpool entry array.
+ * Each entry represents a single or multiple contiguious entries
+ * in the dpool entry array.
+ *
+ * Used only during the defrag operation.
+ */
+struct dpool_free_list {
+	/*
+	 * Number of entries in the free list
+	 */
+	uint32_t size;
+	/*
+	 * List of unused entries in the dpool entry array
+	 */
+	struct dpool_free_list_entry entry[DP_MAX_FREE_SIZE];
+};
+
+/**
+ * Adjacent list entry
+ *
+ * Each entry includes and index in to the dpool entry array,
+ * the size of the entry and the counts of free entries to the
+ * right and left off that entry.
+ */
+struct dpool_adj_list_entry {
+	/*
+	 * Index in to dpool entry array
+	 */
+	uint32_t index;
+	/*
+	 * The size of the entry in the dpool entry array
+	 */
+	uint32_t size;
+	/*
+	 * Number of free entries directly to the  left of
+	 * this entry
+	 */
+	uint32_t left;
+	/*
+	 * Number of free entries directly to the right of
+	 * this entry
+	 */
+	uint32_t right;
+};
+
+/**
+ * Adjacent list
+ *
+ * A list of references to entries in the dpool entry array that
+ * have free entries to the left and right. Since we pack to the
+ * left entries will always have a non zero left cout.
+ *
+ * Used only during the defrag operation.
+ */
+struct dpool_adj_list {
+	/*
+	 * Number of entries in the adj list
+	 */
+	uint32_t size;
+	/*
+	 * List of entries in the dpool entry array that have
+	 * free entries directly to their left and right.
+	 */
+	struct dpool_adj_list_entry entry[DP_MAX_FREE_SIZE];
+};
+
+/**
+ * Dpool entry
+ *
+ * Each entry includes flags and the FW index.
+ */
+struct dpool_entry {
+	uint32_t flags;
+	uint32_t index;
+	uint64_t entry_data;
+};
+
+/**
+ * Dpool
+ *
+ * Used to manage resource pool. Includes the start FW index, the
+ * size of the entry array and the entry array it's self.
+ */
+struct dpool {
+	uint32_t start_index;
+	uint32_t size;
+	uint8_t  max_alloc_size;
+	void *user_data;
+	int (*move_callback)(void *user_data,
+			     uint64_t entry_data,
+			     uint32_t new_index);
+	struct dpool_entry *entry;
+};
+
+/**
+ * dpool_init
+ *
+ * Initialize the dpool
+ *
+ * [in] dpool
+ *      Pointer to a dpool structure that includes an entry field
+ *      that points to the entry array. The user is responsible for
+ *      allocating memory for the dpool struct and the entry array.
+ *
+ * [in] start_index
+ *      The base index to use.
+ *
+ * [in] size
+ *      The number of entries
+ *
+ * [in] max_alloc_size
+ *      The number of entries
+ *
+ * [in] user_data
+ *      Pointer to user data. Will be passed in callbacks.
+ *
+ * [in] move_callback
+ *      Pointer to move EM entry callback.
+ *
+ * Return
+ *      -  0 on success
+ *      - -1 on failure
+ *
+ */
+int dpool_init(struct dpool *dpool,
+	       uint32_t start_index,
+	       uint32_t size,
+	       uint8_t max_alloc_size,
+	       void *user_data,
+	       int (*move_callback)(void *, uint64_t, uint32_t));
+
+/**
+ * dpool_alloc
+ *
+ * Request a FW index of size and if necessary de-fragment the dpool
+ * array.
+ *
+ * [i] dpool
+ *     The dpool
+ *
+ * [i] size
+ *     The size of the requested allocation.
+ *
+ * [i] defrag
+ *     Operation to apply when there is insufficient space:
+ *
+ *     DP_DEFRAG_NONE   (0x0) - Don't do anything.
+ *     DP_DEFRAG_ALL    (0x1) - Defrag until there is nothing left
+ *                              to defrag.
+ *     DP_DEFRAG_TO_FIT (0x2) - Defrag until there is just enough space
+ *                              to insert the requested allocation.
+ *
+ * Return
+ *      - FW index on success
+ *      - DP_INVALID_INDEX on failure
+ *
+ */
+uint32_t dpool_alloc(struct dpool *dpool,
+		     uint32_t size,
+		     uint8_t defrag);
+
+/**
+ * dpool_set_entry_data
+ *
+ * Set the entry data field. This will be passed to callbacks.
+ *
+ * [i] dpool
+ *     The dpool
+ *
+ * [i] index
+ *     FW index
+ *
+ * [i] entry_data
+ *     Entry data value
+ *
+ * Return
+ *      - FW index on success
+ *      - DP_INVALID_INDEX on failure
+ *
+ */
+int dpool_set_entry_data(struct dpool *dpool,
+			 uint32_t index,
+			 uint64_t entry_data);
+
+/**
+ * dpool_free
+ *
+ * Free allocated entry. The is responsible for the dpool and dpool
+ * entry array memory.
+ *
+ * [in] dpool
+ *      The pool
+ *
+ * [in] index
+ *      FW index to free up.
+ *
+ * Result
+ *      - 0  on success
+ *      - -1 on failure
+ *
+ */
+int dpool_free(struct dpool *dpool,
+	       uint32_t index);
+
+/**
+ * dpool_free_all
+ *
+ * Free all entries.
+ *
+ * [in] dpool
+ *      The pool
+ *
+ * Result
+ *      - 0  on success
+ *      - -1 on failure
+ *
+ */
+void dpool_free_all(struct dpool *dpool);
+
+/**
+ * dpool_dump
+ *
+ * Debug/util function to dump the dpool array.
+ *
+ * [in] dpool
+ *      The pool
+ *
+ */
+void dpool_dump(struct dpool *dpool);
+
+/**
+ * dpool_defrag
+ *
+ * De-fragment the dpool array and apply the specified defrag stratagy.
+ *
+ * [in] dpool
+ *      The dpool
+ *
+ * [in] entry_size
+ *      If using the DP_DEFRAG_TO_FIT stratagy defrag will stop when there's
+ *      at least entry_size space available.
+ *
+ * [i] defrag
+ *     Defrag stratagy:
+ *
+ *     DP_DEFRAG_ALL    (0x1) - Defrag until there is nothing left
+ *                              to defrag.
+ *     DP_DEFRAG_TO_FIT (0x2) - Defrag until there is just enough space
+ *                              to insert the requested allocation.
+ *
+ * Return
+ *      < 0 - on failure
+ *      > 0 - The size of the largest free space
+ */
+int dpool_defrag(struct dpool *dpool,
+		 uint32_t entry_size,
+		 uint8_t defrag);
+
+#endif /* _DPOOL_H_ */
diff --git a/drivers/net/bnxt/tf_core/meson.build b/drivers/net/bnxt/tf_core/meson.build
index 2c02214d83..3a91f04bc0 100644
--- a/drivers/net/bnxt/tf_core/meson.build
+++ b/drivers/net/bnxt/tf_core/meson.build
@@ -10,6 +10,7 @@ sources += files(
         'tf_core.c',
         'bitalloc.c',
         'tf_msg.c',
+	'dpool.c',
         'rand.c',
         'stack.c',
         'tf_em_common.c',
diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h
index 4440d60fe5..08a083077c 100644
--- a/drivers/net/bnxt/tf_core/tf_core.h
+++ b/drivers/net/bnxt/tf_core/tf_core.h
@@ -1953,6 +1953,48 @@ struct tf_delete_em_entry_parms {
 	 */
 	uint64_t flow_handle;
 };
+/**
+ * tf_move_em_entry parameter definition
+ */
+struct tf_move_em_entry_parms {
+	/**
+	 * [in] receive or transmit direction
+	 */
+	enum tf_dir dir;
+	/**
+	 * [in] internal or external
+	 */
+	enum tf_mem mem;
+	/**
+	 * [in] ID of table scope to use (external only)
+	 */
+	uint32_t tbl_scope_id;
+	/**
+	 * [in] ID of table interface to use (SR2 only)
+	 */
+	uint32_t tbl_if_id;
+	/**
+	 * [in] epoch group IDs of entry to delete
+	 * 2 element array with 2 ids. (SR2 only)
+	 */
+	uint16_t *epochs;
+	/**
+	 * [out] The index of the entry
+	 */
+	uint16_t index;
+	/**
+	 * [in] External memory channel type to use
+	 */
+	enum tf_ext_mem_chan_type chan_type;
+	/**
+	 * [in] The index of the new EM record
+	 */
+	uint32_t new_index;
+	/**
+	 * [in] structure containing flow delete handle information
+	 */
+	uint64_t flow_handle;
+};
 /**
  * tf_search_em_entry parameter definition
  */
diff --git a/drivers/net/bnxt/tf_core/tf_device.h b/drivers/net/bnxt/tf_core/tf_device.h
index 16c2fe0f64..31806bb289 100644
--- a/drivers/net/bnxt/tf_core/tf_device.h
+++ b/drivers/net/bnxt/tf_core/tf_device.h
@@ -611,6 +611,22 @@ struct tf_dev_ops {
 	int (*tf_dev_delete_int_em_entry)(struct tf *tfp,
 					  struct tf_delete_em_entry_parms *parms);
 
+	/**
+	 * Move EM hash entry API
+	 *
+	 * [in] tfp
+	 *   Pointer to TF handle
+	 *
+	 * [in] parms
+	 *   Pointer to E/EM move parameters
+	 *
+	 *    returns:
+	 *    0       - Success
+	 *    -EINVAL - Error
+	 */
+	int (*tf_dev_move_int_em_entry)(struct tf *tfp,
+					struct tf_move_em_entry_parms *parms);
+
 	/**
 	 * Insert EEM hash entry API
 	 *
@@ -661,6 +677,24 @@ struct tf_dev_ops {
 	int (*tf_dev_get_em_resc_info)(struct tf *tfp,
 				       struct tf_em_resource_info *parms);
 
+	/**
+	 * Move EEM hash entry API
+	 *
+	 *   Pointer to E/EM move parameters
+	 *
+	 * [in] tfp
+	 *   Pointer to TF handle
+	 *
+	 * [in] parms
+	 *   Pointer to em info
+	 *
+	 *    returns:
+	 *    0       - Success
+	 *    -EINVAL - Error
+	 */
+	int (*tf_dev_move_ext_em_entry)(struct tf *tfp,
+					struct tf_move_em_entry_parms *parms);
+
 	/**
 	 * Allocate EEM table scope
 	 *
diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c
index c2bc283220..7917c9613a 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p58.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p58.c
@@ -295,6 +295,11 @@ const struct tf_dev_ops tf_dev_ops_p58 = {
 	.tf_dev_get_tcam_resc_info = tf_tcam_get_resc_info,
 	.tf_dev_insert_int_em_entry = tf_em_hash_insert_int_entry,
 	.tf_dev_delete_int_em_entry = tf_em_hash_delete_int_entry,
+#if (TF_EM_ALLOC == 1)
+	.tf_dev_move_int_em_entry = tf_em_move_int_entry,
+#else
+	.tf_dev_move_int_em_entry = NULL,
+#endif
 	.tf_dev_insert_ext_em_entry = NULL,
 	.tf_dev_delete_ext_em_entry = NULL,
 	.tf_dev_get_em_resc_info = tf_em_get_resc_info,
diff --git a/drivers/net/bnxt/tf_core/tf_em.h b/drivers/net/bnxt/tf_core/tf_em.h
index 60d90e28de..9d168c3c7f 100644
--- a/drivers/net/bnxt/tf_core/tf_em.h
+++ b/drivers/net/bnxt/tf_core/tf_em.h
@@ -13,6 +13,16 @@
 
 #include "hcapi_cfa_defs.h"
 
+/**
+ * TF_EM_ALLOC
+ *
+ * 0: Use stack allocator with fixed sized entries
+ *    (default).
+ * 1: Use dpool allocator with variable size
+ *    entries.
+ */
+#define TF_EM_ALLOC 0
+
 #define TF_EM_MIN_ENTRIES     (1 << 15) /* 32K */
 #define TF_EM_MAX_ENTRIES     (1 << 27) /* 128M */
 
@@ -243,6 +253,22 @@ int tf_em_hash_insert_int_entry(struct tf *tfp,
 int tf_em_hash_delete_int_entry(struct tf *tfp,
 				struct tf_delete_em_entry_parms *parms);
 
+/**
+ * Move record from internal EM table
+ *
+ * [in] tfp
+ *   Pointer to TruFlow handle
+ *
+ * [in] parms
+ *   Pointer to input parameters
+ *
+ * Returns:
+ *   0       - Success
+ *   -EINVAL - Parameter error
+ */
+int tf_em_move_int_entry(struct tf *tfp,
+			 struct tf_move_em_entry_parms *parms);
+
 /**
  * Insert record in to external EEM table
  *
diff --git a/drivers/net/bnxt/tf_core/tf_em_hash_internal.c b/drivers/net/bnxt/tf_core/tf_em_hash_internal.c
index f6c9772b44..098e8af07e 100644
--- a/drivers/net/bnxt/tf_core/tf_em_hash_internal.c
+++ b/drivers/net/bnxt/tf_core/tf_em_hash_internal.c
@@ -22,7 +22,9 @@
 /**
  * EM Pool
  */
-extern struct stack em_pool[TF_DIR_MAX];
+#if (TF_EM_ALLOC == 1)
+#include "dpool.h"
+#endif
 
 /**
  * Insert EM internal entry API
@@ -39,7 +41,11 @@ tf_em_hash_insert_int_entry(struct tf *tfp,
 	uint16_t rptr_index = 0;
 	uint8_t rptr_entry = 0;
 	uint8_t num_of_entries = 0;
-	struct stack *pool = &em_pool[parms->dir];
+#if (TF_EM_ALLOC == 1)
+	struct dpool *pool;
+#else
+	struct stack *pool;
+#endif
 	uint32_t index;
 	uint32_t key0_hash;
 	uint32_t key1_hash;
@@ -56,7 +62,20 @@ tf_em_hash_insert_int_entry(struct tf *tfp,
 	rc = tf_session_get_device(tfs, &dev);
 	if (rc)
 		return rc;
+#if (TF_EM_ALLOC == 1)
+	pool = (struct dpool *)tfs->em_pool[parms->dir];
+	index = dpool_alloc(pool,
+			    parms->em_record_sz_in_bits / 128,
+			    DP_DEFRAG_TO_FIT);
 
+	if (index == DP_INVALID_INDEX) {
+		PMD_DRV_LOG(ERR,
+			    "%s, EM entry index allocation failed\n",
+			    tf_dir_2_str(parms->dir));
+		return -1;
+	}
+#else
+	pool = (struct stack *)tfs->em_pool[parms->dir];
 	rc = stack_pop(pool, &index);
 	if (rc) {
 		PMD_DRV_LOG(ERR,
@@ -64,6 +83,7 @@ tf_em_hash_insert_int_entry(struct tf *tfp,
 			    tf_dir_2_str(parms->dir));
 		return rc;
 	}
+#endif
 
 	if (dev->ops->tf_dev_cfa_key_hash == NULL)
 		return -EINVAL;
@@ -83,19 +103,14 @@ tf_em_hash_insert_int_entry(struct tf *tfp,
 						  &num_of_entries);
 	if (rc) {
 		/* Free the allocated index before returning */
+#if (TF_EM_ALLOC == 1)
+		dpool_free(pool, index);
+#else
 		stack_push(pool, index);
+#endif
 		return -1;
 	}
 
-	PMD_DRV_LOG
-		  (DEBUG,
-		   "%s, Internal entry @ Index:%d rptr_index:0x%x rptr_entry:0x%x num_of_entries:%d\n",
-		   tf_dir_2_str(parms->dir),
-		   index,
-		   rptr_index,
-		   rptr_entry,
-		   num_of_entries);
-
 	TF_SET_GFID(gfid,
 		    ((rptr_index << TF_EM_INTERNAL_INDEX_SHIFT) |
 		     rptr_entry),
@@ -113,6 +128,9 @@ tf_em_hash_insert_int_entry(struct tf *tfp,
 				     rptr_index,
 				     rptr_entry,
 				     0);
+#if (TF_EM_ALLOC == 1)
+	dpool_set_entry_data(pool, index, parms->flow_handle);
+#endif
 	return 0;
 }
 
@@ -127,13 +145,71 @@ tf_em_hash_delete_int_entry(struct tf *tfp,
 			    struct tf_delete_em_entry_parms *parms)
 {
 	int rc = 0;
-	struct stack *pool = &em_pool[parms->dir];
+	struct tf_session *tfs;
+#if (TF_EM_ALLOC == 1)
+	struct dpool *pool;
+#else
+	struct stack *pool;
+#endif
+	/* Retrieve the session information */
+	rc = tf_session_get_session(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
 
 	rc = tf_msg_delete_em_entry(tfp, parms);
 
 	/* Return resource to pool */
-	if (rc == 0)
+	if (rc == 0) {
+#if (TF_EM_ALLOC == 1)
+		pool = (struct dpool *)tfs->em_pool[parms->dir];
+		dpool_free(pool, parms->index);
+#else
+		pool = (struct stack *)tfs->em_pool[parms->dir];
 		stack_push(pool, parms->index);
+#endif
+	}
+
+	return rc;
+}
+
+#if (TF_EM_ALLOC == 1)
+/** Move EM internal entry API
+ *
+ * returns:
+ * 0
+ * -EINVAL
+ */
+int
+tf_em_move_int_entry(struct tf *tfp,
+		     struct tf_move_em_entry_parms *parms)
+{
+	int rc = 0;
+	struct dpool *pool;
+	struct tf_session *tfs;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	rc = tf_msg_move_em_entry(tfp, parms);
+
+	/* Return resource to pool */
+	if (rc == 0) {
+		pool = (struct dpool *)tfs->em_pool[parms->dir];
+		dpool_free(pool, parms->index);
+	}
 
 	return rc;
 }
+#endif
diff --git a/drivers/net/bnxt/tf_core/tf_em_internal.c b/drivers/net/bnxt/tf_core/tf_em_internal.c
index e373a9b029..eec15b89bc 100644
--- a/drivers/net/bnxt/tf_core/tf_em_internal.c
+++ b/drivers/net/bnxt/tf_core/tf_em_internal.c
@@ -15,7 +15,6 @@
 #include "tf_msg.h"
 #include "tfp.h"
 #include "tf_ext_flow_handle.h"
-
 #include "bnxt.h"
 
 #define TF_EM_DB_EM_REC 0
@@ -23,7 +22,9 @@
 /**
  * EM Pool
  */
-struct stack em_pool[TF_DIR_MAX];
+#if (TF_EM_ALLOC == 1)
+#include "dpool.h"
+#else
 
 /**
  * Create EM Tbl pool of memory indexes.
@@ -41,14 +42,35 @@ struct stack em_pool[TF_DIR_MAX];
  *          - Failure, entry not allocated, out of resources
  */
 static int
-tf_create_em_pool(enum tf_dir dir,
+tf_create_em_pool(struct tf_session *tfs,
+		  enum tf_dir dir,
 		  uint32_t num_entries,
 		  uint32_t start)
 {
 	struct tfp_calloc_parms parms;
 	uint32_t i, j;
 	int rc = 0;
-	struct stack *pool = &em_pool[dir];
+	struct stack *pool;
+
+	/*
+	 * Allocate stack pool
+	 */
+	parms.nitems = 1;
+	parms.size = sizeof(struct stack);
+	parms.alignment = 0;
+
+	rc = tfp_calloc(&parms);
+
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s, EM stack allocation failure %s\n",
+			    tf_dir_2_str(dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	pool = (struct stack *)parms.mem_va;
+	tfs->em_pool[dir] = (void *)pool;
 
 	/* Assumes that num_entries has been checked before we get here */
 	parms.nitems = num_entries / TF_SESSION_EM_ENTRY_SIZE;
@@ -108,6 +130,8 @@ tf_create_em_pool(enum tf_dir dir,
 	return 0;
 cleanup:
 	tfp_free((void *)parms.mem_va);
+	tfp_free((void *)tfs->em_pool[dir]);
+	tfs->em_pool[dir] = NULL;
 	return rc;
 }
 
@@ -120,16 +144,23 @@ tf_create_em_pool(enum tf_dir dir,
  * Return:
  */
 static void
-tf_free_em_pool(enum tf_dir dir)
+tf_free_em_pool(struct tf_session *tfs,
+		enum tf_dir dir)
 {
-	struct stack *pool = &em_pool[dir];
+	struct stack *pool = (struct stack *)tfs->em_pool[dir];
 	uint32_t *ptr;
 
-	ptr = stack_items(pool);
+	if (pool != NULL) {
+		ptr = stack_items(pool);
+
+		if (ptr != NULL)
+			tfp_free(ptr);
 
-	if (ptr != NULL)
-		tfp_free(ptr);
+		tfp_free(pool);
+		tfs->em_pool[dir] = NULL;
+	}
 }
+#endif /* TF_EM_ALLOC != 1 */
 
 /**
  * Insert EM internal entry API
@@ -146,17 +177,44 @@ tf_em_insert_int_entry(struct tf *tfp,
 	uint16_t rptr_index = 0;
 	uint8_t rptr_entry = 0;
 	uint8_t num_of_entries = 0;
-	struct stack *pool = &em_pool[parms->dir];
+	struct tf_session *tfs;
+#if (TF_EM_ALLOC == 1)
+	struct dpool *pool;
+#else
+	struct stack *pool;
+#endif
 	uint32_t index;
 
-	rc = stack_pop(pool, &index);
+	/* Retrieve the session information */
+	rc = tf_session_get_session(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
 
+#if (TF_EM_ALLOC == 1)
+	pool = (struct dpool *)tfs->em_pool[parms->dir];
+	index = dpool_alloc(pool, TF_SESSION_EM_ENTRY_SIZE, 0);
+	if (index == DP_INVALID_INDEX) {
+		PMD_DRV_LOG(ERR,
+			    "%s, EM entry index allocation failed\n",
+			    tf_dir_2_str(parms->dir));
+		return -1;
+	}
+#else
+	pool = (struct stack *)tfs->em_pool[parms->dir];
+	rc = stack_pop(pool, &index);
 	if (rc) {
 		PMD_DRV_LOG(ERR,
 			    "%s, EM entry index allocation failed\n",
 			    tf_dir_2_str(parms->dir));
 		return rc;
 	}
+#endif
+
 
 	rptr_index = index;
 	rc = tf_msg_insert_em_internal_entry(tfp,
@@ -166,19 +224,13 @@ tf_em_insert_int_entry(struct tf *tfp,
 					     &num_of_entries);
 	if (rc) {
 		/* Free the allocated index before returning */
+#if (TF_EM_ALLOC == 1)
+		dpool_free(pool, index);
+#else
 		stack_push(pool, index);
+#endif
 		return -1;
 	}
-
-	PMD_DRV_LOG
-		  (DEBUG,
-		   "%s, Internal entry @ Index:%d rptr_index:0x%x rptr_entry:0x%x num_of_entries:%d\n",
-		   tf_dir_2_str(parms->dir),
-		   index,
-		   rptr_index,
-		   rptr_entry,
-		   num_of_entries);
-
 	TF_SET_GFID(gfid,
 		    ((rptr_index << TF_EM_INTERNAL_INDEX_SHIFT) |
 		     rptr_entry),
@@ -211,16 +263,86 @@ tf_em_delete_int_entry(struct tf *tfp,
 		       struct tf_delete_em_entry_parms *parms)
 {
 	int rc = 0;
-	struct stack *pool = &em_pool[parms->dir];
+	struct tf_session *tfs;
+#if (TF_EM_ALLOC == 1)
+	struct dpool *pool;
+#else
+	struct stack *pool;
+#endif
+	/* Retrieve the session information */
+	rc = tf_session_get_session(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
 
 	rc = tf_msg_delete_em_entry(tfp, parms);
 
 	/* Return resource to pool */
-	if (rc == 0)
+	if (rc == 0) {
+#if (TF_EM_ALLOC == 1)
+		pool = (struct dpool *)tfs->em_pool[parms->dir];
+		dpool_free(pool, parms->index);
+#else
+		pool = (struct stack *)tfs->em_pool[parms->dir];
 		stack_push(pool, parms->index);
+#endif
+	}
+
+	return rc;
+}
+
+#if (TF_EM_ALLOC == 1)
+static int
+tf_em_move_callback(void *user_data,
+		    uint64_t entry_data,
+		    uint32_t new_index)
+{
+	int rc;
+	struct tf *tfp = (struct tf *)user_data;
+	struct tf_move_em_entry_parms parms;
+	struct tf_dev_info     *dev;
+	struct tf_session      *tfs;
+
+	memset(&parms, 0, sizeof(parms));
+
+	parms.tbl_scope_id = 0;
+	parms.flow_handle  = entry_data;
+	parms.new_index    = new_index;
+	TF_GET_DIR_FROM_FLOW_ID(entry_data, parms.dir);
+	parms.mem          = TF_MEM_INTERNAL;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(parms.dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup device, rc:%s\n",
+			    tf_dir_2_str(parms.dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	if (dev->ops->tf_dev_move_int_em_entry != NULL)
+		rc = dev->ops->tf_dev_move_int_em_entry(tfp, &parms);
+	else
+		rc = -EOPNOTSUPP;
 
 	return rc;
 }
+#endif
 
 int
 tf_em_int_bind(struct tf *tfp,
@@ -311,14 +433,49 @@ tf_em_int_bind(struct tf *tfp,
 					    tf_dir_2_str(i));
 				return rc;
 			}
+#if (TF_EM_ALLOC == 1)
+			/*
+			 * Allocate stack pool
+			 */
+			cparms.nitems = 1;
+			cparms.size = sizeof(struct dpool);
+			cparms.alignment = 0;
+
+			rc = tfp_calloc(&cparms);
 
-			rc = tf_create_em_pool(i,
-					       iparms.info->entry.stride,
-					       iparms.info->entry.start);
+			if (rc) {
+				TFP_DRV_LOG(ERR,
+					 "%s, EM stack allocation failure %s\n",
+					 tf_dir_2_str(i),
+					 strerror(-rc));
+				return rc;
+			}
+
+			tfs->em_pool[i] = (struct dpool *)cparms.mem_va;
+
+			rc = dpool_init(tfs->em_pool[i],
+					iparms.info->entry.start,
+					iparms.info->entry.stride,
+					7,
+					(void *)tfp,
+					tf_em_move_callback);
+#else
+			rc = tf_create_em_pool(tfs,
+				       i,
+				       iparms.info->entry.stride,
+				       iparms.info->entry.start);
+#endif
 			/* Logging handled in tf_create_em_pool */
 			if (rc)
 				return rc;
 		}
+
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "%s: EM pool init failed\n",
+				    tf_dir_2_str(i));
+			return rc;
+		}
 	}
 
 	return 0;
@@ -343,7 +500,11 @@ tf_em_int_unbind(struct tf *tfp)
 
 	if (!tf_session_is_shared_session(tfs)) {
 		for (i = 0; i < TF_DIR_MAX; i++)
-			tf_free_em_pool(i);
+#if (TF_EM_ALLOC == 1)
+			dpool_free_all(tfs->em_pool[i]);
+#else
+		tf_free_em_pool(tfs, i);
+#endif
 	}
 
 	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_EM, &em_db_ptr);
diff --git a/drivers/net/bnxt/tf_core/tf_msg.c b/drivers/net/bnxt/tf_core/tf_msg.c
index 4a840f3473..2ee8a1e8a9 100644
--- a/drivers/net/bnxt/tf_core/tf_msg.c
+++ b/drivers/net/bnxt/tf_core/tf_msg.c
@@ -1004,6 +1004,75 @@ tf_msg_delete_em_entry(struct tf *tfp,
 	return 0;
 }
 
+int
+tf_msg_move_em_entry(struct tf *tfp,
+		     struct tf_move_em_entry_parms *em_parms)
+{
+	int rc;
+	struct tfp_send_msg_parms parms = { 0 };
+	struct hwrm_tf_em_move_input req = { 0 };
+	struct hwrm_tf_em_move_output resp = { 0 };
+	uint16_t flags;
+	uint8_t fw_session_id;
+	struct tf_dev_info *dev;
+	struct tf_session *tfs;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(em_parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup device, rc:%s\n",
+			    tf_dir_2_str(em_parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Unable to lookup FW id, rc:%s\n",
+			    tf_dir_2_str(em_parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Populate the request */
+	req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
+
+	flags = (em_parms->dir == TF_DIR_TX ?
+		 HWRM_TF_EM_DELETE_INPUT_FLAGS_DIR_TX :
+		 HWRM_TF_EM_DELETE_INPUT_FLAGS_DIR_RX);
+	req.flags = tfp_cpu_to_le_16(flags);
+	req.flow_handle = tfp_cpu_to_le_64(em_parms->flow_handle);
+	req.new_index = tfp_cpu_to_le_32(em_parms->new_index);
+
+	parms.tf_type = HWRM_TF_EM_MOVE;
+	parms.req_data = (uint32_t *)&req;
+	parms.req_size = sizeof(req);
+	parms.resp_data = (uint32_t *)&resp;
+	parms.resp_size = sizeof(resp);
+	parms.mailbox = dev->ops->tf_dev_get_mailbox();
+
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+				 &parms);
+	if (rc)
+		return rc;
+
+	em_parms->index = tfp_le_to_cpu_16(resp.em_index);
+
+	return 0;
+}
+
 int tf_msg_ext_em_ctxt_mem_alloc(struct tf *tfp,
 				struct hcapi_cfa_em_table *tbl,
 				uint64_t *dma_addr,
diff --git a/drivers/net/bnxt/tf_core/tf_msg.h b/drivers/net/bnxt/tf_core/tf_msg.h
index 5ecaf9e7e7..e8662fef0e 100644
--- a/drivers/net/bnxt/tf_core/tf_msg.h
+++ b/drivers/net/bnxt/tf_core/tf_msg.h
@@ -315,6 +315,21 @@ tf_msg_hash_insert_em_internal_entry(struct tf *tfp,
 int tf_msg_delete_em_entry(struct tf *tfp,
 			   struct tf_delete_em_entry_parms *em_parms);
 
+/**
+ * Sends EM internal move request to Firmware
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [in] em_parms
+ *   Pointer to em move parameters
+ *
+ * Returns:
+ *   0 on Success else internal Truflow error
+ */
+int tf_msg_move_em_entry(struct tf *tfp,
+			 struct tf_move_em_entry_parms *em_parms);
+
 /**
  * Sends Ext EM mem allocation request to Firmware
  *
diff --git a/drivers/net/bnxt/tf_core/tf_session.h b/drivers/net/bnxt/tf_core/tf_session.h
index 0b8f63c374..e2cebd20a1 100644
--- a/drivers/net/bnxt/tf_core/tf_session.h
+++ b/drivers/net/bnxt/tf_core/tf_session.h
@@ -159,6 +159,11 @@ struct tf_session {
 	 * the pointer to the parent bp struct
 	 */
 	void *bp;
+
+	/**
+	 * EM allocator for session
+	 */
+	void *em_pool[TF_DIR_MAX];
 };
 
 /**
-- 
2.17.1


^ permalink raw reply	[flat|nested] 129+ messages in thread

* [dpdk-dev] [PATCH 16/58] net/bnxt: update shared session functionality
  2021-05-30  8:58 [dpdk-dev] [PATCH 00/58] enhancements to host based flow table management Venkat Duvvuru
                   ` (14 preceding siblings ...)
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 15/58] net/bnxt: add dpool allocator for EM allocation Venkat Duvvuru
@ 2021-05-30  8:58 ` Venkat Duvvuru
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 17/58] net/bnxt: modify resource reservation strategy Venkat Duvvuru
                   ` (42 subsequent siblings)
  58 siblings, 0 replies; 129+ messages in thread
From: Venkat Duvvuru @ 2021-05-30  8:58 UTC (permalink / raw)
  To: dev; +Cc: Jay Ding, Randy Schacher, Venkat Duvvuru

From: Jay Ding <jay.ding@broadcom.com>

- Distinguish the shared session on host side using PCI address
- One session could be shared by multiple interfaces.

Signed-off-by: Jay Ding <jay.ding@broadcom.com>
Signed-off-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Farah Smith <farah.smith@broadcom.com>
---
 drivers/net/bnxt/tf_core/tf_core.c        |  9 ---
 drivers/net/bnxt/tf_core/tf_core.h        |  4 ++
 drivers/net/bnxt/tf_core/tf_device.c      | 28 +++++----
 drivers/net/bnxt/tf_core/tf_device_p58.c  |  7 ++-
 drivers/net/bnxt/tf_core/tf_em_internal.c | 23 ++++----
 drivers/net/bnxt/tf_core/tf_identifier.c  | 15 ++---
 drivers/net/bnxt/tf_core/tf_msg.c         | 69 +++++++++++++----------
 drivers/net/bnxt/tf_core/tf_session.c     | 13 ++++-
 drivers/net/bnxt/tf_core/tf_session.h     |  9 +--
 drivers/net/bnxt/tf_core/tf_tbl.c         | 57 ++++++++++++++++---
 drivers/net/bnxt/tf_core/tf_tcam.c        | 15 ++---
 drivers/net/bnxt/tf_core/tfp.c            |  4 +-
 12 files changed, 153 insertions(+), 100 deletions(-)

diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c
index 69f5c10293..945e54bfdd 100644
--- a/drivers/net/bnxt/tf_core/tf_core.c
+++ b/drivers/net/bnxt/tf_core/tf_core.c
@@ -27,8 +27,6 @@ tf_open_session(struct tf *tfp,
 	int rc;
 	unsigned int domain, bus, slot, device;
 	struct tf_session_open_session_parms oparms;
-	int name_len;
-	char *name;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -71,13 +69,6 @@ tf_open_session(struct tf *tfp,
 		}
 	}
 
-	name_len = strlen(parms->ctrl_chan_name);
-	name = &parms->ctrl_chan_name[name_len - strlen("tf_shared")];
-	if (!strncmp(name, "tf_shared", strlen("tf_shared"))) {
-		memset(parms->ctrl_chan_name, 0, strlen(parms->ctrl_chan_name));
-		strcpy(parms->ctrl_chan_name, "tf_share");
-	}
-
 	parms->session_id.internal.domain = domain;
 	parms->session_id.internal.bus = bus;
 	parms->session_id.internal.device = device;
diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h
index 08a083077c..3d14dc5391 100644
--- a/drivers/net/bnxt/tf_core/tf_core.h
+++ b/drivers/net/bnxt/tf_core/tf_core.h
@@ -458,6 +458,10 @@ struct tf_session_info {
  */
 struct tf {
 	struct tf_session_info *session;
+	/**
+	 * the pointer to the parent bp struct
+	 */
+	void *bp;
 };
 
 /**
diff --git a/drivers/net/bnxt/tf_core/tf_device.c b/drivers/net/bnxt/tf_core/tf_device.c
index fed4156200..97ae73fa5a 100644
--- a/drivers/net/bnxt/tf_core/tf_device.c
+++ b/drivers/net/bnxt/tf_core/tf_device.c
@@ -44,7 +44,11 @@ tf_dev_reservation_check(uint16_t count,
 		rm_num = (uint16_t *)reservations + i * count;
 		for (j = 0; j < count; j++) {
 			if ((cfg[j].cfg_type == TF_RM_ELEM_CFG_HCAPI ||
-			     cfg[j].cfg_type == TF_RM_ELEM_CFG_HCAPI_BA) &&
+			     cfg[j].cfg_type == TF_RM_ELEM_CFG_HCAPI_BA ||
+			     cfg[j].cfg_type ==
+				TF_RM_ELEM_CFG_HCAPI_BA_PARENT ||
+			     cfg[j].cfg_type ==
+				TF_RM_ELEM_CFG_HCAPI_BA_CHILD) &&
 			     rm_num[j] > 0)
 				cnt++;
 		}
@@ -263,49 +267,49 @@ tf_dev_unbind_p4(struct tf *tfp)
 	 */
 	rc = tf_tcam_unbind(tfp);
 	if (rc) {
-		TFP_DRV_LOG(ERR,
+		TFP_DRV_LOG(INFO,
 			    "Device unbind failed, TCAM\n");
 		fail = true;
 	}
 
 	rc = tf_ident_unbind(tfp);
 	if (rc) {
-		TFP_DRV_LOG(ERR,
+		TFP_DRV_LOG(INFO,
 			    "Device unbind failed, Identifier\n");
 		fail = true;
 	}
 
 	rc = tf_tbl_unbind(tfp);
 	if (rc) {
-		TFP_DRV_LOG(ERR,
+		TFP_DRV_LOG(INFO,
 			    "Device unbind failed, Table Type\n");
 		fail = true;
 	}
 
 	rc = tf_em_ext_common_unbind(tfp);
 	if (rc) {
-		TFP_DRV_LOG(ERR,
+		TFP_DRV_LOG(INFO,
 			    "Device unbind failed, EEM\n");
 		fail = true;
 	}
 
 	rc = tf_em_int_unbind(tfp);
 	if (rc) {
-		TFP_DRV_LOG(ERR,
+		TFP_DRV_LOG(INFO,
 			    "Device unbind failed, EM\n");
 		fail = true;
 	}
 
 	rc = tf_if_tbl_unbind(tfp);
 	if (rc) {
-		TFP_DRV_LOG(ERR,
+		TFP_DRV_LOG(INFO,
 			    "Device unbind failed, IF Table Type\n");
 		fail = true;
 	}
 
 	rc = tf_global_cfg_unbind(tfp);
 	if (rc) {
-		TFP_DRV_LOG(ERR,
+		TFP_DRV_LOG(INFO,
 			    "Device unbind failed, Global Cfg Type\n");
 		fail = true;
 	}
@@ -515,28 +519,28 @@ tf_dev_unbind_p58(struct tf *tfp)
 	 */
 	rc = tf_tcam_unbind(tfp);
 	if (rc) {
-		TFP_DRV_LOG(ERR,
+		TFP_DRV_LOG(INFO,
 			    "Device unbind failed, TCAM\n");
 		fail = true;
 	}
 
 	rc = tf_ident_unbind(tfp);
 	if (rc) {
-		TFP_DRV_LOG(ERR,
+		TFP_DRV_LOG(INFO,
 			    "Device unbind failed, Identifier\n");
 		fail = true;
 	}
 
 	rc = tf_tbl_unbind(tfp);
 	if (rc) {
-		TFP_DRV_LOG(ERR,
+		TFP_DRV_LOG(INFO,
 			    "Device unbind failed, Table Type\n");
 		fail = true;
 	}
 
 	rc = tf_em_int_unbind(tfp);
 	if (rc) {
-		TFP_DRV_LOG(ERR,
+		TFP_DRV_LOG(INFO,
 			    "Device unbind failed, EM\n");
 		fail = true;
 	}
diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c
index 7917c9613a..ba82efdfe2 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p58.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p58.c
@@ -193,8 +193,11 @@ static int tf_dev_p58_get_sram_tbl_info(struct tf *tfp __rte_unused,
 	parms.hcapi_type = &hcapi_type;
 
 	rc = tf_rm_get_hcapi_type(&parms);
-	if (rc)
-		return rc;
+	if (rc) {
+		*base = 0;
+		*shift = 0;
+		return 0;
+	}
 
 	switch (hcapi_type) {
 	case CFA_RESOURCE_TYPE_P58_SRAM_BANK_0:
diff --git a/drivers/net/bnxt/tf_core/tf_em_internal.c b/drivers/net/bnxt/tf_core/tf_em_internal.c
index eec15b89bc..3b1e4e385d 100644
--- a/drivers/net/bnxt/tf_core/tf_em_internal.c
+++ b/drivers/net/bnxt/tf_core/tf_em_internal.c
@@ -509,21 +509,21 @@ tf_em_int_unbind(struct tf *tfp)
 
 	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_EM, &em_db_ptr);
 	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "Failed to get em_ext_db from session, rc:%s\n",
+		TFP_DRV_LOG(INFO,
+			    "Em_db is not initialized, rc:%s\n",
 			    strerror(-rc));
-		return rc;
+		return 0;
 	}
 	em_db = (struct em_rm_db *)em_db_ptr;
 
 	for (i = 0; i < TF_DIR_MAX; i++) {
+		if (em_db->em_db[i] == NULL)
+			continue;
 		fparms.dir = i;
 		fparms.rm_db = em_db->em_db[i];
-		if (em_db->em_db[i] != NULL) {
-			rc = tf_rm_free_db(tfp, &fparms);
-			if (rc)
-				return rc;
-		}
+		rc = tf_rm_free_db(tfp, &fparms);
+		if (rc)
+			return rc;
 
 		em_db->em_db[i] = NULL;
 	}
@@ -546,10 +546,9 @@ tf_em_get_resc_info(struct tf *tfp,
 
 	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_EM, &em_db_ptr);
 	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "Failed to get em_ext_db from session, rc:%s\n",
-			    strerror(-rc));
-		return rc;
+		TFP_DRV_LOG(INFO,
+			    "No resource allocated for em from session\n");
+		return 0;
 	}
 	em_db = (struct em_rm_db *)em_db_ptr;
 
diff --git a/drivers/net/bnxt/tf_core/tf_identifier.c b/drivers/net/bnxt/tf_core/tf_identifier.c
index 4063f3ba17..ebb975562d 100644
--- a/drivers/net/bnxt/tf_core/tf_identifier.c
+++ b/drivers/net/bnxt/tf_core/tf_identifier.c
@@ -119,14 +119,16 @@ tf_ident_unbind(struct tf *tfp)
 
 	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr);
 	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "Failed to get ident_db from session, rc:%s\n",
+		TFP_DRV_LOG(INFO,
+			    "Ident_db is not initialized, rc:%s\n",
 			    strerror(-rc));
-		return rc;
+		return 0;
 	}
 	ident_db = (struct ident_rm_db *)ident_db_ptr;
 
 	for (i = 0; i < TF_DIR_MAX; i++) {
+		if (ident_db->ident_db[i] == NULL)
+			continue;
 		fparms.rm_db = ident_db->ident_db[i];
 		fparms.dir = i;
 		rc = tf_rm_free_db(tfp, &fparms);
@@ -372,10 +374,9 @@ tf_ident_get_resc_info(struct tf *tfp,
 
 	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr);
 	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "Failed to get ident_db from session, rc:%s\n",
-			    strerror(-rc));
-		return rc;
+		TFP_DRV_LOG(INFO,
+			    "No resource allocated for ident from session\n");
+		return 0;
 	}
 	ident_db = (struct ident_rm_db *)ident_db_ptr;
 
diff --git a/drivers/net/bnxt/tf_core/tf_msg.c b/drivers/net/bnxt/tf_core/tf_msg.c
index 2ee8a1e8a9..18eea8338a 100644
--- a/drivers/net/bnxt/tf_core/tf_msg.c
+++ b/drivers/net/bnxt/tf_core/tf_msg.c
@@ -125,9 +125,16 @@ tf_msg_session_open(struct bnxt *bp,
 	struct hwrm_tf_session_open_input req = { 0 };
 	struct hwrm_tf_session_open_output resp = { 0 };
 	struct tfp_send_msg_parms parms = { 0 };
+	int name_len;
+	char *name;
 
 	/* Populate the request */
-	tfp_memcpy(&req.session_name, ctrl_chan_name, TF_SESSION_NAME_MAX);
+	name_len = strnlen(ctrl_chan_name, TF_SESSION_NAME_MAX);
+	name = &ctrl_chan_name[name_len - strlen("tf_shared")];
+	if (!strncmp(name, "tf_shared", strlen("tf_shared")))
+		tfp_memcpy(&req.session_name, name, strlen("tf_share"));
+	else
+		tfp_memcpy(&req.session_name, ctrl_chan_name, TF_SESSION_NAME_MAX);
 
 	parms.tf_type = HWRM_TF_SESSION_OPEN;
 	parms.req_data = (uint32_t *)&req;
@@ -201,7 +208,7 @@ tf_msg_session_client_register(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
 				 &parms);
 	if (rc)
 		return rc;
@@ -252,7 +259,7 @@ tf_msg_session_client_unregister(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
 				 &parms);
 
 	return rc;
@@ -296,7 +303,7 @@ tf_msg_session_close(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
 				 &parms);
 	return rc;
 }
@@ -348,7 +355,7 @@ tf_msg_session_qcfg(struct tf *tfp)
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
 				 &parms);
 	return rc;
 }
@@ -411,7 +418,7 @@ tf_msg_session_resc_qcaps(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp), &parms);
 	if (rc)
 		goto cleanup;
 
@@ -521,7 +528,7 @@ tf_msg_session_resc_alloc(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp), &parms);
 	if (rc)
 		goto cleanup;
 
@@ -628,7 +635,7 @@ tf_msg_session_resc_info(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp), &parms);
 	if (rc)
 		goto cleanup;
 
@@ -735,7 +742,7 @@ tf_msg_session_resc_flush(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp), &parms);
 
 	tf_msg_free_dma_buf(&resv_buf);
 
@@ -829,7 +836,7 @@ tf_msg_insert_em_internal_entry(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
 				 &parms);
 	if (rc)
 		return rc;
@@ -924,7 +931,7 @@ tf_msg_hash_insert_em_internal_entry(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
 				 &parms);
 	if (rc)
 		return rc;
@@ -994,7 +1001,7 @@ tf_msg_delete_em_entry(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
 				 &parms);
 	if (rc)
 		return rc;
@@ -1063,7 +1070,7 @@ tf_msg_move_em_entry(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
 				 &parms);
 	if (rc)
 		return rc;
@@ -1119,7 +1126,7 @@ int tf_msg_ext_em_ctxt_mem_alloc(struct tf *tfp,
 		parms.resp_data = (uint32_t *)&resp;
 		parms.resp_size = sizeof(resp);
 		parms.mailbox = dev->ops->tf_dev_get_mailbox();
-		rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
+		rc = tfp_send_msg_direct(tf_session_get_bp(tfp), &parms);
 		if (rc) {
 			TFP_DRV_LOG(ERR, "Failed ext_em_alloc error rc:%s\n",
 				strerror(-rc));
@@ -1179,7 +1186,7 @@ int tf_msg_ext_em_ctxt_mem_free(struct tf *tfp,
 	parms.resp_data = (uint32_t *)&resp;
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp), &parms);
 
 	return rc;
 }
@@ -1230,7 +1237,7 @@ tf_msg_em_mem_rgtr(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
 				 &parms);
 	if (rc)
 		return rc;
@@ -1282,7 +1289,7 @@ tf_msg_em_mem_unrgtr(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
 				 &parms);
 	return rc;
 }
@@ -1334,7 +1341,7 @@ tf_msg_em_qcaps(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
 				 &parms);
 	if (rc)
 		return rc;
@@ -1409,7 +1416,7 @@ tf_msg_em_cfg(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
 				 &parms);
 	return rc;
 }
@@ -1483,7 +1490,7 @@ tf_msg_ext_em_cfg(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
 				 &parms);
 	return rc;
 }
@@ -1533,7 +1540,7 @@ tf_msg_em_op(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
 				 &parms);
 	return rc;
 }
@@ -1611,7 +1618,7 @@ tf_msg_tcam_entry_set(struct tf *tfp,
 	mparms.resp_size = sizeof(resp);
 	mparms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
 				 &mparms);
 
 cleanup:
@@ -1664,7 +1671,7 @@ tf_msg_tcam_entry_get(struct tf *tfp,
 	mparms.resp_size = sizeof(resp);
 	mparms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
 				 &mparms);
 
 	if (rc != 0)
@@ -1735,7 +1742,7 @@ tf_msg_tcam_entry_free(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
 				 &parms);
 	return rc;
 }
@@ -1816,7 +1823,7 @@ tf_msg_set_tbl_entry(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
 				 &parms);
 	if (rc)
 		return rc;
@@ -1882,7 +1889,7 @@ tf_msg_get_tbl_entry(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
 				 &parms);
 	if (rc)
 		return rc;
@@ -1968,7 +1975,7 @@ tf_msg_get_global_cfg(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp), &parms);
 	if (rc != 0)
 		return rc;
 
@@ -2069,7 +2076,7 @@ tf_msg_set_global_cfg(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp), &parms);
 
 	if (rc != 0)
 		return rc;
@@ -2142,7 +2149,7 @@ tf_msg_bulk_get_tbl_entry(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
 				 &parms);
 	if (rc)
 		return rc;
@@ -2205,7 +2212,7 @@ tf_msg_get_if_tbl_entry(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp), &parms);
 
 	if (rc != 0)
 		return rc;
@@ -2262,7 +2269,7 @@ tf_msg_set_if_tbl_entry(struct tf *tfp,
 	parms.resp_size = sizeof(resp);
 	parms.mailbox = dev->ops->tf_dev_get_mailbox();
 
-	rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
+	rc = tfp_send_msg_direct(tf_session_get_bp(tfp), &parms);
 
 	if (rc != 0)
 		return rc;
diff --git a/drivers/net/bnxt/tf_core/tf_session.c b/drivers/net/bnxt/tf_core/tf_session.c
index 391d8786ab..93876d8e5d 100644
--- a/drivers/net/bnxt/tf_core/tf_session.c
+++ b/drivers/net/bnxt/tf_core/tf_session.c
@@ -59,6 +59,8 @@ tf_session_create(struct tf *tfp,
 	union tf_session_id *session_id;
 	struct tf_dev_info dev;
 	bool shared_session_creator;
+	int name_len;
+	char *name;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -140,7 +142,6 @@ tf_session_create(struct tf *tfp,
 	session_id->id = session->session_id.id;
 
 	session->shadow_copy = parms->open_cfg->shadow_copy;
-	session->bp = parms->open_cfg->bp;
 
 	/* Init session client list */
 	ll_init(&session->client_ll);
@@ -179,7 +180,12 @@ tf_session_create(struct tf *tfp,
 
 	/* Init session em_ext_db */
 	session->em_ext_db_handle = NULL;
-	if (!strcmp(parms->open_cfg->ctrl_chan_name, "tf_share"))
+
+	/* Populate the request */
+	name_len = strnlen(parms->open_cfg->ctrl_chan_name,
+			   TF_SESSION_NAME_MAX);
+	name = &parms->open_cfg->ctrl_chan_name[name_len - strlen("tf_shared")];
+	if (!strncmp(name, "tf_shared", strlen("tf_shared")))
 		session->shared_session = true;
 
 	if (session->shared_session && shared_session_creator) {
@@ -404,8 +410,9 @@ tf_session_open_session(struct tf *tfp,
 	int rc;
 	struct tf_session_client_create_parms scparms;
 
-	TF_CHECK_PARMS2(tfp, parms);
+	TF_CHECK_PARMS3(tfp, parms, parms->open_cfg->bp);
 
+	tfp->bp = parms->open_cfg->bp;
 	/* Decide if we're creating a new session or session client */
 	if (tfp->session == NULL) {
 		rc = tf_session_create(tfp, parms);
diff --git a/drivers/net/bnxt/tf_core/tf_session.h b/drivers/net/bnxt/tf_core/tf_session.h
index e2cebd20a1..034a2213a4 100644
--- a/drivers/net/bnxt/tf_core/tf_session.h
+++ b/drivers/net/bnxt/tf_core/tf_session.h
@@ -155,11 +155,6 @@ struct tf_session {
 	 */
 	void *em_db_handle;
 
-	/**
-	 * the pointer to the parent bp struct
-	 */
-	void *bp;
-
 	/**
 	 * EM allocator for session
 	 */
@@ -567,8 +562,8 @@ tf_session_is_shared_session_creator(struct tf_session *tfs)
  *   - the pointer to the parent bnxt struct
  */
 static inline struct bnxt*
-tf_session_get_bp(struct tf_session *tfs)
+tf_session_get_bp(struct tf *tfp)
 {
-	return tfs->bp;
+	return tfp->bp;
 }
 #endif /* _TF_SESSION_H_ */
diff --git a/drivers/net/bnxt/tf_core/tf_tbl.c b/drivers/net/bnxt/tf_core/tf_tbl.c
index 17fb550917..ca1aef8ebf 100644
--- a/drivers/net/bnxt/tf_core/tf_tbl.c
+++ b/drivers/net/bnxt/tf_core/tf_tbl.c
@@ -109,14 +109,16 @@ tf_tbl_unbind(struct tf *tfp)
 
 	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
 	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "Failed to get em_ext_db from session, rc:%s\n",
+		TFP_DRV_LOG(INFO,
+			    "Tbl_db is not initialized, rc:%s\n",
 			    strerror(-rc));
-		return rc;
+		return 0;
 	}
 	tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
 
 	for (i = 0; i < TF_DIR_MAX; i++) {
+		if (tbl_db->tbl_db[i] == NULL)
+			continue;
 		fparms.dir = i;
 		fparms.rm_db = tbl_db->tbl_db[i];
 		rc = tf_rm_free_db(tfp, &fparms);
@@ -621,23 +623,36 @@ tf_tbl_get_resc_info(struct tf *tfp,
 		     struct tf_tbl_resource_info *tbl)
 {
 	int rc;
-	int d;
+	int d, i;
 	struct tf_resource_info *dinfo;
 	struct tf_rm_get_alloc_info_parms ainfo;
 	void *tbl_db_ptr = NULL;
 	struct tbl_rm_db *tbl_db;
+	uint16_t base = 0, shift = 0;
+	struct tf_dev_info *dev;
+	struct tf_session *tfs;
 
 	TF_CHECK_PARMS2(tfp, tbl);
 
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc)
+		return rc;
+
 	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
 	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "Failed to get em_ext_db from session, rc:%s\n",
-			    strerror(-rc));
-		return rc;
+		TFP_DRV_LOG(INFO,
+			    "No resource allocated for table from session\n");
+		return 0;
 	}
 	tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
 
+
 	/* check if reserved resource for WC is multiple of num_slices */
 	for (d = 0; d < TF_DIR_MAX; d++) {
 		ainfo.rm_db = tbl_db->tbl_db[d];
@@ -648,7 +663,33 @@ tf_tbl_get_resc_info(struct tf *tfp,
 		rc = tf_rm_get_all_info(&ainfo, TF_TBL_TYPE_MAX);
 		if (rc)
 			return rc;
+
+		if (dev->ops->tf_dev_get_tbl_info) {
+			/* Adjust all */
+			for (i = 0; i < TF_TBL_TYPE_MAX; i++) {
+				/* Only get table info if required for the device */
+				rc = dev->ops->tf_dev_get_tbl_info(tfp,
+								   tbl_db->tbl_db[d],
+								   i,
+								   &base,
+								   &shift);
+				if (rc) {
+					TFP_DRV_LOG(ERR,
+						    "%s: Failed to get table info:%d\n",
+						    tf_dir_2_str(d),
+						    i);
+					return rc;
+				}
+				if (dinfo[i].stride)
+					TF_TBL_RM_TO_PTR(&dinfo[i].start,
+							 dinfo[i].start,
+							 base,
+							 shift);
+			}
+		}
 	}
 
+
+
 	return 0;
 }
diff --git a/drivers/net/bnxt/tf_core/tf_tcam.c b/drivers/net/bnxt/tf_core/tf_tcam.c
index 70dc539f15..0f05af87f1 100644
--- a/drivers/net/bnxt/tf_core/tf_tcam.c
+++ b/drivers/net/bnxt/tf_core/tf_tcam.c
@@ -220,14 +220,16 @@ tf_tcam_unbind(struct tf *tfp)
 
 	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);
 	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "Failed to get em_ext_db from session, rc:%s\n",
+		TFP_DRV_LOG(INFO,
+			    "Tcam_db is not initialized, rc:%s\n",
 			    strerror(-rc));
-		return rc;
+		return 0;
 	}
 	tcam_db = (struct tcam_rm_db *)tcam_db_ptr;
 
 	for (i = 0; i < TF_DIR_MAX; i++) {
+		if (tcam_db->tcam_db[i] == NULL)
+			continue;
 		memset(&fparms, 0, sizeof(fparms));
 		fparms.dir = i;
 		fparms.rm_db = tcam_db->tcam_db[i];
@@ -816,10 +818,9 @@ tf_tcam_get_resc_info(struct tf *tfp,
 
 	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);
 	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "Failed to get em_ext_db from session, rc:%s\n",
-			    strerror(-rc));
-		return rc;
+		TFP_DRV_LOG(INFO,
+			    "No resource allocated for tcam from session\n");
+		return 0;
 	}
 	tcam_db = (struct tcam_rm_db *)tcam_db_ptr;
 
diff --git a/drivers/net/bnxt/tf_core/tfp.c b/drivers/net/bnxt/tf_core/tfp.c
index 4d9b37f749..a4b0934610 100644
--- a/drivers/net/bnxt/tf_core/tfp.c
+++ b/drivers/net/bnxt/tf_core/tfp.c
@@ -134,7 +134,7 @@ tfp_get_fid(struct tf *tfp, uint16_t *fw_fid)
 	if (tfp == NULL || fw_fid == NULL)
 		return -EINVAL;
 
-	bp = container_of(tfp, struct bnxt, tfp);
+	bp = (struct bnxt *)tfp->bp;
 	if (bp == NULL)
 		return -EINVAL;
 
@@ -151,7 +151,7 @@ tfp_get_pf(struct tf *tfp, uint16_t *pf)
 	if (tfp == NULL || pf == NULL)
 		return -EINVAL;
 
-	bp = container_of(tfp, struct bnxt, tfp);
+	bp = (struct bnxt *)tfp->bp;
 	if (BNXT_VF(bp) && bp->parent) {
 		*pf = bp->parent->fid - 1;
 		return 0;
-- 
2.17.1


^ permalink raw reply	[flat|nested] 129+ messages in thread

* [dpdk-dev] [PATCH 17/58] net/bnxt: modify resource reservation strategy
  2021-05-30  8:58 [dpdk-dev] [PATCH 00/58] enhancements to host based flow table management Venkat Duvvuru
                   ` (15 preceding siblings ...)
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 16/58] net/bnxt: update shared session functionality Venkat Duvvuru
@ 2021-05-30  8:58 ` Venkat Duvvuru
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 18/58] net/bnxt: shared TCAM region support Venkat Duvvuru
                   ` (41 subsequent siblings)
  58 siblings, 0 replies; 129+ messages in thread
From: Venkat Duvvuru @ 2021-05-30  8:58 UTC (permalink / raw)
  To: dev; +Cc: Jay Ding, Randy Schacher, Venkat Duvvuru

From: Jay Ding <jay.ding@broadcom.com>

Allow an application to only reserve resources for one direction.

Signed-off-by: Jay Ding <jay.ding@broadcom.com>
Signed-off-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Ajit Kumar Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Randy Schacher <stuart.schacher@broadcom.com>
---
 drivers/net/bnxt/tf_core/tf_core.c        |  4 --
 drivers/net/bnxt/tf_core/tf_em_common.c   | 61 +++++++++++------------
 drivers/net/bnxt/tf_core/tf_em_internal.c | 13 +++--
 drivers/net/bnxt/tf_core/tf_identifier.c  | 15 +++---
 drivers/net/bnxt/tf_core/tf_tbl.c         | 12 +++--
 drivers/net/bnxt/tf_core/tf_tcam.c        | 14 ++++--
 6 files changed, 65 insertions(+), 54 deletions(-)

diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c
index 945e54bfdd..de2a93646f 100644
--- a/drivers/net/bnxt/tf_core/tf_core.c
+++ b/drivers/net/bnxt/tf_core/tf_core.c
@@ -1636,7 +1636,6 @@ int tf_get_session_info(struct tf *tfp,
 		TFP_DRV_LOG(ERR,
 			    "Ident get resc info failed, rc:%s\n",
 			    strerror(-rc));
-		return rc;
 	}
 
 	if (dev->ops->tf_dev_get_tbl_resc_info == NULL) {
@@ -1652,7 +1651,6 @@ int tf_get_session_info(struct tf *tfp,
 		TFP_DRV_LOG(ERR,
 			    "Tbl get resc info failed, rc:%s\n",
 			    strerror(-rc));
-		return rc;
 	}
 
 	if (dev->ops->tf_dev_get_tcam_resc_info == NULL) {
@@ -1668,7 +1666,6 @@ int tf_get_session_info(struct tf *tfp,
 		TFP_DRV_LOG(ERR,
 			    "TCAM get resc info failed, rc:%s\n",
 			    strerror(-rc));
-		return rc;
 	}
 
 	if (dev->ops->tf_dev_get_em_resc_info == NULL) {
@@ -1684,7 +1681,6 @@ int tf_get_session_info(struct tf *tfp,
 		TFP_DRV_LOG(ERR,
 			    "EM get resc info failed, rc:%s\n",
 			    strerror(-rc));
-		return rc;
 	}
 
 	return 0;
diff --git a/drivers/net/bnxt/tf_core/tf_em_common.c b/drivers/net/bnxt/tf_core/tf_em_common.c
index ed8f6db58c..812ccb0d29 100644
--- a/drivers/net/bnxt/tf_core/tf_em_common.c
+++ b/drivers/net/bnxt/tf_core/tf_em_common.c
@@ -301,6 +301,7 @@ tf_em_page_tbl_pgcnt(uint32_t num_pages,
 {
 	return roundup(num_pages, MAX_PAGE_PTRS(page_size)) /
 		       MAX_PAGE_PTRS(page_size);
+	return 0;
 }
 
 /**
@@ -722,10 +723,6 @@ tf_insert_eem_entry(struct tf_dev_info *dev,
 	if (!mask)
 		return -EINVAL;
 
-#ifdef TF_EEM_DEBUG
-	dump_raw((uint8_t *)parms->key, TF_P4_HW_EM_KEY_MAX_SIZE + 4, "In Key");
-#endif
-
 	if (dev->ops->tf_dev_cfa_key_hash == NULL)
 		return -EINVAL;
 
@@ -737,10 +734,6 @@ tf_insert_eem_entry(struct tf_dev_info *dev,
 	key0_index = key0_hash & mask;
 	key1_index = key1_hash & mask;
 
-#ifdef TF_EEM_DEBUG
-	TFP_DRV_LOG(DEBUG, "Key0 hash:0x%08x\n", key0_hash);
-	TFP_DRV_LOG(DEBUG, "Key1 hash:0x%08x\n", key1_hash);
-#endif
 	/*
 	 * Use the "result" arg to populate all of the key entry then
 	 * store the byte swapped "raw" entry in a local copy ready
@@ -1010,35 +1003,41 @@ tf_em_ext_common_unbind(struct tf *tfp)
 	}
 	ext_db = (struct em_ext_db *)ext_ptr;
 
-	entry = ext_db->tbl_scope_ll.head;
-	while (entry != NULL) {
-		tbl_scope_cb = (struct tf_tbl_scope_cb *)entry;
-		entry = entry->next;
-		tparms.tbl_scope_id = tbl_scope_cb->tbl_scope_id;
-
-		if (dev->ops->tf_dev_free_tbl_scope) {
-			dev->ops->tf_dev_free_tbl_scope(tfp, &tparms);
-		} else {
-			/* should not reach here */
-			ll_delete(&ext_db->tbl_scope_ll, &tbl_scope_cb->ll_entry);
-			tfp_free(tbl_scope_cb);
+	if (ext_db != NULL) {
+		entry = ext_db->tbl_scope_ll.head;
+		while (entry != NULL) {
+			tbl_scope_cb = (struct tf_tbl_scope_cb *)entry;
+			entry = entry->next;
+			tparms.tbl_scope_id =
+				tbl_scope_cb->tbl_scope_id;
+
+			if (dev->ops->tf_dev_free_tbl_scope) {
+				dev->ops->tf_dev_free_tbl_scope(tfp,
+								&tparms);
+			} else {
+				/* should not reach here */
+				ll_delete(&ext_db->tbl_scope_ll,
+					  &tbl_scope_cb->ll_entry);
+				tfp_free(tbl_scope_cb);
+			}
 		}
-	}
 
-	for (i = 0; i < TF_DIR_MAX; i++) {
-		if (ext_db->eem_db[i] == NULL)
-			continue;
+		for (i = 0; i < TF_DIR_MAX; i++) {
+			if (ext_db->eem_db[i] == NULL)
+				continue;
 
-		fparms.dir = i;
-		fparms.rm_db = ext_db->eem_db[i];
-		rc = tf_rm_free_db(tfp, &fparms);
-		if (rc)
-			return rc;
+			fparms.dir = i;
+			fparms.rm_db = ext_db->eem_db[i];
+			rc = tf_rm_free_db(tfp, &fparms);
+			if (rc)
+				return rc;
 
-		ext_db->eem_db[i] = NULL;
+			ext_db->eem_db[i] = NULL;
+		}
+
+		tfp_free(ext_db);
 	}
 
-	tfp_free(ext_db);
 	tf_session_set_em_ext_db(tfp, NULL);
 
 	return 0;
diff --git a/drivers/net/bnxt/tf_core/tf_em_internal.c b/drivers/net/bnxt/tf_core/tf_em_internal.c
index 3b1e4e385d..93de513989 100644
--- a/drivers/net/bnxt/tf_core/tf_em_internal.c
+++ b/drivers/net/bnxt/tf_core/tf_em_internal.c
@@ -349,6 +349,7 @@ tf_em_int_bind(struct tf *tfp,
 	       struct tf_em_cfg_parms *parms)
 {
 	int rc;
+	int db_rc[TF_DIR_MAX] = { 0 };
 	int i;
 	struct tf_rm_create_db_parms db_cfg = { 0 };
 	struct tf_rm_get_alloc_info_parms iparms;
@@ -408,18 +409,22 @@ tf_em_int_bind(struct tf *tfp,
 		db_cfg.rm_db = (void *)&em_db->em_db[i];
 		if (tf_session_is_shared_session(tfs) &&
 			(!tf_session_is_shared_session_creator(tfs)))
-			rc = tf_rm_create_db_no_reservation(tfp, &db_cfg);
+			db_rc[i] = tf_rm_create_db_no_reservation(tfp, &db_cfg);
 		else
-			rc = tf_rm_create_db(tfp, &db_cfg);
-		if (rc) {
+			db_rc[i] = tf_rm_create_db(tfp, &db_cfg);
+		if (db_rc[i]) {
 			TFP_DRV_LOG(ERR,
 				    "%s: EM Int DB creation failed\n",
 				    tf_dir_2_str(i));
 
-			return rc;
 		}
 	}
 
+	/* No db created */
+	if (db_rc[TF_DIR_RX] && db_rc[TF_DIR_TX])
+		return db_rc[TF_DIR_RX];
+
+
 	if (!tf_session_is_shared_session(tfs)) {
 		for (i = 0; i < TF_DIR_MAX; i++) {
 			iparms.rm_db = em_db->em_db[i];
diff --git a/drivers/net/bnxt/tf_core/tf_identifier.c b/drivers/net/bnxt/tf_core/tf_identifier.c
index ebb975562d..3cc87de4ef 100644
--- a/drivers/net/bnxt/tf_core/tf_identifier.c
+++ b/drivers/net/bnxt/tf_core/tf_identifier.c
@@ -30,6 +30,7 @@ tf_ident_bind(struct tf *tfp,
 	      struct tf_ident_cfg_parms *parms)
 {
 	int rc;
+	int db_rc[TF_DIR_MAX] = { 0 };
 	int i;
 	struct tf_rm_create_db_parms db_cfg = { 0 };
 	struct tf_shadow_ident_cfg_parms shadow_cfg = { 0 };
@@ -70,15 +71,13 @@ tf_ident_bind(struct tf *tfp,
 		db_cfg.alloc_cnt = parms->resources->ident_cnt[i].cnt;
 		if (tf_session_is_shared_session(tfs) &&
 			(!tf_session_is_shared_session_creator(tfs)))
-			rc = tf_rm_create_db_no_reservation(tfp, &db_cfg);
+			db_rc[i] = tf_rm_create_db_no_reservation(tfp, &db_cfg);
 		else
-			rc = tf_rm_create_db(tfp, &db_cfg);
-		if (rc) {
-			TFP_DRV_LOG(ERR,
+			db_rc[i] = tf_rm_create_db(tfp, &db_cfg);
+		if (db_rc[i]) {
+			TFP_DRV_LOG(INFO,
 				    "%s: Identifier DB creation failed\n",
 				    tf_dir_2_str(i));
-
-			return rc;
 		}
 
 		if (parms->shadow_copy) {
@@ -99,6 +98,10 @@ tf_ident_bind(struct tf *tfp,
 		}
 	}
 
+	/* No db created */
+	if (db_rc[TF_DIR_RX] && db_rc[TF_DIR_TX])
+		return db_rc[TF_DIR_RX];
+
 	TFP_DRV_LOG(INFO,
 		    "Identifier - initialized\n");
 
diff --git a/drivers/net/bnxt/tf_core/tf_tbl.c b/drivers/net/bnxt/tf_core/tf_tbl.c
index ca1aef8ebf..192115183b 100644
--- a/drivers/net/bnxt/tf_core/tf_tbl.c
+++ b/drivers/net/bnxt/tf_core/tf_tbl.c
@@ -41,6 +41,7 @@ tf_tbl_bind(struct tf *tfp,
 	    struct tf_tbl_cfg_parms *parms)
 {
 	int rc, d, i;
+	int db_rc[TF_DIR_MAX] = { 0 };
 	struct tf_rm_create_db_parms db_cfg = { 0 };
 	struct tbl_rm_db *tbl_db;
 	struct tfp_calloc_parms cparms;
@@ -79,18 +80,21 @@ tf_tbl_bind(struct tf *tfp,
 		db_cfg.rm_db = (void *)&tbl_db->tbl_db[d];
 		if (tf_session_is_shared_session(tfs) &&
 			(!tf_session_is_shared_session_creator(tfs)))
-			rc = tf_rm_create_db_no_reservation(tfp, &db_cfg);
+			db_rc[d] = tf_rm_create_db_no_reservation(tfp, &db_cfg);
 		else
-			rc = tf_rm_create_db(tfp, &db_cfg);
-		if (rc) {
+			db_rc[d] = tf_rm_create_db(tfp, &db_cfg);
+		if (db_rc[d]) {
 			TFP_DRV_LOG(ERR,
 				    "%s: Table DB creation failed\n",
 				    tf_dir_2_str(d));
 
-			return rc;
 		}
 	}
 
+	/* No db created */
+	if (db_rc[TF_DIR_RX] && db_rc[TF_DIR_TX])
+		return db_rc[TF_DIR_RX];
+
 	TFP_DRV_LOG(INFO,
 		    "Table Type - initialized\n");
 
diff --git a/drivers/net/bnxt/tf_core/tf_tcam.c b/drivers/net/bnxt/tf_core/tf_tcam.c
index 0f05af87f1..ce959e3923 100644
--- a/drivers/net/bnxt/tf_core/tf_tcam.c
+++ b/drivers/net/bnxt/tf_core/tf_tcam.c
@@ -33,6 +33,7 @@ tf_tcam_bind(struct tf *tfp,
 	     struct tf_tcam_cfg_parms *parms)
 {
 	int rc;
+	int db_rc[TF_DIR_MAX] = { 0 };
 	int i, d;
 	struct tf_rm_alloc_info info;
 	struct tf_rm_free_db_parms fparms;
@@ -109,17 +110,20 @@ tf_tcam_bind(struct tf *tfp,
 		db_cfg.rm_db = (void *)&tcam_db->tcam_db[d];
 		if (tf_session_is_shared_session(tfs) &&
 			(!tf_session_is_shared_session_creator(tfs)))
-			rc = tf_rm_create_db_no_reservation(tfp, &db_cfg);
+			db_rc[d] = tf_rm_create_db_no_reservation(tfp, &db_cfg);
 		else
-			rc = tf_rm_create_db(tfp, &db_cfg);
-		if (rc) {
-			TFP_DRV_LOG(ERR,
+			db_rc[d] = tf_rm_create_db(tfp, &db_cfg);
+		if (db_rc[d]) {
+			TFP_DRV_LOG(INFO,
 				    "%s: TCAM DB creation failed\n",
 				    tf_dir_2_str(d));
-			return rc;
 		}
 	}
 
+	/* No db created */
+	if (db_rc[TF_DIR_RX] && db_rc[TF_DIR_TX])
+		return db_rc[TF_DIR_RX];
+
 	/* check if reserved resource for WC is multiple of num_slices */
 	for (d = 0; d < TF_DIR_MAX; d++) {
 		memset(&info, 0, sizeof(info));
-- 
2.17.1


^ permalink raw reply	[flat|nested] 129+ messages in thread

* [dpdk-dev] [PATCH 18/58] net/bnxt: shared TCAM region support
  2021-05-30  8:58 [dpdk-dev] [PATCH 00/58] enhancements to host based flow table management Venkat Duvvuru
                   ` (16 preceding siblings ...)
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 17/58] net/bnxt: modify resource reservation strategy Venkat Duvvuru
@ 2021-05-30  8:58 ` Venkat Duvvuru
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 19/58] net/bnxt: cleanup session open/close messages Venkat Duvvuru
                   ` (40 subsequent siblings)
  58 siblings, 0 replies; 129+ messages in thread
From: Venkat Duvvuru @ 2021-05-30  8:58 UTC (permalink / raw)
  To: dev; +Cc: Farah Smith, Jay Ding, Randy Schacher, Venkat Duvvuru

From: Farah Smith <farah.smith@broadcom.com>

- switch to single slice management on Wh+
- Support of shared session WC_TCAM_HIGH and WC_TCAM_LOW regions
- Enable/disable using TF_TCAM_SHARED flag in tf_core.h
- Fix empty session module DBs in the case that none are
  allocated for a given module type

Signed-off-by: Farah Smith <farah.smith@broadcom.com>
Signed-off-by: Jay Ding <jay.ding@broadcom.com>
Signed-off-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Farah Smith <farah.smith@broadcom.com>
Reviewed-by: Randy Schacher <stuart.schacher@broadcom.com>
---
 drivers/net/bnxt/tf_core/meson.build      |  25 +-
 drivers/net/bnxt/tf_core/tf_core.h        |  45 +-
 drivers/net/bnxt/tf_core/tf_device.c      |  72 ++-
 drivers/net/bnxt/tf_core/tf_device.h      |   4 +-
 drivers/net/bnxt/tf_core/tf_device_p4.c   |  17 +-
 drivers/net/bnxt/tf_core/tf_device_p58.c  |  13 +-
 drivers/net/bnxt/tf_core/tf_identifier.c  |   2 +-
 drivers/net/bnxt/tf_core/tf_tbl.c         |   5 +-
 drivers/net/bnxt/tf_core/tf_tcam.c        |   5 +-
 drivers/net/bnxt/tf_core/tf_tcam_shared.c | 744 ++++++++++++++++++++++
 drivers/net/bnxt/tf_core/tf_tcam_shared.h | 127 ++++
 drivers/net/bnxt/tf_core/tf_util.c        |   6 +
 12 files changed, 1014 insertions(+), 51 deletions(-)
 create mode 100644 drivers/net/bnxt/tf_core/tf_tcam_shared.c
 create mode 100644 drivers/net/bnxt/tf_core/tf_tcam_shared.h

diff --git a/drivers/net/bnxt/tf_core/meson.build b/drivers/net/bnxt/tf_core/meson.build
index 3a91f04bc0..f28e77ec2e 100644
--- a/drivers/net/bnxt/tf_core/meson.build
+++ b/drivers/net/bnxt/tf_core/meson.build
@@ -10,26 +10,27 @@ sources += files(
         'tf_core.c',
         'bitalloc.c',
         'tf_msg.c',
-	'dpool.c',
+        'll.c',
+        'dpool.c',
         'rand.c',
         'stack.c',
-        'tf_em_common.c',
-        'tf_em_internal.c',
         'tf_rm.c',
         'tf_tbl.c',
+        'tf_em_common.c',
+        'tf_em_host.c',
+        'tf_em_internal.c',
+        'tf_em_hash_internal.c',
         'tfp.c',
-        'tf_session.c',
+        'tf_util.c',
         'tf_device.c',
         'tf_device_p4.c',
-        'tf_device_p58.c',
+        'tf_global_cfg.c',
         'tf_identifier.c',
+        'tf_if_tbl.c',
+        'tf_session.c',
         'tf_shadow_tcam.c',
         'tf_tcam.c',
-        'tf_util.c',
-        'tf_if_tbl.c',
-        'll.c',
-        'tf_global_cfg.c',
-        'tf_em_host.c',
-        'tf_em_hash_internal.c',
+        'tf_tcam_shared.c',
         'tf_shadow_identifier.c',
-        'tf_hash.c')
+        'tf_hash.c',
+        'tf_device_p58.c')
diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h
index 3d14dc5391..39a498122b 100644
--- a/drivers/net/bnxt/tf_core/tf_core.h
+++ b/drivers/net/bnxt/tf_core/tf_core.h
@@ -21,7 +21,6 @@
 
 /********** BEGIN Truflow Core DEFINITIONS **********/
 
-
 #define TF_KILOBYTE  1024
 #define TF_MEGABYTE  (1024 * 1024)
 
@@ -77,7 +76,6 @@ enum tf_ext_mem_chan_type {
 #define TF_ACT_REC_OFFSET_2_PTR(offset) ((offset) >> 4)
 #define TF_ACT_REC_PTR_2_OFFSET(offset) ((offset) << 4)
 
-
 /*
  * Helper Macros
  */
@@ -198,7 +196,6 @@ enum tf_module_type {
 	TF_MODULE_TYPE_MAX
 };
 
-
 /**
  * Identifier resource types
  */
@@ -317,6 +314,41 @@ enum tf_tbl_type {
 	TF_TBL_TYPE_MAX
 };
 
+/** Enable Shared TCAM Management
+ *
+ *  This feature allows for management of high and low pools within
+ *  the WC TCAM.  These pools are only valid when this feature is enabled.
+ *
+ *  For normal OVS-DPDK operation, this feature is not required and can
+ *  be disabled by commenting out TF_TCAM_SHARED in this header file.
+ *
+ *  Operation:
+ *
+ *  When a shared session is created with WC TCAM entries allocated during
+ *  tf_open_session(), the TF_TCAM_TBL_TYPE_WC_TCAM pool entries will be divided
+ *  into 2 equal pools - TF_TCAM_TBL_TYPE_WC_TCAM_HIGH and
+ *  TF_TCAM_TBL_TYPE_WC_TCAM_LOW.
+ *
+ *  The user will allocate and free entries from either of these pools to obtain
+ *  WC_TCAM entry offsets.  For the WC_TCAM_HI/LO management, alloc/free is done
+ *  using the tf_alloc_tcam_entry()/tf_free_tcam_entry() APIs for the shared
+ *  session.
+ *
+ *  The use case for this feature is so that applications can have a shared
+ *  session and use the TF core to allocate/set/free entries within a given
+ *  region of the WC_TCAM within the shared session.  Application A only writes
+ *  to the LOW region for example and Application B only writes to the HIGH
+ *  region during normal operation.  After Application A goes down, Application
+ *  B may decide to overwrite the LOW region with the HIGH region's entries
+ *  and switch to the low region.
+ *
+ *  For other TCAM types in the  shared session, no alloc/free operations are
+ *  permitted. Only set should be used for other TCAM table types after getting
+ *  the range as provided by the tf_get_resource_info() API.
+ *
+ */
+#define TF_TCAM_SHARED 1
+
 /**
  * TCAM table type
  */
@@ -335,6 +367,12 @@ enum tf_tcam_tbl_type {
 	TF_TCAM_TBL_TYPE_CT_RULE_TCAM,
 	/** Virtual Edge Bridge TCAM */
 	TF_TCAM_TBL_TYPE_VEB_TCAM,
+#ifdef TF_TCAM_SHARED
+	/** Wildcard TCAM HI Priority */
+	TF_TCAM_TBL_TYPE_WC_TCAM_HIGH,
+	/** Wildcard TCAM Low Priority */
+	TF_TCAM_TBL_TYPE_WC_TCAM_LOW,
+#endif /* TF_TCAM_SHARED */
 	TF_TCAM_TBL_TYPE_MAX
 };
 
@@ -1044,7 +1082,6 @@ int tf_search_identifier(struct tf *tfp,
  * Current thought is that memory is allocated within core.
  */
 
-
 /**
  * tf_alloc_tbl_scope_parms definition
  */
diff --git a/drivers/net/bnxt/tf_core/tf_device.c b/drivers/net/bnxt/tf_core/tf_device.c
index 97ae73fa5a..55cf55886a 100644
--- a/drivers/net/bnxt/tf_core/tf_device.c
+++ b/drivers/net/bnxt/tf_core/tf_device.c
@@ -9,6 +9,9 @@
 #include "tfp.h"
 #include "tf_em.h"
 #include "tf_rm.h"
+#ifdef TF_TCAM_SHARED
+#include "tf_tcam_shared.h"
+#endif /* TF_TCAM_SHARED */
 
 struct tf;
 
@@ -92,6 +95,12 @@ tf_dev_bind_p4(struct tf *tfp,
 	struct tf_em_cfg_parms em_cfg;
 	struct tf_if_tbl_cfg_parms if_tbl_cfg;
 	struct tf_global_cfg_cfg_parms global_cfg;
+	struct tf_session *tfs;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
 
 	/* Initial function initialization */
 	dev_handle->ops = &tf_dev_ops_p4_init;
@@ -142,7 +151,11 @@ tf_dev_bind_p4(struct tf *tfp,
 		tcam_cfg.cfg = tf_tcam_p4;
 		tcam_cfg.shadow_copy = shadow_copy;
 		tcam_cfg.resources = resources;
+#ifdef TF_TCAM_SHARED
+		rc = tf_tcam_shared_bind(tfp, &tcam_cfg);
+#else /* !TF_TCAM_SHARED */
 		rc = tf_tcam_bind(tfp, &tcam_cfg);
+#endif
 		if (rc) {
 			TFP_DRV_LOG(ERR,
 				    "TCAM initialization failure\n");
@@ -203,31 +216,32 @@ tf_dev_bind_p4(struct tf *tfp,
 		return -ENOMEM;
 	}
 
-	/*
-	 * IF_TBL
-	 */
-	if_tbl_cfg.num_elements = TF_IF_TBL_TYPE_MAX;
-	if_tbl_cfg.cfg = tf_if_tbl_p4;
-	if_tbl_cfg.shadow_copy = shadow_copy;
-	rc = tf_if_tbl_bind(tfp, &if_tbl_cfg);
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "IF Table initialization failure\n");
-		goto fail;
-	}
+	if (!tf_session_is_shared_session(tfs)) {
+		/*
+		 * IF_TBL
+		 */
+		if_tbl_cfg.num_elements = TF_IF_TBL_TYPE_MAX;
+		if_tbl_cfg.cfg = tf_if_tbl_p4;
+		if_tbl_cfg.shadow_copy = shadow_copy;
+		rc = tf_if_tbl_bind(tfp, &if_tbl_cfg);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "IF Table initialization failure\n");
+			goto fail;
+		}
 
-	/*
-	 * GLOBAL_CFG
-	 */
-	global_cfg.num_elements = TF_GLOBAL_CFG_TYPE_MAX;
-	global_cfg.cfg = tf_global_cfg_p4;
-	rc = tf_global_cfg_bind(tfp, &global_cfg);
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "Global Cfg initialization failure\n");
-		goto fail;
+		/*
+		 * GLOBAL_CFG
+		 */
+		global_cfg.num_elements = TF_GLOBAL_CFG_TYPE_MAX;
+		global_cfg.cfg = tf_global_cfg_p4;
+		rc = tf_global_cfg_bind(tfp, &global_cfg);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "Global Cfg initialization failure\n");
+			goto fail;
+		}
 	}
-
 	/* Final function initialization */
 	dev_handle->ops = &tf_dev_ops_p4;
 
@@ -265,7 +279,11 @@ tf_dev_unbind_p4(struct tf *tfp)
 	 * In case of residuals TCAMs are cleaned up first as to
 	 * invalidate the pipeline in a clean manner.
 	 */
+#ifdef TF_TCAM_SHARED
+	rc = tf_tcam_shared_unbind(tfp);
+#else /* !TF_TCAM_SHARED */
 	rc = tf_tcam_unbind(tfp);
+#endif /* TF_TCAM_SHARED */
 	if (rc) {
 		TFP_DRV_LOG(INFO,
 			    "Device unbind failed, TCAM\n");
@@ -407,7 +425,11 @@ tf_dev_bind_p58(struct tf *tfp,
 		tcam_cfg.cfg = tf_tcam_p58;
 		tcam_cfg.shadow_copy = shadow_copy;
 		tcam_cfg.resources = resources;
+#ifdef TF_TCAM_SHARED
+		rc = tf_tcam_shared_bind(tfp, &tcam_cfg);
+#else /* !TF_TCAM_SHARED */
 		rc = tf_tcam_bind(tfp, &tcam_cfg);
+#endif
 		if (rc) {
 			TFP_DRV_LOG(ERR,
 				    "TCAM initialization failure\n");
@@ -517,7 +539,11 @@ tf_dev_unbind_p58(struct tf *tfp)
 	 * In case of residuals TCAMs are cleaned up first as to
 	 * invalidate the pipeline in a clean manner.
 	 */
+#ifdef TF_TCAM_SHARED
+	rc = tf_tcam_shared_unbind(tfp);
+#else /* !TF_TCAM_SHARED */
 	rc = tf_tcam_unbind(tfp);
+#endif /* TF_TCAM_SHARED */
 	if (rc) {
 		TFP_DRV_LOG(INFO,
 			    "Device unbind failed, TCAM\n");
diff --git a/drivers/net/bnxt/tf_core/tf_device.h b/drivers/net/bnxt/tf_core/tf_device.h
index 31806bb289..ea4dcfb8e2 100644
--- a/drivers/net/bnxt/tf_core/tf_device.h
+++ b/drivers/net/bnxt/tf_core/tf_device.h
@@ -10,6 +10,9 @@
 #include "tf_identifier.h"
 #include "tf_tbl.h"
 #include "tf_tcam.h"
+#ifdef TF_TCAM_SHARED
+#include "tf_tcam_shared.h"
+#endif
 #include "tf_if_tbl.h"
 #include "tf_global_cfg.h"
 
@@ -136,7 +139,6 @@ struct tf_dev_ops {
 				       uint16_t resource_id,
 				       const char **resource_str);
 
-
 	/**
 	 * Retrieves the WC TCAM slice information that the device
 	 * supports.
diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.c b/drivers/net/bnxt/tf_core/tf_device_p4.c
index 3f788638c1..fccbccc2d8 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p4.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p4.c
@@ -10,6 +10,9 @@
 #include "tf_identifier.h"
 #include "tf_tbl.h"
 #include "tf_tcam.h"
+#ifdef TF_TCAM_SHARED
+#include "tf_tcam_shared.h"
+#endif /* TF_TCAM_SHARED */
 #include "tf_em.h"
 #include "tf_if_tbl.h"
 #include "tfp.h"
@@ -140,7 +143,8 @@ tf_dev_p4_get_tcam_slice_info(struct tf *tfp __rte_unused,
 			      uint16_t key_sz,
 			      uint16_t *num_slices_per_row)
 {
-#define CFA_P4_WC_TCAM_SLICES_PER_ROW 2
+/* Single slice support */
+#define CFA_P4_WC_TCAM_SLICES_PER_ROW 1
 #define CFA_P4_WC_TCAM_SLICE_SIZE     12
 
 	if (type == TF_TCAM_TBL_TYPE_WC_TCAM) {
@@ -266,11 +270,18 @@ const struct tf_dev_ops tf_dev_ops_p4 = {
 	.tf_dev_get_tbl = tf_tbl_get,
 	.tf_dev_get_bulk_tbl = tf_tbl_bulk_get,
 	.tf_dev_get_tbl_resc_info = tf_tbl_get_resc_info,
+#ifdef TF_TCAM_SHARED
+	.tf_dev_alloc_tcam = tf_tcam_shared_alloc,
+	.tf_dev_free_tcam = tf_tcam_shared_free,
+	.tf_dev_set_tcam = tf_tcam_shared_set,
+	.tf_dev_get_tcam = tf_tcam_shared_get,
+#else /* !TF_TCAM_SHARED */
 	.tf_dev_alloc_tcam = tf_tcam_alloc,
 	.tf_dev_free_tcam = tf_tcam_free,
-	.tf_dev_alloc_search_tcam = tf_tcam_alloc_search,
 	.tf_dev_set_tcam = tf_tcam_set,
-	.tf_dev_get_tcam = NULL,
+	.tf_dev_get_tcam = tf_tcam_get,
+#endif
+	.tf_dev_alloc_search_tcam = tf_tcam_alloc_search,
 	.tf_dev_get_tcam_resc_info = tf_tcam_get_resc_info,
 	.tf_dev_insert_int_em_entry = tf_em_insert_int_entry,
 	.tf_dev_delete_int_em_entry = tf_em_delete_int_entry,
diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c
index ba82efdfe2..b25c5acf94 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p58.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p58.c
@@ -10,6 +10,9 @@
 #include "tf_identifier.h"
 #include "tf_tbl.h"
 #include "tf_tcam.h"
+#ifdef TF_TCAM_SHARED
+#include "tf_tcam_shared.h"
+#endif /* TF_TCAM_SHARED */
 #include "tf_em.h"
 #include "tf_if_tbl.h"
 #include "tfp.h"
@@ -151,7 +154,6 @@ static int tf_dev_p58_word_align(uint16_t size)
 	return ((((size) + 63) >> 6) * 8);
 }
 
-
 #define TF_DEV_P58_BANK_SZ_64B 2048
 /**
  * Get SRAM table information.
@@ -290,11 +292,18 @@ const struct tf_dev_ops tf_dev_ops_p58 = {
 	.tf_dev_get_tbl = tf_tbl_get,
 	.tf_dev_get_bulk_tbl = tf_tbl_bulk_get,
 	.tf_dev_get_tbl_resc_info = tf_tbl_get_resc_info,
+#ifdef TF_TCAM_SHARED
+	.tf_dev_alloc_tcam = tf_tcam_shared_alloc,
+	.tf_dev_free_tcam = tf_tcam_shared_free,
+	.tf_dev_set_tcam = tf_tcam_set,
+	.tf_dev_get_tcam = tf_tcam_get,
+#else /* !TF_TCAM_SHARED */
 	.tf_dev_alloc_tcam = tf_tcam_alloc,
 	.tf_dev_free_tcam = tf_tcam_free,
-	.tf_dev_alloc_search_tcam = tf_tcam_alloc_search,
 	.tf_dev_set_tcam = tf_tcam_set,
 	.tf_dev_get_tcam = tf_tcam_get,
+#endif
+	.tf_dev_alloc_search_tcam = tf_tcam_alloc_search,
 	.tf_dev_get_tcam_resc_info = tf_tcam_get_resc_info,
 	.tf_dev_insert_int_em_entry = tf_em_hash_insert_int_entry,
 	.tf_dev_delete_int_em_entry = tf_em_hash_delete_int_entry,
diff --git a/drivers/net/bnxt/tf_core/tf_identifier.c b/drivers/net/bnxt/tf_core/tf_identifier.c
index 3cc87de4ef..3575c3e1a0 100644
--- a/drivers/net/bnxt/tf_core/tf_identifier.c
+++ b/drivers/net/bnxt/tf_core/tf_identifier.c
@@ -76,7 +76,7 @@ tf_ident_bind(struct tf *tfp,
 			db_rc[i] = tf_rm_create_db(tfp, &db_cfg);
 		if (db_rc[i]) {
 			TFP_DRV_LOG(INFO,
-				    "%s: Identifier DB creation failed\n",
+				    "%s: No Identifier DB required\n",
 				    tf_dir_2_str(i));
 		}
 
diff --git a/drivers/net/bnxt/tf_core/tf_tbl.c b/drivers/net/bnxt/tf_core/tf_tbl.c
index 192115183b..295204ac87 100644
--- a/drivers/net/bnxt/tf_core/tf_tbl.c
+++ b/drivers/net/bnxt/tf_core/tf_tbl.c
@@ -85,7 +85,7 @@ tf_tbl_bind(struct tf *tfp,
 			db_rc[d] = tf_rm_create_db(tfp, &db_cfg);
 		if (db_rc[d]) {
 			TFP_DRV_LOG(ERR,
-				    "%s: Table DB creation failed\n",
+				    "%s: No Table DB creation required\n",
 				    tf_dir_2_str(d));
 
 		}
@@ -656,7 +656,6 @@ tf_tbl_get_resc_info(struct tf *tfp,
 	}
 	tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
 
-
 	/* check if reserved resource for WC is multiple of num_slices */
 	for (d = 0; d < TF_DIR_MAX; d++) {
 		ainfo.rm_db = tbl_db->tbl_db[d];
@@ -693,7 +692,5 @@ tf_tbl_get_resc_info(struct tf *tfp,
 		}
 	}
 
-
-
 	return 0;
 }
diff --git a/drivers/net/bnxt/tf_core/tf_tcam.c b/drivers/net/bnxt/tf_core/tf_tcam.c
index ce959e3923..5c018f7003 100644
--- a/drivers/net/bnxt/tf_core/tf_tcam.c
+++ b/drivers/net/bnxt/tf_core/tf_tcam.c
@@ -115,7 +115,7 @@ tf_tcam_bind(struct tf *tfp,
 			db_rc[d] = tf_rm_create_db(tfp, &db_cfg);
 		if (db_rc[d]) {
 			TFP_DRV_LOG(INFO,
-				    "%s: TCAM DB creation failed\n",
+				    "%s: no TCAM DB required\n",
 				    tf_dir_2_str(d));
 		}
 	}
@@ -126,6 +126,9 @@ tf_tcam_bind(struct tf *tfp,
 
 	/* check if reserved resource for WC is multiple of num_slices */
 	for (d = 0; d < TF_DIR_MAX; d++) {
+		if (!tcam_db->tcam_db[d])
+			continue;
+
 		memset(&info, 0, sizeof(info));
 		ainfo.rm_db = tcam_db->tcam_db[d];
 		ainfo.subtype = TF_TCAM_TBL_TYPE_WC_TCAM;
diff --git a/drivers/net/bnxt/tf_core/tf_tcam_shared.c b/drivers/net/bnxt/tf_core/tf_tcam_shared.c
new file mode 100644
index 0000000000..17d7fee7a8
--- /dev/null
+++ b/drivers/net/bnxt/tf_core/tf_tcam_shared.c
@@ -0,0 +1,744 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019-2021 Broadcom
+ * All rights reserved.
+ */
+
+#include <string.h>
+#include <rte_common.h>
+
+#include "tf_tcam_shared.h"
+#include "tf_tcam.h"
+#include "tf_common.h"
+#include "tf_util.h"
+#include "tf_rm.h"
+#include "tf_device.h"
+#include "tfp.h"
+#include "tf_session.h"
+#include "tf_msg.h"
+#include "bitalloc.h"
+#include "tf_core.h"
+#include "tf_rm.h"
+
+struct tf;
+
+/** Shared WC TCAM pool identifiers
+ */
+enum tf_tcam_shared_wc_pool_id {
+	TF_TCAM_SHARED_WC_POOL_HI  = 0,
+	TF_TCAM_SHARED_WC_POOL_LO  = 1,
+	TF_TCAM_SHARED_WC_POOL_MAX = 2
+};
+
+/** Get string representation of a WC TCAM shared pool id
+ */
+static const char *
+tf_pool_2_str(enum tf_tcam_shared_wc_pool_id id)
+{
+	switch (id) {
+	case TF_TCAM_SHARED_WC_POOL_HI:
+		return "TCAM_SHARED_WC_POOL_HI";
+	case TF_TCAM_SHARED_WC_POOL_LO:
+		return "TCAM_SHARED_WC_POOL_LO";
+	default:
+		return "Invalid TCAM_SHARED_WC_POOL";
+	}
+}
+
+/** The WC TCAM shared pool datastructure
+ */
+struct tf_tcam_shared_wc_pool {
+	/** Start and stride data */
+	struct tf_resource_info info;
+	/** bitalloc pool */
+	struct bitalloc *pool;
+};
+
+/** The WC TCAM shared pool declarations
+ * TODO: add tcam_shared_wc_db
+ */
+struct tf_tcam_shared_wc_pool tcam_shared_wc[TF_DIR_MAX][TF_TCAM_SHARED_WC_POOL_MAX];
+
+/** Create a WC TCAM shared pool
+ */
+static int
+tf_tcam_shared_create_wc_pool(int dir,
+			      enum tf_tcam_shared_wc_pool_id id,
+			      int start,
+			      int stride)
+{
+	int rc = 0;
+	bool free = true;
+	struct tfp_calloc_parms cparms;
+	uint32_t pool_size;
+
+	/* Create pool */
+	pool_size = (BITALLOC_SIZEOF(stride) / sizeof(struct bitalloc));
+	cparms.nitems = pool_size;
+	cparms.alignment = 0;
+	cparms.size = sizeof(struct bitalloc);
+	rc = tfp_calloc(&cparms);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: pool memory alloc failed %s:%s\n",
+			    tf_dir_2_str(dir), tf_pool_2_str(id),
+			    strerror(-rc));
+		return rc;
+	}
+	tcam_shared_wc[dir][id].pool = (struct bitalloc *)cparms.mem_va;
+
+	rc = ba_init(tcam_shared_wc[dir][id].pool,
+		     stride,
+		     free);
+
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: pool bitalloc failed %s\n",
+			    tf_dir_2_str(dir), tf_pool_2_str(id));
+		return rc;
+	}
+
+	tcam_shared_wc[dir][id].info.start = start;
+	tcam_shared_wc[dir][id].info.stride = stride;
+	return rc;
+}
+/** Free a WC TCAM shared pool
+ */
+static void
+tf_tcam_shared_free_wc_pool(int dir,
+			    enum tf_tcam_shared_wc_pool_id id)
+{
+	tcam_shared_wc[dir][id].info.start = 0;
+	tcam_shared_wc[dir][id].info.stride = 0;
+
+	if (tcam_shared_wc[dir][id].pool)
+		tfp_free((void *)tcam_shared_wc[dir][id].pool);
+}
+
+/** Get the number of WC TCAM slices allocated during 1 allocation/free
+ */
+static int
+tf_tcam_shared_get_slices(struct tf *tfp,
+			  struct tf_dev_info *dev,
+			  uint16_t *num_slices)
+{
+	int rc;
+
+	if (dev->ops->tf_dev_get_tcam_slice_info == NULL) {
+		rc = -EOPNOTSUPP;
+		TFP_DRV_LOG(ERR,
+			    "Operation not supported, rc:%s\n", strerror(-rc));
+		return rc;
+	}
+	rc = dev->ops->tf_dev_get_tcam_slice_info(tfp,
+						  TF_TCAM_TBL_TYPE_WC_TCAM,
+						  0,
+						  num_slices);
+	return rc;
+}
+
+static bool
+tf_tcam_shared_db_valid(struct tf *tfp,
+			enum tf_dir dir)
+{
+	struct tcam_rm_db *tcam_db;
+	void *tcam_db_ptr = NULL;
+	int rc;
+
+	TF_CHECK_PARMS1(tfp);
+
+	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);
+	if (rc)
+		return false;
+
+	tcam_db = (struct tcam_rm_db *)tcam_db_ptr;
+
+	if (tcam_db->tcam_db[dir])
+		return true;
+
+	return false;
+}
+
+static int
+tf_tcam_shared_get_rm_info(struct tf *tfp,
+			   enum tf_dir dir,
+			   uint16_t *hcapi_type,
+			   struct tf_rm_alloc_info *info)
+{
+	int rc;
+	struct tcam_rm_db *tcam_db;
+	void *tcam_db_ptr = NULL;
+	struct tf_rm_get_alloc_info_parms ainfo;
+	struct tf_rm_get_hcapi_parms hparms;
+
+	TF_CHECK_PARMS3(tfp, hcapi_type, info);
+
+	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);
+	if (rc) {
+		TFP_DRV_LOG(INFO,
+			    "Tcam_db is not initialized, rc:%s\n",
+			    strerror(-rc));
+		return 0;
+	}
+	tcam_db = (struct tcam_rm_db *)tcam_db_ptr;
+
+	/* Convert TF type to HCAPI RM type */
+	memset(&hparms, 0, sizeof(hparms));
+	hparms.rm_db = tcam_db->tcam_db[dir];
+	hparms.subtype = TF_TCAM_TBL_TYPE_WC_TCAM;
+	hparms.hcapi_type = hcapi_type;
+
+	rc = tf_rm_get_hcapi_type(&hparms);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Get RM hcapi type failed %s\n",
+			    tf_dir_2_str(dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	memset(info, 0, sizeof(struct tf_rm_alloc_info));
+	ainfo.rm_db = tcam_db->tcam_db[dir];
+	ainfo.subtype = TF_TCAM_TBL_TYPE_WC_TCAM;
+	ainfo.info = info;
+
+	rc = tf_rm_get_info(&ainfo);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: TCAM rm info get failed %s\n",
+			    tf_dir_2_str(dir),
+			    strerror(-rc));
+		return rc;
+	}
+	return rc;
+}
+
+/**
+ * tf_tcam_shared_bind
+ */
+int
+tf_tcam_shared_bind(struct tf *tfp,
+		    struct tf_tcam_cfg_parms *parms)
+{
+	int rc, dir;
+	struct tf_session *tfs;
+	struct tf_dev_info *dev;
+	struct tf_rm_alloc_info info;
+	uint16_t start, stride;
+	uint16_t num_slices;
+	uint16_t hcapi_type;
+
+	TF_CHECK_PARMS2(tfp, parms);
+
+	/* Perform normal bind
+	 */
+	rc = tf_tcam_bind(tfp, parms);
+	if (rc)
+		return rc;
+
+	/* After the normal TCAM bind, if this is a shared session
+	 * create all required databases for the WC_HI and WC_LO pools
+	 */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Session access failure: %s\n", strerror(-rc));
+		return rc;
+	}
+	if (tf_session_is_shared_session(tfs)) {
+		/* Retrieve the device information */
+		rc = tf_session_get_device(tfs, &dev);
+		if (rc)
+			return rc;
+
+		rc = tf_tcam_shared_get_slices(tfp,
+					       dev,
+					       &num_slices);
+		if (rc)
+			return rc;
+
+		/* If there are WC TCAM entries, create 2 pools each with 1/2
+		 * the total number of entries
+		 */
+		for (dir = 0; dir < TF_DIR_MAX; dir++) {
+			if (!tf_tcam_shared_db_valid(tfp, dir))
+				continue;
+
+			rc = tf_tcam_shared_get_rm_info(tfp,
+							dir,
+							&hcapi_type,
+							&info);
+			if (rc) {
+				TFP_DRV_LOG(ERR,
+					    "%s: TCAM rm info get failed\n",
+					    tf_dir_2_str(dir));
+				goto done;
+			}
+
+			start = info.entry.start;
+			stride = info.entry.stride / 2;
+
+			tf_tcam_shared_create_wc_pool(dir,
+						TF_TCAM_SHARED_WC_POOL_HI,
+						start,
+						stride);
+
+			start += stride;
+			tf_tcam_shared_create_wc_pool(dir,
+						TF_TCAM_SHARED_WC_POOL_LO,
+						start,
+						stride);
+		}
+	}
+done:
+	return rc;
+}
+/**
+ * tf_tcam_shared_unbind
+ */
+int
+tf_tcam_shared_unbind(struct tf *tfp)
+{
+	int rc, dir;
+	struct tf_session *tfs;
+
+	TF_CHECK_PARMS1(tfp);
+
+	/* Perform normal unbind, this will write all the
+	 * allocated TCAM entries in the shared session.
+	 */
+	rc = tf_tcam_unbind(tfp);
+	if (rc)
+		return rc;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
+
+	/* If we are the shared session
+	 */
+	if (tf_session_is_shared_session(tfs)) {
+		/* If there are WC TCAM entries allocated, free them
+		 */
+		for (dir = 0; dir < TF_DIR_MAX; dir++) {
+			tf_tcam_shared_free_wc_pool(dir,
+						    TF_TCAM_SHARED_WC_POOL_HI);
+			tf_tcam_shared_free_wc_pool(dir,
+						    TF_TCAM_SHARED_WC_POOL_LO);
+		}
+	}
+	return 0;
+}
+/**
+ * tf_tcam_shared_alloc
+ */
+int
+tf_tcam_shared_alloc(struct tf *tfp,
+		     struct tf_tcam_alloc_parms *parms)
+{
+	int rc, i;
+	struct tf_session *tfs;
+	struct tf_dev_info *dev;
+	int log_idx;
+	struct bitalloc *pool;
+	enum tf_tcam_shared_wc_pool_id id;
+	uint16_t num_slices;
+
+	TF_CHECK_PARMS2(tfp, parms);
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
+
+	/* If we aren't the shared session or the type is
+	 * not one of the special WC TCAM types, call the normal
+	 * allocation.
+	 */
+	if (!tf_session_is_shared_session(tfs) ||
+	    (parms->type != TF_TCAM_TBL_TYPE_WC_TCAM_HIGH &&
+	     parms->type != TF_TCAM_TBL_TYPE_WC_TCAM_LOW)) {
+		/* Perform normal alloc
+		 */
+		rc = tf_tcam_alloc(tfp, parms);
+		return rc;
+	}
+
+	if (!tf_tcam_shared_db_valid(tfp, parms->dir)) {
+		TFP_DRV_LOG(ERR,
+			    "%s: tcam shared pool doesn't exist\n",
+			    tf_dir_2_str(parms->dir));
+		return -ENOMEM;
+	}
+
+	if (parms->type == TF_TCAM_TBL_TYPE_WC_TCAM_HIGH)
+		id = TF_TCAM_SHARED_WC_POOL_HI;
+	else
+		id = TF_TCAM_SHARED_WC_POOL_LO;
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc)
+		return rc;
+
+	rc = tf_tcam_shared_get_slices(tfp, dev, &num_slices);
+	if (rc)
+		return rc;
+
+	pool = tcam_shared_wc[parms->dir][id].pool;
+
+	for (i = 0; i < num_slices; i++) {
+		/*
+		 * priority  0: allocate from top of the tcam i.e. high
+		 * priority !0: allocate index from bottom i.e lowest
+		 */
+		if (parms->priority)
+			log_idx = ba_alloc_reverse(pool);
+		else
+			log_idx = ba_alloc(pool);
+		if (log_idx == BA_FAIL) {
+			TFP_DRV_LOG(ERR,
+				    "%s: Allocation failed, rc:%s\n",
+				    tf_dir_2_str(parms->dir),
+				    strerror(ENOMEM));
+			return -ENOMEM;
+		}
+		/* return the index without the start of each row */
+		if (i == 0)
+			parms->idx = log_idx;
+	}
+	return 0;
+}
+
+int
+tf_tcam_shared_free(struct tf *tfp,
+		    struct tf_tcam_free_parms *parms)
+{
+	int rc;
+	struct tf_session *tfs;
+	struct tf_dev_info *dev;
+	int allocated = 0;
+	int i;
+	uint16_t start;
+	int phy_idx;
+	struct bitalloc *pool;
+	enum tf_tcam_shared_wc_pool_id id;
+	struct tf_tcam_free_parms nparms;
+	uint16_t num_slices;
+	uint16_t hcapi_type;
+	struct tf_rm_alloc_info info;
+
+	TF_CHECK_PARMS2(tfp, parms);
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
+
+	/* If we aren't the shared session or the type is
+	 * not one of the special WC TCAM types, call the normal
+	 * allocation.
+	 */
+	if (!tf_session_is_shared_session(tfs) ||
+	    (parms->type != TF_TCAM_TBL_TYPE_WC_TCAM_HIGH &&
+	     parms->type != TF_TCAM_TBL_TYPE_WC_TCAM_LOW)) {
+		/* Perform normal free
+		 */
+		rc = tf_tcam_free(tfp, parms);
+		return rc;
+	}
+
+	if (!tf_tcam_shared_db_valid(tfp, parms->dir)) {
+		TFP_DRV_LOG(ERR,
+			    "%s: tcam shared pool doesn't exist\n",
+			    tf_dir_2_str(parms->dir));
+		return -ENOMEM;
+	}
+
+	if (parms->type == TF_TCAM_TBL_TYPE_WC_TCAM_HIGH)
+		id = TF_TCAM_SHARED_WC_POOL_HI;
+	else
+		id = TF_TCAM_SHARED_WC_POOL_LO;
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc)
+		return rc;
+
+	rc = tf_tcam_shared_get_slices(tfp, dev, &num_slices);
+	if (rc)
+		return rc;
+
+	rc = tf_tcam_shared_get_rm_info(tfp,
+					parms->dir,
+					&hcapi_type,
+					&info);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: TCAM rm info get failed\n",
+			    tf_dir_2_str(parms->dir));
+		return rc;
+	}
+
+	pool = tcam_shared_wc[parms->dir][id].pool;
+	start = tcam_shared_wc[parms->dir][id].info.start;
+
+	if (parms->idx % num_slices) {
+		TFP_DRV_LOG(ERR,
+			    "%s: TCAM reserved resource is not multiple of %d\n",
+			    tf_dir_2_str(parms->dir), num_slices);
+		return -EINVAL;
+	}
+
+	phy_idx = parms->idx + start;
+	allocated = ba_inuse(pool, parms->idx);
+
+	if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Entry already free, type:%d, idx:%d\n",
+			    tf_dir_2_str(parms->dir), parms->type, parms->idx);
+		return -EINVAL;
+	}
+
+	for (i = 0; i < num_slices; i++) {
+		rc = ba_free(pool, parms->idx + i);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "%s: Free failed, type:%s, idx:%d\n",
+				    tf_dir_2_str(parms->dir),
+				    tf_tcam_tbl_2_str(parms->type),
+				    parms->idx);
+			return rc;
+		}
+	}
+
+	/* Override HI/LO type with parent WC TCAM type */
+	nparms = *parms;
+	nparms.type = TF_TCAM_TBL_TYPE_WC_TCAM;
+	nparms.hcapi_type = hcapi_type;
+	nparms.idx = phy_idx;
+
+	rc = tf_msg_tcam_entry_free(tfp, dev, &nparms);
+	if (rc) {
+		/* Log error */
+		TFP_DRV_LOG(ERR,
+			    "%s: %s: log%d free failed, rc:%s\n",
+			    tf_dir_2_str(nparms.dir),
+			    tf_tcam_tbl_2_str(nparms.type),
+			    phy_idx,
+			    strerror(-rc));
+		return rc;
+	}
+	return 0;
+}
+
+int
+tf_tcam_shared_set(struct tf *tfp __rte_unused,
+		   struct tf_tcam_set_parms *parms __rte_unused)
+{
+	int rc;
+	struct tf_session *tfs;
+	struct tf_dev_info *dev;
+	int allocated = 0;
+	int phy_idx, log_idx;
+	uint16_t num_slices;
+	struct tf_tcam_set_parms nparms;
+	struct bitalloc *pool;
+	uint16_t start;
+	enum tf_tcam_shared_wc_pool_id id;
+	uint16_t hcapi_type;
+	struct tf_rm_alloc_info info;
+
+	TF_CHECK_PARMS2(tfp, parms);
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
+
+	/* If we aren't the shared session or one of our
+	 * special types
+	 */
+	if (!tf_session_is_shared_session(tfs) ||
+	    (parms->type != TF_TCAM_TBL_TYPE_WC_TCAM_HIGH &&
+	     parms->type != TF_TCAM_TBL_TYPE_WC_TCAM_LOW)) {
+		/* Perform normal set and exit
+		 */
+		rc = tf_tcam_set(tfp, parms);
+		return rc;
+	}
+
+	if (!tf_tcam_shared_db_valid(tfp, parms->dir)) {
+		TFP_DRV_LOG(ERR,
+			    "%s: tcam shared pool doesn't exist\n",
+			    tf_dir_2_str(parms->dir));
+		return -ENOMEM;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc)
+		return rc;
+
+	if (parms->type == TF_TCAM_TBL_TYPE_WC_TCAM_HIGH)
+		id = TF_TCAM_SHARED_WC_POOL_HI;
+	else
+		id = TF_TCAM_SHARED_WC_POOL_LO;
+
+	pool = tcam_shared_wc[parms->dir][id].pool;
+	start = tcam_shared_wc[parms->dir][id].info.start;
+
+	log_idx = parms->idx;
+	phy_idx = parms->idx + start;
+	allocated = ba_inuse(pool, parms->idx);
+
+	if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Entry is not allocated, type:%d, logid:%d\n",
+			    tf_dir_2_str(parms->dir), parms->type, log_idx);
+		return -EINVAL;
+	}
+	rc = tf_tcam_shared_get_slices(tfp, dev, &num_slices);
+	if (rc)
+		return rc;
+
+	if (parms->idx % num_slices) {
+		TFP_DRV_LOG(ERR,
+			    "%s: TCAM reserved resource is not multiple of %d\n",
+			    tf_dir_2_str(parms->dir), num_slices);
+		return -EINVAL;
+	}
+	rc = tf_tcam_shared_get_rm_info(tfp,
+					parms->dir,
+					&hcapi_type,
+					&info);
+	if (rc)
+		return rc;
+
+	/* Override HI/LO type with parent WC TCAM type */
+	nparms.hcapi_type = hcapi_type;
+	nparms.dir = parms->dir;
+	nparms.type = TF_TCAM_TBL_TYPE_WC_TCAM;
+	nparms.idx = phy_idx;
+	nparms.key = parms->key;
+	nparms.mask = parms->mask;
+	nparms.key_size = parms->key_size;
+	nparms.result = parms->result;
+	nparms.result_size = parms->result_size;
+
+	rc = tf_msg_tcam_entry_set(tfp, dev, &nparms);
+	if (rc) {
+		/* Log error */
+		TFP_DRV_LOG(ERR,
+			    "%s: %s: phy entry %d set failed, rc:%s",
+			    tf_dir_2_str(parms->dir),
+			    tf_tcam_tbl_2_str(nparms.type),
+			    phy_idx,
+			    strerror(-rc));
+		return rc;
+	}
+	return 0;
+}
+
+int
+tf_tcam_shared_get(struct tf *tfp __rte_unused,
+		   struct tf_tcam_get_parms *parms)
+{
+	int rc;
+	struct tf_session *tfs;
+	struct tf_dev_info *dev;
+	int allocated = 0;
+	int phy_idx, log_idx;
+	uint16_t num_slices;
+	struct tf_tcam_get_parms nparms;
+	struct bitalloc *pool;
+	uint16_t start;
+	enum tf_tcam_shared_wc_pool_id id;
+	uint16_t hcapi_type;
+	struct tf_rm_alloc_info info;
+
+	TF_CHECK_PARMS2(tfp, parms);
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
+
+	/* If we aren't the shared session or one of our
+	 * special types
+	 */
+	if (!tf_session_is_shared_session(tfs) ||
+	    (parms->type != TF_TCAM_TBL_TYPE_WC_TCAM_HIGH &&
+	     parms->type != TF_TCAM_TBL_TYPE_WC_TCAM_LOW)) {
+		/* Perform normal get and exit
+		 */
+		rc = tf_tcam_get(tfp, parms);
+		return rc;
+	}
+
+	if (!tf_tcam_shared_db_valid(tfp, parms->dir)) {
+		TFP_DRV_LOG(ERR,
+			    "%s: tcam shared pool doesn't exist\n",
+			    tf_dir_2_str(parms->dir));
+		return -ENOMEM;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc)
+		return rc;
+	if (parms->type == TF_TCAM_TBL_TYPE_WC_TCAM_HIGH)
+		id = TF_TCAM_SHARED_WC_POOL_HI;
+	else
+		id = TF_TCAM_SHARED_WC_POOL_LO;
+
+	pool = tcam_shared_wc[parms->dir][id].pool;
+	start = tcam_shared_wc[parms->dir][id].info.start;
+
+	rc = tf_tcam_shared_get_slices(tfp, dev, &num_slices);
+	if (rc)
+		return rc;
+
+	if (parms->idx % num_slices) {
+		TFP_DRV_LOG(ERR,
+			    "%s: TCAM reserved resource is not multiple of %d\n",
+			    tf_dir_2_str(parms->dir), num_slices);
+		return -EINVAL;
+	}
+	log_idx = parms->idx;
+	phy_idx = parms->idx + start;
+	allocated = ba_inuse(pool, parms->idx);
+
+	if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Entry is not allocated, type:%d, logid:%d\n",
+			    tf_dir_2_str(parms->dir), parms->type, log_idx);
+		return -EINVAL;
+	}
+
+	rc = tf_tcam_shared_get_rm_info(tfp,
+					parms->dir,
+					&hcapi_type,
+					&info);
+	if (rc)
+		return rc;
+
+	/* Override HI/LO type with parent WC TCAM type */
+	nparms = *parms;
+	nparms.type = TF_TCAM_TBL_TYPE_WC_TCAM;
+	nparms.hcapi_type = hcapi_type;
+	nparms.idx = phy_idx;
+
+	rc = tf_msg_tcam_entry_get(tfp, dev, &nparms);
+	if (rc) {
+		/* Log error */
+		TFP_DRV_LOG(ERR,
+			    "%s: %s: Entry %d set failed, rc:%s",
+			    tf_dir_2_str(nparms.dir),
+			    tf_tcam_tbl_2_str(nparms.type),
+			    nparms.idx,
+			    strerror(-rc));
+		return rc;
+	}
+	return 0;
+}
diff --git a/drivers/net/bnxt/tf_core/tf_tcam_shared.h b/drivers/net/bnxt/tf_core/tf_tcam_shared.h
new file mode 100644
index 0000000000..fad6e23b4c
--- /dev/null
+++ b/drivers/net/bnxt/tf_core/tf_tcam_shared.h
@@ -0,0 +1,127 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019-2021 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _TF_TCAM_SHARED_H_
+#define _TF_TCAM_SHARED_H_
+
+#include "tf_core.h"
+#include "tf_tcam.h"
+
+/**
+ * @page tcam_shared TCAM SHARED
+ *
+ * @ref tf_tcam_shared_bind
+ *
+ * @ref tf_tcam_shared_unbind
+ *
+ * @ref tf_tcam_shared_alloc
+ *
+ * @ref tf_tcam_shared_free
+ *
+ * @ref tf_tcam_shared_set
+ *
+ * @ref tf_tcam_shared_get
+ *
+ */
+
+/**
+ * Initializes the TCAM shared module with the requested DBs. Must be
+ * invoked as the first thing before any of the access functions.
+ *
+ * [in] tfp
+ *   Pointer to the truflow handle
+ *
+ * [in] parms
+ *   Pointer to parameters
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+int tf_tcam_shared_bind(struct tf *tfp,
+			struct tf_tcam_cfg_parms *parms);
+
+/**
+ * Cleans up the private DBs and releases all the data.
+ *
+ * [in] tfp
+ *   Pointer to the truflow handle
+ *
+ * [in] parms
+ *   Pointer to parameters
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+int tf_tcam_shared_unbind(struct tf *tfp);
+
+/**
+ * Allocates the requested tcam type from the internal RM DB.
+ *
+ * [in] tfp
+ *   Pointer to the truflow handle
+ *
+ * [in] parms
+ *   Pointer to parameters
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+int tf_tcam_shared_alloc(struct tf *tfp,
+			 struct tf_tcam_alloc_parms *parms);
+
+/**
+ * Free's the requested table type and returns it to the DB.
+ *
+ * [in] tfp
+ *   Pointer to the truflow handle
+ *
+ * [in] parms
+ *   Pointer to parameters
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+int tf_tcam_shared_free(struct tf *tfp,
+			struct tf_tcam_free_parms *parms);
+
+/**
+ * Configures the requested element by sending a firmware request which
+ * then installs it into the device internal structures.
+ *
+ * [in] tfp
+ *   Pointer to the truflow handle
+ *
+ * [in] parms
+ *   Pointer to parameters
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+int tf_tcam_shared_set(struct tf *tfp,
+		       struct tf_tcam_set_parms *parms);
+
+/**
+ * Retrieves the requested element by sending a firmware request to get
+ * the element.
+ *
+ * [in] tfp
+ *   Pointer to the truflow handle
+ *
+ * [in] parms
+ *   Pointer to parameters
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+int tf_tcam_shared_get(struct tf *tfp,
+		       struct tf_tcam_get_parms *parms);
+
+#endif /* _TF_TCAM_SHARED_H */
diff --git a/drivers/net/bnxt/tf_core/tf_util.c b/drivers/net/bnxt/tf_core/tf_util.c
index 25f5c152d2..e712816209 100644
--- a/drivers/net/bnxt/tf_core/tf_util.c
+++ b/drivers/net/bnxt/tf_core/tf_util.c
@@ -59,6 +59,12 @@ tf_tcam_tbl_2_str(enum tf_tcam_tbl_type tcam_type)
 		return "sp_tcam";
 	case TF_TCAM_TBL_TYPE_CT_RULE_TCAM:
 		return "ct_rule_tcam";
+#ifdef TF_TCAM_SHARED
+	case TF_TCAM_TBL_TYPE_WC_TCAM_HIGH:
+		return "wc_tcam_hi";
+	case TF_TCAM_TBL_TYPE_WC_TCAM_LOW:
+		return "wc_tcam_lo";
+#endif
 	default:
 		return "Invalid tcam table type";
 	}
-- 
2.17.1


^ permalink raw reply	[flat|nested] 129+ messages in thread

* [dpdk-dev] [PATCH 19/58] net/bnxt: cleanup session open/close messages
  2021-05-30  8:58 [dpdk-dev] [PATCH 00/58] enhancements to host based flow table management Venkat Duvvuru
                   ` (17 preceding siblings ...)
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 18/58] net/bnxt: shared TCAM region support Venkat Duvvuru
@ 2021-05-30  8:58 ` Venkat Duvvuru
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 20/58] net/bnxt: add WC TCAM hi/lo move support Venkat Duvvuru
                   ` (39 subsequent siblings)
  58 siblings, 0 replies; 129+ messages in thread
From: Venkat Duvvuru @ 2021-05-30  8:58 UTC (permalink / raw)
  To: dev; +Cc: Farah Smith, Jay Ding, Randy Schacher, Venkat Duvvuru

From: Farah Smith <farah.smith@broadcom.com>

Add profile_id to set_prof_tcam.

Signed-off-by: Farah Smith <farah.smith@broadcom.com>
Signed-off-by: Jay Ding <jay.ding@broadcom.com>
Signed-off-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Randy Schacher <stuart.schacher@broadcom.com>
Reviewed-by: Peter Spreadborough <peter.spreadborough@broadcom.com>
---
 drivers/net/bnxt/tf_core/tf_device.c      | 90 ++++++++++++-----------
 drivers/net/bnxt/tf_core/tf_em_internal.c | 13 +---
 drivers/net/bnxt/tf_core/tf_identifier.c  | 15 +---
 drivers/net/bnxt/tf_core/tf_if_tbl.c      | 18 +----
 drivers/net/bnxt/tf_core/tf_session.c     | 18 +++--
 drivers/net/bnxt/tf_core/tf_tbl.c         | 18 ++---
 drivers/net/bnxt/tf_core/tf_tcam.c        | 12 +--
 7 files changed, 77 insertions(+), 107 deletions(-)

diff --git a/drivers/net/bnxt/tf_core/tf_device.c b/drivers/net/bnxt/tf_core/tf_device.c
index 55cf55886a..498e668b16 100644
--- a/drivers/net/bnxt/tf_core/tf_device.c
+++ b/drivers/net/bnxt/tf_core/tf_device.c
@@ -216,20 +216,20 @@ tf_dev_bind_p4(struct tf *tfp,
 		return -ENOMEM;
 	}
 
-	if (!tf_session_is_shared_session(tfs)) {
-		/*
-		 * IF_TBL
-		 */
-		if_tbl_cfg.num_elements = TF_IF_TBL_TYPE_MAX;
-		if_tbl_cfg.cfg = tf_if_tbl_p4;
-		if_tbl_cfg.shadow_copy = shadow_copy;
-		rc = tf_if_tbl_bind(tfp, &if_tbl_cfg);
-		if (rc) {
-			TFP_DRV_LOG(ERR,
-				    "IF Table initialization failure\n");
-			goto fail;
-		}
+	/*
+	 * IF_TBL
+	 */
+	if_tbl_cfg.num_elements = TF_IF_TBL_TYPE_MAX;
+	if_tbl_cfg.cfg = tf_if_tbl_p4;
+	if_tbl_cfg.shadow_copy = shadow_copy;
+	rc = tf_if_tbl_bind(tfp, &if_tbl_cfg);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "IF Table initialization failure\n");
+		goto fail;
+	}
 
+	if (!tf_session_is_shared_session(tfs)) {
 		/*
 		 * GLOBAL_CFG
 		 */
@@ -271,6 +271,12 @@ tf_dev_unbind_p4(struct tf *tfp)
 {
 	int rc = 0;
 	bool fail = false;
+	struct tf_session *tfs;
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
 
 	/* Unbind all the support modules. As this is only done on
 	 * close we only report errors as everything has to be cleaned
@@ -318,18 +324,20 @@ tf_dev_unbind_p4(struct tf *tfp)
 		fail = true;
 	}
 
-	rc = tf_if_tbl_unbind(tfp);
-	if (rc) {
-		TFP_DRV_LOG(INFO,
-			    "Device unbind failed, IF Table Type\n");
-		fail = true;
-	}
+	if (!tf_session_is_shared_session(tfs)) {
+		rc = tf_if_tbl_unbind(tfp);
+		if (rc) {
+			TFP_DRV_LOG(INFO,
+				    "Device unbind failed, IF Table Type\n");
+			fail = true;
+		}
 
-	rc = tf_global_cfg_unbind(tfp);
-	if (rc) {
-		TFP_DRV_LOG(INFO,
-			    "Device unbind failed, Global Cfg Type\n");
-		fail = true;
+		rc = tf_global_cfg_unbind(tfp);
+		if (rc) {
+			TFP_DRV_LOG(INFO,
+				    "Device unbind failed, Global Cfg Type\n");
+			fail = true;
+		}
 	}
 
 	if (fail)
@@ -472,17 +480,17 @@ tf_dev_bind_p58(struct tf *tfp,
 	/*
 	 * IF_TBL
 	 */
-	if (!tf_session_is_shared_session(tfs)) {
-		if_tbl_cfg.num_elements = TF_IF_TBL_TYPE_MAX;
-		if_tbl_cfg.cfg = tf_if_tbl_p58;
-		if_tbl_cfg.shadow_copy = shadow_copy;
-		rc = tf_if_tbl_bind(tfp, &if_tbl_cfg);
-		if (rc) {
-			TFP_DRV_LOG(ERR,
-				    "IF Table initialization failure\n");
-			goto fail;
-		}
+	if_tbl_cfg.num_elements = TF_IF_TBL_TYPE_MAX;
+	if_tbl_cfg.cfg = tf_if_tbl_p58;
+	if_tbl_cfg.shadow_copy = shadow_copy;
+	rc = tf_if_tbl_bind(tfp, &if_tbl_cfg);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "IF Table initialization failure\n");
+		goto fail;
+	}
 
+	if (!tf_session_is_shared_session(tfs)) {
 		/*
 		 * GLOBAL_CFG
 		 */
@@ -571,14 +579,14 @@ tf_dev_unbind_p58(struct tf *tfp)
 		fail = true;
 	}
 
-	if (!tf_session_is_shared_session(tfs)) {
-		rc = tf_if_tbl_unbind(tfp);
-		if (rc) {
-			TFP_DRV_LOG(ERR,
-				    "Device unbind failed, IF Table Type\n");
-			fail = true;
-		}
+	rc = tf_if_tbl_unbind(tfp);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Device unbind failed, IF Table Type\n");
+		fail = true;
+	}
 
+	if (!tf_session_is_shared_session(tfs)) {
 		rc = tf_global_cfg_unbind(tfp);
 		if (rc) {
 			TFP_DRV_LOG(ERR,
diff --git a/drivers/net/bnxt/tf_core/tf_em_internal.c b/drivers/net/bnxt/tf_core/tf_em_internal.c
index 93de513989..28ffbd5876 100644
--- a/drivers/net/bnxt/tf_core/tf_em_internal.c
+++ b/drivers/net/bnxt/tf_core/tf_em_internal.c
@@ -412,17 +412,13 @@ tf_em_int_bind(struct tf *tfp,
 			db_rc[i] = tf_rm_create_db_no_reservation(tfp, &db_cfg);
 		else
 			db_rc[i] = tf_rm_create_db(tfp, &db_cfg);
-		if (db_rc[i]) {
-			TFP_DRV_LOG(ERR,
-				    "%s: EM Int DB creation failed\n",
-				    tf_dir_2_str(i));
-
-		}
 	}
 
 	/* No db created */
-	if (db_rc[TF_DIR_RX] && db_rc[TF_DIR_TX])
+	if (db_rc[TF_DIR_RX] && db_rc[TF_DIR_TX]) {
+		TFP_DRV_LOG(ERR, "EM Int DB creation failed\n");
 		return db_rc[TF_DIR_RX];
+	}
 
 
 	if (!tf_session_is_shared_session(tfs)) {
@@ -514,9 +510,6 @@ tf_em_int_unbind(struct tf *tfp)
 
 	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_EM, &em_db_ptr);
 	if (rc) {
-		TFP_DRV_LOG(INFO,
-			    "Em_db is not initialized, rc:%s\n",
-			    strerror(-rc));
 		return 0;
 	}
 	em_db = (struct em_rm_db *)em_db_ptr;
diff --git a/drivers/net/bnxt/tf_core/tf_identifier.c b/drivers/net/bnxt/tf_core/tf_identifier.c
index 3575c3e1a0..9f27a41fcf 100644
--- a/drivers/net/bnxt/tf_core/tf_identifier.c
+++ b/drivers/net/bnxt/tf_core/tf_identifier.c
@@ -74,11 +74,6 @@ tf_ident_bind(struct tf *tfp,
 			db_rc[i] = tf_rm_create_db_no_reservation(tfp, &db_cfg);
 		else
 			db_rc[i] = tf_rm_create_db(tfp, &db_cfg);
-		if (db_rc[i]) {
-			TFP_DRV_LOG(INFO,
-				    "%s: No Identifier DB required\n",
-				    tf_dir_2_str(i));
-		}
 
 		if (parms->shadow_copy) {
 			shadow_cfg.alloc_cnt =
@@ -99,8 +94,10 @@ tf_ident_bind(struct tf *tfp,
 	}
 
 	/* No db created */
-	if (db_rc[TF_DIR_RX] && db_rc[TF_DIR_TX])
+	if (db_rc[TF_DIR_RX] && db_rc[TF_DIR_TX]) {
+		TFP_DRV_LOG(ERR, "No Identifier DB created\n");
 		return db_rc[TF_DIR_RX];
+	}
 
 	TFP_DRV_LOG(INFO,
 		    "Identifier - initialized\n");
@@ -121,12 +118,8 @@ tf_ident_unbind(struct tf *tfp)
 	TF_CHECK_PARMS1(tfp);
 
 	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr);
-	if (rc) {
-		TFP_DRV_LOG(INFO,
-			    "Ident_db is not initialized, rc:%s\n",
-			    strerror(-rc));
+	if (rc)
 		return 0;
-	}
 	ident_db = (struct ident_rm_db *)ident_db_ptr;
 
 	for (i = 0; i < TF_DIR_MAX; i++) {
diff --git a/drivers/net/bnxt/tf_core/tf_if_tbl.c b/drivers/net/bnxt/tf_core/tf_if_tbl.c
index f58fa79b63..762dac0473 100644
--- a/drivers/net/bnxt/tf_core/tf_if_tbl.c
+++ b/drivers/net/bnxt/tf_core/tf_if_tbl.c
@@ -16,24 +16,16 @@ struct tf;
 
 /**
  * IF Table DBs.
+ * TODO: Store this data in session db
  */
 static void *if_tbl_db[TF_DIR_MAX];
 
-/**
- * IF Table Shadow DBs
- */
-/* static void *shadow_if_tbl_db[TF_DIR_MAX]; */
-
 /**
  * Init flag, set on bind and cleared on unbind
+ * TODO: Store this data in session db
  */
 static uint8_t init;
 
-/**
- * Shadow init flag, set on bind and cleared on unbind
- */
-/* static uint8_t shadow_init; */
-
 /**
  * Convert if_tbl_type to hwrm type.
  *
@@ -70,12 +62,6 @@ tf_if_tbl_bind(struct tf *tfp __rte_unused,
 {
 	TF_CHECK_PARMS2(tfp, parms);
 
-	if (init) {
-		TFP_DRV_LOG(ERR,
-			    "IF TBL DB already initialized\n");
-		return -EINVAL;
-	}
-
 	if_tbl_db[TF_DIR_RX] = parms->cfg;
 	if_tbl_db[TF_DIR_TX] = parms->cfg;
 
diff --git a/drivers/net/bnxt/tf_core/tf_session.c b/drivers/net/bnxt/tf_core/tf_session.c
index 93876d8e5d..e6ab518121 100644
--- a/drivers/net/bnxt/tf_core/tf_session.c
+++ b/drivers/net/bnxt/tf_core/tf_session.c
@@ -425,9 +425,11 @@ tf_session_open_session(struct tf *tfp,
 		}
 
 		TFP_DRV_LOG(INFO,
-		       "Session created, session_client_id:%d, session_id:%d\n",
+		       "Session created, session_client_id:%d,"
+		       "session_id:0x%08x, fw_session_id:%d\n",
 		       parms->open_cfg->session_client_id.id,
-		       parms->open_cfg->session_id.id);
+		       parms->open_cfg->session_id.id,
+		       parms->open_cfg->session_id.internal.fw_session_id);
 	} else {
 		scparms.ctrl_chan_name = parms->open_cfg->ctrl_chan_name;
 		scparms.session_client_id = &parms->open_cfg->session_client_id;
@@ -438,16 +440,16 @@ tf_session_open_session(struct tf *tfp,
 		rc = tf_session_client_create(tfp, &scparms);
 		if (rc) {
 			TFP_DRV_LOG(ERR,
-			      "Failed to create client on session %d, rc:%s\n",
+			      "Failed to create client on session 0x%x, rc:%s\n",
 			      parms->open_cfg->session_id.id,
 			      strerror(-rc));
 			return rc;
 		}
 
 		TFP_DRV_LOG(INFO,
-			    "Session Client:%d created on session:%d\n",
-			    parms->open_cfg->session_client_id.id,
-			    parms->open_cfg->session_id.id);
+			"Session Client:%d registered on session:0x%8x\n",
+			scparms.session_client_id->internal.fw_session_client_id,
+			tfp->session->session_id.id);
 	}
 
 	return 0;
@@ -541,7 +543,7 @@ tf_session_close_session(struct tf *tfp,
 			    client->session_client_id.id);
 
 		TFP_DRV_LOG(INFO,
-			    "session_id:%d, ref_count:%d\n",
+			    "session_id:0x%08x, ref_count:%d\n",
 			    tfs->session_id.id,
 			    tfs->ref_count);
 
@@ -587,7 +589,7 @@ tf_session_close_session(struct tf *tfp,
 	tfs->ref_count--;
 
 	TFP_DRV_LOG(INFO,
-		    "Closed session, session_id:%d, ref_count:%d\n",
+		    "Closed session, session_id:0x%08x, ref_count:%d\n",
 		    tfs->session_id.id,
 		    tfs->ref_count);
 
diff --git a/drivers/net/bnxt/tf_core/tf_tbl.c b/drivers/net/bnxt/tf_core/tf_tbl.c
index 295204ac87..6842291adf 100644
--- a/drivers/net/bnxt/tf_core/tf_tbl.c
+++ b/drivers/net/bnxt/tf_core/tf_tbl.c
@@ -83,17 +83,15 @@ tf_tbl_bind(struct tf *tfp,
 			db_rc[d] = tf_rm_create_db_no_reservation(tfp, &db_cfg);
 		else
 			db_rc[d] = tf_rm_create_db(tfp, &db_cfg);
-		if (db_rc[d]) {
-			TFP_DRV_LOG(ERR,
-				    "%s: No Table DB creation required\n",
-				    tf_dir_2_str(d));
-
-		}
 	}
 
 	/* No db created */
-	if (db_rc[TF_DIR_RX] && db_rc[TF_DIR_TX])
+	if (db_rc[TF_DIR_RX] && db_rc[TF_DIR_TX]) {
+		TFP_DRV_LOG(ERR,
+			    "%s: No Table DB created\n",
+			    tf_dir_2_str(d));
 		return db_rc[TF_DIR_RX];
+	}
 
 	TFP_DRV_LOG(INFO,
 		    "Table Type - initialized\n");
@@ -112,12 +110,8 @@ tf_tbl_unbind(struct tf *tfp)
 	TF_CHECK_PARMS1(tfp);
 
 	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
-	if (rc) {
-		TFP_DRV_LOG(INFO,
-			    "Tbl_db is not initialized, rc:%s\n",
-			    strerror(-rc));
+	if (rc)
 		return 0;
-	}
 	tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
 
 	for (i = 0; i < TF_DIR_MAX; i++) {
diff --git a/drivers/net/bnxt/tf_core/tf_tcam.c b/drivers/net/bnxt/tf_core/tf_tcam.c
index 5c018f7003..7878f8727a 100644
--- a/drivers/net/bnxt/tf_core/tf_tcam.c
+++ b/drivers/net/bnxt/tf_core/tf_tcam.c
@@ -113,16 +113,13 @@ tf_tcam_bind(struct tf *tfp,
 			db_rc[d] = tf_rm_create_db_no_reservation(tfp, &db_cfg);
 		else
 			db_rc[d] = tf_rm_create_db(tfp, &db_cfg);
-		if (db_rc[d]) {
-			TFP_DRV_LOG(INFO,
-				    "%s: no TCAM DB required\n",
-				    tf_dir_2_str(d));
-		}
 	}
 
 	/* No db created */
-	if (db_rc[TF_DIR_RX] && db_rc[TF_DIR_TX])
+	if (db_rc[TF_DIR_RX] && db_rc[TF_DIR_TX]) {
+		TFP_DRV_LOG(ERR, "No TCAM DB created\n");
 		return db_rc[TF_DIR_RX];
+	}
 
 	/* check if reserved resource for WC is multiple of num_slices */
 	for (d = 0; d < TF_DIR_MAX; d++) {
@@ -227,9 +224,6 @@ tf_tcam_unbind(struct tf *tfp)
 
 	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);
 	if (rc) {
-		TFP_DRV_LOG(INFO,
-			    "Tcam_db is not initialized, rc:%s\n",
-			    strerror(-rc));
 		return 0;
 	}
 	tcam_db = (struct tcam_rm_db *)tcam_db_ptr;
-- 
2.17.1


^ permalink raw reply	[flat|nested] 129+ messages in thread

* [dpdk-dev] [PATCH 20/58] net/bnxt: add WC TCAM hi/lo move support
  2021-05-30  8:58 [dpdk-dev] [PATCH 00/58] enhancements to host based flow table management Venkat Duvvuru
                   ` (18 preceding siblings ...)
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 19/58] net/bnxt: cleanup session open/close messages Venkat Duvvuru
@ 2021-05-30  8:58 ` Venkat Duvvuru
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 21/58] net/bnxt: add API to get shared table increments Venkat Duvvuru
                   ` (38 subsequent siblings)
  58 siblings, 0 replies; 129+ messages in thread
From: Venkat Duvvuru @ 2021-05-30  8:58 UTC (permalink / raw)
  To: dev; +Cc: Farah Smith, Randy Schacher, Venkat Duvvuru

From: Farah Smith <farah.smith@broadcom.com>

- Add new API to move wc tcam regions from the hi pool
  to the low pool.
- Enable shared tcam get/set functions on Thor.

Signed-off-by: Farah Smith <farah.smith@broadcom.com>
Signed-off-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Randy Schacher <stuart.schacher@broadcom.com>
---
 drivers/net/bnxt/tf_core/tf_core.c        |  53 +++
 drivers/net/bnxt/tf_core/tf_core.h        |  39 ++
 drivers/net/bnxt/tf_core/tf_device.h      |  18 +
 drivers/net/bnxt/tf_core/tf_device_p4.c   |   1 +
 drivers/net/bnxt/tf_core/tf_device_p58.c  |   5 +-
 drivers/net/bnxt/tf_core/tf_session.c     |  41 ++
 drivers/net/bnxt/tf_core/tf_session.h     |  48 +++
 drivers/net/bnxt/tf_core/tf_tcam.c        |   2 +-
 drivers/net/bnxt/tf_core/tf_tcam_shared.c | 468 ++++++++++++++++++++--
 drivers/net/bnxt/tf_core/tf_tcam_shared.h |  35 ++
 10 files changed, 673 insertions(+), 37 deletions(-)

diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c
index de2a93646f..73dbee2940 100644
--- a/drivers/net/bnxt/tf_core/tf_core.c
+++ b/drivers/net/bnxt/tf_core/tf_core.c
@@ -917,6 +917,59 @@ tf_free_tcam_entry(struct tf *tfp,
 	return 0;
 }
 
+#ifdef TF_TCAM_SHARED
+int
+tf_move_tcam_shared_entries(struct tf *tfp,
+			    struct tf_move_tcam_shared_entries_parms *parms)
+{
+	int rc;
+	struct tf_session *tfs;
+	struct tf_dev_info *dev;
+
+	TF_CHECK_PARMS2(tfp, parms);
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup device, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	if (dev->ops->tf_dev_move_tcam == NULL) {
+		rc = -EOPNOTSUPP;
+		TFP_DRV_LOG(ERR,
+			    "%s: Operation not supported, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	rc = dev->ops->tf_dev_move_tcam(tfp, parms);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: TCAM shared entries move failed, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	return 0;
+}
+#endif /* TF_TCAM_SHARED */
+
 int
 tf_alloc_tbl_entry(struct tf *tfp,
 		   struct tf_alloc_tbl_entry_parms *parms)
diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h
index 39a498122b..95cde2e8eb 100644
--- a/drivers/net/bnxt/tf_core/tf_core.h
+++ b/drivers/net/bnxt/tf_core/tf_core.h
@@ -1242,6 +1242,10 @@ int tf_free_tbl_scope(struct tf *tfp,
  * @ref tf_get_tcam_entry
  *
  * @ref tf_free_tcam_entry
+ *
+#ifdef TF_TCAM_SHARED
+ * @ref tf_move_tcam_shared_entries
+#endif
  */
 
 /**
@@ -1543,6 +1547,41 @@ struct tf_free_tcam_entry_parms {
 int tf_free_tcam_entry(struct tf *tfp,
 		       struct tf_free_tcam_entry_parms *parms);
 
+#ifdef TF_TCAM_SHARED
+/**
+ * tf_move_tcam_shared_entries parameter definition
+ */
+struct tf_move_tcam_shared_entries_parms {
+	/**
+	 * [in] receive or transmit direction
+	 */
+	enum tf_dir dir;
+	/**
+	 * [in] TCAM table type
+	 */
+	enum tf_tcam_tbl_type tcam_tbl_type;
+};
+
+/**
+ * Move TCAM entries
+ *
+ * This API only affects the following TCAM pools within a shared session:
+ *
+ * TF_TCAM_TBL_TYPE_WC_TCAM_HIGH
+ * TF_TCAM_TBL_TYPE_WC_TCAM_LOW
+ *
+ * When called, all allocated entries from the high pool will be moved to
+ * the low pool.  Then the allocated entries in the high pool will be
+ * cleared and freed.
+ *
+ * This API is not supported on a non-shared session.
+ *
+ * Returns success or failure code.
+ */
+int tf_move_tcam_shared_entries(struct tf *tfp,
+				struct tf_move_tcam_shared_entries_parms *parms);
+
+#endif /* TF_TCAM_SHARED */
 /**
  * @page table Table Access
  *
diff --git a/drivers/net/bnxt/tf_core/tf_device.h b/drivers/net/bnxt/tf_core/tf_device.h
index ea4dcfb8e2..48ab17d56b 100644
--- a/drivers/net/bnxt/tf_core/tf_device.h
+++ b/drivers/net/bnxt/tf_core/tf_device.h
@@ -563,6 +563,24 @@ struct tf_dev_ops {
 	int (*tf_dev_get_tcam)(struct tf *tfp,
 			       struct tf_tcam_get_parms *parms);
 
+#ifdef TF_TCAM_SHARED
+	/**
+	 * Move TCAM shared entries
+	 *
+	 * [in] tfp
+	 *   Pointer to TF handle
+	 *
+	 * [in] parms
+	 *   Pointer to parameters
+	 *
+	 *    returns:
+	 *    0       - Success
+	 *    -EINVAL - Error
+	 */
+	int (*tf_dev_move_tcam)(struct tf *tfp,
+				struct tf_move_tcam_shared_entries_parms *parms);
+#endif /* TF_TCAM_SHARED */
+
 	/**
 	 * Retrieves the tcam resource info.
 	 *
diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.c b/drivers/net/bnxt/tf_core/tf_device_p4.c
index fccbccc2d8..c870f45ff0 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p4.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p4.c
@@ -275,6 +275,7 @@ const struct tf_dev_ops tf_dev_ops_p4 = {
 	.tf_dev_free_tcam = tf_tcam_shared_free,
 	.tf_dev_set_tcam = tf_tcam_shared_set,
 	.tf_dev_get_tcam = tf_tcam_shared_get,
+	.tf_dev_move_tcam = tf_tcam_shared_move_p4,
 #else /* !TF_TCAM_SHARED */
 	.tf_dev_alloc_tcam = tf_tcam_alloc,
 	.tf_dev_free_tcam = tf_tcam_free,
diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c
index b25c5acf94..14b9d28b13 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p58.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p58.c
@@ -295,8 +295,9 @@ const struct tf_dev_ops tf_dev_ops_p58 = {
 #ifdef TF_TCAM_SHARED
 	.tf_dev_alloc_tcam = tf_tcam_shared_alloc,
 	.tf_dev_free_tcam = tf_tcam_shared_free,
-	.tf_dev_set_tcam = tf_tcam_set,
-	.tf_dev_get_tcam = tf_tcam_get,
+	.tf_dev_set_tcam = tf_tcam_shared_set,
+	.tf_dev_get_tcam = tf_tcam_shared_get,
+	.tf_dev_move_tcam = tf_tcam_shared_move_p58,
 #else /* !TF_TCAM_SHARED */
 	.tf_dev_alloc_tcam = tf_tcam_alloc,
 	.tf_dev_free_tcam = tf_tcam_free,
diff --git a/drivers/net/bnxt/tf_core/tf_session.c b/drivers/net/bnxt/tf_core/tf_session.c
index e6ab518121..70844edb50 100644
--- a/drivers/net/bnxt/tf_core/tf_session.c
+++ b/drivers/net/bnxt/tf_core/tf_session.c
@@ -945,3 +945,44 @@ tf_session_set_db(struct tf *tfp,
 
 	return rc;
 }
+
+#ifdef TF_TCAM_SHARED
+
+int
+tf_session_get_tcam_shared_db(struct tf *tfp,
+			      void **tcam_shared_db_handle)
+{
+	struct tf_session *tfs = NULL;
+	int rc = 0;
+
+	*tcam_shared_db_handle = NULL;
+
+	if (tfp == NULL)
+		return (-EINVAL);
+
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
+
+	*tcam_shared_db_handle = tfs->tcam_shared_db_handle;
+	return rc;
+}
+
+int
+tf_session_set_tcam_shared_db(struct tf *tfp,
+			 void *tcam_shared_db_handle)
+{
+	struct tf_session *tfs = NULL;
+	int rc = 0;
+
+	if (tfp == NULL)
+		return (-EINVAL);
+
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
+
+	tfs->tcam_shared_db_handle = tcam_shared_db_handle;
+	return rc;
+}
+#endif /* TF_TCAM_SHARED */
diff --git a/drivers/net/bnxt/tf_core/tf_session.h b/drivers/net/bnxt/tf_core/tf_session.h
index 034a2213a4..c2875f9fa1 100644
--- a/drivers/net/bnxt/tf_core/tf_session.h
+++ b/drivers/net/bnxt/tf_core/tf_session.h
@@ -159,6 +159,13 @@ struct tf_session {
 	 * EM allocator for session
 	 */
 	void *em_pool[TF_DIR_MAX];
+
+#ifdef TF_TCAM_SHARED
+	/**
+	 * tcam db reference for the session
+	 */
+	void *tcam_shared_db_handle;
+#endif /* TF_TCAM_SHARED */
 };
 
 /**
@@ -255,6 +262,22 @@ struct tf_session_close_session_parms {
  * @ref tf_session_get_fw_session_id
  *
  * @ref tf_session_get_session_id
+ *
+ * @ref tf_session_is_shared_session_creator
+ *
+ * @ref tf_session_get_db
+ *
+ * @ref tf_session_set_db
+ *
+ * @ref tf_session_get_bp
+ *
+ * @ref tf_session_is_shared_session
+ *
+ * #define TF_SHARED
+ * @ref tf_session_get_tcam_shared_db
+ *
+ * @ref tf_session_set_tcam_shared_db
+ * #endif
  */
 
 /**
@@ -566,4 +589,29 @@ tf_session_get_bp(struct tf *tfp)
 {
 	return tfp->bp;
 }
+
+/**
+ * Set the pointer to the tcam shared database
+ *
+ * [in] session, pointer to the session
+ *
+ * Returns:
+ *   - the pointer to the parent bnxt struct
+ */
+int
+tf_session_set_tcam_shared_db(struct tf *tfp,
+			      void *tcam_shared_db_handle);
+
+/**
+ * Get the pointer to the tcam shared database
+ *
+ * [in] session, pointer to the session
+ *
+ * Returns:
+ *   - the pointer to the parent bnxt struct
+ */
+int
+tf_session_get_tcam_shared_db(struct tf *tfp,
+			      void **tcam_shared_db_handle);
+
 #endif /* _TF_SESSION_H_ */
diff --git a/drivers/net/bnxt/tf_core/tf_tcam.c b/drivers/net/bnxt/tf_core/tf_tcam.c
index 7878f8727a..d7e12e00ef 100644
--- a/drivers/net/bnxt/tf_core/tf_tcam.c
+++ b/drivers/net/bnxt/tf_core/tf_tcam.c
@@ -299,7 +299,7 @@ tf_tcam_alloc(struct tf *tfp,
 	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);
 	if (rc) {
 		TFP_DRV_LOG(ERR,
-			    "Failed to get em_ext_db from session, rc:%s\n",
+			    "Failed to get tcam_db from session, rc:%s\n",
 			    strerror(-rc));
 		return rc;
 	}
diff --git a/drivers/net/bnxt/tf_core/tf_tcam_shared.c b/drivers/net/bnxt/tf_core/tf_tcam_shared.c
index 17d7fee7a8..0e8cb78f8d 100644
--- a/drivers/net/bnxt/tf_core/tf_tcam_shared.c
+++ b/drivers/net/bnxt/tf_core/tf_tcam_shared.c
@@ -53,10 +53,34 @@ struct tf_tcam_shared_wc_pool {
 	struct bitalloc *pool;
 };
 
+struct tf_tcam_shared_wc_pools {
+	struct tf_tcam_shared_wc_pool db[TF_DIR_MAX][TF_TCAM_SHARED_WC_POOL_MAX];
+};
+
 /** The WC TCAM shared pool declarations
- * TODO: add tcam_shared_wc_db
  */
-struct tf_tcam_shared_wc_pool tcam_shared_wc[TF_DIR_MAX][TF_TCAM_SHARED_WC_POOL_MAX];
+/* struct tf_tcam_shared_wc_pool tcam_shared_wc[TF_DIR_MAX][TF_TCAM_SHARED_WC_POOL_MAX]; */
+
+static int
+tf_tcam_shared_create_db(struct tf_tcam_shared_wc_pools **db)
+{
+	struct tfp_calloc_parms cparms;
+	int rc = 0;
+
+	cparms.nitems = 1;
+	cparms.alignment = 0;
+	cparms.size = sizeof(struct tf_tcam_shared_wc_pools);
+	rc = tfp_calloc(&cparms);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "TCAM shared db allocation failed (%s)\n",
+			    strerror(-rc));
+		return rc;
+	}
+	*db = cparms.mem_va;
+
+	return rc;
+}
 
 /** Create a WC TCAM shared pool
  */
@@ -64,7 +88,8 @@ static int
 tf_tcam_shared_create_wc_pool(int dir,
 			      enum tf_tcam_shared_wc_pool_id id,
 			      int start,
-			      int stride)
+			      int stride,
+			      struct tf_tcam_shared_wc_pools *tcam_shared_wc)
 {
 	int rc = 0;
 	bool free = true;
@@ -84,9 +109,9 @@ tf_tcam_shared_create_wc_pool(int dir,
 			    strerror(-rc));
 		return rc;
 	}
-	tcam_shared_wc[dir][id].pool = (struct bitalloc *)cparms.mem_va;
+	tcam_shared_wc->db[dir][id].pool = (struct bitalloc *)cparms.mem_va;
 
-	rc = ba_init(tcam_shared_wc[dir][id].pool,
+	rc = ba_init(tcam_shared_wc->db[dir][id].pool,
 		     stride,
 		     free);
 
@@ -97,21 +122,27 @@ tf_tcam_shared_create_wc_pool(int dir,
 		return rc;
 	}
 
-	tcam_shared_wc[dir][id].info.start = start;
-	tcam_shared_wc[dir][id].info.stride = stride;
+	tcam_shared_wc->db[dir][id].info.start = start;
+	tcam_shared_wc->db[dir][id].info.stride = stride;
+
 	return rc;
 }
 /** Free a WC TCAM shared pool
  */
-static void
+static int
 tf_tcam_shared_free_wc_pool(int dir,
-			    enum tf_tcam_shared_wc_pool_id id)
+			    enum tf_tcam_shared_wc_pool_id id,
+			    struct tf_tcam_shared_wc_pools *tcam_shared_wc)
 {
-	tcam_shared_wc[dir][id].info.start = 0;
-	tcam_shared_wc[dir][id].info.stride = 0;
+	int rc = 0;
+	TF_CHECK_PARMS1(tcam_shared_wc);
+
+	tcam_shared_wc->db[dir][id].info.start = 0;
+	tcam_shared_wc->db[dir][id].info.stride = 0;
 
-	if (tcam_shared_wc[dir][id].pool)
-		tfp_free((void *)tcam_shared_wc[dir][id].pool);
+	if (tcam_shared_wc->db[dir][id].pool)
+		tfp_free((void *)tcam_shared_wc->db[dir][id].pool);
+	return rc;
 }
 
 /** Get the number of WC TCAM slices allocated during 1 allocation/free
@@ -137,7 +168,7 @@ tf_tcam_shared_get_slices(struct tf *tfp,
 }
 
 static bool
-tf_tcam_shared_db_valid(struct tf *tfp,
+tf_tcam_db_valid(struct tf *tfp,
 			enum tf_dir dir)
 {
 	struct tcam_rm_db *tcam_db;
@@ -226,6 +257,7 @@ tf_tcam_shared_bind(struct tf *tfp,
 	uint16_t start, stride;
 	uint16_t num_slices;
 	uint16_t hcapi_type;
+	struct tf_tcam_shared_wc_pools *tcam_shared_wc = NULL;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -256,11 +288,14 @@ tf_tcam_shared_bind(struct tf *tfp,
 		if (rc)
 			return rc;
 
+		tf_tcam_shared_create_db(&tcam_shared_wc);
+
+
 		/* If there are WC TCAM entries, create 2 pools each with 1/2
 		 * the total number of entries
 		 */
 		for (dir = 0; dir < TF_DIR_MAX; dir++) {
-			if (!tf_tcam_shared_db_valid(tfp, dir))
+			if (!tf_tcam_db_valid(tfp, dir))
 				continue;
 
 			rc = tf_tcam_shared_get_rm_info(tfp,
@@ -278,15 +313,19 @@ tf_tcam_shared_bind(struct tf *tfp,
 			stride = info.entry.stride / 2;
 
 			tf_tcam_shared_create_wc_pool(dir,
-						TF_TCAM_SHARED_WC_POOL_HI,
-						start,
-						stride);
+						      TF_TCAM_SHARED_WC_POOL_HI,
+						      start,
+						      stride,
+						      tcam_shared_wc);
 
 			start += stride;
 			tf_tcam_shared_create_wc_pool(dir,
-						TF_TCAM_SHARED_WC_POOL_LO,
-						start,
-						stride);
+						      TF_TCAM_SHARED_WC_POOL_LO,
+						      start,
+						      stride,
+						      tcam_shared_wc);
+
+			tf_session_set_tcam_shared_db(tfp, (void *)tcam_shared_wc);
 		}
 	}
 done:
@@ -300,6 +339,8 @@ tf_tcam_shared_unbind(struct tf *tfp)
 {
 	int rc, dir;
 	struct tf_session *tfs;
+	void *tcam_shared_db_ptr = NULL;
+	struct tf_tcam_shared_wc_pools *tcam_shared_wc;
 
 	TF_CHECK_PARMS1(tfp);
 
@@ -315,6 +356,15 @@ tf_tcam_shared_unbind(struct tf *tfp)
 	if (rc)
 		return rc;
 
+	rc = tf_session_get_tcam_shared_db(tfp, (void *)&tcam_shared_db_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to get tcam_shared_db from session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	tcam_shared_wc = (struct tf_tcam_shared_wc_pools *)tcam_shared_db_ptr;
+
 	/* If we are the shared session
 	 */
 	if (tf_session_is_shared_session(tfs)) {
@@ -322,9 +372,11 @@ tf_tcam_shared_unbind(struct tf *tfp)
 		 */
 		for (dir = 0; dir < TF_DIR_MAX; dir++) {
 			tf_tcam_shared_free_wc_pool(dir,
-						    TF_TCAM_SHARED_WC_POOL_HI);
+						    TF_TCAM_SHARED_WC_POOL_HI,
+						    tcam_shared_wc);
 			tf_tcam_shared_free_wc_pool(dir,
-						    TF_TCAM_SHARED_WC_POOL_LO);
+						    TF_TCAM_SHARED_WC_POOL_LO,
+						    tcam_shared_wc);
 		}
 	}
 	return 0;
@@ -343,6 +395,8 @@ tf_tcam_shared_alloc(struct tf *tfp,
 	struct bitalloc *pool;
 	enum tf_tcam_shared_wc_pool_id id;
 	uint16_t num_slices;
+	struct tf_tcam_shared_wc_pools *tcam_shared_wc;
+	void *tcam_shared_db_ptr = NULL;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -364,13 +418,22 @@ tf_tcam_shared_alloc(struct tf *tfp,
 		return rc;
 	}
 
-	if (!tf_tcam_shared_db_valid(tfp, parms->dir)) {
+	if (!tf_tcam_db_valid(tfp, parms->dir)) {
 		TFP_DRV_LOG(ERR,
 			    "%s: tcam shared pool doesn't exist\n",
 			    tf_dir_2_str(parms->dir));
 		return -ENOMEM;
 	}
 
+	rc = tf_session_get_tcam_shared_db(tfp, (void *)&tcam_shared_db_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to get tcam_shared_db from session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	tcam_shared_wc = (struct tf_tcam_shared_wc_pools *)tcam_shared_db_ptr;
+
 	if (parms->type == TF_TCAM_TBL_TYPE_WC_TCAM_HIGH)
 		id = TF_TCAM_SHARED_WC_POOL_HI;
 	else
@@ -385,7 +448,7 @@ tf_tcam_shared_alloc(struct tf *tfp,
 	if (rc)
 		return rc;
 
-	pool = tcam_shared_wc[parms->dir][id].pool;
+	pool = tcam_shared_wc->db[parms->dir][id].pool;
 
 	for (i = 0; i < num_slices; i++) {
 		/*
@@ -427,6 +490,8 @@ tf_tcam_shared_free(struct tf *tfp,
 	uint16_t num_slices;
 	uint16_t hcapi_type;
 	struct tf_rm_alloc_info info;
+	void *tcam_shared_db_ptr = NULL;
+	struct tf_tcam_shared_wc_pools *tcam_shared_wc;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -448,13 +513,23 @@ tf_tcam_shared_free(struct tf *tfp,
 		return rc;
 	}
 
-	if (!tf_tcam_shared_db_valid(tfp, parms->dir)) {
+	if (!tf_tcam_db_valid(tfp, parms->dir)) {
 		TFP_DRV_LOG(ERR,
 			    "%s: tcam shared pool doesn't exist\n",
 			    tf_dir_2_str(parms->dir));
 		return -ENOMEM;
 	}
 
+	rc = tf_session_get_tcam_shared_db(tfp, (void *)&tcam_shared_db_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to get tcam_shared_db from session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	tcam_shared_wc = (struct tf_tcam_shared_wc_pools *)tcam_shared_db_ptr;
+
+
 	if (parms->type == TF_TCAM_TBL_TYPE_WC_TCAM_HIGH)
 		id = TF_TCAM_SHARED_WC_POOL_HI;
 	else
@@ -480,8 +555,8 @@ tf_tcam_shared_free(struct tf *tfp,
 		return rc;
 	}
 
-	pool = tcam_shared_wc[parms->dir][id].pool;
-	start = tcam_shared_wc[parms->dir][id].info.start;
+	pool = tcam_shared_wc->db[parms->dir][id].pool;
+	start = tcam_shared_wc->db[parms->dir][id].info.start;
 
 	if (parms->idx % num_slices) {
 		TFP_DRV_LOG(ERR,
@@ -548,6 +623,9 @@ tf_tcam_shared_set(struct tf *tfp __rte_unused,
 	enum tf_tcam_shared_wc_pool_id id;
 	uint16_t hcapi_type;
 	struct tf_rm_alloc_info info;
+	struct tf_tcam_shared_wc_pools *tcam_shared_wc;
+	void *tcam_shared_db_ptr = NULL;
+
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -568,7 +646,7 @@ tf_tcam_shared_set(struct tf *tfp __rte_unused,
 		return rc;
 	}
 
-	if (!tf_tcam_shared_db_valid(tfp, parms->dir)) {
+	if (!tf_tcam_db_valid(tfp, parms->dir)) {
 		TFP_DRV_LOG(ERR,
 			    "%s: tcam shared pool doesn't exist\n",
 			    tf_dir_2_str(parms->dir));
@@ -585,8 +663,17 @@ tf_tcam_shared_set(struct tf *tfp __rte_unused,
 	else
 		id = TF_TCAM_SHARED_WC_POOL_LO;
 
-	pool = tcam_shared_wc[parms->dir][id].pool;
-	start = tcam_shared_wc[parms->dir][id].info.start;
+	rc = tf_session_get_tcam_shared_db(tfp, (void *)&tcam_shared_db_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to get tcam_shared_db from session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	tcam_shared_wc = (struct tf_tcam_shared_wc_pools *)tcam_shared_db_ptr;
+
+	pool = tcam_shared_wc->db[parms->dir][id].pool;
+	start = tcam_shared_wc->db[parms->dir][id].info.start;
 
 	log_idx = parms->idx;
 	phy_idx = parms->idx + start;
@@ -656,6 +743,8 @@ tf_tcam_shared_get(struct tf *tfp __rte_unused,
 	enum tf_tcam_shared_wc_pool_id id;
 	uint16_t hcapi_type;
 	struct tf_rm_alloc_info info;
+	struct tf_tcam_shared_wc_pools *tcam_shared_wc;
+	void *tcam_shared_db_ptr = NULL;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -676,7 +765,7 @@ tf_tcam_shared_get(struct tf *tfp __rte_unused,
 		return rc;
 	}
 
-	if (!tf_tcam_shared_db_valid(tfp, parms->dir)) {
+	if (!tf_tcam_db_valid(tfp, parms->dir)) {
 		TFP_DRV_LOG(ERR,
 			    "%s: tcam shared pool doesn't exist\n",
 			    tf_dir_2_str(parms->dir));
@@ -692,8 +781,18 @@ tf_tcam_shared_get(struct tf *tfp __rte_unused,
 	else
 		id = TF_TCAM_SHARED_WC_POOL_LO;
 
-	pool = tcam_shared_wc[parms->dir][id].pool;
-	start = tcam_shared_wc[parms->dir][id].info.start;
+
+	rc = tf_session_get_tcam_shared_db(tfp, (void *)&tcam_shared_db_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to get tcam_shared_db from session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	tcam_shared_wc = (struct tf_tcam_shared_wc_pools *)tcam_shared_db_ptr;
+
+	pool = tcam_shared_wc->db[parms->dir][id].pool;
+	start = tcam_shared_wc->db[parms->dir][id].info.start;
 
 	rc = tf_tcam_shared_get_slices(tfp, dev, &num_slices);
 	if (rc)
@@ -742,3 +841,304 @@ tf_tcam_shared_get(struct tf *tfp __rte_unused,
 	}
 	return 0;
 }
+
+/* Temporary builder defines pulled in here and renamed
+ */
+#define TF_TMP_MAX_FIELD_BITLEN 512
+
+union tf_tmp_field_obj {
+	uint8_t bytes[(TF_TMP_MAX_FIELD_BITLEN + 7) / 8];
+};
+
+#define TF_TMP_MAX_KEY_BITLEN 768
+#define TF_TMP_MAX_KEY_WORDLEN ((TF_TMP_MAX_KEY_BITLEN + 63) / 64)
+
+union tf_tmp_key {
+	uint32_t words[(TF_TMP_MAX_KEY_BITLEN + 31) / 32];
+	uint8_t bytes[(TF_TMP_MAX_KEY_BITLEN + 7) / 8];
+};
+
+/** Move a WC TCAM entry from the high offset to the same low offset
+ */
+static int
+tf_tcam_shared_move_entry(struct tf *tfp,
+			  struct tf_dev_info *dev,
+			  uint16_t hcapi_type,
+			  enum tf_dir dir,
+			  int sphy_idx,
+			  int dphy_idx,
+			  int key_sz_bytes,
+			  int remap_sz_bytes,
+			  uint16_t num_slices)
+{
+	int rc = 0;
+	struct tf_tcam_get_parms gparms;
+	struct tf_tcam_set_parms sparms;
+	struct tf_tcam_free_parms fparms;
+	union tf_tmp_key tcam_key_obj;
+	union tf_tmp_key tcam_key_msk_obj;
+	union tf_tmp_field_obj tcam_remap_obj;
+
+	memset(&tcam_key_obj, 0, sizeof(tcam_key_obj));
+	memset(&tcam_key_msk_obj, 0, sizeof(tcam_key_msk_obj));
+	memset(&tcam_remap_obj, 0, sizeof(tcam_remap_obj));
+	memset(&gparms, 0, sizeof(gparms));
+
+	if (num_slices > 1) {
+		TFP_DRV_LOG(ERR,
+			    "Only single slice supported");
+		return -EOPNOTSUPP;
+	}
+
+	gparms.hcapi_type = hcapi_type;
+	gparms.dir = dir;
+	gparms.type = TF_TCAM_TBL_TYPE_WC_TCAM;
+	gparms.idx = sphy_idx;
+	gparms.key = (uint8_t *)&tcam_key_obj;
+	gparms.key_size = key_sz_bytes;
+	gparms.mask = (uint8_t *)&tcam_key_msk_obj;
+	gparms.result = (uint8_t *)&tcam_remap_obj;
+	gparms.result_size = remap_sz_bytes;
+
+	rc = tf_msg_tcam_entry_get(tfp, dev, &gparms);
+	if (rc) {
+		/* Log error */
+		TFP_DRV_LOG(ERR,
+			    "%s: WC_TCAM_HIGH: phyid(%d) get failed, rc:%s",
+			    tf_dir_2_str(dir),
+			    gparms.idx,
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Override HI/LO type with parent WC TCAM type */
+	sparms.hcapi_type = hcapi_type;
+	sparms.dir = dir;
+	sparms.type = TF_TCAM_TBL_TYPE_WC_TCAM;
+	sparms.idx = dphy_idx;
+	sparms.key = gparms.key;
+	sparms.mask = gparms.mask;
+	sparms.key_size = gparms.key_size;
+	sparms.result = gparms.result;
+	sparms.result_size = gparms.result_size;
+
+	rc = tf_msg_tcam_entry_set(tfp, dev, &sparms);
+	if (rc) {
+		/* Log error */
+		TFP_DRV_LOG(ERR,
+			    "%s: WC_TCAM_LOW phyid(%d) set failed, rc:%s",
+			    tf_dir_2_str(dir),
+			    sparms.idx,
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Override HI/LO type with parent WC TCAM type */
+	fparms.dir = dir;
+	fparms.type = TF_TCAM_TBL_TYPE_WC_TCAM;
+	fparms.hcapi_type = hcapi_type;
+	fparms.idx = sphy_idx;
+
+	rc = tf_msg_tcam_entry_free(tfp, dev, &fparms);
+	if (rc) {
+		/* Log error */
+		TFP_DRV_LOG(ERR,
+			    "%s: %s: phyid(%d) free failed, rc:%s\n",
+			    tf_dir_2_str(dir),
+			    tf_tcam_tbl_2_str(fparms.type),
+			    sphy_idx,
+			    strerror(-rc));
+		return rc;
+	}
+	return rc;
+}
+
+/** Move all shared WC TCAM entries from the high pool into the low pool
+ *  and clear out the high pool entries.
+ */
+static
+int tf_tcam_shared_move(struct tf *tfp,
+			struct tf_move_tcam_shared_entries_parms *parms,
+			int key_sz_bytes,
+			int remap_sz_bytes)
+{
+	int rc;
+	struct tf_session *tfs;
+	struct tf_dev_info *dev;
+	int log_idx;
+	uint16_t num_slices;
+	struct bitalloc *hi_pool, *lo_pool;
+	uint16_t hi_start, lo_start;
+	enum tf_tcam_shared_wc_pool_id hi_id, lo_id;
+	uint16_t hcapi_type;
+	struct tf_rm_alloc_info info;
+	int hi_cnt, i, j;
+	struct tf_tcam_shared_wc_pools *tcam_shared_wc;
+	void *tcam_shared_db_ptr = NULL;
+
+	TF_CHECK_PARMS2(tfp, parms);
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session_internal(tfp, &tfs);
+	if (rc)
+		return rc;
+
+	/* If we aren't the shared session or one of our
+	 * special types
+	 */
+	if (!tf_session_is_shared_session(tfs) ||
+	    (parms->tcam_tbl_type != TF_TCAM_TBL_TYPE_WC_TCAM_HIGH &&
+	     parms->tcam_tbl_type != TF_TCAM_TBL_TYPE_WC_TCAM_LOW)) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Session must be shared with HI/LO type\n",
+			    tf_dir_2_str(parms->dir));
+		return -EOPNOTSUPP;
+	}
+
+	if (!tf_tcam_db_valid(tfp, parms->dir)) {
+		TFP_DRV_LOG(ERR,
+			    "%s: tcam shared pool doesn't exist\n",
+			    tf_dir_2_str(parms->dir));
+		return -ENOMEM;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		/* TODO print amazing error */
+		return rc;
+	}
+	rc = tf_tcam_shared_get_slices(tfp, dev, &num_slices);
+	if (rc)
+		return rc;
+
+	rc = tf_tcam_shared_get_rm_info(tfp,
+					parms->dir,
+					&hcapi_type,
+					&info);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: TCAM rm info get failed\n",
+			    tf_dir_2_str(parms->dir));
+		return rc;
+	}
+
+	rc = tf_session_get_tcam_shared_db(tfp, (void *)&tcam_shared_db_ptr);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Failed to get tcam_shared_db from session, rc:%s\n",
+			    strerror(-rc));
+		return rc;
+	}
+	tcam_shared_wc = (struct tf_tcam_shared_wc_pools *)tcam_shared_db_ptr;
+
+	hi_id = TF_TCAM_SHARED_WC_POOL_HI;
+	hi_pool = tcam_shared_wc->db[parms->dir][hi_id].pool;
+	hi_start = tcam_shared_wc->db[parms->dir][hi_id].info.start;
+
+	lo_id = TF_TCAM_SHARED_WC_POOL_LO;
+	lo_pool = tcam_shared_wc->db[parms->dir][lo_id].pool;
+	lo_start = tcam_shared_wc->db[parms->dir][lo_id].info.start;
+
+	if (hi_pool == NULL || lo_pool == NULL)
+		return -ENOMEM;
+
+	/* Get the total count of in use entries in the high pool
+	 */
+	hi_cnt = ba_inuse_count(hi_pool);
+
+	/* Copy each valid entry to the same low pool logical offset
+	 */
+	for (i = 0; i < hi_cnt; i++) {
+		/* Go through all the slices
+		 */
+		for (j = 0; j < num_slices; j++) {
+			/* Find next free starting from where we left off
+			 */
+			log_idx = ba_find_next_inuse(hi_pool, i);
+
+			if (log_idx < 0) {
+				TFP_DRV_LOG(ERR,
+					    "Expected a found %s entry %d\n",
+					    tf_pool_2_str(hi_id),
+					    i);
+				goto done;
+			}
+			/* The user should have never allocated from the low
+			 * pool because the move only happens when switching
+			 * from the high to the low pool
+			 */
+			if (ba_alloc_index(lo_pool, log_idx) < 0) {
+				TFP_DRV_LOG(ERR,
+					    "Cannot allocate %s index %d\n",
+					    tf_pool_2_str(lo_id),
+					    i);
+				goto done;
+			}
+
+			if (j == 0) {
+				rc = tf_tcam_shared_move_entry(tfp, dev,
+							       hcapi_type,
+							       parms->dir,
+							       hi_start + log_idx,
+							       lo_start + log_idx,
+							       key_sz_bytes,
+							       remap_sz_bytes,
+							       num_slices);
+				if (rc) {
+					TFP_DRV_LOG(ERR,
+						    "Cannot allocate %s index %d\n",
+						    tf_pool_2_str(hi_id),
+						    i);
+					goto done;
+				}
+				ba_free(hi_pool, log_idx);
+				TFP_DRV_LOG(DEBUG,
+					    "%s: TCAM shared move pool(%s) phyid(%d)\n",
+					    tf_dir_2_str(parms->dir),
+					    tf_pool_2_str(hi_id),
+					    hi_start + log_idx);
+				TFP_DRV_LOG(DEBUG,
+					    "to pool(%s) phyid(%d)\n",
+					    tf_pool_2_str(lo_id),
+					    lo_start + log_idx);
+			}
+		}
+	}
+done:
+	return rc;
+}
+
+/* Normally, device specific code wouldn't reside here, it belongs
+ * in a separate device specific function in tf_device_pxx.c.
+ * But this code is placed here as it is not a long term solution
+ * and we would like to have this code centrally located for easy
+ * removal
+ */
+#define TF_TCAM_SHARED_KEY_SLICE_SZ_BYTES_P4 12
+#define TF_TCAM_SHARED_REMAP_SZ_BYTES_P4 4
+
+int tf_tcam_shared_move_p4(struct tf *tfp,
+			   struct tf_move_tcam_shared_entries_parms *parms)
+{
+	int rc = 0;
+	rc = tf_tcam_shared_move(tfp,
+				 parms,
+				 TF_TCAM_SHARED_KEY_SLICE_SZ_BYTES_P4,
+				 TF_TCAM_SHARED_REMAP_SZ_BYTES_P4);
+	return rc;
+}
+
+#define TF_TCAM_SHARED_KEY_SLICE_SZ_BYTES_P58 24
+#define TF_TCAM_SHARED_REMAP_SZ_BYTES_P58 8
+
+int tf_tcam_shared_move_p58(struct tf *tfp,
+			    struct tf_move_tcam_shared_entries_parms *parms)
+{
+	int rc = 0;
+	rc = tf_tcam_shared_move(tfp,
+				 parms,
+				 TF_TCAM_SHARED_KEY_SLICE_SZ_BYTES_P58,
+				 TF_TCAM_SHARED_REMAP_SZ_BYTES_P58);
+	return rc;
+}
diff --git a/drivers/net/bnxt/tf_core/tf_tcam_shared.h b/drivers/net/bnxt/tf_core/tf_tcam_shared.h
index fad6e23b4c..5588125470 100644
--- a/drivers/net/bnxt/tf_core/tf_tcam_shared.h
+++ b/drivers/net/bnxt/tf_core/tf_tcam_shared.h
@@ -124,4 +124,39 @@ int tf_tcam_shared_set(struct tf *tfp,
 int tf_tcam_shared_get(struct tf *tfp,
 		       struct tf_tcam_get_parms *parms);
 
+
+/**
+ * Moves entries from the WC_TCAM_HI to the WC_TCAM_LO shared pools
+ * for the P4 device.
+ *
+ * [in] tfp
+ *   Pointer to the truflow handle
+ *
+ * [in] parms
+ *   Pointer to parameters
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+int tf_tcam_shared_move_p4(struct tf *tfp,
+			   struct tf_move_tcam_shared_entries_parms *parms);
+
+/**
+ * Moves entries from the WC_TCAM_HI to the WC_TCAM_LO shared pools
+ * for the P58 device.
+ *
+ * [in] tfp
+ *   Pointer to the truflow handle
+ *
+ * [in] parms
+ *   Pointer to parameters
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+int tf_tcam_shared_move_p58(struct tf *tfp,
+			    struct tf_move_tcam_shared_entries_parms *parms);
+
 #endif /* _TF_TCAM_SHARED_H */
-- 
2.17.1


^ permalink raw reply	[flat|nested] 129+ messages in thread

* [dpdk-dev] [PATCH 21/58] net/bnxt: add API to get shared table increments
  2021-05-30  8:58 [dpdk-dev] [PATCH 00/58] enhancements to host based flow table management Venkat Duvvuru
                   ` (19 preceding siblings ...)
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 20/58] net/bnxt: add WC TCAM hi/lo move support Venkat Duvvuru
@ 2021-05-30  8:58 ` Venkat Duvvuru
  2021-05-30  8:58 ` [dpdk-dev] [PATCH 22/58] net/bnxt: modify host session failure cleanup Venkat Duvvuru
                   ` (37 subsequent siblings)
  58 siblings, 0 replies; 129+ messages in thread
From: Venkat Duvvuru @ 2021-05-30  8:58 UTC (permalink / raw)
  To: dev; +Cc: Farah Smith, Randy Schacher, Venkat Duvvuru

From: Farah Smith <farah.smith@broadcom.com>

Provide tf API to get the shared table increment value
for a given TF table type.

Signed-off-by: Farah Smith <farah.smith@broadcom.com>
Signed-off-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Randy Schacher <stuart.schacher@broadcom.com>
---
 drivers/net/bnxt/tf_core/tf_core.c        | 52 +++++++++++++++++++++++
 drivers/net/bnxt/tf_core/tf_core.h        | 34 ++++++++++++++-
 drivers/net/bnxt/tf_core/tf_device.h      | 17 ++++++++
 drivers/net/bnxt/tf_core/tf_device_p4.c   | 25 +++++++++++
 drivers/net/bnxt/tf_core/tf_device_p58.c  | 44 +++++++++++++++++++
 drivers/net/bnxt/tf_core/tf_tcam_shared.c | 22 +++++++---
 6 files changed, 188 insertions(+), 6 deletions(-)

diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c
index 73dbee2940..0fbbd40252 100644
--- a/drivers/net/bnxt/tf_core/tf_core.c
+++ b/drivers/net/bnxt/tf_core/tf_core.c
@@ -1415,6 +1415,58 @@ tf_bulk_get_tbl_entry(struct tf *tfp,
 	return rc;
 }
 
+int tf_get_shared_tbl_increment(struct tf *tfp,
+				struct tf_get_shared_tbl_increment_parms *parms)
+{
+	int rc = 0;
+	struct tf_session *tfs;
+	struct tf_dev_info *dev;
+
+	TF_CHECK_PARMS2(tfp, parms);
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup device, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Internal table type processing */
+
+	if (dev->ops->tf_dev_get_shared_tbl_increment == NULL) {
+		rc = -EOPNOTSUPP;
+		TFP_DRV_LOG(ERR,
+			    "%s: Operation not supported, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return -EOPNOTSUPP;
+	}
+
+	rc = dev->ops->tf_dev_get_shared_tbl_increment(tfp, parms);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Get table increment not supported, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	return rc;
+}
+
 int
 tf_alloc_tbl_scope(struct tf *tfp,
 		   struct tf_alloc_tbl_scope_parms *parms)
diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h
index 95cde2e8eb..44c30fa904 100644
--- a/drivers/net/bnxt/tf_core/tf_core.h
+++ b/drivers/net/bnxt/tf_core/tf_core.h
@@ -848,7 +848,6 @@ struct tf_get_session_info_parms {
  */
 int tf_get_session_info(struct tf *tfp,
 			struct tf_get_session_info_parms *parms);
-
 /**
  * Experimental
  *
@@ -1594,6 +1593,8 @@ int tf_move_tcam_shared_entries(struct tf *tfp,
  * @ref tf_get_tbl_entry
  *
  * @ref tf_bulk_get_tbl_entry
+ *
+ * @ref tf_get_shared_tbl_increment
  */
 
 /**
@@ -1844,6 +1845,37 @@ struct tf_set_tbl_entry_parms {
 int tf_set_tbl_entry(struct tf *tfp,
 		     struct tf_set_tbl_entry_parms *parms);
 
+/**
+ * tf_get_shared_tbl_increment parameter definition
+ */
+struct tf_get_shared_tbl_increment_parms {
+	/**
+	 * [in] Receive or transmit direction
+	 */
+	enum tf_dir dir;
+	/**
+	 * [in] Type of object to set
+	 */
+	enum tf_tbl_type type;
+	/**
+	 * [out] Value to increment by for resource type
+	 */
+	uint32_t increment_cnt;
+};
+
+/**
+ * tf_get_shared_tbl_increment
+ *
+ * This API is currently only required for use in the shared
+ * session for Thor (p58) actions.  An increment count is returned per
+ * type to indicate how much to increment the start by for each
+ * entry (see tf_resource_info)
+ *
+ * Returns success or failure code.
+ */
+int tf_get_shared_tbl_increment(struct tf *tfp,
+				struct tf_get_shared_tbl_increment_parms *parms);
+
 /**
  * tf_get_tbl_entry parameter definition
  */
diff --git a/drivers/net/bnxt/tf_core/tf_device.h b/drivers/net/bnxt/tf_core/tf_device.h
index 48ab17d56b..1893f630e7 100644
--- a/drivers/net/bnxt/tf_core/tf_device.h
+++ b/drivers/net/bnxt/tf_core/tf_device.h
@@ -446,6 +446,23 @@ struct tf_dev_ops {
 	int (*tf_dev_get_bulk_tbl)(struct tf *tfp,
 				   struct tf_tbl_get_bulk_parms *parms);
 
+	/**
+	 * Gets the increment value to add to the shared session resource
+	 * start offset by for each count in the "stride"
+	 *
+	 * [in] tfp
+	 *   Pointer to TF handle
+	 *
+	 * [in] parms
+	 *   Pointer to get shared tbl increment parameters
+	 *
+	 * Returns
+	 *   - (0) if successful.
+	 *   - (-EINVAL) on failure.
+	 */
+	int (*tf_dev_get_shared_tbl_increment)(struct tf *tfp,
+				struct tf_get_shared_tbl_increment_parms *parms);
+
 	/**
 	 * Retrieves the table resource info.
 	 *
diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.c b/drivers/net/bnxt/tf_core/tf_device_p4.c
index c870f45ff0..28a6e41906 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p4.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p4.c
@@ -193,6 +193,26 @@ tf_dev_p4_map_parif(struct tf *tfp __rte_unused,
 	return 0;
 }
 
+/**
+ * Device specific function that retrieves the increment
+ * required for certain table types in a shared session
+ *
+ * [in] tfp
+ *  tf handle
+ *
+ * [in/out] parms
+ *   pointer to parms structure
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+static int tf_dev_p4_get_shared_tbl_increment(struct tf *tfp __rte_unused,
+				struct tf_get_shared_tbl_increment_parms *parms)
+{
+	parms->increment_cnt = 1;
+	return 0;
+}
 static int tf_dev_p4_get_mailbox(void)
 {
 	return TF_KONG_MB;
@@ -224,12 +244,16 @@ const struct tf_dev_ops tf_dev_ops_p4_init = {
 	.tf_dev_set_ext_tbl = NULL,
 	.tf_dev_get_tbl = NULL,
 	.tf_dev_get_bulk_tbl = NULL,
+	.tf_dev_get_shared_tbl_increment = tf_dev_p4_get_shared_tbl_increment,
 	.tf_dev_get_tbl_resc_info = NULL,
 	.tf_dev_alloc_tcam = NULL,
 	.tf_dev_free_tcam = NULL,
 	.tf_dev_alloc_search_tcam = NULL,
 	.tf_dev_set_tcam = NULL,
 	.tf_dev_get_tcam = NULL,
+#ifdef TF_TCAM_SHARED
+	.tf_dev_move_tcam = NULL,
+#endif /* TF_TCAM_SHARED */
 	.tf_dev_get_tcam_resc_info = NULL,
 	.tf_dev_insert_int_em_entry = NULL,
 	.tf_dev_delete_int_em_entry = NULL,
@@ -269,6 +293,7 @@ const struct tf_dev_ops tf_dev_ops_p4 = {
 	.tf_dev_set_ext_tbl = tf_tbl_ext_common_set,
 	.tf_dev_get_tbl = tf_tbl_get,
 	.tf_dev_get_bulk_tbl = tf_tbl_bulk_get,
+	.tf_dev_get_shared_tbl_increment = tf_dev_p4_get_shared_tbl_increment,
 	.tf_dev_get_tbl_resc_info = tf_tbl_get_resc_info,
 #ifdef TF_TCAM_SHARED
 	.tf_dev_alloc_tcam = tf_tcam_shared_alloc,
diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c
index 14b9d28b13..bd6813beef 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p58.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p58.c
@@ -154,6 +154,48 @@ static int tf_dev_p58_word_align(uint16_t size)
 	return ((((size) + 63) >> 6) * 8);
 }
 
+/**
+ * Device specific function that retrieves the increment
+ * required for certain table types in a shared session
+ *
+ * [in] tfp
+ * tf handle
+ *
+ * [in/out] parms
+ *   pointer to parms structure
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+static int tf_dev_p58_get_shared_tbl_increment(struct tf *tfp __rte_unused,
+				struct tf_get_shared_tbl_increment_parms *parms)
+{
+	switch (parms->type) {
+	case TF_TBL_TYPE_FULL_ACT_RECORD:
+	case TF_TBL_TYPE_COMPACT_ACT_RECORD:
+	case TF_TBL_TYPE_ACT_ENCAP_8B:
+	case TF_TBL_TYPE_ACT_ENCAP_16B:
+	case TF_TBL_TYPE_ACT_ENCAP_32B:
+	case TF_TBL_TYPE_ACT_ENCAP_64B:
+	case TF_TBL_TYPE_ACT_SP_SMAC:
+	case TF_TBL_TYPE_ACT_SP_SMAC_IPV4:
+	case TF_TBL_TYPE_ACT_SP_SMAC_IPV6:
+	case TF_TBL_TYPE_ACT_STATS_64:
+	case TF_TBL_TYPE_ACT_MODIFY_IPV4:
+	case TF_TBL_TYPE_ACT_MODIFY_8B:
+	case TF_TBL_TYPE_ACT_MODIFY_16B:
+	case TF_TBL_TYPE_ACT_MODIFY_32B:
+	case TF_TBL_TYPE_ACT_MODIFY_64B:
+		parms->increment_cnt = 8;
+		break;
+	default:
+		parms->increment_cnt = 1;
+		break;
+	}
+	return 0;
+}
+
 #define TF_DEV_P58_BANK_SZ_64B 2048
 /**
  * Get SRAM table information.
@@ -246,6 +288,7 @@ const struct tf_dev_ops tf_dev_ops_p58_init = {
 	.tf_dev_set_ext_tbl = NULL,
 	.tf_dev_get_tbl = NULL,
 	.tf_dev_get_bulk_tbl = NULL,
+	.tf_dev_get_shared_tbl_increment = tf_dev_p58_get_shared_tbl_increment,
 	.tf_dev_get_tbl_resc_info = NULL,
 	.tf_dev_alloc_tcam = NULL,
 	.tf_dev_free_tcam = NULL,
@@ -291,6 +334,7 @@ const struct tf_dev_ops tf_dev_ops_p58 = {
 	.tf_dev_set_ext_tbl = tf_tbl_ext_common_set,
 	.tf_dev_get_tbl = tf_tbl_get,
 	.tf_dev_get_bulk_tbl = tf_tbl_bulk_get,
+	.tf_dev_get_shared_tbl_increment = tf_dev_p58_get_shared_tbl_increment,
 	.tf_dev_get_tbl_resc_info = tf_tbl_get_resc_info,
 #ifdef TF_TCAM_SHARED
 	.tf_dev_alloc_tcam = tf_tcam_shared_alloc,
diff --git a/drivers/net/bnxt/tf_core/tf_tcam_shared.c b/drivers/net/bnxt/tf_core/tf_tcam_shared.c
index 0e8cb78f8d..f0727cea80 100644
--- a/drivers/net/bnxt/tf_core/tf_tcam_shared.c
+++ b/drivers/net/bnxt/tf_core/tf_tcam_shared.c
@@ -858,6 +858,10 @@ union tf_tmp_key {
 	uint8_t bytes[(TF_TMP_MAX_KEY_BITLEN + 7) / 8];
 };
 
+/** p58 has an enable bit, p4 does not
+ */
+#define TF_TCAM_SHARED_ENTRY_ENABLE 0x8
+
 /** Move a WC TCAM entry from the high offset to the same low offset
  */
 static int
@@ -869,7 +873,8 @@ tf_tcam_shared_move_entry(struct tf *tfp,
 			  int dphy_idx,
 			  int key_sz_bytes,
 			  int remap_sz_bytes,
-			  uint16_t num_slices)
+			  uint16_t num_slices,
+			  bool set_enable_bit)
 {
 	int rc = 0;
 	struct tf_tcam_get_parms gparms;
@@ -911,6 +916,9 @@ tf_tcam_shared_move_entry(struct tf *tfp,
 		return rc;
 	}
 
+	if (set_enable_bit)
+		tcam_key_obj.bytes[0] |= TF_TCAM_SHARED_ENTRY_ENABLE;
+
 	/* Override HI/LO type with parent WC TCAM type */
 	sparms.hcapi_type = hcapi_type;
 	sparms.dir = dir;
@@ -960,7 +968,8 @@ static
 int tf_tcam_shared_move(struct tf *tfp,
 			struct tf_move_tcam_shared_entries_parms *parms,
 			int key_sz_bytes,
-			int remap_sz_bytes)
+			int remap_sz_bytes,
+			bool set_enable_bit)
 {
 	int rc;
 	struct tf_session *tfs;
@@ -1084,7 +1093,8 @@ int tf_tcam_shared_move(struct tf *tfp,
 							       lo_start + log_idx,
 							       key_sz_bytes,
 							       remap_sz_bytes,
-							       num_slices);
+							       num_slices,
+							       set_enable_bit);
 				if (rc) {
 					TFP_DRV_LOG(ERR,
 						    "Cannot allocate %s index %d\n",
@@ -1125,7 +1135,8 @@ int tf_tcam_shared_move_p4(struct tf *tfp,
 	rc = tf_tcam_shared_move(tfp,
 				 parms,
 				 TF_TCAM_SHARED_KEY_SLICE_SZ_BYTES_P4,
-				 TF_TCAM_SHARED_REMAP_SZ_BYTES_P4);
+				 TF_TCAM_SHARED_REMAP_SZ_BYTES_P4,
+				 false); /* no enable bit */
 	return rc;
 }
 
@@ -1139,6 +1150,7 @@ int tf_tcam_shared_move_p58(struct tf *tfp,
 	rc = tf_tcam_shared_move(tfp,
 				 parms,
 				 TF_TCAM_SHARED_KEY_SLICE_SZ_BYTES_P58,
-				 TF_TCAM_SHARED_REMAP_SZ_BYTES_P58);
+				 TF_TCAM_SHARED_REMAP_SZ_BYTES_P58,
+				 true); /* set enable bit */
 	return rc;
 }
-- 
2.17.1


^ permalink raw reply	[flat|nested] 129+ messages in thread

* [dpdk-dev] [PATCH 22/58] net/bnxt: modify host session failure cleanup
  2021-05-30  8:58 [dpdk-dev] [PATCH 00/58] enhancements to host based flow table management Venkat