From patchwork Wed Mar 15 15:27:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 9625929 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6B8D56048C for ; Wed, 15 Mar 2017 15:28:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E2EF285A1 for ; Wed, 15 Mar 2017 15:28:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 520522863E; Wed, 15 Mar 2017 15:28:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B6EC285A1 for ; Wed, 15 Mar 2017 15:28:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753326AbdCOP2b (ORCPT ); Wed, 15 Mar 2017 11:28:31 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:36887 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753871AbdCOP2E (ORCPT ); Wed, 15 Mar 2017 11:28:04 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 15 Mar 2017 17:27:58 +0200 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 v2FFRwuE020175; Wed, 15 Mar 2017 17:27:58 +0200 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [127.0.0.1]) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8) with ESMTP id v2FFRwnw014150; Wed, 15 Mar 2017 17:27:58 +0200 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id v2FFRwu9014149; Wed, 15 Mar 2017 17:27:58 +0200 From: Yishai Hadas To: dledford@redhat.com Cc: linux-rdma@vger.kernel.org, yishaih@mellanox.com, noaos@mellanox.com, majd@mellanox.com Subject: [PATCH V1 rdma-core 1/6] ibverbs: Report raw packet caps as part of query device Date: Wed, 15 Mar 2017 17:27:41 +0200 Message-Id: <1489591666-14062-2-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1489591666-14062-1-git-send-email-yishaih@mellanox.com> References: <1489591666-14062-1-git-send-email-yishaih@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Noa Osherovich Currently, existing raw packet capabilities (IP CSUM and scatter FCS) are reported separately to the user via ibv_query_device_ex. Unify those capabilities into a single enum and report them together for a better user experience. Also introduce CVLAN stripping offload capability. CVLAN is the customer VLAN tag (inner tag). CVLAN stripping offload is the device's ability to strip this tag from incoming raw Ethernet packets and report the data in the matching work completion. This patch includes: - Reading from the uverbs layer and report back to an application. - Extending ibv_devinfo to print that information. Signed-off-by: Noa Osherovich Reviewed-by: Maor Gottlieb Reviewed-by: Yishai Hadas --- libibverbs/cmd.c | 8 ++++++++ libibverbs/examples/devinfo.c | 14 ++++++++++++++ libibverbs/kern-abi.h | 2 +- libibverbs/man/ibv_query_device_ex.3 | 9 +++++++++ libibverbs/verbs.h | 7 +++++++ 5 files changed, 39 insertions(+), 1 deletion(-) diff --git a/libibverbs/cmd.c b/libibverbs/cmd.c index 9b49da0..4aebbb5 100644 --- a/libibverbs/cmd.c +++ b/libibverbs/cmd.c @@ -230,6 +230,14 @@ int ibv_cmd_query_device_ex(struct ibv_context *context, attr->max_wq_type_rq = resp->max_wq_type_rq; } + if (attr_size >= offsetof(struct ibv_device_attr_ex, raw_packet_caps) + + sizeof(attr->raw_packet_caps)) { + if (resp->response_length >= + offsetof(struct ibv_query_device_resp_ex, raw_packet_caps) + + sizeof(resp->raw_packet_caps)) + attr->raw_packet_caps = resp->raw_packet_caps; + } + return 0; } diff --git a/libibverbs/examples/devinfo.c b/libibverbs/examples/devinfo.c index d88562f..42222c4 100644 --- a/libibverbs/examples/devinfo.c +++ b/libibverbs/examples/devinfo.c @@ -401,6 +401,17 @@ static void print_packet_pacing_caps(const struct ibv_packet_pacing_caps *caps) } } +static void print_raw_packet_caps(uint32_t raw_packet_caps) +{ + printf("\traw packet caps:\n"); + if (raw_packet_caps & IBV_RAW_PACKET_CAP_CVLAN_STRIPPING) + printf("\t\t\t\t\tC-VLAN stripping offload\n"); + if (raw_packet_caps & IBV_RAW_PACKET_CAP_SCATTER_FCS) + printf("\t\t\t\t\tScatter FCS offload\n"); + if (raw_packet_caps & IBV_RAW_PACKET_CAP_IP_CSUM) + printf("\t\t\t\t\tIP csum offload\n"); +} + static int print_hca_cap(struct ibv_device *ib_dev, uint8_t ib_port) { struct ibv_context *ctx; @@ -499,6 +510,9 @@ static int print_hca_cap(struct ibv_device *ib_dev, uint8_t ib_port) else printf("\tcore clock not supported\n"); + if (device_attr.raw_packet_caps) + print_raw_packet_caps(device_attr.raw_packet_caps); + printf("\tdevice_cap_flags_ex:\t\t0x%" PRIX64 "\n", device_attr.device_cap_flags_ex); print_device_cap_flags_ex(device_attr.device_cap_flags_ex); print_tso_caps(&device_attr.tso_caps); diff --git a/libibverbs/kern-abi.h b/libibverbs/kern-abi.h index 210dd3e..3958f0c 100644 --- a/libibverbs/kern-abi.h +++ b/libibverbs/kern-abi.h @@ -290,7 +290,7 @@ struct ibv_query_device_resp_ex { __u64 device_cap_flags_ex; struct ibv_rss_caps_resp rss_caps; __u32 max_wq_type_rq; - __u32 reserved; + __u32 raw_packet_caps; }; struct ibv_query_port { diff --git a/libibverbs/man/ibv_query_device_ex.3 b/libibverbs/man/ibv_query_device_ex.3 index c291017..fdfb708 100644 --- a/libibverbs/man/ibv_query_device_ex.3 +++ b/libibverbs/man/ibv_query_device_ex.3 @@ -32,6 +32,7 @@ struct ibv_tso_caps tso_caps; /* TCP segmentation offload c struct ibv_rss_caps rss_caps; /* RSS capabilities */ uint32_t max_wq_type_rq; /* Max Work Queue from type RQ */ struct ibv_packet_pacing_caps packet_pacing_caps; /* Packet pacing capabilities */ +uint32_t raw_packet_caps; /* Raw packet capabilities, use enum ibv_raw_packet_caps */ .in -8 }; @@ -75,6 +76,14 @@ struct ibv_packet_pacing_caps { uint32_t supported_qpts; /* Bitmap showing which QP types are supported. */ }; +enum ibv_raw_packet_caps { +.in +8 +IBV_RAW_PACKET_CAP_CVLAN_STRIPPING = 1 << 0, /* CVLAN stripping is supported */ +IBV_RAW_PACKET_CAP_SCATTER_FCS = 1 << 1, /* FCS scattering is supported */ +IBV_RAW_PACKET_CAP_IP_CSUM = 1 << 2, /* IP CSUM offload is supported */ +.in -8 +}; + .fi .SH "RETURN VALUE" .B ibv_query_device_ex() diff --git a/libibverbs/verbs.h b/libibverbs/verbs.h index 25f4ede..604b09e 100644 --- a/libibverbs/verbs.h +++ b/libibverbs/verbs.h @@ -252,6 +252,12 @@ struct ibv_packet_pacing_caps { uint32_t supported_qpts; }; +enum ibv_raw_packet_caps { + IBV_RAW_PACKET_CAP_CVLAN_STRIPPING = 1 << 0, + IBV_RAW_PACKET_CAP_SCATTER_FCS = 1 << 1, + IBV_RAW_PACKET_CAP_IP_CSUM = 1 << 2, +}; + struct ibv_device_attr_ex { struct ibv_device_attr orig_attr; uint32_t comp_mask; @@ -263,6 +269,7 @@ struct ibv_device_attr_ex { struct ibv_rss_caps rss_caps; uint32_t max_wq_type_rq; struct ibv_packet_pacing_caps packet_pacing_caps; + uint32_t raw_packet_caps; /* Use ibv_raw_packet_caps */ }; enum ibv_mtu {