Commit Graph

279 Commits

Author SHA1 Message Date
dyoung
cb637e784d unifdef -U__FreeBSD__ -D__NetBSD__, et cetera. 2009-08-07 00:10:53 +00:00
dyoung
59d9a6b60c unifdef -U__DragonFlyBSD__ -U__FreeBSD__ -D__NetBSD__.
XXX Compiles, but untested.
2009-06-20 20:18:32 +00:00
cegger
ffb0a63a57 buildfix: don't redefine MIN and MAX. They are defined in <sys/param.h>. 2009-06-20 09:40:52 +00:00
cegger
32c4940900 struct cfdata * -> cfdata_t, no functional changes intended. 2009-05-12 12:10:29 +00:00
mschuett
0d53a16d76 Add queue macros SLIST_FOREACH_SAFE, STAILQ_FOREACH_SAFE, STAILQ_LAST,
SIMPLEQ_CONCAT, and SIMPLEQ_LAST.

Remove seperate definitions outside of queue.h.
2009-04-20 09:56:07 +00:00
tsutsui
d779b85d3e Remove extra whitespace added by a stupid tool.
XXX: more in src/sys/arch
2009-04-18 14:58:02 +00:00
cegger
e2cb85904d bcopy -> memcpy 2009-03-18 17:06:41 +00:00
cegger
c363a9cb62 bzero -> memset 2009-03-18 16:00:08 +00:00
cegger
35fb64746b bcmp -> memcmp 2009-03-18 15:14:29 +00:00
cegger
a1f5aecf36 buildfix: undo previous 2009-03-18 10:41:46 +00:00
cegger
df7f595ecd Ansify function definitions w/o arguments. Generated with sed. 2009-03-18 10:22:21 +00:00
christos
461a86f9bd merge christos-time_t 2009-01-11 02:45:45 +00:00
yamt
b1fea83762 remove extra semicolons. 2009-01-03 03:43:21 +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
gmcgarry
0de5da9678 Replace most gcc-specific __attribute__ uses with BSD-style sys/cdef.h
preprocessor macros.
2008-09-08 23:36:53 +00:00
gmcgarry
b8d5478df6 Replace gcc extension of comma-elimination variadic macros with aprint_debug_ifnet(). 2008-06-24 10:13:51 +00:00
gmcgarry
8f786d7556 Digraphs as lvalues must return the same type. 2008-06-24 10:12:42 +00:00
jmcneill
2b7bb9303a Use aprint 2008-05-10 13:56:54 +00:00
xtraeme
5a38da5ccf Constify, so that usr.sbin/fwctl can be built with WARNS=4. 2008-05-02 19:50:04 +00:00
cegger
50fb102fe3 use aprint_*_dev and device_xname 2008-04-08 06:12:21 +00:00
kiyohara
64e7d595e1 Split device_t/softc.
And cosmetic change.
2008-03-29 16:22:53 +00:00
dyoung
2ccede0a9c Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs.  This will ease extending the kernel and sharing of code
between drivers.

First steps:  Make the signature of ifioctl_common() match struct
ifinet->if_ioctl.  Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.
2008-02-07 01:21:52 +00:00
ad
0664a0459b Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
2008-01-04 21:17:40 +00:00
perry
b6a2ef7569 Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
2007-12-25 18:33:32 +00:00
perry
9b2b412c19 __FUNCTION__ -> __func__ 2007-12-15 00:39:14 +00:00
lukem
388339aa58 use __KERNEL_RCSID() 2007-12-11 11:25:46 +00:00
jmcneill
4c1d81b2b5 Merge jmcneill-pm branch. 2007-12-09 20:27:42 +00:00
kiyohara
2575726a88 The argument of *_intr_establish() is changed to fwohci_flit.
Our ieee1394 coordinates from FreeBSD implementation.
Add fwohci_pci_shutdown() and fwohci_pci_power().
Move __KERNEL_RCSID to ahead.
2007-11-06 15:24:10 +00:00
dogcow
99f2863e95 on NetBSD, cardbus_intr_establish's fifth arg's is a symbol which returns
an int, not a void; change fwohci_intr accordingly.
2007-11-06 12:32:12 +00:00
kiyohara
c33e2714c5 + Sync to FreeBSD.
firewire.c Rev.1.101
    firewire.h Rev.1.21
    firewirereg.h Rev.1.50
    fwdev.c Rev.1.52
    fwdma.c Rev.1.9
    fwmem.c Rev.1.34
    fwohci.c Rev.1.93
    fwohcireg.h Rev.1.23
    fwohcivar.h Rev.1.16
    if_fwip.c Rev.1.16
    if_fwipvar.h Rev.1.5
    sbp.c Rev.1.92
