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 2F60BA0527; Tue, 30 Jun 2020 19:59:34 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D1B521BF68; Tue, 30 Jun 2020 19:59:33 +0200 (CEST) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60048.outbound.protection.outlook.com [40.107.6.48]) by dpdk.org (Postfix) with ESMTP id 0652D1BEDD for ; Tue, 30 Jun 2020 19:59:33 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YsCnDVEUnFq4RVNPD3D2P15eswTTUjX3CAh+aiwSf37CDu/EHpb82iB4ZNhHGg7ofKvlb+36gX4tDMjiSe7pytOrKuD8RR0u7ndQYwhmuUIKItYL6VwUmnH8UdmMyloLDCnO7hvmSDocbV03qxNEYd8LkiCK257dRObtathzsrisbftPtH60XAA1Ci4R5TnHB/QutxKAd6Xolcp9HPaDlRNWtOW02jF+AUQzScDdm5IE/gX/F90HCBPcM5JIU6dY2mwIRLvEoO30SMMRi0JJmJoZI/Kqz9vIJHZqEHo34+JjljKFzjtbEDXxJAfUoUwxWy/mOC+t2A/uHsvYJcDG2g== 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=g4UJivJL7Qx/jC8D83s+DzYtUJQhEwDozq2LCRMUCko=; b=XNuHG1g8IUbg4eJa7A/y1xht4xwa9x0dWAyI0wA5x/VetR/zEq8eAnoceglcrRj3DROC/SnvlXElwudj5pl6PzkBZkACptFfmBgfsRiSsPqHyxfz+ifgye0BLgZoiMx9nPpzBUZ3wkIRBcDydW+eL7gx3Lh9fg+v0luZl0YBm3NDpbE3U9CBuYpP+crAqCNHOQK/F+G845ljwMVpWjP5FpYrXqFuEEkZwUYixJFqfZ7ivcb5eitSQtNSrZElo81Fi8omlwcMqcRJVPJgB1J/vErGvikzxxEIRUfR18x77uQLKbjUJJrHqZacMELpPnp8o3dCuFCRf25XomjgdO9sQA== 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=g4UJivJL7Qx/jC8D83s+DzYtUJQhEwDozq2LCRMUCko=; b=HnTeMuUl/sh/t1n3mHPtsW8yenlxP/Xr59xxPCUGvjjnXzdtcYI6dyYuBoWGk7EpnSLVynD8ulhwnHrIue7NYNTN94TdeO9bDmQmXgRfJR9/sw6DF9hr7I9RAucsqTwj0ex8TEeRpJpQeIxQVjqDKdIa0hHTjzyUp3HwbLp/q7c= Received: from AM6PR05MB5176.eurprd05.prod.outlook.com (2603:10a6:20b:63::30) by AM5PR0501MB2531.eurprd05.prod.outlook.com (2603:10a6:203:d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.20; Tue, 30 Jun 2020 17:59:32 +0000 Received: from AM6PR05MB5176.eurprd05.prod.outlook.com ([fe80::9024:accb:4d6b:805f]) by AM6PR05MB5176.eurprd05.prod.outlook.com ([fe80::9024:accb:4d6b:805f%3]) with mapi id 15.20.3131.027; Tue, 30 Jun 2020 17:59:31 +0000 From: Ori Kam To: "Jiawei(Jonny) Wang" , Slava Ovsiienko , Matan Azrad CC: "dev@dpdk.org" , Thomas Monjalon , Raslan Darawsheh , "ian.stokes@intel.com" , "fbl@redhat.com" , "Jiawei(Jonny) Wang" Thread-Topic: [PATCH 4/8] net/mlx5: add the validate sample action Thread-Index: AQHWSxDDi5sBIIqMHkGW9jVdCvbSY6jxS/tA Date: Tue, 30 Jun 2020 17:59:31 +0000 Message-ID: References: <1593102379-400132-1-git-send-email-jiaweiw@mellanox.com> <1593102379-400132-5-git-send-email-jiaweiw@mellanox.com> In-Reply-To: <1593102379-400132-5-git-send-email-jiaweiw@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: mellanox.com; dkim=none (message not signed) header.d=none;mellanox.com; dmarc=none action=none header.from=mellanox.com; x-originating-ip: [147.236.152.129] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 3e0f994c-9365-4207-2ca3-08d81d1f575e x-ms-traffictypediagnostic: AM5PR0501MB2531: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtFwd,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-forefront-prvs: 0450A714CB x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: xhNcz2FsKEjgyL7nzrWtRdGply9dLkAc+yH41LrRFJ2gm7mAck/U7Bzfqdg2ckwIqmUGHZA6ZMpcYoTICfLOGbzTR0fKf5FBx/ExN3Oe3ep5Xn58wXuVBx4Du+vYaG25RmE0gKBbQqL5WTSGG/NeFkcrZ23cvVx2vuCbNwnCP3yuZIUiZ9tCqPbCtnkXRw5B6biitHNzrnU1ZQm3L52368Bd7mF/0DPZGBeNVUsXxZralw67/UqMR5L0wjwWvYlF8m4ug93pLNQk4HMknPSnb9Oxv/k+dvt8Tk3x/TbKdoMMgjNInOmiOCzTQUZ82BHkhulfdfk+zlqlEZg03Db/+w== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR05MB5176.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(376002)(346002)(136003)(39860400002)(396003)(366004)(5660300002)(55016002)(52536014)(6506007)(9686003)(7696005)(53546011)(4326008)(86362001)(107886003)(186003)(26005)(15650500001)(33656002)(8936002)(8676002)(478600001)(66476007)(66556008)(64756008)(66446008)(316002)(66946007)(110136005)(76116006)(54906003)(6636002)(2906002)(71200400001)(83380400001); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: ZNO0I6irq4/PeLF4gHy6MMeAQuQHOdH5uz/98a4SzYublbWEmJcEF0w3/70GdoESgGXwG4D7SsYLR3Z9zgDwopJT74MflLI5R489UIccEywewR0KHQhu0fhp9sLTfQI/utznYSt3mOFLC8b9s+dQUQ0RRcWokvQTOzy6whzXJM11uM03zfOxTQH2KudZDJ+rT70AdBUR0rTltYvL4wR/oYfWNPF6XRAhoQJ9S3B1OrLv2zzzaAXJ+/d5In9UESU0Upw628kkfh/PKdAXYlwdReisPUB3i5OXrQicX6IuVqvEVf1eXTNka+WxFC7XGDONeOvM+IwSspTU7rLWVNIRgiZml7/HVDcPQ1yTOKyOETmt871cXMGBZEJP5qcmDRHe011noNK2MQEzYjoYSx0e4tWwHlK8BTFYaRSYKGwMrRKzXroR6HfV69Lrgh4P4esq82AaGwBerzzm7c3mbv0HJ4YeMTYzuzWPFcbIkETNDLc8xIxKuq40GkZ60f0EKkvY Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM6PR05MB5176.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3e0f994c-9365-4207-2ca3-08d81d1f575e X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Jun 2020 17:59:31.7907 (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: PLVHY+Fr6Dwzz8XzcqO/jfVynwXMQYTxewRAM+Nb7iey8OprCj0suVnqwAX+s49ZGn0Vx6m59cQs/1/rVGWwaA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0501MB2531 Subject: Re: [dpdk-dev] [PATCH 4/8] net/mlx5: add the validate sample 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 Jiawei, PSB. Best, Ori > -----Original Message----- > From: Jiawei Wang > Sent: Thursday, June 25, 2020 7:26 PM > Subject: [PATCH 4/8] net/mlx5: add the validate sample action >=20 > Add sample action validate function. >=20 > For Sample flow support NIC-RX and FDB domain, must include an > action of a dest TIR in NIC_RX or DEFAULT_MISS in FDB. What is the DEFAULT_MISS action? I think from reading the code that you mean that no action is allowed and i= t is=20 always goes to e-switch manager / go to PF, am I correct? >=20 > Only NIC_RX support with addition optinal actions. >=20 > Signed-off-by: Jiawei Wang > --- > drivers/net/mlx5/linux/mlx5_os.c | 14 +++++ > drivers/net/mlx5/mlx5.h | 1 + > drivers/net/mlx5/mlx5_flow.h | 1 + > drivers/net/mlx5/mlx5_flow_dv.c | 130 > +++++++++++++++++++++++++++++++++++++++ > 4 files changed, 146 insertions(+) >=20 > diff --git a/drivers/net/mlx5/linux/mlx5_os.c > b/drivers/net/mlx5/linux/mlx5_os.c > index f0147e6..5c057d3 100644 > --- a/drivers/net/mlx5/linux/mlx5_os.c > +++ b/drivers/net/mlx5/linux/mlx5_os.c > @@ -878,6 +878,20 @@ > } > } > #endif > +#if defined(HAVE_MLX5DV_DR) && > defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_SAMPLE) > + if (config.hca_attr.log_max_ft_sampler_num > 0 && > + config.dv_flow_en) { > + priv->sampler_en =3D 1; > + DRV_LOG(DEBUG, "The Sampler enabled!\n"); > + } else { > + priv->sampler_en =3D 0; > + if (!config.hca_attr.log_max_ft_sampler_num) > + DRV_LOG(WARNING, "No available register > for" > + " Sampler."); > + else > + DRV_LOG(DEBUG, "DV flow is not > supported!\n"); > + } > +#endif > } > if (config.mprq.enabled && mprq) { > if (config.mprq.stride_num_n && > diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h > index 8a09ebc..c2a875c 100644 > --- a/drivers/net/mlx5/mlx5.h > +++ b/drivers/net/mlx5/mlx5.h > @@ -607,6 +607,7 @@ struct mlx5_priv { > unsigned int counter_fallback:1; /* Use counter fallback management. > */ > unsigned int mtr_en:1; /* Whether support meter. */ > unsigned int mtr_reg_share:1; /* Whether support meter REG_C share. > */ > + unsigned int sampler_en:1; /* Whether support sampler. */ > uint16_t domain_id; /* Switch domain identifier. */ > uint16_t vport_id; /* Associated VF vport index (if any). */ > uint32_t vport_meta_tag; /* Used for vport index match ove VF LAG. */ > diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h > index 2c96677..902380b 100644 > --- a/drivers/net/mlx5/mlx5_flow.h > +++ b/drivers/net/mlx5/mlx5_flow.h > @@ -200,6 +200,7 @@ enum mlx5_feature_name { > #define MLX5_FLOW_ACTION_SET_IPV4_DSCP (1ull << 32) > #define MLX5_FLOW_ACTION_SET_IPV6_DSCP (1ull << 33) > #define MLX5_FLOW_ACTION_AGE (1ull << 34) > +#define MLX5_FLOW_ACTION_SAMPLE (1ull << 35) >=20 > #define MLX5_FLOW_FATE_ACTIONS \ > (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | \ > diff --git a/drivers/net/mlx5/mlx5_flow_dv.c > b/drivers/net/mlx5/mlx5_flow_dv.c > index f174009..710c0f3 100644 > --- a/drivers/net/mlx5/mlx5_flow_dv.c > +++ b/drivers/net/mlx5/mlx5_flow_dv.c > @@ -3925,6 +3925,127 @@ struct field_modify_info modify_tcp[] =3D { > } >=20 > /** > + * Validate the sample action. > + * > + * @param[in] action_flags > + * Holds the actions detected until now. > + * @param[in] action > + * Pointer to the sample action. > + * @param[in] dev > + * Pointer to the Ethernet device structure. > + * @param[in] attr > + * Attributes of flow that includes this action. > + * @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_sample(uint64_t action_flags, > + const struct rte_flow_action *action, > + struct rte_eth_dev *dev, > + const struct rte_flow_attr *attr, > + struct rte_flow_error *error) > +{ > + struct mlx5_priv *priv =3D dev->data->dev_private; > + struct mlx5_dev_config *dev_conf =3D &priv->config; > + const struct rte_flow_action_sample *sample =3D action->conf; > + const struct rte_flow_action *act =3D sample->actions; > + uint64_t sub_action_flags =3D 0; > + int actions_n =3D 0; > + int ret; > + > + if (!attr->group) > + return rte_flow_error_set(error, ENOTSUP, > + > RTE_FLOW_ERROR_TYPE_ATTR_GROUP, > + NULL, "root table is not supported"); > + if (!priv->config.devx || !priv->sampler_en) > + return rte_flow_error_set(error, ENOTSUP, > + > RTE_FLOW_ERROR_TYPE_UNSPECIFIED, > + NULL, > + "sample action not supported"); > + if (!(action->conf)) > + return rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ACTION, > action, > + "configuration cannot be null"); > + if (sample->ratio =3D=3D 0) > + return rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ACTION, > action, > + "ratio value start from 1"); > + if (action_flags & MLX5_FLOW_ACTION_SAMPLE) > + return rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ACTION, > NULL, > + "Duplicate sample actions set"); > + if (action_flags & MLX5_FLOW_ACTION_METER) > + return rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ACTION, > action, > + "wrong action order, meter should " > + "be after sample action"); > + for (; act->type !=3D RTE_FLOW_ACTION_TYPE_END; act++) { > + if (actions_n =3D=3D MLX5_DV_MAX_NUMBER_OF_ACTIONS) > + return rte_flow_error_set(error, ENOTSUP, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + act, "too many actions"); > + switch (act->type) { > + case RTE_FLOW_ACTION_TYPE_QUEUE: > + ret =3D mlx5_flow_validate_action_queue(act, > + sub_action_flags, > + dev, > + attr, error); > + if (ret < 0) > + return ret; > + sub_action_flags |=3D MLX5_FLOW_ACTION_QUEUE; > + break; > + case RTE_FLOW_ACTION_TYPE_MARK: > + ret =3D flow_dv_validate_action_mark(dev, act, > + sub_action_flags, > + attr, error); > + if (ret < 0) > + return ret; > + if (dev_conf->dv_xmeta_en !=3D > MLX5_XMETA_MODE_LEGACY) > + sub_action_flags |=3D > MLX5_FLOW_ACTION_MARK | > + > MLX5_FLOW_ACTION_MARK_EXT; > + else > + sub_action_flags |=3D > MLX5_FLOW_ACTION_MARK; > + break; > + case RTE_FLOW_ACTION_TYPE_COUNT: > + ret =3D flow_dv_validate_action_count(dev, error); > + if (ret < 0) > + return ret; > + sub_action_flags |=3D MLX5_FLOW_ACTION_COUNT; > + break; > + default: > + return rte_flow_error_set(error, ENOTSUP, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, > + "Doesn't support optional " > + "action"); > + } > + } > + if (attr->ingress && !attr->transfer) { > + if (!(sub_action_flags & MLX5_FLOW_ACTION_QUEUE)) > + return rte_flow_error_set(error, EINVAL, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, > + "Ingress must has a dest " > + "QUEUE for Sample"); > + } else if (attr->egress && !attr->transfer) { > + return rte_flow_error_set(error, ENOTSUP, > + RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, > + "Sample Only support Ingress " > + "or E-Switch"); > + } else if (sample->actions->type !=3D RTE_FLOW_ACTION_TYPE_END) { > + return rte_flow_error_set(error, ENOTSUP, > + RTE_FLOW_ERROR_TYPE_ACTION, > NULL, > + "E-Switch doesn't support any " > + "optinal action for sampling"); > + } > + return 0; > +} > + > +/** > * Find existing modify-header resource or create and register a new one= . > * > * @param dev[in, out] > @@ -5539,6 +5660,15 @@ struct field_modify_info modify_tcp[] =3D { > action_flags |=3D MLX5_FLOW_ACTION_SET_IPV6_DSCP; > rw_act_num +=3D MLX5_ACT_NUM_SET_DSCP; > break; > + case RTE_FLOW_ACTION_TYPE_SAMPLE: > + ret =3D flow_dv_validate_action_sample(action_flags, > + actions, dev, > + attr, error); > + if (ret < 0) > + return ret; > + action_flags |=3D MLX5_FLOW_ACTION_SAMPLE; > + ++actions_n; > + break; > default: > return rte_flow_error_set(error, ENOTSUP, >=20 > RTE_FLOW_ERROR_TYPE_ACTION, > -- > 1.8.3.1