Module Name:    src
Committed By:   nat
Date:           Thu Dec 22 11:05:55 UTC 2022

Modified Files:
        src/distrib/sets/lists/man: mi
        src/share/man/man4: Makefile
        src/sys/arch/alpha/conf: GENERIC
        src/sys/arch/amd64/conf: ALL
        src/sys/arch/atari/conf: ATARITT FALCON GENERIC.in HADES HADES.in
        src/sys/arch/i386/conf: ALL
        src/sys/arch/mac68k/conf: GENERIC
        src/sys/arch/next68k/conf: GENERIC SLAB
        src/sys/dev/scsipi: files.scsipi
Added Files:
        src/share/man/man4: dse.4
        src/sys/dev/scsipi: if_dse.c

Log Message:
Driver for DaynaPORT SCSI/Link (dse.4).

Written by Hiroshi Noguchi, of which an updated version was posted to
port-mac68k in 2001.

Attachments were added to kernel configs for platforms that already had
the Cabletron (se.4) driver added, although other platorms may benefit.

Reviewed on tech-net by Izumi Tsutsui.


To generate a diff of this commit:
cvs rdiff -u -r1.1757 -r1.1758 src/distrib/sets/lists/man/mi
cvs rdiff -u -r1.730 -r1.731 src/share/man/man4/Makefile
cvs rdiff -u -r0 -r1.1 src/share/man/man4/dse.4
cvs rdiff -u -r1.416 -r1.417 src/sys/arch/alpha/conf/GENERIC
cvs rdiff -u -r1.174 -r1.175 src/sys/arch/amd64/conf/ALL
cvs rdiff -u -r1.125 -r1.126 src/sys/arch/atari/conf/ATARITT
cvs rdiff -u -r1.122 -r1.123 src/sys/arch/atari/conf/FALCON
cvs rdiff -u -r1.124 -r1.125 src/sys/arch/atari/conf/GENERIC.in
cvs rdiff -u -r1.120 -r1.121 src/sys/arch/atari/conf/HADES
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/atari/conf/HADES.in
cvs rdiff -u -r1.503 -r1.504 src/sys/arch/i386/conf/ALL
cvs rdiff -u -r1.235 -r1.236 src/sys/arch/mac68k/conf/GENERIC
cvs rdiff -u -r1.153 -r1.154 src/sys/arch/next68k/conf/GENERIC
cvs rdiff -u -r1.60 -r1.61 src/sys/arch/next68k/conf/SLAB
cvs rdiff -u -r1.43 -r1.44 src/sys/dev/scsipi/files.scsipi
cvs rdiff -u -r0 -r1.1 src/sys/dev/scsipi/if_dse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/man/mi
diff -u src/distrib/sets/lists/man/mi:1.1757 src/distrib/sets/lists/man/mi:1.1758
--- src/distrib/sets/lists/man/mi:1.1757	Mon Nov 21 22:01:32 2022
+++ src/distrib/sets/lists/man/mi	Thu Dec 22 11:05:54 2022
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1757 2022/11/21 22:01:32 christos Exp $
+# $NetBSD: mi,v 1.1758 2022/12/22 11:05:54 nat Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -1060,6 +1060,7 @@
 ./usr/share/man/cat4/drm.0			man-sys-catman		.cat
 ./usr/share/man/cat4/drum.0			man-sys-catman		.cat
 ./usr/share/man/cat4/drvctl.0			man-sys-catman		.cat
+./usr/share/man/cat4/dse.0			man-sys-catman		.cat
 ./usr/share/man/cat4/dtide.0			man-sys-catman		.cat
 ./usr/share/man/cat4/dtv.0			man-sys-catman		.cat
 ./usr/share/man/cat4/dtviic.0			man-sys-catman		.cat
@@ -4331,6 +4332,7 @@
 ./usr/share/man/html4/drm.html			man-sys-htmlman		html
 ./usr/share/man/html4/drum.html			man-sys-htmlman		html
 ./usr/share/man/html4/drvctl.html		man-sys-htmlman		html
+./usr/share/man/html4/dse.html			man-sys-htmlman		html
 ./usr/share/man/html4/dtide.html		man-sys-htmlman		html
 ./usr/share/man/html4/dtv.html			man-sys-htmlman		html
 ./usr/share/man/html4/dtviic.html		man-sys-htmlman		html
@@ -7374,6 +7376,7 @@
 ./usr/share/man/man4/drm.4			man-sys-man		.man
 ./usr/share/man/man4/drum.4			man-sys-man		.man
 ./usr/share/man/man4/drvctl.4			man-sys-man		.man
+./usr/share/man/man4/dse.4			man-sys-man		.man
 ./usr/share/man/man4/dtide.4			man-sys-man		.man
 ./usr/share/man/man4/dtv.4			man-sys-man		.man
 ./usr/share/man/man4/dtviic.4			man-sys-man		.man

Index: src/share/man/man4/Makefile
diff -u src/share/man/man4/Makefile:1.730 src/share/man/man4/Makefile:1.731
--- src/share/man/man4/Makefile:1.730	Mon Nov 21 21:24:00 2022
+++ src/share/man/man4/Makefile	Thu Dec 22 11:05:54 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.730 2022/11/21 21:24:00 brad Exp $
+#	$NetBSD: Makefile,v 1.731 2022/12/22 11:05:54 nat Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/18/93
 
 MAN=	aac.4 ac97.4 acardide.4 aceride.4 acphy.4 \
@@ -20,7 +20,8 @@ MAN=	aac.4 ac97.4 acardide.4 aceride.4 a
 	clockctl.4 cmdide.4 cmpci.4 cms.4 cnw.4 \
 	com.4 coram.4 crypto.4 cs80bus.4 cuda.4 cypide.4 cxdtv.4 \
 	ddb.4 ddc.4 dge.4 dk.4 dm.4 dmoverio.4 \
-	dmphy.4 dpt.4 dpti.4 drm.4 drum.4 drvctl.4 dtv.4 dtviic.4 dwctwo.4 \
+	dmphy.4 dpt.4 dpti.4 drm.4 drum.4 drvctl.4 dse.4 dtv.4 dtviic.4 \
+	dwctwo.4 \
 	eap.4 ebus.4 edc.4 elmc.4 emuxki.4 ena.4 envsys.4 ep.4 \
 	eqos.4 esa.4 esiop.4 esm.4 eso.4 et.4 etphy.4 exphy.4 \
 	fd.4 finsio.4 flash.4 fms.4 fss.4 \

Index: src/sys/arch/alpha/conf/GENERIC
diff -u src/sys/arch/alpha/conf/GENERIC:1.416 src/sys/arch/alpha/conf/GENERIC:1.417
--- src/sys/arch/alpha/conf/GENERIC:1.416	Thu Sep 29 10:10:05 2022
+++ src/sys/arch/alpha/conf/GENERIC	Thu Dec 22 11:05:54 2022
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.416 2022/09/29 10:10:05 riastradh Exp $
+# $NetBSD: GENERIC,v 1.417 2022/12/22 11:05:54 nat Exp $
 #
 # This machine description file is used to generate the default NetBSD
 # kernel.
@@ -19,7 +19,7 @@ include 	"arch/alpha/conf/std.alpha"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-ident		"GENERIC-$Revision: 1.416 $"
+ident		"GENERIC-$Revision: 1.417 $"
 
 maxusers 32
 
@@ -491,6 +491,7 @@ scsibus* at	scsi?
 cd*	at	scsibus? target ? lun ?		# SCSI CD-ROM drives
 ch*	at	scsibus? target ? lun ?		# SCSI autochangers
 sd*	at	scsibus? target ? lun ?		# SCSI disk drives
+dse*	at	scsibus? target ? lun ?		# SCSI ethernet (Dayna)
 se*	at	scsibus? target ? lun ?		# Cabletron SCSI<->Ethernet
 ses*	at	scsibus? target ? lun ?		# SCSI SES/SAF-TE
 ss*	at	scsibus? target ? lun ?		# SCSI scanners

Index: src/sys/arch/amd64/conf/ALL
diff -u src/sys/arch/amd64/conf/ALL:1.174 src/sys/arch/amd64/conf/ALL:1.175
--- src/sys/arch/amd64/conf/ALL:1.174	Sat Sep 24 11:05:17 2022
+++ src/sys/arch/amd64/conf/ALL	Thu Dec 22 11:05:55 2022
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.174 2022/09/24 11:05:17 riastradh Exp $
+# $NetBSD: ALL,v 1.175 2022/12/22 11:05:55 nat Exp $
 # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
 #
 # ALL machine description file
@@ -17,7 +17,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"ALL-$Revision: 1.174 $"
+#ident		"ALL-$Revision: 1.175 $"
 
 maxusers	64		# estimated number of users
 
@@ -828,6 +828,7 @@ cd*	at scsibus? target ? lun ?	# SCSI CD
 ch*	at scsibus? target ? lun ?	# SCSI autochangers
 ses*	at scsibus? target ? lun ?	# SCSI Enclosure Services devices
 ss*	at scsibus? target ? lun ?	# SCSI scanners
