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 AA015A0561; Tue, 21 Apr 2020 09:40:52 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8E4261D8E1; Tue, 21 Apr 2020 09:40:52 +0200 (CEST) Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40059.outbound.protection.outlook.com [40.107.4.59]) by dpdk.org (Postfix) with ESMTP id D6B031C220 for ; Tue, 21 Apr 2020 09:40:51 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OMaF/bvYmiAG52/i191nH2VY0X1OKmYoh2FQA3WAA2mrauWdrk8hYd8jqqX2JBEZLbUq7ebRWRN3tNmYq7FWYslLyGVqtaOtZfnqOuifup8Jb7suR8syBO2E2GG/J7IsZLhxoe2RNuw2AuvnlPDcci9cX8IV78wRGdNP+O5ZxRM3rK0Ex1OXh7b4974e/Hfrk2nM3vrRDx3KRlYMahRBrmYme5KfBADjxvrLc4053z5HJ3CpaaaAW8udqVTGb4w7AowdEBLZVGQKaHmEQEv5Qpc+OrhNOJ/VHzQakLiXt9Clamg0NLWKeUN0n6yg8KKHAskn4smoeKK/+e+zECEejA== 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=bJSfZzjMbasxXx4040lLfm6ANfOe1xXUkQBp3xhYP0I=; b=SwyUmIKeKSRNMPvPI2yZEsxloookm/FNZ0IOpKQMIAoz6tTm4F0raGS/zPg2Suqyfpj3bj6oTBvl3j6vNGGNGiaRKNbeVGfKY5AAH4ud7DdOVHHEzQYsAjnqNTUanr2LQNxxNN6AmHjEnA35l6GVYsGWYIA4rQaIenAHoPkKDqUYjR++d32dza2ks3Gk/mFm+33ykjGnia5DTHApXeSPlFMNq+waf0FhJnpIcWBVrV7bBj+yPrWkvwrBPFbku1fHO711QPA4+c8uekF03cwiCkIpBolWw4nN8+aPqT25sAW7CnxL/ATGT7xCeA90VhraYSh463ACw0wZw8qhSArGEw== 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=bJSfZzjMbasxXx4040lLfm6ANfOe1xXUkQBp3xhYP0I=; b=FNO2KLz36F4fG4T8O/O/nKO+Uy3vWj6fPpejdLXTetfkud9ywb36bMFD9z2RlioT/EG+8zheX++L+ysWgs9lu8Z6Gsv8iiS+F0dJsMuaNph0WqVJouvQrqXP11FgfF4XHb+WDOy9+PCmWuigDR0EIaoqRZZosmc/tJQ1/4BtDT4= Received: from AM4PR05MB3265.eurprd05.prod.outlook.com (2603:10a6:205:8::26) by AM4PR05MB3217.eurprd05.prod.outlook.com (2603:10a6:205:4::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.27; Tue, 21 Apr 2020 07:40:51 +0000 Received: from AM4PR05MB3265.eurprd05.prod.outlook.com ([fe80::bdf0:88a3:3a39:4be4]) by AM4PR05MB3265.eurprd05.prod.outlook.com ([fe80::bdf0:88a3:3a39:4be4%7]) with mapi id 15.20.2921.030; Tue, 21 Apr 2020 07:40:51 +0000 From: Slava Ovsiienko To: Wentao Cui , Matan Azrad , Shahaf Shuler CC: "dev@dpdk.org" Thread-Topic: [PATCH] net/mlx5: optimize memory of mlx5 flow meter Thread-Index: AQHWFr0Jaw7JHgFADU+EgT5425tI76iDMr/w Date: Tue, 21 Apr 2020 07:40:51 +0000 Message-ID: References: <0001-net-mlx5-optimize-memory-of-mlx5-flow-meter.patch> <20200420024002.20601-1-wentaoc@mellanox.com> In-Reply-To: <20200420024002.20601-1-wentaoc@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=viacheslavo@mellanox.com; x-originating-ip: [95.164.10.10] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 79e034bc-a47c-43f7-55af-08d7e5c750c5 x-ms-traffictypediagnostic: AM4PR05MB3217:|AM4PR05MB3217: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6430; x-forefront-prvs: 038002787A x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM4PR05MB3265.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10009020)(4636009)(39860400002)(376002)(136003)(366004)(346002)(396003)(76116006)(66446008)(64756008)(66556008)(66476007)(66946007)(71200400001)(86362001)(110136005)(186003)(316002)(26005)(53546011)(6506007)(7696005)(5660300002)(81156014)(8676002)(8936002)(6636002)(52536014)(9686003)(55016002)(4326008)(33656002)(478600001)(2906002); DIR:OUT; SFP:1101; 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: UmjGcGeQcxD+dYaa76b9J7JcBMbGPZLBN6bUPGdzljoa1hJPK1OzJ7GF/+fsmCe8AAJ3e8GHpW9cHb9vPJnHdGcbUf+yBqf35hS0Qnm0nI4nj+zV95E4HEu9hHYmahI7imNPZKz/etHEMUlpY9eTYVcEpiCuD7O9DK1u/8Fqmc6FU/YX7DeV4gmUFZc5oVU/dm15yiMxYZin9j+wklGiWI/02w66a5zcAEiWV+0O6r8UJIl3p/Jy9shlqW9JIK6171ygpg+DNq4Y2FVH1ci1OmSksJT0CddXZADt8dkb/+cosGOx+/zBjVLPoo+MFg9gudeWojas1T9P7S1xaV8kyeGe93nB1RVuZUn1lP3W0GHmgoe9mm40q4PaWycOb28RvY3dIW2IkIMTSNLT0u5jpcF/TdMqZ8NO6PsgteuZvg3jnIXsgvAITRXK/N8zniYC x-ms-exchange-antispam-messagedata: uBpp0mNZbibRTwFskQYzFRoyWRO3fM+UuRzqTFDqyDYeebQoSFA1+FjAHozbFFtqAWSo9BrJi0+PtqTLh7dCVqsiX5n/oABzUbBWDtgnvkMz0mQzFZJ5LFte7brJhIbQ+xR53J9kS345r4wHg6ZNzg== 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: 79e034bc-a47c-43f7-55af-08d7e5c750c5 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Apr 2020 07:40:51.1247 (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: CM09w2+1DHUYJJ9EJtXh2dBkpdhvSQzfDL83P2BREXhsM0QHpdLGA5OXaeYfgzYi1kgmAWYs3TaJtk+SdTXhKDZnA0D/f/25UdKx3jRE6+4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3217 Subject: Re: [dpdk-dev] [PATCH] net/mlx5: optimize memory of mlx5 flow meter 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" > -----Original Message----- > From: Wentao Cui > Sent: Monday, April 20, 2020 5:40 > To: Matan Azrad ; Shahaf Shuler > ; Slava Ovsiienko > Cc: dev@dpdk.org > Subject: [PATCH] net/mlx5: optimize memory of mlx5 flow meter >=20 > This commit focus on flow meter data structures > optimization: mlx5_flow_meter. >=20 > Optimize memory consumption of flow meter data structure. > Reorganize flow meter data structure,delete unnecessary data fields. >=20 > Signed-off-by: Wentao Cui Acked-by: Viacheslav Ovsiienko > --- > drivers/net/mlx5/mlx5_flow.h | 37 ++++++++++++++++++++++++++---- > drivers/net/mlx5/mlx5_flow_dv.c | 8 +++---- > drivers/net/mlx5/mlx5_flow_meter.c | 26 ++++++++++++--------- > 3 files changed, 52 insertions(+), 19 deletions(-) >=20 > diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h > index d697eba0e9..74017cfa31 100644 > --- a/drivers/net/mlx5/mlx5_flow.h > +++ b/drivers/net/mlx5/mlx5_flow.h > @@ -709,12 +709,41 @@ struct mlx5_flow_meter { > uint32_t idx; /* Index to meter object. */ > uint32_t meter_id; > /**< Meter id. */ > - struct rte_mtr_params params; > - /**< Meter rule parameters. */ > struct mlx5_flow_meter_profile *profile; > /**< Meter profile parameters. */ > - struct rte_flow_attr attr; > - /**< Flow attributes. */ > + > + /** Policer actions (per meter output color). */ > + enum rte_mtr_policer_action action[RTE_COLORS]; > + > + /** Set of stats counters to be enabled. > + * @see enum rte_mtr_stats_type > + */ > + uint64_t stats_mask; > + > + /**< Rule applies to ingress traffic. */ > + uint32_t ingress:1; > + > + /**< Rule applies to egress traffic. */ > + uint32_t egress:1; > + /** > + * Instead of simply matching the properties of traffic as it would > + * appear on a given DPDK port ID, enabling this attribute transfers > + * a flow rule to the lowest possible level of any device endpoints > + * found in the pattern. > + * > + * When supported, this effectively enables an application to > + * re-route traffic not necessarily intended for it (e.g. coming > + * from or addressed to different physical ports, VFs or > + * applications) at the device level. > + * > + * It complements the behavior of some pattern items such as > + * RTE_FLOW_ITEM_TYPE_PHY_PORT and is meaningless without > them. > + * > + * When transferring flow rules, ingress and egress attributes keep > + * their original meaning, as if processing traffic emitted or > + * received by the application. > + */ > + uint32_t transfer:1; > struct mlx5_meter_domains_infos *mfts; > /**< Flow table created for this meter. */ > struct mlx5_flow_policer_stats policer_stats; diff --git > a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c > index cfc911c9ca..b552b0ea7c 100644 > --- a/drivers/net/mlx5/mlx5_flow_dv.c > +++ b/drivers/net/mlx5/mlx5_flow_dv.c > @@ -3707,9 +3707,9 @@ mlx5_flow_validate_action_meter(struct > rte_eth_dev *dev, > return rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > NULL, > "Meter not found"); > - if (fm->ref_cnt && (!(fm->attr.transfer =3D=3D attr->transfer || > - (!fm->attr.ingress && !attr->ingress && attr->egress) || > - (!fm->attr.egress && !attr->egress && attr->ingress)))) > + if (fm->ref_cnt && (!(fm->transfer =3D=3D attr->transfer || > + (!fm->ingress && !attr->ingress && attr->egress) || > + (!fm->egress && !attr->egress && attr->ingress)))) > return rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > NULL, > "Flow attributes are either invalid " > @@ -9008,7 +9008,7 @@ flow_dv_create_policer_forward_rule(struct > mlx5_flow_meter *fm, > rte_col_2_mlx5_col(i), UINT8_MAX); > if (mtb->count_actns[i]) > actions[j++] =3D mtb->count_actns[i]; > - if (fm->params.action[i] =3D=3D MTR_POLICER_ACTION_DROP) > + if (fm->action[i] =3D=3D MTR_POLICER_ACTION_DROP) > actions[j++] =3D mtb->drop_actn; > else > actions[j++] =3D dtb->jump_actn; > diff --git a/drivers/net/mlx5/mlx5_flow_meter.c > b/drivers/net/mlx5/mlx5_flow_meter.c > index b5fbf5d316..08f7dc8d11 100644 > --- a/drivers/net/mlx5/mlx5_flow_meter.c > +++ b/drivers/net/mlx5/mlx5_flow_meter.c > @@ -55,8 +55,8 @@ mlx5_flow_meter_action_create(struct mlx5_priv > *priv, > MLX5_SET(flow_meter_parameters, > attr, ebs_mantissa, srtcm->ebs_mantissa); > mtr_init.next_table =3D > - fm->attr.transfer ? fm->mfts->transfer.tbl->obj : > - fm->attr.egress ? fm->mfts->egress.tbl->obj : > + fm->transfer ? fm->mfts->transfer.tbl->obj : > + fm->egress ? fm->mfts->egress.tbl->obj : > fm->mfts->ingress.tbl->obj; > mtr_init.reg_c_index =3D priv->mtr_color_reg - REG_C_0; > mtr_init.flow_meter_parameter =3D fm->mfts->fmp; @@ -657,7 > +657,9 @@ mlx5_flow_meter_create(struct rte_eth_dev *dev, uint32_t > meter_id, > /* Fill the flow meter parameters. */ > fm->meter_id =3D meter_id; > fm->profile =3D fmp; > - fm->params =3D *params; > + memcpy(fm->action, params->action, sizeof(params->action)); > + fm->stats_mask =3D params->stats_mask; > + > /* Alloc policer counters. */ > for (i =3D 0; i < RTE_DIM(fm->policer_stats.cnt); i++) { > fm->policer_stats.cnt[i] =3D mlx5_counter_alloc(dev); @@ - > 1050,7 +1052,7 @@ mlx5_flow_meter_stats_read(struct rte_eth_dev *dev, > &bytes); > if (ret) > goto error; > - if (fm->params.action[i] =3D=3D > MTR_POLICER_ACTION_DROP) { > + if (fm->action[i] =3D=3D MTR_POLICER_ACTION_DROP) { > pkts_dropped +=3D pkts; > bytes_dropped +=3D bytes; > } > @@ -1181,7 +1183,9 @@ mlx5_flow_meter_attach(struct mlx5_priv *priv, > uint32_t meter_id, > } > if (!fm->ref_cnt++) { > MLX5_ASSERT(!fm->mfts->meter_action); > - fm->attr =3D *attr; > + fm->ingress =3D attr->ingress; > + fm->egress =3D attr->egress; > + fm->transfer =3D attr->transfer; > /* This also creates the meter object. */ > fm->mfts->meter_action =3D > mlx5_flow_meter_action_create(priv, > fm); > @@ -1189,9 +1193,9 @@ mlx5_flow_meter_attach(struct mlx5_priv *priv, > uint32_t meter_id, > goto error_detach; > } else { > MLX5_ASSERT(fm->mfts->meter_action); > - if (attr->transfer !=3D fm->attr.transfer || > - attr->ingress !=3D fm->attr.ingress || > - attr->egress !=3D fm->attr.egress) { > + if (attr->transfer !=3D fm->transfer || > + attr->ingress !=3D fm->ingress || > + attr->egress !=3D fm->egress) { > DRV_LOG(ERR, "meter I/O attributes do not " > "match flow I/O attributes."); > goto error_detach; > @@ -1216,15 +1220,15 @@ mlx5_flow_meter_attach(struct mlx5_priv > *priv, uint32_t meter_id, void mlx5_flow_meter_detach(struct > mlx5_flow_meter *fm) { > - const struct rte_flow_attr attr =3D { 0 }; > - > MLX5_ASSERT(fm->ref_cnt); > if (--fm->ref_cnt) > return; > if (fm->mfts->meter_action) > mlx5_glue->destroy_flow_action(fm->mfts->meter_action); > fm->mfts->meter_action =3D NULL; > - fm->attr =3D attr; > + fm->ingress =3D 0; > + fm->egress =3D 0; > + fm->transfer =3D 0; > } >=20 > /** > -- > 2.21.0