net/bnxt: get TruFlow version
[dpdk.git] / drivers / net / bnxt / tf_core / tf_device_p58.c
index 47d7836..03e72b9 100644 (file)
@@ -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
 };