Re: Help with device drivers
Hans Petter Selasky wrote: > On Monday 10 August 2009 13:39:31 Krassimir Slavchev wrote: >> If I try to open the device from userland with: >> fd = open("/dev/xxx0", O_RDWR) it fails because open() tries to open the >> device for reading first and then for writing. > > There is a bug in the code. If you open using read+write flags, then the FIFO > open routine is called two times. The RD+WR check should be moved to the > ioctl > routine. > > http://perforce.freebsd.org/chv.cgi?CH=167171 Thanks! It seems that sys/dev/usb/storage/urio.c should be fixed too? Best Regards > > --HPS > > ___ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org" > ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"
Tracing Wake on Lan problem?
Greetings, I'm trying to get the Wake on Lan feature working on a 7.2-release box. I have two Intel NIC's, a Pro/100 and Pro/1000 (82541PI). The Pro/100 worked great right from the start using the generic kernel and was detected by the fxp driver. Using the wol (from ports) on another box fired the WoL box right up. However, I would like to use the gigabit card in the WoL box, which is detected by the em driver, and according to the WoL wiki and some posts to hackers a few months ago, the em driver does not have WoL support yet. I went digging and actually found FreeBSD specific drivers (in source code form) on Intel's site (would never have guessed that in a million years) and the code provided builds an if_em kernel load module. So I built a custom kernel removing all network card drivers. Then I built and installed the Intel provided if_em module. The system starts fine and configures the NIC, but I still do not have WoL ability. What can I do to track down where the problem might be? Here are some details: # dmesg . . . em0: port 0x14c0-0x14ff mem 0x4020-0x4021,0x4030-0x4031 irq 18 at device 9.0 on pci2 . . . 6.9.12 is the version in the source code provided by Intel. The em driver that comes with 7.2R is 6.9.6 I believe. Device 0x107c matches my NIC in the e1000_hw.h file: #define E1000_DEV_ID_82541GI_LF 0x107C # sysctl -a | grep em.0 dev.em.0.%desc: Intel(R) PRO/1000 Network Connection 6.9.12 dev.em.0.%driver: em dev.em.0.%location: slot=9 function=0 dev.em.0.%pnpinfo: vendor=0x8086 device=0x107c subvendor=0x8086 subdevice=0x1376 class=0x02 dev.em.0.%parent: pci2 dev.em.0.debug: -1 dev.em.0.stats: -1 dev.em.0.rx_int_delay: 0 dev.em.0.tx_int_delay: 66 dev.em.0.rx_abs_int_delay: 66 dev.em.0.tx_abs_int_delay: 66 dev.em.0.rx_processing_limit: 100 # ifconfig -m em0 em0: flags=8843 metric 0 mtu 1500 options=9b capabilities=19b ether 00:1b:21:3a:32:ed inet 10.0.81.6 netmask 0xff00 broadcast 10.0.81.255 media: Ethernet autoselect (1000baseTX ) status: active supported media: media autoselect media 1000baseTX media 1000baseTX mediaopt full-duplex media 100baseTX mediaopt full-duplex media 100baseTX media 10baseT/UTP mediaopt full-duplex media 10baseT/UTP The card does not report WoL in its capabilities, however the datasheet (http://download.intel.com/design/network/datashts/318138.pdf) indicates WoL support. # kldstat Id Refs AddressSize Name 18 0xc040 536ef8 kernel 21 0xc0937000 31eecif_em.ko 31 0xc0969000 6a45cacpi.ko 41 0xc238b000 3000 daemon_saver.ko # kldstat -v . . . 21 0xc0937000 31eecif_em.ko Contains modules: Id Name 1 pci/em . . . The if_em.c code from Intel also have functions for dealing with WoL: /* Management and WOL Support */ static void em_init_manageability(struct adapter *); static void em_release_manageability(struct adapter *); static void em_get_hw_control(struct adapter *); static void em_release_hw_control(struct adapter *); static void em_enable_wakeup(device_t); I've been reading through the code to see if there is any reason why my specific chipset would be ignored or have special #ifdefs, etc., but I don't see anything. Only the multi-port fiber cards seem to have special code (only port A supports the WoL it seems). I'm pretty good with C but have no device driver programming experience (but I would like to learn some). Any tips or pointers on how I can proceeded to solving this would be greatly appreciated. Also, is there any reason Intel's source is not provided with FreeBSD, since it seems they have taken the time to write the driver? Probably a copyright thing right? Either way, I'd like to get this working if possible. Thanks, Matthew ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"
device drivers (Krassimir Slavchev) REPLY fd = open("/dev/xxx0", O_RDWR)
Hello Krassimir~ open() fails with [ENXIO]...or other? Please advise~ Regards m_li --- On Mon, 8/10/09, freebsd-hackers-requ...@freebsd.org wrote: From: freebsd-hackers-requ...@freebsd.org Subject: freebsd-hackers Digest, Vol 333, Issue 1 To: freebsd-hackers@freebsd.org Date: Monday, August 10, 2009, 8:00 AM Send freebsd-hackers mailing list submissions to freebsd-hackers@freebsd.org To subscribe or unsubscribe via the World Wide Web, visit http://lists.freebsd.org/mailman/listinfo/freebsd-hackers or, via email, send a message with subject or body 'help' to freebsd-hackers-requ...@freebsd.org You can reach the person managing the list at freebsd-hackers-ow...@freebsd.org When replying, please edit your Subject line so it is more specific than "Re: Contents of freebsd-hackers digest..." Today's Topics: 1. Help with device drivers (Krassimir Slavchev) -- Message: 1 Date: Mon, 10 Aug 2009 14:39:31 +0300 From: Krassimir Slavchev Subject: Help with device drivers To: freebsd-hackers@freebsd.org Message-ID: <4a8006f3.5020...@bulinfo.net> Content-Type: text/plain; charset=ISO-8859-1 -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi All, Looking at sys/dev/usb/misc/ufm.c ... static int ufm_open(struct usb_fifo *dev, int fflags) { if ((fflags & (FWRITE | FREAD)) != (FWRITE | FREAD)) { return (EACCES); } return (0); } ... and sys/dev/usb/storage/urio.c ... static int urio_open(struct usb_fifo *fifo, int fflags) { struct urio_softc *sc = usb_fifo_softc(fifo); if ((fflags & (FWRITE | FREAD)) != (FWRITE | FREAD)) { return (EACCES); } ... If I try to open the device from userland with: fd = open("/dev/xxx0", O_RDWR) it fails because open() tries to open the device for reading first and then for writing. Do I use the wrong function to open such devices? Best Regards -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (FreeBSD) iD8DBQFKgAbyxJBWvpalMpkRAt2ZAKCWfTWtaCu+1Xcf70Z9RM3+peZJ/ACgof4q ybg2Mu3tDnz6Jwc1MA/Zwzs= =Usso -END PGP SIGNATURE- -- ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org" End of freebsd-hackers Digest, Vol 333, Issue 1 *** ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"
Re: How to signal a time zone change?
On Fri, 7 Aug 2009 15:08:16 -0700 "Peter Steele" wrote: > >What's the value of the TZ environment variable for the C apps? You may > need to have them read the new value from somewhere, and then rerun > tzset(). > > The default value of the TZ environment variable is null. I just tried > passing the explicitly time zone value to the C app and setting TZ to > that value and that seemed to work. I would think that that I should be > able to retrieve that value from /etc/localtime as the docs imply. Guess > not. If I have to pass the time zone to the C app, then I guess that's > what I'll do... This doesn't work because of two bugs in localtime.c. The first is what you're hitting where tzset() calls tzset_basic() which calls tzsetwall_basic() which says: if (lcl_is_set < 0) { if (!rdlocked) _RWLOCK_UNLOCK(&lcl_rwlock); return; } If you were to have your own TZ setting and wanted to modify the file referred to by that, you'd bump into this bug in tzset_basic(): if (lcl_is_set > 0 && strcmp(lcl_TZname, name) == 0) { if (!rdlocked) _RWLOCK_UNLOCK(&lcl_rwlock); return; } Roughly translated, localtime.c goes out of its way to never re-read the same zone file twice in a row. This is just a mistake. As you discovered, altering TZ before calling tzset() is the best way to make it work right now. If you really want to ensure that you're reading /etc/localtime, this bit of hackery works too: putenv("TZ=/dev/null"); tzset(); unsetenv("TZ"); tzset(); If you raise a PR and let me know the number, I'd be happy to fix this. -- Brian Somers Don't _EVER_ lose your sense of humour ! signature.asc Description: PGP signature
Re: Help with device drivers
On Monday 10 August 2009 13:39:31 Krassimir Slavchev wrote: > If I try to open the device from userland with: > fd = open("/dev/xxx0", O_RDWR) it fails because open() tries to open the > device for reading first and then for writing. There is a bug in the code. If you open using read+write flags, then the FIFO open routine is called two times. The RD+WR check should be moved to the ioctl routine. http://perforce.freebsd.org/chv.cgi?CH=167171 --HPS ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"
Help with device drivers
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi All, Looking at sys/dev/usb/misc/ufm.c ... static int ufm_open(struct usb_fifo *dev, int fflags) { if ((fflags & (FWRITE | FREAD)) != (FWRITE | FREAD)) { return (EACCES); } return (0); } ... and sys/dev/usb/storage/urio.c ... static int urio_open(struct usb_fifo *fifo, int fflags) { struct urio_softc *sc = usb_fifo_softc(fifo); if ((fflags & (FWRITE | FREAD)) != (FWRITE | FREAD)) { return (EACCES); } ... If I try to open the device from userland with: fd = open("/dev/xxx0", O_RDWR) it fails because open() tries to open the device for reading first and then for writing. Do I use the wrong function to open such devices? Best Regards -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (FreeBSD) iD8DBQFKgAbyxJBWvpalMpkRAt2ZAKCWfTWtaCu+1Xcf70Z9RM3+peZJ/ACgof4q ybg2Mu3tDnz6Jwc1MA/Zwzs= =Usso -END PGP SIGNATURE- ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"