Commit Graph

511 Commits

Author SHA1 Message Date
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
aymeric
c1b8e3521a pass the right sensor types so that the kernel doesn't panic() on my
iBook G3
2008-10-23 07:35:46 +00:00
pgoyette
a3cdedf605 Move the {read,write}reg() routine addresses into the dbcool_softc so
that we can use different routines for macppc's ki2c attachment.  Fixes
problems reported by Robert Fritzsche on current-users@ list.
2008-10-12 12:49:04 +00:00
pgoyette
65d9dac7ee sc->sc_parent was removed because it was never used, so don't bother
trying to set it.
2008-10-09 03:11:29 +00:00
pgoyette
379328cb93 Remove chip-specific drivers for ADT7463, ADT7467, and ADM1030; these
have been superseded by the dbcool(4) driver.
2008-10-07 19:32:29 +00:00
macallan
8133f9d1ce fix bus_spacification botch
from Marco Trillo in PR39696
2008-10-05 05:01:08 +00:00
pgoyette
d5697e7834 Add dbcool ki2c attachment for macppc 2008-10-02 00:55:43 +00:00
macallan
8bcef57bb4 Use access functions to mess with FCRs, GPIOs etc. in order to avoid
multiple mappings of obio's register space.
This needs testing.
2008-09-26 04:06:59 +00:00
macallan
9a3f01e80e add some register definitions 2008-09-26 03:40:26 +00:00
macallan
b8ae2bc305 use access functions to mess with obio's registers 2008-09-26 03:38:25 +00:00
macallan
e3856204b9 use min(255, blah) to cap volume instead of masking the upper bits out 2008-09-26 03:20:30 +00:00
macallan
58c0e446a1 Provide access functions for mac-io registers in order to get rid of
private mappings some drivers use which won't work anymore in the new
post-ppcoea-renovation world order.
2008-09-26 03:19:05 +00:00
macallan
cc43cb490b get rid if some mistyped magic number, spotted by Marco Trillo
While there map only the space we actually need.
Needs to be tested on actual hardware.
2008-09-10 00:33:12 +00:00
jmcneill
ebf54f79dc Add support for keylargo-style mediabays, as found in eg. PowerBook3,1 2008-08-28 04:05:50 +00:00
jmcneill
5297b0caca PR#39414: No audio from awacs on PowerBook G3 (Firewire/Pismo)
Don't enable parallel output on PowerBook3,1 models.
2008-08-27 14:31:46 +00:00
macallan
7f91f2bd1b actually implement smart battery support
From Magnus Henoch.
This needs more testing, especially on older PowerBooks which may have more thanone battery.
2008-08-12 17:16:16 +00:00
macallan
df34d2042b Fix remaining register offset shifting left over from proper bus_space-ification
done a while ago. From Marco Trillo.
This should fix PR 39176.
2008-07-28 16:54:49 +00:00
macallan
9403c29e8e actually initialize sc_dmacmd and get rid of getnodebypci() - use
pcidev_to_ofdev() instead
noticed by Marco Trillo, tested on my iBook G4
2008-07-02 03:20:19 +00:00
cegger
2dace40230 use device_lookup_private to get softc 2008-06-13 11:54:31 +00:00
chs
b2e9f679cb recognize the variant found in the last model of powermac G5. 2008-05-25 16:00:11 +00:00
macallan
e369394198 sprinkle static 2008-05-16 03:49:54 +00:00
macallan
0a9283467c struct device * -> device_t 2008-05-16 03:11:09 +00:00
macallan
b6c6870c6d struct device * -> device_t 2008-05-16 02:41:50 +00:00
macallan
f147f68f57 listen to PMF volume control events
With this volume vontrol via keyboard works on my iBook G4.
2008-05-15 20:11:00 +00:00
macallan
7d61890be8 struct device -> device_t 2008-05-15 19:47:09 +00:00
macallan
757fd24b0c nuke license clause 3 2008-05-08 01:37:04 +00:00
macallan
e24aaf48e7 report chip revision 2008-05-08 01:36:03 +00:00
xtraeme
07c2a78bc8 device_t/softc split for adt7467c(4) and adm1030, and other related
cosmetic changes.
2008-05-04 14:45:01 +00:00
martin
3028e483e4 Convert to new 2 clause license 2008-04-29 06:53:00 +00:00
martin
ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
tsutsui
78a1d236b6 Split device_t/softc for MI ncr53c9x and some related devices,
with various cleanup.
2008-04-13 04:55:52 +00:00
macallan
3b8eb423c6 actually update the 'battery present' sensor. Doh. 2008-03-30 18:19:53 +00:00
macallan
b996b42f44 free & unmap DMA memory and registers on detach()
Now removing and re-attaching a mediabay works again.
2008-03-30 18:16:25 +00:00
macallan
a78054eebc don't splhigh() in the interrupt handler, instead spltty() in adb_poll() 2008-03-30 17:57:29 +00:00
tsutsui
02cb47cab2 Split softc and device_t for zsc(4) and its children.
XXX we should restructure MI APIs and make it really machine independent.
2008-03-29 19:15:34 +00:00
cube
7aa6248cdf Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
2008-03-18 20:46:35 +00:00
cube
607ead0ef4 Split device_t and softc for all com(4) devices (well, everything that
uses a com_softc backend).  Use proper types and ansify where appropriate.
2008-03-14 15:09:09 +00:00
rmind
c6186face4 Welcome to 4.99.55:
- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call.  It will
  indicate which event (POLL_IN, POLL_OUT, etc) happen.  If unknown,
  zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>