+ Cleanup macros in fw_port.h.
+ Fix the occurrence of the error at the resume.  Don't set the buffer again.
2007-11-05 19:08:56 +00:00
ad
a2a3828545 machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h 2007-10-19 11:59:34 +00:00
ad
1934283e4a Use selinit() / seldestroy(). 2007-09-25 14:04:07 +00:00
rmind
c8c024369c Improve per-CPU support for the workqueue(9):
- Make structures CPU-cache friendly, as suggested and explained
   by Andrew Doran.  CACHE_LINE_SIZE definition is invented.
 - Use current CPU if NULL is passed to the workqueue_enqueue().
 - Implemented MI CPU index, which could be used as an index of array.
   Removed linked-lists usage for work queues.

The roundup2() function avoids division, but works only with power of 2.

Reviewed by: <ad>, <yamt>, <tech-kern>
2007-08-05 01:19:17 +00:00
ad
a0d1fd8d0c It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
2007-07-29 13:31:07 +00:00
ad
88ab7da936 Merge some of the less invasive changes from the vmlocking branch:
- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
2007-07-09 20:51:58 +00:00
kiyohara
29417afebc firewire.c sync to Rev.1.86 for FreeBSD.
firewirereg.h sync to Rev.1.41 for FreeBSD.
fwcrom.c sync to Rev.1.14 for FreeBSD.
fwdev.c sync to Rev.1.49 for FreeBSD.
fwmem.c sync to Rev.1.32 for FreeBSD.
fwohci.c sync to Rev.1.86 for FreeBSD.
fwohcivar.h sync to Rev.1.15 for FreeBSD.
if_fwip.c sync to Rev.1.14 for FreeBSD.
if_fwipvar.h sync to Rev.1.4 for FreeBSD.
sbp.c sync to Rev.1.89 for FreeBSD.
2007-04-21 15:27:43 +00:00
ad
2dc89bb0bd Remove #include <machine/vmparam.h>. 2007-03-11 22:11:02 +00:00
christos
53524e44ef Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
kiyohara
c8826cd8a1 Use macro FWBUSNOTREADY. 2006-12-22 03:27:49 +00:00
kiyohara
190ae0482f Include ioconf.h it for `struct cfdriver fwohci_cd'. 2006-12-22 03:26:51 +00:00
kiyohara
71d34007f5 Fix memory allocation, in case isochronous transfer fail this. 2006-12-21 00:31:51 +00:00
jdolecek
e0f8f596d4 undo previous change - crom_buf->len has been changed to uint32_t
(this is backward ABI compatible) so the check for negative value is
no longer necessary
2006-11-16 16:10:43 +00:00
jdolecek
8c96a4b6ac make the struct fw_crom_buf's len uint32_t, so that it can never be negative
the real fix to
http://archives.neohapsis.com/archives/fulldisclosure/2006-11/0261.html
2006-11-16 15:59:28 +00:00
elad
4bfbbae383 Avoid integer overflow, as reported by Rodrigo Rubira Branco in a
message to full-disclosure:

http://archives.neohapsis.com/archives/fulldisclosure/2006-11/0261.html

Also see comment from bouyer@:

http://mail-index.netbsd.org/tech-security/2006/11/16/0001.html
2006-11-16 14:35:07 +00:00
christos
168cd830d2 __unused removal on arguments; approved by core. 2006-11-16 01:32:37 +00:00
christos
4d595fd7b1 - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
2006-10-12 01:30:41 +00:00
christos
ff685a253e we have rounddown in <sys/param.h> now 2006-10-04 15:48:36 +00:00
kiyohara
58f6bfaae5 Fix device name in {fwohci,firewire}_print(). valiable aux is not string
pointer.
2006-09-26 02:50:42 +00:00
jmcneill
f135e0d607 Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
2006-09-24 03:53:07 +00:00