From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0069.outbound.protection.outlook.com [104.47.0.69]) by dpdk.org (Postfix) with ESMTP id DC9F21B33A for ; Tue, 3 Oct 2017 12:50:07 +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=8Yl8iC5nycn7NPPGtnB5+2igkGVbMeYy0UW+7sYyU/Y=; b=XLEM2cB0k7obeNXMzbB0ZAQZz06b2osQpyTThhqh7/l3n+0Ut2Tqfl7YFBXmQm8KnVd+ncFnAlgtShxf+AAiWWeQHXcb1F0cgb3DY873ZWaHtto6Rcrep0sHj4qkn7RAj4ro5ZUcc2AkEDeFYxjYpzx8rvMNASkEfohR4YQ4dCs= 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:05 +0000 From: Matan Azrad To: Adrien Mazarguil Cc: dev@dpdk.org, Moti Haimovsky Date: Tue, 3 Oct 2017 10:48:29 +0000 Message-Id: <1507027711-879-5-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: 1a34e0af-5013-42c1-76cd-08d50a4c828c 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:x9Tl20kbGaOGo2vbRPyifqA/5b+ZR7vRK1p5qbbfgqylCQ/eVJfj0t+YtA+GOkfUSf8uxL2ofNMpSldKBZ731+LnscT3KY3W6MEYwBP/yB/88z2oyc0JwGOZ5q16YzXs59laXpKng+hYPyZ5nhGwO8rDuVxiWMhhlpP5+wm8v+cf218NcqhbS6mAkrvpGHpuOcQpzrKPgo/TOUaNtSoZaNSnOh6PG7QK+47ZW6olqNBwwb+Zxw94kSq6Fu06xbPq; 25:hf0GPR0m4FX7/S4vFeFtIHR5tLnfc93qH4ligemD4a36HHasNNFVroAsXre84g/PFk8pEKLzfHyWFjnWDFCfSb2gJI5DDPYThDIFEnwGWZJrBpUH1glbdDEOGTkPgA0nxe719FyZIJb0U77MnDwVSShz86w5gut78bHJsJBma2s9N590kjiIwY6icjl1wv18vGy8P18laNJw1YkGLbqpUzzMDPVj8F5JJJrIVHqC8TIxAoz6+MN7fJ19qGGmIsn+JgMHT33nTTA+Sy+kbkTpZ1t2gBnw9NG1/LgRVebRUubbkNTH0IlR9BZKP/orstULk2QbhHR0EwIOYbKzq1Pl9A==; 31:YPvoQ4dApaUZENQlpSeH9muQzjYQOuvlZ8mDmWXJNT4UTlzirtMUOWg/FQKdbeeyBl4k89mXCRk4OUretpJd1ZXFseemx0Z8dhFhZezXk6ZzJ9kQ1vlBWY/ahBZ+SBE+ZLHqzr+A7sfGWlkfkdYf4RBrDyE6roSXXAJ6XIbKC5isQ82SxJjDrWIyNWy8Av1FYttS8CzLYOxmAUG5xriUg0wGNbCb8DMnt6GNfOm5MjU= X-MS-TrafficTypeDiagnostic: AM5PR0502MB3042: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; AM5PR0502MB3042; 20:ORcWZkbagh1wohbUEESlCT6USKV2Xrz4MLSVWnNXZq0PwUvnj1U5L21UpQ2unWsHTjs5qAVPmOq0zrW6QFGXVntckQR7kk6/D9TAWS/osTJcYFuQpsuQy23sCsZV361bIhMWgrDXUjrDwrM3DRAfVTQdkmEOm4pHXhRRxOZ0T2KYuKaNfAOwTDF660OfU2oUQNg0oGo+pTaYiiIg8d/aCxNZkRK7YyU9fbhojOgvu6ymkG2MyfKzJzQMnGGp7/RurBMUg1Sy6hpoDDKyXu2dOJ1RsOMcuRaHimmd0EdWr2xuzYiPV7OhWUUWhzUYnETVgH/orfcvgfJBPW04IOZzsAMSVTbcdM+O6IeLlaEQuf1CdU03+rLMsetYAG1Nh+TkigDiJCzPayCRbjTUczYYJJxk5RXjF8VYxYsnnHqRCbUK9L+ppBwbHSfg+eGf4NeWBIAD58MPd67vpXpAkTRk3+PPysRiGZpe4EBi+CG3j38iAV2GMp55Y3RYBWlooNpO; 4:hjB8F1lklYq4/sQElxkt2Mhxo8RbA7D7MejNo3nLr/43KpbM0GhvHFw0JkjurbBN0BG8pQKi7tJcTQtLNm8MYajt8X5LkJpIaymd1MTdbFsNJ4VDu5YDIs2LtUSvIbqhOhVyPtEI7eJVye+8HTathm5n0G0Wem+ve46ba6x8W9JMUc9PWC9YGbf2TyhbnTiyUc4tMDO4EirRKvJaZ3afiwhWwaVKGntYtk7OQCGF8TPSAkVeSr1IF8HyOYc22LeGujRQ7yrwtW+LvguZroik5iIzOdjjEZgRSP9019ma2uc= X-Exchange-Antispam-Report-Test: UriScan:(60795455431006); 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)(8676002)(33026002)(50226002)(7736002)(16526017)(97736004)(48376002)(69596002)(25786009)(478600001)(50466002)(6116002)(4326008)(106356001)(5003940100001)(36756003)(6916009)(6666003)(4720700003)(21086003)(2950100002)(68736007)(189998001); 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:6W8fez6Rbp5NaKUwC7SkXZ/pm0iQO82VxFK3GiD?= =?us-ascii?Q?0FZsI4bL4MTSFxrN7t3CaUNg0QoDI/SKqIHJOxn+8E05A9pT3Rji9rRBqVS3?= =?us-ascii?Q?QLBT2ZH+WE0ZU0jHTi0P7wmPdho6g8U/9zTFsewRP6utKHAMYMOEYnuHDh1s?= =?us-ascii?Q?/o00XT1dFFK2s7gVqjUUMMch6ZYf5UhpouO6kldx0iX/bL3FK91QTsGN7nHZ?= =?us-ascii?Q?x0EmU0/yp/tmbOKoDKHYyltg/VtQDCclmvlyS0ziElZRKD3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XZthpSU5wSRHS1NSYb0+94x6VWmhA=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1; AM5PR0502MB3042; 6:ZbvNNZrynSEOMSOY7XAreSh4G5KTVBiyUZelJDkrRYe+ifwhDy/YirlhbQsHKLz8C13kYtzbBY2BlM33ofEasURlvEcTKzbHz5VqROfAeyb6MNhfP1Vs6n6DHtMT5/ZToVGfRxP0c7V3JgBKx7WfZw8QytEg6KMVislAqSCx1UOIBX93pB0yo8/MfCDl5y2obfHtIKEoiCnfhadn6GrGxbp6Eqae01i5BXui3Owi/oSiV1LdoQLlkbrBkHji2TFHQ6RZrFoUtTDvHifQ1ypX3etw45s0/tbyD47iV4XryPhDk0+SU1Pw2t6kIwSovS+ULAIluc6pCY4tQxSiIJYN2g==; 5:CxX/6D9qmbIo+fU/xSLX+Jfkmuct1h+Jzs3Mq2C0HyaPBSUPz1fHCLoFTSaV9r0BViYJ5hVLSmNwdeD0LgtmSqLrsLUNfQulBgk8GiDSQ1hYRL+myicspZpACRwt/EO++3uJOOwcgRIqCQLdviNJmq5vEeRFn6JdCGDkR70z0p8=; 24:Ea/mH3cENSAQwvJYsUdRmytLLXfWk0APSPOpgdybumNKr/xJieEVXBfCTa+N3mz2Hy8vrt2EchU+GTeoIdzyjILtdeajTahEA8eOG0HoQPA=; 7:rs5adbe1Sge4HA7gKqy/UCxlcSlQMPmRFr69NSSNBjq+9L982vQNzpHg82qmJbvAZOf1AuGmX0UcymNL4WypsHbaENJQ1K5/5IJW6xj5hBX+/RbUtnm3qblGQjvz+uNuJMiGEXUuHsIGOtAmOXxXDUDGS/a6PIsy0gJ7Hyh/1OIgYBtgjS5DRFM/ysMb/VLH4kZbHBfLoTnvPUnKid4XKl7e1VpJsg9mWjsVGPJEkWo= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2017 10:50:05.8703 (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 4/6] net/mlx4: get back Tx 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:08 -0000 From: Moti Haimovsky This patch adds hardware offloading support for IPV4, UDP and TCP checksum calculation. This commit also includes support for offloading IPV4, UDP and TCP tunnel checksum calculation to the hardware. Signed-off-by: Moti Haimovsky --- drivers/net/mlx4/mlx4.c | 9 +++++++++ drivers/net/mlx4/mlx4.h | 2 ++ drivers/net/mlx4/mlx4_ethdev.c | 6 ++++++ drivers/net/mlx4/mlx4_prm.h | 2 ++ drivers/net/mlx4/mlx4_rxtx.c | 25 +++++++++++++++++++++---- drivers/net/mlx4/mlx4_rxtx.h | 2 ++ drivers/net/mlx4/mlx4_txq.c | 2 ++ 7 files changed, 44 insertions(+), 4 deletions(-) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index b084903..a0e76ee 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -397,6 +397,7 @@ struct mlx4_conf { .ports.present = 0, }; unsigned int vf; + unsigned int tunnel_en; int i; (void)pci_drv; @@ -456,6 +457,9 @@ struct mlx4_conf { rte_errno = ENODEV; goto error; } + /* Only cx3-pro supports L3 tunneling */ + tunnel_en = (device_attr.vendor_part_id == + PCI_DEVICE_ID_MELLANOX_CONNECTX3PRO); INFO("%u port(s) detected", device_attr.phys_port_cnt); conf.ports.present |= (UINT64_C(1) << device_attr.phys_port_cnt) - 1; if (mlx4_args(pci_dev->device.devargs, &conf)) { @@ -529,6 +533,11 @@ struct mlx4_conf { priv->pd = pd; priv->mtu = ETHER_MTU; priv->vf = vf; + priv->hw_csum = + !!(device_attr.device_cap_flags & IBV_DEVICE_RAW_IP_CSUM); + priv->hw_csum_l2tun = tunnel_en; + DEBUG("L2 tunnel checksum offloads are %ssupported", + (priv->hw_csum_l2tun ? "" : "not ")); /* Configure the first MAC address by default. */ if (mlx4_get_mac(priv, &mac.addr_bytes)) { ERROR("cannot get MAC address, is mlx4_en loaded?" diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h index b6e1ef2..d0bce91 100644 --- a/drivers/net/mlx4/mlx4.h +++ b/drivers/net/mlx4/mlx4.h @@ -93,6 +93,8 @@ struct priv { unsigned int vf:1; /* This is a VF device. */ unsigned int intr_alarm:1; /* An interrupt alarm is scheduled. */ unsigned int isolated:1; /* Toggle isolated mode. */ + unsigned int hw_csum:1; /* Checksum offload is supported. */ + unsigned int hw_csum_l2tun:1; /* Checksum support for L2 tunnels. */ struct rte_intr_handle intr_handle; /* Port interrupt handle. */ struct rte_flow_drop *flow_drop_queue; /* Flow drop queue. */ LIST_HEAD(mlx4_flows, rte_flow) flows; diff --git a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c index a9e8059..95cc6e4 100644 --- a/drivers/net/mlx4/mlx4_ethdev.c +++ b/drivers/net/mlx4/mlx4_ethdev.c @@ -553,6 +553,12 @@ info->max_mac_addrs = 1; info->rx_offload_capa = 0; info->tx_offload_capa = 0; + if (priv->hw_csum) + info->tx_offload_capa |= (DEV_TX_OFFLOAD_IPV4_CKSUM | + DEV_TX_OFFLOAD_UDP_CKSUM | + DEV_TX_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) info->if_index = if_nametoindex(ifname); info->speed_capa = diff --git a/drivers/net/mlx4/mlx4_prm.h b/drivers/net/mlx4/mlx4_prm.h index 6d1800a..57f5a46 100644 --- a/drivers/net/mlx4/mlx4_prm.h +++ b/drivers/net/mlx4/mlx4_prm.h @@ -64,6 +64,8 @@ /* Work queue element (WQE) flags. */ #define MLX4_BIT_WQE_OWN 0x80000000 +#define MLX4_WQE_CTRL_IIP_HDR_CSUM (1 << 28) +#define MLX4_WQE_CTRL_IL4_HDR_CSUM (1 << 27) #define MLX4_SIZE_TO_TXBBS(size) \ (RTE_ALIGN((size), (MLX4_TXBB_SIZE)) >> (MLX4_TXBB_SHIFT)) diff --git a/drivers/net/mlx4/mlx4_rxtx.c b/drivers/net/mlx4/mlx4_rxtx.c index 4200716..2757aec 100644 --- a/drivers/net/mlx4/mlx4_rxtx.c +++ b/drivers/net/mlx4/mlx4_rxtx.c @@ -433,12 +433,29 @@ struct pv { txq->elts_comp_cd -= nr_txbbs; if (unlikely(txq->elts_comp_cd <= 0)) { txq->elts_comp_cd = txq->elts_comp_cd_init; - srcrb_flags = RTE_BE32(MLX4_WQE_CTRL_SOLICIT | - MLX4_WQE_CTRL_CQ_UPDATE); + srcrb_flags = MLX4_WQE_CTRL_SOLICIT | MLX4_WQE_CTRL_CQ_UPDATE; } else { - srcrb_flags = RTE_BE32(MLX4_WQE_CTRL_SOLICIT); + srcrb_flags = MLX4_WQE_CTRL_SOLICIT; } - ctrl->srcrb_flags = srcrb_flags; + /* Enable HW checksum offload if requested */ + if (txq->csum && + (pkt->ol_flags & + (PKT_TX_IP_CKSUM | PKT_TX_TCP_CKSUM | PKT_TX_UDP_CKSUM))) { + const uint64_t is_tunneled = pkt->ol_flags & + (PKT_TX_TUNNEL_GRE | + PKT_TX_TUNNEL_VXLAN); + + if (is_tunneled && txq->csum_l2tun) { + owner_opcode |= MLX4_WQE_CTRL_IIP_HDR_CSUM | + MLX4_WQE_CTRL_IL4_HDR_CSUM; + if (pkt->ol_flags & PKT_TX_OUTER_IP_CKSUM) + srcrb_flags |= MLX4_WQE_CTRL_IP_HDR_CSUM; + } else { + srcrb_flags |= MLX4_WQE_CTRL_IP_HDR_CSUM | + MLX4_WQE_CTRL_TCP_UDP_CSUM; + } + } + ctrl->srcrb_flags = rte_cpu_to_be_32(srcrb_flags); /* * Make sure descriptor is fully written before * setting ownership bit (because HW can start diff --git a/drivers/net/mlx4/mlx4_rxtx.h b/drivers/net/mlx4/mlx4_rxtx.h index 1b90533..dc283e1 100644 --- a/drivers/net/mlx4/mlx4_rxtx.h +++ b/drivers/net/mlx4/mlx4_rxtx.h @@ -110,6 +110,8 @@ struct txq { struct txq_elt (*elts)[]; /**< Tx elements. */ struct mlx4_txq_stats stats; /**< Tx queue counters. */ uint32_t max_inline; /**< Max inline send size. */ + uint32_t csum:1; /**< Checksum is supported and enabled */ + uint32_t csum_l2tun:1; /**< L2 tun Checksum is supported and enabled */ char *bounce_buf; /**< memory used for storing the first DWORD of data TXBBs. */ struct { diff --git a/drivers/net/mlx4/mlx4_txq.c b/drivers/net/mlx4/mlx4_txq.c index 9333311..2d776eb 100644 --- a/drivers/net/mlx4/mlx4_txq.c +++ b/drivers/net/mlx4/mlx4_txq.c @@ -340,6 +340,8 @@ struct txq_mp2mr_mbuf_check_data { (void *)dev, strerror(rte_errno)); goto error; } + tmpl.csum = priv->hw_csum; + tmpl.csum_l2tun = priv->hw_csum_l2tun; DEBUG("priv->device_attr.max_qp_wr is %d", priv->device_attr.max_qp_wr); DEBUG("priv->device_attr.max_sge is %d", -- 1.8.3.1