From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40073.outbound.protection.outlook.com [40.107.4.73]) by dpdk.org (Postfix) with ESMTP id 185281B2A3 for ; Sun, 5 Nov 2017 16:42:51 +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=C50YQXdtzZBzcvLnrfYDyGw0ie7lK/AebvLw4Ih+tIA=; b=ZL+YDsU1Si6syrd77tcRM1M5HuHIXN8IZuHpJCvzUrYNJ8AeeHdcrC0VtJfjmbLVktILgOMD711mNSywhlT3JmQMLbiusLonPpqgEswLQZouv4SvPQa6L5cLsFyeTtdLpxBw32Q8KyAeKJwAi8wgs29i2R/jCOH/puzNxunzMg8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=motih@mellanox.com; Received: from mellanox.com (37.142.13.130) by HE1PR05MB1915.eurprd05.prod.outlook.com (2a01:111:e400:7b74::15) 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 15:42:47 +0000 From: Moti Haimovsky To: adrien.mazarguil@6wind.com Cc: dev@dpdk.org, Moti Haimovsky Date: Sun, 5 Nov 2017 17:42:29 +0200 Message-Id: <1509896549-23106-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: VI1PR08CA0228.eurprd08.prod.outlook.com (2603:10a6:802:15::37) To HE1PR05MB1915.eurprd05.prod.outlook.com (2a01:111:e400:7b74::15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 066dc462-4811-4b6d-b426-08d52463dd83 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(2017052603199); SRVR:HE1PR05MB1915; X-Microsoft-Exchange-Diagnostics: 1; HE1PR05MB1915; 3:j0e5mrPSUA1uPl4ymm3AGpfn2kgcwvkYXYBTPhl74icDCrOTeGWanwNIITchlF3WWMtxNZpG/qSGNLrJxZsvwbHyhfQrj8/muXOufPMVRbUS/j4oFQXTskde/WFs9JENL6dwC+/ggxAnN6gHOAwdinhT4f+WrH3POwxA14d3ZYyUle+tnvXDD2+oHIHFiWXgTb6sgOXD5tbwo25y40rjKVDk7IEiDdrlUZPCnbmGwmc2tx2fEqGiUgYen7GRZqjx; 25:xwWqDiBEbB5O0y9q6TKmGos/5DL9yI2QYDZsENTvkOe2X1b7inFE/1ZPTu095SGY+y7mlOYCFcHpJ2lYpEvyB3IHn4BEIbiyiRemRkTRMaezVYKt/Inds0T6/7qgBdewEB6oui0FfVxD/a7tFps3IylUTS0CmdD22WT+B/seSgYVsiKGElS2NA4r/q5R2lKbboIlq91NgtyeTjVBHPlfzds3j16pomiQnV9VLWM3Tn1X/EOiuvgNfjtyFTAcFKNdK53jq+7Tnt2O471CTRoweEYDy5hJiDE8NTar6jsM8RD4LuOOWYsdTTIgPWZqesyIiFqO4H+uyX2o2+Vis4REdg==; 31:G43ohKLf4zT6++50kdbcy1lPfIpjRbObdZKR3TPHwksrwkhmWS3OGt9PmxmsGHnoq3vphyO40NSewwuXGIMDjzpZuBPOR/24buvh01GSr4SAwQFKIqPloCiufNjpmcRZdSKNTkLUqUyzEdVagFUKDQzMI7ufQot4CGMOOPatYEzd97/UNrjSh4v83dwdf5b5/p2r+qDQ50OUptLD83UpjhQ7q4oeN6Vh+In4eUxINxc= X-MS-TrafficTypeDiagnostic: HE1PR05MB1915: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; HE1PR05MB1915; 20:CXgB6z2xhqgL4MwZCZ9yGoiXdO5xMTu3tpgNq6qAnG0ilktKc2Svh2FEyWGrtD6Ue86p8/cCCcXs+exWKgUoPPV+ciUZueP1l0kupI/8A8qbgAFcrRvavWaqeu9m3zSzEH4zHIPktxY292Wg23zEuTIJUzNEpHR8fijGpkhAXFkERdFdOb//RCkE/jp9Esv1R7KUc1TopfWfmdu4vXPeXwmh9Q3nvoCBOXQQtD6yQp4S3gqIknsLJHG7DQIcyRB2eh/BeAIxyhWWZXKq7YhhseU2UVz+NtdaYuZrQOnh3wpcpAyXPEnsYcJB3fCjkJtFj4NklCRDmbWnlQcg5EMzLEsrqrN9dd0ieCaRONMH7FOcgH+WuVcFXRCpE1oPQ9KefE9A8hcEcQD/sc5JoF13GJTvjjbruCcNEUA3ktH8G16qCbVVNPM2Cf5MiqVjopcr+JRBqszgTMI+WgkNbkhPxJbYY2xFRZsWUX0En3OywMwef88XT1jB7LZUgPX7wJqN; 4:p0UcZKE7o2y+xXgC3pOuf+RHcnXjKb+rfjAEQCnyaUMdLc60YSZ8sQaXYoq1QAWPVb2LAoaom1q28BRpHIZv6bKrujPIDhX1dwylc+GZP4YW+sUy2FA2wOFQ9W00Td4QJiumJXT0Xc7kDRHFeLlqPKZJ60nYYPzU2Bu5unMZ9npiYHgHufi5+CENH9CsR/1NqSVBBq1nFy+70EqZ3hSiEDFOX0ZLKdUj6xhyA3Z7ZmUN8dflYj22SKgfaqqrABtnph2OsbfqWDg8jgCgTopjYw5+2KdV+SRU5gLGBykH1G7+91v0kDJ9KG8znAdp0iI0 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)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3002001)(100000703101)(100105400095)(3231021)(6055026)(6041248)(20161123558100)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123562025)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:HE1PR05MB1915; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:HE1PR05MB1915; X-Forefront-PRVS: 04825EA361 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(376002)(346002)(39860400002)(199003)(189002)(305945005)(2351001)(7736002)(50466002)(33026002)(50986999)(97736004)(48376002)(107886003)(2361001)(86362001)(3846002)(6116002)(575784001)(106356001)(16586007)(316002)(16526018)(101416001)(478600001)(33646002)(66066001)(105586002)(69596002)(81156014)(50226002)(81166006)(5660300001)(68736007)(8676002)(53936002)(36756003)(2906002)(6916009)(189998001)(4720700003)(6666003)(55016002)(5003940100001)(21086003)(8936002)(4326008)(25786009)(47776003); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR05MB1915; 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; HE1PR05MB1915; 23:EYpZQQMarbT1FO+IxCwueAZGLZ8uUBQxOBulR0wVk?= =?us-ascii?Q?xoMk3OkjnbT4q5qLn7wT3iiTQ26brIm3xJk6yJzy63bAZQlV5ddLf/LydfCR?= =?us-ascii?Q?5LZEa8GZCxO4wUwmvKPkoiN68zOWhbWzQOggfapE3JoAozJNjiDobMv2fhmo?= =?us-ascii?Q?83RAM4cn0SPbJ9CDHSdUCtgG5kjug+vNAW9k9jIDUo6bly+eqhfwzDi7kjtN?= =?us-ascii?Q?wxHipxF4e0QUKJluklJ2sbEu9MJpV9e/iGOuezezzMor7p9ujYZiankS72Oa?= =?us-ascii?Q?e+2pBhC30cc8pB4zwl5Zo+CjHYJLbWre9eNv/0Sp+thGNGpcd5W5N6O6y+Ag?= =?us-ascii?Q?KzkEOm5rCwozceWCOs7f9yJjkkoQfhc/oe6qGLaQh2ifAH/tQIo9sK+3dYp3?= =?us-ascii?Q?8n4+OOqUsknvJekwgsoGtjpSDg4tD4BZtBRUDyWe1PoPVZ1/9GMPWJWzLOW6?= =?us-ascii?Q?vqf5s+eEA9K0bU1T62/SE89gGqGbbfZYCRRWrmmb5turlQ1Z47nkh4Cq4gCL?= =?us-ascii?Q?uRTPYaNsF+iRvbceWxs0G2G5+N+XLk0Wg5dhQQa//BLSOgjG7JFUmYAKxDV8?= =?us-ascii?Q?iNg3PGalDHyolwhTXCopWhOEMLxWZyR/dnoVlnlbZgz+tYUjcfavMLw67zpa?= =?us-ascii?Q?THF6T1qSCZ3m2unMZQBLWBZ1oU80LvhPykQ5l4gVT1TPJr0Y62R4ATFBAXZO?= =?us-ascii?Q?EfesLtlMq8lCzyAF3nvEsnkfDY0LiDw6TGr23cRrPMAg0d2HI3wjhKsDZXOk?= =?us-ascii?Q?Gh3HroFK746Uy4d9NxV6Gs4ccueUVM/OnamkoUC/H4peTDCIZMLYLBeRVkAK?= =?us-ascii?Q?SscE0vAn75yo8/OimivB5mpbjrj0OhZZMxgC41g9PxgPubU/5zBYrcCKZ0LI?= =?us-ascii?Q?1d1oBp0UF81uWIbWFYEYEeNWNON4u8mQ+esUW3UPOqacgLBYPR1HCEEKUvDB?= =?us-ascii?Q?U6bZ30sbIRcimCJyPVdRvZnwXMEN8x/r84w1RDuGCCelqRDNCwjPyO39tcWa?= =?us-ascii?Q?SBNBC/G0BzJuFs6Ny6iL3KXfFFC2+tDYR1RKnAJGA60cteCEnXDouuCTSEjt?= =?us-ascii?Q?ZlxCRcO7BfX+OUWn+UZSsHG3h6S+A+H3MrrqojSgPQx2fBcskS4vFQvuZx4f?= =?us-ascii?Q?aH19iKBxy1sxKkHw/6NGLYwvmVGd34YWOrl4Dcvdl0pzvdoTr334bRSIhhQI?= =?us-ascii?Q?QCakFBZC0PaMYI=3D?= X-Microsoft-Exchange-Diagnostics: 1; HE1PR05MB1915; 6:s/T14bPIw2lcv/atIR/d4u7uxcdYq0Gnwcp0/bgphkAZIHYDxryckX/FMDcm55erOTgkKD5Pckf69UxBS5fiDqJxbsM/lHcSKl4+RVgeEroclXQlOfsPCT2GVREw9JAyp1XcAk2jF12Gnj9LEtuq/HnMMQff11MEd9Pcl/1+XU3tYrLhAH8JL6yT+CmnIXdmmNPpCXteP0sIAoJtOgEHATAFCnbfjYqGYK4/i7EJioaaK9OvGS40J9r4lOEq0QNI1wFdBpZg9HFo6QvM5FYWZF27LGYmNHg2U5ox+fiinZQtkiVfwMJh+Ifh2dXpZg14Bi5Ctv+lsA3qN3xNDgZDRrxs16Bhi1QBuKEtgcGWD3M=; 5:oHRbqJb4Qjg95T5Z5FUVRi4FSHbsGCHQlqqTPwHZUItwkMsPXs9csAzVd8WCn94vTrV9yx7oodA3kR5Xj/jttRI8+tAalEWqGCcXLyugIKSIUGILPA75Yxb8zTCa7BhMOyFkjmQdqmyHOat2F3c5ckPBzXMFrS6C4uA4gD0Cgmo=; 24:6h/2oA9fCx4LSGwa0Soh6eaOQYW4B/EJ92LvFOyQznV+Z6q6ZiXVisCjFbjBwiHeVyJNrrttx6RfkFM/zYuJMmaGeNLzs1CK9fX3MQKfD1M=; 7:ifyqt/ub9t9PV0QyF+iFldMAy/17wVe4mop+qNU+1OPS78VyG3VoUfwhVAHtOvWBuuRno/ogbu/JeDyVkYWilxlEhYi9GKKhl+yKtb99no1rTcgF9hXqTZbg+rfMBvBlp20d9+Bh7NGrgCljh7M2OScyleL5JWrnl6cQFOiZRTouTTUgsjhwMyod59dJgt+hJsZwpR0l1Kv2CT0lck5Sr5rpBNCGUBfzgf8QI+cch/nNS3FEpwJ4gsVm6R7d0sdQ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2017 15:42:47.0957 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 066dc462-4811-4b6d-b426-08d52463dd83 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR05MB1915 Subject: [dpdk-dev] [PATCH v3] 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 15:42:51 -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 --- 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 | 33 ++++++ drivers/net/mlx4/mlx4_prm.h | 16 +++ drivers/net/mlx4/mlx4_rxtx.c | 241 +++++++++++++++++++++++++++++++++++++---- 5 files changed, 269 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..237528e 100644 --- a/drivers/net/mlx4/mlx4_ethdev.c +++ b/drivers/net/mlx4/mlx4_ethdev.c @@ -1013,3 +1013,36 @@ 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