Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Jan 2016 12:30:17 +0000 (UTC)
From:      Steven Hartland <smh@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r294795 - head/sys/dev/ixgbe
Message-ID:  <201601261230.u0QCUH5D009243@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: smh
Date: Tue Jan 26 12:30:17 2016
New Revision: 294795
URL: https://svnweb.freebsd.org/changeset/base/294795

Log:
  ixgbe sysctl hardware defaults
  
  Added hw.ix.flow_control which enables the default flow_control of all ix
  interfaces to be set in loader.conf.
  
  Added hw.ix.advertise_speed which enables the default advertised_speed of
  all ix interfaces to be set in loader.conf.
  
  Made enable_aim device independent based on hw.ix.enable_aim default.
  
  Reviewed by:	erj
  MFC after:	1 week
  Sponsored by:	Multiplay
  Differential Revision:	https://reviews.freebsd.org/D5060

Modified:
  head/sys/dev/ixgbe/if_ix.c
  head/sys/dev/ixgbe/ixgbe.h

Modified: head/sys/dev/ixgbe/if_ix.c
==============================================================================
--- head/sys/dev/ixgbe/if_ix.c	Tue Jan 26 12:28:53 2016	(r294794)
+++ head/sys/dev/ixgbe/if_ix.c	Tue Jan 26 12:30:17 2016	(r294795)
@@ -166,12 +166,14 @@ static void	ixgbe_unregister_vlan(void *
 
 static void	ixgbe_add_device_sysctls(struct adapter *);
 static void     ixgbe_add_hw_stats(struct adapter *);
+static int	ixgbe_set_flowcntl(struct adapter *, int);
+static int	ixgbe_set_advertise(struct adapter *, int);
 
 /* Sysctl handlers */
 static void	ixgbe_set_sysctl_value(struct adapter *, const char *,
 		     const char *, int *, int);
-static int	ixgbe_set_flowcntl(SYSCTL_HANDLER_ARGS);
-static int	ixgbe_set_advertise(SYSCTL_HANDLER_ARGS);
+static int	ixgbe_sysctl_flowcntl(SYSCTL_HANDLER_ARGS);
+static int	ixgbe_sysctl_advertise(SYSCTL_HANDLER_ARGS);
 static int	ixgbe_sysctl_thermal_test(SYSCTL_HANDLER_ARGS);
 static int	ixgbe_sysctl_dmac(SYSCTL_HANDLER_ARGS);
 static int	ixgbe_sysctl_phy_temp(SYSCTL_HANDLER_ARGS);
@@ -290,6 +292,16 @@ SYSCTL_INT(_hw_ix, OID_AUTO, tx_process_
     "Maximum number of sent packets to process at a time,"
     "-1 means unlimited");
 
+/* Flow control setting, default to full */
+static int ixgbe_flow_control = ixgbe_fc_full;
+SYSCTL_INT(_hw_ix, OID_AUTO, flow_control, CTLFLAG_RDTUN,
+    &ixgbe_flow_control, 0, "Default flow control used for all adapters");
+
+/* Advertise Speed, default to 0 (auto) */
+static int ixgbe_advertise_speed = 0;
+SYSCTL_INT(_hw_ix, OID_AUTO, advertise_speed, CTLFLAG_RDTUN,
+    &ixgbe_advertise_speed, 0, "Default advertised speed for all adapters");
+
 /*
 ** Smart speed setting, default to on
 ** this only works as a compile option
@@ -568,6 +580,11 @@ ixgbe_attach(device_t dev)
 		break;
 	}
 
+	/* hw.ix defaults init */
+	ixgbe_set_advertise(adapter, ixgbe_advertise_speed);
+	ixgbe_set_flowcntl(adapter, ixgbe_flow_control);
+	adapter->enable_aim = ixgbe_enable_aim;
+
 	if ((adapter->msix > 1) && (ixgbe_enable_msix))
 		error = ixgbe_allocate_msix(adapter); 
 	else
@@ -1553,7 +1570,7 @@ ixgbe_msix_que(void *arg)
 
 	/* Do AIM now? */
 
-	if (ixgbe_enable_aim == FALSE)
+	if (adapter->enable_aim == FALSE)
 		goto no_calc;
 	/*
 	** Do Adaptive Interrupt Moderation:
@@ -4276,7 +4293,7 @@ ixgbe_add_device_sysctls(struct adapter 
 	/* Sysctls for all devices */
 	SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "fc",
 			CTLTYPE_INT | CTLFLAG_RW, adapter, 0,
-			ixgbe_set_flowcntl, "I", IXGBE_SYSCTL_DESC_SET_FC);
+			ixgbe_sysctl_flowcntl, "I", IXGBE_SYSCTL_DESC_SET_FC);
 
         SYSCTL_ADD_INT(ctx, child, OID_AUTO, "enable_aim",
 			CTLFLAG_RW,
@@ -4284,7 +4301,7 @@ ixgbe_add_device_sysctls(struct adapter 
 
 	SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "advertise_speed",
 			CTLTYPE_INT | CTLFLAG_RW, adapter, 0,
-			ixgbe_set_advertise, "I", IXGBE_SYSCTL_DESC_ADV_SPEED);
+			ixgbe_sysctl_advertise, "I", IXGBE_SYSCTL_DESC_ADV_SPEED);
 
 	SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "thermal_test",
 			CTLTYPE_INT | CTLFLAG_RW, adapter, 0,
