Commit Graph

1339 Commits

Author SHA1 Message Date
pooka
10fe49d72c Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client.  This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached.  However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff.  ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
2010-01-19 22:06:18 +00:00
dyoung
cd6e1fbf91 Expand PMF_FN_* macros. 2010-01-08 19:53:10 +00:00
christos
641f5484f1 convert to pmf 2010-01-02 01:42:49 +00:00
dyoung
0a9ae61983 device_t/softc split. 2009-12-06 23:05:39 +00:00
dyoung
903d1910d3 Simplify device-activation hooks. 2009-12-06 23:05:06 +00:00
rmind
dbd9b86792 Remove some unecessary includes sys/user.h header. 2009-11-23 02:13:44 +00:00
dsl
9a2a9c3ff9 Remove "splurious interrupt" message. The IRQ might be shared.
Fixes PR/11410
2009-11-22 21:18:42 +00:00
dyoung
0db5f71432 Don't use com_activate(), it's gone away. Thanks to Andreas Wrede
for pointing out that these drivers still used com_activate().

Use device_private().  Join some lines.

Remove superfluous activation hooks.

Add child-detachment hooks (not used, yet).

TBD: device_t/softc split.
2009-11-13 01:14:35 +00:00
dyoung
a9d7fca27d Don't use com_activate(), it's gone away. Delete superfluous
activation hook, pcmcom_activate().

Add a child-detachment hook and use it.

Use device_private().

Cosmetic: use __arraycount().  Join a couple of lines.  Delete a
set of superfluous parentheses.
2009-11-12 22:46:47 +00:00
dyoung
9ab08beb52 Call com_detach() before doing any bus-specific detachment.
Don't use com_activate(), it's going away.
2009-11-12 20:29:30 +00:00
dyoung
2957bfb586 Remove superfluous activation hook.
Add a child-detachment hook.
2009-11-12 20:14:04 +00:00
dyoung
04b4cf9e54 Remove superfluous activation hook. 2009-11-12 19:37:17 +00:00
dyoung
f4ac73e2da Don't use the superfluous activation hook.
Cosmetic: while I'm here, join two lines.
2009-11-12 19:24:06 +00:00
snj
e88e7f274c Drop 3rd and 4th clauses. Approved by soren@ and Onno van der Linden
(copyright holders).
2009-10-22 18:47:56 +00:00
tsutsui
2f25e6cf41 - make local functions/variables static
- use __arraycount()
2009-09-22 13:20:36 +00:00
tsutsui
00eb8aa546 Split device_t/softc. Tested on AHA-1520B at ISA and ISAPnP.
XXX: ISA attachment shouldn't match cards in ISAPnP mode.
2009-09-22 12:56:06 +00:00
dyoung
662dfba47d To ease a future device_t/softc split, se device_private() instead
of casting device_t to softc.
2009-09-15 18:37:02 +00:00
tsutsui
edeaa5dd16 Invert logic around nested pmf(9) registrations for readability. 2009-09-05 14:44:59 +00:00
tsutsui
aa60aebf13 Replace shutdownhook_establish(9) with pmf_device_register1(9) in
MI epconfig() and ep_detach(), and remove pmf(9) calls in pcmcia attachment.
Tested on ep0 at pci, but pcmcia attachment is untested.
2009-09-05 12:30:59 +00:00
cegger
7cf2991222 struct device * -> device_t, no functional changes intended. 2009-05-12 14:38:26 +00:00
cegger
d16a259fe3 struct cfdata * -> cfdata_t, no functional changes intended. 2009-05-12 13:15:24 +00:00
elad
2d1c968399 Remove a few KAUTH_GENERIC_ISSUSER in favor of more descriptive
alternatives.

Discussed on tech-kern:

	http://mail-index.netbsd.org/tech-kern/2009/04/11/msg004798.html

Input from ad@, christos@, dyoung@, tsutsui@.

