From patchwork Tue Jan 6 08:30:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Or Gerlitz X-Patchwork-Id: 5572111 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 38E339F2ED for ; Tue, 6 Jan 2015 08:32:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 53033201DD for ; Tue, 6 Jan 2015 08:32:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 71944201BC for ; Tue, 6 Jan 2015 08:32:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753453AbbAFIcM (ORCPT ); Tue, 6 Jan 2015 03:32:12 -0500 Received: from [193.47.165.129] ([193.47.165.129]:44215 "EHLO mellanox.co.il" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753348AbbAFIcM (ORCPT ); Tue, 6 Jan 2015 03:32:12 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from ogerlitz@mellanox.com) with ESMTPS (AES256-SHA encrypted); 6 Jan 2015 10:30:44 +0200 Received: from r-vnc04.mtr.labs.mlnx (r-vnc04.mtr.labs.mlnx [10.208.0.116]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id t068UiP8024198; Tue, 6 Jan 2015 10:30:44 +0200 From: Or Gerlitz To: Yishai Hadas Cc: Roland Dreier , linux-rdma@vger.kernel.org, Tal Alon , Moshe Lazer , Eyal Perry , Or Gerlitz Subject: [PATCH libmlx4] Add IP and TCP/UDP TX checksum offload support Date: Tue, 6 Jan 2015 10:30:43 +0200 Message-Id: <1420533043-28557-1-git-send-email-ogerlitz@mellanox.com> X-Mailer: git-send-email 1.7.8.2 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Moshe Lazer Add support for IBV_SEND_IP_CSUM for posted send work-requests. When this flag is set, enable the HW checksum calculation by setting MLX4_WQE_CTRL_IP_CSUM and MLX4_WQE_CTRL_TCP_UDP_CSUM flags in the WQE control segment. Signed-off-by: Eyal Perry Signed-off-by: Moshe Lazer Signed-off-by: Or Gerlitz --- src/qp.c | 11 ++++++++++- src/wqe.h | 2 ++ 2 files changed, 12 insertions(+), 1 deletions(-) diff --git a/src/qp.c b/src/qp.c index 721bed4..5b800e7 100644 --- a/src/qp.c +++ b/src/qp.c @@ -286,6 +286,10 @@ int mlx4_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr, break; case IBV_QPT_UD: + ctrl->srcrb_flags |= + wr->send_flags & IBV_SEND_IP_CSUM ? + htonl(MLX4_WQE_CTRL_IP_CSUM | + MLX4_WQE_CTRL_TCP_UDP_CSUM) : 0; set_datagram_seg(wqe, wr); wqe += sizeof (struct mlx4_wqe_datagram_seg); size += sizeof (struct mlx4_wqe_datagram_seg) / 16; @@ -294,7 +298,12 @@ int mlx4_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr, case IBV_QPT_RAW_PACKET: /* For raw eth, the MLX4_WQE_CTRL_SOLICIT flag is used * to indicate that no icrc should be calculated */ - ctrl->srcrb_flags |= htonl(MLX4_WQE_CTRL_SOLICIT); + ctrl->srcrb_flags |= + wr->send_flags & IBV_SEND_IP_CSUM ? + htonl(MLX4_WQE_CTRL_IP_CSUM | + MLX4_WQE_CTRL_TCP_UDP_CSUM | + MLX4_WQE_CTRL_SOLICIT) : + htonl(MLX4_WQE_CTRL_SOLICIT); break; default: diff --git a/src/wqe.h b/src/wqe.h index bbd22ba..ebd5167 100644 --- a/src/wqe.h +++ b/src/wqe.h @@ -41,6 +41,8 @@ enum { MLX4_WQE_CTRL_FENCE = 1 << 6, MLX4_WQE_CTRL_CQ_UPDATE = 3 << 2, MLX4_WQE_CTRL_SOLICIT = 1 << 1, + MLX4_WQE_CTRL_IP_CSUM = 1 << 4, + MLX4_WQE_CTRL_TCP_UDP_CSUM = 1 << 5 }; enum {