Date: Mon, 10 Apr 2000 22:18:25 +0100 (BST) From: Duncan Barclay <dmlb@ragnet.demon.co.uk> To: freebsd-hackers@freebsd.org Subject: Help with network driver development Message-ID: <XFMail.000410221825.dmlb@computer.my.domain>
next in thread | raw e-mail | index | archive | help
Hi all I've successfully ported the NetBSD if_ray (Webgear PCCard Wireless LAN) driver to RELENG_3 but have realised that the driver has a bit of a problem and I would like some advice on the best way to fix it. The card doesn't present a register set but uses a mailbox type system to set up most things. The driver fills in a struct in shared ram, pings the card that then completes the command and interrupts when finished. The problem is that the driver returns to userland before the command (e.g. update to multicast list via an ioctl) actually completes. The symptom is everything going belly up when something does: #!/bin/sh ifconfig ray0 inet 192.168.247.32 ifconfig ray0 inet 192.168.247.33 (a bit like dhclient) because the card cannot cope with being told to update (for example) the multicast list until it has finished the previous update. I have a number of alternatives to fixing all this within the driver and sleeping until the user command has completed and I'll go for the most straight forward. My question to all the network driver gods is how best to serialise access to the driver to different userland processes? I want to ensure that two different processes don't try and access the card simultaneously and muck each other up. Am I right in assuming that the ioctl is the only user land entry point to a network driver? Is something like this sufficient (and right) for ioctl entry? ray_ioctl(...) { ... s = splimp(); switch (command) { case SIOCADDMULTI: case SIOCDELMULTI: /* Get exclusive lock */ while (1) { if (!softc->lock) { softc->lock++; break; } rv = tsleep(softc->lock, 0|PCATCH, "rayexl"); if (rv) return (rv); if ((ifp->if_flags & IFF_RUNNING) == 0) return (EIO); } /* Run command and sleep until completed */ ray_update_mcast(sc); rv = tsleep(softc->lock, 0|PCATCH, "raycmd"); /* Release exclusive lock */ softc->lock = 0; splx(s); wakeup(softc->lock); return (rv); break; ... } } The last released version of the driver (and raycontrol like wicontrol(8)) is available at http://www.ragnet.demon.co.uk/raylink.tar.gz this works well for tx and rx and "slow" changes to the device parameters. I can make available later versions with more debugging of the above problems if needed. Duncan PS. Until pccard in RELENG_4 allows access to both attribute and common memory (a bit like if_xe) the driver won't be advanced to > RELENG_3 :-( PPS. This is my first driver. --- ________________________________________________________________________ Duncan Barclay | God smiles upon the little children, dmlb@ragnet.demon.co.uk | the alcoholics, and the permanently stoned. ________________________________________________________________________ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.000410221825.dmlb>