svn commit: r227699 - head/sys/dev/sfxge

Philip Paeps philip at FreeBSD.org
Sat Nov 19 09:13:59 UTC 2011


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);
 }
 


More information about the svn-src-head mailing list