if_fxpvar.h revision 36735
129138Sdg/*
229138Sdg * Copyright (c) 1995, David Greenman
329138Sdg * All rights reserved.
429138Sdg *
529138Sdg * Modifications to support NetBSD:
629138Sdg * Copyright (c) 1997 Jason R. Thorpe.  All rights reserved.
729138Sdg *
829138Sdg * Redistribution and use in source and binary forms, with or without
929138Sdg * modification, are permitted provided that the following conditions
1029138Sdg * are met:
1129138Sdg * 1. Redistributions of source code must retain the above copyright
1229138Sdg *    notice unmodified, this list of conditions, and the following
1329138Sdg *    disclaimer.
1429138Sdg * 2. Redistributions in binary form must reproduce the above copyright
1529138Sdg *    notice, this list of conditions and the following disclaimer in the
1629138Sdg *    documentation and/or other materials provided with the distribution.
1729138Sdg *
1829138Sdg * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1929138Sdg * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2029138Sdg * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2129138Sdg * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2229138Sdg * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2329138Sdg * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2429138Sdg * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2529138Sdg * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2629138Sdg * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2729138Sdg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2829138Sdg * SUCH DAMAGE.
2929138Sdg *
3036735Sdfr *	$Id: if_fxpvar.h,v 1.4 1997/11/29 08:11:01 davidg Exp $
3129138Sdg */
3229138Sdg
3329138Sdg/*
3429138Sdg * Misc. defintions for the Intel EtherExpress Pro/100B PCI Fast
3529138Sdg * Ethernet driver
3629138Sdg */
3729138Sdg
3829138Sdgstruct fxp_softc {
3929138Sdg#if defined(__NetBSD__)
4029138Sdg	struct device sc_dev;		/* generic device structures */
4129138Sdg	void *sc_ih;			/* interrupt handler cookie */
4229138Sdg	bus_space_tag_t sc_st;		/* bus space tag */
4329138Sdg	bus_space_handle_t sc_sh;	/* bus space handle */
4429138Sdg	struct ethercom sc_ethercom;	/* ethernet common part */
4529138Sdg#else
4629138Sdg	struct arpcom arpcom;		/* per-interface network data */
4729138Sdg	caddr_t csr;			/* control/status registers */
4829138Sdg#endif /* __NetBSD__ */
4929138Sdg	struct ifmedia sc_media;	/* media information */
5029138Sdg	struct fxp_cb_tx *cbl_base;	/* base of TxCB list */
5129138Sdg	struct fxp_cb_tx *cbl_first;	/* first active TxCB in list */
5229138Sdg	struct fxp_cb_tx *cbl_last;	/* last active TxCB in list */
5331447Sdg	int tx_queued;			/* # of active TxCB's */
5431447Sdg	int need_mcsetup;		/* multicast filter needs programming */
5529138Sdg	struct mbuf *rfa_headm;		/* first mbuf in receive frame area */
5629138Sdg	struct mbuf *rfa_tailm;		/* last mbuf in receive frame area */
5729138Sdg	struct fxp_stats *fxp_stats;	/* Pointer to interface stats */
5831447Sdg	int rx_idle_secs;		/* # of seconds RX has been idle */
5929681Sgibbs	struct callout_handle stat_ch;	/* Handle for canceling our stat timeout */
6031447Sdg	struct fxp_cb_mcs *mcsp;	/* Pointer to mcast setup descriptor */
6131447Sdg	int all_mcasts;			/* receive all multicasts */
6229138Sdg	int promisc_mode;		/* promiscuous mode enabled */
6329138Sdg	int phy_primary_addr;		/* address of primary PHY */
6429138Sdg	int phy_primary_device;		/* device type of primary PHY */
6529138Sdg	int phy_10Mbps_only;		/* PHY is 10Mbps-only device */
6629138Sdg};
6729138Sdg
6829138Sdg/* Macros to ease CSR access. */
6929138Sdg#if defined(__NetBSD__)
7029138Sdg#define	CSR_READ_1(sc, reg)						\
7129138Sdg	bus_space_read_1((sc)->sc_st, (sc)->sc_sh, (reg))
7229138Sdg#define	CSR_READ_2(sc, reg)						\
7329138Sdg	bus_space_read_2((sc)->sc_st, (sc)->sc_sh, (reg))
7429138Sdg#define	CSR_READ_4(sc, reg)						\
7529138Sdg	bus_space_read_4((sc)->sc_st, (sc)->sc_sh, (reg))
7629138Sdg#define	CSR_WRITE_1(sc, reg, val)					\
7729138Sdg	bus_space_write_1((sc)->sc_st, (sc)->sc_sh, (reg), (val))
7829138Sdg#define	CSR_WRITE_2(sc, reg, val)					\
7929138Sdg	bus_space_write_2((sc)->sc_st, (sc)->sc_sh, (reg), (val))
8029138Sdg#define	CSR_WRITE_4(sc, reg, val)					\
8129138Sdg	bus_space_write_4((sc)->sc_st, (sc)->sc_sh, (reg), (val))
8229138Sdg#else
8329138Sdg#define	CSR_READ_1(sc, reg)						\
8429138Sdg	(*((u_int8_t *)((sc)->csr + (reg))))
8529138Sdg#define	CSR_READ_2(sc, reg)						\
8629138Sdg	(*((u_int16_t *)((sc)->csr + (reg))))
8729138Sdg#define	CSR_READ_4(sc, reg)						\
8829138Sdg	(*((u_int32_t *)((sc)->csr + (reg))))
8929138Sdg#define	CSR_WRITE_1(sc, reg, val)					\
9029138Sdg	(*((u_int8_t *)((sc)->csr + (reg)))) = (val)
9129138Sdg#define	CSR_WRITE_2(sc, reg, val)					\
9229138Sdg	(*((u_int16_t *)((sc)->csr + (reg)))) = (val)
9329138Sdg#define	CSR_WRITE_4(sc, reg, val)					\
9429138Sdg	(*((u_int32_t *)((sc)->csr + (reg)))) = (val)
9529138Sdg#endif /* __NetBSD__ */
9629138Sdg
9729138Sdg/* Deal with slight differences in software interfaces. */
9829138Sdg#if defined(__NetBSD__)
9929138Sdg#define	sc_if			sc_ethercom.ec_if
10029138Sdg#define	FXP_FORMAT		"%s"
10129138Sdg#define	FXP_ARGS(sc)		(sc)->sc_dev.dv_xname
10229138Sdg#define	FXP_INTR_TYPE		int
10329138Sdg#define	FXP_IOCTLCMD_TYPE	u_long
10429138Sdg#define	FXP_BPFTAP_ARG(ifp)	(ifp)->if_bpf
10529138Sdg#else /* __FreeBSD__ */
10629138Sdg#define	sc_if			arpcom.ac_if
10729138Sdg#define	FXP_FORMAT		"fxp%d"
10829138Sdg#define	FXP_ARGS(sc)		(sc)->arpcom.ac_if.if_unit
10929138Sdg#define	FXP_INTR_TYPE		void
11036735Sdfr#define	FXP_IOCTLCMD_TYPE	u_long
11129138Sdg#define	FXP_BPFTAP_ARG(ifp)	ifp
11229138Sdg#endif /* __NetBSD__ */
113