summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authorsmh <smh@FreeBSD.org>2016-02-11 17:34:26 +0000
committersmh <smh@FreeBSD.org>2016-02-11 17:34:26 +0000
commitdc1aed8cd3252c89593a3505387a2d5e80c15b3f (patch)
tree31f85fd120455eb55060d468a867d342d741cdc3 /sys/dev
parent1f678f8c8fa0e9ab39ec82b54e92b43041f7948f (diff)
downloadFreeBSD-src-dc1aed8cd3252c89593a3505387a2d5e80c15b3f.zip
FreeBSD-src-dc1aed8cd3252c89593a3505387a2d5e80c15b3f.tar.gz
MFC r294795
ixgbe sysctl hardware defaults Approved by: re (marius) Sponsored by: Multiplay
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ixgbe/if_ix.c134
-rw-r--r--sys/dev/ixgbe/ixgbe.h1
2 files changed, 86 insertions, 49 deletions
diff --git a/sys/dev/ixgbe/if_ix.c b/sys/dev/ixgbe/if_ix.c
index 4386f5d..65e868a 100644
--- a/sys/dev/ixgbe/if_ix.c
+++ b/sys/dev/ixgbe/if_ix.c
@@ -165,12 +165,14 @@ static void ixgbe_unregister_vlan(void *, struct ifnet *, u16);
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);
@@ -293,6 +295,16 @@ SYSCTL_INT(_hw_ix, OID_AUTO, tx_process_limit, CTLFLAG_RDTUN,
"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
@@ -575,6 +587,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
@@ -1569,7 +1586,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:
@@ -4295,7 +4312,7 @@ ixgbe_add_device_sysctls(struct adapter *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,
@@ -4303,7 +4320,7 @@ ixgbe_add_device_sysctls(struct adapter *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,
@@ -4668,41 +4685,51 @@ ixgbe_set_sysctl_value(struct adapter *adapter, const char *name,
** 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);
}
/*
@@ -4713,31 +4740,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,
@@ -4746,13 +4781,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");
@@ -4760,18 +4795,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);
}
/*
diff --git a/sys/dev/ixgbe/ixgbe.h b/sys/dev/ixgbe/ixgbe.h
index 05fddf6..558b532 100644
--- a/sys/dev/ixgbe/ixgbe.h
+++ b/sys/dev/ixgbe/ixgbe.h
@@ -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;
OpenPOWER on IntegriCloud