From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00042.outbound.protection.outlook.com [40.107.0.42]) by dpdk.org (Postfix) with ESMTP id 76AEC1B1CC for ; Thu, 11 Oct 2018 07:47:27 +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=dxV9rw54TGk4tfPaiNwgpMp9USzZQipDT45xCgUmf1Q=; b=bbhymS6ig8f2cOM/wmPfkkwJrGoKkKrMRBxaiem29W0Z94PhrdGqAwvn90EAWvcbzxy+4Z213VcIzoAWi7J/aXMemFbtTYhmyAk7G+oqLerB1PLvOZoi6avysIAF3j8bm9bQww8k//KoMYEjJSyoeH/bvlRg1zzMyGSK7UEMdx8= Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com (52.134.72.27) by DB3PR0502MB3964.eurprd05.prod.outlook.com (52.134.65.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.23; Thu, 11 Oct 2018 05:47:25 +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.1207.029; Thu, 11 Oct 2018 05:47:25 +0000 From: Yongseok Koh To: Jack Min CC: Shahaf Shuler , "dev@dpdk.org" Thread-Topic: [PATCH v3 3/3] net/mlx5: rewrite TTL by E-Switch Thread-Index: AQHUYJn+MjJKR3RPw0CgxrPr4vvTSqUZiocA Date: Thu, 11 Oct 2018 05:47:25 +0000 Message-ID: <20181011054716.GC27741@mtidpdk.mti.labs.mlnx> References: <20180925143719.23339-1-jackmin@mellanox.com> <20181010130524.23590-1-jackmin@mellanox.com> <20181010130524.23590-4-jackmin@mellanox.com> In-Reply-To: <20181010130524.23590-4-jackmin@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: DM3PR12CA0058.namprd12.prod.outlook.com (2603:10b6:0:56::26) 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; DB3PR0502MB3964; 6:7S5KUS7kOU7j6N62lTxmXeXU2YRkRYPXxm1InUxBrqOIR/N1urUkrGQ+ZCFcBiX9cLTppHnMG+sUczWd4IYIxRovskWchOlLWToVWeXokXoetoMbfb0mkcpISxRIiiAr/VBACMwkt+YlfdtsjGxJh6pqnZh2zzCQcWp7ZYaQP+JB+JEYbFQsX2WAbPXtQIs0idy5e8F9ccehwtQW5kKNXKnucf+C0SfT1S35t5J7mJOLgahREwa48i011/FCs2Dq5gv7C/w9lO91RsOip7b3yeTOv0JpQkw+JMB3rc7hmiEHddVzVdxjCmm5IA7CXRLz2fElvVA6scoYR5YRNyDOhG/KkI7LQ2qYRSj9dFDc5RCgiSjc/et2g0h4ggIswUNqeMEQ8EPRewNeAICh5oPsam47U+AufZMQC26UCpBrmi+H/U0t1WfIeBniBWqA/6UCXqG5VoH6JgZQ26qOuzpbKA==; 5:5U0/NRt3nJz5Zt9TlS3Q0FP/yvfYJYl+WbPnhy7HHFNGiYP6JqSWEKV03DPyL5yWtafllAzkEauTT+a9q4q2RvnUJZ8H7llq8TkdjEKWwlq4O18WPHHL/oqGoNEKK2URcTAz8rLo/1iUB0dCBWLhNUEITyoHtQ7mcJkJ+wOb2bk=; 7:Zt5SigCoSSTLZVTE9TeuXfGJuswC4tEfqHZu4Z21drah2BR+P3lkhy6+zTd8f22XddzsA7QRIhP2QEWzY69snaEX9nqBrOOdiVon7Y0WnnZOiCdV+IBaf9kR0Qy+gGbeOx0ygxID2Rq9bYT9jFx5ArUKFjEqRvuOULbiErVhmjfv8AXCyH1TUIVj8RV+XaHDhjI1A+3ba4ELUgjJjkaWJ21yWvORpd1fAt9ZiaxO1mvwjg5Yz0WQY+wytLSRCwPg x-ms-office365-filtering-correlation-id: 92f27d0c-1d43-49cd-106e-08d62f3d055d 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:DB3PR0502MB3964; x-ms-traffictypediagnostic: DB3PR0502MB3964: 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)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123562045)(201708071742011)(7699051)(76991055); SRVR:DB3PR0502MB3964; BCL:0; PCL:0; RULEID:; SRVR:DB3PR0502MB3964; x-forefront-prvs: 08220FA8D6 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(396003)(39860400002)(376002)(136003)(346002)(199004)(189003)(25786009)(2906002)(305945005)(7736002)(186003)(76176011)(52116002)(9686003)(6512007)(6436002)(99286004)(6486002)(229853002)(6246003)(1076002)(6506007)(386003)(26005)(6862004)(102836004)(33896004)(3846002)(14454004)(6116002)(4326008)(105586002)(106356001)(478600001)(6636002)(71190400001)(97736004)(71200400001)(54906003)(68736007)(66066001)(316002)(8936002)(8676002)(81166006)(81156014)(5660300001)(5250100002)(476003)(86362001)(446003)(256004)(14444005)(11346002)(53936002)(33656002)(486006)(2900100001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR0502MB3964; 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: +lJPgb1tO8XRBGP8i9WN9H4kHfwOs1q05YJfrOKsOgWvr8dlJwFjDbawfbs1jWHjHZ38jaWOzAqz/GbACRueI6LlFo35e2uXdhBfaQ3A/c2kvAO7Vkbx0AzIhnLLSybFCzC3OA3EOAmElh0Dhym76LUEI6lSbWwXpU2gYRara/nULsQTQupe5+Xub3gYh2ziLuvJTQCMEiq0N5/P7KYq5vdJdBeANUfZkiFg0mXi74JmSQHndzSr6vZUcODoZm3mqaZirwhbJyJqySUaZ17VANXyuKC1sMjH2ZxloloCu23Fq2nIh0i2wNT8yKusWDvVmikGu4tvuTOObJw53U8Cbk6FDurNPn9nJds5cKHqGXQ= 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: 92f27d0c-1d43-49cd-106e-08d62f3d055d X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Oct 2018 05:47:25.4933 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0502MB3964 Subject: Re: [dpdk-dev] [PATCH v3 3/3] net/mlx5: rewrite TTL by E-Switch 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, 11 Oct 2018 05:47:27 -0000 On Wed, Oct 10, 2018 at 06:06:00AM -0700, Jack Min wrote: > Offload following modify TTL actions to E-Switch 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 > The example testpmd commands are: >=20 > flow create 0 transfer ingress > pattern eth / ipv4 / udp dst is 7000 / end > actions dec_ttl / > port_id id 1 / end >=20 > flow create 0 transfer ingress > pattern eth / ipv4 / udp dst is 7001 / end > actions set_ttl ttl_value 10 / > port_id id 1 / end >=20 > Signed-off-by: Xiaoyu Min > --- Acked-by: Yongseok Koh But you should rebase it on your patch - net/mlx5: rewrite IP address UDP/TCP port by E-Switch Thanks > drivers/net/mlx5/mlx5_flow.h | 2 + > drivers/net/mlx5/mlx5_flow_tcf.c | 84 +++++++++++++++++++++++++++++++- > 2 files changed, 84 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h > index cbb8c56c8..0ad8c12ea 100644 > --- a/drivers/net/mlx5/mlx5_flow.h > +++ b/drivers/net/mlx5/mlx5_flow.h > @@ -84,6 +84,8 @@ > #define MLX5_FLOW_ACTION_SET_IPV6_DST (1u << 14) > #define MLX5_FLOW_ACTION_SET_TP_SRC (1u << 15) > #define MLX5_FLOW_ACTION_SET_TP_DST (1u << 16) > +#define MLX5_FLOW_ACTION_SET_TTL (1u << 17) > +#define MLX5_FLOW_ACTION_DEC_TTL (1u << 18) > =20 > #define MLX5_FLOW_FATE_ACTIONS \ > (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | MLX5_FLOW_ACTION_RSS) > diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flo= w_tcf.c > index 65e8a4b3f..af8a68529 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; > @@ -299,13 +303,16 @@ struct flow_tcf_ptoi { > MLX5_FLOW_ACTION_SET_IPV6_SRC | \ > MLX5_FLOW_ACTION_SET_IPV6_DST | \ > MLX5_FLOW_ACTION_SET_TP_SRC | \ > - MLX5_FLOW_ACTION_SET_TP_DST) > + MLX5_FLOW_ACTION_SET_TP_DST | \ > + MLX5_FLOW_ACTION_SET_TTL | \ > + MLX5_FLOW_ACTION_DEC_TTL) > =20 > #define MLX5_TCF_CONFIG_ACTIONS (MLX5_FLOW_ACTION_PORT_ID | \ > MLX5_FLOW_ACTION_OF_PUSH_VLAN | \ > MLX5_FLOW_ACTION_OF_SET_VLAN_VID | \ > MLX5_FLOW_ACTION_OF_SET_VLAN_PCP | \ > - MLX5_TCF_PEDIT_ACTIONS) > + (MLX5_TCF_PEDIT_ACTIONS & \ > + ~MLX5_FLOW_ACTION_DEC_TTL)) > =20 > #define MAX_PEDIT_KEYS (128) > #define SZ_PEDIT_KEY_VAL (4) > @@ -338,6 +345,46 @@ flow_tcf_calc_pedit_keys(const uint64_t size) > return keys; > } > =20 > +/** > + * Set pedit key of decrease/set ttl > + * > + * @param[in] actions > + * pointer to action specification > + * @param[in,out] p_parser > + * pointer to pedit_parser > + * @param[in] item_flags > + * flags of all items presented > + */ > +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 > + offsetof(struct ipv4_hdr, time_to_live); > + } > + 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 > + offsetof(struct ipv6_hdr, hop_limits); > + } > + 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 0x000000FF; > + } else { > + p_parser->keys_ex[idx].cmd =3D TCA_PEDIT_KEY_EX_CMD_SET; > + p_parser->keys[idx].val =3D > + (__u32)((const struct rte_flow_action_set_ttl *) > + actions->conf)->ttl_value; > + } > + p_parser->sel.nkeys =3D (++idx); > +} > + > /** > * Set pedit key of transport (TCP/UDP) port value > * > @@ -477,6 +524,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; > } > @@ -557,6 +609,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_FLOW_ACTION_SET_TP_DST; > break; > + case RTE_FLOW_ACTION_TYPE_SET_TTL: > + keys +=3D flow_tcf_calc_pedit_keys(TTL_LEN); > + flags |=3D MLX5_FLOW_ACTION_SET_TTL; > + break; > + case RTE_FLOW_ACTION_TYPE_DEC_TTL: > + keys +=3D flow_tcf_calc_pedit_keys(TTL_LEN); > + flags |=3D MLX5_FLOW_ACTION_DEC_TTL; > + break; > default: > goto get_pedit_action_size_done; > } > @@ -1075,6 +1135,12 @@ flow_tcf_validate(struct rte_eth_dev *dev, > 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; > default: > return rte_flow_error_set(error, ENOTSUP, > RTE_FLOW_ERROR_TYPE_ACTION, > @@ -1169,6 +1235,16 @@ flow_tcf_validate(struct rte_eth_dev *dev, > return rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, actions, > "no fate action is found"); > + if (action_flags & > + (MLX5_FLOW_ACTION_SET_TTL | MLX5_FLOW_ACTION_DEC_TTL)) { > + if (!(item_flags & > + (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | > + MLX5_FLOW_LAYER_OUTER_L3_IPV6))) > + return rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ACTION, > + actions, > + "no IP found in pattern"); > + } > return 0; > } > =20 > @@ -1318,6 +1394,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; > @@ -1862,6 +1940,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