Re: How to add wake on lan support for your card (was: Re: FreeBSD WOL sis on)

2007-11-29 Thread Alexander Leidinger
Quoting Remko Lodder [EMAIL PROTECTED] (from Thu, 29 Nov 2007  
07:19:36 +0100 (CET)):



On Thu, November 29, 2007 12:01 am, Stefan Sperling wrote:



OK, I've created an account in the wiki.
My login is StefanSperling

Thanks :)



I added you to the list.


I created http://wiki.freebsd.org/WakeOnLan with appropriate rights  
for contributors.


Bye,
Alexander.

--
Nasrudin walked into a teahouse and declaimed, The moon is more useful
than the sun.
Why?, he was asked.
Because at night we need the light more.

http://www.Leidinger.netAlexander @ Leidinger.net: PGP ID = B0063FE7
http://www.FreeBSD.org   netchild @ FreeBSD.org  : PGP ID = 72077137
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: How to add wake on lan support for your card (was: Re: FreeBSD WOL sis on)

2007-11-28 Thread Julian H. Stacey
 Well, I hope I haven't missed anything important, but I guess
 that's about it.

Wow ! seems like you spent a fair time assembling that lot,
 it'd sure be a shame if it just got dusty in mail archives,
(OK apart from current readers who might latch it).

Maybe you could send it to [EMAIL PROTECTED] list or via send-pr 
suggest it be swallowed as an Annex to main docs ? Seems useful.

-- 
Julian Stacey. Munich Computer Consultant, BSD Unix C Linux. http://berklix.com
Ihr Rauch = mein allergischer Kopfschmerz. Dump cigs 4 snuff.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: How to add wake on lan support for your card (was: Re: FreeBSD WOL sis on)

2007-11-28 Thread Stefan Sperling
On Wed, Nov 28, 2007 at 05:13:28PM +0100, Julian H. Stacey wrote:
  Well, I hope I haven't missed anything important, but I guess
  that's about it.
 
 Wow ! seems like you spent a fair time assembling that lot,

About 2 hours.

  it'd sure be a shame if it just got dusty in mail archives,
 (OK apart from current readers who might latch it).

Thanks.

 Maybe you could send it to [EMAIL PROTECTED] list or via send-pr 
 suggest it be swallowed as an Annex to main docs ? Seems useful.

I guess the wiki would be more appropriate than the main docs.

Maybe we should add a wiki page about wake on lan?
Reading http://wiki.freebsd.org/AboutWiki it seems that if
I created an account there and someone added me to the
ContributorsGroup for a new WakeOnLan page I would be good to go.

Another place I could add it to is the wake on lan PR, which is at
http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/83807

Anyway, it's not lost in any case, because it's in the archives,
and at least I know about it and can always link people there if
they want to read it (or if they ask me to add support for
their card, heheh).

-- 
stefan
http://stsp.name PGP Key: 0xF59D25F0


pgp6zAcHHkE7k.pgp
Description: PGP signature


Re: How to add wake on lan support for your card (was: Re: FreeBSD WOL sis on)

2007-11-28 Thread Alexander Leidinger
Quoting Stefan Sperling [EMAIL PROTECTED] (Wed, 28 Nov 2007 19:06:18 +0100):

 On Wed, Nov 28, 2007 at 05:13:28PM +0100, Julian H. Stacey wrote:
   Well, I hope I haven't missed anything important, but I guess
   that's about it.
  
  Wow ! seems like you spent a fair time assembling that lot,
 
 About 2 hours.
 
   it'd sure be a shame if it just got dusty in mail archives,
  (OK apart from current readers who might latch it).
 
 Thanks.
 
  Maybe you could send it to [EMAIL PROTECTED] list or via send-pr 
  suggest it be swallowed as an Annex to main docs ? Seems useful.
 
 I guess the wiki would be more appropriate than the main docs.
 
 Maybe we should add a wiki page about wake on lan?
 Reading http://wiki.freebsd.org/AboutWiki it seems that if
 I created an account there and someone added me to the
 ContributorsGroup for a new WakeOnLan page I would be good to go.

