Home | History | Annotate | Line # | Download | only in ic
i82596var.h revision 1.3
      1  1.3  tsutsui /* $NetBSD: i82596var.h,v 1.3 2005/02/18 22:39:31 tsutsui Exp $ */
      2  1.1    jkunz 
      3  1.1    jkunz /*
      4  1.1    jkunz  * Copyright (c) 2003 Jochen Kunz.
      5  1.1    jkunz  * All rights reserved.
      6  1.1    jkunz  *
      7  1.1    jkunz  * Redistribution and use in source and binary forms, with or without
      8  1.1    jkunz  * modification, are permitted provided that the following conditions
      9  1.1    jkunz  * are met:
     10  1.1    jkunz  * 1. Redistributions of source code must retain the above copyright
     11  1.1    jkunz  *    notice, this list of conditions and the following disclaimer.
     12  1.1    jkunz  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1    jkunz  *    notice, this list of conditions and the following disclaimer in the
     14  1.1    jkunz  *    documentation and/or other materials provided with the distribution.
     15  1.1    jkunz  * 3. The name of Jochen Kunz may not be used to endorse or promote
     16  1.1    jkunz  *    products derived from this software without specific prior
     17  1.1    jkunz  *    written permission.
     18  1.1    jkunz  *
     19  1.1    jkunz  * THIS SOFTWARE IS PROVIDED BY JOCHEN KUNZ
     20  1.1    jkunz  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  1.1    jkunz  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  1.1    jkunz  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL JOCHEN KUNZ
     23  1.1    jkunz  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  1.1    jkunz  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  1.1    jkunz  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  1.1    jkunz  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  1.1    jkunz  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  1.1    jkunz  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  1.1    jkunz  * POSSIBILITY OF SUCH DAMAGE.
     30  1.1    jkunz  */
     31  1.1    jkunz 
     32  1.1    jkunz /* All definitions are for a Intel 82596 DX/SX / CA in linear 32 bit mode. */
     33  1.1    jkunz 
     34  1.1    jkunz 
     35  1.1    jkunz 
     36  1.1    jkunz /* Supported chip variants */
     37  1.1    jkunz extern char *i82596_typenames[];
     38  1.1    jkunz enum i82596_types { I82596_UNKNOWN, I82596_DX, I82596_CA };
     39  1.1    jkunz 
     40  1.1    jkunz 
     41  1.1    jkunz 
     42  1.1    jkunz /* System Configuration Pointer */
     43  1.1    jkunz struct iee_scp {
     44  1.3  tsutsui 	volatile uint16_t scp_pad1;
     45  1.3  tsutsui 	volatile uint16_t scp_sysbus;		/* Sysbus Byte */
     46  1.3  tsutsui 	volatile uint32_t scp_pad2;
     47  1.3  tsutsui 	volatile uint32_t scp_iscp_addr;	/* Int. Sys. Conf. Pointer */
     48  1.2  tsutsui } __attribute__((__packed__));
     49  1.1    jkunz 
     50  1.1    jkunz 
     51  1.1    jkunz 
     52  1.1    jkunz /* Intermediate System Configuration Pointer */
     53  1.1    jkunz struct iee_iscp {
     54  1.3  tsutsui 	volatile uint16_t iscp_bussy;		/* Even Word, bits 0..15 */
     55  1.3  tsutsui 	volatile uint16_t iscp_pad;		/* Odd Word, bits 16..32 */
     56  1.3  tsutsui 	volatile uint32_t iscp_scb_addr;	/* address of SCB */
     57  1.2  tsutsui } __attribute__((__packed__));
     58  1.1    jkunz 
     59  1.1    jkunz 
     60  1.1    jkunz 
     61  1.1    jkunz /* System Control Block */
     62  1.1    jkunz struct iee_scb {
     63  1.3  tsutsui 	volatile uint16_t scb_status;		/* Status Bits */
     64  1.3  tsutsui 	volatile uint16_t scb_cmd;		/* Command Bits */
     65  1.3  tsutsui 	volatile uint32_t scb_cmd_blk_addr;	/* Command Block Address */
     66  1.3  tsutsui 	volatile uint32_t scb_rfa_addr;		/* Receive Frame Area Address */
     67  1.3  tsutsui 	volatile uint32_t scb_crc_err;		/* CRC Errors */
     68  1.3  tsutsui 	volatile uint32_t scb_align_err;	/* Alignment Errors */
     69  1.3  tsutsui 	volatile uint32_t scb_resource_err;	/* Resource Errors [1] */
     70  1.3  tsutsui 	volatile uint32_t scb_overrun_err;	/* Overrun Errors [1] */
     71  1.3  tsutsui 	volatile uint32_t scb_rcvcdt_err;	/* RCVCDT Errors [1] */
     72  1.3  tsutsui 	volatile uint32_t scb_short_fr_err;	/* Short Frame Errors */
     73  1.3  tsutsui 	volatile uint16_t scb_tt_off;		/* Bus Throtle Off Timer */
     74  1.3  tsutsui 	volatile uint16_t scb_tt_on;		/* Bus Throtle On Timer */
     75  1.2  tsutsui } __attribute__((__packed__));
     76  1.1    jkunz /* [1] In MONITOR mode these counters change function. */
     77  1.1    jkunz 
     78  1.1    jkunz 
     79  1.1    jkunz 
     80  1.1    jkunz /* Command Block */
     81  1.1    jkunz struct iee_cb {
     82  1.3  tsutsui 	volatile uint16_t cb_status;		/* Status Bits */
     83  1.3  tsutsui 	volatile uint16_t cb_cmd;		/* Command Bits */
     84  1.3  tsutsui 	volatile uint32_t cb_link_addr;		/* Link Address to next CMD */
     85  1.1    jkunz 	union {
     86  1.3  tsutsui 		volatile uint8_t cb_ind_addr[8];/* Individual Address */
     87  1.3  tsutsui 		volatile uint8_t cb_cf[16];	/* Configuration Bytes */
     88  1.1    jkunz 		struct {
     89  1.3  tsutsui 			volatile uint16_t mc_size;/* Num bytes of Mcast Addr.*/
     90  1.3  tsutsui 			volatile uint8_t mc_addrs[6]; /* List of Mcast Addr. */
     91  1.1    jkunz 		} cb_mcast;
     92  1.1    jkunz 		struct {
     93  1.3  tsutsui 			volatile uint32_t tx_tbd_addr;/* TX Buf. Descr. Addr.*/
     94  1.3  tsutsui 			volatile uint16_t tx_tcb_count; /* Len. of opt. data */
     95  1.3  tsutsui 			volatile uint16_t tx_pad;
     96  1.3  tsutsui 			volatile uint8_t tx_dest_addr[6]; /* Dest. Addr. */
     97  1.3  tsutsui 			volatile uint16_t tx_length; /* Length of data */
     98  1.3  tsutsui 			/* uint8_t data;	 Data to send, optional */
     99  1.1    jkunz 		} cb_transmit;
    100  1.3  tsutsui 		volatile uint32_t cb_tdr;	/* Time & Flags from TDR CMD */
    101  1.3  tsutsui 		volatile uint32_t cb_dump_addr;	/* Address of Dump buffer */
    102  1.1    jkunz 	};
    103  1.2  tsutsui } __attribute__((__packed__));
    104  1.1    jkunz 
    105  1.1    jkunz 
    106  1.1    jkunz 
    107  1.1    jkunz /* Transmit Buffer Descriptor */
    108  1.1    jkunz struct iee_tbd {
    109  1.3  tsutsui 	volatile uint16_t tbd_size;		/* Size of buffer & Flags */
    110  1.3  tsutsui 	volatile uint16_t tbd_pad;
    111  1.3  tsutsui 	volatile uint32_t tbd_link_addr;	/* Link Address to next RFD */
    112  1.3  tsutsui 	volatile uint32_t tbd_tb_addr;		/* Transmit Buffer Address */
    113  1.2  tsutsui } __attribute__((__packed__));
    114  1.1    jkunz 
    115  1.1    jkunz 
    116  1.1    jkunz 
    117  1.1    jkunz /* Receive Frame Descriptor */
    118  1.1    jkunz struct iee_rfd {
    119  1.3  tsutsui 	volatile uint16_t rfd_status;		/* Status Bits */
    120  1.3  tsutsui 	volatile uint16_t rfd_cmd;		/* Command Bits */
    121  1.3  tsutsui 	volatile uint32_t rfd_link_addr;	/* Link Address to next RFD */
    122  1.3  tsutsui 	volatile uint32_t rfd_rbd_addr;		/* Address of first free RBD */
    123  1.3  tsutsui 	volatile uint16_t rfd_count;		/* Actual Count */
    124  1.3  tsutsui 	volatile uint16_t rfd_size;		/* Size */
    125  1.3  tsutsui 	volatile uint8_t rfd_dest_addr[6];	/* Destiantion Address */
    126  1.3  tsutsui 	volatile uint8_t rfd_src_addr[6];	/* Source Address */
    127  1.3  tsutsui 	volatile uint16_t rfd_length;		/* Length Field */
    128  1.3  tsutsui 	volatile uint16_t rfd_pad;		/* Optional Data */
    129  1.2  tsutsui } __attribute__((__packed__));
    130  1.1    jkunz 
    131  1.1    jkunz 
    132  1.1    jkunz 
    133  1.1    jkunz /* Receive Buffer Descriptor */
    134  1.1    jkunz struct iee_rbd {
    135  1.3  tsutsui 	volatile uint16_t rbd_count;		/* Actual Cont of bytes */
    136  1.3  tsutsui 	volatile uint16_t rbd_pad1;
    137  1.3  tsutsui 	volatile uint32_t rbd_next_rbd;		/* Address of Next RBD */
    138  1.3  tsutsui 	volatile uint32_t rbd_rb_addr;		/* Receive Buffer Address */
    139  1.3  tsutsui 	volatile uint16_t rbd_size;		/* Size of Receive Buffer */
    140  1.3  tsutsui 	volatile uint16_t rbd_pad2;
    141  1.2  tsutsui } __attribute__((__packed__));
    142  1.1    jkunz 
    143  1.1    jkunz 
    144  1.1    jkunz 
    145  1.1    jkunz #define IEE_NRFD	32	/* Number of RFDs == length of receive queue */
    146  1.1    jkunz #define IEE_NCB		32	/* Number of Command Blocks == transmit queue */
    147  1.1    jkunz #define IEE_NTBD	16	/* Number of TBDs per CB */
    148  1.1    jkunz 
    149  1.1    jkunz 
    150  1.1    jkunz 
    151  1.1    jkunz struct iee_softc {
    152  1.1    jkunz 	struct device sc_dev;		/* common device data */
    153  1.1    jkunz 	struct ifmedia sc_ifmedia;	/* media interface */
    154  1.1    jkunz 	struct ethercom sc_ethercom;	/* ethernet speciffic stuff */
    155  1.1    jkunz 	enum i82596_types sc_type;
    156  1.1    jkunz 	bus_dma_tag_t sc_dmat;
    157  1.1    jkunz 	bus_dmamap_t sc_shmem_map;
    158  1.1    jkunz 	bus_dma_segment_t sc_dma_segs;
    159  1.1    jkunz 	bus_dmamap_t sc_rx_map[IEE_NRFD];
    160  1.1    jkunz 	bus_dmamap_t sc_tx_map[IEE_NCB];
    161  1.1    jkunz 	struct mbuf *sc_rx_mbuf[IEE_NRFD];
    162  1.1    jkunz 	struct mbuf *sc_tx_mbuf[IEE_NCB];
    163  1.1    jkunz 	caddr_t sc_shmem_addr;
    164  1.1    jkunz 	int sc_next_cb;
    165  1.1    jkunz 	int sc_next_tbd;
    166  1.1    jkunz 	int sc_rx_done;
    167  1.3  tsutsui 	uint8_t sc_cf[14];
    168  1.1    jkunz 	int sc_flags;
    169  1.1    jkunz 	int sc_cl_align;
    170  1.3  tsutsui 	uint32_t sc_crc_err;
    171  1.3  tsutsui 	uint32_t sc_align_err;
    172  1.3  tsutsui 	uint32_t sc_resource_err;
    173  1.3  tsutsui 	uint32_t sc_overrun_err;
    174  1.3  tsutsui 	uint32_t sc_rcvcdt_err;
    175  1.3  tsutsui 	uint32_t sc_short_fr_err;
    176  1.3  tsutsui 	uint32_t sc_receive_err;
    177  1.3  tsutsui 	uint32_t sc_tx_col;
    178  1.3  tsutsui 	uint32_t sc_rx_err;
    179  1.3  tsutsui 	uint32_t sc_cmd_err;
    180  1.3  tsutsui 	uint32_t sc_tx_timeout;
    181  1.3  tsutsui 	uint32_t sc_setup_timeout;
    182  1.3  tsutsui 	int (*sc_iee_cmd)(struct iee_softc *, uint32_t);
    183  1.1    jkunz 	int (*sc_iee_reset)(struct iee_softc *);
    184  1.1    jkunz 	void (*sc_mediastatus)(struct ifnet *, struct ifmediareq *);
    185  1.1    jkunz 	int (*sc_mediachange)(struct ifnet *);
    186  1.1    jkunz };
    187  1.1    jkunz 
    188  1.1    jkunz 
    189  1.1    jkunz 
    190  1.1    jkunz /* Flags */
    191  1.1    jkunz #define IEE_NEED_SWAP	0x01
    192  1.1    jkunz #define	IEE_WANT_MCAST	0x02
    193  1.1    jkunz 
    194  1.1    jkunz #define IEE_SWAP(x)	((sc->sc_flags & IEE_NEED_SWAP) == 0 ? x : 	\
    195  1.1    jkunz 			(((x) << 16) | ((x) >> 16)))
    196  1.3  tsutsui #define IEE_PHYS_SHMEM(x) ((uint32_t) (sc->sc_shmem_map->dm_segs[0].ds_addr \
    197  1.1    jkunz 			+ (x)))
    198  1.1    jkunz 
    199  1.1    jkunz 
    200  1.1    jkunz /* Offsets in shared memory */
    201  1.1    jkunz #define IEE_SCP_SZ	(((sizeof(struct iee_scp) - 1) / (sc)->sc_cl_align + 1)\
    202  1.1    jkunz 			* (sc)->sc_cl_align)
    203  1.1    jkunz #define IEE_SCP_OFF	0
    204  1.1    jkunz 
    205  1.1    jkunz #define IEE_ISCP_SZ	(((sizeof(struct iee_iscp) - 1) / (sc)->sc_cl_align + 1)\
    206  1.1    jkunz 			* (sc)->sc_cl_align)
    207  1.1    jkunz #define IEE_ISCP_OFF	IEE_SCP_SZ
    208  1.1    jkunz 
    209  1.1    jkunz #define IEE_SCB_SZ	(((sizeof(struct iee_scb) - 1) / (sc)->sc_cl_align + 1)\
    210  1.1    jkunz 			* (sc)->sc_cl_align)
    211  1.1    jkunz #define IEE_SCB_OFF	(IEE_SCP_SZ + IEE_ISCP_SZ)
    212  1.1    jkunz 
    213  1.1    jkunz #define IEE_RFD_SZ	(((sizeof(struct iee_rfd) - 1) / (sc)->sc_cl_align + 1)\
    214  1.1    jkunz 			* (sc)->sc_cl_align)
    215  1.1    jkunz #define IEE_RFD_LIST_SZ	(IEE_RFD_SZ * IEE_NRFD)
    216  1.1    jkunz #define IEE_RFD_OFF	(IEE_SCP_SZ + IEE_ISCP_SZ + IEE_SCB_SZ)
    217  1.1    jkunz 
    218  1.1    jkunz #define IEE_RBD_SZ	(((sizeof(struct iee_rbd) - 1) / (sc)->sc_cl_align + 1)\
    219  1.1    jkunz 			* (sc)->sc_cl_align)
    220  1.1    jkunz #define IEE_RBD_LIST_SZ	(IEE_RBD_SZ * IEE_NRFD)
    221  1.1    jkunz #define IEE_RBD_OFF	(IEE_SCP_SZ + IEE_ISCP_SZ + IEE_SCB_SZ		\
    222  1.1    jkunz 			+ IEE_RFD_SZ * IEE_NRFD)
    223  1.1    jkunz 
    224  1.1    jkunz #define IEE_CB_SZ	(((sizeof(struct iee_cb) - 1) / (sc)->sc_cl_align + 1)\
    225  1.1    jkunz 			* (sc)->sc_cl_align)
    226  1.1    jkunz #define IEE_CB_LIST_SZ	(IEE_CB_SZ * IEE_NCB)
    227  1.1    jkunz #define IEE_CB_OFF	(IEE_SCP_SZ + IEE_ISCP_SZ + IEE_SCB_SZ		\
    228  1.1    jkunz 			+ IEE_RFD_SZ * IEE_NRFD + IEE_RBD_SZ * IEE_NRFD)
    229  1.1    jkunz 
    230  1.1    jkunz #define IEE_TBD_SZ	(((sizeof(struct iee_tbd) - 1) / (sc)->sc_cl_align + 1)\
    231  1.1    jkunz 			* (sc)->sc_cl_align)
    232  1.1    jkunz #define IEE_TBD_LIST_SZ	(IEE_TBD_SZ * IEE_NTBD * IEE_NCB)
    233  1.1    jkunz #define IEE_TBD_OFF	(IEE_SCP_SZ + IEE_ISCP_SZ + IEE_SCB_SZ		\
    234  1.1    jkunz 			+ IEE_RFD_SZ * IEE_NRFD + IEE_RBD_SZ * IEE_NRFD	\
    235  1.1    jkunz 			+ IEE_CB_SZ * IEE_NCB)
    236  1.1    jkunz 
    237  1.1    jkunz #define IEE_SHMEM_MAX	(IEE_SCP_SZ + IEE_ISCP_SZ + IEE_SCB_SZ		\
    238  1.1    jkunz 			+ IEE_RFD_SZ * IEE_NRFD + IEE_RBD_SZ * IEE_NRFD	\
    239  1.1    jkunz 			+ IEE_CB_SZ * IEE_NCB + IEE_TBD_SZ * IEE_NTBD * IEE_NCB)
    240  1.1    jkunz 
    241  1.1    jkunz 
    242  1.1    jkunz #define SC_SCP		((struct iee_scp*)((sc)->sc_shmem_addr + IEE_SCP_OFF))
    243  1.1    jkunz #define SC_ISCP		((struct iee_iscp*)((sc)->sc_shmem_addr + IEE_ISCP_OFF))
    244  1.1    jkunz #define SC_SCB		((struct iee_scb*)((sc)->sc_shmem_addr + IEE_SCB_OFF))
    245  1.1    jkunz #define SC_RFD(n)	((struct iee_rfd*)((sc)->sc_shmem_addr + IEE_RFD_OFF \
    246  1.1    jkunz 				+ (n) * IEE_RFD_SZ))
    247  1.1    jkunz #define SC_RBD(n)	((struct iee_rbd*)((sc)->sc_shmem_addr + IEE_RBD_OFF \
    248  1.1    jkunz 				+ (n) * IEE_RBD_SZ))
    249  1.1    jkunz #define SC_CB(n)	((struct iee_cb*)((sc)->sc_shmem_addr + IEE_CB_OFF \
    250  1.1    jkunz 				+ (n) * IEE_CB_SZ))
    251  1.1    jkunz #define SC_TBD(n)	((struct iee_tbd*)((sc)->sc_shmem_addr + IEE_TBD_OFF \
    252  1.1    jkunz 				+ (n) * IEE_TBD_SZ))
    253  1.1    jkunz 
    254  1.1    jkunz 
    255  1.1    jkunz 
    256  1.3  tsutsui void iee_attach(struct iee_softc *, uint8_t *, int *, int, int);
    257  1.1    jkunz void iee_detach(struct iee_softc *, int);
    258  1.1    jkunz int iee_intr(void *);
    259  1.1    jkunz 
    260  1.1    jkunz 
    261  1.1    jkunz 
    262  1.1    jkunz 
    263