Okay ad@.
2009-04-15 20:44:24 +00:00
uwe
6a2ffc8f1b Provide pmf(9) hooks that do what dopowerhooks(9) hook does.
XXX: Do NOT call pmf_class_network_register() yet, b/c db8320.c
doesn't provide if_stop method!
2009-04-05 03:37:07 +00:00
uwe
4e37bb5a9c Register with pmf(9), tell it we don't need anything. 2009-04-05 02:29:40 +00:00
dyoung
0d1ba3e899 During shutdown, detach devices in an orderly fashion.
Call the detach routine for every device in the device tree, starting
with the leaves and moving toward the root, expecting that each
(pseudo-)device driver will use the opportunity to gracefully commit
outstandings transactions to the underlying (pseudo-)device and to
relinquish control of the hardware to the system BIOS.

Detaching devices is not suitable for every shutdown: in an emergency,
or if the system state is inconsistent, we should resort to a fast,
simple shutdown that uses only the pmf(9) shutdown hooks and the
(deprecated) shutdownhooks.  For now, if the flag RB_NOSYNC is set in
boothowto, opt for the fast, simple shutdown.

Add a device flag, DVF_DETACH_SHUTDOWN, that indicates by its presence
that it is safe to detach a device during shutdown.  Introduce macros
CFATTACH_DECL3() and CFATTACH_DECL3_NEW() for creating autoconf
attachments with default device flags.  Add DVF_DETACH_SHUTDOWN
to configuration attachments for atabus(4), atw(4) at cardbus(4),
cardbus(4), cardslot(4), com(4) at isa(4), elanpar(4), elanpex(4),
elansc(4), gpio(4), npx(4) at isa(4), nsphyter(4), pci(4), pcib(4),
pcmcia(4), ppb(4), sip(4), wd(4), and wdc(4) at isa(4).

Add a device-detachment "reason" flag, DETACH_SHUTDOWN, that tells the
autoconf code and a device driver that the reason for detachment is
system shutdown.

Add a sysctl, kern.detachall, that tells the system to try to detach
every device at shutdown, regardless of any device's DVF_DETACH_SHUTDOWN
flag.  The default for kern.detachall is 0.  SET IT TO 1, PLEASE, TO
HELP TEST AND DEBUG DEVICE DETACHMENT AT SHUTDOWN.

This is a work in progress.  In future work, I aim to treat
pseudo-devices more thoroughly, and to gracefully tear down a stack of
(pseudo-)disk drivers and filesystems, including cgd(4), vnd(4), and
raid(4) instances at shutdown.

Also commit some changes that are not easily untangled from the rest:

(1) begin to simplify device_t locking: rename struct pmf_private to
device_lock, and incorporate device_lock into struct device.

(2) #include <sys/device.h> in sys/pmf.h in order to get some
definitions that it needs.  Stop unnecessarily #including <sys/device.h>
in sys/arch/x86/include/pic.h to keep the amd64, xen, and i386 releases
building.
2009-04-02 00:09:32 +00:00
drochner
cabe8641e7 Work around a problem with PCMCIA adapter drivers (eg for hpc*) which
attach pcmcia devices before interrupts are enabled. This is unclean
because pcmcia drivers use tsleep(9) in the attach code path but it
worked all the time and it is too late to change this on the 5.0 branch.
So just tolerate it.
Fixes a regression on hpcsh reported by Valeriy E. Ushakov.
2009-03-21 12:35:17 +00:00
cegger
d3189d3544 ansify function definitions 2009-03-15 20:30:05 +00:00
dsl
82357f6d42 ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
2009-03-14 21:04:01 +00:00
dsl
454af1c0e8 Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
2009-03-14 15:35:58 +00:00
bouyer
73920b4161 More printf format fixes. 2009-02-13 23:31:23 +00:00
drochner
37d6396041 -in the wdc@pcmcia driver, don't try to powerup/down while cold or
shutting down -- this is only supposed to happen from the pcmcia
 kernel thread while the system is running
-in wd_shutdown, call ata_addref first, so that the adapter is either
 active or we know that it isn't