This is right. If you tell us the name you registered (we have the
convention to use FirstnameLastname), I try to get the time to add you.

Bye,
Alexander.

-- 
We Klingons believe as you do -- the sick should die.  Only the strong
should live.
-- Kras, Friday's Child, stardate 3497.2
http://www.Leidinger.net  Alexander @ Leidinger.net: PGP ID = B0063FE7
http://www.FreeBSD.org netchild @ FreeBSD.org  : PGP ID = 72077137
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: How to add wake on lan support for your card (was: Re: FreeBSD WOL sis on)

2007-11-28 Thread Stefan Sperling
On Wed, Nov 28, 2007 at 07:57:57PM +0100, Alexander Leidinger wrote:
  Maybe we should add a wiki page about wake on lan?
  Reading http://wiki.freebsd.org/AboutWiki it seems that if
  I created an account there and someone added me to the
  ContributorsGroup for a new WakeOnLan page I would be good to go.
 
 This is right. If you tell us the name you registered (we have the
 convention to use FirstnameLastname), I try to get the time to add you.

OK, I've created an account in the wiki.
My login is StefanSperling

Thanks :)

-- 
stefan
http://stsp.name PGP Key: 0xF59D25F0


pgpfGhqos5q8j.pgp
Description: PGP signature


Re: How to add wake on lan support for your card (was: Re: FreeBSD WOL sis on)

2007-11-28 Thread Remko Lodder

On Thu, November 29, 2007 12:01 am, Stefan Sperling wrote:
 On Wed, Nov 28, 2007 at 07:57:57PM +0100, Alexander Leidinger wrote:
  Maybe we should add a wiki page about wake on lan?
  Reading http://wiki.freebsd.org/AboutWiki it seems that if
  I created an account there and someone added me to the
  ContributorsGroup for a new WakeOnLan page I would be good to go.

 This is right. If you tell us the name you registered (we have the
 convention to use FirstnameLastname), I try to get the time to add you.

 OK, I've created an account in the wiki.
 My login is StefanSperling

 Thanks :)

 --
 stefan
 http://stsp.name PGP Key:
 0xF59D25F0


Hi Stefan,

I added you to the list.

Cheers
remko

-- 
/\   Best regards,  | [EMAIL PROTECTED]
\ /   Remko Lodder   | [EMAIL PROTECTED]
 Xhttp://www.evilcoder.org/  |
/ \   ASCII Ribbon Campaign  | Against HTML Mail and News


___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: FreeBSD WOL sis on

2007-11-25 Thread Stefan Sperling

Hey David,

(I'm Cc'ing this reply to hackers@ with David's consent.)

On Sat, Nov 24, 2007 at 11:31:24PM -0800, David Leslie wrote:
 Have an Intel ITX size board (D201GLY2) with a SiS 900
 NIC, which supports WOL and has a WOL-enabled FreeBSD
 driver, but does not actually wake after powering down
 (ACPI S5) from FreeBSD. Have verified that WOL works
 using ethtool in Linux.
 
 Am not a BSD user, but am attracted to the FreeNAS
 project which has recently integrated your WOL patch
 (hopefully a recent version).

The sis driver supports at least two different types
of cards.

What does dmesg print for your card? I have only one type of
NIC the sis driver supports and have only implemented support
for this one:

sis0: NatSemi DP8381[56] 10/100BaseTX port 0xac00-0xacff mem
0xdb001000-0xdb00
sis0: Silicon Revision: DP83816A

 From userspace it
 appears ready to set the NIC to wake (i.e. ifconfig
 returns will wake on: magic), but the system ignores
 magic packets and does not wake from FreeBSD.

If the card type isn't a DP83815 or DP83816, this is a bug.
The driver should not let you configure cards for WOL
it has no support for.

 Have verified that there is no reconfiguration of the
 adapter as part of the FreeNAS shutdown scripts. I see
 that your patch integrates changes to this driver, so
 maybe you might have seen the issue on other
 platforms? Any ideas where to look as a next step--
 would appear to be something in if_sis that is not
 working on this board?

There are many things that can go wrong with WOL.

Here's a quick checklist (the first three are probably
not causing your problem because you've verified that
WOL works with Linux):

