-/*-
- * BSD LICENSE
- *
- * Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2016 Intel Corporation
*/
#include <string.h>
#include "pipeline_actions_common.h"
#include "pipeline_flow_actions_be.h"
+#include "parser.h"
#include "hash_func.h"
int
*/
struct meter_policer {
struct rte_meter_trtcm meter;
+ struct rte_meter_trtcm_profile meter_profile;
struct pipeline_fa_policer_params policer;
struct pipeline_fa_policer_stats stats;
};
{
struct rte_meter_trtcm *meter = &entry->mp[meter_id].meter;
struct rte_meter_trtcm_params *meter_params = ¶ms->m[meter_id];
+ struct rte_meter_trtcm_profile *meter_profile =
+ &entry->mp[meter_id].meter_profile;
+ int status;
- return rte_meter_trtcm_config(meter, meter_params);
+ status = rte_meter_trtcm_profile_config(meter_profile, meter_params);
+ if (status)
+ return status;
+
+ return rte_meter_trtcm_config(meter, meter_profile);
}
static void
enum rte_meter_color color = p->dscp[dscp].color;
struct rte_meter_trtcm *meter = &entry->mp[tc].meter;
+ struct rte_meter_trtcm_profile *meter_profile =
+ &entry->mp[tc].meter_profile;
struct pipeline_fa_policer_params *policer = &entry->mp[tc].policer;
struct pipeline_fa_policer_stats *stats = &entry->mp[tc].stats;
/* Read (entry), compute */
enum rte_meter_color color2 = rte_meter_trtcm_color_aware_check(meter,
+ meter_profile,
time,
total_length,
color);
enum rte_meter_color color3 = p->dscp[dscp3].color;
struct rte_meter_trtcm *meter0 = &entry0->mp[tc0].meter;
+ struct rte_meter_trtcm_profile *meter0_profile =
+ &entry0->mp[tc0].meter_profile;
struct pipeline_fa_policer_params *policer0 = &entry0->mp[tc0].policer;
struct pipeline_fa_policer_stats *stats0 = &entry0->mp[tc0].stats;
struct rte_meter_trtcm *meter1 = &entry1->mp[tc1].meter;
+ struct rte_meter_trtcm_profile *meter1_profile =
+ &entry1->mp[tc1].meter_profile;
struct pipeline_fa_policer_params *policer1 = &entry1->mp[tc1].policer;
struct pipeline_fa_policer_stats *stats1 = &entry1->mp[tc1].stats;
struct rte_meter_trtcm *meter2 = &entry2->mp[tc2].meter;
+ struct rte_meter_trtcm_profile *meter2_profile =
+ &entry2->mp[tc2].meter_profile;
struct pipeline_fa_policer_params *policer2 = &entry2->mp[tc2].policer;
struct pipeline_fa_policer_stats *stats2 = &entry2->mp[tc2].stats;
struct rte_meter_trtcm *meter3 = &entry3->mp[tc3].meter;
+ struct rte_meter_trtcm_profile *meter3_profile =
+ &entry3->mp[tc3].meter_profile;
struct pipeline_fa_policer_params *policer3 = &entry3->mp[tc3].policer;
struct pipeline_fa_policer_stats *stats3 = &entry3->mp[tc3].stats;
/* Read (entry), compute, write (entry) */
enum rte_meter_color color2_0 = rte_meter_trtcm_color_aware_check(
meter0,
+ meter0_profile,
time,
total_length0,
color0);
enum rte_meter_color color2_1 = rte_meter_trtcm_color_aware_check(
meter1,
+ meter1_profile,
time,
total_length1,
color1);
enum rte_meter_color color2_2 = rte_meter_trtcm_color_aware_check(
meter2,
+ meter2_profile,
time,
total_length2,
color2);
enum rte_meter_color color2_3 = rte_meter_trtcm_color_aware_check(
meter3,
+ meter3_profile,
time,
total_length3,
color3);
/* n_flows */
if (strcmp(arg_name, "n_flows") == 0) {
- if (n_flows_present)
- return -1;
+ int status;
+ PIPELINE_PARSE_ERR_DUPLICATE(
+ n_flows_present == 0, params->name,
+ arg_name);
n_flows_present = 1;
- p->n_flows = atoi(arg_value);
- if (p->n_flows == 0)
- return -1;
+ status = parser_read_uint32(&p->n_flows,
+ arg_value);
+ PIPELINE_PARSE_ERR_INV_VAL(((status != -EINVAL) &&
+ (p->n_flows != 0)), params->name,
+ arg_name, arg_value);
+ PIPELINE_PARSE_ERR_OUT_RNG((status != -ERANGE),
+ params->name, arg_name, arg_value);
continue;
}
/* n_meters_per_flow */
if (strcmp(arg_name, "n_meters_per_flow") == 0) {
- if (n_meters_per_flow_present)
- return -1;
+ int status;
+ PIPELINE_PARSE_ERR_DUPLICATE(
+ n_meters_per_flow_present == 0,
+ params->name, arg_name);
n_meters_per_flow_present = 1;
- p->n_meters_per_flow = atoi(arg_value);
- if ((p->n_meters_per_flow == 0) ||
- (p->n_meters_per_flow > PIPELINE_FA_N_TC_MAX))
- return -1;
+ status = parser_read_uint32(&p->n_meters_per_flow,
+ arg_value);
+ PIPELINE_PARSE_ERR_INV_VAL(((status != -EINVAL) &&
+ (p->n_meters_per_flow != 0)),
+ params->name, arg_name, arg_value);
+ PIPELINE_PARSE_ERR_OUT_RNG(((status != -ERANGE) &&
+ (p->n_meters_per_flow <=
+ PIPELINE_FA_N_TC_MAX)), params->name,
+ arg_name, arg_value);
continue;
}
/* flow_id_offset */
if (strcmp(arg_name, "flow_id_offset") == 0) {
- if (flow_id_offset_present)
- return -1;
+ int status;
+ PIPELINE_PARSE_ERR_DUPLICATE(
+ flow_id_offset_present == 0,
+ params->name, arg_name);
flow_id_offset_present = 1;
- p->flow_id_offset = atoi(arg_value);
+ status = parser_read_uint32(&p->flow_id_offset,
+ arg_value);
+ PIPELINE_PARSE_ERR_INV_VAL((status != -EINVAL),
+ params->name, arg_name, arg_value);
+ PIPELINE_PARSE_ERR_OUT_RNG((status != -ERANGE),
+ params->name, arg_name, arg_value);
continue;
}
/* ip_hdr_offset */
if (strcmp(arg_name, "ip_hdr_offset") == 0) {
- if (ip_hdr_offset_present)
- return -1;
+ int status;
+ PIPELINE_PARSE_ERR_DUPLICATE(
+ ip_hdr_offset_present == 0,
+ params->name, arg_name);
ip_hdr_offset_present = 1;
- p->ip_hdr_offset = atoi(arg_value);
+ status = parser_read_uint32(&p->ip_hdr_offset,
+ arg_value);
+ PIPELINE_PARSE_ERR_INV_VAL((status != -EINVAL),
+ params->name, arg_name, arg_value);
+ PIPELINE_PARSE_ERR_OUT_RNG((status != -ERANGE),
+ params->name, arg_name, arg_value);
continue;
}
/* color_offset */
if (strcmp(arg_name, "color_offset") == 0) {
- if (color_offset_present)
- return -1;
+ int status;
+ PIPELINE_PARSE_ERR_DUPLICATE(
+ color_offset_present == 0, params->name,
+ arg_name);
color_offset_present = 1;
+ status = parser_read_uint32(&p->color_offset,
+ arg_value);
+ PIPELINE_PARSE_ERR_INV_VAL((status != -EINVAL),
+ params->name, arg_name, arg_value);
+ PIPELINE_PARSE_ERR_OUT_RNG((status != -ERANGE),
+ params->name, arg_name, arg_value);
+
p->dscp_enabled = 1;
- p->color_offset = atoi(arg_value);
continue;
}
/* Unknown argument */
- return -1;
+ PIPELINE_PARSE_ERR_INV_ENT(0, params->name, arg_name);
}
/* Check that mandatory arguments are present */
- if ((n_flows_present == 0) ||
- (flow_id_offset_present == 0) ||
- (ip_hdr_offset_present == 0) ||
- (color_offset_present == 0))
- return -1;
+ PIPELINE_PARSE_ERR_MANDATORY((n_flows_present), params->name,
+ "n_flows");
+ PIPELINE_PARSE_ERR_MANDATORY((flow_id_offset_present),
+ params->name, "flow_id_offset");
+ PIPELINE_PARSE_ERR_MANDATORY((ip_hdr_offset_present),
+ params->name, "ip_hdr_offset");
+ PIPELINE_PARSE_ERR_MANDATORY((color_offset_present), params->name,
+ "color_offset");
return 0;
}
.arg_create = pipeline_port_out_params_convert(
¶ms->port_out[i]),
.f_action = NULL,
- .f_action_bulk = NULL,
.arg_ah = NULL,
};
return 0;
}
-static int
-pipeline_fa_track(void *pipeline,
- __rte_unused uint32_t port_in,
- uint32_t *port_out)
-{
- struct pipeline *p = (struct pipeline *) pipeline;
-
- /* Check input arguments */
- if ((p == NULL) ||
- (port_in >= p->n_ports_in) ||
- (port_out == NULL))
- return -1;
-
- if (p->n_ports_in == 1) {
- *port_out = 0;
- return 0;
- }
-
- return -1;
-}
-
static int
pipeline_fa_timer(void *pipeline)
{
.f_free = pipeline_fa_free,
.f_run = NULL,
.f_timer = pipeline_fa_timer,
- .f_track = pipeline_fa_track,
};