| 4438 | } |
| 4439 | |
| 4440 | int32_t |
| 4441 | ulp_mapper_init(struct bnxt_ulp_context *ulp_ctx) |
| 4442 | { |
| 4443 | struct bnxt_ulp_mapper_data *data; |
| 4444 | struct tf *tfp; |
| 4445 | int32_t rc; |
| 4446 | |
| 4447 | if (!ulp_ctx) |
| 4448 | return -EINVAL; |
| 4449 | |
| 4450 | tfp = bnxt_ulp_cntxt_tfp_get(ulp_ctx, BNXT_ULP_SESSION_TYPE_DEFAULT); |
| 4451 | if (!tfp) |
| 4452 | return -EINVAL; |
| 4453 | |
| 4454 | data = rte_zmalloc("ulp_mapper_data", |
| 4455 | sizeof(struct bnxt_ulp_mapper_data), 0); |
| 4456 | if (!data) { |
| 4457 | BNXT_TF_DBG(ERR, "Failed to allocate the mapper data\n"); |
| 4458 | return -ENOMEM; |
| 4459 | } |
| 4460 | |
| 4461 | if (bnxt_ulp_cntxt_ptr2_mapper_data_set(ulp_ctx, data)) { |
| 4462 | BNXT_TF_DBG(ERR, "Failed to set mapper data in context\n"); |
| 4463 | /* Don't call deinit since the prof_func wasn't allocated. */ |
| 4464 | rte_free(data); |
| 4465 | return -ENOMEM; |
| 4466 | } |
| 4467 | |
| 4468 | /* Allocate the global resource ids */ |
| 4469 | rc = ulp_mapper_glb_resource_info_init(ulp_ctx, data); |
| 4470 | if (rc) { |
| 4471 | BNXT_TF_DBG(ERR, "Failed to initialize global resource ids\n"); |
| 4472 | goto error; |
| 4473 | } |
| 4474 | |
| 4475 | /* |
| 4476 | * Only initialize the app global resources if a shared session was |
| 4477 | * created. |
| 4478 | */ |
| 4479 | if (bnxt_ulp_cntxt_shared_session_enabled(ulp_ctx)) { |
| 4480 | rc = ulp_mapper_app_glb_resource_info_init(ulp_ctx, data); |
| 4481 | if (rc) { |
| 4482 | BNXT_TF_DBG(ERR, "Failed to init app glb resources\n"); |
| 4483 | goto error; |
| 4484 | } |
| 4485 | } |
| 4486 | |
| 4487 | /* Allocate the generic table list */ |
| 4488 | rc = ulp_mapper_generic_tbl_list_init(data); |
| 4489 | if (rc) { |
| 4490 | BNXT_TF_DBG(ERR, "Failed to initialize generic tbl list\n"); |
| 4491 | goto error; |
| 4492 | } |
| 4493 | |
| 4494 | return 0; |
| 4495 | error: |
| 4496 | /* Ignore the return code in favor of returning the original error. */ |
| 4497 | ulp_mapper_deinit(ulp_ctx); |
no test coverage detected