1997-09-05 10:23:58 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1995, David Greenman
|
|
|
|
* 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 unmodified, 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.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
|
|
|
|
*
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1997-09-05 10:23:58 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Misc. defintions for the Intel EtherExpress Pro/100B PCI Fast
|
|
|
|
* Ethernet driver
|
|
|
|
*/
|
2001-03-12 21:30:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Number of transmit control blocks. This determines the number
|
|
|
|
* of transmit buffers that can be chained in the CB list.
|
|
|
|
* This must be a power of two.
|
|
|
|
*/
|
|
|
|
#define FXP_NTXCB 128
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Number of completed TX commands at which point an interrupt
|
|
|
|
* will be generated to garbage collect the attached buffers.
|
|
|
|
* Must be at least one less than FXP_NTXCB, and should be
|
|
|
|
* enough less so that the transmitter doesn't becomes idle
|
|
|
|
* during the buffer rundown (which would reduce performance).
|
|
|
|
*/
|
|
|
|
#define FXP_CXINT_THRESH 120
|
|
|
|
|
|
|
|
/*
|
|
|
|
* TxCB list index mask. This is used to do list wrap-around.
|
|
|
|
*/
|
|
|
|
#define FXP_TXCB_MASK (FXP_NTXCB - 1)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Number of receive frame area buffers. These are large so chose
|
|
|
|
* wisely.
|
|
|
|
*/
|
|
|
|
#define FXP_NRFABUFS 64
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Maximum number of seconds that the receiver can be idle before we
|
|
|
|
* assume it's dead and attempt to reset it by reprogramming the
|
|
|
|
* multicast filter. This is part of a work-around for a bug in the
|
|
|
|
* NIC. See fxp_stats_update().
|
|
|
|
*/
|
|
|
|
#define FXP_MAX_RX_IDLE 15
|
|
|
|
|
2001-10-25 05:27:25 +00:00
|
|
|
/*
|
|
|
|
* Default maximum time, in microseconds, that an interrupt may be delayed
|
|
|
|
* in an attempt to coalesce interrupts. This is only effective if the Intel
|
|
|
|
* microcode is loaded, and may be changed via either loader tunables or
|
|
|
|
* sysctl. See also the CPUSAVER_DWORD entry in rcvbundl.h.
|
|
|
|
*/
|
|
|
|
#define TUNABLE_INT_DELAY 1000
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Default number of packets that will be bundled, before an interrupt is
|
|
|
|
* generated. This is only effective if the Intel microcode is loaded, and
|
|
|
|
* may be changed via either loader tunables or sysctl. This may not be
|
|
|
|
* present in all microcode revisions, see also the CPUSAVER_BUNDLE_MAX_DWORD
|
|
|
|
* entry in rcvbundl.h.
|
|
|
|
*/
|
|
|
|
#define TUNABLE_BUNDLE_MAX 6
|
|
|
|
|
2001-03-12 21:30:52 +00:00
|
|
|
#if __FreeBSD_version < 500000
|
|
|
|
#define FXP_LOCK(_sc)
|
|
|
|
#define FXP_UNLOCK(_sc)
|
|
|
|
#define mtx_init(a, b, c)
|
|
|
|
#define mtx_destroy(a)
|
|
|
|
struct mtx { int dummy; };
|
|
|
|
#else
|
|
|
|
#define FXP_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
|
|
|
|
#define FXP_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __alpha__
|
|
|
|
#undef vtophys
|
|
|
|
#define vtophys(va) alpha_XXX_dmamap((vm_offset_t)(va))
|
|
|
|
#endif /* __alpha__ */
|
|
|
|
|
1998-08-02 00:29:15 +00:00
|
|
|
/*
|
|
|
|
* NOTE: Elements are ordered for optimal cacheline behavior, and NOT
|
|
|
|
* for functional grouping.
|
|
|
|
*/
|
1997-09-05 10:23:58 +00:00
|
|
|
struct fxp_softc {
|
|
|
|
struct arpcom arpcom; /* per-interface network data */
|
1999-04-16 21:22:55 +00:00
|
|
|
struct resource *mem; /* resource descriptor for registers */
|
2001-01-23 23:22:17 +00:00
|
|
|
int rtp; /* register resource type */
|
|
|
|
int rgd; /* register descriptor in use */
|
1999-04-16 21:22:55 +00:00
|
|
|
struct resource *irq; /* resource descriptor for interrupt */
|
|
|
|
void *ih; /* interrupt handler cookie */
|
2000-09-17 13:26:25 +00:00
|
|
|
struct mtx sc_mtx;
|
1999-09-30 19:03:12 +00:00
|
|
|
bus_space_tag_t sc_st; /* bus space tag */
|
|
|
|
bus_space_handle_t sc_sh; /* bus space handle */
|
1998-08-02 00:29:15 +00:00
|
|
|
struct mbuf *rfa_headm; /* first mbuf in receive frame area */
|
|
|
|
struct mbuf *rfa_tailm; /* last mbuf in receive frame area */
|
1997-09-05 10:23:58 +00:00
|
|
|
struct fxp_cb_tx *cbl_first; /* first active TxCB in list */
|
1997-11-29 08:11:01 +00:00
|
|
|
int tx_queued; /* # of active TxCB's */
|
|
|
|
int need_mcsetup; /* multicast filter needs programming */
|
1998-08-02 00:29:15 +00:00
|
|
|
struct fxp_cb_tx *cbl_last; /* last active TxCB in list */
|
1997-09-05 10:23:58 +00:00
|
|
|
struct fxp_stats *fxp_stats; /* Pointer to interface stats */
|
1997-11-29 08:11:01 +00:00
|
|
|
int rx_idle_secs; /* # of seconds RX has been idle */
|
1997-09-21 22:02:25 +00:00
|
|
|
struct callout_handle stat_ch; /* Handle for canceling our stat timeout */
|
1998-08-02 00:29:15 +00:00
|
|
|
struct fxp_cb_tx *cbl_base; /* base of TxCB list */
|
1997-11-29 08:11:01 +00:00
|
|
|
struct fxp_cb_mcs *mcsp; /* Pointer to mcast setup descriptor */
|
1998-08-02 00:29:15 +00:00
|
|
|
struct ifmedia sc_media; /* media information */
|
2001-03-12 21:30:52 +00:00
|
|
|
device_t miibus;
|
|
|
|
device_t dev;
|
2001-10-25 05:27:25 +00:00
|
|
|
struct sysctl_ctx_list sysctl_ctx;
|
|
|
|
struct sysctl_oid *sysctl_tree;
|
|
|
|
int tunable_int_delay; /* interrupt delay value for ucode */
|
|
|
|
int tunable_bundle_max; /* max # frames per interrupt (ucode) */
|
2000-03-28 04:41:42 +00:00
|
|
|
int eeprom_size; /* size of serial EEPROM */
|
2000-09-17 22:12:12 +00:00
|
|
|
int suspended; /* 0 = normal 1 = suspended (APM) */
|
2001-05-17 23:50:24 +00:00
|
|
|
int cu_resume_bug;
|
2001-10-25 05:27:25 +00:00
|
|
|
int revision;
|
2001-03-12 21:30:52 +00:00
|
|
|
int flags;
|
2000-09-17 22:12:12 +00:00
|
|
|
u_int32_t saved_maps[5]; /* pci data */
|
|
|
|
u_int32_t saved_biosaddr;
|
|
|
|
u_int8_t saved_intline;
|
|
|
|
u_int8_t saved_cachelnsz;
|
|
|
|
u_int8_t saved_lattimer;
|
1997-09-05 10:23:58 +00:00
|
|
|
};
|
|
|
|
|
2001-03-12 21:30:52 +00:00
|
|
|
#define FXP_FLAG_MWI_ENABLE 0x0001 /* MWI enable */
|
|
|
|
#define FXP_FLAG_READ_ALIGN 0x0002 /* align read access with cacheline */
|
|
|
|
#define FXP_FLAG_WRITE_ALIGN 0x0004 /* end write on cacheline */
|
|
|
|
#define FXP_FLAG_EXT_TXCB 0x0008 /* enable use of extended TXCB */
|
|
|
|
#define FXP_FLAG_SERIAL_MEDIA 0x0010 /* 10Mbps serial interface */
|
|
|
|
#define FXP_FLAG_LONG_PKT_EN 0x0020 /* enable long packet reception */
|
|
|
|
#define FXP_FLAG_ALL_MCAST 0x0040 /* accept all multicast frames */
|
2001-05-17 23:50:24 +00:00
|
|
|
#define FXP_FLAG_CU_RESUME_BUG 0x0080 /* requires workaround for CU_RESUME */
|
2001-10-25 05:27:25 +00:00
|
|
|
#define FXP_FLAG_UCODE 0x0100 /* ucode is loaded */
|
2001-03-12 21:30:52 +00:00
|
|
|
|
1997-09-05 10:23:58 +00:00
|
|
|
/* Macros to ease CSR access. */
|
|
|
|
#define CSR_READ_1(sc, reg) \
|
|
|
|
bus_space_read_1((sc)->sc_st, (sc)->sc_sh, (reg))
|
|
|
|
#define CSR_READ_2(sc, reg) \
|
|
|
|
bus_space_read_2((sc)->sc_st, (sc)->sc_sh, (reg))
|
|
|
|
#define CSR_READ_4(sc, reg) \
|
|
|
|
bus_space_read_4((sc)->sc_st, (sc)->sc_sh, (reg))
|
|
|
|
#define CSR_WRITE_1(sc, reg, val) \
|
|
|
|
bus_space_write_1((sc)->sc_st, (sc)->sc_sh, (reg), (val))
|
|
|
|
#define CSR_WRITE_2(sc, reg, val) \
|
|
|
|
bus_space_write_2((sc)->sc_st, (sc)->sc_sh, (reg), (val))
|
|
|
|
#define CSR_WRITE_4(sc, reg, val) \
|
|
|
|
bus_space_write_4((sc)->sc_st, (sc)->sc_sh, (reg), (val))
|
|
|
|
|
|
|
|
#define sc_if arpcom.ac_if
|
2001-03-12 21:30:52 +00:00
|
|
|
|
2000-09-18 21:12:19 +00:00
|
|
|
#define FXP_UNIT(_sc) (_sc)->arpcom.ac_if.if_unit
|