Bug#519426: laptop-mode-tools: ethernet speed not restored

2009-03-24 Thread Ritesh Raj Sarraf
Hi Bart,

I'm attaching a not-so-good (and untested) patch. But first we need to agree if 
the current approach for handling ethernet devices is the right way. 


On Thursday 12 Mar 2009 19:29:02 Bart Samwel wrote:
 
  Anyway, LM should still be restoring the normal speed when on AC.
  Currently, it is not doing that.

 Thanks for reporting. I've set this back to severity normal since it's
 in a feature that's disabled by default and that's also not used very
 often (why not plug in the AC adapter if you have an ethernet cable
 handy?). I've just checked the code and it is indeed incorrect, it
 doesn't restore ethernet speed at all. I'll have it fixed in the next
 release.


I think the whole approach to hanling ethernet is wrong. In the current state, 
the assumption is that the user in on a gigabit ethernet which can be 
throttled to 100mbit when on battery.

There are users (including me), who have other laptops with ethernet 
capability of only 100mbit. There the ethernet feature will break.

Essentially, the right way of doing this should be to probe the device for its 
supported features/capabilities and then set MIN/MAX depending on Battery/AC.

For probing, depending on the modules will be wrong because every module might 
have a slightly different interface. Do you know of a common interface to probe 
capabilities of a network device ?

ethtool does provide the capabilities for a device. Like this:

r...@champaran:/usr/share/laptop-mode-tools/modules$ sudo ethtool eth0
[sudo] password for rrs:
Settings for eth0:
Supported ports: [ TP ]
Supported link modes:   10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes:  10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Advertised auto-negotiation: Yes
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: g
Wake-on: d
Current message level: 0x00ff (255)
Link detected: yes


We could rely on the Supported link modes here. That'd be one way.

What do you say ? Which approach should be taken ?
But, for sure, the current approach of making an assumption that the device is 
a gigabit ethernet, is incorrect.

PS: BTW, do you know where the $ACTIVATE is being initialized. I see a lot of 
the scripts using it but I'm not sure for what reason.
-- 
Ritesh Raj Sarraf
RESEARCHUT - http://www.researchut.com
Necessity is the mother of invention.

--- ethernet	2009-01-27 01:26:01.0 +0530
+++ /tmp/LM-ethernet.modified	2009-03-24 18:29:21.0 +0530
@@ -4,36 +4,65 @@
 #
 
 if [ x$CONTROL_ETHERNET = x1 ] ; then
-	for DEVICE in $ETHERNET_DEVICES ; do
-
-		# Wakeup-on-LAN handling
-		if [ x$DISABLE_WAKEUP_ON_LAN = x1 ] ; then
-			if ethtool -s $DEVICE wol d  $OUTPUT 21 ; then			
-$LM_VERBOSE  echo Disabled wakeup-on-LAN for $DEVICE  $OUTPUT
-			else
-$LM_VERBOSE  echo Could not disable wakeup-on-LAN for $DEVICE  $OUTPUT
+	if [ $ON_AC -eq 1 ]; then
+		for DEVICE in $ETHERNET_DEVICES ; do
+			# Wakeup-on-LAN handling
+			if [ x$DISABLE_WAKEUP_ON_LAN = x1 ] ; then
+# FIXME: This is bad. There should be a way to find out the capabilities of
+# the device and do the settings accordingly.
+# Since this is going to be used mostly on laptops, physical activity is the
+# wisest option to use, when returning back on AC.
+if ethtool -s $DEVICE wol p  $OUTPUT 21 ; then			
+	$LM_VERBOSE  echo Enabled  wakeup-on-LAN for $DEVICE  $OUTPUT
+else
+	$LM_VERBOSE  echo Could not enable wakeup-on-LAN for $DEVICE  $OUTPUT
+fi
 			fi
-		fi
 		
