diff mbox series

[v2,08/19] net/bnxt: get TruFlow version

Message ID 20211026050547.14692-9-venkatkumar.duvvuru@broadcom.com (mailing list archive)
State Superseded, archived
Delegated to: Ajit Khaparde
Headers show
Series fixes and enhancements to Truflow | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Venkat Duvvuru Oct. 26, 2021, 5:05 a.m. UTC
From: Jay Ding <jay.ding@broadcom.com>

Implement tf_get_version that returns TruFlow version
numbers and CFA resources capbilities.

Signed-off-by: Jay Ding <jay.ding@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>
Reviewed-by: Peter Spreadborough <peter.spreadborough@broadcom.com>
---
 drivers/net/bnxt/hsi_struct_def_dpdk.h   | 15 ++--
 drivers/net/bnxt/tf_core/tf_core.c       | 29 ++++++++
 drivers/net/bnxt/tf_core/tf_core.h       | 75 ++++++++++++++++++++
 drivers/net/bnxt/tf_core/tf_device.h     | 50 ++++++++++++++
 drivers/net/bnxt/tf_core/tf_device_p4.c  | 65 +++++++++++++++++-
 drivers/net/bnxt/tf_core/tf_device_p4.h  | 79 +++++++++++++++++++++
 drivers/net/bnxt/tf_core/tf_device_p58.c | 65 +++++++++++++++++-
 drivers/net/bnxt/tf_core/tf_device_p58.h | 87 ++++++++++++++++++++++++
 drivers/net/bnxt/tf_core/tf_msg.c        | 35 ++++++++++
 drivers/net/bnxt/tf_core/tf_msg.h        | 19 ++++++
 10 files changed, 513 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h b/drivers/net/bnxt/hsi_struct_def_dpdk.h
