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 D7172A0352; Thu, 16 Jan 2020 15:10:45 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6E1571D528; Thu, 16 Jan 2020 15:10:45 +0100 (CET) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70053.outbound.protection.outlook.com [40.107.7.53]) by dpdk.org (Postfix) with ESMTP id EAB281D51D for ; Thu, 16 Jan 2020 15:10:43 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aRGVRBsfde0TZrjL1ZwNH6Miuvo2dvuC2dzjeclxF/IrAyuZiOTWqd824ICFEbaM2spmPfHaRDvif68wfy6Xr63qW/Uh0CkStEu1F1JfX4AcgODsIfg0sA0YMT6iVGt24xjn+dBAco9h/2/iY7oW69rxhPdfQExagUdIN1ZPFmn0JWdC3xOFaDXhiely1hTjwYn3Qc3ZtQKYF+cvVjWk6NmOM3/fwvNAU0b/wA1kOH9MYGLICGCrXVeMXjzZKauA5/Drop8tJO2HlVWDhJHqgSBClb7IXYF/cqw+vOf9IkBsAqzFR2xnf4+dFj86L+UFeqNCsSJBIRXl2yY/Z/lE1g== 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=Fi5+BdUIKmoBxjCcwkX1PWZzEAZne2OYb/3srpz4khg=; b=VAYkgVBvIu7pQ/f/w/Dynt8wUZScyWFd8HFHxsDoH7UoqikSbbDUxt15B0xjte5XV+G0KrAA+2csKlRBVFaRHEyFXeHFGnSaoIsvXSJ3lkAWfgkmKbX7fK1qnkFHSjQbvSm2LdxBoV8favGorKM1A2rU503KK8QsBdYrlCnW8VhhW4Qxj26evH3iDr2nCE/txf5iuwERy7lctbE6T1ivik3O76tzdOhfU7NPypoZK45IQVN8jo4YqE0vSHOY0167HPdqrR7g1KaEWGYcL0fKicJR8alvrH4cWMqxGODIMYQiwiegPxzDnnzHsIjFMYBWjgFNdX0zWQJOTwR2ye4u9A== 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=Fi5+BdUIKmoBxjCcwkX1PWZzEAZne2OYb/3srpz4khg=; b=ZzKfi4KSPNSeJ7te2qq9kti42li5C2a5BmKwU2WlD+v6ZYoAZzBen2kXP2JIRjDUUza0U3HEG4Hm/2Y46OXSRYzWXBcm6w8RmCzulyqYfJ6qK1NJoY0Kyl6bRPmVVapyQEXoX/e7hvuuNSsrINAfISt3ZPxynH7p/j3nrZ9jzXc= Received: from AM5PR0501MB2579.eurprd05.prod.outlook.com (10.169.150.151) by AM5PR0501MB2516.eurprd05.prod.outlook.com (10.169.153.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.20; Thu, 16 Jan 2020 14:10:42 +0000 Received: from AM5PR0501MB2579.eurprd05.prod.outlook.com ([fe80::189a:c6d4:a60d:9a19]) by AM5PR0501MB2579.eurprd05.prod.outlook.com ([fe80::189a:c6d4:a60d:9a19%8]) with mapi id 15.20.2644.015; Thu, 16 Jan 2020 14:10:42 +0000 From: Ori Kam To: Jack Min , "jerinjacobk@gmail.com" , Slava Ovsiienko , Matan Azrad , Raslan Darawsheh , Adrien Mazarguil , Wenzhuo Lu , Jingjing Wu , Bernard Iremonger CC: "dev@dpdk.org" , "Xueming(Steven) Li" Thread-Topic: [PATCH 3/5] app/testpmd: new flow dump CLI Thread-Index: AQHVzFXt98E5Z033Sk+KofrrDYoGw6ftToCg Date: Thu, 16 Jan 2020 14:10:42 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=orika@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 7e9a9721-67be-49f6-ab2c-08d79a8ddf56 x-ms-traffictypediagnostic: AM5PR0501MB2516:|AM5PR0501MB2516: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr,ExtFwd x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:635; x-forefront-prvs: 02843AA9E0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(366004)(136003)(396003)(346002)(376002)(39860400002)(189003)(199004)(8936002)(71200400001)(86362001)(81166006)(2906002)(81156014)(8676002)(66556008)(186003)(64756008)(5660300002)(66476007)(26005)(66946007)(66446008)(76116006)(478600001)(316002)(33656002)(54906003)(6506007)(55016002)(9686003)(107886003)(4326008)(52536014)(110136005)(7696005); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0501MB2516; H:AM5PR0501MB2579.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ihZg+Up4SvKFiE700QfDi0lk7MjXozTutSXbI5GIe2vaiRoPyxv/jeQhGoRbtRx9c8jZyOO7bmHL3umtw8XzIRjr/hJSRdisVXgdPUQXJOhmfUv7TBms8eX+YXAcOEIVxgrk36+rzi80sXalm2uRLP3CdJ9vluLAW3elvAQKYCSfEb3heBmY/MNFZNx5rTuYtDkfJTardDPdkWDdfWijOADSz3IyjpAXmwjpjqmjprh042bcVhVGEhyIbH9A6UnbUBL/c0/QOkY0InVlwpfdv59rALQY+TC1Ef0CRHQjZ9V+DhlGt7BdmCKno8zsg6ZVn23OgriTjbfVutdEufCe4r/teIc8ZFwFIe5lsUBEXW77l2A9XJ0s0udt7DzdxIOC1yxC+eWknKSpOnw3v4isqc5a11M8Mx6s5os4u3ztgcMbTLMQk3MWMx7nNYAWtziL Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7e9a9721-67be-49f6-ab2c-08d79a8ddf56 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Jan 2020 14:10:42.2930 (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: pm61oon/hV7hrtCS4/1sxz53TlQrkbffyK+arHKgeETP1wHOW72d4AT5xZoQDTvmCSN6yd4aPbQuXMeNemnmqw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0501MB2516 Subject: Re: [dpdk-dev] [PATCH 3/5] app/testpmd: new flow dump CLI 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----- > Subject: [PATCH 3/5] app/testpmd: new flow dump CLI >=20 > From: Xueming Li >=20 > New flow dump CLI to dump device internal representation information > of flows into screen. >=20 > Signed-off-by: Xueming Li > Signed-off-by: Xiaoyu Min > --- Acked-by: Ori Kam Thanks, Ori > app/test-pmd/cmdline_flow.c | 91 > +++++++++++++++++++++++++++++++++++++ > app/test-pmd/config.c | 27 +++++++++++ > app/test-pmd/testpmd.h | 1 + > 3 files changed, 119 insertions(+) >=20 > diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c > index 99dade7d8c..19336e5d42 100644 > --- a/app/test-pmd/cmdline_flow.c > +++ b/app/test-pmd/cmdline_flow.c > @@ -41,6 +41,7 @@ enum index { > BOOLEAN, > STRING, > HEX, > + FILE_PATH, > MAC_ADDR, > IPV4_ADDR, > IPV6_ADDR, > @@ -63,6 +64,7 @@ enum index { > CREATE, > DESTROY, > FLUSH, > + DUMP, > QUERY, > LIST, > ISOLATE, > @@ -631,6 +633,9 @@ struct buffer { > uint32_t *rule; > uint32_t rule_n; > } destroy; /**< Destroy arguments. */ > + struct { > + char file[128]; > + } dump; /**< Dump arguments. */ > struct { > uint32_t rule; > struct rte_flow_action action; > @@ -685,6 +690,12 @@ static const enum index next_destroy_attr[] =3D { > ZERO, > }; >=20 > +static const enum index next_dump_attr[] =3D { > + FILE_PATH, > + END, > + ZERO, > +}; > + > static const enum index next_list_attr[] =3D { > LIST_GROUP, > END, > @@ -1374,6 +1385,9 @@ static int parse_destroy(struct context *, const > struct token *, > static int parse_flush(struct context *, const struct token *, > const char *, unsigned int, > void *, unsigned int); > +static int parse_dump(struct context *, const struct token *, > + const char *, unsigned int, > + void *, unsigned int); > static int parse_query(struct context *, const struct token *, > const char *, unsigned int, > void *, unsigned int); > @@ -1401,6 +1415,9 @@ static int parse_string(struct context *, const str= uct > token *, > static int parse_hex(struct context *ctx, const struct token *token, > const char *str, unsigned int len, > void *buf, unsigned int size); > +static int parse_string0(struct context *, const struct token *, > + const char *, unsigned int, > + void *, unsigned int); > static int parse_mac_addr(struct context *, const struct token *, > const char *, unsigned int, > void *, unsigned int); > @@ -1494,6 +1511,12 @@ static const struct token token_list[] =3D { > .type =3D "HEX", > .help =3D "fixed string", > .call =3D parse_hex, > + }, > + [FILE_PATH] =3D { > + .name =3D "{file path}", > + .type =3D "STRING", > + .help =3D "file path", > + .call =3D parse_string0, > .comp =3D comp_none, > }, > [MAC_ADDR] =3D { > @@ -1555,6 +1578,7 @@ static const struct token token_list[] =3D { > CREATE, > DESTROY, > FLUSH, > + DUMP, > LIST, > QUERY, > ISOLATE)), > @@ -1589,6 +1613,14 @@ static const struct token token_list[] =3D { > .args =3D ARGS(ARGS_ENTRY(struct buffer, port)), > .call =3D parse_flush, > }, > + [DUMP] =3D { > + .name =3D "dump", > + .help =3D "dump all flow rules to file", > + .next =3D NEXT(next_dump_attr, NEXT_ENTRY(PORT_ID)), > + .args =3D ARGS(ARGS_ENTRY(struct buffer, args.dump.file), > + ARGS_ENTRY(struct buffer, port)), > + .call =3D parse_dump, > + }, > [QUERY] =3D { > .name =3D "query", > .help =3D "query an existing flow rule", > @@ -5012,6 +5044,33 @@ parse_flush(struct context *ctx, const struct toke= n > *token, > return len; > } >=20 > +/** Parse tokens for dump command. */ > +static int > +parse_dump(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; > + if (!out->command) { > + if (ctx->curr !=3D DUMP) > + return -1; > + if (sizeof(*out) > size) > + return -1; > + out->command =3D ctx->curr; > + ctx->objdata =3D 0; > + ctx->object =3D out; > + ctx->objmask =3D NULL; > + } > + return len; > +} > + > /** Parse tokens for query command. */ > static int > parse_query(struct context *ctx, const struct token *token, > @@ -5409,6 +5468,35 @@ parse_hex(struct context *ctx, const struct token > *token, >=20 > } >=20 > +/** > + * Parse a zero-ended string. > + */ > +static int > +parse_string0(struct context *ctx, const struct token *token __rte_unuse= d, > + const char *str, unsigned int len, > + void *buf, unsigned int size) > +{ > + const struct arg *arg_data =3D pop_args(ctx); > + > + /* Arguments are expected. */ > + if (!arg_data) > + return -1; > + size =3D arg_data->size; > + /* Bit-mask fill is not supported. */ > + if (arg_data->mask || size < len + 1) > + goto error; > + if (!ctx->object) > + return len; > + buf =3D (uint8_t *)ctx->object + arg_data->offset; > + strncpy(buf, str, len); > + if (ctx->objmask) > + memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, > len); > + return len; > +error: > + push_args(ctx, arg_data); > + return -1; > +} > + > /** > * Parse a MAC address. > * > @@ -6068,6 +6156,9 @@ cmd_flow_parsed(const struct buffer *in) > case FLUSH: > port_flow_flush(in->port); > break; > + case DUMP: > + port_flow_dump(in->port, in->args.dump.file); > + break; > case QUERY: > port_flow_query(in->port, in->args.query.rule, > &in->args.query.action); > diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c > index 9da1ffb034..1b4bdf7bf3 100644 > --- a/app/test-pmd/config.c > +++ b/app/test-pmd/config.c > @@ -1441,6 +1441,33 @@ port_flow_flush(portid_t port_id) > return ret; > } >=20 > +/** Dump all flow rules. */ > +int > +port_flow_dump(portid_t port_id, const char *file_name) > +{ > + int ret =3D 0; > + FILE *file =3D stdout; > + struct rte_flow_error error; > + > + if (file_name && strlen(file_name)) { > + file =3D fopen(file_name, "w"); > + if (!file) { > + printf("Failed to create file %s: %s\n", file_name, > + strerror(errno)); > + return -errno; > + } > + } > + ret =3D rte_flow_dev_dump(port_id, file, &error); > + if (ret) { > + port_flow_complain(&error); > + printf("Failed to dump flow: %s\n", strerror(-ret)); > + } else > + printf("Flow dump finished\n"); > + if (file_name && strlen(file_name)) > + fclose(file); > + return ret; > +} > + > /** Query a flow rule. */ > int > port_flow_query(portid_t port_id, uint32_t rule, > diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h > index 857a11f8de..e1b9aba360 100644 > --- a/app/test-pmd/testpmd.h > +++ b/app/test-pmd/testpmd.h > @@ -734,6 +734,7 @@ int port_flow_create(portid_t port_id, > const struct rte_flow_action *actions); > int port_flow_destroy(portid_t port_id, uint32_t n, const uint32_t *rule= ); > int port_flow_flush(portid_t port_id); > +int port_flow_dump(portid_t port_id, const char *file_name); > int port_flow_query(portid_t port_id, uint32_t rule, > const struct rte_flow_action *action); > void port_flow_list(portid_t port_id, uint32_t n, const uint32_t *group)= ; > -- > 2.24.1