From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 899F4A00E6 for ; Wed, 17 Apr 2019 01:41:42 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9842F1B55B; Wed, 17 Apr 2019 01:41:40 +0200 (CEST) Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20061.outbound.protection.outlook.com [40.107.2.61]) by dpdk.org (Postfix) with ESMTP id 8656C1B551; Wed, 17 Apr 2019 01:41:38 +0200 (CEST) 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=c/FeCVMHvHkROFJFSL2Ur8XUAF9nu97eMyUVnLgIfaI=; b=F3wVS8tsvBUoQAmfUsJdh0FEz4TEkpPHW7w1su+IG6tb1mZBYG7aNh9mZxkiBZGiO+eMClzhXwvj0gLvHC2NFbjrxPFIgokSyw+m0l6KwvOAfhvb7gVC9ljRayZzL5K8PujVncLNgpF4YTJFIZNn6UsT2j9d8Fsnvv06wrHxA+I= Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com (52.134.72.27) by DB3PR0502MB4058.eurprd05.prod.outlook.com (52.134.68.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1792.18; Tue, 16 Apr 2019 23:41:36 +0000 Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::6072:43be:7c2d:103a]) by DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::6072:43be:7c2d:103a%3]) with mapi id 15.20.1813.011; Tue, 16 Apr 2019 23:41:36 +0000 From: Yongseok Koh To: Ori Kam CC: Shahaf Shuler , "dev@dpdk.org" , Dekel Peled , "stable@dpdk.org" Thread-Topic: [PATCH] net/mlx5: fix modify header action position Thread-Index: AQHU8v+D1DhK4hnF/UuH1K6kD9HL6qY/ddKA Date: Tue, 16 Apr 2019 23:41:36 +0000 Message-ID: <20190416234126.GC21044@mtidpdk.mti.labs.mlnx> References: <1555273197-1949-1-git-send-email-orika@mellanox.com> In-Reply-To: <1555273197-1949-1-git-send-email-orika@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR01CA0043.prod.exchangelabs.com (2603:10b6:a03:94::20) To DB3PR0502MB3980.eurprd05.prod.outlook.com (2603:10a6:8:10::27) authentication-results: spf=none (sender IP is ) smtp.mailfrom=yskoh@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [209.116.155.178] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1523cdec-d1f4-4687-dc2b-08d6c2c51047 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600140)(711020)(4605104)(4618075)(2017052603328)(7193020); SRVR:DB3PR0502MB4058; x-ms-traffictypediagnostic: DB3PR0502MB4058: x-microsoft-antispam-prvs: x-forefront-prvs: 000947967F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(39860400002)(396003)(346002)(136003)(366004)(199004)(189003)(6636002)(26005)(2906002)(305945005)(4326008)(186003)(316002)(7736002)(66066001)(256004)(446003)(478600001)(71190400001)(71200400001)(11346002)(6862004)(6246003)(33656002)(97736004)(14444005)(54906003)(486006)(52116002)(9686003)(8676002)(229853002)(6512007)(53936002)(81156014)(6116002)(3846002)(25786009)(76176011)(99286004)(476003)(106356001)(68736007)(6486002)(81166006)(105586002)(6436002)(102836004)(8936002)(1076003)(450100002)(14454004)(6506007)(386003)(5660300002)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR0502MB4058; 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: rVt5SKxQhqrfkkIbl99G7qNMPd9H5yJzhrboUf+aYd4+dhHuJmhECCQKYjJIHQyXc/r51hxuDZtbpf1Qu/LUqAC+XsDjilv8udZTXh7SNGDYe7guOfe77F+beTu4l99kR4eCFGdZQIlbe87tedK1jOiJt/whQ7kjBKjjvN8hAHxktsMUNCKwWw2qBiukAf5UfVFbxaVXBFmUYu0WZMT2ie1GLvRGVZMher/S27N4Qb+TdR4CfO7asR0tNf2624qZTpif7VInQn+UBK3SrcvmStmJIFYqqhQFkWOPcWiyblSSeJx3NZimlmXu2R8Ob/U3i9R9HUBCQcFbUQIXiWccH3q+gsurX6IrcyNse/RVpk7a5qjFMnFmv6f9Uu3E2TLB5e/xyKhh0Y7GrstIGre6DkcdwBPUvE5qcb2lXn6yQH4= Content-Type: text/plain; charset="UTF-8" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1523cdec-d1f4-4687-dc2b-08d6c2c51047 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Apr 2019 23:41:36.0326 (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-Transport-CrossTenantHeadersStamped: DB3PR0502MB4058 Subject: Re: [dpdk-dev] [PATCH] net/mlx5: fix modify header action position 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" Message-ID: <20190416234136.BdJzuOyQTrTF7fC-Ke-jxu_SnN8Tm4PyE_DwjLNAYBc@z> On Sun, Apr 14, 2019 at 08:19:57PM +0000, Ori Kam wrote: > According to RTE flow the action order should be the order that the > actions were given. > In the case of modify actions the position of the action was always > last. >=20 > This commit solves this issue by saving the position of the first modify > action, and then adds to this position the pointer to the modify action. >=20 > Fixes: 4bb14c83df95 ("net/mlx5: support modify header using Direct Verbs"= ) > Cc: dekelp@mellanox.com > Cc: stable@dpdk.org >=20 > Signed-off-by: Ori Kam > --- > drivers/net/mlx5/mlx5_flow_dv.c | 15 ++++++++++++++- > 1 file changed, 14 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow= _dv.c > index 3862b26..7b5eab7 100644 > --- a/drivers/net/mlx5/mlx5_flow_dv.c > +++ b/drivers/net/mlx5/mlx5_flow_dv.c > @@ -3235,6 +3235,7 @@ struct field_modify_info modify_tcp[] =3D { > }; > union flow_dv_attr flow_attr =3D { .attr =3D 0 }; > struct mlx5_flow_dv_tag_resource tag_resource; > + uint32_t modify_action_position =3D UINT32_MAX; How about modify_action_idx and setting negative value as invalid? I don't = force it but it is just your choice. int modify_action_idx =3D -1; > if (priority =3D=3D MLX5_FLOW_PRIO_RSVD) > priority =3D priv->config.flow_prio - 1; > @@ -3419,6 +3420,8 @@ struct field_modify_info modify_tcp[] =3D { > RTE_FLOW_ACTION_TYPE_SET_MAC_SRC ? > MLX5_FLOW_ACTION_SET_MAC_SRC : > MLX5_FLOW_ACTION_SET_MAC_DST; > + if (modify_action_position =3D=3D UINT32_MAX) > + modify_action_position =3D actions_n++; Even though this does right thing, I hope it to be neater. Same lines are repeating before 'break', so you can move it just out of this switch-case. For example, for(..) { switch(..) { case .. default: break; } /* Check if a modify action is firstly seen. */ if (modify_action_idx < 0 && (action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS)) modify_action_idx =3D actions_n++; } thanks, Yongseok > break; > case RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC: > case RTE_FLOW_ACTION_TYPE_SET_IPV4_DST: > @@ -3429,6 +3432,8 @@ struct field_modify_info modify_tcp[] =3D { > RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC ? > MLX5_FLOW_ACTION_SET_IPV4_SRC : > MLX5_FLOW_ACTION_SET_IPV4_DST; > + if (modify_action_position =3D=3D UINT32_MAX) > + modify_action_position =3D actions_n++; > break; > case RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC: > case RTE_FLOW_ACTION_TYPE_SET_IPV6_DST: > @@ -3439,6 +3444,8 @@ struct field_modify_info modify_tcp[] =3D { > RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC ? > MLX5_FLOW_ACTION_SET_IPV6_SRC : > MLX5_FLOW_ACTION_SET_IPV6_DST; > + if (modify_action_position =3D=3D UINT32_MAX) > + modify_action_position =3D actions_n++; > break; > case RTE_FLOW_ACTION_TYPE_SET_TP_SRC: > case RTE_FLOW_ACTION_TYPE_SET_TP_DST: > @@ -3450,6 +3457,8 @@ struct field_modify_info modify_tcp[] =3D { > RTE_FLOW_ACTION_TYPE_SET_TP_SRC ? > MLX5_FLOW_ACTION_SET_TP_SRC : > MLX5_FLOW_ACTION_SET_TP_DST; > + if (modify_action_position =3D=3D UINT32_MAX) > + modify_action_position =3D actions_n++; > break; > case RTE_FLOW_ACTION_TYPE_DEC_TTL: > if (flow_dv_convert_action_modify_dec_ttl(&res, items, > @@ -3457,6 +3466,8 @@ struct field_modify_info modify_tcp[] =3D { > error)) > return -rte_errno; > action_flags |=3D MLX5_FLOW_ACTION_DEC_TTL; > + if (modify_action_position =3D=3D UINT32_MAX) > + modify_action_position =3D actions_n++; > break; > case RTE_FLOW_ACTION_TYPE_SET_TTL: > if (flow_dv_convert_action_modify_ttl(&res, actions, > @@ -3464,6 +3475,8 @@ struct field_modify_info modify_tcp[] =3D { > error)) > return -rte_errno; > action_flags |=3D MLX5_FLOW_ACTION_SET_TTL; > + if (modify_action_position =3D=3D UINT32_MAX) > + modify_action_position =3D actions_n++; > break; > case RTE_FLOW_ACTION_TYPE_END: > actions_end =3D true; > @@ -3474,7 +3487,7 @@ struct field_modify_info modify_tcp[] =3D { > dev_flow, > error)) > return -rte_errno; > - dev_flow->dv.actions[actions_n++] =3D > + dev_flow->dv.actions[modify_action_position] =3D > dev_flow->dv.modify_hdr->verbs_action; > } > break; > --=20 > 1.8.3.1 >=20