The function to allocate and initialize the ulp context data. */
| 1076 | |
| 1077 | /* The function to allocate and initialize the ulp context data. */ |
| 1078 | static int32_t |
| 1079 | ulp_ctx_init(struct bnxt *bp, |
| 1080 | struct bnxt_ulp_session_state *session) |
| 1081 | { |
| 1082 | struct bnxt_ulp_data *ulp_data; |
| 1083 | int32_t rc = 0; |
| 1084 | enum bnxt_ulp_device_id devid; |
| 1085 | enum bnxt_ulp_session_type stype; |
| 1086 | struct tf *tfp; |
| 1087 | |
| 1088 | /* Initialize the context entries list */ |
| 1089 | bnxt_ulp_cntxt_list_init(); |
| 1090 | |
| 1091 | /* Add the context to the context entries list */ |
| 1092 | rc = bnxt_ulp_cntxt_list_add(bp->ulp_ctx); |
| 1093 | if (rc) { |
| 1094 | BNXT_TF_DBG(ERR, "Failed to add the context list entry\n"); |
| 1095 | return -ENOMEM; |
| 1096 | } |
| 1097 | |
| 1098 | /* Allocate memory to hold ulp context data. */ |
| 1099 | ulp_data = rte_zmalloc("bnxt_ulp_data", |
| 1100 | sizeof(struct bnxt_ulp_data), 0); |
| 1101 | if (!ulp_data) { |
| 1102 | BNXT_TF_DBG(ERR, "Failed to allocate memory for ulp data\n"); |
| 1103 | return -ENOMEM; |
| 1104 | } |
| 1105 | |
| 1106 | /* Increment the ulp context data reference count usage. */ |
| 1107 | bp->ulp_ctx->cfg_data = ulp_data; |
| 1108 | session->cfg_data = ulp_data; |
| 1109 | ulp_data->ref_cnt++; |
| 1110 | ulp_data->ulp_flags |= BNXT_ULP_VF_REP_ENABLED; |
| 1111 | |
| 1112 | rc = bnxt_ulp_devid_get(bp, &devid); |
| 1113 | if (rc) { |
| 1114 | BNXT_TF_DBG(ERR, "Unable to determine device for ULP init.\n"); |
| 1115 | goto error_deinit; |
| 1116 | } |
| 1117 | |
| 1118 | rc = bnxt_ulp_cntxt_dev_id_set(bp->ulp_ctx, devid); |
| 1119 | if (rc) { |
| 1120 | BNXT_TF_DBG(ERR, "Unable to set device for ULP init.\n"); |
| 1121 | goto error_deinit; |
| 1122 | } |
| 1123 | |
| 1124 | rc = bnxt_ulp_cntxt_app_id_set(bp->ulp_ctx, bp->app_id); |
| 1125 | if (rc) { |
| 1126 | BNXT_TF_DBG(ERR, "Unable to set app_id for ULP init.\n"); |
| 1127 | goto error_deinit; |
| 1128 | } |
| 1129 | BNXT_TF_DBG(DEBUG, "Ulp initialized with app id %d\n", bp->app_id); |
| 1130 | |
| 1131 | rc = bnxt_ulp_cntxt_app_caps_init(bp, bp->app_id, devid); |
| 1132 | if (rc) { |
| 1133 | BNXT_TF_DBG(ERR, "Unable to set caps for app(%x)/dev(%x)\n", |
| 1134 | bp->app_id, devid); |
| 1135 | goto error_deinit; |
no test coverage detected