+dse*	at scsibus? target ? lun ?	# SCSI ethernet (Dayna)
 se*	at scsibus? target ? lun ?	# SCSI ethernet adapters
 uk*	at scsibus? target ? lun ?	# SCSI unknown
 

Index: src/sys/arch/atari/conf/ATARITT
diff -u src/sys/arch/atari/conf/ATARITT:1.125 src/sys/arch/atari/conf/ATARITT:1.126
--- src/sys/arch/atari/conf/ATARITT:1.125	Sun Aug  7 02:55:46 2022
+++ src/sys/arch/atari/conf/ATARITT	Thu Dec 22 11:05:55 2022
@@ -1,5 +1,5 @@
 #
-# $NetBSD: ATARITT,v 1.125 2022/08/07 02:55:46 simonb Exp $
+# $NetBSD: ATARITT,v 1.126 2022/12/22 11:05:55 nat Exp $
 #
 # This file was automatically created. Changes will be
 # lost when running makeconf in this directory.
@@ -90,4 +90,5 @@ et4k0 at vme0 # Crazy Dots II
 scsibus* at scsi? # SCSI bus
 sd* at scsibus? target ? lun ? # SCSI disk drives
 cd* at scsibus? target ? lun ? # SCSI CD-ROM drives
+dse* at scsibus? target ? lun ?	# SCSI ethernet (Dayna)
 se* at scsibus? target ? lun ? # SCSI ethernet

Index: src/sys/arch/atari/conf/FALCON
diff -u src/sys/arch/atari/conf/FALCON:1.122 src/sys/arch/atari/conf/FALCON:1.123
--- src/sys/arch/atari/conf/FALCON:1.122	Sun Aug  7 02:55:46 2022
+++ src/sys/arch/atari/conf/FALCON	Thu Dec 22 11:05:55 2022
@@ -1,5 +1,5 @@
 #
-# $NetBSD: FALCON,v 1.122 2022/08/07 02:55:46 simonb Exp $
+# $NetBSD: FALCON,v 1.123 2022/12/22 11:05:55 nat Exp $
 #
 # This file was automatically created. Changes will be
 # lost when running makeconf in this directory.
@@ -94,4 +94,5 @@ cd* at atapibus? drive ? # ATAPI CD-ROM 
 scsibus* at scsi? # SCSI bus
 sd* at scsibus? target ? lun ? # SCSI disk drives
 cd* at scsibus? target ? lun ? # SCSI CD-ROM drives
+dse* at scsibus? target ? lun ?	# SCSI ethernet (Dayna)
 se* at scsibus? target ? lun ? # SCSI ethernet

Index: src/sys/arch/atari/conf/GENERIC.in
diff -u src/sys/arch/atari/conf/GENERIC.in:1.124 src/sys/arch/atari/conf/GENERIC.in:1.125
--- src/sys/arch/atari/conf/GENERIC.in:1.124	Sun Aug  7 02:52:24 2022
+++ src/sys/arch/atari/conf/GENERIC.in	Thu Dec 22 11:05:55 2022
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC.in,v 1.124 2022/08/07 02:52:24 simonb Exp $
+#	$NetBSD: GENERIC.in,v 1.125 2022/12/22 11:05:55 nat Exp $
 #
 # Generic atari
 #
@@ -371,6 +371,7 @@ cd* 	at scsibus? target ? lun ?	# SCSI C
 #st* 	at scsibus? target ? lun ?	# SCSI tape drives
 #ch* 	at scsibus? target ? lun ?	# SCSI autochangers
 #ss* 	at scsibus? target ? lun ?	# SCSI scanners
+dse*	at scsibus? target ? lun ?	# SCSI ethernet (Dayna)
 se* 	at scsibus? target ? lun ?	# SCSI ethernet
 #uk* 	at scsibus? target ? lun ?	# SCSI unknown
 #endif /* ! SMALL030_KERNEL */

Index: src/sys/arch/atari/conf/HADES
diff -u src/sys/arch/atari/conf/HADES:1.120 src/sys/arch/atari/conf/HADES:1.121
--- src/sys/arch/atari/conf/HADES:1.120	Sun Aug  7 02:55:46 2022
+++ src/sys/arch/atari/conf/HADES	Thu Dec 22 11:05:55 2022
@@ -1,5 +1,5 @@
 #
-# $NetBSD: HADES,v 1.120 2022/08/07 02:55:46 simonb Exp $
+# $NetBSD: HADES,v 1.121 2022/12/22 11:05:55 nat Exp $
 #
 # This file was automatically created. Changes will be
 # lost when running makeconf in this directory.
@@ -113,6 +113,7 @@ st* at scsibus? target ? lun ? # SCSI ta
 cd* at scsibus? target ? lun ? # SCSI CD-ROM drives
 ch* at scsibus? target ? lun ? # SCSI autochangers
 ss* at scsibus? target ? lun ? # SCSI scanners
+dse* at scsibus? target ? lun ?	# SCSI ethernet (Dayna)
 se* at scsibus? target ? lun ? # SCSI ethernet
 uk* at scsibus? target ? lun ? # SCSI unknown
 ne0 at isa0 port 0x300 irq 5 # NE2000 ethernet

Index: src/sys/arch/atari/conf/HADES.in
diff -u src/sys/arch/atari/conf/HADES.in:1.16 src/sys/arch/atari/conf/HADES.in:1.17
--- src/sys/arch/atari/conf/HADES.in:1.16	Sat Mar 31 04:19:41 2018
+++ src/sys/arch/atari/conf/HADES.in	Thu Dec 22 11:05:55 2022
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: HADES.in,v 1.16 2018/03/31 04:19:41 tsutsui Exp $
+#	$NetBSD: HADES.in,v 1.17 2022/12/22 11:05:55 nat Exp $
 #
 # Medusa-Hades
 #
@@ -57,6 +57,7 @@ cd* 	at scsibus? target ? lun ?	# SCSI C
 #if !defined(SMALL030_KERNEL)
 ch* 	at scsibus? target ? lun ?	# SCSI autochangers
 ss* 	at scsibus? target ? lun ?	# SCSI scanners
+dse*	at scsibus? target ? lun ?	# SCSI ethernet (Dayna)
 se* 	at scsibus? target ? lun ?	# SCSI ethernet
 uk* 	at scsibus? target ? lun ?	# SCSI unknown
 #endif /* SMALL030_KERNEL */

Index: src/sys/arch/i386/conf/ALL
diff -u src/sys/arch/i386/conf/ALL:1.503 src/sys/arch/i386/conf/ALL:1.504
--- src/sys/arch/i386/conf/ALL:1.503	Sat Sep 24 11:05:17 2022
+++ src/sys/arch/i386/conf/ALL	Thu Dec 22 11:05:55 2022
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.503 2022/09/24 11:05:17 riastradh Exp $
+# $NetBSD: ALL,v 1.504 2022/12/22 11:05:55 nat Exp $
 # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
 #
 # ALL machine description file
@@ -17,7 +17,7 @@ include 	"arch/i386/conf/std.i386"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"ALL-$Revision: 1.503 $"
+#ident		"ALL-$Revision: 1.504 $"
 
 maxusers	64		# estimated number of users
 
@@ -906,6 +906,7 @@ cd*	at scsibus? target ? lun ?	# SCSI CD
 ch*	at scsibus? target ? lun ?	# SCSI autochangers
 ses*	at scsibus? target ? lun ?	# SCSI Enclosure Services devices
 ss*	at scsibus? target ? lun ?	# SCSI scanners
+dse*	at scsibus? target ? lun ?	# SCSI ethernet (Dayna)
 se*	at scsibus? target ? lun ?	# SCSI ethernet adapters
 uk*	at scsibus? target ? lun ?	# SCSI unknown
 

Index: src/sys/arch/mac68k/conf/GENERIC
diff -u src/sys/arch/mac68k/conf/GENERIC:1.235 src/sys/arch/mac68k/conf/GENERIC:1.236
--- src/sys/arch/mac68k/conf/GENERIC:1.235	Sun Aug  7 02:52:27 2022
+++ src/sys/arch/mac68k/conf/GENERIC	Thu Dec 22 11:05:55 2022
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.235 2022/08/07 02:52:27 simonb Exp $
+# $NetBSD: GENERIC,v 1.236 2022/12/22 11:05:55 nat Exp $
 #
 # GENERIC machine description file
 # 
@@ -22,7 +22,7 @@ include 	"arch/mac68k/conf/std.mac68k"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.235 $"
+#ident 		"GENERIC-$Revision: 1.236 $"
 
 makeoptions	COPTS="-O2 -fno-reorder-blocks -fno-omit-frame-pointer"
 	# See share/mk/sys.mk. -fno-omit-frame-pointer is necessary for
