From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 678614248B for ; Fri, 27 Jan 2023 04:23:51 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5B1EF40143; Fri, 27 Jan 2023 04:23:51 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2040.outbound.protection.outlook.com [40.107.220.40]) by mails.dpdk.org (Postfix) with ESMTP id 7BD20400D7; Fri, 27 Jan 2023 04:23:50 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YsHqG8ZiTwEs+OA1RgEWli/vbWbV2Qc4aQBucmPeTIGHjtEFZiYTMDqQUiwdaGS9IWM8HEHIpbafOOzTJF0k/NKzSfUEsGhnBhLoSAMgCr/xNHw/tbXxxSs6d2+E6o7mlxaXuVM0zksh0vhL2AyToVzjscZ/hrMbFGPLgHAW4aA9tA3jy+i+cHDJzZ5/px4WBWRKvosJIPYizxgDmcZ7GlYJJRTgNIkv4RLiBxiedhX4tchQv/UWSXOmjkCnU8FUR9FQLsWhNqIBy2veaY+4BiYcwCefvt7EmjEjH5RfIOgp0RXV3jdpzK+A3yGpW+IGvxOjvJfv9on9yHEw4Gp4Bg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Fvch1cz9LH2H0KX3D6wal67wZXH2cWN9/5iCT97VUKA=; b=OxPDQz2DQrQT8a9+SMmLDUS3Uko2l/onZNRmDEJ1MhWgPb8lZV9gjkioqndvlMUUm+xq6rOIz8bGhmoP+dbs2YcnXIhcAc5ugtTKMTFsuMlWZGugxontEiqgmyU3bNvF3omTEGskZoGj3DZvWAfDZJtDN/g7AoWHzrX1/PMp0tZ6KWMQlzb3WU5DUswLsIEFWMwDoQwEZjvvOapDEDIjvzaFZ1CKWBoyNp9Km5dvE5WvveNkEssghNppicxt6IpmTFN3crujHbvLSGLG5jLHgiTFdy2Klq9W6bMlsLhYsdFwwVeFYfTuSKpdhBb6jx2WN/xMiYsCeYt4oT9HdndN/A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Fvch1cz9LH2H0KX3D6wal67wZXH2cWN9/5iCT97VUKA=; b=jVdISDk4Pqobbmp25sNMemMp27sF9HsHiQgt61yo5OhIiMBivi9Kk9vKngv5YtUmzxaWjWV+nOS1JlLsj6NX2XiVxFMC3Sl8PlLi6e2te2bCncWT228Lc7dAmLZk4+080wbDvCshU6BOH7M2YngoapI4sUGFKMY0RlfAO+cj6lftKIbF/kFN9h76mwrigud4RmK2wEpxyI6dn4x1eMIkpsMytDwvgLE4mqEn2KxydxjeVQ2XlRNQi3KqrdZ9ZgfXBgCx1pdfz+0lUrqebxb3ClpSNb8IPG+ELkfQHS7SGI3B+2yZmPOHJ0gC0kfCfCVbZiyMBqwBWrtJsd1mI/LSiQ== Received: from BN0PR04CA0003.namprd04.prod.outlook.com (2603:10b6:408:ee::8) by MW4PR12MB7287.namprd12.prod.outlook.com (2603:10b6:303:22c::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.21; Fri, 27 Jan 2023 03:23:46 +0000 Received: from BN8NAM11FT049.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ee:cafe::69) by BN0PR04CA0003.outlook.office365.com (2603:10b6:408:ee::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 03:23:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BN8NAM11FT049.mail.protection.outlook.com (10.13.177.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.21 via Frontend Transport; Fri, 27 Jan 2023 03:23:46 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 26 Jan 2023 19:23:30 -0800 Received: from pegasus01.mtr.labs.mlnx (10.126.231.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 26 Jan 2023 19:23:28 -0800 From: Alexander Kozyrev To: CC: , , , Subject: [PATCH] net/mlx5: check compressed CQE opcode for an error Date: Fri, 27 Jan 2023 05:23:14 +0200 Message-ID: <20230127032314.3990160-1-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.126.231.37] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT049:EE_|MW4PR12MB7287:EE_ X-MS-Office365-Filtering-Correlation-Id: 02f3d6c2-ed27-433b-3b71-08db0015e678 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: F21MISOANfeDbD6zcQZInFnEcHoKKswZ5Vqn9A0Aw3qiJEwo9oQZUqqwDUivQvcGQfTBq8sMUHQwbM/dtXzBPWWZfoh5uP4ECrSS6L+a0hzKilhuf2e1LSFh4f75O4m7mRugAFClv/HH1eNc9nTfJBLw2C0Af5RexWKD6WsRJpc8Q46Ll8z604mMGJaWXWBekT/iKkBUXCpLpQY2STyWDKQ/cOaaoE8UsdF8XP2nB5w8GFlxUEoUA4SGzJMLxQwJnTMOpXtNur7v244cevP7tCs+sHQBYsKaqCQFBL6QWLCdBZsdoIOMzwPH0VhN6sGhTrOR82niugICCUeETeHSCMcbrhVW1ZwB59lVqqvXY5WxJds3ym9vQCdLI0AmfyY3G5jNBC4GMTFUBJamNojwnxpmrtccDQZP1bzumv/+poW00LFEzpkABs+qNfxSd2VjTTnc1yaShkHnnRONDe6E7i1Kp+BU3ejd5WVHQgtHW/r7Fk5Pb39a9GyylGGLii72xPy++cnphaW/uOuMjok9Hu53uplcFYHux/AswGHAq8VWGFvjDvVJXgKZSwMw4GNczQ7g7Si0osU2vls/eyf5Z/Bl5u25I6Q2InVSeYLB7mtcY8DYpnR+o0BBXL7hJkF5O9GGwWglwmkWcdCuI870+Wt4aBp4ruvMSbYq8d+A2Wl9QzpVkqR4cxuTEonBmjqpL0hJ2PIF8+rhK+1zhpaoMg== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230025)(4636009)(346002)(39860400002)(136003)(376002)(396003)(451199018)(36840700001)(46966006)(40470700004)(36756003)(40460700003)(86362001)(336012)(107886003)(54906003)(450100002)(41300700001)(82310400005)(70586007)(70206006)(478600001)(6666004)(316002)(2906002)(8936002)(40480700001)(83380400001)(4326008)(8676002)(82740400003)(36860700001)(5660300002)(1076003)(7636003)(356005)(2616005)(186003)(16526019)(426003)(6916009)(47076005)(26005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 03:23:46.1978 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 02f3d6c2-ed27-433b-3b71-08db0015e678 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT049.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7287 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org The CQE opcode is never checked for a compressed CQE in the vectorized Rx burst routines. It is assumed that compressed CQEs are always valid and skipped error checking. This is obviously not the case and error CQEs may be compressed together as well. Need to check for the MLX5_CQE_RESP_ERR opcode and mark all the packets as bad ones in the compression session if it is there. Note that this issue is not applicable to the scalar Rx burst. Fixes: 6cb559d67b ("net/mlx5: add vectorized Rx/Tx burst for x86") Cc: stable@dpdk.org Signed-off-by: Alexander Kozyrev --- drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 16 +++++++++++++--- drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 10 +++++++--- drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 9 ++++++--- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/drivers/net/mlx5/mlx5_rxtx_vec_altivec.h b/drivers/net/mlx5/mlx5_rxtx_vec_altivec.h index 683a8f9a6c..204d17a8f2 100644 --- a/drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +++ b/drivers/net/mlx5/mlx5_rxtx_vec_altivec.h @@ -783,7 +783,7 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq, { const uint16_t q_n = 1 << rxq->cqe_n; const uint16_t q_mask = q_n - 1; - unsigned int pos; + unsigned int pos, adj; uint64_t n = 0; uint64_t comp_idx = MLX5_VPMD_DESCS_PER_LOOP; uint16_t nocmp_n = 0; @@ -866,7 +866,7 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq, __vector unsigned char pkt_mb0, pkt_mb1, pkt_mb2, pkt_mb3; __vector unsigned char op_own, op_own_tmp1, op_own_tmp2; __vector unsigned char opcode, owner_mask, invalid_mask; - __vector unsigned char comp_mask; + __vector unsigned char comp_mask, mini_mask; __vector unsigned char mask; #ifdef MLX5_PMD_SOFT_COUNTERS const __vector unsigned char lower_half = { @@ -1174,6 +1174,16 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq, (__vector unsigned long)mask); /* D.3 check error in opcode. */ + adj = (comp_idx != MLX5_VPMD_DESCS_PER_LOOP && comp_idx == n); + mask = (__vector unsigned char)(__vector unsigned long){ + (adj * sizeof(uint16_t) * 8), 0}; + lshift = vec_splat((__vector unsigned long)mask, 0); + shmask = vec_cmpgt(shmax, lshift); + mini_mask = (__vector unsigned char) + vec_sl((__vector unsigned long)invalid_mask, lshift); + mini_mask = (__vector unsigned char) + vec_sel((__vector unsigned long)shmask, + (__vector unsigned long)mini_mask, shmask); opcode = (__vector unsigned char) vec_cmpeq((__vector unsigned int)resp_err_check, (__vector unsigned int)opcode); @@ -1182,7 +1192,7 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq, (__vector unsigned int)zero); opcode = (__vector unsigned char) vec_andc((__vector unsigned long)opcode, - (__vector unsigned long)invalid_mask); + (__vector unsigned long)mini_mask); /* D.4 mark if any error is set */ *err |= ((__vector unsigned long)opcode)[0]; diff --git a/drivers/net/mlx5/mlx5_rxtx_vec_neon.h b/drivers/net/mlx5/mlx5_rxtx_vec_neon.h index f7bbde4e0e..41b9cf5444 100644 --- a/drivers/net/mlx5/mlx5_rxtx_vec_neon.h +++ b/drivers/net/mlx5/mlx5_rxtx_vec_neon.h @@ -524,7 +524,7 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq, { const uint16_t q_n = 1 << rxq->cqe_n; const uint16_t q_mask = q_n - 1; - unsigned int pos; + unsigned int pos, adj; uint64_t n = 0; uint64_t comp_idx = MLX5_VPMD_DESCS_PER_LOOP; uint16_t nocmp_n = 0; @@ -616,7 +616,7 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq, pos += MLX5_VPMD_DESCS_PER_LOOP) { uint16x4_t op_own; uint16x4_t opcode, owner_mask, invalid_mask; - uint16x4_t comp_mask; + uint16x4_t comp_mask, mini_mask; uint16x4_t mask; uint16x4_t byte_cnt; uint32x4_t ptype_info, flow_tag; @@ -780,8 +780,12 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq, -1UL >> (n * sizeof(uint16_t) * 8) : 0); invalid_mask = vorr_u16(invalid_mask, mask); /* D.3 check error in opcode. */ + adj = (comp_idx != MLX5_VPMD_DESCS_PER_LOOP && comp_idx == n); + mask = vcreate_u16(adj ? + -1UL >> ((n + 1) * sizeof(uint16_t) * 8) : -1UL); + mini_mask = vand_u16(invalid_mask, mask); opcode = vceq_u16(resp_err_check, opcode); - opcode = vbic_u16(opcode, invalid_mask); + opcode = vbic_u16(opcode, mini_mask); /* D.4 mark if any error is set */ *err |= vget_lane_u64(vreinterpret_u64_u16(opcode), 0); /* C.4 fill in mbuf - rearm_data and packet_type. */ diff --git a/drivers/net/mlx5/mlx5_rxtx_vec_sse.h b/drivers/net/mlx5/mlx5_rxtx_vec_sse.h index 185d2695db..ab69af0c55 100644 --- a/drivers/net/mlx5/mlx5_rxtx_vec_sse.h +++ b/drivers/net/mlx5/mlx5_rxtx_vec_sse.h @@ -523,7 +523,7 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq, { const uint16_t q_n = 1 << rxq->cqe_n; const uint16_t q_mask = q_n - 1; - unsigned int pos; + unsigned int pos, adj; uint64_t n = 0; uint64_t comp_idx = MLX5_VPMD_DESCS_PER_LOOP; uint16_t nocmp_n = 0; @@ -591,7 +591,7 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq, __m128i pkt_mb0, pkt_mb1, pkt_mb2, pkt_mb3; __m128i op_own, op_own_tmp1, op_own_tmp2; __m128i opcode, owner_mask, invalid_mask; - __m128i comp_mask; + __m128i comp_mask, mini_mask; __m128i mask; #ifdef MLX5_PMD_SOFT_COUNTERS __m128i byte_cnt; @@ -729,9 +729,12 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq, mask = _mm_sll_epi64(ones, mask); invalid_mask = _mm_or_si128(invalid_mask, mask); /* D.3 check error in opcode. */ + adj = (comp_idx != MLX5_VPMD_DESCS_PER_LOOP && comp_idx == n); + mask = _mm_set_epi64x(0, adj * sizeof(uint16_t) * 8); + mini_mask = _mm_sll_epi64(invalid_mask, mask); opcode = _mm_cmpeq_epi32(resp_err_check, opcode); opcode = _mm_packs_epi32(opcode, zero); - opcode = _mm_andnot_si128(invalid_mask, opcode); + opcode = _mm_andnot_si128(mini_mask, opcode); /* D.4 mark if any error is set */ *err |= _mm_cvtsi128_si64(opcode); /* D.5 fill in mbuf - rearm_data and packet_type. */ -- 2.18.2