Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1021114pxa; Wed, 12 Aug 2020 20:56:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYcqUY6J6nCiaV9Fnn/rElOeH6+eP8DNO0XNPzeFJZfGSF16ELQZ+t1SEi4VQxqoWeFYrA X-Received: by 2002:a05:6402:1bc5:: with SMTP id ch5mr2814620edb.364.1597290989305; Wed, 12 Aug 2020 20:56:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597290989; cv=none; d=google.com; s=arc-20160816; b=xWLiQPhT9NtaUfxdBXT/cmwDuTSvasy9Rx9np40mfY5MG7RM41bH6K/g0XlTVI58qs +gF7dq48g0KL27IK2rvJ35daVTiXy+vniOzd66J+vPw5lWq4mf8TmOP45NbYd6FZcQBF i8eAapvUL45PRBwhl9rfwoAkVxJl5lVWl1eICSkr+rJdQJVmM7Eu9i8S/zw0+AUnA+NX XL2N2PJsp+nkkwFy5JRrGHt67KnB5ca9q5Zv5tkyhrjnHIhaFtjMcdEpmZKbTb6HsGGO hH7uwjpTD6Kj+paEvJKdTQbpZ/dTgxrEKwtRUgj/Q89mlmh8dja8nCj+Vq+i1y1Kz4j6 /s1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=tQVpSBd8H4mxwa7+/E4VYo7bjaBiT+FzyTgSS58XOy4=; b=qNXSJxzZlcmT5tUTJSeqsED9gM6zaF/DJb2yw4d8i+12Tc/OnWIXs27u27pKlwHhKH flVeuaqRzBWfn99pycR9uQaykzjCpWEaNMCTkZ9bMYo8sxWZGn6A9Khc7fWmrmGFMOOV ey5hC62EzFsqpI/ufEwb9VK9AXmiaCycAZg+mJlyUwboXAIn+7mU4rpx/ypT1/yEI3IR Lh3Tkuk6DoC0KgE+HrpU3sazIStETAnaqeDjARtHRr5xri9iyrl5k1RAhJKSC1y01H06 u3I3o0DpAiNDrscwD11U5rzun310KGA9b+CPNhI6BlAXUyeT01LZ6W+7whorgQRjYnje LIeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Im2DwbtF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v12si2557457edy.197.2020.08.12.20.56.06; Wed, 12 Aug 2020 20:56:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Im2DwbtF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726578AbgHMDzc (ORCPT + 99 others); Wed, 12 Aug 2020 23:55:32 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:38446 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726334AbgHMDzc (ORCPT ); Wed, 12 Aug 2020 23:55:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597290931; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=tQVpSBd8H4mxwa7+/E4VYo7bjaBiT+FzyTgSS58XOy4=; b=Im2DwbtFzyfMe5bKGxHxJHOQqK39nergYst+OJJVmwT+ONkdiMhzE53BBFsgv6+57Wvx2f /YXNWzJTSTLvyBhDqeLzfHlxjOTWB6OC8zBZNX00p9K/5iioz62uCcUo5fh8i/4oK+Y79A tdBJtfi7sENtaqB5Y0r2reiLmYsmfl0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-105-cGpmWOrCOKuNoqayZYf34Q-1; Wed, 12 Aug 2020 23:55:29 -0400 X-MC-Unique: cGpmWOrCOKuNoqayZYf34Q-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EA0BE79EC0; Thu, 13 Aug 2020 03:55:27 +0000 (UTC) Received: from hp-dl360pgen8-07.khw2.lab.eng.bos.redhat.com (hp-dl360pgen8-07.khw2.lab.eng.bos.redhat.com [10.16.210.135]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4697B100AE52; Thu, 13 Aug 2020 03:55:24 +0000 (UTC) From: Jarod Wilson To: linux-kernel@vger.kernel.org Cc: Jarod Wilson , Jay Vosburgh , Veaceslav Falico , Andy Gospodarek , "David S. Miller" , netdev@vger.kernel.org Subject: [PATCH net] bonding: show saner speed for broadcast mode Date: Wed, 12 Aug 2020 23:55:09 -0400 Message-Id: <20200813035509.739-1-jarod@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Broadcast mode bonds transmit a copy of all traffic simultaneously out of all interfaces, so the "speed" of the bond isn't really the aggregate of all interfaces, but rather, the speed of the lowest active interface. Also, the type of the speed field is u32, not unsigned long, so adjust that accordingly, as required to make min() function here without complaining about mismatching types. Fixes: bb5b052f751b ("bond: add support to read speed and duplex via ethtool") CC: Jay Vosburgh CC: Veaceslav Falico CC: Andy Gospodarek CC: "David S. Miller" CC: netdev@vger.kernel.org Signed-off-by: Jarod Wilson --- drivers/net/bonding/bond_main.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 5ad43aaf76e5..c853ca67058c 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -4552,13 +4552,23 @@ static netdev_tx_t bond_start_xmit(struct sk_buff *skb, struct net_device *dev) return ret; } +static u32 bond_mode_bcast_speed(struct slave *slave, u32 speed) +{ + if (speed == 0 || speed == SPEED_UNKNOWN) + speed = slave->speed; + else + speed = min(speed, slave->speed); + + return speed; +} + static int bond_ethtool_get_link_ksettings(struct net_device *bond_dev, struct ethtool_link_ksettings *cmd) { struct bonding *bond = netdev_priv(bond_dev); - unsigned long speed = 0; struct list_head *iter; struct slave *slave; + u32 speed = 0; cmd->base.duplex = DUPLEX_UNKNOWN; cmd->base.port = PORT_OTHER; @@ -4570,8 +4580,13 @@ static int bond_ethtool_get_link_ksettings(struct net_device *bond_dev, */ bond_for_each_slave(bond, slave, iter) { if (bond_slave_can_tx(slave)) { - if (slave->speed != SPEED_UNKNOWN) - speed += slave->speed; + if (slave->speed != SPEED_UNKNOWN) { + if (BOND_MODE(bond) == BOND_MODE_BROADCAST) + speed = bond_mode_bcast_speed(slave, + speed); + else + speed += slave->speed; + } if (cmd->base.duplex == DUPLEX_UNKNOWN && slave->duplex != DUPLEX_UNKNOWN) cmd->base.duplex = slave->duplex; -- 2.20.1