From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60045.outbound.protection.outlook.com [40.107.6.45]) by dpdk.org (Postfix) with ESMTP id D23541B137 for ; Wed, 3 Oct 2018 22:07:03 +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=gaY4b55ZzCq+OqOErDzkOGeH8NLq7r/oLoLLMPsOPUc=; b=JeZj9rzrwfAt03ZLwp2rM+oGJM3aMgM9iub/Xkwint0fCK2ujxoM4I85ZFXBZJJ4185f08G8DtYA9T3UAuSOmYcWFtjeg87MiccEBsm+l3Wzv6BsMBaN7mfT51C5KUa8NyroLXm0jjWKUQxiuMG8L0OcUZgw9XEhCnHM5PGzWa4= Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com (52.134.72.27) by DB3PR0502MB3996.eurprd05.prod.outlook.com (52.134.65.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1185.25; Wed, 3 Oct 2018 20:07:02 +0000 Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::1cb0:661b:ecab:6045]) by DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::1cb0:661b:ecab:6045%2]) with mapi id 15.20.1185.024; Wed, 3 Oct 2018 20:07:02 +0000 From: Yongseok Koh To: Jack Min CC: "ferruh.yigit@intel.com" , Shahaf Shuler , "dev@dpdk.org" Thread-Topic: [PATCH 3/3] net/mlx5: eswitch-modify TTL actions Thread-Index: AQHUVNZgNL7m8fD+3kGE8e3wnMNBsaUN/5SA Date: Wed, 3 Oct 2018 20:07:02 +0000 Message-ID: <20181003200652.GC26206@mtidpdk.mti.labs.mlnx> References: <20180925134718.18945-1-jackmin@mellanox.com> <20180925134718.18945-4-jackmin@mellanox.com> In-Reply-To: <20180925134718.18945-4-jackmin@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MWHPR15CA0067.namprd15.prod.outlook.com (2603:10b6:301:4c::29) 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; DB3PR0502MB3996; 6:dnIMsnlboBBHDgpixtripUjyg2xFJZwhEPzdeNz6qtbePAM3M0Z9wUh4LNgAIikARc73e2jeiVFfywqaRe7dRp39LyACJnDukD977SCX8oEruNNU7EBQL714MGgXvJwWpc+v+1MezWaBnF2Ab7tdZMZgs+2ydrIDeiMAyjNM3yPuwMn+wJz4C9goq2zkhAHElYagidgYbRtlzkxGEqNwnnF40U/dw7AKzAextGiE8/r+dAUZAFw0AvAjKSupP9Zi9Rzc0T+JpULqWEEPPiOrHy+50WQGpSdvjM3NWO5Mj5xSGgovLyENy38JL9IF/LMuNAuR3Y49xrEzeZepM7NUmfXdP/uOGiFMDOybfHUe84Kp8G7yaiRU0GnjY3Gu7Mpfzv3dW5rX2IVqBQIt4WT/SADMpCETSoI8UJm6d00VgJIlcuQkt1KdwtUfM5nF9BUsbMUg1Kdwmn35/dxJ9MTL+A==; 5:C+bwiftNPawKQhKoh9onnjiKbLkrSpdMrV1+rBGGhd4RNPXWiP2xJt+VYF9f/UMfQgh2vFb5XqtpSlJU02iRW4MBuBA+kYDF4tX0ULJzl9qYjTcHjwWTDuf8mzbe71T/bZOWbBPlCR3b5IiSntLhhkBm1AG9HWWqwFeZLjbvvHQ=; 7:4Ufpmd6cAXTuY7Q79emoxYUQ6qy2DFP3t+aDILRyCEMF/am0MlAO7XlQX2gejc+vMUn69l652E+rjJKTvSwBn1PUOpg1cOIkgIxuKZtK/nHgvJFAJHiv04apJv6IitAiHvtptXqPsYJw3ds84GcwviRt8H0GhVbVTI6LA+XPpG1e6UiuDWK4AzgA2zVzgSLNA6B2R0StXogWTzZyjaEb7X/xW/L5f43iMhEOkrv9M53dBReMW+4Zo8TXesp7vEQS x-ms-office365-filtering-correlation-id: 73ca5f24-1db9-436c-a283-08d6296bc866 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:DB3PR0502MB3996; x-ms-traffictypediagnostic: DB3PR0502MB3996: 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)(93006095)(93001095)(3002001)(10201501046)(3231355)(944501410)(52105095)(6055026)(149066)(150057)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123564045)(201708071742011)(7699051); SRVR:DB3PR0502MB3996; BCL:0; PCL:0; RULEID:; SRVR:DB3PR0502MB3996; x-forefront-prvs: 0814A2C7A3 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(39860400002)(346002)(136003)(366004)(396003)(189003)(199004)(33896004)(81166006)(102836004)(575784001)(386003)(486006)(256004)(8676002)(7736002)(8936002)(54906003)(305945005)(6116002)(6862004)(66066001)(71190400001)(71200400001)(6486002)(446003)(476003)(1076002)(26005)(11346002)(186003)(229853002)(3846002)(53936002)(14444005)(9686003)(25786009)(2900100001)(4326008)(6512007)(14454004)(316002)(5660300001)(105586002)(2906002)(106356001)(6246003)(6436002)(478600001)(5250100002)(81156014)(99286004)(6506007)(97736004)(86362001)(76176011)(33656002)(6636002)(52116002)(68736007); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR0502MB3996; H:DB3PR0502MB3980.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-microsoft-antispam-message-info: q72GVrHwGbxRs3lxz77pwdbGhgBjgfk16pnx37YVG3qckFtLnS4pDGfcX+aKDWMoO3N5OGWI6NDgcSurJ8Aej7eCd3FK3KKp/bXRKo8lamh57HKohljOAyEcZ6ANE4VvsDjO4b5FRogXpK4a8b5IWYIPiWrmGrCYMlHP9PmX/nCyuRywgNOuFPGC8JE/Neuij6RpuBSNAxm+IAPtDZuFfed60cP+MAHoB636lmYRPugmO3Uj6qnpC1LPBevGSVLODBlxIjKD103jKz/lpOnYrbMBg8S1qS8hJT7snOS0zV/PRRxQEQTaBkiHj2qg2mwibFrHR6VxGcDGw/Nr7QWX/TOKJJjcrO+zosDdPT96ems= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: <99164CAE1BCFE14BAC28A54509F47067@eurprd05.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 73ca5f24-1db9-436c-a283-08d6296bc866 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Oct 2018 20:07:02.4325 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0502MB3996 Subject: Re: [dpdk-dev] [PATCH 3/3] net/mlx5: eswitch-modify TTL actions 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: Wed, 03 Oct 2018 20:07:05 -0000 On Tue, Sep 25, 2018 at 09:47:18PM +0800, Xiaoyu Min wrote: > Offload following modify TTL actions to E-Swtich via > TC-Flower driver >=20 > - RTE_FLOW_ACTION_TYPE_SET_TTL > - RTE_FLOW_ACTION_TYPE_DEC_TTL >=20 > The corresponding IP protocol rte_flow_item_ipv[4|6] > must be present in rte_flow pattern otherwith PMD > return error >=20 > Signed-off-by: Xiaoyu Min > --- As it is quite similar to the other patch of IP addr and UDP/TCP port, I ha= ve the same comments on this patch too. Two more things. 1) commit title. 'eswitch' isn't allowed. Like you mentioned in the commit message, it is officially E-Switch. And I'm curious why '-' is needed for the title. 2) MLX5_ACTION_* As there are a few more pending patches which add new actions - encap/decap= and multi-table, we may have to have final rebasing in order at the last moment= . Thanks, Yongseok > drivers/net/mlx5/mlx5_flow.h | 2 + > drivers/net/mlx5/mlx5_flow_tcf.c | 74 +++++++++++++++++++++++++++++++- > 2 files changed, 74 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h > index be182a643..5237e31dd 100644 > --- a/drivers/net/mlx5/mlx5_flow.h > +++ b/drivers/net/mlx5/mlx5_flow.h > @@ -93,6 +93,8 @@ > #define MLX5_ACTION_SET_IPV6_DST (1u << 14) > #define MLX5_ACTION_SET_TP_SRC (1u << 15) > #define MLX5_ACTION_SET_TP_DST (1u << 16) > +#define MLX5_ACTION_SET_TTL (1u << 17) > +#define MLX5_ACTION_DEC_TTL (1u << 18) > =20 > /* possible L3 layers protocols filtering. */ > #define MLX5_IP_PROTOCOL_TCP 6 > diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flo= w_tcf.c > index 85c92f369..af88c4a0d 100644 > --- a/drivers/net/mlx5/mlx5_flow_tcf.c > +++ b/drivers/net/mlx5/mlx5_flow_tcf.c > @@ -217,6 +217,10 @@ struct tc_pedit_sel { > #define TP_PORT_LEN 2 /* Transport Port (UDP/TCP) Length */ > #endif > =20 > +#ifndef TTL_LEN > +#define TTL_LEN 1 > +#endif > + > /** Empty masks for known item types. */ > static const union { > struct rte_flow_item_port_id port_id; > @@ -297,7 +301,9 @@ struct flow_tcf_ptoi { > (act) =3D=3D RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC || \ > (act) =3D=3D RTE_FLOW_ACTION_TYPE_SET_IPV6_DST || \ > (act) =3D=3D RTE_FLOW_ACTION_TYPE_SET_TP_SRC || \ > - (act) =3D=3D RTE_FLOW_ACTION_TYPE_SET_TP_DST) ? \ > + (act) =3D=3D RTE_FLOW_ACTION_TYPE_SET_TP_DST || \ > + (act) =3D=3D RTE_FLOW_ACTION_TYPE_SET_TTL || \ > + (act) =3D=3D RTE_FLOW_ACTION_TYPE_DEC_TTL) ? \ > 1 : 0; }) > #define MAX_PEDIT_KEYS (128) > #define SZ_PEDIT_KEY_VAL (4) > @@ -321,6 +327,34 @@ flow_tcf_calc_pedit_keys(const uint64_t size) > return keys; > } > =20 > +static void > +flow_tcf_pedit_key_set_dec_ttl(const struct rte_flow_action *actions, > + struct pedit_parser *p_parser, > + uint64_t item_flags) > +{ > + int idx =3D p_parser->sel.nkeys; > + > + p_parser->keys[idx].mask =3D 0xFFFFFF00; > + if (item_flags & MLX5_FLOW_LAYER_OUTER_L3_IPV4) { > + p_parser->keys_ex[idx].htype =3D TCA_PEDIT_KEY_EX_HDR_TYPE_IP4; > + p_parser->keys[idx].off =3D 8; /* IPv4 TTL Offset */ > + } > + if (item_flags & MLX5_FLOW_LAYER_OUTER_L3_IPV6) { > + p_parser->keys_ex[idx].htype =3D TCA_PEDIT_KEY_EX_HDR_TYPE_IP6; > + p_parser->keys[idx].off =3D 7; /* IPv6 HopLimit Offset */ > + } > + if (actions->type =3D=3D RTE_FLOW_ACTION_TYPE_DEC_TTL) { > + p_parser->keys_ex[idx].cmd =3D TCA_PEDIT_KEY_EX_CMD_ADD; > + p_parser->keys[idx].val =3D 0xFF; > + } else { > + p_parser->keys_ex[idx].cmd =3D TCA_PEDIT_KEY_EX_CMD_SET; > + p_parser->keys[idx].val =3D > + ((const struct rte_flow_action_set_ttl *) > + actions->conf)->ttl_value; > + } > + p_parser->sel.nkeys =3D (++idx); > +} > + > static void > flow_tcf_pedit_key_set_tp_port(const struct rte_flow_action *actions, > struct pedit_parser *p_parser, > @@ -408,6 +442,11 @@ flow_tcf_create_pedit_mnl_msg(struct nlmsghdr *nl, > flow_tcf_pedit_key_set_tp_port(*actions, > &p_parser, item_flags); > break; > + case RTE_FLOW_ACTION_TYPE_SET_TTL: > + case RTE_FLOW_ACTION_TYPE_DEC_TTL: > + flow_tcf_pedit_key_set_dec_ttl(*actions, > + &p_parser, item_flags); > + break; > default: > goto pedit_mnl_msg_done; > } > @@ -488,6 +527,14 @@ flow_tcf_get_pedit_actions_size(const struct rte_flo= w_action **actions, > keys +=3D flow_tcf_calc_pedit_keys(TP_PORT_LEN); > flags |=3D MLX5_ACTION_SET_TP_DST; > break; > + case RTE_FLOW_ACTION_TYPE_SET_TTL: > + keys +=3D flow_tcf_calc_pedit_keys(TTL_LEN); > + flags |=3D MLX5_ACTION_SET_TTL; > + break; > + case RTE_FLOW_ACTION_TYPE_DEC_TTL: > + keys +=3D flow_tcf_calc_pedit_keys(TTL_LEN); > + flags |=3D MLX5_ACTION_DEC_TTL; > + break; > default: > goto get_pedit_action_size_done; > } > @@ -988,13 +1035,20 @@ flow_tcf_validate(struct rte_eth_dev *dev, > case RTE_FLOW_ACTION_TYPE_SET_TP_DST: > action_flags |=3D MLX5_ACTION_SET_TP_DST; > break; > + case RTE_FLOW_ACTION_TYPE_SET_TTL: > + action_flags |=3D MLX5_ACTION_SET_TTL; > + break; > + case RTE_FLOW_ACTION_TYPE_DEC_TTL: > + action_flags |=3D MLX5_ACTION_DEC_TTL; > + break; > default: > return rte_flow_error_set(error, ENOTSUP, > RTE_FLOW_ERROR_TYPE_ACTION, > actions, > "action not supported"); > } > - if (IS_MODIFY_ACTION(actions->type)) { > + if (IS_MODIFY_ACTION(actions->type) && > + actions->type !=3D RTE_FLOW_ACTION_TYPE_DEC_TTL) { > if (!actions->conf) > return rte_flow_error_set(error, ENOTSUP, > RTE_FLOW_ERROR_TYPE_ACTION_CONF, > @@ -1029,6 +1083,16 @@ flow_tcf_validate(struct rte_eth_dev *dev, > "no TCP/UDP item found in" > " pattern"); > } > + if (action_flags & > + (MLX5_ACTION_SET_TTL | MLX5_ACTION_DEC_TTL)) { > + if (!(item_flags & > + (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | > + MLX5_FLOW_LAYER_OUTER_L3_IPV6))) > + return rte_flow_error_set(error, ENOTSUP, > + RTE_FLOW_ERROR_TYPE_ACTION, > + actions, > + "no IP found in pattern"); > + } > return 0; > } > =20 > @@ -1178,6 +1242,8 @@ flow_tcf_get_actions_and_size(const struct rte_flow= _action actions[], > case RTE_FLOW_ACTION_TYPE_SET_IPV6_DST: > case RTE_FLOW_ACTION_TYPE_SET_TP_SRC: > case RTE_FLOW_ACTION_TYPE_SET_TP_DST: > + case RTE_FLOW_ACTION_TYPE_SET_TTL: > + case RTE_FLOW_ACTION_TYPE_DEC_TTL: > size +=3D flow_tcf_get_pedit_actions_size(&actions, > &flags); > break; > @@ -1451,6 +1517,7 @@ flow_tcf_translate(struct rte_eth_dev *dev, struct = mlx5_flow *dev_flow, > RTE_BE16(0x0fff))); > break; > case RTE_FLOW_ITEM_TYPE_IPV4: > + item_flags |=3D MLX5_FLOW_LAYER_OUTER_L3_IPV4; > mask.ipv4 =3D flow_tcf_item_mask > (items, &rte_flow_item_ipv4_mask, > &flow_tcf_mask_supported.ipv4, > @@ -1490,6 +1557,7 @@ flow_tcf_translate(struct rte_eth_dev *dev, struct = mlx5_flow *dev_flow, > } > break; > case RTE_FLOW_ITEM_TYPE_IPV6: > + item_flags |=3D MLX5_FLOW_LAYER_OUTER_L3_IPV6; > mask.ipv6 =3D flow_tcf_item_mask > (items, &rte_flow_item_ipv6_mask, > &flow_tcf_mask_supported.ipv6, > @@ -1718,6 +1786,8 @@ flow_tcf_translate(struct rte_eth_dev *dev, struct = mlx5_flow *dev_flow, > case RTE_FLOW_ACTION_TYPE_SET_IPV6_DST: > case RTE_FLOW_ACTION_TYPE_SET_TP_SRC: > case RTE_FLOW_ACTION_TYPE_SET_TP_DST: > + case RTE_FLOW_ACTION_TYPE_SET_TTL: > + case RTE_FLOW_ACTION_TYPE_DEC_TTL: > na_act_index =3D > mnl_attr_nest_start(nlh, na_act_index_cur++); > flow_tcf_create_pedit_mnl_msg(nlh, > --=20 > 2.17.1 >=20