-		# Handle throttling to 100 Mbit
-		if [ $ON_AC -eq 1 ]; then
 			if [ $ACTIVATE -eq 1 ]; then
 THROTTLE_ETHERNET=$LM_AC_THROTTLE_ETHERNET
 			else
 THROTTLE_ETHERNET=$NOLM_AC_THROTTLE_ETHERNET
 			fi
-		else
-			THROTTLE_ETHERNET=$BATT_THROTTLE_ETHERNET
-		fi
 		
-		if [ x$THROTTLE_ETHERNET = x1 ] ; then
-			if  ethtool -s $DEVICE autoneg off speed 100   $OUTPUT 21 ; then			
-$LM_VERBOSE  echo Throttled speed to 100 Mbit for $DEVICE  $OUTPUT
+			if [ x$THROTTLE_ETHERNET = x1 ] ; then
+if  ethtool -s $DEVICE autoneg on duplex full   $OUTPUT 21 ; then			
+	$LM_VERBOSE  echo autoneg on and duplex full for  $DEVICE  $OUTPUT
+else
+	$LM_VERBOSE  echo couldn't set autoneg/duplex for $DEVICE  $OUTPUT
+fi		
+			fi
+		done
+	else
+		for DEVICE in $ETHERNET_DEVICES ; do
+			# Wakeup-on-LAN handling
+			if [ x$DISABLE_WAKEUP_ON_LAN = x1 ] ; then
+if ethtool -s $DEVICE wol d  $OUTPUT 21 ; then			
+	$LM_VERBOSE  echo Disabled wakeup-on-LAN for $DEVICE  $OUTPUT
+else
+	$LM_VERBOSE  echo Could not disable wakeup-on-LAN for $DEVICE  

Bug#519426: laptop-mode-tools: ethernet speed not restored

2009-03-12 Thread Ritesh Raj Sarraf
Package: laptop-mode-tools
Version: 1.47-1
Severity: important


I'd have preferred giving you a patch, but my ethernet driver itself has
some problems.

r...@champaran:/usr/share/laptop-mode-tools/modules$ sudo ethtool -s eth0
speed 1000 duplex full
Cannot set new settings: Invalid argument
  not setting speed
  not setting duplex


Anyway, LM should still be restoring the normal speed when on AC.
Currently, it is not doing that.


Ritesh


-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (101, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.28-custom (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages laptop-mode-tools depends on:
ii  lsb-base  3.2-20 Linux Standard Base 3.2 init scrip
ii  psmisc22.6-1 Utilities that use the proc filesy
ii  util-linux2.13.1.1-1 Miscellaneous system utilities

Versions of packages laptop-mode-tools recommends:
ii  acpid   1.0.8-6  Utilities for using ACPI power man
ii  apmd3.2.2-12 Utilities for Advanced Power Manag
ii  ethtool 6+20080913-1 display or change Ethernet device 
ii  hal 0.5.11-8 Hardware Abstraction Layer
ii  hdparm  8.9-3tune hard disk parameters for high
ii  sdparm  1.02-1   Output and modify SCSI device para

laptop-mode-tools suggests no packages.

-- no debconf information



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#519426: laptop-mode-tools: ethernet speed not restored

2009-03-12 Thread Bart Samwel
Hi Ritesh,

Ritesh Raj Sarraf wrote:
 I'd have preferred giving you a patch, but my ethernet driver itself has
 some problems.
 
 r...@champaran:/usr/share/laptop-mode-tools/modules$ sudo ethtool -s eth0
 speed 1000 duplex full
 Cannot set new settings: Invalid argument
   not setting speed
   not setting duplex
 
 
 Anyway, LM should still be restoring the normal speed when on AC.
 Currently, it is not doing that.

Thanks for reporting. I've set this back to severity normal since it's
in a feature that's disabled by default and that's also not used very
often (why not plug in the AC adapter if you have an ethernet cable
handy?). I've just checked the code and it is indeed incorrect, it
doesn't restore ethernet speed at all. I'll have it fixed in the next
release.

Cheers,
Bart



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org