This fixes a hang on shutdown-p reported by Dennis den Brok per
PR kern/40531. Verified by by Dennis and me.
(reported against 5.0-Beta, so this is a pullup candidate)
2009-02-06 13:43:11 +00:00
jnemeth
dd35772633 add a comment explaining how to regenerate pcmicadevs.h and pcmciadevs_data.h 2009-01-21 14:13:09 +00:00
ad
0efea177e3 Remove LKMs and switch to the module framework, pass 1.
Proposed on tech-kern@.
2008-11-12 12:35:50 +00:00
dyoung
de87fe677d *** Summary ***
When a link-layer address changes (e.g., ifconfig ex0 link
02🇩🇪ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address.  (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior.  Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability.  KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR.  In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr.  That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR.  In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR.  For example, pull ..._init() out of any switch
statement that looks like this:

        switch (...->sa_family) {
        case ...:
                ..._init();
                ...
                break;
        ...
        default:
                ..._init();
                ...
                break;
        }

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

        switch (x & (IFF_UP|IFF_RUNNING)) {
        case 0:
                ...
                break;
        case IFF_RUNNING:
                ...
                break;
        case IFF_UP:
                ...
                break;
        case IFF_UP|IFF_RUNNING:
                ...
                break;
        }

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure.  Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls.  In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source.  In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively.  Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset.  Delete unnecessary casts to void *.  Use
sockaddr_in_init() and sockaddr_in6_init().  Compare pointers with
NULL instead of "testing truth".  Replace some instances of (type
*)0 with NULL.  Change some K&R prototypes to ANSI C, and join
lines.
2008-11-07 00:20:01 +00:00
apb
96230fab84 Use ${TOOL_AWK} instead of ${AWK} or plain "awk" in make commands.
Pass AWK=${TOOL_AWK:Q} to shell scripts that use awk.
2008-10-19 22:05:19 +00:00
jmcneill
536d3f6c8b Remove esl(4) 2008-09-30 16:51:45 +00:00
rmind
16dee06ce9 Regen. 2008-09-06 22:08:38 +00:00
rmind
3d4ea98e16 PR/38382: Jean-Yves Moulin: Support for Sierra Wireless Aircard 850. 2008-09-06 22:07:11 +00:00
christos
dba33e96d9 pmf_register. 2008-08-27 05:39:01 +00:00
christos
91ca465c78 device_t changes, pmf, minor knf. 2008-08-27 05:33:47 +00:00
drochner
6b623b615a add missing device_private(), fixes crash in interrupt handler 2008-07-28 14:25:30 +00:00
drochner
02b7e019aa split device/softc
Now I'm through - all my devices are split.
2008-07-03 19:07:43 +00:00
drochner
363285ca02 split device/softc (tested with an@pcmcia) 2008-07-03 18:10:07 +00:00
drochner
cc29fcf8b9 constify the pcmcia/cardbus method tables 2008-06-26 12:33:17 +00:00
imp
e8fe37647b Sync to pcmciadevs 1.226 2008-06-19 18:21:32 +00:00
imp
1bb3b88db9 Add in OLICOM cards from FreeBSD's pccarddevs table:
GoCard Ethernet (aka OC-2220)
    GoCard Combo Eth/Modem 28.8 (aka OC-2231)
    GoCard Combo Eth/Modem 33.6 (aka OC-2232)
    GoCard Combo Token Ring 16/4 Modem 28.8 (aka OC-3231)
    GoCard Combo Token Ring 16/4 Modem 33.6 (aka OC-3232)
2008-06-19 18:20:33 +00:00
uwe
b0aa5b3112 aprint_naive("\n") in attach. 2008-06-05 20:34:00 +00:00
martin
98914ea6fa off-by-one-key
: ----------------------------------------------------------------------
2008-06-01 23:34:23 +00:00
jnemeth
1075255134 added Corega LAPCCTXT FastEthernet 2008-05-16 20:27:20 +00:00
jnemeth
c00c7bde7b regen for Corega LAPCCTXD FastEthernet 2008-05-16 20:21:59 +00:00