From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0060.outbound.protection.outlook.com [104.47.0.60]) by dpdk.org (Postfix) with ESMTP id 285D31B34B for ; Tue, 3 Oct 2017 12:50:09 +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=Q+UjhX1toeXTcJypU/M7lgtWzm0vPW2UZ7s/FukmMhI=; b=VDdDCy16dj0eimUYifAaHDoHUH15crrAsOt0YUHm0j60j7H7vypeUZ60dRGS8JisRLbrNdzx2bxC6N8G6jpW9HYAhTu8ABrGalTqC70MegZgZr9Grdk83puNlF7OVmcL/AIc1kCBAoiuL1irRouXP70yA5abcYUn8X14UgHLBIk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; Received: from mellanox.com (37.142.13.130) by AM5PR0502MB3042.eurprd05.prod.outlook.com (2603:10a6:203:a1::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.77.7; Tue, 3 Oct 2017 10:50:07 +0000 From: Matan Azrad To: Adrien Mazarguil Cc: dev@dpdk.org, Moti Haimovsky , Vasily Philipov Date: Tue, 3 Oct 2017 10:48:30 +0000 Message-Id: <1507027711-879-6-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1507027711-879-1-git-send-email-matan@mellanox.com> References: <1503590050-196143-1-git-send-email-motih@mellanox.com> <1507027711-879-1-git-send-email-matan@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: HE1PR09CA0085.eurprd09.prod.outlook.com (2603:10a6:7:3d::29) To AM5PR0502MB3042.eurprd05.prod.outlook.com (2603:10a6:203:a1::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c4a0ce19-1c4c-49d9-54ea-08d50a4c83ce X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254152)(48565401081)(2017052603199)(201703131423075)(201703031133081)(201702281549075); SRVR:AM5PR0502MB3042; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0502MB3042; 3:07H2w4GNKZi6gc3zE/J3mepfn3RkrzdhPn/HLsfmJMyvpWixQAq6RDJuZzqe0GeqZZDbaf6Rn7kH1mqUvK6Gbwooav4zUBJ+HZMnoz0r9jsp1jpJ2TrxDl1eWB/wVapG2cQbazV7cqQyNONNcS+2jgFh/Xo+bkqrIuuVvavwLyIARi4VsCHx4ouDQAUe4m/Gf/ZM7m3CgfCNBMORkWIxHRsnnNvatcIAwGCDDxP1vQnsRc9iPUeM1Q2MX0gbNx6o; 25:t5tLMrKXf/c5t+LmlceF5ysIIOIS7mdH4Ef7/hWEtK/J/yc/2WJJW6N0sDmKNVoDJ7UKv/zpSjuYC4NqK0I9L4aBKK3PdII3eyGIK9D/dctoby0rvxRSRP+T7u0eRFpkZVTtfvID4x3tYKyCLLvZsl+GrHl0Bep0+5yg3UF9qfks54X1cwlrxmUfxiLOn/UCRrFW2xeB/5XYT61CH/y2HVPjJvTCKNmuny0/SYCvvdBGt3bK2uF9JmTOzzG0a31il+Rbtgy+rEZHGB6NodouLc1RRopYaH6jQNowweGxc4jklFjWCZ4eOPHLXMrvJGse6xHeiOf00yyQsFPTCCmWtg==; 31:lvZzfrmUumuZB0XfFOJAIQUy8ASFNgaxoX+uCdpwc2piiosutkNzPTz43gYUX/ODiXfWYt3Nrp4jqq/IfXN5r5P99b2/sB5cj9FTgfwBZsZZcc8iN+l6C5WgUVdd5c7rcgkm/Im5nn0AAAurHRNlHwRm4+OeIT7eidezDr9Qo93uCNvDO+6z9+UPaitvOFPno7ooCjlgsnylrDhGLnp2/CQKJ/YgDDbIfiACL9x8xpQ= X-MS-TrafficTypeDiagnostic: AM5PR0502MB3042: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; AM5PR0502MB3042; 20:GFVQE11ln7nhf8GA9EFYlwQ54lZR+hOwKyPeccC+SSEwSv9sSCfgKYhRJzCwifRCkz4Zh+yslfxY779kSp6iqYsm+Ks1zU+3DVBBvlJ4SSq4xRG1yrNmhBrtH3ddofi6a44Gc/sNzoDYqzrqSMYQMp2COs+lT0NzbXnZMkqqnR1vZCsuoL+U7GNSoFoFcDdzdl5U98bHalyAB8s4CfGCZmmLVgF+t5h1WevfiAk5+bte+lb9vk0abtCjDy6VVN1nKVEbq7EW2PUc9Z7/6dEowhuYR379jeeoh4qttGuTdzs183rsKRyd4jfpouWOJ+TzvDw+kAD+8/3MQQ9TAqth/cEQDBfMIThbSRjOAOZZZYANu2ajnJOO0ALBoiuNCOpK+XnEO0ZEWagO1Wn+Wi0mHw1T2NU5VT4zL3XePyU7IqKy+QStm6hkVNqTd6z9TAs6j6/lhIzE0FS+kC9YVdYVu7xNyK9xdlIirMyqTaqYQRwiZCgS2/NPUpHulaT5iMUd; 4:l1UnPACXzMaqix76Dc5430CAs+27SmXpjPLHrpHEcaSKx0TpMjj9RGLfQWP6OQivYeAUM6N8p+srnXSC/h0WSHNuOzTqRkmwzRTEzvKfwwlhmHWTKQSZNUWzEOYKTShQUiyoYN8I9lXz02O1yK895yDYcok5HPqE8mrOmVXR8Rt9xgMIdGhnF08AHCogoDSJqgKvX8uldMaJqyyYspNSE7VC8jcG78mXNyo0papkzQde2QSqH8IN5X+BWX4dnghm 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)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3002001)(100000703101)(100105400095)(6055026)(6041248)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123558100)(20161123562025)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:AM5PR0502MB3042; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:AM5PR0502MB3042; X-Forefront-PRVS: 044968D9E1 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(376002)(346002)(189002)(199003)(33646002)(107886003)(5660300001)(55016002)(105586002)(47776003)(3846002)(53936002)(2906002)(66066001)(50986999)(76176999)(16586007)(86362001)(575784001)(316002)(101416001)(81156014)(305945005)(8936002)(81166006)(54906003)(8676002)(33026002)(50226002)(7736002)(16526017)(97736004)(48376002)(69596002)(25786009)(478600001)(50466002)(6116002)(4326008)(106356001)(5003940100001)(36756003)(6916009)(6666003)(4720700003)(21086003)(2950100002)(68736007)(189998001)(309714004); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0502MB3042; 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; AM5PR0502MB3042; 23:H7cy8Ksiyi9wN8Y7hXwblgschj3mm4U6ZJBbKCj?= =?us-ascii?Q?DJbXVJ4agdc1H9PmhwmAmWxP59b6vYpsEyk9jKzwmDol6eMiI0iAFLOcT0x/?= =?us-ascii?Q?DuZ1VEUWuHurnTQbfGWyKM8uJ9x375NSbCsR2bh5VDAfe6lvLUgBm4fXZIgK?= =?us-ascii?Q?6VqbLBuj59y91kll3PeBELTexNF+sAnt1bH5BOFQqIBpH/alONSQ9Rg099AN?= =?us-ascii?Q?Jj/R3bjYN5qCJaodyjpEqOJfVBchZlya7AL98QxRaaWcCdp+pGA9tXiaoFWv?= =?us-ascii?Q?/Vuk7e+JF4eMGxgc/PW6Hnay4UvOnwlGjYxXIfIdfq1jmFkcQ6J797lr4CID?= =?us-ascii?Q?EKN1k/Wnq7SmygxJ7vS0GneTAvJO6H+NItg69/ZkefFRiLAx8JRtu6wal1X8?= =?us-ascii?Q?eIPOEskAarjKcUo6Wp5duC0gj0fbLPtc4PkB+lI2uL7axQ9S4VtccgReLEZM?= =?us-ascii?Q?gUBLsWYEf6vnohL5etzoTuuvc6S2jPXJ7r0LxBBkwG7SWhWcBftDM+VMIJC5?= =?us-ascii?Q?C/K3+iTz3W+dIbtxLAMdMHkLBq95NUxB4PRbwcS2n3mdi5Zc80B4kasXpkx8?= =?us-ascii?Q?dRhmp9QLsFKseO4GCgUvf8UGmvesbYdWq40UFJBxyN/dklODE4ORYvbNJYre?= =?us-ascii?Q?4vvDbouiGDaG73Fl/Jo+FRKFJOHWRYWRq/9WcAkPcnLHlTUdUeYAxO0pZvei?= =?us-ascii?Q?fPgUyZt1t8CfW0Je624tw0S0pRU+yasdJFh90Evok8NdSQJl83E2637w3KdM?= =?us-ascii?Q?DJ7bTkOxfUy71pxHjKyLNs2CsU/wQfq7IxyFqIRRbWdHORViNadcwnzf2/er?= =?us-ascii?Q?Cua/LvsJKwE+D8XfKnh0zHLSf1jPRcX9GTQ1A9TtCkyWmO1vlo05e4wc5QHd?= =?us-ascii?Q?X1ryTduTJa66y4fUIoWpmqt1RHZecuhphZXJOYAREJpWu78rBjcBLja5ALTc?= =?us-ascii?Q?HS/V/HXoxFtsU5xM0AqO2UFxyy8ZPOPqTm4yl4ZejmVKrKENB0HgQnpUaq4G?= =?us-ascii?Q?3YG9hO5MR9waa9jPjgsC/161NX7jMmBZdhtXUHCSEO2WF6afLhmCihcxl5Wy?= =?us-ascii?Q?Rl806bun2lG0ccjRme7Mw+Q33uK6TJe0gSBr3KY3pCzpMW9yBmqUuvaikYaK?= =?us-ascii?Q?nElV3x/i/ftbl4WTtFUNKuyEtQ1vUEfAe+fdz6tQd44M8vuCNx9F0zP1y/nT?= =?us-ascii?Q?qjaKSKk899YRJRcxm1Pro+bdMOcPbv0qIbOP5?= X-Microsoft-Exchange-Diagnostics: 1; AM5PR0502MB3042; 6:I5Exig56hqkWfDr5eRDSR+PESdbic0dLQSL3itnQLmAXCmrMZCVnVQVj9PZG5aQUFJU//HuxpPBeIqNrKTpBqP2MMcdpsrNQbBWQCTlynrwGDZifEDrluxGCwCaV1N4M9ZL04gFR8CWcAsgT4CZZ+dj+x1bydI3uNGojqQm8TGaGleg6VVEitm1f0hn+eTch9ecGP9AW/w1UOqzhh8veV2/W8HemhVJr3UxS9CAwFWLVIWj9rfAGd0AHUw5DuAg+L2vZN8BHIf9uUZL/8DEZOzFus6RBc2tzlJROkW+wjJDJb2r9YD48AatRar0GOcma0rOaZB9yxXa++NHPW+R/RQ==; 5:76pqe3z5GxM24LtP+3Vawy6gdX7KDuyoeXtQetLzNaKMT57zZiqo0dEtJkFzIvToPkbrqOLEwNIEadIaas9sMb5oGGtOLT0F+vYym7bcTIZHfjQh8tXthgJQKsbT5TrHQid7Y2SXUCurbuR+GURyVZMwm6SSB5TFrLPQfyWh8zA=; 24:pLN14ARL6Byz6DJBAyH7HGnoXPnHwH8/KfzdP8grfzfxYBoI1DZjVR3lIX+pm7Rgsg/DZ/wvobaYFGvWjpmQSPhXYZ06VflZoSceq+nbcvc=; 7:0uPnpaenaG8DInZByBdOCtdsD2lJMCH9KpYU691e0Oa63Urav5dXYzbHZHeyRRaWHhRNuOrgQebh7MygEGAsNpkIeC15/2W/kxD9NL2IqwqMM4pPro98Lukang95cBLMCSJNHob5PF9zqVYdtojy6RrU9KXU5iCFZ5wumg+WoTdUFFY2gcvHcLiFObV2kGlTJ/SAl33Zted3qcZz8v1FGuH17hSmG4I5197kk9rcK+s= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2017 10:50:07.8079 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0502MB3042 Subject: [dpdk-dev] [PATCH v2 5/6] net/mlx4: get back Rx checksum 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: Tue, 03 Oct 2017 10:50:10 -0000 From: Moti Haimovsky This patch adds hardware offloading support for IPV4, UDP and TCP checksum verification. This commit also includes support for offloading IPV4, UDP and TCP tunnel checksum verification to the hardware. Signed-off-by: Vasily Philipov --- drivers/net/mlx4/mlx4.c | 2 + drivers/net/mlx4/mlx4_ethdev.c | 8 ++- drivers/net/mlx4/mlx4_prm.h | 19 +++++++ drivers/net/mlx4/mlx4_rxq.c | 5 ++ drivers/net/mlx4/mlx4_rxtx.c | 120 ++++++++++++++++++++++++++++++++++++++++- drivers/net/mlx4/mlx4_rxtx.h | 2 + 6 files changed, 152 insertions(+), 4 deletions(-) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index a0e76ee..865ffdd 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -535,6 +535,8 @@ struct mlx4_conf { priv->vf = vf; priv->hw_csum = !!(device_attr.device_cap_flags & IBV_DEVICE_RAW_IP_CSUM); + DEBUG("checksum offloading is %ssupported", + (priv->hw_csum ? "" : "not ")); priv->hw_csum_l2tun = tunnel_en; DEBUG("L2 tunnel checksum offloads are %ssupported", (priv->hw_csum_l2tun ? "" : "not ")); diff --git a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c index 95cc6e4..6dbf273 100644 --- a/drivers/net/mlx4/mlx4_ethdev.c +++ b/drivers/net/mlx4/mlx4_ethdev.c @@ -553,10 +553,14 @@ info->max_mac_addrs = 1; info->rx_offload_capa = 0; info->tx_offload_capa = 0; - if (priv->hw_csum) + if (priv->hw_csum) { info->tx_offload_capa |= (DEV_TX_OFFLOAD_IPV4_CKSUM | - DEV_TX_OFFLOAD_UDP_CKSUM | + DEV_TX_OFFLOAD_UDP_CKSUM | DEV_TX_OFFLOAD_TCP_CKSUM); + info->rx_offload_capa |= (DEV_RX_OFFLOAD_IPV4_CKSUM | + DEV_RX_OFFLOAD_UDP_CKSUM | + DEV_RX_OFFLOAD_TCP_CKSUM); + } if (priv->hw_csum_l2tun) info->tx_offload_capa |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM; if (mlx4_get_ifname(priv, &ifname) == 0) diff --git a/drivers/net/mlx4/mlx4_prm.h b/drivers/net/mlx4/mlx4_prm.h index 57f5a46..b4c14b9 100644 --- a/drivers/net/mlx4/mlx4_prm.h +++ b/drivers/net/mlx4/mlx4_prm.h @@ -70,6 +70,25 @@ #define MLX4_SIZE_TO_TXBBS(size) \ (RTE_ALIGN((size), (MLX4_TXBB_SIZE)) >> (MLX4_TXBB_SHIFT)) +/* Generic macro to convert MLX4 to IBV flags. */ +#define MLX4_TRANSPOSE(val, from, to) \ + (__extension__({ \ + typeof(val) _val = (val); \ + typeof(from) _from = (from); \ + typeof(to) _to = (to); \ + (((_from) >= (_to)) ? \ + (((_val) & (_from)) / ((_from) / (_to))) : \ + (((_val) & (_from)) * ((_to) / (_from)))); \ + })) + +/* CQE checksum flags */ +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_TUNNEL_IPOK = (int)(1U << 31), +}; + /* Send queue information. */ struct mlx4_sq { char *buf; /**< SQ buffer. */ diff --git a/drivers/net/mlx4/mlx4_rxq.c b/drivers/net/mlx4/mlx4_rxq.c index d7447c4..053318f 100644 --- a/drivers/net/mlx4/mlx4_rxq.c +++ b/drivers/net/mlx4/mlx4_rxq.c @@ -267,6 +267,11 @@ int ret; (void)conf; /* Thresholds configuration (ignored). */ + /* Toggle Rx checksum offload if hardware supports it. */ + if (priv->hw_csum) + tmpl.csum = !!dev->data->dev_conf.rxmode.hw_ip_checksum; + if (priv->hw_csum_l2tun) + tmpl.csum_l2tun = !!dev->data->dev_conf.rxmode.hw_ip_checksum; mb_len = rte_pktmbuf_data_room_size(mp); /* Enable scattered packets support for this queue if necessary. */ assert(mb_len >= RTE_PKTMBUF_HEADROOM); diff --git a/drivers/net/mlx4/mlx4_rxtx.c b/drivers/net/mlx4/mlx4_rxtx.c index 2757aec..1e91aaf 100644 --- a/drivers/net/mlx4/mlx4_rxtx.c +++ b/drivers/net/mlx4/mlx4_rxtx.c @@ -562,6 +562,110 @@ struct pv { } /** + * Translate Rx completion flags to packet type. + * + * @param flags + * Rx completion flags returned by poll_length_flags(). + * + * @return + * Packet type for struct rte_mbuf. + */ +static inline uint32_t +rxq_cq_to_pkt_type(uint32_t flags) +{ + uint32_t pkt_type; + + if (flags & MLX4_CQE_L2_TUNNEL) + pkt_type = + MLX4_TRANSPOSE(flags, + (uint32_t)MLX4_CQE_L2_TUNNEL_IPV4, + (uint32_t)RTE_PTYPE_L3_IPV4_EXT_UNKNOWN) | + MLX4_TRANSPOSE(flags, + (uint32_t)MLX4_CQE_STATUS_IPV4_PKT, + (uint32_t)RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN); + else + pkt_type = + MLX4_TRANSPOSE(flags, + (uint32_t)MLX4_CQE_STATUS_IPV4_PKT, + (uint32_t)RTE_PTYPE_L3_IPV4_EXT_UNKNOWN); + ERROR("pkt_type 0x%x", pkt_type); // + return pkt_type; +} + +/** + * Translate Rx completion flags to offload flags. + * + * @param flags + * Rx completion flags returned by poll_length_flags(). + * @param csum + * Rx checksum enable flag + * @param csum_l2tun + * Rx L2-tun checksum enable flag + * + * @return + * Offload flags (ol_flags) for struct rte_mbuf. + */ +static inline uint32_t +rxq_cq_to_ol_flags(uint32_t flags, unsigned int csum, unsigned int csum_l2tun) +{ + uint32_t ol_flags = 0; + + if (csum) + ol_flags |= + MLX4_TRANSPOSE(flags, + (uint64_t)MLX4_CQE_STATUS_IP_HDR_CSUM_OK, + PKT_RX_IP_CKSUM_GOOD) | + MLX4_TRANSPOSE(flags, + (uint64_t)MLX4_CQE_STATUS_TCP_UDP_CSUM_OK, + PKT_RX_L4_CKSUM_GOOD); + if ((flags & MLX4_CQE_L2_TUNNEL) && csum_l2tun) + ol_flags |= + MLX4_TRANSPOSE(flags, + (uint64_t)MLX4_CQE_L2_TUNNEL_IPOK, + PKT_RX_IP_CKSUM_GOOD) | + MLX4_TRANSPOSE(flags, + (uint64_t)MLX4_CQE_L2_TUNNEL_L4_CSUM, + PKT_RX_L4_CKSUM_GOOD); + return ol_flags; +} + +/** + * Get Rx checksum CQE flags. + * + * @param cqe + * Pointer to cqe structure. + * @param csum + * Rx checksum enable flag + * @param csum_l2tun + * RX L2-tun checksum enable flag + * + * @return + * CQE's flags. + */ +static inline uint32_t +mlx4_cqe_flags(struct mlx4_cqe *cqe, + int csum, unsigned int csum_l2tun) +{ + uint32_t flags = 0; + + /* + * The relevant bits are in different locations on their + * CQE fields therefore we can join them in one 32bit + * variable. + */ + if (csum) + flags = rte_be_to_cpu_32(cqe->status) & + MLX4_CQE_STATUS_IPV4_CSUM_OK; + if (csum_l2tun) + flags |= rte_be_to_cpu_32(cqe->vlan_my_qpn) & + (MLX4_CQE_L2_TUNNEL | + MLX4_CQE_L2_TUNNEL_IPOK | + MLX4_CQE_L2_TUNNEL_L4_CSUM | + MLX4_CQE_L2_TUNNEL_IPV4); + return flags; +} + +/** * Poll one CQE from CQ. * * @param rxq @@ -600,7 +704,7 @@ struct pv { } /** - * DPDK callback for RX with scattered packets support. + * DPDK callback for Rx with scattered packets support. * * @param dpdk_rxq * Generic pointer to Rx queue structure. @@ -665,7 +769,7 @@ struct pv { break; } if (unlikely(len < 0)) { - /* RX error, packet is likely too large. */ + /* Rx error, packet is likely too large. */ rte_mbuf_raw_free(rep); ++rxq->stats.idropped; goto skip; @@ -673,6 +777,18 @@ struct pv { pkt = seg; pkt->packet_type = 0; pkt->ol_flags = 0; + if (rxq->csum | rxq->csum_l2tun) { + uint32_t flags = + mlx4_cqe_flags(cqe, rxq->csum, + rxq->csum_l2tun); + pkt->ol_flags = + 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; diff --git a/drivers/net/mlx4/mlx4_rxtx.h b/drivers/net/mlx4/mlx4_rxtx.h index dc283e1..75c98c1 100644 --- a/drivers/net/mlx4/mlx4_rxtx.h +++ b/drivers/net/mlx4/mlx4_rxtx.h @@ -80,6 +80,8 @@ struct rxq { } hw; struct mlx4_cq mcq; /**< Info for directly manipulating the CQ. */ unsigned int sge_n; /**< Log 2 of SGEs number. */ + unsigned int csum:1; /**< Enable checksum offloading. */ + unsigned int csum_l2tun:1; /**< Enable checksum for L2 tunnels. */ struct mlx4_rxq_stats stats; /**< Rx queue counters. */ unsigned int socket; /**< CPU socket ID for allocations. */ }; -- 1.8.3.1