From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0072.outbound.protection.outlook.com [104.47.0.72]) by dpdk.org (Postfix) with ESMTP id F30AD2C58; Thu, 14 Sep 2017 12:51: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; bh=ubsjxTGT4F9YCaI+sQl8QGCDM1ttt8IG2njpDXofXUo=; b=k9QSgBkiYqsOKFR6PJq15CP0Yl/mN0ZZNhSMSIDqWqVpc0Nqw59hC/c4cNkQUXbdpAd0OHNeexGXui5mgjoRwg9hZme+tGXpq3/qdbIcLa2Kjws9a8lQChbI2rCYUhlUk/vBnaFMcn3Mp75pfRcgJDJFXOhOg8CmgQeYEBw2N/8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=shahafs@mellanox.com; Received: from mellanox.com (82.166.227.17) by AM4PR05MB3137.eurprd05.prod.outlook.com (2603:10a6:205:3::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.35.12; Thu, 14 Sep 2017 10:50:49 +0000 From: Shahaf Shuler To: nelio.laranjeiro@6wind.com, yskoh@mellanox.com, adrien.mazarguil@6wind.com Cc: dev@dpdk.org, stable@dpdk.org Date: Thu, 14 Sep 2017 13:50:39 +0300 Message-Id: <5046c30c96938a590412ce03dcad1434824cd952.1505385989.git.shahafs@mellanox.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [82.166.227.17] X-ClientProxiedBy: VI1PR0101CA0057.eurprd01.prod.exchangelabs.com (2603:10a6:800:1f::25) To AM4PR05MB3137.eurprd05.prod.outlook.com (2603:10a6:205:3::14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 558dd3ec-6623-4bac-4665-08d4fb5e7698 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:AM4PR05MB3137; X-Microsoft-Exchange-Diagnostics: 1; AM4PR05MB3137; 3:vNfLFLGbgGl9de4bw2TkG9UtjqB6f9wrjsXTD5KkXtnXjqxQmOgrbGBFQsF9nRFxp8RBGtPTV51FOYiNuPEaRmhJXYqo5cUcezWwrrt4F0WgDwvrB7yYIphMkOHjqo/mK8ELBVwlll/FLoOAnYizrdWSYUIP6GHgqYWJcQUtTLBijlx/fWQDmObsQinVQbhqdqvOLy5oCtA+tz0PuFsjyHzg4HhML3k6OTkK9zeTZGw2F6ykAnbQ6UEAy1j6/ajo; 25:78lVizWo7apWcwP09w5Kfi4BLsyxB4uaNdXl8z6A/A+p0fE1jZyxSbz+fxrhGR9x/+wNXePOeQVaxZSL8ACKOoQWIRFI9Rhb4p7M5280XaE7QOwiibfFBLG0+h20mHt0PSGeERe4hEJB+satpXU16WlVb2XSD88vlLB9XUrtC5RW8aDkrfO1bpUjT5Ph0yiszrEAhbvOl3iRnDf8oRvfaHecXSfrE5nekGnlr2NBKR3j1misaSFyzCg9amUMwIIcDuwv349F4QsoRNvXqszjUbYyjN9ac20xkZWAD5NDOvJkPrbJ+BW/ZUjLiQscQvoviH7lOwgCtcgatt+8StNHOw==; 31:splf7fDTW4EOZ8LwksecKpGTD+QAknp1JOnDUKGOP9fH24oJFrM7w9EsTMMC60pYR3yVrLkTVGkkK5VuGu5vM/C9/YuGFoxEzXH4F4IM8qhSGdzp5eaF1xhr8/N3NZIRG8D4FBqdBeA1AojnY50h35kLOxlqT6EG1Oiygs3UVTGEzBWJr0sInB4wjz+UVDkVKoeBXLEoPdZzWkPfHZeY4k7Qxk4NfQSgQjrcXBeOatw= X-MS-TrafficTypeDiagnostic: AM4PR05MB3137: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; AM4PR05MB3137; 20:lDL+vq2XIAV9SNK46Zw8EBw2QZ/golDNNdDs4rB/oiSNpzCWBj6JFUTwDNVuOg1gZUdLOE3pZzMxmql7x1keF/KZP23cIJeCz30lA8IO+5G0kiw7CDLmdwmQ4d5j3cuv1ZTBxfFmwyfVcdmPoD+cZd2U7nOwVTWVAYB3SDEh4yk4DbosYcXZs7HmPbE1hOX+qmCfDPemZ5Zk3ZlUh2TYV00H+Cpco0e3Ir/PzvsPZSZN1gZG5+AQjOjS2xpxw7CNNbhhdgc/R0Gu6m7YX/9aBFTOum5ynyr2kob3ngxvyP2mOYJhYH579yXae42DC1QmyhLWV1xAyl83p7GEB3hK5RMCLI3FqtVjNoxsotHiyybPwAO8/Vb7TYjJmx8AQgHQVAH5eTD6N5DZmbXYJkeyXBxrghhYSn0GsQOUlqyqWtHn4WRsmpq99vwbC8S65i4OCNh8Ppv7hYJtjOGSKKeczE/Z/iAheT3Cko5XBZp9pb6ArFCajRrVElW/qTmOyXWk; 4:hqs4I5nc3HmMvzOhVlKiWSW569s19NdL+iSaL4oJlrQmofSBntEaTg412jrEoQ8dknCX6DrpG8Z0UlHD465xGVD64o9lqrImW5suE4bWxmuKXAj+7wFqgHwj+ZhJNkMPdc3LHxULSKtOUO9fBQfEZekWa+e0qjflCDwAaUsaB5IqqWhVVKXJXnWMnIjsFSeAIGHjBahHOb7Q9ky4drNoXz7hjt+WmPqT2D181dkJ8I0E/ynxWFc2ApKn1jc3ljoR X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(100000703101)(100105400095)(6055026)(6041248)(20161123564025)(20161123555025)(20161123560025)(20161123558100)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:AM4PR05MB3137; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:AM4PR05MB3137; X-Forefront-PRVS: 0430FA5CB7 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(346002)(376002)(189002)(199003)(50986999)(50226002)(105586002)(478600001)(50466002)(8676002)(48376002)(86362001)(110136004)(2906002)(4326008)(106356001)(53936002)(7350300001)(6666003)(81156014)(101416001)(97736004)(69596002)(16586007)(76176999)(81166006)(36756003)(33026002)(7736002)(5003940100001)(68736007)(189998001)(47776003)(6116002)(575784001)(55016002)(5660300001)(66066001)(25786009)(33646002)(118296001)(316002)(3846002)(21086003)(2950100002)(305945005); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3137; H:mellanox.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM4PR05MB3137; 23:V4c2TeGEr3ZwazSgL93+NsVlkm7LBI2hBsRKnrCgK?= =?us-ascii?Q?uAM7iF+svRC7wLqC8J3qykWawXImhIL+IfTAxP6yiGe/vJMymJA4YE0io/iZ?= =?us-ascii?Q?ALsAswc/xTU8JGPM+dgSXr1L0lRLU29Ki0woFJIa5RmtABwB4a1r7kEkTHPT?= =?us-ascii?Q?Zhes+RY+5JHmzypLCtOJH44DeqboA/OT+sC9qZeFUKL4SGGmOzAzqJ5HnIBe?= =?us-ascii?Q?rUq3eu8KGq/K/ezCvVEoFbgKc9LP7In19TaPZM/nh/G0uI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Q3bBOJL2QV655V5lre58meVGIosjK5T5lZw5jwMoyDdq2g?= =?us-ascii?Q?nnKT7CitA8X4MM=3D?= X-Microsoft-Exchange-Diagnostics: 1; AM4PR05MB3137; 6:qCOPVnV7e6iggG93erHaGRDS8BiunpAaRr7EfplPaodya4sx5ScaZUDorJZMeaBwlip694Rvj5OJ+edYJ6hrF8B+T420TGlCdSxGSM4ex87Tjyu+qnqPNqHdarT7cD85GxTuikA6EyeQZIhK9BPLXFQhFh2FuSYIKZf/Cqkq2WkHD7a5pr2sFSE5D5WGfpF3oQ2OfSNX751yS5vZitmRTUt2DBGrBAB6UYMD8/E533hfo/eGVHLNdOi3UoefxLiixmL9+y7YaTmy7XjQIvHNUOZo4DoFpbyGKLYCpWhaEZ6djNHSQQOnL4RaSgJ0o+wE3mo4yZLs4ashBrUrjoaWlA==; 5:AlmfgA+dJuRWsdDpQpU2M8ORihRXh0N6bZgqFJv4ZUiDKVUlWm15UGHWguEa4vSp9O8KO+Fg+tI7pcbXLz75QAuUxtlrCprNDzdPq6eIl7A8FXcFWwGY2KJPDUeqjvd2aBQNqR9Y/uByhIpKEyK3Nw==; 24:YoXR+cg7lIz1jLFJJfoksilBIV2pHvc9Jcsm5nNPqmGbUF82ZsVYqLuc63WANVvw0wXxgoEVN4z9/NeOoEPqUPcPpJRNt1tXSVfQ8djEhiM=; 7:97IxjwzcxnxWTyaJwTCD5RfiHFgxi/F4Pbyqau6b8+jKt69L4E/qnm0EwaUB38TETKeR7VuinT+sNJ0yME9iPTufIT3uD+lFMJ5yLeHYw12tt0rokX+3BCdm7npXX0O/BoGUfrURz1hZfBVBngzX8ZeceNuvHsB76NETIp6v5kR2/J5Clt8syOM4U58uydNEGlQOJ9CJQnP8pwpufCpgVnDEY4GpaTFX1fjzQlY2XvU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2017 10:50:49.3146 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3137 Subject: [dpdk-stable] [PATCH v5 4/4] net/mlx5: enforce Tx num of segments limitation X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Sep 2017 10:51:02 -0000 Mellanox NICs has a limitation on the number of mbuf segments a multi segment mbuf can have. The max number depends on the Tx offloads requested. The current code not enforce such limitation, which might cause malformed work requests to be written to the device. This commit adds verification for the number of mbuf segments posted to the device. In case of overflow the packet will not be sent. In addition update the nic documentation with the limitation. Considering device limitation is 63 data segments in a work request, the maximum number of segment in mbuf was calculated taking TSO as the worst case: max_nb_segs = 63 - (control_segment + ethernet segment + TSO headers inline + inline segment + extra inline to align to cacheline) Cc: stable@dpdk.org Signed-off-by: Shahaf Shuler --- on v5: - fixed documentation. - changed MLX5_MAX_DS macro to MLX5_DSEG_MAX. --- doc/guides/nics/mlx5.rst | 4 ++++ drivers/net/mlx5/mlx5_defs.h | 3 ++- drivers/net/mlx5/mlx5_prm.h | 3 +++ drivers/net/mlx5/mlx5_rxtx.c | 4 ++++ drivers/net/mlx5/mlx5_rxtx_vec_sse.c | 5 +++++ drivers/net/mlx5/mlx5_txq.c | 24 ++++++++++++++++++++++++ 6 files changed, 42 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index f4cb18bca..c6a196c2e 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -124,6 +124,10 @@ Limitations Will match any ipv4 packet (VLAN included). +- A multi segment packet must have less than 6 segments in case the Tx burst function + is set to multi-packet send or Enhanced multi-packet send. Otherwise it must have + less than 50 segments. + Configuration ------------- diff --git a/drivers/net/mlx5/mlx5_defs.h b/drivers/net/mlx5/mlx5_defs.h index a76bc6f65..59ff00d6b 100644 --- a/drivers/net/mlx5/mlx5_defs.h +++ b/drivers/net/mlx5/mlx5_defs.h @@ -100,7 +100,8 @@ /* * Maximum size of burst for vectorized Tx. This is related to the maximum size - * of Enhaned MPW (eMPW) WQE as vectorized Tx is supported with eMPW. + * of Enhanced MPW (eMPW) WQE as vectorized Tx is supported with eMPW. + * Careful when changing, large value can cause WQE DS to overlap. */ #define MLX5_VPMD_TX_MAX_BURST 32U diff --git a/drivers/net/mlx5/mlx5_prm.h b/drivers/net/mlx5/mlx5_prm.h index 608072f7e..c61e4d86c 100644 --- a/drivers/net/mlx5/mlx5_prm.h +++ b/drivers/net/mlx5/mlx5_prm.h @@ -154,6 +154,9 @@ /* Default mark value used when none is provided. */ #define MLX5_FLOW_MARK_DEFAULT 0xffffff +/* Maximum number of DS in WQE. */ +#define MLX5_DSEG_MAX 63 + /* Subset of struct mlx5_wqe_eth_seg. */ struct mlx5_wqe_eth_seg_small { uint32_t rsvd0; diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c index 7567f2329..5b6bd6ba6 100644 --- a/drivers/net/mlx5/mlx5_rxtx.c +++ b/drivers/net/mlx5/mlx5_rxtx.c @@ -661,6 +661,10 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n) else j += sg; next_pkt: + if (ds > MLX5_DSEG_MAX) { + txq->stats.oerrors++; + break; + } ++elts_head; ++pkts; ++i; diff --git a/drivers/net/mlx5/mlx5_rxtx_vec_sse.c b/drivers/net/mlx5/mlx5_rxtx_vec_sse.c index f89762ff8..39c732515 100644 --- a/drivers/net/mlx5/mlx5_rxtx_vec_sse.c +++ b/drivers/net/mlx5/mlx5_rxtx_vec_sse.c @@ -248,6 +248,10 @@ txq_scatter_v(struct txq *txq, struct rte_mbuf **pkts, uint16_t pkts_n) if (segs_n == 1 || max_elts < segs_n || max_wqe < 2) break; + if (segs_n > MLX5_MPW_DSEG_MAX) { + txq->stats.oerrors++; + break; + } wqe = &((volatile struct mlx5_wqe64 *) txq->wqes)[wqe_ci & wq_mask].hdr; if (buf->ol_flags & @@ -365,6 +369,7 @@ txq_burst_v(struct txq *txq, struct rte_mbuf **pkts, uint16_t pkts_n, max_elts = (elts_n - (elts_head - txq->elts_tail)); max_wqe = (1u << txq->wqe_n) - (txq->wqe_ci - txq->wqe_pi); pkts_n = RTE_MIN((unsigned int)RTE_MIN(pkts_n, max_wqe), max_elts); + assert(pkts_n <= MLX5_DSEG_MAX - nb_dword_in_hdr); if (unlikely(!pkts_n)) return 0; elts = &(*txq->elts)[elts_head & elts_m]; diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c index 4b0b532b1..b4c5b10fb 100644 --- a/drivers/net/mlx5/mlx5_txq.c +++ b/drivers/net/mlx5/mlx5_txq.c @@ -288,6 +288,8 @@ txq_ctrl_setup(struct rte_eth_dev *dev, struct txq_ctrl *txq_ctrl, .comp_mask = IBV_EXP_QP_INIT_ATTR_PD, }; if (priv->txq_inline && (priv->txqs_n >= priv->txqs_inline)) { + unsigned int ds_cnt; + tmpl.txq.max_inline = ((priv->txq_inline + (RTE_CACHE_LINE_SIZE - 1)) / RTE_CACHE_LINE_SIZE); @@ -320,6 +322,28 @@ txq_ctrl_setup(struct rte_eth_dev *dev, struct txq_ctrl *txq_ctrl, attr.init.cap.max_inline_data = tmpl.txq.max_inline * RTE_CACHE_LINE_SIZE; } + /* + * Check if the inline size is too large in a way which + * can make the WQE DS to overflow. + * Considering in calculation: + * WQE CTRL (1 DS) + * WQE ETH (1 DS) + * Inline part (N DS) + */ + ds_cnt = 2 + + (attr.init.cap.max_inline_data / MLX5_WQE_DWORD_SIZE); + if (ds_cnt > MLX5_DSEG_MAX) { + unsigned int max_inline = (MLX5_DSEG_MAX - 2) * + MLX5_WQE_DWORD_SIZE; + + max_inline = max_inline - (max_inline % + RTE_CACHE_LINE_SIZE); + WARN("txq inline is too large (%d) setting it to " + "the maximum possible: %d\n", + priv->txq_inline, max_inline); + tmpl.txq.max_inline = max_inline / RTE_CACHE_LINE_SIZE; + attr.init.cap.max_inline_data = max_inline; + } } if (priv->tso) { attr.init.max_tso_header = -- 2.12.0