From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00064.outbound.protection.outlook.com [40.107.0.64]) by dpdk.org (Postfix) with ESMTP id C3DE11B20B for ; Sun, 5 Nov 2017 18:27:17 +0100 (CET) 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=KyEdxSlitxj5t/gotNOgnqpVodNL2fJm9E7jmhG086Q=; b=JOOu7NNotd5jm1wm5KSVIZ10LqMMgxklVQBJDTTfvMr87/VzurMcQOSlmQ/w/dTlUsOG6QWMIQffA64BZ1AGODVq7OYPAlIX47cBOo83MUJlgRsp9JPmDIQjd9A0tgUh47T+q4QL/e3uSy1M1WOZfx213qHvA1R5xlSaV/8TUnA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=motih@mellanox.com; Received: from mellanox.com (37.142.13.130) by DB5PR05MB1911.eurprd05.prod.outlook.com (2a01:111:e400:c584::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.197.13; Sun, 5 Nov 2017 17:27:14 +0000 From: Moti Haimovsky To: adrien.mazarguil@6wind.com Cc: dev@dpdk.org, Moti Haimovsky Date: Sun, 5 Nov 2017 19:26:56 +0200 Message-Id: <1509902816-26299-1-git-send-email-motih@mellanox.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: VI1PR0102CA0018.eurprd01.prod.exchangelabs.com (2603:10a6:802::31) To DB5PR05MB1911.eurprd05.prod.outlook.com (2a01:111:e400:c584::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5b7d8928-5acf-4e7f-bb12-08d52472753e X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(2017052603199); SRVR:DB5PR05MB1911; X-Microsoft-Exchange-Diagnostics: 1; DB5PR05MB1911; 3:EZq4qPj5ovJzRZN103WJ5dV6B2ZN8jMowOK5DfJLv2CD5EFZymscbf1rBfE5mg52rdnQuEjlGBMznqewNkJmyPm/ftvmOPkbjKcLjp8lXNL4CYVPRl5mLbYRHM6Ooxe13jN/oQPhlR3Y+0NdT/DuKyZB3Hct1LJL7MjpevYwj5tJzfIltxgQinn5q7RDjhgErQ0/bR2hilLH9TS3uNCTePs9SyIl4Arx3yAUyO7xazWvnlpxTrkr8m3okRWggJUG; 25:svSwJ0u6WERxqKPBZ+iBP5wfj1HM8WufWTW0c08W0Jh3qakZijefXs7RKjtZEOiU/qw+7dc9DAi8bp+yY+2ETpRSd0AcapSD94ZX+pEDib3svFzNX4D5C+cundu8iEu//JvKLuH7KDbfPr0ReyLUPnK9Znf+lmrw8/rdbkzAwTwCeArph8thLmM8bpjLSS0CvnMwaloEA/3DR5h+PcLNUegf+GEN8g/qUckMO91JqRAVVZohavytTJEzB/RfAIECPkk2wGf4mKoG+ZGBa9D9qhD++GHS7ira3VOLMm9T2MZOgpu1A7U/xagIDHRt5GdAO/BpdzbzxfTbpOMkbuFuXQ==; 31:2Gt0sMyDYB8HDiI2BY0Ce10rP24QbZjZjzLfkOArUT3zn2MhS8esEIm/I5qK6FpQ6JNHua6Rh2vjnFgiYYpdoW1txxusABO/M8i3GhKk7rN0DAqLTIK5ON+ISh6PlF5cEos7M5pTR+3MsF9+QP/3LejBiq7dQ2LOkLW1vyIUZVBgwbK8tuDRmF88ThpZvtnQ+LLJ4w/jehIQLacCd7l0uppacyrWGF8i69HskQQSs3M= X-MS-TrafficTypeDiagnostic: DB5PR05MB1911: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; DB5PR05MB1911; 20:eS3GMRaohii2X7uZiL4Q0/+gdACA/9FmhZg9JxKf0EdI7691adNkoY3pQkdT5FtJagJn3Ba8+pSGdDnJ7dd/C3DQAQRCT+egiAuzT+TCCYq9sTzeJvpLuDf4iWiDyx84e6f6cZ2EnEKi7vh651qcNtuiikD0Wn6edRSzeziwFUt5Jlba7oAPyPV457kbrptr6VXwTGizqGn4mVVSWyvfzCCr+lpAjKIHcFgBKdyW/FWMtiSzE4zH5Ilyb8nj+4qWSXS2Gk3Q3P6sgrFy2irIDcNEHaja5Blmm9Nk0CxGMmceWw23VavQo5cWtI4uaSwiOVG42QQ4e4tJN+fmh2whW87O8GsO2HfvzSVf3bzKCUziQ9LeBuuIwNBhlXYjkIb8bcKeXuTiH7jtzjyIL35xeb9R8Mrr4XEdHcsT+ZpV4G3y3vKoRgLcYExTiKrb+ge9V6YqpDaD34OojgPxVtEGLZyn9byGqc94bgQEEIWv8BXuMVR8UH4VxyAC4Q+1DGrE; 4:ZMJGHg389E5aqiZt1DlhbLrbSHm3yA5GtVO4xxwH6TZXkk56ldRzD4TicgVJuvmt8bsaHHHW0Z41eKRZo/e5NcNO5l0qjQPz5w44o9ftb3QmWzXeuSYawcm9u+/0iDSqerMgYc9Y4M1RoCYf10tmoOosqaQJi0oFsyPHdwwg3jBgMEl9OZMOp9t5luYe2q/P2dc3giHxem+76GBIkoXBq10AFvtHrAZ3WwISjl+KP71aJU/hyv1nMqPv+I2gQ23acc6wXZw9ignFuUPXpxJ8h2pgtOJCACgNcGmL2M5v3p4uEvKr0h33foqc1FTOnfks X-Exchange-Antispam-Report-Test: UriScan:(211171220733660); 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)(3231021)(100000703101)(100105400095)(3002001)(93006095)(93001095)(10201501046)(6055026)(6041248)(20161123564025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123558100)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DB5PR05MB1911; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DB5PR05MB1911; X-Forefront-PRVS: 04825EA361 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(346002)(376002)(39860400002)(189002)(199003)(2906002)(316002)(4720700003)(189998001)(105586002)(6666003)(25786009)(36756003)(8936002)(33026002)(66066001)(81166006)(6916009)(81156014)(50226002)(106356001)(2351001)(8676002)(16586007)(4326008)(2361001)(478600001)(5660300001)(50986999)(33646002)(101416001)(47776003)(50466002)(21086003)(48376002)(97736004)(7736002)(86362001)(16526018)(6116002)(53936002)(107886003)(55016002)(575784001)(3846002)(68736007)(5003940100001)(305945005)(69596002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR05MB1911; 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; DB5PR05MB1911; 23:U1m9OeMztY6PS5A+0DS68ATUxhtvpNbQpGGy4voYv?= =?us-ascii?Q?E6KJ+Cw2eWhuka4FAJl8IAyLGp5Q4UxBys+VrJbowwS9XvUso5ctOxMawzFn?= =?us-ascii?Q?8cN4gU428N63Fpp5ozX6sPuFg3BphCosDpAjQS4z0y05KmjQZYEj5u6x30nx?= =?us-ascii?Q?qi9DSy2Krw6UhOTIIXxA6fuKwjY6IEYtWoO/UB4XOCCXL5MzHqu1BsrrVqxy?= =?us-ascii?Q?3RY/ETeSk5GIMVMCqoPCVpbH7VxrjeFiPZXV6EhsjE/CCwJQExOZPSTOX6LN?= =?us-ascii?Q?4Vu7TPmnvOmlZ2NntNvNTCnzZXJbMX5GBoAqwXlLogCCM3ymCAYH3cAfmM4k?= =?us-ascii?Q?ghw1QckRGFLm5FpZQcMGDDVoXbgW/tdijDZaa1SeTsX0ocOjr+5/IlfrVfHC?= =?us-ascii?Q?z0EpbGfo0toDi7vpQBHEKsxdLoBj8Gdt/UFKybWnMPZikGeYcMFpojTeCfQ7?= =?us-ascii?Q?knTFnf+N4k9O9axITbK1XLBFUdRiojFdMMsibkxGK2t7faMjUbOP0ufctJKu?= =?us-ascii?Q?zTxuPqiJCH+G4CWXa0+YaOVUhq5tLYEjrCv09Yi2K7he0gHf3XsrJQMIqEYu?= =?us-ascii?Q?uhVx/0FsC0CZzQXJPhnnaUevGLv6rqY7T8hCTRBRydXPDD8J1xvjBqDr92Wd?= =?us-ascii?Q?2VYnmHEXke4VvmmgduNa+CAnhUdSWyS+Sy0Enhgg0+ZiGitPnJ2GF+bf2iOZ?= =?us-ascii?Q?7Gpxf7zUVrMY2uM8PQeonf5JBEXV8sWpsZVqSMG/oLfPMvZfBktEABa1VVKd?= =?us-ascii?Q?ayUD1h2YV/h8pqYxif0yULzxkATzWzZxgtzgUq1XsjKTd7WlTPj315zBqu/9?= =?us-ascii?Q?ItLAnqsJJ3rh6SNnRfijCR7J9PWz98pOwJMg2FdpJnTCuOxfKylmj4TU6ZDP?= =?us-ascii?Q?N0gnddhppLGLAab5jyztEY3LwILjV2xdm1/VNIRTF0FmHIRL166XzXnNFpWw?= =?us-ascii?Q?VW5R+bmXCM45aJWsvGALVqXkm7ODfbt5o9Htxmy1BOYpW+256rap4MB8Dcuu?= =?us-ascii?Q?NXpE+7wtlX0AZcQF6rcDLm9bxR9N8rRqu8Rk9w44h3D4raMNdgKV5r7qJAVO?= =?us-ascii?Q?NYqzQz0drQcuKlivaYpcZU801bTX+j3MgMxAqOlbCo/L87oBvjBI37oPxVei?= =?us-ascii?Q?pP2JbYprdRqAJFRSu3r6DKt2LvcDkVw20b0k5T9PEoLhlfcfysVR8i0UFxlj?= =?us-ascii?Q?YjRPJtIrss0/Cc=3D?= X-Microsoft-Exchange-Diagnostics: 1; DB5PR05MB1911; 6:ldO4mLo5AtsRgad4LNx41FywAyUCPjCkv8vt0r3NtCtxG4iJ0lzgqpfXDYr4FnYHjSOqDuWLzTC3qELE4ZWuB6Tmodjs9h024ywJtC/4GekGpYEzAoXNNDQSfIjjuJKmE2NhxPF6UCjiIp+o43dAc99acb82xBBBHnyws/4UQS5gbdtNPgrgAC1fMUDE005PJaZYAXELIS+JXx6+SCyejpuDIQclYNdy3JCKWeuoVuhs9PzwdQN4DwmDMnGiouVLeKQuFEKhc/4Q0aoUXCFrWmwEWczHBNERLONBwFLl7CwQZBR6OKYRan4jeIPNNtbbkLh/+2zoIMkwnktotvxR0T1DilUYDDQhSMEi/329I+I=; 5:1xw9F9RGlipBi+VwU/+5Wv3vZxRDoJgs671kfmx5xtCIyMsryNkdlG5cPd1wg0lWaTE/KppE3xtzxjmzozyMQ7f0H5Lpzg1cQq4HlJ3JZ9nxV4S+E7QWjC5USrOskMoAU2OuZdpf9KttKN1uhuCB0n/wilh2r8CDyQrH4DgdGIc=; 24:4BhLCtAR66zSF0/eAymvG2p1/Pg2sqbFln33EZBJkG5Ay7jMYWCa/57lsadDVLjKe9nWVSIlKAv0eair5ZcT1dJUxAvpH1IWRgqG5E1pdGE=; 7:6UfxxTgMUX8I9eeE7N/tKZBfm6c1fj3dbhJvMvSioHX8PdZykYefy2krYbLxC845yUj5fy+Cdq7VWBrGOvtIKIZzU5dP/FwgbnRjnpZ0UYV1lgIiAHnGzukm0ahgrkhurrYBjEz9iYc6CKx+8JCmqoaK1K6JCCSJ6CwXVTKNzmmhUOHRlaKpfvEWT71iLHyaDdfPdEFBewu8LzNvLRHy4HbzXXHczxI0PV6N8Q/CXSQBplOXNwh3TjHH39a2Z3J1 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2017 17:27:14.6272 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5b7d8928-5acf-4e7f-bb12-08d52472753e X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR05MB1911 Subject: [dpdk-dev] [PATCH v4] net/mlx4: enhance Rx packet type offloads 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: Sun, 05 Nov 2017 17:27:18 -0000 This patch enhances the Rx packet type offload to also report the L4 protocol information in the hw ptype filled by the PMD for each received packet. Signed-off-by: Moti Haimovsky --- V4: * Removed extra blank line from the end of mlx4_ethdev.c V3: * Modifications according to review by Adrien Mazarguil Re: [PATCH v2] net/mlx4: enhance Rx packet type offloads V2: * Modifications according to review by Adrien Mazarguil Re: [PATCH] net/mlx4: enhance Rx packet type offloads * Added mlx4_dev_supported_ptypes_get used in .dev_supported_ptypes_get for reporting supported packet types. --- drivers/net/mlx4/mlx4.c | 1 + drivers/net/mlx4/mlx4.h | 1 + drivers/net/mlx4/mlx4_ethdev.c | 32 ++++++ drivers/net/mlx4/mlx4_prm.h | 16 +++ drivers/net/mlx4/mlx4_rxtx.c | 241 +++++++++++++++++++++++++++++++++++++---- 5 files changed, 268 insertions(+), 23 deletions(-) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index 5d35a50..f9e4f9d 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -244,6 +244,7 @@ struct mlx4_conf { .stats_get = mlx4_stats_get, .stats_reset = mlx4_stats_reset, .dev_infos_get = mlx4_dev_infos_get, + .dev_supported_ptypes_get = mlx4_dev_supported_ptypes_get, .vlan_filter_set = mlx4_vlan_filter_set, .rx_queue_setup = mlx4_rx_queue_setup, .tx_queue_setup = mlx4_tx_queue_setup, diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h index bccd30c..3aeef87 100644 --- a/drivers/net/mlx4/mlx4.h +++ b/drivers/net/mlx4/mlx4.h @@ -164,6 +164,7 @@ int mlx4_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf); int mlx4_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf); +const uint32_t *mlx4_dev_supported_ptypes_get(struct rte_eth_dev *dev); /* mlx4_intr.c */ diff --git a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c index b0acd12..c2ea4db 100644 --- a/drivers/net/mlx4/mlx4_ethdev.c +++ b/drivers/net/mlx4/mlx4_ethdev.c @@ -1013,3 +1013,35 @@ enum rxmode_toggle { assert(ret >= 0); return -ret; } + +/** + * DPDK callback to retrieve the received packet types that are recognized + * by the device. + * + * @param dev + * Pointer to Ethernet device structure. + * + * @return + * Pointer to an array of recognized packet types if in Rx burst mode, + * NULL otherwise. + */ +const uint32_t * +mlx4_dev_supported_ptypes_get(struct rte_eth_dev *dev) +{ + static const uint32_t ptypes[] = { + /* refers to rxq_cq_to_pkt_type() */ + RTE_PTYPE_L2_ETHER, + RTE_PTYPE_L3_IPV4_EXT_UNKNOWN, + RTE_PTYPE_L3_IPV6_EXT_UNKNOWN, + RTE_PTYPE_L4_FRAG, + RTE_PTYPE_L4_TCP, + RTE_PTYPE_L4_UDP, + RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN, + RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN, + RTE_PTYPE_UNKNOWN + }; + + if (dev->rx_pkt_burst == mlx4_rx_burst) + return ptypes; + return NULL; +} diff --git a/drivers/net/mlx4/mlx4_prm.h b/drivers/net/mlx4/mlx4_prm.h index 339831a..fcc7c12 100644 --- a/drivers/net/mlx4/mlx4_prm.h +++ b/drivers/net/mlx4/mlx4_prm.h @@ -75,9 +75,25 @@ enum { MLX4_CQE_L2_TUNNEL_IPV4 = (int)(1u << 25), MLX4_CQE_L2_TUNNEL_L4_CSUM = (int)(1u << 26), MLX4_CQE_L2_TUNNEL = (int)(1u << 27), + MLX4_CQE_L2_VLAN_MASK = (int)(3u << 29), MLX4_CQE_L2_TUNNEL_IPOK = (int)(1u << 31), }; +/* CQE status flags. */ +#define MLX4_CQE_STATUS_IPV4 (1 << 22) +#define MLX4_CQE_STATUS_IPV4F (1 << 23) +#define MLX4_CQE_STATUS_IPV6 (1 << 24) +#define MLX4_CQE_STATUS_IPV4OPT (1 << 25) +#define MLX4_CQE_STATUS_TCP (1 << 26) +#define MLX4_CQE_STATUS_UDP (1 << 27) +#define MLX4_CQE_STATUS_PTYPE_MASK \ + (MLX4_CQE_STATUS_IPV4 | \ + MLX4_CQE_STATUS_IPV4F | \ + MLX4_CQE_STATUS_IPV6 | \ + MLX4_CQE_STATUS_IPV4OPT | \ + MLX4_CQE_STATUS_TCP | \ + MLX4_CQE_STATUS_UDP) + /* Send queue information. */ struct mlx4_sq { volatile uint8_t *buf; /**< SQ buffer. */ diff --git a/drivers/net/mlx4/mlx4_rxtx.c b/drivers/net/mlx4/mlx4_rxtx.c index 5f8adec..3985e06 100644 --- a/drivers/net/mlx4/mlx4_rxtx.c +++ b/drivers/net/mlx4/mlx4_rxtx.c @@ -73,6 +73,193 @@ struct pv { uint32_t val; }; +/** A table to translate Rx completion flags to packet type. */ +uint32_t mlx4_ptype_table[0x100] __rte_cache_aligned = { + /* + * The index to the array should have: + * bit[7] - MLX4_CQE_L2_TUNNEL + * bit[6] - MLX4_CQE_L2_TUNNEL_IPV4 + * bit[5] - MLX4_CQE_STATUS_UDP + * bit[4] - MLX4_CQE_STATUS_TCP + * bit[3] - MLX4_CQE_STATUS_IPV4OPT + * bit[2] - MLX4_CQE_STATUS_IPV6 + * bit[1] - MLX4_CQE_STATUS_IPV4F + * bit[0] - MLX4_CQE_STATUS_IPV4 + * giving a total of up to 256 entries. + */ + [0x00] = RTE_PTYPE_L2_ETHER, + [0x01] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN, + [0x02] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_L4_FRAG, + [0x03] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_L4_FRAG, + [0x04] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN, + [0x09] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT, + [0x0a] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT | + RTE_PTYPE_L4_FRAG, + [0x11] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_L4_TCP, + [0x12] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_L4_TCP, + [0x14] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | + RTE_PTYPE_L4_TCP, + [0x18] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT | + RTE_PTYPE_L4_TCP, + [0x19] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT | + RTE_PTYPE_L4_TCP, + [0x1a] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT | + RTE_PTYPE_L4_TCP, + [0x21] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_L4_UDP, + [0x22] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_L4_UDP, + [0x24] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | + RTE_PTYPE_L4_UDP, + [0x28] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT | + RTE_PTYPE_L4_UDP, + [0x29] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT | + RTE_PTYPE_L4_UDP, + [0x2a] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT | + RTE_PTYPE_L4_UDP, + /* Tunneled - L3 IPV6 */ + [0x80] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN, + [0x81] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN, + [0x82] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L4_FRAG, + [0x83] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L4_FRAG, + [0x84] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN, + [0x88] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT, + [0x89] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT, + [0x8a] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT | RTE_PTYPE_INNER_L4_FRAG, + /* Tunneled - L3 IPV6, TCP */ + [0x91] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L4_TCP, + [0x92] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L4_FRAG | + RTE_PTYPE_INNER_L4_TCP, + [0x93] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L4_FRAG | + RTE_PTYPE_INNER_L4_TCP, + [0x94] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | + RTE_PTYPE_INNER_L4_TCP, + [0x98] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT | + RTE_PTYPE_INNER_L4_TCP, + [0x99] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT | + RTE_PTYPE_INNER_L4_TCP, + [0x9a] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT | RTE_PTYPE_INNER_L4_FRAG | + RTE_PTYPE_INNER_L4_TCP, + /* Tunneled - L3 IPV6, UDP */ + [0xa1] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L4_UDP, + [0xa2] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L4_FRAG | + RTE_PTYPE_INNER_L4_UDP, + [0xa3] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L4_FRAG | + RTE_PTYPE_INNER_L4_UDP, + [0xa4] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | + RTE_PTYPE_INNER_L4_UDP, + [0xa8] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT | + RTE_PTYPE_INNER_L4_UDP, + [0xa9] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT | + RTE_PTYPE_INNER_L4_UDP, + [0xaa] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT | RTE_PTYPE_INNER_L4_FRAG | + RTE_PTYPE_INNER_L4_UDP, + /* Tunneled - L3 IPV4 */ + [0xc0] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN, + [0xc1] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN, + [0xc2] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L4_FRAG, + [0xc3] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L4_FRAG, + [0xc4] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN, + [0xc8] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT, + [0xc9] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT, + [0xca] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT | + RTE_PTYPE_INNER_L4_FRAG, + /* Tunneled - L3 IPV4, TCP */ + [0xd0] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | + RTE_PTYPE_INNER_L4_TCP, + [0xd1] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L4_TCP, + [0xd2] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L4_FRAG | + RTE_PTYPE_INNER_L4_TCP, + [0xd3] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L4_FRAG | + RTE_PTYPE_INNER_L4_TCP, + [0xd4] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | + RTE_PTYPE_INNER_L4_TCP, + [0xd8] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT | + RTE_PTYPE_INNER_L4_TCP, + [0xd9] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT | + RTE_PTYPE_INNER_L4_TCP, + [0xda] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT | RTE_PTYPE_INNER_L4_FRAG | + RTE_PTYPE_INNER_L4_TCP, + /* Tunneled - L3 IPV4, UDP */ + [0xe0] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | + RTE_PTYPE_INNER_L4_UDP, + [0xe1] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L4_UDP, + [0xe2] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L4_FRAG | + RTE_PTYPE_INNER_L4_UDP, + [0xe3] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L4_FRAG | + RTE_PTYPE_INNER_L4_UDP, + [0xe4] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | + RTE_PTYPE_INNER_L4_UDP, + [0xe8] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT | RTE_PTYPE_INNER_L4_UDP, + [0xe9] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT | RTE_PTYPE_INNER_L4_UDP, + [0xea] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | + RTE_PTYPE_INNER_L3_IPV4_EXT | RTE_PTYPE_INNER_L4_FRAG | + RTE_PTYPE_INNER_L4_UDP, +}; + /** * Stamp a WQE so it won't be reused by the HW. * @@ -557,30 +744,39 @@ struct pv { /** * Translate Rx completion flags to packet type. * - * @param flags - * Rx completion flags returned by mlx4_cqe_flags(). + * @param[in] cqe + * Pointer to CQE. * * @return - * Packet type in mbuf format. + * Packet type for struct rte_mbuf. */ static inline uint32_t -rxq_cq_to_pkt_type(uint32_t flags) +rxq_cq_to_pkt_type(volatile struct mlx4_cqe *cqe) { - uint32_t pkt_type; + uint8_t idx = 0; + uint32_t pinfo = rte_be_to_cpu_32(cqe->vlan_my_qpn); + uint32_t status = rte_be_to_cpu_32(cqe->status); - if (flags & MLX4_CQE_L2_TUNNEL) - pkt_type = - mlx4_transpose(flags, - MLX4_CQE_L2_TUNNEL_IPV4, - RTE_PTYPE_L3_IPV4_EXT_UNKNOWN) | - mlx4_transpose(flags, - MLX4_CQE_STATUS_IPV4_PKT, - RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN); - else - pkt_type = mlx4_transpose(flags, - MLX4_CQE_STATUS_IPV4_PKT, - RTE_PTYPE_L3_IPV4_EXT_UNKNOWN); - return pkt_type; + /* + * The index to the array should have: + * bit[7] - MLX4_CQE_L2_TUNNEL + * bit[6] - MLX4_CQE_L2_TUNNEL_IPV4 + */ + if (!(pinfo & MLX4_CQE_L2_VLAN_MASK) && (pinfo & MLX4_CQE_L2_TUNNEL)) + idx |= ((pinfo & MLX4_CQE_L2_TUNNEL) >> 20) | + ((pinfo & MLX4_CQE_L2_TUNNEL_IPV4) >> 19); + /* + * The index to the array should have: + * bit[5] - MLX4_CQE_STATUS_UDP + * bit[4] - MLX4_CQE_STATUS_TCP + * bit[3] - MLX4_CQE_STATUS_IPV4OPT + * bit[2] - MLX4_CQE_STATUS_IPV6 + * bit[1] - MLX4_CQE_STATUS_IPV4F + * bit[0] - MLX4_CQE_STATUS_IPV4 + * giving a total of up to 256 entries. + */ + idx |= ((status & MLX4_CQE_STATUS_PTYPE_MASK) >> 22); + return mlx4_ptype_table[idx]; } /** @@ -763,6 +959,10 @@ struct pv { goto skip; } pkt = seg; + /* Update packet information. */ + pkt->packet_type = rxq_cq_to_pkt_type(cqe); + pkt->ol_flags = 0; + pkt->pkt_len = len; if (rxq->csum | rxq->csum_l2tun) { uint32_t flags = mlx4_cqe_flags(cqe, @@ -773,12 +973,7 @@ struct pv { rxq_cq_to_ol_flags(flags, rxq->csum, rxq->csum_l2tun); - pkt->packet_type = rxq_cq_to_pkt_type(flags); - } else { - pkt->packet_type = 0; - pkt->ol_flags = 0; } - pkt->pkt_len = len; } rep->nb_segs = 1; rep->port = rxq->port_id; -- 1.8.3.1