From owner-svn-src-stable@freebsd.org Thu Feb 11 17:34:28 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 12246AA5FBD; Thu, 11 Feb 2016 17:34:28 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C7B461B39; Thu, 11 Feb 2016 17:34:27 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u1BHYQRX049997; Thu, 11 Feb 2016 17:34:26 GMT (envelope-from smh@FreeBSD.org) Received: (from smh@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u1BHYQ0K049994; Thu, 11 Feb 2016 17:34:26 GMT (envelope-from smh@FreeBSD.org) Message-Id: <201602111734.u1BHYQ0K049994@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: smh set sender to smh@FreeBSD.org using -f From: Steven Hartland Date: Thu, 11 Feb 2016 17:34:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r295534 - stable/10/sys/dev/ixgbe X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Feb 2016 17:34:28 -0000 Author: smh Date: Thu Feb 11 17:34:26 2016 New Revision: 295534 URL: https://svnweb.freebsd.org/changeset/base/295534 Log: MFC r294795 ixgbe sysctl hardware defaults Approved by: re (marius) Sponsored by: Multiplay Modified: stable/10/sys/dev/ixgbe/if_ix.c stable/10/sys/dev/ixgbe/ixgbe.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/ixgbe/if_ix.c ============================================================================== --- stable/10/sys/dev/ixgbe/if_ix.c Thu Feb 11 17:33:55 2016 (r295533) +++ stable/10/sys/dev/ixgbe/if_ix.c Thu Feb 11 17:34:26 2016 (r295534) @@ -165,12 +165,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); @@ -293,6 +295,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 @@ -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 /* 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 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 *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); } /* @@ -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); } /* Modified: stable/10/sys/dev/ixgbe/ixgbe.h ============================================================================== --- stable/10/sys/dev/ixgbe/ixgbe.h Thu Feb 11 17:33:55 2016 (r295533) +++ stable/10/sys/dev/ixgbe/ixgbe.h Thu Feb 11 17:34:26 2016 (r295534) @@ -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;