From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00078.outbound.protection.outlook.com [40.107.0.78]) by dpdk.org (Postfix) with ESMTP id D6B231B12D for ; Tue, 25 Dec 2018 10:54:25 +0100 (CET) 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=FyqCd9Mo25YQ12/5dZPDhmU5TP3But6W3wAsbfrz6vs=; b=Bfkh+HqsqzNSRK7IKEJNi+a1sq+GcR9rHR1hqW56oePwdAhdXGpcUWFTskhTKEtzslrTWr3WppQoYcsqpQpKIvZvV15gCWNZI6dBFuJpJVZc2aeaDrVoPXiKlYxK2AT84wa9fmdo4V+PIKc0Ub/GxxOeNgIBmsKfQ+umvK369vo= Received: from AM4PR05MB3425.eurprd05.prod.outlook.com (10.171.187.142) by AM4PR05MB3282.eurprd05.prod.outlook.com (10.171.186.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1446.24; Tue, 25 Dec 2018 09:54:24 +0000 Received: from AM4PR05MB3425.eurprd05.prod.outlook.com ([fe80::e086:6fd:7477:c605]) by AM4PR05MB3425.eurprd05.prod.outlook.com ([fe80::e086:6fd:7477:c605%3]) with mapi id 15.20.1446.027; Tue, 25 Dec 2018 09:54:24 +0000 From: Ori Kam To: Dekel Peled CC: "dev@dpdk.org" , Dekel Peled Thread-Topic: [dpdk-dev] [PATCH v2] examples/flow_filtering: fix example documentation Thread-Index: AQHUnDasS3KARZUgTU2EV7pcx44iP6WPNxtA Date: Tue, 25 Dec 2018 09:54:24 +0000 Message-ID: References: <1545648636-36614-1-git-send-email-dekelp@mellanox.com> <1545723738-6343-1-git-send-email-dekelp@mellanox.com> In-Reply-To: <1545723738-6343-1-git-send-email-dekelp@mellanox.com> 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: [42.120.102.174] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM4PR05MB3282; 6:yNF9F86tgLlMkeSVDHOW248NrGkGnQBOz+nWbxHw6tJlIgPywUms6ZR60VLIhNTwoFbHgQ/3LnYfOEMTGLRenVI+UTbLqs9atBRgef2Ae2h5ztwGHE+4y4aptr55swoUxWvMwUEngIgTWNWBaTw96nJYvNHN0ryC6NaeWRNGtGuz/toXpt40iisMAjxOYts+MiziJgZuRPrGN8yVY//es4zt1ygD7JWwnil74u81eb75ECrqd+mthjt33u9bd3qVOrtKl9F2YdTZMnidv9RB8raR2Uer9urhQoZes9JolkCTwtpJ3c7NZD/GB5M3NZZL7M2lVS89oOFqW29/gUN6H14n3uX3aXYd5wvchaWl15SLsrdu0O5ZbFoGcOXv2OMGwHyt6aCVWYKlz838k0jsXX4NuMCBgHDhODKI7BSpoPOWR1cL4REGfI/9wtqGNlKVFD/IeQQZkPLRqK6SnogQwg==; 5:7u0EsbbMenwpjSluOviaeIsq1IjAQy6CBojNLuz7Kqc4CeUbdKO1MR/82dK0qxbxzue4lkaNNA0/DvGT91NPl2CMXwmVuZeHKFb/8vuZ3UHUoL8R+NmLtgUUTzrNMTCnN1/uJv3uiHVNbu6xjhBuR3e7E5T87EYaAnNb6d6XAYs=; 7:qe8/Dtzf7M7BYiQ46H2QmJJmfcgkpcZb24Gqs3W1jYKRZwap4t8pn26XjugmfNw9G7esL6iXiEkl6YK/1GEfxNV0p8MT9n4FCP1es0JmvxdKaDNXk85cF+PXp7ocNqEpZXohxV8VFaSM/gi34aA4TA== x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: fd5c13d7-0324-435a-4c16-08d66a4ef396 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM4PR05MB3282; x-ms-traffictypediagnostic: AM4PR05MB3282: x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(908002)(999002)(5005026)(6040522)(2401047)(8121501046)(93006095)(93001095)(3002001)(10201501046)(3231475)(944501520)(52105112)(6055026)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:AM4PR05MB3282; BCL:0; PCL:0; RULEID:; SRVR:AM4PR05MB3282; x-forefront-prvs: 08978A8F5C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(136003)(376002)(396003)(366004)(39860400002)(13464003)(199004)(189003)(229853002)(186003)(6506007)(53546011)(2906002)(71190400001)(446003)(26005)(486006)(6246003)(476003)(11346002)(71200400001)(102836004)(66066001)(6436002)(68736007)(55016002)(4326008)(9686003)(25786009)(7696005)(76176011)(107886003)(6862004)(33656002)(53936002)(97736004)(316002)(99286004)(54906003)(6116002)(3846002)(478600001)(7736002)(256004)(14444005)(14454004)(305945005)(81166006)(105586002)(106356001)(86362001)(8936002)(5660300001)(81156014)(6636002)(74316002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3282; H:AM4PR05MB3425.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: VxtHv1yYNeVQQrzsxpq4t22UL4TPRVszbIObM0IXmptZwPSBdQ0f21tGTG6OYib6m2RI2EQdw1R6oE4q96DdkxjLikI6EZuf0HB29KBKi8DlNp5Q9zEjTYZnunLLP5p5A4V+hy4HdwrbjMZXpBFjXK+gm52o32eq2DevUQrZo1lgiwbva9T2WJqrM9xcDO5RC2Vta9ZmGHRJTP6aWY+/xLzLNSl5ttOefqj7Chni26WGY5+GCzNXMU8pxs4yRlPNHpxudALIs5ndiZBGyNgQz+iE1UiuwBmy5HUvlgT4nUhJLxfVTLJiaEu426HIe+M4 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM 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: fd5c13d7-0324-435a-4c16-08d66a4ef396 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Dec 2018 09:54:24.4859 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3282 Subject: Re: [dpdk-dev] [PATCH v2] examples/flow_filtering: fix example documentation 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: , X-List-Received-Date: Tue, 25 Dec 2018 09:54:26 -0000 > -----Original Message----- > From: dev On Behalf Of Dekel Peled > Sent: Tuesday, December 25, 2018 9:42 AM > To: Ori Kam > Cc: dev@dpdk.org; Dekel Peled > Subject: [dpdk-dev] [PATCH v2] examples/flow_filtering: fix example > documentation >=20 > Previous patch removed the VLAN item from example code. > This patch fixes the code and documentation accordingly. >=20 > Code update includes fix of comments, and removal of redundant > variables and their initialization. > Documentation update reflects the code changes done in previous > patch and in this patch. >=20 > Fixes: 9af4eb565710 ("examples/flow_filtering: remove VLAN item") > Cc: orika@mellanox.com >=20 > Signed-off-by: Dekel Peled >=20 > --- > v2: Update and elaborate patch log. > --- >=20 > --- > doc/guides/sample_app_ug/flow_filtering.rst | 74 +++++++----------------= ------ > examples/flow_filtering/flow_blocks.c | 18 ++----- > 2 files changed, 21 insertions(+), 71 deletions(-) >=20 > diff --git a/doc/guides/sample_app_ug/flow_filtering.rst > b/doc/guides/sample_app_ug/flow_filtering.rst > index 840d557..9dba85a 100644 > --- a/doc/guides/sample_app_ug/flow_filtering.rst > +++ b/doc/guides/sample_app_ug/flow_filtering.rst > @@ -53,7 +53,7 @@ applications and the Environment Abstraction Layer (EAL= ) > options. > Explanation > ----------- >=20 > -The example is build from 2 main files, > +The example is built from 2 files, > ``main.c`` which holds the example logic and ``flow_blocks.c`` that hold= s the > implementation for building the flow rule. >=20 > @@ -380,13 +380,9 @@ This function is located in the ``flow_blocks.c`` fi= le. > { > struct rte_flow_attr attr; > struct rte_flow_item pattern[MAX_PATTERN_NUM]; > - struct rte_flow_action action[MAX_PATTERN_NUM]; > + struct rte_flow_action action[MAX_ACTION_NUM]; > struct rte_flow *flow =3D NULL; > struct rte_flow_action_queue queue =3D { .index =3D rx_q }; > - struct rte_flow_item_eth eth_spec; > - struct rte_flow_item_eth eth_mask; > - struct rte_flow_item_vlan vlan_spec; > - struct rte_flow_item_vlan vlan_mask; > struct rte_flow_item_ipv4 ip_spec; > struct rte_flow_item_ipv4 ip_mask; >=20 > @@ -404,37 +400,19 @@ This function is located in the ``flow_blocks.c`` f= ile. > * create the action sequence. > * one action only, move packet to queue > */ > - > action[0].type =3D RTE_FLOW_ACTION_TYPE_QUEUE; > action[0].conf =3D &queue; > action[1].type =3D RTE_FLOW_ACTION_TYPE_END; >=20 > /* > - * set the first level of the pattern (eth). > + * set the first level of the pattern (ETH). > * since in this example we just want to get the > * ipv4 we set this level to allow all. > */ > - memset(ð_spec, 0, sizeof(struct rte_flow_item_eth)); > - memset(ð_mask, 0, sizeof(struct rte_flow_item_eth)); > - eth_spec.type =3D 0; > - eth_mask.type =3D 0; > pattern[0].type =3D RTE_FLOW_ITEM_TYPE_ETH; > - pattern[0].spec =3D ð_spec; > - pattern[0].mask =3D ð_mask; > - > - /* > - * setting the second level of the pattern (vlan). > - * since in this example we just want to get the > - * ipv4 we also set this level to allow all. > - */ > - memset(&vlan_spec, 0, sizeof(struct rte_flow_item_vlan)); > - memset(&vlan_mask, 0, sizeof(struct rte_flow_item_vlan)); > - pattern[1].type =3D RTE_FLOW_ITEM_TYPE_VLAN; > - pattern[1].spec =3D &vlan_spec; > - pattern[1].mask =3D &vlan_mask; >=20 > /* > - * setting the third level of the pattern (ip). > + * setting the second level of the pattern (IP). > * in this example this is the level we care about > * so we set it according to the parameters. > */ > @@ -444,12 +422,12 @@ This function is located in the ``flow_blocks.c`` f= ile. > ip_mask.hdr.dst_addr =3D dest_mask; > ip_spec.hdr.src_addr =3D htonl(src_ip); > ip_mask.hdr.src_addr =3D src_mask; > - pattern[2].type =3D RTE_FLOW_ITEM_TYPE_IPV4; > - pattern[2].spec =3D &ip_spec; > - pattern[2].mask =3D &ip_mask; > + pattern[1].type =3D RTE_FLOW_ITEM_TYPE_IPV4; > + pattern[1].spec =3D &ip_spec; > + pattern[1].mask =3D &ip_mask; >=20 > /* the final level must be always type end */ > - pattern[3].type =3D RTE_FLOW_ITEM_TYPE_END; > + pattern[2].type =3D RTE_FLOW_ITEM_TYPE_END; >=20 > int res =3D rte_flow_validate(port_id, &attr, pattern, action= , error); > if(!res) > @@ -464,14 +442,10 @@ The first part of the function is declaring the > structures that will be used. >=20 > struct rte_flow_attr attr; > struct rte_flow_item pattern[MAX_PATTERN_NUM]; > - struct rte_flow_action action[MAX_PATTERN_NUM]; > + struct rte_flow_action action[MAX_ACTION_NUM]; > struct rte_flow *flow; > struct rte_flow_error error; > struct rte_flow_action_queue queue =3D { .index =3D rx_q }; > - struct rte_flow_item_eth eth_spec; > - struct rte_flow_item_eth eth_mask; > - struct rte_flow_item_vlan vlan_spec; > - struct rte_flow_item_vlan vlan_mask; > struct rte_flow_item_ipv4 ip_spec; > struct rte_flow_item_ipv4 ip_mask; >=20 > @@ -491,33 +465,17 @@ the rule. In this case send the packet to queue. > action[0].conf =3D &queue; > action[1].type =3D RTE_FLOW_ACTION_TYPE_END; >=20 > -The forth part is responsible for creating the pattern and is build from > -number of step. In each step we build one level of the pattern starting = with > +The fourth part is responsible for creating the pattern and is built fro= m > +number of steps. In each step we build one level of the pattern starting= with > the lowest one. >=20 > Setting the first level of the pattern ETH: >=20 > .. code-block:: c >=20 > - memset(ð_spec, 0, sizeof(struct rte_flow_item_eth)); > - memset(ð_mask, 0, sizeof(struct rte_flow_item_eth)); > - eth_spec.type =3D 0; > - eth_mask.type =3D 0; > pattern[0].type =3D RTE_FLOW_ITEM_TYPE_ETH; > - pattern[0].spec =3D ð_spec; > - pattern[0].mask =3D ð_mask; > - > -Setting the second level of the pattern VLAN: > - > -.. code-block:: c > - > - memset(&vlan_spec, 0, sizeof(struct rte_flow_item_vlan)); > - memset(&vlan_mask, 0, sizeof(struct rte_flow_item_vlan)); > - pattern[1].type =3D RTE_FLOW_ITEM_TYPE_VLAN; > - pattern[1].spec =3D &vlan_spec; > - pattern[1].mask =3D &vlan_mask; >=20 > -Setting the third level ip: > +Setting the second level of the pattern IP: >=20 > .. code-block:: c >=20 > @@ -527,15 +485,15 @@ Setting the third level ip: > ip_mask.hdr.dst_addr =3D dest_mask; > ip_spec.hdr.src_addr =3D htonl(src_ip); > ip_mask.hdr.src_addr =3D src_mask; > - pattern[2].type =3D RTE_FLOW_ITEM_TYPE_IPV4; > - pattern[2].spec =3D &ip_spec; > - pattern[2].mask =3D &ip_mask; > + pattern[1].type =3D RTE_FLOW_ITEM_TYPE_IPV4; > + pattern[1].spec =3D &ip_spec; > + pattern[1].mask =3D &ip_mask; >=20 > Closing the pattern part. >=20 > .. code-block:: c >=20 > - pattern[3].type =3D RTE_FLOW_ITEM_TYPE_END; > + pattern[2].type =3D RTE_FLOW_ITEM_TYPE_END; >=20 > The last part of the function is to validate the rule and create it. >=20 > diff --git a/examples/flow_filtering/flow_blocks.c > b/examples/flow_filtering/flow_blocks.c > index bae7116..1edf6f9 100644 > --- a/examples/flow_filtering/flow_blocks.c > +++ b/examples/flow_filtering/flow_blocks.c > @@ -2,7 +2,8 @@ > * Copyright 2017 Mellanox Technologies, Ltd > */ >=20 > -#define MAX_PATTERN_NUM 4 > +#define MAX_PATTERN_NUM 3 > +#define MAX_ACTION_NUM 2 >=20 > struct rte_flow * > generate_ipv4_flow(uint16_t port_id, uint16_t rx_q, > @@ -41,11 +42,9 @@ struct rte_flow * > { > struct rte_flow_attr attr; > struct rte_flow_item pattern[MAX_PATTERN_NUM]; > - struct rte_flow_action action[MAX_PATTERN_NUM]; > + struct rte_flow_action action[MAX_ACTION_NUM]; > struct rte_flow *flow =3D NULL; > struct rte_flow_action_queue queue =3D { .index =3D rx_q }; > - struct rte_flow_item_eth eth_spec; > - struct rte_flow_item_eth eth_mask; > struct rte_flow_item_ipv4 ip_spec; > struct rte_flow_item_ipv4 ip_mask; > int res; > @@ -64,26 +63,19 @@ struct rte_flow * > * create the action sequence. > * one action only, move packet to queue > */ > - > action[0].type =3D RTE_FLOW_ACTION_TYPE_QUEUE; > action[0].conf =3D &queue; > action[1].type =3D RTE_FLOW_ACTION_TYPE_END; >=20 > /* > - * set the first level of the pattern (eth). > + * set the first level of the pattern (ETH). > * since in this example we just want to get the > * ipv4 we set this level to allow all. > */ > - memset(ð_spec, 0, sizeof(struct rte_flow_item_eth)); > - memset(ð_mask, 0, sizeof(struct rte_flow_item_eth)); > - eth_spec.type =3D 0; > - eth_mask.type =3D 0; > pattern[0].type =3D RTE_FLOW_ITEM_TYPE_ETH; > - pattern[0].spec =3D ð_spec; > - pattern[0].mask =3D ð_mask; >=20 > /* > - * setting the third level of the pattern (ip). > + * setting the second level of the pattern (IP). > * in this example this is the level we care about > * so we set it according to the parameters. > */ > -- > 1.8.3.1 Acked-by: Ori Kam Thanks, Ori