From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 67AA1A0523; Tue, 30 Jun 2020 17:23:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 084531C065; Tue, 30 Jun 2020 17:23:35 +0200 (CEST) Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10062.outbound.protection.outlook.com [40.107.1.62]) by dpdk.org (Postfix) with ESMTP id 450661C039 for ; Tue, 30 Jun 2020 17:23:33 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tn6istPagqg79MzRiOLik1YBBZ/vENquh8E8UUIhAb89DSeefkoUxTDkSc4L0HxeD9izrUaGNWBeMHHibqqNAuTceV/t7B6kKyh3CtMsFYCqn5LQWc+bsqWY6/cMscObCRddVBvHKWuIYRFeVuMpMz1b2XC6dT/2DhRRYWSi7X7BD7fZkWQ4PvJmyoJNCd9pMqZmYU3WpGbb9DCi9aVD2mjcYXBGV5Ib7l4DdgSlUOrp2WP6a8Pw16p5rWF2HmbPzGNI6ZDd/1ARLboDxNuM8Dgop/YiNBAYWo87OGLk4eKi8CvTeGuS6DOoL7V43i68+N0AjcIm5How6oipZesf/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mE/EWrrr8WhNHyLbO59GsEG2FtUco66JrGiH/er3DQ8=; b=GHv3YDpuEXjGfHRk81iP7HEr8X0gq5NORTbgpWdAvrG56VqAl+Hk/6C8KQbcl2MUGuQWt4Z6uKWxijTG/cMXtq7wkfoidV96xdI0AcQGVl41SapnrIHS/MwkBGTtAtzLZZjM8YCimkew5230cDMsMd1I/ruLT4+8Tk/YFl42dfFEIXCkjPnUYqRoz1rt96iT01IMiB7RYCyT2fi3MEXrpe6BfbAvUJCMMwVNTh++qeBLk3ASyfs0zVysbsr7+FkVYrCROzcnaUvrb5TghyVgKTvp9a3v0k/gL4TFYmJNANmijP/J6/pK/EwxLGGhM3BNRhHWYFlp5ezfU/iPBUOpNg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mE/EWrrr8WhNHyLbO59GsEG2FtUco66JrGiH/er3DQ8=; b=bFX7frYXAwq73JU4sRkqIR3Fgjx3AM1j6uxY+z4RS6vCfQOBEIfZGu8sB+Ntmz1r5zFxP75ZIWW1KS1GtFXYDW/nXAniYjbFZ9KYxgoKCw0/UFy+mwvyW8Q9y6Q5znG/Ac1+0Shkdwyv942R9sHZ+fzcF9sj6TIjJvfsLz80Z/Y= Received: from AM6PR05MB5176.eurprd05.prod.outlook.com (2603:10a6:20b:63::30) by AM6PR05MB5222.eurprd05.prod.outlook.com (2603:10a6:20b:3e::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.23; Tue, 30 Jun 2020 15:23:29 +0000 Received: from AM6PR05MB5176.eurprd05.prod.outlook.com ([fe80::9024:accb:4d6b:805f]) by AM6PR05MB5176.eurprd05.prod.outlook.com ([fe80::9024:accb:4d6b:805f%3]) with mapi id 15.20.3131.027; Tue, 30 Jun 2020 15:23:29 +0000 From: Ori Kam To: "Jiawei(Jonny) Wang" , Slava Ovsiienko , Matan Azrad CC: "dev@dpdk.org" , Thomas Monjalon , Raslan Darawsheh , "ian.stokes@intel.com" , "fbl@redhat.com" , "Jiawei(Jonny) Wang" Thread-Topic: [PATCH 8/8] app/testpmd: add testpmd command for sample action Thread-Index: AQHWSxDCJvtNKwA9RUqoN1vKFR/HX6jxTFYg Date: Tue, 30 Jun 2020 15:23:29 +0000 Message-ID: References: <1593102379-400132-1-git-send-email-jiaweiw@mellanox.com> <1593102379-400132-9-git-send-email-jiaweiw@mellanox.com> In-Reply-To: <1593102379-400132-9-git-send-email-jiaweiw@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: mellanox.com; dkim=none (message not signed) header.d=none;mellanox.com; dmarc=none action=none header.from=mellanox.com; x-originating-ip: [147.236.152.129] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 27c43a80-d7d6-4592-5655-08d81d098b17 x-ms-traffictypediagnostic: AM6PR05MB5222: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtFwd,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3968; x-forefront-prvs: 0450A714CB x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: BUc3G4fCpLQpsPviO/9n+mX5liaki0W++5S7gMtWmyYwGnf4K5sjG4MDBJPbeA6Sp01zNqAZVqwknAhuDTHAvkENn8gZQSx4v7rKxm3mOJmmX6twFyKpWdWBWuvc5jTh0MpFBbu11sdKsaxgl88xxMJEI87Ve8jkXY9v9KWmi5eX3KgFwRa64bEePVUksnjmlpQEkzyebD03YQ4r9ljM8NqXRVDfHQhgou2EtoN4Qj9qnSYOlhhSNA5187ZTgu98Z647ebpJ14XdHA68LJRMw0ZwDZD42yjKObbPIEQlLbdYYWJ9/TP2nJJBIJkkeLcH x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR05MB5176.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(39860400002)(366004)(346002)(136003)(396003)(376002)(6506007)(26005)(53546011)(7696005)(2906002)(110136005)(54906003)(8676002)(478600001)(6636002)(8936002)(71200400001)(186003)(83380400001)(5660300002)(55016002)(30864003)(86362001)(66556008)(64756008)(66446008)(66476007)(66946007)(76116006)(4326008)(33656002)(52536014)(9686003)(316002)(107886003); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: vBNvxuwjWzesVnhzFPZ04prWWCRHTb25nPVYc1sIUJ1kWw3ltwAi4g6z9VoZdcFh3zFUjg1Ppe9X+yyGIRPzhP3UnwGDzzMWpvBPyKF42SiYjl6AdXhdTC+B2rKLfWxXwGBFRtWos+TmvVaGxA9uHreBToeo3VkN23CEldJOmaRNNUTKwxdNNvSKG09rXiVTivcyEP9yfWkteo74+s2qq88moHecNW14nN0ajRLaYef5glM+uaQZc9IqHttJmgUEgK9aVCybCh+xHBoaUmipyeVBhzF528/9ruGxfCicutro474+YZ+XFTO6gjD14SnD+eeC5g4BnGE6Mhh7ypQYf6F1ztQfDHqkQB6eQeG69CpePQf9fsoTQQBiUAJvQ8mpRMxsKF/q+QKmrieWonElPjM6EwYBkoTiycZv7Q87WdG47SKStu6NS0C7qbtcYEhommhURQ9+P5It4WhADbI70QQR3qLrl4ZXoDxwj5WPUtybW76GqmPDH1AKxmCOoytf Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM6PR05MB5176.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 27c43a80-d7d6-4592-5655-08d81d098b17 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Jun 2020 15:23:29.7429 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: /KFE1rTAhIkWQ4KiCzJvsFxaXBjzu8xVYngEUGNTQdp3D44Z6HEQlwkceB2WFnHxopmm4AnYsnL3ssjT+zwUPA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR05MB5222 Subject: Re: [dpdk-dev] [PATCH 8/8] app/testpmd: add testpmd command for sample action X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > -----Original Message----- > From: Jiawei Wang > Sent: Thursday, June 25, 2020 7:26 PM > To: Ori Kam ; Slava Ovsiienko > ; Matan Azrad > Cc: dev@dpdk.org; Thomas Monjalon ; Raslan > Darawsheh ; ian.stokes@intel.com; fbl@redhat.com; > Jiawei(Jonny) Wang > Subject: [PATCH 8/8] app/testpmd: add testpmd command for sample action >=20 > Add a new testpmd command 'set sample_actions' that supports the multiple > sample actions list configuration by using the index: > set sample_actions >=20 > The examples for the sample flow use case and result as below: >=20 > 1. set sample_actions 0 mark id 0x8 / queue index 2 / end > .. pattern eth / end actions sample ratio 2 index 0 / jump group 2 ... >=20 > This flow will result in all the matched ingress packets will be > jumped to next flow table, and the each second packet will be > marked and sent to queue 2 of the control application. >=20 > 2. ...pattern eth / end actions sample ratio 2 / port_id id 2 ... >=20 > The flow will result in all the matched ingress packets will be sent to > port 2, and the each second packet will also be sent to e-switch > manager vport. >=20 > Signed-off-by: Jiawei Wang > --- > app/test-pmd/cmdline_flow.c | 285 > ++++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 276 insertions(+), 9 deletions(-) >=20 > diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c > index 4e2006c..6b1e515 100644 > --- a/app/test-pmd/cmdline_flow.c > +++ b/app/test-pmd/cmdline_flow.c > @@ -56,6 +56,8 @@ enum index { > SET_RAW_ENCAP, > SET_RAW_DECAP, > SET_RAW_INDEX, > + SET_SAMPLE_ACTIONS, > + SET_SAMPLE_INDEX, >=20 > /* Top-level command. */ > FLOW, > @@ -349,6 +351,10 @@ enum index { > ACTION_SET_IPV6_DSCP_VALUE, > ACTION_AGE, > ACTION_AGE_TIMEOUT, > + ACTION_SAMPLE, > + ACTION_SAMPLE_RATIO, > + ACTION_SAMPLE_INDEX, > + ACTION_SAMPLE_INDEX_VALUE, > }; >=20 > /** Maximum size for pattern in struct rte_flow_item_raw. */ > @@ -484,6 +490,22 @@ struct action_nvgre_encap_data { >=20 > struct mplsoudp_decap_conf mplsoudp_decap_conf; >=20 > +#define ACTION_SAMPLE_ACTIONS_NUM 10 > +#define RAW_SAMPLE_CONFS_MAX_NUM 8 > +/** Storage for struct rte_flow_action_sample including external data. *= / > +struct action_sample_data { > + struct rte_flow_action_sample conf; > + uint32_t idx; > +}; > +/** Storage for struct rte_flow_action_sample. */ > +struct raw_sample_conf { > + struct rte_flow_action data[ACTION_SAMPLE_ACTIONS_NUM]; > +}; > +struct raw_sample_conf > raw_sample_confs[RAW_SAMPLE_CONFS_MAX_NUM]; > +struct rte_flow_action_mark > sample_mark[RAW_SAMPLE_CONFS_MAX_NUM]; > +struct rte_flow_action_queue > sample_queue[RAW_SAMPLE_CONFS_MAX_NUM]; > +struct rte_flow_action_count > sample_count[RAW_SAMPLE_CONFS_MAX_NUM]; > + > /** Maximum number of subsequent tokens and arguments on the stack. */ > #define CTX_STACK_SIZE 16 >=20 > @@ -1161,6 +1183,7 @@ struct parse_action_priv { > ACTION_SET_IPV4_DSCP, > ACTION_SET_IPV6_DSCP, > ACTION_AGE, > + ACTION_SAMPLE, > ZERO, > }; >=20 > @@ -1393,9 +1416,28 @@ struct parse_action_priv { > ZERO, > }; >=20 > +static const enum index action_sample[] =3D { > + ACTION_SAMPLE, > + ACTION_SAMPLE_RATIO, > + ACTION_SAMPLE_INDEX, > + ACTION_NEXT, > + ZERO, > +}; > + > +static const enum index next_action_sample[] =3D { > + ACTION_QUEUE, > + ACTION_MARK, > + ACTION_COUNT, > + ACTION_NEXT, > + ZERO, > +}; > + > static int parse_set_raw_encap_decap(struct context *, const struct toke= n *, > const char *, unsigned int, > void *, unsigned int); > +static int parse_set_sample_action(struct context *, const struct token = *, > + const char *, unsigned int, > + void *, unsigned int); > static int parse_set_init(struct context *, const struct token *, > const char *, unsigned int, > void *, unsigned int); > @@ -1460,7 +1502,15 @@ static int parse_vc_action_raw_decap_index(struct > context *, > static int parse_vc_action_set_meta(struct context *ctx, > const struct token *token, const char *str, > unsigned int len, void *buf, > + unsigned int size); > +static int parse_vc_action_sample(struct context *ctx, > + const struct token *token, const char *str, > + unsigned int len, void *buf, > unsigned int size); > +static int > +parse_vc_action_sample_index(struct context *ctx, const struct token *to= ken, > + const char *str, unsigned int len, void *buf, > + unsigned int size); > static int parse_destroy(struct context *, const struct token *, > const char *, unsigned int, > void *, unsigned int); > @@ -1531,6 +1581,8 @@ static int comp_vc_action_rss_queue(struct context > *, const struct token *, > unsigned int, char *, unsigned int); > static int comp_set_raw_index(struct context *, const struct token *, > unsigned int, char *, unsigned int); > +static int comp_set_sample_index(struct context *, const struct token *, > + unsigned int, char *, unsigned int); >=20 > /** Token definitions. */ > static const struct token token_list[] =3D { > @@ -3612,11 +3664,13 @@ static int comp_set_raw_index(struct context *, > const struct token *, > /* Top level command. */ > [SET] =3D { > .name =3D "set", > - .help =3D "set raw encap/decap data", > - .type =3D "set raw_encap|raw_decap ", > + .help =3D "set raw encap/decap/sample data", > + .type =3D "set raw_encap|raw_decap " > + " or set sample_actions ", > .next =3D NEXT(NEXT_ENTRY > (SET_RAW_ENCAP, > - SET_RAW_DECAP)), > + SET_RAW_DECAP, > + SET_SAMPLE_ACTIONS)), > .call =3D parse_set_init, > }, > /* Sub-level commands. */ > @@ -3647,6 +3701,23 @@ static int comp_set_raw_index(struct context *, > const struct token *, > .next =3D NEXT(next_item), > .call =3D parse_port, > }, > + [SET_SAMPLE_INDEX] =3D { > + .name =3D "{index}", > + .type =3D "UNSIGNED", > + .help =3D "index of sample actions", > + .next =3D NEXT(next_action_sample), > + .call =3D parse_port, > + }, > + [SET_SAMPLE_ACTIONS] =3D { > + .name =3D "sample_actions", > + .help =3D "set sample actions list", > + .next =3D NEXT(NEXT_ENTRY(SET_SAMPLE_INDEX)), > + .args =3D ARGS(ARGS_ENTRY_ARB_BOUNDED > + (offsetof(struct buffer, port), > + sizeof(((struct buffer *)0)->port), > + 0, RAW_SAMPLE_CONFS_MAX_NUM - 1)), > + .call =3D parse_set_sample_action, > + }, > [ACTION_SET_TAG] =3D { > .name =3D "set_tag", > .help =3D "set tag", > @@ -3750,6 +3821,37 @@ static int comp_set_raw_index(struct context *, > const struct token *, > .next =3D NEXT(action_age, NEXT_ENTRY(UNSIGNED)), > .call =3D parse_vc_conf, > }, > + [ACTION_SAMPLE] =3D { > + .name =3D "sample", > + .help =3D "set a sample action", > + .next =3D NEXT(action_sample), > + .priv =3D PRIV_ACTION(SAMPLE, > + sizeof(struct action_sample_data)), > + .call =3D parse_vc_action_sample, > + }, > + [ACTION_SAMPLE_RATIO] =3D { > + .name =3D "ratio", > + .help =3D "flow sample ratio value", > + .next =3D NEXT(action_sample, NEXT_ENTRY(UNSIGNED)), > + .args =3D ARGS(ARGS_ENTRY_ARB > + (offsetof(struct action_sample_data, conf) + > + offsetof(struct rte_flow_action_sample, ratio), > + sizeof(((struct rte_flow_action_sample *)0)-> > + ratio))), > + }, > + [ACTION_SAMPLE_INDEX] =3D { > + .name =3D "index", > + .help =3D "the index of sample actions list", > + .next =3D NEXT(NEXT_ENTRY(ACTION_SAMPLE_INDEX_VALUE)), > + }, > + [ACTION_SAMPLE_INDEX_VALUE] =3D { > + .name =3D "{index}", > + .type =3D "UNSIGNED", > + .help =3D "unsigned integer value", > + .next =3D NEXT(NEXT_ENTRY(ACTION_NEXT)), > + .call =3D parse_vc_action_sample_index, > + .comp =3D comp_set_sample_index, > + }, > }; >=20 > /** Remove and return last entry from argument stack. */ > @@ -5207,6 +5309,76 @@ static int comp_set_raw_index(struct context *, > const struct token *, > return len; > } >=20 > +static int > +parse_vc_action_sample(struct context *ctx, const struct token *token, > + const char *str, unsigned int len, void *buf, > + unsigned int size) > +{ > + struct buffer *out =3D buf; > + struct rte_flow_action *action; > + struct action_sample_data *action_sample_data =3D NULL; > + static struct rte_flow_action end_action =3D { > + RTE_FLOW_ACTION_TYPE_END, 0 > + }; > + int ret; > + > + ret =3D parse_vc(ctx, token, str, len, buf, size); > + if (ret < 0) > + return ret; > + /* Nothing else to do if there is no buffer. */ > + if (!out) > + return ret; > + if (!out->args.vc.actions_n) > + return -1; > + action =3D &out->args.vc.actions[out->args.vc.actions_n - 1]; > + /* Point to selected object. */ > + ctx->object =3D out->args.vc.data; > + ctx->objmask =3D NULL; > + /* Copy the headers to the buffer. */ > + action_sample_data =3D ctx->object; > + action_sample_data->conf.actions =3D &end_action; > + action->conf =3D &action_sample_data->conf; > + return ret; > +} > + > +static int > +parse_vc_action_sample_index(struct context *ctx, const struct token *to= ken, > + const char *str, unsigned int len, void *buf, > + unsigned int size) > +{ > + struct action_sample_data *action_sample_data; > + struct rte_flow_action *action; > + const struct arg *arg; > + struct buffer *out =3D buf; > + int ret; > + uint16_t idx; > + > + RTE_SET_USED(token); > + RTE_SET_USED(buf); > + RTE_SET_USED(size); > + if (ctx->curr !=3D ACTION_SAMPLE_INDEX_VALUE) > + return -1; > + arg =3D ARGS_ENTRY_ARB_BOUNDED > + (offsetof(struct action_sample_data, idx), > + sizeof(((struct action_sample_data *)0)->idx), > + 0, RAW_SAMPLE_CONFS_MAX_NUM - 1); > + if (push_args(ctx, arg)) > + return -1; > + ret =3D parse_int(ctx, token, str, len, NULL, 0); > + if (ret < 0) { > + pop_args(ctx); > + return -1; > + } > + if (!ctx->object) > + return len; > + action =3D &out->args.vc.actions[out->args.vc.actions_n - 1]; > + action_sample_data =3D ctx->object; > + idx =3D action_sample_data->idx; > + action_sample_data->conf.actions =3D raw_sample_confs[idx].data; > + action->conf =3D &action_sample_data->conf; > + return len; > +} > + > /** Parse tokens for destroy command. */ > static int > parse_destroy(struct context *ctx, const struct token *token, > @@ -5971,6 +6143,38 @@ static int comp_set_raw_index(struct context *, > const struct token *, > if (!out->command) > return -1; > out->command =3D ctx->curr; > + /* For encap/decap we need is pattern */ > + out->args.vc.pattern =3D (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1), > + sizeof(double)); > + return len; > +} > + > +/** Parse set command, initialize output buffer for subsequent tokens. *= / > +static int > +parse_set_sample_action(struct context *ctx, const struct token *token, > + const char *str, unsigned int len, > + void *buf, unsigned int size) > +{ > + struct buffer *out =3D buf; > + > + /* Token name must match. */ > + if (parse_default(ctx, token, str, len, NULL, 0) < 0) > + return -1; > + /* Nothing else to do if there is no buffer. */ > + if (!out) > + return len; > + /* Make sure buffer is large enough. */ > + if (size < sizeof(*out)) > + return -1; > + ctx->objdata =3D 0; > + ctx->objmask =3D NULL; > + ctx->object =3D out; > + if (!out->command) > + return -1; > + out->command =3D ctx->curr; > + /* For sampler we need is actions */ > + out->args.vc.actions =3D (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1), > + sizeof(double)); > return len; > } >=20 > @@ -6007,11 +6211,8 @@ static int comp_set_raw_index(struct context *, > const struct token *, > return -1; > out->command =3D ctx->curr; > out->args.vc.data =3D (uint8_t *)out + size; > - /* All we need is pattern */ > - out->args.vc.pattern =3D > - (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1), > - sizeof(double)); > - ctx->object =3D out->args.vc.pattern; > + ctx->object =3D (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1), > + sizeof(double)); > } > return len; > } > @@ -6162,6 +6363,24 @@ static int comp_set_raw_index(struct context *, > const struct token *, > return nb; > } >=20 > +/** Complete index number for set raw_encap/raw_decap commands. */ > +static int > +comp_set_sample_index(struct context *ctx, const struct token *token, > + unsigned int ent, char *buf, unsigned int size) > +{ > + uint16_t idx =3D 0; > + uint16_t nb =3D 0; > + > + RTE_SET_USED(ctx); > + RTE_SET_USED(token); > + for (idx =3D 0; idx < RAW_SAMPLE_CONFS_MAX_NUM; ++idx) { > + if (buf && idx =3D=3D ent) > + return snprintf(buf, size, "%u", idx); > + ++nb; > + } > + return nb; > +} > + > /** Internal context. */ > static struct context cmd_flow_context; >=20 > @@ -6607,7 +6826,53 @@ static int comp_set_raw_index(struct context *, > const struct token *, > return mask; > } >=20 > - > +/** Dispatch parsed buffer to function calls. */ > +static void > +cmd_set_raw_parsed_sample(const struct buffer *in) > +{ > + uint32_t n =3D in->args.vc.actions_n; > + uint32_t i =3D 0; > + struct rte_flow_action *action =3D NULL; > + struct rte_flow_action *data =3D NULL; > + size_t size =3D 0; > + uint16_t idx =3D in->port; /* We borrow port field as index */ > + uint32_t max_size =3D sizeof(struct rte_flow_action) * > + > ACTION_SAMPLE_ACTIONS_NUM; > + > + RTE_ASSERT(in->command =3D=3D SET_SAMPLE_ACTIONS); > + data =3D (struct rte_flow_action *)&raw_sample_confs[idx].data; > + memset(data, 0x00, max_size); > + for (; i <=3D n - 1; i++) { > + action =3D in->args.vc.actions + i; > + if (action->type =3D=3D RTE_FLOW_ACTION_TYPE_END) > + break; > + switch (action->type) { > + case RTE_FLOW_ACTION_TYPE_MARK: > + size =3D sizeof(struct rte_flow_action_mark); > + rte_memcpy(&sample_mark[idx], > + (const void *)action->conf, size); > + action->conf =3D &sample_mark[idx]; > + break; > + case RTE_FLOW_ACTION_TYPE_COUNT: > + size =3D sizeof(struct rte_flow_action_count); > + rte_memcpy(&sample_count[idx], > + (const void *)action->conf, size); > + action->conf =3D &sample_count[idx]; > + break; > + case RTE_FLOW_ACTION_TYPE_QUEUE: > + size =3D sizeof(struct rte_flow_action_queue); > + rte_memcpy(&sample_queue[idx], > + (const void *)action->conf, size); > + action->conf =3D &sample_queue[idx]; > + break; > + default: > + printf("Error - Not supported action\n"); > + return; > + } > + rte_memcpy(data, action, sizeof(struct rte_flow_action)); > + data++; > + } > +} >=20 > /** Dispatch parsed buffer to function calls. */ > static void > @@ -6624,6 +6889,8 @@ static int comp_set_raw_index(struct context *, > const struct token *, > uint16_t proto =3D 0; > uint16_t idx =3D in->port; /* We borrow port field as index */ >=20 > + if (in->command =3D=3D SET_SAMPLE_ACTIONS) > + return cmd_set_raw_parsed_sample(in); > RTE_ASSERT(in->command =3D=3D SET_RAW_ENCAP || > in->command =3D=3D SET_RAW_DECAP); > if (in->command =3D=3D SET_RAW_ENCAP) { > -- > 1.8.3.1 Acked-by: Ori Kam Thanks, Ori