2008-03-01 14:16:49 +00:00
matt
652f27646d Convert to prototypes, de'__P, use device_private, switch to aprint_*,
make things static, and some minor constification.
2008-02-25 19:22:39 +00:00
dyoung
b480b62270 Make many ethernet drivers share the common code for MII media
handling, ether_mediastatus() and ether_mediachange().  Check for
a non-ENXIO error return from mii_mediachg().  (ENXIO indicates
that a PHY is suspended.)

This patch shrinks the source code size by 979 lines.  There was
a 5100-byte savings on the NetBSD/i386 kernel configuration, ALL.

I have made a few miscellaneous changes, too:

gem(4): use LIST_EMPTY(), LIST_FOREACH().
mtd(4): handle media ioctls, for a change!
axe(4): do not track link status in sc->axe_link any longer
nfe(4), aue(4), axe(4), udav(4), url(4): do not reset all PHYs
        on a change of media

Except for the change to mtd(4), no functional changes are intended.

XXX This patch affects more architectures than I can feasibly
XXX compile and run.  I have compiled macppc, sparc64, i386.  I
XXX have run the patches on i386 boxen with bnx(4) and sip(4).
XXX Compiling and running on evbmips (MERAKI, ADM5120) is in
XXX progress.
2008-01-19 22:10:14 +00:00
dyoung
13e9109580 De-__P(). 2007-12-29 23:12:38 +00:00
macallan
7f37ac3821 fix sensor attachment 2007-12-12 18:19:20 +00:00
david
587cc41918 Wrong copyright template used on import. Referenced Regents, but
Berkeley wasn't in on this one.

closes port-macppc/37520, filed by Ted Unangst.
2007-12-11 23:23:02 +00:00
macallan
1e6d2e66e6 make this compile again 2007-12-11 21:00:22 +00:00
jmcneill
4c1d81b2b5 Merge jmcneill-pm branch. 2007-12-09 20:27:42 +00:00
macallan
f2c6ff7989 finish mutexification, now ki2c compiles again 2007-12-07 16:01:19 +00:00
ad
065b6ba2fb lockmgr -> mutex 2007-12-06 17:00:31 +00:00
garbled
b0f4d9f970 Apply a set of patches from Frank Wille to make the genfb attachment work
better on ofppc.  In doing so, we also move a few functions around in
macppc and the generic ofw powerpc stuff to allow better sharing of code.
Also, introduce a model_init function.

move ofb_cons.c from macppc/dev to powerpc/oea and rename it to rascons.
This gets rid of some naming confusion, and makes it OFW-MI rather than
macppc specific.
2007-11-26 19:58:29 +00:00
ad
dc26833bb6 - Factor out too many copies of the same bit of tty code.
- Fix another tty signalling/wakeup problem.
2007-11-19 18:51:36 +00:00
ad
417cd168ee Use the softint API. 2007-11-19 18:41:29 +00:00