if_fxpvar.h revision 66007
1239310Sdim/*
2239310Sdim * Copyright (c) 1995, David Greenman
3239310Sdim * All rights reserved.
4239310Sdim *
5239310Sdim * Modifications to support NetBSD:
6239310Sdim * Copyright (c) 1997 Jason R. Thorpe.  All rights reserved.
7239310Sdim *
8239310Sdim * Redistribution and use in source and binary forms, with or without
9239310Sdim * modification, are permitted provided that the following conditions
10239310Sdim * are met:
11239310Sdim * 1. Redistributions of source code must retain the above copyright
12239310Sdim *    notice unmodified, this list of conditions, and the following
13239310Sdim *    disclaimer.
14239310Sdim * 2. Redistributions in binary form must reproduce the above copyright
15239310Sdim *    notice, this list of conditions and the following disclaimer in the
16239310Sdim *    documentation and/or other materials provided with the distribution.
17239310Sdim *
18239310Sdim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19239310Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20239310Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21239310Sdim * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22239310Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23263508Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24263508Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25263508Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26239310Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27239310Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28249423Sdim * SUCH DAMAGE.
29249423Sdim *
30239310Sdim * $FreeBSD: head/sys/dev/fxp/if_fxpvar.h 66007 2000-09-17 22:12:12Z dg $
31263508Sdim */
32239310Sdim
33263508Sdim/*
34263508Sdim * Misc. defintions for the Intel EtherExpress Pro/100B PCI Fast
35263508Sdim * Ethernet driver
36263508Sdim */
37263508Sdim/*
38239310Sdim * NOTE: Elements are ordered for optimal cacheline behavior, and NOT
39249423Sdim *	 for functional grouping.
40239310Sdim */
41243830Sdimstruct fxp_softc {
42243830Sdim#if defined(__NetBSD__)
43239310Sdim	struct device sc_dev;		/* generic device structures */
44239310Sdim	void *sc_ih;			/* interrupt handler cookie */
45239310Sdim	struct ethercom sc_ethercom;	/* ethernet common part */
46239310Sdim#else
47239310Sdim	struct arpcom arpcom;		/* per-interface network data */
48239310Sdim	struct resource *mem;		/* resource descriptor for registers */
49239310Sdim	struct resource *irq;		/* resource descriptor for interrupt */
50239310Sdim	void *ih;			/* interrupt handler cookie */
51243830Sdim	struct mtx sc_mtx;
52243830Sdim#endif /* __NetBSD__ */
53243830Sdim	bus_space_tag_t sc_st;		/* bus space tag */
54243830Sdim	bus_space_handle_t sc_sh;	/* bus space handle */
55243830Sdim	struct mbuf *rfa_headm;		/* first mbuf in receive frame area */
56243830Sdim	struct mbuf *rfa_tailm;		/* last mbuf in receive frame area */
57243830Sdim	struct fxp_cb_tx *cbl_first;	/* first active TxCB in list */
58243830Sdim	int tx_queued;			/* # of active TxCB's */
59239310Sdim	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	int eeprom_size;		/* size of serial EEPROM */
72	int suspended;			/* 0 = normal  1 = suspended (APM) */
73	u_int32_t saved_maps[5];	/* pci data */
74	u_int32_t saved_biosaddr;
75	u_int8_t saved_intline;
76	u_int8_t saved_cachelnsz;
77	u_int8_t saved_lattimer;
78};
79
80/* Macros to ease CSR access. */
81#define	CSR_READ_1(sc, reg)						\
82	bus_space_read_1((sc)->sc_st, (sc)->sc_sh, (reg))
83#define	CSR_READ_2(sc, reg)						\
84	bus_space_read_2((sc)->sc_st, (sc)->sc_sh, (reg))
85#define	CSR_READ_4(sc, reg)						\
86	bus_space_read_4((sc)->sc_st, (sc)->sc_sh, (reg))
87#define	CSR_WRITE_1(sc, reg, val)					\
88	bus_space_write_1((sc)->sc_st, (sc)->sc_sh, (reg), (val))
89#define	CSR_WRITE_2(sc, reg, val)					\
90	bus_space_write_2((sc)->sc_st, (sc)->sc_sh, (reg), (val))
91#define	CSR_WRITE_4(sc, reg, val)					\
92	bus_space_write_4((sc)->sc_st, (sc)->sc_sh, (reg), (val))
93
94/* Deal with slight differences in software interfaces. */
95#if defined(__NetBSD__)
96#define	sc_if			sc_ethercom.ec_if
97#define	FXP_FORMAT		"%s"
98#define	FXP_ARGS(sc)		(sc)->sc_dev.dv_xname
99#define	FXP_INTR_TYPE		int
100#define	FXP_IOCTLCMD_TYPE	u_long
101#define	FXP_BPFTAP_ARG(ifp)	(ifp)->if_bpf
102#define	FXP_SPLVAR(x)		int x;
103#define	FXP_LOCK(sc, x)		x = splimp()
104#define	FXP_UNLOCK(sc, x)	splx(x)
105#else /* __FreeBSD__ */
106#define	sc_if			arpcom.ac_if
107#define	FXP_FORMAT		"fxp%d"
108#define	FXP_ARGS(sc)		(sc)->arpcom.ac_if.if_unit
109#define	FXP_INTR_TYPE		void
110#define	FXP_IOCTLCMD_TYPE	u_long
111#define	FXP_BPFTAP_ARG(ifp)	ifp
112#define	FXP_SPLVAR(s)
113#define	FXP_LOCK(_sc, x)	mtx_enter(&(_sc)->sc_mtx, MTX_DEF)
114#define	FXP_UNLOCK(_sc, x)	mtx_exit(&(_sc)->sc_mtx, MTX_DEF)
115#endif /* __NetBSD__ */
116