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: 0x000000ff (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.000000000 +0530 +++ /tmp/LM-ethernet.modified 2009-03-24 18:29:21.000000000 +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 2>&1 ; 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 2>&1 ; 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 2>&1 ; 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 2>&1 ; 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 2>&1 ; then + $LM_VERBOSE && echo "Disabled wakeup-on-LAN for $DEVICE" >> $OUTPUT + else + $LM_VERBOSE && echo "Could not disable wakeup-on-LAN for $DEVICE" >> $OUTPUT + 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 - $LM_VERBOSE && echo "Could not throttle ethernet device $DEVICE" >> $OUTPUT - fi - fi - done + THROTTLE_ETHERNET="$BATT_THROTTLE_ETHERNET" + fi + + if [ x$THROTTLE_ETHERNET = x1 ] ; then + if ethtool -s $DEVICE autoneg off speed 100 >> $OUTPUT 2>&1 ; then + $LM_VERBOSE && echo "Throttled speed to 100 Mbit for $DEVICE" >> $OUTPUT + else + $LM_VERBOSE && echo "Could not throttle ethernet device $DEVICE" >> $OUTPUT + fi + fi + done else $LM_VERBOSE && echo "Ethernet module is disabled." >> $OUTPUT fi
signature.asc
Description: This is a digitally signed message part.

