From: Sunil Kumar Kori <skori@marvell.com>
Implement API to validate meter policy for CN10K platform.
Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
---
drivers/net/cnxk/cn10k_ethdev_mtr.c | 63 +++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
@@ -184,10 +184,73 @@ cn10k_nix_mtr_profile_delete(struct rte_eth_dev *eth_dev, uint32_t profile_id,
return 0;
}
+static int
+cn10k_nix_mtr_policy_validate(struct rte_eth_dev *dev,
+ struct rte_mtr_meter_policy_params *policy,
+ struct rte_mtr_error *error)
+{
+ enum rte_flow_action_type supported_action[] = {
+ RTE_FLOW_ACTION_TYPE_END, RTE_FLOW_ACTION_TYPE_QUEUE,
+ RTE_FLOW_ACTION_TYPE_DROP, RTE_FLOW_ACTION_TYPE_RSS,
+ RTE_FLOW_ACTION_TYPE_METER};
+ bool supported[RTE_COLORS] = {false, false, false};
+ uint32_t i;
+
+ RTE_SET_USED(dev);
+
+ if (!policy)
+ return 0; /* Nothing to be validated */
+
+ for (i = 0; i < RTE_DIM(supported_action); i++) {
+ if (policy->actions[RTE_COLOR_GREEN]->type ==
+ supported_action[i]) {
+ supported[RTE_COLOR_GREEN] = true;
+ break;
+ }
+ }
+
+ if (!supported[RTE_COLOR_GREEN]) {
+ return -rte_mtr_error_set(error, ENOTSUP,
+ RTE_MTR_ERROR_TYPE_METER_POLICY, NULL,
+ "Green: action is not supported");
+ }
+
+ for (i = 0; i < RTE_DIM(supported_action); i++) {
+ if (policy->actions[RTE_COLOR_YELLOW]->type ==
+ supported_action[i]) {
+ supported[RTE_COLOR_YELLOW] = true;
+ break;
+ }
+ }
+
+ if (!supported[RTE_COLOR_YELLOW]) {
+ return -rte_mtr_error_set(error, ENOTSUP,
+ RTE_MTR_ERROR_TYPE_METER_POLICY, NULL,
+ "Yellow: action is not supported");
+ }
+
+ for (i = 0; i < RTE_DIM(supported_action); i++) {
+ if (policy->actions[RTE_COLOR_RED]->type ==
+ supported_action[i]) {
+ supported[RTE_COLOR_RED] = true;
+ break;
+ }
+ }
+
+ if (!supported[RTE_COLOR_RED]) {
+ return -rte_mtr_error_set(error, ENOTSUP,
+ RTE_MTR_ERROR_TYPE_METER_POLICY, NULL,
+ "Red: action is not supported");
+ }
+
+ return 0;
+}
+
const struct rte_mtr_ops nix_mtr_ops = {
.capabilities_get = cn10k_nix_mtr_capabilities_get,
.meter_profile_add = cn10k_nix_mtr_profile_add,
.meter_profile_delete = cn10k_nix_mtr_profile_delete,
+ .meter_policy_validate = cn10k_nix_mtr_policy_validate,
};
int