Date: Fri, 18 Nov 2011 21:32:15 +0000 From: Ben Hutchings <bhutchings@solarflare.com> To: Philip Paeps <philip@freebsd.org> Cc: freebsd-net@freebsd.org, marius@freebsd.org Subject: sfxge: Fix if_baudrate reports Message-ID: <1321651935.2883.74.camel@bwh-desktop>
next in thread | raw e-mail | index | archive | help
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. --- a/sys/dev/sfxge/sfxge_port.c +++ b/sys/dev/sfxge/sfxge_port.c @@ -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); } -- 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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1321651935.2883.74.camel>