Home | History | Annotate | Line # | Download | only in ic
i82596var.h revision 1.11
      1  1.11  tsutsui /* $NetBSD: i82596var.h,v 1.11 2009/05/05 15:47:35 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.4    skrll extern const 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.9    perry } __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.9    perry } __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.9    perry } __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.9    perry } __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.9    perry } __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.6    skrll 	volatile uint8_t rfd_dest_addr[6];	/* Destination 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.9    perry } __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.9    perry } __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.10  tsutsui 	device_t sc_dev;		/* common device data */
    153   1.1    jkunz 	struct ifmedia sc_ifmedia;	/* media interface */
    154   1.6    skrll 	struct ethercom sc_ethercom;	/* ethernet specific 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.8  tsutsui 	uint8_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.11  tsutsui #define IEE_WANT_MCAST	0x02
    193  1.11  tsutsui #define IEE_REV_A	0x04
    194   1.1    jkunz 
    195  1.11  tsutsui /*
    196  1.11  tsutsui  * Rev A1 chip doesn't have 32-bit BE mode and all 32 bit pointers are
    197  1.11  tsutsui  * treated as two 16-bit big endian entities.
    198  1.11  tsutsui  */
    199  1.11  tsutsui #define IEE_SWAPA32(x)	((sc->sc_flags & (IEE_NEED_SWAP|IEE_REV_A)) ==	\
    200  1.11  tsutsui 			    (IEE_NEED_SWAP|IEE_REV_A) ?			\
    201  1.11  tsutsui 			    (((x) << 16) | ((x) >> 16)) : (x))
    202  1.11  tsutsui /*
    203  1.11  tsutsui  * The SCB absolute address and statistical counters are
    204  1.11  tsutsui  * always treated as two 16-bit big endian entities
    205  1.11  tsutsui  * even in 32-bit BE mode supported by Rev B and C chips.
    206  1.11  tsutsui  */
    207  1.11  tsutsui #define IEE_SWAP32(x)	((sc->sc_flags & IEE_NEED_SWAP) != 0 ? 		\
    208  1.11  tsutsui 			    (((x) << 16) | ((x) >> 16)) : (x))
    209   1.3  tsutsui #define IEE_PHYS_SHMEM(x) ((uint32_t) (sc->sc_shmem_map->dm_segs[0].ds_addr \
    210   1.1    jkunz 			+ (x)))
    211   1.1    jkunz 
    212   1.1    jkunz 
    213   1.1    jkunz /* Offsets in shared memory */
    214   1.1    jkunz #define IEE_SCP_SZ	(((sizeof(struct iee_scp) - 1) / (sc)->sc_cl_align + 1)\
    215   1.1    jkunz 			* (sc)->sc_cl_align)
    216   1.1    jkunz #define IEE_SCP_OFF	0
    217   1.1    jkunz 
    218   1.1    jkunz #define IEE_ISCP_SZ	(((sizeof(struct iee_iscp) - 1) / (sc)->sc_cl_align + 1)\
    219   1.1    jkunz 			* (sc)->sc_cl_align)
    220   1.1    jkunz #define IEE_ISCP_OFF	IEE_SCP_SZ
    221   1.1    jkunz 
    222   1.1    jkunz #define IEE_SCB_SZ	(((sizeof(struct iee_scb) - 1) / (sc)->sc_cl_align + 1)\
    223   1.1    jkunz 			* (sc)->sc_cl_align)
    224   1.1    jkunz #define IEE_SCB_OFF	(IEE_SCP_SZ + IEE_ISCP_SZ)
    225   1.1    jkunz 
    226   1.1    jkunz #define IEE_RFD_SZ	(((sizeof(struct iee_rfd) - 1) / (sc)->sc_cl_align + 1)\
    227   1.1    jkunz 			* (sc)->sc_cl_align)
    228   1.1    jkunz #define IEE_RFD_LIST_SZ	(IEE_RFD_SZ * IEE_NRFD)
    229   1.1    jkunz #define IEE_RFD_OFF	(IEE_SCP_SZ + IEE_ISCP_SZ + IEE_SCB_SZ)
    230   1.1    jkunz 
    231   1.1    jkunz #define IEE_RBD_SZ	(((sizeof(struct iee_rbd) - 1) / (sc)->sc_cl_align + 1)\
    232   1.1    jkunz 			* (sc)->sc_cl_align)
    233   1.1    jkunz #define IEE_RBD_LIST_SZ	(IEE_RBD_SZ * IEE_NRFD)
    234   1.1    jkunz #define IEE_RBD_OFF	(IEE_SCP_SZ + IEE_ISCP_SZ + IEE_SCB_SZ		\
    235   1.1    jkunz 			+ IEE_RFD_SZ * IEE_NRFD)
    236   1.1    jkunz 
    237   1.1    jkunz #define IEE_CB_SZ	(((sizeof(struct iee_cb) - 1) / (sc)->sc_cl_align + 1)\
    238   1.1    jkunz 			* (sc)->sc_cl_align)
    239   1.1    jkunz #define IEE_CB_LIST_SZ	(IEE_CB_SZ * IEE_NCB)
    240   1.1    jkunz #define IEE_CB_OFF	(IEE_SCP_SZ + IEE_ISCP_SZ + IEE_SCB_SZ		\
    241   1.1    jkunz 			+ IEE_RFD_SZ * IEE_NRFD + IEE_RBD_SZ * IEE_NRFD)
    242   1.1    jkunz 
    243   1.1    jkunz #define IEE_TBD_SZ	(((sizeof(struct iee_tbd) - 1) / (sc)->sc_cl_align + 1)\
    244   1.1    jkunz 			* (sc)->sc_cl_align)
    245   1.1    jkunz #define IEE_TBD_LIST_SZ	(IEE_TBD_SZ * IEE_NTBD * IEE_NCB)
    246   1.1    jkunz #define IEE_TBD_OFF	(IEE_SCP_SZ + IEE_ISCP_SZ + IEE_SCB_SZ		\
    247   1.1    jkunz 			+ IEE_RFD_SZ * IEE_NRFD + IEE_RBD_SZ * IEE_NRFD	\
    248   1.1    jkunz 			+ IEE_CB_SZ * IEE_NCB)
    249   1.1    jkunz 
    250   1.1    jkunz #define IEE_SHMEM_MAX	(IEE_SCP_SZ + IEE_ISCP_SZ + IEE_SCB_SZ		\
    251   1.1    jkunz 			+ IEE_RFD_SZ * IEE_NRFD + IEE_RBD_SZ * IEE_NRFD	\
    252   1.1    jkunz 			+ IEE_CB_SZ * IEE_NCB + IEE_TBD_SZ * IEE_NTBD * IEE_NCB)
    253   1.1    jkunz 
    254   1.1    jkunz 
    255   1.1    jkunz #define SC_SCP		((struct iee_scp*)((sc)->sc_shmem_addr + IEE_SCP_OFF))
    256   1.1    jkunz #define SC_ISCP		((struct iee_iscp*)((sc)->sc_shmem_addr + IEE_ISCP_OFF))
    257   1.1    jkunz #define SC_SCB		((struct iee_scb*)((sc)->sc_shmem_addr + IEE_SCB_OFF))
    258   1.1    jkunz #define SC_RFD(n)	((struct iee_rfd*)((sc)->sc_shmem_addr + IEE_RFD_OFF \
    259   1.1    jkunz 				+ (n) * IEE_RFD_SZ))
    260   1.1    jkunz #define SC_RBD(n)	((struct iee_rbd*)((sc)->sc_shmem_addr + IEE_RBD_OFF \
    261   1.1    jkunz 				+ (n) * IEE_RBD_SZ))
    262   1.1    jkunz #define SC_CB(n)	((struct iee_cb*)((sc)->sc_shmem_addr + IEE_CB_OFF \
    263   1.1    jkunz 				+ (n) * IEE_CB_SZ))
    264   1.1    jkunz #define SC_TBD(n)	((struct iee_tbd*)((sc)->sc_shmem_addr + IEE_TBD_OFF \
    265   1.1    jkunz 				+ (n) * IEE_TBD_SZ))
    266   1.1    jkunz 
    267   1.1    jkunz 
    268   1.1    jkunz 
    269   1.3  tsutsui void iee_attach(struct iee_softc *, uint8_t *, int *, int, int);
    270   1.1    jkunz void iee_detach(struct iee_softc *, int);
    271   1.1    jkunz int iee_intr(void *);
    272   1.1    jkunz 
    273   1.1    jkunz 
    274   1.1    jkunz 
    275   1.1    jkunz 
    276