MCPcopy Create free account
hub / github.com/F-Stack/f-stack / nfp_mtr_policy_validate

Function nfp_mtr_policy_validate

dpdk/drivers/net/nfp/nfp_mtr.c:392–442  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

390}
391
392static int
393nfp_mtr_policy_validate(uint32_t mtr_policy_id,
394 struct rte_mtr_meter_policy_params *policy,
395 struct rte_mtr_error *error)
396{
397 const struct rte_flow_action *action;
398
399 /* Policy must not be NULL */
400 if (policy == NULL) {
401 return -rte_mtr_error_set(error, EINVAL,
402 RTE_MTR_ERROR_TYPE_METER_POLICY,
403 NULL, "Meter policy is null.");
404 }
405
406 /* Meter policy ID must be valid. */
407 if (mtr_policy_id >= NFP_MAX_POLICY_CNT) {
408 return -rte_mtr_error_set(error, EINVAL,
409 RTE_MTR_ERROR_TYPE_METER_POLICY_ID,
410 NULL, "Meter policy id not valid.");
411 }
412
413 /* Check green action
414 * Actions equal NULL means end action
415 */
416 action = policy->actions[RTE_COLOR_GREEN];
417 if (action != NULL && action->type != RTE_FLOW_ACTION_TYPE_VOID) {
418 return -rte_mtr_error_set(error, EINVAL,
419 RTE_MTR_ERROR_TYPE_METER_POLICY,
420 NULL, "Green action must be void or end");
421 }
422
423 /* Check yellow action
424 * Actions equal NULL means end action
425 */
426 action = policy->actions[RTE_COLOR_YELLOW];
427 if (action != NULL && action->type != RTE_FLOW_ACTION_TYPE_VOID) {
428 return -rte_mtr_error_set(error, EINVAL,
429 RTE_MTR_ERROR_TYPE_METER_POLICY,
430 NULL, "Yellow action must be void or end");
431 }
432
433 /* Check red action */
434 action = policy->actions[RTE_COLOR_RED];
435 if (action == NULL || action->type != RTE_FLOW_ACTION_TYPE_DROP) {
436 return -rte_mtr_error_set(error, EINVAL,
437 RTE_MTR_ERROR_TYPE_METER_POLICY,
438 NULL, "Red action must be drop");
439 }
440
441 return 0;
442}
443
444/**
445 * Callback to add MTR policy.

Callers 1

nfp_mtr_policy_addFunction · 0.85

Calls 1

rte_mtr_error_setFunction · 0.85

Tested by

no test coverage detected