2000-11-15 04:02:11 +03:00
|
|
|
/* $NetBSD: if_se.c,v 1.32 2000/11/15 01:02:19 thorpej Exp $ */
|
1997-03-18 04:31:15 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1997 Ian W. Dall <ian.dall@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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Driver for Cabletron EA41x scsi ethernet adaptor.
|
|
|
|
*
|
1997-10-14 15:18:18 +04:00
|
|
|
* Written by Ian Dall <ian.dall@dsto.defence.gov.au> Feb 3, 1997
|
|
|
|
*
|
|
|
|
* Acknowledgement: Thanks are due to Philip L. Budne <budd@cs.bu.edu>
|
2000-03-14 02:52:25 +03:00
|
|
|
* who reverse engineered the EA41x. In developing this code,
|
1997-10-14 15:18:18 +04:00
|
|
|
* Phil's userland daemon "etherd", was refered to extensively in lieu
|
|
|
|
* of accurate documentation for the device.
|
|
|
|
*
|
1997-03-18 04:31:15 +03:00
|
|
|
* This is a weird device! It doesn't conform to the scsi spec in much
|
1998-09-26 01:50:38 +04:00
|
|
|
* at all. About the only standard command supported is inquiry. Most
|
1997-03-18 04:31:15 +03:00
|
|
|
* commands are 6 bytes long, but the recv data is only 1 byte. Data
|
|
|
|
* must be received by periodically polling the device with the recv
|
|
|
|
* command.
|
|
|
|
*
|
|
|
|
* This driver is also a bit unusual. It must look like a network
|
|
|
|
* interface and it must also appear to be a scsi device to the scsi
|
|
|
|
* system. Hence there are cases where there are two entry points. eg
|
|
|
|
* sestart is to be called from the scsi subsytem and se_ifstart from
|
|
|
|
* the network interface subsystem. In addition, to facilitate scsi
|
|
|
|
* commands issued by userland programs, there are open, close and
|
|
|
|
* ioctl entry points. This allows a user program to, for example,
|
|
|
|
* display the ea41x stats and download new code into the adaptor ---
|
|
|
|
* functions which can't be performed through the ifconfig interface.
|
1997-04-04 23:02:43 +04:00
|
|
|
* Normal operation does not require any special userland program.
|
1997-03-18 04:31:15 +03:00
|
|
|
*/
|
|
|
|
|
1998-07-05 04:51:04 +04:00
|
|
|
#include "opt_inet.h"
|
|
|
|
#include "opt_atalk.h"
|
1998-07-05 06:12:22 +04:00
|
|
|
#include "opt_ccitt.h"
|
1998-07-05 07:14:41 +04:00
|
|
|
#include "opt_llc.h"
|
1998-07-05 10:49:00 +04:00
|
|
|
#include "opt_ns.h"
|
1997-03-18 04:31:15 +03:00
|
|
|
#include "bpfilter.h"
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
2000-03-23 10:01:25 +03:00
|
|
|
#include <sys/callout.h>
|
1997-03-18 04:31:15 +03:00
|
|
|
#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>
|
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
#include <dev/scsipi/scsipi_all.h>
|
|
|
|
#include <dev/scsipi/scsi_ctron_ether.h>
|
|
|
|
#include <dev/scsipi/scsiconf.h>
|
1997-03-18 04:31:15 +03:00
|
|
|
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_dl.h>
|
|
|
|
#include <net/if_ether.h>
|
1997-04-04 23:02:43 +04:00
|
|
|
#include <net/if_media.h>
|
1997-03-18 04:31:15 +03:00
|
|
|
|
|
|
|
#ifdef INET
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/if_inarp.h>
|
|
|
|
#endif
|
|
|
|
|
1997-03-18 07:45:04 +03:00
|
|
|
#ifdef NS
|
|
|
|
#include <netns/ns.h>
|
|
|
|
#include <netns/ns_if.h>
|
|
|
|
#endif
|
|
|
|
|
1997-04-04 23:02:43 +04:00
|
|
|
#ifdef NETATALK
|
|
|
|
#include <netatalk/at.h>
|
|
|
|
#endif
|
|
|
|
|
1997-03-18 07:45:04 +03:00
|
|
|
#if defined(CCITT) && defined(LLC)
|
|
|
|
#include <sys/socketvar.h>
|
|
|
|
#include <netccitt/x25.h>
|
|
|
|
#include <netccitt/pk.h>
|
|
|
|
#include <netccitt/pk_var.h>
|
|
|
|
#include <netccitt/pk_extern.h>
|
|
|
|
#endif
|
|
|
|
|
1997-03-18 04:31:15 +03:00
|
|
|
#if NBPFILTER > 0
|
|
|
|
#include <net/bpf.h>
|
|
|
|
#include <net/bpfdesc.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SETIMEOUT 1000
|
|
|
|
#define SEOUTSTANDING 4
|
|
|
|
#define SERETRIES 4
|
|
|
|
#define SE_PREFIX 4
|
|
|
|
#define ETHER_CRC 4
|
|
|
|
#define SEMINSIZE 60
|
|
|
|
|
|
|
|
/* Make this big enough for an ETHERMTU packet in promiscuous mode. */
|
|
|
|
#define MAX_SNAP (ETHERMTU + sizeof(struct ether_header) + \
|
|
|
|
SE_PREFIX + ETHER_CRC)
|
|
|
|
|
1997-10-14 15:18:18 +04:00
|
|
|
/* 10 full length packets appears to be the max ever returned. 16k is OK */
|
|
|
|
#define RBUF_LEN (16 * 1024)
|
|
|
|
|
|
|
|
/* Tuning parameters:
|
|
|
|
* The EA41x only returns a maximum of 10 packets (regardless of size).
|
|
|
|
* We will attempt to adapt to polling fast enough to get RDATA_GOAL packets
|
|
|
|
* per read
|
|
|
|
*/
|
|
|
|
#define RDATA_MAX 10
|
|
|
|
#define RDATA_GOAL 8
|
|
|
|
|
|
|
|
/* se_poll and se_poll0 are the normal polling rate and the minimum
|
|
|
|
* polling rate respectively. se_poll0 should be chosen so that at
|
|
|
|
* maximum ethernet speed, we will read nearly RDATA_MAX packets. se_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. se_poll0 is enforced to be always at least 1
|
1997-04-04 23:02:43 +04:00
|
|
|
*/
|
1997-03-18 04:31:15 +03:00
|
|
|
#define SE_POLL 40 /* default in milliseconds */
|
1997-10-14 15:18:18 +04:00
|
|
|
#define SE_POLL0 10 /* default in milliseconds */
|
|
|
|
int se_poll = 0; /* Delay in ticks set at attach time */
|
1997-03-18 04:31:15 +03:00
|
|
|
int se_poll0 = 0;
|
1997-10-14 15:18:18 +04:00
|
|
|
int se_max_received = 0; /* Instrumentation */
|
1997-03-18 04:31:15 +03:00
|
|
|
|
|
|
|
#define PROTOCMD(p, d) \
|
1997-03-24 03:04:53 +03:00
|
|
|
((d) = (p))
|
1997-03-18 04:31:15 +03:00
|
|
|
|
|
|
|
#define PROTOCMD_DECL(name, val) \
|
|
|
|
static const struct scsi_ctron_ether_generic name = val
|
|
|
|
|
1997-03-24 03:04:53 +03:00
|
|
|
#define PROTOCMD_DECL_SPECIAL(name, val) \
|
|
|
|
static const struct __CONCAT(scsi_,name) name = val
|
|
|
|
|
|
|
|
/* Command initializers for commands using scsi_ctron_ether_generic */
|
1997-03-18 04:31:15 +03:00
|
|
|
PROTOCMD_DECL(ctron_ether_send, {CTRON_ETHER_SEND});
|
|
|
|
PROTOCMD_DECL(ctron_ether_add_proto, {CTRON_ETHER_ADD_PROTO});
|
|
|
|
PROTOCMD_DECL(ctron_ether_get_addr, {CTRON_ETHER_GET_ADDR});
|
|
|
|
PROTOCMD_DECL(ctron_ether_set_media, {CTRON_ETHER_SET_MEDIA});
|
|
|
|
PROTOCMD_DECL(ctron_ether_set_addr, {CTRON_ETHER_SET_ADDR});
|
|
|
|
PROTOCMD_DECL(ctron_ether_set_multi, {CTRON_ETHER_SET_MULTI});
|
|
|
|
PROTOCMD_DECL(ctron_ether_remove_multi, {CTRON_ETHER_REMOVE_MULTI});
|
|
|
|
|
1997-03-24 03:04:53 +03:00
|
|
|
/* Command initializers for commands using their own structures */
|
|
|
|
PROTOCMD_DECL_SPECIAL(ctron_ether_recv, {CTRON_ETHER_RECV});
|
|
|
|
PROTOCMD_DECL_SPECIAL(ctron_ether_set_mode, {CTRON_ETHER_SET_MODE});
|
|
|
|
|
1997-03-18 04:31:15 +03:00
|
|
|
struct se_softc {
|
|
|
|
struct device sc_dev;
|
|
|
|
struct ethercom sc_ethercom; /* Ethernet common part */
|
1997-08-27 15:22:52 +04:00
|
|
|
struct scsipi_link *sc_link; /* contains our targ, lun, etc. */
|
2000-03-23 10:01:25 +03:00
|
|
|
|
|
|
|
struct callout sc_ifstart_ch;
|
|
|
|
struct callout sc_recv_ch;
|
|
|
|
|
1997-03-18 04:31:15 +03:00
|
|
|
char *sc_tbuf;
|
|
|
|
char *sc_rbuf;
|
|
|
|
int protos;
|
1997-04-04 23:02:43 +04:00
|
|
|
#define PROTO_IP 0x01
|
|
|
|
#define PROTO_ARP 0x02
|
|
|
|
#define PROTO_REVARP 0x04
|
|
|
|
#define PROTO_AT 0x08
|
|
|
|
#define PROTO_AARP 0x10
|
1997-03-18 04:31:15 +03:00
|
|
|
int sc_debug;
|
|
|
|
int sc_flags;
|
|
|
|
#define SE_NEED_RECV 0x1
|
1997-10-14 15:18:18 +04:00
|
|
|
int sc_last_timeout;
|
1998-11-20 03:35:39 +03:00
|
|
|
int sc_enabled;
|
1997-03-18 04:31:15 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
cdev_decl(se);
|
|
|
|
|
1997-04-04 23:02:43 +04:00
|
|
|
static int sematch __P((struct device *, struct cfdata *, void *));
|
|
|
|
static void seattach __P((struct device *, struct device *, void *));
|
1997-03-18 04:31:15 +03:00
|
|
|
|
1997-04-04 23:02:43 +04:00
|
|
|
static void se_ifstart __P((struct ifnet *));
|
|
|
|
static void sestart __P((void *));
|
1997-03-18 04:31:15 +03:00
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
static void sedone __P((struct scsipi_xfer *));
|
1997-04-04 23:02:43 +04:00
|
|
|
static int se_ioctl __P((struct ifnet *, u_long, caddr_t));
|
|
|
|
static void sewatchdog __P((struct ifnet *));
|
1997-03-18 04:31:15 +03:00
|
|
|
|
1997-04-04 23:02:43 +04:00
|
|
|
static __inline u_int16_t ether_cmp __P((void *, void *));
|
|
|
|
static void se_recv __P((void *));
|
1997-03-18 04:31:15 +03:00
|
|
|
static struct mbuf *se_get __P((struct se_softc *, char *, int));
|
1997-04-04 23:02:43 +04:00
|
|
|
static int se_read __P((struct se_softc *, char *, int));
|
|
|
|
static int se_reset __P((struct se_softc *));
|
|
|
|
static int se_add_proto __P((struct se_softc *, int));
|
|
|
|
static int se_get_addr __P((struct se_softc *, u_int8_t *));
|
|
|
|
static int se_set_media __P((struct se_softc *, int));
|
|
|
|
static int se_init __P((struct se_softc *));
|
|
|
|
static int se_set_multi __P((struct se_softc *, u_int8_t *));
|
|
|
|
static int se_remove_multi __P((struct se_softc *, u_int8_t *));
|
1997-03-18 04:31:15 +03:00
|
|
|
#if 0
|
1997-04-04 23:02:43 +04:00
|
|
|
static int sc_set_all_multi __P((struct se_softc *, int));
|
1997-03-18 04:31:15 +03:00
|
|
|
#endif
|
1997-04-04 23:02:43 +04:00
|
|
|
static void se_stop __P((struct se_softc *));
|
1997-08-27 15:22:52 +04:00
|
|
|
static __inline int se_scsipi_cmd __P((struct scsipi_link *sc_link,
|
1997-10-01 05:18:38 +04:00
|
|
|
struct scsipi_generic *scsipi_cmd,
|
|
|
|
int cmdlen, u_char *data_addr, int datalen,
|
|
|
|
int retries, int timeout, struct buf *bp,
|
|
|
|
int flags));
|
1997-04-04 23:02:43 +04:00
|
|
|
static void se_delayed_ifstart __P((void *));
|
|
|
|
static int se_set_mode(struct se_softc *, int, int);
|
1997-03-18 04:31:15 +03:00
|
|
|
|
1998-11-20 03:35:39 +03:00
|
|
|
int se_enable __P((struct se_softc *));
|
|
|
|
void se_disable __P((struct se_softc *));
|
|
|
|
|
1997-03-18 04:31:15 +03:00
|
|
|
struct cfattach se_ca = {
|
|
|
|
sizeof(struct se_softc), sematch, seattach
|
|
|
|
};
|
|
|
|
|
1998-01-12 12:49:10 +03:00
|
|
|
extern struct cfdriver se_cd;
|
1997-03-18 04:31:15 +03:00
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
struct scsipi_device se_switch = {
|
1997-03-18 04:31:15 +03:00
|
|
|
NULL, /* Use default error handler */
|
|
|
|
sestart, /* have a queue, served by this */
|
|
|
|
NULL, /* have no async handler */
|
|
|
|
sedone, /* deal with stats at interrupt time */
|
|
|
|
};
|
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
struct scsipi_inquiry_pattern se_patterns[] = {
|
1997-03-18 04:31:15 +03:00
|
|
|
{T_PROCESSOR, T_FIXED,
|
1997-10-14 15:18:18 +04:00
|
|
|
"CABLETRN", "EA412", ""},
|
1997-03-18 04:31:15 +03:00
|
|
|
{T_PROCESSOR, T_FIXED,
|
1997-10-14 15:18:18 +04:00
|
|
|
"Cabletrn", "EA412", ""},
|
1997-03-18 04:31:15 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Compare two Ether/802 addresses for equality, inlined and
|
|
|
|
* unrolled for speed.
|
|
|
|
* Note: use this like bcmp()
|
|
|
|
*/
|
1997-04-04 23:02:43 +04:00
|
|
|
static __inline u_int16_t
|
1997-03-18 04:31:15 +03:00
|
|
|
ether_cmp(one, two)
|
|
|
|
void *one, *two;
|
|
|
|
{
|
2000-03-30 04:00:55 +04:00
|
|
|
u_int16_t *a = (u_int16_t *) one;
|
|
|
|
u_int16_t *b = (u_int16_t *) two;
|
|
|
|
u_int16_t diff;
|
1997-03-18 04:31:15 +03:00
|
|
|
|
|
|
|
diff = (a[0] - b[0]) | (a[1] - b[1]) | (a[2] - b[2]);
|
|
|
|
|
|
|
|
return (diff);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ETHER_CMP ether_cmp
|
|
|
|
|
1997-04-04 23:02:43 +04:00
|
|
|
static int
|
1997-03-18 04:31:15 +03:00
|
|
|
sematch(parent, match, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct cfdata *match;
|
|
|
|
void *aux;
|
|
|
|
{
|
1997-08-27 15:22:52 +04:00
|
|
|
struct scsipibus_attach_args *sa = aux;
|
1997-03-18 04:31:15 +03:00
|
|
|
int priority;
|
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
(void)scsipi_inqmatch(&sa->sa_inqbuf,
|
1997-10-01 05:18:38 +04:00
|
|
|
(caddr_t)se_patterns, sizeof(se_patterns) / sizeof(se_patterns[0]),
|
1997-03-18 04:31:15 +03:00
|
|
|
sizeof(se_patterns[0]), &priority);
|
|
|
|
return (priority);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The routine called by the low level scsi routine when it discovers
|
|
|
|
* a device suitable for this driver.
|
|
|
|
*/
|
1997-04-04 23:02:43 +04:00
|
|
|
static void
|
1997-03-18 04:31:15 +03:00
|
|
|
seattach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct se_softc *sc = (void *)self;
|
1997-08-27 15:22:52 +04:00
|
|
|
struct scsipibus_attach_args *sa = aux;
|
|
|
|
struct scsipi_link *sc_link = sa->sa_sc_link;
|
1997-03-18 04:31:15 +03:00
|
|
|
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
|
|
|
|
u_int8_t myaddr[ETHER_ADDR_LEN];
|
|
|
|
|
1997-04-04 23:02:43 +04:00
|
|
|
printf("\n");
|
1997-03-18 04:31:15 +03:00
|
|
|
SC_DEBUG(sc_link, SDEV_DB2, ("seattach: "));
|
|
|
|
|
2000-03-23 10:01:25 +03:00
|
|
|
callout_init(&sc->sc_ifstart_ch);
|
|
|
|
callout_init(&sc->sc_recv_ch);
|
|
|
|
|
1997-03-18 04:31:15 +03:00
|
|
|
/*
|
|
|
|
* Store information needed to contact our base driver
|
|
|
|
*/
|
|
|
|
sc->sc_link = sc_link;
|
|
|
|
sc_link->device = &se_switch;
|
|
|
|
sc_link->device_softc = sc;
|
|
|
|
if (sc_link->openings > SEOUTSTANDING)
|
|
|
|
sc_link->openings = SEOUTSTANDING;
|
|
|
|
|
|
|
|
se_poll = (SE_POLL * hz) / 1000;
|
|
|
|
se_poll = se_poll? se_poll: 1;
|
|
|
|
se_poll0 = (SE_POLL0 * hz) / 1000;
|
|
|
|
se_poll0 = se_poll0? se_poll0: 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize and attach a buffer
|
|
|
|
*/
|
|
|
|
sc->sc_tbuf = malloc(ETHERMTU + sizeof(struct ether_header),
|
|
|
|
M_DEVBUF, M_NOWAIT);
|
1997-04-04 23:02:43 +04:00
|
|
|
if (sc->sc_tbuf == 0)
|
1997-03-18 04:31:15 +03:00
|
|
|
panic("seattach: can't allocate transmit buffer");
|
|
|
|
|
|
|
|
sc->sc_rbuf = malloc(RBUF_LEN, M_DEVBUF, M_NOWAIT);/* A Guess */
|
1997-04-04 23:02:43 +04:00
|
|
|
if (sc->sc_rbuf == 0)
|
1997-03-18 04:31:15 +03:00
|
|
|
panic("seattach: can't allocate receive buffer");
|
|
|
|
|
|
|
|
se_get_addr(sc, myaddr);
|
|
|
|
|
|
|
|
/* Initialize ifnet structure. */
|
|
|
|
bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ);
|
|
|
|
ifp->if_softc = sc;
|
|
|
|
ifp->if_start = se_ifstart;
|
|
|
|
ifp->if_ioctl = se_ioctl;
|
|
|
|
ifp->if_watchdog = sewatchdog;
|
|
|
|
ifp->if_flags =
|
|
|
|
IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST;
|
|
|
|
|
|
|
|
/* Attach the interface. */
|
|
|
|
if_attach(ifp);
|
|
|
|
ether_ifattach(ifp, myaddr);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-04-04 23:02:43 +04:00
|
|
|
static __inline int
|
1997-08-27 15:22:52 +04:00
|
|
|
se_scsipi_cmd(sc_link, scsipi_cmd, cmdlen, data_addr, datalen,
|
1997-03-18 04:31:15 +03:00
|
|
|
retries, timeout, bp, flags)
|
1997-08-27 15:22:52 +04:00
|
|
|
struct scsipi_link *sc_link;
|
|
|
|
struct scsipi_generic *scsipi_cmd;
|
1997-03-18 04:31:15 +03:00
|
|
|
int cmdlen;
|
|
|
|
u_char *data_addr;
|
|
|
|
int datalen;
|
|
|
|
int retries;
|
|
|
|
int timeout;
|
|
|
|
struct buf *bp;
|
|
|
|
int flags;
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
int s = splbio();
|
1997-10-01 05:18:38 +04:00
|
|
|
|
1997-10-18 23:50:51 +04:00
|
|
|
error = scsipi_command(sc_link, scsipi_cmd, cmdlen, data_addr,
|
1997-10-01 05:18:38 +04:00
|
|
|
datalen, retries, timeout, bp, flags);
|
1997-03-18 04:31:15 +03:00
|
|
|
splx(s);
|
1997-10-01 05:18:38 +04:00
|
|
|
return (error);
|
1997-03-18 04:31:15 +03:00
|
|
|
}
|
1997-04-04 23:02:43 +04:00
|
|
|
|
1997-03-18 04:31:15 +03:00
|
|
|
/* Start routine for calling from scsi sub system */
|
1997-04-04 23:02:43 +04:00
|
|
|
static void
|
|
|
|
sestart(v)
|
|
|
|
void *v;
|
1997-03-18 04:31:15 +03:00
|
|
|
{
|
|
|
|
struct se_softc *sc = (struct se_softc *) v;
|
|
|
|
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
|
|
|
|
int s = splnet();
|
1997-10-01 05:18:38 +04:00
|
|
|
|
1997-03-18 04:31:15 +03:00
|
|
|
se_ifstart(ifp);
|
|
|
|
(void) splx(s);
|
|
|
|
}
|
|
|
|
|
1997-04-04 23:02:43 +04:00
|
|
|
static void
|
|
|
|
se_delayed_ifstart(v)
|
|
|
|
void *v;
|
1997-03-18 04:31:15 +03:00
|
|
|
{
|
|
|
|
struct ifnet *ifp = v;
|
1998-11-20 03:35:39 +03:00
|
|
|
struct se_softc *sc = ifp->if_softc;
|
|
|
|
int s;
|
1997-10-01 05:18:38 +04:00
|
|
|
|
1998-11-20 03:35:39 +03:00
|
|
|
s = splnet();
|
|
|
|
if (sc->sc_enabled) {
|
|
|
|
ifp->if_flags &= ~IFF_OACTIVE;
|
|
|
|
se_ifstart(ifp);
|
|
|
|
}
|
1997-03-18 04:31:15 +03:00
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Start transmission on the interface.
|
|
|
|
* Always called at splnet().
|
|
|
|
*/
|
1997-04-04 23:02:43 +04:00
|
|
|
static void
|
1997-03-18 04:31:15 +03:00
|
|
|
se_ifstart(ifp)
|
|
|
|
struct ifnet *ifp;
|
|
|
|
{
|
|
|
|
struct se_softc *sc = ifp->if_softc;
|
|
|
|
struct scsi_ctron_ether_generic send_cmd;
|
|
|
|
struct mbuf *m, *m0;
|
|
|
|
int len, error;
|
|
|
|
u_char *cp;
|
|
|
|
|
|
|
|
/* Don't transmit if interface is busy or not running */
|
|
|
|
if ((ifp->if_flags & (IFF_RUNNING|IFF_OACTIVE)) != IFF_RUNNING)
|
|
|
|
return;
|
|
|
|
|
|
|
|
IF_DEQUEUE(&ifp->if_snd, m0);
|
|
|
|
if (m0 == 0)
|
|
|
|
return;
|
|
|
|
#if NBPFILTER > 0
|
|
|
|
/* If BPF is listening on this interface, let it see the
|
|
|
|
* packet before we commit it to the wire.
|
|
|
|
*/
|
|
|
|
if (ifp->if_bpf)
|
|
|
|
bpf_mtap(ifp->if_bpf, m0);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* 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 we allocated at attach time. */
|
|
|
|
cp = sc->sc_tbuf;
|
|
|
|
for (m = m0; m != NULL; ) {
|
|
|
|
bcopy(mtod(m, u_char *), cp, m->m_len);
|
|
|
|
cp += m->m_len;
|
|
|
|
MFREE(m, m0);
|
|
|
|
m = m0;
|
|
|
|
}
|
|
|
|
if (len < SEMINSIZE) {
|
|
|
|
#ifdef SEDEBUG
|
|
|
|
if (sc->sc_debug)
|
|
|
|
printf("se: packet size %d (%d) < %d\n", len,
|
1997-10-01 05:18:38 +04:00
|
|
|
cp - (u_char *)sc->sc_tbuf, SEMINSIZE);
|
1997-03-18 04:31:15 +03:00
|
|
|
#endif
|
|
|
|
bzero(cp, SEMINSIZE - len);
|
|
|
|
len = SEMINSIZE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fill out SCSI command. */
|
|
|
|
PROTOCMD(ctron_ether_send, send_cmd);
|
|
|
|
_lto2b(len, send_cmd.length);
|
|
|
|
|
|
|
|
/* Send command to device. */
|
1997-08-27 15:22:52 +04:00
|
|
|
error = se_scsipi_cmd(sc->sc_link,
|
1997-10-01 05:18:38 +04:00
|
|
|
(struct scsipi_generic *)&send_cmd, sizeof(send_cmd),
|
|
|
|
sc->sc_tbuf, len, SERETRIES,
|
1999-11-13 21:03:34 +03:00
|
|
|
SETIMEOUT, NULL, XS_CTL_NOSLEEP|XS_CTL_ASYNC|XS_CTL_DATA_OUT);
|
1997-03-18 04:31:15 +03:00
|
|
|
if (error) {
|
|
|
|
printf("%s: not queued, error %d\n",
|
1997-10-01 05:18:38 +04:00
|
|
|
sc->sc_dev.dv_xname, error);
|
1997-03-18 04:31:15 +03:00
|
|
|
ifp->if_oerrors++;
|
|
|
|
ifp->if_flags &= ~IFF_OACTIVE;
|
|
|
|
} else
|
|
|
|
ifp->if_opackets++;
|
|
|
|
if (sc->sc_flags & SE_NEED_RECV) {
|
|
|
|
sc->sc_flags &= ~SE_NEED_RECV;
|
|
|
|
se_recv((void *) sc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Called from the scsibus layer via our scsi device switch.
|
|
|
|
*/
|
1997-04-02 06:29:30 +04:00
|
|
|
static void
|
|
|
|
sedone(xs)
|
1997-08-27 15:22:52 +04:00
|
|
|
struct scsipi_xfer *xs;
|
1997-03-18 04:31:15 +03:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
struct se_softc *sc = xs->sc_link->device_softc;
|
1997-08-27 15:22:52 +04:00
|
|
|
struct scsipi_generic *cmd = xs->cmd;
|
1997-03-18 04:31:15 +03:00
|
|
|
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
|
1997-04-02 06:29:30 +04:00
|
|
|
int s;
|
|
|
|
|
|
|
|
error = !(xs->error == XS_NOERROR);
|
|
|
|
|
|
|
|
s = splnet();
|
|
|
|
if(IS_SEND(cmd)) {
|
|
|
|
if (xs->error == XS_BUSY) {
|
|
|
|
printf("se: busy, retry txmit\n");
|
2000-03-23 10:01:25 +03:00
|
|
|
callout_reset(&sc->sc_ifstart_ch, hz,
|
|
|
|
se_delayed_ifstart, ifp);
|
1997-04-02 06:29:30 +04:00
|
|
|
} else {
|
|
|
|
ifp->if_flags &= ~IFF_OACTIVE;
|
1997-08-27 15:22:52 +04:00
|
|
|
/* the generic scsipi_done will call
|
|
|
|
* sestart (through scsipi_free_xs).
|
1997-04-02 06:29:30 +04:00
|
|
|
*/
|
|
|
|
}
|
|
|
|
} else if(IS_RECV(cmd)) {
|
|
|
|
/* RECV complete */
|
|
|
|
/* pass data up. reschedule a recv */
|
1997-08-27 15:22:52 +04:00
|
|
|
/* scsipi_free_xs will call start. Harmless. */
|
1997-04-02 06:29:30 +04:00
|
|
|
if (error) {
|
|
|
|
/* Reschedule after a delay */
|
2000-03-23 10:01:25 +03:00
|
|
|
callout_reset(&sc->sc_recv_ch, se_poll,
|
|
|
|
se_recv, (void *)sc);
|
1997-04-02 06:29:30 +04:00
|
|
|
} else {
|
1997-10-14 15:18:18 +04:00
|
|
|
int n, ntimeo;
|
1997-04-02 06:29:30 +04:00
|
|
|
n = se_read(sc, xs->data, xs->datalen - xs->resid);
|
1997-10-14 15:18:18 +04:00
|
|
|
if (n > se_max_received)
|
|
|
|
se_max_received = n;
|
|
|
|
if (n == 0)
|
|
|
|
ntimeo = se_poll;
|
|
|
|
else if (n >= RDATA_MAX)
|
|
|
|
ntimeo = se_poll0;
|
|
|
|
else {
|
|
|
|
ntimeo = sc->sc_last_timeout;
|
|
|
|
ntimeo = (ntimeo * RDATA_GOAL)/n;
|
|
|
|
ntimeo = (ntimeo < se_poll0?
|
|
|
|
se_poll0: ntimeo);
|
|
|
|
ntimeo = (ntimeo > se_poll?
|
|
|
|
se_poll: ntimeo);
|
1997-03-18 04:31:15 +03:00
|
|
|
}
|
1997-10-14 15:18:18 +04:00
|
|
|
sc->sc_last_timeout = ntimeo;
|
|
|
|
if (ntimeo == se_poll0 &&
|
|
|
|
ifp->if_snd.ifq_head)
|
|
|
|
/* Output is pending. Do next recv
|
|
|
|
* after the next send. */
|
|
|
|
sc->sc_flags |= SE_NEED_RECV;
|
|
|
|
else {
|
2000-03-23 10:01:25 +03:00
|
|
|
callout_reset(&sc->sc_recv_ch, ntimeo,
|
|
|
|
se_recv, (void *)sc);
|
1997-10-14 15:18:18 +04:00
|
|
|
}
|
1997-03-18 04:31:15 +03:00
|
|
|
}
|
|
|
|
}
|
1997-04-02 06:29:30 +04:00
|
|
|
splx(s);
|
1997-03-18 04:31:15 +03:00
|
|
|
}
|
1997-10-01 05:18:38 +04:00
|
|
|
|
1997-04-04 23:02:43 +04:00
|
|
|
static void
|
|
|
|
se_recv(v)
|
|
|
|
void *v;
|
1997-03-18 04:31:15 +03:00
|
|
|
{
|
|
|
|
/* do a recv command */
|
|
|
|
struct se_softc *sc = (struct se_softc *) v;
|
|
|
|
struct scsi_ctron_ether_recv recv_cmd;
|
|
|
|
int error;
|
|
|
|
|
1998-11-20 03:35:39 +03:00
|
|
|
if (sc->sc_enabled == 0)
|
|
|
|
return;
|
|
|
|
|
1997-03-18 04:31:15 +03:00
|
|
|
PROTOCMD(ctron_ether_recv, recv_cmd);
|
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
error = se_scsipi_cmd(sc->sc_link,
|
1997-10-01 05:18:38 +04:00
|
|
|
(struct scsipi_generic *)&recv_cmd, sizeof(recv_cmd),
|
|
|
|
sc->sc_rbuf, RBUF_LEN, SERETRIES, SETIMEOUT, NULL,
|
1999-11-13 21:03:34 +03:00
|
|
|
XS_CTL_NOSLEEP|XS_CTL_ASYNC|XS_CTL_DATA_IN);
|
1997-03-18 04:31:15 +03:00
|
|
|
if (error)
|
2000-03-23 10:01:25 +03:00
|
|
|
callout_reset(&sc->sc_recv_ch, se_poll, se_recv, (void *)sc);
|
1997-03-18 04:31:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We copy the data into mbufs. When full cluster sized units are present
|
|
|
|
* we copy into clusters.
|
|
|
|
*/
|
|
|
|
static struct mbuf *
|
|
|
|
se_get(sc, data, totlen)
|
|
|
|
struct se_softc *sc;
|
|
|
|
char *data;
|
|
|
|
int totlen;
|
|
|
|
{
|
|
|
|
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
|
1998-12-12 19:58:10 +03:00
|
|
|
struct mbuf *m, *m0, *newm;
|
|
|
|
int len;
|
1997-03-18 04:31:15 +03:00
|
|
|
|
1998-12-12 19:58:10 +03:00
|
|
|
MGETHDR(m0, M_DONTWAIT, MT_DATA);
|
|
|
|
if (m0 == 0)
|
1997-03-18 04:31:15 +03:00
|
|
|
return (0);
|
1998-12-12 19:58:10 +03:00
|
|
|
m0->m_pkthdr.rcvif = ifp;
|
|
|
|
m0->m_pkthdr.len = totlen;
|
|
|
|
len = MHLEN;
|
|
|
|
m = m0;
|
1997-03-18 04:31:15 +03:00
|
|
|
|
|
|
|
while (totlen > 0) {
|
1997-04-24 06:36:46 +04:00
|
|
|
if (totlen >= MINCLSIZE) {
|
1997-03-18 04:31:15 +03:00
|
|
|
MCLGET(m, M_DONTWAIT);
|
1998-12-12 19:58:10 +03:00
|
|
|
if ((m->m_flags & M_EXT) == 0)
|
|
|
|
goto bad;
|
1997-04-24 06:36:46 +04:00
|
|
|
len = MCLBYTES;
|
1997-03-18 04:31:15 +03:00
|
|
|
}
|
1998-12-12 19:58:10 +03:00
|
|
|
|
|
|
|
if (m == m0) {
|
|
|
|
caddr_t newdata = (caddr_t)
|
|
|
|
ALIGN(m->m_data + sizeof(struct ether_header)) -
|
|
|
|
sizeof(struct ether_header);
|
|
|
|
len -= newdata - m->m_data;
|
|
|
|
m->m_data = newdata;
|
|
|
|
}
|
|
|
|
|
1997-03-18 04:31:15 +03:00
|
|
|
m->m_len = len = min(totlen, len);
|
|
|
|
bcopy(data, mtod(m, caddr_t), len);
|
|
|
|
data += len;
|
1998-12-12 19:58:10 +03:00
|
|
|
|
1997-03-18 04:31:15 +03:00
|
|
|
totlen -= len;
|
1998-12-12 19:58:10 +03:00
|
|
|
if (totlen > 0) {
|
|
|
|
MGET(newm, M_DONTWAIT, MT_DATA);
|
|
|
|
if (newm == 0)
|
|
|
|
goto bad;
|
|
|
|
len = MLEN;
|
|
|
|
m = m->m_next = newm;
|
|
|
|
}
|
1997-03-18 04:31:15 +03:00
|
|
|
}
|
|
|
|
|
1998-12-12 19:58:10 +03:00
|
|
|
return (m0);
|
|
|
|
|
|
|
|
bad:
|
|
|
|
m_freem(m0);
|
|
|
|
return (0);
|
1997-03-18 04:31:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Pass packets to higher levels.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
se_read(sc, data, datalen)
|
2000-03-30 04:00:55 +04:00
|
|
|
struct se_softc *sc;
|
1997-03-18 04:31:15 +03:00
|
|
|
char *data;
|
|
|
|
int datalen;
|
|
|
|
{
|
|
|
|
struct mbuf *m;
|
|
|
|
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
n = 0;
|
|
|
|
while (datalen >= 2) {
|
|
|
|
int len = _2btol(data);
|
|
|
|
data += 2;
|
|
|
|
datalen -= 2;
|
|
|
|
|
|
|
|
if (len == 0)
|
|
|
|
break;
|
|
|
|
#ifdef SEDEBUG
|
|
|
|
if (sc->sc_debug) {
|
|
|
|
printf("se_read: datalen = %d, packetlen = %d, proto = 0x%04x\n", datalen, len,
|
|
|
|
ntohs(((struct ether_header *)data)->ether_type));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (len <= sizeof(struct ether_header) ||
|
|
|
|
len > MAX_SNAP) {
|
|
|
|
#ifdef SEDEBUG
|
|
|
|
printf("%s: invalid packet size %d; dropping\n",
|
|
|
|
sc->sc_dev.dv_xname, len);
|
|
|
|
#endif
|
|
|
|
ifp->if_ierrors++;
|
|
|
|
goto next_packet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Don't need crc. Must keep ether header for BPF */
|
|
|
|
m = se_get(sc, data, len - ETHER_CRC);
|
|
|
|
if (m == 0) {
|
|
|
|
#ifdef SEDEBUG
|
1997-10-01 05:18:38 +04:00
|
|
|
if (sc->sc_debug)
|
1997-03-18 04:31:15 +03:00
|
|
|
printf("se_read: se_get returned null\n");
|
|
|
|
#endif
|
|
|
|
ifp->if_ierrors++;
|
|
|
|
goto next_packet;
|
|
|
|
}
|
|
|
|
if ((ifp->if_flags & IFF_PROMISC) != 0) {
|
1997-04-04 23:02:43 +04:00
|
|
|
m_adj(m, SE_PREFIX);
|
1997-03-18 04:31:15 +03:00
|
|
|
}
|
|
|
|
ifp->if_ipackets++;
|
|
|
|
|
|
|
|
#if NBPFILTER > 0
|
|
|
|
/*
|
|
|
|
* Check if there's a BPF listener on this interface.
|
|
|
|
* If so, hand off the raw packet to BPF.
|
|
|
|
*/
|
2000-10-02 03:32:39 +04:00
|
|
|
if (ifp->if_bpf)
|
1997-03-18 04:31:15 +03:00
|
|
|
bpf_mtap(ifp->if_bpf, m);
|
|
|
|
#endif
|
|
|
|
|
1999-05-19 03:52:51 +04:00
|
|
|
/* Pass the packet up. */
|
|
|
|
(*ifp->if_input)(ifp, m);
|
1997-03-18 04:31:15 +03:00
|
|
|
|
|
|
|
next_packet:
|
|
|
|
data += len;
|
|
|
|
datalen -= len;
|
|
|
|
n++;
|
|
|
|
}
|
1997-10-01 05:18:38 +04:00
|
|
|
return (n);
|
1997-03-18 04:31:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-04-04 23:02:43 +04:00
|
|
|
static void
|
1997-03-18 04:31:15 +03:00
|
|
|
sewatchdog(ifp)
|
|
|
|
struct ifnet *ifp;
|
|
|
|
{
|
|
|
|
struct se_softc *sc = ifp->if_softc;
|
|
|
|
|
|
|
|
log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname);
|
|
|
|
++ifp->if_oerrors;
|
|
|
|
|
|
|
|
se_reset(sc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
se_reset(sc)
|
|
|
|
struct se_softc *sc;
|
|
|
|
{
|
1997-10-01 05:18:38 +04:00
|
|
|
int error;
|
1997-03-18 04:31:15 +03:00
|
|
|
int s = splnet();
|
|
|
|
#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.
|
|
|
|
*/
|
1997-08-27 15:22:52 +04:00
|
|
|
error = se_scsipi_cmd(sc->sc_link, 0, 0, 0, 0, SERETRIES, 2000, NULL,
|
1999-10-01 02:57:52 +04:00
|
|
|
XS_CTL_RESET);
|
1997-03-18 04:31:15 +03:00
|
|
|
#endif
|
|
|
|
error = se_init(sc);
|
|
|
|
splx(s);
|
1997-10-01 05:18:38 +04:00
|
|
|
return (error);
|
1997-03-18 04:31:15 +03:00
|
|
|
}
|
|
|
|
|
1997-04-04 23:02:43 +04:00
|
|
|
static int
|
|
|
|
se_add_proto(sc, proto)
|
|
|
|
struct se_softc *sc;
|
|
|
|
int proto;
|
1997-03-18 04:31:15 +03:00
|
|
|
{
|
1997-10-01 05:18:38 +04:00
|
|
|
int error;
|
1997-03-18 04:31:15 +03:00
|
|
|
struct scsi_ctron_ether_generic add_proto_cmd;
|
|
|
|
u_int8_t data[2];
|
|
|
|
_lto2b(proto, data);
|
|
|
|
#ifdef SEDEBUG
|
|
|
|
if (sc->sc_debug)
|
|
|
|
printf("se: adding proto 0x%02x%02x\n", data[0], data[1]);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
PROTOCMD(ctron_ether_add_proto, add_proto_cmd);
|
|
|
|
_lto2b(sizeof(data), add_proto_cmd.length);
|
1997-08-27 15:22:52 +04:00
|
|
|
error = se_scsipi_cmd(sc->sc_link,
|
1997-10-01 05:18:38 +04:00
|
|
|
(struct scsipi_generic *) &add_proto_cmd, sizeof(add_proto_cmd),
|
2000-06-09 12:54:19 +04:00
|
|
|
data, sizeof(data), SERETRIES, SETIMEOUT, NULL,
|
|
|
|
XS_CTL_DATA_OUT | XS_CTL_DATA_ONSTACK);
|
1997-10-01 05:18:38 +04:00
|
|
|
return (error);
|
1997-03-18 04:31:15 +03:00
|
|
|
}
|
|
|
|
|
1997-04-04 23:02:43 +04:00
|
|
|
static int
|
|
|
|
se_get_addr(sc, myaddr)
|
|
|
|
struct se_softc *sc;
|
|
|
|
u_int8_t *myaddr;
|
1997-03-18 04:31:15 +03:00
|
|
|
{
|
1997-10-01 05:18:38 +04:00
|
|
|
int error;
|
1997-03-18 04:31:15 +03:00
|
|
|
struct scsi_ctron_ether_generic get_addr_cmd;
|
|
|
|
|
|
|
|
PROTOCMD(ctron_ether_get_addr, get_addr_cmd);
|
|
|
|
_lto2b(ETHER_ADDR_LEN, get_addr_cmd.length);
|
1997-08-27 15:22:52 +04:00
|
|
|
error = se_scsipi_cmd(sc->sc_link,
|
1997-10-01 05:18:38 +04:00
|
|
|
(struct scsipi_generic *) &get_addr_cmd, sizeof(get_addr_cmd),
|
2000-06-09 12:54:19 +04:00
|
|
|
myaddr, ETHER_ADDR_LEN, SERETRIES, SETIMEOUT, NULL,
|
|
|
|
XS_CTL_DATA_IN | XS_CTL_DATA_ONSTACK);
|
1997-03-18 04:31:15 +03:00
|
|
|
printf("%s: ethernet address %s\n", sc->sc_dev.dv_xname,
|
|
|
|
ether_sprintf(myaddr));
|
1997-10-01 05:18:38 +04:00
|
|
|
return (error);
|
1997-03-18 04:31:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-04-04 23:02:43 +04:00
|
|
|
static int
|
|
|
|
se_set_media(sc, type)
|
|
|
|
struct se_softc *sc;
|
|
|
|
int type;
|
1997-03-18 04:31:15 +03:00
|
|
|
{
|
1997-10-01 05:18:38 +04:00
|
|
|
int error;
|
1997-03-18 04:31:15 +03:00
|
|
|
struct scsi_ctron_ether_generic set_media_cmd;
|
|
|
|
|
|
|
|
PROTOCMD(ctron_ether_set_media, set_media_cmd);
|
|
|
|
set_media_cmd.byte3 = type;
|
1997-08-27 15:22:52 +04:00
|
|
|
error = se_scsipi_cmd(sc->sc_link,
|
1997-10-01 05:18:38 +04:00
|
|
|
(struct scsipi_generic *) &set_media_cmd, sizeof(set_media_cmd),
|
|
|
|
0, 0, SERETRIES, SETIMEOUT, NULL, 0);
|
|
|
|
return (error);
|
1997-03-18 04:31:15 +03:00
|
|
|
}
|
|
|
|
|
1997-04-04 23:02:43 +04:00
|
|
|
static int
|
|
|
|
se_set_mode(sc, len, mode)
|
|
|
|
struct se_softc *sc;
|
|
|
|
int len;
|
|
|
|
int mode;
|
1997-03-18 04:31:15 +03:00
|
|
|
{
|
1997-10-01 05:18:38 +04:00
|
|
|
int error;
|
1997-03-18 04:31:15 +03:00
|
|
|
struct scsi_ctron_ether_set_mode set_mode_cmd;
|
|
|
|
|
|
|
|
PROTOCMD(ctron_ether_set_mode, set_mode_cmd);
|
|
|
|
set_mode_cmd.mode = mode;
|
|
|
|
_lto2b(len, set_mode_cmd.length);
|
1997-08-27 15:22:52 +04:00
|
|
|
error = se_scsipi_cmd(sc->sc_link,
|
1997-10-01 05:18:38 +04:00
|
|
|
(struct scsipi_generic *) &set_mode_cmd, sizeof(set_mode_cmd),
|
|
|
|
0, 0, SERETRIES, SETIMEOUT, NULL, 0);
|
|
|
|
return (error);
|
1997-03-18 04:31:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-04-04 23:02:43 +04:00
|
|
|
static int
|
|
|
|
se_init(sc)
|
|
|
|
struct se_softc *sc;
|
1997-03-18 04:31:15 +03:00
|
|
|
{
|
|
|
|
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
|
|
|
|
struct scsi_ctron_ether_generic set_addr_cmd;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
#if NBPFILTER > 0
|
|
|
|
if (ifp->if_flags & IFF_PROMISC) {
|
|
|
|
error = se_set_mode(sc, MAX_SNAP, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
error = se_set_mode(sc, ETHERMTU + sizeof(struct ether_header),
|
1997-10-01 05:18:38 +04:00
|
|
|
0);
|
1997-04-04 23:02:43 +04:00
|
|
|
if (error != 0)
|
1997-10-01 05:18:38 +04:00
|
|
|
return (error);
|
1997-04-04 23:02:43 +04:00
|
|
|
|
1997-03-18 04:31:15 +03:00
|
|
|
PROTOCMD(ctron_ether_set_addr, set_addr_cmd);
|
|
|
|
_lto2b(ETHER_ADDR_LEN, set_addr_cmd.length);
|
1997-08-27 15:22:52 +04:00
|
|
|
error = se_scsipi_cmd(sc->sc_link,
|
1997-10-01 05:18:38 +04:00
|
|
|
(struct scsipi_generic *) &set_addr_cmd, sizeof(set_addr_cmd),
|
|
|
|
LLADDR(ifp->if_sadl), ETHER_ADDR_LEN, SERETRIES, SETIMEOUT, NULL,
|
1999-10-01 02:57:52 +04:00
|
|
|
XS_CTL_DATA_OUT);
|
1997-10-01 05:18:38 +04:00
|
|
|
if (error != 0)
|
|
|
|
return (error);
|
1997-03-18 04:31:15 +03:00
|
|
|
|
|
|
|
if ((sc->protos & PROTO_IP) &&
|
|
|
|
(error = se_add_proto(sc, ETHERTYPE_IP)) != 0)
|
1997-10-01 05:18:38 +04:00
|
|
|
return (error);
|
1997-03-18 04:31:15 +03:00
|
|
|
if ((sc->protos & PROTO_ARP) &&
|
|
|
|
(error = se_add_proto(sc, ETHERTYPE_ARP)) != 0)
|
1997-10-01 05:18:38 +04:00
|
|
|
return (error);
|
1997-03-18 04:31:15 +03:00
|
|
|
if ((sc->protos & PROTO_REVARP) &&
|
|
|
|
(error = se_add_proto(sc, ETHERTYPE_REVARP)) != 0)
|
1997-10-01 05:18:38 +04:00
|
|
|
return (error);
|
1997-04-04 23:02:43 +04:00
|
|
|
#ifdef NETATALK
|
|
|
|
if ((sc->protos & PROTO_AT) &&
|
1998-10-13 06:34:31 +04:00
|
|
|
(error = se_add_proto(sc, ETHERTYPE_ATALK)) != 0)
|
1997-10-01 05:18:38 +04:00
|
|
|
return (error);
|
1997-04-04 23:02:43 +04:00
|
|
|
if ((sc->protos & PROTO_AARP) &&
|
|
|
|
(error = se_add_proto(sc, ETHERTYPE_AARP)) != 0)
|
1997-10-01 05:18:38 +04:00
|
|
|
return (error);
|
1997-04-04 23:02:43 +04:00
|
|
|
#endif
|
1997-03-18 04:31:15 +03:00
|
|
|
|
1997-04-04 23:02:43 +04:00
|
|
|
if ((ifp->if_flags & (IFF_RUNNING|IFF_UP)) == IFF_UP) {
|
1997-03-18 04:31:15 +03:00
|
|
|
ifp->if_flags |= IFF_RUNNING;
|
|
|
|
se_recv(sc);
|
|
|
|
ifp->if_flags &= ~IFF_OACTIVE;
|
|
|
|
se_ifstart(ifp);
|
|
|
|
}
|
1997-10-01 05:18:38 +04:00
|
|
|
return (error);
|
1997-03-18 04:31:15 +03:00
|
|
|
}
|
|
|
|
|
1997-04-04 23:02:43 +04:00
|
|
|
static int
|
|
|
|
se_set_multi(sc, addr)
|
|
|
|
struct se_softc *sc;
|
|
|
|
u_int8_t *addr;
|
1997-03-18 04:31:15 +03:00
|
|
|
{
|
|
|
|
struct scsi_ctron_ether_generic set_multi_cmd;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
if (sc->sc_debug)
|
|
|
|
printf("%s: set_set_multi: %s\n", sc->sc_dev.dv_xname,
|
|
|
|
ether_sprintf(addr));
|
|
|
|
|
|
|
|
PROTOCMD(ctron_ether_set_multi, set_multi_cmd);
|
|
|
|
_lto2b(sizeof(addr), set_multi_cmd.length);
|
1997-08-27 15:22:52 +04:00
|
|
|
error = se_scsipi_cmd(sc->sc_link,
|
1997-10-01 05:18:38 +04:00
|
|
|
(struct scsipi_generic *) &set_multi_cmd, sizeof(set_multi_cmd),
|
1999-10-01 02:57:52 +04:00
|
|
|
addr, sizeof(addr), SERETRIES, SETIMEOUT, NULL, XS_CTL_DATA_OUT);
|
1997-10-01 05:18:38 +04:00
|
|
|
return (error);
|
1997-03-18 04:31:15 +03:00
|
|
|
}
|
|
|
|
|
1997-04-04 23:02:43 +04:00
|
|
|
static int
|
|
|
|
se_remove_multi(sc, addr)
|
|
|
|
struct se_softc *sc;
|
|
|
|
u_int8_t *addr;
|
1997-03-18 04:31:15 +03:00
|
|
|
{
|
|
|
|
struct scsi_ctron_ether_generic remove_multi_cmd;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
if (sc->sc_debug)
|
|
|
|
printf("%s: se_remove_multi: %s\n", sc->sc_dev.dv_xname,
|
|
|
|
ether_sprintf(addr));
|
|
|
|
|
|
|
|
PROTOCMD(ctron_ether_remove_multi, remove_multi_cmd);
|
|
|
|
_lto2b(sizeof(addr), remove_multi_cmd.length);
|
1997-08-27 15:22:52 +04:00
|
|
|
error = se_scsipi_cmd(sc->sc_link,
|
1997-10-01 05:18:38 +04:00
|
|
|
(struct scsipi_generic *) &remove_multi_cmd,
|
|
|
|
sizeof(remove_multi_cmd),
|
1999-10-01 02:57:52 +04:00
|
|
|
addr, sizeof(addr), SERETRIES, SETIMEOUT, NULL, XS_CTL_DATA_OUT);
|
1997-10-01 05:18:38 +04:00
|
|
|
return (error);
|
1997-03-18 04:31:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#if 0 /* not used --thorpej */
|
1997-04-04 23:02:43 +04:00
|
|
|
static int
|
|
|
|
sc_set_all_multi(sc, set)
|
|
|
|
struct se_softc *sc;
|
|
|
|
int set;
|
1997-03-18 04:31:15 +03:00
|
|
|
{
|
|
|
|
int error = 0;
|
|
|
|
u_int8_t *addr;
|
|
|
|
struct ethercom *ac = &sc->sc_ethercom;
|
|
|
|
struct ether_multi *enm;
|
|
|
|
struct ether_multistep step;
|
1997-10-01 05:18:38 +04:00
|
|
|
|
1997-03-18 04:31:15 +03:00
|
|
|
ETHER_FIRST_MULTI(step, ac, enm);
|
|
|
|
while (enm != NULL) {
|
|
|
|
if (ETHER_CMP(enm->enm_addrlo, enm->enm_addrhi)) {
|
|
|
|
/*
|
|
|
|
* We must listen to a range of multicast addresses.
|
|
|
|
* For now, just accept all multicasts, rather than
|
|
|
|
* trying to set only those filter bits needed to match
|
|
|
|
* the range. (At this time, the only use of address
|
|
|
|
* ranges is for IP multicast routing, for which the
|
|
|
|
* range is big enough to require all bits set.)
|
|
|
|
*/
|
|
|
|
/* We have no way of adding a range to this device.
|
|
|
|
* stepping through all addresses in the range is
|
|
|
|
* typically not possible. The only real alternative
|
|
|
|
* is to go into promicuous mode and filter by hand.
|
|
|
|
*/
|
1997-10-01 05:18:38 +04:00
|
|
|
return (ENODEV);
|
1997-03-18 04:31:15 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
addr = enm->enm_addrlo;
|
1997-10-01 05:18:38 +04:00
|
|
|
if ((error = set ? se_set_multi(sc, addr) :
|
|
|
|
se_remove_multi(sc, addr)) != 0)
|
|
|
|
return (error);
|
1997-03-18 04:31:15 +03:00
|
|
|
ETHER_NEXT_MULTI(step, enm);
|
|
|
|
}
|
1997-10-01 05:18:38 +04:00
|
|
|
return (error);
|
1997-03-18 04:31:15 +03:00
|
|
|
}
|
|
|
|
#endif /* not used */
|
|
|
|
|
1997-04-04 23:02:43 +04:00
|
|
|
static void
|
|
|
|
se_stop(sc)
|
|
|
|
struct se_softc *sc;
|
1997-03-18 04:31:15 +03:00
|
|
|
{
|
1997-10-01 05:18:38 +04:00
|
|
|
|
1997-03-18 04:31:15 +03:00
|
|
|
/* Don't schedule any reads */
|
2000-03-23 10:01:25 +03:00
|
|
|
callout_stop(&sc->sc_recv_ch);
|
1997-04-04 23:02:43 +04:00
|
|
|
|
1997-03-18 04:31:15 +03:00
|
|
|
/* How can we abort any scsi cmds in progress? */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Process an ioctl request.
|
|
|
|
*/
|
1997-04-04 23:02:43 +04:00
|
|
|
static int
|
1997-03-18 04:31:15 +03:00
|
|
|
se_ioctl(ifp, cmd, data)
|
2000-03-30 04:00:55 +04:00
|
|
|
struct ifnet *ifp;
|
1997-03-18 04:31:15 +03:00
|
|
|
u_long cmd;
|
|
|
|
caddr_t data;
|
|
|
|
{
|
2000-03-30 04:00:55 +04:00
|
|
|
struct se_softc *sc = ifp->if_softc;
|
1997-03-18 04:31:15 +03:00
|
|
|
struct ifaddr *ifa = (struct ifaddr *)data;
|
|
|
|
struct ifreq *ifr = (struct ifreq *)data;
|
|
|
|
int s, error = 0;
|
|
|
|
|
|
|
|
s = splnet();
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
|
|
|
|
case SIOCSIFADDR:
|
1998-11-20 03:35:39 +03:00
|
|
|
if ((error = se_enable(sc)) != 0)
|
|
|
|
break;
|
1997-03-18 04:31:15 +03:00
|
|
|
ifp->if_flags |= IFF_UP;
|
|
|
|
|
|
|
|
if ((error = se_set_media(sc, CMEDIA_AUTOSENSE) != 0))
|
1998-11-20 03:35:39 +03:00
|
|
|
break;
|
1997-04-04 23:02:43 +04:00
|
|
|
|
1997-03-18 04:31:15 +03:00
|
|
|
switch (ifa->ifa_addr->sa_family) {
|
|
|
|
#ifdef INET
|
|
|
|
case AF_INET:
|
|
|
|
sc->protos |= (PROTO_IP | PROTO_ARP | PROTO_REVARP);
|
|
|
|
if ((error = se_init(sc)) != 0)
|
|
|
|
break;
|
|
|
|
arp_ifinit(ifp, ifa);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef NS
|
|
|
|
case AF_NS:
|
|
|
|
{
|
2000-03-30 04:00:55 +04:00
|
|
|
struct ns_addr *ina = &IA_SNS(ifa)->sns_addr;
|
1997-03-18 04:31:15 +03:00
|
|
|
|
|
|
|
if (ns_nullhost(*ina))
|
|
|
|
ina->x_host =
|
|
|
|
*(union ns_host *)LLADDR(ifp->if_sadl);
|
|
|
|
else
|
|
|
|
bcopy(ina->x_host.c_host,
|
|
|
|
LLADDR(ifp->if_sadl), ETHER_ADDR_LEN);
|
|
|
|
/* Set new address. */
|
|
|
|
|
|
|
|
error = se_init(sc);
|
|
|
|
break;
|
|
|
|
}
|
1997-04-04 23:02:43 +04:00
|
|
|
#endif
|
|
|
|
#ifdef NETATALK
|
|
|
|
case AF_APPLETALK:
|
|
|
|
sc->protos |= (PROTO_AT | PROTO_AARP);
|
|
|
|
if ((error = se_init(sc)) != 0)
|
|
|
|
break;
|
|
|
|
break;
|
1997-03-18 04:31:15 +03:00
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
error = se_init(sc);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
#if defined(CCITT) && defined(LLC)
|
|
|
|
case SIOCSIFCONF_X25:
|
1998-11-20 03:35:39 +03:00
|
|
|
if ((error = se_enable(sc)) != 0)
|
|
|
|
break;
|
1997-03-18 04:31:15 +03:00
|
|
|
ifp->if_flags |= IFF_UP;
|
|
|
|
ifa->ifa_rtrequest = cons_rtrequest; /* XXX */
|
|
|
|
error = x25_llcglue(PRC_IFUP, ifa->ifa_addr);
|
|
|
|
if (error == 0)
|
|
|
|
error = se_init(sc);
|
|
|
|
break;
|
|
|
|
#endif /* CCITT && LLC */
|
|
|
|
|
|
|
|
case SIOCSIFFLAGS:
|
|
|
|
if ((ifp->if_flags & IFF_UP) == 0 &&
|
|
|
|
(ifp->if_flags & IFF_RUNNING) != 0) {
|
|
|
|
/*
|
|
|
|
* If interface is marked down and it is running, then
|
|
|
|
* stop it.
|
|
|
|
*/
|
|
|
|
se_stop(sc);
|
|
|
|
ifp->if_flags &= ~IFF_RUNNING;
|
1998-11-20 03:35:39 +03:00
|
|
|
se_disable(sc);
|
1997-03-18 04:31:15 +03:00
|
|
|
} else if ((ifp->if_flags & IFF_UP) != 0 &&
|
|
|
|
(ifp->if_flags & IFF_RUNNING) == 0) {
|
|
|
|
/*
|
|
|
|
* If interface is marked up and it is stopped, then
|
|
|
|
* start it.
|
|
|
|
*/
|
1998-11-20 03:35:39 +03:00
|
|
|
if ((error = se_enable(sc)) != 0)
|
|
|
|
break;
|
1997-03-18 04:31:15 +03:00
|
|
|
error = se_init(sc);
|
1998-11-20 03:35:39 +03:00
|
|
|
} else if (sc->sc_enabled) {
|
1997-03-18 04:31:15 +03:00
|
|
|
/*
|
|
|
|
* Reset the interface to pick up changes in any other
|
|
|
|
* flags that affect hardware registers.
|
|
|
|
*/
|
|
|
|
error = se_init(sc);
|
|
|
|
}
|
|
|
|
#ifdef SEDEBUG
|
|
|
|
if (ifp->if_flags & IFF_DEBUG)
|
|
|
|
sc->sc_debug = 1;
|
|
|
|
else
|
|
|
|
sc->sc_debug = 0;
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SIOCADDMULTI:
|
1998-11-20 03:35:39 +03:00
|
|
|
if (sc->sc_enabled == 0) {
|
|
|
|
error = EIO;
|
|
|
|
break;
|
|
|
|
}
|
1997-10-01 05:18:38 +04:00
|
|
|
if (ether_addmulti(ifr, &sc->sc_ethercom) == ENETRESET)
|
1997-03-18 04:31:15 +03:00
|
|
|
error = se_set_multi(sc, ifr->ifr_addr.sa_data);
|
1997-10-01 05:18:38 +04:00
|
|
|
else
|
1997-03-18 04:31:15 +03:00
|
|
|
error = 0;
|
|
|
|
break;
|
|
|
|
case SIOCDELMULTI:
|
1998-11-20 03:35:39 +03:00
|
|
|
if (sc->sc_enabled == 0) {
|
|
|
|
error = EIO;
|
|
|
|
break;
|
|
|
|
}
|
1997-10-01 05:18:38 +04:00
|
|
|
if (ether_delmulti(ifr, &sc->sc_ethercom) == ENETRESET)
|
1997-03-18 04:31:15 +03:00
|
|
|
error = se_remove_multi(sc, ifr->ifr_addr.sa_data);
|
1997-10-01 05:18:38 +04:00
|
|
|
else
|
1997-03-18 04:31:15 +03:00
|
|
|
error = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
error = EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
splx(s);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1998-11-20 03:35:39 +03:00
|
|
|
/*
|
|
|
|
* Enable the network interface.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
se_enable(sc)
|
|
|
|
struct se_softc *sc;
|
|
|
|
{
|
|
|
|
int error = 0;
|
|
|
|
|
|
|
|
if (sc->sc_enabled == 0 &&
|
|
|
|
(error = scsipi_adapter_addref(sc->sc_link)) == 0)
|
|
|
|
sc->sc_enabled = 1;
|
|
|
|
else
|
|
|
|
printf("%s: device enable failed\n",
|
|
|
|
sc->sc_dev.dv_xname);
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable the network interface.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
se_disable(sc)
|
|
|
|
struct se_softc *sc;
|
|
|
|
{
|
|
|
|
|
|
|
|
if (sc->sc_enabled != 0) {
|
|
|
|
scsipi_adapter_delref(sc->sc_link);
|
|
|
|
sc->sc_enabled = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-03-18 04:31:15 +03:00
|
|
|
#define SEUNIT(z) (minor(z))
|
|
|
|
/*
|
|
|
|
* open the device.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
seopen(dev, flag, fmt, p)
|
|
|
|
dev_t dev;
|
|
|
|
int flag, fmt;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
1998-11-20 03:35:39 +03:00
|
|
|
int unit, error;
|
1997-03-18 04:31:15 +03:00
|
|
|
struct se_softc *sc;
|
1997-08-27 15:22:52 +04:00
|
|
|
struct scsipi_link *sc_link;
|
1997-03-18 04:31:15 +03:00
|
|
|
|
|
|
|
unit = SEUNIT(dev);
|
|
|
|
if (unit >= se_cd.cd_ndevs)
|
1997-10-01 05:18:38 +04:00
|
|
|
return (ENXIO);
|
1997-03-18 04:31:15 +03:00
|
|
|
sc = se_cd.cd_devs[unit];
|
1997-10-01 05:18:38 +04:00
|
|
|
if (sc == NULL)
|
|
|
|
return (ENXIO);
|
1997-04-04 23:02:43 +04:00
|
|
|
|
1997-03-18 04:31:15 +03:00
|
|
|
sc_link = sc->sc_link;
|
|
|
|
|
1998-11-20 03:35:39 +03:00
|
|
|
if ((error = scsipi_adapter_addref(sc_link)) != 0)
|
|
|
|
return (error);
|
|
|
|
|
1997-03-18 04:31:15 +03:00
|
|
|
SC_DEBUG(sc_link, SDEV_DB1,
|
1997-10-01 05:18:38 +04:00
|
|
|
("scopen: dev=0x%x (unit %d (of %d))\n", dev, unit,
|
|
|
|
se_cd.cd_ndevs));
|
1997-03-18 04:31:15 +03:00
|
|
|
|
|
|
|
sc_link->flags |= SDEV_OPEN;
|
|
|
|
|
|
|
|
SC_DEBUG(sc_link, SDEV_DB3, ("open complete\n"));
|
1997-10-01 05:18:38 +04:00
|
|
|
return (0);
|
1997-03-18 04:31:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* close the device.. only called if we are the LAST
|
|
|
|
* occurence of an open device
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
seclose(dev, flag, fmt, p)
|
|
|
|
dev_t dev;
|
|
|
|
int flag, fmt;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
|
|
|
struct se_softc *sc = se_cd.cd_devs[SEUNIT(dev)];
|
|
|
|
|
|
|
|
SC_DEBUG(sc->sc_link, SDEV_DB1, ("closing\n"));
|
1998-12-08 03:19:27 +03:00
|
|
|
|
|
|
|
scsipi_wait_drain(sc->sc_link);
|
|
|
|
|
1998-11-20 03:35:39 +03:00
|
|
|
scsipi_adapter_delref(sc->sc_link);
|
1997-03-18 04:31:15 +03:00
|
|
|
sc->sc_link->flags &= ~SDEV_OPEN;
|
|
|
|
|
1997-10-01 05:18:38 +04:00
|
|
|
return (0);
|
1997-03-18 04:31:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Perform special action on behalf of the user
|
|
|
|
* Only does generic scsi ioctls.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
seioctl(dev, cmd, addr, flag, p)
|
|
|
|
dev_t dev;
|
|
|
|
u_long cmd;
|
|
|
|
caddr_t addr;
|
|
|
|
int flag;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
2000-03-30 04:00:55 +04:00
|
|
|
struct se_softc *sc = se_cd.cd_devs[SEUNIT(dev)];
|
1997-03-18 04:31:15 +03:00
|
|
|
|
1997-10-01 05:18:38 +04:00
|
|
|
return (scsipi_do_ioctl(sc->sc_link, dev, cmd, addr, flag, p));
|
1997-03-18 04:31:15 +03:00
|
|
|
}
|