From owner-freebsd-net@FreeBSD.ORG Fri Nov 18 01:38:20 2011 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DB83F1065670; Fri, 18 Nov 2011 01:38:20 +0000 (UTC) (envelope-from bhutchings@solarflare.com) Received: from exchange.solarflare.com (mail.solarflare.com [216.237.3.220]) by mx1.freebsd.org (Postfix) with ESMTP id B5F628FC15; Fri, 18 Nov 2011 01:38:20 +0000 (UTC) Received: from OCEX02.SolarFlarecom.com ([10.20.40.31]) by exchange.solarflare.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 17 Nov 2011 17:38:19 -0800 Received: from [10.17.20.137] (10.17.20.137) by ocex02.SolarFlarecom.com (10.20.40.31) with Microsoft SMTP Server (TLS) id 14.1.339.1; Thu, 17 Nov 2011 17:38:19 -0800 From: Ben Hutchings To: In-Reply-To: <20111117220104.GD11828@michelle.cdnetworks.com> References: <20111117220104.GD11828@michelle.cdnetworks.com> Content-Type: text/plain; charset="UTF-8" Organization: Solarflare Communications Date: Fri, 18 Nov 2011 01:38:16 +0000 Message-ID: <1321580296.2749.78.camel@bwh-desktop> MIME-Version: 1.0 X-Mailer: Evolution 2.32.2 (2.32.2-1.fc14) Content-Transfer-Encoding: 7bit X-Originating-IP: [10.17.20.137] X-TM-AS-Product-Ver: SMEX-8.0.0.1181-6.500.1024-18524.005 X-TM-AS-Result: No--23.762300-0.000000-31 X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-OriginalArrivalTime: 18 Nov 2011 01:38:19.0956 (UTC) FILETIME=[C0745740:01CCA592] Cc: Juli Mallett , freebsd-net , Maksim Yevmenkin Subject: Re: confused with if_baudrate X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Nov 2011 01:38:20 -0000 On Thu, 2011-11-17 at 14:01 -0800, YongHyeon PYUN wrote: > On Thu, Nov 17, 2011 at 01:39:24PM -0800, Juli Mallett wrote: > > On Thu, Nov 17, 2011 at 13:12, Maksim Yevmenkin > > wrote: > > > hello, > > > > > > i'm a little bit confused about if_baudrate. from system headers > > > > > > #define if_baudrate ?? ?? if_data.ifi_baudrate > > > > > > and > > > > > > u_long ??ifi_baudrate; ?? ?? ?? ?? ?? /* linespeed */ > > > > > > so, i'm taking this as if_baudrate really should be an interface line > > > speed in megabits per second. am i correct? if so, then it appears > > > that at least some drivers lie about true line speed. for example from > > > ixgbe(4) > > > > > > ?? ?? ?? ??ifp->if_baudrate = 1000000000; > > > > > > it looks like its order of magnitude lower (i.e. 1 gigabit per second > > > instead of 10 gigabits per second). am i missing something here or its > > > just a typo? > > > > ixgbe's developer is excessively concerned about overflow on 32-bit > > hosts (and unwilling to correct it under a preprocessor conditional), > > unlike several of the other 10GbE driver developers, although I think > > one 10GbE driver opts to omit if_baudrate entirely. > > > > Probably the driver could have used something like this. > ifp->if_baudrate = IF_Gbps(10UL); > > I think the driver should update if_baudrate depending on > resolved speed(lost link, resolved speed etc). > And if we really care about overflowing if_baudrate on 32bit > machines, the IF_Gbps macro could be conditionally defined. It could also overflow on 64-bit machines too because the caller didn't know to use UL (which they shouldn't have to - what kind of encapsulation is that?). How about: #define IF_Gbps(x) ((ulong)MIN(IF_Mbps((uint64_t)(x)), ULONG_MAX)) Ben. -- Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.