From: Jack Min <jackmin@mellanox.com>
To: Ori Kam <orika@mellanox.com>,
Adrien Mazarguil <adrien.mazarguil@6wind.com>,
Wenzhuo Lu <wenzhuo.lu@intel.com>,
Jingjing Wu <jingjing.wu@intel.com>,
Bernard Iremonger <bernard.iremonger@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [RFC] app/testpmd: support multiple raw encap/decap
Date: Fri, 20 Sep 2019 13:55:19 +0000 [thread overview]
Message-ID: <20190920135502.hdzsmib4r5hv4vmd@mellanox.com> (raw)
In-Reply-To: <a63af8b9f2b3331f7a4618e1a1975d82795b3006.1567239840.git.jackmin@mellanox.com>
Hey,
Anyone has any comments?
-Jack
On Sat, 19-08-31, 16:28, Xiaoyu Min wrote:
> In some scenarios, the raw_encap/raw_decap actions could be multiple in
> one single flow (e,g. hirepin flow):
>
> ... actions raw_decap / raw_encap / raw_decap / raw_encap / ...
>
> This requires the testpmd supports multiple raw_encap/raw_decap data
> settings as well.
>
> With the multiple raw_encap/raw_decap settings, the testpmd commands –
> set raw_encap / set raw_decap will become:
>
> set raw_encap <index> <item pattern>
> set raw_encap <index> <item pattern>
>
> And the actions – raw_encap/raw_decap also could optionally choose which
> global raw_encap/raw_decap confs to be used by index:
>
> ... actions raw_decap index 1 / raw_encap index 2 / ...
>
> If there is no `index` specified, the default index is 0.
>
> Signed-off-by: Xiaoyu Min <jackmin@mellanox.com>
> ---
> app/test-pmd/cmdline_flow.c | 198 +++++++++++++++++++++++++++++++-----
> 1 file changed, 171 insertions(+), 27 deletions(-)
>
> diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> index 495871394e..ff384ade42 100644
> --- a/app/test-pmd/cmdline_flow.c
> +++ b/app/test-pmd/cmdline_flow.c
> @@ -51,6 +51,7 @@ enum index {
> /* Sub-leve commands. */
> SET_RAW_ENCAP,
> SET_RAW_DECAP,
> + SET_RAW_INDEX,
>
> /* Top-level command. */
> FLOW,
> @@ -297,6 +298,10 @@ enum index {
> ACTION_DEC_TCP_ACK_VALUE,
> ACTION_RAW_ENCAP,
> ACTION_RAW_DECAP,
> + ACTION_RAW_ENCAP_INDEX,
> + ACTION_RAW_ENCAP_INDEX_VALUE,
> + ACTION_RAW_DECAP_INDEX,
> + ACTION_RAW_DECAP_INDEX_VALUE,
> };
>
> /** Maximum size for pattern in struct rte_flow_item_raw. */
> @@ -320,6 +325,7 @@ struct action_rss_data {
> #define ACTION_VXLAN_ENCAP_ITEMS_NUM 6
>
> #define ACTION_RAW_ENCAP_MAX_DATA 128
> +#define RAW_ENCAP_CONFS_MAX_NUM 8
>
> /** Storage for struct rte_flow_action_raw_encap. */
> struct raw_encap_conf {
> @@ -328,7 +334,7 @@ struct raw_encap_conf {
> size_t size;
> };
>
> -struct raw_encap_conf raw_encap_conf = {.size = 0};
> +struct raw_encap_conf raw_encap_confs[RAW_ENCAP_CONFS_MAX_NUM];
>
> /** Storage for struct rte_flow_action_raw_decap. */
> struct raw_decap_conf {
> @@ -336,7 +342,7 @@ struct raw_decap_conf {
> size_t size;
> };
>
> -struct raw_decap_conf raw_decap_conf = {.size = 0};
> +struct raw_decap_conf raw_decap_confs[RAW_ENCAP_CONFS_MAX_NUM];
>
> /** Storage for struct rte_flow_action_vxlan_encap including external data. */
> struct action_vxlan_encap_data {
> @@ -376,12 +382,14 @@ struct action_raw_encap_data {
> struct rte_flow_action_raw_encap conf;
> uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
> uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
> + uint16_t idx;
> };
>
> /** Storage for struct rte_flow_action_raw_decap including external data. */
> struct action_raw_decap_data {
> struct rte_flow_action_raw_decap conf;
> uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
> + uint16_t idx;
> };
>
> /** Maximum number of subsequent tokens and arguments on the stack. */
> @@ -1143,6 +1151,18 @@ static const enum index action_dec_tcp_ack[] = {
> ZERO,
> };
>
> +static const enum index action_raw_encap[] = {
> + ACTION_RAW_ENCAP_INDEX,
> + ACTION_NEXT,
> + ZERO,
> +};
> +
> +static const enum index action_raw_decap[] = {
> + ACTION_RAW_DECAP_INDEX,
> + ACTION_NEXT,
> + ZERO,
> +};
> +
> static int parse_set_raw_encap_decap(struct context *, const struct token *,
> const char *, unsigned int,
> void *, unsigned int);
> @@ -1201,6 +1221,12 @@ static int parse_vc_action_raw_encap(struct context *,
> static int parse_vc_action_raw_decap(struct context *,
> const struct token *, const char *,
> unsigned int, void *, unsigned int);
> +static int parse_vc_action_raw_encap_index(struct context *,
> + const struct token *, const char *,
> + unsigned int, void *, unsigned int);
> +static int parse_vc_action_raw_decap_index(struct context *,
> + const struct token *, const char *,
> + unsigned int, void *, unsigned int);
> static int parse_destroy(struct context *, const struct token *,
> const char *, unsigned int,
> void *, unsigned int);
> @@ -3095,18 +3121,41 @@ static const struct token token_list[] = {
> .name = "raw_encap",
> .help = "encapsulation data, defined by set raw_encap",
> .priv = PRIV_ACTION(RAW_ENCAP,
> - sizeof(struct rte_flow_action_raw_encap)),
> - .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
> + sizeof(struct action_raw_encap_data)),
> + .next = NEXT(action_raw_encap),
> .call = parse_vc_action_raw_encap,
> },
> + [ACTION_RAW_ENCAP_INDEX] = {
> + .name = "index",
> + .help = "the index of raw_encap_confs",
> + .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
> + },
> + [ACTION_RAW_ENCAP_INDEX_VALUE] = {
> + .name = "{index}",
> + .help = "the index value",
> + .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
> + .call = parse_vc_action_raw_encap_index,
> + },
> [ACTION_RAW_DECAP] = {
> .name = "raw_decap",
> .help = "decapsulation data, defined by set raw_encap",
> .priv = PRIV_ACTION(RAW_DECAP,
> - sizeof(struct rte_flow_action_raw_decap)),
> - .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
> + sizeof(struct action_raw_decap_data)),
> + .next = NEXT(action_raw_decap),
> .call = parse_vc_action_raw_decap,
> },
> + [ACTION_RAW_DECAP_INDEX] = {
> + .name = "index",
> + .help = "the index of raw_decap_confs",
> + .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
> + .call = parse_vc_action_raw_decap_index,
> + },
> + [ACTION_RAW_DECAP_INDEX_VALUE] = {
> + .name = "{index}",
> + .help = "the index value",
> + .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
> + .call = parse_vc_action_raw_decap_index,
> + },
> /* Top level command. */
> [SET] = {
> .name = "set",
> @@ -3121,14 +3170,21 @@ static const struct token token_list[] = {
> [SET_RAW_ENCAP] = {
> .name = "raw_encap",
> .help = "set raw encap data",
> - .next = NEXT(next_item),
> + .next = NEXT(next_item, NEXT_ENTRY(SET_RAW_INDEX)),
> + .args = ARGS(ARGS_ENTRY(struct buffer, port)),
> .call = parse_set_raw_encap_decap,
> },
> [SET_RAW_DECAP] = {
> .name = "raw_decap",
> .help = "set raw decap data",
> - .next = NEXT(next_item),
> + .next = NEXT(next_item, NEXT_ENTRY(SET_RAW_INDEX)),
> .call = parse_set_raw_encap_decap,
> + },
> + [SET_RAW_INDEX] = {
> + .name = "{raw_index}",
> + .help = "index of raw_enca/raw_decap data",
> + .call = parse_port,
> + .comp = comp_none,
> }
> };
>
> @@ -4423,6 +4479,92 @@ parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
> return ret;
> }
>
> +static int
> +parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
> + const char *str, unsigned int len, void *buf,
> + unsigned int size)
> +{
> + struct action_raw_decap_data *action_raw_decap_data;
> + struct rte_flow_action *action;
> + const struct arg *arg;
> + struct buffer *out = buf;
> + uint8_t *data = NULL;
> + int ret;
> + uint16_t idx;
> +
> + RTE_SET_USED(token);
> + RTE_SET_USED(buf);
> + RTE_SET_USED(size);
> + arg = ARGS_ENTRY_ARB_BOUNDED
> + (offsetof(struct action_raw_decap_data, idx),
> + sizeof(((struct action_raw_decap_data *)0)->idx),
> + 0, RAW_ENCAP_CONFS_MAX_NUM);
> + if (push_args(ctx, arg))
> + return -1;
> + ret = parse_int(ctx, token, str, len, NULL, 0);
> + if (ret < 0) {
> + pop_args(ctx);
> + return -1;
> + }
> + if (!ctx->object)
> + return len;
> + action = &out->args.vc.actions[out->args.vc.actions_n - 1];
> + action_raw_decap_data = ctx->object;
> + idx = action_raw_decap_data->idx;
> + /* data stored from tail of data buffer */
> + data = (uint8_t *)&(raw_decap_confs[idx].data) +
> + ACTION_RAW_ENCAP_MAX_DATA - raw_decap_confs[idx].size;
> + action_raw_decap_data->conf.data = data;
> + action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
> + action->conf = &action_raw_decap_data->conf;
> + return len;
> +}
> +
> +
> +static int
> +parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
> + const char *str, unsigned int len, void *buf,
> + unsigned int size)
> +{
> + struct action_raw_encap_data *action_raw_encap_data;
> + struct rte_flow_action *action;
> + const struct arg *arg;
> + struct buffer *out = buf;
> + uint8_t *data = NULL;
> + int ret;
> + uint16_t idx;
> +
> + RTE_SET_USED(token);
> + RTE_SET_USED(buf);
> + RTE_SET_USED(size);
> + if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
> + return -1;
> + arg = ARGS_ENTRY_ARB_BOUNDED
> + (offsetof(struct action_raw_encap_data, idx),
> + sizeof(((struct action_raw_encap_data *)0)->idx),
> + 0, RAW_ENCAP_CONFS_MAX_NUM);
> + if (push_args(ctx, arg))
> + return -1;
> + ret = parse_int(ctx, token, str, len, NULL, 0);
> + if (ret < 0) {
> + pop_args(ctx);
> + return -1;
> + }
> + if (!ctx->object)
> + return len;
> + action = &out->args.vc.actions[out->args.vc.actions_n - 1];
> + action_raw_encap_data = ctx->object;
> + idx = action_raw_encap_data->idx;
> + /* data stored from tail of data buffer */
> + data = (uint8_t *)&(raw_encap_confs[idx].data) +
> + ACTION_RAW_ENCAP_MAX_DATA - raw_encap_confs[idx].size;
> + action_raw_encap_data->conf.data = data;
> + action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
> + action_raw_encap_data->conf.preserve = NULL;
> + action->conf = &action_raw_encap_data->conf;
> + return len;
> +}
> +
> static int
> parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
> const char *str, unsigned int len, void *buf,
> @@ -4430,7 +4572,7 @@ parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
> {
> struct buffer *out = buf;
> struct rte_flow_action *action;
> - struct rte_flow_action_raw_encap *action_raw_encap_conf = NULL;
> + struct action_raw_encap_data *action_raw_encap_data = NULL;
> uint8_t *data = NULL;
> int ret;
>
> @@ -4447,14 +4589,14 @@ parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
> ctx->object = out->args.vc.data;
> ctx->objmask = NULL;
> /* Copy the headers to the buffer. */
> - action_raw_encap_conf = ctx->object;
> + action_raw_encap_data = ctx->object;
> /* data stored from tail of data buffer */
> - data = (uint8_t *)&(raw_encap_conf.data) +
> - ACTION_RAW_ENCAP_MAX_DATA - raw_encap_conf.size;
> - action_raw_encap_conf->data = data;
> - action_raw_encap_conf->preserve = NULL;
> - action_raw_encap_conf->size = raw_encap_conf.size;
> - action->conf = action_raw_encap_conf;
> + data = (uint8_t *)&(raw_encap_confs[0].data) +
> + ACTION_RAW_ENCAP_MAX_DATA - raw_encap_confs[0].size;
> + action_raw_encap_data->conf.data = data;
> + action_raw_encap_data->conf.preserve = NULL;
> + action_raw_encap_data->conf.size = raw_encap_confs[0].size;
> + action->conf = &action_raw_encap_data->conf;
> return ret;
> }
>
> @@ -4465,7 +4607,7 @@ parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
> {
> struct buffer *out = buf;
> struct rte_flow_action *action;
> - struct rte_flow_action_raw_decap *action_raw_decap_conf = NULL;
> + struct action_raw_decap_data *action_raw_decap_data = NULL;
> uint8_t *data = NULL;
> int ret;
>
> @@ -4482,13 +4624,13 @@ parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
> ctx->object = out->args.vc.data;
> ctx->objmask = NULL;
> /* Copy the headers to the buffer. */
> - action_raw_decap_conf = ctx->object;
> + action_raw_decap_data = ctx->object;
> /* data stored from tail of data buffer */
> - data = (uint8_t *)&(raw_decap_conf.data) +
> - ACTION_RAW_ENCAP_MAX_DATA - raw_decap_conf.size;
> - action_raw_decap_conf->data = data;
> - action_raw_decap_conf->size = raw_decap_conf.size;
> - action->conf = action_raw_decap_conf;
> + data = (uint8_t *)&(raw_decap_confs[0].data) +
> + ACTION_RAW_ENCAP_MAX_DATA - raw_decap_confs[0].size;
> + action_raw_decap_data->conf.data = data;
> + action_raw_decap_data->conf.size = raw_decap_confs[0].size;
> + action->conf = &action_raw_decap_data->conf;
> return ret;
> }
>
> @@ -5167,6 +5309,7 @@ parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
> return -1;
> ctx->objdata = 0;
> ctx->objmask = NULL;
> + ctx->object = out;
> if (!out->command)
> return -1;
> out->command = ctx->curr;
> @@ -5777,15 +5920,16 @@ cmd_set_raw_parsed(const struct buffer *in)
> size_t *total_size = NULL;
> uint16_t upper_layer = 0;
> uint16_t proto = 0;
> + uint16_t idx = in->port; /* We borrow port field as index */
>
> RTE_ASSERT(in->command == SET_RAW_ENCAP ||
> in->command == SET_RAW_DECAP);
> if (in->command == SET_RAW_ENCAP) {
> - total_size = &raw_encap_conf.size;
> - data = (uint8_t *)&raw_encap_conf.data;
> + total_size = &raw_encap_confs[idx].size;
> + data = (uint8_t *)&raw_encap_confs[idx].data;
> } else {
> - total_size = &raw_decap_conf.size;
> - data = (uint8_t *)&raw_decap_conf.data;
> + total_size = &raw_decap_confs[idx].size;
> + data = (uint8_t *)&raw_decap_confs[idx].data;
> }
> *total_size = 0;
> memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
> --
> 2.21.0
>
prev parent reply other threads:[~2019-09-20 13:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-31 8:28 Xiaoyu Min
2019-09-20 13:55 ` Jack Min [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190920135502.hdzsmib4r5hv4vmd@mellanox.com \
--to=jackmin@mellanox.com \
--cc=adrien.mazarguil@6wind.com \
--cc=bernard.iremonger@intel.com \
--cc=dev@dpdk.org \
--cc=jingjing.wu@intel.com \
--cc=orika@mellanox.com \
--cc=wenzhuo.lu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).