PERFORCE change 147994 for review
Ed Schouten
ed at FreeBSD.org
Thu Aug 21 13:05:13 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=147994
Change 147994 by ed at ed_dull on 2008/08/21 13:04:18
IFC again, because now is the time to work on the hooks interface.
Affected files ...
.. //depot/projects/mpsafetty/etc/rc.d/kernel_symlink#2 integrate
.. //depot/projects/mpsafetty/release/amd64/boot_crunch.conf#2 integrate
.. //depot/projects/mpsafetty/release/i386/boot_crunch.conf#2 integrate
.. //depot/projects/mpsafetty/release/ia64/boot_crunch.conf#2 integrate
.. //depot/projects/mpsafetty/release/pc98/boot_crunch.conf#2 integrate
.. //depot/projects/mpsafetty/release/powerpc/boot_crunch.conf#2 integrate
.. //depot/projects/mpsafetty/release/sparc64/boot_crunch.conf#2 integrate
.. //depot/projects/mpsafetty/release/sun4v/boot_crunch.conf#2 integrate
.. //depot/projects/mpsafetty/share/man/man4/Makefile#9 integrate
.. //depot/projects/mpsafetty/share/man/man4/acpi_aiboost.4#1 branch
.. //depot/projects/mpsafetty/share/man/man4/acpi_fujitsu.4#1 branch
.. //depot/projects/mpsafetty/share/man/man4/acpi_ibm.4#1 branch
.. //depot/projects/mpsafetty/share/man/man4/acpi_panasonic.4#1 branch
.. //depot/projects/mpsafetty/share/man/man4/acpi_sony.4#1 branch
.. //depot/projects/mpsafetty/share/man/man4/acpi_toshiba.4#1 branch
.. //depot/projects/mpsafetty/share/man/man4/io.4#1 branch
.. //depot/projects/mpsafetty/share/man/man4/linux.4#1 branch
.. //depot/projects/mpsafetty/share/man/man4/man4.i386/Makefile#3 integrate
.. //depot/projects/mpsafetty/share/man/man4/man4.i386/acpi_aiboost.4#2 delete
.. //depot/projects/mpsafetty/share/man/man4/man4.i386/acpi_asus.4#2 delete
.. //depot/projects/mpsafetty/share/man/man4/man4.i386/acpi_fujitsu.4#2 delete
.. //depot/projects/mpsafetty/share/man/man4/man4.i386/acpi_ibm.4#2 delete
.. //depot/projects/mpsafetty/share/man/man4/man4.i386/acpi_panasonic.4#2 delete
.. //depot/projects/mpsafetty/share/man/man4/man4.i386/acpi_sony.4#2 delete
.. //depot/projects/mpsafetty/share/man/man4/man4.i386/acpi_toshiba.4#2 delete
.. //depot/projects/mpsafetty/share/man/man4/man4.i386/io.4#2 delete
.. //depot/projects/mpsafetty/share/man/man4/man4.i386/linux.4#2 delete
.. //depot/projects/mpsafetty/share/man/man4/man4.i386/ndis.4#2 delete
.. //depot/projects/mpsafetty/share/man/man4/ndis.4#1 branch
.. //depot/projects/mpsafetty/sys/dev/bfe/if_bfe.c#4 integrate
.. //depot/projects/mpsafetty/sys/dev/bfe/if_bfereg.h#3 integrate
.. //depot/projects/mpsafetty/sys/dev/pci/pci_pci.c#5 integrate
.. //depot/projects/mpsafetty/sys/dev/pci/pcireg.h#2 integrate
.. //depot/projects/mpsafetty/sys/dev/usb/ubsa.c#2 integrate
.. //depot/projects/mpsafetty/sys/dev/usb/usbdevs#6 integrate
.. //depot/projects/mpsafetty/sys/dev/xen/netfront/netfront.c#4 integrate
.. //depot/projects/mpsafetty/sys/i386/i386/vm_machdep.c#4 integrate
.. //depot/projects/mpsafetty/sys/i386/pci/pci_cfgreg.c#3 integrate
.. //depot/projects/mpsafetty/sys/i386/xen/pmap.c#4 integrate
.. //depot/projects/mpsafetty/usr.bin/cpio/cpio.c#4 integrate
.. //depot/projects/mpsafetty/usr.bin/lockf/lockf.1#2 integrate
.. //depot/projects/mpsafetty/usr.bin/lockf/lockf.c#2 integrate
.. //depot/projects/mpsafetty/usr.bin/tar/read.c#2 integrate
.. //depot/projects/mpsafetty/usr.bin/tar/test/main.c#2 integrate
.. //depot/projects/mpsafetty/usr.bin/tar/test/test.h#2 integrate
.. //depot/projects/mpsafetty/usr.bin/tar/test/test_patterns.c#4 integrate
.. //depot/projects/mpsafetty/usr.bin/tar/test/test_patterns_2.tgz.err.uu#2 delete
.. //depot/projects/mpsafetty/usr.bin/tar/test/test_patterns_2.tgz.out.uu#2 integrate
.. //depot/projects/mpsafetty/usr.bin/tar/test/test_patterns_3.tgz.uu#1 branch
.. //depot/projects/mpsafetty/usr.sbin/pstat/pstat.8#4 integrate
.. //depot/projects/mpsafetty/usr.sbin/sysinstall/install.c#2 integrate
.. //depot/projects/mpsafetty/usr.sbin/sysinstall/media.c#2 integrate
.. //depot/projects/mpsafetty/usr.sbin/sysinstall/options.c#2 integrate
.. //depot/projects/mpsafetty/usr.sbin/sysinstall/sysinstall.h#2 integrate
.. //depot/projects/mpsafetty/usr.sbin/sysinstall/tape.c#2 integrate
Differences ...
==== //depot/projects/mpsafetty/etc/rc.d/kernel_symlink#2 (text+ko) ====
@@ -1,20 +1,20 @@
#!/bin/sh
#
-# $FreeBSD: src/etc/rc.d/kernel_symlink,v 1.1 2008/08/19 14:23:31 obrien Exp $
+# $FreeBSD: src/etc/rc.d/kernel_symlink,v 1.2 2008/08/21 00:04:19 rpaulo Exp $
#
-# PROVIDE: kernel
+# PROVIDE: kernel_symlink
# REQUIRE: mountcritremote
# KEYWORD: nojail
. /etc/rc.subr
-name="kernel"
+name="kernel_symlink"
rcvar=`set_rcvar`
-start_cmd="kernel_start"
+start_cmd="kernel_symlink_start"
stop_cmd=":"
-kernel_start()
+kernel_symlink_start()
{
bootdir=$(dirname $(sysctl -n kern.bootfile))
if [ "$bootdir" != /boot/kernel ] ; then
==== //depot/projects/mpsafetty/release/amd64/boot_crunch.conf#2 (text+ko) ====
@@ -1,4 +1,4 @@
-# $FreeBSD: src/release/amd64/boot_crunch.conf,v 1.63 2008/04/22 18:20:03 thompsa Exp $
+# $FreeBSD: src/release/amd64/boot_crunch.conf,v 1.64 2008/08/20 13:35:39 kensmith Exp $
buildopts -DRELEASE_CRUNCH -Dlint
@@ -11,9 +11,6 @@
ln sh -sh
ln test [
-srcdirs /usr/src/gnu/usr.bin
-progs cpio
-
srcdirs /usr/src/sbin
progs camcontrol
progs dhclient
@@ -29,6 +26,7 @@
ln fsck_ffs fsck_ufs
srcdirs /usr/src/usr.bin
+progs cpio
progs find
progs minigzip
progs sed
@@ -44,4 +42,4 @@
libs -ll -ledit -lutil -lmd -lcrypt -lftpio -lz -lnetgraph
libs -ldialog -lncurses -ldisk -lcam -lsbuf -lufs -ldevinfo
-libs -lbsdxml
+libs -lbsdxml -larchive -lbz2
==== //depot/projects/mpsafetty/release/i386/boot_crunch.conf#2 (text+ko) ====
@@ -1,4 +1,4 @@
-# $FreeBSD: src/release/i386/boot_crunch.conf,v 1.63 2008/04/22 18:20:04 thompsa Exp $
+# $FreeBSD: src/release/i386/boot_crunch.conf,v 1.64 2008/08/20 13:35:39 kensmith Exp $
buildopts -DRELEASE_CRUNCH -Dlint
@@ -11,9 +11,6 @@
ln sh -sh
ln test [
-srcdirs /usr/src/gnu/usr.bin
-progs cpio
-
srcdirs /usr/src/sbin
progs camcontrol
progs dhclient
@@ -29,6 +26,7 @@
ln fsck_ffs fsck_ufs
srcdirs /usr/src/usr.bin
+progs cpio
progs find
progs minigzip
progs sed
@@ -44,4 +42,4 @@
libs -ll -ledit -lutil -lmd -lcrypt -lftpio -lz -lnetgraph
libs -ldialog -lncurses -ldisk -lcam -lsbuf -lufs -ldevinfo
-libs -lbsdxml
+libs -lbsdxml -larchive -lbz2
==== //depot/projects/mpsafetty/release/ia64/boot_crunch.conf#2 (text+ko) ====
@@ -1,4 +1,4 @@
-# $FreeBSD: src/release/ia64/boot_crunch.conf,v 1.14 2008/06/05 15:32:05 marcel Exp $
+# $FreeBSD: src/release/ia64/boot_crunch.conf,v 1.15 2008/08/20 13:35:39 kensmith Exp $
buildopts -DRELEASE_CRUNCH -Dlint
@@ -11,9 +11,6 @@
ln sh -sh
ln test [
-srcdirs /usr/src/gnu/usr.bin
-progs cpio
-
srcdirs /usr/src/sbin
progs camcontrol
progs dhclient
@@ -33,6 +30,7 @@
ln geom gpart
srcdirs /usr/src/usr.bin
+progs cpio
progs find
progs minigzip
progs sed
@@ -48,4 +46,4 @@
libs -ll -ledit -lutil -lmd -lcrypt -lftpio -lz -lnetgraph
libs -ldialog -lncurses -ldisk -lcam -lkiconv -lsbuf -lufs -ldevinfo
-libs -lgeom -lbsdxml
+libs -lgeom -lbsdxml -larchive -lbz2
==== //depot/projects/mpsafetty/release/pc98/boot_crunch.conf#2 (text+ko) ====
@@ -1,4 +1,4 @@
-# $FreeBSD: src/release/pc98/boot_crunch.conf,v 1.64 2008/04/22 18:20:04 thompsa Exp $
+# $FreeBSD: src/release/pc98/boot_crunch.conf,v 1.65 2008/08/20 13:35:39 kensmith Exp $
buildopts -DRELEASE_CRUNCH -Dlint
@@ -11,9 +11,6 @@
ln sh -sh
ln test [
-srcdirs /usr/src/gnu/usr.bin
-progs cpio
-
srcdirs /usr/src/sbin
progs camcontrol
progs dhclient
@@ -29,6 +26,7 @@
ln fsck_ffs fsck_ufs
srcdirs /usr/src/usr.bin
+progs cpio
progs find
progs minigzip
progs sed
@@ -43,3 +41,4 @@
libs -ll -ledit -lutil -lmd -lcrypt -lftpio -lz -lnetgraph
libs -ldialog -lncurses -ldisk -lcam -lsbuf -lufs -lbsdxml
+libs -larchive -lbz2
==== //depot/projects/mpsafetty/release/powerpc/boot_crunch.conf#2 (text+ko) ====
@@ -1,4 +1,4 @@
-# $FreeBSD: src/release/powerpc/boot_crunch.conf,v 1.6 2008/04/22 18:20:05 thompsa Exp $
+# $FreeBSD: src/release/powerpc/boot_crunch.conf,v 1.7 2008/08/20 13:35:39 kensmith Exp $
buildopts -DRELEASE_CRUNCH -Dlint
@@ -11,9 +11,6 @@
ln sh -sh
ln test [
-srcdirs /usr/src/gnu/usr.bin
-progs cpio
-
srcdirs /usr/src/sbin
progs camcontrol
progs dhclient
@@ -31,6 +28,7 @@
ln fsck_ffs fsck_ufs
srcdirs /usr/src/usr.bin
+progs cpio
progs find
progs minigzip
progs sed
@@ -46,4 +44,4 @@
libs -ll -ledit -lutil -lmd -lcrypt -lftpio -lz -lnetgraph
libs -ldialog -lncurses -ldisk -lcam -lkiconv -lsbuf -lufs
-libs -lbsdxml
+libs -lbsdxml -larchive -lbz2
==== //depot/projects/mpsafetty/release/sparc64/boot_crunch.conf#2 (text+ko) ====
@@ -1,4 +1,4 @@
-# $FreeBSD: src/release/sparc64/boot_crunch.conf,v 1.10 2008/04/22 18:20:05 thompsa Exp $
+# $FreeBSD: src/release/sparc64/boot_crunch.conf,v 1.11 2008/08/20 13:35:39 kensmith Exp $
buildopts -DRELEASE_CRUNCH -Dlint
@@ -11,9 +11,6 @@
ln sh -sh
ln test [
-srcdirs /usr/src/gnu/usr.bin
-progs cpio
-
srcdirs /usr/src/sbin
progs camcontrol
progs dhclient
@@ -29,6 +26,7 @@
ln fsck_ffs fsck_ufs
srcdirs /usr/src/usr.bin
+progs cpio
progs find
progs minigzip
progs sed
@@ -44,3 +42,4 @@
libs -ll -ledit -lutil -lmd -lcrypt -lftpio -lz -lnetgraph
libs -ldialog -lncurses -ldisk -lcam -lsbuf -lufs -lbsdxml
+libs -larchive -lbz2
==== //depot/projects/mpsafetty/release/sun4v/boot_crunch.conf#2 (text+ko) ====
@@ -1,4 +1,4 @@
-# $FreeBSD: src/release/sun4v/boot_crunch.conf,v 1.3 2008/04/22 18:20:05 thompsa Exp $
+# $FreeBSD: src/release/sun4v/boot_crunch.conf,v 1.4 2008/08/20 13:35:39 kensmith Exp $
buildopts -DRELEASE_CRUNCH -Dlint
@@ -11,9 +11,6 @@
ln sh -sh
ln test [
-srcdirs /usr/src/gnu/usr.bin
-progs cpio
-
srcdirs /usr/src/sbin
progs camcontrol
progs dhclient
@@ -29,6 +26,7 @@
ln fsck_ffs fsck_ufs
srcdirs /usr/src/usr.bin
+progs cpio
progs find
progs minigzip
progs sed
@@ -44,3 +42,4 @@
libs -ll -ledit -lutil -lmd -lcrypt -lftpio -lz -lnetgraph
libs -ldialog -lncurses -ldisk -lcam -lsbuf -lufs -lbsdxml
+libs -larchive -lbz2
==== //depot/projects/mpsafetty/share/man/man4/Makefile#9 (text+ko) ====
@@ -1,10 +1,17 @@
# @(#)Makefile 8.1 (Berkeley) 6/18/93
-# $FreeBSD: src/share/man/man4/Makefile,v 1.427 2008/08/20 11:48:04 rpaulo Exp $
+# $FreeBSD: src/share/man/man4/Makefile,v 1.429 2008/08/21 00:40:55 rpaulo Exp $
MAN= aac.4 \
acpi.4 \
+ ${_acpi_aiboost.4} \
+ ${_acpi_asus.4} \
${_acpi_dock.4} \
+ ${_acpi_fujitsu.4} \
+ ${_acpi_ibm.4} \
+ ${_acpi_panasonic.4} \
+ ${_acpi_sony.4} \
acpi_thermal.4 \
+ ${_acpi_toshiba.4} \
acpi_video.4 \
adv.4 \
adw.4 \
@@ -127,6 +134,7 @@
inet6.4 \
intpm.4 \
intro.4 \
+ ${_io.4} \
ip.4 \
ip6.4 \
ipfirewall.4 \
@@ -142,7 +150,7 @@
ixgb.4 \
jme.4 \
joy.4 \
- k8temp.4 \
+ ${_k8temp.4} \
kbdmux.4 \
keyboard.4 \
kld.4 \
@@ -152,6 +160,7 @@
le.4 \
led.4 \
lge.4 \
+ ${_linux.4} \
lmc.4 \
lo.4 \
lp.4 \
@@ -191,6 +200,7 @@
natmip.4 \
ncr.4 \
ncv.4 \
+ ${_ndis.4} \
netgraph.4 \
netintro.4 \
${_nfe.4} \
@@ -492,6 +502,7 @@
MLINKS+=mn.4 if_mn.4
MLINKS+=mxge.4 if_mxge.4
MLINKS+=my.4 if_my.4
+MLINKS+=${_ndis.4} ${_if_ndis.4}
MLINKS+=netintro.4 net.4 \
netintro.4 networking.4
MLINKS+=${_nfe.4} ${_if_nfe.4}
@@ -550,7 +561,14 @@
MLINKS+=xl.4 if_xl.4
.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386"
+_acpi_aiboost.4=acpi_aiboost.4
+_acpi_asus.4= acpi_asus.4
_acpi_dock.4= acpi_dock.4
+_acpi_fujitsu.4=acpi_fujitsu.4
+_acpi_ibm.4= acpi_ibm.4
+_acpi_panasonic.4=acpi_panasonic.4
+_acpi_sony.4= acpi_sony.4
+_acpi_toshiba.4=acpi_toshiba.4
_amdsmb.4= amdsmb.4
_asmc.4= asmc.4
_coretemp.4= coretemp.4
@@ -559,11 +577,16 @@
_hptmv.4= hptmv.4
_hptrr.4= hptrr.4
_ichwd.4= ichwd.4
+_if_ndis.4= if_ndis.4
_if_nfe.4= if_nfe.4
_if_nve.4= if_nve.4
_if_nxge.4= if_nxge.4
_if_wpi.4= if_wpi.4
_ipmi.4= ipmi.4
+_io.4= io.4
+_linux.4= linux.4
+_ndis.4= ndis.4
+_k8temp.4= k8temp.4
_nfe.4= nfe.4
_nfsmb.4= nfsmb.4
_nve.4= nve.4
==== //depot/projects/mpsafetty/share/man/man4/man4.i386/Makefile#3 (text+ko) ====
@@ -1,13 +1,6 @@
-# $FreeBSD: src/share/man/man4/man4.i386/Makefile,v 1.189 2008/08/09 14:54:19 philip Exp $
+# $FreeBSD: src/share/man/man4/man4.i386/Makefile,v 1.190 2008/08/21 00:40:55 rpaulo Exp $
-MAN= acpi_aiboost.4 \
- acpi_asus.4 \
- acpi_fujitsu.4 \
- acpi_ibm.4 \
- acpi_panasonic.4 \
- acpi_sony.4 \
- acpi_toshiba.4 \
- aic.4 \
+MAN= aic.4 \
alpm.4 \
amdpm.4 \
apm.4 \
@@ -25,12 +18,9 @@
glxsb.4 \
ichwd.4 \
ie.4 \
- io.4 \
- linux.4 \
longrun.4 \
mcd.4 \
mse.4 \
- ndis.4 \
npx.4 \
padlock.4 \
pae.4 \
@@ -52,7 +42,6 @@
wl.4
MLINKS= CPU_ELAN.4 CPU_SOEKRIS.4
-MLINKS+=ndis.4 if_ndis.4
MLINKS+=pae.4 PAE.4
MANSUBDIR=/i386
==== //depot/projects/mpsafetty/sys/dev/bfe/if_bfe.c#4 (text+ko) ====
@@ -26,45 +26,36 @@
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/bfe/if_bfe.c,v 1.50 2008/08/11 01:49:46 yongari Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/bfe/if_bfe.c,v 1.51 2008/08/21 04:21:53 yongari Exp $");
#include <sys/param.h>
#include <sys/systm.h>
-#include <sys/sockio.h>
+#include <sys/bus.h>
+#include <sys/endian.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
#include <sys/mbuf.h>
-#include <sys/malloc.h>
-#include <sys/kernel.h>
#include <sys/module.h>
+#include <sys/rman.h>
#include <sys/socket.h>
-#include <sys/queue.h>
+#include <sys/sockio.h>
+#include <net/bpf.h>
#include <net/if.h>
-#include <net/if_arp.h>
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_media.h>
-
-#include <net/bpf.h>
-
#include <net/if_types.h>
#include <net/if_vlan_var.h>
-#include <netinet/in_systm.h>
-#include <netinet/in.h>
-#include <netinet/ip.h>
-
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-
#include <dev/mii/mii.h>
#include <dev/mii/miivar.h>
-#include "miidevs.h"
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
+#include <machine/bus.h>
+
#include <dev/bfe/if_bfereg.h>
MODULE_DEPEND(bfe, pci, 1, 1, 1);
@@ -91,6 +82,7 @@
static int bfe_resume (device_t);
static void bfe_release_resources (struct bfe_softc *);
static void bfe_intr (void *);
+static int bfe_encap (struct bfe_softc *, struct mbuf **);
static void bfe_start (struct ifnet *);
static void bfe_start_locked (struct ifnet *);
static int bfe_ioctl (struct ifnet *, u_long, caddr_t);
@@ -104,7 +96,9 @@
static void bfe_rxeof (struct bfe_softc *);
static void bfe_set_rx_mode (struct bfe_softc *);
static int bfe_list_rx_init (struct bfe_softc *);
-static int bfe_list_newbuf (struct bfe_softc *, int, struct mbuf*);
+static void bfe_list_tx_init (struct bfe_softc *);
+static void bfe_discard_buf (struct bfe_softc *, int);
+static int bfe_list_newbuf (struct bfe_softc *, int);
static void bfe_rx_ring_free (struct bfe_softc *);
static void bfe_pci_setup (struct bfe_softc *, u_int32_t);
@@ -127,8 +121,8 @@
static void bfe_chip_halt (struct bfe_softc *);
static void bfe_core_reset (struct bfe_softc *);
static void bfe_core_disable (struct bfe_softc *);
-static int bfe_dma_alloc (device_t);
-static void bfe_dma_map_desc (void *, bus_dma_segment_t *, int, int);
+static int bfe_dma_alloc (struct bfe_softc *);
+static void bfe_dma_free (struct bfe_softc *sc);
static void bfe_dma_map (void *, bus_dma_segment_t *, int, int);
static void bfe_cam_write (struct bfe_softc *, u_char *, int);
@@ -186,137 +180,252 @@
return (ENXIO);
}
+struct bfe_dmamap_arg {
+ bus_addr_t bfe_busaddr;
+};
+
static int
-bfe_dma_alloc(device_t dev)
+bfe_dma_alloc(struct bfe_softc *sc)
{
- struct bfe_softc *sc;
+ struct bfe_dmamap_arg ctx;
+ struct bfe_rx_data *rd;
+ struct bfe_tx_data *td;
int error, i;
- sc = device_get_softc(dev);
-
/*
* parent tag. Apparently the chip cannot handle any DMA address
* greater than 1GB.
*/
- error = bus_dma_tag_create(NULL, /* parent */
- 4096, 0, /* alignment, boundary */
- 0x3FFFFFFF, /* lowaddr */
- BUS_SPACE_MAXADDR, /* highaddr */
- NULL, NULL, /* filter, filterarg */
- MAXBSIZE, /* maxsize */
- BUS_SPACE_UNRESTRICTED, /* num of segments */
- BUS_SPACE_MAXSIZE_32BIT, /* max segment size */
- 0, /* flags */
- NULL, NULL, /* lockfunc, lockarg */
- &sc->bfe_parent_tag);
+ error = bus_dma_tag_create(bus_get_dma_tag(sc->bfe_dev), /* parent */
+ 1, 0, /* alignment, boundary */
+ BFE_DMA_MAXADDR, /* lowaddr */
+ BUS_SPACE_MAXADDR, /* highaddr */
+ NULL, NULL, /* filter, filterarg */
+ BUS_SPACE_MAXSIZE_32BIT, /* maxsize */
+ 0, /* nsegments */
+ BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */
+ 0, /* flags */
+ NULL, NULL, /* lockfunc, lockarg */
+ &sc->bfe_parent_tag);
+ if (error != 0) {
+ device_printf(sc->bfe_dev, "cannot create parent DMA tag.\n");
+ goto fail;
+ }
- /* tag for TX ring */
- error = bus_dma_tag_create(sc->bfe_parent_tag,
- 4096, 0,
- BUS_SPACE_MAXADDR,
- BUS_SPACE_MAXADDR,
- NULL, NULL,
- BFE_TX_LIST_SIZE,
- 1,
- BUS_SPACE_MAXSIZE_32BIT,
- 0,
- NULL, NULL,
- &sc->bfe_tx_tag);
+ /* Create tag for Tx ring. */
+ error = bus_dma_tag_create(sc->bfe_parent_tag, /* parent */
+ BFE_TX_RING_ALIGN, 0, /* alignment, boundary */
+ BUS_SPACE_MAXADDR, /* lowaddr */
+ BUS_SPACE_MAXADDR, /* highaddr */
+ NULL, NULL, /* filter, filterarg */
+ BFE_TX_LIST_SIZE, /* maxsize */
+ 1, /* nsegments */
+ BFE_TX_LIST_SIZE, /* maxsegsize */
+ 0, /* flags */
+ NULL, NULL, /* lockfunc, lockarg */
+ &sc->bfe_tx_tag);
+ if (error != 0) {
+ device_printf(sc->bfe_dev, "cannot create Tx ring DMA tag.\n");
+ goto fail;
+ }
- if (error) {
- device_printf(dev, "could not allocate dma tag\n");
- return (ENOMEM);
+ /* Create tag for Rx ring. */
+ error = bus_dma_tag_create(sc->bfe_parent_tag, /* parent */
+ BFE_RX_RING_ALIGN, 0, /* alignment, boundary */
+ BUS_SPACE_MAXADDR, /* lowaddr */
+ BUS_SPACE_MAXADDR, /* highaddr */
+ NULL, NULL, /* filter, filterarg */
+ BFE_RX_LIST_SIZE, /* maxsize */
+ 1, /* nsegments */
+ BFE_RX_LIST_SIZE, /* maxsegsize */
+ 0, /* flags */
+ NULL, NULL, /* lockfunc, lockarg */
+ &sc->bfe_rx_tag);
+ if (error != 0) {
+ device_printf(sc->bfe_dev, "cannot create Rx ring DMA tag.\n");
+ goto fail;
}
- /* tag for RX ring */
- error = bus_dma_tag_create(sc->bfe_parent_tag,
- 4096, 0,
- BUS_SPACE_MAXADDR,
- BUS_SPACE_MAXADDR,
- NULL, NULL,
- BFE_RX_LIST_SIZE,
- 1,
- BUS_SPACE_MAXSIZE_32BIT,
- 0,
- NULL, NULL,
- &sc->bfe_rx_tag);
+ /* Create tag for Tx buffers. */
+ error = bus_dma_tag_create(sc->bfe_parent_tag, /* parent */
+ 1, 0, /* alignment, boundary */
+ BUS_SPACE_MAXADDR, /* lowaddr */
+ BUS_SPACE_MAXADDR, /* highaddr */
+ NULL, NULL, /* filter, filterarg */
+ MCLBYTES * BFE_MAXTXSEGS, /* maxsize */
+ BFE_MAXTXSEGS, /* nsegments */
+ MCLBYTES, /* maxsegsize */
+ 0, /* flags */
+ NULL, NULL, /* lockfunc, lockarg */
+ &sc->bfe_txmbuf_tag);
+ if (error != 0) {
+ device_printf(sc->bfe_dev,
+ "cannot create Tx buffer DMA tag.\n");
+ goto fail;
+ }
- if (error) {
- device_printf(dev, "could not allocate dma tag\n");
- return (ENOMEM);
+ /* Create tag for Rx buffers. */
+ error = bus_dma_tag_create(sc->bfe_parent_tag, /* parent */
+ 1, 0, /* alignment, boundary */
+ BUS_SPACE_MAXADDR, /* lowaddr */
+ BUS_SPACE_MAXADDR, /* highaddr */
+ NULL, NULL, /* filter, filterarg */
+ MCLBYTES, /* maxsize */
+ 1, /* nsegments */
+ MCLBYTES, /* maxsegsize */
+ 0, /* flags */
+ NULL, NULL, /* lockfunc, lockarg */
+ &sc->bfe_rxmbuf_tag);
+ if (error != 0) {
+ device_printf(sc->bfe_dev,
+ "cannot create Rx buffer DMA tag.\n");
+ goto fail;
}
- /* tag for mbufs */
- error = bus_dma_tag_create(sc->bfe_parent_tag,
- ETHER_ALIGN, 0,
- BUS_SPACE_MAXADDR,
- BUS_SPACE_MAXADDR,
- NULL, NULL,
- MCLBYTES,
- 1,
- BUS_SPACE_MAXSIZE_32BIT,
- BUS_DMA_ALLOCNOW,
- NULL, NULL,
- &sc->bfe_tag);
+ /* Allocate DMA'able memory and load DMA map. */
+ error = bus_dmamem_alloc(sc->bfe_tx_tag, (void *)&sc->bfe_tx_list,
+ BUS_DMA_WAITOK | BUS_DMA_ZERO | BUS_DMA_COHERENT, &sc->bfe_tx_map);
+ if (error != 0) {
+ device_printf(sc->bfe_dev,
+ "cannot allocate DMA'able memory for Tx ring.\n");
+ goto fail;
+ }
+ ctx.bfe_busaddr = 0;
+ error = bus_dmamap_load(sc->bfe_tx_tag, sc->bfe_tx_map,
+ sc->bfe_tx_list, BFE_TX_LIST_SIZE, bfe_dma_map, &ctx,
+ BUS_DMA_NOWAIT);
+ if (error != 0 || ctx.bfe_busaddr == 0) {
+ device_printf(sc->bfe_dev,
+ "cannot load DMA'able memory for Tx ring.\n");
+ goto fail;
+ }
+ sc->bfe_tx_dma = BFE_ADDR_LO(ctx.bfe_busaddr);
- if (error) {
- device_printf(dev, "could not allocate dma tag\n");
- return (ENOMEM);
+ error = bus_dmamem_alloc(sc->bfe_rx_tag, (void *)&sc->bfe_rx_list,
+ BUS_DMA_WAITOK | BUS_DMA_ZERO | BUS_DMA_COHERENT, &sc->bfe_rx_map);
+ if (error != 0) {
+ device_printf(sc->bfe_dev,
+ "cannot allocate DMA'able memory for Rx ring.\n");
+ goto fail;
+ }
+ ctx.bfe_busaddr = 0;
+ error = bus_dmamap_load(sc->bfe_rx_tag, sc->bfe_rx_map,
+ sc->bfe_rx_list, BFE_RX_LIST_SIZE, bfe_dma_map, &ctx,
+ BUS_DMA_NOWAIT);
+ if (error != 0 || ctx.bfe_busaddr == 0) {
+ device_printf(sc->bfe_dev,
+ "cannot load DMA'able memory for Rx ring.\n");
+ goto fail;
}
+ sc->bfe_rx_dma = BFE_ADDR_LO(ctx.bfe_busaddr);
- /* pre allocate dmamaps for RX list */
- for (i = 0; i < BFE_RX_LIST_CNT; i++) {
- error = bus_dmamap_create(sc->bfe_tag, 0,
- &sc->bfe_rx_ring[i].bfe_map);
- if (error) {
- device_printf(dev, "cannot create DMA map for RX\n");
- return (ENOMEM);
+ /* Create DMA maps for Tx buffers. */
+ for (i = 0; i < BFE_TX_LIST_CNT; i++) {
+ td = &sc->bfe_tx_ring[i];
+ td->bfe_mbuf = NULL;
+ td->bfe_map = NULL;
+ error = bus_dmamap_create(sc->bfe_txmbuf_tag, 0, &td->bfe_map);
+ if (error != 0) {
+ device_printf(sc->bfe_dev,
+ "cannot create DMA map for Tx.\n");
+ goto fail;
}
}
- /* pre allocate dmamaps for TX list */
- for (i = 0; i < BFE_TX_LIST_CNT; i++) {
- error = bus_dmamap_create(sc->bfe_tag, 0,
- &sc->bfe_tx_ring[i].bfe_map);
- if (error) {
- device_printf(dev, "cannot create DMA map for TX\n");
- return (ENOMEM);
+ /* Create spare DMA map for Rx buffers. */
+ error = bus_dmamap_create(sc->bfe_rxmbuf_tag, 0, &sc->bfe_rx_sparemap);
+ if (error != 0) {
+ device_printf(sc->bfe_dev, "cannot create spare DMA map for Rx.\n");
+ goto fail;
+ }
+ /* Create DMA maps for Rx buffers. */
+ for (i = 0; i < BFE_RX_LIST_CNT; i++) {
+ rd = &sc->bfe_rx_ring[i];
+ rd->bfe_mbuf = NULL;
+ rd->bfe_map = NULL;
+ rd->bfe_ctrl = 0;
+ error = bus_dmamap_create(sc->bfe_rxmbuf_tag, 0, &rd->bfe_map);
+ if (error != 0) {
+ device_printf(sc->bfe_dev,
+ "cannot create DMA map for Rx.\n");
+ goto fail;
}
}
- /* Alloc dma for rx ring */
- error = bus_dmamem_alloc(sc->bfe_rx_tag, (void *)&sc->bfe_rx_list,
- BUS_DMA_NOWAIT, &sc->bfe_rx_map);
+fail:
+ return (error);
+}
- if (error)
- return (ENOMEM);
+static void
+bfe_dma_free(struct bfe_softc *sc)
+{
+ struct bfe_tx_data *td;
+ struct bfe_rx_data *rd;
+ int i;
- bzero(sc->bfe_rx_list, BFE_RX_LIST_SIZE);
- error = bus_dmamap_load(sc->bfe_rx_tag, sc->bfe_rx_map,
- sc->bfe_rx_list, sizeof(struct bfe_desc),
- bfe_dma_map, &sc->bfe_rx_dma, BUS_DMA_NOWAIT);
+ /* Tx ring. */
+ if (sc->bfe_tx_tag != NULL) {
+ if (sc->bfe_tx_map != NULL)
+ bus_dmamap_unload(sc->bfe_tx_tag, sc->bfe_tx_map);
+ if (sc->bfe_tx_map != NULL && sc->bfe_tx_list != NULL)
+ bus_dmamem_free(sc->bfe_tx_tag, sc->bfe_tx_list,
+ sc->bfe_tx_map);
+ sc->bfe_tx_map = NULL;
+ sc->bfe_tx_list = NULL;
+ bus_dma_tag_destroy(sc->bfe_tx_tag);
+ sc->bfe_tx_tag = NULL;
+ }
- if (error)
- return (ENOMEM);
+ /* Rx ring. */
+ if (sc->bfe_rx_tag != NULL) {
+ if (sc->bfe_rx_map != NULL)
+ bus_dmamap_unload(sc->bfe_rx_tag, sc->bfe_rx_map);
+ if (sc->bfe_rx_map != NULL && sc->bfe_rx_list != NULL)
+ bus_dmamem_free(sc->bfe_rx_tag, sc->bfe_rx_list,
+ sc->bfe_rx_map);
+ sc->bfe_rx_map = NULL;
+ sc->bfe_rx_list = NULL;
+ bus_dma_tag_destroy(sc->bfe_rx_tag);
+ sc->bfe_rx_tag = NULL;
+ }
- bus_dmamap_sync(sc->bfe_rx_tag, sc->bfe_rx_map, BUS_DMASYNC_PREWRITE);
+ /* Tx buffers. */
+ if (sc->bfe_txmbuf_tag != NULL) {
+ for (i = 0; i < BFE_TX_LIST_CNT; i++) {
+ td = &sc->bfe_tx_ring[i];
+ if (td->bfe_map != NULL) {
+ bus_dmamap_destroy(sc->bfe_txmbuf_tag,
+ td->bfe_map);
+ td->bfe_map = NULL;
+ }
+ }
+ bus_dma_tag_destroy(sc->bfe_txmbuf_tag);
+ sc->bfe_txmbuf_tag = NULL;
+ }
- error = bus_dmamem_alloc(sc->bfe_tx_tag, (void *)&sc->bfe_tx_list,
- BUS_DMA_NOWAIT, &sc->bfe_tx_map);
- if (error)
- return (ENOMEM);
+ /* Rx buffers. */
+ if (sc->bfe_rxmbuf_tag != NULL) {
+ for (i = 0; i < BFE_RX_LIST_CNT; i++) {
+ rd = &sc->bfe_rx_ring[i];
+ if (rd->bfe_map != NULL) {
+ bus_dmamap_destroy(sc->bfe_rxmbuf_tag,
+ rd->bfe_map);
+ rd->bfe_map = NULL;
+ }
+ }
+ if (sc->bfe_rx_sparemap != NULL) {
+ bus_dmamap_destroy(sc->bfe_rxmbuf_tag,
+ sc->bfe_rx_sparemap);
+ sc->bfe_rx_sparemap = NULL;
+ }
+ bus_dma_tag_destroy(sc->bfe_rxmbuf_tag);
+ sc->bfe_rxmbuf_tag = NULL;
+ }
-
- error = bus_dmamap_load(sc->bfe_tx_tag, sc->bfe_tx_map,
- sc->bfe_tx_list, sizeof(struct bfe_desc),
- bfe_dma_map, &sc->bfe_tx_dma, BUS_DMA_NOWAIT);
- if (error)
- return (ENOMEM);
-
- bzero(sc->bfe_tx_list, BFE_TX_LIST_SIZE);
- bus_dmamap_sync(sc->bfe_tx_tag, sc->bfe_tx_map, BUS_DMASYNC_PREWRITE);
-
- return (0);
+ if (sc->bfe_parent_tag != NULL) {
+ bus_dma_tag_destroy(sc->bfe_parent_tag);
+ sc->bfe_parent_tag = NULL;
+ }
}
static int
@@ -338,7 +447,7 @@
*/
pci_enable_busmaster(dev);
- rid = BFE_PCI_MEMLO;
+ rid = PCIR_BAR(0);
sc->bfe_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
RF_ACTIVE);
if (sc->bfe_res == NULL) {
@@ -347,10 +456,6 @@
goto fail;
}
- sc->bfe_btag = rman_get_bustag(sc->bfe_res);
- sc->bfe_bhandle = rman_get_bushandle(sc->bfe_res);
- sc->bfe_vhandle = (vm_offset_t)rman_get_virtual(sc->bfe_res);
-
/* Allocate interrupt */
rid = 0;
@@ -362,7 +467,7 @@
goto fail;
}
- if (bfe_dma_alloc(dev)) {
+ if (bfe_dma_alloc(sc) != 0) {
device_printf(dev, "failed to allocate DMA resources\n");
error = ENXIO;
goto fail;
@@ -420,8 +525,8 @@
goto fail;
}
fail:
- if (error)
- bfe_release_resources(sc);
+ if (error != 0)
+ bfe_detach(dev);
return (error);
}
@@ -433,8 +538,6 @@
sc = device_get_softc(dev);
- KASSERT(mtx_initialized(&sc->bfe_mtx), ("bfe mutex not initialized"));
-
ifp = sc->bfe_ifp;
if (device_is_attached(dev)) {
@@ -446,13 +549,16 @@
ether_ifdetach(ifp);
}
+ BFE_LOCK(sc);
bfe_chip_reset(sc);
+ BFE_UNLOCK(sc);
bus_generic_detach(dev);
if (sc->bfe_miibus != NULL)
device_delete_child(dev, sc->bfe_miibus);
bfe_release_resources(sc);
+ bfe_dma_free(sc);
mtx_destroy(&sc->bfe_mtx);
return (0);
@@ -585,14 +691,17 @@
for(i = 0; i < BFE_TX_LIST_CNT; i++) {
if (sc->bfe_tx_ring[i].bfe_mbuf != NULL) {
+ bus_dmamap_sync(sc->bfe_txmbuf_tag,
+ sc->bfe_tx_ring[i].bfe_map, BUS_DMASYNC_POSTWRITE);
+ bus_dmamap_unload(sc->bfe_txmbuf_tag,
+ sc->bfe_tx_ring[i].bfe_map);
m_freem(sc->bfe_tx_ring[i].bfe_mbuf);
sc->bfe_tx_ring[i].bfe_mbuf = NULL;
- bus_dmamap_unload(sc->bfe_tag,
- sc->bfe_tx_ring[i].bfe_map);
}
}
bzero(sc->bfe_tx_list, BFE_TX_LIST_SIZE);
- bus_dmamap_sync(sc->bfe_tx_tag, sc->bfe_tx_map, BUS_DMASYNC_PREWRITE);
+ bus_dmamap_sync(sc->bfe_tx_tag, sc->bfe_tx_map,
+ BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
}
static void
@@ -602,85 +711,117 @@
for (i = 0; i < BFE_RX_LIST_CNT; i++) {
if (sc->bfe_rx_ring[i].bfe_mbuf != NULL) {
+ bus_dmamap_sync(sc->bfe_rxmbuf_tag,
+ sc->bfe_rx_ring[i].bfe_map, BUS_DMASYNC_POSTREAD);
+ bus_dmamap_unload(sc->bfe_rxmbuf_tag,
+ sc->bfe_rx_ring[i].bfe_map);
m_freem(sc->bfe_rx_ring[i].bfe_mbuf);
sc->bfe_rx_ring[i].bfe_mbuf = NULL;
- bus_dmamap_unload(sc->bfe_tag,
- sc->bfe_rx_ring[i].bfe_map);
}
}
bzero(sc->bfe_rx_list, BFE_RX_LIST_SIZE);
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list