index 77981b5cdb..6d04e39e48 100644
--- a/drivers/net/bnxt/hsi_struct_def_dpdk.h
+++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h
@@ -1058,8 +1058,8 @@  struct hwrm_err_output {
 #define HWRM_VERSION_MINOR 10
 #define HWRM_VERSION_UPDATE 2
 /* non-zero means beta version */
-#define HWRM_VERSION_RSVD 55
-#define HWRM_VERSION_STR "1.10.2.55"
+#define HWRM_VERSION_RSVD 58
+#define HWRM_VERSION_STR "1.10.2.58"
 
 /****************
  * hwrm_ver_get *
@@ -45178,7 +45178,7 @@  struct hwrm_tf_version_get_input {
 	uint64_t	resp_addr;
 } __rte_packed;
 
-/* hwrm_tf_version_get_output (size:128b/16B) */
+/* hwrm_tf_version_get_output (size:256b/32B) */
 struct hwrm_tf_version_get_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
@@ -45195,7 +45195,14 @@  struct hwrm_tf_version_get_output {
 	/* Version Update number. */
 	uint8_t	update;
 	/* unused. */
-	uint8_t	unused0[4];
+	uint8_t	unused0[5];
+	/*
+	 * This field is used to indicate device's capabilities and
+	 * configurations.
+	 */
+	uint64_t	dev_caps_cfg;
+	/* unused. */
+	uint8_t	unused1[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c
index 936102c804..86dfec0eb4 100644
--- a/drivers/net/bnxt/tf_core/tf_core.c
+++ b/drivers/net/bnxt/tf_core/tf_core.c
@@ -1802,3 +1802,32 @@  int tf_get_session_info(struct tf *tfp,
 
 	return 0;
 }
+
+int tf_get_version(struct tf *tfp,
+		   struct tf_get_version_parms *parms)
+{
+	int rc;
+	struct tf_dev_info dev;
+
+	TF_CHECK_PARMS2(tfp, parms);
+
+	/* This function can be called before open session, filter
+	 * out any non-supported device types on the Core side.
+	 */
+	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",
+			    parms->device_type);
+		return -ENOTSUP;
+	}
+
+	tf_dev_bind_ops(parms->device_type, &dev);
+
+	rc = tf_msg_get_version(parms->bp, &dev, parms);
+	if (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 fb02c2b161..ba9881c69d 100644
--- a/drivers/net/bnxt/tf_core/tf_core.h
+++ b/drivers/net/bnxt/tf_core/tf_core.h
@@ -2363,4 +2363,79 @@  struct tf_get_if_tbl_entry_parms {
 int tf_get_if_tbl_entry(struct tf *tfp,
 			struct tf_get_if_tbl_entry_parms *parms);
 
+/**
+ * tf_get_version parameters definition.
+ */
+struct tf_get_version_parms {
+	/**
+	 * [in] device type
+	 *
+	 * Device type for the session.
+	 */
+	enum tf_device_type device_type;
+
+	/**
+	 * [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] major
+	 *
+	 * Version Major number.
+	 */
+	uint8_t	major;
+
+	/* [out] minor
+	 *
+	 * Version Minor number.
+	 */
+	uint8_t	minor;
+
+	/* [out] update
+	 *
+	 * Version Update number.
+	 */
+	uint8_t	update;
+
+	/**
+	 * [out] dev_ident_caps
+	 *
+	 * fw available identifier resource list
+	 */
+	uint32_t dev_ident_caps;
+
+	/**
+	 * [out] dev_tbl_caps
+	 *
+	 * fw available table resource list
+	 */
+	uint32_t dev_tbl_caps;
+
+	/**
+	 * [out] dev_tcam_caps
+	 *
+	 * fw available tcam resource list
+	 */
+	uint32_t dev_tcam_caps;
+
+	/**
+	 * [out] dev_em_caps
+	 *
+	 * fw available em resource list
+	 */
+	uint32_t dev_em_caps;
+};
+
+/**
+ * Get tf fw version
+ *
+ * Used to retrieve Truflow fw version information.
+ *
+ * Returns success or failure code.
+ */
+int tf_get_version(struct tf *tfp,
+		   struct tf_get_version_parms *parms);
 #endif /* _TF_CORE_H_ */
diff --git a/drivers/net/bnxt/tf_core/tf_device.h b/drivers/net/bnxt/tf_core/tf_device.h
index 9b0c037db0..88bd4515ff 100644
--- a/drivers/net/bnxt/tf_core/tf_device.h
+++ b/drivers/net/bnxt/tf_core/tf_device.h
@@ -6,6 +6,7 @@ 
 #ifndef _TF_DEVICE_H_
 #define _TF_DEVICE_H_
 
+#include "cfa_resource_types.h"
 #include "tf_core.h"
 #include "tf_identifier.h"
 #include "tf_tbl.h"
@@ -36,6 +37,21 @@  struct tf_dev_info {
 	const struct tf_dev_ops *ops;
 };
 
+/**
+ * This structure can be used to translate the CFA resource type to TF type.
+ */
+struct tf_hcapi_resource_map {
+	/**
+	 * Truflow module type associated with this resource type.
+	 */
+	enum tf_module_type module_type;
+
+	/**
+	 * Bitmap of TF sub-type for the element.
+	 */
+	uint32_t type_caps;
+};
+
 /**
  * @page device Device
  *
@@ -1037,6 +1053,34 @@  struct tf_dev_ops {
 	 */
 	uint64_t (*tf_dev_cfa_key_hash)(uint64_t *key_data,
 					  uint16_t bitlen);
+
+	/**
+	 * Translate the CFA resource type to Truflow type
+	 *
+	 * [in] hcapi_types
+	 *   CFA resource type bitmap
+	 *
+	 * [out] ident_types
+	 *   Pointer to identifier type bitmap
+	 *
+	 * [out] tcam_types
+	 *   Pointer to tcam type bitmap
+	 *
+	 * [out] tbl_types
+	 *   Pointer to table type bitmap
+	 *
+	 * [out] em_types
+	 *   Pointer to em type bitmap
+	 *
+	 * Returns
+	 *   - (0) if successful.
+	 *   - (-EINVAL) on failure.
+	 */
+	int (*tf_dev_map_hcapi_caps)(uint64_t hcapi_caps,
+				     uint32_t *ident_caps,
+				     uint32_t *tcam_caps,
+				     uint32_t *tbl_caps,
+				     uint32_t *em_caps);
 };
 
 /**
@@ -1047,4 +1091,10 @@  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;
 
+/**
+ * Supported device resource type mapping structures
+ */
+extern const struct tf_hcapi_resource_map tf_hcapi_res_map_p4[CFA_RESOURCE_TYPE_P4_LAST + 1];
+extern const struct tf_hcapi_resource_map tf_hcapi_res_map_p58[CFA_RESOURCE_TYPE_P58_LAST + 1];
+
 #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 826cd0cdbc..8089785b82 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p4.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p4.c
@@ -271,6 +271,67 @@  static bool tf_dev_p4_is_sram_managed(struct tf *tfp __rte_unused,
 {
 	return false;
 }
+
+/**
+ * Device specific function that maps the hcapi resource types
+ * to Truflow type.
+ *
+ * [in] hcapi_caps
+ *   CFA resource type bitmap
+ *
+ * [out] ident_caps
+ *   Pointer to identifier type bitmap
+ *
+ * [out] tcam_caps
+ *   Pointer to tcam type bitmap
+ *
+ * [out] tbl_caps
+ *   Pointer to table type bitmap
+ *
+ * [out] em_caps
+ *   Pointer to em type bitmap
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+static int tf_dev_p4_map_hcapi_caps(uint64_t hcapi_caps,
+				    uint32_t *ident_caps,
+				    uint32_t *tcam_caps,
+				    uint32_t *tbl_caps,
+				    uint32_t *em_caps)
+{
+	uint32_t i;
+
+	*ident_caps = 0;
+	*tcam_caps = 0;
+	*tbl_caps = 0;
+	*em_caps = 0;
+
+	for (i = 0; i <= CFA_RESOURCE_TYPE_P4_LAST; i++) {
+		if (hcapi_caps & 1ULL << i) {
+			switch (tf_hcapi_res_map_p4[i].module_type) {
+			case TF_MODULE_TYPE_IDENTIFIER:
+				*ident_caps |= tf_hcapi_res_map_p4[i].type_caps;
+				break;
+			case TF_MODULE_TYPE_TABLE:
+				*tbl_caps |= tf_hcapi_res_map_p4[i].type_caps;
+				break;
+			case TF_MODULE_TYPE_TCAM:
+				*tcam_caps |= tf_hcapi_res_map_p4[i].type_caps;
+				break;
+			case TF_MODULE_TYPE_EM:
+				*em_caps |= tf_hcapi_res_map_p4[i].type_caps;
+				break;
+			default:
+				return -EINVAL;
+			}
+		}
+	}
+
+	return 0;
+}
+
 /**
  * Truflow P4 device specific functions
  */
@@ -321,6 +382,7 @@  const struct tf_dev_ops tf_dev_ops_p4_init = {
 	.tf_dev_get_global_cfg = NULL,
 	.tf_dev_get_mailbox = tf_dev_p4_get_mailbox,
 	.tf_dev_word_align = NULL,
+	.tf_dev_map_hcapi_caps = tf_dev_p4_map_hcapi_caps
 };
 
 /**
@@ -382,5 +444,6 @@  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
+	.tf_dev_cfa_key_hash = hcapi_cfa_p4_key_hash,
+	.tf_dev_map_hcapi_caps = tf_dev_p4_map_hcapi_caps
 };
diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.h b/drivers/net/bnxt/tf_core/tf_device_p4.h
index c1357913f1..e84c0f9e83 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p4.h
+++ b/drivers/net/bnxt/tf_core/tf_device_p4.h
@@ -157,4 +157,83 @@  struct tf_global_cfg_cfg tf_global_cfg_p4[TF_GLOBAL_CFG_TYPE_MAX] = {
 		TF_GLOBAL_CFG_CFG_HCAPI, TF_ACTION_BLOCK
 	},
 };
+
+const struct tf_hcapi_resource_map tf_hcapi_res_map_p4[CFA_RESOURCE_TYPE_P4_LAST + 1] = {
+	[CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP_HIGH] = {
+		TF_MODULE_TYPE_IDENTIFIER, 1 << TF_IDENT_TYPE_L2_CTXT_HIGH
+	},
+	[CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP_LOW] = {
+		TF_MODULE_TYPE_IDENTIFIER, 1 << TF_IDENT_TYPE_L2_CTXT_LOW
+	},
+	[CFA_RESOURCE_TYPE_P4_PROF_FUNC] = {
+		TF_MODULE_TYPE_IDENTIFIER, 1 << TF_IDENT_TYPE_PROF_FUNC
+	},
+	[CFA_RESOURCE_TYPE_P4_WC_TCAM_PROF_ID] = {
+		TF_MODULE_TYPE_IDENTIFIER, 1 << TF_IDENT_TYPE_WC_PROF
+	},
+	[CFA_RESOURCE_TYPE_P4_EM_PROF_ID] = {
+		TF_MODULE_TYPE_IDENTIFIER, 1 << TF_IDENT_TYPE_EM_PROF
+	},
+	[CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_HIGH] = {
+		TF_MODULE_TYPE_TCAM, 1 << TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_HIGH
+	},
+	[CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_LOW] = {
+		TF_MODULE_TYPE_TCAM, 1 << TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_LOW
+	},
+	[CFA_RESOURCE_TYPE_P4_PROF_TCAM] = {
+		TF_MODULE_TYPE_TCAM, 1 << TF_TCAM_TBL_TYPE_PROF_TCAM
+	},
+	[CFA_RESOURCE_TYPE_P4_WC_TCAM] = {
+		TF_MODULE_TYPE_TCAM, 1 << TF_TCAM_TBL_TYPE_WC_TCAM
+	},
+	[CFA_RESOURCE_TYPE_P4_SP_TCAM] = {
+		TF_MODULE_TYPE_TCAM, 1 << TF_TCAM_TBL_TYPE_SP_TCAM
+	},
+	[CFA_RESOURCE_TYPE_P4_NAT_IPV4] = {
+		TF_MODULE_TYPE_TABLE, 1 << TF_TBL_TYPE_ACT_MODIFY_IPV4
+	},
+	[CFA_RESOURCE_TYPE_P4_METER_PROF] = {
+		TF_MODULE_TYPE_TABLE, 1 << TF_TBL_TYPE_METER_PROF
+	},
+	[CFA_RESOURCE_TYPE_P4_METER] = {
+		TF_MODULE_TYPE_TABLE, 1 << TF_TBL_TYPE_METER_INST
+	},
+	[CFA_RESOURCE_TYPE_P4_MIRROR] = {
+		TF_MODULE_TYPE_TABLE, 1 << TF_TBL_TYPE_MIRROR_CONFIG
+	},
+	[CFA_RESOURCE_TYPE_P4_FULL_ACTION] = {
+		TF_MODULE_TYPE_TABLE, 1 << TF_TBL_TYPE_FULL_ACT_RECORD
+	},
+	[CFA_RESOURCE_TYPE_P4_MCG] = {
+		TF_MODULE_TYPE_TABLE, 1 << TF_TBL_TYPE_MCAST_GROUPS
+	},
+	[CFA_RESOURCE_TYPE_P4_ENCAP_8B] = {
+		TF_MODULE_TYPE_TABLE, 1 << TF_TBL_TYPE_ACT_ENCAP_8B
+	},
+	[CFA_RESOURCE_TYPE_P4_ENCAP_16B] = {
+		TF_MODULE_TYPE_TABLE, 1 << TF_TBL_TYPE_ACT_ENCAP_16B
+	},
+	[CFA_RESOURCE_TYPE_P4_ENCAP_64B] = {
+		TF_MODULE_TYPE_TABLE, 1 << TF_TBL_TYPE_ACT_ENCAP_64B
+	},
+	[CFA_RESOURCE_TYPE_P4_SP_MAC] = {
+		TF_MODULE_TYPE_TABLE, 1 << TF_TBL_TYPE_ACT_SP_SMAC
+	},
+	[CFA_RESOURCE_TYPE_P4_SP_MAC_IPV4] = {
+		TF_MODULE_TYPE_TABLE, 1 << TF_TBL_TYPE_ACT_SP_SMAC_IPV4
+	},
+	[CFA_RESOURCE_TYPE_P4_SP_MAC_IPV6] = {
+		TF_MODULE_TYPE_TABLE, 1 << TF_TBL_TYPE_ACT_SP_SMAC_IPV6
+	},
+	[CFA_RESOURCE_TYPE_P4_COUNTER_64B] = {
+		TF_MODULE_TYPE_TABLE, 1 << TF_TBL_TYPE_ACT_STATS_64
+	},
+	[CFA_RESOURCE_TYPE_P4_EM_REC] = {
+		TF_MODULE_TYPE_EM, 1 << TF_EM_TBL_TYPE_EM_RECORD
+	},
+	[CFA_RESOURCE_TYPE_P4_TBL_SCOPE] = {
+		TF_MODULE_TYPE_EM, 1 << TF_EM_TBL_TYPE_TBL_SCOPE
+	},
+};
+
 #endif /* _TF_DEVICE_P4_H_ */
diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c
index 47d7836a58..03e72b90f5 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p58.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p58.c
@@ -45,6 +45,7 @@  const char *tf_resource_str_p58[CFA_RESOURCE_TYPE_P58_LAST + 1] = {
 	[CFA_RESOURCE_TYPE_P58_WC_FKB]             = "wc_fkb  ",
 	[CFA_RESOURCE_TYPE_P58_VEB_TCAM]           = "veb     ",
 	[CFA_RESOURCE_TYPE_P58_METADATA]           = "metadata",
+	[CFA_RESOURCE_TYPE_P58_METER_DROP_CNT]     = "meter_dc",
 };
 
 /**
@@ -336,6 +337,66 @@  static int tf_dev_p58_get_sram_tbl_info(struct tf *tfp __rte_unused,
 	return 0;
 }
 
+/**
+ * Device specific function that maps the hcapi resource types
+ * to Truflow type.
+ *
+ * [in] hcapi_caps
+ *   CFA resource type bitmap
+ *
+ * [out] ident_caps
+ *   Pointer to identifier type bitmap
+ *
+ * [out] tcam_caps
+ *   Pointer to tcam type bitmap
+ *
+ * [out] tbl_caps
+ *   Pointer to table type bitmap
+ *
+ * [out] em_caps
+ *   Pointer to em type bitmap
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+static int tf_dev_p58_map_hcapi_caps(uint64_t hcapi_caps,
+				     uint32_t *ident_caps,
+				     uint32_t *tcam_caps,
+				     uint32_t *tbl_caps,
+				     uint32_t *em_caps)
+{
+	uint32_t i;
+
+	*ident_caps = 0;
+	*tcam_caps = 0;
+	*tbl_caps = 0;
+	*em_caps = 0;
+
+	for (i = 0; i <= CFA_RESOURCE_TYPE_P58_LAST; i++) {
+		if (hcapi_caps & 1ULL << i) {
+			switch (tf_hcapi_res_map_p58[i].module_type) {
+			case TF_MODULE_TYPE_IDENTIFIER:
+				*ident_caps |= tf_hcapi_res_map_p58[i].type_caps;
+				break;
+			case TF_MODULE_TYPE_TABLE:
+				*tbl_caps |= tf_hcapi_res_map_p58[i].type_caps;
+				break;
+			case TF_MODULE_TYPE_TCAM:
+				*tcam_caps |= tf_hcapi_res_map_p58[i].type_caps;
+				break;
+			case TF_MODULE_TYPE_EM:
+				*em_caps |= tf_hcapi_res_map_p58[i].type_caps;
+				break;
+			default:
+				return -EINVAL;
+			}
+		}
+	}
+
+	return 0;
+}
+
 /**
  * Truflow P58 device specific functions
  */
@@ -386,6 +447,7 @@  const struct tf_dev_ops tf_dev_ops_p58_init = {
 	.tf_dev_get_global_cfg = NULL,
 	.tf_dev_get_mailbox = tf_dev_p58_get_mailbox,
 	.tf_dev_word_align = NULL,
+	.tf_dev_map_hcapi_caps = tf_dev_p58_map_hcapi_caps
 };
 
 /**
@@ -448,5 +510,6 @@  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
+	.tf_dev_cfa_key_hash = hcapi_cfa_p58_key_hash,
+	.tf_dev_map_hcapi_caps = tf_dev_p58_map_hcapi_caps
 };
diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.h b/drivers/net/bnxt/tf_core/tf_device_p58.h
index 3e8759f2df..f6e66936f3 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p58.h
+++ b/drivers/net/bnxt/tf_core/tf_device_p58.h
@@ -209,4 +209,91 @@  struct tf_global_cfg_cfg tf_global_cfg_p58[TF_GLOBAL_CFG_TYPE_MAX] = {
 		TF_GLOBAL_CFG_CFG_HCAPI, TF_METER_INTERVAL_CFG
 	},
 };
+
+const struct tf_hcapi_resource_map tf_hcapi_res_map_p58[CFA_RESOURCE_TYPE_P58_LAST + 1] = {
+	[CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP_HIGH] = {
+		TF_MODULE_TYPE_IDENTIFIER, 1 << TF_IDENT_TYPE_L2_CTXT_HIGH
+	},
+	[CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP_LOW] = {
+		TF_MODULE_TYPE_IDENTIFIER, 1 << TF_IDENT_TYPE_L2_CTXT_LOW
+	},
+	[CFA_RESOURCE_TYPE_P58_PROF_FUNC] = {
+		TF_MODULE_TYPE_IDENTIFIER, 1 << TF_IDENT_TYPE_PROF_FUNC
+	},
+	[CFA_RESOURCE_TYPE_P58_WC_TCAM_PROF_ID] = {
+		TF_MODULE_TYPE_IDENTIFIER, 1 << TF_IDENT_TYPE_WC_PROF
+	},
+	[CFA_RESOURCE_TYPE_P58_EM_PROF_ID] = {
+		TF_MODULE_TYPE_IDENTIFIER, 1 << TF_IDENT_TYPE_EM_PROF
+	},
+	[CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_HIGH] = {
+		TF_MODULE_TYPE_TCAM, 1 << TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_HIGH
+	},
+	[CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_LOW] = {
+		TF_MODULE_TYPE_TCAM, 1 << TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_LOW
+	},
+	[CFA_RESOURCE_TYPE_P58_PROF_TCAM] = {
+		TF_MODULE_TYPE_TCAM, 1 << TF_TCAM_TBL_TYPE_PROF_TCAM
+	},
+	[CFA_RESOURCE_TYPE_P58_WC_TCAM] = {
+		TF_MODULE_TYPE_TCAM, 1 << TF_TCAM_TBL_TYPE_WC_TCAM
+	},
+	[CFA_RESOURCE_TYPE_P58_VEB_TCAM] = {
+		TF_MODULE_TYPE_TCAM, 1 << TF_TCAM_TBL_TYPE_VEB_TCAM
+	},
+	[CFA_RESOURCE_TYPE_P58_EM_FKB] = {
+		TF_MODULE_TYPE_TABLE, 1 << TF_TBL_TYPE_EM_FKB
+	},
+	[CFA_RESOURCE_TYPE_P58_WC_FKB] = {
+		TF_MODULE_TYPE_TABLE, 1 << TF_TBL_TYPE_WC_FKB
+	},
+	[CFA_RESOURCE_TYPE_P58_METER_PROF] = {
+		TF_MODULE_TYPE_TABLE, 1 << TF_TBL_TYPE_METER_PROF
+	},
+	[CFA_RESOURCE_TYPE_P58_METER] = {
+		TF_MODULE_TYPE_TABLE, 1 << TF_TBL_TYPE_METER_INST
+	},
+	[CFA_RESOURCE_TYPE_P58_METER_DROP_CNT] = {
+		TF_MODULE_TYPE_TABLE, 1 << TF_TBL_TYPE_METER_DROP_CNT
+	},
+	[CFA_RESOURCE_TYPE_P58_MIRROR] = {
+		TF_MODULE_TYPE_TABLE, 1 << TF_TBL_TYPE_MIRROR_CONFIG
+	},
+	[CFA_RESOURCE_TYPE_P58_METADATA] = {
+		TF_MODULE_TYPE_TABLE, 1 << TF_TBL_TYPE_METADATA
+	},
+	/* Resources in bank 1 */
+	[CFA_RESOURCE_TYPE_P58_SRAM_BANK_1] = {
+		TF_MODULE_TYPE_TABLE,
+		1 << TF_TBL_TYPE_FULL_ACT_RECORD
+		| 1 << TF_TBL_TYPE_COMPACT_ACT_RECORD
+	},
+	/* Resources in bank 2 */
+	[CFA_RESOURCE_TYPE_P58_SRAM_BANK_2] = {
+		TF_MODULE_TYPE_TABLE,
+		1 << TF_TBL_TYPE_ACT_ENCAP_8B |
+		1 << TF_TBL_TYPE_ACT_ENCAP_16B |
+		1 << TF_TBL_TYPE_ACT_ENCAP_32B |
+		1 << TF_TBL_TYPE_ACT_ENCAP_64B |
+		1 << TF_TBL_TYPE_ACT_MODIFY_8B |
+		1 << TF_TBL_TYPE_ACT_MODIFY_16B |
+		1 << TF_TBL_TYPE_ACT_MODIFY_32B |
+		1 << TF_TBL_TYPE_ACT_MODIFY_64B
+
+	},
+	/* Resources in bank 0 */
+	[CFA_RESOURCE_TYPE_P58_SRAM_BANK_0] = {
+		TF_MODULE_TYPE_TABLE,
+		1 << TF_TBL_TYPE_ACT_SP_SMAC |
+		1 << TF_TBL_TYPE_ACT_SP_SMAC_IPV4 |
+		1 << TF_TBL_TYPE_ACT_SP_SMAC_IPV6
+	},
+	/* Resources in bank 3 */
+	[CFA_RESOURCE_TYPE_P58_SRAM_BANK_3] = {
+		TF_MODULE_TYPE_TABLE, 1 << TF_TBL_TYPE_ACT_STATS_64
+	},
+	[CFA_RESOURCE_TYPE_P58_EM_REC] = {
+		TF_MODULE_TYPE_EM, 1 << TF_EM_TBL_TYPE_EM_RECORD
+	},
+};
 #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 ea6e2af7ce..25bf026658 100644
--- a/drivers/net/bnxt/tf_core/tf_msg.c
+++ b/drivers/net/bnxt/tf_core/tf_msg.c
@@ -2306,3 +2306,38 @@  tf_msg_set_if_tbl_entry(struct tf *tfp,
 
 	return 0;
 }
+
+int
+tf_msg_get_version(struct bnxt *bp,
+		   struct tf_dev_info *dev,
+		   struct tf_get_version_parms *params)
+
+{
+	int rc;
+	struct hwrm_tf_version_get_input req = { 0 };
+	struct hwrm_tf_version_get_output resp = { 0 };
+	struct tfp_send_msg_parms parms = { 0 };
+
+	/* Populate the request */
+	parms.tf_type = HWRM_TF_VERSION_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_direct(bp,
+				 &parms);
+
+	params->major = resp.major;
+	params->minor = resp.minor;
+	params->update = resp.update;
+
+	dev->ops->tf_dev_map_hcapi_caps(resp.dev_caps_cfg,
+					&params->dev_ident_caps,
+					&params->dev_tcam_caps,
+					&params->dev_tbl_caps,
+					&params->dev_em_caps);
+
+	return rc;
+}
diff --git a/drivers/net/bnxt/tf_core/tf_msg.h b/drivers/net/bnxt/tf_core/tf_msg.h
index 718bc2f3b2..08d20cdd7a 100644
--- a/drivers/net/bnxt/tf_core/tf_msg.h
+++ b/drivers/net/bnxt/tf_core/tf_msg.h
@@ -738,4 +738,23 @@  int tf_msg_set_if_tbl_entry(struct tf *tfp,
 int tf_msg_get_if_tbl_entry(struct tf *tfp,
 			    struct tf_if_tbl_get_parms *params);
 
+/**
+ * Send get version request to the firmware.
+ *
+ * [in] bp
+ *   Pointer to bnxt handle
+ *
+ * [in] dev
+ *   Pointer to the associated device
+ *
+ * [in/out] parms
+ *   Pointer to the version info parameter
+ *
+ * Returns:
+ *  0 on Success else internal Truflow error
+ */
+int
+tf_msg_get_version(struct bnxt *bp,
+		   struct tf_dev_info *dev,
+		   struct tf_get_version_parms *parms);
 #endif  /* _TF_MSG_H_ */