From owner-svn-src-all@FreeBSD.ORG Sat Jul 7 20:21:06 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A0309106564A; Sat, 7 Jul 2012 20:21:06 +0000 (UTC) (envelope-from jfv@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 802068FC12; Sat, 7 Jul 2012 20:21:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q67KL6SX083774; Sat, 7 Jul 2012 20:21:06 GMT (envelope-from jfv@svn.freebsd.org) Received: (from jfv@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q67KL6qc083771; Sat, 7 Jul 2012 20:21:06 GMT (envelope-from jfv@svn.freebsd.org) Message-Id: <201207072021.q67KL6qc083771@svn.freebsd.org> From: Jack F Vogel Date: Sat, 7 Jul 2012 20:21:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238214 - head/sys/dev/e1000 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Jul 2012 20:21:06 -0000 Author: jfv Date: Sat Jul 7 20:21:05 2012 New Revision: 238214 URL: http://svn.freebsd.org/changeset/base/238214 Log: Change the interface to the Energy Efficient Ethernet (EEE) setting in the igb and em driver. This was necessitated by a shared code change that I was given late in the game, a data type changed from bool to int, in the last update I dealt with it by a cast, but it was pointed out (thanks jhb) that there was a potential problem with this. John suggested this safer approach, and it is fine with me... MFC after:2 days (to catch the 9.1 update) Modified: head/sys/dev/e1000/if_em.c head/sys/dev/e1000/if_igb.c Modified: head/sys/dev/e1000/if_em.c ============================================================================== --- head/sys/dev/e1000/if_em.c Sat Jul 7 20:13:40 2012 (r238213) +++ head/sys/dev/e1000/if_em.c Sat Jul 7 20:21:05 2012 (r238214) @@ -289,6 +289,7 @@ static void em_handle_link(void *context static void em_set_sysctl_value(struct adapter *, const char *, const char *, int *, int); static int em_set_flowcntl(SYSCTL_HANDLER_ARGS); +static int em_sysctl_eee(SYSCTL_HANDLER_ARGS); static __inline void em_rx_discard(struct rx_ring *, int); @@ -389,7 +390,7 @@ SYSCTL_INT(_hw_em, OID_AUTO, rx_process_ "at a time, -1 means unlimited"); /* Energy efficient ethernet - default to OFF */ -static int eee_setting = 0; +static int eee_setting = 1; TUNABLE_INT("hw.em.eee_setting", &eee_setting); SYSCTL_INT(_hw_em, OID_AUTO, eee_setting, CTLFLAG_RDTUN, &eee_setting, 0, "Enable Energy Efficient Ethernet"); @@ -636,9 +637,12 @@ em_attach(device_t dev) " due to SOL/IDER session.\n"); /* Sysctl for setting Energy Efficient Ethernet */ - em_set_sysctl_value(adapter, "eee_control", - "enable Energy Efficient Ethernet", - (int *)&hw->dev_spec.ich8lan.eee_disable, eee_setting); + hw->dev_spec.ich8lan.eee_disable = eee_setting; + SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + OID_AUTO, "eee_control", CTLTYPE_INT|CTLFLAG_RW, + adapter, 0, em_sysctl_eee, "I", + "Disable Energy Efficient Ethernet"); /* ** Start from a known state, this is @@ -5695,6 +5699,27 @@ em_set_flowcntl(SYSCTL_HANDLER_ARGS) return (error); } +/* +** Manage Energy Efficient Ethernet: +** Control values: +** 0/1 - enabled/disabled +*/ +static int +em_sysctl_eee(SYSCTL_HANDLER_ARGS) +{ + struct adapter *adapter = (struct adapter *) arg1; + int error, value; + + value = adapter->hw.dev_spec.ich8lan.eee_disable; + error = sysctl_handle_int(oidp, &value, 0, req); + if (error || req->newptr == NULL) + return (error); + EM_CORE_LOCK(adapter); + adapter->hw.dev_spec.ich8lan.eee_disable = (value != 0); + em_init_locked(adapter); + EM_CORE_UNLOCK(adapter); + return (0); +} static int em_sysctl_debug_info(SYSCTL_HANDLER_ARGS) Modified: head/sys/dev/e1000/if_igb.c ============================================================================== --- head/sys/dev/e1000/if_igb.c Sat Jul 7 20:13:40 2012 (r238213) +++ head/sys/dev/e1000/if_igb.c Sat Jul 7 20:21:05 2012 (r238214) @@ -277,6 +277,7 @@ static void igb_set_sysctl_value(struct const char *, int *, int); static int igb_set_flowcntl(SYSCTL_HANDLER_ARGS); static int igb_sysctl_dmac(SYSCTL_HANDLER_ARGS); +static int igb_sysctl_eee(SYSCTL_HANDLER_ARGS); #ifdef DEVICE_POLLING static poll_handler_t igb_poll; @@ -586,10 +587,11 @@ igb_attach(device_t dev) SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "dmac", CTLTYPE_INT|CTLFLAG_RW, adapter, 0, igb_sysctl_dmac, "I", "DMA Coalesce"); - igb_set_sysctl_value(adapter, "eee_disabled", - "enable Energy Efficient Ethernet", - (int *)&adapter->hw.dev_spec._82575.eee_disable, - TRUE); + SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + OID_AUTO, "eee_disabled", CTLTYPE_INT|CTLFLAG_RW, + adapter, 0, igb_sysctl_eee, "I", + "Disable Energy Efficient Ethernet"); if (adapter->hw.phy.media_type == e1000_media_type_copper) e1000_set_eee_i350(&adapter->hw); } @@ -5988,3 +5990,25 @@ igb_sysctl_dmac(SYSCTL_HANDLER_ARGS) igb_init(adapter); return (error); } + +/* +** Manage Energy Efficient Ethernet: +** Control values: +** 0/1 - enabled/disabled +*/ +static int +igb_sysctl_eee(SYSCTL_HANDLER_ARGS) +{ + struct adapter *adapter = (struct adapter *) arg1; + int error, value; + + value = adapter->hw.dev_spec._82575.eee_disable; + error = sysctl_handle_int(oidp, &value, 0, req); + if (error || req->newptr == NULL) + return (error); + IGB_CORE_LOCK(adapter); + adapter->hw.dev_spec._82575.eee_disable = (value != 0); + igb_init_locked(adapter); + IGB_CORE_UNLOCK(adapter); + return (0); +}