net/bnxt: add a failure log
[dpdk.git] / drivers / net / bnxt / tf_core / tf_em_common.c
index 8b02b8b..ad92cbd 100644 (file)
@@ -49,7 +49,7 @@ struct tf_tbl_scope_cb *
 tbl_scope_cb_find(uint32_t tbl_scope_id)
 {
        int i;
-       struct tf_rm_is_allocated_parms parms;
+       struct tf_rm_is_allocated_parms parms = { 0 };
        int allocated;
 
        /* Check that id is valid */
@@ -1046,3 +1046,94 @@ tf_em_ext_common_free(struct tf *tfp,
 {
        return tf_em_ext_free(tfp, parms);
 }
+
+int tf_em_ext_map_tbl_scope(struct tf *tfp,
+                           struct tf_map_tbl_scope_parms *parms)
+{
+       int rc = 0;
+       struct tf_session *tfs;
+       struct tf_tbl_scope_cb *tbl_scope_cb;
+       struct tf_global_cfg_parms gcfg_parms = { 0 };
+       struct tfp_calloc_parms aparms;
+       uint32_t *data, *mask;
+       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)
+               return rc;
+
+       /* Retrieve the device information */
+       rc = tf_session_get_device(tfs, &dev);
+       if (rc)
+               return rc;
+
+       if (dev->ops->tf_dev_map_tbl_scope == NULL) {
+               rc = -EOPNOTSUPP;
+               TFP_DRV_LOG(ERR,
+                           "Map table scope operation not supported, rc:%s\n",
+                           strerror(-rc));
+               return rc;
+       }
+
+       aparms.nitems = 2;
+       aparms.size = sizeof(uint32_t);
+       aparms.alignment = 0;
+
+       if (tfp_calloc(&aparms) != 0) {
+               TFP_DRV_LOG(ERR, "Map tbl scope alloc data error %s\n",
+                           strerror(ENOMEM));
+               return -ENOMEM;
+       }
+       data = aparms.mem_va;
+
+       if (tfp_calloc(&aparms) != 0) {
+               TFP_DRV_LOG(ERR, "Map tbl scope alloc mask error %s\n",
+                           strerror(ENOMEM));
+               rc = -ENOMEM;
+               goto clean;
+       }
+       mask = aparms.mem_va;
+
+       rc = dev->ops->tf_dev_map_parif(tfp, parms->parif_bitmask,
+                                       tbl_scope_cb->pf,
+                                       (uint8_t *)data, (uint8_t *)mask,
+                                       sz_in_bytes);
+
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "Map table scope config failure, rc:%s\n",
+                           strerror(-rc));
+               goto cleaner;
+       }
+
+       gcfg_parms.type =
+               (enum tf_global_config_type)TF_GLOBAL_CFG_INTERNAL_PARIF_2_PF;
+       gcfg_parms.offset = 0;
+       gcfg_parms.config = (uint8_t *)data;
+       gcfg_parms.config_mask = (uint8_t *)mask;
+       gcfg_parms.config_sz_in_bytes = sizeof(uint64_t);
+
+
+       rc = tf_msg_set_global_cfg(tfp, &gcfg_parms);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "Map tbl scope, set failed, rc:%s\n",
+                           strerror(-rc));
+       }
+cleaner:
+       tfp_free(mask);
+clean:
+       tfp_free(data);
+
+       return rc;
+}