@@ -4649,41 +4666,51 @@ ixgbe_set_sysctl_value(struct adapter *a
 **	3 - full
 */
 static int
-ixgbe_set_flowcntl(SYSCTL_HANDLER_ARGS)
+ixgbe_sysctl_flowcntl(SYSCTL_HANDLER_ARGS)
 {
-	int error, last;
-	struct adapter *adapter = (struct adapter *) arg1;
+	int error, fc;
+	struct adapter *adapter;
+
+	adapter = (struct adapter *) arg1;
+	fc = adapter->fc;
 
-	last = adapter->fc;
-	error = sysctl_handle_int(oidp, &adapter->fc, 0, req);
+	error = sysctl_handle_int(oidp, &fc, 0, req);
 	if ((error) || (req->newptr == NULL))
 		return (error);
 
 	/* Don't bother if it's not changed */
-	if (adapter->fc == last)
+	if (adapter->fc == fc)
 		return (0);
 
-	switch (adapter->fc) {
-		case ixgbe_fc_rx_pause:
-		case ixgbe_fc_tx_pause:
-		case ixgbe_fc_full:
-			adapter->hw.fc.requested_mode = adapter->fc;
-			if (adapter->num_queues > 1)
-				ixgbe_disable_rx_drop(adapter);
-			break;
-		case ixgbe_fc_none:
-			adapter->hw.fc.requested_mode = ixgbe_fc_none;
-			if (adapter->num_queues > 1)
-				ixgbe_enable_rx_drop(adapter);
-			break;
-		default:
-			adapter->fc = last;
-			return (EINVAL);
+	return ixgbe_set_flowcntl(adapter, fc);
+}
+
+
+static int
+ixgbe_set_flowcntl(struct adapter *adapter, int fc)
+{
+
+	switch (fc) {
+	case ixgbe_fc_rx_pause:
+	case ixgbe_fc_tx_pause:
+	case ixgbe_fc_full:
+		adapter->hw.fc.requested_mode = adapter->fc;
+		if (adapter->num_queues > 1)
+			ixgbe_disable_rx_drop(adapter);
+		break;
+	case ixgbe_fc_none:
+		adapter->hw.fc.requested_mode = ixgbe_fc_none;
+		if (adapter->num_queues > 1)
+			ixgbe_enable_rx_drop(adapter);
+		break;
+	default:
+		return (EINVAL);
 	}
+	adapter->fc = fc;
 	/* Don't autoneg if forcing a value */
 	adapter->hw.fc.disable_fc_autoneg = TRUE;
 	ixgbe_fc_enable(&adapter->hw);
-	return error;
+	return (0);
 }
 
 /*
@@ -4694,31 +4721,39 @@ ixgbe_set_flowcntl(SYSCTL_HANDLER_ARGS)
 **	0x4 - advertise 10G
 */
 static int
-ixgbe_set_advertise(SYSCTL_HANDLER_ARGS)
+ixgbe_sysctl_advertise(SYSCTL_HANDLER_ARGS)
 {
-	int			error = 0, requested;
-	struct adapter		*adapter;
-	device_t		dev;
-	struct ixgbe_hw		*hw;
-	ixgbe_link_speed	speed = 0;
+	int error, advertise;
+	struct adapter *adapter;
 
 	adapter = (struct adapter *) arg1;
-	dev = adapter->dev;
-	hw = &adapter->hw;
+	advertise = adapter->advertise;
 
-	requested = adapter->advertise;
-	error = sysctl_handle_int(oidp, &requested, 0, req);
+	error = sysctl_handle_int(oidp, &advertise, 0, req);
 	if ((error) || (req->newptr == NULL))
 		return (error);
 
+	/* Checks to validate new value */
+	if (adapter->advertise == advertise) /* no change */
+		return (0);
+
+	return ixgbe_set_advertise(adapter, advertise);
+}
+
+static int
+ixgbe_set_advertise(struct adapter *adapter, int advertise)
+{
+	device_t		dev;
+	struct ixgbe_hw		*hw;
+	ixgbe_link_speed	speed;
+
+	hw = &adapter->hw;
+	dev = adapter->dev;
+
 	/* No speed changes for backplane media */
 	if (hw->phy.media_type == ixgbe_media_type_backplane)
 		return (ENODEV);
 
-	/* Checks to validate new value */
-	if (adapter->advertise == requested) /* no change */
-		return (0);
-
 	if (!((hw->phy.media_type == ixgbe_media_type_copper) ||
 	    (hw->phy.multispeed_fiber))) {
 		device_printf(dev,
@@ -4727,13 +4762,13 @@ ixgbe_set_advertise(SYSCTL_HANDLER_ARGS)
 		return (EINVAL);
 	}
 
-	if (requested < 0x1 || requested > 0x7) {
+	if (advertise < 0x1 || advertise > 0x7) {
 		device_printf(dev,
 		    "Invalid advertised speed; valid modes are 0x1 through 0x7\n");
 		return (EINVAL);
 	}
 
-	if ((requested & 0x1)
+	if ((advertise & 0x1)
 	    && (hw->mac.type != ixgbe_mac_X540)
 	    && (hw->mac.type != ixgbe_mac_X550)) {
 		device_printf(dev, "Set Advertise: 100Mb on X540/X550 only\n");
@@ -4741,18 +4776,19 @@ ixgbe_set_advertise(SYSCTL_HANDLER_ARGS)
 	}
 
 	/* Set new value and report new advertised mode */
-	if (requested & 0x1)
+	speed = 0;
+	if (advertise & 0x1)
 		speed |= IXGBE_LINK_SPEED_100_FULL;
-	if (requested & 0x2)
+	if (advertise & 0x2)
 		speed |= IXGBE_LINK_SPEED_1GB_FULL;
-	if (requested & 0x4)
+	if (advertise & 0x4)
 		speed |= IXGBE_LINK_SPEED_10GB_FULL;
+	adapter->advertise = advertise;
 
 	hw->mac.autotry_restart = TRUE;
 	hw->mac.ops.setup_link(hw, speed, TRUE);
-	adapter->advertise = requested;
 
-	return (error);
+	return (0);
 }
 
 /*

Modified: head/sys/dev/ixgbe/ixgbe.h
==============================================================================
--- head/sys/dev/ixgbe/ixgbe.h	Tue Jan 26 12:28:53 2016	(r294794)
+++ head/sys/dev/ixgbe/ixgbe.h	Tue Jan 26 12:30:17 2016	(r294795)
@@ -497,6 +497,7 @@ struct adapter {
 	u32			optics;
 	u32			fc; /* local flow ctrl setting */
 	int			advertise;  /* link speeds */
+	bool			enable_aim; /* adaptive interrupt moderation */
 	bool			link_active;
 	u16			max_frame_size;
 	u16			num_segs;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201601261230.u0QCUH5D009243>