| 234 | } |
| 235 | |
| 236 | static int |
| 237 | nfp_mtr_profile_mod(struct nfp_app_fw_flower *app_fw_flower, |
| 238 | struct rte_mtr_meter_profile *profile, |
| 239 | struct nfp_mtr_profile *mtr_profile, |
| 240 | struct rte_mtr_error *error) |
| 241 | { |
| 242 | int ret; |
| 243 | struct nfp_profile_conf old_conf; |
| 244 | |
| 245 | /* Get the old profile config */ |
| 246 | rte_memcpy(&old_conf, &mtr_profile->conf, sizeof(old_conf)); |
| 247 | |
| 248 | memset(&mtr_profile->conf, 0, sizeof(struct nfp_profile_conf)); |
| 249 | |
| 250 | ret = nfp_mtr_profile_conf_mod(mtr_profile->profile_id, |
| 251 | profile, &mtr_profile->conf); |
| 252 | if (ret != 0) { |
| 253 | rte_mtr_error_set(error, EINVAL, |
| 254 | RTE_MTR_ERROR_TYPE_UNSPECIFIED, |
| 255 | NULL, "Mod profile config failed"); |
| 256 | goto rollback; |
| 257 | } |
| 258 | |
| 259 | ret = nfp_flower_cmsg_qos_add(app_fw_flower, &mtr_profile->conf); |
| 260 | if (ret != 0) { |
| 261 | rte_mtr_error_set(error, EINVAL, |
| 262 | RTE_MTR_ERROR_TYPE_UNSPECIFIED, |
| 263 | NULL, "Mod meter to firmware failed"); |
| 264 | goto rollback; |
| 265 | } |
| 266 | |
| 267 | return 0; |
| 268 | |
| 269 | rollback: |
| 270 | rte_memcpy(&mtr_profile->conf, &old_conf, sizeof(old_conf)); |
| 271 | |
| 272 | return ret; |
| 273 | } |
| 274 | |
| 275 | /** |
| 276 | * Callback to add MTR profile. |
no test coverage detected