Is the WOL cable plugged in properly (if needed)?

Are BIOS WOL settings OK?

Is ACPI enabled (in BIOS and OS)?

Have you used shutdown -p to shut down the box?
Using shutdown -h or halt and then turning the
power off might not work (at least I've never tried this...)

Does the card enter D3 sleep mode properly after the box
shuts down, i.e. does a NIC LED stay on after shutdown?

Do wake packets (e.g. magic packets) actually reach the box?
To find out, I do:
  while true; do wol -h 10.42.42.255 mac addr; sleep 1; done
and then if the box doesn't wake up I look at the NIC LEDS to
check for periodic blinking of the tx/rx LED.
Adjust the broadcast IP address to your network of course.

Hope this helps,
-- 
stefan
http://stsp.name PGP Key: 0xF59D25F0


pgp1h7VugA2Up.pgp
Description: PGP signature


Re: FreeBSD WOL sis on

2007-11-25 Thread David Leslie
Appreciate your quick response

 The sis driver supports at least two different types
 of cards.
Yes, among them SiS 900 series NIC. The NIC in
question is embedded on the Intel D201GLY/D201GLY2
desktop board (chipset is SiS662 NB + SiS964 SB). The
NatSemi DP8381[56] is the only implementation
currently supported by FreeBSD for WOL. SiS900 is a
different implementation from the NatSemi DP8381[56],
though they rely on the same if_sis driver. 

 What does dmesg print for your card? I have only one
 type of NIC the sis driver supports and have only
 implemented support for this one...
 NatSemi DP8381[56]
sis0: SiS 900 10/100BaseTX port 0x2000-0x20ff mem
0x4a10-0x4a100fff irq 19 at device 4.0 on pci0

 If the card type isn't a DP83815 or DP83816, this is
 a bug.  The driver should not let you configure
cards
 for WOL it has no support for.
Agreed, this is not a DP8381[56] NIC. Does not appear
to be a (presently) supported NIC for WOL in FreeBSD,
so it would be better if the WOL patch did not
identify its WOL capabilities and allow the setting of
WOL options in this case. Hopefully not a substantial
undertaking to correct. Are other cards supported by
if_sis similarly affected?

Thanks for the troubleshooting info-- can confirm that
the adapter appears to be powered in ACPI S5/D3 state
after shutdown -p from FreeBSD (with ifconfig sis0
wakeon magic). The LAN link light is on, and activity
light blinks when receiving WOL magic packets.

Linux does support WOL for (at least) this SiS900 NIC
(I can verify that it does work on this board), so
maybe it will be supported in FreeBSD in the future?

Thanks for your help

David

___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


How to add wake on lan support for your card (was: Re: FreeBSD WOL sis on)

2007-11-25 Thread Stefan Sperling
On Sun, Nov 25, 2007 at 10:53:59AM -0800, David Leslie wrote:
 Linux does support WOL for (at least) this SiS900 NIC
 (I can verify that it does work on this board), so
 maybe it will be supported in FreeBSD in the future?

Sure, it's possible.

Adding support for a card is not that hard actually.

It can be done in one or two evenings by someone who has
messed with any kind of driver before, and maybe a week
by someone who hasn't and is willing to learn basics about
device drivers, e.g. how to access and manipulate registers from C.
Knowing C is a prerequisite of course. I myself had no idea at all
about drivers either before I started working on the WOL patch.

But I currently rarely have time to work on this (except the odd
Sunday like today), and I keep getting requests to support more
chipsets that queue up faster than I can handle :-/

Maybe if I provide a little guide some people will get interested
and help a bit.

Here it goes:


= How to add WOL support for your card =

To add WOL support for your card, and you have no data sheet
for the card, first look at the Linux driver to find out whether
the card can do WOL under Linux. There should be some routines for
configuring WOL. Look at the ethtool_ops struct, if the driver
sets pointers to get_wol and set_wol routines inside it, it supports WOL.

For example, the via-rhine driver on Linux (if_vr on FreeBSD)
does this:

 static struct ethtool_ops netdev_ethtool_ops = {
 // snip
 .get_wol= rhine_get_wol,
 .set_wol= rhine_set_wol,
 // snip


Now that you know that you can get this to work, apply the WOL patch
to your system: http://stsp.næme/wol/
See the README.txt for instructions.


== How do I tell the chip on my card to do WOL? ==

You can do this in a new driver routine called dev_enable_wol(), where
dev_ is the usual driver name prefix, e.g. xl_enable_wol() for if_xl.

If you have a data sheet, it will probably tell you how to enable WOL
in detail. The data sheet for my NatSemi card is freely available
on the web and has a very good section on configuring wake on lan:

http://www.national.com/ds/DP/DP83815.pdf

Look at page 90 in that PDF. Even if your chip is different the general
procedure is likely the same on most chips so this serves as a good
example (along with a working implementation for the if_sis driver
in my patch). That page helped me getting started at lot.

How exactly WOL is configured depends on the device, but usually involves

a) configuring the receive filter
b) some WOL configuration register 
c) putting the device into D3 (sleep) power state


