From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00057.outbound.protection.outlook.com [40.107.0.57]) by dpdk.org (Postfix) with ESMTP id 8D9A25B32 for ; Thu, 1 Nov 2018 21:37:06 +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=ff6qIQybvqu7eEDsWqDuiuCJQ3nvmDaKq87jW0PbLdo=; b=lqbgMbDYrOcOP9nK2xpZnKK43m/xfc4vrHbaOtXUGQh3zhzc2kL9G4oG9eipGdYqc/AKBUX6WCnjpvFb8Y/LzIhABP9iCVUHMfGuuyorHyQk/L/Rb0lNzcJg1wPxfVa3FJTuHjLFZOwhrVqjFtJ0K+rCNKCXWhf0Z4YnTCEuIew= Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com (52.134.72.27) by DB3PR0502MB3977.eurprd05.prod.outlook.com (52.134.70.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1273.21; Thu, 1 Nov 2018 20:37:05 +0000 Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::f8a1:fcab:94f0:97cc]) by DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::f8a1:fcab:94f0:97cc%4]) with mapi id 15.20.1273.030; Thu, 1 Nov 2018 20:37:05 +0000 From: Yongseok Koh To: Slava Ovsiienko CC: Shahaf Shuler , "dev@dpdk.org" Thread-Topic: [PATCH v3 05/13] net/mlx5: swap items/actions validations for e-switch rules Thread-Index: AQHUcd0iZ2FVj0EBQECEUD+aWtVRqKU7YYmA Date: Thu, 1 Nov 2018 20:37:05 +0000 Message-ID: <20181101203656.GF6118@mtidpdk.mti.labs.mlnx> References: <1539612815-47199-1-git-send-email-viacheslavo@mellanox.com> <1541074741-41368-1-git-send-email-viacheslavo@mellanox.com> <1541074741-41368-6-git-send-email-viacheslavo@mellanox.com> In-Reply-To: <1541074741-41368-6-git-send-email-viacheslavo@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR08CA0020.namprd08.prod.outlook.com (2603:10b6:a03:100::33) 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-microsoft-exchange-diagnostics: 1; DB3PR0502MB3977; 6:bMS+SjsBlZ8ra+zTsQ+hRTyLP3DmnWLkD2K9MSkoG8vVGWTOU52Y51tDGunM1DCGsV4T4gAyRPtfKt7PmZ4coN83FrRK94a5NwEVC2583XSiGwrJxdc7BhB0Ca9WpQiV/zICAzK5oNL5iEn1wMv+IQKwMnmqSE2d+gSDwATuMpK+67szKlCM/u1QtCIlX8N6g7kzqaos3ZuVNAYzkmFjZEoPOCJXgbNOLdqO2/TkwxsWJPBP/m6ERXwaleG3A1qwf6qLJMO4iob6rxWrfKzKNmSgOr5zjqHRYJFtQYA6/4Z0bj/kJe3XkYVUdeIBUGprzWiG+GHgZKYYfr69fxC07HILhES5DQdghP8JNotAdKeDhrD1S/4ArzjebovrmUwIWbbehL2hx4k26e6ch56R2ZkHbKTBWsdhxDR/OnhsrReQL4DjErvRF3EskVSH/HMODVrwmiTYdyFo5Xrfs6lg3Q==; 5:XLNAl8OY6LW0ci+dDg0AfNl/CiLNmpoaSRrTP/5+rpGKuy4XOBqW46SPi/otskGigDkf4QKbODUXVDgyTY5uXm44l3jU16L6g5U9VKjruUvOTkGe2dWRIWr0RkX+wirkTN9F+CKWSCD2BGaDUfwTkOr+sSTpBqGn5MWzLgJmK9Y=; 7:3RLnsIlrKHTZrTgXACLb8y9cyxTy+MhCdOLWU0qfZOdhN/6xA+3VBS6uVvcwGXBwQdg+f0mxnpC9UEylaibcP/raJ8EpuG3zgLiRlyy+5nfr7y4jIRM4JikRM7W7TK1uZjlwcpb5avM250BizgjN7w== x-ms-office365-filtering-correlation-id: f1c072e1-0de6-4b7a-b189-08d64039c903 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DB3PR0502MB3977; x-ms-traffictypediagnostic: DB3PR0502MB3977: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(3231382)(944501410)(52105095)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(20161123558120)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:DB3PR0502MB3977; BCL:0; PCL:0; RULEID:; SRVR:DB3PR0502MB3977; x-forefront-prvs: 0843C17679 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(136003)(376002)(39860400002)(396003)(366004)(199004)(189003)(71190400001)(81156014)(81166006)(8676002)(14454004)(11346002)(446003)(486006)(33656002)(1076002)(476003)(68736007)(66066001)(6862004)(256004)(8936002)(71200400001)(105586002)(2900100001)(6116002)(3846002)(106356001)(2906002)(4326008)(53936002)(25786009)(9686003)(6512007)(99286004)(14444005)(6246003)(186003)(52116002)(86362001)(6486002)(6436002)(386003)(6506007)(33896004)(5660300001)(229853002)(54906003)(316002)(305945005)(6636002)(7736002)(97736004)(5250100002)(478600001)(102836004)(76176011)(26005); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR0502MB3977; 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-microsoft-antispam-message-info: TDg/Eu7p6ZTDGnNTthHCBpxzY3M5w+o+3h46bh52BMYguYUhQH9XEivEezjxL2q8PsyPDL0qqFqYF6XpBDJ9ADuhFwM5xzZX5WO0OjtHFjQgKzThkZu7DomfIaaAEtGG7o0q7jPlWpxqERb4DWxsIbqRx796jFH8elxL7OTTAvVPN6Z2QW99NfaNcHg18sXcQDbJPl69pr8q4a2ICo/278AULbW5hwl3fMqusH7g4pi7tgXwhnKC5ekp+ZqHlBFlHjDDy7hN4iklC4Kx5FW46utNKFrNMEo1/qFukndMPO2ytjrlGlBeBRgT0nqhNAbQ+Xp9SnFnwdroj2suqntI43Jhq3GgZgRIpFrGkSQ4JMA= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: <7EB7BA171E91014A95ECF0FBD3E29252@eurprd05.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: f1c072e1-0de6-4b7a-b189-08d64039c903 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Nov 2018 20:37:05.4043 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0502MB3977 Subject: Re: [dpdk-dev] [PATCH v3 05/13] net/mlx5: swap items/actions validations for e-switch rules 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: Thu, 01 Nov 2018 20:37:06 -0000 On Thu, Nov 01, 2018 at 05:19:26AM -0700, Slava Ovsiienko wrote: > The rule validation function for E-Switch checks item list first, > then action list is checked. This patch swaps the validation order, > now actions are checked first. This is preparation for validation > function update with VXLAN tunnel actions. VXLAN decapsulation > action requires to check the items in special way. We could do > this special check in the single item check pass if the action > flags were gathered before. This is the reason to swap the > item/actions checking loops. >=20 > Suggested-by: Adrien Mazarguil > Signed-off-by: Viacheslav Ovsiienko > --- Acked-by: Yongseok Koh Thanks > drivers/net/mlx5/mlx5_flow_tcf.c | 260 +++++++++++++++++++--------------= ------ > 1 file changed, 130 insertions(+), 130 deletions(-) >=20 > diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flo= w_tcf.c > index 55c77e3..50f3bd1 100644 > --- a/drivers/net/mlx5/mlx5_flow_tcf.c > +++ b/drivers/net/mlx5/mlx5_flow_tcf.c > @@ -1174,6 +1174,136 @@ struct pedit_parser { > ret =3D flow_tcf_validate_attributes(attr, error); > if (ret < 0) > return ret; > + for (; actions->type !=3D RTE_FLOW_ACTION_TYPE_END; actions++) { > + unsigned int i; > + uint64_t current_action_flag =3D 0; > + > + switch (actions->type) { > + case RTE_FLOW_ACTION_TYPE_VOID: > + break; > + case RTE_FLOW_ACTION_TYPE_PORT_ID: > + current_action_flag =3D MLX5_FLOW_ACTION_PORT_ID; > + if (!actions->conf) > + break; > + conf.port_id =3D actions->conf; > + if (conf.port_id->original) > + i =3D 0; > + else > + for (i =3D 0; ptoi[i].ifindex; ++i) > + if (ptoi[i].port_id =3D=3D conf.port_id->id) > + break; > + if (!ptoi[i].ifindex) > + return rte_flow_error_set > + (error, ENODEV, > + RTE_FLOW_ERROR_TYPE_ACTION_CONF, > + conf.port_id, > + "missing data to convert port ID to" > + " ifindex"); > + port_id_dev =3D &rte_eth_devices[conf.port_id->id]; > + break; > + case RTE_FLOW_ACTION_TYPE_JUMP: > + current_action_flag =3D MLX5_FLOW_ACTION_JUMP; > + if (!actions->conf) > + break; > + conf.jump =3D actions->conf; > + if (attr->group >=3D conf.jump->group) > + return rte_flow_error_set > + (error, ENOTSUP, > + RTE_FLOW_ERROR_TYPE_ACTION, > + actions, > + "can jump only to a group forward"); > + break; > + case RTE_FLOW_ACTION_TYPE_DROP: > + current_action_flag =3D MLX5_FLOW_ACTION_DROP; > + break; > + case RTE_FLOW_ACTION_TYPE_COUNT: > + break; > + case RTE_FLOW_ACTION_TYPE_OF_POP_VLAN: > + current_action_flag =3D MLX5_FLOW_ACTION_OF_POP_VLAN; > + break; > + case RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN: > + current_action_flag =3D MLX5_FLOW_ACTION_OF_PUSH_VLAN; > + break; > + case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID: > + if (!(action_flags & MLX5_FLOW_ACTION_OF_PUSH_VLAN)) > + return rte_flow_error_set > + (error, ENOTSUP, > + RTE_FLOW_ERROR_TYPE_ACTION, actions, > + "vlan modify is not supported," > + " set action must follow push action"); > + current_action_flag =3D MLX5_FLOW_ACTION_OF_SET_VLAN_VID; > + break; > + case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP: > + if (!(action_flags & MLX5_FLOW_ACTION_OF_PUSH_VLAN)) > + return rte_flow_error_set > + (error, ENOTSUP, > + RTE_FLOW_ERROR_TYPE_ACTION, actions, > + "vlan modify is not supported," > + " set action must follow push action"); > + current_action_flag =3D MLX5_FLOW_ACTION_OF_SET_VLAN_PCP; > + break; > + case RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC: > + current_action_flag =3D MLX5_FLOW_ACTION_SET_IPV4_SRC; > + break; > + case RTE_FLOW_ACTION_TYPE_SET_IPV4_DST: > + current_action_flag =3D MLX5_FLOW_ACTION_SET_IPV4_DST; > + break; > + case RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC: > + current_action_flag =3D MLX5_FLOW_ACTION_SET_IPV6_SRC; > + break; > + case RTE_FLOW_ACTION_TYPE_SET_IPV6_DST: > + current_action_flag =3D MLX5_FLOW_ACTION_SET_IPV6_DST; > + break; > + case RTE_FLOW_ACTION_TYPE_SET_TP_SRC: > + current_action_flag =3D MLX5_FLOW_ACTION_SET_TP_SRC; > + break; > + case RTE_FLOW_ACTION_TYPE_SET_TP_DST: > + current_action_flag =3D MLX5_FLOW_ACTION_SET_TP_DST; > + break; > + case RTE_FLOW_ACTION_TYPE_SET_TTL: > + current_action_flag =3D MLX5_FLOW_ACTION_SET_TTL; > + break; > + case RTE_FLOW_ACTION_TYPE_DEC_TTL: > + current_action_flag =3D MLX5_FLOW_ACTION_DEC_TTL; > + break; > + case RTE_FLOW_ACTION_TYPE_SET_MAC_SRC: > + current_action_flag =3D MLX5_FLOW_ACTION_SET_MAC_SRC; > + break; > + case RTE_FLOW_ACTION_TYPE_SET_MAC_DST: > + current_action_flag =3D MLX5_FLOW_ACTION_SET_MAC_DST; > + break; > + default: > + return rte_flow_error_set(error, ENOTSUP, > + RTE_FLOW_ERROR_TYPE_ACTION, > + actions, > + "action not supported"); > + } > + if (current_action_flag & MLX5_TCF_CONFIG_ACTIONS) { > + if (!actions->conf) > + return rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ACTION_CONF, > + actions, > + "action configuration not set"); > + } > + if ((current_action_flag & MLX5_TCF_PEDIT_ACTIONS) && > + pedit_validated) > + return rte_flow_error_set(error, ENOTSUP, > + RTE_FLOW_ERROR_TYPE_ACTION, > + actions, > + "set actions should be " > + "listed successively"); > + if ((current_action_flag & ~MLX5_TCF_PEDIT_ACTIONS) && > + (action_flags & MLX5_TCF_PEDIT_ACTIONS)) > + pedit_validated =3D 1; > + if ((current_action_flag & MLX5_TCF_FATE_ACTIONS) && > + (action_flags & MLX5_TCF_FATE_ACTIONS)) > + return rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ACTION, > + actions, > + "can't have multiple fate" > + " actions"); > + action_flags |=3D current_action_flag; > + } > for (; items->type !=3D RTE_FLOW_ITEM_TYPE_END; items++) { > unsigned int i; > =20 > @@ -1375,136 +1505,6 @@ struct pedit_parser { > NULL, "item not supported"); > } > } > - for (; actions->type !=3D RTE_FLOW_ACTION_TYPE_END; actions++) { > - unsigned int i; > - uint64_t current_action_flag =3D 0; > - > - switch (actions->type) { > - case RTE_FLOW_ACTION_TYPE_VOID: > - break; > - case RTE_FLOW_ACTION_TYPE_PORT_ID: > - current_action_flag =3D MLX5_FLOW_ACTION_PORT_ID; > - if (!actions->conf) > - break; > - conf.port_id =3D actions->conf; > - if (conf.port_id->original) > - i =3D 0; > - else > - for (i =3D 0; ptoi[i].ifindex; ++i) > - if (ptoi[i].port_id =3D=3D conf.port_id->id) > - break; > - if (!ptoi[i].ifindex) > - return rte_flow_error_set > - (error, ENODEV, > - RTE_FLOW_ERROR_TYPE_ACTION_CONF, > - conf.port_id, > - "missing data to convert port ID to" > - " ifindex"); > - port_id_dev =3D &rte_eth_devices[conf.port_id->id]; > - break; > - case RTE_FLOW_ACTION_TYPE_JUMP: > - current_action_flag =3D MLX5_FLOW_ACTION_JUMP; > - if (!actions->conf) > - break; > - conf.jump =3D actions->conf; > - if (attr->group >=3D conf.jump->group) > - return rte_flow_error_set > - (error, ENOTSUP, > - RTE_FLOW_ERROR_TYPE_ACTION, > - actions, > - "can jump only to a group forward"); > - break; > - case RTE_FLOW_ACTION_TYPE_DROP: > - current_action_flag =3D MLX5_FLOW_ACTION_DROP; > - break; > - case RTE_FLOW_ACTION_TYPE_COUNT: > - break; > - case RTE_FLOW_ACTION_TYPE_OF_POP_VLAN: > - current_action_flag =3D MLX5_FLOW_ACTION_OF_POP_VLAN; > - break; > - case RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN: > - current_action_flag =3D MLX5_FLOW_ACTION_OF_PUSH_VLAN; > - break; > - case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID: > - if (!(action_flags & MLX5_FLOW_ACTION_OF_PUSH_VLAN)) > - return rte_flow_error_set > - (error, ENOTSUP, > - RTE_FLOW_ERROR_TYPE_ACTION, actions, > - "vlan modify is not supported," > - " set action must follow push action"); > - current_action_flag =3D MLX5_FLOW_ACTION_OF_SET_VLAN_VID; > - break; > - case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP: > - if (!(action_flags & MLX5_FLOW_ACTION_OF_PUSH_VLAN)) > - return rte_flow_error_set > - (error, ENOTSUP, > - RTE_FLOW_ERROR_TYPE_ACTION, actions, > - "vlan modify is not supported," > - " set action must follow push action"); > - current_action_flag =3D MLX5_FLOW_ACTION_OF_SET_VLAN_PCP; > - break; > - case RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC: > - current_action_flag =3D MLX5_FLOW_ACTION_SET_IPV4_SRC; > - break; > - case RTE_FLOW_ACTION_TYPE_SET_IPV4_DST: > - current_action_flag =3D MLX5_FLOW_ACTION_SET_IPV4_DST; > - break; > - case RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC: > - current_action_flag =3D MLX5_FLOW_ACTION_SET_IPV6_SRC; > - break; > - case RTE_FLOW_ACTION_TYPE_SET_IPV6_DST: > - current_action_flag =3D MLX5_FLOW_ACTION_SET_IPV6_DST; > - break; > - case RTE_FLOW_ACTION_TYPE_SET_TP_SRC: > - current_action_flag =3D MLX5_FLOW_ACTION_SET_TP_SRC; > - break; > - case RTE_FLOW_ACTION_TYPE_SET_TP_DST: > - current_action_flag =3D MLX5_FLOW_ACTION_SET_TP_DST; > - break; > - case RTE_FLOW_ACTION_TYPE_SET_TTL: > - current_action_flag =3D MLX5_FLOW_ACTION_SET_TTL; > - break; > - case RTE_FLOW_ACTION_TYPE_DEC_TTL: > - current_action_flag =3D MLX5_FLOW_ACTION_DEC_TTL; > - break; > - case RTE_FLOW_ACTION_TYPE_SET_MAC_SRC: > - current_action_flag =3D MLX5_FLOW_ACTION_SET_MAC_SRC; > - break; > - case RTE_FLOW_ACTION_TYPE_SET_MAC_DST: > - current_action_flag =3D MLX5_FLOW_ACTION_SET_MAC_DST; > - break; > - default: > - return rte_flow_error_set(error, ENOTSUP, > - RTE_FLOW_ERROR_TYPE_ACTION, > - actions, > - "action not supported"); > - } > - if (current_action_flag & MLX5_TCF_CONFIG_ACTIONS) { > - if (!actions->conf) > - return rte_flow_error_set(error, EINVAL, > - RTE_FLOW_ERROR_TYPE_ACTION_CONF, > - actions, > - "action configuration not set"); > - } > - if ((current_action_flag & MLX5_TCF_PEDIT_ACTIONS) && > - pedit_validated) > - return rte_flow_error_set(error, ENOTSUP, > - RTE_FLOW_ERROR_TYPE_ACTION, > - actions, > - "set actions should be " > - "listed successively"); > - if ((current_action_flag & ~MLX5_TCF_PEDIT_ACTIONS) && > - (action_flags & MLX5_TCF_PEDIT_ACTIONS)) > - pedit_validated =3D 1; > - if ((current_action_flag & MLX5_TCF_FATE_ACTIONS) && > - (action_flags & MLX5_TCF_FATE_ACTIONS)) > - return rte_flow_error_set(error, EINVAL, > - RTE_FLOW_ERROR_TYPE_ACTION, > - actions, > - "can't have multiple fate" > - " actions"); > - action_flags |=3D current_action_flag; > - } > if ((action_flags & MLX5_TCF_PEDIT_ACTIONS) && > (action_flags & MLX5_FLOW_ACTION_DROP)) > return rte_flow_error_set(error, ENOTSUP, > --=20 > 1.8.3.1 >=20