Date: Sat, 19 Nov 2011 09:13:58 +0000 (UTC) From: Philip Paeps <philip@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r227699 - head/sys/dev/sfxge Message-ID: <201111190913.pAJ9Dwhh032884@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: philip Date: Sat Nov 19 09:13:58 2011 New Revision: 227699 URL: http://svn.freebsd.org/changeset/base/227699 Log: sfxge: Fix if_baudrate reports This field is supposed to be set to the interface bit rate, but for some reason I thought it was denominated in kilobits. Multiply the values up accordingly, taking care to saturate rather than overflow on 32-bit architectures. Submitted by: Ben Hutchings <bwh -at- solarflare.com> MFC after: 3 weeks Modified: head/sys/dev/sfxge/sfxge_port.c Modified: head/sys/dev/sfxge/sfxge_port.c ============================================================================== --- head/sys/dev/sfxge/sfxge_port.c Sat Nov 19 07:52:39 2011 (r227698) +++ head/sys/dev/sfxge/sfxge_port.c Sat Nov 19 09:13:58 2011 (r227699) @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> +#include <sys/limits.h> #include <net/ethernet.h> #include <net/if_dl.h> @@ -219,14 +220,14 @@ sfxge_port_link_fc_handler(SYSCTL_HANDLE #endif /* SFXGE_HAVE_PAUSE_MEDIAOPTS */ -static const int sfxge_link_speed_kbit[EFX_LINK_NMODES] = { - [EFX_LINK_10HDX] = 10000, - [EFX_LINK_10FDX] = 10000, - [EFX_LINK_100HDX] = 100000, - [EFX_LINK_100FDX] = 100000, - [EFX_LINK_1000HDX] = 1000000, - [EFX_LINK_1000FDX] = 1000000, - [EFX_LINK_10000FDX] = 10000000, +static const u_long sfxge_link_baudrate[EFX_LINK_NMODES] = { + [EFX_LINK_10HDX] = IF_Mbps(10), + [EFX_LINK_10FDX] = IF_Mbps(10), + [EFX_LINK_100HDX] = IF_Mbps(100), + [EFX_LINK_100FDX] = IF_Mbps(100), + [EFX_LINK_1000HDX] = IF_Gbps(1), + [EFX_LINK_1000FDX] = IF_Gbps(1), + [EFX_LINK_10000FDX] = MIN(IF_Gbps(10ULL), ULONG_MAX), }; void @@ -245,7 +246,7 @@ sfxge_mac_link_update(struct sfxge_softc /* Push link state update to the OS */ link_state = (port->link_mode != EFX_LINK_DOWN ? LINK_STATE_UP : LINK_STATE_DOWN); - sc->ifnet->if_baudrate = sfxge_link_speed_kbit[port->link_mode]; + sc->ifnet->if_baudrate = sfxge_link_baudrate[port->link_mode]; if_link_state_change(sc->ifnet, link_state); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201111190913.pAJ9Dwhh032884>