@@ -251,6 +251,7 @@ sd*	at scsibus? target ? lun ?	# SCSI di
 st*	at scsibus? target ? lun ?	# SCSI tape drives
 cd*	at scsibus? target ? lun ?	# SCSI CD-ROM drives
 ch*	at scsibus? target ? lun ?	# SCSI autochangers
+dse*	at scsibus? target ? lun ?	# SCSI ethernet (Dayna)
 se*	at scsibus? target ? lun ?	# SCSI ethernet
 ss*	at scsibus? target ? lun ?	# SCSI scanners
 uk*	at scsibus? target ? lun ?	# SCSI unknown

Index: src/sys/arch/next68k/conf/GENERIC
diff -u src/sys/arch/next68k/conf/GENERIC:1.153 src/sys/arch/next68k/conf/GENERIC:1.154
--- src/sys/arch/next68k/conf/GENERIC:1.153	Sun Aug  7 02:52:28 2022
+++ src/sys/arch/next68k/conf/GENERIC	Thu Dec 22 11:05:55 2022
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.153 2022/08/07 02:52:28 simonb Exp $
+# $NetBSD: GENERIC,v 1.154 2022/12/22 11:05:55 nat Exp $
 #
 # GENERIC machine description file
 # 
@@ -22,7 +22,7 @@ include 	"arch/next68k/conf/std.next68k"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.153 $"
+#ident 		"GENERIC-$Revision: 1.154 $"
 
 makeoptions	COPTS="-O2 -fno-reorder-blocks -fno-omit-frame-pointer"
 	# See share/mk/sys.mk. -fno-omit-frame-pointer is necessary for
@@ -206,6 +206,7 @@ sd*	at scsibus? target ? lun ?	# SCSI di
 st*	at scsibus? target ? lun ?	# SCSI tape drives
 cd*	at scsibus? target ? lun ?	# SCSI CD-ROM drives
 ch*	at scsibus? target ? lun ?	# SCSI autochangers
+dse*	at scsibus? target ? lun ?	# SCSI ethernet (Dayna)
 se*	at scsibus? target ? lun ?	# SCSI ethernet
 ss*	at scsibus? target ? lun ?	# SCSI scanners
 uk*	at scsibus? target ? lun ?	# SCSI unknown

Index: src/sys/arch/next68k/conf/SLAB
diff -u src/sys/arch/next68k/conf/SLAB:1.60 src/sys/arch/next68k/conf/SLAB:1.61
--- src/sys/arch/next68k/conf/SLAB:1.60	Thu Jan 21 06:51:55 2021
+++ src/sys/arch/next68k/conf/SLAB	Thu Dec 22 11:05:55 2022
@@ -1,4 +1,4 @@
-# $NetBSD: SLAB,v 1.60 2021/01/21 06:51:55 nia Exp $
+# $NetBSD: SLAB,v 1.61 2022/12/22 11:05:55 nat Exp $
 #
 # deberg's development machine
 #
@@ -158,6 +158,7 @@ scsibus* at scsi?
 #st*	at scsibus? target ? lun ?	# SCSI tape drives
 #cd*	at scsibus? target ? lun ?	# SCSI CD-ROM drives
 #ch*	at scsibus? target ? lun ?	# SCSI autochangers
+#dse*	at scsibus? target ? lun ?	# SCSI ethernet (Dayna)
 #se*	at scsibus? target ? lun ?	# SCSI ethernet
 #ss*	at scsibus? target ? lun ?	# SCSI scanners
 #uk*	at scsibus? target ? lun ?	# SCSI unknown

Index: src/sys/dev/scsipi/files.scsipi
diff -u src/sys/dev/scsipi/files.scsipi:1.43 src/sys/dev/scsipi/files.scsipi:1.44
--- src/sys/dev/scsipi/files.scsipi:1.43	Thu Apr 14 16:50:26 2022
+++ src/sys/dev/scsipi/files.scsipi	Thu Dec 22 11:05:55 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: files.scsipi,v 1.43 2022/04/14 16:50:26 pgoyette Exp $
+#	$NetBSD: files.scsipi,v 1.44 2022/12/22 11:05:55 nat Exp $
 #
 # Config file and device description for machine-independent SCSI code.
 # Included by ports that need it.  Ports that use it must provide
@@ -40,6 +40,10 @@ device	ch
 attach	ch at scsibus
 file	dev/scsipi/ch.c			ch			needs-flag
 
+device	dse: ifnet, ether, arp
+attach	dse at scsibus
+file	dev/scsipi/if_dse.c		dse			needs-flag
+
 device	se: ifnet, ether, arp
 attach	se at scsibus
 file	dev/scsipi/if_se.c		se			needs-flag

Added files:

Index: src/share/man/man4/dse.4
diff -u /dev/null src/share/man/man4/dse.4:1.1
--- /dev/null	Thu Dec 22 11:05:56 2022
+++ src/share/man/man4/dse.4	Thu Dec 22 11:05:54 2022
@@ -0,0 +1,82 @@
+.\"	$NetBSD: dse.4,v 1.1 2022/12/22 11:05:54 nat Exp $
+.\" Copyright (c) 2022  Nathanial Sloss <nathanialsl...@yahoo.com.au>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd December 16, 2022
+.Dt DSE 4
+.Os
+.Sh NAME
+.Nm dse
+.Nd DaynaPORT SCSI/Link SCSI bus Ethernet interface driver
+.Sh SYNOPSIS
+.Cd "dse* at scsibus? target ? lun ?"
+.Sh DESCRIPTION
+The
+.Nm
+driver supports the
+.Tn DaynaPORT
+SCSI/Link
+.Tn SCSI
+bus
+.Tn Ethernet
+interface.
+These devices can also be currently emulated on a Raspberry Pi with an RaSCSI
+board running PiSCSI software.
+.Pp
+There are additionally
+.Fn open ,
+.Fn close ,
+and
+.Fn ioctl
+entry points so that the device also appears as a
+.Tn SCSI
+device.
+Currently these functions are place holders.
+.Sh SEE ALSO
+.Xr scsi 4 ,
+.Xr ifconfig 8
+.Sh AUTHORS
+.An -nosplit
+.An Hiroshi Noguchi Aq Mt n...@ff.iij4u.or.jp
+.Pp
+.An -nosplit
+.An Matt Sandstrom Aq Mt matt...@beauty.se
+who modified this driver for
+.Nx 1.5.3
+.Sh BUGS
+This device  doesn't conform to the
+.Tn SCSI
+specification.
+Also that this manual page was written by
+.An -nosplit
+.An Nathanial Sloss Aq Mt nathanialsl...@yahoo.com.au
+.Sh REFERNCES
+.Tn RaSCSI
+http://retropc.net/gimons/rascsi/
+.Pp
+.Tn PiSCSI (formally RaSCSI Reloaded)
+https://github.com/PiSCSI
+.Pp
+.Tn Raspberry Pi
+http://raspberrypi.org

