* Do some KNFing.

* Make all local functions static.
* Add some untested netatalk support.
This commit is contained in:
matthias 1997-04-04 19:02:43 +00:00
parent ef8d40a999
commit 470e2a9983
4 changed files with 344 additions and 274 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_se.c,v 1.4 1997/04/02 02:29:34 mycroft Exp $ */
/* $NetBSD: if_se.c,v 1.5 1997/04/04 19:02:43 matthias Exp $ */
/*
* Copyright (c) 1997 Ian W. Dall <ian.dall@dsto.defence.gov.au>
@ -84,6 +84,7 @@
#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>
@ -95,6 +96,10 @@
#include <netns/ns_if.h>
#endif
#ifdef NETATALK
#include <netatalk/at.h>
#endif
#if defined(CCITT) && defined(LLC)
#include <sys/socketvar.h>
#include <netccitt/x25.h>
@ -120,7 +125,8 @@
SE_PREFIX + ETHER_CRC)
#define RBUF_LEN (16 * 1024)
/* se_poll and se_poll0 are the normal polling rate and the
/*
* se_poll and se_poll0 are the normal polling rate and the
* minimum polling rate respectively. If se_poll0 should be
* chosen so that at maximum ethernet speed, we will read nearly
* full buffers. se_poll should be chosen for reasonable maximum
@ -160,9 +166,11 @@ struct se_softc {
char *sc_tbuf;
char *sc_rbuf;
int protos;
#define PROTO_IP 0x1
#define PROTO_ARP 0x2
#define PROTO_REVARP 0x4
#define PROTO_IP 0x01
#define PROTO_ARP 0x02
#define PROTO_REVARP 0x04
#define PROTO_AT 0x08
#define PROTO_AARP 0x10
int sc_debug;
int sc_flags;
#define SE_NEED_RECV 0x1
@ -171,23 +179,23 @@ struct se_softc {
cdev_decl(se);
#ifdef __BROKEN_INDIRECT_CONFIG
int sematch __P((struct device *, void *, void *));
static int sematch __P((struct device *, void *, void *));
#else
int sematch __P((struct device *, struct cfdata *, void *));
static int sematch __P((struct device *, struct cfdata *, void *));
#endif
void seattach __P((struct device *, struct device *, void *));
static void seattach __P((struct device *, struct device *, void *));
void se_ifstart __P((struct ifnet *));
void sestart __P((void *));
static void se_ifstart __P((struct ifnet *));
static void sestart __P((void *));
static void sedone __P((struct scsi_xfer *));
int se_ioctl __P((struct ifnet *, u_long, caddr_t));
void sewatchdog __P((struct ifnet *));
static int se_ioctl __P((struct ifnet *, u_long, caddr_t));
static void sewatchdog __P((struct ifnet *));
static __inline u_int16_t ether_cmp __P((void *, void *));
static void se_recv __P((void *));
static struct mbuf *se_get __P((struct se_softc *, char *, int));
static int se_read __P((struct se_softc *, char *, int));
void sewatchdog __P((struct ifnet *));
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 *));
@ -199,7 +207,7 @@ static int se_remove_multi __P((struct se_softc *, u_int8_t *));
static int sc_set_all_multi __P((struct se_softc *, int));
#endif
static void se_stop __P((struct se_softc *));
static __inline__ int se_scsi_cmd __P((struct scsi_link *sc_link,
static __inline int se_scsi_cmd __P((struct scsi_link *sc_link,
struct scsi_generic *scsi_cmd,
int cmdlen, u_char *data_addr, int datalen,
int retries, int timeout, struct buf *bp,
@ -226,17 +234,15 @@ struct scsi_inquiry_pattern se_patterns[] = {
{T_PROCESSOR, T_FIXED,
"CABLETRN", "EA412/14/19", ""},
{T_PROCESSOR, T_FIXED,
"Cabletrn", "EA412/14/19", ""},
"Cabletrn", "EA412/", ""},
};
static __inline__ u_int16_t ether_cmp __P((void *, void *));
/*
* Compare two Ether/802 addresses for equality, inlined and
* unrolled for speed.
* Note: use this like bcmp()
*/
static __inline__ u_int16_t
static __inline u_int16_t
ether_cmp(one, two)
void *one, *two;
{
@ -251,7 +257,7 @@ ether_cmp(one, two)
#define ETHER_CMP ether_cmp
int
static int
sematch(parent, match, aux)
struct device *parent;
#ifdef __BROKEN_INDIRECT_CONFIG
@ -274,7 +280,7 @@ sematch(parent, match, aux)
* The routine called by the low level scsi routine when it discovers
* a device suitable for this driver.
*/
void
static void
seattach(parent, self, aux)
struct device *parent, *self;
void *aux;
@ -285,6 +291,7 @@ seattach(parent, self, aux)
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
u_int8_t myaddr[ETHER_ADDR_LEN];
printf("\n");
SC_DEBUG(sc_link, SDEV_DB2, ("seattach: "));
/*
@ -334,7 +341,8 @@ seattach(parent, self, aux)
}
static __inline__ int se_scsi_cmd(sc_link, scsi_cmd, cmdlen, data_addr, datalen,
static __inline int
se_scsi_cmd(sc_link, scsi_cmd, cmdlen, data_addr, datalen,
retries, timeout, bp, flags)
struct scsi_link *sc_link;
struct scsi_generic *scsi_cmd;
@ -353,8 +361,11 @@ static __inline__ int se_scsi_cmd(sc_link, scsi_cmd, cmdlen, data_addr, datalen,
splx(s);
return error;
}
/* Start routine for calling from scsi sub system */
void sestart(void *v)
static void
sestart(v)
void *v;
{
struct se_softc *sc = (struct se_softc *) v;
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
@ -363,7 +374,9 @@ void sestart(void *v)
(void) splx(s);
}
static void se_delayed_ifstart(void *v)
static void
se_delayed_ifstart(v)
void *v;
{
struct ifnet *ifp = v;
int s = splnet();
@ -376,7 +389,7 @@ static void se_delayed_ifstart(void *v)
* Start transmission on the interface.
* Always called at splnet().
*/
void
static void
se_ifstart(ifp)
struct ifnet *ifp;
{
@ -510,7 +523,8 @@ sedone(xs)
splx(s);
}
static void se_recv(v)
static void
se_recv(v)
void *v;
{
/* do a recv command */
@ -527,7 +541,6 @@ static void se_recv(v)
SETIMEOUT, NULL, SCSI_NOSLEEP|SCSI_DATA_IN);
if (error)
timeout(se_recv, (void *)sc, se_poll);
}
/*
@ -674,7 +687,7 @@ se_read(sc, data, datalen)
}
void
static void
sewatchdog(ifp)
struct ifnet *ifp;
{
@ -706,7 +719,8 @@ se_reset(sc)
return error;
}
static int se_add_proto(sc, proto)
static int
se_add_proto(sc, proto)
struct se_softc *sc;
int proto;
{
@ -729,10 +743,10 @@ static int se_add_proto(sc, proto)
SERETRIES, SETIMEOUT, NULL,
SCSI_DATA_OUT);
return error;
}
static int se_get_addr(sc, myaddr)
static int
se_get_addr(sc, myaddr)
struct se_softc *sc;
u_int8_t *myaddr;
{
@ -753,7 +767,8 @@ static int se_get_addr(sc, myaddr)
}
static int se_set_media(sc, type)
static int
se_set_media(sc, type)
struct se_softc *sc;
int type;
{
@ -772,7 +787,8 @@ static int se_set_media(sc, type)
return error;
}
static int se_set_mode(sc, len, mode)
static int
se_set_mode(sc, len, mode)
struct se_softc *sc;
int len;
int mode;
@ -794,8 +810,8 @@ static int se_set_mode(sc, len, mode)
}
static int se_init(sc)
static int
se_init(sc)
struct se_softc *sc;
{
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
@ -834,6 +850,14 @@ static int se_init(sc)
if ((sc->protos & PROTO_REVARP) &&
(error = se_add_proto(sc, ETHERTYPE_REVARP)) != 0)
return error;
#ifdef NETATALK
if ((sc->protos & PROTO_AT) &&
(error = se_add_proto(sc, ETHERTYPE_AT)) != 0)
return error;
if ((sc->protos & PROTO_AARP) &&
(error = se_add_proto(sc, ETHERTYPE_AARP)) != 0)
return error;
#endif
if ((ifp->if_flags & (IFF_RUNNING|IFF_UP)) == IFF_UP) {
ifp->if_flags |= IFF_RUNNING;
@ -844,7 +868,8 @@ static int se_init(sc)
return error;
}
static int se_set_multi(sc, addr)
static int
se_set_multi(sc, addr)
struct se_softc *sc;
u_int8_t *addr;
{
@ -867,7 +892,8 @@ static int se_set_multi(sc, addr)
return error;
}
static int se_remove_multi(sc, addr)
static int
se_remove_multi(sc, addr)
struct se_softc *sc;
u_int8_t *addr;
{
@ -891,7 +917,8 @@ static int se_remove_multi(sc, addr)
}
#if 0 /* not used --thorpej */
static int sc_set_all_multi(sc, set)
static int
sc_set_all_multi(sc, set)
struct se_softc *sc;
int set;
{
@ -929,7 +956,8 @@ static int sc_set_all_multi(sc, set)
}
#endif /* not used */
static void se_stop(sc)
static void
se_stop(sc)
struct se_softc *sc;
{
/* Don't schedule any reads */
@ -942,7 +970,7 @@ static void se_stop(sc)
/*
* Process an ioctl request.
*/
int
static int
se_ioctl(ifp, cmd, data)
register struct ifnet *ifp;
u_long cmd;
@ -988,6 +1016,13 @@ se_ioctl(ifp, cmd, data)
error = se_init(sc);
break;
}
#endif
#ifdef NETATALK
case AF_APPLETALK:
sc->protos |= (PROTO_AT | PROTO_AARP);
if ((error = se_init(sc)) != 0)
break;
break;
#endif
default:
error = se_init(sc);

View File

@ -1,4 +1,4 @@
/* $NetBSD: scsi_ctron_ether.h,v 1.2 1997/03/24 00:04:55 thorpej Exp $ */
/* $NetBSD: scsi_ctron_ether.h,v 1.3 1997/04/04 19:02:44 matthias Exp $ */
/*
* SCSI interface description

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_se.c,v 1.4 1997/04/02 02:29:34 mycroft Exp $ */
/* $NetBSD: if_se.c,v 1.5 1997/04/04 19:02:43 matthias Exp $ */
/*
* Copyright (c) 1997 Ian W. Dall <ian.dall@dsto.defence.gov.au>
@ -84,6 +84,7 @@
#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>
@ -95,6 +96,10 @@
#include <netns/ns_if.h>
#endif
#ifdef NETATALK
#include <netatalk/at.h>
#endif
#if defined(CCITT) && defined(LLC)
#include <sys/socketvar.h>
#include <netccitt/x25.h>
@ -120,7 +125,8 @@
SE_PREFIX + ETHER_CRC)
#define RBUF_LEN (16 * 1024)
/* se_poll and se_poll0 are the normal polling rate and the
/*
* se_poll and se_poll0 are the normal polling rate and the
* minimum polling rate respectively. If se_poll0 should be
* chosen so that at maximum ethernet speed, we will read nearly
* full buffers. se_poll should be chosen for reasonable maximum
@ -160,9 +166,11 @@ struct se_softc {
char *sc_tbuf;
char *sc_rbuf;
int protos;
#define PROTO_IP 0x1
#define PROTO_ARP 0x2
#define PROTO_REVARP 0x4
#define PROTO_IP 0x01
#define PROTO_ARP 0x02
#define PROTO_REVARP 0x04
#define PROTO_AT 0x08
#define PROTO_AARP 0x10
int sc_debug;
int sc_flags;
#define SE_NEED_RECV 0x1
@ -171,23 +179,23 @@ struct se_softc {
cdev_decl(se);
#ifdef __BROKEN_INDIRECT_CONFIG
int sematch __P((struct device *, void *, void *));
static int sematch __P((struct device *, void *, void *));
#else
int sematch __P((struct device *, struct cfdata *, void *));
static int sematch __P((struct device *, struct cfdata *, void *));
#endif
void seattach __P((struct device *, struct device *, void *));
static void seattach __P((struct device *, struct device *, void *));
void se_ifstart __P((struct ifnet *));
void sestart __P((void *));
static void se_ifstart __P((struct ifnet *));
static void sestart __P((void *));
static void sedone __P((struct scsi_xfer *));
int se_ioctl __P((struct ifnet *, u_long, caddr_t));
void sewatchdog __P((struct ifnet *));
static int se_ioctl __P((struct ifnet *, u_long, caddr_t));
static void sewatchdog __P((struct ifnet *));
static __inline u_int16_t ether_cmp __P((void *, void *));
static void se_recv __P((void *));
static struct mbuf *se_get __P((struct se_softc *, char *, int));
static int se_read __P((struct se_softc *, char *, int));
void sewatchdog __P((struct ifnet *));
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 *));
@ -199,7 +207,7 @@ static int se_remove_multi __P((struct se_softc *, u_int8_t *));
static int sc_set_all_multi __P((struct se_softc *, int));
#endif
static void se_stop __P((struct se_softc *));
static __inline__ int se_scsi_cmd __P((struct scsi_link *sc_link,
static __inline int se_scsi_cmd __P((struct scsi_link *sc_link,
struct scsi_generic *scsi_cmd,
int cmdlen, u_char *data_addr, int datalen,
int retries, int timeout, struct buf *bp,
@ -226,17 +234,15 @@ struct scsi_inquiry_pattern se_patterns[] = {
{T_PROCESSOR, T_FIXED,
"CABLETRN", "EA412/14/19", ""},
{T_PROCESSOR, T_FIXED,
"Cabletrn", "EA412/14/19", ""},
"Cabletrn", "EA412/", ""},
};
static __inline__ u_int16_t ether_cmp __P((void *, void *));
/*
* Compare two Ether/802 addresses for equality, inlined and
* unrolled for speed.
* Note: use this like bcmp()
*/
static __inline__ u_int16_t
static __inline u_int16_t
ether_cmp(one, two)
void *one, *two;
{
@ -251,7 +257,7 @@ ether_cmp(one, two)
#define ETHER_CMP ether_cmp
int
static int
sematch(parent, match, aux)
struct device *parent;
#ifdef __BROKEN_INDIRECT_CONFIG
@ -274,7 +280,7 @@ sematch(parent, match, aux)
* The routine called by the low level scsi routine when it discovers
* a device suitable for this driver.
*/
void
static void
seattach(parent, self, aux)
struct device *parent, *self;
void *aux;
@ -285,6 +291,7 @@ seattach(parent, self, aux)
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
u_int8_t myaddr[ETHER_ADDR_LEN];
printf("\n");
SC_DEBUG(sc_link, SDEV_DB2, ("seattach: "));
/*
@ -334,7 +341,8 @@ seattach(parent, self, aux)
}
static __inline__ int se_scsi_cmd(sc_link, scsi_cmd, cmdlen, data_addr, datalen,
static __inline int
se_scsi_cmd(sc_link, scsi_cmd, cmdlen, data_addr, datalen,
retries, timeout, bp, flags)
struct scsi_link *sc_link;
struct scsi_generic *scsi_cmd;
@ -353,8 +361,11 @@ static __inline__ int se_scsi_cmd(sc_link, scsi_cmd, cmdlen, data_addr, datalen,
splx(s);
return error;
}
/* Start routine for calling from scsi sub system */
void sestart(void *v)
static void
sestart(v)
void *v;
{
struct se_softc *sc = (struct se_softc *) v;
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
@ -363,7 +374,9 @@ void sestart(void *v)
(void) splx(s);
}
static void se_delayed_ifstart(void *v)
static void
se_delayed_ifstart(v)
void *v;
{
struct ifnet *ifp = v;
int s = splnet();
@ -376,7 +389,7 @@ static void se_delayed_ifstart(void *v)
* Start transmission on the interface.
* Always called at splnet().
*/
void
static void
se_ifstart(ifp)
struct ifnet *ifp;
{
@ -510,7 +523,8 @@ sedone(xs)
splx(s);
}
static void se_recv(v)
static void
se_recv(v)
void *v;
{
/* do a recv command */
@ -527,7 +541,6 @@ static void se_recv(v)
SETIMEOUT, NULL, SCSI_NOSLEEP|SCSI_DATA_IN);
if (error)
timeout(se_recv, (void *)sc, se_poll);
}
/*
@ -674,7 +687,7 @@ se_read(sc, data, datalen)
}
void
static void
sewatchdog(ifp)
struct ifnet *ifp;
{
@ -706,7 +719,8 @@ se_reset(sc)
return error;
}
static int se_add_proto(sc, proto)
static int
se_add_proto(sc, proto)
struct se_softc *sc;
int proto;
{
@ -729,10 +743,10 @@ static int se_add_proto(sc, proto)
SERETRIES, SETIMEOUT, NULL,
SCSI_DATA_OUT);
return error;
}
static int se_get_addr(sc, myaddr)
static int
se_get_addr(sc, myaddr)
struct se_softc *sc;
u_int8_t *myaddr;
{
@ -753,7 +767,8 @@ static int se_get_addr(sc, myaddr)
}
static int se_set_media(sc, type)
static int
se_set_media(sc, type)
struct se_softc *sc;
int type;
{
@ -772,7 +787,8 @@ static int se_set_media(sc, type)
return error;
}
static int se_set_mode(sc, len, mode)
static int
se_set_mode(sc, len, mode)
struct se_softc *sc;
int len;
int mode;
@ -794,8 +810,8 @@ static int se_set_mode(sc, len, mode)
}
static int se_init(sc)
static int
se_init(sc)
struct se_softc *sc;
{
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
@ -834,6 +850,14 @@ static int se_init(sc)
if ((sc->protos & PROTO_REVARP) &&
(error = se_add_proto(sc, ETHERTYPE_REVARP)) != 0)
return error;
#ifdef NETATALK
if ((sc->protos & PROTO_AT) &&
(error = se_add_proto(sc, ETHERTYPE_AT)) != 0)
return error;
if ((sc->protos & PROTO_AARP) &&
(error = se_add_proto(sc, ETHERTYPE_AARP)) != 0)
return error;
#endif
if ((ifp->if_flags & (IFF_RUNNING|IFF_UP)) == IFF_UP) {
ifp->if_flags |= IFF_RUNNING;
@ -844,7 +868,8 @@ static int se_init(sc)
return error;
}
static int se_set_multi(sc, addr)
static int
se_set_multi(sc, addr)
struct se_softc *sc;
u_int8_t *addr;
{
@ -867,7 +892,8 @@ static int se_set_multi(sc, addr)
return error;
}
static int se_remove_multi(sc, addr)
static int
se_remove_multi(sc, addr)
struct se_softc *sc;
u_int8_t *addr;
{
@ -891,7 +917,8 @@ static int se_remove_multi(sc, addr)
}
#if 0 /* not used --thorpej */
static int sc_set_all_multi(sc, set)
static int
sc_set_all_multi(sc, set)
struct se_softc *sc;
int set;
{
@ -929,7 +956,8 @@ static int sc_set_all_multi(sc, set)
}
#endif /* not used */
static void se_stop(sc)
static void
se_stop(sc)
struct se_softc *sc;
{
/* Don't schedule any reads */
@ -942,7 +970,7 @@ static void se_stop(sc)
/*
* Process an ioctl request.
*/
int
static int
se_ioctl(ifp, cmd, data)
register struct ifnet *ifp;
u_long cmd;
@ -988,6 +1016,13 @@ se_ioctl(ifp, cmd, data)
error = se_init(sc);
break;
}
#endif
#ifdef NETATALK
case AF_APPLETALK:
sc->protos |= (PROTO_AT | PROTO_AARP);
if ((error = se_init(sc)) != 0)
break;
break;
#endif
default:
error = se_init(sc);

View File

@ -1,4 +1,4 @@
/* $NetBSD: scsi_ctron_ether.h,v 1.2 1997/03/24 00:04:55 thorpej Exp $ */
/* $NetBSD: scsi_ctron_ether.h,v 1.3 1997/04/04 19:02:44 matthias Exp $ */
/*
* SCSI interface description