From: Maciej Gajdzica Date: Thu, 17 Sep 2015 12:58:33 +0000 (+0200) Subject: examples/ip_pipeline: check pipeline type X-Git-Tag: spdx-start~7859 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=1091a99f6dbc721838e084239e095e650f811685;p=dpdk.git examples/ip_pipeline: check pipeline type This commit add to CLI command check for pipeline type. It prevents running CLI commands on not supported pipeline types. Signed-off-by: Maciej Gajdzica Acked-by: Cristian Dumitrescu --- diff --git a/examples/ip_pipeline/app.h b/examples/ip_pipeline/app.h index d8a1717c2f..6510d6decf 100644 --- a/examples/ip_pipeline/app.h +++ b/examples/ip_pipeline/app.h @@ -227,6 +227,7 @@ struct app_pipeline_params { struct app_pipeline_data { void *be; void *fe; + struct pipeline_type *ptype; uint64_t timer_period; uint32_t enabled; }; diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c index 838a38363f..23fd561b05 100644 --- a/examples/ip_pipeline/init.c +++ b/examples/ip_pipeline/init.c @@ -1340,6 +1340,8 @@ app_init_pipelines(struct app_params *app) "init error\n", params->name); } + data->ptype = ptype; + data->timer_period = (rte_get_tsc_hz() * params->timer_period) / 1000; } diff --git a/examples/ip_pipeline/pipeline/pipeline_common_fe.h b/examples/ip_pipeline/pipeline/pipeline_common_fe.h index e84aa3adeb..cfad963d8e 100644 --- a/examples/ip_pipeline/pipeline/pipeline_common_fe.h +++ b/examples/ip_pipeline/pipeline/pipeline_common_fe.h @@ -60,7 +60,7 @@ app_pipeline_data(struct app_params *app, uint32_t id) } static inline void * -app_pipeline_data_fe(struct app_params *app, uint32_t id) +app_pipeline_data_fe(struct app_params *app, uint32_t id, struct pipeline_type *ptype) { struct app_pipeline_data *pipeline_data; @@ -68,6 +68,9 @@ app_pipeline_data_fe(struct app_params *app, uint32_t id) if (pipeline_data == NULL) return NULL; + if (strcmp(pipeline_data->ptype->name, ptype->name) != 0) + return NULL; + if (pipeline_data->enabled == 0) return NULL; diff --git a/examples/ip_pipeline/pipeline/pipeline_firewall.c b/examples/ip_pipeline/pipeline/pipeline_firewall.c index 4137923c45..3d7ea7aa18 100644 --- a/examples/ip_pipeline/pipeline/pipeline_firewall.c +++ b/examples/ip_pipeline/pipeline/pipeline_firewall.c @@ -141,7 +141,7 @@ app_pipeline_firewall_rule_find(struct app_pipeline_firewall *p, return NULL; } -static void +static int app_pipeline_firewall_ls( struct app_params *app, uint32_t pipeline_id) @@ -153,11 +153,11 @@ app_pipeline_firewall_ls( /* Check input arguments */ if (app == NULL) - return; + return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_firewall); if (p == NULL) - return; + return -1; n_rules = p->n_rules; for (priority = 0; n_rules; priority++) @@ -175,6 +175,8 @@ app_pipeline_firewall_ls( printf("Default rule: DROP\n"); printf("\n"); + + return 0; } static void* @@ -641,7 +643,7 @@ app_pipeline_firewall_add_rule(struct app_params *app, (key->type != PIPELINE_FIREWALL_IPV4_5TUPLE)) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_firewall); if (p == NULL) return -1; @@ -729,7 +731,7 @@ app_pipeline_firewall_delete_rule(struct app_params *app, (key->type != PIPELINE_FIREWALL_IPV4_5TUPLE)) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_firewall); if (p == NULL) return -1; @@ -797,7 +799,7 @@ app_pipeline_firewall_add_bulk(struct app_params *app, if (app == NULL) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_firewall); if (p == NULL) return -1; @@ -1023,7 +1025,7 @@ app_pipeline_firewall_delete_bulk(struct app_params *app, if (app == NULL) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_firewall); if (p == NULL) return -1; @@ -1111,7 +1113,7 @@ app_pipeline_firewall_add_default_rule(struct app_params *app, if (app == NULL) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_firewall); if (p == NULL) return -1; @@ -1162,7 +1164,7 @@ app_pipeline_firewall_delete_default_rule(struct app_params *app, if (app == NULL) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_firewall); if (p == NULL) return -1; @@ -1804,8 +1806,14 @@ cmd_firewall_ls_parsed( { struct cmd_firewall_ls_result *params = parsed_result; struct app_params *app = data; + int status; - app_pipeline_firewall_ls(app, params->pipeline_id); + status = app_pipeline_firewall_ls(app, params->pipeline_id); + + if (status != 0) { + printf("Command failed\n"); + return; + } } cmdline_parse_token_string_t cmd_firewall_ls_p_string = diff --git a/examples/ip_pipeline/pipeline/pipeline_flow_classification.c b/examples/ip_pipeline/pipeline/pipeline_flow_classification.c index 04b6915849..76a152f63c 100644 --- a/examples/ip_pipeline/pipeline/pipeline_flow_classification.c +++ b/examples/ip_pipeline/pipeline/pipeline_flow_classification.c @@ -298,7 +298,7 @@ app_pipeline_fc_add(struct app_params *app, (key == NULL)) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_flow_classification); if (p == NULL) return -1; @@ -398,7 +398,7 @@ app_pipeline_fc_add_bulk(struct app_params *app, (n_keys == 0)) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_flow_classification); if (p == NULL) return -1; @@ -588,7 +588,7 @@ app_pipeline_fc_del(struct app_params *app, (key == NULL)) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_flow_classification); if (p == NULL) return -1; @@ -646,7 +646,7 @@ app_pipeline_fc_add_default(struct app_params *app, if (app == NULL) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_flow_classification); if (p == NULL) return -1; @@ -698,7 +698,7 @@ app_pipeline_fc_del_default(struct app_params *app, if (app == NULL) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_flow_classification); if (p == NULL) return -EINVAL; @@ -879,7 +879,7 @@ app_pipeline_fc_ls(struct app_params *app, if (app == NULL) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_flow_classification); if (p == NULL) return -1; diff --git a/examples/ip_pipeline/pipeline/pipeline_routing.c b/examples/ip_pipeline/pipeline/pipeline_routing.c index 4f6ff81a45..635473083f 100644 --- a/examples/ip_pipeline/pipeline/pipeline_routing.c +++ b/examples/ip_pipeline/pipeline/pipeline_routing.c @@ -267,7 +267,7 @@ app_pipeline_routing_route_ls(struct app_params *app, uint32_t pipeline_id) struct pipeline_routing *p; struct app_pipeline_routing_route *it; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing); if (p == NULL) return -EINVAL; @@ -305,7 +305,7 @@ app_pipeline_routing_add_route(struct app_params *app, (data == NULL)) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing); if (p == NULL) return -1; @@ -407,7 +407,7 @@ app_pipeline_routing_delete_route(struct app_params *app, (key == NULL)) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing); if (p == NULL) return -1; @@ -479,7 +479,7 @@ app_pipeline_routing_add_default_route(struct app_params *app, if (app == NULL) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing); if (p == NULL) return -1; @@ -531,7 +531,7 @@ app_pipeline_routing_delete_default_route(struct app_params *app, if (app == NULL) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing); if (p == NULL) return -1; @@ -569,7 +569,7 @@ app_pipeline_routing_arp_ls(struct app_params *app, uint32_t pipeline_id) struct pipeline_routing *p; struct app_pipeline_routing_arp_entry *it; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing); if (p == NULL) return -EINVAL; @@ -606,7 +606,7 @@ app_pipeline_routing_add_arp_entry(struct app_params *app, uint32_t pipeline_id, (macaddr == NULL)) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing); if (p == NULL) return -1; @@ -701,7 +701,7 @@ app_pipeline_routing_delete_arp_entry(struct app_params *app, (key == NULL)) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing); if (p == NULL) return -EINVAL; @@ -769,7 +769,7 @@ app_pipeline_routing_add_default_arp_entry(struct app_params *app, if (app == NULL) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing); if (p == NULL) return -1; @@ -821,7 +821,7 @@ app_pipeline_routing_delete_default_arp_entry(struct app_params *app, if (app == NULL) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing); if (p == NULL) return -EINVAL; @@ -2172,7 +2172,7 @@ cmd_arp_ls_parsed( struct app_params *app = data; struct pipeline_routing *p; - p = app_pipeline_data_fe(app, params->p); + p = app_pipeline_data_fe(app, params->p, &pipeline_routing); if (p == NULL) return;