From patchwork Mon May 8 13:44:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devesh Sharma X-Patchwork-Id: 9716209 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 0299B60364 for ; Mon, 8 May 2017 13:44:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8F1428304 for ; Mon, 8 May 2017 13:44:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DDBD628338; Mon, 8 May 2017 13:44:39 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 C9F3128304 for ; Mon, 8 May 2017 13:44:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754687AbdEHNoh (ORCPT ); Mon, 8 May 2017 09:44:37 -0400 Received: from mail-wr0-f173.google.com ([209.85.128.173]:35751 "EHLO mail-wr0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750925AbdEHNog (ORCPT ); Mon, 8 May 2017 09:44:36 -0400 Received: by mail-wr0-f173.google.com with SMTP id z52so44138832wrc.2 for ; Mon, 08 May 2017 06:44:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id; bh=9+sERmyvH009jb/JpbMR1oSJJUpJxSDJ6K3Drgz1AFw=; b=R8CAK76GpRKap5pIhgizHqLpWSPv0BCm7oG/SkuxTn3t0DEWHp0Y1bNvYwH7iY4oUG Xa3WAG98LTZ5fiOcO/OWwhXiadNRoXTKe8wSEB7klytt7XH7Sr/AG24XLbzoqqAMBeq/ jsPJwD5gsqGHfYue7lr6YRQP1HQo7bXp5xeqY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=9+sERmyvH009jb/JpbMR1oSJJUpJxSDJ6K3Drgz1AFw=; b=o24DJzp16niufTZdrekeOnqPbMbht3yS9N1DAlxng3DfNUQBXUBYY3vNFCO9duHRoN xVUnpudFG5EEqxrBTY4M9tj7lF1CHm59HkT6nHQnYhD1BsXx0nug5kwL1j4hUNE2PKUV +JbmkhBRhEMYYYBVsgx7SVRTxjHI6IR/0r7QKXq1HmiNEeuozhPCwalQqbP/r6k2z9O5 XXVrRbphGUALa+BFO9hMkUdaCsgCe7vd6q2LzxTjHfyFwbp7pkDoAZfcx2hEvAVeAK4c /gXiLIKEeA7YBTrA3eC9FWMq1Wqb0ydAGxTy7DdMl9ehTRE3K5cBEgY8dHpmr3sv6YDh +tVQ== X-Gm-Message-State: AN3rC/5q27EEsnB1kdnqGGSNF3kktif3VEd0jL8smfDJ5emRFb6x8ECQ /6wfQ0RTf59IS6fdBAvmpQ== X-Received: by 10.223.164.65 with SMTP id e1mr38223934wra.21.1494251075148; Mon, 08 May 2017 06:44:35 -0700 (PDT) Received: from neo00-el73.iig.avagotech.net ([192.19.239.250]) by smtp.gmail.com with ESMTPSA id u88sm13044554wrc.20.2017.05.08.06.44.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 May 2017 06:44:34 -0700 (PDT) From: Devesh Sharma To: linux-rdma@vger.kernel.org Cc: Devesh Sharma Subject: [PATCH] rdma-core: define link speed and link width enums Date: Mon, 8 May 2017 09:44:17 -0400 Message-Id: <1494251057-1060-1-git-send-email-devesh.sharma@broadcom.com> X-Mailer: git-send-email 1.8.3.1 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 Currently application either need to define its own enum values for link-speed and link-width or use hard coded values. This patch inharits the enums from kernel space ib_verbs.h and puts into verbs.h for ease of programming. Signed-off-by: Devesh Sharma --- libibverbs/examples/devinfo.c | 22 ++++++++++++---------- libibverbs/verbs.h | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/libibverbs/examples/devinfo.c b/libibverbs/examples/devinfo.c index 2c1e3f1..42ed50c 100644 --- a/libibverbs/examples/devinfo.c +++ b/libibverbs/examples/devinfo.c @@ -124,10 +124,10 @@ static const char *mtu_str(enum ibv_mtu max_mtu) static const char *width_str(uint8_t width) { switch (width) { - case 1: return "1"; - case 2: return "4"; - case 4: return "8"; - case 8: return "12"; + case IBV_WIDTH_1X: return "1"; + case IBV_WIDTH_4X: return "4"; + case IBV_WIDTH_8X: return "8"; + case IBV_WIDTH_12X: return "12"; default: return "invalid width"; } } @@ -135,14 +135,16 @@ static const char *width_str(uint8_t width) static const char *speed_str(uint8_t speed) { switch (speed) { - case 1: return "2.5 Gbps"; - case 2: return "5.0 Gbps"; + case IBV_SPEED_SDR: return "2.5 Gbps"; + case IBV_SPEED_DDR: return "5.0 Gbps"; - case 4: /* fall through */ - case 8: return "10.0 Gbps"; + case IBV_SPEED_QDR: /* fall through */ + case IBV_SPEED_FDR10: return "10.0 Gbps"; - case 16: return "14.0 Gbps"; - case 32: return "25.0 Gbps"; + case IBV_SPEED_FDR: return "14.0 Gbps"; + case IBV_SPEED_EDR: return "25.0 Gbps"; + case IBV_SPEED_HDR: return "50.0 Gbps"; + case IBV_SPEE_NDR: return "100.0 Gbps"; default: return "invalid speed"; } } diff --git a/libibverbs/verbs.h b/libibverbs/verbs.h index b27dfd1..39a65fe 100644 --- a/libibverbs/verbs.h +++ b/libibverbs/verbs.h @@ -290,6 +290,24 @@ enum ibv_port_state { IBV_PORT_ACTIVE_DEFER = 5 }; +enum ibv_port_speed { + IBV_SPEED_SDR = 1, + IBV_SPEED_DDR = 2, + IBV_SPEED_QDR = 4, + IBV_SPEED_FDR10 = 8, + IBV_SPEED_FDR = 16, + IBV_SPEED_EDR = 32, + IBV_SPEED_HDR = 64, + IBV_SPEED_NDR = 128 +}; + +enum ibv_port_width { + IBV_WIDTH_1X = 1, + IBV_WIDTH_4X = 2, + IBV_WIDTH_8X = 4, + IBV_WIDTH_12X = 8 +}; + enum { IBV_LINK_LAYER_UNSPECIFIED, IBV_LINK_LAYER_INFINIBAND,