From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30060.outbound.protection.outlook.com [40.107.3.60]) by dpdk.org (Postfix) with ESMTP id 506321B19A; Wed, 13 Sep 2017 12:50:51 +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=/o6ls0Asur0+tvsOji5I/3QIqhiVP4YkutoU7ZfufXY=; b=XeptXeQs3xPZd7kf4o58jmXfVp0nhIKRu2W97CO8qSV0nsvJZjKX1bvaxTSNFPHZvEFONB5nIinDe2eeOyccGPiFMHyX/v9aJjEbKNUnRO/spGwpBt4YRuCF38KnhV5Scc3uNhiauzRUUpQeCUawxUAp5ktxl/2KfTUaJnUHcV4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=shahafs@mellanox.com; Received: from mellanox.com (82.166.227.17) by VI1PR05MB3151.eurprd05.prod.outlook.com (2603:10a6:802:1b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.35.12; Wed, 13 Sep 2017 10:50:48 +0000 From: Shahaf Shuler To: nelio.laranjeiro@6wind.com, yskoh@mellanox.com, adrien.mazarguil@6wind.com Cc: dev@dpdk.org, stable@dpdk.org Date: Wed, 13 Sep 2017 13:50:39 +0300 Message-Id: X-Mailer: git-send-email 2.12.0 In-Reply-To: <7b6d42c0c5e1a04f8483b6546ea0b1db8fb7ceee.1505133966.git.shahafs@mellanox.com> References: <7b6d42c0c5e1a04f8483b6546ea0b1db8fb7ceee.1505133966.git.shahafs@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [82.166.227.17] X-ClientProxiedBy: HE1PR0401CA0079.eurprd04.prod.outlook.com (2603:10a6:3:19::47) To VI1PR05MB3151.eurprd05.prod.outlook.com (2603:10a6:802:1b::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f5d09a09-349e-4ae5-4ba6-08d4fa954c09 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:VI1PR05MB3151; X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB3151; 3:CBbpDtPd6jzU6XbbXXhcQXkrUIeHh2f8zLH6x5o1JIxQZbp00V6XRlI3Z6FqdplRuatGAxTs26LKx2+KB9OIn/D4V/g1gXFr0Rei+R54QRR+Tl1PA8W8VFEITVenj4FMd5RgA2zcwsQ+eTnw5uyZiYRrdtwgAArJyN11pW4V1i9T8/zP0PjPQFePO06x2cvTL63hdkidxYAON445HMWJ75tjiw8BhcT/pcFdhFt1fceuiYNOkUj3fCNvFImQOrF4; 25:gloVoWUVQv1mKuemrJUkv7/nMt58gQFGkxCLjiRSPYmhHME56tsXNf3Tf5IYh8ENdIq4tmxqiWYMxz+n6v1zEcRvLlKg0EdFTH3ANlwjQjoqjXDSl06eSOb1WxtfMjS5PubvDmHS/sKjkN6/6PBzNCQK3OCnzDRn/erLDSmuDTjaXedykl/ljKkE9P+/Gg5R5I3QZ/kEReuZ5mXg2D7YtOdClKAbItmYuzY7/m8BTTrmivQy1neTomLYuSJSh1Nsfwck1+dtuzJd4/J/G5FX/q1MaO73ks6kJ7X3voDIQgcq3+WlQ5Jgvgft8fMP74WOYhtb/OCMaZ2D2eiL2bP7aQ==; 31:ygdyu3XE+zRu4SrpTCkexyNzVPvxtp4N00p0hLhPrQjGbbA/Qxrv1Jb5a7FBXiAo8XOrWc+AzW1WAsaU5WFeJL+HKAxwC7YWmhdzfcvApo16k9E69XROyO11Z7w+pR2xiKvT9ttmEpGyQanzC7pvBYrCnESdc94eZTrgtQ6Q69QhWrKW1In5hSbnnLFpzarXmzZdJ4hg6zV2AN87yTcBRHtCTc7Eziue0rXLTxk2Q0Y= X-MS-TrafficTypeDiagnostic: VI1PR05MB3151: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB3151; 20:WRRSIbCzszPv+JS07j2EQBlacSbBmXk7/pOrltzxtYhn2l9PdMzEgLOY94UKW1nR91DaPmPxHQ9KNdtfvJVJJ/PPtnLa3BYsAPDsgQgBHIbFQY9BwvsGBDeIV8PYNy6soMtyWEdL15BZK8OdUZenqTsZReWH0/1UXEdFR5hwJqUI+FA+d24Xn1hZXao0xx3Q+XorYDuFNsSyK5EEC4W4fca4XovQIYECZKMnpwxkwzfb+4VuNRlPwVPtHaqPr/pUd2qFr5jwrEVI6qyM6cnmYWsE9MafzF0s8aXSGb9gYSCO1YJ0s8CTfoh3BbnnbZo7TqJBI5iVnkftehvGl0HOsePRFW6sswQE+5GlOrY42qg/ZhYEs6Hubk2243DRhscXL5fiBjcexb9puGHe6//6tTOtc7W2uQejE+rPbwviIWHqOFhOhuHbpnu5CdX/Jx5/RWWi6+4GJ8JnsGO+DTrFJ6AnEDbXknQ8jVXgmKW427IDhSHCZRXM2cvZpJZm42Wa; 4:0MCn9w1fQqTL/XqH5XyQT9okvIfqi4IHAKxiysm6mPmGTb6iC0PiVm5iQzYsgvnoMbg3MqjzOBKM4+uP8U3Nx0nTqoQW0vcZWc4nLlGOZKM1I8MhmpK6/LvXz+D+dkyZetzQbP/WJc0WGZjJW8Lk61lYt/317anhT9D7jyc4tHRSELZNiAfRTi4bfuYh+RlVPq6GSjPkK+oRQk2UoOvVxQVTI/HZtOTGlwxpOrDdIIuJdXJsqqx0fkk7992rVXvC 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)(93006095)(93001095)(100000703101)(100105400095)(3002001)(10201501046)(6055026)(6041248)(20161123558100)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123555025)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:VI1PR05MB3151; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:VI1PR05MB3151; X-Forefront-PRVS: 042957ACD7 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(346002)(39860400002)(376002)(366002)(199003)(189002)(21086003)(105586002)(86362001)(48376002)(50466002)(3846002)(6116002)(7736002)(69596002)(76176999)(50986999)(118296001)(25786009)(575784001)(66066001)(47776003)(478600001)(106356001)(101416001)(33026002)(55016002)(305945005)(53936002)(2950100002)(4326008)(6666003)(110136004)(5003940100001)(33646002)(50226002)(2906002)(68736007)(5660300001)(81166006)(81156014)(8676002)(189998001)(36756003)(7350300001)(316002)(97736004); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB3151; H:mellanox.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; VI1PR05MB3151; 23:JhhfSRuspG6ryazN+eVTrrozcuAOOFU9f+XCuU+Zp?= =?us-ascii?Q?XAPuReGTo7pCoENHWPMZcy5JGvSapna2RGSowtb898OUyH7MF73R3Yucm5Do?= =?us-ascii?Q?abpAX1Yt/1MVRhFRyofjPW/MRQ8MbqIEbYSkGpqT4ep6j5x0ElaTejPCA8P2?= =?us-ascii?Q?F/Q75IK3RfQKM8oDTrlpCh1LfAY2qnzltP3I1d7p2q5J1Y/IqEUiZKR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PM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2017 10:50:48.8987 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB3151 Subject: [dpdk-stable] [PATCH v4 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: Wed, 13 Sep 2017 10:50:51 -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 --- doc/guides/nics/mlx5.rst | 2 ++ 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 | 27 +++++++++++++++++++++++++++ 6 files changed, 43 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index f4cb18bca..d8244de97 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -124,6 +124,8 @@ Limitations Will match any ipv4 packet (VLAN included). +- A multi segment mbuf must have less than 50 segments. That means mbuf->nb_segs < 50. + Configuration ------------- diff --git a/drivers/net/mlx5/mlx5_defs.h b/drivers/net/mlx5/mlx5_defs.h index a76bc6f65..3de0e5d81 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..bc2b72333 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_MAX_DS 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..fdd7067da 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_MAX_DS) { + 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..3583e6780 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_MAX_DS - 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..091b1a93d 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,31 @@ 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_MAX_DS) { + unsigned int max_inline = (MLX5_MAX_DS - 2) * + MLX5_WQE_DWORD_SIZE; + + /* Ceil down*/ + 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->mps == MLX5_MPW_ENHANCED) + tmpl.txq.inline_max_packet_sz = max_inline; + } } if (priv->tso) { attr.init.max_tso_header = -- 2.12.0