From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20045.outbound.protection.outlook.com [40.107.2.45]) by dpdk.org (Postfix) with ESMTP id 868132C2F for ; Thu, 25 Oct 2018 08:24:01 +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=sU/t5Xxn48p8IOh9sy3VJm6CSb9LU2hHw8bWCYyEpKY=; b=aDH1obMkVH350ch+RtaTjiFUdVY24q6tIAwoDQ0zIEJVfW5hXFlBv1Dnno6rTMdKOmZ7S6tmEB/9cogptnSNIUDw4n061PhT4FMkavr0DHsUikNtgOCLIX5R2ECEbjEdK8pJYIMAZixey5Ydq/f12PCPTnLkqew9cVuYSB0xd2c= Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com (52.134.72.27) by DB3PR0502MB3978.eurprd05.prod.outlook.com (52.134.65.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1273.21; Thu, 25 Oct 2018 06:24:00 +0000 Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::f8a1:fcab:94f0:97cc]) by DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::f8a1:fcab:94f0:97cc%4]) with mapi id 15.20.1273.021; Thu, 25 Oct 2018 06:24:00 +0000 From: Yongseok Koh To: Shahaf Shuler CC: "dev@dpdk.org" , Yongseok Koh Thread-Topic: [PATCH] net/mlx5: add 128B padding of Rx completion entry Thread-Index: AQHUbCtR4rz5iE2dJkCT/GSNE39qEA== Date: Thu, 25 Oct 2018 06:24:00 +0000 Message-ID: <20181025062351.10135-1-yskoh@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR07CA0060.namprd07.prod.outlook.com (2603:10b6:a03:60::37) 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; DB3PR0502MB3978; 6:TauKxAf2/heibwl7kacjyRFA3lzPoMJRlDj+uOyjbeTqcJibXuL7d95JSAxu7OacJuIBxveETPLNLrCdURDbNEe2dQ4RBP1rY+tF42TUDb48aIXGk1qRycnpZPvXhUYB6JQ9SAvcgL4AkN3rxLz7yTEnehA37IQfdacQ+/egmyzdFq4h80KLpGmDI6nRzfp5Lb8wUsycfzKQ03d3XnQbNr6QDScZ2hkcMVMyqU71XgaXJQC5YkjH0uJPIAErJoTDf0V0O0IVF5hCm1zb+XHvHBhjpN4RVJrs3xxoYfeX6bwZHZkdzyix57JvSqNdVcgvPpi5KZTpHQkEYjBj6f2dWM79PQJEbLJ+uZ8p95hZOsrruVZC2FYFACII+vCdYP1UgyQ5rmxhihlgN+1DCRjVhVhQoFYE6MNIXyFgPxi15SmM/gVvRDxPP19K/+Fl/H0FZebzoiRd1uBvkenwi0zsTQ==; 5:RP78OshlVo1FcWSpYsQZRjygKk5ES1CMUUntryR7MRmNsK3rr431u4aIFfWOtoPQw447aEsedXfIow386ZDm0tI5gSoAaRZMoQFfB42RfSxfaASyZVDpxPd6vqM4TAqBXUAUOncFE6hGJ/Zx/NIAB6gc0a7hXnPsm5ljsXd8PwU=; 7:ml9A7TvBZSBnjoj7ZRW1+Q5JmvDqBqD1zCW+bqBEmio3HXcwVnODeGeJgqoXKWkbv5xdc8nNA/5EoT+HDmA7GfWR5VKhPTUOT64DWeyC5PJm3cOsOs9mGBZZQIuXAdanV700E3+k5tYjGyXHrE2RhQ== x-ms-office365-filtering-correlation-id: 32f96971-b436-483a-d81d-08d63a427368 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:DB3PR0502MB3978; x-ms-traffictypediagnostic: DB3PR0502MB3978: 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)(3002001)(3231355)(944501410)(52105095)(10201501046)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(20161123560045)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:DB3PR0502MB3978; BCL:0; PCL:0; RULEID:; SRVR:DB3PR0502MB3978; x-forefront-prvs: 083691450C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(136003)(39860400002)(346002)(396003)(366004)(199004)(189003)(99286004)(8936002)(25786009)(8676002)(81156014)(14454004)(106356001)(68736007)(6506007)(386003)(52116002)(81166006)(476003)(2616005)(486006)(2900100001)(105586002)(54906003)(107886003)(53936002)(37006003)(305945005)(186003)(5660300001)(6486002)(6436002)(316002)(4326008)(97736004)(7736002)(1857600001)(6862004)(66066001)(478600001)(5250100002)(6512007)(575784001)(86362001)(1076002)(26005)(36756003)(256004)(14444005)(71190400001)(71200400001)(2906002)(6116002)(6636002)(102836004)(3846002)(309714004); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR0502MB3978; 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: BvRiRVWTMTayJUbetoouTKIm/4QqwvuyWZOUjLLWdZ+4B0Z/tlJH+OjDi1tRGZo0Nj/AmSwjlcfuqcgGX3TIdCyhXTtWwts6qml9rjhvKFtlUl1jyWKJzhbrFQ+D7h5dYKTnLe5r1aYPb3e3IA7f86EpFhd/WtRrJ3MRaQ7XsZuCvapV7Blu6YjDBCkfHbh1rNhVnQpgtATeF3gRTArur93SBbTIrDb0Mvh0rDghc84S7030bM28s5wXoJTLvcgZFcCKiTZj5Yw5gzGza2qzLjjtmhBZUw+h9szfXWRAlFWWoF73hSw+5osYKVXoUsmBya7bUG25198FN3YwP7s+2hLRkDr3K+YVDh7DLqnIVy0= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 32f96971-b436-483a-d81d-08d63a427368 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Oct 2018 06:24:00.3561 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0502MB3978 Subject: [dpdk-dev] [PATCH] net/mlx5: add 128B padding of Rx completion entry 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, 25 Oct 2018 06:24:02 -0000 A PMD parameter (rxq_cqe_pad_en) is added to enable 128B padding of CQE on RX side. The size of CQE is aligned with the size of a cacheline of the core. If cacheline size is 128B, the CQE size is configured to be 128B even though the device writes only 64B data on the cacheline. This is to avoid unnecessary cache invalidation by device's two consecutive writes on to one cacheline. However in some architecture, it is more beneficial to update entire cacheline with padding the rest 64B rather than striding because read-modify-write could drop performance a lot. On the other hand, writing extra data will consume more PCIe bandwidth and could also drop the maximum throughput. It is recommended to empirically set this parameter. Disabled by default. Signed-off-by: Yongseok Koh --- doc/guides/nics/mlx5.rst | 18 ++++++++++++++++++ drivers/net/mlx5/Makefile | 5 +++++ drivers/net/mlx5/meson.build | 2 ++ drivers/net/mlx5/mlx5.c | 19 +++++++++++++++++++ drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_rxq.c | 6 ++++++ 6 files changed, 51 insertions(+) diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index 67696283e5..1dc32829ff 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -246,6 +246,24 @@ Run-time configuration - x86_64 with ConnectX-4, ConnectX-4 LX, ConnectX-5 and Bluefield. - POWER8 and ARMv8 with ConnectX-4 LX, ConnectX-5 and Bluefield. =20 +- ``rxq_cqe_pad_en`` parameter [int] + + A nonzero value enables 128B padding of CQE on RX side. The size of CQE + is aligned with the size of a cacheline of the core. If cacheline size i= s + 128B, the CQE size is configured to be 128B even though the device write= s + only 64B data on the cacheline. This is to avoid unnecessary cache + invalidation by device's two consecutive writes on to one cacheline. + However in some architecture, it is more beneficial to update entire + cacheline with padding the rest 64B rather than striding because + read-modify-write could drop performance a lot. On the other hand, + writing extra data will consume more PCIe bandwidth and could also drop + the maximum throughput. It is recommended to empirically set this + parameter. Disabled by default. + + Supported on: + + - CPU having 128B cacheline with ConnectX-5 and Bluefield. + - ``mprq_en`` parameter [int] =20 A nonzero value enables configuring Multi-Packet Rx queues. Rx queue is diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile index fecb57c18e..0da898c80f 100644 --- a/drivers/net/mlx5/Makefile +++ b/drivers/net/mlx5/Makefile @@ -137,6 +137,11 @@ mlx5_autoconf.h.new: $(RTE_SDK)/buildtools/auto-config= -h.sh enum MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP \ $(AUTOCONF_OUTPUT) $Q sh -- '$<' '$@' \ + HAVE_IBV_MLX5_MOD_CQE_128B_PAD \ + infiniband/mlx5dv.h \ + enum MLX5DV_CQ_INIT_ATTR_FLAGS_CQE_PAD \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ HAVE_IBV_FLOW_DV_SUPPORT \ infiniband/mlx5dv.h \ enum MLX5DV_FLOW_ACTION_TAG \ diff --git a/drivers/net/mlx5/meson.build b/drivers/net/mlx5/meson.build index e8cbe3eec1..f8e0c1b65b 100644 --- a/drivers/net/mlx5/meson.build +++ b/drivers/net/mlx5/meson.build @@ -96,6 +96,8 @@ if build 'MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED' ], [ 'HAVE_IBV_MLX5_MOD_CQE_128B_COMP', 'infiniband/mlx5dv.h', 'MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP' ], + [ 'HAVE_IBV_MLX5_MOD_CQE_128B_PAD', 'infiniband/mlx5dv.h', + 'MLX5DV_CQ_INIT_ATTR_FLAGS_CQE_PAD' ], [ 'HAVE_IBV_FLOW_DV_SUPPORT', 'infiniband/mlx5dv.h', 'MLX5DV_FLOW_ACTION_TAG' ], [ 'HAVE_IBV_DEVICE_MPLS_SUPPORT', 'infiniband/verbs.h', diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index a277b5730e..ec6a482a9a 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -51,6 +51,9 @@ /* Device parameter to enable RX completion queue compression. */ #define MLX5_RXQ_CQE_COMP_EN "rxq_cqe_comp_en" =20 +/* Device parameter to enable RX completion entry padding to 128B. */ +#define MLX5_RXQ_CQE_PAD_EN "rxq_cqe_pad_en" + /* Device parameter to enable Multi-Packet Rx queue. */ #define MLX5_RX_MPRQ_EN "mprq_en" =20 @@ -479,6 +482,8 @@ mlx5_args_check(const char *key, const char *val, void = *opaque) } if (strcmp(MLX5_RXQ_CQE_COMP_EN, key) =3D=3D 0) { config->cqe_comp =3D !!tmp; + } else if (strcmp(MLX5_RXQ_CQE_PAD_EN, key) =3D=3D 0) { + config->cqe_pad =3D !!tmp; } else if (strcmp(MLX5_RX_MPRQ_EN, key) =3D=3D 0) { config->mprq.enabled =3D !!tmp; } else if (strcmp(MLX5_RX_MPRQ_LOG_STRIDE_NUM, key) =3D=3D 0) { @@ -531,6 +536,7 @@ mlx5_args(struct mlx5_dev_config *config, struct rte_de= vargs *devargs) { const char **params =3D (const char *[]){ MLX5_RXQ_CQE_COMP_EN, + MLX5_RXQ_CQE_PAD_EN, MLX5_RX_MPRQ_EN, MLX5_RX_MPRQ_LOG_STRIDE_NUM, MLX5_RX_MPRQ_MAX_MEMCPY_LEN, @@ -723,6 +729,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, struct mlx5dv_context dv_attr =3D { .comp_mask =3D 0 }; struct mlx5_dev_config config =3D { .vf =3D !!vf, + .cqe_pad =3D 0, .mps =3D MLX5_ARG_UNSET, .tx_vec_en =3D 1, .rx_vec_en =3D 1, @@ -743,6 +750,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, int err =3D 0; unsigned int mps; unsigned int cqe_comp; + unsigned int cqe_pad =3D 0; unsigned int tunnel_en =3D 0; unsigned int mpls_en =3D 0; unsigned int swp =3D 0; @@ -863,6 +871,11 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, else cqe_comp =3D 1; config.cqe_comp =3D cqe_comp; +#ifdef HAVE_IBV_MLX5_MOD_CQE_128B_PAD + /* Whether device supports 128B Rx CQE padding. */ + cqe_pad =3D RTE_CACHE_LINE_SIZE =3D=3D 128 && + (dv_attr.flags & MLX5DV_CONTEXT_FLAGS_CQE_128B_PAD); +#endif #ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT if (dv_attr.comp_mask & MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS) { tunnel_en =3D ((dv_attr.tunnel_offloads_caps & @@ -1079,6 +1092,12 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, DRV_LOG(WARNING, "Rx CQE compression isn't supported"); config.cqe_comp =3D 0; } + if (config.cqe_pad && !cqe_pad) { + DRV_LOG(WARNING, "Rx CQE padding isn't supported"); + config.cqe_pad =3D 0; + } else if (config.cqe_pad) { + DRV_LOG(INFO, "Rx CQE padding is enabled"); + } if (config.mprq.enabled && mprq) { if (config.mprq.stride_num_n > mprq_max_stride_num_n || config.mprq.stride_num_n < mprq_min_stride_num_n) { diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 74d87c054b..24a3415c8d 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -115,6 +115,7 @@ struct mlx5_dev_config { /* Whether tunnel stateless offloads are supported. */ unsigned int mpls_en:1; /* MPLS over GRE/UDP is enabled. */ unsigned int cqe_comp:1; /* CQE compression is enabled. */ + unsigned int cqe_pad:1; /* CQE padding is enabled. */ unsigned int tso:1; /* Whether TSO is supported. */ unsigned int tx_vec_en:1; /* Tx vector is enabled. */ unsigned int rx_vec_en:1; /* Rx vector is enabled. */ diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index ed993ea6d9..7db3f68a81 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -841,6 +841,12 @@ mlx5_rxq_ibv_new(struct rte_eth_dev *dev, uint16_t idx= ) " timestamp", dev->data->port_id); } +#ifdef HAVE_IBV_MLX5_MOD_CQE_128B_PAD + if (config->cqe_pad) { + attr.cq.mlx5.comp_mask |=3D MLX5DV_CQ_INIT_ATTR_MASK_FLAGS; + attr.cq.mlx5.flags |=3D MLX5DV_CQ_INIT_ATTR_FLAGS_CQE_PAD; + } +#endif tmpl->cq =3D mlx5_glue->cq_ex_to_cq (mlx5_glue->dv_create_cq(priv->ctx, &attr.cq.ibv, &attr.cq.mlx5)); --=20 2.11.0