From patchwork Mon Aug 17 15:50:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bodong Wang X-Patchwork-Id: 7025581 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5E355C05AC for ; Mon, 17 Aug 2015 15:51:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 42C1520690 for ; Mon, 17 Aug 2015 15:51:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3E62020681 for ; Mon, 17 Aug 2015 15:51:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755201AbbHQPvT (ORCPT ); Mon, 17 Aug 2015 11:51:19 -0400 Received: from [193.47.165.129] ([193.47.165.129]:59733 "EHLO mellanox.co.il" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753651AbbHQPvS (ORCPT ); Mon, 17 Aug 2015 11:51:18 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 17 Aug 2015 18:50:54 +0300 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [10.7.2.17]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id t7HFoqLd028645; Mon, 17 Aug 2015 18:50:52 +0300 Received: from vnc17.mtl.labs.mlnx (localhost.localdomain [127.0.0.1]) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8) with ESMTP id t7HFoqh3005882; Mon, 17 Aug 2015 18:50:52 +0300 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id t7HFop6f005878; Mon, 17 Aug 2015 18:50:51 +0300 From: Bodong Wang To: dledford@redhat.com Cc: linux-rdma@vger.kernel.org, bodong@mellanox.com, yishaih@mellanox.com, Moshe Lazer , Or Gerlitz Subject: [PATCH libibverbs] Add support for TX/RX checksum offload Date: Mon, 17 Aug 2015 18:50:18 +0300 Message-Id: <1439826618-3015-1-git-send-email-bodong@mellanox.com> X-Mailer: git-send-email 1.7.11.3 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Add a device capability flag IBV_DEVICE_IP_CSUM to denote IPv4 checksum offload support. Devices should set this flag if they support insertion/verification of IPv4, TCP and UDP checksums on outgoing/incoming IPv4 packets sent over IB UD or ETH RAW PACKET QPs. Flags IBV_SEND_IP_CSUM and IBV_WC_IP_CSUM_OK are added for utilizing this capability for send and receive separately. Change-Id: Ie02d708dcbef07ca0d2eac1b156f12aafdba6a97 Signed-off-by: Moshe Lazer Signed-off-by: Or Gerlitz Signed-off-by: Bodong Wang --- include/infiniband/verbs.h | 11 +++++++++-- man/ibv_poll_cq.3 | 3 +++ man/ibv_post_send.3 | 4 ++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/include/infiniband/verbs.h b/include/infiniband/verbs.h index 28e1586..6ae7e6e 100644 --- a/include/infiniband/verbs.h +++ b/include/infiniband/verbs.h @@ -115,6 +115,7 @@ enum ibv_device_cap_flags { IBV_DEVICE_RC_RNR_NAK_GEN = 1 << 12, IBV_DEVICE_SRQ_RESIZE = 1 << 13, IBV_DEVICE_N_NOTIFY_CQ = 1 << 14, + IBV_DEVICE_IP_CSUM = 1 << 18, IBV_DEVICE_XRC = 1 << 20, IBV_DEVICE_MANAGED_FLOW_STEERING = 1 << 29 }; @@ -314,9 +315,14 @@ enum ibv_wc_opcode { IBV_WC_RECV_RDMA_WITH_IMM }; +enum { + IBV_WC_IP_CSUM_OK_SHIFT = 2 +}; + enum ibv_wc_flags { IBV_WC_GRH = 1 << 0, - IBV_WC_WITH_IMM = 1 << 1 + IBV_WC_WITH_IMM = 1 << 1, + IBV_WC_IP_CSUM_OK = 1 << IBV_WC_IP_CSUM_OK_SHIFT }; struct ibv_wc { @@ -653,7 +659,8 @@ enum ibv_send_flags { IBV_SEND_FENCE = 1 << 0, IBV_SEND_SIGNALED = 1 << 1, IBV_SEND_SOLICITED = 1 << 2, - IBV_SEND_INLINE = 1 << 3 + IBV_SEND_INLINE = 1 << 3, + IBV_SEND_IP_CSUM = 1 << 4 }; struct ibv_sge { diff --git a/man/ibv_poll_cq.3 b/man/ibv_poll_cq.3 index 57c6daa..539940d 100644 --- a/man/ibv_poll_cq.3 +++ b/man/ibv_poll_cq.3 @@ -50,6 +50,9 @@ It is either 0 or the bitwise OR of one or more of the following flags: .B IBV_WC_GRH \fR GRH is present (valid only for UD QPs) .TP .B IBV_WC_WITH_IMM \fR Immediate data value is valid +.TP +.B IBV_WC_IP_CSUM_OK \fR TCP/UDP checksum over IPv4 and IPv4 header checksum are verified. +This feature is supported only when \fBIBV_DEVICE_IP_CSUM\fR flag is set in the device capability flags. .PP Not all .I wc diff --git a/man/ibv_post_send.3 b/man/ibv_post_send.3 index 33fbb50..3b07bcb 100644 --- a/man/ibv_post_send.3 +++ b/man/ibv_post_send.3 @@ -98,6 +98,10 @@ The attribute send_flags describes the properties of the \s-1WR\s0. It is either .TP .B IBV_SEND_INLINE \fR Send data in given gather list as inline data in a send WQE. Valid only for Send and RDMA Write. The L_Key will not be checked. ++.TP ++.B IBV_SEND_IP_CSUM \fR Offload the IPv4 and TCP/UDP checksum calculation. ++Valid only for QPs with Transport Service Type \fBIBV_QPT_UD\fR or \fBIBV_QPT_RAW_PACKET\fR. ++This feature supported only when \fBIBV_DEVICE_IP_CSUM\fR the flag is set in the device capability flags. .SH "RETURN VALUE" .B ibv_post_send() returns 0 on success, or the value of errno on failure (which indicates the failure reason).