Index: src/sys/dev/scsipi/if_dse.c
diff -u /dev/null src/sys/dev/scsipi/if_dse.c:1.1
--- /dev/null	Thu Dec 22 11:05:56 2022
+++ src/sys/dev/scsipi/if_dse.c	Thu Dec 22 11:05:55 2022
@@ -0,0 +1,1405 @@
+/*	$NetBSD: if_dse.c,v 1.1 2022/12/22 11:05:55 nat Exp $ */
+
+/*
+ * Driver for DaynaPORT SCSI/Link SCSI-Ethernet
+ *
+ * Written by Hiroshi Noguchi <n...@ff.iij4u.or.jp>
+ *
+ * Modified by Matt Sandstrom <matt...@beauty.se> for NetBSD 1.5.3
+ *
+ * This driver is written based on "if_se.c".
+ */
+
+/*
+ * Copyright (c) 1997 Ian W. Dall <ian.d...@dsto.defence.gov.au>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by Ian W. Dall.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+
+#include "opt_inet.h"
+#include "opt_net_mpsafe.h"
+#include "opt_atalk.h"
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/callout.h>
+#include <sys/syslog.h>
+#include <sys/kernel.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <sys/buf.h>
+#include <sys/uio.h>
+#include <sys/malloc.h>
+#include <sys/errno.h>
+#include <sys/device.h>
+#include <sys/disklabel.h>
+#include <sys/disk.h>
+#include <sys/proc.h>
+#include <sys/conf.h>
+
+#include <sys/workqueue.h>
+
+#include <dev/scsipi/scsipi_all.h>
+#include <dev/scsipi/scsiconf.h>
+
+#include <sys/mbuf.h>
+
+#include <sys/socket.h>
+#include <net/if.h>
+#include <net/if_dl.h>
+#include <net/if_ether.h>
+#include <net/if_media.h>
+
+#ifdef INET
+#include <netinet/in.h>
+#include <netinet/if_inarp.h>
+#endif
+
+#ifdef NETATALK
+#include <netatalk/at.h>
+#endif
+
+#include <net/bpf.h>
+
+
+/*
+ * debug flag
+ */
+#if 0
+#define	DSE_DEBUG
+#endif
+
+
+#define DSE_TIMEOUT	100000
+#define	DSE_OUTSTANDING	4
+#define	DSE_RETRIES	4
+#define DSE_MINSIZE	60
+
+#define	DSE_HEADER_TX	4
+#define	DSE_TAIL_TX	4
+#define DSE_EXTRAS_TX	(DSE_HEADER_TX + DSE_TAIL_TX)
+
+#define	DSE_HEADER_RX	6
+#define	DSE_TAIL_RX	0
+#define	DSE_EXTRAS_RX	(DSE_HEADER_RX + DSE_TAIL_RX)
+
+#define	MAX_BYTES_RX	(ETHERMTU + sizeof(struct ether_header) + ETHER_CRC_LEN)
+
+/* 10 full length packets appears to be the max ever returned. 16k is OK */
+#define RBUF_LEN	(16 * 1024)
+
+/*
+ * Tuning parameters:
+ *   We will attempt to adapt to polling fast enough to get RDATA_GOAL packets
+ *   per read
+ */
+#define RDATA_MAX	10	/* maximum of returned packets (guessed) */
+#define RDATA_GOAL 	8
+
+/*
+ * maximum of available multicast address entries (guessed)
+ */
+#define	DSE_MCAST_MAX	10
+
+
+/* dse_poll and dse_poll0 are the normal polling rate and the minimum
+ * polling rate respectively. dse_poll0 should be chosen so that at
+ * maximum ethernet speed, we will read nearly RDATA_MAX packets. dse_poll
+ * should be chosen for reasonable maximum latency.
+ * In practice, if we are being saturated with min length packets, we
+ * can't poll fast enough. Polling with zero delay actually
+ * worsens performance. dse_poll0 is enforced to be always at least 1
+ */
+#if MAC68K_DEBUG
+#define DSE_POLL		50	/* default in milliseconds */
+#define DSE_POLL0 		30	/* default in milliseconds */
+#else
+#define DSE_POLL		80	/* default in milliseconds */
+#define DSE_POLL0 		40	/* default in milliseconds */
+#endif
+int dse_poll = 0;		/* Delay in ticks set at attach time */
+int dse_poll0 = 0;
+int dse_max_received = 0;	/* Instrumentation */
+
+
+
+
+/*==========================================
+  data type defs
+==========================================*/
+typedef struct scsipi_inquiry_data dayna_ether_inquiry_data;
+
+typedef struct {
+	uint8_t	opcode[2];
+	uint8_t	byte3;
+	uint8_t	length[2];
+	uint8_t	byte6;
+} scsi_dayna_ether_generic;
+
+#define	DAYNA_CMD_SEND		0x0A		/* same as generic "Write" */
+#define	DAYNA_CMD_RECV		0x08		/* same as generic "Read" */
+
+#define	DAYNA_CMD_GET_ADDR	0x09		/* ???: read MAC address ? */
+#define	REQ_LEN_GET_ADDR	0x12
+
+#define	DAYNA_CMD_SET_MULTI	0x0D		/* set multicast address */
+
+#define	DAYNA_CMD_VENDOR1	0x0E		/* ???: initialize signal ? */
+
+#define IS_SEND(generic)	((generic)->opcode == DAYNA_CMD_SEND)
+#define IS_RECV(generic)	((generic)->opcode == DAYNA_CMD_RECV)
+
+struct dse_softc {
+	device_t sc_dev;
+	struct	ethercom sc_ethercom;	/* Ethernet common part */
+	struct scsipi_periph *sc_periph;/* contains our targ, lun, etc. */
+
+	struct callout sc_recv_ch;
+	struct kmutex sc_iflock;
+	struct if_percpuq *sc_ipq;
+	struct workqueue *sc_recv_wq, *sc_send_wq;
+	struct work sc_recv_work, sc_send_work;
+	int sc_recv_work_pending, sc_send_work_pending;
+
+	char *sc_tbuf;
+	char *sc_rbuf;
+	int sc_debug;
+	int sc_flags;
+	int sc_last_timeout;
+	int sc_enabled;
+	int sc_attach_state;
+};
+
+/* bit defs of "sc_flags" */
+#define DSE_NEED_RECV	0x1
+
+static int	dsematch(device_t, cfdata_t, void *);
+static void	dseattach(device_t, device_t, void *);
+static int	dsedetach(device_t, int);
+
+static void	dse_ifstart(struct ifnet *);
+static void	dse_send_worker(struct work *wk, void *cookie);
+
+static void	dsedone(struct scsipi_xfer *, int);
+static int	dse_ioctl(struct ifnet *, u_long, void *);
+static void	dsewatchdog(struct ifnet *);
+
+static void	dse_recv_callout(void *);
+static void	dse_recv_worker(struct work *wk, void *cookie);
+static void	dse_recv(struct dse_softc *);
+static struct mbuf*	dse_get(struct dse_softc *, uint8_t *, int);
+static int	dse_read(struct dse_softc *, uint8_t *, int);
+
+static int	dse_init_adaptor(struct dse_softc *);
+static int	dse_get_addr(struct dse_softc *, uint8_t *);
+static int	dse_set_multi(struct dse_softc *);
+
+static int	dse_reset(struct dse_softc *);
+
+#if 0	/* 07/16/2000 comment-out */
+static int	dse_set_mode(struct dse_softc *, int, int);
+#endif
+static int	dse_init(struct dse_softc *);
+static void	dse_stop(struct dse_softc *);
+
+#if 0
+static __inline uint16_t	ether_cmp(void *, void *);
+#endif
+
+static inline int dse_scsipi_cmd(struct scsipi_periph *periph,
+			struct scsipi_generic *scsipi_cmd,
+			int cmdlen, u_char *data_addr, int datalen,
+			int retries, int timeout, struct buf *bp,
+			int flags);
+
+int	dse_enable(struct dse_softc *);
+void	dse_disable(struct dse_softc *);
+
+
+CFATTACH_DECL_NEW(dse, sizeof(struct dse_softc),
+    dsematch, dseattach, dsedetach, NULL);
+
+extern struct cfdriver dse_cd;
+
+dev_type_open(dseopen);
+dev_type_close(dseclose);
+dev_type_ioctl(dseioctl);
+
+const struct cdevsw dse_cdevsw = {
+	.d_open = dseopen,
+	.d_close = dseclose,
+	.d_read = noread,
+	.d_write = nowrite,
+	.d_ioctl = dseioctl,
+	.d_stop = nostop,
+	.d_tty = notty,
+	.d_poll = nopoll,
+	.d_mmap = nommap,
+	.d_kqfilter = nokqfilter,
+	.d_discard = nodiscard,
+	.d_flag = D_OTHER | D_MPSAFE
+};
+
+const struct scsipi_periphsw dse_switch = {
+
+	NULL,			/* Use default error handler */
+	NULL,		/* have no queue */
+	NULL,			/* have no async handler */
+	dsedone,		/* deal with stats at interrupt time */
+};
+
+struct scsipi_inquiry_pattern dse_patterns[] = {
+	{	T_PROCESSOR,	T_FIXED,
+		"Dayna",		"SCSI/Link",		"" },
+};
+
+
+
+/*====================================================
+  definitions for SCSI commands
+====================================================*/
+
+/*
+ * command templates
+ */
+/* unknown commands */
+/* Vendor #1 */
+static const scsi_dayna_ether_generic	sonic_ether_vendor1 = {
+	{ DAYNA_CMD_VENDOR1, 0x00 },
+	0x00,
+	{ 0x00, 0x00 },
+	0x80
+};
+
+
+
+#if 0
+/*
+ * Compare two Ether/802 addredses for equality, inlined and
+ * unrolled for speed.
+ * Note: use this like memcmp()
+ */
+static __inline uint16_t
+ether_cmp(void *one, void *two)
+{
+	uint16_t*	a;
+	uint16_t*	b;
+	uint16_t diff;
+
+	a = (uint16_t *) one;
+	b = (uint16_t *) two;
+
+	diff = (a[0] - b[0]) | (a[1] - b[1]) | (a[2] - b[2]);
+
+	return (diff);
+}
+
+#define ETHER_CMP	ether_cmp
+#endif
+
+/*
+ * check to match with SCSI inquiry information
+ */
+static int
+dsematch(device_t parent, cfdata_t match, void *aux)
+{
+	struct scsipibus_attach_args *sa = aux;
+	int priority;
+
+	(void)scsipi_inqmatch(&sa->sa_inqbuf,
+	    dse_patterns, sizeof(dse_patterns) / sizeof(dse_patterns[0]),
+	    sizeof(dse_patterns[0]), &priority);
+	return priority;
+}
+
+
+/*
+ * The routine called by the low level scsi routine when it discovers
+ * a device suitable for this driver.
+ */
+static void
+dseattach(device_t parent, device_t self, void *aux)
+{
+	struct dse_softc *sc = device_private(self);
+	struct scsipibus_attach_args *sa = aux;
+	struct scsipi_periph *periph = sa->sa_periph;
+	struct ifnet *ifp = &sc->sc_ethercom.ec_if;
+	uint8_t myaddr[ETHER_ADDR_LEN];
+	char wqname[MAXCOMLEN];
+	int rv;
+
+	sc->sc_dev = self;
+
+	aprint_normal("\n");
+	SC_DEBUG(periph, SCSIPI_DB2, ("dseattach: "));
+
+	sc->sc_attach_state = 0;
+	callout_init(&sc->sc_recv_ch, CALLOUT_MPSAFE);
+	callout_setfunc(&sc->sc_recv_ch, dse_recv_callout, (void *)sc);
+	mutex_init(&sc->sc_iflock, MUTEX_DEFAULT, IPL_SOFTNET);
+
+	/*
+	 * Store information needed to contact our base driver
+	 */
+	sc->sc_periph = periph;
+	periph->periph_dev = sc->sc_dev;
+	periph->periph_switch = &dse_switch;
+#if 0
+	sc_periph->sc_link_dbflags = SCSIPI_DB1;
+#endif
+
+	dse_poll = mstohz(DSE_POLL);
+	dse_poll = dse_poll? dse_poll: 1;
+	dse_poll0 = mstohz(DSE_POLL0);
+	dse_poll0 = dse_poll0? dse_poll0: 1;
+
+	/*
+	 * Initialize and attach send and receive buffers
+	 */
+	sc->sc_tbuf = malloc(ETHERMTU + sizeof(struct ether_header) +
+	    DSE_EXTRAS_TX + 16, M_DEVBUF, M_WAITOK);
+
+	sc->sc_rbuf = malloc(RBUF_LEN + 16, M_DEVBUF, M_WAITOK);
+
+	/* initialize adaptor and obtain MAC address */
+	dse_init_adaptor(sc);
+	sc->sc_attach_state = 1;
+
+	/* Initialize ifnet structure. */
+	strcpy(ifp->if_xname, device_xname(sc->sc_dev));
+	ifp->if_softc = sc;
+	ifp->if_start = dse_ifstart;
+	ifp->if_ioctl = dse_ioctl;
+	ifp->if_watchdog = dsewatchdog;
+	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
+	ifp->if_extflags = IFEF_MPSAFE;
+
+	dse_get_addr(sc, myaddr);
+
+	/* Attach the interface. */
+	if_initialize(ifp);
+
+	snprintf(wqname, sizeof(wqname), "%sRx", device_xname(sc->sc_dev));
+	rv = workqueue_create(&sc->sc_recv_wq, wqname, dse_recv_worker, sc,
+	    PRI_SOFTNET, IPL_NET, WQ_MPSAFE);
+	if (rv != 0) {
+		aprint_error_dev(sc->sc_dev,
+		    "unable to create recv Rx workqueue\n");
+		dsedetach(sc->sc_dev, 0);
+		return; /* Error */
+	}
+	sc->sc_recv_work_pending = false;
+	sc->sc_attach_state = 2;
+
+	snprintf(wqname, sizeof(wqname), "%sTx", device_xname(sc->sc_dev));
+	rv = workqueue_create(&sc->sc_send_wq, wqname, dse_send_worker, ifp,
+	    PRI_SOFTNET, IPL_NET, WQ_MPSAFE);
+	if (rv != 0) {
+		aprint_error_dev(sc->sc_dev,
+		    "unable to create send Tx workqueue\n");
+		dsedetach(sc->sc_dev, 0);
+		return; /* Error */
+	}
+	sc->sc_send_work_pending = false;
+	sc->sc_ipq = if_percpuq_create(&sc->sc_ethercom.ec_if);
+	ether_ifattach(ifp, myaddr);
+	if_register(ifp);
+	sc->sc_attach_state = 4;
+
+	bpf_attach(ifp, DLT_EN10MB, sizeof(struct ether_header));
+}
+
+static int
+dsedetach(device_t self, int flags)
+{
+	struct dse_softc *sc = device_private(self);
+	struct ifnet *ifp = &sc->sc_ethercom.ec_if;
+
+	switch(sc->sc_attach_state) {
+	case 4:
+		dse_stop(sc);
+		mutex_enter(&sc->sc_iflock);
+		ifp->if_flags &= ~IFF_RUNNING;
+		dse_disable(sc);
+		ether_ifdetach(ifp);
+		if_detach(ifp);
+		mutex_exit(&sc->sc_iflock);
+		if_percpuq_destroy(sc->sc_ipq);
+		/*FALLTHROUGH*/
+	case 3:
+		workqueue_destroy(sc->sc_send_wq);
+		/*FALLTHROUGH*/
+	case 2:
+		workqueue_destroy(sc->sc_recv_wq);
+		/*FALLTHROUGH*/
+	case 1:
+		free(sc->sc_rbuf, M_DEVBUF);
+		free(sc->sc_tbuf, M_DEVBUF);
+		callout_destroy(&sc->sc_recv_ch);
+		mutex_destroy(&sc->sc_iflock);
+		break;
+	default:
+		aprint_error_dev(sc->sc_dev, "detach failed (state %d)\n",
+		    sc->sc_attach_state);
+		return 1;
+		break;
+	}
+
+	return 0;
+}
+
+
+/*
+ * submit SCSI command
+ */
+static __inline int
+dse_scsipi_cmd(struct scsipi_periph *periph, struct scsipi_generic *cmd,
+    int cmdlen, u_char *data_addr, int datalen, int retries, int timeout,
+    struct buf *bp, int flags)
+{
+	int error = 0;
+
+	error = scsipi_command(periph, cmd, cmdlen, data_addr,
+   		 datalen, retries, timeout, bp, flags);
+
+	return error;
+}
+
+
+/*
+ * Start routine for calling from network sub system
+ */
+static void
+dse_ifstart(struct ifnet *ifp)
+{
+	struct dse_softc *sc = ifp->if_softc;
+
+	mutex_enter(&sc->sc_iflock);
+	if (!sc->sc_send_work_pending)  {
+		sc->sc_send_work_pending = true;
+		workqueue_enqueue(sc->sc_send_wq, &sc->sc_send_work, NULL);
+	}
+	mutex_exit(&sc->sc_iflock);
+	if (sc->sc_flags & DSE_NEED_RECV) {
+		sc->sc_flags &= ~DSE_NEED_RECV;
+	}
+}
+
+/*
+ * Invoke the transmit workqueue and transmission on the interface.
+ */
+static void
+dse_send_worker(struct work *wk, void *cookie)
+{
+	struct ifnet *ifp = cookie;
+	struct dse_softc *sc = ifp->if_softc;
+	scsi_dayna_ether_generic cmd_send;
+	struct mbuf *m, *m0;
+	int len, error;
+	u_char *cp;
+
+	mutex_enter(&sc->sc_iflock);
+	sc->sc_send_work_pending = false;
+	mutex_exit(&sc->sc_iflock);
+
+	KASSERT(if_is_mpsafe(ifp));
+
+	/* Don't transmit if interface is busy or not running */
+	if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
+		return;
+
+	while (1) {
+		IFQ_DEQUEUE(&ifp->if_snd, m0);
+		if (m0 == NULL)
+			break;
+		/* If BPF is listening on this interface, let it see the
+		 * packet before we commit it to the wire.
+		 */
+		bpf_mtap(ifp, m0, BPF_D_OUT);
+
+		/* We need to use m->m_pkthdr.len, so require the header */
+		if ((m0->m_flags & M_PKTHDR) == 0)
+			panic("ctscstart: no header mbuf");
+		len = m0->m_pkthdr.len;
+
+		/* Mark the interface busy. */
+		ifp->if_flags |= IFF_OACTIVE;
+
+		/* Chain; copy into linear buffer allocated at attach time. */
+		cp = sc->sc_tbuf;
+		for (m = m0; m != NULL; ) {
+			memcpy(cp, mtod(m, u_char *), m->m_len);
+			cp += m->m_len;
+			m = m0 = m_free(m);
+		}
+		if (len < DSE_MINSIZE) {
+#ifdef SEDEBUG
+			if (sc->sc_debug)
+				aprnt_error_dev(sc->sc_dev,
+				    "packet size %d (%zu) < %d\n", len,
+				    cp - (u_char *)sc->sc_tbuf, SEMINSIZE);
+#endif
+			memset(cp, 0, DSE_MINSIZE - len);
+			len = DSE_MINSIZE;
+		}
+
+		/* Fill out SCSI command. */
+		memset(&cmd_send, 0, sizeof(cmd_send));
+		cmd_send.opcode[0] = DAYNA_CMD_SEND;
+		_lto2b(len, &(cmd_send.length[0]));
+		cmd_send.byte6 = 0x00;
+
+		/* Send command to device. */
+		error = dse_scsipi_cmd(sc->sc_periph,
+		    (void *)&cmd_send, sizeof(cmd_send),
+		    sc->sc_tbuf, len, DSE_RETRIES,
+		    DSE_TIMEOUT, NULL, XS_CTL_NOSLEEP | XS_CTL_POLL |
+		    XS_CTL_DATA_OUT);
+		if (error) {
+			aprint_error_dev(sc->sc_dev,
+			    "not queued, error %d\n", error);
+			if_statinc(ifp, if_oerrors);
+			ifp->if_flags &= ~IFF_OACTIVE;
+		} else
+			if_statinc(ifp, if_opackets);
+	}
+}
+
+
+/*
+ * Called from the scsibus layer via our scsi device switch.
+ */
+static void
+dsedone(struct scsipi_xfer *xs, int error)
+{
+	struct dse_softc *sc = device_private(xs->xs_periph->periph_dev);
+	struct scsipi_generic *cmd = xs->cmd;
+	struct ifnet *ifp = &sc->sc_ethercom.ec_if;
+
+	if (IS_SEND(cmd)) {
+		ifp->if_flags &= ~IFF_OACTIVE;
+	} else if (IS_RECV(cmd)) {
+		/* RECV complete */
+		/* pass data up. reschedule a recv */
+		/* scsipi_free_xs will call start. Harmless. */
+
+		if (error) {
+			/* Reschedule after a delay */
+			callout_schedule(&sc->sc_recv_ch, dse_poll);
+		} else {
+			int n, ntimeo;
+			n = dse_read(sc, xs->data, xs->datalen - xs->resid);
+			if (n > dse_max_received)
+				dse_max_received = n;
+			if (n == 0)
+				ntimeo = dse_poll;
+			else if (n >= RDATA_MAX)
+				ntimeo = dse_poll0;
+			else {
+				ntimeo = sc->sc_last_timeout;
+				ntimeo = (ntimeo * RDATA_GOAL)/n;
+				ntimeo = (ntimeo < dse_poll0?
+					  dse_poll0: ntimeo);
+				ntimeo = (ntimeo > dse_poll?
+					  dse_poll: ntimeo);
+			}
+			sc->sc_last_timeout = ntimeo;
+			callout_schedule(&sc->sc_recv_ch, ntimeo);
+		}
+	}
+}
+
+
+/*
+ * Setup a receive command by queuing the work.
+ * Usually called from a callout, but also from se_init().
+ */
+static void
+dse_recv_callout(void *v)
+{
+	/* do a recv command */
+	struct dse_softc *sc = (struct dse_softc *) v;
+
+	if (sc->sc_enabled == 0)
+		return;
+
+	mutex_enter(&sc->sc_iflock);
+	if (sc->sc_recv_work_pending == true) {
+		callout_schedule(&sc->sc_recv_ch, dse_poll);
+		mutex_exit(&sc->sc_iflock);
+		return;
+	}
+
+	sc->sc_recv_work_pending = true;
+	workqueue_enqueue(sc->sc_recv_wq, &sc->sc_recv_work, NULL);
+	mutex_exit(&sc->sc_iflock);
+}
+
+/*
+ * Invoke the receive workqueue
+ */
+static void
+dse_recv_worker(struct work *wk, void *cookie)
+{
+	struct dse_softc *sc = (struct dse_softc *) cookie;
+
+	dse_recv(sc);
+	mutex_enter(&sc->sc_iflock);
+	sc->sc_recv_work_pending = false;
+	mutex_exit(&sc->sc_iflock);
+
+}
+
+/*
+ * Do the actual work of receiving data.
+ */
+static void
+dse_recv(struct dse_softc *sc)
+{
+	scsi_dayna_ether_generic cmd_recv;
+	int error, len;
+
+	/* do a recv command */
+	/* fill out command buffer */
+	memset(&cmd_recv, 0, sizeof(cmd_recv));
+	cmd_recv.opcode[0] = DAYNA_CMD_RECV;
+	len = MAX_BYTES_RX + DSE_EXTRAS_RX;
+	_lto2b(len, &(cmd_recv.length[0]));
+	cmd_recv.byte6 = 0xC0;
+
+	error = dse_scsipi_cmd(sc->sc_periph,
+	    (void *)&cmd_recv, sizeof(cmd_recv),
+	    sc->sc_rbuf, RBUF_LEN, DSE_RETRIES, DSE_TIMEOUT, NULL,
+	    XS_CTL_NOSLEEP | XS_CTL_POLL | XS_CTL_DATA_IN);
+	if (error)
+		callout_schedule(&sc->sc_recv_ch, dse_poll);
+}
+
+
+/*
+ * We copy the data into mbufs.  When full cluster sized units are present
+ * we copy into clusters.
+ */
+static struct mbuf *
+dse_get(struct dse_softc *sc, uint8_t *data, int totlen)
+{
+	struct ifnet *ifp = &sc->sc_ethercom.ec_if;
+	struct mbuf *m, *m0, *newm;
+	int len;
+
+	MGETHDR(m0, M_DONTWAIT, MT_DATA);
+	if (m0 == NULL)
+		return NULL;
+
+	m_set_rcvif(m0, ifp);
+	m0->m_pkthdr.len = totlen;
+	len	= MHLEN;
+	m = m0;
+
+	while (totlen > 0) {
+		if (totlen >= MINCLSIZE) {
+			MCLGET(m, M_DONTWAIT);
+			if((m->m_flags & M_EXT) == 0)
+				goto bad;
+
+			len = MCLBYTES;
+		}
+
+		if (m == m0) {
+			char *newdata = (char *)
+			    ALIGN(m->m_data + sizeof(struct ether_header)) -
+			    sizeof(struct ether_header);
+			len -= newdata - m->m_data;
+			m->m_data = newdata;
+		}
+
+		m->m_len = len = uimin(totlen, len);
+		memcpy(mtod(m, void *), data, len);
+		data += len;
+
+		totlen -= len;
+		if (totlen > 0) {
+			MGET(newm, M_DONTWAIT, MT_DATA);
+			if (newm == NULL)
+				goto bad;
+
+			len = MLEN;
+			m = m->m_next = newm;
+		}
+	}
+
+	return m0;
+
+bad:
+	m_freem(m0);
+	return NULL ;
+}
+
+
+#ifdef MAC68K_DEBUG
+static int
+peek_packet(uint8_t*  buf)
+{
+	struct ether_header *eh;
+	uint16_t type;
+	int len;
+
+	eh = (struct ether_header*)buf;
+	type = _2btol((uint8_t*)&(eh->ether_type));
+
+	len = sizeof(struct ether_header);
+
+	if (type <= ETHERMTU) {
+		/* for 802.3 */
+		len += type;
+	} else{
+		/* for Ethernet II (DIX) */
+		switch (type) {
+		  case ETHERTYPE_ARP:
+			len += 28;
+			break;
+		  case ETHERTYPE_IP:
+			len += _2btol(buf + sizeof(struct ether_header) + 2);
+			break;
+		  default:
+			len = 0;
+			goto l_end;
+			break;
+		}
+	}
+	if (len < DSE_MINSIZE) {
+		len = DSE_MINSIZE;
+	}
+	len += ETHER_CRC_LEN;
+
+  l_end:;
+	return len;
+}
+#endif
+
+
+/*
+ * Pass packets to higher levels.
+ */
+static int
+dse_read(struct dse_softc *sc, uint8_t *data, int datalen)
+{
+	struct mbuf *m;
+	struct ifnet *ifp = &sc->sc_ethercom.ec_if;
+	int	len;
+	int	n;
+#ifdef MAC68K_DEBUG
+	int	peek_flag = 1;
+#endif
+
+	mutex_enter(&sc->sc_iflock);
+	n = 0;
+	while (datalen >= DSE_HEADER_RX) {
+		/*
+		 * fetch bytes of stream.
+		 * here length = (ether frame length) + (FCS's 4 bytes)
+		 */
+		/* fetch frame length */
+		len = _2btol(data);
+
+		/* skip header part */
+		data	+= DSE_HEADER_RX;
+		datalen -= DSE_HEADER_RX;
+
+#if 0	/* 03/10/2001  only for debug */
+		{
+			printf("DATALEN %d len %d\n", datalen, len);
+			int	j;
+			printf("\ndump[%d]: ",n);
+			for ( j = 0 ; j < datalen ; j++ ) {
+				printf("%02X ",data[j-DSE_HEADER_RX]);
+			}
+		}
+#endif
+#ifdef MAC68K_DEBUG
+		if (peek_flag) {
+			peek_flag = 0;
+			len = peek_packet(data);
+		}
+#endif
+		if (len <=0)
+			break;
+
+#ifdef DSE_DEBUG
+		aprint_error_dev("dse_read: datalen = %d, packetlen = %d, "
+		    "proto = 0x%04x\n", datalen, len,
+		    ntohs(((struct ether_header *)data)->ether_type));
+#endif
+		if ((len < (DSE_MINSIZE + ETHER_CRC_LEN)) ||
+		     (MAX_BYTES_RX < len)) {
+#ifdef DSE_DEBUG
+			aprint_error_dev(sc->sc_dev, "invalid packet size "
+			    "%d; dropping\n", len);
+#endif
+			if_statinc(ifp, if_ierrors);
+printf("LEN %d\n",len);
+			break;
+		}
+
+		/* Don't need crc. Must keep ether header for BPF */
+		m = dse_get(sc, data, len - ETHER_CRC_LEN);
+		if (m == NULL) {
+#ifdef DSE_DEBUG
+			if (sc->sc_debug)
+				aprint_error_dev("dse_read: dse_get returned "
+				    "null\n");
+#endif
+printf("M null\n");
+			if_statinc(ifp, if_ierrors);
+			goto next_packet;
+		}
+		if_statinc(ifp, if_ipackets);
+
+		/*
+		 * Check if there's a BPF listener on this interface.
+		 * If so, hand off the raw packet to BPF.
+		 */
+		if (ifp->if_bpf)
+			bpf_mtap(ifp, m, BPF_D_OUT);
+
+		/* Pass the packet up. */
+		if_percpuq_enqueue(sc->sc_ipq, m);
+
+  next_packet:
+		data	+= len;
+		datalen	-= len;
+		n++;
+	}
+	mutex_exit(&sc->sc_iflock);
+
+	return n;
+}
+
+
+static void
+dsewatchdog(struct ifnet *ifp)
+{
+	struct dse_softc *sc = ifp->if_softc;
+
+	log(LOG_ERR, "%s: device timeout\n", device_xname(sc->sc_dev));
+	if_statinc(ifp, if_oerrors);
+
+	dse_reset(sc);
+}
+
+
+static int
+dse_reset(struct dse_softc *sc)
+{
+	int error;
+#if 0
+	/* Maybe we don't *really* want to reset the entire bus
+	 * because the ctron isn't working. We would like to send a
+	 * "BUS DEVICE RESET" message, but don't think the ctron
+	 * understands it.
+	 */
+	error = dse_scsipi_cmd(sc->sc_periph, 0, 0, 0, 0, DSE_RETRIES, 2000,
+	    NULL, XS_CTL_RESET);
+#endif
+	error = dse_init(sc);
+	return error;
+}
+
+
+static int
+dse_init_adaptor(struct dse_softc *sc)
+{
+	scsi_dayna_ether_generic cmd_vend1;
+	u_char tmpbuf[sizeof(cmd_vend1)];
+	int error;
+
+#if 0	/* 07/21/2001 for test */
+	/* Maybe we don't *really* want to reset the entire bus
+	 * because the ctron isn't working. We would like to send a
+	 * "BUS DEVICE RESET" message, but don't think the ctron
+	 * understands it.
+	 */
+	error = dse_scsipi_cmd(sc->sc_periph, 0, 0, 0, 0, DSE_RETRIES,
+	    2000, NULL, XS_CTL_RESET);
+#endif
+
+	cmd_vend1 = sonic_ether_vendor1;
+
+	error = dse_scsipi_cmd(sc->sc_periph,
+	    (struct scsipi_generic *)&cmd_vend1, sizeof(cmd_vend1),
+		&(tmpbuf[0]), sizeof(tmpbuf),
+	    DSE_RETRIES, DSE_TIMEOUT, NULL, XS_CTL_POLL | XS_CTL_DATA_IN);
+
+	if (error)
+		goto l_end;
+
+	/* wait 500 msec */
+	kpause("dsesleep", false, hz / 2, NULL);
+
+l_end:
+	return error;
+}
+
+
+static int
+dse_get_addr(struct dse_softc *sc, uint8_t *myaddr)
+{
+	scsi_dayna_ether_generic cmd_get_addr;
+	u_char tmpbuf[REQ_LEN_GET_ADDR];
+	int error;
+
+	memset(&cmd_get_addr, 0, sizeof(cmd_get_addr));
+	cmd_get_addr.opcode[0] = DAYNA_CMD_GET_ADDR;
+	_lto2b(REQ_LEN_GET_ADDR, cmd_get_addr.length);
+
+	error = dse_scsipi_cmd(sc->sc_periph,
+	    (struct scsipi_generic *)&cmd_get_addr, sizeof(cmd_get_addr),
+	    tmpbuf, sizeof(tmpbuf),
+	    DSE_RETRIES, DSE_TIMEOUT, NULL, XS_CTL_POLL | XS_CTL_DATA_IN);
+
+	if (error == 0) {
+		memcpy(myaddr, &(tmpbuf[0]), ETHER_ADDR_LEN);
+
+		aprint_error_dev(sc->sc_dev, "ethernet address %s\n",
+			   ether_sprintf(myaddr));
+	}
+
+	return error;
+}
+
+
+#if 0	/* 07/16/2000 comment-out */
+static int
+dse_set_mode(struct dse_softc *sc, int len, int mode)
+
+	return 0;
+}
+#endif
+
+
+static int
+dse_init(struct dse_softc *sc)
+{
+	struct ifnet *ifp = &sc->sc_ethercom.ec_if;
+	int error = 0;
+
+	if ((ifp->if_flags & (IFF_RUNNING | IFF_UP)) == IFF_UP) {
+		ifp->if_flags |= IFF_RUNNING;
+		mutex_enter(&sc->sc_iflock);
+		if (!sc->sc_recv_work_pending)  {
+			sc->sc_recv_work_pending = true;
+			workqueue_enqueue(sc->sc_recv_wq, &sc->sc_recv_work,
+			    NULL);
+		}
+		mutex_exit(&sc->sc_iflock);
+		ifp->if_flags &= ~IFF_OACTIVE;
+		mutex_enter(&sc->sc_iflock);
+		if (!sc->sc_send_work_pending)  {
+			sc->sc_send_work_pending = true;
+			workqueue_enqueue(sc->sc_send_wq, &sc->sc_send_work,
+			    NULL);
+		}
+		mutex_exit(&sc->sc_iflock);
+	}
+	return error;
+}
+
+
+static uint8_t	BROADCAST_ADDR[ETHER_ADDR_LEN] =
+			{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
+
+
+static int
+dse_set_multi(struct dse_softc *sc)
+{
+	scsi_dayna_ether_generic cmd_set_multi;
+	struct ether_multistep step;
+	struct ether_multi *enm;
+	u_char *cp, *mybuf;
+	int error, len;
+
+	error = 0;
+
+#ifdef DSE_DEBUG
+	aprint_error_dev(sc->sc_dev, "dse_set_multi\n");
+#endif
+
+	mybuf = malloc(ETHER_ADDR_LEN * DSE_MCAST_MAX, M_DEVBUF, M_NOWAIT);
+	if (mybuf == NULL) {
+		error = EIO;
+		goto l_end;
+	}
+
+	/*
+	 * copy all entries to transfer buffer
+	 */
+	cp = mybuf;
+	len = 0;
+	ETHER_FIRST_MULTI(step, &(sc->sc_ethercom), enm);
+	while ((len < (DSE_MCAST_MAX - 1)) && (enm != NULL)) {
+		/* ### refer low side entry */
+		memcpy(cp, enm->enm_addrlo, ETHER_ADDR_LEN);
+
+		cp += ETHER_ADDR_LEN;
+		len++;
+		ETHER_NEXT_MULTI(step, enm);
+	}
+
+	/* add broadcast address as default */
+	memcpy(cp, BROADCAST_ADDR, ETHER_ADDR_LEN);
+	len++;
+
+	len *= ETHER_ADDR_LEN;
+
+	memset(&cmd_set_multi, 0, sizeof(cmd_set_multi));
+	cmd_set_multi.opcode[0] = DAYNA_CMD_SET_MULTI;
+	_lto2b(len, cmd_set_multi.length);
+
+	error = dse_scsipi_cmd(sc->sc_periph,
+	    (struct scsipi_generic*)&cmd_set_multi, sizeof(cmd_set_multi),
+	    mybuf, len, DSE_RETRIES, DSE_TIMEOUT, NULL, XS_CTL_POLL | XS_CTL_DATA_OUT);
+
+	free(mybuf, M_DEVBUF);
+
+l_end:
+	return error;
+}
+
+
+static void
+dse_stop(struct dse_softc *sc)
+{
+	/* Don't schedule any reads */
+	callout_stop(&sc->sc_recv_ch);
+
+	/* Wait for the workqueues to finish */
+	mutex_enter(&sc->sc_iflock);
+	workqueue_wait(sc->sc_recv_wq, &sc->sc_recv_work);
+	workqueue_wait(sc->sc_send_wq, &sc->sc_send_work);
+	mutex_exit(&sc->sc_iflock);
+
+	/* Abort any scsi cmds in progress */
+	mutex_enter(chan_mtx(sc->sc_periph->periph_channel));
+	scsipi_kill_pending(sc->sc_periph);
+	mutex_exit(chan_mtx(sc->sc_periph->periph_channel));
+}
+
+
+/*
+ * Process an ioctl request.
+ */
+static int
+dse_ioctl(struct ifnet *ifp, u_long cmd, void *data)
+{
+	struct dse_softc *sc;
+	struct ifaddr *ifa;
+	struct ifreq *ifr;
+	struct sockaddr *sa;
+	int error;
+
+	error = 0;
+	sc = ifp->if_softc;
+	ifa = (struct ifaddr *)data;
+	ifr = (struct ifreq *)data;
+
+	switch (cmd) {
+	case SIOCINITIFADDR:
+		mutex_enter(&sc->sc_iflock);
+		if ((error = dse_enable(sc)) != 0)
+			break;
+		ifp->if_flags |= IFF_UP;
+		mutex_exit(&sc->sc_iflock);
+
+#if 0
+		if ((error = dse_set_media(sc, CMEDIA_AUTOSENSE)) != 0)
+			break;
+#endif
+
+		switch (ifa->ifa_addr->sa_family) {
+#ifdef INET
+		case AF_INET:
+	//		sc->protos |= (PROTO_IP | PROTO_ARP | PROTO_REVARP);
+			if ((error = dse_init(sc)) != 0)
+				break;
+			arp_ifinit(ifp, ifa);
+			break;
+#endif
+#ifdef NETATALK
+		case AF_APPLETALK:
+	//		sc->protos |= (PROTO_AT | PROTO_AARP);
+			if ((error = dse_init(sc)) != 0)
+				break;
+			break;
+#endif
+		default:
+			error = dse_init(sc);
+			break;
+		}
+		break;
+
+
+	case SIOCSIFADDR:
+		mutex_enter(&sc->sc_iflock);
+		error = dse_enable(sc);
+		mutex_exit(&sc->sc_iflock);
+		if (error != 0)
+			break;
+		ifp->if_flags |= IFF_UP;
+
+		switch (ifa->ifa_addr->sa_family) {
+#ifdef INET
+		case AF_INET:
+			if ((error = dse_init(sc)) != 0)
+				break;
+			arp_ifinit(ifp, ifa);
+			break;
+#endif
+#ifdef NETATALK
+		case AF_APPLETALK:
+			if ((error = dse_init(sc)) != 0)
+				break;
+			break;
+#endif
+		default:
+			error = dse_init(sc);
+			break;
+		}
+		break;
+
+	case SIOCSIFFLAGS:
+		if ((error = ifioctl_common(ifp, cmd, data)) != 0)
+			break;
+		/* XXX re-use ether_ioctl() */
+		switch (ifp->if_flags & (IFF_UP | IFF_RUNNING)) {
+		case IFF_RUNNING:
+			/*
+			 * If interface is marked down and it is running, then
+			 * stop it.
+			 */
+			dse_stop(sc);
+			mutex_enter(&sc->sc_iflock);
+			ifp->if_flags &= ~IFF_RUNNING;
+			dse_disable(sc);
+			mutex_exit(&sc->sc_iflock);
+			break;
+		case IFF_UP:
+			/*
+			 * If interface is marked up and it is stopped, then
+			 * start it.
+			 */
+			mutex_enter(&sc->sc_iflock);
+			error = dse_enable(sc);
+			mutex_exit(&sc->sc_iflock);
+			if (error)
+				break;
+			error = dse_init(sc);
+			break;
+		default:
+			/*
+			 * Reset the interface to pick up changes in any other
+			 * flags that affect hardware registers.
+			 */
+			mutex_enter(&sc->sc_iflock);
+			if (sc->sc_enabled)
+				error = dse_init(sc);
+			mutex_exit(&sc->sc_iflock);
+			break;
+		}
+#ifdef SEDEBUG
+		if (ifp->if_flags & IFF_DEBUG)
+			sc->sc_debug = 1;
+		else
+			sc->sc_debug = 0;
+#endif
+		break;
+
+	case SIOCADDMULTI:
+		if (sc->sc_enabled == 0) {
+			error = EIO;
+			break;
+		}
+		mutex_enter(&sc->sc_iflock);
+		sa = sockaddr_dup(ifreq_getaddr(cmd, ifr), M_WAITOK);
+		mutex_exit(&sc->sc_iflock);
+		if (ether_addmulti(sa, &sc->sc_ethercom) == ENETRESET) {
+			error = dse_set_multi(sc);
+#ifdef DSE_DEBUG
+			aprint_error_dev(sc->sc_dev, "add multi: %s\n",
+				   ether_sprintf(ifr->ifr_addr.sa_data));
+#endif
+		} else
+			error = 0;
+
+		mutex_enter(&sc->sc_iflock);
+		sockaddr_free(sa);
+		mutex_exit(&sc->sc_iflock);
+
+		break;
+
+	case SIOCDELMULTI:
+		if (sc->sc_enabled == 0) {
+			error = EIO;
+			break;
+		}
+		mutex_enter(&sc->sc_iflock);
+		sa = sockaddr_dup(ifreq_getaddr(cmd, ifr), M_WAITOK);
+		mutex_exit(&sc->sc_iflock);
+		if (ether_delmulti(sa, &sc->sc_ethercom) == ENETRESET) {
+			error = dse_set_multi(sc);
+#ifdef DSE_DEBUG
+			aprint_error_dev(sc->sc_dev, "delete multi: %s\n",
+			    ether_sprintf(ifr->ifr_addr.sa_data));
+#endif
+		} else
+			error = 0;
+
+		mutex_enter(&sc->sc_iflock);
+		sockaddr_free(sa);
+		mutex_exit(&sc->sc_iflock);
+
+		break;
+
+	default:
+		error = ether_ioctl(ifp, cmd, data);
+		break;
+	}
+
+
+	return error;
+}
+
+
+/*
+ * Enable the network interface.
+ */
+int
+dse_enable(struct dse_softc *sc)
+{
+	struct scsipi_periph *periph = sc->sc_periph;
+	struct scsipi_adapter *adapt = periph->periph_channel->chan_adapter;
+	int error = 0;
+
+	if (sc->sc_enabled == 0) {
+		if ((error = scsipi_adapter_addref(adapt)) == 0)
+			sc->sc_enabled = 1;
+		else
+			aprint_error_dev(sc->sc_dev, "device enable failed\n");
+	}
+
+	return error;
+}
+
+
+/*
+ * Disable the network interface.
+ */
+void
+dse_disable(struct dse_softc *sc)
+{
+	struct scsipi_periph *periph = sc->sc_periph;
+	struct scsipi_adapter *adapt = periph->periph_channel->chan_adapter;
+	if (sc->sc_enabled != 0) {
+		scsipi_adapter_delref(adapt);
+		sc->sc_enabled = 0;
+	}
+}
+
+
+#define	DSEUNIT(z)	(minor(z))
+
+/*
+ * open the device.
+ */
+int
+dseopen(dev_t dev, int flag, int fmt, struct lwp *l)
+{
+	int unit, error;
+	struct dse_softc *sc;
+	struct scsipi_periph *periph;
+	struct scsipi_adapter *adapt;
+
+	unit = DSEUNIT(dev);
+	sc = device_lookup_private(&dse_cd, unit);
+	if (sc == NULL)
+		return ENXIO;
+
+	periph = sc->sc_periph;
+	adapt = periph->periph_channel->chan_adapter;
+
+	if ((error = scsipi_adapter_addref(adapt)) != 0)
+		return error;
+
+	SC_DEBUG(periph, SCSIPI_DB1,
+	    ("scopen: dev=0x%"PRIx64" (unit %d (of %d))\n", dev, unit,
+	    dse_cd.cd_ndevs));
+
+	periph->periph_flags |= PERIPH_OPEN;
+
+	SC_DEBUG(periph, SCSIPI_DB3, ("open complete\n"));
+
+	return 0;
+}
+
+
+/*
+ * close the device.. only called if we are the LAST
+ * occurence of an open device
+ */
+int
+dseclose(dev_t dev, int flag, int fmt, struct lwp *l)
+{
+	struct dse_softc *sc = device_lookup_private(&dse_cd, DSEUNIT(dev));
+	struct scsipi_periph *periph = sc->sc_periph;
+	struct scsipi_adapter *adapt = periph->periph_channel->chan_adapter;
+
+	SC_DEBUG(sc->sc_periph, SCSIPI_DB1, ("closing\n"));
+
+	scsipi_wait_drain(periph);
+
+	scsipi_adapter_delref(adapt);
+	periph->periph_flags &= ~PERIPH_OPEN;
+
+	return 0;
+}
+
+
+/*
+ * Perform special action on behalf of the user
+ * Only does generic scsi ioctls.
+ */
+int
+dseioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l)
+{
+	struct dse_softc *sc = device_lookup_private(&dse_cd, DSEUNIT(dev));
+
+	return (scsipi_do_ioctl(sc->sc_periph, dev, cmd, addr, flag, l));
+}
+

Reply via email to