From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10052.outbound.protection.outlook.com [40.107.1.52]) by dpdk.org (Postfix) with ESMTP id C3C934CA9 for ; Tue, 2 Apr 2019 18:34:06 +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=UlR8RFusP9tELiWCTUdNk8N6rKXoAT/M4pw+8sj4gTw=; b=mtH1SjVFFGyE0UCuLH3K/qw8h/ixcDiMUpvMIiWVz7+w9MvyBsradhXKNfpuaBWXaibV7Hj/AJpuS2kv2lX9sPwlkBzZRpHmiXkt8DO5KZhhVuU8ark5UiZ3PaqSe0lceSxlhV8mRPd2/m7anVpAwnWpxNuW8McSx/41E2EXdVs= Received: from AM4PR05MB3425.eurprd05.prod.outlook.com (10.171.190.15) by AM4PR05MB3172.eurprd05.prod.outlook.com (10.171.186.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1750.20; Tue, 2 Apr 2019 16:34:02 +0000 Received: from AM4PR05MB3425.eurprd05.prod.outlook.com ([fe80::5df0:22de:97f0:3827]) by AM4PR05MB3425.eurprd05.prod.outlook.com ([fe80::5df0:22de:97f0:3827%4]) with mapi id 15.20.1750.014; Tue, 2 Apr 2019 16:34:02 +0000 From: Ori Kam To: Dekel Peled , Adrien Mazarguil , "wenzhuo.lu@intel.com" , "jingjing.wu@intel.com" , "bernard.iremonger@intel.com" , Yongseok Koh , Shahaf Shuler CC: "dev@dpdk.org" , Dekel Peled Thread-Topic: [dpdk-dev] [PATCH v2 3/3] net/mlx5: update modify header using Direct Verbs Thread-Index: AQHU6WbnIxLNpIMn2kykC7Y0fgX7aKYpEOMw Date: Tue, 2 Apr 2019 16:34:02 +0000 Message-ID: References: <1553177917-43297-1-git-send-email-dekelp@mellanox.com> <1554218001-62012-4-git-send-email-dekelp@mellanox.com> In-Reply-To: <1554218001-62012-4-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=orika@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 0d8caa66-3c0c-4b10-bd17-08d6b78903d1 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600139)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:AM4PR05MB3172; x-ms-traffictypediagnostic: AM4PR05MB3172: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-forefront-prvs: 0995196AA2 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(346002)(376002)(136003)(39860400002)(396003)(199004)(189003)(13464003)(2906002)(55016002)(71200400001)(478600001)(81166006)(25786009)(229853002)(74316002)(9686003)(4326008)(71190400001)(305945005)(53936002)(52536014)(6636002)(97736004)(7736002)(6246003)(8936002)(107886003)(5660300002)(2501003)(6436002)(81156014)(15650500001)(6506007)(66066001)(2201001)(26005)(6116002)(110136005)(316002)(76176011)(30864003)(102836004)(68736007)(14444005)(33656002)(186003)(106356001)(99286004)(7696005)(53546011)(476003)(486006)(256004)(11346002)(446003)(86362001)(14454004)(3846002)(54906003)(105586002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3172; H:AM4PR05MB3425.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: o5qNBYECmGcm/P8RMBTCehTa39SG1PnbaUOh7huCocDXuSof4fq+kJw5CDzdbzWHXmqCWwj26h/l61QN5wkximKFX8D1ExQehKKoySSEEJICplxZyRP0JLtXOV3M0bov6XAc83IaisYocdBUss457Ux1kIDPZjzLvIrhl5bI0lKB7wrOKUxMqfSv+qTZFszT1hZkbqWC51QTJRxYNDrebWNh29LKY6+Q1te+blOG0sjh5R1roT49go+EZ/pX+16dzPW1BgE0r+rgiPBCAj6FoNYWeWxaZCYl9PulqxcWHBHYQnAZ0MBRAbGxVuX22JFIkWlDf6JrjjCqrIiDKmMBSXiHpZdc+EbNM+JQH3+XaiZ2BaYMyPLTnY8oEcIjYo5jlN9tWUip8pNNafqvHHJgTha5NUAmeY/uO5ZRIxmVABM= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d8caa66-3c0c-4b10-bd17-08d6b78903d1 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Apr 2019 16:34:02.0782 (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: AM4PR05MB3172 Subject: Re: [dpdk-dev] [PATCH v2 3/3] net/mlx5: update modify header using Direct Verbs 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: Tue, 02 Apr 2019 16:34:07 -0000 > -----Original Message----- > From: dev On Behalf Of Dekel Peled > Sent: Tuesday, April 2, 2019 6:13 PM > To: Adrien Mazarguil ; wenzhuo.lu@intel.com; > jingjing.wu@intel.com; bernard.iremonger@intel.com; Yongseok Koh > ; Shahaf Shuler > Cc: dev@dpdk.org; Ori Kam ; Dekel Peled > > Subject: [dpdk-dev] [PATCH v2 3/3] net/mlx5: update modify header using > Direct Verbs >=20 > This patch implements additional actions of packet header > modifications. >=20 > Add actions: > - INC_TCP_SEQ - Increase sequence number in the outermost TCP header. > - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header. > - INC_TCP_ACK - Increase acknowledgment number in the outermost TCP > header. > - DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP > header. >=20 > Original work by Xiaoyu Min. >=20 > Signed-off-by: Dekel Peled > --- > drivers/net/mlx5/mlx5_flow.h | 10 +- > drivers/net/mlx5/mlx5_flow_dv.c | 239 > ++++++++++++++++++++++++++++++++++++++++ > drivers/net/mlx5/mlx5_prm.h | 12 ++ > 3 files changed, 260 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h > index e1e798b..c49e245 100644 > --- a/drivers/net/mlx5/mlx5_flow.h > +++ b/drivers/net/mlx5/mlx5_flow.h > @@ -113,6 +113,10 @@ > #define MLX5_FLOW_ACTION_NVGRE_DECAP (1u << 25) > #define MLX5_FLOW_ACTION_RAW_ENCAP (1u << 26) > #define MLX5_FLOW_ACTION_RAW_DECAP (1u << 27) > +#define MLX5_FLOW_ACTION_INC_TCP_SEQ (1u << 28) > +#define MLX5_FLOW_ACTION_DEC_TCP_SEQ (1u << 29) > +#define MLX5_FLOW_ACTION_INC_TCP_ACK (1u << 30) > +#define MLX5_FLOW_ACTION_DEC_TCP_ACK (1u << 31) >=20 > #define MLX5_FLOW_FATE_ACTIONS \ > (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | > MLX5_FLOW_ACTION_RSS) > @@ -134,7 +138,11 @@ > MLX5_FLOW_ACTION_SET_TTL | \ > MLX5_FLOW_ACTION_DEC_TTL | \ > MLX5_FLOW_ACTION_SET_MAC_SRC | \ > - MLX5_FLOW_ACTION_SET_MAC_DST) > + MLX5_FLOW_ACTION_SET_MAC_DST | \ > + MLX5_FLOW_ACTION_INC_TCP_SEQ | \ > + MLX5_FLOW_ACTION_DEC_TCP_SEQ | \ > + MLX5_FLOW_ACTION_INC_TCP_ACK | \ > + MLX5_FLOW_ACTION_DEC_TCP_ACK) >=20 > #ifndef IPPROTO_MPLS > #define IPPROTO_MPLS 137 > diff --git a/drivers/net/mlx5/mlx5_flow_dv.c > b/drivers/net/mlx5/mlx5_flow_dv.c > index 966dad9..eadd93f 100644 > --- a/drivers/net/mlx5/mlx5_flow_dv.c > +++ b/drivers/net/mlx5/mlx5_flow_dv.c > @@ -126,6 +126,8 @@ struct field_modify_info modify_udp[] =3D { > struct field_modify_info modify_tcp[] =3D { > {2, 0, MLX5_MODI_OUT_TCP_SPORT}, > {2, 2, MLX5_MODI_OUT_TCP_DPORT}, > + {4, 4, MLX5_MODI_OUT_TCP_SEQ_NUM}, > + {4, 8, MLX5_MODI_OUT_TCP_ACK_NUM}, > {0, 0, 0}, > }; >=20 > @@ -512,6 +514,98 @@ struct field_modify_info modify_tcp[] =3D { > } >=20 > /** > + * Convert modify-header increment/decrement TCP Sequence number > + * to DV specification. > + * > + * @param[in,out] resource > + * Pointer to the modify-header resource. > + * @param[in] action > + * Pointer to action specification. > + * @param[out] error > + * Pointer to the error structure. > + * > + * @return > + * 0 on success, a negative errno value otherwise and rte_errno is set= . > + */ > +static int > +flow_dv_convert_action_modify_tcp_seq > + (struct mlx5_flow_dv_modify_hdr_resource *resource, > + const struct rte_flow_action *action, > + struct rte_flow_error *error) > +{ > + const struct rte_flow_action_modify_tcp_seq *conf =3D > + (const struct rte_flow_action_modify_tcp_seq *)(action->conf); > + uint64_t value =3D rte_be_to_cpu_32(conf->value); > + struct rte_flow_item item; > + struct rte_flow_item_tcp tcp; > + struct rte_flow_item_tcp tcp_mask; > + > + memset(&tcp, 0, sizeof(tcp)); > + memset(&tcp_mask, 0, sizeof(tcp_mask)); > + if (action->type =3D=3D RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ) > + /* > + * The HW has no decrement operation, only increment > operation. > + * To simulate decrement X from Y using increment operation > + * we need to add UINT32_MAX X times to Y. > + * Each adding of UINT32_MAX decrements Y by 1. > + */ > + value *=3D UINT32_MAX; > + tcp.hdr.sent_seq =3D rte_cpu_to_be_32((uint32_t)value); > + tcp_mask.hdr.sent_seq =3D RTE_BE32(UINT32_MAX); > + item.type =3D RTE_FLOW_ITEM_TYPE_TCP; > + item.spec =3D &tcp; > + item.mask =3D &tcp_mask; > + return flow_dv_convert_modify_action(&item, modify_tcp, resource, > + MLX5_MODIFICATION_TYPE_ADD, > error); > +} > + > +/** > + * Convert modify-header increment/decrement TCP Acknowledgment > number > + * to DV specification. > + * > + * @param[in,out] resource > + * Pointer to the modify-header resource. > + * @param[in] action > + * Pointer to action specification. > + * @param[out] error > + * Pointer to the error structure. > + * > + * @return > + * 0 on success, a negative errno value otherwise and rte_errno is set= . > + */ > +static int > +flow_dv_convert_action_modify_tcp_ack > + (struct mlx5_flow_dv_modify_hdr_resource *resource, > + const struct rte_flow_action *action, > + struct rte_flow_error *error) > +{ > + const struct rte_flow_action_modify_tcp_ack *conf =3D > + (const struct rte_flow_action_modify_tcp_ack *)(action->conf); > + uint64_t value =3D rte_be_to_cpu_32(conf->value); > + struct rte_flow_item item; > + struct rte_flow_item_tcp tcp; > + struct rte_flow_item_tcp tcp_mask; > + > + memset(&tcp, 0, sizeof(tcp)); > + memset(&tcp_mask, 0, sizeof(tcp_mask)); > + if (action->type =3D=3D RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK) > + /* > + * The HW has no decrement operation, only increment > operation. > + * To simulate decrement X from Y using increment operation > + * we need to add UINT32_MAX X times to Y. > + * Each adding of UINT32_MAX decrements Y by 1. > + */ > + value *=3D UINT32_MAX; > + tcp.hdr.recv_ack =3D rte_cpu_to_be_32((uint32_t)value); > + tcp_mask.hdr.recv_ack =3D RTE_BE32(UINT32_MAX); > + item.type =3D RTE_FLOW_ITEM_TYPE_TCP; > + item.spec =3D &tcp; > + item.mask =3D &tcp_mask; > + return flow_dv_convert_modify_action(&item, modify_tcp, resource, > + MLX5_MODIFICATION_TYPE_ADD, > error); > +} > + > +/** > * Validate META item. > * > * @param[in] dev > @@ -1385,6 +1479,96 @@ struct field_modify_info modify_tcp[] =3D { > } >=20 > /** > + * Validate the modify-header actions of increment/decrement > + * TCP Sequence-number. > + * > + * @param[in] action_flags > + * Holds the actions detected until now. > + * @param[in] action > + * Pointer to the modify action. > + * @param[in] item_flags > + * Holds the items detected. > + * @param[out] error > + * Pointer to error structure. > + * > + * @return > + * 0 on success, a negative errno value otherwise and rte_errno is set= . > + */ > +static int > +flow_dv_validate_action_modify_tcp_seq(const uint64_t action_flags, > + const struct rte_flow_action *action, > + const uint64_t item_flags, > + struct rte_flow_error *error) > +{ > + int ret =3D 0; > + > + ret =3D flow_dv_validate_action_modify_hdr(action_flags, action, error)= ; > + if (!ret) { > + if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP)) > + return rte_flow_error_set(error, EINVAL, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, "no TCP item in" > + " pattern"); > + if ((action->type =3D=3D RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ > && > + (action_flags & MLX5_FLOW_ACTION_DEC_TCP_SEQ)) > || > + (action->type =3D=3D RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ > && > + (action_flags & MLX5_FLOW_ACTION_INC_TCP_SEQ))) > + return rte_flow_error_set(error, EINVAL, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, > + "cannot decrease and > increase" > + " TCP sequence number" > + " at the same time"); > + } > + return ret; > +} > + > +/** > + * Validate the modify-header actions of increment/decrement > + * TCP Acknowledgment number. > + * > + * @param[in] action_flags > + * Holds the actions detected until now. > + * @param[in] action > + * Pointer to the modify action. > + * @param[in] item_flags > + * Holds the items detected. > + * @param[out] error > + * Pointer to error structure. > + * > + * @return > + * 0 on success, a negative errno value otherwise and rte_errno is set= . > + */ > +static int > +flow_dv_validate_action_modify_tcp_ack(const uint64_t action_flags, > + const struct rte_flow_action *action, > + const uint64_t item_flags, > + struct rte_flow_error *error) > +{ > + int ret =3D 0; > + > + ret =3D flow_dv_validate_action_modify_hdr(action_flags, action, error)= ; > + if (!ret) { > + if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP)) > + return rte_flow_error_set(error, EINVAL, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, "no TCP item in" > + " pattern"); > + if ((action->type =3D=3D RTE_FLOW_ACTION_TYPE_INC_TCP_ACK > && > + (action_flags & MLX5_FLOW_ACTION_DEC_TCP_ACK)) > || > + (action->type =3D=3D RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK > && > + (action_flags & MLX5_FLOW_ACTION_INC_TCP_ACK))) > + return rte_flow_error_set(error, EINVAL, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, > + "cannot decrease and > increase" > + " TCP acknowledgment > number" > + " at the same time"); > + } > + return ret; > +} > + > +/** > * Validate the modify-header TTL actions. > * > * @param[in] action_flags > @@ -1962,6 +2146,40 @@ struct field_modify_info modify_tcp[] =3D { >=20 > MLX5_FLOW_ACTION_SET_TTL : >=20 > MLX5_FLOW_ACTION_DEC_TTL; > break; > + case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ: > + case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ: > + ret =3D flow_dv_validate_action_modify_tcp_seq > + (action_flags, > + actions, > + item_flags, > + error); > + if (ret < 0) > + return ret; > + /* Count all modify-header actions as one action. */ > + if (!(action_flags & > MLX5_FLOW_MODIFY_HDR_ACTIONS)) > + ++actions_n; > + action_flags |=3D actions->type =3D=3D > + > RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ? > + > MLX5_FLOW_ACTION_INC_TCP_SEQ : > + > MLX5_FLOW_ACTION_DEC_TCP_SEQ; > + break; > + case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK: > + case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK: > + ret =3D flow_dv_validate_action_modify_tcp_ack > + (action_flags, > + actions, > + item_flags, > + error); > + if (ret < 0) > + return ret; > + /* Count all modify-header actions as one action. */ > + if (!(action_flags & > MLX5_FLOW_MODIFY_HDR_ACTIONS)) > + ++actions_n; > + action_flags |=3D actions->type =3D=3D > + > RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ? > + > MLX5_FLOW_ACTION_INC_TCP_ACK : > + > MLX5_FLOW_ACTION_DEC_TCP_ACK; > + break; > default: > return rte_flow_error_set(error, ENOTSUP, >=20 > RTE_FLOW_ERROR_TYPE_ACTION, > @@ -3089,6 +3307,27 @@ struct field_modify_info modify_tcp[] =3D { > return -rte_errno; > action_flags |=3D MLX5_FLOW_ACTION_SET_TTL; > break; > + case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ: > + case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ: > + if (flow_dv_convert_action_modify_tcp_seq(&res, > actions, > + error)) > + return -rte_errno; > + action_flags |=3D actions->type =3D=3D > + > RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ? > + MLX5_FLOW_ACTION_INC_TCP_SEQ : > + MLX5_FLOW_ACTION_DEC_TCP_SEQ; > + break; > + > + case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK: > + case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK: > + if (flow_dv_convert_action_modify_tcp_ack(&res, > actions, > + error)) > + return -rte_errno; > + action_flags |=3D actions->type =3D=3D > + > RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ? > + MLX5_FLOW_ACTION_INC_TCP_ACK : > + MLX5_FLOW_ACTION_DEC_TCP_ACK; > + break; > case RTE_FLOW_ACTION_TYPE_END: > actions_end =3D true; > if (action_flags & > MLX5_FLOW_MODIFY_HDR_ACTIONS) { > diff --git a/drivers/net/mlx5/mlx5_prm.h b/drivers/net/mlx5/mlx5_prm.h > index da1219e..d5c5d3c 100644 > --- a/drivers/net/mlx5/mlx5_prm.h > +++ b/drivers/net/mlx5/mlx5_prm.h > @@ -336,6 +336,18 @@ enum mlx5_modification_field { > MLX5_MODI_IN_IPV6_HOPLIMIT, > MLX5_MODI_META_DATA_REG_A, > MLX5_MODI_META_DATA_REG_B =3D 0x50, > + MLX5_MODI_META_REG_C_0, > + MLX5_MODI_META_REG_C_1, > + MLX5_MODI_META_REG_C_2, > + MLX5_MODI_META_REG_C_3, > + MLX5_MODI_META_REG_C_4, > + MLX5_MODI_META_REG_C_5, > + MLX5_MODI_META_REG_C_6, > + MLX5_MODI_META_REG_C_7, > + MLX5_MODI_OUT_TCP_SEQ_NUM, > + MLX5_MODI_IN_TCP_SEQ_NUM, > + MLX5_MODI_OUT_TCP_ACK_NUM, > + MLX5_MODI_IN_TCP_ACK_NUM =3D 0x5C, > }; >=20 > /* Modification sub command. */ > -- > 1.8.3.1 Thanks, Acked-by: Ori Kam 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 8D4D7A0679 for ; Tue, 2 Apr 2019 18:34:08 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 558E458C4; Tue, 2 Apr 2019 18:34:08 +0200 (CEST) Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10052.outbound.protection.outlook.com [40.107.1.52]) by dpdk.org (Postfix) with ESMTP id C3C934CA9 for ; Tue, 2 Apr 2019 18:34:06 +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=UlR8RFusP9tELiWCTUdNk8N6rKXoAT/M4pw+8sj4gTw=; b=mtH1SjVFFGyE0UCuLH3K/qw8h/ixcDiMUpvMIiWVz7+w9MvyBsradhXKNfpuaBWXaibV7Hj/AJpuS2kv2lX9sPwlkBzZRpHmiXkt8DO5KZhhVuU8ark5UiZ3PaqSe0lceSxlhV8mRPd2/m7anVpAwnWpxNuW8McSx/41E2EXdVs= Received: from AM4PR05MB3425.eurprd05.prod.outlook.com (10.171.190.15) by AM4PR05MB3172.eurprd05.prod.outlook.com (10.171.186.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1750.20; Tue, 2 Apr 2019 16:34:02 +0000 Received: from AM4PR05MB3425.eurprd05.prod.outlook.com ([fe80::5df0:22de:97f0:3827]) by AM4PR05MB3425.eurprd05.prod.outlook.com ([fe80::5df0:22de:97f0:3827%4]) with mapi id 15.20.1750.014; Tue, 2 Apr 2019 16:34:02 +0000 From: Ori Kam To: Dekel Peled , Adrien Mazarguil , "wenzhuo.lu@intel.com" , "jingjing.wu@intel.com" , "bernard.iremonger@intel.com" , Yongseok Koh , Shahaf Shuler CC: "dev@dpdk.org" , Dekel Peled Thread-Topic: [dpdk-dev] [PATCH v2 3/3] net/mlx5: update modify header using Direct Verbs Thread-Index: AQHU6WbnIxLNpIMn2kykC7Y0fgX7aKYpEOMw Date: Tue, 2 Apr 2019 16:34:02 +0000 Message-ID: References: <1553177917-43297-1-git-send-email-dekelp@mellanox.com> <1554218001-62012-4-git-send-email-dekelp@mellanox.com> In-Reply-To: <1554218001-62012-4-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=orika@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 0d8caa66-3c0c-4b10-bd17-08d6b78903d1 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600139)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:AM4PR05MB3172; x-ms-traffictypediagnostic: AM4PR05MB3172: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-forefront-prvs: 0995196AA2 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(346002)(376002)(136003)(39860400002)(396003)(199004)(189003)(13464003)(2906002)(55016002)(71200400001)(478600001)(81166006)(25786009)(229853002)(74316002)(9686003)(4326008)(71190400001)(305945005)(53936002)(52536014)(6636002)(97736004)(7736002)(6246003)(8936002)(107886003)(5660300002)(2501003)(6436002)(81156014)(15650500001)(6506007)(66066001)(2201001)(26005)(6116002)(110136005)(316002)(76176011)(30864003)(102836004)(68736007)(14444005)(33656002)(186003)(106356001)(99286004)(7696005)(53546011)(476003)(486006)(256004)(11346002)(446003)(86362001)(14454004)(3846002)(54906003)(105586002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3172; H:AM4PR05MB3425.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: o5qNBYECmGcm/P8RMBTCehTa39SG1PnbaUOh7huCocDXuSof4fq+kJw5CDzdbzWHXmqCWwj26h/l61QN5wkximKFX8D1ExQehKKoySSEEJICplxZyRP0JLtXOV3M0bov6XAc83IaisYocdBUss457Ux1kIDPZjzLvIrhl5bI0lKB7wrOKUxMqfSv+qTZFszT1hZkbqWC51QTJRxYNDrebWNh29LKY6+Q1te+blOG0sjh5R1roT49go+EZ/pX+16dzPW1BgE0r+rgiPBCAj6FoNYWeWxaZCYl9PulqxcWHBHYQnAZ0MBRAbGxVuX22JFIkWlDf6JrjjCqrIiDKmMBSXiHpZdc+EbNM+JQH3+XaiZ2BaYMyPLTnY8oEcIjYo5jlN9tWUip8pNNafqvHHJgTha5NUAmeY/uO5ZRIxmVABM= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d8caa66-3c0c-4b10-bd17-08d6b78903d1 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Apr 2019 16:34:02.0782 (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: AM4PR05MB3172 Subject: Re: [dpdk-dev] [PATCH v2 3/3] net/mlx5: update modify header using Direct Verbs 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: <20190402163402.-RBHLRyplKVeyn6YUE8HF0OLAI9nJj6TXCmFNrriZWI@z> > -----Original Message----- > From: dev On Behalf Of Dekel Peled > Sent: Tuesday, April 2, 2019 6:13 PM > To: Adrien Mazarguil ; wenzhuo.lu@intel.com; > jingjing.wu@intel.com; bernard.iremonger@intel.com; Yongseok Koh > ; Shahaf Shuler > Cc: dev@dpdk.org; Ori Kam ; Dekel Peled > > Subject: [dpdk-dev] [PATCH v2 3/3] net/mlx5: update modify header using > Direct Verbs >=20 > This patch implements additional actions of packet header > modifications. >=20 > Add actions: > - INC_TCP_SEQ - Increase sequence number in the outermost TCP header. > - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header. > - INC_TCP_ACK - Increase acknowledgment number in the outermost TCP > header. > - DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP > header. >=20 > Original work by Xiaoyu Min. >=20 > Signed-off-by: Dekel Peled > --- > drivers/net/mlx5/mlx5_flow.h | 10 +- > drivers/net/mlx5/mlx5_flow_dv.c | 239 > ++++++++++++++++++++++++++++++++++++++++ > drivers/net/mlx5/mlx5_prm.h | 12 ++ > 3 files changed, 260 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h > index e1e798b..c49e245 100644 > --- a/drivers/net/mlx5/mlx5_flow.h > +++ b/drivers/net/mlx5/mlx5_flow.h > @@ -113,6 +113,10 @@ > #define MLX5_FLOW_ACTION_NVGRE_DECAP (1u << 25) > #define MLX5_FLOW_ACTION_RAW_ENCAP (1u << 26) > #define MLX5_FLOW_ACTION_RAW_DECAP (1u << 27) > +#define MLX5_FLOW_ACTION_INC_TCP_SEQ (1u << 28) > +#define MLX5_FLOW_ACTION_DEC_TCP_SEQ (1u << 29) > +#define MLX5_FLOW_ACTION_INC_TCP_ACK (1u << 30) > +#define MLX5_FLOW_ACTION_DEC_TCP_ACK (1u << 31) >=20 > #define MLX5_FLOW_FATE_ACTIONS \ > (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | > MLX5_FLOW_ACTION_RSS) > @@ -134,7 +138,11 @@ > MLX5_FLOW_ACTION_SET_TTL | \ > MLX5_FLOW_ACTION_DEC_TTL | \ > MLX5_FLOW_ACTION_SET_MAC_SRC | \ > - MLX5_FLOW_ACTION_SET_MAC_DST) > + MLX5_FLOW_ACTION_SET_MAC_DST | \ > + MLX5_FLOW_ACTION_INC_TCP_SEQ | \ > + MLX5_FLOW_ACTION_DEC_TCP_SEQ | \ > + MLX5_FLOW_ACTION_INC_TCP_ACK | \ > + MLX5_FLOW_ACTION_DEC_TCP_ACK) >=20 > #ifndef IPPROTO_MPLS > #define IPPROTO_MPLS 137 > diff --git a/drivers/net/mlx5/mlx5_flow_dv.c > b/drivers/net/mlx5/mlx5_flow_dv.c > index 966dad9..eadd93f 100644 > --- a/drivers/net/mlx5/mlx5_flow_dv.c > +++ b/drivers/net/mlx5/mlx5_flow_dv.c > @@ -126,6 +126,8 @@ struct field_modify_info modify_udp[] =3D { > struct field_modify_info modify_tcp[] =3D { > {2, 0, MLX5_MODI_OUT_TCP_SPORT}, > {2, 2, MLX5_MODI_OUT_TCP_DPORT}, > + {4, 4, MLX5_MODI_OUT_TCP_SEQ_NUM}, > + {4, 8, MLX5_MODI_OUT_TCP_ACK_NUM}, > {0, 0, 0}, > }; >=20 > @@ -512,6 +514,98 @@ struct field_modify_info modify_tcp[] =3D { > } >=20 > /** > + * Convert modify-header increment/decrement TCP Sequence number > + * to DV specification. > + * > + * @param[in,out] resource > + * Pointer to the modify-header resource. > + * @param[in] action > + * Pointer to action specification. > + * @param[out] error > + * Pointer to the error structure. > + * > + * @return > + * 0 on success, a negative errno value otherwise and rte_errno is set= . > + */ > +static int > +flow_dv_convert_action_modify_tcp_seq > + (struct mlx5_flow_dv_modify_hdr_resource *resource, > + const struct rte_flow_action *action, > + struct rte_flow_error *error) > +{ > + const struct rte_flow_action_modify_tcp_seq *conf =3D > + (const struct rte_flow_action_modify_tcp_seq *)(action->conf); > + uint64_t value =3D rte_be_to_cpu_32(conf->value); > + struct rte_flow_item item; > + struct rte_flow_item_tcp tcp; > + struct rte_flow_item_tcp tcp_mask; > + > + memset(&tcp, 0, sizeof(tcp)); > + memset(&tcp_mask, 0, sizeof(tcp_mask)); > + if (action->type =3D=3D RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ) > + /* > + * The HW has no decrement operation, only increment > operation. > + * To simulate decrement X from Y using increment operation > + * we need to add UINT32_MAX X times to Y. > + * Each adding of UINT32_MAX decrements Y by 1. > + */ > + value *=3D UINT32_MAX; > + tcp.hdr.sent_seq =3D rte_cpu_to_be_32((uint32_t)value); > + tcp_mask.hdr.sent_seq =3D RTE_BE32(UINT32_MAX); > + item.type =3D RTE_FLOW_ITEM_TYPE_TCP; > + item.spec =3D &tcp; > + item.mask =3D &tcp_mask; > + return flow_dv_convert_modify_action(&item, modify_tcp, resource, > + MLX5_MODIFICATION_TYPE_ADD, > error); > +} > + > +/** > + * Convert modify-header increment/decrement TCP Acknowledgment > number > + * to DV specification. > + * > + * @param[in,out] resource > + * Pointer to the modify-header resource. > + * @param[in] action > + * Pointer to action specification. > + * @param[out] error > + * Pointer to the error structure. > + * > + * @return > + * 0 on success, a negative errno value otherwise and rte_errno is set= . > + */ > +static int > +flow_dv_convert_action_modify_tcp_ack > + (struct mlx5_flow_dv_modify_hdr_resource *resource, > + const struct rte_flow_action *action, > + struct rte_flow_error *error) > +{ > + const struct rte_flow_action_modify_tcp_ack *conf =3D > + (const struct rte_flow_action_modify_tcp_ack *)(action->conf); > + uint64_t value =3D rte_be_to_cpu_32(conf->value); > + struct rte_flow_item item; > + struct rte_flow_item_tcp tcp; > + struct rte_flow_item_tcp tcp_mask; > + > + memset(&tcp, 0, sizeof(tcp)); > + memset(&tcp_mask, 0, sizeof(tcp_mask)); > + if (action->type =3D=3D RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK) > + /* > + * The HW has no decrement operation, only increment > operation. > + * To simulate decrement X from Y using increment operation > + * we need to add UINT32_MAX X times to Y. > + * Each adding of UINT32_MAX decrements Y by 1. > + */ > + value *=3D UINT32_MAX; > + tcp.hdr.recv_ack =3D rte_cpu_to_be_32((uint32_t)value); > + tcp_mask.hdr.recv_ack =3D RTE_BE32(UINT32_MAX); > + item.type =3D RTE_FLOW_ITEM_TYPE_TCP; > + item.spec =3D &tcp; > + item.mask =3D &tcp_mask; > + return flow_dv_convert_modify_action(&item, modify_tcp, resource, > + MLX5_MODIFICATION_TYPE_ADD, > error); > +} > + > +/** > * Validate META item. > * > * @param[in] dev > @@ -1385,6 +1479,96 @@ struct field_modify_info modify_tcp[] =3D { > } >=20 > /** > + * Validate the modify-header actions of increment/decrement > + * TCP Sequence-number. > + * > + * @param[in] action_flags > + * Holds the actions detected until now. > + * @param[in] action > + * Pointer to the modify action. > + * @param[in] item_flags > + * Holds the items detected. > + * @param[out] error > + * Pointer to error structure. > + * > + * @return > + * 0 on success, a negative errno value otherwise and rte_errno is set= . > + */ > +static int > +flow_dv_validate_action_modify_tcp_seq(const uint64_t action_flags, > + const struct rte_flow_action *action, > + const uint64_t item_flags, > + struct rte_flow_error *error) > +{ > + int ret =3D 0; > + > + ret =3D flow_dv_validate_action_modify_hdr(action_flags, action, error)= ; > + if (!ret) { > + if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP)) > + return rte_flow_error_set(error, EINVAL, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, "no TCP item in" > + " pattern"); > + if ((action->type =3D=3D RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ > && > + (action_flags & MLX5_FLOW_ACTION_DEC_TCP_SEQ)) > || > + (action->type =3D=3D RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ > && > + (action_flags & MLX5_FLOW_ACTION_INC_TCP_SEQ))) > + return rte_flow_error_set(error, EINVAL, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, > + "cannot decrease and > increase" > + " TCP sequence number" > + " at the same time"); > + } > + return ret; > +} > + > +/** > + * Validate the modify-header actions of increment/decrement > + * TCP Acknowledgment number. > + * > + * @param[in] action_flags > + * Holds the actions detected until now. > + * @param[in] action > + * Pointer to the modify action. > + * @param[in] item_flags > + * Holds the items detected. > + * @param[out] error > + * Pointer to error structure. > + * > + * @return > + * 0 on success, a negative errno value otherwise and rte_errno is set= . > + */ > +static int > +flow_dv_validate_action_modify_tcp_ack(const uint64_t action_flags, > + const struct rte_flow_action *action, > + const uint64_t item_flags, > + struct rte_flow_error *error) > +{ > + int ret =3D 0; > + > + ret =3D flow_dv_validate_action_modify_hdr(action_flags, action, error)= ; > + if (!ret) { > + if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP)) > + return rte_flow_error_set(error, EINVAL, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, "no TCP item in" > + " pattern"); > + if ((action->type =3D=3D RTE_FLOW_ACTION_TYPE_INC_TCP_ACK > && > + (action_flags & MLX5_FLOW_ACTION_DEC_TCP_ACK)) > || > + (action->type =3D=3D RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK > && > + (action_flags & MLX5_FLOW_ACTION_INC_TCP_ACK))) > + return rte_flow_error_set(error, EINVAL, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, > + "cannot decrease and > increase" > + " TCP acknowledgment > number" > + " at the same time"); > + } > + return ret; > +} > + > +/** > * Validate the modify-header TTL actions. > * > * @param[in] action_flags > @@ -1962,6 +2146,40 @@ struct field_modify_info modify_tcp[] =3D { >=20 > MLX5_FLOW_ACTION_SET_TTL : >=20 > MLX5_FLOW_ACTION_DEC_TTL; > break; > + case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ: > + case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ: > + ret =3D flow_dv_validate_action_modify_tcp_seq > + (action_flags, > + actions, > + item_flags, > + error); > + if (ret < 0) > + return ret; > + /* Count all modify-header actions as one action. */ > + if (!(action_flags & > MLX5_FLOW_MODIFY_HDR_ACTIONS)) > + ++actions_n; > + action_flags |=3D actions->type =3D=3D > + > RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ? > + > MLX5_FLOW_ACTION_INC_TCP_SEQ : > + > MLX5_FLOW_ACTION_DEC_TCP_SEQ; > + break; > + case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK: > + case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK: > + ret =3D flow_dv_validate_action_modify_tcp_ack > + (action_flags, > + actions, > + item_flags, > + error); > + if (ret < 0) > + return ret; > + /* Count all modify-header actions as one action. */ > + if (!(action_flags & > MLX5_FLOW_MODIFY_HDR_ACTIONS)) > + ++actions_n; > + action_flags |=3D actions->type =3D=3D > + > RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ? > + > MLX5_FLOW_ACTION_INC_TCP_ACK : > + > MLX5_FLOW_ACTION_DEC_TCP_ACK; > + break; > default: > return rte_flow_error_set(error, ENOTSUP, >=20 > RTE_FLOW_ERROR_TYPE_ACTION, > @@ -3089,6 +3307,27 @@ struct field_modify_info modify_tcp[] =3D { > return -rte_errno; > action_flags |=3D MLX5_FLOW_ACTION_SET_TTL; > break; > + case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ: > + case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ: > + if (flow_dv_convert_action_modify_tcp_seq(&res, > actions, > + error)) > + return -rte_errno; > + action_flags |=3D actions->type =3D=3D > + > RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ? > + MLX5_FLOW_ACTION_INC_TCP_SEQ : > + MLX5_FLOW_ACTION_DEC_TCP_SEQ; > + break; > + > + case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK: > + case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK: > + if (flow_dv_convert_action_modify_tcp_ack(&res, > actions, > + error)) > + return -rte_errno; > + action_flags |=3D actions->type =3D=3D > + > RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ? > + MLX5_FLOW_ACTION_INC_TCP_ACK : > + MLX5_FLOW_ACTION_DEC_TCP_ACK; > + break; > case RTE_FLOW_ACTION_TYPE_END: > actions_end =3D true; > if (action_flags & > MLX5_FLOW_MODIFY_HDR_ACTIONS) { > diff --git a/drivers/net/mlx5/mlx5_prm.h b/drivers/net/mlx5/mlx5_prm.h > index da1219e..d5c5d3c 100644 > --- a/drivers/net/mlx5/mlx5_prm.h > +++ b/drivers/net/mlx5/mlx5_prm.h > @@ -336,6 +336,18 @@ enum mlx5_modification_field { > MLX5_MODI_IN_IPV6_HOPLIMIT, > MLX5_MODI_META_DATA_REG_A, > MLX5_MODI_META_DATA_REG_B =3D 0x50, > + MLX5_MODI_META_REG_C_0, > + MLX5_MODI_META_REG_C_1, > + MLX5_MODI_META_REG_C_2, > + MLX5_MODI_META_REG_C_3, > + MLX5_MODI_META_REG_C_4, > + MLX5_MODI_META_REG_C_5, > + MLX5_MODI_META_REG_C_6, > + MLX5_MODI_META_REG_C_7, > + MLX5_MODI_OUT_TCP_SEQ_NUM, > + MLX5_MODI_IN_TCP_SEQ_NUM, > + MLX5_MODI_OUT_TCP_ACK_NUM, > + MLX5_MODI_IN_TCP_ACK_NUM =3D 0x5C, > }; >=20 > /* Modification sub command. */ > -- > 1.8.3.1 Thanks, Acked-by: Ori Kam