X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;ds=sidebyside;f=app%2Ftest-pmd%2Fcmd_flex_item.c;h=908bcb3f47f80ce5365b1ce704198703f205cbda;hb=c8557ed434213fe11ecd867819823ea6865311d2;hp=45103e45a83059de0eb3695228bde8948ee6b7d1;hpb=59f3a8acbcdbafeebe816a26d76dfb06e6450f31;p=dpdk.git diff --git a/app/test-pmd/cmd_flex_item.c b/app/test-pmd/cmd_flex_item.c index 45103e45a8..908bcb3f47 100644 --- a/app/test-pmd/cmd_flex_item.c +++ b/app/test-pmd/cmd_flex_item.c @@ -20,13 +20,6 @@ struct flex_item *flex_items[RTE_MAX_ETHPORTS][FLEX_MAX_PARSERS_NUM]; struct flex_pattern flex_patterns[FLEX_MAX_PATTERNS_NUM]; -#ifdef RTE_HAS_JANSSON -static __rte_always_inline bool -match_strkey(const char *key, const char *pattern) -{ - return strncmp(key, pattern, strlen(key)) == 0; -} - static struct flex_item * flex_parser_fetch(uint16_t port_id, uint16_t flex_id) { @@ -41,30 +34,11 @@ flex_parser_fetch(uint16_t port_id, uint16_t flex_id) return flex_items[port_id][flex_id]; } -void -flex_item_destroy(portid_t port_id, uint16_t flex_id) +#ifdef RTE_HAS_JANSSON +static __rte_always_inline bool +match_strkey(const char *key, const char *pattern) { - int ret; - struct rte_flow_error error; - struct flex_item *fp = flex_parser_fetch(port_id, flex_id); - if (fp == FLEX_PARSER_ERR) { - printf("Bad parameters: port_id=%u flex_id=%u\n", - port_id, flex_id); - return; - } - if (!fp) - return; - ret = rte_flow_flex_item_release(port_id, fp->flex_handle, &error); - if (!ret) { - free(fp); - flex_items[port_id][flex_id] = NULL; - printf("port-%u: released flex item #%u\n", - port_id, flex_id); - - } else { - printf("port-%u: cannot release flex item #%u: %s\n", - port_id, flex_id, error.message); - } + return strncmp(key, pattern, strlen(key)) == 0; } static int @@ -399,15 +373,37 @@ void flex_item_create(__rte_unused portid_t port_id, __rte_unused uint16_t flex_id, __rte_unused const char *filename) { - printf("no JSON library\n"); + printf("cannot create flex item - no JSON library configured\n"); } +#endif /* RTE_HAS_JANSSON */ -void flex_item_destroy(__rte_unused portid_t port_id, - __rte_unused uint16_t flex_id) +void +flex_item_destroy(portid_t port_id, uint16_t flex_id) { - printf("no JSON library\n"); + int ret; + struct rte_flow_error error; + struct flex_item *fp = flex_parser_fetch(port_id, flex_id); + if (!flex_id) + return; + if (fp == FLEX_PARSER_ERR) { + printf("Bad parameters: port_id=%u flex_id=%u\n", + port_id, flex_id); + return; + } + if (!fp) + return; + ret = rte_flow_flex_item_release(port_id, fp->flex_handle, &error); + if (!ret) { + free(fp); + flex_items[port_id][flex_id] = NULL; + printf("port-%u: released flex item #%u\n", + port_id, flex_id); + + } else { + printf("port-%u: cannot release flex item #%u: %s\n", + port_id, flex_id, error.message); + } } -#endif /* RTE_HAS_JANSSON */ void port_flex_item_flush(portid_t port_id) @@ -415,8 +411,10 @@ port_flex_item_flush(portid_t port_id) uint16_t i; for (i = 0; i < FLEX_MAX_PARSERS_NUM; i++) { - flex_item_destroy(port_id, i); - flex_items[port_id][i] = NULL; + if (flex_items[port_id][i] != NULL) { + flex_item_destroy(port_id, i); + flex_items[port_id][i] = NULL; + } } }