From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 44B9DA04F1; Mon, 6 Jan 2020 15:36:57 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 80F6E1D66D; Mon, 6 Jan 2020 15:36:56 +0100 (CET) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130085.outbound.protection.outlook.com [40.107.13.85]) by dpdk.org (Postfix) with ESMTP id 6DC9B1D666 for ; Mon, 6 Jan 2020 15:36:55 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LbLPU+Wq6pNzFEuCgBZ1Qrk8FrpPqdheTTPQQ5yPEljUz9VbOXDjSqgRn/oSXH6Zsupt0eEnbCSzQDF4hsAibZpsyFl5DI6jP0HyKGw5gYHK1XLqZuuIri2uFtLYXKb109si11rNiHJVjn3ZOL30zRVqIHf1AqqUYCsIaJM501VdNtJxnXvL55NNtHjbQhutWH9VYZGA+pFxC8vC9doVjo66boixixH5UFIrUHUWibYzPDrlggRvZfHR+m/7YLeLsacK5N4RZMRQRAyY+Y4gQmLSGWHBwa42XpU7dYk2a14+etxiM+tgg22x+xknX3umjcQxV8euvVrdvQIQA1l6QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oecifWp6+qRGO1bapV64G/xoI8UT2gOJBOHSAs4QD/k=; b=b1hzEaaRGH4xo3W6ZMQ87EL1E/5rsZzQDkXkf++EQRrBHo3BzuDQo8CkoX6+LjuY1AOKpQNDdWsaVVu3H5Tf0FkOunzkY0vKH34Ax+lp6W/lCVG2gnj+XUH/EuiOSxRiWzDZRXrsGHeKiwZP+SUk/VEXWuBcyYXYTMMnw9mpGQv7JoK7cDu5PrlkEn/f+54DMJLRE4UCikayLEFlSGpqWLhSHANpPdqLdNyAbtXZPHPoVL2jkZ4Wh4zYZq9fFOQP1pMNhwg9+PyAQnZ/BjncY8BcYLWagpRgdnqBA0FVrJo8aM8ejz5WI758rtYWwgxWwxAJKi1C/WxxX4zMydnQpA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none 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=oecifWp6+qRGO1bapV64G/xoI8UT2gOJBOHSAs4QD/k=; b=qz7mj8GNfcjk9anl5CWogI8B8uvB9JqF2O6PeBRKO3rkcIhdwH5PopQLDVWv5gO98nJUoBFiT/N9omSzhcvbm+vPAJJi2oyhDWN3AXTnhYy2K6uYO5Tsmtgfh/GierCr7Nw2wIFv7/+41sUugvwO7BNVSWQGmlcRksA4p2Wph1M= Received: from AM0PR0502MB4019.eurprd05.prod.outlook.com (52.133.39.139) by AM0PR0502MB3811.eurprd05.prod.outlook.com (52.133.50.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.12; Mon, 6 Jan 2020 14:36:52 +0000 Received: from AM0PR0502MB4019.eurprd05.prod.outlook.com ([fe80::e495:9258:db09:1de8]) by AM0PR0502MB4019.eurprd05.prod.outlook.com ([fe80::e495:9258:db09:1de8%7]) with mapi id 15.20.2602.015; Mon, 6 Jan 2020 14:36:52 +0000 From: Matan Azrad To: Suanming Mou , Shahaf Shuler , Slava Ovsiienko CC: "dev@dpdk.org" , Ori Kam , "arybchenko@solarflare.com" , "ferruh.yigit@intel.com" , Thomas Monjalon Thread-Topic: [PATCH 2/2] net/mlx5: add IPv4/IPv6 DSCP rewrite action Thread-Index: AQHVwTJ656IIrQBQtEac38E8jek5fafdtc+w Date: Mon, 6 Jan 2020 14:36:52 +0000 Message-ID: References: <1577945052-39548-1-git-send-email-suanmingm@mellanox.com> <1577945052-39548-3-git-send-email-suanmingm@mellanox.com> In-Reply-To: <1577945052-39548-3-git-send-email-suanmingm@mellanox.com> Accept-Language: en-US, he-IL Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 1e9cdd10-2ee1-47cb-058e-08d792b5deff x-ms-traffictypediagnostic: AM0PR0502MB3811:|AM0PR0502MB3811: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6790; x-forefront-prvs: 0274272F87 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(346002)(136003)(366004)(376002)(396003)(199004)(189003)(478600001)(316002)(76116006)(55016002)(4326008)(9686003)(33656002)(71200400001)(2906002)(66946007)(7696005)(6506007)(6636002)(5660300002)(81156014)(8936002)(8676002)(81166006)(86362001)(66556008)(64756008)(66476007)(54906003)(110136005)(52536014)(66446008)(186003)(26005); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR0502MB3811; H:AM0PR0502MB4019.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: BCL:0; x-microsoft-antispam-message-info: mxyJfPoAzdA2oo4vpS9ctO5XiOWw9VNCFJ11O/BrmeWwDJyzfVTYDFFYDSbsruUacf1sygf5CHYK+pxbg7WcMJZn7ilfSaxn7Jj2ReDajx78y2/LFDVqHjnEfFhJAUFp4Gftpo4POoT7Mz5ddfhHJTQw3W8kGkKksnqjYyVqDSDu+FjFbybnmvikyHFnWWhJtmspjMLdwXYYX/1m29FCyVccrrXt7x1Scd+HH1BclvbClrnt7ovnxFNHrWbsVCCxMy65xf71gZA/h0Scn8qCeptz+TMNIZFuWxd547T5wKNtAAVYSScmEylMWBZs4ZtrgSqYtkvwXcB51phXD4UUU9bWXBBwuJ/mRV8nmbGctVB4ft2Nc/iQFqyAlxMzag2zpbPIw9rWhwjQFFX2QtYFloktH/d7fmPKxFcxSlQu8GThwPTL0mAgkLapcAMxToj2 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: 1e9cdd10-2ee1-47cb-058e-08d792b5deff X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jan 2020 14:36:52.3156 (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-CrossTenant-userprincipalname: uMK59BLOGfRtF0xNSPzr0XzsXjc04XPVysbaGOk6QjtLAHpTjqLIQoI8jl3rejc3M/8yoNsryC/65Qg56XMODQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0502MB3811 Subject: Re: [dpdk-dev] [PATCH 2/2] net/mlx5: add IPv4/IPv6 DSCP rewrite action 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" Hi From: Suanming Mou > This commit add the IPv4/IPv6 DSCP rewrite actions to the PMD code. >=20 > Supported actions: > RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP > RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP >=20 > Signed-off-by: Suanming Mou > --- > drivers/net/mlx5/mlx5_flow.h | 6 +- > drivers/net/mlx5/mlx5_flow_dv.c | 184 > ++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 189 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h > index 27d82ac..e42c98a 100644 > --- a/drivers/net/mlx5/mlx5_flow.h > +++ b/drivers/net/mlx5/mlx5_flow.h > @@ -196,6 +196,8 @@ enum mlx5_feature_name { #define > MLX5_FLOW_ACTION_MARK_EXT (1ull << 33) #define > MLX5_FLOW_ACTION_SET_META (1ull << 34) #define > MLX5_FLOW_ACTION_METER (1ull << 35) > +#define MLX5_FLOW_ACTION_SET_IPV4_DSCP (1ull << 36) #define > +MLX5_FLOW_ACTION_SET_IPV6_DSCP (1ull << 37) >=20 > #define MLX5_FLOW_FATE_ACTIONS \ > (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | \ > @@ -232,7 +234,9 @@ enum mlx5_feature_name { > MLX5_FLOW_ACTION_OF_SET_VLAN_VID > | \ > MLX5_FLOW_ACTION_SET_TAG | \ > MLX5_FLOW_ACTION_MARK_EXT | \ > - MLX5_FLOW_ACTION_SET_META) > + MLX5_FLOW_ACTION_SET_META | \ > + MLX5_FLOW_ACTION_SET_IPV4_DSCP | \ > + MLX5_FLOW_ACTION_SET_IPV6_DSCP) I don't think DSCP set is a reg feature... please check... > #define MLX5_FLOW_VLAN_ACTIONS > (MLX5_FLOW_ACTION_OF_POP_VLAN | \ > MLX5_FLOW_ACTION_OF_PUSH_VLAN) > diff --git a/drivers/net/mlx5/mlx5_flow_dv.c > b/drivers/net/mlx5/mlx5_flow_dv.c index 4c16281..15fe726 100644 > --- a/drivers/net/mlx5/mlx5_flow_dv.c > +++ b/drivers/net/mlx5/mlx5_flow_dv.c > @@ -157,6 +157,7 @@ struct field_modify_info modify_vlan_out_first_vid[] > =3D { }; >=20 > struct field_modify_info modify_ipv4[] =3D { > + {1, 1, MLX5_MODI_OUT_IP_DSCP}, > {1, 8, MLX5_MODI_OUT_IPV4_TTL}, > {4, 12, MLX5_MODI_OUT_SIPV4}, > {4, 16, MLX5_MODI_OUT_DIPV4}, > @@ -164,6 +165,7 @@ struct field_modify_info modify_ipv4[] =3D { }; >=20 > struct field_modify_info modify_ipv6[] =3D { > + {1, 0, MLX5_MODI_OUT_IP_DSCP}, > {1, 7, MLX5_MODI_OUT_IPV6_HOPLIMIT}, > {4, 8, MLX5_MODI_OUT_SIPV6_127_96}, > {4, 12, MLX5_MODI_OUT_SIPV6_95_64}, > @@ -1191,6 +1193,82 @@ struct field_modify_info modify_tcp[] =3D { } >=20 > /** > + * Convert modify-header set IPv4 DSCP action 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_ipv4_dscp > + (struct mlx5_flow_dv_modify_hdr_resource > *resource, > + const struct rte_flow_action *action, > + struct rte_flow_error *error) > +{ > + const struct rte_flow_action_set_dscp *conf =3D > + (const struct rte_flow_action_set_dscp *)(action->conf); > + struct rte_flow_item item =3D { .type =3D RTE_FLOW_ITEM_TYPE_IPV4 }; > + struct rte_flow_item_ipv4 ipv4; > + struct rte_flow_item_ipv4 ipv4_mask; > + > + memset(&ipv4, 0, sizeof(ipv4)); > + memset(&ipv4_mask, 0, sizeof(ipv4_mask)); > + ipv4.hdr.type_of_service =3D conf->dscp; > + ipv4_mask.hdr.type_of_service =3D 0x3f; Please use RTE_IPV4_HDR_DSCP_MASK. > + item.spec =3D &ipv4; > + item.mask =3D &ipv4_mask; > + return flow_dv_convert_modify_action(&item, modify_ipv4, NULL, > resource, > + MLX5_MODIFICATION_TYPE_SET, > error); } > + > +/** > + * Convert modify-header set IPv6 DSCP action 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_ipv6_dscp > + (struct mlx5_flow_dv_modify_hdr_resource > *resource, > + const struct rte_flow_action *action, > + struct rte_flow_error *error) > +{ > + const struct rte_flow_action_set_dscp *conf =3D > + (const struct rte_flow_action_set_dscp *)(action->conf); > + struct rte_flow_item item =3D { .type =3D RTE_FLOW_ITEM_TYPE_IPV6 }; > + struct rte_flow_item_ipv6 ipv6; > + struct rte_flow_item_ipv6 ipv6_mask; > + > + memset(&ipv6, 0, sizeof(ipv6)); > + memset(&ipv6_mask, 0, sizeof(ipv6_mask)); > + /* > + * Even though the DSCP bits offset of IPv6 is not byte aligned, > + * rdma-core only accept the DSCP bits byte aligned start from > + * bit 0 to 5 as to be compatible with IPv4. No need to shift the > + * bits in IPv6 case as rdma-core requires byte aligned value. > + */ > + ipv6.hdr.vtc_flow =3D conf->dscp; > + ipv6_mask.hdr.vtc_flow =3D 0x3f; Please use RTE_IPV6_HDR_DSCP_MASK. > + item.spec =3D &ipv6; > + item.mask =3D &ipv6_mask; > + return flow_dv_convert_modify_action(&item, modify_ipv6, NULL, > resource, > + MLX5_MODIFICATION_TYPE_SET, > error); } > + > +/** > * Validate MARK item. > * > * @param[in] dev > @@ -3433,6 +3511,74 @@ struct field_modify_info modify_tcp[] =3D { } >=20 > /** > + * Validate the modify-header IPv4 DSCP actions. > + * > + * @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_ipv4_dscp(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_L3_IPV4)) > + return rte_flow_error_set(error, EINVAL, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, > + "no ipv4 item in pattern"); > + } > + return ret; > +} > + > +/** > + * Validate the modify-header IPv6 DSCP actions. > + * > + * @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_ipv6_dscp(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_L3_IPV6)) > + return rte_flow_error_set(error, EINVAL, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, > + "no ipv6 item in pattern"); > + } > + return ret; > +} > + > +/** > * Find existing modify-header resource or create and register a new one= . > * > * @param dev[in, out] > @@ -4806,6 +4952,32 @@ struct field_modify_info modify_tcp[] =3D { > action_flags |=3D MLX5_FLOW_ACTION_METER; > ++actions_n; > break; > + case RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP: > + ret =3D flow_dv_validate_action_modify_ipv4_dscp > + (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 > MLX5_FLOW_ACTION_SET_IPV4_DSCP; > + break; > + case RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP: > + ret =3D flow_dv_validate_action_modify_ipv6_dscp > + (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 > MLX5_FLOW_ACTION_SET_IPV6_DSCP; > + break; > default: > return rte_flow_error_set(error, ENOTSUP, >=20 > RTE_FLOW_ERROR_TYPE_ACTION, > @@ -7101,6 +7273,18 @@ struct field_modify_info modify_tcp[] =3D { > flow->meter->mfts->meter_action; > action_flags |=3D MLX5_FLOW_ACTION_METER; > break; > + case RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP: > + if > (flow_dv_convert_action_modify_ipv4_dscp(&mhdr_res, > + actions, error)) > + return -rte_errno; > + action_flags |=3D > MLX5_FLOW_ACTION_SET_IPV4_DSCP; > + break; > + case RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP: > + if > (flow_dv_convert_action_modify_ipv6_dscp(&mhdr_res, > + actions, error)) > + return -rte_errno; > + action_flags |=3D > MLX5_FLOW_ACTION_SET_IPV6_DSCP; > + break; > case RTE_FLOW_ACTION_TYPE_END: > actions_end =3D true; > if (mhdr_res.actions_num) { > -- > 1.8.3.1