| 186 | } |
| 187 | |
| 188 | static int |
| 189 | nfp_mtr_profile_insert(struct nfp_app_fw_flower *app_fw_flower, |
| 190 | struct rte_mtr_meter_profile *profile, |
| 191 | uint32_t mtr_profile_id, |
| 192 | struct rte_mtr_error *error) |
| 193 | { |
| 194 | int ret; |
| 195 | struct nfp_mtr_priv *priv; |
| 196 | struct nfp_mtr_profile *mtr_profile; |
| 197 | |
| 198 | priv = app_fw_flower->mtr_priv; |
| 199 | |
| 200 | /* Meter profile memory allocation. */ |
| 201 | mtr_profile = rte_zmalloc(NULL, sizeof(struct nfp_mtr_profile), 0); |
| 202 | if (mtr_profile == NULL) { |
| 203 | return -rte_mtr_error_set(error, ENOMEM, |
| 204 | RTE_MTR_ERROR_TYPE_UNSPECIFIED, |
| 205 | NULL, "Meter profile alloc failed"); |
| 206 | } |
| 207 | |
| 208 | ret = nfp_mtr_profile_conf_insert(mtr_profile_id, |
| 209 | profile, mtr_profile); |
| 210 | if (ret != 0) { |
| 211 | rte_mtr_error_set(error, EINVAL, |
| 212 | RTE_MTR_ERROR_TYPE_UNSPECIFIED, |
| 213 | NULL, "Insert profile config failed"); |
| 214 | goto free_profile; |
| 215 | } |
| 216 | |
| 217 | ret = nfp_flower_cmsg_qos_add(app_fw_flower, &mtr_profile->conf); |
| 218 | if (ret != 0) { |
| 219 | rte_mtr_error_set(error, EINVAL, |
| 220 | RTE_MTR_ERROR_TYPE_UNSPECIFIED, |
| 221 | NULL, "Add meter to firmware failed"); |
| 222 | goto free_profile; |
| 223 | } |
| 224 | |
| 225 | /* Insert profile into profile list */ |
| 226 | LIST_INSERT_HEAD(&priv->profiles, mtr_profile, next); |
| 227 | |
| 228 | return 0; |
| 229 | |
| 230 | free_profile: |
| 231 | rte_free(mtr_profile); |
| 232 | |
| 233 | return ret; |
| 234 | } |
| 235 | |
| 236 | static int |
| 237 | nfp_mtr_profile_mod(struct nfp_app_fw_flower *app_fw_flower, |
no test coverage detected