if_fxpvar.h revision 45720
1/*
2 * Copyright (c) 1995, David Greenman
3 * All rights reserved.
4 *
5 * Modifications to support NetBSD:
6 * Copyright (c) 1997 Jason R. Thorpe.  All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice unmodified, this list of conditions, and the following
13 *    disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in the
16 *    documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 *	$Id: if_fxpvar.h,v 1.6 1998/08/02 00:29:15 dg Exp $
31 */
32
33/*
34 * Misc. defintions for the Intel EtherExpress Pro/100B PCI Fast
35 * Ethernet driver
36 */
37/*
38 * NOTE: Elements are ordered for optimal cacheline behavior, and NOT
39 *	 for functional grouping.
40 */
41struct fxp_softc {
42#if defined(__NetBSD__)
43	struct device sc_dev;		/* generic device structures */
44	void *sc_ih;			/* interrupt handler cookie */
45	bus_space_tag_t sc_st;		/* bus space tag */
46	bus_space_handle_t sc_sh;	/* bus space handle */
47	struct ethercom sc_ethercom;	/* ethernet common part */
48#else
49	struct arpcom arpcom;		/* per-interface network data */
50	caddr_t csr;			/* control/status registers */
51	struct resource *mem;		/* resource descriptor for registers */
52	struct resource *irq;		/* resource descriptor for interrupt */
53	void *ih;			/* interrupt handler cookie */
54#endif /* __NetBSD__ */
55	struct mbuf *rfa_headm;		/* first mbuf in receive frame area */
56	struct mbuf *rfa_tailm;		/* last mbuf in receive frame area */
57	struct fxp_cb_tx *cbl_first;	/* first active TxCB in list */
58	int tx_queued;			/* # of active TxCB's */
59	int need_mcsetup;		/* multicast filter needs programming */
60	struct fxp_cb_tx *cbl_last;	/* last active TxCB in list */
61	struct fxp_stats *fxp_stats;	/* Pointer to interface stats */
62	int rx_idle_secs;		/* # of seconds RX has been idle */
63	struct callout_handle stat_ch;	/* Handle for canceling our stat timeout */
64	struct fxp_cb_tx *cbl_base;	/* base of TxCB list */
65	struct fxp_cb_mcs *mcsp;	/* Pointer to mcast setup descriptor */
66	int all_mcasts;			/* receive all multicasts */
67	struct ifmedia sc_media;	/* media information */
68	int phy_primary_addr;		/* address of primary PHY */
69	int phy_primary_device;		/* device type of primary PHY */
70	int phy_10Mbps_only;		/* PHY is 10Mbps-only device */
71};
72
73/* Macros to ease CSR access. */
74#if defined(__NetBSD__)
75#define	CSR_READ_1(sc, reg)						\
76	bus_space_read_1((sc)->sc_st, (sc)->sc_sh, (reg))
77#define	CSR_READ_2(sc, reg)						\
78	bus_space_read_2((sc)->sc_st, (sc)->sc_sh, (reg))
79#define	CSR_READ_4(sc, reg)						\
80	bus_space_read_4((sc)->sc_st, (sc)->sc_sh, (reg))
81#define	CSR_WRITE_1(sc, reg, val)					\
82	bus_space_write_1((sc)->sc_st, (sc)->sc_sh, (reg), (val))
83#define	CSR_WRITE_2(sc, reg, val)					\
84	bus_space_write_2((sc)->sc_st, (sc)->sc_sh, (reg), (val))
85#define	CSR_WRITE_4(sc, reg, val)					\
86	bus_space_write_4((sc)->sc_st, (sc)->sc_sh, (reg), (val))
87#else
88#define	CSR_READ_1(sc, reg)						\
89	(*((u_int8_t *)((sc)->csr + (reg))))
90#define	CSR_READ_2(sc, reg)						\
91	(*((u_int16_t *)((sc)->csr + (reg))))
92#define	CSR_READ_4(sc, reg)						\
93	(*((u_int32_t *)((sc)->csr + (reg))))
94#define	CSR_WRITE_1(sc, reg, val)					\
95	(*((u_int8_t *)((sc)->csr + (reg)))) = (val)
96#define	CSR_WRITE_2(sc, reg, val)					\
97	(*((u_int16_t *)((sc)->csr + (reg)))) = (val)
98#define	CSR_WRITE_4(sc, reg, val)					\
99	(*((u_int32_t *)((sc)->csr + (reg)))) = (val)
100#endif /* __NetBSD__ */
101
102/* Deal with slight differences in software interfaces. */
103#if defined(__NetBSD__)
104#define	sc_if			sc_ethercom.ec_if
105#define	FXP_FORMAT		"%s"
106#define	FXP_ARGS(sc)		(sc)->sc_dev.dv_xname
107#define	FXP_INTR_TYPE		int
108#define	FXP_IOCTLCMD_TYPE	u_long
109#define	FXP_BPFTAP_ARG(ifp)	(ifp)->if_bpf
110#else /* __FreeBSD__ */
111#define	sc_if			arpcom.ac_if
112#define	FXP_FORMAT		"fxp%d"
113#define	FXP_ARGS(sc)		(sc)->arpcom.ac_if.if_unit
114#define	FXP_INTR_TYPE		void
115#define	FXP_IOCTLCMD_TYPE	u_long
116#define	FXP_BPFTAP_ARG(ifp)	ifp
117#endif /* __NetBSD__ */
118