2000-04-12 06:51:43 +00:00
|
|
|
/* $OpenBSD: if_txvar.h,v 1.7 1999/11/17 05:21:19 jason Exp $ */
|
1999-08-28 01:08:13 +00:00
|
|
|
/* $FreeBSD$ */
|
1998-11-01 07:44:33 +00:00
|
|
|
|
1998-01-21 18:33:00 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1997 Semen Ustimenko
|
|
|
|
* 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, 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Configuration
|
|
|
|
*/
|
2000-04-12 06:51:43 +00:00
|
|
|
/*#define EPIC_DEBUG 1*/
|
|
|
|
/*#define EPIC_USEIOSPACE 1*/
|
2002-04-19 22:43:57 +00:00
|
|
|
#define EPIC_EARLY_RX 1
|
2000-04-12 06:51:43 +00:00
|
|
|
|
1998-11-01 07:44:33 +00:00
|
|
|
#ifndef ETHER_MAX_LEN
|
|
|
|
#define ETHER_MAX_LEN 1518
|
|
|
|
#endif
|
|
|
|
#ifndef ETHER_MIN_LEN
|
|
|
|
#define ETHER_MIN_LEN 64
|
|
|
|
#endif
|
|
|
|
#ifndef ETHER_CRC_LEN
|
|
|
|
#define ETHER_CRC_LEN 4
|
|
|
|
#endif
|
|
|
|
#define TX_RING_SIZE 16 /* Leave this a power of 2 */
|
|
|
|
#define RX_RING_SIZE 16 /* And this too, to do not */
|
|
|
|
/* confuse RX(TX)_RING_MASK */
|
|
|
|
#define TX_RING_MASK (TX_RING_SIZE - 1)
|
|
|
|
#define RX_RING_MASK (RX_RING_SIZE - 1)
|
1998-01-21 18:33:00 +00:00
|
|
|
#define ETHER_MAX_FRAME_LEN (ETHER_MAX_LEN + ETHER_CRC_LEN)
|
2000-04-12 06:51:43 +00:00
|
|
|
|
1998-02-04 15:04:09 +00:00
|
|
|
/* This is driver's structure to define EPIC descriptors */
|
1998-01-21 18:33:00 +00:00
|
|
|
struct epic_rx_buffer {
|
1998-02-20 18:08:46 +00:00
|
|
|
struct mbuf * mbuf; /* mbuf receiving packet */
|
1998-01-21 18:33:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct epic_tx_buffer {
|
1998-02-04 15:04:09 +00:00
|
|
|
struct mbuf * mbuf; /* mbuf contained packet */
|
1998-01-21 18:33:00 +00:00
|
|
|
};
|
|
|
|
|
2001-02-07 20:11:02 +00:00
|
|
|
/* PHY, known by tx driver */
|
|
|
|
#define EPIC_UNKN_PHY 0x0000
|
|
|
|
#define EPIC_QS6612_PHY 0x0001
|
|
|
|
#define EPIC_AC101_PHY 0x0002
|
|
|
|
#define EPIC_LXT970_PHY 0x0003
|
|
|
|
#define EPIC_SERIAL 0x0004
|
|
|
|
|
1998-02-04 15:04:09 +00:00
|
|
|
/* Driver status structure */
|
1998-01-21 18:33:00 +00:00
|
|
|
typedef struct {
|
1999-05-22 06:10:14 +00:00
|
|
|
struct arpcom arpcom;
|
1998-11-01 07:44:33 +00:00
|
|
|
#if defined(__OpenBSD__)
|
2000-04-12 06:51:43 +00:00
|
|
|
mii_data_t sc_mii;
|
2000-06-21 19:19:49 +00:00
|
|
|
struct device dev;
|
2000-04-12 06:51:43 +00:00
|
|
|
#else /* __FreeBSD__ */
|
|
|
|
struct resource *res;
|
|
|
|
struct resource *irq;
|
|
|
|
|
|
|
|
device_t miibus;
|
2000-06-21 19:19:49 +00:00
|
|
|
device_t dev;
|
2000-04-12 06:51:43 +00:00
|
|
|
struct callout_handle stat_ch;
|
|
|
|
|
|
|
|
u_int32_t unit;
|
|
|
|
#endif
|
1998-11-01 07:44:33 +00:00
|
|
|
void *sc_ih;
|
|
|
|
bus_space_tag_t sc_st;
|
|
|
|
bus_space_handle_t sc_sh;
|
2000-04-12 06:51:43 +00:00
|
|
|
|
1998-01-21 18:33:00 +00:00
|
|
|
struct epic_rx_buffer rx_buffer[RX_RING_SIZE];
|
|
|
|
struct epic_tx_buffer tx_buffer[TX_RING_SIZE];
|
1998-02-20 18:08:46 +00:00
|
|
|
|
|
|
|
/* Each element of array MUST be aligned on dword */
|
|
|
|
/* and bounded on PAGE_SIZE */
|
|
|
|
struct epic_rx_desc *rx_desc;
|
|
|
|
struct epic_tx_desc *tx_desc;
|
|
|
|
struct epic_frag_list *tx_flist;
|
1998-07-04 08:02:46 +00:00
|
|
|
u_int32_t flags;
|
1998-11-01 07:44:33 +00:00
|
|
|
u_int32_t tx_threshold;
|
|
|
|
u_int32_t txcon;
|
2001-02-07 20:11:02 +00:00
|
|
|
u_int32_t miicfg;
|
1998-01-21 18:33:00 +00:00
|
|
|
u_int32_t cur_tx;
|
|
|
|
u_int32_t cur_rx;
|
|
|
|
u_int32_t dirty_tx;
|
|
|
|
u_int32_t pending_txs;
|
2001-02-07 20:11:02 +00:00
|
|
|
u_int16_t cardvend;
|
|
|
|
u_int16_t cardid;
|
|
|
|
struct mii_softc *physc;
|
|
|
|
u_int32_t phyid;
|
|
|
|
int serinst;
|
1998-01-21 18:33:00 +00:00
|
|
|
} epic_softc_t;
|
|
|
|
|
2000-04-12 06:51:43 +00:00
|
|
|
struct epic_type {
|
|
|
|
u_int16_t ven_id;
|
|
|
|
u_int16_t dev_id;
|
|
|
|
char *name;
|
|
|
|
};
|
|
|
|
|
|
|
|
#if defined(EPIC_DEBUG)
|
|
|
|
#define dprintf(a) printf a
|
|
|
|
#else
|
|
|
|
#define dprintf(a)
|
|
|
|
#endif
|
|
|
|
|
1998-11-01 07:44:33 +00:00
|
|
|
#if defined(__FreeBSD__)
|
|
|
|
#define EPIC_FORMAT "tx%d"
|
|
|
|
#define EPIC_ARGS(sc) (sc->unit)
|
2000-04-12 06:51:43 +00:00
|
|
|
#define EPIC_BPFTAP_ARG(ifp) ifp
|
1998-11-01 07:44:33 +00:00
|
|
|
#else /* __OpenBSD__ */
|
|
|
|
#define EPIC_FORMAT "%s"
|
|
|
|
#define EPIC_ARGS(sc) (sc->sc_dev.dv_xname)
|
2000-04-12 06:51:43 +00:00
|
|
|
#define EPIC_BPFTAP_ARG(ifp) (ifp)->if_bpf
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define sc_if arpcom.ac_if
|
1998-11-01 07:44:33 +00:00
|
|
|
#define sc_macaddr arpcom.ac_enaddr
|
2000-04-12 06:51:43 +00:00
|
|
|
|
1998-11-01 07:44:33 +00:00
|
|
|
#define CSR_WRITE_4(sc,reg,val) \
|
|
|
|
bus_space_write_4( (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_1(sc,reg,val) \
|
|
|
|
bus_space_write_1( (sc)->sc_st, (sc)->sc_sh, (reg), (val) )
|
|
|
|
#define CSR_READ_4(sc,reg) \
|
|
|
|
bus_space_read_4( (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_1(sc,reg) \
|
|
|
|
bus_space_read_1( (sc)->sc_st, (sc)->sc_sh, (reg) )
|
|
|
|
|
2000-04-12 06:51:43 +00:00
|
|
|
#define PHY_READ_2(sc,phy,reg) \
|
|
|
|
epic_read_phy_reg((sc),(phy),(reg))
|
|
|
|
#define PHY_WRITE_2(sc,phy,reg,val) \
|
|
|
|
epic_write_phy_reg((sc),(phy),(reg),(val))
|
|
|
|
|
|
|
|
/* Macro to get either mbuf cluster or nothing */
|
|
|
|
#define EPIC_MGETCLUSTER(m) \
|
|
|
|
{ MGETHDR((m),M_DONTWAIT,MT_DATA); \
|
|
|
|
if (m) { \
|
|
|
|
MCLGET((m),M_DONTWAIT); \
|
|
|
|
if( 0 == ((m)->m_flags & M_EXT) ) { \
|
|
|
|
m_freem(m); \
|
|
|
|
(m) = NULL; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
}
|
1998-01-21 18:33:00 +00:00
|
|
|
|