===  The receive filter ==

The receive filter will simply need to accept *any* kind of packet.

There is usually a register in the chip with bits that define
what kind packets the receiver on the card should hand on to
the driver and which it should just ignore -- typically the filter
understands unicast, multicast and broadcast packet types.

In case of the 3com chip, the Linux driver (3c59x) does this in
the acpi_set_WOL() function to set the bits in the receive register:

 /* The RxFilter must accept the WOL frames. */
 iowrite16(SetRxFilter|RxStation|RxMulticast|RxBroadcast, ioaddr + EL3_CMD);
 iowrite16(RxEnable, ioaddr + EL3_CMD);
 
The FreeBSD (almost) equivalent in xl_enable_wol() is this:

 /* Configure the receive filter to accept any kind of packet. */
 XL_SEL_WIN(5);
 rxfilt = CSR_READ_1(sc, XL_W5_RX_FILTER);
 rxfilt |= XL_RXFILTER_INDIVIDUAL | XL_RXFILTER_ALLMULTI |
  XL_RXFILTER_BROADCAST | XL_RXFILTER_ALLFRAMES;
 CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RX_SET_FILT | rxfilt);


Of course, register business is highly chip specific.
For example, other chips I've dealt with didn't have register
windows at all so the XL_SEL_WIN isn't needed there, and the bit
mask macros for the receive filter config register will of course
be named somewhat differently in each driver.

Of course, a data sheet helps. If you don't have one, looking
at what the Linux driver does and matching register offsets and
bit masks with the FreeBSD driver will probably help.


=== The WOL config register ===

The WOL config register is usually a 16bit (e.g. if_xl) or 32bit
(e.g. if_sis) register somewhere in the chip memory with each bit
corresponding to a certain type of wake event -- magic packet,
link status change, unicast packet reception, broadcast packet
reception, etc.

The device will only wake the system if an event happens that it has
been configured for.

Using the NatSemi card an example, there is a 32bit WOL configuration
register at offset 0x40 in the chip register space and bit number 9
(the 8th bit from the right) tells the chip to wake up if it receives
a magic packet. See the DP83815 data sheet again, page 55.

So to add wake on magic packet support, we add the follwing
to /usr/src/sys/dev/if_sisreg.h:

 /* NS DP83815/6 registers */
 // other registers omitted...
 

Re: How to add wake on lan support for your card (was: Re: FreeBSD WOL sis on)

2007-11-25 Thread Stefan Sperling
On Sun, Nov 25, 2007 at 10:48:50PM +0100, Stefan Sperling wrote:
 Using the NatSemi card an example, there is a 32bit WOL configuration
 register at offset 0x40 in the chip register space and bit number 9
 (the 8th bit from the right)

As usual I got the numbers wrong :)

Sorry if this is causing confusion for someone reading this.
Just skip the text inside the parentheses.

-- 
stefan
http://stsp.name PGP Key: 0xF59D25F0


pgpjhlMkV2P6m.pgp
Description: PGP signature