From patchwork Wed Jul 26 08:34:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selvin Xavier X-Patchwork-Id: 13327658 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80AFDC0015E for ; Wed, 26 Jul 2023 08:54:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229793AbjGZIx7 (ORCPT ); Wed, 26 Jul 2023 04:53:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233374AbjGZIws (ORCPT ); Wed, 26 Jul 2023 04:52:48 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 928BD3C34 for ; Wed, 26 Jul 2023 01:46:36 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1b8ad9eede0so51387635ad.1 for ; Wed, 26 Jul 2023 01:46:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1690361196; x=1690965996; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vY2bnMxlKOvVyWrI7bO4i0oaibvQgKTV5/2fVuWi1Uo=; b=Bo5oI0ICK3yPhPGwLEedkGnrlWKZ0V1fWz1IAnXDZuuWAtWxalUgH/Tmf8CVy2VjZP f7hT0Ezt8y7O6WISFxKNfoRsQTvczaUI7elKLStoEvWJlhA3Q0c4FYtFta4zSnyr0Qtu 7T8kO8QO4FPOoGaCl6E1LEtDSDKs9yICxjk5I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690361196; x=1690965996; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vY2bnMxlKOvVyWrI7bO4i0oaibvQgKTV5/2fVuWi1Uo=; b=JI2ITz5wAaBDA04BidFYtRH+PIzpMe0iboFIFW8sW3f0Q1dO/9PiuzMlYMQQkhSzh4 oisAHXA2lfUd9Nst4ercGZk5dotRWv7OxTJdE3v1WsAmCBEnlOLYUPZiSHctvmRrnDUT FXj5JeAb17YfpyV1r5LscOeMg1JUACnrbMotP+ftjRJqQJQegWRcSFAkSP3DOGaUUnPJ lJLLRYaI/xWwOGUvb1OYf93m0U1E7wcUt9LZQyBLJI/4mqZhimwLEGYfphDLQ9acbRwk M0f70Z7ssLQlDBt9bI8eTQD6SFgpUpjYYwm6yM+BHyAo5mvdgGn/BoTvEHHMm220DMIg lX3g== X-Gm-Message-State: ABy/qLbhDzAoGcvBuOX+E6b1HN6p2cf7HV79enbNay+WJzhMbUzXIVk7 M4m21c5pI5X1QeyOoo9hz5zy/ptdbueW7gkxqzo= X-Google-Smtp-Source: APBJJlH7ChgsFNXuDLkeFJ3aQRIfVhpUn+LTFrGWKJ0zIuHMtbtrR/kr0VEOuNEU9EBO/03F9BZC4Q== X-Received: by 2002:a17:903:2287:b0:1bb:9f07:5e0 with SMTP id b7-20020a170903228700b001bb9f0705e0mr1933082plh.60.1690361195964; Wed, 26 Jul 2023 01:46:35 -0700 (PDT) Received: from dhcp-10-192-206-197.iig.avagotech.net.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id w16-20020a170902a71000b001b8052d58a0sm12494218plq.305.2023.07.26.01.46.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Jul 2023 01:46:34 -0700 (PDT) From: Selvin Xavier To: jgg@ziepe.ca, leon@kernel.org Cc: linux-rdma@vger.kernel.org, andrew.gospodarek@broadcom.com, Kalesh AP , Selvin Xavier Subject: [PATCH] IB/core: Add more speed parsing in ib_get_eth_speed() Date: Wed, 26 Jul 2023 01:34:53 -0700 Message-Id: <1690360493-8428-1-git-send-email-selvin.xavier@broadcom.com> X-Mailer: git-send-email 2.5.5 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Kalesh AP The function ib_get_eth_speed() does not take consideration of 50G, 56G, 100G and 200G speeds. Added these speeds parsing. We are not considering the lane width now. This can be enhanced later. Also, refactored the code to use switch case instead of if-else. Signed-off-by: Kalesh AP Signed-off-by: Selvin Xavier --- drivers/infiniband/core/verbs.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index b99b3cc..ebd389a 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c @@ -1908,22 +1908,44 @@ int ib_get_eth_speed(struct ib_device *dev, u32 port_num, u16 *speed, u8 *width) netdev_speed); } - if (netdev_speed <= SPEED_1000) { + switch (netdev_speed) { + case SPEED_1000: *width = IB_WIDTH_1X; *speed = IB_SPEED_SDR; - } else if (netdev_speed <= SPEED_10000) { + break; + case SPEED_10000: *width = IB_WIDTH_1X; *speed = IB_SPEED_FDR10; - } else if (netdev_speed <= SPEED_20000) { + break; + case SPEED_20000: *width = IB_WIDTH_4X; *speed = IB_SPEED_DDR; - } else if (netdev_speed <= SPEED_25000) { + break; + case SPEED_25000: *width = IB_WIDTH_1X; *speed = IB_SPEED_EDR; - } else if (netdev_speed <= SPEED_40000) { + break; + case SPEED_40000: *width = IB_WIDTH_4X; *speed = IB_SPEED_FDR10; - } else { + break; + case SPEED_50000: + *width = IB_WIDTH_2X; + *speed = IB_SPEED_EDR; + break; + case SPEED_56000: + *width = IB_WIDTH_4X; + *speed = IB_SPEED_FDR; + break; + case SPEED_100000: + *width = IB_WIDTH_4X; + *speed = IB_SPEED_EDR; + break; + case SPEED_200000: + *width = IB_WIDTH_4X; + *speed = IB_SPEED_HDR; + break; + default: *width = IB_WIDTH_4X; *speed = IB_SPEED_EDR; }