On Tue, Sep 25, 2018 at 10:37:18PM +0800, Xiaoyu Min wrote: > add commands which supports following TTL actions: > - RTE_FLOW_ACTION_TYPE_DEC_TTL > - RTE_FLOW_ACTION_TYPE_SET_TTL > > Signed-off-by: Xiaoyu Min <jack...@mellanox.com>
Acked-by: Yongseok Koh <ys...@mellanox.com> Thanks > --- > app/test-pmd/cmdline_flow.c | 34 +++++++++++++++++++++ > app/test-pmd/config.c | 3 ++ > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 +++ > 3 files changed, 42 insertions(+) > > diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c > index 3935539cb..fae825462 100644 > --- a/app/test-pmd/cmdline_flow.c > +++ b/app/test-pmd/cmdline_flow.c > @@ -255,6 +255,9 @@ enum index { > ACTION_SET_TP_SRC_TP_SRC, > ACTION_SET_TP_DST, > ACTION_SET_TP_DST_TP_DST, > + ACTION_DEC_TTL, > + ACTION_SET_TTL, > + ACTION_SET_TTL_TTL, > }; > > /** Maximum size for pattern in struct rte_flow_item_raw. */ > @@ -834,6 +837,8 @@ static const enum index next_action[] = { > ACTION_SET_IPV6_DST, > ACTION_SET_TP_SRC, > ACTION_SET_TP_DST, > + ACTION_DEC_TTL, > + ACTION_SET_TTL, > ZERO, > }; > > @@ -972,6 +977,12 @@ static const enum index action_set_tp_dst[] = { > ZERO, > }; > > +static const enum index action_set_ttl[] = { > + ACTION_SET_TTL_TTL, > + ACTION_NEXT, > + ZERO, > +}; > + > static const enum index action_jump[] = { > ACTION_JUMP_GROUP, > ACTION_NEXT, > @@ -2620,6 +2631,29 @@ static const struct token token_list[] = { > (struct rte_flow_action_set_tp, port)), > .call = parse_vc_conf, > }, > + [ACTION_DEC_TTL] = { > + .name = "dec_ttl", > + .help = "decrease network TTL if available", > + .priv = PRIV_ACTION(DEC_TTL, 0), > + .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), > + .call = parse_vc, > + }, > + [ACTION_SET_TTL] = { > + .name = "set_ttl", > + .help = "set ttl value", > + .priv = PRIV_ACTION(SET_TTL, > + sizeof(struct rte_flow_action_set_ttl)), > + .next = NEXT(action_set_ttl), > + .call = parse_vc, > + }, > + [ACTION_SET_TTL_TTL] = { > + .name = "ttl_value", > + .help = "new ttl value to set", > + .next = NEXT(action_set_ttl, NEXT_ENTRY(UNSIGNED)), > + .args = ARGS(ARGS_ENTRY_HTON > + (struct rte_flow_action_set_ttl, ttl_value)), > + .call = parse_vc_conf, > + }, > }; > > /** Remove and return last entry from argument stack. */ > diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c > index d1028d03e..d28b6ed14 100644 > --- a/app/test-pmd/config.c > +++ b/app/test-pmd/config.c > @@ -1174,6 +1174,9 @@ static const struct { > sizeof(struct rte_flow_action_set_tp)), > MK_FLOW_ACTION(SET_TP_DST, > sizeof(struct rte_flow_action_set_tp)), > + MK_FLOW_ACTION(DEC_TTL, 0), > + MK_FLOW_ACTION(SET_TTL, > + sizeof(struct rte_flow_action_set_ttl)), > }; > > /** Compute storage space needed by action configuration and copy it. */ > diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst > b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > index f60be0862..db68c4346 100644 > --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst > +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > @@ -3721,6 +3721,11 @@ This section lists supported actions and their > attributes, if any. > > - ``port``: New TCP/UDP destination port number. > > +- ``dec_ttl``: Performs a decrease TTL value action > + > +- ``set_ttl``: Set TTL value with specificed value > + - ``ttl_value {unsigned}``: The new TTL value to be set > + > Destroying flow rules > ~~~~~~~~~~~~~~~~~~~~~ > > -- > 2.17.1 >