From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140082.outbound.protection.outlook.com [40.107.14.82]) by dpdk.org (Postfix) with ESMTP id 2EB3B5B16 for ; Fri, 28 Dec 2018 11:14:47 +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=RhCXnrt97/IBYdYDkWLBZXKwlltU62yBat90t5n8lTE=; b=n8/hzw1UythPLLwKsnTtMZyDgTVjdMDyX8yJhAK7M02mRFQUBsUEBxxC03ZAOvEbo7gJV2mjwoE1ts6+rJT22rNAyFDCkL6JDCInZFoiUh6t+zzbi48x057qJhv9sukPn3DifAC/zutOwENm6TW/hkkD0tbPWEzXtCMQQXtNhQE= Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com (52.134.72.27) by DB3PR0502MB3945.eurprd05.prod.outlook.com (52.134.65.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1471.20; Fri, 28 Dec 2018 10:14:45 +0000 Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::d43a:3775:8af7:29c6]) by DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::d43a:3775:8af7:29c6%4]) with mapi id 15.20.1446.027; Fri, 28 Dec 2018 10:14:45 +0000 From: Yongseok Koh To: Dekel Peled CC: dpdk stable , Shahaf Shuler , Ori Kam Thread-Topic: [PATCH 17.11] examples/flow_filtering: fix flow create function Thread-Index: AQHUmpXjhbcPb4VCYEuEieeGIXEsy6WT9yIA Date: Fri, 28 Dec 2018 10:14:45 +0000 Message-ID: <8B72F643-9C79-4FCE-BCD0-48E28A5BA259@mellanox.com> References: <1545551899-56910-1-git-send-email-dekelp@mellanox.com> In-Reply-To: <1545551899-56910-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=yskoh@mellanox.com; x-originating-ip: [69.181.245.183] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB3PR0502MB3945; 6:ugd8pEmJDa2X0fmA9l6vEpBgw1rNcP+T+25WEskg+NkLlwwQUaSWWnUW/ZmB+0RP78CGmuWbmisRnWyJZKaY6FBsZRsWCWvYu9gb3P698CR88MNTeCddvREv7sRLNf+CwLyHu8E86b7WDcyNO4a18h9w6GEH/oaCnnhH1VzU6cEdDIJ58wPT9ZKlGv3ByCTCpx2MPbXtqQkZOHrVl9gKtylG6CZSEOTAgP9RuOGdQmr7KONsCoVaiGkBn6TRBU/TQ85QNzmdoGIwW4oG2khIbPhdneupdLDscII0fMS8l4zOokwqaDkdNJGPMTxFa8Hgu3Vfbtqmlc0630LIQPo+cyJL/je2fuhmMF30KO1vBqYh5EvUofk4qAJVzTSH6erekC+35dm2ZL6dJUM7Z9qycVgFIfiph4nWW8J4ypW3w6MlzGPO5MTV/qGAqiu4ps9VfxnD9Y+YPMKsSBg7wqzFUw==; 5:XcMHVTseon6N4tNVeUOy5pqO86Wt+V5dZmG/uos5t2xkJn6aHYBW5M469hDt6UEEtiQO1BrzY+JVUXsqDv2F8LNNouh/m0QSOQMuqbt/4BqzmLqZDsWw+xICHGtvN+9BLc98NTT3x3URBm2scqk/uxNSlslBZ5Z2mz+oVplAdNk=; 7:TrBQ8EL0kB2fLSqYdLqdGtf+xVXCOxm7/l9ZVcAXdoHYVuS6J0zKXjp/h1uV7hK/ZrBvpCJGLhK9VD7KsRl36AqrnrzwUeomyo8qPb1/p+ynxFCOBUG+uK/CMafVOPc/sLCBZ0/1+SRvOW+GQFopiw== x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 104885da-5553-4dd6-769e-08d66cad4a9a x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600109)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:DB3PR0502MB3945; x-ms-traffictypediagnostic: DB3PR0502MB3945: 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)(3231475)(944501520)(52105112)(10201501046)(3002001)(6055026)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:DB3PR0502MB3945; BCL:0; PCL:0; RULEID:; SRVR:DB3PR0502MB3945; x-forefront-prvs: 09007040D4 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(346002)(136003)(376002)(39860400002)(396003)(199004)(189003)(66066001)(11346002)(486006)(3846002)(2616005)(6862004)(305945005)(476003)(229853002)(6246003)(6486002)(33656002)(6512007)(6436002)(14454004)(107886003)(5660300001)(97736004)(82746002)(105586002)(6116002)(53936002)(478600001)(4326008)(86362001)(2906002)(106356001)(68736007)(26005)(71200400001)(81156014)(71190400001)(6506007)(53546011)(83716004)(54906003)(7736002)(6636002)(81166006)(36756003)(102836004)(25786009)(316002)(37006003)(8676002)(76176011)(14444005)(256004)(186003)(99286004)(446003)(8936002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR0502MB3945; H:DB3PR0502MB3980.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: d4DNkJIeZ/9R4Qt0Ze3wnWr/cBc4Rcrsca4rg2Rq2JwVCtAbU4vW/0vO5gCDBwJWpmhRdmXC1qG5jP23mxz5P1nHVksvo+RmePwu1MvbsT2buKEiRsP9ZDqLSLdu0tJna+ONZZQ5Q1fwsLMjS4OfgiErbtD+dFlmIaXHMpLKcVvYkh3neaSND47APQj47aIyxSBRvZJ/raGVwIn6tIISKkx7KKuV0X4+KcydPdsujoED7QjA/iVoUdPW+G5eWT0gKe01x9mjVl0UKmMIgiNjJsPHGfab27T+lSJu91jPSjEMcv9H5uzhg3nAO+BW28dF spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 104885da-5553-4dd6-769e-08d66cad4a9a X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Dec 2018 10:14:45.4651 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0502MB3945 Subject: Re: [dpdk-stable] [PATCH 17.11] examples/flow_filtering: fix flow create function X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Dec 2018 10:14:47 -0000 > On Dec 22, 2018, at 11:58 PM, Dekel Peled wrote: >=20 > Flow filtering example implements a simple flow rule creation and use. > The rule is created with ETH/VLAN/IPv4 pattern, but demonstrates only > IPv4 filtering, hence the VLAN item is redundant. > MLX5 PMD flow-rule validation was modified after the implementation of > this example, and now the example fails when trying to create rule. > Failure occurs due to the VLAN item. >=20 > This patch simplifies the example, removing the VLAN item from rule. > The documentation is modified accordingly. >=20 > Fixes: 4a3ef59a10c8 ("examples/flow_filtering: add simple demo of flow AP= I") > Cc: orika@mellanox.com >=20 > Signed-off-by: Dekel Peled > --- Hi Dekel, I can see the same patch in the dev mailing list. I will merge it once the patch in dev list is acked and merged. Thanks, Yongseok > doc/guides/sample_app_ug/flow_filtering.rst | 74 +++++++-----------------= ----- > examples/flow_filtering/flow_blocks.c | 39 ++++----------- > 2 files changed, 25 insertions(+), 88 deletions(-) >=20 > diff --git a/doc/guides/sample_app_ug/flow_filtering.rst b/doc/guides/sam= ple_app_ug/flow_filtering.rst > index 725dcb4..6086632 100644 > --- a/doc/guides/sample_app_ug/flow_filtering.rst > +++ b/doc/guides/sample_app_ug/flow_filtering.rst > @@ -81,7 +81,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 holds= the > implementation for building the flow rule. >=20 > @@ -378,13 +378,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 > @@ -402,37 +398,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. > */ > @@ -442,12 +420,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) > @@ -462,14 +440,10 @@ The first part of the function is declaring the str= uctures 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 > @@ -489,33 +463,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 > @@ -525,15 +483,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_filter= ing/flow_blocks.c > index f92df10..c1e482f 100644 > --- a/examples/flow_filtering/flow_blocks.c > +++ b/examples/flow_filtering/flow_blocks.c > @@ -30,7 +30,8 @@ > * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > */ >=20 > -#define MAX_PATTERN_NUM 4 > +#define MAX_PATTERN_NUM 3 > +#define MAX_ACTION_NUM 2 >=20 > struct rte_flow * > generate_ipv4_flow(uint8_t port_id, uint16_t rx_q, > @@ -69,13 +70,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_vlan vlan_spec; > - struct rte_flow_item_vlan vlan_mask; > struct rte_flow_item_ipv4 ip_spec; > struct rte_flow_item_ipv4 ip_mask; > int res; > @@ -94,37 +91,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; > - > - /* > - * 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. > */ > @@ -134,12 +113,12 @@ struct rte_flow * > 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 > res =3D rte_flow_validate(port_id, &attr, pattern, action, error); > if (!res) > --=20 > 1.8.3.1 >=20