/*
* Copyright (c) 2003 Jochen Kunz.
* 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.
* 3. The name of Jochen Kunz may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY JOCHEN KUNZ
* ``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 JOCHEN KUNZ
* 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.
*/
/* All definitions are for a Intel 82596 DX/SX / CA in linear 32 bit mode. */
#define IEE_NRFD 32 /* Number of RFDs == length of receive queue */
#define IEE_NCB 32 /* Number of Command Blocks == transmit queue */
#define IEE_NTBD 16 /* Number of TBDs per CB */
struct iee_softc {
device_t sc_dev; /* common device data */
struct ifmedia sc_ifmedia; /* media interface */
struct ethercom sc_ethercom; /* ethernet specific stuff */
enum i82596_types sc_type;
bus_dma_tag_t sc_dmat;
bus_dmamap_t sc_shmem_map;
bus_dma_segment_t sc_dma_segs;
int sc_dma_rsegs;
bus_dmamap_t sc_rx_map[IEE_NRFD];
bus_dmamap_t sc_tx_map[IEE_NCB];
struct mbuf *sc_rx_mbuf[IEE_NRFD];
struct mbuf *sc_tx_mbuf[IEE_NCB];
uint8_t *sc_shmem_addr;
int sc_next_cb;
int sc_next_tbd;
int sc_rx_done;
uint8_t sc_cf[14];
int sc_flags;
int sc_cl_align;
int sc_scp_off;
int sc_scp_sz;
int sc_iscp_off;
int sc_iscp_sz;
int sc_scb_off;
int sc_scb_sz;
int sc_rfd_off;
int sc_rfd_sz;
int sc_rbd_off;
int sc_rbd_sz;
int sc_cb_off;
int sc_cb_sz;
int sc_tbd_off;
int sc_tbd_sz;
int sc_shmem_sz;
uint32_t sc_sysbus;
uint32_t sc_crc_err;
uint32_t sc_align_err;
uint32_t sc_resource_err;
uint32_t sc_overrun_err;
uint32_t sc_rcvcdt_err;
uint32_t sc_short_fr_err;
uint32_t sc_receive_err;
uint32_t sc_tx_col;
uint32_t sc_rx_err;
uint32_t sc_cmd_err;
uint32_t sc_tx_timeout;
uint32_t sc_setup_timeout;
int (*sc_iee_cmd)(struct iee_softc *, uint32_t);
int (*sc_iee_reset)(struct iee_softc *);
void (*sc_mediastatus)(struct ifnet *, struct ifmediareq *);
int (*sc_mediachange)(struct ifnet *);
};
/*
* Rev A1 chip doesn't have 32-bit BE mode and all 32 bit pointers are
* treated as two 16-bit big endian entities.
*/
#define IEE_SWAPA32(x) ((sc->sc_flags & (IEE_NEED_SWAP|IEE_REV_A)) == \
(IEE_NEED_SWAP|IEE_REV_A) ? \
(((x) << 16) | ((x) >> 16)) : (x))
/*
* The SCB absolute address and statistical counters are
* always treated as two 16-bit big endian entities
* even in 32-bit BE mode supported by Rev B and C chips.
*/
#define IEE_SWAP32(x) ((sc->sc_flags & IEE_NEED_SWAP) != 0 ? \
(((x) << 16) | ((x) >> 16)) : (x))
#define IEE_PHYS_SHMEM(x) ((uint32_t) (sc->sc_shmem_map->dm_segs[0].ds_addr \
+ (x)))