Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1063712pxa; Wed, 12 Aug 2020 22:31:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwG/DbtGSph425Ufw7hr3+mhH4HiRqw/wGOCk4QKC7FCePv8y7lxmtxT5QLir+orFC1J7jh X-Received: by 2002:a17:906:3890:: with SMTP id q16mr3077303ejd.107.1597296672733; Wed, 12 Aug 2020 22:31:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597296672; cv=none; d=google.com; s=arc-20160816; b=Wq08WAsAeRLzQo+ejbWCjGyDqdxShvdVzsDzMuFTlLQh786HKqPKUDKWdYNeUGNW14 QbiaPKw7dvc+j3zFwkvEVVnE4XXj7bmvvWyfPuKTUTBcyb7GUcLuze27YwD6lVlLV6IB iitOfDhMHRFyTxGJpbXKf/vw90sp8xfSGr+UbJJ7IfxKm+TxqPCyKcVnObd4X1GGuWdG oP9E7knhytOgJ7sNgYXV7EmPnPl/Bo7ogvJHWF6ioVTw/dpk6xrCJ0JC+QX2bwRYalet FeYKBoJ9qRO+G8eYmZ6CwVJBpJEmu+g1333+BZrWcA2PCy9fxiCQrJ6u4kTbZyWZRGxV Ot2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:content-transfer-encoding :content-id:mime-version:comments:references:in-reply-to:subject:cc :to:from; bh=Co0/GURAeYLxCvDhJN1EV76NDhx3pJccz0L7SiXWNMA=; b=R/hS52R1fZjHDWVxjKitKP8OSY+ayFMYRCB88+uNNYV5rt+w/IjYOjURfo0tbHNU0F iuzVl/fzUOuuqdM/iSgHjZCKdTnykXGtR96DNw/rFphMzfl75uhUAjnbYjKSZPIYVQzx AJaI2b8X/iZ+xI7q9cPLZV0yzfO8cd7NjUhvzfipPtSr6nLykqN+oRd01PAuy/5J7Frs D5QeoOZwdPO/F2r0Xlu0rLecuQ7QQu2ldcPaSNaapPpJwvd3YfwQozP1k7KWBgAyMXia ojLLfLT7+Mu6CX9mpWYIxSqEe5AUsD9fs1ZpVlF0HC5aowtQFspRFisdF2Tyu5PAnGyI eDdw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r3si2456043ejr.664.2020.08.12.22.30.49; Wed, 12 Aug 2020 22:31:12 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726174AbgHMFaD convert rfc822-to-8bit (ORCPT + 99 others); Thu, 13 Aug 2020 01:30:03 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:52968 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725949AbgHMFaD (ORCPT ); Thu, 13 Aug 2020 01:30:03 -0400 Received: from 1.general.jvosburgh.us.vpn ([10.172.68.206] helo=famine.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1k65oL-00043S-Tt; Thu, 13 Aug 2020 05:29:58 +0000 Received: by famine.localdomain (Postfix, from userid 1000) id 3D5635FDD5; Wed, 12 Aug 2020 22:29:56 -0700 (PDT) Received: from famine (localhost [127.0.0.1]) by famine.localdomain (Postfix) with ESMTP id 3758B9FB5C; Wed, 12 Aug 2020 22:29:56 -0700 (PDT) From: Jay Vosburgh To: Jarod Wilson cc: linux-kernel@vger.kernel.org, Veaceslav Falico , Andy Gospodarek , "David S. Miller" , netdev@vger.kernel.org Subject: Re: [PATCH net] bonding: show saner speed for broadcast mode In-reply-to: <20200813035509.739-1-jarod@redhat.com> References: <20200813035509.739-1-jarod@redhat.com> Comments: In-reply-to Jarod Wilson message dated "Wed, 12 Aug 2020 23:55:09 -0400." X-Mailer: MH-E 8.6+git; nmh 1.6; GNU Emacs 27.0.50 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <27388.1597296596.1@famine> Content-Transfer-Encoding: 8BIT Date: Wed, 12 Aug 2020 22:29:56 -0700 Message-ID: <27389.1597296596@famine> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Jarod Wilson wrote: >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. Did you mean "slowest" here? >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 Did you notice this by inspection, or did it come up in use somewhere? I can't recall ever hearing of anyone using broadcast mode, so I'm curious if there is a use for it, but this change seems reasonable enough regardless. -J Acked-by: Jay Vosburgh >--- > 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 >